Skip to content

Commit b96c9dd

Browse files
mark-blochSaeed Mahameed
authored andcommitted
IB/mlx5: E-Switch, Add rule to forward traffic to vport
In order to forward traffic from representor's SQ to the right virtual function, every time an SQ is created also add the corresponding flow rule to the FDB. Signed-off-by: Mark Bloch <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 72afcf8 commit b96c9dd

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

drivers/infiniband/hw/mlx5/ib_rep.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,23 @@ struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, int vport)
102102
{
103103
return mlx5_eswitch_vport_rep(esw, vport);
104104
}
105+
106+
int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
107+
struct mlx5_ib_sq *sq)
108+
{
109+
struct mlx5_flow_handle *flow_rule;
110+
struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;
111+
112+
if (!dev->rep)
113+
return 0;
114+
115+
flow_rule =
116+
mlx5_eswitch_add_send_to_vport_rule(esw,
117+
dev->rep->vport,
118+
sq->base.mqp.qpn);
119+
if (IS_ERR(flow_rule))
120+
return PTR_ERR(flow_rule);
121+
sq->flow_rule = flow_rule;
122+
123+
return 0;
124+
}

drivers/infiniband/hw/mlx5/ib_rep.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,
1717
int vport_index);
1818
void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev);
1919
void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev);
20+
int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
21+
struct mlx5_ib_sq *sq);
2022
struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,
2123
int vport_index);
2224
#else /* CONFIG_MLX5_ESWITCH */
@@ -41,6 +43,12 @@ struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,
4143

4244
static inline void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev) {}
4345
static inline void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev) {}
46+
static inline int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
47+
struct mlx5_ib_sq *sq)
48+
{
49+
return 0;
50+
}
51+
4452
static inline
4553
struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,
4654
int vport_index)

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ struct mlx5_ib_sq {
343343
struct mlx5_ib_wq *sq;
344344
struct mlx5_ib_ubuffer ubuffer;
345345
struct mlx5_db *doorbell;
346+
struct mlx5_flow_handle *flow_rule;
346347
u32 tisn;
347348
u8 state;
348349
};

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <rdma/ib_user_verbs.h>
3737
#include <linux/mlx5/fs.h>
3838
#include "mlx5_ib.h"
39+
#include "ib_rep.h"
3940

4041
/* not supported currently */
4142
static int wq_signature;
@@ -1082,6 +1083,13 @@ static void destroy_raw_packet_qp_tis(struct mlx5_ib_dev *dev,
10821083
mlx5_core_destroy_tis(dev->mdev, sq->tisn);
10831084
}
10841085

1086+
static void destroy_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
1087+
struct mlx5_ib_sq *sq)
1088+
{
1089+
if (sq->flow_rule)
1090+
mlx5_del_flow_rules(sq->flow_rule);
1091+
}
1092+
10851093
static int create_raw_packet_qp_sq(struct mlx5_ib_dev *dev,
10861094
struct mlx5_ib_sq *sq, void *qpin,
10871095
struct ib_pd *pd)
@@ -1145,8 +1153,15 @@ static int create_raw_packet_qp_sq(struct mlx5_ib_dev *dev,
11451153
if (err)
11461154
goto err_umem;
11471155

1156+
err = create_flow_rule_vport_sq(dev, sq);
1157+
if (err)
1158+
goto err_flow;
1159+
11481160
return 0;
11491161

1162+
err_flow:
1163+
mlx5_core_destroy_sq_tracked(dev->mdev, &sq->base.mqp);
1164+
11501165
err_umem:
11511166
ib_umem_release(sq->ubuffer.umem);
11521167
sq->ubuffer.umem = NULL;
@@ -1157,6 +1172,7 @@ static int create_raw_packet_qp_sq(struct mlx5_ib_dev *dev,
11571172
static void destroy_raw_packet_qp_sq(struct mlx5_ib_dev *dev,
11581173
struct mlx5_ib_sq *sq)
11591174
{
1175+
destroy_flow_rule_vport_sq(dev, sq);
11601176
mlx5_core_destroy_sq_tracked(dev->mdev, &sq->base.mqp);
11611177
ib_umem_release(sq->ubuffer.umem);
11621178
}

0 commit comments

Comments
 (0)