datapath-windows: Implement event read handler.
[cascardo/ovs.git] / datapath-windows / include / OvsDpInterfaceExt.h
1 /*
2  * Copyright (c) 2014 VMware, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __OVS_DP_INTERFACE_EXT_H_
18 #define __OVS_DP_INTERFACE_EXT_H_ 1
19
20 /* Windows kernel datapath extensions to the standard datapath interface. */
21
22 /* Version number of the datapath interface extensions. */
23 #define OVS_DATAPATH_EXT_VERSION 1
24
25 /* Name of the device. */
26 #define OVS_DEVICE_NAME_NT     L"\\Device\\OpenvSwitchDevice"
27 #define OVS_DEVICE_NAME_DOS    L"\\DosDevices\\OpenvSwitchDevice"
28 #define OVS_DEVICE_NAME_USER   TEXT("\\\\.\\OpenvSwitchDevice")
29
30 #define OVS_IOCTL_DEVICE_TYPE 45000
31
32 /* We used Direct I/O (zero copy) for the buffers. */
33 #define OVS_IOCTL_START   0x100
34 #define OVS_IOCTL_READ \
35     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x0, METHOD_OUT_DIRECT,\
36               FILE_READ_ACCESS)
37 #define OVS_IOCTL_READ_EVENT \
38     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x1, METHOD_OUT_DIRECT, \
39               FILE_READ_ACCESS)
40 #define OVS_IOCTL_READ_PACKET \
41     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x2, METHOD_OUT_DIRECT, \
42               FILE_READ_ACCESS)
43 #define OVS_IOCTL_WRITE \
44     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x3, METHOD_IN_DIRECT,\
45               FILE_READ_ACCESS)
46 #define OVS_IOCTL_TRANSACT \
47     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x4, METHOD_OUT_DIRECT,\
48               FILE_WRITE_ACCESS)
49
50 /*
51  * On platforms that support netlink natively, the operating system assigns a
52  * dynamic value to a netlink family when it is registered. In the absense of
53  * such mechanism, defined hard-coded values that are known both to userspace
54  * and kernel.
55  */
56 #define OVS_WIN_NL_INVALID_FAMILY_ID         0
57 #define OVS_WIN_NL_CTRL_FAMILY_ID            (NLMSG_MIN_TYPE + 1)
58 #define OVS_WIN_NL_DATAPATH_FAMILY_ID        (NLMSG_MIN_TYPE + 2)
59 #define OVS_WIN_NL_PACKET_FAMILY_ID          (NLMSG_MIN_TYPE + 3)
60 #define OVS_WIN_NL_VPORT_FAMILY_ID           (NLMSG_MIN_TYPE + 4)
61 #define OVS_WIN_NL_FLOW_FAMILY_ID            (NLMSG_MIN_TYPE + 5)
62
63 #define OVS_WIN_NL_INVALID_MCGRP_ID          0
64 #define OVS_WIN_NL_MCGRP_START_ID            100
65 #define OVS_WIN_NL_VPORT_MCGRP_ID            (OVS_WIN_NL_MCGRP_START_ID + 1)
66
67 /*
68  * Define a family of netlink command specific to Windows. This is part of the
69  * extensions.
70  */
71 #define OVS_WIN_CONTROL_FAMILY   "ovs_win_control"
72 #define OVS_WIN_CONTROL_MCGROUP  "ovs_win_control"
73 #define OVS_WIN_CONTROL_VERSION  1
74 #define OVS_WIN_CONTROL_ATTR_MAX (__OVS_FLOW_ATTR_MAX - 1)
75
76 /* Commands available under the OVS_WIN_CONTROL_FAMILY. */
77 enum ovs_win_control_cmd {
78     OVS_CTRL_CMD_WIN_GET_PID,
79     OVS_CTRL_CMD_WIN_PEND_REQ,
80     OVS_CTRL_CMD_MC_SUBSCRIBE_REQ,
81
82     /* This command is logically belong to the Vport family */
83     OVS_CTRL_CMD_EVENT_NOTIFY
84 };
85
86 /* NL Attributes for joining/unjoining an MC group */
87 enum ovs_nl_mcast_attr {
88     OVS_NL_ATTR_MCAST_GRP,   /* (UINT32) Join an MC group */
89     OVS_NL_ATTR_MCAST_JOIN,  /* (UINT8) 1/0 - Join/Unjoin */
90 };
91
92 typedef struct ovs_dp_stats OVS_DP_STATS;
93 typedef enum ovs_vport_type OVS_VPORT_TYPE;
94
95 #endif /* __OVS_DP_INTERFACE_EXT_H_ */