DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/thunderx: fix MTU configuration for jumbo pkts
@ 2018-04-16 10:44 Nitin Saxena
  2018-04-18  4:56 ` Jerin Jacob
  0 siblings, 1 reply; 3+ messages in thread
From: Nitin Saxena @ 2018-04-16 10:44 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: Nitin Saxena, Narayana Prasad, dev

thunderx pmd driver passes dev_info.max_rx_pktlen as
9200 (via rte_eth_dev_info_get()) to application.
But, when application tries to set MTU as
(9200 - sizeof(ethernet_header_t)) the operation fails
because of missing CRC and VLAN additions.

This patch fixes the following for thunderx pmd driver:
 - Sets NIC_HW_MAX_FRS to 9216 (instead of 9200)
 - Sets NIC_HW_MAX_MTU to 9190 (NIC_HW_MAX_FRS - ETH_HLEN
   - ETHER_CRC_LEN - 2*VLAN_HLEN)
 - Sets dev_info->max_rx_pkt_len to NIC_HW_MAX_MTU +
   ETH_HLEN (instead of 9200)
 - Allows rte_eth_dev_set_mtu() to pass if application
   (like VPP) calls rte_eth_dev_set_mtu() before
   rte_eth_dev_start() by putting appropriate check for
   dev->data->dev_started

Fixes: 65d9804edc05 ("net/thunderx: support MTU configuration")

Signed-off-by: Nitin Saxena <nitin.saxena@caviumnetworks.com>
---
 drivers/net/thunderx/base/nicvf_hw_defs.h |  5 ++++-
 drivers/net/thunderx/nicvf_ethdev.c       | 15 +++++++--------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/thunderx/base/nicvf_hw_defs.h b/drivers/net/thunderx/base/nicvf_hw_defs.h
index b13c21f..b12c8ec 100644
--- a/drivers/net/thunderx/base/nicvf_hw_defs.h
+++ b/drivers/net/thunderx/base/nicvf_hw_defs.h
@@ -171,7 +171,10 @@
 
 /* Min/Max packet size */
 #define NIC_HW_MIN_FRS                  (64)
-#define NIC_HW_MAX_FRS                  (9200) /* 9216 max pkt including FCS */
+/* ETH_HLEN+ETH_FCS_LEN+2*VLAN_HLEN */
+#define NIC_HW_L2_OVERHEAD              (26)
+#define NIC_HW_MAX_MTU                  (9190)
+#define NIC_HW_MAX_FRS                  (NIC_HW_MAX_MTU + NIC_HW_L2_OVERHEAD)
 #define NIC_HW_MAX_SEGS                 (12)
 
 /* Descriptor alignments */
diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index 75e9d16..a7931af 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -162,7 +162,7 @@ static int
 nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 {
 	struct nicvf *nic = nicvf_pmd_priv(dev);
-	uint32_t buffsz, frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+	uint32_t buffsz, frame_size = mtu + NIC_HW_L2_OVERHEAD;
 	size_t i;
 	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 
@@ -180,7 +180,7 @@ nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 	 * Refuse mtu that requires the support of scattered packets
 	 * when this feature has not been enabled before.
 	 */
-	if (!dev->data->scattered_rx &&
+	if (dev->data->dev_started && !dev->data->scattered_rx &&
 		(frame_size + 2 * VLAN_TAG_SIZE > buffsz))
 		return -EINVAL;
 
@@ -194,11 +194,11 @@ nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 	else
 		rxmode->offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
 
-	if (nicvf_mbox_update_hw_max_frs(nic, frame_size))
+	if (nicvf_mbox_update_hw_max_frs(nic, mtu))
 		return -EINVAL;
 
-	/* Update max frame size */
-	rxmode->max_rx_pkt_len = (uint32_t)frame_size;
+	/* Update max_rx_pkt_len */
+	rxmode->max_rx_pkt_len = mtu + ETHER_HDR_LEN;
 	nic->mtu = mtu;
 
 	for (i = 0; i < nic->sqs_count; i++)
@@ -1408,7 +1408,7 @@ nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->speed_capa |= ETH_LINK_SPEED_40G;
 
 	dev_info->min_rx_bufsize = ETHER_MIN_MTU;
-	dev_info->max_rx_pktlen = NIC_HW_MAX_FRS;
+	dev_info->max_rx_pktlen = NIC_HW_MAX_MTU + ETHER_HDR_LEN;
 	dev_info->max_rx_queues =
 			(uint16_t)MAX_RCV_QUEUES_PER_QS * (MAX_SQS_PER_VF + 1);
 	dev_info->max_tx_queues =
@@ -1741,8 +1741,7 @@ nicvf_dev_start(struct rte_eth_dev *dev)
 	/* Setup MTU based on max_rx_pkt_len or default */
 	mtu = dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME ?
 		dev->data->dev_conf.rxmode.max_rx_pkt_len
-			-  ETHER_HDR_LEN - ETHER_CRC_LEN
-		: ETHER_MTU;
+			-  ETHER_HDR_LEN : ETHER_MTU;
 
 	if (nicvf_dev_set_mtu(dev, mtu)) {
 		PMD_INIT_LOG(ERR, "Failed to set default mtu size");
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/thunderx: fix MTU configuration for jumbo pkts
  2018-04-16 10:44 [dpdk-dev] [PATCH] net/thunderx: fix MTU configuration for jumbo pkts Nitin Saxena
@ 2018-04-18  4:56 ` Jerin Jacob
  2018-04-18 17:03   ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Jerin Jacob @ 2018-04-18  4:56 UTC (permalink / raw)
  To: Nitin Saxena; +Cc: Narayana Prasad, dev

-----Original Message-----
> Date: Mon, 16 Apr 2018 10:44:47 +0000
> From: Nitin Saxena <nitin.saxena@caviumnetworks.com>
> To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Cc: Nitin Saxena <nitin.saxena@caviumnetworks.com>, Narayana Prasad
>  <narayanaprasad.athreya@caviumnetworks.com>, dev@dpdk.org
> Subject: [PATCH] net/thunderx: fix MTU configuration for jumbo pkts
> X-Mailer: git-send-email 2.7.4
> 
> thunderx pmd driver passes dev_info.max_rx_pktlen as
> 9200 (via rte_eth_dev_info_get()) to application.
> But, when application tries to set MTU as
> (9200 - sizeof(ethernet_header_t)) the operation fails
> because of missing CRC and VLAN additions.
> 
> This patch fixes the following for thunderx pmd driver:
>  - Sets NIC_HW_MAX_FRS to 9216 (instead of 9200)
>  - Sets NIC_HW_MAX_MTU to 9190 (NIC_HW_MAX_FRS - ETH_HLEN
>    - ETHER_CRC_LEN - 2*VLAN_HLEN)
>  - Sets dev_info->max_rx_pkt_len to NIC_HW_MAX_MTU +
>    ETH_HLEN (instead of 9200)
>  - Allows rte_eth_dev_set_mtu() to pass if application
>    (like VPP) calls rte_eth_dev_set_mtu() before
>    rte_eth_dev_start() by putting appropriate check for
>    dev->data->dev_started
> 
> Fixes: 65d9804edc05 ("net/thunderx: support MTU configuration")
> 

Cc: stable@dpdk.org

> Signed-off-by: Nitin Saxena <nitin.saxena@caviumnetworks.com>

Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

> ---
>  drivers/net/thunderx/base/nicvf_hw_defs.h |  5 ++++-
>  drivers/net/thunderx/nicvf_ethdev.c       | 15 +++++++--------
>  2 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/thunderx/base/nicvf_hw_defs.h b/drivers/net/thunderx/base/nicvf_hw_defs.h
> index b13c21f..b12c8ec 100644
> --- a/drivers/net/thunderx/base/nicvf_hw_defs.h
> +++ b/drivers/net/thunderx/base/nicvf_hw_defs.h
> @@ -171,7 +171,10 @@
>  
>  /* Min/Max packet size */
>  #define NIC_HW_MIN_FRS                  (64)
> -#define NIC_HW_MAX_FRS                  (9200) /* 9216 max pkt including FCS */
> +/* ETH_HLEN+ETH_FCS_LEN+2*VLAN_HLEN */
> +#define NIC_HW_L2_OVERHEAD              (26)
> +#define NIC_HW_MAX_MTU                  (9190)
> +#define NIC_HW_MAX_FRS                  (NIC_HW_MAX_MTU + NIC_HW_L2_OVERHEAD)
>  #define NIC_HW_MAX_SEGS                 (12)
>  
>  /* Descriptor alignments */
> diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
> index 75e9d16..a7931af 100644
> --- a/drivers/net/thunderx/nicvf_ethdev.c
> +++ b/drivers/net/thunderx/nicvf_ethdev.c
> @@ -162,7 +162,7 @@ static int
>  nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
>  {
>  	struct nicvf *nic = nicvf_pmd_priv(dev);
> -	uint32_t buffsz, frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
> +	uint32_t buffsz, frame_size = mtu + NIC_HW_L2_OVERHEAD;
>  	size_t i;
>  	struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
>  
> @@ -180,7 +180,7 @@ nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
>  	 * Refuse mtu that requires the support of scattered packets
>  	 * when this feature has not been enabled before.
>  	 */
> -	if (!dev->data->scattered_rx &&
> +	if (dev->data->dev_started && !dev->data->scattered_rx &&
>  		(frame_size + 2 * VLAN_TAG_SIZE > buffsz))
>  		return -EINVAL;
>  
> @@ -194,11 +194,11 @@ nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
>  	else
>  		rxmode->offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
>  
> -	if (nicvf_mbox_update_hw_max_frs(nic, frame_size))
> +	if (nicvf_mbox_update_hw_max_frs(nic, mtu))
>  		return -EINVAL;
>  
> -	/* Update max frame size */
> -	rxmode->max_rx_pkt_len = (uint32_t)frame_size;
> +	/* Update max_rx_pkt_len */
> +	rxmode->max_rx_pkt_len = mtu + ETHER_HDR_LEN;
>  	nic->mtu = mtu;
>  
>  	for (i = 0; i < nic->sqs_count; i++)
> @@ -1408,7 +1408,7 @@ nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
>  		dev_info->speed_capa |= ETH_LINK_SPEED_40G;
>  
>  	dev_info->min_rx_bufsize = ETHER_MIN_MTU;
> -	dev_info->max_rx_pktlen = NIC_HW_MAX_FRS;
> +	dev_info->max_rx_pktlen = NIC_HW_MAX_MTU + ETHER_HDR_LEN;
>  	dev_info->max_rx_queues =
>  			(uint16_t)MAX_RCV_QUEUES_PER_QS * (MAX_SQS_PER_VF + 1);
>  	dev_info->max_tx_queues =
> @@ -1741,8 +1741,7 @@ nicvf_dev_start(struct rte_eth_dev *dev)
>  	/* Setup MTU based on max_rx_pkt_len or default */
>  	mtu = dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME ?
>  		dev->data->dev_conf.rxmode.max_rx_pkt_len
> -			-  ETHER_HDR_LEN - ETHER_CRC_LEN
> -		: ETHER_MTU;
> +			-  ETHER_HDR_LEN : ETHER_MTU;
>  
>  	if (nicvf_dev_set_mtu(dev, mtu)) {
>  		PMD_INIT_LOG(ERR, "Failed to set default mtu size");
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/thunderx: fix MTU configuration for jumbo pkts
  2018-04-18  4:56 ` Jerin Jacob
@ 2018-04-18 17:03   ` Ferruh Yigit
  0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2018-04-18 17:03 UTC (permalink / raw)
  To: Jerin Jacob, Nitin Saxena; +Cc: Narayana Prasad, dev

On 4/18/2018 5:56 AM, Jerin Jacob wrote:
> -----Original Message-----
>> Date: Mon, 16 Apr 2018 10:44:47 +0000
>> From: Nitin Saxena <nitin.saxena@caviumnetworks.com>
>> To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
>> Cc: Nitin Saxena <nitin.saxena@caviumnetworks.com>, Narayana Prasad
>>  <narayanaprasad.athreya@caviumnetworks.com>, dev@dpdk.org
>> Subject: [PATCH] net/thunderx: fix MTU configuration for jumbo pkts
>> X-Mailer: git-send-email 2.7.4
>>
>> thunderx pmd driver passes dev_info.max_rx_pktlen as
>> 9200 (via rte_eth_dev_info_get()) to application.
>> But, when application tries to set MTU as
>> (9200 - sizeof(ethernet_header_t)) the operation fails
>> because of missing CRC and VLAN additions.
>>
>> This patch fixes the following for thunderx pmd driver:
>>  - Sets NIC_HW_MAX_FRS to 9216 (instead of 9200)
>>  - Sets NIC_HW_MAX_MTU to 9190 (NIC_HW_MAX_FRS - ETH_HLEN
>>    - ETHER_CRC_LEN - 2*VLAN_HLEN)
>>  - Sets dev_info->max_rx_pkt_len to NIC_HW_MAX_MTU +
>>    ETH_HLEN (instead of 9200)
>>  - Allows rte_eth_dev_set_mtu() to pass if application
>>    (like VPP) calls rte_eth_dev_set_mtu() before
>>    rte_eth_dev_start() by putting appropriate check for
>>    dev->data->dev_started
>>
>> Fixes: 65d9804edc05 ("net/thunderx: support MTU configuration")
>>
> 
> Cc: stable@dpdk.org
> 
>> Signed-off-by: Nitin Saxena <nitin.saxena@caviumnetworks.com>
> 
> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-18 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16 10:44 [dpdk-dev] [PATCH] net/thunderx: fix MTU configuration for jumbo pkts Nitin Saxena
2018-04-18  4:56 ` Jerin Jacob
2018-04-18 17:03   ` Ferruh Yigit

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).