Skip to content

Commit 75850d0

Browse files
majdmellanoxdledford
authored andcommitted
IB/mlx5: Support setting Ethernet priority for Raw Packet QPs
When the user changes the Address Vector(AV) in the modify QP, he provides an SL. This SL should be translated to Ethernet Priority by taking the 3 LSB bits, and modify the QP's TIS according to this Ethernet priority. Signed-off-by: Majd Dibbiny <majd@mellanox.com> Reviewed-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 6d2f89d commit 75850d0

4 files changed

Lines changed: 57 additions & 4 deletions

File tree

‎drivers/infiniband/hw/mlx5/qp.c‎

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,33 @@ static int ib_rate_to_mlx5(struct mlx5_ib_dev *dev, u8 rate)
17521752
return rate + MLX5_STAT_RATE_OFFSET;
17531753
}
17541754

1755-
static int mlx5_set_path(struct mlx5_ib_dev *dev, const struct ib_ah_attr *ah,
1755+
static int modify_raw_packet_eth_prio(struct mlx5_core_dev *dev,
1756+
struct mlx5_ib_sq *sq, u8 sl)
1757+
{
1758+
void *in;
1759+
void *tisc;
1760+
int inlen;
1761+
int err;
1762+
1763+
inlen = MLX5_ST_SZ_BYTES(modify_tis_in);
1764+
in = mlx5_vzalloc(inlen);
1765+
if (!in)
1766+
return -ENOMEM;
1767+
1768+
MLX5_SET(modify_tis_in, in, bitmask.prio, 1);
1769+
1770+
tisc = MLX5_ADDR_OF(modify_tis_in, in, ctx);
1771+
MLX5_SET(tisc, tisc, prio, ((sl & 0x7) << 1));
1772+
1773+
err = mlx5_core_modify_tis(dev, sq->tisn, in, inlen);
1774+
1775+
kvfree(in);
1776+
1777+
return err;
1778+
}
1779+
1780+
static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
1781+
const struct ib_ah_attr *ah,
17561782
struct mlx5_qp_path *path, u8 port, int attr_mask,
17571783
u32 path_flags, const struct ib_qp_attr *attr)
17581784
{
@@ -1808,6 +1834,11 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, const struct ib_ah_attr *ah,
18081834
if (attr_mask & IB_QP_TIMEOUT)
18091835
path->ackto_lt = attr->timeout << 3;
18101836

1837+
if ((qp->ibqp.qp_type == IB_QPT_RAW_PACKET) && qp->sq.wqe_cnt)
1838+
return modify_raw_packet_eth_prio(dev->mdev,
1839+
&qp->raw_packet_qp.sq,
1840+
ah->sl & 0xf);
1841+
18111842
return 0;
18121843
}
18131844

@@ -2029,7 +2060,7 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
20292060
context->pri_path.port = attr->port_num;
20302061

20312062
if (attr_mask & IB_QP_AV) {
2032-
err = mlx5_set_path(dev, &attr->ah_attr, &context->pri_path,
2063+
err = mlx5_set_path(dev, qp, &attr->ah_attr, &context->pri_path,
20332064
attr_mask & IB_QP_PORT ? attr->port_num : qp->port,
20342065
attr_mask, 0, attr);
20352066
if (err)
@@ -2040,7 +2071,8 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
20402071
context->pri_path.ackto_lt |= attr->timeout << 3;
20412072

20422073
if (attr_mask & IB_QP_ALT_PATH) {
2043-
err = mlx5_set_path(dev, &attr->alt_ah_attr, &context->alt_path,
2074+
err = mlx5_set_path(dev, qp, &attr->alt_ah_attr,
2075+
&context->alt_path,
20442076
attr->alt_port_num, attr_mask, 0, attr);
20452077
if (err)
20462078
goto out;

‎drivers/net/ethernet/mellanox/mlx5/core/transobj.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,18 @@ int mlx5_core_create_tis(struct mlx5_core_dev *dev, u32 *in, int inlen,
235235
}
236236
EXPORT_SYMBOL(mlx5_core_create_tis);
237237

238+
int mlx5_core_modify_tis(struct mlx5_core_dev *dev, u32 tisn, u32 *in,
239+
int inlen)
240+
{
241+
u32 out[MLX5_ST_SZ_DW(modify_tis_out)] = {0};
242+
243+
MLX5_SET(modify_tis_in, in, tisn, tisn);
244+
MLX5_SET(modify_tis_in, in, opcode, MLX5_CMD_OP_MODIFY_TIS);
245+
246+
return mlx5_cmd_exec_check_status(dev, in, inlen, out, sizeof(out));
247+
}
248+
EXPORT_SYMBOL(mlx5_core_modify_tis);
249+
238250
void mlx5_core_destroy_tis(struct mlx5_core_dev *dev, u32 tisn)
239251
{
240252
u32 in[MLX5_ST_SZ_DW(destroy_tis_in)];

‎include/linux/mlx5/mlx5_ifc.h‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4052,6 +4052,13 @@ struct mlx5_ifc_modify_tis_out_bits {
40524052
u8 reserved_1[0x40];
40534053
};
40544054

4055+
struct mlx5_ifc_modify_tis_bitmask_bits {
4056+
u8 reserved_0[0x20];
4057+
4058+
u8 reserved_1[0x1f];
4059+
u8 prio[0x1];
4060+
};
4061+
40554062
struct mlx5_ifc_modify_tis_in_bits {
40564063
u8 opcode[0x10];
40574064
u8 reserved_0[0x10];
@@ -4064,7 +4071,7 @@ struct mlx5_ifc_modify_tis_in_bits {
40644071

40654072
u8 reserved_3[0x20];
40664073

4067-
u8 modify_bitmask[0x40];
4074+
struct mlx5_ifc_modify_tis_bitmask_bits bitmask;
40684075

40694076
u8 reserved_4[0x40];
40704077

‎include/linux/mlx5/transobj.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ int mlx5_core_modify_tir(struct mlx5_core_dev *dev, u32 tirn, u32 *in,
5454
void mlx5_core_destroy_tir(struct mlx5_core_dev *dev, u32 tirn);
5555
int mlx5_core_create_tis(struct mlx5_core_dev *dev, u32 *in, int inlen,
5656
u32 *tisn);
57+
int mlx5_core_modify_tis(struct mlx5_core_dev *dev, u32 tisn, u32 *in,
58+
int inlen);
5759
void mlx5_core_destroy_tis(struct mlx5_core_dev *dev, u32 tisn);
5860
int mlx5_core_create_rmp(struct mlx5_core_dev *dev, u32 *in, int inlen,
5961
u32 *rmpn);

0 commit comments

Comments
 (0)