Skip to contentSkip to conversation

hv_netvsc: preserve hw_features on mtu/channels/ringparam changes

PATCH Applied Vitaly Kuznetsov 3 participants 3 messages Nov 15, 2017 – Nov 16, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hv_netvsc: preserve hw_features on mtu/channels/ringparam changes

rndis_filter_device_add() is called both from netvsc_probe() when we initially create the device and from set channels/mtu/ringparam routines where we basically remove the device and add it back.

hw_features is reset in rndis_filter_device_add() and filled with host data. However, we lose all additional flags which are set outside of the driver, e.g. register_netdevice() adds NETIF_F_SOFT_FEATURES and many others.

Unfortunately, calls to rndis_{query_hwcaps(), _set_offload_params()} calls cannot be avoided on every RNDIS reset: host expects us to set required features explicitly. Moreover, in theory hardware capabilities can change and we need to reflect the change in hw_features.

Reset net->hw_features bits according to host data in rndis_netdev_set_hwcaps(), clear corresponding feature bits from net->features in case some features went missing (will never happen in real life I guess but let's be consistent).

---
Changes since v1: call rndis_netdev_set_hwcaps() unconditionally; clear net->hw_features flags we set and set them again based on host's data. Clear missing features from net->features.

Unfortunately, not calling rndis_netdev_set_hwcaps() on mtu/channels/ ringparam changes is not an option: we still need to call rndis_{query_hwcaps(),set_offload_params()} or we will lose features [Haiyang Zhang]

---
 drivers/net/hyperv/hyperv_net.h   |   4 ++
 drivers/net/hyperv/netvsc_drv.c   |   2 +-
 drivers/net/hyperv/rndis_filter.c | 136 ++++++++++++++++++++++----------------
 3 files changed, 83 insertions(+), 59 deletions(-)
drivers/net/hyperv/hyperv_net.h +4 -0
index 5176be76ca7d..b6cbda2963ad 100644
@@ -646,6 +646,10 @@ struct nvsp_message {
 #define NETVSC_RECEIVE_BUFFER_ID		0xcafe
 #define NETVSC_SEND_BUFFER_ID			0
 
+#define NETVSC_SUPPORTED_HW_FEATURES (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | \
+				      NETIF_F_TSO | NETIF_F_IPV6_CSUM | \
+				      NETIF_F_TSO6)
+
 #define VRSS_SEND_TAB_SIZE 16  /* must be power of 2 */
 #define VRSS_CHANNEL_MAX 64
 #define VRSS_CHANNEL_DEFAULT 8
drivers/net/hyperv/netvsc_drv.c +1 -1
index a32ae02e1b6c..fc1d0b4bca22 100644
@@ -1953,7 +1953,7 @@ static int netvsc_probe(struct hv_device *dev,
 
 	memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN);
 
-	/* hw_features computed in rndis_filter_device_add */
+	/* hw_features computed in rndis_netdev_set_hwcaps() */
 	net->features = net->hw_features |
 		NETIF_F_HIGHDMA | NETIF_F_SG |
 		NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX;
drivers/net/hyperv/rndis_filter.c +78 -58

165 lines not on this page · raw message

Signature · 1 line
2.14.3
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 27 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Wednesday, November 15, 2017 9:13 AM
To: [email protected]
Cc: [email protected]; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Stephen Hemminger <[email protected]>; Mohammed Gamal <[email protected]>
Subject: [PATCH net v2] hv_netvsc: preserve hw_features on mtu/channels/ringparam changes

rndis_filter_device_add() is called both from netvsc_probe() when we initially create the device and from set channels/mtu/ringparam routines where we basically remove the device and add it back.

hw_features is reset in rndis_filter_device_add() and filled with host data. However, we lose all additional flags which are set outside of the driver, e.g. register_netdevice() adds NETIF_F_SOFT_FEATURES and many others.

Unfortunately, calls to rndis_{query_hwcaps(), _set_offload_params()} calls cannot be avoided on every RNDIS reset: host expects us to set required features explicitly. Moreover, in theory hardware capabilities can change and we need to reflect the change in hw_features.

Quoted 6 lines

Reset net->hw_features bits according to host data in rndis_netdev_set_hwcaps(), clear corresponding feature bits from net->features in case some features went missing (will never happen in real life I guess but let's be consistent).

Thank you!

maintainer Applied
#2 lore raw
In reply to Vitaly Kuznetsov

From: Vitaly Kuznetsov <[email protected]>
Date: Wed, 15 Nov 2017 15:12:55 +0100

Quoted 14 lines

rndis_filter_device_add() is called both from netvsc_probe() when we initially create the device and from set channels/mtu/ringparam routines where we basically remove the device and add it back.

hw_features is reset in rndis_filter_device_add() and filled with host data. However, we lose all additional flags which are set outside of the driver, e.g. register_netdevice() adds NETIF_F_SOFT_FEATURES and many others.

Unfortunately, calls to rndis_{query_hwcaps(), _set_offload_params()} calls cannot be avoided on every RNDIS reset: host expects us to set required features explicitly. Moreover, in theory hardware capabilities can change and we need to reflect the change in hw_features.

Quoted 6 lines

Reset net->hw_features bits according to host data in rndis_netdev_set_hwcaps(), clear corresponding feature bits from net->features in case some features went missing (will never happen in real life I guess but let's be consistent).

Applied.