mbuf: add Tx offloading flags for tunnels
[dpdk.git] / lib / librte_pmd_bond / rte_eth_bond_8023ad.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
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
16  *       distribution.
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.
20  *
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.
32  */
33
34 #ifndef RTE_ETH_BOND_8023AD_H_
35 #define RTE_ETH_BOND_8023AD_H_
36
37 #include <rte_ether.h>
38
39 /**
40  * Actor/partner states
41  */
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
51
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
56
57 #define SLOW_SUBTYPE_LACP                   0x01
58 #define SLOW_SUBTYPE_MARKER                 0x02
59
60 #define MARKER_TLV_TYPE_INFO                0x01
61 #define MARKER_TLV_TYPE_RESP                0x02
62
63 enum rte_bond_8023ad_selection {
64         UNSELECTED,
65         STANDBY,
66         SELECTED
67 };
68
69 /** Generic slow protocol structure */
70 struct slow_protocol {
71         uint8_t subtype;
72         uint8_t reserved_119[119];
73 } __attribute__((__packed__));
74
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__));
80
81 struct port_params {
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 */
86         uint16_t key;
87         /**< Speed information (implementation dependednt) and duplex. */
88         uint16_t port_priority;
89         /**< Priority of this (unused in current implementation) */
90         uint16_t port_number;
91         /**< Port number. It corresponds to slave port id. */
92 } __attribute__((__packed__));
93
94 struct lacpdu_actor_partner_params {
95         uint8_t tlv_type_info;
96         uint8_t info_length;
97         struct port_params port_params;
98         uint8_t state;
99         uint8_t reserved_3[3];
100 } __attribute__((__packed__));
101
102 /** LACPDU structure (5.4.2 in 802.1AX documentation). */
103 struct lacpdu {
104         uint8_t subtype;
105         uint8_t version_number;
106
107         struct lacpdu_actor_partner_params actor;
108         struct lacpdu_actor_partner_params partner;
109
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];
114
115         uint8_t tlv_type_terminator;
116         uint8_t terminator_length;
117         uint8_t reserved_50[50];
118 } __attribute__((__packed__));
119
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__));
125
126 struct marker {
127         uint8_t subtype;
128         uint8_t version_number;
129
130         uint8_t tlv_type_marker;
131         uint8_t info_length;
132         uint16_t requester_port;
133         struct ether_addr requester_system;
134         uint32_t requester_transaction_id;
135         uint8_t reserved_2[2];
136
137         uint8_t tlv_type_terminator;
138         uint8_t terminator_length;
139         uint8_t reserved_90[90];
140 } __attribute__((__packed__));
141
142 struct marker_header {
143         struct ether_hdr eth_hdr;
144         struct marker marker;
145 } __attribute__((__packed__));
146
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;
156 };
157
158 struct rte_eth_bond_8023ad_slave_info {
159         enum rte_bond_8023ad_selection selected;
160         uint8_t actor_state;
161         struct port_params actor;
162         uint8_t partner_state;
163         struct port_params partner;
164         uint8_t agg_port_id;
165 };
166
167 /**
168  * @internal
169  *
170  * Function returns current configuration of 802.3AX mode.
171  *
172  * @param port_id   Bonding device id
173  * @param conf          Pointer to timeout structure.
174  *
175  * @return
176  *   0 - if ok
177  *   -EINVAL if conf is NULL
178  */
179 int
180 rte_eth_bond_8023ad_conf_get(uint8_t port_id,
181                 struct rte_eth_bond_8023ad_conf *conf);
182
183 /**
184  * @internal
185  *
186  * Function set new configuration of 802.3AX mode.
187  *
188  * @param port_id   Bonding device id
189  * @param conf          Configuration, if NULL set default configuration.
190  * @return
191  *   0 - if ok
192  *   -EINVAL if configuration is invalid.
193  */
194 int
195 rte_eth_bond_8023ad_setup(uint8_t port_id,
196                 struct rte_eth_bond_8023ad_conf *conf);
197
198 /**
199  * @internal
200  *
201  * Function returns current state of given slave device.
202  *
203  * @param slave_id  Port id of valid slave.
204  * @param conf          buffer for configuration
205  * @return
206  *   0 - if ok
207  *   -EINVAL if conf is NULL or slave id is invalid (not a slave of given
208  *       bonded device or is not inactive).
209  */
210 int
211 rte_eth_bond_8023ad_slave_info(uint8_t port_id, uint8_t slave_id,
212                 struct rte_eth_bond_8023ad_slave_info *conf);
213
214 #endif /* RTE_ETH_BOND_8023AD_H_ */