162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Marvell CN10K RPM driver 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Copyright (C) 2020 Marvell. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef RPM_H 962306a36Sopenharmony_ci#define RPM_H 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <linux/bits.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/* PCI device IDs */ 1462306a36Sopenharmony_ci#define PCI_DEVID_CN10K_RPM 0xA060 1562306a36Sopenharmony_ci#define PCI_SUBSYS_DEVID_CNF10KB_RPM 0xBC00 1662306a36Sopenharmony_ci#define PCI_DEVID_CN10KB_RPM 0xA09F 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* Registers */ 1962306a36Sopenharmony_ci#define RPMX_CMRX_CFG 0x00 2062306a36Sopenharmony_ci#define RPMX_RX_TS_PREPEND BIT_ULL(22) 2162306a36Sopenharmony_ci#define RPMX_TX_PTP_1S_SUPPORT BIT_ULL(17) 2262306a36Sopenharmony_ci#define RPMX_CMRX_RX_ID_MAP 0x80 2362306a36Sopenharmony_ci#define RPMX_CMRX_SW_INT 0x180 2462306a36Sopenharmony_ci#define RPMX_CMRX_SW_INT_W1S 0x188 2562306a36Sopenharmony_ci#define RPMX_CMRX_SW_INT_ENA_W1S 0x198 2662306a36Sopenharmony_ci#define RPMX_CMRX_LINK_CFG 0x1070 2762306a36Sopenharmony_ci#define RPMX_MTI_PCS100X_CONTROL1 0x20000 2862306a36Sopenharmony_ci#define RPMX_MTI_PCS_LBK BIT_ULL(14) 2962306a36Sopenharmony_ci#define RPMX_MTI_LPCSX_CONTROL(id) (0x30000 | ((id) * 0x100)) 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#define RPMX_CMRX_LINK_RANGE_MASK GENMASK_ULL(19, 16) 3262306a36Sopenharmony_ci#define RPMX_CMRX_LINK_BASE_MASK GENMASK_ULL(11, 0) 3362306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_COMMAND_CONFIG 0x8010 3462306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_COMMAND_CONFIG_RX_P_DISABLE BIT_ULL(29) 3562306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_COMMAND_CONFIG_TX_P_DISABLE BIT_ULL(28) 3662306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE BIT_ULL(8) 3762306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_COMMAND_CONFIG_PFC_MODE BIT_ULL(19) 3862306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL01_PAUSE_QUANTA 0x80A8 3962306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL23_PAUSE_QUANTA 0x80B0 4062306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL45_PAUSE_QUANTA 0x80B8 4162306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL67_PAUSE_QUANTA 0x80C0 4262306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL01_QUANTA_THRESH 0x80C8 4362306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL23_QUANTA_THRESH 0x80D0 4462306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL45_QUANTA_THRESH 0x80D8 4562306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL67_QUANTA_THRESH 0x80E0 4662306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL89_PAUSE_QUANTA 0x8108 4762306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL1011_PAUSE_QUANTA 0x8110 4862306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL1213_PAUSE_QUANTA 0x8118 4962306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL1415_PAUSE_QUANTA 0x8120 5062306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL89_QUANTA_THRESH 0x8128 5162306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL1011_QUANTA_THRESH 0x8130 5262306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL1213_QUANTA_THRESH 0x8138 5362306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL1415_QUANTA_THRESH 0x8140 5462306a36Sopenharmony_ci#define RPMX_CMR_RX_OVR_BP 0x4120 5562306a36Sopenharmony_ci#define RPMX_CMR_RX_OVR_BP_EN(x) BIT_ULL((x) + 8) 5662306a36Sopenharmony_ci#define RPMX_CMR_RX_OVR_BP_BP(x) BIT_ULL((x) + 4) 5762306a36Sopenharmony_ci#define RPMX_CMR_CHAN_MSK_OR 0x4118 5862306a36Sopenharmony_ci#define RPMX_MTI_STAT_RX_STAT_PAGES_COUNTERX 0x12000 5962306a36Sopenharmony_ci#define RPMX_MTI_STAT_TX_STAT_PAGES_COUNTERX 0x13000 6062306a36Sopenharmony_ci#define RPMX_MTI_STAT_DATA_HI_CDC 0x10038 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci#define RPM_LMAC_FWI 0xa 6362306a36Sopenharmony_ci#define RPM_TX_EN BIT_ULL(0) 6462306a36Sopenharmony_ci#define RPM_RX_EN BIT_ULL(1) 6562306a36Sopenharmony_ci#define RPMX_CMRX_PRT_CBFC_CTL 0x5B08 6662306a36Sopenharmony_ci#define RPMX_CMRX_PRT_CBFC_CTL_LOGL_EN_RX_SHIFT 33 6762306a36Sopenharmony_ci#define RPMX_CMRX_PRT_CBFC_CTL_PHYS_BP_SHIFT 16 6862306a36Sopenharmony_ci#define RPMX_CMRX_PRT_CBFC_CTL_LOGL_EN_TX_SHIFT 0 6962306a36Sopenharmony_ci#define RPM_PFC_CLASS_MASK GENMASK_ULL(48, 33) 7062306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL89_QUANTA_THRESH 0x8128 7162306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_COMMAND_CONFIG_TX_PAD_EN BIT_ULL(11) 7262306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE BIT_ULL(8) 7362306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_FWD BIT_ULL(7) 7462306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL01_PAUSE_QUANTA 0x80A8 7562306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_CL89_PAUSE_QUANTA 0x8108 7662306a36Sopenharmony_ci#define RPM_DEFAULT_PAUSE_TIME 0x7FF 7762306a36Sopenharmony_ci#define RPMX_CMRX_RX_LOGL_XON 0x4100 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci#define RPMX_MTI_MAC100X_XIF_MODE 0x8100 8062306a36Sopenharmony_ci#define RPMX_ONESTEP_ENABLE BIT_ULL(5) 8162306a36Sopenharmony_ci#define RPMX_TS_BINARY_MODE BIT_ULL(11) 8262306a36Sopenharmony_ci#define RPMX_CONST1 0x2008 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci/* FEC stats */ 8562306a36Sopenharmony_ci#define RPMX_MTI_STAT_STATN_CONTROL 0x10018 8662306a36Sopenharmony_ci#define RPMX_MTI_STAT_DATA_HI_CDC 0x10038 8762306a36Sopenharmony_ci#define RPMX_RSFEC_RX_CAPTURE BIT_ULL(27) 8862306a36Sopenharmony_ci#define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_2 0x40050 8962306a36Sopenharmony_ci#define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_3 0x40058 9062306a36Sopenharmony_ci#define RPMX_MTI_FCFECX_VL0_CCW_LO 0x38618 9162306a36Sopenharmony_ci#define RPMX_MTI_FCFECX_VL0_NCCW_LO 0x38620 9262306a36Sopenharmony_ci#define RPMX_MTI_FCFECX_VL1_CCW_LO 0x38628 9362306a36Sopenharmony_ci#define RPMX_MTI_FCFECX_VL1_NCCW_LO 0x38630 9462306a36Sopenharmony_ci#define RPMX_MTI_FCFECX_CW_HI 0x38638 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci/* CN10KB CSR Declaration */ 9762306a36Sopenharmony_ci#define RPM2_CMRX_SW_INT 0x1b0 9862306a36Sopenharmony_ci#define RPM2_CMRX_SW_INT_ENA_W1S 0x1c8 9962306a36Sopenharmony_ci#define RPM2_LMAC_FWI 0x12 10062306a36Sopenharmony_ci#define RPM2_CMR_CHAN_MSK_OR 0x3120 10162306a36Sopenharmony_ci#define RPM2_CMR_RX_OVR_BP_EN BIT_ULL(2) 10262306a36Sopenharmony_ci#define RPM2_CMR_RX_OVR_BP_BP BIT_ULL(1) 10362306a36Sopenharmony_ci#define RPM2_CMR_RX_OVR_BP 0x3130 10462306a36Sopenharmony_ci#define RPM2_CSR_OFFSET 0x3e00 10562306a36Sopenharmony_ci#define RPM2_CMRX_PRT_CBFC_CTL 0x6510 10662306a36Sopenharmony_ci#define RPM2_CMRX_RX_LMACS 0x100 10762306a36Sopenharmony_ci#define RPM2_CMRX_RX_LOGL_XON 0x3100 10862306a36Sopenharmony_ci#define RPM2_CMRX_RX_STAT2 0x3010 10962306a36Sopenharmony_ci#define RPM2_USX_PCSX_CONTROL1 0x80000 11062306a36Sopenharmony_ci#define RPM2_USX_PCS_LBK BIT_ULL(14) 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci/* Function Declarations */ 11362306a36Sopenharmony_ciint rpm_get_nr_lmacs(void *rpmd); 11462306a36Sopenharmony_ciu8 rpm_get_lmac_type(void *rpmd, int lmac_id); 11562306a36Sopenharmony_ciu32 rpm_get_lmac_fifo_len(void *rpmd, int lmac_id); 11662306a36Sopenharmony_ciu32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id); 11762306a36Sopenharmony_ciint rpm_lmac_internal_loopback(void *rpmd, int lmac_id, bool enable); 11862306a36Sopenharmony_civoid rpm_lmac_enadis_rx_pause_fwding(void *rpmd, int lmac_id, bool enable); 11962306a36Sopenharmony_ciint rpm_lmac_get_pause_frm_status(void *cgxd, int lmac_id, u8 *tx_pause, 12062306a36Sopenharmony_ci u8 *rx_pause); 12162306a36Sopenharmony_civoid rpm_lmac_pause_frm_config(void *rpmd, int lmac_id, bool enable); 12262306a36Sopenharmony_ciint rpm_lmac_enadis_pause_frm(void *rpmd, int lmac_id, u8 tx_pause, 12362306a36Sopenharmony_ci u8 rx_pause); 12462306a36Sopenharmony_ciint rpm_get_tx_stats(void *rpmd, int lmac_id, int idx, u64 *tx_stat); 12562306a36Sopenharmony_ciint rpm_get_rx_stats(void *rpmd, int lmac_id, int idx, u64 *rx_stat); 12662306a36Sopenharmony_civoid rpm_lmac_ptp_config(void *rpmd, int lmac_id, bool enable); 12762306a36Sopenharmony_ciint rpm_lmac_rx_tx_enable(void *rpmd, int lmac_id, bool enable); 12862306a36Sopenharmony_ciint rpm_lmac_tx_enable(void *rpmd, int lmac_id, bool enable); 12962306a36Sopenharmony_ciint rpm_lmac_pfc_config(void *rpmd, int lmac_id, u8 tx_pause, u8 rx_pause, 13062306a36Sopenharmony_ci u16 pfc_en); 13162306a36Sopenharmony_ciint rpm_lmac_get_pfc_frm_cfg(void *rpmd, int lmac_id, u8 *tx_pause, 13262306a36Sopenharmony_ci u8 *rx_pause); 13362306a36Sopenharmony_ciint rpm2_get_nr_lmacs(void *rpmd); 13462306a36Sopenharmony_cibool is_dev_rpm2(void *rpmd); 13562306a36Sopenharmony_ciint rpm_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp); 13662306a36Sopenharmony_ciint rpm_lmac_reset(void *rpmd, int lmac_id, u8 pf_req_flr); 13762306a36Sopenharmony_ci#endif /* RPM_H */ 138