Skip to content

Commit 5c9f6b3

Browse files
321lipengdavem330
authored andcommitted
net: hns3: Add support for ethtool -K to enable/disable HW GRO
This patch adds support of ethtool -K to enable/disable hardware GRO in 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 e559709 commit 5c9f6b3

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ struct hnae3_ae_dev {
305305
* Set vlan filter config of vf
306306
* enable_hw_strip_rxvtag()
307307
* Enable/disable hardware strip vlan tag of packets received
308+
* set_gro_en
309+
* Enable/disable HW GRO
308310
*/
309311
struct hnae3_ae_ops {
310312
int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev);
@@ -449,6 +451,7 @@ struct hnae3_ae_ops {
449451
bool (*get_hw_reset_stat)(struct hnae3_handle *handle);
450452
bool (*ae_dev_resetting)(struct hnae3_handle *handle);
451453
unsigned long (*ae_dev_reset_cnt)(struct hnae3_handle *handle);
454+
int (*set_gro_en)(struct hnae3_handle *handle, int enable);
452455
};
453456

454457
struct hnae3_dcb_ops {

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,15 @@ static int hns3_nic_set_features(struct net_device *netdev,
13451345
priv->ops.maybe_stop_tx = hns3_nic_maybe_stop_tx;
13461346
}
13471347

1348+
if (changed & (NETIF_F_GRO_HW) && h->ae_algo->ops->set_gro_en) {
1349+
if (features & NETIF_F_GRO_HW)
1350+
ret = h->ae_algo->ops->set_gro_en(h, true);
1351+
else
1352+
ret = h->ae_algo->ops->set_gro_en(h, false);
1353+
if (ret)
1354+
return ret;
1355+
}
1356+
13481357
if ((changed & NETIF_F_HW_VLAN_CTAG_FILTER) &&
13491358
h->ae_algo->ops->enable_vlan_filter) {
13501359
if (features & NETIF_F_HW_VLAN_CTAG_FILTER)
@@ -1929,7 +1938,9 @@ static void hns3_set_default_feature(struct net_device *netdev)
19291938
NETIF_F_GSO_UDP_TUNNEL_CSUM | NETIF_F_SCTP_CRC;
19301939

19311940
if (pdev->revision >= 0x21) {
1932-
netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
1941+
netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER |
1942+
NETIF_F_GRO_HW;
1943+
netdev->features |= NETIF_F_GRO_HW;
19331944

19341945
if (!(h->flags & HNAE3_SUPPORT_VF)) {
19351946
netdev->hw_features |= NETIF_F_NTUPLE;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7667,6 +7667,14 @@ static void hclge_get_link_mode(struct hnae3_handle *handle,
76677667
}
76687668
}
76697669

7670+
static int hclge_gro_en(struct hnae3_handle *handle, int enable)
7671+
{
7672+
struct hclge_vport *vport = hclge_get_vport(handle);
7673+
struct hclge_dev *hdev = vport->back;
7674+
7675+
return hclge_config_gro(hdev, enable);
7676+
}
7677+
76707678
static const struct hnae3_ae_ops hclge_ops = {
76717679
.init_ae_dev = hclge_init_ae_dev,
76727680
.uninit_ae_dev = hclge_uninit_ae_dev,
@@ -7738,6 +7746,7 @@ static const struct hnae3_ae_ops hclge_ops = {
77387746
.get_hw_reset_stat = hclge_get_hw_reset_stat,
77397747
.ae_dev_resetting = hclge_ae_dev_resetting,
77407748
.ae_dev_reset_cnt = hclge_ae_dev_reset_cnt,
7749+
.set_gro_en = hclge_gro_en,
77417750
};
77427751

77437752
static struct hnae3_ae_algo ae_algo = {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,13 @@ void hclgevf_update_speed_duplex(struct hclgevf_dev *hdev, u32 speed,
23682368
hdev->hw.mac.duplex = duplex;
23692369
}
23702370

2371+
static int hclgevf_gro_en(struct hnae3_handle *handle, int enable)
2372+
{
2373+
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
2374+
2375+
return hclgevf_config_gro(hdev, enable);
2376+
}
2377+
23712378
static void hclgevf_get_media_type(struct hnae3_handle *handle,
23722379
u8 *media_type)
23732380
{
@@ -2442,6 +2449,7 @@ static const struct hnae3_ae_ops hclgevf_ops = {
24422449
.get_hw_reset_stat = hclgevf_get_hw_reset_stat,
24432450
.ae_dev_resetting = hclgevf_ae_dev_resetting,
24442451
.ae_dev_reset_cnt = hclgevf_ae_dev_reset_cnt,
2452+
.set_gro_en = hclgevf_gro_en,
24452453
};
24462454

24472455
static struct hnae3_ae_algo ae_algovf = {

0 commit comments

Comments
 (0)