Skip to content

Commit 3e7e072

Browse files
committed
Merge tag 'mlx5-fixes-2017-09-28' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-fixes-2017-09-28 Misc. fixes for mlx5 drivers. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 9d538fa + 353f59f commit 3e7e072

File tree

17 files changed

+133
-31
lines changed

17 files changed

+133
-31
lines changed

drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ TRACE_EVENT(mlx5_fs_del_fg,
139139
{MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO, "NEXT_PRIO"}
140140

141141
TRACE_EVENT(mlx5_fs_set_fte,
142-
TP_PROTO(const struct fs_fte *fte, bool new_fte),
142+
TP_PROTO(const struct fs_fte *fte, int new_fte),
143143
TP_ARGS(fte, new_fte),
144144
TP_STRUCT__entry(
145145
__field(const struct fs_fte *, fte)
@@ -149,7 +149,7 @@ TRACE_EVENT(mlx5_fs_set_fte,
149149
__field(u32, action)
150150
__field(u32, flow_tag)
151151
__field(u8, mask_enable)
152-
__field(bool, new_fte)
152+
__field(int, new_fte)
153153
__array(u32, mask_outer, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4))
154154
__array(u32, mask_inner, MLX5_ST_SZ_DW(fte_match_set_lyr_2_4))
155155
__array(u32, mask_misc, MLX5_ST_SZ_DW(fte_match_set_misc))

drivers/net/ethernet/mellanox/mlx5/core/en_fs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv)
291291
priv->fs.vlan.filter_disabled = false;
292292
if (priv->netdev->flags & IFF_PROMISC)
293293
return;
294-
mlx5e_del_any_vid_rules(priv);
294+
mlx5e_del_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_CTAG_VID, 0);
295295
}
296296

297297
void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv)
@@ -302,7 +302,7 @@ void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv)
302302
priv->fs.vlan.filter_disabled = true;
303303
if (priv->netdev->flags & IFF_PROMISC)
304304
return;
305-
mlx5e_add_any_vid_rules(priv);
305+
mlx5e_add_vlan_rule(priv, MLX5E_VLAN_RULE_TYPE_ANY_CTAG_VID, 0);
306306
}
307307

308308
int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
184184
struct mlx5e_sw_stats temp, *s = &temp;
185185
struct mlx5e_rq_stats *rq_stats;
186186
struct mlx5e_sq_stats *sq_stats;
187-
u64 tx_offload_none = 0;
188187
int i, j;
189188

190189
memset(s, 0, sizeof(*s));
@@ -199,6 +198,7 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
199198
s->rx_lro_bytes += rq_stats->lro_bytes;
200199
s->rx_csum_none += rq_stats->csum_none;
201200
s->rx_csum_complete += rq_stats->csum_complete;
201+
s->rx_csum_unnecessary += rq_stats->csum_unnecessary;
202202
s->rx_csum_unnecessary_inner += rq_stats->csum_unnecessary_inner;
203203
s->rx_xdp_drop += rq_stats->xdp_drop;
204204
s->rx_xdp_tx += rq_stats->xdp_tx;
@@ -229,14 +229,11 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
229229
s->tx_queue_dropped += sq_stats->dropped;
230230
s->tx_xmit_more += sq_stats->xmit_more;
231231
s->tx_csum_partial_inner += sq_stats->csum_partial_inner;
232-
tx_offload_none += sq_stats->csum_none;
232+
s->tx_csum_none += sq_stats->csum_none;
233+
s->tx_csum_partial += sq_stats->csum_partial;
233234
}
234235
}
235236

236-
/* Update calculated offload counters */
237-
s->tx_csum_partial = s->tx_packets - tx_offload_none - s->tx_csum_partial_inner;
238-
s->rx_csum_unnecessary = s->rx_packets - s->rx_csum_none - s->rx_csum_complete;
239-
240237
s->link_down_events_phy = MLX5_GET(ppcnt_reg,
241238
priv->stats.pport.phy_counters,
242239
counter_set.phys_layer_cntrs.link_down_events);
@@ -3333,8 +3330,8 @@ static int mlx5e_handle_feature(struct net_device *netdev,
33333330

33343331
err = feature_handler(netdev, enable);
33353332
if (err) {
3336-
netdev_err(netdev, "%s feature 0x%llx failed err %d\n",
3337-
enable ? "Enable" : "Disable", feature, err);
3333+
netdev_err(netdev, "%s feature %pNF failed, err %d\n",
3334+
enable ? "Enable" : "Disable", &feature, err);
33383335
return err;
33393336
}
33403337

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
627627

628628
if (lro) {
629629
skb->ip_summed = CHECKSUM_UNNECESSARY;
630+
rq->stats.csum_unnecessary++;
630631
return;
631632
}
632633

@@ -644,7 +645,9 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,
644645
skb->csum_level = 1;
645646
skb->encapsulation = 1;
646647
rq->stats.csum_unnecessary_inner++;
648+
return;
647649
}
650+
rq->stats.csum_unnecessary++;
648651
return;
649652
}
650653
csum_none:

drivers/net/ethernet/mellanox/mlx5/core/en_stats.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct mlx5e_sw_stats {
6868
u64 rx_xdp_drop;
6969
u64 rx_xdp_tx;
7070
u64 rx_xdp_tx_full;
71+
u64 tx_csum_none;
7172
u64 tx_csum_partial;
7273
u64 tx_csum_partial_inner;
7374
u64 tx_queue_stopped;
@@ -108,6 +109,7 @@ static const struct counter_desc sw_stats_desc[] = {
108109
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_drop) },
109110
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_tx) },
110111
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_tx_full) },
112+
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_none) },
111113
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial) },
112114
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_csum_partial_inner) },
113115
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) },
@@ -339,6 +341,7 @@ struct mlx5e_rq_stats {
339341
u64 packets;
340342
u64 bytes;
341343
u64 csum_complete;
344+
u64 csum_unnecessary;
342345
u64 csum_unnecessary_inner;
343346
u64 csum_none;
344347
u64 lro_packets;
@@ -363,6 +366,7 @@ static const struct counter_desc rq_stats_desc[] = {
363366
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) },
364367
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) },
365368
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) },
369+
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary) },
366370
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) },
367371
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) },
368372
{ MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, xdp_drop) },
@@ -392,6 +396,7 @@ struct mlx5e_sq_stats {
392396
u64 tso_bytes;
393397
u64 tso_inner_packets;
394398
u64 tso_inner_bytes;
399+
u64 csum_partial;
395400
u64 csum_partial_inner;
396401
u64 nop;
397402
/* less likely accessed in data path */
@@ -408,6 +413,7 @@ static const struct counter_desc sq_stats_desc[] = {
408413
{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_bytes) },
409414
{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_packets) },
410415
{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, tso_inner_bytes) },
416+
{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial) },
411417
{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial_inner) },
412418
{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, nop) },
413419
{ MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_none) },

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

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,69 @@ static bool csum_offload_supported(struct mlx5e_priv *priv, u32 action, u32 upda
13171317
return true;
13181318
}
13191319

1320+
static bool modify_header_match_supported(struct mlx5_flow_spec *spec,
1321+
struct tcf_exts *exts)
1322+
{
1323+
const struct tc_action *a;
1324+
bool modify_ip_header;
1325+
LIST_HEAD(actions);
1326+
u8 htype, ip_proto;
1327+
void *headers_v;
1328+
u16 ethertype;
1329+
int nkeys, i;
1330+
1331+
headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value, outer_headers);
1332+
ethertype = MLX5_GET(fte_match_set_lyr_2_4, headers_v, ethertype);
1333+
1334+
/* for non-IP we only re-write MACs, so we're okay */
1335+
if (ethertype != ETH_P_IP && ethertype != ETH_P_IPV6)
1336+
goto out_ok;
1337+
1338+
modify_ip_header = false;
1339+
tcf_exts_to_list(exts, &actions);
1340+
list_for_each_entry(a, &actions, list) {
1341+
if (!is_tcf_pedit(a))
1342+
continue;
1343+
1344+
nkeys = tcf_pedit_nkeys(a);
1345+
for (i = 0; i < nkeys; i++) {
1346+
htype = tcf_pedit_htype(a, i);
1347+
if (htype == TCA_PEDIT_KEY_EX_HDR_TYPE_IP4 ||
1348+
htype == TCA_PEDIT_KEY_EX_HDR_TYPE_IP6) {
1349+
modify_ip_header = true;
1350+
break;
1351+
}
1352+
}
1353+
}
1354+
1355+
ip_proto = MLX5_GET(fte_match_set_lyr_2_4, headers_v, ip_protocol);
1356+
if (modify_ip_header && ip_proto != IPPROTO_TCP && ip_proto != IPPROTO_UDP) {
1357+
pr_info("can't offload re-write of ip proto %d\n", ip_proto);
1358+
return false;
1359+
}
1360+
1361+
out_ok:
1362+
return true;
1363+
}
1364+
1365+
static bool actions_match_supported(struct mlx5e_priv *priv,
1366+
struct tcf_exts *exts,
1367+
struct mlx5e_tc_flow_parse_attr *parse_attr,
1368+
struct mlx5e_tc_flow *flow)
1369+
{
1370+
u32 actions;
1371+
1372+
if (flow->flags & MLX5E_TC_FLOW_ESWITCH)
1373+
actions = flow->esw_attr->action;
1374+
else
1375+
actions = flow->nic_attr->action;
1376+
1377+
if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
1378+
return modify_header_match_supported(&parse_attr->spec, exts);
1379+
1380+
return true;
1381+
}
1382+
13201383
static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
13211384
struct mlx5e_tc_flow_parse_attr *parse_attr,
13221385
struct mlx5e_tc_flow *flow)
@@ -1378,6 +1441,9 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
13781441
return -EINVAL;
13791442
}
13801443

1444+
if (!actions_match_supported(priv, exts, parse_attr, flow))
1445+
return -EOPNOTSUPP;
1446+
13811447
return 0;
13821448
}
13831449

@@ -1564,7 +1630,7 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
15641630
break;
15651631
default:
15661632
err = -EOPNOTSUPP;
1567-
goto out;
1633+
goto free_encap;
15681634
}
15691635
fl4.flowi4_tos = tun_key->tos;
15701636
fl4.daddr = tun_key->u.ipv4.dst;
@@ -1573,7 +1639,7 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
15731639
err = mlx5e_route_lookup_ipv4(priv, mirred_dev, &out_dev,
15741640
&fl4, &n, &ttl);
15751641
if (err)
1576-
goto out;
1642+
goto free_encap;
15771643

15781644
/* used by mlx5e_detach_encap to lookup a neigh hash table
15791645
* entry in the neigh hash table when a user deletes a rule
@@ -1590,7 +1656,7 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
15901656
*/
15911657
err = mlx5e_rep_encap_entry_attach(netdev_priv(out_dev), e);
15921658
if (err)
1593-
goto out;
1659+
goto free_encap;
15941660

15951661
read_lock_bh(&n->lock);
15961662
nud_state = n->nud_state;
@@ -1630,8 +1696,9 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
16301696

16311697
destroy_neigh_entry:
16321698
mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e);
1633-
out:
1699+
free_encap:
16341700
kfree(encap_header);
1701+
out:
16351702
if (n)
16361703
neigh_release(n);
16371704
return err;
@@ -1668,7 +1735,7 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv,
16681735
break;
16691736
default:
16701737
err = -EOPNOTSUPP;
1671-
goto out;
1738+
goto free_encap;
16721739
}
16731740

16741741
fl6.flowlabel = ip6_make_flowinfo(RT_TOS(tun_key->tos), tun_key->label);
@@ -1678,7 +1745,7 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv,
16781745
err = mlx5e_route_lookup_ipv6(priv, mirred_dev, &out_dev,
16791746
&fl6, &n, &ttl);
16801747
if (err)
1681-
goto out;
1748+
goto free_encap;
16821749

16831750
/* used by mlx5e_detach_encap to lookup a neigh hash table
16841751
* entry in the neigh hash table when a user deletes a rule
@@ -1695,7 +1762,7 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv,
16951762
*/
16961763
err = mlx5e_rep_encap_entry_attach(netdev_priv(out_dev), e);
16971764
if (err)
1698-
goto out;
1765+
goto free_encap;
16991766

17001767
read_lock_bh(&n->lock);
17011768
nud_state = n->nud_state;
@@ -1736,8 +1803,9 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv,
17361803

17371804
destroy_neigh_entry:
17381805
mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e);
1739-
out:
1806+
free_encap:
17401807
kfree(encap_header);
1808+
out:
17411809
if (n)
17421810
neigh_release(n);
17431811
return err;
@@ -1791,6 +1859,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
17911859
}
17921860
}
17931861

1862+
/* must verify if encap is valid or not */
17941863
if (found)
17951864
goto attach_flow;
17961865

@@ -1817,6 +1886,8 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
18171886
*encap_dev = e->out_dev;
18181887
if (e->flags & MLX5_ENCAP_ENTRY_VALID)
18191888
attr->encap_id = e->encap_id;
1889+
else
1890+
err = -EAGAIN;
18201891

18211892
return err;
18221893

@@ -1934,6 +2005,10 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
19342005

19352006
return -EINVAL;
19362007
}
2008+
2009+
if (!actions_match_supported(priv, exts, parse_attr, flow))
2010+
return -EOPNOTSUPP;
2011+
19372012
return err;
19382013
}
19392014

drivers/net/ethernet/mellanox/mlx5/core/en_tx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ mlx5e_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *skb, struct
193193
sq->stats.csum_partial_inner++;
194194
} else {
195195
eseg->cs_flags |= MLX5_ETH_WQE_L4_CSUM;
196+
sq->stats.csum_partial++;
196197
}
197198
} else
198199
sq->stats.csum_none++;

drivers/net/ethernet/mellanox/mlx5/core/fpga/cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ int mlx5_fpga_access_reg(struct mlx5_core_dev *dev, u8 size, u64 addr,
7171
return 0;
7272
}
7373

74-
int mlx5_fpga_caps(struct mlx5_core_dev *dev, u32 *caps)
74+
int mlx5_fpga_caps(struct mlx5_core_dev *dev)
7575
{
7676
u32 in[MLX5_ST_SZ_DW(fpga_cap)] = {0};
7777

78-
return mlx5_core_access_reg(dev, in, sizeof(in), caps,
78+
return mlx5_core_access_reg(dev, in, sizeof(in), dev->caps.fpga,
7979
MLX5_ST_SZ_BYTES(fpga_cap),
8080
MLX5_REG_FPGA_CAP, 0, 0);
8181
}

drivers/net/ethernet/mellanox/mlx5/core/fpga/cmd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct mlx5_fpga_qp_counters {
6565
u64 rx_total_drop;
6666
};
6767

68-
int mlx5_fpga_caps(struct mlx5_core_dev *dev, u32 *caps);
68+
int mlx5_fpga_caps(struct mlx5_core_dev *dev);
6969
int mlx5_fpga_query(struct mlx5_core_dev *dev, struct mlx5_fpga_query *query);
7070
int mlx5_fpga_ctrl_op(struct mlx5_core_dev *dev, u8 op);
7171
int mlx5_fpga_access_reg(struct mlx5_core_dev *dev, u8 size, u64 addr,

drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ int mlx5_fpga_device_start(struct mlx5_core_dev *mdev)
139139
if (err)
140140
goto out;
141141

142-
err = mlx5_fpga_caps(fdev->mdev,
143-
fdev->mdev->caps.hca_cur[MLX5_CAP_FPGA]);
142+
err = mlx5_fpga_caps(fdev->mdev);
144143
if (err)
145144
goto out;
146145

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
293293
}
294294

295295
if (fte->action & MLX5_FLOW_CONTEXT_ACTION_COUNT) {
296+
int max_list_size = BIT(MLX5_CAP_FLOWTABLE_TYPE(dev,
297+
log_max_flow_counter,
298+
ft->type));
296299
int list_size = 0;
297300

298301
list_for_each_entry(dst, &fte->node.children, node.list) {
@@ -305,12 +308,17 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
305308
in_dests += MLX5_ST_SZ_BYTES(dest_format_struct);
306309
list_size++;
307310
}
311+
if (list_size > max_list_size) {
312+
err = -EINVAL;
313+
goto err_out;
314+
}
308315

309316
MLX5_SET(flow_context, in_flow_context, flow_counter_list_size,
310317
list_size);
311318
}
312319

313320
err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
321+
err_out:
314322
kvfree(in);
315323
return err;
316324
}

0 commit comments

Comments
 (0)