dpdk: fix rte mempool for rx_queues 40/31540/2
authorVladimir Ratnikov <vratnikov@netgate.com>
Fri, 5 Mar 2021 09:22:59 +0000 (04:22 -0500)
committerDamjan Marion <dmarion@me.com>
Fri, 5 Mar 2021 10:50:24 +0000 (10:50 +0000)
Change dpdk_ops_vpp_get_count() return value from 0
 to actual available pool size;
For some drivers/envs(azure,vmbus) rx_queue size
 will be zero and the only 1 element will be created
(0 + 1)
When more than one packet will arrive, it will cause
SEGFAULT

Type: fix
Signed-off-by: Vladimir Ratnikov <vratnikov@netgate.com>
Change-Id: Ibe7da6acc91200bec33d99f580044456d8984110

src/plugins/dpdk/buffer.c

index 575660b..9718451 100644 (file)
@@ -414,7 +414,15 @@ dpdk_ops_vpp_dequeue_no_cache (struct rte_mempool *mp, void **obj_table,
 static unsigned
 dpdk_ops_vpp_get_count (const struct rte_mempool *mp)
 {
-  clib_warning ("");
+  vlib_main_t *vm = vlib_get_main ();
+  if (mp)
+    {
+      vlib_buffer_pool_t *pool = vlib_get_buffer_pool (vm, mp->pool_id);
+      if (pool)
+       {
+         return pool->n_avail;
+       }
+    }
   return 0;
 }