aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_3ad.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bonding/bond_3ad.c')
-rw-r--r--drivers/net/bonding/bond_3ad.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 0a32143af12b..6bc27d9a8670 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -79,15 +79,17 @@
79 * -------------------------------------------------------------- 79 * --------------------------------------------------------------
80 * 16 6 1 0 80 * 16 6 1 0
81 */ 81 */
82#define AD_DUPLEX_KEY_BITS 0x1 82#define AD_DUPLEX_KEY_MASKS 0x1
83#define AD_SPEED_KEY_BITS 0x3E 83#define AD_SPEED_KEY_MASKS 0x3E
84#define AD_USER_KEY_BITS 0xFFC0 84#define AD_USER_KEY_MASKS 0xFFC0
85 85
86#define AD_LINK_SPEED_BITMASK_1MBPS 0x1 86enum ad_link_speed_type {
87#define AD_LINK_SPEED_BITMASK_10MBPS 0x2 87 AD_LINK_SPEED_1MBPS = 1,
88#define AD_LINK_SPEED_BITMASK_100MBPS 0x4 88 AD_LINK_SPEED_10MBPS,
89#define AD_LINK_SPEED_BITMASK_1000MBPS 0x8 89 AD_LINK_SPEED_100MBPS,
90#define AD_LINK_SPEED_BITMASK_10000MBPS 0x10 90 AD_LINK_SPEED_1000MBPS,
91 AD_LINK_SPEED_10000MBPS
92};
91 93
92/* compare MAC addresses */ 94/* compare MAC addresses */
93#define MAC_ADDRESS_EQUAL(A, B) \ 95#define MAC_ADDRESS_EQUAL(A, B) \
@@ -240,12 +242,12 @@ static inline int __check_agg_selection_timer(struct port *port)
240 * __get_link_speed - get a port's speed 242 * __get_link_speed - get a port's speed
241 * @port: the port we're looking at 243 * @port: the port we're looking at
242 * 244 *
243 * Return @port's speed in 802.3ad bitmask format. i.e. one of: 245 * Return @port's speed in 802.3ad enum format. i.e. one of:
244 * 0, 246 * 0,
245 * %AD_LINK_SPEED_BITMASK_10MBPS, 247 * %AD_LINK_SPEED_10MBPS,
246 * %AD_LINK_SPEED_BITMASK_100MBPS, 248 * %AD_LINK_SPEED_100MBPS,
247 * %AD_LINK_SPEED_BITMASK_1000MBPS, 249 * %AD_LINK_SPEED_1000MBPS,
248 * %AD_LINK_SPEED_BITMASK_10000MBPS 250 * %AD_LINK_SPEED_10000MBPS
249 */ 251 */
250static u16 __get_link_speed(struct port *port) 252static u16 __get_link_speed(struct port *port)
251{ 253{
@@ -262,19 +264,19 @@ static u16 __get_link_speed(struct port *port)
262 else { 264 else {
263 switch (slave->speed) { 265 switch (slave->speed) {
264 case SPEED_10: 266 case SPEED_10:
265 speed = AD_LINK_SPEED_BITMASK_10MBPS; 267 speed = AD_LINK_SPEED_10MBPS;
266 break; 268 break;
267 269
268 case SPEED_100: 270 case SPEED_100:
269 speed = AD_LINK_SPEED_BITMASK_100MBPS; 271 speed = AD_LINK_SPEED_100MBPS;
270 break; 272 break;
271 273
272 case SPEED_1000: 274 case SPEED_1000:
273 speed = AD_LINK_SPEED_BITMASK_1000MBPS; 275 speed = AD_LINK_SPEED_1000MBPS;
274 break; 276 break;
275 277
276 case SPEED_10000: 278 case SPEED_10000:
277 speed = AD_LINK_SPEED_BITMASK_10000MBPS; 279 speed = AD_LINK_SPEED_10000MBPS;
278 break; 280 break;
279 281
280 default: 282 default:
@@ -625,19 +627,19 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator)
625 627
626 if (aggregator->num_of_ports) { 628 if (aggregator->num_of_ports) {
627 switch (__get_link_speed(aggregator->lag_ports)) { 629 switch (__get_link_speed(aggregator->lag_ports)) {
628 case AD_LINK_SPEED_BITMASK_1MBPS: 630 case AD_LINK_SPEED_1MBPS:
629 bandwidth = aggregator->num_of_ports; 631 bandwidth = aggregator->num_of_ports;
630 break; 632 break;
631 case AD_LINK_SPEED_BITMASK_10MBPS: 633 case AD_LINK_SPEED_10MBPS:
632 bandwidth = aggregator->num_of_ports * 10; 634 bandwidth = aggregator->num_of_ports * 10;
633 break; 635 break;
634 case AD_LINK_SPEED_BITMASK_100MBPS: 636 case AD_LINK_SPEED_100MBPS:
635 bandwidth = aggregator->num_of_ports * 100; 637 bandwidth = aggregator->num_of_ports * 100;
636 break; 638 break;
637 case AD_LINK_SPEED_BITMASK_1000MBPS: 639 case AD_LINK_SPEED_1000MBPS:
638 bandwidth = aggregator->num_of_ports * 1000; 640 bandwidth = aggregator->num_of_ports * 1000;
639 break; 641 break;
640 case AD_LINK_SPEED_BITMASK_10000MBPS: 642 case AD_LINK_SPEED_10000MBPS:
641 bandwidth = aggregator->num_of_ports * 10000; 643 bandwidth = aggregator->num_of_ports * 10000;
642 break; 644 break;
643 default: 645 default:
@@ -1011,7 +1013,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
1011 port->sm_rx_state); 1013 port->sm_rx_state);
1012 switch (port->sm_rx_state) { 1014 switch (port->sm_rx_state) {
1013 case AD_RX_INITIALIZE: 1015 case AD_RX_INITIALIZE:
1014 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) 1016 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS))
1015 port->sm_vars &= ~AD_PORT_LACP_ENABLED; 1017 port->sm_vars &= ~AD_PORT_LACP_ENABLED;
1016 else 1018 else
1017 port->sm_vars |= AD_PORT_LACP_ENABLED; 1019 port->sm_vars |= AD_PORT_LACP_ENABLED;
@@ -1318,7 +1320,7 @@ static void ad_port_selection_logic(struct port *port, bool *update_slave_arr)
1318 /* update the new aggregator's parameters 1320 /* update the new aggregator's parameters
1319 * if port was responsed from the end-user 1321 * if port was responsed from the end-user
1320 */ 1322 */
1321 if (port->actor_oper_port_key & AD_DUPLEX_KEY_BITS) 1323 if (port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS)
1322 /* if port is full duplex */ 1324 /* if port is full duplex */
1323 port->aggregator->is_individual = false; 1325 port->aggregator->is_individual = false;
1324 else 1326 else
@@ -1846,7 +1848,7 @@ void bond_3ad_bind_slave(struct slave *slave)
1846 /* if the port is not full duplex, then the port should be not 1848 /* if the port is not full duplex, then the port should be not
1847 * lacp Enabled 1849 * lacp Enabled
1848 */ 1850 */
1849 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) 1851 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS))
1850 port->sm_vars &= ~AD_PORT_LACP_ENABLED; 1852 port->sm_vars &= ~AD_PORT_LACP_ENABLED;
1851 /* actor system is the bond's system */ 1853 /* actor system is the bond's system */
1852 port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr; 1854 port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr;
@@ -2214,7 +2216,7 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
2214 2216
2215 spin_lock_bh(&slave->bond->mode_lock); 2217 spin_lock_bh(&slave->bond->mode_lock);
2216 2218
2217 port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS; 2219 port->actor_admin_port_key &= ~AD_SPEED_KEY_MASKS;
2218 port->actor_oper_port_key = port->actor_admin_port_key |= 2220 port->actor_oper_port_key = port->actor_admin_port_key |=
2219 (__get_link_speed(port) << 1); 2221 (__get_link_speed(port) << 1);
2220 netdev_dbg(slave->bond->dev, "Port %d changed speed\n", port->actor_port_number); 2222 netdev_dbg(slave->bond->dev, "Port %d changed speed\n", port->actor_port_number);
@@ -2247,7 +2249,7 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
2247 2249
2248 spin_lock_bh(&slave->bond->mode_lock); 2250 spin_lock_bh(&slave->bond->mode_lock);
2249 2251
2250 port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS; 2252 port->actor_admin_port_key &= ~AD_DUPLEX_KEY_MASKS;
2251 port->actor_oper_port_key = port->actor_admin_port_key |= 2253 port->actor_oper_port_key = port->actor_admin_port_key |=
2252 __get_duplex(port); 2254 __get_duplex(port);
2253 netdev_dbg(slave->bond->dev, "Port %d changed duplex\n", port->actor_port_number); 2255 netdev_dbg(slave->bond->dev, "Port %d changed duplex\n", port->actor_port_number);
@@ -2289,18 +2291,18 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
2289 */ 2291 */
2290 if (link == BOND_LINK_UP) { 2292 if (link == BOND_LINK_UP) {
2291 port->is_enabled = true; 2293 port->is_enabled = true;
2292 port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS; 2294 port->actor_admin_port_key &= ~AD_DUPLEX_KEY_MASKS;
2293 port->actor_oper_port_key = port->actor_admin_port_key |= 2295 port->actor_oper_port_key = port->actor_admin_port_key |=
2294 __get_duplex(port); 2296 __get_duplex(port);
2295 port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS; 2297 port->actor_admin_port_key &= ~AD_SPEED_KEY_MASKS;
2296 port->actor_oper_port_key = port->actor_admin_port_key |= 2298 port->actor_oper_port_key = port->actor_admin_port_key |=
2297 (__get_link_speed(port) << 1); 2299 (__get_link_speed(port) << 1);
2298 } else { 2300 } else {
2299 /* link has failed */ 2301 /* link has failed */
2300 port->is_enabled = false; 2302 port->is_enabled = false;
2301 port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS; 2303 port->actor_admin_port_key &= ~AD_DUPLEX_KEY_MASKS;
2302 port->actor_oper_port_key = (port->actor_admin_port_key &= 2304 port->actor_oper_port_key = (port->actor_admin_port_key &=
2303 ~AD_SPEED_KEY_BITS); 2305 ~AD_SPEED_KEY_MASKS);
2304 } 2306 }
2305 netdev_dbg(slave->bond->dev, "Port %d changed link status to %s\n", 2307 netdev_dbg(slave->bond->dev, "Port %d changed link status to %s\n",
2306 port->actor_port_number, 2308 port->actor_port_number,