DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/i40e: do not turn on flexible payload on driver init
@ 2017-11-29 12:55 Kirill Rybalchenko
  2017-11-30  9:17 ` Xing, Beilei
  2017-12-01 15:27 ` Kirill Rybalchenko
  0 siblings, 2 replies; 10+ messages in thread
From: Kirill Rybalchenko @ 2017-11-29 12:55 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

Function i40e_GLQF_reg_init() overwrites global register for
flexible payload, forcing extraction of first 16 bytes of L2/L3/L4
payload to the field vector even if flexible payload is not used by
an application. Such unconditional turn on of flexible payload
effectively disables ability to use outer IP Destination address
for RSS/FDIR for tunnelled packets, as flexible payload
overwrites outer IP destination address on the field vector.

Now flexible payload turned on only when flow director is
enabled and configured.

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 11 -----------
 drivers/net/i40e/i40e_fdir.c   |  8 ++++++++
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 811cc9f..de5e2a3 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -701,17 +701,6 @@ RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "* igb_uio | uio_pci_generic | vfio-pci");
 static inline void i40e_GLQF_reg_init(struct i40e_hw *hw)
 {
 	/*
-	 * Force global configuration for flexible payload
-	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
-	 * This should be removed from code once proper
-	 * configuration API is added to avoid configuration conflicts
-	 * between ports of the same device.
-	 */
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
-
-	/*
 	 * Initialize registers for parsing packet type of QinQ
 	 * This should be removed from code once proper
 	 * configuration API is added to avoid configuration conflicts
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 3d7170d..8191f72 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -342,6 +342,14 @@ i40e_init_flx_pld(struct i40e_pf *pf)
 	uint16_t flow_type;
 
 	/*
+	 * Force global configuration for flexible payload
+	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
+	 */
+	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
+	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
+	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
+
+	/*
 	 * Define the bytes stream extracted as flexible payload in
 	 * field vector. By default, select 8 words from the beginning
 	 * of payload as flexible payload.
-- 
2.5.5

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

* Re: [dpdk-dev] [PATCH] net/i40e: do not turn on flexible payload on driver init
  2017-11-29 12:55 [dpdk-dev] [PATCH] net/i40e: do not turn on flexible payload on driver init Kirill Rybalchenko
@ 2017-11-30  9:17 ` Xing, Beilei
  2017-12-01 15:27 ` Kirill Rybalchenko
  1 sibling, 0 replies; 10+ messages in thread
From: Xing, Beilei @ 2017-11-30  9:17 UTC (permalink / raw)
  To: Rybalchenko, Kirill, dev; +Cc: Chilikin, Andrey, Wu, Jingjing


> -----Original Message-----
> From: Rybalchenko, Kirill
> Sent: Wednesday, November 29, 2017 8:56 PM
> To: dev@dpdk.org
> Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin, Andrey
> <andrey.chilikin@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>
> Subject: [PATCH] net/i40e: do not turn on flexible payload on driver init
> 
> Function i40e_GLQF_reg_init() overwrites global register for flexible payload,
> forcing extraction of first 16 bytes of L2/L3/L4 payload to the field vector
> even if flexible payload is not used by an application. Such unconditional turn
> on of flexible payload effectively disables ability to use outer IP Destination
> address for RSS/FDIR for tunnelled packets, as flexible payload overwrites
> outer IP destination address on the field vector.
> 
> Now flexible payload turned on only when flow director is enabled and
> configured.
> 
> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 11 -----------
>  drivers/net/i40e/i40e_fdir.c   |  8 ++++++++
>  2 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 811cc9f..de5e2a3 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -701,17 +701,6 @@ RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "*
> igb_uio | uio_pci_generic | vfio-pci");  static inline void
> i40e_GLQF_reg_init(struct i40e_hw *hw)  {
>  	/*
> -	 * Force global configuration for flexible payload
> -	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
> -	 * This should be removed from code once proper
> -	 * configuration API is added to avoid configuration conflicts
> -	 * between ports of the same device.
> -	 */
> -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
> -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
> -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
> -
> -	/*
>  	 * Initialize registers for parsing packet type of QinQ
>  	 * This should be removed from code once proper
>  	 * configuration API is added to avoid configuration conflicts diff --git
> a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c index
> 3d7170d..8191f72 100644
> --- a/drivers/net/i40e/i40e_fdir.c
> +++ b/drivers/net/i40e/i40e_fdir.c
> @@ -342,6 +342,14 @@ i40e_init_flx_pld(struct i40e_pf *pf)
>  	uint16_t flow_type;
> 
>  	/*
> +	 * Force global configuration for flexible payload
> +	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
> +	 */
> +	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
> +	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
> +	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
> +

In this case, the global registers will be set when enabling flow director, but it won't
be reset to default value unless core reset. So need an alternative mechanism to
configure the global registers.

> +	/*
>  	 * Define the bytes stream extracted as flexible payload in
>  	 * field vector. By default, select 8 words from the beginning
>  	 * of payload as flexible payload.
> --
> 2.5.5

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

* [dpdk-dev] [PATCH] net/i40e: do not turn on flexible payload on driver init
  2017-11-29 12:55 [dpdk-dev] [PATCH] net/i40e: do not turn on flexible payload on driver init Kirill Rybalchenko
  2017-11-30  9:17 ` Xing, Beilei
@ 2017-12-01 15:27 ` Kirill Rybalchenko
  2017-12-11  6:00   ` Xing, Beilei
  2018-01-04 17:45   ` [dpdk-dev] [PATCH v2] " Kirill Rybalchenko
  1 sibling, 2 replies; 10+ messages in thread
From: Kirill Rybalchenko @ 2017-12-01 15:27 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

Function i40e_GLQF_reg_init() overwrites global register for
flexible payload, forcing extraction of first 16 bytes of
L2/L3/L4 payload to the field vector even if flexible payload
is not used by an application. Such unconditional turn on of
flexible payload effectively disables ability to use outer
IP Destination address for RSS/FDIR for tunnelled packets,
as flexible payload overwrites outer IP destination address
on the field vector.

Now flexible payload turned on only when flow director is
enabled and configured.

v1:
Global registers will be set only when payload is enabled.
They will be reset if payload is disabled or on port reset
(uninit).

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 32 +++++++++++++++++++++-----------
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_fdir.c   |  1 +
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 811cc9f..d6a207f 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -701,17 +701,6 @@ RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "* igb_uio | uio_pci_generic | vfio-pci");
 static inline void i40e_GLQF_reg_init(struct i40e_hw *hw)
 {
 	/*
-	 * Force global configuration for flexible payload
-	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
-	 * This should be removed from code once proper
-	 * configuration API is added to avoid configuration conflicts
-	 * between ports of the same device.
-	 */
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
-
-	/*
 	 * Initialize registers for parsing packet type of QinQ
 	 * This should be removed from code once proper
 	 * configuration API is added to avoid configuration conflicts
@@ -1435,6 +1424,24 @@ i40e_rm_fdir_filter_list(struct i40e_pf *pf)
 	}
 }
 
+void i40e_flex_payload_reg_cfg(struct i40e_hw *hw, bool enable)
+{
+	if (enable) {
+		/*
+		 * Set global configuration for flexible payload
+		 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
+		 */
+		I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
+		I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
+		I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
+	} else {
+		/* Disable flexible payload in global configuration */
+		I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x00000000);
+		I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x00000000);
+		I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x00000000);
+	}
+}
+
 static int
 eth_i40e_dev_uninit(struct rte_eth_dev *dev)
 {
@@ -1478,6 +1485,9 @@ eth_i40e_dev_uninit(struct rte_eth_dev *dev)
 	hw->fc.requested_mode = I40E_FC_NONE;
 	i40e_set_fc(hw, &aq_fail, TRUE);
 
+	/* Disable flexible payload in global configuration */
+	i40e_flex_payload_reg_cfg(hw, false);
+
 	/* uninitialize pf host driver */
 	i40e_pf_host_uninit(dev);
 
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cd67453..2cbe9cb 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1198,6 +1198,7 @@ int i40e_dcb_init_configure(struct rte_eth_dev *dev, bool sw_dcb);
 int i40e_flush_queue_region_all_conf(struct rte_eth_dev *dev,
 		struct i40e_hw *hw, struct i40e_pf *pf, uint16_t on);
 void i40e_init_queue_region_conf(struct rte_eth_dev *dev);
+void i40e_flex_payload_reg_cfg(struct i40e_hw *hw, bool enable);
 
 #define I40E_DEV_TO_PCI(eth_dev) \
 	RTE_DEV_TO_PCI((eth_dev)->device)
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 3d7170d..0ae8fbd 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -671,6 +671,7 @@ i40e_fdir_configure(struct rte_eth_dev *dev)
 		return -EINVAL;
 	}
 	/* configure flex payload */
+	i40e_flex_payload_reg_cfg(hw, !!conf->nb_payloads);
 	for (i = 0; i < conf->nb_payloads; i++)
 		i40e_set_flx_pld_cfg(pf, &conf->flex_set[i]);
 	/* configure flex mask*/
-- 
2.5.5

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

* Re: [dpdk-dev] [PATCH] net/i40e: do not turn on flexible payload on driver init
  2017-12-01 15:27 ` Kirill Rybalchenko
@ 2017-12-11  6:00   ` Xing, Beilei
  2017-12-12  3:40     ` Xing, Beilei
  2018-01-04 17:45   ` [dpdk-dev] [PATCH v2] " Kirill Rybalchenko
  1 sibling, 1 reply; 10+ messages in thread
From: Xing, Beilei @ 2017-12-11  6:00 UTC (permalink / raw)
  To: Rybalchenko, Kirill, dev; +Cc: Chilikin, Andrey, Wu, Jingjing

> -----Original Message-----
> From: Rybalchenko, Kirill
> Sent: Friday, December 1, 2017 11:27 PM
> To: dev@dpdk.org
> Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin, Andrey
> <andrey.chilikin@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>
> Subject: [PATCH] net/i40e: do not turn on flexible payload on driver init
> 
> Function i40e_GLQF_reg_init() overwrites global register for flexible payload,
> forcing extraction of first 16 bytes of
> L2/L3/L4 payload to the field vector even if flexible payload is not used by an
> application. Such unconditional turn on of flexible payload effectively
> disables ability to use outer IP Destination address for RSS/FDIR for tunnelled
> packets, as flexible payload overwrites outer IP destination address on the
> field vector.
> 
> Now flexible payload turned on only when flow director is enabled and
> configured.
> 
> v1:
> Global registers will be set only when payload is enabled.
> They will be reset if payload is disabled or on port reset (uninit).
> 
> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 32 +++++++++++++++++++++-----------
> drivers/net/i40e/i40e_ethdev.h |  1 +
>  drivers/net/i40e/i40e_fdir.c   |  1 +
>  3 files changed, 23 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 811cc9f..d6a207f 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -701,17 +701,6 @@ RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "*
> igb_uio | uio_pci_generic | vfio-pci");  static inline void
> i40e_GLQF_reg_init(struct i40e_hw *hw)  {
>  	/*
> -	 * Force global configuration for flexible payload
> -	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
> -	 * This should be removed from code once proper
> -	 * configuration API is added to avoid configuration conflicts
> -	 * between ports of the same device.
> -	 */
> -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
> -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
> -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
> -
> -	/*
>  	 * Initialize registers for parsing packet type of QinQ
>  	 * This should be removed from code once proper
>  	 * configuration API is added to avoid configuration conflicts @@ -
> 1435,6 +1424,24 @@ i40e_rm_fdir_filter_list(struct i40e_pf *pf)
>  	}
>  }
> 
> +void i40e_flex_payload_reg_cfg(struct i40e_hw *hw, bool enable) {
> +	if (enable) {
> +		/*
> +		 * Set global configuration for flexible payload
> +		 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
> +		 */
> +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
> +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
> +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
> +	} else {
> +		/* Disable flexible payload in global configuration */
> +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x00000000);
> +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x00000000);
> +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x00000000);

I'm not sure if 0 is the default value for the three registers, just remind to check the value in FW first.

> +	}
> +}
> +
>  static int
>  eth_i40e_dev_uninit(struct rte_eth_dev *dev)  { @@ -1478,6 +1485,9 @@
> eth_i40e_dev_uninit(struct rte_eth_dev *dev)
>  	hw->fc.requested_mode = I40E_FC_NONE;
>  	i40e_set_fc(hw, &aq_fail, TRUE);
> 
> +	/* Disable flexible payload in global configuration */
> +	i40e_flex_payload_reg_cfg(hw, false);
> +

How about moving it to dev_close and also adding disable flexible payload in dev_init function?
Guarantee flexible payload is disabled during the next launch if application quits in unexpected way.

>  	/* uninitialize pf host driver */
>  	i40e_pf_host_uninit(dev);
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.h
> b/drivers/net/i40e/i40e_ethdev.h index cd67453..2cbe9cb 100644
> --- a/drivers/net/i40e/i40e_ethdev.h
> +++ b/drivers/net/i40e/i40e_ethdev.h
> @@ -1198,6 +1198,7 @@ int i40e_dcb_init_configure(struct rte_eth_dev
> *dev, bool sw_dcb);  int i40e_flush_queue_region_all_conf(struct
> rte_eth_dev *dev,
>  		struct i40e_hw *hw, struct i40e_pf *pf, uint16_t on);  void
> i40e_init_queue_region_conf(struct rte_eth_dev *dev);
> +void i40e_flex_payload_reg_cfg(struct i40e_hw *hw, bool enable);
> 
>  #define I40E_DEV_TO_PCI(eth_dev) \
>  	RTE_DEV_TO_PCI((eth_dev)->device)
> diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c index
> 3d7170d..0ae8fbd 100644
> --- a/drivers/net/i40e/i40e_fdir.c
> +++ b/drivers/net/i40e/i40e_fdir.c
> @@ -671,6 +671,7 @@ i40e_fdir_configure(struct rte_eth_dev *dev)
>  		return -EINVAL;
>  	}
>  	/* configure flex payload */
> +	i40e_flex_payload_reg_cfg(hw, !!conf->nb_payloads);
>  	for (i = 0; i < conf->nb_payloads; i++)
>  		i40e_set_flx_pld_cfg(pf, &conf->flex_set[i]);
>  	/* configure flex mask*/
> --
> 2.5.5

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

* Re: [dpdk-dev] [PATCH] net/i40e: do not turn on flexible payload on driver init
  2017-12-11  6:00   ` Xing, Beilei
@ 2017-12-12  3:40     ` Xing, Beilei
  0 siblings, 0 replies; 10+ messages in thread
From: Xing, Beilei @ 2017-12-12  3:40 UTC (permalink / raw)
  To: Rybalchenko, Kirill, 'dev@dpdk.org'
  Cc: Chilikin, Andrey, Wu, Jingjing



> -----Original Message-----
> From: Xing, Beilei
> Sent: Monday, December 11, 2017 2:00 PM
> To: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; dev@dpdk.org
> Cc: Chilikin, Andrey <andrey.chilikin@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Subject: RE: [PATCH] net/i40e: do not turn on flexible payload on driver init
> 
> > -----Original Message-----
> > From: Rybalchenko, Kirill
> > Sent: Friday, December 1, 2017 11:27 PM
> > To: dev@dpdk.org
> > Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin,
> > Andrey <andrey.chilikin@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> > Subject: [PATCH] net/i40e: do not turn on flexible payload on driver
> > init
> >
> > Function i40e_GLQF_reg_init() overwrites global register for flexible
> > payload, forcing extraction of first 16 bytes of
> > L2/L3/L4 payload to the field vector even if flexible payload is not
> > used by an application. Such unconditional turn on of flexible payload
> > effectively disables ability to use outer IP Destination address for
> > RSS/FDIR for tunnelled packets, as flexible payload overwrites outer
> > IP destination address on the field vector.
> >
> > Now flexible payload turned on only when flow director is enabled and
> > configured.
> >
> > v1:
> > Global registers will be set only when payload is enabled.
> > They will be reset if payload is disabled or on port reset (uninit).
> >
> > Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> > ---
> >  drivers/net/i40e/i40e_ethdev.c | 32 +++++++++++++++++++++-----------
> > drivers/net/i40e/i40e_ethdev.h |  1 +
> >  drivers/net/i40e/i40e_fdir.c   |  1 +
> >  3 files changed, 23 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev.c
> > b/drivers/net/i40e/i40e_ethdev.c index 811cc9f..d6a207f 100644
> > --- a/drivers/net/i40e/i40e_ethdev.c
> > +++ b/drivers/net/i40e/i40e_ethdev.c
> > @@ -701,17 +701,6 @@ RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "*
> igb_uio |
> > uio_pci_generic | vfio-pci");  static inline void
> > i40e_GLQF_reg_init(struct i40e_hw *hw)  {
> >  	/*
> > -	 * Force global configuration for flexible payload
> > -	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
> > -	 * This should be removed from code once proper
> > -	 * configuration API is added to avoid configuration conflicts
> > -	 * between ports of the same device.
> > -	 */
> > -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
> > -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
> > -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
> > -
> > -	/*
> >  	 * Initialize registers for parsing packet type of QinQ
> >  	 * This should be removed from code once proper
> >  	 * configuration API is added to avoid configuration conflicts @@ -
> > 1435,6 +1424,24 @@ i40e_rm_fdir_filter_list(struct i40e_pf *pf)
> >  	}
> >  }
> >
> > +void i40e_flex_payload_reg_cfg(struct i40e_hw *hw, bool enable) {
> > +	if (enable) {
> > +		/*
> > +		 * Set global configuration for flexible payload
> > +		 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
> > +		 */
> > +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
> > +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
> > +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
> > +	} else {
> > +		/* Disable flexible payload in global configuration */
> > +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x00000000);
> > +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x00000000);
> > +		I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x00000000);
> 
> I'm not sure if 0 is the default value for the three registers, just remind to
> check the value in FW first.
> 
> > +	}
> > +}
> > +
> >  static int
> >  eth_i40e_dev_uninit(struct rte_eth_dev *dev)  { @@ -1478,6 +1485,9 @@
> > eth_i40e_dev_uninit(struct rte_eth_dev *dev)
> >  	hw->fc.requested_mode = I40E_FC_NONE;
> >  	i40e_set_fc(hw, &aq_fail, TRUE);
> >
> > +	/* Disable flexible payload in global configuration */
> > +	i40e_flex_payload_reg_cfg(hw, false);
> > +
> 
> How about moving it to dev_close and also adding disable flexible payload in
> dev_init function?
> Guarantee flexible payload is disabled during the next launch if application
> quits in unexpected way.
> 
> >  	/* uninitialize pf host driver */
> >  	i40e_pf_host_uninit(dev);
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev.h
> > b/drivers/net/i40e/i40e_ethdev.h index cd67453..2cbe9cb 100644
> > --- a/drivers/net/i40e/i40e_ethdev.h
> > +++ b/drivers/net/i40e/i40e_ethdev.h
> > @@ -1198,6 +1198,7 @@ int i40e_dcb_init_configure(struct rte_eth_dev
> > *dev, bool sw_dcb);  int i40e_flush_queue_region_all_conf(struct
> > rte_eth_dev *dev,
> >  		struct i40e_hw *hw, struct i40e_pf *pf, uint16_t on);  void
> > i40e_init_queue_region_conf(struct rte_eth_dev *dev);
> > +void i40e_flex_payload_reg_cfg(struct i40e_hw *hw, bool enable);
> >
> >  #define I40E_DEV_TO_PCI(eth_dev) \
> >  	RTE_DEV_TO_PCI((eth_dev)->device)
> > diff --git a/drivers/net/i40e/i40e_fdir.c
> > b/drivers/net/i40e/i40e_fdir.c index 3d7170d..0ae8fbd 100644
> > --- a/drivers/net/i40e/i40e_fdir.c
> > +++ b/drivers/net/i40e/i40e_fdir.c
> > @@ -671,6 +671,7 @@ i40e_fdir_configure(struct rte_eth_dev *dev)
> >  		return -EINVAL;
> >  	}
> >  	/* configure flex payload */
> > +	i40e_flex_payload_reg_cfg(hw, !!conf->nb_payloads);

Besides, I don't think it's the right place to configure flexible payload here. 
When use rte_flow API to create a FDIR flow with flexible payload, flow_director_flex_payload CLI is not needed, then the configuration will be failed to set.


> >  	for (i = 0; i < conf->nb_payloads; i++)
> >  		i40e_set_flx_pld_cfg(pf, &conf->flex_set[i]);
> >  	/* configure flex mask*/
> > --
> > 2.5.5

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

* [dpdk-dev] [PATCH v2] net/i40e: do not turn on flexible payload on driver init
  2017-12-01 15:27 ` Kirill Rybalchenko
  2017-12-11  6:00   ` Xing, Beilei
@ 2018-01-04 17:45   ` Kirill Rybalchenko
  2018-01-08  5:41     ` Xing, Beilei
  2018-01-09 15:36     ` [dpdk-dev] [PATCH v3] " Kirill Rybalchenko
  1 sibling, 2 replies; 10+ messages in thread
From: Kirill Rybalchenko @ 2018-01-04 17:45 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

Function i40e_GLQF_reg_init() overwrites global register for
flexible payload, forcing extraction of first 16 bytes of
L2/L3/L4 payload to the field vector even if flexible payload
is not used by an application. Such unconditional turn on of
flexible payload effectively disables ability to use outer
IP Destination address for RSS/FDIR for tunnelled packets,
as flexible payload overwrites outer IP destination address
on the field vector.

Now flexible payload turned on only when flow director is
enabled and configured.

v1:
Global registers will be set only when payload is enabled.
They will be reset if payload is disabled or on port reset
(uninit).

v2:
dev_init and dev_close disable flexible payload by default.
Flexible payload enabled selectively, only if appropriate
PIT is set up. The same done for FDIR and for rte_flow API.

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 29 ++++++++++++++++++-----------
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_fdir.c   | 14 +++++++++++---
 drivers/net/i40e/i40e_flow.c   |  9 ++++++++-
 4 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 811cc9f..b136120 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -701,17 +701,6 @@ RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "* igb_uio | uio_pci_generic | vfio-pci");
 static inline void i40e_GLQF_reg_init(struct i40e_hw *hw)
 {
 	/*
-	 * Force global configuration for flexible payload
-	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
-	 * This should be removed from code once proper
-	 * configuration API is added to avoid configuration conflicts
-	 * between ports of the same device.
-	 */
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
-
-	/*
 	 * Initialize registers for parsing packet type of QinQ
 	 * This should be removed from code once proper
 	 * configuration API is added to avoid configuration conflicts
@@ -1315,6 +1304,10 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 
 	/* enable uio intr after callback register */
 	rte_intr_enable(intr_handle);
+
+	/* By default disable flexible payload in global configuration */
+	i40e_flex_payload_reg_set_default(hw);
+
 	/*
 	 * Add an ethertype filter to drop all flow control frames transmitted
 	 * from VSIs. By doing so, we stop VF from sending out PAUSE or PFC
@@ -1435,6 +1428,17 @@ i40e_rm_fdir_filter_list(struct i40e_pf *pf)
 	}
 }
 
+void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)
+{
+	/*
+	 * Disable by default flexible payload
+	 * for corresponding L2/L3/L4 layers.
+	 */
+	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x00000000);
+	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x00000000);
+	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x00000000);
+}
+
 static int
 eth_i40e_dev_uninit(struct rte_eth_dev *dev)
 {
@@ -2222,6 +2226,9 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	i40e_res_pool_destroy(&pf->qp_pool);
 	i40e_res_pool_destroy(&pf->msix_pool);
 
+	/* Disable flexible payload in global configuration */
+	i40e_flex_payload_reg_set_default(hw);
+
 	/* force a PF reset to clean anything leftover */
 	reg = I40E_READ_REG(hw, I40E_PFGEN_CTRL);
 	I40E_WRITE_REG(hw, I40E_PFGEN_CTRL,
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cd67453..2919e0a 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1198,6 +1198,7 @@ int i40e_dcb_init_configure(struct rte_eth_dev *dev, bool sw_dcb);
 int i40e_flush_queue_region_all_conf(struct rte_eth_dev *dev,
 		struct i40e_hw *hw, struct i40e_pf *pf, uint16_t on);
 void i40e_init_queue_region_conf(struct rte_eth_dev *dev);
+void i40e_flex_payload_reg_set_default(struct i40e_hw *hw);
 
 #define I40E_DEV_TO_PCI(eth_dev) \
 	RTE_DEV_TO_PCI((eth_dev)->device)
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 3d7170d..2d17944 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -534,7 +534,7 @@ i40e_set_flx_pld_cfg(struct i40e_pf *pf,
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_fdir_flex_pit flex_pit[I40E_MAX_FLXPLD_FIED];
-	uint32_t flx_pit;
+	uint32_t flx_pit, flx_ort;
 	uint16_t num, min_next_off;  /* in words */
 	uint8_t field_idx = 0;
 	uint8_t layer_idx = 0;
@@ -548,9 +548,17 @@ i40e_set_flx_pld_cfg(struct i40e_pf *pf,
 		layer_idx = I40E_FLXPLD_L4_IDX;
 
 	memset(flex_pit, 0, sizeof(flex_pit));
-	num = i40e_srcoff_to_flx_pit(cfg->src_offset, flex_pit);
+	num = RTE_MIN(i40e_srcoff_to_flx_pit(cfg->src_offset, flex_pit),
+		      RTE_DIM(flex_pit));
 
-	for (i = 0; i < RTE_MIN(num, RTE_DIM(flex_pit)); i++) {
+	if (num) {
+		flx_ort = (1 << I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT) |
+			  (num << I40E_GLQF_ORT_FIELD_CNT_SHIFT) |
+			  (layer_idx * I40E_MAX_FLXPLD_FIED);
+		I40E_WRITE_REG(hw, I40E_GLQF_ORT(33 + layer_idx), flx_ort);
+	}
+
+	for (i = 0; i < num; i++) {
 		field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + i;
 		/* record the info in fdir structure */
 		pf->fdir.flex_set[field_idx].src_offset =
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 7e4936e..5487fd0 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -2276,11 +2276,18 @@ i40e_flow_set_fdir_flex_pit(struct i40e_pf *pf,
 			    uint8_t raw_id)
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
-	uint32_t flx_pit;
+	uint32_t flx_pit, flx_ort;
 	uint8_t field_idx;
 	uint16_t min_next_off = 0;  /* in words */
 	uint8_t i;
 
+	if (raw_id) {
+		flx_ort = (1 << I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT) |
+			  (raw_id << I40E_GLQF_ORT_FIELD_CNT_SHIFT) |
+			  (layer_idx * I40E_MAX_FLXPLD_FIED);
+		I40E_WRITE_REG(hw, I40E_GLQF_ORT(33 + layer_idx), flx_ort);
+	}
+
 	/* Set flex pit */
 	for (i = 0; i < raw_id; i++) {
 		field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + i;
-- 
2.5.5

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

* Re: [dpdk-dev] [PATCH v2] net/i40e: do not turn on flexible payload on driver init
  2018-01-04 17:45   ` [dpdk-dev] [PATCH v2] " Kirill Rybalchenko
@ 2018-01-08  5:41     ` Xing, Beilei
  2018-01-09 15:28       ` Zhang, Helin
  2018-01-09 15:36     ` [dpdk-dev] [PATCH v3] " Kirill Rybalchenko
  1 sibling, 1 reply; 10+ messages in thread
From: Xing, Beilei @ 2018-01-08  5:41 UTC (permalink / raw)
  To: Rybalchenko, Kirill, dev
  Cc: Rybalchenko, Kirill, Chilikin, Andrey, Wu, Jingjing



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Kirill Rybalchenko
> Sent: Friday, January 5, 2018 1:45 AM
> To: dev@dpdk.org
> Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin, Andrey
> <andrey.chilikin@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>
> Subject: [dpdk-dev] [PATCH v2] net/i40e: do not turn on flexible payload on
> driver init
> 
> Function i40e_GLQF_reg_init() overwrites global register for flexible payload,
> forcing extraction of first 16 bytes of
> L2/L3/L4 payload to the field vector even if flexible payload is not used by an
> application. Such unconditional turn on of flexible payload effectively
> disables ability to use outer IP Destination address for RSS/FDIR for tunnelled
> packets, as flexible payload overwrites outer IP destination address on the
> field vector.
> 
> Now flexible payload turned on only when flow director is enabled and
> configured.
> 
> v1:
> Global registers will be set only when payload is enabled.
> They will be reset if payload is disabled or on port reset (uninit).
> 
> v2:
> dev_init and dev_close disable flexible payload by default.
> Flexible payload enabled selectively, only if appropriate PIT is set up. The
> same done for FDIR and for rte_flow API.
> 
> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 29 ++++++++++++++++++-----------
> drivers/net/i40e/i40e_ethdev.h |  1 +
>  drivers/net/i40e/i40e_fdir.c   | 14 +++++++++++---
>  drivers/net/i40e/i40e_flow.c   |  9 ++++++++-
>  4 files changed, 38 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 811cc9f..b136120 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -701,17 +701,6 @@ RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "*
> igb_uio | uio_pci_generic | vfio-pci");  static inline void
> i40e_GLQF_reg_init(struct i40e_hw *hw)  {
>  	/*
> -	 * Force global configuration for flexible payload
> -	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
> -	 * This should be removed from code once proper
> -	 * configuration API is added to avoid configuration conflicts
> -	 * between ports of the same device.
> -	 */
> -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
> -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
> -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
> -

Please also help to change the comment in eth_i40e_dev_init where i40e_GLQF_reg_init is involved, since this workaround is removed.

Apart from that,
Acked-by: Beilei Xing <beilei.xing@intel.com>

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

* Re: [dpdk-dev] [PATCH v2] net/i40e: do not turn on flexible payload on driver init
  2018-01-08  5:41     ` Xing, Beilei
@ 2018-01-09 15:28       ` Zhang, Helin
  0 siblings, 0 replies; 10+ messages in thread
From: Zhang, Helin @ 2018-01-09 15:28 UTC (permalink / raw)
  To: Xing, Beilei, Rybalchenko, Kirill, dev; +Cc: Rybalchenko, Kirill



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xing, Beilei
> Sent: Monday, January 8, 2018 1:42 PM
> To: Rybalchenko, Kirill; dev@dpdk.org
> Cc: Rybalchenko, Kirill; Chilikin, Andrey; Wu, Jingjing
> Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: do not turn on flexible payload on
> driver init
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Kirill
> > Rybalchenko
> > Sent: Friday, January 5, 2018 1:45 AM
> > To: dev@dpdk.org
> > Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin,
> > Andrey <andrey.chilikin@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> > Subject: [dpdk-dev] [PATCH v2] net/i40e: do not turn on flexible
> > payload on driver init
> >
> > Function i40e_GLQF_reg_init() overwrites global register for flexible
> > payload, forcing extraction of first 16 bytes of
> > L2/L3/L4 payload to the field vector even if flexible payload is not
> > used by an application. Such unconditional turn on of flexible payload
> > effectively disables ability to use outer IP Destination address for
> > RSS/FDIR for tunnelled packets, as flexible payload overwrites outer
> > IP destination address on the field vector.
> >
> > Now flexible payload turned on only when flow director is enabled and
> > configured.
> >
> > v1:
> > Global registers will be set only when payload is enabled.
> > They will be reset if payload is disabled or on port reset (uninit).
> >
> > v2:
> > dev_init and dev_close disable flexible payload by default.
> > Flexible payload enabled selectively, only if appropriate PIT is set
> > up. The same done for FDIR and for rte_flow API.
> >
> > Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> > ---
> >  drivers/net/i40e/i40e_ethdev.c | 29 ++++++++++++++++++-----------
> > drivers/net/i40e/i40e_ethdev.h |  1 +
> >  drivers/net/i40e/i40e_fdir.c   | 14 +++++++++++---
> >  drivers/net/i40e/i40e_flow.c   |  9 ++++++++-
> >  4 files changed, 38 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev.c
> > b/drivers/net/i40e/i40e_ethdev.c index 811cc9f..b136120 100644
> > --- a/drivers/net/i40e/i40e_ethdev.c
> > +++ b/drivers/net/i40e/i40e_ethdev.c
> > @@ -701,17 +701,6 @@ RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "*
> igb_uio |
> > uio_pci_generic | vfio-pci");  static inline void
> > i40e_GLQF_reg_init(struct i40e_hw *hw)  {
> >  	/*
> > -	 * Force global configuration for flexible payload
> > -	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
> > -	 * This should be removed from code once proper
> > -	 * configuration API is added to avoid configuration conflicts
> > -	 * between ports of the same device.
> > -	 */
> > -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
> > -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
> > -	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
> > -
> 
> Please also help to change the comment in eth_i40e_dev_init where
> i40e_GLQF_reg_init is involved, since this workaround is removed.
> 
> Apart from that,
> Acked-by: Beilei Xing <beilei.xing@intel.com>
Applied to dpdk-next-net-intel, with minor commit log and annotation changes. Thanks!

/Helin

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

* [dpdk-dev] [PATCH v3] net/i40e: do not turn on flexible payload on driver init
  2018-01-04 17:45   ` [dpdk-dev] [PATCH v2] " Kirill Rybalchenko
  2018-01-08  5:41     ` Xing, Beilei
@ 2018-01-09 15:36     ` Kirill Rybalchenko
  2018-01-09 16:06       ` Zhang, Helin
  1 sibling, 1 reply; 10+ messages in thread
From: Kirill Rybalchenko @ 2018-01-09 15:36 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

Function i40e_GLQF_reg_init() overwrites global register for
flexible payload, forcing extraction of first 16 bytes of
L2/L3/L4 payload to the field vector even if flexible payload
is not used by an application. Such unconditional turn on of
flexible payload effectively disables ability to use outer
IP Destination address for RSS/FDIR for tunnelled packets,
as flexible payload overwrites outer IP destination address
on the field vector.

Now flexible payload turned on only when flow director is
enabled and configured.

v1:
Global registers will be set only when payload is enabled.
They will be reset if payload is disabled or on port reset
(uninit).

v2:
dev_init and dev_close disable flexible payload by default.
Flexible payload enabled selectively, only if appropriate
PIT is set up. The same done for FDIR and for rte_flow API.

v3:
Minor fix in comments.

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 34 ++++++++++++++++++++--------------
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_fdir.c   | 14 +++++++++++---
 drivers/net/i40e/i40e_flow.c   |  9 ++++++++-
 4 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 9ec0201..73c83a7 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -672,17 +672,6 @@ RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "* igb_uio | uio_pci_generic | vfio-pci");
 static inline void i40e_GLQF_reg_init(struct i40e_hw *hw)
 {
 	/*
-	 * Force global configuration for flexible payload
-	 * to the first 16 bytes of the corresponding L2/L3/L4 paylod.
-	 * This should be removed from code once proper
-	 * configuration API is added to avoid configuration conflicts
-	 * between ports of the same device.
-	 */
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x000000E0);
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x000000E3);
-	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x000000E6);
-
-	/*
 	 * Initialize registers for parsing packet type of QinQ
 	 * This should be removed from code once proper
 	 * configuration API is added to avoid configuration conflicts
@@ -1115,9 +1104,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 
 	/*
 	 * To work around the NVM issue, initialize registers
-	 * for flexible payload and packet type of QinQ by
-	 * software. It should be removed once issues are fixed
-	 * in NVM.
+	 * for packet type of QinQ by software.
+	 * It should be removed once issues are fixed in NVM.
 	 */
 	i40e_GLQF_reg_init(hw);
 
@@ -1286,6 +1274,10 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 
 	/* enable uio intr after callback register */
 	rte_intr_enable(intr_handle);
+
+	/* By default disable flexible payload in global configuration */
+	i40e_flex_payload_reg_set_default(hw);
+
 	/*
 	 * Add an ethertype filter to drop all flow control frames transmitted
 	 * from VSIs. By doing so, we stop VF from sending out PAUSE or PFC
@@ -1406,6 +1398,17 @@ i40e_rm_fdir_filter_list(struct i40e_pf *pf)
 	}
 }
 
+void i40e_flex_payload_reg_set_default(struct i40e_hw *hw)
+{
+	/*
+	 * Disable by default flexible payload
+	 * for corresponding L2/L3/L4 layers.
+	 */
+	I40E_WRITE_REG(hw, I40E_GLQF_ORT(33), 0x00000000);
+	I40E_WRITE_REG(hw, I40E_GLQF_ORT(34), 0x00000000);
+	I40E_WRITE_REG(hw, I40E_GLQF_ORT(35), 0x00000000);
+}
+
 static int
 eth_i40e_dev_uninit(struct rte_eth_dev *dev)
 {
@@ -2203,6 +2206,9 @@ i40e_dev_close(struct rte_eth_dev *dev)
 	i40e_res_pool_destroy(&pf->qp_pool);
 	i40e_res_pool_destroy(&pf->msix_pool);
 
+	/* Disable flexible payload in global configuration */
+	i40e_flex_payload_reg_set_default(hw);
+
 	/* force a PF reset to clean anything leftover */
 	reg = I40E_READ_REG(hw, I40E_PFGEN_CTRL);
 	I40E_WRITE_REG(hw, I40E_PFGEN_CTRL,
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 7d5aff2..49c9042 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1170,6 +1170,7 @@ int i40e_dcb_init_configure(struct rte_eth_dev *dev, bool sw_dcb);
 int i40e_flush_queue_region_all_conf(struct rte_eth_dev *dev,
 		struct i40e_hw *hw, struct i40e_pf *pf, uint16_t on);
 void i40e_init_queue_region_conf(struct rte_eth_dev *dev);
+void i40e_flex_payload_reg_set_default(struct i40e_hw *hw);
 
 #define I40E_DEV_TO_PCI(eth_dev) \
 	RTE_DEV_TO_PCI((eth_dev)->device)
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index e471b5a..906c204 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -505,7 +505,7 @@ i40e_set_flx_pld_cfg(struct i40e_pf *pf,
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
 	struct i40e_fdir_flex_pit flex_pit[I40E_MAX_FLXPLD_FIED];
-	uint32_t flx_pit;
+	uint32_t flx_pit, flx_ort;
 	uint16_t num, min_next_off;  /* in words */
 	uint8_t field_idx = 0;
 	uint8_t layer_idx = 0;
@@ -519,9 +519,17 @@ i40e_set_flx_pld_cfg(struct i40e_pf *pf,
 		layer_idx = I40E_FLXPLD_L4_IDX;
 
 	memset(flex_pit, 0, sizeof(flex_pit));
-	num = i40e_srcoff_to_flx_pit(cfg->src_offset, flex_pit);
+	num = RTE_MIN(i40e_srcoff_to_flx_pit(cfg->src_offset, flex_pit),
+		      RTE_DIM(flex_pit));
 
-	for (i = 0; i < RTE_MIN(num, RTE_DIM(flex_pit)); i++) {
+	if (num) {
+		flx_ort = (1 << I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT) |
+			  (num << I40E_GLQF_ORT_FIELD_CNT_SHIFT) |
+			  (layer_idx * I40E_MAX_FLXPLD_FIED);
+		I40E_WRITE_REG(hw, I40E_GLQF_ORT(33 + layer_idx), flx_ort);
+	}
+
+	for (i = 0; i < num; i++) {
 		field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + i;
 		/* record the info in fdir structure */
 		pf->fdir.flex_set[field_idx].src_offset =
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index e522962..6feb7aa 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -2248,11 +2248,18 @@ i40e_flow_set_fdir_flex_pit(struct i40e_pf *pf,
 			    uint8_t raw_id)
 {
 	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
-	uint32_t flx_pit;
+	uint32_t flx_pit, flx_ort;
 	uint8_t field_idx;
 	uint16_t min_next_off = 0;  /* in words */
 	uint8_t i;
 
+	if (raw_id) {
+		flx_ort = (1 << I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT) |
+			  (raw_id << I40E_GLQF_ORT_FIELD_CNT_SHIFT) |
+			  (layer_idx * I40E_MAX_FLXPLD_FIED);
+		I40E_WRITE_REG(hw, I40E_GLQF_ORT(33 + layer_idx), flx_ort);
+	}
+
 	/* Set flex pit */
 	for (i = 0; i < raw_id; i++) {
 		field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + i;
-- 
2.5.5

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

* Re: [dpdk-dev] [PATCH v3] net/i40e: do not turn on flexible payload on driver init
  2018-01-09 15:36     ` [dpdk-dev] [PATCH v3] " Kirill Rybalchenko
@ 2018-01-09 16:06       ` Zhang, Helin
  0 siblings, 0 replies; 10+ messages in thread
From: Zhang, Helin @ 2018-01-09 16:06 UTC (permalink / raw)
  To: Rybalchenko, Kirill, dev
  Cc: Rybalchenko, Kirill, Chilikin, Andrey, Xing, Beilei, Wu, Jingjing



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Kirill Rybalchenko
> Sent: Tuesday, January 9, 2018 11:37 PM
> To: dev@dpdk.org
> Cc: Rybalchenko, Kirill; Chilikin, Andrey; Xing, Beilei; Wu, Jingjing
> Subject: [dpdk-dev] [PATCH v3] net/i40e: do not turn on flexible payload on
> driver init
> 
> Function i40e_GLQF_reg_init() overwrites global register for flexible payload,
> forcing extraction of first 16 bytes of
> L2/L3/L4 payload to the field vector even if flexible payload is not used by an
> application. Such unconditional turn on of flexible payload effectively disables
> ability to use outer IP Destination address for RSS/FDIR for tunnelled packets,
> as flexible payload overwrites outer IP destination address on the field vector.
> 
> Now flexible payload turned on only when flow director is enabled and
> configured.
> 
> v1:
> Global registers will be set only when payload is enabled.
> They will be reset if payload is disabled or on port reset (uninit).
> 
> v2:
> dev_init and dev_close disable flexible payload by default.
> Flexible payload enabled selectively, only if appropriate PIT is set up. The same
> done for FDIR and for rte_flow API.
> 
> v3:
> Minor fix in comments.
> 
> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
Applied to dpdk-next-net-intel, with minor commit log changes.

/Helin

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

end of thread, other threads:[~2018-01-09 16:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-29 12:55 [dpdk-dev] [PATCH] net/i40e: do not turn on flexible payload on driver init Kirill Rybalchenko
2017-11-30  9:17 ` Xing, Beilei
2017-12-01 15:27 ` Kirill Rybalchenko
2017-12-11  6:00   ` Xing, Beilei
2017-12-12  3:40     ` Xing, Beilei
2018-01-04 17:45   ` [dpdk-dev] [PATCH v2] " Kirill Rybalchenko
2018-01-08  5:41     ` Xing, Beilei
2018-01-09 15:28       ` Zhang, Helin
2018-01-09 15:36     ` [dpdk-dev] [PATCH v3] " Kirill Rybalchenko
2018-01-09 16:06       ` Zhang, Helin

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