Commit c2a4efdd authored by Haiyang Zhang's avatar Haiyang Zhang Committed by Greg Kroah-Hartman

staging: hv: Convert camel cased variables in rndis_filter.c to lower cases

Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarHank Janssen <hjanssen@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 5a71ae30
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
/* Data types */ /* Data types */
struct rndis_filter_driver_object { struct rndis_filter_driver_object {
/* The original driver */ /* The original driver */
struct netvsc_driver InnerDriver; struct netvsc_driver inner_drv;
}; };
enum rndis_device_state { enum rndis_device_state {
...@@ -43,61 +43,61 @@ enum rndis_device_state { ...@@ -43,61 +43,61 @@ enum rndis_device_state {
}; };
struct rndis_device { struct rndis_device {
struct netvsc_device *NetDevice; struct netvsc_device *net_dev;
enum rndis_device_state State; enum rndis_device_state state;
u32 LinkStatus; u32 link_stat;
atomic_t NewRequestId; atomic_t new_req_id;
spinlock_t request_lock; spinlock_t request_lock;
struct list_head RequestList; struct list_head req_list;
unsigned char HwMacAddr[ETH_ALEN]; unsigned char hw_mac_adr[ETH_ALEN];
}; };
struct rndis_request { struct rndis_request {
struct list_head ListEntry; struct list_head list_ent;
struct osd_waitevent *WaitEvent; struct osd_waitevent *waitevent;
/* /*
* FIXME: We assumed a fixed size response here. If we do ever need to * FIXME: We assumed a fixed size response here. If we do ever need to
* handle a bigger response, we can either define a max response * handle a bigger response, we can either define a max response
* message or add a response buffer variable above this field * message or add a response buffer variable above this field
*/ */
struct rndis_message ResponseMessage; struct rndis_message response_msg;
/* Simplify allocation by having a netvsc packet inline */ /* Simplify allocation by having a netvsc packet inline */
struct hv_netvsc_packet Packet; struct hv_netvsc_packet pkt;
struct hv_page_buffer Buffer; struct hv_page_buffer buf;
/* FIXME: We assumed a fixed size request here. */ /* FIXME: We assumed a fixed size request here. */
struct rndis_message RequestMessage; struct rndis_message request_msg;
}; };
struct rndis_filter_packet { struct rndis_filter_packet {
void *CompletionContext; void *completion_ctx;
void (*OnCompletion)(void *context); void (*completion)(void *context);
struct rndis_message Message; struct rndis_message msg;
}; };
static int RndisFilterOnDeviceAdd(struct hv_device *Device, static int RndisFilterOnDeviceAdd(struct hv_device *dev,
void *AdditionalInfo); void *additional_info);
static int RndisFilterOnDeviceRemove(struct hv_device *Device); static int RndisFilterOnDeviceRemove(struct hv_device *dev);
static void RndisFilterOnCleanup(struct hv_driver *Driver); static void RndisFilterOnCleanup(struct hv_driver *drv);
static int RndisFilterOnSend(struct hv_device *Device, static int RndisFilterOnSend(struct hv_device *dev,
struct hv_netvsc_packet *Packet); struct hv_netvsc_packet *pkt);
static void RndisFilterOnSendCompletion(void *Context); static void RndisFilterOnSendCompletion(void *ctx);
static void RndisFilterOnSendRequestCompletion(void *Context); static void RndisFilterOnSendRequestCompletion(void *ctx);
/* The one and only */ /* The one and only */
static struct rndis_filter_driver_object gRndisFilter; static struct rndis_filter_driver_object rndis_filter;
static struct rndis_device *GetRndisDevice(void) static struct rndis_device *GetRndisDevice(void)
{ {
...@@ -109,19 +109,19 @@ static struct rndis_device *GetRndisDevice(void) ...@@ -109,19 +109,19 @@ static struct rndis_device *GetRndisDevice(void)
spin_lock_init(&device->request_lock); spin_lock_init(&device->request_lock);
INIT_LIST_HEAD(&device->RequestList); INIT_LIST_HEAD(&device->req_list);
device->State = RNDIS_DEV_UNINITIALIZED; device->state = RNDIS_DEV_UNINITIALIZED;
return device; return device;
} }
static struct rndis_request *GetRndisRequest(struct rndis_device *Device, static struct rndis_request *GetRndisRequest(struct rndis_device *dev,
u32 MessageType, u32 msg_type,
u32 MessageLength) u32 msg_len)
{ {
struct rndis_request *request; struct rndis_request *request;
struct rndis_message *rndisMessage; struct rndis_message *rndis_msg;
struct rndis_set_request *set; struct rndis_set_request *set;
unsigned long flags; unsigned long flags;
...@@ -129,61 +129,61 @@ static struct rndis_request *GetRndisRequest(struct rndis_device *Device, ...@@ -129,61 +129,61 @@ static struct rndis_request *GetRndisRequest(struct rndis_device *Device,
if (!request) if (!request)
return NULL; return NULL;
request->WaitEvent = osd_waitevent_create(); request->waitevent = osd_waitevent_create();
if (!request->WaitEvent) { if (!request->waitevent) {
kfree(request); kfree(request);
return NULL; return NULL;
} }
rndisMessage = &request->RequestMessage; rndis_msg = &request->request_msg;
rndisMessage->NdisMessageType = MessageType; rndis_msg->NdisMessageType = msg_type;
rndisMessage->MessageLength = MessageLength; rndis_msg->MessageLength = msg_len;
/* /*
* Set the request id. This field is always after the rndis header for * Set the request id. This field is always after the rndis header for
* request/response packet types so we just used the SetRequest as a * request/response packet types so we just used the SetRequest as a
* template * template
*/ */
set = &rndisMessage->Message.SetRequest; set = &rndis_msg->Message.SetRequest;
set->RequestId = atomic_inc_return(&Device->NewRequestId); set->RequestId = atomic_inc_return(&dev->new_req_id);
/* Add to the request list */ /* Add to the request list */
spin_lock_irqsave(&Device->request_lock, flags); spin_lock_irqsave(&dev->request_lock, flags);
list_add_tail(&request->ListEntry, &Device->RequestList); list_add_tail(&request->list_ent, &dev->req_list);
spin_unlock_irqrestore(&Device->request_lock, flags); spin_unlock_irqrestore(&dev->request_lock, flags);
return request; return request;
} }
static void PutRndisRequest(struct rndis_device *Device, static void PutRndisRequest(struct rndis_device *dev,
struct rndis_request *Request) struct rndis_request *req)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&Device->request_lock, flags); spin_lock_irqsave(&dev->request_lock, flags);
list_del(&Request->ListEntry); list_del(&req->list_ent);
spin_unlock_irqrestore(&Device->request_lock, flags); spin_unlock_irqrestore(&dev->request_lock, flags);
kfree(Request->WaitEvent); kfree(req->waitevent);
kfree(Request); kfree(req);
} }
static void DumpRndisMessage(struct rndis_message *RndisMessage) static void DumpRndisMessage(struct rndis_message *rndis_msg)
{ {
switch (RndisMessage->NdisMessageType) { switch (rndis_msg->NdisMessageType) {
case REMOTE_NDIS_PACKET_MSG: case REMOTE_NDIS_PACKET_MSG:
DPRINT_DBG(NETVSC, "REMOTE_NDIS_PACKET_MSG (len %u, " DPRINT_DBG(NETVSC, "REMOTE_NDIS_PACKET_MSG (len %u, "
"data offset %u data len %u, # oob %u, " "data offset %u data len %u, # oob %u, "
"oob offset %u, oob len %u, pkt offset %u, " "oob offset %u, oob len %u, pkt offset %u, "
"pkt len %u", "pkt len %u",
RndisMessage->MessageLength, rndis_msg->MessageLength,
RndisMessage->Message.Packet.DataOffset, rndis_msg->Message.Packet.DataOffset,
RndisMessage->Message.Packet.DataLength, rndis_msg->Message.Packet.DataLength,
RndisMessage->Message.Packet.NumOOBDataElements, rndis_msg->Message.Packet.NumOOBDataElements,
RndisMessage->Message.Packet.OOBDataOffset, rndis_msg->Message.Packet.OOBDataOffset,
RndisMessage->Message.Packet.OOBDataLength, rndis_msg->Message.Packet.OOBDataLength,
RndisMessage->Message.Packet.PerPacketInfoOffset, rndis_msg->Message.Packet.PerPacketInfoOffset,
RndisMessage->Message.Packet.PerPacketInfoLength); rndis_msg->Message.Packet.PerPacketInfoLength);
break; break;
case REMOTE_NDIS_INITIALIZE_CMPLT: case REMOTE_NDIS_INITIALIZE_CMPLT:
...@@ -191,147 +191,157 @@ static void DumpRndisMessage(struct rndis_message *RndisMessage) ...@@ -191,147 +191,157 @@ static void DumpRndisMessage(struct rndis_message *RndisMessage)
"(len %u, id 0x%x, status 0x%x, major %d, minor %d, " "(len %u, id 0x%x, status 0x%x, major %d, minor %d, "
"device flags %d, max xfer size 0x%x, max pkts %u, " "device flags %d, max xfer size 0x%x, max pkts %u, "
"pkt aligned %u)", "pkt aligned %u)",
RndisMessage->MessageLength, rndis_msg->MessageLength,
RndisMessage->Message.InitializeComplete.RequestId, rndis_msg->Message.InitializeComplete.RequestId,
RndisMessage->Message.InitializeComplete.Status, rndis_msg->Message.InitializeComplete.Status,
RndisMessage->Message.InitializeComplete.MajorVersion, rndis_msg->Message.InitializeComplete.MajorVersion,
RndisMessage->Message.InitializeComplete.MinorVersion, rndis_msg->Message.InitializeComplete.MinorVersion,
RndisMessage->Message.InitializeComplete.DeviceFlags, rndis_msg->Message.InitializeComplete.DeviceFlags,
RndisMessage->Message.InitializeComplete.MaxTransferSize, rndis_msg->Message.InitializeComplete.MaxTransferSize,
RndisMessage->Message.InitializeComplete.MaxPacketsPerMessage, rndis_msg->Message.InitializeComplete.
RndisMessage->Message.InitializeComplete.PacketAlignmentFactor); MaxPacketsPerMessage,
rndis_msg->Message.InitializeComplete.
PacketAlignmentFactor);
break; break;
case REMOTE_NDIS_QUERY_CMPLT: case REMOTE_NDIS_QUERY_CMPLT:
DPRINT_DBG(NETVSC, "REMOTE_NDIS_QUERY_CMPLT " DPRINT_DBG(NETVSC, "REMOTE_NDIS_QUERY_CMPLT "
"(len %u, id 0x%x, status 0x%x, buf len %u, " "(len %u, id 0x%x, status 0x%x, buf len %u, "
"buf offset %u)", "buf offset %u)",
RndisMessage->MessageLength, rndis_msg->MessageLength,
RndisMessage->Message.QueryComplete.RequestId, rndis_msg->Message.QueryComplete.RequestId,
RndisMessage->Message.QueryComplete.Status, rndis_msg->Message.QueryComplete.Status,
RndisMessage->Message.QueryComplete.InformationBufferLength, rndis_msg->Message.QueryComplete.
RndisMessage->Message.QueryComplete.InformationBufferOffset); InformationBufferLength,
rndis_msg->Message.QueryComplete.
InformationBufferOffset);
break; break;
case REMOTE_NDIS_SET_CMPLT: case REMOTE_NDIS_SET_CMPLT:
DPRINT_DBG(NETVSC, DPRINT_DBG(NETVSC,
"REMOTE_NDIS_SET_CMPLT (len %u, id 0x%x, status 0x%x)", "REMOTE_NDIS_SET_CMPLT (len %u, id 0x%x, status 0x%x)",
RndisMessage->MessageLength, rndis_msg->MessageLength,
RndisMessage->Message.SetComplete.RequestId, rndis_msg->Message.SetComplete.RequestId,
RndisMessage->Message.SetComplete.Status); rndis_msg->Message.SetComplete.Status);
break; break;
case REMOTE_NDIS_INDICATE_STATUS_MSG: case REMOTE_NDIS_INDICATE_STATUS_MSG:
DPRINT_DBG(NETVSC, "REMOTE_NDIS_INDICATE_STATUS_MSG " DPRINT_DBG(NETVSC, "REMOTE_NDIS_INDICATE_STATUS_MSG "
"(len %u, status 0x%x, buf len %u, buf offset %u)", "(len %u, status 0x%x, buf len %u, buf offset %u)",
RndisMessage->MessageLength, rndis_msg->MessageLength,
RndisMessage->Message.IndicateStatus.Status, rndis_msg->Message.IndicateStatus.Status,
RndisMessage->Message.IndicateStatus.StatusBufferLength, rndis_msg->Message.IndicateStatus.StatusBufferLength,
RndisMessage->Message.IndicateStatus.StatusBufferOffset); rndis_msg->Message.IndicateStatus.StatusBufferOffset);
break; break;
default: default:
DPRINT_DBG(NETVSC, "0x%x (len %u)", DPRINT_DBG(NETVSC, "0x%x (len %u)",
RndisMessage->NdisMessageType, rndis_msg->NdisMessageType,
RndisMessage->MessageLength); rndis_msg->MessageLength);
break; break;
} }
} }
static int RndisFilterSendRequest(struct rndis_device *Device, static int RndisFilterSendRequest(struct rndis_device *dev,
struct rndis_request *Request) struct rndis_request *req)
{ {
int ret; int ret;
struct hv_netvsc_packet *packet; struct hv_netvsc_packet *packet;
/* Setup the packet to send it */ /* Setup the packet to send it */
packet = &Request->Packet; packet = &req->pkt;
packet->IsDataPacket = false; packet->IsDataPacket = false;
packet->TotalDataBufferLength = Request->RequestMessage.MessageLength; packet->TotalDataBufferLength = req->request_msg.MessageLength;
packet->PageBufferCount = 1; packet->PageBufferCount = 1;
packet->PageBuffers[0].Pfn = virt_to_phys(&Request->RequestMessage) >> packet->PageBuffers[0].Pfn = virt_to_phys(&req->request_msg) >>
PAGE_SHIFT; PAGE_SHIFT;
packet->PageBuffers[0].Length = Request->RequestMessage.MessageLength; packet->PageBuffers[0].Length = req->request_msg.MessageLength;
packet->PageBuffers[0].Offset = packet->PageBuffers[0].Offset =
(unsigned long)&Request->RequestMessage & (PAGE_SIZE - 1); (unsigned long)&req->request_msg & (PAGE_SIZE - 1);
packet->Completion.Send.SendCompletionContext = Request;/* packet; */ packet->Completion.Send.SendCompletionContext = req;/* packet; */
packet->Completion.Send.OnSendCompletion = packet->Completion.Send.OnSendCompletion =
RndisFilterOnSendRequestCompletion; RndisFilterOnSendRequestCompletion;
packet->Completion.Send.SendCompletionTid = (unsigned long)Device; packet->Completion.Send.SendCompletionTid = (unsigned long)dev;
ret = gRndisFilter.InnerDriver.OnSend(Device->NetDevice->Device, packet); ret = rndis_filter.inner_drv.OnSend(dev->net_dev->Device, packet);
return ret; return ret;
} }
static void RndisFilterReceiveResponse(struct rndis_device *Device, static void RndisFilterReceiveResponse(struct rndis_device *dev,
struct rndis_message *Response) struct rndis_message *resp)
{ {
struct rndis_request *request = NULL; struct rndis_request *request = NULL;
bool found = false; bool found = false;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&Device->request_lock, flags); spin_lock_irqsave(&dev->request_lock, flags);
list_for_each_entry(request, &Device->RequestList, ListEntry) { list_for_each_entry(request, &dev->req_list, list_ent) {
/* /*
* All request/response message contains RequestId as the 1st * All request/response message contains RequestId as the 1st
* field * field
*/ */
if (request->RequestMessage.Message.InitializeRequest.RequestId if (request->request_msg.Message.InitializeRequest.RequestId
== Response->Message.InitializeComplete.RequestId) { == resp->Message.InitializeComplete.RequestId) {
DPRINT_DBG(NETVSC, "found rndis request for " DPRINT_DBG(NETVSC, "found rndis request for "
"this response (id 0x%x req type 0x%x res " "this response (id 0x%x req type 0x%x res "
"type 0x%x)", "type 0x%x)",
request->RequestMessage.Message.InitializeRequest.RequestId, request->request_msg.Message.
request->RequestMessage.NdisMessageType, InitializeRequest.RequestId,
Response->NdisMessageType); request->request_msg.NdisMessageType,
resp->NdisMessageType);
found = true; found = true;
break; break;
} }
} }
spin_unlock_irqrestore(&Device->request_lock, flags); spin_unlock_irqrestore(&dev->request_lock, flags);
if (found) { if (found) {
if (Response->MessageLength <= sizeof(struct rndis_message)) { if (resp->MessageLength <= sizeof(struct rndis_message)) {
memcpy(&request->ResponseMessage, Response, memcpy(&request->response_msg, resp,
Response->MessageLength); resp->MessageLength);
} else { } else {
DPRINT_ERR(NETVSC, "rndis response buffer overflow " DPRINT_ERR(NETVSC, "rndis response buffer overflow "
"detected (size %u max %zu)", "detected (size %u max %zu)",
Response->MessageLength, resp->MessageLength,
sizeof(struct rndis_filter_packet)); sizeof(struct rndis_filter_packet));
if (Response->NdisMessageType == if (resp->NdisMessageType ==
REMOTE_NDIS_RESET_CMPLT) { REMOTE_NDIS_RESET_CMPLT) {
/* does not have a request id field */ /* does not have a request id field */
request->ResponseMessage.Message.ResetComplete.Status = STATUS_BUFFER_OVERFLOW; request->response_msg.Message.ResetComplete.
Status = STATUS_BUFFER_OVERFLOW;
} else { } else {
request->ResponseMessage.Message.InitializeComplete.Status = STATUS_BUFFER_OVERFLOW; request->response_msg.Message.
InitializeComplete.Status =
STATUS_BUFFER_OVERFLOW;
} }
} }
osd_waitevent_set(request->WaitEvent); osd_waitevent_set(request->waitevent);
} else { } else {
DPRINT_ERR(NETVSC, "no rndis request found for this response " DPRINT_ERR(NETVSC, "no rndis request found for this response "
"(id 0x%x res type 0x%x)", "(id 0x%x res type 0x%x)",
Response->Message.InitializeComplete.RequestId, resp->Message.InitializeComplete.RequestId,
Response->NdisMessageType); resp->NdisMessageType);
} }
} }
static void RndisFilterReceiveIndicateStatus(struct rndis_device *Device, static void RndisFilterReceiveIndicateStatus(struct rndis_device *dev,
struct rndis_message *Response) struct rndis_message *resp)
{ {
struct rndis_indicate_status *indicate = struct rndis_indicate_status *indicate =
&Response->Message.IndicateStatus; &resp->Message.IndicateStatus;
if (indicate->Status == RNDIS_STATUS_MEDIA_CONNECT) { if (indicate->Status == RNDIS_STATUS_MEDIA_CONNECT) {
gRndisFilter.InnerDriver.OnLinkStatusChanged(Device->NetDevice->Device, 1); rndis_filter.inner_drv.OnLinkStatusChanged(
dev->net_dev->Device, 1);
} else if (indicate->Status == RNDIS_STATUS_MEDIA_DISCONNECT) { } else if (indicate->Status == RNDIS_STATUS_MEDIA_DISCONNECT) {
gRndisFilter.InnerDriver.OnLinkStatusChanged(Device->NetDevice->Device, 0); rndis_filter.inner_drv.OnLinkStatusChanged(
dev->net_dev->Device, 0);
} else { } else {
/* /*
* TODO: * TODO:
...@@ -339,18 +349,18 @@ static void RndisFilterReceiveIndicateStatus(struct rndis_device *Device, ...@@ -339,18 +349,18 @@ static void RndisFilterReceiveIndicateStatus(struct rndis_device *Device,
} }
} }
static void RndisFilterReceiveData(struct rndis_device *Device, static void RndisFilterReceiveData(struct rndis_device *dev,
struct rndis_message *Message, struct rndis_message *msg,
struct hv_netvsc_packet *Packet) struct hv_netvsc_packet *pkt)
{ {
struct rndis_packet *rndisPacket; struct rndis_packet *rndis_pkt;
u32 dataOffset; u32 data_offset;
/* empty ethernet frame ?? */ /* empty ethernet frame ?? */
/* ASSERT(Packet->PageBuffers[0].Length > */ /* ASSERT(Packet->PageBuffers[0].Length > */
/* RNDIS_MESSAGE_SIZE(struct rndis_packet)); */ /* RNDIS_MESSAGE_SIZE(struct rndis_packet)); */
rndisPacket = &Message->Message.Packet; rndis_pkt = &msg->Message.Packet;
/* /*
* FIXME: Handle multiple rndis pkt msgs that maybe enclosed in this * FIXME: Handle multiple rndis pkt msgs that maybe enclosed in this
...@@ -358,48 +368,48 @@ static void RndisFilterReceiveData(struct rndis_device *Device, ...@@ -358,48 +368,48 @@ static void RndisFilterReceiveData(struct rndis_device *Device,
*/ */
/* Remove the rndis header and pass it back up the stack */ /* Remove the rndis header and pass it back up the stack */
dataOffset = RNDIS_HEADER_SIZE + rndisPacket->DataOffset; data_offset = RNDIS_HEADER_SIZE + rndis_pkt->DataOffset;
Packet->TotalDataBufferLength -= dataOffset; pkt->TotalDataBufferLength -= data_offset;
Packet->PageBuffers[0].Offset += dataOffset; pkt->PageBuffers[0].Offset += data_offset;
Packet->PageBuffers[0].Length -= dataOffset; pkt->PageBuffers[0].Length -= data_offset;
Packet->IsDataPacket = true; pkt->IsDataPacket = true;
gRndisFilter.InnerDriver.OnReceiveCallback(Device->NetDevice->Device, rndis_filter.inner_drv.OnReceiveCallback(dev->net_dev->Device,
Packet); pkt);
} }
static int RndisFilterOnReceive(struct hv_device *Device, static int RndisFilterOnReceive(struct hv_device *dev,
struct hv_netvsc_packet *Packet) struct hv_netvsc_packet *pkt)
{ {
struct netvsc_device *netDevice = Device->Extension; struct netvsc_device *net_dev = dev->Extension;
struct rndis_device *rndisDevice; struct rndis_device *rndis_dev;
struct rndis_message rndisMessage; struct rndis_message rndis_msg;
struct rndis_message *rndisHeader; struct rndis_message *rndis_hdr;
if (!netDevice) if (!net_dev)
return -EINVAL; return -EINVAL;
/* Make sure the rndis device state is initialized */ /* Make sure the rndis device state is initialized */
if (!netDevice->Extension) { if (!net_dev->Extension) {
DPRINT_ERR(NETVSC, "got rndis message but no rndis device..." DPRINT_ERR(NETVSC, "got rndis message but no rndis device..."
"dropping this message!"); "dropping this message!");
return -1; return -1;
} }
rndisDevice = (struct rndis_device *)netDevice->Extension; rndis_dev = (struct rndis_device *)net_dev->Extension;
if (rndisDevice->State == RNDIS_DEV_UNINITIALIZED) { if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
DPRINT_ERR(NETVSC, "got rndis message but rndis device " DPRINT_ERR(NETVSC, "got rndis message but rndis device "
"uninitialized...dropping this message!"); "uninitialized...dropping this message!");
return -1; return -1;
} }
rndisHeader = (struct rndis_message *)kmap_atomic( rndis_hdr = (struct rndis_message *)kmap_atomic(
pfn_to_page(Packet->PageBuffers[0].Pfn), KM_IRQ0); pfn_to_page(pkt->PageBuffers[0].Pfn), KM_IRQ0);
rndisHeader = (void *)((unsigned long)rndisHeader + rndis_hdr = (void *)((unsigned long)rndis_hdr +
Packet->PageBuffers[0].Offset); pkt->PageBuffers[0].Offset);
/* Make sure we got a valid rndis message */ /* Make sure we got a valid rndis message */
/* /*
...@@ -408,39 +418,39 @@ static int RndisFilterOnReceive(struct hv_device *Device, ...@@ -408,39 +418,39 @@ static int RndisFilterOnReceive(struct hv_device *Device,
* range shows 52 bytes * range shows 52 bytes
* */ * */
#if 0 #if 0
if (Packet->TotalDataBufferLength != rndisHeader->MessageLength) { if (pkt->TotalDataBufferLength != rndis_hdr->MessageLength) {
kunmap_atomic(rndisHeader - Packet->PageBuffers[0].Offset, kunmap_atomic(rndis_hdr - pkt->PageBuffers[0].Offset,
KM_IRQ0); KM_IRQ0);
DPRINT_ERR(NETVSC, "invalid rndis message? (expected %u " DPRINT_ERR(NETVSC, "invalid rndis message? (expected %u "
"bytes got %u)...dropping this message!", "bytes got %u)...dropping this message!",
rndisHeader->MessageLength, rndis_hdr->MessageLength,
Packet->TotalDataBufferLength); pkt->TotalDataBufferLength);
return -1; return -1;
} }
#endif #endif
if ((rndisHeader->NdisMessageType != REMOTE_NDIS_PACKET_MSG) && if ((rndis_hdr->NdisMessageType != REMOTE_NDIS_PACKET_MSG) &&
(rndisHeader->MessageLength > sizeof(struct rndis_message))) { (rndis_hdr->MessageLength > sizeof(struct rndis_message))) {
DPRINT_ERR(NETVSC, "incoming rndis message buffer overflow " DPRINT_ERR(NETVSC, "incoming rndis message buffer overflow "
"detected (got %u, max %zu)...marking it an error!", "detected (got %u, max %zu)...marking it an error!",
rndisHeader->MessageLength, rndis_hdr->MessageLength,
sizeof(struct rndis_message)); sizeof(struct rndis_message));
} }
memcpy(&rndisMessage, rndisHeader, memcpy(&rndis_msg, rndis_hdr,
(rndisHeader->MessageLength > sizeof(struct rndis_message)) ? (rndis_hdr->MessageLength > sizeof(struct rndis_message)) ?
sizeof(struct rndis_message) : sizeof(struct rndis_message) :
rndisHeader->MessageLength); rndis_hdr->MessageLength);
kunmap_atomic(rndisHeader - Packet->PageBuffers[0].Offset, KM_IRQ0); kunmap_atomic(rndis_hdr - pkt->PageBuffers[0].Offset, KM_IRQ0);
DumpRndisMessage(&rndisMessage); DumpRndisMessage(&rndis_msg);
switch (rndisMessage.NdisMessageType) { switch (rndis_msg.NdisMessageType) {
case REMOTE_NDIS_PACKET_MSG: case REMOTE_NDIS_PACKET_MSG:
/* data msg */ /* data msg */
RndisFilterReceiveData(rndisDevice, &rndisMessage, Packet); RndisFilterReceiveData(rndis_dev, &rndis_msg, pkt);
break; break;
case REMOTE_NDIS_INITIALIZE_CMPLT: case REMOTE_NDIS_INITIALIZE_CMPLT:
...@@ -449,37 +459,37 @@ static int RndisFilterOnReceive(struct hv_device *Device, ...@@ -449,37 +459,37 @@ static int RndisFilterOnReceive(struct hv_device *Device,
/* case REMOTE_NDIS_RESET_CMPLT: */ /* case REMOTE_NDIS_RESET_CMPLT: */
/* case REMOTE_NDIS_KEEPALIVE_CMPLT: */ /* case REMOTE_NDIS_KEEPALIVE_CMPLT: */
/* completion msgs */ /* completion msgs */
RndisFilterReceiveResponse(rndisDevice, &rndisMessage); RndisFilterReceiveResponse(rndis_dev, &rndis_msg);
break; break;
case REMOTE_NDIS_INDICATE_STATUS_MSG: case REMOTE_NDIS_INDICATE_STATUS_MSG:
/* notification msgs */ /* notification msgs */
RndisFilterReceiveIndicateStatus(rndisDevice, &rndisMessage); RndisFilterReceiveIndicateStatus(rndis_dev, &rndis_msg);
break; break;
default: default:
DPRINT_ERR(NETVSC, "unhandled rndis message (type %u len %u)", DPRINT_ERR(NETVSC, "unhandled rndis message (type %u len %u)",
rndisMessage.NdisMessageType, rndis_msg.NdisMessageType,
rndisMessage.MessageLength); rndis_msg.MessageLength);
break; break;
} }
return 0; return 0;
} }
static int RndisFilterQueryDevice(struct rndis_device *Device, u32 Oid, static int RndisFilterQueryDevice(struct rndis_device *dev, u32 oid,
void *Result, u32 *ResultSize) void *result, u32 *result_size)
{ {
struct rndis_request *request; struct rndis_request *request;
u32 inresultSize = *ResultSize; u32 inresult_size = *result_size;
struct rndis_query_request *query; struct rndis_query_request *query;
struct rndis_query_complete *queryComplete; struct rndis_query_complete *query_complete;
int ret = 0; int ret = 0;
if (!Result) if (!result)
return -EINVAL; return -EINVAL;
*ResultSize = 0; *result_size = 0;
request = GetRndisRequest(Device, REMOTE_NDIS_QUERY_MSG, request = GetRndisRequest(dev, REMOTE_NDIS_QUERY_MSG,
RNDIS_MESSAGE_SIZE(struct rndis_query_request)); RNDIS_MESSAGE_SIZE(struct rndis_query_request));
if (!request) { if (!request) {
ret = -1; ret = -1;
...@@ -487,71 +497,71 @@ static int RndisFilterQueryDevice(struct rndis_device *Device, u32 Oid, ...@@ -487,71 +497,71 @@ static int RndisFilterQueryDevice(struct rndis_device *Device, u32 Oid,
} }
/* Setup the rndis query */ /* Setup the rndis query */
query = &request->RequestMessage.Message.QueryRequest; query = &request->request_msg.Message.QueryRequest;
query->Oid = Oid; query->Oid = oid;
query->InformationBufferOffset = sizeof(struct rndis_query_request); query->InformationBufferOffset = sizeof(struct rndis_query_request);
query->InformationBufferLength = 0; query->InformationBufferLength = 0;
query->DeviceVcHandle = 0; query->DeviceVcHandle = 0;
ret = RndisFilterSendRequest(Device, request); ret = RndisFilterSendRequest(dev, request);
if (ret != 0) if (ret != 0)
goto Cleanup; goto Cleanup;
osd_waitevent_wait(request->WaitEvent); osd_waitevent_wait(request->waitevent);
/* Copy the response back */ /* Copy the response back */
queryComplete = &request->ResponseMessage.Message.QueryComplete; query_complete = &request->response_msg.Message.QueryComplete;
if (queryComplete->InformationBufferLength > inresultSize) { if (query_complete->InformationBufferLength > inresult_size) {
ret = -1; ret = -1;
goto Cleanup; goto Cleanup;
} }
memcpy(Result, memcpy(result,
(void *)((unsigned long)queryComplete + (void *)((unsigned long)query_complete +
queryComplete->InformationBufferOffset), query_complete->InformationBufferOffset),
queryComplete->InformationBufferLength); query_complete->InformationBufferLength);
*ResultSize = queryComplete->InformationBufferLength; *result_size = query_complete->InformationBufferLength;
Cleanup: Cleanup:
if (request) if (request)
PutRndisRequest(Device, request); PutRndisRequest(dev, request);
return ret; return ret;
} }
static int RndisFilterQueryDeviceMac(struct rndis_device *Device) static int RndisFilterQueryDeviceMac(struct rndis_device *dev)
{ {
u32 size = ETH_ALEN; u32 size = ETH_ALEN;
return RndisFilterQueryDevice(Device, return RndisFilterQueryDevice(dev,
RNDIS_OID_802_3_PERMANENT_ADDRESS, RNDIS_OID_802_3_PERMANENT_ADDRESS,
Device->HwMacAddr, &size); dev->hw_mac_adr, &size);
} }
static int RndisFilterQueryDeviceLinkStatus(struct rndis_device *Device) static int RndisFilterQueryDeviceLinkStatus(struct rndis_device *dev)
{ {
u32 size = sizeof(u32); u32 size = sizeof(u32);
return RndisFilterQueryDevice(Device, return RndisFilterQueryDevice(dev,
RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
&Device->LinkStatus, &size); &dev->link_stat, &size);
} }
static int RndisFilterSetPacketFilter(struct rndis_device *Device, static int RndisFilterSetPacketFilter(struct rndis_device *dev,
u32 NewFilter) u32 new_filter)
{ {
struct rndis_request *request; struct rndis_request *request;
struct rndis_set_request *set; struct rndis_set_request *set;
struct rndis_set_complete *setComplete; struct rndis_set_complete *set_complete;
u32 status; u32 status;
int ret; int ret;
/* ASSERT(RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32) <= */ /* ASSERT(RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32) <= */
/* sizeof(struct rndis_message)); */ /* sizeof(struct rndis_message)); */
request = GetRndisRequest(Device, REMOTE_NDIS_SET_MSG, request = GetRndisRequest(dev, REMOTE_NDIS_SET_MSG,
RNDIS_MESSAGE_SIZE(struct rndis_set_request) + RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
sizeof(u32)); sizeof(u32));
if (!request) { if (!request) {
...@@ -560,19 +570,19 @@ static int RndisFilterSetPacketFilter(struct rndis_device *Device, ...@@ -560,19 +570,19 @@ static int RndisFilterSetPacketFilter(struct rndis_device *Device,
} }
/* Setup the rndis set */ /* Setup the rndis set */
set = &request->RequestMessage.Message.SetRequest; set = &request->request_msg.Message.SetRequest;
set->Oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER; set->Oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER;
set->InformationBufferLength = sizeof(u32); set->InformationBufferLength = sizeof(u32);
set->InformationBufferOffset = sizeof(struct rndis_set_request); set->InformationBufferOffset = sizeof(struct rndis_set_request);
memcpy((void *)(unsigned long)set + sizeof(struct rndis_set_request), memcpy((void *)(unsigned long)set + sizeof(struct rndis_set_request),
&NewFilter, sizeof(u32)); &new_filter, sizeof(u32));
ret = RndisFilterSendRequest(Device, request); ret = RndisFilterSendRequest(dev, request);
if (ret != 0) if (ret != 0)
goto Cleanup; goto Cleanup;
ret = osd_waitevent_waitex(request->WaitEvent, 2000/*2sec*/); ret = osd_waitevent_waitex(request->waitevent, 2000/*2sec*/);
if (!ret) { if (!ret) {
ret = -1; ret = -1;
DPRINT_ERR(NETVSC, "timeout before we got a set response..."); DPRINT_ERR(NETVSC, "timeout before we got a set response...");
...@@ -584,27 +594,27 @@ static int RndisFilterSetPacketFilter(struct rndis_device *Device, ...@@ -584,27 +594,27 @@ static int RndisFilterSetPacketFilter(struct rndis_device *Device,
} else { } else {
if (ret > 0) if (ret > 0)
ret = 0; ret = 0;
setComplete = &request->ResponseMessage.Message.SetComplete; set_complete = &request->response_msg.Message.SetComplete;
status = setComplete->Status; status = set_complete->Status;
} }
Cleanup: Cleanup:
if (request) if (request)
PutRndisRequest(Device, request); PutRndisRequest(dev, request);
Exit: Exit:
return ret; return ret;
} }
int RndisFilterInit(struct netvsc_driver *Driver) int RndisFilterInit(struct netvsc_driver *drv)
{ {
DPRINT_DBG(NETVSC, "sizeof(struct rndis_filter_packet) == %zd", DPRINT_DBG(NETVSC, "sizeof(struct rndis_filter_packet) == %zd",
sizeof(struct rndis_filter_packet)); sizeof(struct rndis_filter_packet));
Driver->RequestExtSize = sizeof(struct rndis_filter_packet); drv->RequestExtSize = sizeof(struct rndis_filter_packet);
/* Driver->Context = rndisDriver; */ /* Driver->Context = rndisDriver; */
memset(&gRndisFilter, 0, sizeof(struct rndis_filter_driver_object)); memset(&rndis_filter, 0, sizeof(struct rndis_filter_driver_object));
/*rndisDriver->Driver = Driver; /*rndisDriver->Driver = Driver;
...@@ -612,38 +622,38 @@ int RndisFilterInit(struct netvsc_driver *Driver) ...@@ -612,38 +622,38 @@ int RndisFilterInit(struct netvsc_driver *Driver)
rndisDriver->OnLinkStatusChanged = Driver->OnLinkStatusChanged;*/ rndisDriver->OnLinkStatusChanged = Driver->OnLinkStatusChanged;*/
/* Save the original dispatch handlers before we override it */ /* Save the original dispatch handlers before we override it */
gRndisFilter.InnerDriver.Base.OnDeviceAdd = Driver->Base.OnDeviceAdd; rndis_filter.inner_drv.Base.OnDeviceAdd = drv->Base.OnDeviceAdd;
gRndisFilter.InnerDriver.Base.OnDeviceRemove = rndis_filter.inner_drv.Base.OnDeviceRemove =
Driver->Base.OnDeviceRemove; drv->Base.OnDeviceRemove;
gRndisFilter.InnerDriver.Base.OnCleanup = Driver->Base.OnCleanup; rndis_filter.inner_drv.Base.OnCleanup = drv->Base.OnCleanup;
/* ASSERT(Driver->OnSend); */ /* ASSERT(Driver->OnSend); */
/* ASSERT(Driver->OnReceiveCallback); */ /* ASSERT(Driver->OnReceiveCallback); */
gRndisFilter.InnerDriver.OnSend = Driver->OnSend; rndis_filter.inner_drv.OnSend = drv->OnSend;
gRndisFilter.InnerDriver.OnReceiveCallback = Driver->OnReceiveCallback; rndis_filter.inner_drv.OnReceiveCallback = drv->OnReceiveCallback;
gRndisFilter.InnerDriver.OnLinkStatusChanged = rndis_filter.inner_drv.OnLinkStatusChanged =
Driver->OnLinkStatusChanged; drv->OnLinkStatusChanged;
/* Override */ /* Override */
Driver->Base.OnDeviceAdd = RndisFilterOnDeviceAdd; drv->Base.OnDeviceAdd = RndisFilterOnDeviceAdd;
Driver->Base.OnDeviceRemove = RndisFilterOnDeviceRemove; drv->Base.OnDeviceRemove = RndisFilterOnDeviceRemove;
Driver->Base.OnCleanup = RndisFilterOnCleanup; drv->Base.OnCleanup = RndisFilterOnCleanup;
Driver->OnSend = RndisFilterOnSend; drv->OnSend = RndisFilterOnSend;
/* Driver->QueryLinkStatus = RndisFilterQueryDeviceLinkStatus; */ /* Driver->QueryLinkStatus = RndisFilterQueryDeviceLinkStatus; */
Driver->OnReceiveCallback = RndisFilterOnReceive; drv->OnReceiveCallback = RndisFilterOnReceive;
return 0; return 0;
} }
static int RndisFilterInitDevice(struct rndis_device *Device) static int RndisFilterInitDevice(struct rndis_device *dev)
{ {
struct rndis_request *request; struct rndis_request *request;
struct rndis_initialize_request *init; struct rndis_initialize_request *init;
struct rndis_initialize_complete *initComplete; struct rndis_initialize_complete *init_complete;
u32 status; u32 status;
int ret; int ret;
request = GetRndisRequest(Device, REMOTE_NDIS_INITIALIZE_MSG, request = GetRndisRequest(dev, REMOTE_NDIS_INITIALIZE_MSG,
RNDIS_MESSAGE_SIZE(struct rndis_initialize_request)); RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
if (!request) { if (!request) {
ret = -1; ret = -1;
...@@ -651,103 +661,103 @@ static int RndisFilterInitDevice(struct rndis_device *Device) ...@@ -651,103 +661,103 @@ static int RndisFilterInitDevice(struct rndis_device *Device)
} }
/* Setup the rndis set */ /* Setup the rndis set */
init = &request->RequestMessage.Message.InitializeRequest; init = &request->request_msg.Message.InitializeRequest;
init->MajorVersion = RNDIS_MAJOR_VERSION; init->MajorVersion = RNDIS_MAJOR_VERSION;
init->MinorVersion = RNDIS_MINOR_VERSION; init->MinorVersion = RNDIS_MINOR_VERSION;
/* FIXME: Use 1536 - rounded ethernet frame size */ /* FIXME: Use 1536 - rounded ethernet frame size */
init->MaxTransferSize = 2048; init->MaxTransferSize = 2048;
Device->State = RNDIS_DEV_INITIALIZING; dev->state = RNDIS_DEV_INITIALIZING;
ret = RndisFilterSendRequest(Device, request); ret = RndisFilterSendRequest(dev, request);
if (ret != 0) { if (ret != 0) {
Device->State = RNDIS_DEV_UNINITIALIZED; dev->state = RNDIS_DEV_UNINITIALIZED;
goto Cleanup; goto Cleanup;
} }
osd_waitevent_wait(request->WaitEvent); osd_waitevent_wait(request->waitevent);
initComplete = &request->ResponseMessage.Message.InitializeComplete; init_complete = &request->response_msg.Message.InitializeComplete;
status = initComplete->Status; status = init_complete->Status;
if (status == RNDIS_STATUS_SUCCESS) { if (status == RNDIS_STATUS_SUCCESS) {
Device->State = RNDIS_DEV_INITIALIZED; dev->state = RNDIS_DEV_INITIALIZED;
ret = 0; ret = 0;
} else { } else {
Device->State = RNDIS_DEV_UNINITIALIZED; dev->state = RNDIS_DEV_UNINITIALIZED;
ret = -1; ret = -1;
} }
Cleanup: Cleanup:
if (request) if (request)
PutRndisRequest(Device, request); PutRndisRequest(dev, request);
return ret; return ret;
} }
static void RndisFilterHaltDevice(struct rndis_device *Device) static void RndisFilterHaltDevice(struct rndis_device *dev)
{ {
struct rndis_request *request; struct rndis_request *request;
struct rndis_halt_request *halt; struct rndis_halt_request *halt;
/* Attempt to do a rndis device halt */ /* Attempt to do a rndis device halt */
request = GetRndisRequest(Device, REMOTE_NDIS_HALT_MSG, request = GetRndisRequest(dev, REMOTE_NDIS_HALT_MSG,
RNDIS_MESSAGE_SIZE(struct rndis_halt_request)); RNDIS_MESSAGE_SIZE(struct rndis_halt_request));
if (!request) if (!request)
goto Cleanup; goto Cleanup;
/* Setup the rndis set */ /* Setup the rndis set */
halt = &request->RequestMessage.Message.HaltRequest; halt = &request->request_msg.Message.HaltRequest;
halt->RequestId = atomic_inc_return(&Device->NewRequestId); halt->RequestId = atomic_inc_return(&dev->new_req_id);
/* Ignore return since this msg is optional. */ /* Ignore return since this msg is optional. */
RndisFilterSendRequest(Device, request); RndisFilterSendRequest(dev, request);
Device->State = RNDIS_DEV_UNINITIALIZED; dev->state = RNDIS_DEV_UNINITIALIZED;
Cleanup: Cleanup:
if (request) if (request)
PutRndisRequest(Device, request); PutRndisRequest(dev, request);
return; return;
} }
static int RndisFilterOpenDevice(struct rndis_device *Device) static int RndisFilterOpenDevice(struct rndis_device *dev)
{ {
int ret; int ret;
if (Device->State != RNDIS_DEV_INITIALIZED) if (dev->state != RNDIS_DEV_INITIALIZED)
return 0; return 0;
ret = RndisFilterSetPacketFilter(Device, ret = RndisFilterSetPacketFilter(dev,
NDIS_PACKET_TYPE_BROADCAST | NDIS_PACKET_TYPE_BROADCAST |
NDIS_PACKET_TYPE_ALL_MULTICAST | NDIS_PACKET_TYPE_ALL_MULTICAST |
NDIS_PACKET_TYPE_DIRECTED); NDIS_PACKET_TYPE_DIRECTED);
if (ret == 0) if (ret == 0)
Device->State = RNDIS_DEV_DATAINITIALIZED; dev->state = RNDIS_DEV_DATAINITIALIZED;
return ret; return ret;
} }
static int RndisFilterCloseDevice(struct rndis_device *Device) static int RndisFilterCloseDevice(struct rndis_device *dev)
{ {
int ret; int ret;
if (Device->State != RNDIS_DEV_DATAINITIALIZED) if (dev->state != RNDIS_DEV_DATAINITIALIZED)
return 0; return 0;
ret = RndisFilterSetPacketFilter(Device, 0); ret = RndisFilterSetPacketFilter(dev, 0);
if (ret == 0) if (ret == 0)
Device->State = RNDIS_DEV_INITIALIZED; dev->state = RNDIS_DEV_INITIALIZED;
return ret; return ret;
} }
static int RndisFilterOnDeviceAdd(struct hv_device *Device, static int RndisFilterOnDeviceAdd(struct hv_device *dev,
void *AdditionalInfo) void *additional_info)
{ {
int ret; int ret;
struct netvsc_device *netDevice; struct netvsc_device *netDevice;
struct rndis_device *rndisDevice; struct rndis_device *rndisDevice;
struct netvsc_device_info *deviceInfo = AdditionalInfo; struct netvsc_device_info *deviceInfo = additional_info;
rndisDevice = GetRndisDevice(); rndisDevice = GetRndisDevice();
if (!rndisDevice) if (!rndisDevice)
...@@ -760,7 +770,7 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device, ...@@ -760,7 +770,7 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device,
* NOTE! Once the channel is created, we may get a receive callback * NOTE! Once the channel is created, we may get a receive callback
* (RndisFilterOnReceive()) before this call is completed * (RndisFilterOnReceive()) before this call is completed
*/ */
ret = gRndisFilter.InnerDriver.Base.OnDeviceAdd(Device, AdditionalInfo); ret = rndis_filter.inner_drv.Base.OnDeviceAdd(dev, additional_info);
if (ret != 0) { if (ret != 0) {
kfree(rndisDevice); kfree(rndisDevice);
return ret; return ret;
...@@ -768,12 +778,12 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device, ...@@ -768,12 +778,12 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device,
/* Initialize the rndis device */ /* Initialize the rndis device */
netDevice = Device->Extension; netDevice = dev->Extension;
/* ASSERT(netDevice); */ /* ASSERT(netDevice); */
/* ASSERT(netDevice->Device); */ /* ASSERT(netDevice->Device); */
netDevice->Extension = rndisDevice; netDevice->Extension = rndisDevice;
rndisDevice->NetDevice = netDevice; rndisDevice->net_dev = netDevice;
/* Send the rndis initialization message */ /* Send the rndis initialization message */
ret = RndisFilterInitDevice(rndisDevice); ret = RndisFilterInitDevice(rndisDevice);
...@@ -793,43 +803,43 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device, ...@@ -793,43 +803,43 @@ static int RndisFilterOnDeviceAdd(struct hv_device *Device,
} }
DPRINT_INFO(NETVSC, "Device 0x%p mac addr %pM", DPRINT_INFO(NETVSC, "Device 0x%p mac addr %pM",
rndisDevice, rndisDevice->HwMacAddr); rndisDevice, rndisDevice->hw_mac_adr);
memcpy(deviceInfo->MacAddr, rndisDevice->HwMacAddr, ETH_ALEN); memcpy(deviceInfo->MacAddr, rndisDevice->hw_mac_adr, ETH_ALEN);
RndisFilterQueryDeviceLinkStatus(rndisDevice); RndisFilterQueryDeviceLinkStatus(rndisDevice);
deviceInfo->LinkState = rndisDevice->LinkStatus; deviceInfo->LinkState = rndisDevice->link_stat;
DPRINT_INFO(NETVSC, "Device 0x%p link state %s", rndisDevice, DPRINT_INFO(NETVSC, "Device 0x%p link state %s", rndisDevice,
((deviceInfo->LinkState) ? ("down") : ("up"))); ((deviceInfo->LinkState) ? ("down") : ("up")));
return ret; return ret;
} }
static int RndisFilterOnDeviceRemove(struct hv_device *Device) static int RndisFilterOnDeviceRemove(struct hv_device *dev)
{ {
struct netvsc_device *netDevice = Device->Extension; struct netvsc_device *net_dev = dev->Extension;
struct rndis_device *rndisDevice = netDevice->Extension; struct rndis_device *rndis_dev = net_dev->Extension;
/* Halt and release the rndis device */ /* Halt and release the rndis device */
RndisFilterHaltDevice(rndisDevice); RndisFilterHaltDevice(rndis_dev);
kfree(rndisDevice); kfree(rndis_dev);
netDevice->Extension = NULL; net_dev->Extension = NULL;
/* Pass control to inner driver to remove the device */ /* Pass control to inner driver to remove the device */
gRndisFilter.InnerDriver.Base.OnDeviceRemove(Device); rndis_filter.inner_drv.Base.OnDeviceRemove(dev);
return 0; return 0;
} }
static void RndisFilterOnCleanup(struct hv_driver *Driver) static void RndisFilterOnCleanup(struct hv_driver *drv)
{ {
} }
int RndisFilterOnOpen(struct hv_device *Device) int RndisFilterOnOpen(struct hv_device *dev)
{ {
struct netvsc_device *netDevice = Device->Extension; struct netvsc_device *netDevice = dev->Extension;
if (!netDevice) if (!netDevice)
return -EINVAL; return -EINVAL;
...@@ -837,9 +847,9 @@ int RndisFilterOnOpen(struct hv_device *Device) ...@@ -837,9 +847,9 @@ int RndisFilterOnOpen(struct hv_device *Device)
return RndisFilterOpenDevice(netDevice->Extension); return RndisFilterOpenDevice(netDevice->Extension);
} }
int RndisFilterOnClose(struct hv_device *Device) int RndisFilterOnClose(struct hv_device *dev)
{ {
struct netvsc_device *netDevice = Device->Extension; struct netvsc_device *netDevice = dev->Extension;
if (!netDevice) if (!netDevice)
return -EINVAL; return -EINVAL;
...@@ -847,8 +857,8 @@ int RndisFilterOnClose(struct hv_device *Device) ...@@ -847,8 +857,8 @@ int RndisFilterOnClose(struct hv_device *Device)
return RndisFilterCloseDevice(netDevice->Extension); return RndisFilterCloseDevice(netDevice->Extension);
} }
static int RndisFilterOnSend(struct hv_device *Device, static int RndisFilterOnSend(struct hv_device *dev,
struct hv_netvsc_packet *Packet) struct hv_netvsc_packet *pkt)
{ {
int ret; int ret;
struct rndis_filter_packet *filterPacket; struct rndis_filter_packet *filterPacket;
...@@ -857,62 +867,62 @@ static int RndisFilterOnSend(struct hv_device *Device, ...@@ -857,62 +867,62 @@ static int RndisFilterOnSend(struct hv_device *Device,
u32 rndisMessageSize; u32 rndisMessageSize;
/* Add the rndis header */ /* Add the rndis header */
filterPacket = (struct rndis_filter_packet *)Packet->Extension; filterPacket = (struct rndis_filter_packet *)pkt->Extension;
/* ASSERT(filterPacket); */ /* ASSERT(filterPacket); */
memset(filterPacket, 0, sizeof(struct rndis_filter_packet)); memset(filterPacket, 0, sizeof(struct rndis_filter_packet));
rndisMessage = &filterPacket->Message; rndisMessage = &filterPacket->msg;
rndisMessageSize = RNDIS_MESSAGE_SIZE(struct rndis_packet); rndisMessageSize = RNDIS_MESSAGE_SIZE(struct rndis_packet);
rndisMessage->NdisMessageType = REMOTE_NDIS_PACKET_MSG; rndisMessage->NdisMessageType = REMOTE_NDIS_PACKET_MSG;
rndisMessage->MessageLength = Packet->TotalDataBufferLength + rndisMessage->MessageLength = pkt->TotalDataBufferLength +
rndisMessageSize; rndisMessageSize;
rndisPacket = &rndisMessage->Message.Packet; rndisPacket = &rndisMessage->Message.Packet;
rndisPacket->DataOffset = sizeof(struct rndis_packet); rndisPacket->DataOffset = sizeof(struct rndis_packet);
rndisPacket->DataLength = Packet->TotalDataBufferLength; rndisPacket->DataLength = pkt->TotalDataBufferLength;
Packet->IsDataPacket = true; pkt->IsDataPacket = true;
Packet->PageBuffers[0].Pfn = virt_to_phys(rndisMessage) >> PAGE_SHIFT; pkt->PageBuffers[0].Pfn = virt_to_phys(rndisMessage) >> PAGE_SHIFT;
Packet->PageBuffers[0].Offset = pkt->PageBuffers[0].Offset =
(unsigned long)rndisMessage & (PAGE_SIZE-1); (unsigned long)rndisMessage & (PAGE_SIZE-1);
Packet->PageBuffers[0].Length = rndisMessageSize; pkt->PageBuffers[0].Length = rndisMessageSize;
/* Save the packet send completion and context */ /* Save the packet send completion and context */
filterPacket->OnCompletion = Packet->Completion.Send.OnSendCompletion; filterPacket->completion = pkt->Completion.Send.OnSendCompletion;
filterPacket->CompletionContext = filterPacket->completion_ctx =
Packet->Completion.Send.SendCompletionContext; pkt->Completion.Send.SendCompletionContext;
/* Use ours */ /* Use ours */
Packet->Completion.Send.OnSendCompletion = RndisFilterOnSendCompletion; pkt->Completion.Send.OnSendCompletion = RndisFilterOnSendCompletion;
Packet->Completion.Send.SendCompletionContext = filterPacket; pkt->Completion.Send.SendCompletionContext = filterPacket;
ret = gRndisFilter.InnerDriver.OnSend(Device, Packet); ret = rndis_filter.inner_drv.OnSend(dev, pkt);
if (ret != 0) { if (ret != 0) {
/* /*
* Reset the completion to originals to allow retries from * Reset the completion to originals to allow retries from
* above * above
*/ */
Packet->Completion.Send.OnSendCompletion = pkt->Completion.Send.OnSendCompletion =
filterPacket->OnCompletion; filterPacket->completion;
Packet->Completion.Send.SendCompletionContext = pkt->Completion.Send.SendCompletionContext =
filterPacket->CompletionContext; filterPacket->completion_ctx;
} }
return ret; return ret;
} }
static void RndisFilterOnSendCompletion(void *Context) static void RndisFilterOnSendCompletion(void *ctx)
{ {
struct rndis_filter_packet *filterPacket = Context; struct rndis_filter_packet *filterPacket = ctx;
/* Pass it back to the original handler */ /* Pass it back to the original handler */
filterPacket->OnCompletion(filterPacket->CompletionContext); filterPacket->completion(filterPacket->completion_ctx);
} }
static void RndisFilterOnSendRequestCompletion(void *Context) static void RndisFilterOnSendRequestCompletion(void *ctx)
{ {
/* Noop */ /* Noop */
} }
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