Skip to content

Commit 0a7b6d2

Browse files
Jie Wangdavem330
authored andcommitted
net: hns3: create new cmdq hardware description structure hclge_comm_hw
Currently PF and VF cmdq APIs use struct hclge(vf)_hw to describe cmdq hardware information needed by hclge(vf)_cmd_send. There are a little differences between its child struct hclge_cmq_ring and hclgevf_cmq_ring. It is redundent to use two sets of structures to support same functions. So this patch creates new set of common cmdq hardware description structures(hclge_comm_hw) to unify PF and VF cmdq functions. The struct hclge_desc is still kept to avoid too many meaningless replacement. These new structures will be used to unify hclge(vf)_hw structures in PF and VF cmdq APIs in next patches. Signed-off-by: Jie Wang <wangjie125@huawei.com> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5f20be4 commit 0a7b6d2

File tree

3 files changed

+57
-8
lines changed

3 files changed

+57
-8
lines changed

drivers/net/ethernet/hisilicon/hns3/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
ccflags-y += -I$(srctree)/$(src)
77
ccflags-y += -I$(srctree)/drivers/net/ethernet/hisilicon/hns3/hns3pf
88
ccflags-y += -I$(srctree)/drivers/net/ethernet/hisilicon/hns3/hns3vf
9+
ccflags-y += -I$(srctree)/drivers/net/ethernet/hisilicon/hns3/hns3_common
910

1011
obj-$(CONFIG_HNS3) += hnae3.o
1112

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* SPDX-License-Identifier: GPL-2.0+ */
2+
// Copyright (c) 2021-2021 Hisilicon Limited.
3+
4+
#ifndef __HCLGE_COMM_CMD_H
5+
#define __HCLGE_COMM_CMD_H
6+
#include <linux/types.h>
7+
8+
#include "hnae3.h"
9+
10+
#define HCLGE_DESC_DATA_LEN 6
11+
struct hclge_desc {
12+
__le16 opcode;
13+
__le16 flag;
14+
__le16 retval;
15+
__le16 rsv;
16+
__le32 data[HCLGE_DESC_DATA_LEN];
17+
};
18+
19+
struct hclge_comm_cmq_ring {
20+
dma_addr_t desc_dma_addr;
21+
struct hclge_desc *desc;
22+
struct pci_dev *pdev;
23+
u32 head;
24+
u32 tail;
25+
26+
u16 buf_size;
27+
u16 desc_num;
28+
int next_to_use;
29+
int next_to_clean;
30+
u8 ring_type; /* cmq ring type */
31+
spinlock_t lock; /* Command queue lock */
32+
};
33+
34+
enum hclge_comm_cmd_status {
35+
HCLGE_COMM_STATUS_SUCCESS = 0,
36+
HCLGE_COMM_ERR_CSQ_FULL = -1,
37+
HCLGE_COMM_ERR_CSQ_TIMEOUT = -2,
38+
HCLGE_COMM_ERR_CSQ_ERROR = -3,
39+
};
40+
41+
struct hclge_comm_cmq {
42+
struct hclge_comm_cmq_ring csq;
43+
struct hclge_comm_cmq_ring crq;
44+
u16 tx_timeout;
45+
enum hclge_comm_cmd_status last_status;
46+
};
47+
48+
struct hclge_comm_hw {
49+
void __iomem *io_base;
50+
void __iomem *mem_base;
51+
struct hclge_comm_cmq cmq;
52+
unsigned long comm_state;
53+
};
54+
55+
#endif

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,17 @@
77
#include <linux/io.h>
88
#include <linux/etherdevice.h>
99
#include "hnae3.h"
10+
#include "hclge_comm_cmd.h"
1011

1112
#define HCLGE_CMDQ_TX_TIMEOUT 30000
1213
#define HCLGE_CMDQ_CLEAR_WAIT_TIME 200
1314
#define HCLGE_DESC_DATA_LEN 6
1415

1516
struct hclge_dev;
16-
struct hclge_desc {
17-
__le16 opcode;
1817

1918
#define HCLGE_CMDQ_RX_INVLD_B 0
2019
#define HCLGE_CMDQ_RX_OUTVLD_B 1
2120

22-
__le16 flag;
23-
__le16 retval;
24-
__le16 rsv;
25-
__le32 data[HCLGE_DESC_DATA_LEN];
26-
};
27-
2821
struct hclge_cmq_ring {
2922
dma_addr_t desc_dma_addr;
3023
struct hclge_desc *desc;

0 commit comments

Comments
 (0)