Commit 670c239a authored by Ariel Levkovich's avatar Ariel Levkovich Committed by Saeed Mahameed

net/mlx5e: Keep direct reference to mlx5_core_dev in tc ct

Keep and use a direct reference to the mlx5 core device in all of
tc_ct code instead of accessing it via a pointer to mlx5 eswitch
in order to support nic mode ct offload for VF devices that don't
have a valid eswitch pointer set.
Signed-off-by: default avatarAriel Levkovich <lariel@nvidia.com>
Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 89fbdbae
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
netdev_dbg(ct_priv->netdev, "ct_debug: " fmt "\n", ##args) netdev_dbg(ct_priv->netdev, "ct_debug: " fmt "\n", ##args)
struct mlx5_tc_ct_priv { struct mlx5_tc_ct_priv {
struct mlx5_eswitch *esw; struct mlx5_core_dev *dev;
const struct net_device *netdev; const struct net_device *netdev;
struct mod_hdr_tbl *mod_hdr_tbl; struct mod_hdr_tbl *mod_hdr_tbl;
struct idr fte_ids; struct idr fte_ids;
...@@ -397,7 +397,7 @@ mlx5_tc_ct_shared_counter_put(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_en ...@@ -397,7 +397,7 @@ mlx5_tc_ct_shared_counter_put(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_en
if (!refcount_dec_and_test(&entry->shared_counter->refcount)) if (!refcount_dec_and_test(&entry->shared_counter->refcount))
return; return;
mlx5_fc_destroy(ct_priv->esw->dev, entry->shared_counter->counter); mlx5_fc_destroy(ct_priv->dev, entry->shared_counter->counter);
kfree(entry->shared_counter); kfree(entry->shared_counter);
} }
...@@ -412,7 +412,7 @@ mlx5_tc_ct_entry_del_rule(struct mlx5_tc_ct_priv *ct_priv, ...@@ -412,7 +412,7 @@ mlx5_tc_ct_entry_del_rule(struct mlx5_tc_ct_priv *ct_priv,
ct_dbg("Deleting ct entry rule in zone %d", entry->tuple.zone); ct_dbg("Deleting ct entry rule in zone %d", entry->tuple.zone);
mlx5_tc_rule_delete(netdev_priv(ct_priv->netdev), zone_rule->rule, attr); mlx5_tc_rule_delete(netdev_priv(ct_priv->netdev), zone_rule->rule, attr);
mlx5e_mod_hdr_detach(ct_priv->esw->dev, mlx5e_mod_hdr_detach(ct_priv->dev,
ct_priv->mod_hdr_tbl, zone_rule->mh); ct_priv->mod_hdr_tbl, zone_rule->mh);
mapping_remove(ct_priv->labels_mapping, attr->ct_attr.ct_labels_id); mapping_remove(ct_priv->labels_mapping, attr->ct_attr.ct_labels_id);
kfree(attr); kfree(attr);
...@@ -424,7 +424,6 @@ mlx5_tc_ct_entry_del_rules(struct mlx5_tc_ct_priv *ct_priv, ...@@ -424,7 +424,6 @@ mlx5_tc_ct_entry_del_rules(struct mlx5_tc_ct_priv *ct_priv,
{ {
mlx5_tc_ct_entry_del_rule(ct_priv, entry, true); mlx5_tc_ct_entry_del_rule(ct_priv, entry, true);
mlx5_tc_ct_entry_del_rule(ct_priv, entry, false); mlx5_tc_ct_entry_del_rule(ct_priv, entry, false);
} }
static struct flow_action_entry * static struct flow_action_entry *
...@@ -451,25 +450,25 @@ mlx5_tc_ct_entry_set_registers(struct mlx5_tc_ct_priv *ct_priv, ...@@ -451,25 +450,25 @@ mlx5_tc_ct_entry_set_registers(struct mlx5_tc_ct_priv *ct_priv,
u8 zone_restore_id) u8 zone_restore_id)
{ {
enum mlx5_flow_namespace_type ns = ct_priv->ns_type; enum mlx5_flow_namespace_type ns = ct_priv->ns_type;
struct mlx5_eswitch *esw = ct_priv->esw; struct mlx5_core_dev *dev = ct_priv->dev;
int err; int err;
err = mlx5e_tc_match_to_reg_set(esw->dev, mod_acts, ns, err = mlx5e_tc_match_to_reg_set(dev, mod_acts, ns,
CTSTATE_TO_REG, ct_state); CTSTATE_TO_REG, ct_state);
if (err) if (err)
return err; return err;
err = mlx5e_tc_match_to_reg_set(esw->dev, mod_acts, ns, err = mlx5e_tc_match_to_reg_set(dev, mod_acts, ns,
MARK_TO_REG, mark); MARK_TO_REG, mark);
if (err) if (err)
return err; return err;
err = mlx5e_tc_match_to_reg_set(esw->dev, mod_acts, ns, err = mlx5e_tc_match_to_reg_set(dev, mod_acts, ns,
LABELS_TO_REG, labels_id); LABELS_TO_REG, labels_id);
if (err) if (err)
return err; return err;
err = mlx5e_tc_match_to_reg_set(esw->dev, mod_acts, ns, err = mlx5e_tc_match_to_reg_set(dev, mod_acts, ns,
ZONE_RESTORE_TO_REG, zone_restore_id); ZONE_RESTORE_TO_REG, zone_restore_id);
if (err) if (err)
return err; return err;
...@@ -479,7 +478,7 @@ mlx5_tc_ct_entry_set_registers(struct mlx5_tc_ct_priv *ct_priv, ...@@ -479,7 +478,7 @@ mlx5_tc_ct_entry_set_registers(struct mlx5_tc_ct_priv *ct_priv,
* reg_b upon miss. * reg_b upon miss.
*/ */
if (ns != MLX5_FLOW_NAMESPACE_FDB) { if (ns != MLX5_FLOW_NAMESPACE_FDB) {
err = mlx5e_tc_match_to_reg_set(esw->dev, mod_acts, ns, err = mlx5e_tc_match_to_reg_set(dev, mod_acts, ns,
NIC_ZONE_RESTORE_TO_REG, zone_restore_id); NIC_ZONE_RESTORE_TO_REG, zone_restore_id);
if (err) if (err)
return err; return err;
...@@ -564,7 +563,7 @@ mlx5_tc_ct_entry_create_nat(struct mlx5_tc_ct_priv *ct_priv, ...@@ -564,7 +563,7 @@ mlx5_tc_ct_entry_create_nat(struct mlx5_tc_ct_priv *ct_priv,
struct mlx5e_tc_mod_hdr_acts *mod_acts) struct mlx5e_tc_mod_hdr_acts *mod_acts)
{ {
struct flow_action *flow_action = &flow_rule->action; struct flow_action *flow_action = &flow_rule->action;
struct mlx5_core_dev *mdev = ct_priv->esw->dev; struct mlx5_core_dev *mdev = ct_priv->dev;
struct flow_action_entry *act; struct flow_action_entry *act;
size_t action_size; size_t action_size;
char *modact; char *modact;
...@@ -640,7 +639,7 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv, ...@@ -640,7 +639,7 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
if (err) if (err)
goto err_mapping; goto err_mapping;
*mh = mlx5e_mod_hdr_attach(ct_priv->esw->dev, *mh = mlx5e_mod_hdr_attach(ct_priv->dev,
ct_priv->mod_hdr_tbl, ct_priv->mod_hdr_tbl,
ct_priv->ns_type, ct_priv->ns_type,
&mod_acts); &mod_acts);
...@@ -721,7 +720,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, ...@@ -721,7 +720,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
return 0; return 0;
err_rule: err_rule:
mlx5e_mod_hdr_detach(ct_priv->esw->dev, mlx5e_mod_hdr_detach(ct_priv->dev,
ct_priv->mod_hdr_tbl, zone_rule->mh); ct_priv->mod_hdr_tbl, zone_rule->mh);
mapping_remove(ct_priv->labels_mapping, attr->ct_attr.ct_labels_id); mapping_remove(ct_priv->labels_mapping, attr->ct_attr.ct_labels_id);
err_mod_hdr: err_mod_hdr:
...@@ -737,7 +736,7 @@ mlx5_tc_ct_shared_counter_get(struct mlx5_tc_ct_priv *ct_priv, ...@@ -737,7 +736,7 @@ mlx5_tc_ct_shared_counter_get(struct mlx5_tc_ct_priv *ct_priv,
{ {
struct mlx5_ct_tuple rev_tuple = entry->tuple; struct mlx5_ct_tuple rev_tuple = entry->tuple;
struct mlx5_ct_shared_counter *shared_counter; struct mlx5_ct_shared_counter *shared_counter;
struct mlx5_eswitch *esw = ct_priv->esw; struct mlx5_core_dev *dev = ct_priv->dev;
struct mlx5_ct_entry *rev_entry; struct mlx5_ct_entry *rev_entry;
__be16 tmp_port; __be16 tmp_port;
...@@ -776,7 +775,7 @@ mlx5_tc_ct_shared_counter_get(struct mlx5_tc_ct_priv *ct_priv, ...@@ -776,7 +775,7 @@ mlx5_tc_ct_shared_counter_get(struct mlx5_tc_ct_priv *ct_priv,
if (!shared_counter) if (!shared_counter)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
shared_counter->counter = mlx5_fc_create(esw->dev, true); shared_counter->counter = mlx5_fc_create(dev, true);
if (IS_ERR(shared_counter->counter)) { if (IS_ERR(shared_counter->counter)) {
ct_dbg("Failed to create counter for ct entry"); ct_dbg("Failed to create counter for ct entry");
kfree(shared_counter); kfree(shared_counter);
...@@ -1159,7 +1158,7 @@ static int tc_ct_pre_ct_add_rules(struct mlx5_ct_ft *ct_ft, ...@@ -1159,7 +1158,7 @@ static int tc_ct_pre_ct_add_rules(struct mlx5_ct_ft *ct_ft,
{ {
struct mlx5_tc_ct_priv *ct_priv = ct_ft->ct_priv; struct mlx5_tc_ct_priv *ct_priv = ct_ft->ct_priv;
struct mlx5e_tc_mod_hdr_acts pre_mod_acts = {}; struct mlx5e_tc_mod_hdr_acts pre_mod_acts = {};
struct mlx5_core_dev *dev = ct_priv->esw->dev; struct mlx5_core_dev *dev = ct_priv->dev;
struct mlx5_flow_table *ft = pre_ct->ft; struct mlx5_flow_table *ft = pre_ct->ft;
struct mlx5_flow_destination dest = {}; struct mlx5_flow_destination dest = {};
struct mlx5_flow_act flow_act = {}; struct mlx5_flow_act flow_act = {};
...@@ -1246,7 +1245,7 @@ tc_ct_pre_ct_del_rules(struct mlx5_ct_ft *ct_ft, ...@@ -1246,7 +1245,7 @@ tc_ct_pre_ct_del_rules(struct mlx5_ct_ft *ct_ft,
struct mlx5_tc_ct_pre *pre_ct) struct mlx5_tc_ct_pre *pre_ct)
{ {
struct mlx5_tc_ct_priv *ct_priv = ct_ft->ct_priv; struct mlx5_tc_ct_priv *ct_priv = ct_ft->ct_priv;
struct mlx5_core_dev *dev = ct_priv->esw->dev; struct mlx5_core_dev *dev = ct_priv->dev;
mlx5_del_flow_rules(pre_ct->flow_rule); mlx5_del_flow_rules(pre_ct->flow_rule);
mlx5_del_flow_rules(pre_ct->miss_rule); mlx5_del_flow_rules(pre_ct->miss_rule);
...@@ -1260,7 +1259,7 @@ mlx5_tc_ct_alloc_pre_ct(struct mlx5_ct_ft *ct_ft, ...@@ -1260,7 +1259,7 @@ mlx5_tc_ct_alloc_pre_ct(struct mlx5_ct_ft *ct_ft,
{ {
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
struct mlx5_tc_ct_priv *ct_priv = ct_ft->ct_priv; struct mlx5_tc_ct_priv *ct_priv = ct_ft->ct_priv;
struct mlx5_core_dev *dev = ct_priv->esw->dev; struct mlx5_core_dev *dev = ct_priv->dev;
struct mlx5_flow_table_attr ft_attr = {}; struct mlx5_flow_table_attr ft_attr = {};
struct mlx5_flow_namespace *ns; struct mlx5_flow_namespace *ns;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
...@@ -1932,8 +1931,8 @@ mlx5_tc_ct_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains, ...@@ -1932,8 +1931,8 @@ mlx5_tc_ct_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains,
ct_priv->ns_type = ns_type; ct_priv->ns_type = ns_type;
ct_priv->chains = chains; ct_priv->chains = chains;
ct_priv->esw = priv->mdev->priv.eswitch;
ct_priv->netdev = priv->netdev; ct_priv->netdev = priv->netdev;
ct_priv->dev = priv->mdev;
ct_priv->mod_hdr_tbl = mod_hdr; ct_priv->mod_hdr_tbl = mod_hdr;
ct_priv->ct = mlx5_chains_create_global_table(chains); ct_priv->ct = mlx5_chains_create_global_table(chains);
if (IS_ERR(ct_priv->ct)) { if (IS_ERR(ct_priv->ct)) {
......
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