summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2018-05-23 16:09:47 -0400
committerTim Rozet <trozet@redhat.com>2018-05-31 18:13:51 +0000
commit073cf28764cd3700916f57e43741ff20e4af57e5 (patch)
tree54445a3211944efeaaaf71678223f3cd7e1891df
parentfd7f3285fa0d872f3eb23ded248e45bf720ebda7 (diff)
Default ctlplane to native VLAN
We were not setting any vlan type value for the admin network. This caused an issue when deploying and trying to use a single collapsed network (no net isolation). The issue occurred when trying to create an external neutron network. We happen to check if the phys type is flat or vlan using this attribute to decide what kind of phys type to use for the neutron network. JIRA: APEX-606 Change-Id: I4e24dd5e8b99cef920b8203b820a77d0021631cc Signed-off-by: Tim Rozet <trozet@redhat.com> (cherry picked from commit 42a9303a21a46f9e9b1997ab4c0beceb6b0bf438)
-rw-r--r--apex/settings/network_settings.py7
-rw-r--r--apex/tests/test_apex_network_settings.py3
2 files changed, 8 insertions, 2 deletions
diff --git a/apex/settings/network_settings.py b/apex/settings/network_settings.py
index f6566834..36d143cb 100644
--- a/apex/settings/network_settings.py
+++ b/apex/settings/network_settings.py
@@ -167,10 +167,13 @@ class NetworkSettings(dict):
"""
_network = self.get_network(network)
# if vlan not defined then default it to native
- if network is not ADMIN_NETWORK:
- for role in ROLES:
+ for role in ROLES:
+ if network is not ADMIN_NETWORK:
if 'vlan' not in _network['nic_mapping'][role]:
_network['nic_mapping'][role]['vlan'] = 'native'
+ else:
+ # ctlplane network must be native
+ _network['nic_mapping'][role]['vlan'] = 'native'
cidr = _network.get('cidr')
diff --git a/apex/tests/test_apex_network_settings.py b/apex/tests/test_apex_network_settings.py
index 5e2fa072..764c9ef4 100644
--- a/apex/tests/test_apex_network_settings.py
+++ b/apex/tests/test_apex_network_settings.py
@@ -112,6 +112,9 @@ class TestNetworkSettings:
# remove vlan from storage net
storage_net_nicmap['compute'].pop('vlan', None)
assert_is_instance(NetworkSettings(ns), NetworkSettings)
+ for role in ('compute', 'controller'):
+ assert_equal(ns['networks'][ADMIN_NETWORK]['nic_mapping'][
+ role]['vlan'], 'native')
# TODO
# need to manipulate interfaces some how
20 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
#ifndef _USBHUB_H
#define _USBHUB_H

/** @file
 *
 * USB hubs
 *
 */

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

#include <ipxe/usb.h>
#include <ipxe/list.h>
#include <ipxe/process.h>

/** Request recipient is a port */
#define USB_HUB_RECIP_PORT ( 3 << 0 )

/** A basic USB hub descriptor */
struct usb_hub_descriptor_basic {
	/** Descriptor header */
	struct usb_descriptor_header header;
	/** Number of ports */
	uint8_t ports;
	/** Characteristics */
	uint16_t characteristics;
	/** Power-on delay (in 2ms intervals */
	uint8_t delay;
	/** Controller current (in mA) */
	uint8_t current;
} __attribute__ (( packed ));

/** A basic USB hub descriptor */
#define USB_HUB_DESCRIPTOR 41

/** An enhanced USB hub descriptor */
struct usb_hub_descriptor_enhanced {
	/** Basic USB hub descriptor */
	struct usb_hub_descriptor_basic basic;
	/** Header decode latency */
	uint8_t latency;
	/** Maximum delay */
	uint16_t delay;
	/** Removable device bitmask */
	uint16_t removable;
} __attribute__ (( packed ));

/** An enhanced USB hub descriptor */
#define USB_HUB_DESCRIPTOR_ENHANCED 42

/** A USB hub descriptor */
union usb_hub_descriptor {
	/** Descriptor header */
	struct usb_descriptor_header header;
	/** Basic hub descriptor */
	struct usb_hub_descriptor_basic basic;
	/** Enhanced hub descriptor */
	struct usb_hub_descriptor_enhanced enhanced;
} __attribute__ (( packed ));

/** Port status */
struct usb_hub_port_status {
	/** Current status */
	uint16_t current;
	/** Changed status */
	uint16_t changed;
} __attribute__ (( packed ));

/** Current connect status feature */
#define USB_HUB_PORT_CONNECTION 0

/** Port enabled/disabled feature */
#define USB_HUB_PORT_ENABLE 1

/** Port reset feature */
#define USB_HUB_PORT_RESET 4

/** Port power feature */
#define USB_HUB_PORT_POWER 8

/** Low-speed device attached */
#define USB_HUB_PORT_LOW_SPEED 9

/** High-speed device attached */
#define USB_HUB_PORT_HIGH_SPEED 10

/** Connect status changed */
#define USB_HUB_C_PORT_CONNECTION 16

/** Port enable/disable changed */
#define	USB_HUB_C_PORT_ENABLE 17

/** Suspend changed */
#define USB_HUB_C_PORT_SUSPEND 18

/** Over-current indicator changed */
#define USB_HUB_C_PORT_OVER_CURRENT 19

/** Reset changed */
#define USB_HUB_C_PORT_RESET 20

/** Link state changed */
#define USB_HUB_C_PORT_LINK_STATE 25

/** Configuration error */
#define USB_HUB_C_PORT_CONFIG_ERROR 26

/** Calculate feature from change bit number */
#define USB_HUB_C_FEATURE( bit ) ( 16 + (bit) )

/** USB features */
#define USB_HUB_FEATURES						\
	( ( 1 << USB_HUB_C_PORT_CONNECTION ) |				\
	  ( 1 << USB_HUB_C_PORT_ENABLE ) |				\
	  ( 1 << USB_HUB_C_PORT_SUSPEND ) |				\
	  ( 1 << USB_HUB_C_PORT_OVER_CURRENT ) |			\
	  ( 1 << USB_HUB_C_PORT_RESET ) )

/** USB features for enhanced hubs */
#define USB_HUB_FEATURES_ENHANCED					\
	( ( 1 << USB_HUB_C_PORT_CONNECTION ) |				\
	  ( 1 << USB_HUB_C_PORT_OVER_CURRENT ) |			\
	  ( 1 << USB_HUB_C_PORT_RESET ) |				\
	  ( 1 << USB_HUB_C_PORT_LINK_STATE ) |				\
	  ( 1 << USB_HUB_C_PORT_CONFIG_ERROR ) )

/** Set hub depth */
#define USB_HUB_SET_HUB_DEPTH						\
	( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE |		\
	  USB_REQUEST_TYPE ( 12 ) )

/** Clear transaction translator buffer */
#define USB_HUB_CLEAR_TT_BUFFER						\
	( USB_DIR_OUT | USB_TYPE_CLASS | USB_HUB_RECIP_PORT |		\
	  USB_REQUEST_TYPE ( 8 ) )

/**
 * Get hub descriptor
 *
 * @v usb		USB device
 * @v enhanced		Hub is an enhanced hub
 * @v data		Hub descriptor to fill in
 * @ret rc		Return status code
 */
static inline __attribute__ (( always_inline )) int
usb_hub_get_descriptor ( struct usb_device *usb, int enhanced,
			 union usb_hub_descriptor *data ) {
	unsigned int desc;
	size_t len;

	/* Determine descriptor type and length */
	desc = ( enhanced ? USB_HUB_DESCRIPTOR_ENHANCED : USB_HUB_DESCRIPTOR );
	len = ( enhanced ? sizeof ( data->enhanced ) : sizeof ( data->basic ) );

	return usb_get_descriptor ( usb, USB_TYPE_CLASS, desc, 0, 0,
				    &data->header, len );
}

/**
 * Get port status
 *
 * @v usb		USB device
 * @v port		Port address
 * @v status		Port status descriptor to fill in
 * @ret rc		Return status code
 */
static inline __attribute__ (( always_inline )) int
usb_hub_get_port_status ( struct usb_device *usb, unsigned int port,
			  struct usb_hub_port_status *status ) {

	return usb_get_status ( usb, ( USB_TYPE_CLASS | USB_HUB_RECIP_PORT ),
				port, status, sizeof ( *status ) );
}

/**
 * Clear port feature
 *
 * @v usb		USB device
 * @v port		Port address
 * @v feature		Feature to clear
 * @v index		Index (when clearing a port indicator)
 * @ret rc		Return status code
 */
static inline __attribute__ (( always_inline )) int
usb_hub_clear_port_feature ( struct usb_device *usb, unsigned int port,
			     unsigned int feature, unsigned int index ) {

	return usb_clear_feature ( usb, ( USB_TYPE_CLASS | USB_HUB_RECIP_PORT ),
				   feature, ( ( index << 8 ) | port ) );
}

/**
 * Set port feature
 *
 * @v usb		USB device
 * @v port		Port address
 * @v feature		Feature to clear
 * @v index		Index (when clearing a port indicator)
 * @ret rc		Return status code
 */
static inline __attribute__ (( always_inline )) int
usb_hub_set_port_feature ( struct usb_device *usb, unsigned int port,
			   unsigned int feature, unsigned int index ) {

	return usb_set_feature ( usb, ( USB_TYPE_CLASS | USB_HUB_RECIP_PORT ),
				 feature, ( ( index << 8 ) | port ) );
}

/**
 * Set hub depth
 *
 * @v usb		USB device
 * @v depth		Hub depth
 * @ret rc		Return status code
 */
static inline __attribute__ (( always_inline )) int
usb_hub_set_hub_depth ( struct usb_device *usb, unsigned int depth ) {

	return usb_control ( usb, USB_HUB_SET_HUB_DEPTH, depth, 0, NULL, 0 );
}

/**
 * Clear transaction translator buffer
 *
 * @v usb		USB device
 * @v device		Device address
 * @v endpoint		Endpoint address
 * @v attributes	Endpoint attributes
 * @v tt_port		Transaction translator port (or 1 for single-TT hubs)
 * @ret rc		Return status code
 */
static inline __attribute__ (( always_inline )) int
usb_hub_clear_tt_buffer ( struct usb_device *usb, unsigned int device,
			  unsigned int endpoint, unsigned int attributes,
			  unsigned int tt_port ) {
	unsigned int value;

	/* Calculate value */
	value = ( ( ( endpoint & USB_ENDPOINT_MAX ) << 0 ) | ( device << 4 ) |
		  ( ( attributes & USB_ENDPOINT_ATTR_TYPE_MASK ) << 11 ) |
		  ( ( endpoint & USB_ENDPOINT_IN ) << 8 ) );

	return usb_control ( usb, USB_HUB_CLEAR_TT_BUFFER, value,
			     tt_port, NULL, 0 );
}

/** Transaction translator port value for single-TT hubs */
#define USB_HUB_TT_SINGLE 1

/** A USB hub device */
struct usb_hub_device {
	/** Name */
	const char *name;
	/** USB device */
	struct usb_device *usb;
	/** USB hub */
	struct usb_hub *hub;
	/** Features */
	unsigned int features;

	/** Interrupt endpoint */
	struct usb_endpoint intr;
	/** Interrupt endpoint refill process */
	struct process refill;
};

/** Interrupt ring fill level
 *
 * This is a policy decision.
 */
#define USB_HUB_INTR_FILL 4

/** Maximum time to wait for port to become enabled
 *
 * This is a policy decision.
 */
#define USB_HUB_ENABLE_MAX_WAIT_MS 100

#endif /* _USBHUB_H */