drivers: acpi: don't use own implementation of hex_to_bin()
[safe/jmp/linux-2.6] / include / linux / mii.h
index 9b8d047..359fba8 100644 (file)
@@ -9,7 +9,6 @@
 #define __LINUX_MII_H__
 
 #include <linux/types.h>
-#include <linux/if.h>
 
 /* Generic MII registers. */
 
@@ -57,8 +56,8 @@
 #define BMSR_ANEGCOMPLETE       0x0020  /* Auto-negotiation complete   */
 #define BMSR_RESV               0x00c0  /* Unused...                   */
 #define BMSR_ESTATEN           0x0100  /* Extended Status in R15 */
-#define BMSR_100FULL2          0x0200  /* Can do 100BASE-T2 HDX */
-#define BMSR_100HALF2          0x0400  /* Can do 100BASE-T2 FDX */
+#define BMSR_100HALF2           0x0200  /* Can do 100BASE-T2 HDX */
+#define BMSR_100FULL2           0x0400  /* Can do 100BASE-T2 FDX */
 #define BMSR_10HALF             0x0800  /* Can do 10mbps, half-duplex  */
 #define BMSR_10FULL             0x1000  /* Can do 10mbps, full-duplex  */
 #define BMSR_100HALF            0x2000  /* Can do 100mbps, half-duplex */
 #define LPA_1000FULL            0x0800  /* Link partner 1000BASE-T full duplex */
 #define LPA_1000HALF            0x0400  /* Link partner 1000BASE-T half duplex */
 
+/* Flow control flags */
+#define FLOW_CTRL_TX           0x01
+#define FLOW_CTRL_RX           0x02
+
+/* This structure is used in all SIOCxMIIxxx ioctl calls */
+struct mii_ioctl_data {
+       __u16           phy_id;
+       __u16           reg_num;
+       __u16           val_in;
+       __u16           val_out;
+};
+
+#ifdef __KERNEL__ 
+
+#include <linux/if.h>
+
+struct ethtool_cmd;
+
 struct mii_if_info {
        int phy_id;
        int advertising;
@@ -151,13 +168,11 @@ struct mii_if_info {
        void (*mdio_write) (struct net_device *dev, int phy_id, int location, int val);
 };
 
-struct ethtool_cmd;
-struct mii_ioctl_data;
-
 extern int mii_link_ok (struct mii_if_info *mii);
 extern int mii_nway_restart (struct mii_if_info *mii);
 extern int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd);
 extern int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd);
+extern int mii_check_gmii_support(struct mii_if_info *mii);
 extern void mii_check_link (struct mii_if_info *mii);
 extern unsigned int mii_check_media (struct mii_if_info *mii,
                                     unsigned int ok_to_print,
@@ -167,16 +182,6 @@ extern int generic_mii_ioctl(struct mii_if_info *mii_if,
                             unsigned int *duplex_changed);
 
 
-
-/* This structure is used in all SIOCxMIIxxx ioctl calls */
-struct mii_ioctl_data {
-       u16             phy_id;
-       u16             reg_num;
-       u16             val_in;
-       u16             val_out;
-};
-
-
 static inline struct mii_ioctl_data *if_mii(struct ifreq *rq)
 {
        return (struct mii_ioctl_data *) &rq->ifr_ifru;
@@ -234,5 +239,44 @@ 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
+ * @rmtadv: value of MII LPA register
+ *
+ * Resolve full duplex flow control as per IEEE 802.3-2005 table 28B-3
+ */
+static inline u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv)
+{
+       u8 cap = 0;
+
+       if (lcladv & rmtadv & ADVERTISE_PAUSE_CAP) {
+               cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
+       } else if (lcladv & rmtadv & ADVERTISE_PAUSE_ASYM) {
+               if (lcladv & ADVERTISE_PAUSE_CAP)
+                       cap = FLOW_CTRL_RX;
+               else if (rmtadv & ADVERTISE_PAUSE_CAP)
+                       cap = FLOW_CTRL_TX;
+       }
+
+       return cap;
+}
 
+#endif /* __KERNEL__ */
 #endif /* __LINUX_MII_H__ */