]>
Commit | Line | Data |
---|---|---|
f620b43a | 1 | /* |
adcf00ba | 2 | * Copyright (c) 2008, 2009, 2010, 2011, 2014 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> | |
adcf00ba | 22 | #include "ofproto-provider.h" |
f620b43a | 23 | #include "packets.h" |
f620b43a BP |
24 | |
25 | struct flow; | |
f620b43a BP |
26 | struct netdev; |
27 | struct ofpbuf; | |
adcf00ba | 28 | struct ofproto_dpif; |
bdebeece | 29 | enum lacp_status; |
f620b43a | 30 | |
91fc374a | 31 | /* How flows are balanced among bond member interfaces. */ |
f620b43a BP |
32 | enum bond_mode { |
33 | BM_TCP, /* Transport Layer Load Balance. */ | |
34 | BM_SLB, /* Source Load Balance. */ | |
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 | ||
f620b43a BP |
41 | /* Configuration for a bond as a whole. */ |
42 | struct bond_settings { | |
43 | char *name; /* Bond's name, for log messages. */ | |
672d18b2 | 44 | uint32_t basis; /* Flow hashing basis. */ |
f620b43a BP |
45 | |
46 | /* Balancing configuration. */ | |
47 | enum bond_mode balance; | |
bc1b010c EJ |
48 | int rebalance_interval; /* Milliseconds between rebalances. |
49 | Zero to disable rebalancing. */ | |
f620b43a | 50 | |
b4e50218 JS |
51 | const char *primary; /* For AB mode, primary interface name. */ |
52 | ||
f620b43a | 53 | /* Link status detection. */ |
91fc374a BP |
54 | int up_delay; /* ms before enabling an up member. */ |
55 | int down_delay; /* ms before disabling a down member. */ | |
f620b43a | 56 | |
9dd165e0 | 57 | bool lacp_fallback_ab_cfg; /* Fallback to active-backup on LACP failure. */ |
3e5aeeb5 | 58 | |
91fc374a | 59 | struct eth_addr active_member_mac; |
3bd0fd39 | 60 | /* The MAC address of the interface |
3e5aeeb5 AZ |
61 | that was active during the last |
62 | ovs run. */ | |
9df65060 VDA |
63 | bool use_lb_output_action; /* Use lb_output action. Only applicable for |
64 | bond mode BALANCE TCP. */ | |
f620b43a BP |
65 | }; |
66 | ||
67 | /* Program startup. */ | |
68 | void bond_init(void); | |
69 | ||
70 | /* Basics. */ | |
adcf00ba AZ |
71 | struct bond *bond_create(const struct bond_settings *, |
72 | struct ofproto_dpif *ofproto); | |
03366a2d EJ |
73 | void bond_unref(struct bond *); |
74 | struct bond *bond_ref(const struct bond *); | |
f620b43a | 75 | |
59d7b2b6 | 76 | bool bond_reconfigure(struct bond *, const struct bond_settings *); |
91fc374a BP |
77 | void bond_member_register(struct bond *, void *member_, ofp_port_t ofport, |
78 | struct netdev *); | |
79 | void bond_member_set_netdev(struct bond *, void *member_, struct netdev *); | |
80 | void bond_member_unregister(struct bond *, const void *member); | |
f620b43a | 81 | |
4a1b8f30 | 82 | bool bond_run(struct bond *, enum lacp_status); |
f620b43a BP |
83 | void bond_wait(struct bond *); |
84 | ||
91fc374a | 85 | void bond_member_set_may_enable(struct bond *, void *member_, bool may_enable); |
4d6fb5eb | 86 | |
f620b43a BP |
87 | /* Special MAC learning support for SLB bonding. */ |
88 | bool bond_should_send_learning_packets(struct bond *); | |
cf62fa4c | 89 | struct dp_packet *bond_compose_learning_packet(struct bond *, |
74ff3298 JR |
90 | const struct eth_addr eth_src, |
91 | uint16_t vlan, void **port_aux); | |
91fc374a BP |
92 | bool bond_get_changed_active_member(const char *name, struct eth_addr *mac, |
93 | bool force); | |
f620b43a BP |
94 | |
95 | /* Packet processing. */ | |
96 | enum bond_verdict { | |
97 | BV_ACCEPT, /* Accept this packet. */ | |
98 | BV_DROP, /* Drop this packet. */ | |
99 | BV_DROP_IF_MOVED /* Drop if we've learned a different port. */ | |
100 | }; | |
91fc374a | 101 | enum bond_verdict bond_check_admissibility(struct bond *, const void *member_, |
74ff3298 | 102 | const struct eth_addr dst); |
91fc374a BP |
103 | void *bond_choose_output_member(struct bond *, const struct flow *, |
104 | struct flow_wildcards *, uint16_t vlan); | |
f620b43a BP |
105 | |
106 | /* Rebalancing. */ | |
107 | void bond_account(struct bond *, const struct flow *, uint16_t vlan, | |
108 | uint64_t n_bytes); | |
60cda7d6 | 109 | void bond_rebalance(struct bond *); |
f620b43a | 110 | |
adcf00ba AZ |
111 | /* Recirculation |
112 | * | |
113 | * Only balance_tcp mode uses recirculation. | |
114 | * | |
115 | * When recirculation is used, each bond port is assigned with a unique | |
116 | * recirc_id. The output action to the bond port will be replaced by | |
60cda7d6 | 117 | * a Hash action, followed by a RECIRC action. |
adcf00ba | 118 | * |
60cda7d6 | 119 | * ... actions= ... HASH(hash(L4)), RECIRC(recirc_id) .... |
adcf00ba AZ |
120 | * |
121 | * On handling first output packet, 256 post recirculation flows are installed: | |
122 | * | |
91fc374a | 123 | * recirc_id=<bond_recirc_id>, dp_hash=<[0..255]>/0xff, actions: output<member> |
adcf00ba AZ |
124 | * |
125 | * Bond module pulls stats from those post recirculation rules. If rebalancing | |
126 | * is needed, those rules are updated with new output actions. | |
127 | */ | |
82f9f1f5 AZ |
128 | void bond_update_post_recirc_rules(struct bond *, uint32_t *recirc_id, |
129 | uint32_t *hash_basis); | |
9df65060 VDA |
130 | |
131 | bool bond_use_lb_output_action(const struct bond *bond); | |
132 | ||
f620b43a | 133 | #endif /* bond.h */ |