diff mbox

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

Message ID 1463401694-19247-2-git-send-email-erezsh@mellanox.com (mailing list archive)
State Superseded
Headers show

Commit Message

Erez Shitrit May 16, 2016, 12:28 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   |  4 +--
 drivers/infiniband/ulp/srpt/ib_srpt.c |  2 +-
 include/rdma/ib_mad.h                 | 62 +++++++++++++++++++++++++++++++++--
 3 files changed, 63 insertions(+), 5 deletions(-)

Comments

Hal Rosenstock May 16, 2016, 1 p.m. UTC | #1
On 5/16/2016 8:28 AM, Erez Shitrit wrote:
> 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   |  4 +--
>  drivers/infiniband/ulp/srpt/ib_srpt.c |  2 +-
>  include/rdma/ib_mad.h                 | 62 +++++++++++++++++++++++++++++++++--
>  3 files changed, 63 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
> index 0bd1837..a872865 100644
> --- a/drivers/infiniband/hw/qib/qib_mad.c
> +++ b/drivers/infiniband/hw/qib/qib_mad.c
> @@ -1172,11 +1172,11 @@ 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;
> +	ib_set_cpi_capmask2(p, dd->psxmitwait_supported << 7);
>  	/*
>  	 * Expected response time is 4.096 usec. * 2^18 == 1.073741824 sec.
>  	 */
> -	p->resp_time_value = 18;
> +	ib_set_cpi_resp_time(p, 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 2843f1a..887ebad 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -254,8 +254,8 @@ static void srpt_get_class_port_info(struct ib_dm_mad *mad)
>  	memset(cif, 0, sizeof(*cif));
>  	cif->base_version = 1;
>  	cif->class_version = 1;
> -	cif->resp_time_value = 20;
>  
> +	ib_set_cpi_resp_time(cif, 20);
>  	mad->mad_hdr.status = 0;
>  }
>  
> diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
> index 37dd534c..a471348 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;
> @@ -259,6 +259,64 @@ struct ib_class_port_info {
>  	__be32			trap_qkey;
>  };
>  
> +/**
> + * ib_get_cpi_resp_time - Returns the resp_time value from
> + * cap_mask2_resp_time in ib_class_port_info.
> + * @cpi: A struct ib_class_port_info mad.
> + */
> +static inline u8 ib_get_cpi_resp_time(struct ib_class_port_info *cpi)
> +{
> +	return ((be32_to_cpu(cpi->cap_mask2_resp_time) & 0xF8) >> 3);

Should this be:
	
	return ((be32_to_cpu(cpi->cap_mask2_resp_time) & IB_CLASS_PORT_INFO_RESP_TIME_MASK);

where

#define IB_CLASS_PORT_INFO_RESP_TIME_MASK 0x1F

?

> +}
> +
> +/**
> + * ib_set_cpi_resptime - Sets the response time in an
> + * ib_class_port_info mad.
> + * @cpi: A struct ib_class_port_info.
> + * @rtime: The response time to set.
> + */
> +static inline void ib_set_cpi_resp_time(struct ib_class_port_info *cpi,
> +					u8 rtime)
> +{
> +	u32 tmp;
> +	u32 tmp2;
> +
> +	tmp = rtime;
> +	tmp = tmp << 3;
> +	tmp2 = (be32_to_cpu(cpi->cap_mask2_resp_time) & ~0xF8);
> +	tmp = tmp | tmp2;
> +	cpi->cap_mask2_resp_time = cpu_to_be32(tmp);

Should this be:

	cpi->cap_mask2_resp_time = (cpi->cap_mask2_resp_time & cpu_to_be32(~IB_CLASS_PORT_INFO_RESP_TIME_MASK)) |
				     cpu_to_be32(rtime & IB_CLASS_PORT_INFO_RESP_TIME_MASK);

?

> +}
> +
> +/**
> + * ib_get_cpi_capmask2 - Returns the capmask2 value from
> + * cap_mask2_resp_time in ib_class_port_info.
> + * @cpi: A struct ib_class_port_info mad.
> + */
> +static inline u32 ib_get_cpi_capmask2(struct ib_class_port_info *cpi)
> +{
> +	u8 tmp;
> +
> +	tmp = ((be32_to_cpu(cpi->cap_mask2_resp_time) & 0x7) << 5);
> +	return (((be32_to_cpu(cpi->cap_mask2_resp_time) & ~0xFF) >> 5) | tmp);

#define IB_CLASS_PORT_INFO_CAP_MASK2_SHIFT 5

	return (be32_to_cpu(cpi->cap_mask2_resp_time) >> IB_CLASS_PORT_INFO_CAP_MASK2_SHIFT);
?

> +}
> +
> +/**
> + * ib_set_cpi_capmask2 - Sets the capmask2 in an
> + * ib_class_port_info mad.
> + * @cpi: A struct ib_class_port_info.
> + * @capmask2: The capmask2 to set.
> + */
> +static inline void ib_set_cpi_capmask2(struct ib_class_port_info *cpi,
> +				       u32 capmask2)
> +{
> +	u32 tmp;
> +
> +	tmp = ib_get_cpi_resp_time(cpi);
> +	tmp = tmp << 27;
> +	cpi->cap_mask2_resp_time = (__force __be32)(tmp | capmask2);

	cpi->cap_mask2_resp_time = (cpi->cap_mask2_resp_time & cpu_to_be32(IB_CLASS_PORT_INFO_RESP_TIME_MASK)) |
				   cpu_to_be32(capmask2 << IB_CLASS_PORT_INFO_CAP_MASK2_SHIFT);
?

> +}
> +
>  struct ib_mad_notice_attr {
>  	u8 generic_type;
>  	u8 prod_type_msb;
> 
--
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 16, 2016, 1:04 p.m. UTC | #2
On Mon, May 16, 2016 at 4:00 PM, Hal Rosenstock <hal@dev.mellanox.co.il> wrote:
> On 5/16/2016 8:28 AM, Erez Shitrit wrote:
>> 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   |  4 +--
>>  drivers/infiniband/ulp/srpt/ib_srpt.c |  2 +-
>>  include/rdma/ib_mad.h                 | 62 +++++++++++++++++++++++++++++++++--
>>  3 files changed, 63 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
>> index 0bd1837..a872865 100644
>> --- a/drivers/infiniband/hw/qib/qib_mad.c
>> +++ b/drivers/infiniband/hw/qib/qib_mad.c
>> @@ -1172,11 +1172,11 @@ 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;
>> +     ib_set_cpi_capmask2(p, dd->psxmitwait_supported << 7);
>>       /*
>>        * Expected response time is 4.096 usec. * 2^18 == 1.073741824 sec.
>>        */
>> -     p->resp_time_value = 18;
>> +     ib_set_cpi_resp_time(p, 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 2843f1a..887ebad 100644
>> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
>> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
>> @@ -254,8 +254,8 @@ static void srpt_get_class_port_info(struct ib_dm_mad *mad)
>>       memset(cif, 0, sizeof(*cif));
>>       cif->base_version = 1;
>>       cif->class_version = 1;
>> -     cif->resp_time_value = 20;
>>
>> +     ib_set_cpi_resp_time(cif, 20);
>>       mad->mad_hdr.status = 0;
>>  }
>>
>> diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
>> index 37dd534c..a471348 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;
>> @@ -259,6 +259,64 @@ struct ib_class_port_info {
>>       __be32                  trap_qkey;
>>  };
>>
>> +/**
>> + * ib_get_cpi_resp_time - Returns the resp_time value from
>> + * cap_mask2_resp_time in ib_class_port_info.
>> + * @cpi: A struct ib_class_port_info mad.
>> + */
>> +static inline u8 ib_get_cpi_resp_time(struct ib_class_port_info *cpi)
>> +{
>> +     return ((be32_to_cpu(cpi->cap_mask2_resp_time) & 0xF8) >> 3);
>
> Should this be:
>
>         return ((be32_to_cpu(cpi->cap_mask2_resp_time) & IB_CLASS_PORT_INFO_RESP_TIME_MASK);
>
> where
>
> #define IB_CLASS_PORT_INFO_RESP_TIME_MASK 0x1F
>
> ?

Ok, will do.
Thanks


>
>> +}
>> +
>> +/**
>> + * ib_set_cpi_resptime - Sets the response time in an
>> + * ib_class_port_info mad.
>> + * @cpi: A struct ib_class_port_info.
>> + * @rtime: The response time to set.
>> + */
>> +static inline void ib_set_cpi_resp_time(struct ib_class_port_info *cpi,
>> +                                     u8 rtime)
>> +{
>> +     u32 tmp;
>> +     u32 tmp2;
>> +
>> +     tmp = rtime;
>> +     tmp = tmp << 3;
>> +     tmp2 = (be32_to_cpu(cpi->cap_mask2_resp_time) & ~0xF8);
>> +     tmp = tmp | tmp2;
>> +     cpi->cap_mask2_resp_time = cpu_to_be32(tmp);
>
> Should this be:
>
>         cpi->cap_mask2_resp_time = (cpi->cap_mask2_resp_time & cpu_to_be32(~IB_CLASS_PORT_INFO_RESP_TIME_MASK)) |
>                                      cpu_to_be32(rtime & IB_CLASS_PORT_INFO_RESP_TIME_MASK);
>
> ?

Ok, will do.
Thanks


>
>> +}
>> +
>> +/**
>> + * ib_get_cpi_capmask2 - Returns the capmask2 value from
>> + * cap_mask2_resp_time in ib_class_port_info.
>> + * @cpi: A struct ib_class_port_info mad.
>> + */
>> +static inline u32 ib_get_cpi_capmask2(struct ib_class_port_info *cpi)
>> +{
>> +     u8 tmp;
>> +
>> +     tmp = ((be32_to_cpu(cpi->cap_mask2_resp_time) & 0x7) << 5);
>> +     return (((be32_to_cpu(cpi->cap_mask2_resp_time) & ~0xFF) >> 5) | tmp);
>
> #define IB_CLASS_PORT_INFO_CAP_MASK2_SHIFT 5
>
>         return (be32_to_cpu(cpi->cap_mask2_resp_time) >> IB_CLASS_PORT_INFO_CAP_MASK2_SHIFT);
> ?
>
>> +}
>> +
>> +/**
>> + * ib_set_cpi_capmask2 - Sets the capmask2 in an
>> + * ib_class_port_info mad.
>> + * @cpi: A struct ib_class_port_info.
>> + * @capmask2: The capmask2 to set.
>> + */
>> +static inline void ib_set_cpi_capmask2(struct ib_class_port_info *cpi,
>> +                                    u32 capmask2)
>> +{
>> +     u32 tmp;
>> +
>> +     tmp = ib_get_cpi_resp_time(cpi);
>> +     tmp = tmp << 27;
>> +     cpi->cap_mask2_resp_time = (__force __be32)(tmp | capmask2);
>
>         cpi->cap_mask2_resp_time = (cpi->cap_mask2_resp_time & cpu_to_be32(IB_CLASS_PORT_INFO_RESP_TIME_MASK)) |
>                                    cpu_to_be32(capmask2 << IB_CLASS_PORT_INFO_CAP_MASK2_SHIFT);
> ?
>
>> +}
>> +
>>  struct ib_mad_notice_attr {
>>       u8 generic_type;
>>       u8 prod_type_msb;
>>
> --
> 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 16, 2016, 2:59 p.m. UTC | #3
Hi,

I will address Hal's comments and re-post tomorrow morning, in order
to wait the others that made comments on V3.
(to make sure they are ok with that version).

Thanks, Erez

On Mon, May 16, 2016 at 4:04 PM, Erez Shitrit <erezsh@dev.mellanox.co.il> wrote:
> On Mon, May 16, 2016 at 4:00 PM, Hal Rosenstock <hal@dev.mellanox.co.il> wrote:
>> On 5/16/2016 8:28 AM, Erez Shitrit wrote:
>>> 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   |  4 +--
>>>  drivers/infiniband/ulp/srpt/ib_srpt.c |  2 +-
>>>  include/rdma/ib_mad.h                 | 62 +++++++++++++++++++++++++++++++++--
>>>  3 files changed, 63 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/infiniband/hw/qib/qib_mad.c b/drivers/infiniband/hw/qib/qib_mad.c
>>> index 0bd1837..a872865 100644
>>> --- a/drivers/infiniband/hw/qib/qib_mad.c
>>> +++ b/drivers/infiniband/hw/qib/qib_mad.c
>>> @@ -1172,11 +1172,11 @@ 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;
>>> +     ib_set_cpi_capmask2(p, dd->psxmitwait_supported << 7);
>>>       /*
>>>        * Expected response time is 4.096 usec. * 2^18 == 1.073741824 sec.
>>>        */
>>> -     p->resp_time_value = 18;
>>> +     ib_set_cpi_resp_time(p, 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 2843f1a..887ebad 100644
>>> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
>>> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
>>> @@ -254,8 +254,8 @@ static void srpt_get_class_port_info(struct ib_dm_mad *mad)
>>>       memset(cif, 0, sizeof(*cif));
>>>       cif->base_version = 1;
>>>       cif->class_version = 1;
>>> -     cif->resp_time_value = 20;
>>>
>>> +     ib_set_cpi_resp_time(cif, 20);
>>>       mad->mad_hdr.status = 0;
>>>  }
>>>
>>> diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
>>> index 37dd534c..a471348 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;
>>> @@ -259,6 +259,64 @@ struct ib_class_port_info {
>>>       __be32                  trap_qkey;
>>>  };
>>>
>>> +/**
>>> + * ib_get_cpi_resp_time - Returns the resp_time value from
>>> + * cap_mask2_resp_time in ib_class_port_info.
>>> + * @cpi: A struct ib_class_port_info mad.
>>> + */
>>> +static inline u8 ib_get_cpi_resp_time(struct ib_class_port_info *cpi)
>>> +{
>>> +     return ((be32_to_cpu(cpi->cap_mask2_resp_time) & 0xF8) >> 3);
>>
>> Should this be:
>>
>>         return ((be32_to_cpu(cpi->cap_mask2_resp_time) & IB_CLASS_PORT_INFO_RESP_TIME_MASK);
>>
>> where
>>
>> #define IB_CLASS_PORT_INFO_RESP_TIME_MASK 0x1F
>>
>> ?
>
> Ok, will do.
> Thanks
>
>
>>
>>> +}
>>> +
>>> +/**
>>> + * ib_set_cpi_resptime - Sets the response time in an
>>> + * ib_class_port_info mad.
>>> + * @cpi: A struct ib_class_port_info.
>>> + * @rtime: The response time to set.
>>> + */
>>> +static inline void ib_set_cpi_resp_time(struct ib_class_port_info *cpi,
>>> +                                     u8 rtime)
>>> +{
>>> +     u32 tmp;
>>> +     u32 tmp2;
>>> +
>>> +     tmp = rtime;
>>> +     tmp = tmp << 3;
>>> +     tmp2 = (be32_to_cpu(cpi->cap_mask2_resp_time) & ~0xF8);
>>> +     tmp = tmp | tmp2;
>>> +     cpi->cap_mask2_resp_time = cpu_to_be32(tmp);
>>
>> Should this be:
>>
>>         cpi->cap_mask2_resp_time = (cpi->cap_mask2_resp_time & cpu_to_be32(~IB_CLASS_PORT_INFO_RESP_TIME_MASK)) |
>>                                      cpu_to_be32(rtime & IB_CLASS_PORT_INFO_RESP_TIME_MASK);
>>
>> ?
>
> Ok, will do.
> Thanks
>
>
>>
>>> +}
>>> +
>>> +/**
>>> + * ib_get_cpi_capmask2 - Returns the capmask2 value from
>>> + * cap_mask2_resp_time in ib_class_port_info.
>>> + * @cpi: A struct ib_class_port_info mad.
>>> + */
>>> +static inline u32 ib_get_cpi_capmask2(struct ib_class_port_info *cpi)
>>> +{
>>> +     u8 tmp;
>>> +
>>> +     tmp = ((be32_to_cpu(cpi->cap_mask2_resp_time) & 0x7) << 5);
>>> +     return (((be32_to_cpu(cpi->cap_mask2_resp_time) & ~0xFF) >> 5) | tmp);
>>
>> #define IB_CLASS_PORT_INFO_CAP_MASK2_SHIFT 5
>>
>>         return (be32_to_cpu(cpi->cap_mask2_resp_time) >> IB_CLASS_PORT_INFO_CAP_MASK2_SHIFT);
>> ?
>>
>>> +}
>>> +
>>> +/**
>>> + * ib_set_cpi_capmask2 - Sets the capmask2 in an
>>> + * ib_class_port_info mad.
>>> + * @cpi: A struct ib_class_port_info.
>>> + * @capmask2: The capmask2 to set.
>>> + */
>>> +static inline void ib_set_cpi_capmask2(struct ib_class_port_info *cpi,
>>> +                                    u32 capmask2)
>>> +{
>>> +     u32 tmp;
>>> +
>>> +     tmp = ib_get_cpi_resp_time(cpi);
>>> +     tmp = tmp << 27;
>>> +     cpi->cap_mask2_resp_time = (__force __be32)(tmp | capmask2);
>>
>>         cpi->cap_mask2_resp_time = (cpi->cap_mask2_resp_time & cpu_to_be32(IB_CLASS_PORT_INFO_RESP_TIME_MASK)) |
>>                                    cpu_to_be32(capmask2 << IB_CLASS_PORT_INFO_CAP_MASK2_SHIFT);
>> ?
>>
>>> +}
>>> +
>>>  struct ib_mad_notice_attr {
>>>       u8 generic_type;
>>>       u8 prod_type_msb;
>>>
>> --
>> 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 17, 2016, 7:45 p.m. UTC | #4
On Mon, May 16, 2016 at 03:28:11PM +0300, Erez Shitrit wrote:
> 

<snip>

>  
> +/**
> + * ib_get_cpi_resp_time - Returns the resp_time value from
> + * cap_mask2_resp_time in ib_class_port_info.
> + * @cpi: A struct ib_class_port_info mad.
> + */
> +static inline u8 ib_get_cpi_resp_time(struct ib_class_port_info *cpi)
> +{
> +	return ((be32_to_cpu(cpi->cap_mask2_resp_time) & 0xF8) >> 3);

return (uint8_t)((be32_to_cpu(cpi->cap_mask2_resp_time) & 0xF8000000) >> 27);

???

> +}
> +
> +/**
> + * ib_set_cpi_resptime - Sets the response time in an
> + * ib_class_port_info mad.
> + * @cpi: A struct ib_class_port_info.
> + * @rtime: The response time to set.
> + */
> +static inline void ib_set_cpi_resp_time(struct ib_class_port_info *cpi,
> +					u8 rtime)
> +{
> +	u32 tmp;
> +	u32 tmp2;
> +
> +	tmp = rtime;
> +	tmp = tmp << 3;

<< 27 ???


> +	tmp2 = (be32_to_cpu(cpi->cap_mask2_resp_time) & ~0xF8);
> +	tmp = tmp | tmp2;
> +	cpi->cap_mask2_resp_time = cpu_to_be32(tmp);
> +}
> +
> +/**
> + * ib_get_cpi_capmask2 - Returns the capmask2 value from
> + * cap_mask2_resp_time in ib_class_port_info.
> + * @cpi: A struct ib_class_port_info mad.
> + */
> +static inline u32 ib_get_cpi_capmask2(struct ib_class_port_info *cpi)
> +{
> +	u8 tmp;
> +
> +	tmp = ((be32_to_cpu(cpi->cap_mask2_resp_time) & 0x7) << 5);
> +	return (((be32_to_cpu(cpi->cap_mask2_resp_time) & ~0xFF) >> 5) | tmp);


return (be32_to_cpu(cpi->cap_mask2_resp_time) & 0x07FFFFFF);


?


> +}
> +
> +/**
> + * ib_set_cpi_capmask2 - Sets the capmask2 in an
> + * ib_class_port_info mad.
> + * @cpi: A struct ib_class_port_info.
> + * @capmask2: The capmask2 to set.
> + */
> +static inline void ib_set_cpi_capmask2(struct ib_class_port_info *cpi,
> +				       u32 capmask2)
> +{
> +	u32 tmp;
> +
> +	tmp = ib_get_cpi_resp_time(cpi);
> +	tmp = tmp << 27;
> +	cpi->cap_mask2_resp_time = (__force __be32)(tmp | capmask2);

Why is this not

cpi->cap_mask2_resp_time = cpu_to_be32(..);

?

Ira


> +}
> +
>  struct ib_mad_notice_attr {
>  	u8 generic_type;
>  	u8 prod_type_msb;
> -- 
> 1.7.11.3
> 
--
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..a872865 100644
--- a/drivers/infiniband/hw/qib/qib_mad.c
+++ b/drivers/infiniband/hw/qib/qib_mad.c
@@ -1172,11 +1172,11 @@  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;
+	ib_set_cpi_capmask2(p, dd->psxmitwait_supported << 7);
 	/*
 	 * Expected response time is 4.096 usec. * 2^18 == 1.073741824 sec.
 	 */
-	p->resp_time_value = 18;
+	ib_set_cpi_resp_time(p, 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 2843f1a..887ebad 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -254,8 +254,8 @@  static void srpt_get_class_port_info(struct ib_dm_mad *mad)
 	memset(cif, 0, sizeof(*cif));
 	cif->base_version = 1;
 	cif->class_version = 1;
-	cif->resp_time_value = 20;
 
+	ib_set_cpi_resp_time(cif, 20);
 	mad->mad_hdr.status = 0;
 }
 
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index 37dd534c..a471348 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;
@@ -259,6 +259,64 @@  struct ib_class_port_info {
 	__be32			trap_qkey;
 };
 
+/**
+ * ib_get_cpi_resp_time - Returns the resp_time value from
+ * cap_mask2_resp_time in ib_class_port_info.
+ * @cpi: A struct ib_class_port_info mad.
+ */
+static inline u8 ib_get_cpi_resp_time(struct ib_class_port_info *cpi)
+{
+	return ((be32_to_cpu(cpi->cap_mask2_resp_time) & 0xF8) >> 3);
+}
+
+/**
+ * ib_set_cpi_resptime - Sets the response time in an
+ * ib_class_port_info mad.
+ * @cpi: A struct ib_class_port_info.
+ * @rtime: The response time to set.
+ */
+static inline void ib_set_cpi_resp_time(struct ib_class_port_info *cpi,
+					u8 rtime)
+{
+	u32 tmp;
+	u32 tmp2;
+
+	tmp = rtime;
+	tmp = tmp << 3;
+	tmp2 = (be32_to_cpu(cpi->cap_mask2_resp_time) & ~0xF8);
+	tmp = tmp | tmp2;
+	cpi->cap_mask2_resp_time = cpu_to_be32(tmp);
+}
+
+/**
+ * ib_get_cpi_capmask2 - Returns the capmask2 value from
+ * cap_mask2_resp_time in ib_class_port_info.
+ * @cpi: A struct ib_class_port_info mad.
+ */
+static inline u32 ib_get_cpi_capmask2(struct ib_class_port_info *cpi)
+{
+	u8 tmp;
+
+	tmp = ((be32_to_cpu(cpi->cap_mask2_resp_time) & 0x7) << 5);
+	return (((be32_to_cpu(cpi->cap_mask2_resp_time) & ~0xFF) >> 5) | tmp);
+}
+
+/**
+ * ib_set_cpi_capmask2 - Sets the capmask2 in an
+ * ib_class_port_info mad.
+ * @cpi: A struct ib_class_port_info.
+ * @capmask2: The capmask2 to set.
+ */
+static inline void ib_set_cpi_capmask2(struct ib_class_port_info *cpi,
+				       u32 capmask2)
+{
+	u32 tmp;
+
+	tmp = ib_get_cpi_resp_time(cpi);
+	tmp = tmp << 27;
+	cpi->cap_mask2_resp_time = (__force __be32)(tmp | capmask2);
+}
+
 struct ib_mad_notice_attr {
 	u8 generic_type;
 	u8 prod_type_msb;