cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
nts.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 
41 #ifndef _NTS_H_
42 #define _NTS_H_
43 
44 #include "nts_types.hpp"
45 #include "nts_config.hpp"
46 
47 
50 typedef AxisRaw AppData;
51 typedef AxisRaw AxisApp;
52 
53 
60 //=========================================================
61 //== TAIF / RECEIVED & TRANSMITTED SEGMENT INTERFACES
62 //=========================================================
63 
64 //---------------------------------------------------------
65 //-- TCP APP - DATA
66 //-- The data section of a TCP segment over an AXI4S I/F.
67 //---------------------------------------------------------
69 
70 //---------------------------------------------------------
71 //-- TCP APP - METADATA
72 //-- The session identifier to send.
73 //---------------------------------------------------------
75 
76 //---------------------------------------------------------
77 //-- TCP APP - DATA LENGTH
78 //-- The length of the data to send.
79 //---------------------------------------------------------
81 
82 //---------------------------------------------------------
83 //-- TCP APP - NOTIFICATION
84 //-- Notifies the availability of data for the application
85 //-- in the TCP Rx buffer.
86 //---------------------------------------------------------
87 class TcpAppNotif {
88  public:
97  sessionID( sessId), tcpDatLen( 0), ip4SrcAddr(0),
99  TcpAppNotif(SessionId sessId, TcpDatLen dataLen, Ip4Addr sa,
100  TcpPort sp, TcpPort dp) :
101  sessionID( sessId), tcpDatLen(dataLen), ip4SrcAddr(sa),
102  tcpSrcPort(sp), tcpDstPort(dp), tcpState(CLOSED) {}
103  TcpAppNotif(SessionId sessId, TcpDatLen dataLen, Ip4Addr sa,
104  TcpPort sp, TcpPort dp, TcpState tcpState) :
105  sessionID( sessId), tcpDatLen(dataLen), ip4SrcAddr(sa),
106  tcpSrcPort(sp), tcpDstPort(dp), tcpState(tcpState) {}
107 };
108 
109 //---------------------------------------------------------
110 //-- TCP APP - DATA READ REQUEST
111 //-- Used by the application to request data from the
112 //-- TCP Rx buffer.
113 //---------------------------------------------------------
114 class TcpAppRdReq {
115  public:
120  sessionID(id), length(len) {}
121 };
122 
123 //---------------------------------------------------------
124 //-- TCP APP - DATA SEND REQUEST
125 //-- Used by the application to request data transmission.
126 //---------------------------------------------------------
128  public:
133  sessId(id), length(len) {}
134 };
135 
136 //---------------------------------------------------------
137 //-- TCP APP - DATA SEND REPLY
138 //-- Status returned by NTS to APP after request to send.
139 //---------------------------------------------------------
141 public:
142  SessionId sessId; // The session ID
143  TcpDatLen length; // The #bytes that were requested to be written
144  TcpDatLen spaceLeft; // The remaining space in the TCP buffer
145  TcpAppSndErr error; // The error code (OK=0)
148  sessId(sessId), length(datLen), spaceLeft(space), error(rc) {}
149 };
150 
151 //=========================================================
152 //== TAIF / OPEN & CLOSE CONNECTION INTERFACES
153 //=========================================================
154 
155 //--------------------------------------------------------
156 //-- TCP APP - OPEN CONNECTION REQUEST
157 //-- The socket address to be opened.
158 //--------------------------------------------------------
160 
161 //--------------------------------------------------------
162 //-- TCP APP - OPEN CONNECTION REPLY
163 //-- Reports the state of a TCP connection according to RFC-793.
164 //--------------------------------------------------------
166  public:
172 };
173 
174 //--------------------------------------------------------
175 //-- TCP APP - CLOSE CONNECTION REQUEST
176 //-- The socket address to be closed.
177 //-- [FIXME-What about creating a class 'AppConReq' with a member 'opn/cls']
178 //--------------------------------------------------------
180 
181 //=========================================================
182 //== TAIF / LISTEN PORT INTERFACES
183 //=========================================================
184 
185 //---------------------------------------------------------
186 //-- TCP APP - LISTEN REQUEST
187 //-- The TCP port to open for listening.
188 //-- [FIXME-What about creating a class 'AppLsnReq' with a member 'start/stop']
189 //---------------------------------------------------------
191 
192 //---------------------------------------------------------
193 //-- TCP APP - LISTEN REPLY
194 //-- The port status returned by NTS upon listen request.
195 //---------------------------------------------------------
197 
198 
199 
206 //=========================================================
207 //== UAIF / RECEIVED & TRANSMITTED DATAGRAM INTERFACES
208 //=========================================================
209 
210 //---------------------------------------------------------
211 //-- UDP APP - DATA
212 //-- The data section of an UDP datagram over an AXI4S I/F.
213 //---------------------------------------------------------
215 
216 //---------------------------------------------------------
217 //-- UDP APP - METADATA
218 //-- The meta-data of a UDP connection.
219 //--
220 //-- [INFO] Do not use struct 'SocketPair' here because
221 //-- 'DATA_PACK' optimization does not support packing
222 //-- structs which contain other structs.
223 //---------------------------------------------------------
224 class UdpAppMeta {
225  public:
226  Ip4Addr ip4SrcAddr; // IPv4 source address in NETWORK BYTE ORDER
227  Ly4Port udpSrcPort; // UDP source port in NETWORK BYTE ORDER
228  Ip4Addr ip4DstAddr; // IPv4 destination address in NETWORK BYTE ORDER
229  Ly4Port udpDstPort; // UDP destination port in NETWORK BYTE ORDER
231  UdpAppMeta(Ip4Addr srcAddr, Ly4Port srcPort, Ip4Addr dstAddr, Ly4Port dstPort) :
232  ip4SrcAddr(srcAddr), udpSrcPort(srcPort), ip4DstAddr(dstAddr), udpDstPort(dstPort) {}
233  UdpAppMeta(SockAddr srcSock, SockAddr dstSock) :
234  ip4SrcAddr(srcSock.addr), udpSrcPort(srcSock.port), ip4DstAddr(dstSock.addr), udpDstPort(dstSock.port) {}
235  UdpAppMeta(SocketPair sockPair) :
236  ip4SrcAddr(sockPair.src.addr), udpSrcPort(sockPair.src.port), ip4DstAddr(sockPair.dst.addr), udpDstPort(sockPair.dst.port) {}
237 };
238 
239 //---------------------------------------------------------
240 //-- UDP APP - DATA LENGTH
241 //-- The length of the datagram.
242 //---------------------------------------------------------
244 
245 //=========================================================
246 //== UAIF / OPEN & CLOSE PORT INTERFACES
247 //=========================================================
248 
249 //---------------------------------------------------------
250 //-- UDP APP - LISTEN REQUEST
251 //-- The UDP port to open for listening.
252 //---------------------------------------------------------
254 
255 //---------------------------------------------------------
256 //-- UDP APP - LISTEN REPLY
257 //-- The port status returned by NTS upon listen request.
258 //---------------------------------------------------------
260 
261 //--------------------------------------------------------
262 //-- UDP APP - CLOSE PORT REQUEST
263 //-- The listen port to close.
264 //--------------------------------------------------------
265 typedef Ly4Port UdpAppClsReq; // [FIXME-What about creating a class 'AppLsnReq' with a member 'start/stop']
266 
267 //--------------------------------------------------------
268 //-- UDP APP - CLOSE PORT REPLY
269 //-- Reports the status of the port closing.
270 //--------------------------------------------------------
272 
273 
274 
279 void nts(
280 
281  //------------------------------------------------------
282  //-- TAIF / Received Segment Interfaces
283  //------------------------------------------------------
284  stream<TcpAppNotif> &soTAIF_Notif,
285  stream<TcpAppRdReq> &siTAIF_DReq,
286  stream<TcpAppData> &soTAIF_Data,
287  stream<TcpAppMeta> &soTAIF_Meta,
288 
289  //------------------------------------------------------
290  //-- TAIF / Listen Port Interfaces
291  //------------------------------------------------------
292  stream<TcpAppLsnReq> &siTAIF_LsnReq,
293  stream<TcpAppLsnRep> &soTAIF_LsnRep,
294 
295  //------------------------------------------------------
296  //-- TAIF / Transmit Segment Interfaces
297  //------------------------------------------------------
298  stream<TcpAppData> &siTAIF_Data,
299  stream<TcpAppSndReq> &siTAIF_SndReq,
300  stream<TcpAppSndRep> &soTAIF_SndRep,
301 
302  //------------------------------------------------------
303  //-- TAIF / Open Connection Interfaces
304  //------------------------------------------------------
305  stream<TcpAppOpnReq> &siTAIF_OpnReq,
306  stream<TcpAppOpnRep> &soTAIF_OpnRep,
307 
308  //------------------------------------------------------
309  //-- TAIF / Close Connection Interfaces
310  //------------------------------------------------------
311  stream<TcpAppClsReq> &siTAIF_ClsReq,
312  //-- Not USed &soTAIF_ClsSts,
313 
314  //------------------------------------------------------
315  //-- UAIF / Control Port Interfaces
316  //------------------------------------------------------
317  stream<UdpAppLsnReq> &siUAIF_LsnReq,
318  stream<UdpAppLsnRep> &soUAIF_LsnRep,
319  stream<UdpAppClsReq> &siUAIF_ClsReq,
320  stream<UdpAppClsRep> &soUAIF_ClsRep,
321 
322  //------------------------------------------------------
323  //-- UAIF / Received Datagram Interfaces
324  //------------------------------------------------------
325  stream<UdpAppData> &soUAIF_Data,
326  stream<UdpAppMeta> &soUAIF_Meta,
327  stream<UdpAppDLen> &soUAIF_DLen,
328 
329  //------------------------------------------------------
330  //-- UAIF / Transmit Datatagram Interfaces
331  //------------------------------------------------------
332  stream<UdpAppData> &siUAIF_Data,
333  stream<UdpAppMeta> &siUAIF_Meta,
334  stream<UdpAppDLen> &siUAIF_DLen
335 
336 );
337 
338 #endif
339 
SessionId sessionID
Definition: nts.hpp:89
TcpAppNotif(SessionId sessId, TcpDatLen dataLen, Ip4Addr sa, TcpPort sp, TcpPort dp)
Definition: nts.hpp:99
Ip4Addr ip4SrcAddr
Definition: nts.hpp:91
TcpPort tcpDstPort
Definition: nts.hpp:93
TcpAppNotif()
Definition: nts.hpp:95
TcpAppNotif(SessionId sessId, TcpState tcpState)
Definition: nts.hpp:96
TcpDatLen tcpDatLen
Definition: nts.hpp:90
TcpPort tcpSrcPort
Definition: nts.hpp:92
TcpState tcpState
Definition: nts.hpp:94
TcpAppNotif(SessionId sessId, TcpDatLen dataLen, Ip4Addr sa, TcpPort sp, TcpPort dp, TcpState tcpState)
Definition: nts.hpp:103
TcpAppOpnRep(SessionId sessId, TcpState tcpState)
Definition: nts.hpp:170
TcpAppOpnRep()
Definition: nts.hpp:169
SessionId sessId
Definition: nts.hpp:167
TcpState tcpState
Definition: nts.hpp:168
TcpAppRdReq()
Definition: nts.hpp:118
TcpDatLen length
Definition: nts.hpp:117
SessionId sessionID
Definition: nts.hpp:116
TcpAppRdReq(SessionId id, TcpDatLen len)
Definition: nts.hpp:119
TcpAppSndRep()
Definition: nts.hpp:146
TcpDatLen spaceLeft
Definition: nts.hpp:144
TcpAppSndRep(SessionId sessId, TcpDatLen datLen, TcpDatLen space, TcpAppSndErr rc)
Definition: nts.hpp:147
SessionId sessId
Definition: nts.hpp:142
TcpAppSndErr error
Definition: nts.hpp:145
TcpDatLen length
Definition: nts.hpp:143
TcpDatLen length
Definition: nts.hpp:130
SessionId sessId
Definition: nts.hpp:129
TcpAppSndReq(SessionId id, TcpDatLen len)
Definition: nts.hpp:132
TcpAppSndReq()
Definition: nts.hpp:131
UdpAppMeta(Ip4Addr srcAddr, Ly4Port srcPort, Ip4Addr dstAddr, Ly4Port dstPort)
Definition: nts.hpp:231
Ly4Port udpDstPort
Definition: nts.hpp:229
Ly4Port udpSrcPort
Definition: nts.hpp:227
Ip4Addr ip4SrcAddr
Definition: nts.hpp:226
UdpAppMeta(SockAddr srcSock, SockAddr dstSock)
Definition: nts.hpp:233
UdpAppMeta(SocketPair sockPair)
Definition: nts.hpp:235
Ip4Addr ip4DstAddr
Definition: nts.hpp:228
UdpAppMeta()
Definition: nts.hpp:230
bool StsBool
Definition: nal.hpp:246
StsBool UdpAppClsRep
Definition: nts.hpp:271
Ly4Port UdpAppLsnReq
Definition: nts.hpp:253
TcpDatLen TcpAppDLen
Definition: nts.hpp:80
ap_uint< 16 > SessionId
Definition: nts_types.hpp:136
ap_uint< 16 > UdpDatLen
Definition: AxisUdp.hpp:107
AxisRaw AppData
Definition: nts.hpp:50
AxisRaw TcpAppData
Definition: nts.hpp:68
UdpDatLen UdpAppDLen
Definition: nts.hpp:243
TcpState
Definition: nts_types.hpp:296
SockAddr TcpAppOpnReq
Definition: nts.hpp:159
ap_uint< 16 > Ly4Port
Definition: nts_types.hpp:201
Ly4Port UdpAppClsReq
Definition: nts.hpp:265
ap_uint< 32 > Ip4Addr
Definition: AxisIp4.hpp:169
void nts(stream< TcpAppNotif > &soTAIF_Notif, stream< TcpAppRdReq > &siTAIF_DReq, stream< TcpAppData > &soTAIF_Data, stream< TcpAppMeta > &soTAIF_Meta, stream< TcpAppLsnReq > &siTAIF_LsnReq, stream< TcpAppLsnRep > &soTAIF_LsnRep, stream< TcpAppData > &siTAIF_Data, stream< TcpAppSndReq > &siTAIF_SndReq, stream< TcpAppSndRep > &soTAIF_SndRep, stream< TcpAppOpnReq > &siTAIF_OpnReq, stream< TcpAppOpnRep > &soTAIF_OpnRep, stream< TcpAppClsReq > &siTAIF_ClsReq, stream< UdpAppLsnReq > &siUAIF_LsnReq, stream< UdpAppLsnRep > &soUAIF_LsnRep, stream< UdpAppClsReq > &siUAIF_ClsReq, stream< UdpAppClsRep > &soUAIF_ClsRep, stream< UdpAppData > &soUAIF_Data, stream< UdpAppMeta > &soUAIF_Meta, stream< UdpAppDLen > &soUAIF_DLen, stream< UdpAppData > &siUAIF_Data, stream< UdpAppMeta > &siUAIF_Meta, stream< UdpAppDLen > &siUAIF_DLen)
RepBool TcpAppLsnRep
Definition: nts.hpp:196
TcpPort TcpAppLsnReq
Definition: nts.hpp:190
ap_uint< 16 > TcpPort
Definition: AxisTcp.hpp:105
ap_uint< 16 > TcpDatLen
Definition: AxisTcp.hpp:123
TcpAppSndErr
Definition: nts_types.hpp:304
AxisRaw AxisApp
Definition: nts.hpp:51
SessionId TcpAppClsReq
Definition: nts.hpp:179
bool RepBool
Definition: nts_types.hpp:127
AxisRaw UdpAppData
Definition: nts.hpp:214
StsBool UdpAppLsnRep
Definition: nts.hpp:259
TcpSessId TcpAppMeta
Definition: nts.hpp:74
ap_uint< 16 > TcpSessId
Definition: nts_types.hpp:137
@ CLOSED
Definition: nts_types.hpp:296
: Configuration parameters for the Network Transport Stack (NTS) component and sub-components.
: Definition of the types used by the Network Transport Stack (NTS) component of the cloudFPGA shell.