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>
Subject: [PATCH 2/2] net/nfp: implement the device packet type set interface
Date: Wed, 19 Jun 2024 18:11:34 +0800	[thread overview]
Message-ID: <20240619101134.3480274-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619101134.3480274-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>
---
 drivers/net/nfp/nfp_ethdev.c     |  7 +++++--
 drivers/net/nfp/nfp_net_common.c | 26 +++++++++++++++++++++++++-
 drivers/net/nfp/nfp_net_common.h |  1 +
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 9867db9729..b04bc955b5 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -414,8 +414,10 @@ nfp_net_start(struct rte_eth_dev *dev)
 
 	/* Enable packet type offload by extend ctrl word1. */
 	cap_extend = hw->cap_ext;
-	if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
-		ctrl_extend = NFP_NET_CFG_CTRL_PKT_TYPE;
+	if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_PTYPES) != 0) {
+		if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
+			ctrl_extend = NFP_NET_CFG_CTRL_PKT_TYPE;
+	}
 
 	if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_SECURITY) != 0 ||
 			(txmode->offloads & RTE_ETH_TX_OFFLOAD_SECURITY) != 0) {
@@ -884,6 +886,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 f8566d94d7..5616160686 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -1326,6 +1326,9 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SECURITY;
 	}
 
+	if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_PTYPES;
+
 	dev_info->default_rxconf = (struct rte_eth_rxconf) {
 		.rx_thresh = {
 			.pthresh = DEFAULT_RX_PTHRESH,
@@ -1461,13 +1464,34 @@ 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)
+{
+	struct rte_eth_rxmode *rxmode;
+
+	if (dev->data->dev_started != 0) {
+		PMD_DRV_LOG(ERR, "Please stop port %s", dev->data->name);
+		return -EBUSY;
+	}
+
+	rxmode = &dev->data->dev_conf.rxmode;
+
+	if (ptype_mask == 0)
+		rxmode->offloads &= ~RTE_ETH_RX_OFFLOAD_PTYPES;
+	else
+		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_PTYPES;
+
+	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 b5c6152857..b43f815951 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -291,6 +291,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-06-19 10:12 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 ` Chaoyong He [this message]
2024-09-26  7:16 ` [PATCH v2] net/nfp: implement the device packet type set interface Chaoyong He
2024-09-27  0:49   ` Ferruh Yigit
2024-09-27  3:10   ` [PATCH v3] " Chaoyong He
2024-09-27 23:50     ` 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=20240619101134.3480274-3-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).