]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
ixgbe: add a refcnt when turning on/off FCoE offload capability
authorYi Zou <yi.zou@intel.com>
Wed, 20 Oct 2010 23:00:30 +0000 (23:00 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Oct 2010 10:55:23 +0000 (03:55 -0700)
The FCoE offload is enabled/disabled per adapter, but upper FCoE protocol
stack could have multiple FCoE instances created on the same physical network
interface, e.g., FCoE on multiple VLAN interfaces on the same physical
network interface. In this case we want to turn on FCoE offload at the first
request from ndo_fcoe_enable() but only turn off FCoE offload at the very last
call to ndo_fcoe_disable(). This is fixed by adding a refcnt in the per adapter
FCoE structure and tear down FCoE offload when refcnt decrements to zero.

Signed-off-by: Yi Zou <yi.zou@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ixgbe/ixgbe_fcoe.c
drivers/net/ixgbe/ixgbe_fcoe.h

index 2f1de8b90f9eb42a1b82d9a16409893cc1592902..05efa6a8ce8e080c6cea2d85e31bcfd09728e8dd 100644 (file)
@@ -604,11 +604,13 @@ int ixgbe_fcoe_enable(struct net_device *netdev)
 {
        int rc = -EINVAL;
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
+       struct ixgbe_fcoe *fcoe = &adapter->fcoe;
 
 
        if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE))
                goto out_enable;
 
+       atomic_inc(&fcoe->refcnt);
        if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
                goto out_enable;
 
@@ -648,6 +650,7 @@ int ixgbe_fcoe_disable(struct net_device *netdev)
 {
        int rc = -EINVAL;
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
+       struct ixgbe_fcoe *fcoe = &adapter->fcoe;
 
        if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE))
                goto out_disable;
@@ -655,6 +658,9 @@ int ixgbe_fcoe_disable(struct net_device *netdev)
        if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED))
                goto out_disable;
 
+       if (!atomic_dec_and_test(&fcoe->refcnt))
+               goto out_disable;
+
        e_info(drv, "Disabling FCoE offload features.\n");
        netdev->features &= ~NETIF_F_FCOE_CRC;
        netdev->features &= ~NETIF_F_FSO;
index abf4b2b3f2520f35117403061895cf9e968fc003..4bc2c551c8dbc85b96aed6b3fc74ba1a8c0ebd08 100644 (file)
@@ -66,6 +66,7 @@ struct ixgbe_fcoe {
        u8 tc;
        u8 up;
 #endif
+       atomic_t refcnt;
        spinlock_t lock;
        struct pci_pool *pool;
        struct ixgbe_fcoe_ddp ddp[IXGBE_FCOE_DDP_MAX];