2 * Copyright (c) 2011-2014 M3S, Srl - Italy
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.
18 * Rapid Spanning Tree Protocol (IEEE 802.1D-2004) common header file.
21 * Martino Fornasa <mf@fornasa.it>
22 * Daniele Venturino <daniele.venturino@m3s.it>
24 * References to IEEE 802.1D-2004 standard are enclosed in square brackets.
25 * E.g. [17.3], [Table 17-1], etc.
30 #define RSTP_COMMON_H 1
37 #include "ovs-atomic.h"
40 enum admin_port_state {
41 RSTP_ADMIN_BRIDGE_PORT_STATE_DISABLED = 0,
42 RSTP_ADMIN_BRIDGE_PORT_STATE_ENABLED = 1
45 enum oper_p2p_mac_state {
46 RSTP_OPER_P2P_MAC_STATE_DISABLED = 0,
47 RSTP_OPER_P2P_MAC_STATE_ENABLED = 1
50 /* State enumerations for state machines defined in rstp-state-machines.c */
51 enum port_receive_state_machine {
53 PORT_RECEIVE_SM_DISCARD_EXEC,
54 PORT_RECEIVE_SM_DISCARD,
55 PORT_RECEIVE_SM_RECEIVE_EXEC,
56 PORT_RECEIVE_SM_RECEIVE
58 enum port_transmit_state_machine {
59 PORT_TRANSMIT_SM_INIT,
60 PORT_TRANSMIT_SM_TRANSMIT_INIT_EXEC,
61 PORT_TRANSMIT_SM_TRANSMIT_INIT,
62 PORT_TRANSMIT_SM_TRANSMIT_PERIODIC_EXEC,
63 PORT_TRANSMIT_SM_TRANSMIT_PERIODIC,
64 PORT_TRANSMIT_SM_IDLE_EXEC,
65 PORT_TRANSMIT_SM_IDLE,
66 PORT_TRANSMIT_SM_TRANSMIT_CONFIG_EXEC,
67 PORT_TRANSMIT_SM_TRANSMIT_CONFIG,
68 PORT_TRANSMIT_SM_TRANSMIT_TCN_EXEC,
69 PORT_TRANSMIT_SM_TRANSMIT_TCN,
70 PORT_TRANSMIT_SM_TRANSMIT_RSTP_EXEC,
71 PORT_TRANSMIT_SM_TRANSMIT_RSTP
73 enum bridge_detection_state_machine {
74 BRIDGE_DETECTION_SM_INIT,
75 BRIDGE_DETECTION_SM_EDGE_EXEC,
76 BRIDGE_DETECTION_SM_EDGE,
77 BRIDGE_DETECTION_SM_NOT_EDGE_EXEC,
78 BRIDGE_DETECTION_SM_NOT_EDGE
80 enum port_protocol_migration_state_machine {
81 PORT_PROTOCOL_MIGRATION_SM_INIT,
82 PORT_PROTOCOL_MIGRATION_SM_CHECKING_RSTP_EXEC,
83 PORT_PROTOCOL_MIGRATION_SM_CHECKING_RSTP,
84 PORT_PROTOCOL_MIGRATION_SM_SELECTING_STP_EXEC,
85 PORT_PROTOCOL_MIGRATION_SM_SELECTING_STP,
86 PORT_PROTOCOL_MIGRATION_SM_SENSING_EXEC,
87 PORT_PROTOCOL_MIGRATION_SM_SENSING
89 enum port_information_state_machine {
90 PORT_INFORMATION_SM_INIT,
91 PORT_INFORMATION_SM_DISABLED_EXEC,
92 PORT_INFORMATION_SM_DISABLED,
93 PORT_INFORMATION_SM_AGED_EXEC,
94 PORT_INFORMATION_SM_AGED,
95 PORT_INFORMATION_SM_UPDATE_EXEC,
96 PORT_INFORMATION_SM_UPDATE,
97 PORT_INFORMATION_SM_CURRENT_EXEC,
98 PORT_INFORMATION_SM_CURRENT,
99 PORT_INFORMATION_SM_RECEIVE_EXEC,
100 PORT_INFORMATION_SM_RECEIVE,
101 PORT_INFORMATION_SM_OTHER_EXEC,
102 PORT_INFORMATION_SM_OTHER,
103 PORT_INFORMATION_SM_NOT_DESIGNATED_EXEC,
104 PORT_INFORMATION_SM_NOT_DESIGNATED,
105 PORT_INFORMATION_SM_INFERIOR_DESIGNATED_EXEC,
106 PORT_INFORMATION_SM_INFERIOR_DESIGNATED,
107 PORT_INFORMATION_SM_REPEATED_DESIGNATED_EXEC,
108 PORT_INFORMATION_SM_REPEATED_DESIGNATED,
109 PORT_INFORMATION_SM_SUPERIOR_DESIGNATED_EXEC,
110 PORT_INFORMATION_SM_SUPERIOR_DESIGNATED
112 enum port_role_selection_state_machine {
113 PORT_ROLE_SELECTION_SM_INIT,
114 PORT_ROLE_SELECTION_SM_INIT_BRIDGE_EXEC,
115 PORT_ROLE_SELECTION_SM_INIT_BRIDGE,
116 PORT_ROLE_SELECTION_SM_ROLE_SELECTION_EXEC,
117 PORT_ROLE_SELECTION_SM_ROLE_SELECTION
119 enum port_role_transition_state_machine {
120 PORT_ROLE_TRANSITION_SM_INIT,
121 PORT_ROLE_TRANSITION_SM_INIT_PORT_EXEC,
122 PORT_ROLE_TRANSITION_SM_DISABLE_PORT_EXEC,
123 PORT_ROLE_TRANSITION_SM_DISABLE_PORT,
124 PORT_ROLE_TRANSITION_SM_DISABLED_PORT_EXEC,
125 PORT_ROLE_TRANSITION_SM_DISABLED_PORT,
126 PORT_ROLE_TRANSITION_SM_ROOT_PORT_EXEC,
127 PORT_ROLE_TRANSITION_SM_ROOT_PORT,
128 PORT_ROLE_TRANSITION_SM_REROOT_EXEC,
129 PORT_ROLE_TRANSITION_SM_ROOT_AGREED_EXEC,
130 PORT_ROLE_TRANSITION_SM_ROOT_PROPOSED_EXEC,
131 PORT_ROLE_TRANSITION_SM_ROOT_FORWARD_EXEC,
132 PORT_ROLE_TRANSITION_SM_ROOT_LEARN_EXEC,
133 PORT_ROLE_TRANSITION_SM_REROOTED_EXEC,
134 PORT_ROLE_TRANSITION_SM_DESIGNATED_PORT_EXEC,
135 PORT_ROLE_TRANSITION_SM_DESIGNATED_PORT,
136 PORT_ROLE_TRANSITION_SM_DESIGNATED_RETIRED_EXEC,
137 PORT_ROLE_TRANSITION_SM_DESIGNATED_SYNCED_EXEC,
138 PORT_ROLE_TRANSITION_SM_DESIGNATED_PROPOSE_EXEC,
139 PORT_ROLE_TRANSITION_SM_DESIGNATED_FORWARD_EXEC,
140 PORT_ROLE_TRANSITION_SM_DESIGNATED_LEARN_EXEC,
141 PORT_ROLE_TRANSITION_SM_DESIGNATED_DISCARD_EXEC,
142 PORT_ROLE_TRANSITION_SM_ALTERNATE_PORT_EXEC,
143 PORT_ROLE_TRANSITION_SM_ALTERNATE_PORT,
144 PORT_ROLE_TRANSITION_SM_ALTERNATE_AGREED_EXEC,
145 PORT_ROLE_TRANSITION_SM_ALTERNATE_PROPOSED_EXEC,
146 PORT_ROLE_TRANSITION_SM_BLOCK_PORT_EXEC,
147 PORT_ROLE_TRANSITION_SM_BLOCK_PORT,
148 PORT_ROLE_TRANSITION_SM_BACKUP_PORT_EXEC
150 enum port_state_transition_state_machine {
151 PORT_STATE_TRANSITION_SM_INIT,
152 PORT_STATE_TRANSITION_SM_DISCARDING_EXEC,
153 PORT_STATE_TRANSITION_SM_DISCARDING,
154 PORT_STATE_TRANSITION_SM_LEARNING_EXEC,
155 PORT_STATE_TRANSITION_SM_LEARNING,
156 PORT_STATE_TRANSITION_SM_FORWARDING_EXEC,
157 PORT_STATE_TRANSITION_SM_FORWARDING
159 enum topology_change_state_machine {
160 TOPOLOGY_CHANGE_SM_INIT,
161 TOPOLOGY_CHANGE_SM_INACTIVE_EXEC,
162 TOPOLOGY_CHANGE_SM_INACTIVE,
163 TOPOLOGY_CHANGE_SM_LEARNING_EXEC,
164 TOPOLOGY_CHANGE_SM_LEARNING,
165 TOPOLOGY_CHANGE_SM_DETECTED_EXEC,
166 TOPOLOGY_CHANGE_SM_ACTIVE_EXEC,
167 TOPOLOGY_CHANGE_SM_ACTIVE,
168 TOPOLOGY_CHANGE_SM_ACKNOWLEDGED_EXEC,
169 TOPOLOGY_CHANGE_SM_PROPAGATING_EXEC,
170 TOPOLOGY_CHANGE_SM_NOTIFIED_TC_EXEC,
171 TOPOLOGY_CHANGE_SM_NOTIFIED_TCN_EXEC,
175 /* [17.18.4, 17.13, Table 17-1]. */
177 /* [17.13.5 - Bridge Forward Delay] The delay (expressed in seconds) used
178 * by STP Bridges (17.4) to transition Root and Designated Ports to
179 * Forwarding (Table 17-1).
180 * Default = 15.0 s. Values in range 4.0 - 30.0
182 uint16_t forward_delay;
184 /* [17.13.6 - Bridge Hello Time]
185 * The interval between periodic transmissions of Configuration Messages
186 * by Designated Ports (Table 17-1).
187 * Default = 2.0 s. Fixed value
191 /* [17.13.8 - Bridge Max Age]
192 * The maximum age of the information transmitted by the Bridge when it is
193 * the Root Bridge (Table 17-1).
194 * Default = 20.0 s. Values in range 6.0 - 40.0 */
197 uint16_t message_age;
200 /* Priority vector [17.6] */
201 struct rstp_priority_vector {
202 rstp_identifier root_bridge_id;
203 uint32_t root_path_cost;
204 rstp_identifier designated_bridge_id;
205 uint16_t designated_port_id;
206 uint16_t bridge_port_id;
209 enum rstp_bpdu_type {
210 CONFIGURATION_BPDU = 0x0,
211 TOPOLOGY_CHANGE_NOTIFICATION_BPDU = 0x80,
212 RAPID_SPANNING_TREE_BPDU = 0x2
215 enum rstp_bpdu_flag {
216 BPDU_FLAG_TOPCHANGE = 0x01,
217 BPDU_FLAG_PROPOSAL = 0x02,
218 BPDU_FLAG_LEARNING = 0x10,
219 BPDU_FLAG_FORWARDING = 0x20,
220 BPDU_FLAG_AGREEMENT = 0x40,
221 BPDU_FLAG_TOPCHANGEACK = 0x80
224 /* Rapid Spanning Tree BPDU [9.3.3] */
227 ovs_be16 protocol_identifier;
228 uint8_t protocol_version_identifier;
231 ovs_be64 root_bridge_id;
232 ovs_be32 root_path_cost;
233 ovs_be64 designated_bridge_id;
234 ovs_be16 designated_port_id;
235 ovs_be16 message_age;
238 ovs_be16 forward_delay;
239 uint8_t version1_length;
250 enum rstp_rcvd_info {
251 SUPERIOR_DESIGNATED_INFO,
252 REPEATED_DESIGNATED_INFO,
253 INFERIOR_DESIGNATED_INFO,
254 INFERIOR_ROOT_ALTERNATE_INFO,
259 struct ovs_refcount ref_cnt;
261 struct rstp *rstp OVS_GUARDED_BY(rstp_mutex);
262 struct hmap_node node OVS_GUARDED_BY(rstp_mutex); /* In rstp->ports. */
263 void *aux OVS_GUARDED_BY(rstp_mutex);
264 struct rstp_bpdu received_bpdu_buffer OVS_GUARDED_BY(rstp_mutex);
265 /*************************************************************************
266 * MAC status parameters
267 ************************************************************************/
268 /* [6.4.2 - MAC_Operational]
269 * The value of this parameter is TRUE if [...] the MAC entity can be used
270 * to transmit and/or receive frames, and its use is permitted by
273 bool mac_operational OVS_GUARDED_BY(rstp_mutex);
275 /* [14.8.2.2] Administrative Bridge Port State */
276 bool is_administrative_bridge_port OVS_GUARDED_BY(rstp_mutex);
278 /* [6.4.3 - operPointToPointMAC]
279 * a) True. The MAC is connected to a point-to-point LAN; i.e., there is
280 * at most one other system attached to the LAN.
281 * b) False. The MAC is connected to a non-point-to-point LAN; i.e.,
282 * there can be more than one other system attached to the LAN.
284 * If adminPointToPointMAC is set to ForceTrue, then operPointToPointMAC
285 * shall be set True. If adminPointToPointMAC is set to ForceFalse, then
286 * operPointToPointMAC shall be set False.
288 bool oper_point_to_point_mac OVS_GUARDED_BY(rstp_mutex);
290 /* [6.4.3 - adminPointToPointMAC]
291 * a) ForceTrue. The administrator requires the MAC to be treated as if it
292 * is connected to a point-to-point LAN, regardless of any indications
293 * to the contrary that are generated by the MAC entity.
294 * b) ForceFalse. The administrator requires the MAC to be treated as
295 * connected to a non-point-to-point LAN, regardless of any indications
296 * to the contrary that are generated by the MAC entity.
297 * c) Auto. The administrator requires the point-to-point status of the
298 * MAC to be determined in accordance with the specific MAC procedures
301 enum rstp_admin_point_to_point_mac_state admin_point_to_point_mac OVS_GUARDED_BY(rstp_mutex);
304 /*************************************************************************
305 * [17.3 - RSTP performance parameters] Set by management actions on the
307 *************************************************************************/
309 /* [17.13.1 - Admin Edge Port]
310 * The AdminEdgePort parameter for the Port (14.8.2).
312 bool admin_edge OVS_GUARDED_BY(rstp_mutex);
314 /* [17.13.3 - AutoEdge]
315 * The AutoEdgePort parameter for the Port (14.8.2).
317 bool auto_edge OVS_GUARDED_BY(rstp_mutex);
320 /*************************************************************************
321 * The following variables are set by management actions on the bridge
322 ************************************************************************/
324 /* Port number and priority
325 * >=1 (max 12 bits [9.2.7])
327 uint16_t port_number OVS_GUARDED_BY(rstp_mutex);
330 * Range: 0-240 in steps of 16 (table 17-2)
332 uint8_t priority OVS_GUARDED_BY(rstp_mutex);
334 /* [17.13.11 - PortPathCost]
335 * The Port's contribution, when it is the Root Port, to the Root Path Cost
336 * (17.3.1, 17.5, 17.6) for the Bridge.
338 uint32_t port_path_cost OVS_GUARDED_BY(rstp_mutex);
340 /*************************************************************************
341 * The following variables are defined in [17.17 - State machine timers]
342 ************************************************************************/
343 /* [17.17.1 - edgeDelayWhile]
344 * The Edge Delay timer. The time remaining, in the absence of a received
345 * BPDU, before this port is identified as an operEdgePort.
347 uint16_t edge_delay_while OVS_GUARDED_BY(rstp_mutex);
349 /* [17.17.2 - fdWhile]
350 * The Forward Delay timer. Used to delay Port State transitions until
351 * other Bridges have received spanning tree information.
353 uint16_t fd_while OVS_GUARDED_BY(rstp_mutex);
355 /* [17.17.3 - helloWhen]
356 * The Hello timer. Used to ensure that at least one BPDU is transmitted by
357 * a Designated Port in each HelloTime period.
359 uint16_t hello_when OVS_GUARDED_BY(rstp_mutex);
361 /* [17.17.4 - mdelayWhile]
362 * The Migration Delay timer. Used by the Port Protocol Migration state
363 * machine to allow time for another RSTP Bridge on the same LAN to
364 * synchronize its migration state with this Port before the receipt of a
365 * BPDU can cause this Port to change the BPDU types it transmits.
366 * Initialized to MigrateTime (17.13.9).
368 uint16_t mdelay_while OVS_GUARDED_BY(rstp_mutex);
370 /* [17.17.5 - rbWhile]
371 * The Recent Backup timer. Maintained at its initial value, twice
372 * HelloTime, while the Port is a Backup Port.
374 uint16_t rb_while OVS_GUARDED_BY(rstp_mutex);
376 /* [17.17.6 - rcvdInfoWhile]
377 * The Received Info timer. The time remaining before the spanning tree
378 * information received by this Port [portPriority (17.19.21) and portTimes
379 * (17.19.22)] is aged out if not refreshed by the receipt of a further
380 * Configuration Message.
382 uint16_t rcvd_info_while OVS_GUARDED_BY(rstp_mutex);
384 /* [17.17.7 - rrWhile]
385 * The Recent Root timer.
387 uint16_t rr_while OVS_GUARDED_BY(rstp_mutex);
389 /* [17.17.8 - tcWhile]
390 * The Topology Change timer. TCN Messages are sent while this timer is
393 uint16_t tc_while OVS_GUARDED_BY(rstp_mutex);
396 /*************************************************************************
397 * The following variables are defined in [17.19 - Per-Port variables]
398 ************************************************************************/
400 /* [17.19.1 - ageingTime]
401 * Filtering database entries for this Port are aged out after ageingTime
402 * has elapsed since they were first created or refreshed by the Learning
404 * The value of this parameter is normally Ageing Time (7.9.2, Table 7-5),
405 * and is changed to FwdDelay (17.20.6) for a period of FwdDelay after
406 * fdbFlush (17.19.7) is set by the topology change state machine if
407 * stpVersion (17.19.7) is TRUE.
409 uint32_t ageing_time OVS_GUARDED_BY(rstp_mutex);
412 * Set if synced is set for all other Ports. An RST BPDU with the Agreement
413 * flag set is transmitted and proposed is reset when agree is first set,
414 * and when proposed is set.
415 * Initialized by Port Information state machine.
417 bool agree OVS_GUARDED_BY(rstp_mutex);
419 /* [17.19.3 - agreed]
420 * Set when an RST BPDU is received with a Port Role of Root, Alternate, or
421 * Backup Port, the Agreement flag set, and a message priority the same or
422 * worse than the port priority. When agreed is set, the Designated Port
423 * knows that its neighbouring Bridge has confirmed that it can proceed to
424 * the Forwarding state without further delay.
425 * Initialized by Port Information state machine.
427 bool agreed OVS_GUARDED_BY(rstp_mutex);
429 /* [17.19.4 - designatedPriority]
430 * The first four components of the Port's designated priority vector
431 * value, as defined in 17.6. The fifth component of the designated
432 * priority vector value is portId (17.19.19).
433 * (Fifth component of the structure must not be used)
435 struct rstp_priority_vector designated_priority_vector OVS_GUARDED_BY(rstp_mutex);
437 /* [17.19.5 - designatedTimes]
438 * The designatedTimes variable comprises the set of timer parameter values
439 * (Message Age, Max Age, Forward Delay, and Hello Time) that used to
440 * update Port Times when updtInfo is set. Updated by the updtRolesTree()
441 * procedure (17.21.25).
443 struct rstp_times designated_times OVS_GUARDED_BY(rstp_mutex);
445 /* [17.19.6 - disputed] */
446 bool disputed OVS_GUARDED_BY(rstp_mutex);
448 /* [17.19.7 - fdbFlush]
449 * A boolean. Set by the topology change state machine to instruct the
450 * filtering database to remove all entries for this Port, immediately if
451 * rstpVersion (17.20.11) is TRUE, or by rapid ageing (17.19.1) if
452 * stpVersion (17.20.12) is TRUE. Reset by the filtering database once the
454 * removed if rstpVersion is TRUE, and immediately if stpVersion is TRUE.
456 uint8_t fdb_flush OVS_GUARDED_BY(rstp_mutex);
458 /* [17.19.8 - forward]
459 * Initialized by Port State Transition state machine.
461 bool forward OVS_GUARDED_BY(rstp_mutex);
463 /* [17.19.9 - forwarding]
464 * Initialized by Port State Transition state machine.
466 bool forwarding OVS_GUARDED_BY(rstp_mutex);
468 /* [17.19.10 - infoIs]
469 * A variable that takes the values Mine, Aged, Received, or Disabled, to
470 * indicate the origin/state of the Port's Spanning Tree information
471 * (portInfo) held for the Port, as follows:
472 * a) If infoIs is Received, the port has received current (not aged out)
473 * information from the Designated Bridge for the attached LAN (a
474 * point-to-point bridge link being a special case of a LAN).
475 * b) If infoIs is Mine, information for the port has been derived from
476 * the Root Port for the Bridge (with the addition of root port cost
477 * information). This includes the possibility that the Root Port is
478 * "Port 0," i.e., the bridge is the Root Bridge for the Bridged Local
480 * c) If infoIs is Aged, information from the Root Bridge has been aged
481 * out. Just as for "reselect" (see 17.19.34), the state machine does
482 * not formally allow the "Aged" state to persist. However, if there is
483 * a delay in recomputing the new root port, correct processing of a
484 * received BPDU is specified.
485 * d) Finally if the port is disabled, infoIs is Disabled.
487 enum rstp_info_is info_is OVS_GUARDED_BY(rstp_mutex);
489 /* [17.19.11 - learn]
490 * Initialized by Port State Transition state machine.
492 bool learn OVS_GUARDED_BY(rstp_mutex);
494 /* [17.19.12 - learning]
495 * Initialized by Port State Transition state machine.
497 bool learning OVS_GUARDED_BY(rstp_mutex);
499 /* [17.19.13 - mcheck]
500 * A boolean. May be set by management to force the Port Protocol Migration
501 * state machine to transmit RST BPDUs for a MigrateTime (17.13.9) period,
502 * to test whether all STP Bridges (17.4) on the attached LAN have been
503 * removed and the Port can continue to transmit RSTP BPDUs. Setting mcheck
504 * has no effect if stpVersion (17.20.12) is TRUE, i.e., the Bridge is
505 * operating in STP Compatibility mode.
507 bool mcheck OVS_GUARDED_BY(rstp_mutex);
509 /* [17.19.14 - msgPriority]
510 * The first four components of the message priority vector conveyed in a
511 * received BPDU, as defined in 17.6.
512 * (Fifth component of the structure must not be used).
514 struct rstp_priority_vector msg_priority OVS_GUARDED_BY(rstp_mutex);
516 /* [17.19.15 - msgTimes]
517 * The msgTimes variable comprises the timer parameter values (Message Age,
518 * Max Age, Forward Delay, and Hello Time) conveyed in a received BPDU.
520 struct rstp_times msg_times OVS_GUARDED_BY(rstp_mutex);
522 /* [17.19.16 - newInfo]
523 * A boolean. Set if a BPDU is to be transmitted. Reset by the Port
524 * Transmit state machine.
526 bool new_info OVS_GUARDED_BY(rstp_mutex);
528 /* [17.19.17 - operEdge]
529 * A boolean. The value of the operEdgePort parameter, as determined by the
530 * operation of the Bridge Detection state machine (17.25).
532 bool oper_edge OVS_GUARDED_BY(rstp_mutex);
534 /* [17.19.18 - portEnabled]
535 * A boolean. Set if the Bridge's MAC Relay Entity and Spanning Tree
536 * Protocol Entity can use the MAC Service provided by the Port's MAC
537 * entity to transmit and receive frames to and from the attached LAN,
538 * i.e., portEnabled is TRUE if and only if:
539 * a) MAC_Operational (6.4.2) is TRUE; and
540 * b) Administrative Bridge Port State (14.8.2.2) for the Port is
542 * c) AuthControlledPortStatus is Authorized [if the port is a network
543 * access port (IEEE Std 802.1X)].
545 bool port_enabled OVS_GUARDED_BY(rstp_mutex);
547 /* [17.19.19 - portId]
548 * The Port Identifier. This variable forms the fifth component of the port
549 * priority and designated priority vectors defined in 17.6.
551 uint16_t port_id OVS_GUARDED_BY(rstp_mutex);
553 /* [17.19.21 - portPriority]
554 * The first four components of the Port's port priority vector value, as
556 * (Fifth component of the structure must not be used)
558 struct rstp_priority_vector port_priority OVS_GUARDED_BY(rstp_mutex);
560 /* [17.19.22 - portTimes]
561 * The portTimes variable comprises the Port's timer parameter values
562 * (Message Age, Max Age, Forward Delay, and Hello Time). These timer
563 * values are used in BPDUs transmitted from the Port.
565 struct rstp_times port_times OVS_GUARDED_BY(rstp_mutex);
567 /* [17.19.23 - proposed]
568 * Set when an RST BPDU with a Designated Port role and the Proposal flag
569 * set is received. If agree is not set, proposed causes sync to be set for
570 * all other Ports.of the Bridge.
572 bool proposed OVS_GUARDED_BY(rstp_mutex);
574 /* [17.19.24 - proposing]
575 * Set by a Designated Port that is not Forwarding, and conveyed to the
576 * Root Port or Alternate Port of a neighboring Bridge in the Proposal flag
577 * of an RST BPDU (9.3.3).
579 bool proposing OVS_GUARDED_BY(rstp_mutex);
581 /* [17.19.25 - rcvdBPDU]
582 * A boolean. Set by system dependent processes, this variable notifies the
583 * Port Receive state machine (17.23) when a valid (9.3.4) Configuration,
584 * TCN, or RST BPDU (9.3.1, 9.3.2, 9.3.3) is received on the Port. Reset
585 * by the Port Receive state machine.
587 bool rcvd_bpdu OVS_GUARDED_BY(rstp_mutex);
589 /* [17.19.26 - rcvdInfo]
590 * Set to the result of the rcvInfo() procedure (17.21.8).
592 enum rstp_rcvd_info rcvd_info OVS_GUARDED_BY(rstp_mutex);
594 /* [17.19.27 - rcvdMsg] */
595 bool rcvd_msg OVS_GUARDED_BY(rstp_mutex);
597 /* [17.19.28 - rcvdRSTP] */
598 bool rcvd_rstp OVS_GUARDED_BY(rstp_mutex);
600 /* [17.19.29 - rcvdSTP] */
601 bool rcvd_stp OVS_GUARDED_BY(rstp_mutex);
603 /* [17.19.30 - rcvdTc] */
604 bool rcvd_tc OVS_GUARDED_BY(rstp_mutex);
606 /* [17.19.31 - rcvdTcAck] */
607 bool rcvd_tc_ack OVS_GUARDED_BY(rstp_mutex);
609 /* [17.19.32 - rcvdTcn] */
610 bool rcvd_tcn OVS_GUARDED_BY(rstp_mutex);
612 /* [17.19.33 - reRoot] */
613 bool re_root OVS_GUARDED_BY(rstp_mutex);
615 /* [17.19.34 - reselect] */
616 bool reselect OVS_GUARDED_BY(rstp_mutex);
619 * The assigned Port Role (17.7).
621 enum rstp_port_role role OVS_GUARDED_BY(rstp_mutex);
623 /* [17.19.36 - selected]
624 * A boolean. See 17.28, 17.21.16.
626 bool selected OVS_GUARDED_BY(rstp_mutex);
628 /* [17.19.37 - selectedRole]
629 * The newly computed role for the Port (17.7, 17.28, 17.21.25, 17.19.35).
631 enum rstp_port_role selected_role OVS_GUARDED_BY(rstp_mutex);
633 /* [17.19.38 - sendRSTP]
634 * A boolean. See 17.24, 17.26.
636 bool send_rstp OVS_GUARDED_BY(rstp_mutex);
639 * A boolean. See 17.10.
641 bool sync OVS_GUARDED_BY(rstp_mutex);
643 /* [17.19.40 - synced]
644 * A boolean. See 17.10.
646 bool synced OVS_GUARDED_BY(rstp_mutex);
648 /* [17.19.41 - tcAck]
649 * A boolean. Set if a Configuration Message with a topology change
650 * acknowledge flag set is to be transmitted.
652 bool tc_ack OVS_GUARDED_BY(rstp_mutex);
654 /* [17.19.42 - tcProp]
655 * A boolean. Set by the Topology Change state machine of any other Port,
656 * to indicate that a topology change should be propagated through this
659 bool tc_prop OVS_GUARDED_BY(rstp_mutex);
662 * A boolean. See 17.22.
664 bool tick OVS_GUARDED_BY(rstp_mutex);
666 /* [17.19.44 - txCount]
667 * A counter. Incremented by the Port Transmission (17.26) state machine on
668 * every BPDU transmission, and decremented used by the Port Timers state
669 * machine (17.22) once a second. Transmissions are delayed if txCount
670 * reaches TxHoldCount (17.13.12).
672 uint16_t tx_count OVS_GUARDED_BY(rstp_mutex);
674 /* [17.19.45 - updtInfo]
675 * A boolean. Set by the Port Role Selection state machine (17.28,
676 * 17.21.25) to tell the Port Information state machine that it should copy
677 * designatedPriority to portPriority and designatedTimes to portTimes.
679 bool updt_info OVS_GUARDED_BY(rstp_mutex);
681 /* Counter for RSTP received frames - for rstpd */
682 uint32_t rx_rstp_bpdu_cnt;
684 /* Counter for bad RSTP received frames */
685 uint32_t error_count OVS_GUARDED_BY(rstp_mutex);
687 /* [14.8.2.1.3] Outputs
688 * a) Uptime count in seconds of the time elapsed since the Port was last
689 * reset or initialized.
691 uint32_t uptime OVS_GUARDED_BY(rstp_mutex);
693 enum rstp_state rstp_state OVS_GUARDED_BY(rstp_mutex);
694 bool state_changed OVS_GUARDED_BY(rstp_mutex);
696 /* Per-port state machines state */
697 enum port_receive_state_machine port_receive_sm_state OVS_GUARDED_BY(rstp_mutex);
698 enum port_protocol_migration_state_machine port_protocol_migration_sm_state OVS_GUARDED_BY(rstp_mutex);
699 enum bridge_detection_state_machine bridge_detection_sm_state OVS_GUARDED_BY(rstp_mutex);
700 enum port_transmit_state_machine port_transmit_sm_state OVS_GUARDED_BY(rstp_mutex);
701 enum port_information_state_machine port_information_sm_state OVS_GUARDED_BY(rstp_mutex);
702 enum port_role_transition_state_machine port_role_transition_sm_state OVS_GUARDED_BY(rstp_mutex);
703 enum port_state_transition_state_machine port_state_transition_sm_state OVS_GUARDED_BY(rstp_mutex);
704 enum topology_change_state_machine topology_change_sm_state OVS_GUARDED_BY(rstp_mutex);
708 struct ovs_list node OVS_GUARDED_BY(rstp_mutex); /* In rstp instances list */
709 char *name; /* Bridge name. */
711 /* Changes in last SM execution. */
712 bool changes OVS_GUARDED_BY(rstp_mutex);
714 /* Per-bridge state machines state */
715 enum port_role_selection_state_machine port_role_selection_sm_state OVS_GUARDED_BY(rstp_mutex);
717 /* Bridge MAC address
718 * (stored in the least significant 48 bits of rstp_identifier).
720 rstp_identifier address OVS_GUARDED_BY(rstp_mutex); /* [7.12.5] */
722 /* Bridge priority */
723 uint16_t priority OVS_GUARDED_BY(rstp_mutex); /* Valid values: 0-61440 in steps of 4096 */
725 /*************************************************************************
726 * [17.3 - RSTP performance parameters]
727 ************************************************************************/
730 * The Spanning Tree Protocol Entity shall be reinitialized, as specified
731 * by the assertion of BEGIN (17.18.1) in the state machine specification,
732 * if the following parameters are modified:
733 * a) Force Protocol Version (17.13.4)
735 * The spanning tree priority vectors and Port Role assignments for a
736 * Bridge shall be recomputed, as specified by the operation of the Port
737 * Role Selection state machine (17.28) by clearing selected (17.19.36) and
738 * setting reselect (17.19.34) for any Port or Ports for which the
739 * following parameters are modified:
740 * b) Bridge Identifier Priority (17.13.7)
741 * c) Port Identifier Priority (17.13.10)
742 * d) Port Path Cost (17.13.11)
744 * If the Transmit Hold Count is modified the value of txCount (17.19.44)
745 * for all Ports shall be set to zero.
747 * The RSTP specification permits changes in other performance parameters
748 * without exceptional actions.
752 /* [17.13.2 - Ageing Time]
753 * The Ageing Time parameter for the Bridge (7.9.2, Table 7-5).
755 uint32_t ageing_time OVS_GUARDED_BY(rstp_mutex);
757 /* [17.13.4 - Force Protocol Version]
758 * The Force Protocol Version parameter for the Bridge (17.4, 14.8.1).
759 * This can take the value 0 (STP Compatibility mode) or 2 (the default,
762 enum rstp_force_protocol_version force_protocol_version OVS_GUARDED_BY(rstp_mutex);
764 /* [17.13.5 - Bridge Forward Delay]
765 * The delay used by STP Bridges (17.4) to transition Root and Designated
766 * Ports to Forwarding (Table 17-1).
768 uint16_t bridge_forward_delay OVS_GUARDED_BY(rstp_mutex);
770 /* [17.13.6 - Bridge Hello Time]
771 * The interval between periodic transmissions of Configuration Messages
772 * by Designated Ports (Table 17-1).
774 uint16_t bridge_hello_time OVS_GUARDED_BY(rstp_mutex);
776 /* [17.13.8 - Bridge Max Age]
777 * The maximum age of the information transmitted by the Bridge when it is
778 * the Root Bridge (Table 17-1).
780 uint16_t bridge_max_age OVS_GUARDED_BY(rstp_mutex);
782 /* [17.13.9 - Migrate Time]
783 * The initial value of the mdelayWhile and edgeDelayWhile timers (17.17.4,
784 * 17.17.1), fixed for all RSTP implementations conforming to this
785 * specification (Table 17-1).
787 uint16_t migrate_time OVS_GUARDED_BY(rstp_mutex);
789 /* [17.13.12 - Transmit Hold Count]
790 * The Transmit Hold Count (Table 17-1) used by the Port Transmit state
791 * machine to limit transmission rate.
793 uint16_t transmit_hold_count OVS_GUARDED_BY(rstp_mutex);
796 /*************************************************************************
797 * The following variables are defined in [17.18 - Per-Bridge variables]
798 ************************************************************************/
801 * A Boolean controlled by the system initialization (17.16). If TRUE
802 * causes all state machines, including per Port state machines, to
803 * continuously execute their initial state.
805 bool begin OVS_GUARDED_BY(rstp_mutex);
807 /* [17.18.2 BridgeIdentifier]
808 * The unique Bridge Identifier assigned to this Bridge, comprising two
809 * components: the Bridge Identifier Priority, which may be modified by
810 * management (see 9.2.5 and 14.8.1.2) and is the more significant when
811 * Bridge Identifiers are compared, and a component derived from the Bridge
812 * Address (7.12.5), which guarantees uniqueness of the Bridge Identifiers
813 * of different Bridges.
815 rstp_identifier bridge_identifier OVS_GUARDED_BY(rstp_mutex);
817 /* [17.8.3 BridgePriority]
818 * The bridge priority vector, as defined in 17.6. The first (RootBridgeID)
819 * and third (DesignatedBridgeID) components are both equal to the value
820 * of the Bridge Identifier (17.18.2). The other components are zero.
822 struct rstp_priority_vector bridge_priority OVS_GUARDED_BY(rstp_mutex);
824 /* [17.18.4 - BridgeTimes]
825 * BridgeTimes comprises four components: the current values of Bridge
826 * Forward Delay, Bridge Hello Time, Bridge Max Age (17.13, Table 17-1),
827 * and a Message Age of zero.
829 struct rstp_times bridge_times OVS_GUARDED_BY(rstp_mutex);
831 /* [17.18.6 - rootPriority]
832 * The first four components of the Bridge's root priority vector, as
835 struct rstp_priority_vector root_priority OVS_GUARDED_BY(rstp_mutex);
837 /* [17.18.5 - rootPortId]
838 * The Port Identifier of the Root Port. This is the fifth component of
839 * the root priority vector, as defined in 17.6.
841 uint16_t root_port_id OVS_GUARDED_BY(rstp_mutex);
843 /* [17.18.7 - rootTimes]
844 * The rootTimes variable comprises the Bridge's operational timer
845 * parameter values (Message Age, Max Age, Forward Delay, and Hello Time),
846 * derived from the values stored in portTimes (17.19.22) for the Root Port
847 * or from BridgeTimes (17.18.4).
849 struct rstp_times root_times OVS_GUARDED_BY(rstp_mutex);
851 /* 17.20 State machine conditions and parameters */
853 /* [17.20.11] rstpVersion
854 * TRUE if Force Protocol Version (17.13.4) is greater than or equal to 2.
856 bool rstp_version OVS_GUARDED_BY(rstp_mutex);
858 /* [17.20.12] stpVersion
859 * TRUE if Force Protocol Version (17.13.4) is less than 2.
861 bool stp_version OVS_GUARDED_BY(rstp_mutex);
864 struct hmap ports OVS_GUARDED_BY(rstp_mutex);
866 struct ovs_refcount ref_cnt;
868 /* Interface to client. */
869 void (*send_bpdu)(struct dp_packet *bpdu, void *port_aux, void *rstp_aux);
877 #endif /* rstp-common.h */