Mellanox, mlx5 updates 2018-12-19
Hi Dave,
This series includes some misc updates and vlan encap tunnel support. For more information please see tag log below.
Please pull and let me know if there is any problem.
v1->v2:
- Apply the check on not being a rep after and not before adjusting out_dev in patch #5.
- improve commit message of patch #5.
- Add two patches (#12,13) to the series from Aviv to fix VF LAG minor issues.
=======================
Conflict note: when merged with net branch this series adds 2 trivial conflicts in mlx5.
1)
+<<<<<<< HEAD
+#define MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE \
+ max(0x7, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)
++=======
+ #define MLX5E_REP_PARAMS_LOG_SQ_SIZE \
+ max(0x6, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)
+ #define MLX5E_REP_PARAMS_DEF_NUM_CHANNELS 1
++>>>>>>> dave/master
Resolution:
define MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE \
max(0x7, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)#define MLX5E_REP_PARAMS_DEF_NUM_CHANNELS 1
=======================
Thanks,
Saeed.
---
The following changes since commit a9cd3439e3c6d777a05c63b4d06c3500d1d4074e:
neighbor: Use nda_policy for validating attributes in adds and dump requests (2018-12-19 23:55:36 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2018-12-19
for you to fetch changes up to a64917446eafc7212e962561622d697fce04e9a6:
net/mlx5: Fix LAG requirement when CONFIG_MLX5_ESWITCH is off (2018-12-20 05:06:03 -0800)
----------------------------------------------------------------
mlx5-updates-2018-12-19
This series adds some misc updates and the support for tunnels over VLAN tc offloads.
Quoted 1 line
From Miroslav Lichvar, patches #1,2
1) Update timecounter at least twice per counter overflow
2) Extend PTP gettime function to read system clock
Quoted 1 line
From Gavi Teitz, patch #3
3) Increase VF representors' SQ size to 128
Quoted 1 line
From Eli Britstein and Or Gerlitz, patches #4-10
4) Adds the capability to support tunnels over VLAN device.
Patch 4 avoids crash for TC flow with egress upper devices
Patch 5 refactors tunnel routing devs into a helper function
Patch 6 avoids crash for TC encap flows with vlan on underlay
Patches 7-8 refactor encap tunnel header preparing code.
Patch 9 adds support for building VLAN tagged ETH header.
Patch 10 adds support for tunnel routing to VLAN device.
Quoted 1 line
From Aviv, patches 11,12 to fix earlier VF lag series
5) Fix query_nic_sys_image_guid() error during init
6) Fix LAG requirement when CONFIG_MLX5_ESWITCH is off
----------------------------------------------------------------
Aviv Heller (2):
net/mlx5: Fix query_nic_sys_image_guid() error during init net/mlx5: Fix LAG requirement when CONFIG_MLX5_ESWITCH is off
Eli Britstein (7):
net/mlx5e: Fail attempt to offload e-switch TC flows with egress upper devices net/mlx5e: Tunnel routing output devs helper function
net/mlx5e: Fail attempt to offload e-switch TC encap flows with vlan on underlay net/mlx5e: Tunnel encap ETH header helper function
net/mlx5e: Re-order route and encap header memory allocation net/mlx5e: Support VLAN encap ETH header generation
net/mlx5e: Support tunnel encap over tagged Ethernet
Gavi Teitz (1):
net/mlx5e: Increase VF representors' SQ size to 128
Miroslav Lichvar (2):
mlx5: update timecounter at least twice per counter overflow
mlx5: extend PTP gettime function to read system clock
Or Gerlitz (1):
net/mlx5e: Allow vlans on e-switch uplink reps
.../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 186 ++++++++++++--------- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 20 ++- drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 3 + drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 + drivers/net/ethernet/mellanox/mlx5/core/lag.c | 13 +- .../net/ethernet/mellanox/mlx5/core/lib/clock.c | 24 +-- drivers/net/ethernet/mellanox/mlx5/core/main.c | 11 +- .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 4 +- drivers/net/ethernet/mellanox/mlx5/core/vport.c | 16 +- 9 files changed, 177 insertions(+), 103 deletions(-)
PATCH v2 1/13 mlx5: update timecounter at least twice per counter overflow
From: Miroslav Lichvar <[email protected]>
The timecounter needs to be updated at least once in half of the cyclecounter interval to prevent timecounter_cyc2time() interpreting a new timestamp as an old value and causing a backward jump.
This would be an issue if the timecounter multiplier was so small that the update interval would not be limited by the 64-bit overflow in multiplication.
Shorten the calculated interval to make sure the timecounter is updated in time even when the system clock is slowed down by up to 10%, the multiplier is increased by up to 10%, and the scheduled overflow check is late by 15%.
--- drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +2 -2
@@ -517,14 +517,14 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev) ktime_to_ns(ktime_get_real()));/* Calculate period in seconds to call the overflow watchdog - to make -* sure counter is checked at least once every wrap around. +* sure counter is checked at least twice every wrap around. * The period is calculated as the minimum between max HW cycles count * (The clock source mask) and max amount of cycles that can be * multiplied by clock multiplier where the result doesn't exceed * 64bits. */ overflow_cycles =div64_u64 (~0ULL >>1 , clock->cycles.mult); - overflow_cycles =min (overflow_cycles, clock->cycles.mask >>1 ); + overflow_cycles =min (overflow_cycles,div_u64 (clock->cycles.mask,3 )); ns =cyclecounter_cyc2ns (&clock->cycles, overflow_cycles, frac, &frac);
Signature · 1 line
2.19.2
PATCH v2 2/13 mlx5: extend PTP gettime function to read system clock
In reply to Saeed MahameedFrom: Miroslav Lichvar <[email protected]>
Read the system time right before and immediately after reading the low register of the internal timer. This adds support for the PTP_SYS_OFFSET_EXTENDED ioctl.
--- .../ethernet/mellanox/mlx5/core/lib/clock.c | 20 +++++++++++-------- .../net/ethernet/mellanox/mlx5/core/main.c | 11 ++++++++-- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 4 +++- 3 files changed, 24 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +12 -8
@@ -72,7 +72,7 @@ static u64 read_internal_timer(const struct cyclecounter *cc) struct mlx5_core_dev *mdev = container_of(clock, struct mlx5_core_dev, clock); -return mlx5_read_internal_timer (mdev) & cc->mask; +return mlx5_read_internal_timer (mdev,NULL ) & cc->mask; }static void mlx5_update_clock_info_page (struct mlx5_core_dev *mdev)
@@ -156,15 +156,19 @@ static int mlx5_ptp_settime(struct ptp_clock_info *ptp,return 0 ; } -static int mlx5_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) +static int mlx5_ptp_gettimex (struct ptp_clock_info *ptp,struct timespec64 *ts, +struct ptp_system_timestamp *sts) { struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, ptp_info); -u64 ns; + struct mlx5_core_dev *mdev = container_of(clock, struct mlx5_core_dev, + clock);unsigned long flags; +u64 cycles, ns;write_seqlock_irqsave (&clock->lock, flags); - ns =timecounter_read (&clock->tc); + cycles =mlx5_read_internal_timer (mdev, sts); + ns =timecounter_cyc2time (&clock->tc, cycles);write_sequnlock_irqrestore (&clock->lock, flags); *ts =ns_to_timespec64 (ns);
@@ -307,7 +311,7 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp, ts.tv_sec = rq->perout.start.sec; ts.tv_nsec = rq->perout.start.nsec; ns =timespec64_to_ns (&ts); - cycles_now =mlx5_read_internal_timer (mdev); + cycles_now =mlx5_read_internal_timer (mdev,NULL );write_seqlock_irqsave (&clock->lock, flags); nsec_now =timecounter_cyc2time (&clock->tc, cycles_now); nsec_delta = ns - nsec_now;
@@ -384,7 +388,7 @@ static const struct ptp_clock_info mlx5_ptp_clock_info = { .pps = 0, .adjfreq = mlx5_ptp_adjfreq, .adjtime = mlx5_ptp_adjtime, - .gettime64 = mlx5_ptp_gettime, + .gettimex64 = mlx5_ptp_gettimex, .settime64 = mlx5_ptp_settime, .enable = NULL, .verify = NULL,
@@ -469,8 +473,8 @@ static int mlx5_pps_event(struct notifier_block *nb,ptp_clock_event (clock->ptp, &ptp_event);break ;case PTP_PF_PEROUT : -mlx5_ptp_gettime (&clock->ptp_info, &ts); - cycles_now =mlx5_read_internal_timer (mdev); +mlx5_ptp_gettimex (&clock->ptp_info, &ts,NULL ); + cycles_now =mlx5_read_internal_timer (mdev,NULL ); ts.tv_sec +=1 ; ts.tv_nsec =0 ; ns =timespec64_to_ns (&ts);
drivers/net/ethernet/mellanox/mlx5/core/main.c +9 -2
@@ -580,15 +580,22 @@ int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id)return mlx5_cmd_exec (dev, in,sizeof (in), out,sizeof (out)); } -u64 mlx5_read_internal_timer (struct mlx5_core_dev *dev) +u64 mlx5_read_internal_timer (struct mlx5_core_dev *dev, +struct ptp_system_timestamp *sts) {u32 timer_h, timer_h1, timer_l; timer_h =ioread32be (&dev->iseg->internal_timer_h); +ptp_read_system_prets (sts); timer_l =ioread32be (&dev->iseg->internal_timer_l); +ptp_read_system_postts (sts); timer_h1 =ioread32be (&dev->iseg->internal_timer_h); -if (timer_h != timer_h1)/* wrap around */ +if (timer_h != timer_h1) { +/* wrap around */ +ptp_read_system_prets (sts); timer_l =ioread32be (&dev->iseg->internal_timer_l); +ptp_read_system_postts (sts); + }return (u64 )timer_l | (u64 )timer_h1 <<32 ; }
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +3 -1
@@ -38,6 +38,7 @@#include <linux/sched.h> #include <linux/if_link.h> #include <linux/firmware.h> +#include <linux/ptp_clock_kernel.h> #include <linux/mlx5/cq.h> #include <linux/mlx5/fs.h>
@@ -121,7 +122,8 @@ int mlx5_modify_scheduling_element_cmd(struct mlx5_core_dev *dev, u8 hierarchy,int mlx5_destroy_scheduling_element_cmd (struct mlx5_core_dev *dev,u8 hierarchy,u32 element_id);int mlx5_wait_for_vf_pages (struct mlx5_core_dev *dev); -u64 mlx5_read_internal_timer (struct mlx5_core_dev *dev); +u64 mlx5_read_internal_timer (struct mlx5_core_dev *dev, +struct ptp_system_timestamp *sts);void mlx5_cmd_trigger_completions (struct mlx5_core_dev *dev);int mlx5_cq_debugfs_init (struct mlx5_core_dev *dev);
Signature · 1 line
2.19.2
PATCH v2 3/13 net/mlx5e: Increase VF representors' SQ size to 128
In reply to Saeed MahameedFrom: Gavi Teitz <[email protected]>
The default size for the VF representors' SQ was too small to handle high packet rates. Doubling the size from 64 to 128 drastically improves the packet rate under stress (by about 50%), whereas increasing the size beyond 128 has not shown to make any further difference.
The impact of the SQ size was measured with UDP traffic, in the following
topology: TG <-> PF <-> TC forwarding <-> VF representor <-> VF in VM over a single core processing bi-directional traffic, with the following results:
SQ size of 64: SQ size of 128:
Packet rate for 64B UDP packets: 860 [Kpps] 1280 [Kpps]
Packet rate for 114B VxLan
encapsulated UDP packets: 320 [Kpps] 500 [Kpps]
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +3 -3
@@ -45,8 +45,8 @@#include "en/tc_tun.h" #include "fs_core.h" -#define MLX5E_REP_PARAMS_LOG_SQ_SIZE \ - max(0x6, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE) +#define MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE \ + max(0x7, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)static const char mlx5e_rep_driver_name[] ="mlx5e_rep" ;
@@ -1336,7 +1336,7 @@ static void mlx5e_build_rep_params(struct net_device *netdev)if (rep->vport ==FDB_UPLINK_VPORT ) params->log_sq_size =MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE ;else - params->log_sq_size =MLX5E_REP_PARAMS_LOG_SQ_SIZE ; + params->log_sq_size =MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE ;;/* RQ */ mlx5e_build_rq_params (mdev, params);
Signature · 1 line
2.19.2
PATCH v2 4/13 net/mlx5e: Allow vlans on e-switch uplink reps
In reply to Saeed MahameedFrom: Or Gerlitz <[email protected]>
There are cases (e.g tunneling with vlan on underlay and potentially more) where this makes sense, so allow that.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +4 -1
@@ -1381,7 +1381,7 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) netdev->switchdev_ops = &mlx5e_rep_switchdev_ops; - netdev->features |=NETIF_F_VLAN_CHALLENGED |NETIF_F_HW_TC |NETIF_F_NETNS_LOCAL ; + netdev->features |=NETIF_F_HW_TC |NETIF_F_NETNS_LOCAL ; netdev->hw_features |=NETIF_F_HW_TC ; netdev->hw_features |=NETIF_F_SG ;
@@ -1392,6 +1392,9 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) netdev->hw_features |=NETIF_F_TSO6 ; netdev->hw_features |=NETIF_F_RXCSUM ; +if (rep->vport !=FDB_UPLINK_VPORT ) + netdev->features |=NETIF_F_VLAN_CHALLENGED ; + netdev->features |= netdev->hw_features; }
Signature · 1 line
2.19.2
PATCH v2 5/13 net/mlx5e: Fail attempt to offload e-switch TC flows with egress upper devices
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
We use the switchdev parent HW id helper to identify if the mirred device shares the same ASIC/port with the ingress device. This can get us wrong in the presence of upper devices such as vlan or bridge set over the HW devices (VF or uplink representors), b/c the switchdev ID is retrieved recursively.
To fail offload attempts in such cases, we condition the check on the egress device to have not only the same switchdev ID but also the relevant mlx5 netdev ops.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 9 +++++++++ drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 3 +++ drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 +++ 3 files changed, 15 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +9 -0
@@ -1316,6 +1316,15 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = { .ndo_get_vf_stats = mlx5e_get_vf_stats, }; +bool mlx5e_eswitch_rep (struct net_device *netdev) +{ +if (netdev->netdev_ops == &mlx5e_netdev_ops_vf_rep || + netdev->netdev_ops == &mlx5e_netdev_ops_uplink_rep) +return true; + +return false; +} +static void mlx5e_build_rep_params (struct net_device *netdev) {struct mlx5e_priv *priv =netdev_priv (netdev);
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +3 -0
@@ -176,6 +176,9 @@ 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); +#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 +3 -0
@@ -2583,6 +2583,9 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts, uplink_upper == out_dev) out_dev = uplink_dev; +if (!mlx5e_eswitch_rep (out_dev)) +return -EOPNOTSUPP ; + out_priv =netdev_priv (out_dev); rpriv = out_priv->ppriv; attr->dests[attr->out_count].rep = rpriv->rep;
Signature · 1 line
2.19.2
PATCH v2 6/13 net/mlx5e: Tunnel routing output devs helper function
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
For tunnel we determine the output devs for IPv4/6 cases, in two separate functions, with a duplicated code.
Move that code from IPv4/6 functions to a helper function, with no functional change.
--- .../ethernet/mellanox/mlx5/core/en/tc_tun.c | 70 +++++++++---------- 1 file changed, 34 insertions(+), 36 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +34 -36
@@ -6,6 +6,34 @@#include "lib/vxlan.h" #include "en/tc_tun.h" +static int get_route_and_out_devs (struct mlx5e_priv *priv, +struct net_device *dev, +struct net_device **route_dev, +struct net_device **out_dev) +{ +struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; +struct net_device *uplink_dev, *uplink_upper; +bool dst_is_lag_dev; + + uplink_dev =mlx5_eswitch_uplink_get_proto_dev (esw,REP_ETH ); + uplink_upper =netdev_master_upper_dev_get (uplink_dev); + dst_is_lag_dev = (uplink_upper && +netif_is_lag_master (uplink_upper) && + dev == uplink_upper && +mlx5_lag_is_sriov (priv->mdev)); + +/* if the egress device isn't on the same HW e-switch or +* it's a LAG device, use the uplink +*/ +if (!switchdev_port_same_parent_id (priv->netdev, dev) || + dst_is_lag_dev) + *out_dev = uplink_dev; +else + *out_dev = dev; + +return 0 ; +} + static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv, struct net_device *mirred_dev, struct net_device **out_dev,
@@ -13,9 +41,6 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,struct neighbour **out_n, u8 *out_ttl) { - struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; -struct net_device *uplink_dev, *uplink_upper; -bool dst_is_lag_dev; struct rtable *rt;struct neighbour *n =NULL ;
@@ -30,21 +55,9 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,return -EOPNOTSUPP ;#endif - uplink_dev =mlx5_eswitch_uplink_get_proto_dev (esw,REP_ETH ); - uplink_upper =netdev_master_upper_dev_get (uplink_dev); - dst_is_lag_dev = (uplink_upper && -netif_is_lag_master (uplink_upper) && - rt->dst.dev == uplink_upper && -mlx5_lag_is_sriov (priv->mdev)); - -/* if the egress device isn't on the same HW e-switch or -* it's a LAG device, use the uplink -*/ -if (!switchdev_port_same_parent_id (priv->netdev, rt->dst.dev) || - dst_is_lag_dev) - *out_dev = uplink_dev; -else - *out_dev = rt->dst.dev; + ret =get_route_and_out_devs (priv, rt->dst.dev,NULL , out_dev); +if (ret <0 ) +return ret;if (!(*out_ttl)) *out_ttl =ip4_dst_hoplimit (&rt->dst);
@@ -76,9 +89,6 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,struct dst_entry *dst;#if IS_ENABLED (CONFIG_INET ) &&IS_ENABLED (CONFIG_IPV6 ) -struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; -struct net_device *uplink_dev, *uplink_upper; -bool dst_is_lag_dev;int ret; ret = ipv6_stub->ipv6_dst_lookup(dev_net(mirred_dev), NULL, &dst,
@@ -89,21 +99,9 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,if (!(*out_ttl)) *out_ttl =ip6_dst_hoplimit (dst); - uplink_dev =mlx5_eswitch_uplink_get_proto_dev (esw,REP_ETH ); - uplink_upper =netdev_master_upper_dev_get (uplink_dev); - dst_is_lag_dev = (uplink_upper && -netif_is_lag_master (uplink_upper) && - dst->dev == uplink_upper && -mlx5_lag_is_sriov (priv->mdev)); - -/* if the egress device isn't on the same HW e-switch or -* it's a LAG device, use the uplink -*/ -if (!switchdev_port_same_parent_id (priv->netdev, dst->dev) || - dst_is_lag_dev) - *out_dev = uplink_dev; -else - *out_dev = dst->dev; + ret =get_route_and_out_devs (priv, dst->dev,NULL , out_dev); +if (ret <0 ) +return ret;#else return -EOPNOTSUPP ;#endif
Signature · 1 line
2.19.2
PATCH v2 7/13 net/mlx5e: Fail attempt to offload e-switch TC encap flows with vlan on underlay
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
Currently we don't support nor fail attempts to offload encap flows routed to vlan device on the underlay network. We wrongly consider a vlan underlay device to be on the same e-switch b/c the switchdev ID is retrieved recursively.
Add explicit check for that and fail such attempts.
Also align to a more strict check for the ingress and the underlay devices to practically be on the same eswitch.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +6 -0
@@ -15,6 +15,10 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,struct net_device *uplink_dev, *uplink_upper;bool dst_is_lag_dev; +/* we currently don't offload vlan on underlay */ +if (is_vlan_dev (dev)) +return -EOPNOTSUPP ; + uplink_dev =mlx5_eswitch_uplink_get_proto_dev (esw,REP_ETH ); uplink_upper =netdev_master_upper_dev_get (uplink_dev); dst_is_lag_dev = (uplink_upper &&
@@ -28,6 +32,8 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,if (!switchdev_port_same_parent_id (priv->netdev, dev) || dst_is_lag_dev) *out_dev = uplink_dev; +else if (!mlx5e_eswitch_rep (dev)) +return -EOPNOTSUPP ;else *out_dev = dev;
Signature · 1 line
2.19.2
PATCH v2 8/13 net/mlx5e: Tunnel encap ETH header helper function
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
In tunnel encap we prepare the encap header for IPv4/6 cases, in two separate functions. For ETH header generation the code is almost duplicated.
Move the ETH header generation code from IPv4/6 functions to a helper function, with no functional change.
--- .../ethernet/mellanox/mlx5/core/en/tc_tun.c | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +17 -12
@@ -180,6 +180,19 @@ static int mlx5e_gen_ip_tunnel_header(char buf[], __u8 *ip_proto,return err; } +static char *gen_eth_tnl_hdr (char *buf,struct net_device *dev, +struct mlx5e_encap_entry *e, +u16 proto) +{ +struct ethhdr *eth = (struct ethhdr *)buf; + +ether_addr_copy (eth->h_dest, e->h_dest); +ether_addr_copy (eth->h_source, dev->dev_addr); + eth->h_proto =htons (proto); + +return (char *)eth +ETH_HLEN ; +} +int mlx5e_tc_tun_create_header_ipv4 (struct mlx5e_priv *priv,struct net_device *mirred_dev,struct mlx5e_encap_entry *e)
@@ -193,7 +206,6 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,struct neighbour *n =NULL ;struct flowi4 fl4 = {};char *encap_header; -struct ethhdr *eth;u8 nud_state, ttl;struct iphdr *ip;int err;
@@ -242,13 +254,10 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,read_unlock_bh (&n->lock);/* add ethernet header */ - eth = (struct ethhdr *)encap_header; -ether_addr_copy (eth->h_dest, e->h_dest); -ether_addr_copy (eth->h_source, out_dev->dev_addr); - eth->h_proto =htons (ETH_P_IP ); + ip = (struct iphdr *)gen_eth_tnl_hdr (encap_header, out_dev, e, +ETH_P_IP );/* add ip header */ - ip = (struct iphdr *)((char *)eth +sizeof (struct ethhdr )); ip->tos = tun_key->tos; ip->version =0x4 ; ip->ihl =0x5 ;
@@ -308,7 +317,6 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,struct flowi6 fl6 = {};struct ipv6hdr *ip6h;char *encap_header; -struct ethhdr *eth;u8 nud_state, ttl;int err;
@@ -356,13 +364,10 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,read_unlock_bh (&n->lock);/* add ethernet header */ - eth = (struct ethhdr *)encap_header; -ether_addr_copy (eth->h_dest, e->h_dest); -ether_addr_copy (eth->h_source, out_dev->dev_addr); - eth->h_proto =htons (ETH_P_IPV6 ); + ip6h = (struct ipv6hdr *)gen_eth_tnl_hdr (encap_header, out_dev, e, +ETH_P_IPV6 );/* add ip header */ - ip6h = (struct ipv6hdr *)((char *)eth +sizeof (struct ethhdr ));ip6_flow_hdr (ip6h, tun_key->tos,0 );/* the HW fills up ipv6 payload len */ ip6h->hop_limit = ttl;
Signature · 1 line
2.19.2
PATCH v2 9/13 net/mlx5e: Re-order route and encap header memory allocation
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
Change the order to first route IPv4/6 and return if error. Only after successful route continue to allocate an encap header, with no functional change.
--- .../ethernet/mellanox/mlx5/core/en/tc_tun.c | 62 ++++++++++--------- 1 file changed, 34 insertions(+), 28 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +34 -28
@@ -198,28 +198,16 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, struct mlx5e_encap_entry *e) {int max_encap_size =MLX5_CAP_ESW (priv->mdev, max_encap_header_size); -int ipv4_encap_size =ETH_HLEN + -sizeof (struct iphdr ) + - e->tunnel_hlen;struct ip_tunnel_key *tun_key = &e->tun_info.key;struct net_device *out_dev;struct neighbour *n =NULL ;struct flowi4 fl4 = {}; +int ipv4_encap_size;char *encap_header;u8 nud_state, ttl;struct iphdr *ip;int err; -if (max_encap_size < ipv4_encap_size) { -mlx5_core_warn (priv->mdev,"encap size %d too big, max supported is %d\n" , - ipv4_encap_size, max_encap_size); -return -EOPNOTSUPP ; - } - - encap_header =kzalloc (ipv4_encap_size,GFP_KERNEL ); -if (!encap_header) -return -ENOMEM ; -/* add the IP fields */ fl4.flowi4_tos = tun_key->tos; fl4.daddr = tun_key->u.ipv4.dst;
@@ -229,7 +217,22 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, err =mlx5e_route_lookup_ipv4 (priv, mirred_dev, &out_dev, &fl4, &n, &ttl);if (err) - goto free_encap; +return err; + + ipv4_encap_size = +ETH_HLEN + +sizeof (struct iphdr ) + + e->tunnel_hlen; + +if (max_encap_size < ipv4_encap_size) { +mlx5_core_warn (priv->mdev,"encap size %d too big, max supported is %d\n" , + ipv4_encap_size, max_encap_size); +return -EOPNOTSUPP ; + } + + encap_header =kzalloc (ipv4_encap_size,GFP_KERNEL ); +if (!encap_header) +return -ENOMEM ;/* used by mlx5e_detach_encap to lookup a neigh hash table * entry in the neigh hash table when a user deletes a rule
@@ -308,28 +311,16 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, struct mlx5e_encap_entry *e) {int max_encap_size =MLX5_CAP_ESW (priv->mdev, max_encap_header_size); -int ipv6_encap_size =ETH_HLEN + -sizeof (struct ipv6hdr ) + - e->tunnel_hlen;struct ip_tunnel_key *tun_key = &e->tun_info.key;struct net_device *out_dev;struct neighbour *n =NULL ;struct flowi6 fl6 = {};struct ipv6hdr *ip6h; +int ipv6_encap_size;char *encap_header;u8 nud_state, ttl;int err; -if (max_encap_size < ipv6_encap_size) { -mlx5_core_warn (priv->mdev,"encap size %d too big, max supported is %d\n" , - ipv6_encap_size, max_encap_size); -return -EOPNOTSUPP ; - } - - encap_header =kzalloc (ipv6_encap_size,GFP_KERNEL ); -if (!encap_header) -return -ENOMEM ; - ttl = tun_key->ttl; fl6.flowlabel =ip6_make_flowinfo (RT_TOS (tun_key->tos), tun_key->label);
@@ -339,7 +330,22 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, err =mlx5e_route_lookup_ipv6 (priv, mirred_dev, &out_dev, &fl6, &n, &ttl);if (err) - goto free_encap; +return err; + + ipv6_encap_size = +ETH_HLEN + +sizeof (struct ipv6hdr ) + + e->tunnel_hlen; + +if (max_encap_size < ipv6_encap_size) { +mlx5_core_warn (priv->mdev,"encap size %d too big, max supported is %d\n" , + ipv6_encap_size, max_encap_size); +return -EOPNOTSUPP ; + } + + encap_header =kzalloc (ipv6_encap_size,GFP_KERNEL ); +if (!encap_header) +return -ENOMEM ;/* used by mlx5e_detach_encap to lookup a neigh hash table * entry in the neigh hash table when a user deletes a rule
Signature · 1 line
2.19.2
PATCH v2 10/13 net/mlx5e: Support VLAN encap ETH header generation
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
Support generation of native or tagged Ethernet header for encap header, depending on provided net device.
--- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +13 -2
@@ -185,12 +185,23 @@ static char *gen_eth_tnl_hdr(char *buf, struct net_device *dev, u16 proto) {struct ethhdr *eth = (struct ethhdr *)buf; +char *ip;ether_addr_copy (eth->h_dest, e->h_dest);ether_addr_copy (eth->h_source, dev->dev_addr); - eth->h_proto =htons (proto); +if (is_vlan_dev (dev)) { +struct vlan_hdr *vlan = (struct vlan_hdr *) + ((char *)eth +ETH_HLEN ); + ip = (char *)vlan +VLAN_HLEN ; + eth->h_proto =vlan_dev_vlan_proto (dev); + vlan->h_vlan_TCI =htons (vlan_dev_vlan_id (dev)); + vlan->h_vlan_encapsulated_proto =htons (proto); + }else { + eth->h_proto =htons (proto); + ip = (char *)eth +ETH_HLEN ; + } -return (char *)eth +ETH_HLEN ; +return ip; } int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,
Signature · 1 line
2.19.2
PATCH v2 11/13 net/mlx5e: Support tunnel encap over tagged Ethernet
In reply to Saeed MahameedFrom: Eli Britstein <[email protected]>
Generate encap header depending on the routed device to support native/tagged Ethernet header.
--- .../ethernet/mellanox/mlx5/core/en/tc_tun.c | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +24 -20
@@ -15,10 +15,6 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,struct net_device *uplink_dev, *uplink_upper;bool dst_is_lag_dev; -/* we currently don't offload vlan on underlay */ -if (is_vlan_dev (dev)) -return -EOPNOTSUPP ; - uplink_dev =mlx5_eswitch_uplink_get_proto_dev (esw,REP_ETH ); uplink_upper =netdev_master_upper_dev_get (uplink_dev); dst_is_lag_dev = (uplink_upper &&
@@ -30,12 +26,18 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,* it's a LAG device, use the uplink */ if (!switchdev_port_same_parent_id (priv->netdev, dev) || - dst_is_lag_dev) - *out_dev = uplink_dev; -else if (!mlx5e_eswitch_rep (dev)) -return -EOPNOTSUPP ; -else - *out_dev = dev; + dst_is_lag_dev) { + *route_dev = uplink_dev; + *out_dev = *route_dev; + }else { + *route_dev = dev; +if (is_vlan_dev (*route_dev)) + *out_dev = uplink_dev; +else if (mlx5e_eswitch_rep (dev)) + *out_dev = *route_dev; +else +return -EOPNOTSUPP ; + }return 0 ; }
@@ -43,6 +45,7 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,static int mlx5e_route_lookup_ipv4 (struct mlx5e_priv *priv,struct net_device *mirred_dev,struct net_device **out_dev, +struct net_device **route_dev,struct flowi4 *fl4,struct neighbour **out_n,u8 *out_ttl)
@@ -61,7 +64,7 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,return -EOPNOTSUPP ;#endif - ret =get_route_and_out_devs (priv, rt->dst.dev,NULL , out_dev); + ret =get_route_and_out_devs (priv, rt->dst.dev, route_dev, out_dev);if (ret <0 )return ret;
@@ -87,6 +90,7 @@ static const char *mlx5e_netdev_kind(struct net_device *dev)static int mlx5e_route_lookup_ipv6 (struct mlx5e_priv *priv,struct net_device *mirred_dev,struct net_device **out_dev, +struct net_device **route_dev,struct flowi6 *fl6,struct neighbour **out_n,u8 *out_ttl)
@@ -105,7 +109,7 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,if (!(*out_ttl)) *out_ttl =ip6_dst_hoplimit (dst); - ret =get_route_and_out_devs (priv, dst->dev,NULL , out_dev); + ret =get_route_and_out_devs (priv, dst->dev, route_dev, out_dev);if (ret <0 )return ret;#else
@@ -210,7 +214,7 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, {int max_encap_size =MLX5_CAP_ESW (priv->mdev, max_encap_header_size);struct ip_tunnel_key *tun_key = &e->tun_info.key; -struct net_device *out_dev; +struct net_device *out_dev, *route_dev;struct neighbour *n =NULL ;struct flowi4 fl4 = {};int ipv4_encap_size;
@@ -225,13 +229,13 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, fl4.saddr = tun_key->u.ipv4.src; ttl = tun_key->ttl; - err =mlx5e_route_lookup_ipv4 (priv, mirred_dev, &out_dev, + err =mlx5e_route_lookup_ipv4 (priv, mirred_dev, &out_dev, &route_dev, &fl4, &n, &ttl);if (err)return err; ipv4_encap_size = -ETH_HLEN + + (is_vlan_dev (route_dev) ?VLAN_ETH_HLEN :ETH_HLEN ) +sizeof (struct iphdr ) + e->tunnel_hlen;
@@ -268,7 +272,7 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,read_unlock_bh (&n->lock);/* add ethernet header */ - ip = (struct iphdr *)gen_eth_tnl_hdr (encap_header, out_dev, e, + ip = (struct iphdr *)gen_eth_tnl_hdr (encap_header, route_dev, e,ETH_P_IP );/* add ip header */
@@ -323,7 +327,7 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, {int max_encap_size =MLX5_CAP_ESW (priv->mdev, max_encap_header_size);struct ip_tunnel_key *tun_key = &e->tun_info.key; -struct net_device *out_dev; +struct net_device *out_dev, *route_dev;struct neighbour *n =NULL ;struct flowi6 fl6 = {};struct ipv6hdr *ip6h;
@@ -338,13 +342,13 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, fl6.daddr = tun_key->u.ipv6.dst; fl6.saddr = tun_key->u.ipv6.src; - err =mlx5e_route_lookup_ipv6 (priv, mirred_dev, &out_dev, + err =mlx5e_route_lookup_ipv6 (priv, mirred_dev, &out_dev, &route_dev, &fl6, &n, &ttl);if (err)return err; ipv6_encap_size = -ETH_HLEN + + (is_vlan_dev (route_dev) ?VLAN_ETH_HLEN :ETH_HLEN ) +sizeof (struct ipv6hdr ) + e->tunnel_hlen;
@@ -381,7 +385,7 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,read_unlock_bh (&n->lock);/* add ethernet header */ - ip6h = (struct ipv6hdr *)gen_eth_tnl_hdr (encap_header, out_dev, e, + ip6h = (struct ipv6hdr *)gen_eth_tnl_hdr (encap_header, route_dev, e,ETH_P_IPV6 );/* add ip header */
Signature · 1 line
2.19.2
PATCH v2 12/13 net/mlx5: Fix query_nic_sys_image_guid() error during init
In reply to Saeed MahameedFrom: Aviv Heller <[email protected]>
vport system image guid should be queried using vport nic API for Ethernet ports, and vport hca API for Infiniband ports.
--- drivers/net/ethernet/mellanox/mlx5/core/vport.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/vport.c +13 -3
@@ -1204,9 +1204,19 @@ EXPORT_SYMBOL_GPL(mlx5_nic_vport_unaffiliate_multiport);u64 mlx5_query_nic_system_image_guid (struct mlx5_core_dev *mdev) { -if (!mdev->sys_image_guid) -mlx5_query_nic_vport_system_image_guid (mdev, &mdev->sys_image_guid); +int port_type_cap =MLX5_CAP_GEN (mdev, port_type); +u64 tmp =0 ; -return mdev->sys_image_guid; +if (mdev->sys_image_guid) +return mdev->sys_image_guid; + +if (port_type_cap ==MLX5_CAP_PORT_TYPE_ETH ) +mlx5_query_nic_vport_system_image_guid (mdev, &tmp); +else +mlx5_query_hca_vport_system_image_guid (mdev, &tmp); + + mdev->sys_image_guid = tmp; + +return tmp; }EXPORT_SYMBOL_GPL (mlx5_query_nic_system_image_guid);
Signature · 1 line
2.19.2
PATCH v2 13/13 net/mlx5: Fix LAG requirement when CONFIG_MLX5_ESWITCH is off
In reply to Saeed MahameedFrom: Aviv Heller <[email protected]>
If CONFIG_MLX5_ESWITCH is not defined, test for SR-IOV being disabled, instead of calling e-switch LAG prereq routine.
Since LAG with SRIOV is allowed only when switchdev mode is on.
--- drivers/net/ethernet/mellanox/mlx5/core/lag.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag.c +8 -5
@@ -291,12 +291,15 @@ static int mlx5_deactivate_lag(struct mlx5_lag *ldev)static bool mlx5_lag_check_prereq (struct mlx5_lag *ldev) { -if (ldev->pf[0 ].dev && - ldev->pf[1 ].dev && -mlx5_esw_lag_prereq (ldev->pf[0 ].dev, ldev->pf[1 ].dev)) -return true; -else +if (!ldev->pf[0 ].dev || !ldev->pf[1 ].dev)return false; + +#ifdef CONFIG_MLX5_ESWITCH +return mlx5_esw_lag_prereq (ldev->pf[0 ].dev, ldev->pf[1 ].dev); +#else +return (!mlx5_sriov_is_enabled (ldev->pf[0 ].dev) && + !mlx5_sriov_is_enabled (ldev->pf[1 ].dev)); +#endif }static void mlx5_lag_add_ib_devices (struct mlx5_lag *ldev)
Signature · 1 line
2.19.2
David Miller
maintainerFrom: Saeed Mahameed <[email protected]>
Date: Thu, 20 Dec 2018 10:04:27 -0800
Quoted 10 lines
This series includes some misc updates and vlan encap tunnel support. For more information please see tag log below.
Please pull and let me know if there is any problem.
v1->v2:
- Apply the check on not being a rep after and not before adjustingout_devin patch #5.
- improve commit message of patch #5.
- Add two patches (#12,13) to the series from Aviv to fix VF LAG minor issues.
Pulled, thanks for the conflict resolution guidance.