Skip to content

Commit 358aa5c

Browse files
author
Saeed Mahameed
committed
net/mlx5e: Vxlan, move vxlan logic to core driver
Move vxlan logic and objects to mlx5 core dirver. Since it going to be used from different mlx5 interfaces. e.g. mlx5e PF NIC netdev and mlx5e E-Switch representors. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
1 parent aec4eab commit 358aa5c

8 files changed

Lines changed: 21 additions & 19 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#include "wq.h"
5353
#include "mlx5_core.h"
5454
#include "en_stats.h"
55-
#include "vxlan.h"
5655

5756
struct page_pool;
5857

@@ -812,7 +811,6 @@ struct mlx5e_priv {
812811
u32 tx_rates[MLX5E_MAX_NUM_SQS];
813812

814813
struct mlx5e_flow_steering fs;
815-
struct mlx5_vxlan *vxlan;
816814

817815
struct workqueue_struct *wq;
818816
struct work_struct update_carrier_work;

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

Lines changed: 9 additions & 12 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 (mlx5_vxlan_allowed(priv->vxlan))
2977+
if (mlx5_vxlan_allowed(priv->mdev->vxlan))
29782978
udp_tunnel_get_rx_info(netdev);
29792979

29802980
return err;
@@ -3983,7 +3983,7 @@ static void mlx5e_vxlan_add_work(struct work_struct *work)
39833983
u16 port = vxlan_work->port;
39843984

39853985
mutex_lock(&priv->state_lock);
3986-
mlx5_vxlan_add_port(priv->vxlan, port);
3986+
mlx5_vxlan_add_port(priv->mdev->vxlan, port);
39873987
mutex_unlock(&priv->state_lock);
39883988

39893989
kfree(vxlan_work);
@@ -3997,7 +3997,7 @@ static void mlx5e_vxlan_del_work(struct work_struct *work)
39973997
u16 port = vxlan_work->port;
39983998

39993999
mutex_lock(&priv->state_lock);
4000-
mlx5_vxlan_del_port(priv->vxlan, port);
4000+
mlx5_vxlan_del_port(priv->mdev->vxlan, port);
40014001
mutex_unlock(&priv->state_lock);
40024002
kfree(vxlan_work);
40034003
}
@@ -4028,7 +4028,7 @@ static void mlx5e_add_vxlan_port(struct net_device *netdev,
40284028
if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
40294029
return;
40304030

4031-
if (!mlx5_vxlan_allowed(priv->vxlan))
4031+
if (!mlx5_vxlan_allowed(priv->mdev->vxlan))
40324032
return;
40334033

40344034
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 1);
@@ -4042,7 +4042,7 @@ static void mlx5e_del_vxlan_port(struct net_device *netdev,
40424042
if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
40434043
return;
40444044

4045-
if (!mlx5_vxlan_allowed(priv->vxlan))
4045+
if (!mlx5_vxlan_allowed(priv->mdev->vxlan))
40464046
return;
40474047

40484048
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 0);
@@ -4076,7 +4076,7 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
40764076
port = be16_to_cpu(udph->dest);
40774077

40784078
/* Verify if UDP port is being offloaded by HW */
4079-
if (mlx5_vxlan_lookup_port(priv->vxlan, port))
4079+
if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, port))
40804080
return features;
40814081
}
40824082

@@ -4648,15 +4648,15 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
46484648
netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
46494649
netdev->hw_features |= NETIF_F_HW_VLAN_STAG_TX;
46504650

4651-
if (mlx5_vxlan_allowed(priv->vxlan) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) {
4651+
if (mlx5_vxlan_allowed(mdev->vxlan) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) {
46524652
netdev->hw_enc_features |= NETIF_F_IP_CSUM;
46534653
netdev->hw_enc_features |= NETIF_F_IPV6_CSUM;
46544654
netdev->hw_enc_features |= NETIF_F_TSO;
46554655
netdev->hw_enc_features |= NETIF_F_TSO6;
46564656
netdev->hw_enc_features |= NETIF_F_GSO_PARTIAL;
46574657
}
46584658

4659-
if (mlx5_vxlan_allowed(priv->vxlan)) {
4659+
if (mlx5_vxlan_allowed(mdev->vxlan)) {
46604660
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL |
46614661
NETIF_F_GSO_UDP_TUNNEL_CSUM;
46624662
netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL |
@@ -4758,8 +4758,6 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
47584758
struct mlx5e_priv *priv = netdev_priv(netdev);
47594759
int err;
47604760

4761-
priv->vxlan = mlx5_vxlan_create(mdev);
4762-
47634761
mlx5e_build_nic_netdev_priv(mdev, netdev, profile, ppriv);
47644762
err = mlx5e_ipsec_init(priv);
47654763
if (err)
@@ -4773,7 +4771,6 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
47734771

47744772
static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
47754773
{
4776-
mlx5_vxlan_destroy(priv->vxlan);
47774774
mlx5e_tls_cleanup(priv);
47784775
mlx5e_ipsec_cleanup(priv);
47794776
}

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

Lines changed: 3 additions & 3 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

@@ -1133,7 +1133,7 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
11331133
if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst)))
11341134
goto vxlan_match_offload_err;
11351135

1136-
if (mlx5_vxlan_lookup_port(up_priv->vxlan, be16_to_cpu(key->dst)) &&
1136+
if (mlx5_vxlan_lookup_port(up_priv->mdev->vxlan, be16_to_cpu(key->dst)) &&
11371137
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap))
11381138
parse_vxlan_attr(spec, f);
11391139
else {
@@ -2557,7 +2557,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
25572557
return -EOPNOTSUPP;
25582558
}
25592559

2560-
if (mlx5_vxlan_lookup_port(up_priv->vxlan, be16_to_cpu(key->tp_dst)) &&
2560+
if (mlx5_vxlan_lookup_port(up_priv->mdev->vxlan, be16_to_cpu(key->tp_dst)) &&
25612561
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {
25622562
tunnel_type = MLX5_HEADER_TYPE_VXLAN;
25632563
} else {
File renamed without changes.
File renamed without changes.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "accel/ipsec.h"
6363
#include "accel/tls.h"
6464
#include "lib/clock.h"
65+
#include "lib/vxlan.h"
6566
#include "diag/fw_tracer.h"
6667

6768
MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
@@ -961,6 +962,8 @@ static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
961962

962963
mlx5_init_clock(dev);
963964

965+
dev->vxlan = mlx5_vxlan_create(dev);
966+
964967
err = mlx5_init_rl_table(dev);
965968
if (err) {
966969
dev_err(&pdev->dev, "Failed to init rate limiting\n");
@@ -1004,6 +1007,7 @@ static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
10041007
err_rl_cleanup:
10051008
mlx5_cleanup_rl_table(dev);
10061009
err_tables_cleanup:
1010+
mlx5_vxlan_destroy(dev->vxlan);
10071011
mlx5_cleanup_mkey_table(dev);
10081012
mlx5_cleanup_srq_table(dev);
10091013
mlx5_cleanup_qp_table(dev);
@@ -1024,6 +1028,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
10241028
mlx5_eswitch_cleanup(dev->priv.eswitch);
10251029
mlx5_mpfs_cleanup(dev);
10261030
mlx5_cleanup_rl_table(dev);
1031+
mlx5_vxlan_destroy(dev->vxlan);
10271032
mlx5_cleanup_clock(dev);
10281033
mlx5_cleanup_reserved_gids(dev);
10291034
mlx5_cleanup_mkey_table(dev);

‎include/linux/mlx5/driver.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ struct mlx5_clock {
818818
};
819819

820820
struct mlx5_fw_tracer;
821+
struct mlx5_vxlan;
821822

822823
struct mlx5_core_dev {
823824
struct pci_dev *pdev;
@@ -850,6 +851,7 @@ struct mlx5_core_dev {
850851
atomic_t num_qps;
851852
u32 issi;
852853
struct mlx5e_resources mlx5e_res;
854+
struct mlx5_vxlan *vxlan;
853855
struct {
854856
struct mlx5_rsvd_gids reserved_gids;
855857
u32 roce_en;

0 commit comments

Comments
 (0)