Re: [dpdk-dev] [PATCH v7 2/5] eal/windows: hide asprintf() shim

2021-04-10 Thread Nick Connolly




Make asprintf(3) implementation for Windows private to EAL, so that it's
hidden from external consumers. It is not exposed to internal consumers
either, because they don't need asprintf() and also because callers from
other modules would have no reliable way to free allocated memory.

Signed-off-by: Dmitry Kozlyuk 
Acked-by: Khoa To 

Acked-by: Nick Connolly 



[dpdk-dev] [PATCH v3 0/4] Support PPS(packet per second) on meter

2021-04-10 Thread Li Zhang
Currently meter algorithms only supports rate is bytes per second(BPS).
Add packet_mode flag in meter profile parameters data structure.
So that it can meter traffic by packet per second.

When packet_mode is 0, the profile rates and bucket sizes are
specified in bytes per second and bytes
when packet_mode is not 0, the profile rates and bucket sizes are
specified in packets and packets per second.

Add the necessary checks to the existing drivers implementing
the rte_mtr API to makes sure that profiles with
packet_mode set to TRUE are rejected.

RFC ("adds support PPS(packet per second) on meter")
https://patchwork.dpdk.org/project/dpdk/patch/20210125012023.1769769-2-l...@nvidia.com/

Depends-on: series=15998  ("Add ASO meter support in MLX5 PMD")
https://patchwork.dpdk.org/project/dpdk/list/?series=15998

V2: create a unified patch that contains both the series with
the API changes and the series with the necessary error checks in the 
drivers.

V3: Fix comments from Matan and Cristian.

Li Zhang (4):
  ethdev: add packet mode in meter profile structure
  app/testpmd: add meter profile packet mode option
  net/softnic: check meter packet mode
  net/mvpp2: check meter packet mode

 app/test-pmd/cmdline_mtr.c  | 40 -
 doc/guides/rel_notes/release_21_05.rst  | 12 +++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 31 +++
 drivers/net/mvpp2/mrvl_mtr.c|  6 ++
 drivers/net/softnic/rte_eth_softnic_meter.c |  8 ++
 lib/librte_ethdev/rte_mtr.h | 90 ++---
 6 files changed, 159 insertions(+), 28 deletions(-)

-- 
2.21.0



[dpdk-dev] [PATCH v3 1/4] ethdev: add packet mode in meter profile structure

2021-04-10 Thread Li Zhang
Currently meter algorithms only supports rate is bytes per second(BPS).
Add packet_mode flag in meter profile parameters data structure.
So that it can meter traffic by packet per second.

When packet_mode is 0, the profile rates and bucket sizes are
specified in bytes per second and bytes
when packet_mode is not 0, the profile rates and bucket sizes are
specified in packets and packets per second.

The below structure will be extended:
rte_mtr_meter_profile
rte_mtr_capabilities

Signed-off-by: Li Zhang 
Acked-by: Matan Azrad 
---
 doc/guides/rel_notes/release_21_05.rst | 12 
 lib/librte_ethdev/rte_mtr.h| 90 ++
 2 files changed, 91 insertions(+), 11 deletions(-)

diff --git a/doc/guides/rel_notes/release_21_05.rst 
b/doc/guides/rel_notes/release_21_05.rst
index f199ad286d..b4653d63a1 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -152,6 +152,18 @@ New Features
   * ethdev: Added RTE_FLOW_ACTION_TYPE_METER_COLOR in enum 
rte_flow_action_type.
   * ethdev: Added RTE_MTR_ERROR_TYPE_METER_POLICY_ID and 
RTE_MTR_ERROR_TYPE_METER_POLICY_ID into rte_mtr_error_type.
 
+* **Added support for meter PPS profile.**
+
+  Currently meter algorithms only supports bytes per second(BPS).
+  Add packet_mode in the meter profile parameters data structures
+  to support packet per second (PPS) mode.
+  So that it can meter traffic by packet per second.
+  Packet_mode must be 0 when it is bytes mode.
+
+* **Updated MLX5 driver.**
+
+  * Added support for meter profile packet per second mode (packet_mode).
+
 Removed Items
 -
 
diff --git a/lib/librte_ethdev/rte_mtr.h b/lib/librte_ethdev/rte_mtr.h
index 4938ef065f..778fad7638 100644
--- a/lib/librte_ethdev/rte_mtr.h
+++ b/lib/librte_ethdev/rte_mtr.h
@@ -133,46 +133,71 @@ struct rte_mtr_meter_profile {
union {
/** Items only valid when *alg* is set to srTCM - RFC 2697. */
struct {
-   /** Committed Information Rate (CIR) (bytes/second). */
+   /**
+* Committed Information Rate (CIR)
+* (bytes per second or packets per second).
+*/
uint64_t cir;
 
-   /** Committed Burst Size (CBS) (bytes). */
+   /** Committed Burst Size (CBS) (bytes or packets). */
uint64_t cbs;
 
-   /** Excess Burst Size (EBS) (bytes). */
+   /** Excess Burst Size (EBS) (bytes or packets). */
uint64_t ebs;
} srtcm_rfc2697;
 
/** Items only valid when *alg* is set to trTCM - RFC 2698. */
struct {
-   /** Committed Information Rate (CIR) (bytes/second). */
+   /**
+* Committed Information Rate (CIR)
+* (bytes per second or packets per second).
+*/
uint64_t cir;
 
-   /** Peak Information Rate (PIR) (bytes/second). */
+   /**
+* Peak Information Rate (PIR)
+* (bytes per second or packets per second).
+*/
uint64_t pir;
 
-   /** Committed Burst Size (CBS) (byes). */
+   /** Committed Burst Size (CBS) (bytes or packets). */
uint64_t cbs;
 
-   /** Peak Burst Size (PBS) (bytes). */
+   /** Peak Burst Size (PBS) (bytes or packets). */
uint64_t pbs;
} trtcm_rfc2698;
 
/** Items only valid when *alg* is set to trTCM - RFC 4115. */
struct {
-   /** Committed Information Rate (CIR) (bytes/second). */
+   /**
+* Committed Information Rate (CIR)
+* (bytes per second or packets per second).
+*/
uint64_t cir;
 
-   /** Excess Information Rate (EIR) (bytes/second). */
+   /**
+* Excess Information Rate (EIR)
+* (bytes per second or packets per second).
+*/
uint64_t eir;
 
-   /** Committed Burst Size (CBS) (byes). */
+   /** Committed Burst Size (CBS) (bytes or packets). */
uint64_t cbs;
 
-   /** Excess Burst Size (EBS) (bytes). */
+   /** Excess Burst Size (EBS) (bytes or packets). */
uint64_t ebs;
} trtcm_rfc4115;
};
+
+   /**
+* When zero, the byte mode is enabled for the current profile, so the
+*

[dpdk-dev] [PATCH v3 2/4] app/testpmd: add meter profile packet mode option

2021-04-10 Thread Li Zhang
add meter profile packet_mode to the ethernet device.
One example:
add port meter profile rfc2697 (port_id) (profile_id)
(cir) (cbs) (ebs) (packet_mode)

Signed-off-by: Li Zhang 
Acked-by: Matan Azrad 
---
 app/test-pmd/cmdline_mtr.c  | 40 +++--
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 31 
 2 files changed, 54 insertions(+), 17 deletions(-)

diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index bdc9ae8bfe..eff2473e7b 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -263,6 +263,18 @@ static void cmd_show_port_meter_cap_parsed(void 
*parsed_result,
cap.color_aware_trtcm_rfc2698_supported);
printf("cap.color_aware_trtcm_rfc4115_supported %" PRId32 "\n",
cap.color_aware_trtcm_rfc4115_supported);
+   printf("cap.srtcm_rfc2697_byte_mode_supported %" PRId32 "\n",
+   cap.srtcm_rfc2697_byte_mode_supported);
+   printf("cap.srtcm_rfc2697_packet_mode_supported %" PRId32 "\n",
+   cap.srtcm_rfc2697_packet_mode_supported);
+   printf("cap.trtcm_rfc2698_byte_mode_supported %" PRId32 "\n",
+   cap.trtcm_rfc2698_byte_mode_supported);
+   printf("cap.trtcm_rfc2698_packet_mode_supported %" PRId32 "\n",
+   cap.trtcm_rfc2698_packet_mode_supported);
+   printf("cap.trtcm_rfc4115_byte_mode_supported %" PRId32 "\n",
+   cap.trtcm_rfc4115_byte_mode_supported);
+   printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
+   cap.trtcm_rfc4115_packet_mode_supported);
printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
 }
 
@@ -292,6 +304,7 @@ struct cmd_add_port_meter_profile_srtcm_result {
uint64_t cir;
uint64_t cbs;
uint64_t ebs;
+   int packet_mode;
 };
 
 cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_add =
@@ -333,6 +346,10 @@ cmdline_parse_token_num_t 
cmd_add_port_meter_profile_srtcm_ebs =
TOKEN_NUM_INITIALIZER(
struct cmd_add_port_meter_profile_srtcm_result,
ebs, RTE_UINT64);
+cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_packet_mode =
+   TOKEN_NUM_INITIALIZER(
+   struct cmd_add_port_meter_profile_srtcm_result,
+   packet_mode, RTE_UINT32);
 
 static void cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
@@ -354,6 +371,7 @@ static void cmd_add_port_meter_profile_srtcm_parsed(void 
*parsed_result,
mp.srtcm_rfc2697.cir = res->cir;
mp.srtcm_rfc2697.cbs = res->cbs;
mp.srtcm_rfc2697.ebs = res->ebs;
+   mp.packet_mode = res->packet_mode;
 
ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
if (ret != 0) {
@@ -365,7 +383,7 @@ static void cmd_add_port_meter_profile_srtcm_parsed(void 
*parsed_result,
 cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm = {
.f = cmd_add_port_meter_profile_srtcm_parsed,
.data = NULL,
-   .help_str = "add port meter profile srtcm_rfc2697  
   ",
+   .help_str = "add port meter profile srtcm_rfc2697  
",
.tokens = {
(void *)&cmd_add_port_meter_profile_srtcm_add,
(void *)&cmd_add_port_meter_profile_srtcm_port,
@@ -377,6 +395,7 @@ cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm = {
(void *)&cmd_add_port_meter_profile_srtcm_cir,
(void *)&cmd_add_port_meter_profile_srtcm_cbs,
(void *)&cmd_add_port_meter_profile_srtcm_ebs,
+   (void *)&cmd_add_port_meter_profile_srtcm_packet_mode,
NULL,
},
 };
@@ -394,6 +413,7 @@ struct cmd_add_port_meter_profile_trtcm_result {
uint64_t pir;
uint64_t cbs;
uint64_t pbs;
+   int packet_mode;
 };
 
 cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_add =
@@ -439,6 +459,10 @@ cmdline_parse_token_num_t 
cmd_add_port_meter_profile_trtcm_pbs =
TOKEN_NUM_INITIALIZER(
struct cmd_add_port_meter_profile_trtcm_result,
pbs, RTE_UINT64);
+cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_packet_mode =
+   TOKEN_NUM_INITIALIZER(
+   struct cmd_add_port_meter_profile_trtcm_result,
+   packet_mode, RTE_UINT32);
 
 static void cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
@@ -461,6 +485,7 @@ static void cmd_add_port_meter_profile_trtcm_parsed(void 
*parsed_result,
mp.trtcm_rfc2698.pir = res->pir;
mp.trtcm_rfc2698.cbs = res->cbs;
mp.trtcm_rfc2698.pbs = res->pbs;
+   mp.packet_mode = res->packet_mode;
 
ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
if (ret != 0) {
@@ -472,7 +497,7 @@ static void cmd_add_port_meter_profile_trtcm_parsed(void 
*parsed_result,
 cmdline_parse_inst_t cmd_add

[dpdk-dev] [PATCH v3 4/4] net/mvpp2: check meter packet mode

2021-04-10 Thread Li Zhang
Currently meter algorithms only supports bytes per second(BPS).
Check packet_mode set to TRUE are rejected.

Signed-off-by: Li Zhang 
Acked-by: Matan Azrad 
---
 drivers/net/mvpp2/mrvl_mtr.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/mvpp2/mrvl_mtr.c b/drivers/net/mvpp2/mrvl_mtr.c
index 2fa5cb43ad..c07ac95ddc 100644
--- a/drivers/net/mvpp2/mrvl_mtr.c
+++ b/drivers/net/mvpp2/mrvl_mtr.c
@@ -88,6 +88,12 @@ mrvl_meter_profile_add(struct rte_eth_dev *dev, uint32_t 
meter_profile_id,
  NULL,
  "Only srTCM RFC 2697 is supported\n");
 
+   if (profile->packet_mode)
+   return -rte_mtr_error_set(error, EINVAL,
+   RTE_MTR_ERROR_TYPE_METER_PROFILE_PACKET_MODE,
+   NULL,
+   "Packet mode is not supported\n");
+
prof = mrvl_mtr_profile_from_id(priv, meter_profile_id);
if (prof)
return -rte_mtr_error_set(error, EEXIST,
-- 
2.21.0



[dpdk-dev] [PATCH v3 3/4] net/softnic: check meter packet mode

2021-04-10 Thread Li Zhang
Currently meter algorithms only supports bytes per second(BPS).
Check packet_mode set to TRUE are rejected.

Signed-off-by: Li Zhang 
Acked-by: Matan Azrad 
---
 drivers/net/softnic/rte_eth_softnic_meter.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c 
b/drivers/net/softnic/rte_eth_softnic_meter.c
index 2a05a85cdb..046e629f17 100644
--- a/drivers/net/softnic/rte_eth_softnic_meter.c
+++ b/drivers/net/softnic/rte_eth_softnic_meter.c
@@ -107,6 +107,14 @@ meter_profile_check(struct rte_eth_dev *dev,
NULL,
"Metering alg not supported");
 
+   /* Not support packet mode, just support byte mode. */
+   if (profile->packet_mode)
+   return -rte_mtr_error_set(error,
+   EINVAL,
+   RTE_MTR_ERROR_TYPE_METER_PROFILE_PACKET_MODE,
+   NULL,
+   "Meter packet mode not supported");
+
return 0;
 }
 
-- 
2.21.0



[dpdk-dev] [PATCH v2 2/2] net/mlx5: support meter PPS profile

2021-04-10 Thread Li Zhang
Currently meter algorithms only supports bytes per second(BPS).
Such as Single Rate Three Color Marker (srTCM rfc2697)
Add packet_mode flag to support rate is packet per second.
So that it can meter traffic by packet per second (PPS).

Signed-off-by: Li Zhang 
Acked-by: Matan Azrad 
---
 doc/guides/nics/mlx5.rst   |  1 +
 drivers/net/mlx5/mlx5_flow_aso.c   | 17 ---
 drivers/net/mlx5/mlx5_flow_meter.c | 74 +++---
 3 files changed, 69 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index 9d36d27fa9..cf81ad5c09 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -416,6 +416,7 @@ Limitations
  - green: QUEUE, RSS, PORT_ID, JUMP, MARK and SET_TAG.
  - yellow: must be empty.
  - RED: must be DROP.
+  - meter profile packet mode is supported.
 
 Statistics
 --
diff --git a/drivers/net/mlx5/mlx5_flow_aso.c b/drivers/net/mlx5/mlx5_flow_aso.c
index 20cd4fe18c..da513a600c 100644
--- a/drivers/net/mlx5/mlx5_flow_aso.c
+++ b/drivers/net/mlx5/mlx5_flow_aso.c
@@ -191,7 +191,6 @@ mlx5_aso_mtr_init_sq(struct mlx5_aso_sq *sq)
volatile struct mlx5_aso_wqe *restrict wqe;
int i;
int size = 1 << sq->log_desc_n;
-   uint32_t idx;
 
/* All the next fields state should stay constant. */
for (i = 0, wqe = &sq->sq_obj.aso_wqes[0]; i < size; ++i, ++wqe) {
@@ -204,11 +203,6 @@ mlx5_aso_mtr_init_sq(struct mlx5_aso_sq *sq)
 (BYTEWISE_64BYTE << ASO_CSEG_DATA_MASK_MODE_OFFSET));
wqe->general_cseg.flags = RTE_BE32(MLX5_COMP_ALWAYS <<
 MLX5_COMP_MODE_OFFSET);
-   for (idx = 0; idx < MLX5_ASO_METERS_PER_WQE;
-   idx++)
-   wqe->aso_dseg.mtrs[idx].v_bo_sc_bbog_mm =
-   RTE_BE32((1 << ASO_DSEG_VALID_OFFSET) |
-   (MLX5_FLOW_COLOR_GREEN << ASO_DSEG_SC_OFFSET));
}
 }
 
@@ -664,6 +658,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,
 {
volatile struct mlx5_aso_wqe *wqe = NULL;
struct mlx5_flow_meter_info *fm = NULL;
+   struct mlx5_flow_meter_profile *fmp;
uint16_t size = 1 << sq->log_desc_n;
uint16_t mask = size - 1;
uint16_t res;
@@ -704,6 +699,16 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,
RTE_BE32(MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL);
wqe->aso_dseg.mtrs[dseg_idx].ebs_eir = 0;
}
+   fmp = fm->profile;
+   if (fmp->profile.packet_mode)
+   wqe->aso_dseg.mtrs[dseg_idx].v_bo_sc_bbog_mm =
+   RTE_BE32((1 << ASO_DSEG_VALID_OFFSET) |
+   (MLX5_FLOW_COLOR_GREEN << ASO_DSEG_SC_OFFSET) |
+   (MLX5_METER_MODE_PKT << ASO_DSEG_MTR_MODE));
+   else
+   wqe->aso_dseg.mtrs[dseg_idx].v_bo_sc_bbog_mm =
+   RTE_BE32((1 << ASO_DSEG_VALID_OFFSET) |
+   (MLX5_FLOW_COLOR_GREEN << ASO_DSEG_SC_OFFSET));
sq->head++;
sq->pi += 2;/* Each WQE contains 2 WQEBB's. */
rte_io_wmb();
diff --git a/drivers/net/mlx5/mlx5_flow_meter.c 
b/drivers/net/mlx5/mlx5_flow_meter.c
index b8fcc6e658..7b77cb5202 100644
--- a/drivers/net/mlx5/mlx5_flow_meter.c
+++ b/drivers/net/mlx5/mlx5_flow_meter.c
@@ -144,13 +144,19 @@ mlx5_flow_meter_profile_validate(struct rte_eth_dev *dev,
if (profile->alg == RTE_MTR_SRTCM_RFC2697) {
if (priv->config.hca_attr.qos.flow_meter_old) {
/* Verify support for flow meter parameters. */
-   if (profile->srtcm_rfc2697.cir > 0 &&
-   profile->srtcm_rfc2697.cir <= MLX5_SRTCM_CIR_MAX &&
-   profile->srtcm_rfc2697.cbs > 0 &&
-   profile->srtcm_rfc2697.cbs <= MLX5_SRTCM_CBS_MAX &&
-   profile->srtcm_rfc2697.ebs <= MLX5_SRTCM_EBS_MAX)
-   return 0;
-   else
+   if (priv->sh->meter_aso_en && profile->packet_mode) {
+   if (profile->srtcm_rfc2697.cir > 0 &&
+   (profile->srtcm_rfc2697.cir <<
+   MLX5_MTRS_PPS_MAP_BPS_SHIFT)
+   <= MLX5_SRTCM_CIR_MAX &&
+   profile->srtcm_rfc2697.cbs > 0 &&
+   (profile->srtcm_rfc2697.cbs <<
+   MLX5_MTRS_PPS_MAP_BPS_SHIFT)
+   <= MLX5_SRTCM_CBS_MAX &&
+   (profile->srtcm_rfc2697.ebs <<
+   MLX5_MTRS_PPS_MAP_BPS_SHIFT)
+   <= MLX5_SRTCM_EBS_M

[dpdk-dev] [PATCH v2 0/2] Support meter PPS(packet per second) in MLX5 PMD

2021-04-10 Thread Li Zhang
Currently meter algorithms only supports rate is bytes per second(BPS).
Add packet_mode flag in meter profile parameters data structure.
So that it can meter traffic by packet per second.

Depends-on: series=16256  ("Support PPS(packet per second) on meter")
https://patchwork.dpdk.org/project/dpdk/list/?series=16256

V2: Fix comments from Matan.

Li Zhang (2):
  common/mlx5: add meter mode definition in PRM file
  net/mlx5: support meter PPS profile

 doc/guides/nics/mlx5.rst   |  1 +
 drivers/common/mlx5/mlx5_prm.h |  8 
 drivers/net/mlx5/mlx5_flow_aso.c   | 17 ---
 drivers/net/mlx5/mlx5_flow_meter.c | 74 +++---
 4 files changed, 77 insertions(+), 23 deletions(-)

-- 
2.21.0



[dpdk-dev] [PATCH v2 1/2] common/mlx5: add meter mode definition in PRM file

2021-04-10 Thread Li Zhang
Add meter mode definitions in PRM file

Signed-off-by: Li Zhang 
Acked-by: Matan Azrad 
---
 drivers/common/mlx5/mlx5_prm.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index c6d8060bb9..efa5ae67bf 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -2297,6 +2297,13 @@ struct mlx5_ifc_flow_meter_parameters_bits {
 #define MLX5_IFC_FLOW_METER_PARAM_MASK UINT64_C(0x80FF)
 #define MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL 0x14BF00C8
 
+enum {
+   MLX5_METER_MODE_IP_LEN = 0x0,
+   MLX5_METER_MODE_L2_LEN = 0x1,
+   MLX5_METER_MODE_L2_IPG_LEN = 0x2,
+   MLX5_METER_MODE_PKT = 0x3,
+};
+
 enum {
MLX5_CQE_SIZE_64B = 0x0,
MLX5_CQE_SIZE_128B = 0x1,
@@ -2671,6 +2678,7 @@ struct mlx5_aso_mtr_dseg {
 #define ASO_DSEG_VALID_OFFSET 31
 #define ASO_DSEG_BO_OFFSET 30
 #define ASO_DSEG_SC_OFFSET 28
+#define ASO_DSEG_MTR_MODE 24
 #define ASO_DSEG_CBS_EXP_OFFSET 24
 #define ASO_DSEG_CBS_MAN_OFFSET 16
 #define ASO_DSEG_CIR_EXP_MASK 0x1F
-- 
2.21.0



Re: [dpdk-dev] [PATCH v5] build: alias default build as generic

2021-04-10 Thread Thomas Monjalon
30/03/2021 08:40, Juraj Linkeš:
> The current machine='default' build name is not descriptive. The actual
> default build is machine='native'. Add an alternative string which does
> the same build and better describes what we're building:
> machine='generic'. Leave machine='default' for backwards compatibility.
> 
> Signed-off-by: Juraj Linkeš 
> Reviewed-by: Honnappa Nagarahalli 
> Acked-by: Bruce Richardson 

Applied, thanks





[dpdk-dev] [PATCH v2] build: fix symlink of drivers for Windows

2021-04-10 Thread Nick Connolly
The symlink-drivers-solibs.sh script was disabled as part of 'install'
for Windows because there is no support for shell scripts. However,
this means that driver related DLLs are not present in the installed
'libdir' directory. Add a python script to perform the install and use
it for Windows if the version of meson supports using an external
program with add_install_script (>= 0.55.0).

On Windows, symbolic links are somewhat problematic since the
SeCreateSymbolicLinkPrivilege is required to be able to create them.
In addition, different cross-compilation environments handle symbolic
links differently, e.g. WSL, Msys2, Cygwin. Rather than trying to
distinguish these scenarios, the python script will perform a file copy
for any Windows specific names.

On Windows, the shared library outputs have different names depending
upon which toolset has been used to build them. The script currently
handles Clang and GCC.

On Linux the functionality is unchanged, but could be replaced with the
python script once the required minimum version of meson is >= 0.55.0.

Fixes: 5c7d86948764 ("build: fix install on Windows")
Cc: sta...@dpdk.org

Signed-off-by: Nick Connolly 
---
 buildtools/symlink-drivers-solibs.py | 49 
 config/meson.build   |  4 +++
 2 files changed, 53 insertions(+)
 create mode 100644 buildtools/symlink-drivers-solibs.py

diff --git a/buildtools/symlink-drivers-solibs.py 
b/buildtools/symlink-drivers-solibs.py
new file mode 100644
index 0..5627ddd9d
--- /dev/null
+++ b/buildtools/symlink-drivers-solibs.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2021 Intel Corporation
+
+import os
+import sys
+import glob
+import shutil
+
+# post-install script for meson/ninja builds to symlink the PMDs stored in
+# $libdir/dpdk/pmds-*/ to $libdir. This is needed as some PMDs depend on
+# others, e.g. PCI device PMDs depending on the PCI bus driver.
+
+# parameters to script are paths relative to install prefix:
+# 1. directory for installed regular libs e.g. lib64
+# 2. subdirectory of libdir where the pmds are
+# 3. directory for installed regular binaries e.g. bin
+
+os.chdir(os.environ['MESON_INSTALL_DESTDIR_PREFIX'])
+
+lib_dir = sys.argv[1]
+pmd_subdir = sys.argv[2]
+bin_dir = sys.argv[3]
+pmd_dir = os.path.join(lib_dir, pmd_subdir)
+
+# copy Windows PMDs to avoid any issues with symlinks since the
+# build could be a cross-compilation under WSL, Msys or Cygnus.
+# the filenames are dependent upon the specific toolchain in use.
+
+def copy_pmd_files(pattern, to_dir):
+   for file in glob.glob(os.path.join(pmd_dir, pattern)):
+   to = os.path.join(to_dir, os.path.basename(file))
+   shutil.copy2(file, to)
+   print(to + ' -> ' + file)
+
+copy_pmd_files('*rte_*.dll', bin_dir)
+copy_pmd_files('*rte_*.pdb', bin_dir)
+copy_pmd_files('*rte_*.lib', lib_dir)
+copy_pmd_files('*rte_*.dll.a', lib_dir)
+
+# symlink shared objects
+
+os.chdir(lib_dir)
+for file in glob.glob(os.path.join(pmd_subdir, 'librte_*.so*')):
+   to = os.path.basename(file)
+   if os.path.exists(to):
+   os.remove(to)
+   os.symlink(file, to)
+   print(to + ' -> ' + file)
diff --git a/config/meson.build b/config/meson.build
index 66a2edcc4..d0a54b02a 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -61,6 +61,10 @@ if not is_windows
meson.add_install_script('../buildtools/symlink-drivers-solibs.sh',
get_option('libdir'),
pmd_subdir_opt)
+elif meson.version().version_compare('>=0.55.0')
+   # 0.55.0 is required to use external program with add_install_script
+   meson.add_install_script(py3, '../buildtools/symlink-drivers-solibs.py',
+   get_option('libdir'), pmd_subdir_opt, get_option('bindir'))
 endif
 
 # set the machine type and cflags for it
-- 
2.25.1



Re: [dpdk-dev] [PATCH] examples/ptpclient: delete wrong comments

2021-04-10 Thread Min Hu (Connor)

Hi, Ferruh, kirill and all,
Any comments about this patch?

在 2021/3/27 15:36, Min Hu (Connor) 写道:

This patch deletes the comments which are wrong and unnecessary.

Fixes: ab129e9065a5 ("examples/ptpclient: add minimal PTP client")
Cc: sta...@dpdk.org

Signed-off-by: Min Hu (Connor) 
---
  examples/ptpclient/ptpclient.c | 4 
  1 file changed, 4 deletions(-)

diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index 33b297e..878d1a0 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -606,10 +606,6 @@ lcore_main(void)
unsigned nb_rx;
struct rte_mbuf *m;
  
-	/*

-* Check that the port is on the same NUMA node as the polling thread
-* for best performance.
-*/
printf("\nCore %u Waiting for SYNC packets. [Ctrl+C to quit]\n",
rte_lcore_id());
  



Re: [dpdk-dev] [PATCH 0/3] fix check of port and core

2021-04-10 Thread Min Hu (Connor)

Hi,Ferruh, bernard, tomasz, bruce and all,
Any comments about this set of patches?

在 2021/3/27 15:40, Min Hu (Connor) 写道:

Currently, some examples check that the port is on the same NUMA
node as the polling thread for best performance. The method is
to compare the socket id of port and that of current core. If the
result is different, warning info will be given.

But it ignores the port which is from numa node 0, that is, no
warning info will be given if the port is from numa node 0, and
this set of patches will fix it.

Min Hu (Connor) (3):
   examples/flow_classify: fix check of port and core
   examples/l2fwd-cat: fix check of port and core
   examples/skeleton: fix check of port and core

  examples/flow_classify/flow_classify.c | 2 +-
  examples/l2fwd-cat/l2fwd-cat.c | 2 +-
  examples/skeleton/basicfwd.c   | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)



[dpdk-dev] [PATCH] ethdev: add sanity checks in control APIs

2021-04-10 Thread Min Hu (Connor)
This patch adds more sanity checks in control path APIs.

Fixes: 214ed1acd125 ("ethdev: add iterator to match devargs input")
Fixes: 3d98f921fbe9 ("ethdev: unify prefix for static functions and variables")
Fixes: 0366137722a0 ("ethdev: check for invalid device name")
Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process 
model")
Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
Fixes: f8244c6399d9 ("ethdev: increase port id range")
Cc: sta...@dpdk.org

Signed-off-by: Min Hu (Connor) 
---
 lib/librte_ethdev/rte_ethdev.c | 158 -
 1 file changed, 155 insertions(+), 3 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 6b5cfd6..93ad8b3 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -199,6 +199,9 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const 
char *devargs_str)
char *cls_str = NULL;
int str_size;
 
+   if (iter == NULL || devargs_str == NULL)
+   return -EINVAL;
+
memset(iter, 0, sizeof(*iter));
 
/*
@@ -293,7 +296,7 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const 
char *devargs_str)
 uint16_t
 rte_eth_iterator_next(struct rte_dev_iterator *iter)
 {
-   if (iter->cls == NULL) /* invalid ethdev iterator */
+   if (iter == NULL || iter->cls == NULL) /* invalid ethdev iterator */
return RTE_MAX_ETHPORTS;
 
do { /* loop to try all matching rte_device */
@@ -322,7 +325,7 @@ rte_eth_iterator_next(struct rte_dev_iterator *iter)
 void
 rte_eth_iterator_cleanup(struct rte_dev_iterator *iter)
 {
-   if (iter->bus_str == NULL)
+   if (iter == NULL || iter->bus_str == NULL)
return; /* nothing to free in pure class filter */
free(RTE_CAST_FIELD(iter, bus_str, char *)); /* workaround const */
free(RTE_CAST_FIELD(iter, cls_str, char *)); /* workaround const */
@@ -428,6 +431,9 @@ rte_eth_dev_allocated(const char *name)
 {
struct rte_eth_dev *ethdev;
 
+   if (name == NULL)
+   return NULL;
+
eth_dev_shared_data_prepare();
 
rte_spinlock_lock(ð_dev_shared_data->ownership_lock);
@@ -472,6 +478,9 @@ rte_eth_dev_allocate(const char *name)
struct rte_eth_dev *eth_dev = NULL;
size_t name_len;
 
+   if (name == NULL)
+   return NULL;
+
name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
if (name_len == 0) {
RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n");
@@ -525,6 +534,9 @@ rte_eth_dev_attach_secondary(const char *name)
uint16_t i;
struct rte_eth_dev *eth_dev = NULL;
 
+   if (name == NULL)
+   return NULL;
+
eth_dev_shared_data_prepare();
 
/* Synchronize port attachment to primary port creation and release. */
@@ -622,6 +634,9 @@ rte_eth_find_next_owned_by(uint16_t port_id, const uint64_t 
owner_id)
 int
 rte_eth_dev_owner_new(uint64_t *owner_id)
 {
+   if (owner_id == NULL)
+   return -EINVAL;
+
eth_dev_shared_data_prepare();
 
rte_spinlock_lock(ð_dev_shared_data->ownership_lock);
@@ -678,6 +693,9 @@ rte_eth_dev_owner_set(const uint16_t port_id,
 {
int ret;
 
+   if (owner == NULL)
+   return -EINVAL;
+
eth_dev_shared_data_prepare();
 
rte_spinlock_lock(ð_dev_shared_data->ownership_lock);
@@ -741,6 +759,9 @@ rte_eth_dev_owner_get(const uint16_t port_id, struct 
rte_eth_dev_owner *owner)
int ret = 0;
struct rte_eth_dev *ethdev = &rte_eth_devices[port_id];
 
+   if (owner == NULL)
+   return -EINVAL;
+
eth_dev_shared_data_prepare();
 
rte_spinlock_lock(ð_dev_shared_data->ownership_lock);
@@ -820,7 +841,7 @@ rte_eth_dev_get_port_by_name(const char *name, uint16_t 
*port_id)
 {
uint16_t pid;
 
-   if (name == NULL) {
+   if (name == NULL || port_id == NULL) {
RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n");
return -EINVAL;
}
@@ -1297,6 +1318,9 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, 
uint16_t nb_tx_q,
int ret;
uint16_t old_mtu;
 
+   if (dev_conf == NULL)
+   return -EINVAL;
+
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
dev = &rte_eth_devices[port_id];
@@ -1576,6 +1600,9 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, 
uint16_t nb_tx_q,
 void
 rte_eth_dev_internal_reset(struct rte_eth_dev *dev)
 {
+   if (dev == NULL)
+   return;
+
if (dev->data->dev_started) {
RTE_ETHDEV_LOG(ERR, "Port %u must be stopped to allow reset\n",
dev->data->port_id);
@@ -2137,6 +2164,9 @@ rte_eth_rx_hairpin_queue_setup(uint16_t port_id, uint16_t 
rx_queue_id,
int i;
int count;
 
+   if (conf == NULL)
+   return -EINVAL;
+
RTE_ETH_VALID_PORTID_OR

[dpdk-dev] [PATCH v5] eal: fix create user mem map repeatedly when it exists

2021-04-10 Thread wangyunjian
From: Yunjian Wang 

Currently, new user mem maps are checked if they are adjacent to
an existing mem map and if so, the mem map entries are merged.

It doesn't check for duplicate mem maps, so if the API is called
with the same mem map multiple times, they will occupy multiple
mem map entries. This will reduce the amount of entries available
for unique mem maps.

So check for duplicate mem maps and merge them into one mem map
entry if any found.

Fixes: 0cbce3a167f1 ("vfio: skip DMA map failure if already mapped")
Cc: sta...@dpdk.org

Suggested-by: Kevin Traynor 
Signed-off-by: Yunjian Wang 
Acked-by: Anatoly Burakov 
---
v5:
   Update commit log suggested by Kevin Traynor
---
 lib/librte_eal/linux/eal_vfio.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/lib/librte_eal/linux/eal_vfio.c b/lib/librte_eal/linux/eal_vfio.c
index fe25719991..25add2fa5d 100644
--- a/lib/librte_eal/linux/eal_vfio.c
+++ b/lib/librte_eal/linux/eal_vfio.c
@@ -171,6 +171,10 @@ adjust_map(struct user_mem_map *src, struct user_mem_map 
*end,
 static int
 merge_map(struct user_mem_map *left, struct user_mem_map *right)
 {
+   /* merge the same maps into one */
+   if (memcmp(left, right, sizeof(struct user_mem_map)) == 0)
+   goto out;
+
if (left->addr + left->len != right->addr)
return 0;
if (left->iova + left->len != right->iova)
@@ -178,6 +182,7 @@ merge_map(struct user_mem_map *left, struct user_mem_map 
*right)
 
left->len += right->len;
 
+out:
memset(right, 0, sizeof(*right));
 
return 1;
-- 
2.23.0



[dpdk-dev] [PATCH v4 0/4] add support for packed ring in async vhost

2021-04-10 Thread Cheng Jiang
For now async vhost data path only supports split ring structure. In
order to make async vhost compatible with virtio 1.1 spec this patch
set cleans async split ring codes and enables packed ring in async
vhost data path. Batch datapath is also enabled in packed ring.

v4:
  * change the patch structure
  * clean code for async split ring
  * reuse some code from split ring
  * change the error handler for DMA-copy packet
  * add check for malloc
  * remove useless code
  * add doc update
v3:
  * fix error handler for DMA-copy packet
v2:
  * fix wrong buffer index in rte_vhost_poll_enqueue_completed()
  * add async_buffers_packed memory free in vhost_free_async_mem()

Cheng Jiang (4):
  vhost: abstract and reorganize async split ring code
  vhost: add support for packed ring in async vhost
  vhost: add batch datapath for async vhost packed ring
  doc: add release note for vhost async packed ring

 doc/guides/rel_notes/release_21_05.rst |   4 +
 lib/librte_vhost/rte_vhost_async.h |   1 +
 lib/librte_vhost/vhost.c   |  27 +-
 lib/librte_vhost/vhost.h   |   7 +-
 lib/librte_vhost/virtio_net.c  | 603 ++---
 5 files changed, 560 insertions(+), 82 deletions(-)

--
2.29.2



[dpdk-dev] [PATCH v4 1/4] vhost: abstract and reorganize async split ring code

2021-04-10 Thread Cheng Jiang
In order to improve code efficiency and readability when async packed
ring support is enabled. This patch abstract some functions like
shadow_ring_store and write_back_completed_descs_split. And improve
the efficiency of some pointer offset calculation.

Signed-off-by: Cheng Jiang 
---
 lib/librte_vhost/virtio_net.c | 146 +++---
 1 file changed, 84 insertions(+), 62 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index ff3987860..69553e7c3 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1458,6 +1458,29 @@ virtio_dev_rx_async_get_info_idx(uint16_t pkts_idx,
(vq_size - n_inflight + pkts_idx) & (vq_size - 1);
 }
 
+static __rte_always_inline void
+shadow_ring_store(struct vhost_virtqueue *vq,  void *shadow_ring, void *d_ring,
+   uint16_t s_idx, uint16_t d_idx,
+   uint16_t count, uint16_t elem_size)
+{
+   if (s_idx + count <= vq->size) {
+   rte_memcpy((void *)((uintptr_t)d_ring + d_idx * elem_size),
+   (void *)((uintptr_t)shadow_ring + s_idx * elem_size),
+   count * elem_size);
+   } else {
+   uint16_t size = vq->size - d_idx;
+
+   rte_memcpy((void *)((uintptr_t)d_ring + d_idx * elem_size),
+   (void *)((uintptr_t)shadow_ring + s_idx * elem_size),
+   size * elem_size);
+
+   rte_memcpy((void *)((uintptr_t)d_ring),
+   (void *)((uintptr_t)shadow_ring +
+   (s_idx + size) * elem_size),
+   (count - size) * elem_size);
+   }
+}
+
 static __rte_noinline uint32_t
 virtio_dev_rx_async_submit_split(struct virtio_net *dev,
struct vhost_virtqueue *vq, uint16_t queue_id,
@@ -1478,6 +1501,7 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,
struct rte_vhost_iov_iter *dst_it = it_pool + 1;
uint16_t slot_idx = 0;
uint16_t segs_await = 0;
+   uint16_t iovec_idx = 0, it_idx = 0;
struct async_inflight_info *pkts_info = vq->async_pkts_info;
uint32_t n_pkts = 0, pkt_err = 0;
uint32_t num_async_pkts = 0, num_done_pkts = 0;
@@ -1513,27 +1537,32 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,
 
if (async_mbuf_to_desc(dev, vq, pkts[pkt_idx],
buf_vec, nr_vec, num_buffers,
-   src_iovec, dst_iovec, src_it, dst_it) < 0) {
+   &src_iovec[iovec_idx],
+   &dst_iovec[iovec_idx],
+   &src_it[it_idx],
+   &dst_it[it_idx]) < 0) {
vq->shadow_used_idx -= num_buffers;
break;
}
 
slot_idx = (vq->async_pkts_idx + num_async_pkts) &
(vq->size - 1);
-   if (src_it->count) {
+   if (src_it[it_idx].count) {
uint16_t from, to;
 
-   async_fill_desc(&tdes[pkt_burst_idx++], src_it, dst_it);
+   async_fill_desc(&tdes[pkt_burst_idx++],
+   &src_it[it_idx],
+   &dst_it[it_idx]);
pkts_info[slot_idx].descs = num_buffers;
pkts_info[slot_idx].mbuf = pkts[pkt_idx];
async_pkts_log[num_async_pkts].pkt_idx = pkt_idx;
async_pkts_log[num_async_pkts++].last_avail_idx =
vq->last_avail_idx;
-   src_iovec += src_it->nr_segs;
-   dst_iovec += dst_it->nr_segs;
-   src_it += 2;
-   dst_it += 2;
-   segs_await += src_it->nr_segs;
+
+   iovec_idx += src_it[it_idx].nr_segs;
+   it_idx += 2;
+
+   segs_await += src_it[it_idx].nr_segs;
 
/**
 * recover shadow used ring and keep DMA-occupied
@@ -1541,23 +1570,12 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,
 */
from = vq->shadow_used_idx - num_buffers;
to = vq->async_desc_idx & (vq->size - 1);
-   if (num_buffers + to <= vq->size) {
-   rte_memcpy(&vq->async_descs_split[to],
-   &vq->shadow_used_split[from],
-   num_buffers *
-   sizeof(struct vring_used_elem));
-   } else {
-   int size = vq->size - to;
-
-   rte_memcpy(&vq->async_descs_split[to],
-   &vq->sha

[dpdk-dev] [PATCH v4 1/4] vhost: abstract and reorganize async split ring code

2021-04-10 Thread Cheng Jiang
In order to improve code efficiency and readability when async packed
ring support is enabled. This patch abstract some functions like
shadow_ring_store and write_back_completed_descs_split. And improve
the efficiency of some pointer offset calculation.

Signed-off-by: Cheng Jiang 
---
 lib/librte_vhost/virtio_net.c | 146 +++---
 1 file changed, 84 insertions(+), 62 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index ff3987860..69553e7c3 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1458,6 +1458,29 @@ virtio_dev_rx_async_get_info_idx(uint16_t pkts_idx,
(vq_size - n_inflight + pkts_idx) & (vq_size - 1);
 }
 
+static __rte_always_inline void
+shadow_ring_store(struct vhost_virtqueue *vq,  void *shadow_ring, void *d_ring,
+   uint16_t s_idx, uint16_t d_idx,
+   uint16_t count, uint16_t elem_size)
+{
+   if (s_idx + count <= vq->size) {
+   rte_memcpy((void *)((uintptr_t)d_ring + d_idx * elem_size),
+   (void *)((uintptr_t)shadow_ring + s_idx * elem_size),
+   count * elem_size);
+   } else {
+   uint16_t size = vq->size - d_idx;
+
+   rte_memcpy((void *)((uintptr_t)d_ring + d_idx * elem_size),
+   (void *)((uintptr_t)shadow_ring + s_idx * elem_size),
+   size * elem_size);
+
+   rte_memcpy((void *)((uintptr_t)d_ring),
+   (void *)((uintptr_t)shadow_ring +
+   (s_idx + size) * elem_size),
+   (count - size) * elem_size);
+   }
+}
+
 static __rte_noinline uint32_t
 virtio_dev_rx_async_submit_split(struct virtio_net *dev,
struct vhost_virtqueue *vq, uint16_t queue_id,
@@ -1478,6 +1501,7 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,
struct rte_vhost_iov_iter *dst_it = it_pool + 1;
uint16_t slot_idx = 0;
uint16_t segs_await = 0;
+   uint16_t iovec_idx = 0, it_idx = 0;
struct async_inflight_info *pkts_info = vq->async_pkts_info;
uint32_t n_pkts = 0, pkt_err = 0;
uint32_t num_async_pkts = 0, num_done_pkts = 0;
@@ -1513,27 +1537,32 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,
 
if (async_mbuf_to_desc(dev, vq, pkts[pkt_idx],
buf_vec, nr_vec, num_buffers,
-   src_iovec, dst_iovec, src_it, dst_it) < 0) {
+   &src_iovec[iovec_idx],
+   &dst_iovec[iovec_idx],
+   &src_it[it_idx],
+   &dst_it[it_idx]) < 0) {
vq->shadow_used_idx -= num_buffers;
break;
}
 
slot_idx = (vq->async_pkts_idx + num_async_pkts) &
(vq->size - 1);
-   if (src_it->count) {
+   if (src_it[it_idx].count) {
uint16_t from, to;
 
-   async_fill_desc(&tdes[pkt_burst_idx++], src_it, dst_it);
+   async_fill_desc(&tdes[pkt_burst_idx++],
+   &src_it[it_idx],
+   &dst_it[it_idx]);
pkts_info[slot_idx].descs = num_buffers;
pkts_info[slot_idx].mbuf = pkts[pkt_idx];
async_pkts_log[num_async_pkts].pkt_idx = pkt_idx;
async_pkts_log[num_async_pkts++].last_avail_idx =
vq->last_avail_idx;
-   src_iovec += src_it->nr_segs;
-   dst_iovec += dst_it->nr_segs;
-   src_it += 2;
-   dst_it += 2;
-   segs_await += src_it->nr_segs;
+
+   iovec_idx += src_it[it_idx].nr_segs;
+   it_idx += 2;
+
+   segs_await += src_it[it_idx].nr_segs;
 
/**
 * recover shadow used ring and keep DMA-occupied
@@ -1541,23 +1570,12 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,
 */
from = vq->shadow_used_idx - num_buffers;
to = vq->async_desc_idx & (vq->size - 1);
-   if (num_buffers + to <= vq->size) {
-   rte_memcpy(&vq->async_descs_split[to],
-   &vq->shadow_used_split[from],
-   num_buffers *
-   sizeof(struct vring_used_elem));
-   } else {
-   int size = vq->size - to;
-
-   rte_memcpy(&vq->async_descs_split[to],
-   &vq->sha

[dpdk-dev] [PATCH v4 2/4] vhost: add support for packed ring in async vhost

2021-04-10 Thread Cheng Jiang
For now async vhost data path only supports split ring structure. In
order to make async vhost compatible with virtio 1.1 spec this patch
enables packed ring in async vhost data path.

Signed-off-by: Cheng Jiang 
---
 lib/librte_vhost/rte_vhost_async.h |   1 +
 lib/librte_vhost/vhost.c   |  27 +-
 lib/librte_vhost/vhost.h   |   7 +-
 lib/librte_vhost/virtio_net.c  | 428 -
 4 files changed, 441 insertions(+), 22 deletions(-)

diff --git a/lib/librte_vhost/rte_vhost_async.h 
b/lib/librte_vhost/rte_vhost_async.h
index c855ff875..6faa31f5a 100644
--- a/lib/librte_vhost/rte_vhost_async.h
+++ b/lib/librte_vhost/rte_vhost_async.h
@@ -89,6 +89,7 @@ struct rte_vhost_async_channel_ops {
 struct async_inflight_info {
struct rte_mbuf *mbuf;
uint16_t descs; /* num of descs inflight */
+   uint16_t nr_buffers; /* num of buffers inflight for packed ring */
 };
 
 /**
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index a70fe01d8..8c9935c0f 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -342,15 +342,21 @@ vhost_free_async_mem(struct vhost_virtqueue *vq)
 {
if (vq->async_pkts_info)
rte_free(vq->async_pkts_info);
-   if (vq->async_descs_split)
+   if (vq->async_buffers_packed) {
+   rte_free(vq->async_buffers_packed);
+   vq->async_buffers_packed = NULL;
+   }
+   if (vq->async_descs_split) {
rte_free(vq->async_descs_split);
+   vq->async_descs_split = NULL;
+   }
+
if (vq->it_pool)
rte_free(vq->it_pool);
if (vq->vec_pool)
rte_free(vq->vec_pool);
 
vq->async_pkts_info = NULL;
-   vq->async_descs_split = NULL;
vq->it_pool = NULL;
vq->vec_pool = NULL;
 }
@@ -1627,9 +1633,9 @@ int rte_vhost_async_channel_register(int vid, uint16_t 
queue_id,
return -1;
 
/* packed queue is not supported */
-   if (unlikely(vq_is_packed(dev) || !f.async_inorder)) {
+   if (unlikely(!f.async_inorder)) {
VHOST_LOG_CONFIG(ERR,
-   "async copy is not supported on packed queue or 
non-inorder mode "
+   "async copy is not supported on non-inorder mode "
"(vid %d, qid: %d)\n", vid, queue_id);
return -1;
}
@@ -1667,11 +1673,18 @@ int rte_vhost_async_channel_register(int vid, uint16_t 
queue_id,
vq->vec_pool = rte_malloc_socket(NULL,
VHOST_MAX_ASYNC_VEC * sizeof(struct iovec),
RTE_CACHE_LINE_SIZE, node);
-   vq->async_descs_split = rte_malloc_socket(NULL,
+   if (vq_is_packed(dev)) {
+   vq->async_buffers_packed = rte_malloc_socket(NULL,
+   vq->size * sizeof(struct vring_used_elem_packed),
+   RTE_CACHE_LINE_SIZE, node);
+   } else {
+   vq->async_descs_split = rte_malloc_socket(NULL,
vq->size * sizeof(struct vring_used_elem),
RTE_CACHE_LINE_SIZE, node);
-   if (!vq->async_descs_split || !vq->async_pkts_info ||
-   !vq->it_pool || !vq->vec_pool) {
+   }
+
+   if (!vq->async_buffers_packed || !vq->async_descs_split ||
+   !vq->async_pkts_info || !vq->it_pool || !vq->vec_pool) {
vhost_free_async_mem(vq);
VHOST_LOG_CONFIG(ERR,
"async register failed: cannot allocate memory 
for vq data "
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index f628714c2..fe131ae8f 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -201,9 +201,14 @@ struct vhost_virtqueue {
uint16_tasync_pkts_idx;
uint16_tasync_pkts_inflight_n;
uint16_tasync_last_pkts_n;
-   struct vring_used_elem  *async_descs_split;
+   union {
+   struct vring_used_elem  *async_descs_split;
+   struct vring_used_elem_packed *async_buffers_packed;
+   };
uint16_t async_desc_idx;
+   uint16_t async_packed_buffer_idx;
uint16_t last_async_desc_idx;
+   uint16_t last_async_buffer_idx;
 
/* vq async features */
boolasync_inorder;
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 69553e7c3..2b8b873ca 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -363,8 +363,7 @@ vhost_shadow_dequeue_single_packed_inorder(struct 
vhost_virtqueue *vq,
 }
 
 static __rte_always_inline void
-vhost_shadow_enqueue_single_packed(struct virtio_net *dev,
-  struct vhost_virtqueue *vq,
+vhost_shadow_enqueue_packed(struct vhost_virtqueue *vq,
   uint32_t len[],
   uint16_t id[],
   uint16_t c

[dpdk-dev] [PATCH v4 3/4] vhost: add batch datapath for async vhost packed ring

2021-04-10 Thread Cheng Jiang
Add batch datapath for async vhost packed ring to improve the
performance of small packet.

Signed-off-by: Cheng Jiang 
---
 lib/librte_vhost/virtio_net.c | 43 +++
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 2b8b873ca..c98fe6dbb 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1721,6 +1721,29 @@ virtio_dev_rx_async_submit_split(struct virtio_net *dev,
return pkt_idx;
 }
 
+static __rte_always_inline int
+virtio_dev_rx_async_batch_packed(struct virtio_net *dev,
+  struct vhost_virtqueue *vq,
+  struct rte_mbuf **pkts,
+  struct rte_mbuf **comp_pkts, uint32_t *pkt_done)
+{
+   uint16_t i;
+   uint32_t cpy_threshold = vq->async_threshold;
+
+   vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
+   if (unlikely(pkts[i]->pkt_len >= cpy_threshold))
+   return -1;
+   }
+   if (!virtio_dev_rx_batch_packed(dev, vq, pkts)) {
+   vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE)
+   comp_pkts[(*pkt_done)++] = pkts[i];
+
+   return 0;
+   }
+
+   return -1;
+}
+
 static __rte_always_inline int
 vhost_enqueue_async_single_packed(struct virtio_net *dev,
struct vhost_virtqueue *vq,
@@ -1844,6 +1867,7 @@ virtio_dev_rx_async_submit_packed(struct virtio_net *dev,
struct rte_mbuf **comp_pkts, uint32_t *comp_count)
 {
uint32_t pkt_idx = 0, pkt_burst_idx = 0;
+   uint32_t remained = count;
uint16_t async_descs_idx = 0;
uint16_t num_buffers;
uint16_t num_desc;
@@ -1863,9 +1887,17 @@ virtio_dev_rx_async_submit_packed(struct virtio_net *dev,
uint32_t num_async_pkts = 0, num_done_pkts = 0;
struct vring_packed_desc async_descs[vq->size];
 
-   rte_prefetch0(&vq->desc_packed[vq->last_avail_idx & (vq->size - 1)]);
-
-   for (pkt_idx = 0; pkt_idx < count; pkt_idx++) {
+   do {
+   rte_prefetch0(&vq->desc_packed[vq->last_avail_idx &
+   (vq->size - 1)]);
+   if (remained >= PACKED_BATCH_SIZE) {
+   if (!virtio_dev_rx_async_batch_packed(dev, vq,
+   &pkts[pkt_idx], comp_pkts, &num_done_pkts)) {
+   pkt_idx += PACKED_BATCH_SIZE;
+   remained -= PACKED_BATCH_SIZE;
+   continue;
+   }
+   }
if (unlikely(virtio_dev_rx_async_single_packed(dev, vq,
pkts[pkt_idx],
&num_desc, &num_buffers,
@@ -1912,6 +1944,8 @@ virtio_dev_rx_async_submit_packed(struct virtio_net *dev,
} else
comp_pkts[num_done_pkts++] = pkts[pkt_idx];
 
+   pkt_idx++;
+   remained--;
vq_inc_last_avail_packed(vq, num_desc);
 
/*
@@ -1937,13 +1971,12 @@ virtio_dev_rx_async_submit_packed(struct virtio_net 
*dev,
 */
pkt_err = pkt_burst_idx - n_pkts;
pkt_burst_idx = 0;
-   pkt_idx++;
break;
}
 
pkt_burst_idx = 0;
}
-   }
+   } while (pkt_idx < count);
 
if (pkt_burst_idx) {
n_pkts = vq->async_ops.transfer_data(dev->vid,
-- 
2.29.2



[dpdk-dev] [PATCH v4 4/4] doc: add release note for vhost async packed ring

2021-04-10 Thread Cheng Jiang
Add release note for the support of vhost async packed ring.

Signed-off-by: Cheng Jiang 
---
 doc/guides/rel_notes/release_21_05.rst | 4 
 1 file changed, 4 insertions(+)

diff --git a/doc/guides/rel_notes/release_21_05.rst 
b/doc/guides/rel_notes/release_21_05.rst
index 374d6d98e..eb5200669 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -131,6 +131,10 @@ New Features
   * Added command to display Rx queue used descriptor count.
 ``show port (port_id) rxq (queue_id) desc used count``
 
+* **Added support for vhost async packed ring data path.**
+
+  Added packed ring support for async vhost.
+
 
 Removed Items
 -
-- 
2.29.2



[dpdk-dev] [PATCH 5/7] examples/performance-thread: support set thread name

2021-04-10 Thread Min Hu (Connor)
From: Chengwen Feng 

This patch supports set helloworld thread name which is helpful for
debugging.

Signed-off-by: Chengwen Feng 
Signed-off-by: Min Hu (Connor) 
---
 examples/performance-thread/pthread_shim/main.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/examples/performance-thread/pthread_shim/main.c 
b/examples/performance-thread/pthread_shim/main.c
index 23e3b5e..4ce3622 100644
--- a/examples/performance-thread/pthread_shim/main.c
+++ b/examples/performance-thread/pthread_shim/main.c
@@ -27,6 +27,7 @@
 
 #define DEBUG_APP 0
 #define HELLOW_WORLD_MAX_LTHREADS 10
+#define THREAD_NAME_LEN16
 
 #ifndef __GLIBC__ /* sched_getcpu() is glibc-specific */
 #define sched_getcpu() rte_lcore_id()
@@ -149,6 +150,7 @@ static void *initial_lthread(void *args __rte_unused)
 */
pthread_attr_t attr;
rte_cpuset_t cpuset;
+   char name[THREAD_NAME_LEN];
 
CPU_ZERO(&cpuset);
CPU_SET(lcore, &cpuset);
@@ -160,6 +162,9 @@ static void *initial_lthread(void *args __rte_unused)
helloworld_pthread, (void *) i);
if (ret != 0)
rte_exit(EXIT_FAILURE, "Cannot create helloworld 
thread\n");
+
+   snprintf(name, sizeof(name), "helloworld-%u", (uint32_t)i);
+   rte_thread_setname(tid[i], name);
}
 
/* wait for 1s to allow threads
-- 
2.7.4



[dpdk-dev] [PATCH 4/7] raw/ifpga: support set monitor thread name

2021-04-10 Thread Min Hu (Connor)
From: Chengwen Feng 

This patch supports set monitor thread name which is helpful for
debugging.

Signed-off-by: Chengwen Feng 
Signed-off-by: Min Hu (Connor) 
---
 drivers/raw/ifpga/ifpga_rawdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 05d79bf..4db6884 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -534,6 +534,7 @@ ifpga_monitor_start_func(void)
"Fail to create ifpga nonitor thread");
return -1;
}
+   rte_thread_setname(ifpga_monitor_start_thread, "ifpga-monitor");
ifpga_monitor_start = 1;
}
 
-- 
2.7.4



[dpdk-dev] [PATCH 6/7] telemetry: support set init threads name

2021-04-10 Thread Min Hu (Connor)
From: Chengwen Feng 

This patch supports set init threads name which is helpful for
debugging.

Signed-off-by: Chengwen Feng 
Signed-off-by: Min Hu (Connor) 
---
 lib/librte_telemetry/telemetry.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_telemetry/telemetry.c b/lib/librte_telemetry/telemetry.c
index 7e08afd..8f48337 100644
--- a/lib/librte_telemetry/telemetry.c
+++ b/lib/librte_telemetry/telemetry.c
@@ -442,7 +442,7 @@ telemetry_legacy_init(void)
return -1;
pthread_create(&t_old, NULL, socket_listener, &v1_socket);
pthread_setaffinity_np(t_old, sizeof(*thread_cpuset), thread_cpuset);
-
+   pthread_setname_np(t_old, "telemetry-v1");
TMTY_LOG(DEBUG, "Legacy telemetry socket initialized ok\n");
return 0;
 }
@@ -471,6 +471,7 @@ telemetry_v2_init(void)
return -1;
pthread_create(&t_new, NULL, socket_listener, &v2_socket);
pthread_setaffinity_np(t_new, sizeof(*thread_cpuset), thread_cpuset);
+   pthread_setname_np(t_new, "telemetry-v2");
atexit(unlink_sockets);
 
return 0;
-- 
2.7.4



[dpdk-dev] [PATCH 7/7] examples/vhost_blk: support set ctrl worker thread name

2021-04-10 Thread Min Hu (Connor)
From: Chengwen Feng 

This patch supports set ctrl worker thread name which is helpful for
debugging.

Signed-off-by: Chengwen Feng 
Signed-off-by: Min Hu (Connor) 
---
 examples/vhost_blk/vhost_blk.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index 5c64071..4d24dca 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -689,6 +689,7 @@ new_device(int vid)
fprintf(stderr, "Worker Thread Started Failed\n");
return -1;
}
+   rte_thread_setname(tid, "vhostblk-ctrlr");
 
/* device has been started */
ctrlr->started = 1;
-- 
2.7.4



[dpdk-dev] [PATCH 0/7] support set thread name

2021-04-10 Thread Min Hu (Connor)
This set of patches support set thread name for debugging.

Chengwen Feng (7):
  net/ark: support set thread name
  net/ice: support set VSI reset thread name
  vdpa/ifc: support set notify and vring relay thread name
  raw/ifpga: support set monitor thread name
  examples/performance-thread: support set thread name
  telemetry: support set init threads name
  examples/vhost_blk: support set ctrl worker thread name

 drivers/net/ark/ark_ethdev.c|  1 +
 drivers/net/ice/ice_dcf_parent.c|  5 +
 drivers/raw/ifpga/ifpga_rawdev.c|  1 +
 drivers/vdpa/ifc/ifcvf_vdpa.c   | 12 
 examples/performance-thread/pthread_shim/main.c |  5 +
 examples/vhost_blk/vhost_blk.c  |  1 +
 lib/librte_telemetry/telemetry.c|  3 ++-
 7 files changed, 27 insertions(+), 1 deletion(-)

-- 
2.7.4



[dpdk-dev] [PATCH 3/7] vdpa/ifc: support set notify and vring relay thread name

2021-04-10 Thread Min Hu (Connor)
From: Chengwen Feng 

This patch supports set notify and vring relay thread name which is
helpful for debugging.

Signed-off-by: Chengwen Feng 
Signed-off-by: Min Hu (Connor) 
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 39237ae..8a5efa9 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -37,6 +37,8 @@ RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.net.ifcvf_vdpa, 
NOTICE);
 #define IFCVF_VDPA_MODE"vdpa"
 #define IFCVF_SW_FALLBACK_LM   "sw-live-migration"
 
+#define THREAD_NAME_LEN16
+
 static const char * const ifcvf_valid_arguments[] = {
IFCVF_VDPA_MODE,
IFCVF_SW_FALLBACK_LM,
@@ -494,6 +496,7 @@ notify_relay(void *arg)
 static int
 setup_notify_relay(struct ifcvf_internal *internal)
 {
+   char name[THREAD_NAME_LEN];
int ret;
 
ret = pthread_create(&internal->tid, NULL, notify_relay,
@@ -502,6 +505,10 @@ setup_notify_relay(struct ifcvf_internal *internal)
DRV_LOG(ERR, "failed to create notify relay pthread.");
return -1;
}
+
+   snprintf(name, sizeof(name), "ifc-notify-%d", internal->vid);
+   rte_thread_setname(internal->tid, name);
+
return 0;
 }
 
@@ -797,6 +804,7 @@ vring_relay(void *arg)
 static int
 setup_vring_relay(struct ifcvf_internal *internal)
 {
+   char name[THREAD_NAME_LEN];
int ret;
 
ret = pthread_create(&internal->tid, NULL, vring_relay,
@@ -805,6 +813,10 @@ setup_vring_relay(struct ifcvf_internal *internal)
DRV_LOG(ERR, "failed to create ring relay pthread.");
return -1;
}
+
+   snprintf(name, sizeof(name), "ifc-vring-%d", internal->vid);
+   rte_thread_setname(internal->tid, name);
+
return 0;
 }
 
-- 
2.7.4



[dpdk-dev] [PATCH 2/7] net/ice: support set VSI reset thread name

2021-04-10 Thread Min Hu (Connor)
From: Chengwen Feng 

This patch supports set VSI reset thread name which is helpful for
debugging.

Signed-off-by: Chengwen Feng 
Signed-off-by: Min Hu (Connor) 
---
 drivers/net/ice/ice_dcf_parent.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index a8571b3..86aa32b 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -151,7 +151,9 @@ ice_dcf_vsi_update_service_handler(void *param)
 static void
 start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, uint16_t vf_id)
 {
+#define THREAD_NAME_LEN16
struct ice_dcf_reset_event_param *param;
+   char name[THREAD_NAME_LEN];
pthread_t thread;
int ret;
 
@@ -171,6 +173,9 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, 
uint16_t vf_id)
PMD_DRV_LOG(ERR, "Failed to start the thread for reset 
handling");
free(param);
}
+
+   snprintf(name, sizeof(name), "ice-reset-%u", vf_id);
+   rte_thread_setname(thread, name);
 }
 
 void
-- 
2.7.4



[dpdk-dev] [PATCH 1/7] net/ark: support set thread name

2021-04-10 Thread Min Hu (Connor)
From: Chengwen Feng 

This patch supports set delay packet generator start thread name which
is helpful for debugging.

Signed-off-by: Chengwen Feng 
Signed-off-by: Min Hu (Connor) 
---
 drivers/net/ark/ark_ethdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index 9dea5fa..d62a869 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -574,6 +574,7 @@ eth_ark_dev_start(struct rte_eth_dev *dev)
"starter thread\n");
return -1;
}
+   rte_thread_setname(thread, "ark-delay-pg");
}
 
if (ark->user_ext.dev_start)
-- 
2.7.4



[dpdk-dev] [PATCH 0/2] fix missing check for thread creation

2021-04-10 Thread Min Hu (Connor)
There exist some thread creation function without result check.

This set of patches add result check and message print out after
failure.

Chengwen Feng (2):
  telemetry: fix missing check for thread creation
  test: fix missing check for thread creation

 app/test/process.h  |  8 ++--
 lib/librte_telemetry/telemetry.c| 30 +++---
 lib/librte_telemetry/telemetry_legacy.c | 10 --
 3 files changed, 41 insertions(+), 7 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH 2/2] test: fix missing check for thread creation

2021-04-10 Thread Min Hu (Connor)
From: Chengwen Feng 

There was a call for thread create function without result check.
Add result check and message print out after failure.

Fixes: 086eb64db39e ("test/pdump: add unit test for pdump library")
Cc: sta...@dpdk.org

Signed-off-by: Chengwen Feng 
Signed-off-by: Min Hu (Connor) 
---
 app/test/process.h | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/app/test/process.h b/app/test/process.h
index 27f1b1c..9b6b85a 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -48,6 +48,7 @@ process_dup(const char *const argv[], int numargs, const char 
*env_value)
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
pthread_t thread;
+   int rc;
 #endif
 #endif
 
@@ -126,8 +127,11 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
/* parent process does a wait */
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
-   if ((strcmp(env_value, "run_pdump_server_tests") == 0))
-   pthread_create(&thread, NULL, &send_pkts, NULL);
+   if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
+   rc = pthread_create(&thread, NULL, &send_pkts, NULL);
+   if (rc)
+   rte_panic("Cannot start send pkts thread\n");
+   }
 #endif
 #endif
 
-- 
2.7.4



[dpdk-dev] [PATCH 1/2] telemetry: fix missing check for thread creation

2021-04-10 Thread Min Hu (Connor)
From: Chengwen Feng 

Add result check and message print out for thread creation after
failure.

Fixes: b80fe1805eee ("telemetry: introduce backward compatibility")
Cc: sta...@dpdk.org

Signed-off-by: Chengwen Feng 
Signed-off-by: Min Hu (Connor) 
---
 lib/librte_telemetry/telemetry.c| 30 +++---
 lib/librte_telemetry/telemetry_legacy.c | 10 --
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/lib/librte_telemetry/telemetry.c b/lib/librte_telemetry/telemetry.c
index 7e08afd..b039087 100644
--- a/lib/librte_telemetry/telemetry.c
+++ b/lib/librte_telemetry/telemetry.c
@@ -350,6 +350,7 @@ socket_listener(void *socket)
 {
while (1) {
pthread_t th;
+   int rc;
struct socket *s = (struct socket *)socket;
int s_accepted = accept(s->sock, NULL, NULL);
if (s_accepted < 0) {
@@ -366,7 +367,16 @@ socket_listener(void *socket)
__atomic_add_fetch(s->num_clients, 1,
__ATOMIC_RELAXED);
}
-   pthread_create(&th, NULL, s->fn, (void *)(uintptr_t)s_accepted);
+   rc = pthread_create(&th, NULL, s->fn,
+   (void *)(uintptr_t)s_accepted);
+   if (rc) {
+   snprintf(telemetry_log_error,
+   sizeof(telemetry_log_error),
+   "Error with create thread, telemetry thread "
+   "quitting");
+   close(s_accepted);
+   return NULL;
+   }
pthread_detach(th);
}
return NULL;
@@ -425,6 +435,7 @@ static int
 telemetry_legacy_init(void)
 {
pthread_t t_old;
+   int rc;
 
if (num_legacy_callbacks == 1) {
TMTY_LOG(WARNING, "No legacy callbacks, legacy socket not 
created\n");
@@ -440,7 +451,13 @@ telemetry_legacy_init(void)
v1_socket.sock = create_socket(v1_socket.path);
if (v1_socket.sock < 0)
return -1;
-   pthread_create(&t_old, NULL, socket_listener, &v1_socket);
+   rc = pthread_create(&t_old, NULL, socket_listener, &v1_socket);
+   if (rc) {
+   snprintf(telemetry_log_error, sizeof(telemetry_log_error),
+   "Error with create thread");
+   unlink_sockets();
+   return -1;
+   }
pthread_setaffinity_np(t_old, sizeof(*thread_cpuset), thread_cpuset);
 
TMTY_LOG(DEBUG, "Legacy telemetry socket initialized ok\n");
@@ -451,6 +468,7 @@ static int
 telemetry_v2_init(void)
 {
pthread_t t_new;
+   int rc;
 
v2_socket.num_clients = &v2_clients;
rte_telemetry_register_cmd("/", list_commands,
@@ -469,7 +487,13 @@ telemetry_v2_init(void)
v2_socket.sock = create_socket(v2_socket.path);
if (v2_socket.sock < 0)
return -1;
-   pthread_create(&t_new, NULL, socket_listener, &v2_socket);
+   rc = pthread_create(&t_new, NULL, socket_listener, &v2_socket);
+   if (rc) {
+   snprintf(telemetry_log_error, sizeof(telemetry_log_error),
+   "Error with create thread");
+   unlink_sockets();
+   return -1;
+   }
pthread_setaffinity_np(t_new, sizeof(*thread_cpuset), thread_cpuset);
atexit(unlink_sockets);
 
diff --git a/lib/librte_telemetry/telemetry_legacy.c 
b/lib/librte_telemetry/telemetry_legacy.c
index 5e9af37..9587bfe 100644
--- a/lib/librte_telemetry/telemetry_legacy.c
+++ b/lib/librte_telemetry/telemetry_legacy.c
@@ -83,6 +83,7 @@ register_client(const char *cmd __rte_unused, const char 
*params,
pthread_t th;
char data[BUF_SIZE];
int fd;
+   int rc;
struct sockaddr_un addrs;
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
@@ -112,8 +113,13 @@ register_client(const char *cmd __rte_unused, const char 
*params,
close(fd);
return -1;
}
-   pthread_create(&th, NULL, &legacy_client_handler,
-   (void *)(uintptr_t)fd);
+   rc = pthread_create(&th, NULL, &legacy_client_handler,
+   (void *)(uintptr_t)fd);
+   if (rc) {
+   fprintf(stderr, "Failed to create thread\n");
+   close(fd);
+   return -1;
+   }
 #endif /* !RTE_EXEC_ENV_WINDOWS */
return 0;
 }
-- 
2.7.4



[dpdk-dev] [PATCH] ethdev: introduce conntrack flow action and item

2021-04-10 Thread Bing Zhao
This commit introduced the conntrack action and item.

Usually the HW offloading is stateless. For some stateful offloading
like a TCP connection, HW module will help provide the ability of a
full offloading w/o SW participation after the connection was
established.

The basic usage is that in the first flow the application should add
the conntrack action and in the following flow(s) the application
should use the conntrack item to match on the result.

A TCP connection has two directions traffic. To set a conntrack
action context correctly, information from packets of both directions
are required.

The conntrack action should be created on one port and supply the
peer port as a parameter to the action. After context creating, it
could only be used between the ports (dual-port mode) or a single
port. The application should modify the action via the API
"action_handle_update" only when before using it to create a flow
with opposite direction. This will help the driver to recognize the
direction of the flow to be created, especially in single port mode.
The traffic from both directions will go through the same port if
the application works as an "forwarding engine" but not a end point.
There is no need to call the update interface if the subsequent flows
have nothing to be changed.

Query will be supported via action_ctx_query interface, about the
current packets information and connection status. Tha fields
query capabilities depends on the HW.

For the packets received during the conntrack setup, it is suggested
to re-inject the packets in order to take full advantage of the
conntrack. Only the valid packets should pass the conntrack, packets
with invalid TCP information, like out of window, or with invalid
header, like malformed, should not pass.

Naming and definition:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/nf_conntrack_proto_tcp.c

Other reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdf

Signed-off-by: Bing Zhao 
---
 lib/librte_ethdev/rte_flow.h | 195 +++
 1 file changed, 195 insertions(+)

diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h
index 6cc57136ac..d506377f7e 100644
--- a/lib/librte_ethdev/rte_flow.h
+++ b/lib/librte_ethdev/rte_flow.h
@@ -551,6 +551,15 @@ enum rte_flow_item_type {
 * See struct rte_flow_item_geneve_opt
 */
RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
+
+   /**
+* [META]
+*
+* Matches conntrack state.
+*
+* See struct rte_flow_item_conntrack.
+*/
+   RTE_FLOW_ITEM_TYPE_CONNTRACK,
 };
 
 /**
@@ -1685,6 +1694,51 @@ rte_flow_item_geneve_opt_mask = {
 };
 #endif
 
+/**
+ * The packet is with valid state after conntrack checking.
+ */
+#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_VALID (1 << 0)
+/**
+ * The state of the connection was changed.
+ */
+#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_CHANGED (1 << 1)
+/**
+ * Error is detected on this packet for this connection and
+ * an invalid state is set.
+ */
+#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_INVAL (1 << 2)
+/**
+ * The HW connection tracking module is disabled.
+ * It can be due to application command or an invalid state.
+ */
+#define RTE_FLOW_CONNTRACK_FLAG_HW_DISABLED (1 << 3)
+/**
+ * The packet contains some bad field(s) and cannot continue
+ * with the conntrack module checking.
+ */
+#define RTE_FLOW_CONNTRACK_FLAG_PKT_BAD (1 << 4)
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_CONNTRACK
+ *
+ * Matches the state of a packet after it passed the connection tracking
+ * examination. The state is a bit mask of one RTE_FLOW_CONNTRACK_FLAG*
+ * or a reasonable combination of these bits.
+ */
+struct rte_flow_item_conntrack {
+   uint32_t flags;
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
+#ifndef __cplusplus
+static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
+   .flags = 0x,
+};
+#endif
+
 /**
  * Matching pattern item definition.
  *
@@ -2267,6 +2321,17 @@ enum rte_flow_action_type {
 * See struct rte_flow_action_modify_field.
 */
RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
+
+   /**
+* [META]
+*
+* Enable tracking a TCP connection state.
+*
+* Send packet to HW connection tracking module for examination.
+*
+* See struct rte_flow_action_conntrack.
+*/
+   RTE_FLOW_ACTION_TYPE_CONNTRACK,
 };
 
 /**
@@ -2859,6 +2924,136 @@ struct rte_flow_action_set_dscp {
  */
 struct rte_flow_shared_action;
 
+/**
+ * The state of a TCP connection.
+ */
+enum rte_flow_conntrack_state {
+   /**< SYN-ACK packet was seen. */
+   RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
+   /**< 3-way handshark was done. */
+   RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
+   /**< Firs

[dpdk-dev] [PATCH v2 1/4] ethdev: introduce indirect action APIs

2021-04-10 Thread Bing Zhao
Right now, rte_flow_shared_action_* APIs are used for some shared
actions, like RSS, count. The shared action should be created before
using it inside a flow. These shared actions sometimes are not
really shared but just some indirect actions decoupled from a flow.

The new functions rte_flow_action_handle_* are added to replace
the current shared functions rte_flow_shared_action_*.

There are two types of flow actions:
1. the direct (normal) actions that could be created and stored
   within a flow rule. Such action is tied to its flow rule and
   cannot be reused.
2. the indirect action, in the past, named shared_action. It is
   created from a direct actioni, like count or rss, and then used
   in the flow rules with an object handle. The PMD will take care
   of the retrieve from indirect action to the direct action
   when it is referenced.

The indirect action is accessed (update / query) w/o any flow rule,
just via the action object handle. For example, when querying or
resetting a counter, it could be done out of any flow using this
counter, but only the handle of the counter action object is
required.
The indirect action object could be shared by different flows or
used by a single flow, depending on the direct action type and
the real-life requirements.
The handle of an indirect action object is opaque and defined in
each driver and possibly different per direct action type.

The old name "shared" is improper in a sense and should be replaced.

All the command lines in testpmd application with "shared_action*"
are replaced with "indirect_action*".

The parameter of "update" interface is also changed. A general
pointer will replace the rte_flow_action struct pointer due to the
facts:
1. Some action may not support fields updating. In the example of a
   counter, the only "update" supported should be the reset. So
   passing a rte_flow_action struct pointer is meaningless and
   there is even no such corresponding action struct. What's more,
   if more than one operations should be supported, for some other
   action, such pointer parameter may not meet the need.
2. Some action may need conditional or partial update, the current
   parameter will not provide the ability to indicate which part(s)
   to update.
   For different types of indirect action objects, the pointer could
   either be the same of rte_flow_action* struct - in order not to
   break the current driver implementation, or some wrapper
   structures with bits as masks to indicate which part to be
   updated, depending on real needs of the corresponding direct
   action. For different direct actions, the structures of indirect
   action objects updating will be different.

All the underlayer PMD callbacks will be moved to these new APIs.

The RTE_FLOW_ACTION_TYPE_SHARED is kept for now in order not to
break the ABI. All the implementations are changed by using
RTE_FLOW_ACTION_TYPE_INDIRECT.

Signed-off-by: Bing Zhao 
---
 doc/guides/rel_notes/release_21_05.rst |   3 +
 lib/librte_ethdev/rte_flow.c   |  56 
 lib/librte_ethdev/rte_flow.h   | 118 +++--
 lib/librte_ethdev/rte_flow_driver.h|  26 
 lib/librte_ethdev/version.map  |   8 +--
 5 files changed, 115 insertions(+), 96 deletions(-)

diff --git a/doc/guides/rel_notes/release_21_05.rst 
b/doc/guides/rel_notes/release_21_05.rst
index 374d6d9..6c0ac46 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -164,6 +164,9 @@ API Changes
   from ``rte_thread_tls_*`` to ``rte_thread_*`` to avoid naming redundancy
   and confusion with the transport layer security term.
 
+* ethdev: The experimental shared action APIs in ``rte_flow.h`` has been
+  replaced from ``rte_flow_shared_action_*`` to indirect action APIs named
+  ``rte_flow_action_handle_*``.
 
 ABI Changes
 ---
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index e07e617..27a1615 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -180,12 +180,12 @@ struct rte_flow_desc_data {
MK_FLOW_ACTION(MODIFY_FIELD,
   sizeof(struct rte_flow_action_modify_field)),
/**
-* Shared action represented as handle of type
-* (struct rte_flow_shared action *) stored in conf field (see
+* Indirect action represented as handle of type
+* (struct rte_flow_action_handle *) stored in conf field (see
 * struct rte_flow_action); no need for additional structure to * store
-* shared action handle.
+* indirect action handle.
 */
-   MK_FLOW_ACTION(SHARED, 0),
+   MK_FLOW_ACTION(INDIRECT, 0),
 };
 
 int
@@ -1067,53 +1067,53 @@ enum rte_flow_conv_item_spec_type {
  NULL, rte_strerror(ENOTSUP));
 }
 
-struct rte_flow_shared_action *
-rte_flow_shared_action_create(uint16_t port_id,
- const struct rte_flow_shared_ac

[dpdk-dev] [PATCH v2 0/4] Change shared action API to action handle API

2021-04-10 Thread Bing Zhao
The patch set includes:
  1. API changes
  2. testpmd adaption and guide update
  3. driver update (only net/mlx5 impacted)

---
v2: add adaptions of testpmd and driver part
---

Bing Zhao (4):
  ethdev: introduce indirect action APIs
  app/test-pmd: change to indirect action command
  doc: update user guide for indirect action
  net/mlx5: adaption to indirect action API

 app/test-pmd/cmdline.c  |  24 +--
 app/test-pmd/cmdline_flow.c | 252 ++--
 app/test-pmd/config.c   | 160 +-
 app/test-pmd/testpmd.h  |  28 ++--
 doc/guides/rel_notes/release_21_05.rst  |   3 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  94 +--
 drivers/net/mlx5/mlx5.c |   2 +-
 drivers/net/mlx5/mlx5_defs.h|   4 +-
 drivers/net/mlx5/mlx5_flow.c| 238 +-
 drivers/net/mlx5/mlx5_flow.h|  24 +--
 drivers/net/mlx5/mlx5_flow_dv.c |  85 +-
 lib/librte_ethdev/rte_flow.c|  56 +++
 lib/librte_ethdev/rte_flow.h| 118 +++--
 lib/librte_ethdev/rte_flow_driver.h |  26 +--
 lib/librte_ethdev/version.map   |   8 +-
 15 files changed, 574 insertions(+), 548 deletions(-)

-- 
1.8.3.1



[dpdk-dev] [PATCH v2 2/4] app/test-pmd: change to indirect action command

2021-04-10 Thread Bing Zhao
Since the APIs are changed from "rte_flow_shared_action*" to the new
"rte_flow_action_handle*", the testpmd application code and command
line interfaces are also need to be updated to do the adaption.

Signed-off-by: Bing Zhao 
---
 app/test-pmd/cmdline.c  |  24 ++---
 app/test-pmd/cmdline_flow.c | 252 ++--
 app/test-pmd/config.c   | 160 ++--
 app/test-pmd/testpmd.h  |  28 ++---
 4 files changed, 232 insertions(+), 232 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f44116b..c28a3d2 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1002,23 +1002,23 @@ static void cmd_help_long_parsed(void *parsed_result,
"List and destroy aged flows"
" flow rules\n\n"
 
-   "flow shared_action {port_id} create"
-   " [action_id {shared_action_id}]"
+   "flow indirect_action {port_id} create"
+   " [action_id {indirect_action_id}]"
" [ingress] [egress]"
" action {action} / end\n"
-   "Create shared action.\n\n"
+   "Create indirect action.\n\n"
 
-   "flow shared_action {port_id} update"
-   " {shared_action_id} action {action} / end\n"
-   "Update shared action.\n\n"
+   "flow indirect_action {port_id} update"
+   " {indirect_action_id} action {action} / end\n"
+   "Update indirect action.\n\n"
 
-   "flow shared_action {port_id} destroy"
-   " action_id {shared_action_id} [...]\n"
-   "Destroy specific shared actions.\n\n"
+   "flow indirect_action {port_id} destroy"
+   " action_id {indirect_action_id} [...]\n"
+   "Destroy specific indirect actions.\n\n"
 
-   "flow shared_action {port_id} query"
-   " {shared_action_id}\n"
-   "Query an existing shared action.\n\n"
+   "flow indirect_action {port_id} query"
+   " {indirect_action_id}\n"
+   "Query an existing indirect action.\n\n"
 
"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 2c40c69..d4e11a8 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -54,7 +54,7 @@ enum index {
PORT_ID,
GROUP_ID,
PRIORITY_LEVEL,
-   SHARED_ACTION_ID,
+   INDIRECT_ACTION_ID,
 
/* Top-level command. */
SET,
@@ -68,7 +68,7 @@ enum index {
/* Top-level command. */
FLOW,
/* Sub-level commands. */
-   SHARED_ACTION,
+   INDIRECT_ACTION,
VALIDATE,
CREATE,
DESTROY,
@@ -108,21 +108,21 @@ enum index {
TUNNEL_SET,
TUNNEL_MATCH,
 
-   /* Shared action arguments */
-   SHARED_ACTION_CREATE,
-   SHARED_ACTION_UPDATE,
-   SHARED_ACTION_DESTROY,
-   SHARED_ACTION_QUERY,
+   /* Indirect action arguments */
+   INDIRECT_ACTION_CREATE,
+   INDIRECT_ACTION_UPDATE,
+   INDIRECT_ACTION_DESTROY,
+   INDIRECT_ACTION_QUERY,
 
-   /* Shared action create arguments */
-   SHARED_ACTION_CREATE_ID,
-   SHARED_ACTION_INGRESS,
-   SHARED_ACTION_EGRESS,
-   SHARED_ACTION_TRANSFER,
-   SHARED_ACTION_SPEC,
+   /* Indirect action create arguments */
+   INDIRECT_ACTION_CREATE_ID,
+   INDIRECT_ACTION_INGRESS,
+   INDIRECT_ACTION_EGRESS,
+   INDIRECT_ACTION_TRANSFER,
+   INDIRECT_ACTION_SPEC,
 
-   /* Shared action destroy arguments */
-   SHARED_ACTION_DESTROY_ID,
+   /* Indirect action destroy arguments */
+   INDIRECT_ACTION_DESTROY_ID,
 
/* Validate/create pattern. */
PATTERN,
@@ -412,8 +412,8 @@ enum index {
ACTION_SAMPLE_RATIO,
ACTION_SAMPLE_INDEX,
ACTION_SAMPLE_INDEX_VALUE,
-   ACTION_SHARED,
-   SHARED_ACTION_ID2PTR,
+   ACTION_INDIRECT,
+   INDIRECT_ACTION_ID2PTR,
ACTION_MODIFY_FIELD,
ACTION_MODIFY_FIELD_OP,
ACTION_MODIFY_FIELD_OP_VALUE,
@@ -772,10 +772,10 @@ struct buffer {
struct {
uint32_t *action_id;
uint32_t action_id_n;
-   } sa_destroy; /**< Shared action destroy arguments. */
+   } ia_destroy; /**< Indirect action destroy arguments. */
struct {
uint32_t action_id;
-   } sa; /* Shared action query arguments */
+   } ia; /* Indirec

[dpdk-dev] [PATCH v2 3/4] doc: update user guide for indirect action

2021-04-10 Thread Bing Zhao
The testpmd application user guide is updated. All the "shared
action" related parts are replaced with "indirect action" to have a
correct explanation.

Signed-off-by: Bing Zhao 
---
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 94 ++---
 1 file changed, 47 insertions(+), 47 deletions(-)

diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst 
b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 2b407a3..42d3d23 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4049,10 +4049,10 @@ This section lists supported actions and their 
attributes, if any.
 
   - ``dscp_value {unsigned}``: The new DSCP value to be set
 
-- ``shared``: Use shared action created via
-  ``flow shared_action {port_id} create``
+- ``indirect``: Use indirect action created via
+  ``flow indirect_action {port_id} create``
 
-  - ``shared_action_id {unsigned}``: Shared action ID to use
+  - ``indirect_action_id {unsigned}``: Indirect action ID to use
 
 Destroying flow rules
 ~
@@ -4343,113 +4343,113 @@ If attach ``destroy`` parameter, the command will 
destroy all the list aged flow
testpmd> flow aged 0
Port 0 total aged flows: 0
 
-Creating shared actions
+Creating indirect actions
 ~~~
-``flow shared_action {port_id} create`` creates shared action with optional
-shared action ID. It is bound to ``rte_flow_shared_action_create()``::
+``flow indirect_action {port_id} create`` creates indirect action with optional
+indirect action ID. It is bound to ``rte_flow_action_handle_create()``::
 
-   flow shared_action {port_id} create [action_id {shared_action_id}]
+   flow indirect_action {port_id} create [action_id {indirect_action_id}]
   [ingress] [egress] [transfer] action {action} / end
 
 If successful, it will show::
 
-   Shared action #[...] created
+   Indirect action #[...] created
 
-Otherwise, it will complain either that shared action already exists or that
+Otherwise, it will complain either that indirect action already exists or that
 some error occurred::
 
-   Shared action #[...] is already assigned, delete it first
+   Indirect action #[...] is already assigned, delete it first
 
 ::
 
Caught error type [...] ([...]): [...]
 
-Create shared rss action with id 100 to queues 1 and 2 on port 0::
+Create indirect rss action with id 100 to queues 1 and 2 on port 0::
 
-   testpmd> flow shared_action 0 create action_id 100 \
+   testpmd> flow indirect_action 0 create action_id 100 \
   ingress action rss queues 1 2 end / end
 
-Create shared rss action with id assigned by testpmd to queues 1 and 2 on
+Create indirect rss action with id assigned by testpmd to queues 1 and 2 on
 port 0::
 
-   testpmd> flow shared_action 0 create action_id \
+   testpmd> flow indirect_action 0 create action_id \
ingress action rss queues 0 1 end / end
 
-Updating shared actions
+Updating indirect actions
 ~~~
-``flow shared_action {port_id} update`` updates configuration of the shared
-action from its shared action ID (as returned by
-``flow shared_action {port_id} create``). It is bound to
-``rte_flow_shared_action_update()``::
+``flow indirect_action {port_id} update`` updates configuration of the indirect
+action from its indirect action ID (as returned by
+``flow indirect_action {port_id} create``). It is bound to
+``rte_flow_action_handle_update()``::
 
-   flow shared_action {port_id} update {shared_action_id}
+   flow indirect_action {port_id} update {indirect_action_id}
   action {action} / end
 
 If successful, it will show::
 
-   Shared action #[...] updated
+   Indirect action #[...] updated
 
-Otherwise, it will complain either that shared action not found or that some
+Otherwise, it will complain either that indirect action not found or that some
 error occurred::
 
-   Failed to find shared action #[...] on port [...]
+   Failed to find indirect action #[...] on port [...]
 
 ::
 
Caught error type [...] ([...]): [...]
 
-Update shared rss action having id 100 on port 0 with rss to queues 0 and 3
+Update indirect rss action having id 100 on port 0 with rss to queues 0 and 3
 (in create example above rss queues were 1 and 2)::
 
-   testpmd> flow shared_action 0 update 100 action rss queues 0 3 end / end
+   testpmd> flow indirect_action 0 update 100 action rss queues 0 3 end / end
 
-Destroying shared actions
+Destroying indirect actions
 ~
-``flow shared_action {port_id} update`` destroys one or more shared actions
-from their shared action IDs (as returned by
-``flow shared_action {port_id} create``). It is bound to
-``rte_flow_shared_action_destroy()``::
+``flow indirect_action {port_id} destroy`` destroys one or more indirect 
actions
+from their indirect action IDs (as returned by
+``flow indirect_action {port_id} create``). It is bound to
+``rte_flow_action_handle_destroy()``::
 
-   flow shared_action {port_id

[dpdk-dev] [PATCH v2 4/4] net/mlx5: adaption to indirect action API

2021-04-10 Thread Bing Zhao
Since the APIs are changed from "rte_flow_shared_action*" to the new
"rte_flow_action_handle*" and the "update" interface's 3rd input
parameter is changed to generic pointer, mlx5 PMD needs to do the
adaption to the new APIs.

Signed-off-by: Bing Zhao 
---
 drivers/net/mlx5/mlx5.c |   2 +-
 drivers/net/mlx5/mlx5_defs.h|   4 +-
 drivers/net/mlx5/mlx5_flow.c| 238 
 drivers/net/mlx5/mlx5_flow.h|  24 ++--
 drivers/net/mlx5/mlx5_flow_dv.c |  85 +++---
 5 files changed, 180 insertions(+), 173 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 593532d..a198476 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1342,7 +1342,7 @@ struct mlx5_dev_ctx_shared *
 * then this will return directly without any action.
 */
mlx5_flow_list_flush(dev, &priv->flows, true);
-   mlx5_shared_action_flush(dev);
+   mlx5_action_handle_flush(dev);
mlx5_flow_meter_flush(dev, NULL);
/* Prevent crashes when queues are still in use. */
dev->rx_pkt_burst = removed_rx_burst;
diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h
index 8f2807d..6e9c4b9 100644
--- a/drivers/net/mlx5/mlx5_defs.h
+++ b/drivers/net/mlx5/mlx5_defs.h
@@ -192,8 +192,8 @@
 #define MLX5_HAIRPIN_QUEUE_STRIDE 6
 #define MLX5_HAIRPIN_JUMBO_LOG_SIZE (14 + 2)
 
-/* Maximum number of shared actions supported by rte_flow */
-#define MLX5_MAX_SHARED_ACTIONS 2
+/* Maximum number of indirect actions supported by rte_flow */
+#define MLX5_MAX_INDIRECT_ACTIONS 2
 
 /*
  * Linux definition of static_assert is found in /usr/include/assert.h.
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index c347f81..546b9ea 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -583,23 +583,23 @@ enum mlx5_expansion {
},
 };
 
-static struct rte_flow_shared_action *
-mlx5_shared_action_create(struct rte_eth_dev *dev,
- const struct rte_flow_shared_action_conf *conf,
+static struct rte_flow_action_handle *
+mlx5_action_handle_create(struct rte_eth_dev *dev,
+ const struct rte_flow_indir_action_conf *conf,
  const struct rte_flow_action *action,
  struct rte_flow_error *error);
-static int mlx5_shared_action_destroy
+static int mlx5_action_handle_destroy
(struct rte_eth_dev *dev,
-struct rte_flow_shared_action *shared_action,
+struct rte_flow_action_handle *handle,
 struct rte_flow_error *error);
-static int mlx5_shared_action_update
+static int mlx5_action_handle_update
(struct rte_eth_dev *dev,
-struct rte_flow_shared_action *shared_action,
-const struct rte_flow_action *action,
+struct rte_flow_action_handle *handle,
+const void *update,
 struct rte_flow_error *error);
-static int mlx5_shared_action_query
+static int mlx5_action_handle_query
(struct rte_eth_dev *dev,
-const struct rte_flow_shared_action *action,
+const struct rte_flow_action_handle *handle,
 void *data,
 struct rte_flow_error *error);
 static int
@@ -638,10 +638,10 @@ enum mlx5_expansion {
.query = mlx5_flow_query,
.dev_dump = mlx5_flow_dev_dump,
.get_aged_flows = mlx5_flow_get_aged_flows,
-   .shared_action_create = mlx5_shared_action_create,
-   .shared_action_destroy = mlx5_shared_action_destroy,
-   .shared_action_update = mlx5_shared_action_update,
-   .shared_action_query = mlx5_shared_action_query,
+   .action_handle_create = mlx5_action_handle_create,
+   .action_handle_destroy = mlx5_action_handle_destroy,
+   .action_handle_update = mlx5_action_handle_update,
+   .action_handle_query = mlx5_action_handle_query,
.tunnel_decap_set = mlx5_flow_tunnel_decap_set,
.tunnel_match = mlx5_flow_tunnel_match,
.tunnel_action_decap_release = mlx5_flow_tunnel_action_release,
@@ -3417,31 +3417,31 @@ struct mlx5_aso_age_action*
return &pool->actions[offset - 1];
 }
 
-/* maps shared action to translated non shared in some actions array */
-struct mlx5_translated_shared_action {
-   struct rte_flow_shared_action *action; /**< Shared action */
-   int index; /**< Index in related array of rte_flow_action */
+/* maps indirect action to translated direct in some actions array */
+struct mlx5_translated_action_handle {
+   struct rte_flow_action_handle *action; /**< Indirect action handle. */
+   int index; /**< Index in 

[dpdk-dev] [PATCH v4 0/5] eal: enable global device syntax by default

2021-04-10 Thread Xueming Li
The new Global Device Syntax [1] is used to identify a device with full
bus, class and driver description, example:
 -a bus=pci,addr=82:00.0/class=eth/driver=mlx5,...

This patchset fixes bugs and enable global device syntax with
backward compatibility by:
- unify devargs memory buffer cleanup
- parse name from bus driver callback api 
- try new global syntax parsing firstly and fallback to legacy parsing.


History:

V1:
 - Inital version

V2:
 - add devargs.src as complete source dev string
 - change devargs.data to scratch buffer
 - add rte_devargs_free() to release scratch memory
 - change name policy to align with rte_eth_iterator_init()
 - remove PCI bus fix as name already resolved in rte_devargs_parse().
V3:
 - remove devargs.src
 - rename rte_devargs_free() to rte_devargs_reset()
 - add bus callback api to resolve devargs.
V4:
 - add RTE_DEVARGS_KEY_BUS/CLASS/DIRVER macro
 - parsing "name" by default if no bus devargs parsing callback
 - Minor fixes suggested by Ray and Thomas


[1] Global Device Syntax:
https://www.dpdk.org/wp-content/uploads/sites/35/2018/10/am-07-DPDK-hotplug-20180905.pdf

[2] RFC:
http://patchwork.dpdk.org/project/dpdk/list/?series=14378

[3] V1:
http://patchwork.dpdk.org/project/dpdk/list/?series=14610

[4] V2:
http://patchwork.dpdk.org/project/dpdk/list/?series=14816

[5] V3:
http://patchwork.dpdk.org/project/dpdk/list/?series=15979


Xueming Li (5):
  devargs: unify scratch buffer storage
  devargs: fix memory leak on parsing error
  kvargs: add get by key function
  bus: add device arguments name parsing API
  devargs: parse global device syntax

 app/test-pmd/config.c|  3 +-
 app/test-pmd/testpmd.c   |  5 +-
 doc/guides/rel_notes/release_21_05.rst   |  6 ++
 drivers/bus/pci/pci_common.c |  1 +
 drivers/bus/pci/pci_params.c | 47 ++
 drivers/bus/pci/private.h| 14 +++
 drivers/bus/vdev/vdev.c  |  9 +-
 drivers/net/failsafe/failsafe_args.c |  3 +-
 drivers/net/failsafe/failsafe_eal.c  |  2 +-
 examples/multi_process/hotplug_mp/commands.c |  6 +-
 lib/librte_eal/common/eal_common_dev.c   |  9 +-
 lib/librte_eal/common/eal_common_devargs.c   | 91 +++-
 lib/librte_eal/common/hotplug_mp.c   |  6 +-
 lib/librte_eal/include/rte_bus.h | 18 
 lib/librte_eal/include/rte_devargs.h | 22 -
 lib/librte_eal/rte_eal_exports.def   |  1 +
 lib/librte_eal/version.map   |  1 +
 lib/librte_ethdev/rte_ethdev.c   |  9 +-
 lib/librte_kvargs/rte_kvargs.c   | 20 +
 lib/librte_kvargs/rte_kvargs.h   | 21 +
 lib/librte_kvargs/version.map|  3 +
 21 files changed, 245 insertions(+), 52 deletions(-)

-- 
2.25.1



[dpdk-dev] [PATCH v4 1/5] devargs: unify scratch buffer storage

2021-04-10 Thread Xueming Li
In current design, legacy parser rte_devargs_parse() saved scratch
buffer to devargs.args while new parser rte_devargs_layers_parse() saved
to devargs.data. Code using devargs had to know the difference and
cleaned up memory accordingly - error prone.

This patch unifies scratch buffer to data field, introduces
rte_devargs_reset() function to wrap the memory clean up logic.

Signed-off-by: Xueming Li 
Acked-by: Ray Kinsella 
Reviewed-by: Gaetan Rivet 
---
 app/test-pmd/config.c|  3 +-
 app/test-pmd/testpmd.c   |  5 +--
 drivers/bus/vdev/vdev.c  |  9 +++---
 drivers/net/failsafe/failsafe_args.c |  3 +-
 drivers/net/failsafe/failsafe_eal.c  |  2 +-
 examples/multi_process/hotplug_mp/commands.c |  6 ++--
 lib/librte_eal/common/eal_common_dev.c   |  9 +++---
 lib/librte_eal/common/eal_common_devargs.c   | 34 +++-
 lib/librte_eal/common/hotplug_mp.c   |  6 ++--
 lib/librte_eal/include/rte_devargs.h | 18 ---
 lib/librte_eal/rte_eal_exports.def   |  1 +
 lib/librte_eal/version.map   |  1 +
 lib/librte_ethdev/rte_ethdev.c   |  8 ++---
 13 files changed, 59 insertions(+), 46 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index ef0b9784d0..d774610419 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -509,8 +509,6 @@ device_infos_display(const char *identifier)
 
if (rte_devargs_parsef(&da, "%s", identifier)) {
printf("cannot parse identifier\n");
-   if (da.args)
-   free(da.args);
return;
}
 
@@ -558,6 +556,7 @@ device_infos_display(const char *identifier)
}
}
};
+   rte_devargs_reset(&da);
 }
 
 void
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 96d2e0fcec..d4be23f8f8 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3015,8 +3015,6 @@ detach_devargs(char *identifier)
memset(&da, 0, sizeof(da));
if (rte_devargs_parsef(&da, "%s", identifier)) {
printf("cannot parse identifier\n");
-   if (da.args)
-   free(da.args);
return;
}
 
@@ -3025,6 +3023,7 @@ detach_devargs(char *identifier)
if (ports[port_id].port_status != RTE_PORT_STOPPED) {
printf("Port %u not stopped\n", port_id);
rte_eth_iterator_cleanup(&iterator);
+   rte_devargs_reset(&da);
return;
}
port_flow_flush(port_id);
@@ -3034,6 +3033,7 @@ detach_devargs(char *identifier)
if (rte_eal_hotplug_remove(da.bus->name, da.name) != 0) {
TESTPMD_LOG(ERR, "Failed to detach device %s(%s)\n",
da.name, da.bus->name);
+   rte_devargs_reset(&da);
return;
}
 
@@ -3042,6 +3042,7 @@ detach_devargs(char *identifier)
printf("Device %s is detached\n", identifier);
printf("Now total ports is %d\n", nb_ports);
printf("Done\n");
+   rte_devargs_reset(&da);
 }
 
 void
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 9a673347ae..d075409942 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -245,13 +245,14 @@ alloc_devargs(const char *name, const char *args)
 
devargs->bus = &rte_vdev_bus;
if (args)
-   devargs->args = strdup(args);
+   devargs->data = strdup(args);
else
-   devargs->args = strdup("");
+   devargs->data = strdup("");
+   devargs->args = devargs->data;
 
ret = strlcpy(devargs->name, name, sizeof(devargs->name));
if (ret < 0 || ret >= (int)sizeof(devargs->name)) {
-   free(devargs->args);
+   rte_devargs_reset(devargs);
free(devargs);
return NULL;
}
@@ -305,7 +306,7 @@ insert_vdev(const char *name, const char *args,
 
return 0;
 fail:
-   free(devargs->args);
+   rte_devargs_reset(devargs);
free(devargs);
free(dev);
return ret;
diff --git a/drivers/net/failsafe/failsafe_args.c 
b/drivers/net/failsafe/failsafe_args.c
index 707490b94c..b203e02d9a 100644
--- a/drivers/net/failsafe/failsafe_args.c
+++ b/drivers/net/failsafe/failsafe_args.c
@@ -451,8 +451,7 @@ failsafe_args_free(struct rte_eth_dev *dev)
sdev->cmdline = NULL;
free(sdev->fd_str);
sdev->fd_str = NULL;
-   free(sdev->devargs.args);
-   sdev->devargs.args = NULL;
+   rte_devargs_reset(&sdev->devargs);
}
 }
 
diff --git a/drivers/net/failsafe/failsafe_eal.c 
b/drivers/net/failsafe/failsafe_eal.c
index b9fc508673..cb4a2abc02 100644
--- 

[dpdk-dev] [PATCH v4 2/5] devargs: fix memory leak on parsing error

2021-04-10 Thread Xueming Li
This patch fixes memory leak in parsing error handling.

Fixes: 338327d731e6 ("devargs: add function to parse device layers")
Cc: gaetan.ri...@6wind.com
Cc: sta...@dpdk.org

Signed-off-by: Xueming Li 
Reviewed-by: Gaetan Rivet 
---
 lib/librte_eal/common/eal_common_devargs.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c 
b/lib/librte_eal/common/eal_common_devargs.c
index 48f85ee9c0..e40b91ea66 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -60,6 +60,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
size_t nblayer;
size_t i = 0;
int ret = 0;
+   bool allocated_data = false;
 
/* Split each sub-lists. */
nblayer = devargs_layer_count(devstr);
@@ -81,6 +82,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
ret = -ENOMEM;
goto get_out;
}
+   allocated_data = true;
s = devargs->data;
}
 
@@ -163,8 +165,14 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
if (layers[i].kvlist)
rte_kvargs_free(layers[i].kvlist);
}
-   if (ret != 0)
+   if (ret != 0) {
+   if (allocated_data) {
+   /* Free duplicated data. */
+   free(devargs->data);
+   devargs->data = NULL;
+   }
rte_errno = -ret;
+   }
return ret;
 }
 
-- 
2.25.1



[dpdk-dev] [PATCH v4 3/5] kvargs: add get by key function

2021-04-10 Thread Xueming Li
Adds a new function to get value of a specific key from kvargs list.

Signed-off-by: Xueming Li 
Reviewed-by: Gaetan Rivet 
---
 lib/librte_kvargs/rte_kvargs.c | 20 
 lib/librte_kvargs/rte_kvargs.h | 21 +
 lib/librte_kvargs/version.map  |  3 +++
 3 files changed, 44 insertions(+)

diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c
index ffae8914cf..40e7670ab3 100644
--- a/lib/librte_kvargs/rte_kvargs.c
+++ b/lib/librte_kvargs/rte_kvargs.c
@@ -203,6 +203,26 @@ rte_kvargs_free(struct rte_kvargs *kvlist)
free(kvlist);
 }
 
+/* Lookup a value in an rte_kvargs list by its key. */
+const char *
+rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key)
+{
+   unsigned int i;
+
+   if (!kvlist)
+   return NULL;
+   for (i = 0; i < kvlist->count; ++i) {
+   /* Allows key to be NULL. */
+   if (!key && !kvlist->pairs[i].key)
+   return kvlist->pairs[i].value;
+   if (!key || !kvlist->pairs[i].key)
+   continue;
+   if (!strcmp(kvlist->pairs[i].key, key))
+   return kvlist->pairs[i].value;
+   }
+   return NULL;
+}
+
 /*
  * Parse the arguments "key=value,key=value,..." string and return
  * an allocated structure that contains a key/value list. Also
diff --git a/lib/librte_kvargs/rte_kvargs.h b/lib/librte_kvargs/rte_kvargs.h
index eff598e08b..cb3ea99850 100644
--- a/lib/librte_kvargs/rte_kvargs.h
+++ b/lib/librte_kvargs/rte_kvargs.h
@@ -114,6 +114,27 @@ struct rte_kvargs *rte_kvargs_parse_delim(const char *args,
  */
 void rte_kvargs_free(struct rte_kvargs *kvlist);
 
+/**
+ * Get the value associated with a given key.
+ *
+ * If the key is NULL, the first value from the list is returned.
+ * If multiple key matches, the value of the first one is returned.
+ *
+ * The memory returned is allocated as part of the rte_kvargs structure,
+ * it must never be modified.
+ *
+ * @param kvlist
+ *   A list of rte_kvargs pair of 'key=value'.
+ * @param key
+ *   The matching key.
+
+ * @return
+ *   NULL if no key matches the input, a value associated with a matching
+ *   key otherwise.
+ */
+__rte_experimental
+const char *rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key);
+
 /**
  * Call a handler function for each key/value matching the key
  *
diff --git a/lib/librte_kvargs/version.map b/lib/librte_kvargs/version.map
index ed375bf4a3..fb9bed4f93 100644
--- a/lib/librte_kvargs/version.map
+++ b/lib/librte_kvargs/version.map
@@ -15,4 +15,7 @@ EXPERIMENTAL {
rte_kvargs_parse_delim;
rte_kvargs_strcmp;
 
+   # added in 21.05
+   rte_kvargs_get;
+
 };
-- 
2.25.1



[dpdk-dev] [PATCH v4 4/5] bus: add device arguments name parsing API

2021-04-10 Thread Xueming Li
For device probe and iterator, devargs name was key information,
parsed by rte_devargs_parse. In legacy parser, devargs name was
extracted after bus name:
  bus:name,kv_arguments,,,
Example:
  pci:83:00.0,arguments,...
  vdev:pcap0,...

To be compatible with legacy parser, this patch introduces new
bus driver API devargs_parse to parse devargs and update devargs name.
If devargs_parse not implemented by bus driver, the new syntax parser
rte_devargs_layers_parse default will resolve devargs name from bus's
"name" argument.

Different bus driver might choose different keys from arguments with
unified format. The PCI bus implementation fills the devargs name with
the "addr" argument, example:
 -a bus=pci,addr=83:00.0/class=eth/driver=mlx5,...
name: :03:00.0
 -a bus=vdev,name=pcap0/class=eth/driver=pcap,...
name:pcap0

Signed-off-by: Xueming Li 
Reviewed-by: Gaetan Rivet 
---
 drivers/bus/pci/pci_common.c   |  1 +
 drivers/bus/pci/pci_params.c   | 47 ++
 drivers/bus/pci/private.h  | 14 +++
 lib/librte_eal/common/eal_common_devargs.c | 31 ++
 lib/librte_eal/include/rte_bus.h   | 18 +
 5 files changed, 111 insertions(+)

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 9b8d769287..61d3f51452 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -760,6 +760,7 @@ struct rte_pci_bus rte_pci_bus = {
.dev_iterate = rte_pci_dev_iterate,
.hot_unplug_handler = pci_hot_unplug_handler,
.sigbus_handler = pci_sigbus_handler,
+   .devargs_parse = rte_pci_devargs_parse,
},
.device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),
.driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),
diff --git a/drivers/bus/pci/pci_params.c b/drivers/bus/pci/pci_params.c
index 3192e9c967..c0c282e948 100644
--- a/drivers/bus/pci/pci_params.c
+++ b/drivers/bus/pci/pci_params.c
@@ -8,6 +8,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "private.h"
 
@@ -76,3 +78,48 @@ rte_pci_dev_iterate(const void *start,
rte_kvargs_free(kvargs);
return dev;
 }
+
+int
+rte_pci_devargs_parse(struct rte_devargs *da)
+{
+   struct rte_kvargs *kvargs;
+   const char *addr_str;
+   struct rte_pci_addr addr;
+   int ret;
+
+   if (da == NULL)
+   return 0;
+   RTE_ASSERT(da->bus_str != NULL);
+
+   kvargs = rte_kvargs_parse(da->bus_str, NULL);
+   if (kvargs == NULL) {
+   RTE_LOG(ERR, EAL, "cannot parse argument list: %s\n",
+   da->bus_str);
+   ret = -ENODEV;
+   goto out;
+   }
+
+   addr_str = rte_kvargs_get(kvargs, pci_params_keys[RTE_PCI_PARAM_ADDR]);
+   if (addr_str == NULL) {
+   RTE_LOG(ERR, EAL, "No PCI address specified using '%s=' in: 
%s\n",
+   pci_params_keys[RTE_PCI_PARAM_ADDR], da->bus_str);
+   ret = -ENODEV;
+   goto out;
+   }
+
+   ret = rte_pci_addr_parse(addr_str, &addr);
+   if (ret != 0) {
+   RTE_LOG(ERR, EAL, "PCI address invalid: %s\n", da->bus_str);
+   ret = -EINVAL;
+   goto out;
+   }
+
+   rte_pci_device_name(&addr, da->name, sizeof(da->name));
+
+out:
+   if (kvargs != NULL)
+   rte_kvargs_free(kvargs);
+   if (ret != 0)
+   rte_errno = -ret;
+   return ret;
+}
diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h
index f566943f5e..8bc5140e97 100644
--- a/drivers/bus/pci/private.h
+++ b/drivers/bus/pci/private.h
@@ -267,4 +267,18 @@ rte_pci_dev_iterate(const void *start,
const char *str,
const struct rte_dev_iterator *it);
 
+/*
+ * Parse device arguments and update name.
+ *
+ * @param da
+ *   device arguments to parse.
+ *
+ * @return
+ *   0 on success.
+ *   -EINVAL: kvargs string is invalid and cannot be parsed.
+ *   -ENODEV: no key matching a device ID is found in the kv list.
+ */
+int
+rte_pci_devargs_parse(struct rte_devargs *da);
+
 #endif /* _PCI_PRIVATE_H_ */
diff --git a/lib/librte_eal/common/eal_common_devargs.c 
b/lib/librte_eal/common/eal_common_devargs.c
index e40b91ea66..3a62521e05 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "eal_private.h"
 
 /** user device double-linked queue type definition */
@@ -40,6 +41,28 @@ devargs_layer_count(const char *s)
return i;
 }
 
+/* Resolve devargs name from bus arguments. */
+static int
+devargs_bus_parse_default(struct rte_devargs *devargs,
+ struct rte_kvargs *bus_args)
+{
+   const char *name;
+
+   /* Parse devargs name from bus key-value list. */
+   name = rte_kvargs_get(bus_args, "name");
+   

[dpdk-dev] [PATCH v4 5/5] devargs: parse global device syntax

2021-04-10 Thread Xueming Li
When parsing a devargs, try to parse using the global device syntax
first. Fallback on legacy syntax on error.

Example of new global device syntax:
 -a bus=pci,addr=82:00.0/class=eth/driver=mlx5,dv_flow_en=1

Signed-off-by: Xueming Li 
Reviewed-by: Gaetan Rivet 
---
 doc/guides/rel_notes/release_21_05.rst |  6 ++
 lib/librte_eal/common/eal_common_devargs.c | 16 
 lib/librte_eal/include/rte_devargs.h   |  4 
 lib/librte_ethdev/rte_ethdev.c |  1 -
 4 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/doc/guides/rel_notes/release_21_05.rst 
b/doc/guides/rel_notes/release_21_05.rst
index 374d6d98ea..ff1459a4d1 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -131,6 +131,12 @@ New Features
   * Added command to display Rx queue used descriptor count.
 ``show port (port_id) rxq (queue_id) desc used count``
 
+* **Enabled new devargs parser.**
+
+  * Unified devargs storage buffer usage.
+  * Added new bus driver api to allow bus driver contribute to devargs parsing.
+  * Try new devargs syntax parser first, fallback to legacy syntax parser.
+
 
 Removed Items
 -
diff --git a/lib/librte_eal/common/eal_common_devargs.c 
b/lib/librte_eal/common/eal_common_devargs.c
index 3a62521e05..069d8f8499 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -125,7 +125,6 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
layers[i].str = s;
layers[i].kvlist = rte_kvargs_parse_delim(s, NULL, "/");
if (layers[i].kvlist == NULL) {
-   RTE_LOG(ERR, EAL, "Could not parse %s\n", s);
ret = -EINVAL;
goto get_out;
}
@@ -143,7 +142,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
kv = &layers[i].kvlist->pairs[0];
if (kv->key == NULL)
continue;
-   if (strcmp(kv->key, "bus") == 0) {
+   if (strcmp(kv->key, RTE_DEVARGS_KEY_BUS) == 0) {
bus = rte_bus_find_by_name(kv->value);
if (bus == NULL) {
RTE_LOG(ERR, EAL, "Could not find bus \"%s\"\n",
@@ -151,7 +150,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
ret = -EFAULT;
goto get_out;
}
-   } else if (strcmp(kv->key, "class") == 0) {
+   } else if (strcmp(kv->key, RTE_DEVARGS_KEY_CLASS) == 0) {
cls = rte_class_find_by_name(kv->value);
if (cls == NULL) {
RTE_LOG(ERR, EAL, "Could not find class 
\"%s\"\n",
@@ -159,7 +158,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs,
ret = -EFAULT;
goto get_out;
}
-   } else if (strcmp(kv->key, "driver") == 0) {
+   } else if (strcmp(kv->key, RTE_DEVARGS_KEY_DRIVER) == 0) {
/* Ignore */
continue;
}
@@ -224,6 +223,15 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev)
if (da == NULL)
return -EINVAL;
 
+   /* First parse according global device syntax. */
+   if (rte_devargs_layers_parse(da, dev) == 0) {
+   if (da->bus != NULL || da->cls != NULL)
+   return 0;
+   rte_devargs_reset(da);
+   }
+
+   /* Otherwise fallback to legacy syntax: */
+
/* Retrieve eventual bus info */
do {
devname = dev;
diff --git a/lib/librte_eal/include/rte_devargs.h 
b/lib/librte_eal/include/rte_devargs.h
index 134b44a887..39e34ea02e 100644
--- a/lib/librte_eal/include/rte_devargs.h
+++ b/lib/librte_eal/include/rte_devargs.h
@@ -25,6 +25,10 @@ extern "C" {
 #include 
 #include 
 
+#define RTE_DEVARGS_KEY_BUS "bus"
+#define RTE_DEVARGS_KEY_CLASS "class"
+#define RTE_DEVARGS_KEY_DRIVER "driver"
+
 /**
  * Type of generic device
  */
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index e11a95558f..9e9b136438 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -207,7 +207,6 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const 
char *devargs_str)
 *   - :08:00.0,representor=[1-3]
 *   - pci::06:00.0,representor=[0,5]
 *   - class=eth,mac=00:11:22:33:44:55
-* A new syntax is in development (not yet supported):
 *   - bus=X,paramX=x/class=Y,paramY=y/driver=Z,paramZ=z
 */
 
-- 
2.25.1



[dpdk-dev] [PATCH v2 0/8] baseband: add NXP LA12xx driver

2021-04-10 Thread Hemant Agrawal
This series introduces the BBDEV LA12xx poll mode driver (PMD) to support
an implementation for offloading High Phy processing functions like LDPC Encode 
/ Decode
5GNR wireless acceleration function, using PCI based LA12xx Software defined 
radio.

Please check the documentation patch for more info.

The driver currently implements basic feature to offload only the 5G LDPC 
encode/decode.

Modifications has been done in test vectors to optionally support input in 
network byte order.

Two test vectors are also added as an example with data in network byte order.

Hemant Agrawal (6):
  baseband: introduce NXP LA12xx driver
  baseband/la12xx: add devargs for max queues
  baseband/la12xx: add support for multiple modems
  baseband/la12xx: add queue and modem config support
  baseband/la12xx: add enqueue and dequeue support
  baseband/la12xx: add documentation support

Nipun Gupta (2):
  app/bbdev: add parameter to take input in network order
  app/bbdev: add test vectors for transport blocks

 MAINTAINERS   |9 +
 app/test-bbdev/test_bbdev_vector.c|   18 +-
 app/test-bbdev/test_bbdev_vector.h|2 +
 app/test-bbdev/test_vectors/ldpc_dec_tb.data  |  362 +
 app/test-bbdev/test_vectors/ldpc_enc_tb.data  |  482 +++
 doc/guides/bbdevs/features/la12xx.ini |   14 +
 doc/guides/bbdevs/index.rst   |1 +
 doc/guides/bbdevs/la12xx.rst  |  139 ++
 doc/guides/rel_notes/release_21_05.rst|5 +
 drivers/baseband/la12xx/bbdev_la12xx.c| 1180 +
 drivers/baseband/la12xx/bbdev_la12xx.h|   57 +
 drivers/baseband/la12xx/bbdev_la12xx_ipc.h|  237 
 .../baseband/la12xx/bbdev_la12xx_pmd_logs.h   |   38 +
 drivers/baseband/la12xx/meson.build   |6 +
 drivers/baseband/la12xx/version.map   |3 +
 drivers/baseband/meson.build  |2 +-
 16 files changed, 2552 insertions(+), 3 deletions(-)
 create mode 100644 app/test-bbdev/test_vectors/ldpc_dec_tb.data
 create mode 100644 app/test-bbdev/test_vectors/ldpc_enc_tb.data
 create mode 100644 doc/guides/bbdevs/features/la12xx.ini
 create mode 100644 doc/guides/bbdevs/la12xx.rst
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx.c
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx.h
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx_ipc.h
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h
 create mode 100644 drivers/baseband/la12xx/meson.build
 create mode 100644 drivers/baseband/la12xx/version.map

-- 
2.17.1



[dpdk-dev] [PATCH v2 1/8] baseband: introduce NXP LA12xx driver

2021-04-10 Thread Hemant Agrawal
This patch introduce the baseband device drivers for NXP's
LA1200 series software defined baseband modem.

Signed-off-by: Nipun Gupta 
Signed-off-by: Hemant Agrawal 
---
 drivers/baseband/la12xx/bbdev_la12xx.c| 109 ++
 .../baseband/la12xx/bbdev_la12xx_pmd_logs.h   |  38 ++
 drivers/baseband/la12xx/meson.build   |   6 +
 drivers/baseband/la12xx/version.map   |   3 +
 drivers/baseband/meson.build  |   2 +-
 5 files changed, 157 insertions(+), 1 deletion(-)
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx.c
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h
 create mode 100644 drivers/baseband/la12xx/meson.build
 create mode 100644 drivers/baseband/la12xx/version.map

diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c 
b/drivers/baseband/la12xx/bbdev_la12xx.c
new file mode 100644
index 00..7050b17728
--- /dev/null
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -0,0 +1,109 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020-2021 NXP
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#define DRIVER_NAME baseband_la12xx
+
+RTE_LOG_REGISTER(bbdev_la12xx_logtype, pmd.bb.la12xx, NOTICE);
+
+/* private data structure */
+struct bbdev_la12xx_private {
+   unsigned int max_nb_queues;  /**< Max number of queues */
+};
+/* Create device */
+static int
+la12xx_bbdev_create(struct rte_vdev_device *vdev)
+{
+   struct rte_bbdev *bbdev;
+   const char *name = rte_vdev_device_name(vdev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   bbdev = rte_bbdev_allocate(name);
+   if (bbdev == NULL)
+   return -ENODEV;
+
+   bbdev->data->dev_private = rte_zmalloc(name,
+   sizeof(struct bbdev_la12xx_private),
+   RTE_CACHE_LINE_SIZE);
+   if (bbdev->data->dev_private == NULL) {
+   rte_bbdev_release(bbdev);
+   return -ENOMEM;
+   }
+
+   bbdev->dev_ops = NULL;
+   bbdev->device = &vdev->device;
+   bbdev->data->socket_id = 0;
+   bbdev->intr_handle = NULL;
+
+   /* register rx/tx burst functions for data path */
+   bbdev->dequeue_enc_ops = NULL;
+   bbdev->dequeue_dec_ops = NULL;
+   bbdev->enqueue_enc_ops = NULL;
+   bbdev->enqueue_dec_ops = NULL;
+
+   return 0;
+}
+
+/* Initialise device */
+static int
+la12xx_bbdev_probe(struct rte_vdev_device *vdev)
+{
+   const char *name;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (vdev == NULL)
+   return -EINVAL;
+
+   name = rte_vdev_device_name(vdev);
+   if (name == NULL)
+   return -EINVAL;
+
+   return la12xx_bbdev_create(vdev);
+}
+
+/* Uninitialise device */
+static int
+la12xx_bbdev_remove(struct rte_vdev_device *vdev)
+{
+   struct rte_bbdev *bbdev;
+   const char *name;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (vdev == NULL)
+   return -EINVAL;
+
+   name = rte_vdev_device_name(vdev);
+   if (name == NULL)
+   return -EINVAL;
+
+   bbdev = rte_bbdev_get_named_dev(name);
+   if (bbdev == NULL)
+   return -EINVAL;
+
+   rte_free(bbdev->data->dev_private);
+
+   return rte_bbdev_release(bbdev);
+}
+
+static struct rte_vdev_driver bbdev_la12xx_pmd_drv = {
+   .probe = la12xx_bbdev_probe,
+   .remove = la12xx_bbdev_remove
+};
+
+RTE_PMD_REGISTER_VDEV(DRIVER_NAME, bbdev_la12xx_pmd_drv);
diff --git a/drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h 
b/drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h
new file mode 100644
index 00..71613a5bac
--- /dev/null
+++ b/drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 NXP
+ */
+
+#ifndef _BBDEV_LA12XX_PMD_LOGS_H_
+#define _BBDEV_LA12XX_PMD_LOGS_H_
+
+#define BBDEV_LA12XX_PMD_LOG(level, fmt, args...) \
+   rte_log(RTE_LOG_ ## level, bbdev_la12xx_logtype, "bbdev_la12xx: " \
+   fmt "\n", ##args)
+
+#define BBDEV_LA12XX_PMD_DEBUG(fmt, args...) \
+   rte_log(RTE_LOG_DEBUG, bbdev_la12xx_logtype, "bbdev_la12xx: %s(): "\
+   fmt "\n", __func__, ##args)
+
+#define PMD_INIT_FUNC_TRACE() BBDEV_LA12XX_PMD_DEBUG(">>")
+
+#define BBDEV_LA12XX_PMD_CRIT(fmt, args...) \
+   BBDEV_LA12XX_PMD_LOG(CRIT, fmt, ## args)
+#define BBDEV_LA12XX_PMD_INFO(fmt, args...) \
+   BBDEV_LA12XX_PMD_LOG(INFO, fmt, ## args)
+#define BBDEV_LA12XX_PMD_ERR(fmt, args...) \
+   BBDEV_LA12XX_PMD_LOG(ERR, fmt, ## args)
+#define BBDEV_LA12XX_PMD_WARN(fmt, args...) \
+   BBDEV_LA12XX_PMD_LOG(WARNING, fmt, ## args)
+
+/* DP Logs, toggled out at compile time if level lower than current level */
+#define BBDEV_LA12XX_PMD_DP_LOG(level, fmt, args...) \
+   RTE_LOG_DP(level, PMD, fmt, ## args)
+
+#define BBDEV_LA12XX_PMD_DP_DEBUG(fmt, args...) \
+   BBDEV_LA12XX_PMD_DP_LOG(DEBUG, fmt, ## args)
+#define BBDEV_LA12XX_PMD_DP_INFO(fmt, ar

[dpdk-dev] [PATCH v2 2/8] baseband/la12xx: add devargs for max queues

2021-04-10 Thread Hemant Agrawal
This patch adds dev args to take  max queues as input

Signed-off-by: Nipun Gupta 
Signed-off-by: Hemant Agrawal 
---
 drivers/baseband/la12xx/bbdev_la12xx.c | 72 +-
 1 file changed, 70 insertions(+), 2 deletions(-)

diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c 
b/drivers/baseband/la12xx/bbdev_la12xx.c
index 7050b17728..8fc58ce5ae 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -19,13 +19,72 @@
 
 RTE_LOG_REGISTER(bbdev_la12xx_logtype, pmd.bb.la12xx, NOTICE);
 
+/*  Initialisation params structure that can be used by LA12xx BBDEV driver */
+struct bbdev_la12xx_params {
+   uint8_t queues_num; /*< LA12xx BBDEV queues number */
+};
+
+#define BBDEV_LA12XX_MAX_NB_QUEUES_ARG  "max_nb_queues"
+
+static const char * const bbdev_la12xx_valid_params[] = {
+   BBDEV_LA12XX_MAX_NB_QUEUES_ARG,
+};
+
 /* private data structure */
 struct bbdev_la12xx_private {
unsigned int max_nb_queues;  /**< Max number of queues */
 };
+static inline int
+parse_u16_arg(const char *key, const char *value, void *extra_args)
+{
+   uint16_t *u16 = extra_args;
+
+   unsigned int long result;
+   if ((value == NULL) || (extra_args == NULL))
+   return -EINVAL;
+   errno = 0;
+   result = strtoul(value, NULL, 0);
+   if ((result >= (1 << 16)) || (errno != 0)) {
+   BBDEV_LA12XX_PMD_ERR("Invalid value %lu for %s", result, key);
+   return -ERANGE;
+   }
+   *u16 = (uint16_t)result;
+   return 0;
+}
+
+/* Parse parameters used to create device */
+static int
+parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
+   const char *input_args)
+{
+   struct rte_kvargs *kvlist = NULL;
+   int ret = 0;
+
+   if (params == NULL)
+   return -EINVAL;
+   if (input_args) {
+   kvlist = rte_kvargs_parse(input_args,
+   bbdev_la12xx_valid_params);
+   if (kvlist == NULL)
+   return -EFAULT;
+
+   ret = rte_kvargs_process(kvlist, bbdev_la12xx_valid_params[0],
+   &parse_u16_arg, ¶ms->queues_num);
+   if (ret < 0)
+   goto exit;
+
+   }
+
+exit:
+   if (kvlist)
+   rte_kvargs_free(kvlist);
+   return ret;
+}
+
 /* Create device */
 static int
-la12xx_bbdev_create(struct rte_vdev_device *vdev)
+la12xx_bbdev_create(struct rte_vdev_device *vdev,
+   struct bbdev_la12xx_params *init_params)
 {
struct rte_bbdev *bbdev;
const char *name = rte_vdev_device_name(vdev);
@@ -62,7 +121,11 @@ la12xx_bbdev_create(struct rte_vdev_device *vdev)
 static int
 la12xx_bbdev_probe(struct rte_vdev_device *vdev)
 {
+   struct bbdev_la12xx_params init_params = {
+   RTE_BBDEV_DEFAULT_MAX_NB_QUEUES
+   };
const char *name;
+   const char *input_args;
 
PMD_INIT_FUNC_TRACE();
 
@@ -73,7 +136,10 @@ la12xx_bbdev_probe(struct rte_vdev_device *vdev)
if (name == NULL)
return -EINVAL;
 
-   return la12xx_bbdev_create(vdev);
+   input_args = rte_vdev_device_args(vdev);
+   parse_bbdev_la12xx_params(&init_params, input_args);
+
+   return la12xx_bbdev_create(vdev, &init_params);
 }
 
 /* Uninitialise device */
@@ -107,3 +173,5 @@ static struct rte_vdev_driver bbdev_la12xx_pmd_drv = {
 };
 
 RTE_PMD_REGISTER_VDEV(DRIVER_NAME, bbdev_la12xx_pmd_drv);
+RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
+   BBDEV_LA12XX_MAX_NB_QUEUES_ARG"=");
-- 
2.17.1



[dpdk-dev] [PATCH v2 3/8] baseband/la12xx: add support for multiple modems

2021-04-10 Thread Hemant Agrawal
This patch add support for multiple modems by assigning
a modem id as dev args in vdev creation.

Signed-off-by: Hemant Agrawal 
---
 drivers/baseband/la12xx/bbdev_la12xx.c | 62 +++---
 drivers/baseband/la12xx/bbdev_la12xx.h | 56 +++
 drivers/baseband/la12xx/bbdev_la12xx_ipc.h | 20 +++
 3 files changed, 132 insertions(+), 6 deletions(-)
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx.h
 create mode 100644 drivers/baseband/la12xx/bbdev_la12xx_ipc.h

diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c 
b/drivers/baseband/la12xx/bbdev_la12xx.c
index 8fc58ce5ae..3837e43d8e 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -14,6 +14,8 @@
 #include 
 
 #include 
+#include 
+#include 
 
 #define DRIVER_NAME baseband_la12xx
 
@@ -22,18 +24,18 @@ RTE_LOG_REGISTER(bbdev_la12xx_logtype, pmd.bb.la12xx, 
NOTICE);
 /*  Initialisation params structure that can be used by LA12xx BBDEV driver */
 struct bbdev_la12xx_params {
uint8_t queues_num; /*< LA12xx BBDEV queues number */
+   int8_t modem_id; /*< LA12xx modem instance id */
 };
 
 #define BBDEV_LA12XX_MAX_NB_QUEUES_ARG  "max_nb_queues"
+#define BBDEV_LA12XX_VDEV_MODEM_ID_ARG "modem"
+#define LA12XX_MAX_MODEM 4
 
 static const char * const bbdev_la12xx_valid_params[] = {
BBDEV_LA12XX_MAX_NB_QUEUES_ARG,
+   BBDEV_LA12XX_VDEV_MODEM_ID_ARG,
 };
 
-/* private data structure */
-struct bbdev_la12xx_private {
-   unsigned int max_nb_queues;  /**< Max number of queues */
-};
 static inline int
 parse_u16_arg(const char *key, const char *value, void *extra_args)
 {
@@ -52,6 +54,28 @@ parse_u16_arg(const char *key, const char *value, void 
*extra_args)
return 0;
 }
 
+/* Parse integer from integer argument */
+static int
+parse_integer_arg(const char *key __rte_unused,
+   const char *value, void *extra_args)
+{
+   int i;
+   char *end;
+
+   errno = 0;
+
+   i = strtol(value, &end, 10);
+   if (*end != 0 || errno != 0 || i < 0 || i > LA12XX_MAX_MODEM) {
+   BBDEV_LA12XX_PMD_ERR("Supported Port IDS are 0 to %d",
+   LA12XX_MAX_MODEM - 1);
+   return -EINVAL;
+   }
+
+   *((uint32_t *)extra_args) = i;
+
+   return 0;
+}
+
 /* Parse parameters used to create device */
 static int
 parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
@@ -73,6 +97,16 @@ parse_bbdev_la12xx_params(struct bbdev_la12xx_params *params,
if (ret < 0)
goto exit;
 
+   ret = rte_kvargs_process(kvlist,
+   bbdev_la12xx_valid_params[1],
+   &parse_integer_arg,
+   ¶ms->modem_id);
+
+   if (params->modem_id >= LA12XX_MAX_MODEM) {
+   BBDEV_LA12XX_PMD_ERR("Invalid modem id, must be < %u",
+   LA12XX_MAX_MODEM);
+   goto exit;
+   }
}
 
 exit:
@@ -88,6 +122,7 @@ la12xx_bbdev_create(struct rte_vdev_device *vdev,
 {
struct rte_bbdev *bbdev;
const char *name = rte_vdev_device_name(vdev);
+   struct bbdev_la12xx_private *priv;
 
PMD_INIT_FUNC_TRACE();
 
@@ -103,6 +138,20 @@ la12xx_bbdev_create(struct rte_vdev_device *vdev,
return -ENOMEM;
}
 
+   priv = bbdev->data->dev_private;
+   priv->modem_id = init_params->modem_id;
+   /* if modem id is not configured */
+   if (priv->modem_id == -1)
+   priv->modem_id = bbdev->data->dev_id;
+
+   /* Reset Global variables */
+   priv->num_ldpc_enc_queues = 0;
+   priv->num_ldpc_dec_queues = 0;
+   priv->num_valid_queues = 0;
+   priv->max_nb_queues = init_params->queues_num;
+
+   BBDEV_LA12XX_PMD_INFO("Setting Up %s: DevId=%d, ModemId=%d",
+   name, bbdev->data->dev_id, priv->modem_id);
bbdev->dev_ops = NULL;
bbdev->device = &vdev->device;
bbdev->data->socket_id = 0;
@@ -122,7 +171,7 @@ static int
 la12xx_bbdev_probe(struct rte_vdev_device *vdev)
 {
struct bbdev_la12xx_params init_params = {
-   RTE_BBDEV_DEFAULT_MAX_NB_QUEUES
+   RTE_BBDEV_DEFAULT_MAX_NB_QUEUES, -1,
};
const char *name;
const char *input_args;
@@ -174,4 +223,5 @@ static struct rte_vdev_driver bbdev_la12xx_pmd_drv = {
 
 RTE_PMD_REGISTER_VDEV(DRIVER_NAME, bbdev_la12xx_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
-   BBDEV_LA12XX_MAX_NB_QUEUES_ARG"=");
+   BBDEV_LA12XX_MAX_NB_QUEUES_ARG"="
+   BBDEV_LA12XX_VDEV_MODEM_ID_ARG "= ");
diff --git a/drivers/baseband/la12xx/bbdev_la12xx.h 
b/drivers/baseband/la12xx/bbdev_la12xx.h
new file mode 100644
index 00..5228502331
--- /dev/null
+++ b/drivers/baseband/la12xx/bbdev_la12xx.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: BSD-3-Cl

[dpdk-dev] [PATCH v2 4/8] baseband/la12xx: add queue and modem config support

2021-04-10 Thread Hemant Agrawal
This patch add support for connecting with modem
and creating the ipc channel as queues with modem
for the exchange of data.

Signed-off-by: Nipun Gupta 
Signed-off-by: Hemant Agrawal 
---
 drivers/baseband/la12xx/bbdev_la12xx.c | 566 -
 drivers/baseband/la12xx/bbdev_la12xx.h |   5 +-
 drivers/baseband/la12xx/bbdev_la12xx_ipc.h | 180 +++
 3 files changed, 748 insertions(+), 3 deletions(-)

diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c 
b/drivers/baseband/la12xx/bbdev_la12xx.c
index 3837e43d8e..7347106866 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -3,6 +3,11 @@
  */
 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -31,11 +36,563 @@ struct bbdev_la12xx_params {
 #define BBDEV_LA12XX_VDEV_MODEM_ID_ARG "modem"
 #define LA12XX_MAX_MODEM 4
 
+#define LA12XX_MAX_CORES   4
+#define BBDEV_LA12XX_LDPC_ENC_CORE 0
+#define BBDEV_LA12XX_LDPC_DEC_CORE 1
+
 static const char * const bbdev_la12xx_valid_params[] = {
BBDEV_LA12XX_MAX_NB_QUEUES_ARG,
BBDEV_LA12XX_VDEV_MODEM_ID_ARG,
 };
 
+static const struct rte_bbdev_op_cap bbdev_capabilities[] = {
+   {
+   .type   = RTE_BBDEV_OP_LDPC_ENC,
+   .cap.ldpc_enc = {
+   .capability_flags =
+   RTE_BBDEV_LDPC_CRC_24A_ATTACH |
+   RTE_BBDEV_LDPC_CRC_24B_ATTACH,
+   .num_buffers_src =
+   RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
+   .num_buffers_dst =
+   RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
+   }
+   },
+   {
+   .type   = RTE_BBDEV_OP_LDPC_DEC,
+   .cap.ldpc_dec = {
+   .capability_flags =
+   RTE_BBDEV_LDPC_CRC_TYPE_24A_CHECK |
+   RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK |
+   RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP,
+   .num_buffers_src =
+   RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
+   .num_buffers_hard_out =
+   RTE_BBDEV_LDPC_MAX_CODE_BLOCKS,
+   }
+   },
+   RTE_BBDEV_END_OF_CAPABILITIES_LIST()
+};
+
+static struct rte_bbdev_queue_conf default_queue_conf = {
+   .queue_size = MAX_CHANNEL_DEPTH,
+};
+
+/* Get device info */
+static void
+la12xx_info_get(struct rte_bbdev *dev,
+   struct rte_bbdev_driver_info *dev_info)
+{
+   PMD_INIT_FUNC_TRACE();
+
+   dev_info->driver_name = RTE_STR(DRIVER_NAME);
+   dev_info->max_num_queues = LA12XX_MAX_QUEUES;
+   dev_info->queue_size_lim = MAX_CHANNEL_DEPTH;
+   dev_info->hardware_accelerated = true;
+   dev_info->max_dl_queue_priority = 0;
+   dev_info->max_ul_queue_priority = 0;
+   dev_info->default_queue_conf = default_queue_conf;
+   dev_info->capabilities = bbdev_capabilities;
+   dev_info->cpu_flag_reqs = NULL;
+   dev_info->min_alignment = 64;
+
+   BBDEV_LA12XX_PMD_DEBUG("got device info from %u", dev->data->dev_id);
+}
+
+/* Release queue */
+static int
+la12xx_queue_release(struct rte_bbdev *dev, uint16_t q_id)
+{
+   RTE_SET_USED(dev);
+   RTE_SET_USED(q_id);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* TODO: Implement */
+
+   return 0;
+}
+
+#define HUGEPG_OFFSET(A) \
+   ((uint64_t) ((unsigned long) (A) \
+   - ((uint64_t)ipc_priv->hugepg_start.host_vaddr)))
+
+static int ipc_queue_configure(uint32_t channel_id,
+   ipc_t instance, struct bbdev_la12xx_q_priv *q_priv)
+{
+   ipc_userspace_t *ipc_priv = (ipc_userspace_t *)instance;
+   ipc_instance_t *ipc_instance = ipc_priv->instance;
+   ipc_ch_t *ch;
+   void *vaddr;
+   uint32_t i = 0;
+   uint32_t msg_size = sizeof(struct bbdev_ipc_enqueue_op);
+
+   PMD_INIT_FUNC_TRACE();
+
+   BBDEV_LA12XX_PMD_DEBUG("%x %p", ipc_instance->initialized,
+   ipc_priv->instance);
+   ch = &(ipc_instance->ch_list[channel_id]);
+
+   BBDEV_LA12XX_PMD_DEBUG("channel: %u, depth: %u, msg size: %u",
+   channel_id, q_priv->queue_size, msg_size);
+
+   /* Start init of channel */
+   ch->md.ring_size = rte_cpu_to_be_32(q_priv->queue_size);
+   ch->md.pi = 0;
+   ch->md.ci = 0;
+   ch->md.msg_size = msg_size;
+   for (i = 0; i < q_priv->queue_size; i++) {
+   vaddr = rte_malloc(NULL, msg_size, RTE_CACHE_LINE_SIZE);
+   if (!vaddr)
+   return IPC_HOST_BUF_ALLOC_FAIL;
+   /* Only offset now */
+   ch->bd[i].modem_ptr =
+   rte_cpu_to_be_32(HUGEPG_OFFSET(vaddr));
+   ch->bd[i].host_virt_l = lower_32_bits(vaddr);
+   ch->bd[i].host_virt_h = up

[dpdk-dev] [PATCH v2 5/8] baseband/la12xx: add enqueue and dequeue support

2021-04-10 Thread Hemant Agrawal
Add support for enqueue and dequeue the LDPC enc/dec
from the modem device.

Signed-off-by: Nipun Gupta 
Signed-off-by: Hemant Agrawal 
---
 drivers/baseband/la12xx/bbdev_la12xx.c | 397 -
 drivers/baseband/la12xx/bbdev_la12xx_ipc.h |  37 ++
 2 files changed, 430 insertions(+), 4 deletions(-)

diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c 
b/drivers/baseband/la12xx/bbdev_la12xx.c
index 7347106866..0ff4871efe 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -117,6 +117,10 @@ la12xx_queue_release(struct rte_bbdev *dev, uint16_t q_id)
((uint64_t) ((unsigned long) (A) \
- ((uint64_t)ipc_priv->hugepg_start.host_vaddr)))
 
+#define MODEM_P2V(A) \
+   ((uint64_t) ((unsigned long) (A) \
+   + (unsigned long)(ipc_priv->peb_start.host_vaddr)))
+
 static int ipc_queue_configure(uint32_t channel_id,
ipc_t instance, struct bbdev_la12xx_q_priv *q_priv)
 {
@@ -345,6 +349,387 @@ static const struct rte_bbdev_ops pmd_ops = {
.queue_release = la12xx_queue_release,
.start = la12xx_start
 };
+
+static int
+fill_feca_desc_enc(struct bbdev_la12xx_q_priv *q_priv,
+  struct bbdev_ipc_dequeue_op *bbdev_ipc_op,
+  struct rte_bbdev_enc_op *bbdev_enc_op,
+  struct rte_bbdev_op_data *in_op_data)
+{
+   RTE_SET_USED(q_priv);
+   RTE_SET_USED(bbdev_ipc_op);
+   RTE_SET_USED(bbdev_enc_op);
+   RTE_SET_USED(in_op_data);
+
+   return 0;
+}
+
+static int
+fill_feca_desc_dec(struct bbdev_la12xx_q_priv *q_priv,
+  struct bbdev_ipc_dequeue_op *bbdev_ipc_op,
+  struct rte_bbdev_dec_op *bbdev_dec_op,
+  struct rte_bbdev_op_data *out_op_data)
+{
+   RTE_SET_USED(q_priv);
+   RTE_SET_USED(bbdev_ipc_op);
+   RTE_SET_USED(bbdev_dec_op);
+   RTE_SET_USED(out_op_data);
+
+   return 0;
+}
+
+static inline int
+is_bd_ring_full(uint32_t ci, uint32_t ci_flag,
+   uint32_t pi, uint32_t pi_flag)
+{
+   if (pi == ci) {
+   if (pi_flag != ci_flag)
+   return 1; /* Ring is Full */
+   }
+   return 0;
+}
+
+static inline int
+prepare_ldpc_enc_op(struct rte_bbdev_enc_op *bbdev_enc_op,
+   struct bbdev_ipc_dequeue_op *bbdev_ipc_op,
+   struct bbdev_la12xx_q_priv *q_priv,
+   struct rte_bbdev_op_data *in_op_data,
+   struct rte_bbdev_op_data *out_op_data)
+{
+   struct rte_bbdev_op_ldpc_enc *ldpc_enc = &bbdev_enc_op->ldpc_enc;
+   uint32_t total_out_bits;
+   int ret;
+
+   total_out_bits = (ldpc_enc->tb_params.cab *
+   ldpc_enc->tb_params.ea) + (ldpc_enc->tb_params.c -
+   ldpc_enc->tb_params.cab) * ldpc_enc->tb_params.eb;
+
+   ldpc_enc->output.length = (total_out_bits + 7)/8;
+
+   ret = fill_feca_desc_enc(q_priv, bbdev_ipc_op,
+bbdev_enc_op, in_op_data);
+   if (ret) {
+   BBDEV_LA12XX_PMD_ERR(
+   "fill_feca_desc_enc failed, ret: %d", ret);
+   return ret;
+   }
+
+   rte_pktmbuf_append(out_op_data->data, ldpc_enc->output.length);
+
+   return 0;
+}
+
+static inline int
+prepare_ldpc_dec_op(struct rte_bbdev_dec_op *bbdev_dec_op,
+   struct bbdev_ipc_dequeue_op *bbdev_ipc_op,
+   struct bbdev_la12xx_q_priv *q_priv,
+   struct rte_bbdev_op_data *out_op_data)
+{
+   struct rte_bbdev_op_ldpc_dec *ldpc_dec = &bbdev_dec_op->ldpc_dec;
+   uint32_t total_out_bits;
+   uint32_t num_code_blocks = 0;
+   uint16_t sys_cols;
+   int ret;
+
+   sys_cols = (ldpc_dec->basegraph == 1) ? 22 : 10;
+   if (ldpc_dec->tb_params.c == 1) {
+   total_out_bits = ((sys_cols * ldpc_dec->z_c) -
+   ldpc_dec->n_filler);
+   /* 5G-NR protocol uses 16 bit CRC when output packet
+* size <= 3824 (bits). Otherwise 24 bit CRC is used.
+* Adjust the output bits accordingly
+*/
+   if (total_out_bits - 16 <= 3824)
+   total_out_bits -= 16;
+   else
+   total_out_bits -= 24;
+   ldpc_dec->hard_output.length = (total_out_bits / 8);
+   } else {
+   total_out_bits = (((sys_cols * ldpc_dec->z_c) -
+   ldpc_dec->n_filler - 24) *
+   ldpc_dec->tb_params.c);
+   ldpc_dec->hard_output.length = (total_out_bits / 8) - 3;
+   }
+
+   num_code_blocks = ldpc_dec->tb_params.c;
+
+   bbdev_ipc_op->num_code_blocks = rte_cpu_to_be_32(num_code_blocks);
+
+   ret = fill_feca_desc_dec(q_priv, bbdev_ipc_op,
+bbdev_dec_op, out_op_data);
+   if (ret) {
+   BBDEV_LA12XX_PMD_ERR("fi

[dpdk-dev] [PATCH v2 6/8] baseband/la12xx: add documentation support

2021-04-10 Thread Hemant Agrawal
This patch add documentation for LA12xx PMD.

Signed-off-by: Nipun Gupta 
Signed-off-by: Hemant Agrawal 
---
 MAINTAINERS|   9 ++
 doc/guides/bbdevs/features/la12xx.ini  |  14 +++
 doc/guides/bbdevs/index.rst|   1 +
 doc/guides/bbdevs/la12xx.rst   | 139 +
 doc/guides/rel_notes/release_21_05.rst |   5 +
 5 files changed, 168 insertions(+)
 create mode 100644 doc/guides/bbdevs/features/la12xx.ini
 create mode 100644 doc/guides/bbdevs/la12xx.rst

diff --git a/MAINTAINERS b/MAINTAINERS
index e746ef1d32..24081fceb3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1289,6 +1289,15 @@ F: doc/guides/rawdevs/ntb.rst
 F: examples/ntb/
 F: doc/guides/sample_app_ug/ntb.rst
 
+Baseband Drivers
+---
+
+NXP LA12xx
+M: Hemant Agrawal 
+M: Nipun Gupta 
+F: drivers/baseband/la12xx/
+F: doc/guides/bbdevs/la12xx.rst
+F: doc/guides/bbdevs/features/la12xx.ini
 
 Packet processing
 -
diff --git a/doc/guides/bbdevs/features/la12xx.ini 
b/doc/guides/bbdevs/features/la12xx.ini
new file mode 100644
index 00..979d9dd224
--- /dev/null
+++ b/doc/guides/bbdevs/features/la12xx.ini
@@ -0,0 +1,14 @@
+;
+; Supported features of the 'la12xx' bbdev driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Turbo Decoder (4G) = N
+Turbo Encoder (4G) = N
+LDPC Decoder (5G)  = Y
+LDPC Encoder (5G)  = Y
+LLR/HARQ Compression   = N
+External DDR Access= Y
+HW Accelerated = Y
+BBDEV API  = Y
diff --git a/doc/guides/bbdevs/index.rst b/doc/guides/bbdevs/index.rst
index 4445cbd1b0..cedd706fa6 100644
--- a/doc/guides/bbdevs/index.rst
+++ b/doc/guides/bbdevs/index.rst
@@ -14,3 +14,4 @@ Baseband Device Drivers
 fpga_lte_fec
 fpga_5gnr_fec
 acc100
+la12xx
diff --git a/doc/guides/bbdevs/la12xx.rst b/doc/guides/bbdevs/la12xx.rst
new file mode 100644
index 00..1cadd6f337
--- /dev/null
+++ b/doc/guides/bbdevs/la12xx.rst
@@ -0,0 +1,139 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright 2021 NXP
+
+NXP LA12xx Poll Mode Driver
+===
+
+The BBDEV LA12xx poll mode driver (PMD) supports an implementation for
+offloading High Phy processing functions like LDPC Encode / Decode 5GNR 
wireless
+acceleration function, using PCI based LA12xx Software defined radio.
+
+More information can be found at `NXP Official Website
+`_.
+
+Features
+
+
+LA12xx PMD supports the following features:
+
+- LDPC Encode in the DL
+- LDPC Decode in the UL
+- Maximum of 8 UL queues
+- Maximum of 8 DL queues
+- PCIe Gen-3 x8 Interface
+- MSI-X
+
+LA12xx PMD supports the following BBDEV capabilities:
+
+* For the LDPC encode operation:
+   - ``RTE_BBDEV_LDPC_CRC_24B_ATTACH`` :  set to attach CRC24B to CB(s)
+   - ``RTE_BBDEV_LDPC_RATE_MATCH`` :  if set then do not do Rate Match bypass
+
+* For the LDPC decode operation:
+   - ``RTE_BBDEV_LDPC_CRC_TYPE_24B_CHECK`` :  check CRC24B from CB(s)
+   - ``RTE_BBDEV_LDPC_CRC_TYPE_24B_DROP`` :  drops CRC24B bits appended while 
decoding
+   - ``RTE_BBDEV_LDPC_DEC_SCATTER_GATHER`` :  supports scatter-gather for 
input/output data
+
+Installation
+
+
+Section 3 of the DPDK manual provides instructions on installing and compiling 
DPDK.
+
+DPDK requires hugepages to be configured as detailed in section 2 of the DPDK 
manual.
+
+Initialization
+--
+
+The device can be listed on the host console with:
+
+
+Use the following lspci command to get the multiple LA12xx processor ids. The
+device ID of the LA12xx baseband processor is "1c30".
+
+.. code-block:: console
+
+  sudo lspci -nn
+
+...
+0001:01:00.0 Power PC [0b20]: Freescale Semiconductor Inc Device [1957:1c30] (
+rev 10)
+...
+0002:01:00.0 Power PC [0b20]: Freescale Semiconductor Inc Device [1957:1c30] (
+rev 10)
+
+
+Prerequisites
+-
+
+Currently supported by DPDK:
+
+- NXP LA1224 BSP **1.0+**.
+- NXP LA1224 PCIe Modem card connected to ARM host.
+
+- Follow the DPDK :ref:`Getting Started Guide for Linux ` to setup 
the basic DPDK environment.
+
+* Use dev arg option ``modem=0`` to identify the modem instance for a given
+  device. This is required only if more than 1 modem cards are attached to 
host.
+  this is optional and the default value is 0.
+  e.g. ``--vdev=baseband_la12xx,modem=0``
+
+* Use dev arg option ``max_nb_queues=x`` to specify the maximum number of 
queues
+  to be used for communication with offload device i.e. modem. default is 16.
+  e.g. ``--vdev=baseband_la12xx,max_nb_queues=4``
+
+Enabling logs
+-
+
+For enabling logs, use the following EAL parameter:
+
+.. code-block:: console
+
+   ./your_bbdev_application  --log-level=la12xx:
+
+Using ``bb.la12xx`` as log matching criteria, all Baseband PMD logs can be
+ena

[dpdk-dev] [PATCH v2 7/8] app/bbdev: add parameter to take input in network order

2021-04-10 Thread Hemant Agrawal
From: Nipun Gupta 

Test bbdev application is reading the input and output from the
test vector files in the same endianness which is of the system.
This patch adds an option to provide data in the network order
i.e. big endian format

Signed-off-by: Nipun Gupta 
---
 app/test-bbdev/test_bbdev_vector.c | 18 --
 app/test-bbdev/test_bbdev_vector.h |  2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/app/test-bbdev/test_bbdev_vector.c 
b/app/test-bbdev/test_bbdev_vector.c
index 50d1da00f7..fe04bd6b95 100644
--- a/app/test-bbdev/test_bbdev_vector.c
+++ b/app/test-bbdev/test_bbdev_vector.c
@@ -53,7 +53,8 @@ starts_with(const char *str, const char *pre)
 
 /* tokenization test values separated by a comma */
 static int
-parse_values(char *tokens, uint32_t **data, uint32_t *data_length)
+parse_values(char *tokens, uint32_t **data, uint32_t *data_length,
+int network_order)
 {
uint32_t n_tokens = 0;
uint32_t data_size = 32;
@@ -94,6 +95,14 @@ parse_values(char *tokens, uint32_t **data, uint32_t 
*data_length)
}
 
*data_length = *data_length + (strlen(tok) - strlen("0x"))/2;
+   if (network_order) {
+   if ((strlen(tok) - strlen("0x"))/2 == 4)
+   values[n_tokens] =
+   rte_cpu_to_be_32(values[n_tokens]);
+   else if ((strlen(tok) - strlen("0x"))/2 == 2)
+   values[n_tokens] =
+   rte_cpu_to_be_16(values[n_tokens]);
+   }
 
tok = strtok(NULL, VALUE_DELIMITER);
if (tok == NULL)
@@ -416,7 +425,8 @@ parse_data_entry(const char *key_token, char *token,
/* Clear new op data struct */
memset(op_data + *nb_ops, 0, sizeof(struct op_data_buf));
 
-   ret = parse_values(token, &data, &data_length);
+   ret = parse_values(token, &data, &data_length,
+   vector->network_order);
if (!ret) {
op_data[*nb_ops].addr = data;
op_data[*nb_ops].length = data_length;
@@ -728,6 +738,10 @@ parse_ldpc_encoder_params(const char *key_token, char 
*token,
ret = parse_expected_status(token, &status, vector->op_type);
if (!ret)
vector->expected_status = status;
+   } else if (!strcmp(key_token, "network_order")) {
+   vector->mask |= TEST_BBDEV_VF_NETWORK_ORDER;
+   vector->network_order = (uint8_t) strtoul(token, &err, 0);
+   ret = ((err == NULL) || (*err != '\0')) ? -1 : 0;
} else {
printf("Not valid ldpc enc key: '%s'\n", key_token);
return -1;
diff --git a/app/test-bbdev/test_bbdev_vector.h 
b/app/test-bbdev/test_bbdev_vector.h
index 4e5dbf5d50..aa53f0bb0d 100644
--- a/app/test-bbdev/test_bbdev_vector.h
+++ b/app/test-bbdev/test_bbdev_vector.h
@@ -35,6 +35,7 @@ enum {
TEST_BBDEV_VF_CODE_BLOCK_MODE = (1ULL << 23),
TEST_BBDEV_VF_OP_FLAGS = (1ULL << 24),
TEST_BBDEV_VF_EXPECTED_STATUS = (1ULL << 25),
+   TEST_BBDEV_VF_NETWORK_ORDER = (1ULL << 26),
 };
 
 enum op_data_type {
@@ -60,6 +61,7 @@ struct test_bbdev_vector {
enum rte_bbdev_op_type op_type;
int expected_status;
int mask;
+   int network_order;
union {
struct rte_bbdev_op_turbo_dec turbo_dec;
struct rte_bbdev_op_turbo_enc turbo_enc;
-- 
2.17.1



[dpdk-dev] [PATCH v2 8/8] app/bbdev: add test vectors for transport blocks

2021-04-10 Thread Hemant Agrawal
From: Nipun Gupta 

This patch adds two test vectors for transport block in network byte
order:
- LDPC encode for Transport Block
- LDPC decode for Transport block

Signed-off-by: Nipun Gupta 
---
 app/test-bbdev/test_vectors/ldpc_dec_tb.data | 362 ++
 app/test-bbdev/test_vectors/ldpc_enc_tb.data | 482 +++
 2 files changed, 844 insertions(+)
 create mode 100644 app/test-bbdev/test_vectors/ldpc_dec_tb.data
 create mode 100644 app/test-bbdev/test_vectors/ldpc_enc_tb.data

diff --git a/app/test-bbdev/test_vectors/ldpc_dec_tb.data 
b/app/test-bbdev/test_vectors/ldpc_dec_tb.data
new file mode 100644
index 00..76b5105966
--- /dev/null
+++ b/app/test-bbdev/test_vectors/ldpc_dec_tb.data
@@ -0,0 +1,362 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2020 NXP
+
+op_type =
+RTE_BBDEV_OP_LDPC_DEC
+
+network_order =
+1
+
+input0 =
+0x817f7f81, 0x81817f7f, 0x7f7f8181, 0x81817f81, 0x8181817f, 0x7f817f81, 
0x7f817f81, 0x7f817f7f,
+0x7f818181, 0x7f817f7f, 0x81817f81, 0x817f7f7f, 0x81817f81, 0x81818181, 
0x7f818181, 0x81818181,
+0x7f7f7f7f, 0x81818181, 0x7f81817f, 0x817f7f7f, 0x81817f7f, 0x817f817f, 
0x81817f81, 0x7f817f81,
+0x7f7f7f7f, 0x7f7f8181, 0x7f818181, 0x81817f81, 0x7f818181, 0x817f8181, 
0x817f8181, 0x7f7f7f7f,
+0x7f7f817f, 0x817f8181, 0x8181817f, 0x817f7f81, 0x7f818181, 0x81817f7f, 
0x7f81817f, 0x7f7f7f7f,
+0x7f817f7f, 0x81818181, 0x7f81817f, 0x7f7f817f, 0x8181817f, 0x8181817f, 
0x817f8181, 0x7f817f81,
+0x7f7f8181, 0x7f7f7f7f, 0x81817f81, 0x7f7f7f81, 0x7f81817f, 0x81817f7f, 
0x81817f7f, 0x7f7f8181,
+0x817f817f, 0x7f817f7f, 0x7f7f7f7f, 0x817f8181, 0x81818181, 0x7f7f7f7f, 
0x7f7f8181, 0x7f7f7f7f,
+0x7f817f81, 0x7f81817f, 0x7f818181, 0x817f817f, 0x81817f7f, 0x7f7f7f81, 
0x7f7f7f81, 0x7f817f81,
+0x817f7f7f, 0x7f817f7f, 0x817f7f81, 0x7f7f7f7f, 0x7f817f81, 0x81817f7f, 
0x7f817f7f, 0x7f7f7f81,
+0x7f817f7f, 0x7f7f7f81, 0x7f817f7f, 0x7f81817f, 0x817f7f81, 0x7f7f7f7f, 
0x81818181, 0x7f7f8181,
+0x817f7f7f, 0x817f7f81, 0x81817f81, 0x7f817f81, 0x7f818181, 0x817f7f81, 
0x7f817f7f, 0x7f818181,
+0x7f7f8181, 0x81817f81, 0x7f7f8181, 0x8181817f, 0x8181817f, 0x817f7f81, 
0x8181817f, 0x7f7f817f,
+0x7f817f81, 0x817f7f7f, 0x81818181, 0x817f7f7f, 0x81817f81, 0x7f7f7f7f, 
0x8181817f, 0x7f81817f,
+0x8181817f, 0x7f818181, 0x7f817f7f, 0x817f7f7f, 0x7f817f7f, 0x817f8181, 
0x7f7f8181, 0x7f81817f,
+0x7f7f7f7f, 0x7f7f817f, 0x81818181, 0x7f818181, 0x81818181, 0x7f7f817f, 
0x817f817f, 0x817f817f,
+0x7f7f7f81, 0x7f7f817f, 0x7f7f7f7f, 0x7f7f8181, 0x7f817f81, 0x7f7f7f81, 
0x81817f7f, 0x7f817f81,
+0x817f817f, 0x7f7f7f7f, 0x81817f81, 0x817f8181, 0x7f817f7f, 0x7f81817f, 
0x7f818181, 0x817f8181,
+0x7f81817f, 0x7f818181, 0x817f817f, 0x8181817f, 0x817f817f, 0x81817f7f, 
0x817f817f, 0x7f81817f,
+0x8181817f, 0x7f817f81, 0x7f817f7f, 0x81817f81, 0x7f81817f, 0x817f8181, 
0x7f818181, 0x7f7f7f7f,
+0x817f8181, 0x7f817f7f, 0x7f7f8181, 0x817f8181, 0x7f7f7f81, 0x817f8181, 
0x81817f7f, 0x817f7f7f,
+0x81817f81, 0x81818181, 0x7f818181, 0x7f818181, 0x8181817f, 0x7f7f8181, 
0x7f7f817f, 0x7f7f8181,
+0x81817f7f, 0x7f817f7f, 0x7f7f817f, 0x81818181, 0x7f817f81, 0x817f8181, 
0x7f81817f, 0x7f7f7f7f,
+0x7f7f8181, 0x817f7f81, 0x7f7f8181, 0x817f817f, 0x7f818181, 0x7f7f8181, 
0x7f7f7f7f, 0x8181817f,
+0x817f7f81, 0x7f7f7f81, 0x817f7f81, 0x8181817f, 0x817f8181, 0x7f817f7f, 
0x7f7f7f81, 0x817f817f,
+0x81817f7f, 0x817f8181, 0x7f7f7f81, 0x7f81817f, 0x7f7f8181, 0x7f817f7f, 
0x817f8181, 0x7f7f7f81,
+0x8181817f, 0x817f8181, 0x7f817f7f, 0x817f7f81, 0x7f818181, 0x7f7f7f81, 
0x81817f7f, 0x817f8181,
+0x7f7f817f, 0x7f81817f, 0x817f7f81, 0x7f7f7f81, 0x7f81817f, 0x817f8181, 
0x81818181, 0x817f817f,
+0x7f81817f, 0x817f8181, 0x7f817f81, 0x7f817f7f, 0x7f81817f, 0x7f7f817f, 
0x7f81817f, 0x81817f81,
+0x817f817f, 0x81818181, 0x7f817f7f, 0x817f8181, 0x817f7f7f, 0x7f7f7f81, 
0x817f8181, 0x7f818181,
+0x7f7f7f7f, 0x817f8181, 0x817f7f7f, 0x7f817f7f, 0x81817f7f, 0x81818181, 
0x7f7f817f, 0x8181817f,
+0x8181817f, 0x8181817f, 0x81817f7f, 0x7f817f81, 0x817f8181, 0x8181817f, 
0x7f81817f, 0x7f817f7f,
+0x7f817f81, 0x81818181, 0x8181817f, 0x7f81817f, 0x81818181, 0x7f7f7f81, 
0x7f818181, 0x7f7f7f81,
+0x7f7f7f7f, 0x7f7f7f7f, 0x817f7f7f, 0x8181817f, 0x8181817f, 0x817f7f7f, 
0x7f817f7f, 0x817f8181,
+0x817f7f7f, 0x817f8181, 0x7f7f817f, 0x817f817f, 0x817f8181, 0x81817f81, 
0x81817f81, 0x81817f7f,
+0x7f81817f, 0x7f7f7f7f, 0x81817f81, 0x7f7f8181, 0x7f817f7f, 0x81818181, 
0x7f7f817f, 0x81817f7f,
+0x817f817f, 0x7f817f7f, 0x7f7f817f, 0x7f7f7f81, 0x817f7f81, 0x7f7f7f7f, 
0x817f8181, 0x7f818181,
+0x817f8181, 0x7f817f81, 0x7f7f7f7f, 0x8181817f, 0x81818181, 0x81817f7f, 
0x817f7f7f, 0x817f8181,
+0x817f8181, 0x7f818181, 0x81818181, 0x7f818181, 0x7f817f7f, 0x81817f81, 
0x817f7f7f, 0x817f7f81,
+0x817f7f81, 0x81817f81, 0x8181817f, 0x81817f81, 0x81817f81, 0x817f8181, 
0x81818181, 0x81818181,
+0x81818181, 0x817f817f, 0x8181817f, 0x8181817f, 0x81817f81, 0x817f7f81, 
0x817f7f81, 0x817f7f7f,
+0x7f7f8181, 0x7f7f817f, 0x7f7f8181, 0x7f817f7f, 0x7f818181, 0x81817f81, 
0x7f817f81, 0x817f7f81,
+0x7f817

[dpdk-dev] [PATCH] eal/windows: fix pthreads macros return values

2021-04-10 Thread Tal Shnaiderman
The macro definitions of the following pthread functions
return incorrect values from the inner function return code.

while pthread_barrier_init, pthread_barrier_destroy and
pthread_cancel return 0 in a case of success and non zero (errno) value
otherwise the shimming functions InitializeSynchronizationBarrier,
DeleteSynchronizationBarrier and TerminateThread return FALSE (0)
in a case of failure and TRUE(1) in a case of success.

This issue was undetected as none of the functions return codes was
checked until such check was added in commit 34cc55cce6b1 ("eal: fix
race in control thread creation") exposing the issue by failing
pthread_barrier_init and rte_eal_init on Windows as a result.

The fix aligned the return value of the 3 function with the expected
pthread API return values.

Fixes: e8428a9d89f1 ("eal/windows: add some basic functions and macros")
Fixes: 34cc55cce6b1 ("eal: fix race in control thread creation")
Cc: sta...@dpdk.org

Signed-off-by: Tal Shnaiderman 
---
 lib/librte_eal/windows/include/pthread.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/windows/include/pthread.h 
b/lib/librte_eal/windows/include/pthread.h
index 9aeab1fa70..1939b0121c 100644
--- a/lib/librte_eal/windows/include/pthread.h
+++ b/lib/librte_eal/windows/include/pthread.h
@@ -35,12 +35,12 @@ typedef CRITICAL_SECTION pthread_mutex_t;
 typedef SYNCHRONIZATION_BARRIER pthread_barrier_t;
 
 #define pthread_barrier_init(barrier, attr, count) \
-   InitializeSynchronizationBarrier(barrier, count, -1)
+   !InitializeSynchronizationBarrier(barrier, count, -1)
 #define pthread_barrier_wait(barrier) EnterSynchronizationBarrier(barrier, \
SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY)
 #define pthread_barrier_destroy(barrier) \
-   DeleteSynchronizationBarrier(barrier)
-#define pthread_cancel(thread) TerminateThread((HANDLE) thread, 0)
+   !DeleteSynchronizationBarrier(barrier)
+#define pthread_cancel(thread) !TerminateThread((HANDLE) thread, 0)
 
 /* pthread function overrides */
 #define pthread_self() \
-- 
2.16.1.windows.4



Re: [dpdk-dev] [PATCH v4 1/5] devargs: unify scratch buffer storage

2021-04-10 Thread Tal Shnaiderman
> Subject: [dpdk-dev] [PATCH v4 1/5] devargs: unify scratch buffer storage
> 
> In current design, legacy parser rte_devargs_parse() saved scratch buffer to
> devargs.args while new parser rte_devargs_layers_parse() saved to
> devargs.data. Code using devargs had to know the difference and cleaned up
> memory accordingly - error prone.
> 
> This patch unifies scratch buffer to data field, introduces
> rte_devargs_reset() function to wrap the memory clean up logic.
> 
> Signed-off-by: Xueming Li 
> Acked-by: Ray Kinsella 
> Reviewed-by: Gaetan Rivet 
> ---
>  app/test-pmd/config.c|  3 +-
>  app/test-pmd/testpmd.c   |  5 +--
>  drivers/bus/vdev/vdev.c  |  9 +++---
>  drivers/net/failsafe/failsafe_args.c |  3 +-
>  drivers/net/failsafe/failsafe_eal.c  |  2 +-
>  examples/multi_process/hotplug_mp/commands.c |  6 ++--
>  lib/librte_eal/common/eal_common_dev.c   |  9 +++---
>  lib/librte_eal/common/eal_common_devargs.c   | 34 +++-
>  lib/librte_eal/common/hotplug_mp.c   |  6 ++--
>  lib/librte_eal/include/rte_devargs.h | 18 ---
>  lib/librte_eal/rte_eal_exports.def   |  1 +

rte_eal_exports.def was united with version.map and removed thus the 
modification above is unneeded.

>  lib/librte_eal/version.map   |  1 +
>  lib/librte_ethdev/rte_ethdev.c   |  8 ++---
>  13 files changed, 59 insertions(+), 46 deletions(-)


[dpdk-dev] [PATCH] common/mlx5: export all compiled functions on Windows

2021-04-10 Thread Tal Shnaiderman
The functions mlx5_devx_cmd_*, mlx5_mp_* and mlx5_memory_stat_dump are compiled
however some of them are marked with the WINDOWS_NO_EXPORT tag as they are not 
used.

removing the tag to leave only functions which are not compiled for Windows.

Signed-off-by: Tal Shnaiderman 
---
 drivers/common/mlx5/version.map | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map
index 8b196a41d2..4a0f5017ab 100644
--- a/drivers/common/mlx5/version.map
+++ b/drivers/common/mlx5/version.map
@@ -22,7 +22,7 @@ INTERNAL {
mlx5_devx_cmd_create_tir;
mlx5_devx_cmd_create_td;
mlx5_devx_cmd_create_tis;
-   mlx5_devx_cmd_create_virtio_q_counters; # WINDOWS_NO_EXPORT
+   mlx5_devx_cmd_create_virtio_q_counters;
mlx5_devx_cmd_create_virtq;
mlx5_devx_cmd_create_flow_hit_aso_obj;
mlx5_devx_cmd_create_geneve_tlv_option;
@@ -40,14 +40,14 @@ INTERNAL {
mlx5_devx_cmd_qp_query_tis_td;
mlx5_devx_cmd_query_hca_attr;
mlx5_devx_cmd_query_parse_samples;
-   mlx5_devx_cmd_query_virtio_q_counters; # WINDOWS_NO_EXPORT
+   mlx5_devx_cmd_query_virtio_q_counters;
mlx5_devx_cmd_query_virtq;
-   mlx5_devx_cmd_queue_counter_alloc; # WINDOWS_NO_EXPORT
-   mlx5_devx_cmd_queue_counter_query; # WINDOWS_NO_EXPORT
+   mlx5_devx_cmd_queue_counter_alloc;
+   mlx5_devx_cmd_queue_counter_query;
mlx5_devx_cmd_register_read;
-   mlx5_devx_cmd_wq_query; # WINDOWS_NO_EXPORT
+   mlx5_devx_cmd_wq_query;
mlx5_devx_get_out_command_status;
-   mlx5_devx_alloc_uar; # WINDOWS_NO_EXPORT
+   mlx5_devx_alloc_uar;
 
mlx5_devx_cq_create;
mlx5_devx_cq_destroy;
@@ -60,13 +60,13 @@ INTERNAL {
 
mlx5_glue;
 
-   mlx5_mp_init_primary; # WINDOWS_NO_EXPORT
-   mlx5_mp_uninit_primary; # WINDOWS_NO_EXPORT
-   mlx5_mp_init_secondary; # WINDOWS_NO_EXPORT
-   mlx5_mp_uninit_secondary; # WINDOWS_NO_EXPORT
-   mlx5_mp_req_mr_create; # WINDOWS_NO_EXPORT
+   mlx5_mp_init_primary;
+   mlx5_mp_uninit_primary;
+   mlx5_mp_init_secondary;
+   mlx5_mp_uninit_secondary;
+   mlx5_mp_req_mr_create;
mlx5_mp_req_queue_state_modify;
-   mlx5_mp_req_verbs_cmd_fd; # WINDOWS_NO_EXPORT
+   mlx5_mp_req_verbs_cmd_fd;
 
mlx5_mr_btree_init;
mlx5_mr_btree_free;
@@ -110,7 +110,7 @@ INTERNAL {
mlx5_translate_port_name; # WINDOWS_NO_EXPORT
 
mlx5_malloc_mem_select;
-   mlx5_memory_stat_dump; # WINDOWS_NO_EXPORT
+   mlx5_memory_stat_dump;
mlx5_malloc;
mlx5_realloc;
mlx5_free;
-- 
2.16.1.windows.4



Re: [dpdk-dev] [pull-request] dpdk-next-net-mrvl for-dpdk-main - 21.05 - PRE-RC1

2021-04-10 Thread Thomas Monjalon
09/04/2021 09:17, Jerin Jacob Kollanukkaran:
>   http://dpdk.org/git/next/dpdk-next-net-mrvl for-dpdk-main

Pulled, thanks.

Note: I tried to fix some acronyms which were missing uppercasing in titles.
Also "add support for" is shorter as "support".




[dpdk-dev] [PATCH v9 0/4] eal/windows: do not expose POSIX symbols

2021-04-10 Thread Dmitry Kozlyuk
On Windows, EAL contains two sets of functions and macros for POSIX
compatibility:  and a networking shim (socket headers).
The latter conflicts with system headers and should not exist.
Exposing the former from EAL can break consumer own POSIX compatibility
layer and is against standards in general. Hide these symbols from
external consumers, while keeping them available for DPDK code.

v9:
* Fix missing  include in rte_common_log.c.
  (This will happen again. Going to add a checkpatch test
   after this series is merged.)
v8:
* Drop rte_thread_sleep API, use rte_delay_us_sleep (Morten Brørup).

Dmitry Kozlyuk (4):
  eal/windows: hide asprintf() shim
  eal: make OS shims internal
  net: work around s_addr macro on Windows
  net: provide IP-related API on any OS

 drivers/bus/pci/private.h|  4 +-
 drivers/bus/vdev/vdev_private.h  |  2 +
 drivers/common/mlx5/mlx5_common.h|  1 +
 drivers/net/i40e/i40e_ethdev.c   |  1 +
 drivers/net/i40e/i40e_fdir.c |  1 +
 drivers/net/mlx5/mlx5.h  |  1 -
 drivers/net/mlx5/mlx5_flow.c |  4 +-
 drivers/net/mlx5/mlx5_flow.h |  3 +-
 drivers/net/mlx5/mlx5_mac.c  |  1 -
 examples/cmdline/commands.c  |  5 --
 examples/cmdline/parse_obj_list.c|  2 -
 lib/librte_cmdline/cmdline.c |  5 --
 lib/librte_cmdline/cmdline_os_windows.c  |  2 -
 lib/librte_cmdline/cmdline_parse.c   |  2 -
 lib/librte_cmdline/cmdline_parse_etheraddr.c |  6 --
 lib/librte_cmdline/cmdline_parse_ipaddr.c|  6 --
 lib/librte_cmdline/cmdline_parse_ipaddr.h|  2 +-
 lib/librte_cmdline/cmdline_private.h |  1 +
 lib/librte_cmdline/cmdline_socket.c  |  4 -
 lib/librte_eal/common/eal_common_config.c|  1 -
 lib/librte_eal/common/eal_common_errno.c |  4 +
 lib/librte_eal/common/eal_common_log.c   |  1 +
 lib/librte_eal/common/eal_common_options.c   |  2 +-
 lib/librte_eal/common/eal_common_timer.c |  4 +-
 lib/librte_eal/common/eal_internal_cfg.h |  1 +
 lib/librte_eal/common/eal_private.h  | 11 +++
 lib/librte_eal/freebsd/include/rte_os_shim.h | 14 +++
 lib/librte_eal/linux/include/rte_os_shim.h   | 14 +++
 lib/librte_eal/windows/eal.c | 30 +++
 lib/librte_eal/windows/eal_hugepages.c   |  1 -
 lib/librte_eal/windows/eal_lcore.c   |  1 -
 lib/librte_eal/windows/eal_memalloc.c|  1 -
 lib/librte_eal/windows/include/arpa/inet.h   | 30 ---
 lib/librte_eal/windows/include/netinet/in.h  | 38 
 lib/librte_eal/windows/include/netinet/ip.h  | 10 ---
 lib/librte_eal/windows/include/rte_os.h  | 92 +---
 lib/librte_eal/windows/include/rte_os_shim.h | 36 
 lib/librte_eal/windows/include/sys/socket.h  | 24 -
 lib/librte_ethdev/ethdev_private.h   |  2 +
 lib/librte_ethdev/rte_ethdev.c   | 12 +--
 lib/librte_ethdev/rte_ethdev_core.h  |  1 -
 lib/librte_kvargs/rte_kvargs.c   |  1 +
 lib/librte_net/rte_ether.h   | 26 --
 lib/librte_net/rte_ip.h  |  7 ++
 lib/librte_net/rte_net.c |  1 +
 45 files changed, 165 insertions(+), 253 deletions(-)
 create mode 100644 lib/librte_eal/freebsd/include/rte_os_shim.h
 create mode 100644 lib/librte_eal/linux/include/rte_os_shim.h
 delete mode 100644 lib/librte_eal/windows/include/arpa/inet.h
 delete mode 100644 lib/librte_eal/windows/include/netinet/in.h
 delete mode 100644 lib/librte_eal/windows/include/netinet/ip.h
 create mode 100644 lib/librte_eal/windows/include/rte_os_shim.h
 delete mode 100644 lib/librte_eal/windows/include/sys/socket.h

-- 
2.29.3



[dpdk-dev] [PATCH v9 1/4] eal/windows: hide asprintf() shim

2021-04-10 Thread Dmitry Kozlyuk
Make asprintf(3) implementation for Windows private to EAL, so that it's
hidden from external consumers. It is not exposed to internal consumers
either, because they don't need asprintf() and also because callers from
other modules would have no reliable way to free allocated memory.

Signed-off-by: Dmitry Kozlyuk 
Acked-by: Khoa To 
Acked-by: Nick Connolly 
---
 lib/librte_eal/common/eal_private.h | 11 +
 lib/librte_eal/windows/eal.c| 30 +
 lib/librte_eal/windows/include/rte_os.h | 30 -
 3 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index e3512111d9..64cf4e81c8 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -716,4 +716,15 @@ void __rte_thread_init(unsigned int lcore_id, rte_cpuset_t 
*cpuset);
  */
 void __rte_thread_uninit(void);
 
+/**
+ * asprintf(3) replacement for Windows.
+ */
+#ifdef RTE_EXEC_ENV_WINDOWS
+__rte_format_printf(2, 3)
+int eal_asprintf(char **buffer, const char *format, ...);
+
+#define asprintf(buffer, format, ...) \
+   eal_asprintf(buffer, format, ##__VA_ARGS__)
+#endif
+
 #endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c
index 41be20d89f..28c787c0b0 100644
--- a/lib/librte_eal/windows/eal.c
+++ b/lib/librte_eal/windows/eal.c
@@ -2,6 +2,8 @@
  * Copyright(c) 2019 Intel Corporation
  */
 
+#include 
+
 #include 
 #include 
 #include 
@@ -416,6 +418,34 @@ rte_eal_init(int argc, char **argv)
return fctret;
 }
 
+/* Don't use MinGW asprintf() to have identical code with all toolchains. */
+int
+eal_asprintf(char **buffer, const char *format, ...)
+{
+   int size, ret;
+   va_list arg;
+
+   va_start(arg, format);
+   size = vsnprintf(NULL, 0, format, arg);
+   va_end(arg);
+   if (size < 0)
+   return -1;
+   size++;
+
+   *buffer = malloc(size);
+   if (*buffer == NULL)
+   return -1;
+
+   va_start(arg, format);
+   ret = vsnprintf(*buffer, size, format, arg);
+   va_end(arg);
+   if (ret != size - 1) {
+   free(*buffer);
+   return -1;
+   }
+   return ret;
+}
+
 int
 rte_vfio_container_dma_map(__rte_unused int container_fd,
__rte_unused uint64_t vaddr,
diff --git a/lib/librte_eal/windows/include/rte_os.h 
b/lib/librte_eal/windows/include/rte_os.h
index f0512f20a6..1afe49f35e 100644
--- a/lib/librte_eal/windows/include/rte_os.h
+++ b/lib/librte_eal/windows/include/rte_os.h
@@ -10,7 +10,6 @@
  * which is not supported natively or named differently in Windows.
  */
 
-#include 
 #include 
 #include 
 #include 
@@ -71,34 +70,6 @@ extern "C" {
 typedef long long ssize_t;
 
 #ifndef RTE_TOOLCHAIN_GCC
-
-static inline int
-asprintf(char **buffer, const char *format, ...)
-{
-   int size, ret;
-   va_list arg;
-
-   va_start(arg, format);
-   size = vsnprintf(NULL, 0, format, arg);
-   va_end(arg);
-   if (size < 0)
-   return -1;
-   size++;
-
-   *buffer = (char *)malloc(size);
-   if (*buffer == NULL)
-   return -1;
-
-   va_start(arg, format);
-   ret = vsnprintf(*buffer, size, format, arg);
-   va_end(arg);
-   if (ret != size - 1) {
-   free(*buffer);
-   return -1;
-   }
-   return ret;
-}
-
 static inline const char *
 eal_strerror(int code)
 {
@@ -111,7 +82,6 @@ eal_strerror(int code)
 #ifndef strerror
 #define strerror eal_strerror
 #endif
-
 #endif /* RTE_TOOLCHAIN_GCC */
 
 #ifdef __cplusplus
-- 
2.29.3



[dpdk-dev] [PATCH v9 2/4] eal: make OS shims internal

2021-04-10 Thread Dmitry Kozlyuk
DPDK code often relies on functions and macros that are not standard C,
but are found on all platforms, even if by slightly different names.
Windows  provided macros or inline definitions for such symbols.
However, when placed in public header, these symbols were unnecessarily
exposed, breaking consumer POSIX compatibility code.

Move most of the shims to , a header to be used instead
of  by internal code. Include it in libraries and PMDs that
previously imported shims from . Directly replace shims that
were only used inside EAL:
* index -> strchr, rindex -> strrchr
* sleep -> rte_delay_us_sleep
* strerror_r -> strerror_s

Signed-off-by: Dmitry Kozlyuk 
---
 drivers/bus/pci/private.h|  4 +-
 drivers/bus/vdev/vdev_private.h  |  2 +
 drivers/common/mlx5/mlx5_common.h|  1 +
 drivers/net/i40e/i40e_ethdev.c   |  1 +
 lib/librte_cmdline/cmdline.c |  4 --
 lib/librte_cmdline/cmdline_os_windows.c  |  2 -
 lib/librte_cmdline/cmdline_private.h |  1 +
 lib/librte_cmdline/cmdline_socket.c  |  4 --
 lib/librte_eal/common/eal_common_config.c|  1 -
 lib/librte_eal/common/eal_common_errno.c |  4 ++
 lib/librte_eal/common/eal_common_log.c   |  1 +
 lib/librte_eal/common/eal_common_options.c   |  2 +-
 lib/librte_eal/common/eal_common_timer.c |  4 +-
 lib/librte_eal/common/eal_internal_cfg.h |  1 +
 lib/librte_eal/freebsd/include/rte_os_shim.h | 14 +
 lib/librte_eal/linux/include/rte_os_shim.h   | 14 +
 lib/librte_eal/windows/eal_hugepages.c   |  1 -
 lib/librte_eal/windows/eal_lcore.c   |  1 -
 lib/librte_eal/windows/eal_memalloc.c|  1 -
 lib/librte_eal/windows/include/rte_os.h  | 62 ++--
 lib/librte_eal/windows/include/rte_os_shim.h | 28 +
 lib/librte_ethdev/ethdev_private.h   |  2 +
 lib/librte_kvargs/rte_kvargs.c   |  1 +
 23 files changed, 80 insertions(+), 76 deletions(-)
 create mode 100644 lib/librte_eal/freebsd/include/rte_os_shim.h
 create mode 100644 lib/librte_eal/linux/include/rte_os_shim.h
 create mode 100644 lib/librte_eal/windows/include/rte_os_shim.h

diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h
index f566943f5e..4cd9d14ec7 100644
--- a/drivers/bus/pci/private.h
+++ b/drivers/bus/pci/private.h
@@ -7,8 +7,10 @@
 
 #include 
 #include 
-#include 
+
 #include 
+#include 
+#include 
 
 extern struct rte_pci_bus rte_pci_bus;
 
diff --git a/drivers/bus/vdev/vdev_private.h b/drivers/bus/vdev/vdev_private.h
index ba6dc48ff3..e683f5f133 100644
--- a/drivers/bus/vdev/vdev_private.h
+++ b/drivers/bus/vdev/vdev_private.h
@@ -5,6 +5,8 @@
 #ifndef _VDEV_PRIVATE_H_
 #define _VDEV_PRIVATE_H_
 
+#include 
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/drivers/common/mlx5/mlx5_common.h 
b/drivers/common/mlx5/mlx5_common.h
index 8eda6749b4..211e330178 100644
--- a/drivers/common/mlx5/mlx5_common.h
+++ b/drivers/common/mlx5/mlx5_common.h
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "mlx5_prm.h"
 #include "mlx5_devx_cmds.h"
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index fcf150e127..cf9e996ca5 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "i40e_logs.h"
 #include "base/i40e_prototype.h"
diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c
index 79ea5f98c8..49770869bb 100644
--- a/lib/librte_cmdline/cmdline.c
+++ b/lib/librte_cmdline/cmdline.c
@@ -18,10 +18,6 @@
 
 #include "cmdline_private.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-#define write _write
-#endif
-
 static void
 cmdline_valid_buffer(struct rdline *rdl, const char *buf,
 __rte_unused unsigned int size)
diff --git a/lib/librte_cmdline/cmdline_os_windows.c 
b/lib/librte_cmdline/cmdline_os_windows.c
index e9585c9eea..73ed9ba290 100644
--- a/lib/librte_cmdline/cmdline_os_windows.c
+++ b/lib/librte_cmdline/cmdline_os_windows.c
@@ -4,8 +4,6 @@
 
 #include 
 
-#include 
-
 #include "cmdline_private.h"
 
 /* Missing from some MinGW-w64 distributions. */
diff --git a/lib/librte_cmdline/cmdline_private.h 
b/lib/librte_cmdline/cmdline_private.h
index a8a6ee9e69..a87c45275c 100644
--- a/lib/librte_cmdline/cmdline_private.h
+++ b/lib/librte_cmdline/cmdline_private.h
@@ -8,6 +8,7 @@
 #include 
 
 #include 
+#include 
 #ifdef RTE_EXEC_ENV_WINDOWS
 #include 
 #endif
diff --git a/lib/librte_cmdline/cmdline_socket.c 
b/lib/librte_cmdline/cmdline_socket.c
index 0fe1497008..998e8ade25 100644
--- a/lib/librte_cmdline/cmdline_socket.c
+++ b/lib/librte_cmdline/cmdline_socket.c
@@ -16,10 +16,6 @@
 #include "cmdline_private.h"
 #include "cmdline_socket.h"
 
-#ifdef RTE_EXEC_ENV_WINDOWS
-#define open _open
-#endif
-
 struct cmdline *
 cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char 
*path)
 {
diff --git a/lib/librte_eal/common/eal_common_config.c 
b

[dpdk-dev] [PATCH v9 3/4] net: work around s_addr macro on Windows

2021-04-10 Thread Dmitry Kozlyuk
Windows Sockets headers contain `#define s_addr S_un.S_addr`, which
conflicts with definition of `s_addr` field of `struct rte_ether_hdr`.
Prieviously `s_addr` was undefined in , which had been
breaking access to `s_addr` field of `struct in_addr`, so some DPDK
and Windows headers could not be included in one file.

Renaming of `struct rte_ether_hdr` is planned:
https://mails.dpdk.org/archives/dev/2021-March/201444.html

Temporarily disable `s_addr` macro around `struct rte_ether_hdr`
definition to avoid conflict. Place source MAC address in both `s_addr`
and `S_un.S_addr` fields, so that access works either directly or
through the macro as defined in Windows headers.

Signed-off-by: Dmitry Kozlyuk 
Acked-by: Ranjit Menon 
Acked-by: Olivier Matz 
---
 lib/librte_net/rte_ether.h | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h
index 060b63fc9b..a303c24a8c 100644
--- a/lib/librte_net/rte_ether.h
+++ b/lib/librte_net/rte_ether.h
@@ -23,10 +23,6 @@ extern "C" {
 #include 
 #include 
 
-#ifdef RTE_EXEC_ENV_WINDOWS /* Workaround conflict with rte_ether_hdr. */
-#undef s_addr /* Defined in winsock2.h included in windows.h. */
-#endif
-
 #define RTE_ETHER_ADDR_LEN  6 /**< Length of Ethernet address. */
 #define RTE_ETHER_TYPE_LEN  2 /**< Length of Ethernet type field. */
 #define RTE_ETHER_CRC_LEN   4 /**< Length of Ethernet CRC. */
@@ -257,16 +253,34 @@ __rte_experimental
 int
 rte_ether_unformat_addr(const char *str, struct rte_ether_addr *eth_addr);
 
+/* Windows Sockets headers contain `#define s_addr S_un.S_addr`.
+ * Temporarily disable this macro to avoid conflict at definition.
+ * Place source MAC address in both `s_addr` and `S_un.S_addr` fields,
+ * so that access works either directly or through the macro.
+ */
+#pragma push_macro("s_addr")
+#ifdef s_addr
+#undef s_addr
+#endif
+
 /**
  * Ethernet header: Contains the destination address, source address
  * and frame type.
  */
 struct rte_ether_hdr {
struct rte_ether_addr d_addr; /**< Destination address. */
-   struct rte_ether_addr s_addr; /**< Source address. */
-   uint16_t ether_type;  /**< Frame type. */
+   RTE_STD_C11
+   union {
+   struct rte_ether_addr s_addr; /**< Source address. */
+   struct {
+   struct rte_ether_addr S_addr;
+   } S_un; /**< Do not use directly; use s_addr instead.*/
+   };
+   uint16_t ether_type; /**< Frame type. */
 } __rte_aligned(2);
 
+#pragma pop_macro("s_addr")
+
 /**
  * Ethernet VLAN Header.
  * Contains the 16-bit VLAN Tag Control Identifier and the Ethernet type
-- 
2.29.3



[dpdk-dev] [PATCH v9 4/4] net: provide IP-related API on any OS

2021-04-10 Thread Dmitry Kozlyuk
Users of  relied on it to provide IP-related defines,
like IPPROTO_* constants, but still had to include POSIX headers
for inet_pton() and other standard IP-related facilities.

Extend  so that it is a single header to gain access
to IP-related facilities on any OS. Use it to replace POSIX includes
in components enabled on Windows. Move missing constants from Windows
networking shim to OS shim header and include it where needed.

Remove Windows networking shim that is no longer needed.

Signed-off-by: Dmitry Kozlyuk 
Acked-by: Olivier Matz 
---
 drivers/net/i40e/i40e_fdir.c |  1 +
 drivers/net/mlx5/mlx5.h  |  1 -
 drivers/net/mlx5/mlx5_flow.c |  4 +--
 drivers/net/mlx5/mlx5_flow.h |  3 +-
 drivers/net/mlx5/mlx5_mac.c  |  1 -
 examples/cmdline/commands.c  |  5 ---
 examples/cmdline/parse_obj_list.c|  2 --
 lib/librte_cmdline/cmdline.c |  1 -
 lib/librte_cmdline/cmdline_parse.c   |  2 --
 lib/librte_cmdline/cmdline_parse_etheraddr.c |  6 
 lib/librte_cmdline/cmdline_parse_ipaddr.c|  6 
 lib/librte_cmdline/cmdline_parse_ipaddr.h|  2 +-
 lib/librte_eal/windows/include/arpa/inet.h   | 30 
 lib/librte_eal/windows/include/netinet/in.h  | 38 
 lib/librte_eal/windows/include/netinet/ip.h  | 10 --
 lib/librte_eal/windows/include/rte_os_shim.h |  8 +
 lib/librte_eal/windows/include/sys/socket.h  | 24 -
 lib/librte_ethdev/rte_ethdev.c   | 12 +++
 lib/librte_ethdev/rte_ethdev_core.h  |  1 -
 lib/librte_net/rte_ip.h  |  7 
 lib/librte_net/rte_net.c |  1 +
 21 files changed, 24 insertions(+), 141 deletions(-)
 delete mode 100644 lib/librte_eal/windows/include/arpa/inet.h
 delete mode 100644 lib/librte_eal/windows/include/netinet/in.h
 delete mode 100644 lib/librte_eal/windows/include/netinet/ip.h
 delete mode 100644 lib/librte_eal/windows/include/sys/socket.h

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index c572d003cb..e7361bf520 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "i40e_logs.h"
 #include "base/i40e_type.h"
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 6faba4fbb1..392e89d3f5 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index c347f8130e..0f1a9c5ed9 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -3,12 +3,11 @@
  * Copyright 2016 Mellanox Technologies, Ltd
  */
 
-#include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -8241,4 +8240,3 @@ mlx5_release_tunnel_hub(__rte_unused struct 
mlx5_dev_ctx_shared *sh,
 {
 }
 #endif /* HAVE_IBV_FLOW_DV_SUPPORT */
-
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 8324e188e1..d03eb0a7a7 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -5,11 +5,10 @@
 #ifndef RTE_PMD_MLX5_FLOW_H_
 #define RTE_PMD_MLX5_FLOW_H_
 
-#include 
-#include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
index a7946f7756..19981d26d8 100644
--- a/drivers/net/mlx5/mlx5_mac.c
+++ b/drivers/net/mlx5/mlx5_mac.c
@@ -8,7 +8,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
diff --git a/examples/cmdline/commands.c b/examples/cmdline/commands.c
index f43eacfbad..9ce8ef389f 100644
--- a/examples/cmdline/commands.c
+++ b/examples/cmdline/commands.c
@@ -8,12 +8,7 @@
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
-#ifdef RTE_EXEC_ENV_FREEBSD
-#include 
-#endif
 
 #include 
 #include 
diff --git a/examples/cmdline/parse_obj_list.c 
b/examples/cmdline/parse_obj_list.c
index b04adbea58..959bcd1452 100644
--- a/examples/cmdline/parse_obj_list.c
+++ b/examples/cmdline/parse_obj_list.c
@@ -6,11 +6,9 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c
index 49770869bb..a176d15130 100644
--- a/lib/librte_cmdline/cmdline.c
+++ b/lib/librte_cmdline/cmdline.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
diff --git a/lib/librte_cmdline/cmdline_parse.c 
b/lib/librte_cmdline/cmdline_parse.c
index fe366841cd..f5cc934782 100644
--- a/lib/librte_cmdline/cmdline_parse.c
+++ b/lib/librte_cmdline/cmdline_parse.c
@@ -11,8 +11,6 @@
 #include 
 #include 
 
-#include 
-
 #include 
 
 #include "cmdline_private.h"
diff --git a/lib/librte_cmdline/cmdline_parse_etheraddr.c 
b/lib/librte_cmdline/cmdline_parse_ethera

Re: [dpdk-dev] [PATCH] ethdev: add packet integrity checks

2021-04-10 Thread Ori Kam
Hi Jerin & Ajit

> -Original Message-
> From: Ajit Khaparde 
> Sent: Sunday, April 11, 2021 7:13 AM
> 
> On Thu, Apr 8, 2021 at 12:44 AM Jerin Jacob  wrote:
> >
> > On Thu, Apr 8, 2021 at 3:45 AM Ori Kam  wrote:
> > >
> > > Hi Jerin,
> > >
> > > > -Original Message-
> > > > From: Jerin Jacob 
> > > > Subject: Re: [dpdk-dev] [PATCH] ethdev: add packet integrity checks
> > > >
> > > > On Wed, Apr 7, 2021 at 4:02 PM Ori Kam  wrote:
> > > > >
> > > > > Hi Jerin,
> > > >
> > > > Hi Ori,
> > > >
> > > >
> > > > >
> > > > > > -Original Message-
> > > > > > From: Jerin Jacob 
> > > > > > Sent: Tuesday, April 6, 2021 10:40 AM
> > > > > > To: Ori Kam 
> > > > > > Subject: Re: [dpdk-dev] [PATCH] ethdev: add packet integrity checks
> > > > > >
> > > > > > On Mon, Apr 5, 2021 at 11:35 PM Ori Kam 
> wrote:
> > > > > > >
> > > > > > > Currently, DPDK application can offload the checksum check,
> > > > > > > and report it in the mbuf.
> > > > > > >
> > > > > > > However, as more and more applications are offloading some or all
> > > > > > > logic and action to the HW, there is a need to check the packet
> > > > > > > integrity so the right decision can be taken.
> > > > > > >
> > > > > > > The application logic can be positive meaning if the packet is
> > > > > > > valid jump / do  actions, or negative if packet is not valid
> > > > > > > jump to SW / do actions (like drop)  a, and add default flow
> > > > > > > (match all in low priority) that will direct the miss packet
> > > > > > > to the miss path.
> > > > > > >
> > > > > > > Since currenlty rte_flow works in positive way the assumtion is
> > > > > > > that the postive way will be the common way in this case also.
> > > > > > >
> > > > > > > When thinking what is the best API to implement such feature,
> > > > > > > we need to considure the following (in no specific order):
> > > > > > > 1. API breakage.
> > > > > > > 2. Simplicity.
> > > > > > > 3. Performance.
> > > > > > > 4. HW capabilities.
> > > > > > > 5. rte_flow limitation.
> > > > > > > 6. Flexability.
> > > > > >
> > > > > >
> > > > > > Alteast in Marvell HW integrity checks are functions of the Ethdev 
> > > > > > Rx
> > > > > > queue attribute.
> > > > > > Not sure about other Vendor HW.
> > > > >
> > > > > I'm not sure what do you mean?
> > > >
> > > > What I meant is, What will be the preferred way to configure the 
> > > > feature?
> > > > ie. Is it as ethdev Rx offload or rte_flow?
> > > >
> > > > I think, in order to decide that, we need to know, how most of the
> > > > other HW express this feature?
> > > >
> > >
> > > As  I see it both ways could be used,
> > > Maybe even by the same app,
> > >
> > > One flow is to notify the application when it sees the packet
> > > (RX offload) and one is to use as an item to route the packet
> > > when using rte_flow.
> > >
> > > Maybe I'm missing something, on your suggestion how will
> > > application route the packets? Or it will just receive them with flags
> > > on the RX queue?
> >
> > Just receive them with flags on the Rx queue, in order to avoid
> > duplicating features
> > in multiple places.
> I think this is more reasonable and simpler.
> Especially when I read the discussion further in the thread between
> Andrew and Ori.
> 

Ajit, I'm sorry but I'm not sure I understand if you like better the suggested 
approach,
or the RX one?

In any case those are two different cases, one is for the application and one 
is for 
offloaded routing.

Best,
Ori

> >
> > >
> > >
> > >
> > > >
> > > > > This is the idea of the patch, to allow application to route the 
> > > > > packet
> > > > > before getting to the Rx,
> > > > > In any case all items support is dependent on HW capabilities.
> > > >
> > > >
> > > >
> > > >
> > >
> > > Best,
> > > Ori


[dpdk-dev] [PATCH v3 2/4] common/iavf: add proto header for IP fragment

2021-04-10 Thread Jeff Guo
Add new virtchnl protocol header type and fields for IP fragment packets
to support RSS hash and FDIR.

Signed-off-by: Ting Xu 
Signed-off-by: Jeff Guo 
---
 drivers/common/iavf/virtchnl.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/common/iavf/virtchnl.h b/drivers/common/iavf/virtchnl.h
index 6b99e170f0..e3eb767d66 100644
--- a/drivers/common/iavf/virtchnl.h
+++ b/drivers/common/iavf/virtchnl.h
@@ -1415,7 +1415,9 @@ enum virtchnl_proto_hdr_type {
VIRTCHNL_PROTO_HDR_S_VLAN,
VIRTCHNL_PROTO_HDR_C_VLAN,
VIRTCHNL_PROTO_HDR_IPV4,
+   VIRTCHNL_PROTO_HDR_IPV4_FRAG,
VIRTCHNL_PROTO_HDR_IPV6,
+   VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
VIRTCHNL_PROTO_HDR_TCP,
VIRTCHNL_PROTO_HDR_UDP,
VIRTCHNL_PROTO_HDR_SCTP,
@@ -1452,6 +1454,8 @@ enum virtchnl_proto_hdr_field {
VIRTCHNL_PROTO_HDR_IPV4_DSCP,
VIRTCHNL_PROTO_HDR_IPV4_TTL,
VIRTCHNL_PROTO_HDR_IPV4_PROT,
+   VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID =
+   PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4_FRAG),
/* IPV6 */
VIRTCHNL_PROTO_HDR_IPV6_SRC =
PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6),
@@ -1472,6 +1476,9 @@ enum virtchnl_proto_hdr_field {
VIRTCHNL_PROTO_HDR_IPV6_PREFIX64_DST,
VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_SRC,
VIRTCHNL_PROTO_HDR_IPV6_PREFIX96_DST,
+   /* IPv6 Extension Header Fragment */
+   VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID =
+   PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG),
/* TCP */
VIRTCHNL_PROTO_HDR_TCP_SRC_PORT =
PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_TCP),
-- 
2.20.1



[dpdk-dev] [PATCH v3 1/4] app/testpmd: add packet id for IP fragment

2021-04-10 Thread Jeff Guo
Add the new items to support the flow configuration for IP fragment
packets.

Signed-off-by: Ting Xu 
Signed-off-by: Jeff Guo 
---
 app/test-pmd/cmdline_flow.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index fb7a3a8bd3..46ae342b85 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -166,6 +166,7 @@ enum index {
ITEM_VLAN_HAS_MORE_VLAN,
ITEM_IPV4,
ITEM_IPV4_TOS,
+   ITEM_IPV4_ID,
ITEM_IPV4_FRAGMENT_OFFSET,
ITEM_IPV4_TTL,
ITEM_IPV4_PROTO,
@@ -236,6 +237,7 @@ enum index {
ITEM_IPV6_FRAG_EXT,
ITEM_IPV6_FRAG_EXT_NEXT_HDR,
ITEM_IPV6_FRAG_EXT_FRAG_DATA,
+   ITEM_IPV6_FRAG_EXT_ID,
ITEM_ICMP6,
ITEM_ICMP6_TYPE,
ITEM_ICMP6_CODE,
@@ -1028,6 +1030,7 @@ static const enum index item_vlan[] = {
 
 static const enum index item_ipv4[] = {
ITEM_IPV4_TOS,
+   ITEM_IPV4_ID,
ITEM_IPV4_FRAGMENT_OFFSET,
ITEM_IPV4_TTL,
ITEM_IPV4_PROTO,
@@ -1164,6 +1167,7 @@ static const enum index item_ipv6_ext[] = {
 static const enum index item_ipv6_frag_ext[] = {
ITEM_IPV6_FRAG_EXT_NEXT_HDR,
ITEM_IPV6_FRAG_EXT_FRAG_DATA,
+   ITEM_IPV6_FRAG_EXT_ID,
ITEM_NEXT,
ZERO,
 };
@@ -2466,6 +2470,13 @@ static const struct token token_list[] = {
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
 hdr.type_of_service)),
},
+   [ITEM_IPV4_ID] = {
+   .name = "packet_id",
+   .help = "fragment packet id",
+   .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
+   .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
+hdr.packet_id)),
+   },
[ITEM_IPV4_FRAGMENT_OFFSET] = {
.name = "fragment_offset",
.help = "fragmentation flags and fragment offset",
@@ -2969,12 +2980,20 @@ static const struct token token_list[] = {
},
[ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
.name = "frag_data",
-   .help = "Fragment flags and offset",
+   .help = "fragment flags and offset",
.next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
 item_param),
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
 hdr.frag_data)),
},
+   [ITEM_IPV6_FRAG_EXT_ID] = {
+   .name = "packet_id",
+   .help = "fragment packet id",
+   .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
+item_param),
+   .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
+hdr.id)),
+   },
[ITEM_ICMP6] = {
.name = "icmp6",
.help = "match any ICMPv6 header",
-- 
2.20.1



[dpdk-dev] [PATCH v3 3/4] net/iavf: support RSS hash for IP fragment

2021-04-10 Thread Jeff Guo
New pattern and RSS hash flow parsing are added to handle fragmented
IPv4/IPv6  packet.

Signed-off-by: Ting Xu 
Signed-off-by: Jeff Guo 
---
 drivers/net/iavf/iavf_generic_flow.c | 24 
 drivers/net/iavf/iavf_generic_flow.h |  3 +
 drivers/net/iavf/iavf_hash.c | 83 
 3 files changed, 100 insertions(+), 10 deletions(-)

diff --git a/drivers/net/iavf/iavf_generic_flow.c 
b/drivers/net/iavf/iavf_generic_flow.c
index 8635ff83ca..242bb4abc5 100644
--- a/drivers/net/iavf/iavf_generic_flow.c
+++ b/drivers/net/iavf/iavf_generic_flow.c
@@ -219,6 +219,30 @@ enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6[] = {
RTE_FLOW_ITEM_TYPE_END,
 };
 
+enum rte_flow_item_type iavf_pattern_eth_ipv6_frag_ext[] = {
+   RTE_FLOW_ITEM_TYPE_ETH,
+   RTE_FLOW_ITEM_TYPE_IPV6,
+   RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+   RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_vlan_ipv6_frag_ext[] = {
+   RTE_FLOW_ITEM_TYPE_ETH,
+   RTE_FLOW_ITEM_TYPE_VLAN,
+   RTE_FLOW_ITEM_TYPE_IPV6,
+   RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+   RTE_FLOW_ITEM_TYPE_END,
+};
+
+enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6_frag_ext[] = {
+   RTE_FLOW_ITEM_TYPE_ETH,
+   RTE_FLOW_ITEM_TYPE_VLAN,
+   RTE_FLOW_ITEM_TYPE_VLAN,
+   RTE_FLOW_ITEM_TYPE_IPV6,
+   RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+   RTE_FLOW_ITEM_TYPE_END,
+};
+
 enum rte_flow_item_type iavf_pattern_eth_ipv6_udp[] = {
RTE_FLOW_ITEM_TYPE_ETH,
RTE_FLOW_ITEM_TYPE_IPV6,
diff --git a/drivers/net/iavf/iavf_generic_flow.h 
b/drivers/net/iavf/iavf_generic_flow.h
index 005eeb3553..32932557ca 100644
--- a/drivers/net/iavf/iavf_generic_flow.h
+++ b/drivers/net/iavf/iavf_generic_flow.h
@@ -203,6 +203,9 @@ extern enum rte_flow_item_type 
iavf_pattern_eth_qinq_ipv4_icmp[];
 extern enum rte_flow_item_type iavf_pattern_eth_ipv6[];
 extern enum rte_flow_item_type iavf_pattern_eth_vlan_ipv6[];
 extern enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6[];
+extern enum rte_flow_item_type iavf_pattern_eth_ipv6_frag_ext[];
+extern enum rte_flow_item_type iavf_pattern_eth_vlan_ipv6_frag_ext[];
+extern enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6_frag_ext[];
 extern enum rte_flow_item_type iavf_pattern_eth_ipv6_udp[];
 extern enum rte_flow_item_type iavf_pattern_eth_vlan_ipv6_udp[];
 extern enum rte_flow_item_type iavf_pattern_eth_qinq_ipv6_udp[];
diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c
index d8d22f8009..5d3d62839b 100644
--- a/drivers/net/iavf/iavf_hash.c
+++ b/drivers/net/iavf/iavf_hash.c
@@ -112,6 +112,10 @@ iavf_hash_parse_pattern_action(struct iavf_adapter *ad,
FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) | \
FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST), {BUFF_NOUSED} }
 
+#define proto_hdr_ipv6_frag { \
+   VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG, \
+   FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID), {BUFF_NOUSED} }
+
 #define proto_hdr_ipv6_with_prot { \
VIRTCHNL_PROTO_HDR_IPV6, \
FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) | \
@@ -190,6 +194,12 @@ struct virtchnl_proto_hdrs outer_ipv6_tmplt = {
{proto_hdr_eth, proto_hdr_svlan, proto_hdr_cvlan, proto_hdr_ipv6}
 };
 
+struct virtchnl_proto_hdrs outer_ipv6_frag_tmplt = {
+   TUNNEL_LEVEL_OUTER, 5,
+   {proto_hdr_eth, proto_hdr_svlan, proto_hdr_cvlan,
+proto_hdr_ipv6, proto_hdr_ipv6_frag}
+};
+
 struct virtchnl_proto_hdrs outer_ipv6_udp_tmplt = {
TUNNEL_LEVEL_OUTER, 5,
{proto_hdr_eth, proto_hdr_svlan, proto_hdr_cvlan,
@@ -303,7 +313,8 @@ struct virtchnl_proto_hdrs ipv4_ecpri_tmplt = {
 /* rss type super set */
 
 /* IPv4 outer */
-#define IAVF_RSS_TYPE_OUTER_IPV4   (ETH_RSS_ETH | ETH_RSS_IPV4)
+#define IAVF_RSS_TYPE_OUTER_IPV4   (ETH_RSS_ETH | ETH_RSS_IPV4 | \
+ETH_RSS_FRAG_IPV4)
 #define IAVF_RSS_TYPE_OUTER_IPV4_UDP   (IAVF_RSS_TYPE_OUTER_IPV4 | \
 ETH_RSS_NONFRAG_IPV4_UDP)
 #define IAVF_RSS_TYPE_OUTER_IPV4_TCP   (IAVF_RSS_TYPE_OUTER_IPV4 | \
@@ -312,6 +323,8 @@ struct virtchnl_proto_hdrs ipv4_ecpri_tmplt = {
 ETH_RSS_NONFRAG_IPV4_SCTP)
 /* IPv6 outer */
 #define IAVF_RSS_TYPE_OUTER_IPV6   (ETH_RSS_ETH | ETH_RSS_IPV6)
+#define IAVF_RSS_TYPE_OUTER_IPV6_FRAG  (IAVF_RSS_TYPE_OUTER_IPV6 | \
+ETH_RSS_FRAG_IPV6)
 #define IAVF_RSS_TYPE_OUTER_IPV6_UDP   (IAVF_RSS_TYPE_OUTER_IPV6 | \
 ETH_RSS_NONFRAG_IPV6_UDP)
 #define IAVF_RSS_TYPE_OUTER_IPV6_TCP   (IAVF_RSS_TYPE_OUTER_IPV6 | \
@@ -330,6 +343,8 @@ struct virtchnl_proto_hdrs ipv4_ecpri_tmplt = {
 /* VLAN IPv6 */
 #define IAVF_RSS_TYPE_VLAN_IPV6(IAVF_RSS_TYPE_OUTER_IPV6 | \
 ETH_RSS_S_VLAN | ETH_RSS_C_VLAN)
+#define IAVF_RSS_TYPE_VLAN_IPV6_FRAG   (IAVF_RSS_TYPE_OUTER_IPV6_FRAG | \
+

[dpdk-dev] [PATCH v3 4/4] net/iavf: support FDIR for IP fragment packet

2021-04-10 Thread Jeff Guo
New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.

Signed-off-by: Ting Xu 
Signed-off-by: Jeff Guo 
---
 drivers/net/iavf/iavf_fdir.c | 376 ++-
 drivers/net/iavf/iavf_generic_flow.h |   5 +
 2 files changed, 257 insertions(+), 124 deletions(-)

diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c
index 62f032985a..64c169f8c4 100644
--- a/drivers/net/iavf/iavf_fdir.c
+++ b/drivers/net/iavf/iavf_fdir.c
@@ -34,7 +34,7 @@
 #define IAVF_FDIR_INSET_ETH_IPV4 (\
IAVF_INSET_IPV4_SRC | IAVF_INSET_IPV4_DST | \
IAVF_INSET_IPV4_PROTO | IAVF_INSET_IPV4_TOS | \
-   IAVF_INSET_IPV4_TTL)
+   IAVF_INSET_IPV4_TTL | IAVF_INSET_IPV4_ID)
 
 #define IAVF_FDIR_INSET_ETH_IPV4_UDP (\
IAVF_INSET_IPV4_SRC | IAVF_INSET_IPV4_DST | \
@@ -56,6 +56,9 @@
IAVF_INSET_IPV6_NEXT_HDR | IAVF_INSET_IPV6_TC | \
IAVF_INSET_IPV6_HOP_LIMIT)
 
+#define IAVF_FDIR_INSET_ETH_IPV6_FRAG_EXT (\
+   IAVF_INSET_IPV6_ID)
+
 #define IAVF_FDIR_INSET_ETH_IPV6_UDP (\
IAVF_INSET_IPV6_SRC | IAVF_INSET_IPV6_DST | \
IAVF_INSET_IPV6_TC | IAVF_INSET_IPV6_HOP_LIMIT | \
@@ -143,6 +146,7 @@ static struct iavf_pattern_match_item iavf_fdir_pattern[] = 
{
{iavf_pattern_eth_ipv4_tcp,  IAVF_FDIR_INSET_ETH_IPV4_TCP,  
IAVF_INSET_NONE},
{iavf_pattern_eth_ipv4_sctp, IAVF_FDIR_INSET_ETH_IPV4_SCTP, 
IAVF_INSET_NONE},
{iavf_pattern_eth_ipv6,  IAVF_FDIR_INSET_ETH_IPV6,  
IAVF_INSET_NONE},
+   {iavf_pattern_eth_ipv6_frag_ext,
IAVF_FDIR_INSET_ETH_IPV6_FRAG_EXT,  IAVF_INSET_NONE},
{iavf_pattern_eth_ipv6_udp,  IAVF_FDIR_INSET_ETH_IPV6_UDP,  
IAVF_INSET_NONE},
{iavf_pattern_eth_ipv6_tcp,  IAVF_FDIR_INSET_ETH_IPV6_TCP,  
IAVF_INSET_NONE},
{iavf_pattern_eth_ipv6_sctp, IAVF_FDIR_INSET_ETH_IPV6_SCTP, 
IAVF_INSET_NONE},
@@ -543,6 +547,29 @@ iavf_fdir_refine_input_set(const uint64_t input_set,
}
 }
 
+static void
+iavf_fdir_add_fragment_hdr(struct virtchnl_proto_hdrs *hdrs, int layer)
+{
+   struct virtchnl_proto_hdr *hdr1;
+   struct virtchnl_proto_hdr *hdr2;
+   int i;
+
+   if (layer < 0 || layer > hdrs->count)
+   return;
+
+   /* shift headers layer */
+   for (i = hdrs->count; i >= layer; i--) {
+   hdr1 = &hdrs->proto_hdr[i];
+   hdr2 = &hdrs->proto_hdr[i - 1];
+   *hdr1 = *hdr2;
+   }
+
+   /* adding dummy fragment header */
+   hdr1 = &hdrs->proto_hdr[layer];
+   VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, IPV4_FRAG);
+   hdrs->count = ++layer;
+}
+
 static int
 iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
const struct rte_flow_item pattern[],
@@ -550,12 +577,15 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter 
*ad,
struct rte_flow_error *error,
struct iavf_fdir_conf *filter)
 {
-   const struct rte_flow_item *item = pattern;
-   enum rte_flow_item_type item_type;
+   struct virtchnl_proto_hdrs *hdrs =
+   &filter->add_fltr.rule_cfg.proto_hdrs;
enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
const struct rte_flow_item_eth *eth_spec, *eth_mask;
-   const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_mask;
+   const struct rte_flow_item_ipv4 *ipv4_spec, *ipv4_last, *ipv4_mask;
const struct rte_flow_item_ipv6 *ipv6_spec, *ipv6_mask;
+   const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_spec;
+   const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_last;
+   const struct rte_flow_item_ipv6_frag_ext *ipv6_frag_mask;
const struct rte_flow_item_udp *udp_spec, *udp_mask;
const struct rte_flow_item_tcp *tcp_spec, *tcp_mask;
const struct rte_flow_item_sctp *sctp_spec, *sctp_mask;
@@ -566,15 +596,15 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter 
*ad,
const struct rte_flow_item_ah *ah_spec, *ah_mask;
const struct rte_flow_item_pfcp *pfcp_spec, *pfcp_mask;
const struct rte_flow_item_ecpri *ecpri_spec, *ecpri_mask;
+   const struct rte_flow_item *item = pattern;
+   struct virtchnl_proto_hdr *hdr, *hdr1 = NULL;
struct rte_ecpri_common_hdr ecpri_common;
uint64_t input_set = IAVF_INSET_NONE;
-
+   enum rte_flow_item_type item_type;
enum rte_flow_item_type next_type;
+   uint8_t tun_inner = 0;
uint16_t ether_type;
-
-   u8 tun_inner = 0;
int layer = 0;
-   struct virtchnl_proto_hdr *hdr;
 
uint8_t  ipv6_addr_mask[16] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -582,26 +612,28 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter 
*ad,
};
 
for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
-   if (item->last) {
+   item_type = item->type;

[dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE

2021-04-10 Thread Jeff Guo
Support RSS hash and FDIR for IP fragment packets in ICE PMD.

v3:
rebase code and fix some parsing issues.
v2:
add some input check

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c|  50 -
 drivers/net/ice/base/ice_fdir.h|  22 +-
 drivers/net/ice/base/ice_flow.c|  50 -
 drivers/net/ice/base/ice_flow.h|   5 +-
 drivers/net/ice/base/ice_type.h|   1 +
 drivers/net/ice/ice_fdir_filter.c  | 116 ++---
 drivers/net/ice/ice_generic_flow.c |  22 ++
 drivers/net/ice/ice_generic_flow.h |   6 ++
 drivers/net/ice/ice_hash.c |  48 ++--
 9 files changed, 293 insertions(+), 27 deletions(-)

-- 
2.20.1



[dpdk-dev] [PATCH v3 1/3] net/ice/base: support IP fragment RSS and FDIR

2021-04-10 Thread Jeff Guo
Add support for IP fragment RSS hash and FDIR according to packet ID.
Separate IP fragment and IP other packet types.

Signed-off-by: Ting Xu 
Signed-off-by: Jeff Guo 
---
 drivers/net/ice/base/ice_fdir.c | 50 +++--
 drivers/net/ice/base/ice_fdir.h | 22 ---
 drivers/net/ice/base/ice_flow.c | 50 -
 drivers/net/ice/base/ice_flow.h |  5 +++-
 drivers/net/ice/base/ice_type.h |  1 +
 5 files changed, 120 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c
index 2b39c13127..0eb7cdd729 100644
--- a/drivers/net/ice/base/ice_fdir.c
+++ b/drivers/net/ice/base/ice_fdir.c
@@ -518,6 +518,24 @@ static const u8 ice_fdir_ipv4_udp_ecpri_tp0_pkt[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 };
 
+static const u8 ice_fdir_ipv6_frag_pkt[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x2C, 0x40, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const u8 ice_fdir_ipv4_frag_pkt[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00,
+   0x00, 0x14, 0x00, 0x00, 0x20, 0x00, 0x40, 0x10,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00
+};
 static const u8 ice_fdir_tcpv6_pkt[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x86, 0xDD, 0x60, 0x00,
@@ -716,6 +734,16 @@ static const struct ice_fdir_base_pkt ice_fdir_pkt[] = {
sizeof(ice_fdir_ipv4_pkt), ice_fdir_ipv4_pkt,
sizeof(ice_fdir_ip4_tun_pkt), ice_fdir_ip4_tun_pkt,
},
+   {
+   ICE_FLTR_PTYPE_FRAG_IPV4,
+   sizeof(ice_fdir_ipv4_pkt), ice_fdir_ipv4_frag_pkt,
+   sizeof(ice_fdir_ipv4_pkt), ice_fdir_ipv4_frag_pkt,
+   },
+   {
+   ICE_FLTR_PTYPE_FRAG_IPV6,
+   sizeof(ice_fdir_ipv6_frag_pkt), ice_fdir_ipv6_frag_pkt,
+   sizeof(ice_fdir_ipv6_frag_pkt), ice_fdir_ipv6_frag_pkt,
+   },
{
ICE_FLTR_PTYPE_NONF_IPV4_GTPU,
sizeof(ice_fdir_ipv4_gtpu4_pkt),
@@ -1505,7 +1533,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct 
ice_fdir_fltr *input,
ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
if (frag)
-   loc[20] = ICE_FDIR_IPV4_PKT_FLAG_DF;
+   loc[20] = ICE_FDIR_IPV4_PKT_FLAG_MF;
break;
case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac);
@@ -1808,6 +1836,23 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct 
ice_fdir_fltr *input,
  input->ip.v6.proto);
ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
break;
+   case ICE_FLTR_PTYPE_FRAG_IPV4:
+   ice_pkt_insert_u32(loc, ICE_IPV4_DST_ADDR_OFFSET,
+  input->ip.v4.src_ip);
+   ice_pkt_insert_u32(loc, ICE_IPV4_SRC_ADDR_OFFSET,
+  input->ip.v4.dst_ip);
+   ice_pkt_insert_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos);
+   ice_pkt_insert_u16(loc, ICE_IPV4_ID_OFFSET,
+  input->ip.v4.packet_id);
+   ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl);
+   ice_pkt_insert_u8(loc, ICE_IPV4_PROTO_OFFSET,
+ input->ip.v4.proto);
+   ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac);
+   break;
+   case ICE_FLTR_PTYPE_FRAG_IPV6:
+   ice_pkt_insert_u32(loc, ICE_IPV6_ID_OFFSET,
+  input->ip.v6.packet_id);
+   break;
default:
return ICE_ERR_PARAM;
}
@@ -1838,7 +1883,8 @@ ice_fdir_get_prgm_pkt(struct ice_fdir_fltr *input, u8 
*pkt, bool frag)
  */
 bool ice_fdir_has_frag(enum ice_fltr_ptype flow)
 {
-   if (flow == ICE_FLTR_PTYPE_NONF_IPV4_OTHER)
+   if (flow == ICE_FLTR_PTYPE_FRAG_IPV4 ||
+   flow == ICE_FLTR_PTYPE_FRAG_IPV6)
return true;
else
return false;
diff --git a/drivers/net/ice/base/ice_fdir.h b/drivers/net/ice/base/ice_fdir.h
index 6573f96bc1..2acc1d6f1b 100644
--- a/drivers/net/ice/base/ice_fdir.h
+++ b/drivers/net/ice/base/ice_fdir.h
@@ -43,9 +43,11 @@
 #define ICE_MAC_ETHTYPE_OFFSET 12
 #define ICE_IPV4_TOS_OFFSET15
 #define ICE_IPV4_TTL_OFFSET 

[dpdk-dev] [PATCH v3 2/3] net/ice: support RSS hash for IP fragment

2021-04-10 Thread Jeff Guo
New pattern and RSS hash flow parsing are added to handle fragmented
IPv4/IPv6  packet.

Signed-off-by: Jeff Guo 
---
 drivers/net/ice/ice_generic_flow.c | 21 +
 drivers/net/ice/ice_generic_flow.h |  6 
 drivers/net/ice/ice_hash.c | 48 +-
 3 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ice/ice_generic_flow.c 
b/drivers/net/ice/ice_generic_flow.c
index 8704812622..2389bc6637 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -212,6 +212,27 @@ enum rte_flow_item_type pattern_eth_qinq_ipv6[] = {
RTE_FLOW_ITEM_TYPE_IPV6,
RTE_FLOW_ITEM_TYPE_END,
 };
+enum rte_flow_item_type pattern_eth_ipv6_frag_ext[] = {
+   RTE_FLOW_ITEM_TYPE_ETH,
+   RTE_FLOW_ITEM_TYPE_IPV6,
+   RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+   RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[] = {
+   RTE_FLOW_ITEM_TYPE_ETH,
+   RTE_FLOW_ITEM_TYPE_VLAN,
+   RTE_FLOW_ITEM_TYPE_IPV6,
+   RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+   RTE_FLOW_ITEM_TYPE_END,
+};
+enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[] = {
+   RTE_FLOW_ITEM_TYPE_ETH,
+   RTE_FLOW_ITEM_TYPE_VLAN,
+   RTE_FLOW_ITEM_TYPE_VLAN,
+   RTE_FLOW_ITEM_TYPE_IPV6,
+   RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
+   RTE_FLOW_ITEM_TYPE_END,
+};
 enum rte_flow_item_type pattern_eth_ipv6_udp[] = {
RTE_FLOW_ITEM_TYPE_ETH,
RTE_FLOW_ITEM_TYPE_IPV6,
diff --git a/drivers/net/ice/ice_generic_flow.h 
b/drivers/net/ice/ice_generic_flow.h
index 9f422e5925..2afe719264 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -52,6 +52,7 @@
 #define ICE_L2TPV3OIP_SESSION_ID   BIT_ULL(43)
 #define ICE_PFCP_SEID  BIT_ULL(42)
 #define ICE_PFCP_S_FIELD   BIT_ULL(41)
+#define ICE_IP_PK_ID   BIT_ULL(40)
 
 /* input set */
 
@@ -69,11 +70,13 @@
 #define ICE_INSET_IPV4_TOS (ICE_PROT_IPV4 | ICE_IP_TOS)
 #define ICE_INSET_IPV4_PROTO   (ICE_PROT_IPV4 | ICE_IP_PROTO)
 #define ICE_INSET_IPV4_TTL (ICE_PROT_IPV4 | ICE_IP_TTL)
+#define ICE_INSET_IPV4_PKID(ICE_PROT_IPV4 | ICE_IP_PK_ID)
 #define ICE_INSET_IPV6_SRC (ICE_PROT_IPV6 | ICE_IP_SRC)
 #define ICE_INSET_IPV6_DST (ICE_PROT_IPV6 | ICE_IP_DST)
 #define ICE_INSET_IPV6_NEXT_HDR(ICE_PROT_IPV6 | ICE_IP_PROTO)
 #define ICE_INSET_IPV6_HOP_LIMIT   (ICE_PROT_IPV6 | ICE_IP_TTL)
 #define ICE_INSET_IPV6_TC  (ICE_PROT_IPV6 | ICE_IP_TOS)
+#define ICE_INSET_IPV6_PKID(ICE_PROT_IPV6 | ICE_IP_PK_ID)
 
 #define ICE_INSET_TCP_SRC_PORT (ICE_PROT_TCP | ICE_SPORT)
 #define ICE_INSET_TCP_DST_PORT (ICE_PROT_TCP | ICE_DPORT)
@@ -202,6 +205,9 @@ extern enum rte_flow_item_type pattern_eth_qinq_ipv4_icmp[];
 extern enum rte_flow_item_type pattern_eth_ipv6[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6[];
+extern enum rte_flow_item_type pattern_eth_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_vlan_ipv6_frag_ext[];
+extern enum rte_flow_item_type pattern_eth_qinq_ipv6_frag_ext[];
 extern enum rte_flow_item_type pattern_eth_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_vlan_ipv6_udp[];
 extern enum rte_flow_item_type pattern_eth_qinq_ipv6_udp[];
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 7d7e7052da..9df20df550 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -47,8 +47,10 @@
 ETH_RSS_NONFRAG_IPV6_TCP   | \
 ETH_RSS_NONFRAG_IPV6_SCTP)
 
-#define VALID_RSS_IPV4 (ETH_RSS_IPV4 | VALID_RSS_IPV4_L4)
-#define VALID_RSS_IPV6 (ETH_RSS_IPV6 | VALID_RSS_IPV6_L4)
+#define VALID_RSS_IPV4 (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
+VALID_RSS_IPV4_L4)
+#define VALID_RSS_IPV6 (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | \
+VALID_RSS_IPV6_L4)
 #define VALID_RSS_L3   (VALID_RSS_IPV4 | VALID_RSS_IPV6)
 #define VALID_RSS_L4   (VALID_RSS_IPV4_L4 | VALID_RSS_IPV6_L4)
 
@@ -108,6 +110,7 @@ ice_hash_parse_pattern_action(struct ice_adapter *ad,
 /* Rss configuration template */
 struct ice_rss_hash_cfg ipv4_tmplt = {
ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV4 |
+   ICE_FLOW_SEG_HDR_IPV_FRAG |
ICE_FLOW_SEG_HDR_IPV_OTHER,
ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV4,
ICE_RSS_OUTER_HEADERS,
@@ -146,6 +149,15 @@ struct ice_rss_hash_cfg ipv6_tmplt = {
0
 };
 
+struct ice_rss_hash_cfg ipv6_frag_tmplt = {
+   ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_IPV6 |
+   ICE_FLOW_SEG_HDR_IPV_FRAG |
+   ICE_FLOW_SEG_HDR_IPV_OTHER,
+   ICE_FLOW_HASH_ETH | ICE_FLOW_HASH_IPV6,
+   ICE_RSS_ANY_HEADERS,
+   0
+};
+
 struct ice_rss_hash_cfg

[dpdk-dev] [PATCH v3 3/3] net/ice: support FDIR for IP fragment packet

2021-04-10 Thread Jeff Guo
New FDIR parsing are added to handle the fragmented IPv4/IPv6 packet.

Signed-off-by: Jeff Guo 
Signed-off-by: Ting Xu 
---
 drivers/net/ice/ice_fdir_filter.c  | 116 ++---
 drivers/net/ice/ice_generic_flow.c |   1 +
 2 files changed, 106 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c 
b/drivers/net/ice/ice_fdir_filter.c
index 92e18d59cc..093c83ed0c 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -24,7 +24,7 @@
 #define ICE_FDIR_INSET_ETH_IPV4 (\
ICE_FDIR_INSET_ETH | \
ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
-   ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO)
+   ICE_INSET_IPV4_TTL | ICE_INSET_IPV4_PROTO | ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV4_UDP (\
ICE_FDIR_INSET_ETH_IPV4 | \
@@ -41,7 +41,8 @@
 #define ICE_FDIR_INSET_ETH_IPV6 (\
ICE_INSET_DMAC | \
ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_IPV6_TC | \
-   ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR)
+   ICE_INSET_IPV6_HOP_LIMIT | ICE_INSET_IPV6_NEXT_HDR | \
+   ICE_INSET_IPV6_PKID)
 
 #define ICE_FDIR_INSET_ETH_IPV6_UDP (\
ICE_FDIR_INSET_ETH_IPV6 | \
@@ -56,7 +57,8 @@
ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
 
 #define ICE_FDIR_INSET_IPV4 (\
-   ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+   ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
+   ICE_INSET_IPV4_PKID)
 
 #define ICE_FDIR_INSET_IPV4_TCP (\
ICE_FDIR_INSET_IPV4 | \
@@ -95,6 +97,7 @@ static struct ice_pattern_match_item ice_fdir_pattern_list[] 
= {
{pattern_eth_ipv4_tcp,  
ICE_FDIR_INSET_ETH_IPV4_TCP,ICE_INSET_NONE, ICE_INSET_NONE},
{pattern_eth_ipv4_sctp, 
ICE_FDIR_INSET_ETH_IPV4_SCTP,   ICE_INSET_NONE, ICE_INSET_NONE},
{pattern_eth_ipv6,  
ICE_FDIR_INSET_ETH_IPV6,ICE_INSET_NONE, ICE_INSET_NONE},
+   {pattern_eth_ipv6_frag_ext, 
ICE_FDIR_INSET_ETH_IPV6,ICE_INSET_NONE, ICE_INSET_NONE},
{pattern_eth_ipv6_udp,  
ICE_FDIR_INSET_ETH_IPV6_UDP,ICE_INSET_NONE, ICE_INSET_NONE},
{pattern_eth_ipv6_tcp,  
ICE_FDIR_INSET_ETH_IPV6_TCP,ICE_INSET_NONE, ICE_INSET_NONE},
{pattern_eth_ipv6_sctp, 
ICE_FDIR_INSET_ETH_IPV6_SCTP,   ICE_INSET_NONE, ICE_INSET_NONE},
@@ -882,11 +885,13 @@ ice_fdir_input_set_parse(uint64_t inset, enum 
ice_flow_field *field)
{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
+   {ICE_INSET_IPV4_PKID, ICE_FLOW_FIELD_IDX_IPV4_ID},
{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
{ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
+   {ICE_INSET_IPV6_PKID, ICE_FLOW_FIELD_IDX_IPV6_ID},
{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
@@ -936,6 +941,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct 
ice_flow_seg_info *seg)
ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
  ICE_FLOW_SEG_HDR_IPV_OTHER);
break;
+   case ICE_FLTR_PTYPE_FRAG_IPV4:
+   ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 |
+ ICE_FLOW_SEG_HDR_IPV_FRAG);
+   break;
case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
  ICE_FLOW_SEG_HDR_IPV6 |
@@ -955,6 +964,10 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct 
ice_flow_seg_info *seg)
ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
  ICE_FLOW_SEG_HDR_IPV_OTHER);
break;
+   case ICE_FLTR_PTYPE_FRAG_IPV6:
+   ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
+ ICE_FLOW_SEG_HDR_IPV_FRAG);
+   break;
case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN:
ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
ICE_FLOW_SEG_HDR_IPV4 |
@@ -1599,8 +1612,10 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter 
*ad,
enum rte_flow_item_type l3 = RTE_FLOW_ITEM_TYPE_END;
enum ice_fdir_tunnel_type tunnel_type =

[dpdk-dev] [PATCH v3 0/3] support flow for IP fragment in ICE

2021-04-10 Thread Jeff Guo
Support RSS hash and FDIR for IP fragment packets in ICE PMD.

v3:
rebase code and fix some parsing issues.
v2:
add some input check

Jeff Guo (3):
  net/ice/base: support IP fragment RSS and FDIR
  net/ice: support RSS hash for IP fragment
  net/ice: support FDIR for IP fragment packet

 drivers/net/ice/base/ice_fdir.c|  50 -
 drivers/net/ice/base/ice_fdir.h|  22 +-
 drivers/net/ice/base/ice_flow.c|  50 -
 drivers/net/ice/base/ice_flow.h|   5 +-
 drivers/net/ice/base/ice_type.h|   1 +
 drivers/net/ice/ice_fdir_filter.c  | 116 ++---
 drivers/net/ice/ice_generic_flow.c |  22 ++
 drivers/net/ice/ice_generic_flow.h |   6 ++
 drivers/net/ice/ice_hash.c |  48 ++--
 9 files changed, 293 insertions(+), 27 deletions(-)

-- 
2.20.1



Re: [dpdk-dev] [PATCH] ethdev: add packet integrity checks

2021-04-10 Thread Ori Kam
Hi Andrew,

PSB,

Best,
Ori
> -Original Message-
> From: Andrew Rybchenko 
> 
> On 4/8/21 2:39 PM, Ori Kam wrote:
> > Hi Andrew,
> >
> > Thanks for your comments.
> >
> > PSB,
> >
> > Best,
> > Ori
> >
> >> -Original Message-
> >> From: Andrew Rybchenko 
> >> Sent: Thursday, April 8, 2021 11:05 AM
> >> Subject: Re: [PATCH] ethdev: add packet integrity checks
> >>
> >> On 4/5/21 9:04 PM, Ori Kam wrote:
> >>> Currently, DPDK application can offload the checksum check,
> >>> and report it in the mbuf.
> >>>
> >>> However, as more and more applications are offloading some or all
> >>> logic and action to the HW, there is a need to check the packet
> >>> integrity so the right decision can be taken.
> >>>
> >>> The application logic can be positive meaning if the packet is
> >>> valid jump / do  actions, or negative if packet is not valid
> >>> jump to SW / do actions (like drop)  a, and add default flow
> >>> (match all in low priority) that will direct the miss packet
> >>> to the miss path.
> >>>
> >>> Since currenlty rte_flow works in positive way the assumtion is
> >>> that the postive way will be the common way in this case also.
> >>>
> >>> When thinking what is the best API to implement such feature,
> >>> we need to considure the following (in no specific order):
> >>> 1. API breakage.
> >>
> >> First of all I disagree that "API breakage" is put as a top
> >> priority. Design is a top priority, since it is a long term.
> >> aPI breakage is just a short term inconvenient. Of course,
> >> others may disagree, but that's my point of view.
> >>
> > I agree with you, and like I said the order of the list is not
> > according to priorities.
> > I truly believe that what I'm suggesting is the best design.
> >
> >
> >>> 2. Simplicity.
> >>> 3. Performance.
> >>> 4. HW capabilities.
> >>> 5. rte_flow limitation.
> >>> 6. Flexability.
> >>>
> >>> First option: Add integrity flags to each of the items.
> >>> For example add checksum_ok to ipv4 item.
> >>>
> >>> Pros:
> >>> 1. No new rte_flow item.
> >>> 2. Simple in the way that on each item the app can see
> >>> what checks are available.
> >>
> >> 3. Natively supports various tunnels without any extra
> >>changes in a shared item for all layers.
> >>
> > Also in the current suggested approach, we have the level member,
> > So tunnels are supported by default. If someone wants to check also tunnel
> > he just need to add this item again with the right level. (just like with 
> > other
> > items)
> 
> Thanks, missed it. Is it OK to have just one item with
> level 1 or 2?
> 
Yes, of course, if the application just wants to check the sanity of the inner 
packet he can 
just use one integrity item with level of 2.


> What happens if two items with level 0 and level 1 are
> specified, but the packet has no encapsulation?
>
Level zero is the default one (the default just like in RSS case is 
PMD dependent but in any case  from my knowledge layer 0 if there is no tunnel
will point to the header) and level 1 is the outer most so in this case both of 
them
are pointing to the same checks. 
But if for example we use level = 2 then the checks for level 2 should fail.
Since the packet doesn't hold such info, just like if you check state of l4 and 
there is
no l4 it should fails.


> >>>
> >>> Cons:
> >>> 1. API breakage.
> >>> 2. increase number of flows, since app can't add global rule and
> >>>must have dedicated flow for each of the flow combinations, for example
> >>>matching on icmp traffic or UDP/TCP  traffic with IPv4 / IPv6 will
> >>>result in 5 flows.
> >>
> >> Could you expand it? Shouldn't HW offloaded flows with good
> >> checksums go into dedicated queues where as bad packets go
> >> via default path (i.e. no extra rules)?
> >>
> > I'm not sure what do you mean, in a lot of the cases
> > Application will use that to detect valid packets and then
> > forward only valid packets down the flow. (check valid jump
> > --> on next group decap )
> > In other cases the app may choose to drop the bad packets or count
> > and then drop, maybe sample them to check this is not part of an attack.
> >
> > This is what is great about this feature we just give the app
> > the ability to offload the sanity checks and be that enables it
> > to offload the traffic itself
> 
> Please, when you say "increase number of flows... in 5 flows"
> just try to express in flow rules in both cases. Just for my
> understanding. Since you calculated flows you should have a
> real example.
> 
Sure,  you are right I should have a better example.
Lets take the example that the application want all valid traffic to
jump to group 2.
The possibilities of valid traffic can be:
Eth / ipv4.
Eth / ipv6
Eth / ipv4 / udp
Eth/ ivp4 / tcp
Eth / ipv6 / udp
Eth / ipv6 / tcp

So if we use the existing items we will get the following 6 flows:
Flow create 0 ingress pattern eth / ipv4  valid = 1 / end action jump group 2
Flow create 0 ingress pattern eth / ipv6  valid = 1 / end