* [PATCH net-next,1/2] hv_netvsc: Remove unnecessary var link_state from struct netvsc_device_info
@ 2017-06-21 23:40 Haiyang Zhang
2017-06-21 23:40 ` [PATCH net-next,2/2] hv_netvsc: Fix the carrier state error when data path is off Haiyang Zhang
2017-06-22 17:30 ` [PATCH net-next,1/2] hv_netvsc: Remove unnecessary var link_state from struct netvsc_device_info David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Haiyang Zhang @ 2017-06-21 23:40 UTC (permalink / raw)
To: davem, netdev; +Cc: haiyangz, kys, olaf, vkuznets, linux-kernel
From: Haiyang Zhang <haiyangz@microsoft.com>
We simply use rndis_device->link_state in the netdev_dbg. The variable,
link_state from struct netvsc_device_info, is not used anywhere else.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: Stephen Hemminger <sthemmin@microsoft.com>
---
drivers/net/hyperv/hyperv_net.h | 5 +++--
drivers/net/hyperv/rndis_filter.c | 4 +---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index b30a3c2..ced947d 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -146,7 +146,6 @@ struct hv_netvsc_packet {
struct netvsc_device_info {
unsigned char mac_adr[ETH_ALEN];
- bool link_state; /* 0 - link up, 1 - link down */
int ring_size;
u32 max_num_vrss_chns;
u32 num_chn;
@@ -165,7 +164,7 @@ struct rndis_device {
struct net_device *ndev;
enum rndis_device_state state;
- bool link_state;
+
atomic_t new_req_id;
spinlock_t request_lock;
@@ -173,6 +172,8 @@ struct rndis_device {
struct work_struct mcast_work;
+ bool link_state; /* 0 - link up, 1 - link down */
+
u8 hw_mac_adr[ETH_ALEN];
u8 rss_key[NETVSC_HASH_KEYLEN];
u16 ind_table[ITAB_NUM];
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index cb79cd0..85c00e1 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -1185,11 +1185,9 @@ int rndis_filter_device_add(struct hv_device *dev,
rndis_filter_query_device_link_status(rndis_device);
- device_info->link_state = rndis_device->link_state;
-
netdev_dbg(net, "Device MAC %pM link state %s\n",
rndis_device->hw_mac_adr,
- device_info->link_state ? "down" : "up");
+ rndis_device->link_state ? "down" : "up");
if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5)
return 0;
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net-next,2/2] hv_netvsc: Fix the carrier state error when data path is off
2017-06-21 23:40 [PATCH net-next,1/2] hv_netvsc: Remove unnecessary var link_state from struct netvsc_device_info Haiyang Zhang
@ 2017-06-21 23:40 ` Haiyang Zhang
2017-06-22 17:30 ` David Miller
2017-06-22 17:30 ` [PATCH net-next,1/2] hv_netvsc: Remove unnecessary var link_state from struct netvsc_device_info David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Haiyang Zhang @ 2017-06-21 23:40 UTC (permalink / raw)
To: davem, netdev; +Cc: haiyangz, kys, olaf, vkuznets, linux-kernel
From: Haiyang Zhang <haiyangz@microsoft.com>
When the VF NIC is opened, the synthetic NIC's carrier state is set to
off. This tells the host to transitions data path to the VF device. But
if startup script or user manipulates the admin state of the netvsc
device directly for example:
# ifconfig eth0 down
# ifconfig eth0 up
Then the carrier state of the synthetic NIC would be on, even though the
data path was still over the VF NIC. This patch sets the carrier state
of synthetic NIC with consideration of the related VF state.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: Stephen Hemminger <sthemmin@microsoft.com>
---
drivers/net/hyperv/hyperv_net.h | 2 ++
drivers/net/hyperv/netvsc.c | 2 ++
drivers/net/hyperv/netvsc_drv.c | 8 +++++---
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index ced947d..d6c2558 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -717,6 +717,8 @@ struct net_device_context {
u32 vf_alloc;
/* Serial number of the VF to team with */
u32 vf_serial;
+
+ bool datapath; /* 0 - synthetic, 1 - VF nic */
};
/* Per channel data */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 7c5ed8f..0a9167d 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -57,6 +57,8 @@ void netvsc_switch_datapath(struct net_device *ndev, bool vf)
sizeof(struct nvsp_message),
(unsigned long)init_pkt,
VM_PKT_DATA_INBAND, 0);
+
+ net_device_ctx->datapath = vf;
}
static struct netvsc_device *alloc_net_device(void)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 9a6c586..9913721 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -68,7 +68,8 @@ static void netvsc_set_multicast_list(struct net_device *net)
static int netvsc_open(struct net_device *net)
{
- struct netvsc_device *nvdev = net_device_to_netvsc_device(net);
+ struct net_device_context *ndev_ctx = netdev_priv(net);
+ struct netvsc_device *nvdev = ndev_ctx->nvdev;
struct rndis_device *rdev;
int ret = 0;
@@ -84,7 +85,7 @@ static int netvsc_open(struct net_device *net)
netif_tx_wake_all_queues(net);
rdev = nvdev->extension;
- if (!rdev->link_state)
+ if (!rdev->link_state && !ndev_ctx->datapath)
netif_carrier_on(net);
return ret;
@@ -1284,7 +1285,8 @@ static void netvsc_link_change(struct work_struct *w)
case RNDIS_STATUS_MEDIA_CONNECT:
if (rdev->link_state) {
rdev->link_state = false;
- netif_carrier_on(net);
+ if (!ndev_ctx->datapath)
+ netif_carrier_on(net);
netif_tx_wake_all_queues(net);
} else {
notify = true;
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net-next,2/2] hv_netvsc: Fix the carrier state error when data path is off
2017-06-21 23:40 ` [PATCH net-next,2/2] hv_netvsc: Fix the carrier state error when data path is off Haiyang Zhang
@ 2017-06-22 17:30 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-06-22 17:30 UTC (permalink / raw)
To: haiyangz, haiyangz; +Cc: netdev, kys, olaf, vkuznets, linux-kernel
From: Haiyang Zhang <haiyangz@exchange.microsoft.com>
Date: Wed, 21 Jun 2017 16:40:47 -0700
> From: Haiyang Zhang <haiyangz@microsoft.com>
>
> When the VF NIC is opened, the synthetic NIC's carrier state is set to
> off. This tells the host to transitions data path to the VF device. But
> if startup script or user manipulates the admin state of the netvsc
> device directly for example:
> # ifconfig eth0 down
> # ifconfig eth0 up
> Then the carrier state of the synthetic NIC would be on, even though the
> data path was still over the VF NIC. This patch sets the carrier state
> of synthetic NIC with consideration of the related VF state.
>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Reviewed-by: Stephen Hemminger <sthemmin@microsoft.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next,1/2] hv_netvsc: Remove unnecessary var link_state from struct netvsc_device_info
2017-06-21 23:40 [PATCH net-next,1/2] hv_netvsc: Remove unnecessary var link_state from struct netvsc_device_info Haiyang Zhang
2017-06-21 23:40 ` [PATCH net-next,2/2] hv_netvsc: Fix the carrier state error when data path is off Haiyang Zhang
@ 2017-06-22 17:30 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-06-22 17:30 UTC (permalink / raw)
To: haiyangz, haiyangz; +Cc: netdev, kys, olaf, vkuznets, linux-kernel
From: Haiyang Zhang <haiyangz@exchange.microsoft.com>
Date: Wed, 21 Jun 2017 16:40:46 -0700
> From: Haiyang Zhang <haiyangz@microsoft.com>
>
> We simply use rndis_device->link_state in the netdev_dbg. The variable,
> link_state from struct netvsc_device_info, is not used anywhere else.
>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Reviewed-by: Stephen Hemminger <sthemmin@microsoft.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-22 17:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-21 23:40 [PATCH net-next,1/2] hv_netvsc: Remove unnecessary var link_state from struct netvsc_device_info Haiyang Zhang
2017-06-21 23:40 ` [PATCH net-next,2/2] hv_netvsc: Fix the carrier state error when data path is off Haiyang Zhang
2017-06-22 17:30 ` David Miller
2017-06-22 17:30 ` [PATCH net-next,1/2] hv_netvsc: Remove unnecessary var link_state from struct netvsc_device_info David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).