]> git.proxmox.com Git - mirror_ovs.git/blob - lib/lacp.h
lldp: validate a bit more received LLDP frames
[mirror_ovs.git] / lib / lacp.h
1 /*
2 * Copyright (c) 2011 Nicira, Inc.
3 *
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:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 #ifndef LACP_H
18 #define LACP_H 1
19
20 #include <stdbool.h>
21 #include <stdint.h>
22 #include "packets.h"
23
24 /* LACP Protocol Implementation. */
25
26 enum lacp_status {
27 LACP_NEGOTIATED, /* Successful LACP negotations. */
28 LACP_CONFIGURED, /* LACP is enabled but not negotiated. */
29 LACP_DISABLED /* LACP is not enabled. */
30 };
31
32 struct lacp_settings {
33 char *name; /* Name (for debugging). */
34 struct eth_addr id; /* System ID. Must be nonzero. */
35 uint16_t priority; /* System priority. */
36 bool active; /* Active or passive mode? */
37 bool fast; /* Fast or slow probe interval. */
38 bool fallback_ab_cfg; /* Fallback to BM_SLB on LACP failure. */
39 };
40
41 void lacp_init(void);
42 struct lacp *lacp_create(void);
43 void lacp_unref(struct lacp *);
44 struct lacp *lacp_ref(const struct lacp *);
45
46 void lacp_configure(struct lacp *, const struct lacp_settings *);
47 bool lacp_is_active(const struct lacp *);
48
49 bool lacp_process_packet(struct lacp *, const void *member,
50 const struct dp_packet *packet);
51 enum lacp_status lacp_status(const struct lacp *);
52
53 struct lacp_member_settings {
54 char *name; /* Name (for debugging). */
55 uint16_t id; /* Port ID. */
56 uint16_t priority; /* Port priority. */
57 uint16_t key; /* Aggregation key. */
58 };
59
60 void lacp_member_register(struct lacp *, void *member_,
61 const struct lacp_member_settings *);
62 void lacp_member_unregister(struct lacp *, const void *member);
63 void lacp_member_carrier_changed(const struct lacp *, const void *member,
64 bool carrier_up);
65 bool lacp_member_may_enable(const struct lacp *, const void *member);
66 bool lacp_member_is_current(const struct lacp *, const void *member_);
67
68 /* Callback function for lacp_run() for sending a LACP PDU. */
69 typedef void lacp_send_pdu(void *member, const void *pdu, size_t pdu_size);
70
71 void lacp_run(struct lacp *, lacp_send_pdu *);
72 void lacp_wait(struct lacp *);
73
74 struct lacp_member_stats {
75 /* id */
76 struct eth_addr dot3adAggPortActorSystemID;
77 struct eth_addr dot3adAggPortPartnerOperSystemID;
78 uint32_t dot3adAggPortAttachedAggID;
79 /* state */
80 uint8_t dot3adAggPortActorAdminState;
81 uint8_t dot3adAggPortActorOperState;
82 uint8_t dot3adAggPortPartnerAdminState;
83 uint8_t dot3adAggPortPartnerOperState;
84 /* counters */
85 uint32_t dot3adAggPortStatsLACPDUsRx;
86 /* uint32_t dot3adAggPortStatsMarkerPDUsRx; */
87 /* uint32_t dot3adAggPortStatsMarkerResponsePDUsRx; */
88 /* uint32_t dot3adAggPortStatsUnknownRx; */
89 uint32_t dot3adAggPortStatsIllegalRx;
90 uint32_t dot3adAggPortStatsLACPDUsTx;
91 /* uint32_t dot3adAggPortStatsMarkerPDUsTx; */
92 /* uint32_t dot3adAggPortStatsMarkerResponsePDUsTx; */
93 };
94
95 bool lacp_get_member_stats(const struct lacp *, const void *member_,
96 struct lacp_member_stats *);
97
98 #endif /* lacp.h */