summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/User.h
blob: ca27827d6af7aac9fec080544ae89a3fdb36ea29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
 /*
 * Copyright (c) 2014 VMware, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* This file contains structures and function definitions necessary for
 * forwarding packet to user space.
 */

#ifndef __USER_H_
#define __USER_H_ 1


#include "Datapath.h"

/*
 * Even we have more cores, I don't think we need
 * more than 32 queues for processing packets to
 * userspace
 */
#define OVS_DEFAULT_PACKET_QUEUE 1
#define OVS_MAX_PACKET_QUEUE_LEN  4096

/*
 * Only when OVS_PER_VPORT_QUEUE_CTRL is defined
 * we will apply this constraint
 */
#define OVS_MAX_PACKETS_PER_VPORT 128
#define OVS_MAX_PACKETS_PER_TUNNEL 1024

typedef struct _OVS_USER_PACKET_QUEUE {
    UINT32 pid;
    UINT32 numPackets;
    LIST_ENTRY  packetList;
    PVOID instance;
    PIRP pendingIrp;
    NDIS_SPIN_LOCK queueLock;
} OVS_USER_PACKET_QUEUE, *POVS_USER_PACKET_QUEUE;

typedef struct _OVS_PACKET_QUEUE_ELEM {
    UINT32  upcallPid;
    LIST_ENTRY link;
    OVS_PACKET_HDR_INFO hdrInfo;
    OVS_PACKET_INFO packet;
} OVS_PACKET_QUEUE_ELEM, *POVS_PACKET_QUEUE_ELEM;

struct _OVS_OPEN_INSTANCE;

typedef struct _OVS_USER_STATS {
    UINT64 miss;
    UINT64 action;
    UINT32 dropDuetoResource;
    UINT32 dropDuetoChecksum;
    UINT32 ipCsum;
    UINT32 recalTcpCsum;
    UINT32 vlanInsert;
    UINT32 l4Csum;
} OVS_USER_STATS, *POVS_USER_STATS;

VOID OvsCleanupPacketQueue(struct _OVS_OPEN_INSTANCE *instance);

POVS_PACKET_QUEUE_ELEM OvsCreateQueueNlPacket(PVOID userData,
                                              UINT32 userDataLen,
                                              UINT32 cmd, 
                                              POVS_VPORT_ENTRY vport,
                                              OvsFlowKey *key,
                                              OvsIPTunnelKey *tunnelKey,
                                              PNET_BUFFER_LIST nbl,
                                              PNET_BUFFER nb,
                                              BOOLEAN isRecv,
                                              POVS_PACKET_HDR_INFO hdrInfo);

VOID OvsQueuePackets(PLIST_ENTRY packetList, UINT32 numElems);
NTSTATUS OvsCreateAndAddPackets(PVOID userData,
                                UINT32 userDataLen,
                                UINT32 cmd,
                                POVS_VPORT_ENTRY vport,
                                OvsFlowKey *key,
                                PNET_BUFFER_LIST nbl,
                                BOOLEAN isRecv,
                                POVS_PACKET_HDR_INFO hdrInfo,
                                POVS_SWITCH_CONTEXT switchContext,
                                LIST_ENTRY *list,
                                UINT32 *num);

NTSTATUS OvsSubscribeDpIoctl(PVOID instanceP,
                             UINT32 pid,
                             UINT8 join);

NTSTATUS OvsReadDpIoctl(PFILE_OBJECT fileObject,
                        PVOID outputBuffer,
                        UINT32 outputLength,
                        UINT32 *replyLen);
NTSTATUS OvsExecuteDpIoctl(OvsPacketExecute *execute);
NTSTATUS OvsPurgeDpIoctl(PFILE_OBJECT fileObject);

NTSTATUS OvsWaitDpIoctl(PIRP irp, PFILE_OBJECT fileObject);

NTSTATUS OvsNlExecuteCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
                                UINT32 *replyLen);

POVS_OPEN_INSTANCE
OvsGetPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid);

VOID
OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid,
                  POVS_OPEN_INSTANCE instance);

VOID
OvsDelPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid);

NTSTATUS OvsReadPacketCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
                                 UINT32 *replyLen);
NTSTATUS OvsSubscribePacketCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
                                      UINT32 *replyLen);
NTSTATUS OvsPendPacketCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
                                 UINT32 *replyLen);

#endif /* __USER_H_ */