Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mlx5-updates-2020-06-23' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux

Saeed Mahameed says:

====================
mlx5 updates 2020-06-23

This series adds misc cleanup and updates to mlx5 driver.

1) Misc updates and cleanup
2) Use RCU instead of spinlock for vxlan table

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>
Signed-off-by: David S. Miller <davem@davemloft.net>

+55 -82
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
··· 676 676 block_count = tracer->buff.size / TRACER_BLOCK_SIZE_BYTE; 677 677 start_offset = tracer->buff.consumer_index * TRACER_BLOCK_SIZE_BYTE; 678 678 679 - /* Copy the block to local buffer to avoid HW override while being processed*/ 679 + /* Copy the block to local buffer to avoid HW override while being processed */ 680 680 memcpy(tmp_trace_block, tracer->buff.log_buf + start_offset, 681 681 TRACER_BLOCK_SIZE_BYTE); 682 682
+1
drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c
··· 10 10 #include <linux/spinlock.h> 11 11 #include <linux/notifier.h> 12 12 #include <net/netevent.h> 13 + #include <net/arp.h> 13 14 #include "neigh.h" 14 15 #include "tc.h" 15 16 #include "en_rep.h"
-13
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.c
··· 215 215 return umem ? mlx5e_xsk_enable_umem(priv, umem, ix) : 216 216 mlx5e_xsk_disable_umem(priv, ix); 217 217 } 218 - 219 - u16 mlx5e_xsk_first_unused_channel(struct mlx5e_params *params, struct mlx5e_xsk *xsk) 220 - { 221 - u16 res = xsk->refcnt ? params->num_channels : 0; 222 - 223 - while (res) { 224 - if (mlx5e_xsk_get_umem(params, xsk, res - 1)) 225 - break; 226 - --res; 227 - } 228 - 229 - return res; 230 - }
-2
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/umem.h
··· 26 26 27 27 int mlx5e_xsk_resize_reuseq(struct xdp_umem *umem, u32 nentries); 28 28 29 - u16 mlx5e_xsk_first_unused_channel(struct mlx5e_params *params, struct mlx5e_xsk *xsk); 30 - 31 29 #endif /* __MLX5_EN_XSK_UMEM_H__ */
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
··· 220 220 sizeof(*ft->g), GFP_KERNEL); 221 221 in = kvzalloc(inlen, GFP_KERNEL); 222 222 if (!in || !ft->g) { 223 - kvfree(ft->g); 223 + kfree(ft->g); 224 224 kvfree(in); 225 225 return -ENOMEM; 226 226 }
-1
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
··· 35 35 #include <net/switchdev.h> 36 36 #include <net/pkt_cls.h> 37 37 #include <net/act_api.h> 38 - #include <net/arp.h> 39 38 #include <net/devlink.h> 40 39 #include <net/ipv6_stubs.h> 41 40
+8 -8
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
··· 40 40 41 41 #ifdef CONFIG_MLX5_ESWITCH 42 42 43 + int mlx5e_tc_num_filters(struct mlx5e_priv *priv, unsigned long flags); 44 + 45 + struct mlx5e_tc_update_priv { 46 + struct net_device *tun_dev; 47 + }; 48 + 49 + #if IS_ENABLED(CONFIG_MLX5_CLS_ACT) 50 + 43 51 struct tunnel_match_key { 44 52 struct flow_dissector_key_control enc_control; 45 53 struct flow_dissector_key_keyid enc_key_id; ··· 122 114 struct mlx5e_neigh_hash_entry; 123 115 void mlx5e_tc_update_neigh_used_value(struct mlx5e_neigh_hash_entry *nhe); 124 116 125 - int mlx5e_tc_num_filters(struct mlx5e_priv *priv, unsigned long flags); 126 - 127 117 void mlx5e_tc_reoffload_flows_work(struct work_struct *work); 128 118 129 119 enum mlx5e_tc_attr_to_reg { ··· 147 141 148 142 bool mlx5e_is_valid_eswitch_fwd_dev(struct mlx5e_priv *priv, 149 143 struct net_device *out_dev); 150 - 151 - struct mlx5e_tc_update_priv { 152 - struct net_device *tun_dev; 153 - }; 154 144 155 145 struct mlx5e_tc_mod_hdr_acts { 156 146 int num_actions; ··· 175 173 void mlx5e_tc_set_ethertype(struct mlx5_core_dev *mdev, 176 174 struct flow_match_basic *match, bool outer, 177 175 void *headers_c, void *headers_v); 178 - 179 - #if IS_ENABLED(CONFIG_MLX5_CLS_ACT) 180 176 181 177 int mlx5e_tc_nic_init(struct mlx5e_priv *priv); 182 178 void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv);
-10
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
··· 44 44 #include "lib/mpfs.h" 45 45 #include "en/tc_ct.h" 46 46 47 - #define FDB_TC_MAX_CHAIN 3 48 - #define FDB_FT_CHAIN (FDB_TC_MAX_CHAIN + 1) 49 - #define FDB_TC_SLOW_PATH_CHAIN (FDB_FT_CHAIN + 1) 50 - 51 - /* The index of the last real chain (FT) + 1 as chain zero is valid as well */ 52 - #define FDB_NUM_CHAINS (FDB_FT_CHAIN + 1) 53 - 54 - #define FDB_TC_MAX_PRIO 16 55 - #define FDB_TC_LEVELS_PER_PRIO 2 56 - 57 47 #ifdef CONFIG_MLX5_ESWITCH 58 48 59 49 #define ESW_OFFLOADS_DEFAULT_NUM_GROUPS 15
-1
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
··· 41 41 #include "diag/fs_tracepoint.h" 42 42 #include "accel/ipsec.h" 43 43 #include "fpga/ipsec.h" 44 - #include "eswitch.h" 45 44 46 45 #define INIT_TREE_NODE_ARRAY_SIZE(...) (sizeof((struct init_tree_node[]){__VA_ARGS__}) /\ 47 46 sizeof(struct init_tree_node))
+10
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
··· 39 39 #include <linux/llist.h> 40 40 #include <steering/fs_dr.h> 41 41 42 + #define FDB_TC_MAX_CHAIN 3 43 + #define FDB_FT_CHAIN (FDB_TC_MAX_CHAIN + 1) 44 + #define FDB_TC_SLOW_PATH_CHAIN (FDB_FT_CHAIN + 1) 45 + 46 + /* The index of the last real chain (FT) + 1 as chain zero is valid as well */ 47 + #define FDB_NUM_CHAINS (FDB_FT_CHAIN + 1) 48 + 49 + #define FDB_TC_MAX_PRIO 16 50 + #define FDB_TC_LEVELS_PER_PRIO 2 51 + 42 52 struct mlx5_modify_hdr { 43 53 enum mlx5_flow_namespace_type ns_type; 44 54 union {
+32 -42
drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c
··· 40 40 41 41 struct mlx5_vxlan { 42 42 struct mlx5_core_dev *mdev; 43 - spinlock_t lock; /* protect vxlan table */ 44 43 /* max_num_ports is usuallly 4, 16 buckets is more than enough */ 45 44 DECLARE_HASHTABLE(htable, 4); 46 45 int num_ports; ··· 77 78 return mlx5_cmd_exec_in(mdev, delete_vxlan_udp_dport, in); 78 79 } 79 80 80 - static struct mlx5_vxlan_port* 81 - mlx5_vxlan_lookup_port_locked(struct mlx5_vxlan *vxlan, u16 port) 81 + bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) 82 82 { 83 83 struct mlx5_vxlan_port *vxlanp; 84 - 85 - hash_for_each_possible(vxlan->htable, vxlanp, hlist, port) { 86 - if (vxlanp->udp_port == port) 87 - return vxlanp; 88 - } 89 - 90 - return NULL; 91 - } 92 - 93 - struct mlx5_vxlan_port *mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) 94 - { 95 - struct mlx5_vxlan_port *vxlanp; 84 + bool found = false; 96 85 97 86 if (!mlx5_vxlan_allowed(vxlan)) 98 87 return NULL; 99 88 100 - spin_lock_bh(&vxlan->lock); 101 - vxlanp = mlx5_vxlan_lookup_port_locked(vxlan, port); 102 - spin_unlock_bh(&vxlan->lock); 89 + rcu_read_lock(); 90 + hash_for_each_possible_rcu(vxlan->htable, vxlanp, hlist, port) 91 + if (vxlanp->udp_port == port) { 92 + found = true; 93 + break; 94 + } 95 + rcu_read_unlock(); 103 96 104 - return vxlanp; 97 + return found; 98 + } 99 + 100 + static struct mlx5_vxlan_port *vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) 101 + { 102 + struct mlx5_vxlan_port *vxlanp; 103 + 104 + hash_for_each_possible(vxlan->htable, vxlanp, hlist, port) 105 + if (vxlanp->udp_port == port) 106 + return vxlanp; 107 + return NULL; 105 108 } 106 109 107 110 int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port) 108 111 { 109 112 struct mlx5_vxlan_port *vxlanp; 110 - int ret = -ENOSPC; 111 - 112 - vxlanp = mlx5_vxlan_lookup_port(vxlan, port); 113 - if (vxlanp) { 114 - refcount_inc(&vxlanp->refcount); 115 - return 0; 116 - } 113 + int ret = 0; 117 114 118 115 mutex_lock(&vxlan->sync_lock); 116 + vxlanp = vxlan_lookup_port(vxlan, port); 117 + if (vxlanp) { 118 + refcount_inc(&vxlanp->refcount); 119 + goto unlock; 120 + } 121 + 119 122 if (vxlan->num_ports >= mlx5_vxlan_max_udp_ports(vxlan->mdev)) { 120 123 mlx5_core_info(vxlan->mdev, 121 124 "UDP port (%d) not offloaded, max number of UDP ports (%d) are already offloaded\n", ··· 139 138 vxlanp->udp_port = port; 140 139 refcount_set(&vxlanp->refcount, 1); 141 140 142 - spin_lock_bh(&vxlan->lock); 143 - hash_add(vxlan->htable, &vxlanp->hlist, port); 144 - spin_unlock_bh(&vxlan->lock); 141 + hash_add_rcu(vxlan->htable, &vxlanp->hlist, port); 145 142 146 143 vxlan->num_ports++; 147 144 mutex_unlock(&vxlan->sync_lock); ··· 156 157 int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port) 157 158 { 158 159 struct mlx5_vxlan_port *vxlanp; 159 - bool remove = false; 160 160 int ret = 0; 161 161 162 162 mutex_lock(&vxlan->sync_lock); 163 163 164 - spin_lock_bh(&vxlan->lock); 165 - vxlanp = mlx5_vxlan_lookup_port_locked(vxlan, port); 164 + vxlanp = vxlan_lookup_port(vxlan, port); 166 165 if (!vxlanp) { 167 166 ret = -ENOENT; 168 167 goto out_unlock; 169 168 } 170 169 171 170 if (refcount_dec_and_test(&vxlanp->refcount)) { 172 - hash_del(&vxlanp->hlist); 173 - remove = true; 174 - } 175 - 176 - out_unlock: 177 - spin_unlock_bh(&vxlan->lock); 178 - 179 - if (remove) { 171 + hash_del_rcu(&vxlanp->hlist); 172 + synchronize_rcu(); 180 173 mlx5_vxlan_core_del_port_cmd(vxlan->mdev, port); 181 174 kfree(vxlanp); 182 175 vxlan->num_ports--; 183 176 } 184 177 178 + out_unlock: 185 179 mutex_unlock(&vxlan->sync_lock); 186 - 187 180 return ret; 188 181 } 189 182 ··· 192 201 193 202 vxlan->mdev = mdev; 194 203 mutex_init(&vxlan->sync_lock); 195 - spin_lock_init(&vxlan->lock); 196 204 hash_init(vxlan->htable); 197 205 198 206 /* Hardware adds 4789 (IANA_VXLAN_UDP_PORT) by default */
+2 -3
drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h
··· 50 50 void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan); 51 51 int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port); 52 52 int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port); 53 - struct mlx5_vxlan_port *mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port); 53 + bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port); 54 54 #else 55 55 static inline struct mlx5_vxlan* 56 56 mlx5_vxlan_create(struct mlx5_core_dev *mdev) { return ERR_PTR(-EOPNOTSUPP); } 57 57 static inline void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan) { return; } 58 58 static inline int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; } 59 59 static inline int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; } 60 - static inline struct mx5_vxlan_port* 61 - mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) { return NULL; } 60 + static inline bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) { return false; } 62 61 #endif 63 62 64 63 #endif /* __MLX5_VXLAN_H__ */