Skip to content

Commit 14676c0

Browse files
committed
Merge tag 'mlx5-fixes-2022-01-06' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes 2022-01-06 This series provides bug fixes to mlx5 driver. Please pull and let me know if there is any problem. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 2950714 + 4f6626b commit 14676c0

File tree

10 files changed

+165
-65
lines changed

10 files changed

+165
-65
lines changed

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

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,12 @@ static void cmd_ent_put(struct mlx5_cmd_work_ent *ent)
148148
if (!refcount_dec_and_test(&ent->refcnt))
149149
return;
150150

151-
if (ent->idx >= 0)
152-
cmd_free_index(ent->cmd, ent->idx);
151+
if (ent->idx >= 0) {
152+
struct mlx5_cmd *cmd = ent->cmd;
153+
154+
cmd_free_index(cmd, ent->idx);
155+
up(ent->page_queue ? &cmd->pages_sem : &cmd->sem);
156+
}
153157

154158
cmd_free_ent(ent);
155159
}
@@ -900,25 +904,6 @@ static bool opcode_allowed(struct mlx5_cmd *cmd, u16 opcode)
900904
return cmd->allowed_opcode == opcode;
901905
}
902906

903-
static int cmd_alloc_index_retry(struct mlx5_cmd *cmd)
904-
{
905-
unsigned long alloc_end = jiffies + msecs_to_jiffies(1000);
906-
int idx;
907-
908-
retry:
909-
idx = cmd_alloc_index(cmd);
910-
if (idx < 0 && time_before(jiffies, alloc_end)) {
911-
/* Index allocation can fail on heavy load of commands. This is a temporary
912-
* situation as the current command already holds the semaphore, meaning that
913-
* another command completion is being handled and it is expected to release
914-
* the entry index soon.
915-
*/
916-
cpu_relax();
917-
goto retry;
918-
}
919-
return idx;
920-
}
921-
922907
bool mlx5_cmd_is_down(struct mlx5_core_dev *dev)
923908
{
924909
return pci_channel_offline(dev->pdev) ||
@@ -946,7 +931,7 @@ static void cmd_work_handler(struct work_struct *work)
946931
sem = ent->page_queue ? &cmd->pages_sem : &cmd->sem;
947932
down(sem);
948933
if (!ent->page_queue) {
949-
alloc_ret = cmd_alloc_index_retry(cmd);
934+
alloc_ret = cmd_alloc_index(cmd);
950935
if (alloc_ret < 0) {
951936
mlx5_core_err_rl(dev, "failed to allocate command entry\n");
952937
if (ent->callback) {
@@ -1602,8 +1587,6 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force
16021587
vector = vec & 0xffffffff;
16031588
for (i = 0; i < (1 << cmd->log_sz); i++) {
16041589
if (test_bit(i, &vector)) {
1605-
struct semaphore *sem;
1606-
16071590
ent = cmd->ent_arr[i];
16081591

16091592
/* if we already completed the command, ignore it */
@@ -1626,10 +1609,6 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force
16261609
dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
16271610
cmd_ent_put(ent);
16281611

1629-
if (ent->page_queue)
1630-
sem = &cmd->pages_sem;
1631-
else
1632-
sem = &cmd->sem;
16331612
ent->ts2 = ktime_get_ns();
16341613
memcpy(ent->out->first.data, ent->lay->out, sizeof(ent->lay->out));
16351614
dump_command(dev, ent, 0);
@@ -1683,7 +1662,6 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force
16831662
*/
16841663
complete(&ent->done);
16851664
}
1686-
up(sem);
16871665
}
16881666
}
16891667
}

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,8 @@ mlx5e_init_fib_work_ipv4(struct mlx5e_priv *priv,
15791579
struct net_device *fib_dev;
15801580

15811581
fen_info = container_of(info, struct fib_entry_notifier_info, info);
1582+
if (fen_info->fi->nh)
1583+
return NULL;
15821584
fib_dev = fib_info_nh(fen_info->fi, 0)->fib_nh_dev;
15831585
if (!fib_dev || fib_dev->netdev_ops != &mlx5e_netdev_ops ||
15841586
fen_info->dst_len != 32)

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/pool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ static int mlx5e_xsk_map_pool(struct mlx5e_priv *priv,
1111
{
1212
struct device *dev = mlx5_core_dma_dev(priv->mdev);
1313

14-
return xsk_pool_dma_map(pool, dev, 0);
14+
return xsk_pool_dma_map(pool, dev, DMA_ATTR_SKIP_CPU_SYNC);
1515
}
1616

1717
static void mlx5e_xsk_unmap_pool(struct mlx5e_priv *priv,
1818
struct xsk_buff_pool *pool)
1919
{
20-
return xsk_pool_dma_unmap(pool, 0);
20+
return xsk_pool_dma_unmap(pool, DMA_ATTR_SKIP_CPU_SYNC);
2121
}
2222

2323
static int mlx5e_xsk_get_pools(struct mlx5e_xsk *xsk)

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4789,15 +4789,22 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
47894789
}
47904790

47914791
if (mlx5_vxlan_allowed(mdev->vxlan) || mlx5_geneve_tx_allowed(mdev)) {
4792-
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
4793-
netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL;
4794-
netdev->vlan_features |= NETIF_F_GSO_UDP_TUNNEL;
4792+
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL |
4793+
NETIF_F_GSO_UDP_TUNNEL_CSUM;
4794+
netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL |
4795+
NETIF_F_GSO_UDP_TUNNEL_CSUM;
4796+
netdev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM;
4797+
netdev->vlan_features |= NETIF_F_GSO_UDP_TUNNEL |
4798+
NETIF_F_GSO_UDP_TUNNEL_CSUM;
47954799
}
47964800

47974801
if (mlx5e_tunnel_proto_supported_tx(mdev, IPPROTO_GRE)) {
4798-
netdev->hw_features |= NETIF_F_GSO_GRE;
4799-
netdev->hw_enc_features |= NETIF_F_GSO_GRE;
4800-
netdev->gso_partial_features |= NETIF_F_GSO_GRE;
4802+
netdev->hw_features |= NETIF_F_GSO_GRE |
4803+
NETIF_F_GSO_GRE_CSUM;
4804+
netdev->hw_enc_features |= NETIF_F_GSO_GRE |
4805+
NETIF_F_GSO_GRE_CSUM;
4806+
netdev->gso_partial_features |= NETIF_F_GSO_GRE |
4807+
NETIF_F_GSO_GRE_CSUM;
48014808
}
48024809

48034810
if (mlx5e_tunnel_proto_supported_tx(mdev, IPPROTO_IPIP)) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "fs_core.h"
5151
#include "lib/mlx5.h"
5252
#include "lib/devcom.h"
53+
#include "lib/vxlan.h"
5354
#define CREATE_TRACE_POINTS
5455
#include "diag/en_rep_tracepoint.h"
5556
#include "en_accel/ipsec.h"
@@ -1027,6 +1028,7 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
10271028
rtnl_lock();
10281029
if (netif_running(netdev))
10291030
mlx5e_open(netdev);
1031+
udp_tunnel_nic_reset_ntf(priv->netdev);
10301032
netif_device_attach(netdev);
10311033
rtnl_unlock();
10321034
}
@@ -1048,6 +1050,7 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
10481050
mlx5_notifier_unregister(mdev, &priv->events_nb);
10491051
mlx5e_rep_tc_disable(priv);
10501052
mlx5_lag_remove_netdev(mdev, priv->netdev);
1053+
mlx5_vxlan_reset_to_default(mdev->vxlan);
10511054
}
10521055

10531056
static MLX5E_DEFINE_STATS_GRP(sw_rep, 0);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ static inline int mlx5e_page_alloc_pool(struct mlx5e_rq *rq,
278278
if (unlikely(!dma_info->page))
279279
return -ENOMEM;
280280

281-
dma_info->addr = dma_map_page(rq->pdev, dma_info->page, 0,
282-
PAGE_SIZE, rq->buff.map_dir);
281+
dma_info->addr = dma_map_page_attrs(rq->pdev, dma_info->page, 0, PAGE_SIZE,
282+
rq->buff.map_dir, DMA_ATTR_SKIP_CPU_SYNC);
283283
if (unlikely(dma_mapping_error(rq->pdev, dma_info->addr))) {
284284
page_pool_recycle_direct(rq->page_pool, dma_info->page);
285285
dma_info->page = NULL;
@@ -300,7 +300,8 @@ static inline int mlx5e_page_alloc(struct mlx5e_rq *rq,
300300

301301
void mlx5e_page_dma_unmap(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info)
302302
{
303-
dma_unmap_page(rq->pdev, dma_info->addr, PAGE_SIZE, rq->buff.map_dir);
303+
dma_unmap_page_attrs(rq->pdev, dma_info->addr, PAGE_SIZE, rq->buff.map_dir,
304+
DMA_ATTR_SKIP_CPU_SYNC);
304305
}
305306

306307
void mlx5e_page_release_dynamic(struct mlx5e_rq *rq,

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

Lines changed: 116 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,111 @@ u8 mlx5e_tc_get_ip_version(struct mlx5_flow_spec *spec, bool outer)
19491949
return ip_version;
19501950
}
19511951

1952+
/* Tunnel device follows RFC 6040, see include/net/inet_ecn.h.
1953+
* And changes inner ip_ecn depending on inner and outer ip_ecn as follows:
1954+
* +---------+----------------------------------------+
1955+
* |Arriving | Arriving Outer Header |
1956+
* | Inner +---------+---------+---------+----------+
1957+
* | Header | Not-ECT | ECT(0) | ECT(1) | CE |
1958+
* +---------+---------+---------+---------+----------+
1959+
* | Not-ECT | Not-ECT | Not-ECT | Not-ECT | <drop> |
1960+
* | ECT(0) | ECT(0) | ECT(0) | ECT(1) | CE* |
1961+
* | ECT(1) | ECT(1) | ECT(1) | ECT(1)* | CE* |
1962+
* | CE | CE | CE | CE | CE |
1963+
* +---------+---------+---------+---------+----------+
1964+
*
1965+
* Tc matches on inner after decapsulation on tunnel device, but hw offload matches
1966+
* the inner ip_ecn value before hardware decap action.
1967+
*
1968+
* Cells marked are changed from original inner packet ip_ecn value during decap, and
1969+
* so matching those values on inner ip_ecn before decap will fail.
1970+
*
1971+
* The following helper allows offload when inner ip_ecn won't be changed by outer ip_ecn,
1972+
* except for the outer ip_ecn = CE, where in all cases inner ip_ecn will be changed to CE,
1973+
* and such we can drop the inner ip_ecn=CE match.
1974+
*/
1975+
1976+
static int mlx5e_tc_verify_tunnel_ecn(struct mlx5e_priv *priv,
1977+
struct flow_cls_offload *f,
1978+
bool *match_inner_ecn)
1979+
{
1980+
u8 outer_ecn_mask = 0, outer_ecn_key = 0, inner_ecn_mask = 0, inner_ecn_key = 0;
1981+
struct flow_rule *rule = flow_cls_offload_flow_rule(f);
1982+
struct netlink_ext_ack *extack = f->common.extack;
1983+
struct flow_match_ip match;
1984+
1985+
*match_inner_ecn = true;
1986+
1987+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_IP)) {
1988+
flow_rule_match_enc_ip(rule, &match);
1989+
outer_ecn_key = match.key->tos & INET_ECN_MASK;
1990+
outer_ecn_mask = match.mask->tos & INET_ECN_MASK;
1991+
}
1992+
1993+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IP)) {
1994+
flow_rule_match_ip(rule, &match);
1995+
inner_ecn_key = match.key->tos & INET_ECN_MASK;
1996+
inner_ecn_mask = match.mask->tos & INET_ECN_MASK;
1997+
}
1998+
1999+
if (outer_ecn_mask != 0 && outer_ecn_mask != INET_ECN_MASK) {
2000+
NL_SET_ERR_MSG_MOD(extack, "Partial match on enc_tos ecn bits isn't supported");
2001+
netdev_warn(priv->netdev, "Partial match on enc_tos ecn bits isn't supported");
2002+
return -EOPNOTSUPP;
2003+
}
2004+
2005+
if (!outer_ecn_mask) {
2006+
if (!inner_ecn_mask)
2007+
return 0;
2008+
2009+
NL_SET_ERR_MSG_MOD(extack,
2010+
"Matching on tos ecn bits without also matching enc_tos ecn bits isn't supported");
2011+
netdev_warn(priv->netdev,
2012+
"Matching on tos ecn bits without also matching enc_tos ecn bits isn't supported");
2013+
return -EOPNOTSUPP;
2014+
}
2015+
2016+
if (inner_ecn_mask && inner_ecn_mask != INET_ECN_MASK) {
2017+
NL_SET_ERR_MSG_MOD(extack,
2018+
"Partial match on tos ecn bits with match on enc_tos ecn bits isn't supported");
2019+
netdev_warn(priv->netdev,
2020+
"Partial match on tos ecn bits with match on enc_tos ecn bits isn't supported");
2021+
return -EOPNOTSUPP;
2022+
}
2023+
2024+
if (!inner_ecn_mask)
2025+
return 0;
2026+
2027+
/* Both inner and outer have full mask on ecn */
2028+
2029+
if (outer_ecn_key == INET_ECN_ECT_1) {
2030+
/* inner ecn might change by DECAP action */
2031+
2032+
NL_SET_ERR_MSG_MOD(extack, "Match on enc_tos ecn = ECT(1) isn't supported");
2033+
netdev_warn(priv->netdev, "Match on enc_tos ecn = ECT(1) isn't supported");
2034+
return -EOPNOTSUPP;
2035+
}
2036+
2037+
if (outer_ecn_key != INET_ECN_CE)
2038+
return 0;
2039+
2040+
if (inner_ecn_key != INET_ECN_CE) {
2041+
/* Can't happen in software, as packet ecn will be changed to CE after decap */
2042+
NL_SET_ERR_MSG_MOD(extack,
2043+
"Match on tos enc_tos ecn = CE while match on tos ecn != CE isn't supported");
2044+
netdev_warn(priv->netdev,
2045+
"Match on tos enc_tos ecn = CE while match on tos ecn != CE isn't supported");
2046+
return -EOPNOTSUPP;
2047+
}
2048+
2049+
/* outer ecn = CE, inner ecn = CE, as decap will change inner ecn to CE in anycase,
2050+
* drop match on inner ecn
2051+
*/
2052+
*match_inner_ecn = false;
2053+
2054+
return 0;
2055+
}
2056+
19522057
static int parse_tunnel_attr(struct mlx5e_priv *priv,
19532058
struct mlx5e_tc_flow *flow,
19542059
struct mlx5_flow_spec *spec,
@@ -2144,6 +2249,7 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,
21442249
struct flow_rule *rule = flow_cls_offload_flow_rule(f);
21452250
struct flow_dissector *dissector = rule->match.dissector;
21462251
enum fs_flow_table_type fs_type;
2252+
bool match_inner_ecn = true;
21472253
u16 addr_type = 0;
21482254
u8 ip_proto = 0;
21492255
u8 *match_level;
@@ -2197,6 +2303,10 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,
21972303
headers_c = get_match_inner_headers_criteria(spec);
21982304
headers_v = get_match_inner_headers_value(spec);
21992305
}
2306+
2307+
err = mlx5e_tc_verify_tunnel_ecn(priv, f, &match_inner_ecn);
2308+
if (err)
2309+
return err;
22002310
}
22012311

22022312
err = mlx5e_flower_parse_meta(filter_dev, f);
@@ -2420,10 +2530,12 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,
24202530
struct flow_match_ip match;
24212531

24222532
flow_rule_match_ip(rule, &match);
2423-
MLX5_SET(fte_match_set_lyr_2_4, headers_c, ip_ecn,
2424-
match.mask->tos & 0x3);
2425-
MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn,
2426-
match.key->tos & 0x3);
2533+
if (match_inner_ecn) {
2534+
MLX5_SET(fte_match_set_lyr_2_4, headers_c, ip_ecn,
2535+
match.mask->tos & 0x3);
2536+
MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn,
2537+
match.key->tos & 0x3);
2538+
}
24272539

24282540
MLX5_SET(fte_match_set_lyr_2_4, headers_c, ip_dscp,
24292541
match.mask->tos >> 2);

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,26 +295,28 @@ esw_setup_chain_src_port_rewrite(struct mlx5_flow_destination *dest,
295295
int *i)
296296
{
297297
struct mlx5_esw_flow_attr *esw_attr = attr->esw_attr;
298-
int j, err;
298+
int err;
299299

300300
if (!(attr->flags & MLX5_ESW_ATTR_FLAG_SRC_REWRITE))
301301
return -EOPNOTSUPP;
302302

303-
for (j = esw_attr->split_count; j < esw_attr->out_count; j++, (*i)++) {
304-
err = esw_setup_chain_dest(dest, flow_act, chains, attr->dest_chain, 1, 0, *i);
305-
if (err)
306-
goto err_setup_chain;
303+
/* flow steering cannot handle more than one dest with the same ft
304+
* in a single flow
305+
*/
306+
if (esw_attr->out_count - esw_attr->split_count > 1)
307+
return -EOPNOTSUPP;
307308

308-
if (esw_attr->dests[j].pkt_reformat) {
309-
flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
310-
flow_act->pkt_reformat = esw_attr->dests[j].pkt_reformat;
311-
}
309+
err = esw_setup_chain_dest(dest, flow_act, chains, attr->dest_chain, 1, 0, *i);
310+
if (err)
311+
return err;
312+
313+
if (esw_attr->dests[esw_attr->split_count].pkt_reformat) {
314+
flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
315+
flow_act->pkt_reformat = esw_attr->dests[esw_attr->split_count].pkt_reformat;
312316
}
313-
return 0;
317+
(*i)++;
314318

315-
err_setup_chain:
316-
esw_put_dest_tables_loop(esw, attr, esw_attr->split_count, j);
317-
return err;
319+
return 0;
318320
}
319321

320322
static void esw_cleanup_chain_src_port_rewrite(struct mlx5_eswitch *esw,

drivers/net/ethernet/mellanox/mlx5/core/lag/mp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,8 @@ static int mlx5_lag_fib_event(struct notifier_block *nb,
268268
fen_info = container_of(info, struct fib_entry_notifier_info,
269269
info);
270270
fi = fen_info->fi;
271-
if (fi->nh) {
272-
NL_SET_ERR_MSG_MOD(info->extack, "IPv4 route with nexthop objects is not supported");
273-
return notifier_from_errno(-EINVAL);
274-
}
271+
if (fi->nh)
272+
return NOTIFY_DONE;
275273
fib_dev = fib_info_nh(fen_info->fi, 0)->fib_nh_dev;
276274
if (fib_dev != ldev->pf[MLX5_LAG_P1].netdev &&
277275
fib_dev != ldev->pf[MLX5_LAG_P2].netdev) {

drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ bool mlx5_sf_dev_allocated(const struct mlx5_core_dev *dev)
3030
{
3131
struct mlx5_sf_dev_table *table = dev->priv.sf_dev_table;
3232

33-
if (!mlx5_sf_dev_supported(dev))
34-
return false;
35-
36-
return !xa_empty(&table->devices);
33+
return table && !xa_empty(&table->devices);
3734
}
3835

3936
static ssize_t sfnum_show(struct device *dev, struct device_attribute *attr, char *buf)

0 commit comments

Comments
 (0)