mips: octeon: Add ethernet support
Subsystems (2)
PATCH 2/52 mips: octeon: Add cvmx-ilk-defs.h header file
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-igl-defs.h header file from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- .../mach-octeon/include/mach/cvmx-ilk-defs.h | 2269 +++++++++++++++++ 1 file changed, 2269 insertions(+) create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-ilk-defs.h
arch/mips/mach-octeon/include/mach/cvmx-ilk-defs.h new file +2269 -0
@@ -0,0 +1,2269 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Configuration and status register (CSR) type definitions for +* Octeon ilk. +*/ + +#ifndef __CVMX_ILK_DEFS_H__ +#define __CVMX_ILK_DEFS_H__ + +#define CVMX_ILK_BIST_SUM (0x0001180014000038ull) +#define CVMX_ILK_GBL_CFG (0x0001180014000000ull) +#define CVMX_ILK_GBL_ERR_CFG (0x0001180014000058ull) +#define CVMX_ILK_GBL_INT (0x0001180014000008ull) +#define CVMX_ILK_GBL_INT_EN (0x0001180014000010ull) +#define CVMX_ILK_INT_SUM (0x0001180014000030ull) +#define CVMX_ILK_LNEX_TRN_CTL (offset) \ + (0x00011800140380F0ull + ((offset) & 15) * 1024) +#define CVMX_ILK_LNEX_TRN_LD (offset) \ + (0x00011800140380E0ull + ((offset) & 15) * 1024) +#define CVMX_ILK_LNEX_TRN_LP (offset) \ + (0x00011800140380E8ull + ((offset) & 15) * 1024) +#define CVMX_ILK_LNE_DBG (0x0001180014030008ull) +#define CVMX_ILK_LNE_STS_MSG (0x0001180014030000ull) +#define CVMX_ILK_RID_CFG (0x0001180014000050ull) +#define CVMX_ILK_RXF_IDX_PMAP (0x0001180014000020ull) +#define CVMX_ILK_RXF_MEM_PMAP (0x0001180014000028ull) +#define CVMX_ILK_RXX_BYTE_CNTX (offset, block_id) \ + (0x0001180014023000ull + \ + (((offset) & 255) + ((block_id) & 1) * 0x800ull) * 8) +#define CVMX_ILK_RXX_CAL_ENTRYX (offset, block_id) \ + (0x0001180014021000ull + \ + (((offset) & 511) + ((block_id) & 1) * 0x800ull) * 8) +#define CVMX_ILK_RXX_CFG0 (offset) (0x0001180014020000ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_CFG1 (offset) (0x0001180014020008ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_CHAX (offset, block_id) \ + (0x0001180014002000ull + \ + (((offset) & 255) + ((block_id) & 1) * 0x200ull) * 8) +#define CVMX_ILK_RXX_CHA_XONX (offset, block_id) \ + (0x0001180014020400ull + (((offset) & 3) + ((block_id) & 1) * 0x800ull) * 8) +#define CVMX_ILK_RXX_ERR_CFG (offset) \ + (0x00011800140200E0ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_FLOW_CTL0 (offset) \ + (0x0001180014020090ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_FLOW_CTL1 (offset) \ + (0x0001180014020098ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_IDX_CAL (offset) \ + (0x00011800140200A0ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_IDX_STAT0 (offset) \ + (0x0001180014020070ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_IDX_STAT1 (offset) \ + (0x0001180014020078ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_INT (offset) (0x0001180014020010ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_INT_EN (offset) \ + (0x0001180014020018ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_JABBER (offset) \ + (0x00011800140200B8ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_MEM_CAL0 (offset) \ + (0x00011800140200A8ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_MEM_CAL1 (offset) \ + (0x00011800140200B0ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_MEM_STAT0 (offset) \ + (0x0001180014020080ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_MEM_STAT1 (offset) \ + (0x0001180014020088ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_PKT_CNTX (offset, block_id) \ + (0x0001180014022000ull + \ + (((offset) & 255) + ((block_id) & 1) * 0x800ull) * 8) +#define CVMX_ILK_RXX_RID (offset) (0x00011800140200C0ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_STAT0 (offset) \ + (0x0001180014020020ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_STAT1 (offset) \ + (0x0001180014020028ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_STAT2 (offset) \ + (0x0001180014020030ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_STAT3 (offset) \ + (0x0001180014020038ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_STAT4 (offset) \ + (0x0001180014020040ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_STAT5 (offset) \ + (0x0001180014020048ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_STAT6 (offset) \ + (0x0001180014020050ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_STAT7 (offset) \ + (0x0001180014020058ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_STAT8 (offset) \ + (0x0001180014020060ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RXX_STAT9 (offset) \ + (0x0001180014020068ull + ((offset) & 1) * 16384) +#define CVMX_ILK_RX_LNEX_CFG (offset) \ + (0x0001180014038000ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_INT (offset) \ + (0x0001180014038008ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_INT_EN (offset) \ + (0x0001180014038010ull + ((offset) & 7) * 1024) +#define CVMX_ILK_RX_LNEX_STAT0 (offset) \ + (0x0001180014038018ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_STAT1 (offset) \ + (0x0001180014038020ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_STAT10 (offset) \ + (0x0001180014038068ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_STAT2 (offset) \ + (0x0001180014038028ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_STAT3 (offset) \ + (0x0001180014038030ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_STAT4 (offset) \ + (0x0001180014038038ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_STAT5 (offset) \ + (0x0001180014038040ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_STAT6 (offset) \ + (0x0001180014038048ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_STAT7 (offset) \ + (0x0001180014038050ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_STAT8 (offset) \ + (0x0001180014038058ull + ((offset) & 15) * 1024) +#define CVMX_ILK_RX_LNEX_STAT9 (offset) \ + (0x0001180014038060ull + ((offset) & 15) * 1024) +#define CVMX_ILK_SER_CFG (0x0001180014000018ull) +#define CVMX_ILK_TXX_BYTE_CNTX (offset, block_id) \ + (0x0001180014013000ull + \ + (((offset) & 255) + ((block_id) & 1) * 0x800ull) * 8) +#define CVMX_ILK_TXX_CAL_ENTRYX (offset, block_id) \ + (0x0001180014011000ull + \ + (((offset) & 511) + ((block_id) & 1) * 0x800ull) * 8) +#define CVMX_ILK_TXX_CFG0 (offset) (0x0001180014010000ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_CFG1 (offset) (0x0001180014010008ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_CHA_XONX (offset, block_id) \ + (0x0001180014010400ull + (((offset) & 3) + ((block_id) & 1) * 0x800ull) * 8) +#define CVMX_ILK_TXX_DBG (offset) (0x0001180014010070ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_ERR_CFG (offset) \ + (0x00011800140100B0ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_FLOW_CTL0 (offset) \ + (0x0001180014010048ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_FLOW_CTL1 (offset) \ + (0x0001180014010050ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_IDX_CAL (offset) \ + (0x0001180014010058ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_IDX_PMAP (offset) \ + (0x0001180014010010ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_IDX_STAT0 (offset) \ + (0x0001180014010020ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_IDX_STAT1 (offset) \ + (0x0001180014010028ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_INT (offset) (0x0001180014010078ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_INT_EN (offset) \ + (0x0001180014010080ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_MEM_CAL0 (offset) \ + (0x0001180014010060ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_MEM_CAL1 (offset) \ + (0x0001180014010068ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_MEM_PMAP (offset) \ + (0x0001180014010018ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_MEM_STAT0 (offset) \ + (0x0001180014010030ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_MEM_STAT1 (offset) \ + (0x0001180014010038ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_PIPE (offset) (0x0001180014010088ull + ((offset) & 1) * 16384) +#define CVMX_ILK_TXX_PKT_CNTX (offset, block_id) \ + (0x0001180014012000ull + \ + (((offset) & 255) + ((block_id) & 1) * 0x800ull) * 8) +#define CVMX_ILK_TXX_RMATCH (offset) \ + (0x0001180014010040ull + ((offset) & 1) * 16384) + +/** +* cvmx_ilk_bist_sum +*/ +union cvmx_ilk_bist_sum { +u64 u64; +struct cvmx_ilk_bist_sum_s { +u64 rxf_x2p :1 ; +u64 rxf_mem19 :1 ; +u64 rxf_mem18 :1 ; +u64 rxf_mem17 :1 ; +u64 rxf_mem16 :1 ; +u64 rxf_mem15 :1 ; +u64 reserved_52_57 :6 ; +u64 rxf_mem8 :1 ; +u64 rxf_mem7 :1 ; +u64 rxf_mem6 :1 ; +u64 rxf_mem5 :1 ; +u64 rxf_mem4 :1 ; +u64 rxf_mem3 :1 ; +u64 reserved_36_45 :10 ; +u64 rle7_dsk1 :1 ; +u64 rle7_dsk0 :1 ; +u64 rle6_dsk1 :1 ; +u64 rle6_dsk0 :1 ; +u64 rle5_dsk1 :1 ; +u64 rle5_dsk0 :1 ; +u64 rle4_dsk1 :1 ; +u64 rle4_dsk0 :1 ; +u64 rle3_dsk1 :1 ; +u64 rle3_dsk0 :1 ; +u64 rle2_dsk1 :1 ; +u64 rle2_dsk0 :1 ; +u64 rle1_dsk1 :1 ; +u64 rle1_dsk0 :1 ; +u64 rle0_dsk1 :1 ; +u64 rle0_dsk0 :1 ; +u64 rlk1_pmap :1 ; +u64 reserved_18_18 :1 ; +u64 rlk1_fwc :1 ; +u64 reserved_16_16 :1 ; +u64 rlk0_pmap :1 ; +u64 rlk0_stat1 :1 ; +u64 rlk0_fwc :1 ; +u64 rlk0_stat :1 ; +u64 tlk1_stat1 :1 ; +u64 tlk1_fwc :1 ; +u64 reserved_9_9 :1 ; +u64 tlk1_txf2 :1 ; +u64 tlk1_txf1 :1 ; +u64 tlk1_txf0 :1 ; +u64 tlk0_stat1 :1 ; +u64 tlk0_fwc :1 ; +u64 reserved_3_3 :1 ; +u64 tlk0_txf2 :1 ; +u64 tlk0_txf1 :1 ; +u64 tlk0_txf0 :1 ; + } s; +struct cvmx_ilk_bist_sum_cn68xx { +u64 reserved_58_63 :6 ; +u64 rxf_x2p1 :1 ; +u64 rxf_x2p0 :1 ; +u64 rxf_pmap :1 ; +u64 rxf_mem2 :1 ; +u64 rxf_mem1 :1 ; +u64 rxf_mem0 :1 ; +u64 reserved_36_51 :16 ; +u64 rle7_dsk1 :1 ; +u64 rle7_dsk0 :1 ; +u64 rle6_dsk1 :1 ; +u64 rle6_dsk0 :1 ; +u64 rle5_dsk1 :1 ; +u64 rle5_dsk0 :1 ; +u64 rle4_dsk1 :1 ; +u64 rle4_dsk0 :1 ; +u64 rle3_dsk1 :1 ; +u64 rle3_dsk0 :1 ; +u64 rle2_dsk1 :1 ; +u64 rle2_dsk0 :1 ; +u64 rle1_dsk1 :1 ; +u64 rle1_dsk0 :1 ; +u64 rle0_dsk1 :1 ; +u64 rle0_dsk0 :1 ; +u64 reserved_19_19 :1 ; +u64 rlk1_stat1 :1 ; +u64 rlk1_fwc :1 ; +u64 rlk1_stat :1 ; +u64 reserved_15_15 :1 ; +u64 rlk0_stat1 :1 ; +u64 rlk0_fwc :1 ; +u64 rlk0_stat :1 ; +u64 tlk1_stat1 :1 ; +u64 tlk1_fwc :1 ; +u64 tlk1_stat0 :1 ; +u64 tlk1_txf2 :1 ; +u64 tlk1_txf1 :1 ; +u64 tlk1_txf0 :1 ; +u64 tlk0_stat1 :1 ; +u64 tlk0_fwc :1 ; +u64 tlk0_stat0 :1 ; +u64 tlk0_txf2 :1 ; +u64 tlk0_txf1 :1 ; +u64 tlk0_txf0 :1 ; + } cn68xx; +struct cvmx_ilk_bist_sum_cn68xxp1 { +u64 reserved_58_63 :6 ; +u64 rxf_x2p1 :1 ; +u64 rxf_x2p0 :1 ; +u64 rxf_pmap :1 ; +u64 rxf_mem2 :1 ; +u64 rxf_mem1 :1 ; +u64 rxf_mem0 :1 ; +u64 reserved_36_51 :16 ; +u64 rle7_dsk1 :1 ; +u64 rle7_dsk0 :1 ; +u64 rle6_dsk1 :1 ; +u64 rle6_dsk0 :1 ; +u64 rle5_dsk1 :1 ; +u64 rle5_dsk0 :1 ; +u64 rle4_dsk1 :1 ; +u64 rle4_dsk0 :1 ; +u64 rle3_dsk1 :1 ; +u64 rle3_dsk0 :1 ; +u64 rle2_dsk1 :1 ; +u64 rle2_dsk0 :1 ; +u64 rle1_dsk1 :1 ; +u64 rle1_dsk0 :1 ; +u64 rle0_dsk1 :1 ; +u64 rle0_dsk0 :1 ; +u64 reserved_18_19 :2 ; +u64 rlk1_fwc :1 ; +u64 rlk1_stat :1 ; +u64 reserved_14_15 :2 ; +u64 rlk0_fwc :1 ; +u64 rlk0_stat :1 ; +u64 reserved_11_11 :1 ; +u64 tlk1_fwc :1 ; +u64 tlk1_stat :1 ; +u64 tlk1_txf2 :1 ; +u64 tlk1_txf1 :1 ; +u64 tlk1_txf0 :1 ; +u64 reserved_5_5 :1 ; +u64 tlk0_fwc :1 ; +u64 tlk0_stat :1 ; +u64 tlk0_txf2 :1 ; +u64 tlk0_txf1 :1 ; +u64 tlk0_txf0 :1 ; + } cn68xxp1; +struct cvmx_ilk_bist_sum_cn78xx { +u64 rxf_x2p :1 ; +u64 rxf_mem19 :1 ; +u64 rxf_mem18 :1 ; +u64 rxf_mem17 :1 ; +u64 rxf_mem16 :1 ; +u64 rxf_mem15 :1 ; +u64 rxf_mem14 :1 ; +u64 rxf_mem13 :1 ; +u64 rxf_mem12 :1 ; +u64 rxf_mem11 :1 ; +u64 rxf_mem10 :1 ; +u64 rxf_mem9 :1 ; +u64 rxf_mem8 :1 ; +u64 rxf_mem7 :1 ; +u64 rxf_mem6 :1 ; +u64 rxf_mem5 :1 ; +u64 rxf_mem4 :1 ; +u64 rxf_mem3 :1 ; +u64 rxf_mem2 :1 ; +u64 rxf_mem1 :1 ; +u64 rxf_mem0 :1 ; +u64 reserved_36_42 :7 ; +u64 rle7_dsk1 :1 ; +u64 rle7_dsk0 :1 ; +u64 rle6_dsk1 :1 ; +u64 rle6_dsk0 :1 ; +u64 rle5_dsk1 :1 ; +u64 rle5_dsk0 :1 ; +u64 rle4_dsk1 :1 ; +u64 rle4_dsk0 :1 ; +u64 rle3_dsk1 :1 ; +u64 rle3_dsk0 :1 ; +u64 rle2_dsk1 :1 ; +u64 rle2_dsk0 :1 ; +u64 rle1_dsk1 :1 ; +u64 rle1_dsk0 :1 ; +u64 rle0_dsk1 :1 ; +u64 rle0_dsk0 :1 ; +u64 rlk1_pmap :1 ; +u64 rlk1_stat :1 ; +u64 rlk1_fwc :1 ; +u64 rlk1_stat1 :1 ; +u64 rlk0_pmap :1 ; +u64 rlk0_stat1 :1 ; +u64 rlk0_fwc :1 ; +u64 rlk0_stat :1 ; +u64 tlk1_stat1 :1 ; +u64 tlk1_fwc :1 ; +u64 tlk1_stat0 :1 ; +u64 tlk1_txf2 :1 ; +u64 tlk1_txf1 :1 ; +u64 tlk1_txf0 :1 ; +u64 tlk0_stat1 :1 ; +u64 tlk0_fwc :1 ; +u64 tlk0_stat0 :1 ; +u64 tlk0_txf2 :1 ; +u64 tlk0_txf1 :1 ; +u64 tlk0_txf0 :1 ; + } cn78xx; +struct cvmx_ilk_bist_sum_cn78xx cn78xxp1; +}; + +typedef union cvmx_ilk_bist_sum cvmx_ilk_bist_sum_t ; + +/** +* cvmx_ilk_gbl_cfg +*/ +union cvmx_ilk_gbl_cfg { +u64 u64; +struct cvmx_ilk_gbl_cfg_s { +u64 reserved_4_63 :60 ; +u64 rid_rstdis :1 ; +u64 reset :1 ; +u64 cclk_dis :1 ; +u64 rxf_xlink :1 ; + } s; +struct cvmx_ilk_gbl_cfg_s cn68xx; +struct cvmx_ilk_gbl_cfg_cn68xxp1 { +u64 reserved_2_63 :62 ; +u64 cclk_dis :1 ; +u64 rxf_xlink :1 ; + } cn68xxp1; +struct cvmx_ilk_gbl_cfg_s cn78xx; +struct cvmx_ilk_gbl_cfg_s cn78xxp1; +}; + +typedef union cvmx_ilk_gbl_cfg cvmx_ilk_gbl_cfg_t ; + +/** +* cvmx_ilk_gbl_err_cfg +*/ +union cvmx_ilk_gbl_err_cfg { +u64 u64; +struct cvmx_ilk_gbl_err_cfg_s { +u64 reserved_20_63 :44 ; +u64 rxf_flip :2 ; +u64 x2p_flip :2 ; +u64 reserved_2_15 :14 ; +u64 rxf_cor_dis :1 ; +u64 x2p_cor_dis :1 ; + } s; +struct cvmx_ilk_gbl_err_cfg_s cn78xx; +struct cvmx_ilk_gbl_err_cfg_s cn78xxp1; +}; + +typedef union cvmx_ilk_gbl_err_cfg cvmx_ilk_gbl_err_cfg_t ; + +/** +* cvmx_ilk_gbl_int +*/ +union cvmx_ilk_gbl_int { +u64 u64; +struct cvmx_ilk_gbl_int_s { +u64 reserved_9_63 :55 ; +u64 x2p_dbe :1 ; +u64 x2p_sbe :1 ; +u64 rxf_dbe :1 ; +u64 rxf_sbe :1 ; +u64 rxf_push_full :1 ; +u64 rxf_pop_empty :1 ; +u64 rxf_ctl_perr :1 ; +u64 rxf_lnk1_perr :1 ; +u64 rxf_lnk0_perr :1 ; + } s; +struct cvmx_ilk_gbl_int_cn68xx { +u64 reserved_5_63 :59 ; +u64 rxf_push_full :1 ; +u64 rxf_pop_empty :1 ; +u64 rxf_ctl_perr :1 ; +u64 rxf_lnk1_perr :1 ; +u64 rxf_lnk0_perr :1 ; + } cn68xx; +struct cvmx_ilk_gbl_int_cn68xx cn68xxp1; +struct cvmx_ilk_gbl_int_s cn78xx; +struct cvmx_ilk_gbl_int_s cn78xxp1; +}; + +typedef union cvmx_ilk_gbl_int cvmx_ilk_gbl_int_t ; + +/** +* cvmx_ilk_gbl_int_en +*/ +union cvmx_ilk_gbl_int_en { +u64 u64; +struct cvmx_ilk_gbl_int_en_s { +u64 reserved_5_63 :59 ; +u64 rxf_push_full :1 ; +u64 rxf_pop_empty :1 ; +u64 rxf_ctl_perr :1 ; +u64 rxf_lnk1_perr :1 ; +u64 rxf_lnk0_perr :1 ; + } s; +struct cvmx_ilk_gbl_int_en_s cn68xx; +struct cvmx_ilk_gbl_int_en_s cn68xxp1; +}; + +typedef union cvmx_ilk_gbl_int_en cvmx_ilk_gbl_int_en_t ; + +/** +* cvmx_ilk_int_sum +*/ +union cvmx_ilk_int_sum { +u64 u64; +struct cvmx_ilk_int_sum_s { +u64 reserved_13_63 :51 ; +u64 rle7_int :1 ; +u64 rle6_int :1 ; +u64 rle5_int :1 ; +u64 rle4_int :1 ; +u64 rle3_int :1 ; +u64 rle2_int :1 ; +u64 rle1_int :1 ; +u64 rle0_int :1 ; +u64 rlk1_int :1 ; +u64 rlk0_int :1 ; +u64 tlk1_int :1 ; +u64 tlk0_int :1 ; +u64 gbl_int :1 ; + } s; +struct cvmx_ilk_int_sum_s cn68xx; +struct cvmx_ilk_int_sum_s cn68xxp1; +}; + +typedef union cvmx_ilk_int_sum cvmx_ilk_int_sum_t ; + +/** +* cvmx_ilk_lne#_trn_ctl +*/ +union cvmx_ilk_lnex_trn_ctl { +u64 u64; +struct cvmx_ilk_lnex_trn_ctl_s { +u64 reserved_4_63 :60 ; +u64 trn_lock :1 ; +u64 trn_done :1 ; +u64 trn_ena :1 ; +u64 eie_det :1 ; + } s; +struct cvmx_ilk_lnex_trn_ctl_s cn78xx; +struct cvmx_ilk_lnex_trn_ctl_s cn78xxp1; +}; + +typedef union cvmx_ilk_lnex_trn_ctl cvmx_ilk_lnex_trn_ctl_t ; + +/** +* cvmx_ilk_lne#_trn_ld +*/ +union cvmx_ilk_lnex_trn_ld { +u64 u64; +struct cvmx_ilk_lnex_trn_ld_s { +u64 lp_manual :1 ; +u64 reserved_49_62 :14 ; +u64 ld_cu_val :1 ; +u64 ld_cu_dat :16 ; +u64 reserved_17_31 :15 ; +u64 ld_sr_val :1 ; +u64 ld_sr_dat :16 ; + } s; +struct cvmx_ilk_lnex_trn_ld_s cn78xx; +struct cvmx_ilk_lnex_trn_ld_s cn78xxp1; +}; + +typedef union cvmx_ilk_lnex_trn_ld cvmx_ilk_lnex_trn_ld_t ; + +/** +* cvmx_ilk_lne#_trn_lp +*/ +union cvmx_ilk_lnex_trn_lp { +u64 u64; +struct cvmx_ilk_lnex_trn_lp_s { +u64 reserved_49_63 :15 ; +u64 lp_cu_val :1 ; +u64 lp_cu_dat :16 ; +u64 reserved_17_31 :15 ; +u64 lp_sr_val :1 ; +u64 lp_sr_dat :16 ; + } s; +struct cvmx_ilk_lnex_trn_lp_s cn78xx; +struct cvmx_ilk_lnex_trn_lp_s cn78xxp1; +}; + +typedef union cvmx_ilk_lnex_trn_lp cvmx_ilk_lnex_trn_lp_t ; + +/** +* cvmx_ilk_lne_dbg +*/ +union cvmx_ilk_lne_dbg { +u64 u64; +struct cvmx_ilk_lne_dbg_s { +u64 reserved_60_63 :4 ; +u64 tx_bad_crc32 :1 ; +u64 tx_bad_6467_cnt :5 ; +u64 tx_bad_sync_cnt :3 ; +u64 tx_bad_scram_cnt :3 ; +u64 tx_bad_lane_sel :16 ; +u64 tx_dis_dispr :16 ; +u64 tx_dis_scram :16 ; + } s; +struct cvmx_ilk_lne_dbg_cn68xx { +u64 reserved_60_63 :4 ; +u64 tx_bad_crc32 :1 ; +u64 tx_bad_6467_cnt :5 ; +u64 tx_bad_sync_cnt :3 ; +u64 tx_bad_scram_cnt :3 ; +u64 reserved_40_47 :8 ; +u64 tx_bad_lane_sel :8 ; +u64 reserved_24_31 :8 ; +u64 tx_dis_dispr :8 ; +u64 reserved_8_15 :8 ; +u64 tx_dis_scram :8 ; + } cn68xx; +struct cvmx_ilk_lne_dbg_cn68xx cn68xxp1; +struct cvmx_ilk_lne_dbg_s cn78xx; +struct cvmx_ilk_lne_dbg_s cn78xxp1; +}; + +typedef union cvmx_ilk_lne_dbg cvmx_ilk_lne_dbg_t ; + +/** +* cvmx_ilk_lne_sts_msg +*/ +union cvmx_ilk_lne_sts_msg { +u64 u64; +struct cvmx_ilk_lne_sts_msg_s { +u64 rx_lnk_stat :16 ; +u64 rx_lne_stat :16 ; +u64 tx_lnk_stat :16 ; +u64 tx_lne_stat :16 ; + } s; +struct cvmx_ilk_lne_sts_msg_cn68xx { +u64 reserved_56_63 :8 ; +u64 rx_lnk_stat :8 ; +u64 reserved_40_47 :8 ; +u64 rx_lne_stat :8 ; +u64 reserved_24_31 :8 ; +u64 tx_lnk_stat :8 ; +u64 reserved_8_15 :8 ; +u64 tx_lne_stat :8 ; + } cn68xx; +struct cvmx_ilk_lne_sts_msg_cn68xx cn68xxp1; +struct cvmx_ilk_lne_sts_msg_s cn78xx; +struct cvmx_ilk_lne_sts_msg_s cn78xxp1; +}; + +typedef union cvmx_ilk_lne_sts_msg cvmx_ilk_lne_sts_msg_t ; + +/** +* cvmx_ilk_rid_cfg +*/ +union cvmx_ilk_rid_cfg { +u64 u64; +struct cvmx_ilk_rid_cfg_s { +u64 reserved_39_63 :25 ; +u64 max_cnt :7 ; +u64 reserved_7_31 :25 ; +u64 base :7 ; + } s; +struct cvmx_ilk_rid_cfg_s cn78xx; +struct cvmx_ilk_rid_cfg_s cn78xxp1; +}; + +typedef union cvmx_ilk_rid_cfg cvmx_ilk_rid_cfg_t ; + +/** +* cvmx_ilk_rx#_byte_cnt# +*/ +union cvmx_ilk_rxx_byte_cntx { +u64 u64; +struct cvmx_ilk_rxx_byte_cntx_s { +u64 reserved_40_63 :24 ; +u64 rx_bytes :40 ; + } s; +struct cvmx_ilk_rxx_byte_cntx_s cn78xx; +struct cvmx_ilk_rxx_byte_cntx_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_byte_cntx cvmx_ilk_rxx_byte_cntx_t ; + +/** +* cvmx_ilk_rx#_cal_entry# +*/ +union cvmx_ilk_rxx_cal_entryx { +u64 u64; +struct cvmx_ilk_rxx_cal_entryx_s { +u64 reserved_34_63 :30 ; +u64 ctl :2 ; +u64 reserved_8_31 :24 ; +u64 channel :8 ; + } s; +struct cvmx_ilk_rxx_cal_entryx_s cn78xx; +struct cvmx_ilk_rxx_cal_entryx_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_cal_entryx cvmx_ilk_rxx_cal_entryx_t ; + +/** +* cvmx_ilk_rx#_cfg0 +*/ +union cvmx_ilk_rxx_cfg0 { +u64 u64; +struct cvmx_ilk_rxx_cfg0_s { +u64 ext_lpbk_fc :1 ; +u64 ext_lpbk :1 ; +u64 reserved_60_61 :2 ; +u64 lnk_stats_wrap :1 ; +u64 bcw_push :1 ; +u64 mproto_ign :1 ; +u64 ptrn_mode :1 ; +u64 lnk_stats_rdclr :1 ; +u64 lnk_stats_ena :1 ; +u64 mltuse_fc_ena :1 ; +u64 cal_ena :1 ; +u64 mfrm_len :13 ; +u64 brst_shrt :7 ; +u64 lane_rev :1 ; +u64 brst_max :5 ; +u64 reserved_25_25 :1 ; +u64 cal_depth :9 ; +u64 lane_ena :16 ; + } s; +struct cvmx_ilk_rxx_cfg0_cn68xx { +u64 ext_lpbk_fc :1 ; +u64 ext_lpbk :1 ; +u64 reserved_60_61 :2 ; +u64 lnk_stats_wrap :1 ; +u64 bcw_push :1 ; +u64 mproto_ign :1 ; +u64 ptrn_mode :1 ; +u64 lnk_stats_rdclr :1 ; +u64 lnk_stats_ena :1 ; +u64 mltuse_fc_ena :1 ; +u64 cal_ena :1 ; +u64 mfrm_len :13 ; +u64 brst_shrt :7 ; +u64 lane_rev :1 ; +u64 brst_max :5 ; +u64 reserved_25_25 :1 ; +u64 cal_depth :9 ; +u64 reserved_8_15 :8 ; +u64 lane_ena :8 ; + } cn68xx; +struct cvmx_ilk_rxx_cfg0_cn68xxp1 { +u64 ext_lpbk_fc :1 ; +u64 ext_lpbk :1 ; +u64 reserved_57_61 :5 ; +u64 ptrn_mode :1 ; +u64 lnk_stats_rdclr :1 ; +u64 lnk_stats_ena :1 ; +u64 mltuse_fc_ena :1 ; +u64 cal_ena :1 ; +u64 mfrm_len :13 ; +u64 brst_shrt :7 ; +u64 lane_rev :1 ; +u64 brst_max :5 ; +u64 reserved_25_25 :1 ; +u64 cal_depth :9 ; +u64 reserved_8_15 :8 ; +u64 lane_ena :8 ; + } cn68xxp1; +struct cvmx_ilk_rxx_cfg0_s cn78xx; +struct cvmx_ilk_rxx_cfg0_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_cfg0 cvmx_ilk_rxx_cfg0_t ; + +/** +* cvmx_ilk_rx#_cfg1 +*/ +union cvmx_ilk_rxx_cfg1 { +u64 u64; +struct cvmx_ilk_rxx_cfg1_s { +u64 reserved_62_63 :2 ; +u64 rx_fifo_cnt :12 ; +u64 reserved_49_49 :1 ; +u64 rx_fifo_hwm :13 ; +u64 reserved_35_35 :1 ; +u64 rx_fifo_max :13 ; +u64 pkt_flush :1 ; +u64 pkt_ena :1 ; +u64 la_mode :1 ; +u64 tx_link_fc :1 ; +u64 rx_link_fc :1 ; +u64 rx_align_ena :1 ; +u64 rx_bdry_lock_ena :16 ; + } s; +struct cvmx_ilk_rxx_cfg1_cn68xx { +u64 reserved_62_63 :2 ; +u64 rx_fifo_cnt :12 ; +u64 reserved_48_49 :2 ; +u64 rx_fifo_hwm :12 ; +u64 reserved_34_35 :2 ; +u64 rx_fifo_max :12 ; +u64 pkt_flush :1 ; +u64 pkt_ena :1 ; +u64 la_mode :1 ; +u64 tx_link_fc :1 ; +u64 rx_link_fc :1 ; +u64 rx_align_ena :1 ; +u64 reserved_8_15 :8 ; +u64 rx_bdry_lock_ena :8 ; + } cn68xx; +struct cvmx_ilk_rxx_cfg1_cn68xx cn68xxp1; +struct cvmx_ilk_rxx_cfg1_s cn78xx; +struct cvmx_ilk_rxx_cfg1_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_cfg1 cvmx_ilk_rxx_cfg1_t ; + +/** +* cvmx_ilk_rx#_cha# +*/ +union cvmx_ilk_rxx_chax { +u64 u64; +struct cvmx_ilk_rxx_chax_s { +u64 reserved_6_63 :58 ; +u64 port_kind :6 ; + } s; +struct cvmx_ilk_rxx_chax_s cn78xx; +struct cvmx_ilk_rxx_chax_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_chax cvmx_ilk_rxx_chax_t ; + +/** +* cvmx_ilk_rx#_cha_xon# +*/ +union cvmx_ilk_rxx_cha_xonx { +u64 u64; +struct cvmx_ilk_rxx_cha_xonx_s { +u64 xon :64 ; + } s; +struct cvmx_ilk_rxx_cha_xonx_s cn78xx; +struct cvmx_ilk_rxx_cha_xonx_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_cha_xonx cvmx_ilk_rxx_cha_xonx_t ; + +/** +* cvmx_ilk_rx#_err_cfg +*/ +union cvmx_ilk_rxx_err_cfg { +u64 u64; +struct cvmx_ilk_rxx_err_cfg_s { +u64 reserved_20_63 :44 ; +u64 fwc_flip :2 ; +u64 pmap_flip :2 ; +u64 reserved_2_15 :14 ; +u64 fwc_cor_dis :1 ; +u64 pmap_cor_dis :1 ; + } s; +struct cvmx_ilk_rxx_err_cfg_s cn78xx; +struct cvmx_ilk_rxx_err_cfg_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_err_cfg cvmx_ilk_rxx_err_cfg_t ; + +/** +* cvmx_ilk_rx#_flow_ctl0 +*/ +union cvmx_ilk_rxx_flow_ctl0 { +u64 u64; +struct cvmx_ilk_rxx_flow_ctl0_s { +u64 status :64 ; + } s; +struct cvmx_ilk_rxx_flow_ctl0_s cn68xx; +struct cvmx_ilk_rxx_flow_ctl0_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxx_flow_ctl0 cvmx_ilk_rxx_flow_ctl0_t ; + +/** +* cvmx_ilk_rx#_flow_ctl1 +*/ +union cvmx_ilk_rxx_flow_ctl1 { +u64 u64; +struct cvmx_ilk_rxx_flow_ctl1_s { +u64 status :64 ; + } s; +struct cvmx_ilk_rxx_flow_ctl1_s cn68xx; +struct cvmx_ilk_rxx_flow_ctl1_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxx_flow_ctl1 cvmx_ilk_rxx_flow_ctl1_t ; + +/** +* cvmx_ilk_rx#_idx_cal +*/ +union cvmx_ilk_rxx_idx_cal { +u64 u64; +struct cvmx_ilk_rxx_idx_cal_s { +u64 reserved_14_63 :50 ; +u64 inc :6 ; +u64 reserved_6_7 :2 ; +u64 index :6 ; + } s; +struct cvmx_ilk_rxx_idx_cal_s cn68xx; +struct cvmx_ilk_rxx_idx_cal_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxx_idx_cal cvmx_ilk_rxx_idx_cal_t ; + +/** +* cvmx_ilk_rx#_idx_stat0 +*/ +union cvmx_ilk_rxx_idx_stat0 { +u64 u64; +struct cvmx_ilk_rxx_idx_stat0_s { +u64 reserved_32_63 :32 ; +u64 clr :1 ; +u64 reserved_24_30 :7 ; +u64 inc :8 ; +u64 reserved_8_15 :8 ; +u64 index :8 ; + } s; +struct cvmx_ilk_rxx_idx_stat0_s cn68xx; +struct cvmx_ilk_rxx_idx_stat0_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxx_idx_stat0 cvmx_ilk_rxx_idx_stat0_t ; + +/** +* cvmx_ilk_rx#_idx_stat1 +*/ +union cvmx_ilk_rxx_idx_stat1 { +u64 u64; +struct cvmx_ilk_rxx_idx_stat1_s { +u64 reserved_32_63 :32 ; +u64 clr :1 ; +u64 reserved_24_30 :7 ; +u64 inc :8 ; +u64 reserved_8_15 :8 ; +u64 index :8 ; + } s; +struct cvmx_ilk_rxx_idx_stat1_s cn68xx; +struct cvmx_ilk_rxx_idx_stat1_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxx_idx_stat1 cvmx_ilk_rxx_idx_stat1_t ; + +/** +* cvmx_ilk_rx#_int +*/ +union cvmx_ilk_rxx_int { +u64 u64; +struct cvmx_ilk_rxx_int_s { +u64 reserved_13_63 :51 ; +u64 pmap_dbe :1 ; +u64 pmap_sbe :1 ; +u64 fwc_dbe :1 ; +u64 fwc_sbe :1 ; +u64 pkt_drop_sop :1 ; +u64 pkt_drop_rid :1 ; +u64 pkt_drop_rxf :1 ; +u64 lane_bad_word :1 ; +u64 stat_cnt_ovfl :1 ; +u64 lane_align_done :1 ; +u64 word_sync_done :1 ; +u64 crc24_err :1 ; +u64 lane_align_fail :1 ; + } s; +struct cvmx_ilk_rxx_int_cn68xx { +u64 reserved_9_63 :55 ; +u64 pkt_drop_sop :1 ; +u64 pkt_drop_rid :1 ; +u64 pkt_drop_rxf :1 ; +u64 lane_bad_word :1 ; +u64 stat_cnt_ovfl :1 ; +u64 lane_align_done :1 ; +u64 word_sync_done :1 ; +u64 crc24_err :1 ; +u64 lane_align_fail :1 ; + } cn68xx; +struct cvmx_ilk_rxx_int_cn68xxp1 { +u64 reserved_8_63 :56 ; +u64 pkt_drop_rid :1 ; +u64 pkt_drop_rxf :1 ; +u64 lane_bad_word :1 ; +u64 stat_cnt_ovfl :1 ; +u64 lane_align_done :1 ; +u64 word_sync_done :1 ; +u64 crc24_err :1 ; +u64 lane_align_fail :1 ; + } cn68xxp1; +struct cvmx_ilk_rxx_int_s cn78xx; +struct cvmx_ilk_rxx_int_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_int cvmx_ilk_rxx_int_t ; + +/** +* cvmx_ilk_rx#_int_en +*/ +union cvmx_ilk_rxx_int_en { +u64 u64; +struct cvmx_ilk_rxx_int_en_s { +u64 reserved_9_63 :55 ; +u64 pkt_drop_sop :1 ; +u64 pkt_drop_rid :1 ; +u64 pkt_drop_rxf :1 ; +u64 lane_bad_word :1 ; +u64 stat_cnt_ovfl :1 ; +u64 lane_align_done :1 ; +u64 word_sync_done :1 ; +u64 crc24_err :1 ; +u64 lane_align_fail :1 ; + } s; +struct cvmx_ilk_rxx_int_en_s cn68xx; +struct cvmx_ilk_rxx_int_en_cn68xxp1 { +u64 reserved_8_63 :56 ; +u64 pkt_drop_rid :1 ; +u64 pkt_drop_rxf :1 ; +u64 lane_bad_word :1 ; +u64 stat_cnt_ovfl :1 ; +u64 lane_align_done :1 ; +u64 word_sync_done :1 ; +u64 crc24_err :1 ; +u64 lane_align_fail :1 ; + } cn68xxp1; +}; + +typedef union cvmx_ilk_rxx_int_en cvmx_ilk_rxx_int_en_t ; + +/** +* cvmx_ilk_rx#_jabber +*/ +union cvmx_ilk_rxx_jabber { +u64 u64; +struct cvmx_ilk_rxx_jabber_s { +u64 reserved_16_63 :48 ; +u64 cnt :16 ; + } s; +struct cvmx_ilk_rxx_jabber_s cn68xx; +struct cvmx_ilk_rxx_jabber_s cn68xxp1; +struct cvmx_ilk_rxx_jabber_s cn78xx; +struct cvmx_ilk_rxx_jabber_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_jabber cvmx_ilk_rxx_jabber_t ; + +/** +* cvmx_ilk_rx#_mem_cal0 +* +* Notes: +* Software must program the calendar table prior to enabling the +* link. +* +* Software must always write ILK_RXx_MEM_CAL0 then ILK_RXx_MEM_CAL1. +* Software must never write them in reverse order or write one without +* writing the other. +* +* A given calendar table entry has no effect on PKO pipe +* backpressure when either: +* - ENTRY_CTLx=Link (1), or +* - ENTRY_CTLx=XON (3) and PORT_PIPEx is outside the range of ILK_TXx_PIPE[BASE/NUMP]. +* +* Within the 8 calendar table entries of one IDX value, if more +* than one affects the same PKO pipe, XOFF always wins over XON, +* regardless of the calendar table order. +* +* Software must always read ILK_RXx_MEM_CAL0 then ILK_RXx_MEM_CAL1. Software +* must never read them in reverse order or read one without reading the +* other. +*/ +union cvmx_ilk_rxx_mem_cal0 { +u64 u64; +struct cvmx_ilk_rxx_mem_cal0_s { +u64 reserved_36_63 :28 ; +u64 entry_ctl3 :2 ; +u64 port_pipe3 :7 ; +u64 entry_ctl2 :2 ; +u64 port_pipe2 :7 ; +u64 entry_ctl1 :2 ; +u64 port_pipe1 :7 ; +u64 entry_ctl0 :2 ; +u64 port_pipe0 :7 ; + } s; +struct cvmx_ilk_rxx_mem_cal0_s cn68xx; +struct cvmx_ilk_rxx_mem_cal0_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxx_mem_cal0 cvmx_ilk_rxx_mem_cal0_t ; + +/** +* cvmx_ilk_rx#_mem_cal1 +* +* Notes: +* Software must program the calendar table prior to enabling the +* link. +* +* Software must always write ILK_RXx_MEM_CAL0 then ILK_RXx_MEM_CAL1. +* Software must never write them in reverse order or write one without +* writing the other. +* +* A given calendar table entry has no effect on PKO pipe +* backpressure when either: +* - ENTRY_CTLx=Link (1), or +* - ENTRY_CTLx=XON (3) and PORT_PIPEx is outside the range of ILK_TXx_PIPE[BASE/NUMP]. +* +* Within the 8 calendar table entries of one IDX value, if more +* than one affects the same PKO pipe, XOFF always wins over XON, +* regardless of the calendar table order. +* +* Software must always read ILK_RXx_MEM_CAL0 then ILK_Rx_MEM_CAL1. Software +* must never read them in reverse order or read one without reading the +* other. +*/ +union cvmx_ilk_rxx_mem_cal1 { +u64 u64; +struct cvmx_ilk_rxx_mem_cal1_s { +u64 reserved_36_63 :28 ; +u64 entry_ctl7 :2 ; +u64 port_pipe7 :7 ; +u64 entry_ctl6 :2 ; +u64 port_pipe6 :7 ; +u64 entry_ctl5 :2 ; +u64 port_pipe5 :7 ; +u64 entry_ctl4 :2 ; +u64 port_pipe4 :7 ; + } s; +struct cvmx_ilk_rxx_mem_cal1_s cn68xx; +struct cvmx_ilk_rxx_mem_cal1_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxx_mem_cal1 cvmx_ilk_rxx_mem_cal1_t ; + +/** +* cvmx_ilk_rx#_mem_stat0 +*/ +union cvmx_ilk_rxx_mem_stat0 { +u64 u64; +struct cvmx_ilk_rxx_mem_stat0_s { +u64 reserved_28_63 :36 ; +u64 rx_pkt :28 ; + } s; +struct cvmx_ilk_rxx_mem_stat0_s cn68xx; +struct cvmx_ilk_rxx_mem_stat0_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxx_mem_stat0 cvmx_ilk_rxx_mem_stat0_t ; + +/** +* cvmx_ilk_rx#_mem_stat1 +*/ +union cvmx_ilk_rxx_mem_stat1 { +u64 u64; +struct cvmx_ilk_rxx_mem_stat1_s { +u64 reserved_36_63 :28 ; +u64 rx_bytes :36 ; + } s; +struct cvmx_ilk_rxx_mem_stat1_s cn68xx; +struct cvmx_ilk_rxx_mem_stat1_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxx_mem_stat1 cvmx_ilk_rxx_mem_stat1_t ; + +/** +* cvmx_ilk_rx#_pkt_cnt# +*/ +union cvmx_ilk_rxx_pkt_cntx { +u64 u64; +struct cvmx_ilk_rxx_pkt_cntx_s { +u64 reserved_34_63 :30 ; +u64 rx_pkt :34 ; + } s; +struct cvmx_ilk_rxx_pkt_cntx_s cn78xx; +struct cvmx_ilk_rxx_pkt_cntx_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_pkt_cntx cvmx_ilk_rxx_pkt_cntx_t ; + +/** +* cvmx_ilk_rx#_rid +*/ +union cvmx_ilk_rxx_rid { +u64 u64; +struct cvmx_ilk_rxx_rid_s { +u64 reserved_7_63 :57 ; +u64 max_cnt :7 ; + } s; +struct cvmx_ilk_rxx_rid_cn68xx { +u64 reserved_6_63 :58 ; +u64 max_cnt :6 ; + } cn68xx; +struct cvmx_ilk_rxx_rid_s cn78xx; +struct cvmx_ilk_rxx_rid_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_rid cvmx_ilk_rxx_rid_t ; + +/** +* cvmx_ilk_rx#_stat0 +*/ +union cvmx_ilk_rxx_stat0 { +u64 u64; +struct cvmx_ilk_rxx_stat0_s { +u64 reserved_35_63 :29 ; +u64 crc24_match_cnt :35 ; + } s; +struct cvmx_ilk_rxx_stat0_cn68xx { +u64 reserved_33_63 :31 ; +u64 crc24_match_cnt :33 ; + } cn68xx; +struct cvmx_ilk_rxx_stat0_cn68xxp1 { +u64 reserved_27_63 :37 ; +u64 crc24_match_cnt :27 ; + } cn68xxp1; +struct cvmx_ilk_rxx_stat0_s cn78xx; +struct cvmx_ilk_rxx_stat0_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_stat0 cvmx_ilk_rxx_stat0_t ; + +/** +* cvmx_ilk_rx#_stat1 +*/ +union cvmx_ilk_rxx_stat1 { +u64 u64; +struct cvmx_ilk_rxx_stat1_s { +u64 reserved_20_63 :44 ; +u64 crc24_err_cnt :20 ; + } s; +struct cvmx_ilk_rxx_stat1_cn68xx { +u64 reserved_18_63 :46 ; +u64 crc24_err_cnt :18 ; + } cn68xx; +struct cvmx_ilk_rxx_stat1_cn68xx cn68xxp1; +struct cvmx_ilk_rxx_stat1_s cn78xx; +struct cvmx_ilk_rxx_stat1_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_stat1 cvmx_ilk_rxx_stat1_t ; + +/** +* cvmx_ilk_rx#_stat2 +*/ +union cvmx_ilk_rxx_stat2 { +u64 u64; +struct cvmx_ilk_rxx_stat2_s { +u64 reserved_50_63 :14 ; +u64 brst_not_full_cnt :18 ; +u64 reserved_30_31 :2 ; +u64 brst_cnt :30 ; + } s; +struct cvmx_ilk_rxx_stat2_cn68xx { +u64 reserved_48_63 :16 ; +u64 brst_not_full_cnt :16 ; +u64 reserved_28_31 :4 ; +u64 brst_cnt :28 ; + } cn68xx; +struct cvmx_ilk_rxx_stat2_cn68xxp1 { +u64 reserved_48_63 :16 ; +u64 brst_not_full_cnt :16 ; +u64 reserved_16_31 :16 ; +u64 brst_cnt :16 ; + } cn68xxp1; +struct cvmx_ilk_rxx_stat2_s cn78xx; +struct cvmx_ilk_rxx_stat2_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_stat2 cvmx_ilk_rxx_stat2_t ; + +/** +* cvmx_ilk_rx#_stat3 +*/ +union cvmx_ilk_rxx_stat3 { +u64 u64; +struct cvmx_ilk_rxx_stat3_s { +u64 reserved_18_63 :46 ; +u64 brst_max_err_cnt :18 ; + } s; +struct cvmx_ilk_rxx_stat3_cn68xx { +u64 reserved_16_63 :48 ; +u64 brst_max_err_cnt :16 ; + } cn68xx; +struct cvmx_ilk_rxx_stat3_cn68xx cn68xxp1; +struct cvmx_ilk_rxx_stat3_s cn78xx; +struct cvmx_ilk_rxx_stat3_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_stat3 cvmx_ilk_rxx_stat3_t ; + +/** +* cvmx_ilk_rx#_stat4 +*/ +union cvmx_ilk_rxx_stat4 { +u64 u64; +struct cvmx_ilk_rxx_stat4_s { +u64 reserved_18_63 :46 ; +u64 brst_shrt_err_cnt :18 ; + } s; +struct cvmx_ilk_rxx_stat4_cn68xx { +u64 reserved_16_63 :48 ; +u64 brst_shrt_err_cnt :16 ; + } cn68xx; +struct cvmx_ilk_rxx_stat4_cn68xx cn68xxp1; +struct cvmx_ilk_rxx_stat4_s cn78xx; +struct cvmx_ilk_rxx_stat4_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_stat4 cvmx_ilk_rxx_stat4_t ; + +/** +* cvmx_ilk_rx#_stat5 +*/ +union cvmx_ilk_rxx_stat5 { +u64 u64; +struct cvmx_ilk_rxx_stat5_s { +u64 reserved_25_63 :39 ; +u64 align_cnt :25 ; + } s; +struct cvmx_ilk_rxx_stat5_cn68xx { +u64 reserved_23_63 :41 ; +u64 align_cnt :23 ; + } cn68xx; +struct cvmx_ilk_rxx_stat5_cn68xxp1 { +u64 reserved_16_63 :48 ; +u64 align_cnt :16 ; + } cn68xxp1; +struct cvmx_ilk_rxx_stat5_s cn78xx; +struct cvmx_ilk_rxx_stat5_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_stat5 cvmx_ilk_rxx_stat5_t ; + +/** +* cvmx_ilk_rx#_stat6 +*/ +union cvmx_ilk_rxx_stat6 { +u64 u64; +struct cvmx_ilk_rxx_stat6_s { +u64 reserved_18_63 :46 ; +u64 align_err_cnt :18 ; + } s; +struct cvmx_ilk_rxx_stat6_cn68xx { +u64 reserved_16_63 :48 ; +u64 align_err_cnt :16 ; + } cn68xx; +struct cvmx_ilk_rxx_stat6_cn68xx cn68xxp1; +struct cvmx_ilk_rxx_stat6_s cn78xx; +struct cvmx_ilk_rxx_stat6_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_stat6 cvmx_ilk_rxx_stat6_t ; + +/** +* cvmx_ilk_rx#_stat7 +*/ +union cvmx_ilk_rxx_stat7 { +u64 u64; +struct cvmx_ilk_rxx_stat7_s { +u64 reserved_18_63 :46 ; +u64 bad_64b67b_cnt :18 ; + } s; +struct cvmx_ilk_rxx_stat7_cn68xx { +u64 reserved_16_63 :48 ; +u64 bad_64b67b_cnt :16 ; + } cn68xx; +struct cvmx_ilk_rxx_stat7_cn68xx cn68xxp1; +struct cvmx_ilk_rxx_stat7_s cn78xx; +struct cvmx_ilk_rxx_stat7_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_stat7 cvmx_ilk_rxx_stat7_t ; + +/** +* cvmx_ilk_rx#_stat8 +*/ +union cvmx_ilk_rxx_stat8 { +u64 u64; +struct cvmx_ilk_rxx_stat8_s { +u64 reserved_32_63 :32 ; +u64 pkt_drop_rid_cnt :16 ; +u64 pkt_drop_rxf_cnt :16 ; + } s; +struct cvmx_ilk_rxx_stat8_s cn68xx; +struct cvmx_ilk_rxx_stat8_s cn68xxp1; +struct cvmx_ilk_rxx_stat8_s cn78xx; +struct cvmx_ilk_rxx_stat8_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_stat8 cvmx_ilk_rxx_stat8_t ; + +/** +* cvmx_ilk_rx#_stat9 +* +* This register is reserved. +* +*/ +union cvmx_ilk_rxx_stat9 { +u64 u64; +struct cvmx_ilk_rxx_stat9_s { +u64 reserved_0_63 :64 ; + } s; +struct cvmx_ilk_rxx_stat9_s cn68xx; +struct cvmx_ilk_rxx_stat9_s cn68xxp1; +struct cvmx_ilk_rxx_stat9_s cn78xx; +struct cvmx_ilk_rxx_stat9_s cn78xxp1; +}; + +typedef union cvmx_ilk_rxx_stat9 cvmx_ilk_rxx_stat9_t ; + +/** +* cvmx_ilk_rx_lne#_cfg +*/ +union cvmx_ilk_rx_lnex_cfg { +u64 u64; +struct cvmx_ilk_rx_lnex_cfg_s { +u64 reserved_9_63 :55 ; +u64 rx_dis_psh_skip :1 ; +u64 reserved_7_7 :1 ; +u64 rx_dis_disp_chk :1 ; +u64 rx_scrm_sync :1 ; +u64 rx_bdry_sync :1 ; +u64 rx_dis_ukwn :1 ; +u64 rx_dis_scram :1 ; +u64 stat_rdclr :1 ; +u64 stat_ena :1 ; + } s; +struct cvmx_ilk_rx_lnex_cfg_cn68xx { +u64 reserved_9_63 :55 ; +u64 rx_dis_psh_skip :1 ; +u64 reserved_6_7 :2 ; +u64 rx_scrm_sync :1 ; +u64 rx_bdry_sync :1 ; +u64 rx_dis_ukwn :1 ; +u64 rx_dis_scram :1 ; +u64 stat_rdclr :1 ; +u64 stat_ena :1 ; + } cn68xx; +struct cvmx_ilk_rx_lnex_cfg_cn68xxp1 { +u64 reserved_5_63 :59 ; +u64 rx_bdry_sync :1 ; +u64 rx_dis_ukwn :1 ; +u64 rx_dis_scram :1 ; +u64 stat_rdclr :1 ; +u64 stat_ena :1 ; + } cn68xxp1; +struct cvmx_ilk_rx_lnex_cfg_s cn78xx; +struct cvmx_ilk_rx_lnex_cfg_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_cfg cvmx_ilk_rx_lnex_cfg_t ; + +/** +* cvmx_ilk_rx_lne#_int +*/ +union cvmx_ilk_rx_lnex_int { +u64 u64; +struct cvmx_ilk_rx_lnex_int_s { +u64 reserved_10_63 :54 ; +u64 disp_err :1 ; +u64 bad_64b67b :1 ; +u64 stat_cnt_ovfl :1 ; +u64 stat_msg :1 ; +u64 dskew_fifo_ovfl :1 ; +u64 scrm_sync_loss :1 ; +u64 ukwn_cntl_word :1 ; +u64 crc32_err :1 ; +u64 bdry_sync_loss :1 ; +u64 serdes_lock_loss :1 ; + } s; +struct cvmx_ilk_rx_lnex_int_cn68xx { +u64 reserved_9_63 :55 ; +u64 bad_64b67b :1 ; +u64 stat_cnt_ovfl :1 ; +u64 stat_msg :1 ; +u64 dskew_fifo_ovfl :1 ; +u64 scrm_sync_loss :1 ; +u64 ukwn_cntl_word :1 ; +u64 crc32_err :1 ; +u64 bdry_sync_loss :1 ; +u64 serdes_lock_loss :1 ; + } cn68xx; +struct cvmx_ilk_rx_lnex_int_cn68xx cn68xxp1; +struct cvmx_ilk_rx_lnex_int_s cn78xx; +struct cvmx_ilk_rx_lnex_int_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_int cvmx_ilk_rx_lnex_int_t ; + +/** +* cvmx_ilk_rx_lne#_int_en +*/ +union cvmx_ilk_rx_lnex_int_en { +u64 u64; +struct cvmx_ilk_rx_lnex_int_en_s { +u64 reserved_9_63 :55 ; +u64 bad_64b67b :1 ; +u64 stat_cnt_ovfl :1 ; +u64 stat_msg :1 ; +u64 dskew_fifo_ovfl :1 ; +u64 scrm_sync_loss :1 ; +u64 ukwn_cntl_word :1 ; +u64 crc32_err :1 ; +u64 bdry_sync_loss :1 ; +u64 serdes_lock_loss :1 ; + } s; +struct cvmx_ilk_rx_lnex_int_en_s cn68xx; +struct cvmx_ilk_rx_lnex_int_en_s cn68xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_int_en cvmx_ilk_rx_lnex_int_en_t ; + +/** +* cvmx_ilk_rx_lne#_stat0 +*/ +union cvmx_ilk_rx_lnex_stat0 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat0_s { +u64 reserved_18_63 :46 ; +u64 ser_lock_loss_cnt :18 ; + } s; +struct cvmx_ilk_rx_lnex_stat0_s cn68xx; +struct cvmx_ilk_rx_lnex_stat0_s cn68xxp1; +struct cvmx_ilk_rx_lnex_stat0_s cn78xx; +struct cvmx_ilk_rx_lnex_stat0_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat0 cvmx_ilk_rx_lnex_stat0_t ; + +/** +* cvmx_ilk_rx_lne#_stat1 +*/ +union cvmx_ilk_rx_lnex_stat1 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat1_s { +u64 reserved_18_63 :46 ; +u64 bdry_sync_loss_cnt :18 ; + } s; +struct cvmx_ilk_rx_lnex_stat1_s cn68xx; +struct cvmx_ilk_rx_lnex_stat1_s cn68xxp1; +struct cvmx_ilk_rx_lnex_stat1_s cn78xx; +struct cvmx_ilk_rx_lnex_stat1_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat1 cvmx_ilk_rx_lnex_stat1_t ; + +/** +* cvmx_ilk_rx_lne#_stat10 +*/ +union cvmx_ilk_rx_lnex_stat10 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat10_s { +u64 reserved_43_63 :21 ; +u64 prbs_bad :11 ; +u64 reserved_11_31 :21 ; +u64 prbs_good :11 ; + } s; +struct cvmx_ilk_rx_lnex_stat10_s cn78xx; +struct cvmx_ilk_rx_lnex_stat10_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat10 cvmx_ilk_rx_lnex_stat10_t ; + +/** +* cvmx_ilk_rx_lne#_stat2 +*/ +union cvmx_ilk_rx_lnex_stat2 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat2_s { +u64 reserved_50_63 :14 ; +u64 syncw_good_cnt :18 ; +u64 reserved_18_31 :14 ; +u64 syncw_bad_cnt :18 ; + } s; +struct cvmx_ilk_rx_lnex_stat2_s cn68xx; +struct cvmx_ilk_rx_lnex_stat2_s cn68xxp1; +struct cvmx_ilk_rx_lnex_stat2_s cn78xx; +struct cvmx_ilk_rx_lnex_stat2_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat2 cvmx_ilk_rx_lnex_stat2_t ; + +/** +* cvmx_ilk_rx_lne#_stat3 +*/ +union cvmx_ilk_rx_lnex_stat3 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat3_s { +u64 reserved_18_63 :46 ; +u64 bad_64b67b_cnt :18 ; + } s; +struct cvmx_ilk_rx_lnex_stat3_s cn68xx; +struct cvmx_ilk_rx_lnex_stat3_s cn68xxp1; +struct cvmx_ilk_rx_lnex_stat3_s cn78xx; +struct cvmx_ilk_rx_lnex_stat3_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat3 cvmx_ilk_rx_lnex_stat3_t ; + +/** +* cvmx_ilk_rx_lne#_stat4 +*/ +union cvmx_ilk_rx_lnex_stat4 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat4_s { +u64 reserved_59_63 :5 ; +u64 cntl_word_cnt :27 ; +u64 reserved_27_31 :5 ; +u64 data_word_cnt :27 ; + } s; +struct cvmx_ilk_rx_lnex_stat4_s cn68xx; +struct cvmx_ilk_rx_lnex_stat4_s cn68xxp1; +struct cvmx_ilk_rx_lnex_stat4_s cn78xx; +struct cvmx_ilk_rx_lnex_stat4_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat4 cvmx_ilk_rx_lnex_stat4_t ; + +/** +* cvmx_ilk_rx_lne#_stat5 +*/ +union cvmx_ilk_rx_lnex_stat5 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat5_s { +u64 reserved_18_63 :46 ; +u64 unkwn_word_cnt :18 ; + } s; +struct cvmx_ilk_rx_lnex_stat5_s cn68xx; +struct cvmx_ilk_rx_lnex_stat5_s cn68xxp1; +struct cvmx_ilk_rx_lnex_stat5_s cn78xx; +struct cvmx_ilk_rx_lnex_stat5_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat5 cvmx_ilk_rx_lnex_stat5_t ; + +/** +* cvmx_ilk_rx_lne#_stat6 +*/ +union cvmx_ilk_rx_lnex_stat6 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat6_s { +u64 reserved_18_63 :46 ; +u64 scrm_sync_loss_cnt :18 ; + } s; +struct cvmx_ilk_rx_lnex_stat6_s cn68xx; +struct cvmx_ilk_rx_lnex_stat6_s cn68xxp1; +struct cvmx_ilk_rx_lnex_stat6_s cn78xx; +struct cvmx_ilk_rx_lnex_stat6_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat6 cvmx_ilk_rx_lnex_stat6_t ; + +/** +* cvmx_ilk_rx_lne#_stat7 +*/ +union cvmx_ilk_rx_lnex_stat7 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat7_s { +u64 reserved_18_63 :46 ; +u64 scrm_match_cnt :18 ; + } s; +struct cvmx_ilk_rx_lnex_stat7_s cn68xx; +struct cvmx_ilk_rx_lnex_stat7_s cn68xxp1; +struct cvmx_ilk_rx_lnex_stat7_s cn78xx; +struct cvmx_ilk_rx_lnex_stat7_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat7 cvmx_ilk_rx_lnex_stat7_t ; + +/** +* cvmx_ilk_rx_lne#_stat8 +*/ +union cvmx_ilk_rx_lnex_stat8 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat8_s { +u64 reserved_18_63 :46 ; +u64 skipw_good_cnt :18 ; + } s; +struct cvmx_ilk_rx_lnex_stat8_s cn68xx; +struct cvmx_ilk_rx_lnex_stat8_s cn68xxp1; +struct cvmx_ilk_rx_lnex_stat8_s cn78xx; +struct cvmx_ilk_rx_lnex_stat8_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat8 cvmx_ilk_rx_lnex_stat8_t ; + +/** +* cvmx_ilk_rx_lne#_stat9 +*/ +union cvmx_ilk_rx_lnex_stat9 { +u64 u64; +struct cvmx_ilk_rx_lnex_stat9_s { +u64 reserved_50_63 :14 ; +u64 crc32_err_cnt :18 ; +u64 reserved_27_31 :5 ; +u64 crc32_match_cnt :27 ; + } s; +struct cvmx_ilk_rx_lnex_stat9_s cn68xx; +struct cvmx_ilk_rx_lnex_stat9_s cn68xxp1; +struct cvmx_ilk_rx_lnex_stat9_s cn78xx; +struct cvmx_ilk_rx_lnex_stat9_s cn78xxp1; +}; + +typedef union cvmx_ilk_rx_lnex_stat9 cvmx_ilk_rx_lnex_stat9_t ; + +/** +* cvmx_ilk_rxf_idx_pmap +*/ +union cvmx_ilk_rxf_idx_pmap { +u64 u64; +struct cvmx_ilk_rxf_idx_pmap_s { +u64 reserved_25_63 :39 ; +u64 inc :9 ; +u64 reserved_9_15 :7 ; +u64 index :9 ; + } s; +struct cvmx_ilk_rxf_idx_pmap_s cn68xx; +struct cvmx_ilk_rxf_idx_pmap_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxf_idx_pmap cvmx_ilk_rxf_idx_pmap_t ; + +/** +* cvmx_ilk_rxf_mem_pmap +*/ +union cvmx_ilk_rxf_mem_pmap { +u64 u64; +struct cvmx_ilk_rxf_mem_pmap_s { +u64 reserved_6_63 :58 ; +u64 port_kind :6 ; + } s; +struct cvmx_ilk_rxf_mem_pmap_s cn68xx; +struct cvmx_ilk_rxf_mem_pmap_s cn68xxp1; +}; + +typedef union cvmx_ilk_rxf_mem_pmap cvmx_ilk_rxf_mem_pmap_t ; + +/** +* cvmx_ilk_ser_cfg +*/ +union cvmx_ilk_ser_cfg { +u64 u64; +struct cvmx_ilk_ser_cfg_s { +u64 reserved_57_63 :7 ; +u64 ser_rxpol_auto :1 ; +u64 ser_rxpol :16 ; +u64 ser_txpol :16 ; +u64 ser_reset_n :16 ; +u64 ser_pwrup :4 ; +u64 ser_haul :4 ; + } s; +struct cvmx_ilk_ser_cfg_cn68xx { +u64 reserved_57_63 :7 ; +u64 ser_rxpol_auto :1 ; +u64 reserved_48_55 :8 ; +u64 ser_rxpol :8 ; +u64 reserved_32_39 :8 ; +u64 ser_txpol :8 ; +u64 reserved_16_23 :8 ; +u64 ser_reset_n :8 ; +u64 reserved_6_7 :2 ; +u64 ser_pwrup :2 ; +u64 reserved_2_3 :2 ; +u64 ser_haul :2 ; + } cn68xx; +struct cvmx_ilk_ser_cfg_cn68xx cn68xxp1; +struct cvmx_ilk_ser_cfg_s cn78xx; +struct cvmx_ilk_ser_cfg_s cn78xxp1; +}; + +typedef union cvmx_ilk_ser_cfg cvmx_ilk_ser_cfg_t ; + +/** +* cvmx_ilk_tx#_byte_cnt# +*/ +union cvmx_ilk_txx_byte_cntx { +u64 u64; +struct cvmx_ilk_txx_byte_cntx_s { +u64 reserved_40_63 :24 ; +u64 tx_bytes :40 ; + } s; +struct cvmx_ilk_txx_byte_cntx_s cn78xx; +struct cvmx_ilk_txx_byte_cntx_s cn78xxp1; +}; + +typedef union cvmx_ilk_txx_byte_cntx cvmx_ilk_txx_byte_cntx_t ; + +/** +* cvmx_ilk_tx#_cal_entry# +*/ +union cvmx_ilk_txx_cal_entryx { +u64 u64; +struct cvmx_ilk_txx_cal_entryx_s { +u64 reserved_34_63 :30 ; +u64 ctl :2 ; +u64 reserved_8_31 :24 ; +u64 channel :8 ; + } s; +struct cvmx_ilk_txx_cal_entryx_s cn78xx; +struct cvmx_ilk_txx_cal_entryx_s cn78xxp1; +}; + +typedef union cvmx_ilk_txx_cal_entryx cvmx_ilk_txx_cal_entryx_t ; + +/** +* cvmx_ilk_tx#_cfg0 +*/ +union cvmx_ilk_txx_cfg0 { +u64 u64; +struct cvmx_ilk_txx_cfg0_s { +u64 ext_lpbk_fc :1 ; +u64 ext_lpbk :1 ; +u64 int_lpbk :1 ; +u64 txf_byp_dis :1 ; +u64 reserved_57_59 :3 ; +u64 ptrn_mode :1 ; +u64 lnk_stats_rdclr :1 ; +u64 lnk_stats_ena :1 ; +u64 mltuse_fc_ena :1 ; +u64 cal_ena :1 ; +u64 mfrm_len :13 ; +u64 brst_shrt :7 ; +u64 lane_rev :1 ; +u64 brst_max :5 ; +u64 reserved_25_25 :1 ; +u64 cal_depth :9 ; +u64 lane_ena :16 ; + } s; +struct cvmx_ilk_txx_cfg0_cn68xx { +u64 ext_lpbk_fc :1 ; +u64 ext_lpbk :1 ; +u64 int_lpbk :1 ; +u64 reserved_57_60 :4 ; +u64 ptrn_mode :1 ; +u64 reserved_55_55 :1 ; +u64 lnk_stats_ena :1 ; +u64 mltuse_fc_ena :1 ; +u64 cal_ena :1 ; +u64 mfrm_len :13 ; +u64 brst_shrt :7 ; +u64 lane_rev :1 ; +u64 brst_max :5 ; +u64 reserved_25_25 :1 ; +u64 cal_depth :9 ; +u64 reserved_8_15 :8 ; +u64 lane_ena :8 ; + } cn68xx; +struct cvmx_ilk_txx_cfg0_cn68xx cn68xxp1; +struct cvmx_ilk_txx_cfg0_s cn78xx; +struct cvmx_ilk_txx_cfg0_s cn78xxp1; +}; + +typedef union cvmx_ilk_txx_cfg0 cvmx_ilk_txx_cfg0_t ; + +/** +* cvmx_ilk_tx#_cfg1 +*/ +union cvmx_ilk_txx_cfg1 { +u64 u64; +struct cvmx_ilk_txx_cfg1_s { +u64 ser_low :4 ; +u64 reserved_53_59 :7 ; +u64 brst_min :5 ; +u64 reserved_43_47 :5 ; +u64 ser_limit :10 ; +u64 pkt_busy :1 ; +u64 pipe_crd_dis :1 ; +u64 ptp_delay :5 ; +u64 skip_cnt :4 ; +u64 pkt_flush :1 ; +u64 pkt_ena :1 ; +u64 la_mode :1 ; +u64 tx_link_fc :1 ; +u64 rx_link_fc :1 ; +u64 reserved_12_16 :5 ; +u64 tx_link_fc_jam :1 ; +u64 rx_link_fc_pkt :1 ; +u64 rx_link_fc_ign :1 ; +u64 rmatch :1 ; +u64 tx_mltuse :8 ; + } s; +struct cvmx_ilk_txx_cfg1_cn68xx { +u64 reserved_33_63 :31 ; +u64 pkt_busy :1 ; +u64 pipe_crd_dis :1 ; +u64 ptp_delay :5 ; +u64 skip_cnt :4 ; +u64 pkt_flush :1 ; +u64 pkt_ena :1 ; +u64 la_mode :1 ; +u64 tx_link_fc :1 ; +u64 rx_link_fc :1 ; +u64 reserved_12_16 :5 ; +u64 tx_link_fc_jam :1 ; +u64 rx_link_fc_pkt :1 ; +u64 rx_link_fc_ign :1 ; +u64 rmatch :1 ; +u64 tx_mltuse :8 ; + } cn68xx; +struct cvmx_ilk_txx_cfg1_cn68xxp1 { +u64 reserved_32_63 :32 ; +u64 pipe_crd_dis :1 ; +u64 ptp_delay :5 ; +u64 skip_cnt :4 ; +u64 pkt_flush :1 ; +u64 pkt_ena :1 ; +u64 la_mode :1 ; +u64 tx_link_fc :1 ; +u64 rx_link_fc :1 ; +u64 reserved_12_16 :5 ; +u64 tx_link_fc_jam :1 ; +u64 rx_link_fc_pkt :1 ; +u64 rx_link_fc_ign :1 ; +u64 rmatch :1 ; +u64 tx_mltuse :8 ; + } cn68xxp1; +struct cvmx_ilk_txx_cfg1_s cn78xx; +struct cvmx_ilk_txx_cfg1_s cn78xxp1; +}; + +typedef union cvmx_ilk_txx_cfg1 cvmx_ilk_txx_cfg1_t ; + +/** +* cvmx_ilk_tx#_cha_xon# +*/ +union cvmx_ilk_txx_cha_xonx { +u64 u64; +struct cvmx_ilk_txx_cha_xonx_s { +u64 status :64 ; + } s; +struct cvmx_ilk_txx_cha_xonx_s cn78xx; +struct cvmx_ilk_txx_cha_xonx_s cn78xxp1; +}; + +typedef union cvmx_ilk_txx_cha_xonx cvmx_ilk_txx_cha_xonx_t ; + +/** +* cvmx_ilk_tx#_dbg +*/ +union cvmx_ilk_txx_dbg { +u64 u64; +struct cvmx_ilk_txx_dbg_s { +u64 reserved_29_63 :35 ; +u64 data_rate :13 ; +u64 low_delay :6 ; +u64 reserved_3_9 :7 ; +u64 tx_bad_crc24 :1 ; +u64 tx_bad_ctlw2 :1 ; +u64 tx_bad_ctlw1 :1 ; + } s; +struct cvmx_ilk_txx_dbg_cn68xx { +u64 reserved_3_63 :61 ; +u64 tx_bad_crc24 :1 ; +u64 tx_bad_ctlw2 :1 ; +u64 tx_bad_ctlw1 :1 ; + } cn68xx; +struct cvmx_ilk_txx_dbg_cn68xx cn68xxp1; +struct cvmx_ilk_txx_dbg_s cn78xx; +struct cvmx_ilk_txx_dbg_s cn78xxp1; +}; + +typedef union cvmx_ilk_txx_dbg cvmx_ilk_txx_dbg_t ; + +/** +* cvmx_ilk_tx#_err_cfg +*/ +union cvmx_ilk_txx_err_cfg { +u64 u64; +struct cvmx_ilk_txx_err_cfg_s { +u64 reserved_20_63 :44 ; +u64 fwc_flip :2 ; +u64 txf_flip :2 ; +u64 reserved_2_15 :14 ; +u64 fwc_cor_dis :1 ; +u64 txf_cor_dis :1 ; + } s; +struct cvmx_ilk_txx_err_cfg_s cn78xx; +struct cvmx_ilk_txx_err_cfg_s cn78xxp1; +}; + +typedef union cvmx_ilk_txx_err_cfg cvmx_ilk_txx_err_cfg_t ; + +/** +* cvmx_ilk_tx#_flow_ctl0 +*/ +union cvmx_ilk_txx_flow_ctl0 { +u64 u64; +struct cvmx_ilk_txx_flow_ctl0_s { +u64 status :64 ; + } s; +struct cvmx_ilk_txx_flow_ctl0_s cn68xx; +struct cvmx_ilk_txx_flow_ctl0_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_flow_ctl0 cvmx_ilk_txx_flow_ctl0_t ; + +/** +* cvmx_ilk_tx#_flow_ctl1 +* +* Notes: +* Do not publish. +* +*/ +union cvmx_ilk_txx_flow_ctl1 { +u64 u64; +struct cvmx_ilk_txx_flow_ctl1_s { +u64 reserved_0_63 :64 ; + } s; +struct cvmx_ilk_txx_flow_ctl1_s cn68xx; +struct cvmx_ilk_txx_flow_ctl1_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_flow_ctl1 cvmx_ilk_txx_flow_ctl1_t ; + +/** +* cvmx_ilk_tx#_idx_cal +*/ +union cvmx_ilk_txx_idx_cal { +u64 u64; +struct cvmx_ilk_txx_idx_cal_s { +u64 reserved_14_63 :50 ; +u64 inc :6 ; +u64 reserved_6_7 :2 ; +u64 index :6 ; + } s; +struct cvmx_ilk_txx_idx_cal_s cn68xx; +struct cvmx_ilk_txx_idx_cal_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_idx_cal cvmx_ilk_txx_idx_cal_t ; + +/** +* cvmx_ilk_tx#_idx_pmap +*/ +union cvmx_ilk_txx_idx_pmap { +u64 u64; +struct cvmx_ilk_txx_idx_pmap_s { +u64 reserved_23_63 :41 ; +u64 inc :7 ; +u64 reserved_7_15 :9 ; +u64 index :7 ; + } s; +struct cvmx_ilk_txx_idx_pmap_s cn68xx; +struct cvmx_ilk_txx_idx_pmap_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_idx_pmap cvmx_ilk_txx_idx_pmap_t ; + +/** +* cvmx_ilk_tx#_idx_stat0 +*/ +union cvmx_ilk_txx_idx_stat0 { +u64 u64; +struct cvmx_ilk_txx_idx_stat0_s { +u64 reserved_32_63 :32 ; +u64 clr :1 ; +u64 reserved_24_30 :7 ; +u64 inc :8 ; +u64 reserved_8_15 :8 ; +u64 index :8 ; + } s; +struct cvmx_ilk_txx_idx_stat0_s cn68xx; +struct cvmx_ilk_txx_idx_stat0_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_idx_stat0 cvmx_ilk_txx_idx_stat0_t ; + +/** +* cvmx_ilk_tx#_idx_stat1 +*/ +union cvmx_ilk_txx_idx_stat1 { +u64 u64; +struct cvmx_ilk_txx_idx_stat1_s { +u64 reserved_32_63 :32 ; +u64 clr :1 ; +u64 reserved_24_30 :7 ; +u64 inc :8 ; +u64 reserved_8_15 :8 ; +u64 index :8 ; + } s; +struct cvmx_ilk_txx_idx_stat1_s cn68xx; +struct cvmx_ilk_txx_idx_stat1_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_idx_stat1 cvmx_ilk_txx_idx_stat1_t ; + +/** +* cvmx_ilk_tx#_int +*/ +union cvmx_ilk_txx_int { +u64 u64; +struct cvmx_ilk_txx_int_s { +u64 reserved_8_63 :56 ; +u64 fwc_dbe :1 ; +u64 fwc_sbe :1 ; +u64 txf_dbe :1 ; +u64 txf_sbe :1 ; +u64 stat_cnt_ovfl :1 ; +u64 bad_pipe :1 ; +u64 bad_seq :1 ; +u64 txf_err :1 ; + } s; +struct cvmx_ilk_txx_int_cn68xx { +u64 reserved_4_63 :60 ; +u64 stat_cnt_ovfl :1 ; +u64 bad_pipe :1 ; +u64 bad_seq :1 ; +u64 txf_err :1 ; + } cn68xx; +struct cvmx_ilk_txx_int_cn68xx cn68xxp1; +struct cvmx_ilk_txx_int_s cn78xx; +struct cvmx_ilk_txx_int_s cn78xxp1; +}; + +typedef union cvmx_ilk_txx_int cvmx_ilk_txx_int_t ; + +/** +* cvmx_ilk_tx#_int_en +*/ +union cvmx_ilk_txx_int_en { +u64 u64; +struct cvmx_ilk_txx_int_en_s { +u64 reserved_4_63 :60 ; +u64 stat_cnt_ovfl :1 ; +u64 bad_pipe :1 ; +u64 bad_seq :1 ; +u64 txf_err :1 ; + } s; +struct cvmx_ilk_txx_int_en_s cn68xx; +struct cvmx_ilk_txx_int_en_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_int_en cvmx_ilk_txx_int_en_t ; + +/** +* cvmx_ilk_tx#_mem_cal0 +* +* Notes: +* Software must always read ILK_TXx_MEM_CAL0 then ILK_TXx_MEM_CAL1. Software +* must never read them in reverse order or read one without reading the +* other. +* +* Software must always write ILK_TXx_MEM_CAL0 then ILK_TXx_MEM_CAL1. +* Software must never write them in reverse order or write one without +* writing the other. +*/ +union cvmx_ilk_txx_mem_cal0 { +u64 u64; +struct cvmx_ilk_txx_mem_cal0_s { +u64 reserved_36_63 :28 ; +u64 entry_ctl3 :2 ; +u64 reserved_33_33 :1 ; +u64 bpid3 :6 ; +u64 entry_ctl2 :2 ; +u64 reserved_24_24 :1 ; +u64 bpid2 :6 ; +u64 entry_ctl1 :2 ; +u64 reserved_15_15 :1 ; +u64 bpid1 :6 ; +u64 entry_ctl0 :2 ; +u64 reserved_6_6 :1 ; +u64 bpid0 :6 ; + } s; +struct cvmx_ilk_txx_mem_cal0_s cn68xx; +struct cvmx_ilk_txx_mem_cal0_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_mem_cal0 cvmx_ilk_txx_mem_cal0_t ; + +/** +* cvmx_ilk_tx#_mem_cal1 +* +* Notes: +* Software must always read ILK_TXx_MEM_CAL0 then ILK_TXx_MEM_CAL1. Software +* must never read them in reverse order or read one without reading the +* other. +* +* Software must always write ILK_TXx_MEM_CAL0 then ILK_TXx_MEM_CAL1. +* Software must never write them in reverse order or write one without +* writing the other. +*/ +union cvmx_ilk_txx_mem_cal1 { +u64 u64; +struct cvmx_ilk_txx_mem_cal1_s { +u64 reserved_36_63 :28 ; +u64 entry_ctl7 :2 ; +u64 reserved_33_33 :1 ; +u64 bpid7 :6 ; +u64 entry_ctl6 :2 ; +u64 reserved_24_24 :1 ; +u64 bpid6 :6 ; +u64 entry_ctl5 :2 ; +u64 reserved_15_15 :1 ; +u64 bpid5 :6 ; +u64 entry_ctl4 :2 ; +u64 reserved_6_6 :1 ; +u64 bpid4 :6 ; + } s; +struct cvmx_ilk_txx_mem_cal1_s cn68xx; +struct cvmx_ilk_txx_mem_cal1_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_mem_cal1 cvmx_ilk_txx_mem_cal1_t ; + +/** +* cvmx_ilk_tx#_mem_pmap +*/ +union cvmx_ilk_txx_mem_pmap { +u64 u64; +struct cvmx_ilk_txx_mem_pmap_s { +u64 reserved_17_63 :47 ; +u64 remap :1 ; +u64 reserved_8_15 :8 ; +u64 channel :8 ; + } s; +struct cvmx_ilk_txx_mem_pmap_s cn68xx; +struct cvmx_ilk_txx_mem_pmap_cn68xxp1 { +u64 reserved_8_63 :56 ; +u64 channel :8 ; + } cn68xxp1; +}; + +typedef union cvmx_ilk_txx_mem_pmap cvmx_ilk_txx_mem_pmap_t ; + +/** +* cvmx_ilk_tx#_mem_stat0 +*/ +union cvmx_ilk_txx_mem_stat0 { +u64 u64; +struct cvmx_ilk_txx_mem_stat0_s { +u64 reserved_28_63 :36 ; +u64 tx_pkt :28 ; + } s; +struct cvmx_ilk_txx_mem_stat0_s cn68xx; +struct cvmx_ilk_txx_mem_stat0_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_mem_stat0 cvmx_ilk_txx_mem_stat0_t ; + +/** +* cvmx_ilk_tx#_mem_stat1 +*/ +union cvmx_ilk_txx_mem_stat1 { +u64 u64; +struct cvmx_ilk_txx_mem_stat1_s { +u64 reserved_36_63 :28 ; +u64 tx_bytes :36 ; + } s; +struct cvmx_ilk_txx_mem_stat1_s cn68xx; +struct cvmx_ilk_txx_mem_stat1_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_mem_stat1 cvmx_ilk_txx_mem_stat1_t ; + +/** +* cvmx_ilk_tx#_pipe +*/ +union cvmx_ilk_txx_pipe { +u64 u64; +struct cvmx_ilk_txx_pipe_s { +u64 reserved_24_63 :40 ; +u64 nump :8 ; +u64 reserved_7_15 :9 ; +u64 base :7 ; + } s; +struct cvmx_ilk_txx_pipe_s cn68xx; +struct cvmx_ilk_txx_pipe_s cn68xxp1; +}; + +typedef union cvmx_ilk_txx_pipe cvmx_ilk_txx_pipe_t ; + +/** +* cvmx_ilk_tx#_pkt_cnt# +*/ +union cvmx_ilk_txx_pkt_cntx { +u64 u64; +struct cvmx_ilk_txx_pkt_cntx_s { +u64 reserved_34_63 :30 ; +u64 tx_pkt :34 ; + } s; +struct cvmx_ilk_txx_pkt_cntx_s cn78xx; +struct cvmx_ilk_txx_pkt_cntx_s cn78xxp1; +}; + +typedef union cvmx_ilk_txx_pkt_cntx cvmx_ilk_txx_pkt_cntx_t ; + +/** +* cvmx_ilk_tx#_rmatch +*/ +union cvmx_ilk_txx_rmatch { +u64 u64; +struct cvmx_ilk_txx_rmatch_s { +u64 reserved_50_63 :14 ; +u64 grnlrty :2 ; +u64 brst_limit :16 ; +u64 time_limit :16 ; +u64 rate_limit :16 ; + } s; +struct cvmx_ilk_txx_rmatch_s cn68xx; +struct cvmx_ilk_txx_rmatch_s cn68xxp1; +struct cvmx_ilk_txx_rmatch_s cn78xx; +struct cvmx_ilk_txx_rmatch_s cn78xxp1; +}; + +typedef union cvmx_ilk_txx_rmatch cvmx_ilk_txx_rmatch_t ; + +#endif
Signature · 1 line
2.35.1
cover mips: octeon: Add ethernet support
This patchset adds the networking files and drivers including device helper headers and C files. Please excuse the massive amount of files in this patch series. Also the sometimes huge files (mostly headers with register definitions) that I needed to include.
The infrastructure code with all the headers is ported mistly without any intended functional changes from the 2013 Cavium / Marvell U-Boot version. It has undergone many hours of extensive code cleanup and reformatting. Some of it done by using tools (checkpatch, Lindent, clang format etc) and also some of it done manually, as I couldn't find some tools that could do the needed work in a reliable and functional way. The result is that checkpatch now only throws a "few" warnings that are left. Some of those can't be removed without an even more extensive cleanup / rewrite of the code, like the addition of typedefs.
The added header, helper and infrastructure files in the first part of the patch-series (patches 1-43) are the foundation, that is used by the main Octeon U-Boot ethernet driver (patch 50/52). Patches 47-49 add the DT nodes and properties to the corresponding dtsi / dts files. Patches 51 & 52 finally enable the ethernet support both MIPS Octeon boards, EBB7304 & NIC23.
All this is tested on the 2 Cavium / Marvell MIPS Octeon boards:
EBB7304 & NIC23
This patchset including the small Marvell PHY patches is available in this gitlab branch:
https://source.denx.de/u-boot/custodians/u-boot-marvell/-/tree/mips-octeon-ethernet-v1-2022-03-30
Thanks,
Stefan
Aaron Williams (40):
mips: octeon: Add misc cvmx-* header files
mips: octeon: Add cvmx-ilk-defs.h header file
mips: octeon: Add cvmx-iob-defs.h header file
mips: octeon: Add cvmx-lbk-defs.h header file
mips: octeon: Add cvmx-npei-defs.h header file
mips: octeon: Add cvmx-pcsxx-defs.h header file
mips: octeon: Add cvmx-xcv-defs.h header file
mips: octeon: Add cvmx-helper-agl.c
mips: octeon: Add cvmx-helper-bgx.c
mips: octeon: Add cvmx-helper-board.c
mips: octeon: Add cvmx-helper-fpa.c
mips: octeon: Add cvmx-helper-igl.c
mips: octeon: Add cvmx-helper-ipd.c
mips: octeon: Add cvmx-helper-loop.c
mips: octeon: Add cvmx-helper-npi.c
mips: octeon: Add cvmx-helper-pki.c
mips: octeon: Add cvmx-helper-pko.c
mips: octeon: Add cvmx-helper-pko3.c
mips: octeon: Add cvmx-helper-rgmii.c
mips: octeon: Add cvmx-helper-sgmii.c
mips: octeon: Add cvmx-helper-sfp.c
mips: octeon: Add cvmx-helper-xaui.c
mips: octeon: Add cvmx-agl.c
mips: octeon: Add cvmx-cmd-queue.c
mips: octeon: Add cvmx-fau-compat.c
mips: octeon: Add cvmx-fpa.c
mips: octeon: Add cvmx-fpa-resource.c
mips: octeon: Add cvmx-global-resource.c
mips: octeon: Add cvmx-ilk.c
mips: octeon: Add cvmx-ipd.c
mips: octeon: Add cvmx-pki.c
mips: octeon: Add cvmx-pki-resources.c
mips: octeon: Add cvmx-pko.c
mips: octeon: Add cvmx-pko3.c
mips: octeon: Add cvmx-pko3-queue.c
mips: octeon: Add cvmx-pko3-compat.c
mips: octeon: Add cvmx-pko3-resources.c
mips: octeon: Add cvmx-pko-internal-ports-range.c
mips: octeon: Add cvmx-qlm-tables.c
mips: octeon: Add cvmx-range.c
Stefan Roese (12):
mips: octeon: Misc changes to existing headers for upcoming eth
support
mips: octeon: Misc changes to existing C files for upcoming eth
support
mips: octeon: Makefile: Enable building of the newly added C files
mips: octeon: cpu.c: Move bootmem init to arch_early_init_r()
mips: octeon: cpu.c: Implement configure_lmtdma_window()
mips: octeon: octeon_common.h: Move init SP because of increased image
size
mips: octeon: mrvl,cn73xx.dtsi: Add ethernet (BGX) and SMI DT nodes
mips: octeon: mrvl,octeon-ebb7304.dts: Add ethernet DT support
mips: octeon: mrvl,octeon-nic23.dts: Add ethernet DT support
net: Add ethernet support for MIPS Octeon
mips: octeon: ebb7304: Enable ethernet support
mips: octeon: nic23: Enable ethernet support
arch/mips/Kconfig | 1 + arch/mips/dts/mrvl,cn73xx.dtsi | 35 + arch/mips/dts/mrvl,octeon-ebb7304.dts | 45 + arch/mips/dts/mrvl,octeon-nic23.dts | 238 ++ arch/mips/mach-octeon/Makefile | 35 +- arch/mips/mach-octeon/cpu.c | 47 +- arch/mips/mach-octeon/cvmx-agl.c | 216 + arch/mips/mach-octeon/cvmx-bootmem.c | 3 +- arch/mips/mach-octeon/cvmx-cmd-queue.c | 449 +++ arch/mips/mach-octeon/cvmx-fau-compat.c | 53 + arch/mips/mach-octeon/cvmx-fpa-resource.c | 305 ++ arch/mips/mach-octeon/cvmx-fpa.c | 1672 ++++++++ arch/mips/mach-octeon/cvmx-global-resources.c | 639 +++ arch/mips/mach-octeon/cvmx-helper-agl.c | 231 ++ arch/mips/mach-octeon/cvmx-helper-bgx.c | 3215 +++++++++++++++ arch/mips/mach-octeon/cvmx-helper-board.c | 2030 ++++++++++ arch/mips/mach-octeon/cvmx-helper-cfg.c | 67 +- arch/mips/mach-octeon/cvmx-helper-fdt.c | 645 ++- arch/mips/mach-octeon/cvmx-helper-fpa.c | 329 ++ arch/mips/mach-octeon/cvmx-helper-ilk.c | 926 +++++ arch/mips/mach-octeon/cvmx-helper-ipd.c | 313 ++ arch/mips/mach-octeon/cvmx-helper-loop.c | 178 + arch/mips/mach-octeon/cvmx-helper-npi.c | 146 + arch/mips/mach-octeon/cvmx-helper-pki.c | 2156 ++++++++++ arch/mips/mach-octeon/cvmx-helper-pko.c | 312 ++ arch/mips/mach-octeon/cvmx-helper-pko3.c | 1252 ++++++ arch/mips/mach-octeon/cvmx-helper-rgmii.c | 431 ++ arch/mips/mach-octeon/cvmx-helper-sfp.c | 1877 +++++++++ arch/mips/mach-octeon/cvmx-helper-sgmii.c | 781 ++++ arch/mips/mach-octeon/cvmx-helper-xaui.c | 587 +++ arch/mips/mach-octeon/cvmx-helper.c | 45 +- arch/mips/mach-octeon/cvmx-ilk.c | 1618 ++++++++ arch/mips/mach-octeon/cvmx-ipd.c | 690 ++++ arch/mips/mach-octeon/cvmx-pki-resources.c | 519 +++ arch/mips/mach-octeon/cvmx-pki.c | 1619 ++++++++ .../cvmx-pko-internal-ports-range.c | 164 + arch/mips/mach-octeon/cvmx-pko.c | 1110 ++++++ arch/mips/mach-octeon/cvmx-pko3-compat.c | 656 +++ arch/mips/mach-octeon/cvmx-pko3-queue.c | 1331 ++++++ arch/mips/mach-octeon/cvmx-pko3-resources.c | 229 ++ arch/mips/mach-octeon/cvmx-pko3.c | 2143 ++++++++++ arch/mips/mach-octeon/cvmx-qlm-tables.c | 292 ++ arch/mips/mach-octeon/cvmx-range.c | 344 ++ arch/mips/mach-octeon/include/mach/cvmx-agl.h | 45 + .../mach-octeon/include/mach/cvmx-bootmem.h | 3 +- .../mach-octeon/include/mach/cvmx-config.h | 128 + arch/mips/mach-octeon/include/mach/cvmx-fau.h | 581 +++ arch/mips/mach-octeon/include/mach/cvmx-fpa.h | 3 +- .../mips/mach-octeon/include/mach/cvmx-fpa3.h | 37 - .../include/mach/cvmx-helper-board.h | 6 +- .../include/mach/cvmx-helper-fdt.h | 40 +- .../include/mach/cvmx-helper-pko.h | 2 +- .../mach-octeon/include/mach/cvmx-helper.h | 20 + .../mach-octeon/include/mach/cvmx-ilk-defs.h | 2269 +++++++++++ .../mach-octeon/include/mach/cvmx-iob-defs.h | 1328 ++++++ .../mach-octeon/include/mach/cvmx-lbk-defs.h | 157 + .../mips/mach-octeon/include/mach/cvmx-mdio.h | 516 +++ .../mach-octeon/include/mach/cvmx-npei-defs.h | 3550 +++++++++++++++++ .../include/mach/cvmx-pcsxx-defs.h | 787 ++++ .../include/mach/cvmx-pki-cluster.h | 343 ++ arch/mips/mach-octeon/include/mach/cvmx-pko.h | 213 + .../include/mach/cvmx-pko3-resources.h | 36 + .../mips/mach-octeon/include/mach/cvmx-pko3.h | 1052 +++++ .../mach-octeon/include/mach/cvmx-range.h | 23 + .../mips/mach-octeon/include/mach/cvmx-regs.h | 100 +- .../mach-octeon/include/mach/cvmx-xcv-defs.h | 226 ++ .../mach-octeon/include/mach/octeon_eth.h | 54 +- board/Marvell/octeon_nic23/board.c | 87 +- configs/octeon_ebb7304_defconfig | 7 + configs/octeon_nic23_defconfig | 10 +- drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/octeon/Makefile | 6 + drivers/net/octeon/octeon_eth.c | 1060 +++++ drivers/net/octeon/octeon_mdio.c | 226 ++ include/configs/octeon_common.h | 2 +- include/configs/octeon_ebb7304.h | 2 + 77 files changed, 42315 insertions(+), 586 deletions(-) create mode 100644 arch/mips/mach-octeon/cvmx-agl.c create mode 100644 arch/mips/mach-octeon/cvmx-cmd-queue.c create mode 100644 arch/mips/mach-octeon/cvmx-fau-compat.c create mode 100644 arch/mips/mach-octeon/cvmx-fpa-resource.c create mode 100644 arch/mips/mach-octeon/cvmx-fpa.c create mode 100644 arch/mips/mach-octeon/cvmx-global-resources.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-agl.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-bgx.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-board.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-fpa.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-ilk.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-ipd.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-loop.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-npi.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-pki.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-pko.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-pko3.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-rgmii.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-sfp.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-sgmii.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-xaui.c create mode 100644 arch/mips/mach-octeon/cvmx-ilk.c create mode 100644 arch/mips/mach-octeon/cvmx-ipd.c create mode 100644 arch/mips/mach-octeon/cvmx-pki-resources.c create mode 100644 arch/mips/mach-octeon/cvmx-pki.c create mode 100644 arch/mips/mach-octeon/cvmx-pko-internal-ports-range.c create mode 100644 arch/mips/mach-octeon/cvmx-pko.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3-compat.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3-queue.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3-resources.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3.c create mode 100644 arch/mips/mach-octeon/cvmx-qlm-tables.c create mode 100644 arch/mips/mach-octeon/cvmx-range.c create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-agl.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-config.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-fau.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-ilk-defs.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-iob-defs.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-lbk-defs.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-mdio.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-npei-defs.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pcsxx-defs.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pki-cluster.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko3-resources.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko3.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-range.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-xcv-defs.h create mode 100644 drivers/net/octeon/Makefile create mode 100644 drivers/net/octeon/octeon_eth.c create mode 100644 drivers/net/octeon/octeon_mdio.c
Signature · 1 line
2.35.1
PATCH 6/52 mips: octeon: Add cvmx-pcsxx-defs.h header file
From: Aaron Williams <[email protected]>
Import cvmx-pcsxxx-defs.h header file from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- .../include/mach/cvmx-pcsxx-defs.h | 787 ++++++++++++++++++ 1 file changed, 787 insertions(+) create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pcsxx-defs.h
arch/mips/mach-octeon/include/mach/cvmx-pcsxx-defs.h new file +787 -0
@@ -0,0 +1,787 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Configuration and status register (CSR) type definitions for +* Octeon pcsxx. +*/ + +#ifndef __CVMX_PCSXX_DEFS_H__ +#define __CVMX_PCSXX_DEFS_H__ + +static inline u64 CVMX_PCSXX_10GBX_STATUS_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000828ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000828ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000828ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000828ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_BIST_STATUS_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000870ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000870ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000870ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000870ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_BIT_LOCK_STATUS_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000850ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000850ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000850ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000850ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_CONTROL1_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000800ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000800ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000800ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000800ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_CONTROL2_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000818ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000818ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000818ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000818ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_INT_EN_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000860ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000860ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000860ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000860ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_INT_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000858ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000858ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000858ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000858ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_LOG_ANL_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000868ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000868ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000868ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000868ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_MISC_CTL_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000848ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000848ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000848ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000848ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_RX_SYNC_STATES_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000838ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000838ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000838ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000838ull + (offset) *0x8000000ull ; +} + +#define CVMX_PCSXX_SERDES_CRDT_CNT_REG (offset) (0x00011800B0000880ull) +static inline u64 CVMX_PCSXX_SPD_ABIL_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000810ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000810ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000810ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000810ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_STATUS1_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000808ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000808ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000808ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000808ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_STATUS2_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000820ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000820ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000820ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000820ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_TX_RX_POLARITY_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000840ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000840ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000840ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000840ull + (offset) *0x8000000ull ; +} + +static inline u64 CVMX_PCSXX_TX_RX_STATES_REG (unsigned long offset) +{ +switch (cvmx_get_octeon_family ()) { +case OCTEON_CN66XX &OCTEON_FAMILY_MASK : +case OCTEON_CN61XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000830ull + (offset) *0x8000000ull ; +case OCTEON_CN70XX &OCTEON_FAMILY_MASK : +case OCTEON_CN63XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000830ull + (offset) *0x8000000ull ; +case OCTEON_CN68XX &OCTEON_FAMILY_MASK : +return 0x00011800B0000830ull + (offset) *0x1000000ull ; + } +return 0x00011800B0000830ull + (offset) *0x8000000ull ; +} + +/** +* cvmx_pcsx#_10gbx_status_reg +* +* PCSX_10GBX_STATUS_REG = 10gbx_status_reg +* +*/ +union cvmx_pcsxx_10gbx_status_reg { +u64 u64; +struct cvmx_pcsxx_10gbx_status_reg_s { +u64 reserved_13_63 :51 ; +u64 alignd :1 ; +u64 pattst :1 ; +u64 reserved_4_10 :7 ; +u64 l3sync :1 ; +u64 l2sync :1 ; +u64 l1sync :1 ; +u64 l0sync :1 ; + } s; +struct cvmx_pcsxx_10gbx_status_reg_s cn52xx; +struct cvmx_pcsxx_10gbx_status_reg_s cn52xxp1; +struct cvmx_pcsxx_10gbx_status_reg_s cn56xx; +struct cvmx_pcsxx_10gbx_status_reg_s cn56xxp1; +struct cvmx_pcsxx_10gbx_status_reg_s cn61xx; +struct cvmx_pcsxx_10gbx_status_reg_s cn63xx; +struct cvmx_pcsxx_10gbx_status_reg_s cn63xxp1; +struct cvmx_pcsxx_10gbx_status_reg_s cn66xx; +struct cvmx_pcsxx_10gbx_status_reg_s cn68xx; +struct cvmx_pcsxx_10gbx_status_reg_s cn68xxp1; +struct cvmx_pcsxx_10gbx_status_reg_s cn70xx; +struct cvmx_pcsxx_10gbx_status_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_10gbx_status_reg cvmx_pcsxx_10gbx_status_reg_t ; + +/** +* cvmx_pcsx#_bist_status_reg +* +* PCSX Bist Status Register +* +*/ +union cvmx_pcsxx_bist_status_reg { +u64 u64; +struct cvmx_pcsxx_bist_status_reg_s { +u64 reserved_1_63 :63 ; +u64 bist_status :1 ; + } s; +struct cvmx_pcsxx_bist_status_reg_s cn52xx; +struct cvmx_pcsxx_bist_status_reg_s cn52xxp1; +struct cvmx_pcsxx_bist_status_reg_s cn56xx; +struct cvmx_pcsxx_bist_status_reg_s cn56xxp1; +struct cvmx_pcsxx_bist_status_reg_s cn61xx; +struct cvmx_pcsxx_bist_status_reg_s cn63xx; +struct cvmx_pcsxx_bist_status_reg_s cn63xxp1; +struct cvmx_pcsxx_bist_status_reg_s cn66xx; +struct cvmx_pcsxx_bist_status_reg_s cn68xx; +struct cvmx_pcsxx_bist_status_reg_s cn68xxp1; +struct cvmx_pcsxx_bist_status_reg_s cn70xx; +struct cvmx_pcsxx_bist_status_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_bist_status_reg cvmx_pcsxx_bist_status_reg_t ; + +/** +* cvmx_pcsx#_bit_lock_status_reg +* +* PCSX Bit Lock Status Register +* +*/ +union cvmx_pcsxx_bit_lock_status_reg { +u64 u64; +struct cvmx_pcsxx_bit_lock_status_reg_s { +u64 reserved_4_63 :60 ; +u64 bitlck3 :1 ; +u64 bitlck2 :1 ; +u64 bitlck1 :1 ; +u64 bitlck0 :1 ; + } s; +struct cvmx_pcsxx_bit_lock_status_reg_s cn52xx; +struct cvmx_pcsxx_bit_lock_status_reg_s cn52xxp1; +struct cvmx_pcsxx_bit_lock_status_reg_s cn56xx; +struct cvmx_pcsxx_bit_lock_status_reg_s cn56xxp1; +struct cvmx_pcsxx_bit_lock_status_reg_s cn61xx; +struct cvmx_pcsxx_bit_lock_status_reg_s cn63xx; +struct cvmx_pcsxx_bit_lock_status_reg_s cn63xxp1; +struct cvmx_pcsxx_bit_lock_status_reg_s cn66xx; +struct cvmx_pcsxx_bit_lock_status_reg_s cn68xx; +struct cvmx_pcsxx_bit_lock_status_reg_s cn68xxp1; +struct cvmx_pcsxx_bit_lock_status_reg_s cn70xx; +struct cvmx_pcsxx_bit_lock_status_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_bit_lock_status_reg cvmx_pcsxx_bit_lock_status_reg_t ; + +/** +* cvmx_pcsx#_control1_reg +* +* NOTE: Logic Analyzer is enabled with LA_EN for the specified PCS lane only. +* PKT_SZ is effective only when LA_EN=1 +* For normal operation(sgmii or 1000Base-X), this bit must be 0. +* See pcsx.csr for xaui logic analyzer mode. +* For full description see document at .../rtl/pcs/readme_logic_analyzer.txt +* +* +* PCSX regs follow IEEE Std 802.3-2005, Section: 45.2.3 +* +* +* PCSX_CONTROL1_REG = Control Register1 +*/ +union cvmx_pcsxx_control1_reg { +u64 u64; +struct cvmx_pcsxx_control1_reg_s { +u64 reserved_16_63 :48 ; +u64 reset :1 ; +u64 loopbck1 :1 ; +u64 spdsel1 :1 ; +u64 reserved_12_12 :1 ; +u64 lo_pwr :1 ; +u64 reserved_7_10 :4 ; +u64 spdsel0 :1 ; +u64 spd :4 ; +u64 reserved_0_1 :2 ; + } s; +struct cvmx_pcsxx_control1_reg_s cn52xx; +struct cvmx_pcsxx_control1_reg_s cn52xxp1; +struct cvmx_pcsxx_control1_reg_s cn56xx; +struct cvmx_pcsxx_control1_reg_s cn56xxp1; +struct cvmx_pcsxx_control1_reg_s cn61xx; +struct cvmx_pcsxx_control1_reg_s cn63xx; +struct cvmx_pcsxx_control1_reg_s cn63xxp1; +struct cvmx_pcsxx_control1_reg_s cn66xx; +struct cvmx_pcsxx_control1_reg_s cn68xx; +struct cvmx_pcsxx_control1_reg_s cn68xxp1; +struct cvmx_pcsxx_control1_reg_s cn70xx; +struct cvmx_pcsxx_control1_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_control1_reg cvmx_pcsxx_control1_reg_t ; + +/** +* cvmx_pcsx#_control2_reg +* +* PCSX_CONTROL2_REG = Control Register2 +* +*/ +union cvmx_pcsxx_control2_reg { +u64 u64; +struct cvmx_pcsxx_control2_reg_s { +u64 reserved_2_63 :62 ; +u64 type :2 ; + } s; +struct cvmx_pcsxx_control2_reg_s cn52xx; +struct cvmx_pcsxx_control2_reg_s cn52xxp1; +struct cvmx_pcsxx_control2_reg_s cn56xx; +struct cvmx_pcsxx_control2_reg_s cn56xxp1; +struct cvmx_pcsxx_control2_reg_s cn61xx; +struct cvmx_pcsxx_control2_reg_s cn63xx; +struct cvmx_pcsxx_control2_reg_s cn63xxp1; +struct cvmx_pcsxx_control2_reg_s cn66xx; +struct cvmx_pcsxx_control2_reg_s cn68xx; +struct cvmx_pcsxx_control2_reg_s cn68xxp1; +struct cvmx_pcsxx_control2_reg_s cn70xx; +struct cvmx_pcsxx_control2_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_control2_reg cvmx_pcsxx_control2_reg_t ; + +/** +* cvmx_pcsx#_int_en_reg +* +* PCSX Interrupt Enable Register +* +*/ +union cvmx_pcsxx_int_en_reg { +u64 u64; +struct cvmx_pcsxx_int_en_reg_s { +u64 reserved_7_63 :57 ; +u64 dbg_sync_en :1 ; +u64 algnlos_en :1 ; +u64 synlos_en :1 ; +u64 bitlckls_en :1 ; +u64 rxsynbad_en :1 ; +u64 rxbad_en :1 ; +u64 txflt_en :1 ; + } s; +struct cvmx_pcsxx_int_en_reg_cn52xx { +u64 reserved_6_63 :58 ; +u64 algnlos_en :1 ; +u64 synlos_en :1 ; +u64 bitlckls_en :1 ; +u64 rxsynbad_en :1 ; +u64 rxbad_en :1 ; +u64 txflt_en :1 ; + } cn52xx; +struct cvmx_pcsxx_int_en_reg_cn52xx cn52xxp1; +struct cvmx_pcsxx_int_en_reg_cn52xx cn56xx; +struct cvmx_pcsxx_int_en_reg_cn52xx cn56xxp1; +struct cvmx_pcsxx_int_en_reg_s cn61xx; +struct cvmx_pcsxx_int_en_reg_s cn63xx; +struct cvmx_pcsxx_int_en_reg_s cn63xxp1; +struct cvmx_pcsxx_int_en_reg_s cn66xx; +struct cvmx_pcsxx_int_en_reg_s cn68xx; +struct cvmx_pcsxx_int_en_reg_s cn68xxp1; +struct cvmx_pcsxx_int_en_reg_s cn70xx; +struct cvmx_pcsxx_int_en_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_int_en_reg cvmx_pcsxx_int_en_reg_t ; + +/** +* cvmx_pcsx#_int_reg +* +* PCSX Interrupt Register +* Note: DBG_SYNC is a edge triggered interrupt. When set it indicates PCS Synchronization state +* machine in +* Figure 48-7 state diagram in IEEE Std 802.3-2005 changes state SYNC_ACQUIRED_1 to +* SYNC_ACQUIRED_2 +* indicating an invalid code group was received on one of the 4 receive lanes. +* This interrupt should be always disabled and used only for link problem debugging help. +*/ +union cvmx_pcsxx_int_reg { +u64 u64; +struct cvmx_pcsxx_int_reg_s { +u64 reserved_7_63 :57 ; +u64 dbg_sync :1 ; +u64 algnlos :1 ; +u64 synlos :1 ; +u64 bitlckls :1 ; +u64 rxsynbad :1 ; +u64 rxbad :1 ; +u64 txflt :1 ; + } s; +struct cvmx_pcsxx_int_reg_cn52xx { +u64 reserved_6_63 :58 ; +u64 algnlos :1 ; +u64 synlos :1 ; +u64 bitlckls :1 ; +u64 rxsynbad :1 ; +u64 rxbad :1 ; +u64 txflt :1 ; + } cn52xx; +struct cvmx_pcsxx_int_reg_cn52xx cn52xxp1; +struct cvmx_pcsxx_int_reg_cn52xx cn56xx; +struct cvmx_pcsxx_int_reg_cn52xx cn56xxp1; +struct cvmx_pcsxx_int_reg_s cn61xx; +struct cvmx_pcsxx_int_reg_s cn63xx; +struct cvmx_pcsxx_int_reg_s cn63xxp1; +struct cvmx_pcsxx_int_reg_s cn66xx; +struct cvmx_pcsxx_int_reg_s cn68xx; +struct cvmx_pcsxx_int_reg_s cn68xxp1; +struct cvmx_pcsxx_int_reg_s cn70xx; +struct cvmx_pcsxx_int_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_int_reg cvmx_pcsxx_int_reg_t ; + +/** +* cvmx_pcsx#_log_anl_reg +* +* PCSX Logic Analyzer Register +* NOTE: Logic Analyzer is enabled with LA_EN for xaui only. PKT_SZ is effective only when +* LA_EN=1 +* For normal operation(xaui), this bit must be 0. The dropped lane is used to send rxc[3:0]. +* See pcs.csr for sgmii/1000Base-X logic analyzer mode. +* For full description see document at .../rtl/pcs/readme_logic_analyzer.txt +*/ +union cvmx_pcsxx_log_anl_reg { +u64 u64; +struct cvmx_pcsxx_log_anl_reg_s { +u64 reserved_7_63 :57 ; +u64 enc_mode :1 ; +u64 drop_ln :2 ; +u64 lafifovfl :1 ; +u64 la_en :1 ; +u64 pkt_sz :2 ; + } s; +struct cvmx_pcsxx_log_anl_reg_s cn52xx; +struct cvmx_pcsxx_log_anl_reg_s cn52xxp1; +struct cvmx_pcsxx_log_anl_reg_s cn56xx; +struct cvmx_pcsxx_log_anl_reg_s cn56xxp1; +struct cvmx_pcsxx_log_anl_reg_s cn61xx; +struct cvmx_pcsxx_log_anl_reg_s cn63xx; +struct cvmx_pcsxx_log_anl_reg_s cn63xxp1; +struct cvmx_pcsxx_log_anl_reg_s cn66xx; +struct cvmx_pcsxx_log_anl_reg_s cn68xx; +struct cvmx_pcsxx_log_anl_reg_s cn68xxp1; +struct cvmx_pcsxx_log_anl_reg_s cn70xx; +struct cvmx_pcsxx_log_anl_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_log_anl_reg cvmx_pcsxx_log_anl_reg_t ; + +/** +* cvmx_pcsx#_misc_ctl_reg +* +* PCSX Misc Control Register +* LN_SWAP for XAUI is to simplify interconnection layout between devices +*/ +union cvmx_pcsxx_misc_ctl_reg { +u64 u64; +struct cvmx_pcsxx_misc_ctl_reg_s { +u64 reserved_4_63 :60 ; +u64 tx_swap :1 ; +u64 rx_swap :1 ; +u64 xaui :1 ; +u64 gmxeno :1 ; + } s; +struct cvmx_pcsxx_misc_ctl_reg_s cn52xx; +struct cvmx_pcsxx_misc_ctl_reg_s cn52xxp1; +struct cvmx_pcsxx_misc_ctl_reg_s cn56xx; +struct cvmx_pcsxx_misc_ctl_reg_s cn56xxp1; +struct cvmx_pcsxx_misc_ctl_reg_s cn61xx; +struct cvmx_pcsxx_misc_ctl_reg_s cn63xx; +struct cvmx_pcsxx_misc_ctl_reg_s cn63xxp1; +struct cvmx_pcsxx_misc_ctl_reg_s cn66xx; +struct cvmx_pcsxx_misc_ctl_reg_s cn68xx; +struct cvmx_pcsxx_misc_ctl_reg_s cn68xxp1; +struct cvmx_pcsxx_misc_ctl_reg_s cn70xx; +struct cvmx_pcsxx_misc_ctl_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_misc_ctl_reg cvmx_pcsxx_misc_ctl_reg_t ; + +/** +* cvmx_pcsx#_rx_sync_states_reg +* +* PCSX_RX_SYNC_STATES_REG = Receive Sync States Register +* +*/ +union cvmx_pcsxx_rx_sync_states_reg { +u64 u64; +struct cvmx_pcsxx_rx_sync_states_reg_s { +u64 reserved_16_63 :48 ; +u64 sync3st :4 ; +u64 sync2st :4 ; +u64 sync1st :4 ; +u64 sync0st :4 ; + } s; +struct cvmx_pcsxx_rx_sync_states_reg_s cn52xx; +struct cvmx_pcsxx_rx_sync_states_reg_s cn52xxp1; +struct cvmx_pcsxx_rx_sync_states_reg_s cn56xx; +struct cvmx_pcsxx_rx_sync_states_reg_s cn56xxp1; +struct cvmx_pcsxx_rx_sync_states_reg_s cn61xx; +struct cvmx_pcsxx_rx_sync_states_reg_s cn63xx; +struct cvmx_pcsxx_rx_sync_states_reg_s cn63xxp1; +struct cvmx_pcsxx_rx_sync_states_reg_s cn66xx; +struct cvmx_pcsxx_rx_sync_states_reg_s cn68xx; +struct cvmx_pcsxx_rx_sync_states_reg_s cn68xxp1; +struct cvmx_pcsxx_rx_sync_states_reg_s cn70xx; +struct cvmx_pcsxx_rx_sync_states_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_rx_sync_states_reg cvmx_pcsxx_rx_sync_states_reg_t ; + +/** +* cvmx_pcsx#_serdes_crdt_cnt_reg +* +* PCSX SERDES Credit Count +* +*/ +union cvmx_pcsxx_serdes_crdt_cnt_reg { +u64 u64; +struct cvmx_pcsxx_serdes_crdt_cnt_reg_s { +u64 reserved_5_63 :59 ; +u64 cnt :5 ; + } s; +struct cvmx_pcsxx_serdes_crdt_cnt_reg_s cn70xx; +struct cvmx_pcsxx_serdes_crdt_cnt_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_serdes_crdt_cnt_reg cvmx_pcsxx_serdes_crdt_cnt_reg_t ; + +/** +* cvmx_pcsx#_spd_abil_reg +* +* PCSX_SPD_ABIL_REG = Speed ability register +* +*/ +union cvmx_pcsxx_spd_abil_reg { +u64 u64; +struct cvmx_pcsxx_spd_abil_reg_s { +u64 reserved_2_63 :62 ; +u64 tenpasst :1 ; +u64 tengb :1 ; + } s; +struct cvmx_pcsxx_spd_abil_reg_s cn52xx; +struct cvmx_pcsxx_spd_abil_reg_s cn52xxp1; +struct cvmx_pcsxx_spd_abil_reg_s cn56xx; +struct cvmx_pcsxx_spd_abil_reg_s cn56xxp1; +struct cvmx_pcsxx_spd_abil_reg_s cn61xx; +struct cvmx_pcsxx_spd_abil_reg_s cn63xx; +struct cvmx_pcsxx_spd_abil_reg_s cn63xxp1; +struct cvmx_pcsxx_spd_abil_reg_s cn66xx; +struct cvmx_pcsxx_spd_abil_reg_s cn68xx; +struct cvmx_pcsxx_spd_abil_reg_s cn68xxp1; +struct cvmx_pcsxx_spd_abil_reg_s cn70xx; +struct cvmx_pcsxx_spd_abil_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_spd_abil_reg cvmx_pcsxx_spd_abil_reg_t ; + +/** +* cvmx_pcsx#_status1_reg +* +* PCSX_STATUS1_REG = Status Register1 +* +*/ +union cvmx_pcsxx_status1_reg { +u64 u64; +struct cvmx_pcsxx_status1_reg_s { +u64 reserved_8_63 :56 ; +u64 flt :1 ; +u64 reserved_3_6 :4 ; +u64 rcv_lnk :1 ; +u64 lpable :1 ; +u64 reserved_0_0 :1 ; + } s; +struct cvmx_pcsxx_status1_reg_s cn52xx; +struct cvmx_pcsxx_status1_reg_s cn52xxp1; +struct cvmx_pcsxx_status1_reg_s cn56xx; +struct cvmx_pcsxx_status1_reg_s cn56xxp1; +struct cvmx_pcsxx_status1_reg_s cn61xx; +struct cvmx_pcsxx_status1_reg_s cn63xx; +struct cvmx_pcsxx_status1_reg_s cn63xxp1; +struct cvmx_pcsxx_status1_reg_s cn66xx; +struct cvmx_pcsxx_status1_reg_s cn68xx; +struct cvmx_pcsxx_status1_reg_s cn68xxp1; +struct cvmx_pcsxx_status1_reg_s cn70xx; +struct cvmx_pcsxx_status1_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_status1_reg cvmx_pcsxx_status1_reg_t ; + +/** +* cvmx_pcsx#_status2_reg +* +* PCSX_STATUS2_REG = Status Register2 +* +*/ +union cvmx_pcsxx_status2_reg { +u64 u64; +struct cvmx_pcsxx_status2_reg_s { +u64 reserved_16_63 :48 ; +u64 dev :2 ; +u64 reserved_12_13 :2 ; +u64 xmtflt :1 ; +u64 rcvflt :1 ; +u64 reserved_3_9 :7 ; +u64 tengb_w :1 ; +u64 tengb_x :1 ; +u64 tengb_r :1 ; + } s; +struct cvmx_pcsxx_status2_reg_s cn52xx; +struct cvmx_pcsxx_status2_reg_s cn52xxp1; +struct cvmx_pcsxx_status2_reg_s cn56xx; +struct cvmx_pcsxx_status2_reg_s cn56xxp1; +struct cvmx_pcsxx_status2_reg_s cn61xx; +struct cvmx_pcsxx_status2_reg_s cn63xx; +struct cvmx_pcsxx_status2_reg_s cn63xxp1; +struct cvmx_pcsxx_status2_reg_s cn66xx; +struct cvmx_pcsxx_status2_reg_s cn68xx; +struct cvmx_pcsxx_status2_reg_s cn68xxp1; +struct cvmx_pcsxx_status2_reg_s cn70xx; +struct cvmx_pcsxx_status2_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_status2_reg cvmx_pcsxx_status2_reg_t ; + +/** +* cvmx_pcsx#_tx_rx_polarity_reg +* +* RX lane polarity vector [3:0] = XOR_RXPLRT<9:6> ^ [4[RXPLRT<1>]]; +* TX lane polarity vector [3:0] = XOR_TXPLRT<5:2> ^ [4[TXPLRT<0>]]; +* In short keep <1:0> to 2'b00, and use <5:2> and <9:6> fields to define per lane polarities +*/ +union cvmx_pcsxx_tx_rx_polarity_reg { +u64 u64; +struct cvmx_pcsxx_tx_rx_polarity_reg_s { +u64 reserved_10_63 :54 ; +u64 xor_rxplrt :4 ; +u64 xor_txplrt :4 ; +u64 rxplrt :1 ; +u64 txplrt :1 ; + } s; +struct cvmx_pcsxx_tx_rx_polarity_reg_s cn52xx; +struct cvmx_pcsxx_tx_rx_polarity_reg_cn52xxp1 { +u64 reserved_2_63 :62 ; +u64 rxplrt :1 ; +u64 txplrt :1 ; + } cn52xxp1; +struct cvmx_pcsxx_tx_rx_polarity_reg_s cn56xx; +struct cvmx_pcsxx_tx_rx_polarity_reg_cn52xxp1 cn56xxp1; +struct cvmx_pcsxx_tx_rx_polarity_reg_s cn61xx; +struct cvmx_pcsxx_tx_rx_polarity_reg_s cn63xx; +struct cvmx_pcsxx_tx_rx_polarity_reg_s cn63xxp1; +struct cvmx_pcsxx_tx_rx_polarity_reg_s cn66xx; +struct cvmx_pcsxx_tx_rx_polarity_reg_s cn68xx; +struct cvmx_pcsxx_tx_rx_polarity_reg_s cn68xxp1; +struct cvmx_pcsxx_tx_rx_polarity_reg_s cn70xx; +struct cvmx_pcsxx_tx_rx_polarity_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_tx_rx_polarity_reg cvmx_pcsxx_tx_rx_polarity_reg_t ; + +/** +* cvmx_pcsx#_tx_rx_states_reg +* +* PCSX_TX_RX_STATES_REG = Transmit Receive States Register +* +*/ +union cvmx_pcsxx_tx_rx_states_reg { +u64 u64; +struct cvmx_pcsxx_tx_rx_states_reg_s { +u64 reserved_14_63 :50 ; +u64 term_err :1 ; +u64 syn3bad :1 ; +u64 syn2bad :1 ; +u64 syn1bad :1 ; +u64 syn0bad :1 ; +u64 rxbad :1 ; +u64 algn_st :3 ; +u64 rx_st :2 ; +u64 tx_st :3 ; + } s; +struct cvmx_pcsxx_tx_rx_states_reg_s cn52xx; +struct cvmx_pcsxx_tx_rx_states_reg_cn52xxp1 { +u64 reserved_13_63 :51 ; +u64 syn3bad :1 ; +u64 syn2bad :1 ; +u64 syn1bad :1 ; +u64 syn0bad :1 ; +u64 rxbad :1 ; +u64 algn_st :3 ; +u64 rx_st :2 ; +u64 tx_st :3 ; + } cn52xxp1; +struct cvmx_pcsxx_tx_rx_states_reg_s cn56xx; +struct cvmx_pcsxx_tx_rx_states_reg_cn52xxp1 cn56xxp1; +struct cvmx_pcsxx_tx_rx_states_reg_s cn61xx; +struct cvmx_pcsxx_tx_rx_states_reg_s cn63xx; +struct cvmx_pcsxx_tx_rx_states_reg_s cn63xxp1; +struct cvmx_pcsxx_tx_rx_states_reg_s cn66xx; +struct cvmx_pcsxx_tx_rx_states_reg_s cn68xx; +struct cvmx_pcsxx_tx_rx_states_reg_s cn68xxp1; +struct cvmx_pcsxx_tx_rx_states_reg_s cn70xx; +struct cvmx_pcsxx_tx_rx_states_reg_s cn70xxp1; +}; + +typedef union cvmx_pcsxx_tx_rx_states_reg cvmx_pcsxx_tx_rx_states_reg_t ; + +#endif
Signature · 1 line
2.35.1
PATCH 8/52 mips: octeon: Misc changes to existing headers for upcoming eth support
In reply to Stefan RoeseThis patch includes misc changes to already present Octeon MIPS header files, which are necessary for the upcoming ethernet support.
The changes are mostly:
- DM GPIO & I2C infrastructure
- Coding style cleanup while reworking the headers
--- .../mach-octeon/include/mach/cvmx-bootmem.h | 3 +- arch/mips/mach-octeon/include/mach/cvmx-fpa.h | 3 +- .../mips/mach-octeon/include/mach/cvmx-fpa3.h | 37 ------- .../include/mach/cvmx-helper-board.h | 6 +- .../include/mach/cvmx-helper-fdt.h | 40 +++---- .../include/mach/cvmx-helper-pko.h | 2 +- .../mach-octeon/include/mach/cvmx-helper.h | 20 ++++ .../mips/mach-octeon/include/mach/cvmx-regs.h | 100 ++++++++++++++++-- .../mach-octeon/include/mach/octeon_eth.h | 54 +++++----- 9 files changed, 166 insertions(+), 99 deletions(-)
arch/mips/mach-octeon/include/mach/cvmx-bootmem.h +2 -1
@@ -26,7 +26,8 @@/* Real physical addresses of memory regions */ #define OCTEON_DDR0_BASE (0x0ULL) -#define OCTEON_DDR0_SIZE (0x010000000ULL) +/* Use 16MiB here, as 256 leads to overwriting U-Boot reloc space */ +#define OCTEON_DDR0_SIZE (0x001000000ULL)#define OCTEON_DDR1_BASE ((OCTEON_IS_OCTEON2() || OCTEON_IS_OCTEON3()) \ ? 0x20000000ULL : 0x410000000ULL)#define OCTEON_DDR1_SIZE (0x010000000ULL)
arch/mips/mach-octeon/include/mach/cvmx-fpa.h +2 -1
@@ -104,8 +104,9 @@ static inline void *cvmx_fpa_alloc(u64 pool)/* FPA3 is handled differently */ if ((octeon_has_feature (OCTEON_FEATURE_FPA3 ))) {return cvmx_fpa3_alloc (cvmx_fpa1_pool_to_fpa3_aura (pool)); - }else + }else {return cvmx_fpa1_alloc (pool); + } }/**
arch/mips/mach-octeon/include/mach/cvmx-fpa3.h +0 -37
@@ -526,41 +526,4 @@ const char *cvmx_fpa3_get_pool_name(cvmx_fpa3_pool_t pool);int cvmx_fpa3_get_pool_buf_size (cvmx_fpa3_pool_t pool);const char *cvmx_fpa3_get_aura_name (cvmx_fpa3_gaura_t aura); -/* FIXME: Need a different macro for stage2 of u-boot */ - -static inline void cvmx_fpa3_stage2_init (int aura,int pool,u64 stack_paddr,int stacklen, -int buffer_sz,int buf_cnt) -{ -cvmx_fpa_poolx_cfg_t pool_cfg; - -/* Configure pool stack */ -cvmx_write_csr_node (0 ,CVMX_FPA_POOLX_STACK_BASE (pool), stack_paddr); -cvmx_write_csr_node (0 ,CVMX_FPA_POOLX_STACK_ADDR (pool), stack_paddr); -cvmx_write_csr_node (0 ,CVMX_FPA_POOLX_STACK_END (pool), stack_paddr + stacklen); - -/* Configure pool with buffer size */ - pool_cfg.u64 =0 ; - pool_cfg.cn78xx.nat_align =1 ; - pool_cfg.cn78xx.buf_size = buffer_sz >>7 ; - pool_cfg.cn78xx.l_type =0x2 ; - pool_cfg.cn78xx.ena =0 ; -cvmx_write_csr_node (0 ,CVMX_FPA_POOLX_CFG (pool), pool_cfg.u64); -/* Reset pool before starting */ - pool_cfg.cn78xx.ena =1 ; -cvmx_write_csr_node (0 ,CVMX_FPA_POOLX_CFG (pool), pool_cfg.u64); - -cvmx_write_csr_node (0 ,CVMX_FPA_AURAX_CFG (aura),0 ); -cvmx_write_csr_node (0 ,CVMX_FPA_AURAX_CNT_ADD (aura), buf_cnt); -cvmx_write_csr_node (0 ,CVMX_FPA_AURAX_POOL (aura), (u64 )pool); -} - -static inline void cvmx_fpa3_stage2_disable (int aura,int pool) -{ -cvmx_write_csr_node (0 ,CVMX_FPA_AURAX_POOL (aura),0 ); -cvmx_write_csr_node (0 ,CVMX_FPA_POOLX_CFG (pool),0 ); -cvmx_write_csr_node (0 ,CVMX_FPA_POOLX_STACK_BASE (pool),0 ); -cvmx_write_csr_node (0 ,CVMX_FPA_POOLX_STACK_ADDR (pool),0 ); -cvmx_write_csr_node (0 ,CVMX_FPA_POOLX_STACK_END (pool),0 ); -} -#endif /* __CVMX_FPA3_H__ */
arch/mips/mach-octeon/include/mach/cvmx-helper-board.h +4 -2
@@ -9,6 +9,8 @@ #ifndef __CVMX_HELPER_BOARD_H__ #define __CVMX_HELPER_BOARD_H__ +#include <asm-generic/gpio.h> + #define CVMX_VSC7224_NAME_LEN 16 typedef enum {
@@ -185,8 +187,8 @@ struct cvmx_vsc7224 {struct cvmx_fdt_i2c_bus_info *i2c_bus;/** Address of VSC7224 on i2c bus */ int i2c_addr; -struct cvmx_fdt_gpio_info *los_gpio;/** LoS GPIO pin */ -struct cvmx_fdt_gpio_info *reset_gpio;/** Reset GPIO pin */ +struct gpio_desc los_gpio;/** LoS GPIO pin */ +struct gpio_desc reset_gpio;/** Reset GPIO pin */ int of_offset;/** Offset in device tree */ };
arch/mips/mach-octeon/include/mach/cvmx-helper-fdt.h +20 -20
@@ -14,10 +14,13 @@#include <fdtdec.h> #include <time.h> #include <asm/global_data.h> +#include <asm-generic/gpio.h> +#include <dm/device.h> #include <linux/libfdt.h> #include <mach/cvmx-helper-sfp.h> +/* todo: this is deprecated and some of it can be removed at some time */ enum cvmx_i2c_bus_type {CVMX_I2C_BUS_OCTEON ,CVMX_I2C_MUX_PCA9540 ,
@@ -55,6 +58,8 @@ struct cvmx_fdt_i2c_bus_info {u8 enable_bit;/** True if mux, false if switch */ bool is_mux; + +struct udevice *i2c_bus; };/**
@@ -85,22 +90,24 @@ struct cvmx_fdt_sfp_info {bool is_qsfp;/** True if EEPROM data is valid */ bool valid; +/** SFP tx_disable GPIO descriptor */ -struct cvmx_fdt_gpio_info *tx_disable; +struct gpio_desc tx_disable;/** SFP mod_abs/QSFP mod_prs GPIO descriptor */ -struct cvmx_fdt_gpio_info *mod_abs; +struct gpio_desc mod_abs;/** SFP tx_error GPIO descriptor */ -struct cvmx_fdt_gpio_info *tx_error; +struct gpio_desc tx_error;/** SFP rx_los GPIO discriptor */ -struct cvmx_fdt_gpio_info *rx_los; +struct gpio_desc rx_los;/** QSFP select GPIO descriptor */ -struct cvmx_fdt_gpio_info *select; +struct gpio_desc select;/** QSFP reset GPIO descriptor */ -struct cvmx_fdt_gpio_info *reset; +struct gpio_desc reset;/** QSFP interrupt GPIO descriptor */ -struct cvmx_fdt_gpio_info *interrupt; +struct gpio_desc interrupt;/** QSFP lp_mode GPIO descriptor */ -struct cvmx_fdt_gpio_info *lp_mode; +struct gpio_desc lp_mode; +/** Last mod_abs value */ int last_mod_abs;/** Last rx_los value */
@@ -146,6 +153,9 @@ struct cvmx_fdt_sfp_info {int cvmx_fdt_lookup_phandles (const void *fdt_addr,int node,const char *prop_name,int *lenp,int *nodes); +int cvmx_ofnode_lookup_phandles (ofnode node,const char *prop_name, +int *lenp,ofnode *nodes); +/** * Helper to return the address property *
@@ -341,8 +351,7 @@ int cvmx_fdt_node_offset_by_compatible_list(const void *fdt_addr, int startoffse* Given the parent offset of an i2c device build up a list describing the bus * which can contain i2c muxes and switches. * -* @param[in] fdt_addr address of device tree -* @param of_offset Offset of the parent node of a GPIO device in +* @param[in] node ofnode of the parent node of a GPIO device in * the device tree. * * Return: pointer to list of i2c devices starting from the root which
@@ -351,7 +360,7 @@ int cvmx_fdt_node_offset_by_compatible_list(const void *fdt_addr, int startoffse* * @see cvmx_fdt_free_i2c_bus() */ -struct cvmx_fdt_i2c_bus_info *cvmx_fdt_get_i2c_bus (const void *fdt_addr,int of_offset); +struct cvmx_fdt_i2c_bus_info *cvmx_ofnode_get_i2c_bus (ofnode node);/** * Return the Octeon bus number for a bus descriptor
@@ -496,15 +505,6 @@ int __cvmx_fdt_parse_vsc7224(const void *fdt_addr);*/ int __cvmx_fdt_parse_avsp5410 (const void *fdt_addr); -/** -* Parse SFP information from device tree -* -* @param[in] fdt_addr Address of flat device tree -* -* Return: pointer to sfp info or NULL if error -*/ -struct cvmx_fdt_sfp_info *cvmx_helper_fdt_parse_sfp_info (const void *fdt_addr,int of_offset); -/** * @INTERNAL * Parses either a CS4343 phy or a slice of the phy from the device tree
arch/mips/mach-octeon/include/mach/cvmx-helper-pko.h +1 -1
@@ -17,7 +17,7 @@* number. Users should set this pointer to a function before * calling any cvmx-helper operations. */ -void (*cvmx_override_pko_queue_priority)(int ipd_port,u8 *priorities); +extern void (*cvmx_override_pko_queue_priority)(int ipd_port,u8 *priorities);/** * Gets the fpa pool number of pko pool
arch/mips/mach-octeon/include/mach/cvmx-helper.h +20 -0
@@ -127,6 +127,26 @@ enum cvmx_pko_padding { CVMX_PKO_PADDING_60 = 1, }; +/** +* cvmx_override_iface_phy_mode(int interface, int index) is a function pointer. +* It is meant to allow customization of interfaces which do not have a PHY. +* +* @returns 0 if MAC decides TX_CONFIG_REG or 1 if PHY decides TX_CONFIG_REG. +* +* If this function pointer is NULL then it defaults to the MAC. +*/ +extern int (*cvmx_override_iface_phy_mode) (int interface,int index); + +/** +* cvmx_override_ipd_port_setup(int ipd_port) is a function +* pointer. It is meant to allow customization of the IPD port/port kind +* setup before packet input/output comes online. It is called +* after cvmx-helper does the default IPD configuration, but +* before IPD is enabled. Users should set this pointer to a +* function before calling any cvmx-helper operations. +*/ +extern void (*cvmx_override_ipd_port_setup) (int ipd_port); +/** * This function enables the IPD and also enables the packet interfaces. * The packet interfaces (RGMII and SPI) must be enabled after the
arch/mips/mach-octeon/include/mach/cvmx-regs.h +92 -8
147 lines not on this page · raw message
arch/mips/mach-octeon/include/mach/octeon_eth.h +25 -29
93 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH 7/52 mips: octeon: Add cvmx-xcv-defs.h header file
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-xcv-defs.h header file from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- .../mach-octeon/include/mach/cvmx-xcv-defs.h | 226 ++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-xcv-defs.h
arch/mips/mach-octeon/include/mach/cvmx-xcv-defs.h new file +226 -0
@@ -0,0 +1,226 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Configuration and status register (CSR) type definitions for +* Octeon xcv. +*/ + +#ifndef __CVMX_XCV_DEFS_H__ +#define __CVMX_XCV_DEFS_H__ + +#define CVMX_XCV_BATCH_CRD_RET (0x00011800DB000100ull) +#define CVMX_XCV_COMP_CTL (0x00011800DB000020ull) +#define CVMX_XCV_CTL (0x00011800DB000030ull) +#define CVMX_XCV_DLL_CTL (0x00011800DB000010ull) +#define CVMX_XCV_ECO (0x00011800DB000200ull) +#define CVMX_XCV_INBND_STATUS (0x00011800DB000080ull) +#define CVMX_XCV_INT (0x00011800DB000040ull) +#define CVMX_XCV_RESET (0x00011800DB000000ull) + +/** +* cvmx_xcv_batch_crd_ret +*/ +union cvmx_xcv_batch_crd_ret { +u64 u64; +struct cvmx_xcv_batch_crd_ret_s { +u64 reserved_1_63 :63 ; +u64 crd_ret :1 ; + } s; +struct cvmx_xcv_batch_crd_ret_s cn73xx; +}; + +typedef union cvmx_xcv_batch_crd_ret cvmx_xcv_batch_crd_ret_t ; + +/** +* cvmx_xcv_comp_ctl +* +* This register controls programmable compensation. +* +*/ +union cvmx_xcv_comp_ctl { +u64 u64; +struct cvmx_xcv_comp_ctl_s { +u64 drv_byp :1 ; +u64 reserved_61_62 :2 ; +u64 cmp_pctl :5 ; +u64 reserved_53_55 :3 ; +u64 cmp_nctl :5 ; +u64 reserved_45_47 :3 ; +u64 drv_pctl :5 ; +u64 reserved_37_39 :3 ; +u64 drv_nctl :5 ; +u64 reserved_31_31 :1 ; +u64 pctl_lock :1 ; +u64 pctl_sat :1 ; +u64 reserved_28_28 :1 ; +u64 nctl_lock :1 ; +u64 reserved_1_26 :26 ; +u64 nctl_sat :1 ; + } s; +struct cvmx_xcv_comp_ctl_s cn73xx; +}; + +typedef union cvmx_xcv_comp_ctl cvmx_xcv_comp_ctl_t ; + +/** +* cvmx_xcv_ctl +* +* This register contains the status control bits. +* +*/ +union cvmx_xcv_ctl { +u64 u64; +struct cvmx_xcv_ctl_s { +u64 reserved_4_63 :60 ; +u64 lpbk_ext :1 ; +u64 lpbk_int :1 ; +u64 speed :2 ; + } s; +struct cvmx_xcv_ctl_s cn73xx; +}; + +typedef union cvmx_xcv_ctl cvmx_xcv_ctl_t ; + +/** +* cvmx_xcv_dll_ctl +* +* The RGMII timing specification requires that devices transmit clock and +* data synchronously. The specification requires external sources (namely +* the PC board trace routes) to introduce the appropriate 1.5 to 2.0 ns of +* delay. +* +* To eliminate the need for the PC board delays, the RGMII interface has optional +* on-board DLLs for both transmit and receive. For correct operation, at most one +* of the transmitter, board, or receiver involved in an RGMII link should +* introduce delay. By default/reset, the RGMII receivers delay the received clock, +* and the RGMII transmitters do not delay the transmitted clock. Whether this +* default works as-is with a given link partner depends on the behavior of the +* link partner and the PC board. +* +* These are the possible modes of RGMII receive operation: +* +* * XCV_DLL_CTL[CLKRX_BYP] = 0 (reset value) - The RGMII +* receive interface introduces clock delay using its internal DLL. +* This mode is appropriate if neither the remote +* transmitter nor the PC board delays the clock. +* +* * XCV_DLL_CTL[CLKRX_BYP] = 1, [CLKRX_SET] = 0x0 - The +* RGMII receive interface introduces no clock delay. This mode +* is appropriate if either the remote transmitter or the PC board +* delays the clock. +* +* These are the possible modes of RGMII transmit operation: +* +* * XCV_DLL_CTL[CLKTX_BYP] = 1, [CLKTX_SET] = 0x0 (reset value) - +* The RGMII transmit interface introduces no clock +* delay. This mode is appropriate is either the remote receiver +* or the PC board delays the clock. +* +* * XCV_DLL_CTL[CLKTX_BYP] = 0 - The RGMII transmit +* interface introduces clock delay using its internal DLL. +* This mode is appropriate if neither the remote receiver +* nor the PC board delays the clock. +*/ +union cvmx_xcv_dll_ctl { +u64 u64; +struct cvmx_xcv_dll_ctl_s { +u64 reserved_32_63 :32 ; +u64 lock :1 ; +u64 clk_set :7 ; +u64 clkrx_byp :1 ; +u64 clkrx_set :7 ; +u64 clktx_byp :1 ; +u64 clktx_set :7 ; +u64 reserved_2_7 :6 ; +u64 refclk_sel :2 ; + } s; +struct cvmx_xcv_dll_ctl_s cn73xx; +}; + +typedef union cvmx_xcv_dll_ctl cvmx_xcv_dll_ctl_t ; + +/** +* cvmx_xcv_eco +*/ +union cvmx_xcv_eco { +u64 u64; +struct cvmx_xcv_eco_s { +u64 reserved_16_63 :48 ; +u64 eco_rw :16 ; + } s; +struct cvmx_xcv_eco_s cn73xx; +}; + +typedef union cvmx_xcv_eco cvmx_xcv_eco_t ; + +/** +* cvmx_xcv_inbnd_status +* +* This register contains RGMII in-band status. +* +*/ +union cvmx_xcv_inbnd_status { +u64 u64; +struct cvmx_xcv_inbnd_status_s { +u64 reserved_4_63 :60 ; +u64 duplex :1 ; +u64 speed :2 ; +u64 link :1 ; + } s; +struct cvmx_xcv_inbnd_status_s cn73xx; +}; + +typedef union cvmx_xcv_inbnd_status cvmx_xcv_inbnd_status_t ; + +/** +* cvmx_xcv_int +* +* This register controls interrupts. +* +*/ +union cvmx_xcv_int { +u64 u64; +struct cvmx_xcv_int_s { +u64 reserved_7_63 :57 ; +u64 tx_ovrflw :1 ; +u64 tx_undflw :1 ; +u64 incomp_byte :1 ; +u64 duplex :1 ; +u64 reserved_2_2 :1 ; +u64 speed :1 ; +u64 link :1 ; + } s; +struct cvmx_xcv_int_s cn73xx; +}; + +typedef union cvmx_xcv_int cvmx_xcv_int_t ; + +/** +* cvmx_xcv_reset +* +* This register controls reset. +* +*/ +union cvmx_xcv_reset { +u64 u64; +struct cvmx_xcv_reset_s { +u64 enable :1 ; +u64 reserved_16_62 :47 ; +u64 clkrst :1 ; +u64 reserved_12_14 :3 ; +u64 dllrst :1 ; +u64 reserved_8_10 :3 ; +u64 comp :1 ; +u64 reserved_4_6 :3 ; +u64 tx_pkt_rst_n :1 ; +u64 tx_dat_rst_n :1 ; +u64 rx_pkt_rst_n :1 ; +u64 rx_dat_rst_n :1 ; + } s; +struct cvmx_xcv_reset_s cn73xx; +}; + +typedef union cvmx_xcv_reset cvmx_xcv_reset_t ; + +#endif
Signature · 1 line
2.35.1
PATCH 12/52 mips: octeon: Add cvmx-helper-fpa.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-helper-fpa.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-helper-fpa.c | 329 ++++++++++++++++++++++++ 1 file changed, 329 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-helper-fpa.c
arch/mips/mach-octeon/cvmx-helper-fpa.c new file +329 -0
@@ -0,0 +1,329 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Helper functions for FPA setup. +*/ + +#include <errno.h> +#include <log.h> +#include <time.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/cvmx-fuse.h> +#include <mach/octeon-feature.h> +#include <mach/cvmx-qlm.h> +#include <mach/octeon_qlm.h> +#include <mach/cvmx-pcie.h> +#include <mach/cvmx-coremask.h> +#include <mach/cvmx-range.h> +#include <mach/cvmx-global-resources.h> + +#include <mach/cvmx-agl-defs.h> +#include <mach/cvmx-bgxx-defs.h> +#include <mach/cvmx-ciu-defs.h> +#include <mach/cvmx-gmxx-defs.h> +#include <mach/cvmx-gserx-defs.h> +#include <mach/cvmx-ilk-defs.h> +#include <mach/cvmx-ipd-defs.h> +#include <mach/cvmx-pcsx-defs.h> +#include <mach/cvmx-pcsxx-defs.h> +#include <mach/cvmx-pki-defs.h> +#include <mach/cvmx-pko-defs.h> +#include <mach/cvmx-xcv-defs.h> + +#include <mach/cvmx-hwpko.h> +#include <mach/cvmx-ilk.h> +#include <mach/cvmx-ipd.h> +#include <mach/cvmx-pki.h> +#include <mach/cvmx-pko3.h> +#include <mach/cvmx-pko3-queue.h> +#include <mach/cvmx-pko3-resources.h> +#include <mach/cvmx-pip.h> + +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> + +#include <mach/cvmx-helper-bgx.h> +#include <mach/cvmx-helper-cfg.h> +#include <mach/cvmx-helper-util.h> +#include <mach/cvmx-helper-pki.h> +#include <mach/cvmx-helper-pko.h> + +void cvmx_helper_fpa1_dump (int node) +{ +int pool_num =0 , pools_max =cvmx_fpa_get_max_pools (); + +if (node ==-1 ) + node =cvmx_get_node_num (); + +printf ("FPA pool status: pools count: %u\n" , pools_max); +printf ("----------------------------------------------------\n" ); +printf ("%5s %5s %12s %16s\n" ,"POOL" ,"Size" ,"Free" ,"Name" ); + +while (pool_num < pools_max) { +int pool = pool_num++; +unsigned int sz =cvmx_fpa_get_block_size (pool); +char *s ="" ; + +if (sz ==0 ) +continue ; +if (cvmx_fpa_get_pool_owner (pool) !=cvmx_get_app_id ()) + s ="*" ; + +printf ("%5u %5u %12u %16s %1s\n" , pool, sz, +cvmx_fpa_get_current_count (pool), +cvmx_fpa_get_name (pool), s); + } +} + +void cvmx_helper_fpa3_dump (unsigned int node) +{ +int lpool, laura; +unsigned int intr; +char line[128 ]; + + intr =csr_rd_node (node,CVMX_FPA_ERR_INT ); +memset (line,'*' ,80 ); + line[80 ] ='\0' ; +printf ("\n%s\n" , line); +printf (" FPA3 on node %u: intr=%#x\n" , node, intr); +printf ("%s\n" , line); +printf ("%6s %5s %14s %14s %16s %s\n" ,"POOL" ,"Size" ,"Free" ,"" , +"Name" ,"Intr" ); + +for (lpool =0 ; lpool <cvmx_fpa3_num_pools (); lpool++) { +cvmx_fpa3_pool_t pool; +cvmx_fpa_poolx_cfg_t pool_cfg; +cvmx_fpa_poolx_available_t avail_reg; +unsigned int bsz; +unsigned long long bcnt; + + pool =__cvmx_fpa3_pool (node, lpool); + pool_cfg.u64 = +csr_rd_node (pool.node,CVMX_FPA_POOLX_CFG (pool.lpool)); + bsz = pool_cfg.cn78xx.buf_size <<7 ; +if (bsz ==0 ) +continue ; + avail_reg.u64 =csr_rd_node ( + pool.node,CVMX_FPA_POOLX_AVAILABLE (pool.lpool)); + bcnt = avail_reg.cn78xx.count; + intr =csr_rd_node (pool.node,CVMX_FPA_POOLX_INT (pool.lpool)); + +printf ("%6u %5u %14llu %14s %16s %#4x\n" , lpool, bsz, bcnt,"" , +cvmx_fpa3_get_pool_name (pool), intr); + } +printf ("\n" ); + +printf ("%6s %5s %14s %14s %16s %s\n" ,"AURA" ,"POOL" ,"Allocated" , +"Remaining" ,"Name" ,"Intr" ); + +for (laura =0 ; laura <cvmx_fpa3_num_auras (); laura++) { +cvmx_fpa3_gaura_t aura; +cvmx_fpa_aurax_cnt_t cnt_reg; +cvmx_fpa_aurax_cnt_limit_t limit_reg; +cvmx_fpa_aurax_pool_t aurax_pool; +unsigned long long cnt, limit, rem; +unsigned int pool; +const char *name; + + aura =__cvmx_fpa3_gaura (node, laura); + aurax_pool.u64 = +csr_rd_node (aura.node,CVMX_FPA_AURAX_POOL (aura.laura)); + pool = aurax_pool.cn78xx.pool; +if (pool ==0 ) +continue ; + cnt_reg.u64 = +csr_rd_node (aura.node,CVMX_FPA_AURAX_CNT (aura.laura)); + limit_reg.u64 =csr_rd_node ( + aura.node,CVMX_FPA_AURAX_CNT_LIMIT (aura.laura)); + cnt = cnt_reg.cn78xx.cnt; + limit = limit_reg.cn78xx.limit; + rem = limit - cnt; + name =cvmx_fpa3_get_aura_name (aura); + intr =csr_rd_node (aura.node,CVMX_FPA_AURAX_INT (aura.laura)); + +if (limit ==CVMX_FPA3_AURAX_LIMIT_MAX ) +printf ("%6u %5u %14llu %14s %16s %#4x\n" , laura, pool, + cnt,"unlimited" , name, intr); +else +printf ("%6u %5u %14llu %14llu %16s %#4x\n" , laura, pool, + cnt, rem, name, intr); + } +printf ("\n" ); +} + +void cvmx_helper_fpa_dump (int node) +{ +if (node ==-1 ) + node =cvmx_get_node_num (); +if (octeon_has_feature (OCTEON_FEATURE_FPA3 )) +cvmx_helper_fpa3_dump (node); +else +cvmx_helper_fpa1_dump (node); +} + +int cvmx_helper_shutdown_fpa_pools (int node) +{ +if (octeon_has_feature (OCTEON_FEATURE_FPA3 )) { +cvmx_fpa3_gaura_t aura; +cvmx_fpa3_pool_t pool; +int laura, lpool; + +for (laura =0 ; laura <cvmx_fpa3_num_auras (); laura++) { + aura =__cvmx_fpa3_gaura (node, laura); + (void )cvmx_fpa3_shutdown_aura (aura); + } + +for (lpool =0 ; lpool <cvmx_fpa3_num_pools (); lpool++) { + pool =__cvmx_fpa3_pool (node, lpool); + (void )cvmx_fpa3_shutdown_pool (pool); + } + }else { +int pool; + +for (pool =0 ; pool <CVMX_FPA1_NUM_POOLS ; pool++) { +if (cvmx_fpa_get_block_size (pool) >0 ) +cvmx_fpa_shutdown_pool (pool); + } +if (!OCTEON_IS_MODEL (OCTEON_CN68XX )) +cvmx_fpa_disable (); + } + +return 0 ; +} + +/** +* @INTERNAL +* OBSOLETE +* +* Allocate memory for and initialize a single FPA pool. +* +* @param pool Pool to initialize +* @param buffer_size Size of buffers to allocate in bytes +* @param buffers Number of buffers to put in the pool. Zero is allowed +* @param name String name of the pool for debugging purposes +* @return Zero on success, non-zero on failure +* +* This function is only for transition, will be removed. +*/ +int __cvmx_helper_initialize_fpa_pool (int pool,u64 buffer_size,u64 buffers, +const char *name) +{ +return cvmx_fpa_setup_pool (pool, name,NULL , buffer_size, buffers); +} + +/** +* @INTERNAL +* Allocate memory and initialize the FPA pools using memory +* from cvmx-bootmem. Specifying zero for the number of +* buffers will cause that FPA pool to not be setup. This is +* useful if you aren't using some of the hardware and want +* to save memory. Use cvmx_helper_initialize_fpa instead of +* this function directly. +* +* @param pip_pool Should always be CVMX_FPA_PACKET_POOL +* @param pip_size Should always be CVMX_FPA_PACKET_POOL_SIZE +* @param pip_buffers +* Number of packet buffers. +* @param wqe_pool Should always be CVMX_FPA_WQE_POOL +* @param wqe_size Should always be CVMX_FPA_WQE_POOL_SIZE +* @param wqe_entries +* Number of work queue entries +* @param pko_pool Should always be CVMX_FPA_OUTPUT_BUFFER_POOL +* @param pko_size Should always be CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE +* @param pko_buffers +* PKO Command buffers. You should at minimum have two per +* each PKO queue. +* @param tim_pool Should always be CVMX_FPA_TIMER_POOL +* @param tim_size Should always be CVMX_FPA_TIMER_POOL_SIZE +* @param tim_buffers +* TIM ring buffer command queues. At least two per timer bucket +* is recommended. +* @param dfa_pool Should always be CVMX_FPA_DFA_POOL +* @param dfa_size Should always be CVMX_FPA_DFA_POOL_SIZE +* @param dfa_buffers +* DFA command buffer. A relatively small (32 for example) +* number should work. +* @return Zero on success, non-zero if out of memory +*/ +static int +__cvmx_helper_initialize_fpa (int pip_pool,int pip_size,int pip_buffers, +int wqe_pool,int wqe_size,int wqe_entries, +int pko_pool,int pko_size,int pko_buffers, +int tim_pool,int tim_size,int tim_buffers, +int dfa_pool,int dfa_size,int dfa_buffers) +{ +cvmx_fpa_enable (); +if (pip_buffers >0 ) { +cvmx_fpa_setup_pool (pip_pool,"PKI_POOL" ,NULL , pip_size, + pip_buffers); + } +/* Allocate WQE pool only if it is distinct from packet pool */ +if (wqe_entries >0 && wqe_pool != pip_pool) { +cvmx_fpa_setup_pool (wqe_pool,"WQE_POOL" ,NULL , wqe_size, + wqe_entries); + } +/* cn78xx PKO allocates its own FPA pool per HW constraints */ +if (pko_buffers >0 ) { +if (!octeon_has_feature (OCTEON_FEATURE_PKI )) +cvmx_fpa_setup_pool (pko_pool,"PKO_POOL" ,NULL , + pko_size, pko_buffers); + } +if (tim_buffers >0 ) { +cvmx_fpa_setup_pool (tim_pool,"TIM_POOL" ,NULL , tim_size, + tim_buffers); + } +return 0 ; +} + +/** +* Allocate memory and initialize the FPA pools using memory +* from cvmx-bootmem. Sizes of each element in the pools is +* controlled by the cvmx-config.h header file. Specifying +* zero for any parameter will cause that FPA pool to not be +* setup. This is useful if you aren't using some of the +* hardware and want to save memory. +* +* @param packet_buffers +* Number of packet buffers to allocate +* @param work_queue_entries +* Number of work queue entries +* @param pko_buffers +* PKO Command buffers. You should at minimum have two per +* each PKO queue. +* @param tim_buffers +* TIM ring buffer command queues. At least two per timer bucket +* is recommended. +* @param dfa_buffers +* DFA command buffer. A relatively small (32 for example) +* number should work. +* @return Zero on success, non-zero if out of memory +*/ +int cvmx_helper_initialize_fpa (int packet_buffers,int work_queue_entries, +int pko_buffers,int tim_buffers, +int dfa_buffers) +{ +int packet_pool = (int )cvmx_fpa_get_packet_pool (); +int wqe_pool = (int )cvmx_fpa_get_wqe_pool (); +int outputbuffer_pool = (int )cvmx_fpa_get_pko_pool (); +int timer_pool; +int dfa_pool =0 ; +int rv; + + timer_pool =0 ; + + rv =__cvmx_helper_initialize_fpa ( + packet_pool,cvmx_fpa_get_packet_pool_block_size (), + packet_buffers, wqe_pool,cvmx_fpa_get_wqe_pool_block_size (), + work_queue_entries, outputbuffer_pool, +cvmx_fpa_get_pko_pool_block_size (), pko_buffers, timer_pool,0 , + tim_buffers, dfa_pool,0 , dfa_buffers); + +return rv; +}
Signature · 1 line
2.35.1
PATCH 4/52 mips: octeon: Add cvmx-lbk-defs.h header file
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-lbk-defs.h header file from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- .../mach-octeon/include/mach/cvmx-lbk-defs.h | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-lbk-defs.h
arch/mips/mach-octeon/include/mach/cvmx-lbk-defs.h new file +157 -0
@@ -0,0 +1,157 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Configuration and status register (CSR) type definitions for +* Octeon lbk. +*/ + +#ifndef __CVMX_LBK_DEFS_H__ +#define __CVMX_LBK_DEFS_H__ + +#define CVMX_LBK_BIST_RESULT (0x0001180012000020ull) +#define CVMX_LBK_CHX_PKIND (offset) (0x0001180012000200ull + ((offset) & 63) * 8) +#define CVMX_LBK_CLK_GATE_CTL (0x0001180012000008ull) +#define CVMX_LBK_DAT_ERR_INFO (0x0001180012000050ull) +#define CVMX_LBK_ECC_CFG (0x0001180012000060ull) +#define CVMX_LBK_INT (0x0001180012000040ull) +#define CVMX_LBK_SFT_RST (0x0001180012000000ull) + +/** +* cvmx_lbk_bist_result +* +* This register provides access to the internal BIST results. Each bit is the +* BIST result of an individual memory (per bit, 0 = pass and 1 = fail). +*/ +union cvmx_lbk_bist_result { +u64 u64; +struct cvmx_lbk_bist_result_s { +u64 reserved_1_63 :63 ; +u64 dat :1 ; + } s; +struct cvmx_lbk_bist_result_s cn73xx; +struct cvmx_lbk_bist_result_s cn78xx; +struct cvmx_lbk_bist_result_s cn78xxp1; +struct cvmx_lbk_bist_result_s cnf75xx; +}; + +typedef union cvmx_lbk_bist_result cvmx_lbk_bist_result_t ; + +/** +* cvmx_lbk_ch#_pkind +*/ +union cvmx_lbk_chx_pkind { +u64 u64; +struct cvmx_lbk_chx_pkind_s { +u64 reserved_6_63 :58 ; +u64 pkind :6 ; + } s; +struct cvmx_lbk_chx_pkind_s cn73xx; +struct cvmx_lbk_chx_pkind_s cn78xx; +struct cvmx_lbk_chx_pkind_s cn78xxp1; +struct cvmx_lbk_chx_pkind_s cnf75xx; +}; + +typedef union cvmx_lbk_chx_pkind cvmx_lbk_chx_pkind_t ; + +/** +* cvmx_lbk_clk_gate_ctl +* +* This register is for diagnostic use only. +* +*/ +union cvmx_lbk_clk_gate_ctl { +u64 u64; +struct cvmx_lbk_clk_gate_ctl_s { +u64 reserved_1_63 :63 ; +u64 dis :1 ; + } s; +struct cvmx_lbk_clk_gate_ctl_s cn73xx; +struct cvmx_lbk_clk_gate_ctl_s cn78xx; +struct cvmx_lbk_clk_gate_ctl_s cn78xxp1; +struct cvmx_lbk_clk_gate_ctl_s cnf75xx; +}; + +typedef union cvmx_lbk_clk_gate_ctl cvmx_lbk_clk_gate_ctl_t ; + +/** +* cvmx_lbk_dat_err_info +*/ +union cvmx_lbk_dat_err_info { +u64 u64; +struct cvmx_lbk_dat_err_info_s { +u64 reserved_58_63 :6 ; +u64 dbe_ecc_out :9 ; +u64 dbe_synd :9 ; +u64 dbe_addr :8 ; +u64 reserved_26_31 :6 ; +u64 sbe_ecc_out :9 ; +u64 sbe_synd :9 ; +u64 sbe_addr :8 ; + } s; +struct cvmx_lbk_dat_err_info_s cn73xx; +struct cvmx_lbk_dat_err_info_s cn78xx; +struct cvmx_lbk_dat_err_info_s cn78xxp1; +struct cvmx_lbk_dat_err_info_s cnf75xx; +}; + +typedef union cvmx_lbk_dat_err_info cvmx_lbk_dat_err_info_t ; + +/** +* cvmx_lbk_ecc_cfg +*/ +union cvmx_lbk_ecc_cfg { +u64 u64; +struct cvmx_lbk_ecc_cfg_s { +u64 reserved_3_63 :61 ; +u64 dat_flip :2 ; +u64 dat_cdis :1 ; + } s; +struct cvmx_lbk_ecc_cfg_s cn73xx; +struct cvmx_lbk_ecc_cfg_s cn78xx; +struct cvmx_lbk_ecc_cfg_s cn78xxp1; +struct cvmx_lbk_ecc_cfg_s cnf75xx; +}; + +typedef union cvmx_lbk_ecc_cfg cvmx_lbk_ecc_cfg_t ; + +/** +* cvmx_lbk_int +*/ +union cvmx_lbk_int { +u64 u64; +struct cvmx_lbk_int_s { +u64 reserved_6_63 :58 ; +u64 chan_oflow :1 ; +u64 chan_uflow :1 ; +u64 dat_oflow :1 ; +u64 dat_uflow :1 ; +u64 dat_dbe :1 ; +u64 dat_sbe :1 ; + } s; +struct cvmx_lbk_int_s cn73xx; +struct cvmx_lbk_int_s cn78xx; +struct cvmx_lbk_int_s cn78xxp1; +struct cvmx_lbk_int_s cnf75xx; +}; + +typedef union cvmx_lbk_int cvmx_lbk_int_t ; + +/** +* cvmx_lbk_sft_rst +*/ +union cvmx_lbk_sft_rst { +u64 u64; +struct cvmx_lbk_sft_rst_s { +u64 reserved_1_63 :63 ; +u64 reset :1 ; + } s; +struct cvmx_lbk_sft_rst_s cn73xx; +struct cvmx_lbk_sft_rst_s cn78xx; +struct cvmx_lbk_sft_rst_s cn78xxp1; +struct cvmx_lbk_sft_rst_s cnf75xx; +}; + +typedef union cvmx_lbk_sft_rst cvmx_lbk_sft_rst_t ; + +#endif
Signature · 1 line
2.35.1
PATCH 9/52 mips: octeon: Add cvmx-helper-agl.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-helper-agl.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-helper-agl.c | 231 ++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-helper-agl.c
arch/mips/mach-octeon/cvmx-helper-agl.c new file +231 -0
@@ -0,0 +1,231 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Functions for AGL (RGMII) initialization, configuration, +* and monitoring. +*/ + +#include <log.h> +#include <time.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/cvmx-fuse.h> +#include <mach/octeon-feature.h> +#include <mach/cvmx-qlm.h> +#include <mach/octeon_qlm.h> +#include <mach/cvmx-pcie.h> +#include <mach/cvmx-coremask.h> + +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-cfg.h> + +#include <mach/cvmx-agl.h> +#include <mach/cvmx-pki.h> + +#include <mach/cvmx-agl-defs.h> +#include <mach/cvmx-pko-defs.h> + +int __cvmx_helper_agl_enumerate (int xiface) +{ +if (OCTEON_IS_MODEL (OCTEON_CN70XX )) { +union cvmx_agl_prtx_ctl agl_prtx_ctl; + + agl_prtx_ctl.u64 =csr_rd (CVMX_AGL_PRTX_CTL (0 )); +if (agl_prtx_ctl.s.mode ==0 )/* RGMII */ +return 1 ; + } +return 0 ; +} + +/** +* @INTERNAL +* Convert interface to port to assess CSRs. +* +* @param xiface Interface to probe +* @return The port corresponding to the interface +*/ +int cvmx_helper_agl_get_port (int xiface) +{ +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); + +if (OCTEON_IS_MODEL (OCTEON_CN70XX )) +return xi.interface -4 ; +return -1 ; +} + +/** +* @INTERNAL +* Probe a RGMII interface and determine the number of ports +* connected to it. The RGMII interface should still be down +* after this call. +* +* @param interface to probe +* +* @return Number of ports on the interface. Zero to disable. +*/ +int __cvmx_helper_agl_probe (int interface) +{ +int port =cvmx_helper_agl_get_port (interface); +union cvmx_agl_gmx_bist gmx_bist; +union cvmx_agl_gmx_prtx_cfg gmx_prtx_cfg; +union cvmx_agl_prtx_ctl agl_prtx_ctl; +int result; + + result =__cvmx_helper_agl_enumerate (interface); +if (result ==0 ) +return 0 ; + +/* Check BIST status */ + gmx_bist.u64 =csr_rd (CVMX_AGL_GMX_BIST ); +if (gmx_bist.u64) +printf ("Management port AGL failed BIST (0x%016llx) on AGL%d\n" , +CAST64 (gmx_bist.u64), port); + +/* Disable the external input/output */ + gmx_prtx_cfg.u64 =csr_rd (CVMX_AGL_GMX_PRTX_CFG (port)); + gmx_prtx_cfg.s.en =0 ; +csr_wr (CVMX_AGL_GMX_PRTX_CFG (port), gmx_prtx_cfg.u64); + +/* Set the rgx_ref_clk MUX with AGL_PRTx_CTL[REFCLK_SEL]. Default value +* is 0 (RGMII REFCLK). Recommended to use RGMII RXC(1) or sclk/4 (2) +* to save cost. +*/ + + agl_prtx_ctl.u64 =csr_rd (CVMX_AGL_PRTX_CTL (port)); + agl_prtx_ctl.s.clkrst =0 ; + agl_prtx_ctl.s.dllrst =0 ; + agl_prtx_ctl.s.clktx_byp =0 ; + +if (OCTEON_IS_MODEL (OCTEON_CN70XX )) { +bool tx_enable_bypass; +int tx_delay; + + agl_prtx_ctl.s.refclk_sel = +cvmx_helper_get_agl_refclk_sel (interface, port); + agl_prtx_ctl.s.clkrx_set = +cvmx_helper_get_agl_rx_clock_skew (interface, port); + agl_prtx_ctl.s.clkrx_byp = +cvmx_helper_get_agl_rx_clock_delay_bypass (interface, + port); +cvmx_helper_cfg_get_rgmii_tx_clk_delay ( + interface, port, &tx_enable_bypass, &tx_delay); + agl_prtx_ctl.s.clktx_byp = tx_enable_bypass; + agl_prtx_ctl.s.clktx_set = tx_delay; + } +csr_wr (CVMX_AGL_PRTX_CTL (port), agl_prtx_ctl.u64); +/* Force write out before wait */ +csr_rd (CVMX_AGL_PRTX_CTL (port)); +udelay (500 ); + +/* Enable the componsation controller */ + agl_prtx_ctl.u64 =csr_rd (CVMX_AGL_PRTX_CTL (port)); + agl_prtx_ctl.s.drv_byp =0 ; +csr_wr (CVMX_AGL_PRTX_CTL (port), agl_prtx_ctl.u64); +/* Force write out before wait */ +csr_rd (CVMX_AGL_PRTX_CTL (port)); + +if (!OCTEON_IS_OCTEON3 ()) { +/* Enable the interface */ + agl_prtx_ctl.u64 =csr_rd (CVMX_AGL_PRTX_CTL (port)); + agl_prtx_ctl.s.enable =1 ; +csr_wr (CVMX_AGL_PRTX_CTL (port), agl_prtx_ctl.u64); +/* Read the value back to force the previous write */ + agl_prtx_ctl.u64 =csr_rd (CVMX_AGL_PRTX_CTL (port)); + } + +/* Enable the compensation controller */ + agl_prtx_ctl.u64 =csr_rd (CVMX_AGL_PRTX_CTL (port)); + agl_prtx_ctl.s.comp =1 ; +csr_wr (CVMX_AGL_PRTX_CTL (port), agl_prtx_ctl.u64); +/* Force write out before wait */ +csr_rd (CVMX_AGL_PRTX_CTL (port)); + +/* for componsation state to lock. */ +udelay (500 ); + +return result; +} + +/** +* @INTERNAL +* Bringup and enable a RGMII interface. After this call packet +* I/O should be fully functional. This is called with IPD +* enabled but PKO disabled. +* +* @param interface to bring up +* +* @return Zero on success, negative on failure +*/ +int __cvmx_helper_agl_enable (int interface) +{ +int port =cvmx_helper_agl_get_port (interface); +int ipd_port =cvmx_helper_get_ipd_port (interface, port); +union cvmx_pko_mem_port_ptrs pko_mem_port_ptrs; +union cvmx_pko_reg_read_idx read_idx; +int do_link_set =1 ; +int i; + +/* Setup PKO for AGL interface. Back pressure is not supported. */ + pko_mem_port_ptrs.u64 =0 ; + read_idx.u64 =0 ; + read_idx.s.inc =1 ; +csr_wr (CVMX_PKO_REG_READ_IDX , read_idx.u64); + +for (i =0 ; i <40 ; i++) { + pko_mem_port_ptrs.u64 =csr_rd (CVMX_PKO_MEM_PORT_PTRS ); +if (pko_mem_port_ptrs.s.pid ==24 ) { + pko_mem_port_ptrs.s.eid =10 ; + pko_mem_port_ptrs.s.bp_port =40 ; +csr_wr (CVMX_PKO_MEM_PORT_PTRS , pko_mem_port_ptrs.u64); +break ; + } + } + +cvmx_agl_enable (port); +if (do_link_set) +cvmx_agl_link_set (port,cvmx_agl_link_get (ipd_port)); + +return 0 ; +} + +/** +* @INTERNAL +* Return the link state of an IPD/PKO port as returned by +* auto negotiation. The result of this function may not match +* Octeon's link config if auto negotiation has changed since +* the last call to cvmx_helper_link_set(). +* +* @param ipd_port IPD/PKO port to query +* +* @return Link state +*/ +cvmx_helper_link_info_t __cvmx_helper_agl_link_get (int ipd_port) +{ +return cvmx_agl_link_get (ipd_port); +} + +/** +* @INTERNAL +* Configure an IPD/PKO port for the specified link state. This +* function does not influence auto negotiation at the PHY level. +* The passed link state must always match the link state returned +* by cvmx_helper_link_get(). It is normally best to use +* cvmx_helper_link_autoconf() instead. +* +* @param ipd_port IPD/PKO port to configure +* @param link_info The new link state +* +* @return Zero on success, negative on failure +*/ +int __cvmx_helper_agl_link_set (int ipd_port,cvmx_helper_link_info_t link_info) +{ +int interface =cvmx_helper_get_interface_num (ipd_port); +int port =cvmx_helper_agl_get_port (interface); + +return cvmx_agl_link_set (port, link_info); +}
Signature · 1 line
2.35.1
PATCH 11/52 mips: octeon: Add cvmx-helper-board.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-helper-board.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-helper-board.c | 2030 +++++++++++++++++++++ 1 file changed, 2030 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-helper-board.c
arch/mips/mach-octeon/cvmx-helper-board.c new file +2030 -0
@@ -0,0 +1,2030 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Helper functions to abstract board specific data about +* network ports from the rest of the cvmx-helper files. +*/ + +#include <i2c.h> +#include <log.h> +#include <malloc.h> +#include <net.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/octeon_fdt.h> +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> +#include <mach/cvmx-helper-fdt.h> +#include <mach/cvmx-helper-gpio.h> + +#include <mach/cvmx-smix-defs.h> +#include <mach/cvmx-mdio.h> +#include <mach/cvmx-qlm.h> + +DECLARE_GLOBAL_DATA_PTR ; + +static bool sfp_parsed; + +static int __cvmx_helper_78xx_parse_phy (struct cvmx_phy_info *phy_info, +int ipd_port); +static int __get_phy_info_from_dt (cvmx_phy_info_t *phy_info,int ipd_port); + +/** +* Writes to a Microsemi VSC7224 16-bit register +* +* @param[in] i2c_bus i2c bus data structure (must be enabled) +* @param addr Address of VSC7224 on the i2c bus +* @param reg 8-bit register number to write to +* @param val 16-bit value to write +* +* @return 0 for success +*/ +static int cvmx_write_vsc7224_reg (const struct cvmx_fdt_i2c_bus_info *i2c_bus, +u8 addr,u8 reg,u16 val) +{ +struct udevice *dev; +u8 buffer[2 ]; +int ret; + + ret =i2c_get_chip (i2c_bus->i2c_bus, addr,1 , &dev); +if (ret) { +debug ("Cannot find I2C device: %d\n" , ret); +return -1 ; + } + + ret =dm_i2c_write (dev, reg, buffer,2 ); +if (ret) { +debug ("Cannot write I2C device: %d\n" , ret); +return -1 ; + } + +return 0 ; +} + +/** +* Writes to a Microsemi VSC7224 16-bit register +* +* @param[in] i2c_bus i2c bus data structure (must be enabled) +* @param addr Address of VSC7224 on the i2c bus +* @param reg 8-bit register number to write to +* +* @return 16-bit value or error if < 0 +*/ +static int cvmx_read_vsc7224_reg (const struct cvmx_fdt_i2c_bus_info *i2c_bus, +u8 addr,u8 reg) +{ +struct udevice *dev; +u8 buffer[2 ]; +int ret; + + ret =i2c_get_chip (i2c_bus->i2c_bus, addr,1 , &dev); +if (ret) { +debug ("Cannot find I2C device: %d\n" , ret); +return -1 ; + } + + ret =dm_i2c_read (dev, reg, buffer,2 ); +if (ret) { +debug ("Cannot read I2C device: %d\n" , ret); +return -1 ; + } + +return (buffer[0 ] <<8 ) | buffer[1 ]; +} + +/** +* @INTERNAL +* Return loss of signal +* +* @param xiface xinterface number +* @param index port index on interface +* +* @return 0 if signal present, 1 if loss of signal. +* +* @NOTE: A result of 0 is possible in some cases where the signal is +* not present. +* +* This is for use with __cvmx_qlm_rx_equilization +*/ +int __cvmx_helper_get_los (int xiface,int index) +{ +struct cvmx_fdt_sfp_info *sfp; +struct cvmx_vsc7224_chan *vsc7224_chan; +struct cvmx_vsc7224 *vsc7224; +int los =0 ; +int val; +int mode =cvmx_helper_interface_get_mode (xiface); + + sfp =cvmx_helper_cfg_get_sfp_info (xiface, index); + +/* Check all SFP slots in the group +* NOTE: Usually there is only one SFP or QSFP slot except in the case +* where multiple SFP+ slots are grouped together for XLAUI mode. +*/ +while (sfp && sfp->check_mod_abs) { + los = sfp->check_mod_abs (sfp, sfp->mod_abs_data); +if (los >=0 ) +cvmx_sfp_validate_module (sfp, mode); +if (los || los <0 ) { +debug ("%s(0x%x, %d): los detected (mod_abs) los: %d\n" , + __func__, xiface, index, los); +return 1 ; + } + vsc7224_chan = sfp->vsc7224_chan; +while (vsc7224_chan) { +u64 done; +int channel_num = vsc7224_chan->lane; +int los_bit =1 << channel_num; +int lol_bit =0x10 << channel_num; + +/* We only care about receive channels so skip rx. +* Also, in XFI mode we don't care about different +* XFI ports so skip those. +*/ +if (vsc7224_chan->is_tx || + vsc7224_chan->index != index || + vsc7224_chan->xiface != xiface) { + vsc7224_chan = vsc7224_chan->next; +continue ; + } + + vsc7224 = vsc7224_chan->vsc7224; +/* Poll for LoS/LoL for 2ms */ +cvmx_write_vsc7224_reg (vsc7224->i2c_bus, + vsc7224->i2c_addr,0x7f ,0x40 ); + done =20 ; +do { + val =cvmx_read_vsc7224_reg (vsc7224->i2c_bus, + vsc7224->i2c_addr, +0xc0 ); + val &= (los_bit | lol_bit); +if (val) { +debug ("%s(0x%x, %d): LOS/LOL detected from VSC7224: 0x%x\n" , + __func__, xiface, index, val); +return 1 ; + } +udelay (100 ); + }while (done--); + +/* Move to the next channel */ + vsc7224_chan = vsc7224_chan->next; + } +/* Move to the next SFP+ slot */ + sfp = sfp->next; + } +debug ("%s(0x%x, %d): los: 0\n" , __func__, xiface, index); +return 0 ; +} + +/** +* Function called whenever mod_abs/mod_prs has changed for Microsemi VSC7224 +* +* @param sfp pointer to SFP data structure +* @param val 1 if absent, 0 if present, otherwise not set +* @param data user-defined data +* +* @return 0 for success, -1 on error +*/ +int cvmx_sfp_vsc7224_mod_abs_changed (struct cvmx_fdt_sfp_info *sfp,int val, +void *data) +{ +int err; +struct cvmx_sfp_mod_info *mod_info; +int length; +struct cvmx_vsc7224 *vsc7224; +struct cvmx_vsc7224_chan *vsc7224_chan; +struct cvmx_vsc7224_tap *taps, *match =NULL ; +int i; + +debug ("%s(%s, %d, %p): Module %s\n" , __func__, sfp->name, val, data, + val ?"absent" :"present" ); +if (val) +return 0 ; + +/* We're here if we detect that the module is now present */ + err =cvmx_sfp_read_i2c_eeprom (sfp); +if (err) { +debug ("%s: Error reading the SFP module eeprom for %s\n" , + __func__, sfp->name); +return err; + } + mod_info = &sfp->sfp_info; + +if (!mod_info->valid || !sfp->valid) { +debug ("%s: Module data is invalid\n" , __func__); +return -1 ; + } + + vsc7224_chan = sfp->vsc7224_chan; +while (vsc7224_chan) { +/* We don't do any rx tuning */ +if (!vsc7224_chan->is_tx) { + vsc7224_chan = vsc7224_chan->next; +continue ; + } + +/* Walk through all the channels */ + taps = vsc7224_chan->taps; +if (mod_info->limiting) + length =0 ; +else + length = mod_info->max_copper_cable_len; +debug ("%s: limiting: %d, length: %d\n" , __func__, + mod_info->limiting, length); + +/* Find a matching length in the taps table */ +for (i =0 ; i < vsc7224_chan->num_taps; i++) { +if (length >= taps->len) + match = taps; + taps++; + } +if (!match) { +debug ("%s(%s, %d, %p): Error: no matching tap for length %d\n" , + __func__, sfp->name, val, data, length); +return -1 ; + } +debug ("%s(%s): Applying %cx taps to vsc7224 %s:%d for cable length %d+\n" , + __func__, sfp->name, vsc7224_chan->is_tx ?'t' :'r' , + vsc7224_chan->vsc7224->name, vsc7224_chan->lane, + match->len); +/* Program the taps */ + vsc7224 = vsc7224_chan->vsc7224; +cvmx_write_vsc7224_reg (vsc7224->i2c_bus, vsc7224->i2c_addr, +0x7f , vsc7224_chan->lane); +if (!vsc7224_chan->maintap_disable) +cvmx_write_vsc7224_reg (vsc7224->i2c_bus, + vsc7224->i2c_addr,0x99 , + match->main_tap); +if (!vsc7224_chan->pretap_disable) +cvmx_write_vsc7224_reg (vsc7224->i2c_bus, + vsc7224->i2c_addr,0x9a , + match->pre_tap); +if (!vsc7224_chan->posttap_disable) +cvmx_write_vsc7224_reg (vsc7224->i2c_bus, + vsc7224->i2c_addr,0x9b , + match->post_tap); + +/* Re-use val and disable taps if needed */ +if (vsc7224_chan->maintap_disable || + vsc7224_chan->pretap_disable || + vsc7224_chan->posttap_disable) { + val =cvmx_read_vsc7224_reg (vsc7224->i2c_bus, + vsc7224->i2c_addr,0x97 ); +if (vsc7224_chan->maintap_disable) + val |=0x800 ; +if (vsc7224_chan->pretap_disable) + val |=0x1000 ; +if (vsc7224_chan->posttap_disable) + val |=0x400 ; +cvmx_write_vsc7224_reg (vsc7224->i2c_bus, + vsc7224->i2c_addr,0x97 , val); + } + vsc7224_chan = vsc7224_chan->next; + } + +return err; +} + +/** +* Update the mod_abs and error LED +* +* @param ipd_port ipd port number +* @param link link information +*/ +static void __cvmx_helper_update_sfp (int ipd_port, +struct cvmx_fdt_sfp_info *sfp_info, +cvmx_helper_link_info_t link) +{ +debug ("%s(%d): checking mod_abs\n" , __func__, ipd_port); + +cvmx_sfp_check_mod_abs (sfp_info, sfp_info->mod_abs_data); +} + +static void cvmx_sfp_update_link (struct cvmx_fdt_sfp_info *sfp, +cvmx_helper_link_info_t link) +{ +while (sfp) { +debug ("%s(%s): checking mod_abs\n" , __func__, sfp->name); +if (link.s.link_up && sfp->last_mod_abs) +cvmx_sfp_check_mod_abs (sfp, sfp->mod_abs_data); + sfp = sfp->next_iface_sfp; + } +} + +/** +* @INTERNAL +* This function is used ethernet ports link speed. This functions uses the +* device tree information to determine the phy address and type of PHY. +* The only supproted PHYs are Marvell and Broadcom. +* +* @param ipd_port IPD input port associated with the port we want to get link +* status for. +* +* @return The ports link status. If the link isn't fully resolved, this must +* return zero. +*/ +cvmx_helper_link_info_t __cvmx_helper_board_link_get_from_dt (int ipd_port) +{ +cvmx_helper_link_info_t result; +cvmx_phy_info_t *phy_info =NULL ; +cvmx_phy_info_t local_phy_info; +int xiface =0 , index =0 ; +bool use_inband = false; +struct cvmx_fdt_sfp_info *sfp_info; + const void *fdt_addr = CASTPTR(const void *, gd->fdt_blob); + + result.u64 =0 ; + +if (ipd_port >=0 ) { +int mode; + + xiface =cvmx_helper_get_interface_num (ipd_port); + index =cvmx_helper_get_interface_index_num (ipd_port); + mode =cvmx_helper_interface_get_mode (xiface); +if (!cvmx_helper_get_port_autonegotiation (xiface, index)) { + result.s.link_up =1 ; + result.s.full_duplex =1 ; +switch (mode) { +case CVMX_HELPER_INTERFACE_MODE_RGMII : +case CVMX_HELPER_INTERFACE_MODE_GMII : +case CVMX_HELPER_INTERFACE_MODE_SGMII : +case CVMX_HELPER_INTERFACE_MODE_QSGMII : +case CVMX_HELPER_INTERFACE_MODE_AGL : +case CVMX_HELPER_INTERFACE_MODE_SPI : +if (OCTEON_IS_MODEL (OCTEON_CN70XX )) { +struct cvmx_xiface xi = +cvmx_helper_xiface_to_node_interface ( + xiface); +u64 gbaud =cvmx_qlm_get_gbaud_mhz (0 ); + + result.s.speed = gbaud *8 /10 ; +if (cvmx_qlm_get_dlm_mode ( +0 , xi.interface) == +CVMX_QLM_MODE_SGMII ) + result.s.speed >>=1 ; +else + result.s.speed >>=2 ; + }else { + result.s.speed =1000 ; + } +break ; +case CVMX_HELPER_INTERFACE_MODE_RXAUI : +case CVMX_HELPER_INTERFACE_MODE_XAUI : +case CVMX_HELPER_INTERFACE_MODE_10G_KR : +case CVMX_HELPER_INTERFACE_MODE_XFI : + result.s.speed =10000 ; +break ; +case CVMX_HELPER_INTERFACE_MODE_XLAUI : +case CVMX_HELPER_INTERFACE_MODE_40G_KR4 : + result.s.speed =40000 ; +break ; +default : +break ; + } + + sfp_info =cvmx_helper_cfg_get_sfp_info (xiface, index); +/* Initialize the SFP info if it hasn't already been +* done. +*/ +if (!sfp_info && !sfp_parsed) { +cvmx_sfp_parse_device_tree (fdt_addr); + sfp_parsed = true; +cvmx_sfp_read_all_modules (); + sfp_info =cvmx_helper_cfg_get_sfp_info (xiface, + index); + } +/* If the link is down or the link is up but we still +* register the module as being absent, re-check +* mod_abs. +*/ +cvmx_sfp_update_link (sfp_info, result); + +cvmx_helper_update_link_led (xiface, index, result); + +return result; + } + phy_info =cvmx_helper_get_port_phy_info (xiface, index); +if (!phy_info) { +debug ("%s: phy info not saved in config, allocating for 0x%x:%d\n" , + __func__, xiface, index); + + phy_info = (cvmx_phy_info_t *)cvmx_bootmem_alloc ( +sizeof (*phy_info),0 ); +if (!phy_info) { +debug ("%s: Out of memory\n" , __func__); +return result; + } +memset (phy_info,0 ,sizeof (*phy_info)); + phy_info->phy_addr =-1 ; +debug ("%s: Setting phy info for 0x%x:%d to %p\n" , + __func__, xiface, index, phy_info); +cvmx_helper_set_port_phy_info (xiface, index, phy_info); + } + }else { +/* For management ports we don't store the PHY information +* so we use a local copy instead. +*/ + phy_info = &local_phy_info; +memset (phy_info,0 ,sizeof (*phy_info)); + phy_info->phy_addr =-1 ; + } + +if (phy_info->phy_addr ==-1 ) { +if (octeon_has_feature (OCTEON_FEATURE_BGX )) { +if (__cvmx_helper_78xx_parse_phy (phy_info, ipd_port)) { + phy_info->phy_addr =-1 ; + use_inband = true; + } + }else if (__get_phy_info_from_dt (phy_info, ipd_port) <0 ) { + phy_info->phy_addr =-1 ; + use_inband = true; + } + } + +/* If we can't get the PHY info from the device tree then try +* the inband state. +*/ +if (use_inband) { + result.s.full_duplex =1 ; + result.s.link_up =1 ; + result.s.speed =1000 ; +return result; + } + +if (phy_info->phy_addr <0 ) +return result; + +if (phy_info->link_function) + result = phy_info->link_function (phy_info); +else + result =cvmx_helper_link_get (ipd_port); + + sfp_info =cvmx_helper_cfg_get_sfp_info (xiface, index); +while (sfp_info) { +/* If the link is down or the link is up but we still register +* the module as being absent, re-check mod_abs. +*/ +if (!result.s.link_up || + (result.s.link_up && sfp_info->last_mod_abs)) +__cvmx_helper_update_sfp (ipd_port, sfp_info, result); + sfp_info = sfp_info->next_iface_sfp; + } + +return result; +} + +cvmx_helper_link_info_t __cvmx_helper_board_link_get (int ipd_port) +{ +cvmx_helper_link_info_t result; + +/* Unless we fix it later, all links are defaulted to down */ + result.u64 =0 ; + +return __cvmx_helper_board_link_get_from_dt (ipd_port); +} + +void cvmx_helper_update_link_led (int xiface,int index, +cvmx_helper_link_info_t result) +{ +} + +void cvmx_helper_leds_show_error (struct cvmx_phy_gpio_leds *leds,bool error) +{ +} + +int __cvmx_helper_board_interface_probe (int interface,int supported_ports) +{ +return supported_ports; +} + +/** +* Returns the Ethernet node offset in the device tree +* +* @param fdt_addr - pointer to flat device tree in memory +* @param aliases - offset of alias in device tree +* @param ipd_port - ipd port number to look up +* +* @returns offset of Ethernet node if >= 0, error if -1 +*/ +int __pip_eth_node (const void *fdt_addr,int aliases,int ipd_port) +{ +char name_buffer[20 ]; +const char *pip_path; +int pip, iface, eth; +int interface_num =cvmx_helper_get_interface_num (ipd_port); +int interface_index =cvmx_helper_get_interface_index_num (ipd_port); +cvmx_helper_interface_mode_t interface_mode = +cvmx_helper_interface_get_mode (interface_num); + +/* The following are not found in the device tree */ +switch (interface_mode) { +case CVMX_HELPER_INTERFACE_MODE_ILK : +case CVMX_HELPER_INTERFACE_MODE_LOOP : +case CVMX_HELPER_INTERFACE_MODE_SRIO : +debug ("ERROR: No node expected for interface: %d, port: %d, mode: %s\n" , + interface_index, ipd_port, +cvmx_helper_interface_mode_to_string (interface_mode)); +return -1 ; +default : +break ; + } + pip_path = (const char *)fdt_getprop (fdt_addr, aliases,"pip" ,NULL ); +if (!pip_path) { +debug ("ERROR: pip path not found in device tree\n" ); +return -1 ; + } + pip =fdt_path_offset (fdt_addr, pip_path); +debug ("ipdd_port=%d pip_path=%s pip=%d " , ipd_port, pip_path, pip); +if (pip <0 ) { +debug ("ERROR: pip not found in device tree\n" ); +return -1 ; + } +snprintf (name_buffer,sizeof (name_buffer),"interface@%d" , + interface_num); + iface =fdt_subnode_offset (fdt_addr, pip, name_buffer); +debug ("iface=%d " , iface); +if (iface <0 ) { +debug ("ERROR : pip intf %d not found in device tree\n" , + interface_num); +return -1 ; + } +snprintf (name_buffer,sizeof (name_buffer),"ethernet@%x" , + interface_index); + eth =fdt_subnode_offset (fdt_addr, iface, name_buffer); +debug ("eth=%d\n" , eth); +if (eth <0 ) { +debug ("ERROR : pip interface@%d ethernet@%d not found in device tree\n" , + interface_num, interface_index); +return -1 ; + } +return eth; +} + +int __mix_eth_node (const void *fdt_addr,int aliases,int interface_index) +{ +char name_buffer[20 ]; +const char *mix_path; +int mix; + +snprintf (name_buffer,sizeof (name_buffer),"mix%d" , interface_index); + mix_path = + (const char *)fdt_getprop (fdt_addr, aliases, name_buffer,NULL ); +if (!mix_path) { +debug ("ERROR: mix%d path not found in device tree\n" , + interface_index); + } + mix =fdt_path_offset (fdt_addr, mix_path); +if (mix <0 ) { +debug ("ERROR: %s not found in device tree\n" , mix_path); +return -1 ; + } +return mix; +} + +static int __mdiobus_addr_to_unit (u32 addr) +{ +int unit = (addr >>7 ) &3 ; + +if (!OCTEON_IS_MODEL (OCTEON_CN68XX ) && !OCTEON_IS_MODEL (OCTEON_CN78XX )) + unit >>=1 ; +return unit; +} + +/** +* Parse the muxed MDIO interface information from the device tree +* +* @param phy_info - pointer to phy info data structure to update +* @param mdio_offset - offset of MDIO bus +* @param mux_offset - offset of MUX, parent of mdio_offset +* +* @return 0 for success or -1 +*/ +static int __get_muxed_mdio_info_from_dt (cvmx_phy_info_t *phy_info, +int mdio_offset,int mux_offset) +{ + const void *fdt_addr = CASTPTR(const void *, gd->fdt_blob); +int phandle; +int smi_offset; +int gpio_offset; +u64 smi_addr =0 ; +int len; +u32 *pgpio_handle; +int gpio_count =0 ; +u32 *prop_val; +int offset; +const char *prop_name; + +debug ("%s(%p, 0x%x, 0x%x)\n" , __func__, phy_info, mdio_offset, + mux_offset); + +/* Get register value to put onto the GPIO lines to select */ + phy_info->gpio_value = +cvmx_fdt_get_int (fdt_addr, mdio_offset,"reg" ,-1 ); +if (phy_info->gpio_value <0 ) { +debug ("Could not get register value for muxed MDIO bus from DT\n" ); +return -1 ; + } + + smi_offset =cvmx_fdt_lookup_phandle (fdt_addr, mux_offset, +"mdio-parent-bus" ); +if (smi_offset <0 ) { +debug ("Invalid SMI offset for muxed MDIO interface in device tree\n" ); +return -1 ; + } + smi_addr =cvmx_fdt_get_uint64 (fdt_addr, smi_offset,"reg" ,0 ); + +/* Convert SMI address to a MDIO interface */ +switch (smi_addr) { +case 0x1180000001800 : +case 0x1180000003800 :/* 68XX address */ + phy_info->mdio_unit =0 ; +break ; +case 0x1180000001900 : +case 0x1180000003880 : + phy_info->mdio_unit =1 ; +break ; +case 0x1180000003900 : + phy_info->mdio_unit =2 ; +break ; +case 0x1180000003980 : + phy_info->mdio_unit =3 ; +break ; +default : + phy_info->mdio_unit =1 ; +break ; + } +/* Find the GPIO MUX controller */ + pgpio_handle = + (u32 *)fdt_getprop (fdt_addr, mux_offset,"gpios" , &len); +if (!pgpio_handle || len <12 || (len %12 ) !=0 || + len >CVMX_PHY_MUX_MAX_GPIO *12 ) { +debug ("Invalid GPIO for muxed MDIO controller in DT\n" ); +return -1 ; + } + +for (gpio_count =0 ; gpio_count < len /12 ; gpio_count++) { + phandle =fdt32_to_cpu (pgpio_handle[gpio_count *3 ]); + phy_info->gpio[gpio_count] = +fdt32_to_cpu (pgpio_handle[gpio_count *3 +1 ]); + gpio_offset =fdt_node_offset_by_phandle (fdt_addr, phandle); +if (gpio_offset <0 ) { +debug ("Cannot access parent GPIO node in DT\n" ); +return -1 ; + } +if (!fdt_node_check_compatible (fdt_addr, gpio_offset, +"cavium,octeon-3860-gpio" )) { + phy_info->gpio_type[gpio_count] =GPIO_OCTEON ; + }else if (!fdt_node_check_compatible (fdt_addr, gpio_offset, +"nxp,pca8574" )) { +/* GPIO is a TWSI GPIO unit which might sit behind +* another mux. +*/ + phy_info->gpio_type[gpio_count] =GPIO_PCA8574 ; + prop_val = (u32 *)fdt_getprop ( + fdt_addr, gpio_offset,"reg" ,NULL ); +if (!prop_val) { +debug ("Could not find TWSI address of npx pca8574 GPIO from DT\n" ); +return -1 ; + } +/* Get the TWSI address of the GPIO unit */ + phy_info->cvmx_gpio_twsi[gpio_count] = +fdt32_to_cpu (*prop_val); +/* Get the selector on the GPIO mux if present */ + offset =fdt_parent_offset (fdt_addr, gpio_offset); + prop_val = (u32 *)fdt_getprop (fdt_addr, offset, +"reg" ,NULL ); +if (prop_val) { + phy_info->gpio_parent_mux_select = +fdt32_to_cpu (*prop_val); +/* Go up another level */ + offset =fdt_parent_offset (fdt_addr, offset); +if (!fdt_node_check_compatible (fdt_addr, offset, +"nxp,pca9548" )) { + prop_val = (u32 *)fdt_getprop ( + fdt_addr, offset,"reg" ,NULL ); +if (!prop_val) { +debug ("Could not read MUX TWSI address from DT\n" ); +return -1 ; + } + phy_info->gpio_parent_mux_twsi = +fdt32_to_cpu (*prop_val); + } + } + }else { + prop_name = (char *)fdt_getprop (fdt_addr, gpio_offset, +"compatible" ,NULL ); +debug ("Unknown GPIO type %s\n" , prop_name); +return -1 ; + } + } +return 0 ; +} + +/** +* @INTERNAL +* Converts a BGX address to the node, interface and port number +* +* @param bgx_addr Address of CSR register +* +* @return node, interface and port number, will be -1 for invalid address. +*/ +static struct cvmx_xiface __cvmx_bgx_reg_addr_to_xiface (u64 bgx_addr) +{ +struct cvmx_xiface xi = {-1 ,-1 }; + + xi.node =cvmx_csr_addr_to_node (bgx_addr); + bgx_addr =cvmx_csr_addr_strip_node (bgx_addr); +if ((bgx_addr &0xFFFFFFFFF0000000 ) !=0x00011800E0000000 ) { +debug ("%s: Invalid BGX address 0x%llx\n" , __func__, + (unsigned long long )bgx_addr); + xi.node =-1 ; +return xi; + } + xi.interface = (bgx_addr >>24 ) &0x0F ; + +return xi; +} + +static cvmx_helper_link_info_t +__get_marvell_phy_link_state (cvmx_phy_info_t *phy_info) +{ +cvmx_helper_link_info_t result; +int phy_status; +u32 phy_addr = phy_info->phy_addr; + + result.u64 =0 ; +/* Set to page 0 */ +cvmx_mdio_write (phy_addr >>8 , phy_addr &0xff ,22 ,0 ); +/* All the speed information can be read from register 17 in one go. */ + phy_status =cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,17 ); + +/* If the resolve bit 11 isn't set, see if autoneg is turned off +* (bit 12, reg 0). The resolve bit doesn't get set properly when +* autoneg is off, so force it +*/ +if ((phy_status & (1 <<11 )) ==0 ) { +int auto_status = +cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,0 ); +if ((auto_status & (1 <<12 )) ==0 ) + phy_status |=1 <<11 ; + } + +/* Link is up = Speed/Duplex Resolved + RT-Link Up + G-Link Up. */ +if ((phy_status &0x0c08 ) ==0x0c08 ) { + result.s.link_up =1 ; + result.s.full_duplex = ((phy_status >>13 ) &1 ); +switch ((phy_status >>14 ) &3 ) { +case 0 :/* 10 Mbps */ + result.s.speed =10 ; +break ; +case 1 :/* 100 Mbps */ + result.s.speed =100 ; +break ; +case 2 :/* 1 Gbps */ + result.s.speed =1000 ; +break ; +case 3 :/* Illegal */ + result.u64 =0 ; +break ; + } + } +return result; +} + +/** +* @INTERNAL +* Get link state of broadcom PHY +* +* @param phy_info PHY information +*/ +static cvmx_helper_link_info_t +__get_broadcom_phy_link_state (cvmx_phy_info_t *phy_info) +{ +cvmx_helper_link_info_t result; +u32 phy_addr = phy_info->phy_addr; +int phy_status; + + result.u64 =0 ; +/* Below we are going to read SMI/MDIO register 0x19 which works +* on Broadcom parts +*/ + phy_status =cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,0x19 ); +switch ((phy_status >>8 ) &0x7 ) { +case 0 : + result.u64 =0 ; +break ; +case 1 : + result.s.link_up =1 ; + result.s.full_duplex =0 ; + result.s.speed =10 ; +break ; +case 2 : + result.s.link_up =1 ; + result.s.full_duplex =1 ; + result.s.speed =10 ; +break ; +case 3 : + result.s.link_up =1 ; + result.s.full_duplex =0 ; + result.s.speed =100 ; +break ; +case 4 : + result.s.link_up =1 ; + result.s.full_duplex =1 ; + result.s.speed =100 ; +break ; +case 5 : + result.s.link_up =1 ; + result.s.full_duplex =1 ; + result.s.speed =100 ; +break ; +case 6 : + result.s.link_up =1 ; + result.s.full_duplex =0 ; + result.s.speed =1000 ; +break ; +case 7 : + result.s.link_up =1 ; + result.s.full_duplex =1 ; + result.s.speed =1000 ; +break ; + } +return result; +} + +/** +* @INTERNAL +* Get link state of generic gigabit PHY +* +* @param phy_info - information about the PHY +* +* @returns link status of the PHY +*/ +static cvmx_helper_link_info_t +__cvmx_get_generic_8023_c22_phy_link_state (cvmx_phy_info_t *phy_info) +{ +cvmx_helper_link_info_t result; +u32 phy_addr = phy_info->phy_addr; +int phy_basic_control;/* Register 0x0 */ +int phy_basic_status;/* Register 0x1 */ +int phy_anog_adv;/* Register 0x4 */ +int phy_link_part_avail;/* Register 0x5 */ +int phy_control;/* Register 0x9 */ +int phy_status;/* Register 0xA */ + + result.u64 =0 ; + + phy_basic_status =cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,1 ); +if (!(phy_basic_status &0x4 ))/* Check if link is up */ +return result;/* Link is down, return link down */ + + result.s.link_up =1 ; + phy_basic_control =cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,0 ); +/* Check if autonegotiation is enabled and completed */ +if ((phy_basic_control & (1 <<12 )) && (phy_basic_status & (1 <<5 ))) { + phy_status = +cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,0xA ); + phy_control = +cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,0x9 ); + + phy_status &= phy_control <<2 ; + phy_link_part_avail = +cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,0x5 ); + phy_anog_adv = +cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,0x4 ); + phy_link_part_avail &= phy_anog_adv; + +if (phy_status &0xC00 ) {/* Gigabit full or half */ + result.s.speed =1000 ; + result.s.full_duplex = !!(phy_status &0x800 ); + }else if (phy_link_part_avail & +0x0180 ) {/* 100 full or half */ + result.s.speed =100 ; + result.s.full_duplex = !!(phy_link_part_avail &0x100 ); + }else if (phy_link_part_avail &0x0060 ) { + result.s.speed =10 ; + result.s.full_duplex = !!(phy_link_part_avail &0x0040 ); + } + }else { +/* Not autonegotiated */ + result.s.full_duplex = !!(phy_basic_control & (1 <<8 )); + +if (phy_basic_control & (1 <<6 )) + result.s.speed =1000 ; +else if (phy_basic_control & (1 <<13 )) + result.s.speed =100 ; +else + result.s.speed =10 ; + } +return result; +} + +static cvmx_helper_link_info_t +__cvmx_get_qualcomm_s17_phy_link_state (cvmx_phy_info_t *phy_info) +{ +cvmx_helper_link_info_t result; +u32 phy_addr = phy_info->phy_addr; +int phy_status; +int auto_status; + + result.u64 =0 ; + + phy_status =cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,17 ); + +/* If bit 11 isn't set see if autonegotiation is turned off +* (bit 12, reg 0). The resolved bit doesn't get set properly when +* autonegotiation is off, so force it. +*/ +if ((phy_status & (1 <<11 )) ==0 ) { + auto_status =cvmx_mdio_read (phy_addr >>8 , phy_addr &0xff ,0 ); +if ((auto_status & (1 <<12 )) ==0 ) + phy_status |=1 <<11 ; + } +/* Only return a link if the PHY has finished autonegotiation and set +* the resolved bit (bit 11). +*/ +if (phy_status & (1 <<11 )) { + result.s.link_up =1 ; + result.s.full_duplex = !!(phy_status & (1 <<13 )); +switch ((phy_status >>14 ) &3 ) { +case 0 :/* 10Mbps */ + result.s.speed =10 ; +break ; +case 1 :/* 100Mbps */ + result.s.speed =100 ; +break ; +case 2 :/* 1Gbps */ + result.s.speed =1000 ; +break ; +default :/* Illegal */ + result.u64 =0 ; +break ; + } + } +debug (" link: %s, duplex: %s, speed: %lu\n" , + result.s.link_up ?"up" :"down" , + result.s.full_duplex ?"full" :"half" , + (unsigned long )result.s.speed); +return result; +} + +static cvmx_helper_link_info_t +__get_generic_8023_c45_phy_link_state (cvmx_phy_info_t *phy_info) +{ +cvmx_helper_link_info_t result; +int phy_status; +int pma_ctrl1; +u32 phy_addr = phy_info->phy_addr; + + result.u64 =0 ; + pma_ctrl1 =cvmx_mdio_45_read (phy_addr >>8 , phy_addr &0xff ,1 ,0 ); +if ((pma_ctrl1 &0x207c ) ==0x2040 ) + result.s.speed =10000 ; +/* PMA Status 1 (1x0001) */ + phy_status =cvmx_mdio_45_read (phy_addr >>8 , phy_addr &0xff ,1 ,0xa ); +if (phy_status <0 ) +return result; + + result.s.full_duplex =1 ; +if ((phy_status &1 ) ==0 ) +return result; + phy_status =cvmx_mdio_45_read (phy_addr >>8 , phy_addr &0xff ,4 ,0x18 ); +if (phy_status <0 ) +return result; + result.s.link_up = (phy_status &0x1000 ) ?1 :0 ; + +return result; +} + +static cvmx_helper_link_info_t +__cvmx_get_cortina_phy_link_state (cvmx_phy_info_t *phy_info) +{ +cvmx_helper_link_info_t result; + + result.s.link_up =1 ; + result.s.full_duplex =1 ; + result.s.speed =1000 ; +return result; +} + +static cvmx_helper_link_info_t +__get_vitesse_vsc8490_phy_link_state (cvmx_phy_info_t *phy_info) +{ +cvmx_helper_link_info_t result; + + result.s.link_up =1 ; + result.s.full_duplex =1 ; + result.s.speed =1000 ; +return result; +} + +static cvmx_helper_link_info_t +__get_aquantia_phy_link_state (cvmx_phy_info_t *phy_info) +{ +cvmx_helper_link_info_t result; + + result.s.link_up =1 ; + result.s.full_duplex =1 ; + result.s.speed =1000 ; +return result; +} + +static int __cvmx_helper_78xx_parse_phy (struct cvmx_phy_info *phy_info, +int ipd_port) +{ + const void *fdt_addr = CASTPTR(const void *, gd->fdt_blob); +const char *compat; +int phy; +int parent; +u64 mdio_base; +int node, bus; +int phy_addr; +int index =cvmx_helper_get_interface_index_num (ipd_port); +int xiface =cvmx_helper_get_interface_num (ipd_port); +int compat_len =0 ; + +debug ("%s(0x%p, %d) ENTER\n" , __func__, phy_info, ipd_port); + + phy =cvmx_helper_get_phy_fdt_node_offset (xiface, index); +debug ("%s: xiface: 0x%x, index: %d, ipd_port: %d, phy fdt offset: %d\n" , + __func__, xiface, index, ipd_port, phy); +if (phy <0 ) { +/* If this is the first time through we need to first parse the +* device tree to get the node offsets. +*/ +debug ("No config present, calling __cvmx_helper_parse_bgx_dt\n" ); +if (__cvmx_helper_parse_bgx_dt (fdt_addr)) { +printf ("Error: could not parse BGX device tree\n" ); +return -1 ; + } +if (__cvmx_fdt_parse_vsc7224 (fdt_addr)) { +debug ("Error: could not parse Microsemi VSC7224 in DT\n" ); +return -1 ; + } +if (octeon_has_feature (OCTEON_FEATURE_BGX_XCV ) && +__cvmx_helper_parse_bgx_rgmii_dt (fdt_addr)) { +printf ("Error: could not parse BGX XCV device tree\n" ); +return -1 ; + } + phy =cvmx_helper_get_phy_fdt_node_offset (xiface, index); +if (phy <0 ) { +debug ("%s: Could not get PHY node offset for IPD port 0x%x, xiface: 0x%x, index: %d\n" , + __func__, ipd_port, xiface, index); +return -1 ; + } +debug ("%s: phy: %d (%s)\n" , __func__, phy, +fdt_get_name (fdt_addr, phy,NULL )); + } + + compat = (const char *)fdt_getprop (fdt_addr, phy,"compatible" , + &compat_len); +if (!compat) { +printf ("ERROR: %d:%d:no compatible prop in phy\n" , xiface, + index); +return -1 ; + } + +debug (" compatible: %s\n" , compat); + + phy_info->fdt_offset = phy; + phy_addr =cvmx_fdt_get_int (fdt_addr, phy,"reg" ,-1 ); +if (phy_addr ==-1 ) { +printf ("Error: %d:%d:could not get PHY address\n" , xiface, + index); +return -1 ; + } +debug (" PHY address: %d, compat: %s\n" , phy_addr, compat); + +if (!memcmp ("marvell" , compat,strlen ("marvell" ))) { + phy_info->phy_type =MARVELL_GENERIC_PHY ; + phy_info->link_function = __get_marvell_phy_link_state; + }else if (!memcmp ("broadcom" , compat,strlen ("broadcom" ))) { + phy_info->phy_type =BROADCOM_GENERIC_PHY ; + phy_info->link_function = __get_broadcom_phy_link_state; + }else if (!memcmp ("cortina" , compat,strlen ("cortina" ))) { + phy_info->phy_type =CORTINA_PHY ; + phy_info->link_function = __cvmx_get_cortina_phy_link_state; + }else if (!strcmp ("vitesse,vsc8490" , compat)) { + phy_info->phy_type =VITESSE_VSC8490_PHY ; + phy_info->link_function = __get_vitesse_vsc8490_phy_link_state; + }else if (fdt_stringlist_contains (compat, compat_len, +"ethernet-phy-ieee802.3-c22" )) { + phy_info->phy_type =GENERIC_8023_C22_PHY ; + phy_info->link_function = + __cvmx_get_generic_8023_c22_phy_link_state; + }else if (fdt_stringlist_contains (compat, compat_len, +"ethernet-phy-ieee802.3-c45" )) { + phy_info->phy_type =GENERIC_8023_C22_PHY ; + phy_info->link_function = __get_generic_8023_c45_phy_link_state; + } + + phy_info->ipd_port = ipd_port; + phy_info->phy_sub_addr =0 ; + phy_info->direct_connect =1 ; + + parent =fdt_parent_offset (fdt_addr, phy); +if (!fdt_node_check_compatible (fdt_addr, parent, +"ethernet-phy-nexus" )) { +debug (" nexus PHY found\n" ); +if (phy_info->phy_type ==CORTINA_PHY ) { +/* The Cortina CS422X uses the same PHY device for +* multiple ports for XFI. In this case we use a +* nexus and each PHY address is the slice or +* sub-address and the actual PHY address is the +* nexus address. +*/ + phy_info->phy_sub_addr = phy_addr; + phy_addr = +cvmx_fdt_get_int (fdt_addr, parent,"reg" ,-1 ); +debug (" Cortina PHY real address: 0x%x\n" , phy_addr); + } + parent =fdt_parent_offset (fdt_addr, parent); + } + +debug (" Parent: %s\n" ,fdt_get_name (fdt_addr, parent,NULL )); +if (!fdt_node_check_compatible (fdt_addr, parent, +"cavium,octeon-3860-mdio" )) { +debug (" Found Octeon MDIO\n" ); + mdio_base =cvmx_fdt_get_uint64 (fdt_addr, parent,"reg" , +FDT_ADDR_T_NONE ); +debug (" MDIO address: 0x%llx\n" , + (unsigned long long )mdio_base); + + mdio_base =cvmx_fdt_translate_address (fdt_addr, parent, + (u32 *)&mdio_base); +debug (" Translated: 0x%llx\n" , (unsigned long long )mdio_base); +if (mdio_base ==FDT_ADDR_T_NONE ) { +printf ("Could not get MDIO base address from reg field\n" ); +return -1 ; + } +__cvmx_mdio_addr_to_node_bus (mdio_base, &node, &bus); +if (bus <0 ) { +printf ("Invalid MDIO address 0x%llx, could not detect bus and node\n" , + (unsigned long long )mdio_base); +return -1 ; + } +debug (" MDIO node: %d, bus: %d\n" , node, bus); + phy_info->mdio_unit = (node <<2 ) | (bus &3 ); + phy_info->phy_addr = phy_addr | (phy_info->mdio_unit <<8 ); + }else { +printf ("%s: Error: incompatible MDIO bus %s for IPD port %d\n" , + __func__, + (const char *)fdt_get_name (fdt_addr, parent,NULL ), + ipd_port); +return -1 ; + } + +debug ("%s: EXIT 0\n" , __func__); + +return 0 ; +} + +/** +* Return the MII PHY address associated with the given IPD +* port. The phy address is obtained from the device tree. +* +* @param[out] phy_info - PHY information data structure updated +* @param ipd_port Octeon IPD port to get the MII address for. +* +* @return MII PHY address and bus number, -1 on error, -2 if PHY info missing (OK). +*/ +static int __get_phy_info_from_dt (cvmx_phy_info_t *phy_info,int ipd_port) +{ + const void *fdt_addr = CASTPTR(const void *, gd->fdt_blob); +int aliases, eth, phy, phy_parent, ret, i; +int mdio_parent; +const char *phy_compatible_str; +const char *host_mode_str =NULL ; +int interface; +int phy_addr_offset =0 ; + +debug ("%s(%p, %d)\n" , __func__, phy_info, ipd_port); + +if (octeon_has_feature (OCTEON_FEATURE_BGX )) +return __cvmx_helper_78xx_parse_phy (phy_info, ipd_port); + + phy_info->phy_addr =-1 ; + phy_info->phy_sub_addr =0 ; + phy_info->ipd_port = ipd_port; + phy_info->direct_connect =-1 ; + phy_info->phy_type = (cvmx_phy_type_t)-1 ; +for (i =0 ; i <CVMX_PHY_MUX_MAX_GPIO ; i++) + phy_info->gpio[i] =-1 ; + phy_info->mdio_unit =-1 ; + phy_info->gpio_value =-1 ; + phy_info->gpio_parent_mux_twsi =-1 ; + phy_info->gpio_parent_mux_select =-1 ; + phy_info->link_function =NULL ; + phy_info->fdt_offset =-1 ; +if (!fdt_addr) { +debug ("No device tree found.\n" ); +return -1 ; + } + + aliases =fdt_path_offset (fdt_addr,"/aliases" ); +if (aliases <0 ) { +debug ("Error: No /aliases node in device tree.\n" ); +return -1 ; + } +if (ipd_port <0 ) { +int interface_index = + ipd_port -CVMX_HELPER_BOARD_MGMT_IPD_PORT ; + eth =__mix_eth_node (fdt_addr, aliases, interface_index); + }else { + eth =__pip_eth_node (fdt_addr, aliases, ipd_port); + } +if (eth <0 ) { +debug ("ERROR : cannot find interface for ipd_port=%d\n" , + ipd_port); +return -1 ; + } + + interface =cvmx_helper_get_interface_num (ipd_port); +/* Get handle to phy */ + phy =cvmx_fdt_lookup_phandle (fdt_addr, eth,"phy-handle" ); +if (phy <0 ) { +cvmx_helper_interface_mode_t if_mode; + +/* Note that it's OK for RXAUI and ILK to not have a PHY +* connected (i.e. EBB boards in loopback). +*/ +debug ("Cannot get phy-handle for ipd_port: %d\n" , ipd_port); + if_mode =cvmx_helper_interface_get_mode (interface); +if (if_mode !=CVMX_HELPER_INTERFACE_MODE_RXAUI && + if_mode !=CVMX_HELPER_INTERFACE_MODE_ILK ) { +debug ("ERROR : phy handle not found in device tree ipd_port=%d\n" , + ipd_port); +return -1 ; + }else { +return -2 ; + } + } + + phy_compatible_str = + (const char *)fdt_getprop (fdt_addr, phy,"compatible" ,NULL ); +if (!phy_compatible_str) { +debug ("ERROR: no compatible prop in phy\n" ); +return -1 ; + } +debug ("Checking compatible string \"%s\" for ipd port %d\n" , + phy_compatible_str, ipd_port); + phy_info->fdt_offset = phy; +if (!memcmp ("marvell" , phy_compatible_str,strlen ("marvell" ))) { +debug ("Marvell PHY detected for ipd_port %d\n" , ipd_port); + phy_info->phy_type =MARVELL_GENERIC_PHY ; + phy_info->link_function = __get_marvell_phy_link_state; + }else if (!memcmp ("broadcom" , phy_compatible_str, +strlen ("broadcom" ))) { + phy_info->phy_type =BROADCOM_GENERIC_PHY ; + phy_info->link_function = __get_broadcom_phy_link_state; +debug ("Broadcom PHY detected for ipd_port %d\n" , ipd_port); + }else if (!memcmp ("vitesse" , phy_compatible_str,strlen ("vitesse" ))) { +debug ("Vitesse PHY detected for ipd_port %d\n" , ipd_port); +if (!fdt_node_check_compatible (fdt_addr, phy, +"vitesse,vsc8490" )) { + phy_info->phy_type =VITESSE_VSC8490_PHY ; +debug ("Vitesse VSC8490 detected\n" ); + phy_info->link_function = + __get_vitesse_vsc8490_phy_link_state; + }else if (!fdt_node_check_compatible ( + fdt_addr, phy, +"ethernet-phy-ieee802.3-c22" )) { + phy_info->phy_type =GENERIC_8023_C22_PHY ; + phy_info->link_function = + __cvmx_get_generic_8023_c22_phy_link_state; +debug ("Vitesse 802.3 c22 detected\n" ); + }else { + phy_info->phy_type =GENERIC_8023_C45_PHY ; + phy_info->link_function = + __get_generic_8023_c45_phy_link_state; +debug ("Vitesse 802.3 c45 detected\n" ); + } + }else if (!memcmp ("aquantia" , phy_compatible_str, +strlen ("aquantia" ))) { + phy_info->phy_type =AQUANTIA_PHY ; + phy_info->link_function = __get_aquantia_phy_link_state; +debug ("Aquantia c45 PHY detected\n" ); + }else if (!memcmp ("cortina" , phy_compatible_str,strlen ("cortina" ))) { + phy_info->phy_type =CORTINA_PHY ; + phy_info->link_function = __cvmx_get_cortina_phy_link_state; + host_mode_str = (const char *)fdt_getprop ( + fdt_addr, phy,"cortina,host-mode" ,NULL ); +debug ("Cortina PHY detected for ipd_port %d\n" , ipd_port); + }else if (!memcmp ("ti" , phy_compatible_str,strlen ("ti" ))) { + phy_info->phy_type =GENERIC_8023_C45_PHY ; + phy_info->link_function = __get_generic_8023_c45_phy_link_state; +debug ("TI PHY detected for ipd_port %d\n" , ipd_port); + }else if (!fdt_node_check_compatible (fdt_addr, phy, +"atheros,ar8334" ) || + !fdt_node_check_compatible (fdt_addr, phy, +"qualcomm,qca8334" ) || + !fdt_node_check_compatible (fdt_addr, phy, +"atheros,ar8337" ) || + !fdt_node_check_compatible (fdt_addr, phy, +"qualcomm,qca8337" )) { + phy_info->phy_type =QUALCOMM_S17 ; + phy_info->link_function = + __cvmx_get_qualcomm_s17_phy_link_state; +debug ("Qualcomm QCA833X switch detected\n" ); + }else if (!fdt_node_check_compatible (fdt_addr, phy, +"ethernet-phy-ieee802.3-c22" )) { + phy_info->phy_type =GENERIC_8023_C22_PHY ; + phy_info->link_function = + __cvmx_get_generic_8023_c22_phy_link_state; +debug ("Generic 802.3 c22 PHY detected\n" ); + }else if (!fdt_node_check_compatible (fdt_addr, phy, +"ethernet-phy-ieee802.3-c45" )) { + phy_info->phy_type =GENERIC_8023_C45_PHY ; + phy_info->link_function = __get_generic_8023_c45_phy_link_state; +debug ("Generic 802.3 c45 PHY detected\n" ); + }else { +debug ("Unknown PHY compatibility\n" ); + phy_info->phy_type = (cvmx_phy_type_t)-1 ; + phy_info->link_function =NULL ; + } + + phy_info->host_mode =CVMX_PHY_HOST_MODE_UNKNOWN ; +if (host_mode_str) { +if (strcmp (host_mode_str,"rxaui" ) ==0 ) + phy_info->host_mode =CVMX_PHY_HOST_MODE_RXAUI ; +else if (strcmp (host_mode_str,"xaui" ) ==0 ) + phy_info->host_mode =CVMX_PHY_HOST_MODE_XAUI ; +else if (strcmp (host_mode_str,"sgmii" ) ==0 ) + phy_info->host_mode =CVMX_PHY_HOST_MODE_SGMII ; +else if (strcmp (host_mode_str,"qsgmii" ) ==0 ) + phy_info->host_mode =CVMX_PHY_HOST_MODE_QSGMII ; +else +debug ("Unknown PHY host mode\n" ); + } + +/* Check if PHY parent is the octeon MDIO bus. Some boards are connected +* though a MUX and for them direct_connect_to_phy will be 0 +*/ + phy_parent =fdt_parent_offset (fdt_addr, phy); +if (phy_parent <0 ) { +debug ("ERROR : cannot find phy parent for ipd_port=%d ret=%d\n" , + ipd_port, phy_parent); +return -1 ; + } +/* For multi-phy devices and devices on a MUX, go to the parent */ + ret =fdt_node_check_compatible (fdt_addr, phy_parent, +"ethernet-phy-nexus" ); +if (ret ==0 ) { +/* It's a nexus so check the grandparent. */ + phy_addr_offset = +cvmx_fdt_get_int (fdt_addr, phy_parent,"reg" ,0 ); + phy_parent =fdt_parent_offset (fdt_addr, phy_parent); + } + +/* Check for a muxed MDIO interface */ + mdio_parent =fdt_parent_offset (fdt_addr, phy_parent); + ret =fdt_node_check_compatible (fdt_addr, mdio_parent, +"cavium,mdio-mux" ); +if (ret ==0 ) { + ret =__get_muxed_mdio_info_from_dt (phy_info, phy_parent, + mdio_parent); +if (ret) { +printf ("Error reading mdio mux information for ipd port %d\n" , + ipd_port); +return -1 ; + } + } + ret =fdt_node_check_compatible (fdt_addr, phy_parent, +"cavium,octeon-3860-mdio" ); +if (ret ==0 ) { +u32 *mdio_reg_base = + (u32 *)fdt_getprop (fdt_addr, phy_parent,"reg" ,0 ); + phy_info->direct_connect =1 ; +if (mdio_reg_base ==0 ) { +debug ("ERROR : unable to get reg property in phy mdio\n" ); +return -1 ; + } + phy_info->mdio_unit = +__mdiobus_addr_to_unit (fdt32_to_cpu (mdio_reg_base[1 ])); +debug ("phy parent=%s reg_base=%08x mdio_unit=%d\n" , +fdt_get_name (fdt_addr, phy_parent,NULL ), + (int )mdio_reg_base[1 ], phy_info->mdio_unit); + }else { + phy_info->direct_connect =0 ; +/* The PHY is not directly connected to the Octeon MDIO bus. +* SE doesn't have abstractions for MDIO MUX or MDIO MUX +* drivers and hence for the non direct cases code will be +* needed which is board specific. +* For now the MDIO Unit is defaulted to 1. +*/ +debug ("%s PHY at address: %d is not directly connected\n" , + __func__, phy_info->phy_addr); + } + + phy_info->phy_addr =cvmx_fdt_get_int (fdt_addr, phy,"reg" ,-1 ); +if (phy_info->phy_addr <0 ) { +debug ("ERROR: Could not read phy address from reg in DT\n" ); +return -1 ; + } + phy_info->phy_addr += phy_addr_offset; + phy_info->phy_addr |= phy_info->mdio_unit <<8 ; +debug ("%s(%p, %d) => 0x%x\n" , __func__, phy_info, ipd_port, + phy_info->phy_addr); +return phy_info->phy_addr; +} + +/** +* @INTERNAL +* This function outputs the cvmx_phy_info_t data structure for the specified +* port. +* +* @param phy_info - phy info data structure +* @param ipd_port - port to get phy info for +* +* @return 0 for success, -1 if info not available +* +* NOTE: The phy_info data structure is subject to change. +*/ +int cvmx_helper_board_get_phy_info (cvmx_phy_info_t *phy_info,int ipd_port) +{ +int retcode; + + retcode =__get_phy_info_from_dt (phy_info, ipd_port); + +return (retcode >=0 ) ?0 :-1 ; +} + +/** +* Return the MII PHY address associated with the given IPD +* port. The phy address is obtained from the device tree. +* +* @param ipd_port Octeon IPD port to get the MII address for. +* +* @return MII PHY address and bus number or -1 on error, -2 if phy info missing (OK). +*/ +int cvmx_helper_board_get_mii_address_from_dt (int ipd_port) +{ +cvmx_phy_info_t phy_info; +int retcode =__get_phy_info_from_dt (&phy_info, ipd_port); + +if (retcode >=0 ) +return phy_info.phy_addr; +else +return retcode; +} + +/** +* Return the MII PHY address associated with the given IPD +* port. A result of -1 means there isn't a MII capable PHY +* connected to this port. On chips supporting multiple MII +* busses the bus number is encoded in bits <15:8>. +* +* This function must be modified for every new Octeon board. +* Internally it uses switch statements based on the cvmx_sysinfo +* data to determine board types and revisions. It replies on the +* fact that every Octeon board receives a unique board type +* enumeration from the bootloader. +* +* @param ipd_port Octeon IPD port to get the MII address for. +* +* @return MII PHY address and bus number or -1. +*/ +int cvmx_helper_board_get_mii_address (int ipd_port) +{ +cvmx_phy_info_t phy_info; +int retcode; + +debug ("%s(0x%x) getting phy info from device tree\n" , __func__, + ipd_port); +memset (&phy_info,0 ,sizeof (phy_info)); + retcode =__get_phy_info_from_dt (&phy_info, ipd_port); + +if (retcode ==-2 ) { +debug ("%s(0x%x): phy info missing in device tree\n" , __func__, + ipd_port); +return retcode; + }else if (retcode <0 ) { +debug ("%s: could not get phy info for port %d\n" , __func__, + ipd_port); +return retcode; + } +debug ("%s: phy address: 0x%x\n" , __func__, phy_info.phy_addr); + +/* Some unknown board. Somebody forgot to update this function... */ +debug ("%s: Unknown board type\n" , __func__); +return -1 ; +} + +/** +* @INTERNAL +* Parse the device tree and set whether a port is valid or not. +* +* @param fdt_addr Pointer to device tree +* +* @return 0 for success, -1 on error. +*/ +int __cvmx_helper_parse_bgx_dt (const void *fdt_addr) +{ +int port_index; +struct cvmx_xiface xi; +int fdt_port_node =-1 ; +int fdt_interface_node; +int fdt_phy_node; +u64 reg_addr; +int xiface; +struct cvmx_phy_info *phy_info; +static bool parsed; +int err; +int ipd_port; + +if (parsed) { +debug ("%s: Already parsed\n" , __func__); +return 0 ; + } +while ((fdt_port_node =fdt_node_offset_by_compatible ( + fdt_addr, fdt_port_node, +"cavium,octeon-7890-bgx-port" )) >=0 ) { +/* Get the port number */ + port_index = +cvmx_fdt_get_int (fdt_addr, fdt_port_node,"reg" ,-1 ); +if (port_index <0 ) { +debug ("Error: missing reg field for bgx port in device tree\n" ); +return -1 ; + } +debug ("%s: Parsing BGX port %d\n" , __func__, port_index); +/* Get the interface number */ + fdt_interface_node =fdt_parent_offset (fdt_addr, fdt_port_node); +if (fdt_interface_node <0 ) { +debug ("Error: device tree corrupt!\n" ); +return -1 ; + } +if (fdt_node_check_compatible (fdt_addr, fdt_interface_node, +"cavium,octeon-7890-bgx" )) { +debug ("Error: incompatible Ethernet MAC Nexus in device tree!\n" ); +return -1 ; + } + reg_addr = +cvmx_fdt_get_addr (fdt_addr, fdt_interface_node,"reg" ); +debug ("%s: BGX interface address: 0x%llx\n" , __func__, + (unsigned long long )reg_addr); +if (reg_addr ==FDT_ADDR_T_NONE ) { +debug ("Device tree BGX node has invalid address 0x%llx\n" , + (unsigned long long )reg_addr); +return -1 ; + } + reg_addr =cvmx_fdt_translate_address (fdt_addr, + fdt_interface_node, + (u32 *)®_addr); + xi =__cvmx_bgx_reg_addr_to_xiface (reg_addr); +if (xi.node <0 ) { +debug ("Device tree BGX node has invalid address 0x%llx\n" , + (unsigned long long )reg_addr); +return -1 ; + } +debug ("%s: Found BGX node %d, interface %d\n" , __func__, + xi.node, xi.interface); + xiface =cvmx_helper_node_interface_to_xiface (xi.node, + xi.interface); +cvmx_helper_set_port_fdt_node_offset (xiface, port_index, + fdt_port_node); +cvmx_helper_set_port_valid (xiface, port_index, true); + +cvmx_helper_set_port_fdt_node_offset (xiface, port_index, + fdt_port_node); +if (fdt_getprop (fdt_addr, fdt_port_node, +"cavium,sgmii-mac-phy-mode" ,NULL )) +cvmx_helper_set_mac_phy_mode (xiface, port_index, true); +else +cvmx_helper_set_mac_phy_mode (xiface, port_index, false); + +if (fdt_getprop (fdt_addr, fdt_port_node,"cavium,force-link-up" , +NULL )) +cvmx_helper_set_port_force_link_up (xiface, port_index, + true); +else +cvmx_helper_set_port_force_link_up (xiface, port_index, + false); + +if (fdt_getprop (fdt_addr, fdt_port_node, +"cavium,sgmii-mac-1000x-mode" ,NULL )) +cvmx_helper_set_1000x_mode (xiface, port_index, true); +else +cvmx_helper_set_1000x_mode (xiface, port_index, false); + +if (fdt_getprop (fdt_addr, fdt_port_node, +"cavium,disable-autonegotiation" ,NULL )) +cvmx_helper_set_port_autonegotiation (xiface, port_index, + false); +else +cvmx_helper_set_port_autonegotiation (xiface, port_index, + true); + + fdt_phy_node =cvmx_fdt_lookup_phandle (fdt_addr, fdt_port_node, +"phy-handle" ); +if (fdt_phy_node >=0 ) { +cvmx_helper_set_phy_fdt_node_offset (xiface, port_index, + fdt_phy_node); +debug ("%s: Setting PHY fdt node offset for interface 0x%x, port %d to %d\n" , + __func__, xiface, port_index, fdt_phy_node); +debug ("%s: PHY node name: %s\n" , __func__, +fdt_get_name (fdt_addr, fdt_phy_node,NULL )); +cvmx_helper_set_port_phy_present (xiface, port_index, + true); + ipd_port =cvmx_helper_get_ipd_port (xiface, port_index); +if (ipd_port >=0 ) { +debug ("%s: Allocating phy info for 0x%x:%d\n" , + __func__, xiface, port_index); + phy_info = + (cvmx_phy_info_t *)cvmx_bootmem_alloc ( +sizeof (*phy_info),0 ); +if (!phy_info) { +debug ("%s: Out of memory\n" , __func__); +return -1 ; + } +memset (phy_info,0 ,sizeof (*phy_info)); + phy_info->phy_addr =-1 ; + err =__get_phy_info_from_dt (phy_info, + ipd_port); +if (err) { +debug ("%s: Error parsing phy info for ipd port %d\n" , + __func__, ipd_port); +return -1 ; + } +cvmx_helper_set_port_phy_info ( + xiface, port_index, phy_info); +debug ("%s: Saved phy info\n" , __func__); + } + }else { +cvmx_helper_set_phy_fdt_node_offset (xiface, port_index, +-1 ); +debug ("%s: No PHY fdt node offset for interface 0x%x, port %d to %d\n" , + __func__, xiface, port_index, fdt_phy_node); +cvmx_helper_set_port_phy_present (xiface, port_index, + false); + } + } +if (!sfp_parsed) +if (cvmx_sfp_parse_device_tree (fdt_addr)) +debug ("%s: Error parsing SFP device tree\n" , __func__); + parsed = true; +return 0 ; +} + +int __cvmx_helper_parse_bgx_rgmii_dt (const void *fdt_addr) +{ +u64 reg_addr; +struct cvmx_xiface xi; +int fdt_port_node =-1 ; +int fdt_interface_node; +int fdt_phy_node; +int port_index; +int xiface; + +/* There's only one xcv (RGMII) interface, so just search for the one +* that's part of a BGX entry. +*/ +while ((fdt_port_node =fdt_node_offset_by_compatible ( + fdt_addr, fdt_port_node,"cavium,octeon-7360-xcv" )) >= +0 ) { + fdt_interface_node =fdt_parent_offset (fdt_addr, fdt_port_node); +if (fdt_interface_node <0 ) { +printf ("Error: device tree corrupt!\n" ); +return -1 ; + } +debug ("%s: XCV parent node compatible: %s\n" , __func__, + (char *)fdt_getprop (fdt_addr, fdt_interface_node, +"compatible" ,NULL )); +if (!fdt_node_check_compatible (fdt_addr, fdt_interface_node, +"cavium,octeon-7890-bgx" )) +break ; + } +if (fdt_port_node == -FDT_ERR_NOTFOUND ) { +debug ("No XCV/RGMII interface found in device tree\n" ); +return 0 ; + }else if (fdt_port_node <0 ) { +debug ("%s: Error %d parsing device tree\n" , __func__, + fdt_port_node); +return -1 ; + } + port_index =cvmx_fdt_get_int (fdt_addr, fdt_port_node,"reg" ,-1 ); +if (port_index !=0 ) { +printf ("%s: Error: port index (reg) must be 0, not %d.\n" , + __func__, port_index); +return -1 ; + } + reg_addr =cvmx_fdt_get_addr (fdt_addr, fdt_interface_node,"reg" ); +if (reg_addr ==FDT_ADDR_T_NONE ) { +printf ("%s: Error: could not get BGX interface address\n" , + __func__); +return -1 ; + } +/* We don't have to bother translating since only 78xx supports OCX and +* doesn't support RGMII. +*/ + xi =__cvmx_bgx_reg_addr_to_xiface (reg_addr); +debug ("%s: xi.node: %d, xi.interface: 0x%x, addr: 0x%llx\n" , __func__, + xi.node, xi.interface, (unsigned long long )reg_addr); +if (xi.node <0 ) { +printf ("%s: Device tree BGX node has invalid address 0x%llx\n" , + __func__, (unsigned long long )reg_addr); +return -1 ; + } +debug ("%s: Found XCV (RGMII) interface on interface %d\n" , __func__, + xi.interface); +debug (" phy handle: 0x%x\n" , +cvmx_fdt_get_int (fdt_addr, fdt_port_node,"phy-handle" ,-1 )); + fdt_phy_node = +cvmx_fdt_lookup_phandle (fdt_addr, fdt_port_node,"phy-handle" ); +debug ("%s: phy-handle node: 0x%x\n" , __func__, fdt_phy_node); + xiface =cvmx_helper_node_interface_to_xiface (xi.node, xi.interface); + +cvmx_helper_set_port_fdt_node_offset (xiface, port_index, fdt_port_node); +if (fdt_phy_node >=0 ) { +debug ("%s: Setting PHY fdt node offset for interface 0x%x, port %d to %d\n" , + __func__, xiface, port_index, fdt_phy_node); +debug ("%s: PHY node name: %s\n" , __func__, +fdt_get_name (fdt_addr, fdt_phy_node,NULL )); +cvmx_helper_set_phy_fdt_node_offset (xiface, port_index, + fdt_phy_node); +cvmx_helper_set_port_phy_present (xiface, port_index, true); + }else { +cvmx_helper_set_phy_fdt_node_offset (xiface, port_index,-1 ); +debug ("%s: No PHY fdt node offset for interface 0x%x, port %d to %d\n" , + __func__, xiface, port_index, fdt_phy_node); +cvmx_helper_set_port_phy_present (xiface, port_index, false); + } + +return 0 ; +} + +/** +* Returns if a port is present on an interface +* +* @param fdt_addr - address fo flat device tree +* @param ipd_port - IPD port number +* +* @return 1 if port is present, 0 if not present, -1 if error +*/ +int __cvmx_helper_board_get_port_from_dt (void *fdt_addr,int ipd_port) +{ +int port_index; +int aliases; +const char *pip_path; +char name_buffer[24 ]; +int pip, iface, eth; +cvmx_helper_interface_mode_t mode; +int xiface =cvmx_helper_get_interface_num (ipd_port); +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); +u32 val; +int phy_node_offset; +int parse_bgx_dt_err; +int parse_vsc7224_err; + +debug ("%s(%p, %d)\n" , __func__, fdt_addr, ipd_port); +if (octeon_has_feature (OCTEON_FEATURE_BGX )) { +static int fdt_ports_initialized; + + port_index =cvmx_helper_get_interface_index_num (ipd_port); + +if (!fdt_ports_initialized) { +if (octeon_has_feature (OCTEON_FEATURE_BGX_XCV )) { +if (!__cvmx_helper_parse_bgx_rgmii_dt (fdt_addr)) + fdt_ports_initialized =1 ; + parse_bgx_dt_err = +__cvmx_helper_parse_bgx_dt (fdt_addr); + parse_vsc7224_err = +__cvmx_fdt_parse_vsc7224 (fdt_addr); +if (!parse_bgx_dt_err && !parse_vsc7224_err) + fdt_ports_initialized =1 ; + }else { +debug ("%s: Error parsing FDT\n" , __func__); +return -1 ; + } + } + +return cvmx_helper_is_port_valid (xiface, port_index); + } + + mode =cvmx_helper_interface_get_mode (xiface); + +switch (mode) { +/* Device tree has information about the following mode types. */ +case CVMX_HELPER_INTERFACE_MODE_RGMII : +case CVMX_HELPER_INTERFACE_MODE_GMII : +case CVMX_HELPER_INTERFACE_MODE_SPI : +case CVMX_HELPER_INTERFACE_MODE_XAUI : +case CVMX_HELPER_INTERFACE_MODE_SGMII : +case CVMX_HELPER_INTERFACE_MODE_QSGMII : +case CVMX_HELPER_INTERFACE_MODE_RXAUI : +case CVMX_HELPER_INTERFACE_MODE_AGL : +case CVMX_HELPER_INTERFACE_MODE_XLAUI : +case CVMX_HELPER_INTERFACE_MODE_XFI : + aliases =1 ; +break ; +default : + aliases =0 ; +break ; + } + +/* The device tree information is present on interfaces that have phy */ +if (!aliases) +return 1 ; + + port_index =cvmx_helper_get_interface_index_num (ipd_port); + + aliases =fdt_path_offset (fdt_addr,"/aliases" ); +if (aliases <0 ) { +debug ("%s: ERROR: /aliases not found in device tree fdt_addr=%p\n" , + __func__, fdt_addr); +return -1 ; + } + + pip_path = (const char *)fdt_getprop (fdt_addr, aliases,"pip" ,NULL ); +if (!pip_path) { +debug ("%s: ERROR: interface %x pip path not found in device tree\n" , + __func__, xiface); +return -1 ; + } + pip =fdt_path_offset (fdt_addr, pip_path); +if (pip <0 ) { +debug ("%s: ERROR: interface %x pip not found in device tree\n" , + __func__, xiface); +return -1 ; + } +snprintf (name_buffer,sizeof (name_buffer),"interface@%d" , + xi.interface); + iface =fdt_subnode_offset (fdt_addr, pip, name_buffer); +if (iface <0 ) +return 0 ; +snprintf (name_buffer,sizeof (name_buffer),"ethernet@%x" , port_index); + eth =fdt_subnode_offset (fdt_addr, iface, name_buffer); +debug ("%s: eth subnode offset %d from %s\n" , __func__, eth, + name_buffer); + +if (eth <0 ) +return -1 ; + +cvmx_helper_set_port_fdt_node_offset (xiface, port_index, eth); + + phy_node_offset =cvmx_fdt_get_int (fdt_addr, eth,"phy" ,-1 ); +cvmx_helper_set_phy_fdt_node_offset (xiface, port_index, + phy_node_offset); + +if (fdt_getprop (fdt_addr, eth,"cavium,sgmii-mac-phy-mode" ,NULL )) +cvmx_helper_set_mac_phy_mode (xiface, port_index, true); +else +cvmx_helper_set_mac_phy_mode (xiface, port_index, false); + +if (fdt_getprop (fdt_addr, eth,"cavium,force-link-up" ,NULL )) +cvmx_helper_set_port_force_link_up (xiface, port_index, true); +else +cvmx_helper_set_port_force_link_up (xiface, port_index, false); + +if (fdt_getprop (fdt_addr, eth,"cavium,sgmii-mac-1000x-mode" ,NULL )) +cvmx_helper_set_1000x_mode (xiface, port_index, true); +else +cvmx_helper_set_1000x_mode (xiface, port_index, false); + +if (fdt_getprop (fdt_addr, eth,"cavium,disable-autonegotiation" ,NULL )) +cvmx_helper_set_port_autonegotiation (xiface, port_index, false); +else +cvmx_helper_set_port_autonegotiation (xiface, port_index, true); + +if (mode ==CVMX_HELPER_INTERFACE_MODE_AGL ) { +bool tx_bypass = false; + +if (fdt_getprop (fdt_addr, eth,"cavium,rx-clk-delay-bypass" , +NULL )) +cvmx_helper_set_agl_rx_clock_delay_bypass ( + xiface, port_index, true); +else +cvmx_helper_set_agl_rx_clock_delay_bypass ( + xiface, port_index, false); + + val =cvmx_fdt_get_int (fdt_addr, eth,"cavium,rx-clk-skew" ,0 ); +cvmx_helper_set_agl_rx_clock_skew (xiface, port_index, val); + +if (fdt_getprop (fdt_addr, eth,"cavium,tx-clk-delay-bypass" , +NULL )) + tx_bypass = true; + + val =cvmx_fdt_get_int (fdt_addr, eth,"tx-clk-delay" ,0 ); +cvmx_helper_cfg_set_rgmii_tx_clk_delay (xiface, port_index, + tx_bypass, val); + + val =cvmx_fdt_get_int (fdt_addr, eth,"cavium,refclk-sel" ,0 ); +cvmx_helper_set_agl_refclk_sel (xiface, port_index, val); + } + +return (eth >=0 ); +} + +/** +* Given the address of the MDIO registers, output the CPU node and MDIO bus +* +* @param addr 64-bit address of MDIO registers (from device tree) +* @param[out] node CPU node number (78xx) +* @param[out] bus MDIO bus number +*/ +void __cvmx_mdio_addr_to_node_bus (u64 addr,int *node,int *bus) +{ +if (OCTEON_IS_MODEL (OCTEON_CN78XX )) { +if (node) + *node =cvmx_csr_addr_to_node (addr); + addr =cvmx_csr_addr_strip_node (addr); + }else { +if (node) + *node =0 ; + } +if (OCTEON_IS_MODEL (OCTEON_CN68XX ) ||OCTEON_IS_MODEL (OCTEON_CN78XX )) { +switch (addr) { +case 0x0001180000003800 : + *bus =0 ; +break ; +case 0x0001180000003880 : + *bus =1 ; +break ; +case 0x0001180000003900 : + *bus =2 ; +break ; +case 0x0001180000003980 : + *bus =3 ; +break ; +default : + *bus =-1 ; +printf ("%s: Invalid SMI bus address 0x%llx\n" , __func__, + (unsigned long long )addr); +break ; + } + }else if (OCTEON_IS_MODEL (OCTEON_CN73XX ) || +OCTEON_IS_MODEL (OCTEON_CNF75XX )) { +switch (addr) { +case 0x0001180000003800 : + *bus =0 ; +break ; +case 0x0001180000003880 : + *bus =1 ; +break ; +default : + *bus =-1 ; +printf ("%s: Invalid SMI bus address 0x%llx\n" , __func__, + (unsigned long long )addr); +break ; + } + }else { +switch (addr) { +case 0x0001180000001800 : + *bus =0 ; +break ; +case 0x0001180000001900 : + *bus =1 ; +break ; +default : + *bus =-1 ; +printf ("%s: Invalid SMI bus address 0x%llx\n" , __func__, + (unsigned long long )addr); +break ; + } + } +} + +/** +* @INTERNAL +* Figure out which mod_abs changed function to use based on the phy type +* +* @param xiface xinterface number +* @param index port index on interface +* +* @return 0 for success, -1 on error +* +* This function figures out the proper mod_abs_changed function to use and +* registers the appropriate function. This should be called after the device +* tree has been fully parsed for the given port as well as after all SFP +* slots and any Microsemi VSC7224 devices have been parsed in the device tree. +*/ +int cvmx_helper_phy_register_mod_abs_changed (int xiface,int index) +{ +struct cvmx_vsc7224_chan *vsc7224_chan; +struct cvmx_fdt_sfp_info *sfp_info; + +debug ("%s(0x%x, %d)\n" , __func__, xiface, index); + sfp_info =cvmx_helper_cfg_get_sfp_info (xiface, index); +/* Don't return an error if no SFP module is registered */ +if (!sfp_info) { +debug ("%s: No SFP associated with 0x%x:%d\n" , __func__, xiface, + index); +return 0 ; + } + +/* See if the Microsemi VSC7224 reclocking chip has been used */ + vsc7224_chan =cvmx_helper_cfg_get_vsc7224_chan_info (xiface, index); +if (vsc7224_chan) { +debug ("%s: Registering VSC7224 handler\n" , __func__); +cvmx_sfp_register_mod_abs_changed (sfp_info, + &cvmx_sfp_vsc7224_mod_abs_changed,NULL ); +return 0 ; + } + +return 0 ; +}
Signature · 1 line
2.35.1
PATCH 13/52 mips: octeon: Add cvmx-helper-igl.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-helper-igl.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-helper-ilk.c | 926 ++++++++++++++++++++++++ 1 file changed, 926 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-helper-ilk.c
arch/mips/mach-octeon/cvmx-helper-ilk.c new file +926 -0
@@ -0,0 +1,926 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Functions for ILK initialization, configuration, +* and monitoring. +*/ + +#include <time.h> +#include <log.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/cvmx-fuse.h> +#include <mach/octeon-feature.h> +#include <mach/cvmx-qlm.h> +#include <mach/octeon_qlm.h> +#include <mach/cvmx-pcie.h> +#include <mach/cvmx-coremask.h> + +#include <mach/cvmx-agl-defs.h> +#include <mach/cvmx-bgxx-defs.h> +#include <mach/cvmx-ciu-defs.h> +#include <mach/cvmx-gmxx-defs.h> +#include <mach/cvmx-ilk-defs.h> +#include <mach/cvmx-ipd-defs.h> +#include <mach/cvmx-pcsx-defs.h> +#include <mach/cvmx-pcsxx-defs.h> +#include <mach/cvmx-pki-defs.h> +#include <mach/cvmx-pko-defs.h> +#include <mach/cvmx-xcv-defs.h> + +#include <mach/cvmx-hwpko.h> +#include <mach/cvmx-ilk.h> +#include <mach/cvmx-pki.h> + +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> + +int __cvmx_helper_ilk_enumerate (int xiface) +{ +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); + + xi.interface -=CVMX_ILK_GBL_BASE (); +return cvmx_ilk_chans[xi.node][xi.interface]; +} + +/** +* @INTERNAL +* Initialize all tx calendar entries to the xoff state. +* Initialize all rx calendar entries to the xon state. The rx calendar entries +* must be in the xon state to allow new pko pipe assignments. If a calendar +* entry is assigned a different pko pipe while in the xoff state, the old pko +* pipe will stay in the xoff state even when no longer used by ilk. +* +* @param intf Interface whose calendar are to be initialized. +*/ +static void __cvmx_ilk_clear_cal_cn78xx (int intf) +{ +cvmx_ilk_txx_cal_entryx_t tx_entry; +cvmx_ilk_rxx_cal_entryx_t rx_entry; +int i; +int node = (intf >>4 ) &0xf ; +int interface = (intf &0xf ); + +/* Initialize all tx calendar entries to off */ + tx_entry.u64 =0 ; + tx_entry.s.ctl =XOFF ; +for (i =0 ; i <CVMX_ILK_MAX_CAL ; i++) { +csr_wr_node (node,CVMX_ILK_TXX_CAL_ENTRYX (i, interface), + tx_entry.u64); + } + +/* Initialize all rx calendar entries to on */ + rx_entry.u64 =0 ; + rx_entry.s.ctl =XOFF ; +for (i =0 ; i <CVMX_ILK_MAX_CAL ; i++) { +csr_wr_node (node,CVMX_ILK_RXX_CAL_ENTRYX (i, interface), + rx_entry.u64); + } +} + +/** +* @INTERNAL +* Initialize all tx calendar entries to the xoff state. +* Initialize all rx calendar entries to the xon state. The rx calendar entries +* must be in the xon state to allow new pko pipe assignments. If a calendar +* entry is assigned a different pko pipe while in the xoff state, the old pko +* pipe will stay in the xoff state even when no longer used by ilk. +* +* @param interface whose calendar are to be initialized. +*/ +static void __cvmx_ilk_clear_cal_cn68xx (int interface) +{ +cvmx_ilk_txx_idx_cal_t tx_idx; +cvmx_ilk_txx_mem_cal0_t tx_cal0; +cvmx_ilk_txx_mem_cal1_t tx_cal1; +cvmx_ilk_rxx_idx_cal_t rx_idx; +cvmx_ilk_rxx_mem_cal0_t rx_cal0; +cvmx_ilk_rxx_mem_cal1_t rx_cal1; +int i; + +/* +* First we initialize the tx calendar starting from entry 0, +* incrementing the entry with every write. +*/ + tx_idx.u64 =0 ; + tx_idx.s.inc =1 ; +csr_wr (CVMX_ILK_TXX_IDX_CAL (interface), tx_idx.u64); + +/* Set state to xoff for all entries */ + tx_cal0.u64 =0 ; + tx_cal0.s.entry_ctl0 =XOFF ; + tx_cal0.s.entry_ctl1 =XOFF ; + tx_cal0.s.entry_ctl2 =XOFF ; + tx_cal0.s.entry_ctl3 =XOFF ; + + tx_cal1.u64 =0 ; + tx_cal1.s.entry_ctl4 =XOFF ; + tx_cal1.s.entry_ctl5 =XOFF ; + tx_cal1.s.entry_ctl6 =XOFF ; + tx_cal1.s.entry_ctl7 =XOFF ; + +/* Write all 288 entries */ +for (i =0 ; i <CVMX_ILK_MAX_CAL_IDX ; i++) { +csr_wr (CVMX_ILK_TXX_MEM_CAL0 (interface), tx_cal0.u64); +csr_wr (CVMX_ILK_TXX_MEM_CAL1 (interface), tx_cal1.u64); + } + +/* +* Next we initialize the rx calendar starting from entry 0, +* incrementing the entry with every write. +*/ + rx_idx.u64 =0 ; + rx_idx.s.inc =1 ; +csr_wr (CVMX_ILK_RXX_IDX_CAL (interface), rx_idx.u64); + +/* Set state to xon for all entries */ + rx_cal0.u64 =0 ; + rx_cal0.s.entry_ctl0 =XON ; + rx_cal0.s.entry_ctl1 =XON ; + rx_cal0.s.entry_ctl2 =XON ; + rx_cal0.s.entry_ctl3 =XON ; + + rx_cal1.u64 =0 ; + rx_cal1.s.entry_ctl4 =XON ; + rx_cal1.s.entry_ctl5 =XON ; + rx_cal1.s.entry_ctl6 =XON ; + rx_cal1.s.entry_ctl7 =XON ; + +/* Write all 288 entries */ +for (i =0 ; i <CVMX_ILK_MAX_CAL_IDX ; i++) { +csr_wr (CVMX_ILK_RXX_MEM_CAL0 (interface), rx_cal0.u64); +csr_wr (CVMX_ILK_RXX_MEM_CAL1 (interface), rx_cal1.u64); + } +} + +/** +* @INTERNAL +* Initialize all calendar entries. +* +* @param interface whose calendar is to be initialized. +*/ +void __cvmx_ilk_clear_cal (int interface) +{ +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) +__cvmx_ilk_clear_cal_cn68xx (interface); +else if (OCTEON_IS_MODEL (OCTEON_CN78XX )) +__cvmx_ilk_clear_cal_cn78xx (interface); +} + +void __cvmx_ilk_write_tx_cal_entry_cn68xx (int interface,int channel, +unsigned char bpid) +{ +cvmx_ilk_txx_idx_cal_t tx_idx; +cvmx_ilk_txx_mem_cal0_t tx_cal0; +cvmx_ilk_txx_mem_cal1_t tx_cal1; +int entry; +int window; +int window_entry; + +/* +* The calendar has 288 entries. Each calendar entry represents a +* channel's flow control state or the link flow control state. +* Starting with the first entry, every sixteenth entry is used for the +* link flow control state. The other 15 entries are used for the +* channels flow control state: +* entry 0 ----> link flow control state +* entry 1 ----> channel 0 flow control state +* entry 2 ----> channel 1 flow control state +* ... +* entry 15 ----> channel 14 flow control state +* entry 16 ----> link flow control state +* entry 17 ----> channel 15 flow control state +* +* Also, the calendar is accessed via windows into it. Each window maps +* to 8 entries. +*/ + entry =1 + channel + (channel /15 ); + window = entry /8 ; + window_entry = entry %8 ; + +/* Indicate the window we need to access */ + tx_idx.u64 =0 ; + tx_idx.s.index = window; +csr_wr (CVMX_ILK_TXX_IDX_CAL (interface), tx_idx.u64); + +/* Get the window's current value */ + tx_cal0.u64 =csr_rd (CVMX_ILK_TXX_MEM_CAL0 (interface)); + tx_cal1.u64 =csr_rd (CVMX_ILK_TXX_MEM_CAL1 (interface)); + +/* Force every sixteenth entry as link flow control state */ +if ((window &1 ) ==0 ) + tx_cal0.s.entry_ctl0 =LINK ; + +/* Update the entry */ +switch (window_entry) { +case 0 : + tx_cal0.s.entry_ctl0 =0 ; + tx_cal0.s.bpid0 = bpid; +break ; +case 1 : + tx_cal0.s.entry_ctl1 =0 ; + tx_cal0.s.bpid1 = bpid; +break ; +case 2 : + tx_cal0.s.entry_ctl2 =0 ; + tx_cal0.s.bpid2 = bpid; +break ; +case 3 : + tx_cal0.s.entry_ctl3 =0 ; + tx_cal0.s.bpid3 = bpid; +break ; +case 4 : + tx_cal1.s.entry_ctl4 =0 ; + tx_cal1.s.bpid4 = bpid; +break ; +case 5 : + tx_cal1.s.entry_ctl5 =0 ; + tx_cal1.s.bpid5 = bpid; +break ; +case 6 : + tx_cal1.s.entry_ctl6 =0 ; + tx_cal1.s.bpid6 = bpid; +break ; +case 7 : + tx_cal1.s.entry_ctl7 =0 ; + tx_cal1.s.bpid7 = bpid; +break ; + } + +/* Write the window new value */ +csr_wr (CVMX_ILK_TXX_MEM_CAL0 (interface), tx_cal0.u64); +csr_wr (CVMX_ILK_TXX_MEM_CAL1 (interface), tx_cal1.u64); +} + +void __cvmx_ilk_write_tx_cal_entry_cn78xx (int intf,int channel, +unsigned char bpid) +{ +cvmx_ilk_txx_cal_entryx_t tx_cal; +int calender_16_block = channel /15 ; +int calender_16_index = channel %15 +1 ; +int index = calender_16_block *16 + calender_16_index; +int node = (intf >>4 ) &0xf ; +int interface = intf &0xf ; + +/* Program the link status on first channel */ +if (calender_16_index ==1 ) { + tx_cal.u64 =0 ; + tx_cal.s.ctl =1 ; +csr_wr_node (node,CVMX_ILK_TXX_CAL_ENTRYX (index -1 , interface), + tx_cal.u64); + } + tx_cal.u64 =0 ; + tx_cal.s.ctl =0 ; + tx_cal.s.channel = channel; +csr_wr_node (node,CVMX_ILK_TXX_CAL_ENTRYX (index, interface), + tx_cal.u64); +} + +/** +* @INTERNAL +* Setup the channel's tx calendar entry. +* +* @param interface channel belongs to +* @param channel whose calendar entry is to be updated +* @param bpid assigned to the channel +*/ +void __cvmx_ilk_write_tx_cal_entry (int interface,int channel, +unsigned char bpid) +{ +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) +__cvmx_ilk_write_tx_cal_entry_cn68xx (interface, channel, bpid); +else +__cvmx_ilk_write_tx_cal_entry_cn78xx (interface, channel, bpid); +} + +void __cvmx_ilk_write_rx_cal_entry_cn78xx (int intf,int channel, +unsigned char bpid) +{ +cvmx_ilk_rxx_cal_entryx_t rx_cal; +int calender_16_block = channel /15 ; +int calender_16_index = channel %15 +1 ; +int index = calender_16_block *16 + calender_16_index; +int node = (intf >>4 ) &0xf ; +int interface = intf &0xf ; + +/* Program the link status on first channel */ +if (calender_16_index ==1 ) { + rx_cal.u64 =0 ; + rx_cal.s.ctl =1 ; +csr_wr_node (node,CVMX_ILK_RXX_CAL_ENTRYX (index -1 , interface), + rx_cal.u64); + } + rx_cal.u64 =0 ; + rx_cal.s.ctl =0 ; + rx_cal.s.channel = channel; +csr_wr_node (node,CVMX_ILK_RXX_CAL_ENTRYX (index, interface), + rx_cal.u64); +} + +void __cvmx_ilk_write_rx_cal_entry_cn68xx (int interface,int channel, +unsigned char pipe) +{ +cvmx_ilk_rxx_idx_cal_t rx_idx; +cvmx_ilk_rxx_mem_cal0_t rx_cal0; +cvmx_ilk_rxx_mem_cal1_t rx_cal1; +int entry; +int window; +int window_entry; + +/* +* The calendar has 288 entries. Each calendar entry represents a +* channel's flow control state or the link flow control state. +* Starting with the first entry, every sixteenth entry is used for the +* link flow control state. The other 15 entries are used for the +* channels flow control state: +* entry 0 ----> link flow control state +* entry 1 ----> channel 0 flow control state +* entry 2 ----> channel 1 flow control state +* ... +* entry 15 ----> channel 14 flow control state +* entry 16 ----> link flow control state +* entry 17 ----> channel 15 flow control state +* +* Also, the calendar is accessed via windows into it. Each window maps +* to 8 entries. +*/ + entry =1 + channel + (channel /15 ); + window = entry /8 ; + window_entry = entry %8 ; + +/* Indicate the window we need to access */ + rx_idx.u64 =0 ; + rx_idx.s.index = window; +csr_wr (CVMX_ILK_RXX_IDX_CAL (interface), rx_idx.u64); + +/* Get the window's current value */ + rx_cal0.u64 =csr_rd (CVMX_ILK_RXX_MEM_CAL0 (interface)); + rx_cal1.u64 =csr_rd (CVMX_ILK_RXX_MEM_CAL1 (interface)); + +/* Force every sixteenth entry as link flow control state */ +if ((window &1 ) ==0 ) + rx_cal0.s.entry_ctl0 =LINK ; + +/* Update the entry */ +switch (window_entry) { +case 0 : + rx_cal0.s.entry_ctl0 =0 ; + rx_cal0.s.port_pipe0 = pipe; +break ; +case 1 : + rx_cal0.s.entry_ctl1 =0 ; + rx_cal0.s.port_pipe1 = pipe; +break ; +case 2 : + rx_cal0.s.entry_ctl2 =0 ; + rx_cal0.s.port_pipe2 = pipe; +break ; +case 3 : + rx_cal0.s.entry_ctl3 =0 ; + rx_cal0.s.port_pipe3 = pipe; +break ; +case 4 : + rx_cal1.s.entry_ctl4 =0 ; + rx_cal1.s.port_pipe4 = pipe; +break ; +case 5 : + rx_cal1.s.entry_ctl5 =0 ; + rx_cal1.s.port_pipe5 = pipe; +break ; +case 6 : + rx_cal1.s.entry_ctl6 =0 ; + rx_cal1.s.port_pipe6 = pipe; +break ; +case 7 : + rx_cal1.s.entry_ctl7 =0 ; + rx_cal1.s.port_pipe7 = pipe; +break ; + } + +/* Write the window new value */ +csr_wr (CVMX_ILK_RXX_MEM_CAL0 (interface), rx_cal0.u64); +csr_wr (CVMX_ILK_RXX_MEM_CAL1 (interface), rx_cal1.u64); +} + +/** +* @INTERNAL +* Setup the channel's rx calendar entry. +* +* @param interface channel belongs to +* @param channel whose calendar entry is to be updated +* @param pipe PKO assigned to the channel +*/ +void __cvmx_ilk_write_rx_cal_entry (int interface,int channel, +unsigned char pipe) +{ +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) +__cvmx_ilk_write_rx_cal_entry_cn68xx (interface, channel, pipe); +else +__cvmx_ilk_write_rx_cal_entry_cn78xx (interface, channel, pipe); +} + +/** +* @INTERNAL +* Probe a ILK interface and determine the number of ports +* connected to it. The ILK interface should still be down +* after this call. +* +* @param xiface Interface to probe +* +* @return Number of ports on the interface. Zero to disable. +*/ +int __cvmx_helper_ilk_probe (int xiface) +{ +int res =0 ; +int interface; +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); + +if (!octeon_has_feature (OCTEON_FEATURE_ILK )) +return res; + + interface = xi.interface -CVMX_ILK_GBL_BASE (); +if (interface >=CVMX_NUM_ILK_INTF ) +return 0 ; + +/* the configuration should be done only once */ +if (cvmx_ilk_get_intf_ena (xiface)) +return cvmx_ilk_chans[xi.node][interface]; + +/* configure lanes and enable the link */ + res =cvmx_ilk_start_interface (((xi.node <<4 ) | interface), + cvmx_ilk_lane_mask[xi.node][interface]); +if (res <0 ) +return 0 ; + + res =__cvmx_helper_ilk_enumerate (xiface); + +return res; +} + +static int __cvmx_helper_ilk_init_port_cn68xx (int xiface) +{ +int i, j, res =-1 ; +static int pipe_base =0 , pknd_base; +static cvmx_ilk_pipe_chan_t *pch =NULL , *tmp; +static cvmx_ilk_chan_pknd_t *chpknd =NULL , *tmp1; +static cvmx_ilk_cal_entry_t *calent =NULL , *tmp2; +int enable_rx_cal =1 ; +int interface; +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); +int intf; +int num_chans; + + interface = xi.interface -CVMX_ILK_GBL_BASE (); + intf = (xi.node <<4 ) | interface; +if (interface >=CVMX_NUM_ILK_INTF ) +return 0 ; + + num_chans = cvmx_ilk_chans[0 ][interface]; + +/* set up channel to pkind mapping */ +if (pknd_base ==0 ) + pknd_base =cvmx_helper_get_pknd (xiface,0 ); + +/* set up the group of pipes available to ilk */ +if (pipe_base ==0 ) + pipe_base = +__cvmx_pko_get_pipe (interface +CVMX_ILK_GBL_BASE (),0 ); + +if (pipe_base ==-1 ) { + pipe_base =0 ; +return 0 ; + } + + res =cvmx_ilk_set_pipe (xiface, pipe_base, + cvmx_ilk_chans[0 ][interface]); +if (res <0 ) +return 0 ; + +/* set up pipe to channel mapping */ + i = pipe_base; +if (!pch) { + pch = (cvmx_ilk_pipe_chan_t *)cvmx_bootmem_alloc ( + num_chans *sizeof (cvmx_ilk_pipe_chan_t), +sizeof (cvmx_ilk_pipe_chan_t)); +if (!pch) +return 0 ; + } + +memset (pch,0 , num_chans *sizeof (cvmx_ilk_pipe_chan_t)); + tmp = pch; +for (j =0 ; j < num_chans; j++) { + tmp->pipe = i++; + tmp->chan = j; + tmp++; + } + res =cvmx_ilk_tx_set_channel (interface, pch, + cvmx_ilk_chans[0 ][interface]); +if (res <0 ) { + res =0 ; + goto err_free_pch; + } + pipe_base += cvmx_ilk_chans[0 ][interface]; + i = pknd_base; +if (!chpknd) { + chpknd = (cvmx_ilk_chan_pknd_t *)cvmx_bootmem_alloc ( +CVMX_ILK_MAX_PKNDS *sizeof (cvmx_ilk_chan_pknd_t), +sizeof (cvmx_ilk_chan_pknd_t)); +if (!chpknd) { + pipe_base -= cvmx_ilk_chans[xi.node][interface]; + res =0 ; + goto err_free_pch; + } + } + +memset (chpknd,0 ,CVMX_ILK_MAX_PKNDS *sizeof (cvmx_ilk_chan_pknd_t)); + tmp1 = chpknd; +for (j =0 ; j < cvmx_ilk_chans[xi.node][interface]; j++) { + tmp1->chan = j; + tmp1->pknd = i++; + tmp1++; + } + + res =cvmx_ilk_rx_set_pknd (xiface, chpknd, + cvmx_ilk_chans[xi.node][interface]); +if (res <0 ) { + pipe_base -= cvmx_ilk_chans[xi.node][interface]; + res =0 ; + goto err_free_chpknd; + } + pknd_base += cvmx_ilk_chans[xi.node][interface]; + +/* Set up tx calendar */ +if (!calent) { + calent = (cvmx_ilk_cal_entry_t *)cvmx_bootmem_alloc ( +CVMX_ILK_MAX_PIPES *sizeof (cvmx_ilk_cal_entry_t), +sizeof (cvmx_ilk_cal_entry_t)); +if (!calent) { + pipe_base -= cvmx_ilk_chans[xi.node][interface]; + pknd_base -= cvmx_ilk_chans[xi.node][interface]; + res =0 ; + goto err_free_chpknd; + } + } + +memset (calent,0 ,CVMX_ILK_MAX_PIPES *sizeof (cvmx_ilk_cal_entry_t)); + tmp1 = chpknd; + tmp2 = calent; +for (j =0 ; j < cvmx_ilk_chans[xi.node][interface]; j++) { + tmp2->pipe_bpid = tmp1->pknd; + tmp2->ent_ctrl =PIPE_BPID ; + tmp1++; + tmp2++; + } + res =cvmx_ilk_cal_setup_tx (intf, cvmx_ilk_chans[xi.node][interface], + calent,1 ); +if (res <0 ) { + pipe_base -= cvmx_ilk_chans[xi.node][interface]; + pknd_base -= cvmx_ilk_chans[xi.node][interface]; + res =0 ; + goto err_free_calent; + } + +/* set up rx calendar. allocated memory can be reused. +* this is because max pkind is always less than max pipe +*/ +memset (calent,0 ,CVMX_ILK_MAX_PIPES *sizeof (cvmx_ilk_cal_entry_t)); + tmp = pch; + tmp2 = calent; +for (j =0 ; j < cvmx_ilk_chans[0 ][interface]; j++) { + tmp2->pipe_bpid = tmp->pipe; + tmp2->ent_ctrl =PIPE_BPID ; + tmp++; + tmp2++; + } +if (cvmx_ilk_use_la_mode (interface,0 )) + enable_rx_cal =cvmx_ilk_la_mode_enable_rx_calendar (interface); +else + enable_rx_cal =1 ; + + res =cvmx_ilk_cal_setup_rx (intf, cvmx_ilk_chans[xi.node][interface], + calent,CVMX_ILK_RX_FIFO_WM , enable_rx_cal); +if (res <0 ) { + pipe_base -= cvmx_ilk_chans[xi.node][interface]; + pknd_base -= cvmx_ilk_chans[xi.node][interface]; + res =0 ; + goto err_free_calent; + } + goto out; + +err_free_calent: +/* no free() for cvmx_bootmem_alloc() */ + +err_free_chpknd: +/* no free() for cvmx_bootmem_alloc() */ + +err_free_pch: +/* no free() for cvmx_bootmem_alloc() */ +out: +return res; +} + +static int __cvmx_helper_ilk_init_port_cn78xx (int xiface) +{ +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); +int interface; +int intf; + + interface = xi.interface -CVMX_ILK_GBL_BASE (); + intf = (xi.node <<4 ) | interface; +if (interface >=CVMX_NUM_ILK_INTF ) +return 0 ; + +if (OCTEON_IS_MODEL (OCTEON_CN78XX )) { +struct cvmx_pki_style_config style_cfg; +int num_channels = cvmx_ilk_chans[xi.node][interface]; +int index, i; + +for (i =0 ; i < num_channels; i++) { +int pknd; + + index = (i %8 ); + +/* Set jabber to allow max sized packets */ +if (i ==0 ) +csr_wr_node (xi.node, +CVMX_ILK_RXX_JABBER (interface), +0xfff8 ); + +/* Setup PKND */ + pknd =cvmx_helper_get_pknd (xiface, index); +csr_wr_node (xi.node,CVMX_ILK_RXX_CHAX (i, interface), + pknd); +cvmx_pki_read_style_config ( +0 , pknd,CVMX_PKI_CLUSTER_ALL , &style_cfg); + style_cfg.parm_cfg.qpg_port_sh =0 ; +/* 256 channels */ + style_cfg.parm_cfg.qpg_port_msb =8 ; +cvmx_pki_write_style_config ( +0 , pknd,CVMX_PKI_CLUSTER_ALL , &style_cfg); + } + +cvmx_ilk_cal_setup_tx (intf, num_channels,NULL ,1 ); +cvmx_ilk_cal_setup_rx (intf, num_channels,NULL , +CVMX_ILK_RX_FIFO_WM ,1 ); + } +return 0 ; +} + +static int __cvmx_helper_ilk_init_port (int xiface) +{ +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) +return __cvmx_helper_ilk_init_port_cn68xx (xiface); +else +return __cvmx_helper_ilk_init_port_cn78xx (xiface); +} + +/** +* @INTERNAL +* Bringup and enable ILK interface. After this call packet +* I/O should be fully functional. This is called with IPD +* enabled but PKO disabled. +* +* @param xiface Interface to bring up +* +* @return Zero on success, negative on failure +*/ +int __cvmx_helper_ilk_enable (int xiface) +{ +if (__cvmx_helper_ilk_init_port (xiface) <0 ) +return -1 ; + +return cvmx_ilk_enable (xiface); +} + +/** +* @INTERNAL +* Return the link state of an IPD/PKO port as returned by ILK link status. +* +* @param ipd_port IPD/PKO port to query +* +* @return Link state +*/ +cvmx_helper_link_info_t __cvmx_helper_ilk_link_get (int ipd_port) +{ +cvmx_helper_link_info_t result; +int xiface =cvmx_helper_get_interface_num (ipd_port); +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); +int interface; +int retry_count =0 ; +cvmx_ilk_rxx_cfg1_t ilk_rxx_cfg1; +cvmx_ilk_rxx_int_t ilk_rxx_int; +int lane_mask =0 ; +int i; +int node = xi.node; + + result.u64 =0 ; + interface = xi.interface -CVMX_ILK_GBL_BASE (); + +retry: + retry_count++; +if (retry_count >200 ) + goto fail; + +/* Read RX config and status bits */ + ilk_rxx_cfg1.u64 =csr_rd_node (node,CVMX_ILK_RXX_CFG1 (interface)); + ilk_rxx_int.u64 =csr_rd_node (node,CVMX_ILK_RXX_INT (interface)); + +if (ilk_rxx_cfg1.s.rx_bdry_lock_ena ==0 ) { +/* (GSER-21957) GSER RX Equalization may make >= 5gbaud non-KR +* channel better +*/ +if (OCTEON_IS_MODEL (OCTEON_CN78XX )) { +int qlm, lane_mask; + +for (qlm =4 ; qlm <8 ; qlm++) { + lane_mask =1 << (qlm -4 ) *4 ; +if (lane_mask & + cvmx_ilk_lane_mask[node][interface]) { +if (__cvmx_qlm_rx_equalization ( + node, qlm,-1 )) + goto retry; + } + } + } + +/* Clear the boundary lock status bit */ + ilk_rxx_int.u64 =0 ; + ilk_rxx_int.s.word_sync_done =1 ; +csr_wr_node (node,CVMX_ILK_RXX_INT (interface), ilk_rxx_int.u64); + +/* We need to start looking for word boundary lock */ + ilk_rxx_cfg1.s.rx_bdry_lock_ena = + cvmx_ilk_lane_mask[node][interface]; + ilk_rxx_cfg1.s.rx_align_ena =0 ; +csr_wr_node (node,CVMX_ILK_RXX_CFG1 (interface), + ilk_rxx_cfg1.u64); +//debug("ILK%d: Looking for word boundary lock\n", interface); +udelay (50 ); + goto retry; + } + +if (ilk_rxx_cfg1.s.rx_align_ena ==0 ) { +if (ilk_rxx_int.s.word_sync_done) { +/* Clear the lane align status bits */ + ilk_rxx_int.u64 =0 ; + ilk_rxx_int.s.lane_align_fail =1 ; + ilk_rxx_int.s.lane_align_done =1 ; +csr_wr_node (node,CVMX_ILK_RXX_INT (interface), + ilk_rxx_int.u64); + + ilk_rxx_cfg1.s.rx_align_ena =1 ; +csr_wr_node (node,CVMX_ILK_RXX_CFG1 (interface), + ilk_rxx_cfg1.u64); +//printf("ILK%d: Looking for lane alignment\n", interface); + } +udelay (50 ); + goto retry; + } + +if (ilk_rxx_int.s.lane_align_fail) { + ilk_rxx_cfg1.s.rx_bdry_lock_ena =0 ; + ilk_rxx_cfg1.s.rx_align_ena =0 ; +csr_wr_node (node,CVMX_ILK_RXX_CFG1 (interface), + ilk_rxx_cfg1.u64); +//debug("ILK%d: Lane alignment failed\n", interface); + goto fail; + } + + lane_mask = ilk_rxx_cfg1.s.rx_bdry_lock_ena; + +if (ilk_rxx_cfg1.s.pkt_ena ==0 && ilk_rxx_int.s.lane_align_done) { +cvmx_ilk_txx_cfg1_t ilk_txx_cfg1; + + ilk_txx_cfg1.u64 = +csr_rd_node (node,CVMX_ILK_TXX_CFG1 (interface)); + ilk_rxx_cfg1.u64 = +csr_rd_node (node,CVMX_ILK_RXX_CFG1 (interface)); + ilk_rxx_cfg1.s.pkt_ena = ilk_txx_cfg1.s.pkt_ena; +csr_wr_node (node,CVMX_ILK_RXX_CFG1 (interface), + ilk_rxx_cfg1.u64); + +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) { +/* +* Enable rxf_ctl_perr, rxf_lnk0_perr, rxf_lnk1_perr, +* pop_empty, push_full. +*/ +csr_wr (CVMX_ILK_GBL_INT_EN ,0x1f ); +/* Enable bad_pipe, bad_seq, txf_err */ +csr_wr (CVMX_ILK_TXX_INT_EN (interface),0x7 ); + +/* +* Enable crc24_err, lane_bad_word, +* pkt_drop_{rid,rxf,sop} +*/ +csr_wr (CVMX_ILK_RXX_INT_EN (interface),0x1e2 ); + } +/* Need to enable ILK interrupts for 78xx */ + +for (i =0 ; i <CVMX_ILK_MAX_LANES (); i++) { +if ((1 << i) & lane_mask) { +/* clear pending interrupts, before enabling. */ +csr_wr_node (node,CVMX_ILK_RX_LNEX_INT (i), +0x1ff ); +/* Enable bad_64b67b, bdry_sync_loss, crc32_err, +* dskew_fifo_ovfl, scrm_sync_loss, +* serdes_lock_loss, stat_msg, ukwn_cntl_word +*/ +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) +csr_wr (CVMX_ILK_RX_LNEX_INT_EN (i), +0x1ff ); + } + } + +//debug("ILK%d: Lane alignment complete\n", interface); + } + +/* Enable error interrupts, now link is up */ +cvmx_error_enable_group (CVMX_ERROR_GROUP_ILK , + node | (interface <<2 ) | (lane_mask <<4 )); + + result.s.link_up =1 ; + result.s.full_duplex =1 ; +if (OCTEON_IS_MODEL (OCTEON_CN78XX )) { +int qlm =cvmx_qlm_lmac (xiface,0 ); + + result.s.speed =cvmx_qlm_get_gbaud_mhz (qlm) *64 /67 ; + }else { + result.s.speed = +cvmx_qlm_get_gbaud_mhz (1 + interface) *64 /67 ; + } + result.s.speed *=cvmx_pop (lane_mask); + +return result; + +fail: +if (ilk_rxx_cfg1.s.pkt_ena) { +/* Disable the interface */ + ilk_rxx_cfg1.s.pkt_ena =0 ; +csr_wr_node (node,CVMX_ILK_RXX_CFG1 (interface), + ilk_rxx_cfg1.u64); + +/* Disable error interrupts */ +for (i =0 ; i <CVMX_ILK_MAX_LANES (); i++) { +/* Disable bad_64b67b, bdry_sync_loss, crc32_err, +* dskew_fifo_ovfl, scrm_sync_loss, serdes_lock_loss, +* stat_msg, ukwn_cntl_word +*/ +if ((1 << i) & lane_mask) { +csr_wr_node (node,CVMX_ILK_RX_LNEX_INT (i), +0x1ff ); +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) +csr_wr (CVMX_ILK_RX_LNEX_INT_EN (i), + ~0x1ff ); + } + } +/* Disable error interrupts */ +cvmx_error_enable_group (CVMX_ERROR_GROUP_ILK ,0 ); + } + +return result; +} + +/** +* @INTERNAL +* Set the link state of an IPD/PKO port. +* +* @param ipd_port IPD/PKO port to configure +* @param link_info The new link state +* +* @return Zero on success, negative on failure +*/ +int __cvmx_helper_ilk_link_set (int ipd_port,cvmx_helper_link_info_t link_info) +{ +/* Do nothing */ +return 0 ; +} + +/** +* Display ilk interface statistics. +* +*/ +void __cvmx_helper_ilk_show_stats (void ) +{ +int i, j; +int chan_tmp[CVMX_ILK_MAX_CHANS ]; +cvmx_ilk_stats_ctrl_t ilk_stats_ctrl; + +for (i =0 ; i <CVMX_NUM_ILK_INTF ; i++) { +int num_chans = cvmx_ilk_chans[0 ][i]; + +memset (chan_tmp,0 , num_chans *sizeof (int )); +for (j =0 ; j < num_chans; j++) + chan_tmp[j] = j; + + ilk_stats_ctrl.chan_list = chan_tmp; + ilk_stats_ctrl.num_chans = num_chans; + ilk_stats_ctrl.clr_on_rd =0 ; +cvmx_ilk_show_stats (i, &ilk_stats_ctrl); + } +}
Signature · 1 line
2.35.1
PATCH 5/52 mips: octeon: Add cvmx-npei-defs.h header file
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-npei-defs.h header file from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- .../mach-octeon/include/mach/cvmx-npei-defs.h | 3550 +++++++++++++++++ 1 file changed, 3550 insertions(+) create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-npei-defs.h
arch/mips/mach-octeon/include/mach/cvmx-npei-defs.h new file +3550 -0
@@ -0,0 +1,3550 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Configuration and status register (CSR) type definitions for +* Octeon npei. +*/ + +#ifndef __CVMX_NPEI_DEFS_H__ +#define __CVMX_NPEI_DEFS_H__ + +#define CVMX_NPEI_BAR1_INDEXX (offset) \ + (0x0000000000000000ull + ((offset) & 31) * 16) +#define CVMX_NPEI_BIST_STATUS (0x0000000000000580ull) +#define CVMX_NPEI_BIST_STATUS2 (0x0000000000000680ull) +#define CVMX_NPEI_CTL_PORT0 (0x0000000000000250ull) +#define CVMX_NPEI_CTL_PORT1 (0x0000000000000260ull) +#define CVMX_NPEI_CTL_STATUS (0x0000000000000570ull) +#define CVMX_NPEI_CTL_STATUS2 (0x0000000000003C00ull) +#define CVMX_NPEI_DATA_OUT_CNT (0x00000000000005F0ull) +#define CVMX_NPEI_DBG_DATA (0x0000000000000510ull) +#define CVMX_NPEI_DBG_SELECT (0x0000000000000500ull) +#define CVMX_NPEI_DMA0_INT_LEVEL (0x00000000000005C0ull) +#define CVMX_NPEI_DMA1_INT_LEVEL (0x00000000000005D0ull) +#define CVMX_NPEI_DMAX_COUNTS (offset) \ + (0x0000000000000450ull + ((offset) & 7) * 16) +#define CVMX_NPEI_DMAX_DBELL (offset) (0x00000000000003B0ull + ((offset) & 7) * 16) +#define CVMX_NPEI_DMAX_IBUFF_SADDR (offset) \ + (0x0000000000000400ull + ((offset) & 7) * 16) +#define CVMX_NPEI_DMAX_NADDR (offset) (0x00000000000004A0ull + ((offset) & 7) * 16) +#define CVMX_NPEI_DMA_CNTS (0x00000000000005E0ull) +#define CVMX_NPEI_DMA_CONTROL (0x00000000000003A0ull) +#define CVMX_NPEI_DMA_PCIE_REQ_NUM (0x00000000000005B0ull) +#define CVMX_NPEI_DMA_STATE1 (0x00000000000006C0ull) +#define CVMX_NPEI_DMA_STATE1_P1 (0x0000000000000680ull) +#define CVMX_NPEI_DMA_STATE2 (0x00000000000006D0ull) +#define CVMX_NPEI_DMA_STATE2_P1 (0x0000000000000690ull) +#define CVMX_NPEI_DMA_STATE3_P1 (0x00000000000006A0ull) +#define CVMX_NPEI_DMA_STATE4_P1 (0x00000000000006B0ull) +#define CVMX_NPEI_DMA_STATE5_P1 (0x00000000000006C0ull) +#define CVMX_NPEI_INT_A_ENB (0x0000000000000560ull) +#define CVMX_NPEI_INT_A_ENB2 (0x0000000000003CE0ull) +#define CVMX_NPEI_INT_A_SUM (0x0000000000000550ull) +#define CVMX_NPEI_INT_ENB (0x0000000000000540ull) +#define CVMX_NPEI_INT_ENB2 (0x0000000000003CD0ull) +#define CVMX_NPEI_INT_INFO (0x0000000000000590ull) +#define CVMX_NPEI_INT_SUM (0x0000000000000530ull) +#define CVMX_NPEI_INT_SUM2 (0x0000000000003CC0ull) +#define CVMX_NPEI_LAST_WIN_RDATA0 (0x0000000000000600ull) +#define CVMX_NPEI_LAST_WIN_RDATA1 (0x0000000000000610ull) +#define CVMX_NPEI_MEM_ACCESS_CTL (0x00000000000004F0ull) +#define CVMX_NPEI_MEM_ACCESS_SUBIDX (offset) \ + (0x0000000000000280ull + ((offset) & 31) * 16 - 16 * 12) +#define CVMX_NPEI_MSI_ENB0 (0x0000000000003C50ull) +#define CVMX_NPEI_MSI_ENB1 (0x0000000000003C60ull) +#define CVMX_NPEI_MSI_ENB2 (0x0000000000003C70ull) +#define CVMX_NPEI_MSI_ENB3 (0x0000000000003C80ull) +#define CVMX_NPEI_MSI_RCV0 (0x0000000000003C10ull) +#define CVMX_NPEI_MSI_RCV1 (0x0000000000003C20ull) +#define CVMX_NPEI_MSI_RCV2 (0x0000000000003C30ull) +#define CVMX_NPEI_MSI_RCV3 (0x0000000000003C40ull) +#define CVMX_NPEI_MSI_RD_MAP (0x0000000000003CA0ull) +#define CVMX_NPEI_MSI_W1C_ENB0 (0x0000000000003CF0ull) +#define CVMX_NPEI_MSI_W1C_ENB1 (0x0000000000003D00ull) +#define CVMX_NPEI_MSI_W1C_ENB2 (0x0000000000003D10ull) +#define CVMX_NPEI_MSI_W1C_ENB3 (0x0000000000003D20ull) +#define CVMX_NPEI_MSI_W1S_ENB0 (0x0000000000003D30ull) +#define CVMX_NPEI_MSI_W1S_ENB1 (0x0000000000003D40ull) +#define CVMX_NPEI_MSI_W1S_ENB2 (0x0000000000003D50ull) +#define CVMX_NPEI_MSI_W1S_ENB3 (0x0000000000003D60ull) +#define CVMX_NPEI_MSI_WR_MAP (0x0000000000003C90ull) +#define CVMX_NPEI_PCIE_CREDIT_CNT (0x0000000000003D70ull) +#define CVMX_NPEI_PCIE_MSI_RCV (0x0000000000003CB0ull) +#define CVMX_NPEI_PCIE_MSI_RCV_B1 (0x0000000000000650ull) +#define CVMX_NPEI_PCIE_MSI_RCV_B2 (0x0000000000000660ull) +#define CVMX_NPEI_PCIE_MSI_RCV_B3 (0x0000000000000670ull) +#define CVMX_NPEI_PKTX_CNTS (offset) (0x0000000000002400ull + ((offset) & 31) * 16) +#define CVMX_NPEI_PKTX_INSTR_BADDR (offset) \ + (0x0000000000002800ull + ((offset) & 31) * 16) +#define CVMX_NPEI_PKTX_INSTR_BAOFF_DBELL (offset) \ + (0x0000000000002C00ull + ((offset) & 31) * 16) +#define CVMX_NPEI_PKTX_INSTR_FIFO_RSIZE (offset) \ + (0x0000000000003000ull + ((offset) & 31) * 16) +#define CVMX_NPEI_PKTX_INSTR_HEADER (offset) \ + (0x0000000000003400ull + ((offset) & 31) * 16) +#define CVMX_NPEI_PKTX_IN_BP (offset) \ + (0x0000000000003800ull + ((offset) & 31) * 16) +#define CVMX_NPEI_PKTX_SLIST_BADDR (offset) \ + (0x0000000000001400ull + ((offset) & 31) * 16) +#define CVMX_NPEI_PKTX_SLIST_BAOFF_DBELL (offset) \ + (0x0000000000001800ull + ((offset) & 31) * 16) +#define CVMX_NPEI_PKTX_SLIST_FIFO_RSIZE (offset) \ + (0x0000000000001C00ull + ((offset) & 31) * 16) +#define CVMX_NPEI_PKT_CNT_INT (0x0000000000001110ull) +#define CVMX_NPEI_PKT_CNT_INT_ENB (0x0000000000001130ull) +#define CVMX_NPEI_PKT_DATA_OUT_ES (0x00000000000010B0ull) +#define CVMX_NPEI_PKT_DATA_OUT_NS (0x00000000000010A0ull) +#define CVMX_NPEI_PKT_DATA_OUT_ROR (0x0000000000001090ull) +#define CVMX_NPEI_PKT_DPADDR (0x0000000000001080ull) +#define CVMX_NPEI_PKT_INPUT_CONTROL (0x0000000000001150ull) +#define CVMX_NPEI_PKT_INSTR_ENB (0x0000000000001000ull) +#define CVMX_NPEI_PKT_INSTR_RD_SIZE (0x0000000000001190ull) +#define CVMX_NPEI_PKT_INSTR_SIZE (0x0000000000001020ull) +#define CVMX_NPEI_PKT_INT_LEVELS (0x0000000000001100ull) +#define CVMX_NPEI_PKT_IN_BP (0x00000000000006B0ull) +#define CVMX_NPEI_PKT_IN_DONEX_CNTS (offset) \ + (0x0000000000002000ull + ((offset) & 31) * 16) +#define CVMX_NPEI_PKT_IN_INSTR_COUNTS (0x00000000000006A0ull) +#define CVMX_NPEI_PKT_IN_PCIE_PORT (0x00000000000011A0ull) +#define CVMX_NPEI_PKT_IPTR (0x0000000000001070ull) +#define CVMX_NPEI_PKT_OUTPUT_WMARK (0x0000000000001160ull) +#define CVMX_NPEI_PKT_OUT_BMODE (0x00000000000010D0ull) +#define CVMX_NPEI_PKT_OUT_ENB (0x0000000000001010ull) +#define CVMX_NPEI_PKT_PCIE_PORT (0x00000000000010E0ull) +#define CVMX_NPEI_PKT_PORT_IN_RST (0x0000000000000690ull) +#define CVMX_NPEI_PKT_SLIST_ES (0x0000000000001050ull) +#define CVMX_NPEI_PKT_SLIST_ID_SIZE (0x0000000000001180ull) +#define CVMX_NPEI_PKT_SLIST_NS (0x0000000000001040ull) +#define CVMX_NPEI_PKT_SLIST_ROR (0x0000000000001030ull) +#define CVMX_NPEI_PKT_TIME_INT (0x0000000000001120ull) +#define CVMX_NPEI_PKT_TIME_INT_ENB (0x0000000000001140ull) +#define CVMX_NPEI_RSL_INT_BLOCKS (0x0000000000000520ull) +#define CVMX_NPEI_SCRATCH_1 (0x0000000000000270ull) +#define CVMX_NPEI_STATE1 (0x0000000000000620ull) +#define CVMX_NPEI_STATE2 (0x0000000000000630ull) +#define CVMX_NPEI_STATE3 (0x0000000000000640ull) +#define CVMX_NPEI_WINDOW_CTL (0x0000000000000380ull) +#define CVMX_NPEI_WIN_RD_ADDR (0x0000000000000210ull) +#define CVMX_NPEI_WIN_RD_DATA (0x0000000000000240ull) +#define CVMX_NPEI_WIN_WR_ADDR (0x0000000000000200ull) +#define CVMX_NPEI_WIN_WR_DATA (0x0000000000000220ull) +#define CVMX_NPEI_WIN_WR_MASK (0x0000000000000230ull) + +/** +* cvmx_npei_bar1_index# +* +* Total Address is 16Kb; 0x0000 - 0x3fff, 0x000 - 0x7fe(Reg, every other 8B) +* +* General 5kb; 0x0000 - 0x13ff, 0x000 - 0x27e(Reg-General) +* PktMem 10Kb; 0x1400 - 0x3bff, 0x280 - 0x77e(Reg-General-Packet) +* Rsvd 1Kb; 0x3c00 - 0x3fff, 0x780 - 0x7fe(Reg-NCB Only Mode) +* == NPEI_PKT_CNT_INT_ENB[PORT] +* == NPEI_PKT_TIME_INT_ENB[PORT] +* == NPEI_PKT_CNT_INT[PORT] +* == NPEI_PKT_TIME_INT[PORT] +* == NPEI_PKT_PCIE_PORT[PP] +* == NPEI_PKT_SLIST_ROR[ROR] +* == NPEI_PKT_SLIST_ROR[NSR] ? +* == NPEI_PKT_SLIST_ES[ES] +* == NPEI_PKTn_SLIST_BAOFF_DBELL[AOFF] +* == NPEI_PKTn_SLIST_BAOFF_DBELL[DBELL] +* == NPEI_PKTn_CNTS[CNT] +* NPEI_CTL_STATUS[OUTn_ENB] == NPEI_PKT_OUT_ENB[ENB] +* NPEI_BASE_ADDRESS_OUTPUTn[BADDR] == NPEI_PKTn_SLIST_BADDR[ADDR] +* NPEI_DESC_OUTPUTn[SIZE] == NPEI_PKTn_SLIST_FIFO_RSIZE[RSIZE] +* NPEI_Pn_DBPAIR_ADDR[NADDR] == NPEI_PKTn_SLIST_BADDR[ADDR] + +* NPEI_PKTn_SLIST_BAOFF_DBELL[AOFF] +* NPEI_PKT_CREDITSn[PTR_CNT] == NPEI_PKTn_SLIST_BAOFF_DBELL[DBELL] +* NPEI_P0_PAIR_CNTS[AVAIL] == NPEI_PKTn_SLIST_BAOFF_DBELL[DBELL] +* NPEI_P0_PAIR_CNTS[FCNT] == +* NPEI_PKTS_SENTn[PKT_CNT] == NPEI_PKTn_CNTS[CNT] +* NPEI_OUTPUT_CONTROL[Pn_BMODE] == NPEI_PKT_OUT_BMODE[BMODE] +* NPEI_PKT_CREDITSn[PKT_CNT] == NPEI_PKTn_CNTS[CNT] +* NPEI_BUFF_SIZE_OUTPUTn[BSIZE] == NPEI_PKT_SLIST_ID_SIZE[BSIZE] +* NPEI_BUFF_SIZE_OUTPUTn[ISIZE] == NPEI_PKT_SLIST_ID_SIZE[ISIZE] +* NPEI_OUTPUT_CONTROL[On_CSRM] == NPEI_PKT_DPADDR[DPTR] & +* NPEI_PKT_OUT_USE_IPTR[PORT] +* NPEI_OUTPUT_CONTROL[On_ES] == NPEI_PKT_DATA_OUT_ES[ES] +* NPEI_OUTPUT_CONTROL[On_NS] == NPEI_PKT_DATA_OUT_NS[NSR] ? +* NPEI_OUTPUT_CONTROL[On_RO] == NPEI_PKT_DATA_OUT_ROR[ROR] +* NPEI_PKTS_SENT_INT_LEVn[PKT_CNT] == NPEI_PKT_INT_LEVELS[CNT] +* NPEI_PKTS_SENT_TIMEn[PKT_TIME] == NPEI_PKT_INT_LEVELS[TIME] +* NPEI_OUTPUT_CONTROL[IPTR_On] == NPEI_PKT_IPTR[IPTR] +* NPEI_PCIE_PORT_OUTPUT[] == NPEI_PKT_PCIE_PORT[PP] +* +* NPEI_BAR1_INDEXX = NPEI BAR1 IndexX Register +* +* Contains address index and control bits for access to memory ranges of +* BAR-1. Index is build from supplied address [25:22]. +* NPEI_BAR1_INDEX0 through NPEI_BAR1_INDEX15 is used for transactions +* orginating with PCIE-PORT0 and NPEI_BAR1_INDEX16 +* through NPEI_BAR1_INDEX31 is used for transactions originating with +* PCIE-PORT1. +*/ +union cvmx_npei_bar1_indexx { +u32 u32; +struct cvmx_npei_bar1_indexx_s { +u32 reserved_18_31 :14 ; +u32 addr_idx :14 ; +u32 ca :1 ; +u32 end_swp :2 ; +u32 addr_v :1 ; + } s; +struct cvmx_npei_bar1_indexx_s cn52xx; +struct cvmx_npei_bar1_indexx_s cn52xxp1; +struct cvmx_npei_bar1_indexx_s cn56xx; +struct cvmx_npei_bar1_indexx_s cn56xxp1; +}; + +typedef union cvmx_npei_bar1_indexx cvmx_npei_bar1_indexx_t ; + +/** +* cvmx_npei_bist_status +* +* NPEI_BIST_STATUS = NPI's BIST Status Register +* +* Results from BIST runs of NPEI's memories. +*/ +union cvmx_npei_bist_status { +u64 u64; +struct cvmx_npei_bist_status_s { +u64 pkt_rdf :1 ; +u64 reserved_60_62 :3 ; +u64 pcr_gim :1 ; +u64 pkt_pif :1 ; +u64 pcsr_int :1 ; +u64 pcsr_im :1 ; +u64 pcsr_cnt :1 ; +u64 pcsr_id :1 ; +u64 pcsr_sl :1 ; +u64 reserved_50_52 :3 ; +u64 pkt_ind :1 ; +u64 pkt_slm :1 ; +u64 reserved_36_47 :12 ; +u64 d0_pst :1 ; +u64 d1_pst :1 ; +u64 d2_pst :1 ; +u64 d3_pst :1 ; +u64 reserved_31_31 :1 ; +u64 n2p0_c :1 ; +u64 n2p0_o :1 ; +u64 n2p1_c :1 ; +u64 n2p1_o :1 ; +u64 cpl_p0 :1 ; +u64 cpl_p1 :1 ; +u64 p2n1_po :1 ; +u64 p2n1_no :1 ; +u64 p2n1_co :1 ; +u64 p2n0_po :1 ; +u64 p2n0_no :1 ; +u64 p2n0_co :1 ; +u64 p2n0_c0 :1 ; +u64 p2n0_c1 :1 ; +u64 p2n0_n :1 ; +u64 p2n0_p0 :1 ; +u64 p2n0_p1 :1 ; +u64 p2n1_c0 :1 ; +u64 p2n1_c1 :1 ; +u64 p2n1_n :1 ; +u64 p2n1_p0 :1 ; +u64 p2n1_p1 :1 ; +u64 csm0 :1 ; +u64 csm1 :1 ; +u64 dif0 :1 ; +u64 dif1 :1 ; +u64 dif2 :1 ; +u64 dif3 :1 ; +u64 reserved_2_2 :1 ; +u64 msi :1 ; +u64 ncb_cmd :1 ; + } s; +struct cvmx_npei_bist_status_cn52xx { +u64 pkt_rdf :1 ; +u64 reserved_60_62 :3 ; +u64 pcr_gim :1 ; +u64 pkt_pif :1 ; +u64 pcsr_int :1 ; +u64 pcsr_im :1 ; +u64 pcsr_cnt :1 ; +u64 pcsr_id :1 ; +u64 pcsr_sl :1 ; +u64 pkt_imem :1 ; +u64 pkt_pfm :1 ; +u64 pkt_pof :1 ; +u64 reserved_48_49 :2 ; +u64 pkt_pop0 :1 ; +u64 pkt_pop1 :1 ; +u64 d0_mem :1 ; +u64 d1_mem :1 ; +u64 d2_mem :1 ; +u64 d3_mem :1 ; +u64 d4_mem :1 ; +u64 ds_mem :1 ; +u64 reserved_36_39 :4 ; +u64 d0_pst :1 ; +u64 d1_pst :1 ; +u64 d2_pst :1 ; +u64 d3_pst :1 ; +u64 d4_pst :1 ; +u64 n2p0_c :1 ; +u64 n2p0_o :1 ; +u64 n2p1_c :1 ; +u64 n2p1_o :1 ; +u64 cpl_p0 :1 ; +u64 cpl_p1 :1 ; +u64 p2n1_po :1 ; +u64 p2n1_no :1 ; +u64 p2n1_co :1 ; +u64 p2n0_po :1 ; +u64 p2n0_no :1 ; +u64 p2n0_co :1 ; +u64 p2n0_c0 :1 ; +u64 p2n0_c1 :1 ; +u64 p2n0_n :1 ; +u64 p2n0_p0 :1 ; +u64 p2n0_p1 :1 ; +u64 p2n1_c0 :1 ; +u64 p2n1_c1 :1 ; +u64 p2n1_n :1 ; +u64 p2n1_p0 :1 ; +u64 p2n1_p1 :1 ; +u64 csm0 :1 ; +u64 csm1 :1 ; +u64 dif0 :1 ; +u64 dif1 :1 ; +u64 dif2 :1 ; +u64 dif3 :1 ; +u64 dif4 :1 ; +u64 msi :1 ; +u64 ncb_cmd :1 ; + } cn52xx; +struct cvmx_npei_bist_status_cn52xxp1 { +u64 reserved_46_63 :18 ; +u64 d0_mem0 :1 ; +u64 d1_mem1 :1 ; +u64 d2_mem2 :1 ; +u64 d3_mem3 :1 ; +u64 dr0_mem :1 ; +u64 d0_mem :1 ; +u64 d1_mem :1 ; +u64 d2_mem :1 ; +u64 d3_mem :1 ; +u64 dr1_mem :1 ; +u64 d0_pst :1 ; +u64 d1_pst :1 ; +u64 d2_pst :1 ; +u64 d3_pst :1 ; +u64 dr2_mem :1 ; +u64 n2p0_c :1 ; +u64 n2p0_o :1 ; +u64 n2p1_c :1 ; +u64 n2p1_o :1 ; +u64 cpl_p0 :1 ; +u64 cpl_p1 :1 ; +u64 p2n1_po :1 ; +u64 p2n1_no :1 ; +u64 p2n1_co :1 ; +u64 p2n0_po :1 ; +u64 p2n0_no :1 ; +u64 p2n0_co :1 ; +u64 p2n0_c0 :1 ; +u64 p2n0_c1 :1 ; +u64 p2n0_n :1 ; +u64 p2n0_p0 :1 ; +u64 p2n0_p1 :1 ; +u64 p2n1_c0 :1 ; +u64 p2n1_c1 :1 ; +u64 p2n1_n :1 ; +u64 p2n1_p0 :1 ; +u64 p2n1_p1 :1 ; +u64 csm0 :1 ; +u64 csm1 :1 ; +u64 dif0 :1 ; +u64 dif1 :1 ; +u64 dif2 :1 ; +u64 dif3 :1 ; +u64 dr3_mem :1 ; +u64 msi :1 ; +u64 ncb_cmd :1 ; + } cn52xxp1; +struct cvmx_npei_bist_status_cn52xx cn56xx; +struct cvmx_npei_bist_status_cn56xxp1 { +u64 reserved_58_63 :6 ; +u64 pcsr_int :1 ; +u64 pcsr_im :1 ; +u64 pcsr_cnt :1 ; +u64 pcsr_id :1 ; +u64 pcsr_sl :1 ; +u64 pkt_pout :1 ; +u64 pkt_imem :1 ; +u64 pkt_cntm :1 ; +u64 pkt_ind :1 ; +u64 pkt_slm :1 ; +u64 pkt_odf :1 ; +u64 pkt_oif :1 ; +u64 pkt_out :1 ; +u64 pkt_i0 :1 ; +u64 pkt_i1 :1 ; +u64 pkt_s0 :1 ; +u64 pkt_s1 :1 ; +u64 d0_mem :1 ; +u64 d1_mem :1 ; +u64 d2_mem :1 ; +u64 d3_mem :1 ; +u64 d4_mem :1 ; +u64 d0_pst :1 ; +u64 d1_pst :1 ; +u64 d2_pst :1 ; +u64 d3_pst :1 ; +u64 d4_pst :1 ; +u64 n2p0_c :1 ; +u64 n2p0_o :1 ; +u64 n2p1_c :1 ; +u64 n2p1_o :1 ; +u64 cpl_p0 :1 ; +u64 cpl_p1 :1 ; +u64 p2n1_po :1 ; +u64 p2n1_no :1 ; +u64 p2n1_co :1 ; +u64 p2n0_po :1 ; +u64 p2n0_no :1 ; +u64 p2n0_co :1 ; +u64 p2n0_c0 :1 ; +u64 p2n0_c1 :1 ; +u64 p2n0_n :1 ; +u64 p2n0_p0 :1 ; +u64 p2n0_p1 :1 ; +u64 p2n1_c0 :1 ; +u64 p2n1_c1 :1 ; +u64 p2n1_n :1 ; +u64 p2n1_p0 :1 ; +u64 p2n1_p1 :1 ; +u64 csm0 :1 ; +u64 csm1 :1 ; +u64 dif0 :1 ; +u64 dif1 :1 ; +u64 dif2 :1 ; +u64 dif3 :1 ; +u64 dif4 :1 ; +u64 msi :1 ; +u64 ncb_cmd :1 ; + } cn56xxp1; +}; + +typedef union cvmx_npei_bist_status cvmx_npei_bist_status_t ; + +/** +* cvmx_npei_bist_status2 +* +* NPEI_BIST_STATUS2 = NPI's BIST Status Register2 +* +* Results from BIST runs of NPEI's memories. +*/ +union cvmx_npei_bist_status2 { +u64 u64; +struct cvmx_npei_bist_status2_s { +u64 reserved_14_63 :50 ; +u64 prd_tag :1 ; +u64 prd_st0 :1 ; +u64 prd_st1 :1 ; +u64 prd_err :1 ; +u64 nrd_st :1 ; +u64 nwe_st :1 ; +u64 nwe_wr0 :1 ; +u64 nwe_wr1 :1 ; +u64 pkt_rd :1 ; +u64 psc_p0 :1 ; +u64 psc_p1 :1 ; +u64 pkt_gd :1 ; +u64 pkt_gl :1 ; +u64 pkt_blk :1 ; + } s; +struct cvmx_npei_bist_status2_s cn52xx; +struct cvmx_npei_bist_status2_s cn56xx; +}; + +typedef union cvmx_npei_bist_status2 cvmx_npei_bist_status2_t ; + +/** +* cvmx_npei_ctl_port0 +* +* NPEI_CTL_PORT0 = NPEI's Control Port 0 +* +* Contains control for access for Port0 +*/ +union cvmx_npei_ctl_port0 { +u64 u64; +struct cvmx_npei_ctl_port0_s { +u64 reserved_21_63 :43 ; +u64 waitl_com :1 ; +u64 intd :1 ; +u64 intc :1 ; +u64 intb :1 ; +u64 inta :1 ; +u64 intd_map :2 ; +u64 intc_map :2 ; +u64 intb_map :2 ; +u64 inta_map :2 ; +u64 ctlp_ro :1 ; +u64 reserved_6_6 :1 ; +u64 ptlp_ro :1 ; +u64 bar2_enb :1 ; +u64 bar2_esx :2 ; +u64 bar2_cax :1 ; +u64 wait_com :1 ; + } s; +struct cvmx_npei_ctl_port0_s cn52xx; +struct cvmx_npei_ctl_port0_s cn52xxp1; +struct cvmx_npei_ctl_port0_s cn56xx; +struct cvmx_npei_ctl_port0_s cn56xxp1; +}; + +typedef union cvmx_npei_ctl_port0 cvmx_npei_ctl_port0_t ; + +/** +* cvmx_npei_ctl_port1 +* +* NPEI_CTL_PORT1 = NPEI's Control Port1 +* +* Contains control for access for Port1 +*/ +union cvmx_npei_ctl_port1 { +u64 u64; +struct cvmx_npei_ctl_port1_s { +u64 reserved_21_63 :43 ; +u64 waitl_com :1 ; +u64 intd :1 ; +u64 intc :1 ; +u64 intb :1 ; +u64 inta :1 ; +u64 intd_map :2 ; +u64 intc_map :2 ; +u64 intb_map :2 ; +u64 inta_map :2 ; +u64 ctlp_ro :1 ; +u64 reserved_6_6 :1 ; +u64 ptlp_ro :1 ; +u64 bar2_enb :1 ; +u64 bar2_esx :2 ; +u64 bar2_cax :1 ; +u64 wait_com :1 ; + } s; +struct cvmx_npei_ctl_port1_s cn52xx; +struct cvmx_npei_ctl_port1_s cn52xxp1; +struct cvmx_npei_ctl_port1_s cn56xx; +struct cvmx_npei_ctl_port1_s cn56xxp1; +}; + +typedef union cvmx_npei_ctl_port1 cvmx_npei_ctl_port1_t ; + +/** +* cvmx_npei_ctl_status +* +* NPEI_CTL_STATUS = NPEI Control Status Register +* +* Contains control and status for NPEI. Writes to this register are not +* oSrdered with writes/reads to the PCIe Memory space. +* To ensure that a write has completed the user must read the register +* before making an access(i.e. PCIe memory space) +* that requires the value of this register to be updated. +*/ +union cvmx_npei_ctl_status { +u64 u64; +struct cvmx_npei_ctl_status_s { +u64 reserved_44_63 :20 ; +u64 p1_ntags :6 ; +u64 p0_ntags :6 ; +u64 cfg_rtry :16 ; +u64 ring_en :1 ; +u64 lnk_rst :1 ; +u64 arb :1 ; +u64 pkt_bp :4 ; +u64 host_mode :1 ; +u64 chip_rev :8 ; + } s; +struct cvmx_npei_ctl_status_s cn52xx; +struct cvmx_npei_ctl_status_cn52xxp1 { +u64 reserved_44_63 :20 ; +u64 p1_ntags :6 ; +u64 p0_ntags :6 ; +u64 cfg_rtry :16 ; +u64 reserved_15_15 :1 ; +u64 lnk_rst :1 ; +u64 arb :1 ; +u64 reserved_9_12 :4 ; +u64 host_mode :1 ; +u64 chip_rev :8 ; + } cn52xxp1; +struct cvmx_npei_ctl_status_s cn56xx; +struct cvmx_npei_ctl_status_cn56xxp1 { +u64 reserved_15_63 :49 ; +u64 lnk_rst :1 ; +u64 arb :1 ; +u64 pkt_bp :4 ; +u64 host_mode :1 ; +u64 chip_rev :8 ; + } cn56xxp1; +}; + +typedef union cvmx_npei_ctl_status cvmx_npei_ctl_status_t ; + +/** +* cvmx_npei_ctl_status2 +* +* NPEI_CTL_STATUS2 = NPEI's Control Status2 Register +* +* Contains control and status for NPEI. +* Writes to this register are not ordered with writes/reads to the PCI +* Memory space. +* To ensure that a write has completed the user must read the register before +* making an access(i.e. PCI memory space) that requires the value of this +* register to be updated. +*/ +union cvmx_npei_ctl_status2 { +u64 u64; +struct cvmx_npei_ctl_status2_s { +u64 reserved_16_63 :48 ; +u64 mps :1 ; +u64 mrrs :3 ; +u64 c1_w_flt :1 ; +u64 c0_w_flt :1 ; +u64 c1_b1_s :3 ; +u64 c0_b1_s :3 ; +u64 c1_wi_d :1 ; +u64 c1_b0_d :1 ; +u64 c0_wi_d :1 ; +u64 c0_b0_d :1 ; + } s; +struct cvmx_npei_ctl_status2_s cn52xx; +struct cvmx_npei_ctl_status2_s cn52xxp1; +struct cvmx_npei_ctl_status2_s cn56xx; +struct cvmx_npei_ctl_status2_s cn56xxp1; +}; + +typedef union cvmx_npei_ctl_status2 cvmx_npei_ctl_status2_t ; + +/** +* cvmx_npei_data_out_cnt +* +* NPEI_DATA_OUT_CNT = NPEI DATA OUT COUNT +* +* The EXEC data out fifo-count and the data unload counter. +*/ +union cvmx_npei_data_out_cnt { +u64 u64; +struct cvmx_npei_data_out_cnt_s { +u64 reserved_44_63 :20 ; +u64 p1_ucnt :16 ; +u64 p1_fcnt :6 ; +u64 p0_ucnt :16 ; +u64 p0_fcnt :6 ; + } s; +struct cvmx_npei_data_out_cnt_s cn52xx; +struct cvmx_npei_data_out_cnt_s cn52xxp1; +struct cvmx_npei_data_out_cnt_s cn56xx; +struct cvmx_npei_data_out_cnt_s cn56xxp1; +}; + +typedef union cvmx_npei_data_out_cnt cvmx_npei_data_out_cnt_t ; + +/** +* cvmx_npei_dbg_data +* +* NPEI_DBG_DATA = NPEI Debug Data Register +* +* Value returned on the debug-data lines from the RSLs +*/ +union cvmx_npei_dbg_data { +u64 u64; +struct cvmx_npei_dbg_data_s { +u64 reserved_28_63 :36 ; +u64 qlm0_rev_lanes :1 ; +u64 reserved_25_26 :2 ; +u64 qlm1_spd :2 ; +u64 c_mul :5 ; +u64 dsel_ext :1 ; +u64 data :17 ; + } s; +struct cvmx_npei_dbg_data_cn52xx { +u64 reserved_29_63 :35 ; +u64 qlm0_link_width :1 ; +u64 qlm0_rev_lanes :1 ; +u64 qlm1_mode :2 ; +u64 qlm1_spd :2 ; +u64 c_mul :5 ; +u64 dsel_ext :1 ; +u64 data :17 ; + } cn52xx; +struct cvmx_npei_dbg_data_cn52xx cn52xxp1; +struct cvmx_npei_dbg_data_cn56xx { +u64 reserved_29_63 :35 ; +u64 qlm2_rev_lanes :1 ; +u64 qlm0_rev_lanes :1 ; +u64 qlm3_spd :2 ; +u64 qlm1_spd :2 ; +u64 c_mul :5 ; +u64 dsel_ext :1 ; +u64 data :17 ; + } cn56xx; +struct cvmx_npei_dbg_data_cn56xx cn56xxp1; +}; + +typedef union cvmx_npei_dbg_data cvmx_npei_dbg_data_t ; + +/** +* cvmx_npei_dbg_select +* +* NPEI_DBG_SELECT = Debug Select Register +* +* Contains the debug select value last written to the RSLs. +*/ +union cvmx_npei_dbg_select { +u64 u64; +struct cvmx_npei_dbg_select_s { +u64 reserved_16_63 :48 ; +u64 dbg_sel :16 ; + } s; +struct cvmx_npei_dbg_select_s cn52xx; +struct cvmx_npei_dbg_select_s cn52xxp1; +struct cvmx_npei_dbg_select_s cn56xx; +struct cvmx_npei_dbg_select_s cn56xxp1; +}; + +typedef union cvmx_npei_dbg_select cvmx_npei_dbg_select_t ; + +/** +* cvmx_npei_dma#_counts +* +* NPEI_DMA[0..4]_COUNTS = DMA Instruction Counts +* +* Values for determing the number of instructions for DMA[0..4] in the NPEI. +*/ +union cvmx_npei_dmax_counts { +u64 u64; +struct cvmx_npei_dmax_counts_s { +u64 reserved_39_63 :25 ; +u64 fcnt :7 ; +u64 dbell :32 ; + } s; +struct cvmx_npei_dmax_counts_s cn52xx; +struct cvmx_npei_dmax_counts_s cn52xxp1; +struct cvmx_npei_dmax_counts_s cn56xx; +struct cvmx_npei_dmax_counts_s cn56xxp1; +}; + +typedef union cvmx_npei_dmax_counts cvmx_npei_dmax_counts_t ; + +/** +* cvmx_npei_dma#_dbell +* +* NPEI_DMA_DBELL[0..4] = DMA Door Bell +* +* The door bell register for DMA[0..4] queue. +*/ +union cvmx_npei_dmax_dbell { +u32 u32; +struct cvmx_npei_dmax_dbell_s { +u32 reserved_16_31 :16 ; +u32 dbell :16 ; + } s; +struct cvmx_npei_dmax_dbell_s cn52xx; +struct cvmx_npei_dmax_dbell_s cn52xxp1; +struct cvmx_npei_dmax_dbell_s cn56xx; +struct cvmx_npei_dmax_dbell_s cn56xxp1; +}; + +typedef union cvmx_npei_dmax_dbell cvmx_npei_dmax_dbell_t ; + +/** +* cvmx_npei_dma#_ibuff_saddr +* +* NPEI_DMA[0..4]_IBUFF_SADDR = DMA Instruction Buffer Starting Address +* +* The address to start reading Instructions from for DMA[0..4]. +*/ +union cvmx_npei_dmax_ibuff_saddr { +u64 u64; +struct cvmx_npei_dmax_ibuff_saddr_s { +u64 reserved_37_63 :27 ; +u64 idle :1 ; +u64 saddr :29 ; +u64 reserved_0_6 :7 ; + } s; +struct cvmx_npei_dmax_ibuff_saddr_s cn52xx; +struct cvmx_npei_dmax_ibuff_saddr_cn52xxp1 { +u64 reserved_36_63 :28 ; +u64 saddr :29 ; +u64 reserved_0_6 :7 ; + } cn52xxp1; +struct cvmx_npei_dmax_ibuff_saddr_s cn56xx; +struct cvmx_npei_dmax_ibuff_saddr_cn52xxp1 cn56xxp1; +}; + +typedef union cvmx_npei_dmax_ibuff_saddr cvmx_npei_dmax_ibuff_saddr_t ; + +/** +* cvmx_npei_dma#_naddr +* +* NPEI_DMA[0..4]_NADDR = DMA Next Ichunk Address +* +* Place NPEI will read the next Ichunk data from. This is valid when state is 0 +*/ +union cvmx_npei_dmax_naddr { +u64 u64; +struct cvmx_npei_dmax_naddr_s { +u64 reserved_36_63 :28 ; +u64 addr :36 ; + } s; +struct cvmx_npei_dmax_naddr_s cn52xx; +struct cvmx_npei_dmax_naddr_s cn52xxp1; +struct cvmx_npei_dmax_naddr_s cn56xx; +struct cvmx_npei_dmax_naddr_s cn56xxp1; +}; + +typedef union cvmx_npei_dmax_naddr cvmx_npei_dmax_naddr_t ; + +/** +* cvmx_npei_dma0_int_level +* +* NPEI_DMA0_INT_LEVEL = NPEI DMA0 Interrupt Level +* +* Thresholds for DMA count and timer interrupts for DMA0. +*/ +union cvmx_npei_dma0_int_level { +u64 u64; +struct cvmx_npei_dma0_int_level_s { +u64 time :32 ; +u64 cnt :32 ; + } s; +struct cvmx_npei_dma0_int_level_s cn52xx; +struct cvmx_npei_dma0_int_level_s cn52xxp1; +struct cvmx_npei_dma0_int_level_s cn56xx; +struct cvmx_npei_dma0_int_level_s cn56xxp1; +}; + +typedef union cvmx_npei_dma0_int_level cvmx_npei_dma0_int_level_t ; + +/** +* cvmx_npei_dma1_int_level +* +* NPEI_DMA1_INT_LEVEL = NPEI DMA1 Interrupt Level +* +* Thresholds for DMA count and timer interrupts for DMA1. +*/ +union cvmx_npei_dma1_int_level { +u64 u64; +struct cvmx_npei_dma1_int_level_s { +u64 time :32 ; +u64 cnt :32 ; + } s; +struct cvmx_npei_dma1_int_level_s cn52xx; +struct cvmx_npei_dma1_int_level_s cn52xxp1; +struct cvmx_npei_dma1_int_level_s cn56xx; +struct cvmx_npei_dma1_int_level_s cn56xxp1; +}; + +typedef union cvmx_npei_dma1_int_level cvmx_npei_dma1_int_level_t ; + +/** +* cvmx_npei_dma_cnts +* +* NPEI_DMA_CNTS = NPEI DMA Count +* +* The DMA Count values for DMA0 and DMA1. +*/ +union cvmx_npei_dma_cnts { +u64 u64; +struct cvmx_npei_dma_cnts_s { +u64 dma1 :32 ; +u64 dma0 :32 ; + } s; +struct cvmx_npei_dma_cnts_s cn52xx; +struct cvmx_npei_dma_cnts_s cn52xxp1; +struct cvmx_npei_dma_cnts_s cn56xx; +struct cvmx_npei_dma_cnts_s cn56xxp1; +}; + +typedef union cvmx_npei_dma_cnts cvmx_npei_dma_cnts_t ; + +/** +* cvmx_npei_dma_control +* +* NPEI_DMA_CONTROL = DMA Control Register +* +* Controls operation of the DMA IN/OUT. +*/ +union cvmx_npei_dma_control { +u64 u64; +struct cvmx_npei_dma_control_s { +u64 reserved_40_63 :24 ; +u64 p_32b_m :1 ; +u64 dma4_enb :1 ; +u64 dma3_enb :1 ; +u64 dma2_enb :1 ; +u64 dma1_enb :1 ; +u64 dma0_enb :1 ; +u64 b0_lend :1 ; +u64 dwb_denb :1 ; +u64 dwb_ichk :9 ; +u64 fpa_que :3 ; +u64 o_add1 :1 ; +u64 o_ro :1 ; +u64 o_ns :1 ; +u64 o_es :2 ; +u64 o_mode :1 ; +u64 csize :14 ; + } s; +struct cvmx_npei_dma_control_s cn52xx; +struct cvmx_npei_dma_control_cn52xxp1 { +u64 reserved_38_63 :26 ; +u64 dma3_enb :1 ; +u64 dma2_enb :1 ; +u64 dma1_enb :1 ; +u64 dma0_enb :1 ; +u64 b0_lend :1 ; +u64 dwb_denb :1 ; +u64 dwb_ichk :9 ; +u64 fpa_que :3 ; +u64 o_add1 :1 ; +u64 o_ro :1 ; +u64 o_ns :1 ; +u64 o_es :2 ; +u64 o_mode :1 ; +u64 csize :14 ; + } cn52xxp1; +struct cvmx_npei_dma_control_s cn56xx; +struct cvmx_npei_dma_control_cn56xxp1 { +u64 reserved_39_63 :25 ; +u64 dma4_enb :1 ; +u64 dma3_enb :1 ; +u64 dma2_enb :1 ; +u64 dma1_enb :1 ; +u64 dma0_enb :1 ; +u64 b0_lend :1 ; +u64 dwb_denb :1 ; +u64 dwb_ichk :9 ; +u64 fpa_que :3 ; +u64 o_add1 :1 ; +u64 o_ro :1 ; +u64 o_ns :1 ; +u64 o_es :2 ; +u64 o_mode :1 ; +u64 csize :14 ; + } cn56xxp1; +}; + +typedef union cvmx_npei_dma_control cvmx_npei_dma_control_t ; + +/** +* cvmx_npei_dma_pcie_req_num +* +* NPEI_DMA_PCIE_REQ_NUM = NPEI DMA PCIE Outstanding Read Request Number +* +* Outstanding PCIE read request number for DMAs and Packet, maximum number +* is 16 +*/ +union cvmx_npei_dma_pcie_req_num { +u64 u64; +struct cvmx_npei_dma_pcie_req_num_s { +u64 dma_arb :1 ; +u64 reserved_53_62 :10 ; +u64 pkt_cnt :5 ; +u64 reserved_45_47 :3 ; +u64 dma4_cnt :5 ; +u64 reserved_37_39 :3 ; +u64 dma3_cnt :5 ; +u64 reserved_29_31 :3 ; +u64 dma2_cnt :5 ; +u64 reserved_21_23 :3 ; +u64 dma1_cnt :5 ; +u64 reserved_13_15 :3 ; +u64 dma0_cnt :5 ; +u64 reserved_5_7 :3 ; +u64 dma_cnt :5 ; + } s; +struct cvmx_npei_dma_pcie_req_num_s cn52xx; +struct cvmx_npei_dma_pcie_req_num_s cn56xx; +}; + +typedef union cvmx_npei_dma_pcie_req_num cvmx_npei_dma_pcie_req_num_t ; + +/** +* cvmx_npei_dma_state1 +* +* NPEI_DMA_STATE1 = NPI's DMA State 1 +* +* Results from DMA state register 1 +*/ +union cvmx_npei_dma_state1 { +u64 u64; +struct cvmx_npei_dma_state1_s { +u64 reserved_40_63 :24 ; +u64 d4_dwe :8 ; +u64 d3_dwe :8 ; +u64 d2_dwe :8 ; +u64 d1_dwe :8 ; +u64 d0_dwe :8 ; + } s; +struct cvmx_npei_dma_state1_s cn52xx; +}; + +typedef union cvmx_npei_dma_state1 cvmx_npei_dma_state1_t ; + +/** +* cvmx_npei_dma_state1_p1 +* +* NPEI_DMA_STATE1_P1 = NPEI DMA Request and Instruction State +* +* DMA engine Debug information. +*/ +union cvmx_npei_dma_state1_p1 { +u64 u64; +struct cvmx_npei_dma_state1_p1_s { +u64 reserved_60_63 :4 ; +u64 d0_difst :7 ; +u64 d1_difst :7 ; +u64 d2_difst :7 ; +u64 d3_difst :7 ; +u64 d4_difst :7 ; +u64 d0_reqst :5 ; +u64 d1_reqst :5 ; +u64 d2_reqst :5 ; +u64 d3_reqst :5 ; +u64 d4_reqst :5 ; + } s; +struct cvmx_npei_dma_state1_p1_cn52xxp1 { +u64 reserved_60_63 :4 ; +u64 d0_difst :7 ; +u64 d1_difst :7 ; +u64 d2_difst :7 ; +u64 d3_difst :7 ; +u64 reserved_25_31 :7 ; +u64 d0_reqst :5 ; +u64 d1_reqst :5 ; +u64 d2_reqst :5 ; +u64 d3_reqst :5 ; +u64 reserved_0_4 :5 ; + } cn52xxp1; +struct cvmx_npei_dma_state1_p1_s cn56xxp1; +}; + +typedef union cvmx_npei_dma_state1_p1 cvmx_npei_dma_state1_p1_t ; + +/** +* cvmx_npei_dma_state2 +* +* NPEI_DMA_STATE2 = NPI's DMA State 2 +* +* Results from DMA state register 2 +*/ +union cvmx_npei_dma_state2 { +u64 u64; +struct cvmx_npei_dma_state2_s { +u64 reserved_28_63 :36 ; +u64 ndwe :4 ; +u64 reserved_21_23 :3 ; +u64 ndre :5 ; +u64 reserved_10_15 :6 ; +u64 prd :10 ; + } s; +struct cvmx_npei_dma_state2_s cn52xx; +}; + +typedef union cvmx_npei_dma_state2 cvmx_npei_dma_state2_t ; + +/** +* cvmx_npei_dma_state2_p1 +* +* NPEI_DMA_STATE2_P1 = NPEI DMA Instruction Fetch State +* +* DMA engine Debug information. +*/ +union cvmx_npei_dma_state2_p1 { +u64 u64; +struct cvmx_npei_dma_state2_p1_s { +u64 reserved_45_63 :19 ; +u64 d0_dffst :9 ; +u64 d1_dffst :9 ; +u64 d2_dffst :9 ; +u64 d3_dffst :9 ; +u64 d4_dffst :9 ; + } s; +struct cvmx_npei_dma_state2_p1_cn52xxp1 { +u64 reserved_45_63 :19 ; +u64 d0_dffst :9 ; +u64 d1_dffst :9 ; +u64 d2_dffst :9 ; +u64 d3_dffst :9 ; +u64 reserved_0_8 :9 ; + } cn52xxp1; +struct cvmx_npei_dma_state2_p1_s cn56xxp1; +}; + +typedef union cvmx_npei_dma_state2_p1 cvmx_npei_dma_state2_p1_t ; + +/** +* cvmx_npei_dma_state3_p1 +* +* NPEI_DMA_STATE3_P1 = NPEI DMA DRE State +* +* DMA engine Debug information. +*/ +union cvmx_npei_dma_state3_p1 { +u64 u64; +struct cvmx_npei_dma_state3_p1_s { +u64 reserved_60_63 :4 ; +u64 d0_drest :15 ; +u64 d1_drest :15 ; +u64 d2_drest :15 ; +u64 d3_drest :15 ; + } s; +struct cvmx_npei_dma_state3_p1_s cn52xxp1; +struct cvmx_npei_dma_state3_p1_s cn56xxp1; +}; + +typedef union cvmx_npei_dma_state3_p1 cvmx_npei_dma_state3_p1_t ; + +/** +* cvmx_npei_dma_state4_p1 +* +* NPEI_DMA_STATE4_P1 = NPEI DMA DWE State +* +* DMA engine Debug information. +*/ +union cvmx_npei_dma_state4_p1 { +u64 u64; +struct cvmx_npei_dma_state4_p1_s { +u64 reserved_52_63 :12 ; +u64 d0_dwest :13 ; +u64 d1_dwest :13 ; +u64 d2_dwest :13 ; +u64 d3_dwest :13 ; + } s; +struct cvmx_npei_dma_state4_p1_s cn52xxp1; +struct cvmx_npei_dma_state4_p1_s cn56xxp1; +}; + +typedef union cvmx_npei_dma_state4_p1 cvmx_npei_dma_state4_p1_t ; + +/** +* cvmx_npei_dma_state5_p1 +* +* NPEI_DMA_STATE5_P1 = NPEI DMA DWE and DRE State +* +* DMA engine Debug information. +*/ +union cvmx_npei_dma_state5_p1 { +u64 u64; +struct cvmx_npei_dma_state5_p1_s { +u64 reserved_28_63 :36 ; +u64 d4_drest :15 ; +u64 d4_dwest :13 ; + } s; +struct cvmx_npei_dma_state5_p1_s cn56xxp1; +}; + +typedef union cvmx_npei_dma_state5_p1 cvmx_npei_dma_state5_p1_t ; + +/** +* cvmx_npei_int_a_enb +* +* NPEI_INTERRUPT_A_ENB = NPI's Interrupt A Enable Register +* +* Used to allow the generation of interrupts (MSI/INTA) to the PCIe +* CoresUsed to enable the various interrupting conditions of NPEI +*/ +union cvmx_npei_int_a_enb { +u64 u64; +struct cvmx_npei_int_a_enb_s { +u64 reserved_10_63 :54 ; +u64 pout_err :1 ; +u64 pin_bp :1 ; +u64 p1_rdlk :1 ; +u64 p0_rdlk :1 ; +u64 pgl_err :1 ; +u64 pdi_err :1 ; +u64 pop_err :1 ; +u64 pins_err :1 ; +u64 dma1_cpl :1 ; +u64 dma0_cpl :1 ; + } s; +struct cvmx_npei_int_a_enb_s cn52xx; +struct cvmx_npei_int_a_enb_cn52xxp1 { +u64 reserved_2_63 :62 ; +u64 dma1_cpl :1 ; +u64 dma0_cpl :1 ; + } cn52xxp1; +struct cvmx_npei_int_a_enb_s cn56xx; +}; + +typedef union cvmx_npei_int_a_enb cvmx_npei_int_a_enb_t ; + +/** +* cvmx_npei_int_a_enb2 +* +* NPEI_INTERRUPT_A_ENB2 = NPEI's Interrupt A Enable2 Register +* +* Used to enable the various interrupting conditions of NPEI +*/ +union cvmx_npei_int_a_enb2 { +u64 u64; +struct cvmx_npei_int_a_enb2_s { +u64 reserved_10_63 :54 ; +u64 pout_err :1 ; +u64 pin_bp :1 ; +u64 p1_rdlk :1 ; +u64 p0_rdlk :1 ; +u64 pgl_err :1 ; +u64 pdi_err :1 ; +u64 pop_err :1 ; +u64 pins_err :1 ; +u64 dma1_cpl :1 ; +u64 dma0_cpl :1 ; + } s; +struct cvmx_npei_int_a_enb2_s cn52xx; +struct cvmx_npei_int_a_enb2_cn52xxp1 { +u64 reserved_2_63 :62 ; +u64 dma1_cpl :1 ; +u64 dma0_cpl :1 ; + } cn52xxp1; +struct cvmx_npei_int_a_enb2_s cn56xx; +}; + +typedef union cvmx_npei_int_a_enb2 cvmx_npei_int_a_enb2_t ; + +/** +* cvmx_npei_int_a_sum +* +* NPEI_INTERRUPT_A_SUM = NPI Interrupt A Summary Register +* +* Set when an interrupt condition occurs, write '1' to clear. When an +* interrupt bitin this register is set and +* the cooresponding bit in the NPEI_INT_A_ENB register is set, then +* NPEI_INT_SUM[61] will be set. +*/ +union cvmx_npei_int_a_sum { +u64 u64; +struct cvmx_npei_int_a_sum_s { +u64 reserved_10_63 :54 ; +u64 pout_err :1 ; +u64 pin_bp :1 ; +u64 p1_rdlk :1 ; +u64 p0_rdlk :1 ; +u64 pgl_err :1 ; +u64 pdi_err :1 ; +u64 pop_err :1 ; +u64 pins_err :1 ; +u64 dma1_cpl :1 ; +u64 dma0_cpl :1 ; + } s; +struct cvmx_npei_int_a_sum_s cn52xx; +struct cvmx_npei_int_a_sum_cn52xxp1 { +u64 reserved_2_63 :62 ; +u64 dma1_cpl :1 ; +u64 dma0_cpl :1 ; + } cn52xxp1; +struct cvmx_npei_int_a_sum_s cn56xx; +}; + +typedef union cvmx_npei_int_a_sum cvmx_npei_int_a_sum_t ; + +/** +* cvmx_npei_int_enb +* +* NPEI_INTERRUPT_ENB = NPI's Interrupt Enable Register +* +* Used to allow the generation of interrupts (MSI/INTA) to the PCIe +* CoresUsed to enable the various interrupting conditions of NPI +*/ +union cvmx_npei_int_enb { +u64 u64; +struct cvmx_npei_int_enb_s { +u64 mio_inta :1 ; +u64 reserved_62_62 :1 ; +u64 int_a :1 ; +u64 c1_ldwn :1 ; +u64 c0_ldwn :1 ; +u64 c1_exc :1 ; +u64 c0_exc :1 ; +u64 c1_up_wf :1 ; +u64 c0_up_wf :1 ; +u64 c1_un_wf :1 ; +u64 c0_un_wf :1 ; +u64 c1_un_bx :1 ; +u64 c1_un_wi :1 ; +u64 c1_un_b2 :1 ; +u64 c1_un_b1 :1 ; +u64 c1_un_b0 :1 ; +u64 c1_up_bx :1 ; +u64 c1_up_wi :1 ; +u64 c1_up_b2 :1 ; +u64 c1_up_b1 :1 ; +u64 c1_up_b0 :1 ; +u64 c0_un_bx :1 ; +u64 c0_un_wi :1 ; +u64 c0_un_b2 :1 ; +u64 c0_un_b1 :1 ; +u64 c0_un_b0 :1 ; +u64 c0_up_bx :1 ; +u64 c0_up_wi :1 ; +u64 c0_up_b2 :1 ; +u64 c0_up_b1 :1 ; +u64 c0_up_b0 :1 ; +u64 c1_hpint :1 ; +u64 c1_pmei :1 ; +u64 c1_wake :1 ; +u64 crs1_dr :1 ; +u64 c1_se :1 ; +u64 crs1_er :1 ; +u64 c1_aeri :1 ; +u64 c0_hpint :1 ; +u64 c0_pmei :1 ; +u64 c0_wake :1 ; +u64 crs0_dr :1 ; +u64 c0_se :1 ; +u64 crs0_er :1 ; +u64 c0_aeri :1 ; +u64 ptime :1 ; +u64 pcnt :1 ; +u64 pidbof :1 ; +u64 psldbof :1 ; +u64 dtime1 :1 ; +u64 dtime0 :1 ; +u64 dcnt1 :1 ; +u64 dcnt0 :1 ; +u64 dma1fi :1 ; +u64 dma0fi :1 ; +u64 dma4dbo :1 ; +u64 dma3dbo :1 ; +u64 dma2dbo :1 ; +u64 dma1dbo :1 ; +u64 dma0dbo :1 ; +u64 iob2big :1 ; +u64 bar0_to :1 ; +u64 rml_wto :1 ; +u64 rml_rto :1 ; + } s; +struct cvmx_npei_int_enb_s cn52xx; +struct cvmx_npei_int_enb_cn52xxp1 { +u64 mio_inta :1 ; +u64 reserved_62_62 :1 ; +u64 int_a :1 ; +u64 c1_ldwn :1 ; +u64 c0_ldwn :1 ; +u64 c1_exc :1 ; +u64 c0_exc :1 ; +u64 c1_up_wf :1 ; +u64 c0_up_wf :1 ; +u64 c1_un_wf :1 ; +u64 c0_un_wf :1 ; +u64 c1_un_bx :1 ; +u64 c1_un_wi :1 ; +u64 c1_un_b2 :1 ; +u64 c1_un_b1 :1 ; +u64 c1_un_b0 :1 ; +u64 c1_up_bx :1 ; +u64 c1_up_wi :1 ; +u64 c1_up_b2 :1 ; +u64 c1_up_b1 :1 ; +u64 c1_up_b0 :1 ; +u64 c0_un_bx :1 ; +u64 c0_un_wi :1 ; +u64 c0_un_b2 :1 ; +u64 c0_un_b1 :1 ; +u64 c0_un_b0 :1 ; +u64 c0_up_bx :1 ; +u64 c0_up_wi :1 ; +u64 c0_up_b2 :1 ; +u64 c0_up_b1 :1 ; +u64 c0_up_b0 :1 ; +u64 c1_hpint :1 ; +u64 c1_pmei :1 ; +u64 c1_wake :1 ; +u64 crs1_dr :1 ; +u64 c1_se :1 ; +u64 crs1_er :1 ; +u64 c1_aeri :1 ; +u64 c0_hpint :1 ; +u64 c0_pmei :1 ; +u64 c0_wake :1 ; +u64 crs0_dr :1 ; +u64 c0_se :1 ; +u64 crs0_er :1 ; +u64 c0_aeri :1 ; +u64 ptime :1 ; +u64 pcnt :1 ; +u64 pidbof :1 ; +u64 psldbof :1 ; +u64 dtime1 :1 ; +u64 dtime0 :1 ; +u64 dcnt1 :1 ; +u64 dcnt0 :1 ; +u64 dma1fi :1 ; +u64 dma0fi :1 ; +u64 reserved_8_8 :1 ; +u64 dma3dbo :1 ; +u64 dma2dbo :1 ; +u64 dma1dbo :1 ; +u64 dma0dbo :1 ; +u64 iob2big :1 ; +u64 bar0_to :1 ; +u64 rml_wto :1 ; +u64 rml_rto :1 ; + } cn52xxp1; +struct cvmx_npei_int_enb_s cn56xx; +struct cvmx_npei_int_enb_cn56xxp1 { +u64 mio_inta :1 ; +u64 reserved_61_62 :2 ; +u64 c1_ldwn :1 ; +u64 c0_ldwn :1 ; +u64 c1_exc :1 ; +u64 c0_exc :1 ; +u64 c1_up_wf :1 ; +u64 c0_up_wf :1 ; +u64 c1_un_wf :1 ; +u64 c0_un_wf :1 ; +u64 c1_un_bx :1 ; +u64 c1_un_wi :1 ; +u64 c1_un_b2 :1 ; +u64 c1_un_b1 :1 ; +u64 c1_un_b0 :1 ; +u64 c1_up_bx :1 ; +u64 c1_up_wi :1 ; +u64 c1_up_b2 :1 ; +u64 c1_up_b1 :1 ; +u64 c1_up_b0 :1 ; +u64 c0_un_bx :1 ; +u64 c0_un_wi :1 ; +u64 c0_un_b2 :1 ; +u64 c0_un_b1 :1 ; +u64 c0_un_b0 :1 ; +u64 c0_up_bx :1 ; +u64 c0_up_wi :1 ; +u64 c0_up_b2 :1 ; +u64 c0_up_b1 :1 ; +u64 c0_up_b0 :1 ; +u64 c1_hpint :1 ; +u64 c1_pmei :1 ; +u64 c1_wake :1 ; +u64 reserved_29_29 :1 ; +u64 c1_se :1 ; +u64 reserved_27_27 :1 ; +u64 c1_aeri :1 ; +u64 c0_hpint :1 ; +u64 c0_pmei :1 ; +u64 c0_wake :1 ; +u64 reserved_22_22 :1 ; +u64 c0_se :1 ; +u64 reserved_20_20 :1 ; +u64 c0_aeri :1 ; +u64 ptime :1 ; +u64 pcnt :1 ; +u64 pidbof :1 ; +u64 psldbof :1 ; +u64 dtime1 :1 ; +u64 dtime0 :1 ; +u64 dcnt1 :1 ; +u64 dcnt0 :1 ; +u64 dma1fi :1 ; +u64 dma0fi :1 ; +u64 dma4dbo :1 ; +u64 dma3dbo :1 ; +u64 dma2dbo :1 ; +u64 dma1dbo :1 ; +u64 dma0dbo :1 ; +u64 iob2big :1 ; +u64 bar0_to :1 ; +u64 rml_wto :1 ; +u64 rml_rto :1 ; + } cn56xxp1; +}; + +typedef union cvmx_npei_int_enb cvmx_npei_int_enb_t ; + +/** +* cvmx_npei_int_enb2 +* +* NPEI_INTERRUPT_ENB2 = NPI's Interrupt Enable2 Register +* +* Used to enable the various interrupting conditions of NPI +*/ +union cvmx_npei_int_enb2 { +u64 u64; +struct cvmx_npei_int_enb2_s { +u64 reserved_62_63 :2 ; +u64 int_a :1 ; +u64 c1_ldwn :1 ; +u64 c0_ldwn :1 ; +u64 c1_exc :1 ; +u64 c0_exc :1 ; +u64 c1_up_wf :1 ; +u64 c0_up_wf :1 ; +u64 c1_un_wf :1 ; +u64 c0_un_wf :1 ; +u64 c1_un_bx :1 ; +u64 c1_un_wi :1 ; +u64 c1_un_b2 :1 ; +u64 c1_un_b1 :1 ; +u64 c1_un_b0 :1 ; +u64 c1_up_bx :1 ; +u64 c1_up_wi :1 ; +u64 c1_up_b2 :1 ; +u64 c1_up_b1 :1 ; +u64 c1_up_b0 :1 ; +u64 c0_un_bx :1 ; +u64 c0_un_wi :1 ; +u64 c0_un_b2 :1 ; +u64 c0_un_b1 :1 ; +u64 c0_un_b0 :1 ; +u64 c0_up_bx :1 ; +u64 c0_up_wi :1 ; +u64 c0_up_b2 :1 ; +u64 c0_up_b1 :1 ; +u64 c0_up_b0 :1 ; +u64 c1_hpint :1 ; +u64 c1_pmei :1 ; +u64 c1_wake :1 ; +u64 crs1_dr :1 ; +u64 c1_se :1 ; +u64 crs1_er :1 ; +u64 c1_aeri :1 ; +u64 c0_hpint :1 ; +u64 c0_pmei :1 ; +u64 c0_wake :1 ; +u64 crs0_dr :1 ; +u64 c0_se :1 ; +u64 crs0_er :1 ; +u64 c0_aeri :1 ; +u64 ptime :1 ; +u64 pcnt :1 ; +u64 pidbof :1 ; +u64 psldbof :1 ; +u64 dtime1 :1 ; +u64 dtime0 :1 ; +u64 dcnt1 :1 ; +u64 dcnt0 :1 ; +u64 dma1fi :1 ; +u64 dma0fi :1 ; +u64 dma4dbo :1 ; +u64 dma3dbo :1 ; +u64 dma2dbo :1 ; +u64 dma1dbo :1 ; +u64 dma0dbo :1 ; +u64 iob2big :1 ; +u64 bar0_to :1 ; +u64 rml_wto :1 ; +u64 rml_rto :1 ; + } s; +struct cvmx_npei_int_enb2_s cn52xx; +struct cvmx_npei_int_enb2_cn52xxp1 { +u64 reserved_62_63 :2 ; +u64 int_a :1 ; +u64 c1_ldwn :1 ; +u64 c0_ldwn :1 ; +u64 c1_exc :1 ; +u64 c0_exc :1 ; +u64 c1_up_wf :1 ; +u64 c0_up_wf :1 ; +u64 c1_un_wf :1 ; +u64 c0_un_wf :1 ; +u64 c1_un_bx :1 ; +u64 c1_un_wi :1 ; +u64 c1_un_b2 :1 ; +u64 c1_un_b1 :1 ; +u64 c1_un_b0 :1 ; +u64 c1_up_bx :1 ; +u64 c1_up_wi :1 ; +u64 c1_up_b2 :1 ; +u64 c1_up_b1 :1 ; +u64 c1_up_b0 :1 ; +u64 c0_un_bx :1 ; +u64 c0_un_wi :1 ; +u64 c0_un_b2 :1 ; +u64 c0_un_b1 :1 ; +u64 c0_un_b0 :1 ; +u64 c0_up_bx :1 ; +u64 c0_up_wi :1 ; +u64 c0_up_b2 :1 ; +u64 c0_up_b1 :1 ; +u64 c0_up_b0 :1 ; +u64 c1_hpint :1 ; +u64 c1_pmei :1 ; +u64 c1_wake :1 ; +u64 crs1_dr :1 ; +u64 c1_se :1 ; +u64 crs1_er :1 ; +u64 c1_aeri :1 ; +u64 c0_hpint :1 ; +u64 c0_pmei :1 ; +u64 c0_wake :1 ; +u64 crs0_dr :1 ; +u64 c0_se :1 ; +u64 crs0_er :1 ; +u64 c0_aeri :1 ; +u64 ptime :1 ; +u64 pcnt :1 ; +u64 pidbof :1 ; +u64 psldbof :1 ; +u64 dtime1 :1 ; +u64 dtime0 :1 ; +u64 dcnt1 :1 ; +u64 dcnt0 :1 ; +u64 dma1fi :1 ; +u64 dma0fi :1 ; +u64 reserved_8_8 :1 ; +u64 dma3dbo :1 ; +u64 dma2dbo :1 ; +u64 dma1dbo :1 ; +u64 dma0dbo :1 ; +u64 iob2big :1 ; +u64 bar0_to :1 ; +u64 rml_wto :1 ; +u64 rml_rto :1 ; + } cn52xxp1; +struct cvmx_npei_int_enb2_s cn56xx; +struct cvmx_npei_int_enb2_cn56xxp1 { +u64 reserved_61_63 :3 ; +u64 c1_ldwn :1 ; +u64 c0_ldwn :1 ; +u64 c1_exc :1 ; +u64 c0_exc :1 ; +u64 c1_up_wf :1 ; +u64 c0_up_wf :1 ; +u64 c1_un_wf :1 ; +u64 c0_un_wf :1 ; +u64 c1_un_bx :1 ; +u64 c1_un_wi :1 ; +u64 c1_un_b2 :1 ; +u64 c1_un_b1 :1 ; +u64 c1_un_b0 :1 ; +u64 c1_up_bx :1 ; +u64 c1_up_wi :1 ; +u64 c1_up_b2 :1 ; +u64 c1_up_b1 :1 ; +u64 c1_up_b0 :1 ; +u64 c0_un_bx :1 ; +u64 c0_un_wi :1 ; +u64 c0_un_b2 :1 ; +u64 c0_un_b1 :1 ; +u64 c0_un_b0 :1 ; +u64 c0_up_bx :1 ; +u64 c0_up_wi :1 ; +u64 c0_up_b2 :1 ; +u64 c0_up_b1 :1 ; +u64 c0_up_b0 :1 ; +u64 c1_hpint :1 ; +u64 c1_pmei :1 ; +u64 c1_wake :1 ; +u64 reserved_29_29 :1 ; +u64 c1_se :1 ; +u64 reserved_27_27 :1 ; +u64 c1_aeri :1 ; +u64 c0_hpint :1 ; +u64 c0_pmei :1 ; +u64 c0_wake :1 ; +u64 reserved_22_22 :1 ; +u64 c0_se :1 ; +u64 reserved_20_20 :1 ; +u64 c0_aeri :1 ; +u64 ptime :1 ; +u64 pcnt :1 ; +u64 pidbof :1 ; +u64 psldbof :1 ; +u64 dtime1 :1 ; +u64 dtime0 :1 ; +u64 dcnt1 :1 ; +u64 dcnt0 :1 ; +u64 dma1fi :1 ; +u64 dma0fi :1 ; +u64 dma4dbo :1 ; +u64 dma3dbo :1 ; +u64 dma2dbo :1 ; +u64 dma1dbo :1 ; +u64 dma0dbo :1 ; +u64 iob2big :1 ; +u64 bar0_to :1 ; +u64 rml_wto :1 ; +u64 rml_rto :1 ; + } cn56xxp1; +}; + +typedef union cvmx_npei_int_enb2 cvmx_npei_int_enb2_t ; + +/** +* cvmx_npei_int_info +* +* NPEI_INT_INFO = NPI Interrupt Information +* +* Contains information about some of the interrupt condition that can occur +* in the NPEI_INTERRUPT_SUM register. +*/ +union cvmx_npei_int_info { +u64 u64; +struct cvmx_npei_int_info_s { +u64 reserved_12_63 :52 ; +u64 pidbof :6 ; +u64 psldbof :6 ; + } s; +struct cvmx_npei_int_info_s cn52xx; +struct cvmx_npei_int_info_s cn56xx; +struct cvmx_npei_int_info_s cn56xxp1; +}; + +typedef union cvmx_npei_int_info cvmx_npei_int_info_t ; + +/** +* cvmx_npei_int_sum +* +* NPEI_INTERRUPT_SUM = NPI Interrupt Summary Register +* +* Set when an interrupt condition occurs, write '1' to clear. +*/ +union cvmx_npei_int_sum { +u64 u64; +struct cvmx_npei_int_sum_s { +u64 mio_inta :1 ; +u64 reserved_62_62 :1 ; +u64 int_a :1 ; +u64 c1_ldwn :1 ; +u64 c0_ldwn :1 ; +u64 c1_exc :1 ; +u64 c0_exc :1 ; +u64 c1_up_wf :1 ; +u64 c0_up_wf :1 ; +u64 c1_un_wf :1 ; +u64 c0_un_wf :1 ; +u64 c1_un_bx :1 ; +u64 c1_un_wi :1 ; +u64 c1_un_b2 :1 ; +u64 c1_un_b1 :1 ; +u64 c1_un_b0 :1 ; +u64 c1_up_bx :1 ; +u64 c1_up_wi :1 ; +u64 c1_up_b2 :1 ; +u64 c1_up_b1 :1 ; +u64 c1_up_b0 :1 ; +u64 c0_un_bx :1 ; +u64 c0_un_wi :1 ; +u64 c0_un_b2 :1 ; +u64 c0_un_b1 :1 ; +u64 c0_un_b0 :1 ; +u64 c0_up_bx :1 ; +u64 c0_up_wi :1 ; +u64 c0_up_b2 :1 ; +u64 c0_up_b1 :1 ; +u64 c0_up_b0 :1 ; +u64 c1_hpint :1 ; +u64 c1_pmei :1 ; +u64 c1_wake :1 ; +u64 crs1_dr :1 ; +u64 c1_se :1 ; +u64 crs1_er :1 ; +u64 c1_aeri :1 ; +u64 c0_hpint :1 ; +u64 c0_pmei :1 ; +u64 c0_wake :1 ; +u64 crs0_dr :1 ; +u64 c0_se :1 ; +u64 crs0_er :1 ; +u64 c0_aeri :1 ; +u64 ptime :1 ; +u64 pcnt :1 ; +u64 pidbof :1 ; +u64 psldbof :1 ; +u64 dtime1 :1 ; +u64 dtime0 :1 ; +u64 dcnt1 :1 ; +u64 dcnt0 :1 ; +u64 dma1fi :1 ; +u64 dma0fi :1 ; +u64 dma4dbo :1 ; +u64 dma3dbo :1 ; +u64 dma2dbo :1 ; +u64 dma1dbo :1 ; +u64 dma0dbo :1 ; +u64 iob2big :1 ; +u64 bar0_to :1 ; +u64 rml_wto :1 ; +u64 rml_rto :1 ; + } s; +struct cvmx_npei_int_sum_s cn52xx; +struct cvmx_npei_int_sum_cn52xxp1 { +u64 mio_inta :1 ; +u64 reserved_62_62 :1 ; +u64 int_a :1 ; +u64 c1_ldwn :1 ; +u64 c0_ldwn :1 ; +u64 c1_exc :1 ; +u64 c0_exc :1 ; +u64 c1_up_wf :1 ; +u64 c0_up_wf :1 ; +u64 c1_un_wf :1 ; +u64 c0_un_wf :1 ; +u64 c1_un_bx :1 ; +u64 c1_un_wi :1 ; +u64 c1_un_b2 :1 ; +u64 c1_un_b1 :1 ; +u64 c1_un_b0 :1 ; +u64 c1_up_bx :1 ; +u64 c1_up_wi :1 ; +u64 c1_up_b2 :1 ; +u64 c1_up_b1 :1 ; +u64 c1_up_b0 :1 ; +u64 c0_un_bx :1 ; +u64 c0_un_wi :1 ; +u64 c0_un_b2 :1 ; +u64 c0_un_b1 :1 ; +u64 c0_un_b0 :1 ; +u64 c0_up_bx :1 ; +u64 c0_up_wi :1 ; +u64 c0_up_b2 :1 ; +u64 c0_up_b1 :1 ; +u64 c0_up_b0 :1 ; +u64 c1_hpint :1 ; +u64 c1_pmei :1 ; +u64 c1_wake :1 ; +u64 crs1_dr :1 ; +u64 c1_se :1 ; +u64 crs1_er :1 ; +u64 c1_aeri :1 ; +u64 c0_hpint :1 ; +u64 c0_pmei :1 ; +u64 c0_wake :1 ; +u64 crs0_dr :1 ; +u64 c0_se :1 ; +u64 crs0_er :1 ; +u64 c0_aeri :1 ; +u64 reserved_15_18 :4 ; +u64 dtime1 :1 ; +u64 dtime0 :1 ; +u64 dcnt1 :1 ; +u64 dcnt0 :1 ; +u64 dma1fi :1 ; +u64 dma0fi :1 ; +u64 reserved_8_8 :1 ; +u64 dma3dbo :1 ; +u64 dma2dbo :1 ; +u64 dma1dbo :1 ; +u64 dma0dbo :1 ; +u64 iob2big :1 ; +u64 bar0_to :1 ; +u64 rml_wto :1 ; +u64 rml_rto :1 ; + } cn52xxp1; +struct cvmx_npei_int_sum_s cn56xx; +struct cvmx_npei_int_sum_cn56xxp1 { +u64 mio_inta :1 ; +u64 reserved_61_62 :2 ; +u64 c1_ldwn :1 ; +u64 c0_ldwn :1 ; +u64 c1_exc :1 ; +u64 c0_exc :1 ; +u64 c1_up_wf :1 ; +u64 c0_up_wf :1 ; +u64 c1_un_wf :1 ; +u64 c0_un_wf :1 ; +u64 c1_un_bx :1 ; +u64 c1_un_wi :1 ; +u64 c1_un_b2 :1 ; +u64 c1_un_b1 :1 ; +u64 c1_un_b0 :1 ; +u64 c1_up_bx :1 ; +u64 c1_up_wi :1 ; +u64 c1_up_b2 :1 ; +u64 c1_up_b1 :1 ; +u64 c1_up_b0 :1 ; +u64 c0_un_bx :1 ; +u64 c0_un_wi :1 ; +u64 c0_un_b2 :1 ; +u64 c0_un_b1 :1 ; +u64 c0_un_b0 :1 ; +u64 c0_up_bx :1 ; +u64 c0_up_wi :1 ; +u64 c0_up_b2 :1 ; +u64 c0_up_b1 :1 ; +u64 c0_up_b0 :1 ; +u64 c1_hpint :1 ; +u64 c1_pmei :1 ; +u64 c1_wake :1 ; +u64 reserved_29_29 :1 ; +u64 c1_se :1 ; +u64 reserved_27_27 :1 ; +u64 c1_aeri :1 ; +u64 c0_hpint :1 ; +u64 c0_pmei :1 ; +u64 c0_wake :1 ; +u64 reserved_22_22 :1 ; +u64 c0_se :1 ; +u64 reserved_20_20 :1 ; +u64 c0_aeri :1 ; +u64 reserved_15_18 :4 ; +u64 dtime1 :1 ; +u64 dtime0 :1 ; +u64 dcnt1 :1 ; +u64 dcnt0 :1 ; +u64 dma1fi :1 ; +u64 dma0fi :1 ; +u64 dma4dbo :1 ; +u64 dma3dbo :1 ; +u64 dma2dbo :1 ; +u64 dma1dbo :1 ; +u64 dma0dbo :1 ; +u64 iob2big :1 ; +u64 bar0_to :1 ; +u64 rml_wto :1 ; +u64 rml_rto :1 ; + } cn56xxp1; +}; + +typedef union cvmx_npei_int_sum cvmx_npei_int_sum_t ; + +/** +* cvmx_npei_int_sum2 +* +* NPEI_INTERRUPT_SUM2 = NPI Interrupt Summary2 Register +* +* This is a read only copy of the NPEI_INTERRUPT_SUM register with bit +* variances. +*/ +union cvmx_npei_int_sum2 { +u64 u64; +struct cvmx_npei_int_sum2_s { +u64 mio_inta :1 ; +u64 reserved_62_62 :1 ; +u64 int_a :1 ; +u64 c1_ldwn :1 ; +u64 c0_ldwn :1 ; +u64 c1_exc :1 ; +u64 c0_exc :1 ; +u64 c1_up_wf :1 ; +u64 c0_up_wf :1 ; +u64 c1_un_wf :1 ; +u64 c0_un_wf :1 ; +u64 c1_un_bx :1 ; +u64 c1_un_wi :1 ; +u64 c1_un_b2 :1 ; +u64 c1_un_b1 :1 ; +u64 c1_un_b0 :1 ; +u64 c1_up_bx :1 ; +u64 c1_up_wi :1 ; +u64 c1_up_b2 :1 ; +u64 c1_up_b1 :1 ; +u64 c1_up_b0 :1 ; +u64 c0_un_bx :1 ; +u64 c0_un_wi :1 ; +u64 c0_un_b2 :1 ; +u64 c0_un_b1 :1 ; +u64 c0_un_b0 :1 ; +u64 c0_up_bx :1 ; +u64 c0_up_wi :1 ; +u64 c0_up_b2 :1 ; +u64 c0_up_b1 :1 ; +u64 c0_up_b0 :1 ; +u64 c1_hpint :1 ; +u64 c1_pmei :1 ; +u64 c1_wake :1 ; +u64 crs1_dr :1 ; +u64 c1_se :1 ; +u64 crs1_er :1 ; +u64 c1_aeri :1 ; +u64 c0_hpint :1 ; +u64 c0_pmei :1 ; +u64 c0_wake :1 ; +u64 crs0_dr :1 ; +u64 c0_se :1 ; +u64 crs0_er :1 ; +u64 c0_aeri :1 ; +u64 reserved_15_18 :4 ; +u64 dtime1 :1 ; +u64 dtime0 :1 ; +u64 dcnt1 :1 ; +u64 dcnt0 :1 ; +u64 dma1fi :1 ; +u64 dma0fi :1 ; +u64 reserved_8_8 :1 ; +u64 dma3dbo :1 ; +u64 dma2dbo :1 ; +u64 dma1dbo :1 ; +u64 dma0dbo :1 ; +u64 iob2big :1 ; +u64 bar0_to :1 ; +u64 rml_wto :1 ; +u64 rml_rto :1 ; + } s; +struct cvmx_npei_int_sum2_s cn52xx; +struct cvmx_npei_int_sum2_s cn52xxp1; +struct cvmx_npei_int_sum2_s cn56xx; +}; + +typedef union cvmx_npei_int_sum2 cvmx_npei_int_sum2_t ; + +/** +* cvmx_npei_last_win_rdata0 +* +* NPEI_LAST_WIN_RDATA0 = NPEI Last Window Read Data Port0 +* +* The data from the last initiated window read. +*/ +union cvmx_npei_last_win_rdata0 { +u64 u64; +struct cvmx_npei_last_win_rdata0_s { +u64 data :64 ; + } s; +struct cvmx_npei_last_win_rdata0_s cn52xx; +struct cvmx_npei_last_win_rdata0_s cn52xxp1; +struct cvmx_npei_last_win_rdata0_s cn56xx; +struct cvmx_npei_last_win_rdata0_s cn56xxp1; +}; + +typedef union cvmx_npei_last_win_rdata0 cvmx_npei_last_win_rdata0_t ; + +/** +* cvmx_npei_last_win_rdata1 +* +* NPEI_LAST_WIN_RDATA1 = NPEI Last Window Read Data Port1 +* +* The data from the last initiated window read. +*/ +union cvmx_npei_last_win_rdata1 { +u64 u64; +struct cvmx_npei_last_win_rdata1_s { +u64 data :64 ; + } s; +struct cvmx_npei_last_win_rdata1_s cn52xx; +struct cvmx_npei_last_win_rdata1_s cn52xxp1; +struct cvmx_npei_last_win_rdata1_s cn56xx; +struct cvmx_npei_last_win_rdata1_s cn56xxp1; +}; + +typedef union cvmx_npei_last_win_rdata1 cvmx_npei_last_win_rdata1_t ; + +/** +* cvmx_npei_mem_access_ctl +* +* NPEI_MEM_ACCESS_CTL = NPEI's Memory Access Control +* +* Contains control for access to the PCIe address space. +*/ +union cvmx_npei_mem_access_ctl { +u64 u64; +struct cvmx_npei_mem_access_ctl_s { +u64 reserved_14_63 :50 ; +u64 max_word :4 ; +u64 timer :10 ; + } s; +struct cvmx_npei_mem_access_ctl_s cn52xx; +struct cvmx_npei_mem_access_ctl_s cn52xxp1; +struct cvmx_npei_mem_access_ctl_s cn56xx; +struct cvmx_npei_mem_access_ctl_s cn56xxp1; +}; + +typedef union cvmx_npei_mem_access_ctl cvmx_npei_mem_access_ctl_t ; + +/** +* cvmx_npei_mem_access_subid# +* +* NPEI_MEM_ACCESS_SUBIDX = NPEI Memory Access SubidX Register +* +* Contains address index and control bits for access to memory from Core PPs. +*/ +union cvmx_npei_mem_access_subidx { +u64 u64; +struct cvmx_npei_mem_access_subidx_s { +u64 reserved_42_63 :22 ; +u64 zero :1 ; +u64 port :2 ; +u64 nmerge :1 ; +u64 esr :2 ; +u64 esw :2 ; +u64 nsr :1 ; +u64 nsw :1 ; +u64 ror :1 ; +u64 row :1 ; +u64 ba :30 ; + } s; +struct cvmx_npei_mem_access_subidx_s cn52xx; +struct cvmx_npei_mem_access_subidx_s cn52xxp1; +struct cvmx_npei_mem_access_subidx_s cn56xx; +struct cvmx_npei_mem_access_subidx_s cn56xxp1; +}; + +typedef union cvmx_npei_mem_access_subidx cvmx_npei_mem_access_subidx_t ; + +/** +* cvmx_npei_msi_enb0 +* +* NPEI_MSI_ENB0 = NPEI MSI Enable0 +* +* Used to enable the interrupt generation for the bits in the NPEI_MSI_RCV0. +*/ +union cvmx_npei_msi_enb0 { +u64 u64; +struct cvmx_npei_msi_enb0_s { +u64 enb :64 ; + } s; +struct cvmx_npei_msi_enb0_s cn52xx; +struct cvmx_npei_msi_enb0_s cn52xxp1; +struct cvmx_npei_msi_enb0_s cn56xx; +struct cvmx_npei_msi_enb0_s cn56xxp1; +}; + +typedef union cvmx_npei_msi_enb0 cvmx_npei_msi_enb0_t ; + +/** +* cvmx_npei_msi_enb1 +* +* NPEI_MSI_ENB1 = NPEI MSI Enable1 +* +* Used to enable the interrupt generation for the bits in the NPEI_MSI_RCV1. +*/ +union cvmx_npei_msi_enb1 { +u64 u64; +struct cvmx_npei_msi_enb1_s { +u64 enb :64 ; + } s; +struct cvmx_npei_msi_enb1_s cn52xx; +struct cvmx_npei_msi_enb1_s cn52xxp1; +struct cvmx_npei_msi_enb1_s cn56xx; +struct cvmx_npei_msi_enb1_s cn56xxp1; +}; + +typedef union cvmx_npei_msi_enb1 cvmx_npei_msi_enb1_t ; + +/** +* cvmx_npei_msi_enb2 +* +* NPEI_MSI_ENB2 = NPEI MSI Enable2 +* +* Used to enable the interrupt generation for the bits in the NPEI_MSI_RCV2. +*/ +union cvmx_npei_msi_enb2 { +u64 u64; +struct cvmx_npei_msi_enb2_s { +u64 enb :64 ; + } s; +struct cvmx_npei_msi_enb2_s cn52xx; +struct cvmx_npei_msi_enb2_s cn52xxp1; +struct cvmx_npei_msi_enb2_s cn56xx; +struct cvmx_npei_msi_enb2_s cn56xxp1; +}; + +typedef union cvmx_npei_msi_enb2 cvmx_npei_msi_enb2_t ; + +/** +* cvmx_npei_msi_enb3 +* +* NPEI_MSI_ENB3 = NPEI MSI Enable3 +* +* Used to enable the interrupt generation for the bits in the NPEI_MSI_RCV3. +*/ +union cvmx_npei_msi_enb3 { +u64 u64; +struct cvmx_npei_msi_enb3_s { +u64 enb :64 ; + } s; +struct cvmx_npei_msi_enb3_s cn52xx; +struct cvmx_npei_msi_enb3_s cn52xxp1; +struct cvmx_npei_msi_enb3_s cn56xx; +struct cvmx_npei_msi_enb3_s cn56xxp1; +}; + +typedef union cvmx_npei_msi_enb3 cvmx_npei_msi_enb3_t ; + +/** +* cvmx_npei_msi_rcv0 +* +* NPEI_MSI_RCV0 = NPEI MSI Receive0 +* +* Contains bits [63:0] of the 256 bits oof MSI interrupts. +*/ +union cvmx_npei_msi_rcv0 { +u64 u64; +struct cvmx_npei_msi_rcv0_s { +u64 intr :64 ; + } s; +struct cvmx_npei_msi_rcv0_s cn52xx; +struct cvmx_npei_msi_rcv0_s cn52xxp1; +struct cvmx_npei_msi_rcv0_s cn56xx; +struct cvmx_npei_msi_rcv0_s cn56xxp1; +}; + +typedef union cvmx_npei_msi_rcv0 cvmx_npei_msi_rcv0_t ; + +/** +* cvmx_npei_msi_rcv1 +* +* NPEI_MSI_RCV1 = NPEI MSI Receive1 +* +* Contains bits [127:64] of the 256 bits oof MSI interrupts. +*/ +union cvmx_npei_msi_rcv1 { +u64 u64; +struct cvmx_npei_msi_rcv1_s { +u64 intr :64 ; + } s; +struct cvmx_npei_msi_rcv1_s cn52xx; +struct cvmx_npei_msi_rcv1_s cn52xxp1; +struct cvmx_npei_msi_rcv1_s cn56xx; +struct cvmx_npei_msi_rcv1_s cn56xxp1; +}; + +typedef union cvmx_npei_msi_rcv1 cvmx_npei_msi_rcv1_t ; + +/** +* cvmx_npei_msi_rcv2 +* +* NPEI_MSI_RCV2 = NPEI MSI Receive2 +* +* Contains bits [191:128] of the 256 bits oof MSI interrupts. +*/ +union cvmx_npei_msi_rcv2 { +u64 u64; +struct cvmx_npei_msi_rcv2_s { +u64 intr :64 ; + } s; +struct cvmx_npei_msi_rcv2_s cn52xx; +struct cvmx_npei_msi_rcv2_s cn52xxp1; +struct cvmx_npei_msi_rcv2_s cn56xx; +struct cvmx_npei_msi_rcv2_s cn56xxp1; +}; + +typedef union cvmx_npei_msi_rcv2 cvmx_npei_msi_rcv2_t ; + +/** +* cvmx_npei_msi_rcv3 +* +* NPEI_MSI_RCV3 = NPEI MSI Receive3 +* +* Contains bits [255:192] of the 256 bits oof MSI interrupts. +*/ +union cvmx_npei_msi_rcv3 { +u64 u64; +struct cvmx_npei_msi_rcv3_s { +u64 intr :64 ; + } s; +struct cvmx_npei_msi_rcv3_s cn52xx; +struct cvmx_npei_msi_rcv3_s cn52xxp1; +struct cvmx_npei_msi_rcv3_s cn56xx; +struct cvmx_npei_msi_rcv3_s cn56xxp1; +}; + +typedef union cvmx_npei_msi_rcv3 cvmx_npei_msi_rcv3_t ; + +/** +* cvmx_npei_msi_rd_map +* +* NPEI_MSI_RD_MAP = NPEI MSI Read MAP +* +* Used to read the mapping function of the NPEI_PCIE_MSI_RCV to NPEI_MSI_RCV +* registers. +*/ +union cvmx_npei_msi_rd_map { +u64 u64; +struct cvmx_npei_msi_rd_map_s { +u64 reserved_16_63 :48 ; +u64 rd_int :8 ; +u64 msi_int :8 ; + } s; +struct cvmx_npei_msi_rd_map_s cn52xx; +struct cvmx_npei_msi_rd_map_s cn52xxp1; +struct cvmx_npei_msi_rd_map_s cn56xx; +struct cvmx_npei_msi_rd_map_s cn56xxp1; +}; + +typedef union cvmx_npei_msi_rd_map cvmx_npei_msi_rd_map_t ; + +/** +* cvmx_npei_msi_w1c_enb0 +* +* NPEI_MSI_W1C_ENB0 = NPEI MSI Write 1 To Clear Enable0 +* +* Used to clear bits in NPEI_MSI_ENB0. This is a PASS2 register. +*/ +union cvmx_npei_msi_w1c_enb0 { +u64 u64; +struct cvmx_npei_msi_w1c_enb0_s { +u64 clr :64 ; + } s; +struct cvmx_npei_msi_w1c_enb0_s cn52xx; +struct cvmx_npei_msi_w1c_enb0_s cn56xx; +}; + +typedef union cvmx_npei_msi_w1c_enb0 cvmx_npei_msi_w1c_enb0_t ; + +/** +* cvmx_npei_msi_w1c_enb1 +* +* NPEI_MSI_W1C_ENB1 = NPEI MSI Write 1 To Clear Enable1 +* +* Used to clear bits in NPEI_MSI_ENB1. This is a PASS2 register. +*/ +union cvmx_npei_msi_w1c_enb1 { +u64 u64; +struct cvmx_npei_msi_w1c_enb1_s { +u64 clr :64 ; + } s; +struct cvmx_npei_msi_w1c_enb1_s cn52xx; +struct cvmx_npei_msi_w1c_enb1_s cn56xx; +}; + +typedef union cvmx_npei_msi_w1c_enb1 cvmx_npei_msi_w1c_enb1_t ; + +/** +* cvmx_npei_msi_w1c_enb2 +* +* NPEI_MSI_W1C_ENB2 = NPEI MSI Write 1 To Clear Enable2 +* +* Used to clear bits in NPEI_MSI_ENB2. This is a PASS2 register. +*/ +union cvmx_npei_msi_w1c_enb2 { +u64 u64; +struct cvmx_npei_msi_w1c_enb2_s { +u64 clr :64 ; + } s; +struct cvmx_npei_msi_w1c_enb2_s cn52xx; +struct cvmx_npei_msi_w1c_enb2_s cn56xx; +}; + +typedef union cvmx_npei_msi_w1c_enb2 cvmx_npei_msi_w1c_enb2_t ; + +/** +* cvmx_npei_msi_w1c_enb3 +* +* NPEI_MSI_W1C_ENB3 = NPEI MSI Write 1 To Clear Enable3 +* +* Used to clear bits in NPEI_MSI_ENB3. This is a PASS2 register. +*/ +union cvmx_npei_msi_w1c_enb3 { +u64 u64; +struct cvmx_npei_msi_w1c_enb3_s { +u64 clr :64 ; + } s; +struct cvmx_npei_msi_w1c_enb3_s cn52xx; +struct cvmx_npei_msi_w1c_enb3_s cn56xx; +}; + +typedef union cvmx_npei_msi_w1c_enb3 cvmx_npei_msi_w1c_enb3_t ; + +/** +* cvmx_npei_msi_w1s_enb0 +* +* NPEI_MSI_W1S_ENB0 = NPEI MSI Write 1 To Set Enable0 +* +* Used to set bits in NPEI_MSI_ENB0. This is a PASS2 register. +*/ +union cvmx_npei_msi_w1s_enb0 { +u64 u64; +struct cvmx_npei_msi_w1s_enb0_s { +u64 set :64 ; + } s; +struct cvmx_npei_msi_w1s_enb0_s cn52xx; +struct cvmx_npei_msi_w1s_enb0_s cn56xx; +}; + +typedef union cvmx_npei_msi_w1s_enb0 cvmx_npei_msi_w1s_enb0_t ; + +/** +* cvmx_npei_msi_w1s_enb1 +* +* NPEI_MSI_W1S_ENB0 = NPEI MSI Write 1 To Set Enable1 +* +* Used to set bits in NPEI_MSI_ENB1. This is a PASS2 register. +*/ +union cvmx_npei_msi_w1s_enb1 { +u64 u64; +struct cvmx_npei_msi_w1s_enb1_s { +u64 set :64 ; + } s; +struct cvmx_npei_msi_w1s_enb1_s cn52xx; +struct cvmx_npei_msi_w1s_enb1_s cn56xx; +}; + +typedef union cvmx_npei_msi_w1s_enb1 cvmx_npei_msi_w1s_enb1_t ; + +/** +* cvmx_npei_msi_w1s_enb2 +* +* NPEI_MSI_W1S_ENB2 = NPEI MSI Write 1 To Set Enable2 +* +* Used to set bits in NPEI_MSI_ENB2. This is a PASS2 register. +*/ +union cvmx_npei_msi_w1s_enb2 { +u64 u64; +struct cvmx_npei_msi_w1s_enb2_s { +u64 set :64 ; + } s; +struct cvmx_npei_msi_w1s_enb2_s cn52xx; +struct cvmx_npei_msi_w1s_enb2_s cn56xx; +}; + +typedef union cvmx_npei_msi_w1s_enb2 cvmx_npei_msi_w1s_enb2_t ; + +/** +* cvmx_npei_msi_w1s_enb3 +* +* NPEI_MSI_W1S_ENB3 = NPEI MSI Write 1 To Set Enable3 +* +* Used to set bits in NPEI_MSI_ENB3. This is a PASS2 register. +*/ +union cvmx_npei_msi_w1s_enb3 { +u64 u64; +struct cvmx_npei_msi_w1s_enb3_s { +u64 set :64 ; + } s; +struct cvmx_npei_msi_w1s_enb3_s cn52xx; +struct cvmx_npei_msi_w1s_enb3_s cn56xx; +}; + +typedef union cvmx_npei_msi_w1s_enb3 cvmx_npei_msi_w1s_enb3_t ; + +/** +* cvmx_npei_msi_wr_map +* +* NPEI_MSI_WR_MAP = NPEI MSI Write MAP +* +* Used to write the mapping function of the NPEI_PCIE_MSI_RCV to NPEI_MSI_RCV +* registers. +*/ +union cvmx_npei_msi_wr_map { +u64 u64; +struct cvmx_npei_msi_wr_map_s { +u64 reserved_16_63 :48 ; +u64 ciu_int :8 ; +u64 msi_int :8 ; + } s; +struct cvmx_npei_msi_wr_map_s cn52xx; +struct cvmx_npei_msi_wr_map_s cn52xxp1; +struct cvmx_npei_msi_wr_map_s cn56xx; +struct cvmx_npei_msi_wr_map_s cn56xxp1; +}; + +typedef union cvmx_npei_msi_wr_map cvmx_npei_msi_wr_map_t ; + +/** +* cvmx_npei_pcie_credit_cnt +* +* NPEI_PCIE_CREDIT_CNT = NPEI PCIE Credit Count +* +* Contains the number of credits for the pcie port FIFOs used by the NPEI. +* This value needs to be set BEFORE PCIe traffic +* flow from NPEI to PCIE Ports starts. A write to this register will cause +* the credit counts in the NPEI for the two +* PCIE ports to be reset to the value in this register. +*/ +union cvmx_npei_pcie_credit_cnt { +u64 u64; +struct cvmx_npei_pcie_credit_cnt_s { +u64 reserved_48_63 :16 ; +u64 p1_ccnt :8 ; +u64 p1_ncnt :8 ; +u64 p1_pcnt :8 ; +u64 p0_ccnt :8 ; +u64 p0_ncnt :8 ; +u64 p0_pcnt :8 ; + } s; +struct cvmx_npei_pcie_credit_cnt_s cn52xx; +struct cvmx_npei_pcie_credit_cnt_s cn56xx; +}; + +typedef union cvmx_npei_pcie_credit_cnt cvmx_npei_pcie_credit_cnt_t ; + +/** +* cvmx_npei_pcie_msi_rcv +* +* NPEI_PCIE_MSI_RCV = NPEI PCIe MSI Receive +* +* Register where MSI writes are directed from the PCIe. +*/ +union cvmx_npei_pcie_msi_rcv { +u64 u64; +struct cvmx_npei_pcie_msi_rcv_s { +u64 reserved_8_63 :56 ; +u64 intr :8 ; + } s; +struct cvmx_npei_pcie_msi_rcv_s cn52xx; +struct cvmx_npei_pcie_msi_rcv_s cn52xxp1; +struct cvmx_npei_pcie_msi_rcv_s cn56xx; +struct cvmx_npei_pcie_msi_rcv_s cn56xxp1; +}; + +typedef union cvmx_npei_pcie_msi_rcv cvmx_npei_pcie_msi_rcv_t ; + +/** +* cvmx_npei_pcie_msi_rcv_b1 +* +* NPEI_PCIE_MSI_RCV_B1 = NPEI PCIe MSI Receive Byte 1 +* +* Register where MSI writes are directed from the PCIe. +*/ +union cvmx_npei_pcie_msi_rcv_b1 { +u64 u64; +struct cvmx_npei_pcie_msi_rcv_b1_s { +u64 reserved_16_63 :48 ; +u64 intr :8 ; +u64 reserved_0_7 :8 ; + } s; +struct cvmx_npei_pcie_msi_rcv_b1_s cn52xx; +struct cvmx_npei_pcie_msi_rcv_b1_s cn52xxp1; +struct cvmx_npei_pcie_msi_rcv_b1_s cn56xx; +struct cvmx_npei_pcie_msi_rcv_b1_s cn56xxp1; +}; + +typedef union cvmx_npei_pcie_msi_rcv_b1 cvmx_npei_pcie_msi_rcv_b1_t ; + +/** +* cvmx_npei_pcie_msi_rcv_b2 +* +* NPEI_PCIE_MSI_RCV_B2 = NPEI PCIe MSI Receive Byte 2 +* +* Register where MSI writes are directed from the PCIe. +*/ +union cvmx_npei_pcie_msi_rcv_b2 { +u64 u64; +struct cvmx_npei_pcie_msi_rcv_b2_s { +u64 reserved_24_63 :40 ; +u64 intr :8 ; +u64 reserved_0_15 :16 ; + } s; +struct cvmx_npei_pcie_msi_rcv_b2_s cn52xx; +struct cvmx_npei_pcie_msi_rcv_b2_s cn52xxp1; +struct cvmx_npei_pcie_msi_rcv_b2_s cn56xx; +struct cvmx_npei_pcie_msi_rcv_b2_s cn56xxp1; +}; + +typedef union cvmx_npei_pcie_msi_rcv_b2 cvmx_npei_pcie_msi_rcv_b2_t ; + +/** +* cvmx_npei_pcie_msi_rcv_b3 +* +* NPEI_PCIE_MSI_RCV_B3 = NPEI PCIe MSI Receive Byte 3 +* +* Register where MSI writes are directed from the PCIe. +*/ +union cvmx_npei_pcie_msi_rcv_b3 { +u64 u64; +struct cvmx_npei_pcie_msi_rcv_b3_s { +u64 reserved_32_63 :32 ; +u64 intr :8 ; +u64 reserved_0_23 :24 ; + } s; +struct cvmx_npei_pcie_msi_rcv_b3_s cn52xx; +struct cvmx_npei_pcie_msi_rcv_b3_s cn52xxp1; +struct cvmx_npei_pcie_msi_rcv_b3_s cn56xx; +struct cvmx_npei_pcie_msi_rcv_b3_s cn56xxp1; +}; + +typedef union cvmx_npei_pcie_msi_rcv_b3 cvmx_npei_pcie_msi_rcv_b3_t ; + +/** +* cvmx_npei_pkt#_cnts +* +* NPEI_PKT[0..31]_CNTS = NPEI Packet ring# Counts +* +* The counters for output rings. +*/ +union cvmx_npei_pktx_cnts { +u64 u64; +struct cvmx_npei_pktx_cnts_s { +u64 reserved_54_63 :10 ; +u64 timer :22 ; +u64 cnt :32 ; + } s; +struct cvmx_npei_pktx_cnts_s cn52xx; +struct cvmx_npei_pktx_cnts_s cn56xx; +}; + +typedef union cvmx_npei_pktx_cnts cvmx_npei_pktx_cnts_t ; + +/** +* cvmx_npei_pkt#_in_bp +* +* NPEI_PKT[0..31]_IN_BP = NPEI Packet ring# Input Backpressure +* +* The counters and thresholds for input packets to apply backpressure to +* processing of the packets. +*/ +union cvmx_npei_pktx_in_bp { +u64 u64; +struct cvmx_npei_pktx_in_bp_s { +u64 wmark :32 ; +u64 cnt :32 ; + } s; +struct cvmx_npei_pktx_in_bp_s cn52xx; +struct cvmx_npei_pktx_in_bp_s cn56xx; +}; + +typedef union cvmx_npei_pktx_in_bp cvmx_npei_pktx_in_bp_t ; + +/** +* cvmx_npei_pkt#_instr_baddr +* +* NPEI_PKT[0..31]_INSTR_BADDR = NPEI Packet ring# Instruction Base Address +* +* Start of Instruction for input packets. +*/ +union cvmx_npei_pktx_instr_baddr { +u64 u64; +struct cvmx_npei_pktx_instr_baddr_s { +u64 addr :61 ; +u64 reserved_0_2 :3 ; + } s; +struct cvmx_npei_pktx_instr_baddr_s cn52xx; +struct cvmx_npei_pktx_instr_baddr_s cn56xx; +}; + +typedef union cvmx_npei_pktx_instr_baddr cvmx_npei_pktx_instr_baddr_t ; + +/** +* cvmx_npei_pkt#_instr_baoff_dbell +* +* NPEI_PKT[0..31]_INSTR_BAOFF_DBELL = NPEI Packet ring# Instruction Base +* Address Offset and Doorbell +* +* The doorbell and base address offset for next read. +*/ +union cvmx_npei_pktx_instr_baoff_dbell { +u64 u64; +struct cvmx_npei_pktx_instr_baoff_dbell_s { +u64 aoff :32 ; +u64 dbell :32 ; + } s; +struct cvmx_npei_pktx_instr_baoff_dbell_s cn52xx; +struct cvmx_npei_pktx_instr_baoff_dbell_s cn56xx; +}; + +typedef union cvmx_npei_pktx_instr_baoff_dbell +cvmx_npei_pktx_instr_baoff_dbell_t ; + +/** +* cvmx_npei_pkt#_instr_fifo_rsize +* +* NPEI_PKT[0..31]_INSTR_FIFO_RSIZE = NPEI Packet ring# Instruction FIFO and +* Ring Size. +* +* Fifo field and ring size for Instructions. +*/ +union cvmx_npei_pktx_instr_fifo_rsize { +u64 u64; +struct cvmx_npei_pktx_instr_fifo_rsize_s { +u64 max :9 ; +u64 rrp :9 ; +u64 wrp :9 ; +u64 fcnt :5 ; +u64 rsize :32 ; + } s; +struct cvmx_npei_pktx_instr_fifo_rsize_s cn52xx; +struct cvmx_npei_pktx_instr_fifo_rsize_s cn56xx; +}; + +typedef union cvmx_npei_pktx_instr_fifo_rsize cvmx_npei_pktx_instr_fifo_rsize_t ; + +/** +* cvmx_npei_pkt#_instr_header +* +* NPEI_PKT[0..31]_INSTR_HEADER = NPEI Packet ring# Instruction Header. +* +* VAlues used to build input packet header. +*/ +union cvmx_npei_pktx_instr_header { +u64 u64; +struct cvmx_npei_pktx_instr_header_s { +u64 reserved_44_63 :20 ; +u64 pbp :1 ; +u64 reserved_38_42 :5 ; +u64 rparmode :2 ; +u64 reserved_35_35 :1 ; +u64 rskp_len :7 ; +u64 reserved_22_27 :6 ; +u64 use_ihdr :1 ; +u64 reserved_16_20 :5 ; +u64 par_mode :2 ; +u64 reserved_13_13 :1 ; +u64 skp_len :7 ; +u64 reserved_0_5 :6 ; + } s; +struct cvmx_npei_pktx_instr_header_s cn52xx; +struct cvmx_npei_pktx_instr_header_s cn56xx; +}; + +typedef union cvmx_npei_pktx_instr_header cvmx_npei_pktx_instr_header_t ; + +/** +* cvmx_npei_pkt#_slist_baddr +* +* NPEI_PKT[0..31]_SLIST_BADDR = NPEI Packet ring# Scatter List Base Address +* +* Start of Scatter List for output packet pointers - MUST be 16 byte aligned +*/ +union cvmx_npei_pktx_slist_baddr { +u64 u64; +struct cvmx_npei_pktx_slist_baddr_s { +u64 addr :60 ; +u64 reserved_0_3 :4 ; + } s; +struct cvmx_npei_pktx_slist_baddr_s cn52xx; +struct cvmx_npei_pktx_slist_baddr_s cn56xx; +}; + +typedef union cvmx_npei_pktx_slist_baddr cvmx_npei_pktx_slist_baddr_t ; + +/** +* cvmx_npei_pkt#_slist_baoff_dbell +* +* NPEI_PKT[0..31]_SLIST_BAOFF_DBELL = NPEI Packet ring# Scatter List Base +* Address Offset and Doorbell +* +* The doorbell and base address offset for next read. +*/ +union cvmx_npei_pktx_slist_baoff_dbell { +u64 u64; +struct cvmx_npei_pktx_slist_baoff_dbell_s { +u64 aoff :32 ; +u64 dbell :32 ; + } s; +struct cvmx_npei_pktx_slist_baoff_dbell_s cn52xx; +struct cvmx_npei_pktx_slist_baoff_dbell_s cn56xx; +}; + +typedef union cvmx_npei_pktx_slist_baoff_dbell +cvmx_npei_pktx_slist_baoff_dbell_t ; + +/** +* cvmx_npei_pkt#_slist_fifo_rsize +* +* NPEI_PKT[0..31]_SLIST_FIFO_RSIZE = NPEI Packet ring# Scatter List FIFO and +* Ring Size. +* +* The number of scatter pointer pairs in the scatter list. +*/ +union cvmx_npei_pktx_slist_fifo_rsize { +u64 u64; +struct cvmx_npei_pktx_slist_fifo_rsize_s { +u64 reserved_32_63 :32 ; +u64 rsize :32 ; + } s; +struct cvmx_npei_pktx_slist_fifo_rsize_s cn52xx; +struct cvmx_npei_pktx_slist_fifo_rsize_s cn56xx; +}; + +typedef union cvmx_npei_pktx_slist_fifo_rsize cvmx_npei_pktx_slist_fifo_rsize_t ; + +/** +* cvmx_npei_pkt_cnt_int +* +* NPEI_PKT_CNT_INT = NPI Packet Counter Interrupt +* +* The packets rings that are interrupting because of Packet Counters. +*/ +union cvmx_npei_pkt_cnt_int { +u64 u64; +struct cvmx_npei_pkt_cnt_int_s { +u64 reserved_32_63 :32 ; +u64 port :32 ; + } s; +struct cvmx_npei_pkt_cnt_int_s cn52xx; +struct cvmx_npei_pkt_cnt_int_s cn56xx; +}; + +typedef union cvmx_npei_pkt_cnt_int cvmx_npei_pkt_cnt_int_t ; + +/** +* cvmx_npei_pkt_cnt_int_enb +* +* NPEI_PKT_CNT_INT_ENB = NPI Packet Counter Interrupt Enable +* +* Enable for the packets rings that are interrupting because of Packet Counters. +*/ +union cvmx_npei_pkt_cnt_int_enb { +u64 u64; +struct cvmx_npei_pkt_cnt_int_enb_s { +u64 reserved_32_63 :32 ; +u64 port :32 ; + } s; +struct cvmx_npei_pkt_cnt_int_enb_s cn52xx; +struct cvmx_npei_pkt_cnt_int_enb_s cn56xx; +}; + +typedef union cvmx_npei_pkt_cnt_int_enb cvmx_npei_pkt_cnt_int_enb_t ; + +/** +* cvmx_npei_pkt_data_out_es +* +* NPEI_PKT_DATA_OUT_ES = NPEI's Packet Data Out Endian Swap +* +* The Endian Swap for writing Data Out. +*/ +union cvmx_npei_pkt_data_out_es { +u64 u64; +struct cvmx_npei_pkt_data_out_es_s { +u64 es :64 ; + } s; +struct cvmx_npei_pkt_data_out_es_s cn52xx; +struct cvmx_npei_pkt_data_out_es_s cn56xx; +}; + +typedef union cvmx_npei_pkt_data_out_es cvmx_npei_pkt_data_out_es_t ; + +/** +* cvmx_npei_pkt_data_out_ns +* +* NPEI_PKT_DATA_OUT_NS = NPEI's Packet Data Out No Snoop +* +* The NS field for the TLP when writing packet data. +*/ +union cvmx_npei_pkt_data_out_ns { +u64 u64; +struct cvmx_npei_pkt_data_out_ns_s { +u64 reserved_32_63 :32 ; +u64 nsr :32 ; + } s; +struct cvmx_npei_pkt_data_out_ns_s cn52xx; +struct cvmx_npei_pkt_data_out_ns_s cn56xx; +}; + +typedef union cvmx_npei_pkt_data_out_ns cvmx_npei_pkt_data_out_ns_t ; + +/** +* cvmx_npei_pkt_data_out_ror +* +* NPEI_PKT_DATA_OUT_ROR = NPEI's Packet Data Out Relaxed Ordering +* +* The ROR field for the TLP when writing Packet Data. +*/ +union cvmx_npei_pkt_data_out_ror { +u64 u64; +struct cvmx_npei_pkt_data_out_ror_s { +u64 reserved_32_63 :32 ; +u64 ror :32 ; + } s; +struct cvmx_npei_pkt_data_out_ror_s cn52xx; +struct cvmx_npei_pkt_data_out_ror_s cn56xx; +}; + +typedef union cvmx_npei_pkt_data_out_ror cvmx_npei_pkt_data_out_ror_t ; + +/** +* cvmx_npei_pkt_dpaddr +* +* NPEI_PKT_DPADDR = NPEI's Packet Data Pointer Addr +* +* Used to detemine address and attributes for packet data writes. +*/ +union cvmx_npei_pkt_dpaddr { +u64 u64; +struct cvmx_npei_pkt_dpaddr_s { +u64 reserved_32_63 :32 ; +u64 dptr :32 ; + } s; +struct cvmx_npei_pkt_dpaddr_s cn52xx; +struct cvmx_npei_pkt_dpaddr_s cn56xx; +}; + +typedef union cvmx_npei_pkt_dpaddr cvmx_npei_pkt_dpaddr_t ; + +/** +* cvmx_npei_pkt_in_bp +* +* NPEI_PKT_IN_BP = NPEI Packet Input Backpressure +* +* Which input rings have backpressure applied. +*/ +union cvmx_npei_pkt_in_bp { +u64 u64; +struct cvmx_npei_pkt_in_bp_s { +u64 reserved_32_63 :32 ; +u64 bp :32 ; + } s; +struct cvmx_npei_pkt_in_bp_s cn52xx; +struct cvmx_npei_pkt_in_bp_s cn56xx; +}; + +typedef union cvmx_npei_pkt_in_bp cvmx_npei_pkt_in_bp_t ; + +/** +* cvmx_npei_pkt_in_done#_cnts +* +* NPEI_PKT_IN_DONE[0..31]_CNTS = NPEI Instruction Done ring# Counts +* +* Counters for instructions completed on Input rings. +*/ +union cvmx_npei_pkt_in_donex_cnts { +u64 u64; +struct cvmx_npei_pkt_in_donex_cnts_s { +u64 reserved_32_63 :32 ; +u64 cnt :32 ; + } s; +struct cvmx_npei_pkt_in_donex_cnts_s cn52xx; +struct cvmx_npei_pkt_in_donex_cnts_s cn56xx; +}; + +typedef union cvmx_npei_pkt_in_donex_cnts cvmx_npei_pkt_in_donex_cnts_t ; + +/** +* cvmx_npei_pkt_in_instr_counts +* +* NPEI_PKT_IN_INSTR_COUNTS = NPEI Packet Input Instrutction Counts +* +* Keeps track of the number of instructions read into the FIFO and Packets +* sent to IPD. +*/ +union cvmx_npei_pkt_in_instr_counts { +u64 u64; +struct cvmx_npei_pkt_in_instr_counts_s { +u64 wr_cnt :32 ; +u64 rd_cnt :32 ; + } s; +struct cvmx_npei_pkt_in_instr_counts_s cn52xx; +struct cvmx_npei_pkt_in_instr_counts_s cn56xx; +}; + +typedef union cvmx_npei_pkt_in_instr_counts cvmx_npei_pkt_in_instr_counts_t ; + +/** +* cvmx_npei_pkt_in_pcie_port +* +* NPEI_PKT_IN_PCIE_PORT = NPEI's Packet In To PCIe Port Assignment +* +* Assigns Packet Input rings to PCIe ports. +*/ +union cvmx_npei_pkt_in_pcie_port { +u64 u64; +struct cvmx_npei_pkt_in_pcie_port_s { +u64 pp :64 ; + } s; +struct cvmx_npei_pkt_in_pcie_port_s cn52xx; +struct cvmx_npei_pkt_in_pcie_port_s cn56xx; +}; + +typedef union cvmx_npei_pkt_in_pcie_port cvmx_npei_pkt_in_pcie_port_t ; + +/** +* cvmx_npei_pkt_input_control +* +* NPEI_PKT_INPUT_CONTROL = NPEI's Packet Input Control +* +* Control for reads for gather list and instructions. +*/ +union cvmx_npei_pkt_input_control { +u64 u64; +struct cvmx_npei_pkt_input_control_s { +u64 reserved_23_63 :41 ; +u64 pkt_rr :1 ; +u64 pbp_dhi :13 ; +u64 d_nsr :1 ; +u64 d_esr :2 ; +u64 d_ror :1 ; +u64 use_csr :1 ; +u64 nsr :1 ; +u64 esr :2 ; +u64 ror :1 ; + } s; +struct cvmx_npei_pkt_input_control_s cn52xx; +struct cvmx_npei_pkt_input_control_s cn56xx; +}; + +typedef union cvmx_npei_pkt_input_control cvmx_npei_pkt_input_control_t ; + +/** +* cvmx_npei_pkt_instr_enb +* +* NPEI_PKT_INSTR_ENB = NPEI's Packet Instruction Enable +* +* Enables the instruction fetch for a Packet-ring. +*/ +union cvmx_npei_pkt_instr_enb { +u64 u64; +struct cvmx_npei_pkt_instr_enb_s { +u64 reserved_32_63 :32 ; +u64 enb :32 ; + } s; +struct cvmx_npei_pkt_instr_enb_s cn52xx; +struct cvmx_npei_pkt_instr_enb_s cn56xx; +}; + +typedef union cvmx_npei_pkt_instr_enb cvmx_npei_pkt_instr_enb_t ; + +/** +* cvmx_npei_pkt_instr_rd_size +* +* NPEI_PKT_INSTR_RD_SIZE = NPEI Instruction Read Size +* +* The number of instruction allowed to be read at one time. +*/ +union cvmx_npei_pkt_instr_rd_size { +u64 u64; +struct cvmx_npei_pkt_instr_rd_size_s { +u64 rdsize :64 ; + } s; +struct cvmx_npei_pkt_instr_rd_size_s cn52xx; +struct cvmx_npei_pkt_instr_rd_size_s cn56xx; +}; + +typedef union cvmx_npei_pkt_instr_rd_size cvmx_npei_pkt_instr_rd_size_t ; + +/** +* cvmx_npei_pkt_instr_size +* +* NPEI_PKT_INSTR_SIZE = NPEI's Packet Instruction Size +* +* Determines if instructions are 64 or 32 byte in size for a Packet-ring. +*/ +union cvmx_npei_pkt_instr_size { +u64 u64; +struct cvmx_npei_pkt_instr_size_s { +u64 reserved_32_63 :32 ; +u64 is_64b :32 ; + } s; +struct cvmx_npei_pkt_instr_size_s cn52xx; +struct cvmx_npei_pkt_instr_size_s cn56xx; +};
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.35.1
Part of the diff is not shown here. View the raw message.
PATCH 15/52 mips: octeon: Add cvmx-helper-loop.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-helper-loop.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-helper-loop.c | 178 +++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-helper-loop.c
arch/mips/mach-octeon/cvmx-helper-loop.c new file +178 -0
@@ -0,0 +1,178 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Functions for LOOP initialization, configuration, +* and monitoring. +*/ + +#include <log.h> +#include <malloc.h> +#include <net.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/octeon_fdt.h> +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> +#include <mach/cvmx-helper-fdt.h> +#include <mach/cvmx-helper-gpio.h> + +#include <mach/cvmx-agl-defs.h> +#include <mach/cvmx-bgxx-defs.h> +#include <mach/cvmx-ciu-defs.h> +#include <mach/cvmx-gmxx-defs.h> +#include <mach/cvmx-gserx-defs.h> +#include <mach/cvmx-ilk-defs.h> +#include <mach/cvmx-ipd-defs.h> +#include <mach/cvmx-lbk-defs.h> +#include <mach/cvmx-pcsx-defs.h> +#include <mach/cvmx-pcsxx-defs.h> +#include <mach/cvmx-pki-defs.h> +#include <mach/cvmx-pko-defs.h> +#include <mach/cvmx-xcv-defs.h> + +#include <mach/cvmx-hwpko.h> +#include <mach/cvmx-ilk.h> +#include <mach/cvmx-pki.h> + +int __cvmx_helper_loop_enumerate (int xiface) +{ +return OCTEON_IS_MODEL (OCTEON_CN68XX ) ? +8 : (OCTEON_IS_MODEL (OCTEON_CNF71XX ) ?2 :4 ); +} + +/** +* @INTERNAL +* Probe a LOOP interface and determine the number of ports +* connected to it. The LOOP interface should still be down +* after this call. +* +* @param xiface Interface to probe +* +* @return Number of ports on the interface. Zero to disable. +*/ +int __cvmx_helper_loop_probe (int xiface) +{ +return __cvmx_helper_loop_enumerate (xiface); +} + +/** +* @INTERNAL +* Bringup and enable a LOOP interface. After this call packet +* I/O should be fully functional. This is called with IPD +* enabled but PKO disabled. +* +* @param interface to bring up +* +* @return Zero on success, negative on failure +*/ +int __cvmx_helper_loop_enable (int xiface) +{ +cvmx_pip_prt_cfgx_t port_cfg; +int num_ports, index; +unsigned long offset; +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); + + num_ports =__cvmx_helper_get_num_ipd_ports (xiface); +/* +* We need to disable length checking so packet < 64 bytes and jumbo +* frames don't get errors +*/ +for (index =0 ; index < num_ports; index++) { + offset = ((octeon_has_feature (OCTEON_FEATURE_PKND )) ? +cvmx_helper_get_pknd (xiface, index) : +cvmx_helper_get_ipd_port (xiface, index)); + +if (octeon_has_feature (OCTEON_FEATURE_PKI )) { +cvmx_pki_endis_l2_errs (xi.node, offset,1 ,0 ,0 ); +cvmx_pki_endis_fcs_check (xi.node, offset,0 ,0 ); + }else { + port_cfg.u64 =csr_rd (CVMX_PIP_PRT_CFGX (offset)); + port_cfg.s.maxerr_en =0 ; + port_cfg.s.minerr_en =0 ; +csr_wr (CVMX_PIP_PRT_CFGX (offset), port_cfg.u64); + } + } + +/* +* Disable FCS stripping for loopback ports +*/ +if (!octeon_has_feature (OCTEON_FEATURE_PKND )) { +cvmx_ipd_sub_port_fcs_t ipd_sub_port_fcs; + + ipd_sub_port_fcs.u64 =csr_rd (CVMX_IPD_SUB_PORT_FCS ); + ipd_sub_port_fcs.s.port_bit2 =0 ; +csr_wr (CVMX_IPD_SUB_PORT_FCS , ipd_sub_port_fcs.u64); + } +/* +* Set PKND and BPID for loopback ports. +*/ +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) { +cvmx_pko_reg_loopback_pkind_t lp_pknd; +cvmx_pko_reg_loopback_bpid_t lp_bpid; + +for (index =0 ; index < num_ports; index++) { +int pknd =cvmx_helper_get_pknd (xiface, index); +int bpid =cvmx_helper_get_bpid (xiface, index); + + lp_pknd.u64 =csr_rd (CVMX_PKO_REG_LOOPBACK_PKIND ); + lp_bpid.u64 =csr_rd (CVMX_PKO_REG_LOOPBACK_BPID ); + +if (index ==0 ) + lp_pknd.s.num_ports = num_ports; + +switch (index) { +case 0 : + lp_pknd.s.pkind0 = pknd; + lp_bpid.s.bpid0 = bpid; +break ; +case 1 : + lp_pknd.s.pkind1 = pknd; + lp_bpid.s.bpid1 = bpid; +break ; +case 2 : + lp_pknd.s.pkind2 = pknd; + lp_bpid.s.bpid2 = bpid; +break ; +case 3 : + lp_pknd.s.pkind3 = pknd; + lp_bpid.s.bpid3 = bpid; +break ; +case 4 : + lp_pknd.s.pkind4 = pknd; + lp_bpid.s.bpid4 = bpid; +break ; +case 5 : + lp_pknd.s.pkind5 = pknd; + lp_bpid.s.bpid5 = bpid; +break ; +case 6 : + lp_pknd.s.pkind6 = pknd; + lp_bpid.s.bpid6 = bpid; +break ; +case 7 : + lp_pknd.s.pkind7 = pknd; + lp_bpid.s.bpid7 = bpid; +break ; + } +csr_wr (CVMX_PKO_REG_LOOPBACK_PKIND , lp_pknd.u64); +csr_wr (CVMX_PKO_REG_LOOPBACK_BPID , lp_bpid.u64); + } + }else if (octeon_has_feature (OCTEON_FEATURE_BGX )) { +cvmx_lbk_chx_pkind_t lbk_pkind; + +for (index =0 ; index < num_ports; index++) { + lbk_pkind.u64 =0 ; + lbk_pkind.s.pkind =cvmx_helper_get_pknd (xiface, index); +csr_wr_node (xi.node,CVMX_LBK_CHX_PKIND (index), + lbk_pkind.u64); + } + } + +return 0 ; +}
Signature · 1 line
2.35.1
PATCH 24/52 mips: octeon: Add cvmx-agl.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-agl.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-agl.c | 216 +++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-agl.c
arch/mips/mach-octeon/cvmx-agl.c new file +216 -0
@@ -0,0 +1,216 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Functions for RGMII (MGMT) initialization, configuration, +* and monitoring. +*/ + +#include <log.h> +#include <time.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/cvmx-fuse.h> +#include <mach/octeon-feature.h> +#include <mach/cvmx-qlm.h> +#include <mach/octeon_qlm.h> +#include <mach/cvmx-pcie.h> +#include <mach/cvmx-coremask.h> + +#include <mach/cvmx-pki.h> +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> + +#include <mach/cvmx-agl.h> +#include <mach/cvmx-agl-defs.h> + +/* +* @param port to enable +* +* @return Zero on success, negative on failure +*/ +int cvmx_agl_enable (int port) +{ +cvmx_agl_gmx_rxx_frm_ctl_t rxx_frm_ctl; + + rxx_frm_ctl.u64 =0 ; + rxx_frm_ctl.s.pre_align =1 ; +/* When set, disables the length check for non-min sized pkts with +* padding in the client data +*/ + rxx_frm_ctl.s.pad_len =1 ; +/* When set, disables the length check for VLAN pkts */ + rxx_frm_ctl.s.vlan_len =1 ; +/* When set, PREAMBLE checking is less strict */ + rxx_frm_ctl.s.pre_free =1 ; +/* Control Pause Frames can match station SMAC */ + rxx_frm_ctl.s.ctl_smac =0 ; +/* Control Pause Frames can match globally assign Multicast address */ + rxx_frm_ctl.s.ctl_mcst =1 ; + rxx_frm_ctl.s.ctl_bck =1 ;/* Forward pause information to TX block */ + rxx_frm_ctl.s.ctl_drp =1 ;/* Drop Control Pause Frames */ + rxx_frm_ctl.s.pre_strp =1 ;/* Strip off the preamble */ +/* This port is configured to send PREAMBLE+SFD to begin every frame. +* GMX checks that the PREAMBLE is sent correctly +*/ + rxx_frm_ctl.s.pre_chk =1 ; +csr_wr (CVMX_AGL_GMX_RXX_FRM_CTL (port), rxx_frm_ctl.u64); + +return 0 ; +} + +cvmx_helper_link_info_t cvmx_agl_link_get (int port) +{ +cvmx_helper_link_info_t result; +int interface, port_index; + +/* Fake IPD port is used on some older models. */ +if (port <0 ) +return __cvmx_helper_board_link_get (port); + +/* Simulator does not have PHY, use some defaults. */ + interface =cvmx_helper_get_interface_num (port); + port_index =cvmx_helper_get_interface_index_num (port); +if (cvmx_helper_get_port_force_link_up (interface, port_index)) { + result.u64 =0 ; + result.s.full_duplex =1 ; + result.s.link_up =1 ; + result.s.speed =1000 ; +return result; + } + +return __cvmx_helper_board_link_get (port); +} + +/* +* Set MII/RGMII link based on mode. +* +* @param port interface port to set the link. +* @param link_info Link status +* +* @return 0 on success and 1 on failure +*/ +int cvmx_agl_link_set (int port,cvmx_helper_link_info_t link_info) +{ +cvmx_agl_gmx_prtx_cfg_t agl_gmx_prtx; + +/* Disable GMX before we make any changes. */ + agl_gmx_prtx.u64 =csr_rd (CVMX_AGL_GMX_PRTX_CFG (port)); + agl_gmx_prtx.s.en =0 ; + agl_gmx_prtx.s.tx_en =0 ; + agl_gmx_prtx.s.rx_en =0 ; +csr_wr (CVMX_AGL_GMX_PRTX_CFG (port), agl_gmx_prtx.u64); + +if (OCTEON_IS_MODEL (OCTEON_CN6XXX ) ||OCTEON_IS_OCTEON3 ()) { +u64 one_second =0x1000000 ;/* todo: this needs checking */ + +/* Wait for GMX to be idle */ +if (CVMX_WAIT_FOR_FIELD64 (CVMX_AGL_GMX_PRTX_CFG (port), + cvmx_agl_gmx_prtx_cfg_t, rx_idle, ==, +1 , one_second) || +CVMX_WAIT_FOR_FIELD64 (CVMX_AGL_GMX_PRTX_CFG (port), + cvmx_agl_gmx_prtx_cfg_t, tx_idle, ==, +1 , one_second)) { +debug ("AGL%d: Timeout waiting for GMX to be idle\n" , + port); +return -1 ; + } + } + + agl_gmx_prtx.u64 =csr_rd (CVMX_AGL_GMX_PRTX_CFG (port)); + +/* Set duplex mode */ +if (!link_info.s.link_up) + agl_gmx_prtx.s.duplex =1 ;/* Force full duplex on down links */ +else + agl_gmx_prtx.s.duplex = link_info.s.full_duplex; + +switch (link_info.s.speed) { +case 10 : + agl_gmx_prtx.s.speed =0 ; + agl_gmx_prtx.s.slottime =0 ; +if (OCTEON_IS_MODEL (OCTEON_CN6XXX ) ||OCTEON_IS_OCTEON3 ()) { + agl_gmx_prtx.s.speed_msb =1 ; + agl_gmx_prtx.s.burst =1 ; + } +break ; + +case 100 : + agl_gmx_prtx.s.speed =0 ; + agl_gmx_prtx.s.slottime =0 ; +if (OCTEON_IS_MODEL (OCTEON_CN6XXX ) ||OCTEON_IS_OCTEON3 ()) { + agl_gmx_prtx.s.speed_msb =0 ; + agl_gmx_prtx.s.burst =1 ; + } +break ; + +case 1000 : +/* 1000 MBits is only supported on 6XXX chips */ +if (OCTEON_IS_MODEL (OCTEON_CN6XXX ) ||OCTEON_IS_OCTEON3 ()) { + agl_gmx_prtx.s.speed_msb =0 ; + agl_gmx_prtx.s.speed =1 ; + agl_gmx_prtx.s.slottime = +1 ;/* Only matters for half-duplex */ + agl_gmx_prtx.s.burst = agl_gmx_prtx.s.duplex; + } +break ; + +/* No link */ +case 0 : +default : +break ; + } + +/* Write the new GMX setting with the port still disabled. */ +csr_wr (CVMX_AGL_GMX_PRTX_CFG (port), agl_gmx_prtx.u64); + +/* Read GMX CFG again to make sure the config is completed. */ + agl_gmx_prtx.u64 =csr_rd (CVMX_AGL_GMX_PRTX_CFG (port)); + +if (OCTEON_IS_MODEL (OCTEON_CN6XXX ) ||OCTEON_IS_OCTEON3 ()) { +cvmx_agl_gmx_txx_clk_t agl_clk; +cvmx_agl_prtx_ctl_t prt_ctl; + + prt_ctl.u64 =csr_rd (CVMX_AGL_PRTX_CTL (port)); + agl_clk.u64 =csr_rd (CVMX_AGL_GMX_TXX_CLK (port)); +/* MII (both speeds) and RGMII 1000 setting */ + agl_clk.s.clk_cnt =1 ; +/* Check other speeds for RGMII mode */ +if (prt_ctl.s.mode ==0 ||OCTEON_IS_OCTEON3 ()) { +if (link_info.s.speed ==10 ) + agl_clk.s.clk_cnt =50 ; +else if (link_info.s.speed ==100 ) + agl_clk.s.clk_cnt =5 ; + } +csr_wr (CVMX_AGL_GMX_TXX_CLK (port), agl_clk.u64); + } + +/* Enable transmit and receive ports */ + agl_gmx_prtx.s.tx_en =1 ; + agl_gmx_prtx.s.rx_en =1 ; +csr_wr (CVMX_AGL_GMX_PRTX_CFG (port), agl_gmx_prtx.u64); + +/* Enable the link. */ + agl_gmx_prtx.s.en =1 ; +csr_wr (CVMX_AGL_GMX_PRTX_CFG (port), agl_gmx_prtx.u64); + +if (OCTEON_IS_OCTEON3 ()) { +union cvmx_agl_prtx_ctl agl_prtx_ctl; +/* Enable the interface, set clkrst */ + agl_prtx_ctl.u64 =csr_rd (CVMX_AGL_PRTX_CTL (port)); + agl_prtx_ctl.s.clkrst =1 ; +csr_wr (CVMX_AGL_PRTX_CTL (port), agl_prtx_ctl.u64); +csr_rd (CVMX_AGL_PRTX_CTL (port)); + agl_prtx_ctl.s.enable =1 ; +csr_wr (CVMX_AGL_PRTX_CTL (port), agl_prtx_ctl.u64); +/* Read the value back to force the previous write */ +csr_rd (CVMX_AGL_PRTX_CTL (port)); + } + +return 0 ; +}
Signature · 1 line
2.35.1
PATCH 19/52 mips: octeon: Add cvmx-helper-pko3.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-helper-pko3.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-helper-pko3.c | 1252 ++++++++++++++++++++++ 1 file changed, 1252 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-helper-pko3.c
arch/mips/mach-octeon/cvmx-helper-pko3.c new file +1252 -0
@@ -0,0 +1,1252 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* PKOv3 helper file +*/ + +#include <errno.h> +#include <log.h> +#include <time.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/cvmx-fuse.h> +#include <mach/octeon-feature.h> +#include <mach/cvmx-qlm.h> +#include <mach/octeon_qlm.h> +#include <mach/cvmx-pcie.h> +#include <mach/cvmx-coremask.h> +#include <mach/cvmx-range.h> +#include <mach/cvmx-global-resources.h> + +#include <mach/cvmx-agl-defs.h> +#include <mach/cvmx-bgxx-defs.h> +#include <mach/cvmx-ciu-defs.h> +#include <mach/cvmx-gmxx-defs.h> +#include <mach/cvmx-gserx-defs.h> +#include <mach/cvmx-ilk-defs.h> +#include <mach/cvmx-ipd-defs.h> +#include <mach/cvmx-pcsx-defs.h> +#include <mach/cvmx-pcsxx-defs.h> +#include <mach/cvmx-pki-defs.h> +#include <mach/cvmx-pko-defs.h> +#include <mach/cvmx-xcv-defs.h> + +#include <mach/cvmx-hwpko.h> +#include <mach/cvmx-ilk.h> +#include <mach/cvmx-ipd.h> +#include <mach/cvmx-pki.h> +#include <mach/cvmx-pko3.h> +#include <mach/cvmx-pko3-queue.h> +#include <mach/cvmx-pko3-resources.h> + +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> + +#include <mach/cvmx-helper-bgx.h> +#include <mach/cvmx-helper-cfg.h> +#include <mach/cvmx-helper-util.h> +#include <mach/cvmx-helper-pki.h> + +/* channels are present at L2 queue level by default */ +static const enum cvmx_pko3_level_e cvmx_pko_default_channel_level = +CVMX_PKO_L2_QUEUES ; + +static const int debug; + +static int __pko_pkt_budget, __pko_pkt_quota; + +/* These global variables are relevant for boot CPU only */ +static cvmx_fpa3_gaura_t __cvmx_pko3_aura[CVMX_MAX_NODES ]; + +/* This constant can not be modified, defined here for clarity only */ +#define CVMX_PKO3_POOL_BUFFER_SIZE 4096/* 78XX PKO requires 4KB */ + +/** +* @INTERNAL +* +* Build an owner tag based on interface/port +*/ +static int __cvmx_helper_pko3_res_owner (int ipd_port) +{ +int res_owner; +const int res_owner_pfix =0x19d0 <<14 ; + + ipd_port &=0x3fff ;/* 12-bit for local CHAN_E value + node */ + + res_owner = res_owner_pfix | ipd_port; + +return res_owner; +} + +/** +* Configure an AURA/POOL designated for PKO internal use. +* +* This pool is used for (a) memory buffers that store PKO descriptor queues, +* (b) buffers for use with PKO_SEND_JUMP_S sub-header. +* +* The buffers of type (a) are never accessed by software, and their number +* should be at least equal to 4 times the number of descriptor queues +* in use. +* +* Type (b) buffers are consumed by PKO3 command-composition code, +* and are released by the hardware upon completion of transmission. +* +* @returns -1 if the pool could not be established or 12-bit AURA +* that includes the node number for use in PKO3 initialization call. +* +* NOTE: Linux kernel should pass its own aura to PKO3 initialization +* function so that the buffers can be mapped into kernel space +* for when software needs to adccess their contents. +* +*/ +static int __cvmx_pko3_config_memory (unsigned int node) +{ +cvmx_fpa3_gaura_t aura; +int aura_num; +unsigned int buf_count; +bool small_mem; +int i, num_intf =0 ; +const unsigned int pkt_per_buf = + (CVMX_PKO3_POOL_BUFFER_SIZE /sizeof (u64) /16 ); +const unsigned int base_buf_count =1024 *4 ; + +/* Simulator has limited memory, but uses one interface at a time */ +// small_mem = cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_SIM; + small_mem = false; + +/* Count the number of live interfaces */ +for (i =0 ; i <cvmx_helper_get_number_of_interfaces (); i++) { +int xiface =cvmx_helper_node_interface_to_xiface (node, i); + +if (CVMX_HELPER_INTERFACE_MODE_DISABLED != +cvmx_helper_interface_get_mode (xiface)) + num_intf++; + } + + buf_count =1024 ; + __pko_pkt_quota = buf_count * pkt_per_buf; + __pko_pkt_budget = __pko_pkt_quota * num_intf; + (void )small_mem; + (void )base_buf_count; + +if (debug) +debug ("%s: Creating AURA with %u buffers for up to %d total packets, %d packets per interface\n" , + __func__, buf_count, __pko_pkt_budget, __pko_pkt_quota); + + aura =cvmx_fpa3_setup_aura_and_pool (node,-1 ,"PKO3 AURA" ,NULL , +CVMX_PKO3_POOL_BUFFER_SIZE , + buf_count); + +if (!__cvmx_fpa3_aura_valid (aura)) { +printf ("ERROR: %s AURA create failed\n" , __func__); +return -1 ; + } + + aura_num = aura.node <<10 | aura.laura; + +/* Store handle for destruction */ + __cvmx_pko3_aura[node] = aura; + +return aura_num; +} + +/** Initialize a channelized port +* This is intended for LOOP, ILK and NPI interfaces which have one MAC +* per interface and need a channel per subinterface (e.g. ring). +* Each channel then may have 'num_queues' descriptor queues +* attached to it, which can also be prioritized or fair. +*/ +static int __cvmx_pko3_config_chan_interface (int xiface,unsigned int num_chans, +u8 num_queues,bool prioritized) +{ +int l1_q_num; +int l2_q_base; +enum cvmx_pko3_level_e level; +int res; +int parent_q, child_q; +unsigned int chan, dq; +int pko_mac_num; +u16 ipd_port; +int res_owner, prio; +unsigned int i; +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); +unsigned int node = xi.node; +char b1[12 ]; + +if (num_queues ==0 ) + num_queues =1 ; +if ((cvmx_pko3_num_level_queues (CVMX_PKO_DESCR_QUEUES ) / num_chans) <3 ) + num_queues =1 ; + +if (prioritized && num_queues >1 ) + prio = num_queues; +else + prio =-1 ; + +if (debug) +debug ("%s: configuring xiface %u:%u with %u chans %u queues each\n" , + __func__, xi.node, xi.interface, num_chans, num_queues); + +/* all channels all go to the same mac */ + pko_mac_num =__cvmx_pko3_get_mac_num (xiface,0 ); +if (pko_mac_num <0 ) { +printf ("ERROR: %s: Invalid interface\n" , __func__); +return -1 ; + } + +/* Resources of all channels on this port have common owner */ + ipd_port =cvmx_helper_get_ipd_port (xiface,0 ); + +/* Build an identifiable owner */ + res_owner =__cvmx_helper_pko3_res_owner (ipd_port); + +/* Start configuration at L1/PQ */ + level =CVMX_PKO_PORT_QUEUES ; + +/* Reserve port queue to make sure the MAC is not already configured */ + l1_q_num =cvmx_pko_alloc_queues (node, level, res_owner,-1 ,1 ); + +if (l1_q_num <0 ) { +printf ("ERROR: %s: Reserving L1 PQ\n" , __func__); +return -1 ; + } + + res =cvmx_pko3_pq_config (node, pko_mac_num, l1_q_num); +if (res <0 ) { +printf ("ERROR: %s: Configuring L1 PQ\n" , __func__); +return -1 ; + } + +/* next queue level = L2/SQ */ + level =__cvmx_pko3_sq_lvl_next (level); + +/* allocate level 2 queues, one per channel */ + l2_q_base = +cvmx_pko_alloc_queues (node, level, res_owner,-1 , num_chans); +if (l2_q_base <0 ) { +printf ("ERROR: %s: allocation L2 SQ\n" , __func__); +return -1 ; + } + +/* Configre <num_chans> L2 children for PQ, non-prioritized */ + res =cvmx_pko3_sq_config_children (node, level, l1_q_num, l2_q_base, + num_chans,-1 ); + +if (res <0 ) { +printf ("ERROR: %s: Failed channel queues\n" , __func__); +return -1 ; + } + +/* map channels to l2 queues */ +for (chan =0 ; chan < num_chans; chan++) { + ipd_port =cvmx_helper_get_ipd_port (xiface, chan); +cvmx_pko3_map_channel (node, l1_q_num, l2_q_base + chan, + ipd_port); + } + +/* next queue level = L3/SQ */ + level =__cvmx_pko3_sq_lvl_next (level); + parent_q = l2_q_base; + +do { + child_q =cvmx_pko_alloc_queues (node, level, res_owner,-1 , + num_chans); + +if (child_q <0 ) { +printf ("ERROR: %s: allocating %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, child_q)); +return -1 ; + } + +for (i =0 ; i < num_chans; i++) { + res =cvmx_pko3_sq_config_children ( + node, level, parent_q + i, child_q + i,1 ,1 ); + +if (res <0 ) { +printf ("ERROR: %s: configuring %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, child_q)); +return -1 ; + } + + }/* for i */ + + parent_q = child_q; + level =__cvmx_pko3_sq_lvl_next (level); + +/* Terminate loop on DQ level, it has special handling */ + }while (level !=CVMX_PKO_DESCR_QUEUES && + level !=CVMX_PKO_LEVEL_INVAL ); + +if (level !=CVMX_PKO_DESCR_QUEUES ) { +printf ("ERROR: %s: level sequence error\n" , __func__); +return -1 ; + } + +/* Configure DQs, num_dqs per chan */ +for (chan =0 ; chan < num_chans; chan++) { + res =cvmx_pko_alloc_queues (node, level, res_owner,-1 , + num_queues); + +if (res <0 ) + goto _fail; + dq = res; + +if (OCTEON_IS_MODEL (OCTEON_CN78XX_PASS1_0 ) && (dq &7 )) +debug ("WARNING: %s: DQ# %u not integral of 8\n" , + __func__, dq); + + res =cvmx_pko3_sq_config_children (node, level, parent_q + chan, + dq, num_queues, prio); +if (res <0 ) + goto _fail; + +/* register DQ range with the translation table */ + res =__cvmx_pko3_ipd_dq_register (xiface, chan, dq, num_queues); +if (res <0 ) + goto _fail; + } + +return 0 ; +_fail: +debug ("ERROR: %s: configuring queues for xiface %u:%u chan %u\n" , + __func__, xi.node, xi.interface, i); +return -1 ; +} + +/** Initialize a single Ethernet port with PFC-style channels +* +* One interface can contain multiple ports, this function is per-port +* Here, a physical port is allocated 8 logical channel, one per VLAN +* tag priority, one DQ is assigned to each channel, and all 8 DQs +* are registered for that IPD port. +* Note that the DQs are arrange such that the Ethernet QoS/PCP field +* can be used as an offset to the value returned by cvmx_pko_base_queue_get(). +* +* For HighGig2 mode, 16 channels may be desired, instead of 8, +* but this function does not support that. +*/ +static int __cvmx_pko3_config_pfc_interface (int xiface,unsigned int port) +{ +enum cvmx_pko3_level_e level; +int pko_mac_num; +int l1_q_num, l2_q_base; +int child_q, parent_q; +int dq_base; +int res; +const unsigned int num_chans =8 ; +cvmx_xiface_t xi =cvmx_helper_xiface_to_node_interface (xiface); +unsigned int node = xi.node; +u16 ipd_port; +int res_owner; +char b1[12 ]; +unsigned int i; + +if (debug) +debug ("%s: configuring xiface %u:%u port %u with %u PFC channels\n" , + __func__, node, xi.interface, port, num_chans); + +/* Get MAC number for the iface/port */ + pko_mac_num =__cvmx_pko3_get_mac_num (xiface, port); +if (pko_mac_num <0 ) { +printf ("ERROR: %s: Invalid interface\n" , __func__); +return -1 ; + } + + ipd_port =cvmx_helper_get_ipd_port (xiface, port); + +/* Build an identifiable owner identifier */ + res_owner =__cvmx_helper_pko3_res_owner (ipd_port); + + level =CVMX_PKO_PORT_QUEUES ; + +/* Allocate port queue to make sure the MAC is not already configured */ + l1_q_num =cvmx_pko_alloc_queues (node, level, res_owner,-1 ,1 ); + +if (l1_q_num <0 ) { +printf ("ERROR: %s: allocation L1 PQ\n" , __func__); +return -1 ; + } + + res =cvmx_pko3_pq_config (xi.node, pko_mac_num, l1_q_num); +if (res <0 ) { +printf ("ERROR: %s: Configuring %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, l1_q_num)); +return -1 ; + } + +/* Determine the next queue level */ + level =__cvmx_pko3_sq_lvl_next (level); + +/* Allocate 'num_chans' L2 queues, one per channel */ + l2_q_base = +cvmx_pko_alloc_queues (node, level, res_owner,-1 , num_chans); +if (l2_q_base <0 ) { +printf ("ERROR: %s: allocation L2 SQ\n" , __func__); +return -1 ; + } + +/* Configre <num_chans> L2 children for PQ, with static priority */ + res =cvmx_pko3_sq_config_children (node, level, l1_q_num, l2_q_base, + num_chans, num_chans); + +if (res <0 ) { +printf ("ERROR: %s: Configuring %s for PFC\n" , __func__, +__cvmx_pko3_sq_str (b1, level, l1_q_num)); +return -1 ; + } + +/* Map each of the allocated channels */ +for (i =0 ; i < num_chans; i++) { +u16 chan; + +/* Get CHAN_E value for this PFC channel, PCP in low 3 bits */ + chan = ipd_port |cvmx_helper_prio2qos (i); + +cvmx_pko3_map_channel (node, l1_q_num, l2_q_base + i, chan); + } + +/* Iterate through the levels until DQ and allocate 'num_chans' +* consecutive queues at each level and hook them up +* one-to-one with the parent level queues +*/ + + parent_q = l2_q_base; + level =__cvmx_pko3_sq_lvl_next (level); + +do { + child_q =cvmx_pko_alloc_queues (node, level, res_owner,-1 , + num_chans); + +if (child_q <0 ) { +printf ("ERROR: %s: allocating %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, child_q)); +return -1 ; + } + +for (i =0 ; i < num_chans; i++) { + res =cvmx_pko3_sq_config_children ( + node, level, parent_q + i, child_q + i,1 ,1 ); + +if (res <0 ) { +printf ("ERROR: %s: configuring %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, child_q)); +return -1 ; + } + + }/* for i */ + + parent_q = child_q; + level =__cvmx_pko3_sq_lvl_next (level); + +/* Terminate loop on DQ level, it has special handling */ + }while (level !=CVMX_PKO_DESCR_QUEUES && + level !=CVMX_PKO_LEVEL_INVAL ); + +if (level !=CVMX_PKO_DESCR_QUEUES ) { +printf ("ERROR: %s: level sequence error\n" , __func__); +return -1 ; + } + + dq_base =cvmx_pko_alloc_queues (node, level, res_owner,-1 , num_chans); +if (dq_base <0 ) { +printf ("ERROR: %s: allocating %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, dq_base)); +return -1 ; + } + +/* Configure DQs in QoS order, so that QoS/PCP can be index */ +for (i =0 ; i < num_chans; i++) { +int dq_num = dq_base +cvmx_helper_prio2qos (i); + + res =cvmx_pko3_sq_config_children (node, level, parent_q + i, + dq_num,1 ,1 ); +if (res <0 ) { +printf ("ERROR: %s: configuring %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, dq_num)); +return -1 ; + } + } + +/* register entire DQ range with the IPD translation table */ +__cvmx_pko3_ipd_dq_register (xiface, port, dq_base, num_chans); + +return 0 ; +} + +/** +* Initialize a simple interface with a a given number of +* fair or prioritized queues. +* This function will assign one channel per sub-interface. +*/ +int __cvmx_pko3_config_gen_interface (int xiface,uint8_t subif,u8 num_queues, +bool prioritized) +{ +cvmx_xiface_t xi =cvmx_helper_xiface_to_node_interface (xiface); +u8 node = xi.node; +int l1_q_num; +int parent_q, child_q; +int dq; +int res, res_owner; +int pko_mac_num; +enum cvmx_pko3_level_e level; +u16 ipd_port; +int static_pri; +char b1[12 ]; + + num_queues =1 ; + +if (num_queues ==0 ) { + num_queues =1 ; +printf ("WARNING: %s: xiface %#x misconfigured\n" , __func__, + xiface); + } + +/* Configure DQs relative priority (a.k.a. scheduling) */ +if (prioritized) { +/* With 8 queues or fewer, use static priority, else WRR */ + static_pri = (num_queues <9 ) ? num_queues :0 ; + }else { +/* Set equal-RR scheduling among queues */ + static_pri =-1 ; + } + +if (debug) +debug ("%s: configuring xiface %u:%u/%u nq=%u %s\n" , __func__, + xi.node, xi.interface, subif, num_queues, + (prioritized) ?"qos" :"fair" ); + +/* Get MAC number for the iface/port */ + pko_mac_num =__cvmx_pko3_get_mac_num (xiface, subif); +if (pko_mac_num <0 ) { +printf ("ERROR: %s: Invalid interface %u:%u\n" , __func__, + xi.node, xi.interface); +return -1 ; + } + + ipd_port =cvmx_helper_get_ipd_port (xiface, subif); + +if (debug) +debug ("%s: xiface %u:%u/%u ipd_port=%#03x\n" , __func__, xi.node, + xi.interface, subif, ipd_port); + +/* Build an identifiable owner identifier */ + res_owner =__cvmx_helper_pko3_res_owner (ipd_port); + + level =CVMX_PKO_PORT_QUEUES ; + +/* Reserve port queue to make sure the MAC is not already configured */ + l1_q_num =cvmx_pko_alloc_queues (node, level, res_owner,-1 ,1 ); + +if (l1_q_num <0 ) { +printf ("ERROR %s: xiface %u:%u/%u failed allocation L1 PQ\n" , + __func__, xi.node, xi.interface, subif); +return -1 ; + } + + res =cvmx_pko3_pq_config (node, pko_mac_num, l1_q_num); +if (res <0 ) { +printf ("ERROR %s: Configuring L1 PQ\n" , __func__); +return -1 ; + } + + parent_q = l1_q_num; + +/* Determine the next queue level */ + level =__cvmx_pko3_sq_lvl_next (level); + +/* Simply chain queues 1-to-1 from L2 to one before DQ level */ +do { +/* allocate next level queue */ + child_q =cvmx_pko_alloc_queues (node, level, res_owner,-1 ,1 ); + +if (child_q <0 ) { +printf ("ERROR: %s: allocating %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, child_q)); +return -1 ; + } + +/* Configre newly allocated queue */ + res =cvmx_pko3_sq_config_children (node, level, parent_q, + child_q,1 ,1 ); + +if (res <0 ) { +printf ("ERROR: %s: configuring %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, child_q)); +return -1 ; + } + +/* map IPD/channel to L2/L3 queues */ +if (level == cvmx_pko_default_channel_level) +cvmx_pko3_map_channel (node, l1_q_num, child_q, + ipd_port); + +/* Prepare for next level */ + level =__cvmx_pko3_sq_lvl_next (level); + parent_q = child_q; + +/* Terminate loop on DQ level, it has special handling */ + }while (level !=CVMX_PKO_DESCR_QUEUES && + level !=CVMX_PKO_LEVEL_INVAL ); + +if (level !=CVMX_PKO_DESCR_QUEUES ) { +printf ("ERROR: %s: level sequence error\n" , __func__); +return -1 ; + } + +/* Allocate descriptor queues for the port */ + dq =cvmx_pko_alloc_queues (node, level, res_owner,-1 , num_queues); +if (dq <0 ) { +printf ("ERROR: %s: could not reserve DQs\n" , __func__); +return -1 ; + } + + res =cvmx_pko3_sq_config_children (node, level, parent_q, dq, + num_queues, static_pri); +if (res <0 ) { +printf ("ERROR: %s: configuring %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, dq)); +return -1 ; + } + +/* register DQ/IPD translation */ +__cvmx_pko3_ipd_dq_register (xiface, subif, dq, num_queues); + +if (debug) +debug ("%s: xiface %u:%u/%u qs %u-%u\n" , __func__, xi.node, + xi.interface, subif, dq, dq + num_queues -1 ); +return 0 ; +} + +/** Initialize the NULL interface +* +* A NULL interface is a special case in that it is not +* one of the enumerated interfaces in the system, and does +* not apply to input either. Still, it can be very handy +* for dealing with packets that should be discarded in +* a generic, streamlined way. +* +* The Descriptor Queue 0 will be reserved for the NULL interface +* and the normalized (i.e. IPD) port number has the all-ones value. +*/ +static int __cvmx_pko3_config_null_interface (unsigned int node) +{ +int l1_q_num; +int parent_q, child_q; +enum cvmx_pko3_level_e level; +int i, res, res_owner; +int xiface, ipd_port; +int num_dq =1 ;/* # of DQs for NULL */ +const int dq =0 ;/* Reserve DQ#0 for NULL */ +char pko_mac_num; +char b1[12 ]; + +if (OCTEON_IS_MODEL (OCTEON_CN78XX )) + pko_mac_num =0x1C ;/* MAC# 28 virtual MAC for NULL */ +else if (OCTEON_IS_MODEL (OCTEON_CN73XX )) + pko_mac_num =0x0F ;/* MAC# 16 virtual MAC for NULL */ +else if (OCTEON_IS_MODEL (OCTEON_CNF75XX )) + pko_mac_num =0x0A ;/* MAC# 10 virtual MAC for NULL */ +else +return -1 ; + +if (OCTEON_IS_MODEL (OCTEON_CN78XX_PASS1_0 )) + num_dq =8 ; + +if (debug) +debug ("%s: null iface dq=%u-%u\n" , __func__, dq, + dq + num_dq -1 ); + + ipd_port =cvmx_helper_node_to_ipd_port (node,CVMX_PKO3_IPD_PORT_NULL ); + +/* Build an identifiable owner identifier by MAC# for easy release */ + res_owner =__cvmx_helper_pko3_res_owner (ipd_port); +if (res_owner <0 ) { +debug ("%s: ERROR Invalid interface\n" , __func__); +return -1 ; + } + + level =CVMX_PKO_PORT_QUEUES ; + +/* Allocate a port queue */ + l1_q_num =cvmx_pko_alloc_queues (node, level, res_owner,-1 ,1 ); + +if (l1_q_num <0 ) { +debug ("%s: ERROR reserving L1 SQ\n" , __func__); +return -1 ; + } + + res =cvmx_pko3_pq_config (node, pko_mac_num, l1_q_num); +if (res <0 ) { +printf ("ERROR: %s: PQ/L1 queue configuration\n" , __func__); +return -1 ; + } + + parent_q = l1_q_num; + +/* Determine the next queue level */ + level =__cvmx_pko3_sq_lvl_next (level); + +/* Simply chain queues 1-to-1 from L2 to one before DQ level */ +do { +/* allocate next level queue */ + child_q =cvmx_pko_alloc_queues (node, level, res_owner,-1 ,1 ); + +if (child_q <0 ) { +printf ("ERROR: %s: allocating %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, child_q)); +return -1 ; + } + +/* Configre newly allocated queue */ + res =cvmx_pko3_sq_config_children (node, level, parent_q, + child_q,1 ,1 ); + +if (res <0 ) { +printf ("ERROR: %s: configuring %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, child_q)); +return -1 ; + } + +/* Prepare for next level */ + level =__cvmx_pko3_sq_lvl_next (level); + parent_q = child_q; + +/* Terminate loop on DQ level, it has special handling */ + }while (level !=CVMX_PKO_DESCR_QUEUES && + level !=CVMX_PKO_LEVEL_INVAL ); + +if (level !=CVMX_PKO_DESCR_QUEUES ) { +printf ("ERROR: %s: level sequence error\n" , __func__); +return -1 ; + } + +/* Reserve 'num_dq' DQ's at 0 by convention */ + res =cvmx_pko_alloc_queues (node, level, res_owner, dq, num_dq); +if (dq != res) { +debug ("%s: ERROR: could not reserve DQs\n" , __func__); +return -1 ; + } + + res =cvmx_pko3_sq_config_children (node, level, parent_q, dq, num_dq, + num_dq); +if (res <0 ) { +printf ("ERROR: %s: configuring %s\n" , __func__, +__cvmx_pko3_sq_str (b1, level, dq)); +return -1 ; + } + +/* NULL interface does not need to map to a CHAN_E */ + +/* register DQ/IPD translation */ + xiface =cvmx_helper_node_interface_to_xiface (node, __CVMX_XIFACE_NULL); +__cvmx_pko3_ipd_dq_register (xiface,0 , dq, num_dq); + +/* open the null DQs here */ +for (i =0 ; i < num_dq; i++) { +unsigned int limit =128 ;/* NULL never really uses much */ + +cvmx_pko_dq_open (node, dq + i); +cvmx_pko3_dq_set_limit (node, dq + i, limit); + } + +return 0 ; +} + +/** Open all descriptor queues belonging to an interface/port +* @INTERNAL +*/ +int __cvmx_pko3_helper_dqs_activate (int xiface,int index,bool min_pad) +{ +int ipd_port, dq_base, dq_count, i; +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); +unsigned int limit; + +/* Get local IPD port for the interface */ + ipd_port =cvmx_helper_get_ipd_port (xiface, index); +if (ipd_port <0 ) { +printf ("ERROR: %s: No IPD port for interface %d port %d\n" , + __func__, xiface, index); +return -1 ; + } + +/* Get DQ# range for the IPD port */ + dq_base =cvmx_pko3_get_queue_base (ipd_port); + dq_count =cvmx_pko3_get_queue_num (ipd_port); +if (dq_base <0 || dq_count <=0 ) { +printf ("ERROR: %s: No descriptor queues for interface %d port %d\n" , + __func__, xiface, index); +return -1 ; + } + +/* Mask out node from global DQ# */ + dq_base &= (1 <<10 ) -1 ; + + limit = __pko_pkt_quota / dq_count / +cvmx_helper_interface_enumerate (xiface); + +for (i =0 ; i < dq_count; i++) { +/* FIXME: 2ms at 1Gbps max packet rate, make speed dependent */ +cvmx_pko_dq_open (xi.node, dq_base + i); +cvmx_pko3_dq_options (xi.node, dq_base + i, min_pad); + +if (debug) +debug ("%s: DQ%u limit %d\n" , __func__, dq_base + i, + limit); + +cvmx_pko3_dq_set_limit (xi.node, dq_base + i, limit); + __pko_pkt_budget -= limit; + } + +if (__pko_pkt_budget <0 ) +printf ("WARNING: %s: PKO buffer deficit %d\n" , __func__, + __pko_pkt_budget); +else if (debug) +debug ("%s: PKO remaining packet budget: %d\n" , __func__, + __pko_pkt_budget); + +return i; +} + +/** Configure and initialize PKO3 for an interface +* +* @param xiface is the interface number to configure +* @return 0 on success. +*/ +int cvmx_helper_pko3_init_interface (int xiface) +{ +cvmx_helper_interface_mode_t mode; +int node, iface, subif, num_ports; +bool fcs_enable, pad_enable, pad_enable_pko; +u8 fcs_sof_off =0 ; +u8 num_queues =1 ; +bool qos = false, pfc = false; +int res =-1 ; +cvmx_xiface_t xi =cvmx_helper_xiface_to_node_interface (xiface); + + node = xi.node; + iface = xi.interface; + mode =cvmx_helper_interface_get_mode (xiface); + num_ports =cvmx_helper_interface_enumerate (xiface); + subif =0 ; + +if ((unsigned int )iface < +NUM_ELEMENTS (__cvmx_pko_queue_static_config[node].pknd.pko_cfg_iface)) { + pfc = __cvmx_pko_queue_static_config[node] + .pknd.pko_cfg_iface[iface] + .pfc_enable; + num_queues = __cvmx_pko_queue_static_config[node] + .pknd.pko_cfg_iface[iface] + .queues_per_port; + qos = __cvmx_pko_queue_static_config[node] + .pknd.pko_cfg_iface[iface] + .qos_enable; + } + +/* Force 8 DQs per port for pass 1.0 to circumvent limitations */ +if (OCTEON_IS_MODEL (OCTEON_CN78XX_PASS1_0 )) + num_queues =8 ; + +/* For ILK there is one IPD port per channel */ +if (mode ==CVMX_HELPER_INTERFACE_MODE_ILK ) + num_ports =__cvmx_helper_ilk_enumerate (xiface); + +/* Skip non-existent interfaces */ +if (num_ports <1 ) { +debug ("ERROR: %s: invalid iface %u:%u\n" , __func__, node, + iface); +return -1 ; + } + +if (mode ==CVMX_HELPER_INTERFACE_MODE_LOOP ) { + num_queues = __cvmx_pko_queue_static_config[node] + .pknd.pko_cfg_loop.queues_per_port; + qos = __cvmx_pko_queue_static_config[node] + .pknd.pko_cfg_loop.qos_enable; + +if (OCTEON_IS_MODEL (OCTEON_CN78XX_PASS1_0 )) + num_queues =8 ; + + res =__cvmx_pko3_config_chan_interface (xiface, num_ports, + num_queues, qos); +if (res <0 ) + goto __cfg_error; + }else if (mode ==CVMX_HELPER_INTERFACE_MODE_NPI ) { + num_queues = __cvmx_pko_queue_static_config[node] + .pknd.pko_cfg_npi.queues_per_port; + qos = __cvmx_pko_queue_static_config[node] + .pknd.pko_cfg_npi.qos_enable; + +if (OCTEON_IS_MODEL (OCTEON_CN78XX_PASS1_0 )) + num_queues =8 ; + + res =__cvmx_pko3_config_chan_interface (xiface, num_ports, + num_queues, qos); +if (res <0 ) + goto __cfg_error; + } +/* ILK-specific queue configuration */ +else if (mode ==CVMX_HELPER_INTERFACE_MODE_ILK ) { +unsigned int num_chans =__cvmx_helper_ilk_enumerate (xiface); + + num_queues =8 ; + qos = true; + pfc = false; + +if (num_chans >=128 ) + num_queues =1 ; +else if (num_chans >=64 ) + num_queues =2 ; +else if (num_chans >=32 ) + num_queues =4 ; +else + num_queues =8 ; + + res =__cvmx_pko3_config_chan_interface (xiface, num_chans, + num_queues, qos); + } +/* Setup all ethernet configured for PFC */ +else if (pfc) { +/* PFC interfaces have 8 prioritized queues */ +for (subif =0 ; subif < num_ports; subif++) { + res =__cvmx_pko3_config_pfc_interface (xiface, subif); +if (res <0 ) + goto __cfg_error; + +/* Enable PFC/CBFC on BGX */ +__cvmx_helper_bgx_xaui_config_pfc (node, iface, subif, + true); + } + }else { +/* All other interfaces follow static configuration */ +for (subif =0 ; subif < num_ports; subif++) { + res =__cvmx_pko3_config_gen_interface (xiface, subif, + num_queues, qos); +if (res <0 ) + goto __cfg_error; + } + } + + fcs_enable =__cvmx_helper_get_has_fcs (xiface); + pad_enable =__cvmx_helper_get_pko_padding (xiface); + +/* Do not use PKO PAD/FCS generation on o78p1.x on BGX interfaces */ +if (OCTEON_IS_MODEL (OCTEON_CN78XX_PASS1_X )) + pad_enable_pko = false; +else + pad_enable_pko = pad_enable; + +if (debug) +debug ("%s: iface %u:%u FCS=%d pad=%d pko=%d\n" , __func__, node, + iface, fcs_enable, pad_enable, pad_enable_pko); + +/* Setup interface options */ +for (subif =0 ; subif < num_ports; subif++) { +/* Open interface/port DQs to allow transmission to begin */ + res =__cvmx_pko3_helper_dqs_activate (xiface, subif, + pad_enable_pko); + +if (res <0 ) + goto __cfg_error; + +/* ILK has only one MAC, subif == logical-channel */ +if (mode ==CVMX_HELPER_INTERFACE_MODE_ILK && subif >0 ) +continue ; + +/* LOOP has only one MAC, subif == logical-channel */ +if (mode ==CVMX_HELPER_INTERFACE_MODE_LOOP && subif >0 ) +continue ; + +/* NPI has only one MAC, subif == 'ring' */ +if (mode ==CVMX_HELPER_INTERFACE_MODE_NPI && subif >0 ) +continue ; + +/* for sRIO there is 16 byte sRIO header, outside of FCS */ +if (mode ==CVMX_HELPER_INTERFACE_MODE_SRIO ) + fcs_sof_off =16 ; + +if (iface >=CVMX_HELPER_MAX_GMX ) { +/* Non-BGX interface, use PKO for FCS/PAD */ + res =cvmx_pko3_interface_options (xiface, subif, + fcs_enable, + pad_enable_pko, + fcs_sof_off); + }else if (pad_enable == pad_enable_pko) { +/* BGX interface: FCS/PAD done by PKO */ + res =cvmx_pko3_interface_options (xiface, subif, + fcs_enable, + pad_enable, + fcs_sof_off); +cvmx_helper_bgx_tx_options (node, iface, subif, false, + false); + }else { +/* BGX interface: FCS/PAD done by BGX */ + res =cvmx_pko3_interface_options (xiface, subif, false, + false, fcs_sof_off); +cvmx_helper_bgx_tx_options (node, iface, subif, + fcs_enable, pad_enable); + } + +if (res <0 ) +debug ("WARNING: %s: option set failed on iface %u:%u/%u\n" , + __func__, node, iface, subif); +if (debug) +debug ("%s: face %u:%u/%u fifo size %d\n" , __func__, + node, iface, subif, +cvmx_pko3_port_fifo_size (xiface, subif)); + } +return 0 ; + +__cfg_error: +debug ("ERROR: %s: failed on iface %u:%u/%u\n" , __func__, node, iface, + subif); +return -1 ; +} + +/** +* Global initialization for PKO3 +* +* Should only be called once on each node +* +* TBD: Resolve the kernel case. +* When Linux eats up the entire memory, bootmem will be unable to +* satisfy our request, and the memory needs to come from Linux free pages. +*/ +int __cvmx_helper_pko3_init_global (unsigned int node,uint16_t gaura) +{ +int res; + + res =cvmx_pko3_hw_init_global (node, gaura); +if (res <0 ) { +debug ("ERROR: %s:failed block initialization\n" , __func__); +return res; + } + +/* configure channel level */ +cvmx_pko3_channel_credit_level (node, cvmx_pko_default_channel_level); + +/* add NULL MAC/DQ setup */ + res =__cvmx_pko3_config_null_interface (node); +if (res <0 ) +debug ("ERROR: %s: creating NULL interface\n" , __func__); + +return res; +} + +/** +* Global initialization for PKO3 +* +* Should only be called once on each node +* +* When Linux eats up the entire memory, bootmem will be unable to +* satisfy our request, and the memory needs to come from Linux free pages. +*/ +int cvmx_helper_pko3_init_global (unsigned int node) +{ +void *ptr; +int res =-1 ; +unsigned int aura_num = ~0 ; +cvmx_fpa3_gaura_t aura; + +/* Allocate memory required by PKO3 */ + res =__cvmx_pko3_config_memory (node); +if (res <0 ) { +debug ("ERROR: %s: PKO3 memory allocation error\n" , __func__); +return res; + } + + aura_num = res; + aura = __cvmx_pko3_aura[node]; + +/* Exercise the FPA to make sure the AURA is functional */ + ptr =cvmx_fpa3_alloc (aura); + +if (!ptr) { + res =-1 ; + }else { +cvmx_fpa3_free_nosync (ptr, aura,0 ); + res =0 ; + } + +if (res <0 ) { +debug ("ERROR: %s: FPA failure AURA=%u:%d\n" , __func__, + aura.node, aura.laura); +return -1 ; + } + + res =__cvmx_helper_pko3_init_global (node, aura_num); + +if (res <0 ) +debug ("ERROR: %s: failed to start PPKO\n" , __func__); + +return res; +} + +/** +* Uninitialize PKO3 interface +* +* Release all resources held by PKO for an interface. +* The shutdown code is the same for all supported interfaces. +* +* NOTE: The NULL virtual interface is identified by interface +* number -1, which translates into IPD port 0xfff, MAC#28. [Kludge] +*/ +int cvmx_helper_pko3_shut_interface (int xiface) +{ +int index, num_ports; +int dq_base, dq_count; +u16 ipd_port; +int i, res_owner, res; +enum cvmx_pko3_level_e level; +cvmx_pko3_dq_params_t *p_param; +const unsigned int timeout =10 ;/* milliseconds */ +cvmx_xiface_t xi =cvmx_helper_xiface_to_node_interface (xiface); + +if (__cvmx_helper_xiface_is_null (xiface)) { +/* Special case for NULL interface */ + num_ports =1 ; + }else { +cvmx_helper_interface_mode_t mode; + + mode =cvmx_helper_interface_get_mode (xiface); + num_ports =cvmx_helper_interface_enumerate (xiface); + (void )mode; + } + +/* Skip non-existent interfaces silently */ +if (num_ports <1 ) +return -1 ; + +if (debug) +debug ("%s: xiface %u:%d ports %d\n" , __func__, xi.node, + xi.interface, num_ports); + +for (index =0 ; index < num_ports; index++) { +if (__cvmx_helper_xiface_is_null (xiface)) + ipd_port =cvmx_helper_node_to_ipd_port ( + xi.node,CVMX_PKO3_IPD_PORT_NULL ); +else + ipd_port =cvmx_helper_get_ipd_port (xiface, index); + +/* Retrieve DQ range for the index */ + dq_base =cvmx_pko3_get_queue_base (ipd_port); + dq_count =cvmx_pko3_get_queue_num (ipd_port); + +if (dq_base <0 || dq_count <0 ) { +debug ("ERROR: %s: No DQs for iface %u:%d/%u\n" , + __func__, xi.node, xi.interface, index); +continue ; + } + +/* Get rid of node-number in DQ# */ + dq_base &= (1 <<10 ) -1 ; + +if (debug) +debug ("%s: xiface %u:%d/%d dq %u-%u\n" , __func__, + xi.node, xi.interface, index, dq_base, + dq_base + dq_count -1 ); + +/* Unregister the DQs for the port, should stop traffic */ + res =__cvmx_pko3_ipd_dq_unregister (xiface, index); +if (res <0 ) { +debug ("ERROR: %s: failed to unregister DQs iface %u/%d/%u\n" , + __func__, xi.node, xi.interface, index); +continue ; + } + +/* Begin draining all queues */ +for (i =0 ; i < dq_count; i++) +cvmx_pko3_dq_drain (xi.node, dq_base + i); + +/* Wait for all queues to drain, and close them */ +for (i =0 ; i < dq_count; i++) { +/* Prepare timeout */ +u64 start =get_timer (0 ); + +/* Wait for queue to drain */ +do { + res =cvmx_pko3_dq_query (xi.node, dq_base + i); +if (get_timer (start) > timeout) +break ; + }while (res >0 ); + +if (res !=0 ) +debug ("ERROR: %s: querying queue %u\n" , + __func__, dq_base + i); + +/* Close the queue, free internal buffers */ + res =cvmx_pko3_dq_close (xi.node, dq_base + i); + +if (res <0 ) +debug ("ERROR: %s: closing queue %u\n" , __func__, + dq_base + i); + +/* Return DQ packet budget */ + p_param =cvmx_pko3_dq_parameters (xi.node, dq_base + i); + __pko_pkt_budget += p_param->limit; + p_param->limit =0 ; + } + +/* Release all global resources owned by this interface/port */ + + res_owner =__cvmx_helper_pko3_res_owner (ipd_port); +if (res_owner <0 ) { +debug ("ERROR: %s: no resource owner ticket\n" , + __func__); +continue ; + } + +/* Actuall PQ/SQ/DQ associations left intact */ +for (level =CVMX_PKO_PORT_QUEUES ; + level !=CVMX_PKO_LEVEL_INVAL ; + level =__cvmx_pko3_sq_lvl_next (level)) { +cvmx_pko_free_queues (xi.node, level, res_owner); + } + + }/* for port */ + +return 0 ; +} + +/** +* Shutdown PKO3 +* +* Should be called after all interfaces have been shut down on the PKO3. +* +* Disables the PKO, frees all its buffers. +*/ +int cvmx_helper_pko3_shutdown (unsigned int node) +{ +unsigned int dq; +int res; + +/* destroy NULL interface here, only PKO knows about it */ +cvmx_helper_pko3_shut_interface ( +cvmx_helper_node_interface_to_xiface (node, __CVMX_XIFACE_NULL)); + +#ifdef __PKO_DQ_CLOSE_ERRATA_FIXED +/* Check that all DQs are closed */ +/* this seems to cause issue on HW: +* the error code differs from expected +*/ +for (dq =0 ; dq < (1 <<10 ); dq++) { + res =cvmx_pko3_dq_close (node, dq); +if (res !=0 ) { +debug ("ERROR: %s: PKO3 descriptor queue %u could not be closed\n" , + __func__, dq); +return -1 ; + } + } +#endif + (void )dq; + res =cvmx_pko3_hw_disable (node); + +/* shut down AURA/POOL we created, and free its resources */ +cvmx_fpa3_shutdown_aura_and_pool (__cvmx_pko3_aura[node]); +return res; +}
Signature · 1 line
2.35.1
PATCH 28/52 mips: octeon: Add cvmx-fpa-resource.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-fpa-resource.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-fpa-resource.c | 305 ++++++++++++++++++++++ 1 file changed, 305 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-fpa-resource.c
arch/mips/mach-octeon/cvmx-fpa-resource.c new file +305 -0
@@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +*/ + +#include <errno.h> +#include <log.h> +#include <time.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/cvmx-fuse.h> +#include <mach/octeon-feature.h> +#include <mach/cvmx-qlm.h> +#include <mach/octeon_qlm.h> +#include <mach/cvmx-pcie.h> +#include <mach/cvmx-coremask.h> +#include <mach/cvmx-range.h> +#include <mach/cvmx-global-resources.h> + +#include <mach/cvmx-agl-defs.h> +#include <mach/cvmx-bgxx-defs.h> +#include <mach/cvmx-ciu-defs.h> +#include <mach/cvmx-gmxx-defs.h> +#include <mach/cvmx-gserx-defs.h> +#include <mach/cvmx-ilk-defs.h> +#include <mach/cvmx-ipd-defs.h> +#include <mach/cvmx-pcsx-defs.h> +#include <mach/cvmx-pcsxx-defs.h> +#include <mach/cvmx-pki-defs.h> +#include <mach/cvmx-pko-defs.h> +#include <mach/cvmx-xcv-defs.h> + +#include <mach/cvmx-hwpko.h> +#include <mach/cvmx-ilk.h> +#include <mach/cvmx-ipd.h> +#include <mach/cvmx-pki.h> +#include <mach/cvmx-pko3.h> +#include <mach/cvmx-pko3-queue.h> +#include <mach/cvmx-pko3-resources.h> + +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> + +#include <mach/cvmx-helper-bgx.h> +#include <mach/cvmx-helper-cfg.h> +#include <mach/cvmx-helper-util.h> +#include <mach/cvmx-helper-pki.h> + +static struct global_resource_tag get_fpa1_resource_tag (void ) +{ +return CVMX_GR_TAG_FPA ; +} + +static struct global_resource_tag get_fpa3_aura_resource_tag (int node) +{ +return cvmx_get_gr_tag ('c' ,'v' ,'m' ,'_' ,'a' ,'u' ,'r' ,'a' ,'_' , + node +'0' ,'.' ,'.' ,'.' ,'.' ,'.' ,'.' ); +} + +static struct global_resource_tag get_fpa3_pool_resource_tag (int node) +{ +return cvmx_get_gr_tag ('c' ,'v' ,'m' ,'_' ,'p' ,'o' ,'o' ,'l' ,'_' , + node +'0' ,'.' ,'.' ,'.' ,'.' ,'.' ,'.' ); +} + +int cvmx_fpa_get_max_pools (void ) +{ +if (octeon_has_feature (OCTEON_FEATURE_FPA3 )) +return cvmx_fpa3_num_auras (); +else if (OCTEON_IS_MODEL (OCTEON_CN68XX )) +/* 68xx pool 8 is not available via API */ +return CVMX_FPA1_NUM_POOLS ; +else +return CVMX_FPA1_NUM_POOLS ; +} + +u64 cvmx_fpa3_get_aura_owner (cvmx_fpa3_gaura_t aura) +{ +return cvmx_get_global_resource_owner ( +get_fpa3_aura_resource_tag (aura.node), aura.laura); +} + +u64 cvmx_fpa1_get_pool_owner (cvmx_fpa1_pool_t pool) +{ +return cvmx_get_global_resource_owner (get_fpa1_resource_tag (), pool); +} + +u64 cvmx_fpa_get_pool_owner (int pool_num) +{ +if (octeon_has_feature (OCTEON_FEATURE_FPA3 )) +return cvmx_fpa3_get_aura_owner ( +cvmx_fpa1_pool_to_fpa3_aura (pool_num)); +else +return cvmx_fpa1_get_pool_owner (pool_num); +} + +/** +*/ +cvmx_fpa3_gaura_t cvmx_fpa3_reserve_aura (int node,int desired_aura_num) +{ +u64 owner =cvmx_get_app_id (); +int rv =0 ; +struct global_resource_tag tag; +cvmx_fpa3_gaura_t aura; + +if (node ==-1 ) + node =cvmx_get_node_num (); + + tag =get_fpa3_aura_resource_tag (node); + +if (cvmx_create_global_resource_range (tag,cvmx_fpa3_num_auras ()) != +0 ) { +printf ("ERROR: %s: global resource create node=%u\n" , __func__, + node); +return CVMX_FPA3_INVALID_GAURA ; + } + +if (desired_aura_num >=0 ) + rv =cvmx_reserve_global_resource_range (tag, owner, + desired_aura_num,1 ); +else + rv =cvmx_resource_alloc_reverse (tag, owner); + +if (rv <0 ) { +printf ("ERROR: %s: node=%u desired aura=%d\n" , __func__, node, + desired_aura_num); +return CVMX_FPA3_INVALID_GAURA ; + } + + aura =__cvmx_fpa3_gaura (node, rv); + +return aura; +} + +int cvmx_fpa3_release_aura (cvmx_fpa3_gaura_t aura) +{ +struct global_resource_tag tag =get_fpa3_aura_resource_tag (aura.node); +int laura = aura.laura; + +if (!__cvmx_fpa3_aura_valid (aura)) +return -1 ; + +return cvmx_free_global_resource_range_multiple (tag, &laura,1 ); +} + +/** +*/ +cvmx_fpa3_pool_t cvmx_fpa3_reserve_pool (int node,int desired_pool_num) +{ +u64 owner =cvmx_get_app_id (); +int rv =0 ; +struct global_resource_tag tag; +cvmx_fpa3_pool_t pool; + +if (node ==-1 ) + node =cvmx_get_node_num (); + + tag =get_fpa3_pool_resource_tag (node); + +if (cvmx_create_global_resource_range (tag,cvmx_fpa3_num_pools ()) != +0 ) { +printf ("ERROR: %s: global resource create node=%u\n" , __func__, + node); +return CVMX_FPA3_INVALID_POOL ; + } + +if (desired_pool_num >=0 ) + rv =cvmx_reserve_global_resource_range (tag, owner, + desired_pool_num,1 ); +else + rv =cvmx_resource_alloc_reverse (tag, owner); + +if (rv <0 ) { +/* Desired pool is already in use */ +return CVMX_FPA3_INVALID_POOL ; + } + + pool =__cvmx_fpa3_pool (node, rv); + +return pool; +} + +int cvmx_fpa3_release_pool (cvmx_fpa3_pool_t pool) +{ +struct global_resource_tag tag =get_fpa3_pool_resource_tag (pool.node); +int lpool = pool.lpool; + +if (!__cvmx_fpa3_pool_valid (pool)) +return -1 ; + +if (cvmx_create_global_resource_range (tag,cvmx_fpa3_num_pools ()) != +0 ) { +printf ("ERROR: %s: global resource create node=%u\n" , __func__, + pool.node); +return -1 ; + } + +return cvmx_free_global_resource_range_multiple (tag, &lpool,1 ); +} + +cvmx_fpa1_pool_t cvmx_fpa1_reserve_pool (int desired_pool_num) +{ +u64 owner =cvmx_get_app_id (); +struct global_resource_tag tag; +int rv; + + tag =get_fpa1_resource_tag (); + +if (cvmx_create_global_resource_range (tag,CVMX_FPA1_NUM_POOLS ) !=0 ) { +printf ("ERROR: %s: global resource not created\n" , __func__); +return -1 ; + } + +if (desired_pool_num >=0 ) { + rv =cvmx_reserve_global_resource_range (tag, owner, + desired_pool_num,1 ); + }else { + rv =cvmx_resource_alloc_reverse (tag, owner); + } + +if (rv <0 ) { +printf ("ERROR: %s: FPA_POOL %d unavailable\n" , __func__, + desired_pool_num); +return CVMX_RESOURCE_ALREADY_RESERVED ; + } +return (cvmx_fpa1_pool_t )rv; +} + +int cvmx_fpa1_release_pool (cvmx_fpa1_pool_t pool) +{ +struct global_resource_tag tag; + + tag =get_fpa1_resource_tag (); + +return cvmx_free_global_resource_range_multiple (tag, &pool,1 ); +} + +/** +* Query if an FPA pool is available for reservation +* using global resources +* @note This function is no longer in use, and will be removed in a future release +*/ +int cvmx_fpa1_is_pool_available (cvmx_fpa1_pool_t pool) +{ +if (cvmx_fpa1_reserve_pool (pool) ==-1 ) +return 0 ; +cvmx_fpa1_release_pool (pool); +return 1 ; +} + +/** +* @INTERNAL +* +* This function is no longer in use, and will be removed in a future release +*/ +int cvmx_fpa3_is_pool_available (int node,int lpool) +{ +cvmx_fpa3_pool_t pool; + + pool =cvmx_fpa3_reserve_pool (node, lpool); + +if (!__cvmx_fpa3_pool_valid (pool)) +return 0 ; + +cvmx_fpa3_release_pool (pool); +return 1 ; +} + +/** +* @INTERNAL +* +* This function is no longer in use, and will be removed in a future release +*/ +int cvmx_fpa3_is_aura_available (int node,int laura) +{ +cvmx_fpa3_gaura_t aura; + + aura =cvmx_fpa3_reserve_aura (node, laura); + +if (!__cvmx_fpa3_aura_valid (aura)) +return 0 ; + +cvmx_fpa3_release_aura (aura); +return 1 ; +} + +/** +* Return if aura/pool is already reserved +* @param pool_num - pool to check (aura for o78+) +* @return 0 if reserved, 1 if available +* +* @note This function is no longer in use, and will be removed in a future release +*/ +int cvmx_fpa_is_pool_available (int pool_num) +{ +if (octeon_has_feature (OCTEON_FEATURE_FPA3 )) +return cvmx_fpa3_is_aura_available (0 , pool_num); +else +return cvmx_fpa1_is_pool_available (pool_num); +}
Signature · 1 line
2.35.1
PATCH 46/52 mips: octeon: octeon_common.h: Move init SP because of increased image size
In reply to Stefan RoeseThis patch moves CONFIG_SYS_INIT_SP_OFFSET to a higher address so that it does not interfere with larger U-Boot images. This was noticed, while adding network support to the EBB7304 board.
--- include/configs/octeon_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/configs/octeon_common.h +1 -1
@@ -8,7 +8,7 @@#define __OCTEON_COMMON_H__#if defined(CONFIG_RAM_OCTEON ) -#define CONFIG_SYS_INIT_SP_OFFSET 0x20100000 +#define CONFIG_SYS_INIT_SP_OFFSET 0x20180000#else /* No DDR init -> run in L2 cache with limited resources */ #define CONFIG_SYS_INIT_SP_OFFSET 0x00180000
Signature · 1 line
2.35.1
PATCH 45/52 mips: octeon: cpu.c: Implement configure_lmtdma_window()
In reply to Stefan RoeseImport configure_lmtdma_window from Marvell 2013 U-Boot as it's needed for network functionality.
--- arch/mips/mach-octeon/cpu.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
arch/mips/mach-octeon/cpu.c +33 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0+ /* -* Copyright (C) 2020 Marvell International Ltd. +* Copyright (C) 2020-2022 Marvell International Ltd. */ #include <dm.h>
@@ -17,6 +17,8 @@#include <mach/cvmx-bootmem.h> #include <mach/cvmx-regs.h> #include <mach/cvmx-sata-defs.h> +#include <mach/octeon-model.h> +#include <mach/octeon-feature.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -393,6 +395,33 @@ static int init_bootcmd_console(void)return ret; } +static void configure_lmtdma_window (void ) +{ +u64 tmp; +u64 addr; +u64 end_addr; + +CVMX_MF_CVM_MEM_CTL (tmp); + tmp &= ~0x1ffull ; + tmp |=0x104ull ; + +/* enable LMTDMA */ + tmp |= (1ull <<51 ); +/* configure scratch line 2 for LMT */ +/* TODO: reserve this scratch line, so that others will not use it */ +/* TODO: store LMTLINE in global var */ + tmp |= (CVMX_PKO_LMTLINE <<45 ); +/* clear LMTLINE in scratch */ + addr =CVMX_PKO_LMTLINE *CVMX_CACHE_LINE_SIZE ; + end_addr = addr +CVMX_CACHE_LINE_SIZE ; + +while (addr < end_addr) { + *CASTPTR(volatile u64, addr + CVMX_SCRATCH_BASE) = (u64)0; + addr +=8 ; + } +CVMX_MT_CVM_MEM_CTL (tmp); +} +int arch_early_init_r (void ) {int ret;
@@ -405,6 +434,9 @@ int arch_early_init_r(void)if (ret)return ret; +if (octeon_has_feature (OCTEON_FEATURE_PKO3 )) +configure_lmtdma_window (); +return 0 ; }
Signature · 1 line
2.35.1
PATCH 21/52 mips: octeon: Add cvmx-helper-sgmii.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-helper-sgmii.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-helper-sgmii.c | 781 ++++++++++++++++++++++ 1 file changed, 781 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-helper-sgmii.c
arch/mips/mach-octeon/cvmx-helper-sgmii.c new file +781 -0
@@ -0,0 +1,781 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Functions for SGMII initialization, configuration, +* and monitoring. +*/ + +#include <time.h> +#include <log.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/cvmx-fuse.h> +#include <mach/octeon-feature.h> +#include <mach/cvmx-qlm.h> +#include <mach/octeon_qlm.h> +#include <mach/cvmx-pcie.h> +#include <mach/cvmx-coremask.h> + +#include <mach/cvmx-agl-defs.h> +#include <mach/cvmx-bgxx-defs.h> +#include <mach/cvmx-ciu-defs.h> +#include <mach/cvmx-gmxx-defs.h> +#include <mach/cvmx-ipd-defs.h> +#include <mach/cvmx-pcsx-defs.h> +#include <mach/cvmx-pki-defs.h> +#include <mach/cvmx-xcv-defs.h> + +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> + +/** +* @INTERNAL +* Perform initialization required only once for an SGMII port. +* +* @param interface to init +* @param index Index of prot on the interface +* +* @return Zero on success, negative on failure +*/ +static int __cvmx_helper_sgmii_hardware_init_one_time (int interface,int index) +{ +const u64 clock_mhz =1200 ;/* todo: fixme */ +union cvmx_pcsx_miscx_ctl_reg pcsx_miscx_ctl_reg; +union cvmx_pcsx_linkx_timer_count_reg pcsx_linkx_timer_count_reg; +union cvmx_gmxx_prtx_cfg gmxx_prtx_cfg; + +if (!cvmx_helper_is_port_valid (interface, index)) +return 0 ; + +/* Disable GMX */ + gmxx_prtx_cfg.u64 =csr_rd (CVMX_GMXX_PRTX_CFG (index, interface)); + gmxx_prtx_cfg.s.en =0 ; +csr_wr (CVMX_GMXX_PRTX_CFG (index, interface), gmxx_prtx_cfg.u64); + +/* +* Write PCS*_LINK*_TIMER_COUNT_REG[COUNT] with the +* appropriate value. 1000BASE-X specifies a 10ms +* interval. SGMII specifies a 1.6ms interval. +*/ + pcsx_miscx_ctl_reg.u64 = +csr_rd (CVMX_PCSX_MISCX_CTL_REG (index, interface)); +/* Adjust the MAC mode if requested by device tree */ + pcsx_miscx_ctl_reg.s.mac_phy = +cvmx_helper_get_mac_phy_mode (interface, index); + pcsx_miscx_ctl_reg.s.mode = +cvmx_helper_get_1000x_mode (interface, index); +csr_wr (CVMX_PCSX_MISCX_CTL_REG (index, interface), + pcsx_miscx_ctl_reg.u64); + + pcsx_linkx_timer_count_reg.u64 = +csr_rd (CVMX_PCSX_LINKX_TIMER_COUNT_REG (index, interface)); +if (pcsx_miscx_ctl_reg.s.mode) +/* 1000BASE-X */ + pcsx_linkx_timer_count_reg.s.count = + (10000ull * clock_mhz) >>10 ; +else +/* SGMII */ + pcsx_linkx_timer_count_reg.s.count = + (1600ull * clock_mhz) >>10 ; + +csr_wr (CVMX_PCSX_LINKX_TIMER_COUNT_REG (index, interface), + pcsx_linkx_timer_count_reg.u64); + +/* +* Write the advertisement register to be used as the +* tx_Config_Reg<D15:D0> of the autonegotiation. In +* 1000BASE-X mode, tx_Config_Reg<D15:D0> is PCS*_AN*_ADV_REG. +* In SGMII PHY mode, tx_Config_Reg<D15:D0> is +* PCS*_SGM*_AN_ADV_REG. In SGMII MAC mode, +* tx_Config_Reg<D15:D0> is the fixed value 0x4001, so this +* step can be skipped. +*/ +if (pcsx_miscx_ctl_reg.s.mode) { +/* 1000BASE-X */ +union cvmx_pcsx_anx_adv_reg pcsx_anx_adv_reg; + + pcsx_anx_adv_reg.u64 = +csr_rd (CVMX_PCSX_ANX_ADV_REG (index, interface)); + pcsx_anx_adv_reg.s.rem_flt =0 ; + pcsx_anx_adv_reg.s.pause =3 ; + pcsx_anx_adv_reg.s.hfd =1 ; + pcsx_anx_adv_reg.s.fd =1 ; +csr_wr (CVMX_PCSX_ANX_ADV_REG (index, interface), + pcsx_anx_adv_reg.u64); + }else { +if (pcsx_miscx_ctl_reg.s.mac_phy) { +/* PHY Mode */ +union cvmx_pcsx_sgmx_an_adv_reg pcsx_sgmx_an_adv_reg; + + pcsx_sgmx_an_adv_reg.u64 =csr_rd ( +CVMX_PCSX_SGMX_AN_ADV_REG (index, interface)); + pcsx_sgmx_an_adv_reg.s.dup =1 ; + pcsx_sgmx_an_adv_reg.s.speed =2 ; +csr_wr (CVMX_PCSX_SGMX_AN_ADV_REG (index, interface), + pcsx_sgmx_an_adv_reg.u64); + }else { +/* MAC Mode - Nothing to do */ + } + } +return 0 ; +} + +static int __cvmx_helper_need_g15618 (void ) +{ +if (OCTEON_IS_MODEL (OCTEON_CN63XX ) || +OCTEON_IS_MODEL (OCTEON_CN66XX_PASS1_X ) || +OCTEON_IS_MODEL (OCTEON_CN68XX )) +return 1 ; +else +return 0 ; +} + +/** +* @INTERNAL +* Initialize the SERTES link for the first time or after a loss +* of link. +* +* @param interface to init +* @param index Index of prot on the interface +* +* @return Zero on success, negative on failure +*/ +static int __cvmx_helper_sgmii_hardware_init_link (int interface,int index) +{ +union cvmx_pcsx_mrx_control_reg control_reg; +union cvmx_pcsx_miscx_ctl_reg pcsx_miscx_ctl_reg; +bool phy_mode; +bool an_disable;/** Disable autonegotiation */ +bool mode_1000x;/** 1000Base-X mode */ + +if (!cvmx_helper_is_port_valid (interface, index)) +return 0 ; + +/* +* Take PCS through a reset sequence. +* PCS*_MR*_CONTROL_REG[PWR_DN] should be cleared to zero. +* Write PCS*_MR*_CONTROL_REG[RESET]=1 (while not changing the +* value of the other PCS*_MR*_CONTROL_REG bits). Read +* PCS*_MR*_CONTROL_REG[RESET] until it changes value to +* zero. +*/ + control_reg.u64 =csr_rd (CVMX_PCSX_MRX_CONTROL_REG (index, interface)); + +/* +* Errata G-15618 requires disabling PCS soft reset in CN63XX +* pass upto 2.1. +*/ +if (!__cvmx_helper_need_g15618 ()) { + control_reg.s.reset =1 ; +csr_wr (CVMX_PCSX_MRX_CONTROL_REG (index, interface), + control_reg.u64); +if (CVMX_WAIT_FOR_FIELD64 ( +CVMX_PCSX_MRX_CONTROL_REG (index, interface), + cvmx_pcsx_mrx_control_reg_t, reset, ==, 0, 10000)) { +debug ("SGMII%x: Timeout waiting for port %d to finish reset\n" , + interface, index); +return -1 ; + } + } + +/* +* Write PCS*_MR*_CONTROL_REG[RST_AN]=1 to ensure a fresh +* sgmii negotiation starts. +*/ + phy_mode =cvmx_helper_get_mac_phy_mode (interface, index); + an_disable = (phy_mode || + !cvmx_helper_get_port_autonegotiation (interface, index)); + + control_reg.s.an_en = !an_disable; + +/* Force a PCS reset by powering down the PCS interface +* This is needed to deal with broken Qualcomm/Atheros PHYs and switches +* which never recover if PCS is not power cycled. The alternative +* is to power cycle or hardware reset the Qualcomm devices whenever +* SGMII is initialized. +* +* This is needed for the QCA8033 PHYs as well as the QCA833X switches +* to work. The QCA8337 switch has additional SGMII problems and is +* best avoided if at all possible. Failure to power cycle PCS prevents +* any traffic from flowing between Octeon and Qualcomm devices if there +* is a warm reset. Even a software reset to the Qualcomm device will +* not work. +* +* Note that this problem has been reported between Qualcomm and other +* vendor's processors as well so this problem is not unique to +* Qualcomm and Octeon. +* +* Power cycling PCS doesn't hurt anything with non-Qualcomm devices +* other than adding a 25ms delay during initialization. +*/ + control_reg.s.pwr_dn =1 ; +csr_wr (CVMX_PCSX_MRX_CONTROL_REG (index, interface), control_reg.u64); +csr_rd (CVMX_PCSX_MRX_CONTROL_REG (index, interface)); + +/* 25ms should be enough, 10ms is too short */ +mdelay (25 ); + + control_reg.s.pwr_dn =0 ; +csr_wr (CVMX_PCSX_MRX_CONTROL_REG (index, interface), control_reg.u64); + +/* The Cortina PHY runs in 1000base-X mode */ + mode_1000x =cvmx_helper_get_1000x_mode (interface, index); + pcsx_miscx_ctl_reg.u64 = +csr_rd (CVMX_PCSX_MISCX_CTL_REG (index, interface)); + pcsx_miscx_ctl_reg.s.mode = mode_1000x; + pcsx_miscx_ctl_reg.s.mac_phy = phy_mode; +csr_wr (CVMX_PCSX_MISCX_CTL_REG (index, interface), + pcsx_miscx_ctl_reg.u64); +if (an_disable) +/* In PHY mode we can't query the link status so we just +* assume that the link is up. +*/ +return 0 ; + +/* +* Wait for PCS*_MR*_STATUS_REG[AN_CPT] to be set, indicating +* that sgmii autonegotiation is complete. In MAC mode this +* isn't an ethernet link, but a link between Octeon and the +* PHY. +*/ +if (CVMX_WAIT_FOR_FIELD64 (CVMX_PCSX_MRX_STATUS_REG (index, interface), + union cvmx_pcsx_mrx_status_reg, an_cpt, ==, 1, +10000 )) { +debug ("SGMII%x: Port %d link timeout\n" , interface, index); +return -1 ; + } +return 0 ; +} + +/** +* @INTERNAL +* Configure an SGMII link to the specified speed after the SERTES +* link is up. +* +* @param interface to init +* @param index Index of prot on the interface +* @param link_info Link state to configure +* +* @return Zero on success, negative on failure +*/ +static int +__cvmx_helper_sgmii_hardware_init_link_speed (int interface,int index, +cvmx_helper_link_info_t link_info) +{ +int is_enabled; +union cvmx_gmxx_prtx_cfg gmxx_prtx_cfg; +union cvmx_pcsx_miscx_ctl_reg pcsx_miscx_ctl_reg; + +if (!cvmx_helper_is_port_valid (interface, index)) +return 0 ; + +/* Disable GMX before we make any changes. Remember the enable state */ + gmxx_prtx_cfg.u64 =csr_rd (CVMX_GMXX_PRTX_CFG (index, interface)); + is_enabled = gmxx_prtx_cfg.s.en; + gmxx_prtx_cfg.s.en =0 ; +csr_wr (CVMX_GMXX_PRTX_CFG (index, interface), gmxx_prtx_cfg.u64); + +/* Wait for GMX to be idle */ +if (CVMX_WAIT_FOR_FIELD64 (CVMX_GMXX_PRTX_CFG (index, interface), + cvmx_gmxx_prtx_cfg_t, rx_idle, ==, 1, +10000 ) || +CVMX_WAIT_FOR_FIELD64 (CVMX_GMXX_PRTX_CFG (index, interface), + cvmx_gmxx_prtx_cfg_t, tx_idle, ==, 1, +10000 )) { +debug ("SGMII%d: Timeout waiting for port %d to be idle\n" , + interface, index); +return -1 ; + } + +/* Read GMX CFG again to make sure the disable completed */ + gmxx_prtx_cfg.u64 =csr_rd (CVMX_GMXX_PRTX_CFG (index, interface)); + +/* +* Get the misc control for PCS. We will need to set the +* duplication amount. +*/ + pcsx_miscx_ctl_reg.u64 = +csr_rd (CVMX_PCSX_MISCX_CTL_REG (index, interface)); + +/* +* Use GMXENO to force the link down if the status we get says +* it should be down. +*/ + pcsx_miscx_ctl_reg.s.gmxeno = !link_info.s.link_up; + +/* Only change the duplex setting if the link is up */ +if (link_info.s.link_up) + gmxx_prtx_cfg.s.duplex = link_info.s.full_duplex; + +/* Do speed based setting for GMX */ +switch (link_info.s.speed) { +case 10 : + gmxx_prtx_cfg.s.speed =0 ; + gmxx_prtx_cfg.s.speed_msb =1 ; + gmxx_prtx_cfg.s.slottime =0 ; +/* Setting from GMX-603 */ + pcsx_miscx_ctl_reg.s.samp_pt =25 ; +csr_wr (CVMX_GMXX_TXX_SLOT (index, interface),64 ); +csr_wr (CVMX_GMXX_TXX_BURST (index, interface),0 ); +break ; +case 100 : + gmxx_prtx_cfg.s.speed =0 ; + gmxx_prtx_cfg.s.speed_msb =0 ; + gmxx_prtx_cfg.s.slottime =0 ; + pcsx_miscx_ctl_reg.s.samp_pt =0x5 ; +csr_wr (CVMX_GMXX_TXX_SLOT (index, interface),64 ); +csr_wr (CVMX_GMXX_TXX_BURST (index, interface),0 ); +break ; +case 1000 : + gmxx_prtx_cfg.s.speed =1 ; + gmxx_prtx_cfg.s.speed_msb =0 ; + gmxx_prtx_cfg.s.slottime =1 ; + pcsx_miscx_ctl_reg.s.samp_pt =1 ; +csr_wr (CVMX_GMXX_TXX_SLOT (index, interface),512 ); +if (gmxx_prtx_cfg.s.duplex) +/* full duplex */ +csr_wr (CVMX_GMXX_TXX_BURST (index, interface),0 ); +else +/* half duplex */ +csr_wr (CVMX_GMXX_TXX_BURST (index, interface),8192 ); +break ; +default : +break ; + } + +/* Write the new misc control for PCS */ +csr_wr (CVMX_PCSX_MISCX_CTL_REG (index, interface), + pcsx_miscx_ctl_reg.u64); + +/* Write the new GMX settings with the port still disabled */ +csr_wr (CVMX_GMXX_PRTX_CFG (index, interface), gmxx_prtx_cfg.u64); + +/* Read GMX CFG again to make sure the config completed */ + gmxx_prtx_cfg.u64 =csr_rd (CVMX_GMXX_PRTX_CFG (index, interface)); + +/* Restore the enabled / disabled state */ + gmxx_prtx_cfg.s.en = is_enabled; +csr_wr (CVMX_GMXX_PRTX_CFG (index, interface), gmxx_prtx_cfg.u64); + +return 0 ; +} + +/** +* @INTERNAL +* Bring up the SGMII interface to be ready for packet I/O but +* leave I/O disabled using the GMX override. This function +* follows the bringup documented in 10.6.3 of the manual. +* +* @param interface to bringup +* @param num_ports Number of ports on the interface +* +* @return Zero on success, negative on failure +*/ +static int __cvmx_helper_sgmii_hardware_init (int interface,int num_ports) +{ +int index; +int do_link_set =1 ; + +/* +* CN63XX Pass 1.0 errata G-14395 requires the QLM De-emphasis +* be programmed. +*/ +if (OCTEON_IS_MODEL (OCTEON_CN63XX_PASS1_0 )) { +union cvmx_ciu_qlm2 ciu_qlm; + + ciu_qlm.u64 =csr_rd (CVMX_CIU_QLM2 ); + ciu_qlm.s.txbypass =1 ; + ciu_qlm.s.txdeemph =0xf ; + ciu_qlm.s.txmargin =0xd ; +csr_wr (CVMX_CIU_QLM2 , ciu_qlm.u64); + } + +/* +* CN63XX Pass 2.x errata G-15273 requires the QLM De-emphasis +* be programmed when using a 156.25Mhz ref clock. +*/ +if (OCTEON_IS_MODEL (OCTEON_CN63XX_PASS2_X )) { +/* Read the QLM speed pins */ +union cvmx_mio_rst_boot mio_rst_boot; + + mio_rst_boot.u64 =csr_rd (CVMX_MIO_RST_BOOT ); + +if (mio_rst_boot.cn63xx.qlm2_spd ==4 ) { +union cvmx_ciu_qlm2 ciu_qlm; + + ciu_qlm.u64 =csr_rd (CVMX_CIU_QLM2 ); + ciu_qlm.s.txbypass =1 ; + ciu_qlm.s.txdeemph =0x0 ; + ciu_qlm.s.txmargin =0xf ; +csr_wr (CVMX_CIU_QLM2 , ciu_qlm.u64); + } + } + +__cvmx_helper_setup_gmx (interface, num_ports); + +for (index =0 ; index < num_ports; index++) { +int ipd_port =cvmx_helper_get_ipd_port (interface, index); + +if (!cvmx_helper_is_port_valid (interface, index)) +continue ; +__cvmx_helper_sgmii_hardware_init_one_time (interface, index); +if (do_link_set) +__cvmx_helper_sgmii_link_set (ipd_port, +__cvmx_helper_sgmii_link_get (ipd_port)); + } + +return 0 ; +} + +int __cvmx_helper_sgmii_enumerate (int xiface) +{ +if (OCTEON_IS_MODEL (OCTEON_CNF71XX )) +return 2 ; +if (OCTEON_IS_MODEL (OCTEON_CN70XX )) { +struct cvmx_xiface xi = +cvmx_helper_xiface_to_node_interface (xiface); +enum cvmx_qlm_mode qlm_mode = +cvmx_qlm_get_dlm_mode (0 , xi.interface); + +if (qlm_mode ==CVMX_QLM_MODE_SGMII ) +return 1 ; +else if (qlm_mode ==CVMX_QLM_MODE_QSGMII ) +return 4 ; +return 0 ; + } +return 4 ; +} + +/** +* @INTERNAL +* Probe a SGMII interface and determine the number of ports +* connected to it. The SGMII interface should still be down after +* this call. +* +* @param xiface Interface to probe +* +* @return Number of ports on the interface. Zero to disable. +*/ +int __cvmx_helper_sgmii_probe (int xiface) +{ +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); +int interface = xi.interface; +union cvmx_gmxx_inf_mode mode; +int ports; + +/* +* Check if QLM is configured correct for SGMII, verify the +* speed as well as mode. +*/ +if (OCTEON_IS_OCTEON2 ()) { +int qlm =cvmx_qlm_interface (xiface); + +if (cvmx_qlm_get_mode (qlm) !=CVMX_QLM_MODE_SGMII ) +return 0 ; + } + +/* Do not enable the interface if is not in SGMII mode */ + ports =__cvmx_helper_sgmii_enumerate (xiface); + +if (ports <=0 ) +return 0 ; + +/* +* Due to errata GMX-700 on CN56XXp1.x and CN52XXp1.x, the +* interface needs to be enabled before IPD otherwise per port +* backpressure may not work properly. +*/ + mode.u64 =csr_rd (CVMX_GMXX_INF_MODE (interface)); + mode.s.en =1 ; +csr_wr (CVMX_GMXX_INF_MODE (interface), mode.u64); + +return ports; +} + +/** +* @INTERNAL +* Bringup and enable a SGMII interface. After this call packet +* I/O should be fully functional. This is called with IPD +* enabled but PKO disabled. +* +* @param xiface Interface to bring up +* +* @return Zero on success, negative on failure +*/ +int __cvmx_helper_sgmii_enable (int xiface) +{ +int num_ports =cvmx_helper_ports_on_interface (xiface); +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); +int interface = xi.interface; +int index; + +/* Setup PKND and BPID */ +if (octeon_has_feature (OCTEON_FEATURE_PKND )) { +for (index =0 ; index < num_ports; index++) { +union cvmx_gmxx_bpid_msk bpid_msk; +union cvmx_gmxx_bpid_mapx bpid_map; +union cvmx_gmxx_prtx_cfg gmxx_prtx_cfg; + +if (!cvmx_helper_is_port_valid (interface, index)) +continue ; +/* Setup PKIND */ + gmxx_prtx_cfg.u64 = +csr_rd (CVMX_GMXX_PRTX_CFG (index, interface)); + gmxx_prtx_cfg.s.pknd = +cvmx_helper_get_pknd (interface, index); +csr_wr (CVMX_GMXX_PRTX_CFG (index, interface), + gmxx_prtx_cfg.u64); + +/* Setup BPID */ + bpid_map.u64 = +csr_rd (CVMX_GMXX_BPID_MAPX (index, interface)); + bpid_map.s.val =1 ; + bpid_map.s.bpid = +cvmx_helper_get_bpid (interface, index); +csr_wr (CVMX_GMXX_BPID_MAPX (index, interface), + bpid_map.u64); + + bpid_msk.u64 =csr_rd (CVMX_GMXX_BPID_MSK (interface)); + bpid_msk.s.msk_or |= (1 << index); + bpid_msk.s.msk_and &= ~(1 << index); +csr_wr (CVMX_GMXX_BPID_MSK (interface), bpid_msk.u64); + } + } + +__cvmx_helper_sgmii_hardware_init (interface, num_ports); + +/* CN68XX adds the padding and FCS in PKO, not GMX */ +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) { +union cvmx_gmxx_txx_append gmxx_txx_append_cfg; + +for (index =0 ; index < num_ports; index++) { +if (!cvmx_helper_is_port_valid (interface, index)) +continue ; + gmxx_txx_append_cfg.u64 = +csr_rd (CVMX_GMXX_TXX_APPEND (index, interface)); + gmxx_txx_append_cfg.s.fcs =0 ; + gmxx_txx_append_cfg.s.pad =0 ; +csr_wr (CVMX_GMXX_TXX_APPEND (index, interface), + gmxx_txx_append_cfg.u64); + } + } + +/* Enable running disparity check for QSGMII interface */ +if (OCTEON_IS_MODEL (OCTEON_CN70XX ) && num_ports >1 ) { +union cvmx_gmxx_qsgmii_ctl qsgmii_ctl; + + qsgmii_ctl.u64 =0 ; + qsgmii_ctl.s.disparity =1 ; +csr_wr (CVMX_GMXX_QSGMII_CTL (interface), qsgmii_ctl.u64); + } + +for (index =0 ; index < num_ports; index++) { +union cvmx_gmxx_txx_append append_cfg; +union cvmx_gmxx_txx_sgmii_ctl sgmii_ctl; +union cvmx_gmxx_prtx_cfg gmxx_prtx_cfg; + +if (!cvmx_helper_is_port_valid (interface, index)) +continue ; +/* +* Clear the align bit if preamble is set to attain +* maximum tx rate. +*/ + append_cfg.u64 =csr_rd (CVMX_GMXX_TXX_APPEND (index, interface)); + sgmii_ctl.u64 = +csr_rd (CVMX_GMXX_TXX_SGMII_CTL (index, interface)); + sgmii_ctl.s.align = append_cfg.s.preamble ?0 :1 ; +csr_wr (CVMX_GMXX_TXX_SGMII_CTL (index, interface), + sgmii_ctl.u64); + + gmxx_prtx_cfg.u64 = +csr_rd (CVMX_GMXX_PRTX_CFG (index, interface)); + gmxx_prtx_cfg.s.en =1 ; +csr_wr (CVMX_GMXX_PRTX_CFG (index, interface), gmxx_prtx_cfg.u64); + } +return 0 ; +} + +/** +* @INTERNAL +* Return the link state of an IPD/PKO port as returned by +* auto negotiation. The result of this function may not match +* Octeon's link config if auto negotiation has changed since +* the last call to cvmx_helper_link_set(). +* +* @param ipd_port IPD/PKO port to query +* +* @return Link state +*/ +cvmx_helper_link_info_t __cvmx_helper_sgmii_link_get (int ipd_port) +{ +cvmx_helper_link_info_t result; +union cvmx_pcsx_miscx_ctl_reg pcsx_miscx_ctl_reg; +int interface =cvmx_helper_get_interface_num (ipd_port); +int index =cvmx_helper_get_interface_index_num (ipd_port); +union cvmx_pcsx_mrx_control_reg pcsx_mrx_control_reg; +int speed =1000 ; +int qlm; + + result.u64 =0 ; + +if (!cvmx_helper_is_port_valid (interface, index)) +return result; + +if (OCTEON_IS_MODEL (OCTEON_CN66XX )) { +union cvmx_gmxx_inf_mode inf_mode; + + inf_mode.u64 =csr_rd (CVMX_GMXX_INF_MODE (interface)); +if (inf_mode.s.rate & (1 << index)) + speed =2500 ; +else + speed =1000 ; + }else if (OCTEON_IS_MODEL (OCTEON_CN6XXX )) { + qlm =cvmx_qlm_interface (interface); + speed =cvmx_qlm_get_gbaud_mhz (qlm) *8 /10 ; + }else if (OCTEON_IS_MODEL (OCTEON_CNF71XX )) { + speed =cvmx_qlm_get_gbaud_mhz (0 ) *8 /10 ; + }else if (OCTEON_IS_MODEL (OCTEON_CN70XX )) { + speed =cvmx_qlm_get_gbaud_mhz (0 ) *8 /10 ; +if (cvmx_qlm_get_dlm_mode (0 , interface) ==CVMX_QLM_MODE_SGMII ) + speed >>=1 ; +else + speed >>=2 ; + } + + pcsx_mrx_control_reg.u64 = +csr_rd (CVMX_PCSX_MRX_CONTROL_REG (index, interface)); +if (pcsx_mrx_control_reg.s.loopbck1) { +/* Force 1Gbps full duplex link for internal loopback */ + result.s.link_up =1 ; + result.s.full_duplex =1 ; + result.s.speed = speed; +return result; + } + + pcsx_miscx_ctl_reg.u64 = +csr_rd (CVMX_PCSX_MISCX_CTL_REG (index, interface)); +if (pcsx_miscx_ctl_reg.s.mac_phy || +cvmx_helper_get_port_force_link_up (interface, index)) { +/* PHY Mode */ +/* Note that this also works for 1000base-X mode */ + + result.s.speed = speed; + result.s.full_duplex =1 ; + result.s.link_up =1 ; +return result; + } + +/* MAC Mode */ +return __cvmx_helper_board_link_get (ipd_port); +} + +/** +* @INTERNAL +* Configure an IPD/PKO port for the specified link state. This +* function does not influence auto negotiation at the PHY level. +* The passed link state must always match the link state returned +* by cvmx_helper_link_get(). It is normally best to use +* cvmx_helper_link_autoconf() instead. +* +* @param ipd_port IPD/PKO port to configure +* @param link_info The new link state +* +* @return Zero on success, negative on failure +*/ +int __cvmx_helper_sgmii_link_set (int ipd_port, +cvmx_helper_link_info_t link_info) +{ +union cvmx_pcsx_mrx_control_reg control_reg; +int interface =cvmx_helper_get_interface_num (ipd_port); +int index =cvmx_helper_get_interface_index_num (ipd_port); + +if (!cvmx_helper_is_port_valid (interface, index)) +return 0 ; + +/* For some devices, i.e. the Qualcomm QCA8337 switch we need to power +* down the PCS interface when the link goes down and power it back +* up when the link returns. +*/ +if (link_info.s.link_up || !__cvmx_helper_need_g15618 ()) { +__cvmx_helper_sgmii_hardware_init_link (interface, index); + }else { +union cvmx_pcsx_miscx_ctl_reg pcsx_miscx_ctl_reg; + + pcsx_miscx_ctl_reg.u64 = +csr_rd (CVMX_PCSX_MISCX_CTL_REG (index, interface)); + +/* Disable autonegotiation when MAC mode is enabled or +* autonegotiation is disabled. +*/ + control_reg.u64 = +csr_rd (CVMX_PCSX_MRX_CONTROL_REG (index, interface)); +if (pcsx_miscx_ctl_reg.s.mac_phy ==0 || + !cvmx_helper_get_port_autonegotiation (interface, index)) { + control_reg.s.an_en =0 ; + control_reg.s.spdmsb =1 ; + control_reg.s.spdlsb =0 ; + control_reg.s.dup =1 ; + } +csr_wr (CVMX_PCSX_MRX_CONTROL_REG (index, interface), + control_reg.u64); +csr_rd (CVMX_PCSX_MRX_CONTROL_REG (index, interface)); +/* +* Use GMXENO to force the link down it will get +* reenabled later... +*/ + pcsx_miscx_ctl_reg.s.gmxeno =1 ; +csr_wr (CVMX_PCSX_MISCX_CTL_REG (index, interface), + pcsx_miscx_ctl_reg.u64); +csr_rd (CVMX_PCSX_MISCX_CTL_REG (index, interface)); +return 0 ; + } +return __cvmx_helper_sgmii_hardware_init_link_speed (interface, index, + link_info); +} + +/** +* @INTERNAL +* Configure a port for internal and/or external loopback. Internal loopback +* causes packets sent by the port to be received by Octeon. External loopback +* causes packets received from the wire to sent out again. +* +* @param ipd_port IPD/PKO port to loopback. +* @param enable_internal +* Non zero if you want internal loopback +* @param enable_external +* Non zero if you want external loopback +* +* @return Zero on success, negative on failure. +*/ +int __cvmx_helper_sgmii_configure_loopback (int ipd_port,int enable_internal, +int enable_external) +{ +int interface =cvmx_helper_get_interface_num (ipd_port); +int index =cvmx_helper_get_interface_index_num (ipd_port); +union cvmx_pcsx_mrx_control_reg pcsx_mrx_control_reg; +union cvmx_pcsx_miscx_ctl_reg pcsx_miscx_ctl_reg; + +if (!cvmx_helper_is_port_valid (interface, index)) +return 0 ; + + pcsx_mrx_control_reg.u64 = +csr_rd (CVMX_PCSX_MRX_CONTROL_REG (index, interface)); + pcsx_mrx_control_reg.s.loopbck1 = enable_internal; +csr_wr (CVMX_PCSX_MRX_CONTROL_REG (index, interface), + pcsx_mrx_control_reg.u64); + + pcsx_miscx_ctl_reg.u64 = +csr_rd (CVMX_PCSX_MISCX_CTL_REG (index, interface)); + pcsx_miscx_ctl_reg.s.loopbck2 = enable_external; +csr_wr (CVMX_PCSX_MISCX_CTL_REG (index, interface), + pcsx_miscx_ctl_reg.u64); + +__cvmx_helper_sgmii_hardware_init_link (interface, index); +return 0 ; +}
Signature · 1 line
2.35.1
PATCH 48/52 mips: octeon: mrvl, octeon-ebb7304.dts: Add ethernet DT support
In reply to Stefan RoeseAdd the Octeon ethernet (BGX), SMI and PHY DT nodes to the EBB7304 dts file to enable ethernet support on this board.
--- arch/mips/dts/mrvl,octeon-ebb7304.dts | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
arch/mips/dts/mrvl,octeon-ebb7304.dts +45 -0
@@ -201,3 +201,48 @@ cd-gpios = <&gpio 25 1>; /* active low */ }; }; + +/* SMI_1 -- Available on rev 2 and later boards */ +&smi1 { + /** + * The phy names are broken down as follows: + * (m)phyxxyzzs + * where: + * xx = 01 for SGMII, 10 for DXAUI, 20 for RXAUI + * and 40 for XFI/LXAUI + * y = QLM/DLM number + * zz = PHY address (decimal) + * s = sub-phy number in the case of the Cortina + * PHY + * a mphy is a nexus phy that contains one or more + * sub-phys, for example the Cortina CS4223. + */ + + /* QLM 2 */ + phy01208: ethernet-phy@01208 { + reg = <8>; + compatible = "marvell,88e1240", "ethernet-phy-ieee802.3-c22"; + + marvell,reg-init = <3 0x10 0 0x8665>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x8a08>; + + interrupt-parent = <&gpio>; + interrupts = <12 8>; /* Pin 12, active low */ + }; +}; + +/* BGX 0 */ +&bgx0 { + status = "okay"; + phy-handle = <&phy01208>; /* put phy-handle in BGX node and MAC node */ + + /* SerDes 0, may differ from PCS Lane/LMAC */ + eth0: ethernet-mac@D { + compatible = "cavium,octeon-7890-bgx-port"; + reg = <0>; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-handle = <&phy01208>; + }; +};
Signature · 1 line
2.35.1
PATCH 51/52 mips: octeon: ebb7304: Enable ethernet support
In reply to Stefan RoeseThis patch enables the Kconfig symbols needed for full ethernet support on the EBB7304. Also the PHY autonegotiation timeout is increased, as the default 5 seconds are sometime a bit short. With this, ethernet can be used on this board. Here an example of a tftp load:
=> tftp ffffffff81000000 big
ethernet-mac-nexus@11800e0000000 Waiting for PHY auto negotiation to complete....... done Using ethernet-mac-nexus@11800e0000000 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.243
Filename 'big'.
Load address: 0xffffffff81000000
Loading: ################################################## 10 MiB
13.2 MiB/s
done
Bytes transferred = 10485760 (a00000 hex)
--- configs/octeon_ebb7304_defconfig | 7 +++++++ include/configs/octeon_ebb7304.h | 2 ++ 2 files changed, 9 insertions(+)
configs/octeon_ebb7304_defconfig +7 -0
@@ -25,6 +25,7 @@ CONFIG_CMD_PART=y CONFIG_CMD_PCI=y CONFIG_CMD_USB=y CONFIG_CMD_DHCP=y +CONFIG_CMD_MII=y CONFIG_CMD_PING=y CONFIG_CMD_RTC=y CONFIG_CMD_TIME=y
@@ -36,6 +37,7 @@ CONFIG_EFI_PARTITION=y CONFIG_PARTITION_TYPE_GUID=y CONFIG_ENV_IS_IN_FLASH=y CONFIG_ENV_ADDR=0x800000001FBFE000 +CONFIG_TFTP_TSIZE=y CONFIG_CLK=y # CONFIG_INPUT is not set CONFIG_MISC=y
@@ -53,7 +55,12 @@ CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y +CONFIG_PHYLIB=y +CONFIG_PHY_MARVELL=y +CONFIG_DM_MDIO=y +CONFIG_DM_ETH_PHY=y CONFIG_E1000=y +CONFIG_NET_OCTEON=y CONFIG_PCI=y CONFIG_PCIE_OCTEON=y CONFIG_DM_REGULATOR=y
include/configs/octeon_ebb7304.h +2 -0
@@ -16,4 +16,6 @@#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_8BIT#define CONFIG_SYS_FLASH_EMPTY_INFO /* flinfo indicates empty blocks */ +#define PHY_ANEG_TIMEOUT 8000/* PHY needs a longer aneg time */ +#endif /* __CONFIG_H__ */
Signature · 1 line
2.35.1
PATCH 34/52 mips: octeon: Add cvmx-pko.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-pko.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-pko.c | 1110 ++++++++++++++++++++++++++++++ 1 file changed, 1110 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-pko.c
arch/mips/mach-octeon/cvmx-pko.c new file +1110 -0
@@ -0,0 +1,1110 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +* +* Support library for the hardware Packet Output unit. +*/ + +#include <errno.h> +#include <log.h> +#include <time.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/cvmx-fuse.h> +#include <mach/octeon-feature.h> +#include <mach/cvmx-qlm.h> +#include <mach/octeon_qlm.h> +#include <mach/cvmx-pcie.h> +#include <mach/cvmx-coremask.h> + +#include <mach/cvmx-agl-defs.h> +#include <mach/cvmx-bgxx-defs.h> +#include <mach/cvmx-ciu-defs.h> +#include <mach/cvmx-gmxx-defs.h> +#include <mach/cvmx-gserx-defs.h> +#include <mach/cvmx-ilk-defs.h> +#include <mach/cvmx-iob-defs.h> +#include <mach/cvmx-ipd-defs.h> +#include <mach/cvmx-pcsx-defs.h> +#include <mach/cvmx-pcsxx-defs.h> +#include <mach/cvmx-pki-defs.h> +#include <mach/cvmx-pko-defs.h> +#include <mach/cvmx-xcv-defs.h> + +#include <mach/cvmx-hwpko.h> +#include <mach/cvmx-ilk.h> +#include <mach/cvmx-pki.h> +#include <mach/cvmx-pko3.h> +#include <mach/cvmx-pko3-queue.h> +#include <mach/cvmx-pko3-resources.h> + +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> + +#include <mach/cvmx-helper-bgx.h> +#include <mach/cvmx-helper-cfg.h> +#include <mach/cvmx-helper-util.h> +#include <mach/cvmx-helper-pki.h> +#include <mach/cvmx-helper-pko.h> + +DECLARE_GLOBAL_DATA_PTR ; + +#define CVMX_PKO_NQ_PER_PORT_MAX 32 + +static cvmx_pko_return_value_t cvmx_pko2_config_port (short ipd_port, +int base_queue, +int num_queues, +const u8 priority[]); + +static const int debug; + +/** +* Internal state of packet output +*/ + +/* +* PKO port iterator +* XXX this macro only works for 68XX +*/ + +#define pko_for_each_port (__p) \ + for (__p = 0; __p < CVMX_HELPER_CFG_MAX_PKO_PORT; __p++) \ + if (__cvmx_helper_cfg_pko_queue_base(__p) != \ + CVMX_HELPER_CFG_INVALID_VALUE) + +/* +* @INTERNAL +* +* Get INT for a port +* +* @param interface +* @param index +* @return the INT value on success and -1 on error +* +* This function is only for CN68XX. +*/ +static int __cvmx_pko_int (int interface,int index) +{ +cvmx_helper_cfg_assert (interface <CVMX_HELPER_MAX_IFACE ); +cvmx_helper_cfg_assert (index >=0 ); + +switch (interface) { +case 0 : +cvmx_helper_cfg_assert (index <4 ); +return index; +case 1 : +cvmx_helper_cfg_assert (index ==0 ); +return 4 ; +case 2 : +cvmx_helper_cfg_assert (index <4 ); +return index +8 ; +case 3 : +cvmx_helper_cfg_assert (index <4 ); +return index +0xC ; +case 4 : +cvmx_helper_cfg_assert (index <4 ); +return index +0x10 ; +case 5 : +cvmx_helper_cfg_assert (index <256 ); +return 0x1C ; +case 6 : +cvmx_helper_cfg_assert (index <256 ); +return 0x1D ; +case 7 : +cvmx_helper_cfg_assert (index <32 ); +return 0x1E ; +case 8 : +cvmx_helper_cfg_assert (index <8 ); +return 0x1F ; + } + +return -1 ; +} + +int cvmx_pko_get_base_pko_port (int interface,int index) +{ +if (octeon_has_feature (OCTEON_FEATURE_CN78XX_WQE )) +return cvmx_helper_get_ipd_port (interface, index); +else if (octeon_has_feature (OCTEON_FEATURE_PKND )) +return __cvmx_helper_cfg_pko_port_base (interface, index); +else +return cvmx_helper_get_ipd_port (interface, index); +} + +int cvmx_pko_get_num_pko_ports (int interface,int index) +{ +if (octeon_has_feature (OCTEON_FEATURE_CN78XX_WQE )) +return 1 ; +if (octeon_has_feature (OCTEON_FEATURE_PKND )) +return __cvmx_helper_cfg_pko_port_num (interface, index); +else +return 1 ; +} + +int cvmx_pko_get_base_queue (int port) +{ +if (octeon_has_feature (OCTEON_FEATURE_CN78XX_WQE )) { +return cvmx_pko3_get_queue_base (port); + }else if (octeon_has_feature (OCTEON_FEATURE_PKND )) { +return __cvmx_helper_cfg_pko_queue_base ( +cvmx_helper_cfg_ipd2pko_port_base (port)); + }else { +if (port <48 ) +return cvmx_pko_queue_table[port].ccppp_queue_base; +else +return CVMX_PKO_ILLEGAL_QUEUE ; + } +} + +/** +* For a given PKO port number, return the base output queue +* for the port. +* +* @param pko_port PKO port number +* @return Base output queue +*/ +int cvmx_pko_get_base_queue_pkoid (int pko_port) +{ +if (octeon_has_feature (OCTEON_FEATURE_CN78XX_WQE )) +return cvmx_pko3_get_queue_base (pko_port); +return __cvmx_helper_cfg_pko_queue_base (pko_port); +} + +/** +* For a given PKO port number, return the number of output queues +* for the port. +* +* @param pko_port PKO port number +* @return the number of output queues +*/ +int cvmx_pko_get_num_queues_pkoid (int pko_port) +{ +if (octeon_has_feature (OCTEON_FEATURE_CN78XX_WQE )) +return cvmx_pko3_get_queue_num (pko_port); +return __cvmx_helper_cfg_pko_queue_num (pko_port); +} + +int cvmx_pko_get_num_queues (int port) +{ +if (octeon_has_feature (OCTEON_FEATURE_CN78XX_WQE )) { +return cvmx_pko3_get_queue_num (port); + }else if (octeon_has_feature (OCTEON_FEATURE_PKND )) { +return __cvmx_helper_cfg_pko_queue_num ( +cvmx_helper_cfg_ipd2pko_port_base (port)); + }else { +if (port <48 ) +return cvmx_pko_queue_table[port].ccppp_num_queues; + } +return 0 ; +} + +/** +* Show queues for the internal ports +*/ +void cvmx_pko_show_queue_map (void ) +{ +if (octeon_has_feature (OCTEON_FEATURE_CN78XX_WQE )) { +debug ("%s: not supported on this chip\n" , __func__); +return ; + }else if (octeon_has_feature (OCTEON_FEATURE_PKND )) { +int port; + +pko_for_each_port (port) { +debug ("pko_port %d (interface%d index%d) has %d queues (queue base = %d)\n" , + port,__cvmx_helper_cfg_pko_port_interface (port), +__cvmx_helper_cfg_pko_port_index (port), +__cvmx_helper_cfg_pko_queue_num (port), +__cvmx_helper_cfg_pko_queue_base (port)); + } + }else { +int port; +int pko_output_ports; + + pko_output_ports =40 ; +debug ("pko queue info\n" ); +for (port =0 ; port < pko_output_ports; port++) { +debug ("%3d=%3d-%3d " , port, +cvmx_pko_get_base_queue (port), +cvmx_pko_get_base_queue (port) + +cvmx_pko_get_num_queues (port) -1 ); +if (((port +1 ) %4 ) ==0 ) +debug ("\n" ); + } +debug ("\n" ); + } +} + +/* +* Allocate memory for PKO engines. +* +* @param engine is the PKO engine ID. +* @return # of 2KB-chunks allocated to this PKO engine. +*/ +static int __cvmx_pko_memory_per_engine_o68 (int engine) +{ +/* CN68XX has 40KB to devide between the engines in 2KB chunks */ +int max_engine; +int size_per_engine; +int size; + + max_engine =__cvmx_helper_cfg_pko_max_engine (); + size_per_engine =40 /2 / max_engine; + +if (engine >= max_engine) +/* Unused engines get no space */ + size =0 ; +else if (engine == max_engine -1 ) +/* +* The last engine gets all the space lost by rounding. This means +* the ILK gets the most space +*/ + size =40 /2 - engine * size_per_engine; +else +/* All other engines get the same space */ + size = size_per_engine; + +return size; +} + +/* +* Setup one-to-one mapping between PKO2 iport and eport. +* @INTERNAL +*/ +static void __cvmx_pko2_chip_init (void ) +{ +int i; +int interface, index, port; +cvmx_helper_interface_mode_t mode; +union cvmx_pko_mem_iport_ptrs config; + +/* +* Initialize every iport with the invalid eid. +*/ +#define CVMX_O68_PKO2_INVALID_EID 31 + config.u64 =0 ; + config.s.eid =CVMX_O68_PKO2_INVALID_EID ; +for (i =0 ; i <CVMX_HELPER_CFG_MAX_PKO_PORT ; i++) { + config.s.ipid = i; +csr_wr (CVMX_PKO_MEM_IPORT_PTRS , config.u64); + } + +/* +* Set up PKO_MEM_IPORT_PTRS +*/ +pko_for_each_port (port) { + interface =__cvmx_helper_cfg_pko_port_interface (port); + index =__cvmx_helper_cfg_pko_port_index (port); + mode =cvmx_helper_interface_get_mode (interface); + +if (mode ==CVMX_HELPER_INTERFACE_MODE_DISABLED ) +continue ; + + config.s.ipid = port; + config.s.qos_mask =0xff ; + config.s.crc =__cvmx_helper_get_has_fcs (interface); + config.s.min_pkt =__cvmx_helper_get_pko_padding (interface); + config.s.intr =__cvmx_pko_int (interface, index); + config.s.eid =__cvmx_helper_cfg_pko_port_eid (port); + config.s.pipe = (mode ==CVMX_HELPER_INTERFACE_MODE_LOOP ) ? + index : + port; +csr_wr (CVMX_PKO_MEM_IPORT_PTRS , config.u64); + } +} + +int __cvmx_pko_get_pipe (int interface,int index) +{ +/* The loopback ports do not have pipes */ +if (cvmx_helper_interface_get_mode (interface) == +CVMX_HELPER_INTERFACE_MODE_LOOP ) +return -1 ; +/* We use pko_port as the pipe. See __cvmx_pko_port_map_o68(). */ +return cvmx_helper_get_pko_port (interface, index); +} + +static void __cvmx_pko1_chip_init (void ) +{ +int queue; +union cvmx_pko_mem_queue_ptrs config; +union cvmx_pko_reg_queue_ptrs1 config1; +const int port =CVMX_PKO_MEM_QUEUE_PTRS_ILLEGAL_PID ; + +/* Initialize all queues to connect to port 63 (ILLEGAL_PID) */ +for (queue =0 ; queue <CVMX_PKO_MAX_OUTPUT_QUEUES ; queue++) { + config1.u64 =0 ; + config1.s.idx3 =0 ; + config1.s.qid7 = queue >>7 ; + + config.u64 =0 ; + config.s.tail =1 ; + config.s.index =0 ; + config.s.port = port; + config.s.queue = queue; + config.s.buf_ptr =0 ; + +csr_wr (CVMX_PKO_REG_QUEUE_PTRS1 , config1.u64); +csr_wr (CVMX_PKO_MEM_QUEUE_PTRS , config.u64); + } +} + +/** +* Call before any other calls to initialize the packet +* output system. This does chip global config, and should only be +* done by one core. +*/ +void cvmx_pko_hw_init (u8 pool,unsigned int bufsize) +{ +union cvmx_pko_reg_cmd_buf config; +union cvmx_iob_fau_timeout fau_to; +int i; + +if (debug) +debug ("%s: pool=%u bufsz=%u\n" , __func__, pool, bufsize); + +/* chip-specific setup. */ +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) +__cvmx_pko2_chip_init (); +else +__cvmx_pko1_chip_init (); + +/* +* Set the size of the PKO command buffers to an odd number of +* 64bit words. This allows the normal two word send to stay +* aligned and never span a command word buffer. +*/ + config.u64 =0 ; + config.s.pool = pool; + config.s.size = bufsize /8 -1 ; +csr_wr (CVMX_PKO_REG_CMD_BUF , config.u64); + +/* +* Disable tagwait FAU timeout. This needs to be done before +* anyone might start packet output using tags. +*/ + fau_to.u64 =0 ; + fau_to.s.tout_val =0xfff ; + fau_to.s.tout_enb =0 ; +csr_wr (CVMX_IOB_FAU_TIMEOUT , fau_to.u64); + +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) { +union cvmx_pko_reg_min_pkt min_pkt; + + min_pkt.u64 =0 ; + min_pkt.s.size1 =59 ; + min_pkt.s.size2 =59 ; + min_pkt.s.size3 =59 ; + min_pkt.s.size4 =59 ; + min_pkt.s.size5 =59 ; + min_pkt.s.size6 =59 ; + min_pkt.s.size7 =59 ; +csr_wr (CVMX_PKO_REG_MIN_PKT , min_pkt.u64); + } + +/* +* If we aren't using all of the queues optimize PKO's +* internal memory. +*/ +if (OCTEON_IS_OCTEON2 () ||OCTEON_IS_MODEL (OCTEON_CN70XX )) { +int max_queues =__cvmx_helper_cfg_pko_max_queue (); + +if (OCTEON_IS_MODEL (OCTEON_CN68XX ) && max_queues <=32 ) +csr_wr (CVMX_PKO_REG_QUEUE_MODE ,3 ); +else if (max_queues <=64 ) +csr_wr (CVMX_PKO_REG_QUEUE_MODE ,2 ); +else if (max_queues <=128 ) +csr_wr (CVMX_PKO_REG_QUEUE_MODE ,1 ); +else +csr_wr (CVMX_PKO_REG_QUEUE_MODE ,0 ); +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) { +for (i =0 ; i <2 ; i++) { +union cvmx_pko_reg_engine_storagex + engine_storage; + +#define PKO_ASSIGN_ENGINE_STORAGE (index) \ + engine_storage.s.engine##index = \ + __cvmx_pko_memory_per_engine_o68(16 * i + (index)) + + engine_storage.u64 =0 ; +PKO_ASSIGN_ENGINE_STORAGE (0 ); +PKO_ASSIGN_ENGINE_STORAGE (1 ); +PKO_ASSIGN_ENGINE_STORAGE (2 ); +PKO_ASSIGN_ENGINE_STORAGE (3 ); +PKO_ASSIGN_ENGINE_STORAGE (4 ); +PKO_ASSIGN_ENGINE_STORAGE (5 ); +PKO_ASSIGN_ENGINE_STORAGE (6 ); +PKO_ASSIGN_ENGINE_STORAGE (7 ); +PKO_ASSIGN_ENGINE_STORAGE (8 ); +PKO_ASSIGN_ENGINE_STORAGE (9 ); +PKO_ASSIGN_ENGINE_STORAGE (10 ); +PKO_ASSIGN_ENGINE_STORAGE (11 ); +PKO_ASSIGN_ENGINE_STORAGE (12 ); +PKO_ASSIGN_ENGINE_STORAGE (13 ); +PKO_ASSIGN_ENGINE_STORAGE (14 ); +PKO_ASSIGN_ENGINE_STORAGE (15 ); +csr_wr (CVMX_PKO_REG_ENGINE_STORAGEX (i), + engine_storage.u64); + } + } + } +} + +/** +* Enables the packet output hardware. It must already be +* configured. +*/ +void cvmx_pko_enable (void ) +{ +union cvmx_pko_reg_flags flags; + + flags.u64 =csr_rd (CVMX_PKO_REG_FLAGS ); +if (flags.s.ena_pko) +debug ("Warning: Enabling PKO when PKO already enabled.\n" ); + + flags.s.ena_dwb =cvmx_helper_cfg_opt_get (CVMX_HELPER_CFG_OPT_USE_DWB ); + flags.s.ena_pko =1 ; +/* +* always enable big endian for 3-word command. Does nothing +* for 2-word. +*/ + flags.s.store_be =1 ; +csr_wr (CVMX_PKO_REG_FLAGS , flags.u64); +} + +/** +* Disables the packet output. Does not affect any configuration. +*/ +void cvmx_pko_disable (void ) +{ +union cvmx_pko_reg_flags pko_reg_flags; + + pko_reg_flags.u64 =csr_rd (CVMX_PKO_REG_FLAGS ); + pko_reg_flags.s.ena_pko =0 ; +csr_wr (CVMX_PKO_REG_FLAGS , pko_reg_flags.u64); +} + +/** +* @INTERNAL +* Reset the packet output. +*/ +static void __cvmx_pko_reset (void ) +{ +union cvmx_pko_reg_flags pko_reg_flags; + + pko_reg_flags.u64 =csr_rd (CVMX_PKO_REG_FLAGS ); + pko_reg_flags.s.reset =1 ; +csr_wr (CVMX_PKO_REG_FLAGS , pko_reg_flags.u64); +} + +/** +* Shutdown and free resources required by packet output. +*/ +void cvmx_pko_shutdown (void ) +{ +int queue; + +cvmx_pko_disable (); + +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) { +union cvmx_pko_mem_iqueue_ptrs config; + + config.u64 =0 ; +for (queue =0 ; queue <CVMX_PKO_MAX_OUTPUT_QUEUES ; queue++) { + config.s.qid = queue; +csr_wr (CVMX_PKO_MEM_IQUEUE_PTRS , config.u64); +cvmx_cmd_queue_shutdown (CVMX_CMD_QUEUE_PKO (queue)); + } + }else { +union cvmx_pko_mem_queue_ptrs config; + +for (queue =0 ; queue <CVMX_PKO_MAX_OUTPUT_QUEUES ; queue++) { +union cvmx_pko_reg_queue_ptrs1 config1; + + config.u64 =0 ; + config.s.tail =1 ; + config.s.index =0 ; + config.s.port =CVMX_PKO_MEM_QUEUE_PTRS_ILLEGAL_PID ; + config.s.queue = queue &0x7f ; + config.s.qos_mask =0 ; + config.s.buf_ptr =0 ; + + config1.u64 =0 ; + config1.s.qid7 = queue >>7 ; +csr_wr (CVMX_PKO_REG_QUEUE_PTRS1 , config1.u64); +csr_wr (CVMX_PKO_MEM_QUEUE_PTRS , config.u64); +cvmx_cmd_queue_shutdown (CVMX_CMD_QUEUE_PKO (queue)); + } + } + +__cvmx_pko_reset (); +cvmx_pko_queue_free_all (); +} + +/** +* Configure a output port and the associated queues for use. +* +* @param port Port to configure. +* @param base_queue First queue number to associate with this port. +* @param num_queues Number of queues to associate with this port +* @param priority Array of priority levels for each queue. Values are +* allowed to be 0-8. A value of 8 get 8 times the traffic +* of a value of 1. A value of 0 indicates that no rounds +* will be participated in. These priorities can be changed +* on the fly while the pko is enabled. A priority of 9 +* indicates that static priority should be used. If static +* priority is used all queues with static priority must be +* contiguous starting at the base_queue, and lower numbered +* queues have higher priority than higher numbered queues. +* There must be num_queues elements in the array. +*/ +cvmx_pko_return_value_t cvmx_pko_config_port (int port,int base_queue, +int num_queues, +const u8 priority[]) +{ +cvmx_pko_return_value_t result_code; +int queue; +union cvmx_pko_mem_queue_ptrs config; +union cvmx_pko_reg_queue_ptrs1 config1; +int static_priority_base =-1 ; +int static_priority_end =-1 ; +int outputbuffer_pool = (int )cvmx_fpa_get_pko_pool (); +u64 outputbuffer_pool_size =cvmx_fpa_get_pko_pool_block_size (); + +/* This function is not used for CN68XX */ +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) +return cvmx_pko2_config_port (port, base_queue, num_queues, + priority); + +if (debug) +debug ("%s: port=%d queue=%d-%d pri %#x %#x %#x %#x\n" , __func__, + port, base_queue, (base_queue + num_queues -1 ), + priority[0 ], priority[1 ], priority[2 ], priority[3 ]); + +/* The need to handle ILLEGAL_PID port argument +* is obsolete now, the code here can be simplified. +*/ + +if (port >=CVMX_PKO_NUM_OUTPUT_PORTS && + port !=CVMX_PKO_MEM_QUEUE_PTRS_ILLEGAL_PID ) { +debug ("ERROR: %s: Invalid port %llu\n" , __func__, + (unsigned long long )port); +return CVMX_PKO_INVALID_PORT ; + } + +if (base_queue + num_queues >CVMX_PKO_MAX_OUTPUT_QUEUES ) { +debug ("ERROR: %s: Invalid queue range port = %lld base=%llu numques=%lld\n" , + __func__, (unsigned long long )port, + (unsigned long long )base_queue, + (unsigned long long )num_queues); +return CVMX_PKO_INVALID_QUEUE ; + } + +if (port !=CVMX_PKO_MEM_QUEUE_PTRS_ILLEGAL_PID ) { +/* +* Validate the static queue priority setup and set +* static_priority_base and static_priority_end +* accordingly. +*/ +for (queue =0 ; queue < num_queues; queue++) { +/* Find first queue of static priority */ +int p_queue = queue %16 ; + +if (static_priority_base ==-1 && + priority[p_queue] ==CVMX_PKO_QUEUE_STATIC_PRIORITY ) + static_priority_base = queue; +/* Find last queue of static priority */ +if (static_priority_base !=-1 && + static_priority_end ==-1 && + priority[p_queue] != +CVMX_PKO_QUEUE_STATIC_PRIORITY && + queue) + static_priority_end = queue -1 ; +else if (static_priority_base !=-1 && + static_priority_end ==-1 && + queue == num_queues -1 ) +/* all queues're static priority */ + static_priority_end = queue; + +/* +* Check to make sure all static priority +* queues are contiguous. Also catches some +* cases of static priorites not starting at +* queue 0. +*/ +if (static_priority_end !=-1 && + (int )queue > static_priority_end && + priority[p_queue] == +CVMX_PKO_QUEUE_STATIC_PRIORITY ) { +debug ("ERROR: %s: Static priority queues aren't contiguous or don't start at base queue. q: %d, eq: %d\n" , + __func__, (int )queue, static_priority_end); +return CVMX_PKO_INVALID_PRIORITY ; + } + } +if (static_priority_base >0 ) { +debug ("ERROR: %s: Static priority queues don't start at base queue. sq: %d\n" , + __func__, static_priority_base); +return CVMX_PKO_INVALID_PRIORITY ; + } + } + +/* +* At this point, static_priority_base and static_priority_end +* are either both -1, or are valid start/end queue numbers +*/ + + result_code =CVMX_PKO_SUCCESS ; + +for (queue =0 ; queue < num_queues; queue++) { +u64 *buf_ptr =NULL ; +int p_queue = queue %16 ; + + config1.u64 =0 ; + config1.s.idx3 = queue >>3 ; + config1.s.qid7 = (base_queue + queue) >>7 ; + + config.u64 =0 ; + config.s.tail = queue == (num_queues -1 ); + config.s.index = queue; + config.s.port = port; + config.s.queue = base_queue + queue; + + config.s.static_p = static_priority_base >=0 ; + config.s.static_q = (int )queue <= static_priority_end; + config.s.s_tail = (int )queue == static_priority_end; +/* +* Convert the priority into an enable bit field. Try +* to space the bits out evenly so the packet don't +* get grouped up. +*/ +switch ((int )priority[p_queue]) { +case 0 : + config.s.qos_mask =0x00 ; +break ; +case 1 : + config.s.qos_mask =0x01 ; +break ; +case 2 : + config.s.qos_mask =0x11 ; +break ; +case 3 : + config.s.qos_mask =0x49 ; +break ; +case 4 : + config.s.qos_mask =0x55 ; +break ; +case 5 : + config.s.qos_mask =0x57 ; +break ; +case 6 : + config.s.qos_mask =0x77 ; +break ; +case 7 : + config.s.qos_mask =0x7f ; +break ; +case 8 : + config.s.qos_mask =0xff ; +break ; +case CVMX_PKO_QUEUE_STATIC_PRIORITY : + config.s.qos_mask =0xff ; +break ; +default : +debug ("ERROR: %s: Invalid priority %llu\n" , __func__, + (unsigned long long )priority[p_queue]); + config.s.qos_mask =0xff ; + result_code =CVMX_PKO_INVALID_PRIORITY ; +break ; + } + +if (port !=CVMX_PKO_MEM_QUEUE_PTRS_ILLEGAL_PID ) { +cvmx_cmd_queue_result_t cmd_res; + + cmd_res =cvmx_cmd_queue_initialize ( +CVMX_CMD_QUEUE_PKO (base_queue + queue), +CVMX_PKO_MAX_QUEUE_DEPTH , outputbuffer_pool, + outputbuffer_pool_size - +CVMX_PKO_COMMAND_BUFFER_SIZE_ADJUST * +8 ); +if (cmd_res !=CVMX_CMD_QUEUE_SUCCESS ) { +switch (cmd_res) { +case CVMX_CMD_QUEUE_NO_MEMORY : +debug ("ERROR: %s: Unable to allocate output buffer\n" , + __func__); +return CVMX_PKO_NO_MEMORY ; +case CVMX_CMD_QUEUE_ALREADY_SETUP : +debug ("ERROR: %s: Port already setup. port=%d\n" , + __func__, (int )port); +return CVMX_PKO_PORT_ALREADY_SETUP ; +case CVMX_CMD_QUEUE_INVALID_PARAM : +default : +debug ("ERROR: %s: Command queue initialization failed.\n" , + __func__); +return CVMX_PKO_CMD_QUEUE_INIT_ERROR ; + } + } + + buf_ptr = (u64 *)cvmx_cmd_queue_buffer ( +CVMX_CMD_QUEUE_PKO (base_queue + queue)); + config.s.buf_ptr =cvmx_ptr_to_phys (buf_ptr); + }else { + config.s.buf_ptr =0 ; + } + +CVMX_SYNCWS ; + +csr_wr (CVMX_PKO_REG_QUEUE_PTRS1 , config1.u64); +csr_wr (CVMX_PKO_MEM_QUEUE_PTRS , config.u64); + } + +return result_code; +} + +/* +* Configure queues for an internal port. +* @INTERNAL +* @param pko_port PKO internal port number +* @note this is the PKO2 equivalent to cvmx_pko_config_port() +*/ +static cvmx_pko_return_value_t cvmx_pko2_config_port (short ipd_port, +int base_queue, +int num_queues, +const u8 priority[]) +{ +int queue, pko_port; +int static_priority_base; +int static_priority_end; +union cvmx_pko_mem_iqueue_ptrs config; +u64 *buf_ptr =NULL ; +int outputbuffer_pool = (int )cvmx_fpa_get_pko_pool (); +u64 outputbuffer_pool_size =cvmx_fpa_get_pko_pool_block_size (); + + pko_port =cvmx_helper_cfg_ipd2pko_port_base (ipd_port); + +if (debug) +debug ("%s: ipd_port %d pko_iport %d qbase %d qnum %d\n" , + __func__, ipd_port, pko_port, base_queue, num_queues); + + static_priority_base =-1 ; + static_priority_end =-1 ; + +/* +* static queue priority validation +*/ +for (queue =0 ; queue < num_queues; queue++) { +int p_queue = queue %16 ; + +if (static_priority_base ==-1 && + priority[p_queue] ==CVMX_PKO_QUEUE_STATIC_PRIORITY ) + static_priority_base = queue; + +if (static_priority_base !=-1 && static_priority_end ==-1 && + priority[p_queue] !=CVMX_PKO_QUEUE_STATIC_PRIORITY && + queue) + static_priority_end = queue -1 ; +else if (static_priority_base !=-1 && + static_priority_end ==-1 && queue == num_queues -1 ) + static_priority_end = + queue;/* all queues are static priority */ + +/* +* Check to make sure all static priority queues are contiguous. +* Also catches some cases of static priorites not starting from +* queue 0. +*/ +if (static_priority_end !=-1 && + (int )queue > static_priority_end && + priority[p_queue] ==CVMX_PKO_QUEUE_STATIC_PRIORITY ) { +debug ("ERROR: %s: Static priority queues aren't contiguous or don't start at base queue. q: %d, eq: %d\n" , + __func__, (int )queue, static_priority_end); + } +if (static_priority_base >0 ) { +debug ("ERROR: %s: Static priority queues don't start at base queue. sq: %d\n" , + __func__, static_priority_base); + } + } + +/* +* main loop to set the fields of CVMX_PKO_MEM_IQUEUE_PTRS for +* each queue +*/ +for (queue =0 ; queue < num_queues; queue++) { +int p_queue = queue %8 ; + + config.u64 =0 ; + config.s.index = queue; + config.s.qid = base_queue + queue; + config.s.ipid = pko_port; + config.s.tail = (queue == (num_queues -1 )); + config.s.s_tail = (queue == static_priority_end); + config.s.static_p = (static_priority_base >=0 ); + config.s.static_q = (queue <= static_priority_end); + +/* +* Convert the priority into an enable bit field. +* Try to space the bits out evenly so the packet +* don't get grouped up. +*/ +switch ((int )priority[p_queue]) { +case 0 : + config.s.qos_mask =0x00 ; +break ; +case 1 : + config.s.qos_mask =0x01 ; +break ; +case 2 : + config.s.qos_mask =0x11 ; +break ; +case 3 : + config.s.qos_mask =0x49 ; +break ; +case 4 : + config.s.qos_mask =0x55 ; +break ; +case 5 : + config.s.qos_mask =0x57 ; +break ; +case 6 : + config.s.qos_mask =0x77 ; +break ; +case 7 : + config.s.qos_mask =0x7f ; +break ; +case 8 : + config.s.qos_mask =0xff ; +break ; +case CVMX_PKO_QUEUE_STATIC_PRIORITY : + config.s.qos_mask =0xff ; +break ; +default : +debug ("ERROR: %s: Invalid priority %llu\n" , __func__, + (unsigned long long )priority[p_queue]); + config.s.qos_mask =0xff ; +break ; + } + +/* +* The command queues +*/ + { +cvmx_cmd_queue_result_t cmd_res; + + cmd_res =cvmx_cmd_queue_initialize ( +CVMX_CMD_QUEUE_PKO (base_queue + queue), +CVMX_PKO_MAX_QUEUE_DEPTH , outputbuffer_pool, + (outputbuffer_pool_size - +CVMX_PKO_COMMAND_BUFFER_SIZE_ADJUST *8 )); + +if (cmd_res !=CVMX_CMD_QUEUE_SUCCESS ) { +switch (cmd_res) { +case CVMX_CMD_QUEUE_NO_MEMORY : +debug ("ERROR: %s: Unable to allocate output buffer\n" , + __func__); +break ; +case CVMX_CMD_QUEUE_ALREADY_SETUP : +debug ("ERROR: %s: Port already setup\n" , + __func__); +break ; +case CVMX_CMD_QUEUE_INVALID_PARAM : +default : +debug ("ERROR: %s: Command queue initialization failed." , + __func__); +break ; + } +debug (" pko_port%d base_queue%d num_queues%d queue%d.\n" , + pko_port, base_queue, num_queues, queue); + } + + buf_ptr = (u64 *)cvmx_cmd_queue_buffer ( +CVMX_CMD_QUEUE_PKO (base_queue + queue)); + config.s.buf_ptr =cvmx_ptr_to_phys (buf_ptr) >>7 ; + } + +CVMX_SYNCWS ; +csr_wr (CVMX_PKO_MEM_IQUEUE_PTRS , config.u64); + } + +/* Error detection is resirable here */ +return 0 ; +} + +/** +* Rate limit a PKO port to a max packets/sec. This function is only +* supported on CN51XX and higher, excluding CN58XX. +* +* @param port Port to rate limit +* @param packets_s Maximum packet/sec +* @param burst Maximum number of packets to burst in a row before rate +* limiting cuts in. +* +* @return Zero on success, negative on failure +*/ +int cvmx_pko_rate_limit_packets (int port,int packets_s,int burst) +{ +union cvmx_pko_mem_port_rate0 pko_mem_port_rate0; +union cvmx_pko_mem_port_rate1 pko_mem_port_rate1; + + pko_mem_port_rate0.u64 =0 ; + pko_mem_port_rate0.s.pid = port; + pko_mem_port_rate0.s.rate_pkt = gd->bus_clk / packets_s /16 ; +/* No cost per word since we are limited by packets/sec, not bits/sec */ + pko_mem_port_rate0.s.rate_word =0 ; + + pko_mem_port_rate1.u64 =0 ; + pko_mem_port_rate1.s.pid = port; + pko_mem_port_rate1.s.rate_lim = + ((u64 )pko_mem_port_rate0.s.rate_pkt * burst) >>8 ; + +csr_wr (CVMX_PKO_MEM_PORT_RATE0 , pko_mem_port_rate0.u64); +csr_wr (CVMX_PKO_MEM_PORT_RATE1 , pko_mem_port_rate1.u64); +return 0 ; +} + +/** +* Rate limit a PKO port to a max bits/sec. This function is only +* supported on CN51XX and higher, excluding CN58XX. +* +* @param port Port to rate limit +* @param bits_s PKO rate limit in bits/sec +* @param burst Maximum number of bits to burst before rate +* limiting cuts in. +* +* @return Zero on success, negative on failure +*/ +int cvmx_pko_rate_limit_bits (int port,u64 bits_s,int burst) +{ +union cvmx_pko_mem_port_rate0 pko_mem_port_rate0; +union cvmx_pko_mem_port_rate1 pko_mem_port_rate1; +// u64 clock_rate = cvmx_clock_get_rate(CVMX_CLOCK_SCLK); +u64 clock_rate = gd->bus_clk; +u64 tokens_per_bit = clock_rate *16 / bits_s; + + pko_mem_port_rate0.u64 =0 ; + pko_mem_port_rate0.s.pid = port; +/* +* Each packet has a 12 bytes of interframe gap, an 8 byte +* preamble, and a 4 byte CRC. These are not included in the +* per word count. Multiply by 8 to covert to bits and divide +* by 256 for limit granularity. +*/ + pko_mem_port_rate0.s.rate_pkt = (12 +8 +4 ) *8 * tokens_per_bit /256 ; +/* Each 8 byte word has 64bits */ + pko_mem_port_rate0.s.rate_word =64 * tokens_per_bit; + + pko_mem_port_rate1.u64 =0 ; + pko_mem_port_rate1.s.pid = port; + pko_mem_port_rate1.s.rate_lim = tokens_per_bit * burst /256 ; + +csr_wr (CVMX_PKO_MEM_PORT_RATE0 , pko_mem_port_rate0.u64); +csr_wr (CVMX_PKO_MEM_PORT_RATE1 , pko_mem_port_rate1.u64); +return 0 ; +} + +/** +* Get the status counters for a port. +* +* @param ipd_port Port number (ipd_port) to get statistics for. +* @param clear Set to 1 to clear the counters after they are read +* @param status Where to put the results. +* +* Note: +* - Only the doorbell for the base queue of the ipd_port is +* collected. +* - Retrieving the stats involves writing the index through +* CVMX_PKO_REG_READ_IDX and reading the stat CSRs, in that +* order. It is not MP-safe and caller should guarantee +* atomicity. +*/ +void cvmx_pko_get_port_status (u64 ipd_port,u64 clear, +cvmx_pko_port_status_t *status) +{ +cvmx_pko_reg_read_idx_t pko_reg_read_idx; +cvmx_pko_mem_count0_t pko_mem_count0; +cvmx_pko_mem_count1_t pko_mem_count1; +int pko_port, port_base, port_limit; + +if (octeon_has_feature (OCTEON_FEATURE_CN78XX_WQE )) { +int xipd =cvmx_helper_node_to_ipd_port (cvmx_get_node_num (), + ipd_port); +cvmx_pko3_get_legacy_port_stats (xipd, clear, status); +return ; + }else if (octeon_has_feature (OCTEON_FEATURE_PKND )) { +int interface =cvmx_helper_get_interface_num (ipd_port); +int index =cvmx_helper_get_interface_index_num (ipd_port); + + port_base =cvmx_helper_get_pko_port (interface, index); +if (port_base ==-1 ) +debug ("Warning: Invalid port_base\n" ); + port_limit = port_base + +cvmx_pko_get_num_pko_ports (interface, index); + }else { + port_base = ipd_port; + port_limit = port_base +1 ; + } + +/* +* status->packets and status->octets +*/ + status->packets =0 ; + status->octets =0 ; + pko_reg_read_idx.u64 =0 ; + +for (pko_port = port_base; pko_port < port_limit; pko_port++) { +/* +* In theory, one doesn't need to write the index csr every +* time as he can set pko_reg_read_idx.s.inc to increment +* the index automatically. Need to find out exactly how XXX. +*/ + pko_reg_read_idx.s.index = pko_port; +csr_wr (CVMX_PKO_REG_READ_IDX , pko_reg_read_idx.u64); + + pko_mem_count0.u64 =csr_rd (CVMX_PKO_MEM_COUNT0 ); + status->packets += pko_mem_count0.s.count; +if (clear) { + pko_mem_count0.s.count = pko_port; +csr_wr (CVMX_PKO_MEM_COUNT0 , pko_mem_count0.u64); + } + + pko_mem_count1.u64 =csr_rd (CVMX_PKO_MEM_COUNT1 ); + status->octets += pko_mem_count1.s.count; +if (clear) { + pko_mem_count1.s.count = pko_port; +csr_wr (CVMX_PKO_MEM_COUNT1 , pko_mem_count1.u64); + } + } + +/* +* status->doorbell +*/ +cvmx_pko_mem_debug8_t debug8; + + pko_reg_read_idx.s.index =cvmx_pko_get_base_queue (ipd_port); +csr_wr (CVMX_PKO_REG_READ_IDX , pko_reg_read_idx.u64); + debug8.u64 =csr_rd (CVMX_PKO_MEM_DEBUG8 ); +if (OCTEON_IS_MODEL (OCTEON_CN68XX )) + status->doorbell = debug8.cn68xx.doorbell; +else + status->doorbell = debug8.cn58xx.doorbell; +} + +/* +* Obtain the number of PKO commands pending in a queue +* +* @param queue is the queue identifier to be queried +* @return the number of commands pending transmission or -1 on error +*/ +int cvmx_pko_queue_pend_count (cvmx_cmd_queue_id_t queue) +{ +int count; + +if (octeon_has_feature (OCTEON_FEATURE_CN78XX_WQE )) { +int node =cvmx_get_node_num (); + + count =cvmx_pko3_dq_query (node, queue); + }else { + count =cvmx_cmd_queue_length (CVMX_CMD_QUEUE_PKO (queue)); + } +return count; +}
Signature · 1 line
2.35.1
PATCH 36/52 mips: octeon: Add cvmx-pko3-queue.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-pko3-queue.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- arch/mips/mach-octeon/cvmx-pko3-queue.c | 1331 +++++++++++++++++++++++ 1 file changed, 1331 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-pko3-queue.c
arch/mips/mach-octeon/cvmx-pko3-queue.c new file +1331 -0
@@ -0,0 +1,1331 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +*/ + +#include <errno.h> +#include <log.h> +#include <time.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/cvmx-fuse.h> +#include <mach/octeon-feature.h> +#include <mach/cvmx-qlm.h> +#include <mach/octeon_qlm.h> +#include <mach/cvmx-pcie.h> +#include <mach/cvmx-coremask.h> + +#include <mach/cvmx-agl-defs.h> +#include <mach/cvmx-bgxx-defs.h> +#include <mach/cvmx-ciu-defs.h> +#include <mach/cvmx-gmxx-defs.h> +#include <mach/cvmx-gserx-defs.h> +#include <mach/cvmx-ilk-defs.h> +#include <mach/cvmx-ipd-defs.h> +#include <mach/cvmx-pcsx-defs.h> +#include <mach/cvmx-pcsxx-defs.h> +#include <mach/cvmx-pki-defs.h> +#include <mach/cvmx-pko-defs.h> +#include <mach/cvmx-xcv-defs.h> + +#include <mach/cvmx-hwpko.h> +#include <mach/cvmx-ilk.h> +#include <mach/cvmx-pki.h> +#include <mach/cvmx-pko3.h> +#include <mach/cvmx-pko3-queue.h> +#include <mach/cvmx-pko3-resources.h> + +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> + +#include <mach/cvmx-helper-bgx.h> +#include <mach/cvmx-helper-cfg.h> +#include <mach/cvmx-helper-util.h> +#include <mach/cvmx-helper-pki.h> + +/* Smalles Round-Robin quantum to use +1 */ +#define CVMX_PKO3_RR_QUANTUM_MIN 0x10 + +static int debug;/* 1 for basic, 2 for detailed trace */ + +struct cvmx_pko3_dq { +unsigned dq_count :6 ;/* Number of descriptor queues */ +unsigned dq_base :10 ;/* Descriptor queue start number */ +#define CVMX_PKO3_SWIZZLE_IPD 0x0 +}; + +/* +* @INTERNAL +* Descriptor Queue to IPD port mapping table. +* +* This pointer is per-core, contains the virtual address +* of a global named block which has 2^12 entries per each +* possible node. +*/ +struct cvmx_pko3_dq *__cvmx_pko3_dq_table; + +int cvmx_pko3_get_queue_base (int ipd_port) +{ +struct cvmx_pko3_dq *dq_table; +int ret =-1 ; +unsigned int i; +struct cvmx_xport xp =cvmx_helper_ipd_port_to_xport (ipd_port); + +/* get per-node table */ +if (cvmx_unlikely (!__cvmx_pko3_dq_table)) +__cvmx_pko3_dq_table_setup (); + + i =CVMX_PKO3_SWIZZLE_IPD ^ xp.port; + +/* get per-node table */ + dq_table = __cvmx_pko3_dq_table +CVMX_PKO3_IPD_NUM_MAX * xp.node; + +if (cvmx_likely (dq_table[i].dq_count >0 )) + ret = xp.node <<10 | dq_table[i].dq_base; +else if (debug) +cvmx_printf ("ERROR: %s: no queues for ipd_port=%#x\n" , __func__, + ipd_port); + +return ret; +} + +int cvmx_pko3_get_queue_num (int ipd_port) +{ +struct cvmx_pko3_dq *dq_table; +int ret =-1 ; +unsigned int i; +struct cvmx_xport xp =cvmx_helper_ipd_port_to_xport (ipd_port); + +/* get per-node table */ +if (cvmx_unlikely (!__cvmx_pko3_dq_table)) +__cvmx_pko3_dq_table_setup (); + + i =CVMX_PKO3_SWIZZLE_IPD ^ xp.port; + +/* get per-node table */ + dq_table = __cvmx_pko3_dq_table +CVMX_PKO3_IPD_NUM_MAX * xp.node; + +if (cvmx_likely (dq_table[i].dq_count >0 )) + ret = dq_table[i].dq_count; +else if (debug) +debug ("ERROR: %s: no queues for ipd_port=%#x\n" , __func__, + ipd_port); + +return ret; +} + +/** +* Get L1/Port Queue number assigned to interface port. +* +* @param xiface is interface number. +* @param index is port index. +*/ +int cvmx_pko3_get_port_queue (int xiface,int index) +{ +int queue; +cvmx_pko_l1_sqx_topology_t qtop; +int mac =__cvmx_pko3_get_mac_num (xiface, index); +int nqueues =cvmx_pko3_num_level_queues (CVMX_PKO_PORT_QUEUES ); +cvmx_xiface_t xi =cvmx_helper_xiface_to_node_interface (xiface); + +for (queue =0 ; queue < nqueues; queue++) { + qtop.u64 = +csr_rd_node (xi.node,CVMX_PKO_L1_SQX_TOPOLOGY (queue)); +if (qtop.s.link == mac) +break ; + } +if (queue >= nqueues) +return -1 ; +return queue; +} + +/** +* @INTERNAL +* +* Initialize port/dq table contents +*/ +static void __cvmx_pko3_dq_table_init (void *ptr) +{ +unsigned int size =sizeof (struct cvmx_pko3_dq ) * +CVMX_PKO3_IPD_NUM_MAX *CVMX_MAX_NODES ; + +memset (ptr,0 , size); +} + +/** +* @INTERNAL +* +* Find or allocate global port/dq map table +* which is a named table, contains entries for +* all possible OCI nodes. +* +* The table global pointer is stored in core-local variable +* so that every core will call this function once, on first use. +*/ +int __cvmx_pko3_dq_table_setup (void ) +{ +void *ptr; + + ptr =cvmx_bootmem_alloc_named_range_once ( +/* size */ +sizeof (struct cvmx_pko3_dq ) *CVMX_PKO3_IPD_NUM_MAX * +CVMX_MAX_NODES , +/* min_addr, max_addr, align */ +0ull ,0ull ,sizeof (struct cvmx_pko3_dq ), +/* name */ +"cvmx_pko3_global_dq_table" , __cvmx_pko3_dq_table_init); + +if (debug) +debug ("%s: dq_table_ptr=%p\n" , __func__, ptr); + +if (!ptr) +return -1 ; + + __cvmx_pko3_dq_table = ptr; +return 0 ; +} + +/* +* @INTERNAL +* Register a range of Descriptor Queues with an interface port +* +* This function populates the DQ-to-IPD translation table +* used by the application to retrieve the DQ range (typically ordered +* by priority) for a given IPD-port, which is either a physical port, +* or a channel on a channelized interface (i.e. ILK). +* +* @param xiface is the physical interface number +* @param index is either a physical port on an interface +* or a channel of an ILK interface +* @param dq_base is the first Descriptor Queue number in a consecutive range +* @param dq_count is the number of consecutive Descriptor Queues leading +* the same channel or port. +* +* Only a consecutive range of Descriptor Queues can be associated with any +* given channel/port, and usually they are ordered from most to least +* in terms of scheduling priority. +* +* Note: thus function only populates the node-local translation table. +* NOTE: This function would be cleaner if it had a single ipd_port argument +* +* @returns 0 on success, -1 on failure. +*/ +int __cvmx_pko3_ipd_dq_register (int xiface,int index,unsigned int dq_base, +unsigned int dq_count) +{ +struct cvmx_pko3_dq *dq_table; +int ipd_port; +unsigned int i; +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); +struct cvmx_xport xp; + +if (__cvmx_helper_xiface_is_null (xiface)) { + ipd_port =cvmx_helper_node_to_ipd_port (xi.node, +CVMX_PKO3_IPD_PORT_NULL ); + }else { +int p; + + p =cvmx_helper_get_ipd_port (xiface, index); +if (p <0 ) { +cvmx_printf ("ERROR: %s: xiface %#x has no IPD port\n" , + __func__, xiface); +return -1 ; + } + ipd_port = p; + } + + xp =cvmx_helper_ipd_port_to_xport (ipd_port); + + i =CVMX_PKO3_SWIZZLE_IPD ^ xp.port; + +/* get per-node table */ +if (!__cvmx_pko3_dq_table) +__cvmx_pko3_dq_table_setup (); + + dq_table = __cvmx_pko3_dq_table +CVMX_PKO3_IPD_NUM_MAX * xi.node; + +if (debug) +debug ("%s: ipd_port=%#x ix=%#x dq %u cnt %u\n" , __func__, + ipd_port, i, dq_base, dq_count); + +/* Check the IPD port has not already been configured */ +if (dq_table[i].dq_count >0 ) { +cvmx_printf ("%s: ERROR: IPD %#x already registered\n" , __func__, + ipd_port); +return -1 ; + } + +/* Store DQ# range in the queue lookup table */ + dq_table[i].dq_base = dq_base; + dq_table[i].dq_count = dq_count; + +return 0 ; +} + +/** +* @INTERNAL +* +* Unregister DQs associated with CHAN_E (IPD port) +* +* NOTE: This function would be cleaner if it had a single ipd_port argument +*/ +int __cvmx_pko3_ipd_dq_unregister (int xiface,int index) +{ +struct cvmx_pko3_dq *dq_table; +int ipd_port; +unsigned int i; +struct cvmx_xport xp; +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); + +if (__cvmx_helper_xiface_is_null (xiface)) { + ipd_port =cvmx_helper_node_to_ipd_port (xi.node, +CVMX_PKO3_IPD_PORT_NULL ); + }else { +int p; + + p =cvmx_helper_get_ipd_port (xiface, index); +if (p <0 ) { +cvmx_printf ("ERROR: %s: xiface %#x has no IPD port\n" , + __func__, xiface); +return -1 ; + } + ipd_port = p; + } + + xp =cvmx_helper_ipd_port_to_xport (ipd_port); + + i =CVMX_PKO3_SWIZZLE_IPD ^ xp.port; + +/* get per-node table */ +if (!__cvmx_pko3_dq_table) +__cvmx_pko3_dq_table_setup (); + +/* get per-node table */ + dq_table = __cvmx_pko3_dq_table +CVMX_PKO3_IPD_NUM_MAX * xi.node; + +if (dq_table[i].dq_count ==0 ) { +cvmx_printf ("WARNING: %s:ipd=%#x already released\n" , __func__, + ipd_port); +return -1 ; + } + +if (debug) +debug ("%s:ipd_port=%#x release dq %u cnt %u\n" , __func__, + ipd_port, dq_table[i].dq_base, dq_table[i].dq_count); + + dq_table[i].dq_count =0 ; + +return 0 ; +} + +/* +* @INTERNAL +* Convert normal CHAN_E (i.e. IPD port) value to compressed channel form +* that is used to populate PKO_LUT. +* +* Note: This code may be model specific. +*/ +static int cvmx_pko3_chan_2_xchan (uint16_t ipd_port) +{ +u16 xchan; +u8 off; +static const u8 *xchan_base; +static const u8 xchan_base_cn78xx[16 ] = { +/* IPD 0x000 */ 0x3c0 >>4 ,/* LBK */ +/* IPD 0x100 */ 0x380 >>4 ,/* DPI */ +/* IPD 0x200 */ 0xfff >>4 ,/* not used */ +/* IPD 0x300 */ 0xfff >>4 ,/* not used */ +/* IPD 0x400 */ 0x000 >>4 ,/* ILK0 */ +/* IPD 0x500 */ 0x100 >>4 ,/* ILK1 */ +/* IPD 0x600 */ 0xfff >>4 ,/* not used */ +/* IPD 0x700 */ 0xfff >>4 ,/* not used */ +/* IPD 0x800 */ 0x200 >>4 ,/* BGX0 */ +/* IPD 0x900 */ 0x240 >>4 ,/* BGX1 */ +/* IPD 0xa00 */ 0x280 >>4 ,/* BGX2 */ +/* IPD 0xb00 */ 0x2c0 >>4 ,/* BGX3 */ +/* IPD 0xc00 */ 0x300 >>4 ,/* BGX4 */ +/* IPD 0xd00 */ 0x340 >>4 ,/* BGX5 */ +/* IPD 0xe00 */ 0xfff >>4 ,/* not used */ +/* IPD 0xf00 */ 0xfff >>4 /* not used */ + }; +static const u8 xchan_base_cn73xx[16 ] = { +/* IPD 0x000 */ 0x0c0 >>4 ,/* LBK */ +/* IPD 0x100 */ 0x100 >>4 ,/* DPI */ +/* IPD 0x200 */ 0xfff >>4 ,/* not used */ +/* IPD 0x300 */ 0xfff >>4 ,/* not used */ +/* IPD 0x400 */ 0xfff >>4 ,/* not used */ +/* IPD 0x500 */ 0xfff >>4 ,/* not used */ +/* IPD 0x600 */ 0xfff >>4 ,/* not used */ +/* IPD 0x700 */ 0xfff >>4 ,/* not used */ +/* IPD 0x800 */ 0x000 >>4 ,/* BGX0 */ +/* IPD 0x900 */ 0x040 >>4 ,/* BGX1 */ +/* IPD 0xa00 */ 0x080 >>4 ,/* BGX2 */ +/* IPD 0xb00 */ 0xfff >>4 ,/* not used */ +/* IPD 0xc00 */ 0xfff >>4 ,/* not used */ +/* IPD 0xd00 */ 0xfff >>4 ,/* not used */ +/* IPD 0xe00 */ 0xfff >>4 ,/* not used */ +/* IPD 0xf00 */ 0xfff >>4 /* not used */ + }; +static const u8 xchan_base_cn75xx[16 ] = { +/* IPD 0x000 */ 0x040 >>4 ,/* LBK */ +/* IPD 0x100 */ 0x080 >>4 ,/* DPI */ +/* IPD 0x200 */ 0xeee >>4 ,/* SRIO0 noop */ +/* IPD 0x300 */ 0xfff >>4 ,/* not used */ +/* IPD 0x400 */ 0xfff >>4 ,/* not used */ +/* IPD 0x500 */ 0xfff >>4 ,/* not used */ +/* IPD 0x600 */ 0xfff >>4 ,/* not used */ +/* IPD 0x700 */ 0xfff >>4 ,/* not used */ +/* IPD 0x800 */ 0x000 >>4 ,/* BGX0 */ +/* IPD 0x900 */ 0xfff >>4 ,/* not used */ +/* IPD 0xa00 */ 0xfff >>4 ,/* not used */ +/* IPD 0xb00 */ 0xfff >>4 ,/* not used */ +/* IPD 0xc00 */ 0xfff >>4 ,/* not used */ +/* IPD 0xd00 */ 0xfff >>4 ,/* not used */ +/* IPD 0xe00 */ 0xfff >>4 ,/* not used */ +/* IPD 0xf00 */ 0xfff >>4 /* not used */ + }; + +if (OCTEON_IS_MODEL (OCTEON_CN73XX )) + xchan_base = xchan_base_cn73xx; +if (OCTEON_IS_MODEL (OCTEON_CNF75XX )) + xchan_base = xchan_base_cn75xx; +if (OCTEON_IS_MODEL (OCTEON_CN78XX )) + xchan_base = xchan_base_cn78xx; + +if (!xchan_base) +return -1 ; + + xchan = ipd_port >>8 ; + +/* ILKx, DPI has 8 bits logical channels, others just 6 */ +if (((xchan &0xfe ) ==0x04 ) || xchan ==0x01 ) + off = ipd_port &0xff ; +else + off = ipd_port &0x3f ; + + xchan = xchan_base[xchan &0xf ]; + +if (xchan ==0xff ) +return -1 ;/* Invalid IPD_PORT */ +else if (xchan ==0xee ) +return -2 ;/* LUT not used */ +else +return (xchan <<4 ) | off; +} + +/* +* Map channel number in PKO +* +* @param node is to specify the node to which this configuration is applied. +* @param pq_num specifies the Port Queue (i.e. L1) queue number. +* @param l2_l3_q_num specifies L2/L3 queue number. +* @param channel specifies the channel number to map to the queue. +* +* The channel assignment applies to L2 or L3 Shaper Queues depending +* on the setting of channel credit level. +* +* @return returns none. +*/ +void cvmx_pko3_map_channel (unsigned int node,unsigned int pq_num, +unsigned int l2_l3_q_num,uint16_t channel) +{ +union cvmx_pko_l3_l2_sqx_channel sqx_channel; +cvmx_pko_lutx_t lutx; +int xchan; + + sqx_channel.u64 = +csr_rd_node (node,CVMX_PKO_L3_L2_SQX_CHANNEL (l2_l3_q_num)); + + sqx_channel.s.cc_channel = channel; + +csr_wr_node (node,CVMX_PKO_L3_L2_SQX_CHANNEL (l2_l3_q_num), + sqx_channel.u64); + +/* Convert CHAN_E into compressed channel */ + xchan =cvmx_pko3_chan_2_xchan (channel); + +if (debug) +debug ("%s: ipd_port=%#x xchan=%#x\n" , __func__, channel, xchan); + +if (xchan <0 ) { +if (xchan ==-1 ) +cvmx_printf ("%s: ERROR: channel %#x not recognized\n" , + __func__, channel); +return ; + } + + lutx.u64 =0 ; + lutx.s.valid =1 ; + lutx.s.pq_idx = pq_num; + lutx.s.queue_number = l2_l3_q_num; + +csr_wr_node (node,CVMX_PKO_LUTX (xchan), lutx.u64); + +if (debug) +debug ("%s: channel %#x (compressed=%#x) mapped L2/L3 SQ=%u, PQ=%u\n" , + __func__, channel, xchan, l2_l3_q_num, pq_num); +} + +/* +* @INTERNAL +* This function configures port queue scheduling and topology parameters +* in hardware. +* +* @param node is to specify the node to which this configuration is applied. +* @param port_queue is the port queue number to be configured. +* @param mac_num is the mac number of the mac that will be tied to this port_queue. +*/ +static void cvmx_pko_configure_port_queue (int node,int port_queue,int mac_num) +{ +cvmx_pko_l1_sqx_topology_t pko_l1_topology; +cvmx_pko_l1_sqx_shape_t pko_l1_shape; +cvmx_pko_l1_sqx_link_t pko_l1_link; + + pko_l1_topology.u64 =0 ; + pko_l1_topology.s.link = mac_num; +csr_wr_node (node,CVMX_PKO_L1_SQX_TOPOLOGY (port_queue), + pko_l1_topology.u64); + + pko_l1_shape.u64 =0 ; + pko_l1_shape.s.link = mac_num; +csr_wr_node (node,CVMX_PKO_L1_SQX_SHAPE (port_queue), pko_l1_shape.u64); + + pko_l1_link.u64 =0 ; + pko_l1_link.s.link = mac_num; +csr_wr_node (node,CVMX_PKO_L1_SQX_LINK (port_queue), pko_l1_link.u64); +} + +/* +* @INTERNAL +* This function configures level 2 queues scheduling and topology parameters +* in hardware. +* +* @param node is to specify the node to which this configuration is applied. +* @param queue is the level3 queue number to be configured. +* @param parent_queue is the parent queue at next level for this l3 queue. +* @param prio is this queue's priority in parent's scheduler. +* @param rr_quantum is this queue's round robin quantum value. +* @param child_base is the first child queue number in the static prioriy children. +* @param child_rr_prio is the round robin children priority. +*/ +static void cvmx_pko_configure_l2_queue (int node,int queue,int parent_queue, +int prio,int rr_quantum, +int child_base,int child_rr_prio) +{ +cvmx_pko_l2_sqx_schedule_t pko_sq_sched; +cvmx_pko_l2_sqx_topology_t pko_child_topology; +cvmx_pko_l1_sqx_topology_t pko_parent_topology; + +/* parent topology configuration */ + pko_parent_topology.u64 = +csr_rd_node (node,CVMX_PKO_L1_SQX_TOPOLOGY (parent_queue)); + pko_parent_topology.s.prio_anchor = child_base; + pko_parent_topology.s.rr_prio = child_rr_prio; +csr_wr_node (node,CVMX_PKO_L1_SQX_TOPOLOGY (parent_queue), + pko_parent_topology.u64); + +if (debug >1 ) +debug ("CVMX_PKO_L1_SQX_TOPOLOGY(%u): PRIO_ANCHOR=%u PARENT=%u\n" , + parent_queue, pko_parent_topology.s.prio_anchor, + pko_parent_topology.s.link); + +/* scheduler configuration for this sq in the parent queue */ + pko_sq_sched.u64 =0 ; + pko_sq_sched.s.prio = prio; + pko_sq_sched.s.rr_quantum = rr_quantum; +csr_wr_node (node,CVMX_PKO_L2_SQX_SCHEDULE (queue), pko_sq_sched.u64); + +/* child topology configuration */ + pko_child_topology.u64 =0 ; + pko_child_topology.s.parent = parent_queue; +csr_wr_node (node,CVMX_PKO_L2_SQX_TOPOLOGY (queue), + pko_child_topology.u64); +} + +/* +* @INTERNAL +* This function configures level 3 queues scheduling and topology parameters +* in hardware. +* +* @param node is to specify the node to which this configuration is applied. +* @param queue is the level3 queue number to be configured. +* @param parent_queue is the parent queue at next level for this l3 queue. +* @param prio is this queue's priority in parent's scheduler. +* @param rr_quantum is this queue's round robin quantum value. +* @param child_base is the first child queue number in the static prioriy children. +* @param child_rr_prio is the round robin children priority. +*/ +static void cvmx_pko_configure_l3_queue (int node,int queue,int parent_queue, +int prio,int rr_quantum, +int child_base,int child_rr_prio) +{ +cvmx_pko_l3_sqx_schedule_t pko_sq_sched; +cvmx_pko_l3_sqx_topology_t pko_child_topology; +cvmx_pko_l2_sqx_topology_t pko_parent_topology; + +/* parent topology configuration */ + pko_parent_topology.u64 = +csr_rd_node (node,CVMX_PKO_L2_SQX_TOPOLOGY (parent_queue)); + pko_parent_topology.s.prio_anchor = child_base; + pko_parent_topology.s.rr_prio = child_rr_prio; +csr_wr_node (node,CVMX_PKO_L2_SQX_TOPOLOGY (parent_queue), + pko_parent_topology.u64); + +if (debug >1 ) +debug ("CVMX_PKO_L2_SQX_TOPOLOGY(%u): PRIO_ANCHOR=%u PARENT=%u\n" , + parent_queue, pko_parent_topology.s.prio_anchor, + pko_parent_topology.s.parent); + +/* scheduler configuration for this sq in the parent queue */ + pko_sq_sched.u64 =0 ; + pko_sq_sched.s.prio = prio; + pko_sq_sched.s.rr_quantum = rr_quantum; +csr_wr_node (node,CVMX_PKO_L3_SQX_SCHEDULE (queue), pko_sq_sched.u64); + +/* child topology configuration */ + pko_child_topology.u64 =0 ; + pko_child_topology.s.parent = parent_queue; +csr_wr_node (node,CVMX_PKO_L3_SQX_TOPOLOGY (queue), + pko_child_topology.u64); +} + +/* +* @INTERNAL +* This function configures level 4 queues scheduling and topology parameters +* in hardware. +* +* @param node is to specify the node to which this configuration is applied. +* @param queue is the level4 queue number to be configured. +* @param parent_queue is the parent queue at next level for this l4 queue. +* @param prio is this queue's priority in parent's scheduler. +* @param rr_quantum is this queue's round robin quantum value. +* @param child_base is the first child queue number in the static prioriy children. +* @param child_rr_prio is the round robin children priority. +*/ +static void cvmx_pko_configure_l4_queue (int node,int queue,int parent_queue, +int prio,int rr_quantum, +int child_base,int child_rr_prio) +{ +cvmx_pko_l4_sqx_schedule_t pko_sq_sched; +cvmx_pko_l4_sqx_topology_t pko_child_topology; +cvmx_pko_l3_sqx_topology_t pko_parent_topology; + +/* parent topology configuration */ + pko_parent_topology.u64 = +csr_rd_node (node,CVMX_PKO_L3_SQX_TOPOLOGY (parent_queue)); + pko_parent_topology.s.prio_anchor = child_base; + pko_parent_topology.s.rr_prio = child_rr_prio; +csr_wr_node (node,CVMX_PKO_L3_SQX_TOPOLOGY (parent_queue), + pko_parent_topology.u64); + +if (debug >1 ) +debug ("CVMX_PKO_L3_SQX_TOPOLOGY(%u): PRIO_ANCHOR=%u PARENT=%u\n" , + parent_queue, pko_parent_topology.s.prio_anchor, + pko_parent_topology.s.parent); + +/* scheduler configuration for this sq in the parent queue */ + pko_sq_sched.u64 =0 ; + pko_sq_sched.s.prio = prio; + pko_sq_sched.s.rr_quantum = rr_quantum; +csr_wr_node (node,CVMX_PKO_L4_SQX_SCHEDULE (queue), pko_sq_sched.u64); + +/* topology configuration */ + pko_child_topology.u64 =0 ; + pko_child_topology.s.parent = parent_queue; +csr_wr_node (node,CVMX_PKO_L4_SQX_TOPOLOGY (queue), + pko_child_topology.u64); +} + +/* +* @INTERNAL +* This function configures level 5 queues scheduling and topology parameters +* in hardware. +* +* @param node is to specify the node to which this configuration is applied. +* @param queue is the level5 queue number to be configured. +* @param parent_queue is the parent queue at next level for this l5 queue. +* @param prio is this queue's priority in parent's scheduler. +* @param rr_quantum is this queue's round robin quantum value. +* @param child_base is the first child queue number in the static prioriy children. +* @param child_rr_prio is the round robin children priority. +*/ +static void cvmx_pko_configure_l5_queue (int node,int queue,int parent_queue, +int prio,int rr_quantum, +int child_base,int child_rr_prio) +{ +cvmx_pko_l5_sqx_schedule_t pko_sq_sched; +cvmx_pko_l4_sqx_topology_t pko_parent_topology; +cvmx_pko_l5_sqx_topology_t pko_child_topology; + +/* parent topology configuration */ + pko_parent_topology.u64 = +csr_rd_node (node,CVMX_PKO_L4_SQX_TOPOLOGY (parent_queue)); + pko_parent_topology.s.prio_anchor = child_base; + pko_parent_topology.s.rr_prio = child_rr_prio; +csr_wr_node (node,CVMX_PKO_L4_SQX_TOPOLOGY (parent_queue), + pko_parent_topology.u64); + +if (debug >1 ) +debug ("CVMX_PKO_L4_SQX_TOPOLOGY(%u): PRIO_ANCHOR=%u PARENT=%u\n" , + parent_queue, pko_parent_topology.s.prio_anchor, + pko_parent_topology.s.parent); + +/* scheduler configuration for this sq in the parent queue */ + pko_sq_sched.u64 =0 ; + pko_sq_sched.s.prio = prio; + pko_sq_sched.s.rr_quantum = rr_quantum; +csr_wr_node (node,CVMX_PKO_L5_SQX_SCHEDULE (queue), pko_sq_sched.u64); + +/* topology configuration */ + pko_child_topology.u64 =0 ; + pko_child_topology.s.parent = parent_queue; +csr_wr_node (node,CVMX_PKO_L5_SQX_TOPOLOGY (queue), + pko_child_topology.u64); +} + +/* +* @INTERNAL +* This function configures descriptor queues scheduling and topology parameters +* in hardware. +* +* @param node is to specify the node to which this configuration is applied. +* @param dq is the descriptor queue number to be configured. +* @param parent_queue is the parent queue at next level for this dq. +* @param prio is this queue's priority in parent's scheduler. +* @param rr_quantum is this queue's round robin quantum value. +* @param child_base is the first child queue number in the static prioriy children. +* @param child_rr_prio is the round robin children priority. +*/ +static void cvmx_pko_configure_dq (int node,int dq,int parent_queue,int prio, +int rr_quantum,int child_base, +int child_rr_prio) +{ +cvmx_pko_dqx_schedule_t pko_dq_sched; +cvmx_pko_dqx_topology_t pko_dq_topology; +cvmx_pko_l5_sqx_topology_t pko_parent_topology; +cvmx_pko_dqx_wm_ctl_t pko_dq_wm_ctl; +unsigned long long parent_topology_reg; +char lvl; + +if (debug) +debug ("%s: dq %u parent %u child_base %u\n" , __func__, dq, + parent_queue, child_base); + +if (__cvmx_pko3_sq_lvl_max () ==CVMX_PKO_L5_QUEUES ) { + parent_topology_reg =CVMX_PKO_L5_SQX_TOPOLOGY (parent_queue); + lvl =5 ; + }else if (__cvmx_pko3_sq_lvl_max () ==CVMX_PKO_L3_QUEUES ) { + parent_topology_reg =CVMX_PKO_L3_SQX_TOPOLOGY (parent_queue); + lvl =3 ; + }else { +return ; + } + +if (debug) +debug ("%s: parent_topology_reg=%#llx\n" , __func__, + parent_topology_reg); + +/* parent topology configuration */ + pko_parent_topology.u64 =csr_rd_node (node, parent_topology_reg); + pko_parent_topology.s.prio_anchor = child_base; + pko_parent_topology.s.rr_prio = child_rr_prio; +csr_wr_node (node, parent_topology_reg, pko_parent_topology.u64); + +if (debug >1 ) +debug ("CVMX_PKO_L%d_SQX_TOPOLOGY(%u): PRIO_ANCHOR=%u PARENT=%u\n" , + lvl, parent_queue, pko_parent_topology.s.prio_anchor, + pko_parent_topology.s.parent); + +/* scheduler configuration for this dq in the parent queue */ + pko_dq_sched.u64 =0 ; + pko_dq_sched.s.prio = prio; + pko_dq_sched.s.rr_quantum = rr_quantum; +csr_wr_node (node,CVMX_PKO_DQX_SCHEDULE (dq), pko_dq_sched.u64); + +/* topology configuration */ + pko_dq_topology.u64 =0 ; + pko_dq_topology.s.parent = parent_queue; +csr_wr_node (node,CVMX_PKO_DQX_TOPOLOGY (dq), pko_dq_topology.u64); + +/* configure for counting packets, not bytes at this level */ + pko_dq_wm_ctl.u64 =0 ; + pko_dq_wm_ctl.s.kind =1 ; + pko_dq_wm_ctl.s.enable =0 ; +csr_wr_node (node,CVMX_PKO_DQX_WM_CTL (dq), pko_dq_wm_ctl.u64); + +if (debug >1 ) { + pko_dq_sched.u64 =csr_rd_node (node,CVMX_PKO_DQX_SCHEDULE (dq)); + pko_dq_topology.u64 = +csr_rd_node (node,CVMX_PKO_DQX_TOPOLOGY (dq)); +debug ("CVMX_PKO_DQX_TOPOLOGY(%u)PARENT=%u CVMX_PKO_DQX_SCHEDULE(%u) PRIO=%u Q=%u\n" , + dq, pko_dq_topology.s.parent, dq, pko_dq_sched.s.prio, + pko_dq_sched.s.rr_quantum); + } +} + +/* +* @INTERNAL +* The following structure selects the Scheduling Queue configuration +* routine for each of the supported levels. +* The initial content of the table will be setup in accordance +* to the specific SoC model and its implemented resources +*/ +struct pko3_cfg_tab_s { +/* function pointer for to configure the given level, last=DQ */ +struct { +u8 parent_level; +void (*cfg_sq_func)(int node,int queue,int parent_queue, +int prio,int rr_quantum,int child_base, +int child_rr_prio); +//XXX for debugging exagerated size + } lvl[256 ]; +}; + +static const struct pko3_cfg_tab_s pko3_cn78xx_cfg = { + { [CVMX_PKO_L2_QUEUES ] = {CVMX_PKO_PORT_QUEUES , + cvmx_pko_configure_l2_queue }, + [CVMX_PKO_L3_QUEUES ] = {CVMX_PKO_L2_QUEUES , + cvmx_pko_configure_l3_queue }, + [CVMX_PKO_L4_QUEUES ] = {CVMX_PKO_L3_QUEUES , + cvmx_pko_configure_l4_queue }, + [CVMX_PKO_L5_QUEUES ] = {CVMX_PKO_L4_QUEUES , + cvmx_pko_configure_l5_queue }, + [CVMX_PKO_DESCR_QUEUES ] = {CVMX_PKO_L5_QUEUES , + cvmx_pko_configure_dq } } +}; + +static const struct pko3_cfg_tab_s pko3_cn73xx_cfg = { + { [CVMX_PKO_L2_QUEUES ] = {CVMX_PKO_PORT_QUEUES , + cvmx_pko_configure_l2_queue }, + [CVMX_PKO_L3_QUEUES ] = {CVMX_PKO_L2_QUEUES , + cvmx_pko_configure_l3_queue }, + [CVMX_PKO_DESCR_QUEUES ] = {CVMX_PKO_L3_QUEUES , + cvmx_pko_configure_dq } } +}; + +/* +* Configure Port Queue and its children Scheduler Queue +* +* Port Queues (a.k.a L1) are assigned 1-to-1 to MACs. +* L2 Scheduler Queues are used for specifying channels, and thus there +* could be multiple L2 SQs attached to a single L1 PQ, either in a +* fair round-robin scheduling, or with static and/or round-robin priorities. +* +* @param node on which to operate +* @param mac_num is the LMAC number to that is associated with the Port Queue, +* @param pq_num is the number of the L1 PQ attached to the MAC +* +* @returns 0 on success, -1 on failure. +*/ +int cvmx_pko3_pq_config (unsigned int node,unsigned int mac_num, +unsigned int pq_num) +{ +char b1[10 ]; + +if (debug) +debug ("%s: MAC%u -> %s\n" , __func__, mac_num, +__cvmx_pko3_sq_str (b1,CVMX_PKO_PORT_QUEUES , pq_num)); + +cvmx_pko_configure_port_queue (node, pq_num, mac_num); + +return 0 ; +} + +/* +* Configure L3 through L5 Scheduler Queues and Descriptor Queues +* +* The Scheduler Queues in Levels 3 to 5 and Descriptor Queues are +* configured one-to-one or many-to-one to a single parent Scheduler +* Queues. The level of the parent SQ is specified in an argument, +* as well as the number of childer to attach to the specific parent. +* The children can have fair round-robin or priority-based scheduling +* when multiple children are assigned a single parent. +* +* @param node on which to operate +* @param child_level is the level of the child queue +* @param parent_queue is the number of the parent Scheduler Queue +* @param child_base is the number of the first child SQ or DQ to assign to +* @param child_count is the number of consecutive children to assign +* @param stat_prio_count is the priority setting for the children L2 SQs +* +* If <stat_prio_count> is -1, the Ln children will have equal Round-Robin +* relationship with eachother. If <stat_prio_count> is 0, all Ln children +* will be arranged in Weighted-Round-Robin, with the first having the most +* precedence. If <stat_prio_count> is between 1 and 8, it indicates how +* many children will have static priority settings (with the first having +* the most precedence), with the remaining Ln children having WRR scheduling. +* +* @returns 0 on success, -1 on failure. +* +* Note: this function supports the configuration of node-local unit. +*/ +int cvmx_pko3_sq_config_children (unsigned int node, +enum cvmx_pko3_level_e child_level, +unsigned int parent_queue, +unsigned int child_base, +unsigned int child_count,int stat_prio_count) +{ +enum cvmx_pko3_level_e parent_level; +unsigned int num_elem =0 ; +unsigned int rr_quantum, rr_count; +unsigned int child, prio, rr_prio; +const struct pko3_cfg_tab_s *cfg_tbl =NULL ; +char b1[10 ], b2[10 ]; + +if (OCTEON_IS_MODEL (OCTEON_CN78XX )) { + num_elem =NUM_ELEMENTS (pko3_cn78xx_cfg.lvl); + cfg_tbl = &pko3_cn78xx_cfg; + } +if (OCTEON_IS_MODEL (OCTEON_CN73XX ) ||OCTEON_IS_MODEL (OCTEON_CNF75XX )) { + num_elem =NUM_ELEMENTS (pko3_cn73xx_cfg.lvl); + cfg_tbl = &pko3_cn73xx_cfg; + } + +if (!cfg_tbl || child_level >= num_elem) { +cvmx_printf ("ERROR: %s: model or level %#x invalid\n" , __func__, + child_level); +return -1 ; + } + + parent_level = cfg_tbl->lvl[child_level].parent_level; + +if (!cfg_tbl->lvl[child_level].cfg_sq_func || + cfg_tbl->lvl[child_level].parent_level ==0 ) { +cvmx_printf ("ERROR: %s: queue level %#x invalid\n" , __func__, + child_level); +return -1 ; + } + +/* First static priority is 0 - top precedence */ + prio =0 ; + +if (stat_prio_count > (signed int )child_count) + stat_prio_count = child_count; + +/* Valid PRIO field is 0..9, limit maximum static priorities */ +if (stat_prio_count >9 ) + stat_prio_count =9 ; + +/* Special case of a single child */ +if (child_count ==1 ) { + rr_count =0 ; + rr_prio =0xF ; +/* Special case for Fair-RR */ + }else if (stat_prio_count <0 ) { + rr_count = child_count; + rr_prio =0 ; + }else { + rr_count = child_count - stat_prio_count; + rr_prio = stat_prio_count; + } + +/* Compute highest RR_QUANTUM */ +if (stat_prio_count >0 ) + rr_quantum =CVMX_PKO3_RR_QUANTUM_MIN * rr_count; +else + rr_quantum =CVMX_PKO3_RR_QUANTUM_MIN ; + +if (debug) +debug ("%s: Parent %s child_base %u rr_pri %u\n" , __func__, +__cvmx_pko3_sq_str (b1, parent_level, parent_queue), + child_base, rr_prio); + +/* Parent is configured with child */ + +for (child = child_base; child < (child_base + child_count); child++) { +if (debug) +debug ("%s: Child %s of %s prio %u rr_quantum %#x\n" , + __func__, +__cvmx_pko3_sq_str (b1, child_level, child), +__cvmx_pko3_sq_str (b2, parent_level, + parent_queue), + prio, rr_quantum); + + cfg_tbl->lvl[child_level].cfg_sq_func (node, child, parent_queue, + prio, rr_quantum, + child_base, rr_prio); + +if (prio < rr_prio) + prio++; +else if (stat_prio_count >0 ) + rr_quantum -=CVMX_PKO3_RR_QUANTUM_MIN ; + }/* for child */ + +return 0 ; +} + +/** +* Convert bitrate and burst size to SQx_xIR register values +* +* @INTERNAL +* +* Common function to convert bit-rate (ie kilo-bits-per-sec) +* and maximum burst (in bytes) values to PKO shaper register +* format, that is a short-float type, with divisor. +* +* @param tclk is the time-wheel clock for the specific shaper +* @param reg is a pointer to a register structure +* @param rate_kbips is the requested bit rate in kilobits/sec +* @param burst_bytes is the size of maximum burst in bytes +* +* @return A negative number means the transfer rate could +* not be set within acceptable tolerance, and the actual +* error in PPM is the negative of the returned value. +* A positive value indicates that the bit rate was set +* within acceptable tolerance, but the burst rate had an +* error, which is returned in PPM. +* A value of 0 means both measures were set within tolerance. +* +* Note that the bust error could be as a result of this function +* enforcing the minimum MTU as the minimum burst size allowed. +* +*/ +static int cvmx_pko3_shaper_rate_compute (unsigned long tclk, +cvmx_pko_l1_sqx_cir_t *reg, +unsigned long rate_kbips, +unsigned int burst_bytes) +{ +const unsigned int max_exp =12 ;/* maximum exponent */ +const unsigned int tock_bytes_exp =0 ;/* tock rate in bytes */ +long long burst_v, rate_v; +unsigned long long rate_tocks, burst_tocks; +unsigned long min_burst; +unsigned int div_exp, mant, exp; +unsigned long long tmp, fmax; + +if (debug) +debug ("%s: tclk=%lu, rate=%lu kbps, burst=%u bytes\n" , __func__, + tclk, rate_kbips, burst_bytes); + +/* Convert API args into tocks: PSE native units */ + tmp = (1 << (3 + tock_bytes_exp)) -1 ; + tmp += rate_kbips; + rate_tocks = (1000ULL * tmp) >> (3 + tock_bytes_exp); + tmp = (1 << tock_bytes_exp) -1 ; + burst_tocks = (burst_bytes + tmp) >> tock_bytes_exp; + +/* Compute largest short-float that fits in register fields */ + fmax =CVMX_SHOFT_TO_U64 ((1 <<CVMX_SHOFT_MANT_BITS ) -1 , max_exp); + +/* Find the biggest divider that has the short float fit */ +for (div_exp =0 ; div_exp <= max_exp; div_exp++) { + tmp = ((rate_tocks << div_exp) + (tclk /2 )) / tclk; +if (tmp > fmax) { +if (div_exp >0 ) + div_exp--; +break ; + } + } +/* Make sure divider, rate are within valid range */ +if (div_exp > max_exp) { +/* Minimum reached */ + div_exp = max_exp; + }else if (div_exp ==0 ) { +/* Maximum reached */ +if ((rate_tocks / tclk) > fmax) + rate_tocks = fmax * tclk; + } +/* Store common divider */ + reg->s.rate_divider_exponent = div_exp; + +/* Burst register is the maximum accumulated credit count +* in bytes, which must not be less then the MTU, and +* should not be less than RATE/Tclk +*/ + +/* Find the minimum burst size needed for rate (burst ~ 4x rate) */ + min_burst = (rate_tocks << (div_exp +4 )) / tclk; + +/* Apply the minimum */ +if (burst_tocks < min_burst) + burst_tocks = min_burst; + +/* Calculate the rate short float */ + tmp = (rate_tocks << (div_exp +8 )) / tclk; +CVMX_SHOFT_FROM_U64 (tmp, mant, exp); + reg->s.rate_mantissa = mant; + reg->s.rate_exponent = exp -8 ; + +/* Calculate the BURST short float */ + tmp = (burst_tocks <<8 ); +CVMX_SHOFT_FROM_U64 (tmp, mant, exp); + reg->s.burst_mantissa = mant; + reg->s.burst_exponent = exp -8 -1 ; + +if (debug) +debug ("%s: RATE=%llu BURST=%llu DIV_EXP=%d\n" , __func__, +CVMX_SHOFT_TO_U64 (reg->s.rate_mantissa, + reg->s.rate_exponent), +CVMX_SHOFT_TO_U64 (reg->s.burst_mantissa, + (reg->s.burst_exponent +1 )), + div_exp); + +/* Validate the resulting rate */ + rate_v =CVMX_SHOFT_TO_U64 (reg->s.rate_mantissa, reg->s.rate_exponent) * + tclk; +/* Convert to kbips for comaring with argument */ + rate_v = (rate_v << (3 + tock_bytes_exp)) /1000ULL ; +/* Finally apply divider for best accuracy */ + rate_v >>= div_exp; + + burst_v =CVMX_SHOFT_TO_U64 (reg->s.burst_mantissa, + (reg->s.burst_exponent +1 )); +/* Convert in additional bytes as in argument */ + burst_v = burst_v << (tock_bytes_exp); + +if (debug) +debug ("%s: result rate=%'llu kbips burst=%llu bytes\n" , + __func__, rate_v, burst_v); + +/* Compute error in parts-per-million */ + rate_v =abs (rate_v - rate_kbips); + burst_v =abs (burst_v - burst_bytes); + +if (debug) +debug ("%s: diff rate=%llu burst=%llu ppm\n" , __func__, rate_v, + burst_v); + + rate_v = (rate_v *1000000ULL ) / rate_kbips; +if (burst_bytes >0 ) + burst_v = (burst_v *1000000ULL ) / burst_bytes; +else + burst_v =0 ; + +if (debug) +debug ("%s: error rate=%llu burst=%llu ppm\n" , __func__, rate_v, + burst_v); + +/* Allow 1% error for CIR/PIR, and 5% for BURST */ +if (rate_v >10000 ) +return -rate_v; +if (burst_v >50000 ) +return burst_v; + +return 0 ; +} + +/** +* Configure per-port CIR rate limit parameters +* +* This function configures rate limit at the L1/PQ level, +* i.e. for an entire MAC or physical port. +* +* @param node The OCI node where the target port is located +* @param pq_num The L1/PQ queue number for this setting +* @param rate_kbips The desired throughput in kilo-bits-per-second +* @param burst_bytes The size of a burst in bytes, at least MTU +* +* @return Returns zero if both settings applied within allowed tolerance, +* otherwise the error is returned in parts-per-million. +* 'rate_bps" error is e negative number, otherwise 'birst_rate' error +* is returned as a positive integer. +*/ +int cvmx_pko3_port_cir_set (unsigned int node,unsigned int pq_num, +unsigned long rate_kbips,unsigned int burst_bytes, +int adj_bytes) +{ +unsigned long tclk; +cvmx_pko_l1_sqx_cir_t sqx_cir; +cvmx_pko_l1_sqx_shape_t shape; +int rc; + +if (debug) +debug ("%s: pq=%u rate=%lu kbps, burst=%u bytes\n" , __func__, + pq_num, rate_kbips, burst_bytes); + + sqx_cir.u64 =0 ; + +/* When rate == 0, disable the shaper */ +if (rate_kbips ==0ULL ) { + sqx_cir.s.enable =0 ; +csr_wr_node (node,CVMX_PKO_L1_SQX_CIR (pq_num), sqx_cir.u64); +return 0 ; + } +/* Compute time-wheel frequency */ + tclk =cvmx_pko3_pq_tw_clock_rate_node (node); + +/* Compute shaper values */ + rc =cvmx_pko3_shaper_rate_compute (tclk, &sqx_cir, rate_kbips, + burst_bytes); + +/* Apply new settings */ + sqx_cir.s.enable =1 ; + sqx_cir.s.rate_divider_exponent = sqx_cir.s.rate_divider_exponent; + sqx_cir.s.rate_mantissa = sqx_cir.s.rate_mantissa; + sqx_cir.s.rate_exponent = sqx_cir.s.rate_exponent; + sqx_cir.s.burst_mantissa = sqx_cir.s.burst_mantissa; + sqx_cir.s.burst_exponent = sqx_cir.s.burst_exponent -1 ; +csr_wr_node (node,CVMX_PKO_L1_SQX_CIR (pq_num), sqx_cir.u64); + + shape.u64 =csr_rd_node (node,CVMX_PKO_L1_SQX_SHAPE (pq_num)); + shape.s.adjust = adj_bytes; +csr_wr_node (node,CVMX_PKO_L1_SQX_SHAPE (pq_num), shape.u64); + +return rc; +} + +/** +* Configure per-queue CIR rate limit parameters +* +* This function configures rate limit at the descriptor queue level. +* +* @param node The OCI node where the target port is located +* @param dq_num The descriptor queue number for this setting +* @param rate_kbips The desired throughput in kilo-bits-per-second +* @param burst_bytes The size of a burst in bytes, at least MTU +* +* @return Returns zero if both settings applied within allowed tolerance, +* otherwise the error is returned in parts-per-million. +* 'rate_bps" error is a negative number, otherwise 'birst_rate' error +* is returned as a positive integer. +*/ +int cvmx_pko3_dq_cir_set (unsigned int node,unsigned int dq_num, +unsigned long rate_kbips,unsigned int burst_bytes) +{ +unsigned long tclk; +cvmx_pko_l1_sqx_cir_t sqx_cir; +cvmx_pko_dqx_cir_t dqx_cir; +int rc; + + dq_num &=cvmx_pko3_num_level_queues (CVMX_PKO_DESCR_QUEUES ) -1 ; +if (debug) +debug ("%s: dq=%u rate=%lu kbps, burst=%u bytes\n" , __func__, + dq_num, rate_kbips, burst_bytes); + + dqx_cir.u64 =0 ; + +/* When rate == 0, disable the shaper */ +if (rate_kbips ==0ULL ) { + dqx_cir.s.enable =0 ; +csr_wr_node (node,CVMX_PKO_DQX_CIR (dq_num), dqx_cir.u64); +return 0 ; + } +/* Compute time-wheel frequency */ + tclk =cvmx_pko3_dq_tw_clock_rate_node (node); + +/* Compute shaper values */ + rc =cvmx_pko3_shaper_rate_compute (tclk, &sqx_cir, rate_kbips, + burst_bytes); + +/* Apply new settings */ + dqx_cir.s.enable =1 ; + dqx_cir.s.rate_divider_exponent = sqx_cir.s.rate_divider_exponent; + dqx_cir.s.rate_mantissa = sqx_cir.s.rate_mantissa; + dqx_cir.s.rate_exponent = sqx_cir.s.rate_exponent; + dqx_cir.s.burst_mantissa = sqx_cir.s.burst_mantissa; + dqx_cir.s.burst_exponent = sqx_cir.s.burst_exponent -1 ; +csr_wr_node (node,CVMX_PKO_DQX_CIR (dq_num), dqx_cir.u64); + +return rc; +} + +/** +* Configure per-queue PIR rate limit parameters +* +* This function configures rate limit at the descriptor queue level. +* +* @param node The OCI node where the target port is located +* @param dq_num The descriptor queue number for this setting +* @param rate_kbips The desired throughput in kilo-bits-per-second +* @param burst_bytes The size of a burst in bytes, at least MTU +* +* @return Returns zero if both settings applied within allowed tolerance, +* otherwise the error is returned in parts-per-million. +* 'rate_bps" error is a negative number, otherwise 'birst_rate' error +* is returned as a positive integer. +*/ +int cvmx_pko3_dq_pir_set (unsigned int node,unsigned int dq_num, +unsigned long rate_kbips,unsigned int burst_bytes) +{ +unsigned long tclk; +cvmx_pko_l1_sqx_cir_t sqx_cir; +cvmx_pko_dqx_pir_t dqx_pir; +int rc; + + dq_num &=cvmx_pko3_num_level_queues (CVMX_PKO_DESCR_QUEUES ) -1 ; +if (debug) +debug ("%s: dq=%u rate=%lu kbps, burst=%u bytes\n" , __func__, + dq_num, rate_kbips, burst_bytes); + + dqx_pir.u64 =0 ; + +/* When rate == 0, disable the shaper */ +if (rate_kbips ==0ULL ) { + dqx_pir.s.enable =0 ; +csr_wr_node (node,CVMX_PKO_DQX_PIR (dq_num), dqx_pir.u64); +return 0 ; + } +/* Compute time-wheel frequency */ + tclk =cvmx_pko3_dq_tw_clock_rate_node (node); + +/* Compute shaper values */ + rc =cvmx_pko3_shaper_rate_compute (tclk, &sqx_cir, rate_kbips, + burst_bytes); + +/* Apply new settings */ + dqx_pir.s.enable =1 ; + dqx_pir.s.rate_divider_exponent = sqx_cir.s.rate_divider_exponent; + dqx_pir.s.rate_mantissa = sqx_cir.s.rate_mantissa; + dqx_pir.s.rate_exponent = sqx_cir.s.rate_exponent; + dqx_pir.s.burst_mantissa = sqx_cir.s.burst_mantissa; + dqx_pir.s.burst_exponent = sqx_cir.s.burst_exponent -1 ; +csr_wr_node (node,CVMX_PKO_DQX_PIR (dq_num), dqx_pir.u64); + +return rc; +} + +/** +* Configure per-queue treatment of excess traffic +* +* The default and most sensible behavior is to stall the packets +* colored Red (i.e. exceeding the PIR rate in full 3-color mode). +* There is also the option to discard excess traffic, which is +* the desired action for some applications that do not rely on +* back-pressure flow control. +* The shaper may be programmed to pass the RED packets onwards, +* which may be useful it the color is translated to a change +* in packet priority on egress. +* +* @param node The OCI node where the target port is located +* @param dq_num The descriptor queue number for this setting +* @param red_act The action required for all packets in excess of PIR +* @param len_adjust A 2's complement 8 bit value to add/subtract from +* packet length for the purpose of shaping calculations, e.g. +* a value of -14 will subtract the length of the Ethernet header +* and hence only account IP packet size. +* +* @return N/A +*/ +void cvmx_pko3_dq_red (unsigned int node,unsigned int dq_num, +red_action_t red_act,int8_t len_adjust) +{ +cvmx_pko_dqx_shape_t dqx_shape; + + dq_num &=cvmx_pko3_num_level_queues (CVMX_PKO_DESCR_QUEUES ) -1 ; + dqx_shape.u64 =0 ; + +if (OCTEON_IS_MODEL (OCTEON_CN78XX_PASS1_X )) { +if (len_adjust <0 ) + len_adjust =0 ; + } + dqx_shape.s.adjust = len_adjust; + +switch (red_act) { +default : +case CVMX_PKO3_SHAPE_RED_STALL : + dqx_shape.s.red_algo =0x0 ; +break ; +case CVMX_PKO3_SHAPE_RED_DISCARD : + dqx_shape.s.red_algo =0x3 ; +break ; +case CVMX_PKO3_SHAPE_RED_PASS : + dqx_shape.s.red_algo =0x1 ; +break ; + } +csr_wr_node (node,CVMX_PKO_DQX_SHAPE (dq_num), dqx_shape.u64); +}
Signature · 1 line
2.35.1
PATCH 52/52 mips: octeon: nic23: Enable ethernet support
In reply to Stefan RoeseThis patch enables the Kconfig symbols needed for full ethernet support on the NIC23. Additionally board specific setup is done, mostly GPIOs related to SFP / GPIO configuration. With this, ethernet can be used on this board. Here an example of a tftp load:
=> tftp ffffffff81000000 big
Using ethernet-mac-nexus@11800e2000000 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.247 Filename 'big'.
Load address: 0xffffffff81000000
Loading: ################################################## 10 MiB
9.7 MiB/s
done
Bytes transferred = 10485760 (a00000 hex)
--- board/Marvell/octeon_nic23/board.c | 87 +++++++++++++++++++++++++++++- configs/octeon_nic23_defconfig | 10 +++- 2 files changed, 95 insertions(+), 2 deletions(-)
board/Marvell/octeon_nic23/board.c +86 -1
@@ -1,10 +1,11 @@// SPDX-License-Identifier: GPL-2.0+ /* -* Copyright (C) 2021 Stefan Roese <[email protected]> +* Copyright (C) 2021-2022 Stefan Roese <[email protected]> */ #include <dm.h> #include <ram.h> +#include <asm/gpio.h> #include <mach/octeon_ddr.h> #include <mach/cvmx-qlm.h>
@@ -84,6 +85,52 @@ int board_fix_fdt(void *fdt)return rc; } +int board_early_init_f (void ) +{ +struct gpio_desc gpio = {}; +ofnode node; + +/* Initial GPIO configuration */ + +/* GPIO 7: Vitesse reset */ + node =ofnode_by_compatible (ofnode_null (),"vitesse,vsc7224" ); +if (ofnode_valid (node)) { +gpio_request_by_name_nodev (node,"los" ,0 , &gpio,GPIOD_IS_IN ); +dm_gpio_free (gpio.dev, &gpio); +gpio_request_by_name_nodev (node,"reset" ,0 , &gpio, +GPIOD_IS_OUT ); +if (dm_gpio_is_valid (&gpio)) { +/* Vitesse reset */ +debug ("%s: Setting GPIO 7 to 1\n" , __func__); +dm_gpio_set_value (&gpio,1 ); + } +dm_gpio_free (gpio.dev, &gpio); + } + +/* SFP+ transmitters */ +ofnode_for_each_compatible_node (node,"ethernet,sfp-slot" ) { +gpio_request_by_name_nodev (node,"tx_disable" ,0 , + &gpio,GPIOD_IS_OUT ); +if (dm_gpio_is_valid (&gpio)) { +debug ("%s: Setting GPIO %d to 1\n" , __func__, + gpio.offset); +dm_gpio_set_value (&gpio,1 ); + } +dm_gpio_free (gpio.dev, &gpio); +gpio_request_by_name_nodev (node,"mod_abs" ,0 , &gpio, +GPIOD_IS_IN ); +dm_gpio_free (gpio.dev, &gpio); +gpio_request_by_name_nodev (node,"tx_error" ,0 , &gpio, +GPIOD_IS_IN ); +dm_gpio_free (gpio.dev, &gpio); +gpio_request_by_name_nodev (node,"rx_los" ,0 , &gpio, +GPIOD_IS_IN ); +dm_gpio_free (gpio.dev, &gpio); + } + +return 0 ; +} +void board_configure_qlms (void ) {octeon_configure_qlm (4 ,3000 ,CVMX_QLM_MODE_SATA_2X1 ,0 ,0 ,0 ,0 );
@@ -100,7 +147,45 @@ void board_configure_qlms(void)int board_late_init (void ) { +struct gpio_desc gpio = {}; +ofnode node; + +/* Turn on SFP+ transmitters */ +ofnode_for_each_compatible_node (node,"ethernet,sfp-slot" ) { +gpio_request_by_name_nodev (node,"tx_disable" ,0 , + &gpio,GPIOD_IS_OUT ); +if (dm_gpio_is_valid (&gpio)) { +debug ("%s: Setting GPIO %d to 0\n" , __func__, + gpio.offset); +dm_gpio_set_value (&gpio,0 ); + } +dm_gpio_free (gpio.dev, &gpio); + } +board_configure_qlms ();return 0 ; } + +int last_stage_init (void ) +{ +struct gpio_desc gpio = {}; +ofnode node; + + node =ofnode_by_compatible (ofnode_null (),"vitesse,vsc7224" ); +if (!ofnode_valid (node)) { +printf ("Vitesse SPF DT node not found!" ); +return 0 ; + } + +gpio_request_by_name_nodev (node,"reset" ,0 , &gpio,GPIOD_IS_OUT ); +if (dm_gpio_is_valid (&gpio)) { +/* Take Vitesse retimer out of reset */ +debug ("%s: Setting GPIO 7 to 0\n" , __func__); +dm_gpio_set_value (&gpio,0 ); +mdelay (50 ); + } +dm_gpio_free (gpio.dev, &gpio); + +return 0 ; +}
configs/octeon_nic23_defconfig +9 -1
@@ -12,6 +12,7 @@ CONFIG_ARCH_OCTEON=y CONFIG_TARGET_OCTEON_NIC23=y # CONFIG_MIPS_CACHE_SETUP is not set # CONFIG_MIPS_CACHE_DISABLE is not set +CONFIG_MIPS_RELOCATION_TABLE_SIZE=0xc000 CONFIG_DEBUG_UART=y CONFIG_AHCI=y CONFIG_OF_BOARD_FIXUP=y
@@ -19,7 +20,9 @@ CONFIG_SYS_LOAD_ADDR=0xffffffff80100000 CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y # CONFIG_SYS_DEVICE_NULLDEV is not set CONFIG_ARCH_MISC_INIT=y +CONFIG_BOARD_EARLY_INIT_F=y CONFIG_BOARD_LATE_INIT=y +CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_GPIO=y
@@ -37,6 +40,7 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_EFI_PARTITION=y CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_ENV_ADDR=0xe000 +CONFIG_TFTP_TSIZE=y CONFIG_SATA=y CONFIG_AHCI_MVEBU=y CONFIG_CLK=y
@@ -50,7 +54,11 @@ CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y -# CONFIG_NETDEVICES is not set +CONFIG_PHYLIB=y +CONFIG_PHYLIB_10G=y +CONFIG_DM_MDIO=y +CONFIG_DM_ETH_PHY=y +CONFIG_NET_OCTEON=y CONFIG_PCI=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y
Signature · 1 line
2.35.1
PATCH 47/52 mips: octeon: mrvl, cn73xx.dtsi: Add ethernet (BGX) and SMI DT nodes
In reply to Stefan RoeseAdd the Octeon ethernet (BGX) and SMI DT node to the dtsi file.
--- arch/mips/dts/mrvl,cn73xx.dtsi | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/mips/dts/mrvl,cn73xx.dtsi +35 -0
@@ -267,5 +267,40 @@ interrupts = <0x6c010 4>; }; }; + + /* SMI1 */ + smi1: mdio@1180000003880 { + compatible = "cavium,octeon-3860-mdio"; + reg = <0x11800 0x00003880 0x0 0x40>; + #address-cells = <1>; + #size-cells = <0>; + }; + + /* BGX 0 */ + bgx0: ethernet-mac-nexus@11800e0000000 { + compatible = "cavium,octeon-7890-bgx"; + reg = <0x11800 0xe0000000 0x0 0x1000000>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + /* BGX 1 */ + bgx1: ethernet-mac-nexus@11800e1000000 { + compatible = "cavium,octeon-7890-bgx"; + reg = <0x11800 0xe1000000 0x0 0x1000000>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + /* BGX 2*/ + bgx2: ethernet-mac-nexus@11800e2000000 { + compatible = "cavium,octeon-7890-bgx"; + reg = <0x11800 0xe2000000 0x0 0x1000000>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; }; };
Signature · 1 line
2.35.1
PATCH 39/52 mips: octeon: Add cvmx-pko-internal-ports-range.c
In reply to Stefan RoeseFrom: Aaron Williams <[email protected]>
Import cvmx-pko-internal-ports-range.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.
--- .../cvmx-pko-internal-ports-range.c | 164 ++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 arch/mips/mach-octeon/cvmx-pko-internal-ports-range.c
arch/mips/mach-octeon/cvmx-pko-internal-ports-range.c new file +164 -0
@@ -0,0 +1,164 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2018-2022 Marvell International Ltd. +*/ + +#include <errno.h> +#include <log.h> +#include <time.h> +#include <linux/delay.h> + +#include <mach/cvmx-regs.h> +#include <mach/cvmx-csr.h> +#include <mach/cvmx-bootmem.h> +#include <mach/octeon-model.h> +#include <mach/cvmx-fuse.h> +#include <mach/octeon-feature.h> +#include <mach/cvmx-qlm.h> +#include <mach/octeon_qlm.h> +#include <mach/cvmx-pcie.h> +#include <mach/cvmx-coremask.h> +#include <mach/cvmx-range.h> +#include <mach/cvmx-global-resources.h> + +#include <mach/cvmx-agl-defs.h> +#include <mach/cvmx-bgxx-defs.h> +#include <mach/cvmx-ciu-defs.h> +#include <mach/cvmx-gmxx-defs.h> +#include <mach/cvmx-gserx-defs.h> +#include <mach/cvmx-ilk-defs.h> +#include <mach/cvmx-ipd-defs.h> +#include <mach/cvmx-pcsx-defs.h> +#include <mach/cvmx-pcsxx-defs.h> +#include <mach/cvmx-pki-defs.h> +#include <mach/cvmx-pko-defs.h> +#include <mach/cvmx-xcv-defs.h> + +#include <mach/cvmx-hwpko.h> +#include <mach/cvmx-ilk.h> +#include <mach/cvmx-ipd.h> +#include <mach/cvmx-pki.h> +#include <mach/cvmx-pko3.h> +#include <mach/cvmx-pko3-queue.h> +#include <mach/cvmx-pko3-resources.h> + +#include <mach/cvmx-helper.h> +#include <mach/cvmx-helper-board.h> +#include <mach/cvmx-helper-cfg.h> + +#include <mach/cvmx-helper-bgx.h> +#include <mach/cvmx-helper-cfg.h> +#include <mach/cvmx-helper-util.h> +#include <mach/cvmx-helper-pki.h> + +union interface_port { +struct { +int port; +int interface; + } s; +u64 u64; +}; + +static int dbg; + +static int port_range_init; + +int __cvmx_pko_internal_ports_range_init (void ) +{ +int rv =0 ; + +if (port_range_init) +return 0 ; + port_range_init =1 ; + rv =cvmx_create_global_resource_range (CVMX_GR_TAG_PKO_IPORTS , +CVMX_HELPER_CFG_MAX_PKO_QUEUES ); +if (rv !=0 ) +debug ("ERROR : Failed to initialize pko internal port range\n" ); +return rv; +} + +int cvmx_pko_internal_ports_alloc (int xiface,int port,u64 count) +{ +int ret_val =-1 ; +union interface_port inf_port; +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); + +__cvmx_pko_internal_ports_range_init (); + inf_port.s.interface = xi.interface; + inf_port.s.port = port; + ret_val =cvmx_allocate_global_resource_range (CVMX_GR_TAG_PKO_IPORTS , + inf_port.u64, count,1 ); +if (dbg) +debug ("internal port alloc : port=%02d base=%02d count=%02d\n" , + (int )port, ret_val, (int )count); +if (ret_val ==-1 ) +return ret_val; + cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_port_base = ret_val; + cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_num_ports = count; +return 0 ; +} + +/* +* Return the internal ports base +* +* @param port the port for which the queues are returned +* +* @return 0 on success +* -1 on failure +*/ +int cvmx_pko_internal_ports_free (int xiface,int port) +{ +struct cvmx_xiface xi =cvmx_helper_xiface_to_node_interface (xiface); +int ret_val =-1 ; + +__cvmx_pko_internal_ports_range_init (); + ret_val =cvmx_free_global_resource_range_with_base ( +CVMX_GR_TAG_PKO_IPORTS , + cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_port_base, + cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_num_ports); +if (ret_val !=0 ) +return ret_val; + cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_port_base = +CVMX_HELPER_CFG_INVALID_VALUE ; + cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_num_ports = +CVMX_HELPER_CFG_INVALID_VALUE ; + +return 0 ; +} + +void cvmx_pko_internal_ports_range_free_all (void ) +{ +int interface, port; + +__cvmx_pko_internal_ports_range_init (); +for (interface =0 ; interface <CVMX_HELPER_MAX_IFACE ; interface++) +for (port =0 ; port <CVMX_HELPER_CFG_MAX_PORT_PER_IFACE ; + port++) { +if (cvmx_cfg_port[0 ][interface][port] + .ccpp_pko_port_base != +CVMX_HELPER_CFG_INVALID_VALUE ) +cvmx_pko_internal_ports_free (interface, port); + } +//cvmx_range_show(pko_internal_ports_range); +} + +void cvmx_pko_internal_ports_range_show (void ) +{ +int interface, port; + +__cvmx_pko_internal_ports_range_init (); +cvmx_show_global_resource_range (CVMX_GR_TAG_PKO_IPORTS ); +for (interface =0 ; interface <CVMX_HELPER_MAX_IFACE ; interface++) +for (port =0 ; port <CVMX_HELPER_CFG_MAX_PORT_PER_IFACE ; + port++) { +if (cvmx_cfg_port[0 ][interface][port] + .ccpp_pko_port_base != +CVMX_HELPER_CFG_INVALID_VALUE ) +debug ("interface=%d port=%d port_base=%d port_cnt=%d\n" , + interface, port, + (int )cvmx_cfg_port[0 ][interface][port] + .ccpp_pko_port_base, + (int )cvmx_cfg_port[0 ][interface][port] + .ccpp_pko_num_ports); + } +}
Signature · 1 line
2.35.1