DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] add Rx packet type offload control flag
@ 2024-06-19 10:11 Chaoyong He
  2024-06-19 10:11 ` [PATCH 1/2] ethdev: " Chaoyong He
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Chaoyong He @ 2024-06-19 10:11 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series add a control flag used for Rx packet type offload.

Long Wu (2):
  ethdev: add Rx packet type offload control flag
  net/nfp: implement the device packet type set interface

 drivers/net/nfp/nfp_ethdev.c     |  7 +++++--
 drivers/net/nfp/nfp_net_common.c | 26 +++++++++++++++++++++++++-
 drivers/net/nfp/nfp_net_common.h |  1 +
 lib/ethdev/rte_ethdev.h          |  1 +
 4 files changed, 32 insertions(+), 3 deletions(-)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] ethdev: add Rx packet type offload control flag
  2024-06-19 10:11 [PATCH 0/2] add Rx packet type offload control flag Chaoyong He
@ 2024-06-19 10:11 ` Chaoyong He
  2024-09-22 22:41   ` Ferruh Yigit
  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
  2 siblings, 1 reply; 11+ messages in thread
From: Chaoyong He @ 2024-06-19 10:11 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu

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

The Rx packet type offload feature may affect the performance,
so add a control flag for applications to turn it on or off.

Signed-off-by: Long Wu <long.wu@corigine.com>
---
 lib/ethdev/rte_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 548fada1c7..be86983e24 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -1555,6 +1555,7 @@ struct rte_eth_conf {
 #define RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(18)
 #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
 #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
+#define RTE_ETH_RX_OFFLOAD_PTYPES           RTE_BIT64(21)
 
 #define RTE_ETH_RX_OFFLOAD_CHECKSUM (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
 				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/2] net/nfp: implement the device packet type set interface
  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-06-19 10:11 ` Chaoyong He
  2024-09-26  7:16 ` [PATCH v2] " Chaoyong He
  2 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-06-19 10:11 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] ethdev: add Rx packet type offload control flag
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Ferruh Yigit @ 2024-09-22 22:41 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Long Wu

On 6/19/2024 11:11 AM, Chaoyong He wrote:
> From: Long Wu <long.wu@corigine.com>
> 
> The Rx packet type offload feature may affect the performance,
> so add a control flag for applications to turn it on or off.
> 
> Signed-off-by: Long Wu <long.wu@corigine.com>
> ---
>  lib/ethdev/rte_ethdev.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
> index 548fada1c7..be86983e24 100644
> --- a/lib/ethdev/rte_ethdev.h
> +++ b/lib/ethdev/rte_ethdev.h
> @@ -1555,6 +1555,7 @@ struct rte_eth_conf {
>  #define RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(18)
>  #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
>  #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
> +#define RTE_ETH_RX_OFFLOAD_PTYPES           RTE_BIT64(21)
>  
>  #define RTE_ETH_RX_OFFLOAD_CHECKSUM (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
>  				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \

Hi Chaoyong,

Instead of having an offload for ptypes, we have APIs for this,

First one is 'rte_eth_dev_get_supported_ptypes()' that application can
learn the supported packet types.

Second one is more related to above flag, it is
'rte_eth_dev_set_ptypes()' which application can set which pytpes is
required, it can be set to disable all packet type parsing, can be
similar to not requesting 'RTE_ETH_RX_OFFLOAD_PTYPES'.

With above two APIs, do we still need the offload flag?


Another concern with adding new offload flag is backward compatibility,
all existing drivers that support packet type parsing should be updated
to list this offload flag as capability. Also they need to be updated to
configure packet parsing based on user requested offload configuration.

Briefly, we can't just introduce a new offload flag for an existing
capability and update only one driver, all drivers needs to be updated.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH 1/2] ethdev: add Rx packet type offload control flag
  2024-09-22 22:41   ` Ferruh Yigit
@ 2024-09-24  2:03     ` Chaoyong He
  2024-09-25 19:33       ` Ferruh Yigit
  0 siblings, 1 reply; 11+ messages in thread
From: Chaoyong He @ 2024-09-24  2:03 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: oss-drivers, Long Wu

> On 6/19/2024 11:11 AM, Chaoyong He wrote:
> > From: Long Wu <long.wu@corigine.com>
> >
> > The Rx packet type offload feature may affect the performance, so add
> > a control flag for applications to turn it on or off.
> >
> > Signed-off-by: Long Wu <long.wu@corigine.com>
> > ---
> >  lib/ethdev/rte_ethdev.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index
> > 548fada1c7..be86983e24 100644
> > --- a/lib/ethdev/rte_ethdev.h
> > +++ b/lib/ethdev/rte_ethdev.h
> > @@ -1555,6 +1555,7 @@ struct rte_eth_conf {  #define
> > RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(18)
> >  #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
> >  #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
> > +#define RTE_ETH_RX_OFFLOAD_PTYPES           RTE_BIT64(21)
> >
> >  #define RTE_ETH_RX_OFFLOAD_CHECKSUM
> (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
> >  				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
> 
> Hi Chaoyong,
> 
> Instead of having an offload for ptypes, we have APIs for this,
> 
> First one is 'rte_eth_dev_get_supported_ptypes()' that application can learn
> the supported packet types.
> 
> Second one is more related to above flag, it is 'rte_eth_dev_set_ptypes()'
> which application can set which pytpes is required, it can be set to disable all
> packet type parsing, can be similar to not requesting
> 'RTE_ETH_RX_OFFLOAD_PTYPES'.
> 
> With above two APIs, do we still need the offload flag?
> 

At present, the purpose of the ops 'rte_eth_dev_set_ptypes()' is to set the range of packet types to handle.
Of course, we can maintain a flag for each application and driver based on the return value of this ops;
but this is a bit troublesome.
So, we hope to follow the example of RSS, in addition to
'rte_eth_dev_rss_hash_update()' and 'rte_eth_dev_rss_hash_conf_get()', we also want to set a flag for
the ptype function similar to RTE_ETH_RX_OFFLOAD_RSS_HASH.

> 
> Another concern with adding new offload flag is backward compatibility, all
> existing drivers that support packet type parsing should be updated to list this
> offload flag as capability. Also they need to be updated to configure packet
> parsing based on user requested offload configuration.
> 

If you agree with this design suggestion, we will adapt all the related code to ptypes for each PMDs and 'test-pmd' applications in the next patch.
Do you think this okay?

> Briefly, we can't just introduce a new offload flag for an existing capability and
> update only one driver, all drivers needs to be updated.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] ethdev: add Rx packet type offload control flag
  2024-09-24  2:03     ` Chaoyong He
@ 2024-09-25 19:33       ` Ferruh Yigit
  2024-09-26  2:15         ` Chaoyong He
  0 siblings, 1 reply; 11+ messages in thread
From: Ferruh Yigit @ 2024-09-25 19:33 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Long Wu

On 9/24/2024 3:03 AM, Chaoyong He wrote:
>> On 6/19/2024 11:11 AM, Chaoyong He wrote:
>>> From: Long Wu <long.wu@corigine.com>
>>>
>>> The Rx packet type offload feature may affect the performance, so add
>>> a control flag for applications to turn it on or off.
>>>
>>> Signed-off-by: Long Wu <long.wu@corigine.com>
>>> ---
>>>  lib/ethdev/rte_ethdev.h | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index
>>> 548fada1c7..be86983e24 100644
>>> --- a/lib/ethdev/rte_ethdev.h
>>> +++ b/lib/ethdev/rte_ethdev.h
>>> @@ -1555,6 +1555,7 @@ struct rte_eth_conf {  #define
>>> RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(18)
>>>  #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
>>>  #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
>>> +#define RTE_ETH_RX_OFFLOAD_PTYPES           RTE_BIT64(21)
>>>
>>>  #define RTE_ETH_RX_OFFLOAD_CHECKSUM
>> (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
>>>  				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
>>
>> Hi Chaoyong,
>>
>> Instead of having an offload for ptypes, we have APIs for this,
>>
>> First one is 'rte_eth_dev_get_supported_ptypes()' that application can learn
>> the supported packet types.
>>
>> Second one is more related to above flag, it is 'rte_eth_dev_set_ptypes()'
>> which application can set which pytpes is required, it can be set to disable all
>> packet type parsing, can be similar to not requesting
>> 'RTE_ETH_RX_OFFLOAD_PTYPES'.
>>
>> With above two APIs, do we still need the offload flag?
>>
> 
> At present, the purpose of the ops 'rte_eth_dev_set_ptypes()' is to set the range of packet types to handle.
>

Yes, and setting 'ptype_mask' to zero should disable packet type parsing.

Packet type parsing is an offload, but when we have an API that has
finer grained control to what packet type to parse, why not use it
instead of having offload flag, which is all on or off configuration.

> Of course, we can maintain a flag for each application and driver based on the return value of this ops;
> but this is a bit troublesome.
>

I didn't get your point, why maintain a flag?

> So, we hope to follow the example of RSS, in addition to
> 'rte_eth_dev_rss_hash_update()' and 'rte_eth_dev_rss_hash_conf_get()', we also want to set a flag for
> the ptype function similar to RTE_ETH_RX_OFFLOAD_RSS_HASH.
> 
>>
>> Another concern with adding new offload flag is backward compatibility, all
>> existing drivers that support packet type parsing should be updated to list this
>> offload flag as capability. Also they need to be updated to configure packet
>> parsing based on user requested offload configuration.
>>
> 
> If you agree with this design suggestion, we will adapt all the related code to ptypes for each PMDs and 'test-pmd' applications in the next patch.
> Do you think this okay?
> 
>> Briefly, we can't just introduce a new offload flag for an existing capability and
>> update only one driver, all drivers needs to be updated.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH 1/2] ethdev: add Rx packet type offload control flag
  2024-09-25 19:33       ` Ferruh Yigit
@ 2024-09-26  2:15         ` Chaoyong He
  0 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2024-09-26  2:15 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: oss-drivers, Long Wu

> On 9/24/2024 3:03 AM, Chaoyong He wrote:
> >> On 6/19/2024 11:11 AM, Chaoyong He wrote:
> >>> From: Long Wu <long.wu@corigine.com>
> >>>
> >>> The Rx packet type offload feature may affect the performance, so
> >>> add a control flag for applications to turn it on or off.
> >>>
> >>> Signed-off-by: Long Wu <long.wu@corigine.com>
> >>> ---
> >>>  lib/ethdev/rte_ethdev.h | 1 +
> >>>  1 file changed, 1 insertion(+)
> >>>
> >>> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index
> >>> 548fada1c7..be86983e24 100644
> >>> --- a/lib/ethdev/rte_ethdev.h
> >>> +++ b/lib/ethdev/rte_ethdev.h
> >>> @@ -1555,6 +1555,7 @@ struct rte_eth_conf {  #define
> >>> RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM  RTE_BIT64(18)
> >>>  #define RTE_ETH_RX_OFFLOAD_RSS_HASH         RTE_BIT64(19)
> >>>  #define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT     RTE_BIT64(20)
> >>> +#define RTE_ETH_RX_OFFLOAD_PTYPES           RTE_BIT64(21)
> >>>
> >>>  #define RTE_ETH_RX_OFFLOAD_CHECKSUM
> >> (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \
> >>>  				 RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \
> >>
> >> Hi Chaoyong,
> >>
> >> Instead of having an offload for ptypes, we have APIs for this,
> >>
> >> First one is 'rte_eth_dev_get_supported_ptypes()' that application
> >> can learn the supported packet types.
> >>
> >> Second one is more related to above flag, it is 'rte_eth_dev_set_ptypes()'
> >> which application can set which pytpes is required, it can be set to
> >> disable all packet type parsing, can be similar to not requesting
> >> 'RTE_ETH_RX_OFFLOAD_PTYPES'.
> >>
> >> With above two APIs, do we still need the offload flag?
> >>
> >
> > At present, the purpose of the ops 'rte_eth_dev_set_ptypes()' is to set the
> range of packet types to handle.
> >
> 
> Yes, and setting 'ptype_mask' to zero should disable packet type parsing.
> 
> Packet type parsing is an offload, but when we have an API that has finer
> grained control to what packet type to parse, why not use it instead of having
> offload flag, which is all on or off configuration.
> 
> > Of course, we can maintain a flag for each application and driver
> > based on the return value of this ops; but this is a bit troublesome.
> >
> 
> I didn't get your point, why maintain a flag?
> 
> > So, we hope to follow the example of RSS, in addition to
> > 'rte_eth_dev_rss_hash_update()' and 'rte_eth_dev_rss_hash_conf_get()',
> > we also want to set a flag for the ptype function similar to
> RTE_ETH_RX_OFFLOAD_RSS_HASH.
> >
> >>
> >> Another concern with adding new offload flag is backward
> >> compatibility, all existing drivers that support packet type parsing
> >> should be updated to list this offload flag as capability. Also they
> >> need to be updated to configure packet parsing based on user requested
> offload configuration.
> >>
> >
> > If you agree with this design suggestion, we will adapt all the related code to
> ptypes for each PMDs and 'test-pmd' applications in the next patch.
> > Do you think this okay?
> >
> >> Briefly, we can't just introduce a new offload flag for an existing
> >> capability and update only one driver, all drivers needs to be updated.

Hi Ferruh,
Thanks for your explanation, we understand what you mean now.

We'll send a new version patch to drop the 'RTE_ETH_RX_OFFLOAD_PTYPES'.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] net/nfp: implement the device packet type set interface
  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-06-19 10:11 ` [PATCH 2/2] net/nfp: implement the device packet type set interface Chaoyong He
@ 2024-09-26  7:16 ` Chaoyong He
  2024-09-27  0:49   ` Ferruh Yigit
  2024-09-27  3:10   ` [PATCH v3] " Chaoyong He
  2 siblings, 2 replies; 11+ messages in thread
From: Chaoyong He @ 2024-09-26  7:16 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He

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>

---
V2:
* Following the advice from reviewer, abandon the modification of RTE
  layer.
---
 drivers/net/nfp/nfp_ethdev.c     |  1 +
 drivers/net/nfp/nfp_net_common.c | 42 +++++++++++++++++++++++++++++++-
 drivers/net/nfp/nfp_net_common.h |  1 +
 3 files changed, 43 insertions(+), 1 deletion(-)

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] net/nfp: implement the device packet type set interface
  2024-09-26  7:16 ` [PATCH v2] " Chaoyong He
@ 2024-09-27  0:49   ` Ferruh Yigit
  2024-09-27  3:10   ` [PATCH v3] " Chaoyong He
  1 sibling, 0 replies; 11+ messages in thread
From: Ferruh Yigit @ 2024-09-27  0:49 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Long Wu

On 9/26/2024 8:16 AM, Chaoyong He wrote:
> 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>
> 
> ---
> V2:
> * Following the advice from reviewer, abandon the modification of RTE
>   layer.
> ---
>  drivers/net/nfp/nfp_ethdev.c     |  1 +
>  drivers/net/nfp/nfp_net_common.c | 42 +++++++++++++++++++++++++++++++-
>  drivers/net/nfp/nfp_net_common.h |  1 +
>  3 files changed, 43 insertions(+), 1 deletion(-)
> 
> 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,
>

Hi Chaoyong,

It looks like nfp support "Packet type parsing", can you please
advertise this feature in the nfp.ini?
I think it is OK to add it into this patch.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3] net/nfp: implement the device packet type set interface
  2024-09-26  7:16 ` [PATCH v2] " Chaoyong He
  2024-09-27  0:49   ` Ferruh Yigit
@ 2024-09-27  3:10   ` Chaoyong He
  2024-09-27 23:50     ` Ferruh Yigit
  1 sibling, 1 reply; 11+ messages in thread
From: Chaoyong He @ 2024-09-27  3:10 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] net/nfp: implement the device packet type set interface
  2024-09-27  3:10   ` [PATCH v3] " Chaoyong He
@ 2024-09-27 23:50     ` Ferruh Yigit
  0 siblings, 0 replies; 11+ messages in thread
From: Ferruh Yigit @ 2024-09-27 23:50 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Long Wu

On 9/27/2024 4:10 AM, Chaoyong He wrote:
> 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>
>

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-09-27 23:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH v3] " Chaoyong He
2024-09-27 23:50     ` Ferruh Yigit

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).