Skip to contentSkip to conversation

net/mlx5_vdpa: Offer VIRTIO_NET_F_MTU when setting MTU

PATCH Si-Wei Liu 4 participants 5 messages Nov 24, 2021 – Nov 25, 2021 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Si-Wei Liu

author Reviewed-by
#1 lore raw
Quoted 7 lines · Eli Cohen

Make sure to offer VIRTIO_NET_F_MTU since we configure the MTU based on what was queried from the device.

This allows the virtio driver to allocate large enough buffers based on the reported MTU.

Quoted 9 lines
---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 1 +
  1 file changed, 1 insertion(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +0 -0
index 465e832f2ad1..ed7a63e48335 100644

drivers/vdpa/mlx5/net/mlx5_vnet.c static u64 mlx5_vdpa_get_features(struct vdpa_device *vdev) · line 1962

Quoted 7 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -0
@@ -1956,6 +1956,7 @@ static u64 mlx5_vdpa_get_features(struct vdpa_device *vdev)
  	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR);
  	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MQ);
  	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_STATUS);
+	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MTU);
 
  	print_features(mvdev, ndev->mvdev.mlx_features, false);
  	return ndev->mvdev.mlx_features;

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Acked-by
#2 lore raw
In reply to a message not in the archive
Quoted 8 lines · Eli Cohen

Make sure to offer VIRTIO_NET_F_MTU since we configure the MTU based on what was queried from the device.

This allows the virtio driver to allocate large enough buffers based on the reported MTU.

Quoted 17 lines
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -1
index 465e832f2ad1..ed7a63e48335 100644
@@ -1956,6 +1956,7 @@ static u64 mlx5_vdpa_get_features(struct vdpa_device *vdev)
        ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR);
        ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MQ);
        ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_STATUS);
+       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MTU);
 
        print_features(mvdev, ndev->mvdev.mlx_features, false);
        return ndev->mvdev.mlx_features;
--
Quoted 2 lines

2.33.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw
In reply to a message not in the archive
Quoted 22 lines

From: Eli Cohen <[email protected]>
Sent: Wednesday, November 24, 2021 10:40 PM

Make sure to offer VIRTIO_NET_F_MTU since we configure the MTU based on what was queried from the device.

This allows the virtio driver to allocate large enough buffers based on the reported MTU.

---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +0 -0
index 465e832f2ad1..ed7a63e48335 100644

drivers/vdpa/mlx5/net/mlx5_vnet.c static u64 mlx5_vdpa_get_features(struct · line 1961

Quoted 6 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -0
@@ -1956,6 +1956,7 @@ static u64 mlx5_vdpa_get_features(struct
 vdpa_device *vdev)
 	ndev->mvdev.mlx_features |=
 BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR);
 	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MQ);
 	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_STATUS);
+	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MTU);

It is better to set this feature bit along with the writing the RO config.mtu area, adjacent to query_mtu() call.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 35 lines

From: Eli Cohen <[email protected]>
Sent: Thursday, November 25, 2021 1:32 PM

Quoted 16 lines · Parav Pandit
Quoted 16 lines

From: Eli Cohen <[email protected]>
Sent: Wednesday, November 24, 2021 10:40 PM

Make sure to offer VIRTIO_NET_F_MTU since we configure the MTU based on what was queried from the device.

This allows the virtio driver to allocate large enough buffers based on the reported MTU.

---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

drivers/vdpa/mlx5/net/mlx5_vnet.c static u64 mlx5_vdpa_get_features(struct · line 1961

Quoted 12 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -0
index 465e832f2ad1..ed7a63e48335 100644
@@ -1956,6 +1956,7 @@ static u64 mlx5_vdpa_get_features(struct
 vdpa_device *vdev)
 	ndev->mvdev.mlx_features |=
 BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR);
 	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MQ);
 	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_STATUS);
+	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MTU);

It is better to set this feature bit along with the writing the RO config.mtu

Quoted 4 lines

area, adjacent to query_mtu() call.

Why is that so important? We always query the mtu and if the query fails, we fail the initialization so it does not look critical.

It is not so important. But it is more appropriate to set read only field and its associated feature bit at one place, which never changes. There is no need to perform OR operation for those many feature bits on every get_features() callback when they are immutable.

So I wanted to move setting other 5 feature bits assignment at one place in device initialization time similar to how you have done VALID_FEATURES_MASK. Something like below.
But again, its minor.
If you happen to revise the series (I think you should for the supporting dumpit in future), please consider one time assignment like below.

drivers/vdpa/mlx5/net/mlx5_vnet.c +9 -5
index 63813fbb5f62..21802b25b0f5 100644
@@ -1890,11 +1890,6 @@ static u64 mlx5_vdpa_get_features(struct vdpa_device *vdev)
        ndev->mvdev.mlx_features |= mlx_to_vritio_features(dev_features);
        if (MLX5_CAP_DEV_VDPA_EMULATION(mvdev->mdev, virtio_version_1_0))
                ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_F_VERSION_1);
-       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_F_ACCESS_PLATFORM);
-       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_CTRL_VQ);
-       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR);
-       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MQ);
-       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_STATUS);
 
        print_features(mvdev, ndev->mvdev.mlx_features, false);
        return ndev->mvdev.mlx_features;
@@ -2522,6 +2517,14 @@ static int event_handler(struct notifier_block *nb, unsigned long event, void *p
        return ret;
 }
 
+#define DEFAULT_FEATURES \
+       BIT_ULL(VIRTIO_F_ACCESS_PLATFORM) | \
+       BIT_ULL(VIRTIO_NET_F_CTRL_VQ) | \
+       BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) \
+       BIT_ULL(VIRTIO_NET_F_MQ) \
+       BIT_ULL(VIRTIO_NET_F_STATUS) \
+       BIT_ULL(VIRTIO_NET_F_MTU)
+
 static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
                             const struct vdpa_dev_set_config *add_config)
 {
@@ -2565,6 +2568,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
                goto err_mtu;
 
        ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu);
+       ndev->mvdev.mlx_features = DEFAULT_FEATURES;
 
        if (get_link_state(mvdev))
                ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP);

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#6 lore raw
Quoted 65 lines · Parav Pandit
Quoted 35 lines

From: Eli Cohen <[email protected]>
Sent: Thursday, November 25, 2021 1:32 PM

Quoted 16 lines · Parav Pandit
Quoted 16 lines

From: Eli Cohen <[email protected]>
Sent: Wednesday, November 24, 2021 10:40 PM

Make sure to offer VIRTIO_NET_F_MTU since we configure the MTU based on what was queried from the device.

This allows the virtio driver to allocate large enough buffers based on the reported MTU.

---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 13 lines

drivers/vdpa/mlx5/net/mlx5_vnet.c static u64 mlx5_vdpa_get_features(struct · line 1961

Quoted 12 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -0
index 465e832f2ad1..ed7a63e48335 100644
@@ -1956,6 +1956,7 @@ static u64 mlx5_vdpa_get_features(struct
 vdpa_device *vdev)
 	ndev->mvdev.mlx_features |=
 BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR);
 	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MQ);
 	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_STATUS);
+	ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MTU);

It is better to set this feature bit along with the writing the RO config.mtu

Quoted 4 lines

area, adjacent to query_mtu() call.

Why is that so important? We always query the mtu and if the query fails, we fail the initialization so it does not look critical.

It is not so important. But it is more appropriate to set read only field and its associated feature bit at one place, which never changes. There is no need to perform OR operation for those many feature bits on every get_features() callback when they are immutable.

So I wanted to move setting other 5 feature bits assignment at one place in device initialization time similar to how you have done VALID_FEATURES_MASK. Something like below.
But again, its minor.
If you happen to revise the series (I think you should for the supporting dumpit in future), please consider one time assignment like below.

drivers/vdpa/mlx5/net/mlx5_vnet.c +0 -5
index 63813fbb5f62..21802b25b0f5 100644
@@ -1890,11 +1890,6 @@ static u64 mlx5_vdpa_get_features(struct vdpa_device *vdev)
        ndev->mvdev.mlx_features |= mlx_to_vritio_features(dev_features);
        if (MLX5_CAP_DEV_VDPA_EMULATION(mvdev->mdev, virtio_version_1_0))
                ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_F_VERSION_1);
-       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_F_ACCESS_PLATFORM);
-       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_CTRL_VQ);
-       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR);
-       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MQ);
-       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_STATUS);
 
        print_features(mvdev, ndev->mvdev.mlx_features, false);
        return ndev->mvdev.mlx_features;
@@ -2522,6 +2517,14 @@ static int event_handler(struct notifier_block *nb, unsigned long event, void *p
        return ret;

drivers/vdpa/mlx5/net/mlx5_vnet.c static int event_handler(struct notifier_block *nb, unsigned long event, void *p · line 2527

Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +8 -0
 }
 
+#define DEFAULT_FEATURES \
+       BIT_ULL(VIRTIO_F_ACCESS_PLATFORM) | \
+       BIT_ULL(VIRTIO_NET_F_CTRL_VQ) | \
+       BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) \
+       BIT_ULL(VIRTIO_NET_F_MQ) \
+       BIT_ULL(VIRTIO_NET_F_STATUS) \
+       BIT_ULL(VIRTIO_NET_F_MTU)
+

I would just open-code it, don't see what good does the macro do. A single assignment is a bit clearer I think I agree, there's not much of a difference.

drivers/vdpa/mlx5/net/mlx5_vnet.c static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, · line 2574

Quoted 11 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -0
 static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
                             const struct vdpa_dev_set_config *add_config)
 {
@@ -2565,6 +2568,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
                goto err_mtu;
 
        ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu);
+       ndev->mvdev.mlx_features = DEFAULT_FEATURES;
 
        if (get_link_state(mvdev))
                ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP);

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization