From patchwork Fri Jun 21 10:34:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Malov X-Patchwork-Id: 55167 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 877581D4B7; Fri, 21 Jun 2019 12:34:28 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [84.52.114.115]) by dpdk.org (Postfix) with ESMTP id 65A011D4B5 for ; Fri, 21 Jun 2019 12:34:27 +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 E2E707F886; Fri, 21 Jun 2019 13:34:26 +0300 (MSK) From: Ivan Malov To: Olivier Matz Cc: dev@dpdk.org Date: Fri, 21 Jun 2019 13:34:19 +0300 Message-Id: <20190621103419.11626-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> In-Reply-To: <20190412150542.12026-1-ivan.malov@oktetlabs.ru> References: <20190412150542.12026-1-ivan.malov@oktetlabs.ru> Subject: [dpdk-dev] [PATCH] mbuf: outer offsets must be zero 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" Make sure that outer L2 and L3 header length fields are equal to zero for non-tunnel packets in order to ensure consistent and predictable behaviour in network drivers. Explain this expectation in comments to help developers. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- Notes: At the time of writing a couple of network drivers rely on the statement (i40e, ice) whilst more drivers have runtime conditional checks to guard all references to these fields. This patch is likely to relieve datapath checks in drivers. lib/librte_mbuf/rte_mbuf.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 0d9fef0..cb8b34e 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -702,7 +702,12 @@ 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 fields must be equal to zero in the case + * when (ol_flags & PKT_TX_TUNNEL_MASK) == 0, + * i.e. for all non-tunnel packets. + */ 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; @@ -2376,6 +2381,11 @@ static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail !(ol_flags & PKT_TX_OUTER_IPV4)) return -EINVAL; + /* Outer L2/L3 offsets must be equal to zero for non-tunnel packets. */ + if ((ol_flags & PKT_TX_TUNNEL_MASK) == 0 && + m->outer_l2_len + m->outer_l3_len != 0) + return -EINVAL; + return 0; }