18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/****************************************************************************
38c2ecf20Sopenharmony_ci * Driver for Solarflare network controllers and boards
48c2ecf20Sopenharmony_ci * Copyright 2007-2013 Solarflare Communications Inc.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef EF4_ENUM_H
88c2ecf20Sopenharmony_ci#define EF4_ENUM_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/**
118c2ecf20Sopenharmony_ci * enum ef4_loopback_mode - loopback modes
128c2ecf20Sopenharmony_ci * @LOOPBACK_NONE: no loopback
138c2ecf20Sopenharmony_ci * @LOOPBACK_DATA: data path loopback
148c2ecf20Sopenharmony_ci * @LOOPBACK_GMAC: loopback within GMAC
158c2ecf20Sopenharmony_ci * @LOOPBACK_XGMII: loopback after XMAC
168c2ecf20Sopenharmony_ci * @LOOPBACK_XGXS: loopback within BPX after XGXS
178c2ecf20Sopenharmony_ci * @LOOPBACK_XAUI: loopback within BPX before XAUI serdes
188c2ecf20Sopenharmony_ci * @LOOPBACK_GMII: loopback within BPX after GMAC
198c2ecf20Sopenharmony_ci * @LOOPBACK_SGMII: loopback within BPX within SGMII
208c2ecf20Sopenharmony_ci * @LOOPBACK_XGBR: loopback within BPX within XGBR
218c2ecf20Sopenharmony_ci * @LOOPBACK_XFI: loopback within BPX before XFI serdes
228c2ecf20Sopenharmony_ci * @LOOPBACK_XAUI_FAR: loopback within BPX after XAUI serdes
238c2ecf20Sopenharmony_ci * @LOOPBACK_GMII_FAR: loopback within BPX before SGMII
248c2ecf20Sopenharmony_ci * @LOOPBACK_SGMII_FAR: loopback within BPX after SGMII
258c2ecf20Sopenharmony_ci * @LOOPBACK_XFI_FAR: loopback after XFI serdes
268c2ecf20Sopenharmony_ci * @LOOPBACK_GPHY: loopback within 1G PHY at unspecified level
278c2ecf20Sopenharmony_ci * @LOOPBACK_PHYXS: loopback within 10G PHY at PHYXS level
288c2ecf20Sopenharmony_ci * @LOOPBACK_PCS: loopback within 10G PHY at PCS level
298c2ecf20Sopenharmony_ci * @LOOPBACK_PMAPMD: loopback within 10G PHY at PMAPMD level
308c2ecf20Sopenharmony_ci * @LOOPBACK_XPORT: cross port loopback
318c2ecf20Sopenharmony_ci * @LOOPBACK_XGMII_WS: wireside loopback excluding XMAC
328c2ecf20Sopenharmony_ci * @LOOPBACK_XAUI_WS: wireside loopback within BPX within XAUI serdes
338c2ecf20Sopenharmony_ci * @LOOPBACK_XAUI_WS_FAR: wireside loopback within BPX including XAUI serdes
348c2ecf20Sopenharmony_ci * @LOOPBACK_XAUI_WS_NEAR: wireside loopback within BPX excluding XAUI serdes
358c2ecf20Sopenharmony_ci * @LOOPBACK_GMII_WS: wireside loopback excluding GMAC
368c2ecf20Sopenharmony_ci * @LOOPBACK_XFI_WS: wireside loopback excluding XFI serdes
378c2ecf20Sopenharmony_ci * @LOOPBACK_XFI_WS_FAR: wireside loopback including XFI serdes
388c2ecf20Sopenharmony_ci * @LOOPBACK_PHYXS_WS: wireside loopback within 10G PHY at PHYXS level
398c2ecf20Sopenharmony_ci */
408c2ecf20Sopenharmony_ci/* Please keep up-to-date w.r.t the following two #defines */
418c2ecf20Sopenharmony_cienum ef4_loopback_mode {
428c2ecf20Sopenharmony_ci	LOOPBACK_NONE = 0,
438c2ecf20Sopenharmony_ci	LOOPBACK_DATA = 1,
448c2ecf20Sopenharmony_ci	LOOPBACK_GMAC = 2,
458c2ecf20Sopenharmony_ci	LOOPBACK_XGMII = 3,
468c2ecf20Sopenharmony_ci	LOOPBACK_XGXS = 4,
478c2ecf20Sopenharmony_ci	LOOPBACK_XAUI = 5,
488c2ecf20Sopenharmony_ci	LOOPBACK_GMII = 6,
498c2ecf20Sopenharmony_ci	LOOPBACK_SGMII = 7,
508c2ecf20Sopenharmony_ci	LOOPBACK_XGBR = 8,
518c2ecf20Sopenharmony_ci	LOOPBACK_XFI = 9,
528c2ecf20Sopenharmony_ci	LOOPBACK_XAUI_FAR = 10,
538c2ecf20Sopenharmony_ci	LOOPBACK_GMII_FAR = 11,
548c2ecf20Sopenharmony_ci	LOOPBACK_SGMII_FAR = 12,
558c2ecf20Sopenharmony_ci	LOOPBACK_XFI_FAR = 13,
568c2ecf20Sopenharmony_ci	LOOPBACK_GPHY = 14,
578c2ecf20Sopenharmony_ci	LOOPBACK_PHYXS = 15,
588c2ecf20Sopenharmony_ci	LOOPBACK_PCS = 16,
598c2ecf20Sopenharmony_ci	LOOPBACK_PMAPMD = 17,
608c2ecf20Sopenharmony_ci	LOOPBACK_XPORT = 18,
618c2ecf20Sopenharmony_ci	LOOPBACK_XGMII_WS = 19,
628c2ecf20Sopenharmony_ci	LOOPBACK_XAUI_WS = 20,
638c2ecf20Sopenharmony_ci	LOOPBACK_XAUI_WS_FAR = 21,
648c2ecf20Sopenharmony_ci	LOOPBACK_XAUI_WS_NEAR = 22,
658c2ecf20Sopenharmony_ci	LOOPBACK_GMII_WS = 23,
668c2ecf20Sopenharmony_ci	LOOPBACK_XFI_WS = 24,
678c2ecf20Sopenharmony_ci	LOOPBACK_XFI_WS_FAR = 25,
688c2ecf20Sopenharmony_ci	LOOPBACK_PHYXS_WS = 26,
698c2ecf20Sopenharmony_ci	LOOPBACK_MAX
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci#define LOOPBACK_TEST_MAX LOOPBACK_PMAPMD
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/* These loopbacks occur within the controller */
748c2ecf20Sopenharmony_ci#define LOOPBACKS_INTERNAL ((1 << LOOPBACK_DATA) |		\
758c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_GMAC) |		\
768c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XGMII)|		\
778c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XGXS) |		\
788c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XAUI) |		\
798c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_GMII) |		\
808c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_SGMII) |		\
818c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XGBR) |		\
828c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XFI) |		\
838c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XAUI_FAR) |		\
848c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_GMII_FAR) |		\
858c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_SGMII_FAR) |		\
868c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XFI_FAR) |		\
878c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XGMII_WS) |		\
888c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XAUI_WS) |		\
898c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XAUI_WS_FAR) |	\
908c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XAUI_WS_NEAR) |	\
918c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_GMII_WS) |		\
928c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XFI_WS) |		\
938c2ecf20Sopenharmony_ci			    (1 << LOOPBACK_XFI_WS_FAR))
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define LOOPBACKS_WS ((1 << LOOPBACK_XGMII_WS) |		\
968c2ecf20Sopenharmony_ci		      (1 << LOOPBACK_XAUI_WS) |			\
978c2ecf20Sopenharmony_ci		      (1 << LOOPBACK_XAUI_WS_FAR) |		\
988c2ecf20Sopenharmony_ci		      (1 << LOOPBACK_XAUI_WS_NEAR) |		\
998c2ecf20Sopenharmony_ci		      (1 << LOOPBACK_GMII_WS) |			\
1008c2ecf20Sopenharmony_ci		      (1 << LOOPBACK_XFI_WS) |			\
1018c2ecf20Sopenharmony_ci		      (1 << LOOPBACK_XFI_WS_FAR) |		\
1028c2ecf20Sopenharmony_ci		      (1 << LOOPBACK_PHYXS_WS))
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#define LOOPBACKS_EXTERNAL(_efx)					\
1058c2ecf20Sopenharmony_ci	((_efx)->loopback_modes & ~LOOPBACKS_INTERNAL &			\
1068c2ecf20Sopenharmony_ci	 ~(1 << LOOPBACK_NONE))
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci#define LOOPBACK_MASK(_efx)			\
1098c2ecf20Sopenharmony_ci	(1 << (_efx)->loopback_mode)
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#define LOOPBACK_INTERNAL(_efx)				\
1128c2ecf20Sopenharmony_ci	(!!(LOOPBACKS_INTERNAL & LOOPBACK_MASK(_efx)))
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define LOOPBACK_EXTERNAL(_efx)				\
1158c2ecf20Sopenharmony_ci	(!!(LOOPBACK_MASK(_efx) & LOOPBACKS_EXTERNAL(_efx)))
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#define LOOPBACK_CHANGED(_from, _to, _mask)				\
1188c2ecf20Sopenharmony_ci	(!!((LOOPBACK_MASK(_from) ^ LOOPBACK_MASK(_to)) & (_mask)))
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define LOOPBACK_OUT_OF(_from, _to, _mask)				\
1218c2ecf20Sopenharmony_ci	((LOOPBACK_MASK(_from) & (_mask)) && !(LOOPBACK_MASK(_to) & (_mask)))
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci/*****************************************************************************/
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci/**
1268c2ecf20Sopenharmony_ci * enum reset_type - reset types
1278c2ecf20Sopenharmony_ci *
1288c2ecf20Sopenharmony_ci * %RESET_TYPE_INVSIBLE, %RESET_TYPE_ALL, %RESET_TYPE_WORLD and
1298c2ecf20Sopenharmony_ci * %RESET_TYPE_DISABLE specify the method/scope of the reset.  The
1308c2ecf20Sopenharmony_ci * other valuesspecify reasons, which ef4_schedule_reset() will choose
1318c2ecf20Sopenharmony_ci * a method for.
1328c2ecf20Sopenharmony_ci *
1338c2ecf20Sopenharmony_ci * Reset methods are numbered in order of increasing scope.
1348c2ecf20Sopenharmony_ci *
1358c2ecf20Sopenharmony_ci * @RESET_TYPE_INVISIBLE: Reset datapath and MAC
1368c2ecf20Sopenharmony_ci * @RESET_TYPE_RECOVER_OR_ALL: Try to recover. Apply RESET_TYPE_ALL
1378c2ecf20Sopenharmony_ci * if unsuccessful.
1388c2ecf20Sopenharmony_ci * @RESET_TYPE_ALL: Reset datapath, MAC and PHY
1398c2ecf20Sopenharmony_ci * @RESET_TYPE_WORLD: Reset as much as possible
1408c2ecf20Sopenharmony_ci * @RESET_TYPE_RECOVER_OR_DISABLE: Try to recover. Apply RESET_TYPE_DISABLE if
1418c2ecf20Sopenharmony_ci * unsuccessful.
1428c2ecf20Sopenharmony_ci * @RESET_TYPE_DATAPATH: Reset datapath only.
1438c2ecf20Sopenharmony_ci * @RESET_TYPE_DISABLE: Reset datapath, MAC and PHY; leave NIC disabled
1448c2ecf20Sopenharmony_ci * @RESET_TYPE_TX_WATCHDOG: reset due to TX watchdog
1458c2ecf20Sopenharmony_ci * @RESET_TYPE_INT_ERROR: reset due to internal error
1468c2ecf20Sopenharmony_ci * @RESET_TYPE_RX_RECOVERY: reset to recover from RX datapath errors
1478c2ecf20Sopenharmony_ci * @RESET_TYPE_DMA_ERROR: DMA error
1488c2ecf20Sopenharmony_ci * @RESET_TYPE_TX_SKIP: hardware completed empty tx descriptors
1498c2ecf20Sopenharmony_ci */
1508c2ecf20Sopenharmony_cienum reset_type {
1518c2ecf20Sopenharmony_ci	RESET_TYPE_INVISIBLE,
1528c2ecf20Sopenharmony_ci	RESET_TYPE_RECOVER_OR_ALL,
1538c2ecf20Sopenharmony_ci	RESET_TYPE_ALL,
1548c2ecf20Sopenharmony_ci	RESET_TYPE_WORLD,
1558c2ecf20Sopenharmony_ci	RESET_TYPE_RECOVER_OR_DISABLE,
1568c2ecf20Sopenharmony_ci	RESET_TYPE_DATAPATH,
1578c2ecf20Sopenharmony_ci	RESET_TYPE_DISABLE,
1588c2ecf20Sopenharmony_ci	RESET_TYPE_MAX_METHOD,
1598c2ecf20Sopenharmony_ci	RESET_TYPE_TX_WATCHDOG,
1608c2ecf20Sopenharmony_ci	RESET_TYPE_INT_ERROR,
1618c2ecf20Sopenharmony_ci	RESET_TYPE_RX_RECOVERY,
1628c2ecf20Sopenharmony_ci	RESET_TYPE_DMA_ERROR,
1638c2ecf20Sopenharmony_ci	RESET_TYPE_TX_SKIP,
1648c2ecf20Sopenharmony_ci	RESET_TYPE_MAX,
1658c2ecf20Sopenharmony_ci};
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci#endif /* EF4_ENUM_H */
168