DPDK patches and discussions
 help / color / mirror / Atom feed
From: fengchengwen <fengchengwen@huawei.com>
To: <thomas@monjalon.net>, <ferruh.yigit@xilinx.com>,
	<kevin.laatz@intel.com>,  <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>
Subject: Re: [PATCH v3 1/3] examples/dma: fix MTU configuration
Date: Wed, 11 May 2022 10:26:00 +0800	[thread overview]
Message-ID: <9ed2ca68-6cdb-c7f0-e16c-c133bf8998e6@huawei.com> (raw)
In-Reply-To: <20220424060741.33214-2-fengchengwen@huawei.com>

Hi Ferruh

  Could you please review this patch ?

  I notice many examples (e.g. l3fwd/l3fwd-acl/l3fwd-power/l3fwd-thread/l3fwd-graph)
use the same approach (which define eth_dev_get_overhead_len/config_port_max_pkt_len).

  Thanks.

On 2022/4/24 14:07, Chengwen Feng wrote:
> From: Huisong Li <lihuisong@huawei.com>
> 
> The MTU in dma App can be configured by 'max_frame_size' parameters which
> have a default value(1518). It's not reasonable to use it directly as MTU.
> This patch fix it.
> 
> Fixes: 1bb4a528c41f ("ethdev: fix max Rx packet length")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> ---
>  examples/dma/dmafwd.c | 43 +++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 39 insertions(+), 4 deletions(-)
> 
> diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c
> index 608487e35c..a03ca05129 100644
> --- a/examples/dma/dmafwd.c
> +++ b/examples/dma/dmafwd.c
> @@ -117,7 +117,7 @@ static uint16_t nb_txd = TX_DEFAULT_RINGSIZE;
>  static volatile bool force_quit;
>  
>  static uint32_t dma_batch_sz = MAX_PKT_BURST;
> -static uint32_t max_frame_size = RTE_ETHER_MAX_LEN;
> +static uint32_t max_frame_size;
>  
>  /* ethernet addresses of ports */
>  static struct rte_ether_addr dma_ports_eth_addr[RTE_MAX_ETHPORTS];
> @@ -851,6 +851,38 @@ assign_rings(void)
>  }
>  /* >8 End of assigning ring structures for packet exchanging. */
>  
> +static uint32_t
> +eth_dev_get_overhead_len(uint32_t max_rx_pktlen, uint16_t max_mtu)
> +{
> +	uint32_t overhead_len;
> +
> +	if (max_mtu != UINT16_MAX && max_rx_pktlen > max_mtu)
> +		overhead_len = max_rx_pktlen - max_mtu;
> +	else
> +		overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
> +
> +	return overhead_len;
> +}
> +
> +static int
> +config_port_max_pkt_len(struct rte_eth_conf *conf,
> +		struct rte_eth_dev_info *dev_info)
> +{
> +	uint32_t overhead_len;
> +
> +	if (max_frame_size == 0)
> +		return 0;
> +
> +	if (max_frame_size < RTE_ETHER_MIN_LEN)
> +		return -1;
> +
> +	overhead_len = eth_dev_get_overhead_len(dev_info->max_rx_pktlen,
> +			dev_info->max_mtu);
> +	conf->rxmode.mtu = max_frame_size - overhead_len;
> +
> +	return 0;
> +}
> +
>  /*
>   * Initializes a given port using global settings and with the RX buffers
>   * coming from the mbuf_pool passed as a parameter.
> @@ -878,9 +910,6 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues)
>  	struct rte_eth_dev_info dev_info;
>  	int ret, i;
>  
> -	if (max_frame_size > local_port_conf.rxmode.mtu)
> -		local_port_conf.rxmode.mtu = max_frame_size;
> -
>  	/* Skip ports that are not enabled */
>  	if ((dma_enabled_port_mask & (1 << portid)) == 0) {
>  		printf("Skipping disabled port %u\n", portid);
> @@ -895,6 +924,12 @@ port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues)
>  		rte_exit(EXIT_FAILURE, "Cannot get device info: %s, port=%u\n",
>  			rte_strerror(-ret), portid);
>  
> +	ret = config_port_max_pkt_len(&local_port_conf, &dev_info);
> +	if (ret != 0)
> +		rte_exit(EXIT_FAILURE,
> +			"Invalid max frame size: %u (port %u)\n",
> +			max_frame_size, portid);
> +
>  	local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
>  		dev_info.flow_type_rss_offloads;
>  	ret = rte_eth_dev_configure(portid, nb_queues, 1, &local_port_conf);
> 


  reply	other threads:[~2022-05-11  2:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11  2:56 [PATCH 0/4] bugfix and enhance features for DMA example Chengwen Feng
2022-04-11  2:56 ` [PATCH 1/4] examples/dma: fix MTU configuration Chengwen Feng
2022-04-11  2:56 ` [PATCH 2/4] examples/dma: fix Tx drop statistic is not collected Chengwen Feng
2022-04-11  2:56 ` [PATCH 3/4] examples/dma: support enqueue drop statistic Chengwen Feng
2022-04-11  2:56 ` [PATCH 4/4] examples/dma: add minimal copy size parameter Chengwen Feng
2022-04-11  9:27   ` Bruce Richardson
2022-04-11 12:23     ` fengchengwen
2022-04-11 12:14 ` [PATCH v2 0/4] bugfix and enhance features for DMA example Chengwen Feng
2022-04-11 12:14   ` [PATCH v2 1/4] examples/dma: fix MTU configuration Chengwen Feng
2022-04-11 12:14   ` [PATCH v2 2/4] examples/dma: fix Tx drop statistic is not collected Chengwen Feng
2022-04-13 14:57     ` Bruce Richardson
2022-04-11 12:14   ` [PATCH v2 3/4] examples/dma: support enqueue drop statistic Chengwen Feng
2022-04-13 15:01     ` Bruce Richardson
2022-04-16  6:19       ` fengchengwen
2022-04-19  8:45         ` Bruce Richardson
2022-04-19 12:09           ` fengchengwen
2022-04-24  3:55             ` fengchengwen
2022-04-11 12:14   ` [PATCH v2 4/4] examples/dma: add force minimal copy size parameter Chengwen Feng
2022-04-13 15:04     ` Bruce Richardson
2022-04-24  6:07 ` [PATCH v3 0/3] bugfix and enhance features for DMA example Chengwen Feng
2022-04-24  6:07   ` [PATCH v3 1/3] examples/dma: fix MTU configuration Chengwen Feng
2022-05-11  2:26     ` fengchengwen [this message]
2022-04-24  6:07   ` [PATCH v3 2/3] examples/dma: fix Tx drop statistic is not collected Chengwen Feng
2022-04-27 10:54     ` Kevin Laatz
2022-04-24  6:07   ` [PATCH v3 3/3] examples/dma: add force minimal copy size parameter Chengwen Feng
2022-04-27 10:54     ` Kevin Laatz
2022-06-06 21:35   ` [PATCH v3 0/3] bugfix and enhance features for DMA example Thomas Monjalon

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=9ed2ca68-6cdb-c7f0-e16c-c133bf8998e6@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@xilinx.com \
    --cc=kevin.laatz@intel.com \
    --cc=thomas@monjalon.net \
    /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).