Netdev List
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Gavi Teitz <gavi@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [net-next 02/10] net/mlx5: MPFS, Allow adding the same MAC more than once
Date: Fri, 28 Jun 2019 23:18:21 +0000	[thread overview]
Message-ID: <20190628231759.16374-3-saeedm@mellanox.com> (raw)
In-Reply-To: <20190628231759.16374-1-saeedm@mellanox.com>

From: Gavi Teitz <gavi@mellanox.com>

Remove the limitation preventing adding a vport's MAC address to the
Multi-Physical Function Switch (MPFS) more than once per E-switch, as
there is no difference in the MPFS if an address is being used by an
E-switch more than once.

This allows the E-switch to have multiple vports with the same MAC
address, allowing vports to be classified by VLAN id instead of by MAC
if desired.

Signed-off-by: Gavi Teitz <gavi@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c
index 9ae7dad590a9..3118e8d66407 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c
@@ -67,6 +67,7 @@ static int del_l2table_entry_cmd(struct mlx5_core_dev *dev, u32 index)
 struct l2table_node {
 	struct l2addr_node node;
 	u32                index; /* index in HW l2 table */
+	int                ref_count;
 };
 
 struct mlx5_mpfs {
@@ -144,7 +145,7 @@ int mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u8 *mac)
 
 	l2addr = l2addr_hash_find(mpfs->hash, mac, struct l2table_node);
 	if (l2addr) {
-		err = -EEXIST;
+		l2addr->ref_count++;
 		goto out;
 	}
 
@@ -163,6 +164,7 @@ int mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u8 *mac)
 		goto set_table_entry_err;
 
 	l2addr->index = index;
+	l2addr->ref_count = 1;
 
 	mlx5_core_dbg(dev, "MPFS mac added %pM, index (%d)\n", mac, index);
 	goto out;
@@ -194,6 +196,9 @@ int mlx5_mpfs_del_mac(struct mlx5_core_dev *dev, u8 *mac)
 		goto unlock;
 	}
 
+	if (--l2addr->ref_count > 0)
+		goto unlock;
+
 	index = l2addr->index;
 	del_l2table_entry_cmd(dev, index);
 	l2addr_hash_del(l2addr);
-- 
2.21.0


  parent reply	other threads:[~2019-06-28 23:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28 23:18 [pull request][net-next 00/10] Mellanox, mlx5e updates 2019-06-28 Saeed Mahameed
2019-06-28 23:18 ` [net-next 01/10] net/mlx5: MPFS, Cleanup add MAC flow Saeed Mahameed
2019-06-28 23:18 ` Saeed Mahameed [this message]
2019-06-28 23:18 ` [net-next 03/10] net/mlx5e: Move to HW checksumming advertising Saeed Mahameed
2019-06-28 23:18 ` [net-next 04/10] net/mlx5e: Report netdevice MPLS features Saeed Mahameed
2019-06-28 23:18 ` [net-next 05/10] net/mlx5e: Correct phys_port_name for PF port Saeed Mahameed
2019-06-28 23:18 ` [net-next 06/10] net/mlx5e: Set drvinfo in generic manner Saeed Mahameed
2019-06-28 23:18 ` [net-next 07/10] net/mlx5e: reduce stack usage in mlx5_eswitch_termtbl_create Saeed Mahameed
2019-06-28 23:18 ` [net-next 08/10] net/mlx5e: Don't refresh TIRs when updating representor SQs Saeed Mahameed
2019-06-28 23:18 ` [net-next 09/10] net/mlx5e: Expose same physical switch_id for all representors Saeed Mahameed
2019-06-28 23:18 ` [net-next 10/10] net/mlx5e: Disallow tc redirect offload cases we don't support Saeed Mahameed
2019-07-01  1:42 ` [pull request][net-next 00/10] Mellanox, mlx5e updates 2019-06-28 David Miller

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=20190628231759.16374-3-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=gavi@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /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