History

Merge tag 'mlx5-updates-2017-01-24' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux

Saeed Mahameed says: ==================== mlx5-updates-2017-24-01 The first seven patches from Or Gerlitz in this series further enhances the mlx5 SRIOV switchdev mode to support offloading IPv6 tunnels using the TC tunnel key set (encap) and unset (decap) actions. Or Gerlitz says: ======================== As part of doing this change, few cleanups are done in the IPv4 code, later we move to use the full tunnel key info provided to the driver as the key for our internal hashing which is used to identify cases where the same tunnel is used for encapsulating multiple flows. As done in the IPv4 case, the control path for offloading IPv6 tunnels uses route/neigh lookups and construction of the IPv6 tunnel headers on the encap path and matching on the outer hears in the decap path. The last patch of the series enlarges the HW FDB size for the switchdev mode, so it has now room to contain offloaded flows as many as min(max number of HW flow counters supported, max HW table size supported). ======================== Next to Or's series you can find several patches handling several topics. From Mohamad, add support for SRIOV VF min rate guarantee by using the TSAR BW share weights mechanism. From Or, Two patches to enable Eth VFs to query their min-inline value for user-space. for that we move a mlx5 low level min inline helper function from mlx5 ethernet driver into the core driver and then use it in mlx5_ib to expose the inline mode to rdma applications through libmlx5. From Kamal Heib, Reduce memory consumption on kdump kernel. From Shaker Daibes, code reuse in CQE compression control logic ====================

David S. Miller committed 9 years ago

Commit 716dcae2 parents a08ef47 5eb024915 files · +389 −120Browse files

Unified · Split

15 files
  1. drivers/infiniband/hw/mlx5/main.c +9 −0
  2. drivers/net/ethernet/mellanox/mlx5/core/en.h +2 −7
  3. drivers/net/ethernet/mellanox/mlx5/core/en_clock.c +5 −2
  4. drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +4 −13
  5. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +20 −24
  6. drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +2 −6
  7. drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +198 −44
  8. drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +91 −6
  9. drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +11 −9
  10. drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +8 −5
  11. drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +5 −2
  12. drivers/net/ethernet/mellanox/mlx5/core/vport.c +17 −0
  13. include/linux/mlx5/mlx5_ifc.h +3 −1
  14. include/linux/mlx5/vport.h +1 −0
  15. include/uapi/rdma/mlx5-abi.h +13 −1
drivers/infiniband/hw/mlx5/main.c+9−0
@@ -53,6 +53,7 @@ · 52 unmodified lines
53#include <linux/in.h>53#include <linux/in.h>
54#include <linux/etherdevice.h>54#include <linux/etherdevice.h>
55#include <linux/mlx5/fs.h>55#include <linux/mlx5/fs.h>
56#include <linux/mlx5/vport.h>
56#include "mlx5_ib.h"57#include "mlx5_ib.h"
57 58
58#define DRIVER_NAME "mlx5_ib"59#define DRIVER_NAME "mlx5_ib"
@@ -1202,6 +1203,14 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, · 1143 unmodified lines
1202 resp.response_length += sizeof(resp.cmds_supp_uhw);1203 resp.response_length += sizeof(resp.cmds_supp_uhw);
1203 }1204 }
1204 1205
1206 if (field_avail(typeof(resp), eth_min_inline, udata->outlen)) {
1207 if (mlx5_ib_port_link_layer(ibdev, 1) == IB_LINK_LAYER_ETHERNET) {
1208 mlx5_query_min_inline(dev->mdev, &resp.eth_min_inline);
1209 resp.eth_min_inline++;
1210 }
1211 resp.response_length += sizeof(resp.eth_min_inline);
1212 }
1213
1205 /*1214 /*
1206 * We don't want to expose information from the PCI bar that is located1215 * We don't want to expose information from the PCI bar that is located
1207 * after 4096 bytes, so if the arch only supports larger pages, let's1216 * after 4096 bytes, so if the arch only supports larger pages, let's
drivers/net/ethernet/mellanox/mlx5/core/en.h+2−7
@@ -101,6 +101,7 @@ · 100 unmodified lines
101 101
102#define MLX5E_LOG_INDIR_RQT_SIZE 0x7102#define MLX5E_LOG_INDIR_RQT_SIZE 0x7
103#define MLX5E_INDIR_RQT_SIZE BIT(MLX5E_LOG_INDIR_RQT_SIZE)103#define MLX5E_INDIR_RQT_SIZE BIT(MLX5E_LOG_INDIR_RQT_SIZE)
104#define MLX5E_MIN_NUM_CHANNELS 0x1
104#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1)105#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1)
105#define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC)106#define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC)
106#define MLX5E_TX_CQ_POLL_BUDGET 128107#define MLX5E_TX_CQ_POLL_BUDGET 128
@@ -786,7 +787,7 @@ void mlx5e_pps_event_handler(struct mlx5e_priv *priv, · 679 unmodified lines
786 struct ptp_clock_event *event);787 struct ptp_clock_event *event);
787int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr);788int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr);
788int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr);789int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr);
789void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val);790void mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val);
790 791
791int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,792int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
792 u16 vid);793 u16 vid);
@@ -847,12 +848,6 @@ static inline u32 mlx5e_get_wqe_mtt_offset(struct mlx5e_rq *rq, u16 wqe_ix) · 54 unmodified lines
847 return wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8);848 return wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8);
848}849}
849 850
850static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
851{
852 return min_t(int, mdev->priv.eq_table.num_comp_vectors,
853 MLX5E_MAX_NUM_CHANNELS);
854}
855
856extern const struct ethtool_ops mlx5e_ethtool_ops;851extern const struct ethtool_ops mlx5e_ethtool_ops;
857#ifdef CONFIG_MLX5_CORE_EN_DCB852#ifdef CONFIG_MLX5_CORE_EN_DCB
858extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops;853extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops;
drivers/net/ethernet/mellanox/mlx5/core/en_clock.c+5−2
@@ -106,11 +106,12 @@ int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr) · 105 unmodified lines
106 return -ERANGE;106 return -ERANGE;
107 }107 }
108 108
109 mutex_lock(&priv->state_lock);
109 /* RX HW timestamp */110 /* RX HW timestamp */
110 switch (config.rx_filter) {111 switch (config.rx_filter) {
111 case HWTSTAMP_FILTER_NONE:112 case HWTSTAMP_FILTER_NONE:
112 /* Reset CQE compression to Admin default */113 /* Reset CQE compression to Admin default */
113 mlx5e_modify_rx_cqe_compression(priv, priv->params.rx_cqe_compress_def);114 mlx5e_modify_rx_cqe_compression_locked(priv, priv->params.rx_cqe_compress_def);
114 break;115 break;
115 case HWTSTAMP_FILTER_ALL:116 case HWTSTAMP_FILTER_ALL:
116 case HWTSTAMP_FILTER_SOME:117 case HWTSTAMP_FILTER_SOME:
@@ -128,14 +129,16 @@ int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr) · 11 unmodified lines
128 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:129 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
129 /* Disable CQE compression */130 /* Disable CQE compression */
130 netdev_warn(dev, "Disabling cqe compression");131 netdev_warn(dev, "Disabling cqe compression");
131 mlx5e_modify_rx_cqe_compression(priv, false);132 mlx5e_modify_rx_cqe_compression_locked(priv, false);
132 config.rx_filter = HWTSTAMP_FILTER_ALL;133 config.rx_filter = HWTSTAMP_FILTER_ALL;
133 break;134 break;
134 default:135 default:
136 mutex_unlock(&priv->state_lock);
135 return -ERANGE;137 return -ERANGE;
136 }138 }
137 139
138 memcpy(&priv->tstamp.hwtstamp_config, &config, sizeof(config));140 memcpy(&priv->tstamp.hwtstamp_config, &config, sizeof(config));
141 mutex_unlock(&priv->state_lock);
139 142
140 return copy_to_user(ifr->ifr_data, &config,143 return copy_to_user(ifr->ifr_data, &config,
141 sizeof(config)) ? -EFAULT : 0;144 sizeof(config)) ? -EFAULT : 0;
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c+4−13
@@ -552,7 +552,7 @@ static void mlx5e_get_channels(struct net_device *dev, · 551 unmodified lines
552{552{
553 struct mlx5e_priv *priv = netdev_priv(dev);553 struct mlx5e_priv *priv = netdev_priv(dev);
554 554
555 ch->max_combined = mlx5e_get_max_num_channels(priv->mdev);555 ch->max_combined = priv->profile->max_nch(priv->mdev);
556 ch->combined_count = priv->params.num_channels;556 ch->combined_count = priv->params.num_channels;
557}557}
558 558
@@ -560,7 +560,7 @@ static int mlx5e_set_channels(struct net_device *dev, · 1 unmodified line
560 struct ethtool_channels *ch)560 struct ethtool_channels *ch)
561{561{
562 struct mlx5e_priv *priv = netdev_priv(dev);562 struct mlx5e_priv *priv = netdev_priv(dev);
563 int ncv = mlx5e_get_max_num_channels(priv->mdev);563 int ncv = priv->profile->max_nch(priv->mdev);
564 unsigned int count = ch->combined_count;564 unsigned int count = ch->combined_count;
565 bool arfs_enabled;565 bool arfs_enabled;
566 bool was_opened;566 bool was_opened;
@@ -1476,8 +1476,6 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev, · 909 unmodified lines
1476{1476{
1477 struct mlx5e_priv *priv = netdev_priv(netdev);1477 struct mlx5e_priv *priv = netdev_priv(netdev);
1478 struct mlx5_core_dev *mdev = priv->mdev;1478 struct mlx5_core_dev *mdev = priv->mdev;
1479 int err = 0;
1480 bool reset;
1481 1479
1482 if (!MLX5_CAP_GEN(mdev, cqe_compression))1480 if (!MLX5_CAP_GEN(mdev, cqe_compression))
1483 return -ENOTSUPP;1481 return -ENOTSUPP;
@@ -1487,17 +1485,10 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev, · 3 unmodified lines
1487 return -EINVAL;1485 return -EINVAL;
1488 }1486 }
1489 1487
1490 reset = test_bit(MLX5E_STATE_OPENED, &priv->state);1488 mlx5e_modify_rx_cqe_compression_locked(priv, enable);
1491
1492 if (reset)
1493 mlx5e_close_locked(netdev);
1494
1495 MLX5E_SET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS, enable);
1496 priv->params.rx_cqe_compress_def = enable;1489 priv->params.rx_cqe_compress_def = enable;
1497 1490
1498 if (reset)1491 return 0;
1499 err = mlx5e_open_locked(netdev);
1500 return err;
1501}1492}
1502 1493
1503static int mlx5e_handle_pflag(struct net_device *netdev,1494static int mlx5e_handle_pflag(struct net_device *netdev,
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+20−24
@@ -31,6 +31,7 @@ · 30 unmodified lines
31 */31 */
32 32
33#include <net/tc_act/tc_gact.h>33#include <net/tc_act/tc_gact.h>
34#include <linux/crash_dump.h>
34#include <net/pkt_cls.h>35#include <net/pkt_cls.h>
35#include <linux/mlx5/fs.h>36#include <linux/mlx5/fs.h>
36#include <net/vxlan.h>37#include <net/vxlan.h>
@@ -83,7 +84,9 @@ static void mlx5e_set_rq_type_params(struct mlx5e_priv *priv, u8 rq_type) · 46 unmodified lines
83 priv->params.rq_wq_type = rq_type;84 priv->params.rq_wq_type = rq_type;
84 switch (priv->params.rq_wq_type) {85 switch (priv->params.rq_wq_type) {
85 case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:86 case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
86 priv->params.log_rq_size = MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW;87 priv->params.log_rq_size = is_kdump_kernel() ?
88 MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW :
89 MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW;
87 priv->params.mpwqe_log_stride_sz =90 priv->params.mpwqe_log_stride_sz =
88 MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) ?91 MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) ?
89 MLX5_MPWRQ_LOG_STRIDE_SIZE_CQE_COMPRESS :92 MLX5_MPWRQ_LOG_STRIDE_SIZE_CQE_COMPRESS :
@@ -92,7 +95,9 @@ static void mlx5e_set_rq_type_params(struct mlx5e_priv *priv, u8 rq_type) · 2 unmodified lines
92 priv->params.mpwqe_log_stride_sz;95 priv->params.mpwqe_log_stride_sz;
93 break;96 break;
94 default: /* MLX5_WQ_TYPE_LINKED_LIST */97 default: /* MLX5_WQ_TYPE_LINKED_LIST */
95 priv->params.log_rq_size = MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE;98 priv->params.log_rq_size = is_kdump_kernel() ?
99 MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE :
100 MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE;
96 }101 }
97 priv->params.min_rx_wqes = mlx5_min_rx_wqes(priv->params.rq_wq_type,102 priv->params.min_rx_wqes = mlx5_min_rx_wqes(priv->params.rq_wq_type,
98 BIT(priv->params.log_rq_size));103 BIT(priv->params.log_rq_size));
@@ -1508,6 +1513,14 @@ static int mlx5e_set_tx_maxrate(struct net_device *dev, int index, u32 rate) · 1409 unmodified lines
1508 return err;1513 return err;
1509}1514}
1510 1515
1516static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
1517{
1518 return is_kdump_kernel() ?
1519 MLX5E_MIN_NUM_CHANNELS :
1520 min_t(int, mdev->priv.eq_table.num_comp_vectors,
1521 MLX5E_MAX_NUM_CHANNELS);
1522}
1523
1511static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,1524static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
1512 struct mlx5e_channel_param *cparam,1525 struct mlx5e_channel_param *cparam,
1513 struct mlx5e_channel **cp)1526 struct mlx5e_channel **cp)
@@ -3021,11 +3034,8 @@ static int mlx5e_set_vf_rate(struct net_device *dev, int vf, int min_tx_rate, · 1507 unmodified lines
3021 struct mlx5e_priv *priv = netdev_priv(dev);3034 struct mlx5e_priv *priv = netdev_priv(dev);
3022 struct mlx5_core_dev *mdev = priv->mdev;3035 struct mlx5_core_dev *mdev = priv->mdev;
3023 3036
3024 if (min_tx_rate)
3025 return -EOPNOTSUPP;
3026
3027 return mlx5_eswitch_set_vport_rate(mdev->priv.eswitch, vf + 1,3037 return mlx5_eswitch_set_vport_rate(mdev->priv.eswitch, vf + 1,
3028 max_tx_rate);3038 max_tx_rate, min_tx_rate);
3029}3039}
3030 3040
3031static int mlx5_vport_link2ifla(u8 esw_link)3041static int mlx5_vport_link2ifla(u8 esw_link)
@@ -3461,22 +3471,6 @@ void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode) · 429 unmodified lines
3461 MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE;3471 MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE;
3462}3472}
3463 3473
3464static void mlx5e_query_min_inline(struct mlx5_core_dev *mdev,
3465 u8 *min_inline_mode)
3466{
3467 switch (MLX5_CAP_ETH(mdev, wqe_inline_mode)) {
3468 case MLX5_CAP_INLINE_MODE_L2:
3469 *min_inline_mode = MLX5_INLINE_MODE_L2;
3470 break;
3471 case MLX5_CAP_INLINE_MODE_VPORT_CONTEXT:
3472 mlx5_query_nic_vport_min_inline(mdev, 0, min_inline_mode);
3473 break;
3474 case MLX5_CAP_INLINE_MODE_NOT_REQUIRED:
3475 *min_inline_mode = MLX5_INLINE_MODE_NONE;
3476 break;
3477 }
3478}
3479
3480u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout)3474u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout)
3481{3475{
3482 int i;3476 int i;
@@ -3510,7 +3504,9 @@ static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev, · 27 unmodified lines
3510 priv->params.lro_timeout =3504 priv->params.lro_timeout =
3511 mlx5e_choose_lro_timeout(mdev, MLX5E_DEFAULT_LRO_TIMEOUT);3505 mlx5e_choose_lro_timeout(mdev, MLX5E_DEFAULT_LRO_TIMEOUT);
3512 3506
3513 priv->params.log_sq_size = MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;3507 priv->params.log_sq_size = is_kdump_kernel() ?
3508 MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE :
3509 MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;
3514 3510
3515 /* set CQE compression */3511 /* set CQE compression */
3516 priv->params.rx_cqe_compress_def = false;3512 priv->params.rx_cqe_compress_def = false;
@@ -3536,7 +3532,7 @@ static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev, · 19 unmodified lines
3536 priv->params.tx_cq_moderation.pkts =3532 priv->params.tx_cq_moderation.pkts =
3537 MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS;3533 MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS;
3538 priv->params.tx_max_inline = mlx5e_get_max_inline_cap(mdev);3534 priv->params.tx_max_inline = mlx5e_get_max_inline_cap(mdev);
3539 mlx5e_query_min_inline(mdev, &priv->params.tx_min_inline_mode);3535 mlx5_query_min_inline(mdev, &priv->params.tx_min_inline_mode);
3540 priv->params.num_tc = 1;3536 priv->params.num_tc = 1;
3541 priv->params.rss_hfunc = ETH_RSS_HASH_XOR;3537 priv->params.rss_hfunc = ETH_RSS_HASH_XOR;
3542 3538
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c+2−6
@@ -155,17 +155,15 @@ static inline u32 mlx5e_decompress_cqes_start(struct mlx5e_rq *rq, · 154 unmodified lines
155 return mlx5e_decompress_cqes_cont(rq, cq, 1, budget_rem) - 1;155 return mlx5e_decompress_cqes_cont(rq, cq, 1, budget_rem) - 1;
156}156}
157 157
158void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val)158void mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val)
159{159{
160 bool was_opened;160 bool was_opened;
161 161
162 if (!MLX5_CAP_GEN(priv->mdev, cqe_compression))162 if (!MLX5_CAP_GEN(priv->mdev, cqe_compression))
163 return;163 return;
164 164
165 mutex_lock(&priv->state_lock);
166
167 if (MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) == val)165 if (MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) == val)
168 goto unlock;166 return;
169 167
170 was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);168 was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
171 if (was_opened)169 if (was_opened)
@@ -176,8 +174,6 @@ void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val) · 4 unmodified lines
176 if (was_opened)174 if (was_opened)
177 mlx5e_open_locked(priv->netdev);175 mlx5e_open_locked(priv->netdev);
178 176
179unlock:
180 mutex_unlock(&priv->state_lock);
181}177}
182 178
183#define RQ_PAGE_SIZE(rq) ((1 << rq->buff.page_order) << PAGE_SHIFT)179#define RQ_PAGE_SIZE(rq) ((1 << rq->buff.page_order) << PAGE_SHIFT)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c+198−44
@@ -298,6 +298,32 @@ vxlan_match_offload_err: · 297 unmodified lines
298 298
299 MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, ethertype);299 MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, ethertype);
300 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype, ETH_P_IP);300 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype, ETH_P_IP);
301 } else if (enc_control->addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
302 struct flow_dissector_key_ipv6_addrs *key =
303 skb_flow_dissector_target(f->dissector,
304 FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS,
305 f->key);
306 struct flow_dissector_key_ipv6_addrs *mask =
307 skb_flow_dissector_target(f->dissector,
308 FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS,
309 f->mask);
310
311 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_c,
312 src_ipv4_src_ipv6.ipv6_layout.ipv6),
313 &mask->src, MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6));
314 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
315 src_ipv4_src_ipv6.ipv6_layout.ipv6),
316 &key->src, MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6));
317
318 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_c,
319 dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
320 &mask->dst, MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6));
321 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
322 dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
323 &key->dst, MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6));
324
325 MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, ethertype);
326 MLX5_SET(fte_match_set_lyr_2_4, headers_v, ethertype, ETH_P_IPV6);
301 }327 }
302 328
303 /* Enforce DMAC when offloading incoming tunneled flows.329 /* Enforce DMAC when offloading incoming tunneled flows.
@@ -358,12 +384,10 @@ static int __parse_cls_flower(struct mlx5e_priv *priv, · 54 unmodified lines
358 f->key);384 f->key);
359 switch (key->addr_type) {385 switch (key->addr_type) {
360 case FLOW_DISSECTOR_KEY_IPV4_ADDRS:386 case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
387 case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
361 if (parse_tunnel_attr(priv, spec, f))388 if (parse_tunnel_attr(priv, spec, f))
362 return -EOPNOTSUPP;389 return -EOPNOTSUPP;
363 break;390 break;
364 case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
365 netdev_warn(priv->netdev,
366 "IPv6 tunnel decap offload isn't supported\n");
367 default:391 default:
368 return -EOPNOTSUPP;392 return -EOPNOTSUPP;
369 }393 }
@@ -644,15 +668,15 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct tcf_exts *exts, · 274 unmodified lines
644 return 0;668 return 0;
645}669}
646 670
647static inline int cmp_encap_info(struct mlx5_encap_info *a,671static inline int cmp_encap_info(struct ip_tunnel_key *a,
648 struct mlx5_encap_info *b)672 struct ip_tunnel_key *b)
649{673{
650 return memcmp(a, b, sizeof(*a));674 return memcmp(a, b, sizeof(*a));
651}675}
652 676
653static inline int hash_encap_info(struct mlx5_encap_info *info)677static inline int hash_encap_info(struct ip_tunnel_key *key)
654{678{
655 return jhash(info, sizeof(*info), 0);679 return jhash(key, sizeof(*key), 0);
656}680}
657 681
658static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,682static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,
@@ -660,12 +684,10 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv, · 1 unmodified line
660 struct net_device **out_dev,684 struct net_device **out_dev,
661 struct flowi4 *fl4,685 struct flowi4 *fl4,
662 struct neighbour **out_n,686 struct neighbour **out_n,
663 __be32 *saddr,
664 int *out_ttl)687 int *out_ttl)
665{688{
666 struct rtable *rt;689 struct rtable *rt;
667 struct neighbour *n = NULL;690 struct neighbour *n = NULL;
668 int ttl;
669 691
670#if IS_ENABLED(CONFIG_INET)692#if IS_ENABLED(CONFIG_INET)
671 int ret;693 int ret;
@@ -684,20 +706,59 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv, · 12 unmodified lines
684 return -EOPNOTSUPP;706 return -EOPNOTSUPP;
685 }707 }
686 708
687 ttl = ip4_dst_hoplimit(&rt->dst);709 *out_ttl = ip4_dst_hoplimit(&rt->dst);
688 n = dst_neigh_lookup(&rt->dst, &fl4->daddr);710 n = dst_neigh_lookup(&rt->dst, &fl4->daddr);
689 ip_rt_put(rt);711 ip_rt_put(rt);
690 if (!n)712 if (!n)
691 return -ENOMEM;713 return -ENOMEM;
692 714
693 *out_n = n;715 *out_n = n;
694 *saddr = fl4->saddr;
695 *out_ttl = ttl;
696 *out_dev = rt->dst.dev;716 *out_dev = rt->dst.dev;
697 717
698 return 0;718 return 0;
699}719}
700 720
721static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,
722 struct net_device *mirred_dev,
723 struct net_device **out_dev,
724 struct flowi6 *fl6,
725 struct neighbour **out_n,
726 int *out_ttl)
727{
728 struct neighbour *n = NULL;
729 struct dst_entry *dst;
730
731#if IS_ENABLED(CONFIG_INET) && IS_ENABLED(CONFIG_IPV6)
732 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
733 int ret;
734
735 dst = ip6_route_output(dev_net(mirred_dev), NULL, fl6);
736 if (dst->error) {
737 ret = dst->error;
738 dst_release(dst);
739 return ret;
740 }
741
742 *out_ttl = ip6_dst_hoplimit(dst);
743
744 /* if the egress device isn't on the same HW e-switch, we use the uplink */
745 if (!switchdev_port_same_parent_id(priv->netdev, dst->dev))
746 *out_dev = mlx5_eswitch_get_uplink_netdev(esw);
747 else
748 *out_dev = dst->dev;
749#else
750 return -EOPNOTSUPP;
751#endif
752
753 n = dst_neigh_lookup(dst, &fl6->daddr);
754 dst_release(dst);
755 if (!n)
756 return -ENOMEM;
757
758 *out_n = n;
759 return 0;
760}
761
701static int gen_vxlan_header_ipv4(struct net_device *out_dev,762static int gen_vxlan_header_ipv4(struct net_device *out_dev,
702 char buf[],763 char buf[],
703 unsigned char h_dest[ETH_ALEN],764 unsigned char h_dest[ETH_ALEN],
@@ -734,19 +795,52 @@ static int gen_vxlan_header_ipv4(struct net_device *out_dev, · 30 unmodified lines
734 return encap_size;795 return encap_size;
735}796}
736 797
798static int gen_vxlan_header_ipv6(struct net_device *out_dev,
799 char buf[],
800 unsigned char h_dest[ETH_ALEN],
801 int ttl,
802 struct in6_addr *daddr,
803 struct in6_addr *saddr,
804 __be16 udp_dst_port,
805 __be32 vx_vni)
806{
807 int encap_size = VXLAN_HLEN + sizeof(struct ipv6hdr) + ETH_HLEN;
808 struct ethhdr *eth = (struct ethhdr *)buf;
809 struct ipv6hdr *ip6h = (struct ipv6hdr *)((char *)eth + sizeof(struct ethhdr));
810 struct udphdr *udp = (struct udphdr *)((char *)ip6h + sizeof(struct ipv6hdr));
811 struct vxlanhdr *vxh = (struct vxlanhdr *)((char *)udp + sizeof(struct udphdr));
812
813 memset(buf, 0, encap_size);
814
815 ether_addr_copy(eth->h_dest, h_dest);
816 ether_addr_copy(eth->h_source, out_dev->dev_addr);
817 eth->h_proto = htons(ETH_P_IPV6);
818
819 ip6_flow_hdr(ip6h, 0, 0);
820 /* the HW fills up ipv6 payload len */
821 ip6h->nexthdr = IPPROTO_UDP;
822 ip6h->hop_limit = ttl;
823 ip6h->daddr = *daddr;
824 ip6h->saddr = *saddr;
825
826 udp->dest = udp_dst_port;
827 vxh->vx_flags = VXLAN_HF_VNI;
828 vxh->vx_vni = vxlan_vni_field(vx_vni);
829
830 return encap_size;
831}
832
737static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,833static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
738 struct net_device *mirred_dev,834 struct net_device *mirred_dev,
739 struct mlx5_encap_entry *e,835 struct mlx5_encap_entry *e,
740 struct net_device **out_dev)836 struct net_device **out_dev)
741{837{
742 int max_encap_size = MLX5_CAP_ESW(priv->mdev, max_encap_header_size);838 int max_encap_size = MLX5_CAP_ESW(priv->mdev, max_encap_header_size);
839 struct ip_tunnel_key *tun_key = &e->tun_info.key;
840 int encap_size, ttl, err;
743 struct neighbour *n = NULL;841 struct neighbour *n = NULL;
744 struct flowi4 fl4 = {};842 struct flowi4 fl4 = {};
745 char *encap_header;843 char *encap_header;
746 int encap_size;
747 __be32 saddr;
748 int ttl;
749 int err;
750 844
751 encap_header = kzalloc(max_encap_size, GFP_KERNEL);845 encap_header = kzalloc(max_encap_size, GFP_KERNEL);
752 if (!encap_header)846 if (!encap_header)
@@ -755,37 +849,108 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv, · 2 unmodified lines
755 switch (e->tunnel_type) {849 switch (e->tunnel_type) {
756 case MLX5_HEADER_TYPE_VXLAN:850 case MLX5_HEADER_TYPE_VXLAN:
757 fl4.flowi4_proto = IPPROTO_UDP;851 fl4.flowi4_proto = IPPROTO_UDP;
758 fl4.fl4_dport = e->tun_info.tp_dst;852 fl4.fl4_dport = tun_key->tp_dst;
759 break;853 break;
760 default:854 default:
761 err = -EOPNOTSUPP;855 err = -EOPNOTSUPP;
762 goto out;856 goto out;
763 }857 }
764 fl4.daddr = e->tun_info.daddr;858 fl4.flowi4_tos = tun_key->tos;
859 fl4.daddr = tun_key->u.ipv4.dst;
860 fl4.saddr = tun_key->u.ipv4.src;
765 861
766 err = mlx5e_route_lookup_ipv4(priv, mirred_dev, out_dev,862 err = mlx5e_route_lookup_ipv4(priv, mirred_dev, out_dev,
767 &fl4, &n, &saddr, &ttl);863 &fl4, &n, &ttl);
768 if (err)864 if (err)
769 goto out;865 goto out;
770 866
867 if (!(n->nud_state & NUD_VALID)) {
868 pr_warn("%s: can't offload, neighbour to %pI4 invalid\n", __func__, &fl4.daddr);
869 err = -EOPNOTSUPP;
870 goto out;
871 }
872
771 e->n = n;873 e->n = n;
772 e->out_dev = *out_dev;874 e->out_dev = *out_dev;
773 875
876 neigh_ha_snapshot(e->h_dest, n, *out_dev);
877
878 switch (e->tunnel_type) {
879 case MLX5_HEADER_TYPE_VXLAN:
880 encap_size = gen_vxlan_header_ipv4(*out_dev, encap_header,
881 e->h_dest, ttl,
882 fl4.daddr,
883 fl4.saddr, tun_key->tp_dst,
884 tunnel_id_to_key32(tun_key->tun_id));
885 break;
886 default:
887 err = -EOPNOTSUPP;
888 goto out;
889 }
890
891 err = mlx5_encap_alloc(priv->mdev, e->tunnel_type,
892 encap_size, encap_header, &e->encap_id);
893out:
894 if (err && n)
895 neigh_release(n);
896 kfree(encap_header);
897 return err;
898}
899
900static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv,
901 struct net_device *mirred_dev,
902 struct mlx5_encap_entry *e,
903 struct net_device **out_dev)
904
905{
906 int max_encap_size = MLX5_CAP_ESW(priv->mdev, max_encap_header_size);
907 struct ip_tunnel_key *tun_key = &e->tun_info.key;
908 int encap_size, err, ttl = 0;
909 struct neighbour *n = NULL;
910 struct flowi6 fl6 = {};
911 char *encap_header;
912
913 encap_header = kzalloc(max_encap_size, GFP_KERNEL);
914 if (!encap_header)
915 return -ENOMEM;
916
917 switch (e->tunnel_type) {
918 case MLX5_HEADER_TYPE_VXLAN:
919 fl6.flowi6_proto = IPPROTO_UDP;
920 fl6.fl6_dport = tun_key->tp_dst;
921 break;
922 default:
923 err = -EOPNOTSUPP;
924 goto out;
925 }
926
927 fl6.flowlabel = ip6_make_flowinfo(RT_TOS(tun_key->tos), tun_key->label);
928 fl6.daddr = tun_key->u.ipv6.dst;
929 fl6.saddr = tun_key->u.ipv6.src;
930
931 err = mlx5e_route_lookup_ipv6(priv, mirred_dev, out_dev,
932 &fl6, &n, &ttl);
933 if (err)
934 goto out;
935
774 if (!(n->nud_state & NUD_VALID)) {936 if (!(n->nud_state & NUD_VALID)) {
775 pr_warn("%s: can't offload, neighbour to %pI4 invalid\n", __func__, &fl4.daddr);937 pr_warn("%s: can't offload, neighbour to %pI6 invalid\n", __func__, &fl6.daddr);
776 err = -EOPNOTSUPP;938 err = -EOPNOTSUPP;
777 goto out;939 goto out;
778 }940 }
779 941
942 e->n = n;
943 e->out_dev = *out_dev;
944
780 neigh_ha_snapshot(e->h_dest, n, *out_dev);945 neigh_ha_snapshot(e->h_dest, n, *out_dev);
781 946
782 switch (e->tunnel_type) {947 switch (e->tunnel_type) {
783 case MLX5_HEADER_TYPE_VXLAN:948 case MLX5_HEADER_TYPE_VXLAN:
784 encap_size = gen_vxlan_header_ipv4(*out_dev, encap_header,949 encap_size = gen_vxlan_header_ipv6(*out_dev, encap_header,
785 e->h_dest, ttl,950 e->h_dest, ttl,
786 e->tun_info.daddr,951 &fl6.daddr,
787 saddr, e->tun_info.tp_dst,952 &fl6.saddr, tun_key->tp_dst,
788 e->tun_info.tun_id);953 tunnel_id_to_key32(tun_key->tun_id));
789 break;954 break;
790 default:955 default:
791 err = -EOPNOTSUPP;956 err = -EOPNOTSUPP;
@@ -809,13 +974,11 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv, · 17 unmodified lines
809 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;974 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
810 unsigned short family = ip_tunnel_info_af(tun_info);975 unsigned short family = ip_tunnel_info_af(tun_info);
811 struct ip_tunnel_key *key = &tun_info->key;976 struct ip_tunnel_key *key = &tun_info->key;
812 struct mlx5_encap_info info;
813 struct mlx5_encap_entry *e;977 struct mlx5_encap_entry *e;
814 struct net_device *out_dev;978 struct net_device *out_dev;
979 int tunnel_type, err = -EOPNOTSUPP;
815 uintptr_t hash_key;980 uintptr_t hash_key;
816 bool found = false;981 bool found = false;
817 int tunnel_type;
818 int err;
819 982
820 /* udp dst port must be set */983 /* udp dst port must be set */
821 if (!memchr_inv(&key->tp_dst, 0, sizeof(key->tp_dst)))984 if (!memchr_inv(&key->tp_dst, 0, sizeof(key->tp_dst)))
@@ -831,8 +994,6 @@ vxlan_encap_offload_err: · 9 unmodified lines
831 994
832 if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->tp_dst)) &&995 if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->tp_dst)) &&
833 MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {996 MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {
834 info.tp_dst = key->tp_dst;
835 info.tun_id = tunnel_id_to_key32(key->tun_id);
836 tunnel_type = MLX5_HEADER_TYPE_VXLAN;997 tunnel_type = MLX5_HEADER_TYPE_VXLAN;
837 } else {998 } else {
838 netdev_warn(priv->netdev,999 netdev_warn(priv->netdev,
@@ -840,22 +1001,11 @@ vxlan_encap_offload_err: · 1 unmodified line
840 return -EOPNOTSUPP;1001 return -EOPNOTSUPP;
841 }1002 }
842 1003
843 switch (family) {1004 hash_key = hash_encap_info(key);
844 case AF_INET:
845 info.daddr = key->u.ipv4.dst;
846 break;
847 case AF_INET6:
848 netdev_warn(priv->netdev,
849 "IPv6 tunnel encap offload isn't supported\n");
850 default:
851 return -EOPNOTSUPP;
852 }
853
854 hash_key = hash_encap_info(&info);
855 1005
856 hash_for_each_possible_rcu(esw->offloads.encap_tbl, e,1006 hash_for_each_possible_rcu(esw->offloads.encap_tbl, e,
857 encap_hlist, hash_key) {1007 encap_hlist, hash_key) {
858 if (!cmp_encap_info(&e->tun_info, &info)) {1008 if (!cmp_encap_info(&e->tun_info.key, key)) {
859 found = true;1009 found = true;
860 break;1010 break;
861 }1011 }
@@ -870,11 +1020,15 @@ vxlan_encap_offload_err: · 8 unmodified lines
870 if (!e)1020 if (!e)
871 return -ENOMEM;1021 return -ENOMEM;
872 1022
873 e->tun_info = info;1023 e->tun_info = *tun_info;
874 e->tunnel_type = tunnel_type;1024 e->tunnel_type = tunnel_type;
875 INIT_LIST_HEAD(&e->flows);1025 INIT_LIST_HEAD(&e->flows);
876 1026
877 err = mlx5e_create_encap_header_ipv4(priv, mirred_dev, e, &out_dev);1027 if (family == AF_INET)
1028 err = mlx5e_create_encap_header_ipv4(priv, mirred_dev, e, &out_dev);
1029 else if (family == AF_INET6)
1030 err = mlx5e_create_encap_header_ipv6(priv, mirred_dev, e, &out_dev);
1031
878 if (err)1032 if (err)
879 goto out_err;1033 goto out_err;
880 1034
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c+91−6
@@ -1415,7 +1415,7 @@ static void esw_destroy_tsar(struct mlx5_eswitch *esw) · 1414 unmodified lines
1415}1415}
1416 1416
1417static int esw_vport_enable_qos(struct mlx5_eswitch *esw, int vport_num,1417static int esw_vport_enable_qos(struct mlx5_eswitch *esw, int vport_num,
1418 u32 initial_max_rate)1418 u32 initial_max_rate, u32 initial_bw_share)
1419{1419{
1420 u32 sched_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {0};1420 u32 sched_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {0};
1421 struct mlx5_vport *vport = &esw->vports[vport_num];1421 struct mlx5_vport *vport = &esw->vports[vport_num];
@@ -1439,6 +1439,7 @@ static int esw_vport_enable_qos(struct mlx5_eswitch *esw, int vport_num, · 17 unmodified lines
1439 esw->qos.root_tsar_id);1439 esw->qos.root_tsar_id);
1440 MLX5_SET(scheduling_context, &sched_ctx, max_average_bw,1440 MLX5_SET(scheduling_context, &sched_ctx, max_average_bw,
1441 initial_max_rate);1441 initial_max_rate);
1442 MLX5_SET(scheduling_context, &sched_ctx, bw_share, initial_bw_share);
1442 1443
1443 err = mlx5_create_scheduling_element_cmd(dev,1444 err = mlx5_create_scheduling_element_cmd(dev,
1444 SCHEDULING_HIERARCHY_E_SWITCH,1445 SCHEDULING_HIERARCHY_E_SWITCH,
@@ -1473,7 +1474,7 @@ static void esw_vport_disable_qos(struct mlx5_eswitch *esw, int vport_num) · 28 unmodified lines
1473}1474}
1474 1475
1475static int esw_vport_qos_config(struct mlx5_eswitch *esw, int vport_num,1476static int esw_vport_qos_config(struct mlx5_eswitch *esw, int vport_num,
1476 u32 max_rate)1477 u32 max_rate, u32 bw_share)
1477{1478{
1478 u32 sched_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {0};1479 u32 sched_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {0};
1479 struct mlx5_vport *vport = &esw->vports[vport_num];1480 struct mlx5_vport *vport = &esw->vports[vport_num];
@@ -1497,7 +1498,9 @@ static int esw_vport_qos_config(struct mlx5_eswitch *esw, int vport_num, · 17 unmodified lines
1497 esw->qos.root_tsar_id);1498 esw->qos.root_tsar_id);
1498 MLX5_SET(scheduling_context, &sched_ctx, max_average_bw,1499 MLX5_SET(scheduling_context, &sched_ctx, max_average_bw,
1499 max_rate);1500 max_rate);
1501 MLX5_SET(scheduling_context, &sched_ctx, bw_share, bw_share);
1500 bitmask |= MODIFY_SCHEDULING_ELEMENT_IN_MODIFY_BITMASK_MAX_AVERAGE_BW;1502 bitmask |= MODIFY_SCHEDULING_ELEMENT_IN_MODIFY_BITMASK_MAX_AVERAGE_BW;
1503 bitmask |= MODIFY_SCHEDULING_ELEMENT_IN_MODIFY_BITMASK_BW_SHARE;
1501 1504
1502 err = mlx5_modify_scheduling_element_cmd(dev,1505 err = mlx5_modify_scheduling_element_cmd(dev,
1503 SCHEDULING_HIERARCHY_E_SWITCH,1506 SCHEDULING_HIERARCHY_E_SWITCH,
@@ -1563,7 +1566,8 @@ static void esw_enable_vport(struct mlx5_eswitch *esw, int vport_num, · 59 unmodified lines
1563 esw_apply_vport_conf(esw, vport);1566 esw_apply_vport_conf(esw, vport);
1564 1567
1565 /* Attach vport to the eswitch rate limiter */1568 /* Attach vport to the eswitch rate limiter */
1566 if (esw_vport_enable_qos(esw, vport_num, vport->info.max_rate))1569 if (esw_vport_enable_qos(esw, vport_num, vport->info.max_rate,
1570 vport->qos.bw_share))
1567 esw_warn(esw->dev, "Failed to attach vport %d to eswitch rate limiter", vport_num);1571 esw_warn(esw->dev, "Failed to attach vport %d to eswitch rate limiter", vport_num);
1568 1572
1569 /* Sync with current vport context */1573 /* Sync with current vport context */
@@ -1952,6 +1956,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw, · 382 unmodified lines
1952 ivi->qos = evport->info.qos;1956 ivi->qos = evport->info.qos;
1953 ivi->spoofchk = evport->info.spoofchk;1957 ivi->spoofchk = evport->info.spoofchk;
1954 ivi->trusted = evport->info.trusted;1958 ivi->trusted = evport->info.trusted;
1959 ivi->min_tx_rate = evport->info.min_rate;
1955 ivi->max_tx_rate = evport->info.max_rate;1960 ivi->max_tx_rate = evport->info.max_rate;
1956 mutex_unlock(&esw->state_lock);1961 mutex_unlock(&esw->state_lock);
1957 1962
@@ -2046,23 +2051,103 @@ int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw, · 88 unmodified lines
2046 return 0;2051 return 0;
2047}2052}
2048 2053
2049int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw,2054static u32 calculate_vports_min_rate_divider(struct mlx5_eswitch *esw)
2050 int vport, u32 max_rate)
2051{2055{
2056 u32 fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
2052 struct mlx5_vport *evport;2057 struct mlx5_vport *evport;
2058 u32 max_guarantee = 0;
2059 int i;
2060
2061 for (i = 0; i <= esw->total_vports; i++) {
2062 evport = &esw->vports[i];
2063 if (!evport->enabled || evport->info.min_rate < max_guarantee)
2064 continue;
2065 max_guarantee = evport->info.min_rate;
2066 }
2067
2068 return max_t(u32, max_guarantee / fw_max_bw_share, 1);
2069}
2070
2071static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider)
2072{
2073 u32 fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
2074 struct mlx5_vport *evport;
2075 u32 vport_max_rate;
2076 u32 vport_min_rate;
2077 u32 bw_share;
2078 int err;
2079 int i;
2080
2081 for (i = 0; i <= esw->total_vports; i++) {
2082 evport = &esw->vports[i];
2083 if (!evport->enabled)
2084 continue;
2085 vport_min_rate = evport->info.min_rate;
2086 vport_max_rate = evport->info.max_rate;
2087 bw_share = MLX5_MIN_BW_SHARE;
2088
2089 if (vport_min_rate)
2090 bw_share = MLX5_RATE_TO_BW_SHARE(vport_min_rate,
2091 divider,
2092 fw_max_bw_share);
2093
2094 if (bw_share == evport->qos.bw_share)
2095 continue;
2096
2097 err = esw_vport_qos_config(esw, i, vport_max_rate,
2098 bw_share);
2099 if (!err)
2100 evport->qos.bw_share = bw_share;
2101 else
2102 return err;
2103 }
2104
2105 return 0;
2106}
2107
2108int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport,
2109 u32 max_rate, u32 min_rate)
2110{
2111 u32 fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
2112 bool min_rate_supported = MLX5_CAP_QOS(esw->dev, esw_bw_share) &&
2113 fw_max_bw_share >= MLX5_MIN_BW_SHARE;
2114 bool max_rate_supported = MLX5_CAP_QOS(esw->dev, esw_rate_limit);
2115 struct mlx5_vport *evport;
2116 u32 previous_min_rate;
2117 u32 divider;
2053 int err = 0;2118 int err = 0;
2054 2119
2055 if (!ESW_ALLOWED(esw))2120 if (!ESW_ALLOWED(esw))
2056 return -EPERM;2121 return -EPERM;
2057 if (!LEGAL_VPORT(esw, vport))2122 if (!LEGAL_VPORT(esw, vport))
2058 return -EINVAL;2123 return -EINVAL;
2124 if ((min_rate && !min_rate_supported) || (max_rate && !max_rate_supported))
2125 return -EOPNOTSUPP;
2059 2126
2060 mutex_lock(&esw->state_lock);2127 mutex_lock(&esw->state_lock);
2061 evport = &esw->vports[vport];2128 evport = &esw->vports[vport];
2062 err = esw_vport_qos_config(esw, vport, max_rate);2129
2130 if (min_rate == evport->info.min_rate)
2131 goto set_max_rate;
2132
2133 previous_min_rate = evport->info.min_rate;
2134 evport->info.min_rate = min_rate;
2135 divider = calculate_vports_min_rate_divider(esw);
2136 err = normalize_vports_min_rate(esw, divider);
2137 if (err) {
2138 evport->info.min_rate = previous_min_rate;
2139 goto unlock;
2140 }
2141
2142set_max_rate:
2143 if (max_rate == evport->info.max_rate)
2144 goto unlock;
2145
2146 err = esw_vport_qos_config(esw, vport, max_rate, evport->qos.bw_share);
2063 if (!err)2147 if (!err)
2064 evport->info.max_rate = max_rate;2148 evport->info.max_rate = max_rate;
2065 2149
2150unlock:
2066 mutex_unlock(&esw->state_lock);2151 mutex_unlock(&esw->state_lock);
2067 return err;2152 return err;
2068}2153}
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h+11−9
@@ -36,6 +36,7 @@ · 35 unmodified lines
36#include <linux/if_ether.h>36#include <linux/if_ether.h>
37#include <linux/if_link.h>37#include <linux/if_link.h>
38#include <net/devlink.h>38#include <net/devlink.h>
39#include <net/ip_tunnels.h>
39#include <linux/mlx5/device.h>40#include <linux/mlx5/device.h>
40 41
41#define MLX5_MAX_UC_PER_VPORT(dev) \42#define MLX5_MAX_UC_PER_VPORT(dev) \
@@ -49,6 +50,11 @@ · 7 unmodified lines
49 50
50#define FDB_UPLINK_VPORT 0xffff51#define FDB_UPLINK_VPORT 0xffff
51 52
53#define MLX5_MIN_BW_SHARE 1
54
55#define MLX5_RATE_TO_BW_SHARE(rate, divider, limit) \
56 min_t(u32, max_t(u32, (rate) / (divider), MLX5_MIN_BW_SHARE), limit)
57
52/* L2 -mac address based- hash helpers */58/* L2 -mac address based- hash helpers */
53struct l2addr_node {59struct l2addr_node {
54 struct hlist_node hlist;60 struct hlist_node hlist;
@@ -115,6 +121,7 @@ struct mlx5_vport_info { · 60 unmodified lines
115 u8 qos;121 u8 qos;
116 u64 node_guid;122 u64 node_guid;
117 int link_state;123 int link_state;
124 u32 min_rate;
118 u32 max_rate;125 u32 max_rate;
119 bool spoofchk;126 bool spoofchk;
120 bool trusted;127 bool trusted;
@@ -137,6 +144,7 @@ struct mlx5_vport { · 16 unmodified lines
137 struct {144 struct {
138 bool enabled;145 bool enabled;
139 u32 esw_tsar_ix;146 u32 esw_tsar_ix;
147 u32 bw_share;
140 } qos;148 } qos;
141 149
142 bool enabled;150 bool enabled;
@@ -248,8 +256,8 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, · 105 unmodified lines
248 int vport, bool spoofchk);256 int vport, bool spoofchk);
249int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw,257int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw,
250 int vport_num, bool setting);258 int vport_num, bool setting);
251int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw,259int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport,
252 int vport, u32 max_rate);260 u32 max_rate, u32 min_rate);
253int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,261int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
254 int vport, struct ifla_vf_info *ivi);262 int vport, struct ifla_vf_info *ivi);
255int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,263int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
@@ -274,18 +282,12 @@ enum { · 18 unmodified lines
274#define MLX5_FLOW_CONTEXT_ACTION_VLAN_POP 0x40282#define MLX5_FLOW_CONTEXT_ACTION_VLAN_POP 0x40
275#define MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH 0x80283#define MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH 0x80
276 284
277struct mlx5_encap_info {
278 __be32 daddr;
279 __be32 tun_id;
280 __be16 tp_dst;
281};
282
283struct mlx5_encap_entry {285struct mlx5_encap_entry {
284 struct hlist_node encap_hlist;286 struct hlist_node encap_hlist;
285 struct list_head flows;287 struct list_head flows;
286 u32 encap_id;288 u32 encap_id;
287 struct neighbour *n;289 struct neighbour *n;
288 struct mlx5_encap_info tun_info;290 struct ip_tunnel_info tun_info;
289 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */291 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
290 292
291 struct net_device *out_dev;293 struct net_device *out_dev;
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c+8−5
@@ -402,19 +402,18 @@ out: · 401 unmodified lines
402}402}
403 403
404#define MAX_PF_SQ 256404#define MAX_PF_SQ 256
405#define ESW_OFFLOADS_NUM_ENTRIES (1 << 13) /* 8K */
406#define ESW_OFFLOADS_NUM_GROUPS 4405#define ESW_OFFLOADS_NUM_GROUPS 4
407 406
408static int esw_create_offloads_fdb_table(struct mlx5_eswitch *esw, int nvports)407static int esw_create_offloads_fdb_table(struct mlx5_eswitch *esw, int nvports)
409{408{
410 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);409 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
410 int table_size, ix, esw_size, err = 0;
411 struct mlx5_core_dev *dev = esw->dev;411 struct mlx5_core_dev *dev = esw->dev;
412 struct mlx5_flow_namespace *root_ns;412 struct mlx5_flow_namespace *root_ns;
413 struct mlx5_flow_table *fdb = NULL;413 struct mlx5_flow_table *fdb = NULL;
414 struct mlx5_flow_group *g;414 struct mlx5_flow_group *g;
415 u32 *flow_group_in;415 u32 *flow_group_in;
416 void *match_criteria;416 void *match_criteria;
417 int table_size, ix, err = 0;
418 u32 flags = 0;417 u32 flags = 0;
419 418
420 flow_group_in = mlx5_vzalloc(inlen);419 flow_group_in = mlx5_vzalloc(inlen);
@@ -427,15 +426,19 @@ static int esw_create_offloads_fdb_table(struct mlx5_eswitch *esw, int nvports) · 6 unmodified lines
427 goto ns_err;426 goto ns_err;
428 }427 }
429 428
430 esw_debug(dev, "Create offloads FDB table, log_max_size(%d)\n",429 esw_debug(dev, "Create offloads FDB table, min (max esw size(2^%d), max counters(%d)*groups(%d))\n",
431 MLX5_CAP_ESW_FLOWTABLE_FDB(dev, log_max_ft_size));430 MLX5_CAP_ESW_FLOWTABLE_FDB(dev, log_max_ft_size),
431 MLX5_CAP_GEN(dev, max_flow_counter), ESW_OFFLOADS_NUM_GROUPS);
432
433 esw_size = min_t(int, MLX5_CAP_GEN(dev, max_flow_counter) * ESW_OFFLOADS_NUM_GROUPS,
434 1 << MLX5_CAP_ESW_FLOWTABLE_FDB(dev, log_max_ft_size));
432 435
433 if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, encap) &&436 if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, encap) &&
434 MLX5_CAP_ESW_FLOWTABLE_FDB(dev, decap))437 MLX5_CAP_ESW_FLOWTABLE_FDB(dev, decap))
435 flags |= MLX5_FLOW_TABLE_TUNNEL_EN;438 flags |= MLX5_FLOW_TABLE_TUNNEL_EN;
436 439
437 fdb = mlx5_create_auto_grouped_flow_table(root_ns, FDB_FAST_PATH,440 fdb = mlx5_create_auto_grouped_flow_table(root_ns, FDB_FAST_PATH,
438 ESW_OFFLOADS_NUM_ENTRIES,441 esw_size,
439 ESW_OFFLOADS_NUM_GROUPS, 0,442 ESW_OFFLOADS_NUM_GROUPS, 0,
440 flags);443 flags);
441 if (IS_ERR(fdb)) {444 if (IS_ERR(fdb)) {
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c+5−2
@@ -473,10 +473,13 @@ int mlx5_encap_alloc(struct mlx5_core_dev *dev, · 472 unmodified lines
473 int err;473 int err;
474 u32 *in;474 u32 *in;
475 475
476 if (size > MLX5_CAP_ESW(dev, max_encap_header_size))476 if (size > max_encap_size) {
477 mlx5_core_warn(dev, "encap size %zd too big, max supported is %d\n",
478 size, max_encap_size);
477 return -EINVAL;479 return -EINVAL;
480 }
478 481
479 in = kzalloc(MLX5_ST_SZ_BYTES(alloc_encap_header_in) + max_encap_size,482 in = kzalloc(MLX5_ST_SZ_BYTES(alloc_encap_header_in) + size,
480 GFP_KERNEL);483 GFP_KERNEL);
481 if (!in)484 if (!in)
482 return -ENOMEM;485 return -ENOMEM;
drivers/net/ethernet/mellanox/mlx5/core/vport.c+17−0
@@ -127,6 +127,23 @@ int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev, · 126 unmodified lines
127}127}
128EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_min_inline);128EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_min_inline);
129 129
130void mlx5_query_min_inline(struct mlx5_core_dev *mdev,
131 u8 *min_inline_mode)
132{
133 switch (MLX5_CAP_ETH(mdev, wqe_inline_mode)) {
134 case MLX5_CAP_INLINE_MODE_L2:
135 *min_inline_mode = MLX5_INLINE_MODE_L2;
136 break;
137 case MLX5_CAP_INLINE_MODE_VPORT_CONTEXT:
138 mlx5_query_nic_vport_min_inline(mdev, 0, min_inline_mode);
139 break;
140 case MLX5_CAP_INLINE_MODE_NOT_REQUIRED:
141 *min_inline_mode = MLX5_INLINE_MODE_NONE;
142 break;
143 }
144}
145EXPORT_SYMBOL_GPL(mlx5_query_min_inline);
146
130int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,147int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,
131 u16 vport, u8 min_inline)148 u16 vport, u8 min_inline)
132{149{
include/linux/mlx5/mlx5_ifc.h+3−1
@@ -547,7 +547,9 @@ struct mlx5_ifc_e_switch_cap_bits { · 546 unmodified lines
547struct mlx5_ifc_qos_cap_bits {547struct mlx5_ifc_qos_cap_bits {
548 u8 packet_pacing[0x1];548 u8 packet_pacing[0x1];
549 u8 esw_scheduling[0x1];549 u8 esw_scheduling[0x1];
550 u8 reserved_at_2[0x1e];550 u8 esw_bw_share[0x1];
551 u8 esw_rate_limit[0x1];
552 u8 reserved_at_4[0x1c];
551 553
552 u8 reserved_at_20[0x20];554 u8 reserved_at_20[0x20];
553 555
include/linux/mlx5/vport.h+1−0
@@ -51,6 +51,7 @@ int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev, · 50 unmodified lines
51 u16 vport, u8 *addr);51 u16 vport, u8 *addr);
52int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,52int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,
53 u16 vport, u8 *min_inline);53 u16 vport, u8 *min_inline);
54void mlx5_query_min_inline(struct mlx5_core_dev *mdev, u8 *min_inline);
54int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,55int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,
55 u16 vport, u8 min_inline);56 u16 vport, u8 min_inline);
56int mlx5_modify_nic_vport_mac_address(struct mlx5_core_dev *dev,57int mlx5_modify_nic_vport_mac_address(struct mlx5_core_dev *dev,
include/uapi/rdma/mlx5-abi.h+13−1
@@ -90,6 +90,17 @@ enum mlx5_user_cmds_supp_uhw { · 89 unmodified lines
90 MLX5_USER_CMDS_SUPP_UHW_CREATE_AH = 1 << 1,90 MLX5_USER_CMDS_SUPP_UHW_CREATE_AH = 1 << 1,
91};91};
92 92
93/* The eth_min_inline response value is set to off-by-one vs the FW
94 * returned value to allow user-space to deal with older kernels.
95 */
96enum mlx5_user_inline_mode {
97 MLX5_USER_INLINE_MODE_NA,
98 MLX5_USER_INLINE_MODE_NONE,
99 MLX5_USER_INLINE_MODE_L2,
100 MLX5_USER_INLINE_MODE_IP,
101 MLX5_USER_INLINE_MODE_TCP_UDP,
102};
103
93struct mlx5_ib_alloc_ucontext_resp {104struct mlx5_ib_alloc_ucontext_resp {
94 __u32 qp_tab_size;105 __u32 qp_tab_size;
95 __u32 bf_reg_size;106 __u32 bf_reg_size;
@@ -106,7 +117,8 @@ struct mlx5_ib_alloc_ucontext_resp { · 10 unmodified lines
106 __u32 response_length;117 __u32 response_length;
107 __u8 cqe_version;118 __u8 cqe_version;
108 __u8 cmds_supp_uhw;119 __u8 cmds_supp_uhw;
109 __u16 reserved2;120 __u8 eth_min_inline;
121 __u8 reserved2;
110 __u64 hca_core_clock_offset;122 __u64 hca_core_clock_offset;
111 __u32 log_uar_size;123 __u32 log_uar_size;
112 __u32 num_uars_per_page;124 __u32 num_uars_per_page;

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