3 * Copyright (c) 2009, Microsoft Corporation.
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.
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
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.
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
25 #ifndef _NETVSC_API_H_
26 #define _NETVSC_API_H_
32 #define NETVSC_DEVICE_RING_BUFFER_SIZE (64*PAGE_SIZE)
33 #define HW_MACADDR_LEN 6
36 struct hv_netvsc_packet
;
39 typedef int (*PFN_ON_OPEN
)(struct hv_device
*Device
);
40 typedef int (*PFN_ON_CLOSE
)(struct hv_device
*Device
);
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
);
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
);
51 /* Represent the xfer page packet which contains 1 or more netvsc packet */
52 struct xferpage_packet
{
55 /* # of netvsc packets this xfer packet contains */
59 /* The number of pages which are enough to cover jumbo frame buffer. */
60 #define NETVSC_PACKET_MAXPAGE 4
63 * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
66 struct hv_netvsc_packet
{
67 /* Bookkeeping stuff */
70 struct hv_device
*Device
;
74 * Valid only for receives when we break a xfer page packet
75 * into multiple netvsc packets
77 struct xferpage_packet
*XferPagePacket
;
81 u64 ReceiveCompletionTid
;
82 void *ReceiveCompletionContext
;
83 PFN_ON_SENDRECVCOMPLETION OnReceiveCompletion
;
86 u64 SendCompletionTid
;
87 void *SendCompletionContext
;
88 PFN_ON_SENDRECVCOMPLETION OnSendCompletion
;
92 /* This points to the memory after PageBuffers */
95 u32 TotalDataBufferLength
;
96 /* Points to the send/receive buffer where the ethernet frame is */
98 struct hv_page_buffer PageBuffers
[NETVSC_PACKET_MAXPAGE
];
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
;
110 /* Additional num of page buffers to allocate */
111 u32 AdditionalRequestPageBufferCount
;
114 * This is set by the caller to allow us to callback when we
115 * receive a packet from the "wire"
117 PFN_ON_RECVCALLBACK OnReceiveCallback
;
119 PFN_ON_LINKSTATUS_CHANGED OnLinkStatusChanged
;
121 /* Specific to this driver */
123 PFN_ON_CLOSE OnClose
;
125 /* PFN_ON_RECVCOMPLETION OnReceiveCompletion; */
127 /* PFN_QUERY_LINKSTATUS QueryLinkStatus; */
132 struct netvsc_device_info
{
133 unsigned char MacAddr
[6];
134 bool LinkState
; /* 0 - link up, 1 - link down */
138 int NetVscInitialize(struct hv_driver
*drv
);
140 #endif /* _NETVSC_API_H_ */