Staging: hv: remove use of internal list routines in NetVsc
The hv driver has it's own linked list routines. This removes them from NetVsc and uses the kernels routines instead. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Cc: Hank Janssen <hjanssen@microsoft.com> Cc: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
03a6b30a8c
commit
d29274efb7
+28
-49
@@ -711,8 +711,7 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i;
|
int i;
|
||||||
struct netvsc_device *netDevice;
|
struct netvsc_device *netDevice;
|
||||||
struct hv_netvsc_packet *packet;
|
struct hv_netvsc_packet *packet, *pos;
|
||||||
LIST_ENTRY *entry;
|
|
||||||
struct netvsc_driver *netDriver =
|
struct netvsc_driver *netDriver =
|
||||||
(struct netvsc_driver *)Device->Driver;
|
(struct netvsc_driver *)Device->Driver;
|
||||||
|
|
||||||
@@ -732,7 +731,7 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
|
|||||||
|
|
||||||
netDevice->SendBufferSize = NETVSC_SEND_BUFFER_SIZE;
|
netDevice->SendBufferSize = NETVSC_SEND_BUFFER_SIZE;
|
||||||
|
|
||||||
INITIALIZE_LIST_HEAD(&netDevice->ReceivePacketList);
|
INIT_LIST_HEAD(&netDevice->ReceivePacketList);
|
||||||
|
|
||||||
for (i = 0; i < NETVSC_RECEIVE_PACKETLIST_COUNT; i++) {
|
for (i = 0; i < NETVSC_RECEIVE_PACKETLIST_COUNT; i++) {
|
||||||
packet = kzalloc(sizeof(struct hv_netvsc_packet) +
|
packet = kzalloc(sizeof(struct hv_netvsc_packet) +
|
||||||
@@ -744,9 +743,8 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
|
|||||||
NETVSC_RECEIVE_PACKETLIST_COUNT, i);
|
NETVSC_RECEIVE_PACKETLIST_COUNT, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
list_add_tail(&packet->ListEntry,
|
||||||
INSERT_TAIL_LIST(&netDevice->ReceivePacketList,
|
&netDevice->ReceivePacketList);
|
||||||
&packet->ListEntry);
|
|
||||||
}
|
}
|
||||||
netDevice->ChannelInitEvent = osd_WaitEventCreate();
|
netDevice->ChannelInitEvent = osd_WaitEventCreate();
|
||||||
|
|
||||||
@@ -790,11 +788,10 @@ Cleanup:
|
|||||||
if (netDevice) {
|
if (netDevice) {
|
||||||
kfree(netDevice->ChannelInitEvent);
|
kfree(netDevice->ChannelInitEvent);
|
||||||
|
|
||||||
while (!IsListEmpty(&netDevice->ReceivePacketList)) {
|
list_for_each_entry_safe(packet, pos,
|
||||||
entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
|
&netDevice->ReceivePacketList,
|
||||||
packet = CONTAINING_RECORD(entry,
|
ListEntry) {
|
||||||
struct hv_netvsc_packet,
|
list_del(&packet->ListEntry);
|
||||||
ListEntry);
|
|
||||||
kfree(packet);
|
kfree(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -814,8 +811,7 @@ Cleanup:
|
|||||||
static int NetVscOnDeviceRemove(struct hv_device *Device)
|
static int NetVscOnDeviceRemove(struct hv_device *Device)
|
||||||
{
|
{
|
||||||
struct netvsc_device *netDevice;
|
struct netvsc_device *netDevice;
|
||||||
struct hv_netvsc_packet *netvscPacket;
|
struct hv_netvsc_packet *netvscPacket, *pos;
|
||||||
LIST_ENTRY *entry;
|
|
||||||
|
|
||||||
DPRINT_ENTER(NETVSC);
|
DPRINT_ENTER(NETVSC);
|
||||||
|
|
||||||
@@ -853,12 +849,9 @@ static int NetVscOnDeviceRemove(struct hv_device *Device)
|
|||||||
Device->Driver->VmbusChannelInterface.Close(Device);
|
Device->Driver->VmbusChannelInterface.Close(Device);
|
||||||
|
|
||||||
/* Release all resources */
|
/* Release all resources */
|
||||||
while (!IsListEmpty(&netDevice->ReceivePacketList)) {
|
list_for_each_entry_safe(netvscPacket, pos,
|
||||||
entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
|
&netDevice->ReceivePacketList, ListEntry) {
|
||||||
netvscPacket = CONTAINING_RECORD(entry,
|
list_del(&netvscPacket->ListEntry);
|
||||||
struct hv_netvsc_packet,
|
|
||||||
ListEntry);
|
|
||||||
|
|
||||||
kfree(netvscPacket);
|
kfree(netvscPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -994,15 +987,14 @@ static void NetVscOnReceive(struct hv_device *Device,
|
|||||||
struct vmtransfer_page_packet_header *vmxferpagePacket;
|
struct vmtransfer_page_packet_header *vmxferpagePacket;
|
||||||
struct nvsp_message *nvspPacket;
|
struct nvsp_message *nvspPacket;
|
||||||
struct hv_netvsc_packet *netvscPacket = NULL;
|
struct hv_netvsc_packet *netvscPacket = NULL;
|
||||||
LIST_ENTRY *entry;
|
|
||||||
unsigned long start;
|
unsigned long start;
|
||||||
unsigned long end, endVirtual;
|
unsigned long end, endVirtual;
|
||||||
/* struct netvsc_driver *netvscDriver; */
|
/* struct netvsc_driver *netvscDriver; */
|
||||||
struct xferpage_packet *xferpagePacket = NULL;
|
struct xferpage_packet *xferpagePacket = NULL;
|
||||||
LIST_ENTRY listHead;
|
|
||||||
int i, j;
|
int i, j;
|
||||||
int count = 0, bytesRemain = 0;
|
int count = 0, bytesRemain = 0;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
LIST_HEAD(listHead);
|
||||||
|
|
||||||
DPRINT_ENTER(NETVSC);
|
DPRINT_ENTER(NETVSC);
|
||||||
|
|
||||||
@@ -1052,8 +1044,6 @@ static void NetVscOnReceive(struct hv_device *Device,
|
|||||||
DPRINT_DBG(NETVSC, "xfer page - range count %d",
|
DPRINT_DBG(NETVSC, "xfer page - range count %d",
|
||||||
vmxferpagePacket->RangeCount);
|
vmxferpagePacket->RangeCount);
|
||||||
|
|
||||||
INITIALIZE_LIST_HEAD(&listHead);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Grab free packets (range count + 1) to represent this xfer
|
* Grab free packets (range count + 1) to represent this xfer
|
||||||
* page packet. +1 to represent the xfer page packet itself.
|
* page packet. +1 to represent the xfer page packet itself.
|
||||||
@@ -1061,14 +1051,8 @@ static void NetVscOnReceive(struct hv_device *Device,
|
|||||||
* fulfil
|
* fulfil
|
||||||
*/
|
*/
|
||||||
spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
|
spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
|
||||||
while (!IsListEmpty(&netDevice->ReceivePacketList)) {
|
while (!list_empty(&netDevice->ReceivePacketList)) {
|
||||||
entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
|
list_move_tail(&netDevice->ReceivePacketList, &listHead);
|
||||||
netvscPacket = CONTAINING_RECORD(entry,
|
|
||||||
struct hv_netvsc_packet,
|
|
||||||
ListEntry);
|
|
||||||
|
|
||||||
INSERT_TAIL_LIST(&listHead, &netvscPacket->ListEntry);
|
|
||||||
|
|
||||||
if (++count == vmxferpagePacket->RangeCount + 1)
|
if (++count == vmxferpagePacket->RangeCount + 1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1087,13 +1071,8 @@ static void NetVscOnReceive(struct hv_device *Device,
|
|||||||
/* Return it to the freelist */
|
/* Return it to the freelist */
|
||||||
spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
|
spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
|
||||||
for (i = count; i != 0; i--) {
|
for (i = count; i != 0; i--) {
|
||||||
entry = REMOVE_HEAD_LIST(&listHead);
|
list_move_tail(&listHead,
|
||||||
netvscPacket = CONTAINING_RECORD(entry,
|
&netDevice->ReceivePacketList);
|
||||||
struct hv_netvsc_packet,
|
|
||||||
ListEntry);
|
|
||||||
|
|
||||||
INSERT_TAIL_LIST(&netDevice->ReceivePacketList,
|
|
||||||
&netvscPacket->ListEntry);
|
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&netDevice->receive_packet_list_lock,
|
spin_unlock_irqrestore(&netDevice->receive_packet_list_lock,
|
||||||
flags);
|
flags);
|
||||||
@@ -1106,9 +1085,10 @@ static void NetVscOnReceive(struct hv_device *Device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the 1st packet to represent the xfer page packet itself */
|
/* Remove the 1st packet to represent the xfer page packet itself */
|
||||||
entry = REMOVE_HEAD_LIST(&listHead);
|
xferpagePacket = list_entry(&listHead, struct xferpage_packet,
|
||||||
xferpagePacket = CONTAINING_RECORD(entry, struct xferpage_packet,
|
ListEntry);
|
||||||
ListEntry);
|
list_del(&xferpagePacket->ListEntry);
|
||||||
|
|
||||||
/* This is how much we can satisfy */
|
/* This is how much we can satisfy */
|
||||||
xferpagePacket->Count = count - 1;
|
xferpagePacket->Count = count - 1;
|
||||||
ASSERT(xferpagePacket->Count > 0 && xferpagePacket->Count <=
|
ASSERT(xferpagePacket->Count > 0 && xferpagePacket->Count <=
|
||||||
@@ -1122,10 +1102,9 @@ static void NetVscOnReceive(struct hv_device *Device,
|
|||||||
|
|
||||||
/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
|
/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
|
||||||
for (i = 0; i < (count - 1); i++) {
|
for (i = 0; i < (count - 1); i++) {
|
||||||
entry = REMOVE_HEAD_LIST(&listHead);
|
netvscPacket = list_entry(&listHead, struct hv_netvsc_packet,
|
||||||
netvscPacket = CONTAINING_RECORD(entry,
|
ListEntry);
|
||||||
struct hv_netvsc_packet,
|
list_del(&netvscPacket->ListEntry);
|
||||||
ListEntry);
|
|
||||||
|
|
||||||
/* Initialize the netvsc packet */
|
/* Initialize the netvsc packet */
|
||||||
netvscPacket->XferPagePacket = xferpagePacket;
|
netvscPacket->XferPagePacket = xferpagePacket;
|
||||||
@@ -1198,7 +1177,7 @@ static void NetVscOnReceive(struct hv_device *Device,
|
|||||||
NetVscOnReceiveCompletion(netvscPacket->Completion.Recv.ReceiveCompletionContext);
|
NetVscOnReceiveCompletion(netvscPacket->Completion.Recv.ReceiveCompletionContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(IsListEmpty(&listHead));
|
ASSERT(list_empty(&listHead));
|
||||||
|
|
||||||
PutNetDevice(Device);
|
PutNetDevice(Device);
|
||||||
DPRINT_EXIT(NETVSC);
|
DPRINT_EXIT(NETVSC);
|
||||||
@@ -1290,13 +1269,13 @@ static void NetVscOnReceiveCompletion(void *Context)
|
|||||||
if (packet->XferPagePacket->Count == 0) {
|
if (packet->XferPagePacket->Count == 0) {
|
||||||
fSendReceiveComp = true;
|
fSendReceiveComp = true;
|
||||||
transactionId = packet->Completion.Recv.ReceiveCompletionTid;
|
transactionId = packet->Completion.Recv.ReceiveCompletionTid;
|
||||||
|
list_add_tail(&packet->XferPagePacket->ListEntry,
|
||||||
|
&netDevice->ReceivePacketList);
|
||||||
|
|
||||||
INSERT_TAIL_LIST(&netDevice->ReceivePacketList,
|
|
||||||
&packet->XferPagePacket->ListEntry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put the packet back */
|
/* Put the packet back */
|
||||||
INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &packet->ListEntry);
|
list_add_tail(&packet->ListEntry, &netDevice->ReceivePacketList);
|
||||||
spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags);
|
spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags);
|
||||||
|
|
||||||
/* Send a receive completion for the xfer page packet */
|
/* Send a receive completion for the xfer page packet */
|
||||||
|
|||||||
@@ -24,9 +24,9 @@
|
|||||||
#ifndef _NETVSC_H_
|
#ifndef _NETVSC_H_
|
||||||
#define _NETVSC_H_
|
#define _NETVSC_H_
|
||||||
|
|
||||||
|
#include <linux/list.h>
|
||||||
#include "VmbusPacketFormat.h"
|
#include "VmbusPacketFormat.h"
|
||||||
#include "VmbusChannelInterface.h"
|
#include "VmbusChannelInterface.h"
|
||||||
#include "List.h"
|
|
||||||
#include "NetVscApi.h"
|
#include "NetVscApi.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ struct netvsc_device {
|
|||||||
* List of free preallocated hv_netvsc_packet to represent receive
|
* List of free preallocated hv_netvsc_packet to represent receive
|
||||||
* packet
|
* packet
|
||||||
*/
|
*/
|
||||||
LIST_ENTRY ReceivePacketList;
|
struct list_head ReceivePacketList;
|
||||||
spinlock_t receive_packet_list_lock;
|
spinlock_t receive_packet_list_lock;
|
||||||
|
|
||||||
/* Send buffer allocated by us but manages by NetVSP */
|
/* Send buffer allocated by us but manages by NetVSP */
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ struct hv_netvsc_packet;
|
|||||||
|
|
||||||
/* Represent the xfer page packet which contains 1 or more netvsc packet */
|
/* Represent the xfer page packet which contains 1 or more netvsc packet */
|
||||||
struct xferpage_packet {
|
struct xferpage_packet {
|
||||||
LIST_ENTRY ListEntry;
|
struct list_head ListEntry;
|
||||||
|
|
||||||
/* # of netvsc packets this xfer packet contains */
|
/* # of netvsc packets this xfer packet contains */
|
||||||
u32 Count;
|
u32 Count;
|
||||||
@@ -52,7 +52,7 @@ struct xferpage_packet {
|
|||||||
*/
|
*/
|
||||||
struct hv_netvsc_packet {
|
struct hv_netvsc_packet {
|
||||||
/* Bookkeeping stuff */
|
/* Bookkeeping stuff */
|
||||||
LIST_ENTRY ListEntry;
|
struct list_head ListEntry;
|
||||||
|
|
||||||
struct hv_device *Device;
|
struct hv_device *Device;
|
||||||
bool IsDataPacket;
|
bool IsDataPacket;
|
||||||
|
|||||||
Reference in New Issue
Block a user