Commit 1f702c16 authored by Jie Wang's avatar Jie Wang Committed by Jakub Kicinski

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: default avatarJie Wang <wangjie125@huawei.com>
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent bde292c0
...@@ -664,6 +664,8 @@ static void hns3_get_ringparam(struct net_device *netdev, ...@@ -664,6 +664,8 @@ static void hns3_get_ringparam(struct net_device *netdev,
param->tx_pending = priv->ring[0].desc_num; param->tx_pending = priv->ring[0].desc_num;
param->rx_pending = priv->ring[rx_queue_index].desc_num; param->rx_pending = priv->ring[rx_queue_index].desc_num;
kernel_param->rx_buf_len = priv->ring[rx_queue_index].buf_size; kernel_param->rx_buf_len = priv->ring[rx_queue_index].buf_size;
kernel_param->tx_push = test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE,
&priv->state);
} }
static void hns3_get_pauseparam(struct net_device *netdev, 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) ...@@ -1120,6 +1122,30 @@ static int hns3_change_rx_buf_len(struct net_device *ndev, u32 rx_buf_len)
return 0; return 0;
} }
static int hns3_set_tx_push(struct net_device *netdev, u32 tx_push)
{
struct hns3_nic_priv *priv = netdev_priv(netdev);
struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
u32 old_state = test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state);
if (!test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps) && tx_push)
return -EOPNOTSUPP;
if (tx_push == old_state)
return 0;
netdev_dbg(netdev, "Changing tx push from %s to %s\n",
old_state ? "on" : "off", tx_push ? "on" : "off");
if (tx_push)
set_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state);
else
clear_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state);
return 0;
}
static int hns3_set_ringparam(struct net_device *ndev, static int hns3_set_ringparam(struct net_device *ndev,
struct ethtool_ringparam *param, struct ethtool_ringparam *param,
struct kernel_ethtool_ringparam *kernel_param, struct kernel_ethtool_ringparam *kernel_param,
...@@ -1139,6 +1165,10 @@ static int hns3_set_ringparam(struct net_device *ndev, ...@@ -1139,6 +1165,10 @@ static int hns3_set_ringparam(struct net_device *ndev,
if (ret) if (ret)
return ret; return ret;
ret = hns3_set_tx_push(ndev, kernel_param->tx_push);
if (ret)
return ret;
/* Hardware requires that its descriptors must be multiple of eight */ /* Hardware requires that its descriptors must be multiple of eight */
new_tx_desc_num = ALIGN(param->tx_pending, HNS3_RING_BD_MULTIPLE); new_tx_desc_num = ALIGN(param->tx_pending, HNS3_RING_BD_MULTIPLE);
new_rx_desc_num = ALIGN(param->rx_pending, HNS3_RING_BD_MULTIPLE); 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, ...@@ -1858,7 +1888,8 @@ static int hns3_set_tunable(struct net_device *netdev,
ETHTOOL_COALESCE_MAX_FRAMES | \ ETHTOOL_COALESCE_MAX_FRAMES | \
ETHTOOL_COALESCE_USE_CQE) ETHTOOL_COALESCE_USE_CQE)
#define HNS3_ETHTOOL_RING ETHTOOL_RING_USE_RX_BUF_LEN #define HNS3_ETHTOOL_RING (ETHTOOL_RING_USE_RX_BUF_LEN | \
ETHTOOL_RING_USE_TX_PUSH)
static int hns3_get_ts_info(struct net_device *netdev, static int hns3_get_ts_info(struct net_device *netdev,
struct ethtool_ts_info *info) struct ethtool_ts_info *info)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment