2011-02-28 14:48:06 -08:00
|
|
|
/*
|
2012-05-02 15:21:36 -07:00
|
|
|
* Copyright (c) 2011 Nicira, Inc.
|
2011-02-28 14:48:06 -08:00
|
|
|
*
|
|
|
|
|
* 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 LACP_H
|
|
|
|
|
#define LACP_H 1
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
2011-03-21 13:15:31 -07:00
|
|
|
#include "packets.h"
|
2011-02-28 14:48:06 -08:00
|
|
|
|
2011-04-18 12:33:14 -07:00
|
|
|
/* LACP Protocol Implementation. */
|
|
|
|
|
|
2011-11-28 13:54:08 -08:00
|
|
|
enum lacp_status {
|
|
|
|
|
LACP_NEGOTIATED, /* Successful LACP negotations. */
|
|
|
|
|
LACP_CONFIGURED, /* LACP is enabled but not negotiated. */
|
|
|
|
|
LACP_DISABLED /* LACP is not enabled. */
|
|
|
|
|
};
|
|
|
|
|
|
2011-03-21 14:30:33 -07:00
|
|
|
struct lacp_settings {
|
2011-11-30 18:01:32 -08:00
|
|
|
char *name; /* Name (for debugging). */
|
2015-08-28 14:55:11 -07:00
|
|
|
struct eth_addr id; /* System ID. Must be nonzero. */
|
2011-11-30 18:01:32 -08:00
|
|
|
uint16_t priority; /* System priority. */
|
|
|
|
|
bool active; /* Active or passive mode? */
|
2012-04-16 14:55:58 -07:00
|
|
|
bool fast; /* Fast or slow probe interval. */
|
2013-11-04 23:07:10 +00:00
|
|
|
bool fallback_ab_cfg; /* Fallback to BM_SLB on LACP failure. */
|
2011-03-21 14:30:33 -07:00
|
|
|
};
|
2011-02-28 14:48:06 -08:00
|
|
|
|
|
|
|
|
void lacp_init(void);
|
|
|
|
|
struct lacp *lacp_create(void);
|
2013-06-18 16:44:23 -07:00
|
|
|
void lacp_unref(struct lacp *);
|
|
|
|
|
struct lacp *lacp_ref(const struct lacp *);
|
2011-03-21 12:49:44 -07:00
|
|
|
|
2011-03-21 14:30:33 -07:00
|
|
|
void lacp_configure(struct lacp *, const struct lacp_settings *);
|
2011-03-21 12:49:44 -07:00
|
|
|
bool lacp_is_active(const struct lacp *);
|
|
|
|
|
|
2011-08-30 18:17:27 -07:00
|
|
|
void lacp_process_packet(struct lacp *, const void *slave,
|
2015-02-22 03:21:09 -08:00
|
|
|
const struct dp_packet *packet);
|
2011-11-28 13:54:08 -08:00
|
|
|
enum lacp_status lacp_status(const struct lacp *);
|
2011-02-28 14:48:06 -08:00
|
|
|
|
2011-03-21 14:30:33 -07:00
|
|
|
struct lacp_slave_settings {
|
2011-11-30 18:01:32 -08:00
|
|
|
char *name; /* Name (for debugging). */
|
|
|
|
|
uint16_t id; /* Port ID. */
|
|
|
|
|
uint16_t priority; /* Port priority. */
|
|
|
|
|
uint16_t key; /* Aggregation key. */
|
2011-03-21 14:30:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void lacp_slave_register(struct lacp *, void *slave_,
|
|
|
|
|
const struct lacp_slave_settings *);
|
2011-02-28 14:48:06 -08:00
|
|
|
void lacp_slave_unregister(struct lacp *, const void *slave);
|
|
|
|
|
void lacp_slave_carrier_changed(const struct lacp *, const void *slave);
|
|
|
|
|
bool lacp_slave_may_enable(const struct lacp *, const void *slave);
|
2011-04-13 15:44:37 -07:00
|
|
|
bool lacp_slave_is_current(const struct lacp *, const void *slave_);
|
2011-02-28 14:48:06 -08:00
|
|
|
|
2011-03-21 14:30:33 -07:00
|
|
|
/* Callback function for lacp_run() for sending a LACP PDU. */
|
2011-08-30 18:17:27 -07:00
|
|
|
typedef void lacp_send_pdu(void *slave, const void *pdu, size_t pdu_size);
|
2011-03-21 14:30:33 -07:00
|
|
|
|
2011-02-28 14:48:06 -08:00
|
|
|
void lacp_run(struct lacp *, lacp_send_pdu *);
|
|
|
|
|
void lacp_wait(struct lacp *);
|
|
|
|
|
|
2014-06-27 11:19:59 -07:00
|
|
|
struct lacp_slave_stats {
|
|
|
|
|
/* id */
|
2015-08-28 14:55:11 -07:00
|
|
|
struct eth_addr dot3adAggPortActorSystemID;
|
|
|
|
|
struct eth_addr dot3adAggPortPartnerOperSystemID;
|
2014-06-27 11:19:59 -07:00
|
|
|
uint32_t dot3adAggPortAttachedAggID;
|
|
|
|
|
/* state */
|
|
|
|
|
uint8_t dot3adAggPortActorAdminState;
|
|
|
|
|
uint8_t dot3adAggPortActorOperState;
|
|
|
|
|
uint8_t dot3adAggPortPartnerAdminState;
|
|
|
|
|
uint8_t dot3adAggPortPartnerOperState;
|
|
|
|
|
/* counters */
|
|
|
|
|
uint32_t dot3adAggPortStatsLACPDUsRx;
|
|
|
|
|
/* uint32_t dot3adAggPortStatsMarkerPDUsRx; */
|
|
|
|
|
/* uint32_t dot3adAggPortStatsMarkerResponsePDUsRx; */
|
|
|
|
|
/* uint32_t dot3adAggPortStatsUnknownRx; */
|
|
|
|
|
uint32_t dot3adAggPortStatsIllegalRx;
|
|
|
|
|
uint32_t dot3adAggPortStatsLACPDUsTx;
|
|
|
|
|
/* uint32_t dot3adAggPortStatsMarkerPDUsTx; */
|
|
|
|
|
/* uint32_t dot3adAggPortStatsMarkerResponsePDUsTx; */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool lacp_get_slave_stats(const struct lacp *, const void *slave_, struct lacp_slave_stats *);
|
|
|
|
|
|
2011-02-28 14:48:06 -08:00
|
|
|
#endif /* lacp.h */
|