Commit 9af1968e authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Saeed Mahameed

net/mlx5: Check IPsec TX flow steering namespace in advance

Ensure that flow steering is usable as early as possible, to understand
if crypto IPsec is supported or not.
Reviewed-by: default avatarRaed Salem <raeds@nvidia.com>
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 301e0be8
...@@ -164,7 +164,6 @@ struct mlx5e_ptp_fs; ...@@ -164,7 +164,6 @@ struct mlx5e_ptp_fs;
struct mlx5e_flow_steering { struct mlx5e_flow_steering {
struct mlx5_flow_namespace *ns; struct mlx5_flow_namespace *ns;
struct mlx5_flow_namespace *egress_ns;
#ifdef CONFIG_MLX5_EN_RXNFC #ifdef CONFIG_MLX5_EN_RXNFC
struct mlx5e_ethtool_steering ethtool; struct mlx5e_ethtool_steering ethtool;
#endif #endif
......
...@@ -415,6 +415,7 @@ int mlx5e_ipsec_init(struct mlx5e_priv *priv) ...@@ -415,6 +415,7 @@ int mlx5e_ipsec_init(struct mlx5e_priv *priv)
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->en_priv = priv; ipsec->en_priv = priv;
ipsec->wq = alloc_ordered_workqueue("mlx5e_ipsec: %s", 0, ipsec->wq = alloc_ordered_workqueue("mlx5e_ipsec: %s", 0,
priv->netdev->name); priv->netdev->name);
......
...@@ -61,6 +61,7 @@ struct mlx5e_accel_fs_esp; ...@@ -61,6 +61,7 @@ struct mlx5e_accel_fs_esp;
struct mlx5e_ipsec_tx; struct mlx5e_ipsec_tx;
struct mlx5e_ipsec { struct mlx5e_ipsec {
struct mlx5_core_dev *mdev;
struct mlx5e_priv *en_priv; struct mlx5e_priv *en_priv;
DECLARE_HASHTABLE(sadb_rx, MLX5E_IPSEC_SADB_RX_BITS); DECLARE_HASHTABLE(sadb_rx, MLX5E_IPSEC_SADB_RX_BITS);
spinlock_t sadb_rx_lock; /* Protects sadb_rx */ spinlock_t sadb_rx_lock; /* Protects sadb_rx */
......
...@@ -35,6 +35,7 @@ struct mlx5e_accel_fs_esp { ...@@ -35,6 +35,7 @@ struct mlx5e_accel_fs_esp {
}; };
struct mlx5e_ipsec_tx { struct mlx5e_ipsec_tx {
struct mlx5_flow_namespace *ns;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
struct mutex mutex; /* Protect IPsec TX steering */ struct mutex mutex; /* Protect IPsec TX steering */
u32 refcnt; u32 refcnt;
...@@ -338,15 +339,9 @@ static int tx_create(struct mlx5e_priv *priv) ...@@ -338,15 +339,9 @@ static int tx_create(struct mlx5e_priv *priv)
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
int err; int err;
priv->fs.egress_ns =
mlx5_get_flow_namespace(priv->mdev,
MLX5_FLOW_NAMESPACE_EGRESS_KERNEL);
if (!priv->fs.egress_ns)
return -EOPNOTSUPP;
ft_attr.max_fte = NUM_IPSEC_FTE; ft_attr.max_fte = NUM_IPSEC_FTE;
ft_attr.autogroup.max_num_groups = 1; ft_attr.autogroup.max_num_groups = 1;
ft = mlx5_create_auto_grouped_flow_table(priv->fs.egress_ns, &ft_attr); ft = mlx5_create_auto_grouped_flow_table(ipsec->tx_fs->ns, &ft_attr);
if (IS_ERR(ft)) { if (IS_ERR(ft)) {
err = PTR_ERR(ft); err = PTR_ERR(ft);
netdev_err(priv->netdev, "fail to create ipsec tx ft err=%d\n", err); netdev_err(priv->netdev, "fail to create ipsec tx ft err=%d\n", err);
...@@ -658,9 +653,15 @@ int mlx5e_accel_ipsec_fs_init(struct mlx5e_ipsec *ipsec) ...@@ -658,9 +653,15 @@ int mlx5e_accel_ipsec_fs_init(struct mlx5e_ipsec *ipsec)
{ {
struct mlx5e_accel_fs_esp_prot *fs_prot; struct mlx5e_accel_fs_esp_prot *fs_prot;
struct mlx5e_accel_fs_esp *accel_esp; struct mlx5e_accel_fs_esp *accel_esp;
struct mlx5_flow_namespace *ns;
enum accel_fs_esp_type i; enum accel_fs_esp_type i;
int err = -ENOMEM; int err = -ENOMEM;
ns = mlx5_get_flow_namespace(ipsec->mdev,
MLX5_FLOW_NAMESPACE_EGRESS_KERNEL);
if (!ns)
return -EOPNOTSUPP;
ipsec->tx_fs = kzalloc(sizeof(*ipsec->tx_fs), GFP_KERNEL); ipsec->tx_fs = kzalloc(sizeof(*ipsec->tx_fs), GFP_KERNEL);
if (!ipsec->tx_fs) if (!ipsec->tx_fs)
return -ENOMEM; return -ENOMEM;
...@@ -670,6 +671,7 @@ int mlx5e_accel_ipsec_fs_init(struct mlx5e_ipsec *ipsec) ...@@ -670,6 +671,7 @@ int mlx5e_accel_ipsec_fs_init(struct mlx5e_ipsec *ipsec)
goto err_rx; goto err_rx;
mutex_init(&ipsec->tx_fs->mutex); mutex_init(&ipsec->tx_fs->mutex);
ipsec->tx_fs->ns = ns;
accel_esp = ipsec->rx_fs; accel_esp = ipsec->rx_fs;
for (i = 0; i < ACCEL_FS_ESP_NUM_TYPES; i++) { for (i = 0; i < ACCEL_FS_ESP_NUM_TYPES; i++) {
......
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