RE: [PATCH] net/mlx5: support no host PF configuration

2024-09-27 Thread Bing Zhao
Hi,

> -Original Message-
> From: Jiawei Wang 
> Sent: Wednesday, October 11, 2023 2:42 PM
> To: Suanming Mou ; Xueming(Steven) Li
> ; Slava Ovsiienko 
> Cc: dev@dpdk.org; Raslan Darawsheh 
> Subject: [PATCH] net/mlx5: support no host PF configuration
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Xueming Li 
> 
> In BlueField, a new firmware configuration option NUM_OF_PF=0 disables PF
> on the x86 host side, no HPF on the ARM side, and the only RDMA port on
> the ARM side is the bonding device(PF0). A device probe with devargs of
> representor=pf[0-1]vf[...] will probe PF0 and PF1 one by one, and it's
> possible that PF1 device scan results in no switch ports.
> 
> This patch supports the new configuration by allowing a PF scan with empty
> switch ports.
> 
> Signed-off-by: Xueming Li 
> Signed-off-by: Jiawei Wang 
> ---
>  drivers/net/mlx5/linux/mlx5_os.c | 7 ---
>  1 file changed, 7 deletions(-)
> 
> diff --git a/drivers/net/mlx5/linux/mlx5_os.c
> b/drivers/net/mlx5/linux/mlx5_os.c
> index d5ef695e6d..75f53ade8e 100644
> --- a/drivers/net/mlx5/linux/mlx5_os.c
> +++ b/drivers/net/mlx5/linux/mlx5_os.c
> @@ -2195,13 +2195,6 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device
> *cdev,
>  list[ns].info.master))
> ns++;
> }
> -   if (!ns) {
> -   DRV_LOG(ERR,
> -   "Unable to recognize master/representors
> on the IB device with multiple ports.");
> -   rte_errno = ENOENT;
> -   ret = -rte_errno;
> -   goto exit;
> -   }
> } else {
> /*
>  * The existence of several matching entries (nd > 1)
> means
> --

Acked-by: Bing Zhao 

Thanks

> 2.18.1



Usage of rte_latencystats

2024-09-27 Thread Kamil Vojanec

Hello,

I was experimenting with measuring the latency of DPDK applications 
using the rte_latencystats module. While I could eventually get it to 
work somehow, I noticed some issues, that led me to the following questions:


1. How to measure latency on multicore systems? I noticed that there are 
a lot of global variables that store intermediate results of latency 
calculations. Also, the documentation suggests calling 
rte_latencystats_update() only on a single selected lcore.


2.  What is a good value to select for the `samp_intvl` parameter of 
rte_latencystats_init()? It seems that this option has a significant 
impact on the measured application's performance.


3. How often is it recommended to call rte_latencystats_update()? The 
documentation says the function needs to be called periodically, but 
never specifies how often. Should this be done in each processing loop?


4. Is there no way to clear the statistics? I noticed that the minimum 
and maximum measurement typically reaches some kind of static value that 
does not change and does not really reflect the dynamic nature of the 
measured system.


Looking forward to your reply,
Kamil Vojanec
CESNET, z.s.p.o.



smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PATCH v5 1/1] dts: use PythonShell for Scapy instead of XML-RPC

2024-09-27 Thread Juraj Linkeš




On 26. 9. 2024 18:50, jspew...@iol.unh.edu wrote:

From: Jeremy Spewock 

Previously all scapy commands were handled using an XML-RPC server that
ran on the TGNode. This unnecessarily enforces a minimum Python version
of 3.10 on the server that is being used as a traffic generator and
complicates the implementation of scapy methods. This patch removes the
XML-RPC server completely and instead allows the Scapy TG to extend from
the PythonShell to implement the functionality of a traffic generator.
This is done by importing the Scapy library in the PythonShell and
sending commands directly to the interactive session on the TG Node.

Bugzilla ID: 1374

Signed-off-by: Jeremy Spewock 
---


Reviewed-by: Juraj Linkeš 


Re: [PATCH v3 2/2] dts: add binding to different drivers to TG node

2024-09-27 Thread Luca Vizzarro

Reviewed-by: Luca Vizzarro 


[PATCH v2 47/47] net/bnxt: tf_ulp: add stats cache for thor2

2024-09-27 Thread Sriharsha Basavapatna
From: Peter Spreadborough 

This change adds a stats cache for Thor2 flows using counters.
Flow stats will be harvested periodically in the background
and stats reads by the application will be returned stats from
the cache and not by initiating a read from HW.

This change also adds read-clear functionality for counter resets
and restructures the stats collection while loop to
guarantee full coverage of entries added or removed during the
collection period.

Signed-off-by: Peter Spreadborough 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Jay Ding 
Reviewed-by: Shahaji Bhosle 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h   |   2 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c  |  16 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c   |  10 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h |  26 ++
 drivers/net/bnxt/tf_ulp/meson.build  |   4 +-
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c |  13 +
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c|   4 +
 drivers/net/bnxt/tf_ulp/ulp_mapper.c |  73 
 drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c | 529 +++
 drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h | 142 ++
 drivers/net/bnxt/tf_ulp/ulp_sc_mgr_tfc.c |  60 +++
 11 files changed, 877 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_sc_mgr.h
 create mode 100644 drivers/net/bnxt/tf_ulp/ulp_sc_mgr_tfc.c

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
index a35f79f167..83fb205f68 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
@@ -162,6 +162,8 @@ struct bnxt_ulp_data {
uint64_tfeature_bits;
uint64_tdefault_class_bits;
uint64_tdefault_act_bits;
+   struct ulp_fc_tfc_stats_cache_entry *stats_cache;
+   struct bnxt_ulp_sc_info *sc_info;
 };
 
 enum bnxt_ulp_tfo_type {
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
index 334eda99ce..2c22582e1c 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
@@ -670,6 +670,7 @@ bnxt_ulp_flow_query(struct rte_eth_dev *eth_dev,
struct bnxt_ulp_context *ulp_ctx;
struct rte_flow_action_rss *rss_conf;
struct rte_flow_query_count *count;
+   enum bnxt_ulp_device_id  dev_id;
uint32_t flow_id;
 
ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(eth_dev);
@@ -681,6 +682,15 @@ bnxt_ulp_flow_query(struct rte_eth_dev *eth_dev,
return -EINVAL;
}
 
+   rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id);
+   if (rc) {
+   BNXT_DRV_DBG(ERR, "Can't identify the device\n");
+   rte_flow_error_set(error, EINVAL,
+  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+  "Failed to query flow.");
+   return -EINVAL;
+   }
+
flow_id = (uint32_t)(uintptr_t)flow;
 
switch (action->type) {
@@ -696,7 +706,11 @@ bnxt_ulp_flow_query(struct rte_eth_dev *eth_dev,
break;
case RTE_FLOW_ACTION_TYPE_COUNT:
count = data;
-   rc = ulp_fc_mgr_query_count_get(ulp_ctx, flow_id, count);
+   if (dev_id == BNXT_ULP_DEVICE_ID_THOR2)
+   rc = ulp_sc_mgr_query_count_get(ulp_ctx, flow_id, 
count);
+   else
+   rc = ulp_fc_mgr_query_count_get(ulp_ctx, flow_id, 
count);
+
if (unlikely(rc)) {
rte_flow_error_set(error, EINVAL,
   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
index cc779826a5..df4d2a0220 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
@@ -26,6 +26,7 @@
 #include "ulp_template_struct.h"
 #include "ulp_mark_mgr.h"
 #include "ulp_fc_mgr.h"
+#include "ulp_sc_mgr.h"
 #include "ulp_flow_db.h"
 #include "ulp_mapper.h"
 #include "ulp_matcher.h"
@@ -887,6 +888,9 @@ ulp_tfc_deinit(struct bnxt *bp,
BNXT_DRV_DBG(ERR, "Failed to close HA (%d)\n", rc);
}
 
+   /* Delete the Stats Counter Manager */
+   ulp_sc_mgr_deinit(bp->ulp_ctx);
+
/* cleanup the flow database */
ulp_flow_db_deinit(bp->ulp_ctx);
 
@@ -1043,6 +1047,12 @@ ulp_tfc_init(struct bnxt *bp,
goto jump_to_error;
}
 
+   rc = ulp_sc_mgr_init(bp->ulp_ctx);
+   if (rc) {
+   BNXT_DRV_DBG(ERR, "Failed to initialize ulp stats cache mgr\n");
+   goto jump_to_error;
+   }
+
rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &ulp_dev_id);
if (rc) {
BNXT_DRV_DBG(ERR, "Unable to get device id from ulp.\n");
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_util

[PATCH v2 45/47] net/bnxt: tf_ulp: support a few feature extensions

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

This patch supports the following features.

add support for port table write operation
Added support for port table write operation from the
template so that template can write mirror id details into
the port database.

support generic template for socket direct
Support the socket direct feature, which is disabled by
default. User could  enable it with meson configuration
parameter truflow feature bit.

add support for truflow promiscuous mode
The truflow application supports promiscuous mode to enable
or disable receiving the packets with unknown destination
mac addresses.

set metadata for profile tcam entry
The metadata higher bits are currently used for profile
tcam entry. To make better use of EM entries, it is better
to use metadata fully instead of only the higher bits of
the metadata.

support the group miss action
Generic template supports the feature of setting group miss
action with the following rte command:

flow group 0 group_id 1 ingress set_miss_actions jump
 group 3 / end

fix some build failures
This change resolves a build issue seen on some OS's and
compiler versions.

Signed-off-by: Kishore Padmanabha 
Signed-off-by: Shuanglin Wang 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Michael Baucom 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h   |  31 +++
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c  |  27 ++-
 drivers/net/bnxt/tf_ulp/ulp_alloc_tbl.c  |   4 +
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c  | 286 ++-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c |  43 +++-
 drivers/net/bnxt/tf_ulp/ulp_port_db.c|  89 +++
 drivers/net/bnxt/tf_ulp/ulp_port_db.h|  28 +++
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c |  17 ++
 8 files changed, 520 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
index 758b9deb63..a35f79f167 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
@@ -92,9 +92,19 @@ enum bnxt_rte_flow_action_type {
BNXT_RTE_FLOW_ACTION_TYPE_LAST
 };
 
+#define BNXT_ULP_MAX_GROUP_CNT 8
+struct bnxt_ulp_grp_rule_info {
+   uint32_tgroup_id;
+   uint32_tflow_id;
+   uint8_t dir;
+   uint8_t valid;
+};
+
 struct bnxt_ulp_df_rule_info {
uint32_tdef_port_flow_id;
+   uint32_tpromisc_flow_id;
uint8_t valid;
+   struct bnxt_ulp_grp_rule_info   grp_df_rule[BNXT_ULP_MAX_GROUP_CNT];
 };
 
 struct bnxt_ulp_vfr_rule_info {
@@ -291,4 +301,25 @@ bnxt_ulp_cntxt_entry_acquire(void *arg);
 void
 bnxt_ulp_cntxt_entry_release(void);
 
+int32_t
+bnxt_ulp_promisc_mode_set(struct bnxt *bp, uint8_t enable);
+
+int32_t
+bnxt_ulp_set_prio_attribute(struct ulp_rte_parser_params *params,
+   const struct rte_flow_attr *attr);
+
+void
+bnxt_ulp_set_dir_attributes(struct ulp_rte_parser_params *params,
+   const struct rte_flow_attr *attr);
+
+void
+bnxt_ulp_init_parser_cf_defaults(struct ulp_rte_parser_params *params,
+uint16_t port_id);
+
+int32_t
+bnxt_ulp_grp_miss_act_set(struct rte_eth_dev *dev,
+ const struct rte_flow_attr *attr,
+ const struct rte_flow_action actions[],
+ uint32_t *flow_id);
+
 #endif /* _BNXT_ULP_H_ */
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
index eea05e129a..334eda99ce 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
@@ -66,7 +66,7 @@ bnxt_ulp_flow_validate_args(const struct rte_flow_attr *attr,
return BNXT_TF_RC_SUCCESS;
 }
 
-static inline void
+void
 bnxt_ulp_set_dir_attributes(struct ulp_rte_parser_params *params,
const struct rte_flow_attr *attr)
 {
@@ -86,7 +86,7 @@ bnxt_ulp_set_dir_attributes(struct ulp_rte_parser_params 
*params,
}
 }
 
-static int32_t
+int32_t
 bnxt_ulp_set_prio_attribute(struct ulp_rte_parser_params *params,
const struct rte_flow_attr *attr)
 {
@@ -117,7 +117,7 @@ bnxt_ulp_set_prio_attribute(struct ulp_rte_parser_params 
*params,
return 0;
 }
 
-static inline void
+void
 bnxt_ulp_init_parser_cf_defaults(struct ulp_rte_parser_params *params,
 uint16_t port_id)
 {
@@ -268,6 +268,26 @@ bnxt_ulp_init_mapper_params(struct bnxt_ulp_mapper_parms 
*mparms,
ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_SOCKET_DIRECT_VPORT,
(vport == 1) ? 2 : 1);
}
+
+   /* Update the socket direct svif when socket_

[PATCH v2 44/47] net/bnxt: tf_ulp: enable support for truflow feature configuration

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

Added truflow feature bit meson configuration parameter to enable
optional capability features of the appplication.

Signed-off-by: Kishore Padmanabha 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Shahaji Bhosle 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c|  6 -
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c   |  6 -
 drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h | 32 
 3 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
index c591f9327c..fa7e8fe000 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
@@ -476,7 +476,11 @@ ulp_tf_cntxt_app_caps_init(struct bnxt *bp,
   info[i].min_flow_priority);
bnxt_ulp_max_flow_priority_set(ulp_ctx,
   info[i].max_flow_priority);
-   ulp_ctx->cfg_data->feature_bits = info[i].feature_bits;
+   /* Update the capability feature bits*/
+   if (bnxt_ulp_cap_feat_process(info[i].feature_bits,
+ &ulp_ctx->cfg_data->feature_bits))
+   return -EINVAL;
+
bnxt_ulp_cntxt_ptr2_default_class_bits_set(ulp_ctx,
   
info[i].default_class_bits);
bnxt_ulp_cntxt_ptr2_default_act_bits_set(ulp_ctx,
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
index 31ab61b512..cc779826a5 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
@@ -536,7 +536,11 @@ ulp_tfc_cntxt_app_caps_init(struct bnxt *bp, uint8_t 
app_id, uint32_t dev_id)
"Socket Direct feature is 
enabled\n");
}
}
-   ulp_ctx->cfg_data->feature_bits = info[i].feature_bits;
+   /* Update the capability feature bits*/
+   if (bnxt_ulp_cap_feat_process(info[i].feature_bits,
+ &ulp_ctx->cfg_data->feature_bits))
+   return -EINVAL;
+
bnxt_ulp_default_app_priority_set(ulp_ctx,
  info[i].default_priority);
bnxt_ulp_max_def_priority_set(ulp_ctx,
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h
index 26087526e8..edc75da05e 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_utils.h
@@ -1035,4 +1035,36 @@ bnxt_ulp_vfr_session_fid_rem(struct bnxt_ulp_context 
*ulp_ctx,
return rc;
 }
 
+static inline int32_t
+bnxt_ulp_cap_feat_process(uint64_t feat_bits, uint64_t *out_bits)
+{
+#ifdef RTE_BNXT_TF_FEAT_BITS
+   uint64_t bit = RTE_BNXT_TF_FEAT_BITS;
+#else
+   uint64_t bit = 0;
+#endif
+
+   *out_bits = 0;
+   if ((feat_bits | bit) != feat_bits) {
+   BNXT_DRV_DBG(ERR, "Invalid TF feature bit is set %" PRIu64 "\n",
+bit);
+   return -EINVAL;
+   }
+   if ((bit & BNXT_ULP_FEATURE_BIT_PARENT_DMAC) &&
+   (bit & BNXT_ULP_FEATURE_BIT_PORT_DMAC)) {
+   BNXT_DRV_DBG(ERR, "Invalid both Port and Parent Mac set\n");
+   return -EINVAL;
+   }
+
+   if (bit & BNXT_ULP_FEATURE_BIT_PARENT_DMAC)
+   BNXT_DRV_DBG(ERR, "Parent Mac Address Feature is enabled\n");
+   if (bit & BNXT_ULP_FEATURE_BIT_PORT_DMAC)
+   BNXT_DRV_DBG(ERR, "Port Mac Address Feature is enabled\n");
+   if (bit & BNXT_ULP_FEATURE_BIT_MULTI_TUNNEL_FLOW)
+   BNXT_DRV_DBG(ERR, "Multi Tunnel Flow Feature is enabled\n");
+
+   *out_bits =  bit;
+   return 0;
+}
+
 #endif /* _BNXT_ULP_UTILS_H_ */
-- 
2.39.3



[PATCH v2 27/47] net/bnxt: tf_ulp: fixed parent child db counters

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

The locking for the parent child counters need to be done till the
stats are retrieved. Also the OVS is creating multiple F1 flows for
same tunnel hence reference count needs to be maintined for the F1
flows.

Fix name conflicts for class and action tables. Matcher allocates
hash tables for class and action entries. These tables should have
different names for each port.

Signed-off-by: Kishore Padmanabha 
Signed-off-by: Shuanglin Wang 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Michael Baucom 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c  | 37 +--
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 22 ++--
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h |  2 ++
 drivers/net/bnxt/tf_ulp/ulp_matcher.c | 12 +++--
 4 files changed, 50 insertions(+), 23 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c 
b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
index b880b545da..0c46c7d4c9 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
@@ -563,23 +563,29 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context 
*ctxt,
 
} while (!rc && nxt_resource_index);
 
-   bnxt_ulp_cntxt_release_fdb_lock(ctxt);
-
-   if (rc || !found_cntr_resource)
+   if (rc || !found_cntr_resource) {
+   bnxt_ulp_cntxt_release_fdb_lock(ctxt);
return rc;
+   }
 
dir = params.direction;
-   if (!(ulp_fc_info->flags & ULP_FLAG_FC_SW_AGG_EN))
-   return fc_ops->ulp_flow_stat_get(ctxt, dir,
-params.resource_hndl, count);
+   if (!(ulp_fc_info->flags & ULP_FLAG_FC_SW_AGG_EN)) {
+   rc = fc_ops->ulp_flow_stat_get(ctxt, dir,
+  params.resource_hndl, count);
+   bnxt_ulp_cntxt_release_fdb_lock(ctxt);
+   return rc;
+   }
 
if (!found_parent_flow &&
params.resource_sub_type ==
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TABLE_INT_COUNT) {
hw_cntr_id = params.resource_hndl;
-   if (!ulp_fc_info->num_counters)
-   return fc_ops->ulp_flow_stat_get(ctxt, dir,
-hw_cntr_id, count);
+   if (!ulp_fc_info->num_counters) {
+   rc = fc_ops->ulp_flow_stat_get(ctxt, dir,
+  hw_cntr_id, count);
+   bnxt_ulp_cntxt_release_fdb_lock(ctxt);
+   return rc;
+   }
 
/* TODO:
 * Think about optimizing with try_lock later
@@ -603,9 +609,14 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context 
*ctxt,
   params.resource_sub_type ==
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TABLE_INT_COUNT) {
/* Get stats from the parent child table */
-   ulp_flow_db_parent_flow_count_get(ctxt, pc_idx,
- &count->hits, &count->bytes,
- count->reset);
+   if (ulp_flow_db_parent_flow_count_get(ctxt, flow_id,
+ pc_idx,
+ &count->hits,
+ &count->bytes,
+ count->reset)) {
+   bnxt_ulp_cntxt_release_fdb_lock(ctxt);
+   return -EIO;
+   }
if (count->hits)
count->hits_set = 1;
if (count->bytes)
@@ -613,7 +624,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context 
*ctxt,
} else {
rc = -EINVAL;
}
-
+   bnxt_ulp_cntxt_release_fdb_lock(ctxt);
return rc;
 }
 
diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c 
b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
index 099ae7adc8..679dab0f17 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
@@ -836,7 +836,6 @@ ulp_flow_db_fid_free(struct bnxt_ulp_context *ulp_ctxt,
 #ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
BNXT_DRV_DBG(DEBUG, "flow_id = %u:%u freed\n", flow_type, fid);
 #endif
-
/* all good, return success */
return 0;
 }
@@ -1383,13 +1382,12 @@ ulp_flow_db_pc_db_parent_flow_set(struct 
bnxt_ulp_context *ulp_ctxt,
 
if (set_flag) {
pc_entry->parent_fid = parent_fid;
+   pc_entry->parent_ref_cnt++;
} else {
-   if (pc_entry->parent_fid != parent_fid)
-   BNXT_DRV_DBG(ERR, "Panic: invalid parent id\n");
-   pc_entry->parent_fid = 0;
-
+   if (pc_entry->parent_ref_cnt > 0)
+   pc_entry->parent_ref_cnt--;
/* Free the 

[PATCH v2 06/47] net/bnxt: tf_core: TF support flow scale query

2024-09-27 Thread Sriharsha Basavapatna
From: Shuanglin Wang 

TF supports the flow scale query feature for OVS application.
The resource usage is tracked when opening a TF session
or adding/deleting a flow. The resources includes WC TCAM,
EM, Action, Counter, Meter, ACT_ENCAP, ACT_ENCAP, and SP_SMAC.
User can query the resource usage using niccli.

Several improvements on flow scale query feature:
1. Some default rules require both RX and TX resources;
   need to update usage states on both direcitons.
2. Update resoure usage state for regular flows only.
3. Added a buffer dirty state to avoid unnecessary
   state sync with firmware.

This feature is disabled by default. Using the build flag
-DTF_FLOW_SCALE_QUERY to enable it.

Signed-off-by: Shuanglin Wang 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Ajit Khaparde 
Signed-off-by: Sriharsha Basavapatna 
---
 drivers/net/bnxt/hsi_struct_def_dpdk.h| 342 --
 drivers/net/bnxt/tf_core/cfa_tcam_mgr.c   |  57 +-
 .../net/bnxt/tf_core/cfa_tcam_mgr_device.h|   9 +
 .../net/bnxt/tf_core/cfa_tcam_mgr_session.c   |  13 +
 .../net/bnxt/tf_core/cfa_tcam_mgr_session.h   |   3 +
 drivers/net/bnxt/tf_core/meson.build  |   1 +
 drivers/net/bnxt/tf_core/tf_core.c| 150 +
 drivers/net/bnxt/tf_core/tf_core.h|  52 ++
 drivers/net/bnxt/tf_core/tf_device.h  |  65 ++
 drivers/net/bnxt/tf_core/tf_device_p4.c   |  10 +
 drivers/net/bnxt/tf_core/tf_device_p58.c  | 105 +++
 .../net/bnxt/tf_core/tf_em_hash_internal.c|  28 +-
 drivers/net/bnxt/tf_core/tf_em_internal.c |   7 +
 drivers/net/bnxt/tf_core/tf_msg.c | 175 +
 drivers/net/bnxt/tf_core/tf_msg.h |  57 ++
 drivers/net/bnxt/tf_core/tf_resources.c   | 608 ++
 drivers/net/bnxt/tf_core/tf_resources.h   | 129 
 drivers/net/bnxt/tf_core/tf_rm.c  |  39 +-
 drivers/net/bnxt/tf_core/tf_session.c |  10 +
 drivers/net/bnxt/tf_ulp/ulp_mapper.c  |  16 +
 20 files changed, 1806 insertions(+), 70 deletions(-)
 create mode 100644 drivers/net/bnxt/tf_core/tf_resources.c

diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 9beacd94aa..cec4b59d1a 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2014-2023 Broadcom Inc.
+ * Copyright (c) 2014-2024 Broadcom Inc.
  * All rights reserved.
  *
  * DO NOT MODIFY!!! This file is automatically generated.
@@ -836,6 +836,10 @@ struct cmd_nums {
#define HWRM_TF_IF_TBL_SETUINT32_C(0x2fe)
/* Experimental */
#define HWRM_TF_IF_TBL_GETUINT32_C(0x2ff)
+   /* Experimental */
+   #define HWRM_TF_RESC_USAGE_SETUINT32_C(0x300)
+   /* Experimental */
+   #define HWRM_TF_RESC_USAGE_QUERY  UINT32_C(0x301)
/* TruFlow command to check firmware table scope capabilities. */
#define HWRM_TFC_TBL_SCOPE_QCAPS  UINT32_C(0x380)
/* TruFlow command to allocate a table scope ID and create the pools. */
@@ -14960,32 +14964,18 @@ struct hwrm_func_qcaps_output {
uint16_txid_partition_cap;
/*
 * When this bit is '1', it indicates that FW is capable of
-* supporting partition based XID management for KTLS TX
+* supporting partition based XID management for Tx crypto
 * key contexts.
 */
-   #define HWRM_FUNC_QCAPS_OUTPUT_XID_PARTITION_CAP_KTLS_TKC \
+   #define HWRM_FUNC_QCAPS_OUTPUT_XID_PARTITION_CAP_TX_CK \
UINT32_C(0x1)
/*
 * When this bit is '1', it indicates that FW is capable of
-* supporting partition based XID management for KTLS RX
+* supporting partition based XID management for Rx crypto
 * key contexts.
 */
-   #define HWRM_FUNC_QCAPS_OUTPUT_XID_PARTITION_CAP_KTLS_RKC \
+   #define HWRM_FUNC_QCAPS_OUTPUT_XID_PARTITION_CAP_RX_CK \
UINT32_C(0x2)
-   /*
-* When this bit is '1', it indicates that FW is capable of
-* supporting partition based XID management for QUIC TX
-* key contexts.
-*/
-   #define HWRM_FUNC_QCAPS_OUTPUT_XID_PARTITION_CAP_QUIC_TKC \
-   UINT32_C(0x4)
-   /*
-* When this bit is '1', it indicates that FW is capable of
-* supporting partition based XID management for QUIC RX
-* key contexts.
-*/
-   #define HWRM_FUNC_QCAPS_OUTPUT_XID_PARTITION_CAP_QUIC_RKC \
-   UINT32_C(0x8)
/*
 * This value uniquely identifies the hardware NIC used by the
 * function. The value returned will be the same for all functions.
@@ -15804,8 +15794,21 @@ struct hwrm_func_qcfg_output {
 * initialize_fw.
 */
uint32_troce_max_gid_per_vf;
-   /* Bitmap of context typ

[PATCH v2 00/47] TruFlow update for Thor2

2024-09-27 Thread Sriharsha Basavapatna
This patch series introduces TruFlow functionality for Broadcom Thor2 NIC.

TruFlow(TF) is the software library that exposes CFA HW resources to
upper layer protocols or applications. This patch series implements the
tfc (tf_core) and the tf_ulp libraries as a part of the bnxt PMD,
so that upper layer APIs such as rte_flow can access the hardware.

**
v1->v2:
Update the below two patches to fix errors reported by DPDK CICD tests.
0011-net-bnxt-tfc-support-tf-core-for-Thor2.patch
0047-net-bnxt-tf_ulp-add-stats-cache-for-thor2.patch
**

Farah Smith (2):
  net/bnxt: tf_core: Thor TF EM key size check
  net/bnxt: tfc: support tf-core for Thor2

Jay Ding (2):
  net/bnxt: tf_ulp: add action read and clear support
  net/bnxt: tf_ulp: add rte_mtr support for Thor2

Kishore Padmanabha (21):
  net/bnxt: tf_core: flow scale improvement
  net/bnxt: tf_ulp: add support for vf to vf flow offload
  net/bnxt: tf_ulp: add support for overlapping flows
  net/bnxt: tf_ulp: convert recipe table to dynamic memory
  net/bnxt: tf_ulp: add feature bit support
  net/bnxt: tf_ulp: update template files
  net/bnxt: tf_ulp: add support for tunnel flow stats
  net/bnxt: tf_ulp: update template files
  net/bnxt: tf_ulp: enable recipe id generation
  net/bnxt: tf_ulp: fixed parent child db counters
  net/bnxt: tf_ulp: update template files
  net/bnxt: tf_ulp: add mask defaults when mask is not specified
  net/bnxt: tf_ulp: add jump action support
  net/bnxt: tf_ulp: add support for flow priority
  net/bnxt: tf_ulp: support for dynamic tunnel ports
  net/bnxt: tf_ulp: add track type feature to tables
  net/bnxt: tf_ulp: update template files
  net/bnxt: tf_ulp: support a few generic template items
  net/bnxt: tf_ulp: update template files
  net/bnxt: tf_ulp: enable support for truflow feature configuration
  net/bnxt: tf_ulp: support a few feature extensions

Manish Kurup (1):
  net/bnxt: tf_ulp: Wh+ mirroring support

Mike Baucom (2):
  net/bnxt: tf_ulp: miscellaneous fixes
  net/bnxt: tf_ulp: VFR updates for Thor 2

Peter Spreadborough (4):
  net/bnxt: tf_ulp: inline utility functions and use likely/unlikely
  net/bnxt: tf_ulp: switch ulp to use rte crc32 hash
  net/bnxt: update template files
  net/bnxt: tf_ulp: add stats cache for thor2

Randy Schacher (5):
  net/bnxt: tf_core: convert priority based TCAM manager to dynamic
allocation
  net/bnxt: tf_core: remove dead AFM code from session-based priority
TCAM mgr
  net/bnxt: tf_core: remove dead code from session-based priority TCAM
mgr
  net/bnxt: tf_ulp: add vxlan-gpe base support
  net/bnxt: tf_ulp: add support for rss flow query to ULP

Sangtani Parag Satishbhai (1):
  net/bnxt: tf_core: fix slice count in case of HA entry move

Shahaji Bhosle (3):
  net/bnxt: tf_core: fix wc tcam multi slice delete issue
  net/bnxt: tf_core: tcam manager data corruption
  net/bnxt: tf_ulp: add custom l2 etype tunnel support

Shuanglin Wang (6):
  net/bnxt: tf_core: External EM support cleanup
  net/bnxt: tf_core: TF support flow scale query
  net/bnxt: tf_ulp: support for Thor2 ulp layer
  net/bnxt: tf_ulp: modify return values to adhere to C coding standard
  net/bnxt: tf_ulp: TF support flow scale query
  net/bnxt: tf_ulp: TFC support flow scale query for Thor2

 drivers/net/bnxt/bnxt.h   |41 +-
 drivers/net/bnxt/bnxt_cpr.c   |63 +-
 drivers/net/bnxt/bnxt_cpr.h   |24 +-
 drivers/net/bnxt/bnxt_ethdev.c|   111 +-
 drivers/net/bnxt/bnxt_flow.c  | 5 +-
 drivers/net/bnxt/bnxt_hwrm.c  |   326 +-
 drivers/net/bnxt/bnxt_hwrm.h  |20 +
 drivers/net/bnxt/bnxt_mpc.c   |   844 +
 drivers/net/bnxt/bnxt_mpc.h   |   117 +
 drivers/net/bnxt/bnxt_reps.c  |   108 +-
 drivers/net/bnxt/bnxt_ring.c  |19 +-
 drivers/net/bnxt/bnxt_ring.h  |54 +-
 drivers/net/bnxt/bnxt_rxr.c   | 5 +-
 drivers/net/bnxt/bnxt_txr.c   |30 +-
 drivers/net/bnxt/bnxt_vnic.c  |39 +-
 drivers/net/bnxt/bnxt_vnic.h  | 8 +
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa.h|15 +-
 drivers/net/bnxt/hcapi/cfa/hcapi_cfa_defs.h   |   576 +-
 drivers/net/bnxt/hcapi/cfa_v3/CMakeLists.txt  |92 +
 .../bnxt/hcapi/cfa_v3/bld/host/cfa_bld_mpc.c  |42 +
 .../hcapi/cfa_v3/bld/include/cfa_bld_defs.h   |   578 +
 .../hcapi/cfa_v3/bld/include/host/cfa_bld.h   |   524 +
 .../cfa_v3/bld/include/host/cfa_bld_devops.h  |   297 +
 .../bld/include/host/cfa_bld_field_ids.h  |  1542 +
 .../bld/include/host/cfa_bld_mpc_field_ids.h  |  1286 +
 .../cfa_v3/bld/include/host/cfa_bld_mpcops.h  |   598 +
 .../cfa_v3/bld/include/p70/cfa_bld_p70_defs.h |   543 +
 .../bld/include/p70/cfa_bld_p70_field_ids.h   |  1542 +
 .../cfa_v3/bld/include/p70/cfa_bld_p70_mpc.h  |   548 +
 .../hcapi/cfa_v3/bld/include/p70/cfa_p70.h|   164 +
 .../hcapi/cfa

[PATCH v2 02/47] net/bnxt: tf_core: tcam manager data corruption

2024-09-27 Thread Sriharsha Basavapatna
From: Shahaji Bhosle 

Max entries per session were not getting initialized
to 0, when the sessions were closed.
Reset max entries counter session when the session is initialized

Fixes: 97435d7906d7 ("net/bnxt: update Truflow core")
Signed-off-by: Shahaji Bhosle 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Farah Smith 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Shuanglin Wang 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_core/cfa_tcam_mgr.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c 
b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
index f26d93e7a9..9df2d2b937 100644
--- a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
@@ -909,6 +909,7 @@ cfa_tcam_mgr_init(int sess_idx, enum 
cfa_tcam_mgr_device_type type,
/* Now calculate the max entries per table and global max entries based
 * on the updated table limits.
 */
+   cfa_tcam_mgr_max_entries[sess_idx] = 0;
for (dir = 0; dir < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx]); dir++)
for (tbl_type = 0;
 tbl_type < ARRAY_SIZE(cfa_tcam_mgr_tables[sess_idx][dir]);
@@ -958,8 +959,8 @@ cfa_tcam_mgr_init(int sess_idx, enum 
cfa_tcam_mgr_device_type type,
if (parms != NULL)
parms->max_entries = cfa_tcam_mgr_max_entries[sess_idx];
 
-   CFA_TCAM_MGR_LOG(INFO, "Global TCAM table initialized for sess_idx 
%d.\n",
-sess_idx);
+   CFA_TCAM_MGR_LOG(DEBUG, "Global TCAM table initialized for sess_idx %d 
max entries %d.\n",
+sess_idx, cfa_tcam_mgr_max_entries[sess_idx]);
 
return 0;
 }
-- 
2.39.3



[PATCH v2 16/47] net/bnxt: tf_ulp: miscellaneous fixes

2024-09-27 Thread Sriharsha Basavapatna
From: Mike Baucom 

Template compiler modifications for v3 api:
Compile named/unnamed shared app resources for the applications
that are capable.

Change app id signature with base zero offset:
The app id is used in the calculation of the matching signatures
and as app id value increases the output of the signature also
increases to keep up the scale, the app id is reset to zero based
offset. Also fix some whitespace errors.

Add support for vxlan-gpe:
Add support for enabling UPAR1 and UPAR2 to parse vxlan-gpe/nsh/ipv4
and vxlan-gpe/nsh/ipv6 packets for.

Default parif handling for single port cards:
Update Ingress default and offloaded flows to use driver
function parif, instead of physical port parif. We have cards
that use single physical port with two PFs on the same physical
port, this causes the default physical port parif to be over
written by the second PF. If you use driver function parif then
single port with more than one PF can use its own parif and not
step on each other.

Note: We cannot support TWO VFs on the same PF, because driver
function parif is based on PF fw id, so if two VFs on same PF
are offloading flows they will get the same driver function parifs
and this will interfere with each other.

Support vxlan flow with vxlan-gpe port:
The patch adds the APP_CAP_CUST_VXLAN flag, so that the app
can create a custom vxlan flow, instead of vxlan-gpe flow,
when the custom vxlan port is 4790.

Synchronize async event handler and Truflow init:
If Truflow is not initialized then bail out in async event handler
gracefully. Add a new macro ulp_is_default_session_active().

Reduce the log level from info to debug:
Default VFR action record get api in templates that do not support
VFR report an info message which looks like an error. But it is benign
and doesn't impact the functionality. So change the log level to
debug from info.

Read upar_in_use from tunnel_dst_port_alloc response:
This patch reads the upar_in_use field from
hwrm_tunnel_dst_port_alloc's response and stores inside the bp
structure.

Add API to configure hot upgrade:
This patch adds an API that can be called to configure hot upgrade.
If this API is not called then the driver relies on the environment
variable to configure the hot upgrade feature.

Add parser changes to support custom VxLAN:
This patch writes UPAR1 tunnel header type to the computational
field at index VXLAN_IP_UPAR_ID.

Free custom vxlan tunnel port:
The current code invokes ulp_cust_vxlan_free() while detaching
a port from the session. This is incorrect since it should be freed
only when the session reference count goes to zero. So move this
to bnxt_ulp_deinit().

Parse UDP dport 4789 as VxLAN conditionally:
Currently, the ULP parser is parsing UDP dport 4789 as VxLAN
unconditionally. However for some apps, the requirement may be to
consider UDP dport 4789 as non-tunnel. This patch fixes the problem
by parsing UDP dport 4789 as non-tunnel when needed.

Delete flow context for the port being deleted:
Flow manager is running in alarm thread and the main thread is
deleting the flow context causing garbage data to request flow
count. Delete the ulp context before deleting the flows so
that flow manager thread does not dereference invalid ulp context.

Validate ulp context while parsing L4 proto type:
In ulp_rte_l4_proto_type_update() we try to access bp->ulp_ctx
without checking if it is valid. Add error checking and return
if ulp_ctx has not been initialized. Otherwise it could crash
the application.

Fix a crash seen in bnxt_ulp_port_init(), in some conditions:
The function bnxt_ulp_init() invokes ulp_ha_mgr_open() which
could fail in some conditions. As part of the error processing and
cleanup, bnxt_ulp_deinit() is called which frees ulp_ctx->cfg_data.
When the control returns back to bnxt_ulp_port_init(), as part of
its error handling it invokes ulp_cust_vxlan_free(). There we end
up dereferencing ulp_ctx->cfg_data which is already freed.
Fix this by updating the code (macro) to check for validity of
cfg_data before accessing it.

Support 256 vf representors:
Extend ULP port database size
Reduce Rx WC tcam slices from 6860 to 6572
Convert Rx VF rep default action record type from FULL to Compact

Set the correct vxlan or vxlan-gpe header type:
Appropriately configure the vxlan or vxlan_gpe header bit when an
application supports any customer vxlan port. The initial code
erroneously configures both vxlan and vxlan_gpe header bits when
adding a vxlan flow with the vxlan_gpe port(4790).
Remove endian converting code for port id.

Free L2 Etype tunnel for each port stop:
Update the point where ulp_l2_etype_tunnel_free() is called in
bnxt_ulp_port_deinit().

Signed-off-by: Mike Baucom 
Signed

[PATCH v2 09/47] net/bnxt: tf_core: remove dead AFM code from session-based priority TCAM mgr

2024-09-27 Thread Sriharsha Basavapatna
From: Randy Schacher 

Remove references to AFM allocated memory which is no longer
supported with TCAM mgr and truflow

Signed-off-by: Randy Schacher 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Farah Smith 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_core/cfa_tcam_mgr.c | 121 
 drivers/net/bnxt/tf_core/cfa_tcam_mgr.h |  27 +-
 drivers/net/bnxt/tf_core/cfa_tcam_mgr_p4.c  | 320 +++-
 drivers/net/bnxt/tf_core/cfa_tcam_mgr_p58.c | 320 +++-
 drivers/net/bnxt/tf_core/tf_resources.c |   4 +-
 drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c  |  18 +-
 6 files changed, 143 insertions(+), 667 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c 
b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
index 165376182e..380e828da8 100644
--- a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
@@ -20,23 +20,23 @@
 #define TF_TCAM_SLICE_INVALID (-1)
 
 static int physical_table_types[CFA_TCAM_MGR_TBL_TYPE_MAX] = {
-   [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS] =
+   [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH] =
TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH,
-   [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS]  =
+   [CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW]  =
TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW,
-   [CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS]=
+   [CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM] =
TF_TCAM_TBL_TYPE_PROF_TCAM,
-   [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS]  =
+   [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM]   =
TF_TCAM_TBL_TYPE_WC_TCAM,
-   [CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS]  =
+   [CFA_TCAM_MGR_TBL_TYPE_SP_TCAM]   =
TF_TCAM_TBL_TYPE_SP_TCAM,
-   [CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS]  =
+   [CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM]  =
TF_TCAM_TBL_TYPE_CT_RULE_TCAM,
-   [CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS] =
+   [CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM]  =
TF_TCAM_TBL_TYPE_VEB_TCAM,
-   [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS] =
+   [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH] =
TF_TCAM_TBL_TYPE_WC_TCAM_HIGH,
-   [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS]  =
+   [CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW]  =
TF_TCAM_TBL_TYPE_WC_TCAM_LOW,
 };
 
@@ -53,41 +53,23 @@ const char *
 cfa_tcam_mgr_tbl_2_str(enum cfa_tcam_mgr_tbl_type tcam_type)
 {
switch (tcam_type) {
-   case CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_AFM:
-   return "l2_ctxt_tcam_high AFM";
-   case CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH_APPS:
+   case CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_HIGH:
return "l2_ctxt_tcam_high Apps";
-   case CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_AFM:
-   return "l2_ctxt_tcam_low AFM";
-   case CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW_APPS:
+   case CFA_TCAM_MGR_TBL_TYPE_L2_CTXT_TCAM_LOW:
return "l2_ctxt_tcam_low Apps";
-   case CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_AFM:
-   return "prof_tcam AFM";
-   case CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM_APPS:
+   case CFA_TCAM_MGR_TBL_TYPE_PROF_TCAM:
return "prof_tcam Apps";
-   case CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_AFM:
-   return "wc_tcam AFM";
-   case CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_APPS:
+   case CFA_TCAM_MGR_TBL_TYPE_WC_TCAM:
return "wc_tcam Apps";
-   case CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_AFM:
-   return "veb_tcam AFM";
-   case CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM_APPS:
+   case CFA_TCAM_MGR_TBL_TYPE_VEB_TCAM:
return "veb_tcam Apps";
-   case CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_AFM:
-   return "sp_tcam AFM";
-   case CFA_TCAM_MGR_TBL_TYPE_SP_TCAM_APPS:
+   case CFA_TCAM_MGR_TBL_TYPE_SP_TCAM:
return "sp_tcam Apps";
-   case CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_AFM:
-   return "ct_rule_tcam AFM";
-   case CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM_APPS:
+   case CFA_TCAM_MGR_TBL_TYPE_CT_RULE_TCAM:
return "ct_rule_tcam Apps";
-   case CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_AFM:
-   return "wc_tcam_high AFM";
-   case CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH_APPS:
+   case CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_HIGH:
return "wc_tcam_high Apps";
-   case CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_AFM:
-   return "wc_tcam_low AFM";
-   case CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW_APPS:
+   case CFA_TCAM_MGR_TBL_TYPE_WC_TCAM_LOW:
return "wc_tcam_low Apps";
default:
return "Invalid tcam table type";
@@ -972,10 +954,13 @@ cfa_tcam_mgr_bitmap_alloc(struct tf *tfp __rte_unused,
 
/* Allocate first index to avoid idx 0 */
first_idx = ba_alloc(tcam_mgr_data->session_bmp);
-   if (first_idx == BA_FAIL)
+

[PATCH v2 10/47] net/bnxt: tf_core: remove dead code from session-based priority TCAM mgr

2024-09-27 Thread Sriharsha Basavapatna
From: Randy Schacher 

Remove references to tx_tcam_supported and rx_tcam_supported
logic which chooses between FW-based tcam resource allocation
and driver-based tcam manager.

Signed-off-by: Randy Schacher 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Peter Spreadborough 
Reviewed-by: Manish Kurup 
Reviewed-by: Farah Smith 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_core/cfa_tcam_mgr.c|  46 
 drivers/net/bnxt/tf_core/cfa_tcam_mgr.h|  29 --
 drivers/net/bnxt/tf_core/tf_session.h  |   5 -
 drivers/net/bnxt/tf_core/tf_tcam.c | 294 +
 drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c |  28 --
 drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h |   6 -
 6 files changed, 8 insertions(+), 400 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c 
b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
index 380e828da8..3875a0b934 100644
--- a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
@@ -1079,52 +1079,6 @@ cfa_tcam_mgr_init(struct tf *tfp, enum 
cfa_tcam_mgr_device_type type,
return 0;
 }
 
-int
-cfa_tcam_mgr_qcaps(struct tf *tfp __rte_unused,
-  struct cfa_tcam_mgr_qcaps_parms *parms)
-{
-   struct cfa_tcam_mgr_data *tcam_mgr_data;
-   struct tf_session *tfs;
-   unsigned int type;
-   int rc;
-
-   CFA_TCAM_MGR_CHECK_PARMS2(tfp, parms);
-
-   rc = tf_session_get_session_internal(tfp, &tfs);
-   if (rc)
-   return rc;
-
-   tcam_mgr_data = tfs->tcam_mgr_handle;
-   if (!tcam_mgr_data) {
-   CFA_TCAM_MGR_LOG_0(ERR, "No TCAM data created for session.\n");
-   return -CFA_TCAM_MGR_ERR_CODE(PERM);
-   }
-
-   /*
-* This code will indicate if TCAM Manager is managing a logical TCAM
-* table or not.  If not, then the physical TCAM will have to be
-* accessed using the traditional methods.
-*/
-   parms->rx_tcam_supported = 0;
-   parms->tx_tcam_supported = 0;
-   for (type = 0; type < CFA_TCAM_MGR_TBL_TYPE_MAX; type++) {
-   if (tcam_mgr_data->cfa_tcam_mgr_tables[TF_DIR_RX]
-   [type].max_entries > 0 &&
-   tcam_mgr_data->cfa_tcam_mgr_tables[TF_DIR_RX]
-   [type].hcapi_type > 0)
-   parms->rx_tcam_supported |=
-   1 << cfa_tcam_mgr_get_phys_table_type(type);
-   if (tcam_mgr_data->cfa_tcam_mgr_tables[TF_DIR_TX]
-   [type].max_entries > 0 &&
-   tcam_mgr_data->cfa_tcam_mgr_tables[TF_DIR_TX]
-   [type].hcapi_type > 0)
-   parms->tx_tcam_supported |=
-   1 << cfa_tcam_mgr_get_phys_table_type(type);
-   }
-
-   return 0;
-}
-
 static
 int cfa_tcam_mgr_validate_tcam_cnt(struct tf *tfp  __rte_unused,
   struct cfa_tcam_mgr_data *tcam_mgr_data,
diff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h 
b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h
index 25654a8351..1cbd25e7d1 100644
--- a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h
+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h
@@ -122,18 +122,6 @@ struct cfa_tcam_mgr_init_parms {
uint32_t max_entries;
 };
 
-/**
- * TCAM Manager initialization parameters
- */
-struct cfa_tcam_mgr_qcaps_parms {
-   /**
-* [out] Bitmasks.  Set if TCAM Manager is managing a logical TCAM.
-* Each bitmask is indexed by logical TCAM table ID.
-*/
-   uint32_t rx_tcam_supported;
-   uint32_t tx_tcam_supported;
-};
-
 /**
  * TCAM Manager configuration parameters
  */
@@ -369,23 +357,6 @@ cfa_tcam_mgr_init(struct tf *tfp, enum 
cfa_tcam_mgr_device_type type,
 int
 cfa_tcam_mgr_get_phys_table_type(enum cfa_tcam_mgr_tbl_type type);
 
-/**
- * Queries the capabilities of TCAM Manager.
- *
- * [in] context
- *   Pointer to context information
- *
- * [out] parms
- *   Pointer to parameters to be returned
- *
- * Returns
- *   - (0) if successful.
- *   - (<0) on failure.
- */
-int
-cfa_tcam_mgr_qcaps(struct tf *tfp __rte_unused,
-  struct cfa_tcam_mgr_qcaps_parms *parms);
-
 /**
  * Initializes the TCAM module with the requested DBs. Must be
  * invoked as the first thing before any of the access functions.
diff --git a/drivers/net/bnxt/tf_core/tf_session.h 
b/drivers/net/bnxt/tf_core/tf_session.h
index d46d89e9e9..7668e9d0e0 100644
--- a/drivers/net/bnxt/tf_core/tf_session.h
+++ b/drivers/net/bnxt/tf_core/tf_session.h
@@ -174,11 +174,6 @@ struct tf_session {
 */
uint16_t wc_num_slices_per_row;
 
-   /**
-* Indicates if TCAM is controlled by TCAM Manager
-*/
-   int tcam_mgr_control[TF_DIR_MAX][TF_TCAM_TBL_TYPE_MAX];
-
/**
 * TCAM Manager handle pointing to session based tcam memory
 */
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c 
b/drivers/net/bnxt/tf_core/t

[PATCH v2 15/47] net/bnxt: tf_ulp: Wh+ mirroring support

2024-09-27 Thread Sriharsha Basavapatna
From: Manish Kurup 

1. ULP fixes to enable primitives to support mirroring
2. RTE parser changes to support and use multiple ports in RTE
   input msgs
3. Template changes required to support ingress mirroring
4. Template changes required to support egress mirroring
   (using VFR pipeline)

Signed-off-by: Manish Kurup 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c |   8 +
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 179 ---
 2 files changed, 167 insertions(+), 20 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c 
b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 9dda70d75b..eb0f95cfee 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -3789,6 +3789,8 @@ ulp_mapper_func_info_process(struct bnxt_ulp_mapper_parms 
*parms,
case BNXT_ULP_FUNC_OPC_GT:
case BNXT_ULP_FUNC_OPC_LE:
case BNXT_ULP_FUNC_OPC_LT:
+   case BNXT_ULP_FUNC_OPC_ADD:
+   case BNXT_ULP_FUNC_OPC_SUB:
process_src1 = 1;
process_src2 = 1;
break;
@@ -3841,6 +3843,12 @@ ulp_mapper_func_info_process(struct 
bnxt_ulp_mapper_parms *parms,
if (res1 < res2)
res = 1;
break;
+   case BNXT_ULP_FUNC_OPC_ADD:
+   res = res1 + res2;
+   break;
+   case BNXT_ULP_FUNC_OPC_SUB:
+   res = res1 - res2;
+   break;
case BNXT_ULP_FUNC_OPC_COPY_SRC1_TO_RF:
res = res1;
break;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c 
b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
index 013d8b0a59..da20b41c72 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -330,9 +330,21 @@ ulp_post_process_normal_flow(struct ulp_rte_parser_params 
*params)
 
/* Evaluate the VF to VF flag */
if (act_port_set && act_port_type == BNXT_ULP_INTF_TYPE_VF_REP &&
-   match_port_type == BNXT_ULP_INTF_TYPE_VF_REP)
-   ULP_BITMAP_SET(params->act_bitmap.bits,
-  BNXT_ULP_ACT_BIT_VF_TO_VF);
+match_port_type == BNXT_ULP_INTF_TYPE_VF_REP) {
+   if (!ULP_BITMAP_ISSET(params->act_bitmap.bits,
+ BNXT_ULP_ACT_BIT_MULTIPLE_PORT)) {
+   ULP_BITMAP_SET(params->act_bitmap.bits,
+  BNXT_ULP_ACT_BIT_VF_TO_VF);
+   } else {
+   if (ULP_COMP_FLD_IDX_RD(params, 
BNXT_ULP_CF_IDX_MP_A_IS_VFREP) &&
+   ULP_COMP_FLD_IDX_RD(params, 
BNXT_ULP_CF_IDX_MP_B_IS_VFREP))
+   ULP_BITMAP_SET(params->act_bitmap.bits,
+  BNXT_ULP_ACT_BIT_VF_TO_VF);
+   else
+   ULP_BITMAP_RESET(params->act_bitmap.bits,
+BNXT_ULP_ACT_BIT_VF_TO_VF);
+   }
+   }
 
/* Update the decrement ttl computational fields */
if (ULP_BITMAP_ISSET(params->act_bitmap.bits,
@@ -2349,15 +2361,74 @@ ulp_rte_count_act_handler(const struct rte_flow_action 
*action_item,
return BNXT_TF_RC_SUCCESS;
 }
 
+static bool ulp_rte_parser_is_portb_vfrep(struct ulp_rte_parser_params *param)
+{
+   return ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_B_IS_VFREP);
+}
+
+/*
+ * Swaps info related to multi-port:
+ * common:
+ *BNXT_ULP_CF_IDX_MP_B_IS_VFREP, BNXT_ULP_CF_IDX_MP_A_IS_VFREP
+ *BNXT_ULP_CF_IDX_MP_PORT_A, BNXT_ULP_CF_IDX_MP_PORT_B
+ *
+ * ingress:
+ *BNXT_ULP_CF_IDX_MP_VNIC_B, BNXT_ULP_CF_IDX_MP_VNIC_A
+ *
+ * egress:
+ *BNXT_ULP_CF_IDX_MP_MDATA_B, BNXT_ULP_CF_IDX_MP_MDATA_A
+ *BNXT_ULP_CF_IDX_MP_VPORT_B, BNXT_ULP_CF_IDX_MP_VPORT_A
+ *
+ * Note: This is done as OVS could give us a non-VFREP port in port B, and we
+ * cannot use that to mirror, so we swap out the ports so that a VFREP is now
+ * in port B instead.
+ */
+static int32_t
+ulp_rte_parser_normalize_port_info(struct ulp_rte_parser_params *param)
+{
+   uint16_t mp_port_a, mp_port_b, mp_mdata_a, mp_mdata_b,
+mp_vport_a, mp_vport_b, mp_vnic_a, mp_vnic_b,
+mp_is_vfrep_a, mp_is_vfrep_b;
+
+   mp_is_vfrep_a = ULP_COMP_FLD_IDX_RD(param, 
BNXT_ULP_CF_IDX_MP_A_IS_VFREP);
+   mp_is_vfrep_b = ULP_COMP_FLD_IDX_RD(param, 
BNXT_ULP_CF_IDX_MP_B_IS_VFREP);
+   ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_B_IS_VFREP, 
mp_is_vfrep_a);
+   ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_A_IS_VFREP, 
mp_is_vfrep_b);
+
+   mp_port_a = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_PORT_A);
+   mp_port_b = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_MP_PORT_B);
+   ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_MP_PORT_B, mp_port_a);
+   ULP_COMP_FLD_IDX_WR(param, BNXT_

Re: [PATCH v6 1/2] ethdev: Add link_speed lanes support

2024-09-27 Thread Ajit Khaparde
On Thu, Sep 26, 2024 at 5:39 PM Ferruh Yigit  wrote:
>
> On 9/26/2024 10:43 PM, Damodharam Ammepalli wrote:
> > Update the eth_dev_ops structure with new function vectors
> > to get, get capabilities and set ethernet link speed lanes.
> > Update the testpmd to provide required config and information
> > display infrastructure.
> >
> > The supporting ethernet controller driver will register callbacks
> > to avail link speed lanes config and get services. This lanes
> > configuration is applicable only when the nic is forced to fixed
> > speeds. In Autonegiation mode, the hardware automatically
> > negotiates the number of lanes.
> >
> > These are the new commands.
> >
> > testpmd> show port 0 speed_lanes capabilities
> >
> >  Supported speeds Valid lanes
> > ---
> >  10 Gbps  1
> >  25 Gbps  1
> >  40 Gbps  4
> >  50 Gbps  1 2
> >  100 Gbps 1 2 4
> >  200 Gbps 2 4
> >  400 Gbps 4 8
> > testpmd>
> >
> > testpmd>
> > testpmd> port stop 0
> > testpmd> port config 0 speed_lanes 4
> > testpmd> port config 0 speed 20 duplex full
> > testpmd> port start 0
> > testpmd>
> > testpmd> show port info 0
> >
> > * Infos for port 0  *
> > MAC address: 14:23:F2:C3:BA:D2
> > Device name: :b1:00.0
> > Driver name: net_bnxt
> > Firmware-version: 228.9.115.0
> > Connect to socket: 2
> > memory allocation on the socket: 2
> > Link status: up
> > Link speed: 200 Gbps
> > Active Lanes: 4
> > Link duplex: full-duplex
> > Autoneg status: Off
> >
> > Signed-off-by: Damodharam Ammepalli 
> >
>
> Reviewed-by: Ferruh Yigit 
Reviewed-by: Ajit Khaparde 

>
> Suggested patch title:
> ethdev: support link speed lanes
>
> <...>
>
> > +/**
> > + * @warning
> > + * @b EXPERIMENTAL: this API may change, or be removed, without prior 
> > notice
> > + *
> > + * Get Active lanes.
> > + *
> > + * @param port_id
> > + *   The port identifier of the Ethernet device.
> > + * @param lanes
> > + *   Driver updates lanes with the number of active lanes.
> > + *   On a supported NIC on link up, lanes will be a non-zero value 
> > irrespective whether the
> > + *   link is Autonegotiated or Fixed speed. No information is dispalyed 
> > for error.
> >
>
> s/dispalyed/displayed/
>
> I can fix while merging
>


smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PATCH v6 2/2] net/bnxt: code refactor for supporting speed lanes

2024-09-27 Thread Ajit Khaparde
On Thu, Sep 26, 2024 at 2:56 PM Damodharam Ammepalli
 wrote:
>
> Broadcom Thor2 NICs support link mode settings where user
> can configure fixed speed and associated supported number of
> lanes. This patch does code-refactoring to address proposed
> poll mode library design updates.
>
> Signed-off-by: Damodharam Ammepalli 
Reviewed-by: Ajit Khaparde 


smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH v2 25/47] net/bnxt: tf_ulp: update template files

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

This patch updates template files for the following list
of changes, that are being added in the next patch.

- enable recipe id generation
- fix segfault in the wildcard recipe process

Signed-off-by: Kishore Padmanabha 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Ajit Khaparde 
---
 .../generic_templates/ulp_template_db_enum.h  | 115 +++---
 .../generic_templates/ulp_template_db_tbl.c   |   8 +-
 .../ulp_template_db_thor2_class.c | 352 +++--
 .../ulp_template_db_thor_class.c  | 372 --
 4 files changed, 547 insertions(+), 300 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_enum.h 
b/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_enum.h
index 240acbc564..ddd65a62b1 100644
--- a/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_enum.h
+++ b/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_enum.h
@@ -6,7 +6,7 @@
 #ifndef ULP_TEMPLATE_DB_H_
 #define ULP_TEMPLATE_DB_H_
 
-#define BNXT_ULP_REGFILE_MAX_SZ 81
+#define BNXT_ULP_REGFILE_MAX_SZ 82
 #define BNXT_ULP_MAX_NUM_DEVICES 5
 #define BNXT_ULP_LOG2_MAX_NUM_DEV 2.32192809488736
 #define BNXT_ULP_GEN_TBL_MAX_SZ 50
@@ -31,19 +31,19 @@
 #define ULP_WH_PLUS_CLASS_COND_LIST_SIZE 50
 #define ULP_WH_PLUS_CLASS_COND_OPER_LIST_SIZE 0
 #define ULP_THOR_CLASS_TMPL_LIST_SIZE 5
-#define ULP_THOR_CLASS_TBL_LIST_SIZE 122
+#define ULP_THOR_CLASS_TBL_LIST_SIZE 126
 #define ULP_THOR_CLASS_KEY_INFO_LIST_SIZE 605
 #define ULP_THOR_CLASS_KEY_EXT_LIST_SIZE 615
-#define ULP_THOR_CLASS_IDENT_LIST_SIZE 39
-#define ULP_THOR_CLASS_RESULT_FIELD_LIST_SIZE 1248
+#define ULP_THOR_CLASS_IDENT_LIST_SIZE 43
+#define ULP_THOR_CLASS_RESULT_FIELD_LIST_SIZE 1252
 #define ULP_THOR_CLASS_COND_LIST_SIZE 3077
 #define ULP_THOR_CLASS_COND_OPER_LIST_SIZE 7
 #define ULP_THOR2_CLASS_TMPL_LIST_SIZE 5
-#define ULP_THOR2_CLASS_TBL_LIST_SIZE 121
+#define ULP_THOR2_CLASS_TBL_LIST_SIZE 125
 #define ULP_THOR2_CLASS_KEY_INFO_LIST_SIZE 665
 #define ULP_THOR2_CLASS_KEY_EXT_LIST_SIZE 628
-#define ULP_THOR2_CLASS_IDENT_LIST_SIZE 49
-#define ULP_THOR2_CLASS_RESULT_FIELD_LIST_SIZE 1512
+#define ULP_THOR2_CLASS_IDENT_LIST_SIZE 53
+#define ULP_THOR2_CLASS_RESULT_FIELD_LIST_SIZE 1516
 #define ULP_THOR2_CLASS_COND_LIST_SIZE 3298
 #define ULP_THOR2_CLASS_COND_OPER_LIST_SIZE 7
 #define ULP_WH_PLUS_ACT_TMPL_LIST_SIZE 11
@@ -699,8 +699,10 @@ enum bnxt_ulp_key_recipe_opc {
 
 enum bnxt_ulp_key_recipe_tbl_opc {
BNXT_ULP_KEY_RECIPE_TBL_OPC_NOT_USED = 0,
-   BNXT_ULP_KEY_RECIPE_TBL_OPC_WR_REGFILE = 1,
-   BNXT_ULP_KEY_RECIPE_TBL_OPC_LAST = 2
+   BNXT_ULP_KEY_RECIPE_TBL_OPC_ALLOC_REGFILE = 1,
+   BNXT_ULP_KEY_RECIPE_TBL_OPC_ALLOC_WR_REGFILE = 2,
+   BNXT_ULP_KEY_RECIPE_TBL_OPC_WR_REGFILE = 3,
+   BNXT_ULP_KEY_RECIPE_TBL_OPC_LAST = 4
 };
 
 enum bnxt_ulp_mark_db_opc {
@@ -795,53 +797,54 @@ enum bnxt_ulp_rf_idx {
BNXT_ULP_RF_IDX_HDR_SIG_ID = 32,
BNXT_ULP_RF_IDX_FLOW_SIG_ID = 33,
BNXT_ULP_RF_IDX_RID = 34,
-   BNXT_ULP_RF_IDX_RID_1 = 35,
-   BNXT_ULP_RF_IDX_WC_KEY_ID_0 = 36,
-   BNXT_ULP_RF_IDX_EM_KEY_ID_0 = 37,
-   BNXT_ULP_RF_IDX_DRV_FUNC_MAC = 38,
-   BNXT_ULP_RF_IDX_DRV_FUNC_PARENT_MAC = 39,
-   BNXT_ULP_RF_IDX_DEFAULT_AREC_PTR = 40,
-   BNXT_ULP_RF_IDX_CC = 41,
-   BNXT_ULP_RF_IDX_CF_FLOW_SIG_ID = 42,
-   BNXT_ULP_RF_IDX_PHY_PORT = 43,
-   BNXT_ULP_RF_IDX_METADATA_PROF = 44,
-   BNXT_ULP_RF_IDX_MODIFY_PTR = 45,
-   BNXT_ULP_RF_IDX_SOCK_DIR_SVIF = 46,
-   BNXT_ULP_RF_IDX_SOCK_DIR_PARIF = 47,
-   BNXT_ULP_RF_IDX_SOCK_DIR_ACT_PTR = 48,
-   BNXT_ULP_RF_IDX_SOCK_DIR_PARENT_MAC = 49,
-   BNXT_ULP_RF_IDX_RSS_VNIC = 50,
-   BNXT_ULP_RF_IDX_PORT_IS_PF = 51,
-   BNXT_ULP_RF_IDX_METER_PROFILE_PTR_0 = 52,
-   BNXT_ULP_RF_IDX_METER_PTR_0 = 53,
-   BNXT_ULP_RF_IDX_REF_CNT = 54,
-   BNXT_ULP_RF_IDX_RF_0 = 55,
-   BNXT_ULP_RF_IDX_RF_1 = 56,
-   BNXT_ULP_RF_IDX_RF_2 = 57,
-   BNXT_ULP_RF_IDX_RF_3 = 58,
-   BNXT_ULP_RF_IDX_RF_4 = 59,
-   BNXT_ULP_RF_IDX_RF_5 = 60,
-   BNXT_ULP_RF_IDX_RF_6 = 61,
-   BNXT_ULP_RF_IDX_RF_7 = 62,
-   BNXT_ULP_RF_IDX_CMM_ACT_HNDL = 63,
-   BNXT_ULP_RF_IDX_CMM_STAT_HNDL = 64,
-   BNXT_ULP_RF_IDX_CMM_MOD_HNDL = 65,
-   BNXT_ULP_RF_IDX_CMM_ENC_HNDL = 66,
-   BNXT_ULP_RF_IDX_CMM_SRP_HNDL = 67,
-   BNXT_ULP_RF_IDX_VF_FUNC_METADATA = 68,
-   BNXT_ULP_RF_IDX_CHAIN_ID_METADATA = 69,
-   BNXT_ULP_RF_IDX_RECYCLE_CNT = 70,
-   BNXT_ULP_RF_IDX_DEST_VNIC = 71,
-   BNXT_ULP_RF_IDX_DEST_VPORT = 72,
-   BNXT_ULP_RF_IDX_DEST_METADATA = 73,
-   BNXT_ULP_RF_IDX_PROF_TCAM_PRI = 74,
-   BNXT_ULP_RF_IDX_EM_INSERT_FAIL = 75,
-   BNXT_ULP_RF_IDX_PROF_TCAM_PRIORITY = 76,
-   BNXT_ULP_RF_IDX_TERM_FLOW = 77,
-   BNXT_ULP_RF_IDX_O_DMAC = 78,
-   BNXT_ULP_RF_IDX_FLOW_CNTR_PTR_F1 = 79,
-   BNXT_ULP_RF_IDX_CMM_STAT_HNDL_F1 = 80,
-   BNXT_ULP_RF_IDX_LAST = 81
+

[PATCH v2 23/47] net/bnxt: tf_ulp: VFR updates for Thor 2

2024-09-27 Thread Sriharsha Basavapatna
From: Mike Baucom 

Update to VFR code to:
- add the endpoint (efid) to the session
- modify the generic tables to write the l2 context id
- tfc session code changes to allow the efid to be added to the sid
- release both rfid and efid from afm

This patch includes a few related changes:

Thor2 change the counter get to clear on request
Allow the caller to either clear on read or simply read based
on their request.

Reject duplicate EM flow entry
It is not necessary to add an duplicate EM entry to WC.
This change will reject it.

Signed-off-by: Mike Baucom 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Farah Smith 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt_ethdev.c   |  15 +++
 drivers/net/bnxt/bnxt_reps.c |  60 +---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c   |  28 ++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h   |  12 +++
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c|   2 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c   | 114 ++-
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c |  11 ++-
 drivers/net/bnxt/tf_ulp/ulp_mapper_tfc.c |  33 ++-
 8 files changed, 229 insertions(+), 46 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 2c638193a5..aac487bdb2 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1800,6 +1800,21 @@ int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 
/* Initialize bnxt ULP port details */
if (bnxt_enable_ulp(bp)) {
+   if (BNXT_CHIP_P7(bp)) {
+   /* Need to release the Fid from AFM control */
+   rc = bnxt_hwrm_release_afm_func(bp, bp->fw_fid,
+   bp->fw_fid,
+   
HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_RFID,
+   0);
+   if (rc) {
+   PMD_DRV_LOG(ERR,
+   "Failed in hwrm release afm func:%u 
rc=%d\n",
+   bp->fw_fid, rc);
+   goto error;
+   }
+   PMD_DRV_LOG(DEBUG, "Released RFID:%d\n", bp->fw_fid);
+   }
+
rc = bnxt_ulp_port_init(bp);
if (rc)
goto error;
diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index 701f75f53c..f058f1aac2 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -34,7 +34,7 @@ static const struct eth_dev_ops bnxt_rep_dev_ops = {
 
 static bool bnxt_rep_check_parent(struct bnxt_representor *rep)
 {
-   if (!rep->parent_dev->data->dev_private)
+   if (!rep->parent_dev->data || !rep->parent_dev->data->dev_private)
return false;
 
return true;
@@ -357,28 +357,41 @@ static int bnxt_tf_vfr_alloc(struct rte_eth_dev 
*vfr_ethdev)
rc = bnxt_hwrm_release_afm_func(parent_bp,
vfr->fw_fid,
parent_bp->fw_fid,
-   HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_RFID,
+   HWRM_CFA_RELEASE_AFM_FUNC_INPUT_TYPE_EFID,
0);
 
-   if (rc)
+   if (rc) {
PMD_DRV_LOG(ERR,
-   "Failed in hwrm release afm func:%u rc=%d\n",
-   vfr->vf_id, rc);
+   "Failed to release EFID:%d from RFID:%d rc=%d\n",
+   vfr->vf_id, parent_bp->fw_fid, rc);
+   goto error_del_rules;
+   }
+   PMD_DRV_LOG(DEBUG, "Released EFID:%d from RFID:%d\n",
+   vfr->fw_fid, parent_bp->fw_fid);
+
} else {
rc = bnxt_hwrm_cfa_pair_alloc(parent_bp, vfr);
-   if (rc)
+   if (rc) {
PMD_DRV_LOG(ERR,
"Failed in hwrm vfr alloc vfr:%u rc=%d\n",
vfr->vf_id, rc);
+   goto error_del_rules;
+   }
}
 
+   /* if supported, it will add the vfr endpoint to the session, otherwise
+* it returns success
+*/
+   rc = bnxt_ulp_vfr_session_fid_add(parent_bp->ulp_ctx, vfr->fw_fid);
if (rc)
-   (void)bnxt_ulp_delete_vfr_default_rules(vfr);
+   goto error_del_rules;
else
PMD_DRV_LOG(DEBUG,
"BNXT Port:%d VFR created and initialized\n",
vfr->dpdk_port_id);
-
+   return rc;
+error_del_rules:
+   (void)bnxt_ulp_delete_vfr_default_rules(vfr);
return rc;
 }
 
@@ -489,8 +502,29 @@ int bnxt_rep_dev_start_op(struct

[PATCH v2 19/47] net/bnxt: tf_ulp: convert recipe table to dynamic memory

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

Converted the recipe table allocation from static model to dynamic
memory allocation model.

Signed-off-by: Kishore Padmanabha 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Michael Baucom 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c | 175 +++
 drivers/net/bnxt/tf_ulp/ulp_mapper.h |   5 +-
 2 files changed, 97 insertions(+), 83 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c 
b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 7045efffad..a7b35bf292 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -1280,65 +1280,71 @@ ulp_mapper_field_opc_next(struct bnxt_ulp_mapper_parms 
*parms,
 static void
 ulp_mapper_key_recipe_tbl_deinit(struct bnxt_ulp_mapper_data *mdata)
 {
+   struct bnxt_ulp_key_recipe_entry **recipes;
enum bnxt_ulp_direction dir;
+   uint32_t idx, ftype;
+
+   /* If recipe table is not initialized then exit */
+   if (!mdata->key_recipe_info.num_recipes)
+   return;
 
for (dir = 0; dir < BNXT_ULP_DIRECTION_LAST; dir++) {
-   rte_free(mdata->key_recipe_info.em_recipes[dir]);
-   rte_free(mdata->key_recipe_info.wc_recipes[dir]);
+   for (ftype = 0; ftype < ULP_RECIPE_TYPE_MAX; ftype++) {
+   recipes = mdata->key_recipe_info.recipes[dir][ftype];
+   for (idx = 0; idx < mdata->key_recipe_info.num_recipes;
+ idx++) {
+   if (recipes[idx])
+   rte_free(recipes[idx]);
+   }
+   rte_free(mdata->key_recipe_info.recipes[dir][ftype]);
+   mdata->key_recipe_info.recipes[dir][ftype] =  NULL;
+   }
}
+   mdata->key_recipe_info.num_recipes = 0;
 }
 
 static int32_t
 ulp_mapper_key_recipe_tbl_init(struct bnxt_ulp_context *ulp_ctx,
   struct bnxt_ulp_mapper_data *mdata)
 {
-   struct bnxt_ulp_key_recipe_entry *recipes;
+   struct bnxt_ulp_key_recipe_entry **recipes;
enum bnxt_ulp_direction dir;
-   uint32_t dev_id = 0;
-   uint32_t num_recipes;
+   uint32_t dev_id = 0, size_val;
+   uint32_t num_recipes, ftype;
int32_t rc = 0;
 
rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id);
if (rc) {
BNXT_DRV_DBG(ERR, "Unable to get device id from ulp.\n");
-   return rc;
+   return -EINVAL;
}
num_recipes = bnxt_ulp_num_key_recipes_get(ulp_ctx);
if (!num_recipes)
-   return 0;
+   return rc;
 
+   size_val = sizeof(struct bnxt_ulp_key_recipe_entry *);
for (dir = 0; dir < BNXT_ULP_DIRECTION_LAST; dir++) {
-   recipes = rte_zmalloc("key_recipe_em",
-  sizeof(struct bnxt_ulp_key_recipe_entry) *
-  num_recipes, 0);
-   if (!recipes)
-   goto error;
-   mdata->key_recipe_info.em_recipes[dir] = recipes;
-
-   recipes = rte_zmalloc("key_recipe_wc",
-  sizeof(struct bnxt_ulp_key_recipe_entry) *
-  num_recipes, 0);
-   if (!recipes)
-   goto error;
-   mdata->key_recipe_info.wc_recipes[dir] = recipes;
+   for (ftype = 0; ftype < ULP_RECIPE_TYPE_MAX; ftype++) {
+   recipes = rte_zmalloc("key_recipe_list",
+ size_val * num_recipes, 0);
+   if (!recipes) {
+   BNXT_DRV_DBG(ERR, "Uanable to alloc memory\n");
+   return -ENOMEM;
+   }
+   mdata->key_recipe_info.recipes[dir][ftype] = recipes;
+   }
}
-
mdata->key_recipe_info.num_recipes = num_recipes;
mdata->key_recipe_info.max_fields = BNXT_ULP_KEY_RECIPE_MAX_FLDS;
-
-   return 0;
-error:
-   (void)ulp_mapper_key_recipe_tbl_deinit(mdata);
-   return -ENOMEM;
+   return rc;
 }
 
-static struct bnxt_ulp_key_recipe_entry *
-ulp_mapper_key_recipe_entry_get(struct bnxt_ulp_context *ulp_ctx,
-   enum bnxt_ulp_direction dir,
-   enum bnxt_ulp_resource_sub_type stype,
-   uint8_t recipe_id, uint8_t *max_fields)
+static struct bnxt_ulp_mapper_data *
+ulp_mapper_key_recipe_args_validate(struct bnxt_ulp_context *ulp_ctx,
+   enum bnxt_ulp_direction dir,
+   enum bnxt_ulp_resource_sub_type stype,
+   uint8_t recipe_id)
 {
-   struct bnxt_ulp_key_recipe_entry *recipes;
struct bnxt_ulp_mapper_data *mdata;
 
mdata = (struct bn

Re: [PATCH v1] ethdev: fix int overflow in descriptor count logic

2024-09-27 Thread Ferruh Yigit
On 9/27/2024 11:46 AM, Meade, Niall wrote:
>> On 9/26/2024 3:03 PM, Meade, Niall wrote:
 From: Ferruh Yigit 
 Sent: Thursday, September 26, 2024 12:16 AM
 To: Meade, Niall ; Thomas Monjalon 
 ; Andrew Rybchenko ; 
 Roman Zhukov 
 Cc: dev@dpdk.org 
 Subject: Re: [PATCH v1] ethdev: fix int overflow in descriptor count logic
>>> 
> The resolution involves upcasting nb_desc to a uint32_t before the
> RTE_ALIGN_CEIL macro is applied. This change ensures that the subsequent
> call to RTE_ALIGN_FLOOR(nb_desc + (nb_align - 1), nb_align) does not
> result in an overflow, as it would when nb_desc is a uint16_t. By using
> a uint32_t for these operations, the correct behavior is maintained
> without the risk of overflow.
>

 Hi Niall,
>>>
>>> Hi Ferruh,
>>>
 Thanks for the patch.

 For the 'RTE_ALIGN_CEIL(val, align)' macro, 'align' should be power of
 two, as 'desc_lim->nb_align' is uint16_t, max value it can get is 2^15.
 'val' should be smaller than or equal to 'align', so '*nb_desc' can be
 maximum 2^15.

 So RTE_ALIGN_CEIL(2^15-1, 2^15) = 2^15, I think this should work fine
 (although I didn't test).

 And even with your uint32_t cast, I think following will fail:
 RTE_ALIGN_CEIL(2^16-1, 2^15)
 (again, not tested).

>>>
>>> I tested my code with these values and the behaviour is as expected from
>>> what I can see.
>>> At a high level I ran into this issue when passing uint16_tMAX into
>>> rte_eth_dev_adjust_nb_rx_tx_desc() with the intent of selecting the maximum
>>> ring descriptor size but the minimum was selected.
>>>
 Or maybe I am missing a case, can you please give some actual numbers to
 show the problem and the fix?
>>>
>>> Yes sure! If we take an example of val= (2^16)-1 and align= 32.
>>> RTE_ALIGN_CEIL(val, align) calls RTE_ALIGN_FLOOR(val + align - 1, align). 
>>> With
>>> val as a uint16_t this subsequent macro call results in a wrap around for 
>>> val
>>> (originally was the max uint16_t and now we are attempting to add align to
>>> it). The returned value of RTE_ALIGN_CEIL() in this case is 0. This results 
>>> in
>>> nb_desc being set to 0, and later set to the minimum ring descriptor size 
>>> for
>>> that NIC with *nb_desc = RTE_MAX(*nb_desc, desc_lim->nb_min).
>>>
>>> While this example is an unreasonably large request for a descriptor ring 
>>> size,
>>> the expected behaviour would be that the descriptor ring size defaults back 
>>> to
>>> the maximum possible for that particular NIC, not to the minimum which it
>>> currently does.
>>> By introducing a uint32_t, the wrap around in RTE_ALIGN_FLOOR() is avoided,
>>> keeping the large value of nb_desc_32 which is later set to an appropriate 
>>> size
>>> in RTE_MIN(*nb_desc_32, desc_lim->nb_max)
>>>
>>
>> I see the problem now, thanks.
>>
>> When value > (2^16 - align), next aligned value is 2^16, which is
>> UINT16_MAX + 1, hence wraps to 0, this is kind of expected.
>>
>> For the relevant code, assuming 'desc_lim->nb_max' & 'desc_lim->nb_min'
>> are already aligned to 'desc_lim->nb_align', following should fix the
>> issue, that seems simpler to me, what do you think:
> 
> Yes, while it is a simpler solution there is still potential for an overflow 
> if nb_max
> is equal to 0. If nb_max is 0 while nb_desc is UINT16_MAX, UINT16_MAX will be
> passed to the align macro resulting in an overflow again.
> 

ack

>>
>> ```
>> if (desc_lim->nb_max != 0)
>>     *nb_desc = RTE_MIN(*nb_desc, desc_lim->nb_max);
>>
>> nb_desc_32 = RTE_MAX(nb_desc_32, desc_lim->nb_min);
>>
>> if (desc_lim->nb_align != 0)
>>     *nb_desc = RTE_ALIGN_CEIL(*nb_desc, desc_lim->nb_align);
>> ```
>>
>> Basically just changing the order of the operations...
>>
>> It is not easy to see the problem, can you please give sample values in
>> the commit log (for '*nb_desc', 'nb_align', 'nb_max' & 'nb_min'), that
>> makes much easier to see why above works.
> 
> Yes, good idea! I'll add an example to the commit log for clarity.
> --
> Intel Research and Development Ireland Limited
> Registered in Ireland
> Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
> Registered Number: 308263
> 
> 
> This e-mail and any attachments may contain confidential material for the sole
> use of the intended recipient(s). Any review or distribution by others is
> strictly prohibited. If you are not the intended recipient, please contact the
> sender and delete all copies.
> 



Re: [PATCH v9 0/8] support dump reigster names and filter

2024-09-27 Thread Ferruh Yigit
On 9/26/2024 1:42 PM, Jie Hai wrote:
> The registers can be dumped through the API rte_eth_dev_get_reg_info.
> However, only register values are exported, which is inconvenient for
> users to interpret. Therefore, an extension of the structure
> "rte_dev_reg_info" and a new API rte_eth_dev_get_reg_info_ext is added
> to support the capability of exporting the name of the corresponding
> register and filtering by module names.
> 
> --
> v9:
> 1. add Acked-by.
> 2. fix typo and inaccurate expression of hns3.rst.
> 
> v8:
> 1. fix typo on patch[0/8].
> 2. add Reviewed-bys and Acked-bys.
> 3. fix potentital memory leak and error information on telemetry.
> 4. fix on reviews about hns3 driver.
> 
> v7: fix doc indention.
> --
> 
> Jie Hai (8):
>   ethdev: support report register names and filter
>   ethdev: add telemetry cmd for registers
>   net/hns3: remove some basic address dump
>   net/hns3: fix dump counter of registers
>   net/hns3: remove separators between register module
>   net/hns3: refactor register dump
>   net/hns3: support report names of registers
>   net/hns3: support filter registers by module names
>

Series applied to dpdk-next-net/main, thanks.


[PATCH v2 13/47] net/bnxt: tf_ulp: add custom l2 etype tunnel support

2024-09-27 Thread Sriharsha Basavapatna
From: Shahaji Bhosle 

Add hooks in the hwrm and ulp layer to enable,
custom tunnel header support on wh+ generic app(ovs).

Signed-off-by: Shahaji Bhosle 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt.h|  4 +++
 drivers/net/bnxt/bnxt_hwrm.c   | 18 ++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 54 ++
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h |  3 ++
 4 files changed, 79 insertions(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 00123e51ac..b905d9fd3e 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -988,13 +988,17 @@ struct bnxt {
uint8_t vxlan_port_cnt;
uint8_t geneve_port_cnt;
uint8_t ecpri_port_cnt;
+   uint8_t l2_etype_tunnel_cnt;
uint16_tvxlan_port;
uint16_tgeneve_port;
uint16_tecpri_port;
uint16_tvxlan_fw_dst_port_id;
uint16_tgeneve_fw_dst_port_id;
uint16_tecpri_fw_dst_port_id;
+#define BNXT_L2_ETYPE_TUNNEL_ID 0x /* CUSTOM L2 ENCAP - VF representors */
+   uint16_tl2_etype_tunnel_id;
uint16_tecpri_upar_in_use;
+   uint8_t l2_etype_upar_in_use;
uint32_tfw_ver;
uint32_thwrm_spec_code;
 
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 4e62dbbcca..778488ce1a 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -3515,6 +3515,10 @@ bnxt_free_tunnel_ports(struct bnxt *bp)
if (bp->ecpri_port_cnt)
bnxt_hwrm_tunnel_dst_port_free(bp, bp->ecpri_fw_dst_port_id,
HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_ECPRI);
+
+   if (bp->l2_etype_tunnel_cnt)
+   bnxt_hwrm_tunnel_dst_port_free(bp, bp->l2_etype_tunnel_id,
+   HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_L2_ETYPE);
 }
 
 void bnxt_free_all_hwrm_resources(struct bnxt *bp)
@@ -4811,6 +4815,10 @@ int bnxt_hwrm_tunnel_dst_port_alloc(struct bnxt *bp, 
uint16_t port,
bp->ecpri_port = port;
bp->ecpri_upar_in_use = resp->upar_in_use;
break;
+   case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE:
+   bp->l2_etype_tunnel_id = port;
+   bp->l2_etype_upar_in_use = resp->upar_in_use;
+   break;
default:
break;
}
@@ -4841,6 +4849,9 @@ int bnxt_hwrm_tunnel_upar_id_get(struct bnxt *bp, uint8_t 
*upar_id,
case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_SRV6:
*upar_id = resp->upar_in_use;
break;
+   case HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE:
+   *upar_id = resp->upar_in_use;
+   break;
default:
/* INVALID UPAR Id if another tunnel type tries to retrieve */
*upar_id = 0xff;
@@ -4887,6 +4898,13 @@ int bnxt_hwrm_tunnel_dst_port_free(struct bnxt *bp, 
uint16_t port,
bp->ecpri_port_cnt = 0;
}
 
+   if (tunnel_type ==
+   HWRM_TUNNEL_DST_PORT_FREE_INPUT_TUNNEL_TYPE_L2_ETYPE) {
+   bp->l2_etype_tunnel_cnt = 0;
+   bp->l2_etype_tunnel_id = 0;
+   bp->l2_etype_upar_in_use = 0;
+   }
+
bnxt_hwrm_set_tpa(bp);
return rc;
 }
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 96a5353aaf..912946303a 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -454,6 +454,10 @@ bnxt_ulp_cntxt_app_caps_init(struct bnxt *bp,
}
}
 
+   if (info[i].flags & BNXT_ULP_APP_CAP_L2_ETYPE)
+   ulp_ctx->cfg_data->ulp_flags |=
+   BNXT_ULP_APP_L2_ETYPE;
+
bnxt_ulp_vxlan_ip_port_set(ulp_ctx, info[i].vxlan_ip_port);
bnxt_ulp_vxlan_port_set(ulp_ctx, info[i].vxlan_port);
bnxt_ulp_ecpri_udp_port_set(ulp_ctx, info[i].ecpri_udp_port);
@@ -1795,6 +1799,29 @@ bnxt_ulp_init(struct bnxt *bp,
return rc;
 }
 
+static int
+ulp_l2_etype_tunnel_alloc(struct bnxt *bp)
+{
+   int rc = 0;
+
+   if (!ULP_APP_L2_ETYPE_SUPPORT(bp->ulp_ctx))
+   return rc;
+
+   if (bp->l2_etype_tunnel_cnt) {
+   BNXT_TF_DBG(DEBUG, "L2 ETYPE Custom Tunnel already 
allocated\n");
+   return rc;
+   }
+   rc = bnxt_tunnel_dst_port_alloc(bp,
+   BNXT_L2_ETYPE_TUNNEL_ID,
+   
HWRM_TUNNEL_DST_PORT_ALLOC_INPUT_TUNNEL_TYPE_L2_ETYPE);
+   if (rc)
+   BNXT_TF_DBG(ERR, "Failed to set global L2 ETYPE Custo

[PATCH v2 01/47] net/bnxt: tf_core: fix wc tcam multi slice delete issue

2024-09-27 Thread Sriharsha Basavapatna
From: Shahaji Bhosle 

FW tries to update the HWRM request data in the
delete case to update the mode bit and also
update invalid profile id. This update only
happens when the data is send over DMA. HWRM
requests are read only buffers and cannot be
updated. So driver now will always send WC
tcam set message over DMA channel.

Update tunnel alloc apis to provide error message.

Fixes: ca5e61bd562d ("net/bnxt: support EM and TCAM lookup with table scope")
Reviewed-by: Randy Schacher 
Reviewed-by: Kishore Padmanabha 
Signed-off-by: Shahaji Bhosle 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_core/tf_msg.c  | 28 +++---
 drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c | 18 --
 2 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_msg.c 
b/drivers/net/bnxt/tf_core/tf_msg.c
index 1c66c7e01a..4aa90f6b07 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -1612,20 +1612,20 @@ tf_msg_tcam_entry_set(struct tf *tfp,
req.result_size = parms->result_size;
data_size = 2 * req.key_size + req.result_size;
 
-   if (data_size <= TF_PCI_BUF_SIZE_MAX) {
-   /* use pci buffer */
-   data = &req.dev_data[0];
-   } else {
-   /* use dma buffer */
-   req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DMA;
-   rc = tf_msg_alloc_dma_buf(&buf, data_size);
-   if (rc)
-   goto cleanup;
-   data = buf.va_addr;
-   tfp_memcpy(&req.dev_data[0],
-  &buf.pa_addr,
-  sizeof(buf.pa_addr));
-   }
+   /*
+* Always use dma buffer, as the delete multi slice
+* tcam entries not support with HWRM request buffer
+* only DMA'ed buffer can update the mode bits for
+* the delete to work
+*/
+   req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DMA;
+   rc = tf_msg_alloc_dma_buf(&buf, data_size);
+   if (rc)
+   goto cleanup;
+   data = buf.va_addr;
+   tfp_memcpy(&req.dev_data[0],
+  &buf.pa_addr,
+  sizeof(buf.pa_addr));
 
tfp_memcpy(&data[0], parms->key, parms->key_size);
tfp_memcpy(&data[parms->key_size], parms->mask, parms->key_size);
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c 
b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
index 96d61c3ed2..7e4952c062 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
@@ -32,9 +32,17 @@ bnxt_tunnel_dst_port_alloc(struct bnxt *bp,
   uint16_t port,
   uint8_t type)
 {
-   return bnxt_hwrm_tunnel_dst_port_alloc(bp,
+   int rc = 0;
+   rc = bnxt_hwrm_tunnel_dst_port_alloc(bp,
   port,
   type);
+   if (rc) {
+   PMD_DRV_LOG(ERR, "Tunnel type:%d alloc failed for port:%d 
error:%s\n",
+   type, port,
+   (rc == 
HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_ERROR_INFO_ERR_ALLOCATED) ?
+   "already allocated" : "no resource");
+   }
+   return rc;
 }
 
 int
@@ -589,7 +597,13 @@ bnxt_pmd_global_tunnel_set(uint16_t port_id, uint8_t type,
}
 
rc = bnxt_hwrm_tunnel_dst_port_alloc(bp, udp_port, hwtype);
-   if (!rc) {
+   if (rc) {
+   PMD_DRV_LOG(ERR, "Tunnel type:%d alloc failed for 
port:%d error:%s\n",
+   hwtype, udp_port,
+   (rc ==
+
HWRM_TUNNEL_DST_PORT_ALLOC_OUTPUT_ERROR_INFO_ERR_ALLOCATED) ?
+   "already allocated" : "no resource");
+   } else {
ulp_global_tunnel_db[type].ref_cnt++;
ulp_global_tunnel_db[type].dport = udp_port;
bnxt_pmd_global_reg_data_to_hndl(port_id, 
bp->ecpri_upar_in_use,
-- 
2.39.3



[PATCH 09/16] net/e1000: fix use-after-free

2024-09-27 Thread Stephen Hemminger
The driver cleanup code was freeing the filter object
then dereferencing it.

Bugzilla ID: 1550
Fixes: 6a4d050e2855 ("net/igb: flush all the filter")
Cc: wei.zh...@intel.com
Cc: sta...@dpdk.org

Signed-off-by: Stephen Hemminger 
---
 drivers/net/e1000/igb_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 095be27b08..973d0d2407 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -3907,11 +3907,11 @@ igb_delete_2tuple_filter(struct rte_eth_dev *dev,
 
filter_info->twotuple_mask &= ~(1 << filter->index);
TAILQ_REMOVE(&filter_info->twotuple_list, filter, entries);
-   rte_free(filter);
 
E1000_WRITE_REG(hw, E1000_TTQF(filter->index), E1000_TTQF_DISABLE_MASK);
E1000_WRITE_REG(hw, E1000_IMIR(filter->index), 0);
E1000_WRITE_REG(hw, E1000_IMIREXT(filter->index), 0);
+   rte_free(filter);
return 0;
 }
 
@@ -4348,7 +4348,6 @@ igb_delete_5tuple_filter_82576(struct rte_eth_dev *dev,
 
filter_info->fivetuple_mask &= ~(1 << filter->index);
TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
-   rte_free(filter);
 
E1000_WRITE_REG(hw, E1000_FTQF(filter->index),
E1000_FTQF_VF_BP | E1000_FTQF_MASK);
@@ -4357,6 +4356,7 @@ igb_delete_5tuple_filter_82576(struct rte_eth_dev *dev,
E1000_WRITE_REG(hw, E1000_SPQF(filter->index), 0);
E1000_WRITE_REG(hw, E1000_IMIR(filter->index), 0);
E1000_WRITE_REG(hw, E1000_IMIREXT(filter->index), 0);
+   rte_free(filter);
return 0;
 }
 
-- 
2.45.2



Re: [PATCH v7 1/1] dts: add text parser for testpmd verbose output

2024-09-27 Thread Juraj Linkeš




On 26. 9. 2024 17:47, jspew...@iol.unh.edu wrote:

From: Jeremy Spewock 

Multiple test suites from the old DTS framework rely on being able to
consume and interpret the verbose output of testpmd. The new framework
doesn't have an elegant way for handling the verbose output, but test
suites are starting to be written that rely on it. This patch creates a
TextParser class that can be used to extract the verbose information
from any testpmd output and also adjusts the `stop` method of the shell
to return all output that it collected.

Signed-off-by: Jeremy Spewock 
---


Reviewed-by: Juraj Linkeš 


Re: [PATCH v4 1/1] dts: Remove XML-RPC server for Scapy TG and instead use PythonShell

2024-09-27 Thread Juraj Linkeš




+Note that the order of inheritance is important for this class. In order 
to instantiate this
+class, the abstract methods of 
:class:`~.capturing_traffic_generator.CapturingTrafficGenerator`
+must be implemented. Since some of these methods are implemented in the 
underlying interactive
+shell, according to Python's Method Resolution Order (MRO), the 
interactive shell must come
+first.


I didn't notice this before. Is this because of the close() method? Do
we need to add any special steps to close the TG? Closing the
interactive session should be enough, but I wanted to check with you.


Yes it is because of the close method in the traffic generator. I
think closing the shell should be all we need to do really, there
isn't anything else this traffic generator is really using on the
host.



Ok, thanks. We can keep it this way then.



[PATCH v7 4/8] compress/zsda: configure drivers of compressdev

2024-09-27 Thread Hanxiao Li
Add drivers and some interfaces of zsda compressdev.

Signed-off-by: Hanxiao Li 
---
 MAINTAINERS   |   4 +
 drivers/common/zsda/meson.build   |  12 +-
 drivers/compress/zsda/zsda_comp.c | 392 ++
 drivers/compress/zsda/zsda_comp.h |  52 +++
 drivers/compress/zsda/zsda_comp_pmd.c | 451 ++
 drivers/compress/zsda/zsda_comp_pmd.h |  39 +++
 6 files changed, 949 insertions(+), 1 deletion(-)
 create mode 100644 drivers/compress/zsda/zsda_comp.c
 create mode 100644 drivers/compress/zsda/zsda_comp.h
 create mode 100644 drivers/compress/zsda/zsda_comp_pmd.c
 create mode 100644 drivers/compress/zsda/zsda_comp_pmd.h

diff --git a/MAINTAINERS b/MAINTAINERS
index c5a703b5c0..e38e6589f7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1268,6 +1268,10 @@ F: drivers/compress/zlib/
 F: doc/guides/compressdevs/zlib.rst
 F: doc/guides/compressdevs/features/zlib.ini
 
+ZTE Storage Data Accelerator(ZSDA)
+M: Hanxiao Li 
+F: drivers/common/zsda/
+F: drivers/compress/zsda/
 
 DMAdev Drivers
 --
diff --git a/drivers/common/zsda/meson.build b/drivers/common/zsda/meson.build
index 4d1eec8867..1fed5a7f78 100644
--- a/drivers/common/zsda/meson.build
+++ b/drivers/common/zsda/meson.build
@@ -7,10 +7,20 @@ if is_windows
 subdir_done()
 endif
 
-deps += ['bus_pci']
+deps += ['bus_pci', 'compressdev']
 sources += files(
'zsda_common.c',
'zsda_logs.c',
'zsda_device.c',
'zsda_qp.c',
)
+
+zsda_compress = true
+zsda_compress_path = 'compress/zsda'
+zsda_compress_relpath = '../../' + zsda_compress_path
+includes += include_directories(zsda_compress_relpath)
+if zsda_compress
+   foreach f: ['zsda_comp_pmd.c', 'zsda_comp.c']
+   sources += files(join_paths(zsda_compress_relpath, f))
+   endforeach
+endif
diff --git a/drivers/compress/zsda/zsda_comp.c 
b/drivers/compress/zsda/zsda_comp.c
new file mode 100644
index 00..6355c566c8
--- /dev/null
+++ b/drivers/compress/zsda/zsda_comp.c
@@ -0,0 +1,392 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#include "zsda_comp.h"
+
+#define ZLIB_HEADER_SIZE 2
+#define ZLIB_TRAILER_SIZE 4
+#define GZIP_HEADER_SIZE 10
+#define GZIP_TRAILER_SIZE 8
+#define CHECKSUM_SIZE 4
+
+static uint32_t zsda_read_chksum(uint8_t *data_addr, uint8_t op_code,
+uint32_t produced);
+
+
+#define POLYNOMIAL 0xEDB88320
+static uint32_t crc32_table[8][256];
+static int table_config;
+
+static void
+build_crc32_table(void)
+{
+   for (uint32_t i = 0; i < 256; i++) {
+   uint32_t crc = i;
+   for (uint32_t j = 0; j < 8; j++)
+   crc = (crc >> 1) ^ ((crc & 1) ? POLYNOMIAL : 0);
+   crc32_table[0][i] = crc;
+   }
+
+   for (int i = 1; i < 8; i++) {
+   for (uint32_t j = 0; j < 256; j++)
+   crc32_table[i][j] = (crc32_table[i-1][j] >> 8) ^
+   crc32_table[0][crc32_table[i-1][j] & 
0xFF];
+   }
+   table_config = 1;
+}
+
+static uint32_t
+zsda_crc32(const uint8_t *data, size_t length)
+{
+   uint32_t crc = 0x;
+
+   if (!table_config)
+   build_crc32_table();
+
+   while (length >= 8) {
+   crc ^= *(const uint32_t *)data;
+   crc = crc32_table[7][crc & 0xFF] ^
+ crc32_table[6][(crc >> 8) & 0xFF] ^
+ crc32_table[5][(crc >> 16) & 0xFF] ^
+ crc32_table[4][(crc >> 24) & 0xFF] ^
+ crc32_table[3][data[4]] ^
+ crc32_table[2][data[5]] ^
+ crc32_table[1][data[6]] ^
+ crc32_table[0][data[7]];
+
+   data += 8;
+   length -= 8;
+   }
+
+   for (size_t i = 0; i < length; i++)
+   crc = (crc >> 8) ^ crc32_table[0][(crc ^ data[i]) & 0xFF];
+
+   return crc ^ 0x;
+}
+
+#define MOD_ADLER 65521
+#define NMAX 5552
+static uint32_t
+zsda_adler32(const uint8_t *buf, uint32_t len)
+{
+   uint32_t s1 = 1;
+   uint32_t s2 = 0;
+
+   while (len > 0) {
+   uint32_t k = (len < NMAX) ? len : NMAX;
+   len -= k;
+
+   for (uint32_t i = 0; i < k; i++) {
+   s1 += buf[i];
+   s2 += s1;
+   }
+
+   s1 %= MOD_ADLER;
+   s2 %= MOD_ADLER;
+
+   buf += k;
+   }
+
+   return (s2 << 16) | s1;
+}
+
+int
+zsda_comp_match(const void *op_in)
+{
+   const struct rte_comp_op *op = op_in;
+   const struct zsda_comp_xform *xform = op->private_xform;
+
+   if (op->op_type != RTE_COMP_OP_STATELESS)
+   return 0;
+
+   if (xform->type != RTE_COMP_COMPRESS)
+   return 0;
+
+   return 1;
+}
+
+static uint8_t
+get_opc

[PATCH v2 29/47] net/bnxt: tf_ulp: update template files

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

This patch updates template files for the following list
of changes, that are being added in the next patch.

dynamic support for VF representor mode (template files only)
The configurable VF representor mode is removed and it is
dynamic. The action record is not populated for packets
transmitted to network, only packets being sent to VF rep
are sent with action records in the mbuf.

Thor2 priority for l2 tcam records not adhered to

Signed-off-by: Kishore Padmanabha 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Michael Baucom 
Reviewed-by: Ajit Khaparde 
---
 .../generic_templates/ulp_template_db_enum.h  |8 +-
 .../ulp_template_db_thor2_class.c |   28 +-
 .../ulp_template_db_thor_class.c  | 1748 +++--
 3 files changed, 1116 insertions(+), 668 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_enum.h 
b/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_enum.h
index ddd65a62b1..21972cc4ea 100644
--- a/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_enum.h
+++ b/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_enum.h
@@ -31,12 +31,12 @@
 #define ULP_WH_PLUS_CLASS_COND_LIST_SIZE 50
 #define ULP_WH_PLUS_CLASS_COND_OPER_LIST_SIZE 0
 #define ULP_THOR_CLASS_TMPL_LIST_SIZE 5
-#define ULP_THOR_CLASS_TBL_LIST_SIZE 126
-#define ULP_THOR_CLASS_KEY_INFO_LIST_SIZE 605
+#define ULP_THOR_CLASS_TBL_LIST_SIZE 120
+#define ULP_THOR_CLASS_KEY_INFO_LIST_SIZE 646
 #define ULP_THOR_CLASS_KEY_EXT_LIST_SIZE 615
 #define ULP_THOR_CLASS_IDENT_LIST_SIZE 43
-#define ULP_THOR_CLASS_RESULT_FIELD_LIST_SIZE 1252
-#define ULP_THOR_CLASS_COND_LIST_SIZE 3077
+#define ULP_THOR_CLASS_RESULT_FIELD_LIST_SIZE 1253
+#define ULP_THOR_CLASS_COND_LIST_SIZE 3075
 #define ULP_THOR_CLASS_COND_OPER_LIST_SIZE 7
 #define ULP_THOR2_CLASS_TMPL_LIST_SIZE 5
 #define ULP_THOR2_CLASS_TBL_LIST_SIZE 125
diff --git 
a/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_thor2_class.c 
b/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_thor2_class.c
index 99c56fea0c..bef9e7571c 100644
--- a/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_thor2_class.c
+++ b/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_thor2_class.c
@@ -290,8 +290,8 @@ struct bnxt_ulp_mapper_tbl_info ulp_thor2_class_tbl_list[] 
= {
.key_recipe_opcode = BNXT_ULP_KEY_RECIPE_OPC_NOP,
.fdb_opcode = BNXT_ULP_FDB_OPC_PUSH_RID_REGFILE,
.fdb_operand = BNXT_ULP_RF_IDX_RID,
-   .pri_opcode  = BNXT_ULP_PRI_OPC_APP_PRI_OR_CONST,
-   .pri_operand = ULP_THOR2_SYM_L2_CTXT_PRI_APP,
+   .pri_opcode  = BNXT_ULP_PRI_OPC_CONST,
+   .pri_operand = 140,
.ident_start_idx = 10,
.ident_nums = 1
},
@@ -310,8 +310,8 @@ struct bnxt_ulp_mapper_tbl_info ulp_thor2_class_tbl_list[] 
= {
.key_recipe_opcode = BNXT_ULP_KEY_RECIPE_OPC_NOP,
.fdb_opcode = BNXT_ULP_FDB_OPC_PUSH_RID_REGFILE,
.fdb_operand = BNXT_ULP_RF_IDX_RID,
-   .pri_opcode  = BNXT_ULP_PRI_OPC_APP_PRI_OR_CONST,
-   .pri_operand = ULP_THOR2_SYM_L2_CTXT_PRI_APP,
+   .pri_opcode  = BNXT_ULP_PRI_OPC_CONST,
+   .pri_operand = 140,
.key_start_idx = 15,
.blob_key_bit_size = 256,
.key_bit_size = 256,
@@ -17602,7 +17602,9 @@ struct bnxt_ulp_mapper_key_info 
ulp_thor2_class_key_info_list[] = {
.description = "loopback",
.field_bit_size = 1,
.field_opc = BNXT_ULP_FIELD_OPC_SRC1,
-   .field_src1 = BNXT_ULP_FIELD_SRC_ZERO
+   .field_src1 = BNXT_ULP_FIELD_SRC_ONES,
+   .field_opr1 = {
+   0xff}
},
.field_info_spec = {
.description = "loopback",
@@ -30502,17 +30504,13 @@ struct bnxt_ulp_mapper_key_info 
ulp_thor2_class_key_info_list[] = {
.description = "tun_hdr_type",
.field_bit_size = 5,
.field_opc = BNXT_ULP_FIELD_OPC_SRC1,
-   .field_src1 = BNXT_ULP_FIELD_SRC_CONST,
-   .field_opr1 = {
-   ULP_THOR2_SYM_TUN_HDR_TYPE_NONE}
+   .field_src1 = BNXT_ULP_FIELD_SRC_ZERO
},
.field_info_spec = {
.description = "tun_hdr_type",
.field_bit_size = 5,
.field_opc = BNXT_ULP_FIELD_OPC_SRC1,
-   .field_src1 = BNXT_ULP_FIELD_SRC_CONST,
-   .field_opr1 = {
-   ULP_THOR2_SYM_TUN_HDR_TYPE_NONE}
+   .field_src1 = BNXT_ULP_FIELD_SRC_ZERO
}
},
{
@@ -30520,17 +30518,13 @@ struct bnxt_ulp_mapper_key_info 
ulp_thor2_class_key_info_list[] = {
.description = "out_tun_hdr_type",
.field_bit_size = 5,
.field_opc = BNXT_ULP_FIELD_OPC_SRC1,
-   .field_src1 = BNXT_ULP_FIELD_SRC_CONST,
-   .field_opr1 = {
-   ULP_THOR2_SYM_TU

[PATCH v2 28/47] net/bnxt: tf_ulp: modify return values to adhere to C coding standard

2024-09-27 Thread Sriharsha Basavapatna
From: Shuanglin Wang 

Modified return values of the several ULP utilities to comply C
coding standard.  Like using macros EXIT_SUCCESS(0) and
EXIT_FAILURE(1) for the conventional status value for success
and failure, respectively. They are declared in the file stdlib.h.

Signed-off-by: Shuanglin Wang 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/ulp_mapper.c | 172 +++
 drivers/net/bnxt/tf_ulp/ulp_mapper_tf.c  |  40 +++---
 drivers/net/bnxt/tf_ulp/ulp_mapper_tfc.c |  50 +++
 drivers/net/bnxt/tf_ulp/ulp_utils.c  |  70 -
 drivers/net/bnxt/tf_ulp/ulp_utils.h  |  26 ++--
 5 files changed, 181 insertions(+), 177 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c 
b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index b44b25429f..ff57469aa3 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -573,7 +573,7 @@ ulp_mapper_fdb_opc_process(struct bnxt_ulp_mapper_parms 
*parms,
/* get the fid from the regfile */
rc = ulp_regfile_read(parms->regfile, tbl->fdb_operand,
  &val64);
-   if (!rc) {
+   if (rc) {
BNXT_DRV_DBG(ERR, "regfile[%d] read oob\n",
 tbl->fdb_operand);
return -EINVAL;
@@ -630,8 +630,8 @@ ulp_mapper_priority_opc_process(struct 
bnxt_ulp_mapper_parms *parms,
*priority = tbl->pri_operand;
break;
case BNXT_ULP_PRI_OPC_REGFILE:
-   if (!ulp_regfile_read(parms->regfile, tbl->pri_operand,
- ®val)) {
+   if (ulp_regfile_read(parms->regfile, tbl->pri_operand,
+®val)) {
BNXT_DRV_DBG(ERR, "regfile[%u] read oob\n",
 tbl->pri_operand);
rc = -EINVAL;
@@ -880,8 +880,8 @@ ulp_mapper_field_src_process(struct bnxt_ulp_mapper_parms 
*parms,
*value = 1;
break;
case BNXT_ULP_FIELD_SRC_CF:
-   if (!ulp_operand_read(field_opr,
- (uint8_t *)&idx, sizeof(uint16_t))) {
+   if (ulp_operand_read(field_opr,
+(uint8_t *)&idx, sizeof(uint16_t))) {
BNXT_DRV_DBG(ERR, "CF operand read failed\n");
return -EINVAL;
}
@@ -896,15 +896,15 @@ ulp_mapper_field_src_process(struct bnxt_ulp_mapper_parms 
*parms,
*value = ULP_COMP_FLD_IDX_RD(parms, idx);
break;
case BNXT_ULP_FIELD_SRC_RF:
-   if (!ulp_operand_read(field_opr,
- (uint8_t *)&idx, sizeof(uint16_t))) {
+   if (ulp_operand_read(field_opr,
+(uint8_t *)&idx, sizeof(uint16_t))) {
BNXT_DRV_DBG(ERR, "RF operand read failed\n");
return -EINVAL;
}
 
idx = tfp_be_to_cpu_16(idx);
/* Uninitialized regfile entries return 0 */
-   if (!ulp_regfile_read(parms->regfile, idx, &lregval) ||
+   if (ulp_regfile_read(parms->regfile, idx, &lregval) ||
sizeof(uint64_t) < bytelen) {
BNXT_DRV_DBG(ERR, "regfile[%d] read oob %u\n", idx,
 bytelen);
@@ -915,8 +915,8 @@ ulp_mapper_field_src_process(struct bnxt_ulp_mapper_parms 
*parms,
*value = tfp_be_to_cpu_64(lregval);
break;
case BNXT_ULP_FIELD_SRC_ACT_PROP:
-   if (!ulp_operand_read(field_opr,
- (uint8_t *)&idx, sizeof(uint16_t))) {
+   if (ulp_operand_read(field_opr,
+(uint8_t *)&idx, sizeof(uint16_t))) {
BNXT_DRV_DBG(ERR, "Action operand read failed\n");
return -EINVAL;
}
@@ -940,8 +940,8 @@ ulp_mapper_field_src_process(struct bnxt_ulp_mapper_parms 
*parms,
}
break;
case BNXT_ULP_FIELD_SRC_ACT_PROP_SZ:
-   if (!ulp_operand_read(field_opr,
- (uint8_t *)&idx, sizeof(uint16_t))) {
+   if (ulp_operand_read(field_opr,
+(uint8_t *)&idx, sizeof(uint16_t))) {
BNXT_DRV_DBG(ERR, "Action sz operand read failed\n");
return -EINVAL;
}
@@ -954,8 +954,8 @@ ulp_mapper_field_src_process(struct bnxt_ulp_mapper_parms 
*parms,
*val = &parms->act_prop->act_details[idx];
 
/* get the size index next */
-   if (!ulp_operand_read(&field_opr[sizeof(uint1

[PATCH v2 26/47] net/bnxt: tf_ulp: enable recipe id generation

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

Added support to generate recipe id generation.

This patch includes a few related changes:

fix segfault in the wildcard recipe process
The recipe id is being passed as 8 bit instead of 64bit
causing the crash.

Ported code using default_non_ha resource
Missing code to use default_non_ha resource if HA is
disabled.

fix move debug message from info to debug level
The action pointer does not exist for non representor ports
so it is a debug message.

Signed-off-by: Kishore Padmanabha 
Signed-off-by: Shuanglin Wang 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Shahaji Bhosle 
Reviewed-by: Michael Baucom 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c |   4 +
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c |   2 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper.c  | 257 +++---
 drivers/net/bnxt/tf_ulp/ulp_mapper.h  |   2 +
 4 files changed, 196 insertions(+), 69 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
index 2d46d21a5d..0cc2b4e81d 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
@@ -257,6 +257,10 @@ ulp_tf_resources_get(struct bnxt_ulp_context *ulp_ctx,
return -EINVAL;
}
 
+   /* use DEFAULT_NON_HA instead of DEFAULT resources if HA is disabled */
+   if (ULP_APP_HA_IS_DYNAMIC(ulp_ctx))
+   stype = ulp_ctx->cfg_data->def_session_type;
+
unnamed = bnxt_ulp_resource_resv_list_get(&unum);
if (unnamed == NULL) {
BNXT_DRV_DBG(ERR, "Unable to get resource resv list.\n");
diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c 
b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
index 82a653594f..099ae7adc8 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
@@ -1198,7 +1198,7 @@ ulp_default_flow_db_cfa_action_get(struct 
bnxt_ulp_context *ulp_ctx,
 BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE,
 sub_typ, ¶ms);
if (rc) {
-   BNXT_DRV_DBG(INFO, "CFA Action ptr not found for flow id %u\n",
+   BNXT_DRV_DBG(DEBUG, "CFA Action ptr not found for flow id %u\n",
 flow_id);
return -ENOENT;
}
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c 
b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index e399c136f3..b44b25429f 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -1302,7 +1302,9 @@ ulp_mapper_key_recipe_tbl_deinit(struct 
bnxt_ulp_mapper_data *mdata)
rte_free(recipes[idx]);
}
rte_free(mdata->key_recipe_info.recipes[dir][ftype]);
-   mdata->key_recipe_info.recipes[dir][ftype] =  NULL;
+   mdata->key_recipe_info.recipes[dir][ftype] = NULL;
+   rte_free(mdata->key_recipe_info.recipe_ba[dir][ftype]);
+   mdata->key_recipe_info.recipe_ba[dir][ftype] = NULL;
}
}
mdata->key_recipe_info.num_recipes = 0;
@@ -1315,8 +1317,9 @@ ulp_mapper_key_recipe_tbl_init(struct bnxt_ulp_context 
*ulp_ctx,
struct bnxt_ulp_key_recipe_entry **recipes;
enum bnxt_ulp_direction dir;
uint32_t dev_id = 0, size_val;
-   uint32_t num_recipes, ftype;
+   uint32_t num_recipes, ftype, pool_size;
int32_t rc = 0;
+   struct bitalloc *recipe_ba;
 
rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id);
if (rc) {
@@ -1327,20 +1330,43 @@ ulp_mapper_key_recipe_tbl_init(struct bnxt_ulp_context 
*ulp_ctx,
if (!num_recipes)
return rc;
 
+   /* Need to write these values so that a failure will result in freeing
+* the memory in the deinit
+*/
+   mdata->key_recipe_info.num_recipes = num_recipes;
+   mdata->key_recipe_info.max_fields = BNXT_ULP_KEY_RECIPE_MAX_FLDS;
+
size_val = sizeof(struct bnxt_ulp_key_recipe_entry *);
+   pool_size = BITALLOC_SIZEOF(num_recipes);
+
+   /* The caller will deinit if failures occur, so just return fail instead
+* of attempting to free allocated memory
+**/
for (dir = 0; dir < BNXT_ULP_DIRECTION_LAST; dir++) {
for (ftype = 0; ftype < ULP_RECIPE_TYPE_MAX; ftype++) {
recipes = rte_zmalloc("key_recipe_list",
  size_val * num_recipes, 0);
if (!recipes) {
-   BNXT_DRV_DBG(ERR, "Uanable to alloc memory\n");
+   BNXT_DRV_DBG(ERR, "Unable to alloc memory\n");
return -ENOMEM;
}
mdata->key_recipe_info.recipes[dir][ftype] = recipes;
+
+   rec

[PATCH v2 34/47] net/bnxt: tf_ulp: add rte_mtr support for Thor2

2024-09-27 Thread Sriharsha Basavapatna
From: Jay Ding 

1. Implement Thor2 meter template tables
2. Add Thor2 meter support in ULP
3. Make rte_mtr API implementation device independent
   to adapt Thor2 meter hw change
4. Fix the round issue in xir calculation

Signed-off-by: Jay Ding 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Michael Baucom 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h   |  12 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp_meter.c | 273 +++
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c| 113 +-
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c   |  47 +++-
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c |  12 +-
 5 files changed, 246 insertions(+), 211 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
index d62a9df5f0..4868339478 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
@@ -12,6 +12,7 @@
 
 #include "rte_version.h"
 #include "rte_ethdev.h"
+#include "rte_mtr.h"
 
 #include "bnxt.h"
 #include "ulp_template_db_enum.h"
@@ -231,6 +232,10 @@ struct bnxt_ulp_core_ops {
int32_t
(*ulp_vfr_session_fid_rem)(struct bnxt_ulp_context *ulp_ctx,
  uint16_t rep_fid);
+
+   int32_t
+   (*ulp_mtr_cap_get)(struct bnxt *bp,
+  struct rte_mtr_capabilities *cap);
 };
 
 extern const struct bnxt_ulp_core_ops bnxt_ulp_tf_core_ops;
@@ -566,9 +571,6 @@ bnxt_ulp_cntxt_ecpri_udp_port_set(struct bnxt_ulp_context 
*ulp_ctx,
 unsigned int
 bnxt_ulp_cntxt_ecpri_udp_port_get(struct bnxt_ulp_context *ulp_ctx);
 
-int32_t
-bnxt_flow_meter_init(struct bnxt *bp);
-
 uint32_t
 bnxt_ulp_cntxt_convert_dev_id(uint32_t ulp_dev_id);
 
@@ -618,4 +620,8 @@ bnxt_ulp_vfr_session_fid_add(struct bnxt_ulp_context 
*ulp_ctx,
 int32_t
 bnxt_ulp_vfr_session_fid_rem(struct bnxt_ulp_context *ulp_ctx,
 uint16_t vfr_fid);
+
+int32_t
+bnxt_flow_mtr_init(struct bnxt *bp __rte_unused);
+
 #endif /* _BNXT_ULP_H_ */
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_meter.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_meter.c
index 61d006fc08..37b5cc4dfb 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_meter.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_meter.c
@@ -40,122 +40,24 @@
 /**
  * Meter init status
  */
-int bnxt_meter_initialized;
+int bnxt_mtr_initialized;
 
-/**
- * Internal api to config global config.
- * returns 0 on success.
- */
-static int32_t
-bnxt_meter_global_cfg_update(struct bnxt *bp,
-enum tf_dir dir,
-enum tf_global_config_type type,
-uint32_t offset,
-uint32_t value,
-uint32_t set_flag)
-{
-   uint32_t global_cfg = 0;
-   struct tf_global_cfg_parms parms = { 0 };
-   struct tf *tfp;
-   int32_t rc = 0;
-
-   parms.dir = dir,
-   parms.type = type,
-   parms.offset = offset,
-   parms.config = (uint8_t *)&global_cfg,
-   parms.config_sz_in_bytes = sizeof(global_cfg);
-
-   tfp = bnxt_ulp_bp_tfp_get(bp, BNXT_ULP_SESSION_TYPE_DEFAULT);
-   rc = tf_get_global_cfg(tfp, &parms);
-   if (rc) {
-   BNXT_DRV_DBG(ERR, "Failed to get global cfg 0x%x rc:%d\n",
-type, rc);
-   return rc;
-   }
-
-   if (set_flag)
-   global_cfg |= value;
-   else
-   global_cfg &= ~value;
-
-   rc = tf_set_global_cfg(tfp, &parms);
-   if (rc) {
-   BNXT_DRV_DBG(ERR, "Failed to set global cfg 0x%x rc:%d\n",
-type, rc);
-   return rc;
-   }
-   return rc;
-}
-
-/**
- * When a port is initialized by dpdk. This functions is called
- * to enable the meter and initializes the meter global configurations.
- */
-#define BNXT_THOR_FMTCR_NUM_MET_MET_1K (0x7UL << 20)
-#define BNXT_THOR_FMTCR_CNTRS_ENABLE (0x1UL << 25)
-#define BNXT_THOR_FMTCR_INTERVAL_1K (1024)
 int32_t
-bnxt_flow_meter_init(struct bnxt *bp)
+bnxt_flow_mtr_init(struct bnxt *bp __rte_unused)
 {
-   int rc = 0;
-
-   /*
-* Enable metering. Set the meter global configuration register.
-* Set number of meter to 1K. Disable the drop counter for now.
-*/
-   rc = bnxt_meter_global_cfg_update(bp, TF_DIR_RX, TF_METER_CFG,
- 0,
- BNXT_THOR_FMTCR_NUM_MET_MET_1K,
- 1);
-   if (rc) {
-   BNXT_DRV_DBG(ERR, "Failed to set rx meter configuration\n");
-   goto jump_to_error;
-   }
-
-   rc = bnxt_meter_global_cfg_update(bp, TF_DIR_TX, TF_METER_CFG,
-   0,
-   BNXT_THOR_FMTCR_NUM_MET_MET_1K,
-   1);
-   if (rc) {
-   BNXT_DRV_DBG(ERR, "Failed to set tx meter configuration\n");
-

[PATCH v2 36/47] net/bnxt: tf_ulp: add support for rss flow query to ULP

2024-09-27 Thread Sriharsha Basavapatna
From: Randy Schacher 

Support flow query rss command for truflow in ULP layer.

Signed-off-by: Randy Schacher 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt_vnic.c| 39 +-
 drivers/net/bnxt/bnxt_vnic.h|  6 +++
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 71 +
 3 files changed, 114 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index 16373be015..6b31b35715 100644
--- a/drivers/net/bnxt/bnxt_vnic.c
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -30,6 +30,7 @@
((BNXT_VNIC_BITMAP_SIZE - 1) - \
((i) % BNXT_VNIC_BITMAP_SIZE))) & 1)
 
+static uint16_t rss_query_queues[BNXT_VNIC_MAX_QUEUE_SIZE];
 /*
  * VNIC Functions
  */
@@ -777,16 +778,21 @@ bnxt_vnic_rss_create(struct bnxt *bp,
}
 
/* hwrm_type conversion */
+   vnic->hash_f = rss_info->rss_func;
+   vnic->rss_types = rss_info->rss_types;
vnic->hash_type = bnxt_rte_to_hwrm_hash_types(rss_info->rss_types);
vnic->hash_mode = bnxt_rte_to_hwrm_hash_level(bp, rss_info->rss_types,
  rss_info->rss_level);
 
/* configure the key */
-   if (!rss_info->key_len)
+   if (!rss_info->key_len) {
/* If hash key has not been specified, use random hash key.*/
bnxt_prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE);
-   else
+   vnic->key_len = HW_HASH_KEY_SIZE;
+   } else {
memcpy(vnic->rss_hash_key, rss_info->key, rss_info->key_len);
+   vnic->key_len = rss_info->key_len;
+   }
 
/* Prepare the indirection table */
bnxt_vnic_populate_rss_table(bp, vnic);
@@ -820,6 +826,35 @@ bnxt_vnic_rss_create(struct bnxt *bp,
return NULL;
 }
 
+void
+bnxt_vnic_rss_query_info_fill(struct bnxt *bp,
+ struct rte_flow_action_rss *rss_conf,
+ uint16_t vnic_id)
+{
+   struct bnxt_vnic_info *vnic_info;
+   int idx;
+
+   vnic_info = bnxt_vnic_queue_db_get_vnic(bp, vnic_id);
+   if (vnic_info == NULL) {
+   PMD_DRV_LOG(ERR, "lookup failed for id %d\n", vnic_id);
+   return;
+   }
+
+   rss_conf->key_len = vnic_info->key_len;
+   rss_conf->key = vnic_info->rss_hash_key;
+   rss_conf->func = vnic_info->hash_f;
+   rss_conf->level = vnic_info->hash_mode;
+   rss_conf->types = vnic_info->rss_types;
+
+   memset(rss_query_queues, 0, sizeof(rss_query_queues));
+   for (idx = 0; idx < BNXT_VNIC_MAX_QUEUE_SIZE; idx++)
+   if (BNXT_VNIC_BITMAP_GET(vnic_info->queue_bitmap, idx)) {
+   rss_query_queues[rss_conf->queue_num] = idx;
+   rss_conf->queue_num += 1;
+   }
+   rss_conf->queue = (const uint16_t *)&rss_query_queues;
+}
+
 int32_t
 bnxt_vnic_rss_queue_status_update(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 {
diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h
index fe3fc4e540..c4a7c5257c 100644
--- a/drivers/net/bnxt/bnxt_vnic.h
+++ b/drivers/net/bnxt/bnxt_vnic.h
@@ -75,10 +75,13 @@ struct bnxt_vnic_info {
boolrss_dflt_cr;
uint16_tref_cnt;
uint64_tqueue_bitmap[BNXT_VNIC_MAX_QUEUE_SZ_IN_64BITS];
+   uint64_trss_types;
+   uint32_tkey_len; /**< Hash key length in bytes. */
 
STAILQ_HEAD(, bnxt_filter_info) filter;
STAILQ_HEAD(, rte_flow) flow_list;
uint8_t ring_select_mode;
+   enum rte_eth_hash_function hash_f;
enum rte_eth_hash_function hash_f_local;
uint64_trss_types_local;
uint8_t metadata_format;
@@ -121,6 +124,9 @@ int32_t bnxt_vnic_queue_db_init(struct bnxt *bp);
 int32_t bnxt_vnic_queue_db_deinit(struct bnxt *bp);
 
 void bnxt_vnic_queue_db_update_dlft_vnic(struct bnxt *bp);
+void bnxt_vnic_rss_query_info_fill(struct bnxt *bp,
+  struct rte_flow_action_rss *rss_conf,
+  uint16_t vnic_id);
 int32_t
 bnxt_vnic_rss_queue_status_update(struct bnxt *bp, struct bnxt_vnic_info 
*vnic);
 
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
index 85fb03e922..4c99c785c0 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
@@ -577,6 +577,66 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev,
return ret;
 }
 
+/*
+ * Fill the rte_flow_query_rss 'rss_conf' argument passed
+ * in the rte_flow_query() with the values obtained and
+ * accumulated locally.
+ *
+ * ctxt [in] The ulp context for the flow counter manager
+ *
+ * flow_id [in] The HW flow ID
+ *
+ * rss_conf [out] The rte_flow_query_count 'data' that is set
+ *
+ */
+static int ulp_fl

[PATCH v2 35/47] net/bnxt: tf_ulp: TF support flow scale query

2024-09-27 Thread Sriharsha Basavapatna
From: Shuanglin Wang 

TF supports the flow scale query feature for OVS application.
The resource usage is tracked when opening a TF session
or adding/deleting a flow. The resources includes WC TCAM,
EM, Action, Counter, Meter, ACT_ENCAP, ACT_ENCAP, and SP_SMAC.
User can query the resource usage using niccli.

This feature is disabled by default. Using the build flag
-DTF_FLOW_SCALE_QUERY to enable it.

Improvement on flow scale query feature

Several improvements on flow scale query feature:
1. Some default rules require both RX and TX resources;
   need to update usage states on both direcitons.
2. Update resoure usage state for regular flows only.
3. Added a buffer dirty state to avoid unnecessary
   state sync with firmware.

Signed-off-by: Shuanglin Wang 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c | 17 +
 drivers/net/bnxt/tf_ulp/ulp_mapper.c  | 13 +
 2 files changed, 30 insertions(+)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c 
b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
index 79e2931e43..e7ac617d7a 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
@@ -12,6 +12,9 @@
 #include "ulp_flow_db.h"
 #include "ulp_fc_mgr.h"
 #include "ulp_tun.h"
+#ifdef TF_FLOW_SCALE_QUERY
+#include "tf_resources.h"
+#endif /* TF_FLOW_SCALE_QUERY */
 
 #define ULP_FLOW_DB_RES_DIR_BIT31
 #define ULP_FLOW_DB_RES_DIR_MASK   0x8000
@@ -956,8 +959,15 @@ ulp_flow_db_flush_flows(struct bnxt_ulp_context *ulp_ctx,
return -EINVAL;
}
 
+#ifdef TF_FLOW_SCALE_QUERY
+   tf_resc_pause_usage_update();
+#endif
while (!ulp_flow_db_next_entry_get(flow_db, flow_type, &fid))
ulp_mapper_resources_free(ulp_ctx, flow_type, fid, NULL);
+#ifdef TF_FLOW_SCALE_QUERY
+   tf_resc_resume_usage_update();
+   tf_resc_usage_update_all(ulp_ctx->bp);
+#endif
 
bnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);
 
@@ -994,6 +1004,9 @@ ulp_flow_db_function_flow_flush(struct bnxt_ulp_context 
*ulp_ctx,
return -EINVAL;
}
 
+#ifdef TF_FLOW_SCALE_QUERY
+   tf_resc_pause_usage_update();
+#endif
while (!ulp_flow_db_next_entry_get(flow_db, BNXT_ULP_FDB_TYPE_REGULAR,
   &flow_id)) {
if (flow_db->func_id_tbl[flow_id] == func_id)
@@ -1002,6 +1015,10 @@ ulp_flow_db_function_flow_flush(struct bnxt_ulp_context 
*ulp_ctx,
  flow_id,
  NULL);
}
+#ifdef TF_FLOW_SCALE_QUERY
+   tf_resc_resume_usage_update();
+   tf_resc_usage_update_all(ulp_ctx->bp);
+#endif
bnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);
return 0;
 }
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c 
b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 17e5b99562..3bf0307980 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -21,6 +21,9 @@
 #include "ulp_port_db.h"
 #include "ulp_ha_mgr.h"
 #include "bnxt_tf_pmd_shim.h"
+#ifdef TF_FLOW_SCALE_QUERY
+#include "tf_resources.h"
+#endif /* TF_FLOW_SCALE_QUERY */
 
 static uint8_t mapper_fld_zeros[16] = { 0 };
 
@@ -4315,6 +4318,12 @@ ulp_mapper_resources_free(struct bnxt_ulp_context 
*ulp_ctx,
if (rc)
frc = rc;
 
+#ifdef TF_FLOW_SCALE_QUERY
+   /* update for regular flows only */
+   if (flow_type == BNXT_ULP_FDB_TYPE_REGULAR)
+   tf_resc_usage_update_all(ulp_ctx->bp);
+#endif /* TF_FLOW_SCALE_QUERY */
+
return frc;
 }
 
@@ -4464,6 +4473,10 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
goto flow_error;
}
 
+#ifdef TF_FLOW_SCALE_QUERY
+   tf_resc_usage_update_all(ulp_ctx->bp);
+#endif /* TF_FLOW_SCALE_QUERY */
+
return rc;
 
 batch_error:
-- 
2.39.3



[DPDK/ethdev Bug 1554] Use after free in cnxk_ethdev

2024-09-27 Thread bugzilla
https://bugs.dpdk.org/show_bug.cgi?id=1554

Bug ID: 1554
   Summary: Use after free in cnxk_ethdev
   Product: DPDK
   Version: 24.11
  Hardware: All
OS: All
Status: UNCONFIRMED
  Severity: major
  Priority: Normal
 Component: ethdev
  Assignee: dev@dpdk.org
  Reporter: step...@networkplumber.org
  Target Milestone: ---

If GCC malloc function tracing attributes are added, the the following error is
detected at compile time:

../drivers/net/cnxk/cnxk_ethdev_sec.c: In function
‘cnxk_nix_inl_custom_meta_pool_cb’:
../drivers/common/cnxk/roc_platform.h:196:32: warning: pointer ‘hp’ used after
‘rte_mempool_free’ [-Wuse-after-free]
  196 | #define plt_free   rte_free
../drivers/net/cnxk/cnxk_ethdev_sec.c:140:17: note: in expansion of macro
‘plt_free’
  140 | plt_free(hp->pool_config);
  | ^~~~
../drivers/net/cnxk/cnxk_ethdev_sec.c:139:17: note: call to ‘rte_mempool_free’
here
  139 | rte_mempool_free(hp);
  | ^~~~

-- 
You are receiving this mail because:
You are the assignee for the bug.

[PATCH v2 03/47] net/bnxt: tf_core: External EM support cleanup

2024-09-27 Thread Sriharsha Basavapatna
From: Shuanglin Wang 

Isolate external EM support as it is now defunct on Wh+.

Signed-off-by: Shuanglin Wang 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Shahaji Bhosle 
Reviewed-by: Farah Smith 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_core/meson.build |2 -
 drivers/net/bnxt/tf_core/tf_core.h   |   34 +-
 drivers/net/bnxt/tf_core/tf_device.c |   30 -
 drivers/net/bnxt/tf_core/tf_device_p4.c  |   17 +-
 drivers/net/bnxt/tf_core/tf_device_p4.h  |1 +
 drivers/net/bnxt/tf_core/tf_device_p58.c |6 +-
 drivers/net/bnxt/tf_core/tf_em.h |  361 +--
 drivers/net/bnxt/tf_core/tf_em_common.c  | 1191 --
 drivers/net/bnxt/tf_core/tf_em_common.h  |1 +
 drivers/net/bnxt/tf_core/tf_em_host.c|  574 ---
 drivers/net/bnxt/tf_core/tf_msg.c|  465 -
 drivers/net/bnxt/tf_core/tf_tcam.c   |1 -
 12 files changed, 71 insertions(+), 2612 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/meson.build 
b/drivers/net/bnxt/tf_core/meson.build
index ae44aa34cf..13a71738a0 100644
--- a/drivers/net/bnxt/tf_core/meson.build
+++ b/drivers/net/bnxt/tf_core/meson.build
@@ -21,9 +21,7 @@ sources += files(
 'tf_device.c',
 'tf_device_p4.c',
 'tf_device_p58.c',
-'tf_em_common.c',
 'tf_em_hash_internal.c',
-'tf_em_host.c',
 'tf_em_internal.c',
 'tf_global_cfg.c',
 'tf_hash.c',
diff --git a/drivers/net/bnxt/tf_core/tf_core.h 
b/drivers/net/bnxt/tf_core/tf_core.h
index 3da1d2a5ca..fd1ee2f454 100644
--- a/drivers/net/bnxt/tf_core/tf_core.h
+++ b/drivers/net/bnxt/tf_core/tf_core.h
@@ -21,9 +21,15 @@
 
 /** BEGIN Truflow Core DEFINITIONS **/
 
+/**
+ * \cond DO_NOT_DOCUMENT
+ */
 #define TF_KILOBYTE  1024
 #define TF_MEGABYTE  (1024 * 1024)
 
+/**
+ * \endcond
+ */
 /**
  * direction
  */
@@ -93,15 +99,19 @@ enum tf_sram_bank_id {
  *
  * Convert absolute offset to action record pointer in EEM record entry
  * Convert action record pointer in EEM record entry to absolute offset
+ * \cond DO_NOT_DOCUMENT
  */
 #define TF_ACT_REC_OFFSET_2_PTR(offset) ((offset) >> 4)
 #define TF_ACT_REC_PTR_2_OFFSET(offset) ((offset) << 4)
 
-/*
+/**
  * Helper Macros
  */
 #define TF_BITS_2_BYTES(num_bits) (((num_bits) + 7) / 8)
 
+/**
+ * \endcond
+ */
 /** BEGIN API FUNCTION PROTOTYPES/PARAMETERS **/
 
 /**
@@ -147,6 +157,8 @@ enum tf_sram_bank_id {
  * TruFlow session. Session ID is constructed from the passed in
  * ctrl_chan_name in tf_open_session() together with an allocated
  * fw_session_id. Done by TruFlow on tf_open_session().
+ *
+ * \cond DO_NOT_DOCUMENT
  */
 union tf_session_id {
uint32_t id;
@@ -172,6 +184,10 @@ union tf_session_client_id {
uint8_t fw_session_client_id;
} internal;
 };
+/**
+ * \endcond
+ */
+
 
 /**
  * Session Version
@@ -181,12 +197,17 @@ union tf_session_client_id {
  * versions can be supported.
  *
  * Please see the TF_VER_MAJOR/MINOR and UPDATE defines.
+ *
+ * \cond DO_NOT_DOCUMENT
  */
 struct tf_session_version {
uint8_t major;
uint8_t minor;
uint8_t update;
 };
+/**
+ * \endcond
+ */
 
 /**
  * Session supported device types
@@ -485,6 +506,7 @@ struct tf_session_info {
  *
  * NOTE: This struct must be within the BNXT PMD struct bnxt
  *   (bp). This allows use of container_of() to get access to the PMD.
+ * \cond DO_NOT_DOCUMENT
  */
 struct tf {
struct tf_session_info *session;
@@ -493,6 +515,9 @@ struct tf {
 */
void *bp;
 };
+/**
+ * \endcond
+ */
 
 /**
  * Identifier resource definition
@@ -716,12 +741,15 @@ int tf_open_session(struct tf *tfp,
 
 /**
  * General internal resource info
- *
+ * \cond DO_NOT_DOCUMENT
  */
 struct tf_resource_info {
uint16_t start;
uint16_t stride;
 };
+/**
+ * \endcond
+ */
 
 /**
  * Identifier resource definition
@@ -2386,6 +2414,7 @@ struct tf_get_version_parms {
/* [out] major
 *
 * Version Major number.
+* \cond DO_NOT_DOCUMENT
 */
uint8_t major;
 
@@ -2402,6 +2431,7 @@ struct tf_get_version_parms {
uint8_t update;
 
/**
+* \endcond
 * [out] dev_ident_caps
 *
 * fw available identifier resource list
diff --git a/drivers/net/bnxt/tf_core/tf_device.c 
b/drivers/net/bnxt/tf_core/tf_device.c
index 02a9ebd7b2..d023194d0c 100644
--- a/drivers/net/bnxt/tf_core/tf_device.c
+++ b/drivers/net/bnxt/tf_core/tf_device.c
@@ -153,28 +153,6 @@ tf_dev_bind_p4(struct tf *tfp,
}
no_rsv_flag = false;
}
-
-   /*
-* EEM
-*/
-
-   em_cfg.cfg = tf_em_ext_p4;
-   rsv_cnt = tf_dev_reservation_check(TF_EM_TBL_TYPE_MAX,
-  em_cfg.cfg,
-  (uint16_t *)resources->em_cnt);
-   if (rsv_cnt) {
-   em_cfg.num_elements = TF_EM_TBL_TYPE_MAX;
- 

[PATCH v2 07/47] net/bnxt: tf_core: fix slice count in case of HA entry move

2024-09-27 Thread Sriharsha Basavapatna
From: Sangtani Parag Satishbhai 

When entries are moved during HA, a shared move function transfers
TCAM entries by using get/set message APIs, and the slice number of the
entry is required to accomplish the movement. The slice number is
calculated as the product of row_slice and entry size. Before calling
get/set message APIs, the source entry size should be updated with the
destination entry size; otherwise, it might corrupt the slice number field,
which may result in writing an incorrect entry. A fix is made which now
copies the entry size from the source to the destination before calling
get/set message APIs, ensuring the correct slice number is modified.

Signed-off-by: Sangtani Parag Satishbhai 

Reviewed-by: Sriharsha Basavapatna 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_core/cfa_tcam_mgr.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c 
b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
index 349f52caba..33b1e4121e 100644
--- a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
@@ -1717,6 +1717,11 @@ cfa_tcam_mgr_shared_entry_move(int sess_idx, struct 
cfa_tcam_mgr_context *contex
uint8_t  key[CFA_TCAM_MGR_MAX_KEY_SIZE];
uint8_t  mask[CFA_TCAM_MGR_MAX_KEY_SIZE];
uint8_t  result[CFA_TCAM_MGR_MAX_KEY_SIZE];
+   /*
+* Copy entry size before moving else if
+* slice number is non zero and entry size is zero it will cause issues
+*/
+   dst_row->entry_size = src_row->entry_size;
 
int rc;
 
@@ -1791,7 +1796,6 @@ cfa_tcam_mgr_shared_entry_move(int sess_idx, struct 
cfa_tcam_mgr_context *contex
 
ROW_ENTRY_SET(dst_row, dst_row_slice);
dst_row->entries[dst_row_slice] = entry_id;
-   dst_row->entry_size = src_row->entry_size;
dst_row->priority = src_row->priority;
ROW_ENTRY_CLEAR(src_row, entry->slice);
entry->row = dst_row_index;
-- 
2.39.3



[PATCH v2 21/47] net/bnxt: tf_ulp: add action read and clear support

2024-09-27 Thread Sriharsha Basavapatna
From: Jay Ding 

Implement action read and clear support. Change flow
query count to reset the count after read in ULP.
Update cli cmds accordingly.

Fixed bnxt_mpc_xmit() to pad the mpc message to be
multiple of 16 bytes.

Signed-off-by: Jay Ding 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Michael Baucom 
Reviewed-by: Farah Smith 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c 
b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c
index f1bbce797d..2be37b59c2 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c
@@ -83,6 +83,10 @@ ulp_fc_tfc_flow_stat_get(struct bnxt_ulp_context *ctxt,
cmm_info.rsubtype = CFA_RSUBTYPE_CMM_ACT;
cmm_info.act_handle = handle;
cmm_info.dir = (enum cfa_dir)direction;
+   cmm_clr.clr = true;
+   cmm_clr.offset_in_byte = 0;
+   cmm_clr.sz_in_byte = sizeof(data64[ULP_FC_TFC_PKT_CNT_OFFS]) +
+sizeof(data64[ULP_FC_TFC_BYTE_CNT_OFFS]);
rc = tfc_act_get(tfcp, NULL, &cmm_info, &cmm_clr, data, &word_size);
if (rc) {
BNXT_DRV_DBG(ERR,
-- 
2.39.3



[PATCH v2 14/47] net/bnxt: tf_ulp: add support for vf to vf flow offload

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

Added support for the vf to vf flow offload for the whitney platform.
It includes the change of the pipeline from using vlan tags to using
custom L2 encap and decap of the packets.

Signed-off-by: Kishore Padmanabha 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Shahaji Bhosle 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c  |  5 
 drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 32 +
 drivers/net/bnxt/tf_ulp/ulp_def_rules.c | 26 
 drivers/net/bnxt/tf_ulp/ulp_mapper.c|  6 +
 drivers/net/bnxt/tf_ulp/ulp_port_db.c   | 32 +
 drivers/net/bnxt/tf_ulp/ulp_port_db.h   | 13 ++
 6 files changed, 114 insertions(+)

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 912946303a..3f0a5f2300 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -1927,6 +1927,11 @@ bnxt_ulp_port_init(struct bnxt *bp)
}
}
 
+   /* setup the l2 etype tunnel for custom l2 encap/decap */
+   rc = ulp_l2_etype_tunnel_alloc(bp);
+   if (rc)
+   goto jump_to_error;
+
/* Update bnxt driver flags */
rc = ulp_dparms_dev_port_intf_update(bp, bp->ulp_ctx);
if (rc) {
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
index ad04644db4..2f159ae486 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c
@@ -606,6 +606,38 @@ bnxt_ulp_action_handle_create(struct rte_eth_dev *dev,
BNXT_ULP_DIR_EGRESS);
}
 
+   /* perform the conversion from dpdk port to bnxt ifindex */
+   if (ulp_port_db_dev_port_to_ulp_index(ulp_ctx,
+ dev->data->port_id,
+ &ifindex)) {
+   BNXT_TF_DBG(ERR, "Port id is not valid\n");
+   goto parse_error;
+   }
+   port_type = ulp_port_db_port_type_get(ulp_ctx, ifindex);
+   if (port_type == BNXT_ULP_INTF_TYPE_INVALID) {
+   BNXT_TF_DBG(ERR, "Port type is not valid\n");
+   goto parse_error;
+   }
+
+   bnxt_ulp_init_parser_cf_defaults(¶ms, dev->data->port_id);
+
+   /* Emulating the match port for direction processing */
+   ULP_COMP_FLD_IDX_WR(¶ms, BNXT_ULP_CF_IDX_MATCH_PORT_TYPE,
+   port_type);
+
+   if ((params.dir_attr & BNXT_ULP_FLOW_ATTR_INGRESS) &&
+   port_type == BNXT_ULP_INTF_TYPE_VF_REP) {
+   ULP_COMP_FLD_IDX_WR(¶ms, BNXT_ULP_CF_IDX_DIRECTION,
+   BNXT_ULP_DIR_EGRESS);
+   } else {
+   /* Assign the input direction */
+   if (params.dir_attr & BNXT_ULP_FLOW_ATTR_INGRESS)
+   ULP_COMP_FLD_IDX_WR(¶ms, BNXT_ULP_CF_IDX_DIRECTION,
+   BNXT_ULP_DIR_INGRESS);
+   else
+   ULP_COMP_FLD_IDX_WR(¶ms, BNXT_ULP_CF_IDX_DIRECTION,
+   BNXT_ULP_DIR_EGRESS);
+   }
/* Parse the shared action */
ret = bnxt_ulp_rte_parser_act_parse(actions, ¶ms);
if (ret != BNXT_TF_RC_SUCCESS)
diff --git a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c 
b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
index 8237dbd294..e2d281130e 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c
@@ -12,6 +12,10 @@
 #include "ulp_flow_db.h"
 #include "ulp_mapper.h"
 
+static void
+ulp_l2_custom_tunnel_id_update(struct bnxt *bp,
+  struct bnxt_ulp_mapper_create_parms *params);
+
 struct bnxt_ulp_def_param_handler {
int32_t (*vfr_func)(struct bnxt_ulp_context *ulp_ctx,
struct ulp_tlv_param *param,
@@ -306,6 +310,7 @@ ulp_default_flow_create(struct rte_eth_dev *eth_dev,
struct ulp_rte_act_bitmap   act = { 0 };
struct bnxt_ulp_context *ulp_ctx;
uint32_t type, ulp_flags = 0, fid;
+   struct bnxt *bp = eth_dev->data->dev_private;
int rc = 0;
 
memset(&mapper_params, 0, sizeof(mapper_params));
@@ -366,6 +371,9 @@ ulp_default_flow_create(struct rte_eth_dev *eth_dev,
ULP_COMP_FLD_IDX_WR(&mapper_params, BNXT_ULP_CF_IDX_VF_META_FID,
BNXT_ULP_META_VF_FLAG | mapper_params.func_id);
 
+   /* update the upar id */
+   ulp_l2_custom_tunnel_id_update(bp, &mapper_params);
+
BNXT_TF_DBG(DEBUG, "Creating default flow with template id: %u\n",
ulp_class_tid);
 
@@ -641,3 +649,21 @@ bnxt_ulp_delete_vfr_default_rules(struct bnxt_representor 
*vfr)
memset(info, 0, sizeof(struct bnxt_ulp_vfr_rule_info));
return 0;
 }
+
+static void
+ulp_l2_custom_tunnel_id_update(struct bnxt *bp,
+  st

[PATCH 00/16] Fix allocation issues and add hardening

2024-09-27 Thread Stephen Hemminger
Recent versions of GCC have some additional function attributes that can
help with DPDK performance and stability.

The alloc_align attribute can tell the compiler what the alignment
of the allocation will be, and the optimizer can use this to produce
better code (especially memcpy and structure copies).

The malloc attribute tells compiler that object is not overlapping
and potentially aliasing. It also as an additional variant in GCC 11
or later that allows for detecting all sorts of common errors like
calling free() on memory allocated with rte_malloc().

This patch set is structured with:
  - add macros for enable the macros
  - fix any new warnings that were discovered
  - enable the attributes

The same attributes could be added to lots more functions in DPDK,
but this patch set focuses on the key ones, and where problems
exist in current code base.

The fixes should be backported to stable (they are real bugs),
but the macros common and the annotation in malloc should not.

Stephen Hemminger (16):
  eal: add function attributes for allocation functions
  memzone: fix use after free in tracing
  cryptodev/bcmfs: fix mis-matched free
  dma/ixd: fix incorrect free function in cleanup
  event/cnxk: fix pointer mismatch in cleanup
  examples/vhost: fix free function mismatch
  net/cnxk: fix use-after-free
  bpf: fix free mismatch if convert fails
  net/e1000: fix use-after-free
  net/sfc: fix use-after-free warning messages
  net/cpfl: fix free of nonheap object
  raw/ifpga/base: fix use after free
  common/qat: fix use after free
  drivers/ifpga: fix free function mismatch
  eal: add alloc_function attribute to rte_malloc
  mempool: annotate mempool create

 drivers/common/qat/qat_device.c   |  6 +--
 drivers/crypto/bcmfs/bcmfs_device.c   |  4 +-
 drivers/dma/idxd/idxd_pci.c   |  2 +-
 drivers/event/cnxk/cnxk_eventdev.c|  4 +-
 drivers/net/cnxk/cnxk_ethdev_sec.c|  2 +-
 drivers/net/cpfl/cpfl_flow_parser.c   |  1 -
 drivers/net/e1000/igb_ethdev.c|  4 +-
 drivers/net/sfc/sfc_flow_rss.c|  4 +-
 drivers/net/sfc/sfc_mae.c | 23 -
 drivers/raw/ifpga/base/opae_intel_max10.c | 11 +++-
 drivers/raw/ifpga/ifpga_rawdev.c  |  8 +--
 examples/vhost_blk/vhost_blk.c|  2 +-
 lib/bpf/bpf_convert.c |  2 +-
 lib/eal/common/eal_common_memzone.c   |  3 +-
 lib/eal/include/rte_common.h  | 30 +++
 lib/eal/include/rte_malloc.h  | 63 ++-
 lib/mempool/rte_mempool.h | 41 ---
 17 files changed, 130 insertions(+), 80 deletions(-)

-- 
2.45.2



[PATCH 01/16] eal: add function attributes for allocation functions

2024-09-27 Thread Stephen Hemminger
The allocation functions take a alignment argument that
can be useful to hint the compiler optimizer.

This is supported by Gcc and Clang but only useful with
Gcc because Clang gives warning if alignment is 0.

Recent versions of GCC have a malloc attribute that can
be used to find mismatches between allocation and free;
the typical problem caught is a pointer allocated with
rte_malloc() that is then incorrectly freed using free().

Signed-off-by: Stephen Hemminger 
---
 lib/eal/include/rte_common.h | 30 ++
 lib/eal/include/rte_malloc.h | 24 
 2 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index eec0400dad..1b3781274d 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -228,6 +228,36 @@ typedef uint16_t unaligned_uint16_t;
 #define __rte_alloc_size(...)
 #endif
 
+/**
+ * Tells the compiler that the function returns a value that points to
+ * memory aligned by a function argument.
+ * Not enabled on clang because it warns if align argument is zero.
+ */
+#if defined(RTE_CC_GCC)
+#define __rte_alloc_align(align_arg) \
+   __attribute__((alloc_align(align_arg)))
+#else
+#define __rte_alloc_align(...)
+#endif
+
+/**
+ * Tells the compiler this is a function like malloc and that the pointer
+ * returned cannot alias any other pointer (ie new memory).
+ *
+ * Also, with recent GCC versions also able to track that proper
+ * dealloctor function is used for this pointer.
+ */
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 11)
+#define __rte_alloc_func(free_func) \
+   __attribute__((malloc, malloc(free_func)))
+
+#elif defined(RTE_CC_GCC) || defined(RTE_CC_CLANG)
+#define __rte_alloc_func(free_func) \
+   __attribute__((malloc))
+#else
+#define __rte_alloc_func(free_func)
+#endif
+
 #define RTE_PRIORITY_LOG 101
 #define RTE_PRIORITY_BUS 110
 #define RTE_PRIORITY_CLASS 120
diff --git a/lib/eal/include/rte_malloc.h b/lib/eal/include/rte_malloc.h
index 1f91e7bdde..cf3c174022 100644
--- a/lib/eal/include/rte_malloc.h
+++ b/lib/eal/include/rte_malloc.h
@@ -54,7 +54,8 @@ struct rte_malloc_socket_stats {
  */
 void *
 rte_malloc(const char *type, size_t size, unsigned align)
-   __rte_alloc_size(2);
+   __rte_alloc_size(2)
+   __rte_alloc_align(3);
 
 /**
  * Allocate zeroed memory from the heap.
@@ -81,7 +82,8 @@ rte_malloc(const char *type, size_t size, unsigned align)
  */
 void *
 rte_zmalloc(const char *type, size_t size, unsigned align)
-   __rte_alloc_size(2);
+   __rte_alloc_size(2)
+   __rte_alloc_align(3);
 
 /**
  * Replacement function for calloc(), using huge-page memory. Memory area is
@@ -108,7 +110,8 @@ rte_zmalloc(const char *type, size_t size, unsigned align)
  */
 void *
 rte_calloc(const char *type, size_t num, size_t size, unsigned align)
-   __rte_alloc_size(2, 3);
+   __rte_alloc_size(2, 3)
+   __rte_alloc_align(4);
 
 /**
  * Replacement function for realloc(), using huge-page memory. Reserved area
@@ -132,7 +135,8 @@ rte_calloc(const char *type, size_t num, size_t size, 
unsigned align)
  */
 void *
 rte_realloc(void *ptr, size_t size, unsigned int align)
-   __rte_alloc_size(2);
+   __rte_alloc_size(2)
+   __rte_alloc_align(3);
 
 /**
  * Replacement function for realloc(), using huge-page memory. Reserved area
@@ -158,7 +162,8 @@ rte_realloc(void *ptr, size_t size, unsigned int align)
  */
 void *
 rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket)
-   __rte_alloc_size(2);
+   __rte_alloc_size(2)
+   __rte_alloc_align(3);
 
 /**
  * This function allocates memory from the huge-page area of memory. The memory
@@ -185,7 +190,8 @@ rte_realloc_socket(void *ptr, size_t size, unsigned int 
align, int socket)
  */
 void *
 rte_malloc_socket(const char *type, size_t size, unsigned align, int socket)
-   __rte_alloc_size(2);
+   __rte_alloc_size(2)
+   __rte_alloc_align(3);
 
 /**
  * Allocate zeroed memory from the heap.
@@ -214,7 +220,8 @@ rte_malloc_socket(const char *type, size_t size, unsigned 
align, int socket)
  */
 void *
 rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket)
-   __rte_alloc_size(2);
+   __rte_alloc_size(2)
+   __rte_alloc_align(3);
 
 /**
  * Replacement function for calloc(), using huge-page memory. Memory area is
@@ -243,7 +250,8 @@ rte_zmalloc_socket(const char *type, size_t size, unsigned 
align, int socket)
  */
 void *
 rte_calloc_socket(const char *type, size_t num, size_t size, unsigned align, 
int socket)
-   __rte_alloc_size(2, 3);
+   __rte_alloc_size(2, 3)
+   __rte_alloc_align(4);
 
 /**
  * Frees the memory space pointed to by the provided pointer.
-- 
2.45.2



[PATCH 02/16] memzone: fix use after free in tracing

2024-09-27 Thread Stephen Hemminger
Using the freed value for tracing is not a good idea.
Although it is harmless for tracing, it will cause analyzers to flag
this as unsafe.

Signed-off-by: Stephen Hemminger 
---
 lib/eal/common/eal_common_memzone.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/eal/common/eal_common_memzone.c 
b/lib/eal/common/eal_common_memzone.c
index 2d9b6aa3e3..90efbb621d 100644
--- a/lib/eal/common/eal_common_memzone.c
+++ b/lib/eal/common/eal_common_memzone.c
@@ -331,9 +331,10 @@ rte_memzone_free(const struct rte_memzone *mz)
 
rte_rwlock_write_unlock(&mcfg->mlock);
 
+   rte_eal_trace_memzone_free(name, addr, ret);
+
rte_free(addr);
 
-   rte_eal_trace_memzone_free(name, addr, ret);
return ret;
 }
 
-- 
2.45.2



[PATCH 03/16] cryptodev/bcmfs: fix mis-matched free

2024-09-27 Thread Stephen Hemminger
The device structure is allocated with rte_malloc() and
then incorrectly freed with free(). This will lead to
corrupt malloc pool.

Bugzilla ID: 1552
Fixes: c8e79da7c676 ("crypto/bcmfs: introduce BCMFS driver")
Cc: vikas.gu...@broadcom.com
Cc: sta...@dpdk.org

Signed-off-by: Stephen Hemminger 
---
 drivers/crypto/bcmfs/bcmfs_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/bcmfs/bcmfs_device.c 
b/drivers/crypto/bcmfs/bcmfs_device.c
index ada7ba342c..46522970d5 100644
--- a/drivers/crypto/bcmfs/bcmfs_device.c
+++ b/drivers/crypto/bcmfs/bcmfs_device.c
@@ -139,7 +139,7 @@ fsdev_allocate_one_dev(struct rte_vdev_device *vdev,
return fsdev;
 
 cleanup:
-   free(fsdev);
+   rte_free(fsdev);
 
return NULL;
 }
@@ -163,7 +163,7 @@ fsdev_release(struct bcmfs_device *fsdev)
return;
 
TAILQ_REMOVE(&fsdev_list, fsdev, next);
-   free(fsdev);
+   rte_free(fsdev);
 }
 
 static int
-- 
2.45.2



[PATCH 10/16] net/sfc: fix use-after-free warning messages

2024-09-27 Thread Stephen Hemminger
If compiler detection of use-after-free is enabled then this drivers
debug messages will cause warnings. Change to move debug message
before the object is freed.

Bugzilla ID: 1551
Fixes: 55c1238246d5 ("net/sfc: add more debug messages to transfer flows")
Cc: ivan.ma...@oktetlabs.ru
Signed-off-by: Stephen Hemminger 
---
 drivers/net/sfc/sfc_flow_rss.c |  4 ++--
 drivers/net/sfc/sfc_mae.c  | 23 +--
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/net/sfc/sfc_flow_rss.c b/drivers/net/sfc/sfc_flow_rss.c
index e28c943335..8e2749833b 100644
--- a/drivers/net/sfc/sfc_flow_rss.c
+++ b/drivers/net/sfc/sfc_flow_rss.c
@@ -303,9 +303,9 @@ sfc_flow_rss_ctx_del(struct sfc_adapter *sa, struct 
sfc_flow_rss_ctx *ctx)
 
TAILQ_REMOVE(&flow_rss->ctx_list, ctx, entries);
rte_free(ctx->qid_offsets);
-   rte_free(ctx);
-
sfc_dbg(sa, "flow-rss: deleted ctx=%p", ctx);
+
+   rte_free(ctx);
 }
 
 static int
diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c
index 60ff6d2181..8f74f10390 100644
--- a/drivers/net/sfc/sfc_mae.c
+++ b/drivers/net/sfc/sfc_mae.c
@@ -400,9 +400,8 @@ sfc_mae_outer_rule_del(struct sfc_adapter *sa,
efx_mae_match_spec_fini(sa->nic, rule->match_spec);
 
TAILQ_REMOVE(&mae->outer_rules, rule, entries);
-   rte_free(rule);
-
sfc_dbg(sa, "deleted outer_rule=%p", rule);
+   rte_free(rule);
 }
 
 static int
@@ -585,9 +584,8 @@ sfc_mae_mac_addr_del(struct sfc_adapter *sa, struct 
sfc_mae_mac_addr *mac_addr)
}
 
TAILQ_REMOVE(&mae->mac_addrs, mac_addr, entries);
-   rte_free(mac_addr);
-
sfc_dbg(sa, "deleted mac_addr=%p", mac_addr);
+   rte_free(mac_addr);
 }
 
 enum sfc_mae_mac_addr_type {
@@ -785,10 +783,10 @@ sfc_mae_encap_header_del(struct sfc_adapter *sa,
}
 
TAILQ_REMOVE(&mae->encap_headers, encap_header, entries);
+   sfc_dbg(sa, "deleted encap_header=%p", encap_header);
+
rte_free(encap_header->buf);
rte_free(encap_header);
-
-   sfc_dbg(sa, "deleted encap_header=%p", encap_header);
 }
 
 static int
@@ -983,9 +981,8 @@ sfc_mae_counter_del(struct sfc_adapter *sa, struct 
sfc_mae_counter *counter)
}
 
TAILQ_REMOVE(&mae->counters, counter, entries);
-   rte_free(counter);
-
sfc_dbg(sa, "deleted counter=%p", counter);
+   rte_free(counter);
 }
 
 static int
@@ -1165,9 +1162,8 @@ sfc_mae_action_set_del(struct sfc_adapter *sa,
sfc_mae_mac_addr_del(sa, action_set->src_mac_addr);
sfc_mae_counter_del(sa, action_set->counter);
TAILQ_REMOVE(&mae->action_sets, action_set, entries);
-   rte_free(action_set);
-
sfc_dbg(sa, "deleted action_set=%p", action_set);
+   rte_free(action_set);
 }
 
 static int
@@ -1401,10 +1397,10 @@ sfc_mae_action_set_list_del(struct sfc_adapter *sa,
sfc_mae_action_set_del(sa, action_set_list->action_sets[i]);
 
TAILQ_REMOVE(&mae->action_set_lists, action_set_list, entries);
+   sfc_dbg(sa, "deleted action_set_list=%p", action_set_list);
+
rte_free(action_set_list->action_sets);
rte_free(action_set_list);
-
-   sfc_dbg(sa, "deleted action_set_list=%p", action_set_list);
 }
 
 static int
@@ -1667,9 +1663,8 @@ sfc_mae_action_rule_del(struct sfc_adapter *sa,
sfc_mae_outer_rule_del(sa, rule->outer_rule);
 
TAILQ_REMOVE(&mae->action_rules, rule, entries);
-   rte_free(rule);
-
sfc_dbg(sa, "deleted action_rule=%p", rule);
+   rte_free(rule);
 }
 
 static int
-- 
2.45.2



[PATCH 08/16] bpf: fix free mismatch if convert fails

2024-09-27 Thread Stephen Hemminger
If conversion of cBF to eBPF fails then an object allocated with
rte_malloc() would be passed to free().

[908/3201] Compiling C object lib/librte_bpf.a.p/bpf_bpf_convert.c.o
../lib/bpf/bpf_convert.c: In function ‘rte_bpf_convert’:
../lib/bpf/bpf_convert.c:559:17: warning: ‘free’ called on pointer returned 
from a mismatched allocation function [-Wmismatched-dealloc]
  559 | free(prm);
  | ^
../lib/bpf/bpf_convert.c:545:15: note: returned from ‘rte_zmalloc’
  545 | prm = rte_zmalloc("bpf_filter",
  |   ^
  546 |   sizeof(*prm) + ebpf_len * sizeof(*ebpf), 0);
  |   ~~~

Fixes: 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF")
Cc: sta...@dpdk.org
Signed-off-by: Stephen Hemminger 
---
 lib/bpf/bpf_convert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/bpf/bpf_convert.c b/lib/bpf/bpf_convert.c
index d7ff2b4325..e7e298c9cb 100644
--- a/lib/bpf/bpf_convert.c
+++ b/lib/bpf/bpf_convert.c
@@ -556,7 +556,7 @@ rte_bpf_convert(const struct bpf_program *prog)
ret = bpf_convert_filter(prog->bf_insns, prog->bf_len, ebpf, &ebpf_len);
if (ret < 0) {
RTE_BPF_LOG_LINE(ERR, "%s: cannot convert cBPF to eBPF", 
__func__);
-   free(prm);
+   rte_free(prm);
rte_errno = -ret;
return NULL;
}
-- 
2.45.2



[PATCH 05/16] event/cnxk: fix pointer mismatch in cleanup

2024-09-27 Thread Stephen Hemminger
The code to cleanup in case of error was passing incorrect
value to rte_free. The ports[] entry was allocated with
rte_malloc and that should be used instead of the offset
in that object.

Fixes: 97a05c1fe634 ("event/cnxk: add port config")
Cc: sthot...@marvell.com
Cc: sta...@dpdk.org

Signed-off-by: Stephen Hemminger 
---
 drivers/event/cnxk/cnxk_eventdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/event/cnxk/cnxk_eventdev.c 
b/drivers/event/cnxk/cnxk_eventdev.c
index 4b2d6bffa6..08c6ce0c07 100644
--- a/drivers/event/cnxk/cnxk_eventdev.c
+++ b/drivers/event/cnxk/cnxk_eventdev.c
@@ -121,8 +121,10 @@ cnxk_setup_event_ports(const struct rte_eventdev 
*event_dev,
return 0;
 hws_fini:
for (i = i - 1; i >= 0; i--) {
+   void *ws = event_dev->data->ports[i];
+
event_dev->data->ports[i] = NULL;
-   rte_free(cnxk_sso_hws_get_cookie(event_dev->data->ports[i]));
+   rte_free(ws);
}
return -ENOMEM;
 }
-- 
2.45.2



[PATCH 06/16] examples/vhost: fix free function mismatch

2024-09-27 Thread Stephen Hemminger
The pointer bdev is allocated with rte_zmalloc() and then
incorrectly freed with free() which will lead pool corruption.

Bugzilla ID: 1553
Fixes: c19beb3f38cd ("examples/vhost_blk: introduce vhost storage sample")
Cc: jin...@intel.com
Cc: sta...@dpdk.org

Signed-off-by: Stephen Hemminger 
---
 examples/vhost_blk/vhost_blk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index 03f1ac9c3f..9c9e326949 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -776,7 +776,7 @@ vhost_blk_bdev_construct(const char *bdev_name,
bdev->data = rte_zmalloc(NULL, blk_cnt * blk_size, 0);
if (!bdev->data) {
fprintf(stderr, "No enough reserved huge memory for disk\n");
-   free(bdev);
+   rte_free(bdev);
return NULL;
}
 
-- 
2.45.2



[PATCH 16/16] mempool: annotate mempool create

2024-09-27 Thread Stephen Hemminger
Use rte_alloc_function annotation to catch mismatch errors
on memzone handling.

Signed-off-by: Stephen Hemminger 
---
 lib/mempool/rte_mempool.h | 41 +--
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 7bdc92b812..912500ce4c 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -1012,6 +1012,20 @@ typedef void (rte_mempool_mem_cb_t)(struct rte_mempool 
*mp,
  */
 typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);
 
+/**
+ * Free a mempool
+ *
+ * Unlink the mempool from global list, free the memory chunks, and all
+ * memory referenced by the mempool. The objects must not be used by
+ * other cores as they will be freed.
+ *
+ * @param mp
+ *   A pointer to the mempool structure.
+ *   If NULL then, the function does nothing.
+ */
+void
+rte_mempool_free(struct rte_mempool *mp);
+
 /**
  * Create a new mempool named *name* in memory.
  *
@@ -1091,11 +1105,12 @@ typedef void (rte_mempool_ctor_t)(struct rte_mempool *, 
void *);
  *- ENOMEM - no appropriate memory area found in which to create memzone
  */
 struct rte_mempool *
-rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
-  unsigned cache_size, unsigned private_data_size,
+rte_mempool_create(const char *name, unsigned int n, unsigned int elt_size,
+  unsigned int cache_size, unsigned int private_data_size,
   rte_mempool_ctor_t *mp_init, void *mp_init_arg,
   rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
-  int socket_id, unsigned flags);
+  int socket_id, unsigned int flags)
+   __rte_alloc_func(rte_mempool_free);
 
 /**
  * Create an empty mempool
@@ -1132,22 +1147,10 @@ rte_mempool_create(const char *name, unsigned n, 
unsigned elt_size,
  *   with rte_errno set appropriately. See rte_mempool_create() for details.
  */
 struct rte_mempool *
-rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
-   unsigned cache_size, unsigned private_data_size,
-   int socket_id, unsigned flags);
-/**
- * Free a mempool
- *
- * Unlink the mempool from global list, free the memory chunks, and all
- * memory referenced by the mempool. The objects must not be used by
- * other cores as they will be freed.
- *
- * @param mp
- *   A pointer to the mempool structure.
- *   If NULL then, the function does nothing.
- */
-void
-rte_mempool_free(struct rte_mempool *mp);
+rte_mempool_create_empty(const char *name, unsigned int n, unsigned int 
elt_size,
+unsigned int cache_size, unsigned int 
private_data_size,
+int socket_id, unsigned int flags)
+   __rte_alloc_func(rte_mempool_free);
 
 /**
  * Add physically contiguous memory for objects in the pool at init
-- 
2.45.2



[PATCH 14/16] drivers/ifpga: fix free function mismatch

2024-09-27 Thread Stephen Hemminger
The raw ifpga driver redefines malloc to be opae_malloc
and free to be opae_free; which is a bad idea.

This leads to case where interrupt efd array is allocated
with calloc() and then passed to rte_free. The workaround
is to allocate the array with rte_calloc() instead.

Fixes: d61138d4f0e2 ("drivers: remove direct access to interrupt handle")
Cc: hka...@marvell.com
Cc: sta...@dpdk.org

Signed-off-by: Stephen Hemminger 
---
 drivers/raw/ifpga/ifpga_rawdev.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index a972b3b7a4..86558c7b9b 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -1499,7 +1499,7 @@ ifpga_register_msix_irq(struct ifpga_rawdev *dev, int 
port_id,
 
nb_intr = rte_intr_nb_intr_get(*intr_handle);
 
-   intr_efds = calloc(nb_intr, sizeof(int));
+   intr_efds = rte_calloc("ifpga_efds", nb_intr, sizeof(int), 0);
if (!intr_efds)
return -ENOMEM;
 
@@ -1508,7 +1508,7 @@ ifpga_register_msix_irq(struct ifpga_rawdev *dev, int 
port_id,
 
ret = opae_acc_set_irq(acc, vec_start, count, intr_efds);
if (ret) {
-   free(intr_efds);
+   rte_free(intr_efds);
return -EINVAL;
}
}
@@ -1517,13 +1517,13 @@ ifpga_register_msix_irq(struct ifpga_rawdev *dev, int 
port_id,
ret = rte_intr_callback_register(*intr_handle,
handler, (void *)arg);
if (ret) {
-   free(intr_efds);
+   rte_free(intr_efds);
return -EINVAL;
}
 
IFPGA_RAWDEV_PMD_INFO("success register %s interrupt\n", name);
 
-   free(intr_efds);
+   rte_free(intr_efds);
return 0;
 }
 
-- 
2.45.2



[PATCH 15/16] eal: add alloc_function attribute to rte_malloc

2024-09-27 Thread Stephen Hemminger
Use the GCC function attribute to detect cases where
memory is allocated with rte_malloc and freed incorrectly
with libc version of free (and vice versa). Also will detect
some other pointer mismatches.

Signed-off-by: Stephen Hemminger 
---
 lib/eal/include/rte_malloc.h | 55 +---
 1 file changed, 32 insertions(+), 23 deletions(-)

diff --git a/lib/eal/include/rte_malloc.h b/lib/eal/include/rte_malloc.h
index cf3c174022..9e60a36476 100644
--- a/lib/eal/include/rte_malloc.h
+++ b/lib/eal/include/rte_malloc.h
@@ -31,6 +31,22 @@ struct rte_malloc_socket_stats {
size_t heap_allocsz_bytes; /**< Total allocated bytes on heap */
 };
 
+
+/**
+ * Frees the memory space pointed to by the provided pointer.
+ *
+ * This pointer must have been returned by a previous call to
+ * rte_malloc(), rte_zmalloc(), rte_calloc() or rte_realloc(). The behaviour of
+ * rte_free() is undefined if the pointer does not match this requirement.
+ *
+ * If the pointer is NULL, the function does nothing.
+ *
+ * @param ptr
+ *   The pointer to memory to be freed.
+ */
+void
+rte_free(void *ptr);
+
 /**
  * This function allocates memory from the huge-page area of memory. The memory
  * is not cleared. In NUMA systems, the memory allocated resides on the same
@@ -55,7 +71,8 @@ struct rte_malloc_socket_stats {
 void *
 rte_malloc(const char *type, size_t size, unsigned align)
__rte_alloc_size(2)
-   __rte_alloc_align(3);
+   __rte_alloc_align(3)
+   __rte_alloc_func(rte_free);
 
 /**
  * Allocate zeroed memory from the heap.
@@ -83,7 +100,8 @@ rte_malloc(const char *type, size_t size, unsigned align)
 void *
 rte_zmalloc(const char *type, size_t size, unsigned align)
__rte_alloc_size(2)
-   __rte_alloc_align(3);
+   __rte_alloc_align(3)
+   __rte_alloc_func(rte_free);
 
 /**
  * Replacement function for calloc(), using huge-page memory. Memory area is
@@ -111,7 +129,8 @@ rte_zmalloc(const char *type, size_t size, unsigned align)
 void *
 rte_calloc(const char *type, size_t num, size_t size, unsigned align)
__rte_alloc_size(2, 3)
-   __rte_alloc_align(4);
+   __rte_alloc_align(4)
+   __rte_alloc_func(rte_free);
 
 /**
  * Replacement function for realloc(), using huge-page memory. Reserved area
@@ -136,7 +155,8 @@ rte_calloc(const char *type, size_t num, size_t size, 
unsigned align)
 void *
 rte_realloc(void *ptr, size_t size, unsigned int align)
__rte_alloc_size(2)
-   __rte_alloc_align(3);
+   __rte_alloc_align(3)
+   __rte_alloc_func(rte_free);
 
 /**
  * Replacement function for realloc(), using huge-page memory. Reserved area
@@ -163,7 +183,8 @@ rte_realloc(void *ptr, size_t size, unsigned int align)
 void *
 rte_realloc_socket(void *ptr, size_t size, unsigned int align, int socket)
__rte_alloc_size(2)
-   __rte_alloc_align(3);
+   __rte_alloc_align(3)
+   __rte_alloc_func(rte_free);
 
 /**
  * This function allocates memory from the huge-page area of memory. The memory
@@ -191,7 +212,8 @@ rte_realloc_socket(void *ptr, size_t size, unsigned int 
align, int socket)
 void *
 rte_malloc_socket(const char *type, size_t size, unsigned align, int socket)
__rte_alloc_size(2)
-   __rte_alloc_align(3);
+   __rte_alloc_align(3)
+   __rte_alloc_func(rte_free);
 
 /**
  * Allocate zeroed memory from the heap.
@@ -221,7 +243,8 @@ rte_malloc_socket(const char *type, size_t size, unsigned 
align, int socket)
 void *
 rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket)
__rte_alloc_size(2)
-   __rte_alloc_align(3);
+   __rte_alloc_align(3)
+   __rte_alloc_func(rte_free);
 
 /**
  * Replacement function for calloc(), using huge-page memory. Memory area is
@@ -251,22 +274,8 @@ rte_zmalloc_socket(const char *type, size_t size, unsigned 
align, int socket)
 void *
 rte_calloc_socket(const char *type, size_t num, size_t size, unsigned align, 
int socket)
__rte_alloc_size(2, 3)
-   __rte_alloc_align(4);
-
-/**
- * Frees the memory space pointed to by the provided pointer.
- *
- * This pointer must have been returned by a previous call to
- * rte_malloc(), rte_zmalloc(), rte_calloc() or rte_realloc(). The behaviour of
- * rte_free() is undefined if the pointer does not match this requirement.
- *
- * If the pointer is NULL, the function does nothing.
- *
- * @param ptr
- *   The pointer to memory to be freed.
- */
-void
-rte_free(void *ptr);
+   __rte_alloc_align(4)
+   __rte_alloc_func(rte_free);
 
 /**
  * If malloc debug is enabled, check a memory block for header
-- 
2.45.2



[PATCH 12/16] raw/ifpga/base: fix use after free

2024-09-27 Thread Stephen Hemminger
The TAILQ_FOREACH() macro would refer to info after it
had been freed. Fix by introducing TAILQ_FOREACH_SAFE here.

Fixes: 4a19f89104f8 ("raw/ifpga/base: support multiple cards")
Cc: tianfei.zh...@intel.com
Cc: sta...@dpdk.org

Signed-off-by: Stephen Hemminger 
---
 drivers/raw/ifpga/base/opae_intel_max10.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c 
b/drivers/raw/ifpga/base/opae_intel_max10.c
index dd97a5f9fd..d5a9ceb6e3 100644
--- a/drivers/raw/ifpga/base/opae_intel_max10.c
+++ b/drivers/raw/ifpga/base/opae_intel_max10.c
@@ -6,6 +6,13 @@
 #include 
 #include "opae_osdep.h"
 
+#ifndef TAILQ_FOREACH_SAFE
+#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
+   for ((var) = TAILQ_FIRST((head)); \
+   (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
+   (var) = (tvar))
+#endif
+
 int max10_sys_read(struct intel_max10_device *dev,
unsigned int offset, unsigned int *val)
 {
@@ -746,9 +753,9 @@ static int fdt_get_named_reg(const void *fdt, int node, 
const char *name,
 
 static void max10_sensor_uinit(struct intel_max10_device *dev)
 {
-   struct opae_sensor_info *info;
+   struct opae_sensor_info *info, *next;
 
-   TAILQ_FOREACH(info, &dev->opae_sensor_list, node) {
+   TAILQ_FOREACH_SAFE(info, &dev->opae_sensor_list, node, next) {
TAILQ_REMOVE(&dev->opae_sensor_list, info, node);
opae_free(info);
}
-- 
2.45.2



[PATCH 11/16] net/cpfl: fix free of nonheap object

2024-09-27 Thread Stephen Hemminger
With proper annotation, GCC discovers that this driver is
calling rte_free() on an object that was not allocated
(it is part of array in another object).

In function ‘cpfl_flow_js_mr_layout’,
inlined from ‘cpfl_flow_js_mr_action’ at 
../drivers/net/cpfl/cpfl_flow_parser.c:848:9,
inlined from ‘cpfl_flow_js_mod_rule’ at 
../drivers/net/cpfl/cpfl_flow_parser.c:908:9,
inlined from ‘cpfl_parser_init’ at 
../drivers/net/cpfl/cpfl_flow_parser.c:932:8,
inlined from ‘cpfl_parser_create’ at 
../drivers/net/cpfl/cpfl_flow_parser.c:959:8:
../drivers/net/cpfl/cpfl_flow_parser.c:740:9: warning: ‘rte_free’ called on 
pointer ‘*parser.modifications’ with nonzero offset [28, 15479062120396] 
[-Wfree-nonheap-object]
  740 | rte_free(js_mod->layout);
  | ^~~~

Fixes: 6cc97c9971d7 ("net/cpfl: build action mapping rules from JSON")
Cc: wenjing.q...@intel.com
Cc: sta...@dpdk.org

Signed-off-by: Stephen Hemminger 
---
 drivers/net/cpfl/cpfl_flow_parser.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/cpfl/cpfl_flow_parser.c 
b/drivers/net/cpfl/cpfl_flow_parser.c
index 40569ddc6f..30abaad7c8 100644
--- a/drivers/net/cpfl/cpfl_flow_parser.c
+++ b/drivers/net/cpfl/cpfl_flow_parser.c
@@ -737,7 +737,6 @@ cpfl_flow_js_mr_layout(json_t *ob_layouts, struct 
cpfl_flow_js_mr_action_mod *js
return 0;
 
 err:
-   rte_free(js_mod->layout);
return -EINVAL;
 }
 
-- 
2.45.2



[PATCH 13/16] common/qat: fix use after free

2024-09-27 Thread Stephen Hemminger
Checking return value of rte_memzone_free() is pointless
and if it failed then it was because the pointer was null.

Fixes: 7b1374b1e6e7 ("common/qat: limit configuration to primary process")
Cc: arkadiuszx.kusz...@intel.com

Signed-off-by: Stephen Hemminger 
---
 drivers/common/qat/qat_device.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c
index 4a972a83bd..bca88fd9bd 100644
--- a/drivers/common/qat/qat_device.c
+++ b/drivers/common/qat/qat_device.c
@@ -390,11 +390,7 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev)
return qat_dev;
 error:
rte_free(qat_dev->command_line);
-   if (rte_memzone_free(qat_dev_mz)) {
-   QAT_LOG(DEBUG,
-   "QAT internal error! Trying to free already allocated 
memzone: %s",
-   qat_dev_mz->name);
-   }
+   rte_memzone_free(qat_dev_mz);
return NULL;
 }
 
-- 
2.45.2



[PATCH 07/16] net/cnxk: fix use-after-free

2024-09-27 Thread Stephen Hemminger
The driver would refer to the mempool object after it was freed.

Bugzilla ID: 1554
Fixes: 7ea187184a51 ("common/cnxk: support 1-N pool-aura per NIX LF")
Cc: rbhans...@marvell.com
Cc: sta...@dpdk.org

Signed-off-by: Stephen Hemminger 
---
 drivers/net/cnxk/cnxk_ethdev_sec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/cnxk/cnxk_ethdev_sec.c 
b/drivers/net/cnxk/cnxk_ethdev_sec.c
index 6f5319e534..e428d2115d 100644
--- a/drivers/net/cnxk/cnxk_ethdev_sec.c
+++ b/drivers/net/cnxk/cnxk_ethdev_sec.c
@@ -136,8 +136,8 @@ cnxk_nix_inl_custom_meta_pool_cb(uintptr_t pmpool, 
uintptr_t *mpool, const char
return -EINVAL;
}
 
-   rte_mempool_free(hp);
plt_free(hp->pool_config);
+   rte_mempool_free(hp);
 
*aura_handle = 0;
*mpool = 0;
-- 
2.45.2



[PATCH 04/16] dma/ixd: fix incorrect free function in cleanup

2024-09-27 Thread Stephen Hemminger
The data structure is allocated with rte_malloc and incorrectly
freed in cleanup logic using free.

Bugzilla ID: 1549
Fixes: 9449330a8458 ("dma/idxd: create dmadev instances on PCI probe")
Cc: kevin.la...@intel.com
Cc: sta...@dpdk.org

Signed-off-by: Stephen Hemminger 
---
 drivers/dma/idxd/idxd_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c
index 81637d9420..f89e2b41ff 100644
--- a/drivers/dma/idxd/idxd_pci.c
+++ b/drivers/dma/idxd/idxd_pci.c
@@ -301,7 +301,7 @@ init_pci_device(struct rte_pci_device *dev, struct 
idxd_dmadev *idxd,
return nb_wqs;
 
 err:
-   free(pci);
+   rte_free(pci);
return err_code;
 }
 
-- 
2.45.2



Re: [PATCH] dts: add per-test-suite configuration

2024-09-27 Thread Jeremy Spewock
Hi Luca,

I apologize for not giving this patch more time/attention. I think
this patch is worth having a more in-depth discussion about since it
does add quite a bit more complexity, but the benefit of that is some
valuable simplicity. I know we discussed in the recent team meeting
about whether or not to have the test suite configurations in
conf.yaml or make ones specifically for each individual test suite,
and I think that it could really go either way, but that them being in
conf.yaml is potentially slightly better in my opinion as it helps
keep things uniform, but obviously you get into trouble there if there
is a lot of configuration and the file gets long.

On Fri, Sep 6, 2024 at 12:14 PM Luca Vizzarro  wrote:
>
> Allow test suites to be configured individually. Moreover enable them to
> implement their own custom configuration.
>
> This solution adds some new complexity to DTS, which is generated source
> code. In order to ensure strong typing, the test suites and their custom

Generated source code is definitely something new and interesting. I
think the way you did it makes sense and it's well written, but the
idea of generated source code scares me slightly. It leads to the sort
of additional requirement when you are writing test suites to
regenerate the code if you have a custom config, and seems a little
harder to maintain (although, I doubt much maintenance will really be
needed on it, so maybe that's not a good point). It makes me wonder if
the very dumb approach of test suites just each getting a yaml file
that matches the same of the test suite (and maybe ends with _conf)
and then importing that into a TypedDict like we do with conf.yaml
would be worth it to save on this complexity. It would still be simple
enough for a test suite developer to just throw a yaml file into a
directory (maybe conf/ ?) and have the framework auto-magically
consume that and match it to a TypedDict. I guess there would be some
extra rules in place with the dumb approach like the name of the
config file and maybe the name of the TypedDict, but it still feels
like it would save on complexity in the long run. Of course, that's
not to say complexity is bad if it makes things easier, but it begs
the question of how much easier is doing it this way versus making a
yaml file and a matching TypedDict.

Again, something good to discuss in a meeting.

> configurations need to be linked in the main configuration class.
> Unfortunately, this is not feasible during runtime as it will incur in
> circular dependencies. Generating the links appear to be the most
> straightforward approach.
>
> This commit also brings a new major change to the configuration schema.
> Test suites are no longer defined as a list of strings, like:
>
> test_suites:
> - hello_world
> - pmd_buffer_scatter
>
> but as mapping of mappings or strings:
>
> test_suites:
>   hello_world: {} # any custom fields or test cases can be set here
>   pmd_buffer_scatter: all # "all" defines all the test cases, or
>   # they can individually be set separated
>   # by a space
>
> Not defining the `test_cases` field in the configuration is equivalent
> to `all`, therefore the definitions for either test suite above are
> also equivalent.

Making these mappings in general however that also allow you to
specify which test cases to run I really like. It doesn't seem
completely relevant to the suite-wide configurations though, maybe it
would make sense to be in a different patch? I get why it's all in one
though since it they are handled in the same places.

>
> Creating the __init__.py file under the tests folder, allows it to be
> picked up as a package. This is a mypy requirement to import the tests
> from within the framework.
>
> Bugzilla ID: 1375
>
> Signed-off-by: Luca Vizzarro 
> Reviewed-by: Paul Szczepanek 
> Reviewed-by: Alex Chapman 

I didn't really have any comments on this implementation overall
however. I didn't fully understand everything (mostly due to my lack
of pydantic understanding) so I probably would have had to read it
over a few more times to completely understand it, but in general I
think this seems well written. Great work Luca.

> ---
> Depends-on: series-32823 ("dts: Pydantic configuration")
>
> Hello,
>
> sending in a solution for the per-test-suite configuration issue.
> This one took some thinking but I have given most of the motivations in
> the commit body already. The docs are somewhat lacking but hopefully they
> should be automatically tackled by the API docs generation.
>
>
> Best,
> Luca
> ---
>  doc/guides/tools/dts.rst   |  39 --
>  dts/conf.yaml  |   4 +-
>  dts/framework/config/__init__.py   |  98 ++-
>  dts/framework/config/conf_yaml_schema.json |  94 +++---
>  dts/framework/config/generated.py  |  40 ++
>  dts/framework/config/test_suite.py | 140 ++

[PATCH v2 05/47] net/bnxt: tf_core: flow scale improvement

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

Added logic to add flows to wildcard tcam if flows fail to be added to
exact match table.

Signed-off-by: Kishore Padmanabha 
Reviewed-by: Michael Baucom 
Reviewed-by: Ajit Khaparde 
Reviewed-by: Shahaji Bhosle 
Signed-off-by: Sriharsha Basavapatna 
---
 drivers/net/bnxt/tf_core/tf_em_hash_internal.c | 4 ++--
 drivers/net/bnxt/tf_core/tf_msg.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c 
b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
index d72ac83295..cb8da0e370 100644
--- a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c
@@ -65,7 +65,7 @@ tf_em_hash_insert_int_entry(struct tf *tfp,
PMD_DRV_LOG(ERR,
"%s, EM entry index allocation failed\n",
tf_dir_2_str(parms->dir));
-   return -1;
+   return -ENOMEM; /* no more space to add entries */
}
 
if (dev->ops->tf_dev_cfa_key_hash == NULL)
@@ -87,7 +87,7 @@ tf_em_hash_insert_int_entry(struct tf *tfp,
if (rc) {
/* Free the allocated index before returning */
dpool_free(pool, index);
-   return -1;
+   return rc;
}
 
TF_SET_GFID(gfid,
diff --git a/drivers/net/bnxt/tf_core/tf_msg.c 
b/drivers/net/bnxt/tf_core/tf_msg.c
index dd5ea1c80e..1ef828a1e9 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -925,7 +925,7 @@ tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
if (msg_record_size > TF_MSG_EM_INSERT_RECORD_SIZE) {
rc = -EINVAL;
TFP_DRV_LOG(ERR,
-   "%s: Record size to large, rc:%s\n",
+   "%s: Record size too large, rc:%s\n",
tf_dir_2_str(em_parms->dir),
strerror(-rc));
return rc;
-- 
2.39.3



[PATCH v2 04/47] net/bnxt: tf_core: Thor TF EM key size check

2024-09-27 Thread Sriharsha Basavapatna
From: Farah Smith 

The maximum EM key size is 640 bits for Thor.  But the lookup record
+ the key size is 679 bits.  This value must be rounded up to a 128 bit
aligned number.  So the size check should be 96 bytes rather than 80.
This fix allows keys > 601 bits to be successfully inserted.

Fixes: 539931eab3a5 ("net/bnxt: support EM with FKB")
Signed-off-by: Farah Smith 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Farah Smith 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Shahaji Bhosle 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_core/tf_msg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/tf_core/tf_msg.c 
b/drivers/net/bnxt/tf_core/tf_msg.c
index 08e9783d52..dd5ea1c80e 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -25,7 +25,7 @@
  */
 #define TF_MSG_SET_GLOBAL_CFG_DATA_SIZE  16
 #define TF_MSG_EM_INSERT_KEY_SIZE64
-#define TF_MSG_EM_INSERT_RECORD_SIZE 80
+#define TF_MSG_EM_INSERT_RECORD_SIZE 96
 #define TF_MSG_TBL_TYPE_SET_DATA_SIZE88
 
 /* Compile check - Catch any msg changes that we depend on, like the
-- 
2.39.3



[PATCH v2 42/47] net/bnxt: tf_ulp: TFC support flow scale query for Thor2

2024-09-27 Thread Sriharsha Basavapatna
From: Shuanglin Wang 

TFC supports the flow scale query feature for OVS application.
The resource usage(WC-TCAM) is tracked inside Thor2 firmware.
This patch is to query the wc-tcam usage info when adding/
deleting a flow. It is just for debugging purpose and disabled by
default.

Using the build flag -DTF_FLOW_SCALE_QUERY to enable it.
And users should use niccli to query the resource usage.

Signed-off-by: Shuanglin Wang 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c |  6 ++
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c  |  9 +
 drivers/net/bnxt/tf_ulp/ulp_mapper.c   | 26 --
 drivers/net/bnxt/tf_ulp/ulp_mapper.h   |  5 +
 4 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
index 9c9e206285..31ab61b512 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
@@ -34,6 +34,7 @@
 #include "ulp_ha_mgr.h"
 #include "bnxt_tf_pmd_shim.h"
 #include "ulp_template_db_tbl.h"
+#include "tfc_resources.h"
 
 /* define to enable shared table scope */
 #define TFC_SHARED_TBL_SCOPE_ENABLE 0
@@ -1052,6 +1053,11 @@ ulp_tfc_init(struct bnxt *bp,
}
}
 
+#ifdef TF_FLOW_SCALE_QUERY
+   /* Query resource statstics from firmware */
+   tfc_resc_usage_query_all(bp);
+#endif /* TF_FLOW_SCALE_QUERY */
+
BNXT_DRV_DBG(DEBUG, "ulp ctx has been initialized\n");
return rc;
 
diff --git a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c 
b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
index 341c8c2dfe..8984808b67 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_flow_db.c
@@ -15,6 +15,7 @@
 #include "ulp_tun.h"
 #ifdef TF_FLOW_SCALE_QUERY
 #include "tf_resources.h"
+#include "tfc_resources.h"
 #endif /* TF_FLOW_SCALE_QUERY */
 
 #define ULP_FLOW_DB_RES_DIR_BIT31
@@ -963,11 +964,12 @@ ulp_flow_db_flush_flows(struct bnxt_ulp_context *ulp_ctx,
 #ifdef TF_FLOW_SCALE_QUERY
tf_resc_pause_usage_update();
 #endif
+
while (!ulp_flow_db_next_entry_get(flow_db, flow_type, &fid))
ulp_mapper_resources_free(ulp_ctx, flow_type, fid, NULL);
+
 #ifdef TF_FLOW_SCALE_QUERY
-   tf_resc_resume_usage_update();
-   tf_resc_usage_update_all(ulp_ctx->bp);
+   ulp_resc_usage_sync(ulp_ctx);
 #endif
 
bnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);
@@ -1017,8 +1019,7 @@ ulp_flow_db_function_flow_flush(struct bnxt_ulp_context 
*ulp_ctx,
  NULL);
}
 #ifdef TF_FLOW_SCALE_QUERY
-   tf_resc_resume_usage_update();
-   tf_resc_usage_update_all(ulp_ctx->bp);
+   ulp_resc_usage_sync(ulp_ctx);
 #endif
bnxt_ulp_cntxt_release_fdb_lock(ulp_ctx);
return 0;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c 
b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 5dfe72df17..c595e7cfc3 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -24,6 +24,7 @@
 #include "bnxt_tf_pmd_shim.h"
 #ifdef TF_FLOW_SCALE_QUERY
 #include "tf_resources.h"
+#include "tfc_resources.h"
 #endif /* TF_FLOW_SCALE_QUERY */
 
 static uint8_t mapper_fld_zeros[16] = { 0 };
@@ -4322,7 +4323,7 @@ ulp_mapper_resources_free(struct bnxt_ulp_context 
*ulp_ctx,
 #ifdef TF_FLOW_SCALE_QUERY
/* update for regular flows only */
if (flow_type == BNXT_ULP_FDB_TYPE_REGULAR)
-   tf_resc_usage_update_all(ulp_ctx->bp);
+   ulp_resc_usage_sync(ulp_ctx);
 #endif /* TF_FLOW_SCALE_QUERY */
 
return frc;
@@ -4475,7 +4476,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
}
 
 #ifdef TF_FLOW_SCALE_QUERY
-   tf_resc_usage_update_all(ulp_ctx->bp);
+   ulp_resc_usage_sync(ulp_ctx);
 #endif /* TF_FLOW_SCALE_QUERY */
 
return rc;
@@ -4514,6 +4515,27 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
return rc;
 }
 
+#ifdef TF_FLOW_SCALE_QUERY
+/* Sync resource usage state with firmware */
+int ulp_resc_usage_sync(struct bnxt_ulp_context *ulp_ctx)
+{
+   uint32_t dev_id;
+   if (unlikely(bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id))) {
+   BNXT_DRV_DBG(ERR, "Invalid ulp context\n");
+   return -EINVAL;
+   }
+
+   if (dev_id == BNXT_ULP_DEVICE_ID_THOR) {
+   tf_resc_resume_usage_update();
+   tf_resc_usage_update_all(ulp_ctx->bp);
+   } else if (dev_id == BNXT_ULP_DEVICE_ID_THOR2) {
+   tfc_resc_usage_query_all(ulp_ctx->bp);
+   }
+
+   return 0;
+}
+#endif /* TF_FLOW_SCALE_QUERY */
+
 int32_t
 ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx)
 {
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.h 
b/drivers/net/bnxt/tf_ulp/ulp_mapper.h
index 0f43e2a8b5..d2fc716232 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.h
@@ -

[PATCH v2 39/47] net/bnxt: tf_ulp: switch ulp to use rte crc32 hash

2024-09-27 Thread Sriharsha Basavapatna
From: Peter Spreadborough 

The RTE hash is highly optimized and will use HW acceleration
when available.

Signed-off-by: Peter Spreadborough 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Kishore Padmanabha 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c  |  4 
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c |  4 
 drivers/net/bnxt/tf_ulp/ulp_gen_hash.c | 28 ++
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
index 99a6bac0ce..c591f9327c 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "bnxt.h"
 #include "bnxt_ulp.h"
@@ -1457,6 +1458,9 @@ ulp_tf_init(struct bnxt *bp,
int rc;
uint32_t ulp_dev_id = BNXT_ULP_DEVICE_ID_LAST;
 
+   /* Select 64bit SSE4.2 intrinsic if available */
+   rte_hash_crc_set_alg(CRC32_SSE42_x64);
+
/* Allocate and Initialize the ulp context. */
rc = ulp_tf_ctx_init(bp, session);
if (rc) {
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
index 765ae9f6aa..e5bb24299e 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "bnxt.h"
 #include "bnxt_ulp.h"
@@ -924,6 +925,9 @@ ulp_tfc_init(struct bnxt *bp,
uint16_t sid;
int rc;
 
+   /* Select 64bit SSE4.2 intrinsic if available */
+   rte_hash_crc_set_alg(CRC32_SSE42_x64);
+
rc = bnxt_ulp_devid_get(bp, &ulp_dev_id);
if (rc) {
BNXT_DRV_DBG(ERR, "Unable to get device id from ulp.\n");
diff --git a/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c 
b/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
index 17bb9c6b32..7d68bfc778 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c
@@ -5,10 +5,10 @@
 
 #include 
 #include 
+#include 
 #include "bnxt_tf_common.h"
 #include "ulp_gen_hash.h"
 #include "ulp_utils.h"
-#include "tf_hash.h"
 
 static
 int32_t ulp_bit_alloc_list_alloc(struct bit_alloc_list *blist,
@@ -203,8 +203,29 @@ ulp_gen_hash_tbl_list_key_search(struct ulp_gen_hash_tbl 
*hash_tbl,
}
 
/* calculate the hash */
-   hash_id = tf_hash_calc_crc32(entry->key_data,
-hash_tbl->key_tbl.data_size);
+   switch (hash_tbl->key_tbl.data_size) {
+   case 1:
+   hash_id = rte_hash_crc_1byte(*entry->key_data,
+~0U);
+   break;
+   case 2:
+   hash_id = rte_hash_crc_2byte(*((uint16_t *)entry->key_data),
+~0U);
+   break;
+   case 4:
+   hash_id = rte_hash_crc_4byte(*((uint32_t *)entry->key_data),
+~0U);
+   break;
+   case 8:
+   hash_id = rte_hash_crc_8byte(*((uint64_t *)entry->key_data),
+~0U);
+   break;
+   default:
+   hash_id = rte_hash_crc(entry->key_data,
+  hash_tbl->key_tbl.data_size,
+  ~0U);
+   break;
+   }
hash_id = (uint16_t)(((hash_id >> 16) & 0x) ^ (hash_id & 0x));
hash_id &= hash_tbl->hash_mask;
hash_id = hash_id * hash_tbl->hash_bkt_num;
@@ -375,4 +396,3 @@ ulp_gen_hash_tbl_list_del(struct ulp_gen_hash_tbl *hash_tbl,
 
return 0;
 }
-
-- 
2.39.3



[PATCH v2 41/47] net/bnxt: tf_ulp: support a few generic template items

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

This patch provides the following changes.

support generic template items
Add support for jump action, dynamic tunnels and
flow priority to thor2 platform.

fix generic application template
The queue action is enabled for Thor2 platform.
Enabled rejection check for every action template.
Fixed dynamic vxlan ip tunnel configuration.

fix vxlan ip customer tunnel
The upar id is not populated correctly to set the
tunnel id in the tcam table.

fix compiler warnings
This change fixes several compiler warnings.

Signed-off-by: Kishore Padmanabha 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Michael Baucom 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c   |  9 +
 drivers/net/bnxt/tf_ulp/ulp_mapper.c | 11 +++
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 12 
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
index e5bb24299e..9c9e206285 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c
@@ -536,6 +536,15 @@ ulp_tfc_cntxt_app_caps_init(struct bnxt *bp, uint8_t 
app_id, uint32_t dev_id)
}
}
ulp_ctx->cfg_data->feature_bits = info[i].feature_bits;
+   bnxt_ulp_default_app_priority_set(ulp_ctx,
+ info[i].default_priority);
+   bnxt_ulp_max_def_priority_set(ulp_ctx,
+ info[i].max_def_priority);
+   bnxt_ulp_min_flow_priority_set(ulp_ctx,
+  info[i].min_flow_priority);
+   bnxt_ulp_max_flow_priority_set(ulp_ctx,
+  info[i].max_flow_priority);
+
bnxt_ulp_cntxt_ptr2_default_class_bits_set(ulp_ctx,
   
info[i].default_class_bits);
bnxt_ulp_cntxt_ptr2_default_act_bits_set(ulp_ctx,
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c 
b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index f0d715d369..5dfe72df17 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -872,7 +872,7 @@ ulp_mapper_field_src_process(struct bnxt_ulp_mapper_parms 
*parms,
struct bnxt_ulp_mapper_data *m;
uint8_t bit;
uint32_t port_id, val_size, field_size;
-   uint16_t idx, size_idx, offset;
+   uint16_t idx = 0, size_idx = 0, offset = 0;
uint32_t bytelen = ULP_BITS_2_BYTE(bitlen);
uint8_t *buffer;
uint64_t lregval;
@@ -1291,7 +1291,7 @@ ulp_mapper_field_opc_next(struct bnxt_ulp_mapper_parms 
*parms,
  const char *name)
 {
struct bnxt_ulp_mapper_field_info *field_info;
-   uint16_t idx;
+   uint16_t idx = 0;
 
/* read the cond table index and count */
if (unlikely(ulp_operand_read(field_opr,
@@ -1594,7 +1594,7 @@ ulp_mapper_key_recipe_field_opc_next(struct 
bnxt_ulp_mapper_parms *parms,
 struct bnxt_ulp_mapper_field_info *ofld)
 {
struct bnxt_ulp_mapper_field_info *field_info;
-   uint16_t idx;
+   uint16_t idx = 0;
 
/* read the cond table index and count */
if (unlikely(ulp_operand_read(field_opr,
@@ -3777,11 +3777,6 @@ ulp_mapper_cond_reject_list_process(struct 
bnxt_ulp_mapper_parms *parms,
/* set the rejection result to accept */
*res = 0;
 
-   /* If act rej cond is not enabled then skip reject cond processing */
-   if (parms->tmpl_type == BNXT_ULP_TEMPLATE_TYPE_ACTION &&
-   !ULP_COMP_FLD_IDX_RD(parms, BNXT_ULP_CF_IDX_ACT_REJ_COND_EN))
-   return rc;
-
/* get the reject condition list */
reject_info = ulp_mapper_tmpl_reject_list_get(parms, tid);
 
diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c 
b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
index 72d3514647..dbd8a118df 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
@@ -1298,6 +1298,7 @@ ulp_rte_l4_proto_type_update(struct ulp_rte_parser_params 
*params,
 enum bnxt_ulp_hdr_bit hdr_bit)
 {
uint16_t stat_port = 0;
+   struct bnxt *bp;
 
switch (hdr_bit) {
case BNXT_ULP_HDR_BIT_I_UDP:
@@ -1364,10 +1365,21 @@ ulp_rte_l4_proto_type_update(struct 
ulp_rte_parser_params *params,
 
/* if udp and equal to static vxlan port then set tunnel bits*/
if (stat_port && dst_port == tfp_cpu_to_be_16(stat_port)) {
+   bp = bnxt_pmd_get_bp(params->port_id);
+   if (bp == NULL) {
+   BNXT_DRV_DBG(ERR, "Invalid bp\n");
+   return;
+   }
   

[PATCH v2 30/47] net/bnxt: tf_ulp: add mask defaults when mask is not specified

2024-09-27 Thread Sriharsha Basavapatna
From: Kishore Padmanabha 

If application does not specify mask in a field description then
use the default mask values from dpdk header files.

This patch also includes the following related changes.

fix stats collection for shared session
The stats accumulation was being performed on default session,
it needs to get the correct session type to get shared session
counters.

updated ulp flow db for 64 bit handles
Updated the ulp flow database so that all the hardware handles
are 64 bit for all the resource types.

Template rejection with no tables fails for vf to vf
Fixed the template rejection logic to include the table even on
unconditional rejection.  This was exposed for vf to vf traffic on
Thor 2 and resulted in a segmentation fault.

fix spec and default mask parsing for flow items.
Fixed the protocol header parsing when bith spec and mask are
not given.

Thor2 priority for l2 tcam records not adhered to
Fix l2 context records priority in template compiler
Fix flow handle mask offset
Fix cpu_to_le_16 macro issues
Fix misspellings in code

Signed-off-by: Kishore Padmanabha 
Signed-off-by: Sriharsha Basavapatna 
Reviewed-by: Shuanglin Wang 
Reviewed-by: Shahaji Bhosle 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c |  6 +-
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h |  2 +
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tf.c  | 17 +++--
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tfc.c |  1 +
 drivers/net/bnxt/tf_ulp/ulp_flow_db.c| 92 +---
 drivers/net/bnxt/tf_ulp/ulp_flow_db.h| 27 +++
 drivers/net/bnxt/tf_ulp/ulp_mapper.c |  7 +-
 drivers/net/bnxt/tf_ulp/ulp_mapper_tfc.c |  4 +-
 drivers/net/bnxt/tf_ulp/ulp_matcher.c| 10 +--
 drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 64 +++--
 10 files changed, 118 insertions(+), 112 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c 
b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
index 0c46c7d4c9..eb2d14f3be 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c
@@ -525,6 +525,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context 
*ctxt,
bool found_cntr_resource = false;
bool found_parent_flow = false;
uint32_t pc_idx = 0;
+   uint32_t session_type = 0;
uint8_t dir;
 
ulp_fc_info = bnxt_ulp_cntxt_ptr2_fc_info_get(ctxt);
@@ -569,8 +570,9 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context 
*ctxt,
}
 
dir = params.direction;
+   session_type = ulp_flow_db_shared_session_get(¶ms);
if (!(ulp_fc_info->flags & ULP_FLAG_FC_SW_AGG_EN)) {
-   rc = fc_ops->ulp_flow_stat_get(ctxt, dir,
+   rc = fc_ops->ulp_flow_stat_get(ctxt, dir, session_type,
   params.resource_hndl, count);
bnxt_ulp_cntxt_release_fdb_lock(ctxt);
return rc;
@@ -581,7 +583,7 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context 
*ctxt,
BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TABLE_INT_COUNT) {
hw_cntr_id = params.resource_hndl;
if (!ulp_fc_info->num_counters) {
-   rc = fc_ops->ulp_flow_stat_get(ctxt, dir,
+   rc = fc_ops->ulp_flow_stat_get(ctxt, dir, session_type,
   hw_cntr_id, count);
bnxt_ulp_cntxt_release_fdb_lock(ctxt);
return rc;
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h 
b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
index daa2210728..0b81be7af9 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h
@@ -7,6 +7,7 @@
 #define _ULP_FC_MGR_H_
 
 #include "bnxt_ulp.h"
+#include "ulp_flow_db.h"
 
 #define ULP_FLAG_FC_THREAD BIT(0)
 #define ULP_FLAG_FC_SW_AGG_EN  BIT(1)
@@ -28,6 +29,7 @@ struct bnxt_ulp_fc_core_ops {
int32_t
(*ulp_flow_stat_get)(struct bnxt_ulp_context *ctxt,
 uint8_t direction,
+uint32_t session_type,
 uint64_t handle,
 struct rte_flow_query_count *count);
int32_t
diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tf.c 
b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tf.c
index 9c91569473..cd6d067bc9 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tf.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr_tf.c
@@ -157,17 +157,19 @@ ulp_fc_tf_update_accum_stats(struct bnxt_ulp_context 
*ctxt,
enum tf_dir dir;
struct tf *tfp;
 
-   tfp = bnxt_ulp_cntxt_tfp_get(ctxt, BNXT_ULP_SESSION_TYPE_DEFAULT);
-   if (!tfp) {
-   BNXT_DRV_DBG(ERR, "Failed to get the truflow pointer\n");
-   return 0; /* This can happen, return for now with success */
-   }
-
num_entries = dparms->flow_cou

[PATCH 3/7] dts: fix remote session file transfer vars

2024-09-27 Thread Tomáš Ďurovec
The OSSession (and its subclasses) should accept PurePaths
for remote paths to translate from OS-unaware (PurePath)
to OS-aware (Path) only on the remote side. For local paths,
they should accept Paths, as Python is OS-aware locally.

Signed-off-by: Tomáš Ďurovec 
---
 .../remote_session/remote_session.py  | 24 ++--
 dts/framework/remote_session/ssh_session.py   | 18 
 dts/framework/testbed_model/os_session.py | 28 ---
 dts/framework/testbed_model/posix_session.py  | 18 
 4 files changed, 30 insertions(+), 58 deletions(-)

diff --git a/dts/framework/remote_session/remote_session.py 
b/dts/framework/remote_session/remote_session.py
index 8c580b070f..ab83f5b266 100644
--- a/dts/framework/remote_session/remote_session.py
+++ b/dts/framework/remote_session/remote_session.py
@@ -12,7 +12,7 @@
 
 from abc import ABC, abstractmethod
 from dataclasses import InitVar, dataclass, field
-from pathlib import PurePath
+from pathlib import Path, PurePath
 
 from framework.config import NodeConfiguration
 from framework.exception import RemoteCommandExecutionError
@@ -196,35 +196,29 @@ def is_alive(self) -> bool:
 """Check whether the remote session is still responding."""
 
 @abstractmethod
-def copy_from(
-self,
-source_file: str | PurePath,
-destination_file: str | PurePath,
-) -> None:
+def copy_from(self, source_file: str | PurePath, destination_dir: str | 
Path) -> None:
 """Copy a file from the remote Node to the local filesystem.
 
 Copy `source_file` from the remote Node associated with this remote 
session
-to `destination_file` on the local filesystem.
+to `destination_dir` on the local filesystem.
 
 Args:
 source_file: The file on the remote Node.
-destination_file: A file or directory path on the local filesystem.
+destination_dir: The directory path on the local filesystem where 
the `source_file`
+will be saved.
 """
 
 @abstractmethod
-def copy_to(
-self,
-source_file: str | PurePath,
-destination_file: str | PurePath,
-) -> None:
+def copy_to(self, source_file: str | Path, destination_dir: str | 
PurePath) -> None:
 """Copy a file from local filesystem to the remote Node.
 
-Copy `source_file` from local filesystem to `destination_file` on the 
remote Node
+Copy `source_file` from local filesystem to `destination_dir` on the 
remote Node
 associated with this remote session.
 
 Args:
 source_file: The file on the local filesystem.
-destination_file: A file or directory path on the remote Node.
+destination_dir: The directory path on the remote Node where the 
`source_file`
+will be saved.
 """
 
 @abstractmethod
diff --git a/dts/framework/remote_session/ssh_session.py 
b/dts/framework/remote_session/ssh_session.py
index 66f8176833..329121913f 100644
--- a/dts/framework/remote_session/ssh_session.py
+++ b/dts/framework/remote_session/ssh_session.py
@@ -5,7 +5,7 @@
 
 import socket
 import traceback
-from pathlib import PurePath
+from pathlib import Path, PurePath
 
 from fabric import Connection  # type: ignore[import-untyped]
 from invoke.exceptions import (  # type: ignore[import-untyped]
@@ -103,21 +103,13 @@ def is_alive(self) -> bool:
 """Overrides :meth:`~.remote_session.RemoteSession.is_alive`."""
 return self.session.is_connected
 
-def copy_from(
-self,
-source_file: str | PurePath,
-destination_file: str | PurePath,
-) -> None:
+def copy_from(self, source_file: str | PurePath, destination_dir: str | 
Path) -> None:
 """Overrides :meth:`~.remote_session.RemoteSession.copy_from`."""
-self.session.get(str(destination_file), str(source_file))
+self.session.get(str(source_file), str(destination_dir))
 
-def copy_to(
-self,
-source_file: str | PurePath,
-destination_file: str | PurePath,
-) -> None:
+def copy_to(self, source_file: str | Path, destination_dir: str | 
PurePath) -> None:
 """Overrides :meth:`~.remote_session.RemoteSession.copy_to`."""
-self.session.put(str(source_file), str(destination_file))
+self.session.put(str(source_file), str(destination_dir))
 
 def close(self) -> None:
 """Overrides :meth:`~.remote_session.RemoteSession.close`."""
diff --git a/dts/framework/testbed_model/os_session.py 
b/dts/framework/testbed_model/os_session.py
index 79f56b289b..1aac3659bf 100644
--- a/dts/framework/testbed_model/os_session.py
+++ b/dts/framework/testbed_model/os_session.py
@@ -25,7 +25,7 @@
 from abc import ABC, abstractmethod
 from collections.abc import Iterable
 from ipaddress import IPv4Interface, IPv6Interface
-from pathlib import PurePath
+from pathlib import Path, PurePath
 from typing import

Re: [PATCH v1] ethdev: fix int overflow in descriptor count logic

2024-09-27 Thread Meade, Niall
> From: Ferruh Yigit 
> Sent: Thursday, September 26, 2024 12:16 AM
> To: Meade, Niall ; Thomas Monjalon 
> ; Andrew Rybchenko ; 
> Roman Zhukov 
> Cc: dev@dpdk.org 
> Subject: Re: [PATCH v1] ethdev: fix int overflow in descriptor count logic

> > The resolution involves upcasting nb_desc to a uint32_t before the
> > RTE_ALIGN_CEIL macro is applied. This change ensures that the subsequent
> > call to RTE_ALIGN_FLOOR(nb_desc + (nb_align - 1), nb_align) does not
> > result in an overflow, as it would when nb_desc is a uint16_t. By using
> > a uint32_t for these operations, the correct behavior is maintained
> > without the risk of overflow.
> >
>
> Hi Niall,

Hi Ferruh,

> Thanks for the patch.
>
> For the 'RTE_ALIGN_CEIL(val, align)' macro, 'align' should be power of
> two, as 'desc_lim->nb_align' is uint16_t, max value it can get is 2^15.
> 'val' should be smaller than or equal to 'align', so '*nb_desc' can be
> maximum 2^15.
>
> So RTE_ALIGN_CEIL(2^15-1, 2^15) = 2^15, I think this should work fine
> (although I didn't test).
>
> And even with your uint32_t cast, I think following will fail:
> RTE_ALIGN_CEIL(2^16-1, 2^15)
> (again, not tested).
>

I tested my code with these values and the behaviour is as expected from
what I can see.
At a high level I ran into this issue when passing uint16_tMAX into
rte_eth_dev_adjust_nb_rx_tx_desc() with the intent of selecting the maximum
ring descriptor size but the minimum was selected.

> Or maybe I am missing a case, can you please give some actual numbers to
> show the problem and the fix?

Yes sure! If we take an example of val= (2^16)-1 and align= 32.
RTE_ALIGN_CEIL(val, align) calls RTE_ALIGN_FLOOR(val + align - 1, align). With
val as a uint16_t this subsequent macro call results in a wrap around for val
(originally was the max uint16_t and now we are attempting to add align to
it). The returned value of RTE_ALIGN_CEIL() in this case is 0. This results in
nb_desc being set to 0, and later set to the minimum ring descriptor size for
that NIC with *nb_desc = RTE_MAX(*nb_desc, desc_lim->nb_min).

While this example is an unreasonably large request for a descriptor ring size,
the expected behaviour would be that the descriptor ring size defaults back to
the maximum possible for that particular NIC, not to the minimum which it
currently does.
By introducing a uint32_t, the wrap around in RTE_ALIGN_FLOOR() is avoided,
keeping the large value of nb_desc_32 which is later set to an appropriate size
in RTE_MIN(*nb_desc_32, desc_lim->nb_max)


> >  {
> > +     /* Upcast to uint32 to avoid potential overflow with 
> > RTE_ALIGN_CEIL(). */
> > +     uint32_t nb_desc_32 = *nb_desc;
> > +
> >        if (desc_lim->nb_align != 0)
> > -             *nb_desc = RTE_ALIGN_CEIL(*nb_desc, desc_lim->nb_align);
> > +             nb_desc_32 = RTE_ALIGN_CEIL(nb_desc_32, desc_lim->nb_align);

--
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263


This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.



[PATCH 2/7] dts: one dpdk build per test run

2024-09-27 Thread Tomáš Ďurovec
When the DPDK build can be already pre-build, there is
not a need for defining multiple build targets. To make
it cleaner we decide to use one DPDK build wheater can
be pre-build or DTS will build it.

Signed-off-by: Tomáš Ďurovec 
---
 dts/conf.yaml  |  14 +--
 dts/framework/config/__init__.py   |   9 +-
 dts/framework/config/conf_yaml_schema.json |  10 +-
 dts/framework/config/types.py  |   2 +-
 dts/framework/logger.py|   4 -
 dts/framework/runner.py| 117 +---
 dts/framework/test_result.py   | 119 ++---
 dts/framework/test_suite.py|   2 +-
 dts/framework/testbed_model/sut_node.py|   6 +-
 dts/tests/TestSuite_smoke_tests.py |   2 +-
 10 files changed, 80 insertions(+), 205 deletions(-)

diff --git a/dts/conf.yaml b/dts/conf.yaml
index 1363e93580..814744a1fc 100644
--- a/dts/conf.yaml
+++ b/dts/conf.yaml
@@ -4,13 +4,13 @@
 
 test_runs:
   # define one test run environment
-  - dpdk_builds:
-  - arch: x86_64
-os: linux
-cpu: native
-# the combination of the following two makes CC="ccache gcc"
-compiler: gcc
-compiler_wrapper: ccache
+  - dpdk_build:
+  arch: x86_64
+  os: linux
+  cpu: native
+  # the combination of the following two makes CC="ccache gcc"
+  compiler: gcc
+  compiler_wrapper: ccache
 perf: false # disable performance testing
 func: true # enable functional testing
 skip_smoke_tests: false # optional
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index c243716010..49b2e8d016 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -437,7 +437,7 @@ class TestRunConfiguration:
 and with what DPDK build.
 
 Attributes:
-dpdk_builds: A list of DPDK builds to test.
+dpdk_build: A DPDK build to test.
 perf: Whether to run performance tests.
 func: Whether to run functional tests.
 skip_smoke_tests: Whether to skip smoke tests.
@@ -448,7 +448,7 @@ class TestRunConfiguration:
 random_seed: The seed to use for pseudo-random generation.
 """
 
-dpdk_builds: list[DPDKBuildConfiguration]
+dpdk_build: DPDKBuildConfiguration
 perf: bool
 func: bool
 skip_smoke_tests: bool
@@ -477,9 +477,6 @@ def from_dict(
 Returns:
 The test run configuration instance.
 """
-dpdk_builds: list[DPDKBuildConfiguration] = list(
-map(DPDKBuildConfiguration.from_dict, d["dpdk_builds"])
-)
 test_suites: list[TestSuiteConfig] = 
list(map(TestSuiteConfig.from_dict, d["test_suites"]))
 sut_name = d["system_under_test_node"]["node_name"]
 skip_smoke_tests = d.get("skip_smoke_tests", False)
@@ -501,7 +498,7 @@ def from_dict(
 )
 random_seed = d.get("random_seed", None)
 return cls(
-dpdk_builds=dpdk_builds,
+dpdk_build=DPDKBuildConfiguration.from_dict(d["dpdk_build"]),
 perf=d["perf"],
 func=d["func"],
 skip_smoke_tests=skip_smoke_tests,
diff --git a/dts/framework/config/conf_yaml_schema.json 
b/dts/framework/config/conf_yaml_schema.json
index 927a73ac6c..94d7efa5f5 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -327,12 +327,8 @@
   "items": {
 "type": "object",
 "properties": {
-  "dpdk_builds": {
-"type": "array",
-"items": {
-  "$ref": "#/definitions/dpdk_build"
-},
-"minimum": 1
+  "dpdk_build": {
+"$ref": "#/definitions/dpdk_build"
   },
   "perf": {
 "type": "boolean",
@@ -387,7 +383,7 @@
 },
 "additionalProperties": false,
 "required": [
-  "dpdk_builds",
+  "dpdk_build",
   "perf",
   "func",
   "test_suites",
diff --git a/dts/framework/config/types.py b/dts/framework/config/types.py
index 4f450267d1..a710c20d6a 100644
--- a/dts/framework/config/types.py
+++ b/dts/framework/config/types.py
@@ -108,7 +108,7 @@ class TestRunConfigDict(TypedDict):
 """Allowed keys and values."""
 
 #:
-dpdk_builds: list[DPDKBuildConfigDict]
+dpdk_build: DPDKBuildConfigDict
 #:
 perf: bool
 #:
diff --git a/dts/framework/logger.py b/dts/framework/logger.py
index 3fbe618219..d2b8e37da4 100644
--- a/dts/framework/logger.py
+++ b/dts/framework/logger.py
@@ -33,16 +33,12 @@ class DtsStage(StrEnum):
 #:
 test_run_setup = auto()
 #:
-dpdk_build_setup = auto()
-#:
 test_suite_setup = auto()
 #:
 test_suite = auto()
 #:
 test_suite_teardown = auto()
 #:
-dpdk_build_teardown = auto()
-#:
 test_run_teardown = auto()
 #:
 post_run = auto()
diff --git a/dts/framework/runne

[PATCH 5/7] dts: add support for externally compiled DPDK

2024-09-27 Thread Tomáš Ďurovec
Add support for using DPDK source tree directory as well as DPDK
tarball with the pre-build directory that can user specify and
type of location, it can be stored in the local filesystem or SUT
node. Additionally, this can be set up with the config file or
cmd arguments/environment variables.

Signed-off-by: Tomáš Ďurovec 
---
 dts/conf.yaml|  23 +-
 dts/framework/config/__init__.py | 121 ++-
 dts/framework/config/conf_yaml_schema.json   |  62 +++-
 dts/framework/config/types.py|  17 +-
 dts/framework/exception.py   |   4 +-
 dts/framework/remote_session/dpdk_shell.py   |   2 +-
 dts/framework/runner.py  |   8 +-
 dts/framework/settings.py| 193 +--
 dts/framework/test_result.py |  23 +-
 dts/framework/testbed_model/node.py  |  22 +-
 dts/framework/testbed_model/os_session.py|  63 +++-
 dts/framework/testbed_model/posix_session.py |  39 ++-
 dts/framework/testbed_model/sut_node.py  | 345 +--
 13 files changed, 718 insertions(+), 204 deletions(-)

diff --git a/dts/conf.yaml b/dts/conf.yaml
index 814744a1fc..2f3010204d 100644
--- a/dts/conf.yaml
+++ b/dts/conf.yaml
@@ -5,12 +5,23 @@
 test_runs:
   # define one test run environment
   - dpdk_build:
-  arch: x86_64
-  os: linux
-  cpu: native
-  # the combination of the following two makes CC="ccache gcc"
-  compiler: gcc
-  compiler_wrapper: ccache
+  # dpdk_tree: Commented out because `tarball` is defined.
+  tarball: dpdk-tarball.tar.xz
+  # Either `dpdk_tree` or `tarball` can be defined, but not both.
+  remote: false # Optional, defaults to false. If it's true, the 
`dpdk_tree` or `tarball`
+# is located on the SUT node, instead of the execution 
host.
+
+  # dir_name: Commented out because `build` is defined.
+  build:
+arch: x86_64
+os: linux
+cpu: native
+# the combination of the following two makes CC="ccache gcc"
+compiler: gcc
+compiler_wrapper: ccache # Optional.
+  # If `dir_name` is defined, DPDK has been pre-built and the build 
directory is located in a
+  # subdirectory of DPDK tree root directory. Otherwise, will be using a 
`build` to build the
+  # DPDK from source. Either `dir_name` or `build` can be defined, but not 
both.
 perf: false # disable performance testing
 func: true # enable functional testing
 skip_smoke_tests: false # optional
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index 49b2e8d016..1bbc1c8700 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -35,6 +35,7 @@
 
 import json
 import os.path
+import tarfile
 from dataclasses import dataclass, fields
 from enum import auto, unique
 from pathlib import Path
@@ -47,6 +48,7 @@
 from framework.config.types import (
 ConfigurationDict,
 DPDKBuildConfigDict,
+DPDKConfigurationDict,
 NodeConfigDict,
 PortConfigDict,
 TestRunConfigDict,
@@ -380,6 +382,115 @@ def from_dict(cls, d: DPDKBuildConfigDict) -> Self:
 )
 
 
+@dataclass(slots=True, frozen=True)
+class DPDKLocation:
+"""DPDK location.
+
+The path to the DPDK sources, build dir and type of location.
+
+Attributes:
+dpdk_tree: The path to the DPDK source tree directory. Only one of 
`dpdk_tree` or `tarball`
+must be provided.
+tarball: The path to the DPDK tarball. Only one of `dpdk_tree` or 
`tarball` must be
+provided.
+remote: Optional, defaults to :data:`False`. If :data:`True`, 
`dpdk_tree` or `tarball` is
+located on the SUT node, instead of the execution host.
+build_dir: If it's defined, DPDK has been pre-built and the build 
directory is located in a
+subdirectory of `dpdk_tree` or `tarball` root directory. 
Otherwise, will be using a
+`build` from configuration to build the DPDK from source.
+"""
+
+dpdk_tree: str | None
+tarball: str | None
+remote: bool
+build_dir: str | None
+
+@classmethod
+def from_dict(cls, d: DPDKConfigurationDict) -> Self:
+"""A convenience method that processes and validates the inputs before 
creating an instance.
+
+Validate existence and format of `dpdk_tree` or `tarball` on local 
filesystem, if
+`remote` is False.
+
+Args:
+d: The configuration dictionary.
+
+Returns:
+The DPDK location instance.
+
+Raises:
+ConfigurationError: If `dpdk_tree` or `tarball` not found in local 
filesystem or they
+aren't in the right format.
+"""
+dpdk_tree = d.get("dpdk_tree")
+tarball = d.get("tarball")
+remote = d.get("remote", False)
+
+if not remote:
+if dpdk_tree:
+if not Path(dpdk_tree).exists

[PATCH 4/7] dts: add the ability to copy directories via remote

2024-09-27 Thread Tomáš Ďurovec
Before, the remote session did't allows to copy directories,
only files. This feature will be used in future commit.

Signed-off-by: Tomáš Ďurovec 
---
 dts/framework/testbed_model/os_session.py| 120 ++-
 dts/framework/testbed_model/posix_session.py |  88 +-
 dts/framework/utils.py   |  91 +-
 3 files changed, 287 insertions(+), 12 deletions(-)

diff --git a/dts/framework/testbed_model/os_session.py 
b/dts/framework/testbed_model/os_session.py
index 1aac3659bf..6c3f84dec1 100644
--- a/dts/framework/testbed_model/os_session.py
+++ b/dts/framework/testbed_model/os_session.py
@@ -25,7 +25,7 @@
 from abc import ABC, abstractmethod
 from collections.abc import Iterable
 from ipaddress import IPv4Interface, IPv6Interface
-from pathlib import Path, PurePath
+from pathlib import Path, PurePath, PurePosixPath
 from typing import Union
 
 from framework.config import Architecture, NodeConfiguration, NodeInfo
@@ -38,7 +38,7 @@
 )
 from framework.remote_session.remote_session import CommandResult
 from framework.settings import SETTINGS
-from framework.utils import MesonArgs
+from framework.utils import MesonArgs, TarCompressionFormat
 
 from .cpu import LogicalCore
 from .port import Port
@@ -203,6 +203,95 @@ def copy_to(self, source_file: str | Path, 
destination_dir: str | PurePath) -> N
 will be saved.
 """
 
+@abstractmethod
+def copy_dir_from(
+self,
+source_dir: str | PurePath,
+destination_dir: str | Path,
+compress_format: TarCompressionFormat = TarCompressionFormat.none,
+exclude: str | list[str] | None = None,
+) -> None:
+"""Copy a directory from the remote node to the local filesystem.
+
+Copy `source_dir` from the remote node associated with this remote 
session to
+`destination_dir` on the local filesystem. The new local directory 
will be created
+at `destination_dir` path.
+
+Example:
+source_dir = '/remote/path/to/source'
+destination_dir = '/local/path/to/destination'
+compress_format = TarCompressionFormat.xz
+
+The method will:
+1. Create a tarball from `source_dir`, resulting in:
+'/remote/path/to/source.tar.xz',
+2. Copy '/remote/path/to/source.tar.xz' to
+'/local/path/to/destination/source.tar.xz',
+3. Extract the contents of the tarball, resulting in:
+'/local/path/to/destination/source/',
+4. Remove the tarball after extraction
+('/local/path/to/destination/source.tar.xz').
+
+Final Path Structure:
+'/local/path/to/destination/source/'
+
+Args:
+source_dir: The directory on the remote node.
+destination_dir: The directory path on the local filesystem.
+compress_format: The compression format to use. Defaults to no 
compression.
+exclude: Patterns for files or directories to exclude from the 
tarball.
+These patterns are used with `tar`'s `--exclude` option.
+"""
+
+@abstractmethod
+def copy_dir_to(
+self,
+source_dir: str | Path,
+destination_dir: str | PurePath,
+compress_format: TarCompressionFormat = TarCompressionFormat.none,
+exclude: str | list[str] | None = None,
+) -> None:
+"""Copy a directory from the local filesystem to the remote node.
+
+Copy `source_dir` from the local filesystem to `destination_dir` on 
the remote node
+associated with this remote session. The new remote directory will be 
created at
+`destination_dir` path.
+
+Example:
+source_dir = '/local/path/to/source'
+destination_dir = '/remote/path/to/destination'
+compress_format = TarCompressionFormat.xz
+
+The method will:
+1. Create a tarball from `source_dir`, resulting in:
+'/local/path/to/source.tar.xz',
+2. Copy '/local/path/to/source.tar.xz' to
+'/remote/path/to/destination/source.tar.xz',
+3. Extract the contents of the tarball, resulting in:
+'/remote/path/to/destination/source/',
+4. Remove the tarball after extraction
+('/remote/path/to/destination/source.tar.xz').
+
+Final Path Structure:
+'/remote/path/to/destination/source/'
+
+Args:
+source_dir: The directory on the local filesystem.
+destination_dir: The directory path on the remote node.
+compress_format: The compression format to use. Defaults to no 
compression.
+exclude: Patterns for files or directories to exclude from the 
tarball.
+These patterns are used with `fnmatch.fnmatch` to filter out 
files

[PATCH 2/7] dts: one dpdk build per test run

2024-09-27 Thread Tomáš Ďurovec
When the DPDK build can be already pre-build, there is
not a need for defining multiple build targets. To make
it cleaner we decide to use one DPDK build wheater can
be pre-build or DTS will build it.

Signed-off-by: Tomáš Ďurovec 
---
 dts/conf.yaml  |  14 +--
 dts/framework/config/__init__.py   |   9 +-
 dts/framework/config/conf_yaml_schema.json |  10 +-
 dts/framework/config/types.py  |   2 +-
 dts/framework/logger.py|   4 -
 dts/framework/runner.py| 117 +---
 dts/framework/test_result.py   | 119 ++---
 dts/framework/test_suite.py|   2 +-
 dts/framework/testbed_model/sut_node.py|   6 +-
 dts/tests/TestSuite_smoke_tests.py |   2 +-
 10 files changed, 80 insertions(+), 205 deletions(-)

diff --git a/dts/conf.yaml b/dts/conf.yaml
index 1363e93580..814744a1fc 100644
--- a/dts/conf.yaml
+++ b/dts/conf.yaml
@@ -4,13 +4,13 @@
 
 test_runs:
   # define one test run environment
-  - dpdk_builds:
-  - arch: x86_64
-os: linux
-cpu: native
-# the combination of the following two makes CC="ccache gcc"
-compiler: gcc
-compiler_wrapper: ccache
+  - dpdk_build:
+  arch: x86_64
+  os: linux
+  cpu: native
+  # the combination of the following two makes CC="ccache gcc"
+  compiler: gcc
+  compiler_wrapper: ccache
 perf: false # disable performance testing
 func: true # enable functional testing
 skip_smoke_tests: false # optional
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index c243716010..49b2e8d016 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -437,7 +437,7 @@ class TestRunConfiguration:
 and with what DPDK build.
 
 Attributes:
-dpdk_builds: A list of DPDK builds to test.
+dpdk_build: A DPDK build to test.
 perf: Whether to run performance tests.
 func: Whether to run functional tests.
 skip_smoke_tests: Whether to skip smoke tests.
@@ -448,7 +448,7 @@ class TestRunConfiguration:
 random_seed: The seed to use for pseudo-random generation.
 """
 
-dpdk_builds: list[DPDKBuildConfiguration]
+dpdk_build: DPDKBuildConfiguration
 perf: bool
 func: bool
 skip_smoke_tests: bool
@@ -477,9 +477,6 @@ def from_dict(
 Returns:
 The test run configuration instance.
 """
-dpdk_builds: list[DPDKBuildConfiguration] = list(
-map(DPDKBuildConfiguration.from_dict, d["dpdk_builds"])
-)
 test_suites: list[TestSuiteConfig] = 
list(map(TestSuiteConfig.from_dict, d["test_suites"]))
 sut_name = d["system_under_test_node"]["node_name"]
 skip_smoke_tests = d.get("skip_smoke_tests", False)
@@ -501,7 +498,7 @@ def from_dict(
 )
 random_seed = d.get("random_seed", None)
 return cls(
-dpdk_builds=dpdk_builds,
+dpdk_build=DPDKBuildConfiguration.from_dict(d["dpdk_build"]),
 perf=d["perf"],
 func=d["func"],
 skip_smoke_tests=skip_smoke_tests,
diff --git a/dts/framework/config/conf_yaml_schema.json 
b/dts/framework/config/conf_yaml_schema.json
index 927a73ac6c..94d7efa5f5 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -327,12 +327,8 @@
   "items": {
 "type": "object",
 "properties": {
-  "dpdk_builds": {
-"type": "array",
-"items": {
-  "$ref": "#/definitions/dpdk_build"
-},
-"minimum": 1
+  "dpdk_build": {
+"$ref": "#/definitions/dpdk_build"
   },
   "perf": {
 "type": "boolean",
@@ -387,7 +383,7 @@
 },
 "additionalProperties": false,
 "required": [
-  "dpdk_builds",
+  "dpdk_build",
   "perf",
   "func",
   "test_suites",
diff --git a/dts/framework/config/types.py b/dts/framework/config/types.py
index 4f450267d1..a710c20d6a 100644
--- a/dts/framework/config/types.py
+++ b/dts/framework/config/types.py
@@ -108,7 +108,7 @@ class TestRunConfigDict(TypedDict):
 """Allowed keys and values."""
 
 #:
-dpdk_builds: list[DPDKBuildConfigDict]
+dpdk_build: DPDKBuildConfigDict
 #:
 perf: bool
 #:
diff --git a/dts/framework/logger.py b/dts/framework/logger.py
index 3fbe618219..d2b8e37da4 100644
--- a/dts/framework/logger.py
+++ b/dts/framework/logger.py
@@ -33,16 +33,12 @@ class DtsStage(StrEnum):
 #:
 test_run_setup = auto()
 #:
-dpdk_build_setup = auto()
-#:
 test_suite_setup = auto()
 #:
 test_suite = auto()
 #:
 test_suite_teardown = auto()
 #:
-dpdk_build_teardown = auto()
-#:
 test_run_teardown = auto()
 #:
 post_run = auto()
diff --git a/dts/framework/runne

[PATCH 7/7] dts: remove git ref option

2024-09-27 Thread Tomáš Ďurovec
In the previous commits we're adding the support for copying
the whole local DPDK tree directory and git-ref option was
meant to do the same thing.

Signed-off-by: Tomáš Ďurovec 
---
 doc/guides/tools/dts.rst  |   9 ---
 dts/framework/settings.py |  51 +++-
 dts/framework/utils.py| 119 +-
 3 files changed, 8 insertions(+), 171 deletions(-)

diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst
index 20d4d18b18..d806dce2ae 100644
--- a/doc/guides/tools/dts.rst
+++ b/doc/guides/tools/dts.rst
@@ -239,9 +239,6 @@ DTS is run with ``main.py`` located in the ``dts`` 
directory after entering Poet
  --dpdk-tree DIR_PATH  [DTS_DPDK_TREE] Path to DPDK source code tree to 
test. (default: None)
  --tarball FILE_PATH, --snapshot FILE_PATH
[DTS_DPDK_TARBALL] Path to DPDK source code tarball 
to test. (default: None)
- --revision ID, --rev ID, --git-ref ID
-   [DTS_DPDK_REVISION_ID] Git revision ID to test. 
Could be commit, tag, tree ID etc. To test local changes, first
-   commit them, then use their commit ID. (default: 
None)
  --remote-source   [DTS_REMOTE_SOURCE] Set when the DPDK source tree 
or tarball is located on the SUT node. (default: False)
  --build-dir DIR_NAME  [DTS_BUILD_DIR] A directory name, which would be 
located in the `dpdk tree` or `tarball`. (default: None)
  --compile-timeout SECONDS
@@ -263,12 +260,6 @@ The minimum DTS needs is a config file and a pre-built 
DPDK or DPDK
 sources location which can be specified in said config file or on the
 command line or environment variables.
 
-Example command for running DTS with the template configuration and DPDK tag 
v23.11:
-
-.. code-block:: console
-
-   (dts-py3.10) $ ./main.py --git-ref v23.11
-
 
 DTS Results
 ~~~
diff --git a/dts/framework/settings.py b/dts/framework/settings.py
index 17594ecb15..a4ab674189 100644
--- a/dts/framework/settings.py
+++ b/dts/framework/settings.py
@@ -42,20 +42,12 @@
 .. option:: --dpdk-tree
 .. envvar:: DTS_DPDK_TREE
 
-The path to DPDK source tree directory to test. Only this or tarball or 
revision can be
-provided.
+The path to DPDK source tree directory to test. Only this or tarball can 
be provided.
 
 .. option:: --tarball, --snapshot
 .. envvar:: DTS_DPDK_TARBALL
 
-The path to DPDK source tarball to test. Only this or DPDK tree or 
revision can be provided.
-
-.. option:: --revision, --rev, --git-ref
-.. envvar:: DTS_DPDK_REVISION_ID
-
-Git revision ID to test. Could be commit, tag, tree ID etc.
-To test local changes, first commit them, then use their commit ID.
-Only this or DPDK tree or tarball can be provided.
+The path to DPDK source tarball to test. Only this or DPDK tree can be 
provided.
 
 .. option:: --remote-source
 .. envvar:: DTS_REMOTE_SOURCE
@@ -108,8 +100,6 @@
 from typing import Callable
 
 from .config import DPDKLocation, TestSuiteConfig
-from .exception import ConfigurationError
-from .utils import DPDKGitTarball, get_commit_id
 
 
 @dataclass(slots=True)
@@ -256,14 +246,6 @@ def _get_help_string(self, action):
 return help
 
 
-def _parse_revision_id(rev_id: str) -> str:
-"""Validate revision ID and retrieve corresponding commit ID."""
-try:
-return get_commit_id(rev_id)
-except ConfigurationError:
-raise argparse.ArgumentTypeError("The Git revision ID supplied is 
invalid or ambiguous")
-
-
 def _required_with_one_of(parser: _DTSArgumentParser, action: Action, 
*required_dests: str) -> None:
 """Verify that `action` is listed together with at least one of 
`required_dests`.
 
@@ -362,15 +344,15 @@ def _get_parser() -> _DTSArgumentParser:
 dpdk_build = parser.add_argument_group(
 "DPDK Build Options",
 description="Arguments in this group (and subgroup) will be applied to 
a "
-":class:`DPDKLocation` when the DPDK tree, tarball or revision will be 
provided, "
-"other arguments like remote source and build dir are optional. A 
:class:`DPDKLocation` "
+":class:`DPDKLocation` when the DPDK tree, tarball will be provided, 
other "
+"arguments like remote source and build dir are optional. A 
:class:`DPDKLocation` "
 "from settings are used instead of from config if construct 
successful.",
 )
 
 dpdk_source = dpdk_build.add_mutually_exclusive_group()
 action = dpdk_source.add_argument(
 "--dpdk-tree",
-help="The path to DPDK source tree directory to test. Only this or 
tarball or revision "
+help="The path to DPDK source tree directory to test. Only this or 
tarball "
 "can be provided.",
 metavar="DIR_PATH",
 dest="dpdk_tree_path",
@@ -380,26 +362,12 @@ def _get_parser() -> _DTSArgumentParser:
 action = dpdk_source.add_argument(
 "--tarball",
 "--snapshot",
-help="The path to DPDK source tarball to 

[PATCH] net/nfp: fix duplicate call to rte_free

2024-09-27 Thread Stephen Hemminger
Calling rte_free twice on same object will corrupt the heap.
Warning is:
In function 'nfp_pre_tun_table_check_del',
inlined from 'nfp_flow_destroy' at 
../drivers/net/nfp/flower/nfp_flower_flow.c:5143:9:
../drivers/net/nfp/flower/nfp_flower_flow.c:3830:9: error: pointer 'entry' used 
after 'rte_free' [-Werror=use-after-free]
3830 | rte_free(entry);
| ^~~
../drivers/net/nfp/flower/nfp_flower_flow.c:3825:9: note: call to 'rte_free' 
here
3825 | rte_free(entry);
| ^~~

Fixes: d3c33bdf1f18 ("net/nfp: prepare for IPv4 UDP tunnel decap flow action")
Cc: chaoyong...@corigine.com
Signed-off-by: Stephen Hemminger 
---
 drivers/net/nfp/flower/nfp_flower_flow.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c 
b/drivers/net/nfp/flower/nfp_flower_flow.c
index 0078455658..64a0062c8b 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -3822,7 +3822,6 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor 
*repr,
goto free_entry;
}
 
-   rte_free(entry);
rte_free(find_entry);
priv->pre_tun_cnt--;
 
-- 
2.45.2



[PATCH v12 4/4] eal: add PMU support to tracing library

2024-09-27 Thread Tomasz Duszynski
In order to profile app one needs to store significant amount of samples
somewhere for an analysis later on. Since trace library supports
storing data in a CTF format lets take advantage of that and add a
dedicated PMU tracepoint.

Signed-off-by: Tomasz Duszynski 
---
 app/test/test_trace_perf.c   | 10 
 doc/guides/prog_guide/profile_app.rst|  5 ++
 doc/guides/prog_guide/trace_lib.rst  | 32 +
 lib/eal/common/eal_common_trace.c| 13 -
 lib/eal/common/eal_common_trace_points.c |  5 ++
 lib/eal/include/rte_eal_trace.h  | 13 +
 lib/eal/meson.build  |  3 ++
 lib/eal/version.map  |  3 ++
 lib/pmu/rte_pmu.c| 61 
 lib/pmu/rte_pmu.h| 14 ++
 lib/pmu/version.map  |  1 +
 11 files changed, 159 insertions(+), 1 deletion(-)

diff --git a/app/test/test_trace_perf.c b/app/test/test_trace_perf.c
index 8257cc02be..f1f2e74136 100644
--- a/app/test/test_trace_perf.c
+++ b/app/test/test_trace_perf.c
@@ -114,6 +114,10 @@ worker_fn_##func(void *arg) \
 #define GENERIC_DOUBLE rte_eal_trace_generic_double(3.6)
 #define GENERIC_STR rte_eal_trace_generic_str("hello world")
 #define VOID_FP app_dpdk_test_fp()
+#ifdef RTE_EXEC_ENV_LINUX
+/* 0 corresponds first event passed via --trace= */
+#define READ_PMU rte_eal_trace_pmu_read(0)
+#endif
 
 WORKER_DEFINE(GENERIC_VOID)
 WORKER_DEFINE(GENERIC_U64)
@@ -122,6 +126,9 @@ WORKER_DEFINE(GENERIC_FLOAT)
 WORKER_DEFINE(GENERIC_DOUBLE)
 WORKER_DEFINE(GENERIC_STR)
 WORKER_DEFINE(VOID_FP)
+#ifdef RTE_EXEC_ENV_LINUX
+WORKER_DEFINE(READ_PMU)
+#endif
 
 static void
 run_test(const char *str, lcore_function_t f, struct test_data *data, size_t 
sz)
@@ -174,6 +181,9 @@ test_trace_perf(void)
run_test("double", worker_fn_GENERIC_DOUBLE, data, sz);
run_test("string", worker_fn_GENERIC_STR, data, sz);
run_test("void_fp", worker_fn_VOID_FP, data, sz);
+#ifdef RTE_EXEC_ENV_LINUX
+   run_test("read_pmu", worker_fn_READ_PMU, data, sz);
+#endif
 
rte_free(data);
return TEST_SUCCESS;
diff --git a/doc/guides/prog_guide/profile_app.rst 
b/doc/guides/prog_guide/profile_app.rst
index ecb90a0d94..d73d919521 100644
--- a/doc/guides/prog_guide/profile_app.rst
+++ b/doc/guides/prog_guide/profile_app.rst
@@ -33,6 +33,11 @@ As of now implementation imposes certain limitations:
 
 * Each EAL lcore measures same group of events
 
+Alternatively tracing library can be used which offers dedicated tracepoint
+``rte_eal_trace_pmu_event()``.
+
+Refer to :doc:`../prog_guide/trace_lib` for more details.
+
 
 Profiling on x86
 
diff --git a/doc/guides/prog_guide/trace_lib.rst 
b/doc/guides/prog_guide/trace_lib.rst
index d9b17abe90..378abccd72 100644
--- a/doc/guides/prog_guide/trace_lib.rst
+++ b/doc/guides/prog_guide/trace_lib.rst
@@ -46,6 +46,7 @@ DPDK tracing library features
   trace format and is compatible with ``LTTng``.
   For detailed information, refer to
   `Common Trace Format `_.
+- Support reading PMU events on ARM64 and x86-64 (Intel)
 
 How to add a tracepoint?
 
@@ -139,6 +140,37 @@ the user must use ``RTE_TRACE_POINT_FP`` instead of 
``RTE_TRACE_POINT``.
 ``RTE_TRACE_POINT_FP`` is compiled out by default and it can be enabled using
 the ``enable_trace_fp`` option for meson build.
 
+PMU tracepoint
+--
+
+Performance monitoring unit (PMU) event values can be read from hardware
+registers using predefined ``rte_pmu_read`` tracepoint.
+
+Tracing is enabled via ``--trace`` EAL option by passing both expression
+matching PMU tracepoint name i.e ``lib.eal.pmu.read`` and expression
+``e=ev1[,ev2,...]`` matching particular events::
+
+--trace='.*pmu.read\|e=cpu_cycles,l1d_cache'
+
+Event names are available under ``/sys/bus/event_source/devices/PMU/events``
+directory, where ``PMU`` is a placeholder for either a ``cpu`` or a directory
+containing ``cpus``.
+
+In contrary to other tracepoints this does not need any extra variables
+added to source files. Instead, caller passes index which follows the order of
+events specified via ``--trace`` parameter. In the following example index 
``0``
+corresponds to ``cpu_cyclces`` while index ``1`` corresponds to ``l1d_cache``.
+
+.. code-block:: c
+
+ ...
+ rte_eal_trace_pmu_read(0);
+ rte_eal_trace_pmu_read(1);
+ ...
+
+PMU tracing support must be explicitly enabled using the ``enable_trace_fp``
+option for meson build.
+
 Event record mode
 -
 
diff --git a/lib/eal/common/eal_common_trace.c 
b/lib/eal/common/eal_common_trace.c
index 918f49bf4f..5373dbb717 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -12,6 +12,9 @@
 #include 
 #include 
 #include 
+#ifdef RTE_EXEC_ENV_LINUX
+#include 
+#endif
 #include 
 
 #include "eal_trace.h"
@@ -72,8 +75,13 @@ eal_trace_init(void)
goto free_meta;
 

[PATCH v12 0/4] add support for self monitoring

2024-09-27 Thread Tomasz Duszynski
This series adds self monitoring support i.e allows to configure and
read performance measurement unit (PMU) counters in runtime without
using perf utility. This has certain advantages when application runs on
isolated cores running dedicated tasks.

Events can be read directly using rte_pmu_read() or using dedicated
tracepoint rte_eal_trace_pmu_read(). The latter will cause events to be
stored inside CTF file.

By design, all enabled events are grouped together and the same group
is attached to lcores that use self monitoring funtionality.

Events are enabled by names, which need to be read from standard
location under sysfs i.e

/sys/bus/event_source/devices/PMU/events

where PMU is a core pmu i.e one measuring cpu events. As of today
raw events are not supported.

v12:
- rebase old series
- slightly refresh existing documentation
- make sure compiler won't optimize accesses to certain variables during
  event readout
- drop previous Acked-by to respin a fresh review cycle
v11:
- skip fast test in case init fails
v10:
- check permissions before using counters
- do not use internal symbols in exported functions
- address review comments
v9:
- fix 'maybe-uninitialized' warning reported by CI
v8:
- just rebase series
v7:
- use per-lcore event group instead of global table index by lcore-id
- don't add pmu_autotest to fast tests because due to lack of suported
  on every arch
v6:
- move codebase to the separate library
- address review comments
v5:
- address review comments
- fix sign extension while reading pmu on x86
- fix regex mentioned in doc
- various minor changes/improvements here and there
v4:
- fix freeing mem detected by debug_autotest
v3:
- fix shared build
v2:
- fix problems reported by test build infra

Tomasz Duszynski (4):
  lib: add generic support for reading PMU events
  pmu: support reading ARM PMU events in runtime
  pmu: support reading Intel x86_64 PMU events in runtime
  eal: add PMU support to tracing library

 MAINTAINERS  |   5 +
 app/test/meson.build |   1 +
 app/test/test_pmu.c  |  68 +++
 app/test/test_trace_perf.c   |  10 +
 doc/api/doxy-api-index.md|   3 +-
 doc/api/doxy-api.conf.in |   1 +
 doc/guides/prog_guide/profile_app.rst|  31 ++
 doc/guides/prog_guide/trace_lib.rst  |  32 ++
 doc/guides/rel_notes/release_24_11.rst   |   7 +
 lib/eal/common/eal_common_trace.c|  13 +-
 lib/eal/common/eal_common_trace_points.c |   5 +
 lib/eal/include/rte_eal_trace.h  |  13 +
 lib/eal/meson.build  |   3 +
 lib/eal/version.map  |   3 +
 lib/meson.build  |   1 +
 lib/pmu/meson.build  |  24 ++
 lib/pmu/pmu_arm64.c  |  94 
 lib/pmu/pmu_private.h|  32 ++
 lib/pmu/rte_pmu.c| 526 +++
 lib/pmu/rte_pmu.h| 226 ++
 lib/pmu/rte_pmu_pmc_arm64.h  |  30 ++
 lib/pmu/rte_pmu_pmc_x86_64.h |  24 ++
 lib/pmu/version.map  |  15 +
 23 files changed, 1165 insertions(+), 2 deletions(-)
 create mode 100644 app/test/test_pmu.c
 create mode 100644 lib/pmu/meson.build
 create mode 100644 lib/pmu/pmu_arm64.c
 create mode 100644 lib/pmu/pmu_private.h
 create mode 100644 lib/pmu/rte_pmu.c
 create mode 100644 lib/pmu/rte_pmu.h
 create mode 100644 lib/pmu/rte_pmu_pmc_arm64.h
 create mode 100644 lib/pmu/rte_pmu_pmc_x86_64.h
 create mode 100644 lib/pmu/version.map

--
2.34.1



[PATCH v12 3/4] pmu: support reading Intel x86_64 PMU events in runtime

2024-09-27 Thread Tomasz Duszynski
Add support for reading Intel x86_64 PMU events in runtime.

Signed-off-by: Tomasz Duszynski 
---
 app/test/test_pmu.c  |  2 ++
 lib/pmu/meson.build  |  1 +
 lib/pmu/rte_pmu.h|  2 ++
 lib/pmu/rte_pmu_pmc_x86_64.h | 24 
 4 files changed, 29 insertions(+)
 create mode 100644 lib/pmu/rte_pmu_pmc_x86_64.h

diff --git a/app/test/test_pmu.c b/app/test/test_pmu.c
index e77e0927f3..4e734a8ee4 100644
--- a/app/test/test_pmu.c
+++ b/app/test/test_pmu.c
@@ -26,6 +26,8 @@ test_pmu_read(void)
 
 #if defined(RTE_ARCH_ARM64)
name = "cpu_cycles";
+#elif defined(RTE_ARCH_X86_64)
+   name = "cpu-cycles";
 #endif
 
if (name == NULL) {
diff --git a/lib/pmu/meson.build b/lib/pmu/meson.build
index 2958c59cba..0e4b0cbdb9 100644
--- a/lib/pmu/meson.build
+++ b/lib/pmu/meson.build
@@ -14,6 +14,7 @@ headers = files('rte_pmu.h')
 
 indirect_headers += files(
 'rte_pmu_pmc_arm64.h',
+'rte_pmu_pmc_x86_64.h',
 )
 
 if dpdk_conf.has('RTE_ARCH_ARM64')
diff --git a/lib/pmu/rte_pmu.h b/lib/pmu/rte_pmu.h
index 346b8a98f2..a40f69fb5d 100644
--- a/lib/pmu/rte_pmu.h
+++ b/lib/pmu/rte_pmu.h
@@ -28,6 +28,8 @@ extern "C" {
 
 #if defined(RTE_ARCH_ARM64)
 #include "rte_pmu_pmc_arm64.h"
+#elif defined(RTE_ARCH_X86_64)
+#include "rte_pmu_pmc_x86_64.h"
 #endif
 
 /** Maximum number of events in a group */
diff --git a/lib/pmu/rte_pmu_pmc_x86_64.h b/lib/pmu/rte_pmu_pmc_x86_64.h
new file mode 100644
index 00..5eb8f73c11
--- /dev/null
+++ b/lib/pmu/rte_pmu_pmc_x86_64.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 Marvell.
+ */
+#ifndef _RTE_PMU_PMC_X86_64_H_
+#define _RTE_PMU_PMC_X86_64_H_
+
+#include 
+
+static __rte_always_inline uint64_t
+rte_pmu_pmc_read(int index)
+{
+   uint64_t low, high;
+
+   asm volatile(
+   "rdpmc\n"
+   : "=a" (low), "=d" (high)
+   : "c" (index)
+   );
+
+   return low | (high << 32);
+}
+#define rte_pmu_pmc_read rte_pmu_pmc_read
+
+#endif /* _RTE_PMU_PMC_X86_64_H_ */
-- 
2.34.1



[PATCH 5/7] dts: add support for externally compiled DPDK

2024-09-27 Thread Tomáš Ďurovec
Add support for using DPDK source tree directory as well as DPDK
tarball with the pre-build directory that can user specify and
type of location, it can be stored in the local filesystem or SUT
node. Additionally, this can be set up with the config file or
cmd arguments/environment variables.

Signed-off-by: Tomáš Ďurovec 
---
 dts/conf.yaml|  23 +-
 dts/framework/config/__init__.py | 121 ++-
 dts/framework/config/conf_yaml_schema.json   |  62 +++-
 dts/framework/config/types.py|  17 +-
 dts/framework/exception.py   |   4 +-
 dts/framework/remote_session/dpdk_shell.py   |   2 +-
 dts/framework/runner.py  |   8 +-
 dts/framework/settings.py| 193 +--
 dts/framework/test_result.py |  23 +-
 dts/framework/testbed_model/node.py  |  22 +-
 dts/framework/testbed_model/os_session.py|  63 +++-
 dts/framework/testbed_model/posix_session.py |  39 ++-
 dts/framework/testbed_model/sut_node.py  | 345 +--
 13 files changed, 718 insertions(+), 204 deletions(-)

diff --git a/dts/conf.yaml b/dts/conf.yaml
index 814744a1fc..2f3010204d 100644
--- a/dts/conf.yaml
+++ b/dts/conf.yaml
@@ -5,12 +5,23 @@
 test_runs:
   # define one test run environment
   - dpdk_build:
-  arch: x86_64
-  os: linux
-  cpu: native
-  # the combination of the following two makes CC="ccache gcc"
-  compiler: gcc
-  compiler_wrapper: ccache
+  # dpdk_tree: Commented out because `tarball` is defined.
+  tarball: dpdk-tarball.tar.xz
+  # Either `dpdk_tree` or `tarball` can be defined, but not both.
+  remote: false # Optional, defaults to false. If it's true, the 
`dpdk_tree` or `tarball`
+# is located on the SUT node, instead of the execution 
host.
+
+  # dir_name: Commented out because `build` is defined.
+  build:
+arch: x86_64
+os: linux
+cpu: native
+# the combination of the following two makes CC="ccache gcc"
+compiler: gcc
+compiler_wrapper: ccache # Optional.
+  # If `dir_name` is defined, DPDK has been pre-built and the build 
directory is located in a
+  # subdirectory of DPDK tree root directory. Otherwise, will be using a 
`build` to build the
+  # DPDK from source. Either `dir_name` or `build` can be defined, but not 
both.
 perf: false # disable performance testing
 func: true # enable functional testing
 skip_smoke_tests: false # optional
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index 49b2e8d016..1bbc1c8700 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -35,6 +35,7 @@
 
 import json
 import os.path
+import tarfile
 from dataclasses import dataclass, fields
 from enum import auto, unique
 from pathlib import Path
@@ -47,6 +48,7 @@
 from framework.config.types import (
 ConfigurationDict,
 DPDKBuildConfigDict,
+DPDKConfigurationDict,
 NodeConfigDict,
 PortConfigDict,
 TestRunConfigDict,
@@ -380,6 +382,115 @@ def from_dict(cls, d: DPDKBuildConfigDict) -> Self:
 )
 
 
+@dataclass(slots=True, frozen=True)
+class DPDKLocation:
+"""DPDK location.
+
+The path to the DPDK sources, build dir and type of location.
+
+Attributes:
+dpdk_tree: The path to the DPDK source tree directory. Only one of 
`dpdk_tree` or `tarball`
+must be provided.
+tarball: The path to the DPDK tarball. Only one of `dpdk_tree` or 
`tarball` must be
+provided.
+remote: Optional, defaults to :data:`False`. If :data:`True`, 
`dpdk_tree` or `tarball` is
+located on the SUT node, instead of the execution host.
+build_dir: If it's defined, DPDK has been pre-built and the build 
directory is located in a
+subdirectory of `dpdk_tree` or `tarball` root directory. 
Otherwise, will be using a
+`build` from configuration to build the DPDK from source.
+"""
+
+dpdk_tree: str | None
+tarball: str | None
+remote: bool
+build_dir: str | None
+
+@classmethod
+def from_dict(cls, d: DPDKConfigurationDict) -> Self:
+"""A convenience method that processes and validates the inputs before 
creating an instance.
+
+Validate existence and format of `dpdk_tree` or `tarball` on local 
filesystem, if
+`remote` is False.
+
+Args:
+d: The configuration dictionary.
+
+Returns:
+The DPDK location instance.
+
+Raises:
+ConfigurationError: If `dpdk_tree` or `tarball` not found in local 
filesystem or they
+aren't in the right format.
+"""
+dpdk_tree = d.get("dpdk_tree")
+tarball = d.get("tarball")
+remote = d.get("remote", False)
+
+if not remote:
+if dpdk_tree:
+if not Path(dpdk_tree).exists

[PATCH 1/7] dts: rename build target to DPDK build

2024-09-27 Thread Tomáš Ďurovec
Since the DPDK may already be built, some more general name
is needed that includes both the DPDK location and the build
config (if we are going to build).

Signed-off-by: Tomáš Ďurovec 
---
 dts/conf.yaml  |   2 +-
 dts/framework/config/__init__.py   |  26 ++---
 dts/framework/config/conf_yaml_schema.json |  10 +-
 dts/framework/config/types.py  |   4 +-
 dts/framework/logger.py|   4 +-
 dts/framework/runner.py| 112 ++---
 dts/framework/settings.py  |   2 +-
 dts/framework/test_result.py   |  72 +++--
 dts/framework/test_suite.py|   2 +-
 dts/framework/testbed_model/sut_node.py|  55 +-
 dts/tests/TestSuite_smoke_tests.py |   2 +-
 11 files changed, 142 insertions(+), 149 deletions(-)

diff --git a/dts/conf.yaml b/dts/conf.yaml
index ca5e87636e..1363e93580 100644
--- a/dts/conf.yaml
+++ b/dts/conf.yaml
@@ -4,7 +4,7 @@
 
 test_runs:
   # define one test run environment
-  - build_targets:
+  - dpdk_builds:
   - arch: x86_64
 os: linux
 cpu: native
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index 269d9ec318..c243716010 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -45,8 +45,8 @@
 from typing_extensions import Self
 
 from framework.config.types import (
-BuildTargetConfigDict,
 ConfigurationDict,
+DPDKBuildConfigDict,
 NodeConfigDict,
 PortConfigDict,
 TestRunConfigDict,
@@ -335,7 +335,7 @@ class NodeInfo:
 
 
 @dataclass(slots=True, frozen=True)
-class BuildTargetConfiguration:
+class DPDKBuildConfiguration:
 """DPDK build configuration.
 
 The configuration used for building DPDK.
@@ -358,7 +358,7 @@ class BuildTargetConfiguration:
 name: str
 
 @classmethod
-def from_dict(cls, d: BuildTargetConfigDict) -> Self:
+def from_dict(cls, d: DPDKBuildConfigDict) -> Self:
 r"""A convenience method that processes the inputs before creating an 
instance.
 
 `arch`, `os`, `cpu` and `compiler` are converted to :class:`Enum`\s and
@@ -368,7 +368,7 @@ def from_dict(cls, d: BuildTargetConfigDict) -> Self:
 d: The configuration dictionary.
 
 Returns:
-The build target configuration instance.
+The DPDK build configuration instance.
 """
 return cls(
 arch=Architecture(d["arch"]),
@@ -381,8 +381,8 @@ def from_dict(cls, d: BuildTargetConfigDict) -> Self:
 
 
 @dataclass(slots=True, frozen=True)
-class BuildTargetInfo:
-"""Various versions and other information about a build target.
+class DPDKBuildInfo:
+"""Various versions and other information about a DPDK build.
 
 Attributes:
 dpdk_version: The DPDK version that was built.
@@ -437,7 +437,7 @@ class TestRunConfiguration:
 and with what DPDK build.
 
 Attributes:
-build_targets: A list of DPDK builds to test.
+dpdk_builds: A list of DPDK builds to test.
 perf: Whether to run performance tests.
 func: Whether to run functional tests.
 skip_smoke_tests: Whether to skip smoke tests.
@@ -448,7 +448,7 @@ class TestRunConfiguration:
 random_seed: The seed to use for pseudo-random generation.
 """
 
-build_targets: list[BuildTargetConfiguration]
+dpdk_builds: list[DPDKBuildConfiguration]
 perf: bool
 func: bool
 skip_smoke_tests: bool
@@ -466,7 +466,7 @@ def from_dict(
 ) -> Self:
 """A convenience method that processes the inputs before creating an 
instance.
 
-The build target and the test suite config are transformed into their 
respective objects.
+The DPDK build and the test suite config are transformed into their 
respective objects.
 SUT and TG configurations are taken from `node_map`. The other 
(:class:`bool`) attributes
 are just stored.
 
@@ -477,8 +477,8 @@ def from_dict(
 Returns:
 The test run configuration instance.
 """
-build_targets: list[BuildTargetConfiguration] = list(
-map(BuildTargetConfiguration.from_dict, d["build_targets"])
+dpdk_builds: list[DPDKBuildConfiguration] = list(
+map(DPDKBuildConfiguration.from_dict, d["dpdk_builds"])
 )
 test_suites: list[TestSuiteConfig] = 
list(map(TestSuiteConfig.from_dict, d["test_suites"]))
 sut_name = d["system_under_test_node"]["node_name"]
@@ -501,7 +501,7 @@ def from_dict(
 )
 random_seed = d.get("random_seed", None)
 return cls(
-build_targets=build_targets,
+dpdk_builds=dpdk_builds,
 perf=d["perf"],
 func=d["func"],
 skip_smoke_tests=skip_smoke_tests,
@@ -552,7 +552,7 @@ class Configuration:
 def from_dict(cls, d: ConfigurationDict) -> Self:
 """A convenience method that processes t

[PATCH v12 2/4] pmu: support reading ARM PMU events in runtime

2024-09-27 Thread Tomasz Duszynski
Add support for reading ARM PMU events in runtime.

Signed-off-by: Tomasz Duszynski 
---
 app/test/test_pmu.c |  4 ++
 lib/pmu/meson.build |  8 
 lib/pmu/pmu_arm64.c | 94 +
 lib/pmu/rte_pmu.h   |  4 ++
 lib/pmu/rte_pmu_pmc_arm64.h | 30 
 5 files changed, 140 insertions(+)
 create mode 100644 lib/pmu/pmu_arm64.c
 create mode 100644 lib/pmu/rte_pmu_pmc_arm64.h

diff --git a/app/test/test_pmu.c b/app/test/test_pmu.c
index 5792cf1963..e77e0927f3 100644
--- a/app/test/test_pmu.c
+++ b/app/test/test_pmu.c
@@ -24,6 +24,10 @@ test_pmu_read(void)
int tries = 10, event;
uint64_t val = 0;
 
+#if defined(RTE_ARCH_ARM64)
+   name = "cpu_cycles";
+#endif
+
if (name == NULL) {
printf("PMU not supported on this arch\n");
return TEST_SKIPPED;
diff --git a/lib/pmu/meson.build b/lib/pmu/meson.build
index 3502c73551..2958c59cba 100644
--- a/lib/pmu/meson.build
+++ b/lib/pmu/meson.build
@@ -12,4 +12,12 @@ includes = [global_inc]
 sources = files('rte_pmu.c')
 headers = files('rte_pmu.h')
 
+indirect_headers += files(
+'rte_pmu_pmc_arm64.h',
+)
+
+if dpdk_conf.has('RTE_ARCH_ARM64')
+sources += files('pmu_arm64.c')
+endif
+
 deps += ['log']
diff --git a/lib/pmu/pmu_arm64.c b/lib/pmu/pmu_arm64.c
new file mode 100644
index 00..3b72009cff
--- /dev/null
+++ b/lib/pmu/pmu_arm64.c
@@ -0,0 +1,94 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2024 Marvell International Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "pmu_private.h"
+
+#define PERF_USER_ACCESS_PATH "/proc/sys/kernel/perf_user_access"
+
+static int restore_uaccess;
+
+static int
+read_attr_int(const char *path, int *val)
+{
+   char buf[BUFSIZ];
+   int ret, fd;
+
+   fd = open(path, O_RDONLY);
+   if (fd == -1)
+   return -errno;
+
+   ret = read(fd, buf, sizeof(buf));
+   if (ret == -1) {
+   close(fd);
+
+   return -errno;
+   }
+
+   *val = strtol(buf, NULL, 10);
+   close(fd);
+
+   return 0;
+}
+
+static int
+write_attr_int(const char *path, int val)
+{
+   char buf[BUFSIZ];
+   int num, ret, fd;
+
+   fd = open(path, O_WRONLY);
+   if (fd == -1)
+   return -errno;
+
+   num = snprintf(buf, sizeof(buf), "%d", val);
+   ret = write(fd, buf, num);
+   if (ret == -1) {
+   close(fd);
+
+   return -errno;
+   }
+
+   close(fd);
+
+   return 0;
+}
+
+int
+pmu_arch_init(void)
+{
+   int ret;
+
+   ret = read_attr_int(PERF_USER_ACCESS_PATH, &restore_uaccess);
+   if (ret)
+   return ret;
+
+   /* user access already enabled */
+   if (restore_uaccess == 1)
+   return 0;
+
+   return write_attr_int(PERF_USER_ACCESS_PATH, 1);
+}
+
+void
+pmu_arch_fini(void)
+{
+   write_attr_int(PERF_USER_ACCESS_PATH, restore_uaccess);
+}
+
+void
+pmu_arch_fixup_config(uint64_t config[3])
+{
+   /* select 64 bit counters */
+   config[1] |= RTE_BIT64(0);
+   /* enable userspace access */
+   config[1] |= RTE_BIT64(1);
+}
diff --git a/lib/pmu/rte_pmu.h b/lib/pmu/rte_pmu.h
index abf32da967..346b8a98f2 100644
--- a/lib/pmu/rte_pmu.h
+++ b/lib/pmu/rte_pmu.h
@@ -26,6 +26,10 @@ extern "C" {
 #include 
 #include 
 
+#if defined(RTE_ARCH_ARM64)
+#include "rte_pmu_pmc_arm64.h"
+#endif
+
 /** Maximum number of events in a group */
 #define RTE_MAX_NUM_GROUP_EVENTS 8
 
diff --git a/lib/pmu/rte_pmu_pmc_arm64.h b/lib/pmu/rte_pmu_pmc_arm64.h
new file mode 100644
index 00..39165bbc20
--- /dev/null
+++ b/lib/pmu/rte_pmu_pmc_arm64.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 Marvell.
+ */
+#ifndef _RTE_PMU_PMC_ARM64_H_
+#define _RTE_PMU_PMC_ARM64_H_
+
+#include 
+
+static __rte_always_inline uint64_t
+rte_pmu_pmc_read(int index)
+{
+   uint64_t val;
+
+   if (index == 31) {
+   /* CPU Cycles (0x11) must be read via pmccntr_el0 */
+   asm volatile("mrs %0, pmccntr_el0" : "=r" (val));
+   } else {
+   asm volatile(
+   "msr pmselr_el0, %x0\n"
+   "mrs %0, pmxevcntr_el0\n"
+   : "=r" (val)
+   : "rZ" (index)
+   );
+   }
+
+   return val;
+}
+#define rte_pmu_pmc_read rte_pmu_pmc_read
+
+#endif /* _RTE_PMU_PMC_ARM64_H_ */
-- 
2.34.1



[PATCH 6/7] doc: update argument options for external DPDK build

2024-09-27 Thread Tomáš Ďurovec
By adding support for external build, we extend the
argument documentation for supported options.

Signed-off-by: Tomáš Ďurovec 
---
 doc/guides/tools/dts.rst | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst
index 65cce9e5ed..20d4d18b18 100644
--- a/doc/guides/tools/dts.rst
+++ b/doc/guides/tools/dts.rst
@@ -236,12 +236,14 @@ DTS is run with ``main.py`` located in the ``dts`` 
directory after entering Poet
  -t SECONDS, --timeout SECONDS
[DTS_TIMEOUT] The default timeout for all DTS 
operations except for compiling DPDK. (default: 15)
  -v, --verbose [DTS_VERBOSE] Specify to enable verbose output, 
logging all messages to the console. (default: False)
- -s, --skip-setup  [DTS_SKIP_SETUP] Specify to skip all setup steps on 
SUT and TG nodes. (default: False)
+ --dpdk-tree DIR_PATH  [DTS_DPDK_TREE] Path to DPDK source code tree to 
test. (default: None)
  --tarball FILE_PATH, --snapshot FILE_PATH
[DTS_DPDK_TARBALL] Path to DPDK source code tarball 
to test. (default: None)
  --revision ID, --rev ID, --git-ref ID
[DTS_DPDK_REVISION_ID] Git revision ID to test. 
Could be commit, tag, tree ID etc. To test local changes, first
commit them, then use their commit ID. (default: 
None)
+ --remote-source   [DTS_REMOTE_SOURCE] Set when the DPDK source tree 
or tarball is located on the SUT node. (default: False)
+ --build-dir DIR_NAME  [DTS_BUILD_DIR] A directory name, which would be 
located in the `dpdk tree` or `tarball`. (default: None)
  --compile-timeout SECONDS
[DTS_COMPILE_TIMEOUT] The timeout for compiling 
DPDK. (default: 1200)
  --test-suite TEST_SUITE [TEST_CASES ...]
@@ -257,8 +259,9 @@ DTS is run with ``main.py`` located in the ``dts`` 
directory after entering Poet
 
 
 The brackets contain the names of environment variables that set the same 
thing.
-The minimum DTS needs is a config file and a DPDK tarball or git ref ID.
-You may pass those to DTS using the command line arguments or use the default 
paths.
+The minimum DTS needs is a config file and a pre-built DPDK or DPDK
+sources location which can be specified in said config file or on the
+command line or environment variables.
 
 Example command for running DTS with the template configuration and DPDK tag 
v23.11:
 
-- 
2.46.1



Re: [PATCH v1] ethdev: fix int overflow in descriptor count logic

2024-09-27 Thread Meade, Niall
>On 9/26/2024 3:03 PM, Meade, Niall wrote:
>>> From: Ferruh Yigit 
>>> Sent: Thursday, September 26, 2024 12:16 AM
>>> To: Meade, Niall ; Thomas Monjalon 
>>> ; Andrew Rybchenko ; 
>>> Roman Zhukov 
>>> Cc: dev@dpdk.org 
>>> Subject: Re: [PATCH v1] ethdev: fix int overflow in descriptor count logic
>> 
 The resolution involves upcasting nb_desc to a uint32_t before the
 RTE_ALIGN_CEIL macro is applied. This change ensures that the subsequent
 call to RTE_ALIGN_FLOOR(nb_desc + (nb_align - 1), nb_align) does not
 result in an overflow, as it would when nb_desc is a uint16_t. By using
 a uint32_t for these operations, the correct behavior is maintained
 without the risk of overflow.

>>>
>>> Hi Niall,
>>
>> Hi Ferruh,
>>
>>> Thanks for the patch.
>>>
>>> For the 'RTE_ALIGN_CEIL(val, align)' macro, 'align' should be power of
>>> two, as 'desc_lim->nb_align' is uint16_t, max value it can get is 2^15.
>>> 'val' should be smaller than or equal to 'align', so '*nb_desc' can be
>>> maximum 2^15.
>>>
>>> So RTE_ALIGN_CEIL(2^15-1, 2^15) = 2^15, I think this should work fine
>>> (although I didn't test).
>>>
>>> And even with your uint32_t cast, I think following will fail:
>>> RTE_ALIGN_CEIL(2^16-1, 2^15)
>>> (again, not tested).
>>>
>>
>> I tested my code with these values and the behaviour is as expected from
>> what I can see.
>> At a high level I ran into this issue when passing uint16_tMAX into
>> rte_eth_dev_adjust_nb_rx_tx_desc() with the intent of selecting the maximum
>> ring descriptor size but the minimum was selected.
>>
>>> Or maybe I am missing a case, can you please give some actual numbers to
>>> show the problem and the fix?
>>
>> Yes sure! If we take an example of val= (2^16)-1 and align= 32.
>> RTE_ALIGN_CEIL(val, align) calls RTE_ALIGN_FLOOR(val + align - 1, align). 
>> With
>> val as a uint16_t this subsequent macro call results in a wrap around for val
>> (originally was the max uint16_t and now we are attempting to add align to
>> it). The returned value of RTE_ALIGN_CEIL() in this case is 0. This results 
>> in
>> nb_desc being set to 0, and later set to the minimum ring descriptor size for
>> that NIC with *nb_desc = RTE_MAX(*nb_desc, desc_lim->nb_min).
>>
>> While this example is an unreasonably large request for a descriptor ring 
>> size,
>> the expected behaviour would be that the descriptor ring size defaults back 
>> to
>> the maximum possible for that particular NIC, not to the minimum which it
>> currently does.
>> By introducing a uint32_t, the wrap around in RTE_ALIGN_FLOOR() is avoided,
>> keeping the large value of nb_desc_32 which is later set to an appropriate 
>> size
>> in RTE_MIN(*nb_desc_32, desc_lim->nb_max)
>>
>
>I see the problem now, thanks.
>
>When value > (2^16 - align), next aligned value is 2^16, which is
>UINT16_MAX + 1, hence wraps to 0, this is kind of expected.
>
>For the relevant code, assuming 'desc_lim->nb_max' & 'desc_lim->nb_min'
>are already aligned to 'desc_lim->nb_align', following should fix the
>issue, that seems simpler to me, what do you think:

Yes, while it is a simpler solution there is still potential for an overflow if 
nb_max
is equal to 0. If nb_max is 0 while nb_desc is UINT16_MAX, UINT16_MAX will be
passed to the align macro resulting in an overflow again.

>
>```
>if (desc_lim->nb_max != 0)
>    *nb_desc = RTE_MIN(*nb_desc, desc_lim->nb_max);
>
>nb_desc_32 = RTE_MAX(nb_desc_32, desc_lim->nb_min);
>
>if (desc_lim->nb_align != 0)
>    *nb_desc = RTE_ALIGN_CEIL(*nb_desc, desc_lim->nb_align);
>```
>
>Basically just changing the order of the operations...
>
>It is not easy to see the problem, can you please give sample values in
>the commit log (for '*nb_desc', 'nb_align', 'nb_max' & 'nb_min'), that
>makes much easier to see why above works.

Yes, good idea! I'll add an example to the commit log for clarity.
--
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263


This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.



[PATCH 3/7] dts: fix remote session file transfer vars

2024-09-27 Thread Tomáš Ďurovec
The OSSession (and its subclasses) should accept PurePaths
for remote paths to translate from OS-unaware (PurePath)
to OS-aware (Path) only on the remote side. For local paths,
they should accept Paths, as Python is OS-aware locally.

Signed-off-by: Tomáš Ďurovec 
---
 .../remote_session/remote_session.py  | 24 ++--
 dts/framework/remote_session/ssh_session.py   | 18 
 dts/framework/testbed_model/os_session.py | 28 ---
 dts/framework/testbed_model/posix_session.py  | 18 
 4 files changed, 30 insertions(+), 58 deletions(-)

diff --git a/dts/framework/remote_session/remote_session.py 
b/dts/framework/remote_session/remote_session.py
index 8c580b070f..ab83f5b266 100644
--- a/dts/framework/remote_session/remote_session.py
+++ b/dts/framework/remote_session/remote_session.py
@@ -12,7 +12,7 @@
 
 from abc import ABC, abstractmethod
 from dataclasses import InitVar, dataclass, field
-from pathlib import PurePath
+from pathlib import Path, PurePath
 
 from framework.config import NodeConfiguration
 from framework.exception import RemoteCommandExecutionError
@@ -196,35 +196,29 @@ def is_alive(self) -> bool:
 """Check whether the remote session is still responding."""
 
 @abstractmethod
-def copy_from(
-self,
-source_file: str | PurePath,
-destination_file: str | PurePath,
-) -> None:
+def copy_from(self, source_file: str | PurePath, destination_dir: str | 
Path) -> None:
 """Copy a file from the remote Node to the local filesystem.
 
 Copy `source_file` from the remote Node associated with this remote 
session
-to `destination_file` on the local filesystem.
+to `destination_dir` on the local filesystem.
 
 Args:
 source_file: The file on the remote Node.
-destination_file: A file or directory path on the local filesystem.
+destination_dir: The directory path on the local filesystem where 
the `source_file`
+will be saved.
 """
 
 @abstractmethod
-def copy_to(
-self,
-source_file: str | PurePath,
-destination_file: str | PurePath,
-) -> None:
+def copy_to(self, source_file: str | Path, destination_dir: str | 
PurePath) -> None:
 """Copy a file from local filesystem to the remote Node.
 
-Copy `source_file` from local filesystem to `destination_file` on the 
remote Node
+Copy `source_file` from local filesystem to `destination_dir` on the 
remote Node
 associated with this remote session.
 
 Args:
 source_file: The file on the local filesystem.
-destination_file: A file or directory path on the remote Node.
+destination_dir: The directory path on the remote Node where the 
`source_file`
+will be saved.
 """
 
 @abstractmethod
diff --git a/dts/framework/remote_session/ssh_session.py 
b/dts/framework/remote_session/ssh_session.py
index 66f8176833..329121913f 100644
--- a/dts/framework/remote_session/ssh_session.py
+++ b/dts/framework/remote_session/ssh_session.py
@@ -5,7 +5,7 @@
 
 import socket
 import traceback
-from pathlib import PurePath
+from pathlib import Path, PurePath
 
 from fabric import Connection  # type: ignore[import-untyped]
 from invoke.exceptions import (  # type: ignore[import-untyped]
@@ -103,21 +103,13 @@ def is_alive(self) -> bool:
 """Overrides :meth:`~.remote_session.RemoteSession.is_alive`."""
 return self.session.is_connected
 
-def copy_from(
-self,
-source_file: str | PurePath,
-destination_file: str | PurePath,
-) -> None:
+def copy_from(self, source_file: str | PurePath, destination_dir: str | 
Path) -> None:
 """Overrides :meth:`~.remote_session.RemoteSession.copy_from`."""
-self.session.get(str(destination_file), str(source_file))
+self.session.get(str(source_file), str(destination_dir))
 
-def copy_to(
-self,
-source_file: str | PurePath,
-destination_file: str | PurePath,
-) -> None:
+def copy_to(self, source_file: str | Path, destination_dir: str | 
PurePath) -> None:
 """Overrides :meth:`~.remote_session.RemoteSession.copy_to`."""
-self.session.put(str(source_file), str(destination_file))
+self.session.put(str(source_file), str(destination_dir))
 
 def close(self) -> None:
 """Overrides :meth:`~.remote_session.RemoteSession.close`."""
diff --git a/dts/framework/testbed_model/os_session.py 
b/dts/framework/testbed_model/os_session.py
index 79f56b289b..1aac3659bf 100644
--- a/dts/framework/testbed_model/os_session.py
+++ b/dts/framework/testbed_model/os_session.py
@@ -25,7 +25,7 @@
 from abc import ABC, abstractmethod
 from collections.abc import Iterable
 from ipaddress import IPv4Interface, IPv6Interface
-from pathlib import PurePath
+from pathlib import Path, PurePath
 from typing import

[PATCH v2 1/1] ethdev: fix int overflow in descriptor count logic

2024-09-27 Thread Niall Meade
Addressed a specific overflow issue in the eth_dev_adjust_nb_desc()
function where the uint16_t variable nb_desc would overflow when its
value was greater than (2^16 - nb_align). This overflow caused nb_desc
to incorrectly wrap around between 0 and nb_align-1, leading to the
function setting nb_desc to nb_min instead of the expected nb_max.

To give an example, let nb_desc=UINT16_MAX, nb_align=32, nb_max=4096 and
nb_min=64. RTE_ALIGN_CEIL(nb_desc, nb_align) calls
RTE_ALIGN_FLOOR(nb_desc + nb_align - 1, nb_align). This results in an
overflow of nb_desc, leading to nb_desc being set to 30 and then 0 when
the macros return. As a result of this, nb_desc is then set to nb_min
later on.

The resolution involves upcasting nb_desc to a uint32_t before the
RTE_ALIGN_CEIL macro is applied. This change ensures that the subsequent
call to RTE_ALIGN_FLOOR(nb_desc + (nb_align - 1), nb_align) does not
result in an overflow, as it would when nb_desc is a uint16_t. By using
a uint32_t for these operations, the correct behavior is maintained
without the risk of overflow.

Fixes: 0f67fc3baeb9 ("ethdev: add function to adjust number of descriptors")

Signed-off-by: Niall Meade 

---
v2:
* add example of issue to commit message
---
 .mailmap|  1 +
 lib/ethdev/rte_ethdev.c | 12 +---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/.mailmap b/.mailmap
index 4a508bafad..c1941e78bb 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1053,6 +1053,7 @@ Nelson Escobar 
 Nemanja Marjanovic 
 Netanel Belgazal 
 Netanel Gonen 
+Niall Meade 
 Niall Power 
 Nicholas Pratte 
 Nick Connolly  
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index f1c658f49e..f978283edf 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6577,13 +6577,19 @@ static void
 eth_dev_adjust_nb_desc(uint16_t *nb_desc,
const struct rte_eth_desc_lim *desc_lim)
 {
+   /* Upcast to uint32 to avoid potential overflow with RTE_ALIGN_CEIL(). 
*/
+   uint32_t nb_desc_32 = *nb_desc;
+
if (desc_lim->nb_align != 0)
-   *nb_desc = RTE_ALIGN_CEIL(*nb_desc, desc_lim->nb_align);
+   nb_desc_32 = RTE_ALIGN_CEIL(nb_desc_32, desc_lim->nb_align);
 
if (desc_lim->nb_max != 0)
-   *nb_desc = RTE_MIN(*nb_desc, desc_lim->nb_max);
+   nb_desc_32 = RTE_MIN(nb_desc_32, desc_lim->nb_max);
+
+   nb_desc_32 = RTE_MAX(nb_desc_32, desc_lim->nb_min);
 
-   *nb_desc = RTE_MAX(*nb_desc, desc_lim->nb_min);
+   /* Assign clipped u32 back to u16. */
+   *nb_desc = nb_desc_32;
 }
 
 int
-- 
2.34.1

--
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263


This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.



[PATCH 0/7] DTS external DPDK build

2024-09-27 Thread Tomáš Ďurovec
This patch series adds ability to use pre-build DPDK in various options of 
usage. User can specify 
this option from config file or cmd arguments/environment variables:
* The source of DPDK (tarball or tree),
* The build dir witch will be located in a subdirectory of DPDK tree root 
directory, otherwise will 
  be used build configuration from config file, 
* Location where the DPDK source will be stored either in SUT node or local 
filesystem.

Tomáš Ďurovec (7):
  dts: rename build target to DPDK build
  dts: one dpdk build per test run
  dts: fix remote session file transfer vars
  dts: add the ability to copy directories via remote
  dts: add support for externally compiled DPDK
  doc: update argument options for external DPDK build
  dts: remove git ref option

 doc/guides/tools/dts.rst  |  18 +-
 dts/conf.yaml |  17 +-
 dts/framework/config/__init__.py  | 140 ++-
 dts/framework/config/conf_yaml_schema.json|  72 +++-
 dts/framework/config/types.py |  19 +-
 dts/framework/exception.py|   4 +-
 dts/framework/logger.py   |   4 -
 dts/framework/remote_session/dpdk_shell.py|   2 +-
 .../remote_session/remote_session.py  |  24 +-
 dts/framework/remote_session/ssh_session.py   |  18 +-
 dts/framework/runner.py   | 139 ++-
 dts/framework/settings.py | 200 +++---
 dts/framework/test_result.py  | 124 ++
 dts/framework/test_suite.py   |   2 +-
 dts/framework/testbed_model/node.py   |  22 +-
 dts/framework/testbed_model/os_session.py | 209 --
 dts/framework/testbed_model/posix_session.py  | 141 ++-
 dts/framework/testbed_model/sut_node.py   | 366 --
 dts/framework/utils.py| 164 
 dts/tests/TestSuite_smoke_tests.py|   2 +-
 20 files changed, 1078 insertions(+), 609 deletions(-)

-- 
2.46.1



[PATCH v12 1/4] lib: add generic support for reading PMU events

2024-09-27 Thread Tomasz Duszynski
Add support for programming PMU counters and reading their values
in runtime bypassing kernel completely.

This is especially useful in cases where CPU cores are isolated
i.e run dedicated tasks. In such cases one cannot use standard
perf utility without sacrificing latency and performance.

Signed-off-by: Tomasz Duszynski 
---
 MAINTAINERS|   5 +
 app/test/meson.build   |   1 +
 app/test/test_pmu.c|  62 
 doc/api/doxy-api-index.md  |   3 +-
 doc/api/doxy-api.conf.in   |   1 +
 doc/guides/prog_guide/profile_app.rst  |  26 ++
 doc/guides/rel_notes/release_24_11.rst |   7 +
 lib/meson.build|   1 +
 lib/pmu/meson.build|  15 +
 lib/pmu/pmu_private.h  |  32 ++
 lib/pmu/rte_pmu.c  | 465 +
 lib/pmu/rte_pmu.h  | 206 +++
 lib/pmu/version.map|  14 +
 13 files changed, 837 insertions(+), 1 deletion(-)
 create mode 100644 app/test/test_pmu.c
 create mode 100644 lib/pmu/meson.build
 create mode 100644 lib/pmu/pmu_private.h
 create mode 100644 lib/pmu/rte_pmu.c
 create mode 100644 lib/pmu/rte_pmu.h
 create mode 100644 lib/pmu/version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index c5a703b5c0..80bf5968de 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1811,6 +1811,11 @@ M: Nithin Dabilpuram 
 M: Pavan Nikhilesh 
 F: lib/node/
 
+PMU - EXPERIMENTAL
+M: Tomasz Duszynski 
+F: lib/pmu/
+F: app/test/test_pmu*
+
 
 Test Applications
 -
diff --git a/app/test/meson.build b/app/test/meson.build
index e29258e6ec..45f56d8aae 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -139,6 +139,7 @@ source_file_deps = {
 'test_pmd_perf.c': ['ethdev', 'net'] + packet_burst_generator_deps,
 'test_pmd_ring.c': ['net_ring', 'ethdev', 'bus_vdev'],
 'test_pmd_ring_perf.c': ['ethdev', 'net_ring', 'bus_vdev'],
+'test_pmu.c': ['pmu'],
 'test_power.c': ['power'],
 'test_power_cpufreq.c': ['power'],
 'test_power_intel_uncore.c': ['power'],
diff --git a/app/test/test_pmu.c b/app/test/test_pmu.c
new file mode 100644
index 00..5792cf1963
--- /dev/null
+++ b/app/test/test_pmu.c
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 Marvell International Ltd.
+ */
+
+#include "test.h"
+
+#ifndef RTE_EXEC_ENV_LINUX
+
+static int
+test_pmu(void)
+{
+   printf("pmu_autotest only supported on Linux, skipping test\n");
+   return TEST_SKIPPED;
+}
+
+#else
+
+#include 
+
+static int
+test_pmu_read(void)
+{
+   const char *name = NULL;
+   int tries = 10, event;
+   uint64_t val = 0;
+
+   if (name == NULL) {
+   printf("PMU not supported on this arch\n");
+   return TEST_SKIPPED;
+   }
+
+   if (rte_pmu_init() < 0)
+   return TEST_SKIPPED;
+
+   event = rte_pmu_add_event(name);
+   while (tries--)
+   val += rte_pmu_read(event);
+
+   rte_pmu_fini();
+
+   return val ? TEST_SUCCESS : TEST_FAILED;
+}
+
+static struct unit_test_suite pmu_tests = {
+   .suite_name = "pmu autotest",
+   .setup = NULL,
+   .teardown = NULL,
+   .unit_test_cases = {
+   TEST_CASE(test_pmu_read),
+   TEST_CASES_END()
+   }
+};
+
+static int
+test_pmu(void)
+{
+   return unit_test_suite_runner(&pmu_tests);
+}
+
+#endif /* RTE_EXEC_ENV_LINUX */
+
+REGISTER_FAST_TEST(pmu_autotest, true, true, test_pmu);
diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index f9f0300126..805efc6520 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -237,7 +237,8 @@ The public API headers are grouped by topics:
   [log](@ref rte_log.h),
   [errno](@ref rte_errno.h),
   [trace](@ref rte_trace.h),
-  [trace_point](@ref rte_trace_point.h)
+  [trace_point](@ref rte_trace_point.h),
+  [pmu](@ref rte_pmu.h)
 
 - **misc**:
   [EAL config](@ref rte_eal.h),
diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
index a8823c046f..658490b6a2 100644
--- a/doc/api/doxy-api.conf.in
+++ b/doc/api/doxy-api.conf.in
@@ -69,6 +69,7 @@ INPUT   = @TOPDIR@/doc/api/doxy-api-index.md \
   @TOPDIR@/lib/pdcp \
   @TOPDIR@/lib/pdump \
   @TOPDIR@/lib/pipeline \
+  @TOPDIR@/lib/pmu \
   @TOPDIR@/lib/port \
   @TOPDIR@/lib/power \
   @TOPDIR@/lib/ptr_compress \
diff --git a/doc/guides/prog_guide/profile_app.rst 
b/doc/guides/prog_guide/profile_app.rst
index a6b5fb4d5e..ecb90a0d94 100644
--- a/doc/guides/prog_guide/profile_app.rst
+++ b/doc/guides/prog_guide/profile_app.rst
@@ -7,6 +7,32 @@ Profile Your Application
 The following sections describe methods of profiling DPDK applications on
 different architectures.
 
+Performance counte

[PATCH 1/7] dts: rename build target to DPDK build

2024-09-27 Thread Tomáš Ďurovec
Since the DPDK may already be built, some more general name
is needed that includes both the DPDK location and the build
config (if we are going to build).

Signed-off-by: Tomáš Ďurovec 
---
 dts/conf.yaml  |   2 +-
 dts/framework/config/__init__.py   |  26 ++---
 dts/framework/config/conf_yaml_schema.json |  10 +-
 dts/framework/config/types.py  |   4 +-
 dts/framework/logger.py|   4 +-
 dts/framework/runner.py| 112 ++---
 dts/framework/settings.py  |   2 +-
 dts/framework/test_result.py   |  72 +++--
 dts/framework/test_suite.py|   2 +-
 dts/framework/testbed_model/sut_node.py|  55 +-
 dts/tests/TestSuite_smoke_tests.py |   2 +-
 11 files changed, 142 insertions(+), 149 deletions(-)

diff --git a/dts/conf.yaml b/dts/conf.yaml
index ca5e87636e..1363e93580 100644
--- a/dts/conf.yaml
+++ b/dts/conf.yaml
@@ -4,7 +4,7 @@
 
 test_runs:
   # define one test run environment
-  - build_targets:
+  - dpdk_builds:
   - arch: x86_64
 os: linux
 cpu: native
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index 269d9ec318..c243716010 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -45,8 +45,8 @@
 from typing_extensions import Self
 
 from framework.config.types import (
-BuildTargetConfigDict,
 ConfigurationDict,
+DPDKBuildConfigDict,
 NodeConfigDict,
 PortConfigDict,
 TestRunConfigDict,
@@ -335,7 +335,7 @@ class NodeInfo:
 
 
 @dataclass(slots=True, frozen=True)
-class BuildTargetConfiguration:
+class DPDKBuildConfiguration:
 """DPDK build configuration.
 
 The configuration used for building DPDK.
@@ -358,7 +358,7 @@ class BuildTargetConfiguration:
 name: str
 
 @classmethod
-def from_dict(cls, d: BuildTargetConfigDict) -> Self:
+def from_dict(cls, d: DPDKBuildConfigDict) -> Self:
 r"""A convenience method that processes the inputs before creating an 
instance.
 
 `arch`, `os`, `cpu` and `compiler` are converted to :class:`Enum`\s and
@@ -368,7 +368,7 @@ def from_dict(cls, d: BuildTargetConfigDict) -> Self:
 d: The configuration dictionary.
 
 Returns:
-The build target configuration instance.
+The DPDK build configuration instance.
 """
 return cls(
 arch=Architecture(d["arch"]),
@@ -381,8 +381,8 @@ def from_dict(cls, d: BuildTargetConfigDict) -> Self:
 
 
 @dataclass(slots=True, frozen=True)
-class BuildTargetInfo:
-"""Various versions and other information about a build target.
+class DPDKBuildInfo:
+"""Various versions and other information about a DPDK build.
 
 Attributes:
 dpdk_version: The DPDK version that was built.
@@ -437,7 +437,7 @@ class TestRunConfiguration:
 and with what DPDK build.
 
 Attributes:
-build_targets: A list of DPDK builds to test.
+dpdk_builds: A list of DPDK builds to test.
 perf: Whether to run performance tests.
 func: Whether to run functional tests.
 skip_smoke_tests: Whether to skip smoke tests.
@@ -448,7 +448,7 @@ class TestRunConfiguration:
 random_seed: The seed to use for pseudo-random generation.
 """
 
-build_targets: list[BuildTargetConfiguration]
+dpdk_builds: list[DPDKBuildConfiguration]
 perf: bool
 func: bool
 skip_smoke_tests: bool
@@ -466,7 +466,7 @@ def from_dict(
 ) -> Self:
 """A convenience method that processes the inputs before creating an 
instance.
 
-The build target and the test suite config are transformed into their 
respective objects.
+The DPDK build and the test suite config are transformed into their 
respective objects.
 SUT and TG configurations are taken from `node_map`. The other 
(:class:`bool`) attributes
 are just stored.
 
@@ -477,8 +477,8 @@ def from_dict(
 Returns:
 The test run configuration instance.
 """
-build_targets: list[BuildTargetConfiguration] = list(
-map(BuildTargetConfiguration.from_dict, d["build_targets"])
+dpdk_builds: list[DPDKBuildConfiguration] = list(
+map(DPDKBuildConfiguration.from_dict, d["dpdk_builds"])
 )
 test_suites: list[TestSuiteConfig] = 
list(map(TestSuiteConfig.from_dict, d["test_suites"]))
 sut_name = d["system_under_test_node"]["node_name"]
@@ -501,7 +501,7 @@ def from_dict(
 )
 random_seed = d.get("random_seed", None)
 return cls(
-build_targets=build_targets,
+dpdk_builds=dpdk_builds,
 perf=d["perf"],
 func=d["func"],
 skip_smoke_tests=skip_smoke_tests,
@@ -552,7 +552,7 @@ class Configuration:
 def from_dict(cls, d: ConfigurationDict) -> Self:
 """A convenience method that processes t

Re: [PATCH] fib: implement RCU rule reclamation

2024-09-27 Thread Robin Jarry

Vladimir Medvedkin, Sep 06, 2024 at 13:09:

Currently, for DIR24-8 algorithm, the tbl8 group is freed even though the
readers might be using the tbl8 group entries. The freed tbl8 group can
be reallocated quickly. As a result, lookup may be performed incorrectly.

To address that, RCU QSBR is integrated for safe tbl8 group reclamation.

Signed-off-by: Vladimir Medvedkin 
---



diff --git a/lib/fib/meson.build b/lib/fib/meson.build
index 6795f41a0a..1895f37050 100644
--- a/lib/fib/meson.build
+++ b/lib/fib/meson.build
@@ -11,6 +11,7 @@ endif
 sources = files('rte_fib.c', 'rte_fib6.c', 'dir24_8.c', 'trie.c')
 headers = files('rte_fib.h', 'rte_fib6.h')
 deps += ['rib']
+deps += ['rcu']


Hi Vladimir,

thanks a lot for working on this!

I tested with static linking and there is a missing dependency to 
static_rte_rcu:


In file included from ../subprojects/dpdk/lib/fib/dir24_8_avx512.c:6:
../subprojects/dpdk/lib/fib/rte_fib.h:19:10: fatal error: rte_rcu_qsbr.h: No 
such file or directory
  19 | #include 
 |  ^~~~

After adding it:

@@ -45,7 +45,7 @@ if dpdk_conf.has('RTE_ARCH_X86_64') and binutils_ok
elif cc.has_multi_arguments('-mavx512f', '-mavx512dq')
dir24_8_avx512_tmp = static_library('dir24_8_avx512_tmp',
'dir24_8_avx512.c',
-dependencies: static_rte_eal,
+dependencies: [static_rte_eal, static_rte_rcu],
c_args: cflags + ['-mavx512f', '-mavx512dq'])
objs += dir24_8_avx512_tmp.extract_objects('dir24_8_avx512.c')
cflags += ['-DCC_DIR24_8_AVX512_SUPPORT']

I get another error:

In file included from 
/usr/lib/gcc/x86_64-redhat-linux/14/include/immintrin.h:65,
from /usr/lib/gcc/x86_64-redhat-linux/14/include/x86intrin.h:32,
from ../subprojects/dpdk/lib/eal/x86/include/rte_vect.h:26,
from ../subprojects/dpdk/lib/fib/dir24_8_avx512.c:5:
/usr/lib/gcc/x86_64-redhat-linux/14/include/avx512bwintrin.h: In function 
‘dir24_8_vec_lookup_x16’:
/usr/lib/gcc/x86_64-redhat-linux/14/include/avx512bwintrin.h:1947:1: error: 
inlining failed in call to ‘always_inline’ ‘_mm512_shuffle_epi8’: target 
specific option mismatch
1947 | _mm512_shuffle_epi8 (__m512i __A, __m512i __B)
 | ^~~
../subprojects/dpdk/lib/fib/dir24_8_avx512.c:38:26: note: called from here
  38 | ip_vec = _mm512_shuffle_epi8(ip_vec, bswap32);
 |  ^~~~
/usr/lib/gcc/x86_64-redhat-linux/14/include/avx512bwintrin.h:1947:1: error: 
inlining failed in call to ‘always_inline’ ‘_mm512_shuffle_epi8’: target 
specific option mismatch
1947 | _mm512_shuffle_epi8 (__m512i __A, __m512i __B)
 | ^~~
../subprojects/dpdk/lib/fib/dir24_8_avx512.c:38:26: note: called from here
  38 | ip_vec = _mm512_shuffle_epi8(ip_vec, bswap32);
 |  ^~~~

I'm not sure what to do at this point.



[PATCH 6/7] doc: update argument options for external DPDK build

2024-09-27 Thread Tomáš Ďurovec
By adding support for external build, we extend the
argument documentation for supported options.

Signed-off-by: Tomáš Ďurovec 
---
 doc/guides/tools/dts.rst | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst
index 65cce9e5ed..20d4d18b18 100644
--- a/doc/guides/tools/dts.rst
+++ b/doc/guides/tools/dts.rst
@@ -236,12 +236,14 @@ DTS is run with ``main.py`` located in the ``dts`` 
directory after entering Poet
  -t SECONDS, --timeout SECONDS
[DTS_TIMEOUT] The default timeout for all DTS 
operations except for compiling DPDK. (default: 15)
  -v, --verbose [DTS_VERBOSE] Specify to enable verbose output, 
logging all messages to the console. (default: False)
- -s, --skip-setup  [DTS_SKIP_SETUP] Specify to skip all setup steps on 
SUT and TG nodes. (default: False)
+ --dpdk-tree DIR_PATH  [DTS_DPDK_TREE] Path to DPDK source code tree to 
test. (default: None)
  --tarball FILE_PATH, --snapshot FILE_PATH
[DTS_DPDK_TARBALL] Path to DPDK source code tarball 
to test. (default: None)
  --revision ID, --rev ID, --git-ref ID
[DTS_DPDK_REVISION_ID] Git revision ID to test. 
Could be commit, tag, tree ID etc. To test local changes, first
commit them, then use their commit ID. (default: 
None)
+ --remote-source   [DTS_REMOTE_SOURCE] Set when the DPDK source tree 
or tarball is located on the SUT node. (default: False)
+ --build-dir DIR_NAME  [DTS_BUILD_DIR] A directory name, which would be 
located in the `dpdk tree` or `tarball`. (default: None)
  --compile-timeout SECONDS
[DTS_COMPILE_TIMEOUT] The timeout for compiling 
DPDK. (default: 1200)
  --test-suite TEST_SUITE [TEST_CASES ...]
@@ -257,8 +259,9 @@ DTS is run with ``main.py`` located in the ``dts`` 
directory after entering Poet
 
 
 The brackets contain the names of environment variables that set the same 
thing.
-The minimum DTS needs is a config file and a DPDK tarball or git ref ID.
-You may pass those to DTS using the command line arguments or use the default 
paths.
+The minimum DTS needs is a config file and a pre-built DPDK or DPDK
+sources location which can be specified in said config file or on the
+command line or environment variables.
 
 Example command for running DTS with the template configuration and DPDK tag 
v23.11:
 
-- 
2.46.1



[PATCH 7/7] dts: remove git ref option

2024-09-27 Thread Tomáš Ďurovec
In the previous commits we're adding the support for copying
the whole local DPDK tree directory and git-ref option was
meant to do the same thing.

Signed-off-by: Tomáš Ďurovec 
---
 doc/guides/tools/dts.rst  |   9 ---
 dts/framework/settings.py |  51 +++-
 dts/framework/utils.py| 119 +-
 3 files changed, 8 insertions(+), 171 deletions(-)

diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst
index 20d4d18b18..d806dce2ae 100644
--- a/doc/guides/tools/dts.rst
+++ b/doc/guides/tools/dts.rst
@@ -239,9 +239,6 @@ DTS is run with ``main.py`` located in the ``dts`` 
directory after entering Poet
  --dpdk-tree DIR_PATH  [DTS_DPDK_TREE] Path to DPDK source code tree to 
test. (default: None)
  --tarball FILE_PATH, --snapshot FILE_PATH
[DTS_DPDK_TARBALL] Path to DPDK source code tarball 
to test. (default: None)
- --revision ID, --rev ID, --git-ref ID
-   [DTS_DPDK_REVISION_ID] Git revision ID to test. 
Could be commit, tag, tree ID etc. To test local changes, first
-   commit them, then use their commit ID. (default: 
None)
  --remote-source   [DTS_REMOTE_SOURCE] Set when the DPDK source tree 
or tarball is located on the SUT node. (default: False)
  --build-dir DIR_NAME  [DTS_BUILD_DIR] A directory name, which would be 
located in the `dpdk tree` or `tarball`. (default: None)
  --compile-timeout SECONDS
@@ -263,12 +260,6 @@ The minimum DTS needs is a config file and a pre-built 
DPDK or DPDK
 sources location which can be specified in said config file or on the
 command line or environment variables.
 
-Example command for running DTS with the template configuration and DPDK tag 
v23.11:
-
-.. code-block:: console
-
-   (dts-py3.10) $ ./main.py --git-ref v23.11
-
 
 DTS Results
 ~~~
diff --git a/dts/framework/settings.py b/dts/framework/settings.py
index 17594ecb15..a4ab674189 100644
--- a/dts/framework/settings.py
+++ b/dts/framework/settings.py
@@ -42,20 +42,12 @@
 .. option:: --dpdk-tree
 .. envvar:: DTS_DPDK_TREE
 
-The path to DPDK source tree directory to test. Only this or tarball or 
revision can be
-provided.
+The path to DPDK source tree directory to test. Only this or tarball can 
be provided.
 
 .. option:: --tarball, --snapshot
 .. envvar:: DTS_DPDK_TARBALL
 
-The path to DPDK source tarball to test. Only this or DPDK tree or 
revision can be provided.
-
-.. option:: --revision, --rev, --git-ref
-.. envvar:: DTS_DPDK_REVISION_ID
-
-Git revision ID to test. Could be commit, tag, tree ID etc.
-To test local changes, first commit them, then use their commit ID.
-Only this or DPDK tree or tarball can be provided.
+The path to DPDK source tarball to test. Only this or DPDK tree can be 
provided.
 
 .. option:: --remote-source
 .. envvar:: DTS_REMOTE_SOURCE
@@ -108,8 +100,6 @@
 from typing import Callable
 
 from .config import DPDKLocation, TestSuiteConfig
-from .exception import ConfigurationError
-from .utils import DPDKGitTarball, get_commit_id
 
 
 @dataclass(slots=True)
@@ -256,14 +246,6 @@ def _get_help_string(self, action):
 return help
 
 
-def _parse_revision_id(rev_id: str) -> str:
-"""Validate revision ID and retrieve corresponding commit ID."""
-try:
-return get_commit_id(rev_id)
-except ConfigurationError:
-raise argparse.ArgumentTypeError("The Git revision ID supplied is 
invalid or ambiguous")
-
-
 def _required_with_one_of(parser: _DTSArgumentParser, action: Action, 
*required_dests: str) -> None:
 """Verify that `action` is listed together with at least one of 
`required_dests`.
 
@@ -362,15 +344,15 @@ def _get_parser() -> _DTSArgumentParser:
 dpdk_build = parser.add_argument_group(
 "DPDK Build Options",
 description="Arguments in this group (and subgroup) will be applied to 
a "
-":class:`DPDKLocation` when the DPDK tree, tarball or revision will be 
provided, "
-"other arguments like remote source and build dir are optional. A 
:class:`DPDKLocation` "
+":class:`DPDKLocation` when the DPDK tree, tarball will be provided, 
other "
+"arguments like remote source and build dir are optional. A 
:class:`DPDKLocation` "
 "from settings are used instead of from config if construct 
successful.",
 )
 
 dpdk_source = dpdk_build.add_mutually_exclusive_group()
 action = dpdk_source.add_argument(
 "--dpdk-tree",
-help="The path to DPDK source tree directory to test. Only this or 
tarball or revision "
+help="The path to DPDK source tree directory to test. Only this or 
tarball "
 "can be provided.",
 metavar="DIR_PATH",
 dest="dpdk_tree_path",
@@ -380,26 +362,12 @@ def _get_parser() -> _DTSArgumentParser:
 action = dpdk_source.add_argument(
 "--tarball",
 "--snapshot",
-help="The path to DPDK source tarball to 

Re: [PATCH 01/16] eal: add function attributes for allocation functions

2024-09-27 Thread David Marchand
On Fri, Sep 27, 2024 at 4:48 PM Stephen Hemminger
 wrote:
>
> The allocation functions take a alignment argument that
> can be useful to hint the compiler optimizer.
>
> This is supported by Gcc and Clang but only useful with
> Gcc because Clang gives warning if alignment is 0.
>
> Recent versions of GCC have a malloc attribute that can
> be used to find mismatches between allocation and free;
> the typical problem caught is a pointer allocated with
> rte_malloc() that is then incorrectly freed using free().

Interesting tool.

>
> Signed-off-by: Stephen Hemminger 
> ---
>  lib/eal/include/rte_common.h | 30 ++
>  lib/eal/include/rte_malloc.h | 24 
>  2 files changed, 46 insertions(+), 8 deletions(-)
>
> diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
> index eec0400dad..1b3781274d 100644
> --- a/lib/eal/include/rte_common.h
> +++ b/lib/eal/include/rte_common.h
> @@ -228,6 +228,36 @@ typedef uint16_t unaligned_uint16_t;
>  #define __rte_alloc_size(...)
>  #endif
>
> +/**
> + * Tells the compiler that the function returns a value that points to
> + * memory aligned by a function argument.
> + * Not enabled on clang because it warns if align argument is zero.
> + */
> +#if defined(RTE_CC_GCC)
> +#define __rte_alloc_align(align_arg) \
> +   __attribute__((alloc_align(align_arg)))
> +#else
> +#define __rte_alloc_align(...)
> +#endif
> +
> +/**
> + * Tells the compiler this is a function like malloc and that the pointer
> + * returned cannot alias any other pointer (ie new memory).
> + *
> + * Also, with recent GCC versions also able to track that proper
> + * dealloctor function is used for this pointer.
> + */
> +#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 11)

Even though it is probably equivalent, GCC_VERSION is set with RTE_CC_GCC.

> +#define __rte_alloc_func(free_func) \
> +   __attribute__((malloc, malloc(free_func)))

I read that this malloc attribute can also make use of the arg index
to assume the pointer is freed.

Did you try this feature?

Something like:

@@ -248,14 +248,13 @@ typedef uint16_t unaligned_uint16_t;
  * dealloctor function is used for this pointer.
  */
 #if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 11)
-#define __rte_alloc_func(free_func) \
-   __attribute__((malloc, malloc(free_func)))
-
+#define __rte_alloc_func(...) \
+   __attribute__((malloc, malloc(__VA_ARGS__)))
 #elif defined(RTE_CC_GCC) || defined(RTE_CC_CLANG)
-#define __rte_alloc_func(free_func) \
+#define __rte_alloc_func(...) \
__attribute__((malloc))
 #else
-#define __rte_alloc_func(free_func)
+#define __rte_alloc_func(...)
 #endif

 #define RTE_PRIORITY_LOG 101

> +
> +#elif defined(RTE_CC_GCC) || defined(RTE_CC_CLANG)
> +#define __rte_alloc_func(free_func) \
> +   __attribute__((malloc))
> +#else
> +#define __rte_alloc_func(free_func)
> +#endif
> +
>  #define RTE_PRIORITY_LOG 101
>  #define RTE_PRIORITY_BUS 110
>  #define RTE_PRIORITY_CLASS 120


-- 
David Marchand



Re: [PATCH v6 0/2] Add link_speed lanes support

2024-09-27 Thread Ferruh Yigit
On 9/26/2024 10:43 PM, Damodharam Ammepalli wrote:
> This patch series is a continuation of the patch set that supports 
> configuring speed lanes.
> https://patchwork.dpdk.org/project/dpdk/patch/20240708232351.491529-1-
> damodharam.ammepa...@broadcom.com/
> 
> The patchset consists
> 1) rtelib/testpmd changes (Addressing the comments). Earlier comments are 
> available here, 
> https://patchwork.dpdk.org/project/dpdk/list/?
> q=Add%20link_speed%20lanes%20support&archive=both&series=&submitter=&delegate=&state=*
> 
> 2) Driver implementation of bnxt PMD.
> 
> v2->v3 Consolidating the testpmd and rtelib patches into a single patch as 
> requested.
> v3->v4 Addressed comments and fix help string and documentation.
> v4->v5 Addressed comments given in v4 and also driver implementation of bnxt 
> PMD.
> v5->v6 Removed LANE_xx enums and updated driver source files. Minor help
> string fix.
> 
> Damodharam Ammepalli (2):
>   ethdev: Add link_speed lanes support
>   net/bnxt: code refactor for supporting speed lanes
>

Series applied to dpdk-next-net/main, thanks.



FreeBSD problem with ixgbe

2024-09-27 Thread Lewis Donzis
I'm pretty sure this is been reported before, but in ixgbe_ethdev.c, line 4311 
begins:

/* BSD has no interrupt mechanism, so force NIC status synchronization. */
#ifdef RTE_EXEC_ENV_FREEBSD
wait = 1;
#endif

We've had to remove this code ever since it was added because it causes 
improper delays in our code.  When we ask for link status without waiting, we 
need for it not to wait, and I'm not sure why a lack of interrupts makes any 
difference in this case.  Removing this code allows it to behave properly, best 
we can tell.

Thanks,
lew


Re: [PATCH v5 1/2] dts: rework packet addressing

2024-09-27 Thread Juraj Linkeš




On 26. 9. 2024 20:18, jspew...@iol.unh.edu wrote:

From: Jeremy Spewock 

This patch updates the _adjust_addresses method of test suites so
that addresses of packets are only modified if the developer did not
configure them beforehand. This allows for developers to have more
control over the content of their packets when sending them through the
framework.

Signed-off-by: Jeremy Spewock 
---


Reviewed-by: Juraj Linkeš 


Re: [PATCH v4 09/11] doc: add DTS capability doc sources

2024-09-27 Thread Luca Vizzarro

Reviewed-by: Luca Vizzarro 


Re: [PATCH v5 2/2] dts: add send_packets to test_suite

2024-09-27 Thread Luca Vizzarro

Reviewed-by: Luca Vizzarro 


[PATCH v7 1/8] common/zsda: add common function and log macro

2024-09-27 Thread Hanxiao Li
Introduce common function and log macro for ZSDA which
can help accelerate storage data process.

Signed-off-by: Hanxiao Li 
---
 drivers/common/zsda/meson.build   |  14 ++
 drivers/common/zsda/zsda_common.c | 167 +++
 drivers/common/zsda/zsda_common.h | 326 ++
 drivers/common/zsda/zsda_logs.c   |  21 ++
 drivers/common/zsda/zsda_logs.h   |  32 +++
 drivers/meson.build   |   1 +
 6 files changed, 561 insertions(+)
 create mode 100644 drivers/common/zsda/meson.build
 create mode 100644 drivers/common/zsda/zsda_common.c
 create mode 100644 drivers/common/zsda/zsda_common.h
 create mode 100644 drivers/common/zsda/zsda_logs.c
 create mode 100644 drivers/common/zsda/zsda_logs.h

diff --git a/drivers/common/zsda/meson.build b/drivers/common/zsda/meson.build
new file mode 100644
index 00..8971289080
--- /dev/null
+++ b/drivers/common/zsda/meson.build
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 ZTE Corporation
+
+if is_windows
+build = false
+reason = 'not supported on Windows'
+subdir_done()
+endif
+
+deps += ['bus_pci']
+sources += files(
+   'zsda_common.c',
+   'zsda_logs.c',
+   )
diff --git a/drivers/common/zsda/zsda_common.c 
b/drivers/common/zsda/zsda_common.c
new file mode 100644
index 00..22b4c680e1
--- /dev/null
+++ b/drivers/common/zsda/zsda_common.c
@@ -0,0 +1,167 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#include "zsda_common.h"
+
+#include "bus_pci_driver.h"
+
+#define MAGIC_SEND 0xab
+#define MAGIC_RECV 0xcd
+#define ADMIN_VER 1
+
+static const uint8_t crc8_table[256] = {
+   0x00, 0x41, 0x13, 0x52, 0x26, 0x67, 0x35, 0x74, 0x4c, 0x0d, 0x5f, 0x1e,
+   0x6a, 0x2b, 0x79, 0x38, 0x09, 0x48, 0x1a, 0x5b, 0x2f, 0x6e, 0x3c, 0x7d,
+   0x45, 0x04, 0x56, 0x17, 0x63, 0x22, 0x70, 0x31, 0x12, 0x53, 0x01, 0x40,
+   0x34, 0x75, 0x27, 0x66, 0x5e, 0x1f, 0x4d, 0x0c, 0x78, 0x39, 0x6b, 0x2a,
+   0x1b, 0x5a, 0x08, 0x49, 0x3d, 0x7c, 0x2e, 0x6f, 0x57, 0x16, 0x44, 0x05,
+   0x71, 0x30, 0x62, 0x23, 0x24, 0x65, 0x37, 0x76, 0x02, 0x43, 0x11, 0x50,
+   0x68, 0x29, 0x7b, 0x3a, 0x4e, 0x0f, 0x5d, 0x1c, 0x2d, 0x6c, 0x3e, 0x7f,
+   0x0b, 0x4a, 0x18, 0x59, 0x61, 0x20, 0x72, 0x33, 0x47, 0x06, 0x54, 0x15,
+   0x36, 0x77, 0x25, 0x64, 0x10, 0x51, 0x03, 0x42, 0x7a, 0x3b, 0x69, 0x28,
+   0x5c, 0x1d, 0x4f, 0x0e, 0x3f, 0x7e, 0x2c, 0x6d, 0x19, 0x58, 0x0a, 0x4b,
+   0x73, 0x32, 0x60, 0x21, 0x55, 0x14, 0x46, 0x07, 0x48, 0x09, 0x5b, 0x1a,
+   0x6e, 0x2f, 0x7d, 0x3c, 0x04, 0x45, 0x17, 0x56, 0x22, 0x63, 0x31, 0x70,
+   0x41, 0x00, 0x52, 0x13, 0x67, 0x26, 0x74, 0x35, 0x0d, 0x4c, 0x1e, 0x5f,
+   0x2b, 0x6a, 0x38, 0x79, 0x5a, 0x1b, 0x49, 0x08, 0x7c, 0x3d, 0x6f, 0x2e,
+   0x16, 0x57, 0x05, 0x44, 0x30, 0x71, 0x23, 0x62, 0x53, 0x12, 0x40, 0x01,
+   0x75, 0x34, 0x66, 0x27, 0x1f, 0x5e, 0x0c, 0x4d, 0x39, 0x78, 0x2a, 0x6b,
+   0x6c, 0x2d, 0x7f, 0x3e, 0x4a, 0x0b, 0x59, 0x18, 0x20, 0x61, 0x33, 0x72,
+   0x06, 0x47, 0x15, 0x54, 0x65, 0x24, 0x76, 0x37, 0x43, 0x02, 0x50, 0x11,
+   0x29, 0x68, 0x3a, 0x7b, 0x0f, 0x4e, 0x1c, 0x5d, 0x7e, 0x3f, 0x6d, 0x2c,
+   0x58, 0x19, 0x4b, 0x0a, 0x32, 0x73, 0x21, 0x60, 0x14, 0x55, 0x07, 0x46,
+   0x77, 0x36, 0x64, 0x25, 0x51, 0x10, 0x42, 0x03, 0x3b, 0x7a, 0x28, 0x69,
+   0x1d, 0x5c, 0x0e, 0x4f};
+
+static uint8_t
+zsda_crc8(const uint8_t *message, const int length)
+{
+   uint8_t crc = 0;
+   int i;
+
+   for (i = 0; i < length; i++)
+   crc = crc8_table[crc ^ message[i]];
+   return crc;
+}
+
+uint32_t
+zsda_set_reg_8(void *addr, const uint8_t val0, const uint8_t val1,
+ const uint8_t val2, const uint8_t val3)
+{
+   uint8_t val[4];
+   val[0] = val0;
+   val[1] = val1;
+   val[2] = val2;
+   val[3] = val3;
+   ZSDA_CSR_WRITE32(addr, *(uint32_t *)val);
+   return *(uint32_t *)val;
+}
+
+uint8_t
+zsda_get_reg_8(void *addr, const int offset)
+{
+   uint32_t val = ZSDA_CSR_READ32(addr);
+
+   return *(((uint8_t *)&val) + offset);
+}
+
+int
+zsda_admin_msg_init(const struct rte_pci_device *pci_dev)
+{
+   uint8_t *mmio_base = pci_dev->mem_resource[0].addr;
+
+   zsda_set_reg_8(mmio_base + ZSDA_ADMIN_WQ_BASE7, 0, 0, MAGIC_RECV, 0);
+   zsda_set_reg_8(mmio_base + ZSDA_ADMIN_CQ_BASE7, 0, 0, MAGIC_RECV, 0);
+   return 0;
+}
+
+int
+zsda_send_admin_msg(const struct rte_pci_device *pci_dev, void *req,
+   const uint32_t len)
+{
+   uint8_t *mmio_base = pci_dev->mem_resource[0].addr;
+   uint8_t wq_flag;
+   uint8_t crc;
+   uint16_t admin_db;
+   uint32_t retry = ZSDA_TIME_NUM;
+   int i;
+   uint16_t db;
+   int repeat = sizeof(struct zsda_admin_req) / sizeof(uint32_t);
+
+   if (len > ADMIN_BUF_DATA_LEN)
+   return -EINVAL;
+
+   for (i = 0; i < repeat; i++) {
+   ZSDA_CSR_WRITE32(((uint3

Re: [PATCH v4 08/11] dts: add topology capability

2024-09-27 Thread Luca Vizzarro

Reviewed-by: Luca Vizzarro 


Re: [PATCH v4 10/11] dts: add Rx offload capabilities

2024-09-27 Thread Luca Vizzarro

Reviewed-by: Luca Vizzarro 


[PATCH v7 3/8] common/zsda: configure queues

2024-09-27 Thread Hanxiao Li
Add queue initialization, release, enqueue, dequeue and other interface.

Signed-off-by: Hanxiao Li 
---
 drivers/common/zsda/meson.build |   1 +
 drivers/common/zsda/zsda_qp.c   | 780 
 drivers/common/zsda/zsda_qp.h   | 159 +++
 3 files changed, 940 insertions(+)
 create mode 100644 drivers/common/zsda/zsda_qp.c
 create mode 100644 drivers/common/zsda/zsda_qp.h

diff --git a/drivers/common/zsda/meson.build b/drivers/common/zsda/meson.build
index 44f2375d8d..4d1eec8867 100644
--- a/drivers/common/zsda/meson.build
+++ b/drivers/common/zsda/meson.build
@@ -12,4 +12,5 @@ sources += files(
'zsda_common.c',
'zsda_logs.c',
'zsda_device.c',
+   'zsda_qp.c',
)
diff --git a/drivers/common/zsda/zsda_qp.c b/drivers/common/zsda/zsda_qp.c
new file mode 100644
index 00..fe49a391ec
--- /dev/null
+++ b/drivers/common/zsda/zsda_qp.c
@@ -0,0 +1,780 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#include 
+
+#include 
+
+#include "zsda_common.h"
+#include "zsda_logs.h"
+#include "zsda_device.h"
+#include "zsda_qp.h"
+
+#define RING_DIR_TX 0
+#define RING_DIR_RX 1
+
+struct ring_size {
+   uint16_t tx_msg_size;
+   uint16_t rx_msg_size;
+};
+
+struct ring_size zsda_qp_hw_ring_size[ZSDA_MAX_SERVICES] = {
+   [ZSDA_SERVICE_SYMMETRIC_ENCRYPT] = {128, 16},
+   [ZSDA_SERVICE_SYMMETRIC_DECRYPT] = {128, 16},
+   [ZSDA_SERVICE_COMPRESSION] = {32, 16},
+   [ZSDA_SERVICE_DECOMPRESSION] = {32, 16},
+   [ZSDA_SERVICE_HASH_ENCODE] = {32, 16},
+};
+
+static void
+zsda_set_queue_head_tail(const struct zsda_pci_device *zsda_pci_dev,
+const uint8_t qid)
+{
+   struct rte_pci_device *pci_dev =
+   zsda_devs[zsda_pci_dev->zsda_dev_id].pci_dev;
+   uint8_t *mmio_base = pci_dev->mem_resource[0].addr;
+
+   ZSDA_CSR_WRITE32(mmio_base + IO_DB_INITIAL_CONFIG + (qid * 4),
+SET_HEAD_INTI);
+}
+
+static int
+zsda_get_queue_cfg_by_id(const struct zsda_pci_device *zsda_pci_dev,
+const uint8_t qid, struct qinfo *qcfg)
+{
+   struct zsda_admin_req_qcfg req = {0};
+   struct zsda_admin_resp_qcfg resp = {0};
+   int ret = 0;
+   struct rte_pci_device *pci_dev =
+   zsda_devs[zsda_pci_dev->zsda_dev_id].pci_dev;
+
+   if (qid >= MAX_QPS_ON_FUNCTION) {
+   ZSDA_LOG(ERR, "qid beyond limit!");
+   return ZSDA_FAILED;
+   }
+
+   zsda_admin_msg_init(pci_dev);
+   req.msg_type = ZSDA_ADMIN_QUEUE_CFG_REQ;
+   req.qid = qid;
+
+   ret = zsda_send_admin_msg(pci_dev, &req, sizeof(req));
+   if (ret) {
+   ZSDA_LOG(ERR, "Failed! Send msg");
+   return ret;
+   }
+
+   ret = zsda_recv_admin_msg(pci_dev, &resp, sizeof(resp));
+   if (ret) {
+   ZSDA_LOG(ERR, "Failed! Receive msg");
+   return ret;
+   }
+
+   memcpy(qcfg, &resp.qcfg, sizeof(*qcfg));
+
+   return ZSDA_SUCCESS;
+}
+
+
+int
+zsda_get_queue_cfg(struct zsda_pci_device *zsda_pci_dev)
+{
+   uint8_t i;
+   uint32_t index;
+   enum zsda_service_type type;
+   struct zsda_qp_hw *zsda_hw_qps = zsda_pci_dev->zsda_hw_qps;
+   struct qinfo qcfg = {0};
+   int ret = 0;
+
+   for (i = 0; i < zsda_num_used_qps; i++) {
+   zsda_set_queue_head_tail(zsda_pci_dev, i);
+   ret = zsda_get_queue_cfg_by_id(zsda_pci_dev, i, &qcfg);
+   type = qcfg.q_type;
+   if (ret) {
+   ZSDA_LOG(ERR, "get queue cfg!");
+   return ret;
+   }
+   if (type >= ZSDA_SERVICE_INVALID)
+   continue;
+
+   index = zsda_pci_dev->zsda_qp_hw_num[type];
+   zsda_hw_qps[type].data[index].used = true;
+   zsda_hw_qps[type].data[index].tx_ring_num = i;
+   zsda_hw_qps[type].data[index].rx_ring_num = i;
+   zsda_hw_qps[type].data[index].tx_msg_size =
+   zsda_qp_hw_ring_size[type].tx_msg_size;
+   zsda_hw_qps[type].data[index].rx_msg_size =
+   zsda_qp_hw_ring_size[type].rx_msg_size;
+
+   zsda_pci_dev->zsda_qp_hw_num[type]++;
+   }
+
+   return ret;
+}
+
+struct zsda_qp_hw *
+zsda_qps_hw_per_service(struct zsda_pci_device *zsda_pci_dev,
+   const enum zsda_service_type service)
+{
+   struct zsda_qp_hw *qp_hw = NULL;
+
+   if (service < ZSDA_SERVICE_INVALID)
+   qp_hw = &(zsda_pci_dev->zsda_hw_qps[service]);
+
+   return qp_hw;
+}
+
+uint16_t
+zsda_qps_per_service(const struct zsda_pci_device *zsda_pci_dev,
+const enum zsda_service_type service)
+{
+   uint16_t qp_hw_num = 0;
+
+   if (service < ZSDA_SERVICE_INVALID)
+   qp_hw_num = zsda_pci_dev->zsda_qp_hw_

[PATCH v7 2/8] common/zsda: configure device

2024-09-27 Thread Hanxiao Li
Add support for zsdadev operations such as dev_start and dev_stop.

Signed-off-by: Hanxiao Li 
---
 config/rte_config.h   |   4 +
 drivers/common/zsda/meson.build   |   1 +
 drivers/common/zsda/zsda_device.c | 444 ++
 drivers/common/zsda/zsda_device.h | 117 
 4 files changed, 566 insertions(+)
 create mode 100644 drivers/common/zsda/zsda_device.c
 create mode 100644 drivers/common/zsda/zsda_device.h

diff --git a/config/rte_config.h b/config/rte_config.h
index dd7bb0d35b..e1e85b3291 100644
--- a/config/rte_config.h
+++ b/config/rte_config.h
@@ -117,6 +117,10 @@
 #define RTE_PMD_QAT_COMP_SGL_MAX_SEGMENTS 16
 #define RTE_PMD_QAT_COMP_IM_BUFFER_SIZE 65536
 
+/* ZSDA device */
+/* Max. number of ZSDA devices which can be attached */
+#define RTE_PMD_ZSDA_MAX_PCI_DEVICES 256
+
 /* virtio crypto defines */
 #define RTE_MAX_VIRTIO_CRYPTO 32
 
diff --git a/drivers/common/zsda/meson.build b/drivers/common/zsda/meson.build
index 8971289080..44f2375d8d 100644
--- a/drivers/common/zsda/meson.build
+++ b/drivers/common/zsda/meson.build
@@ -11,4 +11,5 @@ deps += ['bus_pci']
 sources += files(
'zsda_common.c',
'zsda_logs.c',
+   'zsda_device.c',
)
diff --git a/drivers/common/zsda/zsda_device.c 
b/drivers/common/zsda/zsda_device.c
new file mode 100644
index 00..4ddc97e564
--- /dev/null
+++ b/drivers/common/zsda/zsda_device.c
@@ -0,0 +1,444 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+
+#include 
+#include 
+
+#include "zsda_device.h"
+#include "zsda_qp.h"
+
+/* per-process array of device data */
+struct zsda_device_info zsda_devs[RTE_PMD_ZSDA_MAX_PCI_DEVICES];
+static int zsda_nb_pci_devices;
+uint8_t zsda_num_used_qps;
+
+/*
+ * The set of PCI devices this driver supports
+ */
+static const struct rte_pci_id pci_id_zsda_map[] = {
+   {
+   RTE_PCI_DEVICE(0x1cf2, 0x8050),
+   },
+   {
+   RTE_PCI_DEVICE(0x1cf2, 0x8051),
+   },
+   {.device_id = 0},
+};
+
+static int
+zsda_check_write(uint8_t *addr, const uint32_t dst_value)
+{
+   int times = ZSDA_TIME_NUM;
+   uint32_t val;
+
+   val = ZSDA_CSR_READ32(addr);
+
+   while ((val != dst_value) && times--) {
+   val = ZSDA_CSR_READ32(addr);
+   rte_delay_us_sleep(ZSDA_TIME_SLEEP_US);
+   }
+   if (val == dst_value)
+   return ZSDA_SUCCESS;
+   else
+   return ZSDA_FAILED;
+}
+
+static uint8_t
+zsda_get_num_used_qps(const struct rte_pci_device *pci_dev)
+{
+   uint8_t *mmio_base = pci_dev->mem_resource[0].addr;
+   uint8_t num_used_qps;
+
+   num_used_qps = ZSDA_CSR_READ8(mmio_base + 0);
+
+   return num_used_qps;
+}
+
+int
+zsda_admin_q_start(const struct rte_pci_device *pci_dev)
+{
+   uint8_t *mmio_base = pci_dev->mem_resource[0].addr;
+   int ret = 0;
+
+   ZSDA_CSR_WRITE32(mmio_base + ZSDA_ADMIN_Q_START, 0);
+
+   ZSDA_CSR_WRITE32(mmio_base + ZSDA_ADMIN_Q_START, ZSDA_Q_START);
+   ret = zsda_check_write(mmio_base + ZSDA_ADMIN_Q_START, ZSDA_Q_START);
+
+   return ret;
+}
+
+int
+zsda_admin_q_stop(const struct rte_pci_device *pci_dev)
+{
+   uint8_t *mmio_base = pci_dev->mem_resource[0].addr;
+   int ret = 0;
+
+   ZSDA_CSR_WRITE32(mmio_base + ZSDA_ADMIN_Q_STOP_RESP, ZSDA_RESP_INVALID);
+   ZSDA_CSR_WRITE32(mmio_base + ZSDA_ADMIN_Q_STOP, ZSDA_Q_STOP);
+
+   ret = zsda_check_write(mmio_base + ZSDA_ADMIN_Q_STOP_RESP,
+  ZSDA_RESP_VALID);
+
+   if (ret)
+   ZSDA_LOG(INFO, "Failed! zsda_admin q stop");
+
+   return ret;
+}
+
+int
+zsda_admin_q_clear(const struct rte_pci_device *pci_dev)
+{
+   uint8_t *mmio_base = pci_dev->mem_resource[0].addr;
+   int ret = 0;
+
+   ZSDA_CSR_WRITE32(mmio_base + ZSDA_ADMIN_Q_CLR_RESP, ZSDA_RESP_INVALID);
+   ZSDA_CSR_WRITE32(mmio_base + ZSDA_ADMIN_Q_CLR, ZSDA_RESP_VALID);
+
+   ret = zsda_check_write(mmio_base + ZSDA_ADMIN_Q_CLR_RESP,
+  ZSDA_RESP_VALID);
+
+   if (ret)
+   ZSDA_LOG(INFO, "Failed! zsda_admin q clear");
+
+   return ret;
+}
+
+static int
+zsda_queue_stop_single(uint8_t *mmio_base, const uint8_t id)
+{
+   int ret = 0;
+   uint8_t *addr_stop = mmio_base + ZSDA_IO_Q_STOP + (4 * id);
+   uint8_t *addr_resp = mmio_base + ZSDA_IO_Q_STOP_RESP + (4 * id);
+
+   ZSDA_CSR_WRITE32(addr_resp, ZSDA_RESP_INVALID);
+   ZSDA_CSR_WRITE32(addr_stop, ZSDA_Q_STOP);
+
+   ret = zsda_check_write(addr_resp, ZSDA_RESP_VALID);
+   ZSDA_CSR_WRITE32(addr_resp, ZSDA_RESP_INVALID);
+
+   return ret;
+}
+
+int
+zsda_queue_stop(const struct rte_pci_device *pci_dev)
+{
+   uint8_t *mmio_base = pci_dev->mem_resource[0].addr;
+   uint8_t id;
+   int ret = 0;
+
+   for (id = 0; id < zsda_num_used_qps; id++)
+   ret |= zsda_queue_stop_single(mmio_base, i

Re: [PATCH v4 07/11] dts: add NIC capabilities from show rxq info

2024-09-27 Thread Luca Vizzarro

Reviewed-by: Luca Vizzarro 


[PATCH v7 8/8] doc/guides: add documents and release notes for two drivers

2024-09-27 Thread Hanxiao Li
This patch adds documents and release notes
about compressdev and cryptodev.

Signed-off-by: Hanxiao Li 
---
 doc/guides/compressdevs/features/zsda.ini |  15 ++
 doc/guides/compressdevs/index.rst |   1 +
 doc/guides/compressdevs/zsda.rst  |  45 
 doc/guides/cryptodevs/features/zsda.ini   |  53 +
 doc/guides/cryptodevs/index.rst   |   1 +
 doc/guides/cryptodevs/zsda.rst| 260 ++
 doc/guides/rel_notes/release_24_11.rst|   8 +
 7 files changed, 383 insertions(+)
 create mode 100644 doc/guides/compressdevs/features/zsda.ini
 create mode 100644 doc/guides/compressdevs/zsda.rst
 create mode 100644 doc/guides/cryptodevs/features/zsda.ini
 create mode 100644 doc/guides/cryptodevs/zsda.rst

diff --git a/doc/guides/compressdevs/features/zsda.ini 
b/doc/guides/compressdevs/features/zsda.ini
new file mode 100644
index 00..3b087ea7f9
--- /dev/null
+++ b/doc/guides/compressdevs/features/zsda.ini
@@ -0,0 +1,15 @@
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+; Supported features of 'ZSDA' compression driver.
+;
+[Features]
+HW Accelerated = Y
+OOP SGL In SGL Out = Y
+OOP SGL In LB  Out = Y
+OOP LB  In SGL Out = Y
+Deflate= Y
+Adler32= Y
+Crc32  = Y
+Fixed  = Y
+Dynamic= Y
diff --git a/doc/guides/compressdevs/index.rst 
b/doc/guides/compressdevs/index.rst
index 87ed4f72a4..bab226ffbc 100644
--- a/doc/guides/compressdevs/index.rst
+++ b/doc/guides/compressdevs/index.rst
@@ -17,3 +17,4 @@ Compression Device Drivers
 qat_comp
 uadk
 zlib
+zsda
diff --git a/doc/guides/compressdevs/zsda.rst b/doc/guides/compressdevs/zsda.rst
new file mode 100644
index 00..2d0737e4ba
--- /dev/null
+++ b/doc/guides/compressdevs/zsda.rst
@@ -0,0 +1,45 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright(c) 2024 ZTE Corporation.
+
+ZTE Storage Data Accelerator (ZSDA) Poll Mode Driver
+===
+
+The ZSDA compression PMD provides poll mode compression & decompression driver
+support for the following hardware accelerator devices:
+
+* ``ZTE Processing accelerators 1cf2``
+
+
+Features
+
+
+ZSDA compression PMD has support for:
+
+Compression/Decompression algorithm:
+
+* DEFLATE - using Fixed and Dynamic Huffman encoding
+
+Checksum generation:
+
+* CRC32, Adler32
+
+Huffman code type:
+
+* FIXED
+* DYNAMIC
+
+
+Limitations
+---
+
+* Compressdev level 0, no compression, is not supported.
+* No BSD support as BSD ZSDA kernel driver not available.
+* Stateful is not supported.
+
+
+Installation
+
+
+The ZSDA compression PMD is built by default with a standard DPDK build.
+
+It depends on a ZSDA kernel driver, see :ref:`building_zsda`.
\ No newline at end of file
diff --git a/doc/guides/cryptodevs/features/zsda.ini 
b/doc/guides/cryptodevs/features/zsda.ini
new file mode 100644
index 00..efa33fbf3c
--- /dev/null
+++ b/doc/guides/cryptodevs/features/zsda.ini
@@ -0,0 +1,53 @@
+;
+; Supported features of the 'zsda' crypto driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Symmetric crypto   = Y
+HW Accelerated = Y
+Protocol offload   = Y
+In Place SGL   = Y
+OOP SGL In SGL Out = Y
+OOP SGL In LB  Out = Y
+OOP LB  In SGL Out = Y
+OOP LB  In LB  Out = Y
+Digest encrypted   = Y
+Sym raw data path API  = Y
+
+;
+; Supported crypto algorithms of the 'zsda' crypto driver.
+;
+[Cipher]
+NULL   = Y
+AES XTS (128)  = Y
+AES XTS (256)  = Y
+SM4 AES= Y
+;
+; Supported authentication algorithms of the 'zsda' crypto driver.
+;
+[Auth]
+NULL = Y
+SHA1 = Y
+SHA224   = Y
+SHA256   = Y
+SHA384   = Y
+SHA512   = Y
+SM3  = Y
+
+;
+; Supported AEAD algorithms of the 'zsda' crypto driver.
+;
+[AEAD]
+
+
+;
+; Supported Asymmetric algorithms of the 'zsda' crypto driver.
+;
+[Asymmetric]
+
+;
+; Supported Operating systems of the 'zsda' crypto driver.
+;
+[OS]
+Linux = Y
diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst
index 1e57a9fe86..be2620f185 100644
--- a/doc/guides/cryptodevs/index.rst
+++ b/doc/guides/cryptodevs/index.rst
@@ -34,3 +34,4 @@ Crypto Device Drivers
 uadk
 virtio
 zuc
+zsda
diff --git a/doc/guides/cryptodevs/zsda.rst b/doc/guides/cryptodevs/zsda.rst
new file mode 100644
index 00..fa6015182d
--- /dev/null
+++ b/doc/guides/cryptodevs/zsda.rst
@@ -0,0 +1,260 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+Copyright(c) 2024 ZTE Corporation.
+
+ZTE Storage Data Accelerator (ZSDA) Poll Mode Driver
+==
+
+ZSDA documentation consists of three parts:
+
+* Details of the symmetric crypto services below.
+* Details of the :doc:`compression service <../compressdevs/zsda>`
+  in the compressdev drivers 

Re: [PATCH v4 11/11] dts: add NIC capabilities from show port info

2024-09-27 Thread Luca Vizzarro

Reviewed-by: Luca Vizzarro 


  1   2   >