Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20220531205447.99236-1-saeed@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+115 -41
+23 -11
drivers/net/ethernet/mellanox/mlx5/core/dev.c
··· 571 571 return 1; 572 572 } 573 573 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 + 574 582 static int next_phys_dev(struct device *dev, const void *data) 575 583 { 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; 578 589 579 590 return _next_phys_dev(mdev, data); 580 591 } 581 592 582 593 static int next_phys_dev_lag(struct device *dev, const void *data) 583 594 { 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; 586 600 587 601 if (!MLX5_CAP_GEN(mdev, vport_group_manager) || 588 602 !MLX5_CAP_GEN(mdev, lag_master) || ··· 610 596 static struct mlx5_core_dev *mlx5_get_next_dev(struct mlx5_core_dev *dev, 611 597 int (*match)(struct device *dev, const void *data)) 612 598 { 613 - struct auxiliary_device *adev; 614 - struct mlx5_adev *madev; 599 + struct device *next; 615 600 616 601 if (!mlx5_core_is_pf(dev)) 617 602 return NULL; 618 603 619 - adev = auxiliary_find_device(NULL, dev, match); 620 - if (!adev) 604 + next = bus_find_device(&pci_bus_type, NULL, dev, match); 605 + if (!next) 621 606 return NULL; 622 607 623 - madev = container_of(adev, struct mlx5_adev, adev); 624 - put_device(&adev->dev); 625 - return madev->mdev; 608 + put_device(next); 609 + return pci_get_drvdata(to_pci_dev(next)); 626 610 } 627 611 628 612 /* Must be called with intf_mutex held */
+4
drivers/net/ethernet/mellanox/mlx5/core/en.h
··· 764 764 u8 wq_type; 765 765 u32 rqn; 766 766 struct mlx5_core_dev *mdev; 767 + struct mlx5e_channel *channel; 767 768 u32 umr_mkey; 768 769 struct mlx5e_dma_info wqe_overflow; 769 770 ··· 1076 1075 1077 1076 int mlx5e_open_locked(struct net_device *netdev); 1078 1077 int mlx5e_close_locked(struct net_device *netdev); 1078 + 1079 + void mlx5e_trigger_napi_icosq(struct mlx5e_channel *c); 1080 + void mlx5e_trigger_napi_sched(struct napi_struct *napi); 1079 1081 1080 1082 int mlx5e_open_channels(struct mlx5e_priv *priv, 1081 1083 struct mlx5e_channels *chs);
+2
drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
··· 12 12 enum { 13 13 MLX5E_TC_FT_LEVEL = 0, 14 14 MLX5E_TC_TTC_FT_LEVEL, 15 + MLX5E_TC_MISS_LEVEL, 15 16 }; 16 17 17 18 struct mlx5e_tc_table { ··· 21 20 */ 22 21 struct mutex t_lock; 23 22 struct mlx5_flow_table *t; 23 + struct mlx5_flow_table *miss_t; 24 24 struct mlx5_fs_chains *chains; 25 25 struct mlx5e_post_act *post_act; 26 26
+1
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
··· 736 736 if (test_bit(MLX5E_PTP_STATE_RX, c->state)) { 737 737 mlx5e_ptp_rx_set_fs(c->priv); 738 738 mlx5e_activate_rq(&c->rq); 739 + mlx5e_trigger_napi_sched(&c->napi); 739 740 } 740 741 } 741 742
+6
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c
··· 123 123 xskrq->stats->recover++; 124 124 } 125 125 126 + mlx5e_trigger_napi_icosq(icosq->channel); 127 + 126 128 mutex_unlock(&icosq->channel->icosq_recovery_lock); 127 129 128 130 return 0; ··· 168 166 clear_bit(MLX5E_RQ_STATE_RECOVERING, &rq->state); 169 167 mlx5e_activate_rq(rq); 170 168 rq->stats->recover++; 169 + if (rq->channel) 170 + mlx5e_trigger_napi_icosq(rq->channel); 171 + else 172 + mlx5e_trigger_napi_sched(rq->cq.napi); 171 173 return 0; 172 174 out: 173 175 clear_bit(MLX5E_RQ_STATE_RECOVERING, &rq->state);
+11 -8
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
··· 715 715 struct mlx5_flow_attr *attr, 716 716 struct flow_rule *flow_rule, 717 717 struct mlx5e_mod_hdr_handle **mh, 718 - u8 zone_restore_id, bool nat) 718 + u8 zone_restore_id, bool nat_table, bool has_nat) 719 719 { 720 720 DECLARE_MOD_HDR_ACTS_ACTIONS(actions_arr, MLX5_CT_MIN_MOD_ACTS); 721 721 DECLARE_MOD_HDR_ACTS(mod_acts, actions_arr); ··· 731 731 &attr->ct_attr.ct_labels_id); 732 732 if (err) 733 733 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 + } 739 740 740 741 ct_state |= MLX5_CT_STATE_NAT_BIT; 741 742 } ··· 751 750 if (err) 752 751 goto err_mapping; 753 752 754 - if (nat) { 753 + if (nat_table && has_nat) { 755 754 attr->modify_hdr = mlx5_modify_header_alloc(ct_priv->dev, ct_priv->ns_type, 756 755 mod_acts.num_actions, 757 756 mod_acts.actions); ··· 819 818 820 819 err = mlx5_tc_ct_entry_create_mod_hdr(ct_priv, attr, flow_rule, 821 820 &zone_rule->mh, 822 - zone_restore_id, nat); 821 + zone_restore_id, 822 + nat, 823 + mlx5_tc_ct_entry_has_nat(entry)); 823 824 if (err) { 824 825 ct_dbg("Failed to create ct entry mod hdr"); 825 826 goto err_mod_hdr;
+1
drivers/net/ethernet/mellanox/mlx5/core/en/trap.c
··· 179 179 { 180 180 napi_enable(&trap->napi); 181 181 mlx5e_activate_rq(&trap->rq); 182 + mlx5e_trigger_napi_sched(&trap->napi); 182 183 } 183 184 184 185 void mlx5e_deactivate_trap(struct mlx5e_priv *priv)
+1
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/pool.c
··· 117 117 goto err_remove_pool; 118 118 119 119 mlx5e_activate_xsk(c); 120 + mlx5e_trigger_napi_icosq(c); 120 121 121 122 /* Don't wait for WQEs, because the newer xdpsock sample doesn't provide 122 123 * any Fill Ring entries at the setup stage.
+1 -4
drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
··· 64 64 rq->clock = &mdev->clock; 65 65 rq->icosq = &c->icosq; 66 66 rq->ix = c->ix; 67 + rq->channel = c; 67 68 rq->mdev = mdev; 68 69 rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu); 69 70 rq->xdpsq = &c->rq_xdpsq; ··· 180 179 mlx5e_reporter_icosq_resume_recovery(c); 181 180 182 181 /* TX queue is created active. */ 183 - 184 - spin_lock_bh(&c->async_icosq_lock); 185 - mlx5e_trigger_irq(&c->async_icosq); 186 - spin_unlock_bh(&c->async_icosq_lock); 187 182 } 188 183 189 184 void mlx5e_deactivate_xsk(struct mlx5e_channel *c)
+22 -7
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 475 475 rq->clock = &mdev->clock; 476 476 rq->icosq = &c->icosq; 477 477 rq->ix = c->ix; 478 + rq->channel = c; 478 479 rq->mdev = mdev; 479 480 rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu); 480 481 rq->xdpsq = &c->rq_xdpsq; ··· 1067 1066 void mlx5e_activate_rq(struct mlx5e_rq *rq) 1068 1067 { 1069 1068 set_bit(MLX5E_RQ_STATE_ENABLED, &rq->state); 1070 - if (rq->icosq) { 1071 - mlx5e_trigger_irq(rq->icosq); 1072 - } else { 1073 - local_bh_disable(); 1074 - napi_schedule(rq->cq.napi); 1075 - local_bh_enable(); 1076 - } 1077 1069 } 1078 1070 1079 1071 void mlx5e_deactivate_rq(struct mlx5e_rq *rq) ··· 2221 2227 return 0; 2222 2228 } 2223 2229 2230 + void mlx5e_trigger_napi_icosq(struct mlx5e_channel *c) 2231 + { 2232 + spin_lock_bh(&c->async_icosq_lock); 2233 + mlx5e_trigger_irq(&c->async_icosq); 2234 + spin_unlock_bh(&c->async_icosq_lock); 2235 + } 2236 + 2237 + void mlx5e_trigger_napi_sched(struct napi_struct *napi) 2238 + { 2239 + local_bh_disable(); 2240 + napi_schedule(napi); 2241 + local_bh_enable(); 2242 + } 2243 + 2224 2244 static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, 2225 2245 struct mlx5e_params *params, 2226 2246 struct mlx5e_channel_param *cparam, ··· 2316 2308 2317 2309 if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state)) 2318 2310 mlx5e_activate_xsk(c); 2311 + 2312 + mlx5e_trigger_napi_icosq(c); 2319 2313 } 2320 2314 2321 2315 static void mlx5e_deactivate_channel(struct mlx5e_channel *c) ··· 4569 4559 4570 4560 unlock: 4571 4561 mutex_unlock(&priv->state_lock); 4562 + 4563 + /* Need to fix some features. */ 4564 + if (!err) 4565 + netdev_update_features(netdev); 4566 + 4572 4567 return err; 4573 4568 } 4574 4569
+36 -2
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 4714 4714 return tc_tbl_size; 4715 4715 } 4716 4716 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 + 4717 4744 int mlx5e_tc_nic_init(struct mlx5e_priv *priv) 4718 4745 { 4719 4746 struct mlx5e_tc_table *tc = &priv->fs.tc; ··· 4773 4746 } 4774 4747 tc->mapping = chains_mapping; 4775 4748 4749 + err = mlx5e_tc_nic_create_miss_table(priv); 4750 + if (err) 4751 + goto err_chains; 4752 + 4776 4753 if (MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, ignore_flow_level)) 4777 4754 attr.flags = MLX5_CHAINS_AND_PRIOS_SUPPORTED | 4778 4755 MLX5_CHAINS_IGNORE_FLOW_LEVEL_SUPPORTED; 4779 4756 attr.ns = MLX5_FLOW_NAMESPACE_KERNEL; 4780 4757 attr.max_ft_sz = mlx5e_tc_nic_get_ft_size(dev); 4781 4758 attr.max_grp_num = MLX5E_TC_TABLE_NUM_GROUPS; 4782 - attr.default_ft = mlx5e_vlan_get_flowtable(priv->fs.vlan); 4759 + attr.default_ft = priv->fs.tc.miss_t; 4783 4760 attr.mapping = chains_mapping; 4784 4761 4785 4762 tc->chains = mlx5_chains_create(dev, &attr); 4786 4763 if (IS_ERR(tc->chains)) { 4787 4764 err = PTR_ERR(tc->chains); 4788 - goto err_chains; 4765 + goto err_miss; 4789 4766 } 4790 4767 4791 4768 tc->post_act = mlx5e_tc_post_act_init(priv, tc->chains, MLX5_FLOW_NAMESPACE_KERNEL); ··· 4812 4781 mlx5_tc_ct_clean(tc->ct); 4813 4782 mlx5e_tc_post_act_destroy(tc->post_act); 4814 4783 mlx5_chains_destroy(tc->chains); 4784 + err_miss: 4785 + mlx5e_tc_nic_destroy_miss_table(priv); 4815 4786 err_chains: 4816 4787 mapping_destroy(chains_mapping); 4817 4788 err_mapping: ··· 4854 4821 mlx5e_tc_post_act_destroy(tc->post_act); 4855 4822 mapping_destroy(tc->mapping); 4856 4823 mlx5_chains_destroy(tc->chains); 4824 + mlx5e_tc_nic_destroy_miss_table(priv); 4857 4825 } 4858 4826 4859 4827 int mlx5e_tc_ht_init(struct rhashtable *tc_ht)
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
··· 114 114 #define KERNEL_MIN_LEVEL (KERNEL_NIC_PRIO_NUM_LEVELS + 1) 115 115 116 116 #define KERNEL_NIC_TC_NUM_PRIOS 1 117 - #define KERNEL_NIC_TC_NUM_LEVELS 2 117 + #define KERNEL_NIC_TC_NUM_LEVELS 3 118 118 119 119 #define ANCHOR_NUM_LEVELS 1 120 120 #define ANCHOR_NUM_PRIOS 1
+4 -5
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c
··· 44 44 err = mlx5dr_table_set_miss_action(ft->fs_dr_table.dr_table, action); 45 45 if (err && action) { 46 46 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; 52 51 } 53 52 ft->fs_dr_table.miss_action = action; 54 53 if (old_miss_action) {
+2 -3
include/linux/mlx5/mlx5_ifc.h
··· 5176 5176 5177 5177 u8 syndrome[0x20]; 5178 5178 5179 - u8 reserved_at_40[0x20]; 5180 - u8 ece[0x20]; 5179 + u8 reserved_at_40[0x40]; 5181 5180 5182 5181 u8 opt_param_mask[0x20]; 5183 5182 5184 - u8 reserved_at_a0[0x20]; 5183 + u8 ece[0x20]; 5185 5184 5186 5185 struct mlx5_ifc_qpc_bits qpc; 5187 5186