]> git.proxmox.com Git - ovs.git/blame - lib/bond.h
Global replace of Nicira Networks.
[ovs.git] / lib / bond.h
CommitLineData
f620b43a 1/*
e0edde6f 2 * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
f620b43a
BP
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 BOND_H
18#define BOND_H 1
19
20#include <stdbool.h>
21#include <stdint.h>
22
23#include "packets.h"
24#include "tag.h"
25
26struct flow;
f620b43a
BP
27struct netdev;
28struct ofpbuf;
bdebeece 29enum lacp_status;
f620b43a
BP
30
31/* How flows are balanced among bond slaves. */
32enum bond_mode {
33 BM_TCP, /* Transport Layer Load Balance. */
34 BM_SLB, /* Source Load Balance. */
fb0b29a3 35 BM_STABLE, /* Stable. */
f620b43a
BP
36 BM_AB /* Active Backup. */
37};
38
39bool bond_mode_from_string(enum bond_mode *, const char *);
40const char *bond_mode_to_string(enum bond_mode);
41
f620b43a
BP
42/* Configuration for a bond as a whole. */
43struct bond_settings {
44 char *name; /* Bond's name, for log messages. */
672d18b2 45 uint32_t basis; /* Flow hashing basis. */
f620b43a
BP
46
47 /* Balancing configuration. */
48 enum bond_mode balance;
bc1b010c
EJ
49 int rebalance_interval; /* Milliseconds between rebalances.
50 Zero to disable rebalancing. */
f620b43a
BP
51
52 /* Link status detection. */
f620b43a
BP
53 int up_delay; /* ms before enabling an up slave. */
54 int down_delay; /* ms before disabling a down slave. */
55
56 /* Legacy compatibility. */
57 bool fake_iface; /* Update fake stats for netdev 'name'? */
f620b43a
BP
58};
59
60/* Program startup. */
61void bond_init(void);
62
63/* Basics. */
64struct bond *bond_create(const struct bond_settings *);
65void bond_destroy(struct bond *);
66
59d7b2b6 67bool bond_reconfigure(struct bond *, const struct bond_settings *);
e1e90548 68void bond_slave_register(struct bond *, void *slave_,
75135fa0 69 uint32_t stable_id, struct netdev *);
f8ddccd2 70void bond_slave_set_netdev(struct bond *, void *slave_, struct netdev *);
f620b43a
BP
71void bond_slave_unregister(struct bond *, const void *slave);
72
bdebeece 73void bond_run(struct bond *, struct tag_set *, enum lacp_status);
f620b43a
BP
74void bond_wait(struct bond *);
75
296f6519 76void bond_slave_set_may_enable(struct bond *, void *slave_, bool may_enable);
4d6fb5eb 77
f620b43a
BP
78/* Special MAC learning support for SLB bonding. */
79bool bond_should_send_learning_packets(struct bond *);
ea131871
JG
80struct ofpbuf *bond_compose_learning_packet(struct bond *,
81 const uint8_t eth_src[ETH_ADDR_LEN],
82 uint16_t vlan, void **port_aux);
f620b43a
BP
83
84/* Packet processing. */
85enum bond_verdict {
86 BV_ACCEPT, /* Accept this packet. */
87 BV_DROP, /* Drop this packet. */
88 BV_DROP_IF_MOVED /* Drop if we've learned a different port. */
89};
90enum bond_verdict bond_check_admissibility(struct bond *, const void *slave_,
91 const uint8_t eth_dst[ETH_ADDR_LEN],
92 tag_type *);
93void *bond_choose_output_slave(struct bond *,
94 const struct flow *, uint16_t vlan, tag_type *);
f620b43a
BP
95
96/* Rebalancing. */
97void bond_account(struct bond *, const struct flow *, uint16_t vlan,
98 uint64_t n_bytes);
99void bond_rebalance(struct bond *, struct tag_set *);
100
101#endif /* bond.h */