[v2,4/7] virtio: VIRTIO_DEVICE_F_MASK for all per-device features

Message ID 1675207345-22328-5-git-send-email-si-wei.liu@oracle.com
State New
Headers
Series features provisioning fixes and mlx5_vdpa support |

Commit Message

Si-Wei Liu Jan. 31, 2023, 11:22 p.m. UTC
  Introduce VIRTIO_DEVICE_F_MASK bitmask used for identification
of per-device features. Feature bits VIRTIO_TRANSPORT_F_START
through VIRTIO_TRANSPORT_F_END are reserved for transport
features hence are not counted as per-device features against
the 64bit feature space.

Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
---
 include/uapi/linux/virtio_config.h | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Comments

Michael S. Tsirkin Feb. 2, 2023, 5:29 p.m. UTC | #1
On Tue, Jan 31, 2023 at 03:22:22PM -0800, Si-Wei Liu wrote:
> Introduce VIRTIO_DEVICE_F_MASK bitmask used for identification
> of per-device features. Feature bits VIRTIO_TRANSPORT_F_START
> through VIRTIO_TRANSPORT_F_END are reserved for transport
> features hence are not counted as per-device features against
> the 64bit feature space.
> 
> Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
> ---
>  include/uapi/linux/virtio_config.h | 8 ++++++++
>  1 file changed, 8 insertions(+)

Pls don't add this in uapi, people tend to depend on this and then
things fail when we extend virtio. For example this won't work with >64
feature bits.

> 
> diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h
> index 3c05162..3bdc7ed 100644
> --- a/include/uapi/linux/virtio_config.h
> +++ b/include/uapi/linux/virtio_config.h
> @@ -54,6 +54,14 @@
>  #define VIRTIO_TRANSPORT_F_START	28
>  #define VIRTIO_TRANSPORT_F_END		41
>  
> +/*
> + * Bitmask for all per-device features: feature bits VIRTIO_TRANSPORT_F_START
> + * through VIRTIO_TRANSPORT_F_END are unset, i.e. 0xfffffc000fffffff for
> + * all 64bit features
> + */
> +#define VIRTIO_DEVICE_F_MASK (~0ULL << (VIRTIO_TRANSPORT_F_END + 1) | \
> +			      ((1ULL << VIRTIO_TRANSPORT_F_START) - 1))
> +
>  #ifndef VIRTIO_CONFIG_NO_LEGACY
>  /* Do we get callbacks when the ring is completely used, even if we've
>   * suppressed them? */
> -- 
> 1.8.3.1
  
Si-Wei Liu Feb. 2, 2023, 10 p.m. UTC | #2
On 2/2/2023 9:29 AM, Michael S. Tsirkin wrote:
> On Tue, Jan 31, 2023 at 03:22:22PM -0800, Si-Wei Liu wrote:
>> Introduce VIRTIO_DEVICE_F_MASK bitmask used for identification
>> of per-device features. Feature bits VIRTIO_TRANSPORT_F_START
>> through VIRTIO_TRANSPORT_F_END are reserved for transport
>> features hence are not counted as per-device features against
>> the 64bit feature space.
>>
>> Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
>> ---
>>   include/uapi/linux/virtio_config.h | 8 ++++++++
>>   1 file changed, 8 insertions(+)
> Pls don't add this in uapi, people tend to depend on this and then
> things fail when we extend virtio. For example this won't work with >64
> feature bits.
Good point. Then keep this macro private to vdpa.c for now?

-Siwei
>
>> diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h
>> index 3c05162..3bdc7ed 100644
>> --- a/include/uapi/linux/virtio_config.h
>> +++ b/include/uapi/linux/virtio_config.h
>> @@ -54,6 +54,14 @@
>>   #define VIRTIO_TRANSPORT_F_START	28
>>   #define VIRTIO_TRANSPORT_F_END		41
>>   
>> +/*
>> + * Bitmask for all per-device features: feature bits VIRTIO_TRANSPORT_F_START
>> + * through VIRTIO_TRANSPORT_F_END are unset, i.e. 0xfffffc000fffffff for
>> + * all 64bit features
>> + */
>> +#define VIRTIO_DEVICE_F_MASK (~0ULL << (VIRTIO_TRANSPORT_F_END + 1) | \
>> +			      ((1ULL << VIRTIO_TRANSPORT_F_START) - 1))
>> +
>>   #ifndef VIRTIO_CONFIG_NO_LEGACY
>>   /* Do we get callbacks when the ring is completely used, even if we've
>>    * suppressed them? */
>> -- 
>> 1.8.3.1
  

Patch

diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h
index 3c05162..3bdc7ed 100644
--- a/include/uapi/linux/virtio_config.h
+++ b/include/uapi/linux/virtio_config.h
@@ -54,6 +54,14 @@ 
 #define VIRTIO_TRANSPORT_F_START	28
 #define VIRTIO_TRANSPORT_F_END		41
 
+/*
+ * Bitmask for all per-device features: feature bits VIRTIO_TRANSPORT_F_START
+ * through VIRTIO_TRANSPORT_F_END are unset, i.e. 0xfffffc000fffffff for
+ * all 64bit features
+ */
+#define VIRTIO_DEVICE_F_MASK (~0ULL << (VIRTIO_TRANSPORT_F_END + 1) | \
+			      ((1ULL << VIRTIO_TRANSPORT_F_START) - 1))
+
 #ifndef VIRTIO_CONFIG_NO_LEGACY
 /* Do we get callbacks when the ring is completely used, even if we've
  * suppressed them? */