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