Skip to content

Commit

Permalink
qede: convert to new udp_tunnel_nic infra
Browse files Browse the repository at this point in the history
Covert to new infra. Looks like this driver was not doing
ref counting, and sleeping in the callback.

Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
kuba-moo authored and davem330 committed Jul 15, 2020
1 parent f7529b4 commit 8cd160a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 103 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/qlogic/qede/qede.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ void qede_set_dcbnl_ops(struct net_device *ndev);

void qede_config_debug(uint debug, u32 *p_dp_module, u8 *p_dp_level);
void qede_set_ethtool_ops(struct net_device *netdev);
void qede_set_udp_tunnels(struct qede_dev *edev);
void qede_reload(struct qede_dev *edev,
struct qede_reload_args *args, bool is_locked);
int qede_change_mtu(struct net_device *dev, int new_mtu);
Expand Down
142 changes: 47 additions & 95 deletions drivers/net/ethernet/qlogic/qede/qede_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,115 +953,67 @@ int qede_set_features(struct net_device *dev, netdev_features_t features)
return 0;
}

void qede_udp_tunnel_add(struct net_device *dev, struct udp_tunnel_info *ti)
static int qede_udp_tunnel_sync(struct net_device *dev, unsigned int table)
{
struct qede_dev *edev = netdev_priv(dev);
struct qed_tunn_params tunn_params;
u16 t_port = ntohs(ti->port);
struct udp_tunnel_info ti;
u16 *save_port;
int rc;

memset(&tunn_params, 0, sizeof(tunn_params));

switch (ti->type) {
case UDP_TUNNEL_TYPE_VXLAN:
if (!edev->dev_info.common.vxlan_enable)
return;

if (edev->vxlan_dst_port)
return;

udp_tunnel_nic_get_port(dev, table, 0, &ti);
if (ti.type == UDP_TUNNEL_TYPE_VXLAN) {
tunn_params.update_vxlan_port = 1;
tunn_params.vxlan_port = t_port;

__qede_lock(edev);
rc = edev->ops->tunn_config(edev->cdev, &tunn_params);
__qede_unlock(edev);

if (!rc) {
edev->vxlan_dst_port = t_port;
DP_VERBOSE(edev, QED_MSG_DEBUG, "Added vxlan port=%d\n",
t_port);
} else {
DP_NOTICE(edev, "Failed to add vxlan UDP port=%d\n",
t_port);
}

break;
case UDP_TUNNEL_TYPE_GENEVE:
if (!edev->dev_info.common.geneve_enable)
return;

if (edev->geneve_dst_port)
return;

tunn_params.vxlan_port = ntohs(ti.port);
save_port = &edev->vxlan_dst_port;
} else {
tunn_params.update_geneve_port = 1;
tunn_params.geneve_port = t_port;

__qede_lock(edev);
rc = edev->ops->tunn_config(edev->cdev, &tunn_params);
__qede_unlock(edev);

if (!rc) {
edev->geneve_dst_port = t_port;
DP_VERBOSE(edev, QED_MSG_DEBUG,
"Added geneve port=%d\n", t_port);
} else {
DP_NOTICE(edev, "Failed to add geneve UDP port=%d\n",
t_port);
}

break;
default:
return;
tunn_params.geneve_port = ntohs(ti.port);
save_port = &edev->geneve_dst_port;
}
}

void qede_udp_tunnel_del(struct net_device *dev,
struct udp_tunnel_info *ti)
{
struct qede_dev *edev = netdev_priv(dev);
struct qed_tunn_params tunn_params;
u16 t_port = ntohs(ti->port);

memset(&tunn_params, 0, sizeof(tunn_params));

switch (ti->type) {
case UDP_TUNNEL_TYPE_VXLAN:
if (t_port != edev->vxlan_dst_port)
return;

tunn_params.update_vxlan_port = 1;
tunn_params.vxlan_port = 0;

__qede_lock(edev);
edev->ops->tunn_config(edev->cdev, &tunn_params);
__qede_unlock(edev);

edev->vxlan_dst_port = 0;

DP_VERBOSE(edev, QED_MSG_DEBUG, "Deleted vxlan port=%d\n",
t_port);

break;
case UDP_TUNNEL_TYPE_GENEVE:
if (t_port != edev->geneve_dst_port)
return;

tunn_params.update_geneve_port = 1;
tunn_params.geneve_port = 0;
__qede_lock(edev);
rc = edev->ops->tunn_config(edev->cdev, &tunn_params);
__qede_unlock(edev);
if (rc)
return rc;

__qede_lock(edev);
edev->ops->tunn_config(edev->cdev, &tunn_params);
__qede_unlock(edev);
*save_port = ntohs(ti.port);
return 0;
}

edev->geneve_dst_port = 0;
static const struct udp_tunnel_nic_info qede_udp_tunnels_both = {
.sync_table = qede_udp_tunnel_sync,
.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP,
.tables = {
{ .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
{ .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, },
},
}, qede_udp_tunnels_vxlan = {
.sync_table = qede_udp_tunnel_sync,
.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP,
.tables = {
{ .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
},
}, qede_udp_tunnels_geneve = {
.sync_table = qede_udp_tunnel_sync,
.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP,
.tables = {
{ .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, },
},
};

DP_VERBOSE(edev, QED_MSG_DEBUG, "Deleted geneve port=%d\n",
t_port);
break;
default:
return;
}
void qede_set_udp_tunnels(struct qede_dev *edev)
{
if (edev->dev_info.common.vxlan_enable &&
edev->dev_info.common.geneve_enable)
edev->ndev->udp_tunnel_nic_info = &qede_udp_tunnels_both;
else if (edev->dev_info.common.vxlan_enable)
edev->ndev->udp_tunnel_nic_info = &qede_udp_tunnels_vxlan;
else if (edev->dev_info.common.geneve_enable)
edev->ndev->udp_tunnel_nic_info = &qede_udp_tunnels_geneve;
}

static void qede_xdp_reload_func(struct qede_dev *edev,
Expand Down
18 changes: 10 additions & 8 deletions drivers/net/ethernet/qlogic/qede/qede_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ static const struct net_device_ops qede_netdev_ops = {
.ndo_get_vf_config = qede_get_vf_config,
.ndo_set_vf_rate = qede_set_vf_rate,
#endif
.ndo_udp_tunnel_add = qede_udp_tunnel_add,
.ndo_udp_tunnel_del = qede_udp_tunnel_del,
.ndo_udp_tunnel_add = udp_tunnel_nic_add_port,
.ndo_udp_tunnel_del = udp_tunnel_nic_del_port,
.ndo_features_check = qede_features_check,
.ndo_bpf = qede_xdp,
#ifdef CONFIG_RFS_ACCEL
Expand All @@ -687,8 +687,8 @@ static const struct net_device_ops qede_netdev_vf_ops = {
.ndo_fix_features = qede_fix_features,
.ndo_set_features = qede_set_features,
.ndo_get_stats64 = qede_get_stats64,
.ndo_udp_tunnel_add = qede_udp_tunnel_add,
.ndo_udp_tunnel_del = qede_udp_tunnel_del,
.ndo_udp_tunnel_add = udp_tunnel_nic_add_port,
.ndo_udp_tunnel_del = udp_tunnel_nic_del_port,
.ndo_features_check = qede_features_check,
};

Expand All @@ -706,8 +706,8 @@ static const struct net_device_ops qede_netdev_vf_xdp_ops = {
.ndo_fix_features = qede_fix_features,
.ndo_set_features = qede_set_features,
.ndo_get_stats64 = qede_get_stats64,
.ndo_udp_tunnel_add = qede_udp_tunnel_add,
.ndo_udp_tunnel_del = qede_udp_tunnel_del,
.ndo_udp_tunnel_add = udp_tunnel_nic_add_port,
.ndo_udp_tunnel_del = udp_tunnel_nic_del_port,
.ndo_features_check = qede_features_check,
.ndo_bpf = qede_xdp,
};
Expand Down Expand Up @@ -822,6 +822,8 @@ static void qede_init_ndev(struct qede_dev *edev)
NETIF_F_GSO_UDP_TUNNEL_CSUM);
ndev->hw_enc_features |= (NETIF_F_GSO_UDP_TUNNEL |
NETIF_F_GSO_UDP_TUNNEL_CSUM);

qede_set_udp_tunnels(edev);
}

if (edev->dev_info.common.gre_enable) {
Expand Down Expand Up @@ -2421,7 +2423,7 @@ static int qede_open(struct net_device *ndev)
if (rc)
return rc;

udp_tunnel_get_rx_info(ndev);
udp_tunnel_nic_reset_ntf(ndev);

edev->ops->common->update_drv_state(edev->cdev, true);

Expand Down Expand Up @@ -2523,7 +2525,7 @@ static void qede_recovery_handler(struct qede_dev *edev)
goto err;

qede_config_rx_mode(edev->ndev);
udp_tunnel_get_rx_info(edev->ndev);
udp_tunnel_nic_reset_ntf(edev->ndev);
}

edev->state = curr_state;
Expand Down

0 comments on commit 8cd160a

Please sign in to comment.