1b790b554SNishad Kamdar /* SPDX-License-Identifier: BSD-3-Clause */ 2*3c9cfb52SVladimir Oltean /* Copyright 2016-2018 NXP 38aa9ebccSVladimir Oltean * Copyright (c) 2018-2019, Vladimir Oltean <olteanv@gmail.com> 48aa9ebccSVladimir Oltean */ 58aa9ebccSVladimir Oltean #ifndef _SJA1105_STATIC_CONFIG_H 68aa9ebccSVladimir Oltean #define _SJA1105_STATIC_CONFIG_H 78aa9ebccSVladimir Oltean 88aa9ebccSVladimir Oltean #include <linux/packing.h> 98aa9ebccSVladimir Oltean #include <linux/types.h> 108aa9ebccSVladimir Oltean #include <asm/types.h> 118aa9ebccSVladimir Oltean 123e77e59bSVladimir Oltean #define SJA1105_NUM_PORTS 5 133e77e59bSVladimir Oltean #define SJA1110_NUM_PORTS 11 143e77e59bSVladimir Oltean #define SJA1105_MAX_NUM_PORTS SJA1110_NUM_PORTS 153e77e59bSVladimir Oltean #define SJA1105_NUM_TC 8 163e77e59bSVladimir Oltean 17718bad0eSVladimir Oltean #define SJA1105_SIZE_SPI_MSG_HEADER 4 18718bad0eSVladimir Oltean #define SJA1105_SIZE_SPI_MSG_MAXLEN (64 * 4) 198aa9ebccSVladimir Oltean #define SJA1105_SIZE_DEVICE_ID 4 208aa9ebccSVladimir Oltean #define SJA1105_SIZE_TABLE_HEADER 12 217f1e4ba8SVladimir Oltean #define SJA1105_SIZE_SCHEDULE_ENTRY 8 223e77e59bSVladimir Oltean #define SJA1110_SIZE_SCHEDULE_ENTRY 12 237f1e4ba8SVladimir Oltean #define SJA1105_SIZE_SCHEDULE_ENTRY_POINTS_ENTRY 4 243e77e59bSVladimir Oltean #define SJA1110_SIZE_SCHEDULE_ENTRY_POINTS_ENTRY 8 2594f94d4aSVladimir Oltean #define SJA1105_SIZE_VL_LOOKUP_ENTRY 12 2694f94d4aSVladimir Oltean #define SJA1105_SIZE_VL_POLICING_ENTRY 8 2794f94d4aSVladimir Oltean #define SJA1105_SIZE_VL_FORWARDING_ENTRY 4 288aa9ebccSVladimir Oltean #define SJA1105_SIZE_L2_POLICING_ENTRY 8 298aa9ebccSVladimir Oltean #define SJA1105_SIZE_VLAN_LOOKUP_ENTRY 8 303e77e59bSVladimir Oltean #define SJA1110_SIZE_VLAN_LOOKUP_ENTRY 12 318aa9ebccSVladimir Oltean #define SJA1105_SIZE_L2_FORWARDING_ENTRY 8 328aa9ebccSVladimir Oltean #define SJA1105_SIZE_L2_FORWARDING_PARAMS_ENTRY 12 3388cac0faSVladimir Oltean #define SJA1105_SIZE_RETAGGING_ENTRY 8 348aa9ebccSVladimir Oltean #define SJA1105_SIZE_XMII_PARAMS_ENTRY 4 353e77e59bSVladimir Oltean #define SJA1110_SIZE_XMII_PARAMS_ENTRY 8 367f1e4ba8SVladimir Oltean #define SJA1105_SIZE_SCHEDULE_PARAMS_ENTRY 12 377f1e4ba8SVladimir Oltean #define SJA1105_SIZE_SCHEDULE_ENTRY_POINTS_PARAMS_ENTRY 4 3894f94d4aSVladimir Oltean #define SJA1105_SIZE_VL_FORWARDING_PARAMS_ENTRY 12 398aa9ebccSVladimir Oltean #define SJA1105ET_SIZE_L2_LOOKUP_ENTRY 12 408aa9ebccSVladimir Oltean #define SJA1105ET_SIZE_MAC_CONFIG_ENTRY 28 418aa9ebccSVladimir Oltean #define SJA1105ET_SIZE_L2_LOOKUP_PARAMS_ENTRY 4 428aa9ebccSVladimir Oltean #define SJA1105ET_SIZE_GENERAL_PARAMS_ENTRY 40 4324c01949SVladimir Oltean #define SJA1105ET_SIZE_AVB_PARAMS_ENTRY 12 444d752508SVladimir Oltean #define SJA1105ET_SIZE_CBS_ENTRY 16 458aa9ebccSVladimir Oltean #define SJA1105PQRS_SIZE_L2_LOOKUP_ENTRY 20 463e77e59bSVladimir Oltean #define SJA1110_SIZE_L2_LOOKUP_ENTRY 24 478aa9ebccSVladimir Oltean #define SJA1105PQRS_SIZE_MAC_CONFIG_ENTRY 32 488aa9ebccSVladimir Oltean #define SJA1105PQRS_SIZE_L2_LOOKUP_PARAMS_ENTRY 16 493e77e59bSVladimir Oltean #define SJA1110_SIZE_L2_LOOKUP_PARAMS_ENTRY 28 508aa9ebccSVladimir Oltean #define SJA1105PQRS_SIZE_GENERAL_PARAMS_ENTRY 44 513e77e59bSVladimir Oltean #define SJA1110_SIZE_GENERAL_PARAMS_ENTRY 56 5224c01949SVladimir Oltean #define SJA1105PQRS_SIZE_AVB_PARAMS_ENTRY 16 534d752508SVladimir Oltean #define SJA1105PQRS_SIZE_CBS_ENTRY 20 543e77e59bSVladimir Oltean #define SJA1110_SIZE_PCP_REMAPPING_ENTRY 4 558aa9ebccSVladimir Oltean 568aa9ebccSVladimir Oltean /* UM10944.pdf Page 11, Table 2. Configuration Blocks */ 578aa9ebccSVladimir Oltean enum { 587f1e4ba8SVladimir Oltean BLKID_SCHEDULE = 0x00, 597f1e4ba8SVladimir Oltean BLKID_SCHEDULE_ENTRY_POINTS = 0x01, 6094f94d4aSVladimir Oltean BLKID_VL_LOOKUP = 0x02, 6194f94d4aSVladimir Oltean BLKID_VL_POLICING = 0x03, 6294f94d4aSVladimir Oltean BLKID_VL_FORWARDING = 0x04, 638aa9ebccSVladimir Oltean BLKID_L2_LOOKUP = 0x05, 648aa9ebccSVladimir Oltean BLKID_L2_POLICING = 0x06, 658aa9ebccSVladimir Oltean BLKID_VLAN_LOOKUP = 0x07, 668aa9ebccSVladimir Oltean BLKID_L2_FORWARDING = 0x08, 678aa9ebccSVladimir Oltean BLKID_MAC_CONFIG = 0x09, 687f1e4ba8SVladimir Oltean BLKID_SCHEDULE_PARAMS = 0x0A, 697f1e4ba8SVladimir Oltean BLKID_SCHEDULE_ENTRY_POINTS_PARAMS = 0x0B, 7094f94d4aSVladimir Oltean BLKID_VL_FORWARDING_PARAMS = 0x0C, 718aa9ebccSVladimir Oltean BLKID_L2_LOOKUP_PARAMS = 0x0D, 728aa9ebccSVladimir Oltean BLKID_L2_FORWARDING_PARAMS = 0x0E, 7324c01949SVladimir Oltean BLKID_AVB_PARAMS = 0x10, 748aa9ebccSVladimir Oltean BLKID_GENERAL_PARAMS = 0x11, 7588cac0faSVladimir Oltean BLKID_RETAGGING = 0x12, 764d752508SVladimir Oltean BLKID_CBS = 0x13, 773e77e59bSVladimir Oltean BLKID_PCP_REMAPPING = 0x1C, 788aa9ebccSVladimir Oltean BLKID_XMII_PARAMS = 0x4E, 798aa9ebccSVladimir Oltean }; 808aa9ebccSVladimir Oltean 818aa9ebccSVladimir Oltean enum sja1105_blk_idx { 827f1e4ba8SVladimir Oltean BLK_IDX_SCHEDULE = 0, 837f1e4ba8SVladimir Oltean BLK_IDX_SCHEDULE_ENTRY_POINTS, 8494f94d4aSVladimir Oltean BLK_IDX_VL_LOOKUP, 8594f94d4aSVladimir Oltean BLK_IDX_VL_POLICING, 8694f94d4aSVladimir Oltean BLK_IDX_VL_FORWARDING, 877f1e4ba8SVladimir Oltean BLK_IDX_L2_LOOKUP, 888aa9ebccSVladimir Oltean BLK_IDX_L2_POLICING, 898aa9ebccSVladimir Oltean BLK_IDX_VLAN_LOOKUP, 908aa9ebccSVladimir Oltean BLK_IDX_L2_FORWARDING, 918aa9ebccSVladimir Oltean BLK_IDX_MAC_CONFIG, 927f1e4ba8SVladimir Oltean BLK_IDX_SCHEDULE_PARAMS, 937f1e4ba8SVladimir Oltean BLK_IDX_SCHEDULE_ENTRY_POINTS_PARAMS, 9494f94d4aSVladimir Oltean BLK_IDX_VL_FORWARDING_PARAMS, 958aa9ebccSVladimir Oltean BLK_IDX_L2_LOOKUP_PARAMS, 968aa9ebccSVladimir Oltean BLK_IDX_L2_FORWARDING_PARAMS, 9724c01949SVladimir Oltean BLK_IDX_AVB_PARAMS, 988aa9ebccSVladimir Oltean BLK_IDX_GENERAL_PARAMS, 9988cac0faSVladimir Oltean BLK_IDX_RETAGGING, 1004d752508SVladimir Oltean BLK_IDX_CBS, 1018aa9ebccSVladimir Oltean BLK_IDX_XMII_PARAMS, 1023e77e59bSVladimir Oltean BLK_IDX_PCP_REMAPPING, 1038aa9ebccSVladimir Oltean BLK_IDX_MAX, 1048aa9ebccSVladimir Oltean /* Fake block indices that are only valid for dynamic access */ 1058aa9ebccSVladimir Oltean BLK_IDX_MGMT_ROUTE, 1068aa9ebccSVladimir Oltean BLK_IDX_MAX_DYN, 1078aa9ebccSVladimir Oltean BLK_IDX_INVAL = -1, 1088aa9ebccSVladimir Oltean }; 1098aa9ebccSVladimir Oltean 1107f1e4ba8SVladimir Oltean #define SJA1105_MAX_SCHEDULE_COUNT 1024 1113e77e59bSVladimir Oltean #define SJA1110_MAX_SCHEDULE_COUNT 4096 1127f1e4ba8SVladimir Oltean #define SJA1105_MAX_SCHEDULE_ENTRY_POINTS_COUNT 2048 11394f94d4aSVladimir Oltean #define SJA1105_MAX_VL_LOOKUP_COUNT 1024 1143e77e59bSVladimir Oltean #define SJA1110_MAX_VL_LOOKUP_COUNT 4096 11594f94d4aSVladimir Oltean #define SJA1105_MAX_VL_POLICING_COUNT 1024 1163e77e59bSVladimir Oltean #define SJA1110_MAX_VL_POLICING_COUNT 4096 11794f94d4aSVladimir Oltean #define SJA1105_MAX_VL_FORWARDING_COUNT 1024 1183e77e59bSVladimir Oltean #define SJA1110_MAX_VL_FORWARDING_COUNT 4096 1198aa9ebccSVladimir Oltean #define SJA1105_MAX_L2_LOOKUP_COUNT 1024 1208aa9ebccSVladimir Oltean #define SJA1105_MAX_L2_POLICING_COUNT 45 1213e77e59bSVladimir Oltean #define SJA1110_MAX_L2_POLICING_COUNT 110 1228aa9ebccSVladimir Oltean #define SJA1105_MAX_VLAN_LOOKUP_COUNT 4096 1238aa9ebccSVladimir Oltean #define SJA1105_MAX_L2_FORWARDING_COUNT 13 1243e77e59bSVladimir Oltean #define SJA1110_MAX_L2_FORWARDING_COUNT 19 1258aa9ebccSVladimir Oltean #define SJA1105_MAX_MAC_CONFIG_COUNT 5 1263e77e59bSVladimir Oltean #define SJA1110_MAX_MAC_CONFIG_COUNT 11 1277f1e4ba8SVladimir Oltean #define SJA1105_MAX_SCHEDULE_PARAMS_COUNT 1 1287f1e4ba8SVladimir Oltean #define SJA1105_MAX_SCHEDULE_ENTRY_POINTS_PARAMS_COUNT 1 12994f94d4aSVladimir Oltean #define SJA1105_MAX_VL_FORWARDING_PARAMS_COUNT 1 1308aa9ebccSVladimir Oltean #define SJA1105_MAX_L2_LOOKUP_PARAMS_COUNT 1 1318aa9ebccSVladimir Oltean #define SJA1105_MAX_L2_FORWARDING_PARAMS_COUNT 1 1328aa9ebccSVladimir Oltean #define SJA1105_MAX_GENERAL_PARAMS_COUNT 1 13388cac0faSVladimir Oltean #define SJA1105_MAX_RETAGGING_COUNT 32 1348aa9ebccSVladimir Oltean #define SJA1105_MAX_XMII_PARAMS_COUNT 1 13524c01949SVladimir Oltean #define SJA1105_MAX_AVB_PARAMS_COUNT 1 1364d752508SVladimir Oltean #define SJA1105ET_MAX_CBS_COUNT 10 1374d752508SVladimir Oltean #define SJA1105PQRS_MAX_CBS_COUNT 16 1383e77e59bSVladimir Oltean #define SJA1110_MAX_CBS_COUNT 80 1393e77e59bSVladimir Oltean #define SJA1110_MAX_PCP_REMAPPING_COUNT 11 1408aa9ebccSVladimir Oltean 1418aa9ebccSVladimir Oltean #define SJA1105_MAX_FRAME_MEMORY 929 1423e77e59bSVladimir Oltean #define SJA1110_MAX_FRAME_MEMORY 1820 1431bf658eeSVladimir Oltean #define SJA1105_FRAME_MEMORY_RETAGGING_OVERHEAD 19 144aaa270c6SVladimir Oltean #define SJA1105_VL_FRAME_MEMORY 100 1458aa9ebccSVladimir Oltean 1468aa9ebccSVladimir Oltean #define SJA1105E_DEVICE_ID 0x9C00000Cull 1478aa9ebccSVladimir Oltean #define SJA1105T_DEVICE_ID 0x9E00030Eull 1488aa9ebccSVladimir Oltean #define SJA1105PR_DEVICE_ID 0xAF00030Eull 1498aa9ebccSVladimir Oltean #define SJA1105QS_DEVICE_ID 0xAE00030Eull 1503e77e59bSVladimir Oltean #define SJA1110_DEVICE_ID 0xB700030Full 1518aa9ebccSVladimir Oltean 1528aa9ebccSVladimir Oltean #define SJA1105ET_PART_NO 0x9A83 1538aa9ebccSVladimir Oltean #define SJA1105P_PART_NO 0x9A84 1548aa9ebccSVladimir Oltean #define SJA1105Q_PART_NO 0x9A85 1558aa9ebccSVladimir Oltean #define SJA1105R_PART_NO 0x9A86 1568aa9ebccSVladimir Oltean #define SJA1105S_PART_NO 0x9A87 1573e77e59bSVladimir Oltean #define SJA1110A_PART_NO 0x1110 1583e77e59bSVladimir Oltean #define SJA1110B_PART_NO 0x1111 1593e77e59bSVladimir Oltean #define SJA1110C_PART_NO 0x1112 1603e77e59bSVladimir Oltean #define SJA1110D_PART_NO 0x1113 1613e77e59bSVladimir Oltean 1623e77e59bSVladimir Oltean #define SJA1110_ACU 0x1c4400 1633e77e59bSVladimir Oltean #define SJA1110_RGU 0x1c6000 1643e77e59bSVladimir Oltean #define SJA1110_CGU 0x1c6400 1653e77e59bSVladimir Oltean 1663e77e59bSVladimir Oltean #define SJA1110_SPI_ADDR(x) ((x) / 4) 1673e77e59bSVladimir Oltean #define SJA1110_ACU_ADDR(x) (SJA1110_ACU + SJA1110_SPI_ADDR(x)) 1683e77e59bSVladimir Oltean #define SJA1110_CGU_ADDR(x) (SJA1110_CGU + SJA1110_SPI_ADDR(x)) 1693e77e59bSVladimir Oltean #define SJA1110_RGU_ADDR(x) (SJA1110_RGU + SJA1110_SPI_ADDR(x)) 1708aa9ebccSVladimir Oltean 171c5037678SVladimir Oltean #define SJA1105_RSV_ADDR 0xffffffffffffffffull 172c5037678SVladimir Oltean 1737f1e4ba8SVladimir Oltean struct sja1105_schedule_entry { 1747f1e4ba8SVladimir Oltean u64 winstindex; 1757f1e4ba8SVladimir Oltean u64 winend; 1767f1e4ba8SVladimir Oltean u64 winst; 1777f1e4ba8SVladimir Oltean u64 destports; 1787f1e4ba8SVladimir Oltean u64 setvalid; 1797f1e4ba8SVladimir Oltean u64 txen; 1807f1e4ba8SVladimir Oltean u64 resmedia_en; 1817f1e4ba8SVladimir Oltean u64 resmedia; 1827f1e4ba8SVladimir Oltean u64 vlindex; 1837f1e4ba8SVladimir Oltean u64 delta; 1847f1e4ba8SVladimir Oltean }; 1857f1e4ba8SVladimir Oltean 1867f1e4ba8SVladimir Oltean struct sja1105_schedule_params_entry { 1877f1e4ba8SVladimir Oltean u64 subscheind[8]; 1887f1e4ba8SVladimir Oltean }; 1897f1e4ba8SVladimir Oltean 1908aa9ebccSVladimir Oltean struct sja1105_general_params_entry { 1918aa9ebccSVladimir Oltean u64 vllupformat; 1928aa9ebccSVladimir Oltean u64 mirr_ptacu; 1938aa9ebccSVladimir Oltean u64 switchid; 1948aa9ebccSVladimir Oltean u64 hostprio; 1958aa9ebccSVladimir Oltean u64 mac_fltres1; 1968aa9ebccSVladimir Oltean u64 mac_fltres0; 1978aa9ebccSVladimir Oltean u64 mac_flt1; 1988aa9ebccSVladimir Oltean u64 mac_flt0; 1998aa9ebccSVladimir Oltean u64 incl_srcpt1; 2008aa9ebccSVladimir Oltean u64 incl_srcpt0; 2018aa9ebccSVladimir Oltean u64 send_meta1; 2028aa9ebccSVladimir Oltean u64 send_meta0; 2038aa9ebccSVladimir Oltean u64 casc_port; 2048aa9ebccSVladimir Oltean u64 host_port; 2058aa9ebccSVladimir Oltean u64 mirr_port; 2068aa9ebccSVladimir Oltean u64 vlmarker; 2078aa9ebccSVladimir Oltean u64 vlmask; 2088aa9ebccSVladimir Oltean u64 tpid; 2098aa9ebccSVladimir Oltean u64 ignore2stf; 2108aa9ebccSVladimir Oltean u64 tpid2; 2118aa9ebccSVladimir Oltean /* P/Q/R/S only */ 2128aa9ebccSVladimir Oltean u64 queue_ts; 2138aa9ebccSVladimir Oltean u64 egrmirrvid; 2148aa9ebccSVladimir Oltean u64 egrmirrpcp; 2158aa9ebccSVladimir Oltean u64 egrmirrdei; 2168aa9ebccSVladimir Oltean u64 replay_port; 2173e77e59bSVladimir Oltean /* SJA1110 only */ 2183e77e59bSVladimir Oltean u64 tte_en; 219ceec8bc0SVladimir Oltean u64 tdmaconfigidx; 2204913b8ebSVladimir Oltean u64 header_type; 2218aa9ebccSVladimir Oltean }; 2228aa9ebccSVladimir Oltean 2237f1e4ba8SVladimir Oltean struct sja1105_schedule_entry_points_entry { 2247f1e4ba8SVladimir Oltean u64 subschindx; 2257f1e4ba8SVladimir Oltean u64 delta; 2267f1e4ba8SVladimir Oltean u64 address; 2277f1e4ba8SVladimir Oltean }; 2287f1e4ba8SVladimir Oltean 2297f1e4ba8SVladimir Oltean struct sja1105_schedule_entry_points_params_entry { 2307f1e4ba8SVladimir Oltean u64 clksrc; 2317f1e4ba8SVladimir Oltean u64 actsubsch; 2327f1e4ba8SVladimir Oltean }; 2337f1e4ba8SVladimir Oltean 2348aa9ebccSVladimir Oltean struct sja1105_vlan_lookup_entry { 2358aa9ebccSVladimir Oltean u64 ving_mirr; 2368aa9ebccSVladimir Oltean u64 vegr_mirr; 2378aa9ebccSVladimir Oltean u64 vmemb_port; 2388aa9ebccSVladimir Oltean u64 vlan_bc; 2398aa9ebccSVladimir Oltean u64 tag_port; 2408aa9ebccSVladimir Oltean u64 vlanid; 2413e77e59bSVladimir Oltean u64 type_entry; /* SJA1110 only */ 2428aa9ebccSVladimir Oltean }; 2438aa9ebccSVladimir Oltean 2448aa9ebccSVladimir Oltean struct sja1105_l2_lookup_entry { 2458aa9ebccSVladimir Oltean u64 vlanid; 2468aa9ebccSVladimir Oltean u64 macaddr; 2478aa9ebccSVladimir Oltean u64 destports; 2488aa9ebccSVladimir Oltean u64 enfport; 2498aa9ebccSVladimir Oltean u64 index; 2509c5098d9SVladimir Oltean /* P/Q/R/S only */ 2519c5098d9SVladimir Oltean u64 mask_iotag; 2529c5098d9SVladimir Oltean u64 mask_vlanid; 2539c5098d9SVladimir Oltean u64 mask_macaddr; 2543e77e59bSVladimir Oltean u64 mask_srcport; 2559c5098d9SVladimir Oltean u64 iotag; 2563e77e59bSVladimir Oltean u64 srcport; 25717ae6555SVladimir Oltean u64 lockeds; 2589c5098d9SVladimir Oltean union { 2599c5098d9SVladimir Oltean /* LOCKEDS=1: Static FDB entries */ 2609c5098d9SVladimir Oltean struct { 2613e77e59bSVladimir Oltean /* TSREG is deprecated in SJA1110, TRAP is supported only 2623e77e59bSVladimir Oltean * in SJA1110. 2633e77e59bSVladimir Oltean */ 2643e77e59bSVladimir Oltean u64 trap; 2659c5098d9SVladimir Oltean u64 tsreg; 2669c5098d9SVladimir Oltean u64 mirrvlan; 2679c5098d9SVladimir Oltean u64 takets; 2689c5098d9SVladimir Oltean u64 mirr; 2699c5098d9SVladimir Oltean u64 retag; 2709c5098d9SVladimir Oltean }; 2719c5098d9SVladimir Oltean /* LOCKEDS=0: Dynamically learned FDB entries */ 2729c5098d9SVladimir Oltean struct { 2739c5098d9SVladimir Oltean u64 touched; 2749c5098d9SVladimir Oltean u64 age; 2759c5098d9SVladimir Oltean }; 2769c5098d9SVladimir Oltean }; 2778aa9ebccSVladimir Oltean }; 2788aa9ebccSVladimir Oltean 2798aa9ebccSVladimir Oltean struct sja1105_l2_lookup_params_entry { 2803e77e59bSVladimir Oltean u64 maxaddrp[SJA1105_MAX_NUM_PORTS]; /* P/Q/R/S only */ 2819c5098d9SVladimir Oltean u64 start_dynspc; /* P/Q/R/S only */ 2829c5098d9SVladimir Oltean u64 drpnolearn; /* P/Q/R/S only */ 2839c5098d9SVladimir Oltean u64 use_static; /* P/Q/R/S only */ 2849c5098d9SVladimir Oltean u64 owr_dyn; /* P/Q/R/S only */ 2859c5098d9SVladimir Oltean u64 learn_once; /* P/Q/R/S only */ 2868aa9ebccSVladimir Oltean u64 maxage; /* Shared */ 2878aa9ebccSVladimir Oltean u64 dyn_tbsz; /* E/T only */ 2888aa9ebccSVladimir Oltean u64 poly; /* E/T only */ 2898aa9ebccSVladimir Oltean u64 shared_learn; /* Shared */ 2908aa9ebccSVladimir Oltean u64 no_enf_hostprt; /* Shared */ 2918aa9ebccSVladimir Oltean u64 no_mgmt_learn; /* Shared */ 2928aa9ebccSVladimir Oltean }; 2938aa9ebccSVladimir Oltean 2948aa9ebccSVladimir Oltean struct sja1105_l2_forwarding_entry { 2958aa9ebccSVladimir Oltean u64 bc_domain; 2968aa9ebccSVladimir Oltean u64 reach_port; 2978aa9ebccSVladimir Oltean u64 fl_domain; 2983e77e59bSVladimir Oltean /* This is actually max(SJA1105_NUM_TC, SJA1105_MAX_NUM_PORTS) */ 2993e77e59bSVladimir Oltean u64 vlan_pmap[SJA1105_MAX_NUM_PORTS]; 3003e77e59bSVladimir Oltean bool type_egrpcp2outputq; 3018aa9ebccSVladimir Oltean }; 3028aa9ebccSVladimir Oltean 3038aa9ebccSVladimir Oltean struct sja1105_l2_forwarding_params_entry { 3048aa9ebccSVladimir Oltean u64 max_dynp; 3058aa9ebccSVladimir Oltean u64 part_spc[8]; 3068aa9ebccSVladimir Oltean }; 3078aa9ebccSVladimir Oltean 3088aa9ebccSVladimir Oltean struct sja1105_l2_policing_entry { 3098aa9ebccSVladimir Oltean u64 sharindx; 3108aa9ebccSVladimir Oltean u64 smax; 3118aa9ebccSVladimir Oltean u64 rate; 3128aa9ebccSVladimir Oltean u64 maxlen; 3138aa9ebccSVladimir Oltean u64 partition; 3148aa9ebccSVladimir Oltean }; 3158aa9ebccSVladimir Oltean 31624c01949SVladimir Oltean struct sja1105_avb_params_entry { 317747e5eb3SVladimir Oltean u64 cas_master; 31824c01949SVladimir Oltean u64 destmeta; 31924c01949SVladimir Oltean u64 srcmeta; 32024c01949SVladimir Oltean }; 32124c01949SVladimir Oltean 3228aa9ebccSVladimir Oltean struct sja1105_mac_config_entry { 3238aa9ebccSVladimir Oltean u64 top[8]; 3248aa9ebccSVladimir Oltean u64 base[8]; 3258aa9ebccSVladimir Oltean u64 enabled[8]; 3268aa9ebccSVladimir Oltean u64 ifg; 3278aa9ebccSVladimir Oltean u64 speed; 3288aa9ebccSVladimir Oltean u64 tp_delin; 3298aa9ebccSVladimir Oltean u64 tp_delout; 3308aa9ebccSVladimir Oltean u64 maxage; 3318aa9ebccSVladimir Oltean u64 vlanprio; 3328aa9ebccSVladimir Oltean u64 vlanid; 3338aa9ebccSVladimir Oltean u64 ing_mirr; 3348aa9ebccSVladimir Oltean u64 egr_mirr; 3358aa9ebccSVladimir Oltean u64 drpnona664; 3368aa9ebccSVladimir Oltean u64 drpdtag; 3378aa9ebccSVladimir Oltean u64 drpuntag; 3388aa9ebccSVladimir Oltean u64 retag; 3398aa9ebccSVladimir Oltean u64 dyn_learn; 3408aa9ebccSVladimir Oltean u64 egress; 3418aa9ebccSVladimir Oltean u64 ingress; 3428aa9ebccSVladimir Oltean }; 3438aa9ebccSVladimir Oltean 34488cac0faSVladimir Oltean struct sja1105_retagging_entry { 34588cac0faSVladimir Oltean u64 egr_port; 34688cac0faSVladimir Oltean u64 ing_port; 34788cac0faSVladimir Oltean u64 vlan_ing; 34888cac0faSVladimir Oltean u64 vlan_egr; 34988cac0faSVladimir Oltean u64 do_not_learn; 35088cac0faSVladimir Oltean u64 use_dest_ports; 35188cac0faSVladimir Oltean u64 destports; 35288cac0faSVladimir Oltean }; 35388cac0faSVladimir Oltean 3544d752508SVladimir Oltean struct sja1105_cbs_entry { 3553e77e59bSVladimir Oltean u64 port; /* Not used for SJA1110 */ 3563e77e59bSVladimir Oltean u64 prio; /* Not used for SJA1110 */ 3574d752508SVladimir Oltean u64 credit_hi; 3584d752508SVladimir Oltean u64 credit_lo; 3594d752508SVladimir Oltean u64 send_slope; 3604d752508SVladimir Oltean u64 idle_slope; 3614d752508SVladimir Oltean }; 3624d752508SVladimir Oltean 3638aa9ebccSVladimir Oltean struct sja1105_xmii_params_entry { 3643e77e59bSVladimir Oltean u64 phy_mac[SJA1105_MAX_NUM_PORTS]; 3653e77e59bSVladimir Oltean u64 xmii_mode[SJA1105_MAX_NUM_PORTS]; 3663e77e59bSVladimir Oltean /* The SJA1110 insists being a snowflake, and requires SGMII, 3673e77e59bSVladimir Oltean * 2500base-x and internal MII ports connected to the 100base-TX PHY to 3683e77e59bSVladimir Oltean * set this bit. We set it unconditionally from the high-level logic, 3693e77e59bSVladimir Oltean * and only sja1110_xmii_params_entry_packing writes it to the static 3703e77e59bSVladimir Oltean * config. I have no better name for it than "special". 3713e77e59bSVladimir Oltean */ 3723e77e59bSVladimir Oltean u64 special[SJA1105_MAX_NUM_PORTS]; 3733e77e59bSVladimir Oltean }; 3743e77e59bSVladimir Oltean 3753e77e59bSVladimir Oltean struct sja1110_pcp_remapping_entry { 3763e77e59bSVladimir Oltean u64 egrpcp[SJA1105_NUM_TC]; 3778aa9ebccSVladimir Oltean }; 3788aa9ebccSVladimir Oltean 37994f94d4aSVladimir Oltean enum { 38094f94d4aSVladimir Oltean SJA1105_VL_FORMAT_PSFP = 0, 38194f94d4aSVladimir Oltean SJA1105_VL_FORMAT_ARINC664 = 1, 38294f94d4aSVladimir Oltean }; 38394f94d4aSVladimir Oltean 38494f94d4aSVladimir Oltean struct sja1105_vl_lookup_entry { 38594f94d4aSVladimir Oltean u64 format; 38694f94d4aSVladimir Oltean u64 port; 38794f94d4aSVladimir Oltean union { 38894f94d4aSVladimir Oltean /* SJA1105_VL_FORMAT_PSFP */ 38994f94d4aSVladimir Oltean struct { 39094f94d4aSVladimir Oltean u64 destports; 39194f94d4aSVladimir Oltean u64 iscritical; 39294f94d4aSVladimir Oltean u64 macaddr; 39394f94d4aSVladimir Oltean u64 vlanid; 39494f94d4aSVladimir Oltean u64 vlanprior; 39594f94d4aSVladimir Oltean }; 39694f94d4aSVladimir Oltean /* SJA1105_VL_FORMAT_ARINC664 */ 39794f94d4aSVladimir Oltean struct { 39894f94d4aSVladimir Oltean u64 egrmirr; 39994f94d4aSVladimir Oltean u64 ingrmirr; 40094f94d4aSVladimir Oltean u64 vlid; 40194f94d4aSVladimir Oltean }; 40294f94d4aSVladimir Oltean }; 403834f8933SVladimir Oltean /* Not part of hardware structure */ 404834f8933SVladimir Oltean unsigned long flow_cookie; 40594f94d4aSVladimir Oltean }; 40694f94d4aSVladimir Oltean 40794f94d4aSVladimir Oltean struct sja1105_vl_policing_entry { 40894f94d4aSVladimir Oltean u64 type; 40994f94d4aSVladimir Oltean u64 maxlen; 41094f94d4aSVladimir Oltean u64 sharindx; 41194f94d4aSVladimir Oltean u64 bag; 41294f94d4aSVladimir Oltean u64 jitter; 41394f94d4aSVladimir Oltean }; 41494f94d4aSVladimir Oltean 41594f94d4aSVladimir Oltean struct sja1105_vl_forwarding_entry { 41694f94d4aSVladimir Oltean u64 type; 41794f94d4aSVladimir Oltean u64 priority; 41894f94d4aSVladimir Oltean u64 partition; 41994f94d4aSVladimir Oltean u64 destports; 42094f94d4aSVladimir Oltean }; 42194f94d4aSVladimir Oltean 42294f94d4aSVladimir Oltean struct sja1105_vl_forwarding_params_entry { 42394f94d4aSVladimir Oltean u64 partspc[8]; 42494f94d4aSVladimir Oltean u64 debugen; 42594f94d4aSVladimir Oltean }; 42694f94d4aSVladimir Oltean 4278aa9ebccSVladimir Oltean struct sja1105_table_header { 4288aa9ebccSVladimir Oltean u64 block_id; 4298aa9ebccSVladimir Oltean u64 len; 4308aa9ebccSVladimir Oltean u64 crc; 4318aa9ebccSVladimir Oltean }; 4328aa9ebccSVladimir Oltean 4338aa9ebccSVladimir Oltean struct sja1105_table_ops { 4348aa9ebccSVladimir Oltean size_t (*packing)(void *buf, void *entry_ptr, enum packing_op op); 4358aa9ebccSVladimir Oltean size_t unpacked_entry_size; 4368aa9ebccSVladimir Oltean size_t packed_entry_size; 4378aa9ebccSVladimir Oltean size_t max_entry_count; 4388aa9ebccSVladimir Oltean }; 4398aa9ebccSVladimir Oltean 4408aa9ebccSVladimir Oltean struct sja1105_table { 4418aa9ebccSVladimir Oltean const struct sja1105_table_ops *ops; 4428aa9ebccSVladimir Oltean size_t entry_count; 4438aa9ebccSVladimir Oltean void *entries; 4448aa9ebccSVladimir Oltean }; 4458aa9ebccSVladimir Oltean 4468aa9ebccSVladimir Oltean struct sja1105_static_config { 4478aa9ebccSVladimir Oltean u64 device_id; 4488aa9ebccSVladimir Oltean struct sja1105_table tables[BLK_IDX_MAX]; 4498aa9ebccSVladimir Oltean }; 4508aa9ebccSVladimir Oltean 451718e44b6SVladimir Oltean extern const struct sja1105_table_ops sja1105e_table_ops[BLK_IDX_MAX]; 452718e44b6SVladimir Oltean extern const struct sja1105_table_ops sja1105t_table_ops[BLK_IDX_MAX]; 453718e44b6SVladimir Oltean extern const struct sja1105_table_ops sja1105p_table_ops[BLK_IDX_MAX]; 454718e44b6SVladimir Oltean extern const struct sja1105_table_ops sja1105q_table_ops[BLK_IDX_MAX]; 455718e44b6SVladimir Oltean extern const struct sja1105_table_ops sja1105r_table_ops[BLK_IDX_MAX]; 456718e44b6SVladimir Oltean extern const struct sja1105_table_ops sja1105s_table_ops[BLK_IDX_MAX]; 4573e77e59bSVladimir Oltean extern const struct sja1105_table_ops sja1110_table_ops[BLK_IDX_MAX]; 4588aa9ebccSVladimir Oltean 4598aa9ebccSVladimir Oltean size_t sja1105_table_header_packing(void *buf, void *hdr, enum packing_op op); 4608aa9ebccSVladimir Oltean void 4618aa9ebccSVladimir Oltean sja1105_table_header_pack_with_crc(void *buf, struct sja1105_table_header *hdr); 4628aa9ebccSVladimir Oltean size_t 4638aa9ebccSVladimir Oltean sja1105_static_config_get_length(const struct sja1105_static_config *config); 4648aa9ebccSVladimir Oltean 4658aa9ebccSVladimir Oltean typedef enum { 4668aa9ebccSVladimir Oltean SJA1105_CONFIG_OK = 0, 4677f1e4ba8SVladimir Oltean SJA1105_TTETHERNET_NOT_SUPPORTED, 4687f1e4ba8SVladimir Oltean SJA1105_INCORRECT_TTETHERNET_CONFIGURATION, 46994f94d4aSVladimir Oltean SJA1105_INCORRECT_VIRTUAL_LINK_CONFIGURATION, 4708aa9ebccSVladimir Oltean SJA1105_MISSING_L2_POLICING_TABLE, 4718aa9ebccSVladimir Oltean SJA1105_MISSING_L2_FORWARDING_TABLE, 4728aa9ebccSVladimir Oltean SJA1105_MISSING_L2_FORWARDING_PARAMS_TABLE, 4738aa9ebccSVladimir Oltean SJA1105_MISSING_GENERAL_PARAMS_TABLE, 4748aa9ebccSVladimir Oltean SJA1105_MISSING_VLAN_TABLE, 4758aa9ebccSVladimir Oltean SJA1105_MISSING_XMII_TABLE, 4768aa9ebccSVladimir Oltean SJA1105_MISSING_MAC_TABLE, 4778aa9ebccSVladimir Oltean SJA1105_OVERCOMMITTED_FRAME_MEMORY, 4788aa9ebccSVladimir Oltean } sja1105_config_valid_t; 4798aa9ebccSVladimir Oltean 4808aa9ebccSVladimir Oltean extern const char *sja1105_static_config_error_msg[]; 4818aa9ebccSVladimir Oltean 4828aa9ebccSVladimir Oltean sja1105_config_valid_t 4831bf658eeSVladimir Oltean sja1105_static_config_check_valid(const struct sja1105_static_config *config, 4841bf658eeSVladimir Oltean int max_mem); 4858aa9ebccSVladimir Oltean void 4868aa9ebccSVladimir Oltean sja1105_static_config_pack(void *buf, struct sja1105_static_config *config); 4878aa9ebccSVladimir Oltean int sja1105_static_config_init(struct sja1105_static_config *config, 4888aa9ebccSVladimir Oltean const struct sja1105_table_ops *static_ops, 4898aa9ebccSVladimir Oltean u64 device_id); 4908aa9ebccSVladimir Oltean void sja1105_static_config_free(struct sja1105_static_config *config); 4918aa9ebccSVladimir Oltean 4926666cebcSVladimir Oltean int sja1105_table_delete_entry(struct sja1105_table *table, int i); 4936666cebcSVladimir Oltean int sja1105_table_resize(struct sja1105_table *table, size_t new_count); 4946666cebcSVladimir Oltean 4958aa9ebccSVladimir Oltean u32 sja1105_crc32(const void *buf, size_t len); 4968aa9ebccSVladimir Oltean 4978aa9ebccSVladimir Oltean void sja1105_pack(void *buf, const u64 *val, int start, int end, size_t len); 4988aa9ebccSVladimir Oltean void sja1105_unpack(const void *buf, u64 *val, int start, int end, size_t len); 4998aa9ebccSVladimir Oltean void sja1105_packing(void *buf, u64 *val, int start, int end, 5008aa9ebccSVladimir Oltean size_t len, enum packing_op op); 5018aa9ebccSVladimir Oltean 50253bd63afSVladimir Oltean /* Common implementations for the static and dynamic configs */ 50399b981f4SVladimir Oltean size_t sja1105pqrs_general_params_entry_packing(void *buf, void *entry_ptr, 50499b981f4SVladimir Oltean enum packing_op op); 5053e77e59bSVladimir Oltean size_t sja1110_general_params_entry_packing(void *buf, void *entry_ptr, 5063e77e59bSVladimir Oltean enum packing_op op); 50799b981f4SVladimir Oltean size_t sja1105pqrs_l2_lookup_params_entry_packing(void *buf, void *entry_ptr, 50899b981f4SVladimir Oltean enum packing_op op); 5093e77e59bSVladimir Oltean size_t sja1110_l2_lookup_params_entry_packing(void *buf, void *entry_ptr, 5103e77e59bSVladimir Oltean enum packing_op op); 51153bd63afSVladimir Oltean size_t sja1105_l2_forwarding_entry_packing(void *buf, void *entry_ptr, 51253bd63afSVladimir Oltean enum packing_op op); 5133e77e59bSVladimir Oltean size_t sja1110_l2_forwarding_entry_packing(void *buf, void *entry_ptr, 5143e77e59bSVladimir Oltean enum packing_op op); 51553bd63afSVladimir Oltean size_t sja1105pqrs_l2_lookup_entry_packing(void *buf, void *entry_ptr, 51653bd63afSVladimir Oltean enum packing_op op); 51753bd63afSVladimir Oltean size_t sja1105et_l2_lookup_entry_packing(void *buf, void *entry_ptr, 51853bd63afSVladimir Oltean enum packing_op op); 5193e77e59bSVladimir Oltean size_t sja1110_l2_lookup_entry_packing(void *buf, void *entry_ptr, 5203e77e59bSVladimir Oltean enum packing_op op); 52153bd63afSVladimir Oltean size_t sja1105_vlan_lookup_entry_packing(void *buf, void *entry_ptr, 52253bd63afSVladimir Oltean enum packing_op op); 5233e77e59bSVladimir Oltean size_t sja1110_vlan_lookup_entry_packing(void *buf, void *entry_ptr, 5243e77e59bSVladimir Oltean enum packing_op op); 52553bd63afSVladimir Oltean size_t sja1105_retagging_entry_packing(void *buf, void *entry_ptr, 52653bd63afSVladimir Oltean enum packing_op op); 5273e77e59bSVladimir Oltean size_t sja1110_retagging_entry_packing(void *buf, void *entry_ptr, 5283e77e59bSVladimir Oltean enum packing_op op); 52953bd63afSVladimir Oltean size_t sja1105pqrs_mac_config_entry_packing(void *buf, void *entry_ptr, 53053bd63afSVladimir Oltean enum packing_op op); 5313e77e59bSVladimir Oltean size_t sja1110_mac_config_entry_packing(void *buf, void *entry_ptr, 5323e77e59bSVladimir Oltean enum packing_op op); 53353bd63afSVladimir Oltean size_t sja1105pqrs_avb_params_entry_packing(void *buf, void *entry_ptr, 53453bd63afSVladimir Oltean enum packing_op op); 53553bd63afSVladimir Oltean size_t sja1105_vl_lookup_entry_packing(void *buf, void *entry_ptr, 53653bd63afSVladimir Oltean enum packing_op op); 5373e77e59bSVladimir Oltean size_t sja1110_vl_lookup_entry_packing(void *buf, void *entry_ptr, 5383e77e59bSVladimir Oltean enum packing_op op); 5393e77e59bSVladimir Oltean size_t sja1110_vl_policing_entry_packing(void *buf, void *entry_ptr, 5403e77e59bSVladimir Oltean enum packing_op op); 5413e77e59bSVladimir Oltean size_t sja1110_xmii_params_entry_packing(void *buf, void *entry_ptr, 5423e77e59bSVladimir Oltean enum packing_op op); 5433e77e59bSVladimir Oltean size_t sja1110_l2_policing_entry_packing(void *buf, void *entry_ptr, 5443e77e59bSVladimir Oltean enum packing_op op); 5453e77e59bSVladimir Oltean size_t sja1110_l2_forwarding_params_entry_packing(void *buf, void *entry_ptr, 5463e77e59bSVladimir Oltean enum packing_op op); 54753bd63afSVladimir Oltean 5488aa9ebccSVladimir Oltean #endif 549