aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-11-29 10:08:41 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-29 20:23:53 -0500
commite58f69f4082f60076885798fae8f3a17ea713bf6 (patch)
treeafd86e4023e266747c8f63d5369c268e1269ff22 /drivers/net/sfc
parent5784946068f81c5f1cce2906a7655652e34f44f3 (diff)
sfc: Extend loopback mode enumeration
New NICs and PHYs support a wider variety of loopback modes. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc')
-rw-r--r--drivers/net/sfc/efx.c19
-rw-r--r--drivers/net/sfc/enum.h106
-rw-r--r--drivers/net/sfc/falcon_xmac.c2
-rw-r--r--drivers/net/sfc/mdio_10g.c4
-rw-r--r--drivers/net/sfc/net_driver.h2
-rw-r--r--drivers/net/sfc/qt202x_phy.c2
-rw-r--r--drivers/net/sfc/tenxpress.c4
7 files changed, 111 insertions, 28 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index e5c33c66eda3..75dcaaedc3e8 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -36,15 +36,32 @@
36const unsigned int efx_loopback_mode_max = LOOPBACK_MAX; 36const unsigned int efx_loopback_mode_max = LOOPBACK_MAX;
37const char *efx_loopback_mode_names[] = { 37const char *efx_loopback_mode_names[] = {
38 [LOOPBACK_NONE] = "NONE", 38 [LOOPBACK_NONE] = "NONE",
39 [LOOPBACK_DATA] = "DATAPATH",
39 [LOOPBACK_GMAC] = "GMAC", 40 [LOOPBACK_GMAC] = "GMAC",
40 [LOOPBACK_XGMII] = "XGMII", 41 [LOOPBACK_XGMII] = "XGMII",
41 [LOOPBACK_XGXS] = "XGXS", 42 [LOOPBACK_XGXS] = "XGXS",
42 [LOOPBACK_XAUI] = "XAUI", 43 [LOOPBACK_XAUI] = "XAUI",
44 [LOOPBACK_GMII] = "GMII",
45 [LOOPBACK_SGMII] = "SGMII",
46 [LOOPBACK_XGBR] = "XGBR",
47 [LOOPBACK_XFI] = "XFI",
48 [LOOPBACK_XAUI_FAR] = "XAUI_FAR",
49 [LOOPBACK_GMII_FAR] = "GMII_FAR",
50 [LOOPBACK_SGMII_FAR] = "SGMII_FAR",
51 [LOOPBACK_XFI_FAR] = "XFI_FAR",
43 [LOOPBACK_GPHY] = "GPHY", 52 [LOOPBACK_GPHY] = "GPHY",
44 [LOOPBACK_PHYXS] = "PHYXS", 53 [LOOPBACK_PHYXS] = "PHYXS",
45 [LOOPBACK_PCS] = "PCS", 54 [LOOPBACK_PCS] = "PCS",
46 [LOOPBACK_PMAPMD] = "PMA/PMD", 55 [LOOPBACK_PMAPMD] = "PMA/PMD",
47 [LOOPBACK_NETWORK] = "NETWORK", 56 [LOOPBACK_XPORT] = "XPORT",
57 [LOOPBACK_XGMII_WS] = "XGMII_WS",
58 [LOOPBACK_XAUI_WS] = "XAUI_WS",
59 [LOOPBACK_XAUI_WS_FAR] = "XAUI_WS_FAR",
60 [LOOPBACK_XAUI_WS_NEAR] = "XAUI_WS_NEAR",
61 [LOOPBACK_GMII_WS] = "GMII_WS",
62 [LOOPBACK_XFI_WS] = "XFI_WS",
63 [LOOPBACK_XFI_WS_FAR] = "XFI_WS_FAR",
64 [LOOPBACK_PHYXS_WS] = "PHYXS_WS",
48}; 65};
49 66
50/* Interrupt mode names (see INT_MODE())) */ 67/* Interrupt mode names (see INT_MODE())) */
diff --git a/drivers/net/sfc/enum.h b/drivers/net/sfc/enum.h
index fcd14b73f24d..7a9e79ab9313 100644
--- a/drivers/net/sfc/enum.h
+++ b/drivers/net/sfc/enum.h
@@ -13,38 +13,101 @@
13/** 13/**
14 * enum efx_loopback_mode - loopback modes 14 * enum efx_loopback_mode - loopback modes
15 * @LOOPBACK_NONE: no loopback 15 * @LOOPBACK_NONE: no loopback
16 * @LOOPBACK_GMAC: loopback within GMAC at unspecified level 16 * @LOOPBACK_DATA: data path loopback
17 * @LOOPBACK_XGMII: loopback within XMAC at XGMII level 17 * @LOOPBACK_GMAC: loopback within GMAC
18 * @LOOPBACK_XGXS: loopback within XMAC at XGXS level 18 * @LOOPBACK_XGMII: loopback after XMAC
19 * @LOOPBACK_XAUI: loopback within XMAC at XAUI level 19 * @LOOPBACK_XGXS: loopback within BPX after XGXS
20 * @LOOPBACK_XAUI: loopback within BPX before XAUI serdes
21 * @LOOPBACK_GMII: loopback within BPX after GMAC
22 * @LOOPBACK_SGMII: loopback within BPX within SGMII
23 * @LOOPBACK_XGBR: loopback within BPX within XGBR
24 * @LOOPBACK_XFI: loopback within BPX before XFI serdes
25 * @LOOPBACK_XAUI_FAR: loopback within BPX after XAUI serdes
26 * @LOOPBACK_GMII_FAR: loopback within BPX before SGMII
27 * @LOOPBACK_SGMII_FAR: loopback within BPX after SGMII
28 * @LOOPBACK_XFI_FAR: loopback after XFI serdes
20 * @LOOPBACK_GPHY: loopback within 1G PHY at unspecified level 29 * @LOOPBACK_GPHY: loopback within 1G PHY at unspecified level
21 * @LOOPBACK_PHYXS: loopback within 10G PHY at PHYXS level 30 * @LOOPBACK_PHYXS: loopback within 10G PHY at PHYXS level
22 * @LOOPBACK_PCS: loopback within 10G PHY at PCS level 31 * @LOOPBACK_PCS: loopback within 10G PHY at PCS level
23 * @LOOPBACK_PMAPMD: loopback within 10G PHY at PMAPMD level 32 * @LOOPBACK_PMAPMD: loopback within 10G PHY at PMAPMD level
24 * @LOOPBACK_NETWORK: reflecting loopback (even further than furthest!) 33 * @LOOPBACK_XPORT: cross port loopback
34 * @LOOPBACK_XGMII_WS: wireside loopback excluding XMAC
35 * @LOOPBACK_XAUI_WS: wireside loopback within BPX within XAUI serdes
36 * @LOOPBACK_XAUI_WS_FAR: wireside loopback within BPX including XAUI serdes
37 * @LOOPBACK_XAUI_WS_NEAR: wireside loopback within BPX excluding XAUI serdes
38 * @LOOPBACK_GMII_WS: wireside loopback excluding GMAC
39 * @LOOPBACK_XFI_WS: wireside loopback excluding XFI serdes
40 * @LOOPBACK_XFI_WS_FAR: wireside loopback including XFI serdes
41 * @LOOPBACK_PHYXS_WS: wireside loopback within 10G PHY at PHYXS level
25 */ 42 */
26/* Please keep in order and up-to-date w.r.t the following two #defines */ 43/* Please keep up-to-date w.r.t the following two #defines */
27enum efx_loopback_mode { 44enum efx_loopback_mode {
28 LOOPBACK_NONE = 0, 45 LOOPBACK_NONE = 0,
29 LOOPBACK_GMAC = 1, 46 LOOPBACK_DATA = 1,
30 LOOPBACK_XGMII = 2, 47 LOOPBACK_GMAC = 2,
31 LOOPBACK_XGXS = 3, 48 LOOPBACK_XGMII = 3,
32 LOOPBACK_XAUI = 4, 49 LOOPBACK_XGXS = 4,
33 LOOPBACK_GPHY = 5, 50 LOOPBACK_XAUI = 5,
34 LOOPBACK_PHYXS = 6, 51 LOOPBACK_GMII = 6,
35 LOOPBACK_PCS = 7, 52 LOOPBACK_SGMII = 7,
36 LOOPBACK_PMAPMD = 8, 53 LOOPBACK_XGBR = 8,
37 LOOPBACK_NETWORK = 9, 54 LOOPBACK_XFI = 9,
55 LOOPBACK_XAUI_FAR = 10,
56 LOOPBACK_GMII_FAR = 11,
57 LOOPBACK_SGMII_FAR = 12,
58 LOOPBACK_XFI_FAR = 13,
59 LOOPBACK_GPHY = 14,
60 LOOPBACK_PHYXS = 15,
61 LOOPBACK_PCS = 16,
62 LOOPBACK_PMAPMD = 17,
63 LOOPBACK_XPORT = 18,
64 LOOPBACK_XGMII_WS = 19,
65 LOOPBACK_XAUI_WS = 20,
66 LOOPBACK_XAUI_WS_FAR = 21,
67 LOOPBACK_XAUI_WS_NEAR = 22,
68 LOOPBACK_GMII_WS = 23,
69 LOOPBACK_XFI_WS = 24,
70 LOOPBACK_XFI_WS_FAR = 25,
71 LOOPBACK_PHYXS_WS = 26,
38 LOOPBACK_MAX 72 LOOPBACK_MAX
39}; 73};
40
41#define LOOPBACK_TEST_MAX LOOPBACK_PMAPMD 74#define LOOPBACK_TEST_MAX LOOPBACK_PMAPMD
42 75
43/* These loopbacks occur within the controller */ 76/* These loopbacks occur within the controller */
44#define LOOPBACKS_INTERNAL ((1 << LOOPBACK_GMAC) | \ 77#define LOOPBACKS_INTERNAL ((1 << LOOPBACK_DATA) | \
45 (1 << LOOPBACK_XGMII)| \ 78 (1 << LOOPBACK_GMAC) | \
46 (1 << LOOPBACK_XGXS) | \ 79 (1 << LOOPBACK_XGMII)| \
47 (1 << LOOPBACK_XAUI)) 80 (1 << LOOPBACK_XGXS) | \
81 (1 << LOOPBACK_XAUI) | \
82 (1 << LOOPBACK_GMII) | \
83 (1 << LOOPBACK_SGMII) | \
84 (1 << LOOPBACK_SGMII) | \
85 (1 << LOOPBACK_XGBR) | \
86 (1 << LOOPBACK_XFI) | \
87 (1 << LOOPBACK_XAUI_FAR) | \
88 (1 << LOOPBACK_GMII_FAR) | \
89 (1 << LOOPBACK_SGMII_FAR) | \
90 (1 << LOOPBACK_XFI_FAR) | \
91 (1 << LOOPBACK_XGMII_WS) | \
92 (1 << LOOPBACK_XAUI_WS) | \
93 (1 << LOOPBACK_XAUI_WS_FAR) | \
94 (1 << LOOPBACK_XAUI_WS_NEAR) | \
95 (1 << LOOPBACK_GMII_WS) | \
96 (1 << LOOPBACK_XFI_WS) | \
97 (1 << LOOPBACK_XFI_WS_FAR))
98
99#define LOOPBACKS_WS ((1 << LOOPBACK_XGMII_WS) | \
100 (1 << LOOPBACK_XAUI_WS) | \
101 (1 << LOOPBACK_XAUI_WS_FAR) | \
102 (1 << LOOPBACK_XAUI_WS_NEAR) | \
103 (1 << LOOPBACK_GMII_WS) | \
104 (1 << LOOPBACK_XFI_WS) | \
105 (1 << LOOPBACK_XFI_WS_FAR) | \
106 (1 << LOOPBACK_PHYXS_WS))
107
108#define LOOPBACKS_EXTERNAL(_efx) \
109 ((_efx)->loopback_modes & ~LOOPBACKS_INTERNAL & \
110 ~(1 << LOOPBACK_NONE))
48 111
49#define LOOPBACK_MASK(_efx) \ 112#define LOOPBACK_MASK(_efx) \
50 (1 << (_efx)->loopback_mode) 113 (1 << (_efx)->loopback_mode)
@@ -52,6 +115,9 @@ enum efx_loopback_mode {
52#define LOOPBACK_INTERNAL(_efx) \ 115#define LOOPBACK_INTERNAL(_efx) \
53 (!!(LOOPBACKS_INTERNAL & LOOPBACK_MASK(_efx))) 116 (!!(LOOPBACKS_INTERNAL & LOOPBACK_MASK(_efx)))
54 117
118#define LOOPBACK_EXTERNAL(_efx) \
119 (!!(LOOPBACK_MASK(_efx) & LOOPBACKS_EXTERNAL(_efx)))
120
55#define LOOPBACK_CHANGED(_from, _to, _mask) \ 121#define LOOPBACK_CHANGED(_from, _to, _mask) \
56 (!!((LOOPBACK_MASK(_from) ^ LOOPBACK_MASK(_to)) & (_mask))) 122 (!!((LOOPBACK_MASK(_from) ^ LOOPBACK_MASK(_to)) & (_mask)))
57 123
diff --git a/drivers/net/sfc/falcon_xmac.c b/drivers/net/sfc/falcon_xmac.c
index 898afc1b5ef1..83da79279a95 100644
--- a/drivers/net/sfc/falcon_xmac.c
+++ b/drivers/net/sfc/falcon_xmac.c
@@ -249,7 +249,7 @@ static bool falcon_check_xaui_link_up(struct efx_nic *efx, int tries)
249{ 249{
250 bool mac_up = falcon_xaui_link_ok(efx); 250 bool mac_up = falcon_xaui_link_ok(efx);
251 251
252 if ((efx->loopback_mode == LOOPBACK_NETWORK) || 252 if (LOOPBACK_MASK(efx) & LOOPBACKS_EXTERNAL(efx) & LOOPBACKS_WS ||
253 efx_phy_mode_disabled(efx->phy_mode)) 253 efx_phy_mode_disabled(efx->phy_mode))
254 /* XAUI link is expected to be down */ 254 /* XAUI link is expected to be down */
255 return mac_up; 255 return mac_up;
diff --git a/drivers/net/sfc/mdio_10g.c b/drivers/net/sfc/mdio_10g.c
index 1f62a5c002fd..e6ca988abbb5 100644
--- a/drivers/net/sfc/mdio_10g.c
+++ b/drivers/net/sfc/mdio_10g.c
@@ -173,7 +173,7 @@ bool efx_mdio_links_ok(struct efx_nic *efx, unsigned int mmd_mask)
173 * of mmd's */ 173 * of mmd's */
174 if (LOOPBACK_INTERNAL(efx)) 174 if (LOOPBACK_INTERNAL(efx))
175 return true; 175 return true;
176 else if (efx->loopback_mode == LOOPBACK_NETWORK) 176 else if (LOOPBACK_MASK(efx) & LOOPBACKS_WS)
177 return false; 177 return false;
178 else if (efx_phy_mode_disabled(efx->phy_mode)) 178 else if (efx_phy_mode_disabled(efx->phy_mode))
179 return false; 179 return false;
@@ -210,7 +210,7 @@ void efx_mdio_phy_reconfigure(struct efx_nic *efx)
210 efx->loopback_mode == LOOPBACK_PCS); 210 efx->loopback_mode == LOOPBACK_PCS);
211 efx_mdio_set_flag(efx, MDIO_MMD_PHYXS, 211 efx_mdio_set_flag(efx, MDIO_MMD_PHYXS,
212 MDIO_CTRL1, MDIO_PHYXS_CTRL1_LOOPBACK, 212 MDIO_CTRL1, MDIO_PHYXS_CTRL1_LOOPBACK,
213 efx->loopback_mode == LOOPBACK_NETWORK); 213 efx->loopback_mode == LOOPBACK_PHYXS_WS);
214} 214}
215 215
216static void efx_mdio_set_mmd_lpower(struct efx_nic *efx, 216static void efx_mdio_set_mmd_lpower(struct efx_nic *efx,
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 62b2089b05df..cd2debb0a552 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -824,7 +824,7 @@ struct efx_nic {
824 824
825 atomic_t rx_reset; 825 atomic_t rx_reset;
826 enum efx_loopback_mode loopback_mode; 826 enum efx_loopback_mode loopback_mode;
827 unsigned int loopback_modes; 827 u64 loopback_modes;
828 828
829 void *loopback_selftest; 829 void *loopback_selftest;
830}; 830};
diff --git a/drivers/net/sfc/qt202x_phy.c b/drivers/net/sfc/qt202x_phy.c
index 4c38516a5525..49a5ab5efb9a 100644
--- a/drivers/net/sfc/qt202x_phy.c
+++ b/drivers/net/sfc/qt202x_phy.c
@@ -23,7 +23,7 @@
23 23
24#define QT202X_LOOPBACKS ((1 << LOOPBACK_PCS) | \ 24#define QT202X_LOOPBACKS ((1 << LOOPBACK_PCS) | \
25 (1 << LOOPBACK_PMAPMD) | \ 25 (1 << LOOPBACK_PMAPMD) | \
26 (1 << LOOPBACK_NETWORK)) 26 (1 << LOOPBACK_PHYXS_WS))
27 27
28/****************************************************************************/ 28/****************************************************************************/
29/* Quake-specific MDIO registers */ 29/* Quake-specific MDIO registers */
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index c30185393cdc..0dfb2275a158 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -30,13 +30,13 @@
30#define SFX7101_LOOPBACKS ((1 << LOOPBACK_PHYXS) | \ 30#define SFX7101_LOOPBACKS ((1 << LOOPBACK_PHYXS) | \
31 (1 << LOOPBACK_PCS) | \ 31 (1 << LOOPBACK_PCS) | \
32 (1 << LOOPBACK_PMAPMD) | \ 32 (1 << LOOPBACK_PMAPMD) | \
33 (1 << LOOPBACK_NETWORK)) 33 (1 << LOOPBACK_PHYXS_WS))
34 34
35#define SFT9001_LOOPBACKS ((1 << LOOPBACK_GPHY) | \ 35#define SFT9001_LOOPBACKS ((1 << LOOPBACK_GPHY) | \
36 (1 << LOOPBACK_PHYXS) | \ 36 (1 << LOOPBACK_PHYXS) | \
37 (1 << LOOPBACK_PCS) | \ 37 (1 << LOOPBACK_PCS) | \
38 (1 << LOOPBACK_PMAPMD) | \ 38 (1 << LOOPBACK_PMAPMD) | \
39 (1 << LOOPBACK_NETWORK)) 39 (1 << LOOPBACK_PHYXS_WS))
40 40
41/* We complain if we fail to see the link partner as 10G capable this many 41/* We complain if we fail to see the link partner as 10G capable this many
42 * times in a row (must be > 1 as sampling the autoneg. registers is racy) 42 * times in a row (must be > 1 as sampling the autoneg. registers is racy)