summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Malov <ivan.malov@oktetlabs.ru>2019-06-28 00:06:18 +0300
committerThomas Monjalon <thomas@monjalon.net>2019-07-01 17:15:01 +0200
commitb51690ec69d62b93e98f867198be0e4d20665b35 (patch)
tree8f67c077b9f22c414c85c426665c72a7d4c4041d
parent196a46fab6eeb3ce2039e3bcaca80f8ba43ffc8d (diff)
downloaddpdk-b51690ec69d62b93e98f867198be0e4d20665b35.zip
dpdk-b51690ec69d62b93e98f867198be0e4d20665b35.tar.gz
dpdk-b51690ec69d62b93e98f867198be0e4d20665b35.tar.xz
mbuf: clarify outer offsets for non-tunnel packets
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 <ivan.malov@oktetlabs.ru> Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
-rw-r--r--drivers/net/bnxt/bnxt_txr.c6
-rw-r--r--drivers/net/fm10k/fm10k_rxtx.c5
-rw-r--r--drivers/net/i40e/i40e_rxtx.c12
-rw-r--r--drivers/net/iavf/iavf_rxtx.c3
-rw-r--r--drivers/net/ice/ice_rxtx.c12
-rw-r--r--lib/librte_mbuf/rte_mbuf.h13
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 @@ i40e_set_tso_ctx(struct rte_mbuf *mbuf, union i40e_tx_offload tx_offload)
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 @@ iavf_set_tso_ctx(struct rte_mbuf *mbuf, union iavf_tx_offload tx_offload)
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 @@ ice_set_tso_ctx(struct rte_mbuf *mbuf, union ice_tx_offload tx_offload)
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 9542488..98225ec 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;