Set BlueFlame size based on memory properties
Subsystems (2)
cover Set BlueFlame size based on memory properties
From: Leon Romanovsky <[email protected]>
Hi,
Libmlx5 needs real knowledge of BlueFlame size to properly set data path to leverage performance advantages of BF. However such advantage is visible in systems which use WC memory. Unfortunately, user space applications (and libmlx5) can't know if memory is WC or not, so we rely on in-kernel test to set BF dynamically.
Thanks
Michael Guralnik (2):
IB/mlx5: Align usage of QP1 create flags with rest of mlx5 defines IB/mlx5: Test write combining support
drivers/infiniband/hw/mlx5/gsi.c | 2 +- drivers/infiniband/hw/mlx5/main.c | 15 +- drivers/infiniband/hw/mlx5/mem.c | 200 +++++++++++++++++++++++++++ drivers/infiniband/hw/mlx5/mlx5_ib.h | 13 +- drivers/infiniband/hw/mlx5/qp.c | 12 +- 5 files changed, 229 insertions(+), 13 deletions(-)
--
2.20.1
PATCH 1/2 IB/mlx5: Align usage of QP1 create flags with rest of mlx5 defines
From: Michael Guralnik <[email protected]>
There is little value in keeping separate function for one flag, provide it directly like any other mlx5 define.
--- drivers/infiniband/hw/mlx5/gsi.c | 2 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 7 +------ drivers/infiniband/hw/mlx5/qp.c | 8 ++++---- 3 files changed, 6 insertions(+), 11 deletions(-)
drivers/infiniband/hw/mlx5/gsi.c +1 -1
@@ -263,7 +263,7 @@ static struct ib_qp *create_gsi_ud_qp(struct mlx5_ib_gsi_qp *gsi) }, .sq_sig_type = gsi->sq_sig_type, .qp_type = IB_QPT_UD, - .create_flags = mlx5_ib_create_qp_sqpn_qp1(), + .create_flags = MLX5_IB_QP_CREATE_SQPN_QP1, };return ib_create_qp (pd, &init_attr);
drivers/infiniband/hw/mlx5/mlx5_ib.h +1 -6
@@ -247,12 +247,7 @@ struct mlx5_ib_flow_db {* These flags are intended for internal use by the mlx5_ib driver, and they * rely on the range reserved for that use in the ib_qp_create_flags enum. */ - -/* Create a UD QP whose source QP number is 1 */ -static inline enum ib_qp_create_flags mlx5_ib_create_qp_sqpn_qp1 (void ) -{ -return IB_QP_CREATE_RESERVED_START ; -} +#define MLX5_IB_QP_CREATE_SQPN_QP1 IB_QP_CREATE_RESERVED_STARTstruct wr_list {u16 opcode;
drivers/infiniband/hw/mlx5/qp.c +4 -4
@@ -1041,7 +1041,7 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK |IB_QP_CREATE_IPOIB_UD_LSO |IB_QP_CREATE_NETIF_QP | - mlx5_ib_create_qp_sqpn_qp1())) + MLX5_IB_QP_CREATE_SQPN_QP1)) return -EINVAL;if (init_attr->qp_type ==MLX5_IB_QPT_REG_UMR )
@@ -1104,7 +1104,7 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,MLX5_SET (qpc, qpc, fre,1 );MLX5_SET (qpc, qpc, rlky,1 ); -if (init_attr->create_flags &mlx5_ib_create_qp_sqpn_qp1 ()) { +if (init_attr->create_flags &MLX5_IB_QP_CREATE_SQPN_QP1 ) {MLX5_SET (qpc, qpc, deth_sqpn,1 ); qp->flags |=MLX5_IB_QP_SQPN_QP1 ; }
@@ -2140,7 +2140,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,return -EINVAL ; }if (init_attr->create_flags & -mlx5_ib_create_qp_sqpn_qp1 ()) { +MLX5_IB_QP_CREATE_SQPN_QP1 ) {mlx5_ib_dbg (dev,"user-space is not allowed to create UD QPs spoofing as QP1\n" );return -EINVAL ; }
@@ -5823,7 +5823,7 @@ int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,if (qp->flags &MLX5_IB_QP_MANAGED_RECV ) qp_init_attr->create_flags |=IB_QP_CREATE_MANAGED_RECV ;if (qp->flags &MLX5_IB_QP_SQPN_QP1 ) - qp_init_attr->create_flags |=mlx5_ib_create_qp_sqpn_qp1 (); + qp_init_attr->create_flags |=MLX5_IB_QP_CREATE_SQPN_QP1 ; qp_init_attr->sq_sig_type = qp->sq_signal_bits &MLX5_WQE_CTRL_CQ_UPDATE ?IB_SIGNAL_ALL_WR :IB_SIGNAL_REQ_WR ;
--
2.20.1
PATCH 2/2 IB/mlx5: Test write combining support
In reply to Leon RomanovskyFrom: Michael Guralnik <[email protected]>
Add a test in mlx5_ib initialization process to test whether write-combining is supported on the machine.
The test will run as part of the enable_driver callback to ensure that the test runs after the device is setup and can create and modify the QP needed, but runs before the device is exposed to the users.
The test opens UD QP and posts NOP WQEs, the WQE written to the BlueFlame is different from the WQE in memory, requesting CQE only on the BlueFlame WQE. By checking whether we received a completion on one of these WQEs we can know if BlueFlame succeeded and whether write-combining is supported.
Change reporting of BlueFlame support to be dependent on write-combining support.
--- drivers/infiniband/hw/mlx5/main.c | 15 +- drivers/infiniband/hw/mlx5/mem.c | 200 +++++++++++++++++++++++++++ drivers/infiniband/hw/mlx5/mlx5_ib.h | 6 + drivers/infiniband/hw/mlx5/qp.c | 6 +- 4 files changed, 224 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mlx5/main.c +14 -1
@@ -1811,7 +1811,7 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx,return -EINVAL ; resp.qp_tab_size =1 <<MLX5_CAP_GEN (dev->mdev, log_max_qp); -if (mlx5_core_is_pf (dev->mdev) &&MLX5_CAP_GEN (dev->mdev, bf)) +if (dev->wc_support) resp.bf_reg_size =1 <<MLX5_CAP_GEN (dev->mdev, log_bf_reg_size); resp.cache_line_size =cache_line_size (); resp.max_sq_desc_sz =MLX5_CAP_GEN (dev->mdev, max_wqe_sz_sq);
@@ -6272,6 +6272,7 @@ static const struct ib_device_ops mlx5_ib_dev_ops = { .disassociate_ucontext = mlx5_ib_disassociate_ucontext, .drain_rq = mlx5_ib_drain_rq, .drain_sq = mlx5_ib_drain_sq, + .enable_driver = mlx5_ib_enable_driver, .fill_res_entry = mlx5_ib_fill_res_entry, .fill_stat_entry = mlx5_ib_fill_stat_entry, .get_dev_fw_str = get_dev_fw_str,
@@ -6715,6 +6716,18 @@ static void mlx5_ib_stage_devx_cleanup(struct mlx5_ib_dev *dev) } } +int mlx5_ib_enable_driver (struct ib_device *dev) +{ +struct mlx5_ib_dev *mdev =to_mdev (dev); +int ret; + + ret =mlx5_ib_test_wc (mdev); +mlx5_ib_dbg (mdev,"Write-Combining %s" , + mdev->wc_support ?"supported" :"not supported" ); + +return ret; +} +void __mlx5_ib_remove (struct mlx5_ib_dev *dev,const struct mlx5_ib_profile *profile,int stage)
drivers/infiniband/hw/mlx5/mem.c +200 -0
209 lines not on this page · raw message
drivers/infiniband/hw/mlx5/mlx5_ib.h +6 -0
@@ -248,6 +248,7 @@ struct mlx5_ib_flow_db {* rely on the range reserved for that use in the ib_qp_create_flags enum. */ #define MLX5_IB_QP_CREATE_SQPN_QP1 IB_QP_CREATE_RESERVED_START +#define MLX5_IB_QP_CREATE_WC_TEST (IB_QP_CREATE_RESERVED_START << 1)struct wr_list {u16 opcode;
@@ -962,6 +963,7 @@ struct mlx5_ib_dev { u8 fill_delay:1; u8 is_rep:1; u8 lag_active:1; + u8 wc_support:1;struct umr_common umrc;/* sync used page count stats */
@@ -987,6 +989,7 @@ struct mlx5_ib_dev {/* Array with num_ports elements */ struct mlx5_ib_port *port;struct mlx5_sq_bfreg bfreg; +struct mlx5_sq_bfreg wc_bfreg;struct mlx5_sq_bfreg fp_bfreg;struct mlx5_ib_delay_drop delay_drop;const struct mlx5_ib_profile *profile;
@@ -1496,4 +1499,7 @@ static inline bool mlx5_ib_can_use_umr(struct mlx5_ib_dev *dev, return true; } + +int mlx5_ib_enable_driver (struct ib_device *dev); +int mlx5_ib_test_wc (struct mlx5_ib_dev *dev);#endif /* MLX5_IB_H */
drivers/infiniband/hw/mlx5/qp.c +4 -2
@@ -1041,11 +1041,14 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK |IB_QP_CREATE_IPOIB_UD_LSO |IB_QP_CREATE_NETIF_QP | - MLX5_IB_QP_CREATE_SQPN_QP1)) +MLX5_IB_QP_CREATE_SQPN_QP1 | + MLX5_IB_QP_CREATE_WC_TEST)) return -EINVAL;if (init_attr->qp_type ==MLX5_IB_QPT_REG_UMR ) qp->bf.bfreg = &dev->fp_bfreg; +else if (init_attr->create_flags &MLX5_IB_QP_CREATE_WC_TEST ) + qp->bf.bfreg = &dev->wc_bfreg;else qp->bf.bfreg = &dev->bfreg;
@@ -5328,7 +5331,6 @@ static int _mlx5_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,* we hit doorbell */ wmb (); -/* currently we support only regular doorbells */ mlx5_write64 ((__be32 *)ctrl, bf->bfreg->map + bf->offset);/* Make sure doorbells don't leak out of SQ spinlock * and reach the HCA out of order.
--
2.20.1
Re: [PATCH rdma-next 2/2] IB/mlx5: Test write combining support
Quoted 16 lines · Leon Romanovsky
From: Michael Guralnik <[email protected]>
Add a test in
mlx5_ibinitialization process to test whether write-combining is supported on the machine.
The test will run as part of theenable_drivercallback to ensure that the test runs after the device is setup and can create and modify the QP needed, but runs before the device is exposed to the users.The test opens UD QP and posts NOP WQEs, the WQE written to the BlueFlame is different from the WQE in memory, requesting CQE only on the BlueFlame WQE. By checking whether we received a completion on one of these WQEs we can know if BlueFlame succeeded and whether write-combining is supported.
Change reporting of BlueFlame support to be dependent on write-combining support.
Quoted 9 lines
Signed-off-by Michael Guralnik <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- drivers/infiniband/hw/mlx5/main.c | 15 +- drivers/infiniband/hw/mlx5/mem.c | 200 +++++++++++++++++++++++++++ drivers/infiniband/hw/mlx5/mlx5_ib.h | 6 + drivers/infiniband/hw/mlx5/qp.c | 6 +- 4 files changed, 224 insertions(+), 3 deletions(-)
We found statistical failure with this patch and I'll resend it.
Thanks
Jason Gunthorpe
AppliedRe: [PATCH rdma-next 1/2] IB/mlx5: Align usage of QP1 create flags with rest of mlx5 defines
In reply to Leon RomanovskyQuoted 5 lines · Leon Romanovsky
From: Michael Guralnik <[email protected]>
There is little value in keeping separate function for one flag, provide it directly like any other mlx5 define.
Quoted 7 lines
Signed-off-by Michael Guralnik <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>--- drivers/infiniband/hw/mlx5/gsi.c | 2 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 7 +------ drivers/infiniband/hw/mlx5/qp.c | 8 ++++---- 3 files changed, 6 insertions(+), 11 deletions(-)
Applied to for-next, thanks
Jason