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 01/10] net/mlx5: MPFS, Cleanup add MAC flow
Date: Fri, 28 Jun 2019 23:18:20 +0000 [thread overview]
Message-ID: <20190628231759.16374-2-saeedm@mellanox.com> (raw)
In-Reply-To: <20190628231759.16374-1-saeedm@mellanox.com>
From: Gavi Teitz <gavi@mellanox.com>
Unify and isolate the error handling flow in mlx5_mpfs_add_mac(),
removing code duplication.
Signed-off-by: Gavi Teitz <gavi@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
.../ethernet/mellanox/mlx5/core/lib/mpfs.c | 26 +++++++++++--------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c
index a71d5b9c7ab2..9ae7dad590a9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c
@@ -134,8 +134,8 @@ int mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u8 *mac)
{
struct mlx5_mpfs *mpfs = dev->priv.mpfs;
struct l2table_node *l2addr;
+ int err = 0;
u32 index;
- int err;
if (!MLX5_ESWITCH_MANAGER(dev))
return 0;
@@ -145,29 +145,33 @@ 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;
- goto abort;
+ goto out;
}
err = alloc_l2table_index(mpfs, &index);
if (err)
- goto abort;
+ goto out;
l2addr = l2addr_hash_add(mpfs->hash, mac, struct l2table_node, GFP_KERNEL);
if (!l2addr) {
- free_l2table_index(mpfs, index);
err = -ENOMEM;
- goto abort;
+ goto hash_add_err;
}
- l2addr->index = index;
err = set_l2table_entry_cmd(dev, index, mac);
- if (err) {
- l2addr_hash_del(l2addr);
- free_l2table_index(mpfs, index);
- }
+ if (err)
+ goto set_table_entry_err;
+
+ l2addr->index = index;
mlx5_core_dbg(dev, "MPFS mac added %pM, index (%d)\n", mac, index);
-abort:
+ goto out;
+
+set_table_entry_err:
+ l2addr_hash_del(l2addr);
+hash_add_err:
+ free_l2table_index(mpfs, index);
+out:
mutex_unlock(&mpfs->lock);
return err;
}
--
2.21.0
next prev 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 ` Saeed Mahameed [this message]
2019-06-28 23:18 ` [net-next 02/10] net/mlx5: MPFS, Allow adding the same MAC more than once Saeed Mahameed
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-2-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;
as well as URLs for NNTP newsgroup(s).