xref: /openbmc/linux/drivers/net/ethernet/sfc/siena/enum.h (revision 2a598d0b)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /****************************************************************************
3  * Driver for Solarflare network controllers and boards
4  * Copyright 2007-2013 Solarflare Communications Inc.
5  */
6 
7 #ifndef EFX_ENUM_H
8 #define EFX_ENUM_H
9 
10 /**
11  * enum efx_loopback_mode - loopback modes
12  * @LOOPBACK_NONE: no loopback
13  * @LOOPBACK_DATA: data path loopback
14  * @LOOPBACK_GMAC: loopback within GMAC
15  * @LOOPBACK_XGMII: loopback after XMAC
16  * @LOOPBACK_XGXS: loopback within BPX after XGXS
17  * @LOOPBACK_XAUI: loopback within BPX before XAUI serdes
18  * @LOOPBACK_GMII: loopback within BPX after GMAC
19  * @LOOPBACK_SGMII: loopback within BPX within SGMII
20  * @LOOPBACK_XGBR: loopback within BPX within XGBR
21  * @LOOPBACK_XFI: loopback within BPX before XFI serdes
22  * @LOOPBACK_XAUI_FAR: loopback within BPX after XAUI serdes
23  * @LOOPBACK_GMII_FAR: loopback within BPX before SGMII
24  * @LOOPBACK_SGMII_FAR: loopback within BPX after SGMII
25  * @LOOPBACK_XFI_FAR: loopback after XFI serdes
26  * @LOOPBACK_GPHY: loopback within 1G PHY at unspecified level
27  * @LOOPBACK_PHYXS: loopback within 10G PHY at PHYXS level
28  * @LOOPBACK_PCS: loopback within 10G PHY at PCS level
29  * @LOOPBACK_PMAPMD: loopback within 10G PHY at PMAPMD level
30  * @LOOPBACK_XPORT: cross port loopback
31  * @LOOPBACK_XGMII_WS: wireside loopback excluding XMAC
32  * @LOOPBACK_XAUI_WS: wireside loopback within BPX within XAUI serdes
33  * @LOOPBACK_XAUI_WS_FAR: wireside loopback within BPX including XAUI serdes
34  * @LOOPBACK_XAUI_WS_NEAR: wireside loopback within BPX excluding XAUI serdes
35  * @LOOPBACK_GMII_WS: wireside loopback excluding GMAC
36  * @LOOPBACK_XFI_WS: wireside loopback excluding XFI serdes
37  * @LOOPBACK_XFI_WS_FAR: wireside loopback including XFI serdes
38  * @LOOPBACK_PHYXS_WS: wireside loopback within 10G PHY at PHYXS level
39  */
40 /* Please keep up-to-date w.r.t the following two #defines */
41 enum efx_loopback_mode {
42 	LOOPBACK_NONE = 0,
43 	LOOPBACK_DATA = 1,
44 	LOOPBACK_GMAC = 2,
45 	LOOPBACK_XGMII = 3,
46 	LOOPBACK_XGXS = 4,
47 	LOOPBACK_XAUI = 5,
48 	LOOPBACK_GMII = 6,
49 	LOOPBACK_SGMII = 7,
50 	LOOPBACK_XGBR = 8,
51 	LOOPBACK_XFI = 9,
52 	LOOPBACK_XAUI_FAR = 10,
53 	LOOPBACK_GMII_FAR = 11,
54 	LOOPBACK_SGMII_FAR = 12,
55 	LOOPBACK_XFI_FAR = 13,
56 	LOOPBACK_GPHY = 14,
57 	LOOPBACK_PHYXS = 15,
58 	LOOPBACK_PCS = 16,
59 	LOOPBACK_PMAPMD = 17,
60 	LOOPBACK_XPORT = 18,
61 	LOOPBACK_XGMII_WS = 19,
62 	LOOPBACK_XAUI_WS = 20,
63 	LOOPBACK_XAUI_WS_FAR = 21,
64 	LOOPBACK_XAUI_WS_NEAR = 22,
65 	LOOPBACK_GMII_WS = 23,
66 	LOOPBACK_XFI_WS = 24,
67 	LOOPBACK_XFI_WS_FAR = 25,
68 	LOOPBACK_PHYXS_WS = 26,
69 	LOOPBACK_MAX
70 };
71 #define LOOPBACK_TEST_MAX LOOPBACK_PMAPMD
72 
73 /* These loopbacks occur within the controller */
74 #define LOOPBACKS_INTERNAL ((1 << LOOPBACK_DATA) |		\
75 			    (1 << LOOPBACK_GMAC) |		\
76 			    (1 << LOOPBACK_XGMII)|		\
77 			    (1 << LOOPBACK_XGXS) |		\
78 			    (1 << LOOPBACK_XAUI) |		\
79 			    (1 << LOOPBACK_GMII) |		\
80 			    (1 << LOOPBACK_SGMII) |		\
81 			    (1 << LOOPBACK_XGBR) |		\
82 			    (1 << LOOPBACK_XFI) |		\
83 			    (1 << LOOPBACK_XAUI_FAR) |		\
84 			    (1 << LOOPBACK_GMII_FAR) |		\
85 			    (1 << LOOPBACK_SGMII_FAR) |		\
86 			    (1 << LOOPBACK_XFI_FAR) |		\
87 			    (1 << LOOPBACK_XGMII_WS) |		\
88 			    (1 << LOOPBACK_XAUI_WS) |		\
89 			    (1 << LOOPBACK_XAUI_WS_FAR) |	\
90 			    (1 << LOOPBACK_XAUI_WS_NEAR) |	\
91 			    (1 << LOOPBACK_GMII_WS) |		\
92 			    (1 << LOOPBACK_XFI_WS) |		\
93 			    (1 << LOOPBACK_XFI_WS_FAR))
94 
95 #define LOOPBACKS_WS ((1 << LOOPBACK_XGMII_WS) |		\
96 		      (1 << LOOPBACK_XAUI_WS) |			\
97 		      (1 << LOOPBACK_XAUI_WS_FAR) |		\
98 		      (1 << LOOPBACK_XAUI_WS_NEAR) |		\
99 		      (1 << LOOPBACK_GMII_WS) |			\
100 		      (1 << LOOPBACK_XFI_WS) |			\
101 		      (1 << LOOPBACK_XFI_WS_FAR) |		\
102 		      (1 << LOOPBACK_PHYXS_WS))
103 
104 #define LOOPBACKS_EXTERNAL(_efx)					\
105 	((_efx)->loopback_modes & ~LOOPBACKS_INTERNAL &			\
106 	 ~(1 << LOOPBACK_NONE))
107 
108 #define LOOPBACK_MASK(_efx)			\
109 	(1 << (_efx)->loopback_mode)
110 
111 #define LOOPBACK_INTERNAL(_efx)				\
112 	(!!(LOOPBACKS_INTERNAL & LOOPBACK_MASK(_efx)))
113 
114 #define LOOPBACK_EXTERNAL(_efx)				\
115 	(!!(LOOPBACK_MASK(_efx) & LOOPBACKS_EXTERNAL(_efx)))
116 
117 #define LOOPBACK_CHANGED(_from, _to, _mask)				\
118 	(!!((LOOPBACK_MASK(_from) ^ LOOPBACK_MASK(_to)) & (_mask)))
119 
120 #define LOOPBACK_OUT_OF(_from, _to, _mask)				\
121 	((LOOPBACK_MASK(_from) & (_mask)) && !(LOOPBACK_MASK(_to) & (_mask)))
122 
123 /*****************************************************************************/
124 
125 /**
126  * enum reset_type - reset types
127  *
128  * %RESET_TYPE_INVSIBLE, %RESET_TYPE_ALL, %RESET_TYPE_WORLD and
129  * %RESET_TYPE_DISABLE specify the method/scope of the reset.  The
130  * other valuesspecify reasons, which efx_siena_schedule_reset() will choose
131  * a method for.
132  *
133  * Reset methods are numbered in order of increasing scope.
134  *
135  * @RESET_TYPE_INVISIBLE: Reset datapath and MAC (Falcon only)
136  * @RESET_TYPE_RECOVER_OR_ALL: Try to recover. Apply RESET_TYPE_ALL
137  * if unsuccessful.
138  * @RESET_TYPE_ALL: Reset datapath, MAC and PHY
139  * @RESET_TYPE_WORLD: Reset as much as possible
140  * @RESET_TYPE_RECOVER_OR_DISABLE: Try to recover. Apply RESET_TYPE_DISABLE if
141  * unsuccessful.
142  * @RESET_TYPE_DATAPATH: Reset datapath only.
143  * @RESET_TYPE_MC_BIST: MC entering BIST mode.
144  * @RESET_TYPE_DISABLE: Reset datapath, MAC and PHY; leave NIC disabled
145  * @RESET_TYPE_TX_WATCHDOG: reset due to TX watchdog
146  * @RESET_TYPE_INT_ERROR: reset due to internal error
147  * @RESET_TYPE_DMA_ERROR: DMA error
148  * @RESET_TYPE_TX_SKIP: hardware completed empty tx descriptors
149  * @RESET_TYPE_MC_FAILURE: MC reboot/assertion
150  * @RESET_TYPE_MCDI_TIMEOUT: MCDI timeout.
151  */
152 enum reset_type {
153 	RESET_TYPE_INVISIBLE,
154 	RESET_TYPE_RECOVER_OR_ALL,
155 	RESET_TYPE_ALL,
156 	RESET_TYPE_WORLD,
157 	RESET_TYPE_RECOVER_OR_DISABLE,
158 	RESET_TYPE_DATAPATH,
159 	RESET_TYPE_MC_BIST,
160 	RESET_TYPE_DISABLE,
161 	RESET_TYPE_MAX_METHOD,
162 	RESET_TYPE_TX_WATCHDOG,
163 	RESET_TYPE_INT_ERROR,
164 	RESET_TYPE_DMA_ERROR,
165 	RESET_TYPE_TX_SKIP,
166 	RESET_TYPE_MC_FAILURE,
167 	/* RESET_TYPE_MCDI_TIMEOUT is actually a method, not just a reason, but
168 	 * it doesn't fit the scope hierarchy (not well-ordered by inclusion).
169 	 * We encode this by having its enum value be greater than
170 	 * RESET_TYPE_MAX_METHOD.
171 	 */
172 	RESET_TYPE_MCDI_TIMEOUT,
173 	RESET_TYPE_MAX,
174 };
175 
176 #endif /* EFX_ENUM_H */
177