[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1360172255.28557.42.camel@edumazet-glaptop>
Date: Wed, 06 Feb 2013 09:37:35 -0800
From: Eric Dumazet <eric.dumazet@...il.com>
To: Amir Vadai <amirv@...lanox.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Yan Burman <yanb@...lanox.com>,
Or Gerlitz <ogerlitz@...lanox.com>, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v1 8/9] net/mlx4_en: Add unicast MAC filtering
On Wed, 2013-02-06 at 11:13 +0200, Amir Vadai wrote:
> From: Yan Burman <yanb@...lanox.com>
>
> Implement and advertise unicast MAC filtering, such that setting macvlan
> instance over mlx4_en interfaces will not require the networking core
> to put mlx4_en devices in promiscuous mode.
>
> Signed-off-by: Yan Burman <yanb@...lanox.com>
> Signed-off-by: Amir Vadai <amirv@...lanox.com>
> ---
> drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 102 ++++++++++++++++++++++++
> 1 files changed, 102 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> index 8eb24ee..5da293b 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> @@ -1016,6 +1016,102 @@ static void mlx4_en_do_multicast(struct mlx4_en_priv *priv,
> }
> }
>
> +static void mlx4_en_do_uc_filter(struct mlx4_en_priv *priv,
> + struct net_device *dev,
> + struct mlx4_en_dev *mdev)
> +{
> + struct netdev_hw_addr *ha;
> + struct mlx4_mac_entry *entry;
> + struct hlist_node *n, *tmp;
> + bool found;
> + u64 mac;
> + int err = 0;
> + struct hlist_head *bucket;
> + unsigned int i;
> +
> + /* Note that we do not need to protect our mac_hash traversal with rcu,
> + * since all modification code is protected by mdev->state_lock
> + */
> +
> + /* find what to add */
> + netdev_for_each_uc_addr(ha, dev) {
> + found = false;
> + bucket = &priv->mac_hash[ha->addr[MLX4_EN_MAC_HASH_IDX]];
> + hlist_for_each_entry(entry, n, bucket, hlist) {
> + if (ether_addr_equal_64bits(entry->mac, ha->addr)) {
> + found = true;
> + break;
> + }
> + }
> +
> + if (!found) {
> + entry = kmalloc(sizeof(*entry), GFP_KERNEL);
> + if (!entry) {
> + en_err(priv, "Failed adding MAC %pM on port:%d (out of memory)\n",
> + ha->addr, priv->port);
> + return;
> + }
> + mac = mlx4_en_mac_to_u64(ha->addr);
> + memcpy(entry->mac, ha->addr, ETH_ALEN);
> + err = mlx4_register_mac(mdev->dev, priv->port, mac);
> + if (err < 0) {
> + en_err(priv, "Failed registering MAC %pM on port %d: %d\n",
> + ha->addr, priv->port, err);
> + kfree(entry);
> + continue;
> + }
In case of error (kmalloc() -> NULL, or mlx4_register_mac() -> err,
should not you need to force promisc ?
At first glance, there is a limit of 128 mac per device
(MLX4_MAX_MAC_NUM), but one can declare more than 128 macvlans...
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists