[processor-sdk/pdk.git] / packages / ti / drv / icss_emac / firmware / icss_switch / src / icss_switch.h
1 ;
2 ; TEXAS INSTRUMENTS TEXT FILE LICENSE
3 ;
4 ; Copyright (c) 2017 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 ;
55 ; file: icss_switch.h
56 ;
57 ; brief: Definitions and mapping of Ethernet switch over PRU
58 ; Includes:
59 ; 1. Buffer pools, queus, descriptors
60 ; 2. Switch configutation parameter
61 ; 3. Statistics
62 ; 4. Events for switch interaction
63 ; 5. Memory Map and Control Register definition
64 ;
65 ;
67 .if !$defined("ICSS_SWITCH__H")
68 ICSS_SWITCH__H .set 1
70 ;****************************************************************************
71 ;* Basic Switch Parameters *
72 ;* Used to auto compute offset addresses on L3 OCMC RAM. Do not modify these*
73 ;* without changing firmware accordingly *
74 ;****************************************************************************
76 SWITCH_BUFFER_SIZE .set 64*1024 ; L3 buffer
77 BLOCK_SIZE .set 32 ; bytes derived from ICSS architecture
78 BD_SIZE .set 4 ; one buffer descriptor is 4 bytes
79 MAX_NUMBER_OF_QUEUES .set 4 ; up to 4 queues supported
80 MIN_NUMBER_OF_QUEUES .set 1 ;
81 NUMBER_OF_PORTS .set 3 ; two phy ports and one host port
82 ;****************************************************************************
83 ;* End of Section *
84 ;****************************************************************************
89 ;****************************************************************************
90 ;* LINK/DUPLEX MACROS & MASKS *
91 ;* Bits for Port Status and Duplexity. This is set by ARM and read by FW *
92 ;* Possible to add more info as bits 2-7 are free *
93 ;****************************************************************************
94 .asg t0, PORT_LINK_UP
95 .asg t1, PORT_IS_HD
97 PORT_LINK_MASK .set 0x1
98 PORT_IS_HD_MASK .set 0x2
100 NUM_EXCESS_COLLISIONS .set 15
102 ;****************************************************************************
103 ;* End of Section *
104 ;****************************************************************************
106 ;****************************************************************************
107 ; *
108 ; *
109 ; *
110 ; *
111 ; Shared RAM Offsets for Switch *
112 ; *
113 ; *
114 ; *
115 ; *
116 ; *
117 ;****************************************************************************
118 ; ICSS Shared RAM 12kB.
120 ; Queues on PHY PORT 1/2
121 NUMBER_OF_QUEUES .set 4 ; different number of queues will have significant impact to memory map
122 ; 48 blocks per max packet
123 ; 2 full sized ETH packets: 96 blocks, 3 packets = 144, 4 packets = 192
125 ; Physical Port queue size. Same for both ports
126 QUEUE_1_SIZE .set 97 ; Network Management high
127 QUEUE_2_SIZE .set 97 ; Network Management low
128 QUEUE_3_SIZE .set 97 ; Protocol specific
129 QUEUE_4_SIZE .set 97 ; NRT (IP,ARP, ICMP, \85)
131 ; HOST PORT QUEUES can buffer up to 4 full sized frames per queue
132 HOST_QUEUE_1_SIZE .set 194 ; Protocol and/or VLAN priority 7 and 6
133 HOST_QUEUE_2_SIZE .set 194 ; Protocol mid
134 HOST_QUEUE_3_SIZE .set 194 ; Protocol low
135 HOST_QUEUE_4_SIZE .set 194 ; NRT (IP, ARP, ICMP \85)
137 COLLISION_QUEUE_SIZE .set 48
138 P0_COL_TOP_MOST_BD_OFFSET .set (4*COLLISION_QUEUE_SIZE) + P0_COL_BD_OFFSET - 4
139 P1_COL_TOP_MOST_BD_OFFSET .set (4*COLLISION_QUEUE_SIZE) + P1_COL_BD_OFFSET - 4
140 P2_COL_TOP_MOST_BD_OFFSET .set (4*COLLISION_QUEUE_SIZE) + P2_COL_BD_OFFSET - 4
142 TOTAL_BUFFER_POOL .set 2*(QUEUE_1_SIZE + QUEUE_2_SIZE + QUEUE_3_SIZE + QUEUE_4_SIZE) + HOST_QUEUE_1_SIZE + HOST_QUEUE_2_SIZE + HOST_QUEUE_3_SIZE + HOST_QUEUE_4_SIZE
144 ; NRT Buffer descriptor definition
145 ; Each buffer descriptor points to a max 32 byte block and has 32 bit in size to have atomic operation.
146 ; PRU can address bytewise into memory.
147 ; Definition of 32 bit desriptor is as follows
148 ;
149 ; Bits Name Meaning
150 ; ==================================================================================================
151 ; 0..7 Index points to index in buffer queue, max 256 x 32 byte blocks can be addressed
152 ; 8..12 Block_length number of valid bytes in this specific block. Will be <=32 bytes on last block of packet
153 ; 13 More "More" bit indicating that there are more blocks for the
154 ; 14 Shadow inidcates that "index" is pointing into shadow buffer
155 ; 15 TimeStamp indicates that this packet has time stamp in seperate buffer - only needed of PTCP runs on host
156 ; 16..17 Port different meaning for ingress and egress, ingress Port=0 inidcates phy port 1 and Port = 1
157 ; inidcates phy port 2. Egress: 0 sends on phy port 1 and 1 sends on phy port 2. Port = 2 goes
158 ; over MAC table look-up
159 ; 18..28 Length 11 bit of total packet length which is put into first BD only so that host access only one BD
160 ; 29 VlanTag indicates that packet has Length/Type field of 0x08100 with VLAN tag in following byte
161 ; 30 Broadcast inidcates that packet goes out on both physical ports, there will be two bd but only one buffer
162 ; 31 Error indicates there was an error in the packet
163 ;
164 .if $defined("PRU")
165 .asg b0, Index
166 .asg b1, Block_length
167 .asg t13, More
168 .asg t14, Shadow
169 .asg t16, TimeStamp
170 .asg b2, Port
171 .asg w2, Length
172 .asg t29, VlanTag
173 .asg t30, Broadcat
174 .asg t31, Error
175 .else
176 ; #defines for bd masks
177 .endif
179 ; NRT Queue Defintion
180 ; Each port has up to 4 queues with variable length. The queus is processed as ring buffer with read and write pointer.
181 ; Both pointer are address pointers and increment by 4 for each buffer descriptor/position.
182 ; Queue has a length defined in constants and a status. Status is defined as described below
183 ;
184 ; Bits Name Meaning
185 ; =====================================================================================================
186 ; 0 Busy_M This queue is busy by the master port which is the PRU receiving packets from the master
187 ; 1 Collision Slave is/has written into shadow queue, both descriptors and data.
188 ; 2 Overflow there was not enough space to write to queue and packet was discarded
189 ; 4..7 Reserved reserved
190 ;
191 ; There is busy slave flag in different byte address to grant access to queue to master in case
192 ; of simultaneous access. Host will alwasys be slave in this case. The PRU which is sending the
193 ; packet on phy port will be the master. When both PRUs wants to write to host queues PRU0
194 ; is master and PRU1 is slave.
195 ;
196 ; Bits Name Meaning
197 ; =====================================================================================================
198 ; 0 Busy_S This queue is busy by the master port which is the PRU receiving packets from the master
199 ; 1..7 Reserved
200 ;
201 ; Length is the number of 32 byte blocks per queue. max_fill_level tells the minimum distance between write and read pointer.
202 ; over_flow_cnt tells how many times the write pointer runs into the read_pointer.
204 .if $defined("PRU")
205 struct_queue .struct
206 rd_ptr .ushort
207 wr_ptr .ushort
208 busy_s .ubyte
209 status .ubyte
210 max_fill_level .ubyte
211 overflow_cnt .ubyte
212 ;struct_queue_len
213 .endstruct
215 .asg t0, busy_m
216 ; .else
217 ;typedef struct _Queue
218 ;{
219 ; uint16_t rd_ptr;
220 ; uint16_t wr_ptr;
221 ; uint8_t busy_s;
222 ; uint8_t status;
223 ; uint8_t max_fill_level;
224 ; uint8_t overflow_cnt;
225 ;} Queue;
226 ;
227 .endif
229 .if $defined("PRU")
230 QUEUE_DESCRIPTOR_SIZE .set $sizeof(struct_queue) ; typically 8 bytes per register
231 ; .else
232 ; #define QUEUE_DESCRIPTOR_SIZE sizeof(Queue) ; typically 8 bytes per register
233 ; .endif
234 TOTAL_QUEUE_DESCRIPTOR_SIZE .set NUMBER_OF_PORTS * NUMBER_OF_QUEUES
236 Q_MAX_FILL_LEVEL_OFFSET .set 6
237 Q_OVERFLOW_CNT_OFFSET .set 7
238 ; Memory Map for buffer pool, buffer descriptor and queue descriptor
239 .asg t7, TX0_UNDERFLOW
240 .asg t8, TX0_OVERFLOW
241 .asg t19, TX1_UNDERFLOW
242 .asg t20, TX1_OVERFLOW
244 ;//**************************************************************************
245 ; *
246 ; *
247 ; Diagrams below show the memory usage for PRU DRAM *
248 ; and shared RAM for switch and EMAC *
249 ; *
250 ; *
251 ;****************************************************************************
253 ;//**************************************************************************
254 ; *
255 ; *
256 ; Usage for switch. Numbers indicate bytes *
257 ; *
258 ; *
259 ;****************************************************************************
261 ; DRAM0 DRAM1 Shared RAM
262 ;***********0x2000************** ************0x2000*************** *************0x3000**************
263 ;** Reserved * ** Reserved * ** Available for Protocol *
264 ;***********0x1FA8************** ***********0x1FA8**************** ** Usage *
265 ;** Used for statistics * ** Used for statistics * * *
266 ;** and misc * ** and misc * ** ***********0x2290*************
267 ;***********0x1F00************** ************0x1F00*************** ** Multicast Filtering Table *
268 ;** * ** Reserved * ** (Only used by Profinet) *
269 ;** * *************0x1EDC************** * Free for other protocols *
270 ;** * ** Switch Context + Misc * *************0X1E80**************
271 ;** Available for Protocol * ** Stored here * ** *
272 ;** Usage * ************0X1D00*************** ** BD Offsets for *
273 ;** * ** * ** 3 queues *
274 ;** * ** Available for Protocol * ** and collision queue *
275 ;** * ** Usage * ** *
276 ;** * ** * **************0x400**************
277 ;************0x200************** **************0x200************** ** Available for Protocols *
278 ;*** Reserved * ** Reserved * ** *
279 ;***********0x0000************** *************0x0000************** *************0x0000**************
281 ;***********************************************************************************************************
282 ; *
283 ; *
284 ; End of Section *
285 ; *
286 ; *
287 ;***********************************************************************************************************
290 ;//**************************************************************************
291 ; *
292 ; *
293 ; Usage for EMAC. Numbers indicate bytes *
294 ; *
295 ; *
296 ;****************************************************************************
298 ; DRAM0 DRAM1 Shared RAM
299 ;***********0x2000************** ************0x2000*************** *************0x3000**************
300 ;** Reserved * ** Reserved * ** *
301 ;***********0x1FA8************** *************0x1FA8************** ** *
302 ;** Used for statistics * ** Used for statistics * ** Available for Protocol *
303 ;** and misc * ** and misc * ** Usage *
304 ;***********0x1F00************** ************0x1F00*************** ** *
305 ;** Queue Context Offsets * ** Queue Context Offsets * ** *
306 ;************0x1EC0************* *************0x1EC0************** * *
307 ;** * ** * *************0X1D00**************
308 ;** Available for Protocol * ** Available for Protocol * ** *
309 ;** Usage * ** Usage * ** BD Offsets for *
310 ;** * ** * ** 3 queues *
311 ;** * ** * ** and host queue BD *
312 ;** * ** * ** + reserved *
313 ;** * ** * **************0x400**************
314 ;************0x200************** **************0x200************** ** Available for Protocols *
315 ;** Reserved * ** Reserved * ** *
316 ;***********0x0000************** *************0x0000************** *************0x0000**************
318 ;***********************************************************************************************************
319 ; *
320 ; *
321 ; End of Section *
322 ; *
323 ; *
324 ;***********************************************************************************************************
326 ;*******************************************************************************
327 ; The following offsets indicate which sections of the memory
328 ; are reserved/provided for other protocol
329 ;*******************************************************************************
330 ;NOTE:Some memory is reserved for future use
331 ;See map above for usage
332 SWITCH_PROTOCOL_SPECIFIC_DRAM0_MEMORY_SIZE .set 0x1F00
333 SWITCH_PROTOCOL_SPECIFIC_DRAM0_MEMORY_OFFSET .set 0x400
335 SWITCH_PROTOCOL_SPECIFIC_DRAM1_USAGE_SIZE .set 0x1D00
336 SWITCH_PROTOCOL_SPECIFIC_DRAM1_MEMORY_OFFSET .set 0x400
338 EMAC_PROTOCOL_SPECIFIC_DRAM_USAGE_SIZE .set 0x1D00
339 EMAC_PROTOCOL_SPECIFIC_DRAM_MEMORY_OFFSET .set 0x400
341 SWITCH_PROTOCOL_SPECIFIC_SRAM_USAGE_SIZE .set 0x3000
342 SWITCH_PROTOCOL_SPECIFIC_SRAM_MEMORY_OFFSET .set 0x2400
344 EMAC_PROTOCOL_SPECIFIC_SRAM_USAGE_SIZE .set 0x300
345 EMAC_PROTOCOL_SPECIFIC_SRAM_MEMORY_OFFSET .set 0x1C00
347 ;The following offsets indicate which sections of the memory are used for switch and EMAC internal tasks
348 SWITCH_SPECIFIC_DRAM0_START_SIZE .set 0x100
349 SWITCH_SPECIFIC_DRAM0_START_OFFSET .set 0x1F00
351 SWITCH_SPECIFIC_DRAM1_START_SIZE .set 0x300
352 SWITCH_SPECIFIC_DRAM1_START_OFFSET .set 0x1D00
354 EMAC_SPECIFIC_DRAM_USAGE_SIZE .set 0x140
355 EMAC_SPECIFIC_DRAM_START_OFFSET .set 0x1EC0
357 SWITCH_SPECIFIC_SRAM_USAGE_SIZE .set 0x2010
358 SWITCH_SPECIFIC_SRAM_START_OFFSET .set 0x400 ;same as EMAC. The BD offsets are common between EMAC and Switch. See diagram
360 EMAC_SPECIFIC_SRAM_USAGE_SIZE .set 0x1900
361 EMAC_SPECIFIC_SRAM_START_OFFSET .set 0x0
365 ;***********************************************************************************************************
366 ; *
367 ; *
368 ; End of Section *
369 ; *
370 ; *
371 ;***********************************************************************************************************
374 ;****************************************************************************
375 ;* General Purpose Statistics *
376 ;* These are present on both PRU0 and PRU1 DRAM *
377 ;****************************************************************************
378 ; base statistics offset
379 STATISTICS_OFFSET .set 0x1F00
381 ; MII port TX statistics flags
382 TX_BC_FRAMES_OFFSET .set 0x0
383 TX_MC_FRAMES_OFFSET .set 0x4
384 TX_UC_FRAMES_OFFSET .set 0x8
386 TX_BYTE_CNT_OFFSET .set 0xc
388 ; MII port RX statistics flags
389 RX_BC_FRAMES_OFFSET .set 0x10
390 RX_MC_FRAMES_OFFSET .set 0x14
391 RX_UC_FRAMES_OFFSET .set 0x18
393 ;Binning counters : disabled by default
394 RX_BYTE_CNT_OFFSET .set 0x1c
396 ;Binning counters : disabled by default
397 TX_64_BYTE_FRAME_OFFSET .set 0x20
398 TX_65_127_BYTE_FRAME_OFFSET .set 0x24
399 TX_128_255_BYTE_FRAME_OFFSET .set 0x28
400 TX_256_511_BYTE_FRAME_OFFSET .set 0x2c
401 TX_512_1023_BYTE_FRAME_OFFSET .set 0x30
402 TX_1024_MAX_BYTE_FRAME_OFFSET .set 0x34
404 RX_64_BYTE_FRAME_OFFSET .set 0x38
405 RX_65_127_BYTE_FRAME_OFFSET .set 0x3c
406 RX_128_255_BYTE_FRAME_OFFSET .set 0x40
407 RX_256_511_BYTE_FRAME_OFFSET .set 0x44
408 RX_512_1023_BYTE_FRAME_OFFSET .set 0x48
409 RX_1024_MAX_BYTE_FRAME_OFFSET .set 0x4c
411 ;**********************************Collision Counters*******************************/
412 LATE_COLLISION_OFFSET .set STATISTICS_OFFSET + 0x50 ;set for a frame where collision took place after 512 bytes were sent on wire
413 SINGLE_COLLISION_OFFSET .set STATISTICS_OFFSET + 0x54 ;frame was sent after a single collision was reported
414 MULTIPLE_COLLISION_OFFSET .set STATISTICS_OFFSET + 0x58 ;frame was sent after more than one collision
415 EXCESS_COLLISION_OFFSET .set STATISTICS_OFFSET + 0x5c ;more than 16 collisions
416 ;***********************************************************************************/
418 ;********************Error packets****************
419 ;Packed dropped on account of storm prevention
420 RX_MISALIGNMENT_COUNT_OFFSET .set STATISTICS_OFFSET + 0x60 ;frame size in bits is not a multiple of 8
421 STORM_PREVENTION_COUNTER .set STATISTICS_OFFSET + 0x64
422 RX_ERROR_OFFSET .set STATISTICS_OFFSET + 0x68
423 SFD_ERROR_OFFSET .set STATISTICS_OFFSET + 0x6c
424 TX_DEFERRED_OFFSET .set STATISTICS_OFFSET + 0x70
425 TX_ERROR_OFFSET .set STATISTICS_OFFSET + 0x74
426 RX_OVERSIZED_FRAME_OFFSET .set STATISTICS_OFFSET + 0x78 ;count of frames with size greater than 1518 bytes
427 RX_UNDERSIZED_FRAME_OFFSET .set STATISTICS_OFFSET + 0x7c ;count of frames shorter than 64 bytes (including CRC)
428 RX_CRC_COUNT_OFFSET .set STATISTICS_OFFSET + 0x80 ;number of frames with CRC error
429 RX_DROPPED_FRAMES_OFFSET .set STATISTICS_OFFSET + 0x84
431 ;****************Debug Statistics***************************************************/
432 TX_OVERFLOW_OFFSET .set STATISTICS_OFFSET + 0x88
433 TX_UNDERFLOW_OFFSET .set STATISTICS_OFFSET + 0x8c
435 ;**********************************************************************************/
438 STAT_SIZE .set 0x90 ;always keep it's value same as the last stat offset
440 ;****************************************************************************
441 ; End of Statistics *
442 ;****************************************************************************
445 ;****************************************************************************
446 ;* Offset for storing *
447 ; 1. Storm Prevention Params *
448 ; 2. PHY Speed Offset *
449 ; 3. Port Status Offset *
450 ;* These are present on both PRU0 and PRU1 *
451 ;****************************************************************************
452 ;STATISTICS_OFFSET .set 0x1f00
453 STORM_PREVENTION_OFFSET .set STATISTICS_OFFSET + STAT_SIZE ;4 bytes
454 PHY_SPEED_OFFSET .set STATISTICS_OFFSET + STAT_SIZE + 4 ;4 bytes
455 PORT_STATUS_OFFSET .set STATISTICS_OFFSET + STAT_SIZE + 8 ;1 byte
456 COLLISION_COUNTER .set STATISTICS_OFFSET + STAT_SIZE + 9 ;1 byte
457 RX_PKT_SIZE_OFFSET .set STATISTICS_OFFSET + STAT_SIZE + 10 ;4 bytes
458 PORT_CONTROL_ADDR .set STATISTICS_OFFSET + STAT_SIZE + 14 ;4 bytes
459 PORT_MAC_ADDR .set STATISTICS_OFFSET + STAT_SIZE + 18 ;6 bytes
460 RX_INT_STATUS_OFFSET .set STATISTICS_OFFSET + STAT_SIZE + 24 ;1 byte
462 ;***********************************************************************************************************
463 ; *
464 ; *
465 ; End of Section *
466 ; *
467 ; *
468 ;***********************************************************************************************************
471 ;****************************************************************************
472 ; *
473 ; *
474 ; *
475 ; *
476 ; DRAM1 Offsets for Switch *
477 ; *
478 ; *
479 ; *
480 ; *
481 ; *
482 ;****************************************************************************
483 ;*****************Queue Descriptors********************
484 P2_QUEUE_DESC_OFFSET .set 0x1EBC ; 4 queue descriptors for port 2 (PRU0 xmt)
485 P1_QUEUE_DESC_OFFSET .set 0x1E9C ; 4 queue descriptors for port 1 (PRU1 xmt)
486 P0_QUEUE_DESC_OFFSET .set 0x1E7C ; 4 queue descriptors for port 0 (host receive)
487 P2_COL_QUEUE_DESC_OFFSET .set 0x1E74 ; collision descriptor of port 2
488 P1_COL_QUEUE_DESC_OFFSET .set 0x1E6C ; collision descriptor of port 1
489 P0_COL_QUEUE_DESC_OFFSET .set 0x1E64 ; collision descriptor of port 0
490 COLLISION_STATUS_ADDR .set 0x1E60 ; Collision Status Register, P0: bit 0 is pending flag, bit 1..2 inidicates which queue,
491 ; P1: bit 8 is pending flag, 9..10 is queue number
492 ; p2: bit 16 is pending flag, 17..18 is queue number, remaining bits are 0.
494 INTERFACE_MAC_ADDR .set 0x1E58 ; Interface MAC Address
495 P2_MAC_ADDR .set 0x1E50 ; Port 2 MAC Address
496 P1_MAC_ADDR .set 0x1E48 ; Port 1 MAC Address
497 ; With dynamic configuration of queue size the offsets are variablel. For PRU to find which queue and descriptor needs to be served there
498 ; is a look-up table with index of port and queue number.
499 ; table definition to access queue size, buffer descriptor and buffer
501 ; table offset for queue size: 3 ports * 4 Queues * 1 byte offset = 24 bytes
502 QUEUE_SIZE_ADDR .set 0x1E30
503 ; table offset for queue: 3 ports * 4 Queues * 2 byte offset = 24 bytes
504 QUEUE_OFFSET_ADDR .set 0x1E18
505 ; table offset for queue descriptors: 3 ports * 4 Queues * 2 byte offset = 24 bytes
506 QUEUE_DESCRIPTOR_OFFSET_ADDR .set 0x1E00
507 ; todo: remove this older definition
508 QUEUE_SIZE_TBL_ADDR .set 0x1E00 ; table is filled by host before operation and structured in
509 ; 0x1E08: P0Q0 0x1E09: P0Q1 0x1E0A: P0Q2 0x1E0B: P0Q3
510 ; 0x1E04: P1Q0 0x1E05: P1Q1 0x1E06: P1Q2 0x1E07: P0Q3
511 ; 0x1E00: P0Q0 0x1E01: P0Q1 0x1E02: P0Q2 0x1E03: P0Q3
513 CONFIGURATION_OFFSET .set 0x1E00 ; 256 bytes of Configuratuin which also includes queue descriptors
515 ; Port 1
516 TX_CONTEXT_P1_Q1_OFFSET_ADDR .set SWITCH_SPECIFIC_DRAM1_START_OFFSET
517 P1_Q1_TX_CONTEXT_OFFSET .set TX_CONTEXT_P1_Q1_OFFSET_ADDR
518 P1_Q2_TX_CONTEXT_OFFSET .set P1_Q1_TX_CONTEXT_OFFSET + 8
519 P1_Q3_TX_CONTEXT_OFFSET .set P1_Q2_TX_CONTEXT_OFFSET + 8
520 P1_Q4_TX_CONTEXT_OFFSET .set P1_Q3_TX_CONTEXT_OFFSET + 8
521 ; Port 2
522 TX_CONTEXT_P2_Q1_OFFSET_ADDR .set P1_Q4_TX_CONTEXT_OFFSET + 8
523 P2_Q1_TX_CONTEXT_OFFSET .set TX_CONTEXT_P2_Q1_OFFSET_ADDR
524 P2_Q2_TX_CONTEXT_OFFSET .set P2_Q1_TX_CONTEXT_OFFSET + 8
525 P2_Q3_TX_CONTEXT_OFFSET .set P2_Q2_TX_CONTEXT_OFFSET + 8
526 P2_Q4_TX_CONTEXT_OFFSET .set P2_Q3_TX_CONTEXT_OFFSET + 8
528 ; Port 1 Tx Collision Context
529 COL_TX_CONTEXT_P1_Q1_OFFSET_ADDR .set P2_Q4_TX_CONTEXT_OFFSET + 8
530 ; Port 2 Tx Collision Context
531 COL_TX_CONTEXT_P2_Q1_OFFSET_ADDR .set COL_TX_CONTEXT_P1_Q1_OFFSET_ADDR + 8
533 ; Host Port Rx Context
534 RX_CONTEXT_P0_Q1_OFFSET_ADDR .set COL_TX_CONTEXT_P2_Q1_OFFSET_ADDR + 8
535 P0_Q1_RX_CONTEXT_OFFSET .set RX_CONTEXT_P0_Q1_OFFSET_ADDR
536 P0_Q2_RX_CONTEXT_OFFSET .set P0_Q1_RX_CONTEXT_OFFSET + 8
537 P0_Q3_RX_CONTEXT_OFFSET .set P0_Q2_RX_CONTEXT_OFFSET + 8
538 P0_Q4_RX_CONTEXT_OFFSET .set P0_Q3_RX_CONTEXT_OFFSET + 8
540 ; Port 1 Rx Context
541 RX_CONTEXT_P1_Q1_OFFSET_ADDR .set P0_Q4_RX_CONTEXT_OFFSET + 8
542 P1_Q1_RX_CONTEXT_OFFSET .set RX_CONTEXT_P1_Q1_OFFSET_ADDR
543 P1_Q2_RX_CONTEXT_OFFSET .set P1_Q1_RX_CONTEXT_OFFSET + 8
544 P1_Q3_RX_CONTEXT_OFFSET .set P1_Q2_RX_CONTEXT_OFFSET + 8
545 P1_Q4_RX_CONTEXT_OFFSET .set P1_Q3_RX_CONTEXT_OFFSET + 8
547 ; Port 2 Rx Context
548 RX_CONTEXT_P2_Q1_OFFSET_ADDR .set P1_Q4_RX_CONTEXT_OFFSET + 8
549 P2_Q1_RX_CONTEXT_OFFSET .set RX_CONTEXT_P2_Q1_OFFSET_ADDR
550 P2_Q2_RX_CONTEXT_OFFSET .set P2_Q1_RX_CONTEXT_OFFSET + 8
551 P2_Q3_RX_CONTEXT_OFFSET .set P2_Q2_RX_CONTEXT_OFFSET + 8
552 P2_Q4_RX_CONTEXT_OFFSET .set P2_Q3_RX_CONTEXT_OFFSET + 8
554 ; Host Port Collision Context
555 COL_RX_CONTEXT_P0_OFFSET_ADDR .set P2_Q4_RX_CONTEXT_OFFSET + 8 ;10 bytes
556 ; Port 1 Rx Collision context
557 COL_RX_CONTEXT_P1_OFFSET_ADDR .set COL_RX_CONTEXT_P0_OFFSET_ADDR + 12 ;10 bytes
558 ; Port 2 Rx Collision context
559 COL_RX_CONTEXT_P2_OFFSET_ADDR .set COL_RX_CONTEXT_P1_OFFSET_ADDR + 12 ;10 bytes
562 ;***********************************************************************************************************
563 ; *
564 ; *
565 ; End of Section *
566 ; *
567 ; *
568 ;***********************************************************************************************************
571 PORT_QUEUE_DESC_OFFSET .set EMAC_SPECIFIC_DRAM_START_OFFSET ; 4 queue descriptors for port tx. 32 bytes
572 TX_CONTEXT_Q1_OFFSET_ADDR .set PORT_QUEUE_DESC_OFFSET + 32
573 ;***********************************************************************************************************
574 ; *
575 ; *
576 ; End of Section *
577 ; *
578 ; *
579 ;***********************************************************************************************************
581 ;****************************************************************************
582 ; *
583 ; *
584 ; *
585 ; *
586 ; DRAM Offsets for EMAC *
587 ; Present on Both DRAM0 and DRAM1 *
588 ; *
589 ; *
590 ; *
591 ; *
592 ;****************************************************************************
593 ; table offset for Port queue descriptors: 1 ports * 4 Queues * 2 byte offset = 8 bytes
594 Q1_TX_CONTEXT_OFFSET .set TX_CONTEXT_Q1_OFFSET_ADDR
595 Q2_TX_CONTEXT_OFFSET .set Q1_TX_CONTEXT_OFFSET + 8
596 Q3_TX_CONTEXT_OFFSET .set Q2_TX_CONTEXT_OFFSET + 8
597 Q4_TX_CONTEXT_OFFSET .set Q3_TX_CONTEXT_OFFSET + 8
599 HOST_BD_SIZE .set (HOST_QUEUE_1_SIZE + HOST_QUEUE_2_SIZE + HOST_QUEUE_3_SIZE + HOST_QUEUE_4_SIZE) * BD_SIZE
600 PORT_BD_SIZE .set (QUEUE_1_SIZE + QUEUE_2_SIZE + QUEUE_3_SIZE + QUEUE_4_SIZE) * 2 * BD_SIZE
602 P0_BUFFER_DESC_OFFSET .set SWITCH_SPECIFIC_SRAM_START_OFFSET
603 EOF_48K_BUFFER_BD .set P0_BUFFER_DESC_OFFSET + HOST_BD_SIZE + PORT_BD_SIZE
604 P0_COL_BD_OFFSET .set EOF_48K_BUFFER_BD
605 EOF_COL_BUFFER_BD .set P0_COL_BD_OFFSET + 3* BD_SIZE * 48
607 ;Static Tables are only used in Profinet, they are not used in EMAC, EtherNet/IP or HSR/PRP
608 STATIC_MAC_TABLE_RCV_PORT1 .set EOF_COL_BUFFER_BD
609 STATIC_MAC_TABLE_FWD_PORT1 .set STATIC_MAC_TABLE_RCV_PORT1 + 256
610 STATIC_MAC_TABLE_RCV_PORT2 .set STATIC_MAC_TABLE_FWD_PORT1 + 256
611 STATIC_MAC_TABLE_FWD_PORT2 .set STATIC_MAC_TABLE_RCV_PORT2 + 256
613 ;***********************************************************************************************************
614 ; *
615 ; *
616 ; End of Section *
617 ; *
618 ; *
619 ;***********************************************************************************************************
621 ;****************************************************************************
622 ; *
623 ; *
624 ; *
625 ; *
626 ; Shared RAM offsets for EMAC *
627 ; *
628 ; *
629 ; *
630 ; *
631 ; *
632 ;****************************************************************************
634 MULTICAST_FIRST_VALID_ADDR_OFFSET .set STATIC_MAC_TABLE_FWD_PORT2 + 256 ;6 bytes
635 MULTICAST_LAST_VALID_ADDR_OFFSET .set MULTICAST_FIRST_VALID_ADDR_OFFSET + 8 ;6 bytes
637 P1_COL_BD_OFFSET .set P0_COL_BD_OFFSET + BD_SIZE * 48
638 P2_COL_BD_OFFSET .set P1_COL_BD_OFFSET + BD_SIZE * 48
640 ;EMAC Firmware Version Information
641 ICSS_EMAC_FIRMWARE_RELEASE_1_OFFSET .set 0
642 ICSS_EMAC_FIRMWARE_RELEASE_2_OFFSET .set ICSS_EMAC_FIRMWARE_RELEASE_1_OFFSET + 4
643 ICSS_EMAC_FIRMWARE_FEATURE_OFFSET .set ICSS_EMAC_FIRMWARE_RELEASE_2_OFFSET + 4
644 ICSS_EMAC_FIRMWARE_RESERVED_FEATURE_OFFSET .set ICSS_EMAC_FIRMWARE_FEATURE_OFFSET + 4
645 ; Host Port Rx Context
646 HOST_Q1_RX_CONTEXT_OFFSET .set EOF_48K_BUFFER_BD ;1; Prashant - TODO EOF_48K_BUFFER_BD
647 HOST_Q2_RX_CONTEXT_OFFSET .set HOST_Q1_RX_CONTEXT_OFFSET + 8
648 HOST_Q3_RX_CONTEXT_OFFSET .set HOST_Q2_RX_CONTEXT_OFFSET + 8
649 HOST_Q4_RX_CONTEXT_OFFSET .set HOST_Q3_RX_CONTEXT_OFFSET + 8
651 ;***********************************************************************************************************
652 ; *
653 ; *
654 ; End of Section *
655 ; *
656 ; *
657 ;***********************************************************************************************************
660 ;****************************************************************************
661 ; *
662 ; *
663 ; *
664 ; *
665 ; Shared RAM offsets for both Switch and EMAC *
666 ; *
667 ; *
668 ; *
669 ; *
670 ; *
671 ;****************************************************************************
673 ; allow for max 48k switch buffer which spans the descriptors up to 0x1800 6kB
675 ; table offset for Host queue descriptors: 1 ports * 4 Queues * 2 byte offset = 8 bytes
676 HOST_QUEUE_DESCRIPTOR_OFFSET_ADDR .set HOST_Q4_RX_CONTEXT_OFFSET + 8 ;8 bytes
677 ; table offset for queue: 4 Queues * 2 byte offset = 8 bytes
678 HOST_QUEUE_OFFSET_ADDR .set HOST_QUEUE_DESCRIPTOR_OFFSET_ADDR + 8
679 ; table offset for queue size: 3 ports * 4 Queues * 1 byte offset = 12 bytes
680 HOST_QUEUE_SIZE_ADDR .set HOST_QUEUE_OFFSET_ADDR + 8
682 ;------------------------------Queue Descriptors--------------------------------;
683 HOST_QUEUE_DESC_OFFSET .set HOST_QUEUE_SIZE_ADDR + 16 ; 4 queue descriptors for port 0 (host receive). 32 bytes
684 ;------------------------------End of queue descriptors---------------------------;
685 P0_Q1_BD_OFFSET .set P0_BUFFER_DESC_OFFSET
686 P0_Q2_BD_OFFSET .set P0_Q1_BD_OFFSET + HOST_QUEUE_1_SIZE * BD_SIZE
687 P0_Q3_BD_OFFSET .set P0_Q2_BD_OFFSET + HOST_QUEUE_2_SIZE * BD_SIZE
688 P0_Q4_BD_OFFSET .set P0_Q3_BD_OFFSET + HOST_QUEUE_3_SIZE * BD_SIZE
690 P1_Q1_BD_OFFSET .set P0_Q4_BD_OFFSET + HOST_QUEUE_4_SIZE * BD_SIZE
691 P1_Q2_BD_OFFSET .set P1_Q1_BD_OFFSET + QUEUE_1_SIZE * BD_SIZE
692 P1_Q3_BD_OFFSET .set P1_Q2_BD_OFFSET + QUEUE_2_SIZE * BD_SIZE
693 P1_Q4_BD_OFFSET .set P1_Q3_BD_OFFSET + QUEUE_3_SIZE * BD_SIZE
695 P2_Q1_BD_OFFSET .set P1_Q4_BD_OFFSET + QUEUE_4_SIZE * BD_SIZE
696 P2_Q2_BD_OFFSET .set P2_Q1_BD_OFFSET + QUEUE_1_SIZE * BD_SIZE
697 P2_Q3_BD_OFFSET .set P2_Q2_BD_OFFSET + QUEUE_2_SIZE * BD_SIZE
698 P2_Q4_BD_OFFSET .set P2_Q3_BD_OFFSET + QUEUE_3_SIZE * BD_SIZE
700 ;***********************************************************************************************************
701 ; *
702 ; *
703 ; End of Section *
704 ; *
705 ; *
706 ;***********************************************************************************************************
709 ;****************************************************************************
710 ; *
711 ; *
712 ; *
713 ; *
714 ; Memory Usage of L3 OCMC RAM *
715 ; *
716 ; *
717 ; *
718 ; *
719 ; *
720 ;****************************************************************************
721 ; L3 64KB Memory - mainly buffer Pool
722 ; put collision buffer at end of L3 memory. Simplifies PRU coding to be on same memory as queue buffer
723 P2_COL_BUFFER_OFFSET .set 0xFA00 ; 1536 byte collision buffer for port 2 send queue
724 P1_COL_BUFFER_OFFSET .set 0xF400 ; 1536 byte collision buffer for port 1 send queue
725 P0_COL_BUFFER_OFFSET .set 0xEE00 ; 1536 byte collision buffer for port 0 send queue
727 P0_Q1_BUFFER_OFFSET .set 0x0000
728 P0_Q2_BUFFER_OFFSET .set P0_Q1_BUFFER_OFFSET + HOST_QUEUE_1_SIZE * BLOCK_SIZE
729 P0_Q3_BUFFER_OFFSET .set P0_Q2_BUFFER_OFFSET + HOST_QUEUE_2_SIZE * BLOCK_SIZE
730 P0_Q4_BUFFER_OFFSET .set P0_Q3_BUFFER_OFFSET + HOST_QUEUE_3_SIZE * BLOCK_SIZE
731 P1_Q1_BUFFER_OFFSET .set P0_Q4_BUFFER_OFFSET + HOST_QUEUE_4_SIZE * BLOCK_SIZE
732 P1_Q2_BUFFER_OFFSET .set P1_Q1_BUFFER_OFFSET + QUEUE_1_SIZE * BLOCK_SIZE
733 P1_Q3_BUFFER_OFFSET .set P1_Q2_BUFFER_OFFSET + QUEUE_2_SIZE * BLOCK_SIZE
734 P1_Q4_BUFFER_OFFSET .set P1_Q3_BUFFER_OFFSET + QUEUE_3_SIZE * BLOCK_SIZE
735 P2_Q1_BUFFER_OFFSET .set P1_Q4_BUFFER_OFFSET + QUEUE_4_SIZE * BLOCK_SIZE
736 P2_Q2_BUFFER_OFFSET .set P2_Q1_BUFFER_OFFSET + QUEUE_1_SIZE * BLOCK_SIZE
737 P2_Q3_BUFFER_OFFSET .set P2_Q2_BUFFER_OFFSET + QUEUE_2_SIZE * BLOCK_SIZE
738 P2_Q4_BUFFER_OFFSET .set P2_Q3_BUFFER_OFFSET + QUEUE_3_SIZE * BLOCK_SIZE
739 END_OF_BUFFER_POOL .set P2_Q4_BUFFER_OFFSET + QUEUE_4_SIZE * BLOCK_SIZE
741 ;***********************************************************************************************************
742 ; *
743 ; *
744 ; End of Section *
745 ; *
746 ; *
747 ;***********************************************************************************************************
749 .if $defined("PRU")
750 ; Collision Status Register
751 struct_collision_status .struct
752 port0 .ubyte ; port 0 pending and queue number
753 port1 .ubyte ; port 1 pending and queue number
754 port2 .ubyte ; port 2 pending and queue number
755 .endstruct
757 .asg t0, P0_COLLISION_PENDING
758 .asg t8, P1_COLLISION_PENDING
759 .asg t16, P2_COLLISION_PENDING
760 .asg t24, HOST_COLLISION_READ_PENDING ;Host yet to clear the collision buffer
763 .endif
765 ; switch configuration
766 ; enable ports : receive enable , transmit enable, block, learning, flush table, age out table (older are removed), tear
767 ; rate limiting setup
768 ; filter database setup for MC
769 ; learn multicast option one for both ports
770 ; learn broadcast option one for both ports
771 ; statistics clear
772 .endif ;ICSS_SWITCH__H