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

Merge tag 'mlx5-fixes-2019-10-24' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux

Saeed Mahameed says:

====================
Mellanox, mlx5 fixes 2019-10-24

This series introduces misc fixes to mlx5 driver.

v1->v2:
- Dropped the kTLS counter documentation patch, Tariq will fix it and
send it later.
- Added a new fix for link speed mode reporting.
('net/mlx5e: Initialize link modes bitmap on stack')

For -stable v4.14
('net/mlx5e: Fix handling of compressed CQEs in case of low NAPI budget')

For -stable v4.19
('net/mlx5e: Fix ethtool self test: link speed')

For -stable v5.2
('net/mlx5: Fix flow counter list auto bits struct')
('net/mlx5: Fix rtable reference leak')

For -stable v5.3
('net/mlx5e: Remove incorrect match criteria assignment line')
('net/mlx5e: Determine source port properly for vlan push action')
('net/mlx5e: Initialize link modes bitmap on stack')
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+67 -38
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c
··· 141 141 "Failed to create hv vhca stats agent, err = %ld\n", 142 142 PTR_ERR(agent)); 143 143 144 - kfree(priv->stats_agent.buf); 144 + kvfree(priv->stats_agent.buf); 145 145 return IS_ERR_OR_NULL(agent); 146 146 } 147 147 ··· 157 157 return; 158 158 159 159 mlx5_hv_vhca_agent_destroy(priv->stats_agent.agent); 160 - kfree(priv->stats_agent.buf); 160 + kvfree(priv->stats_agent.buf); 161 161 }
+9 -3
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
··· 97 97 if (ret) 98 98 return ret; 99 99 100 - if (mlx5_lag_is_multipath(mdev) && rt->rt_gw_family != AF_INET) 100 + if (mlx5_lag_is_multipath(mdev) && rt->rt_gw_family != AF_INET) { 101 + ip_rt_put(rt); 101 102 return -ENETUNREACH; 103 + } 102 104 #else 103 105 return -EOPNOTSUPP; 104 106 #endif 105 107 106 108 ret = get_route_and_out_devs(priv, rt->dst.dev, route_dev, out_dev); 107 - if (ret < 0) 109 + if (ret < 0) { 110 + ip_rt_put(rt); 108 111 return ret; 112 + } 109 113 110 114 if (!(*out_ttl)) 111 115 *out_ttl = ip4_dst_hoplimit(&rt->dst); ··· 153 149 *out_ttl = ip6_dst_hoplimit(dst); 154 150 155 151 ret = get_route_and_out_devs(priv, dst->dev, route_dev, out_dev); 156 - if (ret < 0) 152 + if (ret < 0) { 153 + dst_release(dst); 157 154 return ret; 155 + } 158 156 #else 159 157 return -EOPNOTSUPP; 160 158 #endif
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
··· 1021 1021 { 1022 1022 #define MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT ETHTOOL_LINK_MODE_50000baseKR_Full_BIT 1023 1023 int size = __ETHTOOL_LINK_MODE_MASK_NBITS - MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT; 1024 - __ETHTOOL_DECLARE_LINK_MODE_MASK(modes); 1024 + __ETHTOOL_DECLARE_LINK_MODE_MASK(modes) = {0,}; 1025 1025 1026 1026 bitmap_set(modes, MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT, size); 1027 1027 return bitmap_intersects(modes, adver, __ETHTOOL_LINK_MODE_MASK_NBITS);
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
··· 611 611 612 612 mutex_lock(&esw->offloads.encap_tbl_lock); 613 613 encap_connected = !!(e->flags & MLX5_ENCAP_ENTRY_VALID); 614 - if (e->compl_result || (encap_connected == neigh_connected && 615 - ether_addr_equal(e->h_dest, ha))) 614 + if (e->compl_result < 0 || (encap_connected == neigh_connected && 615 + ether_addr_equal(e->h_dest, ha))) 616 616 goto unlock; 617 617 618 618 mlx5e_take_all_encap_flows(e, &flow_list);
+4 -1
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
··· 1386 1386 if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state))) 1387 1387 return 0; 1388 1388 1389 - if (rq->cqd.left) 1389 + if (rq->cqd.left) { 1390 1390 work_done += mlx5e_decompress_cqes_cont(rq, cqwq, 0, budget); 1391 + if (rq->cqd.left || work_done >= budget) 1392 + goto out; 1393 + } 1391 1394 1392 1395 cqe = mlx5_cqwq_get_cqe(cqwq); 1393 1396 if (!cqe) {
+3 -12
drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c
··· 35 35 #include <linux/udp.h> 36 36 #include <net/udp.h> 37 37 #include "en.h" 38 + #include "en/port.h" 38 39 39 40 enum { 40 41 MLX5E_ST_LINK_STATE, ··· 81 80 82 81 static int mlx5e_test_link_speed(struct mlx5e_priv *priv) 83 82 { 84 - u32 out[MLX5_ST_SZ_DW(ptys_reg)]; 85 - u32 eth_proto_oper; 86 - int i; 83 + u32 speed; 87 84 88 85 if (!netif_carrier_ok(priv->netdev)) 89 86 return 1; 90 87 91 - if (mlx5_query_port_ptys(priv->mdev, out, sizeof(out), MLX5_PTYS_EN, 1)) 92 - return 1; 93 - 94 - eth_proto_oper = MLX5_GET(ptys_reg, out, eth_proto_oper); 95 - for (i = 0; i < MLX5E_LINK_MODES_NUMBER; i++) { 96 - if (eth_proto_oper & MLX5E_PROT_MASK(i)) 97 - return 0; 98 - } 99 - return 1; 88 + return mlx5e_port_linkspeed(priv->mdev, &speed); 100 89 } 101 90 102 91 struct mlx5ehdr {
+27 -7
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 1278 1278 mlx5_eswitch_del_vlan_action(esw, attr); 1279 1279 1280 1280 for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) 1281 - if (attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP) 1281 + if (attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP) { 1282 1282 mlx5e_detach_encap(priv, flow, out_index); 1283 + kfree(attr->parse_attr->tun_info[out_index]); 1284 + } 1283 1285 kvfree(attr->parse_attr); 1284 1286 1285 1287 if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) ··· 1561 1559 mlx5_packet_reformat_dealloc(priv->mdev, e->pkt_reformat); 1562 1560 } 1563 1561 1562 + kfree(e->tun_info); 1564 1563 kfree(e->encap_header); 1565 1564 kfree_rcu(e, rcu); 1566 1565 } ··· 2975 2972 return NULL; 2976 2973 } 2977 2974 2975 + static struct ip_tunnel_info *dup_tun_info(const struct ip_tunnel_info *tun_info) 2976 + { 2977 + size_t tun_size = sizeof(*tun_info) + tun_info->options_len; 2978 + 2979 + return kmemdup(tun_info, tun_size, GFP_KERNEL); 2980 + } 2981 + 2978 2982 static int mlx5e_attach_encap(struct mlx5e_priv *priv, 2979 2983 struct mlx5e_tc_flow *flow, 2980 2984 struct net_device *mirred_dev, ··· 3038 3028 refcount_set(&e->refcnt, 1); 3039 3029 init_completion(&e->res_ready); 3040 3030 3031 + tun_info = dup_tun_info(tun_info); 3032 + if (!tun_info) { 3033 + err = -ENOMEM; 3034 + goto out_err_init; 3035 + } 3041 3036 e->tun_info = tun_info; 3042 3037 err = mlx5e_tc_tun_init_encap_attr(mirred_dev, priv, e, extack); 3043 - if (err) { 3044 - kfree(e); 3045 - e = NULL; 3046 - goto out_err; 3047 - } 3038 + if (err) 3039 + goto out_err_init; 3048 3040 3049 3041 INIT_LIST_HEAD(&e->flows); 3050 3042 hash_add_rcu(esw->offloads.encap_tbl, &e->encap_hlist, hash_key); ··· 3086 3074 mutex_unlock(&esw->offloads.encap_tbl_lock); 3087 3075 if (e) 3088 3076 mlx5e_encap_put(priv, e); 3077 + return err; 3078 + 3079 + out_err_init: 3080 + mutex_unlock(&esw->offloads.encap_tbl_lock); 3081 + kfree(tun_info); 3082 + kfree(e); 3089 3083 return err; 3090 3084 } 3091 3085 ··· 3313 3295 } else if (encap) { 3314 3296 parse_attr->mirred_ifindex[attr->out_count] = 3315 3297 out_dev->ifindex; 3316 - parse_attr->tun_info[attr->out_count] = info; 3298 + parse_attr->tun_info[attr->out_count] = dup_tun_info(info); 3299 + if (!parse_attr->tun_info[attr->out_count]) 3300 + return -ENOMEM; 3317 3301 encap = false; 3318 3302 attr->dests[attr->out_count].flags |= 3319 3303 MLX5_ESW_DEST_ENCAP;
-1
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
··· 285 285 286 286 mlx5_eswitch_set_rule_source_port(esw, spec, attr); 287 287 288 - spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS; 289 288 if (attr->outer_match_level != MLX5_MATCH_NONE) 290 289 spec->match_criteria_enable |= MLX5_MATCH_OUTER_HEADERS; 291 290
+16 -6
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
··· 177 177 memset(&src->vlan[1], 0, sizeof(src->vlan[1])); 178 178 } 179 179 180 + static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw, 181 + const struct mlx5_flow_spec *spec) 182 + { 183 + u32 port_mask, port_value; 184 + 185 + if (MLX5_CAP_ESW_FLOWTABLE(esw->dev, flow_source)) 186 + return spec->flow_context.flow_source == MLX5_VPORT_UPLINK; 187 + 188 + port_mask = MLX5_GET(fte_match_param, spec->match_criteria, 189 + misc_parameters.source_port); 190 + port_value = MLX5_GET(fte_match_param, spec->match_value, 191 + misc_parameters.source_port); 192 + return (port_mask & port_value & 0xffff) == MLX5_VPORT_UPLINK; 193 + } 194 + 180 195 bool 181 196 mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw, 182 197 struct mlx5_flow_act *flow_act, 183 198 struct mlx5_flow_spec *spec) 184 199 { 185 - u32 port_mask = MLX5_GET(fte_match_param, spec->match_criteria, 186 - misc_parameters.source_port); 187 - u32 port_value = MLX5_GET(fte_match_param, spec->match_value, 188 - misc_parameters.source_port); 189 - 190 200 if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table)) 191 201 return false; 192 202 193 203 /* push vlan on RX */ 194 204 return (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH) && 195 - ((port_mask & port_value) == MLX5_VPORT_UPLINK); 205 + mlx5_eswitch_offload_is_uplink_port(esw, spec); 196 206 } 197 207 198 208 struct mlx5_flow_handle *
+2 -1
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
··· 507 507 MLX5_SET(dest_format_struct, in_dests, 508 508 destination_eswitch_owner_vhca_id, 509 509 dst->dest_attr.vport.vhca_id); 510 - if (extended_dest) { 510 + if (extended_dest && 511 + dst->dest_attr.vport.pkt_reformat) { 511 512 MLX5_SET(dest_format_struct, in_dests, 512 513 packet_reformat, 513 514 !!(dst->dest_attr.vport.flags &
+1 -2
include/linux/mlx5/mlx5_ifc.h
··· 1545 1545 }; 1546 1546 1547 1547 union mlx5_ifc_dest_format_struct_flow_counter_list_auto_bits { 1548 - struct mlx5_ifc_dest_format_struct_bits dest_format_struct; 1548 + struct mlx5_ifc_extended_dest_format_bits extended_dest_format; 1549 1549 struct mlx5_ifc_flow_counter_list_bits flow_counter_list; 1550 - u8 reserved_at_0[0x40]; 1551 1550 }; 1552 1551 1553 1552 struct mlx5_ifc_fte_match_param_bits {