Skip to content

Commit c034ff2

Browse files
committed
Merge tag 'mlx5-fixes-2022-05-31' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes 2022-05-31 This series provides bug fixes to mlx5 driver. Please pull and let me know if there is any problem. * tag 'mlx5-fixes-2022-05-31' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux: net/mlx5: Fix mlx5_get_next_dev() peer device matching net/mlx5e: Update netdev features after changing XDP state net/mlx5: correct ECE offset in query qp output net/mlx5e: Disable softirq in mlx5e_activate_rq to avoid race condition net/mlx5: CT: Fix header-rewrite re-use for tupels net/mlx5e: TC NIC mode, fix tc chains miss table net/mlx5: Don't use already freed action pointer ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 11049c9 + 1c5de09 commit c034ff2

File tree

14 files changed

+115
-41
lines changed

14 files changed

+115
-41
lines changed

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

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -571,18 +571,32 @@ static int _next_phys_dev(struct mlx5_core_dev *mdev,
571571
return 1;
572572
}
573573

574+
static void *pci_get_other_drvdata(struct device *this, struct device *other)
575+
{
576+
if (this->driver != other->driver)
577+
return NULL;
578+
579+
return pci_get_drvdata(to_pci_dev(other));
580+
}
581+
574582
static int next_phys_dev(struct device *dev, const void *data)
575583
{
576-
struct mlx5_adev *madev = container_of(dev, struct mlx5_adev, adev.dev);
577-
struct mlx5_core_dev *mdev = madev->mdev;
584+
struct mlx5_core_dev *mdev, *this = (struct mlx5_core_dev *)data;
585+
586+
mdev = pci_get_other_drvdata(this->device, dev);
587+
if (!mdev)
588+
return 0;
578589

579590
return _next_phys_dev(mdev, data);
580591
}
581592

582593
static int next_phys_dev_lag(struct device *dev, const void *data)
583594
{
584-
struct mlx5_adev *madev = container_of(dev, struct mlx5_adev, adev.dev);
585-
struct mlx5_core_dev *mdev = madev->mdev;
595+
struct mlx5_core_dev *mdev, *this = (struct mlx5_core_dev *)data;
596+
597+
mdev = pci_get_other_drvdata(this->device, dev);
598+
if (!mdev)
599+
return 0;
586600

587601
if (!MLX5_CAP_GEN(mdev, vport_group_manager) ||
588602
!MLX5_CAP_GEN(mdev, lag_master) ||
@@ -596,19 +610,17 @@ static int next_phys_dev_lag(struct device *dev, const void *data)
596610
static struct mlx5_core_dev *mlx5_get_next_dev(struct mlx5_core_dev *dev,
597611
int (*match)(struct device *dev, const void *data))
598612
{
599-
struct auxiliary_device *adev;
600-
struct mlx5_adev *madev;
613+
struct device *next;
601614

602615
if (!mlx5_core_is_pf(dev))
603616
return NULL;
604617

605-
adev = auxiliary_find_device(NULL, dev, match);
606-
if (!adev)
618+
next = bus_find_device(&pci_bus_type, NULL, dev, match);
619+
if (!next)
607620
return NULL;
608621

609-
madev = container_of(adev, struct mlx5_adev, adev);
610-
put_device(&adev->dev);
611-
return madev->mdev;
622+
put_device(next);
623+
return pci_get_drvdata(to_pci_dev(next));
612624
}
613625

614626
/* Must be called with intf_mutex held */

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ struct mlx5e_rq {
764764
u8 wq_type;
765765
u32 rqn;
766766
struct mlx5_core_dev *mdev;
767+
struct mlx5e_channel *channel;
767768
u32 umr_mkey;
768769
struct mlx5e_dma_info wqe_overflow;
769770

@@ -1076,6 +1077,9 @@ void mlx5e_close_cq(struct mlx5e_cq *cq);
10761077
int mlx5e_open_locked(struct net_device *netdev);
10771078
int mlx5e_close_locked(struct net_device *netdev);
10781079

1080+
void mlx5e_trigger_napi_icosq(struct mlx5e_channel *c);
1081+
void mlx5e_trigger_napi_sched(struct napi_struct *napi);
1082+
10791083
int mlx5e_open_channels(struct mlx5e_priv *priv,
10801084
struct mlx5e_channels *chs);
10811085
void mlx5e_close_channels(struct mlx5e_channels *chs);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct mlx5e_post_act;
1212
enum {
1313
MLX5E_TC_FT_LEVEL = 0,
1414
MLX5E_TC_TTC_FT_LEVEL,
15+
MLX5E_TC_MISS_LEVEL,
1516
};
1617

1718
struct mlx5e_tc_table {
@@ -20,6 +21,7 @@ struct mlx5e_tc_table {
2021
*/
2122
struct mutex t_lock;
2223
struct mlx5_flow_table *t;
24+
struct mlx5_flow_table *miss_t;
2325
struct mlx5_fs_chains *chains;
2426
struct mlx5e_post_act *post_act;
2527

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ void mlx5e_ptp_activate_channel(struct mlx5e_ptp *c)
736736
if (test_bit(MLX5E_PTP_STATE_RX, c->state)) {
737737
mlx5e_ptp_rx_set_fs(c->priv);
738738
mlx5e_activate_rq(&c->rq);
739+
mlx5e_trigger_napi_sched(&c->napi);
739740
}
740741
}
741742

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ static int mlx5e_rx_reporter_err_icosq_cqe_recover(void *ctx)
123123
xskrq->stats->recover++;
124124
}
125125

126+
mlx5e_trigger_napi_icosq(icosq->channel);
127+
126128
mutex_unlock(&icosq->channel->icosq_recovery_lock);
127129

128130
return 0;
@@ -166,6 +168,10 @@ static int mlx5e_rx_reporter_err_rq_cqe_recover(void *ctx)
166168
clear_bit(MLX5E_RQ_STATE_RECOVERING, &rq->state);
167169
mlx5e_activate_rq(rq);
168170
rq->stats->recover++;
171+
if (rq->channel)
172+
mlx5e_trigger_napi_icosq(rq->channel);
173+
else
174+
mlx5e_trigger_napi_sched(rq->cq.napi);
169175
return 0;
170176
out:
171177
clear_bit(MLX5E_RQ_STATE_RECOVERING, &rq->state);

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
715715
struct mlx5_flow_attr *attr,
716716
struct flow_rule *flow_rule,
717717
struct mlx5e_mod_hdr_handle **mh,
718-
u8 zone_restore_id, bool nat)
718+
u8 zone_restore_id, bool nat_table, bool has_nat)
719719
{
720720
DECLARE_MOD_HDR_ACTS_ACTIONS(actions_arr, MLX5_CT_MIN_MOD_ACTS);
721721
DECLARE_MOD_HDR_ACTS(mod_acts, actions_arr);
@@ -731,11 +731,12 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
731731
&attr->ct_attr.ct_labels_id);
732732
if (err)
733733
return -EOPNOTSUPP;
734-
if (nat) {
735-
err = mlx5_tc_ct_entry_create_nat(ct_priv, flow_rule,
736-
&mod_acts);
737-
if (err)
738-
goto err_mapping;
734+
if (nat_table) {
735+
if (has_nat) {
736+
err = mlx5_tc_ct_entry_create_nat(ct_priv, flow_rule, &mod_acts);
737+
if (err)
738+
goto err_mapping;
739+
}
739740

740741
ct_state |= MLX5_CT_STATE_NAT_BIT;
741742
}
@@ -750,7 +751,7 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
750751
if (err)
751752
goto err_mapping;
752753

753-
if (nat) {
754+
if (nat_table && has_nat) {
754755
attr->modify_hdr = mlx5_modify_header_alloc(ct_priv->dev, ct_priv->ns_type,
755756
mod_acts.num_actions,
756757
mod_acts.actions);
@@ -818,7 +819,9 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
818819

819820
err = mlx5_tc_ct_entry_create_mod_hdr(ct_priv, attr, flow_rule,
820821
&zone_rule->mh,
821-
zone_restore_id, nat);
822+
zone_restore_id,
823+
nat,
824+
mlx5_tc_ct_entry_has_nat(entry));
822825
if (err) {
823826
ct_dbg("Failed to create ct entry mod hdr");
824827
goto err_mod_hdr;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ static void mlx5e_activate_trap(struct mlx5e_trap *trap)
179179
{
180180
napi_enable(&trap->napi);
181181
mlx5e_activate_rq(&trap->rq);
182+
mlx5e_trigger_napi_sched(&trap->napi);
182183
}
183184

184185
void mlx5e_deactivate_trap(struct mlx5e_priv *priv)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ static int mlx5e_xsk_enable_locked(struct mlx5e_priv *priv,
117117
goto err_remove_pool;
118118

119119
mlx5e_activate_xsk(c);
120+
mlx5e_trigger_napi_icosq(c);
120121

121122
/* Don't wait for WQEs, because the newer xdpsock sample doesn't provide
122123
* any Fill Ring entries at the setup stage.

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static int mlx5e_init_xsk_rq(struct mlx5e_channel *c,
6464
rq->clock = &mdev->clock;
6565
rq->icosq = &c->icosq;
6666
rq->ix = c->ix;
67+
rq->channel = c;
6768
rq->mdev = mdev;
6869
rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
6970
rq->xdpsq = &c->rq_xdpsq;
@@ -179,10 +180,6 @@ void mlx5e_activate_xsk(struct mlx5e_channel *c)
179180
mlx5e_reporter_icosq_resume_recovery(c);
180181

181182
/* TX queue is created active. */
182-
183-
spin_lock_bh(&c->async_icosq_lock);
184-
mlx5e_trigger_irq(&c->async_icosq);
185-
spin_unlock_bh(&c->async_icosq_lock);
186183
}
187184

188185
void mlx5e_deactivate_xsk(struct mlx5e_channel *c)

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param
475475
rq->clock = &mdev->clock;
476476
rq->icosq = &c->icosq;
477477
rq->ix = c->ix;
478+
rq->channel = c;
478479
rq->mdev = mdev;
479480
rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu);
480481
rq->xdpsq = &c->rq_xdpsq;
@@ -1066,13 +1067,6 @@ int mlx5e_open_rq(struct mlx5e_params *params, struct mlx5e_rq_param *param,
10661067
void mlx5e_activate_rq(struct mlx5e_rq *rq)
10671068
{
10681069
set_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
1069-
if (rq->icosq) {
1070-
mlx5e_trigger_irq(rq->icosq);
1071-
} else {
1072-
local_bh_disable();
1073-
napi_schedule(rq->cq.napi);
1074-
local_bh_enable();
1075-
}
10761070
}
10771071

10781072
void mlx5e_deactivate_rq(struct mlx5e_rq *rq)
@@ -2227,6 +2221,20 @@ static int mlx5e_channel_stats_alloc(struct mlx5e_priv *priv, int ix, int cpu)
22272221
return 0;
22282222
}
22292223

2224+
void mlx5e_trigger_napi_icosq(struct mlx5e_channel *c)
2225+
{
2226+
spin_lock_bh(&c->async_icosq_lock);
2227+
mlx5e_trigger_irq(&c->async_icosq);
2228+
spin_unlock_bh(&c->async_icosq_lock);
2229+
}
2230+
2231+
void mlx5e_trigger_napi_sched(struct napi_struct *napi)
2232+
{
2233+
local_bh_disable();
2234+
napi_schedule(napi);
2235+
local_bh_enable();
2236+
}
2237+
22302238
static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
22312239
struct mlx5e_params *params,
22322240
struct mlx5e_channel_param *cparam,
@@ -2308,6 +2316,8 @@ static void mlx5e_activate_channel(struct mlx5e_channel *c)
23082316

23092317
if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
23102318
mlx5e_activate_xsk(c);
2319+
2320+
mlx5e_trigger_napi_icosq(c);
23112321
}
23122322

23132323
static void mlx5e_deactivate_channel(struct mlx5e_channel *c)
@@ -4559,6 +4569,11 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
45594569

45604570
unlock:
45614571
mutex_unlock(&priv->state_lock);
4572+
4573+
/* Need to fix some features. */
4574+
if (!err)
4575+
netdev_update_features(netdev);
4576+
45624577
return err;
45634578
}
45644579

0 commit comments

Comments
 (0)