summaryrefslogtreecommitdiffstats
path: root/src/plugins/lacp/protocol.h
diff options
context:
space:
mode:
authorSteven <sluong@cisco.com>2017-12-20 12:43:01 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2018-03-21 21:02:15 +0000
commit9cd2d7a5a4fafadb65d772c48109d55d1e19d425 (patch)
tree4a9e0665be0096ee6bfc2235388f90b276b23814 /src/plugins/lacp/protocol.h
parent43ebe29b6ea1107c30311cfb3dbd8190282903d0 (diff)
bond: Add bonding driver and LACP protocol
Add bonding driver to support creation of bond interface which composes of multiple slave interfaces. The slave interfaces could be physical interfaces, or just any virtual interfaces. For example, memif interfaces. The syntax to create a bond interface is create bond mode <lacp | xor | acitve-backup | broadcast | round-robin> To enslave an interface to the bond interface, enslave interface TenGigabitEthernet6/0/0 to BondEthernet0 Please see src/plugins/lacp/lacp_doc.md for more examples and additional options. LACP is a control plane protocol which manages and monitors the status of the slave interfaces. The protocol is part of 802.3ad standard. This patch implements LACPv1. LACPv2 is not supported. To enable LACP on the bond interface, specify "mode lacp" when the bond interface is created. The syntax to enslave a slave interface is the same as other bonding modes. Change-Id: I06581d3b87635972f9f0e1ec50b67560fc13e26c Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/plugins/lacp/protocol.h')
-rw-r--r--src/plugins/lacp/protocol.h178
1 files changed, 178 insertions, 0 deletions
diff --git a/src/plugins/lacp/protocol.h b/src/plugins/lacp/protocol.h
new file mode 100644
index 00000000000..05a3f04a227
--- /dev/null
+++ b/src/plugins/lacp/protocol.h
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __included_lacp_protocol_h__
+#define __included_lacp_protocol_h__
+
+#include <vnet/ethernet/ethernet.h>
+#include <vnet/bonding/node.h>
+
+#define LACP_CHURN_DETECTION_TIME 60
+#define LACP_AGGREGATE_WAIT_TIME 2.0
+
+#define LACP_SUBTYPE 1
+#define LACP_ACTOR_LACP_VERSION 1
+
+#define foreach_lacp_tlv \
+ _ (TERMINATOR_INFORMATION, 0) \
+ _ (ACTOR_INFORMATION, 1) \
+ _ (PARTNER_INFORMATION , 2) \
+ _ (COLLECTOR_INFORMATION, 3)
+
+typedef enum
+{
+#define _(f,n) LACP_##f = (n),
+ foreach_lacp_tlv
+#undef _
+} lacp_tlv_t;
+
+#define foreach_lacp_port \
+ _ (UNSELECTED, 0) \
+ _ (SELECTED, 1) \
+ _ (STANDBY, 2)
+
+typedef enum
+{
+#define _(f,n) LACP_PORT_##f = (n),
+ foreach_lacp_port
+#undef _
+} lacp_port_t;
+
+/* Port state */
+#define foreach_lacp_state \
+ _(0, LACP_ACTIVITY, "activity") \
+ _(1, LACP_TIMEOUT, "lacp timeout") \
+ _(2, AGGREGATION, "aggregation") \
+ _(3, SYNCHRONIZATION, "synchronization") \
+ _(4, COLLECTING, "collecting") \
+ _(5, DISTRIBUTING, "distributing") \
+ _(6, DEFAULTED, "defaulted") \
+ _(7, EXPIRED, "expired")
+
+typedef enum
+{
+#define _(a, b, c) LACP_STATE_##b = (1 << a),
+ foreach_lacp_state
+#undef _
+} lacp_state_t;
+
+#define foreach_lacp_state_flag \
+ _(0, LACP_STATE_LACP_ACTIViTY, "activity") \
+ _(1, LACP_STATE_LACP_TIMEOUT, "lacp timeout") \
+ _(2, LACP_STATE_AGGREGATION, "aggregation") \
+ _(3, LACP_STATE_SYNCHRONIZATION, "synchronization") \
+ _(4, LACP_STATE_COLLECTIING, "collecting") \
+ _(5, LACP_STATE_DISTRIBUTING, "distributing") \
+ _(6, LACP_STATE_DEFAULTED, "defaulted") \
+ _(7, LACP_STATE_EXPIRED, "expired")
+
+typedef struct
+{
+ u8 bit;
+ char *str;
+} lacp_state_struct;
+
+typedef struct
+{
+ u8 bit;
+ char *str;
+} lacp_event_struct;
+
+#define LACP_MAX_TX_IN_SECOND 3
+#define LACP_DEFAULT_PORT_PRIORITY 0x00ff
+#define LACP_DEFAULT_SYSTEM_PRIORITY 0xffff
+
+typedef CLIB_PACKED (struct
+ {
+ u8 tlv_type;
+ u8 tlv_length;
+ lacp_port_info_t port_info; u8 reserved[3];
+ }) lacp_actor_partner_t;
+
+typedef CLIB_PACKED (struct
+ {
+ u8 tlv_type; u8 tlv_length; u16 max_delay;
+ u8 reserved[12];
+ }) lacp_collector_t;
+
+typedef CLIB_PACKED (struct
+ {
+ u8 tlv_type; u8 tlv_length;
+ u8 pad[50];
+ }) lacp_terminator_t;
+
+typedef CLIB_PACKED (struct
+ {
+ u8 subtype; u8 version_number;
+ lacp_actor_partner_t actor; lacp_actor_partner_t partner;
+ lacp_collector_t collector; lacp_terminator_t terminator;
+ }) lacp_pdu_t;
+
+typedef CLIB_PACKED (struct
+ {
+ ethernet_header_t ethernet; lacp_pdu_t lacp;
+ }) ethernet_lacp_pdu_t;
+
+#define MARKER_SUBTYPE 2
+#define MARKER_PROTOCOL_VERSION 1
+
+#define foreach_marker_tlv \
+ _ (TERMINATOR_INFORMATION, 0) \
+ _ (INFORMATION, 1) \
+ _ (RESPONSE_INFORMATION , 2)
+
+typedef enum
+{
+#define _(f,n) MARKER_##f = (n),
+ foreach_marker_tlv
+#undef _
+} marker_tlv_t;
+
+typedef CLIB_PACKED (struct
+ {
+ u8 tlv_type; u8 tlv_length;
+ u8 reserved[90];
+ }) marker_terminator_t;
+
+typedef CLIB_PACKED (struct
+ {
+ u8 tlv_type;
+ u8 tlv_length;
+ u16 requester_port; u8 requester_system[6];
+ u32 requester_transaction_id; u8 pad[2];
+ }) marker_information_t;
+
+typedef CLIB_PACKED (struct
+ {
+ u8 subtype;
+ u8 version_number;
+ marker_information_t marker_info;
+ marker_terminator_t terminator;
+ }) marker_pdu_t;
+
+typedef CLIB_PACKED (struct
+ {
+ ethernet_header_t ethernet; marker_pdu_t marker;
+ }) ethernet_marker_pdu_t;
+
+#endif /* __included_lacp_protocol_h__ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */