diff mbox

[V3,for-next,1/4] IB/core: Introduce capabilitymask2 field in ClassPortInfo mad

Message ID 1462892208-6140-2-git-send-email-erezsh@mellanox.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Erez Shitrit May 10, 2016, 2:56 p.m. UTC
Change struct ib_class_port_info to conform to IB Spec 1.3
That in order to get specific capability mask from ClassPortInfo mad.

From the IB Spec, ClassPortInfo section:
        "CapabilityMask2 Bits 0-26: Additional class-specific capabilities...
         RespTimeValue the rest 5 bits"

The new struct now has one field for capabilitymask2 (previously was the
reserved field) and the resp_time field.

And it fixes up qib and srpt, use of the field repurposed to be used as
capabilitymask2:
IB/qib: Change pma_get_classportinfo
IB/srpt: Adjust the use of ib_class_port_info

Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/qib/qib_mad.c   | 6 ++++--
 drivers/infiniband/ulp/srpt/ib_srpt.c | 5 ++++-
 include/rdma/ib_mad.h                 | 4 ++--
 3 files changed, 10 insertions(+), 5 deletions(-)

Comments

Bart Van Assche May 10, 2016, 3:38 p.m. UTC | #1
On 05/10/2016 07:56 AM, Erez Shitrit wrote:
 >   drivers/infiniband/hw/qib/qib_mad.c   | 6 ++++--
 >   drivers/infiniband/ulp/srpt/ib_srpt.c | 5 ++++-
 >   include/rdma/ib_mad.h                 | 4 ++--
 >   3 files changed, 10 insertions(+), 5 deletions(-)

This patch modifies ib_srpt but I'm not on the CC-list for this patch 
series?

> diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
> index 0bd1837..c5d029d 100644
> --- a/drivers/infiniband/hw/qib/qib_mad.c
> +++ b/drivers/infiniband/hw/qib/qib_mad.c
> @@ -1158,6 +1158,7 @@ static int pma_get_classportinfo(struct ib_pma_mad *pmp,
>   	struct ib_class_port_info *p =
>   		(struct ib_class_port_info *)pmp->data;
>   	struct qib_devdata *dd = dd_from_ibdev(ibdev);
> +	char *p_cap_mask2;
>
>   	memset(pmp->data, 0, sizeof(pmp->data));
>
> @@ -1172,11 +1173,12 @@ static int pma_get_classportinfo(struct ib_pma_mad *pmp,
>   	 * Set the most significant bit of CM2 to indicate support for
>   	 * congestion statistics
>   	 */
> -	p->reserved[0] = dd->psxmitwait_supported << 7;
> +	p_cap_mask2 = (char *)&p->cap_mask2_resp_time;
> +	p_cap_mask2[0] = dd->psxmitwait_supported << 7;

Casting __be32 * into char * will make the sparse endianness checks go 
crazy. Please introduce (inline) functions that allow to extract and set 
the cap_mask2 and resp_time fields. Please also verify whether the 
modified code builds cleanly with make C=2 CF=-D__CHECK_ENDIAN__.

Bart.
--
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
Erez Shitrit May 10, 2016, 3:45 p.m. UTC | #2
On Tue, May 10, 2016 at 6:38 PM, Bart Van Assche
<bart.vanassche@sandisk.com> wrote:
> On 05/10/2016 07:56 AM, Erez Shitrit wrote:
>>   drivers/infiniband/hw/qib/qib_mad.c   | 6 ++++--
>>   drivers/infiniband/ulp/srpt/ib_srpt.c | 5 ++++-
>>   include/rdma/ib_mad.h                 | 4 ++--
>>   3 files changed, 10 insertions(+), 5 deletions(-)
>
> This patch modifies ib_srpt but I'm not on the CC-list for this patch
> series?

my bad. will fix that next time.

>
>> diff --git a/drivers/infiniband/hw/qib/qib_mad.c
>> b/drivers/infiniband/hw/qib/qib_mad.c
>> index 0bd1837..c5d029d 100644
>> --- a/drivers/infiniband/hw/qib/qib_mad.c
>> +++ b/drivers/infiniband/hw/qib/qib_mad.c
>> @@ -1158,6 +1158,7 @@ static int pma_get_classportinfo(struct ib_pma_mad
>> *pmp,
>>         struct ib_class_port_info *p =
>>                 (struct ib_class_port_info *)pmp->data;
>>         struct qib_devdata *dd = dd_from_ibdev(ibdev);
>> +       char *p_cap_mask2;
>>
>>         memset(pmp->data, 0, sizeof(pmp->data));
>>
>> @@ -1172,11 +1173,12 @@ static int pma_get_classportinfo(struct ib_pma_mad
>> *pmp,
>>          * Set the most significant bit of CM2 to indicate support for
>>          * congestion statistics
>>          */
>> -       p->reserved[0] = dd->psxmitwait_supported << 7;
>> +       p_cap_mask2 = (char *)&p->cap_mask2_resp_time;
>> +       p_cap_mask2[0] = dd->psxmitwait_supported << 7;
>
>
> Casting __be32 * into char * will make the sparse endianness checks go
> crazy. Please introduce (inline) functions that allow to extract and set the
> cap_mask2 and resp_time fields. Please also verify whether the modified code
> builds cleanly with make C=2 CF=-D__CHECK_ENDIAN__.

OK, will do.

>
> Bart.
>
> --
> 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
--
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
Ira Weiny May 13, 2016, 3:23 p.m. UTC | #3
On Tue, May 10, 2016 at 08:38:32AM -0700, Bart Van Assche wrote:
> On 05/10/2016 07:56 AM, Erez Shitrit wrote:
> >   drivers/infiniband/hw/qib/qib_mad.c   | 6 ++++--
> >   drivers/infiniband/ulp/srpt/ib_srpt.c | 5 ++++-
> >   include/rdma/ib_mad.h                 | 4 ++--
> >   3 files changed, 10 insertions(+), 5 deletions(-)
> 
> This patch modifies ib_srpt but I'm not on the CC-list for this patch 
> series?
> 
> >diff --git a/drivers/infiniband/hw/qib/qib_mad.c 
> >b/drivers/infiniband/hw/qib/qib_mad.c
> >index 0bd1837..c5d029d 100644
> >--- a/drivers/infiniband/hw/qib/qib_mad.c
> >+++ b/drivers/infiniband/hw/qib/qib_mad.c
> >@@ -1158,6 +1158,7 @@ static int pma_get_classportinfo(struct ib_pma_mad 
> >*pmp,
> >  	struct ib_class_port_info *p =
> >  		(struct ib_class_port_info *)pmp->data;
> >  	struct qib_devdata *dd = dd_from_ibdev(ibdev);
> >+	char *p_cap_mask2;
> >
> >  	memset(pmp->data, 0, sizeof(pmp->data));
> >
> >@@ -1172,11 +1173,12 @@ static int pma_get_classportinfo(struct ib_pma_mad 
> >*pmp,
> >  	 * Set the most significant bit of CM2 to indicate support for
> >  	 * congestion statistics
> >  	 */
> >-	p->reserved[0] = dd->psxmitwait_supported << 7;
> >+	p_cap_mask2 = (char *)&p->cap_mask2_resp_time;
> >+	p_cap_mask2[0] = dd->psxmitwait_supported << 7;
> 
> Casting __be32 * into char * will make the sparse endianness checks go 
> crazy. Please introduce (inline) functions that allow to extract and set 
> the cap_mask2 and resp_time fields. Please also verify whether the 
> modified code builds cleanly with make C=2 CF=-D__CHECK_ENDIAN__.

Agreed.  I sent a reply yesterday but apparently my mail did not get through?

Ira


> 
> Bart.
> --
> 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
--
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
Erez Shitrit May 15, 2016, 6:12 a.m. UTC | #4
On Fri, May 13, 2016 at 6:23 PM, ira.weiny <ira.weiny@intel.com> wrote:
> On Tue, May 10, 2016 at 08:38:32AM -0700, Bart Van Assche wrote:
>> On 05/10/2016 07:56 AM, Erez Shitrit wrote:
>> >   drivers/infiniband/hw/qib/qib_mad.c   | 6 ++++--
>> >   drivers/infiniband/ulp/srpt/ib_srpt.c | 5 ++++-
>> >   include/rdma/ib_mad.h                 | 4 ++--
>> >   3 files changed, 10 insertions(+), 5 deletions(-)
>>
>> This patch modifies ib_srpt but I'm not on the CC-list for this patch
>> series?
>>
>> >diff --git a/drivers/infiniband/hw/qib/qib_mad.c
>> >b/drivers/infiniband/hw/qib/qib_mad.c
>> >index 0bd1837..c5d029d 100644
>> >--- a/drivers/infiniband/hw/qib/qib_mad.c
>> >+++ b/drivers/infiniband/hw/qib/qib_mad.c
>> >@@ -1158,6 +1158,7 @@ static int pma_get_classportinfo(struct ib_pma_mad
>> >*pmp,
>> >     struct ib_class_port_info *p =
>> >             (struct ib_class_port_info *)pmp->data;
>> >     struct qib_devdata *dd = dd_from_ibdev(ibdev);
>> >+    char *p_cap_mask2;
>> >
>> >     memset(pmp->data, 0, sizeof(pmp->data));
>> >
>> >@@ -1172,11 +1173,12 @@ static int pma_get_classportinfo(struct ib_pma_mad
>> >*pmp,
>> >      * Set the most significant bit of CM2 to indicate support for
>> >      * congestion statistics
>> >      */
>> >-    p->reserved[0] = dd->psxmitwait_supported << 7;
>> >+    p_cap_mask2 = (char *)&p->cap_mask2_resp_time;
>> >+    p_cap_mask2[0] = dd->psxmitwait_supported << 7;
>>
>> Casting __be32 * into char * will make the sparse endianness checks go
>> crazy. Please introduce (inline) functions that allow to extract and set
>> the cap_mask2 and resp_time fields. Please also verify whether the
>> modified code builds cleanly with make C=2 CF=-D__CHECK_ENDIAN__.
>
> Agreed.  I sent a reply yesterday but apparently my mail did not get through?

Hi Bart, Ira,

I will add setter/getter for the 2 field.
Thanks,

>
> Ira
>
>
>>
>> Bart.
>> --
>> 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
> --
> 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
--
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/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
index 0bd1837..c5d029d 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -1158,6 +1158,7 @@  static int pma_get_classportinfo(struct ib_pma_mad *pmp,
 	struct ib_class_port_info *p =
 		(struct ib_class_port_info *)pmp->data;
 	struct qib_devdata *dd = dd_from_ibdev(ibdev);
+	char *p_cap_mask2;
 
 	memset(pmp->data, 0, sizeof(pmp->data));
 
@@ -1172,11 +1173,12 @@  static int pma_get_classportinfo(struct ib_pma_mad *pmp,
 	 * Set the most significant bit of CM2 to indicate support for
 	 * congestion statistics
 	 */
-	p->reserved[0] = dd->psxmitwait_supported << 7;
+	p_cap_mask2 = (char *)&p->cap_mask2_resp_time;
+	p_cap_mask2[0] = dd->psxmitwait_supported << 7;
 	/*
 	 * Expected response time is 4.096 usec. * 2^18 == 1.073741824 sec.
 	 */
-	p->resp_time_value = 18;
+	p_cap_mask2[3] = 18;
 
 	return reply((struct ib_smp *) pmp);
 }
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 8b42401..cf7868e 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -249,12 +249,15 @@  static void srpt_set_ioc(u8 *c_list, u32 slot, u8 value)
 static void srpt_get_class_port_info(struct ib_dm_mad *mad)
 {
 	struct ib_class_port_info *cif;
+	char *p_cap_mask2;
 
 	cif = (struct ib_class_port_info *)mad->data;
 	memset(cif, 0, sizeof(*cif));
 	cif->base_version = 1;
 	cif->class_version = 1;
-	cif->resp_time_value = 20;
+
+	p_cap_mask2 = (char *)&cif->cap_mask2_resp_time;
+	p_cap_mask2[3] = 20;
 
 	mad->mad_hdr.status = 0;
 }
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index 37dd534c..2aaf1cb 100644
--- a/include/rdma/ib_mad.h
+++ b/include/rdma/ib_mad.h
@@ -243,8 +243,8 @@  struct ib_class_port_info {
 	u8			base_version;
 	u8			class_version;
 	__be16			capability_mask;
-	u8			reserved[3];
-	u8			resp_time_value;
+	  /* 27 bits for cap_mask2, 5 bits for resp_time */
+	__be32			cap_mask2_resp_time;
 	u8			redirect_gid[16];
 	__be32			redirect_tcslfl;
 	__be16			redirect_lid;