X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_mbuf%2Frte_mbuf.h;h=a50b05c648c794d8a65737549209531e485a503d;hb=41dbdb68723b;hp=28fd4ad52f6e2f8067195c3fb8c7641c032ffd55;hpb=c779ebdca0e4765158bd1eaa6f65c9d714605fae;p=dpdk.git diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 28fd4ad52f..a50b05c648 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -728,6 +728,24 @@ rte_mbuf_to_baddr(struct rte_mbuf *md) return buffer_addr; } +/** + * Return the starting address of the private data area embedded in + * the given mbuf. + * + * Note that no check is made to ensure that a private data area + * actually exists in the supplied mbuf. + * + * @param m + * The pointer to the mbuf. + * @return + * The starting address of the private data area of the given mbuf. + */ +static inline void * __rte_experimental +rte_mbuf_to_priv(struct rte_mbuf *m) +{ + return RTE_PTR_ADD(m, sizeof(struct rte_mbuf)); +} + /** * Returns TRUE if given mbuf is cloned by mbuf indirection, or FALSE * otherwise. @@ -738,7 +756,8 @@ rte_mbuf_to_baddr(struct rte_mbuf *md) #define RTE_MBUF_CLONED(mb) ((mb)->ol_flags & IND_ATTACHED_MBUF) /** - * Returns TRUE if given mbuf is indirect, or FALSE otherwise. + * Deprecated. + * Use RTE_MBUF_CLONED(). */ #define RTE_MBUF_INDIRECT(mb) RTE_MBUF_CLONED(mb) @@ -1019,14 +1038,6 @@ rte_mbuf_raw_free(struct rte_mbuf *m) rte_mempool_put(m->pool, m); } -/* compat with older versions */ -__rte_deprecated -static inline void -__rte_mbuf_raw_free(struct rte_mbuf *m) -{ - rte_mbuf_raw_free(m); -} - /** * The packet mbuf constructor. * @@ -1145,7 +1156,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, * - EEXIST - a memzone with the same name already exists * - ENOMEM - no appropriate memory area found in which to create memzone */ -struct rte_mempool * __rte_experimental +struct rte_mempool * rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n, unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id, const char *ops_name); @@ -1571,7 +1582,8 @@ __rte_pktmbuf_free_direct(struct rte_mbuf *m) static inline void rte_pktmbuf_detach(struct rte_mbuf *m) { struct rte_mempool *mp = m->pool; - uint32_t mbuf_size, buf_len, priv_size; + uint32_t mbuf_size, buf_len; + uint16_t priv_size; if (RTE_MBUF_HAS_EXTBUF(m)) __rte_pktmbuf_free_extbuf(m); @@ -1638,14 +1650,6 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) return NULL; } -/* deprecated, replaced by rte_pktmbuf_prefree_seg() */ -__rte_deprecated -static inline struct rte_mbuf * -__rte_pktmbuf_prefree_seg(struct rte_mbuf *m) -{ - return rte_pktmbuf_prefree_seg(m); -} - /** * Free a segment of a packet mbuf into its original mempool. * @@ -1907,7 +1911,10 @@ static inline char *rte_pktmbuf_prepend(struct rte_mbuf *m, if (unlikely(len > rte_pktmbuf_headroom(m))) return NULL; - m->data_off -= len; + /* NB: elaborating the subtraction like this instead of using + * -= allows us to ensure the result type is uint16_t + * avoiding compiler warnings on gcc 8.1 at least */ + m->data_off = (uint16_t)(m->data_off - len); m->data_len = (uint16_t)(m->data_len + len); m->pkt_len = (m->pkt_len + len); @@ -1967,8 +1974,11 @@ static inline char *rte_pktmbuf_adj(struct rte_mbuf *m, uint16_t len) if (unlikely(len > m->data_len)) return NULL; + /* NB: elaborating the addition like this instead of using + * += allows us to ensure the result type is uint16_t + * avoiding compiler warnings on gcc 8.1 at least */ m->data_len = (uint16_t)(m->data_len - len); - m->data_off += len; + m->data_off = (uint16_t)(m->data_off + len); m->pkt_len = (m->pkt_len - len); return (char *)m->buf_addr + m->data_off; } @@ -2080,8 +2090,11 @@ static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail cur_tail = rte_pktmbuf_lastseg(head); cur_tail->next = tail; - /* accumulate number of segments and total length. */ - head->nb_segs += tail->nb_segs; + /* accumulate number of segments and total length. + * NB: elaborating the addition like this instead of using + * -= allows us to ensure the result type is uint16_t + * avoiding compiler warnings on gcc 8.1 at least */ + head->nb_segs = (uint16_t)(head->nb_segs + tail->nb_segs); head->pkt_len += tail->pkt_len; /* pkt_len is only set in the head */ @@ -2111,7 +2124,11 @@ rte_validate_tx_offload(const struct rte_mbuf *m) return 0; if (ol_flags & PKT_TX_OUTER_IP_CKSUM) - inner_l3_offset += m->outer_l2_len + m->outer_l3_len; + /* NB: elaborating the addition like this instead of using + * += gives the result uint64_t type instead of int, + * avoiding compiler warnings on gcc 8.1 at least */ + inner_l3_offset = inner_l3_offset + m->outer_l2_len + + m->outer_l3_len; /* Headers are fragmented */ if (rte_pktmbuf_data_len(m) < inner_l3_offset + m->l3_len + m->l4_len) @@ -2156,7 +2173,7 @@ rte_validate_tx_offload(const struct rte_mbuf *m) static inline int rte_pktmbuf_linearize(struct rte_mbuf *mbuf) { - int seg_len, copy_len; + size_t seg_len, copy_len; struct rte_mbuf *m; struct rte_mbuf *m_next; char *buffer;