Staging: hv: coding style cleanups of BlkVsc.c
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / hv / NetVscApi.h
blobc53e4170e94ec0e1d3451c95f4d715761ce28c6e
1 /*
3 * Copyright (c) 2009, Microsoft Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
25 #ifndef _NETVSC_API_H_
26 #define _NETVSC_API_H_
28 #include "VmbusApi.h"
29 #include "List.h"
31 /* Defines */
32 #define NETVSC_DEVICE_RING_BUFFER_SIZE (64*PAGE_SIZE)
33 #define HW_MACADDR_LEN 6
35 /* Fwd declaration */
36 struct hv_netvsc_packet;
38 /* Data types */
39 typedef int (*PFN_ON_OPEN)(struct hv_device *Device);
40 typedef int (*PFN_ON_CLOSE)(struct hv_device *Device);
42 typedef void (*PFN_QUERY_LINKSTATUS)(struct hv_device *Device);
43 typedef int (*PFN_ON_SEND)(struct hv_device *dev,
44 struct hv_netvsc_packet *packet);
45 typedef void (*PFN_ON_SENDRECVCOMPLETION)(void *Context);
47 typedef int (*PFN_ON_RECVCALLBACK)(struct hv_device *dev,
48 struct hv_netvsc_packet *packet);
49 typedef void (*PFN_ON_LINKSTATUS_CHANGED)(struct hv_device *dev, u32 Status);
51 /* Represent the xfer page packet which contains 1 or more netvsc packet */
52 struct xferpage_packet {
53 LIST_ENTRY ListEntry;
55 /* # of netvsc packets this xfer packet contains */
56 u32 Count;
59 /* The number of pages which are enough to cover jumbo frame buffer. */
60 #define NETVSC_PACKET_MAXPAGE 4
63 * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
64 * within the RNDIS
66 struct hv_netvsc_packet {
67 /* Bookkeeping stuff */
68 LIST_ENTRY ListEntry;
70 struct hv_device *Device;
71 bool IsDataPacket;
74 * Valid only for receives when we break a xfer page packet
75 * into multiple netvsc packets
77 struct xferpage_packet *XferPagePacket;
79 union {
80 struct{
81 u64 ReceiveCompletionTid;
82 void *ReceiveCompletionContext;
83 PFN_ON_SENDRECVCOMPLETION OnReceiveCompletion;
84 } Recv;
85 struct{
86 u64 SendCompletionTid;
87 void *SendCompletionContext;
88 PFN_ON_SENDRECVCOMPLETION OnSendCompletion;
89 } Send;
90 } Completion;
92 /* This points to the memory after PageBuffers */
93 void *Extension;
95 u32 TotalDataBufferLength;
96 /* Points to the send/receive buffer where the ethernet frame is */
97 u32 PageBufferCount;
98 struct hv_page_buffer PageBuffers[NETVSC_PACKET_MAXPAGE];
101 /* Represents the net vsc driver */
102 struct netvsc_driver {
103 /* Must be the first field */
104 /* Which is a bug FIXME! */
105 struct hv_driver Base;
107 u32 RingBufferSize;
108 u32 RequestExtSize;
110 /* Additional num of page buffers to allocate */
111 u32 AdditionalRequestPageBufferCount;
114 * This is set by the caller to allow us to callback when we
115 * receive a packet from the "wire"
117 PFN_ON_RECVCALLBACK OnReceiveCallback;
119 PFN_ON_LINKSTATUS_CHANGED OnLinkStatusChanged;
121 /* Specific to this driver */
122 PFN_ON_OPEN OnOpen;
123 PFN_ON_CLOSE OnClose;
124 PFN_ON_SEND OnSend;
125 /* PFN_ON_RECVCOMPLETION OnReceiveCompletion; */
127 /* PFN_QUERY_LINKSTATUS QueryLinkStatus; */
129 void *Context;
132 struct netvsc_device_info {
133 unsigned char MacAddr[6];
134 bool LinkState; /* 0 - link up, 1 - link down */
137 /* Interface */
138 int NetVscInitialize(struct hv_driver *drv);
140 #endif /* _NETVSC_API_H_ */