* [pull request][net-next V4 0/8] mlx5 updates 2020-06-23
@ 2020-06-25 20:13 Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 1/8] net/mlx5: Avoid eswitch header inclusion in fs core layer Saeed Mahameed
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Saeed Mahameed @ 2020-06-25 20:13 UTC (permalink / raw)
To: David S. Miller, kuba; +Cc: netdev, Saeed Mahameed
Hi Dave, Jakub
This series adds misc cleanup and updates to mlx5 driver.
v1->v2:
- Removed unnecessary Fixes Tags
v2->v3:
- Drop "macro undefine" patch, it has no value
v3->v4:
- Drop the Relaxed ordering patch.
For more information please see tag log below.
Please pull and let me know if there is any problem.
Thanks,
Saeed.
---
The following changes since commit d621d7703d510d222fa674254293ec48ca6ea709:
net: enetc add tc flower offload flow metering policing action (2020-06-24 22:05:01 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2020-06-23
for you to fetch changes up to efbb974d8ead5106787144219cb240fdcebccc16:
net/mlx5e: vxlan: Return bool instead of opaque ptr in port_lookup() (2020-06-25 12:41:46 -0700)
----------------------------------------------------------------
mlx5-updates-2020-06-23
1) Misc updates and cleanup
2) Use RCU instead of spinlock for vxlan table
----------------------------------------------------------------
Alaa Hleihel (1):
net/mlx5e: Move including net/arp.h from en_rep.c to rep/neigh.c
Denis Efremov (1):
net/mlx5: Use kfree(ft->g) in arfs_create_groups()
Hu Haowen (1):
net/mlx5: FWTrace: Add missing space
Maxim Mikityanskiy (1):
net/mlx5e: Remove unused mlx5e_xsk_first_unused_channel
Parav Pandit (1):
net/mlx5: Avoid eswitch header inclusion in fs core layer
Saeed Mahameed (2):
net/mlx5e: vxlan: Use RCU for vxlan table lookup
net/mlx5e: vxlan: Return bool instead of opaque ptr in port_lookup()
Vlad Buslov (1):
net/mlx5e: Move TC-specific function definitions into MLX5_CLS_ACT
.../ethernet/mellanox/mlx5/core/diag/fw_tracer.c | 2 +-
.../net/ethernet/mellanox/mlx5/core/en/rep/neigh.c | 1 +
.../net/ethernet/mellanox/mlx5/core/en/xsk/umem.c | 13 -----
.../net/ethernet/mellanox/mlx5/core/en/xsk/umem.h | 2 -
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 1 -
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 16 +++---
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 10 ----
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 1 -
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 10 ++++
.../net/ethernet/mellanox/mlx5/core/lib/vxlan.c | 64 +++++++++-------------
.../net/ethernet/mellanox/mlx5/core/lib/vxlan.h | 5 +-
12 files changed, 50 insertions(+), 77 deletions(-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [net-next V4 1/8] net/mlx5: Avoid eswitch header inclusion in fs core layer
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
@ 2020-06-25 20:13 ` Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 2/8] net/mlx5: FWTrace: Add missing space Saeed Mahameed
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2020-06-25 20:13 UTC (permalink / raw)
To: David S. Miller, kuba; +Cc: netdev, Parav Pandit, Saeed Mahameed
From: Parav Pandit <parav@mellanox.com>
Flow steering core layer is independent of the eswitch layer.
Hence avoid fs_core dependency on eswitch.
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 10 ----------
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 1 -
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 10 ++++++++++
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index 67e09902bd88b..522cadc09149a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -44,16 +44,6 @@
#include "lib/mpfs.h"
#include "en/tc_ct.h"
-#define FDB_TC_MAX_CHAIN 3
-#define FDB_FT_CHAIN (FDB_TC_MAX_CHAIN + 1)
-#define FDB_TC_SLOW_PATH_CHAIN (FDB_FT_CHAIN + 1)
-
-/* The index of the last real chain (FT) + 1 as chain zero is valid as well */
-#define FDB_NUM_CHAINS (FDB_FT_CHAIN + 1)
-
-#define FDB_TC_MAX_PRIO 16
-#define FDB_TC_LEVELS_PER_PRIO 2
-
#ifdef CONFIG_MLX5_ESWITCH
#define ESW_OFFLOADS_DEFAULT_NUM_GROUPS 15
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 13e2fb79c21ae..e47a669839356 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -41,7 +41,6 @@
#include "diag/fs_tracepoint.h"
#include "accel/ipsec.h"
#include "fpga/ipsec.h"
-#include "eswitch.h"
#define INIT_TREE_NODE_ARRAY_SIZE(...) (sizeof((struct init_tree_node[]){__VA_ARGS__}) /\
sizeof(struct init_tree_node))
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
index 825b662f809b4..afe7f0bffb939 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
@@ -39,6 +39,16 @@
#include <linux/llist.h>
#include <steering/fs_dr.h>
+#define FDB_TC_MAX_CHAIN 3
+#define FDB_FT_CHAIN (FDB_TC_MAX_CHAIN + 1)
+#define FDB_TC_SLOW_PATH_CHAIN (FDB_FT_CHAIN + 1)
+
+/* The index of the last real chain (FT) + 1 as chain zero is valid as well */
+#define FDB_NUM_CHAINS (FDB_FT_CHAIN + 1)
+
+#define FDB_TC_MAX_PRIO 16
+#define FDB_TC_LEVELS_PER_PRIO 2
+
struct mlx5_modify_hdr {
enum mlx5_flow_namespace_type ns_type;
union {
--
2.26.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net-next V4 2/8] net/mlx5: FWTrace: Add missing space
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 1/8] net/mlx5: Avoid eswitch header inclusion in fs core layer Saeed Mahameed
@ 2020-06-25 20:13 ` Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 3/8] net/mlx5: Use kfree(ft->g) in arfs_create_groups() Saeed Mahameed
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2020-06-25 20:13 UTC (permalink / raw)
To: David S. Miller, kuba; +Cc: netdev, Hu Haowen, Saeed Mahameed
From: Hu Haowen <xianfengting221@163.com>
Missing space at the end of a comment line, add it.
Signed-off-by: Hu Haowen <xianfengting221@163.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c b/drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
index a7551274be58a..ad3594c4afcb5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
@@ -676,7 +676,7 @@ static void mlx5_fw_tracer_handle_traces(struct work_struct *work)
block_count = tracer->buff.size / TRACER_BLOCK_SIZE_BYTE;
start_offset = tracer->buff.consumer_index * TRACER_BLOCK_SIZE_BYTE;
- /* Copy the block to local buffer to avoid HW override while being processed*/
+ /* Copy the block to local buffer to avoid HW override while being processed */
memcpy(tmp_trace_block, tracer->buff.log_buf + start_offset,
TRACER_BLOCK_SIZE_BYTE);
--
2.26.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net-next V4 3/8] net/mlx5: Use kfree(ft->g) in arfs_create_groups()
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 1/8] net/mlx5: Avoid eswitch header inclusion in fs core layer Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 2/8] net/mlx5: FWTrace: Add missing space Saeed Mahameed
@ 2020-06-25 20:13 ` Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 4/8] net/mlx5e: Remove unused mlx5e_xsk_first_unused_channel Saeed Mahameed
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2020-06-25 20:13 UTC (permalink / raw)
To: David S. Miller, kuba; +Cc: netdev, Denis Efremov, Saeed Mahameed
From: Denis Efremov <efremov@linux.com>
Use kfree() instead of kvfree() on ft->g in arfs_create_groups() because
the memory is allocated with kcalloc().
Signed-off-by: Denis Efremov <efremov@linux.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
index 014639ea06e34..c4c9d6cda7e62 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
@@ -220,7 +220,7 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
sizeof(*ft->g), GFP_KERNEL);
in = kvzalloc(inlen, GFP_KERNEL);
if (!in || !ft->g) {
- kvfree(ft->g);
+ kfree(ft->g);
kvfree(in);
return -ENOMEM;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net-next V4 4/8] net/mlx5e: Remove unused mlx5e_xsk_first_unused_channel
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
` (2 preceding siblings ...)
2020-06-25 20:13 ` [net-next V4 3/8] net/mlx5: Use kfree(ft->g) in arfs_create_groups() Saeed Mahameed
@ 2020-06-25 20:13 ` Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 5/8] net/mlx5e: Move including net/arp.h from en_rep.c to rep/neigh.c Saeed Mahameed
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2020-06-25 20:13 UTC (permalink / raw)
To: David S. Miller, kuba; +Cc: netdev, Maxim Mikityanskiy, Saeed Mahameed
From: Maxim Mikityanskiy <maximmi@mellanox.com>
mlx5e_xsk_first_unused_channel is a leftover from old versions of the
first XSK commit, and it was never used. Remove it.
Fixes: db05815b36cb ("net/mlx5e: Add XSK zero-copy support")
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
.../net/ethernet/mellanox/mlx5/core/en/xsk/umem.c | 13 -------------
.../net/ethernet/mellanox/mlx5/core/en/xsk/umem.h | 2 --
2 files changed, 15 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.c
index 7b17fcd0a56d7..331ca2b0f8a4a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.c
@@ -215,16 +215,3 @@ int mlx5e_xsk_setup_umem(struct net_device *dev, struct xdp_umem *umem, u16 qid)
return umem ? mlx5e_xsk_enable_umem(priv, umem, ix) :
mlx5e_xsk_disable_umem(priv, ix);
}
-
-u16 mlx5e_xsk_first_unused_channel(struct mlx5e_params *params, struct mlx5e_xsk *xsk)
-{
- u16 res = xsk->refcnt ? params->num_channels : 0;
-
- while (res) {
- if (mlx5e_xsk_get_umem(params, xsk, res - 1))
- break;
- --res;
- }
-
- return res;
-}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.h b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.h
index 25b4cbe58b540..bada949735867 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.h
@@ -26,6 +26,4 @@ int mlx5e_xsk_setup_umem(struct net_device *dev, struct xdp_umem *umem, u16 qid)
int mlx5e_xsk_resize_reuseq(struct xdp_umem *umem, u32 nentries);
-u16 mlx5e_xsk_first_unused_channel(struct mlx5e_params *params, struct mlx5e_xsk *xsk);
-
#endif /* __MLX5_EN_XSK_UMEM_H__ */
--
2.26.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net-next V4 5/8] net/mlx5e: Move including net/arp.h from en_rep.c to rep/neigh.c
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
` (3 preceding siblings ...)
2020-06-25 20:13 ` [net-next V4 4/8] net/mlx5e: Remove unused mlx5e_xsk_first_unused_channel Saeed Mahameed
@ 2020-06-25 20:13 ` Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 6/8] net/mlx5e: Move TC-specific function definitions into MLX5_CLS_ACT Saeed Mahameed
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2020-06-25 20:13 UTC (permalink / raw)
To: David S. Miller, kuba; +Cc: netdev, Alaa Hleihel, Vlad Buslov, Saeed Mahameed
From: Alaa Hleihel <alaa@mellanox.com>
After the cited commit, the header net/arp.h is no longer used in en_rep.c.
So, move it to the new file rep/neigh.c that uses it now.
Signed-off-by: Alaa Hleihel <alaa@mellanox.com>
Reviewed-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c | 1 +
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c
index baa162432e75e..a0913836c973f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c
@@ -10,6 +10,7 @@
#include <linux/spinlock.h>
#include <linux/notifier.h>
#include <net/netevent.h>
+#include <net/arp.h>
#include "neigh.h"
#include "tc.h"
#include "en_rep.h"
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 20ff8526d2126..ed2430677b129 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -35,7 +35,6 @@
#include <net/switchdev.h>
#include <net/pkt_cls.h>
#include <net/act_api.h>
-#include <net/arp.h>
#include <net/devlink.h>
#include <net/ipv6_stubs.h>
--
2.26.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net-next V4 6/8] net/mlx5e: Move TC-specific function definitions into MLX5_CLS_ACT
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
` (4 preceding siblings ...)
2020-06-25 20:13 ` [net-next V4 5/8] net/mlx5e: Move including net/arp.h from en_rep.c to rep/neigh.c Saeed Mahameed
@ 2020-06-25 20:13 ` Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 7/8] net/mlx5e: vxlan: Use RCU for vxlan table lookup Saeed Mahameed
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2020-06-25 20:13 UTC (permalink / raw)
To: David S. Miller, kuba
Cc: netdev, Vlad Buslov, Roi Dayan, Maor Dickman, Saeed Mahameed
From: Vlad Buslov <vladbu@mellanox.com>
en_tc.h header file declares several TC-specific functions in
CONFIG_MLX5_ESWITCH block even though those functions are only compiled
when CONFIG_MLX5_CLS_ACT is set, which is a recent change. Move them to
proper block.
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Maor Dickman <maord@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
index 5c330b0cae213..1561eaa89ffd2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
@@ -40,6 +40,14 @@
#ifdef CONFIG_MLX5_ESWITCH
+int mlx5e_tc_num_filters(struct mlx5e_priv *priv, unsigned long flags);
+
+struct mlx5e_tc_update_priv {
+ struct net_device *tun_dev;
+};
+
+#if IS_ENABLED(CONFIG_MLX5_CLS_ACT)
+
struct tunnel_match_key {
struct flow_dissector_key_control enc_control;
struct flow_dissector_key_keyid enc_key_id;
@@ -114,8 +122,6 @@ void mlx5e_put_encap_flow_list(struct mlx5e_priv *priv, struct list_head *flow_l
struct mlx5e_neigh_hash_entry;
void mlx5e_tc_update_neigh_used_value(struct mlx5e_neigh_hash_entry *nhe);
-int mlx5e_tc_num_filters(struct mlx5e_priv *priv, unsigned long flags);
-
void mlx5e_tc_reoffload_flows_work(struct work_struct *work);
enum mlx5e_tc_attr_to_reg {
@@ -142,10 +148,6 @@ extern struct mlx5e_tc_attr_to_reg_mapping mlx5e_tc_attr_to_reg_mappings[];
bool mlx5e_is_valid_eswitch_fwd_dev(struct mlx5e_priv *priv,
struct net_device *out_dev);
-struct mlx5e_tc_update_priv {
- struct net_device *tun_dev;
-};
-
struct mlx5e_tc_mod_hdr_acts {
int num_actions;
int max_actions;
@@ -174,8 +176,6 @@ void mlx5e_tc_set_ethertype(struct mlx5_core_dev *mdev,
struct flow_match_basic *match, bool outer,
void *headers_c, void *headers_v);
-#if IS_ENABLED(CONFIG_MLX5_CLS_ACT)
-
int mlx5e_tc_nic_init(struct mlx5e_priv *priv);
void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv);
--
2.26.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net-next V4 7/8] net/mlx5e: vxlan: Use RCU for vxlan table lookup
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
` (5 preceding siblings ...)
2020-06-25 20:13 ` [net-next V4 6/8] net/mlx5e: Move TC-specific function definitions into MLX5_CLS_ACT Saeed Mahameed
@ 2020-06-25 20:13 ` Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 8/8] net/mlx5e: vxlan: Return bool instead of opaque ptr in port_lookup() Saeed Mahameed
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2020-06-25 20:13 UTC (permalink / raw)
To: David S. Miller, kuba; +Cc: netdev, Saeed Mahameed, Maxim Mikityanskiy
Remove the spinlock protecting the vxlan table and use RCU instead.
This will improve performance as it will eliminate contention on data
path cores.
Fixes: b3f63c3d5e2c ("net/mlx5e: Add netdev support for VXLAN tunneling")
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Maxim Mikityanskiy <maximmi@mellanox.com>
---
.../ethernet/mellanox/mlx5/core/lib/vxlan.c | 65 ++++++++-----------
1 file changed, 27 insertions(+), 38 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c
index 82c766a951656..85cbc42955859 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c
@@ -40,7 +40,6 @@
struct mlx5_vxlan {
struct mlx5_core_dev *mdev;
- spinlock_t lock; /* protect vxlan table */
/* max_num_ports is usuallly 4, 16 buckets is more than enough */
DECLARE_HASHTABLE(htable, 4);
int num_ports;
@@ -78,45 +77,46 @@ static int mlx5_vxlan_core_del_port_cmd(struct mlx5_core_dev *mdev, u16 port)
return mlx5_cmd_exec_in(mdev, delete_vxlan_udp_dport, in);
}
-static struct mlx5_vxlan_port*
-mlx5_vxlan_lookup_port_locked(struct mlx5_vxlan *vxlan, u16 port)
+struct mlx5_vxlan_port *mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port)
{
- struct mlx5_vxlan_port *vxlanp;
+ struct mlx5_vxlan_port *retptr = NULL, *vxlanp;
- hash_for_each_possible(vxlan->htable, vxlanp, hlist, port) {
- if (vxlanp->udp_port == port)
- return vxlanp;
- }
+ if (!mlx5_vxlan_allowed(vxlan))
+ return NULL;
- return NULL;
+ rcu_read_lock();
+ hash_for_each_possible_rcu(vxlan->htable, vxlanp, hlist, port)
+ if (vxlanp->udp_port == port) {
+ retptr = vxlanp;
+ break;
+ }
+ rcu_read_unlock();
+
+ return retptr;
}
-struct mlx5_vxlan_port *mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port)
+static struct mlx5_vxlan_port *vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port)
{
struct mlx5_vxlan_port *vxlanp;
- if (!mlx5_vxlan_allowed(vxlan))
- return NULL;
-
- spin_lock_bh(&vxlan->lock);
- vxlanp = mlx5_vxlan_lookup_port_locked(vxlan, port);
- spin_unlock_bh(&vxlan->lock);
-
- return vxlanp;
+ hash_for_each_possible(vxlan->htable, vxlanp, hlist, port)
+ if (vxlanp->udp_port == port)
+ return vxlanp;
+ return NULL;
}
int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port)
{
struct mlx5_vxlan_port *vxlanp;
- int ret = -ENOSPC;
+ int ret = 0;
- vxlanp = mlx5_vxlan_lookup_port(vxlan, port);
+ mutex_lock(&vxlan->sync_lock);
+ vxlanp = vxlan_lookup_port(vxlan, port);
if (vxlanp) {
refcount_inc(&vxlanp->refcount);
- return 0;
+ goto unlock;
}
- mutex_lock(&vxlan->sync_lock);
if (vxlan->num_ports >= mlx5_vxlan_max_udp_ports(vxlan->mdev)) {
mlx5_core_info(vxlan->mdev,
"UDP port (%d) not offloaded, max number of UDP ports (%d) are already offloaded\n",
@@ -138,9 +138,7 @@ int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port)
vxlanp->udp_port = port;
refcount_set(&vxlanp->refcount, 1);
- spin_lock_bh(&vxlan->lock);
- hash_add(vxlan->htable, &vxlanp->hlist, port);
- spin_unlock_bh(&vxlan->lock);
+ hash_add_rcu(vxlan->htable, &vxlanp->hlist, port);
vxlan->num_ports++;
mutex_unlock(&vxlan->sync_lock);
@@ -157,34 +155,26 @@ int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port)
int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port)
{
struct mlx5_vxlan_port *vxlanp;
- bool remove = false;
int ret = 0;
mutex_lock(&vxlan->sync_lock);
- spin_lock_bh(&vxlan->lock);
- vxlanp = mlx5_vxlan_lookup_port_locked(vxlan, port);
+ vxlanp = vxlan_lookup_port(vxlan, port);
if (!vxlanp) {
ret = -ENOENT;
goto out_unlock;
}
if (refcount_dec_and_test(&vxlanp->refcount)) {
- hash_del(&vxlanp->hlist);
- remove = true;
- }
-
-out_unlock:
- spin_unlock_bh(&vxlan->lock);
-
- if (remove) {
+ hash_del_rcu(&vxlanp->hlist);
+ synchronize_rcu();
mlx5_vxlan_core_del_port_cmd(vxlan->mdev, port);
kfree(vxlanp);
vxlan->num_ports--;
}
+out_unlock:
mutex_unlock(&vxlan->sync_lock);
-
return ret;
}
@@ -201,7 +191,6 @@ struct mlx5_vxlan *mlx5_vxlan_create(struct mlx5_core_dev *mdev)
vxlan->mdev = mdev;
mutex_init(&vxlan->sync_lock);
- spin_lock_init(&vxlan->lock);
hash_init(vxlan->htable);
/* Hardware adds 4789 (IANA_VXLAN_UDP_PORT) by default */
--
2.26.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [net-next V4 8/8] net/mlx5e: vxlan: Return bool instead of opaque ptr in port_lookup()
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
` (6 preceding siblings ...)
2020-06-25 20:13 ` [net-next V4 7/8] net/mlx5e: vxlan: Use RCU for vxlan table lookup Saeed Mahameed
@ 2020-06-25 20:13 ` Saeed Mahameed
2020-06-25 20:27 ` [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Jakub Kicinski
2020-06-25 21:05 ` David Miller
9 siblings, 0 replies; 11+ messages in thread
From: Saeed Mahameed @ 2020-06-25 20:13 UTC (permalink / raw)
To: David S. Miller, kuba; +Cc: netdev, Saeed Mahameed
struct mlx5_vxlan_port is not exposed to the outside callers, it is
redundant to return a pointer to it from mlx5_vxlan_port_lookup(), to be
only used as a boolean, so just return a boolean.
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c | 9 +++++----
drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h | 5 ++---
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c
index 85cbc42955859..be34330d89cc4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c
@@ -77,9 +77,10 @@ static int mlx5_vxlan_core_del_port_cmd(struct mlx5_core_dev *mdev, u16 port)
return mlx5_cmd_exec_in(mdev, delete_vxlan_udp_dport, in);
}
-struct mlx5_vxlan_port *mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port)
+bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port)
{
- struct mlx5_vxlan_port *retptr = NULL, *vxlanp;
+ struct mlx5_vxlan_port *vxlanp;
+ bool found = false;
if (!mlx5_vxlan_allowed(vxlan))
return NULL;
@@ -87,12 +88,12 @@ struct mlx5_vxlan_port *mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 por
rcu_read_lock();
hash_for_each_possible_rcu(vxlan->htable, vxlanp, hlist, port)
if (vxlanp->udp_port == port) {
- retptr = vxlanp;
+ found = true;
break;
}
rcu_read_unlock();
- return retptr;
+ return found;
}
static struct mlx5_vxlan_port *vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h
index 8fb0eb08fa6d2..6d599f4a8acdf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h
@@ -50,15 +50,14 @@ struct mlx5_vxlan *mlx5_vxlan_create(struct mlx5_core_dev *mdev);
void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan);
int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port);
int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port);
-struct mlx5_vxlan_port *mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port);
+bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port);
#else
static inline struct mlx5_vxlan*
mlx5_vxlan_create(struct mlx5_core_dev *mdev) { return ERR_PTR(-EOPNOTSUPP); }
static inline void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan) { return; }
static inline int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; }
static inline int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; }
-static inline struct mx5_vxlan_port*
-mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) { return NULL; }
+static inline bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) { return false; }
#endif
#endif /* __MLX5_VXLAN_H__ */
--
2.26.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [pull request][net-next V4 0/8] mlx5 updates 2020-06-23
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
` (7 preceding siblings ...)
2020-06-25 20:13 ` [net-next V4 8/8] net/mlx5e: vxlan: Return bool instead of opaque ptr in port_lookup() Saeed Mahameed
@ 2020-06-25 20:27 ` Jakub Kicinski
2020-06-25 21:05 ` David Miller
9 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2020-06-25 20:27 UTC (permalink / raw)
To: Saeed Mahameed; +Cc: David S. Miller, netdev
On Thu, 25 Jun 2020 13:13:21 -0700 Saeed Mahameed wrote:
> Hi Dave, Jakub
>
> This series adds misc cleanup and updates to mlx5 driver.
>
> v1->v2:
> - Removed unnecessary Fixes Tags
>
> v2->v3:
> - Drop "macro undefine" patch, it has no value
>
> v3->v4:
> - Drop the Relaxed ordering patch.
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [pull request][net-next V4 0/8] mlx5 updates 2020-06-23
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
` (8 preceding siblings ...)
2020-06-25 20:27 ` [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Jakub Kicinski
@ 2020-06-25 21:05 ` David Miller
9 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2020-06-25 21:05 UTC (permalink / raw)
To: saeedm; +Cc: kuba, netdev
From: Saeed Mahameed <saeedm@mellanox.com>
Date: Thu, 25 Jun 2020 13:13:21 -0700
> This series adds misc cleanup and updates to mlx5 driver.
>
> v1->v2:
> - Removed unnecessary Fixes Tags
>
> v2->v3:
> - Drop "macro undefine" patch, it has no value
>
> v3->v4:
> - Drop the Relaxed ordering patch.
>
> For more information please see tag log below.
>
> Please pull and let me know if there is any problem.
...
> git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2020-06-23
Pulled, thanks everyone.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-06-25 21:05 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 20:13 [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 1/8] net/mlx5: Avoid eswitch header inclusion in fs core layer Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 2/8] net/mlx5: FWTrace: Add missing space Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 3/8] net/mlx5: Use kfree(ft->g) in arfs_create_groups() Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 4/8] net/mlx5e: Remove unused mlx5e_xsk_first_unused_channel Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 5/8] net/mlx5e: Move including net/arp.h from en_rep.c to rep/neigh.c Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 6/8] net/mlx5e: Move TC-specific function definitions into MLX5_CLS_ACT Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 7/8] net/mlx5e: vxlan: Use RCU for vxlan table lookup Saeed Mahameed
2020-06-25 20:13 ` [net-next V4 8/8] net/mlx5e: vxlan: Return bool instead of opaque ptr in port_lookup() Saeed Mahameed
2020-06-25 20:27 ` [pull request][net-next V4 0/8] mlx5 updates 2020-06-23 Jakub Kicinski
2020-06-25 21:05 ` David Miller
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).