9p: Optimize TCREATE by eliminating a redundant fid clone.
[pandora-kernel.git] / 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
30 /* Defines */
31 #define NETVSC_DEVICE_RING_BUFFER_SIZE  (64*PAGE_SIZE)
32 #define HW_MACADDR_LEN                  6
33
34 /* Fwd declaration */
35 struct hv_netvsc_packet;
36
37 /* Represent the xfer page packet which contains 1 or more netvsc packet */
38 struct xferpage_packet {
39         struct list_head ListEntry;
40
41         /* # of netvsc packets this xfer packet contains */
42         u32 Count;
43 };
44
45 /* The number of pages which are enough to cover jumbo frame buffer. */
46 #define NETVSC_PACKET_MAXPAGE           4
47
48 /*
49  * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
50  * within the RNDIS
51  */
52 struct hv_netvsc_packet {
53         /* Bookkeeping stuff */
54         struct list_head ListEntry;
55
56         struct hv_device *Device;
57         bool IsDataPacket;
58
59         /*
60          * Valid only for receives when we break a xfer page packet
61          * into multiple netvsc packets
62          */
63         struct xferpage_packet *XferPagePacket;
64
65         union {
66                 struct{
67                         u64 ReceiveCompletionTid;
68                         void *ReceiveCompletionContext;
69                         void (*OnReceiveCompletion)(void *context);
70                 } Recv;
71                 struct{
72                         u64 SendCompletionTid;
73                         void *SendCompletionContext;
74                         void (*OnSendCompletion)(void *context);
75                 } Send;
76         } Completion;
77
78         /* This points to the memory after PageBuffers */
79         void *Extension;
80
81         u32 TotalDataBufferLength;
82         /* Points to the send/receive buffer where the ethernet frame is */
83         u32 PageBufferCount;
84         struct hv_page_buffer PageBuffers[NETVSC_PACKET_MAXPAGE];
85 };
86
87 /* Represents the net vsc driver */
88 struct netvsc_driver {
89         /* Must be the first field */
90         /* Which is a bug FIXME! */
91         struct hv_driver Base;
92
93         u32 RingBufferSize;
94         u32 RequestExtSize;
95
96         /* Additional num  of page buffers to allocate */
97         u32 AdditionalRequestPageBufferCount;
98
99         /*
100          * This is set by the caller to allow us to callback when we
101          * receive a packet from the "wire"
102          */
103         int (*OnReceiveCallback)(struct hv_device *dev,
104                                  struct hv_netvsc_packet *packet);
105         void (*OnLinkStatusChanged)(struct hv_device *dev, u32 Status);
106
107         /* Specific to this driver */
108         int (*OnSend)(struct hv_device *dev, struct hv_netvsc_packet *packet);
109
110         void *Context;
111 };
112
113 struct netvsc_device_info {
114     unsigned char MacAddr[6];
115     bool LinkState;     /* 0 - link up, 1 - link down */
116 };
117
118 /* Interface */
119 int NetVscInitialize(struct hv_driver *drv);
120 int RndisFilterOnOpen(struct hv_device *Device);
121 int RndisFilterOnClose(struct hv_device *Device);
122
123 #endif /* _NETVSC_API_H_ */