diff mbox series

[v2,2/2] vdpa: order vdpa_feature_bits array

Message ID b31f0bce96ad1b66fabeace182cddb41fede9683.1688112025.git.yin31149@gmail.com
State New
Headers show
Series vdpa: refactor vdpa_feature_bits array | expand

Commit Message

Hawkins Jiawei June 30, 2023, 8:54 a.m. UTC
This patch reorganizes the vdpa_feature_bits array
in ascending order based on its value to avoid future duplicates.

Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
---
v2:
  - resolve conflicts with the master branch

v1: https://lists.nongnu.org/archive/html/qemu-devel/2023-06/msg01585.html

 net/vhost-vdpa.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

Comments

Philippe Mathieu-Daudé June 30, 2023, 10:20 a.m. UTC | #1
On 30/6/23 10:54, Hawkins Jiawei wrote:
> This patch reorganizes the vdpa_feature_bits array
> in ascending order based on its value to avoid future duplicates.
> 
> Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
> ---
> v2:
>    - resolve conflicts with the master branch
> 
> v1: https://lists.nongnu.org/archive/html/qemu-devel/2023-06/msg01585.html
> 
>   net/vhost-vdpa.c | 24 +++++++++++++-----------
>   1 file changed, 13 insertions(+), 11 deletions(-)
> 
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 0479988a79..db7f1241af 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -50,15 +50,12 @@ typedef struct VhostVDPAState {
>       bool started;
>   } VhostVDPAState;
>   
> +/* The array is sorted in ascending order based on its value */

Alphabetically would have been simpler IMO, anyhow:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Hawkins Jiawei June 30, 2023, 12:18 p.m. UTC | #2
On 2023/6/30 18:20, Philippe Mathieu-Daudé wrote:
> On 30/6/23 10:54, Hawkins Jiawei wrote:
>> This patch reorganizes the vdpa_feature_bits array
>> in ascending order based on its value to avoid future duplicates.
>>
>> Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
>> ---
>> v2:
>>    - resolve conflicts with the master branch
>>
>> v1:
>> https://lists.nongnu.org/archive/html/qemu-devel/2023-06/msg01585.html
>>
>>   net/vhost-vdpa.c | 24 +++++++++++++-----------
>>   1 file changed, 13 insertions(+), 11 deletions(-)
>>
>> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
>> index 0479988a79..db7f1241af 100644
>> --- a/net/vhost-vdpa.c
>> +++ b/net/vhost-vdpa.c
>> @@ -50,15 +50,12 @@ typedef struct VhostVDPAState {
>>       bool started;
>>   } VhostVDPAState;
>> +/* The array is sorted in ascending order based on its value */
>
> Alphabetically would have been simpler IMO, anyhow:

Yes, it seems that rearranging the array in alphabetical order could
improve the maintainability of the code.

I will sort the features alphabetically, excluding
VHOST_INVALID_FEATURE_BIT, according to your suggestion.

Thanks!

> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
diff mbox series

Patch

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 0479988a79..db7f1241af 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -50,15 +50,12 @@  typedef struct VhostVDPAState {
     bool started;
 } VhostVDPAState;
 
+/* The array is sorted in ascending order based on its value */
 const int vdpa_feature_bits[] = {
-    VIRTIO_F_NOTIFY_ON_EMPTY,
-    VIRTIO_RING_F_INDIRECT_DESC,
-    VIRTIO_RING_F_EVENT_IDX,
-    VIRTIO_F_ANY_LAYOUT,
-    VIRTIO_F_VERSION_1,
     VIRTIO_NET_F_CSUM,
     VIRTIO_NET_F_GUEST_CSUM,
     VIRTIO_NET_F_CTRL_GUEST_OFFLOADS,
+    VIRTIO_NET_F_MTU,
     VIRTIO_NET_F_GSO,
     VIRTIO_NET_F_GUEST_TSO4,
     VIRTIO_NET_F_GUEST_TSO6,
@@ -69,19 +66,24 @@  const int vdpa_feature_bits[] = {
     VIRTIO_NET_F_HOST_ECN,
     VIRTIO_NET_F_HOST_UFO,
     VIRTIO_NET_F_MRG_RXBUF,
-    VIRTIO_NET_F_MTU,
+    VIRTIO_NET_F_STATUS,
+    VIRTIO_NET_F_CTRL_VQ,
     VIRTIO_NET_F_CTRL_RX,
-    VIRTIO_NET_F_CTRL_RX_EXTRA,
     VIRTIO_NET_F_CTRL_VLAN,
-    VIRTIO_NET_F_CTRL_MAC_ADDR,
+    VIRTIO_NET_F_CTRL_RX_EXTRA,
     VIRTIO_NET_F_MQ,
-    VIRTIO_NET_F_CTRL_VQ,
+    VIRTIO_NET_F_CTRL_MAC_ADDR,
+    VIRTIO_F_NOTIFY_ON_EMPTY,
+    VIRTIO_F_ANY_LAYOUT,
+    VIRTIO_RING_F_INDIRECT_DESC,
+    VIRTIO_RING_F_EVENT_IDX,
+    VIRTIO_F_VERSION_1,
     VIRTIO_F_IOMMU_PLATFORM,
     VIRTIO_F_RING_PACKED,
     VIRTIO_F_RING_RESET,
-    VIRTIO_NET_F_RSS,
     VIRTIO_NET_F_HASH_REPORT,
-    VIRTIO_NET_F_STATUS,
+    VIRTIO_NET_F_RSS,
+    /* VHOST_INVALID_FEATURE_BIT should always be the last entry */
     VHOST_INVALID_FEATURE_BIT
 };