This is a test. Please ignore.

It seems silly using a non-default headroom when attaching external memory.

Most functions assume default headroom, so don't reset to anything less.

Signed-off-by: Morten Brørup <m...@smartsharesystems.com>
---
 app/test/test_mbuf.c       |  8 ++++----
 drivers/net/mlx5/mlx5_rx.h |  1 -
 lib/mbuf/rte_mbuf.c        |  4 ++--
 lib/mbuf/rte_mbuf.h        | 15 +++++++--------
 lib/vhost/virtio_net.c     |  1 -
 5 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
index d7393df7eb..f10eee6ea7 100644
--- a/app/test/test_mbuf.c
+++ b/app/test/test_mbuf.c
@@ -608,9 +608,9 @@ test_attach_from_different_pool(struct rte_mempool 
*pktmbuf_pool,
 
        /* save data pointer to compare it after detach() */
        c_data = rte_pktmbuf_mtod(clone, char *);
-       if (c_data != (char *)clone + sizeof(*clone) + MBUF2_PRIV_SIZE)
+       if (c_data != (char *)clone + sizeof(*clone) + MBUF2_PRIV_SIZE + 
RTE_PKTMBUF_HEADROOM)
                GOTO_FAIL("bad data pointer in clone");
-       if (rte_pktmbuf_headroom(clone) != 0)
+       if (rte_pktmbuf_headroom(clone) != RTE_PKTMBUF_HEADROOM)
                GOTO_FAIL("bad headroom in clone");
 
        rte_pktmbuf_attach(clone, m);
@@ -637,9 +637,9 @@ test_attach_from_different_pool(struct rte_mempool 
*pktmbuf_pool,
 
        /* save data pointer to compare it after detach() */
        c_data2 = rte_pktmbuf_mtod(clone2, char *);
-       if (c_data2 != (char *)clone2 + sizeof(*clone2) + MBUF2_PRIV_SIZE)
+       if (c_data2 != (char *)clone2 + sizeof(*clone2) + MBUF2_PRIV_SIZE + 
RTE_PKTMBUF_HEADROOM)
                GOTO_FAIL("bad data pointer in clone2");
-       if (rte_pktmbuf_headroom(clone2) != 0)
+       if (rte_pktmbuf_headroom(clone2) != RTE_PKTMBUF_HEADROOM)
                GOTO_FAIL("bad headroom in clone2");
 
        rte_pktmbuf_attach(clone2, clone);
diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h
index baeb4797aa..0927ac13ea 100644
--- a/drivers/net/mlx5/mlx5_rx.h
+++ b/drivers/net/mlx5/mlx5_rx.h
@@ -546,7 +546,6 @@ mprq_buf_to_pkt(struct mlx5_rxq_data *rxq, struct rte_mbuf 
*pkt, uint32_t len,
                rte_pktmbuf_attach_extbuf(pkt, buf_addr, buf_iova,
                                          buf_len, shinfo);
                /* Set mbuf head-room. */
-               SET_DATA_OFF(pkt, RTE_PKTMBUF_HEADROOM);
                MLX5_ASSERT(pkt->ol_flags & RTE_MBUF_F_EXTERNAL);
                MLX5_ASSERT(rte_pktmbuf_tailroom(pkt) >=
                        len - (hdrm_overlap > 0 ? hdrm_overlap : 0));
diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c
index 686e797c80..7ccc814a75 100644
--- a/lib/mbuf/rte_mbuf.c
+++ b/lib/mbuf/rte_mbuf.c
@@ -93,7 +93,7 @@ rte_pktmbuf_init(struct rte_mempool *mp,
        m->buf_len = (uint16_t)buf_len;
 
        /* keep some headroom between start of buffer and data */
-       m->data_off = RTE_MIN(RTE_PKTMBUF_HEADROOM, (uint16_t)m->buf_len);
+       rte_pktmbuf_reset_headroom(m);
 
        /* init some constant fields */
        m->pool = mp;
@@ -196,7 +196,7 @@ __rte_pktmbuf_init_extmem(struct rte_mempool *mp,
                ++ctx->ext;
        }
        /* keep some headroom between start of buffer and data */
-       m->data_off = RTE_MIN(RTE_PKTMBUF_HEADROOM, (uint16_t)m->buf_len);
+       rte_pktmbuf_reset_headroom(m);
 
        /* init some constant fields */
        m->pool = mp;
diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
index 913c459b1c..b1047bc848 100644
--- a/lib/mbuf/rte_mbuf.h
+++ b/lib/mbuf/rte_mbuf.h
@@ -859,8 +859,7 @@ rte_pktmbuf_priv_size(struct rte_mempool *mp)
  */
 static inline void rte_pktmbuf_reset_headroom(struct rte_mbuf *m)
 {
-       m->data_off = (uint16_t)RTE_MIN((uint16_t)RTE_PKTMBUF_HEADROOM,
-                                       (uint16_t)m->buf_len);
+       m->data_off = RTE_PKTMBUF_HEADROOM;
 }
 
 /**
@@ -1028,14 +1027,14 @@ rte_pktmbuf_ext_shinfo_init_helper(void *buf_addr, 
uint16_t *buf_len,
  * provided via shinfo. This callback function will be called once all the
  * mbufs are detached from the buffer (refcnt becomes zero).
  *
- * The headroom length of the attaching mbuf will be set to zero and this
- * can be properly adjusted after attachment. For example, 
``rte_pktmbuf_adj()``
- * or ``rte_pktmbuf_reset_headroom()`` might be used.
- *
- * Similarly, the packet length is initialized to 0. If the buffer contains
+ * The packet length is initialized to 0. If the buffer contains
  * data, the user has to adjust ``data_len`` and the ``pkt_len`` field of
  * the mbuf accordingly.
  *
+ * Similarly, the headroom length of the attaching mbuf will be set to the
+ * default (RTE_PKTMBUF_HEADROOM). This can also be properly adjusted after
+ * attachment. For example, ``rte_pktmbuf_adj()`` might be used.
+ *
  * More mbufs can be attached to the same external buffer by
  * ``rte_pktmbuf_attach()`` once the external buffer has been attached by
  * this API.
@@ -1094,7 +1093,7 @@ rte_pktmbuf_attach_extbuf(struct rte_mbuf *m, void 
*buf_addr,
        m->buf_len = buf_len;
 
        m->data_len = 0;
-       m->data_off = 0;
+       rte_pktmbuf_reset_headroom(m);
 
        m->ol_flags |= RTE_MBUF_F_EXTERNAL;
        m->shinfo = shinfo;
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 759a78e3e3..61e6fa1864 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -3042,7 +3042,6 @@ virtio_dev_extbuf_alloc(struct virtio_net *dev, struct 
rte_mbuf *pkt, uint32_t s
 
        iova = rte_malloc_virt2iova(buf);
        rte_pktmbuf_attach_extbuf(pkt, buf, iova, buf_len, shinfo);
-       rte_pktmbuf_reset_headroom(pkt);
 
        return 0;
 }
-- 
2.17.1

Reply via email to