1 ;
2 ; TEXAS INSTRUMENTS TEXT FILE LICENSE
3 ;
4 ; Copyright (c) 2018-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.
55 ;------------------------
56 ;File: psisandf.h
57 ;Purpose:
58 ; experimental do sandf to host over psi (instead of cutthrough)
59 ;------------------------
61 ;----------------------------------------------
62 ;free slot management
63 ;----------------------------------------------
65 ;BSram slots used (96) = 3072 bytes = ~ 2x 1500 byte pkts
66 MAXPS .set 127 ;last slot for 32 byte chuncks
67 MINPS .set 32 ;1st slot for 32 byte chunks
69 ;----------------------
70 ;called by Rx Task
71 ;----------------------
72 ;push r2-r9 to a bs slot, start of packet
73 ;push r2-r9 to a bs slot
74 ; GR_AUX_STATE holds slot control info (r/w ptr)
75 P_W32 .macro full_label
76 .newblock
77 mov r10, GRegs.snf.b.wr_cur
78 xout Q_XID, &r2, 36
79 add GRegs.snf.b.wr_cur, GRegs.snf.b.wr_cur, 1
80 qbge $1, GRegs.snf.b.wr_cur, MAXPS
81 ldi GRegs.snf.b.wr_cur, MINPS
82 $1: qbeq full_label, GRegs.snf.b.wr_cur, GRegs.snf.b.rd_cur
83 .endm
85 P_W32_S .macro full_label
86 mov GRegs.snf.b.wr_orig, GRegs.snf.b.wr_cur ;stash original write pointer in case we abort
87 P_W32 full_label
88 .endm
90 P_W32_ABORT .macro
91 mov GRegs.snf.b.wr_cur, GRegs.snf.b.wr_orig ; restore write pointer
92 .endm
94 ;usefull macro to poll until psiwidget txfifo status says there is room
95 ; steps on r1/r2
96 PSILOOP_STALL_TX_OK .macro
97 .newblock
98 $1: xin XID_PSI_S, &r1, 8
99 qbbs $2, r2, TB_WRITE ;only send if widget unblocked
100 add r30.w2, r30.w2, 1 ;debug -> count # of stalls
101 jmp $1
102 $2:
103 .endm
105 ; called by bg task
106 ;'tx' init for tohost store and forward
107 ; r_d.w0 = len
108 ; r_d.w2 = flow
109 ; r_strti = bsram fifo state snapshot
110 PSISANDF_TX_INIT2 .macro r_d, r_starti
111 mov r11.w0, r_d.w2 ;save flow
112 mov GRegs.snf.b.rd_cur, r_starti.b1 ;save start slot #
113 ;save length we are expecting to transmit
114 mov BgRegs.len2host, r_d.w0
115 mov BgRegs.len_orig, r_d.w0
116 ldi BgRegs.psi2h_active, 1
117 ;send info
118 TM_DISABLE
119 ;ok to write to PSI since we checked before entry to this macro!
120 PSI_GET_INFO2 PSI_INFO_SLOT, r11.w0
121 TM_ENABLE
122 PSI_WRITE
123 PSILOOP_STALL_TX_OK ;stall until PSI tx status good
124 PSISANDF_TX md_lab?, eop_lab? ;now write 2 x 16bytes to PSI, checking that data is available from dma
125 md_lab?:
126 PSILOOP_STALL_TX_OK
127 PSISANDF_TX md_lab2?, eop_lab? ;now write 2 x 16bytes to PSI, checking that data is available from dma
128 md_lab2?:
129 eop_lab?:
130 .endm
132 READ_PAGE .macro page
133 TM_DISABLE
134 mov r10.w0, page
135 xout Q_XID, &r10.w0, 2
136 xin Q_XID, &r2, 32
137 TM_ENABLE
138 .endm
140 ;poll routine for bg. read 32 bytes from BS and send to host in 2 psi transfers
141 ; r_s = psi state
142 ; returns to more_data_lab if still more data, else returns to eop_lab
143 PSISANDF_TX .macro more_data_label, eop_label
145 ;have data ready
146 qbge tx_cont1a?, BgRegs.len2host, 32
147 ;read the 32 bytes & write to PSI in 2 transactions
148 READ_PAGE GRegs.snf.b.rd_cur
149 ldi32 r1, MD_DATA0
150 PSI_WRITE
151 PSILOOP_STALL_TX_OK ;stall until PSI tx status good
152 LEBE2_5_swap_6_9
153 ldi32 r1, MD_DATA0
154 PSI_WRITE
155 sub BgRegs.len2host, BgRegs.len2host, 32
156 add GRegs.snf.b.rd_cur, GRegs.snf.b.rd_cur, 1
157 qbge more_data_label, GRegs.snf.b.rd_cur, MAXPS
158 ldi GRegs.snf.b.rd_cur, MINPS
159 jmp more_data_label
161 tx_cont1a?: ;eop
162 READ_PAGE GRegs.snf.b.rd_cur
163 add GRegs.snf.b.rd_cur, GRegs.snf.b.rd_cur, 1
164 qbge chk_len?, GRegs.snf.b.rd_cur, MAXPS
165 ldi GRegs.snf.b.rd_cur,MINPS
166 chk_len?
167 qble mt16?, BgRegs.len2host, 16
168 ;just have 16bytes or less
169 ldi32 r1, MD_DATA1
170 add r0.b0, BgRegs.len2host, 4
171 PSI_WRITE_N
172 jmp tx_done2?
173 mt16?:
174 ;just have 32bytes or less
175 ldi32 r1, MD_DATA0
176 PSI_WRITE
177 PSILOOP_STALL_TX_OK ;stall until PSI tx status good
178 LEBE2_5_swap_6_9
179 ldi32 r1, MD_DATA1
180 sub BgRegs.len2host, BgRegs.len2host, 16
181 add r0.b0, BgRegs.len2host, 4
182 PSI_WRITE_N
183 tx_done2?:
184 ;send status
185 PSILOOP_STALL_TX_OK ;stall until PSI tx status good
186 ;todo get rx timestamp in here
187 ldi32 r1, FW_CONFIG + RX_TS_BASE
188 lbbo &r11, r1, 0, 8
189 TM_DISABLE
190 PSI_GET_STATUS2 PSI_STATUS_SLOT, r12, r11, r13
191 TM_ENABLE
192 mov r5, BgRegs.len_orig
193 PSI_WRITE
194 ;set tx state
195 ldi BgRegs.psi2h_active, 0
196 jmp eop_label
197 tx_done?:
198 .endm