Re: [RFC] Remove Kernel Network Interface (KNI)

2023-01-13 Thread Thomas Monjalon
13/01/2023 06:03, Stephen Hemminger:
> The Linux special network driver for kernel networking has been
> a long term problem for DPDK. The performance benefits of KNI
> are available via virtio-user and XDP, and the simpler kernel
> interface via TAP is also available.
> 
> This driver has required lots of effort to keep up with the
> kernel API changes. And the overall architecture of the driver
> is fundamentally insecure and has unfixable locking and data
> race problems. No developer has been willing to do extensive
> tests or be the maintainer.
> 
> In short, the time has come to do some early spring cleaning
> and remove KNI from DPDK 23.03.

In doc/guides/rel_notes/deprecation.rst it is announced
to be removed in 23.11. Let's keep this RFC for later :)




RE: [PATCH v5 3/6] ethdev: add trace points for remaining functions

2023-01-13 Thread Sunil Kumar Kori
> -Original Message-
> From: Ankur Dwivedi 
> Sent: Friday, January 13, 2023 12:01 PM
> To: Sunil Kumar Kori ; dev@dpdk.org
> Cc: tho...@monjalon.net; david.march...@redhat.com; m...@ashroe.eu;
> or...@nvidia.com; ferruh.yi...@amd.com; ch...@att.com;
> humi...@huawei.com; linvi...@tuxdriver.com; ciara.lof...@intel.com;
> qi.z.zh...@intel.com; m...@semihalf.com; m...@semihalf.com;
> shaib...@amazon.com; evge...@amazon.com; igo...@amazon.com;
> cha...@amd.com; Igor Russkikh ;
> shepard.sie...@atomicrules.com; ed.cz...@atomicrules.com;
> john.mil...@atomicrules.com; ajit.khapa...@broadcom.com;
> somnath.ko...@broadcom.com; Jerin Jacob Kollanukkaran
> ; Maciej Czekaj [C] ; Shijith
> Thotton ; Srisivasubramanian Srinivasan
> ; Harman Kalra ;
> rahul.lakkire...@chelsio.com; johnd...@cisco.com; hyon...@cisco.com;
> liudongdo...@huawei.com; yisen.zhu...@huawei.com;
> xuanziya...@huawei.com; cloud.wangxiao...@huawei.com;
> zhouguoy...@huawei.com; simei...@intel.com; wenjun1...@intel.com;
> qiming.y...@intel.com; yuying.zh...@intel.com; beilei.x...@intel.com;
> xiao.w.w...@intel.com; jingjing...@intel.com; junfeng@intel.com;
> rosen...@intel.com; Nithin Kumar Dabilpuram
> ; Kiran Kumar Kokkilagadda
> ; Satha Koteswara Rao Kottidi
> ; Liron Himi ;
> z...@semihalf.com; Radha Chintakuntla ;
> Veerasenareddy Burru ; Sathesh B Edara
> ; ma...@nvidia.com; viachesl...@nvidia.com;
> lon...@microsoft.com; spin...@cesnet.cz; chaoyong...@corigine.com;
> niklas.soderl...@corigine.com; hemant.agra...@nxp.com;
> sachin.sax...@oss.nxp.com; g.si...@nxp.com; apeksha.gu...@nxp.com;
> sachin.sax...@nxp.com; abo...@pensando.io; Rasesh Mody
> ; Shahed Shaikh ; Devendra
> Singh Rawat ; andrew.rybche...@oktetlabs.ru;
> jiawe...@trustnetic.com; jianw...@trustnetic.com;
> jbehr...@vmware.com; maxime.coque...@redhat.com;
> chenbo@intel.com; steven.webs...@windriver.com;
> matt.pet...@windriver.com; bruce.richard...@intel.com;
> mtetsu...@gmail.com; gr...@u256.net; jasvinder.si...@intel.com;
> cristian.dumitre...@intel.com; jgraj...@cisco.com;
> m...@smartsharesystems.com
> Subject: RE: [PATCH v5 3/6] ethdev: add trace points for remaining functions
> 
> Hi Sunil,
> 
> My comments are inline.
> 
> >-Original Message-
> >From: Sunil Kumar Kori 
> >Sent: Thursday, January 12, 2023 10:09 PM
> >To: Ankur Dwivedi ; dev@dpdk.org
> >Cc: tho...@monjalon.net; david.march...@redhat.com;
> m...@ashroe.eu;
> >or...@nvidia.com; ferruh.yi...@amd.com; ch...@att.com;
> >humi...@huawei.com; linvi...@tuxdriver.com; ciara.lof...@intel.com;
> >qi.z.zh...@intel.com; m...@semihalf.com; m...@semihalf.com;
> >shaib...@amazon.com; evge...@amazon.com; igo...@amazon.com;
> >cha...@amd.com; Igor Russkikh ;
> >shepard.sie...@atomicrules.com; ed.cz...@atomicrules.com;
> >john.mil...@atomicrules.com; ajit.khapa...@broadcom.com;
> >somnath.ko...@broadcom.com; Jerin Jacob Kollanukkaran
> >; Maciej Czekaj [C] ; Shijith
> >Thotton ; Srisivasubramanian Srinivasan
> >; Harman Kalra ;
> >rahul.lakkire...@chelsio.com; johnd...@cisco.com; hyon...@cisco.com;
> >liudongdo...@huawei.com; yisen.zhu...@huawei.com;
> >xuanziya...@huawei.com; cloud.wangxiao...@huawei.com;
> >zhouguoy...@huawei.com; simei...@intel.com; wenjun1...@intel.com;
> >qiming.y...@intel.com; yuying.zh...@intel.com; beilei.x...@intel.com;
> >xiao.w.w...@intel.com; jingjing...@intel.com; junfeng@intel.com;
> >rosen...@intel.com; Nithin Kumar Dabilpuram
> ;
> >Kiran Kumar Kokkilagadda ; Satha Koteswara
> Rao
> >Kottidi ; Liron Himi ;
> >z...@semihalf.com; Radha Chintakuntla ;
> >Veerasenareddy Burru ; Sathesh B Edara
> >; ma...@nvidia.com; viachesl...@nvidia.com;
> >lon...@microsoft.com; spin...@cesnet.cz; chaoyong...@corigine.com;
> >niklas.soderl...@corigine.com; hemant.agra...@nxp.com;
> >sachin.sax...@oss.nxp.com; g.si...@nxp.com; apeksha.gu...@nxp.com;
> >sachin.sax...@nxp.com; abo...@pensando.io; Rasesh Mody
> >; Shahed Shaikh ;
> Devendra
> >Singh Rawat ;
> andrew.rybche...@oktetlabs.ru;
> >jiawe...@trustnetic.com; jianw...@trustnetic.com;
> jbehr...@vmware.com;
> >maxime.coque...@redhat.com; chenbo@intel.com;
> >steven.webs...@windriver.com; matt.pet...@windriver.com;
> >bruce.richard...@intel.com; mtetsu...@gmail.com; gr...@u256.net;
> >jasvinder.si...@intel.com; cristian.dumitre...@intel.com;
> jgraj...@cisco.com;
> >m...@smartsharesystems.com; Ankur Dwivedi 
> >Subject: RE: [PATCH v5 3/6] ethdev: add trace points for remaining functions
> >
> >> -Original Message-
> >> From: Ankur Dwivedi 
> >> Sent: Thursday, January 12, 2023 4:52 PM
> >> To: dev@dpdk.org
> >> Cc: tho...@monjalon.net; david.march...@redhat.com;
> m...@ashroe.eu;
> >> or...@nvidia.com; ferruh.yi...@amd.com; ch...@att.com;
> >> humi...@huawei.com; linvi...@tuxdriver.com; ciara.lof...@intel.com;
> >> qi.z.zh...@intel.com; m...@semihalf.com; m...@semihalf.com;
> >> shaib...@amazon.com; evge...@amazon.com; igo...@amazon.com;
> >> cha...@amd.com; Igor Russkikh ;
> >> shepard.sie...@atomicrules.com; ed.cz..

RE: [PATCH] app/testpmd: fix secondary process not forwarding

2023-01-13 Thread He, ShiyangX
@Zhang, Yuying Hi, please take a look at this patch! Are there any comments?

>-Original Message-
>From: He, ShiyangX 
>Sent: Wednesday, January 4, 2023 10:02 AM
>To: Stephen Hemminger 
>Cc: dev@dpdk.org; Zhou, YidingX ;
>sta...@dpdk.org; Singh, Aman Deep ; Zhang,
>Yuying ; Burakov, Anatoly
>; Li, Xiaoyun ; Alvin
>Zhang 
>Subject: RE: [PATCH] app/testpmd: fix secondary process not forwarding
>
>>> Under multi-process scenario, the secondary process gets queue state
>>> from the wrong location (the global variable 'ports'). Therefore, the
>>> secondary process can not forward since "stream_init" is not called.
>>>
>>> This commit fixes the issue by calling 'rte_eth_rx/tx_queue_info_get'
>>> to get queue state from shared memory.
>>>
>>> Fixes: a78040c990cb ("app/testpmd: update forward engine beginning")
>>> Cc: sta...@dpdk.org
>>>
>>> Signed-off-by: Shiyang He 
>>
>>Would it be possible to fix this the initialization of ports variable,
>>rather than doing a per-state fixup here?
>
>In multi-process scenario, the secondary process does not initialize the queue
>state in the 'ports' variable, and the ethdev's queue state may be changed by
>any other process, which causes 'ports' queue state of per-process and
>ethdev's queue state are inconsistent. Therefore, getting the queue state
>from ethdev is a feasible way which I can think of.


[PATCH v2 00/21] add support for cpfl PMD in DPDK

2023-01-13 Thread Mingxia Liu
The patchset introduced the cpfl (Control Plane Function Library) PMD
for Intel® IPU E2100’s Configure Physical Function (Device ID: 0x1453)

The cpfl PMD inherits all the features from idpf PMD which will follow
an ongoing standard data plan function spec
https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=idpf
Besides, it will also support more device specific hardware offloading
features from DPDK’s control path (e.g.: hairpin, rte_flow …)

This patchset mainly focuses on idpf PMD’s equivalent features.
To avoid duplicated code, the patchset depends on below patchsets which
move the common part from net/idpf into common/idpf as a shared library.

This patchset is based on the idpf PMD code:
http://patches.dpdk.org/project/dpdk/cover/20230106090501.9106-1-beilei.x...@intel.com/
http://patches.dpdk.org/project/dpdk/cover/20230106091627.13530-1-beilei.x...@intel.com/
http://patches.dpdk.org/project/dpdk/patch/20230113015119.3279019-2-wenjun1...@intel.com/
http://patches.dpdk.org/project/dpdk/cover/20230111071545.504706-1-mingxia@intel.com/

v2 changes:
 - rebase to the new baseline.
 - Fix rss lut config issue.

Mingxia Liu (21):
  net/cpfl: support device initialization
  net/cpfl: add Tx queue setup
  net/cpfl: add Rx queue setup
  net/cpfl: support device start and stop
  net/cpfl: support queue start
  net/cpfl: support queue stop
  net/cpfl: support queue release
  net/cpfl: support MTU configuration
  net/cpfl: support basic Rx data path
  net/cpfl: support basic Tx data path
  net/cpfl: support write back based on ITR expire
  net/cpfl: support RSS
  net/cpfl: support Rx offloading
  net/cpfl: support Tx offloading
  net/cpfl: add AVX512 data path for single queue model
  net/cpfl: support timestamp offload
  net/cpfl: add AVX512 data path for split queue model
  net/cpfl: add hw statistics
  net/cpfl: add RSS set/get ops
  net/cpfl: support single q scatter RX datapath
  net/cpfl: add xstats ops

 MAINTAINERS |9 +
 doc/guides/nics/cpfl.rst|   88 ++
 doc/guides/nics/features/cpfl.ini   |   17 +
 doc/guides/rel_notes/release_23_03.rst  |5 +
 drivers/net/cpfl/cpfl_ethdev.c  | 1490 +++
 drivers/net/cpfl/cpfl_ethdev.h  |   95 ++
 drivers/net/cpfl/cpfl_logs.h|   32 +
 drivers/net/cpfl/cpfl_rxtx.c|  900 ++
 drivers/net/cpfl/cpfl_rxtx.h|   44 +
 drivers/net/cpfl/cpfl_rxtx_vec_common.h |  113 ++
 drivers/net/cpfl/meson.build|   38 +
 drivers/net/idpf/idpf_ethdev.c  |3 +-
 drivers/net/meson.build |1 +
 13 files changed, 2834 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/nics/cpfl.rst
 create mode 100644 doc/guides/nics/features/cpfl.ini
 create mode 100644 drivers/net/cpfl/cpfl_ethdev.c
 create mode 100644 drivers/net/cpfl/cpfl_ethdev.h
 create mode 100644 drivers/net/cpfl/cpfl_logs.h
 create mode 100644 drivers/net/cpfl/cpfl_rxtx.c
 create mode 100644 drivers/net/cpfl/cpfl_rxtx.h
 create mode 100644 drivers/net/cpfl/cpfl_rxtx_vec_common.h
 create mode 100644 drivers/net/cpfl/meson.build

-- 
2.25.1



[PATCH v2 01/21] net/cpfl: support device initialization

2023-01-13 Thread Mingxia Liu
Support device init and add the following dev ops:
 - dev_configure
 - dev_close
 - dev_infos_get
 - link_update
 - cpfl_dev_supported_ptypes_get

Signed-off-by: Mingxia Liu 
---
 MAINTAINERS|   9 +
 doc/guides/nics/cpfl.rst   |  66 +++
 doc/guides/nics/features/cpfl.ini  |  12 +
 doc/guides/rel_notes/release_23_03.rst |   5 +
 drivers/net/cpfl/cpfl_ethdev.c | 769 +
 drivers/net/cpfl/cpfl_ethdev.h |  78 +++
 drivers/net/cpfl/cpfl_logs.h   |  32 +
 drivers/net/cpfl/cpfl_rxtx.c   | 244 
 drivers/net/cpfl/cpfl_rxtx.h   |  25 +
 drivers/net/cpfl/meson.build   |  14 +
 drivers/net/meson.build|   1 +
 11 files changed, 1255 insertions(+)
 create mode 100644 doc/guides/nics/cpfl.rst
 create mode 100644 doc/guides/nics/features/cpfl.ini
 create mode 100644 drivers/net/cpfl/cpfl_ethdev.c
 create mode 100644 drivers/net/cpfl/cpfl_ethdev.h
 create mode 100644 drivers/net/cpfl/cpfl_logs.h
 create mode 100644 drivers/net/cpfl/cpfl_rxtx.c
 create mode 100644 drivers/net/cpfl/cpfl_rxtx.h
 create mode 100644 drivers/net/cpfl/meson.build

diff --git a/MAINTAINERS b/MAINTAINERS
index 22ef2ea4b9..970acc5751 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -780,6 +780,15 @@ F: drivers/common/idpf/
 F: doc/guides/nics/idpf.rst
 F: doc/guides/nics/features/idpf.ini
 
+Intel cpfl
+M: Qi Zhang 
+M: Jingjing Wu 
+M: Beilei Xing 
+T: git://dpdk.org/next/dpdk-next-net-intel
+F: drivers/net/cpfl/
+F: doc/guides/nics/cpfl.rst
+F: doc/guides/nics/features/cpfl.ini
+
 Intel igc
 M: Junfeng Guo 
 M: Simei Su 
diff --git a/doc/guides/nics/cpfl.rst b/doc/guides/nics/cpfl.rst
new file mode 100644
index 00..064c69ba7d
--- /dev/null
+++ b/doc/guides/nics/cpfl.rst
@@ -0,0 +1,66 @@
+.. SPDX-License-Identifier: BSD-3-Clause
+   Copyright(c) 2022 Intel Corporation.
+
+.. include:: 
+
+CPFL Poll Mode Driver
+=
+
+The [*EXPERIMENTAL*] cpfl PMD (**librte_net_cpfl**) provides poll mode driver 
support
+for Intel\ |reg| Infrastructure Processing Unit (Intel\ |reg| IPU) E2100.
+
+
+Linux Prerequisites
+---
+
+Follow the DPDK :doc:`../linux_gsg/index` to setup the basic DPDK environment.
+
+To get better performance on Intel platforms,
+please follow the :doc:`../linux_gsg/nic_perf_intel_platform`.
+
+
+Pre-Installation Configuration
+--
+
+Runtime Config Options
+~~
+
+- ``vport`` (default ``0``)
+
+  The PMD supports creation of multiple vports for one PCI device,
+  each vport corresponds to a single ethdev.
+  The user can specify the vports with specific ID to be created, for example::
+
+-a ca:00.0,vport=[0,2,3]
+
+  Then the PMD will create 3 vports (ethdevs) for device ``ca:00.0``.
+
+  If the parameter is not provided, the vport 0 will be created by default.
+
+- ``rx_single`` (default ``0``)
+
+  There are two queue modes supported by Intel\ |reg| IPU Ethernet ES2000 
Series,
+  single queue mode and split queue mode for Rx queue.
+  User can choose Rx queue mode, example::
+
+-a ca:00.0,rx_single=1
+
+  Then the PMD will configure Rx queue with single queue mode.
+  Otherwise, split queue mode is chosen by default.
+
+- ``tx_single`` (default ``0``)
+
+  There are two queue modes supported by Intel\ |reg| IPU Ethernet ES2000 
Series,
+  single queue mode and split queue mode for Tx queue.
+  User can choose Tx queue mode, example::
+
+-a ca:00.0,tx_single=1
+
+  Then the PMD will configure Tx queue with single queue mode.
+  Otherwise, split queue mode is chosen by default.
+
+
+Driver compilation and testing
+--
+
+Refer to the document :doc:`build_and_test` for details.
\ No newline at end of file
diff --git a/doc/guides/nics/features/cpfl.ini 
b/doc/guides/nics/features/cpfl.ini
new file mode 100644
index 00..a2d1ca9e15
--- /dev/null
+++ b/doc/guides/nics/features/cpfl.ini
@@ -0,0 +1,12 @@
+;
+; Supported features of the 'cpfl' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+; A feature with "P" indicates only be supported when non-vector path
+; is selected.
+;
+[Features]
+Linux= Y
+x86-32   = Y
+x86-64   = Y
diff --git a/doc/guides/rel_notes/release_23_03.rst 
b/doc/guides/rel_notes/release_23_03.rst
index b8c5b68d6c..465a25e91e 100644
--- a/doc/guides/rel_notes/release_23_03.rst
+++ b/doc/guides/rel_notes/release_23_03.rst
@@ -55,6 +55,11 @@ New Features
  Also, make sure to start the actual text at the margin.
  ===
 
+* **Added Intel cpfl driver.**
+
+  Added the new ``cpfl`` net driver
+  for Intel\ |reg| Infrastructure Processing Unit (Intel\ |reg| IPU) E2100.
+  See the :doc:`../nics/cpfl` NIC guide for more details on this new driver.
 
 Removed Items
 -
diff --git a/drivers/net/cpfl/cpfl_ethdev

[PATCH v2 02/21] net/cpfl: add Tx queue setup

2023-01-13 Thread Mingxia Liu
Add support for tx_queue_setup ops.

In the single queue model, the same descriptor queue is used by SW to
post buffer descriptors to HW and by HW to post completed descriptors
to SW.

In the split queue model, "RX buffer queues" are used to pass
descriptor buffers from SW to HW while Rx queues are used only to
pass the descriptor completions, that is, descriptors that point
to completed buffers, from HW to SW. This is contrary to the single
queue model in which Rx queues are used for both purposes.

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c | 13 +
 drivers/net/cpfl/meson.build   |  1 +
 2 files changed, 14 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 2d79ba2098..f07e2f97a2 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -12,6 +12,7 @@
 #include 
 
 #include "cpfl_ethdev.h"
+#include "cpfl_rxtx.h"
 
 #define CPFL_TX_SINGLE_Q   "tx_single"
 #define CPFL_RX_SINGLE_Q   "rx_single"
@@ -96,6 +97,17 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
dev_info->max_mtu = vport->max_mtu;
dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 
+   dev_info->default_txconf = (struct rte_eth_txconf) {
+   .tx_free_thresh = CPFL_DEFAULT_TX_FREE_THRESH,
+   .tx_rs_thresh = CPFL_DEFAULT_TX_RS_THRESH,
+   };
+
+   dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
+   .nb_max = CPFL_MAX_RING_DESC,
+   .nb_min = CPFL_MIN_RING_DESC,
+   .nb_align = CPFL_ALIGN_RING_DESC,
+   };
+
return 0;
 }
 
@@ -514,6 +526,7 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, 
struct cpfl_adapter_ext *a
 static const struct eth_dev_ops cpfl_eth_dev_ops = {
.dev_configure  = cpfl_dev_configure,
.dev_close  = cpfl_dev_close,
+   .tx_queue_setup = cpfl_tx_queue_setup,
.dev_infos_get  = cpfl_dev_info_get,
.link_update= cpfl_dev_link_update,
.dev_supported_ptypes_get   = cpfl_dev_supported_ptypes_get,
diff --git a/drivers/net/cpfl/meson.build b/drivers/net/cpfl/meson.build
index 106cc97e60..3ccee15703 100644
--- a/drivers/net/cpfl/meson.build
+++ b/drivers/net/cpfl/meson.build
@@ -11,4 +11,5 @@ deps += ['common_idpf']
 
 sources = files(
 'cpfl_ethdev.c',
+'cpfl_rxtx.c',
 )
\ No newline at end of file
-- 
2.25.1



[PATCH v2 03/21] net/cpfl: add Rx queue setup

2023-01-13 Thread Mingxia Liu
Add support for rx_queue_setup ops.

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c |  11 ++
 drivers/net/cpfl/cpfl_rxtx.c   | 232 +
 drivers/net/cpfl/cpfl_rxtx.h   |   6 +
 3 files changed, 249 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index f07e2f97a2..a113ed0de0 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -102,12 +102,22 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
.tx_rs_thresh = CPFL_DEFAULT_TX_RS_THRESH,
};
 
+   dev_info->default_rxconf = (struct rte_eth_rxconf) {
+   .rx_free_thresh = CPFL_DEFAULT_RX_FREE_THRESH,
+   };
+
dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
.nb_max = CPFL_MAX_RING_DESC,
.nb_min = CPFL_MIN_RING_DESC,
.nb_align = CPFL_ALIGN_RING_DESC,
};
 
+   dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
+   .nb_max = CPFL_MAX_RING_DESC,
+   .nb_min = CPFL_MIN_RING_DESC,
+   .nb_align = CPFL_ALIGN_RING_DESC,
+   };
+
return 0;
 }
 
@@ -526,6 +536,7 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, 
struct cpfl_adapter_ext *a
 static const struct eth_dev_ops cpfl_eth_dev_ops = {
.dev_configure  = cpfl_dev_configure,
.dev_close  = cpfl_dev_close,
+   .rx_queue_setup = cpfl_rx_queue_setup,
.tx_queue_setup = cpfl_tx_queue_setup,
.dev_infos_get  = cpfl_dev_info_get,
.link_update= cpfl_dev_link_update,
diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index ea4a2002bf..695c79e1db 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -9,6 +9,25 @@
 #include "cpfl_ethdev.h"
 #include "cpfl_rxtx.h"
 
+static uint64_t
+cpfl_rx_offload_convert(uint64_t offload)
+{
+   uint64_t ol = 0;
+
+   if ((offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0)
+   ol |= IDPF_RX_OFFLOAD_IPV4_CKSUM;
+   if ((offload & RTE_ETH_RX_OFFLOAD_UDP_CKSUM) != 0)
+   ol |= IDPF_RX_OFFLOAD_UDP_CKSUM;
+   if ((offload & RTE_ETH_RX_OFFLOAD_TCP_CKSUM) != 0)
+   ol |= IDPF_RX_OFFLOAD_TCP_CKSUM;
+   if ((offload & RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM) != 0)
+   ol |= IDPF_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+   if ((offload & RTE_ETH_RX_OFFLOAD_TIMESTAMP) != 0)
+   ol |= IDPF_RX_OFFLOAD_TIMESTAMP;
+
+   return ol;
+}
+
 static uint64_t
 cpfl_tx_offload_convert(uint64_t offload)
 {
@@ -94,6 +113,219 @@ cpfl_dma_zone_release(const struct rte_memzone *mz)
rte_memzone_free(mz);
 }
 
+static int
+cpfl_rx_split_bufq_setup(struct rte_eth_dev *dev, struct idpf_rx_queue *rxq,
+uint16_t queue_idx, uint16_t rx_free_thresh,
+uint16_t nb_desc, unsigned int socket_id,
+struct rte_mempool *mp, uint8_t bufq_id)
+{
+   struct idpf_vport *vport = dev->data->dev_private;
+   struct idpf_adapter *adapter = vport->adapter;
+   struct idpf_hw *hw = &adapter->hw;
+   const struct rte_memzone *mz;
+   struct idpf_rx_queue *bufq;
+   uint16_t len;
+   int ret;
+
+   bufq = rte_zmalloc_socket("cpfl bufq",
+  sizeof(struct idpf_rx_queue),
+  RTE_CACHE_LINE_SIZE,
+  socket_id);
+   if (bufq == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate memory for rx buffer 
queue.");
+   ret = -ENOMEM;
+   goto err_bufq1_alloc;
+   }
+
+   bufq->mp = mp;
+   bufq->nb_rx_desc = nb_desc;
+   bufq->rx_free_thresh = rx_free_thresh;
+   bufq->queue_id = vport->chunks_info.rx_buf_start_qid + queue_idx;
+   bufq->port_id = dev->data->port_id;
+   bufq->rx_hdr_len = 0;
+   bufq->adapter = adapter;
+
+   len = rte_pktmbuf_data_room_size(bufq->mp) - RTE_PKTMBUF_HEADROOM;
+   bufq->rx_buf_len = len;
+
+   /* Allocate a little more to support bulk allocate. */
+   len = nb_desc + IDPF_RX_MAX_BURST;
+
+   mz = cpfl_dma_zone_reserve(dev, queue_idx, len,
+  VIRTCHNL2_QUEUE_TYPE_RX_BUFFER,
+  socket_id, true);
+   if (mz == NULL) {
+   ret = -ENOMEM;
+   goto err_mz_reserve;
+   }
+
+   bufq->rx_ring_phys_addr = mz->iova;
+   bufq->rx_ring = mz->addr;
+   bufq->mz = mz;
+
+   bufq->sw_ring =
+   rte_zmalloc_socket("cpfl rx bufq sw ring",
+  sizeof(struct rte_mbuf *) * len,
+  RTE_CACHE_LINE_SIZE,
+  socket_id);
+   if (bufq->sw_ring == NULL) {
+   

[PATCH v2 04/21] net/cpfl: support device start and stop

2023-01-13 Thread Mingxia Liu
Add dev ops dev_start, dev_stop and link_update.

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c | 35 ++
 1 file changed, 35 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index a113ed0de0..05c3ad1a9c 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -185,12 +185,45 @@ cpfl_dev_configure(struct rte_eth_dev *dev)
return 0;
 }
 
+static int
+cpfl_dev_start(struct rte_eth_dev *dev)
+{
+   struct idpf_vport *vport = dev->data->dev_private;
+   int ret;
+
+   ret = idpf_vc_ena_dis_vport(vport, true);
+   if (ret != 0) {
+   PMD_DRV_LOG(ERR, "Failed to enable vport");
+   return ret;
+   }
+
+   vport->stopped = 0;
+
+   return 0;
+}
+
+static int
+cpfl_dev_stop(struct rte_eth_dev *dev)
+{
+   struct idpf_vport *vport = dev->data->dev_private;
+
+   if (vport->stopped == 1)
+   return 0;
+
+   idpf_vc_ena_dis_vport(vport, false);
+
+   vport->stopped = 1;
+
+   return 0;
+}
+
 static int
 cpfl_dev_close(struct rte_eth_dev *dev)
 {
struct idpf_vport *vport = dev->data->dev_private;
struct cpfl_adapter_ext *adapter = CPFL_ADAPTER_TO_EXT(vport->adapter);
 
+   cpfl_dev_stop(dev);
idpf_vport_deinit(vport);
 
adapter->cur_vports &= ~RTE_BIT32(vport->devarg_id);
@@ -539,6 +572,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = {
.rx_queue_setup = cpfl_rx_queue_setup,
.tx_queue_setup = cpfl_tx_queue_setup,
.dev_infos_get  = cpfl_dev_info_get,
+   .dev_start  = cpfl_dev_start,
+   .dev_stop   = cpfl_dev_stop,
.link_update= cpfl_dev_link_update,
.dev_supported_ptypes_get   = cpfl_dev_supported_ptypes_get,
 };
-- 
2.25.1



[PATCH v2 05/21] net/cpfl: support queue start

2023-01-13 Thread Mingxia Liu
Add support for these device ops:
 - rx_queue_start
 - tx_queue_start

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c |  41 ++
 drivers/net/cpfl/cpfl_rxtx.c   | 138 +
 drivers/net/cpfl/cpfl_rxtx.h   |   4 +
 3 files changed, 183 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 05c3ad1a9c..51d6243028 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -185,12 +185,51 @@ cpfl_dev_configure(struct rte_eth_dev *dev)
return 0;
 }
 
+static int
+cpfl_start_queues(struct rte_eth_dev *dev)
+{
+   struct idpf_rx_queue *rxq;
+   struct idpf_tx_queue *txq;
+   int err = 0;
+   int i;
+
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   if (txq == NULL || txq->tx_deferred_start)
+   continue;
+   err = cpfl_tx_queue_start(dev, i);
+   if (err != 0) {
+   PMD_DRV_LOG(ERR, "Fail to start Tx queue %u", i);
+   return err;
+   }
+   }
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   rxq = dev->data->rx_queues[i];
+   if (rxq == NULL || rxq->rx_deferred_start)
+   continue;
+   err = cpfl_rx_queue_start(dev, i);
+   if (err != 0) {
+   PMD_DRV_LOG(ERR, "Fail to start Rx queue %u", i);
+   return err;
+   }
+   }
+
+   return err;
+}
+
 static int
 cpfl_dev_start(struct rte_eth_dev *dev)
 {
struct idpf_vport *vport = dev->data->dev_private;
int ret;
 
+   ret = cpfl_start_queues(dev);
+   if (ret != 0) {
+   PMD_DRV_LOG(ERR, "Failed to start queues");
+   return ret;
+   }
+
ret = idpf_vc_ena_dis_vport(vport, true);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to enable vport");
@@ -575,6 +614,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = {
.dev_start  = cpfl_dev_start,
.dev_stop   = cpfl_dev_stop,
.link_update= cpfl_dev_link_update,
+   .rx_queue_start = cpfl_rx_queue_start,
+   .tx_queue_start = cpfl_tx_queue_start,
.dev_supported_ptypes_get   = cpfl_dev_supported_ptypes_get,
 };
 
diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index 695c79e1db..aa67db1e92 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -474,3 +474,141 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_idx,
 err_txq_alloc:
return ret;
 }
+
+int
+cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)
+{
+   struct idpf_rx_queue *rxq;
+   int err;
+
+   if (rx_queue_id >= dev->data->nb_rx_queues)
+   return -EINVAL;
+
+   rxq = dev->data->rx_queues[rx_queue_id];
+
+   if (rxq == NULL || !rxq->q_set) {
+   PMD_DRV_LOG(ERR, "RX queue %u not available or setup",
+   rx_queue_id);
+   return -EINVAL;
+   }
+
+   if (rxq->bufq1 == NULL) {
+   /* Single queue */
+   err = idpf_alloc_single_rxq_mbufs(rxq);
+   if (err != 0) {
+   PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
+   return err;
+   }
+
+   rte_wmb();
+
+   /* Init the RX tail register. */
+   IDPF_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
+   } else {
+   /* Split queue */
+   err = idpf_alloc_split_rxq_mbufs(rxq->bufq1);
+   if (err != 0) {
+   PMD_DRV_LOG(ERR, "Failed to allocate RX buffer queue 
mbuf");
+   return err;
+   }
+   err = idpf_alloc_split_rxq_mbufs(rxq->bufq2);
+   if (err != 0) {
+   PMD_DRV_LOG(ERR, "Failed to allocate RX buffer queue 
mbuf");
+   return err;
+   }
+
+   rte_wmb();
+
+   /* Init the RX tail register. */
+   IDPF_PCI_REG_WRITE(rxq->bufq1->qrx_tail, rxq->bufq1->rx_tail);
+   IDPF_PCI_REG_WRITE(rxq->bufq2->qrx_tail, rxq->bufq2->rx_tail);
+   }
+
+   return err;
+}
+
+int
+cpfl_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
+{
+   struct idpf_vport *vport = dev->data->dev_private;
+   struct idpf_rx_queue *rxq =
+   dev->data->rx_queues[rx_queue_id];
+   int err = 0;
+
+   err = idpf_vc_config_rxq(vport, rxq);
+   if (err != 0) {
+   PMD_DRV_LOG(ERR, "Fail to configure Rx queue %u", rx_queue_id);
+   return err;
+   }
+
+   err = cpfl_rx_queue_init(dev, rx_queue_id)

[PATCH v2 06/21] net/cpfl: support queue stop

2023-01-13 Thread Mingxia Liu
Add support for these device ops:
 - rx_queue_stop
 - tx_queue_stop

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c | 10 +++-
 drivers/net/cpfl/cpfl_rxtx.c   | 87 ++
 drivers/net/cpfl/cpfl_rxtx.h   |  3 ++
 3 files changed, 99 insertions(+), 1 deletion(-)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 51d6243028..a80e916ae4 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -233,12 +233,16 @@ cpfl_dev_start(struct rte_eth_dev *dev)
ret = idpf_vc_ena_dis_vport(vport, true);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to enable vport");
-   return ret;
+   goto err_vport;
}
 
vport->stopped = 0;
 
return 0;
+
+err_vport:
+   cpfl_stop_queues(dev);
+   return ret;
 }
 
 static int
@@ -251,6 +255,8 @@ cpfl_dev_stop(struct rte_eth_dev *dev)
 
idpf_vc_ena_dis_vport(vport, false);
 
+   cpfl_stop_queues(dev);
+
vport->stopped = 1;
 
return 0;
@@ -616,6 +622,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = {
.link_update= cpfl_dev_link_update,
.rx_queue_start = cpfl_rx_queue_start,
.tx_queue_start = cpfl_tx_queue_start,
+   .rx_queue_stop  = cpfl_rx_queue_stop,
+   .tx_queue_stop  = cpfl_tx_queue_stop,
.dev_supported_ptypes_get   = cpfl_dev_supported_ptypes_get,
 };
 
diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index aa67db1e92..b7d616de4f 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -612,3 +612,90 @@ cpfl_tx_queue_start(struct rte_eth_dev *dev, uint16_t 
tx_queue_id)
 
return err;
 }
+
+int
+cpfl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
+{
+   struct idpf_vport *vport = dev->data->dev_private;
+   struct idpf_rx_queue *rxq;
+   int err;
+
+   if (rx_queue_id >= dev->data->nb_rx_queues)
+   return -EINVAL;
+
+   err = idpf_switch_queue(vport, rx_queue_id, true, false);
+   if (err != 0) {
+   PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
+   rx_queue_id);
+   return err;
+   }
+
+   rxq = dev->data->rx_queues[rx_queue_id];
+   if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) {
+   rxq->ops->release_mbufs(rxq);
+   reset_single_rx_queue(rxq);
+   } else {
+   rxq->bufq1->ops->release_mbufs(rxq->bufq1);
+   rxq->bufq2->ops->release_mbufs(rxq->bufq2);
+   reset_split_rx_queue(rxq);
+   }
+   dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+
+   return 0;
+}
+
+int
+cpfl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
+{
+   struct idpf_vport *vport = dev->data->dev_private;
+   struct idpf_tx_queue *txq;
+   int err;
+
+   if (tx_queue_id >= dev->data->nb_tx_queues)
+   return -EINVAL;
+
+   err = idpf_switch_queue(vport, tx_queue_id, false, false);
+   if (err != 0) {
+   PMD_DRV_LOG(ERR, "Failed to switch TX queue %u off",
+   tx_queue_id);
+   return err;
+   }
+
+   txq = dev->data->tx_queues[tx_queue_id];
+   txq->ops->release_mbufs(txq);
+   if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SINGLE) {
+   reset_single_tx_queue(txq);
+   } else {
+   reset_split_tx_descq(txq);
+   reset_split_tx_complq(txq->complq);
+   }
+   dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+
+   return 0;
+}
+
+void
+cpfl_stop_queues(struct rte_eth_dev *dev)
+{
+   struct idpf_rx_queue *rxq;
+   struct idpf_tx_queue *txq;
+   int i;
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   rxq = dev->data->rx_queues[i];
+   if (rxq == NULL)
+   continue;
+
+   if (cpfl_rx_queue_stop(dev, i) != 0)
+   PMD_DRV_LOG(WARNING, "Fail to stop Rx queue %d", i);
+   }
+
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   if (txq == NULL)
+   continue;
+
+   if (cpfl_tx_queue_stop(dev, i) != 0)
+   PMD_DRV_LOG(WARNING, "Fail to stop Tx queue %d", i);
+   }
+}
diff --git a/drivers/net/cpfl/cpfl_rxtx.h b/drivers/net/cpfl/cpfl_rxtx.h
index 2fa7950775..6b63137d5c 100644
--- a/drivers/net/cpfl/cpfl_rxtx.h
+++ b/drivers/net/cpfl/cpfl_rxtx.h
@@ -32,4 +32,7 @@ int cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t 
rx_queue_id);
 int cpfl_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int cpfl_tx_queue_init(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 int cpfl_tx_queue_start(stru

[PATCH v2 07/21] net/cpfl: support queue release

2023-01-13 Thread Mingxia Liu
Add support for queue operations:
 - rx_queue_release
 - tx_queue_release

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c |  2 ++
 drivers/net/cpfl/cpfl_rxtx.c   | 35 ++
 drivers/net/cpfl/cpfl_rxtx.h   |  2 ++
 3 files changed, 39 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index a80e916ae4..922f1acc59 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -624,6 +624,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = {
.tx_queue_start = cpfl_tx_queue_start,
.rx_queue_stop  = cpfl_rx_queue_stop,
.tx_queue_stop  = cpfl_tx_queue_stop,
+   .rx_queue_release   = cpfl_dev_rx_queue_release,
+   .tx_queue_release   = cpfl_dev_tx_queue_release,
.dev_supported_ptypes_get   = cpfl_dev_supported_ptypes_get,
 };
 
diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index b7d616de4f..a10deb6c96 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -49,6 +49,14 @@ cpfl_tx_offload_convert(uint64_t offload)
return ol;
 }
 
+static const struct idpf_rxq_ops def_rxq_ops = {
+   .release_mbufs = release_rxq_mbufs,
+};
+
+static const struct idpf_txq_ops def_txq_ops = {
+   .release_mbufs = release_txq_mbufs,
+};
+
 static const struct rte_memzone *
 cpfl_dma_zone_reserve(struct rte_eth_dev *dev, uint16_t queue_idx,
  uint16_t len, uint16_t queue_type,
@@ -177,6 +185,7 @@ cpfl_rx_split_bufq_setup(struct rte_eth_dev *dev, struct 
idpf_rx_queue *rxq,
reset_split_rx_bufq(bufq);
bufq->qrx_tail = hw->hw_addr + (vport->chunks_info.rx_buf_qtail_start +
 queue_idx * vport->chunks_info.rx_buf_qtail_spacing);
+   bufq->ops = &def_rxq_ops;
bufq->q_set = true;
 
if (bufq_id == 1) {
@@ -235,6 +244,12 @@ cpfl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_idx,
if (check_rx_thresh(nb_desc, rx_free_thresh) != 0)
return -EINVAL;
 
+   /* Free memory if needed */
+   if (dev->data->rx_queues[queue_idx] != NULL) {
+   idpf_rx_queue_release(dev->data->rx_queues[queue_idx]);
+   dev->data->rx_queues[queue_idx] = NULL;
+   }
+
/* Setup Rx queue */
rxq = rte_zmalloc_socket("cpfl rxq",
 sizeof(struct idpf_rx_queue),
@@ -287,6 +302,7 @@ cpfl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_idx,
reset_single_rx_queue(rxq);
rxq->qrx_tail = hw->hw_addr + 
(vport->chunks_info.rx_qtail_start +
queue_idx * 
vport->chunks_info.rx_qtail_spacing);
+   rxq->ops = &def_rxq_ops;
} else {
reset_split_rx_descq(rxq);
 
@@ -399,6 +415,12 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_idx,
if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
return -EINVAL;
 
+   /* Free memory if needed. */
+   if (dev->data->tx_queues[queue_idx] != NULL) {
+   idpf_tx_queue_release(dev->data->tx_queues[queue_idx]);
+   dev->data->tx_queues[queue_idx] = NULL;
+   }
+
/* Allocate the TX queue data structure. */
txq = rte_zmalloc_socket("cpfl txq",
 sizeof(struct idpf_tx_queue),
@@ -461,6 +483,7 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_idx,
 
txq->qtx_tail = hw->hw_addr + (vport->chunks_info.tx_qtail_start +
queue_idx * vport->chunks_info.tx_qtail_spacing);
+   txq->ops = &def_txq_ops;
txq->q_set = true;
dev->data->tx_queues[queue_idx] = txq;
 
@@ -674,6 +697,18 @@ cpfl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t 
tx_queue_id)
return 0;
 }
 
+void
+cpfl_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
+{
+   idpf_rx_queue_release(dev->data->rx_queues[qid]);
+}
+
+void
+cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
+{
+   idpf_tx_queue_release(dev->data->tx_queues[qid]);
+}
+
 void
 cpfl_stop_queues(struct rte_eth_dev *dev)
 {
diff --git a/drivers/net/cpfl/cpfl_rxtx.h b/drivers/net/cpfl/cpfl_rxtx.h
index 6b63137d5c..037d479d56 100644
--- a/drivers/net/cpfl/cpfl_rxtx.h
+++ b/drivers/net/cpfl/cpfl_rxtx.h
@@ -35,4 +35,6 @@ int cpfl_tx_queue_start(struct rte_eth_dev *dev, uint16_t 
tx_queue_id);
 void cpfl_stop_queues(struct rte_eth_dev *dev);
 int cpfl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 int cpfl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+void cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
+void cpfl_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 #endif /* _CPFL_RXTX_H_ */
-- 
2.25.1



[PATCH v2 08/21] net/cpfl: support MTU configuration

2023-01-13 Thread Mingxia Liu
Add dev ops mtu_set.

Signed-off-by: Mingxia Liu 
---
 doc/guides/nics/features/cpfl.ini |  1 +
 drivers/net/cpfl/cpfl_ethdev.c| 26 ++
 2 files changed, 27 insertions(+)

diff --git a/doc/guides/nics/features/cpfl.ini 
b/doc/guides/nics/features/cpfl.ini
index a2d1ca9e15..470ba81579 100644
--- a/doc/guides/nics/features/cpfl.ini
+++ b/doc/guides/nics/features/cpfl.ini
@@ -7,6 +7,7 @@
 ; is selected.
 ;
 [Features]
+MTU update   = Y
 Linux= Y
 x86-32   = Y
 x86-64   = Y
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 922f1acc59..5ef9c902f7 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -121,6 +121,27 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
return 0;
 }
 
+static int
+cpfl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+   struct idpf_vport *vport = dev->data->dev_private;
+
+   /* mtu setting is forbidden if port is start */
+   if (dev->data->dev_started) {
+   PMD_DRV_LOG(ERR, "port must be stopped before configuration");
+   return -EBUSY;
+   }
+
+   if (mtu > vport->max_mtu) {
+   PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+   return -EINVAL;
+   }
+
+   vport->max_pkt_len = mtu + CPFL_ETH_OVERHEAD;
+
+   return 0;
+}
+
 static const uint32_t *
 cpfl_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
 {
@@ -182,6 +203,10 @@ cpfl_dev_configure(struct rte_eth_dev *dev)
return -ENOTSUP;
}
 
+   vport->max_pkt_len =
+   (dev->data->mtu == 0) ? CPFL_DEFAULT_MTU : dev->data->mtu +
+   CPFL_ETH_OVERHEAD;
+
return 0;
 }
 
@@ -626,6 +651,7 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = {
.tx_queue_stop  = cpfl_tx_queue_stop,
.rx_queue_release   = cpfl_dev_rx_queue_release,
.tx_queue_release   = cpfl_dev_tx_queue_release,
+   .mtu_set= cpfl_dev_mtu_set,
.dev_supported_ptypes_get   = cpfl_dev_supported_ptypes_get,
 };
 
-- 
2.25.1



[PATCH v2 09/21] net/cpfl: support basic Rx data path

2023-01-13 Thread Mingxia Liu
Add basic Rx support in split queue mode and single queue mode.

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c |  2 ++
 drivers/net/cpfl/cpfl_rxtx.c   | 11 +++
 drivers/net/cpfl/cpfl_rxtx.h   |  1 +
 3 files changed, 14 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 5ef9c902f7..716b9e3807 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -255,6 +255,8 @@ cpfl_dev_start(struct rte_eth_dev *dev)
return ret;
}
 
+   cpfl_set_rx_function(dev);
+
ret = idpf_vc_ena_dis_vport(vport, true);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to enable vport");
diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index a10deb6c96..30df129a19 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -734,3 +734,14 @@ cpfl_stop_queues(struct rte_eth_dev *dev)
PMD_DRV_LOG(WARNING, "Fail to stop Tx queue %d", i);
}
 }
+
+void
+cpfl_set_rx_function(struct rte_eth_dev *dev)
+{
+   struct idpf_vport *vport = dev->data->dev_private;
+
+   if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT)
+   dev->rx_pkt_burst = idpf_splitq_recv_pkts;
+   else
+   dev->rx_pkt_burst = idpf_singleq_recv_pkts;
+}
diff --git a/drivers/net/cpfl/cpfl_rxtx.h b/drivers/net/cpfl/cpfl_rxtx.h
index 037d479d56..c29c30c7a3 100644
--- a/drivers/net/cpfl/cpfl_rxtx.h
+++ b/drivers/net/cpfl/cpfl_rxtx.h
@@ -37,4 +37,5 @@ int cpfl_tx_queue_stop(struct rte_eth_dev *dev, uint16_t 
tx_queue_id);
 int cpfl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 void cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 void cpfl_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
+void cpfl_set_rx_function(struct rte_eth_dev *dev);
 #endif /* _CPFL_RXTX_H_ */
-- 
2.25.1



[PATCH v2 10/21] net/cpfl: support basic Tx data path

2023-01-13 Thread Mingxia Liu
Add basic Tx support in split queue mode and single queue mode.

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c |  3 +++
 drivers/net/cpfl/cpfl_rxtx.c   | 14 ++
 drivers/net/cpfl/cpfl_rxtx.h   |  1 +
 3 files changed, 18 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 716b9e3807..f94af81d95 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -97,6 +97,8 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
dev_info->max_mtu = vport->max_mtu;
dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 
+   dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+
dev_info->default_txconf = (struct rte_eth_txconf) {
.tx_free_thresh = CPFL_DEFAULT_TX_FREE_THRESH,
.tx_rs_thresh = CPFL_DEFAULT_TX_RS_THRESH,
@@ -256,6 +258,7 @@ cpfl_dev_start(struct rte_eth_dev *dev)
}
 
cpfl_set_rx_function(dev);
+   cpfl_set_tx_function(dev);
 
ret = idpf_vc_ena_dis_vport(vport, true);
if (ret != 0) {
diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index 30df129a19..0e053f4434 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -745,3 +745,17 @@ cpfl_set_rx_function(struct rte_eth_dev *dev)
else
dev->rx_pkt_burst = idpf_singleq_recv_pkts;
 }
+
+void
+cpfl_set_tx_function(struct rte_eth_dev *dev)
+{
+   struct idpf_vport *vport = dev->data->dev_private;
+
+   if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
+   dev->tx_pkt_burst = idpf_splitq_xmit_pkts;
+   dev->tx_pkt_prepare = idpf_prep_pkts;
+   } else {
+   dev->tx_pkt_burst = idpf_singleq_xmit_pkts;
+   dev->tx_pkt_prepare = idpf_prep_pkts;
+   }
+}
diff --git a/drivers/net/cpfl/cpfl_rxtx.h b/drivers/net/cpfl/cpfl_rxtx.h
index c29c30c7a3..021db5bf8a 100644
--- a/drivers/net/cpfl/cpfl_rxtx.h
+++ b/drivers/net/cpfl/cpfl_rxtx.h
@@ -38,4 +38,5 @@ int cpfl_rx_queue_stop(struct rte_eth_dev *dev, uint16_t 
rx_queue_id);
 void cpfl_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 void cpfl_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 void cpfl_set_rx_function(struct rte_eth_dev *dev);
+void cpfl_set_tx_function(struct rte_eth_dev *dev);
 #endif /* _CPFL_RXTX_H_ */
-- 
2.25.1



[PATCH v2 11/21] net/cpfl: support write back based on ITR expire

2023-01-13 Thread Mingxia Liu
Enable write back on ITR expire, then packets can be received one by

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c | 45 +-
 drivers/net/cpfl/cpfl_ethdev.h |  2 ++
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index f94af81d95..8c968a8eeb 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -212,6 +212,15 @@ cpfl_dev_configure(struct rte_eth_dev *dev)
return 0;
 }
 
+static int
+cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev)
+{
+   struct idpf_vport *vport = dev->data->dev_private;
+   uint16_t nb_rx_queues = dev->data->nb_rx_queues;
+
+   return idpf_config_irq_map(vport, nb_rx_queues);
+}
+
 static int
 cpfl_start_queues(struct rte_eth_dev *dev)
 {
@@ -249,12 +258,37 @@ static int
 cpfl_dev_start(struct rte_eth_dev *dev)
 {
struct idpf_vport *vport = dev->data->dev_private;
+   struct idpf_adapter *base = vport->adapter;
+   struct cpfl_adapter_ext *adapter = CPFL_ADAPTER_TO_EXT(base);
+   uint16_t num_allocated_vectors = base->caps.num_allocated_vectors;
+   uint16_t req_vecs_num;
int ret;
 
+   req_vecs_num = CPFL_DFLT_Q_VEC_NUM;
+   if (req_vecs_num + adapter->used_vecs_num > num_allocated_vectors) {
+   PMD_DRV_LOG(ERR, "The accumulated request vectors' number 
should be less than %d",
+   num_allocated_vectors);
+   ret = -EINVAL;
+   goto err_vec;
+   }
+
+   ret = idpf_vc_alloc_vectors(vport, req_vecs_num);
+   if (ret != 0) {
+   PMD_DRV_LOG(ERR, "Failed to allocate interrupt vectors");
+   goto err_vec;
+   }
+   adapter->used_vecs_num += req_vecs_num;
+
+   ret = cpfl_config_rx_queues_irqs(dev);
+   if (ret != 0) {
+   PMD_DRV_LOG(ERR, "Failed to configure irqs");
+   goto err_irq;
+   }
+
ret = cpfl_start_queues(dev);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to start queues");
-   return ret;
+   goto err_startq;
}
 
cpfl_set_rx_function(dev);
@@ -272,6 +306,11 @@ cpfl_dev_start(struct rte_eth_dev *dev)
 
 err_vport:
cpfl_stop_queues(dev);
+err_startq:
+   idpf_config_irq_unmap(vport, dev->data->nb_rx_queues);
+err_irq:
+   idpf_vc_dealloc_vectors(vport);
+err_vec:
return ret;
 }
 
@@ -287,6 +326,10 @@ cpfl_dev_stop(struct rte_eth_dev *dev)
 
cpfl_stop_queues(dev);
 
+   idpf_config_irq_unmap(vport, dev->data->nb_rx_queues);
+
+   idpf_vc_dealloc_vectors(vport);
+
vport->stopped = 1;
 
return 0;
diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
index 83459b9c91..9ae543c2ad 100644
--- a/drivers/net/cpfl/cpfl_ethdev.h
+++ b/drivers/net/cpfl/cpfl_ethdev.h
@@ -24,6 +24,8 @@
 
 #define CPFL_INVALID_VPORT_IDX 0x
 
+#define CPFL_DFLT_Q_VEC_NUM1
+
 #define CPFL_MIN_BUF_SIZE  1024
 #define CPFL_MAX_FRAME_SIZE9728
 #define CPFL_DEFAULT_MTU   RTE_ETHER_MTU
-- 
2.25.1



[PATCH v2 13/21] net/cpfl: support Rx offloading

2023-01-13 Thread Mingxia Liu
Add Rx offloading support:
 - support CHKSUM and RSS offload for split queue model
 - support CHKSUM offload for single queue model

Signed-off-by: Mingxia Liu 
---
 doc/guides/nics/features/cpfl.ini | 2 ++
 drivers/net/cpfl/cpfl_ethdev.c| 6 ++
 2 files changed, 8 insertions(+)

diff --git a/doc/guides/nics/features/cpfl.ini 
b/doc/guides/nics/features/cpfl.ini
index 470ba81579..ee5948f444 100644
--- a/doc/guides/nics/features/cpfl.ini
+++ b/doc/guides/nics/features/cpfl.ini
@@ -8,6 +8,8 @@
 ;
 [Features]
 MTU update   = Y
+L3 checksum offload  = P
+L4 checksum offload  = P
 Linux= Y
 x86-32   = Y
 x86-64   = Y
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 2be1f841e0..569f74197f 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -99,6 +99,12 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 
dev_info->flow_type_rss_offloads = CPFL_RSS_OFFLOAD_ALL;
 
+   dev_info->rx_offload_capa =
+   RTE_ETH_RX_OFFLOAD_IPV4_CKSUM   |
+   RTE_ETH_RX_OFFLOAD_UDP_CKSUM|
+   RTE_ETH_RX_OFFLOAD_TCP_CKSUM|
+   RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+
dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
dev_info->default_txconf = (struct rte_eth_txconf) {
-- 
2.25.1



[PATCH v2 12/21] net/cpfl: support RSS

2023-01-13 Thread Mingxia Liu
Add RSS support.

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c | 51 ++
 drivers/net/cpfl/cpfl_ethdev.h | 15 ++
 2 files changed, 66 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 8c968a8eeb..2be1f841e0 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -97,6 +97,8 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
dev_info->max_mtu = vport->max_mtu;
dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 
+   dev_info->flow_type_rss_offloads = CPFL_RSS_OFFLOAD_ALL;
+
dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
dev_info->default_txconf = (struct rte_eth_txconf) {
@@ -162,11 +164,49 @@ cpfl_dev_supported_ptypes_get(struct rte_eth_dev *dev 
__rte_unused)
return ptypes;
 }
 
+static int
+cpfl_init_rss(struct idpf_vport *vport)
+{
+   struct rte_eth_rss_conf *rss_conf;
+   struct rte_eth_dev_data *dev_data;
+   uint16_t i, nb_q;
+   int ret = 0;
+
+   dev_data = vport->dev_data;
+   rss_conf = &dev_data->dev_conf.rx_adv_conf.rss_conf;
+   nb_q = dev_data->nb_rx_queues;
+
+   if (rss_conf->rss_key == NULL) {
+   for (i = 0; i < vport->rss_key_size; i++)
+   vport->rss_key[i] = (uint8_t)rte_rand();
+   } else if (rss_conf->rss_key_len != vport->rss_key_size) {
+   PMD_INIT_LOG(ERR, "Invalid RSS key length in RSS configuration, 
should be %d",
+vport->rss_key_size);
+   return -EINVAL;
+   } else {
+   rte_memcpy(vport->rss_key, rss_conf->rss_key,
+  vport->rss_key_size);
+   }
+
+   for (i = 0; i < vport->rss_lut_size; i++)
+   vport->rss_lut[i] = i % nb_q;
+
+   vport->rss_hf = IDPF_DEFAULT_RSS_HASH_EXPANDED;
+
+   ret = idpf_config_rss(vport);
+   if (ret != 0)
+   PMD_INIT_LOG(ERR, "Failed to configure RSS");
+
+   return ret;
+}
+
 static int
 cpfl_dev_configure(struct rte_eth_dev *dev)
 {
struct idpf_vport *vport = dev->data->dev_private;
struct rte_eth_conf *conf = &dev->data->dev_conf;
+   struct idpf_adapter *adapter = vport->adapter;
+   int ret;
 
if (conf->link_speeds & RTE_ETH_LINK_SPEED_FIXED) {
PMD_INIT_LOG(ERR, "Setting link speed is not supported");
@@ -205,6 +245,17 @@ cpfl_dev_configure(struct rte_eth_dev *dev)
return -ENOTSUP;
}
 
+   if (adapter->caps.rss_caps != 0 && dev->data->nb_rx_queues != 0) {
+   ret = cpfl_init_rss(vport);
+   if (ret != 0) {
+   PMD_INIT_LOG(ERR, "Failed to init rss");
+   return ret;
+   }
+   } else {
+   PMD_INIT_LOG(ERR, "RSS is not supported.");
+   return -1;
+   }
+
vport->max_pkt_len =
(dev->data->mtu == 0) ? CPFL_DEFAULT_MTU : dev->data->mtu +
CPFL_ETH_OVERHEAD;
diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
index 9ae543c2ad..0d60ee3aed 100644
--- a/drivers/net/cpfl/cpfl_ethdev.h
+++ b/drivers/net/cpfl/cpfl_ethdev.h
@@ -36,6 +36,21 @@
 #define CPFL_ETH_OVERHEAD \
(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + CPFL_VLAN_TAG_SIZE * 2)
 
+#define CPFL_RSS_OFFLOAD_ALL ( \
+   RTE_ETH_RSS_IPV4|   \
+   RTE_ETH_RSS_FRAG_IPV4   |   \
+   RTE_ETH_RSS_NONFRAG_IPV4_TCP|   \
+   RTE_ETH_RSS_NONFRAG_IPV4_UDP|   \
+   RTE_ETH_RSS_NONFRAG_IPV4_SCTP   |   \
+   RTE_ETH_RSS_NONFRAG_IPV4_OTHER  |   \
+   RTE_ETH_RSS_IPV6|   \
+   RTE_ETH_RSS_FRAG_IPV6   |   \
+   RTE_ETH_RSS_NONFRAG_IPV6_TCP|   \
+   RTE_ETH_RSS_NONFRAG_IPV6_UDP|   \
+   RTE_ETH_RSS_NONFRAG_IPV6_SCTP   |   \
+   RTE_ETH_RSS_NONFRAG_IPV6_OTHER  |   \
+   RTE_ETH_RSS_L2_PAYLOAD)
+
 #define CPFL_ADAPTER_NAME_LEN  (PCI_PRI_STR_SIZE + 1)
 
 #define CPFL_ALARM_INTERVAL5 /* us */
-- 
2.25.1



[PATCH v2 14/21] net/cpfl: support Tx offloading

2023-01-13 Thread Mingxia Liu
Add Tx offloading support:
 - support TSO for single queue model and split queue model.

Signed-off-by: Mingxia Liu 
---
 doc/guides/nics/features/cpfl.ini | 1 +
 drivers/net/cpfl/cpfl_ethdev.c| 8 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/features/cpfl.ini 
b/doc/guides/nics/features/cpfl.ini
index ee5948f444..f4e45c7c68 100644
--- a/doc/guides/nics/features/cpfl.ini
+++ b/doc/guides/nics/features/cpfl.ini
@@ -8,6 +8,7 @@
 ;
 [Features]
 MTU update   = Y
+TSO  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
 Linux= Y
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 569f74197f..01a730716e 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -105,7 +105,13 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
RTE_ETH_RX_OFFLOAD_TCP_CKSUM|
RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 
-   dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+   dev_info->tx_offload_capa =
+   RTE_ETH_TX_OFFLOAD_IPV4_CKSUM   |
+   RTE_ETH_TX_OFFLOAD_UDP_CKSUM|
+   RTE_ETH_TX_OFFLOAD_TCP_CKSUM|
+   RTE_ETH_TX_OFFLOAD_SCTP_CKSUM   |
+   RTE_ETH_TX_OFFLOAD_TCP_TSO  |
+   RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
dev_info->default_txconf = (struct rte_eth_txconf) {
.tx_free_thresh = CPFL_DEFAULT_TX_FREE_THRESH,
-- 
2.25.1



[PATCH v2 16/21] net/cpfl: support timestamp offload

2023-01-13 Thread Mingxia Liu
Add support for timestamp offload.

Signed-off-by: Mingxia Liu 
---
 doc/guides/nics/features/cpfl.ini | 1 +
 drivers/net/cpfl/cpfl_ethdev.c| 3 ++-
 drivers/net/cpfl/cpfl_rxtx.c  | 7 +++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/features/cpfl.ini 
b/doc/guides/nics/features/cpfl.ini
index f4e45c7c68..c1209df3e5 100644
--- a/doc/guides/nics/features/cpfl.ini
+++ b/doc/guides/nics/features/cpfl.ini
@@ -11,6 +11,7 @@ MTU update   = Y
 TSO  = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Timestamp offload= P
 Linux= Y
 x86-32   = Y
 x86-64   = Y
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index a4ebbb9821..5fc40f8298 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -103,7 +103,8 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
RTE_ETH_RX_OFFLOAD_IPV4_CKSUM   |
RTE_ETH_RX_OFFLOAD_UDP_CKSUM|
RTE_ETH_RX_OFFLOAD_TCP_CKSUM|
-   RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+   RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
+   RTE_ETH_RX_OFFLOAD_TIMESTAMP;
 
dev_info->tx_offload_capa =
RTE_ETH_TX_OFFLOAD_IPV4_CKSUM   |
diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index a5bb3c728b..3101e59ee1 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -516,6 +516,13 @@ cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t 
rx_queue_id)
return -EINVAL;
}
 
+   err = idpf_register_ts_mbuf(rxq);
+   if (err != 0) {
+   PMD_DRV_LOG(ERR, "fail to register timestamp mbuf %u",
+   rx_queue_id);
+   return -EIO;
+   }
+
if (rxq->bufq1 == NULL) {
/* Single queue */
err = idpf_alloc_single_rxq_mbufs(rxq);
-- 
2.25.1



[PATCH v2 15/21] net/cpfl: add AVX512 data path for single queue model

2023-01-13 Thread Mingxia Liu
Add support of AVX512 vector data path for single queue model.

Signed-off-by: Wenjun Wu 
Signed-off-by: Mingxia Liu 
---
 doc/guides/nics/cpfl.rst|  24 +-
 drivers/net/cpfl/cpfl_ethdev.c  |   3 +-
 drivers/net/cpfl/cpfl_rxtx.c|  85 
 drivers/net/cpfl/cpfl_rxtx_vec_common.h | 100 
 drivers/net/cpfl/meson.build|  25 +-
 5 files changed, 234 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/cpfl/cpfl_rxtx_vec_common.h

diff --git a/doc/guides/nics/cpfl.rst b/doc/guides/nics/cpfl.rst
index 064c69ba7d..489a2d6153 100644
--- a/doc/guides/nics/cpfl.rst
+++ b/doc/guides/nics/cpfl.rst
@@ -63,4 +63,26 @@ Runtime Config Options
 Driver compilation and testing
 --
 
-Refer to the document :doc:`build_and_test` for details.
\ No newline at end of file
+Refer to the document :doc:`build_and_test` for details.
+
+Features
+
+
+Vector PMD
+~~
+
+Vector path for Rx and Tx path are selected automatically.
+The paths are chosen based on 2 conditions:
+
+- ``CPU``
+
+  On the x86 platform, the driver checks if the CPU supports AVX512.
+  If the CPU supports AVX512 and EAL argument ``--force-max-simd-bitwidth``
+  is set to 512, AVX512 paths will be chosen.
+
+- ``Offload features``
+
+  The supported HW offload features are described in the document cpfl.ini,
+  A value "P" means the offload feature is not supported by vector path.
+  If any not supported features are used, cpfl vector PMD is disabled
+  and the scalar paths are chosen.
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 01a730716e..a4ebbb9821 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -111,7 +111,8 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
RTE_ETH_TX_OFFLOAD_TCP_CKSUM|
RTE_ETH_TX_OFFLOAD_SCTP_CKSUM   |
RTE_ETH_TX_OFFLOAD_TCP_TSO  |
-   RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
+   RTE_ETH_TX_OFFLOAD_MULTI_SEGS   |
+   RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
dev_info->default_txconf = (struct rte_eth_txconf) {
.tx_free_thresh = CPFL_DEFAULT_TX_FREE_THRESH,
diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index 0e053f4434..a5bb3c728b 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -8,6 +8,7 @@
 
 #include "cpfl_ethdev.h"
 #include "cpfl_rxtx.h"
+#include "cpfl_rxtx_vec_common.h"
 
 static uint64_t
 cpfl_rx_offload_convert(uint64_t offload)
@@ -739,22 +740,106 @@ void
 cpfl_set_rx_function(struct rte_eth_dev *dev)
 {
struct idpf_vport *vport = dev->data->dev_private;
+#ifdef RTE_ARCH_X86
+   struct idpf_rx_queue *rxq;
+   int i;
+
+   if (cpfl_rx_vec_dev_check_default(dev) == CPFL_VECTOR_PATH &&
+   rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
+   vport->rx_vec_allowed = true;
+
+   if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)
+#ifdef CC_AVX512_SUPPORT
+   if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 
&&
+   rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1 
&&
+   rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512DQ))
+   vport->rx_use_avx512 = true;
+#else
+   PMD_DRV_LOG(NOTICE,
+   "AVX512 is not supported in build env");
+#endif /* CC_AVX512_SUPPORT */
+   } else {
+   vport->rx_vec_allowed = false;
+   }
+#endif /* RTE_ARCH_X86 */
+
+#ifdef RTE_ARCH_X86
+   if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
+   dev->rx_pkt_burst = idpf_splitq_recv_pkts;
+   } else {
+   if (vport->rx_vec_allowed) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   rxq = dev->data->rx_queues[i];
+   (void)idpf_singleq_rx_vec_setup(rxq);
+   }
+#ifdef CC_AVX512_SUPPORT
+   if (vport->rx_use_avx512) {
+   dev->rx_pkt_burst = 
idpf_singleq_recv_pkts_avx512;
+   return;
+   }
+#endif /* CC_AVX512_SUPPORT */
+   }
 
+   dev->rx_pkt_burst = idpf_singleq_recv_pkts;
+   }
+#else
if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT)
dev->rx_pkt_burst = idpf_splitq_recv_pkts;
else
dev->rx_pkt_burst = idpf_singleq_recv_pkts;
+#endif /* RTE_ARCH_X86 */
 }
 
 void
 cpfl_set_tx_function(struct rte_eth_dev *dev)
 {
struct idpf_vport *vport = dev->data->dev_private;
+#ifdef RTE_ARCH_X86
+#ifdef CC_AVX512_SUPPORT
+   struct idpf_tx_queue *txq;
+   int i;
+#endif /* CC_AVX512_SUPPORT */
+
+ 

[PATCH v2 17/21] net/cpfl: add AVX512 data path for split queue model

2023-01-13 Thread Mingxia Liu
Add support of AVX512 data path for split queue model.

Signed-off-by: Wenjun Wu 
Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_rxtx.c| 25 +
 drivers/net/cpfl/cpfl_rxtx_vec_common.h | 17 +++--
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index 3101e59ee1..c797e09b52 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -772,6 +772,20 @@ cpfl_set_rx_function(struct rte_eth_dev *dev)
 
 #ifdef RTE_ARCH_X86
if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
+#ifdef RTE_ARCH_X86
+   if (vport->rx_vec_allowed) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   rxq = dev->data->rx_queues[i];
+   (void)idpf_splitq_rx_vec_setup(rxq);
+   }
+#ifdef CC_AVX512_SUPPORT
+   if (vport->rx_use_avx512) {
+   dev->rx_pkt_burst = 
idpf_splitq_recv_pkts_avx512;
+   return;
+   }
+#endif
+   }
+#endif
dev->rx_pkt_burst = idpf_splitq_recv_pkts;
} else {
if (vport->rx_vec_allowed) {
@@ -833,6 +847,17 @@ cpfl_set_tx_function(struct rte_eth_dev *dev)
 #endif /* RTE_ARCH_X86 */
 
if (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
+#ifdef RTE_ARCH_X86
+   if (vport->tx_vec_allowed) {
+#ifdef CC_AVX512_SUPPORT
+   if (vport->tx_use_avx512) {
+   dev->tx_pkt_burst = 
idpf_splitq_xmit_pkts_avx512;
+   dev->tx_pkt_prepare = idpf_prep_pkts;
+   return;
+   }
+#endif
+   }
+#endif
dev->tx_pkt_burst = idpf_splitq_xmit_pkts;
dev->tx_pkt_prepare = idpf_prep_pkts;
} else {
diff --git a/drivers/net/cpfl/cpfl_rxtx_vec_common.h 
b/drivers/net/cpfl/cpfl_rxtx_vec_common.h
index 503bc87f21..63e52dd937 100644
--- a/drivers/net/cpfl/cpfl_rxtx_vec_common.h
+++ b/drivers/net/cpfl/cpfl_rxtx_vec_common.h
@@ -64,15 +64,28 @@ cpfl_tx_vec_queue_default(struct idpf_tx_queue *txq)
return CPFL_VECTOR_PATH;
 }
 
+static inline int
+cpfl_rx_splitq_vec_default(struct idpf_rx_queue *rxq)
+{
+   if (rxq->bufq2->rx_buf_len < rxq->max_pkt_len)
+   return CPFL_SCALAR_PATH;
+
+   return CPFL_VECTOR_PATH;
+}
+
 static inline int
 cpfl_rx_vec_dev_check_default(struct rte_eth_dev *dev)
 {
+   struct idpf_vport *vport = dev->data->dev_private;
struct idpf_rx_queue *rxq;
-   int i, ret = 0;
+   int i, default_ret, splitq_ret, ret = CPFL_SCALAR_PATH;
 
for (i = 0; i < dev->data->nb_rx_queues; i++) {
rxq = dev->data->rx_queues[i];
-   ret = (cpfl_rx_vec_queue_default(rxq));
+   splitq_ret = cpfl_rx_splitq_vec_default(rxq);
+   default_ret = cpfl_rx_vec_queue_default(rxq);
+   ret = (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) ?
+ splitq_ret && default_ret : default_ret;
if (ret == CPFL_SCALAR_PATH)
return CPFL_SCALAR_PATH;
}
-- 
2.25.1



[PATCH v2 18/21] net/cpfl: add hw statistics

2023-01-13 Thread Mingxia Liu
This patch add hardware packets/bytes statistics.

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c | 88 ++
 drivers/net/idpf/idpf_ethdev.c |  3 +-
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 5fc40f8298..9ae653b99a 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -178,6 +178,87 @@ cpfl_dev_supported_ptypes_get(struct rte_eth_dev *dev 
__rte_unused)
return ptypes;
 }
 
+static uint64_t
+cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)
+{
+   uint64_t mbuf_alloc_failed = 0;
+   struct idpf_rx_queue *rxq;
+   int i = 0;
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   rxq = dev->data->rx_queues[i];
+   mbuf_alloc_failed +=
+   rte_atomic64_read(&(rxq->rx_stats.mbuf_alloc_failed));
+   }
+
+   return mbuf_alloc_failed;
+}
+
+static int
+cpfl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+   struct idpf_vport *vport =
+   (struct idpf_vport *)dev->data->dev_private;
+   struct virtchnl2_vport_stats *pstats = NULL;
+   int ret;
+
+   ret = idpf_query_stats(vport, &pstats);
+   if (ret == 0) {
+   uint8_t crc_stats_len = (dev->data->dev_conf.rxmode.offloads &
+RTE_ETH_RX_OFFLOAD_KEEP_CRC) ? 0 :
+RTE_ETHER_CRC_LEN;
+
+   idpf_update_stats(&vport->eth_stats_offset, pstats);
+   stats->ipackets = pstats->rx_unicast + pstats->rx_multicast +
+   pstats->rx_broadcast - pstats->rx_discards;
+   stats->opackets = pstats->tx_broadcast + pstats->tx_multicast +
+   pstats->tx_unicast;
+   stats->imissed = pstats->rx_discards;
+   stats->oerrors = pstats->tx_errors + pstats->tx_discards;
+   stats->ibytes = pstats->rx_bytes;
+   stats->ibytes -= stats->ipackets * crc_stats_len;
+   stats->obytes = pstats->tx_bytes;
+
+   dev->data->rx_mbuf_alloc_failed = 
cpfl_get_mbuf_alloc_failed_stats(dev);
+   stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
+   } else {
+   PMD_DRV_LOG(ERR, "Get statistics failed");
+   }
+   return ret;
+}
+
+static void
+cpfl_reset_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)
+{
+   struct idpf_rx_queue *rxq;
+   int i;
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   rxq = dev->data->rx_queues[i];
+   rte_atomic64_set(&(rxq->rx_stats.mbuf_alloc_failed), 0);
+   }
+}
+
+static int
+cpfl_dev_stats_reset(struct rte_eth_dev *dev)
+{
+   struct idpf_vport *vport =
+   (struct idpf_vport *)dev->data->dev_private;
+   struct virtchnl2_vport_stats *pstats = NULL;
+   int ret;
+
+   ret = idpf_query_stats(vport, &pstats);
+   if (ret != 0)
+   return ret;
+
+   /* set stats offset base on current values */
+   vport->eth_stats_offset = *pstats;
+
+   cpfl_reset_mbuf_alloc_failed_stats(dev);
+
+   return 0;
+}
+
 static int
 cpfl_init_rss(struct idpf_vport *vport)
 {
@@ -365,6 +446,11 @@ cpfl_dev_start(struct rte_eth_dev *dev)
goto err_vport;
}
 
+   if (cpfl_dev_stats_reset(dev)) {
+   PMD_DRV_LOG(ERR, "Failed to reset stats");
+   goto err_vport;
+   }
+
vport->stopped = 0;
 
return 0;
@@ -766,6 +852,8 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = {
.tx_queue_release   = cpfl_dev_tx_queue_release,
.mtu_set= cpfl_dev_mtu_set,
.dev_supported_ptypes_get   = cpfl_dev_supported_ptypes_get,
+   .stats_get  = cpfl_dev_stats_get,
+   .stats_reset= cpfl_dev_stats_reset,
 };
 
 static uint16_t
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index bcd15db3c5..b2cf959ee7 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -824,13 +824,14 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
if (idpf_dev_stats_reset(dev)) {
PMD_DRV_LOG(ERR, "Failed to reset stats");
-   goto err_vport;
+   goto err_stats_reset;
}
 
vport->stopped = 0;
 
return 0;
 
+err_stats_reset:
 err_vport:
idpf_stop_queues(dev);
 err_startq:
-- 
2.25.1



[PATCH v2 19/21] net/cpfl: add RSS set/get ops

2023-01-13 Thread Mingxia Liu
Add support for these device ops:
- rss_reta_update
- rss_reta_query
- rss_hash_update
- rss_hash_conf_get

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c | 303 +
 1 file changed, 303 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index 9ae653b99a..b35224e1ec 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -30,6 +30,56 @@ static const char * const cpfl_valid_args[] = {
NULL
 };
 
+static const uint64_t cpfl_map_hena_rss[] = {
+   [IDPF_HASH_NONF_UNICAST_IPV4_UDP] =
+   RTE_ETH_RSS_NONFRAG_IPV4_UDP,
+   [IDPF_HASH_NONF_MULTICAST_IPV4_UDP] =
+   RTE_ETH_RSS_NONFRAG_IPV4_UDP,
+   [IDPF_HASH_NONF_IPV4_UDP] =
+   RTE_ETH_RSS_NONFRAG_IPV4_UDP,
+   [IDPF_HASH_NONF_IPV4_TCP_SYN_NO_ACK] =
+   RTE_ETH_RSS_NONFRAG_IPV4_TCP,
+   [IDPF_HASH_NONF_IPV4_TCP] =
+   RTE_ETH_RSS_NONFRAG_IPV4_TCP,
+   [IDPF_HASH_NONF_IPV4_SCTP] =
+   RTE_ETH_RSS_NONFRAG_IPV4_SCTP,
+   [IDPF_HASH_NONF_IPV4_OTHER] =
+   RTE_ETH_RSS_NONFRAG_IPV4_OTHER,
+   [IDPF_HASH_FRAG_IPV4] = RTE_ETH_RSS_FRAG_IPV4,
+
+   /* IPv6 */
+   [IDPF_HASH_NONF_UNICAST_IPV6_UDP] =
+   RTE_ETH_RSS_NONFRAG_IPV6_UDP,
+   [IDPF_HASH_NONF_MULTICAST_IPV6_UDP] =
+   RTE_ETH_RSS_NONFRAG_IPV6_UDP,
+   [IDPF_HASH_NONF_IPV6_UDP] =
+   RTE_ETH_RSS_NONFRAG_IPV6_UDP,
+   [IDPF_HASH_NONF_IPV6_TCP_SYN_NO_ACK] =
+   RTE_ETH_RSS_NONFRAG_IPV6_TCP,
+   [IDPF_HASH_NONF_IPV6_TCP] =
+   RTE_ETH_RSS_NONFRAG_IPV6_TCP,
+   [IDPF_HASH_NONF_IPV6_SCTP] =
+   RTE_ETH_RSS_NONFRAG_IPV6_SCTP,
+   [IDPF_HASH_NONF_IPV6_OTHER] =
+   RTE_ETH_RSS_NONFRAG_IPV6_OTHER,
+   [IDPF_HASH_FRAG_IPV6] = RTE_ETH_RSS_FRAG_IPV6,
+
+   /* L2 Payload */
+   [IDPF_HASH_L2_PAYLOAD] = RTE_ETH_RSS_L2_PAYLOAD
+};
+
+static const uint64_t cpfl_ipv4_rss = RTE_ETH_RSS_NONFRAG_IPV4_UDP |
+ RTE_ETH_RSS_NONFRAG_IPV4_TCP |
+ RTE_ETH_RSS_NONFRAG_IPV4_SCTP |
+ RTE_ETH_RSS_NONFRAG_IPV4_OTHER |
+ RTE_ETH_RSS_FRAG_IPV4;
+
+static const uint64_t cpfl_ipv6_rss = RTE_ETH_RSS_NONFRAG_IPV6_UDP |
+ RTE_ETH_RSS_NONFRAG_IPV6_TCP |
+ RTE_ETH_RSS_NONFRAG_IPV6_SCTP |
+ RTE_ETH_RSS_NONFRAG_IPV6_OTHER |
+ RTE_ETH_RSS_FRAG_IPV6;
+
 static int
 cpfl_dev_link_update(struct rte_eth_dev *dev,
 __rte_unused int wait_to_complete)
@@ -97,6 +147,9 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
dev_info->max_mtu = vport->max_mtu;
dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 
+   dev_info->hash_key_size = vport->rss_key_size;
+   dev_info->reta_size = vport->rss_lut_size;
+
dev_info->flow_type_rss_offloads = CPFL_RSS_OFFLOAD_ALL;
 
dev_info->rx_offload_capa =
@@ -259,6 +312,54 @@ cpfl_dev_stats_reset(struct rte_eth_dev *dev)
return 0;
 }
 
+static int cpfl_config_rss_hf(struct idpf_vport *vport, uint64_t rss_hf)
+{
+   uint64_t hena = 0, valid_rss_hf = 0;
+   int ret = 0;
+   uint16_t i;
+
+   /**
+* RTE_ETH_RSS_IPV4 and RTE_ETH_RSS_IPV6 can be considered as 2
+* generalizations of all other IPv4 and IPv6 RSS types.
+*/
+   if (rss_hf & RTE_ETH_RSS_IPV4)
+   rss_hf |= cpfl_ipv4_rss;
+
+   if (rss_hf & RTE_ETH_RSS_IPV6)
+   rss_hf |= cpfl_ipv6_rss;
+
+   for (i = 0; i < RTE_DIM(cpfl_map_hena_rss); i++) {
+   uint64_t bit = BIT_ULL(i);
+
+   if (cpfl_map_hena_rss[i] & rss_hf) {
+   valid_rss_hf |= cpfl_map_hena_rss[i];
+   hena |= bit;
+   }
+   }
+
+   vport->rss_hf = hena;
+
+   ret = idpf_vc_set_rss_hash(vport);
+   if (ret != 0) {
+   PMD_DRV_LOG(WARNING,
+   "fail to set RSS offload types, ret: %d", ret);
+   return ret;
+   }
+
+   if (valid_rss_hf & cpfl_ipv4_rss)
+   valid_rss_hf |= rss_hf & RTE_ETH_RSS_IPV4;
+
+   if (valid_rss_hf & cpfl_ipv6_rss)
+   valid_rss_hf |= rss_hf & RTE_ETH_RSS_IPV6;
+
+   if (rss_hf & ~valid_rss_hf)
+   PMD_DRV_LOG(WARNING, "Unsupported rss_hf 0x%" PRIx64,
+   rss_hf & ~valid_rss_hf);
+   vport->last_general_rss_hf = valid_rss_hf;
+
+   return ret;
+}
+
 static int
 cpfl_init_rss(struct idpf_vport *vport)
 {
@@ -295,6 +396,204 @@ cpfl_init_rss(struct idpf_vport *vport)
return ret;
 }
 
+static int
+cpfl_rss_reta_update(struct rte_eth_dev *dev,
+  

[PATCH v2 20/21] net/cpfl: support single q scatter RX datapath

2023-01-13 Thread Mingxia Liu
This patch add single q recv scatter rx function.

Signed-off-by: Wenjun Wu 
Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c |  3 ++-
 drivers/net/cpfl/cpfl_rxtx.c   | 26 --
 drivers/net/cpfl/cpfl_rxtx.h   |  2 ++
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index b35224e1ec..e7034c4e22 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -157,7 +157,8 @@ cpfl_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
RTE_ETH_RX_OFFLOAD_UDP_CKSUM|
RTE_ETH_RX_OFFLOAD_TCP_CKSUM|
RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
-   RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+   RTE_ETH_RX_OFFLOAD_TIMESTAMP|
+   RTE_ETH_RX_OFFLOAD_SCATTER;
 
dev_info->tx_offload_capa =
RTE_ETH_TX_OFFLOAD_IPV4_CKSUM   |
diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index c797e09b52..bedbaa9de0 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -503,6 +503,8 @@ int
 cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 {
struct idpf_rx_queue *rxq;
+   uint16_t max_pkt_len;
+   uint32_t frame_size;
int err;
 
if (rx_queue_id >= dev->data->nb_rx_queues)
@@ -516,6 +518,17 @@ cpfl_rx_queue_init(struct rte_eth_dev *dev, uint16_t 
rx_queue_id)
return -EINVAL;
}
 
+   frame_size = dev->data->mtu + CPFL_ETH_OVERHEAD;
+
+   max_pkt_len =
+   RTE_MIN((uint32_t)CPFL_SUPPORT_CHAIN_NUM * rxq->rx_buf_len,
+   frame_size);
+
+   rxq->max_pkt_len = max_pkt_len;
+   if ((dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_SCATTER) 
||
+   frame_size > rxq->rx_buf_len)
+   dev->data->scattered_rx = 1;
+
err = idpf_register_ts_mbuf(rxq);
if (err != 0) {
PMD_DRV_LOG(ERR, "fail to register timestamp mbuf %u",
@@ -801,13 +814,22 @@ cpfl_set_rx_function(struct rte_eth_dev *dev)
 #endif /* CC_AVX512_SUPPORT */
}
 
+   if (dev->data->scattered_rx) {
+   dev->rx_pkt_burst = idpf_singleq_recv_scatter_pkts;
+   return;
+   }
dev->rx_pkt_burst = idpf_singleq_recv_pkts;
}
 #else
-   if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT)
+   if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {
dev->rx_pkt_burst = idpf_splitq_recv_pkts;
-   else
+   } else {
+   if (dev->data->scattered_rx) {
+   dev->rx_pkt_burst = idpf_singleq_recv_scatter_pkts;
+   return;
+   }
dev->rx_pkt_burst = idpf_singleq_recv_pkts;
+   }
 #endif /* RTE_ARCH_X86 */
 }
 
diff --git a/drivers/net/cpfl/cpfl_rxtx.h b/drivers/net/cpfl/cpfl_rxtx.h
index 021db5bf8a..2d55f58455 100644
--- a/drivers/net/cpfl/cpfl_rxtx.h
+++ b/drivers/net/cpfl/cpfl_rxtx.h
@@ -21,6 +21,8 @@
 #define CPFL_DEFAULT_TX_RS_THRESH  32
 #define CPFL_DEFAULT_TX_FREE_THRESH32
 
+#define CPFL_SUPPORT_CHAIN_NUM 5
+
 int cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
uint16_t nb_desc, unsigned int socket_id,
const struct rte_eth_txconf *tx_conf);
-- 
2.25.1



[PATCH v2 21/21] net/cpfl: add xstats ops

2023-01-13 Thread Mingxia Liu
Add support for these device ops:
- dev_xstats_get
- dev_xstats_get_names
- dev_xstats_reset

Signed-off-by: Mingxia Liu 
---
 drivers/net/cpfl/cpfl_ethdev.c | 80 ++
 1 file changed, 80 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index e7034c4e22..7b0ca81cd9 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -80,6 +80,30 @@ static const uint64_t cpfl_ipv6_rss = 
RTE_ETH_RSS_NONFRAG_IPV6_UDP |
  RTE_ETH_RSS_NONFRAG_IPV6_OTHER |
  RTE_ETH_RSS_FRAG_IPV6;
 
+struct rte_cpfl_xstats_name_off {
+   char name[RTE_ETH_XSTATS_NAME_SIZE];
+   unsigned int offset;
+};
+
+static const struct rte_cpfl_xstats_name_off rte_cpfl_stats_strings[] = {
+   {"rx_bytes", offsetof(struct virtchnl2_vport_stats, rx_bytes)},
+   {"rx_unicast_packets", offsetof(struct virtchnl2_vport_stats, 
rx_unicast)},
+   {"rx_multicast_packets", offsetof(struct virtchnl2_vport_stats, 
rx_multicast)},
+   {"rx_broadcast_packets", offsetof(struct virtchnl2_vport_stats, 
rx_broadcast)},
+   {"rx_dropped_packets", offsetof(struct virtchnl2_vport_stats, 
rx_discards)},
+   {"rx_errors", offsetof(struct virtchnl2_vport_stats, rx_errors)},
+   {"rx_unknown_protocol_packets", offsetof(struct virtchnl2_vport_stats,
+rx_unknown_protocol)},
+   {"tx_bytes", offsetof(struct virtchnl2_vport_stats, tx_bytes)},
+   {"tx_unicast_packets", offsetof(struct virtchnl2_vport_stats, 
tx_unicast)},
+   {"tx_multicast_packets", offsetof(struct virtchnl2_vport_stats, 
tx_multicast)},
+   {"tx_broadcast_packets", offsetof(struct virtchnl2_vport_stats, 
tx_broadcast)},
+   {"tx_dropped_packets", offsetof(struct virtchnl2_vport_stats, 
tx_discards)},
+   {"tx_error_packets", offsetof(struct virtchnl2_vport_stats, 
tx_errors)}};
+
+#define CPFL_NB_XSTATS (sizeof(rte_cpfl_stats_strings) / \
+   sizeof(rte_cpfl_stats_strings[0]))
+
 static int
 cpfl_dev_link_update(struct rte_eth_dev *dev,
 __rte_unused int wait_to_complete)
@@ -313,6 +337,59 @@ cpfl_dev_stats_reset(struct rte_eth_dev *dev)
return 0;
 }
 
+static int cpfl_dev_xstats_reset(struct rte_eth_dev *dev)
+{
+   cpfl_dev_stats_reset(dev);
+   return 0;
+}
+
+static int cpfl_dev_xstats_get(struct rte_eth_dev *dev,
+  struct rte_eth_xstat *xstats, unsigned int n)
+{
+   struct idpf_vport *vport =
+   (struct idpf_vport *)dev->data->dev_private;
+   struct virtchnl2_vport_stats *pstats = NULL;
+   unsigned int i;
+   int ret;
+
+   if (n < CPFL_NB_XSTATS)
+   return CPFL_NB_XSTATS;
+
+   if (!xstats)
+   return 0;
+
+   ret = idpf_query_stats(vport, &pstats);
+   if (ret) {
+   PMD_DRV_LOG(ERR, "Get statistics failed");
+   return 0;
+   }
+
+   idpf_update_stats(&vport->eth_stats_offset, pstats);
+
+   /* loop over xstats array and values from pstats */
+   for (i = 0; i < CPFL_NB_XSTATS; i++) {
+   xstats[i].id = i;
+   xstats[i].value = *(uint64_t *)(((char *)pstats) +
+   rte_cpfl_stats_strings[i].offset);
+   }
+   return CPFL_NB_XSTATS;
+}
+
+static int cpfl_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+__rte_unused unsigned int limit)
+{
+   unsigned int i;
+
+   if (xstats_names)
+   for (i = 0; i < CPFL_NB_XSTATS; i++) {
+   snprintf(xstats_names[i].name,
+sizeof(xstats_names[i].name),
+"%s", rte_cpfl_stats_strings[i].name);
+   }
+   return CPFL_NB_XSTATS;
+}
+
 static int cpfl_config_rss_hf(struct idpf_vport *vport, uint64_t rss_hf)
 {
uint64_t hena = 0, valid_rss_hf = 0;
@@ -1158,6 +1235,9 @@ static const struct eth_dev_ops cpfl_eth_dev_ops = {
.reta_query = cpfl_rss_reta_query,
.rss_hash_update= cpfl_rss_hash_update,
.rss_hash_conf_get  = cpfl_rss_hash_conf_get,
+   .xstats_get = cpfl_dev_xstats_get,
+   .xstats_get_names   = cpfl_dev_xstats_get_names,
+   .xstats_reset   = cpfl_dev_xstats_reset,
 };
 
 static uint16_t
-- 
2.25.1



Request for src .p4

2023-01-13 Thread Guy Davidi
Hi Cristian I got your email via GitHub.

I wonder if I can view the l2fwd.p4 that you guys compiled in order to get
the l2fwd .spec in this commit:
https://github.com/DPDK/dpdk/commit/43821022a4c1a35010e9f70a82e1fe0e12f6949f



Thanks a lot for your time,

Guy


Re: [PATCH] net/hns3: fix inaccurate RTC time to read

2023-01-13 Thread Ferruh Yigit
On 1/13/2023 6:49 AM, Dongdong Liu wrote:
> Hi Huisong
> 
> On 2023/1/9 16:23, Huisong Li wrote:
>> The sequence of reading current RTC time register doesn't meet
>> the hardware requirements, which causes this time obtained is
>> the one before modifying RTC time.
>>
>> Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP")
>> Cc: sta...@dpdk.org
>>
>> Signed-off-by: Huisong Li 
> 
> Acked-by: Dongdong Liu 
> 

Applied to dpdk-next-net/main, thanks.



Re: trace point symbols

2023-01-13 Thread Jerin Jacob
On Thu, Jan 12, 2023 at 3:13 PM Morten Brørup  
wrote:
>
> > From: Thomas Monjalon [mailto:tho...@monjalon.net]
> > Sent: Thursday, 12 January 2023 10.11
> >

> >
> > I would like to see a policy regarding trace symbols.
> > If we decide option 1 is not so useful,
> > then we should not export trace symbols at all and document this
> > policy.
> > Also there are some trace symbols which could be cleaned up.

I can send a patch to remove existing exposed symbols for option 1 in
DPDK repo. But, Is n't  an ABI break? The only downside, I can think
of, is that a few more entries in version.map file.
I don't have a strong option one way, either. Let me know what you think?

If we decided to remove then, In
https://doc.dpdk.org/guides/prog_guide/trace_lib.html, There is NOTE
section as following, I can remove that as well.

--
The RTE_TRACE_POINT_REGISTER defines the placeholder for the
rte_trace_point_t tracepoint object. The user must export a
__ symbol in the library .map file for this
tracepoint to be used out of the library, in shared builds. For
example, __app_trace_string will be the exported symbol in the above
example.
---

>
> +1 for not exposing trace point symbols at all.
>
> The trace point symbols are only used internally by DPDK, so they should not 
> be part of DPDK's public API.
>
> It might also make it easier for Bruce to move the trace library out of EAL.
>
> I'm not familiar with the CTF format, but I assume that if we don't expose 
> the trace point symbols, the trace points can still be identified when 
> parsing the trace file.

Yes. It won't impact. The only use case for option 1 is to avoid named lookup.

>


RE: [RFC] net/i40e: replace get and put functions

2023-01-13 Thread Morten Brørup
+CC: i40e maintainers

> From: Kamalakshitha Aligeri [mailto:kamalakshitha.alig...@arm.com]
> Sent: Monday, 9 January 2023 15.58
> 
> Integrated zero-copy get and put API's in mempool cache in i40e PMD
> 
> Signed-off-by: Kamalakshitha Aligeri 
> ---
> 1. I have replaced the rte_mempool_get_bulk and rte_mempool_put_bulk in
> net/i40e with the zero-copy get and put API's
> 
>  drivers/net/i40e/i40e_rxtx_vec_avx512.c | 10 +-
>  drivers/net/i40e/i40e_rxtx_vec_common.h | 21 +
>  drivers/net/i40e/i40e_rxtx_vec_neon.c   | 16 
>  3 files changed, 26 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_rxtx_vec_avx512.c
> b/drivers/net/i40e/i40e_rxtx_vec_avx512.c
> index 60c97d5331..736bd4650f 100644
> --- a/drivers/net/i40e/i40e_rxtx_vec_avx512.c
> +++ b/drivers/net/i40e/i40e_rxtx_vec_avx512.c

i40e_rxq_rearm() also accesses the cache directly, and thus needs rewriting to 
the new mempool cache API.

> @@ -909,7 +909,7 @@ i40e_tx_free_bufs_avx512(struct i40e_tx_queue *txq)
>   if (!cache || cache->len == 0)

This is not your doing, but I don't understand the reason for the cache->len == 
0 comparison here. Why not store objects in the cache if it is empty? Maybe an 
old copy-paste bug?

>   goto normal;
> 
> - cache_objs = &cache->objs[cache->len];
> + cache_objs = rte_mempool_cache_zc_put_bulk(cache, mp, n);
> 
>   if (n > RTE_MEMPOOL_CACHE_MAX_SIZE) {

This comparison should be (cache_objs == NULL) instead.

>   rte_mempool_ops_enqueue_bulk(mp, (void *)txep, n);

The comment block on lines 919-923 must be deleted too.

> @@ -936,14 +936,6 @@ i40e_tx_free_bufs_avx512(struct i40e_tx_queue
> *txq)
>   _mm512_storeu_si512(&cache_objs[copied + 24], d);
>   copied += 32;
>   }
> - cache->len += n;
> -
> - if (cache->len >= cache->flushthresh) {
> - rte_mempool_ops_enqueue_bulk
> - (mp, &cache->objs[cache->size],
> - cache->len - cache->size);
> - cache->len = cache->size;
> - }
>   goto done;
>   }
> 
> diff --git a/drivers/net/i40e/i40e_rxtx_vec_common.h
> b/drivers/net/i40e/i40e_rxtx_vec_common.h
> index fe1a6ec75e..4fc4aa0aec 100644
> --- a/drivers/net/i40e/i40e_rxtx_vec_common.h
> +++ b/drivers/net/i40e/i40e_rxtx_vec_common.h
> @@ -89,23 +89,28 @@ i40e_tx_free_bufs(struct i40e_tx_queue *txq)
> 
>   /* check DD bits on threshold descriptor */
>   if ((txq->tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
> - rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) !=
> + rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) !=
>   rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE))
>   return 0;
> 
>   n = txq->tx_rs_thresh;
> 
> -  /* first buffer to free from S/W ring is at index
> -   * tx_next_dd - (tx_rs_thresh-1)
> -   */
> + /* first buffer to free from S/W ring is at index
> +  * tx_next_dd - (tx_rs_thresh-1)
> +  */
>   txep = &txq->sw_ring[txq->tx_next_dd - (n - 1)];
> + struct rte_mempool *mp = txep[0].mbuf->pool;
> + struct rte_mempool_cache *cache = rte_mempool_default_cache(mp,
> rte_lcore_id());
> + void **cache_objs;
> +
> + cache_objs = rte_mempool_cache_zc_put_bulk(cache, mp, n);

These belong inside the "if (txq->offloads & 
RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)" block.

> 
>   if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) {
>   for (i = 0; i < n; i++) {
> - free[i] = txep[i].mbuf;
> + rte_memcpy(&cache_objs[i], &txep->mbuf, sizeof(struct
> rte_mbuf));

You must copy pointers to mbufs, not mbuf structures. I.e. instead of 
rte_memcpy(...) do this:

+   cache_objs[i] = txep->mbuf;


>   /* no need to reset txep[i].mbuf in vector path */
> + txep++;
>   }
> - rte_mempool_put_bulk(free[0]->pool, (void **)free, n);
>   goto done;
>   }
> 
> @@ -120,8 +125,8 @@ i40e_tx_free_bufs(struct i40e_tx_queue *txq)
>   free[nb_free++] = m;
>   } else {
>   rte_mempool_put_bulk(free[0]->pool,
> -  (void *)free,
> -  nb_free);
> + (void *)free,
> + nb_free);
>   free[0] = m;
>   nb_free = 1;
>   }
> diff --git a/drivers/net/i40e/i40e_rxtx_vec_neon.c
> b/drivers/net/i40e/i40e_rxtx_vec_neon.c
> index 

RE: [PATCH v2 1/4] crypto/ccp: remove some printf

2023-01-13 Thread Uttarwar, Sunil Prakashrao
[Public]

Acked-by: Sunil Uttarwar 

-Original Message-
From: David Marchand  
Sent: Tuesday, October 4, 2022 3:21 PM
To: dev@dpdk.org
Cc: gak...@marvell.com; Uttarwar, Sunil Prakashrao 
; sta...@dpdk.org; Kumar, Ravi1 

Subject: [PATCH v2 1/4] crypto/ccp: remove some printf

Caution: This message originated from an External Source. Use proper caution 
when opening attachments, clicking links, or responding.


A DPDK application must _not_ use printf.
Use log framework.

Fixes: ef4b04f87fa6 ("crypto/ccp: support device init")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand 
---
 drivers/crypto/ccp/ccp_dev.c | 4 ++--
 drivers/crypto/ccp/ccp_pci.c | 3 ++-
 drivers/crypto/ccp/rte_ccp_pmd.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c index 
424ead82c3..9c9cb81236 100644
--- a/drivers/crypto/ccp/ccp_dev.c
+++ b/drivers/crypto/ccp/ccp_dev.c
@@ -362,7 +362,7 @@ ccp_find_lsb_regions(struct ccp_queue *cmd_q, uint64_t 
status)
if (ccp_get_bit(&cmd_q->lsbmask, j))
weight++;

-   printf("Queue %d can access %d LSB regions  of mask  %lu\n",
+   CCP_LOG_DBG("Queue %d can access %d LSB regions  of mask  
+ %lu\n",
   (int)cmd_q->id, weight, cmd_q->lsbmask);

return weight ? 0 : -EINVAL;
@@ -709,7 +709,7 @@ ccp_probe_devices(struct rte_pci_device *pci_dev,
snprintf(dirname, sizeof(dirname), "%s/%s",
 SYSFS_PCI_DEVICES, d->d_name);
if (is_ccp_device(dirname, ccp_id, &ccp_type)) {
-   printf("CCP : Detected CCP device with ID = 0x%x\n",
+   CCP_LOG_DBG("CCP : Detected CCP device with ID = 
+ 0x%x\n",
   ccp_id[ccp_type].device_id);
ret = ccp_probe_device(ccp_type, pci_dev);
if (ret == 0)
diff --git a/drivers/crypto/ccp/ccp_pci.c b/drivers/crypto/ccp/ccp_pci.c index 
38029a9081..c941e222c7 100644
--- a/drivers/crypto/ccp/ccp_pci.c
+++ b/drivers/crypto/ccp/ccp_pci.c
@@ -11,6 +11,7 @@
 #include 

 #include "ccp_pci.h"
+#include "ccp_pmd_private.h"

 static const char * const uio_module_names[] = {
"igb_uio",
@@ -41,7 +42,7 @@ ccp_check_pci_uio_module(void)
rewind(fp);
}
fclose(fp);
-   printf("Insert igb_uio or uio_pci_generic kernel module(s)");
+   CCP_LOG_DBG("Insert igb_uio or uio_pci_generic kernel 
+ module(s)");
return -1;/* uio not inserted */  }

diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c
index 013f3be1e6..7338ef0ae8 100644
--- a/drivers/crypto/ccp/rte_ccp_pmd.c
+++ b/drivers/crypto/ccp/rte_ccp_pmd.c
@@ -250,7 +250,7 @@ cryptodev_ccp_create(const char *name,
goto init_error;
}

-   printf("CCP : Crypto device count = %d\n", cryptodev_cnt);
+   CCP_LOG_DBG("CCP : Crypto device count = %d\n", cryptodev_cnt);
dev->device = &pci_dev->device;
dev->device->driver = &pci_drv->driver;
dev->driver_id = ccp_cryptodev_driver_id;
--
2.37.3


RE: [PATCH v2 2/4] crypto/ccp: remove some dead code for UIO

2023-01-13 Thread Uttarwar, Sunil Prakashrao
[Public]

Acked-by: Sunil Uttarwar 

-Original Message-
From: David Marchand  
Sent: Tuesday, October 4, 2022 3:22 PM
To: dev@dpdk.org
Cc: gak...@marvell.com; Uttarwar, Sunil Prakashrao 
; sta...@dpdk.org; Somalapuram, Amaranath 

Subject: [PATCH v2 2/4] crypto/ccp: remove some dead code for UIO

Caution: This message originated from an External Source. Use proper caution 
when opening attachments, clicking links, or responding.


uio_fd is unused.

Fixes: 09a0fd736a08 ("crypto/ccp: enable IOMMU")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand 
---
 drivers/crypto/ccp/ccp_dev.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c index 
9c9cb81236..410e62121e 100644
--- a/drivers/crypto/ccp/ccp_dev.c
+++ b/drivers/crypto/ccp/ccp_dev.c
@@ -653,7 +653,6 @@ static int
 ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev)  {
struct ccp_device *ccp_dev = NULL;
-   int uio_fd = -1;

ccp_dev = rte_zmalloc("ccp_device", sizeof(*ccp_dev),
  RTE_CACHE_LINE_SIZE); @@ -671,8 +670,6 @@ 
ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev)
return 0;
 fail:
CCP_LOG_ERR("CCP Device probe failed");
-   if (uio_fd >= 0)
-   close(uio_fd);
rte_free(ccp_dev);
return -1;
 }
--
2.37.3


RE: [PATCH v2 3/4] crypto/ccp: fix IOVA handling

2023-01-13 Thread Uttarwar, Sunil Prakashrao
[Public]

Acked-by: Sunil Uttarwar 

-Original Message-
From: David Marchand  
Sent: Tuesday, October 4, 2022 3:22 PM
To: dev@dpdk.org
Cc: gak...@marvell.com; Uttarwar, Sunil Prakashrao 
; sta...@dpdk.org; Somalapuram, Amaranath 

Subject: [PATCH v2 3/4] crypto/ccp: fix IOVA handling

Caution: This message originated from an External Source. Use proper caution 
when opening attachments, clicking links, or responding.


Using IOVA or physical addresses is something that the user (via
--iova-mode=) or the bus code decides.

The crypto/ccp PCI driver should only use rte_mem_virt2iova.
It should not try to decide what to use solely based on the kmod the PCI device 
is bound to.

While at it, the global variable sha_ctx looks unsafe and unneeded.
Remove it.

Fixes: 09a0fd736a08 ("crypto/ccp: enable IOMMU")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand 
---
 drivers/crypto/ccp/ccp_crypto.c  | 105 ++-
 drivers/crypto/ccp/ccp_dev.c |   9 +--
 drivers/crypto/ccp/ccp_pci.c |  34 --
 drivers/crypto/ccp/ccp_pci.h |   3 -
 drivers/crypto/ccp/rte_ccp_pmd.c |   3 -
 5 files changed, 19 insertions(+), 135 deletions(-)

diff --git a/drivers/crypto/ccp/ccp_crypto.c b/drivers/crypto/ccp/ccp_crypto.c 
index 4bab18323b..351d8ac63e 100644
--- a/drivers/crypto/ccp/ccp_crypto.c
+++ b/drivers/crypto/ccp/ccp_crypto.c
@@ -33,8 +33,6 @@
 #include 
 #include 

-extern int iommu_mode;
-void *sha_ctx;
 /* SHA initial context values */
 uint32_t ccp_sha1_init[SHA_COMMON_DIGEST_SIZE / sizeof(uint32_t)] = {
SHA1_H4, SHA1_H3,
@@ -748,13 +746,8 @@ ccp_configure_session_cipher(struct ccp_session *sess,
CCP_LOG_ERR("Invalid CCP Engine");
return -ENOTSUP;
}
-   if (iommu_mode == 2) {
-   sess->cipher.nonce_phys = rte_mem_virt2iova(sess->cipher.nonce);
-   sess->cipher.key_phys = rte_mem_virt2iova(sess->cipher.key_ccp);
-   } else {
-   sess->cipher.nonce_phys = rte_mem_virt2phy(sess->cipher.nonce);
-   sess->cipher.key_phys = rte_mem_virt2phy(sess->cipher.key_ccp);
-   }
+   sess->cipher.nonce_phys = rte_mem_virt2iova(sess->cipher.nonce);
+   sess->cipher.key_phys = rte_mem_virt2iova(sess->cipher.key_ccp);
return 0;
 }

@@ -793,7 +786,6 @@ ccp_configure_session_auth(struct ccp_session *sess,
sess->auth.ctx = (void *)ccp_sha1_init;
sess->auth.ctx_len = CCP_SB_BYTES;
sess->auth.offset = CCP_SB_BYTES - SHA1_DIGEST_SIZE;
-   rte_memcpy(sha_ctx, sess->auth.ctx, SHA_COMMON_DIGEST_SIZE);
break;
case RTE_CRYPTO_AUTH_SHA1_HMAC:
if (sess->auth_opt) {
@@ -832,7 +824,6 @@ ccp_configure_session_auth(struct ccp_session *sess,
sess->auth.ctx = (void *)ccp_sha224_init;
sess->auth.ctx_len = CCP_SB_BYTES;
sess->auth.offset = CCP_SB_BYTES - SHA224_DIGEST_SIZE;
-   rte_memcpy(sha_ctx, sess->auth.ctx, SHA256_DIGEST_SIZE);
break;
case RTE_CRYPTO_AUTH_SHA224_HMAC:
if (sess->auth_opt) {
@@ -895,7 +886,6 @@ ccp_configure_session_auth(struct ccp_session *sess,
sess->auth.ctx = (void *)ccp_sha256_init;
sess->auth.ctx_len = CCP_SB_BYTES;
sess->auth.offset = CCP_SB_BYTES - SHA256_DIGEST_SIZE;
-   rte_memcpy(sha_ctx, sess->auth.ctx, SHA256_DIGEST_SIZE);
break;
case RTE_CRYPTO_AUTH_SHA256_HMAC:
if (sess->auth_opt) {
@@ -958,7 +948,6 @@ ccp_configure_session_auth(struct ccp_session *sess,
sess->auth.ctx = (void *)ccp_sha384_init;
sess->auth.ctx_len = CCP_SB_BYTES << 1;
sess->auth.offset = (CCP_SB_BYTES << 1) - SHA384_DIGEST_SIZE;
-   rte_memcpy(sha_ctx, sess->auth.ctx, SHA512_DIGEST_SIZE);
break;
case RTE_CRYPTO_AUTH_SHA384_HMAC:
if (sess->auth_opt) {
@@ -1023,7 +1012,6 @@ ccp_configure_session_auth(struct ccp_session *sess,
sess->auth.ctx = (void *)ccp_sha512_init;
sess->auth.ctx_len = CCP_SB_BYTES << 1;
sess->auth.offset = (CCP_SB_BYTES << 1) - SHA512_DIGEST_SIZE;
-   rte_memcpy(sha_ctx, sess->auth.ctx, SHA512_DIGEST_SIZE);
break;
case RTE_CRYPTO_AUTH_SHA512_HMAC:
if (sess->auth_opt) {
@@ -1173,13 +1161,8 @@ ccp_configure_session_aead(struct ccp_session *sess,
CCP_LOG_ERR("Unsupported aead algo");
return -ENOTSUP;
}
-   if (iommu_mode == 2) {
-   sess->cipher.nonce_phys = rte_mem_virt2iova(sess->cipher.nonce);
-   sess->cipher.key_phys = rte_mem_virt2iova(sess->cipher.key_ccp);
-   } else {
-   sess->cipher.nonce_phys = rte_mem_virt2phy(sess->cipher.nonce);
-   sess->cipher.key_phys = rte_mem_virt2phy(sess->

RE: [EXT] Re: [PATCH] ring: compilation fix with GCC-12

2023-01-13 Thread Amit Prakash Shukla
Hi Thomas,

> -Original Message-
> From: Thomas Monjalon 
> Sent: Friday, January 13, 2023 3:12 AM
> To: Konstantin Ananyev ; Honnappa
> Nagarahalli ; Amit Prakash Shukla
> 
> Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran ;
> david.march...@redhat.com; bruce.richard...@intel.com;
> ferruh.yi...@amd.com
> Subject: Re: [EXT] Re: [PATCH] ring: compilation fix with GCC-12
> 
> 23/08/2022 11:38, Amit Prakash Shukla:
> > From: Konstantin Ananyev 
> > > 06/08/2022 19:35, Honnappa Nagarahalli пишет:
> > > >> Replacing memcpy with rte_memcpy fixes the GCC-12 compilation
> issue.
> > > >
> > > > Any reason why this replacement fixes the problem?
> > > > Do you have any performance numbers with this change?
> > > >
> > > >> Also it would be better to change to rte_memcpy as the function
> > > >> is called in fastpath.
> > > >
> > > > On Arm platforms, memcpy in the later versions has the best
> performance.
> > >
> > > I agree with Honnappa, it is better to keep memcpy() here.
> > > Actually what is strange - why it ends up in
> > > __rte_ring_dequeue_elems_128() at all?
> > > Inside rxa_intr_ring_dequeue() we clearly doing: rte_ring_dequeue(),
> > > which should boil down to ___rte_ring_dequeue_elems_64().
> > > it should go to __rte_ring_dequeue_elems_128() at all.
> >
> > I agree. After having close look and doing few experiments, ideally it
> > should not be going to __rte_ring_dequeue_elems_128().
> > Sizeof(in call of rte_ring_enqueue_elem) gets evaluated at compile
> > time which in this case it is evaluated to 8 bytes so
> > __rte_ring_dequeue_elems_128() shall not be in the path. Looks like more
> of a gcc-12 bug.?
> >
> > > Another q - is this warning happens only on arm platforms?
> >
> > Warning is observed on x86 with build type as debug.
> > "meson --werror --buildtype=debug build"
> 
> I confirm the compilation issue on x86 with GCC 12 in a debug build.
> 
> We need to find a workaround.
> Is it reported to GCC already?
> 
I found an old gcc bug reporting similar issue. This bug seems to be re-opened 
recently in Dec-2022. Not sure if it is reopened specifically for gcc-12.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89689

Kevin has push a work around for DPDK-21.11.3.
https://git.dpdk.org/dpdk-stable/commit/?h=21.11&id=e1d728588dc73af9ed60cc0074d51a7f24b2ba60


RE: [PATCH v2 00/21] add support for cpfl PMD in DPDK

2023-01-13 Thread Zhang, Helin


> -Original Message-
> From: Mingxia Liu 
> Sent: Friday, January 13, 2023 4:19 PM
> To: dev@dpdk.org; Zhang, Qi Z ; Wu, Jingjing
> ; Xing, Beilei 
> Cc: Wu, Wenjun1 ; Liu, Mingxia
> 
> Subject: [PATCH v2 00/21] add support for cpfl PMD in DPDK
> 
> The patchset introduced the cpfl (Control Plane Function Library) PMD for
> Intel® IPU E2100’s Configure Physical Function (Device ID: 0x1453)
> 
> The cpfl PMD inherits all the features from idpf PMD which will follow an
> ongoing standard data plan function spec https://www.oasis-
> open.org/committees/tc_home.php?wg_abbrev=idpf
> Besides, it will also support more device specific hardware offloading
> features from DPDK’s control path (e.g.: hairpin, rte_flow …)
Can you explain a bit why idpf cannot be used for this new PCIe function? Why 
do you need to create a new PMD?

Thanks,
Helin
> 
> This patchset mainly focuses on idpf PMD’s equivalent features.
> To avoid duplicated code, the patchset depends on below patchsets which
> move the common part from net/idpf into common/idpf as a shared library.
> 
> This patchset is based on the idpf PMD code:
> http://patches.dpdk.org/project/dpdk/cover/20230106090501.9106-1-
> beilei.x...@intel.com/
> http://patches.dpdk.org/project/dpdk/cover/20230106091627.13530-1-
> beilei.x...@intel.com/
> http://patches.dpdk.org/project/dpdk/patch/20230113015119.3279019-2-
> wenjun1...@intel.com/
> http://patches.dpdk.org/project/dpdk/cover/20230111071545.504706-1-
> mingxia@intel.com/
> 
> v2 changes:
>  - rebase to the new baseline.
>  - Fix rss lut config issue.
> 
> Mingxia Liu (21):
>   net/cpfl: support device initialization
>   net/cpfl: add Tx queue setup
>   net/cpfl: add Rx queue setup
>   net/cpfl: support device start and stop
>   net/cpfl: support queue start
>   net/cpfl: support queue stop
>   net/cpfl: support queue release
>   net/cpfl: support MTU configuration
>   net/cpfl: support basic Rx data path
>   net/cpfl: support basic Tx data path
>   net/cpfl: support write back based on ITR expire
>   net/cpfl: support RSS
>   net/cpfl: support Rx offloading
>   net/cpfl: support Tx offloading
>   net/cpfl: add AVX512 data path for single queue model
>   net/cpfl: support timestamp offload
>   net/cpfl: add AVX512 data path for split queue model
>   net/cpfl: add hw statistics
>   net/cpfl: add RSS set/get ops
>   net/cpfl: support single q scatter RX datapath
>   net/cpfl: add xstats ops
> 
>  MAINTAINERS |9 +
>  doc/guides/nics/cpfl.rst|   88 ++
>  doc/guides/nics/features/cpfl.ini   |   17 +
>  doc/guides/rel_notes/release_23_03.rst  |5 +
>  drivers/net/cpfl/cpfl_ethdev.c  | 1490 +++
>  drivers/net/cpfl/cpfl_ethdev.h  |   95 ++
>  drivers/net/cpfl/cpfl_logs.h|   32 +
>  drivers/net/cpfl/cpfl_rxtx.c|  900 ++
>  drivers/net/cpfl/cpfl_rxtx.h|   44 +
>  drivers/net/cpfl/cpfl_rxtx_vec_common.h |  113 ++
>  drivers/net/cpfl/meson.build|   38 +
>  drivers/net/idpf/idpf_ethdev.c  |3 +-
>  drivers/net/meson.build |1 +
>  13 files changed, 2834 insertions(+), 1 deletion(-)  create mode 100644
> doc/guides/nics/cpfl.rst  create mode 100644
> doc/guides/nics/features/cpfl.ini  create mode 100644
> drivers/net/cpfl/cpfl_ethdev.c  create mode 100644
> drivers/net/cpfl/cpfl_ethdev.h  create mode 100644
> drivers/net/cpfl/cpfl_logs.h  create mode 100644 drivers/net/cpfl/cpfl_rxtx.c
> create mode 100644 drivers/net/cpfl/cpfl_rxtx.h  create mode 100644
> drivers/net/cpfl/cpfl_rxtx_vec_common.h
>  create mode 100644 drivers/net/cpfl/meson.build
> 
> --
> 2.25.1



Re: [PATCH] net/i40e: disable source pruning

2023-01-13 Thread Ferruh Yigit
On 1/9/2023 2:20 AM, Ke Zhang wrote:
> VRRP advertisement packets are dropped on i40e PF devices because
> when a MAC address is added to a device, packets originating from
> that MAC address are dropped.
> 
> This patch adds a interface in lib/ethdev to support disabling
> source pruning to work around above issue.
> 

Hi Ke,

We have a dilemma between enabling as much HW config/feature as possible
and having common/portable APIs.

If we add a new API for each specific HW config/feature, it will be
confusing for users and DPDK APIs won't be portable. We may end up
slightly specific version of an API specific to a NIC.
For this we used PMD specific APIs time to time (like
drivers/net/i40e/rte_pmd_i40e.h), although is not also a good solution.


If this is a common config/feature for more than one NIC, I am OK to
procced with the patch as it is, for this I have cc'ed a few more folks,
but first can you please describe the config/feature a little more
detailed please.

What I understand is if packet target MAC address is same as device MAC
address, packet is dropped, which is called 'source pruning' feature.
What is the use case for this, is the expectation send a packet to
router/switch and expect to receive it back?

Is all egress packets dropped as described? Becase feture referred as
"local loopback" in the code, is this only applied to packets switched
locally in NIC?

Can it be solution to always disable source pruning by default?


If this is specific to i40e, I suggest adding it as PMD specific API.
I put some comments below but first need to clarify how to procced with
the patch.



> Bugzilla ID: 648
> 
> Signed-off-by: Ke Zhang 
> ---
>  app/test-pmd/cmdline.c | 77 ++
>  drivers/net/i40e/i40e_ethdev.c | 53 +++
>  lib/ethdev/ethdev_driver.h |  6 +++
>  lib/ethdev/rte_ethdev.c| 16 +++
>  lib/ethdev/rte_ethdev.h| 15 +++
>  5 files changed, 167 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index cb8c174020..a9602a2ed0 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -482,6 +482,9 @@ static void cmd_help_long_parsed(void *parsed_result,
>   "set promisc (port_id|all) (on|off)\n"
>   "Set the promiscuous mode on port_id, or all.\n\n"
>  
> + "set llb (port_id|all) (on|off)\n"
> + "Set vsi local loopback on port_id, or all.\n\n"
> +

Please don't use abreviations, specially for not commonly knows
features, 'llb' won't make sense to many people, and as number of this
unkown commonds increase it has a risk to make testpmd unusable,
please prefer 'local_loopback'.

And please don't refer to 'vsi' here.

And personally I don't prefer using 'set xxx' commands to configure
device, what I prefer:

"set xxx"   --> set testpmd specific configuration
"port config  xxx" --> configure device


Although I am aware this separation is not clear and there is a mixuture
of usage, some of them historical.


>   "set allmulti (port_id|all) (on|off)\n"
>   "Set the allmulti mode on port_id, or all.\n\n"
>  
> @@ -5775,6 +5778,78 @@ static cmdline_parse_inst_t cmd_set_promisc_mode_one = 
> {
>   },
>  };
>  
> +/* *** SET VSI LOCAL LOOPBACK *** *> +struct cmd_set_vsi_local_lb_result {
> + cmdline_fixed_string_t set;
> + cmdline_fixed_string_t llb;
> + cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
> + uint16_t port_num;   /* valid if "allports" argument == 0 */
> + cmdline_fixed_string_t enable;
> +};
> +
> +static void cmd_set_vsi_llb_parsed(void *parsed_result,
> + __rte_unused struct cmdline *cl,
> + void *allports)
> +{
> + struct cmd_set_vsi_local_lb_result *res = parsed_result;
> + int enable;
> + portid_t i;
> +
> + if (!strcmp(res->enable, "on"))
> + enable = 1;
> + else
> + enable = 0;
> +
> + /* all ports */
> + if (allports) {
> + RTE_ETH_FOREACH_DEV(i)
> + rte_eth_dev_enable_local_lb(i, enable);
> + } else {
> + rte_eth_dev_enable_local_lb(res->port_num, enable);
> + }
> +}
> +
> +static cmdline_parse_token_string_t cmd_setllb_set =
> + TOKEN_STRING_INITIALIZER(struct cmd_set_vsi_local_lb_result, set, 
> "set");
> +static cmdline_parse_token_string_t cmd_setllb_llb =
> + TOKEN_STRING_INITIALIZER(struct cmd_set_vsi_local_lb_result, llb,
> +  "llb");
> +static cmdline_parse_token_string_t cmd_setllb_portall =
> + TOKEN_STRING_INITIALIZER(struct cmd_set_vsi_local_lb_result, port_all,
> +  "all");
> +static cmdline_parse_token_num_t cmd_setllb_portnum =
> + TOKEN_NUM_INITIALIZER(struct cmd_set_vsi_local_lb_result, port_nu

Re: [EXT] Re: [PATCH] ring: compilation fix with GCC-12

2023-01-13 Thread Thomas Monjalon
13/01/2023 13:39, Amit Prakash Shukla:
> From: Thomas Monjalon 
> > 23/08/2022 11:38, Amit Prakash Shukla:
> > > From: Konstantin Ananyev 
> > > > 06/08/2022 19:35, Honnappa Nagarahalli пишет:
> > > > >> Replacing memcpy with rte_memcpy fixes the GCC-12 compilation
> > issue.
> > > > >
> > > > > Any reason why this replacement fixes the problem?
> > > > > Do you have any performance numbers with this change?
> > > > >
> > > > >> Also it would be better to change to rte_memcpy as the function
> > > > >> is called in fastpath.
> > > > >
> > > > > On Arm platforms, memcpy in the later versions has the best
> > performance.
> > > >
> > > > I agree with Honnappa, it is better to keep memcpy() here.
> > > > Actually what is strange - why it ends up in
> > > > __rte_ring_dequeue_elems_128() at all?
> > > > Inside rxa_intr_ring_dequeue() we clearly doing: rte_ring_dequeue(),
> > > > which should boil down to ___rte_ring_dequeue_elems_64().
> > > > it should go to __rte_ring_dequeue_elems_128() at all.
> > >
> > > I agree. After having close look and doing few experiments, ideally it
> > > should not be going to __rte_ring_dequeue_elems_128().
> > > Sizeof(in call of rte_ring_enqueue_elem) gets evaluated at compile
> > > time which in this case it is evaluated to 8 bytes so
> > > __rte_ring_dequeue_elems_128() shall not be in the path. Looks like more
> > of a gcc-12 bug.?
> > >
> > > > Another q - is this warning happens only on arm platforms?
> > >
> > > Warning is observed on x86 with build type as debug.
> > > "meson --werror --buildtype=debug build"
> > 
> > I confirm the compilation issue on x86 with GCC 12 in a debug build.
> > 
> > We need to find a workaround.
> > Is it reported to GCC already?
> > 
> I found an old gcc bug reporting similar issue. This bug seems to be 
> re-opened recently in Dec-2022. Not sure if it is reopened specifically for 
> gcc-12.
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89689

Please would you like to open a bug specific to GCC 12?

> Kevin has push a work around for DPDK-21.11.3.
> https://git.dpdk.org/dpdk-stable/commit/?h=21.11&id=e1d728588dc73af9ed60cc0074d51a7f24b2ba60

In the meantime we could use Kevin's workaround:

#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 12)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#pragma GCC diagnostic ignored "-Wstringop-overread"
#endif

Opinions?




RE: [PATCH v2 01/21] net/cpfl: support device initialization

2023-01-13 Thread Zhang, Helin



> -Original Message-
> From: Mingxia Liu 
> Sent: Friday, January 13, 2023 4:19 PM
> To: dev@dpdk.org; Zhang, Qi Z ; Wu, Jingjing
> ; Xing, Beilei 
> Cc: Wu, Wenjun1 ; Liu, Mingxia
> 
> Subject: [PATCH v2 01/21] net/cpfl: support device initialization
> 
> Support device init and add the following dev ops:
>  - dev_configure
>  - dev_close
>  - dev_infos_get
>  - link_update
>  - cpfl_dev_supported_ptypes_get
> 
> Signed-off-by: Mingxia Liu 
> ---
>  MAINTAINERS|   9 +
>  doc/guides/nics/cpfl.rst   |  66 +++
>  doc/guides/nics/features/cpfl.ini  |  12 +
>  doc/guides/rel_notes/release_23_03.rst |   5 +
>  drivers/net/cpfl/cpfl_ethdev.c | 769 +
>  drivers/net/cpfl/cpfl_ethdev.h |  78 +++
>  drivers/net/cpfl/cpfl_logs.h   |  32 +
>  drivers/net/cpfl/cpfl_rxtx.c   | 244 
>  drivers/net/cpfl/cpfl_rxtx.h   |  25 +
>  drivers/net/cpfl/meson.build   |  14 +
>  drivers/net/meson.build|   1 +
>  11 files changed, 1255 insertions(+)
>  create mode 100644 doc/guides/nics/cpfl.rst  create mode 100644
> doc/guides/nics/features/cpfl.ini  create mode 100644
> drivers/net/cpfl/cpfl_ethdev.c  create mode 100644
> drivers/net/cpfl/cpfl_ethdev.h  create mode 100644
> drivers/net/cpfl/cpfl_logs.h  create mode 100644 drivers/net/cpfl/cpfl_rxtx.c
> create mode 100644 drivers/net/cpfl/cpfl_rxtx.h  create mode 100644
> drivers/net/cpfl/meson.build
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 22ef2ea4b9..970acc5751 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -780,6 +780,15 @@ F: drivers/common/idpf/
>  F: doc/guides/nics/idpf.rst
>  F: doc/guides/nics/features/idpf.ini
> 
> +Intel cpfl
> +M: Qi Zhang 
> +M: Jingjing Wu 
> +M: Beilei Xing 
> +T: git://dpdk.org/next/dpdk-next-net-intel
> +F: drivers/net/cpfl/
> +F: doc/guides/nics/cpfl.rst
> +F: doc/guides/nics/features/cpfl.ini
> +
>  Intel igc
>  M: Junfeng Guo 
>  M: Simei Su 
> diff --git a/doc/guides/nics/cpfl.rst b/doc/guides/nics/cpfl.rst new file mode
> 100644 index 00..064c69ba7d
> --- /dev/null
> +++ b/doc/guides/nics/cpfl.rst
> @@ -0,0 +1,66 @@
> +.. SPDX-License-Identifier: BSD-3-Clause
> +   Copyright(c) 2022 Intel Corporation.
> +
> +.. include:: 
> +
> +CPFL Poll Mode Driver
> +=
> +
> +The [*EXPERIMENTAL*] cpfl PMD (**librte_net_cpfl**) provides poll mode
> +driver support for Intel\ |reg| Infrastructure Processing Unit (Intel\ |reg|
> IPU) E2100.
> +
> +
> +Linux Prerequisites
> +---
> +
> +Follow the DPDK :doc:`../linux_gsg/index` to setup the basic DPDK
> environment.
> +
> +To get better performance on Intel platforms, please follow the
> +:doc:`../linux_gsg/nic_perf_intel_platform`.
> +
> +
> +Pre-Installation Configuration
> +--
> +
> +Runtime Config Options
> +~~
> +
> +- ``vport`` (default ``0``)
> +
> +  The PMD supports creation of multiple vports for one PCI device,
> + each vport corresponds to a single ethdev.
> +  The user can specify the vports with specific ID to be created, for 
> example::
> +
> +-a ca:00.0,vport=[0,2,3]
> +
> +  Then the PMD will create 3 vports (ethdevs) for device ``ca:00.0``.
> +
> +  If the parameter is not provided, the vport 0 will be created by default.
> +
> +- ``rx_single`` (default ``0``)
> +
> +  There are two queue modes supported by Intel\ |reg| IPU Ethernet
> + ES2000 Series,  single queue mode and split queue mode for Rx queue.
What is the relationship with IPU E2100? Is IPU ethernet ES2000 a new product?

Thanks,
Helin

> +  User can choose Rx queue mode, example::
> +
> +-a ca:00.0,rx_single=1
> +
> +  Then the PMD will configure Rx queue with single queue mode.
> +  Otherwise, split queue mode is chosen by default.
> +
> +- ``tx_single`` (default ``0``)
> +
> +  There are two queue modes supported by Intel\ |reg| IPU Ethernet
> + ES2000 Series,  single queue mode and split queue mode for Tx queue.
> +  User can choose Tx queue mode, example::
> +
> +-a ca:00.0,tx_single=1
> +
> +  Then the PMD will configure Tx queue with single queue mode.
> +  Otherwise, split queue mode is chosen by default.
> +
> +
> +Driver compilation and testing
> +--
> +
> +Refer to the document :doc:`build_and_test` for details.
> \ No newline at end of file
> diff --git a/doc/guides/nics/features/cpfl.ini
> b/doc/guides/nics/features/cpfl.ini
> new file mode 100644
> index 00..a2d1ca9e15
> --- /dev/null
> +++ b/doc/guides/nics/features/cpfl.ini
> @@ -0,0 +1,12 @@
> +;
> +; Supported features of the 'cpfl' network poll mode driver.
> +;
> +; Refer to default.ini for the full list of available PMD features.
> +;
> +; A feature with "P" indicates only be supported when non-vector path ;
> +is selected.
> +;
> +[Features]
> +Linux= Y
> +x86-32   = Y
> +x86-64   = Y
> diff --git a/doc/guides/rel_notes/

Re: [PATCH v2] net/i40e: don't check link status on device start

2023-01-13 Thread David Marchand
Hello i40e maintainers, John,

On Mon, Jan 9, 2023 at 10:21 AM David Marchand
 wrote:
> On Tue, Jan 3, 2023 at 3:02 PM David Marchand  
> wrote:
> > Hi i40e maintainers,
> >
> > On Tue, Dec 13, 2022 at 10:19 AM David Marchand
> >  wrote:
> > >
> > > The mentioned changes broke existing applications when the link status
> > > of i40e ports is down at the time the port is started.
> > > Revert those changes, the original issue will need a different fix.
> > >
> > > Fixes: a4ba77367923 ("net/i40e: enable maximum frame size at port level")
> > > Fixes: 2184f7cdeeaa ("net/i40e: fix max frame size config at port level")
> > > Fixes: 719469f13b11 ("net/i40e: fix jumbo frame Rx with X722")
> > > Cc: sta...@dpdk.org
> > >
> > > Signed-off-by: David Marchand 
> >
> > This issue was reported only by our QE, but I suspect that real
> > deployments will get affected.
> > Please review.
>
> Ping.

Ping.

Note: I removed Jie Wang from Cc list since I get bounces.

-- 
David Marchand



Re: [PATCH v4] net/iavf: add lock for vf commands

2023-01-13 Thread David Marchand
Hi iavf maintainers,

On Thu, Dec 29, 2022 at 12:00 AM Mike Pattrick  wrote:
>
> iavf admin queue commands aren't thread-safe. Bugs surrounding this
> issue can manifest in a variety of ways but frequently pend_cmd is
> over written. Simultaneously executing commands can result in a
> misconfigured device or DPDK sleeping in a thread for 2 second.
>
> Despite this limitation, vf commands may be executed from both
> iavf_dev_alarm_handler() in a control thread and the applications main
> thread. This is trivial to simulate in the testpmd application by
> creating a bond of vf's in active backup mode, and then turning the
> bond off and then on again repeatedly.
>
> Previously [1] was proposed as a potential solution, but this commit did
> not resolve all potential issues concerning the admin queue and has been
> reverted from the stable branch. I propose adding locks until a more
> complete solution is available.
>
> [1] commit cb5c1b91f76f ("net/iavf: add thread for event callbacks")
>
> Fixes: 48de41ca11f0 ("net/avf: enable link status update")
> Fixes: 84108425054a ("net/iavf: support asynchronous virtual channel message")
> Cc: sta...@dpdk.org
>
> Signed-off-by: Mike Pattrick 

Review please.


-- 
David Marchand



RE: [PATCH v2] net/i40e: don't check link status on device start

2023-01-13 Thread Zhang, Helin


> -Original Message-
> From: David Marchand 
> Sent: Friday, January 13, 2023 9:33 PM
> To: Zhang, Yuying ; Xing, Beilei
> ; Mcnamara, John 
> Cc: dev@dpdk.org; sta...@dpdk.org; Zhang, Qi Z ;
> Dapeng Yu ; Wenxuan Wu
> 
> Subject: Re: [PATCH v2] net/i40e: don't check link status on device start
> 
> Hello i40e maintainers, John,
> 
> On Mon, Jan 9, 2023 at 10:21 AM David Marchand
>  wrote:
> > On Tue, Jan 3, 2023 at 3:02 PM David Marchand
>  wrote:
> > > Hi i40e maintainers,
> > >
> > > On Tue, Dec 13, 2022 at 10:19 AM David Marchand
> > >  wrote:
> > > >
> > > > The mentioned changes broke existing applications when the link
> > > > status of i40e ports is down at the time the port is started.
> > > > Revert those changes, the original issue will need a different fix.
Hi David

Does it break all the application or just a specific application?
We may need to understand the issue you met, and try to fix it later.
Thank you very much for reporting it out!

Regards,
Helin

> > > >
> > > > Fixes: a4ba77367923 ("net/i40e: enable maximum frame size at port
> > > > level")
> > > > Fixes: 2184f7cdeeaa ("net/i40e: fix max frame size config at port
> > > > level")
> > > > Fixes: 719469f13b11 ("net/i40e: fix jumbo frame Rx with X722")
> > > > Cc: sta...@dpdk.org
> > > >
> > > > Signed-off-by: David Marchand 
> > >
> > > This issue was reported only by our QE, but I suspect that real
> > > deployments will get affected.
> > > Please review.
> >
> > Ping.
> 
> Ping.
> 
> Note: I removed Jie Wang from Cc list since I get bounces.
> 
> --
> David Marchand



Re: [PATCH v2] net/i40e: don't check link status on device start

2023-01-13 Thread David Marchand
On Fri, Jan 13, 2023 at 2:39 PM Zhang, Helin  wrote:
>
>
>
> > -Original Message-
> > From: David Marchand 
> > Sent: Friday, January 13, 2023 9:33 PM
> > To: Zhang, Yuying ; Xing, Beilei
> > ; Mcnamara, John 
> > Cc: dev@dpdk.org; sta...@dpdk.org; Zhang, Qi Z ;
> > Dapeng Yu ; Wenxuan Wu
> > 
> > Subject: Re: [PATCH v2] net/i40e: don't check link status on device start
> >
> > Hello i40e maintainers, John,
> >
> > On Mon, Jan 9, 2023 at 10:21 AM David Marchand
> >  wrote:
> > > On Tue, Jan 3, 2023 at 3:02 PM David Marchand
> >  wrote:
> > > > Hi i40e maintainers,
> > > >
> > > > On Tue, Dec 13, 2022 at 10:19 AM David Marchand
> > > >  wrote:
> > > > >
> > > > > The mentioned changes broke existing applications when the link
> > > > > status of i40e ports is down at the time the port is started.
> > > > > Revert those changes, the original issue will need a different fix.
> Hi David
>
> Does it break all the application or just a specific application?

I don't see how it would not affect all applications seeing how the
original patch is dumb.

> We may need to understand the issue you met, and try to fix it later.

Just unplug the cable or fake a link down on your i40e port, start
your application or port, then plug the cable back.
The max frame size will never get applied to hw.


-- 
David Marchand



RE: [PATCH v2] net/i40e: don't check link status on device start

2023-01-13 Thread Zhang, Helin


> -Original Message-
> From: David Marchand 
> Sent: Friday, January 13, 2023 9:47 PM
> To: Zhang, Helin 
> Cc: Zhang, Yuying ; Xing, Beilei
> ; Mcnamara, John ;
> dev@dpdk.org; sta...@dpdk.org; Zhang, Qi Z ;
> Dapeng Yu ; Wenxuan Wu
> 
> Subject: Re: [PATCH v2] net/i40e: don't check link status on device start
> 
> On Fri, Jan 13, 2023 at 2:39 PM Zhang, Helin  wrote:
> >
> >
> >
> > > -Original Message-
> > > From: David Marchand 
> > > Sent: Friday, January 13, 2023 9:33 PM
> > > To: Zhang, Yuying ; Xing, Beilei
> > > ; Mcnamara, John 
> > > Cc: dev@dpdk.org; sta...@dpdk.org; Zhang, Qi Z
> > > ; Dapeng Yu ; Wenxuan
> Wu
> > > 
> > > Subject: Re: [PATCH v2] net/i40e: don't check link status on device
> > > start
> > >
> > > Hello i40e maintainers, John,
> > >
> > > On Mon, Jan 9, 2023 at 10:21 AM David Marchand
> > >  wrote:
> > > > On Tue, Jan 3, 2023 at 3:02 PM David Marchand
> > >  wrote:
> > > > > Hi i40e maintainers,
> > > > >
> > > > > On Tue, Dec 13, 2022 at 10:19 AM David Marchand
> > > > >  wrote:
> > > > > >
> > > > > > The mentioned changes broke existing applications when the
> > > > > > link status of i40e ports is down at the time the port is started.
> > > > > > Revert those changes, the original issue will need a different fix.
> > Hi David
> >
> > Does it break all the application or just a specific application?
> 
> I don't see how it would not affect all applications seeing how the original
> patch is dumb.
> 
> > We may need to understand the issue you met, and try to fix it later.
> 
> Just unplug the cable or fake a link down on your i40e port, start your
> application or port, then plug the cable back.
> The max frame size will never get applied to hw.
Got it, I will forward to a right expert to check. Thank you very much for 
reaching out to us!

Regards,
Helin
> 
> 
> --
> David Marchand



Re: [PATCH v7 4/4] eventdev/timer: change eventdev reconfig logic

2023-01-13 Thread Jerin Jacob
On Thu, Jan 12, 2023 at 10:01 PM Naga Harish K S V
 wrote:
>
> When rte_event_timer_adapter_create() is used for creating adapter
> instance, eventdev is reconfigured with additional
> ``rte_event_dev_config::nb_event_ports`` parameter.
>
> This eventdev reconfig logic is enhanced to increment the
> ``rte_event_dev_config::nb_single_link_event_port_queues``
> parameter if the adapter event port config is of type
> ``RTE_EVENT_PORT_CFG_SINGLE_LINK``.
>
> With this change the application is no longer need to configure the
> eventdev with ``rte_event_dev_config::nb_single_link_event_port_queues``
> parameter required for timer adapter when the adapter is created
> using above mentioned api.
>
> Signed-off-by: Naga Harish K S V 
> Acked-by: Abhinandan Gujjar 
> +* **Updated the eventdev reconfigure logic for service based adapters.**
> +
> +  * This eventdev reconfig logic is enhanced to increment the
> +``rte_event_dev_config::nb_single_link_event_port_queues``
> +parameter if event port config is of type
> +``RTE_EVENT_PORT_CFG_SINGLE_LINK``.
> +  * With this change, the application no longer needs to account for the
> +``rte_event_dev_config::nb_single_link_event_port_queues`` parameter
> +required for adapters.
> +  * This change is added for eth_rx, eth_tx, crypto and timer eventdev 
> adapters.

Updated as following and series applied to
dpdk-next-net-eventdev/for-main. Thanks

+* **Updated the eventdev reconfigure logic for service based adapters.**
+
+  * eventdev reconfig logic is enhanced to increment the
+``rte_event_dev_config::nb_single_link_event_port_queues`` parameter
+if event port config is of type ``RTE_EVENT_PORT_CFG_SINGLE_LINK``.
+  * With this change, the application no longer needs to account for the
+``rte_event_dev_config::nb_single_link_event_port_queues``
parameter required for
+eth_rx, eth_tx, crypto and timer eventdev adapters.
+


Re: [PATCH v2] net/i40e: don't check link status on device start

2023-01-13 Thread David Marchand
On Fri, Jan 13, 2023 at 2:51 PM Zhang, Helin  wrote:
>
>
>
> > -Original Message-
> > From: David Marchand 
> > Sent: Friday, January 13, 2023 9:47 PM
> > To: Zhang, Helin 
> > Cc: Zhang, Yuying ; Xing, Beilei
> > ; Mcnamara, John ;
> > dev@dpdk.org; sta...@dpdk.org; Zhang, Qi Z ;
> > Dapeng Yu ; Wenxuan Wu
> > 
> > Subject: Re: [PATCH v2] net/i40e: don't check link status on device start
> >
> > On Fri, Jan 13, 2023 at 2:39 PM Zhang, Helin  wrote:
> > >
> > >
> > >
> > > > -Original Message-
> > > > From: David Marchand 
> > > > Sent: Friday, January 13, 2023 9:33 PM
> > > > To: Zhang, Yuying ; Xing, Beilei
> > > > ; Mcnamara, John 
> > > > Cc: dev@dpdk.org; sta...@dpdk.org; Zhang, Qi Z
> > > > ; Dapeng Yu ; Wenxuan
> > Wu
> > > > 
> > > > Subject: Re: [PATCH v2] net/i40e: don't check link status on device
> > > > start
> > > >
> > > > Hello i40e maintainers, John,
> > > >
> > > > On Mon, Jan 9, 2023 at 10:21 AM David Marchand
> > > >  wrote:
> > > > > On Tue, Jan 3, 2023 at 3:02 PM David Marchand
> > > >  wrote:
> > > > > > Hi i40e maintainers,
> > > > > >
> > > > > > On Tue, Dec 13, 2022 at 10:19 AM David Marchand
> > > > > >  wrote:
> > > > > > >
> > > > > > > The mentioned changes broke existing applications when the
> > > > > > > link status of i40e ports is down at the time the port is started.
> > > > > > > Revert those changes, the original issue will need a different 
> > > > > > > fix.
> > > Hi David
> > >
> > > Does it break all the application or just a specific application?
> >
> > I don't see how it would not affect all applications seeing how the original
> > patch is dumb.
> >
> > > We may need to understand the issue you met, and try to fix it later.
> >
> > Just unplug the cable or fake a link down on your i40e port, start your
> > application or port, then plug the cable back.
> > The max frame size will never get applied to hw.
> Got it, I will forward to a right expert to check. Thank you very much for 
> reaching out to us!

I hope I get a reply _soon_.
Or I will just apply those reverts.


Thanks.

-- 
David Marchand



Re: [PATCH v3] eventdev/timer: add API to get remaining ticks

2023-01-13 Thread Jerin Jacob
On Tue, Dec 20, 2022 at 2:41 AM Erik Gabriel Carrillo
 wrote:
>
> Introduce an event timer adapter API which allows users to determine how
> many adapter ticks remain until an event timer fires.
>
> Signed-off-by: Erik Gabriel Carrillo 
>
>  /**
> diff --git a/lib/eventdev/rte_event_timer_adapter.c 
> b/lib/eventdev/rte_event_timer_adapter.c
> index a0f14bf861..ff762bb5f1 100644
> --- a/lib/eventdev/rte_event_timer_adapter.c
> +++ b/lib/eventdev/rte_event_timer_adapter.c
> @@ -8,6 +8,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include 
>  #include 
> @@ -458,6 +459,21 @@ rte_event_timer_adapter_stats_reset(struct 
> rte_event_timer_adapter *adapter)
> return adapter->ops->stats_reset(adapter);
>  }
>
> +int
> +rte_event_timer_get_remaining_ticks(
> +   const struct rte_event_timer_adapter *adapter,
> +   const struct rte_event_timer *evtim,
> +   uint64_t *ticks_remaining)
> +{
> +   ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL);
> +   FUNC_PTR_OR_ERR_RET(adapter->ops->get_remaining_ticks, -ENOTSUP);
> +
> +   RTE_ASSERT(ticks_remaining != NULL);

No ASSERT in library implementation. Return -ENIVAL

> +
> +   return adapter->ops->get_remaining_ticks(adapter, evtim,
> +ticks_remaining);
> +}
> +
>  /*
>   * Software event timer adapter buffer helper functions
>   */
> @@ -1072,6 +1088,41 @@ swtim_stats_reset(const struct rte_event_timer_adapter 
> *adapter)
> return 0;
>  }
>
> +static int
> +swtim_get_remaining_ticks(const struct rte_event_timer_adapter *adapter,
> + const struct rte_event_timer *evtim,
> + uint64_t *ticks_remaining)
> +{
> +   uint64_t nsecs_per_adapter_tick, opaque, cycles_remaining;
> +   enum rte_event_timer_state n_state;
> +   double nsecs_per_cycle;
> +   struct rte_timer *tim;
> +   uint64_t cur_cycles;
> +
> +   /* Check that timer is armed */
> +   n_state = __atomic_load_n(&evtim->state, __ATOMIC_ACQUIRE);
> +   if (n_state != RTE_EVENT_TIMER_ARMED)
> +   return -EINVAL;
> +
> +   opaque = evtim->impl_opaque[0];
> +   tim = (struct rte_timer *)(uintptr_t)opaque;
> +
> +   cur_cycles = rte_get_timer_cycles();
> +   if (cur_cycles > tim->expire) {
> +   *ticks_remaining = 0;
> +   return 0;
> +   }
> +
> +   cycles_remaining = tim->expire - cur_cycles;
> +   nsecs_per_cycle = (double)NSECPERSEC / rte_get_timer_hz();
> +   nsecs_per_adapter_tick = adapter->data->conf.timer_tick_ns;
> +
> +   *ticks_remaining = (uint64_t)ceil((cycles_remaining * 
> nsecs_per_cycle) /
> + nsecs_per_adapter_tick);

Can RTE_*CEIL* in eal/include/rte_common.h" API helps here? Also, it
will remove the need for math.h, and it will be more optimized.


> +
> +   return 0;
> +}
> +
>  static uint16_t
>  __swtim_arm_burst(const struct rte_event_timer_adapter *adapter,
> struct rte_event_timer **evtims,
> @@ -1286,6 +1337,7 @@ static const struct event_timer_adapter_ops swtim_ops = 
> {
> .arm_burst = swtim_arm_burst,
> .arm_tmo_tick_burst = swtim_arm_tmo_tick_burst,
> .cancel_burst = swtim_cancel_burst,
> +   .get_remaining_ticks = swtim_get_remaining_ticks,
>  };
>
>  static int
> diff --git a/lib/eventdev/rte_event_timer_adapter.h 
> b/lib/eventdev/rte_event_timer_adapter.h
> index cd10db19e4..1e43c09612 100644
> --- a/lib/eventdev/rte_event_timer_adapter.h
> +++ b/lib/eventdev/rte_event_timer_adapter.h
> @@ -678,6 +678,33 @@ rte_event_timer_cancel_burst(const struct 
> rte_event_timer_adapter *adapter,
> return adapter->cancel_burst(adapter, evtims, nb_evtims);
>  }
>
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this API may change without prior notice
> + *
> + * Get the number of ticks remaining until an event timer fires.

fire vs expiry ? If it makes sense then use expiry

> + *
> + * @param adapter
> + *   A pointer to an event timer adapter structure
> + * @param evtim
> + *   A pointer to an rte_event_timer structure
> + * @param[out] ticks_remaining
> + *   Pointer to variable into which to write the number of ticks remaining
> + *   until the event timer fires

Same above comment

> + *
> + * @return
> + *   - 0: Success
> + *   - -EINVAL Invalid timer adapter identifier or the event timer is not in
> + *   the armed state

OR ticks_remaining is NULL

> + *   - -ENOTSUP The timer adapter implementation does not support this API.
> + */
> +__rte_experimental
> +int
> +rte_event_timer_get_remaining_ticks(
> +   const struct rte_event_timer_adapter *adapter,
> +   const struct rte_event_timer *evtim,
> +   uint64_t *ticks_remaining);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eventdev/version.map b/lib/eventdev/version.map
> in

Re: RFC abstracting atomics

2023-01-13 Thread Ben Magistro
As a user/developer I'll put a vote on Morten's side here.  There are other
libraries we utilize that have stated x.y.z is the last version that will
support w, beginning on version l.m.n it will be standard o.  I personally
don't think a project asking for C11 support at a minimum would be
unreasonable or overly burdensome.

In that vein I thought there was a supported operating systems page (can't
find it for 22.11 but did find it for an older version, 17.05).  On more
recent versions, there is the tested platforms page.  Going back to the
oldest LTS, 20.11 (and current 22.11 which includes some older OS not on
the 20.11 list), I would be shocked if any of the listed operating systems
didn't support C11 out of the box.

Just my $0.01

On Wed, Jan 11, 2023 at 10:07 AM Morten Brørup 
wrote:

> > From: Bruce Richardson [mailto:bruce.richard...@intel.com]
> > Sent: Wednesday, 11 January 2023 15.18
> >
> > On Wed, Jan 11, 2023 at 01:46:02PM +0100, Morten Brørup wrote:
> > > > From: Bruce Richardson [mailto:bruce.richard...@intel.com]
> > > > Sent: Wednesday, 11 January 2023 12.57
> > > >
> > > > On Wed, Jan 11, 2023 at 11:23:07AM +0100, Morten Brørup wrote:
> > > > > > From: Bruce Richardson [mailto:bruce.richard...@intel.com]
> > > > > > Sent: Wednesday, 11 January 2023 11.10
> > > > > >
> > > > > > One additional point that just became clear to me when I
> > started
> > > > > > thinking
> > > > > > about upping our DPDK C-standard-baseline. We need to be
> > careful
> > > > what
> > > > > > we
> > > > > > are considering when we up our C baseline. We can mandate a
> > > > specific
> > > > > > compiler minimum and C version for compiling up DPDK itself,
> > but I
> > > > > > think we
> > > > > > should not mandate that for the end applications.
> > > > >
> > > > > Why not?
> > > > >
> > > > > And do you consider this backwards compatibility a build time or
> > run
> > > > time requirement?
> > > > >
> > > > > >
> > > > > > That means that our header files, such as atomics, should not
> > > > require
> > > > > > C99
> > > > > > or C11 even if the build of DPDK itself does. More
> > specifically,
> > > > even
> > > > > > if we
> > > > > > bump DPDK minimum to C11, we should still allow apps to build
> > using
> > > > > > older
> > > > > > compiler settings.
> > > > > >
> > > > > > Therefore, we probably need to maintain non-C11 atomics code
> > paths
> > > > in
> > > > > > headers beyond the point at which DPDK itself uses C11 as a
> > code
> > > > > > baseline.
> > > > >
> > > > > Am I misunderstanding your suggestion here: Code can be C11, but
> > all
> > > > APIs and header files must be C89?
> > > > >
> > > > > Wouldn't that also prevent DPDK inline functions from being C11?
> > > > >
> > > > Yes, it would.
> > > >
> > > > Now, perhaps we don't need to ensure that our headers have strict
> > C89
> > > > compatibility, but I think we need to be very careful about
> > mandating
> > > > that
> > > > end-user apps use particular c standard settings when compiling
> > their
> > > > own
> > > > code.
> > >
> > > I get your point, Bruce, but I disagree.
> > >
> > > There should be a limit for how backwards compatible we want DPDK to
> > be, and the limit should certainly not be C89. It might be C99 for a
> > while, but it should soon be C11.
> > >
> > > If someone is stuck with a very old C compiler, and already rely on
> > (extended) LTS for their compiler and runtime environment, why would
> > they expect bleeding edge DPDK to cater for them? They can use some old
> > DPDK version and rely on DPDK LTS.
> > >
> > > If you want to use an old compiler, you often have to use old
> > libraries too, as new libraries often require newer compilers. This
> > also applies to the Linux kernel. I don't see why DPDK should be any
> > different.
> > >
> > > But... DPDK LTS is only two years!?! My point is: What you are
> > describing is not a DPDK problem, it is a DPDK LTS policy problem.
> > >
> >
> > I don't see it as a compiler problem, but as a codebase one. It doesn't
> > matter if your compiler supports C11 if your codebase is using legacy
> > features from C89 that are no longer supported by later versions.
> > Changing
> > compilers can be tricky, but updating a large legacy code-base is a
> > much
> > more challenging proposition. There is a lot of old code out there in
> > the
> > world!
>
> OK. But my same argument applies: Why would you need to use a brand new
> DPDK release in your project when the rest of your code base is ancient? In
> that case, you should rely on DPDK LTS.
>
> >
> > That said, I would hope that there are few large codebases out there
> > that
> > won't compile with a C99 or C11 standard language level, and there
> > aren't
> > that many things that should cause problems. However, I don't really
> > know for
> > sure, so urge caution.
> >
> > /Bruce
>
>


Marvell DPDK v23.03 Roadmap

2023-01-13 Thread Jerin Jacob Kollanukkaran
Marvell DPDK v23.03 Roadmap for non-driver changes
~~

1) New device class:


a) Machine learning inference device library
http://patches.dpdk.org/project/dpdk/patch/20221114120238.2143832-2-jer...@marvell.com/

b)Test application to verify the mldev APIs
https://patches.dpdk.org/project/dpdk/patch/20221208192918.25022-1-syalavar...@marvell.com/


2) New library(libpdcp)
===

a) Add lib/pdcp library to enable PDCP protocol support similar to lib/ipsec/ 
library for enabling IPsec protocol support.
http://patches.dpdk.org/project/dpdk/list/?series=26246


3) EAL
==

a) Enable PMU counter for self monitoring/profiling via trace and non trace 
infrastructure
https://patches.dpdk.org/project/dpdk/patch/20230110234642.1188550-2-tduszyn...@marvell.com/


b)Add vfio-platform bus
https://patches.dpdk.org/project/dpdk/list/?series=26249


4) ethdev:
==

a) add trace points
https://patches.dpdk.org/project/dpdk/list/?series=26505


5) eventdev:


a) add trace points
http://patches.dpdk.org/project/dpdk/patch/20221219141114.1687608-1-amitpraka...@marvell.com/


6) Crypto
==

a) Support for SHAKE algorithm in rte_cryptodev
http://patches.dpdk.org/project/dpdk/list/?series=26503

b) Crypto cross verification test suite to compare crypto results generated 
from two different drivers
http://patches.dpdk.org/project/dpdk/list/?series=26226

c) cryptodev: introduce query API for error interrupt event
https://patches.dpdk.org/project/dpdk/patch/20221221132142.2732040-3-scha...@marvell.com/


7) Graph 


a) pcap capture support
https://patches.dpdk.org/project/dpdk/patch/20230112100106.2180665-1-amitpraka...@marvell.com/


8)reorder library
=

a) Bug fixes
http://patches.dpdk.org/project/dpdk/list/?series=26425

b) Add a new API for allowing applications to drain re-order buffers to a 
specified sequence number.


9) Test and example applications

a) Crypto producer enhancements in test-eventdev
http://patches.dpdk.org/project/dpdk/list/?series=25982
http://patches.dpdk.org/project/dpdk/list/?series=25983

b) ECDSA, SHA3 & SHAKE support in FIPS validation app

c) Support non-NULL crypto algorithms with test-eventdev perf application

d) test/security: add inline MACsec cases
http://patches.dpdk.org/project/dpdk/patch/20220928124516.93050-5-gak...@marvell.com/

e) test: add reassembly perf test
https://patchwork.dpdk.org/project/dpdk/patch/20211004142305.14924-1-pbhagavat...@marvell.com/


Re: RFC abstracting atomics

2023-01-13 Thread Jerin Jacob
On Fri, Jan 13, 2023 at 7:49 PM Ben Magistro  wrote:
>
> As a user/developer I'll put a vote on Morten's side here.  There are other 
> libraries we utilize that have stated x.y.z is the last version that will 
> support w, beginning on version l.m.n it will be standard o.  I personally 
> don't think a project asking for C11 support at a minimum would be 
> unreasonable or overly burdensome.

+1


Instead of polluting new DPDK code for legacy applications(If some
reason they want absolutely want to move latest and greatest DPDK), I
think it should be possible for legacy application selectivity turning
on/of like "#pragma GCC diagnostic warning "-std=c++11"
 or worst case  move DPDK function in wrapper(which is already case in
most of the applications) in their app and compile the wrapper only
with C11


>
> In that vein I thought there was a supported operating systems page (can't 
> find it for 22.11 but did find it for an older version, 17.05).  On more 
> recent versions, there is the tested platforms page.  Going back to the 
> oldest LTS, 20.11 (and current 22.11 which includes some older OS not on the 
> 20.11 list), I would be shocked if any of the listed operating systems didn't 
> support C11 out of the box.
>
> Just my $0.01
>
> On Wed, Jan 11, 2023 at 10:07 AM Morten Brørup  
> wrote:
>>
>> > From: Bruce Richardson [mailto:bruce.richard...@intel.com]
>> > Sent: Wednesday, 11 January 2023 15.18
>> >
>> > On Wed, Jan 11, 2023 at 01:46:02PM +0100, Morten Brørup wrote:
>> > > > From: Bruce Richardson [mailto:bruce.richard...@intel.com]
>> > > > Sent: Wednesday, 11 January 2023 12.57
>> > > >
>> > > > On Wed, Jan 11, 2023 at 11:23:07AM +0100, Morten Brørup wrote:
>> > > > > > From: Bruce Richardson [mailto:bruce.richard...@intel.com]
>> > > > > > Sent: Wednesday, 11 January 2023 11.10
>> > > > > >
>> > > > > > One additional point that just became clear to me when I
>> > started
>> > > > > > thinking
>> > > > > > about upping our DPDK C-standard-baseline. We need to be
>> > careful
>> > > > what
>> > > > > > we
>> > > > > > are considering when we up our C baseline. We can mandate a
>> > > > specific
>> > > > > > compiler minimum and C version for compiling up DPDK itself,
>> > but I
>> > > > > > think we
>> > > > > > should not mandate that for the end applications.
>> > > > >
>> > > > > Why not?
>> > > > >
>> > > > > And do you consider this backwards compatibility a build time or
>> > run
>> > > > time requirement?
>> > > > >
>> > > > > >
>> > > > > > That means that our header files, such as atomics, should not
>> > > > require
>> > > > > > C99
>> > > > > > or C11 even if the build of DPDK itself does. More
>> > specifically,
>> > > > even
>> > > > > > if we
>> > > > > > bump DPDK minimum to C11, we should still allow apps to build
>> > using
>> > > > > > older
>> > > > > > compiler settings.
>> > > > > >
>> > > > > > Therefore, we probably need to maintain non-C11 atomics code
>> > paths
>> > > > in
>> > > > > > headers beyond the point at which DPDK itself uses C11 as a
>> > code
>> > > > > > baseline.
>> > > > >
>> > > > > Am I misunderstanding your suggestion here: Code can be C11, but
>> > all
>> > > > APIs and header files must be C89?
>> > > > >
>> > > > > Wouldn't that also prevent DPDK inline functions from being C11?
>> > > > >
>> > > > Yes, it would.
>> > > >
>> > > > Now, perhaps we don't need to ensure that our headers have strict
>> > C89
>> > > > compatibility, but I think we need to be very careful about
>> > mandating
>> > > > that
>> > > > end-user apps use particular c standard settings when compiling
>> > their
>> > > > own
>> > > > code.
>> > >
>> > > I get your point, Bruce, but I disagree.
>> > >
>> > > There should be a limit for how backwards compatible we want DPDK to
>> > be, and the limit should certainly not be C89. It might be C99 for a
>> > while, but it should soon be C11.
>> > >
>> > > If someone is stuck with a very old C compiler, and already rely on
>> > (extended) LTS for their compiler and runtime environment, why would
>> > they expect bleeding edge DPDK to cater for them? They can use some old
>> > DPDK version and rely on DPDK LTS.
>> > >
>> > > If you want to use an old compiler, you often have to use old
>> > libraries too, as new libraries often require newer compilers. This
>> > also applies to the Linux kernel. I don't see why DPDK should be any
>> > different.
>> > >
>> > > But... DPDK LTS is only two years!?! My point is: What you are
>> > describing is not a DPDK problem, it is a DPDK LTS policy problem.
>> > >
>> >
>> > I don't see it as a compiler problem, but as a codebase one. It doesn't
>> > matter if your compiler supports C11 if your codebase is using legacy
>> > features from C89 that are no longer supported by later versions.
>> > Changing
>> > compilers can be tricky, but updating a large legacy code-base is a
>> > much
>> > more challenging proposition. There is a lot of old code out there in
>> > the
>> > world!
>>
>> OK. But my same a

[RFC PATCH v2 0/3] Split logging functionality out of EAL

2023-01-13 Thread Bruce Richardson
There seems to be a general desire to reduce the size and scope of
EAL. To this end, this patchset makes a (very) small step in that
direction by taking the logging functionality out of EAL and putting
it into its own library that can be built and maintained separately.

As with the previous RFC for this, the main obstacle is the "fnmatch"
function which is needed by both EAL and the new log function when
building on windows. While the function cannot stay in EAL - or we
would have a circular dependency, moving it to a new library or just
putting it in the log library have the disadvantages that it then
"leaks" into the public namespace without an rte_prefix, which could
cause issues. Since only a single function is involved, this v2 RFC
takes a different approach to v1, and just moves the offending function
to be a static function in a header file. This allows use by multiple
libs without conflicting names or making it public.

The other complication, as explained in v1 RFC was that of multiple
implementations for different OS's. This is solved here in the same
way as v1, by including the OS in the name and having meson pick the
correct file for each build. Since only one file is involved, there
seemed little need for replicating EAL's separate subdirectories
per-OS.

Bruce Richardson (3):
  eal/windows: move fnmatch function to header file
  log: separate logging functions out of EAL
  telemetry: use standard logging

 lib/eal/common/eal_private.h  |   7 -
 lib/eal/common/meson.build|   1 -
 lib/eal/freebsd/eal.c |   6 +-
 lib/eal/include/meson.build   |   1 -
 lib/eal/linux/eal.c   |   6 +-
 lib/eal/linux/meson.build |   1 -
 lib/eal/meson.build   |   2 +-
 lib/eal/version.map   |  17 --
 lib/eal/windows/fnmatch.c | 172 -
 lib/eal/windows/include/fnmatch.h | 175 --
 lib/eal/windows/meson.build   |   2 -
 lib/kvargs/meson.build|   3 +-
 lib/{eal/common => log}/eal_common_log.c  |   1 -
 lib/{eal/common => log}/eal_log.h |  12 ++
 .../linux/eal_log.c => log/eal_log_linux.c}   |   0
 .../eal_log.c => log/eal_log_windows.c}   |   0
 lib/log/meson.build   |   9 +
 lib/{eal/include => log}/rte_log.h|   0
 lib/log/version.map   |  34 
 lib/meson.build   |   1 +
 lib/telemetry/meson.build |   3 +-
 lib/telemetry/telemetry.c |  12 +-
 lib/telemetry/telemetry_internal.h|   3 +-
 23 files changed, 229 insertions(+), 239 deletions(-)
 delete mode 100644 lib/eal/windows/fnmatch.c
 rename lib/{eal/common => log}/eal_common_log.c (99%)
 rename lib/{eal/common => log}/eal_log.h (78%)
 rename lib/{eal/linux/eal_log.c => log/eal_log_linux.c} (100%)
 rename lib/{eal/windows/eal_log.c => log/eal_log_windows.c} (100%)
 create mode 100644 lib/log/meson.build
 rename lib/{eal/include => log}/rte_log.h (100%)
 create mode 100644 lib/log/version.map

--
2.34.1



[RFC PATCH v2 1/3] eal/windows: move fnmatch function to header file

2023-01-13 Thread Bruce Richardson
To allow the fnmatch function to be shared between libraries, without
having to export it into the public namespace (since it's not prefixed
with "rte"), we can convert fnmatch.c to replace fnmatch.h. This allows
fnmatch function to be static and limited in scope to the current file,
preventing duplicate definitions if it is used by two libraries, while
also not requiring export for sharing.

Signed-off-by: Bruce Richardson 
---
 lib/eal/windows/fnmatch.c | 172 -
 lib/eal/windows/include/fnmatch.h | 175 +++---
 lib/eal/windows/meson.build   |   1 -
 3 files changed, 162 insertions(+), 186 deletions(-)
 delete mode 100644 lib/eal/windows/fnmatch.c

diff --git a/lib/eal/windows/fnmatch.c b/lib/eal/windows/fnmatch.c
deleted file mode 100644
index f622bf54c5..00
--- a/lib/eal/windows/fnmatch.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)fnmatch.c8.2 (Berkeley) 4/16/94";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
- * Compares a filename or pathname to a pattern.
- */
-
-#include 
-#include 
-#include 
-
-#include "fnmatch.h"
-
-#define EOS'\0'
-
-static const char *rangematch(const char *, char, int);
-
-int
-fnmatch(const char *pattern, const char *string, int flags)
-{
-   const char *stringstart;
-   char c, test;
-
-   for (stringstart = string;;)
-   switch (c = *pattern++) {
-   case EOS:
-   if ((flags & FNM_LEADING_DIR) && *string == '/')
-   return (0);
-   return (*string == EOS ? 0 : FNM_NOMATCH);
-   case '?':
-   if (*string == EOS)
-   return (FNM_NOMATCH);
-   if (*string == '/' && (flags & FNM_PATHNAME))
-   return (FNM_NOMATCH);
-   if (*string == '.' && (flags & FNM_PERIOD) &&
-   (string == stringstart ||
-   ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
-   return (FNM_NOMATCH);
-   ++string;
-   break;
-   case '*':
-   c = *pattern;
-   /* Collapse multiple stars. */
-   while (c == '*')
-   c = *++pattern;
-
-   if (*string == '.' && (flags & FNM_PERIOD) &&
-   (string == stringstart ||
-   ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
-   return (FNM_NOMATCH);
-
-   /* Optimize for pattern with * at end or before /. */
-   if (c == EOS)
-   if (flags & FNM_PATHNAME)
-   return ((flags & FNM_LEADING_DIR) ||
-   strchr(string, '/') == NULL ?
-   0 : FNM_NOMATCH);
-   else
-   return (0);
-   else if (c == '/' && flags & FNM_PATHNAME) {
-   string = strchr(string, '/');
-   if (string == NULL)
-   return (FNM_NOMATCH);
-   break;
-   }
-
-   /* General case, use recursion. */
-   while ((test = *string) != EOS) {
-   if (!fnmatch(pattern, string,
-   flags & ~FNM_PERIOD))
-   return (0);
-   if (test == '/' && flags & FNM_PATHNAME)
-   break;
-   ++string;
-   }
-   return (FNM_NOMATCH);
-   case '[':
-   if (*string == EOS)
-   return (FNM_NOMATCH);
-   if (*string == '/' && flags & FNM_PATHNAME)
-   return (FNM_NOMATCH);
-   pattern = rangematch(pattern, *string, flags);
-   if (pattern == NULL)
-   return (FNM_NOMATCH);
-   ++string;
-   break;
-   case '\\':
-   if (!(flags & FNM_NOESCAPE)) {
-   c = *pattern++;
-   if (

[RFC PATCH v2 2/3] log: separate logging functions out of EAL

2023-01-13 Thread Bruce Richardson
Move the logging capability to a separate library, free from EAL.

Signed-off-by: Bruce Richardson 
---
 lib/eal/common/eal_private.h  |  7 
 lib/eal/common/meson.build|  1 -
 lib/eal/include/meson.build   |  1 -
 lib/eal/linux/meson.build |  1 -
 lib/eal/meson.build   |  2 +-
 lib/eal/version.map   | 17 --
 lib/eal/windows/meson.build   |  1 -
 lib/kvargs/meson.build|  3 +-
 lib/{eal/common => log}/eal_common_log.c  |  1 -
 lib/{eal/common => log}/eal_log.h | 12 +++
 .../linux/eal_log.c => log/eal_log_linux.c}   |  0
 .../eal_log.c => log/eal_log_windows.c}   |  0
 lib/log/meson.build   |  9 +
 lib/{eal/include => log}/rte_log.h|  0
 lib/log/version.map   | 34 +++
 lib/meson.build   |  1 +
 lib/telemetry/meson.build |  3 +-
 17 files changed, 59 insertions(+), 34 deletions(-)
 rename lib/{eal/common => log}/eal_common_log.c (99%)
 rename lib/{eal/common => log}/eal_log.h (78%)
 rename lib/{eal/linux/eal_log.c => log/eal_log_linux.c} (100%)
 rename lib/{eal/windows/eal_log.c => log/eal_log_windows.c} (100%)
 create mode 100644 lib/log/meson.build
 rename lib/{eal/include => log}/rte_log.h (100%)
 create mode 100644 lib/log/version.map

diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 0f4d75bb89..dbf60190f4 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -152,13 +152,6 @@ int rte_eal_tailqs_init(void);
  */
 int rte_eal_intr_init(void);
 
-/**
- * Close the default log stream
- *
- * This function is private to EAL.
- */
-void rte_eal_log_cleanup(void);
-
 /**
  * Init alarm mechanism. This is to allow a callback be called after
  * specific time.
diff --git a/lib/eal/common/meson.build b/lib/eal/common/meson.build
index 917758cc65..22a626ba6f 100644
--- a/lib/eal/common/meson.build
+++ b/lib/eal/common/meson.build
@@ -18,7 +18,6 @@ sources += files(
 'eal_common_interrupts.c',
 'eal_common_launch.c',
 'eal_common_lcore.c',
-'eal_common_log.c',
 'eal_common_mcfg.c',
 'eal_common_memalloc.c',
 'eal_common_memory.c',
diff --git a/lib/eal/include/meson.build b/lib/eal/include/meson.build
index cfcd40aaed..1eaa074d1b 100644
--- a/lib/eal/include/meson.build
+++ b/lib/eal/include/meson.build
@@ -27,7 +27,6 @@ headers += files(
 'rte_keepalive.h',
 'rte_launch.h',
 'rte_lcore.h',
-'rte_log.h',
 'rte_malloc.h',
 'rte_mcslock.h',
 'rte_memory.h',
diff --git a/lib/eal/linux/meson.build b/lib/eal/linux/meson.build
index 3cccfa36c0..1b913acc06 100644
--- a/lib/eal/linux/meson.build
+++ b/lib/eal/linux/meson.build
@@ -11,7 +11,6 @@ sources += files(
 'eal_hugepage_info.c',
 'eal_interrupts.c',
 'eal_lcore.c',
-'eal_log.c',
 'eal_memalloc.c',
 'eal_memory.c',
 'eal_thread.c',
diff --git a/lib/eal/meson.build b/lib/eal/meson.build
index 056beb9461..af8c4eae4a 100644
--- a/lib/eal/meson.build
+++ b/lib/eal/meson.build
@@ -22,7 +22,7 @@ subdir(exec_env)
 
 subdir(arch_subdir)
 
-deps += ['kvargs']
+deps += ['log', 'kvargs']
 if not is_windows
 deps += ['telemetry']
 endif
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 7ad12a7dc9..3fb11a16b2 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -140,21 +140,6 @@ DPDK_23 {
rte_lcore_iterate;
rte_lcore_to_cpu_id;
rte_lcore_to_socket_id;
-   rte_log;
-   rte_log_can_log;
-   rte_log_cur_msg_loglevel;
-   rte_log_cur_msg_logtype;
-   rte_log_dump;
-   rte_log_get_global_level;
-   rte_log_get_level;
-   rte_log_get_stream;
-   rte_log_list_types;
-   rte_log_register;
-   rte_log_register_type_and_pick_level;
-   rte_log_set_global_level;
-   rte_log_set_level;
-   rte_log_set_level_pattern;
-   rte_log_set_level_regexp;
rte_malloc;
rte_malloc_dump_heaps;
rte_malloc_dump_stats;
@@ -225,7 +210,6 @@ DPDK_23 {
rte_mp_request_async;
rte_mp_request_sync;
rte_mp_sendmsg;
-   rte_openlog_stream;
rte_rand;
rte_rand_max;
rte_realloc;
@@ -299,7 +283,6 @@ DPDK_23 {
rte_vfio_noiommu_is_enabled; # WINDOWS_NO_EXPORT
rte_vfio_release_device; # WINDOWS_NO_EXPORT
rte_vfio_setup_device; # WINDOWS_NO_EXPORT
-   rte_vlog;
rte_zmalloc;
rte_zmalloc_socket;
 
diff --git a/lib/eal/windows/meson.build b/lib/eal/windows/meson.build
index e4b2427610..7756d417be 100644
--- a/lib/eal/windows/meson.build
+++ b/lib/eal/windows/meson.build
@@ -12,7 +12,6 @@ sources += files(
 'eal_hugepages.c',
 'eal_interrupts.c',
 

[RFC PATCH v2 3/3] telemetry: use standard logging

2023-01-13 Thread Bruce Richardson
Now that logging is moved out of EAL, we don't need injection of the
logtype and logging function from EAL to telemetry library, simplifying
things.

Signed-off-by: Bruce Richardson 
---
 lib/eal/freebsd/eal.c  |  6 +-
 lib/eal/linux/eal.c|  6 +-
 lib/telemetry/telemetry.c  | 12 +---
 lib/telemetry/telemetry_internal.h |  3 +--
 4 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 607684c1a3..820c4524e5 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -871,13 +871,9 @@ rte_eal_init(int argc, char **argv)
return -1;
}
if (rte_eal_process_type() == RTE_PROC_PRIMARY && 
!internal_conf->no_telemetry) {
-   int tlog = rte_log_register_type_and_pick_level(
-   "lib.telemetry", RTE_LOG_WARNING);
-   if (tlog < 0)
-   tlog = RTE_LOGTYPE_EAL;
if (rte_telemetry_init(rte_eal_get_runtime_dir(),
rte_version(),
-   &internal_conf->ctrl_cpuset, rte_log, tlog) != 
0)
+   &internal_conf->ctrl_cpuset) != 0)
return -1;
}
 
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 8c118d0d9f..56ebca302e 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1319,13 +1319,9 @@ rte_eal_init(int argc, char **argv)
return -1;
}
if (rte_eal_process_type() == RTE_PROC_PRIMARY && 
!internal_conf->no_telemetry) {
-   int tlog = rte_log_register_type_and_pick_level(
-   "lib.telemetry", RTE_LOG_WARNING);
-   if (tlog < 0)
-   tlog = RTE_LOGTYPE_EAL;
if (rte_telemetry_init(rte_eal_get_runtime_dir(),
rte_version(),
-   &internal_conf->ctrl_cpuset, rte_log, tlog) != 
0)
+   &internal_conf->ctrl_cpuset) != 0)
return -1;
}
 
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 8fbb4f3060..46afc5c4ac 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -54,11 +54,10 @@ static struct socket v1_socket; /* socket for v1 telemetry 
*/
 static const char *telemetry_version; /* save rte_version */
 static const char *socket_dir;/* runtime directory */
 static rte_cpuset_t *thread_cpuset;
-static rte_log_fn rte_log_ptr;
-static uint32_t logtype;
+extern int logtype;
 
 #define TMTY_LOG(l, ...) \
-rte_log_ptr(RTE_LOG_ ## l, logtype, "TELEMETRY: " __VA_ARGS__)
+rte_log(RTE_LOG_ ## l, logtype, "TELEMETRY: " __VA_ARGS__)
 
 /* list of command callbacks, with one command registered by default */
 static struct cmd_callback *callbacks;
@@ -612,14 +611,11 @@ telemetry_v2_init(void)
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
 int32_t
-rte_telemetry_init(const char *runtime_dir, const char *rte_version, 
rte_cpuset_t *cpuset,
-   rte_log_fn log_fn, uint32_t registered_logtype)
+rte_telemetry_init(const char *runtime_dir, const char *rte_version, 
rte_cpuset_t *cpuset)
 {
telemetry_version = rte_version;
socket_dir = runtime_dir;
thread_cpuset = cpuset;
-   rte_log_ptr = log_fn;
-   logtype = registered_logtype;
 
 #ifndef RTE_EXEC_ENV_WINDOWS
if (telemetry_v2_init() != 0)
@@ -630,3 +626,5 @@ rte_telemetry_init(const char *runtime_dir, const char 
*rte_version, rte_cpuset_
 
return 0;
 }
+
+RTE_LOG_REGISTER_DEFAULT(logtype, WARNING);
diff --git a/lib/telemetry/telemetry_internal.h 
b/lib/telemetry/telemetry_internal.h
index d085c492dc..5c75d73183 100644
--- a/lib/telemetry/telemetry_internal.h
+++ b/lib/telemetry/telemetry_internal.h
@@ -109,7 +109,6 @@ typedef int (*rte_log_fn)(uint32_t level, uint32_t logtype, 
const char *format,
  */
 __rte_internal
 int
-rte_telemetry_init(const char *runtime_dir, const char *rte_version, 
rte_cpuset_t *cpuset,
-   rte_log_fn log_fn, uint32_t registered_logtype);
+rte_telemetry_init(const char *runtime_dir, const char *rte_version, 
rte_cpuset_t *cpuset);
 
 #endif
-- 
2.34.1



Re: [PATCH] net/vmxnet3: added checks for TCP for RSS Configuration

2023-01-13 Thread Ferruh Yigit
On 12/22/2022 8:24 AM, Raghav Roy wrote:
> Added checks for TCP in vmxnet3_rss_configure()
> This check ensures the hashType for RSS, when enabled
> just for UDP, is not NONE.
> 

Mandatory hash functions for v4 already added in the past:
Commit 52ec00fd1474 ("net/vmxnet3: fix RSS setting on v4")

Now this commit adds it for all versions, why it was fine in the past
but it is needed now?

@Jochen, can you please help reviewing this patch?


> Signed-off-by: Raghav Roy 
> ---
>  drivers/net/vmxnet3/vmxnet3_rxtx.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c 
> b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> index a875ffec07..e8407c9b2e 100644
> --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
> +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> @@ -1412,6 +1412,13 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)
>   dev_rss_conf = hw->rss_conf;
>   port_rss_conf = &dev->data->dev_conf.rx_adv_conf.rss_conf;
>  
> + if ((port_rss_conf->rss_hf & VMXNET3_MANDATORY_V4_RSS) !=
> +VMXNET3_MANDATORY_V4_RSS) {
> + PMD_INIT_LOG(WARNING, "RSS: IPv4/6 TCP is required for vmxnet3 
> RSS, "
> +  "automatically setting it");
> + port_rss_conf->rss_hf |= VMXNET3_MANDATORY_V4_RSS;
> + }
> +

`
#define VMXNET3_MANDATORY_V4_RSS ( \
RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
RTE_ETH_RSS_NONFRAG_IPV6_TCP)
`

Can you please describe why IPv4/6 TCP hash function is required for driver?
And what is the impact, I mean what is the observed behavior without
this patch, if RSS is failing without this change patch needs to be fix
patch and please describe since when RSS is failing.

>   /* loading hashFunc */
>   dev_rss_conf->hashFunc = VMXNET3_RSS_HASH_FUNC_TOEPLITZ;
>   /* loading hashKeySize */
> @@ -1419,6 +1426,7 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)
>   /* loading indTableSize: Must not exceed VMXNET3_RSS_MAX_IND_TABLE_SIZE 
> (128)*/
>   dev_rss_conf->indTableSize = (uint16_t)((MAX_RX_QUEUES(hw)) * 4);
>  
> +
>   if (port_rss_conf->rss_key == NULL) {
>   /* Default hash key */
>   port_rss_conf->rss_key = rss_intel_key;
> @@ -1446,6 +1454,5 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)
>   dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_IPV6;
>   if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_TCP)
>   dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_TCP_IPV6;
> -

Please drop unrelated/unimportant syntax changes.

>   return VMXNET3_SUCCESS;
>  }



RE: [PATCH v3] eventdev/timer: add API to get remaining ticks

2023-01-13 Thread Carrillo, Erik G
Hi Jerin,

Thanks for the review.  One response in-line:

<...snipped...>

> > +static int
> > +swtim_get_remaining_ticks(const struct rte_event_timer_adapter
> *adapter,
> > + const struct rte_event_timer *evtim,
> > + uint64_t *ticks_remaining) {
> > +   uint64_t nsecs_per_adapter_tick, opaque, cycles_remaining;
> > +   enum rte_event_timer_state n_state;
> > +   double nsecs_per_cycle;
> > +   struct rte_timer *tim;
> > +   uint64_t cur_cycles;
> > +
> > +   /* Check that timer is armed */
> > +   n_state = __atomic_load_n(&evtim->state, __ATOMIC_ACQUIRE);
> > +   if (n_state != RTE_EVENT_TIMER_ARMED)
> > +   return -EINVAL;
> > +
> > +   opaque = evtim->impl_opaque[0];
> > +   tim = (struct rte_timer *)(uintptr_t)opaque;
> > +
> > +   cur_cycles = rte_get_timer_cycles();
> > +   if (cur_cycles > tim->expire) {
> > +   *ticks_remaining = 0;
> > +   return 0;
> > +   }
> > +
> > +   cycles_remaining = tim->expire - cur_cycles;
> > +   nsecs_per_cycle = (double)NSECPERSEC / rte_get_timer_hz();
> > +   nsecs_per_adapter_tick = adapter->data->conf.timer_tick_ns;
> > +
> > +   *ticks_remaining = (uint64_t)ceil((cycles_remaining *
> nsecs_per_cycle) /
> > + nsecs_per_adapter_tick);
> 
> Can RTE_*CEIL* in eal/include/rte_common.h" API helps here? Also, it will
> remove the need for math.h, and it will be more optimized.
>
It looks like the RTE_*CEIL* macros are related to alignment, so they don't 
seem to apply here.

I'll make the suggested changes for the remainder of the comments in the next 
version of the patch. 
 
Thanks,
Erik

<...snipped...>


RE: [PATCH v3 0/9] Standardize telemetry int types

2023-01-13 Thread Power, Ciara
Hi Bruce,

> -Original Message-
> From: Bruce Richardson 
> Sent: Thursday 12 January 2023 17:41
> To: dev@dpdk.org
> Cc: Richardson, Bruce 
> Subject: [PATCH v3 0/9] Standardize telemetry int types
> 
> Rather than having 64-bit unsigned types and 32-bit signed types supported
> by the telemetry lib, we should support 64-bit values for both types. On the
> naming side, since both are 64-bit, we should no longer call the unsigned
> value u64 - "uint" is better.
> 
> This patchset implements these changes as far as is possible while still
> keeping API and ABI compatibility.
> 
> * Internal structures and functions are updated to use 64-bit ints
> * Internal functions are renamed from u64 to uint
> * Public enum values are renamed from u64 to uint, and a macro is
>   added to ensure that older code still compiles
> * The public add_*_int functions are changed to take a 64-bit value
>   rather than a 32-bit one. Since this would be an ABI break, we
>   use function versioning to ensure older code still calls into
>   a wrapper function which takes a 32-bit value.
> 
> The patchset also contains a couple of other small cleanups to the telemetry
> code that were seen in passing when making these changes - removing RTE_
> prefix on internal enums, and simplifying the init of the the array of data
> types.
> 
> NOTE: the renaming of the u64 functions to uint is split across 3 patches in
> this set - patches 4,5 and 6. This is to make it easier to review and to avoid
> warnings about new functions not being marked initially as experimental.
> Some/all of these 3 can be combined on merge if so desired.
> 
> V3:
> - fix build issues due to missing a driver code change
> - fix spelling issue flagged by checkpatch
> 
> V2:
> - added additional patches to replace the old function calls within DPDK
>   code, something missed in RFC version
> - added new patch to make the renamed/new functions immediately public
>   allowing us to mark the original named versions as deprecated
> - re-ordered patches within the sit, so the extra cleanup changes come
>   first
> 
> Bruce Richardson (9):
>   telemetry: remove RTE prefix from internal enum values
>   telemetry: make array initialization more robust
>   telemetry: rename unsigned 64-bit enum value to uint
>   telemetry: add uint type as alias for u64
>   global: rename telemetry functions to newer versions
>   telemetry: mark old names of renamed fns as deprecated
>   telemetry: update json functions to use int/uint in names
>   telemetry: make internal int representation 64-bits
>   telemetry: change public API to use 64-bit signed values
> 
>  app/test/test_telemetry_data.c   | 22 ++---
>  app/test/test_telemetry_json.c   |  9 +-
>  doc/guides/rel_notes/deprecation.rst |  5 ++
>  drivers/common/cnxk/roc_platform.h   |  4 +-
>  drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c | 24 ++---
>  drivers/net/cnxk/cnxk_ethdev_telemetry.c |  6 +-
>  examples/ipsec-secgw/ipsec-secgw.c   | 72 +++
>  examples/l3fwd-power/main.c  |  4 +-
>  lib/cryptodev/rte_cryptodev.c|  6 +-
>  lib/dmadev/rte_dmadev.c  |  2 +-
>  lib/eal/common/eal_common_memory.c   | 19 ++--
>  lib/ethdev/rte_ethdev.c  | 12 +--
>  lib/ethdev/sff_telemetry.c   |  2 +-
>  lib/eventdev/rte_event_eth_rx_adapter.c  | 22 ++---
>  lib/eventdev/rte_event_timer_adapter.c   | 38 
>  lib/eventdev/rte_eventdev.c  |  5 +-
>  lib/ipsec/ipsec_telemetry.c  | 33 +++
>  lib/rawdev/rte_rawdev.c  |  4 +-
>  lib/security/rte_security.c  |  8 +-
>  lib/telemetry/meson.build|  1 +
>  lib/telemetry/rte_telemetry.h| 51 +--
>  lib/telemetry/telemetry.c| 56 ++--
>  lib/telemetry/telemetry_data.c   | 95 ++--
>  lib/telemetry/telemetry_data.h   | 24 +++--
>  lib/telemetry/telemetry_json.h   | 16 ++--
>  lib/telemetry/version.map|  9 ++
>  26 files changed, 325 insertions(+), 224 deletions(-)
> 
> --
> 2.37.2

Series-Acked-by: Ciara Power 



RE: [RFC PATCH v2 1/3] eal/windows: move fnmatch function to header file

2023-01-13 Thread Morten Brørup
> From: Bruce Richardson [mailto:bruce.richard...@intel.com]
> Sent: Friday, 13 January 2023 17.20
> 
> To allow the fnmatch function to be shared between libraries, without
> having to export it into the public namespace (since it's not prefixed
> with "rte"), we can convert fnmatch.c to replace fnmatch.h. This allows
> fnmatch function to be static and limited in scope to the current file,
> preventing duplicate definitions if it is used by two libraries, while
> also not requiring export for sharing.
> 
> Signed-off-by: Bruce Richardson 
> ---

[...]

>  #define FNM_CASEFOLD 0x10
>  #define FNM_PREFIX_DIRS 0x20
> 
> +#define EOS  '\0'

Careful about names in header files. Perhaps EOS should also have the FNM_ name 
space prefix to reduce the risk of collision. Or even better: just use '\0' in 
the code instead of defining a special name for it.

> +
> +static const char *rangematch(const char *, char, int);

I don't think rangematch() is a POSIX function, so similar comment here. Prefix 
with fnm_ to reduce risk of collision.

With those fixes...

Series-acked-by: Morten Brørup 



Re: [RFC PATCH v2 1/3] eal/windows: move fnmatch function to header file

2023-01-13 Thread Bruce Richardson
On Fri, Jan 13, 2023 at 05:41:29PM +0100, Morten Brørup wrote:
> > From: Bruce Richardson [mailto:bruce.richard...@intel.com]
> > Sent: Friday, 13 January 2023 17.20
> > 
> > To allow the fnmatch function to be shared between libraries, without
> > having to export it into the public namespace (since it's not prefixed
> > with "rte"), we can convert fnmatch.c to replace fnmatch.h. This allows
> > fnmatch function to be static and limited in scope to the current file,
> > preventing duplicate definitions if it is used by two libraries, while
> > also not requiring export for sharing.
> > 
> > Signed-off-by: Bruce Richardson 
> > ---
> 
> [...]
> 
> >  #define FNM_CASEFOLD 0x10
> >  #define FNM_PREFIX_DIRS 0x20
> > 
> > +#define EOS'\0'
> 
> Careful about names in header files. Perhaps EOS should also have the FNM_ 
> name space prefix to reduce the risk of collision. Or even better: just use 
> '\0' in the code instead of defining a special name for it.
> 
> > +
> > +static const char *rangematch(const char *, char, int);
> 
> I don't think rangematch() is a POSIX function, so similar comment here. 
> Prefix with fnm_ to reduce risk of collision.
> 
> With those fixes...
> 
> Series-acked-by: Morten Brørup 
> 

Sure, I can prefix those.

However, since this is a non-published header, private to the DPDK build,
the only chances of collision come from the DPDK files which include the
header. The objective of making it a header was so that none of this ever
leaks outside of the DPDK libs that use the functions internally. That
said, there is no harm in prefixing either, so I'll do so in any future
version.


Re: [PATCH v2 1/4] eal: add thread set name API operating on rte thread

2023-01-13 Thread Tyler Retzlaff
On Fri, Jan 13, 2023 at 10:06:44AM +0530, Jerin Jacob wrote:
> On Wed, Jan 11, 2023 at 9:39 PM David Marchand
>  wrote:
> >
> > On Wed, Dec 14, 2022 at 5:47 PM Tyler Retzlaff
> >  wrote:
> > > diff --git a/lib/eal/common/eal_common_trace.c 
> > > b/lib/eal/common/eal_common_trace.c
> > > index 5caaac8..89522dc 100644
> > > --- a/lib/eal/common/eal_common_trace.c
> > > +++ b/lib/eal/common/eal_common_trace.c
> > > @@ -356,8 +356,6 @@ rte_trace_mode rte_trace_mode_get(void)
> > > /* Store the thread name */
> > > char *name = header->stream_header.thread_name;
> > > memset(name, 0, __RTE_TRACE_EMIT_STRING_LEN_MAX);
> > > -   rte_thread_getname(pthread_self(), name,
> > > -   __RTE_TRACE_EMIT_STRING_LEN_MAX);
> > >
> > > trace->lcore_meta[count].mem = header;
> > > trace->nb_trace_mem_list++;
> >
> > Note, this belongs to patch 2.
> >
> > I understand we can drop the thread name retrieval helper from public
> > API, but at least for the trace framework it added some info in the
> > traces.
> > Jerin, Sunil, what do you think? Should we keep this helper internally?
> 
> 
> Good catch @David Marchand. Yes, we should be it as internal helper
> API use it here.
> For trace, It will be difficult to make sense without thread name.

is the name what is really valuable here because it will only appear in
traces for linux with a new enough glibc, i.e. freebsd and windows it
will always be empty.

we could just provide the thread id and that is available on all
platforms, i'd like to see consistency for all platforms if possible
here but i'm not pushing too hard since we don't declare our tracing
output to be a compatibility surface.

can we just provide the thread id?

> 
> >
> >
> > --
> > David Marchand
> >


Re: [RFC] Remove Kernel Network Interface (KNI)

2023-01-13 Thread Stephen Hemminger
On Fri, 13 Jan 2023 09:12:16 +0100
Thomas Monjalon  wrote:

> 13/01/2023 06:03, Stephen Hemminger:
> > The Linux special network driver for kernel networking has been
> > a long term problem for DPDK. The performance benefits of KNI
> > are available via virtio-user and XDP, and the simpler kernel
> > interface via TAP is also available.
> > 
> > This driver has required lots of effort to keep up with the
> > kernel API changes. And the overall architecture of the driver
> > is fundamentally insecure and has unfixable locking and data
> > race problems. No developer has been willing to do extensive
> > tests or be the maintainer.
> > 
> > In short, the time has come to do some early spring cleaning
> > and remove KNI from DPDK 23.03.  
> 
> In doc/guides/rel_notes/deprecation.rst it is announced
> to be removed in 23.11. Let's keep this RFC for later :)
> 
> 

For 23.03 could we add a deprecation log message when library is
used and when kernel module is loaded.


Re: RFC abstracting atomics

2023-01-13 Thread Tyler Retzlaff
On Fri, Jan 13, 2023 at 09:40:20PM +0530, Jerin Jacob wrote:
> On Fri, Jan 13, 2023 at 7:49 PM Ben Magistro  wrote:
> >
> > As a user/developer I'll put a vote on Morten's side here.  There are other 
> > libraries we utilize that have stated x.y.z is the last version that will 
> > support w, beginning on version l.m.n it will be standard o.  I personally 
> > don't think a project asking for C11 support at a minimum would be 
> > unreasonable or overly burdensome.
> 
> +1
> 
> 
> Instead of polluting new DPDK code for legacy applications(If some
> reason they want absolutely want to move latest and greatest DPDK), I
> think it should be possible for legacy application selectivity turning
> on/of like "#pragma GCC diagnostic warning "-std=c++11"
>  or worst case  move DPDK function in wrapper(which is already case in
> most of the applications) in their app and compile the wrapper only
> with C11

so just a caution that this mail thread isn't proposing any bump in C
standard requirement, it's about introducing an atomics abstraction
though it's really easy to start talking about standard C i understand.

let's move discussion about dpdk minimum standard C to the thread Bruce
posted yesterday to avoid distraction about atomics abstraction
integration.

Bruce's thread addressing setting the minimum standard is here.
http://mails.dpdk.org/archives/dev/2023-January/258925.html

thanks!



Re: [RFC PATCH v2 1/3] eal/windows: move fnmatch function to header file

2023-01-13 Thread Tyler Retzlaff
On Fri, Jan 13, 2023 at 05:01:20PM +, Bruce Richardson wrote:
> On Fri, Jan 13, 2023 at 05:41:29PM +0100, Morten Brørup wrote:
> > > From: Bruce Richardson [mailto:bruce.richard...@intel.com]
> > > Sent: Friday, 13 January 2023 17.20
> > > 
> > > To allow the fnmatch function to be shared between libraries, without
> > > having to export it into the public namespace (since it's not prefixed
> > > with "rte"), we can convert fnmatch.c to replace fnmatch.h. This allows
> > > fnmatch function to be static and limited in scope to the current file,
> > > preventing duplicate definitions if it is used by two libraries, while
> > > also not requiring export for sharing.
> > > 
> > > Signed-off-by: Bruce Richardson 
> > > ---
> > 
> > [...]
> > 
> > >  #define FNM_CASEFOLD 0x10
> > >  #define FNM_PREFIX_DIRS 0x20
> > > 
> > > +#define EOS  '\0'
> > 
> > Careful about names in header files. Perhaps EOS should also have the FNM_ 
> > name space prefix to reduce the risk of collision. Or even better: just use 
> > '\0' in the code instead of defining a special name for it.
> > 
> > > +
> > > +static const char *rangematch(const char *, char, int);
> > 
> > I don't think rangematch() is a POSIX function, so similar comment here. 
> > Prefix with fnm_ to reduce risk of collision.
> > 
> > With those fixes...
> > 
> > Series-acked-by: Morten Brørup 
> > 
> 
> Sure, I can prefix those.
> 
> However, since this is a non-published header, private to the DPDK build,
> the only chances of collision come from the DPDK files which include the
> header. The objective of making it a header was so that none of this ever
> leaks outside of the DPDK libs that use the functions internally. That
> said, there is no harm in prefixing either, so I'll do so in any future
> version.

and if a future collision occurs we should be able to adapt without
compat break. you know for platforms that step on the application
namespace... *cough* legacy windows headers.

thank you for doing this Bruce.

Series-acked-by: Tyler Retzlaff 


Re: [RFC PATCH v2 1/3] eal/windows: move fnmatch function to header file

2023-01-13 Thread Bruce Richardson
On Fri, Jan 13, 2023 at 09:31:26AM -0800, Tyler Retzlaff wrote:
> On Fri, Jan 13, 2023 at 05:01:20PM +, Bruce Richardson wrote:
> > On Fri, Jan 13, 2023 at 05:41:29PM +0100, Morten Brørup wrote:
> > > > From: Bruce Richardson [mailto:bruce.richard...@intel.com]
> > > > Sent: Friday, 13 January 2023 17.20
> > > > 
> > > > To allow the fnmatch function to be shared between libraries, without
> > > > having to export it into the public namespace (since it's not prefixed
> > > > with "rte"), we can convert fnmatch.c to replace fnmatch.h. This allows
> > > > fnmatch function to be static and limited in scope to the current file,
> > > > preventing duplicate definitions if it is used by two libraries, while
> > > > also not requiring export for sharing.
> > > > 
> > > > Signed-off-by: Bruce Richardson 
> > > > ---
> > > 
> > > [...]
> > > 
> > > >  #define FNM_CASEFOLD 0x10
> > > >  #define FNM_PREFIX_DIRS 0x20
> > > > 
> > > > +#define EOS'\0'
> > > 
> > > Careful about names in header files. Perhaps EOS should also have the 
> > > FNM_ name space prefix to reduce the risk of collision. Or even better: 
> > > just use '\0' in the code instead of defining a special name for it.
> > > 
> > > > +
> > > > +static const char *rangematch(const char *, char, int);
> > > 
> > > I don't think rangematch() is a POSIX function, so similar comment here. 
> > > Prefix with fnm_ to reduce risk of collision.
> > > 
> > > With those fixes...
> > > 
> > > Series-acked-by: Morten Brørup 
> > > 
> > 
> > Sure, I can prefix those.
> > 
> > However, since this is a non-published header, private to the DPDK build,
> > the only chances of collision come from the DPDK files which include the
> > header. The objective of making it a header was so that none of this ever
> > leaks outside of the DPDK libs that use the functions internally. That
> > said, there is no harm in prefixing either, so I'll do so in any future
> > version.
> 
> and if a future collision occurs we should be able to adapt without
> compat break. you know for platforms that step on the application
> namespace... *cough* legacy windows headers.
> 
> thank you for doing this Bruce.
> 
> Series-acked-by: Tyler Retzlaff 

Thanks.
Seems there is some support for the changes in this set generally, so I'll
clean it up a little more and send out v3 as a non-RFC version. Main gap I
see right now (having fixed some checkpatch and build issues) is the docs.
:-(


Re: [RFC] Remove Kernel Network Interface (KNI)

2023-01-13 Thread Thomas Monjalon
13/01/2023 18:13, Stephen Hemminger:
> On Fri, 13 Jan 2023 09:12:16 +0100
> Thomas Monjalon  wrote:
> 
> > 13/01/2023 06:03, Stephen Hemminger:
> > > The Linux special network driver for kernel networking has been
> > > a long term problem for DPDK. The performance benefits of KNI
> > > are available via virtio-user and XDP, and the simpler kernel
> > > interface via TAP is also available.
> > > 
> > > This driver has required lots of effort to keep up with the
> > > kernel API changes. And the overall architecture of the driver
> > > is fundamentally insecure and has unfixable locking and data
> > > race problems. No developer has been willing to do extensive
> > > tests or be the maintainer.
> > > 
> > > In short, the time has come to do some early spring cleaning
> > > and remove KNI from DPDK 23.03.  
> > 
> > In doc/guides/rel_notes/deprecation.rst it is announced
> > to be removed in 23.11. Let's keep this RFC for later :)
> > 
> > 
> 
> For 23.03 could we add a deprecation log message when library is
> used and when kernel module is loaded.

We already have a message in the lib:

int
rte_kni_init(unsigned int max_kni_ifaces __rte_unused)
{
RTE_LOG(WARNING, KNI, "WARNING: KNI is deprecated and will be removed 
in DPDK 23.11\n");

It is a good idea to add a message in the kernel module loading.






[PATCH] ipsec: remove unneccessary null check

2023-01-13 Thread Stephen Hemminger
The function rte_ring_free() accepts NULL as vaild input
like free() and other functions.

Found with null_free_check.cocci.

Fixes: 16d6ebb65d59 ("crypto/ipsec_mb: fix null checks")
Cc: kai...@intel.com
Signed-off-by: Stephen Hemminger 
---
 drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c 
b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
index 71e02cd0513d..3e52f9567401 100644
--- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
+++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
@@ -139,15 +139,12 @@ int
 ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 {
struct ipsec_mb_qp *qp = dev->data->queue_pairs[qp_id];
-   struct rte_ring *r = NULL;
 
if (!qp)
return 0;
 
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-   r = rte_ring_lookup(qp->name);
-   if (r)
-   rte_ring_free(r);
+   rte_ring_free(rte_ring_lookup(qp->name));
 
 #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
if (qp->mb_mgr)
-- 
2.39.0



[PATCH v4 0/4] add rte_thread_set_name API for rte_thread_t

2023-01-13 Thread Tyler Retzlaff
Replace the rte_thread_setname API which operates on pthread_t with
rte_thread_set_name that operates on rte_thread_t.

We should try to align tracing output from the EAL for all platforms
but in this case we are retaining an exception for linux as requested
from the community.

v4:
  * retain and move rte_thread_getname function to the
single site of use

v3:
  * fix coding style error
  * move remove of rte_thread_getname to patch #2

v2:
  * initial series provided get/set for lcore thread id, those
additions have been removed as per discussion. including
unit test
  * add a single api rte_thread_set_name does not fail but emits
debug logging if the internal implementation is aware of
in-exact use of the name or failure to set the name
  * adapt mlx5 driver to avoid use of deprecated API


Tyler Retzlaff (4):
  eal: add thread set name API operating on rte thread
  eal: remove thread getname API
  drivers: mlx5 use rte thread set name
  eal: deprecate rte thread setname API

 doc/guides/rel_notes/deprecation.rst |  4 
 drivers/net/mlx5/mlx5_hws_cnt.c  |  3 ++-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c  |  3 +--
 lib/eal/common/eal_common_thread.c   |  9 +++
 lib/eal/common/eal_common_trace.c| 15 +++-
 lib/eal/freebsd/eal.c|  4 +++-
 lib/eal/freebsd/eal_thread.c | 20 +---
 lib/eal/include/rte_lcore.h  | 19 ++-
 lib/eal/include/rte_thread.h | 17 +
 lib/eal/linux/eal.c  |  8 +++
 lib/eal/linux/eal_thread.c   | 29 ++-
 lib/eal/version.map  |  4 +++-
 lib/eal/windows/rte_thread.c | 46 
 13 files changed, 127 insertions(+), 54 deletions(-)

Series-acked-by: Morten Brørup 

-- 
1.8.3.1



[PATCH v4 3/4] drivers: mlx5 use rte thread set name

2023-01-13 Thread Tyler Retzlaff
Use the new internal rte_thread_set_name API instead of the now
deprecated rte_thread_setname API.

Signed-off-by: Tyler Retzlaff 
---
 drivers/net/mlx5/mlx5_hws_cnt.c | 3 ++-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c
index 51704ef..05cc954 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.c
+++ b/drivers/net/mlx5/mlx5_hws_cnt.c
@@ -465,7 +465,8 @@ struct mlx5_hws_cnt_pool *
}
snprintf(name, CNT_THREAD_NAME_MAX - 1, "%s/svc@%d",
 sh->ibdev_name, service_core);
-   rte_thread_setname(sh->cnt_svc->service_thread, name);
+   
rte_thread_set_name((rte_thread_t){(uintptr_t)sh->cnt_svc->service_thread},
+   name);
CPU_SET(service_core, &cpuset);
pthread_setaffinity_np(sh->cnt_svc->service_thread, sizeof(cpuset),
&cpuset);
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c 
b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 4d81976..f3d392c 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -547,8 +547,7 @@
goto out;
}
snprintf(name, sizeof(name), "vDPA-mlx5-%d", priv->vid);
-   if (rte_thread_setname(priv->timer_tid, name) != 0)
-   DRV_LOG(DEBUG, "Cannot set timer thread name.");
+   rte_thread_set_name((rte_thread_t){(uintptr_t)priv->timer_tid}, name);
 out:
if (attrp != NULL)
pthread_attr_destroy(attrp);
-- 
1.8.3.1



[PATCH v4 4/4] eal: deprecate rte thread setname API

2023-01-13 Thread Tyler Retzlaff
Notify deprecation of rte_thread_setname API, it is being removed as it
exposes platform-specific thread details. The functionality it provided
is now implicitly provided via the rte_lcore_set_name API if the
underlying platform supports it.

Signed-off-by: Tyler Retzlaff 
---
 doc/guides/rel_notes/deprecation.rst | 4 
 lib/eal/include/rte_lcore.h  | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index e18ac34..2990bb1 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -126,3 +126,7 @@ Deprecation Notices
   Its removal has been postponed to let potential users report interest
   in maintaining it.
   In the absence of such interest, this library will be removed in DPDK 23.11.
+
+* eal: The function ``rte_thread_setname`` will be removed, continuing
+  the effort to decouple EAL from platform-specific thread
+  implementations.
diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h
index 9c78650..2fb3091 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -13,6 +13,7 @@
  */
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -349,6 +350,7 @@ enum rte_lcore_role_t {
  * @return
  *   On success, return 0; otherwise return a negative value.
  */
+__rte_deprecated
 int rte_thread_setname(pthread_t id, const char *name);
 
 /**
-- 
1.8.3.1



[PATCH v4 2/4] eal: remove thread getname API

2023-01-13 Thread Tyler Retzlaff
Remove the rte_thread_getname API.  The API is __rte_experimental and
requires no deprecation notice.

Fold the platform specific variants into the one place it is used as a
special case to retain the functionality for linux only.

Adjust the function as follows.
* limit use of this very platform glibc specific function to the single
  place it is used.
* change the return type to void since the single use cannot
  meaningfully check for failure given the platform defined behavior.
* change the thread id type to be rte_thread_t.
* rename the function rte_thread_get_name to be consistent with the
  exported rte_thread_set_name.

Signed-off-by: Tyler Retzlaff 
---
 lib/eal/common/eal_common_trace.c | 15 ++-
 lib/eal/freebsd/eal_thread.c  |  9 -
 lib/eal/include/rte_lcore.h   | 17 -
 lib/eal/linux/eal_thread.c| 15 ---
 lib/eal/version.map   |  1 -
 5 files changed, 14 insertions(+), 43 deletions(-)

diff --git a/lib/eal/common/eal_common_trace.c 
b/lib/eal/common/eal_common_trace.c
index 5caaac8..808f9c3 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -298,6 +298,19 @@ rte_trace_mode rte_trace_mode_get(void)
trace_point_dump(f, tp);
 }
 
+static void
+rte_thread_get_name(rte_thread_t id, char *name, size_t len)
+{
+#if defined(RTE_EXEC_ENV_LINUX) && defined(__GLIBC__) && 
defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 12)
+   pthread_getname_np((pthread_t)id.opaque_id, name, len);
+#endif
+#endif
+   RTE_SET_USED(id);
+   RTE_SET_USED(name);
+   RTE_SET_USED(len);
+}
+
 void
 __rte_trace_mem_per_thread_alloc(void)
 {
@@ -356,7 +369,7 @@ rte_trace_mode rte_trace_mode_get(void)
/* Store the thread name */
char *name = header->stream_header.thread_name;
memset(name, 0, __RTE_TRACE_EMIT_STRING_LEN_MAX);
-   rte_thread_getname(pthread_self(), name,
+   rte_thread_get_name(rte_thread_self(), name,
__RTE_TRACE_EMIT_STRING_LEN_MAX);
 
trace->lcore_meta[count].mem = header;
diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c
index b69f5d3..3227d9b 100644
--- a/lib/eal/freebsd/eal_thread.c
+++ b/lib/eal/freebsd/eal_thread.c
@@ -49,12 +49,3 @@ int rte_thread_setname(pthread_t id, const char *name)
pthread_set_name_np(id, name);
return 0;
 }
-
-int rte_thread_getname(pthread_t id, char *name, size_t len)
-{
-   RTE_SET_USED(id);
-   RTE_SET_USED(name);
-   RTE_SET_USED(len);
-
-   return -ENOTSUP;
-}
diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h
index 6938c3f..9c78650 100644
--- a/lib/eal/include/rte_lcore.h
+++ b/lib/eal/include/rte_lcore.h
@@ -352,23 +352,6 @@ enum rte_lcore_role_t {
 int rte_thread_setname(pthread_t id, const char *name);
 
 /**
- * Get thread name.
- *
- * @note It fails with glibc < 2.12.
- *
- * @param id
- *   Thread id.
- * @param name
- *   Thread name to set.
- * @param len
- *   Thread name buffer length.
- * @return
- *   On success, return 0; otherwise return a negative value.
- */
-__rte_experimental
-int rte_thread_getname(pthread_t id, char *name, size_t len);
-
-/**
  * Register current non-EAL thread as a lcore.
  *
  * @note This API is not compatible with the multi-process feature:
diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c
index d5fddab..c07ad9d 100644
--- a/lib/eal/linux/eal_thread.c
+++ b/lib/eal/linux/eal_thread.c
@@ -55,18 +55,3 @@ int rte_thread_setname(pthread_t id, const char *name)
RTE_SET_USED(name);
return -ret;
 }
-
-int rte_thread_getname(pthread_t id, char *name, size_t len)
-{
-   int ret = ENOSYS;
-#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
-#if __GLIBC_PREREQ(2, 12)
-   ret = pthread_getname_np(id, name, len);
-#endif
-#endif
-   RTE_SET_USED(id);
-   RTE_SET_USED(name);
-   RTE_SET_USED(len);
-   return -ret;
-
-}
diff --git a/lib/eal/version.map b/lib/eal/version.map
index c98ba71..6523102 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -369,7 +369,6 @@ EXPERIMENTAL {
__rte_trace_point_register;
per_lcore_trace_mem;
per_lcore_trace_point_sz;
-   rte_thread_getname; # WINDOWS_NO_EXPORT
rte_trace_dump; # WINDOWS_NO_EXPORT
rte_trace_is_enabled; # WINDOWS_NO_EXPORT
rte_trace_metadata_dump; # WINDOWS_NO_EXPORT
-- 
1.8.3.1



[PATCH v4 1/4] eal: add thread set name API operating on rte thread

2023-01-13 Thread Tyler Retzlaff
Add a rte_thread_set_name that sets the name of an rte_thread_t thread.
This is a replacement for the rte_thread_setname(pthread_t, ...) which
exposes platform-specific details.

Signed-off-by: Tyler Retzlaff 
---
 lib/eal/common/eal_common_thread.c |  9 +++-
 lib/eal/freebsd/eal.c  |  4 +++-
 lib/eal/freebsd/eal_thread.c   | 11 +
 lib/eal/include/rte_thread.h   | 17 ++
 lib/eal/linux/eal.c|  8 +++
 lib/eal/linux/eal_thread.c | 22 ++
 lib/eal/version.map|  3 +++
 lib/eal/windows/rte_thread.c   | 46 ++
 8 files changed, 108 insertions(+), 12 deletions(-)

diff --git a/lib/eal/common/eal_common_thread.c 
b/lib/eal/common/eal_common_thread.c
index c5d8b43..a44023c 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -291,12 +291,9 @@ static void *ctrl_thread_init(void *arg)
return -ret;
}
 
-   if (name != NULL) {
-   ret = rte_thread_setname(*thread, name);
-   if (ret < 0)
-   RTE_LOG(DEBUG, EAL,
-   "Cannot set name for ctrl thread\n");
-   }
+   if (name != NULL)
+   rte_thread_set_name((rte_thread_t){(uintptr_t)*thread},
+   name);
 
/* Wait for the control thread to initialize successfully */
while ((ctrl_thread_status =
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 607684c..2a6415e 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -817,7 +817,9 @@ static void rte_eal_init_alert(const char *msg)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"rte-worker-%d", i);
-   rte_thread_setname(lcore_config[i].thread_id, thread_name);
+   rte_thread_set_name(
+   (rte_thread_t){(uintptr_t)lcore_config[i].thread_id},
+   thread_name);
 
ret = pthread_setaffinity_np(lcore_config[i].thread_id,
sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c
index ab81b52..b69f5d3 100644
--- a/lib/eal/freebsd/eal_thread.c
+++ b/lib/eal/freebsd/eal_thread.c
@@ -32,6 +32,17 @@ int rte_sys_gettid(void)
return (int)lwpid;
 }
 
+void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name)
+{
+   char truncated[RTE_MAX_THREAD_NAME_LEN];
+   const size_t truncatedsz = sizeof(truncated);
+
+   if (strlcpy(truncated, thread_name, truncatedsz) >= truncatedsz)
+   RTE_LOG(DEBUG, EAL, "Truncated thread name\n");
+
+   pthread_set_name_np((pthread_t)thread_id.opaque_id, truncated);
+}
+
 int rte_thread_setname(pthread_t id, const char *name)
 {
/* this BSD function returns no error */
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index b9edf70..8a63a52 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -146,6 +146,23 @@ int rte_thread_create(rte_thread_t *thread_id,
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
  *
+ * Set the name of the thread.
+ *
+ * @param thread_id
+ *The id of the thread to set name.
+ *
+ * @param thread_name
+ *The name to set. Truncated to RTE_MAX_THREAD_NAME_LEN,
+ *including terminating NUL if necessary.
+ */
+__rte_experimental
+void
+rte_thread_set_name(rte_thread_t thread_id, const char *thread_name);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
  * Check if 2 thread ids are equal.
  *
  * @param t1
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 8c118d0..f7a4a10 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1255,11 +1255,9 @@ static void rte_eal_init_alert(const char *msg)
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
"rte-worker-%d", i);
-   ret = rte_thread_setname(lcore_config[i].thread_id,
-   thread_name);
-   if (ret != 0)
-   RTE_LOG(DEBUG, EAL,
-   "Cannot set name for lcore thread\n");
+   rte_thread_set_name(
+   (rte_thread_t){(uintptr_t)lcore_config[i].thread_id},
+   thread_name);
 
ret = pthread_setaffinity_np(lcore_config[i].thread_id,
sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c
index 625bde6..d5fddab 100644
--- a/lib/eal/linux/eal_thread.c
+++ b/lib/eal/linux/eal_thread.c
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 /* require calling thread

Re: [PATCH v2 1/4] eal: add thread set name API operating on rte thread

2023-01-13 Thread Tyler Retzlaff
On Fri, Jan 13, 2023 at 09:09:21AM -0800, Tyler Retzlaff wrote:
> On Fri, Jan 13, 2023 at 10:06:44AM +0530, Jerin Jacob wrote:
> > On Wed, Jan 11, 2023 at 9:39 PM David Marchand
> >  wrote:
> > >
> > > On Wed, Dec 14, 2022 at 5:47 PM Tyler Retzlaff
> > >  wrote:
> > > > diff --git a/lib/eal/common/eal_common_trace.c 
> > > > b/lib/eal/common/eal_common_trace.c
> > > > index 5caaac8..89522dc 100644
> > > > --- a/lib/eal/common/eal_common_trace.c
> > > > +++ b/lib/eal/common/eal_common_trace.c
> > > > @@ -356,8 +356,6 @@ rte_trace_mode rte_trace_mode_get(void)
> > > > /* Store the thread name */
> > > > char *name = header->stream_header.thread_name;
> > > > memset(name, 0, __RTE_TRACE_EMIT_STRING_LEN_MAX);
> > > > -   rte_thread_getname(pthread_self(), name,
> > > > -   __RTE_TRACE_EMIT_STRING_LEN_MAX);
> > > >
> > > > trace->lcore_meta[count].mem = header;
> > > > trace->nb_trace_mem_list++;
> > >
> > > Note, this belongs to patch 2.
> > >
> > > I understand we can drop the thread name retrieval helper from public
> > > API, but at least for the trace framework it added some info in the
> > > traces.
> > > Jerin, Sunil, what do you think? Should we keep this helper internally?
> > 
> > 
> > Good catch @David Marchand. Yes, we should be it as internal helper
> > API use it here.
> > For trace, It will be difficult to make sense without thread name.
> 
> is the name what is really valuable here because it will only appear in
> traces for linux with a new enough glibc, i.e. freebsd and windows it
> will always be empty.
> 
> we could just provide the thread id and that is available on all
> platforms, i'd like to see consistency for all platforms if possible
> here but i'm not pushing too hard since we don't declare our tracing
> output to be a compatibility surface.
> 
> can we just provide the thread id?

as a compromise i have submitted a new version for the series that
curtails the scope of the original rte_thread_getname and allowing it at
this single callsite.

going forward however i would suggest we do not allow further internal
use.

thanks!


Re: [PATCH] ipsec: remove unneccessary null check

2023-01-13 Thread Tyler Retzlaff
On Fri, Jan 13, 2023 at 10:44:25AM -0800, Stephen Hemminger wrote:
> The function rte_ring_free() accepts NULL as vaild input
> like free() and other functions.
> 
> Found with null_free_check.cocci.
> 
> Fixes: 16d6ebb65d59 ("crypto/ipsec_mb: fix null checks")
> Cc: kai...@intel.com
> Signed-off-by: Stephen Hemminger 
> ---
>  drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c 
> b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> index 71e02cd0513d..3e52f9567401 100644
> --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
> @@ -139,15 +139,12 @@ int
>  ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
>  {
>   struct ipsec_mb_qp *qp = dev->data->queue_pairs[qp_id];
> - struct rte_ring *r = NULL;
>  
>   if (!qp)
>   return 0;
>  
>   if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> - r = rte_ring_lookup(qp->name);
> - if (r)
> - rte_ring_free(r);
> + rte_ring_free(rte_ring_lookup(qp->name));
>  
>  #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM
>   if (qp->mb_mgr)
> -- 

Acked-by: Tyler Retzlaff 



Re: [EXT] Re: [PATCH v5 0/4] add support for self monitoring

2023-01-13 Thread Tyler Retzlaff
On Fri, Jan 13, 2023 at 07:44:57AM +, Tomasz Duszynski wrote:
> 
> 
> >-Original Message-
> >From: Tyler Retzlaff 
> >Sent: Wednesday, January 11, 2023 10:06 PM
> >To: Tomasz Duszynski 
> >Cc: bruce.richard...@intel.com; m...@smartsharesystems.com; dev@dpdk.org; 
> >tho...@monjalon.net; Jerin
> >Jacob Kollanukkaran ; ruifeng.w...@arm.com; 
> >mattias.ronnb...@ericsson.com;
> >zhou...@loongson.cn
> >Subject: Re: [EXT] Re: [PATCH v5 0/4] add support for self monitoring
> >
> >On Wed, Jan 11, 2023 at 09:39:35AM +, Tomasz Duszynski wrote:
> >> Hi Tyler,
> >>
> >> >-Original Message-
> >> >From: Tyler Retzlaff 
> >> >Sent: Wednesday, January 11, 2023 1:32 AM
> >> >To: Tomasz Duszynski ;
> >> >bruce.richard...@intel.com; m...@smartsharesystems.com
> >> >Cc: dev@dpdk.org; tho...@monjalon.net; Jerin Jacob Kollanukkaran
> >> >; m...@smartsharesystems.com; ruifeng.w...@arm.com;
> >> >mattias.ronnb...@ericsson.com; zhou...@loongson.cn
> >> >Subject: [EXT] Re: [PATCH v5 0/4] add support for self monitoring
> >> >
> >> >External Email
> >> >
> >> >-
> >> >-
> >> >hi,
> >> >
> >> >don't interpret this as an objection to the functionality but this
> >> >looks like a clear example of something that doesn't belong in the
> >> >EAL. has there been a discussion as to whether or not this should be in a 
> >> >separate library?
> >>
> >> No, I don't recall anybody having any concerns about the code
> >> placement. Rationale behind making this part of eal was based on the
> >> fact that tracing itself is a part of eal and since this was meant to be 
> >> extension to tracing,
> >code placement decision came out naturally.
> >>
> >> During development phase idea evolved a bit and what initially was
> >> supposed to be solely yet another tracepoint become generic API to
> >> read pmu and tracepoint based on that. Which means both can be used 
> >> independently.
> >>
> >> That said, since this code has both platform agnostic and platform 
> >> specific parts this can either
> >be split into:
> >> 1. library + eal platform code
> >> 2. all under eal
> >>
> >> Either approach seems legit. Thoughts?
> >>
> >> >
> >> >a basic test is whether or not an implementation exists or can be
> >> >reasonably provided for all platforms and that isn't strictly evident
> >> >here. red flag is to see yet more code being added conditionally compiled 
> >> >for a single platform.
> >>
> >> Even libs are not entirely pristine and have platform specific ifdefs
> >> lurking so not sure where this red flag is coming from.
> >
> >i think red flag was probably the wrong term to use sorry for that.
> >rather i should say it is an indicator that the api probably doesn't belong 
> >in the eal.
> >
> >fundamentally the purpose of the abstraction library is to relieve the 
> >application from having to
> >do conditional compilation and/or execution for the subject apis coming from 
> >eal. including and
> >exporting apis that work for only one platform is in direct contradiction.
> >
> >please explore adding this as a separate library, it is understood that 
> >there are tradeoffs
> >involved.
> >
> >thanks!
> 
> Any ideas how to name the library?

naming is always so hard and i'm definitely not authoritative.

it seems like lib/pmu would be the least churn against your existing
patch series, here are some other suggestions that might work.

lib/pmu (measuring unit)
lib/pmc (measuring counters)
lib/pcq (counter query)
lib/pmq (measuring query)



Re: [PATCH] eal: replace lcore direct use of pthread in the EAL

2023-01-13 Thread Tyler Retzlaff
hey folks,

any feedback here? incremental progress untangling pthread out of eal.

thanks!

On Thu, Dec 08, 2022 at 01:48:16PM -0800, Tyler Retzlaff wrote:
> * Replace the use of pthread_t in struct lcore_config with the EAL
>   rte_thread_t type.
> 
> * Replace the direct use of pthread_create(), pthread_self()
>   pthread_getaffinity_np() and pthread_setaffinity_np().
> 
> Minor tweaks to return value comparisons to align with current DPDK
> style.
> 
> Signed-off-by: Tyler Retzlaff 
> ---
>  lib/eal/common/eal_common_options.c |  8 
>  lib/eal/common/eal_common_thread.c  | 13 ++---
>  lib/eal/common/eal_private.h|  2 +-
>  lib/eal/common/eal_thread.h |  2 +-
>  lib/eal/freebsd/eal.c   | 13 -
>  lib/eal/linux/eal.c | 24 +---
>  lib/eal/windows/eal.c   | 10 ++
>  lib/eal/windows/eal_thread.c| 25 -
>  lib/eal/windows/eal_windows.h   | 12 
>  9 files changed, 43 insertions(+), 66 deletions(-)
> 
> diff --git a/lib/eal/common/eal_common_options.c 
> b/lib/eal/common/eal_common_options.c
> index 2d65357..86a519c 100644
> --- a/lib/eal/common/eal_common_options.c
> +++ b/lib/eal/common/eal_common_options.c
> @@ -1943,8 +1943,8 @@ static int xdigit2val(unsigned char c)
>   unsigned int removed = 0;
>   rte_cpuset_t affinity_set;
>  
> - if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
> - &affinity_set))
> + if (rte_thread_get_affinity_by_id(rte_thread_self(),
> + &affinity_set) != 0)
>   CPU_ZERO(&affinity_set);
>  
>   for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
> @@ -1972,8 +1972,8 @@ static int xdigit2val(unsigned char c)
>   }
>   RTE_CPU_NOT(cpuset, cpuset);
>  
> - if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
> - &default_set))
> + if (rte_thread_get_affinity_by_id(rte_thread_self(),
> + &default_set) != 0)
>   CPU_ZERO(&default_set);
>  
>   RTE_CPU_AND(cpuset, cpuset, &default_set);
> diff --git a/lib/eal/common/eal_common_thread.c 
> b/lib/eal/common/eal_common_thread.c
> index c5d8b43..dbe52a4 100644
> --- a/lib/eal/common/eal_common_thread.c
> +++ b/lib/eal/common/eal_common_thread.c
> @@ -85,9 +85,9 @@ unsigned rte_socket_id(void)
>  int
>  rte_thread_set_affinity(rte_cpuset_t *cpusetp)
>  {
> - if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
> + if (rte_thread_set_affinity_by_id(rte_thread_self(),
>   cpusetp) != 0) {
> - RTE_LOG(ERR, EAL, "pthread_setaffinity_np failed\n");
> + RTE_LOG(ERR, EAL, "rte_thread_set_affinity_by_id failed\n");
>   return -1;
>   }
>  
> @@ -166,7 +166,7 @@ unsigned rte_socket_id(void)
>  }
>  
>  /* main loop of threads */
> -__rte_noreturn void *
> +__rte_noreturn uint32_t
>  eal_thread_loop(void *arg)
>  {
>   unsigned int lcore_id = (uintptr_t)arg;
> @@ -223,8 +223,7 @@ unsigned rte_socket_id(void)
>   }
>  
>   /* never reached */
> - /* pthread_exit(NULL); */
> - /* return NULL; */
> + /* return 0; */
>  }
>  
>  enum __rte_ctrl_thread_status {
> @@ -253,7 +252,7 @@ static void *ctrl_thread_init(void *arg)
>   void *routine_arg = params->arg;
>  
>   __rte_thread_init(rte_lcore_id(), cpuset);
> - params->ret = pthread_setaffinity_np(pthread_self(), sizeof(*cpuset),
> + params->ret = rte_thread_set_affinity_by_id(rte_thread_self(),
>   cpuset);
>   if (params->ret != 0) {
>   __atomic_store_n(¶ms->ctrl_thread_status,
> @@ -338,7 +337,7 @@ static void *ctrl_thread_init(void *arg)
>   rte_errno = EINVAL;
>   return -1;
>   }
> - if (pthread_getaffinity_np(pthread_self(), sizeof(cpuset),
> + if (rte_thread_get_affinity_by_id(rte_thread_self(),
>   &cpuset) != 0)
>   CPU_ZERO(&cpuset);
>   lcore_id = eal_lcore_non_eal_allocate();
> diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
> index 0f4d75b..d7f8377 100644
> --- a/lib/eal/common/eal_private.h
> +++ b/lib/eal/common/eal_private.h
> @@ -20,7 +20,7 @@
>   * Structure storing internal configuration (per-lcore)
>   */
>  struct lcore_config {
> - pthread_t thread_id;   /**< pthread identifier */
> + rte_thread_t thread_id;/**< thread identifier */
>   int pipe_main2worker[2];   /**< communication pipe with main */
>   int pipe_worker2main[2];   /**< communication pipe with main */
>  
> diff --git a/lib/eal/common/eal_thread.h b/lib/eal/common/eal_thread.h
> index 32bfe5c..1c3c344 100644
> --- a/lib/eal/common/eal_thread.h
> +++ b/lib/eal/common/eal_thread.h
> @@ -14,7 +14,7 @@
>   * @param arg
>   *   The lcore_id (passed as an integer) of this worker thread.
>   */
> -

[PATCH v4] eventdev/timer: add API to get remaining ticks

2023-01-13 Thread Erik Gabriel Carrillo
Introduce an event timer adapter API which allows users to determine how
many adapter ticks remain until an event timer expires.

Signed-off-by: Erik Gabriel Carrillo 
---
v4:
* Rename API to rte_event_timer_remaining_ticks_get
* Return error if API out param is NULL instead asserting it is non-NULL
* Update documentation

v3:
* Handle ENOTSUP case in unit test

v2:
* Rename API to rte_event_timer_get_remaining_ticks
* Assert that API out param is non-NULL instead of checking and returning
  error

 app/test/test_event_timer_adapter.c| 75 ++
 lib/eventdev/event_timer_adapter_pmd.h |  7 +++
 lib/eventdev/rte_event_timer_adapter.c | 53 ++
 lib/eventdev/rte_event_timer_adapter.h | 27 ++
 lib/eventdev/version.map   |  3 ++
 5 files changed, 165 insertions(+)

diff --git a/app/test/test_event_timer_adapter.c 
b/app/test/test_event_timer_adapter.c
index 1a440dfd10..5e7feec1c7 100644
--- a/app/test/test_event_timer_adapter.c
+++ b/app/test/test_event_timer_adapter.c
@@ -1920,6 +1920,79 @@ adapter_create_max(void)
return TEST_SUCCESS;
 }
 
+static inline int
+test_timer_ticks_remaining(void)
+{
+   uint64_t ticks_remaining = UINT64_MAX;
+   struct rte_event_timer *ev_tim;
+   struct rte_event ev;
+   int ret, i;
+   const struct rte_event_timer tim = {
+   .ev.op = RTE_EVENT_OP_NEW,
+   .ev.queue_id = 0,
+   .ev.sched_type = RTE_SCHED_TYPE_ATOMIC,
+   .ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL,
+   .ev.event_type =  RTE_EVENT_TYPE_TIMER,
+   .state = RTE_EVENT_TIMER_NOT_ARMED,
+   };
+
+   rte_mempool_get(eventdev_test_mempool, (void **)&ev_tim);
+   *ev_tim = tim;
+   ev_tim->ev.event_ptr = ev_tim;
+#define TEST_TICKS 5
+   ev_tim->timeout_ticks = CALC_TICKS(TEST_TICKS);
+
+   ret = rte_event_timer_remaining_ticks_get(timdev, ev_tim,
+ &ticks_remaining);
+   if (ret == -ENOTSUP) {
+   rte_mempool_put(eventdev_test_mempool, (void *)ev_tim);
+   printf("API not supported, skipping test\n");
+   return TEST_SKIPPED;
+   }
+
+   /* Test that unarmed timer returns error */
+   TEST_ASSERT_FAIL(ret,
+"Didn't fail to get ticks for unarmed event timer");
+
+   TEST_ASSERT_EQUAL(rte_event_timer_arm_burst(timdev, &ev_tim, 1), 1,
+ "Failed to arm timer with proper timeout.");
+   TEST_ASSERT_EQUAL(ev_tim->state, RTE_EVENT_TIMER_ARMED,
+ "Improper timer state set expected %d returned %d",
+ RTE_EVENT_TIMER_ARMED, ev_tim->state);
+
+   for (i = 0; i < TEST_TICKS; i++) {
+   ret = rte_event_timer_remaining_ticks_get(timdev, ev_tim,
+ &ticks_remaining);
+   if (ret < 0)
+   return TEST_FAILED;
+
+   TEST_ASSERT_EQUAL((int)ticks_remaining, TEST_TICKS - i,
+ "Expected %d ticks remaining, got %"PRIu64"",
+ TEST_TICKS - i, ticks_remaining);
+
+   rte_delay_ms(100);
+   }
+
+   rte_delay_ms(100);
+
+   TEST_ASSERT_EQUAL(rte_event_dequeue_burst(evdev, 0, &ev, 1, 0), 1,
+ "Armed timer failed to trigger.");
+   TEST_ASSERT_EQUAL(ev_tim->state, RTE_EVENT_TIMER_NOT_ARMED,
+ "Improper timer state set expected %d returned %d",
+ RTE_EVENT_TIMER_NOT_ARMED, ev_tim->state);
+
+   /* Test that timer that fired returns error */
+   TEST_ASSERT_FAIL(rte_event_timer_remaining_ticks_get(timdev, ev_tim,
+  &ticks_remaining),
+"Didn't fail to get ticks for unarmed event timer");
+
+   rte_mempool_put(eventdev_test_mempool, (void *)ev_tim);
+
+#undef TEST_TICKS
+   return TEST_SUCCESS;
+}
+
+
 static struct unit_test_suite event_timer_adptr_functional_testsuite  = {
.suite_name = "event timer functional test suite",
.setup = testsuite_setup,
@@ -1982,6 +2055,8 @@ static struct unit_test_suite 
event_timer_adptr_functional_testsuite  = {
TEST_CASE_ST(timdev_setup_msec, timdev_teardown,
adapter_tick_resolution),
TEST_CASE(adapter_create_max),
+   TEST_CASE_ST(timdev_setup_msec, timdev_teardown,
+   test_timer_ticks_remaining),
TEST_CASES_END() /**< NULL terminate unit test array */
}
 };
diff --git a/lib/eventdev/event_timer_adapter_pmd.h 
b/lib/eventdev/event_timer_adapter_pmd.h
index 189017b5c1..c7d4a4f0f6 100644
--- a/lib/eventdev/event_timer_adapter_pmd.h
+++ b/lib/eventdev/event_timer_adapter_pmd.h
@@ -52,6 +52,11 @@ typedef int (*rte_event_timer_adap

[PATCH v3 0/3] Split logging functionality out of EAL

2023-01-13 Thread Bruce Richardson
There is a general desire to reduce the size and scope of EAL. To this
end, this patchset makes a (very) small step in that direction by taking
the logging functionality out of EAL and putting it into its own library
that can be built and maintained separately.

As with the v1 RFC for this, the main obstacle is the "fnmatch" function
which is needed by both EAL and the new log function when building on
windows. While the function cannot stay in EAL - or we would have a
circular dependency, moving it to a new library or just putting it in
the log library have the disadvantages that it then "leaks" into the
public namespace without an rte_prefix, which could cause issues.  Since
only a single function is involved, this v2 RFC takes a different
approach to v1, and just moves the offending function to be a static
function in a header file. This allows use by multiple libs without
conflicting names or making it public.

The other complication, as explained in v1 RFC was that of multiple
implementations for different OS's. This is solved here in the same
way as v1, by including the OS in the name and having meson pick the
correct file for each build. Since only one file is involved, there
seemed little need for replicating EAL's separate subdirectories
per-OS.

NOTE: documentation updates are still missing in v3, will come in v4.
Submitting v3 to allow CI testing and check that v2 broken builds are
now working

v3:
* Fixed missing log file for BSD
* Removed "eal" from the filenames of files in the log directory
* added prefixes to elements in the fnmatch header to avoid conflicts
* fixed space indentation in new lines in telemetry.c (checkpatch)
* removed "extern int logtype" definition in telemetry.c (checkpatch)
* added log directory to list for doxygen scanning

Bruce Richardson (3):
  eal/windows: move fnmatch function to header file
  log: separate logging functions out of EAL
  telemetry: use standard logging

 doc/api/doxy-api.conf.in  |   1 +
 lib/eal/common/eal_common_options.c   |   2 +-
 lib/eal/common/eal_private.h  |   7 -
 lib/eal/common/meson.build|   1 -
 lib/eal/freebsd/eal.c |   6 +-
 lib/eal/include/meson.build   |   1 -
 lib/eal/linux/eal.c   |   8 +-
 lib/eal/linux/meson.build |   1 -
 lib/eal/meson.build   |   2 +-
 lib/eal/version.map   |  17 --
 lib/eal/windows/eal.c |   2 +-
 lib/eal/windows/fnmatch.c | 172 -
 lib/eal/windows/include/fnmatch.h | 175 --
 lib/eal/windows/meson.build   |   2 -
 lib/kvargs/meson.build|   3 +-
 .../common/eal_common_log.c => log/log.c} |   3 +-
 lib/log/log_freebsd.c |  12 ++
 .../common/eal_log.h => log/log_internal.h}   |  18 +-
 lib/{eal/linux/eal_log.c => log/log_linux.c}  |   2 +-
 .../windows/eal_log.c => log/log_windows.c}   |   2 +-
 lib/log/meson.build   |   9 +
 lib/{eal/include => log}/rte_log.h|   0
 lib/log/version.map   |  34 
 lib/meson.build   |   1 +
 lib/telemetry/meson.build |   3 +-
 lib/telemetry/telemetry.c |  11 +-
 lib/telemetry/telemetry_internal.h|   3 +-
 27 files changed, 249 insertions(+), 249 deletions(-)
 delete mode 100644 lib/eal/windows/fnmatch.c
 rename lib/{eal/common/eal_common_log.c => log/log.c} (99%)
 create mode 100644 lib/log/log_freebsd.c
 rename lib/{eal/common/eal_log.h => log/log_internal.h} (69%)
 rename lib/{eal/linux/eal_log.c => log/log_linux.c} (97%)
 rename lib/{eal/windows/eal_log.c => log/log_windows.c} (93%)
 create mode 100644 lib/log/meson.build
 rename lib/{eal/include => log}/rte_log.h (100%)
 create mode 100644 lib/log/version.map

--
2.37.2



[PATCH v3 1/3] eal/windows: move fnmatch function to header file

2023-01-13 Thread Bruce Richardson
To allow the fnmatch function to be shared between libraries, without
having to export it into the public namespace (since it's not prefixed
with "rte"), we can convert fnmatch.c to replace fnmatch.h. This allows
fnmatch function to be static and limited in scope to the current file,
preventing duplicate definitions if it is used by two libraries, while
also not requiring export for sharing.

Signed-off-by: Bruce Richardson 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 lib/eal/windows/fnmatch.c | 172 -
 lib/eal/windows/include/fnmatch.h | 175 +++---
 lib/eal/windows/meson.build   |   1 -
 3 files changed, 162 insertions(+), 186 deletions(-)
 delete mode 100644 lib/eal/windows/fnmatch.c

diff --git a/lib/eal/windows/fnmatch.c b/lib/eal/windows/fnmatch.c
deleted file mode 100644
index f622bf54c5..00
--- a/lib/eal/windows/fnmatch.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)fnmatch.c8.2 (Berkeley) 4/16/94";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
- * Compares a filename or pathname to a pattern.
- */
-
-#include 
-#include 
-#include 
-
-#include "fnmatch.h"
-
-#define EOS'\0'
-
-static const char *rangematch(const char *, char, int);
-
-int
-fnmatch(const char *pattern, const char *string, int flags)
-{
-   const char *stringstart;
-   char c, test;
-
-   for (stringstart = string;;)
-   switch (c = *pattern++) {
-   case EOS:
-   if ((flags & FNM_LEADING_DIR) && *string == '/')
-   return (0);
-   return (*string == EOS ? 0 : FNM_NOMATCH);
-   case '?':
-   if (*string == EOS)
-   return (FNM_NOMATCH);
-   if (*string == '/' && (flags & FNM_PATHNAME))
-   return (FNM_NOMATCH);
-   if (*string == '.' && (flags & FNM_PERIOD) &&
-   (string == stringstart ||
-   ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
-   return (FNM_NOMATCH);
-   ++string;
-   break;
-   case '*':
-   c = *pattern;
-   /* Collapse multiple stars. */
-   while (c == '*')
-   c = *++pattern;
-
-   if (*string == '.' && (flags & FNM_PERIOD) &&
-   (string == stringstart ||
-   ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
-   return (FNM_NOMATCH);
-
-   /* Optimize for pattern with * at end or before /. */
-   if (c == EOS)
-   if (flags & FNM_PATHNAME)
-   return ((flags & FNM_LEADING_DIR) ||
-   strchr(string, '/') == NULL ?
-   0 : FNM_NOMATCH);
-   else
-   return (0);
-   else if (c == '/' && flags & FNM_PATHNAME) {
-   string = strchr(string, '/');
-   if (string == NULL)
-   return (FNM_NOMATCH);
-   break;
-   }
-
-   /* General case, use recursion. */
-   while ((test = *string) != EOS) {
-   if (!fnmatch(pattern, string,
-   flags & ~FNM_PERIOD))
-   return (0);
-   if (test == '/' && flags & FNM_PATHNAME)
-   break;
-   ++string;
-   }
-   return (FNM_NOMATCH);
-   case '[':
-   if (*string == EOS)
-   return (FNM_NOMATCH);
-   if (*string == '/' && flags & FNM_PATHNAME)
-   return (FNM_NOMATCH);
-   pattern = rangematch(pattern, *string, flags);
-   if (pattern == NULL)
-   return (FNM_NOMATCH);
-   ++string;
-   break;
-   case '\\':
-   if (!(flags & FNM_NOESCAPE)) {
-   c

[PATCH v3 2/3] log: separate logging functions out of EAL

2023-01-13 Thread Bruce Richardson
Move the logging capability to a separate library, free from EAL. Rename
files as appropriate, and use meson.build to select the correct file to
be built for each operating system, rather than having a subdir per-os.

Signed-off-by: Bruce Richardson 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 doc/api/doxy-api.conf.in  |  1 +
 lib/eal/common/eal_common_options.c   |  2 +-
 lib/eal/common/eal_private.h  |  7 
 lib/eal/common/meson.build|  1 -
 lib/eal/include/meson.build   |  1 -
 lib/eal/linux/eal.c   |  2 +-
 lib/eal/linux/meson.build |  1 -
 lib/eal/meson.build   |  2 +-
 lib/eal/version.map   | 17 --
 lib/eal/windows/eal.c |  2 +-
 lib/eal/windows/meson.build   |  1 -
 lib/kvargs/meson.build|  3 +-
 .../common/eal_common_log.c => log/log.c} |  3 +-
 lib/log/log_freebsd.c | 12 +++
 .../common/eal_log.h => log/log_internal.h}   | 18 --
 lib/{eal/linux/eal_log.c => log/log_linux.c}  |  2 +-
 .../windows/eal_log.c => log/log_windows.c}   |  2 +-
 lib/log/meson.build   |  9 +
 lib/{eal/include => log}/rte_log.h|  0
 lib/log/version.map   | 34 +++
 lib/meson.build   |  1 +
 lib/telemetry/meson.build |  3 +-
 22 files changed, 81 insertions(+), 43 deletions(-)
 rename lib/{eal/common/eal_common_log.c => log/log.c} (99%)
 create mode 100644 lib/log/log_freebsd.c
 rename lib/{eal/common/eal_log.h => log/log_internal.h} (69%)
 rename lib/{eal/linux/eal_log.c => log/log_linux.c} (97%)
 rename lib/{eal/windows/eal_log.c => log/log_windows.c} (93%)
 create mode 100644 lib/log/meson.build
 rename lib/{eal/include => log}/rte_log.h (100%)
 create mode 100644 lib/log/version.map

diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
index f0886c3bd1..442703c01a 100644
--- a/doc/api/doxy-api.conf.in
+++ b/doc/api/doxy-api.conf.in
@@ -51,6 +51,7 @@ INPUT   = @TOPDIR@/doc/api/doxy-api-index.md \
   @TOPDIR@/lib/kni \
   @TOPDIR@/lib/kvargs \
   @TOPDIR@/lib/latencystats \
+  @TOPDIR@/lib/log \
   @TOPDIR@/lib/lpm \
   @TOPDIR@/lib/mbuf \
   @TOPDIR@/lib/member \
diff --git a/lib/eal/common/eal_common_options.c 
b/lib/eal/common/eal_common_options.c
index 2d6535781b..89c312f441 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -39,7 +39,7 @@
 #include "eal_options.h"
 #include "eal_filesystem.h"
 #include "eal_private.h"
-#include "eal_log.h"
+#include "log_internal.h"
 #ifndef RTE_EXEC_ENV_WINDOWS
 #include "eal_trace.h"
 #endif
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 0f4d75bb89..dbf60190f4 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -152,13 +152,6 @@ int rte_eal_tailqs_init(void);
  */
 int rte_eal_intr_init(void);
 
-/**
- * Close the default log stream
- *
- * This function is private to EAL.
- */
-void rte_eal_log_cleanup(void);
-
 /**
  * Init alarm mechanism. This is to allow a callback be called after
  * specific time.
diff --git a/lib/eal/common/meson.build b/lib/eal/common/meson.build
index 917758cc65..22a626ba6f 100644
--- a/lib/eal/common/meson.build
+++ b/lib/eal/common/meson.build
@@ -18,7 +18,6 @@ sources += files(
 'eal_common_interrupts.c',
 'eal_common_launch.c',
 'eal_common_lcore.c',
-'eal_common_log.c',
 'eal_common_mcfg.c',
 'eal_common_memalloc.c',
 'eal_common_memory.c',
diff --git a/lib/eal/include/meson.build b/lib/eal/include/meson.build
index cfcd40aaed..1eaa074d1b 100644
--- a/lib/eal/include/meson.build
+++ b/lib/eal/include/meson.build
@@ -27,7 +27,6 @@ headers += files(
 'rte_keepalive.h',
 'rte_launch.h',
 'rte_lcore.h',
-'rte_log.h',
 'rte_malloc.h',
 'rte_mcslock.h',
 'rte_memory.h',
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 8c118d0d9f..0df9f1f353 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -49,10 +49,10 @@
 #include "eal_hugepages.h"
 #include "eal_memcfg.h"
 #include "eal_trace.h"
-#include "eal_log.h"
 #include "eal_options.h"
 #include "eal_vfio.h"
 #include "hotplug_mp.h"
+#include "log_internal.h"
 
 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
 
diff --git a/lib/eal/linux/meson.build b/lib/eal/linux/meson.build
index 3cccfa36c0..1b913acc06 100644
--- a/lib/eal/linux/meson.build
+++ b/lib/eal/linux/meson.build
@@ -11,7 +11,6 @@ sources += files(
 'eal_hugepage_info.c',
 'eal_in

[PATCH v3 3/3] telemetry: use standard logging

2023-01-13 Thread Bruce Richardson
Now that logging is moved out of EAL, we don't need injection of the
logtype and logging function from EAL to telemetry library, simplifying
things.

Signed-off-by: Bruce Richardson 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 lib/eal/freebsd/eal.c  |  6 +-
 lib/eal/linux/eal.c|  6 +-
 lib/telemetry/telemetry.c  | 11 +++
 lib/telemetry/telemetry_internal.h |  3 +--
 4 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 607684c1a3..820c4524e5 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -871,13 +871,9 @@ rte_eal_init(int argc, char **argv)
return -1;
}
if (rte_eal_process_type() == RTE_PROC_PRIMARY && 
!internal_conf->no_telemetry) {
-   int tlog = rte_log_register_type_and_pick_level(
-   "lib.telemetry", RTE_LOG_WARNING);
-   if (tlog < 0)
-   tlog = RTE_LOGTYPE_EAL;
if (rte_telemetry_init(rte_eal_get_runtime_dir(),
rte_version(),
-   &internal_conf->ctrl_cpuset, rte_log, tlog) != 
0)
+   &internal_conf->ctrl_cpuset) != 0)
return -1;
}
 
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 0df9f1f353..dec0041094 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1319,13 +1319,9 @@ rte_eal_init(int argc, char **argv)
return -1;
}
if (rte_eal_process_type() == RTE_PROC_PRIMARY && 
!internal_conf->no_telemetry) {
-   int tlog = rte_log_register_type_and_pick_level(
-   "lib.telemetry", RTE_LOG_WARNING);
-   if (tlog < 0)
-   tlog = RTE_LOGTYPE_EAL;
if (rte_telemetry_init(rte_eal_get_runtime_dir(),
rte_version(),
-   &internal_conf->ctrl_cpuset, rte_log, tlog) != 
0)
+   &internal_conf->ctrl_cpuset) != 0)
return -1;
}
 
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 8fbb4f3060..13a32f4279 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -54,11 +54,9 @@ static struct socket v1_socket; /* socket for v1 telemetry */
 static const char *telemetry_version; /* save rte_version */
 static const char *socket_dir;/* runtime directory */
 static rte_cpuset_t *thread_cpuset;
-static rte_log_fn rte_log_ptr;
-static uint32_t logtype;
 
-#define TMTY_LOG(l, ...) \
-rte_log_ptr(RTE_LOG_ ## l, logtype, "TELEMETRY: " __VA_ARGS__)
+RTE_LOG_REGISTER_DEFAULT(logtype, WARNING);
+#define TMTY_LOG(l, ...) rte_log(RTE_LOG_ ## l, logtype, "TELEMETRY: " 
__VA_ARGS__)
 
 /* list of command callbacks, with one command registered by default */
 static struct cmd_callback *callbacks;
@@ -612,14 +610,11 @@ telemetry_v2_init(void)
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
 int32_t
-rte_telemetry_init(const char *runtime_dir, const char *rte_version, 
rte_cpuset_t *cpuset,
-   rte_log_fn log_fn, uint32_t registered_logtype)
+rte_telemetry_init(const char *runtime_dir, const char *rte_version, 
rte_cpuset_t *cpuset)
 {
telemetry_version = rte_version;
socket_dir = runtime_dir;
thread_cpuset = cpuset;
-   rte_log_ptr = log_fn;
-   logtype = registered_logtype;
 
 #ifndef RTE_EXEC_ENV_WINDOWS
if (telemetry_v2_init() != 0)
diff --git a/lib/telemetry/telemetry_internal.h 
b/lib/telemetry/telemetry_internal.h
index d085c492dc..5c75d73183 100644
--- a/lib/telemetry/telemetry_internal.h
+++ b/lib/telemetry/telemetry_internal.h
@@ -109,7 +109,6 @@ typedef int (*rte_log_fn)(uint32_t level, uint32_t logtype, 
const char *format,
  */
 __rte_internal
 int
-rte_telemetry_init(const char *runtime_dir, const char *rte_version, 
rte_cpuset_t *cpuset,
-   rte_log_fn log_fn, uint32_t registered_logtype);
+rte_telemetry_init(const char *runtime_dir, const char *rte_version, 
rte_cpuset_t *cpuset);
 
 #endif
-- 
2.37.2



[PATCH 0/7] replace zero length arrays

2023-01-13 Thread Stephen Hemminger
Zero length arrays are a GNU extension that has been
superseded by flex arrays.

https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

These are places found by cocci/zero_length_array.cocci

Stephen Hemminger (7):
  member: replace zero length array with flex array
  cryptodev: replace zero length array with flex array
  security: replace zero length array with flex array
  mlx5: replace zero length array with flex array
  nfp: replace zero length array with flex array
  enic: replace zero length array with flex array
  dpaax: replace zero length array with flex array

 drivers/common/dpaax/caamflib/desc/ipsec.h | 2 +-
 drivers/net/enic/base/vnic_devcmd.h| 2 +-
 drivers/net/mlx5/mlx5.h| 4 ++--
 drivers/net/mlx5/mlx5_flow.h   | 2 +-
 drivers/net/mlx5/mlx5_tx.h | 2 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h   | 2 +-
 lib/cryptodev/cryptodev_pmd.h  | 2 +-
 lib/member/rte_member_heap.h   | 2 +-
 lib/security/rte_security_driver.h | 2 +-
 9 files changed, 10 insertions(+), 10 deletions(-)

-- 
2.39.0



[PATCH 1/7] member: replace zero length array with flex array

2023-01-13 Thread Stephen Hemminger
Zero length arrays are GNU extension. Replace with
standard flex array.

Signed-off-by: Stephen Hemminger 
---
 lib/member/rte_member_heap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/member/rte_member_heap.h b/lib/member/rte_member_heap.h
index 9c4a01aebe95..ab6319bc2de4 100644
--- a/lib/member/rte_member_heap.h
+++ b/lib/member/rte_member_heap.h
@@ -26,7 +26,7 @@ struct hash {
uint16_t bkt_cnt;
uint16_t num_item;
uint32_t seed;
-   struct hash_bkt buckets[0];
+   struct hash_bkt buckets[];
 };
 
 struct node {
-- 
2.39.0



[PATCH 2/7] cryptodev: replace zero length array with flex array

2023-01-13 Thread Stephen Hemminger
Zero length arrays are GNU extension. Replace with
standard flex array.

Signed-off-by: Stephen Hemminger 
---
 lib/cryptodev/cryptodev_pmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
index 0020102eb7db..ffca31db4a96 100644
--- a/lib/cryptodev/cryptodev_pmd.h
+++ b/lib/cryptodev/cryptodev_pmd.h
@@ -153,7 +153,7 @@ struct rte_cryptodev_sym_session {
 
RTE_MARKER cacheline1 __rte_cache_min_aligned;
/**< Second cache line - start of the driver session data */
-   uint8_t driver_priv_data[0];
+   uint8_t driver_priv_data[];
/**< Driver specific session data, variable size */
 };
 
-- 
2.39.0



[PATCH 3/7] security: replace zero length array with flex array

2023-01-13 Thread Stephen Hemminger
Zero length arrays are GNU extension. Replace with
standard flex array.

Signed-off-by: Stephen Hemminger 
---
 lib/security/rte_security_driver.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/security/rte_security_driver.h 
b/lib/security/rte_security_driver.h
index 421e6f778067..ff6a33369a08 100644
--- a/lib/security/rte_security_driver.h
+++ b/lib/security/rte_security_driver.h
@@ -34,7 +34,7 @@ struct rte_security_session {
/**< session private data IOVA address */
 
RTE_MARKER cacheline1 __rte_cache_min_aligned;
-   uint8_t driver_priv_data[0];
+   uint8_t driver_priv_data[];
/**< Private session material, variable size (depends on driver) */
 };
 
-- 
2.39.0



[PATCH 4/7] mlx5: replace zero length array with flex array

2023-01-13 Thread Stephen Hemminger
Zero length arrays are GNU extension. Replace with
standard flex array.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/mlx5/mlx5.h  | 4 ++--
 drivers/net/mlx5/mlx5_flow.h | 2 +-
 drivers/net/mlx5/mlx5_tx.h   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 31982002ee9b..2b295f9ba037 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1273,7 +1273,7 @@ struct mlx5_aso_ct_pool {
};
struct mlx5_aso_sq *sq; /* Async ASO SQ. */
struct mlx5_aso_sq *shared_sq; /* Shared ASO SQ. */
-   struct mlx5_aso_ct_action actions[0];
+   struct mlx5_aso_ct_action actions[];
/* CT action structures bulk. */
 };
 
@@ -1290,7 +1290,7 @@ struct mlx5_aso_ct_pools_mng {
rte_spinlock_t ct_sl; /* The ASO CT free list lock. */
rte_rwlock_t resize_rwl; /* The ASO CT pool resize lock. */
struct aso_ct_list free_cts; /* Free ASO CT objects list. */
-   struct mlx5_aso_sq aso_sqs[0]; /* ASO queue objects. */
+   struct mlx5_aso_sq aso_sqs[]; /* ASO queue objects. */
 };
 
 #ifdef PEDANTIC
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 1f57ecd6e1c1..e12efab211d2 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -1149,7 +1149,7 @@ struct rte_flow_hw {
uint32_t age_idx;
cnt_id_t cnt_id;
uint32_t mtr_id;
-   uint8_t rule[0]; /* HWS layer data struct. */
+   uint8_t rule[]; /* HWS layer data struct. */
 } __rte_packed;
 
 #ifdef PEDANTIC
diff --git a/drivers/net/mlx5/mlx5_tx.h b/drivers/net/mlx5/mlx5_tx.h
index a44050a1cec3..d026e8126a75 100644
--- a/drivers/net/mlx5/mlx5_tx.h
+++ b/drivers/net/mlx5/mlx5_tx.h
@@ -166,7 +166,7 @@ struct mlx5_txq_data {
struct mlx5_txq_stats stats; /* TX queue counters. */
struct mlx5_txq_stats stats_reset; /* stats on last reset. */
struct mlx5_uar_data uar_data;
-   struct rte_mbuf *elts[0];
+   struct rte_mbuf * elts[];
/* Storage for queued packets, must be the last field. */
 } __rte_cache_aligned;
 
-- 
2.39.0



[PATCH 5/7] nfp: replace zero length array with flex array

2023-01-13 Thread Stephen Hemminger
Zero length arrays are GNU extension. Replace with
standard flex array.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h 
b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 04601cb0bd25..ee8b439d617f 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -73,7 +73,7 @@ struct nfp_flower_cmsg_mac_repr {
uint8_t info;
uint8_t nbi_port;
uint8_t phys_port;
-   } ports[0];
+   } ports[];
 };
 
 /*
-- 
2.39.0



[PATCH 6/7] enic: replace zero length array with flex array

2023-01-13 Thread Stephen Hemminger
Zero length arrays are GNU extension. Replace with
standard flex array.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/enic/base/vnic_devcmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/enic/base/vnic_devcmd.h 
b/drivers/net/enic/base/vnic_devcmd.h
index 253a791c3f65..f91cc3078d63 100644
--- a/drivers/net/enic/base/vnic_devcmd.h
+++ b/drivers/net/enic/base/vnic_devcmd.h
@@ -765,7 +765,7 @@ struct vnic_devcmd_notify {
 struct vnic_devcmd_provinfo {
uint8_t oui[3];
uint8_t type;
-   uint8_t data[0];
+   uint8_t data[];
 };
 
 /*
-- 
2.39.0



[PATCH 7/7] dpaax: replace zero length array with flex array

2023-01-13 Thread Stephen Hemminger
Zero length arrays are GNU extension. Replace with
standard flex array.

Signed-off-by: Stephen Hemminger 
---
 drivers/common/dpaax/caamflib/desc/ipsec.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/common/dpaax/caamflib/desc/ipsec.h 
b/drivers/common/dpaax/caamflib/desc/ipsec.h
index 8ec6aac915b4..2c9080a1b51d 100644
--- a/drivers/common/dpaax/caamflib/desc/ipsec.h
+++ b/drivers/common/dpaax/caamflib/desc/ipsec.h
@@ -350,7 +350,7 @@ struct ipsec_encap_pdb {
};
uint32_t spi;
uint32_t ip_hdr_len;
-   uint8_t ip_hdr[0];
+   uint8_t ip_hdr[];
 };
 
 static inline unsigned int
-- 
2.39.0



Re: [PATCH] net/vmxnet3: added checks for TCP for RSS Configuration

2023-01-13 Thread Jochen Behrens
The check is at an additional location. I agree, and pointed out to him offline 
earlier, that a check for the h/w version should be used with the additional 
code, too.

Jochen



From: Ferruh Yigit 
Date: Friday, January 13, 2023 at 8:24 AM
To: Raghav Roy , dev@dpdk.org 
Cc: Jochen Behrens 
Subject: Re: [PATCH] net/vmxnet3: added checks for TCP for RSS Configuration
!! External Email

On 12/22/2022 8:24 AM, Raghav Roy wrote:
> Added checks for TCP in vmxnet3_rss_configure()
> This check ensures the hashType for RSS, when enabled
> just for UDP, is not NONE.
>

Mandatory hash functions for v4 already added in the past:
Commit 52ec00fd1474 ("net/vmxnet3: fix RSS setting on v4")

Now this commit adds it for all versions, why it was fine in the past
but it is needed now?

@Jochen, can you please help reviewing this patch?


> Signed-off-by: Raghav Roy 
> ---
>  drivers/net/vmxnet3/vmxnet3_rxtx.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c 
> b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> index a875ffec07..e8407c9b2e 100644
> --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
> +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> @@ -1412,6 +1412,13 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)
>   dev_rss_conf = hw->rss_conf;
>   port_rss_conf = &dev->data->dev_conf.rx_adv_conf.rss_conf;
>
> + if ((port_rss_conf->rss_hf & VMXNET3_MANDATORY_V4_RSS) !=
> +VMXNET3_MANDATORY_V4_RSS) {
> + PMD_INIT_LOG(WARNING, "RSS: IPv4/6 TCP is required for vmxnet3 
> RSS, "
> +  "automatically setting it");
> + port_rss_conf->rss_hf |= VMXNET3_MANDATORY_V4_RSS;
> + }
> +

`
#define VMXNET3_MANDATORY_V4_RSS ( \
RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
RTE_ETH_RSS_NONFRAG_IPV6_TCP)
`

Can you please describe why IPv4/6 TCP hash function is required for driver?
And what is the impact, I mean what is the observed behavior without
this patch, if RSS is failing without this change patch needs to be fix
patch and please describe since when RSS is failing.

>   /* loading hashFunc */
>   dev_rss_conf->hashFunc = VMXNET3_RSS_HASH_FUNC_TOEPLITZ;
>   /* loading hashKeySize */
> @@ -1419,6 +1426,7 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)
>   /* loading indTableSize: Must not exceed VMXNET3_RSS_MAX_IND_TABLE_SIZE 
> (128)*/
>   dev_rss_conf->indTableSize = (uint16_t)((MAX_RX_QUEUES(hw)) * 4);
>
> +
>   if (port_rss_conf->rss_key == NULL) {
>   /* Default hash key */
>   port_rss_conf->rss_key = rss_intel_key;
> @@ -1446,6 +1454,5 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)
>   dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_IPV6;
>   if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_TCP)
>   dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_TCP_IPV6;
> -

Please drop unrelated/unimportant syntax changes.

>   return VMXNET3_SUCCESS;
>  }


!! External Email: This email originated from outside of the organization. Do 
not click links or open attachments unless you recognize the sender.


Re: [RFC] Remove Kernel Network Interface (KNI)

2023-01-13 Thread Stephen Hemminger
On Fri, 13 Jan 2023 19:34:24 +0100
Thomas Monjalon  wrote:

> 13/01/2023 18:13, Stephen Hemminger:
> > On Fri, 13 Jan 2023 09:12:16 +0100
> > Thomas Monjalon  wrote:
> >   
> > > 13/01/2023 06:03, Stephen Hemminger:  
> > > > The Linux special network driver for kernel networking has been
> > > > a long term problem for DPDK. The performance benefits of KNI
> > > > are available via virtio-user and XDP, and the simpler kernel
> > > > interface via TAP is also available.
> > > > 
> > > > This driver has required lots of effort to keep up with the
> > > > kernel API changes. And the overall architecture of the driver
> > > > is fundamentally insecure and has unfixable locking and data
> > > > race problems. No developer has been willing to do extensive
> > > > tests or be the maintainer.
> > > > 
> > > > In short, the time has come to do some early spring cleaning
> > > > and remove KNI from DPDK 23.03.
> > > 
> > > In doc/guides/rel_notes/deprecation.rst it is announced
> > > to be removed in 23.11. Let's keep this RFC for later :)
> > > 
> > >   
> > 
> > For 23.03 could we add a deprecation log message when library is
> > used and when kernel module is loaded.  
> 
> We already have a message in the lib:
> 
> int
> rte_kni_init(unsigned int max_kni_ifaces __rte_unused)
> {
>   RTE_LOG(WARNING, KNI, "WARNING: KNI is deprecated and will be removed 
> in DPDK 23.11\n");
> 
> It is a good idea to add a message in the kernel module loading.
> 
> 
> 
> 

No matter how much we tell users, guarantee someone will still miss it and 
complain :-)


Re: [PATCH 1/7] member: replace zero length array with flex array

2023-01-13 Thread Tyler Retzlaff
On Fri, Jan 13, 2023 at 01:51:59PM -0800, Stephen Hemminger wrote:
> Zero length arrays are GNU extension. Replace with
> standard flex array.
> 
> Signed-off-by: Stephen Hemminger 
> ---
>  lib/member/rte_member_heap.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/member/rte_member_heap.h b/lib/member/rte_member_heap.h
> index 9c4a01aebe95..ab6319bc2de4 100644
> --- a/lib/member/rte_member_heap.h
> +++ b/lib/member/rte_member_heap.h
> @@ -26,7 +26,7 @@ struct hash {
>   uint16_t bkt_cnt;
>   uint16_t num_item;
>   uint32_t seed;
> - struct hash_bkt buckets[0];
> + struct hash_bkt buckets[];
>  };
>  
>  struct node {
> -- 

i suppose arguably this series depends on the series Bruce is putting
up defaulting the minimum C standard to C99 since technically that's the
minimum needed for the flexible array members.

Series-acked-by: Tyler Retzlaff 



Re: [PATCH 1/7] member: replace zero length array with flex array

2023-01-13 Thread Stephen Hemminger
On Fri, 13 Jan 2023 16:19:21 -0800
Tyler Retzlaff  wrote:

> On Fri, Jan 13, 2023 at 01:51:59PM -0800, Stephen Hemminger wrote:
> > Zero length arrays are GNU extension. Replace with
> > standard flex array.
> > 
> > Signed-off-by: Stephen Hemminger 
> > ---
> >  lib/member/rte_member_heap.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/lib/member/rte_member_heap.h b/lib/member/rte_member_heap.h
> > index 9c4a01aebe95..ab6319bc2de4 100644
> > --- a/lib/member/rte_member_heap.h
> > +++ b/lib/member/rte_member_heap.h
> > @@ -26,7 +26,7 @@ struct hash {
> > uint16_t bkt_cnt;
> > uint16_t num_item;
> > uint32_t seed;
> > -   struct hash_bkt buckets[0];
> > +   struct hash_bkt buckets[];
> >  };
> >  
> >  struct node {
> > --   
> 
> i suppose arguably this series depends on the series Bruce is putting
> up defaulting the minimum C standard to C99 since technically that's the
> minimum needed for the flexible array members.
> 
> Series-acked-by: Tyler Retzlaff 
> 

There is already flex array usage in several places in DPDK.
Therefore this won't be raising the requirements.


Re: [PATCH 1/7] member: replace zero length array with flex array

2023-01-13 Thread Tyler Retzlaff
On Fri, Jan 13, 2023 at 04:36:10PM -0800, Stephen Hemminger wrote:
> On Fri, 13 Jan 2023 16:19:21 -0800
> Tyler Retzlaff  wrote:
> 
> > On Fri, Jan 13, 2023 at 01:51:59PM -0800, Stephen Hemminger wrote:
> > > Zero length arrays are GNU extension. Replace with
> > > standard flex array.
> > > 
> > > Signed-off-by: Stephen Hemminger 
> > > ---
> > >  lib/member/rte_member_heap.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/lib/member/rte_member_heap.h b/lib/member/rte_member_heap.h
> > > index 9c4a01aebe95..ab6319bc2de4 100644
> > > --- a/lib/member/rte_member_heap.h
> > > +++ b/lib/member/rte_member_heap.h
> > > @@ -26,7 +26,7 @@ struct hash {
> > >   uint16_t bkt_cnt;
> > >   uint16_t num_item;
> > >   uint32_t seed;
> > > - struct hash_bkt buckets[0];
> > > + struct hash_bkt buckets[];
> > >  };
> > >  
> > >  struct node {
> > > --   
> > 
> > i suppose arguably this series depends on the series Bruce is putting
> > up defaulting the minimum C standard to C99 since technically that's the
> > minimum needed for the flexible array members.
> > 
> > Series-acked-by: Tyler Retzlaff 
> > 
> 
> There is already flex array usage in several places in DPDK.
> Therefore this won't be raising the requirements.

agreed.


Re: [PATCH 6/7] enic: replace zero length array with flex array

2023-01-13 Thread John Daley (johndale)
Acked-by: John Daley 

From: Stephen Hemminger 
Date: Friday, January 13, 2023 at 1:52 PM
To: dev@dpdk.org 
Cc: Stephen Hemminger , John Daley (johndale) 
, Hyong Youb Kim (hyonkim) 
Subject: [PATCH 6/7] enic: replace zero length array with flex array
Zero length arrays are GNU extension. Replace with
standard flex array.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/enic/base/vnic_devcmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/enic/base/vnic_devcmd.h 
b/drivers/net/enic/base/vnic_devcmd.h
index 253a791c3f65..f91cc3078d63 100644
--- a/drivers/net/enic/base/vnic_devcmd.h
+++ b/drivers/net/enic/base/vnic_devcmd.h
@@ -765,7 +765,7 @@ struct vnic_devcmd_notify {
 struct vnic_devcmd_provinfo {
 uint8_t oui[3];
 uint8_t type;
-   uint8_t data[0];
+   uint8_t data[];
 };

 /*
--
2.39.0


[PATCH v6 0/1] Add support AVX512 split queue datapath

2023-01-13 Thread Wenjun Wu
This patchset enables AVX512 data path for split queue model.

It is based on the below two pathsets

1. 
https://patches.dpdk.org/project/dpdk/cover/20230106090501.9106-1-beilei.x...@intel.com/
2. 
https://patches.dpdk.org/project/dpdk/cover/20230106091627.13530-1-beilei.x...@intel.com/

v3: fix logical error.
v4: rebase to the new baseline.
v5: fix compilation error.
v6: remove unexpected changes.

Wenjun Wu (1):
  common/idpf: add AVX512 data path for split queue model

 drivers/common/idpf/idpf_common_rxtx.c|  22 +-
 drivers/common/idpf/idpf_common_rxtx.h|  19 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 797 +-
 drivers/common/idpf/version.map   |   5 +-
 drivers/net/idpf/idpf_rxtx.c  |  46 +-
 drivers/net/idpf/idpf_rxtx_vec_common.h   |  53 +-
 6 files changed, 888 insertions(+), 54 deletions(-)

-- 
2.34.1



[PATCH v6 1/1] common/idpf: add AVX512 data path for split queue model

2023-01-13 Thread Wenjun Wu
Add support of AVX512 data path for split queue model.

Signed-off-by: Wenjun Wu 
Reviewed-by: Wenjing Qiao 
Acked-by: Wenzhuo Lu 
---
 drivers/common/idpf/idpf_common_rxtx.c|  22 +-
 drivers/common/idpf/idpf_common_rxtx.h|  19 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 797 +-
 drivers/common/idpf/version.map   |   5 +-
 drivers/net/idpf/idpf_rxtx.c  |  46 +-
 drivers/net/idpf/idpf_rxtx_vec_common.h   |  53 +-
 6 files changed, 888 insertions(+), 54 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_rxtx.c 
b/drivers/common/idpf/idpf_common_rxtx.c
index d1fa5884db..3a9a32 100644
--- a/drivers/common/idpf/idpf_common_rxtx.c
+++ b/drivers/common/idpf/idpf_common_rxtx.c
@@ -161,6 +161,9 @@ reset_split_rx_bufq(struct idpf_rx_queue *rxq)
/* The number of descriptors which can be refilled. */
rxq->nb_rx_hold = rxq->nb_rx_desc - 1;
 
+   rxq->rxrearm_nb = 0;
+   rxq->rxrearm_start = 0;
+
rxq->bufq1 = NULL;
rxq->bufq2 = NULL;
 }
@@ -236,6 +239,10 @@ reset_split_tx_descq(struct idpf_tx_queue *txq)
txq->last_desc_cleaned = 0;
txq->sw_tail = 0;
txq->nb_free = txq->nb_tx_desc - 1;
+
+   memset(txq->ctype, 0, sizeof(txq->ctype));
+   txq->next_dd = txq->rs_thresh - 1;
+   txq->next_rs = txq->rs_thresh - 1;
 }
 
 void
@@ -1428,12 +1435,12 @@ release_rxq_mbufs_vec(struct idpf_rx_queue *rxq)
memset(rxq->sw_ring, 0, sizeof(rxq->sw_ring[0]) * rxq->nb_rx_desc);
 }
 
-static const struct idpf_rxq_ops def_singleq_rx_ops_vec = {
+static const struct idpf_rxq_ops def_rx_ops_vec = {
.release_mbufs = release_rxq_mbufs_vec,
 };
 
 static inline int
-idpf_singleq_rx_vec_setup_default(struct idpf_rx_queue *rxq)
+idpf_rxq_vec_setup_default(struct idpf_rx_queue *rxq)
 {
uintptr_t p;
struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
@@ -1453,6 +1460,13 @@ idpf_singleq_rx_vec_setup_default(struct idpf_rx_queue 
*rxq)
 int __rte_cold
 idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq)
 {
-   rxq->ops = &def_singleq_rx_ops_vec;
-   return idpf_singleq_rx_vec_setup_default(rxq);
+   rxq->ops = &def_rx_ops_vec;
+   return idpf_rxq_vec_setup_default(rxq);
+}
+
+int __rte_cold
+idpf_splitq_rx_vec_setup(struct idpf_rx_queue *rxq)
+{
+   rxq->bufq2->ops = &def_rx_ops_vec;
+   return idpf_rxq_vec_setup_default(rxq->bufq2);
 }
diff --git a/drivers/common/idpf/idpf_common_rxtx.h 
b/drivers/common/idpf/idpf_common_rxtx.h
index 720025fbe1..d44d92101a 100644
--- a/drivers/common/idpf/idpf_common_rxtx.h
+++ b/drivers/common/idpf/idpf_common_rxtx.h
@@ -52,6 +52,8 @@
 #define IDPF_VPMD_TX_MAX_BURST 32
 #define IDPF_VPMD_DESCS_PER_LOOP   4
 #define IDPF_RXQ_REARM_THRESH  64
+#define IDPD_TXQ_SCAN_CQ_THRESH64
+#define IDPF_TX_CTYPE_NUM  8
 
 /* MTS */
 #define GLTSYN_CMD_SYNC_0_0(PF_TIMESYNC_BASE + 0x0)
@@ -185,6 +187,7 @@ struct idpf_tx_queue {
uint32_t tx_start_qid;
uint8_t expected_gen_id;
struct idpf_tx_queue *complq;
+   uint16_t ctype[IDPF_TX_CTYPE_NUM];
 };
 
 /* Offload features */
@@ -203,6 +206,12 @@ struct idpf_tx_vec_entry {
struct rte_mbuf *mbuf;
 };
 
+union idpf_tx_desc {
+   struct idpf_base_tx_desc *tx_ring;
+   struct idpf_flex_tx_sched_desc *desc_ring;
+   struct idpf_splitq_tx_compl_desc *compl_ring;
+};
+
 struct idpf_rxq_ops {
void (*release_mbufs)(struct idpf_rx_queue *rxq);
 };
@@ -265,14 +274,22 @@ uint16_t idpf_prep_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts,
 __rte_internal
 int idpf_singleq_rx_vec_setup(struct idpf_rx_queue *rxq);
 __rte_internal
-int idpf_singleq_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
+int idpf_splitq_rx_vec_setup(struct idpf_rx_queue *rxq);
+__rte_internal
+int idpf_tx_vec_setup_avx512(struct idpf_tx_queue *txq);
 __rte_internal
 uint16_t idpf_singleq_recv_pkts_avx512(void *rx_queue,
   struct rte_mbuf **rx_pkts,
   uint16_t nb_pkts);
 __rte_internal
+uint16_t idpf_splitq_recv_pkts_avx512(void *tx_queue, struct rte_mbuf 
**tx_pkts,
+ uint16_t nb_pkts);
+__rte_internal
 uint16_t idpf_singleq_xmit_pkts_avx512(void *tx_queue,
   struct rte_mbuf **tx_pkts,
   uint16_t nb_pkts);
+__rte_internal
+uint16_t idpf_splitq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf 
**tx_pkts,
+ uint16_t nb_pkts);
 
 #endif /* _IDPF_COMMON_RXTX_H_ */
diff --git a/drivers/common/idpf/idpf_common_rxtx_avx512.c 
b/drivers/common/idpf/idpf_common_rxtx_avx512.c
index 6ae0e14d2f..8ca2bd0dc3 100644
--- a/drivers/common/idpf/idpf_common_rxtx_avx512.c
+++ b/drivers/common/idpf/idpf_common_rxtx_avx512.c
@@ -539,8 +539,462 @@ idpf_singleq_recv_pkts_avx512(void *rx_queue, struct 
rte_mbuf **rx_pkts,