cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
tcp_shell_if.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016 -- 2021 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
30 #ifndef _TSIF_H_
31 #define _TSIF_H_
32 
33 #include <hls_stream.h>
34 #include "ap_int.h"
35 
36 #include "../../../../cFDK/SRA/LIB/SHELL/LIB/hls/NTS/nts.hpp"
37 #include "../../../../cFDK/SRA/LIB/SHELL/LIB/hls/NTS/nts_utils.hpp"
38 
39 //-------------------------------------------------------------------
40 //-- CONSTANTS FOR THE INTERNAL STREAM DEPTHS
41 //-------------------------------------------------------------------
42 const int cDepth_IRbToRDp_Data = 256; // SizeOf input data read buffer (in #chunks)
43 const int cDepth_IRbToRDp_Meta = 256; // SizeOf input meta read buffer (in #metadata)
44 
45 const int cDepth_RNhToRRh_Notif = 64; // SizeOf input notif buffer (in #notifications)
46 const int cDepth_RRhToRDp_FwdCmd = 8; // SizeOf output data request buffer (in #requests)
48 
52 
55 
56 //-------------------------------------------------------------------
57 //-- CONSTANTS FOR THE TCP SHELL INTERFACE
58 //-------------------------------------------------------------------
59 const int cMaxSessions = TOE_MAX_SESSIONS;
60 
62 const int cMinDataReqLen = 128; // The minimum DReq length we want to generate
63 
64 //-------------------------------------------------------------------
65 //-- DEFAULT LOCAL-FPGA AND FOREIGN-HOST SOCKETS
66 //-- By default, the following sockets and port numbers will be used
67 //-- by the TcpShellInterface (unless user specifies new ones via TBD).
68 //-- Default listen ports:
69 //-- --> 5001 : Traffic received on this port is [TODO-TBD].
70 //-- It is used to emulate IPERF V2.
71 //-- --> 5201 : Traffic received on this port is [TODO-TBD].
72 //-- It is used to emulate IPREF V3.
73 //-- --> 8800 : Traffic received on this port is systematically
74 //-- dumped. It is used to test the Rx part of TOE.
75 //-- --> 8801 : A message received on this port triggers the
76 //-- transmission of 'nr' bytes from the FPGA to the host.
77 //-- It is used to test the Tx part of TOE.
78 //-- --> 8802 : Traffic received on this port is forwarded to the TCP
79 //-- test application which will loop and echo it back to
80 //-- the sender in store-and-forward mode.
81 //-- --> 8803 : Traffic received on this port is forwarded to the TCP
82 //-- test application which will loop and echo it back to
83 //-- the sender in path-through mode.
84 //-------------------------------------------------------------------
85 #define RECV_MODE_LSN_PORT 8800 // 0x2260
86 #define XMIT_MODE_LSN_PORT 8801 // 0x2261
87 #define ECHO_MOD2_LSN_PORT 8802 // 0x2262
88 #define ECHO_MODE_LSN_PORT 8803 // 0x2263
89 #define IPERF_LSN_PORT 5001 // 0x1389
90 #define IPREF3_LSN_PORT 5201 // 0x1451
91 
92 #define FIXME_DEFAULT_HOST_IP4_ADDR 0x0A0CC832 // HOST's IP Address = 10.12.200.50
93 #define FIXME_DEFAULT_HOST_LSN_PORT 8803+0x8000 // HOST listens on port = 41571
94 
95 //-------------------------------------------------------------------
96 //-- DEFAULT XMIT STRING
97 //-- By default, the string 'Hi from FMKU60\n' is sent out as two
98 //-- alternating chunks during the transmission test, which turns
99 //-- into the two following chunks:
100 //-------------------------------------------------------------------
101 #define GEN_CHK0 0x48692066726f6d20 // 'Hi from '
102 #define GEN_CHK1 0x464d4b553630210a // 'FMKU60\n'
103 
104 enum DropCode {
105  NOP=0, // No Operation
106  GEN // Generate traffic towards producer
107 };
108 
109 //=========================================================
110 //== Forward Command
111 //== Indicates if a received stream must be forwarded or
112 //== dropped. If the action is 'CMD_DROP' the field
113 //== 'DropCOde' is meaningful, otherwise void.
114 //=========================================================
115 class ForwardCmd {
116  public:
122  ForwardCmd(SessionId _sessId, TcpDatLen _datLen, CmdBit _action, DropCode _dropCode) :
123  sessId(_sessId), datLen(_datLen), action(_action), dropCode(_dropCode) {}
124 };
125 
126 //=========================================================
127 //== Interrupt Table Entry
128 //== The interrupt table keeps track of the received
129 //== notifications. It maintains a counter of received
130 //== bytes per sessions as well as the TCP destination
131 //== port number.
132 //=========================================================
134  public:
138  InterruptEntry(TcpDatLen _byteCnt, TcpPort _dstPort) :
139  byteCnt(_byteCnt), dstPort(_dstPort) {}
140 };
141 
142 enum QueryCmd {
143  GET=0, // Retrieve a table entry
144  PUT, // Modify an entry of the table
145  POST, // Create a new entry in the table
146 };
147 
148 //=========================================================
149 //== Interrupt Table Query
150 //=========================================================
152  public:
157  InterruptQuery(SessionId _sessId, QueryCmd _action=GET) : // GET Query
158  sessId(_sessId), action(GET) {}
159  InterruptQuery(SessionId _sessId, TcpDatLen _byteCnt) : // PUT Query: 'byteCnt'
160  sessId(_sessId), entry(_byteCnt, 0), action(PUT) {}
161  InterruptQuery(SessionId _sessId, InterruptEntry _entry, QueryCmd _action=POST) : // POST Query
162  sessId(_sessId), entry(_entry), action(POST) {}
163 };
164 
165 
170 void tcp_shell_if(
171 
172  //------------------------------------------------------
173  //-- SHELL / Mmio Interface
174  //------------------------------------------------------
175  CmdBit *piSHL_Mmio_En,
176 
177  //------------------------------------------------------
178  //-- TAF / Rx Data Interface
179  //------------------------------------------------------
180  stream<TcpAppData> &siTAF_Data,
181  stream<TcpSessId> &siTAF_SessId,
182  stream<TcpDatLen> &siTAF_DatLen,
183 
184  //------------------------------------------------------
185  //-- TAF / Tx Data Interface
186  //------------------------------------------------------
187  stream<TcpAppData> &soTAF_Data,
188  stream<TcpSessId> &soTAF_SessId,
189  stream<TcpDatLen> &soTAF_DatLen,
190 
191  //------------------------------------------------------
192  //-- SHELL / Rx Data Interfaces
193  //------------------------------------------------------
194  stream<TcpAppNotif> &siSHL_Notif,
195  stream<TcpAppRdReq> &soSHL_DReq,
196  stream<TcpAppData> &siSHL_Data,
197  stream<TcpAppMeta> &siSHL_Meta,
198 
199  //------------------------------------------------------
200  //-- SHELL / Listen Interfaces
201  //------------------------------------------------------
202  stream<TcpAppLsnReq> &soSHL_LsnReq,
203  stream<TcpAppLsnRep> &siSHL_LsnRep,
204 
205  //------------------------------------------------------
206  //-- SHELL / Tx Data Interfaces
207  //------------------------------------------------------
208  stream<TcpAppData> &soSHL_Data,
209  stream<TcpAppSndReq> &soSHL_SndReq,
210  stream<TcpAppSndRep> &siSHL_SndRep,
211 
212  //------------------------------------------------------
213  //-- SHELL / Open Interfaces
214  //------------------------------------------------------
215  stream<TcpAppOpnReq> &soSHL_OpnReq,
216  stream<TcpAppOpnRep> &siSHL_OpnRep,
217 
218  //------------------------------------------------------
219  //-- SHELL / Close Interfaces
220  //------------------------------------------------------
221  stream<TcpAppClsReq> &soSHL_ClsReq,
222  //-- Not Used &siSHL_ClsSts,
223 
224  //------------------------------------------------------
225  //-- DEBUG Probes
226  //------------------------------------------------------
227  stream<ap_uint<32> > &soDBG_SinkCnt,
228  stream<ap_uint<16> > &soDBG_InpBufSpace
229 
230 );
231 
232 #endif
233 
SessionId sessId
DropCode dropCode
ForwardCmd(SessionId _sessId, TcpDatLen _datLen, CmdBit _action, DropCode _dropCode)
TcpDatLen datLen
TcpDatLen byteCnt
InterruptEntry(TcpDatLen _byteCnt, TcpPort _dstPort)
InterruptQuery(SessionId _sessId, QueryCmd _action=GET)
InterruptQuery(SessionId _sessId, TcpDatLen _byteCnt)
InterruptQuery(SessionId _sessId, InterruptEntry _entry, QueryCmd _action=POST)
InterruptEntry entry
SessionId sessId
ap_uint< 16 > SessionId
Definition: nts_types.hpp:136
#define ARW
Definition: AxisRaw.hpp:114
ap_uint< 16 > TcpPort
Definition: AxisTcp.hpp:105
ap_uint< 16 > TcpDatLen
Definition: AxisTcp.hpp:123
ap_uint< 1 > CmdBit
Definition: nts_types.hpp:108
const int cDepth_IRbToRDp_Meta
const int cDepth_COnToWRp_TxBytesReq
const int cDepth_RRhToRRm_DReq
const int cDepth_RDpToCOn_OpnSockReq
void tcp_shell_if(CmdBit *piSHL_Mmio_En, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, stream< TcpAppNotif > &siSHL_Notif, stream< TcpAppRdReq > &soSHL_DReq, stream< TcpAppData > &siSHL_Data, stream< TcpAppMeta > &siSHL_Meta, stream< TcpAppLsnReq > &soSHL_LsnReq, stream< TcpAppLsnRep > &siSHL_LsnRep, stream< TcpAppData > &soSHL_Data, stream< TcpAppSndReq > &soSHL_SndReq, stream< TcpAppSndRep > &siSHL_SndRep, stream< TcpAppOpnReq > &soSHL_OpnReq, stream< TcpAppOpnRep > &siSHL_OpnRep, stream< TcpAppClsReq > &soSHL_ClsReq, stream< ap_uint< 32 > > &soDBG_SinkCnt, stream< ap_uint< 16 > > &soDBG_InpBufSpace)
TCP Shell Interface (TSIF)
DropCode
const int cDepth_RNhToRRh_Notif
const int cMinDataReqLen
const int cDepth_COnToWRp_TxSessId
QueryCmd
const int cDepth_IRbToRDp_Data
const int cIBuffBytes
const int cDepth_RRhToRDp_FwdCmd
const int cDepth_RDpToRRh_Dequeue
const int cDepth_RDpToCOn_TxCountReq
const int cMaxSessions
@ GEN
@ NOP
@ GET
@ POST
@ PUT