Commit 953d7715 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Saeed Mahameed

net/mlx5e: Support devlink reload of IPsec core

Change IPsec initialization flow to allow future creation of hardware
resources that should be released and allocated during devlink reload
operation. As part of that change, update function signature to be
void as no callers are actually interested in it.
Reviewed-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent dcf19b9c
...@@ -345,29 +345,27 @@ static void mlx5e_xfrm_free_state(struct xfrm_state *x) ...@@ -345,29 +345,27 @@ static void mlx5e_xfrm_free_state(struct xfrm_state *x)
kfree(sa_entry); kfree(sa_entry);
} }
int mlx5e_ipsec_init(struct mlx5e_priv *priv) void mlx5e_ipsec_init(struct mlx5e_priv *priv)
{ {
struct mlx5e_ipsec *ipsec; struct mlx5e_ipsec *ipsec;
int ret; int ret = -ENOMEM;
if (!mlx5_ipsec_device_caps(priv->mdev)) { if (!mlx5_ipsec_device_caps(priv->mdev)) {
netdev_dbg(priv->netdev, "Not an IPSec offload device\n"); netdev_dbg(priv->netdev, "Not an IPSec offload device\n");
return 0; return;
} }
ipsec = kzalloc(sizeof(*ipsec), GFP_KERNEL); ipsec = kzalloc(sizeof(*ipsec), GFP_KERNEL);
if (!ipsec) if (!ipsec)
return -ENOMEM; return;
hash_init(ipsec->sadb_rx); hash_init(ipsec->sadb_rx);
spin_lock_init(&ipsec->sadb_rx_lock); spin_lock_init(&ipsec->sadb_rx_lock);
ipsec->mdev = priv->mdev; ipsec->mdev = priv->mdev;
ipsec->wq = alloc_ordered_workqueue("mlx5e_ipsec: %s", 0, ipsec->wq = alloc_ordered_workqueue("mlx5e_ipsec: %s", 0,
priv->netdev->name); priv->netdev->name);
if (!ipsec->wq) { if (!ipsec->wq)
ret = -ENOMEM;
goto err_wq; goto err_wq;
}
ret = mlx5e_accel_ipsec_fs_init(ipsec); ret = mlx5e_accel_ipsec_fs_init(ipsec);
if (ret) if (ret)
...@@ -375,13 +373,14 @@ int mlx5e_ipsec_init(struct mlx5e_priv *priv) ...@@ -375,13 +373,14 @@ int mlx5e_ipsec_init(struct mlx5e_priv *priv)
priv->ipsec = ipsec; priv->ipsec = ipsec;
netdev_dbg(priv->netdev, "IPSec attached to netdevice\n"); netdev_dbg(priv->netdev, "IPSec attached to netdevice\n");
return 0; return;
err_fs_init: err_fs_init:
destroy_workqueue(ipsec->wq); destroy_workqueue(ipsec->wq);
err_wq: err_wq:
kfree(ipsec); kfree(ipsec);
return (ret != -EOPNOTSUPP) ? ret : 0; mlx5_core_err(priv->mdev, "IPSec initialization failed, %d\n", ret);
return;
} }
void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv) void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv)
......
...@@ -146,7 +146,7 @@ struct mlx5e_ipsec_sa_entry { ...@@ -146,7 +146,7 @@ struct mlx5e_ipsec_sa_entry {
struct mlx5e_ipsec_modify_state_work modify_work; struct mlx5e_ipsec_modify_state_work modify_work;
}; };
int mlx5e_ipsec_init(struct mlx5e_priv *priv); void mlx5e_ipsec_init(struct mlx5e_priv *priv);
void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv); void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv);
void mlx5e_ipsec_build_netdev(struct mlx5e_priv *priv); void mlx5e_ipsec_build_netdev(struct mlx5e_priv *priv);
...@@ -174,9 +174,8 @@ mlx5e_ipsec_sa2dev(struct mlx5e_ipsec_sa_entry *sa_entry) ...@@ -174,9 +174,8 @@ mlx5e_ipsec_sa2dev(struct mlx5e_ipsec_sa_entry *sa_entry)
return sa_entry->ipsec->mdev; return sa_entry->ipsec->mdev;
} }
#else #else
static inline int mlx5e_ipsec_init(struct mlx5e_priv *priv) static inline void mlx5e_ipsec_init(struct mlx5e_priv *priv)
{ {
return 0;
} }
static inline void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv) static inline void mlx5e_ipsec_cleanup(struct mlx5e_priv *priv)
......
...@@ -5238,10 +5238,6 @@ static int mlx5e_nic_init(struct mlx5_core_dev *mdev, ...@@ -5238,10 +5238,6 @@ static int mlx5e_nic_init(struct mlx5_core_dev *mdev,
} }
priv->fs = fs; priv->fs = fs;
err = mlx5e_ipsec_init(priv);
if (err)
mlx5_core_err(mdev, "IPSec initialization failed, %d\n", err);
err = mlx5e_ktls_init(priv); err = mlx5e_ktls_init(priv);
if (err) if (err)
mlx5_core_err(mdev, "TLS initialization failed, %d\n", err); mlx5_core_err(mdev, "TLS initialization failed, %d\n", err);
...@@ -5254,7 +5250,6 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv) ...@@ -5254,7 +5250,6 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
{ {
mlx5e_health_destroy_reporters(priv); mlx5e_health_destroy_reporters(priv);
mlx5e_ktls_cleanup(priv); mlx5e_ktls_cleanup(priv);
mlx5e_ipsec_cleanup(priv);
mlx5e_fs_cleanup(priv->fs); mlx5e_fs_cleanup(priv->fs);
} }
...@@ -5383,6 +5378,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv) ...@@ -5383,6 +5378,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
int err; int err;
mlx5e_fs_init_l2_addr(priv->fs, netdev); mlx5e_fs_init_l2_addr(priv->fs, netdev);
mlx5e_ipsec_init(priv);
err = mlx5e_macsec_init(priv); err = mlx5e_macsec_init(priv);
if (err) if (err)
...@@ -5446,6 +5442,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv) ...@@ -5446,6 +5442,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
mlx5_lag_remove_netdev(mdev, priv->netdev); mlx5_lag_remove_netdev(mdev, priv->netdev);
mlx5_vxlan_reset_to_default(mdev->vxlan); mlx5_vxlan_reset_to_default(mdev->vxlan);
mlx5e_macsec_cleanup(priv); mlx5e_macsec_cleanup(priv);
mlx5e_ipsec_cleanup(priv);
} }
int mlx5e_update_nic_rx(struct mlx5e_priv *priv) int mlx5e_update_nic_rx(struct mlx5e_priv *priv)
......
...@@ -751,7 +751,6 @@ static int mlx5e_init_ul_rep(struct mlx5_core_dev *mdev, ...@@ -751,7 +751,6 @@ static int mlx5e_init_ul_rep(struct mlx5_core_dev *mdev,
struct net_device *netdev) struct net_device *netdev)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
int err;
priv->fs = mlx5e_fs_init(priv->profile, mdev, priv->fs = mlx5e_fs_init(priv->profile, mdev,
!test_bit(MLX5E_STATE_DESTROYING, &priv->state)); !test_bit(MLX5E_STATE_DESTROYING, &priv->state));
...@@ -760,10 +759,6 @@ static int mlx5e_init_ul_rep(struct mlx5_core_dev *mdev, ...@@ -760,10 +759,6 @@ static int mlx5e_init_ul_rep(struct mlx5_core_dev *mdev,
return -ENOMEM; return -ENOMEM;
} }
err = mlx5e_ipsec_init(priv);
if (err)
mlx5_core_err(mdev, "Uplink rep IPsec initialization failed, %d\n", err);
mlx5e_vxlan_set_netdev_info(priv); mlx5e_vxlan_set_netdev_info(priv);
mlx5e_build_rep_params(netdev); mlx5e_build_rep_params(netdev);
mlx5e_timestamp_init(priv); mlx5e_timestamp_init(priv);
...@@ -773,7 +768,6 @@ static int mlx5e_init_ul_rep(struct mlx5_core_dev *mdev, ...@@ -773,7 +768,6 @@ static int mlx5e_init_ul_rep(struct mlx5_core_dev *mdev,
static void mlx5e_cleanup_rep(struct mlx5e_priv *priv) static void mlx5e_cleanup_rep(struct mlx5e_priv *priv)
{ {
mlx5e_fs_cleanup(priv->fs); mlx5e_fs_cleanup(priv->fs);
mlx5e_ipsec_cleanup(priv);
} }
static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv) static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)
...@@ -1112,6 +1106,8 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv) ...@@ -1112,6 +1106,8 @@ static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u16 max_mtu; u16 max_mtu;
mlx5e_ipsec_init(priv);
netdev->min_mtu = ETH_MIN_MTU; netdev->min_mtu = ETH_MIN_MTU;
mlx5_query_port_max_mtu(priv->mdev, &max_mtu, 1); mlx5_query_port_max_mtu(priv->mdev, &max_mtu, 1);
netdev->max_mtu = MLX5E_HW2SW_MTU(&priv->channels.params, max_mtu); netdev->max_mtu = MLX5E_HW2SW_MTU(&priv->channels.params, max_mtu);
...@@ -1158,6 +1154,8 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv) ...@@ -1158,6 +1154,8 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
mlx5e_rep_tc_disable(priv); mlx5e_rep_tc_disable(priv);
mlx5_lag_remove_netdev(mdev, priv->netdev); mlx5_lag_remove_netdev(mdev, priv->netdev);
mlx5_vxlan_reset_to_default(mdev->vxlan); mlx5_vxlan_reset_to_default(mdev->vxlan);
mlx5e_ipsec_cleanup(priv);
} }
static MLX5E_DEFINE_STATS_GRP(sw_rep, 0); static MLX5E_DEFINE_STATS_GRP(sw_rep, 0);
......
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