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_
31 #define NETVSC_DEVICE_RING_BUFFER_SIZE (64*PAGE_SIZE)
32 #define HW_MACADDR_LEN 6
35 struct hv_netvsc_packet
;
37 /* Represent the xfer page packet which contains 1 or more netvsc packet */
38 struct xferpage_packet
{
39 struct list_head ListEntry
;
41 /* # of netvsc packets this xfer packet contains */
45 /* The number of pages which are enough to cover jumbo frame buffer. */
46 #define NETVSC_PACKET_MAXPAGE 4
49 * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
52 struct hv_netvsc_packet
{
53 /* Bookkeeping stuff */
54 struct list_head ListEntry
;
56 struct hv_device
*Device
;
60 * Valid only for receives when we break a xfer page packet
61 * into multiple netvsc packets
63 struct xferpage_packet
*XferPagePacket
;
67 u64 ReceiveCompletionTid
;
68 void *ReceiveCompletionContext
;
69 void (*OnReceiveCompletion
)(void *context
);
72 u64 SendCompletionTid
;
73 void *SendCompletionContext
;
74 void (*OnSendCompletion
)(void *context
);
78 /* This points to the memory after PageBuffers */
81 u32 TotalDataBufferLength
;
82 /* Points to the send/receive buffer where the ethernet frame is */
84 struct hv_page_buffer PageBuffers
[NETVSC_PACKET_MAXPAGE
];
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
;
96 /* Additional num of page buffers to allocate */
97 u32 AdditionalRequestPageBufferCount
;
100 * This is set by the caller to allow us to callback when we
101 * receive a packet from the "wire"
103 int (*OnReceiveCallback
)(struct hv_device
*dev
,
104 struct hv_netvsc_packet
*packet
);
105 void (*OnLinkStatusChanged
)(struct hv_device
*dev
, u32 Status
);
107 /* Specific to this driver */
108 int (*OnOpen
)(struct hv_device
*dev
);
109 int (*OnClose
)(struct hv_device
*dev
);
110 int (*OnSend
)(struct hv_device
*dev
, struct hv_netvsc_packet
*packet
);
115 struct netvsc_device_info
{
116 unsigned char MacAddr
[6];
117 bool LinkState
; /* 0 - link up, 1 - link down */
121 int NetVscInitialize(struct hv_driver
*drv
);
123 #endif /* _NETVSC_API_H_ */