Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fpga-network-stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
paulrr2
fpga-network-stack
Commits
0c774c1a
Commit
0c774c1a
authored
5 years ago
by
David Sidler
Browse files
Options
Downloads
Patches
Plain Diff
deduplicate ip optinal header drop
parent
775a1811
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hls/ipv4/ipv4.cpp
+2
-141
2 additions, 141 deletions
hls/ipv4/ipv4.cpp
hls/ipv4/ipv4.hpp
+139
-0
139 additions, 0 deletions
hls/ipv4/ipv4.hpp
hls/toe/rx_engine/rx_engine.cpp
+1
-143
1 addition, 143 deletions
hls/toe/rx_engine/rx_engine.cpp
with
142 additions
and
284 deletions
hls/ipv4/ipv4.cpp
+
2
−
141
View file @
0c774c1a
...
...
@@ -69,145 +69,6 @@ void process_ipv4( stream<net_axis<WIDTH> >& dataIn,
}
}
template
<
int
WIDTH
>
void
drop_optional_header
(
stream
<
ap_uint
<
4
>
>&
process2dropLengthFifo
,
stream
<
net_axis
<
WIDTH
>
>&
process2dropFifo
,
stream
<
net_axis
<
WIDTH
>
>&
dataOut
)
{
#pragma HLS INLINE off
#pragma HLS pipeline II=1
enum
fsmStateType
{
META
,
DROP
,
BODY
,
SHIFT
,
LAST
,
SHIFT_FIVE
,
LAST_FIVE
};
static
fsmStateType
doh_state
=
META
;
static
ap_uint
<
4
>
length
;
static
net_axis
<
WIDTH
>
prevWord
;
net_axis
<
WIDTH
>
currWord
;
net_axis
<
WIDTH
>
sendWord
;
//TODO length deduction depends on WIDTH
switch
(
doh_state
)
{
case
META
:
if
(
!
process2dropLengthFifo
.
empty
()
&&
!
process2dropFifo
.
empty
())
{
process2dropLengthFifo
.
read
(
length
);
//Handle differently depending on AXI bus width. TODO 128, 256
if
(
WIDTH
==
64
)
{
if
(
length
>
1
)
{
doh_state
=
DROP
;
}
else
{
process2dropFifo
.
read
(
prevWord
);
doh_state
=
SHIFT
;
}
}
if
(
WIDTH
==
512
)
{
if
(
length
==
5
)
{
process2dropFifo
.
read
(
prevWord
);
doh_state
=
SHIFT_FIVE
;
if
(
prevWord
.
last
)
{
doh_state
=
LAST_FIVE
;
}
}
}
}
break
;
case
DROP
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
prevWord
);
length
-=
2
;
if
(
length
==
1
)
{
doh_state
=
SHIFT
;
}
else
if
(
length
==
0
)
{
doh_state
=
BODY
;
}
}
break
;
case
BODY
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
currWord
);
dataOut
.
write
(
currWord
);
if
(
currWord
.
last
)
{
doh_state
=
META
;
}
}
break
;
case
SHIFT
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
currWord
);
sendWord
.
data
(
WIDTH
-
32
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
32
);
sendWord
.
keep
((
WIDTH
/
8
)
-
4
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
4
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
32
)
=
currWord
.
data
(
31
,
0
);
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
4
)
=
currWord
.
keep
(
3
,
0
);
sendWord
.
last
=
(
currWord
.
keep
[
4
]
==
0
);
dataOut
.
write
(
sendWord
);
prevWord
=
currWord
;
if
(
sendWord
.
last
)
{
doh_state
=
META
;
}
else
if
(
currWord
.
last
)
{
doh_state
=
LAST
;
}
}
break
;
case
SHIFT_FIVE
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
currWord
);
sendWord
.
data
(
WIDTH
-
160
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
160
);
sendWord
.
keep
((
WIDTH
/
8
)
-
20
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
20
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
160
)
=
currWord
.
data
(
160
-
1
,
0
);
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
20
)
=
currWord
.
keep
(
20
-
1
,
0
);
sendWord
.
last
=
(
currWord
.
keep
[
20
]
==
0
);
dataOut
.
write
(
sendWord
);
prevWord
=
currWord
;
if
(
sendWord
.
last
)
{
doh_state
=
META
;
}
else
if
(
currWord
.
last
)
{
doh_state
=
LAST_FIVE
;
}
}
break
;
case
LAST
:
sendWord
.
data
(
WIDTH
-
32
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
32
);
sendWord
.
keep
((
WIDTH
/
8
)
-
4
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
4
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
32
)
=
0
;
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
4
)
=
0x0
;
sendWord
.
last
=
0x1
;
dataOut
.
write
(
sendWord
);
doh_state
=
META
;
break
;
case
LAST_FIVE
:
sendWord
.
data
(
WIDTH
-
160
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
160
);
sendWord
.
keep
((
WIDTH
/
8
)
-
20
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
20
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
160
)
=
0
;
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
20
)
=
0x0
;
sendWord
.
last
=
0x1
;
dataOut
.
write
(
sendWord
);
doh_state
=
META
;
break
;
}
//switch
}
template
<
int
WIDTH
>
void
generate_ipv4
(
stream
<
ipv4Meta
>&
txEng_ipMetaDataFifoIn
,
stream
<
net_axis
<
WIDTH
>
>&
tx_shift2ipv4Fifo
,
...
...
@@ -321,8 +182,8 @@ void ipv4( hls::stream<net_axis<WIDTH> >& s_axis_rx_data,
* RX PATH
*/
process_ipv4
(
s_axis_rx_data
,
rx_process2dropLengthFifo
,
m_axis_rx_meta
,
rx_process2dropFifo
);
//
TODO maybe assume
no optional
header
fields
!
drop_optional_header
(
rx_process2dropLengthFifo
,
rx_process2dropFifo
,
m_axis_rx_data
);
//
Assumes for WIDTH > 64
no optional fields
drop_optional_
ip_
header
(
rx_process2dropLengthFifo
,
rx_process2dropFifo
,
m_axis_rx_data
);
/*
* TX PATH
...
...
This diff is collapsed.
Click to expand it.
hls/ipv4/ipv4.hpp
+
139
−
0
View file @
0c774c1a
...
...
@@ -50,6 +50,145 @@ struct subSums
ap_uint
<
17
>
sum
[
N
];
};
template
<
int
WIDTH
>
void
drop_optional_ip_header
(
stream
<
ap_uint
<
4
>
>&
process2dropLengthFifo
,
stream
<
net_axis
<
WIDTH
>
>&
process2dropFifo
,
stream
<
net_axis
<
WIDTH
>
>&
dataOut
)
{
#pragma HLS INLINE off
#pragma HLS pipeline II=1
enum
fsmStateType
{
META
,
DROP
,
BODY
,
SHIFT
,
LAST
,
SHIFT_FIVE
,
LAST_FIVE
};
static
fsmStateType
doh_state
=
META
;
static
ap_uint
<
4
>
length
;
static
net_axis
<
WIDTH
>
prevWord
;
net_axis
<
WIDTH
>
currWord
;
net_axis
<
WIDTH
>
sendWord
;
switch
(
doh_state
)
{
case
META
:
if
(
!
process2dropLengthFifo
.
empty
()
&&
!
process2dropFifo
.
empty
())
{
process2dropLengthFifo
.
read
(
length
);
std
::
cout
<<
"(Optional) Header length: "
<<
length
<<
std
::
endl
;
//TODO for WIDTH == 128 this only works if no IP options
if
(
WIDTH
==
64
||
WIDTH
==
128
)
{
if
(
length
>
1
)
{
doh_state
=
DROP
;
}
else
{
process2dropFifo
.
read
(
prevWord
);
doh_state
=
SHIFT
;
}
}
if
(
WIDTH
==
256
||
WIDTH
==
512
)
{
//TODO this is a hack and only works if there are no IP options
if
(
length
==
5
)
{
process2dropFifo
.
read
(
prevWord
);
doh_state
=
SHIFT_FIVE
;
if
(
prevWord
.
last
)
{
doh_state
=
LAST_FIVE
;
}
}
}
}
break
;
case
DROP
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
prevWord
);
length
-=
2
;
if
(
length
==
1
)
{
doh_state
=
SHIFT
;
}
else
if
(
length
==
0
)
{
doh_state
=
BODY
;
}
}
break
;
case
BODY
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
currWord
);
dataOut
.
write
(
currWord
);
if
(
currWord
.
last
)
{
doh_state
=
META
;
}
}
break
;
case
SHIFT
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
currWord
);
sendWord
.
data
(
WIDTH
-
32
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
32
);
sendWord
.
keep
((
WIDTH
/
8
)
-
4
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
4
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
32
)
=
currWord
.
data
(
31
,
0
);
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
4
)
=
currWord
.
keep
(
3
,
0
);
sendWord
.
last
=
(
currWord
.
keep
[
4
]
==
0
);
dataOut
.
write
(
sendWord
);
prevWord
=
currWord
;
if
(
sendWord
.
last
)
{
doh_state
=
META
;
}
else
if
(
currWord
.
last
)
{
doh_state
=
LAST
;
}
}
break
;
case
SHIFT_FIVE
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
currWord
);
sendWord
.
data
(
WIDTH
-
160
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
160
);
sendWord
.
keep
((
WIDTH
/
8
)
-
20
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
20
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
160
)
=
currWord
.
data
(
160
-
1
,
0
);
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
20
)
=
currWord
.
keep
(
20
-
1
,
0
);
sendWord
.
last
=
(
currWord
.
keep
[
20
]
==
0
);
dataOut
.
write
(
sendWord
);
prevWord
=
currWord
;
if
(
sendWord
.
last
)
{
doh_state
=
META
;
}
else
if
(
currWord
.
last
)
{
doh_state
=
LAST_FIVE
;
}
}
break
;
case
LAST
:
sendWord
.
data
(
WIDTH
-
32
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
32
);
sendWord
.
keep
((
WIDTH
/
8
)
-
4
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
4
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
32
)
=
0
;
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
4
)
=
0x0
;
sendWord
.
last
=
0x1
;
dataOut
.
write
(
sendWord
);
doh_state
=
META
;
break
;
case
LAST_FIVE
:
sendWord
.
data
(
WIDTH
-
160
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
160
);
sendWord
.
keep
((
WIDTH
/
8
)
-
20
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
20
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
160
)
=
0
;
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
20
)
=
0
;
sendWord
.
last
=
0x1
;
dataOut
.
write
(
sendWord
);
doh_state
=
META
;
break
;
}
//switch
}
void
compute_ipv4_checksum
(
hls
::
stream
<
net_axis
<
64
>
>&
dataIn
,
hls
::
stream
<
net_axis
<
64
>
>&
dataOut
,
...
...
This diff is collapsed.
Click to expand it.
hls/toe/rx_engine/rx_engine.cpp
+
1
−
143
View file @
0c774c1a
...
...
@@ -75,149 +75,6 @@ void process_ipv4( stream<net_axis<WIDTH> >& dataIn,
}
}
//align remove options??
//USE code from ipv4.hpp
template
<
int
WIDTH
>
void
drop_optional_ip_header
(
stream
<
ap_uint
<
4
>
>&
process2dropLengthFifo
,
stream
<
net_axis
<
WIDTH
>
>&
process2dropFifo
,
stream
<
net_axis
<
WIDTH
>
>&
dataOut
)
{
#pragma HLS INLINE off
#pragma HLS pipeline II=1
enum
fsmStateType
{
META
,
DROP
,
BODY
,
SHIFT
,
LAST
,
SHIFT_FIVE
,
LAST_FIVE
};
static
fsmStateType
doh_state
=
META
;
static
ap_uint
<
4
>
length
;
static
net_axis
<
WIDTH
>
prevWord
;
net_axis
<
WIDTH
>
currWord
;
net_axis
<
WIDTH
>
sendWord
;
//TODO length deduction depends on AXI_WIDTH
switch
(
doh_state
)
{
case
META
:
if
(
!
process2dropLengthFifo
.
empty
()
&&
!
process2dropFifo
.
empty
())
{
process2dropLengthFifo
.
read
(
length
);
std
::
cout
<<
"(Optional) Header length: "
<<
length
<<
std
::
endl
;
//TODO for WIDTH == 128 this only works if no IP options
if
(
WIDTH
==
64
||
WIDTH
==
128
)
{
if
(
length
>
1
)
{
doh_state
=
DROP
;
}
else
{
process2dropFifo
.
read
(
prevWord
);
doh_state
=
SHIFT
;
}
}
if
(
WIDTH
==
256
||
WIDTH
==
512
)
{
//TODO this is a hack and only works if there are no IP options
if
(
length
==
5
)
{
process2dropFifo
.
read
(
prevWord
);
doh_state
=
SHIFT_FIVE
;
if
(
prevWord
.
last
)
{
doh_state
=
LAST_FIVE
;
}
}
}
}
break
;
case
DROP
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
prevWord
);
length
-=
2
;
if
(
length
==
1
)
{
doh_state
=
SHIFT
;
}
else
if
(
length
==
0
)
{
doh_state
=
BODY
;
}
}
break
;
case
BODY
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
currWord
);
dataOut
.
write
(
currWord
);
if
(
currWord
.
last
)
{
doh_state
=
META
;
}
}
break
;
case
SHIFT
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
currWord
);
sendWord
.
data
(
WIDTH
-
32
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
32
);
sendWord
.
keep
((
WIDTH
/
8
)
-
4
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
4
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
32
)
=
currWord
.
data
(
31
,
0
);
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
4
)
=
currWord
.
keep
(
3
,
0
);
sendWord
.
last
=
(
currWord
.
keep
[
4
]
==
0
);
dataOut
.
write
(
sendWord
);
prevWord
=
currWord
;
if
(
sendWord
.
last
)
{
doh_state
=
META
;
}
else
if
(
currWord
.
last
)
{
doh_state
=
LAST
;
}
}
break
;
case
SHIFT_FIVE
:
if
(
!
process2dropFifo
.
empty
())
{
process2dropFifo
.
read
(
currWord
);
sendWord
.
data
(
WIDTH
-
160
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
160
);
sendWord
.
keep
((
WIDTH
/
8
)
-
20
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
20
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
160
)
=
currWord
.
data
(
160
-
1
,
0
);
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
20
)
=
currWord
.
keep
(
20
-
1
,
0
);
sendWord
.
last
=
(
currWord
.
keep
[
20
]
==
0
);
dataOut
.
write
(
sendWord
);
prevWord
=
currWord
;
if
(
sendWord
.
last
)
{
doh_state
=
META
;
}
else
if
(
currWord
.
last
)
{
doh_state
=
LAST_FIVE
;
}
}
break
;
case
LAST
:
sendWord
.
data
(
WIDTH
-
32
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
32
);
sendWord
.
keep
((
WIDTH
/
8
)
-
4
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
4
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
32
)
=
0
;
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
4
)
=
0x0
;
sendWord
.
last
=
0x1
;
dataOut
.
write
(
sendWord
);
doh_state
=
META
;
break
;
case
LAST_FIVE
:
sendWord
.
data
(
WIDTH
-
160
-
1
,
0
)
=
prevWord
.
data
(
WIDTH
-
1
,
160
);
sendWord
.
keep
((
WIDTH
/
8
)
-
20
-
1
,
0
)
=
prevWord
.
keep
((
WIDTH
/
8
)
-
1
,
20
);
sendWord
.
data
(
WIDTH
-
1
,
WIDTH
-
160
)
=
0
;
sendWord
.
keep
((
WIDTH
/
8
)
-
1
,
(
WIDTH
/
8
)
-
20
)
=
0
;
sendWord
.
last
=
0x1
;
dataOut
.
write
(
sendWord
);
doh_state
=
META
;
break
;
}
//switch
}
template
<
int
WIDTH
>
void
constructPseudoHeader
(
hls
::
stream
<
pseudoMeta
>&
ipMetaIn
,
hls
::
stream
<
net_axis
<
WIDTH
>
>&
headerOut
)
...
...
@@ -1942,6 +1799,7 @@ void rx_engine( stream<net_axis<WIDTH> >& ipRxData,
process_ipv4
<
WIDTH
>
(
ipRxData
,
rx_process2dropLengthFifo
,
rxEng_ipMetaFifo
,
rxEng_dataBuffer0
);
//Assumes for WIDTH > 64 no optional fields
drop_optional_ip_header
<
WIDTH
>
(
rx_process2dropLengthFifo
,
rxEng_dataBuffer0
,
rxEng_dataBuffer4
);
//align
lshiftWordByOctet
<
WIDTH
,
2
>
(((
TCP_PSEUDO_HEADER_SIZE
%
WIDTH
)
/
8
),
rxEng_dataBuffer4
,
rxEng_dataBuffer5
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment