ofproto-dpif: Get rid of effectively unused 'check_special' flag.
[sliver-openvswitch.git] / lib / bond.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
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
26 struct flow;
27 struct netdev;
28 struct ofpbuf;
29
30 /* How flows are balanced among bond slaves. */
31 enum bond_mode {
32     BM_TCP, /* Transport Layer Load Balance. */
33     BM_SLB, /* Source Load Balance. */
34     BM_STABLE, /* Stable. */
35     BM_AB   /* Active Backup. */
36 };
37
38 bool bond_mode_from_string(enum bond_mode *, const char *);
39 const char *bond_mode_to_string(enum bond_mode);
40
41 /* How to detect link status. */
42 enum bond_detect_mode {
43     BLSM_CARRIER,               /* Use carrier. */
44     BLSM_MIIMON                 /* Poll MII status. */
45 };
46
47 bool bond_detect_mode_from_string(enum bond_detect_mode *, const char *);
48 const char *bond_detect_mode_to_string(enum bond_detect_mode);
49
50 /* Configuration for a bond as a whole. */
51 struct bond_settings {
52     char *name;                 /* Bond's name, for log messages. */
53
54     /* Balancing configuration. */
55     enum bond_mode balance;
56     int rebalance_interval;     /* Milliseconds between rebalances. */
57
58     /* Link status detection. */
59     enum bond_detect_mode detect; /* BLSM_CARRIER or BLSM_MIIMON. */
60     int miimon_interval;        /* Used only for BLSM_MIIMON. */
61     int up_delay;               /* ms before enabling an up slave. */
62     int down_delay;             /* ms before disabling a down slave. */
63
64     /* Legacy compatibility. */
65     bool fake_iface;            /* Update fake stats for netdev 'name'? */
66 };
67
68 /* Program startup. */
69 void bond_init(void);
70
71 /* Basics. */
72 struct bond *bond_create(const struct bond_settings *);
73 void bond_destroy(struct bond *);
74
75 bool bond_reconfigure(struct bond *, const struct bond_settings *);
76 void bond_slave_register(struct bond *, void *slave_,
77                          uint16_t stable_id, struct netdev *);
78 void bond_slave_set_netdev(struct bond *, void *slave_, struct netdev *);
79 void bond_slave_unregister(struct bond *, const void *slave);
80
81 void bond_run(struct bond *, struct tag_set *, bool lacp_negotiated);
82 void bond_wait(struct bond *);
83
84 /* LACP. */
85 void bond_slave_set_lacp_may_enable(struct bond *, void *slave_,
86                                     bool may_enable);
87
88 /* Special MAC learning support for SLB bonding. */
89 bool bond_should_send_learning_packets(struct bond *);
90 int bond_send_learning_packet(struct bond *,
91                               const uint8_t eth_src[ETH_ADDR_LEN],
92                               uint16_t vlan);
93
94 /* Packet processing. */
95 enum bond_verdict {
96     BV_ACCEPT,                  /* Accept this packet. */
97     BV_DROP,                    /* Drop this packet. */
98     BV_DROP_IF_MOVED            /* Drop if we've learned a different port. */
99 };
100 enum bond_verdict bond_check_admissibility(struct bond *, const void *slave_,
101                                            const uint8_t eth_dst[ETH_ADDR_LEN],
102                                            tag_type *);
103 void *bond_choose_output_slave(struct bond *,
104                                const struct flow *, uint16_t vlan, tag_type *);
105
106 /* Rebalancing. */
107 void bond_account(struct bond *, const struct flow *, uint16_t vlan,
108                   uint64_t n_bytes);
109 void bond_rebalance(struct bond *, struct tag_set *);
110
111 #endif /* bond.h */