Mellanox, mlx5 updates 2019-03-20
Subsystems (9)
Hi Dave,
This series includes mlx5 updates.
For more information please see tag log below.
Please pull and let me know if there is any problem.
v1->v2:
Remove NFP specific vxlan/geneve port #defines based upon Jakub's feedback.
Thanks,
Saeed.
---
The following changes since commit 83b038db255d83a32c15fd003f9a921204b9215a:
Merge branch 'net-phy-Move-Omega-PHY-entry-to-Cygnus-PHY-driver' (2019-03-21 13:41:52 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2019-03-20
for you to fetch changes up to 4f22632dcd2db7969ad614c8d2ed03ac6be47889:
net/mlx5e: Replace TC VLAN pop and push actions with VLAN modify (2019-03-21 15:15:29 -0700)
----------------------------------------------------------------
mlx5-updates-2019-03-20
This series includes updates to mlx5 driver,
1) Compiler warnings cleanup from Saeed Mahameed
2) Parav Pandit simplifies sriov enable/disables
3) Roi Dayan, protection from invalid memory access in offload fdb table
4) Gustavo A. R. Silva, Removes a redundant assignment
5) Moshe Shemesh, Adds Geneve tunnel stateless offload support
6) Eli Britstein, Adds the Support for VLAN modify action and Replaces TC VLAN pop and push actions with VLAN modify
Note: This series includes two simple non-mlx5 patches,
1) Declare IANA_VXLAN_UDP_PORT definition in include/net/vxlan.h, and use it in some drivers.
2) Declare GENEVE_UDP_PORT definition in include/net/geneve.h, and use it in mlx5 and nfp drivers.
----------------------------------------------------------------
Eli Britstein (3):
net/mlx5e: Add VLAN ID rewrite fields
net/mlx5e: Support VLAN modify action
net/mlx5e: Replace TC VLAN pop and push actions with VLAN modify
Gustavo A. R. Silva (1):
net/mlx5e: Remove redundant assignment
Moshe Shemesh (4):
net: Move the definition of the default Geneve udp port to public header file net/mlx5e: Take SW parser code to a separate function
net/mlx5e: TX, Add geneve tunnel stateless offload support
net: Add IANA_VXLAN_UDP_PORT definition to vxlan header file
Parav Pandit (3):
net/mlx5: Simplify sriov enable/disable flow net/mlx5: Rename total_vfs to total_vports
net/mlx5: Simplify mlx5_sriov_is_enabled() by using pci core API
Roi Dayan (1):
net/mlx5: E-Switch, Protect from invalid memory access in offload fdb table
Saeed Mahameed (3):
net/mlx5: Fix compilation warning in eq.c net/mlx5e: Fix port buffer function documentation format net/mlx5e: Fix compilation warning in en_tc.c
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/en.h | 47 ++++++++++++++++ .../ethernet/mellanox/mlx5/core/en/port_buffer.c | 30 +++++----- .../mellanox/mlx5/core/en_accel/en_accel.h | 51 +++++++++++++++++ .../mellanox/mlx5/core/en_accel/ipsec_rxtx.c | 36 ++++-------- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 18 +++++- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 65 +++++++++++++++++++++- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 5 ++ drivers/net/ethernet/mellanox/mlx5/core/eq.c | 6 +- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 3 + .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 7 +-- .../net/ethernet/mellanox/mlx5/core/lib/port_tun.c | 6 +- .../net/ethernet/mellanox/mlx5/core/lib/vxlan.c | 5 +- .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 6 +- drivers/net/ethernet/mellanox/mlx5/core/sriov.c | 51 +++-------------- drivers/net/ethernet/netronome/nfp/flower/action.c | 4 +- drivers/net/ethernet/netronome/nfp/flower/main.h | 3 - .../net/ethernet/netronome/nfp/flower/offload.c | 4 +- drivers/net/geneve.c | 2 - include/linux/mlx5/mlx5_ifc.h | 1 + include/net/geneve.h | 2 + include/net/vxlan.h | 2 + 22 files changed, 244 insertions(+), 114 deletions(-)
PATCH v2 1/15 net/mlx5: Simplify sriov enable/disable flow
From: Parav Pandit <[email protected]>
Simplify sriov enable/disable flow for below two checks.
1. PCI core driver allows sriov configuration only on a PF. This is done in drivers/pci/pci-sysfs.c sriov_attrs_are_visible().
2. PCI core driver allow sriov enablement if the sriov is currently disabled for for a PF. This is done in drivers/pci/pci-sysfs.c sriov_numvfs_store().
Hence there is no need for mlx5 driver to duplicate such checks.
--- .../net/ethernet/mellanox/mlx5/core/sriov.c | 44 ++++--------------- 1 file changed, 8 insertions(+), 36 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/sriov.c +8 -36
@@ -151,33 +151,10 @@ static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev)mlx5_core_warn (dev,"timeout reclaiming VFs pages\n" ); } -static int mlx5_pci_enable_sriov (struct pci_dev *pdev,int num_vfs) -{ -struct mlx5_core_dev *dev =pci_get_drvdata (pdev); -int err =0 ; - -if (pci_num_vf (pdev)) { -mlx5_core_warn (dev,"Unable to enable pci sriov, already enabled\n" ); -return -EBUSY ; - } - - err =pci_enable_sriov (pdev, num_vfs); -if (err) -mlx5_core_warn (dev,"pci_enable_sriov failed : %d\n" , err); - -return err; -} - -static void mlx5_pci_disable_sriov (struct pci_dev *pdev) -{ -pci_disable_sriov (pdev); -} -static int mlx5_sriov_enable (struct pci_dev *pdev,int num_vfs) {struct mlx5_core_dev *dev =pci_get_drvdata (pdev); -struct mlx5_core_sriov *sriov = &dev->priv.sriov; -int err =0 ; +int err; err =mlx5_device_enable_sriov (dev, num_vfs);if (err) {
@@ -185,42 +162,37 @@ static int mlx5_sriov_enable(struct pci_dev *pdev, int num_vfs)return err; } - err =mlx5_pci_enable_sriov (pdev, num_vfs); + err =pci_enable_sriov (pdev, num_vfs);if (err) { -mlx5_core_warn (dev,"mlx5_pci_enable_sriov failed : %d\n" , err); +mlx5_core_warn (dev,"pci_enable_sriov failed : %d\n" , err);mlx5_device_disable_sriov (dev); -return err; } - - sriov->num_vfs = num_vfs; - -return 0 ; +return err; }static void mlx5_sriov_disable (struct pci_dev *pdev) {struct mlx5_core_dev *dev =pci_get_drvdata (pdev); -struct mlx5_core_sriov *sriov = &dev->priv.sriov; -mlx5_pci_disable_sriov (pdev); +pci_disable_sriov (pdev);mlx5_device_disable_sriov (dev); - sriov->num_vfs =0 ; }int mlx5_core_sriov_configure (struct pci_dev *pdev,int num_vfs) {struct mlx5_core_dev *dev =pci_get_drvdata (pdev); +struct mlx5_core_sriov *sriov = &dev->priv.sriov;int err =0 ;mlx5_core_dbg (dev,"requested num_vfs %d\n" , num_vfs); -if (!mlx5_core_is_pf (dev)) -return -EPERM ;if (num_vfs) err =mlx5_sriov_enable (pdev, num_vfs);else mlx5_sriov_disable (pdev); +if (!err) + sriov->num_vfs = num_vfs;return err ? err : num_vfs; }
Signature · 1 line
2.20.1
PATCH v2 2/15 net/mlx5: Rename total_vfs to total_vports
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Macro MLX5_TOTAL_VPORTS() returns total number of vports. Therefore, rename variable total_vfs to total_vports to improve code readability.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -2
@@ -1287,13 +1287,13 @@ void esw_offloads_cleanup_reps(struct mlx5_eswitch *esw)int esw_offloads_init_reps (struct mlx5_eswitch *esw) { -int total_vfs =MLX5_TOTAL_VPORTS (esw->dev); +int total_vports =MLX5_TOTAL_VPORTS (esw->dev);struct mlx5_core_dev *dev = esw->dev;struct mlx5_eswitch_rep *rep;u8 hw_id[ETH_ALEN ], rep_type;int vport; - esw->offloads.vport_reps =kcalloc (total_vfs, + esw->offloads.vport_reps =kcalloc (total_vports,sizeof (struct mlx5_eswitch_rep ),GFP_KERNEL );if (!esw->offloads.vport_reps)
Signature · 1 line
2.20.1
PATCH v2 3/15 net/mlx5: Simplify mlx5_sriov_is_enabled() by using pci core API
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
It is desired to get rid of num_vfs stored inside mlx5_core_sriov to safely support vports more than vfs.
To reduce dependency on mlx5_core_sriov num_vfs, start using pci_num_vf() from pci core.
--- drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 6 +++++- drivers/net/ethernet/mellanox/mlx5/core/sriov.c | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +5 -1
@@ -111,7 +111,6 @@ void mlx5_sriov_cleanup(struct mlx5_core_dev *dev);int mlx5_sriov_attach (struct mlx5_core_dev *dev);void mlx5_sriov_detach (struct mlx5_core_dev *dev);int mlx5_core_sriov_configure (struct pci_dev *dev,int num_vfs); -bool mlx5_sriov_is_enabled (struct mlx5_core_dev *dev);int mlx5_core_enable_hca (struct mlx5_core_dev *dev,u16 func_id);int mlx5_core_disable_hca (struct mlx5_core_dev *dev,u16 func_id); int mlx5_create_scheduling_element_cmd(struct mlx5_core_dev *dev, u8 hierarchy,
@@ -176,6 +175,11 @@ int mlx5_firmware_flash(struct mlx5_core_dev *dev, const struct firmware *fw);void mlx5e_init (void );void mlx5e_cleanup (void ); +static inline bool mlx5_sriov_is_enabled (struct mlx5_core_dev *dev) +{ +return pci_num_vf (dev->pdev) ? true : false; +} +static inline int mlx5_lag_is_lacp_owner (struct mlx5_core_dev *dev) {/* LACP owner conditions:
drivers/net/ethernet/mellanox/mlx5/core/sriov.c +0 -7
@@ -36,13 +36,6 @@#include "mlx5_core.h" #include "eswitch.h" -bool mlx5_sriov_is_enabled (struct mlx5_core_dev *dev) -{ -struct mlx5_core_sriov *sriov = &dev->priv.sriov; - -return !!sriov->num_vfs; -} -static int sriov_restore_guids (struct mlx5_core_dev *dev,int vf) {struct mlx5_core_sriov *sriov = &dev->priv.sriov;
Signature · 1 line
2.20.1
PATCH v2 4/15 net/mlx5: Fix compilation warning in eq.c
In reply to Saeed Mahameedmlx5_eq_table_get_rmap is being used only when CONFIG_RFS_ACCEL is enabled, this patch fixes the below warning when CONFIG_RFS_ACCEL is disabled.
drivers/.../mlx5/core/eq.c:903:18: [-Werror=missing-prototypes]
error: no previous prototype for ‘mlx5_eq_table_get_rmap’
--- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eq.c +2 -4
@@ -900,14 +900,12 @@ mlx5_comp_irq_get_affinity_mask(struct mlx5_core_dev *dev, int vector) }EXPORT_SYMBOL (mlx5_comp_irq_get_affinity_mask); +#ifdef CONFIG_RFS_ACCEL struct cpu_rmap *mlx5_eq_table_get_rmap (struct mlx5_core_dev *dev) { -#ifdef CONFIG_RFS_ACCEL return dev->priv.eq_table->rmap; -#else -return NULL ; -#endif } +#endif struct mlx5_eq_comp *mlx5_eqn2comp_eq (struct mlx5_core_dev *dev,int eqn) {
Signature · 1 line
2.20.1
PATCH v2 5/15 net/mlx5e: Fix port buffer function documentation format
In reply to Saeed MahameedThis patch fixes compiler warnings:
In drivers/.../mlx5/core/en/port_buffer.c:190:
warning: Function parameter or member 'pfc_en' not described...
...
warning: Function parameter or member 'change' not described...
--- .../mellanox/mlx5/core/en/port_buffer.c | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c +15 -15
@@ -165,23 +165,23 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer, }/** -* update_buffer_lossy() -* mtu: device's MTU -* pfc_en: <input> current pfc configuration -* buffer: <input> current prio to buffer mapping -* xoff: <input> xoff value -* port_buffer: <output> port receive buffer configuration -* change: <output> +* update_buffer_lossy - Update buffer configuration based on pfc +* @mtu: device's MTU +* @pfc_en: <input> current pfc configuration +* @buffer: <input> current prio to buffer mapping +* @xoff: <input> xoff value +* @port_buffer: <output> port receive buffer configuration +* @change: <output> * -* Update buffer configuration based on pfc configuraiton and priority -* to buffer mapping. -* Buffer's lossy bit is changed to: -* lossless if there is at least one PFC enabled priority mapped to this buffer -* lossy if all priorities mapped to this buffer are PFC disabled +* Update buffer configuration based on pfc configuraiton and +* priority to buffer mapping. +* Buffer's lossy bit is changed to: +* lossless if there is at least one PFC enabled priority +* mapped to this buffer lossy if all priorities mapped to +* this buffer are PFC disabled * -* Return: -* Return 0 if no error. -* Set change to true if buffer configuration is modified. +* @return: 0 if no error, +* sets change to true if buffer configuration was modified. */ static int update_buffer_lossy(unsigned int mtu, u8 pfc_en, u8 *buffer, u32 xoff,
Signature · 1 line
2.20.1
PATCH v2 6/15 net/mlx5e: Fix compilation warning in en_tc.c
In reply to Saeed MahameedAmazingly a mlx5e_tc function is being called from the eswitch layer, which is by itself very terrible! The function was declared locally in eswitch_offloads.c so it could be used there, which caused the following compilation warning, fix that.
drivers/.../mlx5/core/en_tc.c:3242:6: [-Werror=missing-prototypes]
error: no previous prototype for ‘mlx5e_tc_clean_fdb_peer_flows’
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 3 +++ drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +3 -0
@@ -431,6 +431,9 @@ static inline int mlx5_eswitch_index_to_vport_num(struct mlx5_eswitch *esw, return index; } +/* TODO: This mlx5e_tc function shouldn't be called by eswitch */ +void mlx5e_tc_clean_fdb_peer_flows (struct mlx5_eswitch *esw); +#else /* CONFIG_MLX5_ESWITCH */ /* eswitch API stubs */ static inline int mlx5_eswitch_init (struct mlx5_core_dev *dev) {return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +0 -2
@@ -1523,8 +1523,6 @@ static int mlx5_esw_offloads_pair(struct mlx5_eswitch *esw,return 0 ; } -void mlx5e_tc_clean_fdb_peer_flows (struct mlx5_eswitch *esw); -static void mlx5_esw_offloads_unpair (struct mlx5_eswitch *esw) {mlx5e_tc_clean_fdb_peer_flows (esw);
Signature · 1 line
2.20.1
PATCH v2 7/15 net/mlx5e: Remove redundant assignment
In reply to Saeed MahameedFrom: "Gustavo A. R. Silva" <[email protected]>
Remove redundant assignment to tun_entropy->enabled.
Addesses-Coverity-ID: 1477328 ("Unused value")
--- drivers/net/ethernet/mellanox/mlx5/core/lib/port_tun.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/port_tun.c +2 -4
@@ -80,10 +80,8 @@ void mlx5_init_port_tun_entropy(struct mlx5_tun_entropy *tun_entropy,mlx5_query_port_tun_entropy (mdev, &entropy_flags); tun_entropy->num_enabling_entries =0 ; tun_entropy->num_disabling_entries =0 ; - tun_entropy->enabled = entropy_flags.calc_enabled; - tun_entropy->enabled = - (entropy_flags.calc_supported) ? - entropy_flags.calc_enabled : true; + tun_entropy->enabled = entropy_flags.calc_supported ? + entropy_flags.calc_enabled : true; } static int mlx5_set_entropy(struct mlx5_tun_entropy *tun_entropy,
Signature · 1 line
2.20.1
PATCH v2 8/15 net/mlx5: E-Switch, Protect from invalid memory access in offload fdb table
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
The esw offloads structures share a union with the legacy mode structs. Reset the offloads struct to zero in init to protect from null assumptions made by the legacy mode code.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -0
@@ -1609,6 +1609,7 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw, int nvports) {int err; +memset (&esw->fdb_table.offloads,0 ,sizeof (struct offloads_fdb ));mutex_init (&esw->fdb_table.offloads.fdb_prio_lock); err =esw_create_offloads_fdb_tables (esw, nvports);
Signature · 1 line
2.20.1
PATCH v2 9/15 net: Move the definition of the default Geneve udp port to public header file
In reply to Saeed MahameedFrom: Moshe Shemesh <[email protected]>
Move the definition of the default Geneve udp port from the geneve source to the header file, so we can re-use it from drivers. Modify existing drivers to use it.
--- drivers/net/ethernet/netronome/nfp/flower/action.c | 2 +- drivers/net/ethernet/netronome/nfp/flower/main.h | 1 - drivers/net/ethernet/netronome/nfp/flower/offload.c | 2 +- drivers/net/geneve.c | 2 -- include/net/geneve.h | 2 ++ 5 files changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/netronome/nfp/flower/action.c +1 -1
@@ -163,7 +163,7 @@ nfp_fl_get_tun_from_act_l4_port(struct nfp_app *app,switch (tun->key.tp_dst) {case htons (NFP_FL_VXLAN_PORT ):return NFP_FL_TUNNEL_VXLAN ; -case htons (NFP_FL_GENEVE_PORT ): +case htons (GENEVE_UDP_PORT ):if (priv->flower_ext_feats &NFP_FL_FEATS_GENEVE )return NFP_FL_TUNNEL_GENEVE ;/* FALLTHROUGH */
drivers/net/ethernet/netronome/nfp/flower/main.h +0 -1
@@ -35,7 +35,6 @@ struct nfp_app;#define NFP_FL_MASK_ID_LOCATION 1#define NFP_FL_VXLAN_PORT 4789 -#define NFP_FL_GENEVE_PORT 6081/* Extra features bitmap. */ #define NFP_FL_FEATS_GENEVE BIT(0)
drivers/net/ethernet/netronome/nfp/flower/offload.c +1 -1
@@ -203,7 +203,7 @@ nfp_flower_calculate_key_layers(struct nfp_app *app,if (enc_op.key)return -EOPNOTSUPP ;break ; -case htons (NFP_FL_GENEVE_PORT ): +case htons (GENEVE_UDP_PORT ):if (!(priv->flower_ext_feats &NFP_FL_FEATS_GENEVE ))return -EOPNOTSUPP ; *tun_type =NFP_FL_TUNNEL_GENEVE ;
drivers/net/geneve.c +0 -2
@@ -22,8 +22,6 @@#define GENEVE_NETDEV_VER "0.6" -#define GENEVE_UDP_PORT 6081 -#define GENEVE_N_VID (1u << 24)#define GENEVE_VID_MASK (GENEVE_N_VID - 1)
include/net/geneve.h +2 -0
@@ -4,6 +4,8 @@#include <net/udp_tunnel.h> +#define GENEVE_UDP_PORT 6081 +/* Geneve Header: * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |Ver| Opt Len |O|C| Rsvd. | Protocol Type |
Signature · 1 line
2.20.1
Re: [net-next V2 09/15] net: Move the definition of the default Geneve udp port to public header file
Quoted 6 lines · Saeed Mahameed
From: Moshe Shemesh <[email protected]>
Move the definition of the default Geneve udp port from the geneve source to the header file, so we can re-use it from drivers. Modify existing drivers to use it.
Quoted 6 lines
Signed-off-by Moshe Shemesh <[email protected]>Reviewed-by Or Gerlitz <[email protected]>Cc John Hurley <[email protected]>Cc Jakub Kicinski <[email protected]>Reviewed-by Tariq Toukan <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>
PATCH v2 10/15 net/mlx5e: Take SW parser code to a separate function
In reply to Saeed MahameedFrom: Moshe Shemesh <[email protected]>
Refactor mlx5e_ipsec_set_swp() code, split the part which sets the eseg software parser (SWP) offsets and flags, so it can be used in a downstream patch by other mlx5e functionality which needs to set eseg SWP.
The new function mlx5e_set_eseg_swp() is useful for setting swp for both outer and inner headers. It also handles the special ipsec case of xfrm mode transfer.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 41 +++++++++++++++++++ .../mellanox/mlx5/core/en_accel/ipsec_rxtx.c | 36 ++++++---------- 2 files changed, 53 insertions(+), 24 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +41 -0
@@ -884,6 +884,47 @@ static inline bool mlx5e_tunnel_inner_ft_supported(struct mlx5_core_dev *mdev) MLX5_CAP_FLOWTABLE_NIC_RX(mdev, ft_field_support.inner_ip_version)); } +struct mlx5e_swp_spec { +__be16 l3_proto; +u8 l4_proto; +u8 is_tun; +__be16 tun_l3_proto; +u8 tun_l4_proto; +}; + +static inline void +mlx5e_set_eseg_swp (struct sk_buff *skb,struct mlx5_wqe_eth_seg *eseg, +struct mlx5e_swp_spec *swp_spec) +{ +/* SWP offsets are in 2-bytes words */ + eseg->swp_outer_l3_offset =skb_network_offset (skb) /2 ; +if (swp_spec->l3_proto ==htons (ETH_P_IPV6 )) + eseg->swp_flags |=MLX5_ETH_WQE_SWP_OUTER_L3_IPV6 ; +if (swp_spec->l4_proto) { + eseg->swp_outer_l4_offset =skb_transport_offset (skb) /2 ; +if (swp_spec->l4_proto ==IPPROTO_UDP ) + eseg->swp_flags |=MLX5_ETH_WQE_SWP_OUTER_L4_UDP ; + } + +if (swp_spec->is_tun) { + eseg->swp_inner_l3_offset =skb_inner_network_offset (skb) /2 ; +if (swp_spec->tun_l3_proto ==htons (ETH_P_IPV6 )) + eseg->swp_flags |=MLX5_ETH_WQE_SWP_INNER_L3_IPV6 ; + }else {/* typically for ipsec when xfrm mode != XFRM_MODE_TUNNEL */ + eseg->swp_inner_l3_offset =skb_network_offset (skb) /2 ; +if (swp_spec->l3_proto ==htons (ETH_P_IPV6 )) + eseg->swp_flags |=MLX5_ETH_WQE_SWP_INNER_L3_IPV6 ; + } +switch (swp_spec->tun_l4_proto) { +case IPPROTO_UDP : + eseg->swp_flags |=MLX5_ETH_WQE_SWP_INNER_L4_UDP ; +/* fall through */ +case IPPROTO_TCP : + eseg->swp_inner_l4_offset =skb_inner_transport_offset (skb) /2 ; +break ; + } +} +static inline void mlx5e_sq_fetch_wqe (struct mlx5e_txqsq *sq,struct mlx5e_tx_wqe **wqe,u16 *pi)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c +12 -24
@@ -136,7 +136,7 @@ static void mlx5e_ipsec_set_swp(struct sk_buff *skb, struct mlx5_wqe_eth_seg *eseg, u8 mode, struct xfrm_offload *xo) { - u8 proto; + struct mlx5e_swp_spec swp_spec = {};/* Tunnel Mode: * SWP: OutL3 InL3 InL4
@@ -146,35 +146,23 @@ static void mlx5e_ipsec_set_swp(struct sk_buff *skb,* SWP: OutL3 InL4 * InL3 * Pkt: MAC IP ESP L4 -* -* Offsets are in 2-byte words, counting from start of frame */ - eseg->swp_outer_l3_offset =skb_network_offset (skb) /2 ; -if (skb->protocol ==htons (ETH_P_IPV6 )) - eseg->swp_flags |=MLX5_ETH_WQE_SWP_OUTER_L3_IPV6 ; - -if (mode ==XFRM_MODE_TUNNEL ) { - eseg->swp_inner_l3_offset =skb_inner_network_offset (skb) /2 ; + swp_spec.l3_proto = skb->protocol; + swp_spec.is_tun = mode ==XFRM_MODE_TUNNEL ; +if (swp_spec.is_tun) {if (xo->proto ==IPPROTO_IPV6 ) { - eseg->swp_flags |=MLX5_ETH_WQE_SWP_INNER_L3_IPV6 ; - proto =inner_ipv6_hdr (skb)->nexthdr; + swp_spec.tun_l3_proto =htons (ETH_P_IPV6 ); + swp_spec.tun_l4_proto =inner_ipv6_hdr (skb)->nexthdr; }else { - proto =inner_ip_hdr (skb)->protocol; + swp_spec.tun_l3_proto =htons (ETH_P_IP ); + swp_spec.tun_l4_proto =inner_ip_hdr (skb)->protocol; } }else { - eseg->swp_inner_l3_offset =skb_network_offset (skb) /2 ; -if (skb->protocol ==htons (ETH_P_IPV6 )) - eseg->swp_flags |=MLX5_ETH_WQE_SWP_INNER_L3_IPV6 ; - proto = xo->proto; - } -switch (proto) { -case IPPROTO_UDP : - eseg->swp_flags |=MLX5_ETH_WQE_SWP_INNER_L4_UDP ; -/* Fall through */ -case IPPROTO_TCP : - eseg->swp_inner_l4_offset =skb_inner_transport_offset (skb) /2 ; -break ; + swp_spec.tun_l3_proto = skb->protocol; + swp_spec.tun_l4_proto = xo->proto; } + +mlx5e_set_eseg_swp (skb, eseg, &swp_spec); } void mlx5e_ipsec_set_iv_esn(struct sk_buff *skb, struct xfrm_state *x,
Signature · 1 line
2.20.1
PATCH v2 11/15 net/mlx5e: TX, Add geneve tunnel stateless offload support
In reply to Saeed MahameedFrom: Moshe Shemesh <[email protected]>
Currently support only default geneve udp port (6081).
For the tx side, the HW is assisted by SW parsing, which sets the headers offset to offload tunneled LSO and csum. Note that for udp tunnels, we don't use special rx offloads, as rss on the outer headers is enough, we support checksum complete and GRO takes care of aggregation.
Geneve TSO BW and CPU load results (tested using iperf single tcp stream).
In this patch we add TSO support over Geneve, so the "before" result doesn't actually get to using the TSO HW offload even when turned on. Tested on ConnectX-5, Intel(R) Xeon(R) CPU E5-2660 v2 @2.20GHz.
__________________________________
| Before | After | |________________|_________________| | 12.6 Gbits/sec | 21.7 Gbits/sec | | 100% CPU load | 61.5% CPU load | |________________|_________________|
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 6 +++ .../mellanox/mlx5/core/en_accel/en_accel.h | 51 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_main.c | 18 +++++-- .../net/ethernet/mellanox/mlx5/core/en_tx.c | 5 ++ 4 files changed, 77 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +6 -0
@@ -884,6 +884,12 @@ static inline bool mlx5e_tunnel_inner_ft_supported(struct mlx5_core_dev *mdev) MLX5_CAP_FLOWTABLE_NIC_RX(mdev, ft_field_support.inner_ip_version)); } +static inline bool mlx5_tx_swp_supported (struct mlx5_core_dev *mdev) +{ +return MLX5_CAP_ETH (mdev, swp) && +MLX5_CAP_ETH (mdev, swp_csum) &&MLX5_CAP_ETH (mdev, swp_lso); +} +struct mlx5e_swp_spec {__be16 l3_proto;u8 l4_proto;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +51 -0
57 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +15 -3
@@ -34,6 +34,7 @@#include <net/pkt_cls.h> #include <linux/mlx5/fs.h> #include <net/vxlan.h> +#include <net/geneve.h> #include <linux/bpf.h> #include <linux/if_bridge.h> #include <net/page_pool.h>
@@ -43,6 +44,7 @@#include "en_rep.h" #include "en_accel/ipsec.h" #include "en_accel/ipsec_rxtx.h" +#include "en_accel/en_accel.h" #include "en_accel/tls.h" #include "accel/ipsec.h" #include "accel/tls.h"
@@ -2173,10 +2175,13 @@ static void mlx5e_build_sq_param(struct mlx5e_priv *priv, {void *sqc = param->sqc;void *wq =MLX5_ADDR_OF (sqc, sqc, wq); +bool allow_swp; + allow_swp =mlx5_geneve_tx_allowed (priv->mdev) || + !!MLX5_IPSEC_DEV (priv->mdev);mlx5e_build_sq_param_common (priv, param);MLX5_SET (wq, wq, log_wq_sz, params->log_sq_size); -MLX5_SET (sqc, sqc, allow_swp, !!MLX5_IPSEC_DEV (priv->mdev)); +MLX5_SET (sqc, sqc, allow_swp, allow_swp); } static void mlx5e_build_common_cq_param(struct mlx5e_priv *priv,
@@ -4103,6 +4108,12 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,/* Verify if UDP port is being offloaded by HW */ if (mlx5_vxlan_lookup_port (priv->mdev->vxlan, port))return features; + +#if IS_ENABLED (CONFIG_GENEVE ) +/* Support Geneve offload for default UDP port */ +if (port ==GENEVE_UDP_PORT &&mlx5_geneve_tx_allowed (priv->mdev)) +return features; +#endif } out:
@@ -4674,7 +4685,8 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) netdev->hw_features |=NETIF_F_HW_VLAN_CTAG_FILTER ; netdev->hw_features |=NETIF_F_HW_VLAN_STAG_TX ; -if (mlx5_vxlan_allowed (mdev->vxlan) ||MLX5_CAP_ETH (mdev, tunnel_stateless_gre)) { +if (mlx5_vxlan_allowed (mdev->vxlan) ||mlx5_geneve_tx_allowed (mdev) || +MLX5_CAP_ETH (mdev, tunnel_stateless_gre)) { netdev->hw_enc_features |=NETIF_F_IP_CSUM ; netdev->hw_enc_features |=NETIF_F_IPV6_CSUM ; netdev->hw_enc_features |=NETIF_F_TSO ;
@@ -4682,7 +4694,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) netdev->hw_enc_features |=NETIF_F_GSO_PARTIAL ; } -if (mlx5_vxlan_allowed (mdev->vxlan)) { +if (mlx5_vxlan_allowed (mdev->vxlan) ||mlx5_geneve_tx_allowed (mdev)) { netdev->hw_features |=NETIF_F_GSO_UDP_TUNNEL |NETIF_F_GSO_UDP_TUNNEL_CSUM ; netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL |
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +5 -0
@@ -32,6 +32,7 @@#include <linux/tcp.h> #include <linux/if_vlan.h> +#include <net/geneve.h> #include <net/dsfield.h> #include "en.h" #include "ipoib/ipoib.h"
@@ -391,6 +392,10 @@ netdev_tx_t mlx5e_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, eseg = &wqe->eth; dseg = wqe->data; +#if IS_ENABLED (CONFIG_GENEVE ) +if (skb->encapsulation) +mlx5e_tx_tunnel_accel (skb, eseg); +#endif mlx5e_txwqe_build_eseg_csum (sq, skb, eseg); eseg->mss = mss;
Signature · 1 line
2.20.1
PATCH v2 12/15 net: Add IANA_VXLAN_UDP_PORT definition to vxlan header file
In reply to Saeed MahameedFrom: Moshe Shemesh <[email protected]>
Added IANA_VXLAN_UDP_PORT (4789) definition to vxlan header file so it can be used by drivers instead of local definition.
Updated drivers which locally defined it as 4789 to use it.
--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c | 5 +++-- drivers/net/ethernet/netronome/nfp/flower/action.c | 2 +- drivers/net/ethernet/netronome/nfp/flower/main.h | 2 -- drivers/net/ethernet/netronome/nfp/flower/offload.c | 2 +- include/net/vxlan.h | 2 ++ 6 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +2 -2
@@ -826,12 +826,12 @@ static void hns3_set_l2l3l4_len(struct sk_buff *skb, u8 ol4_proto,*/ static bool hns3_tunnel_csum_bug (struct sk_buff *skb) { -#define IANA_VXLAN_PORT 4789union l4_hdr_info l4; l4.hdr =skb_transport_header (skb); -if (!(!skb->encapsulation && l4.udp->dest ==htons (IANA_VXLAN_PORT ))) +if (!(!skb->encapsulation && + l4.udp->dest ==htons (IANA_VXLAN_UDP_PORT )))return false;skb_checksum_help (skb);
drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c +3 -2
@@ -33,6 +33,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/mlx5/driver.h> +#include <net/vxlan.h> #include "mlx5_core.h" #include "vxlan.h"
@@ -204,8 +205,8 @@ struct mlx5_vxlan *mlx5_vxlan_create(struct mlx5_core_dev *mdev)spin_lock_init (&vxlan->lock);hash_init (vxlan->htable); -/* Hardware adds 4789 by default */ -mlx5_vxlan_add_port (vxlan,4789 ); +/* Hardware adds 4789 (IANA_VXLAN_UDP_PORT) by default */ +mlx5_vxlan_add_port (vxlan,IANA_VXLAN_UDP_PORT );return vxlan; }
drivers/net/ethernet/netronome/nfp/flower/action.c +1 -1
@@ -161,7 +161,7 @@ nfp_fl_get_tun_from_act_l4_port(struct nfp_app *app,struct nfp_flower_priv *priv = app->priv;switch (tun->key.tp_dst) { -case htons (NFP_FL_VXLAN_PORT ): +case htons (IANA_VXLAN_UDP_PORT ):return NFP_FL_TUNNEL_VXLAN ;case htons (GENEVE_UDP_PORT ):if (priv->flower_ext_feats &NFP_FL_FEATS_GENEVE )
drivers/net/ethernet/netronome/nfp/flower/main.h +0 -2
@@ -34,8 +34,6 @@ struct nfp_app;#define NFP_FL_MASK_REUSE_TIME_NS 40000#define NFP_FL_MASK_ID_LOCATION 1 -#define NFP_FL_VXLAN_PORT 4789 -/* Extra features bitmap. */ #define NFP_FL_FEATS_GENEVE BIT(0)#define NFP_FL_NBI_MTU_SETTING BIT(1)
drivers/net/ethernet/netronome/nfp/flower/offload.c +1 -1
@@ -195,7 +195,7 @@ nfp_flower_calculate_key_layers(struct nfp_app *app,flow_rule_match_enc_opts (rule, &enc_op);switch (enc_ports.key->dst) { -case htons (NFP_FL_VXLAN_PORT ): +case htons (IANA_VXLAN_UDP_PORT ): *tun_type =NFP_FL_TUNNEL_VXLAN ; key_layer |=NFP_FLOWER_LAYER_VXLAN ; key_size +=sizeof (struct nfp_flower_ipv4_udp_tun );
include/net/vxlan.h +2 -0
@@ -8,6 +8,8 @@#include <net/rtnetlink.h> #include <net/switchdev.h> +#define IANA_VXLAN_UDP_PORT 4789 +/* VXLAN protocol (RFC 7348) header: * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |R|R|R|R|I|R|R|R| Reserved |
Signature · 1 line
2.20.1
Re: [net-next V2 12/15] net: Add IANA_VXLAN_UDP_PORT definition to vxlan header file
Quoted 6 lines · Saeed Mahameed
From: Moshe Shemesh <[email protected]>
Added
IANA_VXLAN_UDP_PORT(4789) definition to vxlan header file so it can be used by drivers instead of local definition.
Updated drivers which locally defined it as 4789 to use it.
Quoted 8 lines
Signed-off-by Moshe Shemesh <[email protected]>Reviewed-by Or Gerlitz <[email protected]>Cc John Hurley <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Yunsheng Lin <[email protected]>Cc Peng Li <[email protected]>Reviewed-by Tariq Toukan <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>
Thanks!
Re: [net-next V2 12/15] net: Add IANA_VXLAN_UDP_PORT definition to vxlan header file
Quoted 17 lines · Jakub Kicinski
Quoted 7 lines · Saeed Mahameed
From: Moshe Shemesh <[email protected]>
Added
IANA_VXLAN_UDP_PORT(4789) definition to vxlan header file so it
can be used by drivers instead of local definition. Updated drivers which locally defined it as 4789 to use it.Quoted 8 lines
Signed-off-by Moshe Shemesh <[email protected]>Reviewed-by Or Gerlitz <[email protected]>Cc John Hurley <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Yunsheng Lin <[email protected]>Cc Peng Li <[email protected]>Reviewed-by Tariq Toukan <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>
Quoted 3 lines
Acked-by Jakub Kicinski <[email protected]>Thanks!
Thanks Jakub, By the way these Acks are not going to be applied to the commit messages since Dave is going to be pulling from a tag from my tree.
I don't think there is a way to deal with this..
PATCH v2 13/15 net/mlx5e: Add VLAN ID rewrite fields
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
Add VLAN ID rewrite fields as a pre-step to support this rewrite.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 ++ include/linux/mlx5/mlx5_ifc.h | 1 + 2 files changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 -0
@@ -1827,6 +1827,7 @@ static int parse_cls_flower(struct mlx5e_priv *priv,struct pedit_headers {struct ethhdr eth; +struct vlan_hdr vlan;struct iphdr ip4;struct ipv6hdr ip6;struct tcphdr tcp;
@@ -1884,6 +1885,7 @@ static struct mlx5_fields fields[] = {OFFLOAD (SMAC_47_16 ,4 , eth.h_source[0 ],0 ),OFFLOAD (SMAC_15_0 ,2 , eth.h_source[4 ],0 ),OFFLOAD (ETHERTYPE ,2 , eth.h_proto,0 ), +OFFLOAD (FIRST_VID ,2 , vlan.h_vlan_TCI,0 ),OFFLOAD (IP_TTL ,1 , ip4.ttl,0 ), OFFLOAD(SIPV4, 4, ip4.saddr, 0),
include/linux/mlx5/mlx5_ifc.h +1 -0
@@ -5110,6 +5110,7 @@ enum {MLX5_ACTION_IN_FIELD_OUT_DIPV6_31_0 =0x14 ,MLX5_ACTION_IN_FIELD_OUT_SIPV4 =0x15 ,MLX5_ACTION_IN_FIELD_OUT_DIPV4 =0x16 , +MLX5_ACTION_IN_FIELD_OUT_FIRST_VID =0x17 , MLX5_ACTION_IN_FIELD_OUT_IPV6_HOPLIMIT = 0x47, };
Signature · 1 line
2.20.1
PATCH v2 14/15 net/mlx5e: Support VLAN modify action
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
Support VLAN modify action by emulating a rewrite action for the VLAN fields. Currently, the only supported field is the vid. The prio in the action must be set to 0 to indicate no change.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 51 ++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +49 -2
@@ -2249,6 +2249,35 @@ static bool same_hw_devs(struct mlx5e_priv *priv, struct mlx5e_priv *peer_priv)return (fsystem_guid == psystem_guid); } +static int add_vlan_rewrite_action (struct mlx5e_priv *priv,int namespace, +const struct flow_action_entry *act, +struct mlx5e_tc_flow_parse_attr *parse_attr, +struct pedit_headers_action *hdrs, +u32 *action,struct netlink_ext_ack *extack) +{ +u16 mask16 =VLAN_VID_MASK ; +u16 val16 = act->vlan.vid &VLAN_VID_MASK ; +const struct flow_action_entry pedit_act = { + .id =FLOW_ACTION_MANGLE , + .mangle.htype =FLOW_ACT_MANGLE_HDR_TYPE_ETH , + .mangle.offset = offsetof(struct vlan_ethhdr , h_vlan_TCI), + .mangle.mask = ~(u32 )be16_to_cpu (*(__be16 *)&mask16), + .mangle.val = (u32 )be16_to_cpu (*(__be16 *)&val16), + }; +int err; + +if (act->vlan.prio) { +NL_SET_ERR_MSG_MOD (extack,"Setting VLAN prio is not supported" ); +return -EOPNOTSUPP ; + } + + err =parse_tc_pedit_action (priv, &pedit_act, namespace, parse_attr, + hdrs,NULL ); + *action |=MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ; + +return err; +} + static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct flow_action *flow_action, struct mlx5e_tc_flow_parse_attr *parse_attr,
@@ -2284,6 +2313,15 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, action |=MLX5_FLOW_CONTEXT_ACTION_MOD_HDR |MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ;break ; +case FLOW_ACTION_VLAN_MANGLE : + err =add_vlan_rewrite_action (priv, +MLX5_FLOW_NAMESPACE_KERNEL , + act, parse_attr, hdrs, + &action, extack); +if (err) +return err; + +break ;case FLOW_ACTION_CSUM : if (csum_offload_supported(priv, action, act->csum_flags,
@@ -2492,8 +2530,7 @@ static int parse_tc_vlan_action(struct mlx5e_priv *priv, }break ;default : -/* action is FLOW_ACT_VLAN_MANGLE */ -return -EOPNOTSUPP ; +return -EINVAL ; } attr->total_vlan = vlan_idx +1 ;
@@ -2631,6 +2668,16 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,if (err)return err; + attr->split_count = attr->out_count; +break ; +case FLOW_ACTION_VLAN_MANGLE : + err =add_vlan_rewrite_action (priv, +MLX5_FLOW_NAMESPACE_FDB , + act, parse_attr, hdrs, + &action, extack); +if (err) +return err; + attr->split_count = attr->out_count;break ;case FLOW_ACTION_TUNNEL_DECAP :
Signature · 1 line
2.20.1
PATCH v2 15/15 net/mlx5e: Replace TC VLAN pop and push actions with VLAN modify
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
Changing the VLAN header may be implemented by pop the existing header and push a new one. Translate those operations as VLAN modify. Applicable for use cases such as OVS where the controller translates a vlan modify meta (OF) rule to DP pop+push actions rule.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +11 -1
@@ -2664,7 +2664,17 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,break ;case FLOW_ACTION_VLAN_PUSH :case FLOW_ACTION_VLAN_POP : - err =parse_tc_vlan_action (priv, act, attr, &action); +if (act->id ==FLOW_ACTION_VLAN_PUSH && + (action &MLX5_FLOW_CONTEXT_ACTION_VLAN_POP )) { +/* Replace vlan pop+push with vlan modify */ + action &= ~MLX5_FLOW_CONTEXT_ACTION_VLAN_POP ; + err =add_vlan_rewrite_action (priv, +MLX5_FLOW_NAMESPACE_FDB , + act, parse_attr, hdrs, + &action, extack); + }else { + err =parse_tc_vlan_action (priv, act, attr, &action); + }if (err)return err;
Signature · 1 line
2.20.1
Quoted 8 lines · Saeed Mahameed
Hi Dave,
This series includes mlx5 updates.
For more information please see tag log below.Please pull and let me know if there is any problem.
Hi Dave, I would like to re-spin and send V3 to move one patch out of this series into net branch
#8) net/mlx5: E-Switch, Protect from invalid memory access in offload fdb table
I take this opportunity to add Jakub's Acks.
Thanks,
Saeed.