[processor-sdk/pdk.git] / packages / ti / drv / emac / firmware / icss_switch / config / emac_fw_config_switch.c
1 /*
2 * TEXAS INSTRUMENTS TEXT FILE LICENSE
3 *
4 * Copyright (c) 2019 Texas Instruments Incorporated
5 *
6 * All rights reserved not granted herein.
7 *
8 * Limited License.
9 *
10 * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
11 * license under copyrights and patents it now or hereafter owns or controls to
12 * make, have made, use, import, offer to sell and sell ("Utilize") this software
13 * subject to the terms herein. With respect to the foregoing patent license,
14 * such license is granted solely to the extent that any such patent is necessary
15 * to Utilize the software alone. The patent license shall not apply to any
16 * combinations which include this software, other than combinations with devices
17 * manufactured by or for TI (“TI Devices”). No hardware patent is licensed hereunder.
18 *
19 * Redistributions must preserve existing copyright notices and reproduce this license
20 * (including the above copyright notice and the disclaimer and (if applicable) source
21 * code license limitations below) in the documentation and/or other materials provided
22 * with the distribution.
23 *
24 * Redistribution and use in binary form, without modification, are permitted provided
25 * that the following conditions are met:
26 * No reverse engineering, decompilation, or disassembly of this software is
27 * permitted with respect to any software provided in binary form.
28 * Any redistribution and use are licensed by TI for use only with TI Devices.
29 * Nothing shall obligate TI to provide you with source code for the software
30 * licensed and provided to you in object code.
31 *
32 * If software source code is provided to you, modification and redistribution of the
33 * source code are permitted provided that the following conditions are met:
34 * Any redistribution and use of the source code, including any resulting derivative
35 * works, are licensed by TI for use only with TI Devices.
36 * Any redistribution and use of any object code compiled from the source code
37 * and any resulting derivative works, are licensed by TI for use only with TI Devices.
38 *
39 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
40 * may be used to endorse or promote products derived from this software without
41 * specific prior written permission.
42 *
43 * DISCLAIMER.
44 *
45 * THIS SOFTWARE IS PROVIDED BY TI AND TI’S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED
46 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
47 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TI AND TI’S
48 * LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
49 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
50 * GOODS OR SERVICES* LOSS OF USE, DATA, OR PROFITS* OR BUSINESS INTERRUPTION) HOWEVER
51 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
53 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
56 /**
57 * @file emac_fw_config_switch.c
58 * @brief EMAC firmware configuration file which contain initializtion values for
59 * static configuration parameters for ICSSG Firmware.
60 *
61 */
63 /* ========================================================================== */
64 /* Include Files */
65 /* ========================================================================== */
67 #include <stdint.h>
68 #include <ti/csl/cslr_icss.h>
69 #include <ti/drv/emac/src/v5/emac_drv_v5.h>
70 #include <ti/drv/emac/firmware/icss_switch/config/emac_fw_config_switch.h>
72 EMAC_ICSSG_SWITCH_FW_CFG emac_switch_cfg = {
73 EMAC_ICSSG_SWITCH_PORT_QUEUE_CONTEXT_OFFSET,
74 EMAC_ICSSG_SWITCH_PORT_DESC_QUEUE_CONTEXT_OFFSET,
75 {
76 NRT_PORT_QUEUE_SIZE,NRT_PORT_QUEUE_SIZE,NRT_PORT_QUEUE_SIZE,NRT_PORT_QUEUE_SIZE,NRT_PORT_QUEUE_SIZE,NRT_PORT_QUEUE_SIZE,NRT_PORT_QUEUE_SIZE,NRT_PORT_QUEUE_SIZE
77 },
78 {
79 NRT_HOST_QUEUE_SIZE,NRT_HOST_QUEUE_SIZE,NRT_HOST_QUEUE_SIZE,NRT_HOST_QUEUE_SIZE,NRT_HOST_QUEUE_SIZE,NRT_HOST_QUEUE_SIZE,NRT_HOST_QUEUE_SIZE,NRT_HOST_QUEUE_SIZE
80 },
81 PORT_DESC_Q0_OFFSET,
82 MTU_SIZE,
83 EMAC_ICSSG_SWITCH_DEFAULT_VLAN_TABLE_OFFSET,
84 EMAC_ICSSG_SWITCH_PSI_L_REGULAR_FLOW_ID_BASE_OFFSET,
85 EMAC_ICSSG_SWITCH_PSI_L_MGMT_FLOW_ID_BASE_OFFSET,
86 EMAC_ICSSG_SWITCH_PORT0_DEFAULT_VLAN_OFFSET,
87 EMAC_ICSSG_SWITCH_PORT1_DEFAULT_VLAN_OFFSET,
88 EMAC_ICSSG_SWITCH_PORT2_DEFAULT_VLAN_OFFSET,
89 EMAC_ICSSG_SWITCH_PORT_QUEUE_READ_PTR_OFFSET,
90 PORT_Q_PRIORITY_REGEN_OFFSET,
91 NRT_PORT_DESC_QUEUE_SIZE,
92 NRT_HOST_DESC_QUEUE_SIZE,
93 EXPRESS_PRE_EMPTIVE_Q_MAP,
94 SPL_PKT_DEFAULT_PRIORITY,
95 FDB_AGEING_TIMEOUT_OFFSET,
96 PRE_EMPTION_ENABLE_TX, //placeholder for premptionTxEnabledStatusOffset
97 PRE_EMPTION_ACTIVE_TX, //placeholder for premptionTxActiveStatusOffset
98 PRE_EMPTION_ENABLE_VERIFY, //placeholder for premptionVerifyStateStatusOffset
99 PRE_EMPTION_VERIFY_STATUS, //placeholder for premptionVerifyStateValueOffset
100 PRE_EMPTION_ADD_FRAG_SIZE_LOCAL, //placeholder for premptionMinFragSizeOffset
101 PRE_EMPTION_ADD_FRAG_SIZE_REMOTE, //placeholder for premptionMinFragAddOffset
102 DEFAULT_FDB_AGEING_INTERVAL, // Default ageing timeout value
103 NUMBER_OF_FDB_BUCKET_ENTRIES, // Number of entries in FDB bucket
104 SIZE_OF_FDB, // FDB size
105 PORT_Q_PRIORITY_MAPPING_OFFSET, //Port Priority Mapping offset
106 P1_QUEUE_NUM_UNTAGGED, // Untagged packet default Queue num offset Port1
107 P2_QUEUE_NUM_UNTAGGED // Untagged packet default Queue num offset Port1
108 };
111 EMAC_PER_PORT_ICSSG_FW_CFG emacFwCfgMmapSwitch[EMAC_MAX_ICSS*2] = {
112 {
113 {0,0},
114 (struct EMAC_FW_PORT_CFG*)&emac_switch_cfg,
115 },
116 {
117 {0,0},
118 (struct EMAC_FW_PORT_CFG*)&emac_switch_cfg,
119 },
120 {
121 {0,0},
122 (struct EMAC_FW_PORT_CFG*)&emac_switch_cfg,
123 },
124 {
125 {0,0},
126 (struct EMAC_FW_PORT_CFG*)&emac_switch_cfg,
127 },
128 {
129 {0,0},
130 (struct EMAC_FW_PORT_CFG*)&emac_switch_cfg,
131 },
132 {
133 {0,0},
134 (struct EMAC_FW_PORT_CFG*)&emac_switch_cfg,
135 }
136 };
138 /**
139 * \brief Gets the EMAC switch firmware configuration
140 *
141 * @param[in] port_num port number
142 * @param[in] pFwCfg Address of pointer to be set to firmware configuration structure
143 *
144 * \return 0 success: -1: error
145 *
146 */
147 int32_t emacGetSwitchFwConfig(uint32_t portNum, EMAC_PER_PORT_ICSSG_FW_CFG **pFwCfg)
148 {
149 int32_t ret = -1;
150 if ((pFwCfg != NULL) && (portNum < (EMAC_MAX_ICSS*2)))
151 {
152 *pFwCfg = &(emacFwCfgMmapSwitch[portNum]);
153 ret = 0;
154 }
155 return ret;
156 }
158 /**
159 * \brief Sets the EMAC switch firmware configuration
160 *
161 * @param[in] port_num port number
162 * @param[in] pFwCfg Pointer to firmware configuration to be set
163 *
164 * \return 0 success: -1: error
165 */
166 int32_t emacSetSwitchFwConfig(uint32_t portNum, const EMAC_PER_PORT_ICSSG_FW_CFG *pFwCfg)
167 {
168 int32_t ret = -1;
169 if ((pFwCfg != NULL) && (portNum < (EMAC_MAX_ICSS*2)))
170 {
171 memcpy(&(emacFwCfgMmapSwitch[portNum]),pFwCfg, sizeof(EMAC_PER_PORT_ICSSG_FW_CFG));
172 ret = 0;
173 }
174 return ret;
175 }
178 /**
179 * \brief Gets the application provided EMAC switch firmware configuration
180 *
181 * @param[in] port_num port number
182 * @param[in] pFwCfg Address of pointer to be set to application provided firmware configuration structure
183 *
184 * \return 0 success: -1: error
185 *
186 */
187 int32_t emacGetSwitchFwAppInitCfg(uint32_t portNum, EMAC_FW_APP_CONFIG **pFwAppCfg)
188 {
189 int32_t ret = -1;
190 if ((pFwAppCfg != NULL) && (portNum < (EMAC_MAX_ICSS*2)))
191 {
192 *pFwAppCfg =&(emacFwCfgMmapSwitch[portNum].fwAppCfg);
193 ret = 0;
194 }
195 return ret;
196 }
198 /**
199 * \brief Sets the application provided EMAC dual mac firmware configuration
200 *
201 * @param[in] port_num port number
202 * @param[in] pFwCfg Pointer to application provided firmware configuration to be set
203 *
204 * \return 0 success: -1: error
205 *
206 */
207 int32_t emacSetSwitchFwAppInitCfg(uint32_t portNum, EMAC_FW_APP_CONFIG *pFwAppCfg)
208 {
209 int32_t ret = -1;
211 if ((pFwAppCfg != NULL) && (portNum < (EMAC_MAX_ICSS*2)))
212 {
213 emacFwCfgMmapSwitch[portNum].fwAppCfg.txPortQueueHighAddr = pFwAppCfg->txPortQueueHighAddr;
214 emacFwCfgMmapSwitch[portNum].fwAppCfg.txPortQueueLowAddr = pFwAppCfg->txPortQueueLowAddr;
215 emacFwCfgMmapSwitch[portNum].fwAppCfg.txPortQueueSize = pFwAppCfg->txPortQueueSize;
216 return 0;
217 }
218 return ret;
219 }