From patchwork Tue Aug 1 16:53:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrien Mazarguil X-Patchwork-Id: 27323 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 37958A104; Tue, 1 Aug 2017 18:55:22 +0200 (CEST) Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by dpdk.org (Postfix) with ESMTP id E1122A0B6 for ; Tue, 1 Aug 2017 18:55:05 +0200 (CEST) Received: by mail-wr0-f177.google.com with SMTP id v105so9273892wrb.0 for ; Tue, 01 Aug 2017 09:55:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=VtnuCq2qPSbwFLjpLMCUYQ3tNMLSOBkK0BKctQk8HwA=; b=DCMEAjW9usv1b7UXlLKQ6SL0AXYAbvKgsnyIvYdKsTvTnWGDxZxozXtAt7IKY7la+h Ezf3B195ZYFW4J9zAVi3J8S8YlTsw24r8aetxwMYM54z6sTtMUhkvWmZmvZQmq8+xigM rjNKXppGe/d9wXQRS5SaLdypZV+GLSsVwBEFyL3CS1+1lp6chrngZgxPxG8f4rNytvoL SccW2Wf6iGgztjbS4Is6XfEK+PhqjY6shZN8cGNdMHWkittU6yGOtWHOADNoHwAAemCW JeMjoPHA4yjW7e4tn12+TzL79mvVPa9hxangT1aYCr3BTMpejJ1iqwUeYN8GGYz64eH0 bwRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=VtnuCq2qPSbwFLjpLMCUYQ3tNMLSOBkK0BKctQk8HwA=; b=aDXWoJ6mxVlGdhwI1NeYA+LngqYJ0TLh+7K1n6gI3cEAiHeqTWeVaP80S4gThTBcwO LIe6ch2/yp6Flah8Ep98UrRDWjr0HrWVEcY97DkkO1GEa1/mwM45M+ghGq75eSufZo0q uoapBqiVo5b35QO5BO4yg8Uti6cxEqHREWkU0+2l/OYofqz+njxBQxM1C6S0aJDIcWP3 YAcw3jA1zU1C3YWsFSdo+DOzfBrXo4YJ4nff77sJqLm1qBUmgz52Ch8eeayssTARny/V qKy16T5w8T+TUAYjXGunnDYguBDDIBThVc9uA7RnhIzHaUr4d6QaVzE7wJjUE9CvCjdf cQag== X-Gm-Message-State: AIVw112Qj7mXwoO+9yZtY+7po7LisJqRcm60tTt3XewhRkgSj7S97lnc 2j+yI2QLaYsTjihXsns= X-Received: by 10.223.164.157 with SMTP id g29mr17957286wrb.105.1501606505189; Tue, 01 Aug 2017 09:55:05 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id b141sm1778908wma.39.2017.08.01.09.55.03 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 01 Aug 2017 09:55:04 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Tue, 1 Aug 2017 18:53:58 +0200 Message-Id: <283443c8420e95132105cc66e99566896edae6d8.1501598384.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v1 11/48] net/mlx4: remove VLAN filter support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This is done in preparation for a major refactoring. Signed-off-by: Adrien Mazarguil --- 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 #include #include -#include #include #include #include @@ -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. */