X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_mbuf%2Frte_mbuf.h;h=80419df37a682c87ed31071c0b352eb57a85a9e9;hb=7392dde0cc9d40022bc5cf1098f2579dc3c0ca80;hp=6c9cfd6cb0bc9b7d4ae215447a9142cc52dabd5c;hpb=f20b50b946da9070d21e392e4dbc7d9f68bc983e;p=dpdk.git diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 6c9cfd6cb0..80419df37a 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -54,6 +54,7 @@ */ #include +#include #include #include #include @@ -101,10 +102,16 @@ extern "C" { #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 header. */ #define PKT_RX_FDIR_ID (1ULL << 13) /**< FD id reported if FDIR match. */ #define PKT_RX_FDIR_FLX (1ULL << 14) /**< Flexible bytes reported if FDIR match. */ +#define PKT_RX_QINQ_PKT (1ULL << 15) /**< RX packet with double VLAN stripped. */ /* add new RX flags here */ /* add new TX flags here */ +/** + * Second VLAN insertion (QinQ) flag. + */ +#define PKT_TX_QINQ_PKT (1ULL << 49) /**< TX packet with double VLAN inserted. */ + /** * TCP segmentation offload. To enable this offload feature for a * packet to be transmitted on hardware supporting TSO: @@ -279,7 +286,7 @@ struct rte_mbuf { uint16_t data_len; /**< Amount of data in segment buffer. */ uint32_t pkt_len; /**< Total pkt len: sum of all segments. */ uint16_t vlan_tci; /**< VLAN Tag Control Identifier (CPU order) */ - uint16_t reserved; + uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */ union { uint32_t rss; /**< RSS hash result if RSS enabled */ struct { @@ -347,13 +354,7 @@ static inline uint16_t rte_pktmbuf_priv_size(struct rte_mempool *mp); static inline struct rte_mbuf * rte_mbuf_from_indirect(struct rte_mbuf *mi) { - struct rte_mbuf *md; - - /* mi->buf_addr and mi->priv_size correspond to buffer and - * private size of the direct mbuf */ - md = (struct rte_mbuf *)((char *)mi->buf_addr - sizeof(*mi) - - mi->priv_size); - return md; + return RTE_PTR_SUB(mi->buf_addr, sizeof(*mi) + mi->priv_size); } /** @@ -552,7 +553,7 @@ static inline struct rte_mbuf *__rte_mbuf_raw_alloc(struct rte_mempool *mp) m = (struct rte_mbuf *)mb; RTE_MBUF_ASSERT(rte_mbuf_refcnt_read(m) == 0); rte_mbuf_refcnt_set(m, 1); - return (m); + return m; } /** @@ -648,7 +649,7 @@ void rte_ctrlmbuf_init(struct rte_mempool *mp, void *opaque_arg, static inline int rte_is_ctrlmbuf(struct rte_mbuf *m) { - return (!!(m->ol_flags & CTRL_MBUF_FLAG)); + return !!(m->ol_flags & CTRL_MBUF_FLAG); } /* Operations on pkt mbuf */ @@ -789,6 +790,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m) m->pkt_len = 0; m->tx_offload = 0; m->vlan_tci = 0; + m->vlan_tci_outer = 0; m->nb_segs = 1; m->port = 0xff; @@ -819,7 +821,7 @@ static inline struct rte_mbuf *rte_pktmbuf_alloc(struct rte_mempool *mp) struct rte_mbuf *m; if ((m = __rte_mbuf_raw_alloc(mp)) != NULL) rte_pktmbuf_reset(m); - return (m); + return m; } /** @@ -861,6 +863,7 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *m) mi->data_len = m->data_len; mi->port = m->port; mi->vlan_tci = m->vlan_tci; + mi->vlan_tci_outer = m->vlan_tci_outer; mi->tx_offload = m->tx_offload; mi->hash = m->hash; @@ -919,9 +922,9 @@ __rte_pktmbuf_prefree_seg(struct rte_mbuf *m) if (rte_mbuf_refcnt_update(md, -1) == 0) __rte_mbuf_raw_free(md); } - return(m); + return m; } - return (NULL); + return NULL; } /** @@ -989,7 +992,7 @@ static inline struct rte_mbuf *rte_pktmbuf_clone(struct rte_mbuf *md, uint8_t nseg; if (unlikely ((mc = rte_pktmbuf_alloc(mp)) == NULL)) - return (NULL); + return NULL; mi = mc; prev = &mi->next; @@ -1011,11 +1014,11 @@ static inline struct rte_mbuf *rte_pktmbuf_clone(struct rte_mbuf *md, /* Allocation of new indirect segment failed */ if (unlikely (mi == NULL)) { rte_pktmbuf_free(mc); - return (NULL); + return NULL; } __rte_mbuf_sanity_check(mc, 1); - return (mc); + return mc; } /** @@ -1085,19 +1088,36 @@ static inline struct rte_mbuf *rte_pktmbuf_lastseg(struct rte_mbuf *m) return m2; } +/** + * A macro that points to an offset into the data in the mbuf. + * + * The returned pointer is cast to type t. Before using this + * function, the user must ensure that the first segment is large + * enough to accommodate its data. + * + * @param m + * The packet mbuf. + * @param o + * The offset into the mbuf data. + * @param t + * The type to cast the result into. + */ +#define rte_pktmbuf_mtod_offset(m, t, o) \ + ((t)((char *)(m)->buf_addr + (m)->data_off + (o))) + /** * A macro that points to the start of the data in the mbuf. * * The returned pointer is cast to type t. Before using this - * function, the user must ensure that m_headlen(m) is large enough to - * read its data. + * function, the user must ensure that the first segment is large + * enough to accommodate its data. * * @param m * The packet mbuf. * @param t * The type to cast the result into. */ -#define rte_pktmbuf_mtod(m, t) ((t)((char *)(m)->buf_addr + (m)->data_off)) +#define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0) /** * A macro that returns the length of the packet.