mbp_ctor_arg = (struct mbuf_pool_ctor_arg *) opaque_arg;
mbp_priv = rte_mempool_get_priv(mp);
mbp_priv->mbuf_data_room_size = mbp_ctor_arg->seg_buf_size;
+ mbp_priv->mbuf_priv_size = 0;
}
static void
Although backward compatibility is being maintained across DPDK releases, code written for previous versions of the DPDK
may require some code updates to benefit from performance and user experience enhancements provided in later DPDK releases.
+DPDK 2.0 to DPDK 2.1
+--------------------
+
+* The second argument of rte_pktmbuf_pool_init(mempool, opaque) is now a
+ pointer to a struct rte_pktmbuf_pool_private instead of a uint16_t
+ casted into a pointer. Backward compatibility is preserved when the
+ argument was NULL which is the majority of use cases, but not if the
+ opaque pointer was not NULL, as it is not technically feasible. In
+ this case, the application has to be modified to properly fill a
+ rte_pktmbuf_pool_private structure and pass it to
+ rte_pktmbuf_pool_init().
+
DPDK 1.7 to DPDK 1.8
--------------------
setup_mempool_tbl(int socket, uint32_t index, char *pool_name,
char *ring_name, uint32_t nb_mbuf)
{
- uint16_t roomsize = VIRTIO_DESCRIPTOR_LEN_ZCP + RTE_PKTMBUF_HEADROOM;
vpool_array[index].pool
= rte_mempool_create(pool_name, nb_mbuf, MBUF_SIZE_ZCP,
MBUF_CACHE_SIZE_ZCP, sizeof(struct rte_pktmbuf_pool_private),
- rte_pktmbuf_pool_init, (void *)(uintptr_t)roomsize,
+ rte_pktmbuf_pool_init, NULL,
rte_pktmbuf_init, NULL, socket, 0);
if (vpool_array[index].pool != NULL) {
vpool_array[index].ring
}
/* Need consider head room. */
- vpool_array[index].buf_size = roomsize - RTE_PKTMBUF_HEADROOM;
+ vpool_array[index].buf_size = VIRTIO_DESCRIPTOR_LEN_ZCP;
} else {
rte_exit(EXIT_FAILURE, "mempool_create(%s) failed", pool_name);
}
void
rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg)
{
- struct rte_pktmbuf_pool_private *mbp_priv;
+ struct rte_pktmbuf_pool_private *user_mbp_priv, *mbp_priv;
+ struct rte_pktmbuf_pool_private default_mbp_priv;
uint16_t roomsz;
- mbp_priv = rte_mempool_get_priv(mp);
- roomsz = (uint16_t)(uintptr_t)opaque_arg;
+ RTE_MBUF_ASSERT(mp->elt_size >= sizeof(struct rte_mbuf));
- /* Use default data room size. */
- if (0 == roomsz)
- roomsz = 2048 + RTE_PKTMBUF_HEADROOM;
+ /* if no structure is provided, assume no mbuf private area */
+ user_mbp_priv = opaque_arg;
+ if (user_mbp_priv == NULL) {
+ default_mbp_priv.mbuf_priv_size = 0;
+ if (mp->elt_size > sizeof(struct rte_mbuf))
+ roomsz = mp->elt_size - sizeof(struct rte_mbuf);
+ else
+ roomsz = 0;
+ default_mbp_priv.mbuf_data_room_size = roomsz;
+ user_mbp_priv = &default_mbp_priv;
+ }
- mbp_priv->mbuf_data_room_size = roomsz;
+ RTE_MBUF_ASSERT(mp->elt_size >= sizeof(struct rte_mbuf) +
+ user_mbp_priv->mbuf_data_room_size +
+ user_mbp_priv->mbuf_priv_size);
+
+ mbp_priv = rte_mempool_get_priv(mp);
+ memcpy(mbp_priv, user_mbp_priv, sizeof(*mbp_priv));
}
/*
* appended after the mempool structure (in private data).
*/
struct rte_pktmbuf_pool_private {
- uint16_t mbuf_data_room_size; /**< Size of data space in each mbuf.*/
+ uint16_t mbuf_data_room_size; /**< Size of data space in each mbuf. */
+ uint16_t mbuf_priv_size; /**< Size of private area in each mbuf. */
};
#ifdef RTE_LIBRTE_MBUF_DEBUG