From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: Matan Azrad <matan@mellanox.com>, Shahaf Shuler <shahafs@mellanox.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] net/mlx4: add support for multicast address list interface
Date: Thu, 18 Apr 2019 15:10:34 +0200 [thread overview]
Message-ID: <20190418130245.25618-1-adrien.mazarguil@6wind.com> (raw)
Message-ID: <20190418131034.BRUbc9JsB0gK6KhGbI2Btk8hqgZRmySKpkWqBihojII@z> (raw)
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 <adrien.mazarguil@6wind.com>
---
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
next reply other threads:[~2019-04-18 13:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-18 13:10 Adrien Mazarguil [this message]
2019-04-18 13:10 ` Adrien Mazarguil
2019-04-29 8:54 ` Shahaf Shuler
2019-04-29 8:54 ` Shahaf Shuler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190418130245.25618-1-adrien.mazarguil@6wind.com \
--to=adrien.mazarguil@6wind.com \
--cc=dev@dpdk.org \
--cc=matan@mellanox.com \
--cc=shahafs@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).