From 91f0c71eb52d601d4e78bd20dbafed51f802e53e Mon Sep 17 00:00:00 2001 From: Intiyaz Basha Date: Wed, 11 Oct 2017 13:17:47 +0530 Subject: [PATCH] net/liquidio: support promiscuous mode Signed-off-by: Intiyaz Basha Signed-off-by: Shijith Thotton --- doc/guides/nics/features/liquidio.ini | 1 + doc/guides/nics/liquidio.rst | 8 +++++ drivers/net/liquidio/base/lio_hw_defs.h | 3 ++ drivers/net/liquidio/lio_ethdev.c | 47 +++++++++++++++++++++++++ drivers/net/liquidio/lio_struct.h | 1 + 5 files changed, 60 insertions(+) diff --git a/doc/guides/nics/features/liquidio.ini b/doc/guides/nics/features/liquidio.ini index d673d7a370..f628b764ba 100644 --- a/doc/guides/nics/features/liquidio.ini +++ b/doc/guides/nics/features/liquidio.ini @@ -10,6 +10,7 @@ Link status event = Y MTU update = Y Jumbo frame = Y Scattered Rx = Y +Promiscuous mode = Y Allmulticast mode = Y RSS hash = Y RSS key update = Y diff --git a/doc/guides/nics/liquidio.rst b/doc/guides/nics/liquidio.rst index f04cb16d20..4ccde0c3d2 100644 --- a/doc/guides/nics/liquidio.rst +++ b/doc/guides/nics/liquidio.rst @@ -195,6 +195,14 @@ This section provides instructions to configure SR-IOV with Linux OS. Done testpmd> +#. Enabling VF promiscuous mode + + One VF per PF can be marked as trusted for promiscuous mode. + + .. code-block:: console + + ip link set dev vf trust on + Limitations ----------- diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h index 8713519f1e..c7f97f2590 100644 --- a/drivers/net/liquidio/base/lio_hw_defs.h +++ b/drivers/net/liquidio/base/lio_hw_defs.h @@ -106,6 +106,8 @@ enum lio_card_type { #define LIO_FW_VERSION_LENGTH 32 +#define LIO_VF_TRUST_MIN_VERSION "1.7.1" + /** Tag types used by Octeon cores in its work. */ enum octeon_tag_type { OCTEON_ORDERED_TAG = 0, @@ -185,6 +187,7 @@ enum octeon_tag_type { /* Interface flags communicated between host driver and core app. */ enum lio_ifflags { + LIO_IFFLAG_PROMISC = 0x01, LIO_IFFLAG_ALLMULTI = 0x02, LIO_IFFLAG_UNICAST = 0x10 }; diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 5407e391b9..239f6afc6a 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -1048,6 +1048,48 @@ lio_change_dev_flag(struct rte_eth_dev *eth_dev) lio_dev_err(lio_dev, "Change dev flag command timed out\n"); } +static void +lio_dev_promiscuous_enable(struct rte_eth_dev *eth_dev) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + + if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) { + lio_dev_err(lio_dev, "Require firmware version >= %s\n", + LIO_VF_TRUST_MIN_VERSION); + return; + } + + if (!lio_dev->intf_open) { + lio_dev_err(lio_dev, "Port %d down, can't enable promiscuous\n", + lio_dev->port_id); + return; + } + + lio_dev->ifflags |= LIO_IFFLAG_PROMISC; + lio_change_dev_flag(eth_dev); +} + +static void +lio_dev_promiscuous_disable(struct rte_eth_dev *eth_dev) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + + if (strcmp(lio_dev->firmware_version, LIO_VF_TRUST_MIN_VERSION) < 0) { + lio_dev_err(lio_dev, "Require firmware version >= %s\n", + LIO_VF_TRUST_MIN_VERSION); + return; + } + + if (!lio_dev->intf_open) { + lio_dev_err(lio_dev, "Port %d down, can't disable promiscuous\n", + lio_dev->port_id); + return; + } + + lio_dev->ifflags &= ~LIO_IFFLAG_PROMISC; + lio_change_dev_flag(eth_dev); +} + static void lio_dev_allmulticast_enable(struct rte_eth_dev *eth_dev) { @@ -1748,6 +1790,9 @@ static int lio_dev_configure(struct rte_eth_dev *eth_dev) goto nic_config_fail; } + snprintf(lio_dev->firmware_version, LIO_FW_VERSION_LENGTH, "%s", + resp->cfg_info.lio_firmware_version); + lio_swap_8B_data((uint64_t *)(&resp->cfg_info), sizeof(struct octeon_if_cfg_info) >> 3); @@ -1851,6 +1896,8 @@ static const struct eth_dev_ops liovf_eth_dev_ops = { .dev_set_link_up = lio_dev_set_link_up, .dev_set_link_down = lio_dev_set_link_down, .dev_close = lio_dev_close, + .promiscuous_enable = lio_dev_promiscuous_enable, + .promiscuous_disable = lio_dev_promiscuous_disable, .allmulticast_enable = lio_dev_allmulticast_enable, .allmulticast_disable = lio_dev_allmulticast_disable, .link_update = lio_dev_link_update, diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h index d9cbf00031..635e47fbf5 100644 --- a/drivers/net/liquidio/lio_struct.h +++ b/drivers/net/liquidio/lio_struct.h @@ -685,5 +685,6 @@ struct lio_device { uint8_t port_configured; struct lio_rss_ctx rss_state; uint8_t port_id; + char firmware_version[LIO_FW_VERSION_LENGTH]; }; #endif /* _LIO_STRUCT_H_ */ -- 2.20.1