Skip to content

Commit b26a6fe

Browse files
321lipengdavem330
authored andcommitted
net: hns3: Enable HW GRO for Rev B(=0x21) HNS3 hardware
HNS3 hardware Revision B(=0x21) supports Hardware GRO feature. This patch enables this feature in the HNS3 PF/VF driver. Signed-off-by: Peng Li <[email protected]> Signed-off-by: Salil Mehta <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ba2f55b commit b26a6fe

File tree

6 files changed

+83
-1
lines changed

6 files changed

+83
-1
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#define HNAE3_UNIC_CLIENT_INITED_B 0x4
5353
#define HNAE3_ROCE_CLIENT_INITED_B 0x5
5454
#define HNAE3_DEV_SUPPORT_FD_B 0x6
55+
#define HNAE3_DEV_SUPPORT_GRO_B 0x7
5556

5657
#define HNAE3_DEV_SUPPORT_ROCE_DCB_BITS (BIT(HNAE3_DEV_SUPPORT_DCB_B) |\
5758
BIT(HNAE3_DEV_SUPPORT_ROCE_B))
@@ -65,6 +66,9 @@
6566
#define hnae3_dev_fd_supported(hdev) \
6667
hnae3_get_bit((hdev)->ae_dev->flag, HNAE3_DEV_SUPPORT_FD_B)
6768

69+
#define hnae3_dev_gro_supported(hdev) \
70+
hnae3_get_bit((hdev)->ae_dev->flag, HNAE3_DEV_SUPPORT_GRO_B)
71+
6872
#define ring_ptr_move_fw(ring, p) \
6973
((ring)->p = ((ring)->p + 1) % (ring)->desc_num)
7074
#define ring_ptr_move_bw(ring, p) \

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,8 +1714,10 @@ static void hns3_disable_sriov(struct pci_dev *pdev)
17141714
static void hns3_get_dev_capability(struct pci_dev *pdev,
17151715
struct hnae3_ae_dev *ae_dev)
17161716
{
1717-
if (pdev->revision >= 0x21)
1717+
if (pdev->revision >= 0x21) {
17181718
hnae3_set_bit(ae_dev->flag, HNAE3_DEV_SUPPORT_FD_B, 1);
1719+
hnae3_set_bit(ae_dev->flag, HNAE3_DEV_SUPPORT_GRO_B, 1);
1720+
}
17191721
}
17201722

17211723
/* hns3_probe - Device initialization routine

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ enum hclge_opcode_type {
152152

153153
/* TSO command */
154154
HCLGE_OPC_TSO_GENERIC_CONFIG = 0x0C01,
155+
HCLGE_OPC_GRO_GENERIC_CONFIG = 0x0C10,
155156

156157
/* RSS commands */
157158
HCLGE_OPC_RSS_GENERIC_CONFIG = 0x0D01,
@@ -758,6 +759,12 @@ struct hclge_cfg_tso_status_cmd {
758759
u8 rsv[20];
759760
};
760761

762+
#define HCLGE_GRO_EN_B 0
763+
struct hclge_cfg_gro_status_cmd {
764+
__le16 gro_en;
765+
u8 rsv[22];
766+
};
767+
761768
#define HCLGE_TSO_MSS_MIN 256
762769
#define HCLGE_TSO_MSS_MAX 9668
763770

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,28 @@ static int hclge_config_tso(struct hclge_dev *hdev, int tso_mss_min,
921921
return hclge_cmd_send(&hdev->hw, &desc, 1);
922922
}
923923

924+
static int hclge_config_gro(struct hclge_dev *hdev, bool en)
925+
{
926+
struct hclge_cfg_gro_status_cmd *req;
927+
struct hclge_desc desc;
928+
int ret;
929+
930+
if (!hnae3_dev_gro_supported(hdev))
931+
return 0;
932+
933+
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_GRO_GENERIC_CONFIG, false);
934+
req = (struct hclge_cfg_gro_status_cmd *)desc.data;
935+
936+
req->gro_en = cpu_to_le16(en ? 1 : 0);
937+
938+
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
939+
if (ret)
940+
dev_err(&hdev->pdev->dev,
941+
"GRO hardware config cmd failed, ret = %d\n", ret);
942+
943+
return ret;
944+
}
945+
924946
static int hclge_alloc_tqps(struct hclge_dev *hdev)
925947
{
926948
struct hclge_tqp *tqp;
@@ -7090,6 +7112,10 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
70907112
goto err_mdiobus_unreg;
70917113
}
70927114

7115+
ret = hclge_config_gro(hdev, true);
7116+
if (ret)
7117+
goto err_mdiobus_unreg;
7118+
70937119
ret = hclge_init_vlan_config(hdev);
70947120
if (ret) {
70957121
dev_err(&pdev->dev, "VLAN init fail, ret =%d\n", ret);
@@ -7221,6 +7247,10 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev)
72217247
return ret;
72227248
}
72237249

7250+
ret = hclge_config_gro(hdev, true);
7251+
if (ret)
7252+
return ret;
7253+
72247254
ret = hclge_init_vlan_config(hdev);
72257255
if (ret) {
72267256
dev_err(&pdev->dev, "VLAN init fail, ret =%d\n", ret);

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ enum hclgevf_opcode_type {
8787
HCLGEVF_OPC_QUERY_TX_STATUS = 0x0B03,
8888
HCLGEVF_OPC_QUERY_RX_STATUS = 0x0B13,
8989
HCLGEVF_OPC_CFG_COM_TQP_QUEUE = 0x0B20,
90+
/* GRO command */
91+
HCLGEVF_OPC_GRO_GENERIC_CONFIG = 0x0C10,
9092
/* RSS cmd */
9193
HCLGEVF_OPC_RSS_GENERIC_CONFIG = 0x0D01,
9294
HCLGEVF_OPC_RSS_INPUT_TUPLE = 0x0D02,
@@ -149,6 +151,12 @@ struct hclgevf_query_res_cmd {
149151
__le16 rsv[7];
150152
};
151153

154+
#define HCLGEVF_GRO_EN_B 0
155+
struct hclgevf_cfg_gro_status_cmd {
156+
__le16 gro_en;
157+
u8 rsv[22];
158+
};
159+
152160
#define HCLGEVF_RSS_DEFAULT_OUTPORT_B 4
153161
#define HCLGEVF_RSS_HASH_KEY_OFFSET_B 4
154162
#define HCLGEVF_RSS_HASH_KEY_NUM 16

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,29 @@ static int hclgevf_init_roce_base_info(struct hclgevf_dev *hdev)
16551655
return 0;
16561656
}
16571657

1658+
static int hclgevf_config_gro(struct hclgevf_dev *hdev, bool en)
1659+
{
1660+
struct hclgevf_cfg_gro_status_cmd *req;
1661+
struct hclgevf_desc desc;
1662+
int ret;
1663+
1664+
if (!hnae3_dev_gro_supported(hdev))
1665+
return 0;
1666+
1667+
hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_GRO_GENERIC_CONFIG,
1668+
false);
1669+
req = (struct hclgevf_cfg_gro_status_cmd *)desc.data;
1670+
1671+
req->gro_en = cpu_to_le16(en ? 1 : 0);
1672+
1673+
ret = hclgevf_cmd_send(&hdev->hw, &desc, 1);
1674+
if (ret)
1675+
dev_err(&hdev->pdev->dev,
1676+
"VF GRO hardware config cmd failed, ret = %d.\n", ret);
1677+
1678+
return ret;
1679+
}
1680+
16581681
static int hclgevf_rss_init_hw(struct hclgevf_dev *hdev)
16591682
{
16601683
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
@@ -2122,6 +2145,10 @@ static int hclgevf_reset_hdev(struct hclgevf_dev *hdev)
21222145
return ret;
21232146
}
21242147

2148+
ret = hclgevf_config_gro(hdev, true);
2149+
if (ret)
2150+
return ret;
2151+
21252152
ret = hclgevf_init_vlan_config(hdev);
21262153
if (ret) {
21272154
dev_err(&hdev->pdev->dev,
@@ -2199,6 +2226,10 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
21992226
goto err_config;
22002227
}
22012228

2229+
ret = hclgevf_config_gro(hdev, true);
2230+
if (ret)
2231+
goto err_config;
2232+
22022233
/* Initialize RSS for this VF */
22032234
ret = hclgevf_rss_init_hw(hdev);
22042235
if (ret) {

0 commit comments

Comments
 (0)