xref: /linux/drivers/net/ethernet/marvell/octeontx2/af/rpm.h (revision 621cde16e49b3ecf7d59a8106a20aaebfb4a59a9)
191c6945eSHariprasad Kelam /* SPDX-License-Identifier: GPL-2.0 */
2c7cd6c5aSSunil Goutham /* Marvell CN10K RPM driver
391c6945eSHariprasad Kelam  *
491c6945eSHariprasad Kelam  * Copyright (C) 2020 Marvell.
591c6945eSHariprasad Kelam  *
691c6945eSHariprasad Kelam  */
791c6945eSHariprasad Kelam 
891c6945eSHariprasad Kelam #ifndef RPM_H
991c6945eSHariprasad Kelam #define RPM_H
1091c6945eSHariprasad Kelam 
11242da439SSubbaraya Sundeep #include <linux/bits.h>
12242da439SSubbaraya Sundeep 
1391c6945eSHariprasad Kelam /* PCI device IDs */
1491c6945eSHariprasad Kelam #define PCI_DEVID_CN10K_RPM		0xA060
15b9d0fedcSHariprasad Kelam #define PCI_SUBSYS_DEVID_CNF10KB_RPM	0xBC00
16b9d0fedcSHariprasad Kelam #define PCI_DEVID_CN10KB_RPM		0xA09F
1791c6945eSHariprasad Kelam 
1891c6945eSHariprasad Kelam /* Registers */
19d1489208SHariprasad Kelam #define RPMX_CMRX_CFG			0x00
20d1489208SHariprasad Kelam #define RPMX_RX_TS_PREPEND              BIT_ULL(22)
212958d17aSHariprasad Kelam #define RPMX_TX_PTP_1S_SUPPORT          BIT_ULL(17)
22b9d0fedcSHariprasad Kelam #define RPMX_CMRX_RX_ID_MAP		0x80
2391c6945eSHariprasad Kelam #define RPMX_CMRX_SW_INT                0x180
2491c6945eSHariprasad Kelam #define RPMX_CMRX_SW_INT_W1S            0x188
2591c6945eSHariprasad Kelam #define RPMX_CMRX_SW_INT_ENA_W1S        0x198
26242da439SSubbaraya Sundeep #define RPMX_CMRX_LINK_CFG		0x1070
273ad3f8f9SHariprasad Kelam #define RPMX_MTI_PCS100X_CONTROL1       0x20000
283ad3f8f9SHariprasad Kelam #define RPMX_MTI_PCS_LBK                BIT_ULL(14)
29ce7a6c31SHariprasad Kelam #define RPMX_MTI_LPCSX_CONTROL(id)     (0x30000 | ((id) * 0x100))
30242da439SSubbaraya Sundeep 
31242da439SSubbaraya Sundeep #define RPMX_CMRX_LINK_RANGE_MASK	GENMASK_ULL(19, 16)
32242da439SSubbaraya Sundeep #define RPMX_CMRX_LINK_BASE_MASK	GENMASK_ULL(11, 0)
331845ada4SRakesh Babu #define RPMX_MTI_MAC100X_COMMAND_CONFIG	0x8010
341845ada4SRakesh Babu #define RPMX_MTI_MAC100X_COMMAND_CONFIG_RX_P_DISABLE	BIT_ULL(29)
351845ada4SRakesh Babu #define RPMX_MTI_MAC100X_COMMAND_CONFIG_TX_P_DISABLE	BIT_ULL(28)
361845ada4SRakesh Babu #define RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE	BIT_ULL(8)
371845ada4SRakesh Babu #define RPMX_MTI_MAC100X_COMMAND_CONFIG_PFC_MODE	BIT_ULL(19)
381845ada4SRakesh Babu #define RPMX_MTI_MAC100X_CL01_PAUSE_QUANTA		0x80A8
391121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL23_PAUSE_QUANTA		0x80B0
401121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL45_PAUSE_QUANTA		0x80B8
411121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL67_PAUSE_QUANTA		0x80C0
421845ada4SRakesh Babu #define RPMX_MTI_MAC100X_CL01_QUANTA_THRESH		0x80C8
431121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL23_QUANTA_THRESH		0x80D0
441121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL45_QUANTA_THRESH		0x80D8
451121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL67_QUANTA_THRESH		0x80E0
461121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL89_PAUSE_QUANTA		0x8108
471121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL1011_PAUSE_QUANTA		0x8110
481121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL1213_PAUSE_QUANTA		0x8118
491121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL1415_PAUSE_QUANTA		0x8120
501121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL89_QUANTA_THRESH		0x8128
511121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL1011_QUANTA_THRESH		0x8130
521121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL1213_QUANTA_THRESH		0x8138
531121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL1415_QUANTA_THRESH		0x8140
541845ada4SRakesh Babu #define RPMX_CMR_RX_OVR_BP		0x4120
551845ada4SRakesh Babu #define RPMX_CMR_RX_OVR_BP_EN(x)	BIT_ULL((x) + 8)
561845ada4SRakesh Babu #define RPMX_CMR_RX_OVR_BP_BP(x)	BIT_ULL((x) + 4)
573e35d198SHariprasad Kelam #define RPMX_CMR_CHAN_MSK_OR            0x4118
58ce7a6c31SHariprasad Kelam #define RPMX_MTI_STAT_RX_STAT_PAGES_COUNTERX 0x12000
59ce7a6c31SHariprasad Kelam #define RPMX_MTI_STAT_TX_STAT_PAGES_COUNTERX 0x13000
60ce7a6c31SHariprasad Kelam #define RPMX_MTI_STAT_DATA_HI_CDC            0x10038
61ce7a6c31SHariprasad Kelam 
6291c6945eSHariprasad Kelam #define RPM_LMAC_FWI			0xa
63fae80edeSGeetha sowjanya #define RPM_TX_EN			BIT_ULL(0)
64fae80edeSGeetha sowjanya #define RPM_RX_EN			BIT_ULL(1)
651121f6b0SSunil Kumar Kori #define RPMX_CMRX_PRT_CBFC_CTL                         0x5B08
661121f6b0SSunil Kumar Kori #define RPMX_CMRX_PRT_CBFC_CTL_LOGL_EN_RX_SHIFT        33
671121f6b0SSunil Kumar Kori #define RPMX_CMRX_PRT_CBFC_CTL_PHYS_BP_SHIFT           16
681121f6b0SSunil Kumar Kori #define RPMX_CMRX_PRT_CBFC_CTL_LOGL_EN_TX_SHIFT        0
691121f6b0SSunil Kumar Kori #define RPM_PFC_CLASS_MASK			       GENMASK_ULL(48, 33)
701121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL89_QUANTA_THRESH		0x8128
711121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_COMMAND_CONFIG_TX_PAD_EN              BIT_ULL(11)
721121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE           BIT_ULL(8)
731121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_FWD              BIT_ULL(7)
741121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL01_PAUSE_QUANTA              0x80A8
751121f6b0SSunil Kumar Kori #define RPMX_MTI_MAC100X_CL89_PAUSE_QUANTA		0x8108
768e151457SHariprasad Kelam #define RPM_DEFAULT_PAUSE_TIME                          0x7FF
772e3e94c2SHariprasad Kelam #define RPMX_CMRX_RX_LOGL_XON				0x4100
7891c6945eSHariprasad Kelam 
792958d17aSHariprasad Kelam #define RPMX_MTI_MAC100X_XIF_MODE		        0x8100
802958d17aSHariprasad Kelam #define RPMX_ONESTEP_ENABLE				BIT_ULL(5)
812958d17aSHariprasad Kelam #define RPMX_TS_BINARY_MODE				BIT_ULL(11)
82b9d0fedcSHariprasad Kelam #define RPMX_CONST1					0x2008
83b9d0fedcSHariprasad Kelam 
8484ad3642SHariprasad Kelam /* FEC stats */
8584ad3642SHariprasad Kelam #define RPMX_MTI_STAT_STATN_CONTROL			0x10018
8684ad3642SHariprasad Kelam #define RPMX_MTI_STAT_DATA_HI_CDC			0x10038
8784ad3642SHariprasad Kelam #define RPMX_RSFEC_RX_CAPTURE				BIT_ULL(27)
88*4c6ce450SSai Krishna #define RPMX_CMD_CLEAR_RX				BIT_ULL(30)
89*4c6ce450SSai Krishna #define RPMX_CMD_CLEAR_TX				BIT_ULL(31)
9084ad3642SHariprasad Kelam #define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_2		0x40050
9184ad3642SHariprasad Kelam #define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_3		0x40058
9284ad3642SHariprasad Kelam #define RPMX_MTI_FCFECX_VL0_CCW_LO			0x38618
9384ad3642SHariprasad Kelam #define RPMX_MTI_FCFECX_VL0_NCCW_LO			0x38620
9484ad3642SHariprasad Kelam #define RPMX_MTI_FCFECX_VL1_CCW_LO			0x38628
9584ad3642SHariprasad Kelam #define RPMX_MTI_FCFECX_VL1_NCCW_LO			0x38630
9684ad3642SHariprasad Kelam #define RPMX_MTI_FCFECX_CW_HI				0x38638
9784ad3642SHariprasad Kelam 
98b9d0fedcSHariprasad Kelam /* CN10KB CSR Declaration */
99b9d0fedcSHariprasad Kelam #define  RPM2_CMRX_SW_INT				0x1b0
1004c5a331cSHariprasad Kelam #define  RPM2_CMRX_SW_INT_ENA_W1S			0x1c8
1014c5a331cSHariprasad Kelam #define  RPM2_LMAC_FWI					0x12
102b9d0fedcSHariprasad Kelam #define  RPM2_CMR_CHAN_MSK_OR				0x3120
103b9d0fedcSHariprasad Kelam #define  RPM2_CMR_RX_OVR_BP_EN				BIT_ULL(2)
104b9d0fedcSHariprasad Kelam #define  RPM2_CMR_RX_OVR_BP_BP				BIT_ULL(1)
105b9d0fedcSHariprasad Kelam #define  RPM2_CMR_RX_OVR_BP				0x3130
106b9d0fedcSHariprasad Kelam #define  RPM2_CSR_OFFSET				0x3e00
107b9d0fedcSHariprasad Kelam #define  RPM2_CMRX_PRT_CBFC_CTL				0x6510
108b9d0fedcSHariprasad Kelam #define  RPM2_CMRX_RX_LMACS				0x100
109b9d0fedcSHariprasad Kelam #define  RPM2_CMRX_RX_LOGL_XON				0x3100
110b9d0fedcSHariprasad Kelam #define  RPM2_CMRX_RX_STAT2				0x3010
111b9d0fedcSHariprasad Kelam #define  RPM2_USX_PCSX_CONTROL1				0x80000
112b9d0fedcSHariprasad Kelam #define  RPM2_USX_PCS_LBK				BIT_ULL(14)
1132958d17aSHariprasad Kelam 
11491c6945eSHariprasad Kelam /* Function Declarations */
115ce7a6c31SHariprasad Kelam int rpm_get_nr_lmacs(void *rpmd);
1163ad3f8f9SHariprasad Kelam u8 rpm_get_lmac_type(void *rpmd, int lmac_id);
117459f326eSSunil Goutham u32 rpm_get_lmac_fifo_len(void *rpmd, int lmac_id);
118b9d0fedcSHariprasad Kelam u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id);
1193ad3f8f9SHariprasad Kelam int rpm_lmac_internal_loopback(void *rpmd, int lmac_id, bool enable);
1201845ada4SRakesh Babu void rpm_lmac_enadis_rx_pause_fwding(void *rpmd, int lmac_id, bool enable);
1211845ada4SRakesh Babu int rpm_lmac_get_pause_frm_status(void *cgxd, int lmac_id, u8 *tx_pause,
1221845ada4SRakesh Babu 				  u8 *rx_pause);
1231845ada4SRakesh Babu void rpm_lmac_pause_frm_config(void *rpmd, int lmac_id, bool enable);
1241845ada4SRakesh Babu int rpm_lmac_enadis_pause_frm(void *rpmd, int lmac_id, u8 tx_pause,
1251845ada4SRakesh Babu 			      u8 rx_pause);
126ce7a6c31SHariprasad Kelam int rpm_get_tx_stats(void *rpmd, int lmac_id, int idx, u64 *tx_stat);
127ce7a6c31SHariprasad Kelam int rpm_get_rx_stats(void *rpmd, int lmac_id, int idx, u64 *rx_stat);
128d1489208SHariprasad Kelam void rpm_lmac_ptp_config(void *rpmd, int lmac_id, bool enable);
129fae80edeSGeetha sowjanya int rpm_lmac_rx_tx_enable(void *rpmd, int lmac_id, bool enable);
130fae80edeSGeetha sowjanya int rpm_lmac_tx_enable(void *rpmd, int lmac_id, bool enable);
1311121f6b0SSunil Kumar Kori int rpm_lmac_pfc_config(void *rpmd, int lmac_id, u8 tx_pause, u8 rx_pause,
1321121f6b0SSunil Kumar Kori 			u16 pfc_en);
133e7400038SHariprasad Kelam int rpm_lmac_get_pfc_frm_cfg(void *rpmd, int lmac_id, u8 *tx_pause,
134e7400038SHariprasad Kelam 			     u8 *rx_pause);
135b9d0fedcSHariprasad Kelam int rpm2_get_nr_lmacs(void *rpmd);
136b9d0fedcSHariprasad Kelam bool is_dev_rpm2(void *rpmd);
13784ad3642SHariprasad Kelam int rpm_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp);
1382e3e94c2SHariprasad Kelam int rpm_lmac_reset(void *rpmd, int lmac_id, u8 pf_req_flr);
139*4c6ce450SSai Krishna int rpm_stats_reset(void *rpmd, int lmac_id);
14091c6945eSHariprasad Kelam #endif /* RPM_H */
141