DPDK patches and discussions
 help / color / mirror / Atom feed
From: Marcin Wojtas <mw@semihalf.com>
To: dev@dpdk.org
Cc: jan.medala@outlook.com, jpalider@gmail.com, netanel@amazon.com,
	evgenys@amazon.com, matua@amazon.com, gtzalik@amazon.com,
	igorch@amazon.com, mw@semihalf.com, mk@semihalf.com
Subject: [dpdk-dev] [PATCH v2 4/4] net/ena: calculate partial checksum if DF bit is disabled
Date: Mon, 10 Apr 2017 16:28:11 +0200	[thread overview]
Message-ID: <1491834491-13944-5-git-send-email-mw@semihalf.com> (raw)
In-Reply-To: <1491834491-13944-1-git-send-email-mw@semihalf.com>

From: Michal Krawczyk <mk@semihalf.com>

When TSO is disabled we still have to calculate partial checksum if DF bit
if turned off. This is caused by firmware bug.

First of all, we must make sure that we are dealing with IPV4 packet.
If not, we will just skip further checking of this packet and move to
the next one.

If application will not set m2_len field, we assume we that it was Ethernet
frame because we have to look inside the packet to check for the DF flag.
To make it work properly, PMD is assuming that before sending
packet application called function rte_eth_tx_prepare().

Signed-off-by: Michal Krawczyk <mk@semihalf.com>
---
 drivers/net/ena/ena_ethdev.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index e6e889b..3ba9901 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -1599,14 +1599,33 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	uint64_t ol_flags;
 	uint16_t frag_field;
 
-	/* ENA needs partial checksum for TSO packets only, skip early */
-	if (!tx_ring->adapter->tso4_supported)
-		return nb_pkts;
-
 	for (i = 0; i != nb_pkts; i++) {
 		m = tx_pkts[i];
 		ol_flags = m->ol_flags;
 
+		if (!(ol_flags & PKT_TX_IPV4))
+			continue;
+
+		/* If there was not L2 header length specified, assume it is
+		 * length of the ethernet header.
+		 */
+		if (unlikely(m->l2_len == 0))
+			m->l2_len = sizeof(struct ether_hdr);
+
+		ip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,
+						 m->l2_len);
+		frag_field = rte_be_to_cpu_16(ip_hdr->fragment_offset);
+
+		if ((frag_field & IPV4_HDR_DF_FLAG) != 0) {
+			m->packet_type |= RTE_PTYPE_L4_NONFRAG;
+
+			/* If IPv4 header has DF flag enabled and TSO support is
+			 * disabled, partial chcecksum should not be calculated.
+			 */
+			if (!tx_ring->adapter->tso4_supported)
+				continue;
+		}
+
 		if ((ol_flags & ENA_TX_OFFLOAD_NOTSUP_MASK) != 0 ||
 				(ol_flags & PKT_TX_L4_MASK) ==
 				PKT_TX_SCTP_CKSUM) {
@@ -1622,15 +1641,6 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		}
 #endif
 
-		if (!(m->ol_flags & PKT_TX_IPV4))
-			continue;
-
-		ip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,
-						 m->l2_len);
-		frag_field = rte_be_to_cpu_16(ip_hdr->fragment_offset);
-		if (frag_field & IPV4_HDR_DF_FLAG)
-			continue;
-
 		/* In case we are supposed to TSO and have DF not set (DF=0)
 		 * hardware must be provided with partial checksum, otherwise
 		 * it will take care of necessary calculations.
-- 
1.8.3.1

  parent reply	other threads:[~2017-04-10 14:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 14:28 [dpdk-dev] [PATCH v2 0/4] Ena PMD fixes Marcin Wojtas
2017-04-10 14:28 ` [dpdk-dev] [PATCH v2 1/4] net/ena: fix incorrect Rx descriptors allocation Marcin Wojtas
2017-04-10 14:28 ` [dpdk-dev] [PATCH v2 2/4] net/ena: fix delayed cleanup of Rx descriptors Marcin Wojtas
2017-04-10 14:28 ` [dpdk-dev] [PATCH v2 3/4] net/ena: cleanup if refilling of rx descriptors fails Marcin Wojtas
2017-04-10 14:28 ` Marcin Wojtas [this message]
2017-04-10 22:20 ` [dpdk-dev] [PATCH v2 0/4] Ena PMD fixes Jakub Palider
2017-04-12 11:22   ` Ferruh Yigit
2017-04-11  8:29 ` Jan M?dala

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=1491834491-13944-5-git-send-email-mw@semihalf.com \
    --to=mw@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=evgenys@amazon.com \
    --cc=gtzalik@amazon.com \
    --cc=igorch@amazon.com \
    --cc=jan.medala@outlook.com \
    --cc=jpalider@gmail.com \
    --cc=matua@amazon.com \
    --cc=mk@semihalf.com \
    --cc=netanel@amazon.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).