Re: [PATCH for-next 2/3] RDMA/hns: Add new interfaces to set/clear/read fields in QPC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020/10/7 3:56, Jason Gunthorpe wrote:
> On Wed, Sep 30, 2020 at 05:34:11PM +0800, Weihang Li wrote:
>> From: Lang Cheng <chenglang@xxxxxxxxxx>
>>
>> For a field in extended QPC, there are four newly added interfaces:
>> - hr_reg_set(arr, field) can set all bits to 1,
>> - hr_reg_clear(arr, field) can clear all bits to 0,
>> - hr_reg_write(arr, field, val) can write a new value,
>> - hr_reg_read(arr, field) can read the value.
>> 'arr' is the array name of extended QPC, and 'field' is the global bit
>> offset of the whole array.
>>
>> Signed-off-by: Lang Cheng <chenglang@xxxxxxxxxx>
>> Signed-off-by: Weihang Li <liweihang@xxxxxxxxxx>
>>  drivers/infiniband/hw/hns/hns_roce_common.h | 26 ++++++++++++++++++++++++++
>>  1 file changed, 26 insertions(+)
>>
>> diff --git a/drivers/infiniband/hw/hns/hns_roce_common.h b/drivers/infiniband/hw/hns/hns_roce_common.h
>> index f5669ff..ab2386d 100644
>> +++ b/drivers/infiniband/hw/hns/hns_roce_common.h
>> @@ -53,6 +53,32 @@
>>  #define roce_set_bit(origin, shift, val) \
>>  	roce_set_field((origin), (1ul << (shift)), (shift), (val))
>>  
>> +#define hr_reg_set(arr, field)                                                 \
>> +	((arr)[(field) / 32] |=                                                \
>> +	 cpu_to_le32((field##_W) +                                             \
>> +		     BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr))))
>> +
>> +#define hr_reg_clear(arr, field)                                               \
>> +	((arr)[(field) / 32] &=                                                \
>> +	 ~cpu_to_le32((field##_W) +                                            \
>> +		      BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr))))
>> +
>> +#define hr_reg_write(arr, field, val)                                          \
>> +	do {                                                                   \
>> +		BUILD_BUG_ON((field) / 32 >= ARRAY_SIZE(arr));                 \
>> +		(arr)[(field) / 32] &= ~cpu_to_le32(field##_W);                \
>> +		(arr)[(field) / 32] |= cpu_to_le32(                            \
>> +			((u32)(val) << ((field) % 32)) & (field##_W));         \
>> +	} while (0)
>> +
>> +#define hr_reg_read(arr, field)                                                \
>> +	(((le32_to_cpu((arr)[(field) / 32]) & (field##_W)) >> (field) % 32) +  \
>> +	 BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr)))
> 
> Why add these functions that are not used?
> 
> Jason
> 

hr_reg_set() is to be used in patch 3/3 in this series, the others are prepared
for follow-up series. I will put hr_reg_set() in patch #3 and add other interfaces
only when required.

Thanks
Weihang




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux