4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef RTE_ETH_BOND_8023AD_H_
35 #define RTE_ETH_BOND_8023AD_H_
37 #include <rte_ether.h>
40 * Actor/partner states
42 #define STATE_LACP_ACTIVE 0x01
43 #define STATE_LACP_SHORT_TIMEOUT 0x02
44 #define STATE_AGGREGATION 0x04
45 #define STATE_SYNCHRONIZATION 0x08
46 #define STATE_COLLECTING 0x10
47 #define STATE_DISTRIBUTING 0x20
48 /** Partners parameters are defaulted */
49 #define STATE_DEFAULTED 0x40
50 #define STATE_EXPIRED 0x80
52 #define TLV_TYPE_ACTOR_INFORMATION 0x01
53 #define TLV_TYPE_PARTNER_INFORMATION 0x02
54 #define TLV_TYPE_COLLECTOR_INFORMATION 0x03
55 #define TLV_TYPE_TERMINATOR_INFORMATION 0x00
57 #define SLOW_SUBTYPE_LACP 0x01
58 #define SLOW_SUBTYPE_MARKER 0x02
60 #define MARKER_TLV_TYPE_INFO 0x01
61 #define MARKER_TLV_TYPE_RESP 0x02
63 enum rte_bond_8023ad_selection {
69 /** Generic slow protocol structure */
70 struct slow_protocol {
72 uint8_t reserved_119[119];
73 } __attribute__((__packed__));
75 /** Generic slow protocol frame type structure */
76 struct slow_protocol_frame {
77 struct ether_hdr eth_hdr;
78 struct slow_protocol slow_protocol;
79 } __attribute__((__packed__));
82 uint16_t system_priority;
83 /**< System priority (unused in current implementation) */
84 struct ether_addr system;
85 /**< System ID - Slave MAC address, same as bonding MAC address */
87 /**< Speed information (implementation dependednt) and duplex. */
88 uint16_t port_priority;
89 /**< Priority of this (unused in current implementation) */
91 /**< Port number. It corresponds to slave port id. */
92 } __attribute__((__packed__));
94 struct lacpdu_actor_partner_params {
95 uint8_t tlv_type_info;
97 struct port_params port_params;
99 uint8_t reserved_3[3];
100 } __attribute__((__packed__));
102 /** LACPDU structure (5.4.2 in 802.1AX documentation). */
105 uint8_t version_number;
107 struct lacpdu_actor_partner_params actor;
108 struct lacpdu_actor_partner_params partner;
110 uint8_t tlv_type_collector_info;
111 uint8_t collector_info_length;
112 uint16_t collector_max_delay;
113 uint8_t reserved_12[12];
115 uint8_t tlv_type_terminator;
116 uint8_t terminator_length;
117 uint8_t reserved_50[50];
118 } __attribute__((__packed__));
120 /** LACPDU frame: Contains ethernet header and LACPDU. */
121 struct lacpdu_header {
122 struct ether_hdr eth_hdr;
123 struct lacpdu lacpdu;
124 } __attribute__((__packed__));
128 uint8_t version_number;
130 uint8_t tlv_type_marker;
132 uint16_t requester_port;
133 struct ether_addr requester_system;
134 uint32_t requester_transaction_id;
135 uint8_t reserved_2[2];
137 uint8_t tlv_type_terminator;
138 uint8_t terminator_length;
139 uint8_t reserved_90[90];
140 } __attribute__((__packed__));
142 struct marker_header {
143 struct ether_hdr eth_hdr;
144 struct marker marker;
145 } __attribute__((__packed__));
147 struct rte_eth_bond_8023ad_conf {
148 uint32_t fast_periodic_ms;
149 uint32_t slow_periodic_ms;
150 uint32_t short_timeout_ms;
151 uint32_t long_timeout_ms;
152 uint32_t aggregate_wait_timeout_ms;
153 uint32_t tx_period_ms;
154 uint32_t rx_marker_period_ms;
155 uint32_t update_timeout_ms;
158 struct rte_eth_bond_8023ad_slave_info {
159 enum rte_bond_8023ad_selection selected;
161 struct port_params actor;
162 uint8_t partner_state;
163 struct port_params partner;
170 * Function returns current configuration of 802.3AX mode.
172 * @param port_id Bonding device id
173 * @param conf Pointer to timeout structure.
177 * -EINVAL if conf is NULL
180 rte_eth_bond_8023ad_conf_get(uint8_t port_id,
181 struct rte_eth_bond_8023ad_conf *conf);
186 * Function set new configuration of 802.3AX mode.
188 * @param port_id Bonding device id
189 * @param conf Configuration, if NULL set default configuration.
192 * -EINVAL if configuration is invalid.
195 rte_eth_bond_8023ad_setup(uint8_t port_id,
196 struct rte_eth_bond_8023ad_conf *conf);
201 * Function returns current state of given slave device.
203 * @param slave_id Port id of valid slave.
204 * @param conf buffer for configuration
207 * -EINVAL if conf is NULL or slave id is invalid (not a slave of given
208 * bonded device or is not inactive).
211 rte_eth_bond_8023ad_slave_info(uint8_t port_id, uint8_t slave_id,
212 struct rte_eth_bond_8023ad_slave_info *conf);
214 #endif /* RTE_ETH_BOND_8023AD_H_ */