Commit 3f300ff4 authored by Simon Xiao's avatar Simon Xiao Committed by David S. Miller

hv_netvsc: introduce netif-msg into netvsc module

1. Introduce netif-msg to netvsc to control debug logging output
and keep msg_enable in netvsc_device_context so that it is
kept persistently.
2. Only call dump_rndis_message() when NETIF_MSG_RX_ERR or above
is specified in netvsc module debug param.
In non-debug mode, in current code, dump_rndis_message() will not
dump anything but it still initialize some local variables and
process the switch logic which is unnecessary, especially in
high network throughput situation.
Signed-off-by: default avatarSimon Xiao <sixiao@microsoft.com>
Reviewed-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb6ccf09
...@@ -612,6 +612,15 @@ struct multi_send_data { ...@@ -612,6 +612,15 @@ struct multi_send_data {
u32 count; /* counter of batched packets */ u32 count; /* counter of batched packets */
}; };
/* The context of the netvsc device */
struct net_device_context {
/* point back to our device context */
struct hv_device *device_ctx;
struct delayed_work dwork;
struct work_struct work;
u32 msg_enable; /* debug level */
};
/* Per netvsc device */ /* Per netvsc device */
struct netvsc_device { struct netvsc_device {
struct hv_device *dev; struct hv_device *dev;
...@@ -667,6 +676,9 @@ struct netvsc_device { ...@@ -667,6 +676,9 @@ struct netvsc_device {
struct multi_send_data msd[NR_CPUS]; struct multi_send_data msd[NR_CPUS];
u32 max_pkt; /* max number of pkt in one send, e.g. 8 */ u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
u32 pkt_align; /* alignment bytes, e.g. 8 */ u32 pkt_align; /* alignment bytes, e.g. 8 */
/* The net device context */
struct net_device_context *nd_ctx;
}; };
/* NdisInitialize message */ /* NdisInitialize message */
......
...@@ -1197,6 +1197,9 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) ...@@ -1197,6 +1197,9 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
*/ */
ndev = net_device->ndev; ndev = net_device->ndev;
/* Add netvsc_device context to netvsc_device */
net_device->nd_ctx = netdev_priv(ndev);
/* Initialize the NetVSC channel extension */ /* Initialize the NetVSC channel extension */
init_completion(&net_device->channel_init_wait); init_completion(&net_device->channel_init_wait);
......
...@@ -40,18 +40,21 @@ ...@@ -40,18 +40,21 @@
#include "hyperv_net.h" #include "hyperv_net.h"
struct net_device_context {
/* point back to our device context */
struct hv_device *device_ctx;
struct delayed_work dwork;
struct work_struct work;
};
#define RING_SIZE_MIN 64 #define RING_SIZE_MIN 64
static int ring_size = 128; static int ring_size = 128;
module_param(ring_size, int, S_IRUGO); module_param(ring_size, int, S_IRUGO);
MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)"); MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
static const u32 default_msg = NETIF_MSG_DRV | NETIF_MSG_PROBE |
NETIF_MSG_LINK | NETIF_MSG_IFUP |
NETIF_MSG_IFDOWN | NETIF_MSG_RX_ERR |
NETIF_MSG_TX_ERR;
static int debug = -1;
module_param(debug, int, S_IRUGO);
MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
static void do_set_multicast(struct work_struct *w) static void do_set_multicast(struct work_struct *w)
{ {
struct net_device_context *ndevctx = struct net_device_context *ndevctx =
...@@ -888,6 +891,11 @@ static int netvsc_probe(struct hv_device *dev, ...@@ -888,6 +891,11 @@ static int netvsc_probe(struct hv_device *dev,
net_device_ctx = netdev_priv(net); net_device_ctx = netdev_priv(net);
net_device_ctx->device_ctx = dev; net_device_ctx->device_ctx = dev;
net_device_ctx->msg_enable = netif_msg_init(debug, default_msg);
if (netif_msg_probe(net_device_ctx))
netdev_dbg(net, "netvsc msg_enable: %d\n",
net_device_ctx->msg_enable);
hv_set_drvdata(dev, net); hv_set_drvdata(dev, net);
INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change); INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change);
INIT_WORK(&net_device_ctx->work, do_set_multicast); INIT_WORK(&net_device_ctx->work, do_set_multicast);
......
...@@ -429,6 +429,7 @@ int rndis_filter_receive(struct hv_device *dev, ...@@ -429,6 +429,7 @@ int rndis_filter_receive(struct hv_device *dev,
rndis_msg = pkt->data; rndis_msg = pkt->data;
if (netif_msg_rx_err(net_dev->nd_ctx))
dump_rndis_message(dev, rndis_msg); dump_rndis_message(dev, rndis_msg);
switch (rndis_msg->ndis_msg_type) { switch (rndis_msg->ndis_msg_type) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment