staging: hv: replace DPRINT with native primitives in hv_netvsc
Replace all remaining DPRINT calls with their native dev_ and netvsc_ calls. And also change some of the verbiage to be more useful. rndis_filter has a few remaining DPRINT calls in it that will be removed in a future patch because the debug will be implemented differently. Signed-off-by: Hank Janssen <hjanssen@microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
0a46618d58
commit
eb335bc427
drivers/staging/hv
|
@ -18,6 +18,8 @@
|
||||||
* Haiyang Zhang <haiyangz@microsoft.com>
|
* Haiyang Zhang <haiyangz@microsoft.com>
|
||||||
* Hank Janssen <hjanssen@microsoft.com>
|
* Hank Janssen <hjanssen@microsoft.com>
|
||||||
*/
|
*/
|
||||||
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||||
|
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/wait.h>
|
#include <linux/wait.h>
|
||||||
|
@ -200,7 +202,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
|
||||||
|
|
||||||
net_device = get_outbound_net_device(device);
|
net_device = get_outbound_net_device(device);
|
||||||
if (!net_device) {
|
if (!net_device) {
|
||||||
DPRINT_ERR(NETVSC, "unable to get net device..."
|
dev_err(&device->device, "unable to get net device..."
|
||||||
"device being destroyed?");
|
"device being destroyed?");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -209,9 +211,8 @@ static int netvsc_init_recv_buf(struct hv_device *device)
|
||||||
(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
|
(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
|
||||||
get_order(net_device->recv_buf_size));
|
get_order(net_device->recv_buf_size));
|
||||||
if (!net_device->recv_buf) {
|
if (!net_device->recv_buf) {
|
||||||
DPRINT_ERR(NETVSC,
|
dev_err(&device->device, "unable to allocate receive "
|
||||||
"unable to allocate receive buffer of size %d",
|
"buffer of size %d", net_device->recv_buf_size);
|
||||||
net_device->recv_buf_size);
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -225,8 +226,8 @@ static int netvsc_init_recv_buf(struct hv_device *device)
|
||||||
net_device->recv_buf_size,
|
net_device->recv_buf_size,
|
||||||
&net_device->recv_buf_gpadl_handle);
|
&net_device->recv_buf_gpadl_handle);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC,
|
dev_err(&device->device,
|
||||||
"unable to establish receive buffer's gpadl");
|
"unable to establish receive buffer's gpadl");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,8 +251,8 @@ static int netvsc_init_recv_buf(struct hv_device *device)
|
||||||
VM_PKT_DATA_INBAND,
|
VM_PKT_DATA_INBAND,
|
||||||
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
|
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC,
|
dev_err(&device->device,
|
||||||
"unable to send receive buffer's gpadl to netvsp");
|
"unable to send receive buffer's gpadl to netvsp");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +265,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
|
||||||
/* Check the response */
|
/* Check the response */
|
||||||
if (init_packet->msg.v1_msg.
|
if (init_packet->msg.v1_msg.
|
||||||
send_recv_buf_complete.status != NVSP_STAT_SUCCESS) {
|
send_recv_buf_complete.status != NVSP_STAT_SUCCESS) {
|
||||||
DPRINT_ERR(NETVSC, "Unable to complete receive buffer "
|
dev_err(&device->device, "Unable to complete receive buffer "
|
||||||
"initialzation with NetVsp - status %d",
|
"initialzation with NetVsp - status %d",
|
||||||
init_packet->msg.v1_msg.
|
init_packet->msg.v1_msg.
|
||||||
send_recv_buf_complete.status);
|
send_recv_buf_complete.status);
|
||||||
|
@ -318,7 +319,7 @@ static int netvsc_init_send_buf(struct hv_device *device)
|
||||||
|
|
||||||
net_device = get_outbound_net_device(device);
|
net_device = get_outbound_net_device(device);
|
||||||
if (!net_device) {
|
if (!net_device) {
|
||||||
DPRINT_ERR(NETVSC, "unable to get net device..."
|
dev_err(&device->device, "unable to get net device..."
|
||||||
"device being destroyed?");
|
"device being destroyed?");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -331,8 +332,8 @@ static int netvsc_init_send_buf(struct hv_device *device)
|
||||||
(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
|
(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
|
||||||
get_order(net_device->send_buf_size));
|
get_order(net_device->send_buf_size));
|
||||||
if (!net_device->send_buf) {
|
if (!net_device->send_buf) {
|
||||||
DPRINT_ERR(NETVSC, "unable to allocate send buffer of size %d",
|
dev_err(&device->device, "unable to allocate send "
|
||||||
net_device->send_buf_size);
|
"buffer of size %d", net_device->send_buf_size);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -346,7 +347,7 @@ static int netvsc_init_send_buf(struct hv_device *device)
|
||||||
net_device->send_buf_size,
|
net_device->send_buf_size,
|
||||||
&net_device->send_buf_gpadl_handle);
|
&net_device->send_buf_gpadl_handle);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC, "unable to establish send buffer's gpadl");
|
dev_err(&device->device, "unable to establish send buffer's gpadl");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +370,7 @@ static int netvsc_init_send_buf(struct hv_device *device)
|
||||||
VM_PKT_DATA_INBAND,
|
VM_PKT_DATA_INBAND,
|
||||||
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
|
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC,
|
dev_err(&device->device,
|
||||||
"unable to send receive buffer's gpadl to netvsp");
|
"unable to send receive buffer's gpadl to netvsp");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -382,7 +383,7 @@ static int netvsc_init_send_buf(struct hv_device *device)
|
||||||
/* Check the response */
|
/* Check the response */
|
||||||
if (init_packet->msg.v1_msg.
|
if (init_packet->msg.v1_msg.
|
||||||
send_send_buf_complete.status != NVSP_STAT_SUCCESS) {
|
send_send_buf_complete.status != NVSP_STAT_SUCCESS) {
|
||||||
DPRINT_ERR(NETVSC, "Unable to complete send buffer "
|
dev_err(&device->device, "Unable to complete send buffer "
|
||||||
"initialzation with NetVsp - status %d",
|
"initialzation with NetVsp - status %d",
|
||||||
init_packet->msg.v1_msg.
|
init_packet->msg.v1_msg.
|
||||||
send_send_buf_complete.status);
|
send_send_buf_complete.status);
|
||||||
|
@ -434,8 +435,8 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
|
||||||
* have a leak rather than continue and a bugchk
|
* have a leak rather than continue and a bugchk
|
||||||
*/
|
*/
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC, "unable to send revoke receive "
|
dev_err(&net_device->dev->device, "unable to send "
|
||||||
"buffer to netvsp");
|
"revoke receive buffer to netvsp");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -447,7 +448,7 @@ static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
|
||||||
|
|
||||||
/* If we failed here, we might as well return and have a leak rather than continue and a bugchk */
|
/* If we failed here, we might as well return and have a leak rather than continue and a bugchk */
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC,
|
dev_err(&net_device->dev->device,
|
||||||
"unable to teardown receive buffer's gpadl");
|
"unable to teardown receive buffer's gpadl");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -501,8 +502,8 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
|
||||||
* rather than continue and a bugchk
|
* rather than continue and a bugchk
|
||||||
*/
|
*/
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC, "unable to send revoke send buffer "
|
dev_err(&net_device->dev->device, "unable to send "
|
||||||
"to netvsp");
|
"revoke send buffer to netvsp");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,8 +518,8 @@ static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
|
||||||
* rather than continue and a bugchk
|
* rather than continue and a bugchk
|
||||||
*/
|
*/
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC, "unable to teardown send buffer's "
|
dev_err(&net_device->dev->device,
|
||||||
"gpadl");
|
"unable to teardown send buffer's gpadl");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
net_device->send_buf_gpadl_handle = 0;
|
net_device->send_buf_gpadl_handle = 0;
|
||||||
|
@ -544,7 +545,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
|
||||||
|
|
||||||
net_device = get_outbound_net_device(device);
|
net_device = get_outbound_net_device(device);
|
||||||
if (!net_device) {
|
if (!net_device) {
|
||||||
DPRINT_ERR(NETVSC, "unable to get net device..."
|
dev_err(&device->device, "unable to get net device..."
|
||||||
"device being destroyed?");
|
"device being destroyed?");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -672,18 +673,19 @@ static int netvsc_device_add(struct hv_device *device, void *additional_info)
|
||||||
netvsc_channel_cb, device);
|
netvsc_channel_cb, device);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC, "unable to open channel: %d", ret);
|
dev_err(&device->device, "unable to open channel: %d", ret);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Channel is opened */
|
/* Channel is opened */
|
||||||
DPRINT_INFO(NETVSC, "*** NetVSC channel opened successfully! ***");
|
pr_info("hv_netvsc channel opened successfully");
|
||||||
|
|
||||||
/* Connect with the NetVsp */
|
/* Connect with the NetVsp */
|
||||||
ret = netvsc_connect_vsp(device);
|
ret = netvsc_connect_vsp(device);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC, "unable to connect to NetVSP - %d", ret);
|
dev_err(&device->device,
|
||||||
|
"unable to connect to NetVSP - %d", ret);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto close;
|
goto close;
|
||||||
}
|
}
|
||||||
|
@ -724,14 +726,15 @@ static int netvsc_device_remove(struct hv_device *device)
|
||||||
/* Stop outbound traffic ie sends and receives completions */
|
/* Stop outbound traffic ie sends and receives completions */
|
||||||
net_device = release_outbound_net_device(device);
|
net_device = release_outbound_net_device(device);
|
||||||
if (!net_device) {
|
if (!net_device) {
|
||||||
DPRINT_ERR(NETVSC, "No net device present!!");
|
dev_err(&device->device, "No net device present!!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for all send completions */
|
/* Wait for all send completions */
|
||||||
while (atomic_read(&net_device->num_outstanding_sends)) {
|
while (atomic_read(&net_device->num_outstanding_sends)) {
|
||||||
DPRINT_INFO(NETVSC, "waiting for %d requests to complete...",
|
dev_err(&device->device,
|
||||||
atomic_read(&net_device->num_outstanding_sends));
|
"waiting for %d requests to complete...",
|
||||||
|
atomic_read(&net_device->num_outstanding_sends));
|
||||||
udelay(100);
|
udelay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,7 +744,7 @@ static int netvsc_device_remove(struct hv_device *device)
|
||||||
net_device = release_inbound_net_device(device);
|
net_device = release_inbound_net_device(device);
|
||||||
|
|
||||||
/* At this point, no one should be accessing netDevice except in here */
|
/* At this point, no one should be accessing netDevice except in here */
|
||||||
DPRINT_INFO(NETVSC, "net device (%p) safe to remove", net_device);
|
dev_notice(&device->device, "net device safe to remove");
|
||||||
|
|
||||||
/* Now, we can close the channel safely */
|
/* Now, we can close the channel safely */
|
||||||
vmbus_close(device->channel);
|
vmbus_close(device->channel);
|
||||||
|
@ -773,7 +776,7 @@ static void netvsc_send_completion(struct hv_device *device,
|
||||||
|
|
||||||
net_device = get_inbound_net_device(device);
|
net_device = get_inbound_net_device(device);
|
||||||
if (!net_device) {
|
if (!net_device) {
|
||||||
DPRINT_ERR(NETVSC, "unable to get net device..."
|
dev_err(&device->device, "unable to get net device..."
|
||||||
"device being destroyed?");
|
"device being destroyed?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -803,7 +806,7 @@ static void netvsc_send_completion(struct hv_device *device,
|
||||||
|
|
||||||
atomic_dec(&net_device->num_outstanding_sends);
|
atomic_dec(&net_device->num_outstanding_sends);
|
||||||
} else {
|
} else {
|
||||||
DPRINT_ERR(NETVSC, "Unknown send completion packet type - "
|
dev_err(&device->device, "Unknown send completion packet type- "
|
||||||
"%d received!!", nvsp_packet->hdr.msg_type);
|
"%d received!!", nvsp_packet->hdr.msg_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,7 +823,7 @@ static int netvsc_send(struct hv_device *device,
|
||||||
|
|
||||||
net_device = get_outbound_net_device(device);
|
net_device = get_outbound_net_device(device);
|
||||||
if (!net_device) {
|
if (!net_device) {
|
||||||
DPRINT_ERR(NETVSC, "net device (%p) shutting down..."
|
dev_err(&device->device, "net device (%p) shutting down..."
|
||||||
"ignoring outbound packets", net_device);
|
"ignoring outbound packets", net_device);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
@ -856,7 +859,7 @@ static int netvsc_send(struct hv_device *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
DPRINT_ERR(NETVSC, "Unable to send packet %p ret %d",
|
dev_err(&device->device, "Unable to send packet %p ret %d",
|
||||||
packet, ret);
|
packet, ret);
|
||||||
|
|
||||||
atomic_inc(&net_device->num_outstanding_sends);
|
atomic_inc(&net_device->num_outstanding_sends);
|
||||||
|
@ -882,7 +885,7 @@ static void netvsc_receive(struct hv_device *device,
|
||||||
|
|
||||||
net_device = get_inbound_net_device(device);
|
net_device = get_inbound_net_device(device);
|
||||||
if (!net_device) {
|
if (!net_device) {
|
||||||
DPRINT_ERR(NETVSC, "unable to get net device..."
|
dev_err(&device->device, "unable to get net device..."
|
||||||
"device being destroyed?");
|
"device being destroyed?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -892,7 +895,7 @@ static void netvsc_receive(struct hv_device *device,
|
||||||
* packet
|
* packet
|
||||||
*/
|
*/
|
||||||
if (packet->type != VM_PKT_DATA_USING_XFER_PAGES) {
|
if (packet->type != VM_PKT_DATA_USING_XFER_PAGES) {
|
||||||
DPRINT_ERR(NETVSC, "Unknown packet type received - %d",
|
dev_err(&device->device, "Unknown packet type received - %d",
|
||||||
packet->type);
|
packet->type);
|
||||||
put_net_device(device);
|
put_net_device(device);
|
||||||
return;
|
return;
|
||||||
|
@ -904,8 +907,8 @@ static void netvsc_receive(struct hv_device *device,
|
||||||
/* Make sure this is a valid nvsp packet */
|
/* Make sure this is a valid nvsp packet */
|
||||||
if (nvsp_packet->hdr.msg_type !=
|
if (nvsp_packet->hdr.msg_type !=
|
||||||
NVSP_MSG1_TYPE_SEND_RNDIS_PKT) {
|
NVSP_MSG1_TYPE_SEND_RNDIS_PKT) {
|
||||||
DPRINT_ERR(NETVSC, "Unknown nvsp packet type received - %d",
|
dev_err(&device->device, "Unknown nvsp packet type received-"
|
||||||
nvsp_packet->hdr.msg_type);
|
" %d", nvsp_packet->hdr.msg_type);
|
||||||
put_net_device(device);
|
put_net_device(device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -913,7 +916,7 @@ static void netvsc_receive(struct hv_device *device,
|
||||||
vmxferpage_packet = (struct vmtransfer_page_packet_header *)packet;
|
vmxferpage_packet = (struct vmtransfer_page_packet_header *)packet;
|
||||||
|
|
||||||
if (vmxferpage_packet->xfer_pageset_id != NETVSC_RECEIVE_BUFFER_ID) {
|
if (vmxferpage_packet->xfer_pageset_id != NETVSC_RECEIVE_BUFFER_ID) {
|
||||||
DPRINT_ERR(NETVSC, "Invalid xfer page set id - "
|
dev_err(&device->device, "Invalid xfer page set id - "
|
||||||
"expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID,
|
"expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID,
|
||||||
vmxferpage_packet->xfer_pageset_id);
|
vmxferpage_packet->xfer_pageset_id);
|
||||||
put_net_device(device);
|
put_net_device(device);
|
||||||
|
@ -940,9 +943,9 @@ static void netvsc_receive(struct hv_device *device,
|
||||||
* some of the xfer page packet ranges...
|
* some of the xfer page packet ranges...
|
||||||
*/
|
*/
|
||||||
if (count < 2) {
|
if (count < 2) {
|
||||||
DPRINT_ERR(NETVSC, "Got only %d netvsc pkt...needed %d pkts. "
|
dev_err(&device->device, "Got only %d netvsc pkt...needed "
|
||||||
"Dropping this xfer page packet completely!",
|
"%d pkts. Dropping this xfer page packet completely!",
|
||||||
count, vmxferpage_packet->range_cnt + 1);
|
count, vmxferpage_packet->range_cnt + 1);
|
||||||
|
|
||||||
/* Return it to the freelist */
|
/* Return it to the freelist */
|
||||||
spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags);
|
spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags);
|
||||||
|
@ -968,9 +971,9 @@ static void netvsc_receive(struct hv_device *device,
|
||||||
xferpage_packet->count = count - 1;
|
xferpage_packet->count = count - 1;
|
||||||
|
|
||||||
if (xferpage_packet->count != vmxferpage_packet->range_cnt) {
|
if (xferpage_packet->count != vmxferpage_packet->range_cnt) {
|
||||||
DPRINT_INFO(NETVSC, "Needed %d netvsc pkts to satisy this xfer "
|
dev_err(&device->device, "Needed %d netvsc pkts to satisy "
|
||||||
"page...got %d", vmxferpage_packet->range_cnt,
|
"this xfer page...got %d",
|
||||||
xferpage_packet->count);
|
vmxferpage_packet->range_cnt, xferpage_packet->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
|
/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
|
||||||
|
@ -1073,20 +1076,20 @@ retry_send_cmplt:
|
||||||
} else if (ret == -1) {
|
} else if (ret == -1) {
|
||||||
/* no more room...wait a bit and attempt to retry 3 times */
|
/* no more room...wait a bit and attempt to retry 3 times */
|
||||||
retries++;
|
retries++;
|
||||||
DPRINT_ERR(NETVSC, "unable to send receive completion pkt "
|
dev_err(&device->device, "unable to send receive completion pkt"
|
||||||
"(tid %llx)...retrying %d", transaction_id, retries);
|
" (tid %llx)...retrying %d", transaction_id, retries);
|
||||||
|
|
||||||
if (retries < 4) {
|
if (retries < 4) {
|
||||||
udelay(100);
|
udelay(100);
|
||||||
goto retry_send_cmplt;
|
goto retry_send_cmplt;
|
||||||
} else {
|
} else {
|
||||||
DPRINT_ERR(NETVSC, "unable to send receive completion "
|
dev_err(&device->device, "unable to send receive "
|
||||||
"pkt (tid %llx)...give up retrying",
|
"completion pkt (tid %llx)...give up retrying",
|
||||||
transaction_id);
|
transaction_id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DPRINT_ERR(NETVSC, "unable to send receive completion pkt - "
|
dev_err(&device->device, "unable to send receive "
|
||||||
"%llx", transaction_id);
|
"completion pkt - %llx", transaction_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1107,7 +1110,7 @@ static void netvsc_receive_completion(void *context)
|
||||||
*/
|
*/
|
||||||
net_device = get_inbound_net_device(device);
|
net_device = get_inbound_net_device(device);
|
||||||
if (!net_device) {
|
if (!net_device) {
|
||||||
DPRINT_ERR(NETVSC, "unable to get net device..."
|
dev_err(&device->device, "unable to get net device..."
|
||||||
"device being destroyed?");
|
"device being destroyed?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1160,7 +1163,7 @@ static void netvsc_channel_cb(void *context)
|
||||||
|
|
||||||
net_device = get_inbound_net_device(device);
|
net_device = get_inbound_net_device(device);
|
||||||
if (!net_device) {
|
if (!net_device) {
|
||||||
DPRINT_ERR(NETVSC, "net device (%p) shutting down..."
|
dev_err(&device->device, "net device (%p) shutting down..."
|
||||||
"ignoring inbound packets", net_device);
|
"ignoring inbound packets", net_device);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1181,7 +1184,7 @@ static void netvsc_channel_cb(void *context)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DPRINT_ERR(NETVSC,
|
dev_err(&device->device,
|
||||||
"unhandled packet type %d, "
|
"unhandled packet type %d, "
|
||||||
"tid %llx len %d\n",
|
"tid %llx len %d\n",
|
||||||
desc->type, request_id,
|
desc->type, request_id,
|
||||||
|
@ -1210,7 +1213,7 @@ static void netvsc_channel_cb(void *context)
|
||||||
buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
|
buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
/* Try again next time around */
|
/* Try again next time around */
|
||||||
DPRINT_ERR(NETVSC,
|
dev_err(&device->device,
|
||||||
"unable to allocate buffer of size "
|
"unable to allocate buffer of size "
|
||||||
"(%d)!!", bytes_recvd);
|
"(%d)!!", bytes_recvd);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
* Haiyang Zhang <haiyangz@microsoft.com>
|
* Haiyang Zhang <haiyangz@microsoft.com>
|
||||||
* Hank Janssen <hjanssen@microsoft.com>
|
* Hank Janssen <hjanssen@microsoft.com>
|
||||||
*/
|
*/
|
||||||
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||||
|
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/highmem.h>
|
#include <linux/highmem.h>
|
||||||
|
@ -77,14 +79,14 @@ static int netvsc_open(struct net_device *net)
|
||||||
/* Open up the device */
|
/* Open up the device */
|
||||||
ret = rndis_filter_open(device_obj);
|
ret = rndis_filter_open(device_obj);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DPRINT_ERR(NETVSC_DRV,
|
netdev_err(net, "unable to open device (ret %d).\n",
|
||||||
"unable to open device (ret %d).", ret);
|
ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
netif_start_queue(net);
|
netif_start_queue(net);
|
||||||
} else {
|
} else {
|
||||||
DPRINT_ERR(NETVSC_DRV, "unable to open device...link is down.");
|
netdev_err(net, "unable to open device...link is down.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -100,7 +102,7 @@ static int netvsc_close(struct net_device *net)
|
||||||
|
|
||||||
ret = rndis_filter_close(device_obj);
|
ret = rndis_filter_close(device_obj);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
DPRINT_ERR(NETVSC_DRV, "unable to close device (ret %d).", ret);
|
netdev_err(net, "unable to close device (ret %d).\n", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +149,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
|
||||||
net_drv_obj->req_ext_size, GFP_ATOMIC);
|
net_drv_obj->req_ext_size, GFP_ATOMIC);
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
/* out of memory, silently drop packet */
|
/* out of memory, silently drop packet */
|
||||||
DPRINT_ERR(NETVSC_DRV, "unable to allocate hv_netvsc_packet");
|
netdev_err(net, "unable to allocate hv_netvsc_packet\n");
|
||||||
|
|
||||||
dev_kfree_skb(skb);
|
dev_kfree_skb(skb);
|
||||||
net->stats.tx_dropped++;
|
net->stats.tx_dropped++;
|
||||||
|
@ -214,8 +216,8 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj,
|
||||||
struct net_device *net = dev_get_drvdata(&device_obj->device);
|
struct net_device *net = dev_get_drvdata(&device_obj->device);
|
||||||
|
|
||||||
if (!net) {
|
if (!net) {
|
||||||
DPRINT_ERR(NETVSC_DRV, "got link status but net device "
|
netdev_err(net, "got link status but net device "
|
||||||
"not initialized yet");
|
"not initialized yet\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,8 +245,8 @@ static int netvsc_recv_callback(struct hv_device *device_obj,
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (!net) {
|
if (!net) {
|
||||||
DPRINT_ERR(NETVSC_DRV, "got receive callback but net device "
|
netdev_err(net, "got receive callback but net device"
|
||||||
"not initialized yet");
|
" not initialized yet\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,8 +352,7 @@ static int netvsc_probe(struct device *device)
|
||||||
free_netdev(net);
|
free_netdev(net);
|
||||||
dev_set_drvdata(device, NULL);
|
dev_set_drvdata(device, NULL);
|
||||||
|
|
||||||
DPRINT_ERR(NETVSC_DRV, "unable to add netvsc device (ret %d)",
|
netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
|
||||||
ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +398,7 @@ static int netvsc_remove(struct device *device)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (net == NULL) {
|
if (net == NULL) {
|
||||||
DPRINT_INFO(NETVSC, "no net device to remove");
|
dev_err(device, "No net device to remove\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +418,7 @@ static int netvsc_remove(struct device *device)
|
||||||
ret = net_drv_obj->base.dev_rm(device_obj);
|
ret = net_drv_obj->base.dev_rm(device_obj);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
/* TODO: */
|
/* TODO: */
|
||||||
DPRINT_ERR(NETVSC, "unable to remove vsc device (ret %d)", ret);
|
netdev_err(net, "unable to remove vsc device (ret %d)\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
free_netdev(net);
|
free_netdev(net);
|
||||||
|
@ -446,16 +447,13 @@ static void netvsc_drv_exit(void)
|
||||||
/* Get the device */
|
/* Get the device */
|
||||||
ret = driver_for_each_device(&drv->driver, NULL,
|
ret = driver_for_each_device(&drv->driver, NULL,
|
||||||
¤t_dev, netvsc_drv_exit_cb);
|
¤t_dev, netvsc_drv_exit_cb);
|
||||||
if (ret)
|
|
||||||
DPRINT_WARN(NETVSC_DRV,
|
|
||||||
"driver_for_each_device returned %d", ret);
|
|
||||||
|
|
||||||
if (current_dev == NULL)
|
if (current_dev == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Initiate removal from the top-down */
|
/* Initiate removal from the top-down */
|
||||||
DPRINT_INFO(NETVSC_DRV, "unregistering device (%p)...",
|
dev_err(current_dev, "unregistering device (%s)...\n",
|
||||||
current_dev);
|
dev_name(current_dev));
|
||||||
|
|
||||||
device_unregister(current_dev);
|
device_unregister(current_dev);
|
||||||
}
|
}
|
||||||
|
@ -509,7 +507,7 @@ MODULE_DEVICE_TABLE(dmi, hv_netvsc_dmi_table);
|
||||||
|
|
||||||
static int __init netvsc_init(void)
|
static int __init netvsc_init(void)
|
||||||
{
|
{
|
||||||
DPRINT_INFO(NETVSC_DRV, "Netvsc initializing....");
|
pr_info("initializing....");
|
||||||
|
|
||||||
if (!dmi_check_system(hv_netvsc_dmi_table))
|
if (!dmi_check_system(hv_netvsc_dmi_table))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/if_ether.h>
|
#include <linux/if_ether.h>
|
||||||
|
#include <linux/netdevice.h>
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "hv_api.h"
|
#include "hv_api.h"
|
||||||
#include "netvsc_api.h"
|
#include "netvsc_api.h"
|
||||||
|
@ -294,10 +294,11 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
|
||||||
memcpy(&request->response_msg, resp,
|
memcpy(&request->response_msg, resp,
|
||||||
resp->msg_len);
|
resp->msg_len);
|
||||||
} else {
|
} else {
|
||||||
DPRINT_ERR(NETVSC, "rndis response buffer overflow "
|
dev_err(&dev->net_dev->dev->device,
|
||||||
"detected (size %u max %zu)",
|
"rndis response buffer overflow "
|
||||||
resp->msg_len,
|
"detected (size %u max %zu)\n",
|
||||||
sizeof(struct rndis_filter_packet));
|
resp->msg_len,
|
||||||
|
sizeof(struct rndis_filter_packet));
|
||||||
|
|
||||||
if (resp->ndis_msg_type ==
|
if (resp->ndis_msg_type ==
|
||||||
REMOTE_NDIS_RESET_CMPLT) {
|
REMOTE_NDIS_RESET_CMPLT) {
|
||||||
|
@ -314,10 +315,11 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
|
||||||
request->wait_condition = 1;
|
request->wait_condition = 1;
|
||||||
wake_up(&request->wait_event);
|
wake_up(&request->wait_event);
|
||||||
} else {
|
} else {
|
||||||
DPRINT_ERR(NETVSC, "no rndis request found for this response "
|
dev_err(&dev->net_dev->dev->device,
|
||||||
"(id 0x%x res type 0x%x)",
|
"no rndis request found for this response "
|
||||||
resp->msg.init_complete.req_id,
|
"(id 0x%x res type 0x%x)\n",
|
||||||
resp->ndis_msg_type);
|
resp->msg.init_complete.req_id,
|
||||||
|
resp->ndis_msg_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,15 +382,15 @@ static int rndis_filter_receive(struct hv_device *dev,
|
||||||
|
|
||||||
/* Make sure the rndis device state is initialized */
|
/* Make sure the rndis device state is initialized */
|
||||||
if (!net_dev->extension) {
|
if (!net_dev->extension) {
|
||||||
DPRINT_ERR(NETVSC, "got rndis message but no rndis device..."
|
dev_err(&dev->device, "got rndis message but no rndis device - "
|
||||||
"dropping this message!");
|
"dropping this message!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rndis_dev = (struct rndis_device *)net_dev->extension;
|
rndis_dev = (struct rndis_device *)net_dev->extension;
|
||||||
if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
|
if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
|
||||||
DPRINT_ERR(NETVSC, "got rndis message but rndis device "
|
dev_err(&dev->device, "got rndis message but rndis device "
|
||||||
"uninitialized...dropping this message!");
|
"uninitialized...dropping this message!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,8 +411,8 @@ static int rndis_filter_receive(struct hv_device *dev,
|
||||||
kunmap_atomic(rndis_hdr - pkt->page_buf[0].offset,
|
kunmap_atomic(rndis_hdr - pkt->page_buf[0].offset,
|
||||||
KM_IRQ0);
|
KM_IRQ0);
|
||||||
|
|
||||||
DPRINT_ERR(NETVSC, "invalid rndis message? (expected %u "
|
dev_err(&dev->device, "invalid rndis message? (expected %u "
|
||||||
"bytes got %u)...dropping this message!",
|
"bytes got %u)...dropping this message!\n",
|
||||||
rndis_hdr->msg_len,
|
rndis_hdr->msg_len,
|
||||||
pkt->total_data_buflen);
|
pkt->total_data_buflen);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -419,8 +421,8 @@ static int rndis_filter_receive(struct hv_device *dev,
|
||||||
|
|
||||||
if ((rndis_hdr->ndis_msg_type != REMOTE_NDIS_PACKET_MSG) &&
|
if ((rndis_hdr->ndis_msg_type != REMOTE_NDIS_PACKET_MSG) &&
|
||||||
(rndis_hdr->msg_len > sizeof(struct rndis_message))) {
|
(rndis_hdr->msg_len > sizeof(struct rndis_message))) {
|
||||||
DPRINT_ERR(NETVSC, "incoming rndis message buffer overflow "
|
dev_err(&dev->device, "incoming rndis message buffer overflow "
|
||||||
"detected (got %u, max %zu)...marking it an error!",
|
"detected (got %u, max %zu)..marking it an error!\n",
|
||||||
rndis_hdr->msg_len,
|
rndis_hdr->msg_len,
|
||||||
sizeof(struct rndis_message));
|
sizeof(struct rndis_message));
|
||||||
}
|
}
|
||||||
|
@ -452,7 +454,8 @@ static int rndis_filter_receive(struct hv_device *dev,
|
||||||
rndis_filter_receive_indicate_status(rndis_dev, &rndis_msg);
|
rndis_filter_receive_indicate_status(rndis_dev, &rndis_msg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DPRINT_ERR(NETVSC, "unhandled rndis message (type %u len %u)",
|
dev_err(&dev->device,
|
||||||
|
"unhandled rndis message (type %u len %u)\n",
|
||||||
rndis_msg.ndis_msg_type,
|
rndis_msg.ndis_msg_type,
|
||||||
rndis_msg.msg_len);
|
rndis_msg.msg_len);
|
||||||
break;
|
break;
|
||||||
|
@ -575,7 +578,8 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
|
||||||
msecs_to_jiffies(2000));
|
msecs_to_jiffies(2000));
|
||||||
if (request->wait_condition == 0) {
|
if (request->wait_condition == 0) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
DPRINT_ERR(NETVSC, "timeout before we got a set response...");
|
dev_err(&dev->net_dev->dev->device,
|
||||||
|
"timeout before we got a set response...\n");
|
||||||
/*
|
/*
|
||||||
* We cant deallocate the request since we may still receive a
|
* We cant deallocate the request since we may still receive a
|
||||||
* send completion for it.
|
* send completion for it.
|
||||||
|
@ -789,16 +793,15 @@ static int rndis_filte_device_add(struct hv_device *dev,
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT_INFO(NETVSC, "Device 0x%p mac addr %pM",
|
|
||||||
rndisDevice, rndisDevice->hw_mac_adr);
|
|
||||||
|
|
||||||
memcpy(deviceInfo->mac_adr, rndisDevice->hw_mac_adr, ETH_ALEN);
|
memcpy(deviceInfo->mac_adr, rndisDevice->hw_mac_adr, ETH_ALEN);
|
||||||
|
|
||||||
rndis_filter_query_device_link_status(rndisDevice);
|
rndis_filter_query_device_link_status(rndisDevice);
|
||||||
|
|
||||||
deviceInfo->link_state = rndisDevice->link_stat;
|
deviceInfo->link_state = rndisDevice->link_stat;
|
||||||
DPRINT_INFO(NETVSC, "Device 0x%p link state %s", rndisDevice,
|
|
||||||
((deviceInfo->link_state) ? ("down") : ("up")));
|
dev_info(&dev->device, "Device MAC %pM link state %s",
|
||||||
|
rndisDevice->hw_mac_adr,
|
||||||
|
((deviceInfo->link_state) ? ("down\n") : ("up\n")));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue