Staging: hv: fix up typedefs in NetVscApi.h
[sfrench/cifs-2.6.git] / drivers / staging / hv / include / 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 /* Data types */
39 typedef int (*PFN_ON_OPEN)(struct hv_device *Device);
40 typedef int (*PFN_ON_CLOSE)(struct hv_device *Device);
41
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);
46
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);
50
51 /* Represent the xfer page packet which contains 1 or more netvsc packet */
52 struct xferpage_packet {
53         LIST_ENTRY ListEntry;
54
55         /* # of netvsc packets this xfer packet contains */
56         u32 Count;
57 };
58
59 /* The number of pages which are enough to cover jumbo frame buffer. */
60 #define NETVSC_PACKET_MAXPAGE           4
61
62 /*
63  * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
64  * within the RNDIS
65  */
66 struct hv_netvsc_packet {
67         /* Bookkeeping stuff */
68         LIST_ENTRY ListEntry;
69
70         struct hv_device *Device;
71         bool IsDataPacket;
72
73         /*
74          * Valid only for receives when we break a xfer page packet
75          * into multiple netvsc packets
76          */
77         struct xferpage_packet *XferPagePacket;
78
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;
91
92         /* This points to the memory after PageBuffers */
93         void *Extension;
94
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];
99 };
100
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;
106
107         u32 RingBufferSize;
108         u32 RequestExtSize;
109
110         /* Additional num  of page buffers to allocate */
111         u32 AdditionalRequestPageBufferCount;
112
113         /*
114          * This is set by the caller to allow us to callback when we
115          * receive a packet from the "wire"
116          */
117         PFN_ON_RECVCALLBACK OnReceiveCallback;
118
119         PFN_ON_LINKSTATUS_CHANGED OnLinkStatusChanged;
120
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; */
126
127         /* PFN_QUERY_LINKSTATUS QueryLinkStatus; */
128
129         void *Context;
130 };
131
132 struct netvsc_device_info {
133     unsigned char MacAddr[6];
134     bool LinkState;     /* 0 - link up, 1 - link down */
135 };
136
137 /* Interface */
138 int NetVscInitialize(struct hv_driver *drv);
139
140 #endif /* _NETVSC_API_H_ */