RE: [PATCH] kernel/freebsd: fix module build on FreeBSD 14

2023-12-22 Thread Gao, DaxueX
> -Original Message-
> From: Bruce Richardson 
> Sent: Tuesday, December 19, 2023 7:30 PM
> To: dev@dpdk.org
> Cc: Richardson, Bruce 
> Subject: [PATCH] kernel/freebsd: fix module build on FreeBSD 14
> 
> When building nic_uio module on FreeBSD 14, a build error is given in the
> DRIVER_MODULE macro:
> 
> .../nic_uio.c:84:81: error: too many arguments provided to function-like
> macro invocation DRIVER_MODULE(nic_uio, pci, nic_uio_driver,
> nic_uio_devclass, nic_uio_modevent, 0);
>   
>   ^ On FreeBSD 14, the devclass
> parameter is dropped from the macro, so we conditionally compile a different
> invocation for BSD versions before/ after v14.
> 
> Bugzilla Id: 1335
> 
> Signed-off-by: Bruce Richardson 
Tested-by: Daxue Gao 


Re: [PATCH v3] ethdev: fix getting supported ptypes list

2023-12-22 Thread David Marchand
On Thu, Dec 21, 2023 at 7:40 PM Sivaramakrishnan Venkat
 wrote:
>
> Incorrect ptypes list causes buffer overflow for Address Sanitizer
> run.Previously, the last element in the ptypes lists to be

Which driver(s) is(are) affected?
We need separated fixes for backporting.


> "RTE_PTYPE_UNKNOWN" for rte_eth_dev_get_supported_ptypes(), but this was
> not clearly documented and many PMDs did not follow this implementation.
> Instead, the dev_supported_ptypes_get() function pointer now returns the
> number of elements to eliminate the need for "RTE_PTYPE_UNKNOWN"
> as the last item.
>
> Fixes: 4790935 ("ethdev: make device operations struct private")

I doubt it is a correct Fixes: tag.

> Cc: ferruh.yi...@intel.com
> CC: sta...@dpdk.org

Once the fixes are separated, then the driver API update proposed in
this patch can be done in a second step (and it won't be backported).

The CI caught unconverted drivers, please fix.


-- 
David Marchand



[PATCH] common/idpf: refine get packet type

2023-12-22 Thread beilei . xing
From: Beilei Xing 

Since the response of virtual channel virtchnl2_get_ptype_info is
changed on IMC side, driver needs to be updated when requiring
the virtual channel.

Signed-off-by: Beilei Xing 
---
 drivers/common/idpf/idpf_common_device.c   | 64 ++
 drivers/common/idpf/idpf_common_device.h   |  9 +++
 drivers/common/idpf/idpf_common_virtchnl.c | 28 --
 drivers/common/idpf/idpf_common_virtchnl.h |  4 +-
 4 files changed, 63 insertions(+), 42 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_device.c 
b/drivers/common/idpf/idpf_common_device.c
index cc4207a46e..1380cc462c 100644
--- a/drivers/common/idpf/idpf_common_device.c
+++ b/drivers/common/idpf/idpf_common_device.c
@@ -157,49 +157,65 @@ idpf_init_mbx(struct idpf_hw *hw)
 static int
 idpf_get_pkt_type(struct idpf_adapter *adapter)
 {
-   struct virtchnl2_get_ptype_info *ptype_info;
+   struct virtchnl2_get_ptype_info *req_ptype_info;
+   struct virtchnl2_get_ptype_info *recv_ptype_info;
+   uint16_t recv_num_ptypes = 0;
uint16_t ptype_offset, i, j;
-   uint16_t ptype_recvd = 0;
+   uint16_t start_ptype_id = 0;
int ret;
 
-   ret = idpf_vc_ptype_info_query(adapter);
-   if (ret != 0) {
-   DRV_LOG(ERR, "Fail to query packet type information");
-   return ret;
+   req_ptype_info = rte_zmalloc("req_ptype_info", IDPF_DFLT_MBX_BUF_SIZE, 
0);
+   if (req_ptype_info == NULL)
+   return -ENOMEM;
+
+   recv_ptype_info = rte_zmalloc("recv_ptype_info", 
IDPF_DFLT_MBX_BUF_SIZE, 0);
+   if (recv_ptype_info == NULL) {
+   ret = -ENOMEM;
+   goto free_req_ptype_info;
}
 
-   ptype_info = rte_zmalloc("ptype_info", IDPF_DFLT_MBX_BUF_SIZE, 0);
-   if (ptype_info == NULL)
-   return -ENOMEM;
+   while (start_ptype_id < IDPF_MAX_PKT_TYPE) {
+   memset(req_ptype_info, 0, sizeof(*req_ptype_info));
+   memset(recv_ptype_info, 0, sizeof(*recv_ptype_info));
+
+   if ((start_ptype_id + IDPF_RX_MAX_PTYPES_PER_BUF) > 
IDPF_MAX_PKT_TYPE)
+   req_ptype_info->num_ptypes =
+   rte_cpu_to_le_16(IDPF_MAX_PKT_TYPE - 
start_ptype_id);
+   else
+   req_ptype_info->num_ptypes = 
rte_cpu_to_le_16(IDPF_RX_MAX_PTYPES_PER_BUF);
+   req_ptype_info->start_ptype_id = start_ptype_id;
 
-   while (ptype_recvd < IDPF_MAX_PKT_TYPE) {
-   ret = idpf_vc_one_msg_read(adapter, VIRTCHNL2_OP_GET_PTYPE_INFO,
-  IDPF_DFLT_MBX_BUF_SIZE, (uint8_t 
*)ptype_info);
+   ret = idpf_vc_ptype_info_query(adapter, req_ptype_info, 
recv_ptype_info);
if (ret != 0) {
-   DRV_LOG(ERR, "Fail to get packet type information");
-   goto free_ptype_info;
+   DRV_LOG(ERR, "Fail to query packet type information");
+   goto free_recv_ptype_info;
}
 
-   ptype_recvd += ptype_info->num_ptypes;
+   recv_num_ptypes += 
rte_cpu_to_le_16(recv_ptype_info->num_ptypes);
+   if (recv_num_ptypes > IDPF_MAX_PKT_TYPE) {
+   ret = -EINVAL;
+   goto free_recv_ptype_info;
+   }
+
+   start_ptype_id = 
rte_cpu_to_le_16(req_ptype_info->start_ptype_id) +
+   rte_cpu_to_le_16(req_ptype_info->num_ptypes);
+
ptype_offset = sizeof(struct virtchnl2_get_ptype_info) -
sizeof(struct virtchnl2_ptype);
 
-   for (i = 0; i < rte_cpu_to_le_16(ptype_info->num_ptypes); i++) {
+   for (i = 0; i < rte_cpu_to_le_16(recv_ptype_info->num_ptypes); 
i++) {
bool is_inner = false, is_ip = false;
struct virtchnl2_ptype *ptype;
uint32_t proto_hdr = 0;
 
ptype = (struct virtchnl2_ptype *)
-   ((uint8_t *)ptype_info + ptype_offset);
+   ((uint8_t *)recv_ptype_info + 
ptype_offset);
ptype_offset += IDPF_GET_PTYPE_SIZE(ptype);
if (ptype_offset > IDPF_DFLT_MBX_BUF_SIZE) {
ret = -EINVAL;
-   goto free_ptype_info;
+   goto free_recv_ptype_info;
}
 
-   if (rte_cpu_to_le_16(ptype->ptype_id_10) == 0x)
-   goto free_ptype_info;
-
for (j = 0; j < ptype->proto_id_count; j++) {
switch (rte_cpu_to_le_16(ptype->proto_id[j])) {
case VIRTCHNL2_PROTO_HDR_GRE:
@@ -358,8 +374,10 @@ idpf_get_pkt_type(struct idpf_adapter

Re: [PATCH v3 2/2] ip_frag: updated name for IP frag max frag define

2023-12-22 Thread Bruce Richardson
On Thu, Dec 21, 2023 at 05:41:40PM +, Euan Bourke wrote:
> Removed LIBRTE from name as its an old prefix.
> 
> Signed-off-by: Euan Bourke 
> ---
>  app/test/test_reassembly_perf.c  | 2 +-
>  config/rte_config.h  | 2 +-
>  doc/guides/prog_guide/ip_fragment_reassembly_lib.rst | 8 
>  doc/guides/sample_app_ug/ip_reassembly.rst   | 4 ++--
>  examples/ip_fragmentation/main.c | 2 +-
>  examples/ip_reassembly/main.c| 2 +-
>  examples/ipsec-secgw/ipsec_worker.h  | 2 +-
>  lib/ip_frag/ip_reassembly.h  | 2 +-
>  lib/ip_frag/rte_ip_frag.h| 2 +-
>  9 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/app/test/test_reassembly_perf.c b/app/test/test_reassembly_perf.c
> index 3912179022..805ae2fe9d 100644
> --- a/app/test/test_reassembly_perf.c
> +++ b/app/test/test_reassembly_perf.c
> @@ -20,7 +20,7 @@
>  #define MAX_FLOWS(1024 * 32)
>  #define MAX_BKTS MAX_FLOWS
>  #define MAX_ENTRIES_PER_BKT 16
> -#define MAX_FRAGMENTSRTE_LIBRTE_IP_FRAG_MAX_FRAG
> +#define MAX_FRAGMENTSRTE_IP_FRAG_MAX_FRAG
>  #define MIN_FRAGMENTS2
>  #define MAX_PKTS (MAX_FLOWS * MAX_FRAGMENTS)
>  
> diff --git a/config/rte_config.h b/config/rte_config.h
> index da265d7dd2..e2fa2a58fa 100644
> --- a/config/rte_config.h
> +++ b/config/rte_config.h
> @@ -85,7 +85,7 @@
>  #define RTE_RAWDEV_MAX_DEVS 64
>  
>  /* ip_fragmentation defines */
> -#define RTE_LIBRTE_IP_FRAG_MAX_FRAG 8
> +#define RTE_IP_FRAG_MAX_FRAG 8
>  // RTE_LIBRTE_IP_FRAG_TBL_STAT is not set
>  
>  /* rte_power defines */
> diff --git a/doc/guides/prog_guide/ip_fragment_reassembly_lib.rst 
> b/doc/guides/prog_guide/ip_fragment_reassembly_lib.rst
> index f3ed90d700..2d422309bb 100644
> --- a/doc/guides/prog_guide/ip_fragment_reassembly_lib.rst
> +++ b/doc/guides/prog_guide/ip_fragment_reassembly_lib.rst
> @@ -43,12 +43,12 @@ Note that all update/lookup operations on Fragment Table 
> are not thread safe.
>  So if different execution contexts (threads/processes) will access the same 
> table simultaneously,
>  then some external syncing mechanism have to be provided.
>  
> -Each table entry can hold information about packets of up to 
> ``RTE_LIBRTE_IP_FRAG_MAX_FRAG`` fragments,
> -where ``RTE_LIBRTE_IP_FRAG_MAX_FRAG`` defaults to:
> +Each table entry can hold information about packets of up to 
> ``RTE_IP_FRAG_MAX_FRAG`` fragments,
> +where ``RTE_IP_FRAG_MAX_FRAG`` defaults to:
>  
>  .. literalinclude:: ../../../config/rte_config.h
>  :language: c
> -:start-at: #define RTE_LIBRTE_IP_FRAG_MAX_FRAG
> +:start-at: #define RTE_IP_FRAG_MAX_FRAG
>  :lines: 1
>  
>  Code example, that demonstrates creation of a new Fragment table:
> @@ -69,7 +69,7 @@ Also, entries that resides in the table longer then 
>  are considered
>  and could be removed/replaced by the new ones.
>  
>  Note that reassembly demands a lot of mbuf's to be allocated.
> -At any given time up to (2 \* bucket_entries \* RTE_LIBRTE_IP_FRAG_MAX \* 
> )
> +At any given time up to (2 \* bucket_entries \* RTE_IP_FRAG_MAX \*  number of mbufs per packet>)

Should be RTE_IP_FRAG_MAX_FRAG. You should check all other replacements to
ensure the correct define name is being used. I see a couple of other
occurances in this patch where the name is wrong.

>  can be stored inside Fragment Table waiting for remaining fragments.
>  



[PATCH 0/2] net/cpfl: support flow offloading for P4

2023-12-22 Thread wenjing . qiao
From: Wenjing Qiao 

Enable TDI flow engine which can program hardware offloading rules
for a P4 programmable network controller.

Wenjing Qiao (2):
  net/cpfl: parse flow offloading hint from P4 context file
  net/cpfl: add TDI to flow engine

 doc/guides/nics/cpfl.rst|   10 +
 doc/guides/nics/features/cpfl.ini   |1 +
 drivers/net/cpfl/cpfl_ethdev.h  |   17 +-
 drivers/net/cpfl/cpfl_flow.c|   13 +-
 drivers/net/cpfl/cpfl_flow.h|1 +
 drivers/net/cpfl/cpfl_flow_engine_fxp.c |   21 +-
 drivers/net/cpfl/cpfl_flow_parser.c |   68 +-
 drivers/net/cpfl/cpfl_flow_parser.h |2 +-
 drivers/net/cpfl/cpfl_fxp_rule.h|   12 +
 drivers/net/cpfl/cpfl_tdi.c | 1244 
 drivers/net/cpfl/cpfl_tdi.h |  123 ++
 drivers/net/cpfl/cpfl_tdi_parser.c  | 1715 +++
 drivers/net/cpfl/cpfl_tdi_parser.h  |  293 
 drivers/net/cpfl/meson.build|2 +
 14 files changed, 3488 insertions(+), 34 deletions(-)
 create mode 100644 drivers/net/cpfl/cpfl_tdi.c
 create mode 100644 drivers/net/cpfl/cpfl_tdi.h
 create mode 100644 drivers/net/cpfl/cpfl_tdi_parser.c
 create mode 100644 drivers/net/cpfl/cpfl_tdi_parser.h

-- 
2.34.1



[PATCH 1/2] net/cpfl: parse flow offloading hint from P4 context file

2023-12-22 Thread wenjing . qiao
From: Wenjing Qiao 

To supporting P4-programmed network controller, reuse devargs
"flow_parser" to specify the path of a p4 context JSON configure
file. The cpfl PMD use the JSON configuration file to translate
rte_flow tokens into low level hardware representation.

Note, the p4 context JSON file is generated by the P4 compiler
and is intended to work exclusively with a specific P4 pipeline
configuration, which must be compiled and programmed into the hardware.

Signed-off-by: Wenjing Qiao 
---
 drivers/net/cpfl/cpfl_ethdev.h  |9 +-
 drivers/net/cpfl/cpfl_flow.c|   10 +-
 drivers/net/cpfl/cpfl_flow_engine_fxp.c |9 +-
 drivers/net/cpfl/cpfl_flow_parser.c |   60 +-
 drivers/net/cpfl/cpfl_flow_parser.h |2 +-
 drivers/net/cpfl/cpfl_tdi_parser.c  | 1715 +++
 drivers/net/cpfl/cpfl_tdi_parser.h  |  293 
 drivers/net/cpfl/meson.build|1 +
 8 files changed, 2077 insertions(+), 22 deletions(-)
 create mode 100644 drivers/net/cpfl/cpfl_tdi_parser.c
 create mode 100644 drivers/net/cpfl/cpfl_tdi_parser.h

diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
index 457db6d6be..e580f80f2f 100644
--- a/drivers/net/cpfl/cpfl_ethdev.h
+++ b/drivers/net/cpfl/cpfl_ethdev.h
@@ -185,6 +185,12 @@ struct cpfl_repr {
bool func_up; /* If the represented function is up */
 };
 
+struct cpfl_flow_parser {
+   struct cpfl_flow_js_parser *fixed_parser;
+   struct cpfl_tdi_program *p4_parser;
+   bool is_p4_parser;
+};
+
 struct cpfl_metadata_chunk {
int type;
uint8_t data[CPFL_META_CHUNK_LENGTH];
@@ -218,8 +224,7 @@ struct cpfl_adapter_ext {
 
rte_spinlock_t repr_lock;
struct rte_hash *repr_allowlist_hash;
-
-   struct cpfl_flow_js_parser *flow_parser;
+   struct cpfl_flow_parser flow_parser;
struct rte_bitmap *mod_bm;
void *mod_bm_mem;
 
diff --git a/drivers/net/cpfl/cpfl_flow.c b/drivers/net/cpfl/cpfl_flow.c
index 3ba6c0f0e7..1c4131da2c 100644
--- a/drivers/net/cpfl/cpfl_flow.c
+++ b/drivers/net/cpfl/cpfl_flow.c
@@ -6,6 +6,7 @@
 
 #include "cpfl_flow.h"
 #include "cpfl_flow_parser.h"
+#include "cpfl_tdi_parser.h"
 
 TAILQ_HEAD(cpfl_flow_engine_list, cpfl_flow_engine);
 
@@ -331,9 +332,14 @@ cpfl_flow_init(struct cpfl_adapter_ext *ad, struct 
cpfl_devargs *devargs)
 void
 cpfl_flow_uninit(struct cpfl_adapter_ext *ad)
 {
-   if (ad->flow_parser == NULL)
+   if (ad->flow_parser.fixed_parser == NULL && ad->flow_parser.p4_parser 
== NULL)
return;
 
-   cpfl_parser_destroy(ad->flow_parser);
+   if (ad->flow_parser.fixed_parser)
+   cpfl_parser_destroy(ad->flow_parser.fixed_parser);
+
+   if (ad->flow_parser.p4_parser)
+   cpfl_tdi_program_destroy(ad->flow_parser.p4_parser);
+
cpfl_flow_engine_uninit(ad);
 }
diff --git a/drivers/net/cpfl/cpfl_flow_engine_fxp.c 
b/drivers/net/cpfl/cpfl_flow_engine_fxp.c
index 8a4e1419b4..f269ff97e1 100644
--- a/drivers/net/cpfl/cpfl_flow_engine_fxp.c
+++ b/drivers/net/cpfl/cpfl_flow_engine_fxp.c
@@ -503,20 +503,25 @@ cpfl_fxp_parse_pattern_action(struct rte_eth_dev *dev,
struct cpfl_rule_info_meta *rim;
int ret;
 
+   if (adapter->flow_parser.is_p4_parser)
+   return -EINVAL;
+
ret = cpfl_fxp_get_metadata_port(itf, actions);
if (!ret) {
PMD_DRV_LOG(ERR, "Fail to save metadata.");
return -EINVAL;
}
 
-   ret = cpfl_flow_parse_items(itf, adapter->flow_parser, pattern, attr, 
&pr_action);
+   ret = cpfl_flow_parse_items(itf, adapter->flow_parser.fixed_parser, 
pattern, attr,
+   &pr_action);
if (ret) {
PMD_DRV_LOG(ERR, "No Match pattern support.");
return -EINVAL;
}
 
if (cpfl_is_mod_action(actions)) {
-   ret = cpfl_flow_parse_actions(adapter->flow_parser, actions, 
mr_action);
+   ret = cpfl_flow_parse_actions(adapter->flow_parser.fixed_parser,
+ actions, mr_action);
if (ret) {
PMD_DRV_LOG(ERR, "action parse fails.");
return -EINVAL;
diff --git a/drivers/net/cpfl/cpfl_flow_parser.c 
b/drivers/net/cpfl/cpfl_flow_parser.c
index a8f0488f21..e7f8a8a6cc 100644
--- a/drivers/net/cpfl/cpfl_flow_parser.c
+++ b/drivers/net/cpfl/cpfl_flow_parser.c
@@ -5,6 +5,7 @@
 #include 
 
 #include "cpfl_flow_parser.h"
+#include "cpfl_tdi_parser.h"
 
 static enum rte_flow_item_type
 cpfl_get_item_type_by_str(const char *type)
@@ -938,36 +939,65 @@ cpfl_parser_init(json_t *ob_root, struct 
cpfl_flow_js_parser *parser)
return 0;
 }
 
+static int
+cpfl_check_is_p4_mode(json_t *ob_root)
+{
+   return json_object_get(ob_root, "patterns") ? false : true;
+}
+
 int
-cpfl_parser_create(struct cpfl_flow_js_parser **flow_parser, const char 
*filename)
+cpfl_parser_crea

[PATCH 2/2] net/cpfl: add TDI to flow engine

2023-12-22 Thread wenjing . qiao
From: Wenjing Qiao 

Add TDI implementation to a flow engine.

Signed-off-by: Wenjing Qiao 
---
 doc/guides/nics/cpfl.rst|   10 +
 doc/guides/nics/features/cpfl.ini   |1 +
 drivers/net/cpfl/cpfl_ethdev.h  |8 +
 drivers/net/cpfl/cpfl_flow.c|5 +-
 drivers/net/cpfl/cpfl_flow.h|1 +
 drivers/net/cpfl/cpfl_flow_engine_fxp.c |   12 -
 drivers/net/cpfl/cpfl_flow_parser.c |8 +
 drivers/net/cpfl/cpfl_fxp_rule.h|   12 +
 drivers/net/cpfl/cpfl_tdi.c | 1244 +++
 drivers/net/cpfl/cpfl_tdi.h |  123 +++
 drivers/net/cpfl/meson.build|1 +
 11 files changed, 1412 insertions(+), 13 deletions(-)
 create mode 100644 drivers/net/cpfl/cpfl_tdi.c
 create mode 100644 drivers/net/cpfl/cpfl_tdi.h

diff --git a/doc/guides/nics/cpfl.rst b/doc/guides/nics/cpfl.rst
index 9b7a99c894..591bd496e6 100644
--- a/doc/guides/nics/cpfl.rst
+++ b/doc/guides/nics/cpfl.rst
@@ -213,6 +213,16 @@ low level hardware resources.
   flow create X ingress group M pattern eth dst is 00:01:00:00:03:14 / 
ipv4 src is 192.168.0.1 \
   dst is 192.168.0.2 / tcp / end actions port_representor port_id Y / end
 
+#. Create one flow for TDI engine to forward ETH-IPV4-TCP from I/O port to a 
local(CPF's) vport. Flow should
+   be created on vport X. Group M should be table id. Prog name N should be 
action id. Prog arguments
+   port_representor Y means forward packet to local vport Y::
+
+   .. code-block:: console
+
+  flow create X ingress group M pattern prog key is 0x00 / prog key is 
0x00010314 / prog key
+  is 0x001122334455 / prog key is 0xC0A80001 / prog key is 0xC0A80002 / 
prog key is 0x1451 / prog key
+  is 0x157C / end actions prog name N arguments port_representor Y  end / 
end
+
 #. Send a matched packet, and it should be displayed on PMD::
 
.. code-block:: console
diff --git a/doc/guides/nics/features/cpfl.ini 
b/doc/guides/nics/features/cpfl.ini
index 4eadaca6e7..85b8011a54 100644
--- a/doc/guides/nics/features/cpfl.ini
+++ b/doc/guides/nics/features/cpfl.ini
@@ -33,6 +33,7 @@ tcp  = Y
 udp  = Y
 vlan = Y
 vxlan= Y
+flex = Y
 
 [rte_flow actions]
 count= Y
diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
index e580f80f2f..7dfa4a0183 100644
--- a/drivers/net/cpfl/cpfl_ethdev.h
+++ b/drivers/net/cpfl/cpfl_ethdev.h
@@ -185,10 +185,18 @@ struct cpfl_repr {
bool func_up; /* If the represented function is up */
 };
 
+struct cpfl_tdi_table_node;
+TAILQ_HEAD(cpfl_tdi_table_list, cpfl_tdi_table_node);
+
+struct cpfl_tdi_action_node;
+TAILQ_HEAD(cpfl_tdi_action_list, cpfl_tdi_action_node);
+
 struct cpfl_flow_parser {
struct cpfl_flow_js_parser *fixed_parser;
struct cpfl_tdi_program *p4_parser;
bool is_p4_parser;
+   struct cpfl_tdi_table_list tdi_table_list;
+   struct cpfl_tdi_action_list tdi_action_list;
 };
 
 struct cpfl_metadata_chunk {
diff --git a/drivers/net/cpfl/cpfl_flow.c b/drivers/net/cpfl/cpfl_flow.c
index 1c4131da2c..15c7cc6d8b 100644
--- a/drivers/net/cpfl/cpfl_flow.c
+++ b/drivers/net/cpfl/cpfl_flow.c
@@ -6,6 +6,7 @@
 
 #include "cpfl_flow.h"
 #include "cpfl_flow_parser.h"
+#include "cpfl_tdi.h"
 #include "cpfl_tdi_parser.h"
 
 TAILQ_HEAD(cpfl_flow_engine_list, cpfl_flow_engine);
@@ -338,8 +339,10 @@ cpfl_flow_uninit(struct cpfl_adapter_ext *ad)
if (ad->flow_parser.fixed_parser)
cpfl_parser_destroy(ad->flow_parser.fixed_parser);
 
-   if (ad->flow_parser.p4_parser)
+   if (ad->flow_parser.p4_parser) {
+   cpfl_tdi_free_table_list(&ad->flow_parser);
cpfl_tdi_program_destroy(ad->flow_parser.p4_parser);
+   }
 
cpfl_flow_engine_uninit(ad);
 }
diff --git a/drivers/net/cpfl/cpfl_flow.h b/drivers/net/cpfl/cpfl_flow.h
index 1bde847763..1de9c25b17 100644
--- a/drivers/net/cpfl/cpfl_flow.h
+++ b/drivers/net/cpfl/cpfl_flow.h
@@ -15,6 +15,7 @@ extern const struct rte_flow_ops cpfl_flow_ops;
 enum cpfl_flow_engine_type {
CPFL_FLOW_ENGINE_NONE = 0,
CPFL_FLOW_ENGINE_FXP,
+   CPFL_FLOW_ENGINE_TDI,
 };
 
 typedef int (*engine_init_t)(struct cpfl_adapter_ext *ad);
diff --git a/drivers/net/cpfl/cpfl_flow_engine_fxp.c 
b/drivers/net/cpfl/cpfl_flow_engine_fxp.c
index f269ff97e1..6a5e7ed770 100644
--- a/drivers/net/cpfl/cpfl_flow_engine_fxp.c
+++ b/drivers/net/cpfl/cpfl_flow_engine_fxp.c
@@ -27,23 +27,11 @@
 #include "cpfl_fxp_rule.h"
 #include "cpfl_flow_parser.h"
 
-#define CPFL_COOKIE_DEF0x1000
-#define CPFL_MOD_COOKIE_DEF0x1237561
 #define CPFL_PREC_DEF  1
 #define CPFL_PREC_SET  5
 #define CPFL_TYPE_ID   3
 #define CPFL_OFFSET0x0a
-#define CPFL_HOST_ID_DEF   0
 #define CPFL_PF_NUM_DEF0
-#define CPFL_PORT_NUM_DEF  0
-#define CPFL_RESP_REQ_DEF  2
-#define CP

[PATCH v2] net/iavf: add diagnostic support in TX path

2023-12-22 Thread Mingjin Ye
The only way to enable diagnostics for TX paths is to modify the
application source code. Making it difficult to diagnose faults.

In this patch, the devarg option "mbuf_check" is introduced and the
parameters are configured to enable the corresponding diagnostics.

supported cases: mbuf, size, segment, offload, strict.
 1. mbuf: check for corrupted mbuf.
 2. size: check min/max packet length according to hw spec.
 3. segment: check number of mbuf segments not exceed hw limitation.
 4. offload: check any unsupported offload flag.
 5. strict: check protocol headers.

parameter format: mbuf_check=[mbuf,,]
eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i

Signed-off-by: Mingjin Ye 
---
v2: Remove call chain.
---
 drivers/net/iavf/iavf.h|  25 -
 drivers/net/iavf/iavf_ethdev.c |  69 
 drivers/net/iavf/iavf_rxtx.c   | 186 ++---
 drivers/net/iavf/iavf_rxtx.h   |   6 ++
 4 files changed, 246 insertions(+), 40 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 10868f2c30..ab80388422 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -113,9 +113,14 @@ struct iavf_ipsec_crypto_stats {
} ierrors;
 };
 
+struct iavf_mdd_stats {
+   uint64_t tx_pkt_errors;
+};
+
 struct iavf_eth_xstats {
struct virtchnl_eth_stats eth_stats;
struct iavf_ipsec_crypto_stats ips_stats;
+   struct iavf_mdd_stats mdd_stats;
 };
 
 /* Structure that defines a VSI, associated with a adapter. */
@@ -309,10 +314,27 @@ struct iavf_devargs {
uint32_t watchdog_period;
int auto_reset;
int no_poll_on_link_down;
+   int mbuf_check;
 };
 
 struct iavf_security_ctx;
 
+struct iavf_rx_burst_elem {
+   TAILQ_ENTRY(iavf_rx_burst_elem) next;
+   eth_rx_burst_t rx_pkt_burst;
+};
+
+struct iavf_tx_burst_elem {
+   TAILQ_ENTRY(iavf_tx_burst_elem) next;
+   eth_tx_burst_t tx_pkt_burst;
+};
+
+#define IAVF_MDD_CHECK_F_TX_MBUF(1ULL << 0)
+#define IAVF_MDD_CHECK_F_TX_SIZE(1ULL << 1)
+#define IAVF_MDD_CHECK_F_TX_SEGMENT (1ULL << 2)
+#define IAVF_MDD_CHECK_F_TX_OFFLOAD (1ULL << 3)
+#define IAVF_MDD_CHECK_F_TX_STRICT  (1ULL << 4)
+
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
struct iavf_hw hw;
@@ -328,8 +350,7 @@ struct iavf_adapter {
bool stopped;
bool closed;
bool no_poll;
-   eth_rx_burst_t rx_pkt_burst;
-   eth_tx_burst_t tx_pkt_burst;
+   uint64_t mc_flags; /* mdd check flags. */
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
 };
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d1edb0dd5c..6f4dd54602 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -39,6 +39,8 @@
 #define IAVF_RESET_WATCHDOG_ARG"watchdog_period"
 #define IAVF_ENABLE_AUTO_RESET_ARG "auto_reset"
 #define IAVF_NO_POLL_ON_LINK_DOWN_ARG "no-poll-on-link-down"
+#define IAVF_MDD_CHECK_ARG   "mbuf_check"
+
 uint64_t iavf_timestamp_dynflag;
 int iavf_timestamp_dynfield_offset = -1;
 
@@ -48,6 +50,7 @@ static const char * const iavf_valid_args[] = {
IAVF_RESET_WATCHDOG_ARG,
IAVF_ENABLE_AUTO_RESET_ARG,
IAVF_NO_POLL_ON_LINK_DOWN_ARG,
+   IAVF_MDD_CHECK_ARG,
NULL
 };
 
@@ -174,6 +177,7 @@ static const struct rte_iavf_xstats_name_off 
rte_iavf_stats_strings[] = {
{"tx_broadcast_packets", _OFF_OF(eth_stats.tx_broadcast)},
{"tx_dropped_packets", _OFF_OF(eth_stats.tx_discards)},
{"tx_error_packets", _OFF_OF(eth_stats.tx_errors)},
+   {"tx_mdd_error_packets", _OFF_OF(mdd_stats.tx_pkt_errors)},
 
{"inline_ipsec_crypto_ipackets", _OFF_OF(ips_stats.icount)},
{"inline_ipsec_crypto_ibytes", _OFF_OF(ips_stats.ibytes)},
@@ -1881,6 +1885,8 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
 {
int ret;
unsigned int i;
+   struct iavf_tx_queue *txq;
+   uint64_t mdd_pkt_errors = 0;
struct iavf_adapter *adapter =
IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
@@ -1904,6 +1910,15 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev,
if (iavf_ipsec_crypto_supported(adapter))
iavf_dev_update_ipsec_xstats(dev, &iavf_xtats.ips_stats);
 
+   if (adapter->devargs.mbuf_check) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   mdd_pkt_errors += __atomic_load_n(&txq->mdd_pkt_errors,
+   __ATOMIC_RELAXED);
+   }
+   iavf_xtats.mdd_stats.tx_pkt_errors = mdd_pkt_errors;
+   }
+
/* loop over xstats array and values from pstats */
for (i = 0; i < IAVF_NB_XSTATS; i++) {
xstats[i].id = i;
@@ -2286,6 +2301,52 @@ iavf_par

[v7 1/1] net/af_xdp: fix multi interface support for K8s

2023-12-22 Thread Maryam Tahhan
The original 'use_cni' implementation, was added
to enable support for the AF_XDP PMD in a K8s env
without any escalated privileges.
However 'use_cni' used a hardcoded socket rather
than a configurable one. If a DPDK pod is requesting
multiple net devices and these devices are from
different pools, then the AF_XDP PMD attempts to
mount all the netdev UDSes in the pod as /tmp/afxdp.sock.
Which means that at best only 1 netdev will handshake
correctly with the AF_XDP DP. This patch addresses
this by making the socket parameter configurable using
a new vdev param called 'uds_path' and removing the
previous 'use_cni' param. This change has been tested
with the AF_XDP DP PR 81[1], with both single and
multiple interfaces. This patch also renames the
af_xdp_cni.rst doc to af_xdp_dp.rst and changes
incorrect references to the DP as CNI. Lastly,
this patch adds this feature to the release notes.

[1] https://github.com/intel/afxdp-plugins-for-kubernetes/pull/81

Signed-off-by: Maryam Tahhan 
Reviewed-by: Ciara Loftus 
Reviewed-by: Shibin Koikkara Reeny 
---
v7:
* Give a more descriptive commit msg headline.
* Fixup typos in documentation.

v6:
* Add link to PR 81 in commit message
* Add release notes changes to this patchset

v5:
* Fix alignment for ETH_AF_XDP_USE_DP_UDS_PATH_ARG
* Remove use_cni references in af_xdp.rst

v4:
* Rename af_xdp_cni.rst to af_xdp_dp.rst
* Removed all incorrect references to CNI throughout af_xdp
  PMD file.
* Fixed Typos in af_xdp_dp.rst

v3:
* Remove `use_cni` vdev argument as it's no longer needed.
* Update incorrect CNI references for the AF_XDP DP in the
  documentation.
* Update the documentation to run a simple example with the
  AF_XDP DP plugin in K8s.

v2:
* Rename sock_path to uds_path.
* Update documentation to reflect when CAP_BPF is needed.
* Fix testpmd arguments in the provided example for Pods.
* Use AF_XDP API to update the xskmap entry.
---
 doc/guides/howto/af_xdp_cni.rst| 253 --
 doc/guides/howto/af_xdp_dp.rst | 281 +
 doc/guides/howto/index.rst |   2 +-
 doc/guides/nics/af_xdp.rst |  27 ++-
 doc/guides/rel_notes/release_24_03.rst |   8 +
 drivers/net/af_xdp/rte_eth_af_xdp.c| 100 +
 6 files changed, 356 insertions(+), 315 deletions(-)
 delete mode 100644 doc/guides/howto/af_xdp_cni.rst
 create mode 100644 doc/guides/howto/af_xdp_dp.rst

diff --git a/doc/guides/howto/af_xdp_cni.rst b/doc/guides/howto/af_xdp_cni.rst
deleted file mode 100644
index a1a6d5b99c..00
--- a/doc/guides/howto/af_xdp_cni.rst
+++ /dev/null
@@ -1,253 +0,0 @@
-.. SPDX-License-Identifier: BSD-3-Clause
-   Copyright(c) 2023 Intel Corporation.
-
-Using a CNI with the AF_XDP driver
-==
-
-Introduction
-
-
-CNI, the Container Network Interface, is a technology for configuring
-container network interfaces
-and which can be used to setup Kubernetes networking.
-AF_XDP is a Linux socket Address Family that enables an XDP program
-to redirect packets to a memory buffer in userspace.
-
-This document explains how to enable the `AF_XDP Plugin for Kubernetes`_ within
-a DPDK application using the :doc:`../nics/af_xdp` to connect and use these 
technologies.
-
-.. _AF_XDP Plugin for Kubernetes: 
https://github.com/intel/afxdp-plugins-for-kubernetes
-
-
-Background
---
-
-The standard :doc:`../nics/af_xdp` initialization process involves loading an 
eBPF program
-onto the kernel netdev to be used by the PMD.
-This operation requires root or escalated Linux privileges
-and thus prevents the PMD from working in an unprivileged container.
-The AF_XDP CNI plugin handles this situation
-by providing a device plugin that performs the program loading.
-
-At a technical level the CNI opens a Unix Domain Socket and listens for a 
client
-to make requests over that socket.
-A DPDK application acting as a client connects and initiates a configuration 
"handshake".
-The client then receives a file descriptor which points to the XSKMAP
-associated with the loaded eBPF program.
-The XSKMAP is a BPF map of AF_XDP sockets (XSK).
-The client can then proceed with creating an AF_XDP socket
-and inserting that socket into the XSKMAP pointed to by the descriptor.
-
-The EAL vdev argument ``use_cni`` is used to indicate that the user wishes
-to run the PMD in unprivileged mode and to receive the XSKMAP file descriptor
-from the CNI.
-When this flag is set,
-the ``XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD`` libbpf flag
-should be used when creating the socket
-to instruct libbpf not to load the default libbpf program on the netdev.
-Instead the loading is handled by the CNI.
-
-.. note::
-
-   The Unix Domain Socket file path appear in the end user is 
"/tmp/afxdp.sock".
-
-
-Prerequisites
--
-
-Docker and container prerequisites:
-
-* Set up the device plugin
-  as described in the instructions for `AF_XDP Plugin for Kubernetes`_.
-
-* The Docker image should contain the

[PATCH 0/4] add VFIO IOMMUFD/CDEV support

2023-12-22 Thread beilei . xing
From: Beilei Xing 

This is a draft implementation to support IOMMUFD[1] user interface and VFIO
CDEV user interface[2].

Problem statement:
Linux now includes multiple device-passthrough frameworks (e.g. VFIO and vDPA)
and those frameworks implement their own logic for managing I/O page tables,
which is hard to scale to support modern IOMMU features like PASID, I/O page
fault, IOMMU dirty page tracking, etc.

In order to fix the issue, a new standalone IOMMU subsystem called IOMMUFD is
introduced in Linux Kernel since v6.2. The goal is to make Linux subsystems like
VFIO and vDPA to consume a unified IOMMU framework. Along with this new IOMMUFD
framework, new device-centric VFIO uAPI called VFIO CDEV is also introduced
since Linux Kernel v6.6. vDPA support for IOMMUFD in Linux Kernel is still work
in progress[3].

Since all new IOMMU features provided by different vendors will only be 
supported
in the new framework instead of legacy one, it's important for DPDK to support
this new IOMMUFD framework to use latest IOMMU features.

For VFIO subsystem, mainline Linux supports both of VFIO Container/GROUP 
interface
and VFIO IOMMUFD/CDEV interface. IOMMUFD has no impact on the existing VFIO
Container/Group interface, while latest IOMMU feature(e.g. PASID/SSID) may be 
only
available through VFIO IOMMUFD/CDEV interface. Comparing with VFIO Container and
VFIO IOMMUFD, vfio device uAPI does not change while I/O page tables management 
is
moved from VFIO Container into IOMMUFD interface.

Design:
For DPDK implementation, since VFIO Container/GROUP & VFIO IOMMUFD/CDEV may 
co-exist
now, a new VFIO IOMMUFD file/interface will be added in EAL. Since IOMMUFD is a
unified framework which can be consumed by VFIO, vDPA, etc, iommufd will be 
added
as a standalone file/interface in EAL. Hence, DPDK bus driver (e.g. PCI) has 2
option to probe vfio device.

The diagram below shows relationship between VFIO Container/GROUP, IOMMUFD, VFIO
CDEV and bus driver (e.g. PCI) in DPDK with some comments below.

 _
|[4]  |
| |
| |
|PCI BUS  |
|_|
| |
| |
v___   ___v__  

   |   [1]  | |   [2]|| 
   |
   |vfio container  | |  || 
   |
   |vfio group  | |vfio cdev ||   Other Consumer
   |
   || |  ||   (vDPA IOMMUFD,
   |
   |VFIO| |VFIO IOMMUFD(new) ||common memory)   
   |
   || |__|
||
|  |
|  |
 ___v__v___
|[3]   |
| i/o page table mgmt  |
|  |
|  |
|IOMMUFD(new)  |
|__|

1. VFIO component is the existed and mature framework for device passthrough. No
   function changes here.
2. VFIO IOMMUFD is a new component added to co-work with IOMMUFD. It exposes 
function
   for PCI BUS to probe PCI device through VFIO CDEV interface.
3. IOMMUFD is a new component added. It exposes unified interface for VFIO 
IOMMUFD
   and other consumer to manage I/O page table.
4. PCI BUS is the existed component. Since now Linux has both of VFIO 
Container/GROUP
   & VFIO IOMMUFD/CDEV support, PCI BUS needs to determine the interface to 
probe the
   PCI device depending on user configuration.

TBD:
Multi-process will be supported in future.

[1] https://lwn.net/Articles/912515/
[2] 
https://patchwork.kernel.org/project/kvm/cover/20230718135551.6592-1-yi.l@intel.com/
[3] https://lore.kernel.org/lkml/20231103171641.1703146-1-l...@redhat.com/

Beilei Xing (3):
  vfio: add VFIO IOMMUFD support
  bus/pci: add VFIO CDEV support
  eal: add new args to choose VFIO mode

Yahui Cao (1):
  iommufd: add IOMMUFD support

 config/meson.build  |   3 +
 config/rte_config.h |   1 +
 drivers/bus/pci/bus_pci_driver.h|   1 +
 drivers/bus/pci/linux/pci.c |  21 +-
 drivers/bus/pci/linux/pci_init.h|   4 +
 drivers/bus/pci/linux/pci_vfio.c|  52 +++-
 lib/eal/common/eal_common_config.c  |   6 +
 lib/eal/common/eal_common_options.c |  48 +++-
 lib/eal/common/e

[PATCH 1/4] iommufd: add IOMMUFD support

2023-12-22 Thread beilei . xing
From: Yahui Cao 

IOMMUFD is a new standalone IOMMU subsystem introduced in Linux.

Linux now includes multiple device-passthrough frameworks (e.g. VFIO and
vDPA) and those frameworks implements their own logic for managing I/O
page tables, which is hard to scale to support modern IOMMU features like
PASID, I/O page fault, IOMMU dirty page tracking. The goal of IOMMUFD is
to make Linux subsystems like VFIO and vDPA to consume a unified IOMMU
framework.

This patch exports basic enable function, default isolation domain and
per-IOMMUFD dma mapping function. The IOMMUFD consumer should use the
default isolation domain and dma mapping function when user-initiated
DMA is required.

Signed-off-by: Yahui Cao 
Signed-off-by: Beilei Xing 
---
 config/meson.build|   3 +
 config/rte_config.h   |   1 +
 lib/eal/include/rte_iommufd.h |  73 ++
 lib/eal/linux/eal.c   |  22 
 lib/eal/linux/eal_iommufd.c   | 183 ++
 lib/eal/linux/eal_iommufd.h   |  43 
 lib/eal/linux/meson.build |   1 +
 lib/eal/version.map   |   3 +
 8 files changed, 329 insertions(+)
 create mode 100644 lib/eal/include/rte_iommufd.h
 create mode 100644 lib/eal/linux/eal_iommufd.c
 create mode 100644 lib/eal/linux/eal_iommufd.h

diff --git a/config/meson.build b/config/meson.build
index a9ccd56deb..93c63984c8 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -442,6 +442,9 @@ install_headers(['rte_config.h'],
 # enable VFIO only if it is linux OS
 dpdk_conf.set('RTE_EAL_VFIO', is_linux)
 
+# enable IOMMUFD only if it is linux OS
+dpdk_conf.set('RTE_EAL_IOMMUFD', is_linux)
+
 # specify -D_GNU_SOURCE unconditionally
 add_project_arguments('-D_GNU_SOURCE', language: 'c')
 
diff --git a/config/rte_config.h b/config/rte_config.h
index da265d7dd2..25a6dccd8f 100644
--- a/config/rte_config.h
+++ b/config/rte_config.h
@@ -38,6 +38,7 @@
 #define RTE_MAX_TAILQ 32
 #define RTE_LOG_DP_LEVEL RTE_LOG_INFO
 #define RTE_MAX_VFIO_CONTAINERS 64
+#define RTE_MAX_IOMMUFD_FD 1
 
 /* bsd module defines */
 #define RTE_CONTIGMEM_MAX_NUM_BUFS 64
diff --git a/lib/eal/include/rte_iommufd.h b/lib/eal/include/rte_iommufd.h
new file mode 100644
index 00..ac42713018
--- /dev/null
+++ b/lib/eal/include/rte_iommufd.h
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Intel Corporation
+ */
+
+#ifndef _RTE_IOMMUFD_H_
+#define _RTE_IOMMUFD_H_
+
+/**
+ * @file
+ * RTE IOMMUFD. This library provides various IOMMUFD related utility 
functions.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+#include 
+/*
+ * determine if IOMMUFD is present on the system
+ */
+#if !defined(IOMMUFD_PRESENT) && defined(RTE_EAL_IOMMUFD)
+#include 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
+#define IOMMUFD_PRESENT
+#endif /* kernel version >= 6.6.0 */
+#endif /* RTE_EAL_IOMMUFD */
+
+#ifdef IOMMUFD_PRESENT
+
+#define IOMMUFD_PATH "/dev/iommu"
+
+#else /* not IOMMUFD_PRESENT */
+#endif /* IOMMUFD_PRESENT */
+
+/**
+ * Enable a IOMMUFD-related kmod.
+ *
+ * This function is only relevant to linux and will return
+ * an error on BSD.
+ *
+ * @param modname
+ *   kernel module name.
+ *
+ * @return
+ *   0 on success.
+ *   <0 on failure.
+ */
+__rte_experimental
+int rte_iommufd_enable(const char *modname);
+
+/**
+ * Check whether a IOMMUFD-related kmod is enabled.
+ *
+ * This function is only relevant to Linux.
+ *
+ * @param modname
+ *   kernel module name.
+ *
+ * @return
+ *   1 if true.
+ *   0 otherwise.
+ */
+__rte_experimental
+int rte_iommufd_is_enabled(const char *modname);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_IOMMUFD_H_ */
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 57da058cec..4c8e0a7b6e 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include "eal_private.h"
@@ -52,6 +53,7 @@
 #include "eal_trace.h"
 #include "eal_options.h"
 #include "eal_vfio.h"
+#include "eal_iommufd.h"
 #include "hotplug_mp.h"
 #include "log_internal.h"
 
@@ -877,6 +879,16 @@ static int rte_eal_vfio_setup(void)
 }
 #endif
 
+#ifdef IOMMUFD_PRESENT
+static int rte_eal_iommufd_setup(void)
+{
+   if (rte_iommufd_enable("iommufd"))
+   return -1;
+
+   return 0;
+}
+#endif
+
 static void rte_eal_init_alert(const char *msg)
 {
fprintf(stderr, "EAL: FATAL: %s\n", msg);
@@ -1162,6 +1174,16 @@ rte_eal_init(int argc, char **argv)
return -1;
}
 #endif
+
+#ifdef IOMMUFD_PRESENT
+   if (rte_eal_iommufd_setup() < 0) {
+   rte_eal_init_alert("Cannot init IOMMUFD");
+   rte_errno = EAGAIN;
+   rte_atomic_store_explicit(&run_once, 0, 
rte_memory_order_relaxed);
+   return -1;
+   }
+#endif
+
/* in secondary processes, memory init may allocate additional fbarrays
 * not present in primary processes, so to avoid any potential issues

[PATCH 2/4] vfio: add VFIO IOMMUFD support

2023-12-22 Thread beilei . xing
From: Beilei Xing 

VFIO IOMMUFD is a new component added to co-work with IOMMUFD.
IOMMUFD has no impact on the existing VFIO Container/Group
interface, while the latest IOMMU feature(e.g. PASID/SSID) may
be only available through VFIO IOMMUFD/CDEV interface.

This path exposes setup/release vfio device functions with VFIO
IOMMUFD/CDEV interface.

Signed-off-by: Beilei Xing 
Signed-off-by: Yahui Cao 
---
 lib/eal/include/rte_vfio.h   |  55 +
 lib/eal/linux/eal_vfio.h |   3 +
 lib/eal/linux/eal_vfio_iommufd.c | 385 +++
 lib/eal/linux/meson.build|   1 +
 lib/eal/version.map  |   2 +
 5 files changed, 446 insertions(+)
 create mode 100644 lib/eal/linux/eal_vfio_iommufd.c

diff --git a/lib/eal/include/rte_vfio.h b/lib/eal/include/rte_vfio.h
index 22832afd0f..7a9b26b0f7 100644
--- a/lib/eal/include/rte_vfio.h
+++ b/lib/eal/include/rte_vfio.h
@@ -17,6 +17,8 @@ extern "C" {
 #include 
 #include 
 
+#include 
+
 /*
  * determine if VFIO is present on the system
  */
@@ -28,6 +30,9 @@ extern "C" {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
 #define HAVE_VFIO_DEV_REQ_INTERFACE
 #endif /* kernel version >= 4.0.0 */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
+#define VFIO_IOMMUFD_PRESENT
+#endif /* kernel version >= 6.6.0 */
 #endif /* RTE_EAL_VFIO */
 
 #ifdef VFIO_PRESENT
@@ -42,6 +47,10 @@ extern "C" {
 #define VFIO_NOIOMMU_MODE  \
"/sys/module/vfio/parameters/enable_unsafe_noiommu_mode"
 
+#ifdef VFIO_IOMMUFD_PRESENT
+#define VFIO_CDEV_CLASS_DIR "/sys/class/vfio-dev"
+#endif
+
 /* NOIOMMU is defined from kernel version 4.5 onwards */
 #ifdef VFIO_NOIOMMU_IOMMU
 #define RTE_VFIO_NOIOMMU VFIO_NOIOMMU_IOMMU
@@ -137,6 +146,33 @@ struct vfio_device_info;
 int rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
int *vfio_dev_fd, struct vfio_device_info *device_info);
 
+/**
+ * Setup iommufd_cfg for the device identified by its address.
+ *
+ * This function is only relevant to linux and will return
+ * an error on BSD.
+ *
+ * @param sysfs_base
+ *   sysfs path prefix.
+ *
+ * @param dev_addr
+ *   device location.
+ *
+ * @param vfio_dev_fd
+ *   VFIO fd.
+ *
+ * @param device_info
+ *   Device information.
+ *
+ * @return
+ *   0 on success.
+ *   <0 on failure.
+ *   >1 if the device cannot be managed this way.
+ */
+__rte_experimental
+int rte_vfio_iommufd_setup_device(const char *sysfs_base, const char *dev_addr,
+ int *vfio_dev_fd, struct vfio_device_info 
*device_info);
+
 /**
  * Release a device mapped to a VFIO-managed I/O MMU group.
  *
@@ -158,6 +194,25 @@ int rte_vfio_setup_device(const char *sysfs_base, const 
char *dev_addr,
  */
 int rte_vfio_release_device(const char *sysfs_base, const char *dev_addr, int 
fd);
 
+/**
+ * Release a device mapped to a VFIO-iommufd-managed I/O MMU group.
+ *
+ * This function is only relevant to linux and will return
+ * an error on BSD.
+ *
+ * @param dev_addr
+ *   device location.
+ *
+ * @param fd
+ *   VFIO fd.
+ *
+ * @return
+ *   0 on success.
+ *   <0 on failure.
+ */
+__rte_experimental
+int rte_vfio_iommufd_release_device(const char *dev_addr, int fd);
+
 /**
  * Enable a VFIO-related kmod.
  *
diff --git a/lib/eal/linux/eal_vfio.h b/lib/eal/linux/eal_vfio.h
index 23a787ad20..c94409e828 100644
--- a/lib/eal/linux/eal_vfio.h
+++ b/lib/eal/linux/eal_vfio.h
@@ -17,6 +17,9 @@
 #else
 #pragma message("VFIO configured but not supported by this kernel, disabling.")
 #endif /* kernel version >= 3.6.0 */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
+#define VFIO_IOMMUFD_PRESENT
+#endif /* kernel version >= 6.6.0 */
 #endif /* RTE_EAL_VFIO */
 
 #ifdef VFIO_PRESENT
diff --git a/lib/eal/linux/eal_vfio_iommufd.c b/lib/eal/linux/eal_vfio_iommufd.c
new file mode 100644
index 00..02996a588a
--- /dev/null
+++ b/lib/eal/linux/eal_vfio_iommufd.c
@@ -0,0 +1,385 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Intel Corporation
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "eal_private.h"
+#include "eal_internal_cfg.h"
+
+#ifdef VFIO_IOMMUFD_PRESENT
+#include 
+#include "eal_iommufd.h"
+
+#define VFIO_IOMMUFD_MEM_EVENT_CLB_NAME "vfio_iommufd_mem_event_clb"
+
+struct ioas_info {
+   int iommufd;
+   uint32_t ioas_id;
+};
+
+static int
+vfio_iommufd_add_device(const char *dev_addr, int vfio_dev_fd)
+{
+   struct iommufd_config *iommufd_cfg;
+   int iommufd;
+   uint32_t ioas_id;
+   struct vfio_device_bind_iommufd bind = {};
+   struct vfio_device_attach_iommufd_pt attach = {};
+   int ret = 0;
+
+   iommufd_cfg = default_iommufd_cfg;
+   iommufd = iommufd_cfg->iommufd;
+   ioas_id = iommufd_cfg->ioas_id;
+
+   bind.argsz = sizeof(bind);
+   bind.iommufd = iommufd;
+   bind.flags = 0;
+
+   ret = ioctl(vfio_dev_fd, VFIO_DEVICE_BIND_IOMMUFD, &bind);
+   if (ret) 

[PATCH 3/4] bus/pci: add VFIO CDEV support

2023-12-22 Thread beilei . xing
From: Beilei Xing 

This patch adds VFIO CDEV support to probe PCI devices.

For VFIO subsystem, mainline Linux supports both of VFIO Container/GROUP
interface and VFIO IOMMUFD/CDEV interface. Comparing with VFIO Container
and VFIO IOMMUFD, vfio device uAPI does not change while I/O page tables
management is moved from VFIO Container into IOMMUFD interface.

Signed-off-by: Beilei Xing 
Signed-off-by: Yahui Cao 
---
 drivers/bus/pci/bus_pci_driver.h |  1 +
 drivers/bus/pci/linux/pci.c  | 14 +
 drivers/bus/pci/linux/pci_init.h |  4 +++
 drivers/bus/pci/linux/pci_vfio.c | 52 ++--
 4 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/drivers/bus/pci/bus_pci_driver.h b/drivers/bus/pci/bus_pci_driver.h
index be32263a82..6ac25546cf 100644
--- a/drivers/bus/pci/bus_pci_driver.h
+++ b/drivers/bus/pci/bus_pci_driver.h
@@ -26,6 +26,7 @@ enum rte_pci_kernel_driver {
RTE_PCI_KDRV_NIC_UIO,  /* nic_uio for FreeBSD */
RTE_PCI_KDRV_NONE, /* no attached driver */
RTE_PCI_KDRV_NET_UIO,  /* NetUIO for Windows */
+   RTE_PCI_KDRV_VFIO_IOMMUFD, /* VFIO IOMMUFD for Linux */
 };
 
 /**
diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 3d237398d9..1a37f5de22 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -65,6 +65,12 @@ rte_pci_map_device(struct rte_pci_device *dev)
 #ifdef VFIO_PRESENT
if (pci_vfio_is_enabled())
ret = pci_vfio_map_resource(dev);
+#endif
+   break;
+   case RTE_PCI_KDRV_VFIO_IOMMUFD:
+#ifdef VFIO_IOMMUFD_PRESENT
+   if (pci_iommufd_is_enabled())
+   ret = pci_vfio_map_resource(dev);
 #endif
break;
case RTE_PCI_KDRV_IGB_UIO:
@@ -94,6 +100,12 @@ rte_pci_unmap_device(struct rte_pci_device *dev)
 #ifdef VFIO_PRESENT
if (pci_vfio_is_enabled())
pci_vfio_unmap_resource(dev);
+#endif
+   break;
+   case RTE_PCI_KDRV_VFIO_IOMMUFD:
+#ifdef VFIO_IOMMUFD_PRESENT
+   if (pci_iommufd_is_enabled())
+   pci_vfio_unmap_resource(dev);
 #endif
break;
case RTE_PCI_KDRV_IGB_UIO:
@@ -645,6 +657,7 @@ int rte_pci_read_config(const struct rte_pci_device *device,
return pci_uio_read_config(intr_handle, buf, len, offset);
 #ifdef VFIO_PRESENT
case RTE_PCI_KDRV_VFIO:
+   case RTE_PCI_KDRV_VFIO_IOMMUFD:
return pci_vfio_read_config(device, buf, len, offset);
 #endif
default:
@@ -669,6 +682,7 @@ int rte_pci_write_config(const struct rte_pci_device 
*device,
return pci_uio_write_config(intr_handle, buf, len, offset);
 #ifdef VFIO_PRESENT
case RTE_PCI_KDRV_VFIO:
+   case RTE_PCI_KDRV_VFIO_IOMMUFD:
return pci_vfio_write_config(device, buf, len, offset);
 #endif
default:
diff --git a/drivers/bus/pci/linux/pci_init.h b/drivers/bus/pci/linux/pci_init.h
index a4d37c0d0a..a096bc245b 100644
--- a/drivers/bus/pci/linux/pci_init.h
+++ b/drivers/bus/pci/linux/pci_init.h
@@ -79,4 +79,8 @@ int pci_vfio_is_enabled(void);
 
 #endif
 
+#ifdef VFIO_IOMMUFD_PRESENT
+int pci_iommufd_is_enabled(void);
+#endif
+
 #endif /* EAL_PCI_INIT_H_ */
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index 3f3201daf2..97032231d7 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -21,6 +21,9 @@
 #include 
 #include 
 #include 
+#ifdef VFIO_IOMMUFD_PRESENT
+#include 
+#endif
 
 #include "eal_filesystem.h"
 
@@ -783,10 +786,21 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)
snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
loc->domain, loc->bus, loc->devid, loc->function);
 
-   ret = rte_vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr,
-   &vfio_dev_fd, &device_info);
-   if (ret)
-   return ret;
+#ifdef VFIO_IOMMUFD_PRESENT
+   if (dev->kdrv == RTE_PCI_KDRV_VFIO_IOMMUFD) {
+   ret = rte_vfio_iommufd_setup_device(rte_pci_get_sysfs_path(), 
pci_addr,
+   &vfio_dev_fd, &device_info);
+   if (ret)
+   return ret;
+   } else {
+#endif
+   ret = rte_vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr,
+   &vfio_dev_fd, &device_info);
+   if (ret)
+   return ret;
+#ifdef VFIO_IOMMUFD_PRESENT
+   }
+#endif
 
if (rte_intr_dev_fd_set(dev->intr_handle, vfio_dev_fd))
goto err_vfio_dev_fd;
@@ -1148,12 +1162,24 @@ pci_vfio_unmap_resource_primary(struct rte_pci_device 
*dev)
return -1;
}
 
-   ret = rte_vfio_release_device(rte_pci_get_sysfs_path(), pci_addr,
- vfio_dev_fd);
-  

[PATCH 4/4] eal: add new args to choose VFIO mode

2023-12-22 Thread beilei . xing
From: Beilei Xing 

Since now Linux has both of VFIO Container/GROUP & VFIO IOMMUFD/CDEV
support, user can determine how to probe the PCI device by the new
args "--vfio-mode".

Use "--vfio-mode=container" to choose VFIO Container/GROUP, and use
"--vfio-mode=iommufd" to choose VFIO IOMMUFD/CDEV.

Signed-off-by: Beilei Xing 
Signed-off-by: Yahui Cao 
---
 drivers/bus/pci/linux/pci.c |  7 -
 lib/eal/common/eal_common_config.c  |  6 
 lib/eal/common/eal_common_options.c | 48 -
 lib/eal/common/eal_internal_cfg.h   |  1 +
 lib/eal/common/eal_options.h|  2 ++
 lib/eal/include/rte_eal.h   | 18 +++
 lib/eal/version.map |  1 +
 7 files changed, 81 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 1a37f5de22..24c7395f98 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -226,6 +226,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr 
*addr)
struct rte_pci_device_internal *pdev;
struct rte_pci_device *dev;
char driver[PATH_MAX];
+   enum rte_vfio_mode vfio_mode;
int ret;
 
pdev = malloc(sizeof(*pdev));
@@ -317,6 +318,8 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr 
*addr)
return -1;
}
 
+   vfio_mode = rte_eal_vfio_mode();
+
/* parse driver */
snprintf(filename, sizeof(filename), "%s/driver", dirname);
ret = pci_get_kernel_driver_by_path(filename, driver, sizeof(driver));
@@ -327,8 +330,10 @@ pci_scan_one(const char *dirname, const struct 
rte_pci_addr *addr)
}
 
if (!ret) {
-   if (!strcmp(driver, "vfio-pci"))
+   if (!strcmp(driver, "vfio-pci") && vfio_mode == 
RTE_VFIO_CONTAINER)
dev->kdrv = RTE_PCI_KDRV_VFIO;
+   else if (!strcmp(driver, "vfio-pci") && vfio_mode == 
RTE_VFIO_IOMMUFD)
+   dev->kdrv = RTE_PCI_KDRV_VFIO_IOMMUFD;
else if (!strcmp(driver, "igb_uio"))
dev->kdrv = RTE_PCI_KDRV_IGB_UIO;
else if (!strcmp(driver, "uio_pci_generic"))
diff --git a/lib/eal/common/eal_common_config.c 
b/lib/eal/common/eal_common_config.c
index 0daf0f3188..cb3368095d 100644
--- a/lib/eal/common/eal_common_config.c
+++ b/lib/eal/common/eal_common_config.c
@@ -58,6 +58,12 @@ rte_eal_iova_mode(void)
return rte_eal_get_configuration()->iova_mode;
 }
 
+enum rte_vfio_mode
+rte_eal_vfio_mode(void)
+{
+   return internal_config.vfio_mode;
+}
+
 /* Get the EAL base address */
 uint64_t
 rte_eal_get_baseaddr(void)
diff --git a/lib/eal/common/eal_common_options.c 
b/lib/eal/common/eal_common_options.c
index a6d21f1cba..7df1fa0821 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -35,6 +35,7 @@
 #include 
 #endif
 #include 
+#include 
 
 #include "eal_internal_cfg.h"
 #include "eal_options.h"
@@ -96,6 +97,7 @@ eal_long_options[] = {
{OPT_SYSLOG,1, NULL, OPT_SYSLOG_NUM   },
{OPT_VDEV,  1, NULL, OPT_VDEV_NUM },
{OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},
+   {OPT_VFIO_MODE, 1, NULL, OPT_VFIO_MODE_NUM},
{OPT_VFIO_VF_TOKEN, 1, NULL, OPT_VFIO_VF_TOKEN_NUM},
{OPT_VMWARE_TSC_MAP,0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
{OPT_LEGACY_MEM,0, NULL, OPT_LEGACY_MEM_NUM   },
@@ -1598,6 +1600,42 @@ available_cores(void)
return str;
 }
 
+static int
+eal_parse_vfio_mode(const char *name)
+{
+   int mode;
+   struct internal_config *internal_conf =
+   eal_get_internal_configuration();
+#ifdef VFIO_IOMMUFD_PRESENT
+   char dirname[PATH_MAX] = VFIO_CDEV_CLASS_DIR;
+#endif
+
+   if (name == NULL)
+   return -1;
+
+   if (!strcmp("container", name)) {
+   mode = RTE_VFIO_CONTAINER;
+   } else if (!strcmp("iommufd", name)) {
+#ifdef VFIO_IOMMUFD_PRESENT
+   if (opendir(dirname) == NULL) {
+   RTE_LOG(WARNING, EAL, "vfio cdev isn't supported, 
change to vfio container mode\n");
+   mode = RTE_VFIO_CONTAINER;
+   } else {
+   mode = RTE_VFIO_IOMMUFD;
+   }
+#else
+   RTE_LOG(WARNING, EAL, "vfio cdev isn't supported, change to 
vfio container mode\n");
+   mode = RTE_VFIO_CONTAINER;
+#endif
+   } else {
+   RTE_LOG(ERR, EAL, "unsupported vfio mode\n");
+   return -1;
+   }
+
+   internal_conf->vfio_mode = mode;
+   return 0;
+}
+
 #define HUGE_UNLINK_NEVER "never"
 
 static int
@@ -1922,7 +1960,13 @@ eal_parse_common_option(int opt, const char *optarg,
return -1;
}
break;
-
+   case OPT_VFIO_MODE_NUM:
+   if (eal_parse_vfio_mode(o

RE: [PATCH v2] net/iavf: add diagnostic support in TX path

2023-12-22 Thread Zhang, Qi Z



> -Original Message-
> From: Mingjin Ye 
> Sent: Friday, December 22, 2023 6:45 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming ; Ye, MingjinX
> ; Wu, Jingjing ; Xing, Beilei
> 
> Subject: [PATCH v2] net/iavf: add diagnostic support in TX path
> 
> The only way to enable diagnostics for TX paths is to modify the application
> source code. Making it difficult to diagnose faults.
> 
> In this patch, the devarg option "mbuf_check" is introduced and the
> parameters are configured to enable the corresponding diagnostics.
> 
> supported cases: mbuf, size, segment, offload, strict.
>  1. mbuf: check for corrupted mbuf.
>  2. size: check min/max packet length according to hw spec.
>  3. segment: check number of mbuf segments not exceed hw limitation.
>  4. offload: check any unsupported offload flag.
>  5. strict: check protocol headers.
> 
> parameter format: mbuf_check=[mbuf,,]
> eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i
> 
> Signed-off-by: Mingjin Ye 
> ---
> v2: Remove call chain.

...

> 
> +static struct iavf_pkt_burst iavf_rxtx_pkt_burst[RTE_MAX_ETHPORTS];

Global array is not necessary, I assume we can get adapter with 
rxq->vsi->adapter.

> +
>  static inline void
>  iavf_rxd_to_pkt_fields_by_comms_ovs(__rte_unused struct iavf_rx_queue
> *rxq,
>   struct rte_mbuf *mb,
> @@ -3394,34 +3396,34 @@ check_mbuf_len(struct offload_info *info,
> struct rte_mbuf *m)  {
>   if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
>   if (info->outer_l2_len != m->outer_l2_len) {
> - PMD_TX_LOG(ERR, "outer_l2_len error in mbuf.
> Original "
> - "length: %hu, calculated length: %u", m-
> >outer_l2_len,
> + PMD_DRV_LOG(ERR, "outer_l2_len error in mbuf.
> Original "
> + "length: %d, calculated length: %u", m-
> >outer_l2_len,
>   info->outer_l2_len);
>   return -1;
>   }
>   if (info->outer_l3_len != m->outer_l3_len) {
> - PMD_TX_LOG(ERR, "outer_l3_len error in mbuf.
> Original "
> - "length: %hu,calculated length: %u", m-
> >outer_l3_len,
> + PMD_DRV_LOG(ERR, "outer_l3_len error in mbuf.
> Original "
> + "length: %d,calculated length: %u", m->outer_l3_len,
>   info->outer_l3_len);
>   return -1;
>   }
>   }
> 
>   if (info->l2_len != m->l2_len) {
> - PMD_TX_LOG(ERR, "l2_len error in mbuf. Original "
> - "length: %hu, calculated length: %u", m->l2_len,
> + PMD_DRV_LOG(ERR, "l2_len error in mbuf. Original "
> + "length: %d, calculated length: %u", m->l2_len,
>   info->l2_len);
>   return -1;

Can you explain why need to change all the log type here? basically the 
diagnose check is for Tx only , we don't need to touch existing Rx 
implementation.  it could be a separate patch if you think something need to be 
refactor.




Re: [PATCH v5 00/18] Replace uses of PMD logtype

2023-12-22 Thread David Marchand
On Thu, Dec 21, 2023 at 5:49 PM Stephen Hemminger
 wrote:
>
> The generic RTE_LOGTYPE_PMD is a leftover and should be removed.
> This replaces all uses in current tree. It leaves PMD logtype
> as deprecated because there maybe other uses in external projects
> leftover.
>
> This version does not use Depends-on: because CI system can't
> handle that and want to make sure no PMD left behind.
>
> v5 - incorporate review feedback
>
> David Marchand (1):
>   drivers: use dedicated logtypes
>
> Stephen Hemminger (17):
>   common/sfc_efx: remove use of PMD logtype
>   mempool/dpaa2: use driver logtype not PMD
>   net/dpaa: use dedicated logtype not PMD
>   net/dpaa2: used dedicated logtype not PMD
>   net/mvpp2: use dedicated logtype
>   net/vmxnet3: used dedicated logtype not PMD
>   raw/cnxk: replace PMD logtype with dynamic type
>   crypto/scheduler: replace use of logtype PMD
>   crypto/ccp: do not use PMD logtype
>   crypto/caam_jr: use dedicated logtype
>   crypto/dpaa_sec, crypto/dpaa2_sec: use dedicated logtype
>   event/dlb2: use dedicated logtype
>   event/dpaa, event/dpaa2: use dedicated logtype
>   event/skeleton: replace logtype PMD with dynamic type
>   net/nfb: use dynamic logtype
>   examples/fips_validation: replace use of PMD logtype
>   log: mark PMD logtype as deprecated

It seems our CI has some gaps.

I found some PMD use in two drivers:
drivers/crypto/armv8/rte_armv8_pmd.c:   RTE_LOG(INFO, PMD,
drivers/net/mvpp2/mrvl_ethdev.c:RTE_LOG(ERR, PMD,



-- 
David Marchand



[PATCH] net/gve: Enable stats reporting for GQ format

2023-12-22 Thread Rushil Gupta
Read from shared region to retrieve imissed statistics for GQ.
Tested using `show port xstats ` in interactive mode.
This metric can be triggered by using queues > cores.

Signed-off-by: Rushil Gupta 
Reviewed-by: Joshua Washington 
---
 drivers/net/gve/base/gve_adminq.h |  11 +++
 drivers/net/gve/gve_ethdev.c  | 142 --
 drivers/net/gve/gve_ethdev.h  |  20 -
 3 files changed, 167 insertions(+), 6 deletions(-)

diff --git a/drivers/net/gve/base/gve_adminq.h 
b/drivers/net/gve/base/gve_adminq.h
index e30b184913..f05362f85f 100644
--- a/drivers/net/gve/base/gve_adminq.h
+++ b/drivers/net/gve/base/gve_adminq.h
@@ -314,6 +314,17 @@ struct gve_stats_report {
 
 GVE_CHECK_STRUCT_LEN(8, gve_stats_report);
 
+/* Numbers of gve tx/rx stats in stats report. */
+#define GVE_TX_STATS_REPORT_NUM6
+#define GVE_RX_STATS_REPORT_NUM2
+
+/* Interval to schedule a stats report update, 2ms. */
+#define GVE_STATS_REPORT_TIMER_PERIOD  2
+
+/* Numbers of NIC tx/rx stats in stats report. */
+#define NIC_TX_STATS_REPORT_NUM0
+#define NIC_RX_STATS_REPORT_NUM4
+
 enum gve_stat_names {
/* stats from gve */
TX_WAKE_CNT = 1,
diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c
index ecd37ff37f..bb535a863f 100644
--- a/drivers/net/gve/gve_ethdev.c
+++ b/drivers/net/gve/gve_ethdev.c
@@ -125,6 +125,73 @@ gve_link_update(struct rte_eth_dev *dev, __rte_unused int 
wait_to_complete)
return rte_eth_linkstatus_set(dev, &link);
 }
 
+static int gve_alloc_stats_report(struct gve_priv *priv,
+   uint16_t nb_tx_queues, uint16_t nb_rx_queues)
+{
+   char z_name[RTE_MEMZONE_NAMESIZE];
+   int tx_stats_cnt;
+   int rx_stats_cnt;
+
+   tx_stats_cnt = (GVE_TX_STATS_REPORT_NUM + NIC_TX_STATS_REPORT_NUM) *
+   nb_tx_queues;
+   rx_stats_cnt = (GVE_RX_STATS_REPORT_NUM + NIC_RX_STATS_REPORT_NUM) *
+   nb_rx_queues;
+   priv->stats_report_len = sizeof(struct gve_stats_report) +
+   sizeof(struct stats) * (tx_stats_cnt + rx_stats_cnt);
+
+   snprintf(z_name, sizeof(z_name), "stats_report_%s", 
priv->pci_dev->device.name);
+   priv->stats_report_mem = rte_memzone_reserve_aligned(z_name,
+   priv->stats_report_len,
+   rte_socket_id(),
+   RTE_MEMZONE_IOVA_CONTIG, PAGE_SIZE);
+
+   if (!priv->stats_report_mem)
+   return -ENOMEM;
+
+   /* offset by skipping stats written by gve. */
+   priv->stats_start_idx = (GVE_TX_STATS_REPORT_NUM * nb_tx_queues) +
+   (GVE_RX_STATS_REPORT_NUM * nb_rx_queues);
+   priv->stats_end_idx = priv->stats_start_idx +
+   (NIC_TX_STATS_REPORT_NUM * nb_tx_queues) +
+   (NIC_RX_STATS_REPORT_NUM * nb_rx_queues) - 1;
+
+   return 0;
+}
+
+static void gve_free_stats_report(struct rte_eth_dev *dev)
+{
+struct gve_priv *priv = dev->data->dev_private;
+rte_memzone_free(priv->stats_report_mem);
+}
+
+/* Read Rx NIC stats from shared region */
+static void gve_get_imissed_from_nic(struct rte_eth_dev *dev)
+{
+   struct gve_stats_report *stats_report;
+   struct gve_rx_queue *rxq;
+   struct gve_priv *priv;
+   struct stats stat;
+   int queue_id;
+   int stat_id;
+   int i;
+
+   priv = dev->data->dev_private;
+   stats_report = (struct gve_stats_report *)
+   priv->stats_report_mem->addr;
+
+   for (i = priv->stats_start_idx; i <= priv->stats_end_idx; i++) {
+   stat = stats_report->stats[i];
+   queue_id = cpu_to_be32(stat.queue_id);
+   rxq = dev->data->rx_queues[queue_id];
+   if (rxq == NULL)
+   continue;
+   stat_id = cpu_to_be32(stat.stat_name);
+   /* Update imissed. */
+   if (stat_id == RX_NO_BUFFERS_POSTED)
+   rxq->stats.imissed = cpu_to_be64(stat.value);
+   }
+}
+
 static int
 gve_start_queues(struct rte_eth_dev *dev)
 {
@@ -176,6 +243,7 @@ gve_start_queues(struct rte_eth_dev *dev)
 static int
 gve_dev_start(struct rte_eth_dev *dev)
 {
+   struct gve_priv *priv;
int ret;
 
ret = gve_start_queues(dev);
@@ -187,6 +255,27 @@ gve_dev_start(struct rte_eth_dev *dev)
dev->data->dev_started = 1;
gve_link_update(dev, 0);
 
+   priv = dev->data->dev_private;
+   /* No stats available yet for Dqo. */
+   if (gve_is_gqi(priv))
+   {
+   ret = gve_alloc_stats_report(priv,
+   dev->data->nb_tx_queues,
+   dev->data->nb_rx_queues);
+   if (ret != 0) {
+   PMD_DRV_LOG(ERR,
+   "Failed to allocate region for stats 
reporting.");
+   return ret;
+   }
+   ret = gve_adminq_report_stats(priv

[PATCH] net/gve: Enable stats reporting for GQ format

2023-12-22 Thread Rushil Gupta
Read from shared region to retrieve imissed statistics for GQ from device.
Tested using `show port xstats ` in interactive mode.
This metric can be triggered by using queues > cores.
---
 drivers/net/gve/base/gve_adminq.h |  11 +++
 drivers/net/gve/gve_ethdev.c  | 117 ++
 drivers/net/gve/gve_ethdev.h  |   6 ++
 3 files changed, 134 insertions(+)

diff --git a/drivers/net/gve/base/gve_adminq.h 
b/drivers/net/gve/base/gve_adminq.h
index e30b184913..f05362f85f 100644
--- a/drivers/net/gve/base/gve_adminq.h
+++ b/drivers/net/gve/base/gve_adminq.h
@@ -314,6 +314,17 @@ struct gve_stats_report {
 
 GVE_CHECK_STRUCT_LEN(8, gve_stats_report);
 
+/* Numbers of gve tx/rx stats in stats report. */
+#define GVE_TX_STATS_REPORT_NUM6
+#define GVE_RX_STATS_REPORT_NUM2
+
+/* Interval to schedule a stats report update, 2ms. */
+#define GVE_STATS_REPORT_TIMER_PERIOD  2
+
+/* Numbers of NIC tx/rx stats in stats report. */
+#define NIC_TX_STATS_REPORT_NUM0
+#define NIC_RX_STATS_REPORT_NUM4
+
 enum gve_stat_names {
/* stats from gve */
TX_WAKE_CNT = 1,
diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c
index ecd37ff37f..8e9596bb83 100644
--- a/drivers/net/gve/gve_ethdev.c
+++ b/drivers/net/gve/gve_ethdev.c
@@ -125,6 +125,73 @@ gve_link_update(struct rte_eth_dev *dev, __rte_unused int 
wait_to_complete)
return rte_eth_linkstatus_set(dev, &link);
 }
 
+static int gve_alloc_stats_report(struct gve_priv *priv,
+   uint16_t nb_tx_queues, uint16_t nb_rx_queues)
+{
+   char z_name[RTE_MEMZONE_NAMESIZE];
+   int tx_stats_cnt;
+   int rx_stats_cnt;
+
+   tx_stats_cnt = (GVE_TX_STATS_REPORT_NUM + NIC_TX_STATS_REPORT_NUM) *
+   nb_tx_queues;
+   rx_stats_cnt = (GVE_RX_STATS_REPORT_NUM + NIC_RX_STATS_REPORT_NUM) *
+   nb_rx_queues;
+   priv->stats_report_len = sizeof(struct gve_stats_report) +
+   sizeof(struct stats) * (tx_stats_cnt + rx_stats_cnt);
+
+   snprintf(z_name, sizeof(z_name), "stats_report_%s", 
priv->pci_dev->device.name);
+   priv->stats_report_mem = rte_memzone_reserve_aligned(z_name,
+   priv->stats_report_len,
+   rte_socket_id(),
+   RTE_MEMZONE_IOVA_CONTIG, PAGE_SIZE);
+
+   if (!priv->stats_report_mem)
+   return -ENOMEM;
+
+   /* offset by skipping stats written by gve. */
+   priv->stats_start_idx = (GVE_TX_STATS_REPORT_NUM * nb_tx_queues) +
+   (GVE_RX_STATS_REPORT_NUM * nb_rx_queues);
+   priv->stats_end_idx = priv->stats_start_idx +
+   (NIC_TX_STATS_REPORT_NUM * nb_tx_queues) +
+   (NIC_RX_STATS_REPORT_NUM * nb_rx_queues) - 1;
+
+   return 0;
+}
+
+static void gve_free_stats_report(struct rte_eth_dev *dev)
+{
+   struct gve_priv *priv = dev->data->dev_private;
+   rte_memzone_free(priv->stats_report_mem);
+}
+
+/* Read Rx NIC stats from shared region */
+static void gve_get_imissed_from_nic(struct rte_eth_dev *dev)
+{
+   struct gve_stats_report *stats_report;
+   struct gve_rx_queue *rxq;
+   struct gve_priv *priv;
+   struct stats stat;
+   int queue_id;
+   int stat_id;
+   int i;
+
+   priv = dev->data->dev_private;
+   stats_report = (struct gve_stats_report *)
+   priv->stats_report_mem->addr;
+
+   for (i = priv->stats_start_idx; i <= priv->stats_end_idx; i++) {
+   stat = stats_report->stats[i];
+   queue_id = cpu_to_be32(stat.queue_id);
+   rxq = dev->data->rx_queues[queue_id];
+   if (rxq == NULL)
+   continue;
+   stat_id = cpu_to_be32(stat.stat_name);
+   /* Update imissed. */
+   if (stat_id == RX_NO_BUFFERS_POSTED)
+   rxq->stats.imissed = cpu_to_be64(stat.value);
+   }
+}
+
 static int
 gve_start_queues(struct rte_eth_dev *dev)
 {
@@ -176,6 +243,7 @@ gve_start_queues(struct rte_eth_dev *dev)
 static int
 gve_dev_start(struct rte_eth_dev *dev)
 {
+   struct gve_priv *priv;
int ret;
 
ret = gve_start_queues(dev);
@@ -187,6 +255,26 @@ gve_dev_start(struct rte_eth_dev *dev)
dev->data->dev_started = 1;
gve_link_update(dev, 0);
 
+   priv = dev->data->dev_private;
+   /* No stats available yet for Dqo. */
+   if (gve_is_gqi(priv) {
+   ret = gve_alloc_stats_report(priv,
+   dev->data->nb_tx_queues,
+   dev->data->nb_rx_queues);
+   if (ret != 0) {
+   PMD_DRV_LOG(ERR,
+   "Failed to allocate region for stats 
reporting.");
+   return ret;
+   }
+   ret = gve_adminq_report_stats(priv, priv->stats_report_len,
+   priv->stats_report_mem

[PATCH] net/gve: Enable stats reporting for GQ format

2023-12-22 Thread Rushil Gupta
Read from shared region to retrieve imissed statistics for GQ from device.
Tested using `show port xstats ` in interactive mode.
This metric can be triggered by using queues > cores.

Signed-off-by: Rushil Gupta 
Reviewed-by: Joshua Washington 
---
 drivers/net/gve/base/gve_adminq.h | 11 
 drivers/net/gve/gve_ethdev.c  | 95 +++
 drivers/net/gve/gve_ethdev.h  |  6 ++
 3 files changed, 112 insertions(+)

diff --git a/drivers/net/gve/base/gve_adminq.h 
b/drivers/net/gve/base/gve_adminq.h
index e30b184913..f05362f85f 100644
--- a/drivers/net/gve/base/gve_adminq.h
+++ b/drivers/net/gve/base/gve_adminq.h
@@ -314,6 +314,17 @@ struct gve_stats_report {
 
 GVE_CHECK_STRUCT_LEN(8, gve_stats_report);
 
+/* Numbers of gve tx/rx stats in stats report. */
+#define GVE_TX_STATS_REPORT_NUM6
+#define GVE_RX_STATS_REPORT_NUM2
+
+/* Interval to schedule a stats report update, 2ms. */
+#define GVE_STATS_REPORT_TIMER_PERIOD  2
+
+/* Numbers of NIC tx/rx stats in stats report. */
+#define NIC_TX_STATS_REPORT_NUM0
+#define NIC_RX_STATS_REPORT_NUM4
+
 enum gve_stat_names {
/* stats from gve */
TX_WAKE_CNT = 1,
diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c
index ecd37ff37f..986418cf5b 100644
--- a/drivers/net/gve/gve_ethdev.c
+++ b/drivers/net/gve/gve_ethdev.c
@@ -125,6 +125,73 @@ gve_link_update(struct rte_eth_dev *dev, __rte_unused int 
wait_to_complete)
return rte_eth_linkstatus_set(dev, &link);
 }
 
+static int gve_alloc_stats_report(struct gve_priv *priv,
+   uint16_t nb_tx_queues, uint16_t nb_rx_queues)
+{
+   char z_name[RTE_MEMZONE_NAMESIZE];
+   int tx_stats_cnt;
+   int rx_stats_cnt;
+
+   tx_stats_cnt = (GVE_TX_STATS_REPORT_NUM + NIC_TX_STATS_REPORT_NUM) *
+   nb_tx_queues;
+   rx_stats_cnt = (GVE_RX_STATS_REPORT_NUM + NIC_RX_STATS_REPORT_NUM) *
+   nb_rx_queues;
+   priv->stats_report_len = sizeof(struct gve_stats_report) +
+   sizeof(struct stats) * (tx_stats_cnt + rx_stats_cnt);
+
+   snprintf(z_name, sizeof(z_name), "stats_report_%s", 
priv->pci_dev->device.name);
+   priv->stats_report_mem = rte_memzone_reserve_aligned(z_name,
+   priv->stats_report_len,
+   rte_socket_id(),
+   RTE_MEMZONE_IOVA_CONTIG, PAGE_SIZE);
+
+   if (!priv->stats_report_mem)
+   return -ENOMEM;
+
+   /* offset by skipping stats written by gve. */
+   priv->stats_start_idx = (GVE_TX_STATS_REPORT_NUM * nb_tx_queues) +
+   (GVE_RX_STATS_REPORT_NUM * nb_rx_queues);
+   priv->stats_end_idx = priv->stats_start_idx +
+   (NIC_TX_STATS_REPORT_NUM * nb_tx_queues) +
+   (NIC_RX_STATS_REPORT_NUM * nb_rx_queues) - 1;
+
+   return 0;
+}
+
+static void gve_free_stats_report(struct rte_eth_dev *dev)
+{
+   struct gve_priv *priv = dev->data->dev_private;
+   rte_memzone_free(priv->stats_report_mem);
+}
+
+/* Read Rx NIC stats from shared region */
+static void gve_get_imissed_from_nic(struct rte_eth_dev *dev)
+{
+   struct gve_stats_report *stats_report;
+   struct gve_rx_queue *rxq;
+   struct gve_priv *priv;
+   struct stats stat;
+   int queue_id;
+   int stat_id;
+   int i;
+
+   priv = dev->data->dev_private;
+   stats_report = (struct gve_stats_report *)
+   priv->stats_report_mem->addr;
+
+   for (i = priv->stats_start_idx; i <= priv->stats_end_idx; i++) {
+   stat = stats_report->stats[i];
+   queue_id = cpu_to_be32(stat.queue_id);
+   rxq = dev->data->rx_queues[queue_id];
+   if (rxq == NULL)
+   continue;
+   stat_id = cpu_to_be32(stat.stat_name);
+   /* Update imissed. */
+   if (stat_id == RX_NO_BUFFERS_POSTED)
+   rxq->stats.imissed = cpu_to_be64(stat.value);
+   }
+}
+
 static int
 gve_start_queues(struct rte_eth_dev *dev)
 {
@@ -176,6 +243,7 @@ gve_start_queues(struct rte_eth_dev *dev)
 static int
 gve_dev_start(struct rte_eth_dev *dev)
 {
+   struct gve_priv *priv;
int ret;
 
ret = gve_start_queues(dev);
@@ -187,6 +255,26 @@ gve_dev_start(struct rte_eth_dev *dev)
dev->data->dev_started = 1;
gve_link_update(dev, 0);
 
+   priv = dev->data->dev_private;
+   /* No stats available yet for Dqo. */
+   if (gve_is_gqi(priv) {
+   ret = gve_alloc_stats_report(priv,
+   dev->data->nb_tx_queues,
+   dev->data->nb_rx_queues);
+   if (ret != 0) {
+   PMD_DRV_LOG(ERR,
+   "Failed to allocate region for stats 
reporting.");
+   return ret;
+   }
+   ret = gve_adminq_report_stats(priv, priv->stats_repor

[PATCH] net/gve: Enable stats reporting for GQ format

2023-12-22 Thread Rushil Gupta
Read from shared region to retrieve imissed statistics for GQ from device.
Tested using `show port xstats ` in interactive mode.
This metric can be triggered by using queues > cores.

Signed-off-by: Rushil Gupta 
Reviewed-by: Joshua Washington 
---
 drivers/net/gve/base/gve_adminq.h | 11 
 drivers/net/gve/gve_ethdev.c  | 95 +++
 drivers/net/gve/gve_ethdev.h  |  6 ++
 3 files changed, 112 insertions(+)

diff --git a/drivers/net/gve/base/gve_adminq.h 
b/drivers/net/gve/base/gve_adminq.h
index e30b184913..f05362f85f 100644
--- a/drivers/net/gve/base/gve_adminq.h
+++ b/drivers/net/gve/base/gve_adminq.h
@@ -314,6 +314,17 @@ struct gve_stats_report {
 
 GVE_CHECK_STRUCT_LEN(8, gve_stats_report);
 
+/* Numbers of gve tx/rx stats in stats report. */
+#define GVE_TX_STATS_REPORT_NUM6
+#define GVE_RX_STATS_REPORT_NUM2
+
+/* Interval to schedule a stats report update, 2ms. */
+#define GVE_STATS_REPORT_TIMER_PERIOD  2
+
+/* Numbers of NIC tx/rx stats in stats report. */
+#define NIC_TX_STATS_REPORT_NUM0
+#define NIC_RX_STATS_REPORT_NUM4
+
 enum gve_stat_names {
/* stats from gve */
TX_WAKE_CNT = 1,
diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c
index ecd37ff37f..836136d993 100644
--- a/drivers/net/gve/gve_ethdev.c
+++ b/drivers/net/gve/gve_ethdev.c
@@ -125,6 +125,73 @@ gve_link_update(struct rte_eth_dev *dev, __rte_unused int 
wait_to_complete)
return rte_eth_linkstatus_set(dev, &link);
 }
 
+static int gve_alloc_stats_report(struct gve_priv *priv,
+   uint16_t nb_tx_queues, uint16_t nb_rx_queues)
+{
+   char z_name[RTE_MEMZONE_NAMESIZE];
+   int tx_stats_cnt;
+   int rx_stats_cnt;
+
+   tx_stats_cnt = (GVE_TX_STATS_REPORT_NUM + NIC_TX_STATS_REPORT_NUM) *
+   nb_tx_queues;
+   rx_stats_cnt = (GVE_RX_STATS_REPORT_NUM + NIC_RX_STATS_REPORT_NUM) *
+   nb_rx_queues;
+   priv->stats_report_len = sizeof(struct gve_stats_report) +
+   sizeof(struct stats) * (tx_stats_cnt + rx_stats_cnt);
+
+   snprintf(z_name, sizeof(z_name), "stats_report_%s", 
priv->pci_dev->device.name);
+   priv->stats_report_mem = rte_memzone_reserve_aligned(z_name,
+   priv->stats_report_len,
+   rte_socket_id(),
+   RTE_MEMZONE_IOVA_CONTIG, PAGE_SIZE);
+
+   if (!priv->stats_report_mem)
+   return -ENOMEM;
+
+   /* offset by skipping stats written by gve. */
+   priv->stats_start_idx = (GVE_TX_STATS_REPORT_NUM * nb_tx_queues) +
+   (GVE_RX_STATS_REPORT_NUM * nb_rx_queues);
+   priv->stats_end_idx = priv->stats_start_idx +
+   (NIC_TX_STATS_REPORT_NUM * nb_tx_queues) +
+   (NIC_RX_STATS_REPORT_NUM * nb_rx_queues) - 1;
+
+   return 0;
+}
+
+static void gve_free_stats_report(struct rte_eth_dev *dev)
+{
+   struct gve_priv *priv = dev->data->dev_private;
+   rte_memzone_free(priv->stats_report_mem);
+}
+
+/* Read Rx NIC stats from shared region */
+static void gve_get_imissed_from_nic(struct rte_eth_dev *dev)
+{
+   struct gve_stats_report *stats_report;
+   struct gve_rx_queue *rxq;
+   struct gve_priv *priv;
+   struct stats stat;
+   int queue_id;
+   int stat_id;
+   int i;
+
+   priv = dev->data->dev_private;
+   stats_report = (struct gve_stats_report *)
+   priv->stats_report_mem->addr;
+
+   for (i = priv->stats_start_idx; i <= priv->stats_end_idx; i++) {
+   stat = stats_report->stats[i];
+   queue_id = cpu_to_be32(stat.queue_id);
+   rxq = dev->data->rx_queues[queue_id];
+   if (rxq == NULL)
+   continue;
+   stat_id = cpu_to_be32(stat.stat_name);
+   /* Update imissed. */
+   if (stat_id == RX_NO_BUFFERS_POSTED)
+   rxq->stats.imissed = cpu_to_be64(stat.value);
+   }
+}
+
 static int
 gve_start_queues(struct rte_eth_dev *dev)
 {
@@ -176,6 +243,7 @@ gve_start_queues(struct rte_eth_dev *dev)
 static int
 gve_dev_start(struct rte_eth_dev *dev)
 {
+   struct gve_priv *priv;
int ret;
 
ret = gve_start_queues(dev);
@@ -187,6 +255,26 @@ gve_dev_start(struct rte_eth_dev *dev)
dev->data->dev_started = 1;
gve_link_update(dev, 0);
 
+   priv = dev->data->dev_private;
+   /* No stats available yet for Dqo. */
+   if (gve_is_gqi(priv)) {
+   ret = gve_alloc_stats_report(priv,
+   dev->data->nb_tx_queues,
+   dev->data->nb_rx_queues);
+   if (ret != 0) {
+   PMD_DRV_LOG(ERR,
+   "Failed to allocate region for stats 
reporting.");
+   return ret;
+   }
+   ret = gve_adminq_report_stats(priv, priv->stats_repo

RE: [PATCH] net/i40e: add diagnostic support in TX path

2023-12-22 Thread Morten Brørup
> From: Mingjin Ye [mailto:mingjinx...@intel.com]
> Sent: Thursday, 21 December 2023 11.14
> 
> The only way to enable diagnostics for TX paths is to modify the
> application source code. Making it difficult to diagnose faults.
> 
> In this patch, the devarg option "mbuf_check" is introduced and the
> parameters are configured to enable the corresponding diagnostics.

Why not use the already existing RTE_LIBRTE_MBUF_DEBUG?

> 
> supported cases: mbuf, size, segment, offload, strict.
>  1. mbuf: check for corrupted mbuf.
>  2. size: check min/max packet length according to hw spec.
>  3. segment: check number of mbuf segments not exceed hw limitation.
>  4. offload: check any unsupported offload flag.
>  5. strict: check protocol headers.

These are all good things to test for, when debugging.

The checks should be part of RTE_LIBRTE_MBUF_DEBUG, instead of introducing yet 
another runtime parameter.

Also, it would be better to add these checks somewhere in the ethdev library 
instead of in the individual drivers. That would make them available for all 
drivers.

> 
> parameter format: mbuf_check=[mbuf,,]
> eg: dpdk-testpmd -a :81:01.0,mbuf_check=[mbuf,size] -- -i
> 
> Signed-off-by: Mingjin Ye 
> ---


Re: [PATCH 2/4] vfio: add VFIO IOMMUFD support

2023-12-22 Thread Stephen Hemminger
On Fri, 22 Dec 2023 19:44:51 +
beilei.x...@intel.com wrote:

> diff --git a/lib/eal/include/rte_vfio.h b/lib/eal/include/rte_vfio.h
> index 22832afd0f..7a9b26b0f7 100644
> --- a/lib/eal/include/rte_vfio.h
> +++ b/lib/eal/include/rte_vfio.h
> @@ -17,6 +17,8 @@ extern "C" {
>  #include 
>  #include 
>  
> +#include 
> +
>  /*
>   * determine if VFIO is present on the system
>   */
> @@ -28,6 +30,9 @@ extern "C" {
>  #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
>  #define HAVE_VFIO_DEV_REQ_INTERFACE
>  #endif /* kernel version >= 4.0.0 */
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
> +#define VFIO_IOMMUFD_PRESENT
> +#endif /* kernel version >= 6.6.0 */
>  #endif /* RTE_EAL_VFIO */

Depending on kernel version macro is a mistake because many enterprise
distro's backport features and do not change kernel version.
Also, it means the build and target machine have to be same kernel version.


[PATCH v6 00/20] Remove uses of PMD logtype

2023-12-22 Thread Stephen Hemminger
The generic RTE_LOGTYPE_PMD is a leftover and should be removed.
This replaces all uses in current tree. It leaves PMD logtype
as deprecated because there maybe other uses in external projects
leftover.

This version does not use Depends-on: because CI system can't
handle that and want to make sure no PMD left behind

v6 - add a couple of more places
 remove PMD logtype in last patch

David Marchand (1):
  drivers: use dedicated logtypes

Stephen Hemminger (19):
  common/sfc_efx: remove use of PMD logtype
  mempool/dpaa2: use driver logtype not PMD
  net/dpaa: use dedicated logtype not PMD
  net/dpaa2: used dedicated logtype not PMD
  net/mrvl: do not use PMD logtype
  net/mvpp2: use dedicated logtype
  net/nfb: use dynamic logtype
  net/vmxnet3: used dedicated logtype not PMD
  raw/cnxk: replace PMD logtype with dynamic type
  crypto/scheduler: replace use of logtype PMD
  crypto/armv8: do not use PMD logtype
  crypto/ccp: do not use PMD logtype
  crypto/caam_jr: use dedicated logtype
  crypto/dpaa_sec, crypto/dpaa2_sec: use dedicated logtype
  event/dlb2: use dedicated logtype
  event/dpaa, event/dpaa2: use dedicated logtype
  event/skeleton: replace logtype PMD with dynamic type
  examples/fips_validation: replace use of PMD logtype
  log: remove PMD log type

 .../baseband/la12xx/bbdev_la12xx_pmd_logs.h   |   3 +-
 drivers/bus/cdx/cdx_logs.h|   3 +-
 drivers/bus/fslmc/fslmc_logs.h|   3 +-
 drivers/common/cnxk/roc_platform.h|  16 +-
 drivers/common/cpt/cpt_pmd_logs.h |   6 +-
 drivers/common/dpaax/caamflib/compat.h|   4 +-
 drivers/common/dpaax/dpaax_logs.h |   3 +-
 drivers/common/dpaax/version.map  |   1 +
 drivers/common/idpf/idpf_common_logs.h|   5 +-
 drivers/common/sfc_efx/sfc_efx.c  |  11 +-
 drivers/common/sfc_efx/sfc_efx_log.h  |   2 +-
 drivers/crypto/armv8/rte_armv8_pmd.c  |   4 +-
 drivers/crypto/caam_jr/caam_jr.c  |  46 ++-
 drivers/crypto/caam_jr/caam_jr_log.h  |  15 +-
 drivers/crypto/caam_jr/caam_jr_uio.c  |   4 +-
 drivers/crypto/ccp/rte_ccp_pmd.c  |  13 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   |   6 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_logs.h |   3 +-
 drivers/crypto/dpaa_sec/dpaa_sec.c|  30 +-
 drivers/crypto/dpaa_sec/dpaa_sec_log.h|   3 +-
 drivers/crypto/scheduler/scheduler_pmd.c  |   4 +-
 drivers/dma/dpaa/dpaa_qdma_logs.h |   3 +-
 drivers/dma/dpaa2/dpaa2_qdma_logs.h   |   3 +-
 drivers/event/dlb2/dlb2.c | 275 +-
 drivers/event/dlb2/dlb2_log.h |   3 +-
 drivers/event/dpaa/dpaa_eventdev.c|   2 +-
 drivers/event/dpaa2/dpaa2_eventdev.c  |   4 +-
 drivers/event/dpaa2/dpaa2_eventdev_logs.h |   3 +-
 drivers/event/dpaa2/dpaa2_eventdev_selftest.c |   6 +-
 drivers/event/skeleton/skeleton_eventdev.c|   4 +-
 drivers/event/skeleton/skeleton_eventdev.h|   8 +-
 drivers/mempool/dpaa/dpaa_mempool.c   |   1 +
 drivers/mempool/dpaa/dpaa_mempool.h   |   2 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c  |   4 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool_logs.h |   3 +-
 drivers/net/atlantic/atl_logs.h   |   5 +-
 drivers/net/avp/avp_logs.h|   5 +-
 drivers/net/bnxt/bnxt.h   |   1 +
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c |   2 +-
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c  |   2 +-
 drivers/net/bnxt/bnxt_txr.c   |   2 +-
 drivers/net/dpaa/dpaa_ethdev.c|   8 +-
 drivers/net/dpaa/dpaa_ethdev.h|   3 +-
 drivers/net/dpaa2/dpaa2_ethdev.c  |   2 +-
 drivers/net/dpaa2/dpaa2_pmd_logs.h|   3 +-
 drivers/net/dpaa2/dpaa2_sparser.c |   4 +-
 drivers/net/enetc/enetc_logs.h|   3 +-
 drivers/net/enetfec/enet_pmd_logs.h   |   3 +-
 drivers/net/igc/igc_logs.h|   5 +-
 drivers/net/mana/mana.h   |   3 +-
 drivers/net/mvpp2/mrvl_ethdev.c   |   7 +-
 drivers/net/nfb/nfb.h |   5 +
 drivers/net/nfb/nfb_ethdev.c  |  24 +-
 drivers/net/nfb/nfb_rx.c  |   9 +-
 drivers/net/nfb/nfb_rx.h  |   2 +-
 drivers/net/nfb/nfb_tx.c  |   9 +-
 drivers/net/nfb/nfb_tx.h  |   2 +-
 drivers/net/octeon_ep/otx_ep_common.h |   2 +
 drivers/net/octeon_ep/otx_ep_rxtx.c   |   2 +-
 drivers/net/octeontx/octeontx_logs.h  |   3 +-
 drivers/net/pfe/pfe_logs.h|   3 +-
 drivers/net/qede/qede_logs.h  |   5 +-
 drivers/net/virtio/virtio_logs.h  |   5 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c  |   2 +-
 drivers/net/vmxnet3/vmxnet3_logs.h|   7 +-
 drivers/raw/cnxk_bphy/cnxk_bphy.c |   3 +-
 dr

[PATCH v6 01/20] drivers: use dedicated logtypes

2023-12-22 Thread Stephen Hemminger
From: David Marchand 

When a driver dedicated logtype exists, use it instead of the generic
PMD logtype.

This has been done partially automatically with:

$ for file in $(git grep -l RTE_LOG.*PMD.*fmt drivers/'**.h' \
  :^drivers/common/cnxk/roc_platform.h)
do
  tail=${file#drivers/*/*/}
  dir=${file%%$tail}
  ! git grep -q RTE_LOGTYPE_ $dir || \
{ echo $dir already done; continue; }
  git grep -hE '^extern int .*log.*;$' $file | \
  sed -ne 's/^extern int \([^ ;]*\);$/\1/p' | \
  while read logtype
  do
git grep -q 'RTE_LOG_REGISTER\(_DEFAULT\|\)('$logtype',' || \
[ "$logtype" != "${logtype%%driver}" ] || \
  { echo Skipped $logtype; continue; }
abbrev=$(echo $logtype | sed -e 's/_logtype//' | tr '[a-z]' '[A-Z]')
sed -i -e 's/^\(extern int '$logtype'.*\)$/\1\n#define RTE_LOGTYPE_' \
  $abbrev' '$logtype'/' $file
sed -i -e 's/\(RTE_LOG.*, \)PMD,/\1'$abbrev',/' $file
break
  done
done

Then a manual update for:
- common/cpt,
- common/dpaax,
- common/idpf,
- mempool/dpaa,
- net/bnxt,
- net/octeon_ep,
- raw/ifpga,
- vdpa/ifc,

Signed-off-by: David Marchand 
---
 drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h  |  3 ++-
 drivers/bus/cdx/cdx_logs.h   |  3 ++-
 drivers/bus/fslmc/fslmc_logs.h   |  3 ++-
 drivers/common/cpt/cpt_pmd_logs.h|  6 +++---
 drivers/common/dpaax/caamflib/compat.h   |  4 +++-
 drivers/common/dpaax/dpaax_logs.h|  3 ++-
 drivers/common/dpaax/version.map |  1 +
 drivers/common/idpf/idpf_common_logs.h   |  5 +++--
 drivers/crypto/caam_jr/caam_jr_log.h |  3 ++-
 drivers/crypto/dpaa2_sec/dpaa2_sec_logs.h|  3 ++-
 drivers/crypto/dpaa_sec/dpaa_sec_log.h   |  3 ++-
 drivers/dma/dpaa/dpaa_qdma_logs.h|  3 ++-
 drivers/dma/dpaa2/dpaa2_qdma_logs.h  |  3 ++-
 drivers/event/dlb2/dlb2_log.h|  3 ++-
 drivers/event/dpaa2/dpaa2_eventdev_logs.h|  3 ++-
 drivers/mempool/dpaa/dpaa_mempool.c  |  1 +
 drivers/mempool/dpaa/dpaa_mempool.h  |  2 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool_logs.h|  3 ++-
 drivers/net/atlantic/atl_logs.h  |  5 +++--
 drivers/net/avp/avp_logs.h   |  5 +++--
 drivers/net/bnxt/bnxt.h  |  1 +
 drivers/net/bnxt/bnxt_rxtx_vec_neon.c|  2 +-
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c |  2 +-
 drivers/net/bnxt/bnxt_txr.c  |  2 +-
 drivers/net/dpaa/dpaa_ethdev.h   |  3 ++-
 drivers/net/dpaa2/dpaa2_pmd_logs.h   |  3 ++-
 drivers/net/enetc/enetc_logs.h   |  3 ++-
 drivers/net/enetfec/enet_pmd_logs.h  |  3 ++-
 drivers/net/igc/igc_logs.h   |  5 +++--
 drivers/net/mana/mana.h  |  3 ++-
 drivers/net/octeon_ep/otx_ep_common.h|  2 ++
 drivers/net/octeon_ep/otx_ep_rxtx.c  |  2 +-
 drivers/net/octeontx/octeontx_logs.h |  3 ++-
 drivers/net/pfe/pfe_logs.h   |  3 ++-
 drivers/net/qede/qede_logs.h |  5 +++--
 drivers/net/virtio/virtio_logs.h |  5 +++--
 drivers/net/vmxnet3/vmxnet3_logs.h   |  7 ---
 drivers/raw/dpaa2_cmdif/dpaa2_cmdif_logs.h   |  3 ++-
 drivers/raw/ifpga/base/osdep_rte/osdep_generic.h |  5 -
 drivers/vdpa/ifc/base/ifcvf.c| 10 +-
 drivers/vdpa/ifc/base/ifcvf_osdep.h  |  7 +--
 41 files changed, 92 insertions(+), 52 deletions(-)

diff --git a/drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h 
b/drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h
index 452435ccb942..49c8d35d104d 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h
+++ b/drivers/baseband/la12xx/bbdev_la12xx_pmd_logs.h
@@ -6,6 +6,7 @@
 #define _BBDEV_LA12XX_PMD_LOGS_H_
 
 extern int bbdev_la12xx_logtype;
+#define RTE_LOGTYPE_BBDEV_LA12XX bbdev_la12xx_logtype
 
 #define rte_bbdev_log(level, fmt, ...) \
rte_log(RTE_LOG_ ## level, bbdev_la12xx_logtype, fmt "\n", \
@@ -23,6 +24,6 @@ extern int bbdev_la12xx_logtype;
 
 /* DP Logs, toggled out at compile time if level lower than current level */
 #define rte_bbdev_dp_log(level, fmt, args...) \
-   RTE_LOG_DP(level, PMD, fmt, ## args)
+   RTE_LOG_DP(level, BBDEV_LA12XX, fmt, ## args)
 
 #endif /* _BBDEV_LA12XX_PMD_LOGS_H_ */
diff --git a/drivers/bus/cdx/cdx_logs.h b/drivers/bus/cdx/cdx_logs.h
index a1046ce544a6..3a56e814d0fd 100644
--- a/drivers/bus/cdx/cdx_logs.h
+++ b/drivers/bus/cdx/cdx_logs.h
@@ -6,6 +6,7 @@
 #define CDX_LOGS_H
 
 extern int cdx_logtype_bus;
+#define RTE_LOGTYPE_CDX_BUS cdx_logtype_bus
 
 #define CDX_BUS_LOG(level, fmt, args...) \
rte_log(RTE_LOG_ ## level, cdx_logtype_bus, "cdx: " fmt "\n", \
@@ -25,7 +26,7 @@ extern int cdx_logtype_bus;
 
 /* DP Logs, toggled out at compile time if level lower than current level */
 #define CDX_BUS_DP_LOG(l

[PATCH v6 02/20] common/sfc_efx: remove use of PMD logtype

2023-12-22 Thread Stephen Hemminger
This code was implemented in a slightly different manner
than all the other logging code (for no good reason).
Make it the same and handle errors in same way as
other drivers.

Signed-off-by: Stephen Hemminger 
---
 drivers/common/sfc_efx/sfc_efx.c | 11 ++-
 drivers/common/sfc_efx/sfc_efx_log.h |  2 +-
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c
index 2dc5545760b8..5eeffb065b0d 100644
--- a/drivers/common/sfc_efx/sfc_efx.c
+++ b/drivers/common/sfc_efx/sfc_efx.c
@@ -15,7 +15,7 @@
 #include "sfc_efx_log.h"
 #include "sfc_efx.h"
 
-uint32_t sfc_efx_logtype;
+int sfc_efx_logtype;
 
 static int
 sfc_efx_kvarg_dev_class_handler(__rte_unused const char *key,
@@ -117,11 +117,4 @@ sfc_efx_family(struct rte_pci_device *pci_dev,
return rc;
 }
 
-RTE_INIT(sfc_efx_register_logtype)
-{
-   int ret;
-
-   ret = rte_log_register_type_and_pick_level("pmd.common.sfc_efx",
-  RTE_LOG_NOTICE);
-   sfc_efx_logtype = (ret < 0) ? RTE_LOGTYPE_PMD : ret;
-}
+RTE_LOG_REGISTER_DEFAULT(sfc_efx_logtype, NOTICE);
diff --git a/drivers/common/sfc_efx/sfc_efx_log.h 
b/drivers/common/sfc_efx/sfc_efx_log.h
index 694455c1b14e..1519ebdc175f 100644
--- a/drivers/common/sfc_efx/sfc_efx_log.h
+++ b/drivers/common/sfc_efx/sfc_efx_log.h
@@ -11,7 +11,7 @@
 #define _SFC_EFX_LOG_H_
 
 /** Generic driver log type */
-extern uint32_t sfc_efx_logtype;
+extern int sfc_efx_logtype;
 
 /** Log message, add a prefix and a line break */
 #define SFC_EFX_LOG(level, ...) \
-- 
2.43.0



[PATCH v6 03/20] mempool/dpaa2: use driver logtype not PMD

2023-12-22 Thread Stephen Hemminger
The driver already has macros for logging, use them.
Fixes: 7ed359909556 ("mempool/dpaa2: add functions for CMDIF")

Signed-off-by: Stephen Hemminger 
---
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c 
b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index 84371d5d1abb..4c9245cb814c 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -293,7 +293,7 @@ rte_dpaa2_mbuf_pool_bpid(struct rte_mempool *mp)
 
bp_info = mempool_to_bpinfo(mp);
if (!(bp_info->bp_list)) {
-   RTE_LOG(ERR, PMD, "DPAA2 buffer pool not configured\n");
+   DPAA2_MEMPOOL_ERR("DPAA2 buffer pool not configured");
return -ENOMEM;
}
 
@@ -307,7 +307,7 @@ rte_dpaa2_mbuf_from_buf_addr(struct rte_mempool *mp, void 
*buf_addr)
 
bp_info = mempool_to_bpinfo(mp);
if (!(bp_info->bp_list)) {
-   RTE_LOG(ERR, PMD, "DPAA2 buffer pool not configured\n");
+   DPAA2_MEMPOOL_ERR("DPAA2 buffer pool not configured");
return NULL;
}
 
-- 
2.43.0



[PATCH v6 04/20] net/dpaa: use dedicated logtype not PMD

2023-12-22 Thread Stephen Hemminger
The driver already has a logtype, but was not used in couple
places.

Fixes: 6b10d1f7bdea ("net/dpaa: update process specific device info")
Fixes: c2c4f87b1259 ("net: add macro for MAC address print")

Signed-off-by: Stephen Hemminger 
---
 drivers/net/dpaa/dpaa_ethdev.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index ef4c06db6a4d..2b497694cb02 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -2096,8 +2096,8 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
/* copy the primary mac address */
rte_ether_addr_copy(&fman_intf->mac_addr, ð_dev->data->mac_addrs[0]);
 
-   RTE_LOG(INFO, PMD, "net: dpaa: %s: " RTE_ETHER_ADDR_PRT_FMT "\n",
-   dpaa_device->name, RTE_ETHER_ADDR_BYTES(&fman_intf->mac_addr));
+   DPAA_PMD_INFO("net: dpaa: %s: " RTE_ETHER_ADDR_PRT_FMT,
+ dpaa_device->name, 
RTE_ETHER_ADDR_BYTES(&fman_intf->mac_addr));
 
if (!fman_intf->is_shared_mac) {
/* Configure error packet handling */
@@ -2166,7 +2166,7 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv,
 
ret = dpaa_dev_init_secondary(eth_dev);
if (ret != 0) {
-   RTE_LOG(ERR, PMD, "secondary dev init failed\n");
+   DPAA_PMD_ERR("secondary dev init failed");
return ret;
}
 
@@ -2182,7 +2182,7 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv,
 
if (!(default_q || fmc_q)) {
if (dpaa_fm_init()) {
-   DPAA_PMD_ERR("FM init failed\n");
+   DPAA_PMD_ERR("FM init failed");
return -1;
}
}
-- 
2.43.0



[PATCH v6 05/20] net/dpaa2: used dedicated logtype not PMD

2023-12-22 Thread Stephen Hemminger
The driver has a logtype, but was not being used in one place.

Fixes: f023d059769f ("net/dpaa2: support recycle loopback port")
Fixes: 72ec7a678e70 ("net/dpaa2: add soft parser driver")

Signed-off-by: Stephen Hemminger 
---
 drivers/net/dpaa2/dpaa2_ethdev.c  | 2 +-
 drivers/net/dpaa2/dpaa2_sparser.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 8e610b6bba30..91846fcd2f23 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -2851,7 +2851,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
return ret;
}
}
-   RTE_LOG(INFO, PMD, "%s: netdev created, connected to %s\n",
+   DPAA2_PMD_INFO("%s: netdev created, connected to %s",
eth_dev->data->name, dpaa2_dev->ep_name);
 
return 0;
diff --git a/drivers/net/dpaa2/dpaa2_sparser.c 
b/drivers/net/dpaa2/dpaa2_sparser.c
index 63463c4fbfd6..36a14526a5c5 100644
--- a/drivers/net/dpaa2/dpaa2_sparser.c
+++ b/drivers/net/dpaa2/dpaa2_sparser.c
@@ -181,7 +181,7 @@ int dpaa2_eth_load_wriop_soft_parser(struct dpaa2_dev_priv 
*priv,
 
priv->ss_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(addr));
priv->ss_offset += sp_param.size;
-   RTE_LOG(INFO, PMD, "Soft parser loaded for dpni@%d\n", priv->hw_id);
+   DPAA2_PMD_INFO("Soft parser loaded for dpni@%d", priv->hw_id);
 
rte_free(addr);
return 0;
@@ -234,6 +234,6 @@ int dpaa2_eth_enable_wriop_soft_parser(struct 
dpaa2_dev_priv *priv,
}
 
rte_free(param_addr);
-   RTE_LOG(INFO, PMD, "Soft parser enabled for dpni@%d\n", priv->hw_id);
+   DPAA2_PMD_INFO("Soft parser enabled for dpni@%d", priv->hw_id);
return 0;
 }
-- 
2.43.0



[PATCH v6 06/20] net/mrvl: do not use PMD logtype

2023-12-22 Thread Stephen Hemminger
Use the same logtype as other places in the driver.

Fixes: 9e79d810911d ("net/mvpp2: support Tx scatter/gather")
Signed-off-by: Stephen Hemminger 
---
 drivers/net/mvpp2/mrvl_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index c12364941d62..1ca13e8b89d7 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -2976,8 +2976,7 @@ mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
 */
if (nb_segs > PP2_PPIO_DESC_NUM_FRAGS) {
total_descs -= nb_segs;
-   RTE_LOG(ERR, PMD,
-   "Too many segments. Packet won't be sent.\n");
+   MRVL_LOG(ERR, "Too many segments. Packet won't be 
sent.");
break;
}
 
-- 
2.43.0



[PATCH v6 07/20] net/mvpp2: use dedicated logtype

2023-12-22 Thread Stephen Hemminger
Always use the dedicated logtype, not PMD.

Fixes: 9e79d810911d ("net/mvpp2: support Tx scatter/gather")
Signed-off-by: Stephen Hemminger 
---
 drivers/net/mvpp2/mrvl_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index 1ca13e8b89d7..a91509d92afb 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -415,10 +415,10 @@ mrvl_set_tx_function(struct rte_eth_dev *dev)
 
/* Use a simple Tx queue (no offloads, no multi segs) if possible */
if (priv->multiseg) {
-   RTE_LOG(INFO, PMD, "Using multi-segment tx callback\n");
+   MRVL_LOG(INFO, "Using multi-segment tx callback");
dev->tx_pkt_burst = mrvl_tx_sg_pkt_burst;
} else {
-   RTE_LOG(INFO, PMD, "Using single-segment tx callback\n");
+   MRVL_LOG(INFO, "Using single-segment tx callback");
dev->tx_pkt_burst = mrvl_tx_pkt_burst;
}
 }
-- 
2.43.0



[PATCH v6 08/20] net/nfb: use dynamic logtype

2023-12-22 Thread Stephen Hemminger
All drivers should be using dynamic logtype.

Fixes: 6435f9a0ac22 ("net/nfb: add new netcope driver")
Signed-off-by: Stephen Hemminger 
---
 drivers/net/nfb/nfb.h|  5 +
 drivers/net/nfb/nfb_ethdev.c | 24 ++--
 drivers/net/nfb/nfb_rx.c |  9 -
 drivers/net/nfb/nfb_rx.h |  2 +-
 drivers/net/nfb/nfb_tx.c |  9 -
 drivers/net/nfb/nfb_tx.h |  2 +-
 6 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/drivers/net/nfb/nfb.h b/drivers/net/nfb/nfb.h
index 7dc5bd29e44c..45226ee3d938 100644
--- a/drivers/net/nfb/nfb.h
+++ b/drivers/net/nfb/nfb.h
@@ -12,6 +12,11 @@
 #include 
 #include 
 
+extern int nfb_logtype;
+#define NFB_LOG(level, fmt, args...) \
+   rte_log(RTE_LOG_ ## level, nfb_logtype, "%s(): " fmt "\n", \
+   __func__, ## args)
+
 #include "nfb_rx.h"
 #include "nfb_tx.h"
 
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index defd118bd0ee..e533144efe5d 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -12,11 +12,9 @@
 #include 
 #include 
 
+#include "nfb.h"
 #include "nfb_stats.h"
-#include "nfb_rx.h"
-#include "nfb_tx.h"
 #include "nfb_rxmode.h"
-#include "nfb.h"
 
 /**
  * Default MAC addr
@@ -192,8 +190,7 @@ nfb_eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
(&nfb_timestamp_dynfield_offset,
&nfb_timestamp_rx_dynflag);
if (ret != 0) {
-   RTE_LOG(ERR, PMD, "Cannot register Rx timestamp"
-   " field/flag %d\n", ret);
+   NFB_LOG(ERR, "Cannot register Rx timestamp field/flag 
%d", ret);
nfb_close(internals->nfb);
return -rte_errno;
}
@@ -520,7 +517,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
struct rte_ether_addr eth_addr_init;
struct rte_kvargs *kvlist;
 
-   RTE_LOG(INFO, PMD, "Initializing NFB device (" PCI_PRI_FMT ")\n",
+   NFB_LOG(INFO, "Initializing NFB device (" PCI_PRI_FMT ")",
pci_addr->domain, pci_addr->bus, pci_addr->devid,
pci_addr->function);
 
@@ -536,7 +533,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
kvlist = rte_kvargs_parse(dev->device->devargs->args,
VALID_KEYS);
if (kvlist == NULL) {
-   RTE_LOG(ERR, PMD, "Failed to parse device arguments %s",
+   NFB_LOG(ERR, "Failed to parse device arguments %s",
dev->device->devargs->args);
rte_kvargs_free(kvlist);
return -EINVAL;
@@ -551,14 +548,14 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
 */
internals->nfb = nfb_open(internals->nfb_dev);
if (internals->nfb == NULL) {
-   RTE_LOG(ERR, PMD, "nfb_open(): failed to open %s",
+   NFB_LOG(ERR, "nfb_open(): failed to open %s",
internals->nfb_dev);
return -EINVAL;
}
data->nb_rx_queues = ndp_get_rx_queue_available_count(internals->nfb);
data->nb_tx_queues = ndp_get_tx_queue_available_count(internals->nfb);
 
-   RTE_LOG(INFO, PMD, "Available NDP queues RX: %u TX: %u\n",
+   NFB_LOG(INFO, "Available NDP queues RX: %u TX: %u\n",
data->nb_rx_queues, data->nb_tx_queues);
 
nfb_nc_rxmac_init(internals->nfb,
@@ -583,7 +580,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
data->mac_addrs = rte_zmalloc(data->name,
sizeof(struct rte_ether_addr) * mac_count, RTE_CACHE_LINE_SIZE);
if (data->mac_addrs == NULL) {
-   RTE_LOG(ERR, PMD, "Could not alloc space for MAC address!\n");
+   NFB_LOG(ERR, "Could not alloc space for MAC address");
nfb_close(internals->nfb);
return -EINVAL;
}
@@ -601,8 +598,7 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
 
dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
 
-   RTE_LOG(INFO, PMD, "NFB device ("
-   PCI_PRI_FMT ") successfully initialized\n",
+   NFB_LOG(INFO, "NFB device (" PCI_PRI_FMT ") successfully initialized",
pci_addr->domain, pci_addr->bus, pci_addr->devid,
pci_addr->function);
 
@@ -626,8 +622,7 @@ nfb_eth_dev_uninit(struct rte_eth_dev *dev)
 
nfb_eth_dev_close(dev);
 
-   RTE_LOG(INFO, PMD, "NFB device ("
-   PCI_PRI_FMT ") successfully uninitialized\n",
+   NFB_LOG(INFO, "NFB device (" PCI_PRI_FMT ") successfully uninitialized",
pci_addr->domain, pci_addr->bus, pci_addr->devid,
pci_addr->function);
 
@@ -690,3 +685,4 @@ static struct rte_pci_driver nfb_eth_driver = {
 RTE_PMD_REGISTER_PCI(RTE_NFB_DRIVER_NAME, nfb_eth_driver);
 RTE_PMD_REGISTER_PCI_TABLE(RTE_NFB_DRIVER_NAME, nfb_pci_id_

[PATCH v6 09/20] net/vmxnet3: used dedicated logtype not PMD

2023-12-22 Thread Stephen Hemminger
The driver has log macros, just not used in one place.

Fixes: 046f11619567 ("net/vmxnet3: support MSI-X interrupt")
Signed-off-by: Stephen Hemminger 
---
 drivers/net/vmxnet3/vmxnet3_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c 
b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index e49191718aea..4fd704045fc4 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -1919,7 +1919,7 @@ vmxnet3_interrupt_handler(void *param)
if (events == 0)
goto done;
 
-   RTE_LOG(DEBUG, PMD, "Reading events: 0x%X", events);
+   PMD_DRV_LOG(DEBUG, "Reading events: 0x%X", events);
vmxnet3_process_events(dev);
 done:
vmxnet3_enable_intr(hw, *eventIntrIdx);
-- 
2.43.0



[PATCH v6 10/20] raw/cnxk: replace PMD logtype with dynamic type

2023-12-22 Thread Stephen Hemminger
Driver should not be using PMD logtype, they should have their
own logtype.

Signed-off-by: Stephen Hemminger 
---
 drivers/common/cnxk/roc_platform.h | 16 ++-
 drivers/raw/cnxk_bphy/cnxk_bphy.c  |  3 ++-
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c  |  2 +-
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c | 31 +++---
 drivers/raw/cnxk_bphy/rte_pmd_bphy.h   |  6 +
 drivers/raw/cnxk_gpio/cnxk_gpio.c  | 21 ---
 drivers/raw/cnxk_gpio/cnxk_gpio.h  |  5 
 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 17 ++--
 8 files changed, 57 insertions(+), 44 deletions(-)

diff --git a/drivers/common/cnxk/roc_platform.h 
b/drivers/common/cnxk/roc_platform.h
index ba23b2e0d79e..9d2ea8f00965 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -265,11 +265,13 @@ extern int cnxk_logtype_tm;
 extern int cnxk_logtype_ree;
 extern int cnxk_logtype_dpi;
 
+#define RTE_LOGTYPE_CNXK cnxk_logtype_base
+
 #define plt_err(fmt, args...)  
\
-   RTE_LOG(ERR, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
-#define plt_info(fmt, args...) RTE_LOG(INFO, PMD, fmt "\n", ##args)
-#define plt_warn(fmt, args...) RTE_LOG(WARNING, PMD, fmt "\n", ##args)
-#define plt_print(fmt, args...) RTE_LOG(INFO, PMD, fmt "\n", ##args)
+   RTE_LOG(ERR, CNXK, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
+#define plt_info(fmt, args...) RTE_LOG(INFO, CNXK, fmt "\n", ##args)
+#define plt_warn(fmt, args...) RTE_LOG(WARNING, CNXK, fmt "\n", ##args)
+#define plt_print(fmt, args...) RTE_LOG(INFO, CNXK, fmt "\n", ##args)
 #define plt_dump(fmt, ...)  fprintf(stderr, fmt "\n", ##__VA_ARGS__)
 #define plt_dump_no_nl(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
 
@@ -296,11 +298,11 @@ extern int cnxk_logtype_dpi;
 
 /* Datapath logs */
 #define plt_dp_err(fmt, args...)   
\
-   RTE_LOG_DP(ERR, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
+   RTE_LOG_DP(ERR, CNXK, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
 #define plt_dp_info(fmt, args...)  
\
-   RTE_LOG_DP(INFO, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
+   RTE_LOG_DP(INFO, CNXK, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
 #define plt_dp_dbg(fmt, args...)  \
-   RTE_LOG_DP(DEBUG, PMD, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
+   RTE_LOG_DP(DEBUG, CNXK, "%s():%u " fmt "\n", __func__, __LINE__, ##args)
 
 #ifdef __cplusplus
 #define CNXK_PCI_ID(subsystem_dev, dev)
\
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy.c 
b/drivers/raw/cnxk_bphy/cnxk_bphy.c
index 15dbc4c1a637..1dbab6fb3e12 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy.c
@@ -251,7 +251,7 @@ cnxk_bphy_irq_enqueue_bufs(struct rte_rawdev *dev,
 
/* get rid of last response if any */
if (qp->rsp) {
-   RTE_LOG(WARNING, PMD, "Previous response got overwritten\n");
+   CNXK_BPHY_LOG(WARNING, "Previous response got overwritten");
rte_free(qp->rsp);
}
qp->rsp = rsp;
@@ -410,3 +410,4 @@ static struct rte_pci_driver cnxk_bphy_rawdev_pmd = {
 RTE_PMD_REGISTER_PCI(bphy_rawdev_pci_driver, cnxk_bphy_rawdev_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(bphy_rawdev_pci_driver, pci_bphy_map);
 RTE_PMD_REGISTER_KMOD_DEP(bphy_rawdev_pci_driver, "vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_bphy, bphy, INFO);
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c 
b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
index 2d8466ef918b..4358aeecc3e5 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
@@ -189,7 +189,7 @@ cnxk_bphy_cgx_process_buf(struct cnxk_bphy_cgx *cgx, 
unsigned int queue,
 
/* get rid of last response if any */
if (qp->rsp) {
-   RTE_LOG(WARNING, PMD, "Previous response got overwritten\n");
+   CNXK_BPHY_LOG(WARNING, "Previous response got overwritten");
rte_free(qp->rsp);
}
qp->rsp = rsp;
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c 
b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c
index a3021b4bb7db..f01d958661ad 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c
@@ -57,62 +57,61 @@ cnxk_bphy_cgx_dev_selftest(uint16_t dev_id)
if (ret)
break;
if (descs != 1) {
-   RTE_LOG(ERR, PMD, "Wrong number of descs reported\n");
+   CNXK_BPHY_LOG(ERR, "Wrong number of descs reported");
ret = -ENODEV;
break;
}
 
-   RTE_LOG(INFO, PMD, "Testing queue %d\n", i);
+   CNXK_BPHY_LOG(INFO, "Testing queue %d", i);
 
   

[PATCH v6 11/20] crypto/scheduler: replace use of logtype PMD

2023-12-22 Thread Stephen Hemminger
Driver has logging macro but not used everywhere.

Fixes: 6760463c9f26 ("crypto/scheduler: add mode-specific threshold parameter")
Signed-off-by: Stephen Hemminger 
---
 drivers/crypto/scheduler/scheduler_pmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/scheduler/scheduler_pmd.c 
b/drivers/crypto/scheduler/scheduler_pmd.c
index 589d092d7457..95ce893f0540 100644
--- a/drivers/crypto/scheduler/scheduler_pmd.c
+++ b/drivers/crypto/scheduler/scheduler_pmd.c
@@ -197,8 +197,8 @@ cryptodev_scheduler_create(const char *name,
return -EINVAL;
}
 
-   RTE_LOG(INFO, PMD, "  Sched mode param (%s = %s)\n",
-   param_name, param_val);
+   CR_SCHED_LOG(INFO, "  Sched mode param (%s = %s)",
+param_name, param_val);
}
}
 
-- 
2.43.0



[PATCH v6 12/20] crypto/armv8: do not use PMD logtype

2023-12-22 Thread Stephen Hemminger
Driver already has logging macros, just not used in one place.

Fixes: 169ca3db550c ("crypto/armv8: add PMD optimized for ARMv8 processors")
Signed-off-by: Stephen Hemminger 
---
 drivers/crypto/armv8/rte_armv8_pmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c 
b/drivers/crypto/armv8/rte_armv8_pmd.c
index 824a2cc7352a..3b7f45b46c33 100644
--- a/drivers/crypto/armv8/rte_armv8_pmd.c
+++ b/drivers/crypto/armv8/rte_armv8_pmd.c
@@ -833,8 +833,8 @@ cryptodev_armv8_crypto_uninit(struct rte_vdev_device *vdev)
if (name == NULL)
return -EINVAL;
 
-   RTE_LOG(INFO, PMD,
-   "Closing ARMv8 crypto device %s on numa socket %u\n",
+   ARVM8_CRYTPO_LOG_INFO(
+   "Closing ARMv8 crypto device %s on numa socket %u",
name, rte_socket_id());
 
cryptodev = rte_cryptodev_pmd_get_named_dev(name);
-- 
2.43.0



[PATCH v6 13/20] crypto/ccp: do not use PMD logtype

2023-12-22 Thread Stephen Hemminger
This driver has logging macros but not used consistently.

Fixes: ef4b04f87fa6 ("crypto/ccp: support device init")
Signed-off-by: Stephen Hemminger 
---
 drivers/crypto/ccp/rte_ccp_pmd.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c
index a5271d72273d..46a9275e3743 100644
--- a/drivers/crypto/ccp/rte_ccp_pmd.c
+++ b/drivers/crypto/ccp/rte_ccp_pmd.c
@@ -194,8 +194,7 @@ cryptodev_ccp_remove(struct rte_pci_device *pci_dev)
 
ccp_pmd_init_done = 0;
 
-   RTE_LOG(INFO, PMD, "Closing ccp device %s on numa socket %u\n",
-   name, rte_socket_id());
+   CCP_LOG_INFO("Closing ccp device %s on numa socket %u", name, 
rte_socket_id());
 
return rte_cryptodev_pmd_destroy(dev);
 }
@@ -228,7 +227,7 @@ cryptodev_ccp_create(const char *name,
}
cryptodev_cnt++;
 
-   CCP_LOG_DBG("CCP : Crypto device count = %d\n", cryptodev_cnt);
+   CCP_LOG_DBG("CCP : Crypto device count = %d", cryptodev_cnt);
dev->device = &pci_dev->device;
dev->device->driver = &pci_drv->driver;
dev->driver_id = ccp_cryptodev_driver_id;
@@ -279,7 +278,7 @@ cryptodev_ccp_probe(struct rte_pci_driver *pci_drv 
__rte_unused,
};
 
if (ccp_pmd_init_done) {
-   RTE_LOG(INFO, PMD, "CCP PMD already initialized\n");
+   CCP_LOG_INFO("CCP PMD already initialized");
return -EFAULT;
}
rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
@@ -288,11 +287,11 @@ cryptodev_ccp_probe(struct rte_pci_driver *pci_drv 
__rte_unused,
 
init_params.def_p.max_nb_queue_pairs = CCP_PMD_MAX_QUEUE_PAIRS;
 
-   RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name,
+   CCP_LOG_INFO("Initialising %s on NUMA node %d", name,
init_params.def_p.socket_id);
-   RTE_LOG(INFO, PMD, "Max number of queue pairs = %d\n",
+   CCP_LOG_INFO("Max number of queue pairs = %d",
init_params.def_p.max_nb_queue_pairs);
-   RTE_LOG(INFO, PMD, "Authentication offload to %s\n",
+   CCP_LOG_INFO("Authentication offload to %s",
((init_params.auth_opt == 0) ? "CCP" : "CPU"));
 
rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
-- 
2.43.0



[PATCH v6 15/20] crypto/dpaa_sec, crypto/dpaa2_sec: use dedicated logtype

2023-12-22 Thread Stephen Hemminger
A couple of messages were using RTE_LOGTYPE_PMD when dedicated
logtype was already available.

Fixes: fe3688ba7950 ("crypto/dpaa_sec: support event crypto adapter")
Fixes: bffc7d561c81 ("crypto/dpaa2_sec: support event crypto adapter")
Signed-off-by: Stephen Hemminger 
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  6 ++---
 drivers/crypto/dpaa_sec/dpaa_sec.c  | 30 ++---
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c 
b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index bb5a2c629e53..1cae6c45059e 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -4153,7 +4153,7 @@ dpaa2_sec_eventq_attach(const struct rte_cryptodev *dev,
ret = dpseci_set_opr(dpseci, CMD_PRI_LOW, priv->token,
   qp_id, OPR_OPT_CREATE, &ocfg);
if (ret) {
-   RTE_LOG(ERR, PMD, "Error setting opr: ret: %d\n", ret);
+   DPAA2_SEC_ERR("Error setting opr: ret: %d", ret);
return ret;
}
qp->tx_vq.cb_eqresp_free = dpaa2_sec_free_eqresp_buf;
@@ -4163,7 +4163,7 @@ dpaa2_sec_eventq_attach(const struct rte_cryptodev *dev,
ret = dpseci_set_rx_queue(dpseci, CMD_PRI_LOW, priv->token,
  qp_id, &cfg);
if (ret) {
-   RTE_LOG(ERR, PMD, "Error in dpseci_set_queue: ret: %d\n", ret);
+   DPAA2_SEC_ERR("Error in dpseci_set_queue: ret: %d", ret);
return ret;
}
 
@@ -4188,7 +4188,7 @@ dpaa2_sec_eventq_detach(const struct rte_cryptodev *dev,
ret = dpseci_set_rx_queue(dpseci, CMD_PRI_LOW, priv->token,
  qp_id, &cfg);
if (ret)
-   RTE_LOG(ERR, PMD, "Error in dpseci_set_queue: ret: %d\n", ret);
+   DPAA2_SEC_ERR("Error in dpseci_set_queue: ret: %d", ret);
 
return ret;
 }
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c 
b/drivers/crypto/dpaa_sec/dpaa_sec.c
index a301e8edb2a4..e7ebcbe2af22 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -102,7 +102,7 @@ ern_sec_fq_handler(struct qman_portal *qm __rte_unused,
   struct qman_fq *fq,
   const struct qm_mr_entry *msg)
 {
-   DPAA_SEC_DP_ERR("sec fq %d error, RC = %x, seqnum = %x\n",
+   DPAA_SEC_DP_ERR("sec fq %d error, RC = %x, seqnum = %x",
fq->fqid, msg->ern.rc, msg->ern.seqnum);
 }
 
@@ -849,7 +849,7 @@ dpaa_sec_deq(struct dpaa_sec_qp *qp, struct rte_crypto_op 
**ops, int nb_ops)
op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
} else {
if (dpaa_sec_dp_dump > DPAA_SEC_DP_NO_DUMP) {
-   DPAA_SEC_DP_WARN("SEC return err:0x%x\n",
+   DPAA_SEC_DP_WARN("SEC return err:0x%x",
  ctx->fd_status);
if (dpaa_sec_dp_dump > DPAA_SEC_DP_ERR_DUMP)
dpaa_sec_dump(ctx, qp);
@@ -1943,8 +1943,7 @@ dpaa_sec_enqueue_burst(void *qp, struct rte_crypto_op 
**ops,
}
} else if (unlikely(ses->qp[rte_lcore_id() %
MAX_DPAA_CORES] != qp)) {
-   DPAA_SEC_DP_ERR("Old:sess->qp = %p"
-   " New qp = %p\n",
+   DPAA_SEC_DP_ERR("Old: sess->qp = %p New qp = 
%p",
ses->qp[rte_lcore_id() %
MAX_DPAA_CORES], qp);
frames_to_send = loop;
@@ -2054,7 +2053,7 @@ dpaa_sec_enqueue_burst(void *qp, struct rte_crypto_op 
**ops,
fd->cmd = 0x8000 |
*((uint32_t *)((uint8_t *)op +
ses->pdcp.hfn_ovd_offset));
-   DPAA_SEC_DP_DEBUG("Per packet HFN: %x, 
ovd:%u\n",
+   DPAA_SEC_DP_DEBUG("Per packet HFN: %x, ovd:%u",
*((uint32_t *)((uint8_t *)op +
ses->pdcp.hfn_ovd_offset)),
ses->pdcp.hfn_ovd);
@@ -2095,7 +2094,7 @@ dpaa_sec_dequeue_burst(void *qp, struct rte_crypto_op 
**ops,
dpaa_qp->rx_pkts += num_rx;
dpaa_qp->rx_errs += nb_ops - num_rx;
 
-   DPAA_SEC_DP_DEBUG("SEC Received %d Packets\n", num_rx);
+   DPAA_SEC_DP_DEBUG("SEC Received %d Packets", num_rx);
 
return num_rx;
 }
@@ -2158,7 +2157,7 @@ dpaa_sec_queue_pair_setup(struct rte_cryptodev *dev, 
uint16_t qp_id,
NULL, NULL, NULL, NULL,
   

[PATCH v6 14/20] crypto/caam_jr: use dedicated logtype

2023-12-22 Thread Stephen Hemminger
The driver has macro and logtype but not used in a couple places.
Also, remove extraneous newlines.

Fixes: af7c9b5e9ce7 ("crypto/caam_jr: introduce basic driver")
Signed-off-by: Stephen Hemminger 
---
 drivers/crypto/caam_jr/caam_jr.c | 46 +---
 drivers/crypto/caam_jr/caam_jr_log.h | 12 
 drivers/crypto/caam_jr/caam_jr_uio.c |  4 +--
 3 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index b55258689b49..d3b42d8e1b91 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -123,10 +123,8 @@ void caam_jr_stats_get(struct rte_cryptodev *dev,
stats->dequeued_count += qp[i]->rx_pkts;
stats->enqueue_err_count += qp[i]->tx_errs;
stats->dequeue_err_count += qp[i]->rx_errs;
-   CAAM_JR_INFO("extra stats:\n\tRX Poll ERR = %" PRIu64
-"\n\tTX Ring Full = %" PRIu64,
-qp[i]->rx_poll_err,
-qp[i]->tx_ring_full);
+   CAAM_JR_INFO("extra stats: RX Poll ERR = %" PRIu64 "TX Ring 
Full = %" PRIu64,
+qp[i]->rx_poll_err, qp[i]->tx_ring_full);
}
 }
 
@@ -309,7 +307,7 @@ caam_jr_prep_cdb(struct caam_jr_session *ses)
 
cdb = caam_jr_dma_mem_alloc(L1_CACHE_BYTES, sizeof(struct sec_cdb));
if (!cdb) {
-   CAAM_JR_ERR("failed to allocate memory for cdb\n");
+   CAAM_JR_ERR("failed to allocate memory for cdb");
return -1;
}
 
@@ -606,7 +604,7 @@ hw_poll_job_ring(struct sec_job_ring_t *job_ring,
/*TODO for multiple ops, packets*/
ctx = container_of(current_desc, struct caam_jr_op_ctx, jobdes);
if (unlikely(sec_error_code)) {
-   CAAM_JR_ERR("desc at cidx %d generated error 0x%x\n",
+   CAAM_JR_ERR("desc at cidx %d generated error 0x%x",
job_ring->cidx, sec_error_code);
hw_handle_job_ring_error(job_ring, sec_error_code);
//todo improve with exact errors
@@ -1368,7 +1366,7 @@ caam_jr_enqueue_op(struct rte_crypto_op *op, struct 
caam_jr_qp *qp)
}
 
if (unlikely(!ses->qp || ses->qp != qp)) {
-   CAAM_JR_DP_DEBUG("Old:sess->qp=%p New qp = %p\n", ses->qp, qp);
+   CAAM_JR_DP_DEBUG("Old:sess->qp=%p New qp = %p", ses->qp, qp);
ses->qp = qp;
caam_jr_prep_cdb(ses);
}
@@ -1554,7 +1552,7 @@ caam_jr_cipher_init(struct rte_cryptodev *dev 
__rte_unused,
session->cipher_key.data = rte_zmalloc(NULL, xform->cipher.key.length,
   RTE_CACHE_LINE_SIZE);
if (session->cipher_key.data == NULL && xform->cipher.key.length > 0) {
-   CAAM_JR_ERR("No Memory for cipher key\n");
+   CAAM_JR_ERR("No Memory for cipher key");
return -ENOMEM;
}
session->cipher_key.length = xform->cipher.key.length;
@@ -1576,7 +1574,7 @@ caam_jr_auth_init(struct rte_cryptodev *dev __rte_unused,
session->auth_key.data = rte_zmalloc(NULL, xform->auth.key.length,
 RTE_CACHE_LINE_SIZE);
if (session->auth_key.data == NULL && xform->auth.key.length > 0) {
-   CAAM_JR_ERR("No Memory for auth key\n");
+   CAAM_JR_ERR("No Memory for auth key");
return -ENOMEM;
}
session->auth_key.length = xform->auth.key.length;
@@ -1602,7 +1600,7 @@ caam_jr_aead_init(struct rte_cryptodev *dev __rte_unused,
session->aead_key.data = rte_zmalloc(NULL, xform->aead.key.length,
 RTE_CACHE_LINE_SIZE);
if (session->aead_key.data == NULL && xform->aead.key.length > 0) {
-   CAAM_JR_ERR("No Memory for aead key\n");
+   CAAM_JR_ERR("No Memory for aead key");
return -ENOMEM;
}
session->aead_key.length = xform->aead.key.length;
@@ -1755,7 +1753,7 @@ caam_jr_set_ipsec_session(__rte_unused struct 
rte_cryptodev *dev,
   RTE_CACHE_LINE_SIZE);
if (session->cipher_key.data == NULL &&
cipher_xform->key.length > 0) {
-   CAAM_JR_ERR("No Memory for cipher key\n");
+   CAAM_JR_ERR("No Memory for cipher key");
return -ENOMEM;
}
 
@@ -1765,7 +1763,7 @@ caam_jr_set_ipsec_session(__rte_unused struct 
rte_cryptodev *dev,
RTE_CACHE_LINE_SIZE);
if (session->auth_key.data == NULL &&
auth_xform->key.length > 0) {
-   CAAM_JR_ERR("No Memory for auth key\n");
+   CAAM_JR_ERR("No Memory for auth key");
rte_free(session->cipher_key.

[PATCH v6 16/20] event/dlb2: use dedicated logtype

2023-12-22 Thread Stephen Hemminger
Driver was using RTE_LOGTYPE_PMD when it had its own logtype.
Fixes: 5433956d5185 ("event/dlb2: add eventdev probe")

Signed-off-by: Stephen Hemminger 
---
 drivers/event/dlb2/dlb2.c | 275 +++---
 1 file changed, 137 insertions(+), 138 deletions(-)

diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index 050ace0904b4..419876490780 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -169,7 +169,7 @@ dlb2_hw_query_resources(struct dlb2_eventdev *dlb2)
ret = dlb2_iface_get_num_resources(handle,
   &dlb2->hw_rsrc_query_results);
if (ret) {
-   DLB2_LOG_ERR("ioctl get dlb2 num resources, err=%d\n", ret);
+   DLB2_LOG_ERR("ioctl get dlb2 num resources, err=%d", ret);
return ret;
}
 
@@ -259,7 +259,7 @@ set_producer_coremask(const char *key __rte_unused,
const char **mask_str = opaque;
 
if (value == NULL || opaque == NULL) {
-   DLB2_LOG_ERR("NULL pointer\n");
+   DLB2_LOG_ERR("NULL pointer");
return -EINVAL;
}
 
@@ -293,7 +293,7 @@ set_max_cq_depth(const char *key __rte_unused,
int ret;
 
if (value == NULL || opaque == NULL) {
-   DLB2_LOG_ERR("NULL pointer\n");
+   DLB2_LOG_ERR("NULL pointer");
return -EINVAL;
}
 
@@ -304,7 +304,7 @@ set_max_cq_depth(const char *key __rte_unused,
if (*max_cq_depth < DLB2_MIN_CQ_DEPTH_OVERRIDE ||
*max_cq_depth > DLB2_MAX_CQ_DEPTH_OVERRIDE ||
!rte_is_power_of_2(*max_cq_depth)) {
-   DLB2_LOG_ERR("dlb2: max_cq_depth %d and %d and a power of 2\n",
+   DLB2_LOG_ERR("dlb2: max_cq_depth %d and %d and a power of 2",
 DLB2_MIN_CQ_DEPTH_OVERRIDE,
 DLB2_MAX_CQ_DEPTH_OVERRIDE);
return -EINVAL;
@@ -322,7 +322,7 @@ set_max_enq_depth(const char *key __rte_unused,
int ret;
 
if (value == NULL || opaque == NULL) {
-   DLB2_LOG_ERR("NULL pointer\n");
+   DLB2_LOG_ERR("NULL pointer");
return -EINVAL;
}
 
@@ -333,7 +333,7 @@ set_max_enq_depth(const char *key __rte_unused,
if (*max_enq_depth < DLB2_MIN_ENQ_DEPTH_OVERRIDE ||
*max_enq_depth > DLB2_MAX_ENQ_DEPTH_OVERRIDE ||
!rte_is_power_of_2(*max_enq_depth)) {
-   DLB2_LOG_ERR("dlb2: max_enq_depth %d and %d and a power of 2\n",
+   DLB2_LOG_ERR("dlb2: max_enq_depth %d and %d and a power of 2",
DLB2_MIN_ENQ_DEPTH_OVERRIDE,
DLB2_MAX_ENQ_DEPTH_OVERRIDE);
return -EINVAL;
@@ -351,7 +351,7 @@ set_max_num_events(const char *key __rte_unused,
int ret;
 
if (value == NULL || opaque == NULL) {
-   DLB2_LOG_ERR("NULL pointer\n");
+   DLB2_LOG_ERR("NULL pointer");
return -EINVAL;
}
 
@@ -361,7 +361,7 @@ set_max_num_events(const char *key __rte_unused,
 
if (*max_num_events < 0 || *max_num_events >
DLB2_MAX_NUM_LDB_CREDITS) {
-   DLB2_LOG_ERR("dlb2: max_num_events must be between 0 and %d\n",
+   DLB2_LOG_ERR("dlb2: max_num_events must be between 0 and %d",
 DLB2_MAX_NUM_LDB_CREDITS);
return -EINVAL;
}
@@ -378,7 +378,7 @@ set_num_dir_credits(const char *key __rte_unused,
int ret;
 
if (value == NULL || opaque == NULL) {
-   DLB2_LOG_ERR("NULL pointer\n");
+   DLB2_LOG_ERR("NULL pointer");
return -EINVAL;
}
 
@@ -388,7 +388,7 @@ set_num_dir_credits(const char *key __rte_unused,
 
if (*num_dir_credits < 0 ||
*num_dir_credits > DLB2_MAX_NUM_DIR_CREDITS(DLB2_HW_V2)) {
-   DLB2_LOG_ERR("dlb2: num_dir_credits must be between 0 and %d\n",
+   DLB2_LOG_ERR("dlb2: num_dir_credits must be between 0 and %d",
 DLB2_MAX_NUM_DIR_CREDITS(DLB2_HW_V2));
return -EINVAL;
}
@@ -405,7 +405,7 @@ set_dev_id(const char *key __rte_unused,
int ret;
 
if (value == NULL || opaque == NULL) {
-   DLB2_LOG_ERR("NULL pointer\n");
+   DLB2_LOG_ERR("NULL pointer");
return -EINVAL;
}
 
@@ -425,7 +425,7 @@ set_poll_interval(const char *key __rte_unused,
int ret;
 
if (value == NULL || opaque == NULL) {
-   DLB2_LOG_ERR("NULL pointer\n");
+   DLB2_LOG_ERR("NULL pointer");
return -EINVAL;
}
 
@@ -445,7 +445,7 @@ set_port_cos(const char *key __rte_unused,
int first, last, cos_id, i;
 
if (value == NULL || opaque == NULL) {
-   DLB2_LOG_ERR("NULL pointer\n");
+   DLB2_LOG_ERR("NULL pointer");
return -EINVAL;

[PATCH v6 17/20] event/dpaa, event/dpaa2: use dedicated logtype

2023-12-22 Thread Stephen Hemminger
Do not use RTE_LOGTYPE_PMD.

Fixes: b0f66a68ca74 ("event/dpaa: support crypto adapter")
Fixes: 4ab57b042e7c ("event/dpaa2: affine portal at runtime during I/O")
Signed-off-by: Stephen Hemminger 
---
 drivers/event/dpaa/dpaa_eventdev.c| 2 +-
 drivers/event/dpaa2/dpaa2_eventdev.c  | 4 ++--
 drivers/event/dpaa2/dpaa2_eventdev_selftest.c | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/event/dpaa/dpaa_eventdev.c 
b/drivers/event/dpaa/dpaa_eventdev.c
index 46a9b88c73ae..a8e5c3421df1 100644
--- a/drivers/event/dpaa/dpaa_eventdev.c
+++ b/drivers/event/dpaa/dpaa_eventdev.c
@@ -1025,7 +1025,7 @@ dpaa_event_dev_create(const char *name, const char 
*params, struct rte_vdev_devi
eventdev->txa_enqueue = dpaa_eventdev_txa_enqueue;
eventdev->txa_enqueue_same_dest = dpaa_eventdev_txa_enqueue_same_dest;
 
-   RTE_LOG(INFO, PMD, "%s eventdev added", name);
+   DPAA_EVENTDEV_INFO("%s eventdev added", name);
 
/* For secondary processes, the primary has done all the work */
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c 
b/drivers/event/dpaa2/dpaa2_eventdev.c
index dd4e64395fe5..85c2dbd998dd 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev.c
@@ -1141,7 +1141,7 @@ dpaa2_eventdev_create(const char *name, struct 
rte_vdev_device *vdev)
priv->max_event_queues++;
} while (dpcon_dev && dpci_dev);
 
-   RTE_LOG(INFO, PMD, "%s eventdev created\n", name);
+   DPAA2_EVENTDEV_INFO("%s eventdev created", name);
 
 done:
event_dev_probing_finish(eventdev);
@@ -1178,7 +1178,7 @@ dpaa2_eventdev_destroy(const char *name)
}
priv->max_event_queues = 0;
 
-   RTE_LOG(INFO, PMD, "%s eventdev cleaned\n", name);
+   DPAA2_EVENTDEV_INFO("%s eventdev cleaned", name);
return 0;
 }
 
diff --git a/drivers/event/dpaa2/dpaa2_eventdev_selftest.c 
b/drivers/event/dpaa2/dpaa2_eventdev_selftest.c
index 427aff4b..9d4938efe6aa 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev_selftest.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev_selftest.c
@@ -774,15 +774,15 @@ static void dpaa2_test_run(int (*setup)(void), void 
(*tdown)(void),
int (*test)(void), const char *name)
 {
if (setup() < 0) {
-   RTE_LOG(INFO, PMD, "Error setting up test %s", name);
+   DPAA2_EVENTDEV_INFO("Error setting up test %s", name);
unsupported++;
} else {
if (test() < 0) {
failed++;
-   RTE_LOG(INFO, PMD, "%s Failed\n", name);
+   DPAA2_EVENTDEV_INFO("%s Failed", name);
} else {
passed++;
-   RTE_LOG(INFO, PMD, "%s Passed", name);
+   DPAA2_EVENTDEV_INFO("%s Passed", name);
}
}
 
-- 
2.43.0



[PATCH v6 18/20] event/skeleton: replace logtype PMD with dynamic type

2023-12-22 Thread Stephen Hemminger
The skeleton is supposed to match current best practices.
Change it to use dynamic logtype.

Signed-off-by: Stephen Hemminger 
---
 drivers/event/skeleton/skeleton_eventdev.c | 4 ++--
 drivers/event/skeleton/skeleton_eventdev.h | 8 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/event/skeleton/skeleton_eventdev.c 
b/drivers/event/skeleton/skeleton_eventdev.c
index 7df032b7daa1..848b3be82c40 100644
--- a/drivers/event/skeleton/skeleton_eventdev.c
+++ b/drivers/event/skeleton/skeleton_eventdev.c
@@ -457,8 +457,7 @@ skeleton_eventdev_probe(struct rte_vdev_device *vdev)
const char *name;
 
name = rte_vdev_device_name(vdev);
-   RTE_LOG(INFO, PMD, "Initializing %s on NUMA node %d\n", name,
-   rte_socket_id());
+   PMD_DRV_LOG(INFO, "Initializing %s on NUMA node %d", name, 
rte_socket_id());
return skeleton_eventdev_create(name, rte_socket_id(), vdev);
 }
 
@@ -479,3 +478,4 @@ static struct rte_vdev_driver vdev_eventdev_skeleton_pmd = {
 };
 
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_SKELETON_PMD, vdev_eventdev_skeleton_pmd);
+RTE_LOG_REGISTER_DEFAULT(skeleton_eventdev_logtype, INFO);
diff --git a/drivers/event/skeleton/skeleton_eventdev.h 
b/drivers/event/skeleton/skeleton_eventdev.h
index 9193f45f4782..9c1ed4ec5755 100644
--- a/drivers/event/skeleton/skeleton_eventdev.h
+++ b/drivers/event/skeleton/skeleton_eventdev.h
@@ -8,9 +8,12 @@
 #include 
 #include 
 
+extern int skeleton_eventdev_logtype;
+
 #ifdef RTE_LIBRTE_PMD_SKELETON_EVENTDEV_DEBUG
 #define PMD_DRV_LOG(level, fmt, args...) \
-   RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+   rte_log(RTE_LOG_ ## level, skeleton_eventdev_logtype, \
+   "%s(): " fmt "\n", __func__, ## args)
 #define PMD_DRV_FUNC_TRACE() PMD_DRV_LOG(DEBUG, ">>")
 #else
 #define PMD_DRV_LOG(level, fmt, args...) do { } while (0)
@@ -18,7 +21,8 @@
 #endif
 
 #define PMD_DRV_ERR(fmt, args...) \
-   RTE_LOG(ERR, PMD, "%s(): " fmt "\n", __func__, ## args)
+   rte_log(RTE_LOG_ERR, skeleton_eventdev_logtype, \
+   "%s(): " fmt "\n", __func__, ## args)
 
 struct skeleton_eventdev {
uintptr_t reg_base;
-- 
2.43.0



[PATCH v6 20/20] log: remove PMD log type

2023-12-22 Thread Stephen Hemminger
All uses of PMD logtype in core DPDK have been replaced
by dynamic types.

Signed-off-by: Stephen Hemminger 
---
 lib/log/log.c | 1 -
 lib/log/rte_log.h | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/log/log.c b/lib/log/log.c
index ab06132a98a1..07cbc66ebfa8 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -352,7 +352,6 @@ struct logtype {
 
 static const struct logtype logtype_strings[] = {
{RTE_LOGTYPE_EAL,"lib.eal"},
-   {RTE_LOGTYPE_PMD,"pmd"},
{RTE_LOGTYPE_PORT,   "lib.port"},
{RTE_LOGTYPE_TABLE,  "lib.table"},
{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
diff --git a/lib/log/rte_log.h b/lib/log/rte_log.h
index 5ba198ba2484..9ed51eb96014 100644
--- a/lib/log/rte_log.h
+++ b/lib/log/rte_log.h
@@ -32,7 +32,7 @@ extern "C" {
 /* was RTE_LOGTYPE_RING */
 /* was RTE_LOGTYPE_MEMPOOL */
 /* was RTE_LOGTYPE_TIMER */
-#define RTE_LOGTYPE_PMD5 /**< Log related to poll mode driver. */
+/* was RTE_LOGTYPE_PMD */
 /* was RTE_LOGTYPE_HASH */
 /* was RTE_LOGTYPE_LPM */
 /* was RTE_LOGTYPE_KNI */
-- 
2.43.0



[PATCH v6 19/20] examples/fips_validation: replace use of PMD logtype

2023-12-22 Thread Stephen Hemminger
Replace PMD with USER1 since that is already used in main

Fixes: 41d561cbdd24 ("examples/fips_validation: add power on self test")
Signed-off-by: Stephen Hemminger 
---
 examples/fips_validation/fips_dev_self_test.c | 44 +--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/examples/fips_validation/fips_dev_self_test.c 
b/examples/fips_validation/fips_dev_self_test.c
index b17f664a5eda..667f5da4e7d9 100644
--- a/examples/fips_validation/fips_dev_self_test.c
+++ b/examples/fips_validation/fips_dev_self_test.c
@@ -1032,7 +1032,7 @@ prepare_cipher_xform(uint8_t dev_id,
 
cap = rte_cryptodev_sym_capability_get(dev_id, &cap_idx);
if (!cap) {
-   RTE_LOG(ERR, PMD, "Failed to get capability for cdev %u\n",
+   RTE_LOG(ERR, USER1, "Failed to get capability for cdev %u\n",
dev_id);
return -EACCES;
}
@@ -1040,7 +1040,7 @@ prepare_cipher_xform(uint8_t dev_id,
if (rte_cryptodev_sym_capability_check_cipher(cap,
cipher_xform->key.length,
cipher_xform->iv.length) != 0) {
-   RTE_LOG(ERR, PMD, "PMD %s key length %u IV length %u\n",
+   RTE_LOG(ERR, USER1, "PMD %s key length %u IV length %u\n",
rte_cryptodev_name_get(dev_id),
cipher_xform->key.length,
cipher_xform->iv.length);
@@ -1088,7 +1088,7 @@ prepare_auth_xform(uint8_t dev_id,
 
cap = rte_cryptodev_sym_capability_get(dev_id, &cap_idx);
if (!cap) {
-   RTE_LOG(ERR, PMD, "Failed to get capability for cdev %u\n",
+   RTE_LOG(ERR, USER1, "Failed to get capability for cdev %u\n",
dev_id);
return -EACCES;
}
@@ -1096,7 +1096,7 @@ prepare_auth_xform(uint8_t dev_id,
if (rte_cryptodev_sym_capability_check_auth(cap,
auth_xform->key.length,
auth_xform->digest_length, 0) != 0) {
-   RTE_LOG(ERR, PMD, "PMD %s key length %u Digest length %u\n",
+   RTE_LOG(ERR, USER1, "PMD %s key length %u Digest length %u\n",
rte_cryptodev_name_get(dev_id),
auth_xform->key.length,
auth_xform->digest_length);
@@ -1147,7 +1147,7 @@ prepare_aead_xform(uint8_t dev_id,
 
cap = rte_cryptodev_sym_capability_get(dev_id, &cap_idx);
if (!cap) {
-   RTE_LOG(ERR, PMD, "Failed to get capability for cdev %u\n",
+   RTE_LOG(ERR, USER1, "Failed to get capability for cdev %u\n",
dev_id);
return -EACCES;
}
@@ -1156,7 +1156,7 @@ prepare_aead_xform(uint8_t dev_id,
aead_xform->key.length,
aead_xform->digest_length, aead_xform->aad_length,
aead_xform->iv.length) != 0) {
-   RTE_LOG(ERR, PMD,
+   RTE_LOG(ERR, USER1,
"PMD %s key_len %u tag_len %u aad_len %u iv_len %u\n",
rte_cryptodev_name_get(dev_id),
aead_xform->key.length,
@@ -1195,7 +1195,7 @@ prepare_cipher_op(struct rte_crypto_op *op,
 
dst = (uint8_t *)rte_pktmbuf_append(mbuf, len);
if (!dst) {
-   RTE_LOG(ERR, PMD, "Error %i: MBUF too small\n", -ENOMEM);
+   RTE_LOG(ERR, USER1, "Error %i: MBUF too small\n", -ENOMEM);
return -ENOMEM;
}
 
@@ -1219,7 +1219,7 @@ prepare_auth_op(struct rte_crypto_op *op,
uint8_t *dst;
 
if (vec->input.len + vec->digest.len > RTE_MBUF_MAX_NB_SEGS) {
-   RTE_LOG(ERR, PMD, "Error %i: Test data too long (%u).\n",
+   RTE_LOG(ERR, USER1, "Error %i: Test data too long (%u).\n",
-ENOMEM, vec->input.len + vec->digest.len);
return -ENOMEM;
}
@@ -1229,7 +1229,7 @@ prepare_auth_op(struct rte_crypto_op *op,
dst = (uint8_t *)rte_pktmbuf_append(mbuf, vec->input.len +
vec->digest.len);
if (!dst) {
-   RTE_LOG(ERR, PMD, "Error %i: MBUF too small\n", -ENOMEM);
+   RTE_LOG(ERR, USER1, "Error %i: MBUF too small\n", -ENOMEM);
return -ENOMEM;
}
 
@@ -1274,7 +1274,7 @@ prepare_aead_op(struct rte_crypto_op *op,
memcpy(iv, vec->iv.data, vec->iv.len);
 
if (len + vec->digest.len > RTE_MBUF_MAX_NB_SEGS) {
-   RTE_LOG(ERR, PMD, "Error %i: Test data too long (%u).\n",
+   RTE_LOG(ERR, USER1, "Error %i: Test data too long (%u).\n",
-ENOMEM, len + vec->digest.len);
return -ENOMEM;
}
@@ -1282,7 +1282,7 @@ prepare_aead_op(struct rte_crypto_op *op,
dst = (uint8_t *)rte_pktmb

Depends-on patchseries support via git-pw or patchwork

2023-12-22 Thread Patrick Robb
Hi all,

As some of you know from discussions at DPDK CI meetings, Adam from UNH is
writing a script which leverages git-pw, and takes as arguments a patch
series patchwork id, patchwork project, and pw token, and produces a
project artifact for CI testing purposes. Starting in January we will use
it for applying patches to DPDK and creating our dpdk.tar.gz artifacts for
testing. And, we will submit it to the dpdk-ci repo.

Anyways, when we originally discussed the idea, Thomas suggested that we
implement the depends-on functionality by contributing to the git-pw
project, as opposed to implementing the depend-on support in the create
artifact script itself. Adam did create a github issue on the git-pw
project in order to poll the community for interest in this feature, and
one of the patchwork maintainers chimed in to suggest that rather than
implementing the feature on the client side via git-pw, it should simply be
implemented for patchwork itself. That way if it's patchwork server side
and exposed via the api, other client side tools like pwclient can also
receive the benefits.

I just wanted to flag this on the ci mailing list so that anyone with
thoughts could submit them on the Github issue, which you can find here:
https://github.com/getpatchwork/git-pw/issues/71

Thanks Adam for pushing this effort forward.


Re: [PATCH v6 12/20] crypto/armv8: do not use PMD logtype

2023-12-22 Thread Stephen Hemminger
On Fri, 22 Dec 2023 09:11:45 -0800
Stephen Hemminger  wrote:

>  
> - RTE_LOG(INFO, PMD,
> - "Closing ARMv8 crypto device %s on numa socket %u\n",
> + ARVM8_CRYTPO_LOG_INFO(
> + "Closing ARMv8 crypto device %s on numa socket %u",
>   name, rte_socket_id

Typo here will fix in next version


[PATCH 0/3] Remove last library static logtypes

2023-12-22 Thread Stephen Hemminger
These three libraries were depending on static logtypes.

Stephen Hemminger (3):
  port: convert to dynamic log type
  table: convert to dynamic logtype
  pipeline: convert to a dynamic logtype

 lib/log/log.c   | 3 ---
 lib/log/rte_log.h   | 6 +++---
 lib/pipeline/rte_pipeline.c | 3 +++
 lib/port/meson.build| 1 +
 lib/port/port_log.c | 7 +++
 lib/port/port_log.h | 4 +++-
 lib/table/meson.build   | 2 ++
 lib/table/table_log.c   | 7 +++
 lib/table/table_log.h   | 4 +++-
 9 files changed, 29 insertions(+), 8 deletions(-)
 create mode 100644 lib/port/port_log.c
 create mode 100644 lib/table/table_log.c

-- 
2.43.0



[PATCH 1/3] port: convert to dynamic log type

2023-12-22 Thread Stephen Hemminger
Replace static RTE_LOGTYPE_PORT with dynamic type.
Since there are several types of port do initialization
in a short standalone file.

Signed-off-by: Stephen Hemminger 
---
 lib/log/log.c| 1 -
 lib/log/rte_log.h| 2 +-
 lib/port/meson.build | 1 +
 lib/port/port_log.h  | 4 +++-
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/log/log.c b/lib/log/log.c
index ab06132a98a1..853acaf07eb2 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -353,7 +353,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
{RTE_LOGTYPE_EAL,"lib.eal"},
{RTE_LOGTYPE_PMD,"pmd"},
-   {RTE_LOGTYPE_PORT,   "lib.port"},
{RTE_LOGTYPE_TABLE,  "lib.table"},
{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
diff --git a/lib/log/rte_log.h b/lib/log/rte_log.h
index 5ba198ba2484..5c73e689e8aa 100644
--- a/lib/log/rte_log.h
+++ b/lib/log/rte_log.h
@@ -40,7 +40,7 @@ extern "C" {
 /* was RTE_LOGTYPE_POWER */
 /* was RTE_LOGTYPE_METER */
 /* was RTE_LOGTYPE_SCHED */
-#define RTE_LOGTYPE_PORT  13 /**< Log related to port. */
+/* was RTE_LOGTYPE_PORT */
 #define RTE_LOGTYPE_TABLE 14 /**< Log related to table. */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 /* was RTE_LOGTYPE_MBUF */
diff --git a/lib/port/meson.build b/lib/port/meson.build
index b0af2b185b39..b5977728723a 100644
--- a/lib/port/meson.build
+++ b/lib/port/meson.build
@@ -8,6 +8,7 @@ if is_windows
 endif
 
 sources = files(
+'port_log.c',
 'rte_port_ethdev.c',
 'rte_port_fd.c',
 'rte_port_frag.c',
diff --git a/lib/port/port_log.h b/lib/port/port_log.h
index 99332a380323..28d75ee48b3b 100644
--- a/lib/port/port_log.h
+++ b/lib/port/port_log.h
@@ -4,6 +4,8 @@
 
 #include 
 
+extern int port_logtype;
+#define RTE_LOGTYPE_PORT port_logtype
+
 #define PORT_LOG(level, ...) \
RTE_LOG_LINE(level, PORT, "" __VA_ARGS__)
-
-- 
2.43.0



[PATCH 2/3] table: convert to dynamic logtype

2023-12-22 Thread Stephen Hemminger
Replace static RTE_LOGTYPE_TABLE with dynamic type.

Signed-off-by: Stephen Hemminger 
---
 lib/log/log.c | 1 -
 lib/log/rte_log.h | 2 +-
 lib/port/port_log.c   | 7 +++
 lib/table/meson.build | 2 ++
 lib/table/table_log.c | 7 +++
 lib/table/table_log.h | 4 +++-
 6 files changed, 20 insertions(+), 3 deletions(-)
 create mode 100644 lib/port/port_log.c
 create mode 100644 lib/table/table_log.c

diff --git a/lib/log/log.c b/lib/log/log.c
index 853acaf07eb2..7ae798493e51 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -353,7 +353,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
{RTE_LOGTYPE_EAL,"lib.eal"},
{RTE_LOGTYPE_PMD,"pmd"},
-   {RTE_LOGTYPE_TABLE,  "lib.table"},
{RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
{RTE_LOGTYPE_USER1,  "user1"},
diff --git a/lib/log/rte_log.h b/lib/log/rte_log.h
index 5c73e689e8aa..6bfa66dc8986 100644
--- a/lib/log/rte_log.h
+++ b/lib/log/rte_log.h
@@ -41,7 +41,7 @@ extern "C" {
 /* was RTE_LOGTYPE_METER */
 /* was RTE_LOGTYPE_SCHED */
 /* was RTE_LOGTYPE_PORT */
-#define RTE_LOGTYPE_TABLE 14 /**< Log related to table. */
+/* was RTE_LOGTYPE_TABLE */
 #define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
 /* was RTE_LOGTYPE_MBUF */
 /* was RTE_LOGTYPE_CRYPTODEV */
diff --git a/lib/port/port_log.c b/lib/port/port_log.c
new file mode 100644
index ..1984b17bc4f7
--- /dev/null
+++ b/lib/port/port_log.c
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Red Hat, Inc.
+ */
+
+#include 
+
+RTE_LOG_REGISTER_DEFAULT(port_logtype, INFO);
diff --git a/lib/table/meson.build b/lib/table/meson.build
index f8cef24b5918..9b3d9ac759eb 100644
--- a/lib/table/meson.build
+++ b/lib/table/meson.build
@@ -18,7 +18,9 @@ sources = files(
 'rte_table_lpm.c',
 'rte_table_lpm_ipv6.c',
 'rte_table_stub.c',
+'table_log.c',
 )
+
 headers = files(
 'rte_lru.h',
 'rte_swx_hash_func.h',
diff --git a/lib/table/table_log.c b/lib/table/table_log.c
new file mode 100644
index ..8c84ed84671c
--- /dev/null
+++ b/lib/table/table_log.c
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Red Hat, Inc.
+ */
+
+#include 
+
+RTE_LOG_REGISTER_DEFAULT(table_logtype, INFO);
diff --git a/lib/table/table_log.h b/lib/table/table_log.h
index 0330f89d4192..b24b8614c227 100644
--- a/lib/table/table_log.h
+++ b/lib/table/table_log.h
@@ -4,6 +4,8 @@
 
 #include 
 
+extern int table_logtype;
+#define RTE_LOGTYPE_TABLE table_logtype
+
 #define TABLE_LOG(level, ...) \
RTE_LOG_LINE(level, TABLE, "" __VA_ARGS__)
-
-- 
2.43.0



[PATCH 3/3] pipeline: convert to a dynamic logtype

2023-12-22 Thread Stephen Hemminger
Replace RTE_LOGTYPE_PIPELINE static type with a dynamic one.

Signed-off-by: Stephen Hemminger 
---
 lib/log/log.c   | 1 -
 lib/log/rte_log.h   | 2 +-
 lib/pipeline/rte_pipeline.c | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/log/log.c b/lib/log/log.c
index 7ae798493e51..123510616455 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -353,7 +353,6 @@ struct logtype {
 static const struct logtype logtype_strings[] = {
{RTE_LOGTYPE_EAL,"lib.eal"},
{RTE_LOGTYPE_PMD,"pmd"},
-   {RTE_LOGTYPE_PIPELINE,   "lib.pipeline"},
{RTE_LOGTYPE_EVENTDEV,   "lib.eventdev"},
{RTE_LOGTYPE_USER1,  "user1"},
{RTE_LOGTYPE_USER2,  "user2"},
diff --git a/lib/log/rte_log.h b/lib/log/rte_log.h
index 6bfa66dc8986..5f28c3832de9 100644
--- a/lib/log/rte_log.h
+++ b/lib/log/rte_log.h
@@ -42,7 +42,7 @@ extern "C" {
 /* was RTE_LOGTYPE_SCHED */
 /* was RTE_LOGTYPE_PORT */
 /* was RTE_LOGTYPE_TABLE */
-#define RTE_LOGTYPE_PIPELINE  15 /**< Log related to pipeline. */
+/* was RTE_LOGTYPE_PIPELINE */
 /* was RTE_LOGTYPE_MBUF */
 /* was RTE_LOGTYPE_CRYPTODEV */
 /* was RTE_LOGTYPE_EFD */
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index b0aea4596daa..c9ed903d716b 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -12,6 +12,9 @@
 
 #include "rte_pipeline.h"
 
+RTE_LOG_REGISTER_DEFAULT(pipeline_logtype, INFO);
+#define RTE_LOGTYPE_PIPELINE pipeline_logtype
+
 #define PIPELINE_LOG(level, ...) \
RTE_LOG_LINE(level, PIPELINE, "" __VA_ARGS__)
 
-- 
2.43.0



[PATCH v2 00/18] bnxt patchset

2023-12-22 Thread Ajit Khaparde
This patchset contains more code fixes and reafctoring, apart from
extending more support for the newer P7 device family.
The patchset adds vector mode support for compressed Rx CQE.
This patchset includes support for checksum and XOR RSS hash mode.
It also adds support for forced speeds and autoneg support upto 400G.

v1->v2:
 - Fixed a redefinition of page size and used rte variant instead.
 - Fixed typo in some commit logs

Ajit Khaparde (9):
  net/bnxt: add support for UDP GSO
  net/bnxt: add support for compressed Rx CQE
  net/bnxt: reattempt mbuf allocation for Rx and AGG rings
  net/bnxt: refactor Rx doorbell during Rx flush
  net/bnxt: extend RSS hash support for P7 devices
  net/bnxt: add ESP and AH header based RSS support
  net/bnxt: set allmulti mode if multicast filter fails
  net/bnxt: add AVX2 support for compressed CQE
  net/bnxt: enable SSE mode for compressed CQE

Damodharam Ammepalli (4):
  net/bnxt: add flow query callback
  net/bnxt: add tunnel TPA support
  net/bnxt: add 400G get support for P7 devices
  net/bnxt: query extended stats from firmware

Jay Ding (1):
  net/bnxt: add VF FLR async event handler

Kalesh AP (4):
  net/bnxt: fix a typo while parsing link speed
  net/bnxt: fix setting 50G and 100G forced speed
  net/bnxt: fix speed change from 200G to 25G on Thor
  net/bnxt: support backward compatibility

 drivers/net/bnxt/bnxt.h| 106 ++-
 drivers/net/bnxt/bnxt_cpr.c|  20 +
 drivers/net/bnxt/bnxt_cpr.h|   3 +-
 drivers/net/bnxt/bnxt_ethdev.c | 253 ++--
 drivers/net/bnxt/bnxt_flow.c   |  98 ++-
 drivers/net/bnxt/bnxt_hwrm.c   | 853 +++--
 drivers/net/bnxt/bnxt_hwrm.h   |  16 +-
 drivers/net/bnxt/bnxt_reps.c   |   2 +-
 drivers/net/bnxt/bnxt_ring.c   |  19 +-
 drivers/net/bnxt/bnxt_rxq.c|   8 +-
 drivers/net/bnxt/bnxt_rxq.h|   1 +
 drivers/net/bnxt/bnxt_rxr.c| 320 --
 drivers/net/bnxt/bnxt_rxr.h|  59 ++
 drivers/net/bnxt/bnxt_rxtx_vec_avx2.c  | 309 +
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c   | 167 -
 drivers/net/bnxt/bnxt_stats.c  | 279 +++-
 drivers/net/bnxt/bnxt_txq.c|   2 +
 drivers/net/bnxt/bnxt_txr.c|   7 +-
 drivers/net/bnxt/bnxt_vnic.c   | 195 +-
 drivers/net/bnxt/bnxt_vnic.h   |  20 +-
 drivers/net/bnxt/hsi_struct_def_dpdk.h |  10 +-
 21 files changed, 2542 insertions(+), 205 deletions(-)

-- 
2.39.2 (Apple Git-143)



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH v2 01/18] net/bnxt: add support for UDP GSO

2023-12-22 Thread Ajit Khaparde
UDP GSO aka UDP Fragmentation Offload allows an application or stack
to provide a data payload larger than the MTU. The application then
updates the mbuf ol_flags and sets the PKT_TX_UDP_SEG flag. Then based
on the tso_segs and tso_mss fields in the mbuf the PMD can indicate
the UDP GSO transmit request to the hardware.
This feature is supported on Thor2 and will be enabled when the firmware
sets the UDP GSO support via the HWRM_FUNC_QCAPS.

Signed-off-by: Ajit Khaparde 
Reviewed-by: Damodharam Ammepalli 
---
 drivers/net/bnxt/bnxt.h  | 1 +
 drivers/net/bnxt/bnxt_hwrm.c | 2 ++
 drivers/net/bnxt/bnxt_txq.c  | 2 ++
 drivers/net/bnxt/bnxt_txr.c  | 7 ++-
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 7aed4c3da3..4b5c2c4b8f 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -801,6 +801,7 @@ struct bnxt {
(BNXT_CHIP_P5_P7((bp)) && \
 (bp)->hwrm_spec_code >= HWRM_VERSION_1_9_2 && \
 !BNXT_VF((bp)))
+#define BNXT_FW_CAP_UDP_GSOBIT(13)
 #define BNXT_TRUFLOW_EN(bp)((bp)->fw_cap & BNXT_FW_CAP_TRUFLOW_EN &&\
 (bp)->app_id != 0xFF)
 
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index e56f7693af..37cf179938 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -950,6 +950,8 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
flags_ext2 = rte_le_to_cpu_32(resp->flags_ext2);
if (flags_ext2 & 
HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_RX_ALL_PKTS_TIMESTAMPS_SUPPORTED)
bp->fw_cap |= BNXT_FW_CAP_RX_ALL_PKT_TS;
+   if (flags_ext2 & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT2_UDP_GSO_SUPPORTED)
+   bp->fw_cap |= BNXT_FW_CAP_UDP_GSO;
 
 unlock:
HWRM_UNLOCK();
diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c
index 4df4604975..f99ad211db 100644
--- a/drivers/net/bnxt/bnxt_txq.c
+++ b/drivers/net/bnxt/bnxt_txq.c
@@ -42,6 +42,8 @@ uint64_t bnxt_get_tx_port_offloads(struct bnxt *bp)
tx_offload_capa |= RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO;
if (BNXT_TUNNELED_OFFLOADS_CAP_IPINIP_EN(bp))
tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO;
+   if (bp->fw_cap & BNXT_FW_CAP_UDP_GSO)
+   tx_offload_capa |= RTE_ETH_TX_OFFLOAD_UDP_TSO;
 
return tx_offload_capa;
 }
diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c
index 899986764f..38da2d2829 100644
--- a/drivers/net/bnxt/bnxt_txr.c
+++ b/drivers/net/bnxt/bnxt_txr.c
@@ -123,6 +123,10 @@ bnxt_xmit_need_long_bd(struct rte_mbuf *tx_pkt, struct 
bnxt_tx_queue *txq)
return false;
 }
 
+/* Used for verifying TSO segments during TCP Segmentation Offload or
+ * UDP Fragmentation Offload. tx_pkt->tso_segsz stores the number of
+ * segments or fragments in those cases.
+ */
 static bool
 bnxt_zero_data_len_tso_segsz(struct rte_mbuf *tx_pkt, uint8_t data_len_chk)
 {
@@ -308,7 +312,8 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
else
txbd1->cfa_action = txq->bp->tx_cfa_action;
 
-   if (tx_pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+   if (tx_pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG ||
+   tx_pkt->ol_flags & RTE_MBUF_F_TX_UDP_SEG) {
uint16_t hdr_size;
 
/* TSO */
-- 
2.39.2 (Apple Git-143)



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH v2 02/18] net/bnxt: add support for compressed Rx CQE

2023-12-22 Thread Ajit Khaparde
Thor2 supports compressed Rx completions instead of the
full featured 32-byte Rx completions.
Add support for these compressed CQEs in scalar mode.
Unlike in the typical Rx completions, the hardware does
not provide the opaque field to index into the aggregator
descriptor ring. So maintain the consumer index for the
aggregation ring in the driver.

Signed-off-by: Ajit Khaparde 
Reviewed-by: Somnath Kotur 
Reviewed-by: Damodharam Ammepalli 
---
 drivers/net/bnxt/bnxt.h|  17 +++
 drivers/net/bnxt/bnxt_ethdev.c |  51 +
 drivers/net/bnxt/bnxt_hwrm.c   |  16 +++
 drivers/net/bnxt/bnxt_ring.c   |  13 ++-
 drivers/net/bnxt/bnxt_rxr.c| 201 +
 drivers/net/bnxt/bnxt_rxr.h|  55 +
 6 files changed, 352 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 4b5c2c4b8f..cfdbfd3f54 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -782,6 +782,7 @@ struct bnxt {
 #defineBNXT_MULTIROOT_EN(bp)   \
((bp)->flags2 & BNXT_FLAGS2_MULTIROOT_EN)
 
+#defineBNXT_FLAGS2_COMPRESSED_RX_CQE   BIT(5)
uint32_tfw_cap;
 #define BNXT_FW_CAP_HOT_RESET  BIT(0)
 #define BNXT_FW_CAP_IF_CHANGE  BIT(1)
@@ -814,6 +815,7 @@ struct bnxt {
 #define BNXT_VNIC_CAP_VLAN_RX_STRIPBIT(3)
 #define BNXT_RX_VLAN_STRIP_EN(bp)  ((bp)->vnic_cap_flags & 
BNXT_VNIC_CAP_VLAN_RX_STRIP)
 #define BNXT_VNIC_CAP_OUTER_RSS_TRUSTED_VF BIT(4)
+#define BNXT_VNIC_CAP_L2_CQE_MODE  BIT(8)
unsigned intrx_nr_rings;
unsigned intrx_cp_nr_rings;
unsigned intrx_num_qs_per_vnic;
@@ -1013,6 +1015,21 @@ inline uint16_t bnxt_max_rings(struct bnxt *bp)
return max_rings;
 }
 
+static inline bool
+bnxt_compressed_rx_cqe_mode_enabled(struct bnxt *bp)
+{
+   uint64_t rx_offloads = bp->eth_dev->data->dev_conf.rxmode.offloads;
+
+   if (bp->vnic_cap_flags & BNXT_VNIC_CAP_L2_CQE_MODE &&
+   bp->flags2 & BNXT_FLAGS2_COMPRESSED_RX_CQE &&
+   !(rx_offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO) &&
+   !(rx_offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) &&
+   !bp->num_reps && !bp->ieee_1588)
+   return true;
+
+   return false;
+}
+
 #define BNXT_FC_TIMER  1 /* Timer freq in Sec Flow Counters */
 
 /**
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 75e968394f..0f1c4326c4 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -103,6 +103,7 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
 #define BNXT_DEVARG_REP_FC_F2R  "rep-fc-f2r"
 #define BNXT_DEVARG_APP_ID "app-id"
 #define BNXT_DEVARG_IEEE_1588  "ieee-1588"
+#define BNXT_DEVARG_CQE_MODE   "cqe-mode"
 
 static const char *const bnxt_dev_args[] = {
BNXT_DEVARG_REPRESENTOR,
@@ -116,9 +117,15 @@ static const char *const bnxt_dev_args[] = {
BNXT_DEVARG_REP_FC_F2R,
BNXT_DEVARG_APP_ID,
BNXT_DEVARG_IEEE_1588,
+   BNXT_DEVARG_CQE_MODE,
NULL
 };
 
+/*
+ * cqe-mode = an non-negative 8-bit number
+ */
+#define BNXT_DEVARG_CQE_MODE_INVALID(val)  ((val) > 1)
+
 /*
  * app-id = an non-negative 8-bit number
  */
@@ -5706,6 +5713,43 @@ bnxt_parse_devarg_max_num_kflows(__rte_unused const char 
*key,
return 0;
 }
 
+static int
+bnxt_parse_devarg_cqe_mode(__rte_unused const char *key,
+  const char *value, void *opaque_arg)
+{
+   struct bnxt *bp = opaque_arg;
+   unsigned long cqe_mode;
+   char *end = NULL;
+
+   if (!value || !opaque_arg) {
+   PMD_DRV_LOG(ERR,
+   "Invalid parameter passed to cqe-mode "
+   "devargs.\n");
+   return -EINVAL;
+   }
+
+   cqe_mode = strtoul(value, &end, 10);
+   if (end == NULL || *end != '\0' ||
+   (cqe_mode == ULONG_MAX && errno == ERANGE)) {
+   PMD_DRV_LOG(ERR,
+   "Invalid parameter passed to cqe-mode "
+   "devargs.\n");
+   return -EINVAL;
+   }
+
+   if (BNXT_DEVARG_CQE_MODE_INVALID(cqe_mode)) {
+   PMD_DRV_LOG(ERR, "Invalid cqe-mode(%d) devargs.\n",
+   (uint16_t)cqe_mode);
+   return -EINVAL;
+   }
+
+   if (cqe_mode == 1)
+   bp->flags2 |= BNXT_FLAGS2_COMPRESSED_RX_CQE;
+   PMD_DRV_LOG(INFO, "cqe-mode=%d feature enabled.\n", (uint8_t)cqe_mode);
+
+   return 0;
+}
+
 static int
 bnxt_parse_devarg_app_id(__rte_unused const char *key,
 const char *value, void *opaque_arg)
@@ -6047,6 +6091,13 @@ bnxt_parse_dev_args(struct bnxt *bp, struct rte_devargs 
*devargs)
rte_kvargs_process(kvlist, BNXT_DEVARG_IEEE_1588,
   bnxt_parse_devarg_ieee_1588, bp);
 
+   /*
+* Handler

[PATCH v2 03/18] net/bnxt: fix a typo while parsing link speed

2023-12-22 Thread Ajit Khaparde
From: Kalesh AP 

While setting forced speed, the speed should have mapped to
macro "HWRM_PORT_PHY_CFG_INPUT_FORCE_xxx" instead of
"HWRM_PORT_PHY_CFG_INPUT_AUTO_xxx". We do not see any issue
as both these macros are defined to the same value.

Fixing it for better convey the intent.

Signed-off-by: Kalesh AP 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 378be997d3..8f99582819 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -3168,15 +3168,15 @@ static uint16_t bnxt_parse_eth_link_speed(uint32_t 
conf_link_speed,
case RTE_ETH_LINK_SPEED_100M_HD:
/* FALLTHROUGH */
eth_link_speed =
-   HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_100MB;
+   HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100MB;
break;
case RTE_ETH_LINK_SPEED_1G:
eth_link_speed =
-   HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_1GB;
+   HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_1GB;
break;
case RTE_ETH_LINK_SPEED_2_5G:
eth_link_speed =
-   HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_2_5GB;
+   HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_2_5GB;
break;
case RTE_ETH_LINK_SPEED_10G:
eth_link_speed =
@@ -3184,11 +3184,11 @@ static uint16_t bnxt_parse_eth_link_speed(uint32_t 
conf_link_speed,
break;
case RTE_ETH_LINK_SPEED_20G:
eth_link_speed =
-   HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_20GB;
+   HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_20GB;
break;
case RTE_ETH_LINK_SPEED_25G:
eth_link_speed =
-   HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_25GB;
+   HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_25GB;
break;
case RTE_ETH_LINK_SPEED_40G:
eth_link_speed =
-- 
2.39.2 (Apple Git-143)



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH v2 04/18] net/bnxt: fix setting 50G and 100G forced speed

2023-12-22 Thread Ajit Khaparde
From: Kalesh AP 

Thor based NICs can support PAM4 as well as NRZ link negotiation.
While PAM4 can negotiate speeds at 50G, 100G and 200G, the PMD will
use NRZ signaling for 50G and 100G speeds. PAM4 signaling will be
used only for 200G speed negotiations.

Driver has to check for NRZ speed support first while forcing speed.

Fixes: c23f9ded0391 ("net/bnxt: support 200G PAM4 link")
Cc: sta...@dpdk.org

Signed-off-by: Kalesh AP 
Reviewed-by: Somnath Kotur 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 8f99582819..c31a5d4226 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -3158,6 +3158,8 @@ static uint16_t bnxt_check_eth_link_autoneg(uint32_t 
conf_link)
 static uint16_t bnxt_parse_eth_link_speed(uint32_t conf_link_speed,
  struct bnxt_link_info *link_info)
 {
+   uint16_t support_pam4_speeds = link_info->support_pam4_speeds;
+   uint16_t support_speeds = link_info->support_speeds;
uint16_t eth_link_speed = 0;
 
if (conf_link_speed == RTE_ETH_LINK_SPEED_AUTONEG)
@@ -3195,23 +3197,23 @@ static uint16_t bnxt_parse_eth_link_speed(uint32_t 
conf_link_speed,
HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_40GB;
break;
case RTE_ETH_LINK_SPEED_50G:
-   if (link_info->support_pam4_speeds &
-   HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_50G) {
-   eth_link_speed = 
HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_50GB;
-   link_info->link_signal_mode = BNXT_SIG_MODE_PAM4;
-   } else {
+   if (support_speeds & 
HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_50GB) {
eth_link_speed = 
HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_50GB;
link_info->link_signal_mode = BNXT_SIG_MODE_NRZ;
+   } else if (support_pam4_speeds &
+  HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_50G) {
+   eth_link_speed = 
HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_50GB;
+   link_info->link_signal_mode = BNXT_SIG_MODE_PAM4;
}
break;
case RTE_ETH_LINK_SPEED_100G:
-   if (link_info->support_pam4_speeds &
-   HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_100G) {
-   eth_link_speed = 
HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_100GB;
-   link_info->link_signal_mode = BNXT_SIG_MODE_PAM4;
-   } else {
+   if (support_speeds & 
HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS_100GB) {
eth_link_speed = 
HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100GB;
link_info->link_signal_mode = BNXT_SIG_MODE_NRZ;
+   } else if (support_pam4_speeds &
+  HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_PAM4_SPEEDS_100G) {
+   eth_link_speed = 
HWRM_PORT_PHY_CFG_INPUT_FORCE_PAM4_LINK_SPEED_100GB;
+   link_info->link_signal_mode = BNXT_SIG_MODE_PAM4;
}
break;
case RTE_ETH_LINK_SPEED_200G:
-- 
2.39.2 (Apple Git-143)



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH v2 05/18] net/bnxt: fix speed change from 200G to 25G on Thor

2023-12-22 Thread Ajit Khaparde
From: Kalesh AP 

While forcing speed to 200G, driver sets the structure variable
"bp->link_info->link_signal_mode" value to BNXT_SIG_MODE_PAM4.
After that when the user forces the speed back to 25G, this
cached value is not set back to BNXT_SIG_MODE_NRZ which results
in issuing the HWRM_PORT_PHY_CFG command with wrong inputs.

Fixes: c23f9ded0391 ("net/bnxt: support 200G PAM4 link")
Cc: sta...@dpdk.org

Reviewed-by: Somnath Kotur 
Signed-off-by: Kalesh AP 
Signed-off-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt_hwrm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index c31a5d4226..a1f3a8251f 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -3191,6 +3191,7 @@ static uint16_t bnxt_parse_eth_link_speed(uint32_t 
conf_link_speed,
case RTE_ETH_LINK_SPEED_25G:
eth_link_speed =
HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_25GB;
+   link_info->link_signal_mode = BNXT_SIG_MODE_NRZ;
break;
case RTE_ETH_LINK_SPEED_40G:
eth_link_speed =
-- 
2.39.2 (Apple Git-143)



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH v2 06/18] net/bnxt: support backward compatibility

2023-12-22 Thread Ajit Khaparde
From: Kalesh AP 

On older firmware versions, HWRM_FUNC_QCAPS response is not
returning the maximum number of multicast filters that can be
supported by the function. As a result, memory allocation with
size 0 fails.

Bugzilla ID: 1309
Cc: sta...@dpdk.org

Signed-off-by: Kalesh AP 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt.h  | 1 +
 drivers/net/bnxt/bnxt_hwrm.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index cfdbfd3f54..cd85a944e8 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -974,6 +974,7 @@ struct bnxt {
struct rte_ether_addr   *mcast_addr_list;
rte_iova_t  mc_list_dma_addr;
uint32_tnb_mc_addr;
+#define BNXT_DFLT_MAX_MC_ADDR  16 /* for compatibility with older firmware */
uint32_tmax_mcast_addr; /* maximum number of mcast 
filters supported */
 
struct rte_eth_rss_conf rss_conf; /* RSS configuration. */
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index a1f3a8251f..d649f217ec 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -901,6 +901,8 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
bp->max_l2_ctx, bp->max_vnics);
bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
bp->max_mcast_addr = rte_le_to_cpu_32(resp->max_mcast_filters);
+   if (!bp->max_mcast_addr)
+   bp->max_mcast_addr = BNXT_DFLT_MAX_MC_ADDR;
memcpy(bp->dsn, resp->device_serial_number, sizeof(bp->dsn));
 
if (BNXT_PF(bp))
-- 
2.39.2 (Apple Git-143)



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH v2 07/18] net/bnxt: reattempt mbuf allocation for Rx and AGG rings

2023-12-22 Thread Ajit Khaparde
Normally the PMD allocates a new mbuf for every mbuf consumed.
In case of mbuf alloc failure, that slot in the Rx or AGG ring remains
empty till a new mbuf is not allocated for that slot. If this happens
too frequently the Rx ring or the aggregation ring could be completely
drained of mbufs and can cause unexpected behavior.

To prevent this, in case of an mbuf allocation failure, set a bit and
try to reattempt mbuf allocation to fill the empty slots. Since this
should not happen under normal circumstances, it should not impact
regular Rx performance.

The need_realloc bit is set in the RxQ if mbuf allocation fails for
Rx ring or the AGG ring.

As long as the application calls the Rx burst function even in cases
where the Rx rings became completely empty, the logic should be able to
reattempt buffer allocation for the associated Rx and aggregation rings.

Signed-off-by: Ajit Khaparde 
Reviewed-by: Somnath Kotur 
---
 drivers/net/bnxt/bnxt_rxq.h |   1 +
 drivers/net/bnxt/bnxt_rxr.c | 101 ++--
 2 files changed, 64 insertions(+), 38 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_rxq.h b/drivers/net/bnxt/bnxt_rxq.h
index b9908be5f4..77bc382a1d 100644
--- a/drivers/net/bnxt/bnxt_rxq.h
+++ b/drivers/net/bnxt/bnxt_rxq.h
@@ -41,6 +41,7 @@ struct bnxt_rx_queue {
struct bnxt_cp_ring_info*cp_ring;
struct rte_mbuf fake_mbuf;
uint64_trx_mbuf_alloc_fail;
+   uint8_t need_realloc;
const struct rte_memzone *mz;
 };
 
diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index b919922a64..c5c9f9e6e6 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -50,6 +50,8 @@ static inline int bnxt_alloc_rx_data(struct bnxt_rx_queue 
*rxq,
mbuf = __bnxt_alloc_rx_data(rxq->mb_pool);
if (!mbuf) {
__atomic_fetch_add(&rxq->rx_mbuf_alloc_fail, 1, 
__ATOMIC_RELAXED);
+   /* If buff has failed already, setting this again won't hurt */
+   rxq->need_realloc = 1;
return -ENOMEM;
}
 
@@ -85,6 +87,8 @@ static inline int bnxt_alloc_ag_data(struct bnxt_rx_queue 
*rxq,
mbuf = __bnxt_alloc_rx_data(rxq->mb_pool);
if (!mbuf) {
__atomic_fetch_add(&rxq->rx_mbuf_alloc_fail, 1, 
__ATOMIC_RELAXED);
+   /* If buff has failed already, setting this again won't hurt */
+   rxq->need_realloc = 1;
return -ENOMEM;
}
 
@@ -139,7 +143,6 @@ static void bnxt_rx_ring_reset(void *arg)
int i, rc = 0;
struct bnxt_rx_queue *rxq;
 
-
for (i = 0; i < (int)bp->rx_nr_rings; i++) {
struct bnxt_rx_ring_info *rxr;
 
@@ -357,7 +360,8 @@ static int bnxt_rx_pages(struct bnxt_rx_queue *rxq,
RTE_ASSERT(ag_cons <= rxr->ag_ring_struct->ring_mask);
ag_buf = &rxr->ag_buf_ring[ag_cons];
ag_mbuf = *ag_buf;
-   RTE_ASSERT(ag_mbuf != NULL);
+   if (ag_mbuf == NULL)
+   return -EBUSY;
 
ag_mbuf->data_len = rte_le_to_cpu_16(rxcmp->len);
 
@@ -452,7 +456,7 @@ static inline struct rte_mbuf *bnxt_tpa_end(
RTE_ASSERT(mbuf != NULL);
 
if (agg_bufs) {
-   bnxt_rx_pages(rxq, mbuf, raw_cp_cons, agg_bufs, tpa_info);
+   (void)bnxt_rx_pages(rxq, mbuf, raw_cp_cons, agg_bufs, tpa_info);
}
mbuf->l4_len = payload_offset;
 
@@ -1230,8 +1234,11 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
bnxt_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
 
 reuse_rx_mbuf:
-   if (agg_buf)
-   bnxt_rx_pages(rxq, mbuf, &tmp_raw_cons, agg_buf, NULL);
+   if (agg_buf) {
+   rc = bnxt_rx_pages(rxq, mbuf, &tmp_raw_cons, agg_buf, NULL);
+   if (rc != 0)
+   return -EBUSY;
+   }
 
 #ifdef BNXT_DEBUG
if (rxcmp1->errors_v2 & RX_CMP_L2_ERRORS) {
@@ -1293,6 +1300,48 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
return rc;
 }
 
+static void bnxt_reattempt_buffer_alloc(struct bnxt_rx_queue *rxq)
+{
+   struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
+   struct bnxt_ring *ring;
+   uint16_t raw_prod;
+   uint32_t cnt;
+
+   /* Assume alloc passes. On failure,
+* need_realloc will be set inside bnxt_alloc_XY_data.
+*/
+   rxq->need_realloc = 0;
+   if (!bnxt_need_agg_ring(rxq->bp->eth_dev))
+   goto alloc_rx;
+
+   raw_prod = rxr->ag_raw_prod;
+   bnxt_prod_ag_mbuf(rxq);
+   if (raw_prod != rxr->ag_raw_prod)
+   bnxt_db_write(&rxr->ag_db, rxr->ag_raw_prod);
+
+alloc_rx:
+   raw_prod = rxr->rx_raw_prod;
+   ring = rxr->rx_ring_struct;
+   for (cnt = 0; cnt < ring->ring_size; cnt++) {
+   struct rte_mbuf **rx_buf;
+   uint16_t ndx;
+
+   ndx = RING_IDX(ring, raw_prod + cnt)

[PATCH v2 08/18] net/bnxt: refactor Rx doorbell during Rx flush

2023-12-22 Thread Ajit Khaparde
Ring the Rx doorbell during the Rx ring flush processing only if
there is a valid completion.

Signed-off-by: Ajit Khaparde 
Reviewed-by: Damodharam Ammepalli 
---
 drivers/net/bnxt/bnxt_rxr.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c
index c5c9f9e6e6..d0706874a6 100644
--- a/drivers/net/bnxt/bnxt_rxr.c
+++ b/drivers/net/bnxt/bnxt_rxr.c
@@ -1713,10 +1713,11 @@ int bnxt_flush_rx_cmp(struct bnxt_cp_ring_info *cpr)
nb_rx++;
} while (nb_rx < ring_mask);
 
-   cpr->cp_raw_cons = raw_cons;
-
-   /* Ring the completion queue doorbell. */
-   bnxt_db_cq(cpr);
+   if (nb_rx) {
+   cpr->cp_raw_cons = raw_cons;
+   /* Ring the completion queue doorbell. */
+   bnxt_db_cq(cpr);
+   }
 
return 0;
 }
-- 
2.39.2 (Apple Git-143)



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH v2 09/18] net/bnxt: extend RSS hash support for P7 devices

2023-12-22 Thread Ajit Khaparde
P7 adapters support XOR based and checksum based RSS hashing.
Add support for checksum and XOR based RSS hash for these adapters.

Signed-off-by: Ajit Khaparde 
Reviewed-by: Damodharam Ammepalli 
---
 drivers/net/bnxt/bnxt.h|  15 +--
 drivers/net/bnxt/bnxt_ethdev.c |  72 ++-
 drivers/net/bnxt/bnxt_flow.c   |  37 +++-
 drivers/net/bnxt/bnxt_hwrm.c   |   6 ++
 drivers/net/bnxt/bnxt_reps.c   |   2 +-
 drivers/net/bnxt/bnxt_vnic.c   | 161 +++--
 drivers/net/bnxt/bnxt_vnic.h   |  18 +++-
 7 files changed, 242 insertions(+), 69 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index cd85a944e8..e7b288c849 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -638,15 +638,6 @@ struct bnxt_rep_info {
 #define BNXT_FW_STATUS_HEALTHY 0x8000
 #define BNXT_FW_STATUS_SHUTDOWN0x10
 
-#define BNXT_ETH_RSS_SUPPORT ( \
-   RTE_ETH_RSS_IPV4 |  \
-   RTE_ETH_RSS_NONFRAG_IPV4_TCP |  \
-   RTE_ETH_RSS_NONFRAG_IPV4_UDP |  \
-   RTE_ETH_RSS_IPV6 |  \
-   RTE_ETH_RSS_NONFRAG_IPV6_TCP |  \
-   RTE_ETH_RSS_NONFRAG_IPV6_UDP |  \
-   RTE_ETH_RSS_LEVEL_MASK)
-
 #define BNXT_HWRM_SHORT_REQ_LENsizeof(struct hwrm_short_input)
 
 struct bnxt_flow_stat_info {
@@ -815,7 +806,10 @@ struct bnxt {
 #define BNXT_VNIC_CAP_VLAN_RX_STRIPBIT(3)
 #define BNXT_RX_VLAN_STRIP_EN(bp)  ((bp)->vnic_cap_flags & 
BNXT_VNIC_CAP_VLAN_RX_STRIP)
 #define BNXT_VNIC_CAP_OUTER_RSS_TRUSTED_VF BIT(4)
-#define BNXT_VNIC_CAP_L2_CQE_MODE  BIT(8)
+#define BNXT_VNIC_CAP_XOR_MODE BIT(5)
+#define BNXT_VNIC_CAP_CHKSM_MODE   BIT(6)
+#define BNXT_VNIC_CAP_L2_CQE_MODE  BIT(8)
+
unsigned intrx_nr_rings;
unsigned intrx_cp_nr_rings;
unsigned intrx_num_qs_per_vnic;
@@ -1176,4 +1170,5 @@ void bnxt_handle_vf_cfg_change(void *arg);
 int bnxt_flow_meter_ops_get(struct rte_eth_dev *eth_dev, void *arg);
 struct bnxt_vnic_info *bnxt_get_default_vnic(struct bnxt *bp);
 struct tf *bnxt_get_tfp_session(struct bnxt *bp, enum bnxt_session_type type);
+uint64_t bnxt_eth_rss_support(struct bnxt *bp);
 #endif
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 0f1c4326c4..ef5e65ff16 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -982,6 +982,25 @@ uint32_t bnxt_get_speed_capabilities(struct bnxt *bp)
return speed_capa;
 }
 
+uint64_t bnxt_eth_rss_support(struct bnxt *bp)
+{
+   uint64_t support;
+
+   support = RTE_ETH_RSS_IPV4 |
+ RTE_ETH_RSS_NONFRAG_IPV4_TCP |
+ RTE_ETH_RSS_NONFRAG_IPV4_UDP |
+ RTE_ETH_RSS_IPV6 |
+ RTE_ETH_RSS_NONFRAG_IPV6_TCP |
+ RTE_ETH_RSS_NONFRAG_IPV6_UDP |
+ RTE_ETH_RSS_LEVEL_MASK;
+
+   if (bp->vnic_cap_flags & BNXT_VNIC_CAP_CHKSM_MODE)
+   support |= (RTE_ETH_RSS_IPV4_CHKSUM |
+   RTE_ETH_RSS_L4_CHKSUM);
+
+   return support;
+}
+
 static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
struct rte_eth_dev_info *dev_info)
 {
@@ -1023,7 +1042,7 @@ static int bnxt_dev_info_get_op(struct rte_eth_dev 
*eth_dev,
dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
dev_info->tx_offload_capa = bnxt_get_tx_port_offloads(bp) |
dev_info->tx_queue_offload_capa;
-   dev_info->flow_type_rss_offloads = BNXT_ETH_RSS_SUPPORT;
+   dev_info->flow_type_rss_offloads = bnxt_eth_rss_support(bp);
 
dev_info->speed_capa = bnxt_get_speed_capabilities(bp);
dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
@@ -2175,7 +2194,7 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev 
*eth_dev,
if (!rss_conf->rss_hf)
PMD_DRV_LOG(ERR, "Hash type NONE\n");
} else {
-   if (rss_conf->rss_hf & BNXT_ETH_RSS_SUPPORT)
+   if (rss_conf->rss_hf & bnxt_eth_rss_support(bp))
return -EINVAL;
}
 
@@ -2185,6 +2204,12 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev 
*eth_dev,
vnic->hash_mode =
bnxt_rte_to_hwrm_hash_level(bp, rss_conf->rss_hf,

RTE_ETH_RSS_LEVEL(rss_conf->rss_hf));
+   rc = bnxt_rte_eth_to_hwrm_ring_select_mode(bp, rss_conf->rss_hf, vnic);
+   if (rc != 0)
+   return rc;
+
+   /* Cache the hash function */
+   bp->rss_conf.rss_hf = rss_conf->rss_hf;
 
/* Cache the hash function */
bp->rss_conf.rss_hf = rss_conf->rss_hf;
@@ -2218,60 +2243,21 @@ static int bnxt_rss_hash_conf_get_op(struct rte_eth_dev 
*eth_dev,
struct bnxt *bp = eth_dev->data->dev_private;
struct bnxt_vnic_info *vnic = bnxt_get_default_vnic(bp);
in

[PATCH v2 10/18] net/bnxt: add flow query callback

2023-12-22 Thread Ajit Khaparde
From: Damodharam Ammepalli 

This patch addsbnxt query callback to rte_flow_ops in non TruFlow mode.
At this point only the RSS hash function type is displayed.

Signed-off-by: Damodharam Ammepalli 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt_flow.c | 61 
 drivers/net/bnxt/bnxt_vnic.c | 11 +++
 drivers/net/bnxt/bnxt_vnic.h |  2 ++
 3 files changed, 74 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 2d707b48d2..f25bc6ff78 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -1917,6 +1917,66 @@ void bnxt_flow_cnt_alarm_cb(void *arg)
  (void *)bp);
 }
 
+/* Query an requested flow rule. */
+static int
+bnxt_flow_query_all(struct rte_flow *flow,
+   const struct rte_flow_action *actions, void *data,
+   struct rte_flow_error *error)
+{
+   struct rte_flow_action_rss *rss_conf;
+   struct bnxt_vnic_info *vnic;
+
+   vnic = flow->vnic;
+   if (vnic == NULL)
+   return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_HANDLE, flow,
+ "Invalid flow: failed to query 
flow.");
+
+   for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
+   switch (actions->type) {
+   case RTE_FLOW_ACTION_TYPE_VOID:
+   break;
+   case RTE_FLOW_ACTION_TYPE_COUNT:
+   break;
+   case RTE_FLOW_ACTION_TYPE_RSS:
+   /* Full details of rte_flow_action_rss not available 
yet TBD*/
+   rss_conf = (struct rte_flow_action_rss *)data;
+
+   /* toeplitz is default */
+   if (vnic->ring_select_mode ==
+   
HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ)
+   rss_conf->func = vnic->hash_f_local;
+   else
+   rss_conf->func = 
RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
+
+   break;
+   default:
+   return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ACTION, 
actions,
+ "action is not supported");
+   }
+   }
+
+   return 0;
+}
+
+static int
+bnxt_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
+   const struct rte_flow_action *actions, void *data,
+   struct rte_flow_error *error)
+{
+   struct bnxt *bp = dev->data->dev_private;
+   int ret = 0;
+
+   if (bp == NULL)
+   return -ENODEV;
+
+   bnxt_acquire_flow_lock(bp);
+   ret = bnxt_flow_query_all(flow, actions, data, error);
+   bnxt_release_flow_lock(bp);
+
+   return ret;
+}
 
 static struct rte_flow *
 bnxt_flow_create(struct rte_eth_dev *dev,
@@ -2374,4 +2434,5 @@ const struct rte_flow_ops bnxt_flow_ops = {
.create = bnxt_flow_create,
.destroy = bnxt_flow_destroy,
.flush = bnxt_flow_flush,
+   .query = bnxt_flow_query,
 };
diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index 6a57f85ea7..bf1f0ea09f 100644
--- a/drivers/net/bnxt/bnxt_vnic.c
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -1335,6 +1335,9 @@ int bnxt_rte_flow_to_hwrm_ring_select_mode(enum 
rte_eth_hash_function hash_f,
}
 
vnic->ring_select_mode = _bnxt_rte_to_hwrm_ring_select_mode(hash_f);
+   vnic->hash_f_local = hash_f;
+   /* shadow copy types as !hash_f is always true with default func */
+   vnic->rss_types_local = types;
return 0;
 }
 
@@ -1359,6 +1362,8 @@ int bnxt_rte_eth_to_hwrm_ring_select_mode(struct bnxt 
*bp, uint64_t types,
 */
vnic->ring_select_mode =
HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ;
+   vnic->hash_f_local =
+   HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ;
return 0;
 }
 
@@ -1367,6 +1372,12 @@ void bnxt_hwrm_rss_to_rte_hash_conf(struct 
bnxt_vnic_info *vnic,
 {
uint32_t hash_types;
 
+   /* check for local shadow rte types */
+   if (vnic->rss_types_local != 0) {
+   *rss_conf = vnic->rss_types_local;
+   return;
+   }
+
hash_types = vnic->hash_type;
*rss_conf = 0;
if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4)
diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h
index d01c9ebdb4..93155648e2 100644
--- a/drivers/net/bnxt/bnxt_vnic.h
+++ b/drivers/net/bnxt/bnxt_vnic.h
@@ -79,6 +79,8 @@ struct bnxt_vnic_info {
STAILQ_HEAD(, bnxt_filter_info) filter;
STAILQ_HEAD(, rte_flow) flow_list;
uint8_t ring_select_mode;
+   enum rte_eth_hash_function hash_f_local;
+   uint64_trss_types_local;
 };
 
 struc

[PATCH v2 11/18] net/bnxt: add ESP and AH header based RSS support

2023-12-22 Thread Ajit Khaparde
Check if the firmware can support RSS based on these types and
program the hardware accordingly when requested when the
firmware indicates that the underlying hardware supports the
functionality.

Signed-off-by: Ajit Khaparde 
Reviewed-by: Damodharam Ammepalli 
---
 drivers/net/bnxt/bnxt.h|   6 ++
 drivers/net/bnxt/bnxt_ethdev.c |   8 ++-
 drivers/net/bnxt/bnxt_hwrm.c   | 104 +
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 drivers/net/bnxt/bnxt_vnic.c   |  13 -
 5 files changed, 102 insertions(+), 30 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index e7b288c849..576688bbff 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -809,6 +809,12 @@ struct bnxt {
 #define BNXT_VNIC_CAP_XOR_MODE BIT(5)
 #define BNXT_VNIC_CAP_CHKSM_MODE   BIT(6)
 #define BNXT_VNIC_CAP_L2_CQE_MODE  BIT(8)
+#define BNXT_VNIC_CAP_AH_SPI4_CAP  BIT(9)
+#define BNXT_VNIC_CAP_AH_SPI6_CAP  BIT(10)
+#define BNXT_VNIC_CAP_ESP_SPI4_CAP BIT(11)
+#define BNXT_VNIC_CAP_ESP_SPI6_CAP BIT(12)
+#define BNXT_VNIC_CAP_AH_SPI_CAP   (BNXT_VNIC_CAP_AH_SPI4_CAP | 
BNXT_VNIC_CAP_AH_SPI6_CAP)
+#define BNXT_VNIC_CAP_ESP_SPI_CAP  (BNXT_VNIC_CAP_ESP_SPI4_CAP | 
BNXT_VNIC_CAP_ESP_SPI6_CAP)
 
unsigned intrx_nr_rings;
unsigned intrx_cp_nr_rings;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index ef5e65ff16..5b775e7716 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -995,8 +995,12 @@ uint64_t bnxt_eth_rss_support(struct bnxt *bp)
  RTE_ETH_RSS_LEVEL_MASK;
 
if (bp->vnic_cap_flags & BNXT_VNIC_CAP_CHKSM_MODE)
-   support |= (RTE_ETH_RSS_IPV4_CHKSUM |
-   RTE_ETH_RSS_L4_CHKSUM);
+   support |= RTE_ETH_RSS_IPV4_CHKSUM |
+  RTE_ETH_RSS_L4_CHKSUM;
+   if (bp->vnic_cap_flags & BNXT_VNIC_CAP_AH_SPI_CAP)
+   support |= RTE_ETH_RSS_AH;
+   if (bp->vnic_cap_flags & BNXT_VNIC_CAP_ESP_SPI_CAP)
+   support |= RTE_ETH_RSS_ESP;
 
return support;
 }
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 587433a878..1ac3f30074 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1031,6 +1031,21 @@ int bnxt_hwrm_vnic_qcaps(struct bnxt *bp)
if (flags & 
HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RING_SELECT_MODE_TOEPLITZ_CHKSM_CAP)
bp->vnic_cap_flags |= BNXT_VNIC_CAP_CHKSM_MODE;
 
+   if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_L2_CQE_MODE_CAP)
+   bp->vnic_cap_flags |= BNXT_VNIC_CAP_L2_CQE_MODE;
+
+   if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_AH_SPI_IPV4_CAP)
+   bp->vnic_cap_flags |= BNXT_VNIC_CAP_AH_SPI4_CAP;
+
+   if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_AH_SPI_IPV6_CAP)
+   bp->vnic_cap_flags |= BNXT_VNIC_CAP_AH_SPI6_CAP;
+
+   if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_ESP_SPI_IPV4_CAP)
+   bp->vnic_cap_flags |= BNXT_VNIC_CAP_ESP_SPI4_CAP;
+
+   if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_ESP_SPI_IPV6_CAP)
+   bp->vnic_cap_flags |= BNXT_VNIC_CAP_ESP_SPI6_CAP;
+
bp->max_tpa_v2 = rte_le_to_cpu_16(resp->max_aggs_supported);
 
HWRM_UNLOCK();
@@ -2412,6 +2427,52 @@ int bnxt_hwrm_vnic_free(struct bnxt *bp, struct 
bnxt_vnic_info *vnic)
return rc;
 }
 
+static uint32_t bnxt_sanitize_rss_type(struct bnxt *bp, uint32_t types)
+{
+   uint32_t hwrm_type = types;
+
+   if (types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_ESP_SPI_IPV4 &&
+   !(bp->vnic_cap_flags & BNXT_VNIC_CAP_ESP_SPI4_CAP))
+   hwrm_type &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_ESP_SPI_IPV4;
+   if (types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_ESP_SPI_IPV6 &&
+   !(bp->vnic_cap_flags & BNXT_VNIC_CAP_ESP_SPI6_CAP))
+   hwrm_type &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_ESP_SPI_IPV6;
+
+   if (types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_AH_SPI_IPV4 &&
+   !(bp->vnic_cap_flags & BNXT_VNIC_CAP_AH_SPI4_CAP))
+   hwrm_type &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_AH_SPI_IPV4;
+
+   if (types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_AH_SPI_IPV6 &&
+   !(bp->vnic_cap_flags & BNXT_VNIC_CAP_AH_SPI6_CAP))
+   hwrm_type &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_AH_SPI_IPV6;
+
+   return hwrm_type;
+}
+
+#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
+static int
+bnxt_hwrm_vnic_rss_qcfg_p5(struct bnxt *bp)
+{
+   struct hwrm_vnic_rss_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
+   struct hwrm_vnic_rss_qcfg_input req = {0};
+   int rc;
+
+   HWRM_PREP(&req, HWRM_VNIC_RSS_QCFG, BNXT_USE_CHIMP_MB);
+   /* vnic_id and rss_ctx_idx must be set to INVALID to read the
+* global hash mode.
+*/
+   req.vnic_id = rte_cpu_to_le_16(BNXT_DFLT_VNIC_ID_INVALID);
+   req.rss_ctx_idx = rt

[PATCH v2 12/18] net/bnxt: set allmulti mode if multicast filter fails

2023-12-22 Thread Ajit Khaparde
Fallback to all multicast mode if FW rejects multicast filter
programming.

The firmware can reject the MC filter programming request if
it is running low in resources when there is a large number of functions.
The driver must be prepared to fallback to the all-multicast mode
if the original MC filter programming request is rejected.

Signed-off-by: Ajit Khaparde 
Reviewed-by: Damodharam Ammepalli 
---
 drivers/net/bnxt/bnxt_ethdev.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 5b775e7716..7aed6d3ab6 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -2947,7 +2947,17 @@ bnxt_dev_set_mc_addr_list_op(struct rte_eth_dev *eth_dev,
vnic->flags &= ~BNXT_VNIC_INFO_MCAST;
 
 allmulti:
-   return bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL);
+   rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL);
+   if (rc == -ENOSPC && (vnic->flags & BNXT_VNIC_INFO_MCAST)) {
+   /* If MCAST addition failed because FW ran out of
+* multicast filters, enable all multicast mode.
+*/
+   vnic->flags &= ~BNXT_VNIC_INFO_MCAST;
+   vnic->flags |= BNXT_VNIC_INFO_ALLMULTI;
+   goto allmulti;
+   }
+
+   return rc;
 }
 
 static int
-- 
2.39.2 (Apple Git-143)



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH v2 13/18] net/bnxt: add VF FLR async event handler

2023-12-22 Thread Ajit Khaparde
From: Jay Ding 

When a VF undergoes an FLR, the firmware indicates this via
an async notification to the PF. Note that the PF driver
needs to register for the notification with the firmware.
Add support for VF_FLR async event handling when the driver
is running on a PF.

Signed-off-by: Jay Ding 
Signed-off-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt_cpr.c  | 20 
 drivers/net/bnxt/bnxt_hwrm.c |  6 --
 drivers/net/bnxt/bnxt_hwrm.h |  2 ++
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index 0733cf4df2..fb43bc58da 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -127,6 +127,23 @@ void bnxt_handle_vf_cfg_change(void *arg)
}
 }
 
+static void
+bnxt_process_vf_flr(struct bnxt *bp, uint32_t data1)
+{
+   uint16_t pfid, vfid;
+
+   if (!BNXT_TRUFLOW_EN(bp))
+   return;
+
+   pfid = (data1 & HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_PF_ID_MASK) >>
+   HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_PF_ID_SFT;
+   vfid = (data1 & HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_VF_ID_MASK) >>
+   HWRM_ASYNC_EVENT_CMPL_VF_FLR_EVENT_DATA1_VF_ID_SFT;
+
+   PMD_DRV_LOG(INFO, "VF FLR async event received pfid: %u, vfid: %u\n",
+   pfid, vfid);
+}
+
 /*
  * Async event handling
  */
@@ -264,6 +281,9 @@ void bnxt_handle_async_event(struct bnxt *bp,
case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_REPORT:
bnxt_handle_event_error_report(bp, data1, data2);
break;
+   case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_FLR:
+   bnxt_process_vf_flr(bp, data1);
+   break;
default:
PMD_DRV_LOG(DEBUG, "handle_async_event id = 0x%x\n", event_id);
break;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 1ac3f30074..3c16abea69 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1125,9 +1125,11 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
req.async_event_fwd[1] |=
rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_DBG_NOTIFICATION);
 
-   if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))
+   if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) {
req.async_event_fwd[1] |=
-   rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE);
+   rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE |
+ASYNC_CMPL_EVENT_ID_VF_FLR);
+   }
 
req.async_event_fwd[2] |=
rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_ECHO_REQUEST |
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 56b232d7de..6116253787 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -29,6 +29,8 @@ struct hwrm_func_qstats_output;
(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY)
 #define ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD \
(1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD - 32))
+#define ASYNC_CMPL_EVENT_ID_VF_FLR \
+   (1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_FLR - 32))
 #define ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE  \
(1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE - 32))
 #define ASYNC_CMPL_EVENT_ID_DBG_NOTIFICATION   \
-- 
2.39.2 (Apple Git-143)



smime.p7s
Description: S/MIME Cryptographic Signature


[PATCH v2 14/18] net/bnxt: add tunnel TPA support

2023-12-22 Thread Ajit Khaparde
From: Damodharam Ammepalli 

This patch adds support for tunnel TPA type.
The tunnel TPA support is brought in by the updated bit_field
tnl_tpa_en(4) in hwrm_vnic_tpa_cfg_input->enables,
which is used by the firmware to indicate the capability
of the underlying hardware.

This patch updates hwrm HWRM_VNIC_TPA_CFG request
for vxlan, geneve and default tunnel type bit_fields.

The patch also updates to use the V3 TPA completion which
the P7 devices support.

Signed-off-by: Damodharam Ammepalli 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt.h  |  4 ++
 drivers/net/bnxt/bnxt_hwrm.c | 74 
 drivers/net/bnxt/bnxt_rxr.c  |  9 +++--
 drivers/net/bnxt/bnxt_vnic.c | 16 
 4 files changed, 100 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 576688bbff..2357e9f747 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "bnxt_cpr.h"
 #include "bnxt_util.h"
@@ -119,6 +120,8 @@
(BNXT_CHIP_P5_P7(bp) ? TPA_MAX_SEGS_TH : \
  TPA_MAX_SEGS)
 
+#define BNXT_TPA_MAX_PAGES 65536
+
 /*
  * Define the number of async completion rings to be used. Set to zero for
  * configurations in which the maximum number of packet completion rings
@@ -815,6 +818,7 @@ struct bnxt {
 #define BNXT_VNIC_CAP_ESP_SPI6_CAP BIT(12)
 #define BNXT_VNIC_CAP_AH_SPI_CAP   (BNXT_VNIC_CAP_AH_SPI4_CAP | 
BNXT_VNIC_CAP_AH_SPI6_CAP)
 #define BNXT_VNIC_CAP_ESP_SPI_CAP  (BNXT_VNIC_CAP_ESP_SPI4_CAP | 
BNXT_VNIC_CAP_ESP_SPI6_CAP)
+#define BNXT_VNIC_CAP_VNIC_TUNNEL_TPA  BIT(13)
 
unsigned intrx_nr_rings;
unsigned intrx_cp_nr_rings;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 3c16abea69..f896a41653 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1046,6 +1046,9 @@ int bnxt_hwrm_vnic_qcaps(struct bnxt *bp)
if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_RSS_IPSEC_ESP_SPI_IPV6_CAP)
bp->vnic_cap_flags |= BNXT_VNIC_CAP_ESP_SPI6_CAP;
 
+   if (flags & HWRM_VNIC_QCAPS_OUTPUT_FLAGS_HW_TUNNEL_TPA_CAP)
+   bp->vnic_cap_flags |= BNXT_VNIC_CAP_VNIC_TUNNEL_TPA;
+
bp->max_tpa_v2 = rte_le_to_cpu_16(resp->max_aggs_supported);
 
HWRM_UNLOCK();
@@ -2666,6 +2669,30 @@ int bnxt_hwrm_vnic_plcmode_cfg(struct bnxt *bp,
return rc;
 }
 
+#define BNXT_DFLT_TUNL_TPA_BMAP\
+   (HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_GRE |\
+HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_IPV4 |   \
+HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_IPV6)
+
+static void bnxt_vnic_update_tunl_tpa_bmap(struct bnxt *bp,
+  struct hwrm_vnic_tpa_cfg_input *req)
+{
+   uint32_t tunl_tpa_bmap = BNXT_DFLT_TUNL_TPA_BMAP;
+
+   if (!(bp->vnic_cap_flags & BNXT_VNIC_CAP_VNIC_TUNNEL_TPA))
+   return;
+
+   if (bp->vxlan_port_cnt)
+   tunl_tpa_bmap |= 
HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_VXLAN |
+   HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_VXLAN_GPE;
+
+   if (bp->geneve_port_cnt)
+   tunl_tpa_bmap |= 
HWRM_VNIC_TPA_CFG_INPUT_TNL_TPA_EN_BITMAP_GENEVE;
+
+   req->enables |= 
rte_cpu_to_le_32(HWRM_VNIC_TPA_CFG_INPUT_ENABLES_TNL_TPA_EN);
+   req->tnl_tpa_en_bitmap = rte_cpu_to_le_32(tunl_tpa_bmap);
+}
+
 int bnxt_hwrm_vnic_tpa_cfg(struct bnxt *bp,
struct bnxt_vnic_info *vnic, bool enable)
 {
@@ -2714,6 +2741,29 @@ int bnxt_hwrm_vnic_tpa_cfg(struct bnxt *bp,
 
if (BNXT_CHIP_P5_P7(bp))
req.max_aggs = rte_cpu_to_le_16(bp->max_tpa_v2);
+
+   /* For tpa v2 handle as per spec mss and log2 units */
+   if (BNXT_CHIP_P7(bp)) {
+   uint32_t nsegs, n, segs = 0;
+   uint16_t mss = bp->eth_dev->data->mtu - 40;
+   size_t page_size = rte_mem_page_size();
+   uint32_t max_mbuf_frags =
+   BNXT_TPA_MAX_PAGES / (rte_mem_page_size() + 1);
+
+   /* Calculate the number of segs based on mss */
+   if (mss <= page_size) {
+   n = page_size / mss;
+   nsegs = (max_mbuf_frags - 1) * n;
+   } else {
+   n = mss / page_size;
+   if (mss & (page_size - 1))
+   n++;
+   nsegs = (max_mbuf_frags - n) / n;
+   }
+   segs = rte_log2_u32(nsegs);
+   req.max_agg_segs = rte_cpu_to_le_16(segs);
+   }
+   bnxt_vnic_update_tunl_tpa_bmap(bp, &req);
}
req.vnic

[PATCH v2 15/18] net/bnxt: add 400G get support for P7 devices

2023-12-22 Thread Ajit Khaparde
From: Damodharam Ammepalli 

P7 devices report speeds over speeds2 hsi fields. Adding required
support to capture the capability from phy_qcap and save the
speeds2 fields into driver priv structure.
In fixed mode update the link_speed from force_link_speeds2 field.
Updates to logging to provide more info regarding numbers of lanes
and the link signal mode.

Some code refactoring done for PHY auto detect and displaying
XCVR information.

Signed-off-by: Damodharam Ammepalli 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt.h|  15 +
 drivers/net/bnxt/bnxt_ethdev.c |  57 ++-
 drivers/net/bnxt/bnxt_hwrm.c   | 493 -
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h |  10 +-
 5 files changed, 568 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 2357e9f747..858689533b 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -318,6 +318,16 @@ struct bnxt_link_info {
uint16_tsupport_pam4_auto_speeds;
uint8_t req_signal_mode;
uint8_t module_status;
+   /* P7 speeds2 fields */
+   boolsupport_speeds_v2;
+   uint16_tsupported_speeds2_force_mode;
+   uint16_tsupported_speeds2_auto_mode;
+   uint16_tsupport_speeds2;
+   uint16_tforce_link_speeds2;
+   uint16_tauto_link_speeds2;
+   uint16_tcfg_auto_link_speeds2_mask;
+   uint8_t active_lanes;
+   uint8_t option_flags;
 };
 
 #define BNXT_COS_QUEUE_COUNT   8
@@ -1156,6 +1166,11 @@ extern int bnxt_logtype_driver;
 #define PMD_DRV_LOG(level, fmt, args...) \
  PMD_DRV_LOG_RAW(level, fmt, ## args)
 
+#define BNXT_LINK_SPEEDS_V2_OPTIONS(f) \
+   ((f) & HWRM_PORT_PHY_QCFG_OUTPUT_OPTION_FLAGS_SPEEDS2_SUPPORTED)
+#define BNXT_LINK_SPEEDS_V2_VF(bp) (BNXT_VF((bp)) && 
((bp)->link_info->option_flags))
+#define BNXT_LINK_SPEEDS_V2(bp) (((bp)->link_info) && 
(((bp)->link_info->support_speeds_v2) || \
+  
BNXT_LINK_SPEEDS_V2_VF((bp
 extern const struct rte_flow_ops bnxt_ulp_rte_flow_ops;
 int32_t bnxt_ulp_port_init(struct bnxt *bp);
 void bnxt_ulp_port_deinit(struct bnxt *bp);
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 7aed6d3ab6..625e5f1f9a 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -697,7 +697,10 @@ static inline bool bnxt_force_link_config(struct bnxt *bp)
 
 static int bnxt_update_phy_setting(struct bnxt *bp)
 {
+   struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf;
+   struct rte_eth_link *link = &bp->eth_dev->data->dev_link;
struct rte_eth_link new;
+   uint32_t curr_speed_bit;
int rc;
 
rc = bnxt_get_hwrm_link_config(bp, &new);
@@ -706,13 +709,17 @@ static int bnxt_update_phy_setting(struct bnxt *bp)
return rc;
}
 
+   /* convert to speedbit flag */
+   curr_speed_bit = rte_eth_speed_bitflag((uint32_t)link->link_speed, 1);
+
/*
 * Device is not obliged link down in certain scenarios, even
 * when forced. When FW does not allow any user other than BMC
 * to shutdown the port, bnxt_get_hwrm_link_config() call always
 * returns link up. Force phy update always in that case.
 */
-   if (!new.link_status || bnxt_force_link_config(bp)) {
+   if (!new.link_status || bnxt_force_link_config(bp) ||
+   (BNXT_LINK_SPEEDS_V2(bp) && dev_conf->link_speeds != 
curr_speed_bit)) {
rc = bnxt_set_hwrm_link_config(bp, true);
if (rc) {
PMD_DRV_LOG(ERR, "Failed to update PHY settings\n");
@@ -933,6 +940,50 @@ static int bnxt_shutdown_nic(struct bnxt *bp)
  * Device configuration and status function
  */
 
+static uint32_t bnxt_get_speed_capabilities_v2(struct bnxt *bp)
+{
+   uint32_t link_speed = 0;
+   uint32_t speed_capa = 0;
+
+   if (bp->link_info == NULL)
+   return 0;
+
+   link_speed = bp->link_info->support_speeds2;
+
+   if (link_speed & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_1GB)
+   speed_capa |= RTE_ETH_LINK_SPEED_1G;
+   if (link_speed & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_10GB)
+   speed_capa |= RTE_ETH_LINK_SPEED_10G;
+   if (link_speed & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_25GB)
+   speed_capa |= RTE_ETH_LINK_SPEED_25G;
+   if (link_speed & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_40GB)
+   speed_capa |= RTE_ETH_LINK_SPEED_40G;
+   if (link_speed & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_50GB)
+   speed_capa |= RTE_ETH_LINK_SPEED_50G;
+   if (link_speed & HWRM_PORT_PHY_QCFG_OUTPUT_SUPPORT_SPEEDS2_10

[PATCH v2 16/18] net/bnxt: query extended stats from firmware

2023-12-22 Thread Ajit Khaparde
From: Damodharam Ammepalli 

Add the driver support for HWRM_STAT_EXT_CTX_QUERY HWRM
msg. In this patch only P7 chipset is enabled for this HWRM
while P5 and previous generation remain with HWRM_STAT_CTX_QUERY.

Signed-off-by: Damodharam Ammepalli 
Reviewed-by: Ajit Khaparde 
---
 drivers/net/bnxt/bnxt.h|  49 ++
 drivers/net/bnxt/bnxt_cpr.h|   3 +-
 drivers/net/bnxt/bnxt_ethdev.c |  36 -
 drivers/net/bnxt/bnxt_hwrm.c   | 117 ++
 drivers/net/bnxt/bnxt_hwrm.h   |  12 +-
 drivers/net/bnxt/bnxt_ring.c   |   6 +-
 drivers/net/bnxt/bnxt_rxq.c|   8 +-
 drivers/net/bnxt/bnxt_stats.c  | 279 ++---
 8 files changed, 483 insertions(+), 27 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 858689533b..d91f0e427d 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -705,6 +705,53 @@ struct bnxt_ring_stats {
uint64_trx_agg_aborts;
 };
 
+struct bnxt_ring_stats_ext {
+   /* Number of received unicast packets */
+   uint64_trx_ucast_pkts;
+   /* Number of received multicast packets */
+   uint64_trx_mcast_pkts;
+   /* Number of received broadcast packets */
+   uint64_trx_bcast_pkts;
+   /* Number of discarded packets on receive path */
+   uint64_trx_discard_pkts;
+   /* Number of packets on receive path with error */
+   uint64_trx_error_pkts;
+   /* Number of received bytes for unicast traffic */
+   uint64_trx_ucast_bytes;
+   /* Number of received bytes for multicast traffic */
+   uint64_trx_mcast_bytes;
+   /* Number of received bytes for broadcast traffic */
+   uint64_trx_bcast_bytes;
+   /* Number of transmitted unicast packets */
+   uint64_ttx_ucast_pkts;
+   /* Number of transmitted multicast packets */
+   uint64_ttx_mcast_pkts;
+   /* Number of transmitted broadcast packets */
+   uint64_ttx_bcast_pkts;
+   /* Number of packets on transmit path with error */
+   uint64_ttx_error_pkts;
+   /* Number of discarded packets on transmit path */
+   uint64_ttx_discard_pkts;
+   /* Number of transmitted bytes for unicast traffic */
+   uint64_ttx_ucast_bytes;
+   /* Number of transmitted bytes for multicast traffic */
+   uint64_ttx_mcast_bytes;
+   /* Number of transmitted bytes for broadcast traffic */
+   uint64_ttx_bcast_bytes;
+   /* Number of TPA eligible packets */
+   uint64_trx_tpa_eligible_pkt;
+   /* Number of TPA eligible bytes */
+   uint64_trx_tpa_eligible_bytes;
+   /* Number of TPA packets */
+   uint64_trx_tpa_pkt;
+   /* Number of TPA bytes */
+   uint64_trx_tpa_bytes;
+   /* Number of TPA errors */
+   uint64_trx_tpa_errors;
+   /* Number of TPA events */
+   uint64_trx_tpa_events;
+};
+
 enum bnxt_session_type {
BNXT_SESSION_TYPE_REGULAR = 0,
BNXT_SESSION_TYPE_SHARED_COMMON,
@@ -982,6 +1029,8 @@ struct bnxt {
uint16_ttx_cfa_action;
struct bnxt_ring_stats  *prev_rx_ring_stats;
struct bnxt_ring_stats  *prev_tx_ring_stats;
+   struct bnxt_ring_stats_ext  *prev_rx_ring_stats_ext;
+   struct bnxt_ring_stats_ext  *prev_tx_ring_stats_ext;
struct bnxt_vnic_queue_db vnic_queue_db;
 
 #define BNXT_MAX_MC_ADDRS  ((bp)->max_mcast_addr)
diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h
index 26e81a6a7e..c7b3480dc9 100644
--- a/drivers/net/bnxt/bnxt_cpr.h
+++ b/drivers/net/bnxt/bnxt_cpr.h
@@ -68,7 +68,8 @@ struct bnxt_cp_ring_info {
struct bnxt_db_info cp_db;
rte_iova_t  cp_desc_mapping;
 
-   struct ctx_hw_stats *hw_stats;
+   char*hw_stats;
+   uint16_thw_ring_stats_size;
rte_iova_t  hw_stats_map;
uint32_thw_stats_ctx_id;
 
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 625e5f1f9a..031028eda1 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -732,15 +732,49 @@ static int bnxt_update_phy_setting(struct bnxt *bp)
 
 static void bnxt_free_prev_ring_stats(struct bnxt *bp)
 {
+   /* tpa v2 devices use ext variant local struct */
+   if (BNXT_TPA_V2_P7(bp)) {
+   rte_free(bp->prev_rx_ring_stats_ext);
+   rte_free(bp->prev_tx_ring_stats_ext);
+   bp->prev_rx_ring_stats_ext = NULL;
+   bp->prev_tx_ring_stats_ext = NULL;
+   return;
+   }
rte_free(bp->prev_rx_ring_stats);
rte_free(bp->prev_tx_ring_stats);
-
bp->prev_rx_ring_stats = NULL;
bp->prev_tx_ring_stats = NULL;
 }
 
+static int bnxt_alloc_prev_ring_ext_stats(struct bnxt *bp)
+{
+   bp-

[PATCH v2 17/18] net/bnxt: add AVX2 support for compressed CQE

2023-12-22 Thread Ajit Khaparde
P7 device family supports 16 byte Rx completions.
Add AVX2 vector mode for compressed Rx CQE.

Signed-off-by: Ajit Khaparde 
Reviewed-by: Damodharam Ammepalli 
---
 drivers/net/bnxt/bnxt_ethdev.c|   5 +
 drivers/net/bnxt/bnxt_rxr.h   |   2 +
 drivers/net/bnxt/bnxt_rxtx_vec_avx2.c | 309 ++
 3 files changed, 316 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 031028eda1..bd8c7557dd 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1406,6 +1406,8 @@ bnxt_receive_function(struct rte_eth_dev *eth_dev)
"Using AVX2 vector mode receive for port %d\n",
eth_dev->data->port_id);
bp->flags |= BNXT_FLAG_RX_VECTOR_PKT_MODE;
+   if (bnxt_compressed_rx_cqe_mode_enabled(bp))
+   return bnxt_crx_pkts_vec_avx2;
return bnxt_recv_pkts_vec_avx2;
}
  #endif
@@ -3124,6 +3126,9 @@ static const struct {
{bnxt_recv_pkts,"Scalar"},
 #if defined(RTE_ARCH_X86)
{bnxt_recv_pkts_vec,"Vector SSE"},
+#endif
+#if defined(RTE_ARCH_X86) && defined(CC_AVX2_SUPPORT)
+   {bnxt_crx_pkts_vec_avx2,"Vector AVX2"},
{bnxt_recv_pkts_vec_avx2,   "Vector AVX2"},
 #endif
 #if defined(RTE_ARCH_ARM64)
diff --git a/drivers/net/bnxt/bnxt_rxr.h b/drivers/net/bnxt/bnxt_rxr.h
index c51bb2d62c..a474a69ae3 100644
--- a/drivers/net/bnxt/bnxt_rxr.h
+++ b/drivers/net/bnxt/bnxt_rxr.h
@@ -162,6 +162,8 @@ int bnxt_rxq_vec_setup(struct bnxt_rx_queue *rxq);
 #if defined(RTE_ARCH_X86)
 uint16_t bnxt_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
 uint16_t nb_pkts);
+uint16_t bnxt_crx_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts);
 #endif
 void bnxt_set_mark_in_mbuf(struct bnxt *bp,
   struct rx_pkt_cmpl_hi *rxcmp1,
diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_avx2.c 
b/drivers/net/bnxt/bnxt_rxtx_vec_avx2.c
index ea8dbaffba..e4d84bc9b6 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_avx2.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_avx2.c
@@ -361,6 +361,294 @@ recv_burst_vec_avx2(void *rx_queue, struct rte_mbuf 
**rx_pkts, uint16_t nb_pkts)
return nb_rx_pkts;
 }
 
+static uint16_t
+crx_burst_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
+{
+   struct bnxt_rx_queue *rxq = rx_queue;
+   const __m256i mbuf_init =
+   _mm256_set_epi64x(0, 0, 0, rxq->mbuf_initializer);
+   struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
+   struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
+   uint16_t cp_ring_size = cpr->cp_ring_struct->ring_size;
+   uint16_t rx_ring_size = rxr->rx_ring_struct->ring_size;
+   struct cmpl_base *cp_desc_ring = cpr->cp_desc_ring;
+   uint64_t valid, desc_valid_mask = ~0ULL;
+   const __m256i info3_v_mask = _mm256_set1_epi32(CMPL_BASE_V);
+   uint32_t raw_cons = cpr->cp_raw_cons;
+   uint32_t cons, mbcons;
+   int nb_rx_pkts = 0;
+   int i;
+   const __m256i valid_target =
+   _mm256_set1_epi32(!!(raw_cons & cp_ring_size));
+   const __m256i shuf_msk =
+   _mm256_set_epi8(15, 14, 13, 12,  /* rss */
+   7, 6,/* vlan_tci */
+   3, 2,/* data_len */
+   0xFF, 0xFF, 3, 2,/* pkt_len */
+   0xFF, 0xFF, 0xFF, 0xFF,  /* pkt_type (zeroes) */
+   15, 14, 13, 12,  /* rss */
+   7, 6,/* vlan_tci */
+   3, 2,/* data_len */
+   0xFF, 0xFF, 3, 2,/* pkt_len */
+   0xFF, 0xFF, 0xFF, 0xFF); /* pkt_type (zeroes) */
+   const __m256i flags_type_mask =
+   _mm256_set1_epi32(RX_PKT_CMPL_FLAGS_ITYPE_MASK);
+   const __m256i flags2_mask1 =
+   _mm256_set1_epi32(CMPL_FLAGS2_VLAN_TUN_MSK);
+   const __m256i flags2_mask2 =
+   _mm256_set1_epi32(RX_PKT_CMPL_FLAGS2_IP_TYPE);
+   const __m256i rss_mask =
+   _mm256_set1_epi32(RX_PKT_CMPL_FLAGS_RSS_VALID);
+   __m256i t0, t1, flags_type, flags2, index, errors;
+   __m256i ptype_idx, ptypes, is_tunnel;
+   __m256i mbuf01, mbuf23, mbuf45, mbuf67;
+   __m256i rearm0, rearm1, rearm2, rearm3, rearm4, rearm5, rearm6, rearm7;
+   __m256i ol_flags, ol_flags_hi;
+   __m256i rss_flags;
+
+   /* Validate ptype table indexing at build time. */
+   bnxt_check_ptype_constants();
+
+   /* If Rx Q was stopped return */
+   if (unlikely(!rxq->rx_started))
+   return 0;
+
+   if (rxq->rxrearm_nb >= rxq->rx_free_thresh)
+   b

[PATCH v2 18/18] net/bnxt: enable SSE mode for compressed CQE

2023-12-22 Thread Ajit Khaparde
P7 device family supports 16 byte Rx completions.
Enable SSE vector mode for compressed Rx CQE processing.

Signed-off-by: Ajit Khaparde 
Reviewed-by: Damodharam Ammepalli 
---
 drivers/net/bnxt/bnxt_ethdev.c   |  16 ++-
 drivers/net/bnxt/bnxt_rxr.h  |   2 +
 drivers/net/bnxt/bnxt_rxtx_vec_sse.c | 167 +--
 3 files changed, 173 insertions(+), 12 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index bd8c7557dd..f9cd234bb6 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1377,7 +1377,8 @@ bnxt_receive_function(struct rte_eth_dev *eth_dev)
 * asynchronous completions and receive completions can be placed in
 * the same completion ring.
 */
-   if (BNXT_TRUFLOW_EN(bp) || !BNXT_NUM_ASYNC_CPR(bp))
+   if ((BNXT_TRUFLOW_EN(bp) && !BNXT_CHIP_P7(bp)) ||
+   !BNXT_NUM_ASYNC_CPR(bp))
goto use_scalar_rx;
 
/*
@@ -1410,12 +1411,19 @@ bnxt_receive_function(struct rte_eth_dev *eth_dev)
return bnxt_crx_pkts_vec_avx2;
return bnxt_recv_pkts_vec_avx2;
}
- #endif
+#endif
if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
PMD_DRV_LOG(INFO,
"Using SSE vector mode receive for port %d\n",
eth_dev->data->port_id);
bp->flags |= BNXT_FLAG_RX_VECTOR_PKT_MODE;
+   if (bnxt_compressed_rx_cqe_mode_enabled(bp)) {
+#if defined(RTE_ARCH_ARM64)
+   goto use_scalar_rx;
+#else
+   return bnxt_crx_pkts_vec;
+#endif
+   }
return bnxt_recv_pkts_vec;
}
 
@@ -1445,7 +1453,8 @@ bnxt_transmit_function(__rte_unused struct rte_eth_dev 
*eth_dev)
 */
if (eth_dev->data->scattered_rx ||
(offloads & ~RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) ||
-   BNXT_TRUFLOW_EN(bp) || bp->ieee_1588)
+   (BNXT_TRUFLOW_EN(bp) && !BNXT_CHIP_P7(bp)) ||
+   bp->ieee_1588)
goto use_scalar_tx;
 
 #if defined(RTE_ARCH_X86)
@@ -3125,6 +3134,7 @@ static const struct {
 } bnxt_rx_burst_info[] = {
{bnxt_recv_pkts,"Scalar"},
 #if defined(RTE_ARCH_X86)
+   {bnxt_crx_pkts_vec, "Vector SSE"},
{bnxt_recv_pkts_vec,"Vector SSE"},
 #endif
 #if defined(RTE_ARCH_X86) && defined(CC_AVX2_SUPPORT)
diff --git a/drivers/net/bnxt/bnxt_rxr.h b/drivers/net/bnxt/bnxt_rxr.h
index a474a69ae3..d36cbded1d 100644
--- a/drivers/net/bnxt/bnxt_rxr.h
+++ b/drivers/net/bnxt/bnxt_rxr.h
@@ -156,6 +156,8 @@ int bnxt_flush_rx_cmp(struct bnxt_cp_ring_info *cpr);
 #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
 uint16_t bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
+uint16_t bnxt_crx_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
+  uint16_t nb_pkts);
 int bnxt_rxq_vec_setup(struct bnxt_rx_queue *rxq);
 #endif
 
diff --git a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c 
b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
index e99a547f58..c04b33a382 100644
--- a/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
+++ b/drivers/net/bnxt/bnxt_rxtx_vec_sse.c
@@ -54,15 +54,9 @@
 
 static inline void
 descs_to_mbufs(__m128i mm_rxcmp[4], __m128i mm_rxcmp1[4],
-  __m128i mbuf_init, struct rte_mbuf **mbuf,
-  struct bnxt_rx_ring_info *rxr)
+  __m128i mbuf_init, const __m128i shuf_msk,
+  struct rte_mbuf **mbuf, struct bnxt_rx_ring_info *rxr)
 {
-   const __m128i shuf_msk =
-   _mm_set_epi8(15, 14, 13, 12,  /* rss */
-0xFF, 0xFF,  /* vlan_tci (zeroes) */
-3, 2,/* data_len */
-0xFF, 0xFF, 3, 2,/* pkt_len */
-0xFF, 0xFF, 0xFF, 0xFF); /* pkt_type (zeroes) */
const __m128i flags_type_mask =
_mm_set1_epi32(RX_PKT_CMPL_FLAGS_ITYPE_MASK);
const __m128i flags2_mask1 =
@@ -166,6 +160,12 @@ recv_burst_vec_sse(void *rx_queue, struct rte_mbuf 
**rx_pkts, uint16_t nb_pkts)
int nb_rx_pkts = 0;
const __m128i valid_target =
_mm_set1_epi32(!!(raw_cons & cp_ring_size));
+   const __m128i shuf_msk =
+   _mm_set_epi8(15, 14, 13, 12,  /* rss */
+0xFF, 0xFF,  /* vlan_tci (zeroes) */
+3, 2,/* data_len */
+0xFF, 0xFF, 3, 2,/* pkt_len */
+0xFF, 0xFF, 0xFF, 0xFF); /* pkt_type (zeroes) */
int i;
 
/* If Rx Q was stopped return */
@@ -264,7 +264,7 @@ recv_burst_vec_sse(void *rx_queue, struct rte_mbuf 
**rx_pkts, uint16_t nb_pkts)
if (num_valid == 0)

Re: [EXT] [PATCH v6 05/20] net/dpaa2: used dedicated logtype not PMD

2023-12-22 Thread Stephen Hemminger
On Sat, 23 Dec 2023 00:53:51 +
Jun Yang  wrote:

> What is the log level of DPAA2_PMD_INFO? I expect to print information by 
> this as default.
> 
> 获取 Outlook for iOS

The default log level of DPAA2 is NOTICE
RTE_LOG_REGISTER_DEFAULT(dpaa2_logtype_pmd, NOTICE);

But there is no reason for drivers to be so chatty.
Log messages are something developers seem to want a lot.
But at scale they just add up to more noise to wade through.