2 * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
27 struct lacp_slave_settings;
31 /* How flows are balanced among bond slaves. */
33 BM_TCP, /* Transport Layer Load Balance. */
34 BM_SLB, /* Source Load Balance. */
35 BM_STABLE, /* Stable. */
36 BM_AB /* Active Backup. */
39 bool bond_mode_from_string(enum bond_mode *, const char *);
40 const char *bond_mode_to_string(enum bond_mode);
42 /* How to detect link status. */
43 enum bond_detect_mode {
44 BLSM_CARRIER, /* Use carrier. */
45 BLSM_MIIMON /* Poll MII status. */
48 bool bond_detect_mode_from_string(enum bond_detect_mode *, const char *);
49 const char *bond_detect_mode_to_string(enum bond_detect_mode);
51 /* Configuration for a bond as a whole. */
52 struct bond_settings {
53 char *name; /* Bond's name, for log messages. */
55 /* Balancing configuration. */
56 enum bond_mode balance;
57 int rebalance_interval; /* Milliseconds between rebalances. */
59 /* Link status detection. */
60 enum bond_detect_mode detect; /* BLSM_CARRIER or BLSM_MIIMON. */
61 int miimon_interval; /* Used only for BLSM_MIIMON. */
62 int up_delay; /* ms before enabling an up slave. */
63 int down_delay; /* ms before disabling a down slave. */
65 /* Legacy compatibility. */
66 bool fake_iface; /* Update fake stats for netdev 'name'? */
69 struct lacp_settings *lacp; /* NULL to disable LACP. */
72 /* Program startup. */
76 struct bond *bond_create(const struct bond_settings *);
77 void bond_destroy(struct bond *);
79 bool bond_reconfigure(struct bond *, const struct bond_settings *);
80 void bond_slave_register(struct bond *, void *slave_, struct netdev *,
81 const struct lacp_slave_settings *);
82 void bond_slave_unregister(struct bond *, const void *slave);
84 void bond_run(struct bond *, struct tag_set *);
85 void bond_wait(struct bond *);
87 /* Special MAC learning support for SLB bonding. */
88 bool bond_should_send_learning_packets(struct bond *);
89 int bond_send_learning_packet(struct bond *,
90 const uint8_t eth_src[ETH_ADDR_LEN],
93 /* Packet processing. */
95 BV_ACCEPT, /* Accept this packet. */
96 BV_DROP, /* Drop this packet. */
97 BV_DROP_IF_MOVED /* Drop if we've learned a different port. */
99 enum bond_verdict bond_check_admissibility(struct bond *, const void *slave_,
100 const uint8_t eth_dst[ETH_ADDR_LEN],
102 void *bond_choose_output_slave(struct bond *,
103 const struct flow *, uint16_t vlan, tag_type *);
104 void bond_process_lacp(struct bond *, void *slave,
105 const struct ofpbuf *packet);
108 void bond_account(struct bond *, const struct flow *, uint16_t vlan,
110 void bond_rebalance(struct bond *, struct tag_set *);