Staging: hv: remove function pointer typedefs from vmbus.h
[safe/jmp/linux-2.6] / drivers / staging / hv / NetVscApi.h
1 /*
2  *
3  * Copyright (c) 2009, Microsoft Corporation.
4  *
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.
8  *
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.
13  *
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.
17  *
18  * Authors:
19  *   Haiyang Zhang <haiyangz@microsoft.com>
20  *   Hank Janssen  <hjanssen@microsoft.com>
21  *
22  */
23
24
25 #ifndef _NETVSC_API_H_
26 #define _NETVSC_API_H_
27
28 #include "VmbusApi.h"
29 #include "List.h"
30
31 /* Defines */
32 #define NETVSC_DEVICE_RING_BUFFER_SIZE  (64*PAGE_SIZE)
33 #define HW_MACADDR_LEN                  6
34
35 /* Fwd declaration */
36 struct hv_netvsc_packet;
37
38 /* Represent the xfer page packet which contains 1 or more netvsc packet */
39 struct xferpage_packet {
40         LIST_ENTRY ListEntry;
41
42         /* # of netvsc packets this xfer packet contains */
43         u32 Count;
44 };
45
46 /* The number of pages which are enough to cover jumbo frame buffer. */
47 #define NETVSC_PACKET_MAXPAGE           4
48
49 /*
50  * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
51  * within the RNDIS
52  */
53 struct hv_netvsc_packet {
54         /* Bookkeeping stuff */
55         LIST_ENTRY ListEntry;
56
57         struct hv_device *Device;
58         bool IsDataPacket;
59
60         /*
61          * Valid only for receives when we break a xfer page packet
62          * into multiple netvsc packets
63          */
64         struct xferpage_packet *XferPagePacket;
65
66         union {
67                 struct{
68                         u64 ReceiveCompletionTid;
69                         void *ReceiveCompletionContext;
70                         void (*OnReceiveCompletion)(void *context);
71                 } Recv;
72                 struct{
73                         u64 SendCompletionTid;
74                         void *SendCompletionContext;
75                         void (*OnSendCompletion)(void *context);
76                 } Send;
77         } Completion;
78
79         /* This points to the memory after PageBuffers */
80         void *Extension;
81
82         u32 TotalDataBufferLength;
83         /* Points to the send/receive buffer where the ethernet frame is */
84         u32 PageBufferCount;
85         struct hv_page_buffer PageBuffers[NETVSC_PACKET_MAXPAGE];
86 };
87
88 /* Represents the net vsc driver */
89 struct netvsc_driver {
90         /* Must be the first field */
91         /* Which is a bug FIXME! */
92         struct hv_driver Base;
93
94         u32 RingBufferSize;
95         u32 RequestExtSize;
96
97         /* Additional num  of page buffers to allocate */
98         u32 AdditionalRequestPageBufferCount;
99
100         /*
101          * This is set by the caller to allow us to callback when we
102          * receive a packet from the "wire"
103          */
104         int (*OnReceiveCallback)(struct hv_device *dev,
105                                  struct hv_netvsc_packet *packet);
106         void (*OnLinkStatusChanged)(struct hv_device *dev, u32 Status);
107
108         /* Specific to this driver */
109         int (*OnOpen)(struct hv_device *dev);
110         int (*OnClose)(struct hv_device *dev);
111         int (*OnSend)(struct hv_device *dev, struct hv_netvsc_packet *packet);
112
113         void *Context;
114 };
115
116 struct netvsc_device_info {
117     unsigned char MacAddr[6];
118     bool LinkState;     /* 0 - link up, 1 - link down */
119 };
120
121 /* Interface */
122 int NetVscInitialize(struct hv_driver *drv);
123
124 #endif /* _NETVSC_API_H_ */