mbuf: remove experimental tag from pool ops
[dpdk.git] / lib / librte_mbuf / rte_mbuf.h
index 0a94e3e..9ce5d76 100644 (file)
@@ -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)
 
@@ -1145,7 +1164,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);
@@ -1360,7 +1379,7 @@ rte_pktmbuf_ext_shinfo_init_helper(void *buf_addr, uint16_t *buf_len,
        shinfo->fcb_opaque = fcb_opaque;
        rte_mbuf_ext_refcnt_set(shinfo, 1);
 
-       *buf_len = RTE_PTR_DIFF(shinfo, buf_addr);
+       *buf_len = (uint16_t)RTE_PTR_DIFF(shinfo, buf_addr);
        return shinfo;
 }
 
@@ -1571,7 +1590,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);
@@ -1579,7 +1599,7 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m)
                __rte_pktmbuf_free_direct(m);
 
        priv_size = rte_pktmbuf_priv_size(mp);
-       mbuf_size = sizeof(struct rte_mbuf) + priv_size;
+       mbuf_size = (uint32_t)(sizeof(struct rte_mbuf) + priv_size);
        buf_len = rte_pktmbuf_data_room_size(mp);
 
        m->priv_size = priv_size;
@@ -1907,7 +1927,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 +1990,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 +2106,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 +2140,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 +2189,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;