Commit cb8dda90 authored by Jianhua Xie's avatar Jianhua Xie Committed by David S. Miller

bonding: change AD_LINK_SPEED_BITMASK to enum to suport more speed

Port Key was determined as 16 bits according to the link speed,
duplex and user key (which is yet not supported).  In the old
speed field, 5 bits are for speed [1|10|100|1000|10000]Mbps as
below:
--------------------------------------------------------------
Port key :| User key        | Speed         |       Duplex|
--------------------------------------------------------------
    16                  6               1               0
This patch keeps the old layout, but changes AD_LINK_SPEED_BITMASK
from bit type to an enum type.  In this way, the speed field can
expand speed type from 5 to 32.

CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Veaceslav Falico <vfalico@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: David S. Miller <davem@davemloft.net>
Signed-off-by: default avatarJianhua Xie <jianhua.xie@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent daaf427c
...@@ -79,15 +79,17 @@ ...@@ -79,15 +79,17 @@
* -------------------------------------------------------------- * --------------------------------------------------------------
* 16 6 1 0 * 16 6 1 0
*/ */
#define AD_DUPLEX_KEY_BITS 0x1 #define AD_DUPLEX_KEY_MASKS 0x1
#define AD_SPEED_KEY_BITS 0x3E #define AD_SPEED_KEY_MASKS 0x3E
#define AD_USER_KEY_BITS 0xFFC0 #define AD_USER_KEY_MASKS 0xFFC0
#define AD_LINK_SPEED_BITMASK_1MBPS 0x1 enum ad_link_speed_type {
#define AD_LINK_SPEED_BITMASK_10MBPS 0x2 AD_LINK_SPEED_1MBPS = 1,
#define AD_LINK_SPEED_BITMASK_100MBPS 0x4 AD_LINK_SPEED_10MBPS,
#define AD_LINK_SPEED_BITMASK_1000MBPS 0x8 AD_LINK_SPEED_100MBPS,
#define AD_LINK_SPEED_BITMASK_10000MBPS 0x10 AD_LINK_SPEED_1000MBPS,
AD_LINK_SPEED_10000MBPS
};
/* compare MAC addresses */ /* compare MAC addresses */
#define MAC_ADDRESS_EQUAL(A, B) \ #define MAC_ADDRESS_EQUAL(A, B) \
...@@ -240,12 +242,12 @@ static inline int __check_agg_selection_timer(struct port *port) ...@@ -240,12 +242,12 @@ static inline int __check_agg_selection_timer(struct port *port)
* __get_link_speed - get a port's speed * __get_link_speed - get a port's speed
* @port: the port we're looking at * @port: the port we're looking at
* *
* Return @port's speed in 802.3ad bitmask format. i.e. one of: * Return @port's speed in 802.3ad enum format. i.e. one of:
* 0, * 0,
* %AD_LINK_SPEED_BITMASK_10MBPS, * %AD_LINK_SPEED_10MBPS,
* %AD_LINK_SPEED_BITMASK_100MBPS, * %AD_LINK_SPEED_100MBPS,
* %AD_LINK_SPEED_BITMASK_1000MBPS, * %AD_LINK_SPEED_1000MBPS,
* %AD_LINK_SPEED_BITMASK_10000MBPS * %AD_LINK_SPEED_10000MBPS
*/ */
static u16 __get_link_speed(struct port *port) static u16 __get_link_speed(struct port *port)
{ {
...@@ -262,19 +264,19 @@ static u16 __get_link_speed(struct port *port) ...@@ -262,19 +264,19 @@ static u16 __get_link_speed(struct port *port)
else { else {
switch (slave->speed) { switch (slave->speed) {
case SPEED_10: case SPEED_10:
speed = AD_LINK_SPEED_BITMASK_10MBPS; speed = AD_LINK_SPEED_10MBPS;
break; break;
case SPEED_100: case SPEED_100:
speed = AD_LINK_SPEED_BITMASK_100MBPS; speed = AD_LINK_SPEED_100MBPS;
break; break;
case SPEED_1000: case SPEED_1000:
speed = AD_LINK_SPEED_BITMASK_1000MBPS; speed = AD_LINK_SPEED_1000MBPS;
break; break;
case SPEED_10000: case SPEED_10000:
speed = AD_LINK_SPEED_BITMASK_10000MBPS; speed = AD_LINK_SPEED_10000MBPS;
break; break;
default: default:
...@@ -625,19 +627,19 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator) ...@@ -625,19 +627,19 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator)
if (aggregator->num_of_ports) { if (aggregator->num_of_ports) {
switch (__get_link_speed(aggregator->lag_ports)) { switch (__get_link_speed(aggregator->lag_ports)) {
case AD_LINK_SPEED_BITMASK_1MBPS: case AD_LINK_SPEED_1MBPS:
bandwidth = aggregator->num_of_ports; bandwidth = aggregator->num_of_ports;
break; break;
case AD_LINK_SPEED_BITMASK_10MBPS: case AD_LINK_SPEED_10MBPS:
bandwidth = aggregator->num_of_ports * 10; bandwidth = aggregator->num_of_ports * 10;
break; break;
case AD_LINK_SPEED_BITMASK_100MBPS: case AD_LINK_SPEED_100MBPS:
bandwidth = aggregator->num_of_ports * 100; bandwidth = aggregator->num_of_ports * 100;
break; break;
case AD_LINK_SPEED_BITMASK_1000MBPS: case AD_LINK_SPEED_1000MBPS:
bandwidth = aggregator->num_of_ports * 1000; bandwidth = aggregator->num_of_ports * 1000;
break; break;
case AD_LINK_SPEED_BITMASK_10000MBPS: case AD_LINK_SPEED_10000MBPS:
bandwidth = aggregator->num_of_ports * 10000; bandwidth = aggregator->num_of_ports * 10000;
break; break;
default: default:
...@@ -1011,7 +1013,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) ...@@ -1011,7 +1013,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
port->sm_rx_state); port->sm_rx_state);
switch (port->sm_rx_state) { switch (port->sm_rx_state) {
case AD_RX_INITIALIZE: case AD_RX_INITIALIZE:
if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS))
port->sm_vars &= ~AD_PORT_LACP_ENABLED; port->sm_vars &= ~AD_PORT_LACP_ENABLED;
else else
port->sm_vars |= AD_PORT_LACP_ENABLED; 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,7 +1320,7 @@ static void ad_port_selection_logic(struct port *port, bool *update_slave_arr)
/* update the new aggregator's parameters /* update the new aggregator's parameters
* if port was responsed from the end-user * if port was responsed from the end-user
*/ */
if (port->actor_oper_port_key & AD_DUPLEX_KEY_BITS) if (port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS)
/* if port is full duplex */ /* if port is full duplex */
port->aggregator->is_individual = false; port->aggregator->is_individual = false;
else else
...@@ -1846,7 +1848,7 @@ void bond_3ad_bind_slave(struct slave *slave) ...@@ -1846,7 +1848,7 @@ void bond_3ad_bind_slave(struct slave *slave)
/* if the port is not full duplex, then the port should be not /* if the port is not full duplex, then the port should be not
* lacp Enabled * lacp Enabled
*/ */
if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS))
port->sm_vars &= ~AD_PORT_LACP_ENABLED; port->sm_vars &= ~AD_PORT_LACP_ENABLED;
/* actor system is the bond's system */ /* actor system is the bond's system */
port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr; 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,7 +2216,7 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
spin_lock_bh(&slave->bond->mode_lock); spin_lock_bh(&slave->bond->mode_lock);
port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS; port->actor_admin_port_key &= ~AD_SPEED_KEY_MASKS;
port->actor_oper_port_key = port->actor_admin_port_key |= port->actor_oper_port_key = port->actor_admin_port_key |=
(__get_link_speed(port) << 1); (__get_link_speed(port) << 1);
netdev_dbg(slave->bond->dev, "Port %d changed speed\n", port->actor_port_number); 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,7 +2249,7 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
spin_lock_bh(&slave->bond->mode_lock); spin_lock_bh(&slave->bond->mode_lock);
port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS; port->actor_admin_port_key &= ~AD_DUPLEX_KEY_MASKS;
port->actor_oper_port_key = port->actor_admin_port_key |= port->actor_oper_port_key = port->actor_admin_port_key |=
__get_duplex(port); __get_duplex(port);
netdev_dbg(slave->bond->dev, "Port %d changed duplex\n", port->actor_port_number); 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,18 +2291,18 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
*/ */
if (link == BOND_LINK_UP) { if (link == BOND_LINK_UP) {
port->is_enabled = true; port->is_enabled = true;
port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS; port->actor_admin_port_key &= ~AD_DUPLEX_KEY_MASKS;
port->actor_oper_port_key = port->actor_admin_port_key |= port->actor_oper_port_key = port->actor_admin_port_key |=
__get_duplex(port); __get_duplex(port);
port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS; port->actor_admin_port_key &= ~AD_SPEED_KEY_MASKS;
port->actor_oper_port_key = port->actor_admin_port_key |= port->actor_oper_port_key = port->actor_admin_port_key |=
(__get_link_speed(port) << 1); (__get_link_speed(port) << 1);
} else { } else {
/* link has failed */ /* link has failed */
port->is_enabled = false; port->is_enabled = false;
port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS; port->actor_admin_port_key &= ~AD_DUPLEX_KEY_MASKS;
port->actor_oper_port_key = (port->actor_admin_port_key &= port->actor_oper_port_key = (port->actor_admin_port_key &=
~AD_SPEED_KEY_BITS); ~AD_SPEED_KEY_MASKS);
} }
netdev_dbg(slave->bond->dev, "Port %d changed link status to %s\n", netdev_dbg(slave->bond->dev, "Port %d changed link status to %s\n",
port->actor_port_number, port->actor_port_number,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment