xref: /linux/drivers/net/ethernet/sfc/enum.h (revision 3de82b91)
1874aeea5SJeff Kirsher /****************************************************************************
2874aeea5SJeff Kirsher  * Driver for Solarflare Solarstorm network controllers and boards
3874aeea5SJeff Kirsher  * Copyright 2007-2009 Solarflare Communications Inc.
4874aeea5SJeff Kirsher  *
5874aeea5SJeff Kirsher  * This program is free software; you can redistribute it and/or modify it
6874aeea5SJeff Kirsher  * under the terms of the GNU General Public License version 2 as published
7874aeea5SJeff Kirsher  * by the Free Software Foundation, incorporated herein by reference.
8874aeea5SJeff Kirsher  */
9874aeea5SJeff Kirsher 
10874aeea5SJeff Kirsher #ifndef EFX_ENUM_H
11874aeea5SJeff Kirsher #define EFX_ENUM_H
12874aeea5SJeff Kirsher 
13874aeea5SJeff Kirsher /**
14874aeea5SJeff Kirsher  * enum efx_loopback_mode - loopback modes
15874aeea5SJeff Kirsher  * @LOOPBACK_NONE: no loopback
16874aeea5SJeff Kirsher  * @LOOPBACK_DATA: data path loopback
17874aeea5SJeff Kirsher  * @LOOPBACK_GMAC: loopback within GMAC
18874aeea5SJeff Kirsher  * @LOOPBACK_XGMII: loopback after XMAC
19874aeea5SJeff Kirsher  * @LOOPBACK_XGXS: loopback within BPX after XGXS
20874aeea5SJeff Kirsher  * @LOOPBACK_XAUI: loopback within BPX before XAUI serdes
21874aeea5SJeff Kirsher  * @LOOPBACK_GMII: loopback within BPX after GMAC
22874aeea5SJeff Kirsher  * @LOOPBACK_SGMII: loopback within BPX within SGMII
23874aeea5SJeff Kirsher  * @LOOPBACK_XGBR: loopback within BPX within XGBR
24874aeea5SJeff Kirsher  * @LOOPBACK_XFI: loopback within BPX before XFI serdes
25874aeea5SJeff Kirsher  * @LOOPBACK_XAUI_FAR: loopback within BPX after XAUI serdes
26874aeea5SJeff Kirsher  * @LOOPBACK_GMII_FAR: loopback within BPX before SGMII
27874aeea5SJeff Kirsher  * @LOOPBACK_SGMII_FAR: loopback within BPX after SGMII
28874aeea5SJeff Kirsher  * @LOOPBACK_XFI_FAR: loopback after XFI serdes
29874aeea5SJeff Kirsher  * @LOOPBACK_GPHY: loopback within 1G PHY at unspecified level
30874aeea5SJeff Kirsher  * @LOOPBACK_PHYXS: loopback within 10G PHY at PHYXS level
31874aeea5SJeff Kirsher  * @LOOPBACK_PCS: loopback within 10G PHY at PCS level
32874aeea5SJeff Kirsher  * @LOOPBACK_PMAPMD: loopback within 10G PHY at PMAPMD level
33874aeea5SJeff Kirsher  * @LOOPBACK_XPORT: cross port loopback
34874aeea5SJeff Kirsher  * @LOOPBACK_XGMII_WS: wireside loopback excluding XMAC
35874aeea5SJeff Kirsher  * @LOOPBACK_XAUI_WS: wireside loopback within BPX within XAUI serdes
36874aeea5SJeff Kirsher  * @LOOPBACK_XAUI_WS_FAR: wireside loopback within BPX including XAUI serdes
37874aeea5SJeff Kirsher  * @LOOPBACK_XAUI_WS_NEAR: wireside loopback within BPX excluding XAUI serdes
38874aeea5SJeff Kirsher  * @LOOPBACK_GMII_WS: wireside loopback excluding GMAC
39874aeea5SJeff Kirsher  * @LOOPBACK_XFI_WS: wireside loopback excluding XFI serdes
40874aeea5SJeff Kirsher  * @LOOPBACK_XFI_WS_FAR: wireside loopback including XFI serdes
41874aeea5SJeff Kirsher  * @LOOPBACK_PHYXS_WS: wireside loopback within 10G PHY at PHYXS level
42874aeea5SJeff Kirsher  */
43874aeea5SJeff Kirsher /* Please keep up-to-date w.r.t the following two #defines */
44874aeea5SJeff Kirsher enum efx_loopback_mode {
45874aeea5SJeff Kirsher 	LOOPBACK_NONE = 0,
46874aeea5SJeff Kirsher 	LOOPBACK_DATA = 1,
47874aeea5SJeff Kirsher 	LOOPBACK_GMAC = 2,
48874aeea5SJeff Kirsher 	LOOPBACK_XGMII = 3,
49874aeea5SJeff Kirsher 	LOOPBACK_XGXS = 4,
50874aeea5SJeff Kirsher 	LOOPBACK_XAUI = 5,
51874aeea5SJeff Kirsher 	LOOPBACK_GMII = 6,
52874aeea5SJeff Kirsher 	LOOPBACK_SGMII = 7,
53874aeea5SJeff Kirsher 	LOOPBACK_XGBR = 8,
54874aeea5SJeff Kirsher 	LOOPBACK_XFI = 9,
55874aeea5SJeff Kirsher 	LOOPBACK_XAUI_FAR = 10,
56874aeea5SJeff Kirsher 	LOOPBACK_GMII_FAR = 11,
57874aeea5SJeff Kirsher 	LOOPBACK_SGMII_FAR = 12,
58874aeea5SJeff Kirsher 	LOOPBACK_XFI_FAR = 13,
59874aeea5SJeff Kirsher 	LOOPBACK_GPHY = 14,
60874aeea5SJeff Kirsher 	LOOPBACK_PHYXS = 15,
61874aeea5SJeff Kirsher 	LOOPBACK_PCS = 16,
62874aeea5SJeff Kirsher 	LOOPBACK_PMAPMD = 17,
63874aeea5SJeff Kirsher 	LOOPBACK_XPORT = 18,
64874aeea5SJeff Kirsher 	LOOPBACK_XGMII_WS = 19,
65874aeea5SJeff Kirsher 	LOOPBACK_XAUI_WS = 20,
66874aeea5SJeff Kirsher 	LOOPBACK_XAUI_WS_FAR = 21,
67874aeea5SJeff Kirsher 	LOOPBACK_XAUI_WS_NEAR = 22,
68874aeea5SJeff Kirsher 	LOOPBACK_GMII_WS = 23,
69874aeea5SJeff Kirsher 	LOOPBACK_XFI_WS = 24,
70874aeea5SJeff Kirsher 	LOOPBACK_XFI_WS_FAR = 25,
71874aeea5SJeff Kirsher 	LOOPBACK_PHYXS_WS = 26,
72874aeea5SJeff Kirsher 	LOOPBACK_MAX
73874aeea5SJeff Kirsher };
74874aeea5SJeff Kirsher #define LOOPBACK_TEST_MAX LOOPBACK_PMAPMD
75874aeea5SJeff Kirsher 
76874aeea5SJeff Kirsher /* These loopbacks occur within the controller */
77874aeea5SJeff Kirsher #define LOOPBACKS_INTERNAL ((1 << LOOPBACK_DATA) |		\
78874aeea5SJeff Kirsher 			    (1 << LOOPBACK_GMAC) |		\
79874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XGMII)|		\
80874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XGXS) |		\
81874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XAUI) |		\
82874aeea5SJeff Kirsher 			    (1 << LOOPBACK_GMII) |		\
83874aeea5SJeff Kirsher 			    (1 << LOOPBACK_SGMII) |		\
84874aeea5SJeff Kirsher 			    (1 << LOOPBACK_SGMII) |		\
85874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XGBR) |		\
86874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XFI) |		\
87874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XAUI_FAR) |		\
88874aeea5SJeff Kirsher 			    (1 << LOOPBACK_GMII_FAR) |		\
89874aeea5SJeff Kirsher 			    (1 << LOOPBACK_SGMII_FAR) |		\
90874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XFI_FAR) |		\
91874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XGMII_WS) |		\
92874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XAUI_WS) |		\
93874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XAUI_WS_FAR) |	\
94874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XAUI_WS_NEAR) |	\
95874aeea5SJeff Kirsher 			    (1 << LOOPBACK_GMII_WS) |		\
96874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XFI_WS) |		\
97874aeea5SJeff Kirsher 			    (1 << LOOPBACK_XFI_WS_FAR))
98874aeea5SJeff Kirsher 
99874aeea5SJeff Kirsher #define LOOPBACKS_WS ((1 << LOOPBACK_XGMII_WS) |		\
100874aeea5SJeff Kirsher 		      (1 << LOOPBACK_XAUI_WS) |			\
101874aeea5SJeff Kirsher 		      (1 << LOOPBACK_XAUI_WS_FAR) |		\
102874aeea5SJeff Kirsher 		      (1 << LOOPBACK_XAUI_WS_NEAR) |		\
103874aeea5SJeff Kirsher 		      (1 << LOOPBACK_GMII_WS) |			\
104874aeea5SJeff Kirsher 		      (1 << LOOPBACK_XFI_WS) |			\
105874aeea5SJeff Kirsher 		      (1 << LOOPBACK_XFI_WS_FAR) |		\
106874aeea5SJeff Kirsher 		      (1 << LOOPBACK_PHYXS_WS))
107874aeea5SJeff Kirsher 
108874aeea5SJeff Kirsher #define LOOPBACKS_EXTERNAL(_efx)					\
109874aeea5SJeff Kirsher 	((_efx)->loopback_modes & ~LOOPBACKS_INTERNAL &			\
110874aeea5SJeff Kirsher 	 ~(1 << LOOPBACK_NONE))
111874aeea5SJeff Kirsher 
112874aeea5SJeff Kirsher #define LOOPBACK_MASK(_efx)			\
113874aeea5SJeff Kirsher 	(1 << (_efx)->loopback_mode)
114874aeea5SJeff Kirsher 
115874aeea5SJeff Kirsher #define LOOPBACK_INTERNAL(_efx)				\
116874aeea5SJeff Kirsher 	(!!(LOOPBACKS_INTERNAL & LOOPBACK_MASK(_efx)))
117874aeea5SJeff Kirsher 
118874aeea5SJeff Kirsher #define LOOPBACK_EXTERNAL(_efx)				\
119874aeea5SJeff Kirsher 	(!!(LOOPBACK_MASK(_efx) & LOOPBACKS_EXTERNAL(_efx)))
120874aeea5SJeff Kirsher 
121874aeea5SJeff Kirsher #define LOOPBACK_CHANGED(_from, _to, _mask)				\
122874aeea5SJeff Kirsher 	(!!((LOOPBACK_MASK(_from) ^ LOOPBACK_MASK(_to)) & (_mask)))
123874aeea5SJeff Kirsher 
124874aeea5SJeff Kirsher #define LOOPBACK_OUT_OF(_from, _to, _mask)				\
125874aeea5SJeff Kirsher 	((LOOPBACK_MASK(_from) & (_mask)) && !(LOOPBACK_MASK(_to) & (_mask)))
126874aeea5SJeff Kirsher 
127874aeea5SJeff Kirsher /*****************************************************************************/
128874aeea5SJeff Kirsher 
129874aeea5SJeff Kirsher /**
130874aeea5SJeff Kirsher  * enum reset_type - reset types
131874aeea5SJeff Kirsher  *
132874aeea5SJeff Kirsher  * %RESET_TYPE_INVSIBLE, %RESET_TYPE_ALL, %RESET_TYPE_WORLD and
133874aeea5SJeff Kirsher  * %RESET_TYPE_DISABLE specify the method/scope of the reset.  The
134874aeea5SJeff Kirsher  * other valuesspecify reasons, which efx_schedule_reset() will choose
135874aeea5SJeff Kirsher  * a method for.
136874aeea5SJeff Kirsher  *
137874aeea5SJeff Kirsher  * Reset methods are numbered in order of increasing scope.
138874aeea5SJeff Kirsher  *
139c2dbab39SBen Hutchings  * @RESET_TYPE_INVISIBLE: Reset datapath and MAC (Falcon only)
140626950dbSAlexandre Rames  * @RESET_TYPE_RECOVER_OR_ALL: Try to recover. Apply RESET_TYPE_ALL
141626950dbSAlexandre Rames  * if unsuccessful.
142c2dbab39SBen Hutchings  * @RESET_TYPE_ALL: Reset datapath, MAC and PHY
143c2dbab39SBen Hutchings  * @RESET_TYPE_WORLD: Reset as much as possible
144626950dbSAlexandre Rames  * @RESET_TYPE_RECOVER_OR_DISABLE: Try to recover. Apply RESET_TYPE_DISABLE if
145626950dbSAlexandre Rames  * unsuccessful.
146c2dbab39SBen Hutchings  * @RESET_TYPE_DISABLE: Reset datapath, MAC and PHY; leave NIC disabled
147874aeea5SJeff Kirsher  * @RESET_TYPE_TX_WATCHDOG: reset due to TX watchdog
148874aeea5SJeff Kirsher  * @RESET_TYPE_INT_ERROR: reset due to internal error
149874aeea5SJeff Kirsher  * @RESET_TYPE_RX_RECOVERY: reset to recover from RX datapath errors
150*3de82b91SAlexandre Rames  * @RESET_TYPE_DMA_ERROR: DMA error
151874aeea5SJeff Kirsher  * @RESET_TYPE_TX_SKIP: hardware completed empty tx descriptors
152874aeea5SJeff Kirsher  * @RESET_TYPE_MC_FAILURE: MC reboot/assertion
153874aeea5SJeff Kirsher  */
154874aeea5SJeff Kirsher enum reset_type {
155874aeea5SJeff Kirsher 	RESET_TYPE_INVISIBLE = 0,
156626950dbSAlexandre Rames 	RESET_TYPE_RECOVER_OR_ALL = 1,
157626950dbSAlexandre Rames 	RESET_TYPE_ALL = 2,
158626950dbSAlexandre Rames 	RESET_TYPE_WORLD = 3,
159626950dbSAlexandre Rames 	RESET_TYPE_RECOVER_OR_DISABLE = 4,
160626950dbSAlexandre Rames 	RESET_TYPE_DISABLE = 5,
161874aeea5SJeff Kirsher 	RESET_TYPE_MAX_METHOD,
162874aeea5SJeff Kirsher 	RESET_TYPE_TX_WATCHDOG,
163874aeea5SJeff Kirsher 	RESET_TYPE_INT_ERROR,
164874aeea5SJeff Kirsher 	RESET_TYPE_RX_RECOVERY,
165*3de82b91SAlexandre Rames 	RESET_TYPE_DMA_ERROR,
166874aeea5SJeff Kirsher 	RESET_TYPE_TX_SKIP,
167874aeea5SJeff Kirsher 	RESET_TYPE_MC_FAILURE,
168874aeea5SJeff Kirsher 	RESET_TYPE_MAX,
169874aeea5SJeff Kirsher };
170874aeea5SJeff Kirsher 
171874aeea5SJeff Kirsher #endif /* EFX_ENUM_H */
172