Skip to content

Commit 0dbcac3

Browse files
committed
Merge tag 'mlx5-fixes-2023-06-16' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-fixes-2023-06-16 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 92717c2 + a128f9d commit 0dbcac3

File tree

15 files changed

+163
-36
lines changed

15 files changed

+163
-36
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,8 @@ static void mlx5e_rx_compute_wqe_bulk_params(struct mlx5e_params *params,
732732
static int mlx5e_build_rq_frags_info(struct mlx5_core_dev *mdev,
733733
struct mlx5e_params *params,
734734
struct mlx5e_xsk_param *xsk,
735-
struct mlx5e_rq_frags_info *info)
735+
struct mlx5e_rq_frags_info *info,
736+
u32 *xdp_frag_size)
736737
{
737738
u32 byte_count = MLX5E_SW2HW_MTU(params, params->sw_mtu);
738739
int frag_size_max = DEFAULT_FRAG_SIZE;
@@ -845,6 +846,8 @@ static int mlx5e_build_rq_frags_info(struct mlx5_core_dev *mdev,
845846

846847
info->log_num_frags = order_base_2(info->num_frags);
847848

849+
*xdp_frag_size = info->num_frags > 1 && params->xdp_prog ? PAGE_SIZE : 0;
850+
848851
return 0;
849852
}
850853

@@ -989,7 +992,8 @@ int mlx5e_build_rq_param(struct mlx5_core_dev *mdev,
989992
}
990993
default: /* MLX5_WQ_TYPE_CYCLIC */
991994
MLX5_SET(wq, wq, log_wq_sz, params->log_rq_mtu_frames);
992-
err = mlx5e_build_rq_frags_info(mdev, params, xsk, &param->frags_info);
995+
err = mlx5e_build_rq_frags_info(mdev, params, xsk, &param->frags_info,
996+
&param->xdp_frag_size);
993997
if (err)
994998
return err;
995999
ndsegs = param->frags_info.num_frags;

drivers/net/ethernet/mellanox/mlx5/core/en/params.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct mlx5e_rq_param {
2424
u32 rqc[MLX5_ST_SZ_DW(rqc)];
2525
struct mlx5_wq_param wq;
2626
struct mlx5e_rq_frags_info frags_info;
27+
u32 xdp_frag_size;
2728
};
2829

2930
struct mlx5e_sq_param {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,8 @@ void
20212021
mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv,
20222022
struct mlx5_flow_attr *attr)
20232023
{
2024+
if (!attr->ct_attr.ft) /* no ct action, return */
2025+
return;
20242026
if (!attr->ct_attr.nf_ft) /* means only ct clear action, and not ct_clear,ct() */
20252027
return;
20262028

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int mlx5e_init_xsk_rq(struct mlx5e_channel *c,
8686
if (err)
8787
return err;
8888

89-
return xdp_rxq_info_reg(&rq->xdp_rxq, rq->netdev, rq_xdp_ix, 0);
89+
return xdp_rxq_info_reg(&rq->xdp_rxq, rq->netdev, rq_xdp_ix, c->napi.napi_id);
9090
}
9191

9292
static int mlx5e_open_xsk_rq(struct mlx5e_channel *c, struct mlx5e_params *params,

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,19 @@ static void mlx5e_ipsec_handle_tx_limit(struct work_struct *_work)
6161
struct mlx5e_ipsec_sa_entry *sa_entry = dwork->sa_entry;
6262
struct xfrm_state *x = sa_entry->x;
6363

64-
spin_lock(&x->lock);
64+
if (sa_entry->attrs.drop)
65+
return;
66+
67+
spin_lock_bh(&x->lock);
6568
xfrm_state_check_expire(x);
6669
if (x->km.state == XFRM_STATE_EXPIRED) {
6770
sa_entry->attrs.drop = true;
68-
mlx5e_accel_ipsec_fs_modify(sa_entry);
69-
}
70-
spin_unlock(&x->lock);
71+
spin_unlock_bh(&x->lock);
7172

72-
if (sa_entry->attrs.drop)
73+
mlx5e_accel_ipsec_fs_modify(sa_entry);
7374
return;
75+
}
76+
spin_unlock_bh(&x->lock);
7477

7578
queue_delayed_work(sa_entry->ipsec->wq, &dwork->dwork,
7679
MLX5_IPSEC_RESCHED);
@@ -1040,11 +1043,17 @@ static int mlx5e_xfrm_add_policy(struct xfrm_policy *x,
10401043
return err;
10411044
}
10421045

1043-
static void mlx5e_xfrm_free_policy(struct xfrm_policy *x)
1046+
static void mlx5e_xfrm_del_policy(struct xfrm_policy *x)
10441047
{
10451048
struct mlx5e_ipsec_pol_entry *pol_entry = to_ipsec_pol_entry(x);
10461049

10471050
mlx5e_accel_ipsec_fs_del_pol(pol_entry);
1051+
}
1052+
1053+
static void mlx5e_xfrm_free_policy(struct xfrm_policy *x)
1054+
{
1055+
struct mlx5e_ipsec_pol_entry *pol_entry = to_ipsec_pol_entry(x);
1056+
10481057
kfree(pol_entry);
10491058
}
10501059

@@ -1065,6 +1074,7 @@ static const struct xfrmdev_ops mlx5e_ipsec_packet_xfrmdev_ops = {
10651074

10661075
.xdo_dev_state_update_curlft = mlx5e_xfrm_update_curlft,
10671076
.xdo_dev_policy_add = mlx5e_xfrm_add_policy,
1077+
.xdo_dev_policy_delete = mlx5e_xfrm_del_policy,
10681078
.xdo_dev_policy_free = mlx5e_xfrm_free_policy,
10691079
};
10701080

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,17 @@ static void mlx5e_ipsec_update_esn_state(struct mlx5e_ipsec_sa_entry *sa_entry,
305305
}
306306

307307
mlx5e_ipsec_build_accel_xfrm_attrs(sa_entry, &attrs);
308+
309+
/* It is safe to execute the modify below unlocked since the only flows
310+
* that could affect this HW object, are create, destroy and this work.
311+
*
312+
* Creation flow can't co-exist with this modify work, the destruction
313+
* flow would cancel this work, and this work is a single entity that
314+
* can't conflict with it self.
315+
*/
316+
spin_unlock_bh(&sa_entry->x->lock);
308317
mlx5_accel_esp_modify_xfrm(sa_entry, &attrs);
318+
spin_lock_bh(&sa_entry->x->lock);
309319

310320
data.data_offset_condition_operand =
311321
MLX5_IPSEC_ASO_REMOVE_FLOW_PKT_CNT_OFFSET;
@@ -431,7 +441,7 @@ static void mlx5e_ipsec_handle_event(struct work_struct *_work)
431441
aso = sa_entry->ipsec->aso;
432442
attrs = &sa_entry->attrs;
433443

434-
spin_lock(&sa_entry->x->lock);
444+
spin_lock_bh(&sa_entry->x->lock);
435445
ret = mlx5e_ipsec_aso_query(sa_entry, NULL);
436446
if (ret)
437447
goto unlock;
@@ -447,7 +457,7 @@ static void mlx5e_ipsec_handle_event(struct work_struct *_work)
447457
mlx5e_ipsec_handle_limits(sa_entry);
448458

449459
unlock:
450-
spin_unlock(&sa_entry->x->lock);
460+
spin_unlock_bh(&sa_entry->x->lock);
451461
kfree(work);
452462
}
453463

@@ -596,7 +606,8 @@ int mlx5e_ipsec_aso_query(struct mlx5e_ipsec_sa_entry *sa_entry,
596606
do {
597607
ret = mlx5_aso_poll_cq(aso->aso, false);
598608
if (ret)
599-
usleep_range(2, 10);
609+
/* We are in atomic context */
610+
udelay(10);
600611
} while (ret && time_is_after_jiffies(expires));
601612
spin_unlock_bh(&aso->lock);
602613
return ret;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ static void mlx5e_free_mpwqe_rq_drop_page(struct mlx5e_rq *rq)
641641
}
642642

643643
static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *params,
644-
struct mlx5e_rq *rq)
644+
u32 xdp_frag_size, struct mlx5e_rq *rq)
645645
{
646646
struct mlx5_core_dev *mdev = c->mdev;
647647
int err;
@@ -665,7 +665,8 @@ static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param
665665
if (err)
666666
return err;
667667

668-
return xdp_rxq_info_reg(&rq->xdp_rxq, rq->netdev, rq->ix, c->napi.napi_id);
668+
return __xdp_rxq_info_reg(&rq->xdp_rxq, rq->netdev, rq->ix, c->napi.napi_id,
669+
xdp_frag_size);
669670
}
670671

671672
static int mlx5_rq_shampo_alloc(struct mlx5_core_dev *mdev,
@@ -2240,7 +2241,7 @@ static int mlx5e_open_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param
22402241
{
22412242
int err;
22422243

2243-
err = mlx5e_init_rxq_rq(c, params, &c->rq);
2244+
err = mlx5e_init_rxq_rq(c, params, rq_params->xdp_frag_size, &c->rq);
22442245
if (err)
22452246
return err;
22462247

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,7 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
14391439
mlx5e_hairpin_flow_del(priv, flow);
14401440

14411441
free_flow_post_acts(flow);
1442+
mlx5_tc_ct_delete_flow(get_ct_priv(flow->priv), attr);
14421443

14431444
kvfree(attr->parse_attr);
14441445
kfree(flow->attr);

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

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,11 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
511511
struct mlx5_flow_rule *dst;
512512
void *in_flow_context, *vlan;
513513
void *in_match_value;
514+
int reformat_id = 0;
514515
unsigned int inlen;
515516
int dst_cnt_size;
517+
u32 *in, action;
516518
void *in_dests;
517-
u32 *in;
518519
int err;
519520

520521
if (mlx5_set_extended_dest(dev, fte, &extended_dest))
@@ -553,22 +554,42 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
553554

554555
MLX5_SET(flow_context, in_flow_context, extended_destination,
555556
extended_dest);
556-
if (extended_dest) {
557-
u32 action;
558557

559-
action = fte->action.action &
560-
~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
561-
MLX5_SET(flow_context, in_flow_context, action, action);
562-
} else {
563-
MLX5_SET(flow_context, in_flow_context, action,
564-
fte->action.action);
565-
if (fte->action.pkt_reformat)
566-
MLX5_SET(flow_context, in_flow_context, packet_reformat_id,
567-
fte->action.pkt_reformat->id);
558+
action = fte->action.action;
559+
if (extended_dest)
560+
action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
561+
562+
MLX5_SET(flow_context, in_flow_context, action, action);
563+
564+
if (!extended_dest && fte->action.pkt_reformat) {
565+
struct mlx5_pkt_reformat *pkt_reformat = fte->action.pkt_reformat;
566+
567+
if (pkt_reformat->owner == MLX5_FLOW_RESOURCE_OWNER_SW) {
568+
reformat_id = mlx5_fs_dr_action_get_pkt_reformat_id(pkt_reformat);
569+
if (reformat_id < 0) {
570+
mlx5_core_err(dev,
571+
"Unsupported SW-owned pkt_reformat type (%d) in FW-owned table\n",
572+
pkt_reformat->reformat_type);
573+
err = reformat_id;
574+
goto err_out;
575+
}
576+
} else {
577+
reformat_id = fte->action.pkt_reformat->id;
578+
}
568579
}
569-
if (fte->action.modify_hdr)
580+
581+
MLX5_SET(flow_context, in_flow_context, packet_reformat_id, (u32)reformat_id);
582+
583+
if (fte->action.modify_hdr) {
584+
if (fte->action.modify_hdr->owner == MLX5_FLOW_RESOURCE_OWNER_SW) {
585+
mlx5_core_err(dev, "Can't use SW-owned modify_hdr in FW-owned table\n");
586+
err = -EOPNOTSUPP;
587+
goto err_out;
588+
}
589+
570590
MLX5_SET(flow_context, in_flow_context, modify_header_id,
571591
fte->action.modify_hdr->id);
592+
}
572593

573594
MLX5_SET(flow_context, in_flow_context, encrypt_decrypt_type,
574595
fte->action.crypto.type);
@@ -885,6 +906,8 @@ static int mlx5_cmd_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns,
885906

886907
pkt_reformat->id = MLX5_GET(alloc_packet_reformat_context_out,
887908
out, packet_reformat_id);
909+
pkt_reformat->owner = MLX5_FLOW_RESOURCE_OWNER_FW;
910+
888911
kfree(in);
889912
return err;
890913
}
@@ -969,6 +992,7 @@ static int mlx5_cmd_modify_header_alloc(struct mlx5_flow_root_namespace *ns,
969992
err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
970993

971994
modify_hdr->id = MLX5_GET(alloc_modify_header_context_out, out, modify_header_id);
995+
modify_hdr->owner = MLX5_FLOW_RESOURCE_OWNER_FW;
972996
kfree(in);
973997
return err;
974998
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@ struct mlx5_flow_definer {
5454
u32 id;
5555
};
5656

57+
enum mlx5_flow_resource_owner {
58+
MLX5_FLOW_RESOURCE_OWNER_FW,
59+
MLX5_FLOW_RESOURCE_OWNER_SW,
60+
};
61+
5762
struct mlx5_modify_hdr {
5863
enum mlx5_flow_namespace_type ns_type;
64+
enum mlx5_flow_resource_owner owner;
5965
union {
6066
struct mlx5_fs_dr_action action;
6167
u32 id;
@@ -65,6 +71,7 @@ struct mlx5_modify_hdr {
6571
struct mlx5_pkt_reformat {
6672
enum mlx5_flow_namespace_type ns_type;
6773
int reformat_type; /* from mlx5_ifc */
74+
enum mlx5_flow_resource_owner owner;
6875
union {
6976
struct mlx5_fs_dr_action action;
7077
u32 id;

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

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,22 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int function_id,
126126
return ret;
127127
}
128128

129-
static void irq_release(struct mlx5_irq *irq)
129+
/* mlx5_system_free_irq - Free an IRQ
130+
* @irq: IRQ to free
131+
*
132+
* Free the IRQ and other resources such as rmap from the system.
133+
* BUT doesn't free or remove reference from mlx5.
134+
* This function is very important for the shutdown flow, where we need to
135+
* cleanup system resoruces but keep mlx5 objects alive,
136+
* see mlx5_irq_table_free_irqs().
137+
*/
138+
static void mlx5_system_free_irq(struct mlx5_irq *irq)
130139
{
131140
struct mlx5_irq_pool *pool = irq->pool;
132141
#ifdef CONFIG_RFS_ACCEL
133142
struct cpu_rmap *rmap;
134143
#endif
135144

136-
xa_erase(&pool->irqs, irq->pool_index);
137145
/* free_irq requires that affinity_hint and rmap will be cleared before
138146
* calling it. To satisfy this requirement, we call
139147
* irq_cpu_rmap_remove() to remove the notifier
@@ -145,10 +153,18 @@ static void irq_release(struct mlx5_irq *irq)
145153
irq_cpu_rmap_remove(rmap, irq->map.virq);
146154
#endif
147155

148-
free_cpumask_var(irq->mask);
149156
free_irq(irq->map.virq, &irq->nh);
150157
if (irq->map.index && pci_msix_can_alloc_dyn(pool->dev->pdev))
151158
pci_msix_free_irq(pool->dev->pdev, irq->map);
159+
}
160+
161+
static void irq_release(struct mlx5_irq *irq)
162+
{
163+
struct mlx5_irq_pool *pool = irq->pool;
164+
165+
xa_erase(&pool->irqs, irq->pool_index);
166+
mlx5_system_free_irq(irq);
167+
free_cpumask_var(irq->mask);
152168
kfree(irq);
153169
}
154170

@@ -565,15 +581,21 @@ void mlx5_irqs_release_vectors(struct mlx5_irq **irqs, int nirqs)
565581
int mlx5_irqs_request_vectors(struct mlx5_core_dev *dev, u16 *cpus, int nirqs,
566582
struct mlx5_irq **irqs, struct cpu_rmap **rmap)
567583
{
584+
struct mlx5_irq_table *table = mlx5_irq_table_get(dev);
585+
struct mlx5_irq_pool *pool = table->pcif_pool;
568586
struct irq_affinity_desc af_desc;
569587
struct mlx5_irq *irq;
588+
int offset = 1;
570589
int i;
571590

591+
if (!pool->xa_num_irqs.max)
592+
offset = 0;
593+
572594
af_desc.is_managed = false;
573595
for (i = 0; i < nirqs; i++) {
574596
cpumask_clear(&af_desc.mask);
575597
cpumask_set_cpu(cpus[i], &af_desc.mask);
576-
irq = mlx5_irq_request(dev, i + 1, &af_desc, rmap);
598+
irq = mlx5_irq_request(dev, i + offset, &af_desc, rmap);
577599
if (IS_ERR(irq))
578600
break;
579601
irqs[i] = irq;
@@ -699,7 +721,8 @@ static void mlx5_irq_pool_free_irqs(struct mlx5_irq_pool *pool)
699721
unsigned long index;
700722

701723
xa_for_each(&pool->irqs, index, irq)
702-
free_irq(irq->map.virq, &irq->nh);
724+
mlx5_system_free_irq(irq);
725+
703726
}
704727

705728
static void mlx5_irq_pools_free_irqs(struct mlx5_irq_table *table)

0 commit comments

Comments
 (0)