[dpdk-dev] [PATCH v1 11/48] net/mlx4: remove VLAN filter support
Adrien Mazarguil
adrien.mazarguil at 6wind.com
Tue Aug 1 18:53:58 CEST 2017
This is done in preparation for a major refactoring.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil at 6wind.com>
---
doc/guides/nics/features/mlx4.ini | 1 -
doc/guides/nics/mlx4.rst | 1 -
drivers/net/mlx4/mlx4.c | 206 +++------------------------------
drivers/net/mlx4/mlx4.h | 13 +--
4 files changed, 17 insertions(+), 204 deletions(-)
diff --git a/doc/guides/nics/features/mlx4.ini b/doc/guides/nics/features/mlx4.ini
index 344731f..bfa6948 100644
--- a/doc/guides/nics/features/mlx4.ini
+++ b/doc/guides/nics/features/mlx4.ini
@@ -17,7 +17,6 @@ Unicast MAC filter = Y
Multicast MAC filter = Y
RSS hash = Y
SR-IOV = Y
-VLAN filter = Y
L3 checksum offload = Y
L4 checksum offload = Y
Inner L3 checksum = Y
diff --git a/doc/guides/nics/mlx4.rst b/doc/guides/nics/mlx4.rst
index 9559261..9ab8da9 100644
--- a/doc/guides/nics/mlx4.rst
+++ b/doc/guides/nics/mlx4.rst
@@ -80,7 +80,6 @@ Features
- Multi arch support: x86_64 and POWER8.
- RSS, also known as RCA, is supported. In this mode the number of
configured RX queues must be a power of two.
-- VLAN filtering is supported.
- Link state information is provided.
- Multiple MAC addresses (unicast, multicast) can be configured.
- Scattered packets are supported for TX and RX.
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index fe1da04..288fd9b 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -47,7 +47,6 @@
#include <unistd.h>
#include <limits.h>
#include <assert.h>
-#include <arpa/inet.h>
#include <net/if.h>
#include <dirent.h>
#include <sys/ioctl.h>
@@ -2073,11 +2072,9 @@ rxq_free_elts(struct rxq *rxq)
* Pointer to RX queue structure.
* @param mac_index
* MAC address index.
- * @param vlan_index
- * VLAN index.
*/
static void
-rxq_del_flow(struct rxq *rxq, unsigned int mac_index, unsigned int vlan_index)
+rxq_del_flow(struct rxq *rxq, unsigned int mac_index)
{
#ifndef NDEBUG
struct priv *priv = rxq->priv;
@@ -2085,14 +2082,13 @@ rxq_del_flow(struct rxq *rxq, unsigned int mac_index, unsigned int vlan_index)
(const uint8_t (*)[ETHER_ADDR_LEN])
priv->mac[mac_index].addr_bytes;
#endif
- assert(rxq->mac_flow[mac_index][vlan_index] != NULL);
- DEBUG("%p: removing MAC address %02x:%02x:%02x:%02x:%02x:%02x index %u"
- " (VLAN ID %" PRIu16 ")",
+ assert(rxq->mac_flow[mac_index] != NULL);
+ DEBUG("%p: removing MAC address %02x:%02x:%02x:%02x:%02x:%02x index %u",
(void *)rxq,
(*mac)[0], (*mac)[1], (*mac)[2], (*mac)[3], (*mac)[4], (*mac)[5],
- mac_index, priv->vlan_filter[vlan_index].id);
- claim_zero(ibv_destroy_flow(rxq->mac_flow[mac_index][vlan_index]));
- rxq->mac_flow[mac_index][vlan_index] = NULL;
+ mac_index);
+ claim_zero(ibv_destroy_flow(rxq->mac_flow[mac_index]));
+ rxq->mac_flow[mac_index] = NULL;
}
/**
@@ -2106,22 +2102,10 @@ rxq_del_flow(struct rxq *rxq, unsigned int mac_index, unsigned int vlan_index)
static void
rxq_mac_addr_del(struct rxq *rxq, unsigned int mac_index)
{
- struct priv *priv = rxq->priv;
- unsigned int i;
- unsigned int vlans = 0;
-
- assert(mac_index < elemof(priv->mac));
+ assert(mac_index < elemof(rxq->priv->mac));
if (!BITFIELD_ISSET(rxq->mac_configured, mac_index))
return;
- for (i = 0; (i != elemof(priv->vlan_filter)); ++i) {
- if (!priv->vlan_filter[i].enabled)
- continue;
- rxq_del_flow(rxq, mac_index, i);
- vlans++;
- }
- if (!vlans) {
- rxq_del_flow(rxq, mac_index, 0);
- }
+ rxq_del_flow(rxq, mac_index);
BITFIELD_RESET(rxq->mac_configured, mac_index);
}
@@ -2148,14 +2132,12 @@ rxq_mac_addrs_del(struct rxq *rxq)
* Pointer to RX queue structure.
* @param mac_index
* MAC address index to register.
- * @param vlan_index
- * VLAN index. Use -1 for a flow without VLAN.
*
* @return
* 0 on success, errno value on failure.
*/
static int
-rxq_add_flow(struct rxq *rxq, unsigned int mac_index, unsigned int vlan_index)
+rxq_add_flow(struct rxq *rxq, unsigned int mac_index)
{
struct ibv_flow *flow;
struct priv *priv = rxq->priv;
@@ -2172,7 +2154,6 @@ rxq_add_flow(struct rxq *rxq, unsigned int mac_index, unsigned int vlan_index)
struct ibv_flow_spec_eth *spec = &data.spec;
assert(mac_index < elemof(priv->mac));
- assert((vlan_index < elemof(priv->vlan_filter)) || (vlan_index == -1u));
/*
* No padding must be inserted by the compiler between attr and spec.
* This layout is expected by libibverbs.
@@ -2193,22 +2174,15 @@ rxq_add_flow(struct rxq *rxq, unsigned int mac_index, unsigned int vlan_index)
(*mac)[0], (*mac)[1], (*mac)[2],
(*mac)[3], (*mac)[4], (*mac)[5]
},
- .vlan_tag = ((vlan_index != -1u) ?
- htons(priv->vlan_filter[vlan_index].id) :
- 0),
},
.mask = {
.dst_mac = "\xff\xff\xff\xff\xff\xff",
- .vlan_tag = ((vlan_index != -1u) ? htons(0xfff) : 0),
}
};
- DEBUG("%p: adding MAC address %02x:%02x:%02x:%02x:%02x:%02x index %u"
- " (VLAN %s %" PRIu16 ")",
+ DEBUG("%p: adding MAC address %02x:%02x:%02x:%02x:%02x:%02x index %u",
(void *)rxq,
(*mac)[0], (*mac)[1], (*mac)[2], (*mac)[3], (*mac)[4], (*mac)[5],
- mac_index,
- ((vlan_index != -1u) ? "ID" : "index"),
- ((vlan_index != -1u) ? priv->vlan_filter[vlan_index].id : -1u));
+ mac_index);
/* Create related flow. */
errno = 0;
flow = ibv_create_flow(rxq->qp, attr);
@@ -2221,10 +2195,8 @@ rxq_add_flow(struct rxq *rxq, unsigned int mac_index, unsigned int vlan_index)
return errno;
return EINVAL;
}
- if (vlan_index == -1u)
- vlan_index = 0;
- assert(rxq->mac_flow[mac_index][vlan_index] == NULL);
- rxq->mac_flow[mac_index][vlan_index] = flow;
+ assert(rxq->mac_flow[mac_index] == NULL);
+ rxq->mac_flow[mac_index] = flow;
return 0;
}
@@ -2242,37 +2214,14 @@ rxq_add_flow(struct rxq *rxq, unsigned int mac_index, unsigned int vlan_index)
static int
rxq_mac_addr_add(struct rxq *rxq, unsigned int mac_index)
{
- struct priv *priv = rxq->priv;
- unsigned int i;
- unsigned int vlans = 0;
int ret;
- assert(mac_index < elemof(priv->mac));
+ assert(mac_index < elemof(rxq->priv->mac));
if (BITFIELD_ISSET(rxq->mac_configured, mac_index))
rxq_mac_addr_del(rxq, mac_index);
- /* Fill VLAN specifications. */
- for (i = 0; (i != elemof(priv->vlan_filter)); ++i) {
- if (!priv->vlan_filter[i].enabled)
- continue;
- /* Create related flow. */
- ret = rxq_add_flow(rxq, mac_index, i);
- if (!ret) {
- vlans++;
- continue;
- }
- /* Failure, rollback. */
- while (i != 0)
- if (priv->vlan_filter[--i].enabled)
- rxq_del_flow(rxq, mac_index, i);
- assert(ret > 0);
+ ret = rxq_add_flow(rxq, mac_index);
+ if (ret)
return ret;
- }
- /* In case there is no VLAN filter. */
- if (!vlans) {
- ret = rxq_add_flow(rxq, mac_index, -1);
- if (ret)
- return ret;
- }
BITFIELD_SET(rxq->mac_configured, mac_index);
return 0;
}
@@ -4474,128 +4423,6 @@ mlx4_dev_set_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
return -ret;
}
-/**
- * Configure a VLAN filter.
- *
- * @param dev
- * Pointer to Ethernet device structure.
- * @param vlan_id
- * VLAN ID to filter.
- * @param on
- * Toggle filter.
- *
- * @return
- * 0 on success, errno value on failure.
- */
-static int
-vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
-{
- struct priv *priv = dev->data->dev_private;
- unsigned int i;
- unsigned int j = -1;
-
- DEBUG("%p: %s VLAN filter ID %" PRIu16,
- (void *)dev, (on ? "enable" : "disable"), vlan_id);
- for (i = 0; (i != elemof(priv->vlan_filter)); ++i) {
- if (!priv->vlan_filter[i].enabled) {
- /* Unused index, remember it. */
- j = i;
- continue;
- }
- if (priv->vlan_filter[i].id != vlan_id)
- continue;
- /* This VLAN ID is already known, use its index. */
- j = i;
- break;
- }
- /* Check if there's room for another VLAN filter. */
- if (j == (unsigned int)-1)
- return ENOMEM;
- /*
- * VLAN filters apply to all configured MAC addresses, flow
- * specifications must be reconfigured accordingly.
- */
- priv->vlan_filter[j].id = vlan_id;
- if ((on) && (!priv->vlan_filter[j].enabled)) {
- /*
- * Filter is disabled, enable it.
- * Rehashing flows in all RX queues is necessary.
- */
- if (priv->rss)
- rxq_mac_addrs_del(LIST_FIRST(&priv->parents));
- else
- for (i = 0; (i != priv->rxqs_n); ++i)
- if ((*priv->rxqs)[i] != NULL)
- rxq_mac_addrs_del((*priv->rxqs)[i]);
- priv->vlan_filter[j].enabled = 1;
- if (priv->started) {
- if (priv->rss)
- rxq_mac_addrs_add(LIST_FIRST(&priv->parents));
- else
- for (i = 0; (i != priv->rxqs_n); ++i) {
- if ((*priv->rxqs)[i] == NULL)
- continue;
- rxq_mac_addrs_add((*priv->rxqs)[i]);
- }
- }
- } else if ((!on) && (priv->vlan_filter[j].enabled)) {
- /*
- * Filter is enabled, disable it.
- * Rehashing flows in all RX queues is necessary.
- */
- if (priv->rss)
- rxq_mac_addrs_del(LIST_FIRST(&priv->parents));
- else
- for (i = 0; (i != priv->rxqs_n); ++i)
- if ((*priv->rxqs)[i] != NULL)
- rxq_mac_addrs_del((*priv->rxqs)[i]);
- priv->vlan_filter[j].enabled = 0;
- if (priv->started) {
- if (priv->rss)
- rxq_mac_addrs_add(LIST_FIRST(&priv->parents));
- else
- for (i = 0; (i != priv->rxqs_n); ++i) {
- if ((*priv->rxqs)[i] == NULL)
- continue;
- rxq_mac_addrs_add((*priv->rxqs)[i]);
- }
- }
- }
- return 0;
-}
-
-/**
- * DPDK callback to configure a VLAN filter.
- *
- * @param dev
- * Pointer to Ethernet device structure.
- * @param vlan_id
- * VLAN ID to filter.
- * @param on
- * Toggle filter.
- *
- * @return
- * 0 on success, negative errno value on failure.
- */
-static int
-mlx4_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
-{
- struct priv *priv = dev->data->dev_private;
- int ret;
-
- priv_lock(priv);
- if (priv->isolated) {
- DEBUG("%p: cannot set vlan filter, "
- "device is in isolated mode", (void *)dev);
- priv_unlock(priv);
- return -EINVAL;
- }
- ret = vlan_filter_set(dev, vlan_id, on);
- priv_unlock(priv);
- assert(ret >= 0);
- return -ret;
-}
-
const struct rte_flow_ops mlx4_flow_ops = {
.validate = mlx4_flow_validate,
.create = mlx4_flow_create,
@@ -4654,7 +4481,6 @@ static const struct eth_dev_ops mlx4_dev_ops = {
.stats_reset = mlx4_stats_reset,
.dev_infos_get = mlx4_dev_infos_get,
.dev_supported_ptypes_get = mlx4_dev_supported_ptypes_get,
- .vlan_filter_set = mlx4_vlan_filter_set,
.rx_queue_setup = mlx4_rx_queue_setup,
.tx_queue_setup = mlx4_tx_queue_setup,
.rx_queue_release = mlx4_rx_queue_release,
diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h
index 35c9549..6b2c83b 100644
--- a/drivers/net/mlx4/mlx4.h
+++ b/drivers/net/mlx4/mlx4.h
@@ -74,9 +74,6 @@
*/
#define MLX4_MAX_MAC_ADDRESSES 128
-/* Maximum number of simultaneous VLAN filters supported. See above. */
-#define MLX4_MAX_VLAN_IDS 127
-
/* Request send completion once in every 64 sends, might be less. */
#define MLX4_PMD_TX_PER_COMP_REQ 64
@@ -199,11 +196,8 @@ struct rxq {
struct ibv_exp_qp_burst_family *if_qp; /* QP burst interface. */
struct ibv_exp_cq_family *if_cq; /* CQ interface. */
struct ibv_comp_channel *channel;
- /*
- * Each VLAN ID requires a separate flow steering rule.
- */
BITFIELD_DECLARE(mac_configured, uint32_t, MLX4_MAX_MAC_ADDRESSES);
- struct ibv_flow *mac_flow[MLX4_MAX_MAC_ADDRESSES][MLX4_MAX_VLAN_IDS];
+ struct ibv_flow *mac_flow[MLX4_MAX_MAC_ADDRESSES];
unsigned int port_id; /* Port ID for incoming packets. */
unsigned int elts_n; /* (*elts)[] length. */
unsigned int elts_head; /* Current index in (*elts)[]. */
@@ -286,11 +280,6 @@ struct priv {
*/
struct ether_addr mac[MLX4_MAX_MAC_ADDRESSES];
BITFIELD_DECLARE(mac_configured, uint32_t, MLX4_MAX_MAC_ADDRESSES);
- /* VLAN filters. */
- struct {
- unsigned int enabled:1; /* If enabled. */
- unsigned int id:12; /* VLAN ID (0-4095). */
- } vlan_filter[MLX4_MAX_VLAN_IDS]; /* VLAN filters table. */
/* Device properties. */
uint16_t mtu; /* Configured MTU. */
uint8_t port; /* Physical port number. */
--
2.1.4
More information about the dev
mailing list