Prevent calling rte_eth_xstats_get not initialized dev 44/11144/2
authorSzymon Sliwa <szs@semihalf.com>
Wed, 14 Mar 2018 11:54:55 +0000 (11:54 +0000)
committerDamjan Marion <dmarion.lists@gmail.com>
Wed, 14 Mar 2018 14:45:34 +0000 (14:45 +0000)
DPDK API forbids calling rte_eth_xstats_get on a port
which has not been setup up yet.

Citing the DPDK docs (reformated):

"
The functions exported by the application Ethernet API to setup a device
designated by its port identifier must be invoked in the following order:

rte_eth_dev_configure()
rte_eth_tx_queue_setup()
rte_eth_rx_queue_setup()
rte_eth_dev_start()
Then, the network application can invoke, in any order, the functions
exported by the Ethernet API to get the MAC address of a given device,
to get the speed and the status of a device physical link, to
receive/transmit [burst of] packets, and so on.
"

original can be found here:
http://dpdk.org/doc/api/rte__ethdev_8h.html#a36ba70a5a6fce2c2c1f774828ba78f8d

Change-Id: I91854b8b0dd12dd028b4b36665cca49f16eac24c
Signed-off-by: Szymon Sliwa <szs@semihalf.com>
src/plugins/dpdk/device/dpdk_priv.h

index a95d03c..7c4091c 100644 (file)
@@ -62,6 +62,8 @@ typedef struct
 static inline void
 dpdk_get_xstats (dpdk_device_t * xd)
 {
+  if (!(xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP))
+    return;
   int len;
   if ((len = rte_eth_xstats_get (xd->device_index, NULL, 0)) > 0)
     {