Skip to content

Commit 1f702c1

Browse files
Jie Wangkuba-moo
authored andcommitted
net: hns3: add tx push support in hns3 ring param process
This patch adds tx push param to hns3 ring param and adapts the set and get API of ring params. So users can set it by cmd ethtool -G and get it by cmd ethtool -g. Signed-off-by: Jie Wang <[email protected]> Signed-off-by: Guangbin Huang <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent bde292c commit 1f702c1

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ static void hns3_get_ringparam(struct net_device *netdev,
664664
param->tx_pending = priv->ring[0].desc_num;
665665
param->rx_pending = priv->ring[rx_queue_index].desc_num;
666666
kernel_param->rx_buf_len = priv->ring[rx_queue_index].buf_size;
667+
kernel_param->tx_push = test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE,
668+
&priv->state);
667669
}
668670

669671
static void hns3_get_pauseparam(struct net_device *netdev,
@@ -1120,6 +1122,30 @@ static int hns3_change_rx_buf_len(struct net_device *ndev, u32 rx_buf_len)
11201122
return 0;
11211123
}
11221124

1125+
static int hns3_set_tx_push(struct net_device *netdev, u32 tx_push)
1126+
{
1127+
struct hns3_nic_priv *priv = netdev_priv(netdev);
1128+
struct hnae3_handle *h = hns3_get_handle(netdev);
1129+
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
1130+
u32 old_state = test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state);
1131+
1132+
if (!test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps) && tx_push)
1133+
return -EOPNOTSUPP;
1134+
1135+
if (tx_push == old_state)
1136+
return 0;
1137+
1138+
netdev_dbg(netdev, "Changing tx push from %s to %s\n",
1139+
old_state ? "on" : "off", tx_push ? "on" : "off");
1140+
1141+
if (tx_push)
1142+
set_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state);
1143+
else
1144+
clear_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state);
1145+
1146+
return 0;
1147+
}
1148+
11231149
static int hns3_set_ringparam(struct net_device *ndev,
11241150
struct ethtool_ringparam *param,
11251151
struct kernel_ethtool_ringparam *kernel_param,
@@ -1139,6 +1165,10 @@ static int hns3_set_ringparam(struct net_device *ndev,
11391165
if (ret)
11401166
return ret;
11411167

1168+
ret = hns3_set_tx_push(ndev, kernel_param->tx_push);
1169+
if (ret)
1170+
return ret;
1171+
11421172
/* Hardware requires that its descriptors must be multiple of eight */
11431173
new_tx_desc_num = ALIGN(param->tx_pending, HNS3_RING_BD_MULTIPLE);
11441174
new_rx_desc_num = ALIGN(param->rx_pending, HNS3_RING_BD_MULTIPLE);
@@ -1858,7 +1888,8 @@ static int hns3_set_tunable(struct net_device *netdev,
18581888
ETHTOOL_COALESCE_MAX_FRAMES | \
18591889
ETHTOOL_COALESCE_USE_CQE)
18601890

1861-
#define HNS3_ETHTOOL_RING ETHTOOL_RING_USE_RX_BUF_LEN
1891+
#define HNS3_ETHTOOL_RING (ETHTOOL_RING_USE_RX_BUF_LEN | \
1892+
ETHTOOL_RING_USE_TX_PUSH)
18621893

18631894
static int hns3_get_ts_info(struct net_device *netdev,
18641895
struct ethtool_ts_info *info)

0 commit comments

Comments
 (0)