Re: [dpdk-dev] [PATCH v2] net/i40e: extend VF reset waiting time

2021-04-25 Thread Zhou, JunX W
> -Original Message-
> From: dev  On Behalf Of Wenjun Wu
> Sent: Sunday, April 25, 2021 10:03 AM
> To: dev@dpdk.org; Xing, Beilei 
> Cc: Wu, Wenjun1 
> Subject: [dpdk-dev] [PATCH v2] net/i40e: extend VF reset waiting time


Tested-by: Zhou, Jun 



[dpdk-dev] Recall: [PATCH v2] net/i40e: extend VF reset waiting time

2021-04-25 Thread Zhou, JunX W
Zhou, JunX W would like to recall the message, "[dpdk-dev] [PATCH v2] net/i40e: 
extend VF reset waiting time".

Re: [dpdk-dev] [PATCH] net/i40e: fix offload flag checking in simple Tx datapath

2021-05-05 Thread Zhou, JunX W
> -Original Message-
> From: dev  On Behalf Of Alvin Zhang
> Sent: Tuesday, April 27, 2021 4:59 PM
> To: Wu, Jingjing ; Xing, Beilei 
> Cc: dev@dpdk.org; Zhang, AlvinX ; sta...@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/i40e: fix offload flag checking in simple Tx 
> datapath

Tested-by: Jun, Zhou 


Re: [dpdk-dev] [PATCH v2] app/testpmd: fix RSS key

2021-01-21 Thread Zhou, JunX W
Tested-by: Zhou, Jun  

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Zhang,Alvin
Sent: Thursday, January 21, 2021 5:42 PM
To: Yigit, Ferruh 
Cc: dev@dpdk.org; Zhang, AlvinX ; sta...@dpdk.org
Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix RSS key

From: Alvin Zhang 

Since the patch '1848b117' has initialized the variable 'key' in 'struct 
rte_flow_action_rss' with 'NULL', the PMD cannot get the RSS key now. Details 
as bellow:

testpmd> flow create 0 ingress pattern eth / ipv4 / end actions
 rss types ipv4-other end key
 1234567890123456789012345678901234567890123
 4567890123456789012345678901234567890
 queues end / end
Flow rule #1 created
testpmd> show port 0 rss-hash key
RSS functions:
 all ipv4-other ip
RSS key:
 4439796BB54C5023B675EA5B124F9F30B8A2C03DDFDC4D02A08C9B3
 34AF64A4C05C6FA343958D8557D99583AE138C92E81150366

This patch sets offset and size of the 'key' variable as the first parameter of 
the token 'key'. Later, the address of the RSS key will be copied to 'key' 
variable.

Fixes: 1848b117cca1 ("app/testpmd: fix RSS key for flow API RSS rule")
Cc: sta...@dpdk.org

Signed-off-by: Alvin Zhang 
---
 app/test-pmd/cmdline_flow.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 
0618611..067e120 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -3541,7 +3541,10 @@ static int comp_set_modify_field_id(struct context *, 
const struct token *,
.name = "key",
.help = "RSS hash key",
.next = NEXT(action_rss, NEXT_ENTRY(HEX)),
-   .args = ARGS(ARGS_ENTRY_ARB(0, 0),
+   .args = ARGS(ARGS_ENTRY_ARB
+(offsetof(struct action_rss_data, conf) +
+ offsetof(struct rte_flow_action_rss, key),
+ sizeof(((struct rte_flow_action_rss *)0)->key)),
 ARGS_ENTRY_ARB
 (offsetof(struct action_rss_data, conf) +
  offsetof(struct rte_flow_action_rss, key_len),
--
1.8.3.1



Re: [dpdk-dev] [PATCH] net/i40e: fix X722 FDIR field mask

2021-01-28 Thread Zhou, JunX W
Tested-by: Zhou, Jun 

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Zhang,Alvin
Sent: Friday, January 29, 2021 10:09 AM
To: Guo, Jia ; Xing, Beilei ; Zhang, 
Qi Z 
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] net/i40e: fix X722 FDIR field mask

From: Alvin Zhang 

The absolute field offsets of IPv4 or IPv6 header are related to hardware 
configuration. The X710 and X722 have different hardware configurations, and 
users can even modify the hardware configuration.
Therefore, The default values cannot be used when calculating mask offset.

commands and packets as below:
  flow create 0 ingress pattern eth / ipv4 proto is 255  / end
  actions queue index 2 / end
  pkt = Ether()/IP(ttl=63, proto=255)/Raw('X'*40)

  flow create 0 ingress pattern eth / ipv4 tos is 50 / udp / end
  actions queue index 2 / end
  pkt = Ether()/IP(tos=50)/UDP()/Raw('X'*40)

  flow create 0 ingress pattern eth / ipv6 tc is 12 / udp / end
  actions queue index 3 / end
  pkt = Ether()/IPv6(tc=12,hlim=34,fl=0x98765)/UDP()/Raw('X'*40)

  flow create 0 ingress pattern eth / ipv6 hop is 34 / end actions
  queue index 3 / end
  pkt = Ether()/IPv6(tc=12,hlim=34,fl=0x98765)/Raw('X'*40)

This patch read the field offsets from the NIC and return the mask register 
value.

Fixes: 98f055707685 ("i40e: configure input fields for RSS or flow director")
Fixes: 92cf7f8ec082 ("i40e: allow filtering on more IP header fields")
Cc: sta...@dpdk.org

Signed-off-by: Alvin Zhang 
---
 drivers/net/i40e/i40e_ethdev.c | 158 +++--
 drivers/net/i40e/i40e_ethdev.h |   4 +-
 drivers/net/i40e/i40e_flow.c   |   2 +-
 3 files changed, 125 insertions(+), 39 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c 
index 946994b..e21c125 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -202,12 +202,12 @@
 #define I40E_TRANSLATE_INSET 0
 #define I40E_TRANSLATE_REG   1
 
-#define I40E_INSET_IPV4_TOS_MASK0x0009FF00UL
-#define I40E_INSET_IPv4_TTL_MASK0x000D00FFUL
-#define I40E_INSET_IPV4_PROTO_MASK  0x000DFF00UL
-#define I40E_INSET_IPV6_TC_MASK 0x0009F00FUL
-#define I40E_INSET_IPV6_HOP_LIMIT_MASK  0x000CFF00UL
-#define I40E_INSET_IPV6_NEXT_HDR_MASK   0x000C00FFUL
+#define I40E_INSET_IPV4_TOS_MASK0xFF00UL
+#define I40E_INSET_IPV4_TTL_MASK0x00FFUL
+#define I40E_INSET_IPV4_PROTO_MASK  0xFF00UL
+#define I40E_INSET_IPV6_TC_MASK 0xF00FUL
+#define I40E_INSET_IPV6_HOP_LIMIT_MASK  0xFF00UL
+#define I40E_INSET_IPV6_NEXT_HDR_MASK   0x00FFUL
 
 /* PCI offset for querying capability */
 #define PCI_DEV_CAP_REG0xA4
@@ -220,6 +220,25 @@
 /* Bit mask of Extended Tag enable/disable */  #define 
PCI_DEV_CTRL_EXT_TAG_MASK  (1 << PCI_DEV_CTRL_EXT_TAG_SHIFT)
 
+#define I40E_GLQF_PIT_IPV4_START   2
+#define I40E_GLQF_PIT_IPV4_COUNT   2
+#define I40E_GLQF_PIT_IPV6_START   4
+#define I40E_GLQF_PIT_IPV6_COUNT   2
+
+#define I40E_GLQF_PIT_SOURCE_OFF_GET(a)\
+   (((a) & I40E_GLQF_PIT_SOURCE_OFF_MASK) >> \
+I40E_GLQF_PIT_SOURCE_OFF_SHIFT)
+
+#define I40E_GLQF_PIT_DEST_OFF_GET(a) \
+   (((a) & I40E_GLQF_PIT_DEST_OFF_MASK) >> \
+I40E_GLQF_PIT_DEST_OFF_SHIFT)
+
+#define I40E_GLQF_PIT_FSIZE_GET(a) (((a) & I40E_GLQF_PIT_FSIZE_MASK) >> \
+I40E_GLQF_PIT_FSIZE_SHIFT)
+
+#define I40E_GLQF_PIT_BUILD(off, mask) (((off) << 16) | (mask))
+#define I40E_FDIR_FIELD_OFFSET(a)  ((a) >> 1)
+
 static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev, void *init_params);  
static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);  static int 
i40e_dev_configure(struct rte_eth_dev *dev); @@ -9417,49 +9436,116 @@ 
i40e_status_code i40e_replace_gtp_cloud_filter(struct i40e_pf *pf)
return val;
 }
 
+static int
+i40e_fd_get_field_offset(struct i40e_hw *hw, uint32_t pit_reg_start,
+ uint32_t pit_reg_count, uint32_t hdr_off) {
+   const uint32_t pit_reg_end = pit_reg_start + pit_reg_count;
+   uint32_t field_off = I40E_FDIR_FIELD_OFFSET(hdr_off);
+   uint32_t i, reg_val, src_off, count;
+
+   for (i = pit_reg_start; i < pit_reg_end; i++) {
+   reg_val = i40e_read_rx_ctl(hw, I40E_GLQF_PIT(i));
+
+   src_off = I40E_GLQF_PIT_SOURCE_OFF_GET(reg_val);
+   count = I40E_GLQF_PIT_FSIZE_GET(reg_val);
+
+   if (src_off <= field_off && (src_off + count) > field_off)
+   break;
+   }
+
+   if (i >= pit_reg_end) {
+   PMD_DRV_LOG(ERR,
+   "Hardware GLQF_PIT configuration does not support 
this field mask");
+   return -1;
+   }
+
+   return I40E_GLQF_PIT_DEST_OFF_GET(reg_val) + field_off - src_off; }
+
 int
-i40e_generate_inset_mask_reg(uint6

Re: [dpdk-dev] [PATCH] net/virtio: fix missing listen FD initialization

2021-02-02 Thread Zhou, JunX W
Tested-by: Zhou, Jun  

-Original Message-
From: Maxime Coquelin [mailto:maxime.coque...@redhat.com] 
Sent: Monday, February 1, 2021 5:33 PM
To: dev@dpdk.org; Wang, Yinan ; Xia, Chenbo 
; amore...@redhat.com; david.march...@redhat.com; Ling, 
WeiX ; Jiang, YuX 
Cc: Maxime Coquelin ; Zhou, JunX W 

Subject: [PATCH] net/virtio: fix missing listen FD initialization

When running in client mode, the listen file descriptor is not initialized, and 
so has value 0. At destroy time, the listen FD is closed if its value is 
greater than or equal to zero, which causes STDIN to be closed.

Fixes: 949735312f5e ("net/virtio: move vhost-user specifics to its backend") 
Bugzilla ID: 630

Reported-by: Jun W Zhou 
Signed-off-by: Maxime Coquelin 
---
 drivers/net/virtio/virtio_user/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/virtio/virtio_user/vhost_user.c 
b/drivers/net/virtio/virtio_user/vhost_user.c
index ec2c53c8fb..f8569f6e6f 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -831,6 +831,7 @@ vhost_user_setup(struct virtio_user_dev *dev)
dev->backend_data = data;
 
data->vhostfd = -1;
+   data->listenfd = -1;
 
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
--
2.29.2



Re: [dpdk-dev] [PATCH v2] lib/table: fix cache alignment issue

2020-07-02 Thread Zhou, JunX W
Tested-by: junx.w.z...@intel.com

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Ting Xu
Sent: Wednesday, June 17, 2020 1:44 PM
To: dev@dpdk.org
Cc: Dumitrescu, Cristian ; sta...@dpdk.org
Subject: [dpdk-dev] [PATCH v2] lib/table: fix cache alignment issue

When create softnic hash table with 16 keys, it failed on 32bit environment 
because of the structure rte_bucket_4_16 alignment issue. Add 
__rte_cache_aligned to ensure correct cache align.

Fixes: 8aa327214c ("table: hash")
Cc: sta...@dpdk.org

Signed-off-by: Ting Xu 

---
v1->v2: Correct patch time
---
 lib/librte_table/rte_table_hash_key16.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_table/rte_table_hash_key16.c 
b/lib/librte_table/rte_table_hash_key16.c
index 2cca1c924..5e1665c15 100644
--- a/lib/librte_table/rte_table_hash_key16.c
+++ b/lib/librte_table/rte_table_hash_key16.c
@@ -44,7 +44,7 @@ struct rte_bucket_4_16 {
uint64_t key[4][2];
 
/* Cache line 2 */
-   uint8_t data[0];
+   uint8_t data[0] __rte_cache_aligned;
 };
 
 struct rte_table_hash {
--
2.17.1



Re: [dpdk-dev] [PATCH] examples/eventdev_pipeline: fix segfault on exit

2020-05-07 Thread Zhou, JunX W
Tested-by: Zhou, JunX W 

-Original Message-
From: Van Haaren, Harry 
Sent: Tuesday, May 5, 2020 5:39 PM
To: dev@dpdk.org
Cc: Zhou, JunX W ; Van Haaren, Harry 
; sta...@dpdk.org; pbhagavat...@caviumnetworks.com
Subject: [PATCH] examples/eventdev_pipeline: fix segfault on exit

This commit fixes a segfault on exit by using Ctrl^C if the master lcore was 
also being used as a worker core. The root cause of the issue was that the 
interrupt handler was cleaning up resources such as the ethdev and eventdev 
ports, and once the interrupt handler would return, that thread would continue 
working as an eventdev worker, and dereference the memory which just had free() 
called on it.

Fixed by moving the cleanup code from the interrupt handler to the cleanup 
stage of main(), which the master thread will execute once it has returned from 
its worker() functionality.

Fixes: 085edac2ca38 ("examples/eventdev_pipeline: support Tx adapter")

Signed-off-by: Harry van Haaren 

---

Cc: sta...@dpdk.org
Cc: pbhagavat...@caviumnetworks.com
---
 examples/eventdev_pipeline/main.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/examples/eventdev_pipeline/main.c 
b/examples/eventdev_pipeline/main.c
index d0da51b1c..21958269f 100644
--- a/examples/eventdev_pipeline/main.c
+++ b/examples/eventdev_pipeline/main.c
@@ -301,12 +301,6 @@ signal_handler(int signum)
 
rte_eal_mp_wait_lcore();
 
-   RTE_ETH_FOREACH_DEV(portid) {
-   rte_eth_dev_close(portid);
-   }
-
-   rte_event_dev_stop(0);
-   rte_event_dev_close(0);
}
if (signum == SIGTSTP)
rte_event_dev_dump(0, stdout);
@@ -469,5 +463,14 @@ main(int argc, char **argv)
 
}
 
+   RTE_ETH_FOREACH_DEV(portid) {
+   rte_eth_dev_close(portid);
+   }
+
+   rte_event_dev_stop(0);
+   rte_event_dev_close(0);
+
+   rte_eal_cleanup();
+
return 0;
 }
--
2.17.1



Re: [dpdk-dev] [dpdk-stable] [PATCH v3] eal/mem: preallocate VA space in no-huge mode

2020-03-26 Thread Zhou, JunX W
Tested-by: Zhou, JunX W 
-Original Message-
From: Jiang, YuX 
Sent: Thursday, March 26, 2020 8:24 PM
To: David Marchand ; Burakov, Anatoly 

Cc: dev ; dpdk stable ; Zhou, JunX W 

Subject: RE: [dpdk-dev] [dpdk-stable] [PATCH v3] eal/mem: preallocate VA space 
in no-huge mode

+  Zhou, JunX W 

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of David Marchand
Sent: Wednesday, March 25, 2020 10:40 PM
To: Burakov, Anatoly 
Cc: dev ; dpdk stable 
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v3] eal/mem: preallocate VA space 
in no-huge mode

On Fri, Feb 7, 2020 at 12:11 PM Anatoly Burakov  
wrote:
>
> When --no-huge mode is used, the memory is currently allocated with 
> mmap(NULL, ...). This is fine in most cases, but can fail in cases 
> where DPDK is run on a machine with an IOMMU that is of more limited 
> address width than that of a VA, because we're not specifying the 
> address hint for mmap() call.
>
> Fix it by preallocating VA space before mapping it.
>
> Cc: sta...@dpdk.org
>
> Signed-off-by: Anatoly Burakov 

Reproduced issue reported by Thomas on v2.
Works fine with v3.

Tested-by: David Marchand 


Does this issue affect FreeBSD too?

--
David Marchand



Re: [dpdk-dev] [PATCH] net/i40e: fix Rx-bytes statistics

2020-12-17 Thread Zhou, JunX W
Tested-by: Zhou, Jun  

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Zhang,Alvin
Sent: Tuesday, December 15, 2020 5:51 PM
To: Guo, Jia ; Xing, Beilei 
Cc: dev@dpdk.org; Zhang, AlvinX ; sta...@dpdk.org
Subject: [dpdk-dev] [PATCH] net/i40e: fix Rx-bytes statistics

From: Alvin Zhang 

Update the Rx-bytes statistics by subtract CRC bytes count from original bytes 
count.

Fixes: bd7883c07d4a ("net/i40e: refactor some stats related functions")
Cc: sta...@dpdk.org

Signed-off-by: Alvin Zhang 
---
 drivers/net/i40e/i40e_ethdev_vf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index c26b036..b82e782 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -2406,6 +2406,7 @@ static int eth_i40evf_pci_remove(struct rte_pci_device 
*pci_dev)
stats->imissed = pstats->rx_discards;
stats->oerrors = pstats->tx_errors + pstats->tx_discards;
stats->ibytes = pstats->rx_bytes;
+   stats->ibytes -= stats->ipackets * RTE_ETHER_CRC_LEN;
stats->obytes = pstats->tx_bytes;
} else {
PMD_DRV_LOG(ERR, "Get statistics failed");
--
1.8.3.1



Re: [dpdk-dev] [PATCH v2] net/ixgbe: fix fdirctrl register setting

2020-12-21 Thread Zhou, JunX W
Tested-by: Zhou, Jun  

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of dapengx...@intel.com
Sent: Tuesday, December 15, 2020 6:11 PM
To: Guo, Jia 
Cc: dev@dpdk.org; Yu, DapengX ; sta...@dpdk.org
Subject: [dpdk-dev] [PATCH v2] net/ixgbe: fix fdirctrl register setting

From: YU DAPENG 

The function ixgbe_fdir_set_flexbytes_offset is used when create FDir rule for 
flexbytes. It set a register: FDIRCTRL.FLEX_OFFSET, which cause that even if 
the FDir flexbytes rule is destroyed, the rule still direct the packet and 
transfer it to the wrong place. It is because setting FDIRCTRL shall only be 
permitted on Flow Director initialization flow or clearing the Flow Director 
table according to intel datasheet, otherwise unexpected happens. In order to 
evade the limit, add code to set FDIRCMD.CLEARHT to 1b and then clear it back 
to 0b to make the setting act like the Flow Director initialization flow or 
clearing the Flow Director table.

Fixes: f35fec63dde1 ("net/ixgbe: enable flex bytes for generic flow API")
Cc: sta...@dpdk.org

Signed-off-by: YU DAPENG 
---
 drivers/net/ixgbe/ixgbe_fdir.c | 29 +  
drivers/net/ixgbe/ixgbe_flow.c | 15 ---
 2 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_fdir.c b/drivers/net/ixgbe/ixgbe_fdir.c 
index a0fab5070..11b9effeb 100644
--- a/drivers/net/ixgbe/ixgbe_fdir.c
+++ b/drivers/net/ixgbe/ixgbe_fdir.c
@@ -503,9 +503,30 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev,
uint16_t offset)
 {
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct ixgbe_hw_fdir_info *fdir_info =
+   IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
uint32_t fdirctrl;
int i;
 
+   if (fdir_info->flex_bytes_offset == offset)
+   return 0;
+
+   /**
+* 82599 adapters flow director init flow cannot be restarted,
+* Workaround 82599 silicon errata by performing the following steps
+* before re-writing the FDIRCTRL control register with the same value.
+* - write 1 to bit 8 of FDIRCMD register &
+* - write 0 to bit 8 of FDIRCMD register
+*/
+   IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
+   (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) |
+IXGBE_FDIRCMD_CLEARHT));
+   IXGBE_WRITE_FLUSH(hw);
+   IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
+   (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
+~IXGBE_FDIRCMD_CLEARHT));
+   IXGBE_WRITE_FLUSH(hw);
+
fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
 
fdirctrl &= ~IXGBE_FDIRCTRL_FLEX_MASK; @@ -520,6 +541,14 @@ 
ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev,
break;
msec_delay(1);
}
+
+   if (i >= IXGBE_FDIR_INIT_DONE_POLL) {
+   PMD_DRV_LOG(ERR, "Flow Director poll time exceeded!");
+   return -ETIMEDOUT;
+   }
+
+   fdir_info->flex_bytes_offset = offset;
+
return 0;
 }
 
diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c 
index 39f6ed73f..9aeb2e4a4 100644
--- a/drivers/net/ixgbe/ixgbe_flow.c
+++ b/drivers/net/ixgbe/ixgbe_flow.c
@@ -3137,13 +3137,13 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
rte_memcpy(&fdir_info->mask,
&fdir_rule.mask,
sizeof(struct ixgbe_hw_fdir_mask));
-   fdir_info->flex_bytes_offset =
-   fdir_rule.flex_bytes_offset;
 
-   if (fdir_rule.mask.flex_bytes_mask)
-   ixgbe_fdir_set_flexbytes_offset(dev,
+   if (fdir_rule.mask.flex_bytes_mask) {
+   ret = 
ixgbe_fdir_set_flexbytes_offset(dev,
fdir_rule.flex_bytes_offset);
-
+   if (ret)
+   goto out;
+   }
ret = ixgbe_fdir_set_input_mask(dev);
if (ret)
goto out;
@@ -3161,8 +3161,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
if (ret)
goto out;
 
-   if (fdir_info->flex_bytes_offset !=
-   fdir_rule.flex_bytes_offset)
+   if (fdir_rule.mask.flex_bytes_mask &&
+   fdir_info->flex_bytes_offset !=
+   fdir_rule.flex_bytes_offset)
goto out;
}
}
--

Re: [dpdk-dev] [PATCH v2] net/i40e: fix incorrect FDIR flex configuration

2020-11-08 Thread Zhou, JunX W
Tested-by: Zhou, Jun 

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Chenxu Di
Sent: Friday, November 6, 2020 2:47 PM
To: dev@dpdk.org
Cc: Xing, Beilei ; Guo, Jia ; Wang, 
Haiyue ; Di, ChenxuX ; 
sta...@dpdk.org
Subject: [dpdk-dev] [PATCH v2] net/i40e: fix incorrect FDIR flex configuration

The configuration of FDIR flex mask and flex pit should not be set during flow 
validate. It should be set when flow create.

Fixes: 6ced3dd72f5f ("net/i40e: support flexible payload parsing for FDIR")
Cc: sta...@dpdk.org

Signed-off-by: Chenxu Di 
---
v2:
-Merge two patches into one patch.
---
 drivers/net/i40e/i40e_ethdev.h |  22 ++--
 drivers/net/i40e/i40e_fdir.c   | 194 
 drivers/net/i40e/i40e_flow.c   | 195 ++---
 3 files changed, 216 insertions(+), 195 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h 
index 1466998aa..e00133c88 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -599,11 +599,22 @@ enum i40e_fdir_ip_type {
I40E_FDIR_IPTYPE_IPV6,
 };
 
+/*
+ * Structure to store flex pit for flow diretor.
+ */
+struct i40e_fdir_flex_pit {
+   uint8_t src_offset; /* offset in words from the beginning of payload */
+   uint8_t size;   /* size in words */
+   uint8_t dst_offset; /* offset in words of flexible payload */ };
+
 /* A structure used to contain extend input of flow */  struct 
i40e_fdir_flow_ext {
uint16_t vlan_tci;
uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
/* It is filled by the flexible payload to match. */
+   uint8_t flex_mask[I40E_FDIR_MAX_FLEX_LEN];
+   uint8_t raw_id;
uint8_t is_vf;   /* 1 for VF, 0 for port dev */
uint16_t dst_id; /* VF ID, available when is_vf is 1*/
bool inner_ip;   /* If there is inner ip */
@@ -612,6 +623,8 @@ struct i40e_fdir_flow_ext {
bool customized_pctype; /* If customized pctype is used */
bool pkt_template; /* If raw packet template is used */
bool is_udp; /* ipv4|ipv6 udp flow */
+   enum i40e_flxpld_layer_idx layer_idx;
+   struct i40e_fdir_flex_pit flex_pit[I40E_MAX_FLXPLD_LAYER * 
+I40E_MAX_FLXPLD_FIED];
 };
 
 /* A structure used to define the input for a flow director filter entry */ @@ 
-663,15 +676,6 @@ struct i40e_fdir_filter_conf {
struct i40e_fdir_action action;  /* Action taken when match */  };
 
-/*
- * Structure to store flex pit for flow diretor.
- */
-struct i40e_fdir_flex_pit {
-   uint8_t src_offset;/* offset in words from the beginning of payload 
*/
-   uint8_t size;  /* size in words */
-   uint8_t dst_offset;/* offset in words of flexible payload */
-};
-
 struct i40e_fdir_flex_mask {
uint8_t word_mask;  /**< Bit i enables word i of flexible payload */
uint8_t nb_bitmask;
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c index 
aa8e72949..e64cb2fd0 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -1765,6 +1765,153 @@ i40e_add_del_fdir_filter(struct rte_eth_dev *dev,
return ret;
 }
 
+static int
+i40e_flow_store_flex_pit(struct i40e_pf *pf,
+struct i40e_fdir_flex_pit *flex_pit,
+enum i40e_flxpld_layer_idx layer_idx,
+uint8_t raw_id)
+{
+   uint8_t field_idx;
+
+   field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + raw_id;
+   /* Check if the configuration is conflicted */
+   if (pf->fdir.flex_pit_flag[layer_idx] &&
+   (pf->fdir.flex_set[field_idx].src_offset != flex_pit->src_offset ||
+pf->fdir.flex_set[field_idx].size != flex_pit->size ||
+pf->fdir.flex_set[field_idx].dst_offset != flex_pit->dst_offset))
+   return -1;
+
+   /* Check if the configuration exists. */
+   if (pf->fdir.flex_pit_flag[layer_idx] &&
+   (pf->fdir.flex_set[field_idx].src_offset == flex_pit->src_offset &&
+pf->fdir.flex_set[field_idx].size == flex_pit->size &&
+pf->fdir.flex_set[field_idx].dst_offset == flex_pit->dst_offset))
+   return 1;
+
+   pf->fdir.flex_set[field_idx].src_offset =
+   flex_pit->src_offset;
+   pf->fdir.flex_set[field_idx].size =
+   flex_pit->size;
+   pf->fdir.flex_set[field_idx].dst_offset =
+   flex_pit->dst_offset;
+
+   return 0;
+}
+
+static void
+i40e_flow_set_fdir_flex_pit(struct i40e_pf *pf,
+   enum i40e_flxpld_layer_idx layer_idx,
+   uint8_t raw_id)
+{
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+   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_

Re: [dpdk-dev] [PATCH 5/5] net/softnic: update headers size calculation

2020-11-17 Thread Zhou, JunX W
Tested-by: Zhou, Jun 

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Xiaoyu Min
Sent: Monday, November 16, 2020 3:55 PM
To: Singh, Jasvinder ; Dumitrescu, Cristian 

Cc: dev@dpdk.org; Dekel Peled 
Subject: [dpdk-dev] [PATCH 5/5] net/softnic: update headers size calculation

From: Dekel Peled 

The rte_flow_item_eth and rte_flow_item_vlan items were updated in [1].
The rte_flow_item_ipv6 item was updated in [2].
The structs now contain additional metadata following the header data.
The size to use for match should be the header data size only, and not the size 
of the whole struct.

This patch replaces the rte_flow_item_* with the corresponding rte_*_hdr.

[1]:commit 09315fc83861 ("ethdev: add VLAN attributes to ethernet and VLAN
items")

[2]: commit ad976bd40d28 ("ethdev: add extensions attributes to IPv6 item")

Signed-off-by: Dekel Peled 
---
 drivers/net/softnic/rte_eth_softnic_flow.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c 
b/drivers/net/softnic/rte_eth_softnic_flow.c
index f05ff092fa..7925bad1c0 100644
--- a/drivers/net/softnic/rte_eth_softnic_flow.c
+++ b/drivers/net/softnic/rte_eth_softnic_flow.c
@@ -169,22 +169,22 @@ flow_item_is_proto(enum rte_flow_item_type type,
 
case RTE_FLOW_ITEM_TYPE_ETH:
*mask = &rte_flow_item_eth_mask;
-   *size = sizeof(struct rte_flow_item_eth);
+   *size = sizeof(struct rte_ether_hdr);
return 1; /* TRUE */
 
case RTE_FLOW_ITEM_TYPE_VLAN:
*mask = &rte_flow_item_vlan_mask;
-   *size = sizeof(struct rte_flow_item_vlan);
+   *size = sizeof(struct rte_vlan_hdr);
return 1;
 
case RTE_FLOW_ITEM_TYPE_IPV4:
*mask = &rte_flow_item_ipv4_mask;
-   *size = sizeof(struct rte_flow_item_ipv4);
+   *size = sizeof(struct rte_ipv4_hdr);
return 1;
 
case RTE_FLOW_ITEM_TYPE_IPV6:
*mask = &rte_flow_item_ipv6_mask;
-   *size = sizeof(struct rte_flow_item_ipv6);
+   *size = sizeof(struct rte_ipv6_hdr);
return 1;
 
case RTE_FLOW_ITEM_TYPE_ICMP:
--
2.25.1



Re: [dpdk-dev] [PATCH] net/ixgbe: fix fdirctrl register setting

2020-12-14 Thread Zhou, JunX W
Tested-by: Zhou, Jun 

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of dapengx...@intel.com
Sent: Friday, December 11, 2020 9:35 AM
To: Guo, Jia 
Cc: dev@dpdk.org; Yu, DapengX ; Zhang, Qi Z 

Subject: [dpdk-dev] [PATCH] net/ixgbe: fix fdirctrl register setting

From: YU DAPENG 

The function ixgbe_fdir_set_flexbytes_offset is used when create FDir rule for 
flexbytes. It set a register: FDIRCTRL.FLEX_OFFSET, which cause that even if 
the FDir flexbytes rule is destroyed, the rule still direct the packet and 
transfer it to the wrong place. It is because Setting FDIRCTRL shall only be 
permitted on Flow Director initialization flow or Clearing the Flow Director 
table, otherwise unexpected happens. In order to evade the limit, add code to 
make setting FDIRCTRL work without unexpected effects.

Fixes: f35fec63dde1 ("net/ixgbe: enable flex bytes for generic flow API")
Cc: qi.z.zh...@intel.com

Signed-off-by: YU DAPENG 
---
 drivers/net/ixgbe/ixgbe_fdir.c | 23 +++  
drivers/net/ixgbe/ixgbe_flow.c |  7 +++
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_fdir.c b/drivers/net/ixgbe/ixgbe_fdir.c 
index a0fab5070..5656b 100644
--- a/drivers/net/ixgbe/ixgbe_fdir.c
+++ b/drivers/net/ixgbe/ixgbe_fdir.c
@@ -503,9 +503,32 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev,
uint16_t offset)
 {
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct ixgbe_hw_fdir_info *fdir_info =
+   IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
uint32_t fdirctrl;
int i;
 
+   if (fdir_info->flex_bytes_offset == offset)
+   return 0;
+
+   fdir_info->flex_bytes_offset = offset;
+
+   /*
+* 82599 adapters flow director init flow cannot be restarted,
+* Workaround 82599 silicon errata by performing the following steps
+* before re-writing the FDIRCTRL control register with the same value.
+* - write 1 to bit 8 of FDIRCMD register &
+* - write 0 to bit 8 of FDIRCMD register
+*/
+   IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
+   (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) |
+IXGBE_FDIRCMD_CLEARHT));
+   IXGBE_WRITE_FLUSH(hw);
+   IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
+   (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
+~IXGBE_FDIRCMD_CLEARHT));
+   IXGBE_WRITE_FLUSH(hw);
+
fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
 
fdirctrl &= ~IXGBE_FDIRCTRL_FLEX_MASK; diff --git 
a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 
39f6ed73f..b37541d9b 100644
--- a/drivers/net/ixgbe/ixgbe_flow.c
+++ b/drivers/net/ixgbe/ixgbe_flow.c
@@ -3137,8 +3137,6 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
rte_memcpy(&fdir_info->mask,
&fdir_rule.mask,
sizeof(struct ixgbe_hw_fdir_mask));
-   fdir_info->flex_bytes_offset =
-   fdir_rule.flex_bytes_offset;
 
if (fdir_rule.mask.flex_bytes_mask)
ixgbe_fdir_set_flexbytes_offset(dev,
@@ -3161,8 +3159,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
if (ret)
goto out;
 
-   if (fdir_info->flex_bytes_offset !=
-   fdir_rule.flex_bytes_offset)
+   if (fdir_rule.mask.flex_bytes_mask &&
+   (fdir_info->flex_bytes_offset !=
+   fdir_rule.flex_bytes_offset))
goto out;
}
}
--
2.26.2.windows.1



Re: [dpdk-dev] [PATCH] net/dpaa2: fix build error about timesync functions

2020-09-15 Thread Zhou, JunX W
Tested-by: Zhou, Jun  

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Chenxu Di
Sent: Tuesday, September 15, 2020 10:41 AM
To: dev@dpdk.org
Cc: hemant.agra...@nxp.com; sachin.sax...@nxp.com; Di, ChenxuX 
; sta...@dpdk.org
Subject: [dpdk-dev] [PATCH] net/dpaa2: fix build error about timesync functions

When the build option has '-DRTE_LIBRTE_IEEE1588=1', the announce of timesync 
functions will be build.
However the dpdk_conf doesn't hav RTE_LIBRTE_IEEE1588 so that the file 
dpaa2_ptp.c will not be build.
It cause the build error.
This patch fixes it by adding set for dpdk_conf.

Fixes: 184c39d16568 ("net/dpaa2: add DPRTC sub-module")
Cc: sta...@dpdk.org

Signed-off-by: Chenxu Di 
---
 drivers/net/dpaa2/meson.build | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build 
index 6dd0eb274..d9aadfdae 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -17,6 +17,10 @@ sources = files('base/dpaa2_hw_dpni.c',
'mc/dpdmux.c',
'mc/dpni.c')
 
+if '-DRTE_LIBRTE_IEEE1588=1' in get_option('c_args')
+   dpdk_conf.set('RTE_LIBRTE_IEEE1588', 1) endif
+
 if dpdk_conf.has('RTE_LIBRTE_IEEE1588')
sources += files('mc/dprtc.c')
sources += files('dpaa2_ptp.c')
--
2.17.1