From: Guangbin Huang <huangguangbin2@huawei.com>
To: <davem@davemloft.net>, <kuba@kernel.org>, <mkubecek@suse.cz>,
<andrew@lunn.ch>, <amitc@mellanox.com>, <idosch@idosch.org>,
<danieller@nvidia.com>, <jesse.brandeburg@intel.com>,
<anthony.l.nguyen@intel.com>, <jdike@addtoit.com>,
<richard@nod.at>, <anton.ivanov@cambridgegreys.com>,
<netanel@amazon.com>, <akiyano@amazon.com>, <gtzalik@amazon.com>,
<saeedb@amazon.com>, <chris.snook@gmail.com>,
<ulli.kroll@googlemail.com>, <linus.walleij@linaro.org>,
<jeroendb@google.com>, <csully@google.com>,
<awogbemila@google.com>, <jdmason@kudzu.us>,
<rain.1986.08.12@gmail.com>, <zyjzyj2000@gmail.com>,
<kys@microsoft.com>, <haiyangz@microsoft.com>, <mst@redhat.com>,
<jasowang@redhat.com>, <doshir@vmware.com>,
<pv-drivers@vmware.com>, <jwi@linux.ibm.com>,
<kgraul@linux.ibm.com>, <hca@linux.ibm.com>, <gor@linux.ibm.com>,
<johannes@sipsolutions.net>
Cc: <netdev@vger.kernel.org>, <lipeng321@huawei.com>,
<chenhao288@hisilicon.com>, <huangguangbin2@huawei.com>,
<linux-s390@vger.kernel.org>
Subject: [PATCH V2 net-next 5/6] net: hns3: add support to set/get rx buf len via ethtool for hns3 driver
Date: Fri, 24 Sep 2021 22:29:58 +0800 [thread overview]
Message-ID: <20210924142959.7798-6-huangguangbin2@huawei.com> (raw)
In-Reply-To: <20210924142959.7798-1-huangguangbin2@huawei.com>
From: Hao Chen <chenhao288@hisilicon.com>
Rx buf len is for rx BD buffer size, support setting it via ethtool -G
parameter and getting it via ethtool -g parameter.
Signed-off-by: Hao Chen <chenhao288@hisilicon.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
.../ethernet/hisilicon/hns3/hns3_ethtool.c | 52 ++++++++++++++++---
1 file changed, 44 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index ed50b3b7b9e8..68512432d4b3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -645,7 +645,7 @@ static void hns3_get_ringparam(struct net_device *netdev,
{
struct hns3_nic_priv *priv = netdev_priv(netdev);
struct hnae3_handle *h = priv->ae_handle;
- int queue_num = h->kinfo.num_tqps;
+ int rx_queue_index = h->kinfo.num_tqps;
if (hns3_nic_resetting(netdev)) {
netdev_err(netdev, "dev resetting!");
@@ -656,7 +656,8 @@ static void hns3_get_ringparam(struct net_device *netdev,
param->rx_max_pending = HNS3_RING_MAX_PENDING;
param->tx_pending = priv->ring[0].desc_num;
- param->rx_pending = priv->ring[queue_num].desc_num;
+ param->rx_pending = priv->ring[rx_queue_index].desc_num;
+ param_ext->rx_buf_len = priv->ring[rx_queue_index].buf_size;
}
static void hns3_get_pauseparam(struct net_device *netdev,
@@ -1058,14 +1059,23 @@ static struct hns3_enet_ring *hns3_backup_ringparam(struct hns3_nic_priv *priv)
}
static int hns3_check_ringparam(struct net_device *ndev,
- struct ethtool_ringparam *param)
+ struct ethtool_ringparam *param,
+ struct ethtool_ringparam_ext *param_ext)
{
+#define RX_BUF_LEN_2K 2048
+#define RX_BUF_LEN_4K 4096
if (hns3_nic_resetting(ndev))
return -EBUSY;
if (param->rx_mini_pending || param->rx_jumbo_pending)
return -EINVAL;
+ if (param_ext->rx_buf_len != RX_BUF_LEN_2K &&
+ param_ext->rx_buf_len != RX_BUF_LEN_4K) {
+ netdev_err(ndev, "Rx buf len only support 2048 and 4096\n");
+ return -EINVAL;
+ }
+
if (param->tx_pending > HNS3_RING_MAX_PENDING ||
param->tx_pending < HNS3_RING_MIN_PENDING ||
param->rx_pending > HNS3_RING_MAX_PENDING ||
@@ -1078,6 +1088,22 @@ static int hns3_check_ringparam(struct net_device *ndev,
return 0;
}
+static int hns3_change_rx_buf_len(struct net_device *ndev, u32 rx_buf_len)
+{
+ struct hns3_nic_priv *priv = netdev_priv(ndev);
+ struct hnae3_handle *h = priv->ae_handle;
+ int i;
+
+ h->kinfo.rx_buf_len = rx_buf_len;
+
+ for (i = 0; i < h->kinfo.num_tqps; i++) {
+ h->kinfo.tqp[i]->buf_size = rx_buf_len;
+ priv->ring[i + h->kinfo.num_tqps].buf_size = rx_buf_len;
+ }
+
+ return 0;
+}
+
static int hns3_set_ringparam(struct net_device *ndev,
struct ethtool_ringparam *param,
struct ethtool_ringparam_ext *param_ext,
@@ -1090,9 +1116,10 @@ static int hns3_set_ringparam(struct net_device *ndev,
u32 old_tx_desc_num, new_tx_desc_num;
u32 old_rx_desc_num, new_rx_desc_num;
u16 queue_num = h->kinfo.num_tqps;
+ u32 old_rx_buf_len;
int ret, i;
- ret = hns3_check_ringparam(ndev, param);
+ ret = hns3_check_ringparam(ndev, param, param_ext);
if (ret)
return ret;
@@ -1101,8 +1128,10 @@ static int hns3_set_ringparam(struct net_device *ndev,
new_rx_desc_num = ALIGN(param->rx_pending, HNS3_RING_BD_MULTIPLE);
old_tx_desc_num = priv->ring[0].desc_num;
old_rx_desc_num = priv->ring[queue_num].desc_num;
+ old_rx_buf_len = priv->ring[queue_num].buf_size;
if (old_tx_desc_num == new_tx_desc_num &&
- old_rx_desc_num == new_rx_desc_num)
+ old_rx_desc_num == new_rx_desc_num &&
+ param_ext->rx_buf_len == old_rx_buf_len)
return 0;
tmp_rings = hns3_backup_ringparam(priv);
@@ -1113,19 +1142,22 @@ static int hns3_set_ringparam(struct net_device *ndev,
}
netdev_info(ndev,
- "Changing Tx/Rx ring depth from %u/%u to %u/%u\n",
+ "Changing Tx/Rx ring depth from %u/%u to %u/%u, Changing rx buffer len from %d to %d\n",
old_tx_desc_num, old_rx_desc_num,
- new_tx_desc_num, new_rx_desc_num);
+ new_tx_desc_num, new_rx_desc_num,
+ old_rx_buf_len, param_ext->rx_buf_len);
if (if_running)
ndev->netdev_ops->ndo_stop(ndev);
hns3_change_all_ring_bd_num(priv, new_tx_desc_num, new_rx_desc_num);
+ hns3_change_rx_buf_len(ndev, param_ext->rx_buf_len);
ret = hns3_init_all_ring(priv);
if (ret) {
- netdev_err(ndev, "Change bd num fail, revert to old value(%d)\n",
+ netdev_err(ndev, "set ringparam fail, revert to old value(%d)\n",
ret);
+ hns3_change_rx_buf_len(ndev, old_rx_buf_len);
hns3_change_all_ring_bd_num(priv, old_tx_desc_num,
old_rx_desc_num);
for (i = 0; i < h->kinfo.num_tqps * 2; i++)
@@ -1807,6 +1839,8 @@ static int hns3_set_tunable(struct net_device *netdev,
ETHTOOL_COALESCE_MAX_FRAMES | \
ETHTOOL_COALESCE_USE_CQE)
+#define HNS3_ETHTOOL_RING ETHTOOL_RING_USE_RX_BUF_LEN
+
static int hns3_get_ts_info(struct net_device *netdev,
struct ethtool_ts_info *info)
{
@@ -1885,6 +1919,7 @@ static int hns3_get_link_ext_state(struct net_device *netdev,
static const struct ethtool_ops hns3vf_ethtool_ops = {
.supported_coalesce_params = HNS3_ETHTOOL_COALESCE,
+ .supported_ring_params = HNS3_ETHTOOL_RING,
.get_drvinfo = hns3_get_drvinfo,
.get_ringparam = hns3_get_ringparam,
.set_ringparam = hns3_set_ringparam,
@@ -1916,6 +1951,7 @@ static const struct ethtool_ops hns3vf_ethtool_ops = {
static const struct ethtool_ops hns3_ethtool_ops = {
.supported_coalesce_params = HNS3_ETHTOOL_COALESCE,
+ .supported_ring_params = HNS3_ETHTOOL_RING,
.self_test = hns3_self_test,
.get_drvinfo = hns3_get_drvinfo,
.get_link = hns3_get_link,
--
2.33.0
next prev parent reply other threads:[~2021-09-24 14:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-24 14:29 [PATCH V2 net-next 0/6] ethtool: add support to set/get tx copybreak buf size and rx buf len Guangbin Huang
2021-09-24 14:29 ` [PATCH V2 net-next 1/6] ethtool: add support to set/get tx copybreak buf size via ethtool Guangbin Huang
2021-09-24 23:05 ` Michal Kubecek
2021-09-29 2:19 ` huangguangbin (A)
2021-09-24 14:29 ` [PATCH V2 net-next 2/6] net: hns3: add support to set/get tx copybreak buf size via ethtool for hns3 driver Guangbin Huang
2021-09-24 14:29 ` [PATCH V2 net-next 3/6] ethtool: add support to set/get rx buf len via ethtool Guangbin Huang
2021-09-24 17:47 ` Jakub Kicinski
2021-09-29 2:21 ` huangguangbin (A)
2021-09-24 23:14 ` Michal Kubecek
2021-09-29 2:33 ` huangguangbin (A)
2021-09-24 14:29 ` [PATCH V2 net-next 4/6] ethtool: extend ringparam setting uAPI with rx_buf_len Guangbin Huang
2021-09-24 14:57 ` Haiyang Zhang
2021-09-24 14:29 ` Guangbin Huang [this message]
2021-09-24 14:29 ` [PATCH V2 net-next 6/6] net: hns3: remove the way to set tx spare buf via module parameter Guangbin Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210924142959.7798-6-huangguangbin2@huawei.com \
--to=huangguangbin2@huawei.com \
--cc=akiyano@amazon.com \
--cc=amitc@mellanox.com \
--cc=andrew@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=anton.ivanov@cambridgegreys.com \
--cc=awogbemila@google.com \
--cc=chenhao288@hisilicon.com \
--cc=chris.snook@gmail.com \
--cc=csully@google.com \
--cc=danieller@nvidia.com \
--cc=davem@davemloft.net \
--cc=doshir@vmware.com \
--cc=gor@linux.ibm.com \
--cc=gtzalik@amazon.com \
--cc=haiyangz@microsoft.com \
--cc=hca@linux.ibm.com \
--cc=idosch@idosch.org \
--cc=jasowang@redhat.com \
--cc=jdike@addtoit.com \
--cc=jdmason@kudzu.us \
--cc=jeroendb@google.com \
--cc=jesse.brandeburg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=jwi@linux.ibm.com \
--cc=kgraul@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=kys@microsoft.com \
--cc=linus.walleij@linaro.org \
--cc=linux-s390@vger.kernel.org \
--cc=lipeng321@huawei.com \
--cc=mkubecek@suse.cz \
--cc=mst@redhat.com \
--cc=netanel@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=pv-drivers@vmware.com \
--cc=rain.1986.08.12@gmail.com \
--cc=richard@nod.at \
--cc=saeedb@amazon.com \
--cc=ulli.kroll@googlemail.com \
--cc=zyjzyj2000@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).