* [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove
@ 2021-01-09 0:53 Long Li
2021-01-09 0:53 ` [PATCH v2 1/3] hv_netvsc: Check VF datapath when sending traffic to VF Long Li
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Long Li @ 2021-01-09 0:53 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
David S. Miller, Jakub Kicinski, linux-hyperv, netdev,
linux-kernel
Cc: Long Li
From: Long Li <longli@microsoft.com>
This patch set fixes issues with packet loss on VF add/remove.
Long Li (3):
hv_netvsc: Check VF datapath when sending traffic to VF
hv_netvsc: Wait for completion on request SWITCH_DATA_PATH
hv_netvsc: Process NETDEV_GOING_DOWN on VF hot remove
drivers/net/hyperv/netvsc.c | 37 ++++++++++++++++++++++++++++++---
drivers/net/hyperv/netvsc_drv.c | 14 ++++++++-----
2 files changed, 43 insertions(+), 8 deletions(-)
--
2.27.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/3] hv_netvsc: Check VF datapath when sending traffic to VF
2021-01-09 0:53 [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove Long Li
@ 2021-01-09 0:53 ` Long Li
2021-01-09 0:53 ` [PATCH v2 2/3] hv_netvsc: Wait for completion on request SWITCH_DATA_PATH Long Li
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Long Li @ 2021-01-09 0:53 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
David S. Miller, Jakub Kicinski, linux-hyperv, netdev,
linux-kernel
Cc: Long Li
From: Long Li <longli@microsoft.com>
The driver needs to check if the datapath has been switched to VF before
sending traffic to VF.
Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f32f28311d57..5dd4f37afa3d 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -539,7 +539,8 @@ static int netvsc_xmit(struct sk_buff *skb, struct net_device *net, bool xdp_tx)
*/
vf_netdev = rcu_dereference_bh(net_device_ctx->vf_netdev);
if (vf_netdev && netif_running(vf_netdev) &&
- netif_carrier_ok(vf_netdev) && !netpoll_tx_running(net))
+ netif_carrier_ok(vf_netdev) && !netpoll_tx_running(net) &&
+ net_device_ctx->data_path_is_vf)
return netvsc_vf_xmit(net, vf_netdev, skb);
/* We will atmost need two pages to describe the rndis
--
2.27.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] hv_netvsc: Wait for completion on request SWITCH_DATA_PATH
2021-01-09 0:53 [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove Long Li
2021-01-09 0:53 ` [PATCH v2 1/3] hv_netvsc: Check VF datapath when sending traffic to VF Long Li
@ 2021-01-09 0:53 ` Long Li
2021-01-09 0:53 ` [PATCH v2 3/3] hv_netvsc: Process NETDEV_GOING_DOWN on VF hot remove Long Li
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Long Li @ 2021-01-09 0:53 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
David S. Miller, Jakub Kicinski, linux-hyperv, netdev,
linux-kernel
Cc: Long Li
From: Long Li <longli@microsoft.com>
The completion indicates if NVSP_MSG4_TYPE_SWITCH_DATA_PATH has been
processed by the VSP. The traffic is steered to VF or synthetic after we
receive this completion.
Signed-off-by: Long Li <longli@microsoft.com>
Reported-by: kernel test robot <lkp@intel.com>
---
Change from v1:
Fixed warnings from kernel test robot.
drivers/net/hyperv/netvsc.c | 37 ++++++++++++++++++++++++++++++---
drivers/net/hyperv/netvsc_drv.c | 1 -
2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 2350342b961f..3a3db2f0134d 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -37,6 +37,10 @@ void netvsc_switch_datapath(struct net_device *ndev, bool vf)
struct netvsc_device *nv_dev = rtnl_dereference(net_device_ctx->nvdev);
struct nvsp_message *init_pkt = &nv_dev->channel_init_pkt;
+ /* Block sending traffic to VF if it's about to be gone */
+ if (!vf)
+ net_device_ctx->data_path_is_vf = vf;
+
memset(init_pkt, 0, sizeof(struct nvsp_message));
init_pkt->hdr.msg_type = NVSP_MSG4_TYPE_SWITCH_DATA_PATH;
if (vf)
@@ -50,8 +54,11 @@ void netvsc_switch_datapath(struct net_device *ndev, bool vf)
vmbus_sendpacket(dev->channel, init_pkt,
sizeof(struct nvsp_message),
- VMBUS_RQST_ID_NO_RESPONSE,
- VM_PKT_DATA_INBAND, 0);
+ (unsigned long)init_pkt,
+ VM_PKT_DATA_INBAND,
+ VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+ wait_for_completion(&nv_dev->channel_init_wait);
+ net_device_ctx->data_path_is_vf = vf;
}
/* Worker to setup sub channels on initial setup
@@ -754,8 +761,31 @@ static void netvsc_send_completion(struct net_device *ndev,
const struct vmpacket_descriptor *desc,
int budget)
{
- const struct nvsp_message *nvsp_packet = hv_pkt_data(desc);
+ const struct nvsp_message *nvsp_packet;
u32 msglen = hv_pkt_datalen(desc);
+ struct nvsp_message *pkt_rqst;
+ u64 cmd_rqst;
+
+ /* First check if this is a VMBUS completion without data payload */
+ if (!msglen) {
+ cmd_rqst = vmbus_request_addr(&incoming_channel->requestor,
+ (u64)desc->trans_id);
+ if (cmd_rqst == VMBUS_RQST_ERROR) {
+ netdev_err(ndev, "Invalid transaction id\n");
+ return;
+ }
+
+ pkt_rqst = (struct nvsp_message *)(uintptr_t)cmd_rqst;
+ switch (pkt_rqst->hdr.msg_type) {
+ case NVSP_MSG4_TYPE_SWITCH_DATA_PATH:
+ complete(&net_device->channel_init_wait);
+ break;
+
+ default:
+ netdev_err(ndev, "Unexpected VMBUS completion!!\n");
+ }
+ return;
+ }
/* Ensure packet is big enough to read header fields */
if (msglen < sizeof(struct nvsp_message_header)) {
@@ -763,6 +793,7 @@ static void netvsc_send_completion(struct net_device *ndev,
return;
}
+ nvsp_packet = hv_pkt_data(desc);
switch (nvsp_packet->hdr.msg_type) {
case NVSP_MSG_TYPE_INIT_COMPLETE:
if (msglen < sizeof(struct nvsp_message_header) +
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 5dd4f37afa3d..64ae5f4e974e 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2400,7 +2400,6 @@ static int netvsc_vf_changed(struct net_device *vf_netdev)
if (net_device_ctx->data_path_is_vf == vf_is_up)
return NOTIFY_OK;
- net_device_ctx->data_path_is_vf = vf_is_up;
netvsc_switch_datapath(ndev, vf_is_up);
netdev_info(ndev, "Data path switched %s VF: %s\n",
--
2.27.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] hv_netvsc: Process NETDEV_GOING_DOWN on VF hot remove
2021-01-09 0:53 [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove Long Li
2021-01-09 0:53 ` [PATCH v2 1/3] hv_netvsc: Check VF datapath when sending traffic to VF Long Li
2021-01-09 0:53 ` [PATCH v2 2/3] hv_netvsc: Wait for completion on request SWITCH_DATA_PATH Long Li
@ 2021-01-09 0:53 ` Long Li
2021-01-12 2:07 ` [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove Jakub Kicinski
2021-01-13 4:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 7+ messages in thread
From: Long Li @ 2021-01-09 0:53 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
David S. Miller, Jakub Kicinski, linux-hyperv, netdev,
linux-kernel
Cc: Long Li
From: Long Li <longli@microsoft.com>
On VF hot remove, NETDEV_GOING_DOWN is sent to notify the VF is about to
go down. At this time, the VF is still sending/receiving traffic and we
request the VSP to switch datapath.
On completion, the datapath is switched to synthetic and we can proceed
with VF hot remove.
Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 64ae5f4e974e..75b4d6703cf1 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2382,12 +2382,15 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
* During hibernation, if a VF NIC driver (e.g. mlx5) preserves the network
* interface, there is only the CHANGE event and no UP or DOWN event.
*/
-static int netvsc_vf_changed(struct net_device *vf_netdev)
+static int netvsc_vf_changed(struct net_device *vf_netdev, unsigned long event)
{
struct net_device_context *net_device_ctx;
struct netvsc_device *netvsc_dev;
struct net_device *ndev;
- bool vf_is_up = netif_running(vf_netdev);
+ bool vf_is_up = false;
+
+ if (event != NETDEV_GOING_DOWN)
+ vf_is_up = netif_running(vf_netdev);
ndev = get_netvsc_byref(vf_netdev);
if (!ndev)
@@ -2716,7 +2719,8 @@ static int netvsc_netdev_event(struct notifier_block *this,
case NETDEV_UP:
case NETDEV_DOWN:
case NETDEV_CHANGE:
- return netvsc_vf_changed(event_dev);
+ case NETDEV_GOING_DOWN:
+ return netvsc_vf_changed(event_dev, event);
default:
return NOTIFY_DONE;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove
2021-01-09 0:53 [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove Long Li
` (2 preceding siblings ...)
2021-01-09 0:53 ` [PATCH v2 3/3] hv_netvsc: Process NETDEV_GOING_DOWN on VF hot remove Long Li
@ 2021-01-12 2:07 ` Jakub Kicinski
2021-01-12 21:31 ` Long Li
2021-01-13 4:10 ` patchwork-bot+netdevbpf
4 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2021-01-12 2:07 UTC (permalink / raw)
To: Long Li
Cc: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
David S. Miller, linux-hyperv, netdev, linux-kernel, Long Li
On Fri, 8 Jan 2021 16:53:40 -0800 Long Li wrote:
> From: Long Li <longli@microsoft.com>
>
> This patch set fixes issues with packet loss on VF add/remove.
These patches are for net-next? They just optimize the amount of packet
loss on switch, not fix bugs, right?
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove
2021-01-12 2:07 ` [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove Jakub Kicinski
@ 2021-01-12 21:31 ` Long Li
0 siblings, 0 replies; 7+ messages in thread
From: Long Li @ 2021-01-12 21:31 UTC (permalink / raw)
To: Jakub Kicinski, Long Li
Cc: KY Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
David S. Miller, linux-hyperv, netdev, linux-kernel
> Subject: Re: [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF
> add/remove
>
> On Fri, 8 Jan 2021 16:53:40 -0800 Long Li wrote:
> > From: Long Li <longli@microsoft.com>
> >
> > This patch set fixes issues with packet loss on VF add/remove.
>
> These patches are for net-next? They just optimize the amount of packet
> loss on switch, not fix bugs, right?
Yes, those patches are for net-next.
They eliminate the packet loss introduced from Linux side during VF changes. They can be seen as optimizations.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove
2021-01-09 0:53 [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove Long Li
` (3 preceding siblings ...)
2021-01-12 2:07 ` [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove Jakub Kicinski
@ 2021-01-13 4:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-01-13 4:10 UTC (permalink / raw)
To: Long Li
Cc: kys, haiyangz, sthemmin, wei.liu, davem, kuba, linux-hyperv,
netdev, linux-kernel, longli
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
On Fri, 8 Jan 2021 16:53:40 -0800 you wrote:
> From: Long Li <longli@microsoft.com>
>
> This patch set fixes issues with packet loss on VF add/remove.
>
> Long Li (3):
> hv_netvsc: Check VF datapath when sending traffic to VF
> hv_netvsc: Wait for completion on request SWITCH_DATA_PATH
> hv_netvsc: Process NETDEV_GOING_DOWN on VF hot remove
>
> [...]
Here is the summary with links:
- [v2,1/3] hv_netvsc: Check VF datapath when sending traffic to VF
https://git.kernel.org/netdev/net-next/c/69d25a6cf4ca
- [v2,2/3] hv_netvsc: Wait for completion on request SWITCH_DATA_PATH
https://git.kernel.org/netdev/net-next/c/8b31f8c982b7
- [v2,3/3] hv_netvsc: Process NETDEV_GOING_DOWN on VF hot remove
https://git.kernel.org/netdev/net-next/c/34b06a2eee44
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-01-13 4:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-09 0:53 [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove Long Li
2021-01-09 0:53 ` [PATCH v2 1/3] hv_netvsc: Check VF datapath when sending traffic to VF Long Li
2021-01-09 0:53 ` [PATCH v2 2/3] hv_netvsc: Wait for completion on request SWITCH_DATA_PATH Long Li
2021-01-09 0:53 ` [PATCH v2 3/3] hv_netvsc: Process NETDEV_GOING_DOWN on VF hot remove Long Li
2021-01-12 2:07 ` [PATCH v2 0/3] hv_netvsc: Prevent packet loss during VF add/remove Jakub Kicinski
2021-01-12 21:31 ` Long Li
2021-01-13 4:10 ` patchwork-bot+netdevbpf
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.