Commit 7e2304f5 authored by Patrisious Haddad's avatar Patrisious Haddad Committed by Leon Romanovsky

net/mlx5: Remove netdevice from MACsec steering

Since MACsec steering was moved from ethernet private code to core,
remove the netdevice from the MACsec steering, and use core device
methods for error reporting instead.
Signed-off-by: default avatarPatrisious Haddad <phaddad@nvidia.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
parent 2e92f669
...@@ -1804,7 +1804,7 @@ int mlx5e_macsec_init(struct mlx5e_priv *priv) ...@@ -1804,7 +1804,7 @@ int mlx5e_macsec_init(struct mlx5e_priv *priv)
macsec->mdev = mdev; macsec->mdev = mdev;
macsec_fs = mlx5_macsec_fs_init(mdev, priv->netdev); macsec_fs = mlx5_macsec_fs_init(mdev);
if (!macsec_fs) { if (!macsec_fs) {
err = -ENOMEM; err = -ENOMEM;
goto err_out; goto err_out;
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ /* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
#include <net/macsec.h> #include <net/macsec.h>
#include <linux/netdevice.h>
#include <linux/mlx5/qp.h> #include <linux/mlx5/qp.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include "fs_core.h" #include "fs_core.h"
...@@ -103,7 +102,6 @@ union mlx5_macsec_rule { ...@@ -103,7 +102,6 @@ union mlx5_macsec_rule {
struct mlx5_macsec_fs { struct mlx5_macsec_fs {
struct mlx5_core_dev *mdev; struct mlx5_core_dev *mdev;
struct net_device *netdev;
struct mlx5_macsec_tx *tx_fs; struct mlx5_macsec_tx *tx_fs;
struct mlx5_macsec_rx *rx_fs; struct mlx5_macsec_rx *rx_fs;
...@@ -267,7 +265,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -267,7 +265,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs)
{ {
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
struct mlx5_macsec_tx *tx_fs = macsec_fs->tx_fs; struct mlx5_macsec_tx *tx_fs = macsec_fs->tx_fs;
struct net_device *netdev = macsec_fs->netdev; struct mlx5_core_dev *mdev = macsec_fs->mdev;
struct mlx5_flow_table_attr ft_attr = {}; struct mlx5_flow_table_attr ft_attr = {};
struct mlx5_flow_destination dest = {}; struct mlx5_flow_destination dest = {};
struct mlx5_macsec_tables *tx_tables; struct mlx5_macsec_tables *tx_tables;
...@@ -281,7 +279,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -281,7 +279,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs)
u32 *flow_group_in; u32 *flow_group_in;
int err; int err;
ns = mlx5_get_flow_namespace(macsec_fs->mdev, MLX5_FLOW_NAMESPACE_EGRESS_MACSEC); ns = mlx5_get_flow_namespace(mdev, MLX5_FLOW_NAMESPACE_EGRESS_MACSEC);
if (!ns) if (!ns)
return -ENOMEM; return -ENOMEM;
...@@ -306,7 +304,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -306,7 +304,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs)
flow_table = mlx5_create_flow_table(ns, &ft_attr); flow_table = mlx5_create_flow_table(ns, &ft_attr);
if (IS_ERR(flow_table)) { if (IS_ERR(flow_table)) {
err = PTR_ERR(flow_table); err = PTR_ERR(flow_table);
netdev_err(netdev, "Failed to create MACsec Tx crypto table err(%d)\n", err); mlx5_core_err(mdev, "Failed to create MACsec Tx crypto table err(%d)\n", err);
goto out_flow_group; goto out_flow_group;
} }
ft_crypto->t = flow_table; ft_crypto->t = flow_table;
...@@ -314,9 +312,9 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -314,9 +312,9 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs)
/* Tx crypto table groups */ /* Tx crypto table groups */
err = macsec_fs_tx_create_crypto_table_groups(ft_crypto); err = macsec_fs_tx_create_crypto_table_groups(ft_crypto);
if (err) { if (err) {
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to create default flow group for MACsec Tx crypto table err(%d)\n", "Failed to create default flow group for MACsec Tx crypto table err(%d)\n",
err); err);
goto err; goto err;
} }
...@@ -330,7 +328,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -330,7 +328,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs)
rule = mlx5_add_flow_rules(ft_crypto->t, spec, &flow_act, NULL, 0); rule = mlx5_add_flow_rules(ft_crypto->t, spec, &flow_act, NULL, 0);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(netdev, "Failed to add MACsec TX MKE rule, err=%d\n", err); mlx5_core_err(mdev, "Failed to add MACsec TX MKE rule, err=%d\n", err);
goto err; goto err;
} }
tx_fs->crypto_mke_rule = rule; tx_fs->crypto_mke_rule = rule;
...@@ -341,7 +339,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -341,7 +339,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs)
rule = mlx5_add_flow_rules(ft_crypto->t, NULL, &flow_act, NULL, 0); rule = mlx5_add_flow_rules(ft_crypto->t, NULL, &flow_act, NULL, 0);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(netdev, "Failed to add MACsec Tx table default miss rule %d\n", err); mlx5_core_err(mdev, "Failed to add MACsec Tx table default miss rule %d\n", err);
goto err; goto err;
} }
tx_tables->crypto_miss_rule = rule; tx_tables->crypto_miss_rule = rule;
...@@ -351,7 +349,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -351,7 +349,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs)
TX_CHECK_TABLE_NUM_FTE); TX_CHECK_TABLE_NUM_FTE);
if (IS_ERR(flow_table)) { if (IS_ERR(flow_table)) {
err = PTR_ERR(flow_table); err = PTR_ERR(flow_table);
netdev_err(netdev, "fail to create MACsec TX check table, err(%d)\n", err); mlx5_core_err(mdev, "Fail to create MACsec TX check table, err(%d)\n", err);
goto err; goto err;
} }
tx_tables->ft_check = flow_table; tx_tables->ft_check = flow_table;
...@@ -363,9 +361,9 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -363,9 +361,9 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs)
flow_group = mlx5_create_flow_group(tx_tables->ft_check, flow_group_in); flow_group = mlx5_create_flow_group(tx_tables->ft_check, flow_group_in);
if (IS_ERR(flow_group)) { if (IS_ERR(flow_group)) {
err = PTR_ERR(flow_group); err = PTR_ERR(flow_group);
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to create default flow group for MACsec Tx crypto table err(%d)\n", "Failed to create default flow group for MACsec Tx crypto table err(%d)\n",
err); err);
goto err; goto err;
} }
tx_tables->ft_check_group = flow_group; tx_tables->ft_check_group = flow_group;
...@@ -379,7 +377,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -379,7 +377,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs)
rule = mlx5_add_flow_rules(tx_tables->ft_check, NULL, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(tx_tables->ft_check, NULL, &flow_act, &dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(netdev, "Failed to added MACsec tx check drop rule, err(%d)\n", err); mlx5_core_err(mdev, "Failed to added MACsec tx check drop rule, err(%d)\n", err);
goto err; goto err;
} }
tx_tables->check_miss_rule = rule; tx_tables->check_miss_rule = rule;
...@@ -400,7 +398,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -400,7 +398,7 @@ static int macsec_fs_tx_create(struct mlx5_macsec_fs *macsec_fs)
rule = mlx5_add_flow_rules(tx_tables->ft_check, spec, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(tx_tables->ft_check, spec, &flow_act, &dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(netdev, "Failed to add MACsec check rule, err=%d\n", err); mlx5_core_err(mdev, "Failed to add MACsec check rule, err=%d\n", err);
goto err; goto err;
} }
tx_fs->check_rule = rule; tx_fs->check_rule = rule;
...@@ -548,7 +546,7 @@ macsec_fs_tx_add_rule(struct mlx5_macsec_fs *macsec_fs, ...@@ -548,7 +546,7 @@ macsec_fs_tx_add_rule(struct mlx5_macsec_fs *macsec_fs,
char reformatbf[MLX5_MACSEC_TAG_LEN + MACSEC_SCI_LEN]; char reformatbf[MLX5_MACSEC_TAG_LEN + MACSEC_SCI_LEN];
struct mlx5_pkt_reformat_params reformat_params = {}; struct mlx5_pkt_reformat_params reformat_params = {};
struct mlx5_macsec_tx *tx_fs = macsec_fs->tx_fs; struct mlx5_macsec_tx *tx_fs = macsec_fs->tx_fs;
struct net_device *netdev = macsec_fs->netdev; struct mlx5_core_dev *mdev = macsec_fs->mdev;
union mlx5_macsec_rule *macsec_rule = NULL; union mlx5_macsec_rule *macsec_rule = NULL;
struct mlx5_flow_destination dest = {}; struct mlx5_flow_destination dest = {};
struct mlx5_macsec_tables *tx_tables; struct mlx5_macsec_tables *tx_tables;
...@@ -588,21 +586,21 @@ macsec_fs_tx_add_rule(struct mlx5_macsec_fs *macsec_fs, ...@@ -588,21 +586,21 @@ macsec_fs_tx_add_rule(struct mlx5_macsec_fs *macsec_fs,
if (is_vlan_dev(macsec_ctx->netdev)) if (is_vlan_dev(macsec_ctx->netdev))
reformat_params.param_0 = MLX5_REFORMAT_PARAM_ADD_MACSEC_OFFSET_4_BYTES; reformat_params.param_0 = MLX5_REFORMAT_PARAM_ADD_MACSEC_OFFSET_4_BYTES;
flow_act.pkt_reformat = mlx5_packet_reformat_alloc(macsec_fs->mdev, flow_act.pkt_reformat = mlx5_packet_reformat_alloc(mdev,
&reformat_params, &reformat_params,
MLX5_FLOW_NAMESPACE_EGRESS_MACSEC); MLX5_FLOW_NAMESPACE_EGRESS_MACSEC);
if (IS_ERR(flow_act.pkt_reformat)) { if (IS_ERR(flow_act.pkt_reformat)) {
err = PTR_ERR(flow_act.pkt_reformat); err = PTR_ERR(flow_act.pkt_reformat);
netdev_err(netdev, "Failed to allocate MACsec Tx reformat context err=%d\n", err); mlx5_core_err(mdev, "Failed to allocate MACsec Tx reformat context err=%d\n", err);
goto err; goto err;
} }
tx_rule->pkt_reformat = flow_act.pkt_reformat; tx_rule->pkt_reformat = flow_act.pkt_reformat;
err = macsec_fs_tx_setup_fte(macsec_fs, spec, &flow_act, attrs->macsec_obj_id, &fs_id); err = macsec_fs_tx_setup_fte(macsec_fs, spec, &flow_act, attrs->macsec_obj_id, &fs_id);
if (err) { if (err) {
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to add packet reformat for MACsec TX crypto rule, err=%d\n", "Failed to add packet reformat for MACsec TX crypto rule, err=%d\n",
err); err);
goto err; goto err;
} }
...@@ -617,7 +615,7 @@ macsec_fs_tx_add_rule(struct mlx5_macsec_fs *macsec_fs, ...@@ -617,7 +615,7 @@ macsec_fs_tx_add_rule(struct mlx5_macsec_fs *macsec_fs,
rule = mlx5_add_flow_rules(tx_tables->ft_crypto.t, spec, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(tx_tables->ft_crypto.t, spec, &flow_act, &dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(netdev, "Failed to add MACsec TX crypto rule, err=%d\n", err); mlx5_core_err(mdev, "Failed to add MACsec TX crypto rule, err=%d\n", err);
goto err; goto err;
} }
tx_rule->rule = rule; tx_rule->rule = rule;
...@@ -644,9 +642,9 @@ static void macsec_fs_tx_cleanup(struct mlx5_macsec_fs *macsec_fs) ...@@ -644,9 +642,9 @@ static void macsec_fs_tx_cleanup(struct mlx5_macsec_fs *macsec_fs)
tx_tables = &tx_fs->tables; tx_tables = &tx_fs->tables;
if (tx_tables->refcnt) { if (tx_tables->refcnt) {
netdev_err(macsec_fs->netdev, mlx5_core_err(mdev,
"Can't destroy MACsec offload tx_fs, refcnt(%u) isn't 0\n", "Can't destroy MACsec offload tx_fs, refcnt(%u) isn't 0\n",
tx_tables->refcnt); tx_tables->refcnt);
return; return;
} }
...@@ -668,7 +666,6 @@ static void macsec_fs_tx_cleanup(struct mlx5_macsec_fs *macsec_fs) ...@@ -668,7 +666,6 @@ static void macsec_fs_tx_cleanup(struct mlx5_macsec_fs *macsec_fs)
static int macsec_fs_tx_init(struct mlx5_macsec_fs *macsec_fs) static int macsec_fs_tx_init(struct mlx5_macsec_fs *macsec_fs)
{ {
struct net_device *netdev = macsec_fs->netdev;
struct mlx5_core_dev *mdev = macsec_fs->mdev; struct mlx5_core_dev *mdev = macsec_fs->mdev;
struct mlx5_macsec_tables *tx_tables; struct mlx5_macsec_tables *tx_tables;
struct mlx5_macsec_tx *tx_fs; struct mlx5_macsec_tx *tx_fs;
...@@ -684,9 +681,9 @@ static int macsec_fs_tx_init(struct mlx5_macsec_fs *macsec_fs) ...@@ -684,9 +681,9 @@ static int macsec_fs_tx_init(struct mlx5_macsec_fs *macsec_fs)
flow_counter = mlx5_fc_create(mdev, false); flow_counter = mlx5_fc_create(mdev, false);
if (IS_ERR(flow_counter)) { if (IS_ERR(flow_counter)) {
err = PTR_ERR(flow_counter); err = PTR_ERR(flow_counter);
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to create MACsec Tx encrypt flow counter, err(%d)\n", "Failed to create MACsec Tx encrypt flow counter, err(%d)\n",
err); err);
goto err_encrypt_counter; goto err_encrypt_counter;
} }
tx_tables->check_rule_counter = flow_counter; tx_tables->check_rule_counter = flow_counter;
...@@ -694,9 +691,9 @@ static int macsec_fs_tx_init(struct mlx5_macsec_fs *macsec_fs) ...@@ -694,9 +691,9 @@ static int macsec_fs_tx_init(struct mlx5_macsec_fs *macsec_fs)
flow_counter = mlx5_fc_create(mdev, false); flow_counter = mlx5_fc_create(mdev, false);
if (IS_ERR(flow_counter)) { if (IS_ERR(flow_counter)) {
err = PTR_ERR(flow_counter); err = PTR_ERR(flow_counter);
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to create MACsec Tx drop flow counter, err(%d)\n", "Failed to create MACsec Tx drop flow counter, err(%d)\n",
err); err);
goto err_drop_counter; goto err_drop_counter;
} }
tx_tables->check_miss_rule_counter = flow_counter; tx_tables->check_miss_rule_counter = flow_counter;
...@@ -856,7 +853,7 @@ static int macsec_fs_rx_create_check_decap_rule(struct mlx5_macsec_fs *macsec_fs ...@@ -856,7 +853,7 @@ static int macsec_fs_rx_create_check_decap_rule(struct mlx5_macsec_fs *macsec_fs
u8 mlx5_reformat_buf[MLX5_SECTAG_HEADER_SIZE_WITH_SCI]; u8 mlx5_reformat_buf[MLX5_SECTAG_HEADER_SIZE_WITH_SCI];
struct mlx5_pkt_reformat_params reformat_params = {}; struct mlx5_pkt_reformat_params reformat_params = {};
struct mlx5_macsec_rx *rx_fs = macsec_fs->rx_fs; struct mlx5_macsec_rx *rx_fs = macsec_fs->rx_fs;
struct net_device *netdev = macsec_fs->netdev; struct mlx5_core_dev *mdev = macsec_fs->mdev;
struct mlx5_macsec_tables *rx_tables; struct mlx5_macsec_tables *rx_tables;
struct mlx5_flow_handle *rule; struct mlx5_flow_handle *rule;
int err = 0; int err = 0;
...@@ -871,12 +868,12 @@ static int macsec_fs_rx_create_check_decap_rule(struct mlx5_macsec_fs *macsec_fs ...@@ -871,12 +868,12 @@ static int macsec_fs_rx_create_check_decap_rule(struct mlx5_macsec_fs *macsec_fs
reformat_params.type = MLX5_REFORMAT_TYPE_DEL_MACSEC; reformat_params.type = MLX5_REFORMAT_TYPE_DEL_MACSEC;
reformat_params.size = reformat_param_size; reformat_params.size = reformat_param_size;
reformat_params.data = mlx5_reformat_buf; reformat_params.data = mlx5_reformat_buf;
flow_act->pkt_reformat = mlx5_packet_reformat_alloc(macsec_fs->mdev, flow_act->pkt_reformat = mlx5_packet_reformat_alloc(mdev,
&reformat_params, &reformat_params,
MLX5_FLOW_NAMESPACE_KERNEL_RX_MACSEC); MLX5_FLOW_NAMESPACE_KERNEL_RX_MACSEC);
if (IS_ERR(flow_act->pkt_reformat)) { if (IS_ERR(flow_act->pkt_reformat)) {
err = PTR_ERR(flow_act->pkt_reformat); err = PTR_ERR(flow_act->pkt_reformat);
netdev_err(netdev, "Failed to allocate MACsec Rx reformat context err=%d\n", err); mlx5_core_err(mdev, "Failed to allocate MACsec Rx reformat context err=%d\n", err);
return err; return err;
} }
rx_fs->check_rule_pkt_reformat[rule_index] = flow_act->pkt_reformat; rx_fs->check_rule_pkt_reformat[rule_index] = flow_act->pkt_reformat;
...@@ -908,7 +905,7 @@ static int macsec_fs_rx_create_check_decap_rule(struct mlx5_macsec_fs *macsec_fs ...@@ -908,7 +905,7 @@ static int macsec_fs_rx_create_check_decap_rule(struct mlx5_macsec_fs *macsec_fs
rule = mlx5_add_flow_rules(rx_tables->ft_check, spec, flow_act, dest, 1); rule = mlx5_add_flow_rules(rx_tables->ft_check, spec, flow_act, dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(netdev, "Failed to add MACsec Rx check rule, err=%d\n", err); mlx5_core_err(mdev, "Failed to add MACsec Rx check rule, err=%d\n", err);
return err; return err;
} }
...@@ -921,7 +918,7 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -921,7 +918,7 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs)
{ {
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
struct mlx5_macsec_rx *rx_fs = macsec_fs->rx_fs; struct mlx5_macsec_rx *rx_fs = macsec_fs->rx_fs;
struct net_device *netdev = macsec_fs->netdev; struct mlx5_core_dev *mdev = macsec_fs->mdev;
struct mlx5_macsec_flow_table *ft_crypto; struct mlx5_macsec_flow_table *ft_crypto;
struct mlx5_flow_table_attr ft_attr = {}; struct mlx5_flow_table_attr ft_attr = {};
struct mlx5_flow_destination dest = {}; struct mlx5_flow_destination dest = {};
...@@ -935,7 +932,7 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -935,7 +932,7 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs)
u32 *flow_group_in; u32 *flow_group_in;
int err; int err;
ns = mlx5_get_flow_namespace(macsec_fs->mdev, MLX5_FLOW_NAMESPACE_KERNEL_RX_MACSEC); ns = mlx5_get_flow_namespace(mdev, MLX5_FLOW_NAMESPACE_KERNEL_RX_MACSEC);
if (!ns) if (!ns)
return -ENOMEM; return -ENOMEM;
...@@ -959,7 +956,7 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -959,7 +956,7 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs)
flow_table = mlx5_create_flow_table(ns, &ft_attr); flow_table = mlx5_create_flow_table(ns, &ft_attr);
if (IS_ERR(flow_table)) { if (IS_ERR(flow_table)) {
err = PTR_ERR(flow_table); err = PTR_ERR(flow_table);
netdev_err(netdev, "Failed to create MACsec Rx crypto table err(%d)\n", err); mlx5_core_err(mdev, "Failed to create MACsec Rx crypto table err(%d)\n", err);
goto out_flow_group; goto out_flow_group;
} }
ft_crypto->t = flow_table; ft_crypto->t = flow_table;
...@@ -967,9 +964,9 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -967,9 +964,9 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs)
/* Rx crypto table groups */ /* Rx crypto table groups */
err = macsec_fs_rx_create_crypto_table_groups(ft_crypto); err = macsec_fs_rx_create_crypto_table_groups(ft_crypto);
if (err) { if (err) {
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to create default flow group for MACsec Tx crypto table err(%d)\n", "Failed to create default flow group for MACsec Tx crypto table err(%d)\n",
err); err);
goto err; goto err;
} }
...@@ -977,9 +974,9 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -977,9 +974,9 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs)
rule = mlx5_add_flow_rules(ft_crypto->t, NULL, &flow_act, NULL, 0); rule = mlx5_add_flow_rules(ft_crypto->t, NULL, &flow_act, NULL, 0);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to add MACsec Rx crypto table default miss rule %d\n", "Failed to add MACsec Rx crypto table default miss rule %d\n",
err); err);
goto err; goto err;
} }
rx_tables->crypto_miss_rule = rule; rx_tables->crypto_miss_rule = rule;
...@@ -991,7 +988,7 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -991,7 +988,7 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs)
RX_CHECK_TABLE_NUM_FTE); RX_CHECK_TABLE_NUM_FTE);
if (IS_ERR(flow_table)) { if (IS_ERR(flow_table)) {
err = PTR_ERR(flow_table); err = PTR_ERR(flow_table);
netdev_err(netdev, "fail to create MACsec RX check table, err(%d)\n", err); mlx5_core_err(mdev, "Fail to create MACsec RX check table, err(%d)\n", err);
goto err; goto err;
} }
rx_tables->ft_check = flow_table; rx_tables->ft_check = flow_table;
...@@ -1002,9 +999,9 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -1002,9 +999,9 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs)
flow_group = mlx5_create_flow_group(rx_tables->ft_check, flow_group_in); flow_group = mlx5_create_flow_group(rx_tables->ft_check, flow_group_in);
if (IS_ERR(flow_group)) { if (IS_ERR(flow_group)) {
err = PTR_ERR(flow_group); err = PTR_ERR(flow_group);
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to create default flow group for MACsec Rx check table err(%d)\n", "Failed to create default flow group for MACsec Rx check table err(%d)\n",
err); err);
goto err; goto err;
} }
rx_tables->ft_check_group = flow_group; rx_tables->ft_check_group = flow_group;
...@@ -1018,7 +1015,7 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs) ...@@ -1018,7 +1015,7 @@ static int macsec_fs_rx_create(struct mlx5_macsec_fs *macsec_fs)
rule = mlx5_add_flow_rules(rx_tables->ft_check, NULL, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(rx_tables->ft_check, NULL, &flow_act, &dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(netdev, "Failed to added MACsec Rx check drop rule, err(%d)\n", err); mlx5_core_err(mdev, "Failed to added MACsec Rx check drop rule, err(%d)\n", err);
goto err; goto err;
} }
rx_tables->check_miss_rule = rule; rx_tables->check_miss_rule = rule;
...@@ -1147,7 +1144,7 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs, ...@@ -1147,7 +1144,7 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs,
{ {
u8 action[MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto)] = {}; u8 action[MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto)] = {};
struct mlx5_macsec_rx *rx_fs = macsec_fs->rx_fs; struct mlx5_macsec_rx *rx_fs = macsec_fs->rx_fs;
struct net_device *netdev = macsec_fs->netdev; struct mlx5_core_dev *mdev = macsec_fs->mdev;
union mlx5_macsec_rule *macsec_rule = NULL; union mlx5_macsec_rule *macsec_rule = NULL;
struct mlx5_modify_hdr *modify_hdr = NULL; struct mlx5_modify_hdr *modify_hdr = NULL;
struct mlx5_macsec_flow_table *ft_crypto; struct mlx5_macsec_flow_table *ft_crypto;
...@@ -1185,11 +1182,11 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs, ...@@ -1185,11 +1182,11 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs,
MLX5_SET(set_action_in, action, offset, 0); MLX5_SET(set_action_in, action, offset, 0);
MLX5_SET(set_action_in, action, length, 32); MLX5_SET(set_action_in, action, length, 32);
modify_hdr = mlx5_modify_header_alloc(macsec_fs->mdev, MLX5_FLOW_NAMESPACE_KERNEL_RX_MACSEC, modify_hdr = mlx5_modify_header_alloc(mdev, MLX5_FLOW_NAMESPACE_KERNEL_RX_MACSEC,
1, action); 1, action);
if (IS_ERR(modify_hdr)) { if (IS_ERR(modify_hdr)) {
err = PTR_ERR(modify_hdr); err = PTR_ERR(modify_hdr);
netdev_err(netdev, "fail to alloc MACsec set modify_header_id err=%d\n", err); mlx5_core_err(mdev, "Fail to alloc MACsec set modify_header_id err=%d\n", err);
modify_hdr = NULL; modify_hdr = NULL;
goto err; goto err;
} }
...@@ -1208,9 +1205,9 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs, ...@@ -1208,9 +1205,9 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs,
rule = mlx5_add_flow_rules(ft_crypto->t, spec, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(ft_crypto->t, spec, &flow_act, &dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to add SA with SCI rule to Rx crypto rule, err=%d\n", "Failed to add SA with SCI rule to Rx crypto rule, err=%d\n",
err); err);
goto err; goto err;
} }
rx_rule->rule[0] = rule; rx_rule->rule[0] = rule;
...@@ -1233,9 +1230,9 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs, ...@@ -1233,9 +1230,9 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs,
rule = mlx5_add_flow_rules(ft_crypto->t, spec, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(ft_crypto->t, spec, &flow_act, &dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to add SA without SCI rule to Rx crypto rule, err=%d\n", "Failed to add SA without SCI rule to Rx crypto rule, err=%d\n",
err); err);
goto err; goto err;
} }
rx_rule->rule[1] = rule; rx_rule->rule[1] = rule;
...@@ -1254,7 +1251,6 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs, ...@@ -1254,7 +1251,6 @@ macsec_fs_rx_add_rule(struct mlx5_macsec_fs *macsec_fs,
static int macsec_fs_rx_init(struct mlx5_macsec_fs *macsec_fs) static int macsec_fs_rx_init(struct mlx5_macsec_fs *macsec_fs)
{ {
struct net_device *netdev = macsec_fs->netdev;
struct mlx5_core_dev *mdev = macsec_fs->mdev; struct mlx5_core_dev *mdev = macsec_fs->mdev;
struct mlx5_macsec_tables *rx_tables; struct mlx5_macsec_tables *rx_tables;
struct mlx5_macsec_rx *rx_fs; struct mlx5_macsec_rx *rx_fs;
...@@ -1268,9 +1264,9 @@ static int macsec_fs_rx_init(struct mlx5_macsec_fs *macsec_fs) ...@@ -1268,9 +1264,9 @@ static int macsec_fs_rx_init(struct mlx5_macsec_fs *macsec_fs)
flow_counter = mlx5_fc_create(mdev, false); flow_counter = mlx5_fc_create(mdev, false);
if (IS_ERR(flow_counter)) { if (IS_ERR(flow_counter)) {
err = PTR_ERR(flow_counter); err = PTR_ERR(flow_counter);
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to create MACsec Rx encrypt flow counter, err(%d)\n", "Failed to create MACsec Rx encrypt flow counter, err(%d)\n",
err); err);
goto err_encrypt_counter; goto err_encrypt_counter;
} }
...@@ -1280,9 +1276,9 @@ static int macsec_fs_rx_init(struct mlx5_macsec_fs *macsec_fs) ...@@ -1280,9 +1276,9 @@ static int macsec_fs_rx_init(struct mlx5_macsec_fs *macsec_fs)
flow_counter = mlx5_fc_create(mdev, false); flow_counter = mlx5_fc_create(mdev, false);
if (IS_ERR(flow_counter)) { if (IS_ERR(flow_counter)) {
err = PTR_ERR(flow_counter); err = PTR_ERR(flow_counter);
netdev_err(netdev, mlx5_core_err(mdev,
"Failed to create MACsec Rx drop flow counter, err(%d)\n", "Failed to create MACsec Rx drop flow counter, err(%d)\n",
err); err);
goto err_drop_counter; goto err_drop_counter;
} }
rx_tables->check_miss_rule_counter = flow_counter; rx_tables->check_miss_rule_counter = flow_counter;
...@@ -1314,9 +1310,9 @@ static void macsec_fs_rx_cleanup(struct mlx5_macsec_fs *macsec_fs) ...@@ -1314,9 +1310,9 @@ static void macsec_fs_rx_cleanup(struct mlx5_macsec_fs *macsec_fs)
rx_tables = &rx_fs->tables; rx_tables = &rx_fs->tables;
if (rx_tables->refcnt) { if (rx_tables->refcnt) {
netdev_err(macsec_fs->netdev, mlx5_core_err(mdev,
"Can't destroy MACsec offload rx_fs, refcnt(%u) isn't 0\n", "Can't destroy MACsec offload rx_fs, refcnt(%u) isn't 0\n",
rx_tables->refcnt); rx_tables->refcnt);
return; return;
} }
...@@ -1394,8 +1390,7 @@ void mlx5_macsec_fs_cleanup(struct mlx5_macsec_fs *macsec_fs) ...@@ -1394,8 +1390,7 @@ void mlx5_macsec_fs_cleanup(struct mlx5_macsec_fs *macsec_fs)
} }
struct mlx5_macsec_fs * struct mlx5_macsec_fs *
mlx5_macsec_fs_init(struct mlx5_core_dev *mdev, mlx5_macsec_fs_init(struct mlx5_core_dev *mdev)
struct net_device *netdev)
{ {
struct mlx5_macsec_fs *macsec_fs; struct mlx5_macsec_fs *macsec_fs;
int err; int err;
...@@ -1405,17 +1400,16 @@ mlx5_macsec_fs_init(struct mlx5_core_dev *mdev, ...@@ -1405,17 +1400,16 @@ mlx5_macsec_fs_init(struct mlx5_core_dev *mdev,
return NULL; return NULL;
macsec_fs->mdev = mdev; macsec_fs->mdev = mdev;
macsec_fs->netdev = netdev;
err = macsec_fs_tx_init(macsec_fs); err = macsec_fs_tx_init(macsec_fs);
if (err) { if (err) {
netdev_err(netdev, "MACsec offload: Failed to init tx_fs, err=%d\n", err); mlx5_core_err(mdev, "MACsec offload: Failed to init tx_fs, err=%d\n", err);
goto err; goto err;
} }
err = macsec_fs_rx_init(macsec_fs); err = macsec_fs_rx_init(macsec_fs);
if (err) { if (err) {
netdev_err(netdev, "MACsec offload: Failed to init tx_fs, err=%d\n", err); mlx5_core_err(mdev, "MACsec offload: Failed to init tx_fs, err=%d\n", err);
goto tx_cleanup; goto tx_cleanup;
} }
......
...@@ -43,7 +43,7 @@ enum mlx5_macsec_action { ...@@ -43,7 +43,7 @@ enum mlx5_macsec_action {
void mlx5_macsec_fs_cleanup(struct mlx5_macsec_fs *macsec_fs); void mlx5_macsec_fs_cleanup(struct mlx5_macsec_fs *macsec_fs);
struct mlx5_macsec_fs * struct mlx5_macsec_fs *
mlx5_macsec_fs_init(struct mlx5_core_dev *mdev, struct net_device *netdev); mlx5_macsec_fs_init(struct mlx5_core_dev *mdev);
union mlx5_macsec_rule * union mlx5_macsec_rule *
mlx5_macsec_fs_add_rule(struct mlx5_macsec_fs *macsec_fs, mlx5_macsec_fs_add_rule(struct mlx5_macsec_fs *macsec_fs,
......
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