DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Shaiq Wani <shaiq.wani@intel.com>
Cc: <dev@dpdk.org>, <aman.deep.singh@intel.com>
Subject: Re: [PATCH v2 1/3] common/idpf: enable AVX2 for single queue Rx
Date: Wed, 29 Jan 2025 16:48:34 +0000	[thread overview]
Message-ID: <Z5pb4umxKg9adtQH@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20250129121856.1040065-2-shaiq.wani@intel.com>

On Wed, Jan 29, 2025 at 05:48:54PM +0530, Shaiq Wani wrote:
> In case some CPUs don't support AVX512. Enable AVX2 for them to
> get better per-core performance.
> 
> The single queue model processes all packets in order while
> the split queue model separates packet data and metadata into
> different queues for parallel processing and improved performance.
> 
> Signed-off-by: Shaiq Wani <shaiq.wani@intel.com>
> ---
>  drivers/common/idpf/idpf_common_device.h    |   1 +
>  drivers/common/idpf/idpf_common_rxtx.h      |   4 +
>  drivers/common/idpf/idpf_common_rxtx_avx2.c | 485 ++++++++++++++++++++
>  drivers/common/idpf/meson.build             |   9 +
>  drivers/common/idpf/version.map             |   1 +
>  drivers/net/idpf/idpf_rxtx.c                |  11 +

This patch needs a rebase onto next-net-intel to update this final path.
See also comments inline below.

Regards,
/Bruce

>  6 files changed, 511 insertions(+)
>  create mode 100644 drivers/common/idpf/idpf_common_rxtx_avx2.c
> 
> diff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h
> index bfa927a5ff..734be1c88a 100644
> --- a/drivers/common/idpf/idpf_common_device.h
> +++ b/drivers/common/idpf/idpf_common_device.h
> @@ -123,6 +123,7 @@ struct idpf_vport {
>  
>  	bool rx_vec_allowed;
>  	bool tx_vec_allowed;
> +	bool rx_use_avx2;
>  	bool rx_use_avx512;
>  	bool tx_use_avx512;
>  
> diff --git a/drivers/common/idpf/idpf_common_rxtx.h b/drivers/common/idpf/idpf_common_rxtx.h
> index eeeeed12e2..f50cf5ef46 100644
> --- a/drivers/common/idpf/idpf_common_rxtx.h
> +++ b/drivers/common/idpf/idpf_common_rxtx.h
> @@ -302,5 +302,9 @@ uint16_t idpf_dp_splitq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pk
>  __rte_internal
>  uint16_t idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
>  			  uint16_t nb_pkts);
> +__rte_internal
> +uint16_t idpf_dp_singleq_recv_pkts_avx2(void *rx_queue,
> +					struct rte_mbuf **rx_pkts,
> +					uint16_t nb_pkts);
>  
>  #endif /* _IDPF_COMMON_RXTX_H_ */
> diff --git a/drivers/common/idpf/idpf_common_rxtx_avx2.c b/drivers/common/idpf/idpf_common_rxtx_avx2.c
> new file mode 100644
> index 0000000000..de76f01ff8
> --- /dev/null
> +++ b/drivers/common/idpf/idpf_common_rxtx_avx2.c
> @@ -0,0 +1,485 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2023 Intel Corporation
> + */
> +
> +#include <rte_vect.h>
> +
> +#include "idpf_common_rxtx.h"
> +#include "idpf_common_device.h"
> +

<snip>

> +idpf_dp_singleq_recv_pkts_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
> +{
> +	return _idpf_singleq_recv_raw_pkts_vec_avx2(rx_queue, rx_pkts, nb_pkts);
> +}

I assume the presence of this wrapper function is to allow future support
for scattered packets, as with other drivers?

> diff --git a/drivers/common/idpf/meson.build b/drivers/common/idpf/meson.build
> index 46fd45c03b..fe54fdcd87 100644
> --- a/drivers/common/idpf/meson.build
> +++ b/drivers/common/idpf/meson.build
> @@ -16,6 +16,15 @@ sources = files(
>  )
>  
>  if arch_subdir == 'x86'
> +    sources += files('idpf_common_rxtx.c')

This is already added to sources in the block above. It's also not x86
specific, I believe.

> +    cflags += ['-DCC_AVX2_SUPPORT']

Strictly speaking, we don't need this, as we always have AVX2 support in
x86 builds. The code can just check for RTE_ARCH_x86 macro.

> +    idpf_avx2_lib = static_library('idpf_avx2_lib',
> +        'idpf_common_rxtx_avx2.c',
> +        dependencies: [static_rte_ethdev, static_rte_kvargs, static_rte_hash],

rte_kvargs is already a dependency of hash and ethdev libraries, so you can
drop it from the list to shorten it.

> +        include_directories: includes,
> +        c_args: [cflags, '-mavx2'])
> +    objs += idpf_avx2_lib.extract_objects('idpf_common_rxtx_avx2.c')
> +
>      if cc_has_avx512
>          cflags += ['-DCC_AVX512_SUPPORT']
>          avx512_args = cflags + cc_avx512_flags
> diff --git a/drivers/common/idpf/version.map b/drivers/common/idpf/version.map
> index 0729f6b912..22b689f5f5 100644
> --- a/drivers/common/idpf/version.map
> +++ b/drivers/common/idpf/version.map
> @@ -6,6 +6,7 @@ INTERNAL {
>  
>  	idpf_dp_prep_pkts;
>  	idpf_dp_singleq_recv_pkts;
> +	idpf_dp_singleq_recv_pkts_avx2;
>  	idpf_dp_singleq_recv_pkts_avx512;
>  	idpf_dp_singleq_recv_scatter_pkts;
>  	idpf_dp_singleq_xmit_pkts;
> diff --git a/drivers/net/idpf/idpf_rxtx.c b/drivers/net/idpf/idpf_rxtx.c
> index 858bbefe3b..a8377d3fee 100644
> --- a/drivers/net/idpf/idpf_rxtx.c
> +++ b/drivers/net/idpf/idpf_rxtx.c
> @@ -776,6 +776,10 @@ idpf_set_rx_function(struct rte_eth_dev *dev)
>  	    rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
>  		vport->rx_vec_allowed = true;
>  
> +		if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 &&
> +		    rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256)
> +			vport->rx_use_avx2 = true;
> +
>  		if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)
>  #ifdef CC_AVX512_SUPPORT
>  			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
> @@ -827,6 +831,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev)
>  				return;
>  			}
>  #endif /* CC_AVX512_SUPPORT */
> +			if (vport->rx_use_avx2) {
> +				PMD_DRV_LOG(NOTICE,
> +					    "Using Single AVX2 Vector Rx (port %d).",
> +					    dev->data->port_id);
> +				dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts_avx2;
> +				return;
> +			}
>  		}
>  
>  		if (dev->data->scattered_rx) {
> -- 
> 2.34.1
> 

  reply	other threads:[~2025-01-29 16:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08 12:17 [PATCH 0/2] enable AVX2 for IDPF single queue Shaiq Wani
2025-01-08 12:17 ` [PATCH 1/2] common/idpf: enable AVX2 for single queue Rx Shaiq Wani
2025-01-20 14:15   ` Bruce Richardson
2025-01-27  8:19     ` Wani, Shaiq
2025-01-29 12:18   ` [PATCH v2 0/3] enable AVX2 for single queue Rx/Tx Shaiq Wani
2025-01-29 12:18     ` [PATCH v2 1/3] common/idpf: enable AVX2 for single queue Rx Shaiq Wani
2025-01-29 16:48       ` Bruce Richardson [this message]
2025-01-30  8:24       ` [PATCH v3 0/2] enable AVX2 for single queue Rx/Tx Shaiq Wani
2025-01-30  8:24         ` [PATCH v3 1/2] common/idpf: enable AVX2 for single queue Rx Shaiq Wani
2025-01-30  8:21           ` David Marchand
2025-01-30  8:24         ` [PATCH v3 2/2] common/idpf: enable AVX2 for single queue Tx Shaiq Wani
2025-01-29 12:18     ` [PATCH v2 2/3] " Shaiq Wani
2025-01-29 16:53       ` Bruce Richardson
2025-01-29 12:18     ` [PATCH v2 3/3] doc: documentaion update for idpf pmd Shaiq Wani
2025-01-29 16:55       ` Bruce Richardson
2025-01-08 12:17 ` [PATCH 2/2] common/idpf: enable AVX2 for single queue Tx Shaiq Wani
2025-01-20 14:23   ` Bruce Richardson
2025-01-27  9:46     ` Wani, Shaiq

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z5pb4umxKg9adtQH@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=shaiq.wani@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).