RE: [EXT] [PATCH v2 0/2] crypto/scheduler: add support for security protocols

2023-09-13 Thread Anoob Joseph
Hi David,

Please see inline.

Thanks,
Anoob

> -Original Message-
> From: Coyle, David 
> Sent: Monday, September 11, 2023 9:32 PM
> To: Anoob Joseph ; dev@dpdk.org
> Cc: Ji, Kai ; O'Sullivan, Kevin ;
> Jerin Jacob Kollanukkaran 
> Subject: RE: [EXT] [PATCH v2 0/2] crypto/scheduler: add support for security
> protocols
> 
> Hi Anoob,
> 
> Thank you for that feedback - I was on extended leave so only just getting
> back to it now.
> See replies below.
> 
> Regards,
> David
> 
> > -Original Message-
> > From: Anoob Joseph 
> > Sent: Friday, August 11, 2023 12:09 PM
> > To: Coyle, David ; dev@dpdk.org
> > Cc: Ji, Kai ; O'Sullivan, Kevin
> > ; Jerin Jacob Kollanukkaran
> > 
> > Subject: RE: [EXT] [PATCH v2 0/2] crypto/scheduler: add support for
> > security protocols
> >
> > Hi David,
> >
> > While it is desirable to add security under crypto/scheduler, would it
> > be functionally possible if the PMDs perform stateful processing? For
> > example, with lookaside protocol mode of IPsec, fields such as seq no
> > & AR defines how the crypto operation can be performed. Without two
> > PMDs sharing this (actively), how can the load balancing happen?
> 
> [DC] So if some fields such as seq numbers are maintained within the PMDs
> for some protocols, then yes you are right - this would not work without
> some synchronization across PMD instances which I think we'd want to avoid
> at this point.
> 
> I tried to find some cases where a crypto PMD that supports IPSec, for
> example, maintains some global stateful parameters, but I could not find
> these cases.
> I'm not at all familiar with these PMDs (cnxk, mvsam, dpaa_sec, dpaa2_sec)
> though, so maybe you could guide me as to where they are maintained?

[Anoob] I can comment about cnxk. 

In cn9k, PMD updates the states.
https://elixir.bootlin.com/dpdk/v23.07/source/drivers/crypto/cnxk/cn9k_ipsec_la_ops.h#L177

In cn10k, hw updates the states. Please check the corresponding fields,
https://elixir.bootlin.com/dpdk/v23.07/source/drivers/common/cnxk/roc_ie_ot.h#L258

> 
> >
> > Said that, I agree utility of scheduler for stateless operations. My
> > understanding is, PDCP offload that is available today is not stateful
> > and that can leverage this. I'm not sure of DOCSIS and MACsec.
> 
> [DC] I notice that the PDCP security xform struct has a seq number related
> field, which would also suggest it could be stateful, but I could be wrong.

[Anoob] The field there is seq no size. That is not stateful. But then, it has 
HFN field which is the upper few bits of seq no. It is unclear if HFN is 
expected to be incremented when lower bits overflow. May be it's better PDCP is 
also left unsupported. I'll let Hemanth confirm.

> 
> From a google search MACSec is stateless, but again I'm not an expert.
> 
> The protocol I am familiar with is DOCSIS, and it is for this protocol that we
> have added security support to the cryptodev scheduler.
> DOCSIS is 100% stateless, so will work no problem with the scheduler.
> 
> >
> > Should we make it such that only specific security sessions would be
> > eligible for scheduler operation?
> 
> [DC] Do you think it would be acceptable to limit the scheduler to the DOCSIS
> protocol only for now, and let the IPSec, MACSec and PDCP experts add
> these later if applicable?
> If you think this would be ok, I can easily make that change.

[Anoob] I think that would be a good approach. For any stateless protocols, 
addition of crypto scheduler is a huge plus.

> 
> >
> > Thanks,
> > Anoob
> >
> > > -Original Message-
> > > From: David Coyle 
> > > Sent: Friday, August 11, 2023 3:54 PM
> > > To: dev@dpdk.org
> > > Cc: kai...@intel.com; kevin.osulli...@intel.com; David Coyle
> > > 
> > > Subject: [EXT] [PATCH v2 0/2] crypto/scheduler: add support for
> > > security protocols
> > >
> > > External Email
> > >
> > > 
> > > -- This patchset adds support to the cryptodev scheduler PMD and
> > > unit tests for the existing security protocols in the security
> > > library, namely IPSec, MACSec, PDCP and DOCSIS.
> > >
> > > v2:
> > > * Improve inclusion of rte_security header files
> > > * Fix typo in commit message
> > >
> > > David Coyle (2):
> > >   crypto/scheduler: support security protocols
> > >   test/crypto: add security tests for cryptodev scheduler
> > >
> > >  app/test/test_cryptodev.c |  14 +-
> > >  doc/guides/rel_notes/release_23_11.rst|   3 +
> > >  drivers/crypto/scheduler/meson.build  |   2 +-
> > >  .../scheduler/rte_cryptodev_scheduler.c   | 229 ++-
> > >  drivers/crypto/scheduler/scheduler_failover.c |  12 +-
> > >  .../crypto/scheduler/scheduler_multicore.c|  10 +-
> > >  .../scheduler/scheduler_pkt_size_distr.c  |  54 +--
> > >  drivers/crypto/scheduler/scheduler_pmd.c  |  33 ++
> > >  drivers/crypto/scheduler/scheduler_pmd_ops.c  | 375
> > > +- .../crypto/scheduler

Re: [PATCH 1/1] test/hash: fix error log output

2023-09-13 Thread Stephen Hemminger
On Tue, 12 Sep 2023 19:52:39 +0800
Min Zhou  wrote:

> diff --git a/app/test/test_hash_readwrite.c
> b/app/test/test_hash_readwrite.c index 74ca13912f..4997a01249 100644
> --- a/app/test/test_hash_readwrite.c
> +++ b/app/test/test_hash_readwrite.c
> @@ -162,7 +162,7 @@ init_params(int use_ext, int use_htm, int rw_lf,
> int use_jhash) 
>   handle = rte_hash_create(&hash_params);
>   if (handle == NULL) {
> - printf("hash creation failed");
> + printf("hash creation failed\n");

Errors should be writen to stderr, not stdout?
It looks like the hash test doesn't do that anywhere though.


RE: [PATCH v3] common/idpf: refactor single queue Tx function

2023-09-13 Thread Zhang, Qi Z



> -Original Message-
> From: Wu, Wenjun1 
> Sent: Wednesday, September 13, 2023 1:57 PM
> To: Su, Simei ; Wu, Jingjing ;
> Xing, Beilei ; Zhang, Qi Z 
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v3] common/idpf: refactor single queue Tx function
> 
> 
> 
> > -Original Message-
> > From: Su, Simei 
> > Sent: Friday, September 8, 2023 6:28 PM
> > To: Wu, Jingjing ; Xing, Beilei
> > ; Zhang, Qi Z 
> > Cc: dev@dpdk.org; Wu, Wenjun1 ; Su, Simei
> > 
> > Subject: [PATCH v3] common/idpf: refactor single queue Tx function
> >
> > This patch replaces flex Tx descriptor with base Tx descriptor to
> > align with kernel driver practice.
> >
> > Signed-off-by: Simei Su 
> > ---
> > v3:
> > * Change context TSO descriptor from base mode to flex mode.
> >
> > v2:
> > * Refine commit title and commit log.
> > * Remove redundant definition.
> > * Modify base mode context TSO descriptor.
> >
> >  drivers/common/idpf/idpf_common_rxtx.c| 39 +--
> >  drivers/common/idpf/idpf_common_rxtx.h|  2 +-
> >  drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +-
> >  drivers/net/idpf/idpf_rxtx.c  |  2 +-
> >  4 files changed, 39 insertions(+), 41 deletions(-)
> >
> > diff --git a/drivers/common/idpf/idpf_common_rxtx.c
> > b/drivers/common/idpf/idpf_common_rxtx.c
> > index fc87e3e243..e6d2486272 100644
> > --- a/drivers/common/idpf/idpf_common_rxtx.c
> > +++ b/drivers/common/idpf/idpf_common_rxtx.c
> > @@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct
> > idpf_tx_queue *txq)
> > }
> >
> > txe = txq->sw_ring;
> > -   size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
> > +   size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
> > for (i = 0; i < size; i++)
> > ((volatile char *)txq->tx_ring)[i] = 0;
> >
> > prev = (uint16_t)(txq->nb_tx_desc - 1);
> > for (i = 0; i < txq->nb_tx_desc; i++) {
> > -   txq->tx_ring[i].qw1.cmd_dtype =
> > -
> > rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
> > +   txq->tx_ring[i].qw1 =
> > +
> > rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
> > txe[i].mbuf =  NULL;
> > txe[i].last_id = i;
> > txe[prev].next_id = i;
> > @@ -1307,17 +1307,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
> > uint16_t nb_tx_to_clean;
> > uint16_t i;
> >
> > -   volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
> > +   volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
> >
> > desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->rs_thresh);
> > if (desc_to_clean_to >= nb_tx_desc)
> > desc_to_clean_to = (uint16_t)(desc_to_clean_to -
> nb_tx_desc);
> >
> > desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
> > -   /* In the writeback Tx desccriptor, the only significant fields are the 
> > 4-
> > bit DTYPE */
> > -   if ((txd[desc_to_clean_to].qw1.cmd_dtype &
> > -rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
> > -   rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
> > +   if ((txd[desc_to_clean_to].qw1 &
> > +rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
> > +   rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
> > TX_LOG(DEBUG, "TX descriptor %4u is not done "
> >"(port=%d queue=%d)", desc_to_clean_to,
> >txq->port_id, txq->queue_id); @@ -1331,10 +1330,7 @@
> > idpf_xmit_cleanup(struct idpf_tx_queue *txq)
> > nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
> > last_desc_cleaned);
> >
> > -   txd[desc_to_clean_to].qw1.cmd_dtype = 0;
> > -   txd[desc_to_clean_to].qw1.buf_size = 0;
> > -   for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
> > -   txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
> > +   txd[desc_to_clean_to].qw1 = 0;
> >
> > txq->last_desc_cleaned = desc_to_clean_to;
> > txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean); @@ -
> > 1347,8 +1343,8 @@ uint16_t  idpf_dp_singleq_xmit_pkts(void *tx_queue,
> > struct rte_mbuf **tx_pkts,
> >   uint16_t nb_pkts)
> >  {
> > -   volatile struct idpf_flex_tx_desc *txd;
> > -   volatile struct idpf_flex_tx_desc *txr;
> > +   volatile struct idpf_base_tx_desc *txd;
> > +   volatile struct idpf_base_tx_desc *txr;
> > union idpf_tx_offload tx_offload = {0};
> > struct idpf_tx_entry *txe, *txn;
> > struct idpf_tx_entry *sw_ring;
> > @@ -1356,6 +1352,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,
> struct
> > rte_mbuf **tx_pkts,
> > struct rte_mbuf *tx_pkt;
> > struct rte_mbuf *m_seg;
> > uint64_t buf_dma_addr;
> > +   uint32_t td_offset;
> > uint64_t ol_flags;
> > uint16_t tx_last;
> > uint16_t nb_used;
> > @@ -1382,6 +1379,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,
> struct
> > rte_mbuf **tx_pkts,
> >
> > for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
> > td_cmd = 0;
> > +   td_offset = 0;
> >
> > t

[PATCH] bus/pci: fix device ID print

2023-09-13 Thread Qiming Yang
This patch fixes the issue where device id first 0 does not print.

Fixes: e4f27af0f448 ("bus/pci: reduce boot-up logs to absolute minimum")
Cc: sta...@dpdk.org

Signed-off-by: Qiming Yang 
---
 drivers/bus/pci/pci_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 52404ab0fe..6605d0647d 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -304,7 +304,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
}
}
 
-   RTE_LOG(INFO, EAL, "Probe PCI driver: %s (%x:%x) device: "PCI_PRI_FMT" 
(socket %i)\n",
+   RTE_LOG(INFO, EAL, "Probe PCI driver: %s (%x:%04x) device: 
"PCI_PRI_FMT" (socket %i)\n",
dr->driver.name, dev->id.vendor_id, dev->id.device_id,
loc->domain, loc->bus, loc->devid, loc->function,
dev->device.numa_node);
-- 
2.25.1



[PATCH] net/ice: fix initail link status issue

2023-09-13 Thread Qiming Yang
This patch fixed the issue which the link status still up
when the link status changed from up to downi after device
restart.

Fixes: fdcf92ed6637 ("net/ice: fix link status recovery")
Cc: sta...@dpdk.org

Signed-off-by: Qiming Yang 
---
 drivers/net/ice/ice_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 4bad39c2c1..ed9771be1c 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3646,6 +3646,8 @@ ice_get_init_link_status(struct rte_eth_dev *dev)
 
if (link_status.link_info & ICE_AQ_LINK_UP)
pf->init_link_up = true;
+   else
+   pf->init_link_up = false;
 }
 
 static int
-- 
2.25.1



Re: [PATCH 1/1] test/hash: fix error log output

2023-09-13 Thread zhoumin



On Wed, Sep 13, 2023 at 3:30PM, Stephen Hemminger wrote:

On Tue, 12 Sep 2023 19:52:39 +0800
Min Zhou  wrote:


diff --git a/app/test/test_hash_readwrite.c
b/app/test/test_hash_readwrite.c index 74ca13912f..4997a01249 100644
--- a/app/test/test_hash_readwrite.c
+++ b/app/test/test_hash_readwrite.c
@@ -162,7 +162,7 @@ init_params(int use_ext, int use_htm, int rw_lf,
int use_jhash)
handle = rte_hash_create(&hash_params);
if (handle == NULL) {
-   printf("hash creation failed");
+   printf("hash creation failed\n");

Errors should be writen to stderr, not stdout?
It looks like the hash test doesn't do that anywhere though.


Agree! The errors should go to stderr. However, there are many such 
cases in app/test that errors were written to stderr.  It requires huge 
effort to fix them.


Regards,

Min




RE: [PATCH v2 5/5] devtools: ignore changes into bbdev experimental API

2023-09-13 Thread Hemant Agrawal
Acked-by: Hemant Agrawal 

> -Original Message-
> From: Vargas, Hernan 
> Sent: Wednesday, September 13, 2023 2:03 AM
> To: Hemant Agrawal ; Chautru, Nicolas
> ; dev@dpdk.org; maxime.coque...@redhat.com
> Cc: Rix, Tom ; david.march...@redhat.com
> Subject: RE: [PATCH v2 5/5] devtools: ignore changes into bbdev experimental
> API
> Importance: High
> 
> Hi Hemant,
> 
> Your previous ack was under the [PATCH v2 0/5] email.
> Could you please place your ack for the patch under this email?
> 
> Thanks,
> Hernan
> 
> Acked-by: Hernan Vargas 
> 
> > -Original Message-
> > From: Hemant Agrawal 
> > Sent: Wednesday, September 6, 2023 1:17 AM
> > To: Chautru, Nicolas ; dev@dpdk.org;
> > maxime.coque...@redhat.com
> > Cc: Rix, Tom ; hemant.agra...@nxp.com;
> > david.march...@redhat.com; Vargas, Hernan 
> > Subject: Re: [PATCH v2 5/5] devtools: ignore changes into bbdev
> > experimental API
> >
> >
> > On 15-Jun-23 10:19 PM, Nicolas Chautru wrote:
> > > Caution: This is an external email. Please take care when clicking
> > > links or opening attachments. When in doubt, report the message
> > > using the 'Report this email' button
> > >
> > >
> > > Developpers are warned that the related fft experimental functions
> > > do not preserve ABI, hence these can be waived.
> > %s/Developpers/Developers
> > >
> > > Signed-off-by: Nicolas Chautru 
> > > ---
> > >   devtools/libabigail.abignore | 4 +++-
> > >   1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/devtools/libabigail.abignore
> > > b/devtools/libabigail.abignore index 7a93de3ba1..09b8f156b5 100644
> > > --- a/devtools/libabigail.abignore
> > > +++ b/devtools/libabigail.abignore
> > > @@ -30,7 +30,9 @@
> > >   [suppress_type]
> > >   type_kind = enum
> > >   changed_enumerators = RTE_CRYPTO_ASYM_XFORM_ECPM,
> > > RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END
> > > -
> > > +; Ignore changes to bbdev FFT API which is experimental
> > > +[suppress_type]
> > > +name = rte_bbdev_fft_op
> > >   
> > >   ; Temporary exceptions till next major ABI version ;
> > >   
> > > --
> > > 2.34.1
> > >


[PATCH v2 00/11] rework thread management

2023-09-13 Thread Thomas Monjalon
The main effect of this patch series is to
remove calls to pthread functions except for pthread_cancel and locks.

The function rte_thread_create_control() does not take thread attributes
settings anymore as it looks a useless complication of the API.
Then the rte_thread API is made stable,
so we can remove the old deprecated functions
rte_thread_setname() and rte_ctrl_thread_create().

Some new internal functions are added in rte_thread to make sure
all internal thread names are prefixed with "dpdk-".

Few other cleanups are done.

Future work about pthread portability are about:
  - cancel
  - mutex

---

v2 changes:
- replace (|_) with _? in checkpatch
- simplify thread name size doc
- build time check of internal thread name size
- clean control thread params struct


Thomas Monjalon (11):
  devtools: warn when adding some pthread calls
  eal: rename thread name length definition
  eal: remove attributes from control thread creation
  eal: promote thread API as stable
  eal: force prefix for internal threads
  lib: convert to internal control threads
  drivers: convert to internal control threads
  examples: convert to normal control threads
  test: convert threads creation
  eal: remove deprecated thread functions
  lib: remove pthread.h from includes

 app/test/process.h|  10 +-
 app/test/test_lcores.c|   9 +-
 app/test/test_link_bonding.c  |   2 +
 app/test/test_pdump.c |   6 +-
 app/test/test_pdump.h |   2 +-
 app/test/test_threads.c   |   2 +-
 devtools/checkpatches.sh  |  16 +++
 .../prog_guide/env_abstraction_layer.rst  |   2 +-
 doc/guides/rel_notes/deprecation.rst  |   5 -
 doc/guides/rel_notes/release_23_11.rst|   6 +
 drivers/common/cnxk/roc_dev.c |  16 +--
 drivers/common/cnxk/roc_dev_priv.h|   2 +-
 drivers/common/cnxk/roc_nix_inl_dev.c |   9 +-
 drivers/common/cnxk/roc_nix_inl_priv.h|   2 +-
 drivers/common/cnxk/roc_platform.h|   3 +-
 drivers/common/mlx5/mlx5_common.c |   1 +
 drivers/common/mlx5/windows/mlx5_win_ext.h|   2 +
 drivers/dma/skeleton/skeleton_dmadev.c|   8 +-
 drivers/event/dlb2/pf/base/dlb2_osdep.h   |  14 +-
 drivers/event/dlb2/pf/base/dlb2_resource.c|  39 ++---
 drivers/event/dlb2/pf/dlb2_main.h |   1 -
 drivers/net/ark/ark_ethdev.c  |  11 +-
 drivers/net/ark/ark_pktgen.c  |   8 +-
 drivers/net/ark/ark_pktgen.h  |   2 +-
 drivers/net/bnxt/bnxt.h   |   1 +
 drivers/net/iavf/iavf_vchnl.c |   4 +-
 drivers/net/ice/ice_dcf_parent.c  |   7 +-
 drivers/net/ipn3ke/ipn3ke_representor.c   |  17 ++-
 drivers/net/ixgbe/ixgbe_ethdev.c  |   8 +-
 drivers/net/mlx5/mlx5.h   |   2 +-
 drivers/net/mlx5/mlx5_hws_cnt.c   |  42 +++---
 drivers/net/qede/base/bcm_osal.h  |   1 +
 drivers/net/sfc/sfc_mae.h |   2 +-
 drivers/net/sfc/sfc_mae_counter.c |  11 +-
 drivers/net/txgbe/txgbe_ethdev.c  |   6 +-
 drivers/raw/ifpga/base/opae_osdep.h   |   1 +
 drivers/raw/ifpga/ifpga_rawdev.c  |  19 ++-
 drivers/vdpa/ifc/ifcvf_vdpa.c |  86 ++-
 drivers/vdpa/mlx5/mlx5_vdpa.c |   2 +-
 drivers/vdpa/mlx5/mlx5_vdpa.h |  10 +-
 drivers/vdpa/mlx5/mlx5_vdpa_cthread.c |  70 +++--
 drivers/vdpa/mlx5/mlx5_vdpa_event.c   |  64 +++--
 drivers/vdpa/sfc/sfc_vdpa.c   |   1 +
 drivers/vdpa/sfc/sfc_vdpa_ops.c   |  15 +-
 drivers/vdpa/sfc/sfc_vdpa_ops.h   |   3 +-
 examples/vhost/main.c |   9 +-
 examples/vhost_blk/vhost_blk.c|  21 +--
 lib/eal/common/eal_common_options.c   |   1 +
 lib/eal/common/eal_common_proc.c  |  15 +-
 lib/eal/common/eal_common_thread.c| 127 ++---
 lib/eal/common/eal_common_trace.c |   1 +
 lib/eal/common/malloc_mp.c|   1 +
 lib/eal/freebsd/eal.c |   2 +-
 lib/eal/freebsd/eal_alarm.c   |   1 +
 lib/eal/freebsd/eal_interrupts.c  |  10 +-
 lib/eal/freebsd/eal_thread.c  |   9 +-
 lib/eal/include/rte_eal.h |   3 -
 lib/eal/include/rte_lcore.h   |  42 --
 lib/eal/include/rte_per_lcore.h   |   2 -
 lib/eal/include/rte_thread.h  | 133 +-
 lib/eal/linux/eal.c   |   2 +-
 lib/eal/linux/eal_alarm.c |   1 +
 lib/eal/linux/eal_interrupts.c|  10 +-
 lib/eal/linux/eal_thread.c|  18 +--
 lib/eal/linux/eal_timer.c |  11 +-
 lib/eal/un

[PATCH v2 01/11] devtools: warn when adding some pthread calls

2023-09-13 Thread Thomas Monjalon
All pthread functions below have an equivalent in rte_thread API:
- pthread_create
- pthread_join
- pthread_detach
- pthread_setname_np
- pthread_set_name_np
- pthread_setaffinity_np
- pthread_attr_setinheritsched
- pthread_attr_setschedpolicy
Usage of these functions will be raised to encourage rte_thread adoption.

The pthread functions for locks and cancel are still allowed.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 

---
v2: replace (|_) with _?
---
 devtools/checkpatches.sh | 8 
 1 file changed, 8 insertions(+)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 55fabc5458..ec9d232393 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -119,6 +119,14 @@ check_forbidden_additions() { # 
-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
"$1" || res=1
 
+   # refrain from using some pthread functions
+   awk -v FOLDERS="lib drivers app examples" \
+   -v 
EXPRESSIONS="pthread_(create|join|detach|set(_?name_np|affinity_np)|attr_set(inheritsched|schedpolicy))\\\("
 \
+   -v RET_ON_FAIL=1 \
+   -v MESSAGE='Using pthread functions, prefer rte_thread' \
+   -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+   "$1" || res=1
+
# forbid use of __reserved which is a reserved keyword in Windows 
system headers
awk -v FOLDERS="lib drivers app examples" \
-v EXPRESSIONS='\\<__reserved\\>' \
-- 
2.42.0



[PATCH v2 02/11] eal: rename thread name length definition

2023-09-13 Thread Thomas Monjalon
RTE_MAX_THREAD_NAME_LEN is including the NUL character,
so it should be named "size" instead of "length".
A new constant RTE_THREAD_NAME_SIZE is introduced for naming accuracy.
For API compatibility, the old name is kept.

At the same time, the original definition is moved
from rte_eal.h to rte_thread.h.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 lib/eal/freebsd/eal.c| 2 +-
 lib/eal/freebsd/eal_thread.c | 2 +-
 lib/eal/include/rte_eal.h| 3 ---
 lib/eal/include/rte_thread.h | 9 +++--
 lib/eal/linux/eal.c  | 2 +-
 lib/eal/linux/eal_thread.c   | 2 +-
 lib/eal/windows/eal.c| 2 +-
 lib/eal/windows/rte_thread.c | 2 +-
 8 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 9e1e267955..39a2868523 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -583,7 +583,7 @@ rte_eal_init(int argc, char **argv)
static uint32_t run_once;
uint32_t has_run = 0;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
-   char thread_name[RTE_MAX_THREAD_NAME_LEN];
+   char thread_name[RTE_THREAD_NAME_SIZE];
const struct rte_config *config = rte_eal_get_configuration();
struct internal_config *internal_conf =
eal_get_internal_configuration();
diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c
index 3227d9b8a2..ba9b25c2c0 100644
--- a/lib/eal/freebsd/eal_thread.c
+++ b/lib/eal/freebsd/eal_thread.c
@@ -34,7 +34,7 @@ int rte_sys_gettid(void)
 
 void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name)
 {
-   char truncated[RTE_MAX_THREAD_NAME_LEN];
+   char truncated[RTE_THREAD_NAME_SIZE];
const size_t truncatedsz = sizeof(truncated);
 
if (strlcpy(truncated, thread_name, truncatedsz) >= truncatedsz)
diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h
index 53c4a5519e..cd318ee141 100644
--- a/lib/eal/include/rte_eal.h
+++ b/lib/eal/include/rte_eal.h
@@ -27,9 +27,6 @@ extern "C" {
 
 #define RTE_MAGIC 19820526 /**< Magic number written by the main partition 
when ready. */
 
-/* Maximum thread_name length. */
-#define RTE_MAX_THREAD_NAME_LEN 16
-
 /**
  * The type of process in a linux, multi-process setup
  */
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 369e2375f6..6233142322 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -23,6 +23,11 @@
 extern "C" {
 #endif
 
+/** Maximum thread name length (including '\0'). */
+#define RTE_THREAD_NAME_SIZE 16
+/* Old definition, aliased for compatibility. */
+#define RTE_MAX_THREAD_NAME_LEN RTE_THREAD_NAME_SIZE
+
 /**
  * Thread id descriptor.
  */
@@ -110,7 +115,7 @@ int rte_thread_create(rte_thread_t *thread_id,
  *   Filled with the thread id of the new created thread.
  * @param name
  *   The name of the control thread
- *   (max RTE_MAX_THREAD_NAME_LEN characters including '\0').
+ *   (max RTE_THREAD_NAME_SIZE characters including '\0').
  * @param thread_attr
  *   Attributes for the new thread.
  * @param thread_func
@@ -188,7 +193,7 @@ rte_thread_t rte_thread_self(void);
  *The id of the thread to set name.
  *
  * @param thread_name
- *The name to set. Truncated to RTE_MAX_THREAD_NAME_LEN,
+ *The name to set. Truncated to RTE_THREAD_NAME_SIZE,
  *including terminating NUL if necessary.
  */
 __rte_experimental
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index a26822f667..5f4b2fb005 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -970,7 +970,7 @@ rte_eal_init(int argc, char **argv)
static uint32_t run_once;
uint32_t has_run = 0;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
-   char thread_name[RTE_MAX_THREAD_NAME_LEN];
+   char thread_name[RTE_THREAD_NAME_SIZE];
bool phys_addrs;
const struct rte_config *config = rte_eal_get_configuration();
struct internal_config *internal_conf =
diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c
index c07ad9d8a4..b9a126f3a8 100644
--- a/lib/eal/linux/eal_thread.c
+++ b/lib/eal/linux/eal_thread.c
@@ -24,7 +24,7 @@ void rte_thread_set_name(rte_thread_t thread_id, const char 
*thread_name)
int ret = ENOSYS;
 #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
 #if __GLIBC_PREREQ(2, 12)
-   char truncated[RTE_MAX_THREAD_NAME_LEN];
+   char truncated[RTE_THREAD_NAME_SIZE];
const size_t truncatedsz = sizeof(truncated);
 
if (strlcpy(truncated, thread_name, truncatedsz) >= truncatedsz)
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 16c1ba1596..7ec2152211 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -283,7 +283,7 @@ rte_eal_init(int argc, char **argv)
enum rte_iova_mode iova_mode;
int ret;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
-   char thread_name[RTE_MAX_THREAD_NAME_LEN];
+   char thread_name[RTE_THREAD_NAME_SIZE]

[PATCH v2 03/11] eal: remove attributes from control thread creation

2023-09-13 Thread Thomas Monjalon
The experimental function rte_thread_create_control()
is supposed to wrap actions needed to create a control thread in DPDK.
This function should be easy to port on any OS.

As such, the thread attributes should not be customizable in this API.
The thread priority should be normal, and the affinity is on "free cores".
That's why the custom attributes parameter thread_attr is dropped.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 app/test/test_threads.c| 2 +-
 doc/guides/rel_notes/release_23_11.rst | 3 +++
 drivers/dma/skeleton/skeleton_dmadev.c | 3 +--
 drivers/net/iavf/iavf_vchnl.c  | 2 +-
 drivers/net/ice/ice_dcf_parent.c   | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c   | 1 -
 drivers/net/txgbe/txgbe_ethdev.c   | 2 +-
 lib/eal/common/eal_common_thread.c | 5 ++---
 lib/eal/include/rte_thread.h   | 5 +
 lib/eal/windows/eal_interrupts.c   | 2 +-
 10 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/app/test/test_threads.c b/app/test/test_threads.c
index 8c27e2bae1..4ac3f2671a 100644
--- a/app/test/test_threads.c
+++ b/app/test/test_threads.c
@@ -240,7 +240,7 @@ test_thread_control_create_join(void)
 
thread_id_ready = 0;
RTE_TEST_ASSERT(rte_thread_create_control(&thread_id, "dpdk-test-thcc",
-   NULL, thread_main, &thread_main_id) == 0,
+   thread_main, &thread_main_id) == 0,
"Failed to create thread.");
 
while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
diff --git a/doc/guides/rel_notes/release_23_11.rst 
b/doc/guides/rel_notes/release_23_11.rst
index 333e1d95a2..d3d500f294 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -113,6 +113,9 @@ API Changes
Also, make sure to start the actual text at the margin.
===
 
+* eal: The thread API has changed.
+  The function ``rte_thread_create_control()`` does not take attributes 
anymore.
+
 
 ABI Changes
 ---
diff --git a/drivers/dma/skeleton/skeleton_dmadev.c 
b/drivers/dma/skeleton/skeleton_dmadev.c
index 493224542f..4fc2319668 100644
--- a/drivers/dma/skeleton/skeleton_dmadev.c
+++ b/drivers/dma/skeleton/skeleton_dmadev.c
@@ -128,8 +128,7 @@ skeldma_start(struct rte_dma_dev *dev)
rte_mb();
 
snprintf(name, sizeof(name), "dpdk-dma-skel%d", dev->data->dev_id);
-   ret = rte_thread_create_control(&hw->thread, name, NULL,
-cpucopy_thread, dev);
+   ret = rte_thread_create_control(&hw->thread, name, cpucopy_thread, dev);
if (ret) {
SKELDMA_LOG(ERR, "Start cpucopy thread fail!");
return -EINVAL;
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index c31a6d5c98..6baa6d5955 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -136,7 +136,7 @@ iavf_dev_event_handler_init(void)
pthread_mutex_init(&handler->lock, NULL);
 
if (rte_thread_create_control(&handler->tid, "dpdk-iavf-event",
-   NULL, iavf_dev_event_handle, NULL)) {
+   iavf_dev_event_handle, NULL)) {
__atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED);
return -1;
}
diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index ad98a531de..d3bb65874f 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -182,7 +182,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, 
uint16_t vf_id)
param->vf_id = vf_id;
 
snprintf(name, sizeof(name), "dpdk-ice-rst%u", vf_id);
-   ret = rte_thread_create_control(&thread, name, NULL,
+   ret = rte_thread_create_control(&thread, name,
 ice_dcf_vsi_update_service_handler, param);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to start the thread for reset 
handling");
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 7eac05ee60..64e7e5d7d6 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4330,7 +4330,6 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
if 
(rte_thread_create_control(&ad->link_thread_tid,
"dpdk-ixgbe-link",
-   NULL,
ixgbe_dev_setup_link_thread_handler,
dev) < 0) {
PMD_DRV_LOG(ERR,
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 6f2f5a1841..198fac8318 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ 

[PATCH v2 04/11] eal: promote thread API as stable

2023-09-13 Thread Thomas Monjalon
The rte_thread API must be used to ease OS porting.
One step of this process is to mark the necessary API as stable.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 doc/guides/rel_notes/release_23_11.rst |  1 +
 lib/eal/include/rte_thread.h   | 64 --
 lib/eal/version.map| 40 
 3 files changed, 20 insertions(+), 85 deletions(-)

diff --git a/doc/guides/rel_notes/release_23_11.rst 
b/doc/guides/rel_notes/release_23_11.rst
index d3d500f294..d7562fd646 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -115,6 +115,7 @@ API Changes
 
 * eal: The thread API has changed.
   The function ``rte_thread_create_control()`` does not take attributes 
anymore.
+  The whole thread API was promoted to stable level.
 
 
 ABI Changes
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 28cc5220a4..dd1f62523f 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -73,9 +73,6 @@ typedef struct {
 typedef struct eal_tls_key *rte_thread_key;
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Create a new thread that will invoke the 'thread_func' routine.
  *
  * @param thread_id
@@ -94,15 +91,11 @@ typedef struct eal_tls_key *rte_thread_key;
  *   On success, return 0.
  *   On failure, return a positive errno-style error number.
  */
-__rte_experimental
 int rte_thread_create(rte_thread_t *thread_id,
const rte_thread_attr_t *thread_attr,
rte_thread_func thread_func, void *arg);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Create a control thread.
  *
  * Creates a control thread with the given name and attributes. The
@@ -124,15 +117,11 @@ int rte_thread_create(rte_thread_t *thread_id,
  *   On success, returns 0; on error, it returns a negative value
  *   corresponding to the error number.
  */
-__rte_experimental
 int
 rte_thread_create_control(rte_thread_t *thread, const char *name,
rte_thread_func thread_func, void *arg);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Waits for the thread identified by 'thread_id' to terminate
  *
  * @param thread_id
@@ -145,13 +134,9 @@ rte_thread_create_control(rte_thread_t *thread, const char 
*name,
  *   On success, return 0.
  *   On failure, return a positive errno-style error number.
  */
-__rte_experimental
 int rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Indicate that the return value of the thread is not needed and
  * all thread resources should be release when the thread terminates.
  *
@@ -162,25 +147,17 @@ int rte_thread_join(rte_thread_t thread_id, uint32_t 
*value_ptr);
  *   On success, return 0.
  *   On failure, return a positive errno-style error number.
  */
-__rte_experimental
 int rte_thread_detach(rte_thread_t thread_id);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Get the id of the calling thread.
  *
  * @return
  *   Return the thread id of the calling thread.
  */
-__rte_experimental
 rte_thread_t rte_thread_self(void);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Set the name of the thread.
  * This API is a noop if the underlying platform does not
  * support setting the thread name or the platform-specific
@@ -193,14 +170,10 @@ rte_thread_t rte_thread_self(void);
  *The name to set. Truncated to RTE_THREAD_NAME_SIZE,
  *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
@@ -213,13 +186,9 @@ rte_thread_set_name(rte_thread_t thread_id, const char 
*thread_name);
  *   If the ids are equal, return nonzero.
  *   Otherwise, return 0.
  */
-__rte_experimental
 int rte_thread_equal(rte_thread_t t1, rte_thread_t t2);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Initialize the attributes of a thread.
  * These attributes can be passed to the rte_thread_create() function
  * that will create a new thread and set its attributes according to attr.
@@ -231,13 +200,9 @@ int rte_thread_equal(rte_thread_t t1, rte_thread_t t2);
  *   On success, return 0.
  *   On failure, return a positive errno-style error number.
  */
-__rte_experimental
 int rte_thread_attr_init(rte_thread_attr_t *attr);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Set the thread priority value in the thread attributes pointed to
  * by 'thread_attr'.
  *
@@ -251,16 +216,12 @@ int rte_thread_attr_i

[PATCH v2 05/11] eal: force prefix for internal threads

2023-09-13 Thread Thomas Monjalon
In order to make sure all threads created in DPDK drivers and libraries
have the same prefix in their name, some wrapper functions are added
for internal use when creating a control thread or setting a thread name:
- rte_thread_create_internal_control
- rte_thread_set_prefixed_name

The equivalent public functions are then forbidden for internal use:
- rte_thread_create_control
- rte_thread_set_name

Note: the libraries and drivers conversion is done in next patches,
while doing other thread-related changes.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 

---
v2: simplify size doc + build time check of internal name size
---
 devtools/checkpatches.sh   |  8 
 lib/eal/common/eal_common_thread.c | 29 +++
 lib/eal/include/rte_thread.h   | 59 +-
 lib/eal/version.map|  2 +
 4 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index ec9d232393..e97811192a 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -159,6 +159,14 @@ check_forbidden_additions() { # 
-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
"$1" || res=1
 
+   # forbid non-internal thread in drivers and libs
+   awk -v FOLDERS='lib drivers' \
+   -v EXPRESSIONS="rte_thread_(set_name|create_control)\\\(" \
+   -v RET_ON_FAIL=1 \
+   -v MESSAGE='Prefer 
rte_thread_(set_prefixed_name|create_internal_control) in lib & drivers' \
+   -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+   "$1" || res=1
+
# forbid inclusion of driver specific headers in apps and examples
awk -v FOLDERS='app examples' \
-v EXPRESSIONS='include.*_driver\\.h include.*_pmd\\.h' \
diff --git a/lib/eal/common/eal_common_thread.c 
b/lib/eal/common/eal_common_thread.c
index 07ac721da1..cd6e00fe8a 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -392,6 +392,35 @@ rte_thread_create_control(rte_thread_t *thread, const char 
*name,
return ret;
 }
 
+static void
+add_internal_prefix(char *prefixed_name, const char *name, size_t size)
+{
+   size_t prefixlen;
+
+   prefixlen = strlen(RTE_THREAD_INTERNAL_PREFIX);
+   strlcpy(prefixed_name, RTE_THREAD_INTERNAL_PREFIX, size);
+   strlcpy(prefixed_name + prefixlen, name, size - prefixlen);
+}
+
+int
+rte_thread_create_internal_control(rte_thread_t *id, const char *name,
+   rte_thread_func func, void *arg)
+{
+   char prefixed_name[RTE_THREAD_NAME_SIZE];
+
+   add_internal_prefix(prefixed_name, name, sizeof(prefixed_name));
+   return rte_thread_create_control(id, prefixed_name, func, arg);
+}
+
+void
+rte_thread_set_prefixed_name(rte_thread_t id, const char *name)
+{
+   char prefixed_name[RTE_THREAD_NAME_SIZE];
+
+   add_internal_prefix(prefixed_name, name, sizeof(prefixed_name));
+   rte_thread_set_name(id, prefixed_name);
+}
+
 int
 rte_thread_register(void)
 {
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index dd1f62523f..afede97bed 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -28,6 +28,13 @@ extern "C" {
 /* Old definition, aliased for compatibility. */
 #define RTE_MAX_THREAD_NAME_LEN RTE_THREAD_NAME_SIZE
 
+/** Thread name prefix automatically added to all internal threads. */
+#define RTE_THREAD_INTERNAL_PREFIX "dpdk-"
+/** Maximum internal thread name length (including '\0'). */
+#define RTE_THREAD_INTERNAL_NAME_SIZE 11
+RTE_BUILD_BUG_ON(RTE_THREAD_INTERNAL_NAME_SIZE !=
+   RTE_THREAD_NAME_SIZE - sizeof(RTE_THREAD_INTERNAL_PREFIX) + 1)
+
 /**
  * Thread id descriptor.
  */
@@ -112,7 +119,7 @@ int rte_thread_create(rte_thread_t *thread_id,
  * @param thread_func
  *   Function to be executed by the new thread.
  * @param arg
- *   Argument passed to start_routine.
+ *   Argument passed to thread_func.
  * @return
  *   On success, returns 0; on error, it returns a negative value
  *   corresponding to the error number.
@@ -121,6 +128,35 @@ int
 rte_thread_create_control(rte_thread_t *thread, const char *name,
rte_thread_func thread_func, void *arg);
 
+/**
+ * Create an internal control thread.
+ *
+ * Creates a control thread with the given name prefixed.
+ * If setting the name of the thread fails, the error is ignored and logged.
+ *
+ * The affinity of the new thread is based on the CPU affinity retrieved
+ * at the time rte_eal_init() was called, the EAL threads are then excluded.
+ *
+ * @param id
+ *   Filled with the thread ID of the new created thread.
+ * @param name
+ *   The name of the control thread.
+ *   See RTE_THREAD_INTERNAL_NAME_SIZE for maximum length.
+ *   The name of the driver or library should be first,
+ *   then followed by a hyphen and more details.

[PATCH v2 06/11] lib: convert to internal control threads

2023-09-13 Thread Thomas Monjalon
Calls to rte_ctrl_thread_create() are replaced with
rte_thread_create_internal_control().
Other pthread-related functions are replaced with the rte_thread API.
Only pthread_cancel() has no replacement.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 lib/eal/common/eal_common_proc.c| 15 ---
 lib/eal/freebsd/eal_interrupts.c| 10 +-
 lib/eal/linux/eal_interrupts.c  | 10 +-
 lib/eal/linux/eal_timer.c   | 11 ++-
 lib/eal/unix/rte_thread.c   |  2 +-
 lib/eal/windows/eal_interrupts.c|  2 +-
 lib/eventdev/rte_event_eth_rx_adapter.c | 23 ---
 lib/vhost/fd_man.c  |  6 +++---
 lib/vhost/fd_man.h  |  2 +-
 lib/vhost/socket.c  | 23 +++
 lib/vhost/vduse.c   |  5 +++--
 11 files changed, 56 insertions(+), 53 deletions(-)

diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c
index 26e6b78f8f..f20a348ede 100644
--- a/lib/eal/common/eal_common_proc.c
+++ b/lib/eal/common/eal_common_proc.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "eal_memcfg.h"
 #include "eal_private.h"
@@ -33,7 +34,7 @@
 #include "eal_internal_cfg.h"
 
 static int mp_fd = -1;
-static pthread_t mp_handle_tid;
+static rte_thread_t mp_handle_tid;
 static char mp_filter[PATH_MAX];   /* Filter for secondary process sockets */
 static char mp_dir_path[PATH_MAX]; /* The directory path for all mp sockets */
 static pthread_mutex_t mp_mutex_action = PTHREAD_MUTEX_INITIALIZER;
@@ -396,7 +397,7 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un 
*s)
}
 }
 
-static void *
+static uint32_t
 mp_handle(void *arg __rte_unused)
 {
struct mp_msg_internal msg;
@@ -413,7 +414,7 @@ mp_handle(void *arg __rte_unused)
process_msg(&msg, &sa);
}
 
-   return NULL;
+   return 0;
 }
 
 static int
@@ -646,8 +647,8 @@ rte_mp_channel_init(void)
return -1;
}
 
-   if (rte_ctrl_thread_create(&mp_handle_tid, "dpdk-mp-msg",
-   NULL, mp_handle, NULL) < 0) {
+   if (rte_thread_create_internal_control(&mp_handle_tid, "mp-msg",
+   mp_handle, NULL) < 0) {
RTE_LOG(ERR, EAL, "failed to create mp thread: %s\n",
strerror(errno));
close(dir_fd);
@@ -671,8 +672,8 @@ rte_mp_channel_cleanup(void)
if (fd < 0)
return;
 
-   pthread_cancel(mp_handle_tid);
-   pthread_join(mp_handle_tid, NULL);
+   pthread_cancel((pthread_t)mp_handle_tid.opaque_id);
+   rte_thread_join(mp_handle_tid, NULL);
close_socket_fd(fd);
 }
 
diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c
index 68cdb9deb3..2b31dfb099 100644
--- a/lib/eal/freebsd/eal_interrupts.c
+++ b/lib/eal/freebsd/eal_interrupts.c
@@ -52,7 +52,7 @@ static rte_spinlock_t intr_lock = RTE_SPINLOCK_INITIALIZER;
 static struct rte_intr_source_list intr_sources;
 
 /* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
 
 static volatile int kq = -1;
 
@@ -591,7 +591,7 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)
}
 }
 
-static void *
+static uint32_t
 eal_intr_thread_main(void *arg __rte_unused)
 {
struct kevent events[MAX_INTR_EVENTS];
@@ -619,7 +619,7 @@ eal_intr_thread_main(void *arg __rte_unused)
}
close(kq);
kq = -1;
-   return NULL;
+   return 0;
 }
 
 int
@@ -637,7 +637,7 @@ rte_eal_intr_init(void)
}
 
/* create the host thread to wait/handle the interrupt */
-   ret = rte_ctrl_thread_create(&intr_thread, "dpdk-intr", NULL,
+   ret = rte_thread_create_internal_control(&intr_thread, "intr",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -746,5 +746,5 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)
 
 int rte_thread_is_intr(void)
 {
-   return pthread_equal(intr_thread, pthread_self());
+   return rte_thread_equal(intr_thread, rte_thread_self());
 }
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index 19b36787b8..24fff3d3c2 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -5,7 +5,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -19,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -89,7 +89,7 @@ static union intr_pipefds intr_pipe;
 static struct rte_intr_source_list intr_sources;
 
 /* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
 
 /* VFIO interrupts */
 #ifdef VFIO_PRESENT
@@ -1103,7 +1103,7 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds)
  * @return
  *  never return;
  */

[PATCH v2 07/11] drivers: convert to internal control threads

2023-09-13 Thread Thomas Monjalon
Calls to rte_ctrl_thread_create() are replaced with
rte_thread_create_internal_control().
Other pthread-related functions are replaced with the rte_thread API.
Only pthread_cancel() has no replacement.

The mlx5 vDPA control threads were real-time threads
with an affinity on the core specified by the devarg "event_core".
As there is no heavy performance requirement,
these threads are converted into real control threads.

Some threads in dlb2 and mlx5 are not control threads
because they are designed to run on some specific cores.
It would be interesting to rework them in future.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
Acked-by: Andrew Rybchenko 
---
 drivers/common/cnxk/roc_dev.c  | 16 ++--
 drivers/common/cnxk/roc_dev_priv.h |  2 +-
 drivers/common/cnxk/roc_nix_inl_dev.c  |  9 +--
 drivers/common/cnxk/roc_nix_inl_priv.h |  2 +-
 drivers/common/cnxk/roc_platform.h |  3 +-
 drivers/dma/skeleton/skeleton_dmadev.c |  7 +-
 drivers/event/dlb2/pf/base/dlb2_osdep.h| 14 ++--
 drivers/event/dlb2/pf/base/dlb2_resource.c | 39 +-
 drivers/event/dlb2/pf/dlb2_main.h  |  1 -
 drivers/net/ark/ark_ethdev.c   | 11 ++-
 drivers/net/ark/ark_pktgen.c   |  8 +-
 drivers/net/ark/ark_pktgen.h   |  2 +-
 drivers/net/iavf/iavf_vchnl.c  |  2 +-
 drivers/net/ice/ice_dcf_parent.c   |  7 +-
 drivers/net/ipn3ke/ipn3ke_representor.c| 17 ++---
 drivers/net/ixgbe/ixgbe_ethdev.c   |  7 +-
 drivers/net/mlx5/mlx5.h|  2 +-
 drivers/net/mlx5/mlx5_hws_cnt.c| 42 ++-
 drivers/net/sfc/sfc_mae.h  |  2 +-
 drivers/net/sfc/sfc_mae_counter.c  | 11 ++-
 drivers/net/txgbe/txgbe_ethdev.c   |  6 +-
 drivers/raw/ifpga/ifpga_rawdev.c   | 19 +++--
 drivers/vdpa/ifc/ifcvf_vdpa.c  | 86 ++
 drivers/vdpa/mlx5/mlx5_vdpa.c  |  2 +-
 drivers/vdpa/mlx5/mlx5_vdpa.h  | 10 +--
 drivers/vdpa/mlx5/mlx5_vdpa_cthread.c  | 70 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c| 64 +---
 drivers/vdpa/sfc/sfc_vdpa_ops.c| 15 ++--
 drivers/vdpa/sfc/sfc_vdpa_ops.h|  3 +-
 29 files changed, 203 insertions(+), 276 deletions(-)

diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index 13d3eece47..08fd13f741 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -18,7 +18,7 @@
 #define ROC_PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */
 
 /* VF Mbox handler thread name */
-#define MBOX_HANDLER_NAME_MAX_LEN 25
+#define MBOX_HANDLER_NAME_MAX_LEN RTE_THREAD_INTERNAL_NAME_SIZE
 
 /* VF interrupt message pending bits - mbox or flr */
 #define ROC_DEV_MBOX_PEND BIT_ULL(0)
@@ -1070,7 +1070,7 @@ vf_flr_handle_msg(void *param, dev_intr_t *flr)
}
 }
 
-static void *
+static uint32_t
 pf_vf_mbox_thread_main(void *arg)
 {
struct dev *dev = arg;
@@ -1114,7 +1114,7 @@ pf_vf_mbox_thread_main(void *arg)
 
pthread_mutex_unlock(&dev->sync.mutex);
 
-   return NULL;
+   return 0;
 }
 
 static void
@@ -1455,10 +1455,10 @@ dev_init(struct dev *dev, struct plt_pci_device 
*pci_dev)
pthread_cond_init(&dev->sync.pfvf_msg_cond, NULL);
pthread_mutex_init(&dev->sync.mutex, NULL);
 
-   snprintf(name, MBOX_HANDLER_NAME_MAX_LEN, "pf%d_vf_msg_hndlr", 
dev->pf);
+   snprintf(name, MBOX_HANDLER_NAME_MAX_LEN, "mbox_pf%d", dev->pf);
dev->sync.start_thread = true;
-   rc = plt_ctrl_thread_create(&dev->sync.pfvf_msg_thread, name, 
NULL,
-   pf_vf_mbox_thread_main, dev);
+   rc = plt_thread_create_control(&dev->sync.pfvf_msg_thread, name,
+   pf_vf_mbox_thread_main, dev);
if (rc != 0) {
plt_err("Failed to create thread for VF mbox 
handling\n");
goto iounmap;
@@ -1488,7 +1488,7 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev)
if (dev->sync.start_thread) {
dev->sync.start_thread = false;
pthread_cond_signal(&dev->sync.pfvf_msg_cond);
-   pthread_join(dev->sync.pfvf_msg_thread, NULL);
+   plt_thread_join(dev->sync.pfvf_msg_thread, NULL);
pthread_mutex_destroy(&dev->sync.mutex);
pthread_cond_destroy(&dev->sync.pfvf_msg_cond);
}
@@ -1519,7 +1519,7 @@ dev_fini(struct dev *dev, struct plt_pci_device *pci_dev)
if (dev->sync.start_thread) {
dev->sync.start_thread = false;
pthread_cond_signal(&dev->sync.pfvf_msg_cond);
-   pthread_join(dev->sync.pfvf_msg_thread, NULL);
+   plt_thread_join(dev->sync.pfvf_msg_thread, NULL);
pthread_mutex_destroy(&dev->sync.mutex);
pthrea

[PATCH v2 08/11] examples: convert to normal control threads

2023-09-13 Thread Thomas Monjalon
Calls to rte_ctrl_thread_create() are replaced with
rte_thread_create_control().

In vhost_blk, the control thread is not forced
to be scheduled on core 0 anymore.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 examples/vhost/main.c  |  9 +
 examples/vhost_blk/vhost_blk.c | 21 ++---
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 9ff2c1f31b..ce5c1efddf 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "main.h"
 
@@ -1807,7 +1808,7 @@ static const struct rte_vhost_device_ops 
virtio_net_device_ops =
  * This is a thread will wake up after a period to print stats if the user has
  * enabled them.
  */
-static void *
+static uint32_t
 print_stats(__rte_unused void *arg)
 {
struct vhost_dev *vdev;
@@ -1852,7 +1853,7 @@ print_stats(__rte_unused void *arg)
fflush(stdout);
}
 
-   return NULL;
+   return 0;
 }
 
 static void
@@ -1907,7 +1908,7 @@ main(int argc, char *argv[])
unsigned nb_ports, valid_num_ports;
int ret, i;
uint16_t portid;
-   static pthread_t tid;
+   rte_thread_t tid;
uint64_t flags = RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS;
 
signal(SIGINT, sigint_handler);
@@ -1986,7 +1987,7 @@ main(int argc, char *argv[])
 
/* Enable stats if the user option is set. */
if (enable_stats) {
-   ret = rte_ctrl_thread_create(&tid, "dpdk-vhost-stat", NULL,
+   ret = rte_thread_create_control(&tid, "dpdk-vhost-stat",
print_stats, NULL);
if (ret < 0)
rte_exit(EXIT_FAILURE,
diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index 45699eb0b3..376f7b89a7 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -5,8 +5,6 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
-#include 
-#include 
 
 #include 
 #include 
@@ -529,12 +527,10 @@ process_vq(struct vhost_blk_queue *vq)
}
 }
 
-static void *
+static uint32_t
 ctrlr_worker(void *arg)
 {
struct vhost_blk_ctrlr *ctrlr = (struct vhost_blk_ctrlr *)arg;
-   cpu_set_t cpuset;
-   pthread_t thread;
int i;
 
fprintf(stdout, "Ctrlr Worker Thread start\n");
@@ -546,11 +542,6 @@ ctrlr_worker(void *arg)
exit(0);
}
 
-   thread = pthread_self();
-   CPU_ZERO(&cpuset);
-   CPU_SET(0, &cpuset);
-   pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
-
for (i = 0; i < NUM_OF_BLK_QUEUES; i++)
submit_inflight_vq(&ctrlr->queues[i]);
 
@@ -560,7 +551,7 @@ ctrlr_worker(void *arg)
 
fprintf(stdout, "Ctrlr Worker Thread Exiting\n");
sem_post(&exit_sem);
-   return NULL;
+   return 0;
 }
 
 static int
@@ -605,7 +596,7 @@ new_device(int vid)
struct vhost_blk_queue *vq;
char path[PATH_MAX];
uint64_t features, protocol_features;
-   pthread_t tid;
+   rte_thread_t tid;
int i, ret;
bool packed_ring, inflight_shmfd;
 
@@ -686,15 +677,15 @@ new_device(int vid)
/* start polling vring */
worker_thread_status = WORKER_STATE_START;
fprintf(stdout, "New Device %s, Device ID %d\n", path, vid);
-   if (rte_ctrl_thread_create(&tid, "dpdk-vhost-blk", NULL,
-  &ctrlr_worker, ctrlr) != 0) {
+   if (rte_thread_create_control(&tid, "dpdk-vhost-blk",
+   &ctrlr_worker, ctrlr) != 0) {
fprintf(stderr, "Worker Thread Started Failed\n");
return -1;
}
 
/* device has been started */
ctrlr->started = 1;
-   pthread_detach(tid);
+   rte_thread_detach(tid);
return 0;
 }
 
-- 
2.42.0



[PATCH v2 09/11] test: convert threads creation

2023-09-13 Thread Thomas Monjalon
Calls to pthread for thread creation are replaced with the rte_thread API.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 app/test/process.h | 10 +-
 app/test/test_lcores.c |  9 -
 app/test/test_pdump.c  |  6 +++---
 app/test/test_pdump.h  |  2 +-
 4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/app/test/process.h b/app/test/process.h
index 1f073b9c5c..af7bc3e0de 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -28,8 +28,8 @@
 
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
-#include 
-extern void *send_pkts(void *empty);
+#include 
+extern uint32_t send_pkts(void *empty);
 extern uint16_t flag_for_send_pkts;
 #endif
 #endif
@@ -49,7 +49,7 @@ process_dup(const char *const argv[], int numargs, const char 
*env_value)
char path[32];
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
-   pthread_t thread;
+   rte_thread_t thread;
int rc;
 #endif
 #endif
@@ -136,7 +136,7 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
-   rc = pthread_create(&thread, NULL, &send_pkts, NULL);
+   rc = rte_thread_create(&thread, NULL, send_pkts, NULL);
if (rc != 0) {
rte_panic("Cannot start send pkts thread: %s\n",
  strerror(rc));
@@ -151,7 +151,7 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
 #ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
flag_for_send_pkts = 0;
-   pthread_join(thread, NULL);
+   rte_thread_join(thread, NULL);
}
 #endif
 #endif
diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c
index 0c96faa4cb..5a9fd3 100644
--- a/app/test/test_lcores.c
+++ b/app/test/test_lcores.c
@@ -2,7 +2,6 @@
  * Copyright (c) 2020 Red Hat, Inc.
  */
 
-#include 
 #include 
 
 #include 
@@ -341,7 +340,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
return -1;
 }
 
-static void *ctrl_thread_loop(void *arg)
+static uint32_t ctrl_thread_loop(void *arg)
 {
struct thread_context *t = arg;
 
@@ -350,7 +349,7 @@ static void *ctrl_thread_loop(void *arg)
/* Set the thread state to DONE */
t->state = Thread_DONE;
 
-   return NULL;
+   return 0;
 }
 
 static int
@@ -362,8 +361,8 @@ test_ctrl_thread(void)
/* Create one control thread */
t = &ctrl_thread_context;
t->state = Thread_INIT;
-   if (rte_ctrl_thread_create((pthread_t *)&t->id, "dpdk-test-ctrlt",
-   NULL, ctrl_thread_loop, t) != 0)
+   if (rte_thread_create_control(&t->id, "dpdk-test-ctrlt",
+   ctrl_thread_loop, t) != 0)
return -1;
 
/* Wait till the control thread exits.
diff --git a/app/test/test_pdump.c b/app/test/test_pdump.c
index ea03056b47..adf49f0b54 100644
--- a/app/test/test_pdump.c
+++ b/app/test/test_pdump.c
@@ -136,8 +136,8 @@ test_pdump_uninit(void)
return ret;
 }
 
-void *
-send_pkts(void *empty)
+uint32_t
+send_pkts(void *empty __rte_unused)
 {
int ret = 0;
struct rte_mbuf *pbuf[NUM_PACKETS] = { };
@@ -161,7 +161,7 @@ send_pkts(void *empty)
 
rte_eth_dev_stop(portid);
test_put_mbuf_to_pool(mp, pbuf);
-   return empty;
+   return 0;
 }
 
 /*
diff --git a/app/test/test_pdump.h b/app/test/test_pdump.h
index abef9a85ec..8746d61269 100644
--- a/app/test/test_pdump.h
+++ b/app/test/test_pdump.h
@@ -9,7 +9,7 @@
 #define NUM_ITR 3
 
 /* sample test to send packets to the pdump client recursively */
-void *send_pkts(void *port);
+uint32_t send_pkts(void *empty);
 
 /* Sample test to create setup for the pdump server tests */
 int test_pdump_init(void);
-- 
2.42.0



[PATCH v2 10/11] eal: remove deprecated thread functions

2023-09-13 Thread Thomas Monjalon
The deprecated functions rte_thread_setname() and rte_ctrl_thread_create()
are replaced with the new rte_thread API:

rte_thread_setname()
can be replaced with
rte_thread_set_name()
or  rte_thread_set_prefixed_name()

rte_ctrl_thread_create()
can be replaced with
rte_thread_create_control()
or  rte_thread_create_internal_control()

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 

---
v2: clean control thread params struct
---
 .../prog_guide/env_abstraction_layer.rst  |  2 +-
 doc/guides/rel_notes/deprecation.rst  |  5 -
 doc/guides/rel_notes/release_23_11.rst|  4 +-
 lib/eal/common/eal_common_thread.c| 93 +++
 lib/eal/freebsd/eal_thread.c  |  7 --
 lib/eal/include/rte_lcore.h   | 42 -
 lib/eal/linux/eal_thread.c| 16 
 lib/eal/version.map   |  2 -
 lib/eal/windows/eal_thread.c  |  8 --
 9 files changed, 18 insertions(+), 161 deletions(-)

diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst 
b/doc/guides/prog_guide/env_abstraction_layer.rst
index 89014789de..6debf54efb 100644
--- a/doc/guides/prog_guide/env_abstraction_layer.rst
+++ b/doc/guides/prog_guide/env_abstraction_layer.rst
@@ -756,7 +756,7 @@ Control Thread API
 ~~
 
 It is possible to create Control Threads using the public API
-``rte_ctrl_thread_create()``.
+``rte_thread_create_control()``.
 Those threads can be used for management/infrastructure tasks and are used
 internally by DPDK for multi process support and interrupt handling.
 
diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index 3e48908b51..8c8873006d 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -29,11 +29,6 @@ Deprecation Notices
   are renamed to ``rte_tel_data_add_array_uint`` and 
``rte_tel_data_add_dict_uint`` respectively.
   As such, the old function names are deprecated and will be removed in a 
future release.
 
-* eal: The functions ``rte_thread_setname`` and ``rte_ctrl_thread_create``
-  are planned to be deprecated starting with the 23.07 release, subject to
-  the replacement API rte_thread_set_name and rte_thread_create_control being
-  marked as stable, and planned to be removed by the 23.11 release.
-
 * eal: ``RTE_CPUFLAG_NUMFLAGS`` will be removed in DPDK 23.11 release.
   This is to allow new CPU features to be added without ABI breakage.
 
diff --git a/doc/guides/rel_notes/release_23_11.rst 
b/doc/guides/rel_notes/release_23_11.rst
index d7562fd646..9746809a66 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -115,7 +115,9 @@ API Changes
 
 * eal: The thread API has changed.
   The function ``rte_thread_create_control()`` does not take attributes 
anymore.
-  The whole thread API was promoted to stable level.
+  The whole thread API was promoted to stable level,
+  except ``rte_thread_setname()`` and ``rte_ctrl_thread_create()`` which are
+  replaced with ``rte_thread_set_name()`` and ``rte_thread_create_control()``.
 
 
 ABI Changes
diff --git a/lib/eal/common/eal_common_thread.c 
b/lib/eal/common/eal_common_thread.c
index cd6e00fe8a..a71142662a 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -235,25 +235,22 @@ enum __rte_ctrl_thread_status {
CTRL_THREAD_ERROR /* Control thread encountered an error */
 };
 
-struct rte_thread_ctrl_params {
-   union {
-   void *(*ctrl_start_routine)(void *arg);
-   rte_thread_func control_start_routine;
-   } u;
+struct control_thread_params {
+   rte_thread_func start_routine;
void *arg;
int ret;
/* Control thread status.
 * If the status is CTRL_THREAD_ERROR, 'ret' has the error code.
 */
-   enum __rte_ctrl_thread_status ctrl_thread_status;
+   enum __rte_ctrl_thread_status status;
 };
 
-static int ctrl_thread_init(void *arg)
+static int control_thread_init(void *arg)
 {
struct internal_config *internal_conf =
eal_get_internal_configuration();
rte_cpuset_t *cpuset = &internal_conf->ctrl_cpuset;
-   struct rte_thread_ctrl_params *params = arg;
+   struct control_thread_params *params = arg;
 
__rte_thread_init(rte_lcore_id(), cpuset);
/* Set control thread socket ID to SOCKET_ID_ANY
@@ -262,96 +259,34 @@ static int ctrl_thread_init(void *arg)
RTE_PER_LCORE(_socket_id) = SOCKET_ID_ANY;
params->ret = rte_thread_set_affinity_by_id(rte_thread_self(), cpuset);
if (params->ret != 0) {
-   __atomic_store_n(¶ms->ctrl_thread_status,
+   __atomic_store_n(¶ms->status,
CTRL_THREAD_ERROR, __ATOMIC_RELEASE);
return 1;
}
 
-   __atomic_store_n(¶ms->ctrl_thread_status,
+ 

[PATCH v2 11/11] lib: remove pthread.h from includes

2023-09-13 Thread Thomas Monjalon
The header files should have the minimum embedded includes.
The file pthread.h can logically be removed from
rte_per_lcore.h and rte_ethdev_core.h files.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
Acked-by: Ajit Khaparde 
Acked-by: Rosen Xu 
---
 app/test/test_link_bonding.c   | 2 ++
 drivers/common/mlx5/mlx5_common.c  | 1 +
 drivers/common/mlx5/windows/mlx5_win_ext.h | 2 ++
 drivers/net/bnxt/bnxt.h| 1 +
 drivers/net/qede/base/bcm_osal.h   | 1 +
 drivers/raw/ifpga/base/opae_osdep.h| 1 +
 drivers/vdpa/sfc/sfc_vdpa.c| 1 +
 lib/eal/common/eal_common_options.c| 1 +
 lib/eal/common/eal_common_trace.c  | 1 +
 lib/eal/common/malloc_mp.c | 1 +
 lib/eal/freebsd/eal_alarm.c| 1 +
 lib/eal/include/rte_per_lcore.h| 2 --
 lib/eal/linux/eal_alarm.c  | 1 +
 lib/ethdev/ethdev_driver.c | 1 +
 lib/ethdev/ethdev_driver.h | 2 ++
 lib/ethdev/rte_ethdev_core.h   | 2 --
 lib/ethdev/rte_flow.c  | 1 +
 lib/eventdev/rte_event_eth_rx_adapter.c| 1 +
 lib/vhost/vhost.c  | 1 +
 19 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 2f46e4c6ee..d6b6ebc2f2 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -10,8 +10,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+
 #include 
 #include 
 #include 
diff --git a/drivers/common/mlx5/mlx5_common.c 
b/drivers/common/mlx5/mlx5_common.c
index 0ad14a48c7..ca8543e36e 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/common/mlx5/windows/mlx5_win_ext.h 
b/drivers/common/mlx5/windows/mlx5_win_ext.h
index 6f69329a6f..a71c69bff5 100644
--- a/drivers/common/mlx5/windows/mlx5_win_ext.h
+++ b/drivers/common/mlx5/windows/mlx5_win_ext.h
@@ -5,6 +5,8 @@
 #ifndef __MLX5_WIN_ETX_H__
 #define __MLX5_WIN_ETX_H__
 
+#include 
+
 #include "mlx5_prm.h"
 #include "mlx5devx.h"
 
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index ed21ba7f29..0e01b1d4ba 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h
index 97e261d306..11019b5623 100644
--- a/drivers/net/qede/base/bcm_osal.h
+++ b/drivers/net/qede/base/bcm_osal.h
@@ -8,6 +8,7 @@
 #define __BCM_OSAL_H
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/raw/ifpga/base/opae_osdep.h 
b/drivers/raw/ifpga/base/opae_osdep.h
index 033b7e098c..e91205f536 100644
--- a/drivers/raw/ifpga/base/opae_osdep.h
+++ b/drivers/raw/ifpga/base/opae_osdep.h
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 
 #ifdef RTE_LIB_EAL
 #include "osdep_rte/osdep_generic.h"
diff --git a/drivers/vdpa/sfc/sfc_vdpa.c b/drivers/vdpa/sfc/sfc_vdpa.c
index bd6ecde450..9db87fcb7d 100644
--- a/drivers/vdpa/sfc/sfc_vdpa.c
+++ b/drivers/vdpa/sfc/sfc_vdpa.c
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/lib/eal/common/eal_common_options.c 
b/lib/eal/common/eal_common_options.c
index d74b581567..a6d21f1cba 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #ifndef RTE_EXEC_ENV_WINDOWS
 #include 
 #endif
diff --git a/lib/eal/common/eal_common_trace.c 
b/lib/eal/common/eal_common_trace.c
index cb980af06d..b21e61bf39 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c
index 7270c2ec90..4d62397aba 100644
--- a/lib/eal/common/malloc_mp.c
+++ b/lib/eal/common/malloc_mp.c
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c
index acdcf53804..e5b0909a45 100644
--- a/lib/eal/freebsd/eal_alarm.c
+++ b/lib/eal/freebsd/eal_alarm.c
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/lib/eal/include/rte_per_lcore.h b/lib/eal/include/rte_per_lcore.h
index 2b846f9337..5a1497631a 100644
--- a/lib/eal/include/rte_per_lcore.h
+++ b/lib/eal/include/rte_per_lcore.h
@@ -22,8 +22,6 @@
 extern "C" {
 #endif
 
-#include 
-
 #ifdef RTE_TOOLCHAIN_MSVC
 /**
  * Macro to define a per lcore variable "var" of type "type", don't
diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c
index 397f25d7d5..766ba2c251 100644
--- a/lib/eal/linux/eal_alarm.c
+++ b/lib/eal/linux/eal_alarm.c
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#incl

Re: [PATCH] gpu/cuda: Add missing stdlib include

2023-09-13 Thread Aaron Conole
John Romein  writes:

> getenv needs stdlib.h to be included.
>
> Bugzilla ID: 1133
>
> Fixes: 24c77594e08f ("gpu/cuda: map GPU memory with GDRCopy")
> Signed-off-by: John Romein 
> ---

Hi John,

Thanks so much for the contribution.  It looks like the patch got
corrupted by something.  Please check your mail client settings.  I'll
point out some of the specific characters here.  You may also need to
switch to using a gmail server or some other mail service to email the
patch.

-Aaron

>   drivers/gpu/cuda/gdrcopy.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/cuda/gdrcopy.c b/drivers/gpu/cuda/gdrcopy.c
> index 322a5dbeb2..f19ad396f1 100644
> --- a/drivers/gpu/cuda/gdrcopy.c
> +++ b/drivers/gpu/cuda/gdrcopy.c
> @@ -2,6 +2,8 @@
>    * Copyright (c) 2022 NVIDIA Corporation & Affiliates

   ^  This character looks incorrect
>    */

   ^ Same here
   
>
> +#include 
> +
>   #include "common.h"

   ^ Same here

>   #ifdef DRIVERS_GPU_CUDA_GDRCOPY_H

   ^ Same here



RE: [PATCH v4 6/7] app/proc-info: support querying RSS hash algorithm

2023-09-13 Thread Pattan, Reshma



> -Original Message-
> From: Jie Hai 
> Subject: [PATCH v4 6/7] app/proc-info: support querying RSS hash algorithm
> 
> Display RSS hash algorithm with command show-port as below.
>   - RSS info
> -- hash algorithm : toeplitz
> 
> Signed-off-by: Jie Hai 
> Signed-off-by: Dongdong Liu 

Acked-by: Reshma Pattan 


RE: [PATCH v4 6/7] app/proc-info: support querying RSS hash algorithm

2023-09-13 Thread Pattan, Reshma



> -Original Message-
> From: Jie Hai 
> Sent: Friday, September 8, 2023 9:00 AM
> To: dev@dpdk.org; Pattan, Reshma 
> Cc: haij...@huawei.com; lihuis...@huawei.com
> Subject: [PATCH v4 6/7] app/proc-info: support querying RSS hash algorithm
> 
> Display RSS hash algorithm with command show-port as below.
>   - RSS info
> -- hash algorithm : toeplitz
> 
> Signed-off-by: Jie Hai 
> Signed-off-by: Dongdong Liu 

Acked-by: Reshma Pattan 


[PATCH v3 00/11] rework thread management

2023-09-13 Thread Thomas Monjalon
The main effect of this patch series is to
remove calls to pthread functions except for pthread_cancel and locks.

The function rte_thread_create_control() does not take thread attributes
settings anymore as it looks a useless complication of the API.
Then the rte_thread API is made stable,
so we can remove the old deprecated functions
rte_thread_setname() and rte_ctrl_thread_create().

Some new internal functions are added in rte_thread to make sure
all internal thread names are prefixed with "dpdk-".

Few other cleanups are done.

Future work about pthread portability are about:
  - cancel
  - mutex

---

v2 changes:
  - replace (|_) with _? in checkpatch
  - simplify thread name size doc
  - build time check of internal thread name size
  - clean control thread params struct
v3 change:
  - fix build (wrong placement of RTE_BUILD_BUG_ON)
note for later: never send a patch during a summit!


Thomas Monjalon (11):
  devtools: warn when adding some pthread calls
  eal: rename thread name length definition
  eal: remove attributes from control thread creation
  eal: promote thread API as stable
  eal: force prefix for internal threads
  lib: convert to internal control threads
  drivers: convert to internal control threads
  examples: convert to normal control threads
  test: convert threads creation
  eal: remove deprecated thread functions
  lib: remove pthread.h from includes

 app/test/process.h|  10 +-
 app/test/test_lcores.c|   9 +-
 app/test/test_link_bonding.c  |   2 +
 app/test/test_pdump.c |   6 +-
 app/test/test_pdump.h |   2 +-
 app/test/test_threads.c   |   2 +-
 devtools/checkpatches.sh  |  16 +++
 .../prog_guide/env_abstraction_layer.rst  |   2 +-
 doc/guides/rel_notes/deprecation.rst  |   5 -
 doc/guides/rel_notes/release_23_11.rst|   6 +
 drivers/common/cnxk/roc_dev.c |  16 +--
 drivers/common/cnxk/roc_dev_priv.h|   2 +-
 drivers/common/cnxk/roc_nix_inl_dev.c |   9 +-
 drivers/common/cnxk/roc_nix_inl_priv.h|   2 +-
 drivers/common/cnxk/roc_platform.h|   3 +-
 drivers/common/mlx5/mlx5_common.c |   1 +
 drivers/common/mlx5/windows/mlx5_win_ext.h|   2 +
 drivers/dma/skeleton/skeleton_dmadev.c|   8 +-
 drivers/event/dlb2/pf/base/dlb2_osdep.h   |  14 +-
 drivers/event/dlb2/pf/base/dlb2_resource.c|  39 +++---
 drivers/event/dlb2/pf/dlb2_main.h |   1 -
 drivers/net/ark/ark_ethdev.c  |  11 +-
 drivers/net/ark/ark_pktgen.c  |   8 +-
 drivers/net/ark/ark_pktgen.h  |   2 +-
 drivers/net/bnxt/bnxt.h   |   1 +
 drivers/net/iavf/iavf_vchnl.c |   4 +-
 drivers/net/ice/ice_dcf_parent.c  |   7 +-
 drivers/net/ipn3ke/ipn3ke_representor.c   |  17 ++-
 drivers/net/ixgbe/ixgbe_ethdev.c  |   8 +-
 drivers/net/mlx5/mlx5.h   |   2 +-
 drivers/net/mlx5/mlx5_hws_cnt.c   |  42 +++---
 drivers/net/qede/base/bcm_osal.h  |   1 +
 drivers/net/sfc/sfc_mae.h |   2 +-
 drivers/net/sfc/sfc_mae_counter.c |  11 +-
 drivers/net/txgbe/txgbe_ethdev.c  |   6 +-
 drivers/raw/ifpga/base/opae_osdep.h   |   1 +
 drivers/raw/ifpga/ifpga_rawdev.c  |  19 ++-
 drivers/vdpa/ifc/ifcvf_vdpa.c |  86 ++--
 drivers/vdpa/mlx5/mlx5_vdpa.c |   2 +-
 drivers/vdpa/mlx5/mlx5_vdpa.h |  10 +-
 drivers/vdpa/mlx5/mlx5_vdpa_cthread.c |  70 +++---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c   |  64 +++--
 drivers/vdpa/sfc/sfc_vdpa.c   |   1 +
 drivers/vdpa/sfc/sfc_vdpa_ops.c   |  15 +-
 drivers/vdpa/sfc/sfc_vdpa_ops.h   |   3 +-
 examples/vhost/main.c |   9 +-
 examples/vhost_blk/vhost_blk.c|  21 +--
 lib/eal/common/eal_common_options.c   |   1 +
 lib/eal/common/eal_common_proc.c  |  15 +-
 lib/eal/common/eal_common_thread.c| 131 +++---
 lib/eal/common/eal_common_trace.c |   1 +
 lib/eal/common/malloc_mp.c|   1 +
 lib/eal/freebsd/eal.c |   2 +-
 lib/eal/freebsd/eal_alarm.c   |   1 +
 lib/eal/freebsd/eal_interrupts.c  |  10 +-
 lib/eal/freebsd/eal_thread.c  |   9 +-
 lib/eal/include/rte_eal.h |   3 -
 lib/eal/include/rte_lcore.h   |  42 --
 lib/eal/include/rte_per_lcore.h   |   2 -
 lib/eal/include/rte_thread.h  | 131 +-
 lib/eal/linux/eal.c   |   2 +-
 lib/eal/linux/eal_alarm.c |   1 +
 lib/eal/linux/eal_interrupts.c|  10 +-
 lib/eal/

[PATCH v3 01/11] devtools: warn when adding some pthread calls

2023-09-13 Thread Thomas Monjalon
All pthread functions below have an equivalent in rte_thread API:
- pthread_create
- pthread_join
- pthread_detach
- pthread_setname_np
- pthread_set_name_np
- pthread_setaffinity_np
- pthread_attr_setinheritsched
- pthread_attr_setschedpolicy
Usage of these functions will be raised to encourage rte_thread adoption.

The pthread functions for locks and cancel are still allowed.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 

---
v2: replace (|_) with _?
---
 devtools/checkpatches.sh | 8 
 1 file changed, 8 insertions(+)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 55fabc5458..ec9d232393 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -119,6 +119,14 @@ check_forbidden_additions() { # 
-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
"$1" || res=1
 
+   # refrain from using some pthread functions
+   awk -v FOLDERS="lib drivers app examples" \
+   -v 
EXPRESSIONS="pthread_(create|join|detach|set(_?name_np|affinity_np)|attr_set(inheritsched|schedpolicy))\\\("
 \
+   -v RET_ON_FAIL=1 \
+   -v MESSAGE='Using pthread functions, prefer rte_thread' \
+   -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+   "$1" || res=1
+
# forbid use of __reserved which is a reserved keyword in Windows 
system headers
awk -v FOLDERS="lib drivers app examples" \
-v EXPRESSIONS='\\<__reserved\\>' \
-- 
2.42.0



[PATCH v3 02/11] eal: rename thread name length definition

2023-09-13 Thread Thomas Monjalon
RTE_MAX_THREAD_NAME_LEN is including the NUL character,
so it should be named "size" instead of "length".
A new constant RTE_THREAD_NAME_SIZE is introduced for naming accuracy.
For API compatibility, the old name is kept.

At the same time, the original definition is moved
from rte_eal.h to rte_thread.h.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 lib/eal/freebsd/eal.c| 2 +-
 lib/eal/freebsd/eal_thread.c | 2 +-
 lib/eal/include/rte_eal.h| 3 ---
 lib/eal/include/rte_thread.h | 9 +++--
 lib/eal/linux/eal.c  | 2 +-
 lib/eal/linux/eal_thread.c   | 2 +-
 lib/eal/windows/eal.c| 2 +-
 lib/eal/windows/rte_thread.c | 2 +-
 8 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 9e1e267955..39a2868523 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -583,7 +583,7 @@ rte_eal_init(int argc, char **argv)
static uint32_t run_once;
uint32_t has_run = 0;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
-   char thread_name[RTE_MAX_THREAD_NAME_LEN];
+   char thread_name[RTE_THREAD_NAME_SIZE];
const struct rte_config *config = rte_eal_get_configuration();
struct internal_config *internal_conf =
eal_get_internal_configuration();
diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c
index 3227d9b8a2..ba9b25c2c0 100644
--- a/lib/eal/freebsd/eal_thread.c
+++ b/lib/eal/freebsd/eal_thread.c
@@ -34,7 +34,7 @@ int rte_sys_gettid(void)
 
 void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name)
 {
-   char truncated[RTE_MAX_THREAD_NAME_LEN];
+   char truncated[RTE_THREAD_NAME_SIZE];
const size_t truncatedsz = sizeof(truncated);
 
if (strlcpy(truncated, thread_name, truncatedsz) >= truncatedsz)
diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h
index 53c4a5519e..cd318ee141 100644
--- a/lib/eal/include/rte_eal.h
+++ b/lib/eal/include/rte_eal.h
@@ -27,9 +27,6 @@ extern "C" {
 
 #define RTE_MAGIC 19820526 /**< Magic number written by the main partition 
when ready. */
 
-/* Maximum thread_name length. */
-#define RTE_MAX_THREAD_NAME_LEN 16
-
 /**
  * The type of process in a linux, multi-process setup
  */
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 369e2375f6..6233142322 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -23,6 +23,11 @@
 extern "C" {
 #endif
 
+/** Maximum thread name length (including '\0'). */
+#define RTE_THREAD_NAME_SIZE 16
+/* Old definition, aliased for compatibility. */
+#define RTE_MAX_THREAD_NAME_LEN RTE_THREAD_NAME_SIZE
+
 /**
  * Thread id descriptor.
  */
@@ -110,7 +115,7 @@ int rte_thread_create(rte_thread_t *thread_id,
  *   Filled with the thread id of the new created thread.
  * @param name
  *   The name of the control thread
- *   (max RTE_MAX_THREAD_NAME_LEN characters including '\0').
+ *   (max RTE_THREAD_NAME_SIZE characters including '\0').
  * @param thread_attr
  *   Attributes for the new thread.
  * @param thread_func
@@ -188,7 +193,7 @@ rte_thread_t rte_thread_self(void);
  *The id of the thread to set name.
  *
  * @param thread_name
- *The name to set. Truncated to RTE_MAX_THREAD_NAME_LEN,
+ *The name to set. Truncated to RTE_THREAD_NAME_SIZE,
  *including terminating NUL if necessary.
  */
 __rte_experimental
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index a26822f667..5f4b2fb005 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -970,7 +970,7 @@ rte_eal_init(int argc, char **argv)
static uint32_t run_once;
uint32_t has_run = 0;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
-   char thread_name[RTE_MAX_THREAD_NAME_LEN];
+   char thread_name[RTE_THREAD_NAME_SIZE];
bool phys_addrs;
const struct rte_config *config = rte_eal_get_configuration();
struct internal_config *internal_conf =
diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c
index c07ad9d8a4..b9a126f3a8 100644
--- a/lib/eal/linux/eal_thread.c
+++ b/lib/eal/linux/eal_thread.c
@@ -24,7 +24,7 @@ void rte_thread_set_name(rte_thread_t thread_id, const char 
*thread_name)
int ret = ENOSYS;
 #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
 #if __GLIBC_PREREQ(2, 12)
-   char truncated[RTE_MAX_THREAD_NAME_LEN];
+   char truncated[RTE_THREAD_NAME_SIZE];
const size_t truncatedsz = sizeof(truncated);
 
if (strlcpy(truncated, thread_name, truncatedsz) >= truncatedsz)
diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index 16c1ba1596..7ec2152211 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -283,7 +283,7 @@ rte_eal_init(int argc, char **argv)
enum rte_iova_mode iova_mode;
int ret;
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
-   char thread_name[RTE_MAX_THREAD_NAME_LEN];
+   char thread_name[RTE_THREAD_NAME_SIZE]

[PATCH v3 03/11] eal: remove attributes from control thread creation

2023-09-13 Thread Thomas Monjalon
The experimental function rte_thread_create_control()
is supposed to wrap actions needed to create a control thread in DPDK.
This function should be easy to port on any OS.

As such, the thread attributes should not be customizable in this API.
The thread priority should be normal, and the affinity is on "free cores".
That's why the custom attributes parameter thread_attr is dropped.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 app/test/test_threads.c| 2 +-
 doc/guides/rel_notes/release_23_11.rst | 3 +++
 drivers/dma/skeleton/skeleton_dmadev.c | 3 +--
 drivers/net/iavf/iavf_vchnl.c  | 2 +-
 drivers/net/ice/ice_dcf_parent.c   | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c   | 1 -
 drivers/net/txgbe/txgbe_ethdev.c   | 2 +-
 lib/eal/common/eal_common_thread.c | 5 ++---
 lib/eal/include/rte_thread.h   | 5 +
 lib/eal/windows/eal_interrupts.c   | 2 +-
 10 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/app/test/test_threads.c b/app/test/test_threads.c
index 8c27e2bae1..4ac3f2671a 100644
--- a/app/test/test_threads.c
+++ b/app/test/test_threads.c
@@ -240,7 +240,7 @@ test_thread_control_create_join(void)
 
thread_id_ready = 0;
RTE_TEST_ASSERT(rte_thread_create_control(&thread_id, "dpdk-test-thcc",
-   NULL, thread_main, &thread_main_id) == 0,
+   thread_main, &thread_main_id) == 0,
"Failed to create thread.");
 
while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
diff --git a/doc/guides/rel_notes/release_23_11.rst 
b/doc/guides/rel_notes/release_23_11.rst
index 333e1d95a2..d3d500f294 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -113,6 +113,9 @@ API Changes
Also, make sure to start the actual text at the margin.
===
 
+* eal: The thread API has changed.
+  The function ``rte_thread_create_control()`` does not take attributes 
anymore.
+
 
 ABI Changes
 ---
diff --git a/drivers/dma/skeleton/skeleton_dmadev.c 
b/drivers/dma/skeleton/skeleton_dmadev.c
index 493224542f..4fc2319668 100644
--- a/drivers/dma/skeleton/skeleton_dmadev.c
+++ b/drivers/dma/skeleton/skeleton_dmadev.c
@@ -128,8 +128,7 @@ skeldma_start(struct rte_dma_dev *dev)
rte_mb();
 
snprintf(name, sizeof(name), "dpdk-dma-skel%d", dev->data->dev_id);
-   ret = rte_thread_create_control(&hw->thread, name, NULL,
-cpucopy_thread, dev);
+   ret = rte_thread_create_control(&hw->thread, name, cpucopy_thread, dev);
if (ret) {
SKELDMA_LOG(ERR, "Start cpucopy thread fail!");
return -EINVAL;
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index c31a6d5c98..6baa6d5955 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -136,7 +136,7 @@ iavf_dev_event_handler_init(void)
pthread_mutex_init(&handler->lock, NULL);
 
if (rte_thread_create_control(&handler->tid, "dpdk-iavf-event",
-   NULL, iavf_dev_event_handle, NULL)) {
+   iavf_dev_event_handle, NULL)) {
__atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED);
return -1;
}
diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index ad98a531de..d3bb65874f 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -182,7 +182,7 @@ start_vsi_reset_thread(struct ice_dcf_hw *dcf_hw, bool vfr, 
uint16_t vf_id)
param->vf_id = vf_id;
 
snprintf(name, sizeof(name), "dpdk-ice-rst%u", vf_id);
-   ret = rte_thread_create_control(&thread, name, NULL,
+   ret = rte_thread_create_control(&thread, name,
 ice_dcf_vsi_update_service_handler, param);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to start the thread for reset 
handling");
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 7eac05ee60..64e7e5d7d6 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4330,7 +4330,6 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
if 
(rte_thread_create_control(&ad->link_thread_tid,
"dpdk-ixgbe-link",
-   NULL,
ixgbe_dev_setup_link_thread_handler,
dev) < 0) {
PMD_DRV_LOG(ERR,
diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 6f2f5a1841..198fac8318 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ 

[PATCH v3 04/11] eal: promote thread API as stable

2023-09-13 Thread Thomas Monjalon
The rte_thread API must be used to ease OS porting.
One step of this process is to mark the necessary API as stable.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 doc/guides/rel_notes/release_23_11.rst |  1 +
 lib/eal/include/rte_thread.h   | 64 --
 lib/eal/version.map| 40 
 3 files changed, 20 insertions(+), 85 deletions(-)

diff --git a/doc/guides/rel_notes/release_23_11.rst 
b/doc/guides/rel_notes/release_23_11.rst
index d3d500f294..d7562fd646 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -115,6 +115,7 @@ API Changes
 
 * eal: The thread API has changed.
   The function ``rte_thread_create_control()`` does not take attributes 
anymore.
+  The whole thread API was promoted to stable level.
 
 
 ABI Changes
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 28cc5220a4..dd1f62523f 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -73,9 +73,6 @@ typedef struct {
 typedef struct eal_tls_key *rte_thread_key;
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Create a new thread that will invoke the 'thread_func' routine.
  *
  * @param thread_id
@@ -94,15 +91,11 @@ typedef struct eal_tls_key *rte_thread_key;
  *   On success, return 0.
  *   On failure, return a positive errno-style error number.
  */
-__rte_experimental
 int rte_thread_create(rte_thread_t *thread_id,
const rte_thread_attr_t *thread_attr,
rte_thread_func thread_func, void *arg);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Create a control thread.
  *
  * Creates a control thread with the given name and attributes. The
@@ -124,15 +117,11 @@ int rte_thread_create(rte_thread_t *thread_id,
  *   On success, returns 0; on error, it returns a negative value
  *   corresponding to the error number.
  */
-__rte_experimental
 int
 rte_thread_create_control(rte_thread_t *thread, const char *name,
rte_thread_func thread_func, void *arg);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Waits for the thread identified by 'thread_id' to terminate
  *
  * @param thread_id
@@ -145,13 +134,9 @@ rte_thread_create_control(rte_thread_t *thread, const char 
*name,
  *   On success, return 0.
  *   On failure, return a positive errno-style error number.
  */
-__rte_experimental
 int rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Indicate that the return value of the thread is not needed and
  * all thread resources should be release when the thread terminates.
  *
@@ -162,25 +147,17 @@ int rte_thread_join(rte_thread_t thread_id, uint32_t 
*value_ptr);
  *   On success, return 0.
  *   On failure, return a positive errno-style error number.
  */
-__rte_experimental
 int rte_thread_detach(rte_thread_t thread_id);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Get the id of the calling thread.
  *
  * @return
  *   Return the thread id of the calling thread.
  */
-__rte_experimental
 rte_thread_t rte_thread_self(void);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Set the name of the thread.
  * This API is a noop if the underlying platform does not
  * support setting the thread name or the platform-specific
@@ -193,14 +170,10 @@ rte_thread_t rte_thread_self(void);
  *The name to set. Truncated to RTE_THREAD_NAME_SIZE,
  *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
@@ -213,13 +186,9 @@ rte_thread_set_name(rte_thread_t thread_id, const char 
*thread_name);
  *   If the ids are equal, return nonzero.
  *   Otherwise, return 0.
  */
-__rte_experimental
 int rte_thread_equal(rte_thread_t t1, rte_thread_t t2);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Initialize the attributes of a thread.
  * These attributes can be passed to the rte_thread_create() function
  * that will create a new thread and set its attributes according to attr.
@@ -231,13 +200,9 @@ int rte_thread_equal(rte_thread_t t1, rte_thread_t t2);
  *   On success, return 0.
  *   On failure, return a positive errno-style error number.
  */
-__rte_experimental
 int rte_thread_attr_init(rte_thread_attr_t *attr);
 
 /**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice.
- *
  * Set the thread priority value in the thread attributes pointed to
  * by 'thread_attr'.
  *
@@ -251,16 +216,12 @@ int rte_thread_attr_i

[PATCH v3 05/11] eal: force prefix for internal threads

2023-09-13 Thread Thomas Monjalon
In order to make sure all threads created in DPDK drivers and libraries
have the same prefix in their name, some wrapper functions are added
for internal use when creating a control thread or setting a thread name:
- rte_thread_create_internal_control
- rte_thread_set_prefixed_name

The equivalent public functions are then forbidden for internal use:
- rte_thread_create_control
- rte_thread_set_name

Note: the libraries and drivers conversion is done in next patches,
while doing other thread-related changes.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 

---
v2: simplify size doc + build time check of internal name size
v3: fix build of RTE_BUILD_BUG_ON
---
 devtools/checkpatches.sh   |  8 +
 lib/eal/common/eal_common_thread.c | 33 +
 lib/eal/include/rte_thread.h   | 57 +-
 lib/eal/version.map|  2 ++
 4 files changed, 99 insertions(+), 1 deletion(-)

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index ec9d232393..e97811192a 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -159,6 +159,14 @@ check_forbidden_additions() { # 
-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
"$1" || res=1
 
+   # forbid non-internal thread in drivers and libs
+   awk -v FOLDERS='lib drivers' \
+   -v EXPRESSIONS="rte_thread_(set_name|create_control)\\\(" \
+   -v RET_ON_FAIL=1 \
+   -v MESSAGE='Prefer 
rte_thread_(set_prefixed_name|create_internal_control) in lib & drivers' \
+   -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+   "$1" || res=1
+
# forbid inclusion of driver specific headers in apps and examples
awk -v FOLDERS='app examples' \
-v EXPRESSIONS='include.*_driver\\.h include.*_pmd\\.h' \
diff --git a/lib/eal/common/eal_common_thread.c 
b/lib/eal/common/eal_common_thread.c
index 07ac721da1..830273813f 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -392,6 +392,39 @@ rte_thread_create_control(rte_thread_t *thread, const char 
*name,
return ret;
 }
 
+static void
+add_internal_prefix(char *prefixed_name, const char *name, size_t size)
+{
+   size_t prefixlen;
+
+   /* Check RTE_THREAD_INTERNAL_NAME_SIZE definition. */
+   RTE_BUILD_BUG_ON(RTE_THREAD_INTERNAL_NAME_SIZE !=
+   RTE_THREAD_NAME_SIZE - sizeof(RTE_THREAD_INTERNAL_PREFIX) + 1);
+
+   prefixlen = strlen(RTE_THREAD_INTERNAL_PREFIX);
+   strlcpy(prefixed_name, RTE_THREAD_INTERNAL_PREFIX, size);
+   strlcpy(prefixed_name + prefixlen, name, size - prefixlen);
+}
+
+int
+rte_thread_create_internal_control(rte_thread_t *id, const char *name,
+   rte_thread_func func, void *arg)
+{
+   char prefixed_name[RTE_THREAD_NAME_SIZE];
+
+   add_internal_prefix(prefixed_name, name, sizeof(prefixed_name));
+   return rte_thread_create_control(id, prefixed_name, func, arg);
+}
+
+void
+rte_thread_set_prefixed_name(rte_thread_t id, const char *name)
+{
+   char prefixed_name[RTE_THREAD_NAME_SIZE];
+
+   add_internal_prefix(prefixed_name, name, sizeof(prefixed_name));
+   rte_thread_set_name(id, prefixed_name);
+}
+
 int
 rte_thread_register(void)
 {
diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index dd1f62523f..8da9d4d3fb 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -28,6 +28,11 @@ extern "C" {
 /* Old definition, aliased for compatibility. */
 #define RTE_MAX_THREAD_NAME_LEN RTE_THREAD_NAME_SIZE
 
+/** Thread name prefix automatically added to all internal threads. */
+#define RTE_THREAD_INTERNAL_PREFIX "dpdk-"
+/** Maximum internal thread name length (including '\0'). */
+#define RTE_THREAD_INTERNAL_NAME_SIZE 11
+
 /**
  * Thread id descriptor.
  */
@@ -112,7 +117,7 @@ int rte_thread_create(rte_thread_t *thread_id,
  * @param thread_func
  *   Function to be executed by the new thread.
  * @param arg
- *   Argument passed to start_routine.
+ *   Argument passed to thread_func.
  * @return
  *   On success, returns 0; on error, it returns a negative value
  *   corresponding to the error number.
@@ -121,6 +126,35 @@ int
 rte_thread_create_control(rte_thread_t *thread, const char *name,
rte_thread_func thread_func, void *arg);
 
+/**
+ * Create an internal control thread.
+ *
+ * Creates a control thread with the given name prefixed.
+ * If setting the name of the thread fails, the error is ignored and logged.
+ *
+ * The affinity of the new thread is based on the CPU affinity retrieved
+ * at the time rte_eal_init() was called, the EAL threads are then excluded.
+ *
+ * @param id
+ *   Filled with the thread ID of the new created thread.
+ * @param name
+ *   The name of the control thread.
+ *   See RTE_THREAD_INTERNAL_NAME_SIZE for maxim

[PATCH v3 06/11] lib: convert to internal control threads

2023-09-13 Thread Thomas Monjalon
Calls to rte_ctrl_thread_create() are replaced with
rte_thread_create_internal_control().
Other pthread-related functions are replaced with the rte_thread API.
Only pthread_cancel() has no replacement.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 lib/eal/common/eal_common_proc.c| 15 ---
 lib/eal/freebsd/eal_interrupts.c| 10 +-
 lib/eal/linux/eal_interrupts.c  | 10 +-
 lib/eal/linux/eal_timer.c   | 11 ++-
 lib/eal/unix/rte_thread.c   |  2 +-
 lib/eal/windows/eal_interrupts.c|  2 +-
 lib/eventdev/rte_event_eth_rx_adapter.c | 23 ---
 lib/vhost/fd_man.c  |  6 +++---
 lib/vhost/fd_man.h  |  2 +-
 lib/vhost/socket.c  | 23 +++
 lib/vhost/vduse.c   |  5 +++--
 11 files changed, 56 insertions(+), 53 deletions(-)

diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c
index 26e6b78f8f..f20a348ede 100644
--- a/lib/eal/common/eal_common_proc.c
+++ b/lib/eal/common/eal_common_proc.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "eal_memcfg.h"
 #include "eal_private.h"
@@ -33,7 +34,7 @@
 #include "eal_internal_cfg.h"
 
 static int mp_fd = -1;
-static pthread_t mp_handle_tid;
+static rte_thread_t mp_handle_tid;
 static char mp_filter[PATH_MAX];   /* Filter for secondary process sockets */
 static char mp_dir_path[PATH_MAX]; /* The directory path for all mp sockets */
 static pthread_mutex_t mp_mutex_action = PTHREAD_MUTEX_INITIALIZER;
@@ -396,7 +397,7 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un 
*s)
}
 }
 
-static void *
+static uint32_t
 mp_handle(void *arg __rte_unused)
 {
struct mp_msg_internal msg;
@@ -413,7 +414,7 @@ mp_handle(void *arg __rte_unused)
process_msg(&msg, &sa);
}
 
-   return NULL;
+   return 0;
 }
 
 static int
@@ -646,8 +647,8 @@ rte_mp_channel_init(void)
return -1;
}
 
-   if (rte_ctrl_thread_create(&mp_handle_tid, "dpdk-mp-msg",
-   NULL, mp_handle, NULL) < 0) {
+   if (rte_thread_create_internal_control(&mp_handle_tid, "mp-msg",
+   mp_handle, NULL) < 0) {
RTE_LOG(ERR, EAL, "failed to create mp thread: %s\n",
strerror(errno));
close(dir_fd);
@@ -671,8 +672,8 @@ rte_mp_channel_cleanup(void)
if (fd < 0)
return;
 
-   pthread_cancel(mp_handle_tid);
-   pthread_join(mp_handle_tid, NULL);
+   pthread_cancel((pthread_t)mp_handle_tid.opaque_id);
+   rte_thread_join(mp_handle_tid, NULL);
close_socket_fd(fd);
 }
 
diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c
index 68cdb9deb3..2b31dfb099 100644
--- a/lib/eal/freebsd/eal_interrupts.c
+++ b/lib/eal/freebsd/eal_interrupts.c
@@ -52,7 +52,7 @@ static rte_spinlock_t intr_lock = RTE_SPINLOCK_INITIALIZER;
 static struct rte_intr_source_list intr_sources;
 
 /* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
 
 static volatile int kq = -1;
 
@@ -591,7 +591,7 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)
}
 }
 
-static void *
+static uint32_t
 eal_intr_thread_main(void *arg __rte_unused)
 {
struct kevent events[MAX_INTR_EVENTS];
@@ -619,7 +619,7 @@ eal_intr_thread_main(void *arg __rte_unused)
}
close(kq);
kq = -1;
-   return NULL;
+   return 0;
 }
 
 int
@@ -637,7 +637,7 @@ rte_eal_intr_init(void)
}
 
/* create the host thread to wait/handle the interrupt */
-   ret = rte_ctrl_thread_create(&intr_thread, "dpdk-intr", NULL,
+   ret = rte_thread_create_internal_control(&intr_thread, "intr",
eal_intr_thread_main, NULL);
if (ret != 0) {
rte_errno = -ret;
@@ -746,5 +746,5 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)
 
 int rte_thread_is_intr(void)
 {
-   return pthread_equal(intr_thread, pthread_self());
+   return rte_thread_equal(intr_thread, rte_thread_self());
 }
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index 19b36787b8..24fff3d3c2 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -5,7 +5,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -19,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -89,7 +89,7 @@ static union intr_pipefds intr_pipe;
 static struct rte_intr_source_list intr_sources;
 
 /* interrupt handling thread */
-static pthread_t intr_thread;
+static rte_thread_t intr_thread;
 
 /* VFIO interrupts */
 #ifdef VFIO_PRESENT
@@ -1103,7 +1103,7 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds)
  * @return
  *  never return;
  */

[PATCH v3 07/11] drivers: convert to internal control threads

2023-09-13 Thread Thomas Monjalon
Calls to rte_ctrl_thread_create() are replaced with
rte_thread_create_internal_control().
Other pthread-related functions are replaced with the rte_thread API.
Only pthread_cancel() has no replacement.

The mlx5 vDPA control threads were real-time threads
with an affinity on the core specified by the devarg "event_core".
As there is no heavy performance requirement,
these threads are converted into real control threads.

Some threads in dlb2 and mlx5 are not control threads
because they are designed to run on some specific cores.
It would be interesting to rework them in future.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
Acked-by: Andrew Rybchenko 
---
 drivers/common/cnxk/roc_dev.c  | 16 ++--
 drivers/common/cnxk/roc_dev_priv.h |  2 +-
 drivers/common/cnxk/roc_nix_inl_dev.c  |  9 +--
 drivers/common/cnxk/roc_nix_inl_priv.h |  2 +-
 drivers/common/cnxk/roc_platform.h |  3 +-
 drivers/dma/skeleton/skeleton_dmadev.c |  7 +-
 drivers/event/dlb2/pf/base/dlb2_osdep.h| 14 ++--
 drivers/event/dlb2/pf/base/dlb2_resource.c | 39 +-
 drivers/event/dlb2/pf/dlb2_main.h  |  1 -
 drivers/net/ark/ark_ethdev.c   | 11 ++-
 drivers/net/ark/ark_pktgen.c   |  8 +-
 drivers/net/ark/ark_pktgen.h   |  2 +-
 drivers/net/iavf/iavf_vchnl.c  |  2 +-
 drivers/net/ice/ice_dcf_parent.c   |  7 +-
 drivers/net/ipn3ke/ipn3ke_representor.c| 17 ++---
 drivers/net/ixgbe/ixgbe_ethdev.c   |  7 +-
 drivers/net/mlx5/mlx5.h|  2 +-
 drivers/net/mlx5/mlx5_hws_cnt.c| 42 ++-
 drivers/net/sfc/sfc_mae.h  |  2 +-
 drivers/net/sfc/sfc_mae_counter.c  | 11 ++-
 drivers/net/txgbe/txgbe_ethdev.c   |  6 +-
 drivers/raw/ifpga/ifpga_rawdev.c   | 19 +++--
 drivers/vdpa/ifc/ifcvf_vdpa.c  | 86 ++
 drivers/vdpa/mlx5/mlx5_vdpa.c  |  2 +-
 drivers/vdpa/mlx5/mlx5_vdpa.h  | 10 +--
 drivers/vdpa/mlx5/mlx5_vdpa_cthread.c  | 70 +-
 drivers/vdpa/mlx5/mlx5_vdpa_event.c| 64 +---
 drivers/vdpa/sfc/sfc_vdpa_ops.c| 15 ++--
 drivers/vdpa/sfc/sfc_vdpa_ops.h|  3 +-
 29 files changed, 203 insertions(+), 276 deletions(-)

diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index 13d3eece47..08fd13f741 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -18,7 +18,7 @@
 #define ROC_PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */
 
 /* VF Mbox handler thread name */
-#define MBOX_HANDLER_NAME_MAX_LEN 25
+#define MBOX_HANDLER_NAME_MAX_LEN RTE_THREAD_INTERNAL_NAME_SIZE
 
 /* VF interrupt message pending bits - mbox or flr */
 #define ROC_DEV_MBOX_PEND BIT_ULL(0)
@@ -1070,7 +1070,7 @@ vf_flr_handle_msg(void *param, dev_intr_t *flr)
}
 }
 
-static void *
+static uint32_t
 pf_vf_mbox_thread_main(void *arg)
 {
struct dev *dev = arg;
@@ -1114,7 +1114,7 @@ pf_vf_mbox_thread_main(void *arg)
 
pthread_mutex_unlock(&dev->sync.mutex);
 
-   return NULL;
+   return 0;
 }
 
 static void
@@ -1455,10 +1455,10 @@ dev_init(struct dev *dev, struct plt_pci_device 
*pci_dev)
pthread_cond_init(&dev->sync.pfvf_msg_cond, NULL);
pthread_mutex_init(&dev->sync.mutex, NULL);
 
-   snprintf(name, MBOX_HANDLER_NAME_MAX_LEN, "pf%d_vf_msg_hndlr", 
dev->pf);
+   snprintf(name, MBOX_HANDLER_NAME_MAX_LEN, "mbox_pf%d", dev->pf);
dev->sync.start_thread = true;
-   rc = plt_ctrl_thread_create(&dev->sync.pfvf_msg_thread, name, 
NULL,
-   pf_vf_mbox_thread_main, dev);
+   rc = plt_thread_create_control(&dev->sync.pfvf_msg_thread, name,
+   pf_vf_mbox_thread_main, dev);
if (rc != 0) {
plt_err("Failed to create thread for VF mbox 
handling\n");
goto iounmap;
@@ -1488,7 +1488,7 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev)
if (dev->sync.start_thread) {
dev->sync.start_thread = false;
pthread_cond_signal(&dev->sync.pfvf_msg_cond);
-   pthread_join(dev->sync.pfvf_msg_thread, NULL);
+   plt_thread_join(dev->sync.pfvf_msg_thread, NULL);
pthread_mutex_destroy(&dev->sync.mutex);
pthread_cond_destroy(&dev->sync.pfvf_msg_cond);
}
@@ -1519,7 +1519,7 @@ dev_fini(struct dev *dev, struct plt_pci_device *pci_dev)
if (dev->sync.start_thread) {
dev->sync.start_thread = false;
pthread_cond_signal(&dev->sync.pfvf_msg_cond);
-   pthread_join(dev->sync.pfvf_msg_thread, NULL);
+   plt_thread_join(dev->sync.pfvf_msg_thread, NULL);
pthread_mutex_destroy(&dev->sync.mutex);
pthrea

[PATCH v3 08/11] examples: convert to normal control threads

2023-09-13 Thread Thomas Monjalon
Calls to rte_ctrl_thread_create() are replaced with
rte_thread_create_control().

In vhost_blk, the control thread is not forced
to be scheduled on core 0 anymore.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 examples/vhost/main.c  |  9 +
 examples/vhost_blk/vhost_blk.c | 21 ++---
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 9ff2c1f31b..ce5c1efddf 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "main.h"
 
@@ -1807,7 +1808,7 @@ static const struct rte_vhost_device_ops 
virtio_net_device_ops =
  * This is a thread will wake up after a period to print stats if the user has
  * enabled them.
  */
-static void *
+static uint32_t
 print_stats(__rte_unused void *arg)
 {
struct vhost_dev *vdev;
@@ -1852,7 +1853,7 @@ print_stats(__rte_unused void *arg)
fflush(stdout);
}
 
-   return NULL;
+   return 0;
 }
 
 static void
@@ -1907,7 +1908,7 @@ main(int argc, char *argv[])
unsigned nb_ports, valid_num_ports;
int ret, i;
uint16_t portid;
-   static pthread_t tid;
+   rte_thread_t tid;
uint64_t flags = RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS;
 
signal(SIGINT, sigint_handler);
@@ -1986,7 +1987,7 @@ main(int argc, char *argv[])
 
/* Enable stats if the user option is set. */
if (enable_stats) {
-   ret = rte_ctrl_thread_create(&tid, "dpdk-vhost-stat", NULL,
+   ret = rte_thread_create_control(&tid, "dpdk-vhost-stat",
print_stats, NULL);
if (ret < 0)
rte_exit(EXIT_FAILURE,
diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index 45699eb0b3..376f7b89a7 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -5,8 +5,6 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
-#include 
-#include 
 
 #include 
 #include 
@@ -529,12 +527,10 @@ process_vq(struct vhost_blk_queue *vq)
}
 }
 
-static void *
+static uint32_t
 ctrlr_worker(void *arg)
 {
struct vhost_blk_ctrlr *ctrlr = (struct vhost_blk_ctrlr *)arg;
-   cpu_set_t cpuset;
-   pthread_t thread;
int i;
 
fprintf(stdout, "Ctrlr Worker Thread start\n");
@@ -546,11 +542,6 @@ ctrlr_worker(void *arg)
exit(0);
}
 
-   thread = pthread_self();
-   CPU_ZERO(&cpuset);
-   CPU_SET(0, &cpuset);
-   pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
-
for (i = 0; i < NUM_OF_BLK_QUEUES; i++)
submit_inflight_vq(&ctrlr->queues[i]);
 
@@ -560,7 +551,7 @@ ctrlr_worker(void *arg)
 
fprintf(stdout, "Ctrlr Worker Thread Exiting\n");
sem_post(&exit_sem);
-   return NULL;
+   return 0;
 }
 
 static int
@@ -605,7 +596,7 @@ new_device(int vid)
struct vhost_blk_queue *vq;
char path[PATH_MAX];
uint64_t features, protocol_features;
-   pthread_t tid;
+   rte_thread_t tid;
int i, ret;
bool packed_ring, inflight_shmfd;
 
@@ -686,15 +677,15 @@ new_device(int vid)
/* start polling vring */
worker_thread_status = WORKER_STATE_START;
fprintf(stdout, "New Device %s, Device ID %d\n", path, vid);
-   if (rte_ctrl_thread_create(&tid, "dpdk-vhost-blk", NULL,
-  &ctrlr_worker, ctrlr) != 0) {
+   if (rte_thread_create_control(&tid, "dpdk-vhost-blk",
+   &ctrlr_worker, ctrlr) != 0) {
fprintf(stderr, "Worker Thread Started Failed\n");
return -1;
}
 
/* device has been started */
ctrlr->started = 1;
-   pthread_detach(tid);
+   rte_thread_detach(tid);
return 0;
 }
 
-- 
2.42.0



[PATCH v3 09/11] test: convert threads creation

2023-09-13 Thread Thomas Monjalon
Calls to pthread for thread creation are replaced with the rte_thread API.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
---
 app/test/process.h | 10 +-
 app/test/test_lcores.c |  9 -
 app/test/test_pdump.c  |  6 +++---
 app/test/test_pdump.h  |  2 +-
 4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/app/test/process.h b/app/test/process.h
index 1f073b9c5c..af7bc3e0de 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -28,8 +28,8 @@
 
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
-#include 
-extern void *send_pkts(void *empty);
+#include 
+extern uint32_t send_pkts(void *empty);
 extern uint16_t flag_for_send_pkts;
 #endif
 #endif
@@ -49,7 +49,7 @@ process_dup(const char *const argv[], int numargs, const char 
*env_value)
char path[32];
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
-   pthread_t thread;
+   rte_thread_t thread;
int rc;
 #endif
 #endif
@@ -136,7 +136,7 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
 #ifdef RTE_LIB_PDUMP
 #ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
-   rc = pthread_create(&thread, NULL, &send_pkts, NULL);
+   rc = rte_thread_create(&thread, NULL, send_pkts, NULL);
if (rc != 0) {
rte_panic("Cannot start send pkts thread: %s\n",
  strerror(rc));
@@ -151,7 +151,7 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
 #ifdef RTE_NET_RING
if ((strcmp(env_value, "run_pdump_server_tests") == 0)) {
flag_for_send_pkts = 0;
-   pthread_join(thread, NULL);
+   rte_thread_join(thread, NULL);
}
 #endif
 #endif
diff --git a/app/test/test_lcores.c b/app/test/test_lcores.c
index 0c96faa4cb..5a9fd3 100644
--- a/app/test/test_lcores.c
+++ b/app/test/test_lcores.c
@@ -2,7 +2,6 @@
  * Copyright (c) 2020 Red Hat, Inc.
  */
 
-#include 
 #include 
 
 #include 
@@ -341,7 +340,7 @@ test_non_eal_lcores_callback(unsigned int eal_threads_count)
return -1;
 }
 
-static void *ctrl_thread_loop(void *arg)
+static uint32_t ctrl_thread_loop(void *arg)
 {
struct thread_context *t = arg;
 
@@ -350,7 +349,7 @@ static void *ctrl_thread_loop(void *arg)
/* Set the thread state to DONE */
t->state = Thread_DONE;
 
-   return NULL;
+   return 0;
 }
 
 static int
@@ -362,8 +361,8 @@ test_ctrl_thread(void)
/* Create one control thread */
t = &ctrl_thread_context;
t->state = Thread_INIT;
-   if (rte_ctrl_thread_create((pthread_t *)&t->id, "dpdk-test-ctrlt",
-   NULL, ctrl_thread_loop, t) != 0)
+   if (rte_thread_create_control(&t->id, "dpdk-test-ctrlt",
+   ctrl_thread_loop, t) != 0)
return -1;
 
/* Wait till the control thread exits.
diff --git a/app/test/test_pdump.c b/app/test/test_pdump.c
index ea03056b47..adf49f0b54 100644
--- a/app/test/test_pdump.c
+++ b/app/test/test_pdump.c
@@ -136,8 +136,8 @@ test_pdump_uninit(void)
return ret;
 }
 
-void *
-send_pkts(void *empty)
+uint32_t
+send_pkts(void *empty __rte_unused)
 {
int ret = 0;
struct rte_mbuf *pbuf[NUM_PACKETS] = { };
@@ -161,7 +161,7 @@ send_pkts(void *empty)
 
rte_eth_dev_stop(portid);
test_put_mbuf_to_pool(mp, pbuf);
-   return empty;
+   return 0;
 }
 
 /*
diff --git a/app/test/test_pdump.h b/app/test/test_pdump.h
index abef9a85ec..8746d61269 100644
--- a/app/test/test_pdump.h
+++ b/app/test/test_pdump.h
@@ -9,7 +9,7 @@
 #define NUM_ITR 3
 
 /* sample test to send packets to the pdump client recursively */
-void *send_pkts(void *port);
+uint32_t send_pkts(void *empty);
 
 /* Sample test to create setup for the pdump server tests */
 int test_pdump_init(void);
-- 
2.42.0



[PATCH v3 10/11] eal: remove deprecated thread functions

2023-09-13 Thread Thomas Monjalon
The deprecated functions rte_thread_setname() and rte_ctrl_thread_create()
are replaced with the new rte_thread API:

rte_thread_setname()
can be replaced with
rte_thread_set_name()
or  rte_thread_set_prefixed_name()

rte_ctrl_thread_create()
can be replaced with
rte_thread_create_control()
or  rte_thread_create_internal_control()

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 

---
v2: clean control thread params struct
---
 .../prog_guide/env_abstraction_layer.rst  |  2 +-
 doc/guides/rel_notes/deprecation.rst  |  5 -
 doc/guides/rel_notes/release_23_11.rst|  4 +-
 lib/eal/common/eal_common_thread.c| 93 +++
 lib/eal/freebsd/eal_thread.c  |  7 --
 lib/eal/include/rte_lcore.h   | 42 -
 lib/eal/linux/eal_thread.c| 16 
 lib/eal/version.map   |  2 -
 lib/eal/windows/eal_thread.c  |  8 --
 9 files changed, 18 insertions(+), 161 deletions(-)

diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst 
b/doc/guides/prog_guide/env_abstraction_layer.rst
index 89014789de..6debf54efb 100644
--- a/doc/guides/prog_guide/env_abstraction_layer.rst
+++ b/doc/guides/prog_guide/env_abstraction_layer.rst
@@ -756,7 +756,7 @@ Control Thread API
 ~~
 
 It is possible to create Control Threads using the public API
-``rte_ctrl_thread_create()``.
+``rte_thread_create_control()``.
 Those threads can be used for management/infrastructure tasks and are used
 internally by DPDK for multi process support and interrupt handling.
 
diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index 3e48908b51..8c8873006d 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -29,11 +29,6 @@ Deprecation Notices
   are renamed to ``rte_tel_data_add_array_uint`` and 
``rte_tel_data_add_dict_uint`` respectively.
   As such, the old function names are deprecated and will be removed in a 
future release.
 
-* eal: The functions ``rte_thread_setname`` and ``rte_ctrl_thread_create``
-  are planned to be deprecated starting with the 23.07 release, subject to
-  the replacement API rte_thread_set_name and rte_thread_create_control being
-  marked as stable, and planned to be removed by the 23.11 release.
-
 * eal: ``RTE_CPUFLAG_NUMFLAGS`` will be removed in DPDK 23.11 release.
   This is to allow new CPU features to be added without ABI breakage.
 
diff --git a/doc/guides/rel_notes/release_23_11.rst 
b/doc/guides/rel_notes/release_23_11.rst
index d7562fd646..9746809a66 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -115,7 +115,9 @@ API Changes
 
 * eal: The thread API has changed.
   The function ``rte_thread_create_control()`` does not take attributes 
anymore.
-  The whole thread API was promoted to stable level.
+  The whole thread API was promoted to stable level,
+  except ``rte_thread_setname()`` and ``rte_ctrl_thread_create()`` which are
+  replaced with ``rte_thread_set_name()`` and ``rte_thread_create_control()``.
 
 
 ABI Changes
diff --git a/lib/eal/common/eal_common_thread.c 
b/lib/eal/common/eal_common_thread.c
index 830273813f..668b1ed96b 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -235,25 +235,22 @@ enum __rte_ctrl_thread_status {
CTRL_THREAD_ERROR /* Control thread encountered an error */
 };
 
-struct rte_thread_ctrl_params {
-   union {
-   void *(*ctrl_start_routine)(void *arg);
-   rte_thread_func control_start_routine;
-   } u;
+struct control_thread_params {
+   rte_thread_func start_routine;
void *arg;
int ret;
/* Control thread status.
 * If the status is CTRL_THREAD_ERROR, 'ret' has the error code.
 */
-   enum __rte_ctrl_thread_status ctrl_thread_status;
+   enum __rte_ctrl_thread_status status;
 };
 
-static int ctrl_thread_init(void *arg)
+static int control_thread_init(void *arg)
 {
struct internal_config *internal_conf =
eal_get_internal_configuration();
rte_cpuset_t *cpuset = &internal_conf->ctrl_cpuset;
-   struct rte_thread_ctrl_params *params = arg;
+   struct control_thread_params *params = arg;
 
__rte_thread_init(rte_lcore_id(), cpuset);
/* Set control thread socket ID to SOCKET_ID_ANY
@@ -262,96 +259,34 @@ static int ctrl_thread_init(void *arg)
RTE_PER_LCORE(_socket_id) = SOCKET_ID_ANY;
params->ret = rte_thread_set_affinity_by_id(rte_thread_self(), cpuset);
if (params->ret != 0) {
-   __atomic_store_n(¶ms->ctrl_thread_status,
+   __atomic_store_n(¶ms->status,
CTRL_THREAD_ERROR, __ATOMIC_RELEASE);
return 1;
}
 
-   __atomic_store_n(¶ms->ctrl_thread_status,
+ 

[PATCH v3 11/11] lib: remove pthread.h from includes

2023-09-13 Thread Thomas Monjalon
The header files should have the minimum embedded includes.
The file pthread.h can logically be removed from
rte_per_lcore.h and rte_ethdev_core.h files.

Signed-off-by: Thomas Monjalon 
Acked-by: Morten Brørup 
Acked-by: Tyler Retzlaff 
Acked-by: Ajit Khaparde 
Acked-by: Rosen Xu 
---
 app/test/test_link_bonding.c   | 2 ++
 drivers/common/mlx5/mlx5_common.c  | 1 +
 drivers/common/mlx5/windows/mlx5_win_ext.h | 2 ++
 drivers/net/bnxt/bnxt.h| 1 +
 drivers/net/qede/base/bcm_osal.h   | 1 +
 drivers/raw/ifpga/base/opae_osdep.h| 1 +
 drivers/vdpa/sfc/sfc_vdpa.c| 1 +
 lib/eal/common/eal_common_options.c| 1 +
 lib/eal/common/eal_common_trace.c  | 1 +
 lib/eal/common/malloc_mp.c | 1 +
 lib/eal/freebsd/eal_alarm.c| 1 +
 lib/eal/include/rte_per_lcore.h| 2 --
 lib/eal/linux/eal_alarm.c  | 1 +
 lib/ethdev/ethdev_driver.c | 1 +
 lib/ethdev/ethdev_driver.h | 2 ++
 lib/ethdev/rte_ethdev_core.h   | 2 --
 lib/ethdev/rte_flow.c  | 1 +
 lib/eventdev/rte_event_eth_rx_adapter.c| 1 +
 lib/vhost/vhost.c  | 1 +
 19 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 2f46e4c6ee..d6b6ebc2f2 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -10,8 +10,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+
 #include 
 #include 
 #include 
diff --git a/drivers/common/mlx5/mlx5_common.c 
b/drivers/common/mlx5/mlx5_common.c
index 0ad14a48c7..ca8543e36e 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/common/mlx5/windows/mlx5_win_ext.h 
b/drivers/common/mlx5/windows/mlx5_win_ext.h
index 6f69329a6f..a71c69bff5 100644
--- a/drivers/common/mlx5/windows/mlx5_win_ext.h
+++ b/drivers/common/mlx5/windows/mlx5_win_ext.h
@@ -5,6 +5,8 @@
 #ifndef __MLX5_WIN_ETX_H__
 #define __MLX5_WIN_ETX_H__
 
+#include 
+
 #include "mlx5_prm.h"
 #include "mlx5devx.h"
 
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index ed21ba7f29..0e01b1d4ba 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h
index 97e261d306..11019b5623 100644
--- a/drivers/net/qede/base/bcm_osal.h
+++ b/drivers/net/qede/base/bcm_osal.h
@@ -8,6 +8,7 @@
 #define __BCM_OSAL_H
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/raw/ifpga/base/opae_osdep.h 
b/drivers/raw/ifpga/base/opae_osdep.h
index 033b7e098c..e91205f536 100644
--- a/drivers/raw/ifpga/base/opae_osdep.h
+++ b/drivers/raw/ifpga/base/opae_osdep.h
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 
 #ifdef RTE_LIB_EAL
 #include "osdep_rte/osdep_generic.h"
diff --git a/drivers/vdpa/sfc/sfc_vdpa.c b/drivers/vdpa/sfc/sfc_vdpa.c
index bd6ecde450..9db87fcb7d 100644
--- a/drivers/vdpa/sfc/sfc_vdpa.c
+++ b/drivers/vdpa/sfc/sfc_vdpa.c
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/lib/eal/common/eal_common_options.c 
b/lib/eal/common/eal_common_options.c
index d74b581567..a6d21f1cba 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #ifndef RTE_EXEC_ENV_WINDOWS
 #include 
 #endif
diff --git a/lib/eal/common/eal_common_trace.c 
b/lib/eal/common/eal_common_trace.c
index cb980af06d..b21e61bf39 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c
index 7270c2ec90..4d62397aba 100644
--- a/lib/eal/common/malloc_mp.c
+++ b/lib/eal/common/malloc_mp.c
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c
index acdcf53804..e5b0909a45 100644
--- a/lib/eal/freebsd/eal_alarm.c
+++ b/lib/eal/freebsd/eal_alarm.c
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/lib/eal/include/rte_per_lcore.h b/lib/eal/include/rte_per_lcore.h
index 2b846f9337..5a1497631a 100644
--- a/lib/eal/include/rte_per_lcore.h
+++ b/lib/eal/include/rte_per_lcore.h
@@ -22,8 +22,6 @@
 extern "C" {
 #endif
 
-#include 
-
 #ifdef RTE_TOOLCHAIN_MSVC
 /**
  * Macro to define a per lcore variable "var" of type "type", don't
diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c
index 397f25d7d5..766ba2c251 100644
--- a/lib/eal/linux/eal_alarm.c
+++ b/lib/eal/linux/eal_alarm.c
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include 
+#incl

RE: [PATCH v4 4/7] app/proc-info: fix never show RSS info

2023-09-13 Thread Pattan, Reshma



> -Original Message-
> From: Jie Hai 
> Sent: Friday, September 8, 2023 9:00 AM
> To: dev@dpdk.org; Pattan, Reshma ; Vipin
> Varghese ; Mcnamara, John
> 
> Cc: haij...@huawei.com; lihuis...@huawei.com
> Subject: [PATCH v4 4/7] app/proc-info: fix never show RSS info
> 
> Command show-port should show RSS info (rss_key, len and rss_hf), However,
> the information is shown only when rss_conf.rss_key is not NULL. Since no
> memory is allocated for rss_conf.rss_key, rss_key will always be NULL and the
> rss_info will never show. This patch allocates memory for rss_conf.rss_key and
> makes it possible to show RSS info.
> 

Nitpick:
You have to change the commit message as malloc and free not used now.

Acked-by: Reshma Pattan 






RE: [PATCH v4 5/7] app/proc-info: adjust the display format of RSS info

2023-09-13 Thread Pattan, Reshma



> -Original Message-
> From: Jie Hai 
> Subject: [PATCH v4 5/7] app/proc-info: adjust the display format of RSS info
> 
> Signed-off-by: Jie Hai 

Acked-by: Reshma Pattan



[PATCH v2 1/1] net/mana: enable 32 bit build for mana driver

2023-09-13 Thread Wei Hu
Enable 32 bit build on x86 Linux. Fixed build warnings and errors
when building in 32 bit.

Cc: sta...@dpdk.org

Signed-off-by: Wei Hu 

---
v2: change port casting from size_t to uintptr_t. 
---
 drivers/net/mana/mana.c  |  2 +-
 drivers/net/mana/meson.build |  4 ++--
 drivers/net/mana/mr.c| 18 +-
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c
index 7630118d4f..896b53ed35 100644
--- a/drivers/net/mana/mana.c
+++ b/drivers/net/mana/mana.c
@@ -1260,7 +1260,7 @@ mana_probe_port(struct ibv_device *ibdev, struct 
ibv_device_attr_ex *dev_attr,
/* Create a parent domain with the port number */
attr.pd = priv->ib_pd;
attr.comp_mask = IBV_PARENT_DOMAIN_INIT_ATTR_PD_CONTEXT;
-   attr.pd_context = (void *)(uint64_t)port;
+   attr.pd_context = (void *)(uintptr_t)port;
priv->ib_parent_pd = ibv_alloc_parent_domain(ctx, &attr);
if (!priv->ib_parent_pd) {
DRV_LOG(ERR, "ibv_alloc_parent_domain failed port %d", port);
diff --git a/drivers/net/mana/meson.build b/drivers/net/mana/meson.build
index 493f0d26d4..2d72eca5a8 100644
--- a/drivers/net/mana/meson.build
+++ b/drivers/net/mana/meson.build
@@ -1,9 +1,9 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2022 Microsoft Corporation
 
-if not is_linux or not dpdk_conf.has('RTE_ARCH_X86_64')
+if not is_linux or not dpdk_conf.has('RTE_ARCH_X86')
 build = false
-reason = 'only supported on x86_64 Linux'
+reason = 'only supported on x86 Linux'
 subdir_done()
 endif
 
diff --git a/drivers/net/mana/mr.c b/drivers/net/mana/mr.c
index fec0dc961c..b8e6ea0bbf 100644
--- a/drivers/net/mana/mr.c
+++ b/drivers/net/mana/mr.c
@@ -53,7 +53,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct 
mana_priv *priv,
}
 
DP_LOG(DEBUG,
-  "registering memory chunk start 0x%" PRIx64 " len %u",
+  "registering memory chunk start 0x%" PRIxPTR " len %u",
   ranges[i].start, ranges[i].len);
 
if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
@@ -62,7 +62,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct 
mana_priv *priv,
ranges[i].len);
if (ret) {
DP_LOG(ERR,
-  "MR failed start 0x%" PRIx64 " len %u",
+  "MR failed start 0x%" PRIxPTR " len %u",
   ranges[i].start, ranges[i].len);
return ret;
}
@@ -72,7 +72,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct 
mana_priv *priv,
ibv_mr = ibv_reg_mr(priv->ib_pd, (void *)ranges[i].start,
ranges[i].len, IBV_ACCESS_LOCAL_WRITE);
if (ibv_mr) {
-   DP_LOG(DEBUG, "MR lkey %u addr %p len %" PRIu64,
+   DP_LOG(DEBUG, "MR lkey %u addr %p len %zu",
   ibv_mr->lkey, ibv_mr->addr, ibv_mr->length);
 
mr = rte_calloc("MANA MR", 1, sizeof(*mr), 0);
@@ -99,7 +99,7 @@ mana_new_pmd_mr(struct mana_mr_btree *local_tree, struct 
mana_priv *priv,
return ret;
}
} else {
-   DP_LOG(ERR, "MR failed at 0x%" PRIx64 " len %u",
+   DP_LOG(ERR, "MR failed at 0x%" PRIxPTR " len %u",
   ranges[i].start, ranges[i].len);
return -errno;
}
@@ -141,7 +141,7 @@ mana_find_pmd_mr(struct mana_mr_btree *local_mr_btree, 
struct mana_priv *priv,
mr = mana_mr_btree_lookup(local_mr_btree, &idx,
  (uintptr_t)mbuf->buf_addr, mbuf->buf_len);
if (mr) {
-   DP_LOG(DEBUG, "Local mr lkey %u addr 0x%" PRIx64 " len %" 
PRIu64,
+   DP_LOG(DEBUG, "Local mr lkey %u addr 0x%" PRIxPTR " len %zu",
   mr->lkey, mr->addr, mr->len);
return mr;
}
@@ -162,7 +162,7 @@ mana_find_pmd_mr(struct mana_mr_btree *local_mr_btree, 
struct mana_priv *priv,
}
 
DP_LOG(DEBUG,
-  "Added local MR key %u addr 0x%" PRIx64 " len %" PRIu64,
+  "Added local MR key %u addr 0x%" PRIxPTR " len %zu",
   mr->lkey, mr->addr, mr->len);
return mr;
}
@@ -266,7 +266,7 @@ mana_mr_btree_lookup(struct mana_mr_btree *bt, uint16_t 
*idx,
return &table[base];
 
DP_LOG(DEBUG,
-  "addr 0x%" PRIx64 " len %zu idx %u sum 0x%" PRIx64 " not found",
+  "addr 0x%" PRIxPTR " len %zu idx %u sum 0x%" PRIxPTR " not 
found",
   addr, len, *idx, addr + len);
 

Re: Commit broke 32-bit testpmd app

2023-09-13 Thread Roger Melton (rmelton)
+Chris Brezovec

Hi Maxime,

Chris from our team is attending the DPDK Summit in Dublin this week.  If you 
have some time available, we'd appreciate it if he could meet with you to 
discuss the 32bit virtio issue we are seeing.

Regards,
Roger Melton

On 9/6/23 2:57 PM, Dave Johnson (davejo) wrote:
Hi Maxime,
This email is regarding the following commit:
https://github.com/DPDK/dpdk/commit/ba55c94a7ebc386d2288d6578ed57aad6cb92657

A query had been sent previously on this topic (see below) indicating this 
commit appears to have broken the 32-bit testpmd app and impacted one of our 
products that runs as a 32-bit DPDK application.  We consequently backed the 
commit out of our product but would prefer to get a fix for it.  In the earlier 
exchange, you had asked if we were using virtio-pci or virtio-user (we are 
using virtio-pci) and asked for logs which Sampath provided.  It’s been a 
while, so let me now if you need me to send resend those logs or need any other 
information.

FWIW, I reproduced this using testpmd and noticed that this part of the change 
seems to be the interesting part (in drivers/net/virtio/virtqueue.h):

/**
* Return the IOVA (or virtual address in case of virtio-user) of mbuf
* data buffer.
*
* The address is firstly casted to the word size (sizeof(uintptr_t))
* before casting it to uint64_t. This is to make it work with different
* combination of word size (64 bit and 32 bit) and virtio device
* (virtio-pci and virtio-user).
*/
#define VIRTIO_MBUF_ADDR(mb, vq) \
  ((uint64_t)(*(uintptr_t *)((uintptr_t)(mb) + (vq)->mbuf_addr_offset))

If I revert just this part of the changeset (by re-using the VIRTIO_MBUF_ADDR 
to return buf_iova which matches what it had used previously), then 32-bit 
testpmd is able to receive traffic again:

#define VIRTIO_MBUF_ADDR(mb, vq) (mb->buf_iova)

Looking at the address produced by each of these, I see the address is the same 
except that the casting results in the upper bits getting cleared:

Address from patch (nonworking case) = 0x58e7c900
Address using buf_iova (working case) = 0x158e7c900
::
Address from patch (nonworking case) = 0x58e7bfc0
Address using buf_iova (working case) = 0x158e7bfc0
::
Address from patch (nonworking case) = 0x58e7b680
Address using buf_iova (working case) = 0x158e7b680
::

Regards, Dave

From: Sampath Peechu (speechu) 
Date: Monday, January 30, 2023 at 3:29 PM
To: Maxime Coquelin 
, 
chenbo@intel.com 
, 
dev@dpdk.org 
Cc: Roger Melton (rmelton) , 
Malcolm Bumgardner (mbumgard) 
Subject: Re: Commit broke 32-bit testpmd app
Hi Maxime,

Could you please let us know if you got a chance to look at the debugs logs I 
provided?

Thanks,
Sampath


From: Sampath Peechu (speechu) 
Date: Tuesday, December 6, 2022 at 1:08 PM
To: Maxime Coquelin 
, 
chenbo@intel.com 
, 
dev@dpdk.org 
Cc: Roger Melton (rmelton) 
Subject: Re: Commit broke 32-bit testpmd app
Hi Maxime,

Did you get a chance to look into this?

Please let me know if you need anything else.

Thanks,
Sampath

From: Sampath Peechu (speechu) 
Date: Wednesday, November 23, 2022 at 5:15 PM
To: Maxime Coquelin 
, 
chenbo@intel.com 
, 
dev@dpdk.org 
Cc: Roger Melton (rmelton) 
Subject: Re: Commit broke 32-bit testpmd app
Hi Maxime,

I’m attaching the following for reference.


  *   Instructions for Centos8 test setup
  *   Diffs between the working and non-working versions (working version has 
the problem commit backed out)
  *   Working logs (stats show that ping packets from neighbor VM can be seen 
with both 64-bit and 32-bit apps)
  *   Non-working logs (stats show that ping packets from neighbor VM are seen 
with 64-bit app but NOT seen with 32-bit app)




$ sudo ./usertools/dpdk-devbind.py --status

Network devices using DPDK-compatible driver

:07:00.0 'Virtio network device 1041' drv=igb_uio unused=
:08:00.0 'Virtio network device 1041' drv=igb_uio unused=

Network devices using kernel driver
===
:01:00.0 'Virtio network device 1041' if=enp1s0 drv=virtio-pci 
unused=igb_uio *Active*

…
===


Thanks,
Sampath



From: Maxime Coquelin 

Date: Tuesday, November 22, 2022 at 4:24 AM
To: Sampath Peechu (speechu) , 
chenbo@intel.com 


[PATCH] maintainers: update for gro and gso

2023-09-13 Thread hujiayu . hu
From: Jiayu Hu 

Update the email address for gro and gso libraries.

Signed-off-by: Jiayu Hu 
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 698608cdb2..8b00ae4711 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1481,12 +1481,12 @@ F: examples/ip_reassembly/
 F: doc/guides/sample_app_ug/ip_reassembly.rst
 
 Generic Receive Offload - EXPERIMENTAL
-M: Jiayu Hu 
+M: Jiayu Hu 
 F: lib/gro/
 F: doc/guides/prog_guide/generic_receive_offload_lib.rst
 
 Generic Segmentation Offload
-M: Jiayu Hu 
+M: Jiayu Hu 
 F: lib/gso/
 F: doc/guides/prog_guide/generic_segmentation_offload_lib.rst
 
-- 
2.34.1



[PATCH] app/bbdev: fix link with NXP LA12XX

2023-09-13 Thread David Marchand
The LA12XX driver was not linked to the dpdk-test-bbdev tool because of
what looks like a rebase issue.

Fixes: 2b504721bfda ("app/bbdev: enable la12xx")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand 
---
 app/test-bbdev/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-bbdev/meson.build b/app/test-bbdev/meson.build
index cd6a5089d5..926e0a5271 100644
--- a/app/test-bbdev/meson.build
+++ b/app/test-bbdev/meson.build
@@ -23,6 +23,6 @@ endif
 if dpdk_conf.has('RTE_BASEBAND_ACC')
 deps += ['baseband_acc']
 endif
-if dpdk_conf.has('RTE_LIBRTE_PMD_BBDEV_LA12XX')
+if dpdk_conf.has('RTE_BASEBAND_LA12XX')
 deps += ['baseband_la12xx']
 endif
-- 
2.41.0



[PATCH 2/2] crypto/dpaa_sec: fix debug prints

2023-09-13 Thread David Marchand
RTE_LIBRTE_SECURITY has been replaced with RTE_LIB_SECURITY for a
while now.

Fixes: b1bbf222bef1 ("crypto/dpaa_sec: add debug prints")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand 
---
 drivers/crypto/dpaa_sec/dpaa_sec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c 
b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 7d47c32693..f3f565826f 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -666,7 +666,7 @@ dpaa_sec_dump(struct dpaa_sec_op_ctx *ctx, struct 
dpaa_sec_qp *qp)
 
if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
sess = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session);
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION)
sess = SECURITY_GET_SESS_PRIV(op->sym->session);
 #endif
@@ -677,7 +677,7 @@ dpaa_sec_dump(struct dpaa_sec_op_ctx *ctx, struct 
dpaa_sec_qp *qp)
 
cdb = &sess->cdb;
rte_memcpy(&c_cdb, cdb, sizeof(struct sec_cdb));
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
printf("\nsession protocol type = %d\n", sess->proto_alg);
 #endif
printf("\n\n"
@@ -702,7 +702,7 @@ dpaa_sec_dump(struct dpaa_sec_op_ctx *ctx, struct 
dpaa_sec_qp *qp)
sess->iv.length, sess->iv.offset,
sess->digest_length, sess->auth_only_len,
sess->auth_cipher_text);
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
printf("PDCP session params:\n"
"\tDomain:\t\t%d\n\tBearer:\t\t%d\n\tpkt_dir:\t%d\n\thfn_ovd:"
"\t%d\n\tsn_size:\t%d\n\tsdap_enabled:\t%d\n\thfn_ovd_offset:"
-- 
2.41.0



[PATCH 1/2] crypto/dpaa2_sec: fix debug prints

2023-09-13 Thread David Marchand
RTE_LIBRTE_SECURITY has been replaced with RTE_LIB_SECURITY for a
while now.

Fixes: 84bb24bd058c ("crypto/dpaa2_sec: add debug prints")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand 
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c 
b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 5ccfcbd7a6..f9eba4a7bd 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -1663,7 +1663,7 @@ dpaa2_sec_dump(struct rte_crypto_op *op)
 
if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
sess = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session);
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION)
sess = SECURITY_GET_SESS_PRIV(op->sym->session);
 #endif
@@ -1690,7 +1690,7 @@ dpaa2_sec_dump(struct rte_crypto_op *op)
sess->digest_length, sess->status,
sess->ext_params.aead_ctxt.auth_only_len,
sess->ext_params.aead_ctxt.auth_cipher_text);
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
printf("PDCP session params:\n"
"\tDomain:\t\t%d\n\tBearer:\t\t%d\n\tpkt_dir:\t%d\n\thfn_ovd:"
"\t%d\n\tsn_size:\t%d\n\thfn_ovd_offset:\t%d\n\thfn:\t\t%d\n"
-- 
2.41.0



[PATCH] common/cnxk: remove dead meson code

2023-09-13 Thread David Marchand
config_flag_fmt was used in the past and was dropped with commit
762bfccc8abf ("config: remove compatibility build defines").

Fixes: fa8f86a14e2e ("common/cnxk: add build infrastructre and HW definition")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand 
---
 drivers/common/cnxk/meson.build | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index 79e10bac74..fe1609a025 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -8,7 +8,6 @@ if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
 subdir_done()
 endif
 
-config_flag_fmt = 'RTE_LIBRTE_@0@_COMMON'
 deps = ['eal', 'pci', 'bus_pci', 'mbuf', 'security']
 sources = files(
 'roc_ae.c',
-- 
2.41.0



[PATCH] net/iavf: fix Tx debug

2023-09-13 Thread David Marchand
Commit 1e728b01120c ("net/iavf: rework Tx path") reintroduced a check on
RTE_LIBRTE_IAVF_DEBUG_TX that has been dropped in favor of
RTE_ETHDEV_DEBUG_TX.

Fixes: 1e728b01120c ("net/iavf: rework Tx path")
Cc: sta...@dpdk.org

Signed-off-by: David Marchand 
---
 drivers/net/iavf/iavf_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index f7df4665d1..f1952e1bc8 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -2529,7 +2529,7 @@ iavf_fill_ctx_desc_segmentation_field(volatile uint64_t 
*field,
total_length -= m->outer_l3_len + m->outer_l2_len;
}
 
-#ifdef RTE_LIBRTE_IAVF_DEBUG_TX
+#ifdef RTE_ETHDEV_DEBUG_TX
if (!m->l4_len || !m->tso_segsz)
PMD_TX_LOG(DEBUG, "L4 length %d, LSO Segment size %d",
 m->l4_len, m->tso_segsz);
-- 
2.41.0



Re: quick thread in DLB2

2023-09-13 Thread Mattias Rönnblom

On 2023-09-11 16:28, Sevincer, Abdullah wrote:

Mattias,
Yes that’s correct.




There is no way to cleaner and more robust way to achieve the same 
result? For example, by accessing /proc, or better, an DPDK abstraction 
of the same.



-Original Message-
From: Mattias Rönnblom 
Sent: Friday, September 8, 2023 12:28 AM
To: Sevincer, Abdullah ; Stephen Hemminger 
; Thomas Monjalon 
Cc: dev@dpdk.org; Tyler Retzlaff 
Subject: Re: quick thread in DLB2

On 2023-09-08 00:09, Sevincer, Abdullah wrote:

Hi Stephen,
It is probing ports for best CPU. Yes it collects cycles. We may rework in the 
future.


Best, in what sense? Is this some kind of topology exploration? One DLB port 
being closer to (cheaper to access for) certain cores?


Open to suggestions.

-Original Message-
From: Stephen Hemminger 
Sent: Wednesday, September 6, 2023 12:45 PM
To: Thomas Monjalon 
Cc: Sevincer, Abdullah ; dev@dpdk.org;
Tyler Retzlaff 
Subject: Re: quick thread in DLB2

On Fri, 01 Sep 2023 16:08:48 +0200
Thomas Monjalon  wrote:


Hello Abdullah,

In the DLB2 code, I see a thread is created for a single operation:
In drivers/event/dlb2/pf/base/dlb2_resource.c
pthread_create(&pthread, NULL, &dlb2_pp_profile_func,
&dlb2_thread_data[i]); and just after:
pthread_join(pthread, NULL);

Can we avoid creating this thread?
I guess no, because it must spawn on a specific CPU.




The per thread data seems to break lots of expectations in EAL.
It all seems to be about capturing the number of cycles on different cores.
Looks like a mess.


RE: [PATCH] app/bbdev: fix link with NXP LA12XX

2023-09-13 Thread Chautru, Nicolas
Acked-by: Nicolas Chautru 

> -Original Message-
> From: David Marchand 
> Sent: Wednesday, September 13, 2023 6:59 AM
> To: dev@dpdk.org
> Cc: maxime.coque...@redhat.com; sta...@dpdk.org; Chautru, Nicolas
> ; Hemant Agrawal ;
> Akhil Goyal 
> Subject: [PATCH] app/bbdev: fix link with NXP LA12XX
> 
> The LA12XX driver was not linked to the dpdk-test-bbdev tool because of what
> looks like a rebase issue.
> 
> Fixes: 2b504721bfda ("app/bbdev: enable la12xx")
> Cc: sta...@dpdk.org
> 
> Signed-off-by: David Marchand 
> ---
>  app/test-bbdev/meson.build | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-bbdev/meson.build b/app/test-bbdev/meson.build index
> cd6a5089d5..926e0a5271 100644
> --- a/app/test-bbdev/meson.build
> +++ b/app/test-bbdev/meson.build
> @@ -23,6 +23,6 @@ endif
>  if dpdk_conf.has('RTE_BASEBAND_ACC')
>  deps += ['baseband_acc']
>  endif
> -if dpdk_conf.has('RTE_LIBRTE_PMD_BBDEV_LA12XX')
> +if dpdk_conf.has('RTE_BASEBAND_LA12XX')
>  deps += ['baseband_la12xx']
>  endif
> --
> 2.41.0



RE: quick thread in DLB2

2023-09-13 Thread Honnappa Nagarahalli


> -Original Message-
> From: Mattias Rönnblom 
> Sent: Wednesday, September 13, 2023 10:48 AM
> To: Sevincer, Abdullah ; Stephen Hemminger
> ; tho...@monjalon.net
> Cc: dev@dpdk.org; Tyler Retzlaff 
> Subject: Re: quick thread in DLB2
> 
> On 2023-09-11 16:28, Sevincer, Abdullah wrote:
> > Mattias,
> > Yes that’s correct.
> >
> >
> 
> There is no way to cleaner and more robust way to achieve the same result?
> For example, by accessing /proc, or better, an DPDK abstraction of the same.
There similar issues in other areas. For ex: the CPUs with large core count 
have larger interconnect. The SLC to CPU distance starts to matter and the 
memory latency increases. The distance of the cores on the interconnect also 
impacts lock behaviors. We probably need a common mechanism/library to export 
such details. Not sure how much of this would be a security risk.

> 
> > -Original Message-
> > From: Mattias Rönnblom 
> > Sent: Friday, September 8, 2023 12:28 AM
> > To: Sevincer, Abdullah ; Stephen
> > Hemminger ; Thomas Monjalon
> > 
> > Cc: dev@dpdk.org; Tyler Retzlaff 
> > Subject: Re: quick thread in DLB2
> >
> > On 2023-09-08 00:09, Sevincer, Abdullah wrote:
> >> Hi Stephen,
> >> It is probing ports for best CPU. Yes it collects cycles. We may rework in 
> >> the
> future.
> >
> > Best, in what sense? Is this some kind of topology exploration? One DLB
> port being closer to (cheaper to access for) certain cores?
> >
> >> Open to suggestions.
> >>
> >> -Original Message-
> >> From: Stephen Hemminger 
> >> Sent: Wednesday, September 6, 2023 12:45 PM
> >> To: Thomas Monjalon 
> >> Cc: Sevincer, Abdullah ; dev@dpdk.org;
> >> Tyler Retzlaff 
> >> Subject: Re: quick thread in DLB2
> >>
> >> On Fri, 01 Sep 2023 16:08:48 +0200
> >> Thomas Monjalon  wrote:
> >>
> >>> Hello Abdullah,
> >>>
> >>> In the DLB2 code, I see a thread is created for a single operation:
> >>> In drivers/event/dlb2/pf/base/dlb2_resource.c
> >>> pthread_create(&pthread, NULL, &dlb2_pp_profile_func,
> >>> &dlb2_thread_data[i]); and just after:
> >>> pthread_join(pthread, NULL);
> >>>
> >>> Can we avoid creating this thread?
> >>> I guess no, because it must spawn on a specific CPU.
> >>>
> >>>
> >>
> >> The per thread data seems to break lots of expectations in EAL.
> >> It all seems to be about capturing the number of cycles on different cores.
> >> Looks like a mess.


RE: [PATCH 1/1] net/mana: add 32 bit short doorbell

2023-09-13 Thread Long Li
> Subject: [PATCH 1/1] net/mana: add 32 bit short doorbell
> 
> Add 32 bit short doorbell support. Ring short doorbell when running in 32 bit
> applicactions.
> 
> Cc: sta...@dpdk.org
> 
> Signed-off-by: Wei Hu 

Please send this patch to

Ferruh Yigit 
Andrew Rybchenko 


> ---
>  drivers/net/mana/gdma.c | 95
> +
>  drivers/net/mana/mana.h | 25 +++
>  drivers/net/mana/rx.c   | 52 ++
>  drivers/net/mana/tx.c   | 28 
>  4 files changed, 200 insertions(+)
> 
> diff --git a/drivers/net/mana/gdma.c b/drivers/net/mana/gdma.c index
> 65685fe236..d1da025d1b 100644
> --- a/drivers/net/mana/gdma.c
> +++ b/drivers/net/mana/gdma.c
> @@ -166,6 +166,97 @@ gdma_post_work_request(struct
> mana_gdma_queue *queue,
>   return 0;
>  }
> 
> +#ifdef RTE_ARCH_32
> +union gdma_short_doorbell_entry {
> + uint32_t as_uint32;
> +
> + struct {
> + uint32_t tail_ptr_incr  : 16; /* Number of CQEs */
> + uint32_t id : 12;
> + uint32_t reserved   : 3;
> + uint32_t arm: 1;
> + } cq;
> +
> + struct {
> + uint32_t tail_ptr_incr  : 16; /* In number of bytes */
> + uint32_t id : 12;
> + uint32_t reserved   : 4;
> + } rq;
> +
> + struct {
> + uint32_t tail_ptr_incr  : 16; /* In number of bytes */
> + uint32_t id : 12;
> + uint32_t reserved   : 4;
> + } sq;
> +
> + struct {
> + uint32_t tail_ptr_incr  : 16; /* Number of EQEs */
> + uint32_t id : 12;
> + uint32_t reserved   : 3;
> + uint32_t arm: 1;
> + } eq;
> +}; /* HW DATA */
> +
> +enum {
> + DOORBELL_SHORT_OFFSET_SQ = 0x10,
> + DOORBELL_SHORT_OFFSET_RQ = 0x410,
> + DOORBELL_SHORT_OFFSET_CQ = 0x810,
> + DOORBELL_SHORT_OFFSET_EQ = 0xFF0,
> +};
> +
> +/*
> + * Write to hardware doorbell to notify new activity.
> + */
> +int
> +mana_ring_short_doorbell(void *db_page, enum gdma_queue_types
> queue_type,
> +  uint32_t queue_id, uint32_t tail_incr, uint8_t arm) {
> + uint8_t *addr = db_page;
> + union gdma_short_doorbell_entry e = {};
> +
> + if ((queue_id & ~GDMA_SHORT_DB_QID_MASK) ||
> + (tail_incr & ~GDMA_SHORT_DB_INC_MASK)) {
> + DP_LOG(ERR, "%s: queue_id %u or "
> +"tail_incr %u overflowed, queue type %d",
> +__func__, queue_id, tail_incr, queue_type);

This should never happen.

What does "overflowed" mean? Is it a hardware error or software error? If this 
is a software error, the calling code needs to make sure it never overflows 
when using short doorbells.

Thanks,

Long


RE: [PATCH v3] common/idpf: refactor single queue Tx function

2023-09-13 Thread Zhang, Qi Z



> -Original Message-
> From: Zhang, Qi Z 
> Sent: Wednesday, September 13, 2023 3:46 PM
> To: Wu, Wenjun1 ; Su, Simei ;
> Wu, Jingjing ; Xing, Beilei 
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v3] common/idpf: refactor single queue Tx function
> 
> 
> 
> > -Original Message-
> > From: Wu, Wenjun1 
> > Sent: Wednesday, September 13, 2023 1:57 PM
> > To: Su, Simei ; Wu, Jingjing
> > ; Xing, Beilei ; Zhang,
> > Qi Z 
> > Cc: dev@dpdk.org
> > Subject: RE: [PATCH v3] common/idpf: refactor single queue Tx function
> >
> >
> >
> > > -Original Message-
> > > From: Su, Simei 
> > > Sent: Friday, September 8, 2023 6:28 PM
> > > To: Wu, Jingjing ; Xing, Beilei
> > > ; Zhang, Qi Z 
> > > Cc: dev@dpdk.org; Wu, Wenjun1 ; Su, Simei
> > > 
> > > Subject: [PATCH v3] common/idpf: refactor single queue Tx function
> > >
> > > This patch replaces flex Tx descriptor with base Tx descriptor to
> > > align with kernel driver practice.
> > >
> > > Signed-off-by: Simei Su 
> > > ---
> > > v3:
> > > * Change context TSO descriptor from base mode to flex mode.
> > >
> > > v2:
> > > * Refine commit title and commit log.
> > > * Remove redundant definition.
> > > * Modify base mode context TSO descriptor.
> > >
> > >  drivers/common/idpf/idpf_common_rxtx.c| 39 +--
> > >  drivers/common/idpf/idpf_common_rxtx.h|  2 +-
> > >  drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +
> -
> > >  drivers/net/idpf/idpf_rxtx.c  |  2 +-
> > >  4 files changed, 39 insertions(+), 41 deletions(-)
> > >
> > > diff --git a/drivers/common/idpf/idpf_common_rxtx.c
> > > b/drivers/common/idpf/idpf_common_rxtx.c
> > > index fc87e3e243..e6d2486272 100644
> > > --- a/drivers/common/idpf/idpf_common_rxtx.c
> > > +++ b/drivers/common/idpf/idpf_common_rxtx.c
> > > @@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct
> > > idpf_tx_queue *txq)
> > >   }
> > >
> > >   txe = txq->sw_ring;
> > > - size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
> > > + size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
> > >   for (i = 0; i < size; i++)
> > >   ((volatile char *)txq->tx_ring)[i] = 0;
> > >
> > >   prev = (uint16_t)(txq->nb_tx_desc - 1);
> > >   for (i = 0; i < txq->nb_tx_desc; i++) {
> > > - txq->tx_ring[i].qw1.cmd_dtype =
> > > -
> > >   rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
> > > + txq->tx_ring[i].qw1 =
> > > +
> > >   rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
> > >   txe[i].mbuf =  NULL;
> > >   txe[i].last_id = i;
> > >   txe[prev].next_id = i;
> > > @@ -1307,17 +1307,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue
> *txq)
> > >   uint16_t nb_tx_to_clean;
> > >   uint16_t i;
> > >
> > > - volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
> > > + volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
> > >
> > >   desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->rs_thresh);
> > >   if (desc_to_clean_to >= nb_tx_desc)
> > >   desc_to_clean_to = (uint16_t)(desc_to_clean_to -
> > nb_tx_desc);
> > >
> > >   desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
> > > - /* In the writeback Tx desccriptor, the only significant fields are the 
> > > 4-
> > > bit DTYPE */
> > > - if ((txd[desc_to_clean_to].qw1.cmd_dtype &
> > > -  rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
> > > - rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
> > > + if ((txd[desc_to_clean_to].qw1 &
> > > +  rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
> > > + rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
> > >   TX_LOG(DEBUG, "TX descriptor %4u is not done "
> > >  "(port=%d queue=%d)", desc_to_clean_to,
> > >  txq->port_id, txq->queue_id); @@ -1331,10 +1330,7 @@
> > > idpf_xmit_cleanup(struct idpf_tx_queue *txq)
> > >   nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
> > >   last_desc_cleaned);
> > >
> > > - txd[desc_to_clean_to].qw1.cmd_dtype = 0;
> > > - txd[desc_to_clean_to].qw1.buf_size = 0;
> > > - for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
> > > - txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
> > > + txd[desc_to_clean_to].qw1 = 0;
> > >
> > >   txq->last_desc_cleaned = desc_to_clean_to;
> > >   txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean); @@ -
> > > 1347,8 +1343,8 @@ uint16_t  idpf_dp_singleq_xmit_pkts(void
> > > *tx_queue, struct rte_mbuf **tx_pkts,
> > > uint16_t nb_pkts)
> > >  {
> > > - volatile struct idpf_flex_tx_desc *txd;
> > > - volatile struct idpf_flex_tx_desc *txr;
> > > + volatile struct idpf_base_tx_desc *txd;
> > > + volatile struct idpf_base_tx_desc *txr;
> > >   union idpf_tx_offload tx_offload = {0};
> > >   struct idpf_tx_entry *txe, *txn;
> > >   struct idpf_tx_entry *sw_ring;
> > > @@ -1356,6 +1352,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue,
> > struct
> > > rte_mbuf **tx_pkts,
> > >   struct rte_mbuf *tx_pkt;
> > >   str

[PATCH v4 0/3] refactor single queue Tx data path

2023-09-13 Thread Simei Su
1. Refine single queue Tx data path for idpf common module.
2. Refine Tx queue setup for idpf pmd.
3. Refine Tx queue setup for cpfl pmd.

v4:
* Split one patch into patchset.
* Refine commit title and commit log.

v3:
* Change context TSO descriptor from base mode to flex mode.

v2:
* Refine commit title and commit log.
* Remove redundant definition.
* Modify base mode context TSO descriptor.

Simei Su (3):
  common/idpf: refactor single queue Tx data path
  net/idpf: refine Tx queue setup
  net/cpfl: refine Tx queue setup

 drivers/common/idpf/idpf_common_rxtx.c| 39 +--
 drivers/common/idpf/idpf_common_rxtx.h|  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +-
 drivers/net/cpfl/cpfl_rxtx.c  |  2 +-
 drivers/net/idpf/idpf_rxtx.c  |  2 +-
 5 files changed, 40 insertions(+), 42 deletions(-)

-- 
2.25.1



[PATCH v4 2/3] net/idpf: refine Tx queue setup

2023-09-13 Thread Simei Su
This patch refines Tx single queue setup to align with Tx data path.

Signed-off-by: Simei Su 
Acked-by: Wenjun Wu 
---
 drivers/net/idpf/idpf_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/idpf/idpf_rxtx.c b/drivers/net/idpf/idpf_rxtx.c
index 3e3d81ca6d..64f2235580 100644
--- a/drivers/net/idpf/idpf_rxtx.c
+++ b/drivers/net/idpf/idpf_rxtx.c
@@ -74,7 +74,7 @@ idpf_dma_zone_reserve(struct rte_eth_dev *dev, uint16_t 
queue_idx,
ring_size = RTE_ALIGN(len * sizeof(struct 
idpf_flex_tx_sched_desc),
  IDPF_DMA_MEM_ALIGN);
else
-   ring_size = RTE_ALIGN(len * sizeof(struct 
idpf_flex_tx_desc),
+   ring_size = RTE_ALIGN(len * sizeof(struct 
idpf_base_tx_desc),
  IDPF_DMA_MEM_ALIGN);
rte_memcpy(ring_name, "idpf Tx ring", sizeof("idpf Tx ring"));
break;
-- 
2.25.1



[PATCH v4 1/3] common/idpf: refactor single queue Tx data path

2023-09-13 Thread Simei Su
Currently, single queue Tx data path uses flex Tx data descriptor
which is changed in the latest idpf spec. This patch replaces flex
Tx data descriptor with base Tx data descriptor for single queue Tx
data path.

Signed-off-by: Simei Su 
Acked-by: Wenjun Wu 
---
 drivers/common/idpf/idpf_common_rxtx.c| 39 +--
 drivers/common/idpf/idpf_common_rxtx.h|  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +-
 3 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_rxtx.c 
b/drivers/common/idpf/idpf_common_rxtx.c
index fc87e3e243..e6d2486272 100644
--- a/drivers/common/idpf/idpf_common_rxtx.c
+++ b/drivers/common/idpf/idpf_common_rxtx.c
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct idpf_tx_queue *txq)
}
 
txe = txq->sw_ring;
-   size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+   size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
for (i = 0; i < size; i++)
((volatile char *)txq->tx_ring)[i] = 0;
 
prev = (uint16_t)(txq->nb_tx_desc - 1);
for (i = 0; i < txq->nb_tx_desc; i++) {
-   txq->tx_ring[i].qw1.cmd_dtype =
-   rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+   txq->tx_ring[i].qw1 =
+   rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
txe[i].mbuf =  NULL;
txe[i].last_id = i;
txe[prev].next_id = i;
@@ -1307,17 +1307,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
uint16_t nb_tx_to_clean;
uint16_t i;
 
-   volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
+   volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->rs_thresh);
if (desc_to_clean_to >= nb_tx_desc)
desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
 
desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
-   /* In the writeback Tx desccriptor, the only significant fields are the 
4-bit DTYPE */
-   if ((txd[desc_to_clean_to].qw1.cmd_dtype &
-rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
-   rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
+   if ((txd[desc_to_clean_to].qw1 &
+rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
+   rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
TX_LOG(DEBUG, "TX descriptor %4u is not done "
   "(port=%d queue=%d)", desc_to_clean_to,
   txq->port_id, txq->queue_id);
@@ -1331,10 +1330,7 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
last_desc_cleaned);
 
-   txd[desc_to_clean_to].qw1.cmd_dtype = 0;
-   txd[desc_to_clean_to].qw1.buf_size = 0;
-   for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
-   txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
+   txd[desc_to_clean_to].qw1 = 0;
 
txq->last_desc_cleaned = desc_to_clean_to;
txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean);
@@ -1347,8 +1343,8 @@ uint16_t
 idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
  uint16_t nb_pkts)
 {
-   volatile struct idpf_flex_tx_desc *txd;
-   volatile struct idpf_flex_tx_desc *txr;
+   volatile struct idpf_base_tx_desc *txd;
+   volatile struct idpf_base_tx_desc *txr;
union idpf_tx_offload tx_offload = {0};
struct idpf_tx_entry *txe, *txn;
struct idpf_tx_entry *sw_ring;
@@ -1356,6 +1352,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts,
struct rte_mbuf *tx_pkt;
struct rte_mbuf *m_seg;
uint64_t buf_dma_addr;
+   uint32_t td_offset;
uint64_t ol_flags;
uint16_t tx_last;
uint16_t nb_used;
@@ -1382,6 +1379,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts,
 
for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
td_cmd = 0;
+   td_offset = 0;
 
tx_pkt = *tx_pkts++;
RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
@@ -1462,9 +1460,10 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct 
rte_mbuf **tx_pkts,
slen = m_seg->data_len;
buf_dma_addr = rte_mbuf_data_iova(m_seg);
txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-   txd->qw1.buf_size = slen;
-   txd->qw1.cmd_dtype = 
rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_FLEX_DATA <<
- 
IDPF_FLEX_TXD_QW1_DTYPE_S);
+   txd->qw1 = rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DATA |
+   ((uint64_t)td_cmd  << IDPF_TXD_QW1_CMD_S) |
+   ((uint64_t)td_offs

[PATCH v4 3/3] net/cpfl: refine Tx queue setup

2023-09-13 Thread Simei Su
This patch refines Tx single queue setup to align with Tx data path.

Signed-off-by: Simei Su 
Acked-by: Wenjun Wu 
---
 drivers/net/cpfl/cpfl_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/cpfl/cpfl_rxtx.c b/drivers/net/cpfl/cpfl_rxtx.c
index 2ef6871a85..ab8bec4645 100644
--- a/drivers/net/cpfl/cpfl_rxtx.c
+++ b/drivers/net/cpfl/cpfl_rxtx.c
@@ -135,7 +135,7 @@ cpfl_dma_zone_reserve(struct rte_eth_dev *dev, uint16_t 
queue_idx,
ring_size = RTE_ALIGN(len * sizeof(struct 
idpf_flex_tx_sched_desc),
  CPFL_DMA_MEM_ALIGN);
else
-   ring_size = RTE_ALIGN(len * sizeof(struct 
idpf_flex_tx_desc),
+   ring_size = RTE_ALIGN(len * sizeof(struct 
idpf_base_tx_desc),
  CPFL_DMA_MEM_ALIGN);
memcpy(ring_name, "cpfl Tx ring", sizeof("cpfl Tx ring"));
break;
-- 
2.25.1



RE: [PATCH v4 0/3] refactor single queue Tx data path

2023-09-13 Thread Xing, Beilei



> -Original Message-
> From: Su, Simei 
> Sent: Thursday, September 14, 2023 9:50 AM
> To: Wu, Jingjing ; Xing, Beilei
> ; Zhang, Qi Z 
> Cc: dev@dpdk.org; Wu, Wenjun1 ; Su, Simei
> 
> Subject: [PATCH v4 0/3] refactor single queue Tx data path
> 
> 1. Refine single queue Tx data path for idpf common module.
> 2. Refine Tx queue setup for idpf pmd.
> 3. Refine Tx queue setup for cpfl pmd.
> 
> v4:
> * Split one patch into patchset.
> * Refine commit title and commit log.
> 
> v3:
> * Change context TSO descriptor from base mode to flex mode.
> 
> v2:
> * Refine commit title and commit log.
> * Remove redundant definition.
> * Modify base mode context TSO descriptor.
> 
> Simei Su (3):
>   common/idpf: refactor single queue Tx data path
>   net/idpf: refine Tx queue setup
>   net/cpfl: refine Tx queue setup
> 
>  drivers/common/idpf/idpf_common_rxtx.c| 39 +--
>  drivers/common/idpf/idpf_common_rxtx.h|  2 +-
>  drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +-
>  drivers/net/cpfl/cpfl_rxtx.c  |  2 +-
>  drivers/net/idpf/idpf_rxtx.c  |  2 +-
>  5 files changed, 40 insertions(+), 42 deletions(-)
> 
> --
> 2.25.1

Acked-by: Beilei Xing 



RE: [PATCH] net/ice: fix initail link status issue

2023-09-13 Thread Zhang, Qi Z



> -Original Message-
> From: Yang, Qiming 
> Sent: Wednesday, September 13, 2023 5:02 PM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z ; Yang, Qiming
> ; sta...@dpdk.org
> Subject: [PATCH] net/ice: fix initail link status issue

s/initail/initial
> 
> This patch fixed the issue which the link status still up when the link status
> changed from up to downi after device restart.
> 
> Fixes: fdcf92ed6637 ("net/ice: fix link status recovery")
> Cc: sta...@dpdk.org
> 
> Signed-off-by: Qiming Yang 

Acked-by: Qi Zhang 

Applied to dpdk-next-net-intel.

Thanks
Qi



RE: [PATCH] net/iavf: fix Tx debug

2023-09-13 Thread Zhang, Qi Z



> -Original Message-
> From: David Marchand 
> Sent: Wednesday, September 13, 2023 10:03 PM
> To: dev@dpdk.org
> Cc: sta...@dpdk.org; Wu, Jingjing ; Xing, Beilei
> ; Doherty, Declan ;
> Sinha, Abhijit ; Nicolau, Radu
> 
> Subject: [PATCH] net/iavf: fix Tx debug
> 
> Commit 1e728b01120c ("net/iavf: rework Tx path") reintroduced a check on
> RTE_LIBRTE_IAVF_DEBUG_TX that has been dropped in favor of
> RTE_ETHDEV_DEBUG_TX.
> 
> Fixes: 1e728b01120c ("net/iavf: rework Tx path")
> Cc: sta...@dpdk.org
> 
> Signed-off-by: David Marchand 

Acked-by: Qi Zhang 

Applied to dpdk-next-net-intel.

Thanks
Qi



RE: [PATCH 1/1] net/mana: add 32 bit short doorbell

2023-09-13 Thread Wei Hu
> -Original Message-
> From: Long Li 
> Sent: Thursday, September 14, 2023 5:11 AM
> To: Wei Hu ; dev@dpdk.org; Ferruh Yigit
> ; Andrew Rybchenko
> 
> Cc: sta...@dpdk.org
> Subject: RE: [PATCH 1/1] net/mana: add 32 bit short doorbell
> 
> > +
> > +/*
> > + * Write to hardware doorbell to notify new activity.
> > + */
> > +int
> > +mana_ring_short_doorbell(void *db_page, enum gdma_queue_types
> > queue_type,
> > +uint32_t queue_id, uint32_t tail_incr, uint8_t arm) {
> > +   uint8_t *addr = db_page;
> > +   union gdma_short_doorbell_entry e = {};
> > +
> > +   if ((queue_id & ~GDMA_SHORT_DB_QID_MASK) ||
> > +   (tail_incr & ~GDMA_SHORT_DB_INC_MASK)) {
> > +   DP_LOG(ERR, "%s: queue_id %u or "
> > +  "tail_incr %u overflowed, queue type %d",
> > +  __func__, queue_id, tail_incr, queue_type);
> 
> This should never happen.
> 
> What does "overflowed" mean? Is it a hardware error or software error? If this
> is a software error, the calling code needs to make sure it never overflows
> when using short doorbells.
> 
This is to guard any hardware and software bugs or weirdness, which could lead
to silent failures if it doesn't log. 

The software code has already been made to avoid any intentional behaviors which
could cause tail_incr overflow. 

Thanks,
Wei



[PATCH v5] common/idpf: refactor single queue Tx data path

2023-09-13 Thread Simei Su
Currently, single queue Tx data path uses flex Tx data
descriptor(DTYPE3) which is removed in the latest idpf spec.
This patch replaces flex Tx data descriptor with base Tx data
descriptor for single queue Tx data path and refines Tx single
queue setup to align with Tx data path.

Signed-off-by: Simei Su 
Acked-by: Wenjun Wu 
Acked-by: Beilei Xing 
---
 drivers/common/idpf/idpf_common_rxtx.c| 39 +--
 drivers/common/idpf/idpf_common_rxtx.h|  2 +-
 drivers/common/idpf/idpf_common_rxtx_avx512.c | 37 +-
 drivers/net/cpfl/cpfl_rxtx.c  |  2 +-
 drivers/net/idpf/idpf_rxtx.c  |  2 +-
 5 files changed, 40 insertions(+), 42 deletions(-)

diff --git a/drivers/common/idpf/idpf_common_rxtx.c 
b/drivers/common/idpf/idpf_common_rxtx.c
index fc87e3e243..e6d2486272 100644
--- a/drivers/common/idpf/idpf_common_rxtx.c
+++ b/drivers/common/idpf/idpf_common_rxtx.c
@@ -276,14 +276,14 @@ idpf_qc_single_tx_queue_reset(struct idpf_tx_queue *txq)
}
 
txe = txq->sw_ring;
-   size = sizeof(struct idpf_flex_tx_desc) * txq->nb_tx_desc;
+   size = sizeof(struct idpf_base_tx_desc) * txq->nb_tx_desc;
for (i = 0; i < size; i++)
((volatile char *)txq->tx_ring)[i] = 0;
 
prev = (uint16_t)(txq->nb_tx_desc - 1);
for (i = 0; i < txq->nb_tx_desc; i++) {
-   txq->tx_ring[i].qw1.cmd_dtype =
-   rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE);
+   txq->tx_ring[i].qw1 =
+   rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE);
txe[i].mbuf =  NULL;
txe[i].last_id = i;
txe[prev].next_id = i;
@@ -1307,17 +1307,16 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
uint16_t nb_tx_to_clean;
uint16_t i;
 
-   volatile struct idpf_flex_tx_desc *txd = txq->tx_ring;
+   volatile struct idpf_base_tx_desc *txd = txq->tx_ring;
 
desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->rs_thresh);
if (desc_to_clean_to >= nb_tx_desc)
desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
 
desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
-   /* In the writeback Tx desccriptor, the only significant fields are the 
4-bit DTYPE */
-   if ((txd[desc_to_clean_to].qw1.cmd_dtype &
-rte_cpu_to_le_16(IDPF_TXD_QW1_DTYPE_M)) !=
-   rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
+   if ((txd[desc_to_clean_to].qw1 &
+rte_cpu_to_le_64(IDPF_TXD_QW1_DTYPE_M)) !=
+   rte_cpu_to_le_64(IDPF_TX_DESC_DTYPE_DESC_DONE)) {
TX_LOG(DEBUG, "TX descriptor %4u is not done "
   "(port=%d queue=%d)", desc_to_clean_to,
   txq->port_id, txq->queue_id);
@@ -1331,10 +1330,7 @@ idpf_xmit_cleanup(struct idpf_tx_queue *txq)
nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
last_desc_cleaned);
 
-   txd[desc_to_clean_to].qw1.cmd_dtype = 0;
-   txd[desc_to_clean_to].qw1.buf_size = 0;
-   for (i = 0; i < RTE_DIM(txd[desc_to_clean_to].qw1.flex.raw); i++)
-   txd[desc_to_clean_to].qw1.flex.raw[i] = 0;
+   txd[desc_to_clean_to].qw1 = 0;
 
txq->last_desc_cleaned = desc_to_clean_to;
txq->nb_free = (uint16_t)(txq->nb_free + nb_tx_to_clean);
@@ -1347,8 +1343,8 @@ uint16_t
 idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
  uint16_t nb_pkts)
 {
-   volatile struct idpf_flex_tx_desc *txd;
-   volatile struct idpf_flex_tx_desc *txr;
+   volatile struct idpf_base_tx_desc *txd;
+   volatile struct idpf_base_tx_desc *txr;
union idpf_tx_offload tx_offload = {0};
struct idpf_tx_entry *txe, *txn;
struct idpf_tx_entry *sw_ring;
@@ -1356,6 +1352,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts,
struct rte_mbuf *tx_pkt;
struct rte_mbuf *m_seg;
uint64_t buf_dma_addr;
+   uint32_t td_offset;
uint64_t ol_flags;
uint16_t tx_last;
uint16_t nb_used;
@@ -1382,6 +1379,7 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts,
 
for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
td_cmd = 0;
+   td_offset = 0;
 
tx_pkt = *tx_pkts++;
RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
@@ -1462,9 +1460,10 @@ idpf_dp_singleq_xmit_pkts(void *tx_queue, struct 
rte_mbuf **tx_pkts,
slen = m_seg->data_len;
buf_dma_addr = rte_mbuf_data_iova(m_seg);
txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
-   txd->qw1.buf_size = slen;
-   txd->qw1.cmd_dtype = 
rte_cpu_to_le_16(IDPF_TX_DESC_DTYPE_FLEX_DATA <<
- 
IDPF_FLEX_TXD_QW1_DTYPE_S);
+