Skip to content

Commit

Permalink
mlx4: convert to new udp_tunnel_nic infra
Browse files Browse the repository at this point in the history
Convert to new infra, make use of the ability to sleep in the callback.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Jul 10, 2020
1 parent 442a35a commit fb6f897
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 84 deletions.
107 changes: 25 additions & 82 deletions drivers/net/ethernet/mellanox/mlx4/en_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ int mlx4_en_start_port(struct net_device *dev)
queue_work(mdev->workqueue, &priv->rx_mode_task);

if (priv->mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)
udp_tunnel_get_rx_info(dev);
udp_tunnel_nic_reset_ntf(dev);

priv->port_up = true;

Expand Down Expand Up @@ -2628,89 +2628,32 @@ static int mlx4_en_get_phys_port_id(struct net_device *dev,
return 0;
}

static void mlx4_en_add_vxlan_offloads(struct work_struct *work)
static int mlx4_udp_tunnel_sync(struct net_device *dev, unsigned int table)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct udp_tunnel_info ti;
int ret;
struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
vxlan_add_task);

ret = mlx4_config_vxlan_port(priv->mdev->dev, priv->vxlan_port);
if (ret)
goto out;
udp_tunnel_nic_get_port(dev, table, 0, &ti);
priv->vxlan_port = ti.port;

ret = mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port,
VXLAN_STEER_BY_OUTER_MAC, 1);
out:
if (ret) {
en_err(priv, "failed setting L2 tunnel configuration ret %d\n", ret);
return;
}
}

static void mlx4_en_del_vxlan_offloads(struct work_struct *work)
{
int ret;
struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
vxlan_del_task);
ret = mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port,
VXLAN_STEER_BY_OUTER_MAC, 0);
ret = mlx4_config_vxlan_port(priv->mdev->dev, priv->vxlan_port);
if (ret)
en_err(priv, "failed setting L2 tunnel configuration ret %d\n", ret);
return ret;

priv->vxlan_port = 0;
return mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port,
VXLAN_STEER_BY_OUTER_MAC,
!!priv->vxlan_port);
}

static void mlx4_en_add_vxlan_port(struct net_device *dev,
struct udp_tunnel_info *ti)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
__be16 port = ti->port;
__be16 current_port;

if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
return;

if (ti->sa_family != AF_INET)
return;

if (priv->mdev->dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)
return;

current_port = priv->vxlan_port;
if (current_port && current_port != port) {
en_warn(priv, "vxlan port %d configured, can't add port %d\n",
ntohs(current_port), ntohs(port));
return;
}

priv->vxlan_port = port;
queue_work(priv->mdev->workqueue, &priv->vxlan_add_task);
}

static void mlx4_en_del_vxlan_port(struct net_device *dev,
struct udp_tunnel_info *ti)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
__be16 port = ti->port;
__be16 current_port;

if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
return;

if (ti->sa_family != AF_INET)
return;

if (priv->mdev->dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)
return;

current_port = priv->vxlan_port;
if (current_port != port) {
en_dbg(DRV, priv, "vxlan port %d isn't configured, ignoring\n", ntohs(port));
return;
}

queue_work(priv->mdev->workqueue, &priv->vxlan_del_task);
}
static const struct udp_tunnel_nic_info mlx4_udp_tunnels = {
.sync_table = mlx4_udp_tunnel_sync,
.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP |
UDP_TUNNEL_NIC_INFO_IPV4_ONLY,
.tables = {
{ .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
},
};

static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
struct net_device *dev,
Expand Down Expand Up @@ -2914,8 +2857,8 @@ static const struct net_device_ops mlx4_netdev_ops = {
.ndo_rx_flow_steer = mlx4_en_filter_rfs,
#endif
.ndo_get_phys_port_id = mlx4_en_get_phys_port_id,
.ndo_udp_tunnel_add = mlx4_en_add_vxlan_port,
.ndo_udp_tunnel_del = mlx4_en_del_vxlan_port,
.ndo_udp_tunnel_add = udp_tunnel_nic_add_port,
.ndo_udp_tunnel_del = udp_tunnel_nic_del_port,
.ndo_features_check = mlx4_en_features_check,
.ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate,
.ndo_bpf = mlx4_xdp,
Expand Down Expand Up @@ -2948,8 +2891,8 @@ static const struct net_device_ops mlx4_netdev_ops_master = {
.ndo_rx_flow_steer = mlx4_en_filter_rfs,
#endif
.ndo_get_phys_port_id = mlx4_en_get_phys_port_id,
.ndo_udp_tunnel_add = mlx4_en_add_vxlan_port,
.ndo_udp_tunnel_del = mlx4_en_del_vxlan_port,
.ndo_udp_tunnel_add = udp_tunnel_nic_add_port,
.ndo_udp_tunnel_del = udp_tunnel_nic_del_port,
.ndo_features_check = mlx4_en_features_check,
.ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate,
.ndo_bpf = mlx4_xdp,
Expand Down Expand Up @@ -3250,8 +3193,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate);
INIT_DELAYED_WORK(&priv->stats_task, mlx4_en_do_get_stats);
INIT_DELAYED_WORK(&priv->service_task, mlx4_en_service_task);
INIT_WORK(&priv->vxlan_add_task, mlx4_en_add_vxlan_offloads);
INIT_WORK(&priv->vxlan_del_task, mlx4_en_del_vxlan_offloads);
#ifdef CONFIG_RFS_ACCEL
INIT_LIST_HEAD(&priv->filters);
spin_lock_init(&priv->filters_lock);
Expand Down Expand Up @@ -3406,6 +3347,8 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
NETIF_F_GSO_UDP_TUNNEL |
NETIF_F_GSO_UDP_TUNNEL_CSUM |
NETIF_F_GSO_PARTIAL;

dev->udp_tunnel_nic_info = &mlx4_udp_tunnels;
}

dev->vlan_features = dev->hw_features;
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,6 @@ struct mlx4_en_priv {
struct work_struct linkstate_task;
struct delayed_work stats_task;
struct delayed_work service_task;
struct work_struct vxlan_add_task;
struct work_struct vxlan_del_task;
struct mlx4_en_perf_stats pstats;
struct mlx4_en_pkt_stats pkstats;
struct mlx4_en_counter_stats pf_stats;
Expand Down

0 comments on commit fb6f897

Please sign in to comment.