]> Pileus Git - ~andy/linux/blobdiff - drivers/net/bonding/bond_3ad.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[~andy/linux] / drivers / net / bonding / bond_3ad.c
index 5393e1ed8d4e741fe589f175743b6eb064bdc704..539e24a1c86cea1aade44ea2ada8bd5230831df8 100644 (file)
@@ -1855,22 +1855,16 @@ void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution)
  * Returns:   0 on success
  *          < 0 on error
  */
-int bond_3ad_bind_slave(struct slave *slave)
+void bond_3ad_bind_slave(struct slave *slave)
 {
        struct bonding *bond = bond_get_bond_by_slave(slave);
        struct port *port;
        struct aggregator *aggregator;
 
-       if (bond == NULL) {
-               pr_err("%s: The slave %s is not attached to its bond\n",
-                      slave->bond->dev->name, slave->dev->name);
-               return -1;
-       }
-
-       //check that the slave has not been initialized yet.
+       /* check that the slave has not been initialized yet. */
        if (SLAVE_AD_INFO(slave).port.slave != slave) {
 
-               // port initialization
+               /* port initialization */
                port = &(SLAVE_AD_INFO(slave).port);
 
                ad_initialize_port(port, bond->params.lacp_fast);
@@ -1878,28 +1872,30 @@ int bond_3ad_bind_slave(struct slave *slave)
                __initialize_port_locks(slave);
                port->slave = slave;
                port->actor_port_number = SLAVE_AD_INFO(slave).id;
-               // key is determined according to the link speed, duplex and user key(which is yet not supported)
-               //              ------------------------------------------------------------
-               // Port key :   | User key                       |      Speed       |Duplex|
-               //              ------------------------------------------------------------
-               //              16                               6               1 0
-               port->actor_admin_port_key = 0; // initialize this parameter
+               /* key is determined according to the link speed, duplex and user key(which
+                * is yet not supported)
+                *              ------------------------------------------------------------
+                * Port key :   | User key                       |      Speed       |Duplex|
+                *              ------------------------------------------------------------
+                *              16                               6               1 0
+                */
+               port->actor_admin_port_key = 0; /* initialize this parameter */
                port->actor_admin_port_key |= __get_duplex(port);
                port->actor_admin_port_key |= (__get_link_speed(port) << 1);
                port->actor_oper_port_key = port->actor_admin_port_key;
-               // if the port is not full duplex, then the port should be not lacp Enabled
+               /* if the port is not full duplex, then the port should be not lacp Enabled */
                if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS))
                        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;
-               // tx timer(to verify that no more than MAX_TX_IN_SECOND lacpdu's are sent in one second)
+               /* tx timer(to verify that no more than MAX_TX_IN_SECOND lacpdu's are sent in one second) */
                port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
                port->aggregator = NULL;
                port->next_port_in_aggregator = NULL;
 
                __disable_port(port);
 
-               // aggregator initialization
+               /* aggregator initialization */
                aggregator = &(SLAVE_AD_INFO(slave).aggregator);
 
                ad_initialize_agg(aggregator);
@@ -1910,8 +1906,6 @@ int bond_3ad_bind_slave(struct slave *slave)
                aggregator->is_active = 0;
                aggregator->num_of_ports = 0;
        }
-
-       return 0;
 }
 
 /**
@@ -2215,20 +2209,25 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
 
        port = &(SLAVE_AD_INFO(slave).port);
 
-       // if slave is null, the whole port is not initialized
+       /* if slave is null, the whole port is not initialized */
        if (!port->slave) {
                pr_warning("Warning: %s: speed changed for uninitialized port on %s\n",
                           slave->bond->dev->name, slave->dev->name);
                return;
        }
 
+       __get_state_machine_lock(port);
+
        port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS;
        port->actor_oper_port_key = port->actor_admin_port_key |=
                (__get_link_speed(port) << 1);
        pr_debug("Port %d changed speed\n", port->actor_port_number);
-       // there is no need to reselect a new aggregator, just signal the
-       // state machines to reinitialize
+       /* there is no need to reselect a new aggregator, just signal the
+        * state machines to reinitialize
+        */
        port->sm_vars |= AD_PORT_BEGIN;
+
+       __release_state_machine_lock(port);
 }
 
 /**
@@ -2243,20 +2242,25 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
 
        port = &(SLAVE_AD_INFO(slave).port);
 
-       // if slave is null, the whole port is not initialized
+       /* if slave is null, the whole port is not initialized */
        if (!port->slave) {
                pr_warning("%s: Warning: duplex changed for uninitialized port on %s\n",
                           slave->bond->dev->name, slave->dev->name);
                return;
        }
 
+       __get_state_machine_lock(port);
+
        port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
        port->actor_oper_port_key = port->actor_admin_port_key |=
                __get_duplex(port);
        pr_debug("Port %d changed duplex\n", port->actor_port_number);
-       // there is no need to reselect a new aggregator, just signal the
-       // state machines to reinitialize
+       /* there is no need to reselect a new aggregator, just signal the
+        * state machines to reinitialize
+        */
        port->sm_vars |= AD_PORT_BEGIN;
+
+       __release_state_machine_lock(port);
 }
 
 /**
@@ -2272,15 +2276,21 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
 
        port = &(SLAVE_AD_INFO(slave).port);
 
-       // if slave is null, the whole port is not initialized
+       /* if slave is null, the whole port is not initialized */
        if (!port->slave) {
                pr_warning("Warning: %s: link status changed for uninitialized port on %s\n",
                           slave->bond->dev->name, slave->dev->name);
                return;
        }
 
-       // on link down we are zeroing duplex and speed since some of the adaptors(ce1000.lan) report full duplex/speed instead of N/A(duplex) / 0(speed)
-       // on link up we are forcing recheck on the duplex and speed since some of he adaptors(ce1000.lan) report
+       __get_state_machine_lock(port);
+       /* on link down we are zeroing duplex and speed since
+        * some of the adaptors(ce1000.lan) report full duplex/speed
+        * instead of N/A(duplex) / 0(speed).
+        *
+        * on link up we are forcing recheck on the duplex and speed since
+        * some of he adaptors(ce1000.lan) report.
+        */
        if (link == BOND_LINK_UP) {
                port->is_enabled = true;
                port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
@@ -2296,10 +2306,15 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
                port->actor_oper_port_key = (port->actor_admin_port_key &=
                                             ~AD_SPEED_KEY_BITS);
        }
-       //BOND_PRINT_DBG(("Port %d changed link status to %s", port->actor_port_number, ((link == BOND_LINK_UP)?"UP":"DOWN")));
-       // there is no need to reselect a new aggregator, just signal the
-       // state machines to reinitialize
+       pr_debug("Port %d changed link status to %s",
+               port->actor_port_number,
+               (link == BOND_LINK_UP) ? "UP" : "DOWN");
+       /* there is no need to reselect a new aggregator, just signal the
+        * state machines to reinitialize
+        */
        port->sm_vars |= AD_PORT_BEGIN;
+
+       __release_state_machine_lock(port);
 }
 
 /*
@@ -2401,13 +2416,12 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
        struct list_head *iter;
        int slaves_in_agg;
        int slave_agg_no;
-       int res = 1;
        int agg_id;
 
        if (__bond_3ad_get_active_agg_info(bond, &ad_info)) {
                pr_debug("%s: Error: __bond_3ad_get_active_agg_info failed\n",
                         dev->name);
-               goto out;
+               goto err_free;
        }
 
        slaves_in_agg = ad_info.ports;
@@ -2415,7 +2429,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
 
        if (slaves_in_agg == 0) {
                pr_debug("%s: Error: active aggregator is empty\n", dev->name);
-               goto out;
+               goto err_free;
        }
 
        slave_agg_no = bond_xmit_hash(bond, skb, slaves_in_agg);
@@ -2434,7 +2448,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
                }
 
                if (SLAVE_IS_OK(slave)) {
-                       res = bond_dev_queue_xmit(bond, skb, slave->dev);
+                       bond_dev_queue_xmit(bond, skb, slave->dev);
                        goto out;
                }
        }
@@ -2442,21 +2456,22 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
        if (slave_agg_no >= 0) {
                pr_err("%s: Error: Couldn't find a slave to tx on for aggregator ID %d\n",
                       dev->name, agg_id);
-               goto out;
+               goto err_free;
        }
 
        /* we couldn't find any suitable slave after the agg_no, so use the
         * first suitable found, if found. */
        if (first_ok_slave)
-               res = bond_dev_queue_xmit(bond, skb, first_ok_slave->dev);
+               bond_dev_queue_xmit(bond, skb, first_ok_slave->dev);
+       else
+               goto err_free;
 
 out:
-       if (res) {
-               /* no suitable interface, frame not sent */
-               kfree_skb(skb);
-       }
-
        return NETDEV_TX_OK;
+err_free:
+       /* no suitable interface, frame not sent */
+       kfree_skb(skb);
+       goto out;
 }
 
 int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,