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
5353 #include <linux/in.h>
5454 #include <linux/etherdevice.h>
5555 #include <linux/mlx5/fs.h>
56+#include <linux/mlx5/vport.h>
5657 #include "mlx5_ib.h"
5758
5859 #define DRIVER_NAME "mlx5_ib"
@@ -1202,6 +1203,14 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, · 1143 unmodified lines
12021203 resp.response_length += sizeof(resp.cmds_supp_uhw);
12031204 }
12041205
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+
12051214 /*
12061215 * We don't want to expose information from the PCI bar that is located
12071216 * 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
101101
102102 #define MLX5E_LOG_INDIR_RQT_SIZE 0x7
103103 #define MLX5E_INDIR_RQT_SIZE BIT(MLX5E_LOG_INDIR_RQT_SIZE)
104+#define MLX5E_MIN_NUM_CHANNELS 0x1
104105 #define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE >> 1)
105106 #define MLX5E_MAX_NUM_SQS (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC)
106107 #define MLX5E_TX_CQ_POLL_BUDGET 128
@@ -786,7 +787,7 @@ void mlx5e_pps_event_handler(struct mlx5e_priv *priv, · 679 unmodified lines
786787 struct ptp_clock_event *event);
787788 int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr);
788789 int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr);
789−void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val);
790+void mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val);
790791
791792 int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
792793 u16 vid);
@@ -847,12 +848,6 @@ static inline u32 mlx5e_get_wqe_mtt_offset(struct mlx5e_rq *rq, u16 wqe_ix) · 54 unmodified lines
847848 return wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8);
848849 }
849850
850−static 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−
856851 extern const struct ethtool_ops mlx5e_ethtool_ops;
857852 #ifdef CONFIG_MLX5_CORE_EN_DCB
858853 extern 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
106106 return -ERANGE;
107107 }
108108
109+ mutex_lock(&priv->state_lock);
109110 /* RX HW timestamp */
110111 switch (config.rx_filter) {
111112 case HWTSTAMP_FILTER_NONE:
112113 /* 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);
114115 break;
115116 case HWTSTAMP_FILTER_ALL:
116117 case HWTSTAMP_FILTER_SOME:
@@ -128,14 +129,16 @@ int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr) · 11 unmodified lines
128129 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
129130 /* Disable CQE compression */
130131 netdev_warn(dev, "Disabling cqe compression");
131− mlx5e_modify_rx_cqe_compression(priv, false);
132+ mlx5e_modify_rx_cqe_compression_locked(priv, false);
132133 config.rx_filter = HWTSTAMP_FILTER_ALL;
133134 break;
134135 default:
136+ mutex_unlock(&priv->state_lock);
135137 return -ERANGE;
136138 }
137139
138140 memcpy(&priv->tstamp.hwtstamp_config, &config, sizeof(config));
141+ mutex_unlock(&priv->state_lock);
139142
140143 return copy_to_user(ifr->ifr_data, &config,
141144 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
552552 {
553553 struct mlx5e_priv *priv = netdev_priv(dev);
554554
555− ch->max_combined = mlx5e_get_max_num_channels(priv->mdev);
555+ ch->max_combined = priv->profile->max_nch(priv->mdev);
556556 ch->combined_count = priv->params.num_channels;
557557 }
558558
@@ -560,7 +560,7 @@ static int mlx5e_set_channels(struct net_device *dev, · 1 unmodified line
560560 struct ethtool_channels *ch)
561561 {
562562 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);
564564 unsigned int count = ch->combined_count;
565565 bool arfs_enabled;
566566 bool was_opened;
@@ -1476,8 +1476,6 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev, · 909 unmodified lines
14761476 {
14771477 struct mlx5e_priv *priv = netdev_priv(netdev);
14781478 struct mlx5_core_dev *mdev = priv->mdev;
1479− int err = 0;
1480− bool reset;
14811479
14821480 if (!MLX5_CAP_GEN(mdev, cqe_compression))
14831481 return -ENOTSUPP;
@@ -1487,17 +1485,10 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev, · 3 unmodified lines
14871485 return -EINVAL;
14881486 }
14891487
1490− reset = test_bit(MLX5E_STATE_OPENED, &priv->state);
1491−
1492− if (reset)
1493− mlx5e_close_locked(netdev);
1494−
1495− MLX5E_SET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS, enable);
1488+ mlx5e_modify_rx_cqe_compression_locked(priv, enable);
14961489 priv->params.rx_cqe_compress_def = enable;
14971490
1498− if (reset)
1499− err = mlx5e_open_locked(netdev);
1500− return err;
1491+ return 0;
15011492 }
15021493
15031494 static 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
3131 */
3232
3333 #include <net/tc_act/tc_gact.h>
34+#include <linux/crash_dump.h>
3435 #include <net/pkt_cls.h>
3536 #include <linux/mlx5/fs.h>
3637 #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
8384 priv->params.rq_wq_type = rq_type;
8485 switch (priv->params.rq_wq_type) {
8586 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;
8790 priv->params.mpwqe_log_stride_sz =
8891 MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) ?
8992 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
9295 priv->params.mpwqe_log_stride_sz;
9396 break;
9497 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;
96101 }
97102 priv->params.min_rx_wqes = mlx5_min_rx_wqes(priv->params.rq_wq_type,
98103 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
15081513 return err;
15091514 }
15101515
1516+static 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+
15111524 static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
15121525 struct mlx5e_channel_param *cparam,
15131526 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
30213034 struct mlx5e_priv *priv = netdev_priv(dev);
30223035 struct mlx5_core_dev *mdev = priv->mdev;
30233036
3024− if (min_tx_rate)
3025− return -EOPNOTSUPP;
3026−
30273037 return mlx5_eswitch_set_vport_rate(mdev->priv.eswitch, vf + 1,
3028− max_tx_rate);
3038+ max_tx_rate, min_tx_rate);
30293039 }
30303040
30313041 static 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
34613471 MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE;
34623472 }
34633473
3464−static 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−
34803474 u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout)
34813475 {
34823476 int i;
@@ -3510,7 +3504,9 @@ static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev, · 27 unmodified lines
35103504 priv->params.lro_timeout =
35113505 mlx5e_choose_lro_timeout(mdev, MLX5E_DEFAULT_LRO_TIMEOUT);
35123506
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;
35143510
35153511 /* set CQE compression */
35163512 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
35363532 priv->params.tx_cq_moderation.pkts =
35373533 MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS;
35383534 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);
35403536 priv->params.num_tc = 1;
35413537 priv->params.rss_hfunc = ETH_RSS_HASH_XOR;
35423538
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
155155 return mlx5e_decompress_cqes_cont(rq, cq, 1, budget_rem) - 1;
156156 }
157157
158−void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val)
158+void mlx5e_modify_rx_cqe_compression_locked(struct mlx5e_priv *priv, bool val)
159159 {
160160 bool was_opened;
161161
162162 if (!MLX5_CAP_GEN(priv->mdev, cqe_compression))
163163 return;
164164
165− mutex_lock(&priv->state_lock);
166−
167165 if (MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) == val)
168− goto unlock;
166+ return;
169167
170168 was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
171169 if (was_opened)
@@ -176,8 +174,6 @@ void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val) · 4 unmodified lines
176174 if (was_opened)
177175 mlx5e_open_locked(priv->netdev);
178176
179−unlock:
180− mutex_unlock(&priv->state_lock);
181177 }
182178
183179 #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
298298
299299 MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, ethertype);
300300 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);
301327 }
302328
303329 /* Enforce DMAC when offloading incoming tunneled flows.
@@ -358,12 +384,10 @@ static int __parse_cls_flower(struct mlx5e_priv *priv, · 54 unmodified lines
358384 f->key);
359385 switch (key->addr_type) {
360386 case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
387+ case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
361388 if (parse_tunnel_attr(priv, spec, f))
362389 return -EOPNOTSUPP;
363390 break;
364− case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
365− netdev_warn(priv->netdev,
366− "IPv6 tunnel decap offload isn't supported\n");
367391 default:
368392 return -EOPNOTSUPP;
369393 }
@@ -644,15 +668,15 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct tcf_exts *exts, · 274 unmodified lines
644668 return 0;
645669 }
646670
647−static inline int cmp_encap_info(struct mlx5_encap_info *a,
648− struct mlx5_encap_info *b)
671+static inline int cmp_encap_info(struct ip_tunnel_key *a,
672+ struct ip_tunnel_key *b)
649673 {
650674 return memcmp(a, b, sizeof(*a));
651675 }
652676
653−static inline int hash_encap_info(struct mlx5_encap_info *info)
677+static inline int hash_encap_info(struct ip_tunnel_key *key)
654678 {
655− return jhash(info, sizeof(*info), 0);
679+ return jhash(key, sizeof(*key), 0);
656680 }
657681
658682 static 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
660684 struct net_device **out_dev,
661685 struct flowi4 *fl4,
662686 struct neighbour **out_n,
663− __be32 *saddr,
664687 int *out_ttl)
665688 {
666689 struct rtable *rt;
667690 struct neighbour *n = NULL;
668− int ttl;
669691
670692 #if IS_ENABLED(CONFIG_INET)
671693 int ret;
@@ -684,20 +706,59 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv, · 12 unmodified lines
684706 return -EOPNOTSUPP;
685707 }
686708
687− ttl = ip4_dst_hoplimit(&rt->dst);
709+ *out_ttl = ip4_dst_hoplimit(&rt->dst);
688710 n = dst_neigh_lookup(&rt->dst, &fl4->daddr);
689711 ip_rt_put(rt);
690712 if (!n)
691713 return -ENOMEM;
692714
693715 *out_n = n;
694− *saddr = fl4->saddr;
695− *out_ttl = ttl;
696716 *out_dev = rt->dst.dev;
697717
698718 return 0;
699719 }
700720
721+static 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+
701762 static int gen_vxlan_header_ipv4(struct net_device *out_dev,
702763 char buf[],
703764 unsigned char h_dest[ETH_ALEN],
@@ -734,19 +795,52 @@ static int gen_vxlan_header_ipv4(struct net_device *out_dev, · 30 unmodified lines
734795 return encap_size;
735796 }
736797
798+static 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+
737833 static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
738834 struct net_device *mirred_dev,
739835 struct mlx5_encap_entry *e,
740836 struct net_device **out_dev)
741837 {
742838 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;
743841 struct neighbour *n = NULL;
744842 struct flowi4 fl4 = {};
745843 char *encap_header;
746− int encap_size;
747− __be32 saddr;
748− int ttl;
749− int err;
750844
751845 encap_header = kzalloc(max_encap_size, GFP_KERNEL);
752846 if (!encap_header)
@@ -755,37 +849,108 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv, · 2 unmodified lines
755849 switch (e->tunnel_type) {
756850 case MLX5_HEADER_TYPE_VXLAN:
757851 fl4.flowi4_proto = IPPROTO_UDP;
758− fl4.fl4_dport = e->tun_info.tp_dst;
852+ fl4.fl4_dport = tun_key->tp_dst;
759853 break;
760854 default:
761855 err = -EOPNOTSUPP;
762856 goto out;
763857 }
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;
765861
766862 err = mlx5e_route_lookup_ipv4(priv, mirred_dev, out_dev,
767− &fl4, &n, &saddr, &ttl);
863+ &fl4, &n, &ttl);
768864 if (err)
769865 goto out;
770866
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+
771873 e->n = n;
772874 e->out_dev = *out_dev;
773875
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);
893+out:
894+ if (err && n)
895+ neigh_release(n);
896+ kfree(encap_header);
897+ return err;
898+}
899+
900+static 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+
774936 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);
776938 err = -EOPNOTSUPP;
777939 goto out;
778940 }
779941
942+ e->n = n;
943+ e->out_dev = *out_dev;
944+
780945 neigh_ha_snapshot(e->h_dest, n, *out_dev);
781946
782947 switch (e->tunnel_type) {
783948 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,
785950 e->h_dest, ttl,
786− e->tun_info.daddr,
787− saddr, e->tun_info.tp_dst,
788− e->tun_info.tun_id);
951+ &fl6.daddr,
952+ &fl6.saddr, tun_key->tp_dst,
953+ tunnel_id_to_key32(tun_key->tun_id));
789954 break;
790955 default:
791956 err = -EOPNOTSUPP;
@@ -809,13 +974,11 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv, · 17 unmodified lines
809974 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
810975 unsigned short family = ip_tunnel_info_af(tun_info);
811976 struct ip_tunnel_key *key = &tun_info->key;
812− struct mlx5_encap_info info;
813977 struct mlx5_encap_entry *e;
814978 struct net_device *out_dev;
979+ int tunnel_type, err = -EOPNOTSUPP;
815980 uintptr_t hash_key;
816981 bool found = false;
817− int tunnel_type;
818− int err;
819982
820983 /* udp dst port must be set */
821984 if (!memchr_inv(&key->tp_dst, 0, sizeof(key->tp_dst)))
@@ -831,8 +994,6 @@ vxlan_encap_offload_err: · 9 unmodified lines
831994
832995 if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->tp_dst)) &&
833996 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);
836997 tunnel_type = MLX5_HEADER_TYPE_VXLAN;
837998 } else {
838999 netdev_warn(priv->netdev,
@@ -840,22 +1001,11 @@ vxlan_encap_offload_err: · 1 unmodified line
8401001 return -EOPNOTSUPP;
8411002 }
8421003
843− switch (family) {
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);
1004+ hash_key = hash_encap_info(key);
8551005
8561006 hash_for_each_possible_rcu(esw->offloads.encap_tbl, e,
8571007 encap_hlist, hash_key) {
858− if (!cmp_encap_info(&e->tun_info, &info)) {
1008+ if (!cmp_encap_info(&e->tun_info.key, key)) {
8591009 found = true;
8601010 break;
8611011 }
@@ -870,11 +1020,15 @@ vxlan_encap_offload_err: · 8 unmodified lines
8701020 if (!e)
8711021 return -ENOMEM;
8721022
873− e->tun_info = info;
1023+ e->tun_info = *tun_info;
8741024 e->tunnel_type = tunnel_type;
8751025 INIT_LIST_HEAD(&e->flows);
8761026
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+
8781032 if (err)
8791033 goto out_err;
8801034
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
14151415 }
14161416
14171417 static 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)
14191419 {
14201420 u32 sched_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {0};
14211421 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
14391439 esw->qos.root_tsar_id);
14401440 MLX5_SET(scheduling_context, &sched_ctx, max_average_bw,
14411441 initial_max_rate);
1442+ MLX5_SET(scheduling_context, &sched_ctx, bw_share, initial_bw_share);
14421443
14431444 err = mlx5_create_scheduling_element_cmd(dev,
14441445 SCHEDULING_HIERARCHY_E_SWITCH,
@@ -1473,7 +1474,7 @@ static void esw_vport_disable_qos(struct mlx5_eswitch *esw, int vport_num) · 28 unmodified lines
14731474 }
14741475
14751476 static int esw_vport_qos_config(struct mlx5_eswitch *esw, int vport_num,
1476− u32 max_rate)
1477+ u32 max_rate, u32 bw_share)
14771478 {
14781479 u32 sched_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {0};
14791480 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
14971498 esw->qos.root_tsar_id);
14981499 MLX5_SET(scheduling_context, &sched_ctx, max_average_bw,
14991500 max_rate);
1501+ MLX5_SET(scheduling_context, &sched_ctx, bw_share, bw_share);
15001502 bitmask |= MODIFY_SCHEDULING_ELEMENT_IN_MODIFY_BITMASK_MAX_AVERAGE_BW;
1503+ bitmask |= MODIFY_SCHEDULING_ELEMENT_IN_MODIFY_BITMASK_BW_SHARE;
15011504
15021505 err = mlx5_modify_scheduling_element_cmd(dev,
15031506 SCHEDULING_HIERARCHY_E_SWITCH,
@@ -1563,7 +1566,8 @@ static void esw_enable_vport(struct mlx5_eswitch *esw, int vport_num, · 59 unmodified lines
15631566 esw_apply_vport_conf(esw, vport);
15641567
15651568 /* 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))
15671571 esw_warn(esw->dev, "Failed to attach vport %d to eswitch rate limiter", vport_num);
15681572
15691573 /* Sync with current vport context */
@@ -1952,6 +1956,7 @@ int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw, · 382 unmodified lines
19521956 ivi->qos = evport->info.qos;
19531957 ivi->spoofchk = evport->info.spoofchk;
19541958 ivi->trusted = evport->info.trusted;
1959+ ivi->min_tx_rate = evport->info.min_rate;
19551960 ivi->max_tx_rate = evport->info.max_rate;
19561961 mutex_unlock(&esw->state_lock);
19571962
@@ -2046,23 +2051,103 @@ int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw, · 88 unmodified lines
20462051 return 0;
20472052 }
20482053
2049−int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw,
2050− int vport, u32 max_rate)
2054+static u32 calculate_vports_min_rate_divider(struct mlx5_eswitch *esw)
20512055 {
2056+ u32 fw_max_bw_share = MLX5_CAP_QOS(esw->dev, max_tsar_bw_share);
20522057 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+
2071+static 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+
2108+int 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;
20532118 int err = 0;
20542119
20552120 if (!ESW_ALLOWED(esw))
20562121 return -EPERM;
20572122 if (!LEGAL_VPORT(esw, vport))
20582123 return -EINVAL;
2124+ if ((min_rate && !min_rate_supported) || (max_rate && !max_rate_supported))
2125+ return -EOPNOTSUPP;
20592126
20602127 mutex_lock(&esw->state_lock);
20612128 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+
2142+set_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);
20632147 if (!err)
20642148 evport->info.max_rate = max_rate;
20652149
2150+unlock:
20662151 mutex_unlock(&esw->state_lock);
20672152 return err;
20682153 }
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h+11−9
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636 #include <linux/if_ether.h>
3737 #include <linux/if_link.h>
3838 #include <net/devlink.h>
39+#include <net/ip_tunnels.h>
3940 #include <linux/mlx5/device.h>
4041
4142 #define MLX5_MAX_UC_PER_VPORT(dev) \
@@ -49,6 +50,11 @@ · 7 unmodified lines
4950
5051 #define FDB_UPLINK_VPORT 0xffff
5152
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+
5258 /* L2 -mac address based- hash helpers */
5359 struct l2addr_node {
5460 struct hlist_node hlist;
@@ -115,6 +121,7 @@ struct mlx5_vport_info { · 60 unmodified lines
115121 u8 qos;
116122 u64 node_guid;
117123 int link_state;
124+ u32 min_rate;
118125 u32 max_rate;
119126 bool spoofchk;
120127 bool trusted;
@@ -137,6 +144,7 @@ struct mlx5_vport { · 16 unmodified lines
137144 struct {
138145 bool enabled;
139146 u32 esw_tsar_ix;
147+ u32 bw_share;
140148 } qos;
141149
142150 bool enabled;
@@ -248,8 +256,8 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw, · 105 unmodified lines
248256 int vport, bool spoofchk);
249257 int mlx5_eswitch_set_vport_trust(struct mlx5_eswitch *esw,
250258 int vport_num, bool setting);
251−int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw,
252− int vport, u32 max_rate);
259+int mlx5_eswitch_set_vport_rate(struct mlx5_eswitch *esw, int vport,
260+ u32 max_rate, u32 min_rate);
253261 int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
254262 int vport, struct ifla_vf_info *ivi);
255263 int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
@@ -274,18 +282,12 @@ enum { · 18 unmodified lines
274282 #define MLX5_FLOW_CONTEXT_ACTION_VLAN_POP 0x40
275283 #define MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH 0x80
276284
277−struct mlx5_encap_info {
278− __be32 daddr;
279− __be32 tun_id;
280− __be16 tp_dst;
281−};
282−
283285 struct mlx5_encap_entry {
284286 struct hlist_node encap_hlist;
285287 struct list_head flows;
286288 u32 encap_id;
287289 struct neighbour *n;
288− struct mlx5_encap_info tun_info;
290+ struct ip_tunnel_info tun_info;
289291 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
290292
291293 struct net_device *out_dev;
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c+8−5
@@ -402,19 +402,18 @@ out: · 401 unmodified lines
402402 }
403403
404404 #define MAX_PF_SQ 256
405−#define ESW_OFFLOADS_NUM_ENTRIES (1 << 13) /* 8K */
406405 #define ESW_OFFLOADS_NUM_GROUPS 4
407406
408407 static int esw_create_offloads_fdb_table(struct mlx5_eswitch *esw, int nvports)
409408 {
410409 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
410+ int table_size, ix, esw_size, err = 0;
411411 struct mlx5_core_dev *dev = esw->dev;
412412 struct mlx5_flow_namespace *root_ns;
413413 struct mlx5_flow_table *fdb = NULL;
414414 struct mlx5_flow_group *g;
415415 u32 *flow_group_in;
416416 void *match_criteria;
417− int table_size, ix, err = 0;
418417 u32 flags = 0;
419418
420419 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
427426 goto ns_err;
428427 }
429428
430− esw_debug(dev, "Create offloads FDB table, log_max_size(%d)\n",
431− MLX5_CAP_ESW_FLOWTABLE_FDB(dev, log_max_ft_size));
429+ esw_debug(dev, "Create offloads FDB table, min (max esw size(2^%d), max counters(%d)*groups(%d))\n",
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));
432435
433436 if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, encap) &&
434437 MLX5_CAP_ESW_FLOWTABLE_FDB(dev, decap))
435438 flags |= MLX5_FLOW_TABLE_TUNNEL_EN;
436439
437440 fdb = mlx5_create_auto_grouped_flow_table(root_ns, FDB_FAST_PATH,
438− ESW_OFFLOADS_NUM_ENTRIES,
441+ esw_size,
439442 ESW_OFFLOADS_NUM_GROUPS, 0,
440443 flags);
441444 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
473473 int err;
474474 u32 *in;
475475
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);
477479 return -EINVAL;
480+ }
478481
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,
480483 GFP_KERNEL);
481484 if (!in)
482485 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
127127 }
128128 EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_min_inline);
129129
130+void 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+}
145+EXPORT_SYMBOL_GPL(mlx5_query_min_inline);
146+
130147 int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,
131148 u16 vport, u8 min_inline)
132149 {
include/linux/mlx5/mlx5_ifc.h+3−1
@@ -547,7 +547,9 @@ struct mlx5_ifc_e_switch_cap_bits { · 546 unmodified lines
547547 struct mlx5_ifc_qos_cap_bits {
548548 u8 packet_pacing[0x1];
549549 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];
551553
552554 u8 reserved_at_20[0x20];
553555
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
5151 u16 vport, u8 *addr);
5252 int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,
5353 u16 vport, u8 *min_inline);
54+void mlx5_query_min_inline(struct mlx5_core_dev *mdev, u8 *min_inline);
5455 int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,
5556 u16 vport, u8 min_inline);
5657 int 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
9090 MLX5_USER_CMDS_SUPP_UHW_CREATE_AH = 1 << 1,
9191 };
9292
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+ */
96+enum 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+
93104 struct mlx5_ib_alloc_ucontext_resp {
94105 __u32 qp_tab_size;
95106 __u32 bf_reg_size;
@@ -106,7 +117,8 @@ struct mlx5_ib_alloc_ucontext_resp { · 10 unmodified lines
106117 __u32 response_length;
107118 __u8 cqe_version;
108119 __u8 cmds_supp_uhw;
109− __u16 reserved2;
120+ __u8 eth_min_inline;
121+ __u8 reserved2;
110122 __u64 hca_core_clock_offset;
111123 __u32 log_uar_size;
112124 __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