[ovs-dev] [branch-2.6] netdev-dpdk: leverage the mempool offload support
Hemant Agrawal
hemant.agrawal at nxp.com
Mon Mar 20 11:38:44 UTC 2017
DPDK 16.07 introduced the support for mempool offload support.
rte_pktmbuf_pool_create is the recommended method for creating pktmbuf
pools. Buffer pools created with rte_mempool_create may not get offloaded
to the underlying offloaded mempools.
This patch, changes the rte_mempool_create to use helper wrapper
"rte_pktmbuf_pool_create" provided by dpdk, so that it can leverage
offloaded mempools.
Signed-off-by: Hemant Agrawal <hemant.agrawal at nxp.com>
---
lib/netdev-dpdk.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 9203de0..8d658ff 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -468,7 +468,6 @@ dpdk_mp_get(int socket_id, int mtu) OVS_REQUIRES(dpdk_mutex)
struct dpdk_mp *dmp = NULL;
char mp_name[RTE_MEMPOOL_NAMESIZE];
unsigned mp_size;
- struct rte_pktmbuf_pool_private mbp_priv;
LIST_FOR_EACH (dmp, list_node, &dpdk_mp_list) {
if (dmp->socket_id == socket_id && dmp->mtu == mtu) {
@@ -481,9 +480,6 @@ dpdk_mp_get(int socket_id, int mtu) OVS_REQUIRES(dpdk_mutex)
dmp->socket_id = socket_id;
dmp->mtu = mtu;
dmp->refcount = 1;
- mbp_priv.mbuf_data_room_size = MBUF_SIZE(mtu) - sizeof(struct dp_packet);
- mbp_priv.mbuf_priv_size = sizeof (struct dp_packet)
- - sizeof (struct rte_mbuf);
/* XXX: this is a really rough method of provisioning memory.
* It's impossible to determine what the exact memory requirements are when
* the number of ports and rxqs that utilize a particular mempool can change
@@ -500,13 +496,13 @@ dpdk_mp_get(int socket_id, int mtu) OVS_REQUIRES(dpdk_mutex)
dmp->mtu, dmp->socket_id, mp_size) < 0) {
goto fail;
}
-
- dmp->mp = rte_mempool_create(mp_name, mp_size, MBUF_SIZE(mtu),
- MP_CACHE_SZ,
- sizeof(struct rte_pktmbuf_pool_private),
- rte_pktmbuf_pool_init, &mbp_priv,
- ovs_rte_pktmbuf_init, NULL,
- socket_id, 0);
+ dmp->mp = rte_pktmbuf_pool_create(mp_name, mp_size,
+ MP_CACHE_SZ,
+ sizeof (struct dp_packet)
+ - sizeof (struct rte_mbuf),
+ MBUF_SIZE(mtu)
+ - sizeof(struct dp_packet),
+ socket_id);
} while (!dmp->mp && rte_errno == ENOMEM && (mp_size /= 2) >= MIN_NB_MBUF);
if (dmp->mp == NULL) {
@@ -514,6 +510,8 @@ dpdk_mp_get(int socket_id, int mtu) OVS_REQUIRES(dpdk_mutex)
} else {
VLOG_DBG("Allocated \"%s\" mempool with %u mbufs", mp_name, mp_size );
}
+ /* pktmbuf only prepare the rte_mbuf, prepare the ovs bufs */
+ rte_mempool_obj_iter(dmp->mp, ovs_rte_pktmbuf_init, NULL);
ovs_list_push_back(&dpdk_mp_list, &dmp->list_node);
return dmp;
--
1.9.1
More information about the dev
mailing list