Commit 358aa5ce authored by Saeed Mahameed's avatar Saeed Mahameed

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: default avatarSaeed Mahameed <saeedm@mellanox.com>
Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
parent aec4eab9
...@@ -14,8 +14,8 @@ mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o \ ...@@ -14,8 +14,8 @@ mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o \
fpga/ipsec.o fpga/tls.o fpga/ipsec.o fpga/tls.o
mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \ mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o vxlan.o \ en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o \
en_arfs.o en_fs_ethtool.o en_selftest.o en/port.o en_arfs.o en_fs_ethtool.o en_selftest.o en/port.o lib/vxlan.o
mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o
......
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
#include "wq.h" #include "wq.h"
#include "mlx5_core.h" #include "mlx5_core.h"
#include "en_stats.h" #include "en_stats.h"
#include "vxlan.h"
struct page_pool; struct page_pool;
...@@ -812,7 +811,6 @@ struct mlx5e_priv { ...@@ -812,7 +811,6 @@ struct mlx5e_priv {
u32 tx_rates[MLX5E_MAX_NUM_SQS]; u32 tx_rates[MLX5E_MAX_NUM_SQS];
struct mlx5e_flow_steering fs; struct mlx5e_flow_steering fs;
struct mlx5_vxlan *vxlan;
struct workqueue_struct *wq; struct workqueue_struct *wq;
struct work_struct update_carrier_work; struct work_struct update_carrier_work;
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#include "en_accel/tls.h" #include "en_accel/tls.h"
#include "accel/ipsec.h" #include "accel/ipsec.h"
#include "accel/tls.h" #include "accel/tls.h"
#include "vxlan.h" #include "lib/vxlan.h"
#include "en/port.h" #include "en/port.h"
#include "en/xdp.h" #include "en/xdp.h"
...@@ -2974,7 +2974,7 @@ int mlx5e_open(struct net_device *netdev) ...@@ -2974,7 +2974,7 @@ int mlx5e_open(struct net_device *netdev)
mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_UP); mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_UP);
mutex_unlock(&priv->state_lock); mutex_unlock(&priv->state_lock);
if (mlx5_vxlan_allowed(priv->vxlan)) if (mlx5_vxlan_allowed(priv->mdev->vxlan))
udp_tunnel_get_rx_info(netdev); udp_tunnel_get_rx_info(netdev);
return err; return err;
...@@ -3983,7 +3983,7 @@ static void mlx5e_vxlan_add_work(struct work_struct *work) ...@@ -3983,7 +3983,7 @@ static void mlx5e_vxlan_add_work(struct work_struct *work)
u16 port = vxlan_work->port; u16 port = vxlan_work->port;
mutex_lock(&priv->state_lock); mutex_lock(&priv->state_lock);
mlx5_vxlan_add_port(priv->vxlan, port); mlx5_vxlan_add_port(priv->mdev->vxlan, port);
mutex_unlock(&priv->state_lock); mutex_unlock(&priv->state_lock);
kfree(vxlan_work); kfree(vxlan_work);
...@@ -3997,7 +3997,7 @@ static void mlx5e_vxlan_del_work(struct work_struct *work) ...@@ -3997,7 +3997,7 @@ static void mlx5e_vxlan_del_work(struct work_struct *work)
u16 port = vxlan_work->port; u16 port = vxlan_work->port;
mutex_lock(&priv->state_lock); mutex_lock(&priv->state_lock);
mlx5_vxlan_del_port(priv->vxlan, port); mlx5_vxlan_del_port(priv->mdev->vxlan, port);
mutex_unlock(&priv->state_lock); mutex_unlock(&priv->state_lock);
kfree(vxlan_work); kfree(vxlan_work);
} }
...@@ -4028,7 +4028,7 @@ static void mlx5e_add_vxlan_port(struct net_device *netdev, ...@@ -4028,7 +4028,7 @@ static void mlx5e_add_vxlan_port(struct net_device *netdev,
if (ti->type != UDP_TUNNEL_TYPE_VXLAN) if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
return; return;
if (!mlx5_vxlan_allowed(priv->vxlan)) if (!mlx5_vxlan_allowed(priv->mdev->vxlan))
return; return;
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 1); 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, ...@@ -4042,7 +4042,7 @@ static void mlx5e_del_vxlan_port(struct net_device *netdev,
if (ti->type != UDP_TUNNEL_TYPE_VXLAN) if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
return; return;
if (!mlx5_vxlan_allowed(priv->vxlan)) if (!mlx5_vxlan_allowed(priv->mdev->vxlan))
return; return;
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 0); 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, ...@@ -4076,7 +4076,7 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
port = be16_to_cpu(udph->dest); port = be16_to_cpu(udph->dest);
/* Verify if UDP port is being offloaded by HW */ /* Verify if UDP port is being offloaded by HW */
if (mlx5_vxlan_lookup_port(priv->vxlan, port)) if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, port))
return features; return features;
} }
...@@ -4648,7 +4648,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) ...@@ -4648,7 +4648,7 @@ 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_CTAG_FILTER;
netdev->hw_features |= NETIF_F_HW_VLAN_STAG_TX; netdev->hw_features |= NETIF_F_HW_VLAN_STAG_TX;
if (mlx5_vxlan_allowed(priv->vxlan) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) { if (mlx5_vxlan_allowed(mdev->vxlan) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) {
netdev->hw_enc_features |= NETIF_F_IP_CSUM; netdev->hw_enc_features |= NETIF_F_IP_CSUM;
netdev->hw_enc_features |= NETIF_F_IPV6_CSUM; netdev->hw_enc_features |= NETIF_F_IPV6_CSUM;
netdev->hw_enc_features |= NETIF_F_TSO; netdev->hw_enc_features |= NETIF_F_TSO;
...@@ -4656,7 +4656,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) ...@@ -4656,7 +4656,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
netdev->hw_enc_features |= NETIF_F_GSO_PARTIAL; netdev->hw_enc_features |= NETIF_F_GSO_PARTIAL;
} }
if (mlx5_vxlan_allowed(priv->vxlan)) { if (mlx5_vxlan_allowed(mdev->vxlan)) {
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL | netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL |
NETIF_F_GSO_UDP_TUNNEL_CSUM; NETIF_F_GSO_UDP_TUNNEL_CSUM;
netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL | netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL |
...@@ -4758,8 +4758,6 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev, ...@@ -4758,8 +4758,6 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
int err; int err;
priv->vxlan = mlx5_vxlan_create(mdev);
mlx5e_build_nic_netdev_priv(mdev, netdev, profile, ppriv); mlx5e_build_nic_netdev_priv(mdev, netdev, profile, ppriv);
err = mlx5e_ipsec_init(priv); err = mlx5e_ipsec_init(priv);
if (err) if (err)
...@@ -4773,7 +4771,6 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev, ...@@ -4773,7 +4771,6 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
static void mlx5e_nic_cleanup(struct mlx5e_priv *priv) static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
{ {
mlx5_vxlan_destroy(priv->vxlan);
mlx5e_tls_cleanup(priv); mlx5e_tls_cleanup(priv);
mlx5e_ipsec_cleanup(priv); mlx5e_ipsec_cleanup(priv);
} }
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include "en_rep.h" #include "en_rep.h"
#include "en_tc.h" #include "en_tc.h"
#include "eswitch.h" #include "eswitch.h"
#include "vxlan.h" #include "lib/vxlan.h"
#include "fs_core.h" #include "fs_core.h"
#include "en/port.h" #include "en/port.h"
...@@ -1133,7 +1133,7 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv, ...@@ -1133,7 +1133,7 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst))) if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst)))
goto vxlan_match_offload_err; goto vxlan_match_offload_err;
if (mlx5_vxlan_lookup_port(up_priv->vxlan, be16_to_cpu(key->dst)) && if (mlx5_vxlan_lookup_port(up_priv->mdev->vxlan, be16_to_cpu(key->dst)) &&
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap))
parse_vxlan_attr(spec, f); parse_vxlan_attr(spec, f);
else { else {
...@@ -2557,7 +2557,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv, ...@@ -2557,7 +2557,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if (mlx5_vxlan_lookup_port(up_priv->vxlan, be16_to_cpu(key->tp_dst)) && if (mlx5_vxlan_lookup_port(up_priv->mdev->vxlan, be16_to_cpu(key->tp_dst)) &&
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) { MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {
tunnel_type = MLX5_HEADER_TYPE_VXLAN; tunnel_type = MLX5_HEADER_TYPE_VXLAN;
} else { } else {
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#include "accel/ipsec.h" #include "accel/ipsec.h"
#include "accel/tls.h" #include "accel/tls.h"
#include "lib/clock.h" #include "lib/clock.h"
#include "lib/vxlan.h"
#include "diag/fw_tracer.h" #include "diag/fw_tracer.h"
MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>"); 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) ...@@ -961,6 +962,8 @@ static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
mlx5_init_clock(dev); mlx5_init_clock(dev);
dev->vxlan = mlx5_vxlan_create(dev);
err = mlx5_init_rl_table(dev); err = mlx5_init_rl_table(dev);
if (err) { if (err) {
dev_err(&pdev->dev, "Failed to init rate limiting\n"); 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) ...@@ -1004,6 +1007,7 @@ static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
err_rl_cleanup: err_rl_cleanup:
mlx5_cleanup_rl_table(dev); mlx5_cleanup_rl_table(dev);
err_tables_cleanup: err_tables_cleanup:
mlx5_vxlan_destroy(dev->vxlan);
mlx5_cleanup_mkey_table(dev); mlx5_cleanup_mkey_table(dev);
mlx5_cleanup_srq_table(dev); mlx5_cleanup_srq_table(dev);
mlx5_cleanup_qp_table(dev); mlx5_cleanup_qp_table(dev);
...@@ -1024,6 +1028,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev) ...@@ -1024,6 +1028,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
mlx5_eswitch_cleanup(dev->priv.eswitch); mlx5_eswitch_cleanup(dev->priv.eswitch);
mlx5_mpfs_cleanup(dev); mlx5_mpfs_cleanup(dev);
mlx5_cleanup_rl_table(dev); mlx5_cleanup_rl_table(dev);
mlx5_vxlan_destroy(dev->vxlan);
mlx5_cleanup_clock(dev); mlx5_cleanup_clock(dev);
mlx5_cleanup_reserved_gids(dev); mlx5_cleanup_reserved_gids(dev);
mlx5_cleanup_mkey_table(dev); mlx5_cleanup_mkey_table(dev);
......
...@@ -818,6 +818,7 @@ struct mlx5_clock { ...@@ -818,6 +818,7 @@ struct mlx5_clock {
}; };
struct mlx5_fw_tracer; struct mlx5_fw_tracer;
struct mlx5_vxlan;
struct mlx5_core_dev { struct mlx5_core_dev {
struct pci_dev *pdev; struct pci_dev *pdev;
...@@ -850,6 +851,7 @@ struct mlx5_core_dev { ...@@ -850,6 +851,7 @@ struct mlx5_core_dev {
atomic_t num_qps; atomic_t num_qps;
u32 issi; u32 issi;
struct mlx5e_resources mlx5e_res; struct mlx5e_resources mlx5e_res;
struct mlx5_vxlan *vxlan;
struct { struct {
struct mlx5_rsvd_gids reserved_gids; struct mlx5_rsvd_gids reserved_gids;
u32 roce_en; u32 roce_en;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment