summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/mellanox/mlx5/core
diff options
context:
space:
mode:
authorOr Gerlitz <ogerlitz@mellanox.com>2017-12-20 17:53:22 +0200
committerSaeed Mahameed <saeedm@mellanox.com>2018-01-19 22:41:32 +0200
commitd8822868535eacd7ff52afb0c542361f54280108 (patch)
treeb0308fb680ea67ce1438e0a8e28b88d83514265a /drivers/net/ethernet/mellanox/mlx5/core
parent60c2530696320ee6ffe4491c17079fa403790c98 (diff)
net/mlx5e: Use vhca id as the hairpin peer identifier
The peer vhca id spans less bits vs the ifindex and can well serve for the hairpin hash key, move to use that. This is a pre-step to put more info into the hairpin hash key in downstream patch while keeping it at 32 bits. Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx5/core')
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tc.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index cf528da51243..fac8c91c261b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -111,7 +111,7 @@ struct mlx5e_hairpin_entry {
/* flows sharing the same hairpin */
struct list_head flows;
- int peer_ifindex;
+ u16 peer_vhca_id;
struct mlx5e_hairpin *hp;
};
@@ -334,13 +334,13 @@ static void mlx5e_hairpin_destroy(struct mlx5e_hairpin *hp)
}
static struct mlx5e_hairpin_entry *mlx5e_hairpin_get(struct mlx5e_priv *priv,
- int peer_ifindex)
+ u16 peer_vhca_id)
{
struct mlx5e_hairpin_entry *hpe;
hash_for_each_possible(priv->fs.tc.hairpin_tbl, hpe,
- hairpin_hlist, peer_ifindex) {
- if (hpe->peer_ifindex == peer_ifindex)
+ hairpin_hlist, peer_vhca_id) {
+ if (hpe->peer_vhca_id == peer_vhca_id)
return hpe;
}
@@ -353,16 +353,20 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv,
{
int peer_ifindex = parse_attr->mirred_ifindex;
struct mlx5_hairpin_params params;
+ struct mlx5_core_dev *peer_mdev;
struct mlx5e_hairpin_entry *hpe;
struct mlx5e_hairpin *hp;
+ u16 peer_id;
int err;
- if (!MLX5_CAP_GEN(priv->mdev, hairpin)) {
+ peer_mdev = mlx5e_hairpin_get_mdev(dev_net(priv->netdev), peer_ifindex);
+ if (!MLX5_CAP_GEN(priv->mdev, hairpin) || !MLX5_CAP_GEN(peer_mdev, hairpin)) {
netdev_warn(priv->netdev, "hairpin is not supported\n");
return -EOPNOTSUPP;
}
- hpe = mlx5e_hairpin_get(priv, peer_ifindex);
+ peer_id = MLX5_CAP_GEN(peer_mdev, vhca_id);
+ hpe = mlx5e_hairpin_get(priv, peer_id);
if (hpe)
goto attach_flow;
@@ -371,7 +375,7 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv,
return -ENOMEM;
INIT_LIST_HEAD(&hpe->flows);
- hpe->peer_ifindex = peer_ifindex;
+ hpe->peer_vhca_id = peer_id;
params.log_data_size = 15;
params.log_data_size = min_t(u8, params.log_data_size,
@@ -391,7 +395,7 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv,
hp->pair->sqn, params.log_data_size);
hpe->hp = hp;
- hash_add(priv->fs.tc.hairpin_tbl, &hpe->hairpin_hlist, peer_ifindex);
+ hash_add(priv->fs.tc.hairpin_tbl, &hpe->hairpin_hlist, peer_id);
attach_flow:
flow->nic_attr->hairpin_tirn = hpe->hp->tirn;