mii: Add mii_advertise_flowctrl()
authorBen Hutchings <bhutchings@solarflare.com>
Wed, 29 Apr 2009 08:19:03 +0000 (08:19 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 Apr 2009 00:32:35 +0000 (17:32 -0700)
This converts flow control capabilites to an advertising mask and can
be useful in combination with mii_resolve_flowctrl_fdx().

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/mii.h

index 14ecb2e114f1692bce6d8db9a4cf877c97beb9ed..359fba8802746111b4c10c640487b889dc9d6937 100644 (file)
@@ -239,6 +239,22 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock,
        return 0;
 }
 
+/**
+ * mii_advertise_flowctrl - get flow control advertisement flags
+ * @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both)
+ */
+static inline u16 mii_advertise_flowctrl(int cap)
+{
+       u16 adv = 0;
+
+       if (cap & FLOW_CTRL_RX)
+               adv = ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
+       if (cap & FLOW_CTRL_TX)
+               adv ^= ADVERTISE_PAUSE_ASYM;
+
+       return adv;
+}
+
 /**
  * mii_resolve_flowctrl_fdx
  * @lcladv: value of MII ADVERTISE register