From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id D31831B9CC for ; Thu, 18 Apr 2019 15:10:36 +0200 (CEST) Received: by mail-wr1-f68.google.com with SMTP id k17so2890882wrx.10 for ; Thu, 18 Apr 2019 06:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=pcEVvMvBb5zcnJJz7LLo4jKSbiq7IS/W1ET7TwiBSe8=; b=alvt4T2LxbwwnxNLYigC9N5r19nmPxDX5O4DuXDIoIZiLkPYI1GYWg5N874j4Wm77H akGPCHxJlU3UoHw+z6DxDEUHDoLLl1eutHAs6iOtVLJEv9Shuif44uqm9/XwykSzStgD OpK/x3wPd9wVHO3LkJZ6woRcSadptT8X58J7dKDt4hiQTABzez0ckEP7GkyU8x/9omp3 CHJ7hcYD4B2qjoHlJSziXYmesNlLqOWq6rwaZ0hNvdaUJKXYRBk1QksVdgmqRHdiWuto mcyYwwc/1qh4Cp24lncXZbbUOk9qNUHEYK5HEQp1rLX1/H6JO9OHFf2LzGhXjQh+t2fL ij+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=pcEVvMvBb5zcnJJz7LLo4jKSbiq7IS/W1ET7TwiBSe8=; b=ZtPPXiUrZ5Pv50VmydyenANFIIg6z+YwFQ9xgmFcpilfoQpSxx60NagHguCDVEjA/e LLxpVNzF4nA/mps0+KxuFSBeGkeaXVlkRpvglSsXOC+NG84Jhuk7BkbQd2Yj6WWRwk70 d140hzDRZVFOyKN0JJz6ujOzGnD0hInjGrj5sx2jC5JyYxsE5vRQOMLY2nR976rDRTra NXXMckJAm55AT9TdaELiLZ/CilY6qMS+szJ6lugutDBP4Nw7x1Ir//9y0AKRnDrbU0mw W4XhgAyJ+hrtlCb82SXvU0GYBUH3VK/lEwQQJC31V9PjAd5onmTrRZ4q6PR7oWoWMS2X wgkg== X-Gm-Message-State: APjAAAXF3HzUPE76upVj4WWCWQDh6nNGRVgsgx8gbJMgN8w3NFyVNu/9 KRL1faaCIqsI8c8RWxWgu9UnyQ== X-Google-Smtp-Source: APXvYqw/dbs0rZwGOJF/okQXX/O/1NWBe8ozl3UyT82pFpoebjb1Tgy5mfmf4LjUAaG4on32wmXF2A== X-Received: by 2002:a5d:4a4f:: with SMTP id v15mr2814536wrs.5.1555593036528; Thu, 18 Apr 2019 06:10:36 -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 j7sm2588175wrt.96.2019.04.18.06.10.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 06:10:35 -0700 (PDT) Date: Thu, 18 Apr 2019 15:10:34 +0200 From: Adrien Mazarguil To: Matan Azrad , Shahaf Shuler Cc: dev@dpdk.org Message-ID: <20190418130245.25618-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] net/mlx4: add support for multicast address list interface 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: , X-List-Received-Date: Thu, 18 Apr 2019 13:10:37 -0000 Since this driver does not distinguish unicast/multicast addresses, applications could always rely on the standard MAC add/remove/set interface to configure both types. As a result, the multicast address list interface never got implemented (rte_eth_dev_set_mc_addr_list()) however PMD-agnostic applications still rely on it for compatibility reasons; a wrapper is therefore required. Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 1 + drivers/net/mlx4/mlx4.h | 3 ++ drivers/net/mlx4/mlx4_ethdev.c | 61 +++++++++++++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 17dfcd5a3..fe559c040 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -410,6 +410,7 @@ static const struct eth_dev_ops mlx4_dev_ops = { .mac_addr_remove = mlx4_mac_addr_remove, .mac_addr_add = mlx4_mac_addr_add, .mac_addr_set = mlx4_mac_addr_set, + .set_mc_addr_list = mlx4_set_mc_addr_list, .stats_get = mlx4_stats_get, .stats_reset = mlx4_stats_reset, .fw_version_get = mlx4_fw_version_get, diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 6224b3be1..e2d184f84 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -188,6 +188,7 @@ struct mlx4_priv { LIST_HEAD(, rte_flow) flows; /**< Configured flow rule handles. */ struct ether_addr mac[MLX4_MAX_MAC_ADDRESSES]; /**< Configured MAC addresses. Unused entries are zeroed. */ + uint32_t mac_mc; /**< Number of trailing multicast entries in mac[]. */ struct mlx4_verbs_alloc_ctx verbs_alloc_ctx; /**< Context for Verbs allocator. */ }; @@ -211,6 +212,8 @@ void mlx4_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); int mlx4_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr, uint32_t index, uint32_t vmdq); int mlx4_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr); +int mlx4_set_mc_addr_list(struct rte_eth_dev *dev, struct ether_addr *list, + uint32_t num); int mlx4_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on); int mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); void mlx4_stats_reset(struct rte_eth_dev *dev); diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index 4dae67a1b..c38455767 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -433,7 +433,7 @@ mlx4_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) struct mlx4_priv *priv = dev->data->dev_private; struct rte_flow_error error; - if (index >= RTE_DIM(priv->mac)) { + if (index >= RTE_DIM(priv->mac) - priv->mac_mc) { rte_errno = EINVAL; return; } @@ -471,7 +471,7 @@ mlx4_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr, int ret; (void)vmdq; - if (index >= RTE_DIM(priv->mac)) { + if (index >= RTE_DIM(priv->mac) - priv->mac_mc) { rte_errno = EINVAL; return -rte_errno; } @@ -488,6 +488,63 @@ mlx4_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr, } /** + * DPDK callback to configure multicast addresses. + * + * @param dev + * Pointer to Ethernet device structure. + * @param list + * List of MAC addresses to register. + * @param num + * Number of entries in list. + * + * @return + * 0 on success, negative errno value otherwise and rte_errno is set. + */ +int +mlx4_set_mc_addr_list(struct rte_eth_dev *dev, struct ether_addr *list, + uint32_t num) +{ + struct priv *priv = dev->data->dev_private; + struct rte_flow_error error; + int ret; + + if (num > RTE_DIM(priv->mac)) { + rte_errno = EINVAL; + return -rte_errno; + } + /* + * Make sure there is enough room to increase the number of + * multicast entries without overwriting standard entries. + */ + if (num > priv->mac_mc) { + unsigned int i; + + for (i = RTE_DIM(priv->mac) - num; + i != RTE_DIM(priv->mac) - priv->mac_mc; + ++i) + if (!is_zero_ether_addr(&priv->mac[i])) { + rte_errno = EBUSY; + return -rte_errno; + } + } else if (num < priv->mac_mc) { + /* Clear unused entries. */ + memset(priv->mac + RTE_DIM(priv->mac) - priv->mac_mc, + 0, + sizeof(priv->mac[0]) * (priv->mac_mc - num)); + } + memcpy(priv->mac + RTE_DIM(priv->mac) - num, list, sizeof(*list) * num); + priv->mac_mc = num; + ret = mlx4_flow_sync(priv, &error); + if (!ret) + return 0; + ERROR("failed to synchronize flow rules after modifying MC list," + " (code %d, \"%s\"), flow error type %d, cause %p, message: %s", + rte_errno, strerror(rte_errno), error.type, error.cause, + error.message ? error.message : "(unspecified)"); + return ret; +} + +/** * DPDK callback to configure a VLAN filter. * * @param dev -- 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 81281A00E6 for ; Thu, 18 Apr 2019 15:10:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 524421B9E7; Thu, 18 Apr 2019 15:10:38 +0200 (CEST) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id D31831B9CC for ; Thu, 18 Apr 2019 15:10:36 +0200 (CEST) Received: by mail-wr1-f68.google.com with SMTP id k17so2890882wrx.10 for ; Thu, 18 Apr 2019 06:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=pcEVvMvBb5zcnJJz7LLo4jKSbiq7IS/W1ET7TwiBSe8=; b=alvt4T2LxbwwnxNLYigC9N5r19nmPxDX5O4DuXDIoIZiLkPYI1GYWg5N874j4Wm77H akGPCHxJlU3UoHw+z6DxDEUHDoLLl1eutHAs6iOtVLJEv9Shuif44uqm9/XwykSzStgD OpK/x3wPd9wVHO3LkJZ6woRcSadptT8X58J7dKDt4hiQTABzez0ckEP7GkyU8x/9omp3 CHJ7hcYD4B2qjoHlJSziXYmesNlLqOWq6rwaZ0hNvdaUJKXYRBk1QksVdgmqRHdiWuto mcyYwwc/1qh4Cp24lncXZbbUOk9qNUHEYK5HEQp1rLX1/H6JO9OHFf2LzGhXjQh+t2fL ij+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=pcEVvMvBb5zcnJJz7LLo4jKSbiq7IS/W1ET7TwiBSe8=; b=ZtPPXiUrZ5Pv50VmydyenANFIIg6z+YwFQ9xgmFcpilfoQpSxx60NagHguCDVEjA/e LLxpVNzF4nA/mps0+KxuFSBeGkeaXVlkRpvglSsXOC+NG84Jhuk7BkbQd2Yj6WWRwk70 d140hzDRZVFOyKN0JJz6ujOzGnD0hInjGrj5sx2jC5JyYxsE5vRQOMLY2nR976rDRTra NXXMckJAm55AT9TdaELiLZ/CilY6qMS+szJ6lugutDBP4Nw7x1Ir//9y0AKRnDrbU0mw W4XhgAyJ+hrtlCb82SXvU0GYBUH3VK/lEwQQJC31V9PjAd5onmTrRZ4q6PR7oWoWMS2X wgkg== X-Gm-Message-State: APjAAAXF3HzUPE76upVj4WWCWQDh6nNGRVgsgx8gbJMgN8w3NFyVNu/9 KRL1faaCIqsI8c8RWxWgu9UnyQ== X-Google-Smtp-Source: APXvYqw/dbs0rZwGOJF/okQXX/O/1NWBe8ozl3UyT82pFpoebjb1Tgy5mfmf4LjUAaG4on32wmXF2A== X-Received: by 2002:a5d:4a4f:: with SMTP id v15mr2814536wrs.5.1555593036528; Thu, 18 Apr 2019 06:10:36 -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 j7sm2588175wrt.96.2019.04.18.06.10.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 06:10:35 -0700 (PDT) Date: Thu, 18 Apr 2019 15:10:34 +0200 From: Adrien Mazarguil To: Matan Azrad , Shahaf Shuler Cc: dev@dpdk.org Message-ID: <20190418130245.25618-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] net/mlx4: add support for multicast address list interface 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" Message-ID: <20190418131034.BRUbc9JsB0gK6KhGbI2Btk8hqgZRmySKpkWqBihojII@z> Since this driver does not distinguish unicast/multicast addresses, applications could always rely on the standard MAC add/remove/set interface to configure both types. As a result, the multicast address list interface never got implemented (rte_eth_dev_set_mc_addr_list()) however PMD-agnostic applications still rely on it for compatibility reasons; a wrapper is therefore required. Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 1 + drivers/net/mlx4/mlx4.h | 3 ++ drivers/net/mlx4/mlx4_ethdev.c | 61 +++++++++++++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 17dfcd5a3..fe559c040 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -410,6 +410,7 @@ static const struct eth_dev_ops mlx4_dev_ops = { .mac_addr_remove = mlx4_mac_addr_remove, .mac_addr_add = mlx4_mac_addr_add, .mac_addr_set = mlx4_mac_addr_set, + .set_mc_addr_list = mlx4_set_mc_addr_list, .stats_get = mlx4_stats_get, .stats_reset = mlx4_stats_reset, .fw_version_get = mlx4_fw_version_get, diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 6224b3be1..e2d184f84 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -188,6 +188,7 @@ struct mlx4_priv { LIST_HEAD(, rte_flow) flows; /**< Configured flow rule handles. */ struct ether_addr mac[MLX4_MAX_MAC_ADDRESSES]; /**< Configured MAC addresses. Unused entries are zeroed. */ + uint32_t mac_mc; /**< Number of trailing multicast entries in mac[]. */ struct mlx4_verbs_alloc_ctx verbs_alloc_ctx; /**< Context for Verbs allocator. */ }; @@ -211,6 +212,8 @@ void mlx4_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index); int mlx4_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr, uint32_t index, uint32_t vmdq); int mlx4_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr); +int mlx4_set_mc_addr_list(struct rte_eth_dev *dev, struct ether_addr *list, + uint32_t num); int mlx4_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on); int mlx4_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); void mlx4_stats_reset(struct rte_eth_dev *dev); diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index 4dae67a1b..c38455767 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -433,7 +433,7 @@ mlx4_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) struct mlx4_priv *priv = dev->data->dev_private; struct rte_flow_error error; - if (index >= RTE_DIM(priv->mac)) { + if (index >= RTE_DIM(priv->mac) - priv->mac_mc) { rte_errno = EINVAL; return; } @@ -471,7 +471,7 @@ mlx4_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr, int ret; (void)vmdq; - if (index >= RTE_DIM(priv->mac)) { + if (index >= RTE_DIM(priv->mac) - priv->mac_mc) { rte_errno = EINVAL; return -rte_errno; } @@ -488,6 +488,63 @@ mlx4_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr, } /** + * DPDK callback to configure multicast addresses. + * + * @param dev + * Pointer to Ethernet device structure. + * @param list + * List of MAC addresses to register. + * @param num + * Number of entries in list. + * + * @return + * 0 on success, negative errno value otherwise and rte_errno is set. + */ +int +mlx4_set_mc_addr_list(struct rte_eth_dev *dev, struct ether_addr *list, + uint32_t num) +{ + struct priv *priv = dev->data->dev_private; + struct rte_flow_error error; + int ret; + + if (num > RTE_DIM(priv->mac)) { + rte_errno = EINVAL; + return -rte_errno; + } + /* + * Make sure there is enough room to increase the number of + * multicast entries without overwriting standard entries. + */ + if (num > priv->mac_mc) { + unsigned int i; + + for (i = RTE_DIM(priv->mac) - num; + i != RTE_DIM(priv->mac) - priv->mac_mc; + ++i) + if (!is_zero_ether_addr(&priv->mac[i])) { + rte_errno = EBUSY; + return -rte_errno; + } + } else if (num < priv->mac_mc) { + /* Clear unused entries. */ + memset(priv->mac + RTE_DIM(priv->mac) - priv->mac_mc, + 0, + sizeof(priv->mac[0]) * (priv->mac_mc - num)); + } + memcpy(priv->mac + RTE_DIM(priv->mac) - num, list, sizeof(*list) * num); + priv->mac_mc = num; + ret = mlx4_flow_sync(priv, &error); + if (!ret) + return 0; + ERROR("failed to synchronize flow rules after modifying MC list," + " (code %d, \"%s\"), flow error type %d, cause %p, message: %s", + rte_errno, strerror(rte_errno), error.type, error.cause, + error.message ? error.message : "(unspecified)"); + return ret; +} + +/** * DPDK callback to configure a VLAN filter. * * @param dev -- 2.11.0