[07/13] net/ionic: inline queue flush function

Message ID 20210118203508.1332-8-aboyer@pensando.io (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/ionic: fixes and optimizations |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andrew Boyer Jan. 18, 2021, 8:35 p.m. UTC
  This is hot-path function.

Signed-off-by: Andrew Boyer <aboyer@pensando.io>
Signed-off-by: Neel Patel <neel@pensando.io>
---
 drivers/net/ionic/ionic_dev.c   | 6 ------
 drivers/net/ionic/ionic_dev.h   | 9 ++++++++-
 drivers/net/ionic/ionic_osdep.h | 1 -
 3 files changed, 8 insertions(+), 8 deletions(-)
  

Comments

Ferruh Yigit Jan. 27, 2021, 5:36 p.m. UTC | #1
On 1/18/2021 8:35 PM, Andrew Boyer wrote:
> This is hot-path function.
> 
> Signed-off-by: Andrew Boyer <aboyer@pensando.io>
> Signed-off-by: Neel Patel <neel@pensando.io>
> ---
>   drivers/net/ionic/ionic_dev.c   | 6 ------
>   drivers/net/ionic/ionic_dev.h   | 9 ++++++++-
>   drivers/net/ionic/ionic_osdep.h | 1 -
>   3 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c
> index eef015686f..fcb3df482a 100644
> --- a/drivers/net/ionic/ionic_dev.c
> +++ b/drivers/net/ionic/ionic_dev.c
> @@ -459,12 +459,6 @@ ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa)
>   	q->sg_base_pa = base_pa;
>   }
>   
> -void
> -ionic_q_flush(struct ionic_queue *q)
> -{
> -	writeq(IONIC_DBELL_QID(q->hw_index) | q->head_idx, q->db);
> -}
> -
>   void
>   ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
>   	     void *cb_arg)
> diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h
> index ea89218662..55a56434fd 100644
> --- a/drivers/net/ionic/ionic_dev.h
> +++ b/drivers/net/ionic/ionic_dev.h
> @@ -254,7 +254,6 @@ int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
>   	size_t desc_size, size_t sg_desc_size);
>   void ionic_q_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
>   void ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
> -void ionic_q_flush(struct ionic_queue *q);
>   void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
>   	void *cb_arg);
>   uint32_t ionic_q_space_avail(struct ionic_queue *q);
> @@ -262,6 +261,14 @@ bool ionic_q_has_space(struct ionic_queue *q, uint32_t want);
>   void ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index,
>   	uint32_t stop_index, void *service_cb_arg);
>   
> +static inline void
> +ionic_q_flush(struct ionic_queue *q)
> +{
> +	uint64_t val = IONIC_DBELL_QID(q->hw_index) | q->head_idx;
> +
> +	rte_write64(val, q->db);
> +}
> +

Please be aware of '__rte_always_inline' attribute if you want to force it, 
since 'inline' keyword is only a suggestion to the compilers.

>   int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
>   
>   #endif /* _IONIC_DEV_H_ */
> diff --git a/drivers/net/ionic/ionic_osdep.h b/drivers/net/ionic/ionic_osdep.h
> index 157b0ca516..d46687b32f 100644
> --- a/drivers/net/ionic/ionic_osdep.h
> +++ b/drivers/net/ionic/ionic_osdep.h
> @@ -45,6 +45,5 @@ typedef uint64_t __le64;
>   #define ioread32(reg)		rte_read32(reg)
>   #define iowrite8(value, reg)	rte_write8(value, reg)
>   #define iowrite32(value, reg)	rte_write32(value, reg)
> -#define writeq(value, reg)	rte_write64(value, reg)
>   
>   #endif
>
  
Andrew Boyer Jan. 27, 2021, 5:43 p.m. UTC | #2
> On Jan 27, 2021, at 12:36 PM, Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> 
> On 1/18/2021 8:35 PM, Andrew Boyer wrote:
>> This is hot-path function.
>> Signed-off-by: Andrew Boyer <aboyer@pensando.io>
>> Signed-off-by: Neel Patel <neel@pensando.io>
>> ---
>>  drivers/net/ionic/ionic_dev.c   | 6 ------
>>  drivers/net/ionic/ionic_dev.h   | 9 ++++++++-
>>  drivers/net/ionic/ionic_osdep.h | 1 -
>>  3 files changed, 8 insertions(+), 8 deletions(-)
>> diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c
>> index eef015686f..fcb3df482a 100644
>> --- a/drivers/net/ionic/ionic_dev.c
>> +++ b/drivers/net/ionic/ionic_dev.c
>> @@ -459,12 +459,6 @@ ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa)
>>  	q->sg_base_pa = base_pa;
>>  }
>>  -void
>> -ionic_q_flush(struct ionic_queue *q)
>> -{
>> -	writeq(IONIC_DBELL_QID(q->hw_index) | q->head_idx, q->db);
>> -}
>> -
>>  void
>>  ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
>>  	     void *cb_arg)
>> diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h
>> index ea89218662..55a56434fd 100644
>> --- a/drivers/net/ionic/ionic_dev.h
>> +++ b/drivers/net/ionic/ionic_dev.h
>> @@ -254,7 +254,6 @@ int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
>>  	size_t desc_size, size_t sg_desc_size);
>>  void ionic_q_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
>>  void ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
>> -void ionic_q_flush(struct ionic_queue *q);
>>  void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
>>  	void *cb_arg);
>>  uint32_t ionic_q_space_avail(struct ionic_queue *q);
>> @@ -262,6 +261,14 @@ bool ionic_q_has_space(struct ionic_queue *q, uint32_t want);
>>  void ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index,
>>  	uint32_t stop_index, void *service_cb_arg);
>>  +static inline void
>> +ionic_q_flush(struct ionic_queue *q)
>> +{
>> +	uint64_t val = IONIC_DBELL_QID(q->hw_index) | q->head_idx;
>> +
>> +	rte_write64(val, q->db);
>> +}
>> +
> 
> Please be aware of '__rte_always_inline' attribute if you want to force it, since 'inline' keyword is only a suggestion to the compilers.
> 

Is it though? We are using __rte_always_inline in the hot-path .c file, but I would have said that in a header file the compiler wouldn’t have a choice. Happy to be corrected.

Thanks,
Andrew

>>  int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
>>    #endif /* _IONIC_DEV_H_ */
>> diff --git a/drivers/net/ionic/ionic_osdep.h b/drivers/net/ionic/ionic_osdep.h
>> index 157b0ca516..d46687b32f 100644
>> --- a/drivers/net/ionic/ionic_osdep.h
>> +++ b/drivers/net/ionic/ionic_osdep.h
>> @@ -45,6 +45,5 @@ typedef uint64_t __le64;
>>  #define ioread32(reg)		rte_read32(reg)
>>  #define iowrite8(value, reg)	rte_write8(value, reg)
>>  #define iowrite32(value, reg)	rte_write32(value, reg)
>> -#define writeq(value, reg)	rte_write64(value, reg)
>>    #endif
  
Ferruh Yigit Jan. 27, 2021, 5:50 p.m. UTC | #3
On 1/27/2021 5:43 PM, Andrew Boyer wrote:
> 
> 
>> On Jan 27, 2021, at 12:36 PM, Ferruh Yigit <ferruh.yigit@intel.com 
>> <mailto:ferruh.yigit@intel.com>> wrote:
>>
>> On 1/18/2021 8:35 PM, Andrew Boyer wrote:
>>> This is hot-path function.
>>> Signed-off-by: Andrew Boyer <aboyer@pensando.io <mailto:aboyer@pensando.io>>
>>> Signed-off-by: Neel Patel <neel@pensando.io <mailto:neel@pensando.io>>
>>> ---
>>>  drivers/net/ionic/ionic_dev.c   | 6 ------
>>>  drivers/net/ionic/ionic_dev.h   | 9 ++++++++-
>>>  drivers/net/ionic/ionic_osdep.h | 1 -
>>>  3 files changed, 8 insertions(+), 8 deletions(-)
>>> diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c
>>> index eef015686f..fcb3df482a 100644
>>> --- a/drivers/net/ionic/ionic_dev.c
>>> +++ b/drivers/net/ionic/ionic_dev.c
>>> @@ -459,12 +459,6 @@ ionic_q_sg_map(struct ionic_queue *q, void *base, 
>>> rte_iova_t base_pa)
>>> q->sg_base_pa = base_pa;
>>>  }
>>>  -void
>>> -ionic_q_flush(struct ionic_queue *q)
>>> -{
>>> -writeq(IONIC_DBELL_QID(q->hw_index) | q->head_idx, q->db);
>>> -}
>>> -
>>>  void
>>>  ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
>>>     void *cb_arg)
>>> diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h
>>> index ea89218662..55a56434fd 100644
>>> --- a/drivers/net/ionic/ionic_dev.h
>>> +++ b/drivers/net/ionic/ionic_dev.h
>>> @@ -254,7 +254,6 @@ int ionic_q_init(struct ionic_lif *lif, struct ionic_dev 
>>> *idev,
>>> size_t desc_size, size_t sg_desc_size);
>>>  void ionic_q_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
>>>  void ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
>>> -void ionic_q_flush(struct ionic_queue *q);
>>>  void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
>>> void *cb_arg);
>>>  uint32_t ionic_q_space_avail(struct ionic_queue *q);
>>> @@ -262,6 +261,14 @@ bool ionic_q_has_space(struct ionic_queue *q, uint32_t 
>>> want);
>>>  void ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index,
>>> uint32_t stop_index, void *service_cb_arg);
>>>  +static inline void
>>> +ionic_q_flush(struct ionic_queue *q)
>>> +{
>>> +uint64_t val = IONIC_DBELL_QID(q->hw_index) | q->head_idx;
>>> +
>>> +rte_write64(val, q->db);
>>> +}
>>> +
>>
>> Please be aware of '__rte_always_inline' attribute if you want to force it, 
>> since 'inline' keyword is only a suggestion to the compilers.
>>
> 
> Is it though? We are using __rte_always_inline in the hot-path .c file, but I 
> would have said that in a header file the compiler wouldn’t have a choice. Happy 
> to be corrected.
>

You are right, in the header file compiler doesn't have much choice, so it 
should be OK.

> Thanks,
> Andrew
> 
>>>  int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
>>>    #endif /* _IONIC_DEV_H_ */
>>> diff --git a/drivers/net/ionic/ionic_osdep.h b/drivers/net/ionic/ionic_osdep.h
>>> index 157b0ca516..d46687b32f 100644
>>> --- a/drivers/net/ionic/ionic_osdep.h
>>> +++ b/drivers/net/ionic/ionic_osdep.h
>>> @@ -45,6 +45,5 @@ typedef uint64_t __le64;
>>>  #define ioread32(reg)rte_read32(reg)
>>>  #define iowrite8(value, reg)rte_write8(value, reg)
>>>  #define iowrite32(value, reg)rte_write32(value, reg)
>>> -#define writeq(value, reg)rte_write64(value, reg)
>>>    #endif
>
  

Patch

diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c
index eef015686f..fcb3df482a 100644
--- a/drivers/net/ionic/ionic_dev.c
+++ b/drivers/net/ionic/ionic_dev.c
@@ -459,12 +459,6 @@  ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa)
 	q->sg_base_pa = base_pa;
 }
 
-void
-ionic_q_flush(struct ionic_queue *q)
-{
-	writeq(IONIC_DBELL_QID(q->hw_index) | q->head_idx, q->db);
-}
-
 void
 ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
 	     void *cb_arg)
diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h
index ea89218662..55a56434fd 100644
--- a/drivers/net/ionic/ionic_dev.h
+++ b/drivers/net/ionic/ionic_dev.h
@@ -254,7 +254,6 @@  int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
 	size_t desc_size, size_t sg_desc_size);
 void ionic_q_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
 void ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
-void ionic_q_flush(struct ionic_queue *q);
 void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
 	void *cb_arg);
 uint32_t ionic_q_space_avail(struct ionic_queue *q);
@@ -262,6 +261,14 @@  bool ionic_q_has_space(struct ionic_queue *q, uint32_t want);
 void ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index,
 	uint32_t stop_index, void *service_cb_arg);
 
+static inline void
+ionic_q_flush(struct ionic_queue *q)
+{
+	uint64_t val = IONIC_DBELL_QID(q->hw_index) | q->head_idx;
+
+	rte_write64(val, q->db);
+}
+
 int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
 
 #endif /* _IONIC_DEV_H_ */
diff --git a/drivers/net/ionic/ionic_osdep.h b/drivers/net/ionic/ionic_osdep.h
index 157b0ca516..d46687b32f 100644
--- a/drivers/net/ionic/ionic_osdep.h
+++ b/drivers/net/ionic/ionic_osdep.h
@@ -45,6 +45,5 @@  typedef uint64_t __le64;
 #define ioread32(reg)		rte_read32(reg)
 #define iowrite8(value, reg)	rte_write8(value, reg)
 #define iowrite32(value, reg)	rte_write32(value, reg)
-#define writeq(value, reg)	rte_write64(value, reg)
 
 #endif