Skip to contentSkip to conversation

net/tap: do not include l2 header in gso size when compared with mtu

PATCH In review Harold Huang 5 participants 6 messages Feb 28, 2022 – Oct 17, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/tap: do not include l2 header in gso size when compared with mtu

The gso size is calculated with all of the headers and payload. As a result, the l2 header should not be included when comparing gso size with mtu.

Fixes 050316a88313 ("net/tap: support TSO (TCP Segment Offload)")
---
 drivers/net/tap/rte_eth_tap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/tap/rte_eth_tap.c +1 -1
index f1b48cae82..2b561d232c 100644
@@ -731,7 +731,7 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 					mbuf_in->l4_len;
 			tso_segsz = mbuf_in->tso_segsz + hdrs_len;
 			if (unlikely(tso_segsz == hdrs_len) ||
-				tso_segsz > *txq->mtu) {
+				tso_segsz > *txq->mtu + mbuf_in->l2_len) {
 				txq->stats.errs++;
 				break;
 			}
Signature · 1 line
2.27.0
#1 lore raw
Quoted 16 lines · Harold Huang

The gso size is calculated with all of the headers and payload. As a result, the l2 header should not be included when comparing gso size with mtu.

Fixes 050316a88313 ("net/tap: support TSO (TCP Segment Offload)")
---
  drivers/net/tap/rte_eth_tap.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/tap/rte_eth_tap.c +0 -0
index f1b48cae82..2b561d232c 100644

drivers/net/tap/rte_eth_tap.c pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 737

Quoted 8 lines
drivers/net/tap/rte_eth_tap.c +1 -1
@@ -731,7 +731,7 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
  					mbuf_in->l4_len;
  			tso_segsz = mbuf_in->tso_segsz + hdrs_len;
  			if (unlikely(tso_segsz == hdrs_len) ||
-				tso_segsz > *txq->mtu) {
+				tso_segsz > *txq->mtu + mbuf_in->l2_len) {
  				txq->stats.errs++;
  				break;
  			}

update emails for Ophir & Raslan.

Hi Ophir, since original code is from you can you please help on review?

#2 lore raw
In reply to Harold Huang
Quoted 26 lines · Harold Huang

The gso size is calculated with all of the headers and payload. As a result, the l2 header should not be included when comparing gso size with mtu.

Fixes 050316a88313 ("net/tap: support TSO (TCP Segment Offload)")
---
 drivers/net/tap/rte_eth_tap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/tap/rte_eth_tap.c +1 -2
index f1b48cae82..2b561d232c 100644
@@ -731,7 +731,7 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                                        mbuf_in->l4_len;
                        tso_segsz = mbuf_in->tso_segsz + hdrs_len;
                        if (unlikely(tso_segsz == hdrs_len) ||
-                               tso_segsz > *txq->mtu) {
+                               tso_segsz > *txq->mtu + mbuf_in->l2_len) {
                                txq->stats.errs++;
                                break;
                        }
--
Quoted 2 lines

2.27.0

Hi, Jiayu,

This is the only example in the driver to use GSO. I think it is important for us to calculate a correct GSO size. I see you are the GSO lib maintainer, could you please help review this patch?

#3 lore raw
Quoted 32 lines · Harold Huang
Quoted 26 lines · Harold Huang

The gso size is calculated with all of the headers and payload. As a result, the l2 header should not be included when comparing gso size with mtu.

Fixes 050316a88313 ("net/tap: support TSO (TCP Segment Offload)")
---
  drivers/net/tap/rte_eth_tap.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/tap/rte_eth_tap.c +1 -2
index f1b48cae82..2b561d232c 100644
@@ -731,7 +731,7 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                                         mbuf_in->l4_len;
                         tso_segsz = mbuf_in->tso_segsz + hdrs_len;
                         if (unlikely(tso_segsz == hdrs_len) ||
-                               tso_segsz > *txq->mtu) {
+                               tso_segsz > *txq->mtu + mbuf_in->l2_len) {
                                 txq->stats.errs++;
                                 break;
                         }
--
Quoted 2 lines

2.27.0

Hi, Jiayu,

Quoted 3 lines

This is the only example in the driver to use GSO. I think it is important for us to calculate a correct GSO size. I see you are the GSO lib maintainer, could you please help review this patch?

Hi Jiayu, Ophir,

Can you please review this patch?

For reference, patchwork link:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

Thanks,
ferruh

#4 lore raw

Hi all,

Please note that max size is calculated in the same function (drivers/net/tap/rte_eth_tap.c) as:
max_size = *txq->mtu + (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + 4);

Since tso_setgsz should not exceed the max packet size - the desired update should be:
tso_segsz > max_size

rather than the suggested one:

                      tso_segsz > *txq->mtu + mbuf_in->l2_len)

Regards,
Ophir

Quoted 61 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Saturday, May 21, 2022 1:08 AM
To: Harold Huang <[email protected]>; [email protected]; [email protected]; Ophir Munk <[email protected]>; Raslan Darawsheh <[email protected]>
Cc: [email protected]; Keith Wiles <[email protected]>
Subject: Re: [PATCH] net/tap: do not include l2 header in gso size when compared with mtu

Quoted 1 line · Harold Huang

On Mon, Feb 28, 2022 at 4:27 PM Harold Huang

Quoted 12 lines · <[email protected]> wrote:
Quoted 12 lines

The gso size is calculated with all of the headers and payload. As a result, the l2 header should not be included when comparing gso size with mtu.

Fixes 050316a88313 ("net/tap: support TSO (TCP Segment Offload)")
---
  drivers/net/tap/rte_eth_tap.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines

drivers/net/tap/rte_eth_tap.c pmd_tx_burst(void *queue, struct rte_mbuf

Quoted 5 lines
(quoted diff) +0 -0

b/drivers/net/tap/rte_eth_tap.c index f1b48cae82..2b561d232c 100644

drivers/net/tap/rte_eth_tap.c +0 -0
@@ -731,7 +731,7 @@ pmd_tx_burst(void *queue, struct rte_mbuf

**bufs, uint16_t nb_pkts)

Quoted 13 lines
Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +2 -2
                                         mbuf_in->l4_len;
                         tso_segsz = mbuf_in->tso_segsz + hdrs_len;
                         if (unlikely(tso_segsz == hdrs_len) ||
-                               tso_segsz > *txq->mtu) {
+                               tso_segsz > *txq->mtu +
+ mbuf_in->l2_len) {
                                 txq->stats.errs++;
                                 break;
                         }
--
Quoted 2 lines

2.27.0

Quoted 5 lines

Hi, Jiayu,

This is the only example in the driver to use GSO. I think it is important for us to calculate a correct GSO size. I see you are the GSO lib maintainer, could you please help review this patch?

Hi Jiayu, Ophir,

Can you please review this patch?

For reference, patchwork link:
https://patches.dpdk.org/project/dpdk/patch/20220228082724.1646930-1-
[email protected]/

Thanks,
ferruh

#5 lore raw
In reply to Harold Huang
Quoted 32 lines · On Tue, 8 Mar 2022 22:35:18 +0800 Harold Huang <[email protected]> wrote:
Quoted 26 lines · Harold Huang

The gso size is calculated with all of the headers and payload. As a result, the l2 header should not be included when comparing gso size with mtu.

Fixes 050316a88313 ("net/tap: support TSO (TCP Segment Offload)")
---
 drivers/net/tap/rte_eth_tap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/tap/rte_eth_tap.c +1 -2
index f1b48cae82..2b561d232c 100644
@@ -731,7 +731,7 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                                        mbuf_in->l4_len;
                        tso_segsz = mbuf_in->tso_segsz + hdrs_len;
                        if (unlikely(tso_segsz == hdrs_len) ||
-                               tso_segsz > *txq->mtu) {
+                               tso_segsz > *txq->mtu + mbuf_in->l2_len) {
                                txq->stats.errs++;
                                break;
                        }
--
Quoted 2 lines

2.27.0

Hi, Jiayu,

Quoted 3 lines

This is the only example in the driver to use GSO. I think it is important for us to calculate a correct GSO size. I see you are the GSO lib maintainer, could you please help review this patch?

See Ophir's comment and address it in new version

Please note that max size is calculated in the same function (drivers/net/tap/rte_eth_tap.c) as:
max_size = *txq->mtu + (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + 4);

Since tso_setgsz should not exceed the max packet size - the desired update should be:
tso_segsz > max_size

rather than the suggested one:

                      tso_segsz > *txq->mtu + mbuf_in->l2_len)