* [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
@ 2020-09-30 2:03 ` xiangxia.m.yue
0 siblings, 0 replies; 15+ messages in thread
From: xiangxia.m.yue @ 2020-09-30 2:03 UTC (permalink / raw)
To: jasowang, mst; +Cc: virtualization, netdev, Tonghao Zhang
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Allow user configuring RXCSUM separately with ethtool -K,
reusing the existing virtnet_set_guest_offloads helper
that configures RXCSUM for XDP. This is conditional on
VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
If Rx checksum is disabled, LRO should also be disabled.
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
v2:
* LRO depends the rx csum
* remove the unnecessary check
---
drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
1 file changed, 37 insertions(+), 12 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 21b71148c532..5407a0106771 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
(1ULL << VIRTIO_NET_F_GUEST_ECN) | \
(1ULL << VIRTIO_NET_F_GUEST_UFO))
+#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
+
struct virtnet_stat_desc {
char desc[ETH_GSTRING_LEN];
size_t offset;
@@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
return 0;
}
+static netdev_features_t virtnet_fix_features(struct net_device *netdev,
+ netdev_features_t features)
+{
+ /* If Rx checksum is disabled, LRO should also be disabled.
+ * That is life. :)
+ */
+ if (!(features & NETIF_F_RXCSUM))
+ features &= ~NETIF_F_LRO;
+
+ return features;
+}
+
static int virtnet_set_features(struct net_device *dev,
netdev_features_t features)
{
struct virtnet_info *vi = netdev_priv(dev);
- u64 offloads;
+ u64 offloads = vi->guest_offloads &
+ vi->guest_offloads_capable;
int err;
- if ((dev->features ^ features) & NETIF_F_LRO) {
- if (vi->xdp_queue_pairs)
- return -EBUSY;
+ /* Don't allow configuration while XDP is active. */
+ if (vi->xdp_queue_pairs)
+ return -EBUSY;
+ if ((dev->features ^ features) & NETIF_F_LRO) {
if (features & NETIF_F_LRO)
- offloads = vi->guest_offloads_capable;
+ offloads |= GUEST_OFFLOAD_LRO_MASK;
else
- offloads = vi->guest_offloads_capable &
- ~GUEST_OFFLOAD_LRO_MASK;
+ offloads &= ~GUEST_OFFLOAD_LRO_MASK;
+ }
- err = virtnet_set_guest_offloads(vi, offloads);
- if (err)
- return err;
- vi->guest_offloads = offloads;
+ if ((dev->features ^ features) & NETIF_F_RXCSUM) {
+ if (features & NETIF_F_RXCSUM)
+ offloads |= GUEST_OFFLOAD_CSUM_MASK;
+ else
+ offloads &= ~GUEST_OFFLOAD_CSUM_MASK;
}
+ err = virtnet_set_guest_offloads(vi, offloads);
+ if (err)
+ return err;
+
+ vi->guest_offloads = offloads;
return 0;
}
@@ -2563,6 +2585,7 @@ static const struct net_device_ops virtnet_netdev = {
.ndo_features_check = passthru_features_check,
.ndo_get_phys_port_name = virtnet_get_phys_port_name,
.ndo_set_features = virtnet_set_features,
+ .ndo_fix_features = virtnet_fix_features,
};
static void virtnet_config_changed_work(struct work_struct *work)
@@ -3013,8 +3036,10 @@ static int virtnet_probe(struct virtio_device *vdev)
if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
dev->features |= NETIF_F_LRO;
- if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
+ if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
+ dev->hw_features |= NETIF_F_RXCSUM;
dev->hw_features |= NETIF_F_LRO;
+ }
dev->vlan_features = dev->features;
--
2.23.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
@ 2020-09-30 2:03 ` xiangxia.m.yue
0 siblings, 0 replies; 15+ messages in thread
From: xiangxia.m.yue @ 2020-09-30 2:03 UTC (permalink / raw)
To: jasowang, mst; +Cc: netdev, virtualization
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Allow user configuring RXCSUM separately with ethtool -K,
reusing the existing virtnet_set_guest_offloads helper
that configures RXCSUM for XDP. This is conditional on
VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
If Rx checksum is disabled, LRO should also be disabled.
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
v2:
* LRO depends the rx csum
* remove the unnecessary check
---
drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
1 file changed, 37 insertions(+), 12 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 21b71148c532..5407a0106771 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
(1ULL << VIRTIO_NET_F_GUEST_ECN) | \
(1ULL << VIRTIO_NET_F_GUEST_UFO))
+#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
+
struct virtnet_stat_desc {
char desc[ETH_GSTRING_LEN];
size_t offset;
@@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
return 0;
}
+static netdev_features_t virtnet_fix_features(struct net_device *netdev,
+ netdev_features_t features)
+{
+ /* If Rx checksum is disabled, LRO should also be disabled.
+ * That is life. :)
+ */
+ if (!(features & NETIF_F_RXCSUM))
+ features &= ~NETIF_F_LRO;
+
+ return features;
+}
+
static int virtnet_set_features(struct net_device *dev,
netdev_features_t features)
{
struct virtnet_info *vi = netdev_priv(dev);
- u64 offloads;
+ u64 offloads = vi->guest_offloads &
+ vi->guest_offloads_capable;
int err;
- if ((dev->features ^ features) & NETIF_F_LRO) {
- if (vi->xdp_queue_pairs)
- return -EBUSY;
+ /* Don't allow configuration while XDP is active. */
+ if (vi->xdp_queue_pairs)
+ return -EBUSY;
+ if ((dev->features ^ features) & NETIF_F_LRO) {
if (features & NETIF_F_LRO)
- offloads = vi->guest_offloads_capable;
+ offloads |= GUEST_OFFLOAD_LRO_MASK;
else
- offloads = vi->guest_offloads_capable &
- ~GUEST_OFFLOAD_LRO_MASK;
+ offloads &= ~GUEST_OFFLOAD_LRO_MASK;
+ }
- err = virtnet_set_guest_offloads(vi, offloads);
- if (err)
- return err;
- vi->guest_offloads = offloads;
+ if ((dev->features ^ features) & NETIF_F_RXCSUM) {
+ if (features & NETIF_F_RXCSUM)
+ offloads |= GUEST_OFFLOAD_CSUM_MASK;
+ else
+ offloads &= ~GUEST_OFFLOAD_CSUM_MASK;
}
+ err = virtnet_set_guest_offloads(vi, offloads);
+ if (err)
+ return err;
+
+ vi->guest_offloads = offloads;
return 0;
}
@@ -2563,6 +2585,7 @@ static const struct net_device_ops virtnet_netdev = {
.ndo_features_check = passthru_features_check,
.ndo_get_phys_port_name = virtnet_get_phys_port_name,
.ndo_set_features = virtnet_set_features,
+ .ndo_fix_features = virtnet_fix_features,
};
static void virtnet_config_changed_work(struct work_struct *work)
@@ -3013,8 +3036,10 @@ static int virtnet_probe(struct virtio_device *vdev)
if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
dev->features |= NETIF_F_LRO;
- if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
+ if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
+ dev->hw_features |= NETIF_F_RXCSUM;
dev->hw_features |= NETIF_F_LRO;
+ }
dev->vlan_features = dev->features;
--
2.23.0
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
2020-09-30 2:03 ` xiangxia.m.yue
@ 2020-09-30 10:05 ` Willem de Bruijn
-1 siblings, 0 replies; 15+ messages in thread
From: Willem de Bruijn @ 2020-09-30 10:05 UTC (permalink / raw)
To: Tonghao Zhang
Cc: Jason Wang, Michael S. Tsirkin, virtualization, Network Development
On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
>
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> Allow user configuring RXCSUM separately with ethtool -K,
> reusing the existing virtnet_set_guest_offloads helper
> that configures RXCSUM for XDP. This is conditional on
> VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
>
> If Rx checksum is disabled, LRO should also be disabled.
>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
The first patch was merged into net.
Please wait until that is merged into net-next, as this depends on the
other patch.
> ---
> v2:
> * LRO depends the rx csum
> * remove the unnecessary check
> ---
> drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> 1 file changed, 37 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 21b71148c532..5407a0106771 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> (1ULL << VIRTIO_NET_F_GUEST_UFO))
>
> +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> +
> struct virtnet_stat_desc {
> char desc[ETH_GSTRING_LEN];
> size_t offset;
> @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> return 0;
> }
>
> +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> + netdev_features_t features)
> +{
> + /* If Rx checksum is disabled, LRO should also be disabled.
> + * That is life. :)
Please remove this second line.
> + */
> + if (!(features & NETIF_F_RXCSUM))
> + features &= ~NETIF_F_LRO;
> +
> + return features;
> +}
> +
> static int virtnet_set_features(struct net_device *dev,
> netdev_features_t features)
> {
> struct virtnet_info *vi = netdev_priv(dev);
> - u64 offloads;
> + u64 offloads = vi->guest_offloads &
> + vi->guest_offloads_capable;
When can vi->guest_offloads have bits set outside the mask of
vi->guest_offloads_capable?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
@ 2020-09-30 10:05 ` Willem de Bruijn
0 siblings, 0 replies; 15+ messages in thread
From: Willem de Bruijn @ 2020-09-30 10:05 UTC (permalink / raw)
To: Tonghao Zhang; +Cc: Network Development, virtualization, Michael S. Tsirkin
On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
>
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> Allow user configuring RXCSUM separately with ethtool -K,
> reusing the existing virtnet_set_guest_offloads helper
> that configures RXCSUM for XDP. This is conditional on
> VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
>
> If Rx checksum is disabled, LRO should also be disabled.
>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
The first patch was merged into net.
Please wait until that is merged into net-next, as this depends on the
other patch.
> ---
> v2:
> * LRO depends the rx csum
> * remove the unnecessary check
> ---
> drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> 1 file changed, 37 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 21b71148c532..5407a0106771 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> (1ULL << VIRTIO_NET_F_GUEST_UFO))
>
> +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> +
> struct virtnet_stat_desc {
> char desc[ETH_GSTRING_LEN];
> size_t offset;
> @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> return 0;
> }
>
> +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> + netdev_features_t features)
> +{
> + /* If Rx checksum is disabled, LRO should also be disabled.
> + * That is life. :)
Please remove this second line.
> + */
> + if (!(features & NETIF_F_RXCSUM))
> + features &= ~NETIF_F_LRO;
> +
> + return features;
> +}
> +
> static int virtnet_set_features(struct net_device *dev,
> netdev_features_t features)
> {
> struct virtnet_info *vi = netdev_priv(dev);
> - u64 offloads;
> + u64 offloads = vi->guest_offloads &
> + vi->guest_offloads_capable;
When can vi->guest_offloads have bits set outside the mask of
vi->guest_offloads_capable?
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
2020-09-30 2:03 ` xiangxia.m.yue
@ 2020-09-30 10:06 ` Michael S. Tsirkin
-1 siblings, 0 replies; 15+ messages in thread
From: Michael S. Tsirkin @ 2020-09-30 10:06 UTC (permalink / raw)
To: xiangxia.m.yue; +Cc: jasowang, virtualization, netdev
On Wed, Sep 30, 2020 at 10:03:00AM +0800, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> Allow user configuring RXCSUM separately with ethtool -K,
> reusing the existing virtnet_set_guest_offloads helper
> that configures RXCSUM for XDP. This is conditional on
> VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
>
> If Rx checksum is disabled, LRO should also be disabled.
>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> v2:
> * LRO depends the rx csum
> * remove the unnecessary check
> ---
> drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> 1 file changed, 37 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 21b71148c532..5407a0106771 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> (1ULL << VIRTIO_NET_F_GUEST_UFO))
>
> +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> +
> struct virtnet_stat_desc {
> char desc[ETH_GSTRING_LEN];
> size_t offset;
> @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> return 0;
> }
>
> +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> + netdev_features_t features)
> +{
> + /* If Rx checksum is disabled, LRO should also be disabled.
> + * That is life. :)
> + */
> + if (!(features & NETIF_F_RXCSUM))
> + features &= ~NETIF_F_LRO;
> +
> + return features;
> +}
> +
> static int virtnet_set_features(struct net_device *dev,
> netdev_features_t features)
> {
> struct virtnet_info *vi = netdev_priv(dev);
> - u64 offloads;
> + u64 offloads = vi->guest_offloads &
> + vi->guest_offloads_capable;
> int err;
>
> - if ((dev->features ^ features) & NETIF_F_LRO) {
> - if (vi->xdp_queue_pairs)
> - return -EBUSY;
> + /* Don't allow configuration while XDP is active. */
> + if (vi->xdp_queue_pairs)
> + return -EBUSY;
>
> + if ((dev->features ^ features) & NETIF_F_LRO) {
> if (features & NETIF_F_LRO)
> - offloads = vi->guest_offloads_capable;
> + offloads |= GUEST_OFFLOAD_LRO_MASK;
> else
> - offloads = vi->guest_offloads_capable &
> - ~GUEST_OFFLOAD_LRO_MASK;
> + offloads &= ~GUEST_OFFLOAD_LRO_MASK;
> + }
>
> - err = virtnet_set_guest_offloads(vi, offloads);
> - if (err)
> - return err;
> - vi->guest_offloads = offloads;
> + if ((dev->features ^ features) & NETIF_F_RXCSUM) {
> + if (features & NETIF_F_RXCSUM)
> + offloads |= GUEST_OFFLOAD_CSUM_MASK;
> + else
> + offloads &= ~GUEST_OFFLOAD_CSUM_MASK;
> }
>
> + err = virtnet_set_guest_offloads(vi, offloads);
> + if (err)
> + return err;
> +
> + vi->guest_offloads = offloads;
> return 0;
> }
>
> @@ -2563,6 +2585,7 @@ static const struct net_device_ops virtnet_netdev = {
> .ndo_features_check = passthru_features_check,
> .ndo_get_phys_port_name = virtnet_get_phys_port_name,
> .ndo_set_features = virtnet_set_features,
> + .ndo_fix_features = virtnet_fix_features,
> };
>
> static void virtnet_config_changed_work(struct work_struct *work)
> @@ -3013,8 +3036,10 @@ static int virtnet_probe(struct virtio_device *vdev)
> if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
> virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
> dev->features |= NETIF_F_LRO;
> - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
> + if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
> + dev->hw_features |= NETIF_F_RXCSUM;
> dev->hw_features |= NETIF_F_LRO;
> + }
>
> dev->vlan_features = dev->features;
>
> --
> 2.23.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
@ 2020-09-30 10:06 ` Michael S. Tsirkin
0 siblings, 0 replies; 15+ messages in thread
From: Michael S. Tsirkin @ 2020-09-30 10:06 UTC (permalink / raw)
To: xiangxia.m.yue; +Cc: netdev, virtualization
On Wed, Sep 30, 2020 at 10:03:00AM +0800, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> Allow user configuring RXCSUM separately with ethtool -K,
> reusing the existing virtnet_set_guest_offloads helper
> that configures RXCSUM for XDP. This is conditional on
> VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
>
> If Rx checksum is disabled, LRO should also be disabled.
>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> v2:
> * LRO depends the rx csum
> * remove the unnecessary check
> ---
> drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> 1 file changed, 37 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 21b71148c532..5407a0106771 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> (1ULL << VIRTIO_NET_F_GUEST_UFO))
>
> +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> +
> struct virtnet_stat_desc {
> char desc[ETH_GSTRING_LEN];
> size_t offset;
> @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> return 0;
> }
>
> +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> + netdev_features_t features)
> +{
> + /* If Rx checksum is disabled, LRO should also be disabled.
> + * That is life. :)
> + */
> + if (!(features & NETIF_F_RXCSUM))
> + features &= ~NETIF_F_LRO;
> +
> + return features;
> +}
> +
> static int virtnet_set_features(struct net_device *dev,
> netdev_features_t features)
> {
> struct virtnet_info *vi = netdev_priv(dev);
> - u64 offloads;
> + u64 offloads = vi->guest_offloads &
> + vi->guest_offloads_capable;
> int err;
>
> - if ((dev->features ^ features) & NETIF_F_LRO) {
> - if (vi->xdp_queue_pairs)
> - return -EBUSY;
> + /* Don't allow configuration while XDP is active. */
> + if (vi->xdp_queue_pairs)
> + return -EBUSY;
>
> + if ((dev->features ^ features) & NETIF_F_LRO) {
> if (features & NETIF_F_LRO)
> - offloads = vi->guest_offloads_capable;
> + offloads |= GUEST_OFFLOAD_LRO_MASK;
> else
> - offloads = vi->guest_offloads_capable &
> - ~GUEST_OFFLOAD_LRO_MASK;
> + offloads &= ~GUEST_OFFLOAD_LRO_MASK;
> + }
>
> - err = virtnet_set_guest_offloads(vi, offloads);
> - if (err)
> - return err;
> - vi->guest_offloads = offloads;
> + if ((dev->features ^ features) & NETIF_F_RXCSUM) {
> + if (features & NETIF_F_RXCSUM)
> + offloads |= GUEST_OFFLOAD_CSUM_MASK;
> + else
> + offloads &= ~GUEST_OFFLOAD_CSUM_MASK;
> }
>
> + err = virtnet_set_guest_offloads(vi, offloads);
> + if (err)
> + return err;
> +
> + vi->guest_offloads = offloads;
> return 0;
> }
>
> @@ -2563,6 +2585,7 @@ static const struct net_device_ops virtnet_netdev = {
> .ndo_features_check = passthru_features_check,
> .ndo_get_phys_port_name = virtnet_get_phys_port_name,
> .ndo_set_features = virtnet_set_features,
> + .ndo_fix_features = virtnet_fix_features,
> };
>
> static void virtnet_config_changed_work(struct work_struct *work)
> @@ -3013,8 +3036,10 @@ static int virtnet_probe(struct virtio_device *vdev)
> if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
> virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
> dev->features |= NETIF_F_LRO;
> - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
> + if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
> + dev->hw_features |= NETIF_F_RXCSUM;
> dev->hw_features |= NETIF_F_LRO;
> + }
>
> dev->vlan_features = dev->features;
>
> --
> 2.23.0
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
2020-09-30 10:05 ` Willem de Bruijn
@ 2020-10-09 1:16 ` Tonghao Zhang
-1 siblings, 0 replies; 15+ messages in thread
From: Tonghao Zhang @ 2020-10-09 1:16 UTC (permalink / raw)
To: Willem de Bruijn
Cc: Jason Wang, Michael S. Tsirkin, virtualization, Network Development
On Wed, Sep 30, 2020 at 6:05 PM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
> >
> > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >
> > Allow user configuring RXCSUM separately with ethtool -K,
> > reusing the existing virtnet_set_guest_offloads helper
> > that configures RXCSUM for XDP. This is conditional on
> > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
> >
> > If Rx checksum is disabled, LRO should also be disabled.
> >
> > Cc: Michael S. Tsirkin <mst@redhat.com>
> > Cc: Jason Wang <jasowang@redhat.com>
> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> The first patch was merged into net.
>
> Please wait until that is merged into net-next, as this depends on the
> other patch.
>
> > ---
> > v2:
> > * LRO depends the rx csum
> > * remove the unnecessary check
> > ---
> > drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> > 1 file changed, 37 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index 21b71148c532..5407a0106771 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> > (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> > (1ULL << VIRTIO_NET_F_GUEST_UFO))
> >
> > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> > +
> > struct virtnet_stat_desc {
> > char desc[ETH_GSTRING_LEN];
> > size_t offset;
> > @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> > return 0;
> > }
> >
> > +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> > + netdev_features_t features)
> > +{
> > + /* If Rx checksum is disabled, LRO should also be disabled.
> > + * That is life. :)
>
> Please remove this second line.
OK
> > + */
> > + if (!(features & NETIF_F_RXCSUM))
> > + features &= ~NETIF_F_LRO;
> > +
> > + return features;
> > +}
> > +
> > static int virtnet_set_features(struct net_device *dev,
> > netdev_features_t features)
> > {
> > struct virtnet_info *vi = netdev_priv(dev);
> > - u64 offloads;
> > + u64 offloads = vi->guest_offloads &
> > + vi->guest_offloads_capable;
>
> When can vi->guest_offloads have bits set outside the mask of
> vi->guest_offloads_capable?
In this case, we can use only vi->guest_offloads. and
guest_offloads_capable will not be used any more.
so should we remove guest_offloads_capable ?
--
Best regards, Tonghao
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
@ 2020-10-09 1:16 ` Tonghao Zhang
0 siblings, 0 replies; 15+ messages in thread
From: Tonghao Zhang @ 2020-10-09 1:16 UTC (permalink / raw)
To: Willem de Bruijn; +Cc: Network Development, virtualization, Michael S. Tsirkin
On Wed, Sep 30, 2020 at 6:05 PM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
> >
> > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >
> > Allow user configuring RXCSUM separately with ethtool -K,
> > reusing the existing virtnet_set_guest_offloads helper
> > that configures RXCSUM for XDP. This is conditional on
> > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
> >
> > If Rx checksum is disabled, LRO should also be disabled.
> >
> > Cc: Michael S. Tsirkin <mst@redhat.com>
> > Cc: Jason Wang <jasowang@redhat.com>
> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> The first patch was merged into net.
>
> Please wait until that is merged into net-next, as this depends on the
> other patch.
>
> > ---
> > v2:
> > * LRO depends the rx csum
> > * remove the unnecessary check
> > ---
> > drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> > 1 file changed, 37 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index 21b71148c532..5407a0106771 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> > (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> > (1ULL << VIRTIO_NET_F_GUEST_UFO))
> >
> > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> > +
> > struct virtnet_stat_desc {
> > char desc[ETH_GSTRING_LEN];
> > size_t offset;
> > @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> > return 0;
> > }
> >
> > +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> > + netdev_features_t features)
> > +{
> > + /* If Rx checksum is disabled, LRO should also be disabled.
> > + * That is life. :)
>
> Please remove this second line.
OK
> > + */
> > + if (!(features & NETIF_F_RXCSUM))
> > + features &= ~NETIF_F_LRO;
> > +
> > + return features;
> > +}
> > +
> > static int virtnet_set_features(struct net_device *dev,
> > netdev_features_t features)
> > {
> > struct virtnet_info *vi = netdev_priv(dev);
> > - u64 offloads;
> > + u64 offloads = vi->guest_offloads &
> > + vi->guest_offloads_capable;
>
> When can vi->guest_offloads have bits set outside the mask of
> vi->guest_offloads_capable?
In this case, we can use only vi->guest_offloads. and
guest_offloads_capable will not be used any more.
so should we remove guest_offloads_capable ?
--
Best regards, Tonghao
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
2020-10-09 1:16 ` Tonghao Zhang
@ 2020-10-09 13:48 ` Willem de Bruijn
-1 siblings, 0 replies; 15+ messages in thread
From: Willem de Bruijn @ 2020-10-09 13:48 UTC (permalink / raw)
To: Tonghao Zhang
Cc: Willem de Bruijn, Jason Wang, Michael S. Tsirkin, virtualization,
Network Development
On Thu, Oct 8, 2020 at 9:19 PM Tonghao Zhang <xiangxia.m.yue@gmail.com> wrote:
>
> On Wed, Sep 30, 2020 at 6:05 PM Willem de Bruijn
> <willemdebruijn.kernel@gmail.com> wrote:
> >
> > On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
> > >
> > > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > >
> > > Allow user configuring RXCSUM separately with ethtool -K,
> > > reusing the existing virtnet_set_guest_offloads helper
> > > that configures RXCSUM for XDP. This is conditional on
> > > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
> > >
> > > If Rx checksum is disabled, LRO should also be disabled.
> > >
> > > Cc: Michael S. Tsirkin <mst@redhat.com>
> > > Cc: Jason Wang <jasowang@redhat.com>
> > > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >
> > The first patch was merged into net.
> >
> > Please wait until that is merged into net-next, as this depends on the
> > other patch.
> >
> > > ---
> > > v2:
> > > * LRO depends the rx csum
> > > * remove the unnecessary check
> > > ---
> > > drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> > > 1 file changed, 37 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > index 21b71148c532..5407a0106771 100644
> > > --- a/drivers/net/virtio_net.c
> > > +++ b/drivers/net/virtio_net.c
> > > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> > > (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> > > (1ULL << VIRTIO_NET_F_GUEST_UFO))
> > >
> > > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> > > +
> > > struct virtnet_stat_desc {
> > > char desc[ETH_GSTRING_LEN];
> > > size_t offset;
> > > @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> > > return 0;
> > > }
> > >
> > > +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> > > + netdev_features_t features)
> > > +{
> > > + /* If Rx checksum is disabled, LRO should also be disabled.
> > > + * That is life. :)
> >
> > Please remove this second line.
> OK
> > > + */
> > > + if (!(features & NETIF_F_RXCSUM))
> > > + features &= ~NETIF_F_LRO;
> > > +
> > > + return features;
> > > +}
> > > +
> > > static int virtnet_set_features(struct net_device *dev,
> > > netdev_features_t features)
> > > {
> > > struct virtnet_info *vi = netdev_priv(dev);
> > > - u64 offloads;
> > > + u64 offloads = vi->guest_offloads &
> > > + vi->guest_offloads_capable;
> >
> > When can vi->guest_offloads have bits set outside the mask of
> > vi->guest_offloads_capable?
> In this case, we can use only vi->guest_offloads. and
> guest_offloads_capable will not be used any more.
> so should we remove guest_offloads_capable ?
That bitmap stores the capabilities of the device as learned at
initial device probe. I don't see how it can be removed.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
@ 2020-10-09 13:48 ` Willem de Bruijn
0 siblings, 0 replies; 15+ messages in thread
From: Willem de Bruijn @ 2020-10-09 13:48 UTC (permalink / raw)
To: Tonghao Zhang
Cc: Network Development, Willem de Bruijn, virtualization,
Michael S. Tsirkin
On Thu, Oct 8, 2020 at 9:19 PM Tonghao Zhang <xiangxia.m.yue@gmail.com> wrote:
>
> On Wed, Sep 30, 2020 at 6:05 PM Willem de Bruijn
> <willemdebruijn.kernel@gmail.com> wrote:
> >
> > On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
> > >
> > > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > >
> > > Allow user configuring RXCSUM separately with ethtool -K,
> > > reusing the existing virtnet_set_guest_offloads helper
> > > that configures RXCSUM for XDP. This is conditional on
> > > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
> > >
> > > If Rx checksum is disabled, LRO should also be disabled.
> > >
> > > Cc: Michael S. Tsirkin <mst@redhat.com>
> > > Cc: Jason Wang <jasowang@redhat.com>
> > > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >
> > The first patch was merged into net.
> >
> > Please wait until that is merged into net-next, as this depends on the
> > other patch.
> >
> > > ---
> > > v2:
> > > * LRO depends the rx csum
> > > * remove the unnecessary check
> > > ---
> > > drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> > > 1 file changed, 37 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > index 21b71148c532..5407a0106771 100644
> > > --- a/drivers/net/virtio_net.c
> > > +++ b/drivers/net/virtio_net.c
> > > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> > > (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> > > (1ULL << VIRTIO_NET_F_GUEST_UFO))
> > >
> > > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> > > +
> > > struct virtnet_stat_desc {
> > > char desc[ETH_GSTRING_LEN];
> > > size_t offset;
> > > @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> > > return 0;
> > > }
> > >
> > > +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> > > + netdev_features_t features)
> > > +{
> > > + /* If Rx checksum is disabled, LRO should also be disabled.
> > > + * That is life. :)
> >
> > Please remove this second line.
> OK
> > > + */
> > > + if (!(features & NETIF_F_RXCSUM))
> > > + features &= ~NETIF_F_LRO;
> > > +
> > > + return features;
> > > +}
> > > +
> > > static int virtnet_set_features(struct net_device *dev,
> > > netdev_features_t features)
> > > {
> > > struct virtnet_info *vi = netdev_priv(dev);
> > > - u64 offloads;
> > > + u64 offloads = vi->guest_offloads &
> > > + vi->guest_offloads_capable;
> >
> > When can vi->guest_offloads have bits set outside the mask of
> > vi->guest_offloads_capable?
> In this case, we can use only vi->guest_offloads. and
> guest_offloads_capable will not be used any more.
> so should we remove guest_offloads_capable ?
That bitmap stores the capabilities of the device as learned at
initial device probe. I don't see how it can be removed.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
2020-10-09 13:48 ` Willem de Bruijn
@ 2020-10-10 1:53 ` Tonghao Zhang
-1 siblings, 0 replies; 15+ messages in thread
From: Tonghao Zhang @ 2020-10-10 1:53 UTC (permalink / raw)
To: Willem de Bruijn
Cc: Jason Wang, Michael S. Tsirkin, virtualization, Network Development
On Fri, Oct 9, 2020 at 9:49 PM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> On Thu, Oct 8, 2020 at 9:19 PM Tonghao Zhang <xiangxia.m.yue@gmail.com> wrote:
> >
> > On Wed, Sep 30, 2020 at 6:05 PM Willem de Bruijn
> > <willemdebruijn.kernel@gmail.com> wrote:
> > >
> > > On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
> > > >
> > > > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > > >
> > > > Allow user configuring RXCSUM separately with ethtool -K,
> > > > reusing the existing virtnet_set_guest_offloads helper
> > > > that configures RXCSUM for XDP. This is conditional on
> > > > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
> > > >
> > > > If Rx checksum is disabled, LRO should also be disabled.
> > > >
> > > > Cc: Michael S. Tsirkin <mst@redhat.com>
> > > > Cc: Jason Wang <jasowang@redhat.com>
> > > > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > >
> > > The first patch was merged into net.
> > >
> > > Please wait until that is merged into net-next, as this depends on the
> > > other patch.
> > >
> > > > ---
> > > > v2:
> > > > * LRO depends the rx csum
> > > > * remove the unnecessary check
> > > > ---
> > > > drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> > > > 1 file changed, 37 insertions(+), 12 deletions(-)
> > > >
> > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > > index 21b71148c532..5407a0106771 100644
> > > > --- a/drivers/net/virtio_net.c
> > > > +++ b/drivers/net/virtio_net.c
> > > > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> > > > (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> > > > (1ULL << VIRTIO_NET_F_GUEST_UFO))
> > > >
> > > > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> > > > +
> > > > struct virtnet_stat_desc {
> > > > char desc[ETH_GSTRING_LEN];
> > > > size_t offset;
> > > > @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> > > > return 0;
> > > > }
> > > >
> > > > +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> > > > + netdev_features_t features)
> > > > +{
> > > > + /* If Rx checksum is disabled, LRO should also be disabled.
> > > > + * That is life. :)
> > >
> > > Please remove this second line.
> > OK
> > > > + */
> > > > + if (!(features & NETIF_F_RXCSUM))
> > > > + features &= ~NETIF_F_LRO;
> > > > +
> > > > + return features;
> > > > +}
> > > > +
> > > > static int virtnet_set_features(struct net_device *dev,
> > > > netdev_features_t features)
> > > > {
> > > > struct virtnet_info *vi = netdev_priv(dev);
> > > > - u64 offloads;
> > > > + u64 offloads = vi->guest_offloads &
> > > > + vi->guest_offloads_capable;
> > >
> > > When can vi->guest_offloads have bits set outside the mask of
> > > vi->guest_offloads_capable?
> > In this case, we can use only vi->guest_offloads. and
> > guest_offloads_capable will not be used any more.
> > so should we remove guest_offloads_capable ?
>
> That bitmap stores the capabilities of the device as learned at
> initial device probe. I don't see how it can be removed.
Hi Willem
guest_offloads_capable was introduced by
a02e8964eaf9 ("virtio-net: ethtool configurable LRO")
and used only for LRO. Now we don't use it anymore, right ?
because this patch (virtio-net: ethtool configurable RXCSUM)
doesn't use it.
--
Best regards, Tonghao
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
@ 2020-10-10 1:53 ` Tonghao Zhang
0 siblings, 0 replies; 15+ messages in thread
From: Tonghao Zhang @ 2020-10-10 1:53 UTC (permalink / raw)
To: Willem de Bruijn; +Cc: Network Development, virtualization, Michael S. Tsirkin
On Fri, Oct 9, 2020 at 9:49 PM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> On Thu, Oct 8, 2020 at 9:19 PM Tonghao Zhang <xiangxia.m.yue@gmail.com> wrote:
> >
> > On Wed, Sep 30, 2020 at 6:05 PM Willem de Bruijn
> > <willemdebruijn.kernel@gmail.com> wrote:
> > >
> > > On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
> > > >
> > > > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > > >
> > > > Allow user configuring RXCSUM separately with ethtool -K,
> > > > reusing the existing virtnet_set_guest_offloads helper
> > > > that configures RXCSUM for XDP. This is conditional on
> > > > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
> > > >
> > > > If Rx checksum is disabled, LRO should also be disabled.
> > > >
> > > > Cc: Michael S. Tsirkin <mst@redhat.com>
> > > > Cc: Jason Wang <jasowang@redhat.com>
> > > > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > >
> > > The first patch was merged into net.
> > >
> > > Please wait until that is merged into net-next, as this depends on the
> > > other patch.
> > >
> > > > ---
> > > > v2:
> > > > * LRO depends the rx csum
> > > > * remove the unnecessary check
> > > > ---
> > > > drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> > > > 1 file changed, 37 insertions(+), 12 deletions(-)
> > > >
> > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > > index 21b71148c532..5407a0106771 100644
> > > > --- a/drivers/net/virtio_net.c
> > > > +++ b/drivers/net/virtio_net.c
> > > > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> > > > (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> > > > (1ULL << VIRTIO_NET_F_GUEST_UFO))
> > > >
> > > > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> > > > +
> > > > struct virtnet_stat_desc {
> > > > char desc[ETH_GSTRING_LEN];
> > > > size_t offset;
> > > > @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> > > > return 0;
> > > > }
> > > >
> > > > +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> > > > + netdev_features_t features)
> > > > +{
> > > > + /* If Rx checksum is disabled, LRO should also be disabled.
> > > > + * That is life. :)
> > >
> > > Please remove this second line.
> > OK
> > > > + */
> > > > + if (!(features & NETIF_F_RXCSUM))
> > > > + features &= ~NETIF_F_LRO;
> > > > +
> > > > + return features;
> > > > +}
> > > > +
> > > > static int virtnet_set_features(struct net_device *dev,
> > > > netdev_features_t features)
> > > > {
> > > > struct virtnet_info *vi = netdev_priv(dev);
> > > > - u64 offloads;
> > > > + u64 offloads = vi->guest_offloads &
> > > > + vi->guest_offloads_capable;
> > >
> > > When can vi->guest_offloads have bits set outside the mask of
> > > vi->guest_offloads_capable?
> > In this case, we can use only vi->guest_offloads. and
> > guest_offloads_capable will not be used any more.
> > so should we remove guest_offloads_capable ?
>
> That bitmap stores the capabilities of the device as learned at
> initial device probe. I don't see how it can be removed.
Hi Willem
guest_offloads_capable was introduced by
a02e8964eaf9 ("virtio-net: ethtool configurable LRO")
and used only for LRO. Now we don't use it anymore, right ?
because this patch (virtio-net: ethtool configurable RXCSUM)
doesn't use it.
--
Best regards, Tonghao
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
2020-10-10 1:53 ` Tonghao Zhang
@ 2020-10-10 18:58 ` Willem de Bruijn
-1 siblings, 0 replies; 15+ messages in thread
From: Willem de Bruijn @ 2020-10-10 18:58 UTC (permalink / raw)
To: Tonghao Zhang
Cc: Jason Wang, Michael S. Tsirkin, virtualization, Network Development
On Fri, Oct 9, 2020 at 10:10 PM Tonghao Zhang <xiangxia.m.yue@gmail.com> wrote:
>
> On Fri, Oct 9, 2020 at 9:49 PM Willem de Bruijn
> <willemdebruijn.kernel@gmail.com> wrote:
> >
> > On Thu, Oct 8, 2020 at 9:19 PM Tonghao Zhang <xiangxia.m.yue@gmail.com> wrote:
> > >
> > > On Wed, Sep 30, 2020 at 6:05 PM Willem de Bruijn
> > > <willemdebruijn.kernel@gmail.com> wrote:
> > > >
> > > > On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
> > > > >
> > > > > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > > > >
> > > > > Allow user configuring RXCSUM separately with ethtool -K,
> > > > > reusing the existing virtnet_set_guest_offloads helper
> > > > > that configures RXCSUM for XDP. This is conditional on
> > > > > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
> > > > >
> > > > > If Rx checksum is disabled, LRO should also be disabled.
> > > > >
> > > > > Cc: Michael S. Tsirkin <mst@redhat.com>
> > > > > Cc: Jason Wang <jasowang@redhat.com>
> > > > > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > > >
> > > > The first patch was merged into net.
> > > >
> > > > Please wait until that is merged into net-next, as this depends on the
> > > > other patch.
> > > >
> > > > > ---
> > > > > v2:
> > > > > * LRO depends the rx csum
> > > > > * remove the unnecessary check
> > > > > ---
> > > > > drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> > > > > 1 file changed, 37 insertions(+), 12 deletions(-)
> > > > >
> > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > > > index 21b71148c532..5407a0106771 100644
> > > > > --- a/drivers/net/virtio_net.c
> > > > > +++ b/drivers/net/virtio_net.c
> > > > > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> > > > > (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> > > > > (1ULL << VIRTIO_NET_F_GUEST_UFO))
> > > > >
> > > > > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> > > > > +
> > > > > struct virtnet_stat_desc {
> > > > > char desc[ETH_GSTRING_LEN];
> > > > > size_t offset;
> > > > > @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> > > > > return 0;
> > > > > }
> > > > >
> > > > > +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> > > > > + netdev_features_t features)
> > > > > +{
> > > > > + /* If Rx checksum is disabled, LRO should also be disabled.
> > > > > + * That is life. :)
> > > >
> > > > Please remove this second line.
> > > OK
> > > > > + */
> > > > > + if (!(features & NETIF_F_RXCSUM))
> > > > > + features &= ~NETIF_F_LRO;
> > > > > +
> > > > > + return features;
> > > > > +}
> > > > > +
> > > > > static int virtnet_set_features(struct net_device *dev,
> > > > > netdev_features_t features)
> > > > > {
> > > > > struct virtnet_info *vi = netdev_priv(dev);
> > > > > - u64 offloads;
> > > > > + u64 offloads = vi->guest_offloads &
> > > > > + vi->guest_offloads_capable;
> > > >
> > > > When can vi->guest_offloads have bits set outside the mask of
> > > > vi->guest_offloads_capable?
> > > In this case, we can use only vi->guest_offloads. and
> > > guest_offloads_capable will not be used any more.
> > > so should we remove guest_offloads_capable ?
> >
> > That bitmap stores the capabilities of the device as learned at
> > initial device probe. I don't see how it can be removed.
> Hi Willem
> guest_offloads_capable was introduced by
> a02e8964eaf9 ("virtio-net: ethtool configurable LRO")
> and used only for LRO. Now we don't use it anymore, right ?
> because this patch (virtio-net: ethtool configurable RXCSUM)
> doesn't use it.
It is needed, because it serves as an upper bound on configurable options.
virtnet_set_features cannot enable LRO unless the LRO flags are
captured by the feature negotiation at probe time.
I think on enable you need something like
- offloads = vi->guest_offloads_capable;
+ offloads |= vi->guest_offloads_capable &
GUEST_OFFLOAD_LRO_MASK;
instead of unconditional
+ offloads |= GUEST_OFFLOAD_LRO_MASK;
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
@ 2020-10-10 18:58 ` Willem de Bruijn
0 siblings, 0 replies; 15+ messages in thread
From: Willem de Bruijn @ 2020-10-10 18:58 UTC (permalink / raw)
To: Tonghao Zhang; +Cc: Network Development, virtualization, Michael S. Tsirkin
On Fri, Oct 9, 2020 at 10:10 PM Tonghao Zhang <xiangxia.m.yue@gmail.com> wrote:
>
> On Fri, Oct 9, 2020 at 9:49 PM Willem de Bruijn
> <willemdebruijn.kernel@gmail.com> wrote:
> >
> > On Thu, Oct 8, 2020 at 9:19 PM Tonghao Zhang <xiangxia.m.yue@gmail.com> wrote:
> > >
> > > On Wed, Sep 30, 2020 at 6:05 PM Willem de Bruijn
> > > <willemdebruijn.kernel@gmail.com> wrote:
> > > >
> > > > On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
> > > > >
> > > > > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > > > >
> > > > > Allow user configuring RXCSUM separately with ethtool -K,
> > > > > reusing the existing virtnet_set_guest_offloads helper
> > > > > that configures RXCSUM for XDP. This is conditional on
> > > > > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
> > > > >
> > > > > If Rx checksum is disabled, LRO should also be disabled.
> > > > >
> > > > > Cc: Michael S. Tsirkin <mst@redhat.com>
> > > > > Cc: Jason Wang <jasowang@redhat.com>
> > > > > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > > >
> > > > The first patch was merged into net.
> > > >
> > > > Please wait until that is merged into net-next, as this depends on the
> > > > other patch.
> > > >
> > > > > ---
> > > > > v2:
> > > > > * LRO depends the rx csum
> > > > > * remove the unnecessary check
> > > > > ---
> > > > > drivers/net/virtio_net.c | 49 ++++++++++++++++++++++++++++++----------
> > > > > 1 file changed, 37 insertions(+), 12 deletions(-)
> > > > >
> > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > > > index 21b71148c532..5407a0106771 100644
> > > > > --- a/drivers/net/virtio_net.c
> > > > > +++ b/drivers/net/virtio_net.c
> > > > > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] = {
> > > > > (1ULL << VIRTIO_NET_F_GUEST_ECN) | \
> > > > > (1ULL << VIRTIO_NET_F_GUEST_UFO))
> > > > >
> > > > > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL << VIRTIO_NET_F_GUEST_CSUM)
> > > > > +
> > > > > struct virtnet_stat_desc {
> > > > > char desc[ETH_GSTRING_LEN];
> > > > > size_t offset;
> > > > > @@ -2522,29 +2524,49 @@ static int virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> > > > > return 0;
> > > > > }
> > > > >
> > > > > +static netdev_features_t virtnet_fix_features(struct net_device *netdev,
> > > > > + netdev_features_t features)
> > > > > +{
> > > > > + /* If Rx checksum is disabled, LRO should also be disabled.
> > > > > + * That is life. :)
> > > >
> > > > Please remove this second line.
> > > OK
> > > > > + */
> > > > > + if (!(features & NETIF_F_RXCSUM))
> > > > > + features &= ~NETIF_F_LRO;
> > > > > +
> > > > > + return features;
> > > > > +}
> > > > > +
> > > > > static int virtnet_set_features(struct net_device *dev,
> > > > > netdev_features_t features)
> > > > > {
> > > > > struct virtnet_info *vi = netdev_priv(dev);
> > > > > - u64 offloads;
> > > > > + u64 offloads = vi->guest_offloads &
> > > > > + vi->guest_offloads_capable;
> > > >
> > > > When can vi->guest_offloads have bits set outside the mask of
> > > > vi->guest_offloads_capable?
> > > In this case, we can use only vi->guest_offloads. and
> > > guest_offloads_capable will not be used any more.
> > > so should we remove guest_offloads_capable ?
> >
> > That bitmap stores the capabilities of the device as learned at
> > initial device probe. I don't see how it can be removed.
> Hi Willem
> guest_offloads_capable was introduced by
> a02e8964eaf9 ("virtio-net: ethtool configurable LRO")
> and used only for LRO. Now we don't use it anymore, right ?
> because this patch (virtio-net: ethtool configurable RXCSUM)
> doesn't use it.
It is needed, because it serves as an upper bound on configurable options.
virtnet_set_features cannot enable LRO unless the LRO flags are
captured by the feature negotiation at probe time.
I think on enable you need something like
- offloads = vi->guest_offloads_capable;
+ offloads |= vi->guest_offloads_capable &
GUEST_OFFLOAD_LRO_MASK;
instead of unconditional
+ offloads |= GUEST_OFFLOAD_LRO_MASK;
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM
2020-10-10 18:58 ` Willem de Bruijn
(?)
@ 2020-10-12 5:13 ` Tonghao Zhang
-1 siblings, 0 replies; 15+ messages in thread
From: Tonghao Zhang @ 2020-10-12 5:13 UTC (permalink / raw)
To: Willem de Bruijn; +Cc: Network Development, virtualization, Michael S. Tsirkin
[-- Attachment #1.1: Type: text/plain, Size: 4837 bytes --]
On Sun, Oct 11, 2020 at 2:58 AM Willem de Bruijn <
willemdebruijn.kernel@gmail.com> wrote:
>
> On Fri, Oct 9, 2020 at 10:10 PM Tonghao Zhang <xiangxia.m.yue@gmail.com>
wrote:
> >
> > On Fri, Oct 9, 2020 at 9:49 PM Willem de Bruijn
> > <willemdebruijn.kernel@gmail.com> wrote:
> > >
> > > On Thu, Oct 8, 2020 at 9:19 PM Tonghao Zhang <xiangxia.m.yue@gmail.com>
wrote:
> > > >
> > > > On Wed, Sep 30, 2020 at 6:05 PM Willem de Bruijn
> > > > <willemdebruijn.kernel@gmail.com> wrote:
> > > > >
> > > > > On Wed, Sep 30, 2020 at 4:05 AM <xiangxia.m.yue@gmail.com> wrote:
> > > > > >
> > > > > > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > > > > >
> > > > > > Allow user configuring RXCSUM separately with ethtool -K,
> > > > > > reusing the existing virtnet_set_guest_offloads helper
> > > > > > that configures RXCSUM for XDP. This is conditional on
> > > > > > VIRTIO_NET_F_CTRL_GUEST_OFFLOADS.
> > > > > >
> > > > > > If Rx checksum is disabled, LRO should also be disabled.
> > > > > >
> > > > > > Cc: Michael S. Tsirkin <mst@redhat.com>
> > > > > > Cc: Jason Wang <jasowang@redhat.com>
> > > > > > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > > > >
> > > > > The first patch was merged into net.
> > > > >
> > > > > Please wait until that is merged into net-next, as this depends
on the
> > > > > other patch.
> > > > >
> > > > > > ---
> > > > > > v2:
> > > > > > * LRO depends the rx csum
> > > > > > * remove the unnecessary check
> > > > > > ---
> > > > > > drivers/net/virtio_net.c | 49
++++++++++++++++++++++++++++++----------
> > > > > > 1 file changed, 37 insertions(+), 12 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > > > > index 21b71148c532..5407a0106771 100644
> > > > > > --- a/drivers/net/virtio_net.c
> > > > > > +++ b/drivers/net/virtio_net.c
> > > > > > @@ -68,6 +68,8 @@ static const unsigned long guest_offloads[] =
{
> > > > > > (1ULL <<
VIRTIO_NET_F_GUEST_ECN) | \
> > > > > > (1ULL <<
VIRTIO_NET_F_GUEST_UFO))
> > > > > >
> > > > > > +#define GUEST_OFFLOAD_CSUM_MASK (1ULL <<
VIRTIO_NET_F_GUEST_CSUM)
> > > > > > +
> > > > > > struct virtnet_stat_desc {
> > > > > > char desc[ETH_GSTRING_LEN];
> > > > > > size_t offset;
> > > > > > @@ -2522,29 +2524,49 @@ static int
virtnet_get_phys_port_name(struct net_device *dev, char *buf,
> > > > > > return 0;
> > > > > > }
> > > > > >
> > > > > > +static netdev_features_t virtnet_fix_features(struct
net_device *netdev,
> > > > > > + netdev_features_t
features)
> > > > > > +{
> > > > > > + /* If Rx checksum is disabled, LRO should also be
disabled.
> > > > > > + * That is life. :)
> > > > >
> > > > > Please remove this second line.
> > > > OK
> > > > > > + */
> > > > > > + if (!(features & NETIF_F_RXCSUM))
> > > > > > + features &= ~NETIF_F_LRO;
> > > > > > +
> > > > > > + return features;
> > > > > > +}
> > > > > > +
> > > > > > static int virtnet_set_features(struct net_device *dev,
> > > > > > netdev_features_t features)
> > > > > > {
> > > > > > struct virtnet_info *vi = netdev_priv(dev);
> > > > > > - u64 offloads;
> > > > > > + u64 offloads = vi->guest_offloads &
> > > > > > + vi->guest_offloads_capable;
> > > > >
> > > > > When can vi->guest_offloads have bits set outside the mask of
> > > > > vi->guest_offloads_capable?
> > > > In this case, we can use only vi->guest_offloads. and
> > > > guest_offloads_capable will not be used any more.
> > > > so should we remove guest_offloads_capable ?
> > >
> > > That bitmap stores the capabilities of the device as learned at
> > > initial device probe. I don't see how it can be removed.
> > Hi Willem
> > guest_offloads_capable was introduced by
> > a02e8964eaf9 ("virtio-net: ethtool configurable LRO")
> > and used only for LRO. Now we don't use it anymore, right ?
> > because this patch (virtio-net: ethtool configurable RXCSUM)
> > doesn't use it.
>
> It is needed, because it serves as an upper bound on configurable options.
>
> virtnet_set_features cannot enable LRO unless the LRO flags are
> captured by the feature negotiation at probe time.
>
> I think on enable you need something like
>
> - offloads = vi->guest_offloads_capable;
> + offloads |= vi->guest_offloads_capable &
> GUEST_OFFLOAD_LRO_MASK;
>
> instead of unconditional
>
> + offloads |= GUEST_OFFLOAD_LRO_MASK;
Thanks, I send v3 with your suggestion. please review.
http://patchwork.ozlabs.org/project/netdev/patch/20201012015820.62042-1-xiangxia.m.yue@gmail.com/
--
Best regards, Tonghao
--
Best regards, Tonghao
[-- Attachment #1.2: Type: text/html, Size: 8079 bytes --]
[-- Attachment #2: Type: text/plain, Size: 183 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2020-10-12 5:14 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 2:03 [PATCH net-next v2] virtio-net: ethtool configurable RXCSUM xiangxia.m.yue
2020-09-30 2:03 ` xiangxia.m.yue
2020-09-30 10:05 ` Willem de Bruijn
2020-09-30 10:05 ` Willem de Bruijn
2020-10-09 1:16 ` Tonghao Zhang
2020-10-09 1:16 ` Tonghao Zhang
2020-10-09 13:48 ` Willem de Bruijn
2020-10-09 13:48 ` Willem de Bruijn
2020-10-10 1:53 ` Tonghao Zhang
2020-10-10 1:53 ` Tonghao Zhang
2020-10-10 18:58 ` Willem de Bruijn
2020-10-10 18:58 ` Willem de Bruijn
2020-10-12 5:13 ` Tonghao Zhang
2020-09-30 10:06 ` Michael S. Tsirkin
2020-09-30 10:06 ` Michael S. Tsirkin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.