diff options
author | Petri Savolainen <petri.savolainen@nokia.com> | 2019-11-29 14:51:26 +0200 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2019-12-20 10:17:34 +0200 |
commit | c1b0347116dd0992634cc79d82831636e9ef6a4b (patch) | |
tree | 0732ab6e4f91d400fc928033fe499a68a81a728e /platform/linux-generic/pktio/dpdk.c | |
parent | 427d0bcf792637cb31828c5a84fcbd3202213350 (diff) |
linux-gen: dpdk: improve check of promisc mode support
Make check failed when using PCAP PMD device with DPDK
v19.11, as rte_eth_promiscuous_enable() is supported,
but rte_eth_promiscuous_disable() is not. Check both
return values to determine if promiscuous mode change is
supported.
Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'platform/linux-generic/pktio/dpdk.c')
-rw-r--r-- | platform/linux-generic/pktio/dpdk.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index ae596b6a0..f6c63df92 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -1525,6 +1525,33 @@ static void dpdk_init_capability(pktio_entry_t *pktio_entry, capa->config.pktout.bit.tcp_chksum; } +/* Some DPDK PMD virtual devices, like PCAP, do not support promisc + * mode change. Use system call for them. */ +static void promisc_mode_check(pkt_dpdk_t *pkt_dpdk) +{ +#if RTE_VERSION < RTE_VERSION_NUM(19, 11, 0, 0) + /* Enable and disable calls do not have return value */ + rte_eth_promiscuous_enable(pkt_dpdk->port_id); + + if (!rte_eth_promiscuous_get(pkt_dpdk->port_id)) + pkt_dpdk->vdev_sysc_promisc = 1; + + rte_eth_promiscuous_disable(pkt_dpdk->port_id); +#else + int ret; + + ret = rte_eth_promiscuous_enable(pkt_dpdk->port_id); + + if (!rte_eth_promiscuous_get(pkt_dpdk->port_id)) + pkt_dpdk->vdev_sysc_promisc = 1; + + ret += rte_eth_promiscuous_disable(pkt_dpdk->port_id); + + if (ret) + pkt_dpdk->vdev_sysc_promisc = 1; +#endif +} + static int dpdk_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, const char *netdev, @@ -1589,12 +1616,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, } pkt_dpdk->mtu = mtu + _ODP_ETHHDR_LEN; - /* Some DPDK PMD virtual devices, like PCAP, do not support promisc - * mode change. Use system call for them. */ - rte_eth_promiscuous_enable(pkt_dpdk->port_id); - if (!rte_eth_promiscuous_get(pkt_dpdk->port_id)) - pkt_dpdk->vdev_sysc_promisc = 1; - rte_eth_promiscuous_disable(pkt_dpdk->port_id); + promisc_mode_check(pkt_dpdk); /* Drivers requiring minimum burst size. Supports also *_vf versions * of the drivers. */ |