From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E2A3FA046B for ; Thu, 27 Jun 2019 23:06:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 18AEA28EE; Thu, 27 Jun 2019 23:06:28 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [84.52.114.115]) by dpdk.org (Postfix) with ESMTP id D4E1420BD for ; Thu, 27 Jun 2019 23:06:26 +0200 (CEST) Received: from olwe.oktetlabs.ru (olwe.oktetlabs.ru [192.168.37.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 434517F6DE; Fri, 28 Jun 2019 00:06:26 +0300 (MSK) From: Ivan Malov To: Olivier Matz Cc: dev@dpdk.org, "Ananyev, Konstantin" , Andrew Rybchenko Date: Fri, 28 Jun 2019 00:06:18 +0300 Message-Id: <20190627210618.22205-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190412150542.12026-1-ivan.malov@oktetlabs.ru> References: <20190412150542.12026-1-ivan.malov@oktetlabs.ru> Subject: [dpdk-dev] [PATCH v3] mbuf: outer offsets are undefined for non-tunnel packets X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The default policy for offload-specific fields is that they are undefined unless the corresponding offloads are requested in mbuf ol_flags. This is also the case for outer L2 and L3 length fields which must not be assumed to contain zeros for non-tunnel packets. The patch clarifies this behaviour in the comments and also adds appropriate checks to the PMDs which do not check any tunnel-related offloads before using the said fields. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Acked-by: Konstantin Ananyev --- drivers/net/bnxt/bnxt_txr.c | 6 ++++-- drivers/net/fm10k/fm10k_rxtx.c | 5 +++-- drivers/net/i40e/i40e_rxtx.c | 12 +++--------- drivers/net/iavf/iavf_rxtx.c | 3 --- drivers/net/ice/ice_rxtx.c | 12 +++--------- lib/librte_mbuf/rte_mbuf.h | 13 ++++++++++++- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c index 124186e..c71e6f1 100644 --- a/drivers/net/bnxt/bnxt_txr.c +++ b/drivers/net/bnxt/bnxt_txr.c @@ -235,8 +235,10 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, txbd1->lflags |= TX_BD_LONG_LFLAGS_LSO | TX_BD_LONG_LFLAGS_T_IPID; hdr_size = tx_pkt->l2_len + tx_pkt->l3_len + - tx_pkt->l4_len + tx_pkt->outer_l2_len + - tx_pkt->outer_l3_len; + tx_pkt->l4_len; + hdr_size += (tx_pkt->ol_flags & PKT_TX_TUNNEL_MASK) ? + tx_pkt->outer_l2_len + + tx_pkt->outer_l3_len : 0; /* The hdr_size is multiple of 16bit units not 8bit. * Hence divide by 2. */ diff --git a/drivers/net/fm10k/fm10k_rxtx.c b/drivers/net/fm10k/fm10k_rxtx.c index 2f4dad0..5c31121 100644 --- a/drivers/net/fm10k/fm10k_rxtx.c +++ b/drivers/net/fm10k/fm10k_rxtx.c @@ -619,8 +619,9 @@ static inline void tx_xmit_pkt(struct fm10k_tx_queue *q, struct rte_mbuf *mb) rte_cpu_to_le_16(rte_pktmbuf_data_len(mb)); if (mb->ol_flags & PKT_TX_TCP_SEG) { - hdrlen = mb->outer_l2_len + mb->outer_l3_len + mb->l2_len + - mb->l3_len + mb->l4_len; + hdrlen = mb->l2_len + mb->l3_len + mb->l4_len; + hdrlen += (mb->ol_flags & PKT_TX_TUNNEL_MASK) ? + mb->outer_l2_len + mb->outer_l3_len : 0; if (q->hw_ring[q->next_free].flags & FM10K_TXD_FLAG_FTAG) hdrlen += sizeof(struct fm10k_ftag); diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 85c44f5..34aa6c8 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -981,15 +981,9 @@ return ctx_desc; } - /** - * in case of non tunneling packet, the outer_l2_len and - * outer_l3_len must be 0. - */ - hdr_len = tx_offload.outer_l2_len + - tx_offload.outer_l3_len + - tx_offload.l2_len + - tx_offload.l3_len + - tx_offload.l4_len; + hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len; + hdr_len += (mbuf->ol_flags & PKT_TX_TUNNEL_MASK) ? + tx_offload.outer_l2_len + tx_offload.outer_l3_len : 0; cd_cmd = I40E_TX_CTX_DESC_TSO; cd_tso_len = mbuf->pkt_len - hdr_len; diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index 0be3ede..2d37c17 100644 --- a/drivers/net/iavf/iavf_rxtx.c +++ b/drivers/net/iavf/iavf_rxtx.c @@ -1449,9 +1449,6 @@ return ctx_desc; } - /* in case of non tunneling packet, the outer_l2_len and - * outer_l3_len must be 0. - */ hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len; diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 0fb3e7f..035ed84 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -1940,15 +1940,9 @@ return ctx_desc; } - /** - * in case of non tunneling packet, the outer_l2_len and - * outer_l3_len must be 0. - */ - hdr_len = tx_offload.outer_l2_len + - tx_offload.outer_l3_len + - tx_offload.l2_len + - tx_offload.l3_len + - tx_offload.l4_len; + hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len; + hdr_len += (mbuf->ol_flags & PKT_TX_TUNNEL_MASK) ? + tx_offload.outer_l2_len + tx_offload.outer_l3_len : 0; cd_cmd = ICE_TX_CTX_DESC_TSO; cd_tso_len = mbuf->pkt_len - hdr_len; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 0d9fef0..ddb562f 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -702,7 +702,18 @@ struct rte_mbuf { uint64_t tso_segsz:RTE_MBUF_TSO_SEGSZ_BITS; /**< TCP TSO segment size */ - /* fields for TX offloading of tunnels */ + /* + * Fields for Tx offloading of tunnels. + * These are undefined for packets which don't request + * any tunnel offloads (outer IP or UDP checksum, + * tunnel TSO). + * + * PMDs should not use these fields unconditionally + * when calculating offsets. + * + * Applications are expected to set appropriate tunnel + * offload flags when they fill in these fields. + */ uint64_t outer_l3_len:RTE_MBUF_OUTL3_LEN_BITS; /**< Outer L3 (IP) Hdr Length. */ uint64_t outer_l2_len:RTE_MBUF_OUTL2_LEN_BITS; -- 1.8.3.1