Skip to content

Commit 6f74a55

Browse files
committed
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>
2 parents 8b73018 + 926b37f commit 6f74a55

11 files changed

Lines changed: 67 additions & 38 deletions

File tree

‎drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ int mlx5e_hv_vhca_stats_create(struct mlx5e_priv *priv)
141141
"Failed to create hv vhca stats agent, err = %ld\n",
142142
PTR_ERR(agent));
143143

144-
kfree(priv->stats_agent.buf);
144+
kvfree(priv->stats_agent.buf);
145145
return IS_ERR_OR_NULL(agent);
146146
}
147147

@@ -157,5 +157,5 @@ void mlx5e_hv_vhca_stats_destroy(struct mlx5e_priv *priv)
157157
return;
158158

159159
mlx5_hv_vhca_agent_destroy(priv->stats_agent.agent);
160-
kfree(priv->stats_agent.buf);
160+
kvfree(priv->stats_agent.buf);
161161
}

‎drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,19 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,
9797
if (ret)
9898
return ret;
9999

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);
101102
return -ENETUNREACH;
103+
}
102104
#else
103105
return -EOPNOTSUPP;
104106
#endif
105107

106108
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);
108111
return ret;
112+
}
109113

110114
if (!(*out_ttl))
111115
*out_ttl = ip4_dst_hoplimit(&rt->dst);
@@ -149,8 +153,10 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,
149153
*out_ttl = ip6_dst_hoplimit(dst);
150154

151155
ret = get_route_and_out_devs(priv, dst->dev, route_dev, out_dev);
152-
if (ret < 0)
156+
if (ret < 0) {
157+
dst_release(dst);
153158
return ret;
159+
}
154160
#else
155161
return -EOPNOTSUPP;
156162
#endif

‎drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ static bool ext_link_mode_requested(const unsigned long *adver)
10211021
{
10221022
#define MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT ETHTOOL_LINK_MODE_50000baseKR_Full_BIT
10231023
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,};
10251025

10261026
bitmap_set(modes, MLX5E_MIN_PTYS_EXT_LINK_MODE_BIT, size);
10271027
return bitmap_intersects(modes, adver, __ETHTOOL_LINK_MODE_MASK_NBITS);

‎drivers/net/ethernet/mellanox/mlx5/core/en_rep.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,8 @@ static void mlx5e_rep_update_flows(struct mlx5e_priv *priv,
611611

612612
mutex_lock(&esw->offloads.encap_tbl_lock);
613613
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)))
616616
goto unlock;
617617

618618
mlx5e_take_all_encap_flows(e, &flow_list);

‎drivers/net/ethernet/mellanox/mlx5/core/en_rx.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,8 +1386,11 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
13861386
if (unlikely(!test_bit(MLX5E_RQ_STATE_ENABLED, &rq->state)))
13871387
return 0;
13881388

1389-
if (rq->cqd.left)
1389+
if (rq->cqd.left) {
13901390
work_done += mlx5e_decompress_cqes_cont(rq, cqwq, 0, budget);
1391+
if (rq->cqd.left || work_done >= budget)
1392+
goto out;
1393+
}
13911394

13921395
cqe = mlx5_cqwq_get_cqe(cqwq);
13931396
if (!cqe) {

‎drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/udp.h>
3636
#include <net/udp.h>
3737
#include "en.h"
38+
#include "en/port.h"
3839

3940
enum {
4041
MLX5E_ST_LINK_STATE,
@@ -80,22 +81,12 @@ static int mlx5e_test_link_state(struct mlx5e_priv *priv)
8081

8182
static int mlx5e_test_link_speed(struct mlx5e_priv *priv)
8283
{
83-
u32 out[MLX5_ST_SZ_DW(ptys_reg)];
84-
u32 eth_proto_oper;
85-
int i;
84+
u32 speed;
8685

8786
if (!netif_carrier_ok(priv->netdev))
8887
return 1;
8988

90-
if (mlx5_query_port_ptys(priv->mdev, out, sizeof(out), MLX5_PTYS_EN, 1))
91-
return 1;
92-
93-
eth_proto_oper = MLX5_GET(ptys_reg, out, eth_proto_oper);
94-
for (i = 0; i < MLX5E_LINK_MODES_NUMBER; i++) {
95-
if (eth_proto_oper & MLX5E_PROT_MASK(i))
96-
return 0;
97-
}
98-
return 1;
89+
return mlx5e_port_linkspeed(priv->mdev, &speed);
9990
}
10091

10192
struct mlx5ehdr {

‎drivers/net/ethernet/mellanox/mlx5/core/en_tc.c‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,8 +1278,10 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
12781278
mlx5_eswitch_del_vlan_action(esw, attr);
12791279

12801280
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) {
12821282
mlx5e_detach_encap(priv, flow, out_index);
1283+
kfree(attr->parse_attr->tun_info[out_index]);
1284+
}
12831285
kvfree(attr->parse_attr);
12841286

12851287
if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
@@ -1559,6 +1561,7 @@ static void mlx5e_encap_dealloc(struct mlx5e_priv *priv, struct mlx5e_encap_entr
15591561
mlx5_packet_reformat_dealloc(priv->mdev, e->pkt_reformat);
15601562
}
15611563

1564+
kfree(e->tun_info);
15621565
kfree(e->encap_header);
15631566
kfree_rcu(e, rcu);
15641567
}
@@ -2972,6 +2975,13 @@ mlx5e_encap_get(struct mlx5e_priv *priv, struct encap_key *key,
29722975
return NULL;
29732976
}
29742977

2978+
static struct ip_tunnel_info *dup_tun_info(const struct ip_tunnel_info *tun_info)
2979+
{
2980+
size_t tun_size = sizeof(*tun_info) + tun_info->options_len;
2981+
2982+
return kmemdup(tun_info, tun_size, GFP_KERNEL);
2983+
}
2984+
29752985
static int mlx5e_attach_encap(struct mlx5e_priv *priv,
29762986
struct mlx5e_tc_flow *flow,
29772987
struct net_device *mirred_dev,
@@ -3028,13 +3038,15 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
30283038
refcount_set(&e->refcnt, 1);
30293039
init_completion(&e->res_ready);
30303040

3041+
tun_info = dup_tun_info(tun_info);
3042+
if (!tun_info) {
3043+
err = -ENOMEM;
3044+
goto out_err_init;
3045+
}
30313046
e->tun_info = tun_info;
30323047
err = mlx5e_tc_tun_init_encap_attr(mirred_dev, priv, e, extack);
3033-
if (err) {
3034-
kfree(e);
3035-
e = NULL;
3036-
goto out_err;
3037-
}
3048+
if (err)
3049+
goto out_err_init;
30383050

30393051
INIT_LIST_HEAD(&e->flows);
30403052
hash_add_rcu(esw->offloads.encap_tbl, &e->encap_hlist, hash_key);
@@ -3075,6 +3087,12 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
30753087
if (e)
30763088
mlx5e_encap_put(priv, e);
30773089
return err;
3090+
3091+
out_err_init:
3092+
mutex_unlock(&esw->offloads.encap_tbl_lock);
3093+
kfree(tun_info);
3094+
kfree(e);
3095+
return err;
30783096
}
30793097

30803098
static int parse_tc_vlan_action(struct mlx5e_priv *priv,
@@ -3295,7 +3313,9 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
32953313
} else if (encap) {
32963314
parse_attr->mirred_ifindex[attr->out_count] =
32973315
out_dev->ifindex;
3298-
parse_attr->tun_info[attr->out_count] = info;
3316+
parse_attr->tun_info[attr->out_count] = dup_tun_info(info);
3317+
if (!parse_attr->tun_info[attr->out_count])
3318+
return -ENOMEM;
32993319
encap = false;
33003320
attr->dests[attr->out_count].flags |=
33013321
MLX5_ESW_DEST_ENCAP;

‎drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ mlx5_eswitch_add_fwd_rule(struct mlx5_eswitch *esw,
285285

286286
mlx5_eswitch_set_rule_source_port(esw, spec, attr);
287287

288-
spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS;
289288
if (attr->outer_match_level != MLX5_MATCH_NONE)
290289
spec->match_criteria_enable |= MLX5_MATCH_OUTER_HEADERS;
291290

‎drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,32 @@ mlx5_eswitch_termtbl_actions_move(struct mlx5_flow_act *src,
177177
memset(&src->vlan[1], 0, sizeof(src->vlan[1]));
178178
}
179179

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+
180195
bool
181196
mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,
182197
struct mlx5_flow_act *flow_act,
183198
struct mlx5_flow_spec *spec)
184199
{
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-
190200
if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, termination_table))
191201
return false;
192202

193203
/* push vlan on RX */
194204
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);
196206
}
197207

198208
struct mlx5_flow_handle *

‎drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
507507
MLX5_SET(dest_format_struct, in_dests,
508508
destination_eswitch_owner_vhca_id,
509509
dst->dest_attr.vport.vhca_id);
510-
if (extended_dest) {
510+
if (extended_dest &&
511+
dst->dest_attr.vport.pkt_reformat) {
511512
MLX5_SET(dest_format_struct, in_dests,
512513
packet_reformat,
513514
!!(dst->dest_attr.vport.flags &

0 commit comments

Comments
 (0)