2 * Copyright (c) 2014 VMware, Inc.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #define OVS_MAX_DPPORTS MAXUINT16
23 #define OVS_DPPORT_NUMBER_INVALID OVS_MAX_DPPORTS
25 * The local port (0) is a reserved port, that is not allowed to be be
26 * created by the netlink command vport add. On linux, this port is created
27 * at netlink command datapath new. However, on windows, we do not need to
28 * create it, and more, we shouldn't. The userspace attempts to create two
29 * internal vports, the LOCAL port (0) and the internal port (with any other
30 * port number). The non-LOCAL internal port is used in the userspace when it
31 * requests the internal port.
33 #define OVS_DPPORT_NUMBER_LOCAL 0
36 * A Vport, or Virtual Port, is a port on the OVS. It can be one of the
37 * following types. Some of the Vports are "real" ports on the hyper-v switch,
39 * - VIF port (VM's NIC)
40 * - External Adapters (physical NIC)
41 * - Internal Adapter (Virtual adapter exposed on the host).
42 * - Tunnel ports created by OVS userspace.
47 OVS_STATE_PORT_CREATED,
48 OVS_STATE_NIC_CREATED,
50 OVS_STATE_PORT_TEAR_DOWN,
51 OVS_STATE_PORT_DELETED,
54 typedef struct _OVS_VPORT_STATS {
61 typedef struct _OVS_VPORT_ERR_STATS {
66 } OVS_VPORT_ERR_STATS;
68 /* used for vport netlink commands. */
69 typedef struct _OVS_VPORT_FULL_STATS {
72 }OVS_VPORT_FULL_STATS;
74 * Each internal, external adapter or vritual adapter has
75 * one vport entry. In addition, we have one vport for each
76 * tunnel type, such as vxlan, gre, gre64
78 typedef struct _OVS_VPORT_ENTRY {
79 LIST_ENTRY ovsNameLink;
80 LIST_ENTRY portIdLink;
81 LIST_ENTRY portNoLink;
83 OVS_VPORT_STATE ovsState;
84 OVS_VPORT_TYPE ovsType;
85 OVS_VPORT_STATS stats;
86 OVS_VPORT_ERR_STATS errStats;
89 CHAR ovsName[OVS_MAX_PORT_NAME_LENGTH];
93 NDIS_SWITCH_PORT_ID portId;
94 NDIS_SWITCH_NIC_INDEX nicIndex;
96 NDIS_SWITCH_PORT_STATE portState;
97 NDIS_SWITCH_NIC_STATE nicState;
98 NDIS_SWITCH_PORT_TYPE portType;
100 UINT8 permMacAddress[MAC_ADDRESS_LEN];
101 UINT8 currMacAddress[MAC_ADDRESS_LEN];
102 UINT8 vmMacAddress[MAC_ADDRESS_LEN];
104 NDIS_SWITCH_PORT_NAME hvPortName;
105 IF_COUNTED_STRING portFriendlyName;
106 NDIS_SWITCH_NIC_NAME nicName;
108 GUID netCfgInstanceId;
110 UINT32 upcallPid; /* netlink upcall port id */
111 } OVS_VPORT_ENTRY, *POVS_VPORT_ENTRY;
113 struct _OVS_SWITCH_CONTEXT;
116 OvsFindVportByPortNo(struct _OVS_SWITCH_CONTEXT *switchContext,
119 OvsFindVportByOvsName(struct _OVS_SWITCH_CONTEXT *switchContext,
120 CHAR *name, UINT32 length);
122 OvsFindVportByHvName(POVS_SWITCH_CONTEXT switchContext, PSTR name);
124 OvsFindVportByPortIdAndNicIndex(struct _OVS_SWITCH_CONTEXT *switchContext,
125 NDIS_SWITCH_PORT_ID portId,
126 NDIS_SWITCH_NIC_INDEX index);
128 NDIS_STATUS OvsAddConfiguredSwitchPorts(struct _OVS_SWITCH_CONTEXT *switchContext);
129 NDIS_STATUS OvsInitConfiguredSwitchNics(struct _OVS_SWITCH_CONTEXT *switchContext);
131 VOID OvsClearAllSwitchVports(struct _OVS_SWITCH_CONTEXT *switchContext);
133 NDIS_STATUS HvCreateNic(POVS_SWITCH_CONTEXT switchContext,
134 PNDIS_SWITCH_NIC_PARAMETERS nicParam);
135 NDIS_STATUS HvCreatePort(POVS_SWITCH_CONTEXT switchContext,
136 PNDIS_SWITCH_PORT_PARAMETERS portParam);
137 VOID HvTeardownPort(POVS_SWITCH_CONTEXT switchContext,
138 PNDIS_SWITCH_PORT_PARAMETERS portParam);
139 VOID HvDeletePort(POVS_SWITCH_CONTEXT switchContext,
140 PNDIS_SWITCH_PORT_PARAMETERS portParam);
141 VOID HvConnectNic(POVS_SWITCH_CONTEXT switchContext,
142 PNDIS_SWITCH_NIC_PARAMETERS nicParam);
143 VOID HvUpdateNic(POVS_SWITCH_CONTEXT switchContext,
144 PNDIS_SWITCH_NIC_PARAMETERS nicParam);
145 VOID HvDeleteNic(POVS_SWITCH_CONTEXT switchContext,
146 PNDIS_SWITCH_NIC_PARAMETERS nicParam);
147 VOID HvDisconnectNic(POVS_SWITCH_CONTEXT switchContext,
148 PNDIS_SWITCH_NIC_PARAMETERS nicParam);
150 static __inline BOOLEAN
151 OvsIsTunnelVportType(OVS_VPORT_TYPE ovsType)
153 return ovsType == OVS_VPORT_TYPE_VXLAN ||
154 ovsType == OVS_VPORT_TYPE_GRE ||
155 ovsType == OVS_VPORT_TYPE_GRE64;
158 static __inline BOOLEAN
159 OvsIsInternalVportType(OVS_VPORT_TYPE ovsType)
161 return ovsType == OVS_VPORT_TYPE_INTERNAL;
164 static __inline UINT32
167 return ((POVS_VPORT_ENTRY) OvsGetExternalVport())->mtu;
170 #endif /* __VPORT_H_ */