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

Merge tag 'mlx5-updates-2020-02-25' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux

Saeed Mahameed says:

====================
mlx5-updates-2020-02-25

The following series provides some misc updates to mlx5 driver:

1) From Maxim, Refactoring for mlx5e netdev channels recreation flow.
- Add error handling
- Add context to the preactivate hook
- Use preactivate hook with context where it can be used
and subsequently unify channel recreation flow everywhere.
- Fix XPS cpumask to not reset upon channel recreation.

2) From Tariq:
- Use indirect calls wrapper on RX.
- Check LRO capability bit

3) Multiple small cleanups
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+216 -128
+1 -1
Documentation/networking/device_drivers/mellanox/mlx5.rst
··· 101 101 **External options** ( Choose if the corresponding mlx5 feature is required ) 102 102 103 103 - CONFIG_PTP_1588_CLOCK: When chosen, mlx5 ptp support will be enabled 104 - - CONFIG_VXLAN: When chosen, mlx5 vxaln support will be enabled. 104 + - CONFIG_VXLAN: When chosen, mlx5 vxlan support will be enabled. 105 105 - CONFIG_MLXFW: When chosen, mlx5 firmware flashing support will be enabled (via devlink and ethtool). 106 106 107 107 Devlink info
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
··· 188 188 189 189 MLX5_SET(create_mkey_in, in, translations_octword_actual_size, 190 190 DIV_ROUND_UP(TRACER_BUFFER_PAGE_NUM, 2)); 191 - mtt = (u64 *)MLX5_ADDR_OF(create_mkey_in, in, klm_pas_mtt); 191 + mtt = (__be64 *)MLX5_ADDR_OF(create_mkey_in, in, klm_pas_mtt); 192 192 for (i = 0 ; i < TRACER_BUFFER_PAGE_NUM ; i++) 193 193 mtt[i] = cpu_to_be64(tracer->buff.dma + i * PAGE_SIZE); 194 194
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/diag/rsc_dump.h
··· 2 2 /* Copyright (c) 2019 Mellanox Technologies. */ 3 3 4 4 #ifndef __MLX5_RSC_DUMP_H 5 - #define __MLX5_RSC_DUMP__H 5 + #define __MLX5_RSC_DUMP_H 6 6 7 7 #include <linux/mlx5/driver.h> 8 8 #include "mlx5_core.h"
+23 -6
drivers/net/ethernet/mellanox/mlx5/core/en.h
··· 737 737 DECLARE_BITMAP(state, MLX5E_CHANNEL_NUM_STATES); 738 738 int ix; 739 739 int cpu; 740 - cpumask_var_t xps_cpumask; 741 740 }; 742 741 743 742 struct mlx5e_channels { ··· 812 813 bool ever_used; 813 814 }; 814 815 816 + /* Temporary storage for variables that are allocated when struct mlx5e_priv is 817 + * initialized, and used where we can't allocate them because that functions 818 + * must not fail. Use with care and make sure the same variable is not used 819 + * simultaneously by multiple users. 820 + */ 821 + struct mlx5e_scratchpad { 822 + cpumask_var_t cpumask; 823 + }; 824 + 815 825 struct mlx5e_priv { 816 826 /* priv data path fields - start */ 817 827 struct mlx5e_txqsq *txq2sq[MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC]; ··· 884 876 #if IS_ENABLED(CONFIG_PCI_HYPERV_INTERFACE) 885 877 struct mlx5e_hv_vhca_stats_agent stats_agent; 886 878 #endif 879 + struct mlx5e_scratchpad scratchpad; 887 880 }; 888 881 889 882 struct mlx5e_profile { ··· 1044 1035 struct mlx5e_channels *chs); 1045 1036 void mlx5e_close_channels(struct mlx5e_channels *chs); 1046 1037 1047 - /* Function pointer to be used to modify WH settings while 1038 + /* Function pointer to be used to modify HW or kernel settings while 1048 1039 * switching channels 1049 1040 */ 1050 - typedef int (*mlx5e_fp_hw_modify)(struct mlx5e_priv *priv); 1041 + typedef int (*mlx5e_fp_preactivate)(struct mlx5e_priv *priv, void *context); 1042 + #define MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX(fn) \ 1043 + int fn##_ctx(struct mlx5e_priv *priv, void *context) \ 1044 + { \ 1045 + return fn(priv); \ 1046 + } 1051 1047 int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv); 1052 1048 int mlx5e_safe_switch_channels(struct mlx5e_priv *priv, 1053 1049 struct mlx5e_channels *new_chs, 1054 - mlx5e_fp_hw_modify hw_modify); 1050 + mlx5e_fp_preactivate preactivate, 1051 + void *context); 1052 + int mlx5e_num_channels_changed(struct mlx5e_priv *priv); 1053 + int mlx5e_num_channels_changed_ctx(struct mlx5e_priv *priv, void *context); 1055 1054 void mlx5e_activate_priv_channels(struct mlx5e_priv *priv); 1056 1055 void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv); 1057 1056 ··· 1139 1122 void mlx5e_queue_update_stats(struct mlx5e_priv *priv); 1140 1123 int mlx5e_bits_invert(unsigned long a, int size); 1141 1124 1142 - typedef int (*change_hw_mtu_cb)(struct mlx5e_priv *priv); 1143 1125 int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv); 1126 + int mlx5e_set_dev_port_mtu_ctx(struct mlx5e_priv *priv, void *context); 1144 1127 int mlx5e_change_mtu(struct net_device *netdev, int new_mtu, 1145 - change_hw_mtu_cb set_mtu_cb); 1128 + mlx5e_fp_preactivate preactivate); 1146 1129 1147 1130 /* ethtool helpers */ 1148 1131 void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv,
+33 -22
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
··· 1098 1098 mlx5e_dcbnl_dscp_app(priv, DELETE); 1099 1099 } 1100 1100 1101 - static void mlx5e_trust_update_tx_min_inline_mode(struct mlx5e_priv *priv, 1102 - struct mlx5e_params *params) 1101 + static void mlx5e_params_calc_trust_tx_min_inline_mode(struct mlx5_core_dev *mdev, 1102 + struct mlx5e_params *params, 1103 + u8 trust_state) 1103 1104 { 1104 - mlx5_query_min_inline(priv->mdev, &params->tx_min_inline_mode); 1105 - if (priv->dcbx_dp.trust_state == MLX5_QPTS_TRUST_DSCP && 1105 + mlx5_query_min_inline(mdev, &params->tx_min_inline_mode); 1106 + if (trust_state == MLX5_QPTS_TRUST_DSCP && 1106 1107 params->tx_min_inline_mode == MLX5_INLINE_MODE_L2) 1107 1108 params->tx_min_inline_mode = MLX5_INLINE_MODE_IP; 1108 1109 } 1109 1110 1110 - static void mlx5e_trust_update_sq_inline_mode(struct mlx5e_priv *priv) 1111 + static int mlx5e_update_trust_state_hw(struct mlx5e_priv *priv, void *context) 1112 + { 1113 + u8 *trust_state = context; 1114 + int err; 1115 + 1116 + err = mlx5_set_trust_state(priv->mdev, *trust_state); 1117 + if (err) 1118 + return err; 1119 + priv->dcbx_dp.trust_state = *trust_state; 1120 + 1121 + return 0; 1122 + } 1123 + 1124 + static int mlx5e_set_trust_state(struct mlx5e_priv *priv, u8 trust_state) 1111 1125 { 1112 1126 struct mlx5e_channels new_channels = {}; 1127 + bool reset_channels = true; 1128 + int err = 0; 1113 1129 1114 1130 mutex_lock(&priv->state_lock); 1115 1131 1116 1132 new_channels.params = priv->channels.params; 1117 - mlx5e_trust_update_tx_min_inline_mode(priv, &new_channels.params); 1133 + mlx5e_params_calc_trust_tx_min_inline_mode(priv->mdev, &new_channels.params, 1134 + trust_state); 1118 1135 1119 1136 if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) { 1120 1137 priv->channels.params = new_channels.params; 1121 - goto out; 1138 + reset_channels = false; 1122 1139 } 1123 1140 1124 1141 /* Skip if tx_min_inline is the same */ 1125 1142 if (new_channels.params.tx_min_inline_mode == 1126 1143 priv->channels.params.tx_min_inline_mode) 1127 - goto out; 1144 + reset_channels = false; 1128 1145 1129 - mlx5e_safe_switch_channels(priv, &new_channels, NULL); 1146 + if (reset_channels) 1147 + err = mlx5e_safe_switch_channels(priv, &new_channels, 1148 + mlx5e_update_trust_state_hw, 1149 + &trust_state); 1150 + else 1151 + err = mlx5e_update_trust_state_hw(priv, &trust_state); 1130 1152 1131 - out: 1132 1153 mutex_unlock(&priv->state_lock); 1133 - } 1134 - 1135 - static int mlx5e_set_trust_state(struct mlx5e_priv *priv, u8 trust_state) 1136 - { 1137 - int err; 1138 - 1139 - err = mlx5_set_trust_state(priv->mdev, trust_state); 1140 - if (err) 1141 - return err; 1142 - priv->dcbx_dp.trust_state = trust_state; 1143 - mlx5e_trust_update_sq_inline_mode(priv); 1144 1154 1145 1155 return err; 1146 1156 } ··· 1181 1171 if (err) 1182 1172 return err; 1183 1173 1184 - mlx5e_trust_update_tx_min_inline_mode(priv, &priv->channels.params); 1174 + mlx5e_params_calc_trust_tx_min_inline_mode(priv->mdev, &priv->channels.params, 1175 + priv->dcbx_dp.trust_state); 1185 1176 1186 1177 err = mlx5_query_dscp2prio(priv->mdev, priv->dcbx_dp.dscp2prio); 1187 1178 if (err)
+9 -14
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
··· 357 357 goto unlock; 358 358 } 359 359 360 - err = mlx5e_safe_switch_channels(priv, &new_channels, NULL); 360 + err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); 361 361 362 362 unlock: 363 363 mutex_unlock(&priv->state_lock); ··· 432 432 433 433 if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) { 434 434 *cur_params = new_channels.params; 435 - if (!netif_is_rxfh_configured(priv->netdev)) 436 - mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt, 437 - MLX5E_INDIR_RQT_SIZE, count); 435 + mlx5e_num_channels_changed(priv); 438 436 goto out; 439 437 } 440 438 ··· 440 442 if (arfs_enabled) 441 443 mlx5e_arfs_disable(priv); 442 444 443 - if (!netif_is_rxfh_configured(priv->netdev)) 444 - mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt, 445 - MLX5E_INDIR_RQT_SIZE, count); 446 - 447 445 /* Switch to new channels, set new parameters and close old ones */ 448 - err = mlx5e_safe_switch_channels(priv, &new_channels, NULL); 446 + err = mlx5e_safe_switch_channels(priv, &new_channels, 447 + mlx5e_num_channels_changed_ctx, NULL); 449 448 450 449 if (arfs_enabled) { 451 450 int err2 = mlx5e_arfs_enable(priv); ··· 575 580 goto out; 576 581 } 577 582 578 - err = mlx5e_safe_switch_channels(priv, &new_channels, NULL); 583 + err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); 579 584 580 585 out: 581 586 mutex_unlock(&priv->state_lock); ··· 1743 1748 return 0; 1744 1749 } 1745 1750 1746 - return mlx5e_safe_switch_channels(priv, &new_channels, NULL); 1751 + return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); 1747 1752 } 1748 1753 1749 1754 static int set_pflag_tx_cqe_based_moder(struct net_device *netdev, bool enable) ··· 1776 1781 return 0; 1777 1782 } 1778 1783 1779 - err = mlx5e_safe_switch_channels(priv, &new_channels, NULL); 1784 + err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); 1780 1785 if (err) 1781 1786 return err; 1782 1787 ··· 1833 1838 return 0; 1834 1839 } 1835 1840 1836 - return mlx5e_safe_switch_channels(priv, &new_channels, NULL); 1841 + return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); 1837 1842 } 1838 1843 1839 1844 static int set_pflag_rx_no_csum_complete(struct net_device *netdev, bool enable) ··· 1877 1882 return 0; 1878 1883 } 1879 1884 1880 - err = mlx5e_safe_switch_channels(priv, &new_channels, NULL); 1885 + err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); 1881 1886 return err; 1882 1887 } 1883 1888
+126 -69
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 1794 1794 return err; 1795 1795 } 1796 1796 1797 - static int mlx5e_alloc_xps_cpumask(struct mlx5e_channel *c, 1798 - struct mlx5e_params *params) 1799 - { 1800 - int num_comp_vectors = mlx5_comp_vectors_count(c->mdev); 1801 - int irq; 1802 - 1803 - if (!zalloc_cpumask_var(&c->xps_cpumask, GFP_KERNEL)) 1804 - return -ENOMEM; 1805 - 1806 - for (irq = c->ix; irq < num_comp_vectors; irq += params->num_channels) { 1807 - int cpu = cpumask_first(mlx5_comp_irq_get_affinity_mask(c->mdev, irq)); 1808 - 1809 - cpumask_set_cpu(cpu, c->xps_cpumask); 1810 - } 1811 - 1812 - return 0; 1813 - } 1814 - 1815 - static void mlx5e_free_xps_cpumask(struct mlx5e_channel *c) 1816 - { 1817 - free_cpumask_var(c->xps_cpumask); 1818 - } 1819 - 1820 1797 static int mlx5e_open_queues(struct mlx5e_channel *c, 1821 1798 struct mlx5e_params *params, 1822 1799 struct mlx5e_channel_param *cparam) ··· 1944 1967 c->irq_desc = irq_to_desc(irq); 1945 1968 c->lag_port = mlx5e_enumerate_lag_port(priv->mdev, ix); 1946 1969 1947 - err = mlx5e_alloc_xps_cpumask(c, params); 1948 - if (err) 1949 - goto err_free_channel; 1950 - 1951 1970 netif_napi_add(netdev, &c->napi, mlx5e_napi_poll, 64); 1952 1971 1953 1972 err = mlx5e_open_queues(c, params, cparam); ··· 1966 1993 1967 1994 err_napi_del: 1968 1995 netif_napi_del(&c->napi); 1969 - mlx5e_free_xps_cpumask(c); 1970 1996 1971 - err_free_channel: 1972 1997 kvfree(c); 1973 1998 1974 1999 return err; ··· 1980 2009 mlx5e_activate_txqsq(&c->sq[tc]); 1981 2010 mlx5e_activate_icosq(&c->icosq); 1982 2011 mlx5e_activate_rq(&c->rq); 1983 - netif_set_xps_queue(c->netdev, c->xps_cpumask, c->ix); 1984 2012 1985 2013 if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state)) 1986 2014 mlx5e_activate_xsk(c); ··· 2004 2034 mlx5e_close_xsk(c); 2005 2035 mlx5e_close_queues(c); 2006 2036 netif_napi_del(&c->napi); 2007 - mlx5e_free_xps_cpumask(c); 2008 2037 2009 2038 kvfree(c); 2010 2039 } ··· 2753 2784 return err; 2754 2785 } 2755 2786 2787 + static MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX(mlx5e_modify_tirs_lro); 2788 + 2756 2789 static int mlx5e_set_mtu(struct mlx5_core_dev *mdev, 2757 2790 struct mlx5e_params *params, u16 mtu) 2758 2791 { ··· 2804 2833 return 0; 2805 2834 } 2806 2835 2836 + MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX(mlx5e_set_dev_port_mtu); 2837 + 2807 2838 void mlx5e_set_netdev_mtu_boundaries(struct mlx5e_priv *priv) 2808 2839 { 2809 2840 struct mlx5e_params *params = &priv->channels.params; ··· 2842 2869 netdev_set_tc_queue(netdev, tc, nch, 0); 2843 2870 } 2844 2871 2872 + static void mlx5e_update_netdev_queues(struct mlx5e_priv *priv, u16 count) 2873 + { 2874 + int num_txqs = count * priv->channels.params.num_tc; 2875 + int num_rxqs = count * priv->profile->rq_groups; 2876 + struct net_device *netdev = priv->netdev; 2877 + 2878 + mlx5e_netdev_set_tcs(netdev); 2879 + netif_set_real_num_tx_queues(netdev, num_txqs); 2880 + netif_set_real_num_rx_queues(netdev, num_rxqs); 2881 + } 2882 + 2883 + static void mlx5e_set_default_xps_cpumasks(struct mlx5e_priv *priv, 2884 + struct mlx5e_params *params) 2885 + { 2886 + struct mlx5_core_dev *mdev = priv->mdev; 2887 + int num_comp_vectors, ix, irq; 2888 + 2889 + num_comp_vectors = mlx5_comp_vectors_count(mdev); 2890 + 2891 + for (ix = 0; ix < params->num_channels; ix++) { 2892 + cpumask_clear(priv->scratchpad.cpumask); 2893 + 2894 + for (irq = ix; irq < num_comp_vectors; irq += params->num_channels) { 2895 + int cpu = cpumask_first(mlx5_comp_irq_get_affinity_mask(mdev, irq)); 2896 + 2897 + cpumask_set_cpu(cpu, priv->scratchpad.cpumask); 2898 + } 2899 + 2900 + netif_set_xps_queue(priv->netdev, priv->scratchpad.cpumask, ix); 2901 + } 2902 + } 2903 + 2904 + int mlx5e_num_channels_changed(struct mlx5e_priv *priv) 2905 + { 2906 + u16 count = priv->channels.params.num_channels; 2907 + 2908 + mlx5e_update_netdev_queues(priv, count); 2909 + mlx5e_set_default_xps_cpumasks(priv, &priv->channels.params); 2910 + 2911 + if (!netif_is_rxfh_configured(priv->netdev)) 2912 + mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt, 2913 + MLX5E_INDIR_RQT_SIZE, count); 2914 + 2915 + return 0; 2916 + } 2917 + 2918 + MLX5E_DEFINE_PREACTIVATE_WRAPPER_CTX(mlx5e_num_channels_changed); 2919 + 2845 2920 static void mlx5e_build_txq_maps(struct mlx5e_priv *priv) 2846 2921 { 2847 2922 int i, ch; ··· 2911 2890 2912 2891 void mlx5e_activate_priv_channels(struct mlx5e_priv *priv) 2913 2892 { 2914 - int num_txqs = priv->channels.num * priv->channels.params.num_tc; 2915 - int num_rxqs = priv->channels.num * priv->profile->rq_groups; 2916 - struct net_device *netdev = priv->netdev; 2917 - 2918 - mlx5e_netdev_set_tcs(netdev); 2919 - netif_set_real_num_tx_queues(netdev, num_txqs); 2920 - netif_set_real_num_rx_queues(netdev, num_rxqs); 2921 - 2922 2893 mlx5e_build_txq_maps(priv); 2923 2894 mlx5e_activate_channels(&priv->channels); 2924 2895 mlx5e_xdp_tx_enable(priv); ··· 2943 2930 mlx5e_deactivate_channels(&priv->channels); 2944 2931 } 2945 2932 2946 - static void mlx5e_switch_priv_channels(struct mlx5e_priv *priv, 2947 - struct mlx5e_channels *new_chs, 2948 - mlx5e_fp_hw_modify hw_modify) 2933 + static int mlx5e_switch_priv_channels(struct mlx5e_priv *priv, 2934 + struct mlx5e_channels *new_chs, 2935 + mlx5e_fp_preactivate preactivate, 2936 + void *context) 2949 2937 { 2950 2938 struct net_device *netdev = priv->netdev; 2951 - int new_num_txqs; 2939 + struct mlx5e_channels old_chs; 2952 2940 int carrier_ok; 2953 - 2954 - new_num_txqs = new_chs->num * new_chs->params.num_tc; 2941 + int err = 0; 2955 2942 2956 2943 carrier_ok = netif_carrier_ok(netdev); 2957 2944 netif_carrier_off(netdev); 2958 2945 2959 - if (new_num_txqs < netdev->real_num_tx_queues) 2960 - netif_set_real_num_tx_queues(netdev, new_num_txqs); 2961 - 2962 2946 mlx5e_deactivate_priv_channels(priv); 2963 - mlx5e_close_channels(&priv->channels); 2964 2947 2948 + old_chs = priv->channels; 2965 2949 priv->channels = *new_chs; 2966 2950 2967 - /* New channels are ready to roll, modify HW settings if needed */ 2968 - if (hw_modify) 2969 - hw_modify(priv); 2951 + /* New channels are ready to roll, call the preactivate hook if needed 2952 + * to modify HW settings or update kernel parameters. 2953 + */ 2954 + if (preactivate) { 2955 + err = preactivate(priv, context); 2956 + if (err) { 2957 + priv->channels = old_chs; 2958 + goto out; 2959 + } 2960 + } 2970 2961 2962 + mlx5e_close_channels(&old_chs); 2971 2963 priv->profile->update_rx(priv); 2964 + 2965 + out: 2972 2966 mlx5e_activate_priv_channels(priv); 2973 2967 2974 2968 /* return carrier back if needed */ 2975 2969 if (carrier_ok) 2976 2970 netif_carrier_on(netdev); 2971 + 2972 + return err; 2977 2973 } 2978 2974 2979 2975 int mlx5e_safe_switch_channels(struct mlx5e_priv *priv, 2980 2976 struct mlx5e_channels *new_chs, 2981 - mlx5e_fp_hw_modify hw_modify) 2977 + mlx5e_fp_preactivate preactivate, 2978 + void *context) 2982 2979 { 2983 2980 int err; 2984 2981 ··· 2996 2973 if (err) 2997 2974 return err; 2998 2975 2999 - mlx5e_switch_priv_channels(priv, new_chs, hw_modify); 2976 + err = mlx5e_switch_priv_channels(priv, new_chs, preactivate, context); 2977 + if (err) 2978 + goto err_close; 2979 + 3000 2980 return 0; 2981 + 2982 + err_close: 2983 + mlx5e_close_channels(new_chs); 2984 + 2985 + return err; 3001 2986 } 3002 2987 3003 2988 int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv) ··· 3013 2982 struct mlx5e_channels new_channels = {}; 3014 2983 3015 2984 new_channels.params = priv->channels.params; 3016 - return mlx5e_safe_switch_channels(priv, &new_channels, NULL); 2985 + return mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); 3017 2986 } 3018 2987 3019 2988 void mlx5e_timestamp_init(struct mlx5e_priv *priv) ··· 3462 3431 goto out; 3463 3432 } 3464 3433 3465 - err = mlx5e_safe_switch_channels(priv, &new_channels, NULL); 3434 + err = mlx5e_safe_switch_channels(priv, &new_channels, 3435 + mlx5e_num_channels_changed_ctx, NULL); 3466 3436 if (err) 3467 3437 goto out; 3468 3438 ··· 3676 3644 goto out; 3677 3645 } 3678 3646 3679 - err = mlx5e_safe_switch_channels(priv, &new_channels, mlx5e_modify_tirs_lro); 3647 + err = mlx5e_safe_switch_channels(priv, &new_channels, 3648 + mlx5e_modify_tirs_lro_ctx, NULL); 3680 3649 out: 3681 3650 mutex_unlock(&priv->state_lock); 3682 3651 return err; ··· 3896 3863 } 3897 3864 3898 3865 int mlx5e_change_mtu(struct net_device *netdev, int new_mtu, 3899 - change_hw_mtu_cb set_mtu_cb) 3866 + mlx5e_fp_preactivate preactivate) 3900 3867 { 3901 3868 struct mlx5e_priv *priv = netdev_priv(netdev); 3902 3869 struct mlx5e_channels new_channels = {}; ··· 3945 3912 3946 3913 if (!reset) { 3947 3914 params->sw_mtu = new_mtu; 3948 - if (set_mtu_cb) 3949 - set_mtu_cb(priv); 3915 + if (preactivate) 3916 + preactivate(priv, NULL); 3950 3917 netdev->mtu = params->sw_mtu; 3951 3918 goto out; 3952 3919 } 3953 3920 3954 - err = mlx5e_safe_switch_channels(priv, &new_channels, set_mtu_cb); 3921 + err = mlx5e_safe_switch_channels(priv, &new_channels, preactivate, NULL); 3955 3922 if (err) 3956 3923 goto out; 3957 3924 ··· 3964 3931 3965 3932 static int mlx5e_change_nic_mtu(struct net_device *netdev, int new_mtu) 3966 3933 { 3967 - return mlx5e_change_mtu(netdev, new_mtu, mlx5e_set_dev_port_mtu); 3934 + return mlx5e_change_mtu(netdev, new_mtu, mlx5e_set_dev_port_mtu_ctx); 3968 3935 } 3969 3936 3970 3937 int mlx5e_hwstamp_set(struct mlx5e_priv *priv, struct ifreq *ifr) ··· 4425 4392 mlx5e_set_rq_type(priv->mdev, &new_channels.params); 4426 4393 old_prog = priv->channels.params.xdp_prog; 4427 4394 4428 - err = mlx5e_safe_switch_channels(priv, &new_channels, NULL); 4395 + err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); 4429 4396 if (err) 4430 4397 goto unlock; 4431 4398 } else { ··· 4803 4770 mlx5e_build_rq_params(mdev, params); 4804 4771 4805 4772 /* HW LRO */ 4806 - 4807 - /* TODO: && MLX5_CAP_ETH(mdev, lro_cap) */ 4808 - if (params->rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ) { 4773 + if (MLX5_CAP_ETH(mdev, lro_cap) && 4774 + params->rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ) { 4809 4775 /* No XSK params: checking the availability of striding RQ in general. */ 4810 4776 if (!mlx5e_rx_mpwqe_is_linear_skb(mdev, params, NULL)) 4811 4777 params->lro_en = !slow_pci_heuristic(mdev); ··· 5246 5214 priv->max_nch = netdev->num_rx_queues / max_t(u8, profile->rq_groups, 1); 5247 5215 priv->max_opened_tc = 1; 5248 5216 5217 + if (!alloc_cpumask_var(&priv->scratchpad.cpumask, GFP_KERNEL)) 5218 + return -ENOMEM; 5219 + 5249 5220 mutex_init(&priv->state_lock); 5250 5221 INIT_WORK(&priv->update_carrier_work, mlx5e_update_carrier_work); 5251 5222 INIT_WORK(&priv->set_rx_mode_work, mlx5e_set_rx_mode_work); ··· 5257 5222 5258 5223 priv->wq = create_singlethread_workqueue("mlx5e"); 5259 5224 if (!priv->wq) 5260 - return -ENOMEM; 5225 + goto err_free_cpumask; 5261 5226 5262 5227 /* netdev init */ 5263 5228 netif_carrier_off(netdev); ··· 5267 5232 #endif 5268 5233 5269 5234 return 0; 5235 + 5236 + err_free_cpumask: 5237 + free_cpumask_var(priv->scratchpad.cpumask); 5238 + 5239 + return -ENOMEM; 5270 5240 } 5271 5241 5272 5242 void mlx5e_netdev_cleanup(struct net_device *netdev, struct mlx5e_priv *priv) 5273 5243 { 5274 5244 destroy_workqueue(priv->wq); 5245 + free_cpumask_var(priv->scratchpad.cpumask); 5275 5246 } 5276 5247 5277 5248 struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev, ··· 5312 5271 5313 5272 int mlx5e_attach_netdev(struct mlx5e_priv *priv) 5314 5273 { 5274 + const bool take_rtnl = priv->netdev->reg_state == NETREG_REGISTERED; 5315 5275 const struct mlx5e_profile *profile; 5316 5276 int max_nch; 5317 5277 int err; ··· 5324 5282 max_nch = mlx5e_get_max_num_channels(priv->mdev); 5325 5283 if (priv->channels.params.num_channels > max_nch) { 5326 5284 mlx5_core_warn(priv->mdev, "MLX5E: Reducing number of channels to %d\n", max_nch); 5285 + /* Reducing the number of channels - RXFH has to be reset, and 5286 + * mlx5e_num_channels_changed below will build the RQT. 5287 + */ 5288 + priv->netdev->priv_flags &= ~IFF_RXFH_CONFIGURED; 5327 5289 priv->channels.params.num_channels = max_nch; 5328 - mlx5e_build_default_indir_rqt(priv->rss_params.indirection_rqt, 5329 - MLX5E_INDIR_RQT_SIZE, max_nch); 5330 5290 } 5291 + /* 1. Set the real number of queues in the kernel the first time. 5292 + * 2. Set our default XPS cpumask. 5293 + * 3. Build the RQT. 5294 + * 5295 + * rtnl_lock is required by netif_set_real_num_*_queues in case the 5296 + * netdev has been registered by this point (if this function was called 5297 + * in the reload or resume flow). 5298 + */ 5299 + if (take_rtnl) 5300 + rtnl_lock(); 5301 + mlx5e_num_channels_changed(priv); 5302 + if (take_rtnl) 5303 + rtnl_unlock(); 5331 5304 5332 5305 err = profile->init_tx(priv); 5333 5306 if (err)
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
··· 1396 1396 1397 1397 static int mlx5e_uplink_rep_change_mtu(struct net_device *netdev, int new_mtu) 1398 1398 { 1399 - return mlx5e_change_mtu(netdev, new_mtu, mlx5e_set_dev_port_mtu); 1399 + return mlx5e_change_mtu(netdev, new_mtu, mlx5e_set_dev_port_mtu_ctx); 1400 1400 } 1401 1401 1402 1402 static int mlx5e_uplink_rep_set_mac(struct net_device *netdev, void *addr)
+4 -2
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
··· 158 158 mlx5e_read_mini_arr_slot(wq, cqd, cqcc); 159 159 160 160 mlx5e_decompress_cqe_no_hash(rq, wq, cqcc); 161 - rq->handle_rx_cqe(rq, &cqd->title); 161 + INDIRECT_CALL_2(rq->handle_rx_cqe, mlx5e_handle_rx_cqe_mpwrq, 162 + mlx5e_handle_rx_cqe, rq, &cqd->title); 162 163 } 163 164 mlx5e_cqes_update_owner(wq, cqcc - wq->cc); 164 165 wq->cc = cqcc; ··· 179 178 mlx5e_read_title_slot(rq, wq, cc); 180 179 mlx5e_read_mini_arr_slot(wq, cqd, cc + 1); 181 180 mlx5e_decompress_cqe(rq, wq, cc); 182 - rq->handle_rx_cqe(rq, &cqd->title); 181 + INDIRECT_CALL_2(rq->handle_rx_cqe, mlx5e_handle_rx_cqe_mpwrq, 182 + mlx5e_handle_rx_cqe, rq, &cqd->title); 183 183 cqd->mini_arr_idx++; 184 184 185 185 return mlx5e_decompress_cqes_cont(rq, wq, 1, budget_rem) - 1;
+6 -7
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
··· 72 72 { 73 73 int txq_ix = netdev_pick_tx(dev, skb, NULL); 74 74 struct mlx5e_priv *priv = netdev_priv(dev); 75 - u16 num_channels; 76 75 int up = 0; 76 + int ch_ix; 77 77 78 78 if (!netdev_get_num_tc(dev)) 79 79 return txq_ix; ··· 86 86 if (skb_vlan_tag_present(skb)) 87 87 up = skb_vlan_tag_get_prio(skb); 88 88 89 - /* txq_ix can be larger than num_channels since 90 - * dev->num_real_tx_queues = num_channels * num_tc 89 + /* Normalize any picked txq_ix to [0, num_channels), 90 + * So we can return a txq_ix that matches the channel and 91 + * packet UP. 91 92 */ 92 - num_channels = priv->channels.params.num_channels; 93 - if (txq_ix >= num_channels) 94 - txq_ix = priv->txq2sq[txq_ix]->ch_ix; 93 + ch_ix = priv->txq2sq[txq_ix]->ch_ix; 95 94 96 - return priv->channel_tc2realtxq[txq_ix][up]; 95 + return priv->channel_tc2realtxq[ch_ix][up]; 97 96 } 98 97 99 98 static inline int mlx5e_skb_l2_header_offset(struct sk_buff *skb)
+9 -2
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
··· 31 31 */ 32 32 33 33 #include <linux/irq.h> 34 + #include <linux/indirect_call_wrapper.h> 34 35 #include "en.h" 35 36 #include "en/xdp.h" 36 37 #include "en/xsk/rx.h" ··· 100 99 busy_xsk |= mlx5e_xsk_tx(xsksq, MLX5E_TX_XSK_POLL_BUDGET); 101 100 mlx5e_xsk_update_tx_wakeup(xsksq); 102 101 103 - xsk_rx_alloc_err = xskrq->post_wqes(xskrq); 102 + xsk_rx_alloc_err = INDIRECT_CALL_2(xskrq->post_wqes, 103 + mlx5e_post_rx_mpwqes, 104 + mlx5e_post_rx_wqes, 105 + xskrq); 104 106 busy_xsk |= mlx5e_xsk_update_rx_wakeup(xskrq, xsk_rx_alloc_err); 105 107 106 108 return busy_xsk; ··· 146 142 147 143 mlx5e_poll_ico_cq(&c->icosq.cq); 148 144 149 - busy |= rq->post_wqes(rq); 145 + busy |= INDIRECT_CALL_2(rq->post_wqes, 146 + mlx5e_post_rx_mpwqes, 147 + mlx5e_post_rx_wqes, 148 + rq); 150 149 if (xsk_open) { 151 150 mlx5e_poll_ico_cq(&c->xskicosq.cq); 152 151 busy |= mlx5e_poll_xdpsq_cq(&xsksq->cq);
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
··· 483 483 new_channels.params = *params; 484 484 new_channels.params.sw_mtu = new_mtu; 485 485 486 - err = mlx5e_safe_switch_channels(priv, &new_channels, NULL); 486 + err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); 487 487 if (err) 488 488 goto out; 489 489
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c
··· 21 21 struct mlx5_dm *dm; 22 22 23 23 if (!(MLX5_CAP_GEN_64(dev, general_obj_types) & MLX5_GENERAL_OBJ_TYPES_CAP_SW_ICM)) 24 - return 0; 24 + return NULL; 25 25 26 26 dm = kzalloc(sizeof(*dm), GFP_KERNEL); 27 27 if (!dm)