Skip to content

Commit

Permalink
net/mlx5e: rework ct offload init messages
Browse files Browse the repository at this point in the history
The changes are:
- Use mlx5_core print macros instead of netdev_warn since
  netdev is not always initialized at that stage.

- Print a warning message in case the issue is with lack of
  support for CT offload without indicating an error.

Signed-off-by: Ariel Levkovich <lariel@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
  • Loading branch information
Ariel Levkovich authored and Saeed Mahameed committed Sep 23, 2020
1 parent c756909 commit 211a536
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -1803,44 +1803,35 @@ mlx5_tc_ct_init_check_support(struct mlx5_eswitch *esw,
return 0;
}

static void
mlx5_tc_ct_init_err(struct mlx5e_rep_priv *rpriv, const char *msg, int err)
{
if (msg)
netdev_warn(rpriv->netdev,
"tc ct offload not supported, %s, err: %d\n",
msg, err);
else
netdev_warn(rpriv->netdev,
"tc ct offload not supported, err: %d\n",
err);
}
#define INIT_ERR_PREFIX "tc ct offload init failed"

int
mlx5_tc_ct_init(struct mlx5_rep_uplink_priv *uplink_priv)
{
struct mlx5_tc_ct_priv *ct_priv;
struct mlx5e_rep_priv *rpriv;
struct mlx5_core_dev *dev;
struct mlx5_eswitch *esw;
struct mlx5e_priv *priv;
const char *msg;
int err;

rpriv = container_of(uplink_priv, struct mlx5e_rep_priv, uplink_priv);
priv = netdev_priv(rpriv->netdev);
esw = priv->mdev->priv.eswitch;
dev = priv->mdev;
esw = dev->priv.eswitch;

err = mlx5_tc_ct_init_check_support(esw, &msg);
if (err) {
mlx5_tc_ct_init_err(rpriv, msg, err);
mlx5_core_warn(dev,
"tc ct offload not supported, %s\n",
msg);
goto err_support;
}

ct_priv = kzalloc(sizeof(*ct_priv), GFP_KERNEL);
if (!ct_priv) {
mlx5_tc_ct_init_err(rpriv, NULL, -ENOMEM);
if (!ct_priv)
goto err_alloc;
}

ct_priv->zone_mapping = mapping_create(sizeof(u16), 0, true);
if (IS_ERR(ct_priv->zone_mapping)) {
Expand All @@ -1859,23 +1850,27 @@ mlx5_tc_ct_init(struct mlx5_rep_uplink_priv *uplink_priv)
ct_priv->ct = mlx5_chains_create_global_table(esw_chains(esw));
if (IS_ERR(ct_priv->ct)) {
err = PTR_ERR(ct_priv->ct);
mlx5_tc_ct_init_err(rpriv, "failed to create ct table", err);
mlx5_core_warn(dev,
"%s, failed to create ct table err: %d\n",
INIT_ERR_PREFIX, err);
goto err_ct_tbl;
}

ct_priv->ct_nat = mlx5_chains_create_global_table(esw_chains(esw));
if (IS_ERR(ct_priv->ct_nat)) {
err = PTR_ERR(ct_priv->ct_nat);
mlx5_tc_ct_init_err(rpriv, "failed to create ct nat table",
err);
mlx5_core_warn(dev,
"%s, failed to create ct nat table err: %d\n",
INIT_ERR_PREFIX, err);
goto err_ct_nat_tbl;
}

ct_priv->post_ct = mlx5_chains_create_global_table(esw_chains(esw));
if (IS_ERR(ct_priv->post_ct)) {
err = PTR_ERR(ct_priv->post_ct);
mlx5_tc_ct_init_err(rpriv, "failed to create post ct table",
err);
mlx5_core_warn(dev,
"%s, failed to create post ct table err: %d\n",
INIT_ERR_PREFIX, err);
goto err_post_ct_tbl;
}

Expand Down

0 comments on commit 211a536

Please sign in to comment.