mlx5 updates 2020-05-22
Hi Dave/Jakub
This series adds misc updates to mlx5 driver.
For more information please see tag log below.
Please pull and let me know if there is any problem.
Thanks,
Saeed.
---
The following changes since commit 593532668f635d19d207510e0fbb5c2250f56b6f:
Revert "net: mvneta: speed down the PHY, if WoL used, to save energy" (2020-05-22 16:09:42 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2020-05-22
for you to fetch changes up to 582234b465edfa12835b20477c0aa2bc91a02e18:
net/mlx5e: Support pedit on mpls over UDP decap (2020-05-22 16:46:23 -0700)
----------------------------------------------------------------
mlx5-updates-2020-05-22
This series includes two updates and one cleanup patch
1) Tang Bim, clean-up with IS_ERR() usage
2) Vlad introduces a new mlx5 kconfig flag for TC support
This is required due to the high volume of current and upcoming development in the eswitch and representors areas where some of the feature are TC based such as the downstream patches of MPLSoUDP and the following representor bonding support for VF live migration and uplink representor dynamic loading.
For this Vlad kept TC specific code in tc.c and rep/tc.c and organized non TC code in representors specific files.
3) Eli Cohen adds support for MPLS over UPD encap and decap TC offloads.
----------------------------------------------------------------
Eli Cohen (5):
net: Add netif_is_bareudp() API to identify bareudp devices net/mlx5e: Add support for hw encapsulation of MPLS over UDP net/mlx5e: Allow to match on mpls parameters net/mlx5e: Add support for hw decapsulation of MPLS over UDP net/mlx5e: Support pedit on mpls over UDP decap
Tang Bin (1):
net/mlx5e: Use IS_ERR() to check and simplify code
Vlad Buslov (4):
net/mlx5e: Extract TC-specific code from en_rep.c to rep/tc.c net/mlx5e: Extract neigh-specific code from en_rep.c to rep/neigh.c net/mlx5e: Move TC-specific code from en_main.c to en_tc.c net/mlx5e: Introduce kconfig var for TC support
drivers/net/ethernet/mellanox/mlx5/core/Kconfig | 17 +- drivers/net/ethernet/mellanox/mlx5/core/Makefile | 10 +- .../net/ethernet/mellanox/mlx5/core/en/rep/neigh.c | 368 +++++++++ .../net/ethernet/mellanox/mlx5/core/en/rep/neigh.h | 34 + .../net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 711 +++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en/rep/tc.h | 81 ++ .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 10 +- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.h | 2 + .../mellanox/mlx5/core/en/tc_tun_mplsoudp.c | 137 ++++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 41 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 887 +-------------------- drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 21 +- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 9 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 509 +++++++----- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 58 +- .../net/ethernet/mellanox/mlx5/core/esw/chains.h | 19 + drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 3 + drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 3 + .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 6 + .../net/ethernet/mellanox/mlx5/core/lib/port_tun.c | 4 +- include/net/bareudp.h | 7 + 21 files changed, 1816 insertions(+), 1121 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c
PATCH 1/10 net/mlx5e: Use IS_ERR() to check and simplify code
From: Tang Bin <[email protected]>
Use IS_ERR() and PTR_ERR() instead of PTR_ERR_OR_ZERO() to simplify code, avoid redundant judgements.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +2 -3
@@ -96,9 +96,8 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv, } rt =ip_route_output_key (dev_net (mirred_dev), fl4); - ret =PTR_ERR_OR_ZERO (rt); -if (ret) -return ret; +if (IS_ERR (rt)) +return PTR_ERR (rt);if (mlx5_lag_is_multipath (mdev) && rt->rt_gw_family !=AF_INET ) {ip_rt_put (rt);
Signature · 1 line
2.25.4
PATCH 2/10 net/mlx5e: Extract TC-specific code from en_rep.c to rep/tc.c
In reply to Saeed MahameedFrom: Vlad Buslov <[email protected]>
As a preparation for introducing new kconfig option that controls compilation of all TC offloads code in mlx5, extract TC-specific code from en_rep.c to standalone file. This allows easily compiling out the code by only including new source in make file when corresponding kconfig is enabled instead of adding multiple ifdef blocks to en_rep.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 3 +- .../ethernet/mellanox/mlx5/core/en/rep/tc.c | 710 ++++++++++++++++++ .../ethernet/mellanox/mlx5/core/en/rep/tc.h | 45 ++ .../ethernet/mellanox/mlx5/core/en/tc_tun.c | 1 + .../net/ethernet/mellanox/mlx5/core/en_rep.c | 543 +------------- .../net/ethernet/mellanox/mlx5/core/en_rep.h | 13 +- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 9 +- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 170 +---- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 35 +- 9 files changed, 821 insertions(+), 708 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.h
drivers/net/ethernet/mellanox/mlx5/core/Makefile +2 -1
@@ -33,7 +33,8 @@ mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \ mlx5_core-$(CONFIG_MLX5_EN_ARFS) += en_arfs.o mlx5_core-$(CONFIG_MLX5_EN_RXNFC) += en_fs_ethtool.o mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o en/port_buffer.o -mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o en_tc.o en/tc_tun.o lib/port_tun.o lag_mp.o \ +mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o en_tc.o en/rep/tc.o en/tc_tun.o lib/port_tun.o \ + lag_mp.o \ lib/geneve.o en/mapping.o en/tc_tun_vxlan.o en/tc_tun_gre.o \ en/tc_tun_geneve.o diag/en_tc_tracepoint.o mlx5_core-$(CONFIG_PCI_HYPERV_INTERFACE) += en/hv_vhca_stats.o
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c new file +710 -0
710 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.h new file +45 -0
45 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +1 -0
@@ -6,6 +6,7 @@#include <net/geneve.h> #include "en/tc_tun.h" #include "en_tc.h" +#include "rep/tc.h" struct mlx5e_tc_tunnel *mlx5e_get_tc_tun (struct net_device *tunnel_dev) {
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +19 -524
655 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +8 -5
@@ -203,16 +203,19 @@ void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);void mlx5e_handle_rx_cqe_mpwrq_rep (struct mlx5e_rq *rq,struct mlx5_cqe64 *cqe); -int mlx5e_rep_encap_entry_attach (struct mlx5e_priv *priv, -struct mlx5e_encap_entry *e); -void mlx5e_rep_encap_entry_detach (struct mlx5e_priv *priv, -struct mlx5e_encap_entry *e); -void mlx5e_rep_queue_neigh_stats_work (struct mlx5e_priv *priv);bool mlx5e_eswitch_rep (struct net_device *netdev);bool mlx5e_eswitch_uplink_rep (struct net_device *netdev); +struct mlx5e_neigh_hash_entry * +mlx5e_rep_neigh_entry_lookup (struct mlx5e_priv *priv, +struct mlx5e_neigh *m_neigh); +int mlx5e_rep_neigh_entry_create (struct mlx5e_priv *priv, +struct mlx5e_encap_entry *e, +struct mlx5e_neigh_hash_entry **nhe); +void mlx5e_rep_neigh_entry_release (struct mlx5e_neigh_hash_entry *nhe); +#else /* CONFIG_MLX5_ESWITCH */ static inline bool mlx5e_is_uplink_rep (struct mlx5e_priv *priv) {return false; }static inline int mlx5e_add_sqs_fwd_rules (struct mlx5e_priv *priv) {return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +5 -4
@@ -42,6 +42,7 @@#include "en_tc.h" #include "eswitch.h" #include "en_rep.h" +#include "en/rep/tc.h" #include "ipoib/ipoib.h" #include "en_accel/ipsec_rxtx.h" #include "en_accel/tls_rxtx.h"
@@ -1216,12 +1217,12 @@ void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)if (rep->vlan &&skb_vlan_tag_present (skb))skb_vlan_pop (skb); -if (!mlx5e_tc_rep_update_skb (cqe, skb, &tc_priv)) +if (!mlx5e_rep_tc_update_skb (cqe, skb, &tc_priv)) goto free_wqe;napi_gro_receive (rq->cq.napi, skb); -mlx5_tc_rep_post_napi_receive (&tc_priv); +mlx5_rep_tc_post_napi_receive (&tc_priv); free_wqe:mlx5e_free_rx_wqe (rq, wi, true);
@@ -1272,12 +1273,12 @@ void mlx5e_handle_rx_cqe_mpwrq_rep(struct mlx5e_rq *rq,mlx5e_complete_rx_cqe (rq, cqe, cqe_bcnt, skb); -if (!mlx5e_tc_rep_update_skb (cqe, skb, &tc_priv)) +if (!mlx5e_rep_tc_update_skb (cqe, skb, &tc_priv)) goto mpwrq_cqe_out;napi_gro_receive (rq->cq.napi, skb); -mlx5_tc_rep_post_napi_receive (&tc_priv); +mlx5_rep_tc_post_napi_receive (&tc_priv); mpwrq_cqe_out:if (likely (wi->consumed_strides < rq->mpwqe.num_strides))
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -169
188 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +30 -5
@@ -34,11 +34,41 @@#define __MLX5_EN_TC_H__#include <net/pkt_cls.h> +#include "en.h" #define MLX5E_TC_FLOW_ID_MASK 0x0000ffff#ifdef CONFIG_MLX5_ESWITCH +struct tunnel_match_key { +struct flow_dissector_key_control enc_control; +struct flow_dissector_key_keyid enc_key_id; +struct flow_dissector_key_ports enc_tp; +struct flow_dissector_key_ip enc_ip; +union { +struct flow_dissector_key_ipv4_addrs enc_ipv4; +struct flow_dissector_key_ipv6_addrs enc_ipv6; + }; + +int filter_ifindex; +}; + +struct tunnel_match_enc_opts { +struct flow_dissector_key_enc_opts key; +struct flow_dissector_key_enc_opts mask; +}; + +/* Tunnel_id mapping is TUNNEL_INFO_BITS + ENC_OPTS_BITS. +* Upper TUNNEL_INFO_BITS for general tunnel info. +* Lower ENC_OPTS_BITS bits for enc_opts. +*/ +#define TUNNEL_INFO_BITS 6 +#define TUNNEL_INFO_BITS_MASK GENMASK(TUNNEL_INFO_BITS - 1, 0) +#define ENC_OPTS_BITS 2 +#define ENC_OPTS_BITS_MASK GENMASK(ENC_OPTS_BITS - 1, 0) +#define TUNNEL_ID_BITS (TUNNEL_INFO_BITS + ENC_OPTS_BITS) +#define TUNNEL_ID_MASK GENMASK(TUNNEL_ID_BITS - 1, 0) +enum {MLX5E_TC_FLAG_INGRESS_BIT , MLX5E_TC_FLAG_EGRESS_BIT,
@@ -119,11 +149,6 @@ struct mlx5e_tc_update_priv {struct net_device *tun_dev; }; -bool mlx5e_tc_rep_update_skb (struct mlx5_cqe64 *cqe,struct sk_buff *skb, -struct mlx5e_tc_update_priv *tc_priv); - -void mlx5_tc_rep_post_napi_receive (struct mlx5e_tc_update_priv *tc_priv); -struct mlx5e_tc_mod_hdr_acts {int num_actions;int max_actions;
Signature · 1 line
2.25.4
PATCH 3/10 net/mlx5e: Extract neigh-specific code from en_rep.c to rep/neigh.c
In reply to Saeed MahameedFrom: Vlad Buslov <[email protected]>
As a preparation for introducing new kconfig option that controls compilation of all TC offloads code in mlx5, extract neigh-specific code from en_rep.c to standalone file. This allows easily compiling out the code by only including new source in make file when corresponding kconfig is enabled instead of adding multiple ifdef blocks to en_rep.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../mellanox/mlx5/core/en/rep/neigh.c | 368 ++++++++++++++++++ .../mellanox/mlx5/core/en/rep/neigh.h | 23 ++ .../ethernet/mellanox/mlx5/core/en/rep/tc.c | 1 + .../ethernet/mellanox/mlx5/core/en/tc_tun.c | 1 + .../net/ethernet/mellanox/mlx5/core/en_rep.c | 354 +---------------- .../net/ethernet/mellanox/mlx5/core/en_rep.h | 8 - .../net/ethernet/mellanox/mlx5/core/en_tc.c | 6 - 8 files changed, 395 insertions(+), 368 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.h
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -33,7 +33,7 @@ mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \ mlx5_core-$(CONFIG_MLX5_EN_ARFS) += en_arfs.o mlx5_core-$(CONFIG_MLX5_EN_RXNFC) += en_fs_ethtool.o mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o en/port_buffer.o -mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o en_tc.o en/rep/tc.o en/tc_tun.o lib/port_tun.o \ +mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o en_tc.o en/rep/tc.o en/rep/neigh.o en/tc_tun.o lib/port_tun.o \ lag_mp.o \ lib/geneve.o en/mapping.o en/tc_tun_vxlan.o en/tc_tun_gre.o \ en/tc_tun_geneve.o diag/en_tc_tracepoint.o
drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c new file +368 -0
368 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2020 Mellanox Technologies. */ + +#ifndef __MLX5_EN_REP_NEIGH__ +#define __MLX5_EN_REP_NEIGH__ + +#include "en.h" +#include "en_rep.h" + +int mlx5e_rep_neigh_init (struct mlx5e_rep_priv *rpriv); +void mlx5e_rep_neigh_cleanup (struct mlx5e_rep_priv *rpriv); + +struct mlx5e_neigh_hash_entry * +mlx5e_rep_neigh_entry_lookup (struct mlx5e_priv *priv, +struct mlx5e_neigh *m_neigh); +int mlx5e_rep_neigh_entry_create (struct mlx5e_priv *priv, +struct mlx5e_encap_entry *e, +struct mlx5e_neigh_hash_entry **nhe); +void mlx5e_rep_neigh_entry_release (struct mlx5e_neigh_hash_entry *nhe); + +void mlx5e_rep_queue_neigh_stats_work (struct mlx5e_priv *priv); + +#endif /* __MLX5_EN_REP_NEIGH__ */
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +1 -0
@@ -9,6 +9,7 @@#include <linux/workqueue.h> #include <linux/spinlock.h> #include "tc.h" +#include "neigh.h" #include "en_rep.h" #include "eswitch.h" #include "esw/chains.h"
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +1 -0
@@ -7,6 +7,7 @@#include "en/tc_tun.h" #include "en_tc.h" #include "rep/tc.h" +#include "rep/neigh.h" struct mlx5e_tc_tunnel *mlx5e_get_tc_tun (struct net_device *tunnel_dev) {
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -353
372 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +0 -8
@@ -208,14 +208,6 @@ void mlx5e_rep_queue_neigh_stats_work(struct mlx5e_priv *priv);bool mlx5e_eswitch_rep (struct net_device *netdev);bool mlx5e_eswitch_uplink_rep (struct net_device *netdev); -struct mlx5e_neigh_hash_entry * -mlx5e_rep_neigh_entry_lookup (struct mlx5e_priv *priv, -struct mlx5e_neigh *m_neigh); -int mlx5e_rep_neigh_entry_create (struct mlx5e_priv *priv, -struct mlx5e_encap_entry *e, -struct mlx5e_neigh_hash_entry **nhe); -void mlx5e_rep_neigh_entry_release (struct mlx5e_neigh_hash_entry *nhe); -#else /* CONFIG_MLX5_ESWITCH */ static inline bool mlx5e_is_uplink_rep (struct mlx5e_priv *priv) {return false; }static inline int mlx5e_add_sqs_fwd_rules (struct mlx5e_priv *priv) {return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -6
@@ -4777,9 +4777,3 @@ void mlx5e_tc_reoffload_flows_work(struct work_struct *work) }mutex_unlock (&rpriv->unready_flows_lock); } - -void mlx5_tc_rep_post_napi_receive (struct mlx5e_tc_update_priv *tc_priv) -{ -if (tc_priv->tun_dev) -dev_put (tc_priv->tun_dev); -}
Signature · 1 line
2.25.4
PATCH 4/10 net/mlx5e: Move TC-specific code from en_main.c to en_tc.c
In reply to Saeed MahameedFrom: Vlad Buslov <[email protected]>
As a preparation for introducing new kconfig option that controls compilation of all TC offloads code in mlx5, extract TC-specific code from en_main.c to en_tc.c. This allows easily compiling out the code by only including new source in make file when corresponding kconfig is enabled instead of adding multiple ifdef blocks to en_main.
--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 37 ------------------- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 35 ++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.h | 7 ++++ 3 files changed, 42 insertions(+), 37 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +0 -37
@@ -3539,41 +3539,6 @@ static int mlx5e_setup_tc_mqprio(struct mlx5e_priv *priv,return err; } -#ifdef CONFIG_MLX5_ESWITCH -static int mlx5e_setup_tc_cls_flower (struct mlx5e_priv *priv, -struct flow_cls_offload *cls_flower, -unsigned long flags) -{ -switch (cls_flower->command) { -case FLOW_CLS_REPLACE : -return mlx5e_configure_flower (priv->netdev, priv, cls_flower, - flags); -case FLOW_CLS_DESTROY : -return mlx5e_delete_flower (priv->netdev, priv, cls_flower, - flags); -case FLOW_CLS_STATS : -return mlx5e_stats_flower (priv->netdev, priv, cls_flower, - flags); -default : -return -EOPNOTSUPP ; - } -} - -static int mlx5e_setup_tc_block_cb (enum tc_setup_type type,void *type_data, -void *cb_priv) -{ -unsigned long flags =MLX5_TC_FLAG (INGRESS ) |MLX5_TC_FLAG (NIC_OFFLOAD ); -struct mlx5e_priv *priv = cb_priv; - -switch (type) { -case TC_SETUP_CLSFLOWER : -return mlx5e_setup_tc_cls_flower (priv, type_data, flags); -default : -return -EOPNOTSUPP ; - } -} -#endif -static LIST_HEAD (mlx5e_block_cb_list); static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
@@ -3582,7 +3547,6 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,struct mlx5e_priv *priv =netdev_priv (dev);switch (type) { -#ifdef CONFIG_MLX5_ESWITCH case TC_SETUP_BLOCK : {struct flow_block_offload *f = type_data;
@@ -3592,7 +3556,6 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, mlx5e_setup_tc_block_cb, priv, priv, true); } -#endif case TC_SETUP_QDISC_MQPRIO :return mlx5e_setup_tc_mqprio (priv, type_data);default :
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +35 -0
@@ -31,6 +31,7 @@*/ #include <net/flow_dissector.h> +#include <net/flow_offload.h> #include <net/sch_generic.h> #include <net/pkt_cls.h> #include <net/tc_act/tc_gact.h>
@@ -50,6 +51,7 @@#include "en.h" #include "en_rep.h" #include "en/rep/tc.h" +#include "en/rep/neigh.h" #include "en_tc.h" #include "eswitch.h" #include "esw/chains.h"
@@ -4777,3 +4779,36 @@ void mlx5e_tc_reoffload_flows_work(struct work_struct *work) }mutex_unlock (&rpriv->unready_flows_lock); } + +static int mlx5e_setup_tc_cls_flower (struct mlx5e_priv *priv, +struct flow_cls_offload *cls_flower, +unsigned long flags) +{ +switch (cls_flower->command) { +case FLOW_CLS_REPLACE : +return mlx5e_configure_flower (priv->netdev, priv, cls_flower, + flags); +case FLOW_CLS_DESTROY : +return mlx5e_delete_flower (priv->netdev, priv, cls_flower, + flags); +case FLOW_CLS_STATS : +return mlx5e_stats_flower (priv->netdev, priv, cls_flower, + flags); +default : +return -EOPNOTSUPP ; + } +} + +int mlx5e_setup_tc_block_cb (enum tc_setup_type type,void *type_data, +void *cb_priv) +{ +unsigned long flags =MLX5_TC_FLAG (INGRESS ) |MLX5_TC_FLAG (NIC_OFFLOAD ); +struct mlx5e_priv *priv = cb_priv; + +switch (type) { +case TC_SETUP_CLSFLOWER : +return mlx5e_setup_tc_cls_flower (priv, type_data, flags); +default : +return -EOPNOTSUPP ; + } +}
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +7 -0
@@ -173,6 +173,9 @@ void dealloc_mod_hdr_actions(struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);struct mlx5e_tc_flow ;u32 mlx5e_tc_get_flow_tun_id (struct mlx5e_tc_flow *flow); +int mlx5e_setup_tc_block_cb (enum tc_setup_type type,void *type_data, +void *cb_priv); +#else /* CONFIG_MLX5_ESWITCH */ static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; }static inline void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv) {}
@@ -181,6 +184,10 @@ static inline int mlx5e_tc_num_filters(struct mlx5e_priv *priv, {return 0 ; } + +static inline int +mlx5e_setup_tc_block_cb (enum tc_setup_type type,void *type_data,void *cb_priv) +{return -EOPNOTSUPP ; }#endif #endif /* __MLX5_EN_TC_H__ */
Signature · 1 line
2.25.4
PATCH 5/10 net/mlx5e: Introduce kconfig var for TC support
In reply to Saeed MahameedFrom: Vlad Buslov <[email protected]>
In order to improve code maintainability and readability, introduce new CONFIG_MLX5_CLS_ACT kconfig variable to control compilation of TC hardware offloads implementation. This allows distinguishing between features that require TC support (MPLSoUDP, etc.) and features that just rely on representor functionality (rep_bond for live migration, etc.).
Modify rep_tc.h, rep_neigh.h, en_tc.h and chains.h files to provide stubs for functions that are called from generic code.
--- .../net/ethernet/mellanox/mlx5/core/Kconfig | 17 ++++++- .../net/ethernet/mellanox/mlx5/core/Makefile | 11 ++--- .../mellanox/mlx5/core/en/rep/neigh.h | 11 +++++ .../ethernet/mellanox/mlx5/core/en/rep/tc.h | 44 +++++++++++++++++-- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 16 +++++-- .../ethernet/mellanox/mlx5/core/esw/chains.h | 19 ++++++++ .../mellanox/mlx5/core/eswitch_offloads.c | 2 + 8 files changed, 109 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +16 -1
@@ -78,9 +78,24 @@ config MLX5_ESWITCH Legacy SRIOV mode (L2 mac vlan steering based). Switchdev mode (eswitch offloads). +config MLX5_CLS_ACT + bool "MLX5 TC classifier action support" + depends on MLX5_ESWITCH && NET_CLS_ACT + default y + help + mlx5 ConnectX offloads support for TC classifier action (NET_CLS_ACT), + works in both native NIC mdoe and Switchdev SRIOV mode. + Actions get attached to a Hardware offloaded classifiers and are + invoked after a successful classification. Actions are used to + overwrite the classification result, instantly drop or redirect and/or + reformat packets in wire speeds without involving the host cpu. + + If set to N, TC offloads in both NIC and switchdev modes will be disabled. + If unsure, set to Y + config MLX5_TC_CT bool "MLX5 TC connection tracking offload support" - depends on MLX5_CORE_EN && NET_SWITCHDEV && NF_FLOW_TABLE && NET_ACT_CT && NET_TC_SKB_EXT + depends on MLX5_CLS_ACT && NF_FLOW_TABLE && NET_ACT_CT && NET_TC_SKB_EXT default y help Say Y here if you want to support offloading connection tracking rules
drivers/net/ethernet/mellanox/mlx5/core/Makefile +6 -5
@@ -33,18 +33,19 @@ mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \ mlx5_core-$(CONFIG_MLX5_EN_ARFS) += en_arfs.o mlx5_core-$(CONFIG_MLX5_EN_RXNFC) += en_fs_ethtool.o mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o en/port_buffer.o -mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o en_tc.o en/rep/tc.o en/rep/neigh.o en/tc_tun.o lib/port_tun.o \ - lag_mp.o \ - lib/geneve.o en/mapping.o en/tc_tun_vxlan.o en/tc_tun_gre.o \ - en/tc_tun_geneve.o diag/en_tc_tracepoint.o mlx5_core-$(CONFIG_PCI_HYPERV_INTERFACE) += en/hv_vhca_stats.o +mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o lib/geneve.o lib/port_tun.o lag_mp.o +mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ + en/mapping.o esw/chains.o en/tc_tun.o \ + en/tc_tun_vxlan.o en/tc_tun_gre.o en/tc_tun_geneve.o \ + diag/en_tc_tracepoint.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o # # Core extra # mlx5_core-$(CONFIG_MLX5_ESWITCH) += eswitch.o eswitch_offloads.o eswitch_offloads_termtbl.o \ - ecpf.o rdma.o esw/chains.o + ecpf.o rdma.o mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o mlx5_core-$(CONFIG_VXLAN) += lib/vxlan.o mlx5_core-$(CONFIG_PTP_1588_CLOCK) += lib/clock.o
drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.h +11 -0
@@ -7,6 +7,8 @@#include "en.h" #include "en_rep.h" +#if IS_ENABLED (CONFIG_MLX5_CLS_ACT ) +int mlx5e_rep_neigh_init (struct mlx5e_rep_priv *rpriv);void mlx5e_rep_neigh_cleanup (struct mlx5e_rep_priv *rpriv);
@@ -20,4 +22,13 @@ void mlx5e_rep_neigh_entry_release(struct mlx5e_neigh_hash_entry *nhe);void mlx5e_rep_queue_neigh_stats_work (struct mlx5e_priv *priv); +#else /* CONFIG_MLX5_CLS_ACT */ + +static inline int +mlx5e_rep_neigh_init (struct mlx5e_rep_priv *rpriv) {return 0 ; } +static inline void +mlx5e_rep_neigh_cleanup (struct mlx5e_rep_priv *rpriv) {} + +#endif /* CONFIG_MLX5_CLS_ACT */ +#endif /* __MLX5_EN_REP_NEIGH__ */
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.h +40 -4
68 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -2
@@ -3728,7 +3728,7 @@ static int set_feature_cvlan_filter(struct net_device *netdev, bool enable)return 0 ; } -#ifdef CONFIG_MLX5_ESWITCH +#if IS_ENABLED (CONFIG_MLX5_CLS_ACT )static int set_feature_tc_num_filters (struct net_device *netdev,bool enable) {struct mlx5e_priv *priv =netdev_priv (netdev);
@@ -3839,7 +3839,7 @@ int mlx5e_set_features(struct net_device *netdev, netdev_features_t features) err |=MLX5E_HANDLE_FEATURE (NETIF_F_LRO , set_feature_lro); err |=MLX5E_HANDLE_FEATURE (NETIF_F_HW_VLAN_CTAG_FILTER , set_feature_cvlan_filter); -#ifdef CONFIG_MLX5_ESWITCH +#if IS_ENABLED (CONFIG_MLX5_CLS_ACT ) err |=MLX5E_HANDLE_FEATURE (NETIF_F_HW_TC , set_feature_tc_num_filters);#endif err |=MLX5E_HANDLE_FEATURE (NETIF_F_RXALL , set_feature_rx_all);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +13 -3
@@ -80,9 +80,6 @@ enum {#define MLX5_TC_FLAG (flag) BIT(MLX5E_TC_FLAG_##flag##_BIT) -int mlx5e_tc_nic_init (struct mlx5e_priv *priv); -void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv); -int mlx5e_tc_esw_init (struct rhashtable *tc_ht);void mlx5e_tc_esw_cleanup (struct rhashtable *tc_ht);
@@ -173,9 +170,22 @@ void dealloc_mod_hdr_actions(struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);struct mlx5e_tc_flow ;u32 mlx5e_tc_get_flow_tun_id (struct mlx5e_tc_flow *flow); +#if IS_ENABLED (CONFIG_MLX5_CLS_ACT ) + +int mlx5e_tc_nic_init (struct mlx5e_priv *priv); +void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv); +int mlx5e_setup_tc_block_cb (enum tc_setup_type type,void *type_data,void *cb_priv); +#else /* CONFIG_MLX5_CLS_ACT */ +static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; } +static inline void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv) {} +static inline int +mlx5e_setup_tc_block_cb (enum tc_setup_type type,void *type_data,void *cb_priv) +{return -EOPNOTSUPP ; } +#endif /* CONFIG_MLX5_CLS_ACT */ +#else /* CONFIG_MLX5_ESWITCH */ static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; }static inline void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv) {}
drivers/net/ethernet/mellanox/mlx5/core/esw/chains.h +19 -0
@@ -6,6 +6,8 @@#include "eswitch.h" +#if IS_ENABLED (CONFIG_MLX5_CLS_ACT ) +bool mlx5_esw_chains_prios_supported (struct mlx5_eswitch *esw);bool
@@ -46,4 +48,21 @@ void mlx5_esw_chains_destroy(struct mlx5_eswitch *esw);int mlx5_eswitch_get_chain_for_tag (struct mlx5_eswitch *esw,u32 tag,u32 *chain); +#else /* CONFIG_MLX5_CLS_ACT */ + +static inline struct mlx5_flow_table * +mlx5_esw_chains_get_table (struct mlx5_eswitch *esw,u32 chain,u32 prio, +u32 level) {return ERR_PTR (-EOPNOTSUPP ); } +static inline void +mlx5_esw_chains_put_table (struct mlx5_eswitch *esw,u32 chain,u32 prio, +u32 level) {} + +static inline struct mlx5_flow_table * +mlx5_esw_chains_get_tc_end_ft (struct mlx5_eswitch *esw) {return ERR_PTR (-EOPNOTSUPP ); } + +static inline int mlx5_esw_chains_create (struct mlx5_eswitch *esw) {return 0 ; } +static inline void mlx5_esw_chains_destroy (struct mlx5_eswitch *esw) {} + +#endif /* CONFIG_MLX5_CLS_ACT */ +#endif /* __ML5_ESW_CHAINS_H__ */
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
@@ -1727,7 +1727,9 @@ static int mlx5_esw_offloads_pair(struct mlx5_eswitch *esw,static void mlx5_esw_offloads_unpair (struct mlx5_eswitch *esw) { +#if IS_ENABLED (CONFIG_MLX5_CLS_ACT )mlx5e_tc_clean_fdb_peer_flows (esw); +#endif esw_del_fdb_peer_miss_rules (esw); }
Signature · 1 line
2.25.4
Re: [net-next 05/10] net/mlx5e: Introduce kconfig var for TC support
On Fri, May 22, 2020 at 04:51:43PM -0700, Saeed Mahameed wrote:
...
drivers/net/ethernet/mellanox/mlx5/core/Kconfig config MLX5_ESWITCH · line 87
Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +7
-0+config MLX5_CLS_ACT + bool "MLX5 TC classifier action support" + depends on MLX5_ESWITCH && NET_CLS_ACT + default y + help + mlx5 ConnectX offloads support for TC classifier action (NET_CLS_ACT), + works in both native NIC mdoe and Switchdev SRIOV mode.
Typo here btw, "mdoe".
Quoted 15 lines
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +9
-1+ Actions get attached to a Hardware offloaded classifiers and are + invoked after a successful classification. Actions are used to + overwrite the classification result, instantly drop or redirect and/or + reformat packets in wire speeds without involving the host cpu. + + If set to N, TC offloads in both NIC and switchdev modes will be disabled. + If unsure, set to Y + config MLX5_TC_CT bool "MLX5 TC connection tracking offload support" - depends on MLX5_CORE_EN && NET_SWITCHDEV && NF_FLOW_TABLE && NET_ACT_CT && NET_TC_SKB_EXT + depends on MLX5_CLS_ACT && NF_FLOW_TABLE && NET_ACT_CT && NET_TC_SKB_EXT default y help Say Y here if you want to support offloading connection tracking rules
Re: [net-next 05/10] net/mlx5e: Introduce kconfig var for TC support
Quoted 14 lines · Marcelo Ricardo Leitner
Quoted 1 line
On Fri, May 22, 2020 at 04:51:43PM -0700, Saeed Mahameed wrote:
...drivers/net/ethernet/mellanox/mlx5/core/Kconfig config MLX5_ESWITCH · line 87
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/Kconfig +6
-0+config MLX5_CLS_ACT + bool "MLX5 TC classifier action support" + depends on MLX5_ESWITCH && NET_CLS_ACT + default y + help + mlx5 ConnectX offloads support for TC classifier action(
NET_CLS_ACT),drivers/net/ethernet/mellanox/mlx5/core/Kconfig +1
-0+ works in both native NIC mdoe and Switchdev SRIOV mode.Typo here btw, "mdoe".
Right ! will fix,
Thanks!
PATCH 6/10 net: Add netif_is_bareudp() API to identify bareudp devices
In reply to Saeed MahameedFrom: Eli Cohen <[email protected]>
Add netif_is_bareudp() so the device can be identified as a bareudp one.
--- include/net/bareudp.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/net/bareudp.h +7 -0
@@ -5,6 +5,7 @@#include <linux/types.h> #include <linux/skbuff.h> +#include <net/rtnetlink.h> struct bareudp_conf {__be16 ethertype;
@@ -17,4 +18,10 @@ struct net_device *bareudp_dev_create(struct net *net, const char *name,u8 name_assign_type, struct bareudp_conf *info); +static inline bool netif_is_bareudp (const struct net_device *dev) +{ +return dev->rtnl_link_ops && + !strcmp (dev->rtnl_link_ops->kind,"bareudp" ); +} +#endif
Signature · 1 line
2.25.4
PATCH 7/10 net/mlx5e: Add support for hw encapsulation of MPLS over UDP
In reply to Saeed MahameedFrom: Eli Cohen <[email protected]>
MPLS over UDP is supported by adding a rule on a representor net device which does tunnel_key set, push mpls and forward to a baredup device. At the hardware level we use a packet_reformat_context object to do the encapsulation of the packet.
The resulting packet looks as follows (left side transmitted first):
outer L2 | outer IP | UDP | MPLS | inner L3 and data |
Example usage:
tc filter add dev $rep0 protocol ip prio 1 root flower skip_sw \
action tunnel_key set src_ip 8.8.8.21 dst_ip 8.8.8.24 id 555 \
dst_port 6635 tos 4 ttl 6 csum action mpls push protocol 0x8847 \
label 555 tc 3 action mirred egress redirect dev bareudp0This is how the filter is shown with tc filter show:
tc filter show dev enp59s0f0_0 ingress filter protocol ip pref 1 flower chain 0 filter protocol ip pref 1 flower chain 0 handle 0x1
eth_type ipv4
skip_sw
in_hw in_hw_count 1
action order 1: tunnel_key set src_ip 8.8.8.21
dst_ip 8.8.8.24
key_id 555
dst_port 6635
csum
tos 0x4
ttl 6 pipe
index 1 ref 1 bind 1
action order 2: mpls push protocol mpls_uc label 555 tc 3 ttl 255 pipe
index 1 ref 1 bind 1
action order 3: mirred (Egress Redirect to device bareudp0) stolen index 1 ref 1 bind 1
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../ethernet/mellanox/mlx5/core/en/tc_tun.c | 3 + .../ethernet/mellanox/mlx5/core/en/tc_tun.h | 2 + .../mellanox/mlx5/core/en/tc_tun_mplsoudp.c | 88 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 18 ++++ .../mellanox/mlx5/core/lib/port_tun.c | 4 +- 6 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -38,7 +38,7 @@ mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o lib/geneve.o lib/port_tun.o lag mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ en/mapping.o esw/chains.o en/tc_tun.o \ en/tc_tun_vxlan.o en/tc_tun_gre.o en/tc_tun_geneve.o \ - diag/en_tc_tracepoint.o + en/tc_tun_mplsoudp.o diag/en_tc_tracepoint.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o #
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +3 -0
@@ -4,6 +4,7 @@#include <net/vxlan.h> #include <net/gre.h> #include <net/geneve.h> +#include <net/bareudp.h> #include "en/tc_tun.h" #include "en_tc.h" #include "rep/tc.h"
@@ -18,6 +19,8 @@ struct mlx5e_tc_tunnel *mlx5e_get_tc_tun(struct net_device *tunnel_dev)else if (netif_is_gretap (tunnel_dev) ||netif_is_ip6gretap (tunnel_dev))return &gre_tunnel; +else if (netif_is_bareudp (tunnel_dev)) +return &mplsoudp_tunnel;else return NULL ; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h +2 -0
@@ -16,6 +16,7 @@ enum {MLX5E_TC_TUNNEL_TYPE_VXLAN ,MLX5E_TC_TUNNEL_TYPE_GENEVE ,MLX5E_TC_TUNNEL_TYPE_GRETAP , + MLX5E_TC_TUNNEL_TYPE_MPLSOUDP, }; struct mlx5e_tc_tunnel {
@@ -46,6 +47,7 @@ struct mlx5e_tc_tunnel {extern struct mlx5e_tc_tunnel vxlan_tunnel;extern struct mlx5e_tc_tunnel geneve_tunnel;extern struct mlx5e_tc_tunnel gre_tunnel; +extern struct mlx5e_tc_tunnel mplsoudp_tunnel;struct mlx5e_tc_tunnel *mlx5e_get_tc_tun (struct net_device *tunnel_dev);
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c new file +88 -0
88 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +18 -0
@@ -48,6 +48,7 @@#include <net/tc_act/tc_csum.h> #include <net/arp.h> #include <net/ipv6_stubs.h> +#include <net/bareudp.h> #include "en.h" #include "en_rep.h" #include "en/rep/tc.h"
@@ -3685,6 +3686,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,bool encap = false, decap = false;u32 action = attr->action;int err, i, if_count =0 ; +bool mpls_push = false;if (!flow_action_has_entries (flow_action))return -EINVAL ;
@@ -3699,6 +3701,16 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, action |=MLX5_FLOW_CONTEXT_ACTION_DROP |MLX5_FLOW_CONTEXT_ACTION_COUNT ;break ; +case FLOW_ACTION_MPLS_PUSH : +if (!MLX5_CAP_ESW_FLOWTABLE_FDB (priv->mdev, + reformat_l2_to_l3_tunnel) || + act->mpls_push.proto !=htons (ETH_P_MPLS_UC )) { +NL_SET_ERR_MSG_MOD (extack, +"mpls push is supported only for mpls_uc protocol" ); +return -EOPNOTSUPP ; + } + mpls_push = true; +break ;case FLOW_ACTION_MANGLE :case FLOW_ACTION_ADD : err = parse_tc_pedit_action(priv, act, MLX5_FLOW_NAMESPACE_FDB,
@@ -3729,6 +3741,12 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,return -EINVAL ; } +if (mpls_push && !netif_is_bareudp (out_dev)) { +NL_SET_ERR_MSG_MOD (extack, +"mpls is supported only through a bareudp device" ); +return -EOPNOTSUPP ; + } +if (ft_flow && out_dev == priv->netdev) {/* Ignore forward to self rules generated * by adding both mlx5 devs to the flow table
drivers/net/ethernet/mellanox/mlx5/core/lib/port_tun.c +2 -2
@@ -144,11 +144,11 @@ static int mlx5_set_entropy(struct mlx5_tun_entropy *tun_entropy,int mlx5_tun_entropy_refcount_inc (struct mlx5_tun_entropy *tun_entropy,int reformat_type) { -/* the default is error for unknown (non VXLAN/GRE tunnel types) */ int err = -EOPNOTSUPP ;mutex_lock (&tun_entropy->lock); -if (reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_VXLAN && +if ((reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_VXLAN || + reformat_type ==MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL ) && tun_entropy->enabled) {/* in case entropy calculation is enabled for all tunneling * types, it is ok for VXLAN, so approve.
Signature · 1 line
2.25.4
Jakub Kicinski
maintainerRe: [net-next 07/10] net/mlx5e: Add support for hw encapsulation of MPLS over UDP
Quoted 4 lines · On Fri, 22 May 2020 16:51:45 -0700 Saeed Mahameed wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c new file +4
-0+static inline __be32 mpls_label_id_field (__be32 label,u8 tos,u8 ttl) +{ +u32 res; +
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c line 41
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c new file +10
-0+/* mpls label is 32 bits long and construction as follows: +* 20 bits label +* 3 bits tos +* 1 bit bottom of stack. Since we support only one label, this bit is +* always set. +* 8 bits TTL +*/ + res =be32_to_cpu (label) <<12 |1 <<8 | (tos &7 ) <<9 | ttl; +return cpu_to_be32 (res); +}
No static inlines in C source, please. Besides this belongs in the mpls header, it's a generic helper.
Re: [net-next 07/10] net/mlx5e: Add support for hw encapsulation of MPLS over UDP
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Fri, 22 May 2020 16:51:45 -0700 Saeed Mahameed wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c new file +9
-0+static inline __be32 mpls_label_id_field (__be32 label,u8 tos,u8 ttl) +{ +u32 res; + +/* mpls label is 32 bits long and construction as follows: +* 20 bits label +* 3 bits tos +* 1 bit bottom of stack. Since we support only one label, this bit is +* always set.
Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c line 41
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c new file +5
-0+* 8 bits TTL +*/ + res =be32_to_cpu (label) <<12 |1 <<8 | (tos &7 ) <<9 | ttl; +return cpu_to_be32 (res); +}No static inlines in C source, please. Besides this belongs in the mpls header, it's a generic helper.
net/mpls/internal.h:
static inline struct mpls_shim_hdr mpls_entry_encode(u32 label, unsigned ttl, unsigned tc, bool bos)
{
struct mpls_shim_hdr result;
result.label_stack_entry =
cpu_to_be32((label << MPLS_LS_LABEL_SHIFT) |
(tc << MPLS_LS_TC_SHIFT) |
(bos ? (1 << MPLS_LS_S_SHIFT) : 0) |
(ttl << MPLS_LS_TTL_SHIFT));
return result;
}perhaps that can be moved to include/net/mpls.h
Re: [net-next 07/10] net/mlx5e: Add support for hw encapsulation of MPLS over UDP
Quoted 40 lines · David Ahern
Quoted 14 lines · Jakub Kicinski
Quoted 13 lines · On Fri, 22 May 2020 16:51:45 -0700 Saeed Mahameed wrote:
+static inline
__be32mpls_label_id_field(__be32 label, u8 tos, u8 ttl)drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c new file +7
-0+{ +u32 res; + +/* mpls label is 32 bits long and construction as follows: +* 20 bits label +* 3 bits tos +* 1 bit bottom of stack. Since we support only one label, this bit is
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c new file +3
-0+* always set. +* 8 bits TTL +*/ Quoted 9 lines
Review
Quoted 4 lines
(quoted diff) +1
-0+ res = be32_to_cpu(label) << 12 | 1 << 8 | (tos & 7) << 9 |ttl;
(quoted diff) +2
-0+ return cpu_to_be32(res); +}No static inlines in C source, please. Besides this belongs in the mpls
header, it's a generic helper.
net/mpls/internal.h:static inline struct
mpls_shim_hdrmpls_entry_encode(u32 label, unsigned
ttl, unsigned tc, bool bos){ struct mpls_shim_hdr result; result.label_stack_entry = cpu_to_be32((label << MPLS_LS_LABEL_SHIFT) | (tc << MPLS_LS_TC_SHIFT) | (bos ? (1 << MPLS_LS_S_SHIFT) : 0) | (ttl << MPLS_LS_TTL_SHIFT)); return result; }
Quoted 1 line
perhaps that can be moved to
include/net/mpls.h
Agreed, Eli is preparing a patch as we speak.
Thanks,
Saeed.
PATCH 8/10 net/mlx5e: Allow to match on mpls parameters
In reply to Saeed MahameedFrom: Eli Cohen <[email protected]>
Support matching on MPLS over UDP parameters using misc2 section of match parameters.
--- .../mellanox/mlx5/core/en/tc_tun_mplsoudp.c | 49 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 20 +++++++- 2 files changed, 67 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c +49 -0
@@ -73,6 +73,55 @@ static int parse_tunnel(struct mlx5e_priv *priv,void *headers_c, void *headers_v) { + struct flow_rule *rule = flow_cls_offload_flow_rule(f); +struct flow_match_enc_keyid enc_keyid; +struct flow_match_mpls match; +void *misc2_c; +void *misc2_v; + + misc2_c =MLX5_ADDR_OF (fte_match_param, spec->match_criteria, + misc_parameters_2); + misc2_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, + misc_parameters_2); + +if (!flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_MPLS )) +return 0 ; + +if (!flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_KEYID )) +return 0 ; + +flow_rule_match_enc_keyid (rule, &enc_keyid); + +if (!enc_keyid.mask->keyid) +return 0 ; + +if (!(MLX5_CAP_GEN (priv->mdev, flex_parser_protocols) & +MLX5_FLEX_PROTO_CW_MPLS_UDP )) +return -EOPNOTSUPP ; + +flow_rule_match_mpls (rule, &match); + +MLX5_SET (fte_match_set_misc2, misc2_c, + outer_first_mpls_over_udp.mpls_label, match.mask->mpls_label); +MLX5_SET (fte_match_set_misc2, misc2_v, + outer_first_mpls_over_udp.mpls_label, match.key->mpls_label); + +MLX5_SET (fte_match_set_misc2, misc2_c, + outer_first_mpls_over_udp.mpls_exp, match.mask->mpls_tc); +MLX5_SET (fte_match_set_misc2, misc2_v, + outer_first_mpls_over_udp.mpls_exp, match.key->mpls_tc); + +MLX5_SET (fte_match_set_misc2, misc2_c, + outer_first_mpls_over_udp.mpls_s_bos, match.mask->mpls_bos); +MLX5_SET (fte_match_set_misc2, misc2_v, + outer_first_mpls_over_udp.mpls_s_bos, match.key->mpls_bos); + +MLX5_SET (fte_match_set_misc2, misc2_c, + outer_first_mpls_over_udp.mpls_ttl, match.mask->mpls_ttl); +MLX5_SET (fte_match_set_misc2, misc2_v, + outer_first_mpls_over_udp.mpls_ttl, match.key->mpls_ttl); + spec->match_criteria_enable |=MLX5_MATCH_MISC_PARAMETERS_2 ; +return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +18 -2
@@ -2073,6 +2073,20 @@ static int mlx5e_flower_parse_meta(struct net_device *filter_dev,return 0 ; } +static bool skip_key_basic (struct net_device *filter_dev, +struct flow_cls_offload *f) +{ +/* When doing mpls over udp decap, the user needs to provide +* MPLS_UC as the protocol in order to be able to match on mpls +* label fields. However, the actual ethertype is IP so we want to +* avoid matching on this, otherwise we'll fail the match. +*/ +if (netif_is_bareudp (filter_dev) && f->common.chain_index ==0 ) +return true; + +return false; +} + static int __parse_cls_flower(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow, struct mlx5_flow_spec *spec,
@@ -2117,7 +2131,8 @@ static int __parse_cls_flower(struct mlx5e_priv *priv, BIT(FLOW_DISSECTOR_KEY_IP) | BIT(FLOW_DISSECTOR_KEY_CT) | BIT(FLOW_DISSECTOR_KEY_ENC_IP) | - BIT(FLOW_DISSECTOR_KEY_ENC_OPTS))) { + BIT(FLOW_DISSECTOR_KEY_ENC_OPTS) | + BIT(FLOW_DISSECTOR_KEY_MPLS))) {NL_SET_ERR_MSG_MOD (extack,"Unsupported key" );netdev_warn (priv->netdev,"Unsupported key used: 0x%x\n" , dissector->used_keys);
@@ -2147,7 +2162,8 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,if (err)return err; -if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_BASIC )) { +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_BASIC ) && + !skip_key_basic (filter_dev, f)) {struct flow_match_basic match;flow_rule_match_basic (rule, &match);
Signature · 1 line
2.25.4
PATCH 9/10 net/mlx5e: Add support for hw decapsulation of MPLS over UDP
In reply to Saeed MahameedFrom: Eli Cohen <[email protected]>
MPLS over UDP is supported in hardware by using a packet reformat object with reformat type equal L3_TUNNEL_TO_L2 which both decapsulates the outer L3, L4 and MPLS headers, and allows for setting the L2 headers of the resulting decapsulated packet. For the hardware to operate correctly, the configuration of the firmware must have FLEX_PARSER_PROFILE_ENABLE = 1.
Example tc rule:
tc filter add dev bareudp0 protocol all prio 1 root flower enc_dst_port \
6635 enc_src_ip 8.8.8.23 action mpls pop protocol ip pipe \
action pedit ex munge eth dst set 00:11:22:33:44:21 pipe action \
mirred egress redirect dev enp59s0f0_0We use pedit to set the correct destination MAC.
For MPLS over UDP decapsulation to take place, the driver logic requires the following:
1. flower filter added on bareudp device.
2. action mpls pop
3. zero or more pedit munge actions
4. one redirect action
Current implementation supports only IPv4 and no VLAN.
tc filter show output looks like this:
filter protocol all pref 1 flower chain 0 filter protocol all pref 1 flower chain 0 handle 0x1
enc_src_ip 8.8.8.24
enc_dst_port 6635
in_hw in_hw_count 1
action order 1: mpls pop protocol ip pipe
index 2 ref 1 bind 1
action order 2: pedit action pipe keys 2
index 1 ref 1 bind 1
key #0 at eth+0: val 00112233 mask 00000000 key #1 at eth+4: val 44210000 mask 0000ffff
action order 3: mirred (Egress Redirect to device enp59s0f0_0) stolen index 2 ref 1 bind 1
--- .../net/ethernet/mellanox/mlx5/core/en_rep.h | 16 ++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 217 +++++++++++++++++- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 3 + .../net/ethernet/mellanox/mlx5/core/eswitch.h | 3 + .../mellanox/mlx5/core/eswitch_offloads.c | 4 + 5 files changed, 238 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +16 -0
@@ -158,6 +158,22 @@ struct mlx5e_neigh_hash_entry {enum {/* set when the encap entry is successfully offloaded into HW */ MLX5_ENCAP_ENTRY_VALID =BIT (0 ), +MLX5_REFORMAT_DECAP =BIT (1 ), +}; + +struct mlx5e_decap_key { +struct ethhdr key; +}; + +struct mlx5e_decap_entry { +struct mlx5e_decap_key key; +struct list_head flows; +struct hlist_node hlist; +refcount_t refcnt; +struct completion res_ready; +int compl_result; +struct mlx5_pkt_reformat *pkt_reformat; +struct rcu_head rcu; };struct mlx5e_encap_entry {
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +212 -5
344 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +3 -0
@@ -2262,6 +2262,8 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)hash_init (esw->offloads.encap_tbl);mutex_init (&esw->offloads.mod_hdr.lock);hash_init (esw->offloads.mod_hdr.hlist); +mutex_init (&esw->offloads.decap_tbl_lock); +hash_init (esw->offloads.decap_tbl);atomic64_set (&esw->offloads.num_flows,0 );mutex_init (&esw->state_lock);mutex_init (&esw->mode_lock);
@@ -2303,6 +2305,7 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)mutex_destroy (&esw->state_lock);mutex_destroy (&esw->offloads.mod_hdr.lock);mutex_destroy (&esw->offloads.encap_tbl_lock); +mutex_destroy (&esw->offloads.decap_tbl_lock);kfree (esw->vports);kfree (esw); }
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +3 -0
@@ -209,6 +209,8 @@ struct mlx5_esw_offload {struct mutex peer_mutex;struct mutex encap_tbl_lock;/* protects encap_tbl */ DECLARE_HASHTABLE (encap_tbl,8 ); +struct mutex decap_tbl_lock;/* protects decap_tbl */ +DECLARE_HASHTABLE (decap_tbl,8 );struct mod_hdr_tbl mod_hdr;DECLARE_HASHTABLE (termtbl_tbl,8 );struct mutex termtbl_mutex;/* protects termtbl hash */
@@ -432,6 +434,7 @@ struct mlx5_esw_flow_attr {struct mlx5_flow_table *fdb;struct mlx5_flow_table *dest_ft;struct mlx5_ct_attr ct_attr; +struct mlx5_pkt_reformat *decap_pkt_reformat;struct mlx5e_tc_flow_parse_attr *parse_attr; };
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +4 -0
@@ -366,6 +366,10 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, } } } + +if (attr->decap_pkt_reformat) + flow_act.pkt_reformat = attr->decap_pkt_reformat; +if (flow_act.action &MLX5_FLOW_CONTEXT_ACTION_COUNT ) { dest[i].type =MLX5_FLOW_DESTINATION_TYPE_COUNTER ; dest[i].counter_id =mlx5_fc_id (attr->counter);
Signature · 1 line
2.25.4
PATCH 10/10 net/mlx5e: Support pedit on mpls over UDP decap
In reply to Saeed MahameedFrom: Eli Cohen <[email protected]>
Allow to modify ethernet headers while decapsulating mpls over UDP packets. This is implemented using the same reformat object used for decapsulation.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 65 +++++++++++++++---- 1 file changed, 53 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +53 -12
@@ -2900,10 +2900,12 @@ void dealloc_mod_hdr_actions(struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts)static const struct pedit_headers zero_masks = {}; -static int parse_tc_pedit_action (struct mlx5e_priv *priv, -const struct flow_action_entry *act,int namespace, -struct pedit_headers_action *hdrs, -struct netlink_ext_ack *extack) +static int +parse_pedit_to_modify_hdr (struct mlx5e_priv *priv, +const struct flow_action_entry *act,int namespace, +struct mlx5e_tc_flow_parse_attr *parse_attr, +struct pedit_headers_action *hdrs, +struct netlink_ext_ack *extack) {u8 cmd = (act->id ==FLOW_ACTION_MANGLE ) ?0 :1 ;int err = -EOPNOTSUPP ;
@@ -2939,6 +2941,46 @@ static int parse_tc_pedit_action(struct mlx5e_priv *priv,return err; } +static int +parse_pedit_to_reformat (struct mlx5e_priv *priv, +const struct flow_action_entry *act, +struct mlx5e_tc_flow_parse_attr *parse_attr, +struct netlink_ext_ack *extack) +{ +u32 mask, val, offset; +u32 *p; + +if (act->id !=FLOW_ACTION_MANGLE ) +return -EOPNOTSUPP ; + +if (act->mangle.htype !=FLOW_ACT_MANGLE_HDR_TYPE_ETH ) { +NL_SET_ERR_MSG_MOD (extack,"Only Ethernet modification is supported" ); +return -EOPNOTSUPP ; + } + + mask = ~act->mangle.mask; + val = act->mangle.val; + offset = act->mangle.offset; + p = (u32 *)&parse_attr->eth; + *(p + (offset >>2 )) |= (val & mask); + +return 0 ; +} + +static int parse_tc_pedit_action (struct mlx5e_priv *priv, +const struct flow_action_entry *act,int namespace, +struct mlx5e_tc_flow_parse_attr *parse_attr, +struct pedit_headers_action *hdrs, +struct mlx5e_tc_flow *flow, +struct netlink_ext_ack *extack) +{ +if (flow &&flow_flag_test (flow,L3_TO_L2_DECAP )) +return parse_pedit_to_reformat (priv, act, parse_attr, extack); + +return parse_pedit_to_modify_hdr (priv, act, namespace, + parse_attr, hdrs, extack); +} + static int alloc_tc_pedit_action(struct mlx5e_priv *priv, int namespace, struct mlx5e_tc_flow_parse_attr *parse_attr, struct pedit_headers_action *hdrs,
@@ -3197,7 +3239,7 @@ static int add_vlan_rewrite_action(struct mlx5e_priv *priv, int namespace,return -EOPNOTSUPP ; } - err =parse_tc_pedit_action (priv, &pedit_act, namespace, hdrs,NULL ); + err =parse_tc_pedit_action (priv, &pedit_act, namespace, parse_attr, hdrs,NULL , extack); *action |=MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ;return err;
@@ -3263,7 +3305,7 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,case FLOW_ACTION_MANGLE :case FLOW_ACTION_ADD : err =parse_tc_pedit_action (priv, act,MLX5_FLOW_NAMESPACE_KERNEL , - hdrs, extack); + parse_attr, hdrs,NULL , extack);if (err)return err;
@@ -3932,16 +3974,15 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,break ;case FLOW_ACTION_MANGLE :case FLOW_ACTION_ADD : -if (flow_flag_test (flow,L3_TO_L2_DECAP )) -return -EOPNOTSUPP ; - err =parse_tc_pedit_action (priv, act,MLX5_FLOW_NAMESPACE_FDB , - hdrs, extack); + parse_attr, hdrs, flow, extack);if (err)return err; - action |=MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ; - attr->split_count = attr->out_count; +if (!flow_flag_test (flow,L3_TO_L2_DECAP )) { + action |=MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ; + attr->split_count = attr->out_count; + }break ;case FLOW_ACTION_CSUM : if (csum_offload_supported(priv, action,
Signature · 1 line
2.25.4
Quoted 7 lines · Saeed Mahameed
Hi Dave/Jakub
This series adds misc updates to mlx5 driver.
For more information please see tag log below.Please pull and let me know if there is any problem.
I forgot to mention that there is a slight touch out side mlx5 in this series to include/net/bareudp.h that adds: netif_is_bareudp(netdev) so the net device can be identified as a bareudp one. it is pretty straight forward.
[...]
Quoted 42 lines
----------------------------------------------------------------
mlx5-updates-2020-05-22This series includes two updates and one cleanup patch
1) Tang Bim, clean-up with
IS_ERR()usage2) Vlad introduces a new mlx5 kconfig flag for TC support
This is required due to the high volume of current and upcoming development in the eswitch and representors areas where some of
the
feature are TC based such as the downstream patches of MPLSoUDP
and
the following representor bonding support for VF live migration
and
uplink representor dynamic loading.
For this Vlad kept TC specific code intc.candrep/tc.cand organized non TC code in representors specific files.3) Eli Cohen adds support for MPLS over UPD encap and decap TC offloads.
----------------------------------------------------------------
Eli Cohen (5):
net: Addnetif_is_bareudp()API to identify bareudp devices net/mlx5e: Add support for hw encapsulation of MPLS over UDP net/mlx5e: Allow to match on mpls parameters net/mlx5e: Add support for hw decapsulation of MPLS over UDP net/mlx5e: Support pedit on mpls over UDP decapTang Bin (1):
net/mlx5e: UseIS_ERR()to check and simplify codeVlad Buslov (4):
net/mlx5e: Extract TC-specific code fromen_rep.ctorep/tc.cnet/mlx5e: Extract neigh-specific code fromen_rep.ctorep/neigh.c
net/mlx5e: Move TC-specific code fromen_main.ctoen_tc.cnet/mlx5e: Introduce kconfig var for TC support
[...]
David Miller
maintainerFrom: Saeed Mahameed <[email protected]>
Date: Fri, 22 May 2020 16:51:38 -0700
Quoted 4 lines
This series adds misc updates to mlx5 driver.
For more information please see tag log below.Please pull and let me know if there is any problem.
Pulled, thank you.