aboutsummaryrefslogtreecommitdiffstats
path: root/app/pdump/main.c
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@gmail.com>2018-08-14 18:55:37 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2018-08-14 18:57:39 +0100
commitae1479de3027a4a0f68d90bf65ac6ff2b862b837 (patch)
tree5dbca675b6717b6b61abbe1a9583d5166fed942b /app/pdump/main.c
parent8cee230dd1f0f9f31f4b0339c671d0b1ee14e111 (diff)
parentb63264c8342e6a1b6971c79550d2af2024b6a4de (diff)
Merge branch 'upstream' into 18.08.x
Change-Id: Ifbda2d554199dd4d11e01f0090881b5f0103ae12 Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Diffstat (limited to 'app/pdump/main.c')
-rw-r--r--app/pdump/main.c94
1 files changed, 70 insertions, 24 deletions
diff --git a/app/pdump/main.c b/app/pdump/main.c
index 6bcf8c49..ac228712 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -38,8 +38,9 @@
#define PDUMP_MSIZE_ARG "mbuf-size"
#define PDUMP_NUM_MBUFS_ARG "total-num-mbufs"
-#define VDEV_PCAP "net_pcap_%s_%d,tx_pcap=%s"
-#define VDEV_IFACE "net_pcap_%s_%d,tx_iface=%s"
+#define VDEV_NAME_FMT "net_pcap_%s_%d"
+#define VDEV_PCAP_ARGS_FMT "tx_pcap=%s"
+#define VDEV_IFACE_ARGS_FMT "tx_iface=%s"
#define TX_STREAM_SIZE 64
#define MP_NAME "pdump_pool_%d"
@@ -570,6 +571,7 @@ create_mp_ring_vdev(void)
uint16_t portid;
struct pdump_tuples *pt = NULL;
struct rte_mempool *mbuf_pool = NULL;
+ char vdev_name[SIZE];
char vdev_args[SIZE];
char ring_name[SIZE];
char mempool_name[SIZE];
@@ -619,17 +621,28 @@ create_mp_ring_vdev(void)
}
/* create vdevs */
+ snprintf(vdev_name, sizeof(vdev_name),
+ VDEV_NAME_FMT, RX_STR, i);
(pt->rx_vdev_stream_type == IFACE) ?
- snprintf(vdev_args, SIZE, VDEV_IFACE, RX_STR, i,
- pt->rx_dev) :
- snprintf(vdev_args, SIZE, VDEV_PCAP, RX_STR, i,
- pt->rx_dev);
- if (rte_eth_dev_attach(vdev_args, &portid) < 0) {
+ snprintf(vdev_args, sizeof(vdev_args),
+ VDEV_IFACE_ARGS_FMT, pt->rx_dev) :
+ snprintf(vdev_args, sizeof(vdev_args),
+ VDEV_PCAP_ARGS_FMT, pt->rx_dev);
+ if (rte_eal_hotplug_add("vdev", vdev_name,
+ vdev_args) < 0) {
cleanup_rings();
rte_exit(EXIT_FAILURE,
"vdev creation failed:%s:%d\n",
__func__, __LINE__);
}
+ if (rte_eth_dev_get_port_by_name(vdev_name,
+ &portid) != 0) {
+ rte_eal_hotplug_remove("vdev", vdev_name);
+ cleanup_rings();
+ rte_exit(EXIT_FAILURE,
+ "cannot find added vdev %s:%s:%d\n",
+ vdev_name, __func__, __LINE__);
+ }
pt->rx_vdev_id = portid;
/* configure vdev */
@@ -638,18 +651,29 @@ create_mp_ring_vdev(void)
if (pt->single_pdump_dev)
pt->tx_vdev_id = portid;
else {
- (pt->tx_vdev_stream_type == IFACE) ?
- snprintf(vdev_args, SIZE, VDEV_IFACE, TX_STR, i,
- pt->tx_dev) :
- snprintf(vdev_args, SIZE, VDEV_PCAP, TX_STR, i,
- pt->tx_dev);
- if (rte_eth_dev_attach(vdev_args,
- &portid) < 0) {
+ snprintf(vdev_name, sizeof(vdev_name),
+ VDEV_NAME_FMT, TX_STR, i);
+ (pt->rx_vdev_stream_type == IFACE) ?
+ snprintf(vdev_args, sizeof(vdev_args),
+ VDEV_IFACE_ARGS_FMT, pt->tx_dev) :
+ snprintf(vdev_args, sizeof(vdev_args),
+ VDEV_PCAP_ARGS_FMT, pt->tx_dev);
+ if (rte_eal_hotplug_add("vdev", vdev_name,
+ vdev_args) < 0) {
cleanup_rings();
rte_exit(EXIT_FAILURE,
"vdev creation failed:"
"%s:%d\n", __func__, __LINE__);
}
+ if (rte_eth_dev_get_port_by_name(vdev_name,
+ &portid) != 0) {
+ rte_eal_hotplug_remove("vdev",
+ vdev_name);
+ cleanup_rings();
+ rte_exit(EXIT_FAILURE,
+ "cannot find added vdev %s:%s:%d\n",
+ vdev_name, __func__, __LINE__);
+ }
pt->tx_vdev_id = portid;
/* configure vdev */
@@ -667,17 +691,28 @@ create_mp_ring_vdev(void)
rte_strerror(rte_errno));
}
+ snprintf(vdev_name, sizeof(vdev_name),
+ VDEV_NAME_FMT, RX_STR, i);
(pt->rx_vdev_stream_type == IFACE) ?
- snprintf(vdev_args, SIZE, VDEV_IFACE, RX_STR, i,
- pt->rx_dev) :
- snprintf(vdev_args, SIZE, VDEV_PCAP, RX_STR, i,
- pt->rx_dev);
- if (rte_eth_dev_attach(vdev_args, &portid) < 0) {
+ snprintf(vdev_args, sizeof(vdev_args),
+ VDEV_IFACE_ARGS_FMT, pt->rx_dev) :
+ snprintf(vdev_args, sizeof(vdev_args),
+ VDEV_PCAP_ARGS_FMT, pt->rx_dev);
+ if (rte_eal_hotplug_add("vdev", vdev_name,
+ vdev_args) < 0) {
cleanup_rings();
rte_exit(EXIT_FAILURE,
"vdev creation failed:%s:%d\n",
__func__, __LINE__);
}
+ if (rte_eth_dev_get_port_by_name(vdev_name,
+ &portid) != 0) {
+ rte_eal_hotplug_remove("vdev", vdev_name);
+ cleanup_rings();
+ rte_exit(EXIT_FAILURE,
+ "cannot find added vdev %s:%s:%d\n",
+ vdev_name, __func__, __LINE__);
+ }
pt->rx_vdev_id = portid;
/* configure vdev */
configure_vdev(pt->rx_vdev_id);
@@ -693,16 +728,27 @@ create_mp_ring_vdev(void)
rte_strerror(rte_errno));
}
+ snprintf(vdev_name, sizeof(vdev_name),
+ VDEV_NAME_FMT, TX_STR, i);
(pt->tx_vdev_stream_type == IFACE) ?
- snprintf(vdev_args, SIZE, VDEV_IFACE, TX_STR, i,
- pt->tx_dev) :
- snprintf(vdev_args, SIZE, VDEV_PCAP, TX_STR, i,
- pt->tx_dev);
- if (rte_eth_dev_attach(vdev_args, &portid) < 0) {
+ snprintf(vdev_args, sizeof(vdev_args),
+ VDEV_IFACE_ARGS_FMT, pt->tx_dev) :
+ snprintf(vdev_args, sizeof(vdev_args),
+ VDEV_PCAP_ARGS_FMT, pt->tx_dev);
+ if (rte_eal_hotplug_add("vdev", vdev_name,
+ vdev_args) < 0) {
cleanup_rings();
rte_exit(EXIT_FAILURE,
"vdev creation failed\n");
}
+ if (rte_eth_dev_get_port_by_name(vdev_name,
+ &portid) != 0) {
+ rte_eal_hotplug_remove("vdev", vdev_name);
+ cleanup_rings();
+ rte_exit(EXIT_FAILURE,
+ "cannot find added vdev %s:%s:%d\n",
+ vdev_name, __func__, __LINE__);
+ }
pt->tx_vdev_id = portid;
/* configure vdev */