Skip to content

Commit ebe023a

Browse files
committed
Merge tag 'mlx5e-updates-2018-07-27' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5e-updates-2018-07-27 (Vxlan updates) This series from Gal and Saeed provides updates to mlx5 vxlan implementation. Gal, started with three cleanups to reflect the actual hardware vxlan state - reflect 4789 UDP port default addition to software database - check maximum number of vxlan UDP ports - cleanup an unused member in vxlan work Then Gal provides performance optimization by replacing the vxlan radix tree with a hash table. Measuring mlx5e_vxlan_lookup_port execution time: Radix Tree Hash Table --------------- ------------ ------------ Single Stream 161 ns 79 ns (51% improvement) Multi Stream 259 ns 136 ns (47% improvement) Measuring UDP stream packet rate, single fully utilized TX core: Radix Tree: 498,300 PPS Hash Table: 555,468 PPS (11% improvement) Next, from Saeed, vxlan refactoring to allow sharing the vxlan table between different mlx5 netdevice instances like PF and VF representors, this is done by making mlx5 vxlan interface more generic and decoupling it from PF netdevice structures and logic, then moving it into mlx5 core as a low level interface so it can be used by VF representors, which is illustrated in the last patch of the serious. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents eef6ab8 + a3e6736 commit ebe023a

10 files changed

Lines changed: 325 additions & 240 deletions

File tree

‎drivers/net/ethernet/mellanox/mlx5/core/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o \
1414
fpga/ipsec.o fpga/tls.o
1515

1616
mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
17-
en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o vxlan.o \
18-
en_arfs.o en_fs_ethtool.o en_selftest.o en/port.o
17+
en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o \
18+
en_arfs.o en_fs_ethtool.o en_selftest.o en/port.o lib/vxlan.o
1919

2020
mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o
2121

‎drivers/net/ethernet/mellanox/mlx5/core/en.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,6 @@ enum {
654654
MLX5E_STATE_DESTROYING,
655655
};
656656

657-
struct mlx5e_vxlan_db {
658-
spinlock_t lock; /* protect vxlan table */
659-
struct radix_tree_root tree;
660-
};
661-
662657
struct mlx5e_l2_rule {
663658
u8 addr[ETH_ALEN + 2];
664659
struct mlx5_flow_handle *rule;
@@ -816,7 +811,6 @@ struct mlx5e_priv {
816811
u32 tx_rates[MLX5E_MAX_NUM_SQS];
817812

818813
struct mlx5e_flow_steering fs;
819-
struct mlx5e_vxlan_db vxlan;
820814

821815
struct workqueue_struct *wq;
822816
struct work_struct update_carrier_work;

‎drivers/net/ethernet/mellanox/mlx5/core/en_main.c‎

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "en_accel/tls.h"
4646
#include "accel/ipsec.h"
4747
#include "accel/tls.h"
48-
#include "vxlan.h"
48+
#include "lib/vxlan.h"
4949
#include "en/port.h"
5050
#include "en/xdp.h"
5151

@@ -2974,7 +2974,7 @@ int mlx5e_open(struct net_device *netdev)
29742974
mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_UP);
29752975
mutex_unlock(&priv->state_lock);
29762976

2977-
if (mlx5e_vxlan_allowed(priv->mdev))
2977+
if (mlx5_vxlan_allowed(priv->mdev->vxlan))
29782978
udp_tunnel_get_rx_info(netdev);
29792979

29802980
return err;
@@ -3969,6 +3969,57 @@ static int mlx5e_get_vf_stats(struct net_device *dev,
39693969
}
39703970
#endif
39713971

3972+
struct mlx5e_vxlan_work {
3973+
struct work_struct work;
3974+
struct mlx5e_priv *priv;
3975+
u16 port;
3976+
};
3977+
3978+
static void mlx5e_vxlan_add_work(struct work_struct *work)
3979+
{
3980+
struct mlx5e_vxlan_work *vxlan_work =
3981+
container_of(work, struct mlx5e_vxlan_work, work);
3982+
struct mlx5e_priv *priv = vxlan_work->priv;
3983+
u16 port = vxlan_work->port;
3984+
3985+
mutex_lock(&priv->state_lock);
3986+
mlx5_vxlan_add_port(priv->mdev->vxlan, port);
3987+
mutex_unlock(&priv->state_lock);
3988+
3989+
kfree(vxlan_work);
3990+
}
3991+
3992+
static void mlx5e_vxlan_del_work(struct work_struct *work)
3993+
{
3994+
struct mlx5e_vxlan_work *vxlan_work =
3995+
container_of(work, struct mlx5e_vxlan_work, work);
3996+
struct mlx5e_priv *priv = vxlan_work->priv;
3997+
u16 port = vxlan_work->port;
3998+
3999+
mutex_lock(&priv->state_lock);
4000+
mlx5_vxlan_del_port(priv->mdev->vxlan, port);
4001+
mutex_unlock(&priv->state_lock);
4002+
kfree(vxlan_work);
4003+
}
4004+
4005+
static void mlx5e_vxlan_queue_work(struct mlx5e_priv *priv, u16 port, int add)
4006+
{
4007+
struct mlx5e_vxlan_work *vxlan_work;
4008+
4009+
vxlan_work = kmalloc(sizeof(*vxlan_work), GFP_ATOMIC);
4010+
if (!vxlan_work)
4011+
return;
4012+
4013+
if (add)
4014+
INIT_WORK(&vxlan_work->work, mlx5e_vxlan_add_work);
4015+
else
4016+
INIT_WORK(&vxlan_work->work, mlx5e_vxlan_del_work);
4017+
4018+
vxlan_work->priv = priv;
4019+
vxlan_work->port = port;
4020+
queue_work(priv->wq, &vxlan_work->work);
4021+
}
4022+
39724023
static void mlx5e_add_vxlan_port(struct net_device *netdev,
39734024
struct udp_tunnel_info *ti)
39744025
{
@@ -3977,10 +4028,10 @@ static void mlx5e_add_vxlan_port(struct net_device *netdev,
39774028
if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
39784029
return;
39794030

3980-
if (!mlx5e_vxlan_allowed(priv->mdev))
4031+
if (!mlx5_vxlan_allowed(priv->mdev->vxlan))
39814032
return;
39824033

3983-
mlx5e_vxlan_queue_work(priv, ti->sa_family, be16_to_cpu(ti->port), 1);
4034+
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 1);
39844035
}
39854036

39864037
static void mlx5e_del_vxlan_port(struct net_device *netdev,
@@ -3991,10 +4042,10 @@ static void mlx5e_del_vxlan_port(struct net_device *netdev,
39914042
if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
39924043
return;
39934044

3994-
if (!mlx5e_vxlan_allowed(priv->mdev))
4045+
if (!mlx5_vxlan_allowed(priv->mdev->vxlan))
39954046
return;
39964047

3997-
mlx5e_vxlan_queue_work(priv, ti->sa_family, be16_to_cpu(ti->port), 0);
4048+
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 0);
39984049
}
39994050

40004051
static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
@@ -4025,7 +4076,7 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
40254076
port = be16_to_cpu(udph->dest);
40264077

40274078
/* Verify if UDP port is being offloaded by HW */
4028-
if (mlx5e_vxlan_lookup_port(priv, port))
4079+
if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, port))
40294080
return features;
40304081
}
40314082

@@ -4597,15 +4648,15 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
45974648
netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
45984649
netdev->hw_features |= NETIF_F_HW_VLAN_STAG_TX;
45994650

4600-
if (mlx5e_vxlan_allowed(mdev) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) {
4651+
if (mlx5_vxlan_allowed(mdev->vxlan) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) {
46014652
netdev->hw_enc_features |= NETIF_F_IP_CSUM;
46024653
netdev->hw_enc_features |= NETIF_F_IPV6_CSUM;
46034654
netdev->hw_enc_features |= NETIF_F_TSO;
46044655
netdev->hw_enc_features |= NETIF_F_TSO6;
46054656
netdev->hw_enc_features |= NETIF_F_GSO_PARTIAL;
46064657
}
46074658

4608-
if (mlx5e_vxlan_allowed(mdev)) {
4659+
if (mlx5_vxlan_allowed(mdev->vxlan)) {
46094660
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL |
46104661
NETIF_F_GSO_UDP_TUNNEL_CSUM;
46114662
netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL |
@@ -4716,14 +4767,12 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
47164767
mlx5_core_err(mdev, "TLS initialization failed, %d\n", err);
47174768
mlx5e_build_nic_netdev(netdev);
47184769
mlx5e_build_tc2txq_maps(priv);
4719-
mlx5e_vxlan_init(priv);
47204770
}
47214771

47224772
static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
47234773
{
47244774
mlx5e_tls_cleanup(priv);
47254775
mlx5e_ipsec_cleanup(priv);
4726-
mlx5e_vxlan_cleanup(priv);
47274776
}
47284777

47294778
static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)

‎drivers/net/ethernet/mellanox/mlx5/core/en_tc.c‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#include "en_rep.h"
5151
#include "en_tc.h"
5252
#include "eswitch.h"
53-
#include "vxlan.h"
53+
#include "lib/vxlan.h"
5454
#include "fs_core.h"
5555
#include "en/port.h"
5656

@@ -1124,16 +1124,12 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
11241124
skb_flow_dissector_target(f->dissector,
11251125
FLOW_DISSECTOR_KEY_ENC_PORTS,
11261126
f->mask);
1127-
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
1128-
struct mlx5e_rep_priv *uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH);
1129-
struct net_device *up_dev = uplink_rpriv->netdev;
1130-
struct mlx5e_priv *up_priv = netdev_priv(up_dev);
11311127

11321128
/* Full udp dst port must be given */
11331129
if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst)))
11341130
goto vxlan_match_offload_err;
11351131

1136-
if (mlx5e_vxlan_lookup_port(up_priv, be16_to_cpu(key->dst)) &&
1132+
if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, be16_to_cpu(key->dst)) &&
11371133
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap))
11381134
parse_vxlan_attr(spec, f);
11391135
else {
@@ -2533,11 +2529,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
25332529
struct mlx5e_tc_flow *flow)
25342530
{
25352531
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
2536-
struct mlx5e_rep_priv *uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw,
2537-
REP_ETH);
2538-
struct net_device *up_dev = uplink_rpriv->netdev;
25392532
unsigned short family = ip_tunnel_info_af(tun_info);
2540-
struct mlx5e_priv *up_priv = netdev_priv(up_dev);
25412533
struct mlx5_esw_flow_attr *attr = flow->esw_attr;
25422534
struct ip_tunnel_key *key = &tun_info->key;
25432535
struct mlx5e_encap_entry *e;
@@ -2557,7 +2549,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
25572549
return -EOPNOTSUPP;
25582550
}
25592551

2560-
if (mlx5e_vxlan_lookup_port(up_priv, be16_to_cpu(key->tp_dst)) &&
2552+
if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, be16_to_cpu(key->tp_dst)) &&
25612553
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {
25622554
tunnel_type = MLX5_HEADER_TYPE_VXLAN;
25632555
} else {

0 commit comments

Comments
 (0)