fedora: include ovs-save file in the rpm package
[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 #define OVS_IOCTL_START   0x100
33 /* We used Direct I/O (zero copy) for the buffers. */
34 /* Non-Netlink-based IOCTLs. */
35 #define OVS_IOCTL_GET_PID \
36     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x0, METHOD_BUFFERED,\
37               FILE_WRITE_ACCESS)
38 /* Netlink-based IOCTLs. */
39 #define OVS_IOCTL_READ \
40     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x1, METHOD_OUT_DIRECT,\
41               FILE_READ_ACCESS)
42 #define OVS_IOCTL_READ_EVENT \
43     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x2, METHOD_OUT_DIRECT, \
44               FILE_READ_ACCESS)
45 #define OVS_IOCTL_READ_PACKET \
46     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x3, METHOD_OUT_DIRECT, \
47               FILE_READ_ACCESS)
48 #define OVS_IOCTL_WRITE \
49     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x4, METHOD_IN_DIRECT,\
50               FILE_READ_ACCESS)
51 #define OVS_IOCTL_TRANSACT \
52     CTL_CODE (OVS_IOCTL_DEVICE_TYPE, OVS_IOCTL_START + 0x5, METHOD_OUT_DIRECT,\
53               FILE_WRITE_ACCESS)
54
55 /*
56  * On platforms that support netlink natively, the operating system assigns a
57  * dynamic value to a netlink family when it is registered. In the absense of
58  * such mechanism, defined hard-coded values that are known both to userspace
59  * and kernel.
60  */
61 #define OVS_WIN_NL_INVALID_FAMILY_ID         0
62 #define OVS_WIN_NL_CTRL_FAMILY_ID            (NLMSG_MIN_TYPE + 1)
63 #define OVS_WIN_NL_DATAPATH_FAMILY_ID        (NLMSG_MIN_TYPE + 2)
64 #define OVS_WIN_NL_PACKET_FAMILY_ID          (NLMSG_MIN_TYPE + 3)
65 #define OVS_WIN_NL_VPORT_FAMILY_ID           (NLMSG_MIN_TYPE + 4)
66 #define OVS_WIN_NL_FLOW_FAMILY_ID            (NLMSG_MIN_TYPE + 5)
67 #define OVS_WIN_NL_NETDEV_FAMILY_ID          (NLMSG_MIN_TYPE + 6)
68
69 #define OVS_WIN_NL_INVALID_MCGRP_ID          0
70 #define OVS_WIN_NL_MCGRP_START_ID            100
71 #define OVS_WIN_NL_VPORT_MCGRP_ID            (OVS_WIN_NL_MCGRP_START_ID + 1)
72
73 /*
74  * Define a family of netlink command specific to Windows. This is part of the
75  * extensions.
76  */
77 #define OVS_WIN_CONTROL_FAMILY   "ovs_win_control"
78 #define OVS_WIN_CONTROL_MCGROUP  "ovs_win_control"
79 #define OVS_WIN_CONTROL_VERSION  1
80
81 /* Commands available under the OVS_WIN_CONTROL_FAMILY. */
82 enum ovs_win_control_cmd {
83     OVS_CTRL_CMD_WIN_PEND_REQ,
84     OVS_CTRL_CMD_WIN_PEND_PACKET_REQ,
85     OVS_CTRL_CMD_MC_SUBSCRIBE_REQ,
86     OVS_CTRL_CMD_PACKET_SUBSCRIBE_REQ,
87
88     /* This command is logically belong to the Vport family */
89     OVS_CTRL_CMD_EVENT_NOTIFY,
90     OVS_CTRL_CMD_READ_NOTIFY
91 };
92
93 /* NL Attributes for joining/unjoining an MC group */
94 enum ovs_nl_mcast_attr {
95     OVS_NL_ATTR_MCAST_GRP,        /* (UINT32) Join an MC group */
96     OVS_NL_ATTR_MCAST_JOIN,       /* (UINT8) 1/0 - Join/Unjoin */
97     OVS_NL_ATTR_PACKET_SUBSCRIBE, /* (UNINT8): 1/0 - subscribe/unsubscribe */
98     OVS_NL_ATTR_PACKET_PID,       /* (UNINT32) netlink PID to receive upcalls */
99     __OVS_NL_ATTR_CTRL_MAX
100 };
101 #define OVS_WIN_CONTROL_ATTR_MAX (__OVS_NL_ATTR_CTRL_MAX - 1)
102
103 /*
104  * Netdev family of commands specific to Windows.
105  */
106 #define OVS_WIN_NETDEV_FAMILY   "ovs_win_netdev"
107 #define OVS_WIN_NETDEV_MCGROUP  "ovs_win_netdev"
108 #define OVS_WIN_NETDEV_VERSION  1
109
110 enum ovs_win_netdev_cmd {
111     OVS_WIN_NETDEV_CMD_UNSPEC,
112     OVS_WIN_NETDEV_CMD_GET,     /* information about the netdev. */
113 };
114
115 /**
116  * For every vport on the datapath, there is a corresponding netdev.  General
117  * network device attributes of a vport that are not specific to OVS, such as
118  * MTU are represented using a netdev.  For convenience, some of the vport
119  * attributes are also included as netdev attributes.
120  *
121  * enum ovs_win_netdev_attr - attributes for %OVS_WIN_NETDEV_* commands.
122  * @OVS_WIN_NETDEV_ATTR_PORT_NO: 32-bit port number of the vport within the
123  * datapath.
124  * @OVS_WIN_NETDEV_ATTR_TYPE: 32-bit %OVS_VPORT_TYPE_* constant describing
125  * the type of vport.
126  * @OVS_WIN_NETDEV_ATTR_NAME: Name of vport.  Maximum length %IFNAMSIZ-1 bytes
127  * plus a null terminator.
128  * @OVS_WIN_NETDEV_ATTR_MAC_ADDR: MAC address of the vport.  %ETH_ADDR_LEN bytes
129  * long.
130  * @OVS_WIN_NETDEV_ATTR_MTU : 32-bit MTU of the vport.
131  * @OVS_WIN_NETDEV_ATTR_IF_FLAGS: 32-bit %OVS_WIN_NETDEV_IFF_* interface flags
132  * of the vport.
133  *
134  * These attributes follow the &struct ovs_header within the Generic Netlink
135  * payload for %OVS_WIN_NETDEV_* commands.
136  *
137  * For all requests, if %OVS_WIN_NETDEV_ATTR_NAME is specified then it is used
138  * to look up the netdev to operate on; dp_idx from the &struct
139  * ovs_header is not relevant for the look up.
140  */
141 enum ovs_win_netdev_attr {
142     OVS_WIN_NETDEV_ATTR_UNSPEC,
143     OVS_WIN_NETDEV_ATTR_PORT_NO,     /* u32 port number within datapath. */
144     OVS_WIN_NETDEV_ATTR_TYPE,        /* u32 OVS_NETDEV_TYPE_* constant. */
145     OVS_WIN_NETDEV_ATTR_NAME,        /* string name, up to IFNAMSIZ bytes long. */
146     OVS_WIN_NETDEV_ATTR_MAC_ADDR,    /* MAC address of the vport. */
147     OVS_WIN_NETDEV_ATTR_MTU,         /* MTU of the vport. */
148     OVS_WIN_NETDEV_ATTR_IF_FLAGS,    /* Interface flags o the vport. */
149     __OVS_WIN_NETDEV_ATTR_MAX
150 };
151 #define OVS_WIN_NETDEV_ATTR_MAX (__OVS_WIN_NETDEV_ATTR_MAX - 1)
152
153 #define OVS_WIN_NETDEV_IFF_UP                   (1 << 0)
154 #define OVS_WIN_NETDEV_IFF_PROMISC              (1 << 1)
155
156 typedef struct ovs_dp_stats OVS_DP_STATS;
157 typedef enum ovs_vport_type OVS_VPORT_TYPE;
158
159 #endif /* __OVS_DP_INTERFACE_EXT_H_ */