History

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 ====================

Jakub Kicinski committed 4 years ago

Commit c034ff22 parents 11049c9 1c5de0914 files · +115 −41Browse files

Unified · Split

14 files
  1. drivers/net/ethernet/mellanox/mlx5/core/dev.c +23 −11
  2. drivers/net/ethernet/mellanox/mlx5/core/en.h +4 −0
  3. drivers/net/ethernet/mellanox/mlx5/core/en/fs.h +2 −0
  4. drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +1 −0
  5. drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c +6 −0
  6. drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +11 −8
  7. drivers/net/ethernet/mellanox/mlx5/core/en/trap.c +1 −0
  8. drivers/net/ethernet/mellanox/mlx5/core/en/xsk/pool.c +1 −0
  9. drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c +1 −4
  10. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +22 −7
  11. drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +36 −2
  12. drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +1 −1
  13. drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c +4 −5
  14. include/linux/mlx5/mlx5_ifc.h +2 −3
drivers/net/ethernet/mellanox/mlx5/core/dev.c+23−11
@@ -571,18 +571,32 @@ static int _next_phys_dev(struct mlx5_core_dev *mdev, · 570 unmodified lines
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) · 7 unmodified lines
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+4−0
@@ -764,6 +764,7 @@ struct mlx5e_rq { · 763 unmodified lines
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); · 306 unmodified lines
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+2−0
@@ -12,6 +12,7 @@ struct mlx5e_post_act; · 11 unmodified lines
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 { · 2 unmodified lines
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+1−0
@@ -736,6 +736,7 @@ void mlx5e_ptp_activate_channel(struct mlx5e_ptp *c) · 735 unmodified lines
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+6−0
@@ -123,6 +123,8 @@ static int mlx5e_rx_reporter_err_icosq_cqe_recover(void *ctx) · 122 unmodified lines
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) · 37 unmodified lines
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+11−8
@@ -715,7 +715,7 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv, · 714 unmodified lines
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, · 9 unmodified lines
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, · 8 unmodified lines
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, · 61 unmodified lines
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+1−0
@@ -179,6 +179,7 @@ static void mlx5e_activate_trap(struct mlx5e_trap *trap) · 178 unmodified lines
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+1−0
@@ -117,6 +117,7 @@ static int mlx5e_xsk_enable_locked(struct mlx5e_priv *priv, · 116 unmodified lines
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+1−4
@@ -64,6 +64,7 @@ static int mlx5e_init_xsk_rq(struct mlx5e_channel *c, · 63 unmodified lines
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) · 109 unmodified lines
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+22−7
@@ -475,6 +475,7 @@ static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param · 474 unmodified lines
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 @@ err_free_rq: · 585 unmodified lines
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) · 1148 unmodified lines
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) · 75 unmodified lines
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) · 2245 unmodified lines
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
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c+36−2
@@ -4714,6 +4714,33 @@ static int mlx5e_tc_nic_get_ft_size(struct mlx5_core_dev *dev) · 4713 unmodified lines
47144714 return tc_tbl_size;
47154715 }
47164716
4717+static int mlx5e_tc_nic_create_miss_table(struct mlx5e_priv *priv)
4718+{
4719+ struct mlx5_flow_table **ft = &priv->fs.tc.miss_t;
4720+ struct mlx5_flow_table_attr ft_attr = {};
4721+ struct mlx5_flow_namespace *ns;
4722+ int err = 0;
4723+
4724+ ft_attr.max_fte = 1;
4725+ ft_attr.autogroup.max_num_groups = 1;
4726+ ft_attr.level = MLX5E_TC_MISS_LEVEL;
4727+ ft_attr.prio = 0;
4728+ ns = mlx5_get_flow_namespace(priv->mdev, MLX5_FLOW_NAMESPACE_KERNEL);
4729+
4730+ *ft = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
4731+ if (IS_ERR(*ft)) {
4732+ err = PTR_ERR(*ft);
4733+ netdev_err(priv->netdev, "failed to create tc nic miss table err=%d\n", err);
4734+ }
4735+
4736+ return err;
4737+}
4738+
4739+static void mlx5e_tc_nic_destroy_miss_table(struct mlx5e_priv *priv)
4740+{
4741+ mlx5_destroy_flow_table(priv->fs.tc.miss_t);
4742+}
4743+
47174744 int mlx5e_tc_nic_init(struct mlx5e_priv *priv)
47184745 {
47194746 struct mlx5e_tc_table *tc = &priv->fs.tc;
@@ -4746,19 +4773,23 @@ int mlx5e_tc_nic_init(struct mlx5e_priv *priv) · 26 unmodified lines
47464773 }
47474774 tc->mapping = chains_mapping;
47484775
4776+ err = mlx5e_tc_nic_create_miss_table(priv);
4777+ if (err)
4778+ goto err_chains;
4779+
47494780 if (MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, ignore_flow_level))
47504781 attr.flags = MLX5_CHAINS_AND_PRIOS_SUPPORTED |
47514782 MLX5_CHAINS_IGNORE_FLOW_LEVEL_SUPPORTED;
47524783 attr.ns = MLX5_FLOW_NAMESPACE_KERNEL;
47534784 attr.max_ft_sz = mlx5e_tc_nic_get_ft_size(dev);
47544785 attr.max_grp_num = MLX5E_TC_TABLE_NUM_GROUPS;
4755− attr.default_ft = mlx5e_vlan_get_flowtable(priv->fs.vlan);
4786+ attr.default_ft = priv->fs.tc.miss_t;
47564787 attr.mapping = chains_mapping;
47574788
47584789 tc->chains = mlx5_chains_create(dev, &attr);
47594790 if (IS_ERR(tc->chains)) {
47604791 err = PTR_ERR(tc->chains);
4761− goto err_chains;
4792+ goto err_miss;
47624793 }
47634794
47644795 tc->post_act = mlx5e_tc_post_act_init(priv, tc->chains, MLX5_FLOW_NAMESPACE_KERNEL);
@@ -4781,6 +4812,8 @@ err_reg: · 16 unmodified lines
47814812 mlx5_tc_ct_clean(tc->ct);
47824813 mlx5e_tc_post_act_destroy(tc->post_act);
47834814 mlx5_chains_destroy(tc->chains);
4815+err_miss:
4816+ mlx5e_tc_nic_destroy_miss_table(priv);
47844817 err_chains:
47854818 mapping_destroy(chains_mapping);
47864819 err_mapping:
@@ -4821,6 +4854,7 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv) · 34 unmodified lines
48214854 mlx5e_tc_post_act_destroy(tc->post_act);
48224855 mapping_destroy(tc->mapping);
48234856 mlx5_chains_destroy(tc->chains);
4857+ mlx5e_tc_nic_destroy_miss_table(priv);
48244858 }
48254859
48264860 int mlx5e_tc_ht_init(struct rhashtable *tc_ht)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c+1−1
@@ -114,7 +114,7 @@ · 113 unmodified lines
114114 #define KERNEL_MIN_LEVEL (KERNEL_NIC_PRIO_NUM_LEVELS + 1)
115115
116116 #define KERNEL_NIC_TC_NUM_PRIOS 1
117−#define KERNEL_NIC_TC_NUM_LEVELS 2
117+#define KERNEL_NIC_TC_NUM_LEVELS 3
118118
119119 #define ANCHOR_NUM_LEVELS 1
120120 #define ANCHOR_NUM_PRIOS 1
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c+4−5
@@ -44,11 +44,10 @@ static int set_miss_action(struct mlx5_flow_root_namespace *ns, · 43 unmodified lines
4444 err = mlx5dr_table_set_miss_action(ft->fs_dr_table.dr_table, action);
4545 if (err && action) {
4646 err = mlx5dr_action_destroy(action);
47− if (err) {
48− action = NULL;
49− mlx5_core_err(ns->dev, "Failed to destroy action (%d)\n",
50− err);
51− }
47+ if (err)
48+ mlx5_core_err(ns->dev,
49+ "Failed to destroy action (%d)\n", err);
50+ action = NULL;
5251 }
5352 ft->fs_dr_table.miss_action = action;
5453 if (old_miss_action) {
include/linux/mlx5/mlx5_ifc.h+2−3
@@ -5176,12 +5176,11 @@ struct mlx5_ifc_query_qp_out_bits { · 5175 unmodified lines
51765176
51775177 u8 syndrome[0x20];
51785178
5179− u8 reserved_at_40[0x20];
5180− u8 ece[0x20];
5179+ u8 reserved_at_40[0x40];
51815180
51825181 u8 opt_param_mask[0x20];
51835182
5184− u8 reserved_at_a0[0x20];
5183+ u8 ece[0x20];
51855184
51865185 struct mlx5_ifc_qpc_bits qpc;
51875186

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t