DPDK-dev Archive on lore.kernel.org
 help / color / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Xiao Zhang <xiao.zhang@intel.com>, dev@dpdk.org
Cc: beilei.xing@intel.com, qi.z.zhang@intel.com,
	ian.stokes@intel.com, stable@dpdk.org,
	Andrew Rybchenko <arybchenko@solarflare.com>,
	"Yigit, Ferruh" <ferruh.yigit@intel.com>,
	"thomas@monjalon.net" <thomas@monjalon.net>,
	Xiaolong Ye <xiaolong.ye@intel.com>
Subject: Re: [dpdk-dev] [v3] net/i40e: fix vlan packets drop
Date: Fri, 8 Nov 2019 19:28:47 +0000
Message-ID: <39c0da13-5bd4-8dd2-ac09-a6ef5c1e3380@redhat.com> (raw)
In-Reply-To: <1572325942-72488-1-git-send-email-xiao.zhang@intel.com>

Hi Xiao,

On 29/10/2019 05:12, Xiao Zhang wrote:
> VLAN packets with ip length bigger than 1496 will not be received by
> i40e/i40evf due to wrong packets size checking. This patch fixes the
> issue by correcting the maximum frame size during checking.
> 
> Fixes: 43e5488c0ac6 ("net/i40e: support MTU configuration")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xiao Zhang <xiao.zhang@intel.com>
> ---
> v3
> Checking more places using max packet len.
> v2
> Add fix for i40evf and correct the checking when using the max_pkt_len.
> ---
>  drivers/net/i40e/i40e_ethdev.c    |  2 +-
>  drivers/net/i40e/i40e_ethdev_vf.c | 11 +++++++----
>  drivers/net/i40e/i40e_fdir.c      |  2 +-
>  drivers/net/i40e/i40e_rxtx.c      |  9 ++++++---
>  lib/librte_ethdev/rte_ethdev.c    | 10 ++++++++--
>  lib/librte_net/rte_ether.h        |  1 +
>  6 files changed, 24 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 77a4683..b0e23c7 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -12105,7 +12105,7 @@ i40e_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
>  		return -EBUSY;
>  	}
>  
> -	if (frame_size > RTE_ETHER_MAX_LEN)
> +	if (frame_size > RTE_ETHER_MAX_LEN + I40E_VLAN_TAG_SIZE * 2)
>  		dev_data->dev_conf.rxmode.offloads |=
>  			DEV_RX_OFFLOAD_JUMBO_FRAME;
>  	else
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
> index 5dba092..1e0b50f 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -1772,7 +1772,8 @@ i40evf_rxq_init(struct rte_eth_dev *dev, struct i40e_rx_queue *rxq)
>  	 * Check if the jumbo frame and maximum packet length are set correctly
>  	 */
>  	if (dev_data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
> -		if (rxq->max_pkt_len <= RTE_ETHER_MAX_LEN ||
> +		if (rxq->max_pkt_len <= RTE_ETHER_MAX_LEN +
> +				I40E_VLAN_TAG_SIZE * 2 ||
>  		    rxq->max_pkt_len > I40E_FRAME_SIZE_MAX) {
>  			PMD_DRV_LOG(ERR, "maximum packet length must be "
>  				"larger than %u and smaller than %u, as jumbo "

The log needs to be match the check

> @@ -1782,12 +1783,14 @@ i40evf_rxq_init(struct rte_eth_dev *dev, struct i40e_rx_queue *rxq)
>  		}
>  	} else {
>  		if (rxq->max_pkt_len < RTE_ETHER_MIN_LEN ||
> -		    rxq->max_pkt_len > RTE_ETHER_MAX_LEN) {
> +		    rxq->max_pkt_len > RTE_ETHER_MAX_LEN +
> +				I40E_VLAN_TAG_SIZE * 2) {
>  			PMD_DRV_LOG(ERR, "maximum packet length must be "
>  				"larger than %u and smaller than %u, as jumbo "
>  				"frame is disabled",
>  				(uint32_t)RTE_ETHER_MIN_LEN,
> -				(uint32_t)RTE_ETHER_MAX_LEN);
> +				(uint32_t)RTE_ETHER_MAX_LEN +
> +					I40E_VLAN_TAG_SIZE * 2);
>  			return I40E_ERR_CONFIG;
>  		}
>  	}
> @@ -2747,7 +2750,7 @@ i40evf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
>  		return -EBUSY;
>  	}
>  
> -	if (frame_size > RTE_ETHER_MAX_LEN)
> +	if (frame_size > RTE_ETHER_MAX_LEN + I40E_VLAN_TAG_SIZE * 2)
>  		dev_data->dev_conf.rxmode.offloads |=
>  			DEV_RX_OFFLOAD_JUMBO_FRAME;
>  	else
> diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
> index dee007d..8b813cb 100644
> --- a/drivers/net/i40e/i40e_fdir.c
> +++ b/drivers/net/i40e/i40e_fdir.c
> @@ -113,7 +113,7 @@ i40e_fdir_rx_queue_init(struct i40e_rx_queue *rxq)
>  #endif
>  	rx_ctx.dtype = i40e_header_split_none;
>  	rx_ctx.hsplit_0 = I40E_HEADER_SPLIT_NONE;
> -	rx_ctx.rxmax = RTE_ETHER_MAX_LEN;
> +	rx_ctx.rxmax = RTE_ETHER_MAX_LEN + I40E_VLAN_TAG_SIZE * 2;
>  	rx_ctx.tphrdesc_ena = 1;
>  	rx_ctx.tphwdesc_ena = 1;
>  	rx_ctx.tphdata_ena = 1;
> diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
> index 6a66cec..a93b11f 100644
> --- a/drivers/net/i40e/i40e_rxtx.c
> +++ b/drivers/net/i40e/i40e_rxtx.c
> @@ -2617,7 +2617,8 @@ i40e_rx_queue_config(struct i40e_rx_queue *rxq)
>  		RTE_MIN((uint32_t)(hw->func_caps.rx_buf_chain_len *
>  			rxq->rx_buf_len), data->dev_conf.rxmode.max_rx_pkt_len);
>  	if (data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
> -		if (rxq->max_pkt_len <= RTE_ETHER_MAX_LEN ||
> +		if (rxq->max_pkt_len <= RTE_ETHER_MAX_LEN +
> +				I40E_VLAN_TAG_SIZE * 2 ||
>  			rxq->max_pkt_len > I40E_FRAME_SIZE_MAX) {
>  			PMD_DRV_LOG(ERR, "maximum packet length must "
>  				    "be larger than %u and smaller than %u,"

The log needs to be match the check

> @@ -2628,12 +2629,14 @@ i40e_rx_queue_config(struct i40e_rx_queue *rxq)
>  		}
>  	} else {
>  		if (rxq->max_pkt_len < RTE_ETHER_MIN_LEN ||
> -			rxq->max_pkt_len > RTE_ETHER_MAX_LEN) {
> +			rxq->max_pkt_len > RTE_ETHER_MAX_LEN +
> +				I40E_VLAN_TAG_SIZE * 2) {
>  			PMD_DRV_LOG(ERR, "maximum packet length must be "
>  				    "larger than %u and smaller than %u, "
>  				    "as jumbo frame is disabled",
>  				    (uint32_t)RTE_ETHER_MIN_LEN,
> -				    (uint32_t)RTE_ETHER_MAX_LEN);
> +				    (uint32_t)RTE_ETHER_MAX_LEN +
> +						I40E_VLAN_TAG_SIZE * 2);
>  			return I40E_ERR_CONFIG;
>  		}
>  	}
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index 7743205..f6722be 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -1257,11 +1257,17 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
>  			goto rollback;
>  		}
>  	} else {
> +		/**
> +		 * The overhead from MTU to max frame size.
> +		 * Considering VLAN and QinQ packet, the VLAN tag size
> +		 * needs to be added to RTE_ETHER_MAX_LEN.
> +		 */
>  		if (dev_conf->rxmode.max_rx_pkt_len < RTE_ETHER_MIN_LEN ||
> -			dev_conf->rxmode.max_rx_pkt_len > RTE_ETHER_MAX_LEN)
> +			dev_conf->rxmode.max_rx_pkt_len > RTE_ETHER_MAX_LEN
> +				+ RTE_ETHER_VLAN_LEN * 2)
>  			/* Use default value */
>  			dev->data->dev_conf.rxmode.max_rx_pkt_len =
> -							RTE_ETHER_MAX_LEN;
> +				RTE_ETHER_MAX_LEN + RTE_ETHER_VLAN_LEN * 2;

+cc ethdev maintainers

This looks ok to me for i40e case, but I don't know if there is a
consequence for other PMDs. It seems late to change this, so maybe you
can live without this part for now.

Even on the i40e parts, there can be some subtle bug and I requested
i40e maintainers to review carefully but it has not happened, so for me
it shouldn't be merged at present.

>  	}
>  
>  	/* Any requested offloading must be within its device capabilities */
> diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h
> index e069dc7..9c5eee7 100644
> --- a/lib/librte_net/rte_ether.h
> +++ b/lib/librte_net/rte_ether.h
> @@ -26,6 +26,7 @@ extern "C" {
>  #define RTE_ETHER_ADDR_LEN  6 /**< Length of Ethernet address. */
>  #define RTE_ETHER_TYPE_LEN  2 /**< Length of Ethernet type field. */
>  #define RTE_ETHER_CRC_LEN   4 /**< Length of Ethernet CRC. */
> +#define RTE_ETHER_VLAN_LEN  4 /**< Length of Ethernet VLAN tag. */
>  #define RTE_ETHER_HDR_LEN   \
>  	(RTE_ETHER_ADDR_LEN * 2 + \
>  		RTE_ETHER_TYPE_LEN) /**< Length of Ethernet header. */
> 


  reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14  7:53 [dpdk-dev] " Xiao Zhang
2019-10-14 17:41 ` Kevin Traynor
2019-10-15  1:41   ` Zhang, Xiao
2019-10-21  2:44 ` [dpdk-dev] [v2] " Xiao Zhang
2019-10-21 20:15   ` Kevin Traynor
2019-10-29  5:12 ` [dpdk-dev] [v3] " Xiao Zhang
2019-11-08 19:28   ` Kevin Traynor [this message]
2019-11-08 19:49     ` Thomas Monjalon
2019-11-09  3:01       ` Zhang, Qi Z

Reply instructions:

You may reply publically 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=39c0da13-5bd4-8dd2-ac09-a6ef5c1e3380@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=arybchenko@solarflare.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=ian.stokes@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=xiao.zhang@intel.com \
    --cc=xiaolong.ye@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

DPDK-dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dpdk-dev/0 dpdk-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dpdk-dev dpdk-dev/ https://lore.kernel.org/dpdk-dev \
		dev@dpdk.org
	public-inbox-index dpdk-dev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git