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;
38 /* Represent the xfer page packet which contains 1 or more netvsc packet */
39 struct xferpage_packet {
42 /* # of netvsc packets this xfer packet contains */
46 /* The number of pages which are enough to cover jumbo frame buffer. */
47 #define NETVSC_PACKET_MAXPAGE 4
50 * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
53 struct hv_netvsc_packet {
54 /* Bookkeeping stuff */
57 struct hv_device *Device;
61 * Valid only for receives when we break a xfer page packet
62 * into multiple netvsc packets
64 struct xferpage_packet *XferPagePacket;
68 u64 ReceiveCompletionTid;
69 void *ReceiveCompletionContext;
70 void (*OnReceiveCompletion)(void *context);
73 u64 SendCompletionTid;
74 void *SendCompletionContext;
75 void (*OnSendCompletion)(void *context);
79 /* This points to the memory after PageBuffers */
82 u32 TotalDataBufferLength;
83 /* Points to the send/receive buffer where the ethernet frame is */
85 struct hv_page_buffer PageBuffers[NETVSC_PACKET_MAXPAGE];
88 /* Represents the net vsc driver */
89 struct netvsc_driver {
90 /* Must be the first field */
91 /* Which is a bug FIXME! */
92 struct hv_driver Base;
97 /* Additional num of page buffers to allocate */
98 u32 AdditionalRequestPageBufferCount;
101 * This is set by the caller to allow us to callback when we
102 * receive a packet from the "wire"
104 int (*OnReceiveCallback)(struct hv_device *dev,
105 struct hv_netvsc_packet *packet);
106 void (*OnLinkStatusChanged)(struct hv_device *dev, u32 Status);
108 /* Specific to this driver */
109 int (*OnOpen)(struct hv_device *dev);
110 int (*OnClose)(struct hv_device *dev);
111 int (*OnSend)(struct hv_device *dev, struct hv_netvsc_packet *packet);
116 struct netvsc_device_info {
117 unsigned char MacAddr[6];
118 bool LinkState; /* 0 - link up, 1 - link down */
122 int NetVscInitialize(struct hv_driver *drv);
124 #endif /* _NETVSC_API_H_ */