@@ -400,6 +400,11 @@ static inline int verbs_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num)
return ENOSYS;
}
+static inline bool check_comp_mask(uint64_t input, uint64_t supported)
+{
+ return (input & ~supported) == 0;
+}
+
int ibv_query_gid_type(struct ibv_context *context, uint8_t port_num,
unsigned int index, enum ibv_gid_type *type);
#endif /* INFINIBAND_DRIVER_H */
@@ -922,8 +922,8 @@ static struct ibv_qp *create_qp_ex(struct ibv_context *context,
goto err_free;
if (mlx4qp_attr) {
- if (mlx4qp_attr->comp_mask &
- ~(MLX4DV_QP_INIT_ATTR_MASK_RESERVED - 1)) {
+ if (!check_comp_mask(mlx4qp_attr->comp_mask,
+ MLX4DV_QP_INIT_ATTR_MASK_RESERVED - 1)) {
errno = EINVAL;
goto err_free;
}
@@ -434,7 +434,8 @@ static struct ibv_cq_ex *create_cq(struct ibv_context *context,
cmd.cqe_size = cqe_sz;
if (mlx5cq_attr) {
- if (mlx5cq_attr->comp_mask & ~(MLX5DV_CQ_INIT_ATTR_MASK_RESERVED - 1)) {
+ if (!check_comp_mask(mlx5cq_attr->comp_mask,
+ MLX5DV_CQ_INIT_ATTR_MASK_RESERVED - 1)) {
mlx5_dbg(fp, MLX5_DBG_CQ,
"Unsupported vendor comp_mask for create_cq\n");
errno = EINVAL;