IB/mlx5: Fix binary compatibility with libmlx5
Commit c1be5232d2
("Fix micro UAR allocator") broke binary compatibility
between libmlx5 and mlx5_ib since it defines a different value to the number
of micro UARs per page, leading to wrong calculation in libmlx5. This patch
defines struct mlx5_ib_alloc_ucontext_req_v2 as an extension to struct
mlx5_ib_alloc_ucontext_req. The extended size is determined in mlx5_ib_alloc_ucontext()
and in case of old library we use uuarn 0 which works fine -- this is
acheived due to create_user_qp() falling back from high to medium then to
low class where low class will return 0. For new libraries we use the
more sophisticated allocation algorithm.
Signed-off-by: Eli Cohen <eli@mellanox.com>
Reviewed-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
This commit is contained in:
@ -536,24 +536,38 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
|
|||||||
struct ib_udata *udata)
|
struct ib_udata *udata)
|
||||||
{
|
{
|
||||||
struct mlx5_ib_dev *dev = to_mdev(ibdev);
|
struct mlx5_ib_dev *dev = to_mdev(ibdev);
|
||||||
struct mlx5_ib_alloc_ucontext_req req;
|
struct mlx5_ib_alloc_ucontext_req_v2 req;
|
||||||
struct mlx5_ib_alloc_ucontext_resp resp;
|
struct mlx5_ib_alloc_ucontext_resp resp;
|
||||||
struct mlx5_ib_ucontext *context;
|
struct mlx5_ib_ucontext *context;
|
||||||
struct mlx5_uuar_info *uuari;
|
struct mlx5_uuar_info *uuari;
|
||||||
struct mlx5_uar *uars;
|
struct mlx5_uar *uars;
|
||||||
int gross_uuars;
|
int gross_uuars;
|
||||||
int num_uars;
|
int num_uars;
|
||||||
|
int ver;
|
||||||
int uuarn;
|
int uuarn;
|
||||||
int err;
|
int err;
|
||||||
int i;
|
int i;
|
||||||
|
int reqlen;
|
||||||
|
|
||||||
if (!dev->ib_active)
|
if (!dev->ib_active)
|
||||||
return ERR_PTR(-EAGAIN);
|
return ERR_PTR(-EAGAIN);
|
||||||
|
|
||||||
err = ib_copy_from_udata(&req, udata, sizeof(req));
|
memset(&req, 0, sizeof(req));
|
||||||
|
reqlen = udata->inlen - sizeof(struct ib_uverbs_cmd_hdr);
|
||||||
|
if (reqlen == sizeof(struct mlx5_ib_alloc_ucontext_req))
|
||||||
|
ver = 0;
|
||||||
|
else if (reqlen == sizeof(struct mlx5_ib_alloc_ucontext_req_v2))
|
||||||
|
ver = 2;
|
||||||
|
else
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
|
err = ib_copy_from_udata(&req, udata, reqlen);
|
||||||
if (err)
|
if (err)
|
||||||
return ERR_PTR(err);
|
return ERR_PTR(err);
|
||||||
|
|
||||||
|
if (req.flags || req.reserved)
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
if (req.total_num_uuars > MLX5_MAX_UUARS)
|
if (req.total_num_uuars > MLX5_MAX_UUARS)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
@ -626,6 +640,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
|
|||||||
if (err)
|
if (err)
|
||||||
goto out_uars;
|
goto out_uars;
|
||||||
|
|
||||||
|
uuari->ver = ver;
|
||||||
uuari->num_low_latency_uuars = req.num_low_latency_uuars;
|
uuari->num_low_latency_uuars = req.num_low_latency_uuars;
|
||||||
uuari->uars = uars;
|
uuari->uars = uars;
|
||||||
uuari->num_uars = num_uars;
|
uuari->num_uars = num_uars;
|
||||||
|
@ -430,11 +430,17 @@ static int alloc_uuar(struct mlx5_uuar_info *uuari,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MLX5_IB_LATENCY_CLASS_MEDIUM:
|
case MLX5_IB_LATENCY_CLASS_MEDIUM:
|
||||||
uuarn = alloc_med_class_uuar(uuari);
|
if (uuari->ver < 2)
|
||||||
|
uuarn = -ENOMEM;
|
||||||
|
else
|
||||||
|
uuarn = alloc_med_class_uuar(uuari);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MLX5_IB_LATENCY_CLASS_HIGH:
|
case MLX5_IB_LATENCY_CLASS_HIGH:
|
||||||
uuarn = alloc_high_class_uuar(uuari);
|
if (uuari->ver < 2)
|
||||||
|
uuarn = -ENOMEM;
|
||||||
|
else
|
||||||
|
uuarn = alloc_high_class_uuar(uuari);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MLX5_IB_LATENCY_CLASS_FAST_PATH:
|
case MLX5_IB_LATENCY_CLASS_FAST_PATH:
|
||||||
|
@ -62,6 +62,13 @@ struct mlx5_ib_alloc_ucontext_req {
|
|||||||
__u32 num_low_latency_uuars;
|
__u32 num_low_latency_uuars;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct mlx5_ib_alloc_ucontext_req_v2 {
|
||||||
|
__u32 total_num_uuars;
|
||||||
|
__u32 num_low_latency_uuars;
|
||||||
|
__u32 flags;
|
||||||
|
__u32 reserved;
|
||||||
|
};
|
||||||
|
|
||||||
struct mlx5_ib_alloc_ucontext_resp {
|
struct mlx5_ib_alloc_ucontext_resp {
|
||||||
__u32 qp_tab_size;
|
__u32 qp_tab_size;
|
||||||
__u32 bf_reg_size;
|
__u32 bf_reg_size;
|
||||||
|
@ -227,6 +227,7 @@ struct mlx5_uuar_info {
|
|||||||
* protect uuar allocation data structs
|
* protect uuar allocation data structs
|
||||||
*/
|
*/
|
||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
|
u32 ver;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mlx5_bf {
|
struct mlx5_bf {
|
||||||
|
Reference in New Issue
Block a user