netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 2/6] net: hns3: add support to set/get tx copybreak buf size via ethtool for hns3 driver
Date: Fri, 24 Sep 2021 22:29:55 +0800	[thread overview]
Message-ID: <20210924142959.7798-3-huangguangbin2@huawei.com> (raw)
In-Reply-To: <20210924142959.7798-1-huangguangbin2@huawei.com>

From: Hao Chen <chenhao288@hisilicon.com>

Tx copybreak buf size is used for tx copybreak feature, the feature is
used for small size packet or frag. It adds a queue based tx shared
bounce buffer to memcpy the small packet when the len of xmitted skb is
below tx_copybreak(value to distinguish small size and normal size),
and reduce the overhead of dma map and unmap when IOMMU is on.

Support setting it via ethtool --set-tunable parameter and getting
it via ethtool --get-tunable parameter.

Signed-off-by: Hao Chen <chenhao288@hisilicon.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   |  4 +-
 .../net/ethernet/hisilicon/hns3/hns3_enet.h   |  2 +
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    | 56 +++++++++++++++++++
 3 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index adc54a726661..345dddb2d691 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -5519,8 +5519,8 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
 	return 0;
 }
 
-static int hns3_reset_notify(struct hnae3_handle *handle,
-			     enum hnae3_reset_notify_type type)
+int hns3_reset_notify(struct hnae3_handle *handle,
+		      enum hnae3_reset_notify_type type)
 {
 	int ret = 0;
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index 6162d9f88e37..eefdcef341d2 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -705,6 +705,8 @@ void hns3_set_vector_coalesce_tx_ql(struct hns3_enet_tqp_vector *tqp_vector,
 				    u32 ql_value);
 
 void hns3_request_update_promisc_mode(struct hnae3_handle *handle);
+int hns3_reset_notify(struct hnae3_handle *handle,
+		      enum hnae3_reset_notify_type type);
 
 #ifdef CONFIG_HNS3_DCB
 void hns3_dcbnl_setup(struct hnae3_handle *handle);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 7ea511d59e91..c757e067f31f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -1691,6 +1691,7 @@ static int hns3_get_tunable(struct net_device *netdev,
 			    void *data)
 {
 	struct hns3_nic_priv *priv = netdev_priv(netdev);
+	struct hnae3_handle *h = priv->ae_handle;
 	int ret = 0;
 
 	switch (tuna->id) {
@@ -1701,6 +1702,9 @@ static int hns3_get_tunable(struct net_device *netdev,
 	case ETHTOOL_RX_COPYBREAK:
 		*(u32 *)data = priv->rx_copybreak;
 		break;
+	case ETHTOOL_TX_COPYBREAK_BUF_SIZE:
+		*(u32 *)data = h->kinfo.tx_spare_buf_size;
+		break;
 	default:
 		ret = -EOPNOTSUPP;
 		break;
@@ -1709,11 +1713,43 @@ static int hns3_get_tunable(struct net_device *netdev,
 	return ret;
 }
 
+static int hns3_set_tx_spare_buf_size(struct net_device *netdev,
+				      u32 data)
+{
+	struct hns3_nic_priv *priv = netdev_priv(netdev);
+	struct hnae3_handle *h = priv->ae_handle;
+	int ret;
+
+	if (hns3_nic_resetting(netdev))
+		return -EBUSY;
+
+	h->kinfo.tx_spare_buf_size = data;
+
+	ret = hns3_reset_notify(h, HNAE3_DOWN_CLIENT);
+	if (ret)
+		return ret;
+
+	ret = hns3_reset_notify(h, HNAE3_UNINIT_CLIENT);
+	if (ret)
+		return ret;
+
+	ret = hns3_reset_notify(h, HNAE3_INIT_CLIENT);
+	if (ret)
+		return ret;
+
+	ret = hns3_reset_notify(h, HNAE3_UP_CLIENT);
+	if (ret)
+		hns3_reset_notify(h, HNAE3_UNINIT_CLIENT);
+
+	return ret;
+}
+
 static int hns3_set_tunable(struct net_device *netdev,
 			    const struct ethtool_tunable *tuna,
 			    const void *data)
 {
 	struct hns3_nic_priv *priv = netdev_priv(netdev);
+	u32 old_tx_spare_buf_size, new_tx_spare_buf_size;
 	struct hnae3_handle *h = priv->ae_handle;
 	int i, ret = 0;
 
@@ -1731,6 +1767,26 @@ static int hns3_set_tunable(struct net_device *netdev,
 		for (i = h->kinfo.num_tqps; i < h->kinfo.num_tqps * 2; i++)
 			priv->ring[i].rx_copybreak = priv->rx_copybreak;
 
+		break;
+	case ETHTOOL_TX_COPYBREAK_BUF_SIZE:
+		old_tx_spare_buf_size = h->kinfo.tx_spare_buf_size;
+		new_tx_spare_buf_size = *(u32 *)data;
+		ret = hns3_set_tx_spare_buf_size(netdev, new_tx_spare_buf_size);
+		if (ret) {
+			int ret1;
+
+			netdev_warn(netdev,
+				    "change tx spare buf size fail, revert to old value\n");
+			ret1 = hns3_set_tx_spare_buf_size(netdev,
+							  old_tx_spare_buf_size);
+			if (ret1) {
+				netdev_err(netdev,
+					   "revert to old tx spare buf size fail\n");
+				return ret1;
+			}
+
+			return ret;
+		}
 		break;
 	default:
 		ret = -EOPNOTSUPP;
-- 
2.33.0


  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 ` Guangbin Huang [this message]
2021-09-24 14:29 ` [PATCH V2 net-next 3/6] ethtool: add support to set/get rx buf len " 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 ` [PATCH V2 net-next 5/6] net: hns3: add support to set/get rx buf len via ethtool for hns3 driver Guangbin Huang
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-3-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).