diff mbox series

[V2,for-next] RDMA/hns: Update the kernel header file of hns

Message ID 1548146357-11880-1-git-send-email-oulijun@huawei.com (mailing list archive)
State Superseded
Headers show
Series [V2,for-next] RDMA/hns: Update the kernel header file of hns | expand

Commit Message

Lijun Ou Jan. 22, 2019, 8:39 a.m. UTC
The hns_roce_ib_create_srq_resp is used to interact with the
user for data. As a result, it is added to tranfer the srqn
to the user.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
V1->V2:
- Use hns_roce_ib_create_srq_resp to transfer srqn
---
 drivers/infiniband/hw/hns/hns_roce_srq.c | 4 +++-
 include/uapi/rdma/hns-abi.h              | 5 +++++
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

Jason Gunthorpe Jan. 22, 2019, 4:05 p.m. UTC | #1
On Tue, Jan 22, 2019 at 04:39:17PM +0800, Lijun Ou wrote:
> The hns_roce_ib_create_srq_resp is used to interact with the
> user for data. As a result, it is added to tranfer the srqn
> to the user.
> 
> Signed-off-by: Lijun Ou <oulijun@huawei.com>
> ---
> V1->V2:
> - Use hns_roce_ib_create_srq_resp to transfer srqn
> ---
>  drivers/infiniband/hw/hns/hns_roce_srq.c | 4 +++-
>  include/uapi/rdma/hns-abi.h              | 5 +++++
>  2 files changed, 8 insertions(+), 1 deletion(-)

Yes, okay, this is better
 
> diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
> index 8975f85..8492153 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_srq.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
> @@ -210,6 +210,7 @@ struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
>  				   struct ib_udata *udata)
>  {
>  	struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);
> +	struct hns_roce_ib_create_srq_resp resp = {};
>  	struct hns_roce_srq *srq;
>  	int srq_desc_size;
>  	int srq_buf_size;
> @@ -377,9 +378,10 @@ struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
>  
>  	srq->event = hns_roce_ib_srq_event;
>  	srq->ibsrq.ext.xrc.srq_num = srq->srqn;
> +	resp.srqn = srq->srqn;
>
>  	if (udata) {
> -		if (ib_copy_to_udata(udata, &srq->srqn, sizeof(__u32))) {
> +		if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {

min(udata->outlen, sizeof(resp))

Jason
Leon Romanovsky Jan. 22, 2019, 5:48 p.m. UTC | #2
On Tue, Jan 22, 2019 at 09:05:26AM -0700, Jason Gunthorpe wrote:
> On Tue, Jan 22, 2019 at 04:39:17PM +0800, Lijun Ou wrote:
> > The hns_roce_ib_create_srq_resp is used to interact with the
> > user for data. As a result, it is added to tranfer the srqn
> > to the user.
> >
> > Signed-off-by: Lijun Ou <oulijun@huawei.com>
> > ---
> > V1->V2:
> > - Use hns_roce_ib_create_srq_resp to transfer srqn
> > ---
> >  drivers/infiniband/hw/hns/hns_roce_srq.c | 4 +++-
> >  include/uapi/rdma/hns-abi.h              | 5 +++++
> >  2 files changed, 8 insertions(+), 1 deletion(-)
>
> Yes, okay, this is better
>
> > diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
> > index 8975f85..8492153 100644
> > --- a/drivers/infiniband/hw/hns/hns_roce_srq.c
> > +++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
> > @@ -210,6 +210,7 @@ struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
> >  				   struct ib_udata *udata)
> >  {
> >  	struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);
> > +	struct hns_roce_ib_create_srq_resp resp = {};
> >  	struct hns_roce_srq *srq;
> >  	int srq_desc_size;
> >  	int srq_buf_size;
> > @@ -377,9 +378,10 @@ struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
> >
> >  	srq->event = hns_roce_ib_srq_event;
> >  	srq->ibsrq.ext.xrc.srq_num = srq->srqn;
> > +	resp.srqn = srq->srqn;
> >
> >  	if (udata) {
> > -		if (ib_copy_to_udata(udata, &srq->srqn, sizeof(__u32))) {
> > +		if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {
>
> min(udata->outlen, sizeof(resp))

IMHO, we should update ib_copy_to_udata() to have 4 parameters instead
of 3 and do min() internally.

Thanks

>
> Jason
Lijun Ou Jan. 23, 2019, 1:34 a.m. UTC | #3
在 2019/1/23 0:05, Jason Gunthorpe 写道:
> On Tue, Jan 22, 2019 at 04:39:17PM +0800, Lijun Ou wrote:
>> The hns_roce_ib_create_srq_resp is used to interact with the
>> user for data. As a result, it is added to tranfer the srqn
>> to the user.
>>
>> Signed-off-by: Lijun Ou <oulijun@huawei.com>
>> ---
>> V1->V2:
>> - Use hns_roce_ib_create_srq_resp to transfer srqn
>> ---
>>  drivers/infiniband/hw/hns/hns_roce_srq.c | 4 +++-
>>  include/uapi/rdma/hns-abi.h              | 5 +++++
>>  2 files changed, 8 insertions(+), 1 deletion(-)
> Yes, okay, this is better
>  
>> diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
>> index 8975f85..8492153 100644
>> --- a/drivers/infiniband/hw/hns/hns_roce_srq.c
>> +++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
>> @@ -210,6 +210,7 @@ struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
>>  				   struct ib_udata *udata)
>>  {
>>  	struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);
>> +	struct hns_roce_ib_create_srq_resp resp = {};
>>  	struct hns_roce_srq *srq;
>>  	int srq_desc_size;
>>  	int srq_buf_size;
>> @@ -377,9 +378,10 @@ struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
>>  
>>  	srq->event = hns_roce_ib_srq_event;
>>  	srq->ibsrq.ext.xrc.srq_num = srq->srqn;
>> +	resp.srqn = srq->srqn;
>>
>>  	if (udata) {
>> -		if (ib_copy_to_udata(udata, &srq->srqn, sizeof(__u32))) {
>> +		if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {
> min(udata->outlen, sizeof(resp))
>
> Jason
>
Thanks. I will send the v3.
Jason Gunthorpe Jan. 23, 2019, 4:32 a.m. UTC | #4
On Tue, Jan 22, 2019 at 07:48:11PM +0200, Leon Romanovsky wrote:
> On Tue, Jan 22, 2019 at 09:05:26AM -0700, Jason Gunthorpe wrote:
> > On Tue, Jan 22, 2019 at 04:39:17PM +0800, Lijun Ou wrote:
> > > The hns_roce_ib_create_srq_resp is used to interact with the
> > > user for data. As a result, it is added to tranfer the srqn
> > > to the user.
> > >
> > > Signed-off-by: Lijun Ou <oulijun@huawei.com>
> > > V1->V2:
> > > - Use hns_roce_ib_create_srq_resp to transfer srqn
> > >  drivers/infiniband/hw/hns/hns_roce_srq.c | 4 +++-
> > >  include/uapi/rdma/hns-abi.h              | 5 +++++
> > >  2 files changed, 8 insertions(+), 1 deletion(-)
> >
> > Yes, okay, this is better
> >
> > > diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
> > > index 8975f85..8492153 100644
> > > +++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
> > > @@ -210,6 +210,7 @@ struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
> > >  				   struct ib_udata *udata)
> > >  {
> > >  	struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);
> > > +	struct hns_roce_ib_create_srq_resp resp = {};
> > >  	struct hns_roce_srq *srq;
> > >  	int srq_desc_size;
> > >  	int srq_buf_size;
> > > @@ -377,9 +378,10 @@ struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
> > >
> > >  	srq->event = hns_roce_ib_srq_event;
> > >  	srq->ibsrq.ext.xrc.srq_num = srq->srqn;
> > > +	resp.srqn = srq->srqn;
> > >
> > >  	if (udata) {
> > > -		if (ib_copy_to_udata(udata, &srq->srqn, sizeof(__u32))) {
> > > +		if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {
> >
> > min(udata->outlen, sizeof(resp))
> 
> IMHO, we should update ib_copy_to_udata() to have 4 parameters instead
> of 3 and do min() internally.

Yes.. I fixed all the core code, the drivers need to have the same
API.

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c
index 8975f85..8492153 100644
--- a/drivers/infiniband/hw/hns/hns_roce_srq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_srq.c
@@ -210,6 +210,7 @@  struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
 				   struct ib_udata *udata)
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);
+	struct hns_roce_ib_create_srq_resp resp = {};
 	struct hns_roce_srq *srq;
 	int srq_desc_size;
 	int srq_buf_size;
@@ -377,9 +378,10 @@  struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
 
 	srq->event = hns_roce_ib_srq_event;
 	srq->ibsrq.ext.xrc.srq_num = srq->srqn;
+	resp.srqn = srq->srqn;
 
 	if (udata) {
-		if (ib_copy_to_udata(udata, &srq->srqn, sizeof(__u32))) {
+		if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {
 			ret = -EFAULT;
 			goto err_wrid;
 		}
diff --git a/include/uapi/rdma/hns-abi.h b/include/uapi/rdma/hns-abi.h
index ef3c7ec..eb76b38 100644
--- a/include/uapi/rdma/hns-abi.h
+++ b/include/uapi/rdma/hns-abi.h
@@ -52,6 +52,11 @@  struct hns_roce_ib_create_srq {
 	__aligned_u64 que_addr;
 };
 
+struct hns_roce_ib_create_srq_resp {
+	__u32	srqn;
+	__u32	reserved;
+};
+
 struct hns_roce_ib_create_qp {
 	__aligned_u64 buf_addr;
 	__aligned_u64 db_addr;