diff mbox

[for-next,08/10] IB/mlx4: Add support for timestamp in cq creation

Message ID 1431869786-6308-9-git-send-email-ogerlitz@mellanox.com (mailing list archive)
State Superseded
Headers show

Commit Message

Or Gerlitz May 17, 2015, 1:36 p.m. UTC
From: Matan Barak <matanb@mellanox.com>

Support allocation of CQ with IB_CQ_FLAGS_TIMESTAMP
creation flag.

Signed-off-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
---
 drivers/infiniband/hw/mlx4/cq.c      |    9 ++++++---
 drivers/infiniband/hw/mlx4/mlx4_ib.h |    1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Jason Gunthorpe May 19, 2015, 6:55 p.m. UTC | #1
On Sun, May 17, 2015 at 04:36:24PM +0300, Or Gerlitz wrote:
> @@ -110,6 +110,7 @@ struct mlx4_ib_cq {
>  	struct mutex		resize_mutex;
>  	struct ib_umem	       *umem;
>  	struct ib_umem	       *resize_umem;
> +	int			create_flags;

flags is u32
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sagi Grimberg May 20, 2015, 8:56 a.m. UTC | #2
On 5/19/2015 9:55 PM, Jason Gunthorpe wrote:
> On Sun, May 17, 2015 at 04:36:24PM +0300, Or Gerlitz wrote:
>> @@ -110,6 +110,7 @@ struct mlx4_ib_cq {
>>   	struct mutex		resize_mutex;
>>   	struct ib_umem	       *umem;
>>   	struct ib_umem	       *resize_umem;
>> +	int			create_flags;
>
> flags is u32

Maybe even u64 so we wont run out of bits like we did in
device_cap_flags.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Or Gerlitz May 20, 2015, 2:43 p.m. UTC | #3
On 5/20/2015 11:56 AM, Sagi Grimberg wrote:
> On 5/19/2015 9:55 PM, Jason Gunthorpe wrote:
>> On Sun, May 17, 2015 at 04:36:24PM +0300, Or Gerlitz wrote:
>>> @@ -110,6 +110,7 @@ struct mlx4_ib_cq {
>>>       struct mutex        resize_mutex;
>>>       struct ib_umem           *umem;
>>>       struct ib_umem           *resize_umem;
>>> +    int            create_flags;
>>
>> flags is u32
>
> Maybe even u64 so we wont run out of bits like we did in 
> device_cap_flags. 

Horses hold, you are comparing the volume of the whole feature set 
exposed by the RDMA subsystem to user-space vs  the number of future CQ 
creation flags? I bet we will not have > 8 of them till 2020 and the 
framework used for this uverb command is extendable...

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jason Gunthorpe May 20, 2015, 5:27 p.m. UTC | #4
On Wed, May 20, 2015 at 11:56:37AM +0300, Sagi Grimberg wrote:
> On 5/19/2015 9:55 PM, Jason Gunthorpe wrote:
> >On Sun, May 17, 2015 at 04:36:24PM +0300, Or Gerlitz wrote:
> >>@@ -110,6 +110,7 @@ struct mlx4_ib_cq {
> >>  	struct mutex		resize_mutex;
> >>  	struct ib_umem	       *umem;
> >>  	struct ib_umem	       *resize_umem;
> >>+	int			create_flags;
> >
> >flags is u32
> 
> Maybe even u64 so we wont run out of bits like we did in
> device_cap_flags.

It is all internal so the bitwidth doesn't matter, we can change
it. My remark was because the definitions of flags in the other
structure is u32, and copying u32 to int is sloppy.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 02b0424..da7ea19 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -166,6 +166,7 @@  err_buf:
 	return err;
 }
 
+#define CQ_CREATE_FLAGS_SUPPORTED IB_CQ_FLAGS_TIMESTAMP
 struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev,
 				struct ib_cq_init_attr *attr,
 				struct ib_ucontext *context,
@@ -178,10 +179,10 @@  struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev,
 	struct mlx4_uar *uar;
 	int err;
 
-	if (attr->flags)
+	if (entries < 1 || entries > dev->dev->caps.max_cqes)
 		return ERR_PTR(-EINVAL);
 
-	if (entries < 1 || entries > dev->dev->caps.max_cqes)
+	if (attr->flags & ~CQ_CREATE_FLAGS_SUPPORTED)
 		return ERR_PTR(-EINVAL);
 
 	cq = kmalloc(sizeof *cq, GFP_KERNEL);
@@ -194,6 +195,7 @@  struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev,
 	spin_lock_init(&cq->lock);
 	cq->resize_buf = NULL;
 	cq->resize_umem = NULL;
+	cq->create_flags = attr->flags;
 	INIT_LIST_HEAD(&cq->send_qp_list);
 	INIT_LIST_HEAD(&cq->recv_qp_list);
 
@@ -237,7 +239,8 @@  struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev,
 		vector = dev->eq_table[vector % ibdev->num_comp_vectors];
 
 	err = mlx4_cq_alloc(dev->dev, entries, &cq->buf.mtt, uar,
-			    cq->db.dma, &cq->mcq, vector, 0, 0);
+			    cq->db.dma, &cq->mcq, vector, 0,
+			    !!(cq->create_flags & IB_CQ_FLAGS_TIMESTAMP));
 	if (err)
 		goto err_dbmap;
 
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 8bd07c9..3afd3c5 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -110,6 +110,7 @@  struct mlx4_ib_cq {
 	struct mutex		resize_mutex;
 	struct ib_umem	       *umem;
 	struct ib_umem	       *resize_umem;
+	int			create_flags;
 	/* List of qps that it serves.*/
 	struct list_head		send_qp_list;
 	struct list_head		recv_qp_list;