Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 162285
b: refs/heads/master
c: d29274e
h: refs/heads/master
i:
  162283: 675a774
v: v3
  • Loading branch information
Bill Pemberton authored and Greg Kroah-Hartman committed Sep 15, 2009
1 parent 5ff5132 commit 96dc104
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 54 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 03a6b30a8c4420fb4be765a945a6989d4bcd24a8
refs/heads/master: d29274efb73735c6a94f20214b1e4ea994da8848
77 changes: 28 additions & 49 deletions trunk/drivers/staging/hv/NetVsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,7 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
int ret = 0;
int i;
struct netvsc_device *netDevice;
struct hv_netvsc_packet *packet;
LIST_ENTRY *entry;
struct hv_netvsc_packet *packet, *pos;
struct netvsc_driver *netDriver =
(struct netvsc_driver *)Device->Driver;

Expand All @@ -732,7 +731,7 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)

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++) {
packet = kzalloc(sizeof(struct hv_netvsc_packet) +
Expand All @@ -744,9 +743,8 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
NETVSC_RECEIVE_PACKETLIST_COUNT, i);
break;
}

INSERT_TAIL_LIST(&netDevice->ReceivePacketList,
&packet->ListEntry);
list_add_tail(&packet->ListEntry,
&netDevice->ReceivePacketList);
}
netDevice->ChannelInitEvent = osd_WaitEventCreate();

Expand Down Expand Up @@ -790,11 +788,10 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
if (netDevice) {
kfree(netDevice->ChannelInitEvent);

while (!IsListEmpty(&netDevice->ReceivePacketList)) {
entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
packet = CONTAINING_RECORD(entry,
struct hv_netvsc_packet,
ListEntry);
list_for_each_entry_safe(packet, pos,
&netDevice->ReceivePacketList,
ListEntry) {
list_del(&packet->ListEntry);
kfree(packet);
}

Expand All @@ -814,8 +811,7 @@ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
static int NetVscOnDeviceRemove(struct hv_device *Device)
{
struct netvsc_device *netDevice;
struct hv_netvsc_packet *netvscPacket;
LIST_ENTRY *entry;
struct hv_netvsc_packet *netvscPacket, *pos;

DPRINT_ENTER(NETVSC);

Expand Down Expand Up @@ -853,12 +849,9 @@ static int NetVscOnDeviceRemove(struct hv_device *Device)
Device->Driver->VmbusChannelInterface.Close(Device);

/* Release all resources */
while (!IsListEmpty(&netDevice->ReceivePacketList)) {
entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
netvscPacket = CONTAINING_RECORD(entry,
struct hv_netvsc_packet,
ListEntry);

list_for_each_entry_safe(netvscPacket, pos,
&netDevice->ReceivePacketList, ListEntry) {
list_del(&netvscPacket->ListEntry);
kfree(netvscPacket);
}

Expand Down Expand Up @@ -994,15 +987,14 @@ static void NetVscOnReceive(struct hv_device *Device,
struct vmtransfer_page_packet_header *vmxferpagePacket;
struct nvsp_message *nvspPacket;
struct hv_netvsc_packet *netvscPacket = NULL;
LIST_ENTRY *entry;
unsigned long start;
unsigned long end, endVirtual;
/* struct netvsc_driver *netvscDriver; */
struct xferpage_packet *xferpagePacket = NULL;
LIST_ENTRY listHead;
int i, j;
int count = 0, bytesRemain = 0;
unsigned long flags;
LIST_HEAD(listHead);

DPRINT_ENTER(NETVSC);

Expand Down Expand Up @@ -1052,23 +1044,15 @@ static void NetVscOnReceive(struct hv_device *Device,
DPRINT_DBG(NETVSC, "xfer page - range count %d",
vmxferpagePacket->RangeCount);

INITIALIZE_LIST_HEAD(&listHead);

/*
* Grab free packets (range count + 1) to represent this xfer
* page packet. +1 to represent the xfer page packet itself.
* We grab it here so that we know exactly how many we can
* fulfil
*/
spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
while (!IsListEmpty(&netDevice->ReceivePacketList)) {
entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
netvscPacket = CONTAINING_RECORD(entry,
struct hv_netvsc_packet,
ListEntry);

INSERT_TAIL_LIST(&listHead, &netvscPacket->ListEntry);

while (!list_empty(&netDevice->ReceivePacketList)) {
list_move_tail(&netDevice->ReceivePacketList, &listHead);
if (++count == vmxferpagePacket->RangeCount + 1)
break;
}
Expand All @@ -1087,13 +1071,8 @@ static void NetVscOnReceive(struct hv_device *Device,
/* Return it to the freelist */
spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
for (i = count; i != 0; i--) {
entry = REMOVE_HEAD_LIST(&listHead);
netvscPacket = CONTAINING_RECORD(entry,
struct hv_netvsc_packet,
ListEntry);

INSERT_TAIL_LIST(&netDevice->ReceivePacketList,
&netvscPacket->ListEntry);
list_move_tail(&listHead,
&netDevice->ReceivePacketList);
}
spin_unlock_irqrestore(&netDevice->receive_packet_list_lock,
flags);
Expand All @@ -1106,9 +1085,10 @@ static void NetVscOnReceive(struct hv_device *Device,
}

/* Remove the 1st packet to represent the xfer page packet itself */
entry = REMOVE_HEAD_LIST(&listHead);
xferpagePacket = CONTAINING_RECORD(entry, struct xferpage_packet,
ListEntry);
xferpagePacket = list_entry(&listHead, struct xferpage_packet,
ListEntry);
list_del(&xferpagePacket->ListEntry);

/* This is how much we can satisfy */
xferpagePacket->Count = count - 1;
ASSERT(xferpagePacket->Count > 0 && xferpagePacket->Count <=
Expand All @@ -1122,10 +1102,9 @@ static void NetVscOnReceive(struct hv_device *Device,

/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
for (i = 0; i < (count - 1); i++) {
entry = REMOVE_HEAD_LIST(&listHead);
netvscPacket = CONTAINING_RECORD(entry,
struct hv_netvsc_packet,
ListEntry);
netvscPacket = list_entry(&listHead, struct hv_netvsc_packet,
ListEntry);
list_del(&netvscPacket->ListEntry);

/* Initialize the netvsc packet */
netvscPacket->XferPagePacket = xferpagePacket;
Expand Down Expand Up @@ -1198,7 +1177,7 @@ static void NetVscOnReceive(struct hv_device *Device,
NetVscOnReceiveCompletion(netvscPacket->Completion.Recv.ReceiveCompletionContext);
}

ASSERT(IsListEmpty(&listHead));
ASSERT(list_empty(&listHead));

PutNetDevice(Device);
DPRINT_EXIT(NETVSC);
Expand Down Expand Up @@ -1290,13 +1269,13 @@ static void NetVscOnReceiveCompletion(void *Context)
if (packet->XferPagePacket->Count == 0) {
fSendReceiveComp = true;
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 */
INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &packet->ListEntry);
list_add_tail(&packet->ListEntry, &netDevice->ReceivePacketList);
spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags);

/* Send a receive completion for the xfer page packet */
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/staging/hv/NetVsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#ifndef _NETVSC_H_
#define _NETVSC_H_

#include <linux/list.h>
#include "VmbusPacketFormat.h"
#include "VmbusChannelInterface.h"
#include "List.h"
#include "NetVscApi.h"


Expand Down Expand Up @@ -299,7 +299,7 @@ struct netvsc_device {
* List of free preallocated hv_netvsc_packet to represent receive
* packet
*/
LIST_ENTRY ReceivePacketList;
struct list_head ReceivePacketList;
spinlock_t receive_packet_list_lock;

/* Send buffer allocated by us but manages by NetVSP */
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/staging/hv/NetVscApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct hv_netvsc_packet;

/* Represent the xfer page packet which contains 1 or more netvsc packet */
struct xferpage_packet {
LIST_ENTRY ListEntry;
struct list_head ListEntry;

/* # of netvsc packets this xfer packet contains */
u32 Count;
Expand All @@ -52,7 +52,7 @@ struct xferpage_packet {
*/
struct hv_netvsc_packet {
/* Bookkeeping stuff */
LIST_ENTRY ListEntry;
struct list_head ListEntry;

struct hv_device *Device;
bool IsDataPacket;
Expand Down

0 comments on commit 96dc104

Please sign in to comment.