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