Commit | Line | Data |
---|---|---|
ab057781 HJ |
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 | ||
454f18a9 BP |
30 | |
31 | /* Defines */ | |
32 | ||
ab057781 HJ |
33 | #define NETVSC_DEVICE_RING_BUFFER_SIZE 64*PAGE_SIZE |
34 | ||
35 | #define HW_MACADDR_LEN 6 | |
36 | ||
454f18a9 BP |
37 | |
38 | /* Fwd declaration */ | |
39 | ||
ab057781 HJ |
40 | typedef struct _NETVSC_PACKET *PNETVSC_PACKET; |
41 | ||
42 | ||
454f18a9 BP |
43 | |
44 | /* Data types */ | |
45 | ||
ab057781 | 46 | |
3d3b5518 NP |
47 | typedef int (*PFN_ON_OPEN)(struct hv_device *Device); |
48 | typedef int (*PFN_ON_CLOSE)(struct hv_device *Device); | |
ab057781 | 49 | |
3d3b5518 NP |
50 | typedef void (*PFN_QUERY_LINKSTATUS)(struct hv_device *Device); |
51 | typedef int (*PFN_ON_SEND)(struct hv_device *dev, PNETVSC_PACKET packet); | |
8282c400 | 52 | typedef void (*PFN_ON_SENDRECVCOMPLETION)(void * Context); |
ab057781 | 53 | |
3d3b5518 NP |
54 | typedef int (*PFN_ON_RECVCALLBACK)(struct hv_device *dev, PNETVSC_PACKET packet); |
55 | typedef void (*PFN_ON_LINKSTATUS_CHANGED)(struct hv_device *dev, u32 Status); | |
ab057781 | 56 | |
454f18a9 | 57 | /* Represent the xfer page packet which contains 1 or more netvsc packet */ |
ab057781 HJ |
58 | typedef struct _XFERPAGE_PACKET { |
59 | DLIST_ENTRY ListEntry; | |
60 | ||
454f18a9 | 61 | /* # of netvsc packets this xfer packet contains */ |
4d643114 | 62 | u32 Count; |
ab057781 HJ |
63 | } XFERPAGE_PACKET; |
64 | ||
65 | ||
454f18a9 | 66 | /* The number of pages which are enough to cover jumbo frame buffer. */ |
ab057781 HJ |
67 | #define NETVSC_PACKET_MAXPAGE 4 |
68 | ||
454f18a9 BP |
69 | /* |
70 | * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame | |
71 | * within the RNDIS | |
72 | */ | |
ab057781 | 73 | typedef struct _NETVSC_PACKET { |
454f18a9 | 74 | /* Bookkeeping stuff */ |
ab057781 HJ |
75 | DLIST_ENTRY ListEntry; |
76 | ||
3d3b5518 | 77 | struct hv_device *Device; |
27274e5d | 78 | bool IsDataPacket; |
ab057781 | 79 | |
454f18a9 BP |
80 | /* |
81 | * Valid only for receives when we break a xfer page packet | |
82 | * into multiple netvsc packets | |
83 | */ | |
ab057781 HJ |
84 | XFERPAGE_PACKET *XferPagePacket; |
85 | ||
86 | union { | |
87 | struct{ | |
59471438 | 88 | u64 ReceiveCompletionTid; |
8282c400 | 89 | void * ReceiveCompletionContext; |
ab057781 HJ |
90 | PFN_ON_SENDRECVCOMPLETION OnReceiveCompletion; |
91 | } Recv; | |
92 | struct{ | |
59471438 | 93 | u64 SendCompletionTid; |
8282c400 | 94 | void * SendCompletionContext; |
ab057781 HJ |
95 | PFN_ON_SENDRECVCOMPLETION OnSendCompletion; |
96 | } Send; | |
97 | } Completion; | |
98 | ||
454f18a9 | 99 | /* This points to the memory after PageBuffers */ |
8282c400 | 100 | void * Extension; |
ab057781 | 101 | |
4d643114 | 102 | u32 TotalDataBufferLength; |
454f18a9 | 103 | /* Points to the send/receive buffer where the ethernet frame is */ |
4d643114 | 104 | u32 PageBufferCount; |
ab057781 HJ |
105 | PAGE_BUFFER PageBuffers[NETVSC_PACKET_MAXPAGE]; |
106 | ||
107 | } NETVSC_PACKET; | |
108 | ||
109 | ||
454f18a9 | 110 | /* Represents the net vsc driver */ |
ab057781 | 111 | typedef struct _NETVSC_DRIVER_OBJECT { |
775ef25e | 112 | struct hv_driver Base; /* Must be the first field */ |
ab057781 | 113 | |
4d643114 GKH |
114 | u32 RingBufferSize; |
115 | u32 RequestExtSize; | |
ab057781 | 116 | |
454f18a9 | 117 | /* Additional num of page buffers to allocate */ |
4d643114 | 118 | u32 AdditionalRequestPageBufferCount; |
ab057781 | 119 | |
454f18a9 BP |
120 | /* |
121 | * This is set by the caller to allow us to callback when we | |
122 | * receive a packet from the "wire" | |
123 | */ | |
ab057781 HJ |
124 | PFN_ON_RECVCALLBACK OnReceiveCallback; |
125 | ||
126 | PFN_ON_LINKSTATUS_CHANGED OnLinkStatusChanged; | |
127 | ||
454f18a9 | 128 | /* Specific to this driver */ |
ab057781 HJ |
129 | PFN_ON_OPEN OnOpen; |
130 | PFN_ON_CLOSE OnClose; | |
131 | PFN_ON_SEND OnSend; | |
454f18a9 | 132 | /* PFN_ON_RECVCOMPLETION OnReceiveCompletion; */ |
ab057781 | 133 | |
454f18a9 | 134 | /* PFN_QUERY_LINKSTATUS QueryLinkStatus; */ |
ab057781 HJ |
135 | |
136 | void* Context; | |
137 | } NETVSC_DRIVER_OBJECT; | |
138 | ||
139 | ||
140 | typedef struct _NETVSC_DEVICE_INFO { | |
59471438 | 141 | unsigned char MacAddr[6]; |
454f18a9 | 142 | bool LinkState; /* 0 - link up, 1 - link down */ |
ab057781 HJ |
143 | } NETVSC_DEVICE_INFO; |
144 | ||
454f18a9 BP |
145 | |
146 | /* Interface */ | |
147 | ||
ab057781 HJ |
148 | int |
149 | NetVscInitialize( | |
775ef25e | 150 | struct hv_driver *drv |
ab057781 HJ |
151 | ); |
152 | ||
454f18a9 | 153 | #endif /* _NETVSC_API_H_ */ |