DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Long Wu <long.wu@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH v3] net/nfp: implement the device packet type set interface
Date: Fri, 27 Sep 2024 11:10:54 +0800	[thread overview]
Message-ID: <20240927031054.3379687-1-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240926071620.3366399-1-chaoyong.he@corigine.com>

From: Long Wu <long.wu@corigine.com>

Using the Rx packet offload flag rather than the device
capability to control the packet type offload configuration.
Also implement the device packet type set interface to
let application can set the Rx packet offload flag.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>

---
V3:
* Also add entry in the 'nfp.ini' file.
V2:
* Following the advice from reviewer, abandon the modification of RTE
  layer.
---
 doc/guides/nics/features/nfp.ini |  1 +
 drivers/net/nfp/nfp_ethdev.c     |  1 +
 drivers/net/nfp/nfp_net_common.c | 42 +++++++++++++++++++++++++++++++-
 drivers/net/nfp/nfp_net_common.h |  1 +
 4 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 5b507cfe94..c3c282b288 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -22,6 +22,7 @@ QinQ offload         = Y
 FEC                  = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
+Packet type parsing  = Y
 Basic stats          = Y
 Stats per queue      = Y
 Linux                = Y
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index bd35df2dc9..09c15eedac 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -932,6 +932,7 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = {
 	.xstats_get_names_by_id = nfp_net_xstats_get_names_by_id,
 	.dev_infos_get          = nfp_net_infos_get,
 	.dev_supported_ptypes_get = nfp_net_supported_ptypes_get,
+	.dev_ptypes_set         = nfp_net_ptypes_set,
 	.mtu_set                = nfp_net_dev_mtu_set,
 	.mac_addr_set           = nfp_net_set_mac_addr,
 	.vlan_offload_set       = nfp_net_vlan_offload_set,
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 3d916cd147..0b71d55366 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -1459,13 +1459,53 @@ nfp_net_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)
 		return NULL;
 
 	net_hw = dev->data->dev_private;
-	if ((net_hw->super.ctrl_ext & NFP_NET_CFG_CTRL_PKT_TYPE) == 0)
+	if ((net_hw->super.cap_ext & NFP_NET_CFG_CTRL_PKT_TYPE) == 0)
 		return NULL;
 
 	*no_of_elements = RTE_DIM(ptypes);
 	return ptypes;
 }
 
+int
+nfp_net_ptypes_set(struct rte_eth_dev *dev,
+		uint32_t ptype_mask)
+{
+	int ret;
+	uint32_t update;
+	uint32_t ctrl_ext;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
+
+	net_hw = dev->data->dev_private;
+	hw = &net_hw->super;
+
+	if ((hw->cap_ext & NFP_NET_CFG_CTRL_PKT_TYPE) == 0)
+		return -ENOTSUP;
+
+	ctrl_ext = hw->ctrl_ext;
+	if (ptype_mask == 0) {
+		if ((ctrl_ext & NFP_NET_CFG_CTRL_PKT_TYPE) == 0)
+			return 0;
+
+		ctrl_ext &= ~NFP_NET_CFG_CTRL_PKT_TYPE;
+	} else {
+		if ((ctrl_ext & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
+			return 0;
+
+		ctrl_ext |= NFP_NET_CFG_CTRL_PKT_TYPE;
+	}
+
+	update = NFP_NET_CFG_UPDATE_GEN;
+
+	ret = nfp_ext_reconfig(hw, ctrl_ext, update);
+	if (ret != 0)
+		return ret;
+
+	hw->ctrl_ext = ctrl_ext;
+
+	return 0;
+}
+
 int
 nfp_rx_queue_intr_enable(struct rte_eth_dev *dev,
 		uint16_t queue_id)
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index bebb754ced..3c4d305b01 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -315,6 +315,7 @@ int nfp_net_infos_get(struct rte_eth_dev *dev,
 		struct rte_eth_dev_info *dev_info);
 const uint32_t *nfp_net_supported_ptypes_get(struct rte_eth_dev *dev,
 					     size_t *no_of_elements);
+int nfp_net_ptypes_set(struct rte_eth_dev *dev, uint32_t ptype_mask);
 int nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id);
 int nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
-- 
2.39.1


  parent reply	other threads:[~2024-09-27  3:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19 10:11 [PATCH 0/2] add Rx packet type offload control flag Chaoyong He
2024-06-19 10:11 ` [PATCH 1/2] ethdev: " Chaoyong He
2024-09-22 22:41   ` Ferruh Yigit
2024-09-24  2:03     ` Chaoyong He
2024-09-25 19:33       ` Ferruh Yigit
2024-09-26  2:15         ` Chaoyong He
2024-06-19 10:11 ` [PATCH 2/2] net/nfp: implement the device packet type set interface Chaoyong He
2024-09-26  7:16 ` [PATCH v2] " Chaoyong He
2024-09-27  0:49   ` Ferruh Yigit
2024-09-27  3:10   ` Chaoyong He [this message]
2024-09-27 23:50     ` [PATCH v3] " Ferruh Yigit

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=20240927031054.3379687-1-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=oss-drivers@corigine.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).