aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests/common/chdr_resource/hardcoded_packets.py
blob: c79d6f9cb10a5ec53b65d0039f58d7abb94d0f0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#
# Copyright 2020 Ettus Research, a National Instruments Brand
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
from uhd import chdr
from chdr_resource import rfnoc_packets_data
from chdr_resource import rfnoc_packets_ctrl_mgmt

CHDR_W = chdr.ChdrWidth.W64

def make_control_packet0():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.CTRL
    header.length = 24
    header.dst_epid = 2
    payload = chdr.CtrlPayload()
    payload.src_epid = 1
    payload.set_data([0])
    payload.op_code = chdr.CtrlOpCode.READ
    return chdr.ChdrPacket(CHDR_W, header, payload)

def make_control_packet1():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.CTRL
    header.length = 24
    header.dst_epid = 1
    payload = chdr.CtrlPayload()
    payload.src_epid = 2
    payload.is_ack = True
    payload.set_data([0x12C60100])
    payload.op_code = chdr.CtrlOpCode.READ
    return chdr.ChdrPacket(CHDR_W, header, payload)

def make_mgmt_packet0():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.MGMT
    header.length = 48
    header.seq_num = 2
    payload = chdr.MgmtPayload()
    payload.set_header(1, (1 << 8) | (0 << 0), chdr.ChdrWidth.W64)
    hop1 = chdr.MgmtHop()
    hop1.add_op(chdr.MgmtOp(chdr.MgmtOpCode.NOP))
    payload.add_hop(hop1)
    hop2 = chdr.MgmtHop()
    hop2.add_op(chdr.MgmtOp(chdr.MgmtOpCode.INFO_REQ, chdr.MgmtOpNodeInfo(0, 0, 0, 0)))
    hop2.add_op(chdr.MgmtOp(chdr.MgmtOpCode.RETURN))
    payload.add_hop(hop2)
    hop3 = chdr.MgmtHop()
    hop3.add_op(chdr.MgmtOp(chdr.MgmtOpCode.NOP))
    payload.add_hop(hop3)
    return chdr.ChdrPacket(CHDR_W, header, payload)

def make_mgmt_packet1():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.MGMT
    header.length = 48
    header.seq_num = 3
    payload = chdr.MgmtPayload()
    payload.set_header(1, (1 << 8) | (0 << 0), chdr.ChdrWidth.W64)
    hop1 = chdr.MgmtHop()
    hop1.add_op(chdr.MgmtOp(chdr.MgmtOpCode.NOP))
    payload.add_hop(hop1)
    hop2 = chdr.MgmtHop()
    hop2.add_op(chdr.MgmtOp(chdr.MgmtOpCode.CFG_WR_REQ, chdr.MgmtOpCfg(0x1, 0x2)))
    hop2.add_op(chdr.MgmtOp(chdr.MgmtOpCode.RETURN))
    payload.add_hop(hop2)
    hop3 = chdr.MgmtHop()
    hop3.add_op(chdr.MgmtOp(chdr.MgmtOpCode.NOP))
    payload.add_hop(hop3)
    return chdr.ChdrPacket(CHDR_W, header, payload)

def make_mgmt_packet2():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.MGMT
    header.length = 56
    header.seq_num = 6
    payload = chdr.MgmtPayload()
    payload.set_header(1, (1 << 8) | (0 << 0), chdr.ChdrWidth.W64)
    hop1 = chdr.MgmtHop()
    hop1.add_op(chdr.MgmtOp(chdr.MgmtOpCode.NOP))
    payload.add_hop(hop1)
    hop2 = chdr.MgmtHop()
    hop2.add_op(chdr.MgmtOp(chdr.MgmtOpCode.SEL_DEST, chdr.MgmtOpSelDest(3)))
    payload.add_hop(hop2)
    hop3 = chdr.MgmtHop()
    hop3.add_op(chdr.MgmtOp(chdr.MgmtOpCode.INFO_REQ, 0))
    hop3.add_op(chdr.MgmtOp(chdr.MgmtOpCode.RETURN, 0))
    payload.add_hop(hop3)
    hop4 = chdr.MgmtHop()
    hop4.add_op(chdr.MgmtOp(chdr.MgmtOpCode.NOP, 0))
    payload.add_hop(hop4)
    return chdr.ChdrPacket(CHDR_W, header, payload)

def make_strs_packet0():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.STRS
    header.length = 40
    header.dst_epid = 2
    payload = chdr.StrsPayload()
    payload.capacity_bytes = 163840
    payload.src_epid = 3
    payload.capacity_pkts = 16777215
    return chdr.ChdrPacket(CHDR_W, header, payload)

def make_strs_packet1():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.STRS
    header.length = 40
    header.dst_epid = 2
    payload = chdr.StrsPayload()
    payload.capacity_bytes = 163840
    payload.src_epid = 3
    payload.xfer_count_pkts = 1
    payload.capacity_pkts = 16777215
    payload.xfer_count_bytes = 8000
    return chdr.ChdrPacket(CHDR_W, header, payload)

def make_strc_packet0():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.STRC
    header.length = 24
    header.dst_epid = 3
    payload = chdr.StrcPayload()
    payload.num_pkts = 16777215
    payload.op_code = chdr.StrcOpCode.INIT
    payload.src_epid = 2
    payload.num_bytes = 5120
    return chdr.ChdrPacket(CHDR_W, header, payload)

def make_strc_packet1():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.STRC
    header.length = 24
    header.dst_epid = 3
    payload = chdr.StrcPayload()
    payload.num_pkts = 21
    payload.op_code = chdr.StrcOpCode.RESYNC
    payload.src_epid = 2
    payload.num_bytes = 168000
    return chdr.ChdrPacket(CHDR_W, header, payload)

def make_data_packet0():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.DATA_WITH_TS
    header.length = 8000
    header.dst_epid = 3
    header.seq_num = 1
    timestamp = 0x7C40C83
    data_src = rfnoc_packets_data.peer1_9
    data = bytes(data_src[(2 * 8):])
    return chdr.ChdrPacket(CHDR_W, header, data, timestamp)

def make_data_packet1():
    header = chdr.ChdrHeader()
    header.pkt_type = chdr.PacketType.DATA_WITH_TS
    header.length = 4252
    header.dst_epid = 3
    header.eob = True
    header.seq_num = 1716
    timestamp = 0x21452B97
    data_src = rfnoc_packets_data.eob_packet
    data = bytes(data_src[(2 * 8):])
    return chdr.ChdrPacket(CHDR_W, header, data, timestamp)

packets = [
    (make_control_packet0(), rfnoc_packets_ctrl_mgmt.peer0_19),
    (make_control_packet1(), rfnoc_packets_ctrl_mgmt.peer1_17),
    (make_mgmt_packet0(), rfnoc_packets_ctrl_mgmt.peer0_2),
    (make_mgmt_packet1(), rfnoc_packets_ctrl_mgmt.peer0_3),
    (make_mgmt_packet2(), rfnoc_packets_ctrl_mgmt.peer0_6),
    (make_strs_packet0(), rfnoc_packets_data.peer0_5),
    (make_strs_packet1(), rfnoc_packets_data.peer0_8),
    (make_strc_packet0(), rfnoc_packets_data.peer1_5),
    (make_strc_packet1(), rfnoc_packets_data.peer1_29),
    (make_data_packet0(), rfnoc_packets_data.peer1_9),
    (make_data_packet1(), rfnoc_packets_data.eob_packet)
]

names = [
    "Control_Packet_0",
    "Control_Packet_1",
    "Management_Packet_0",
    "Management_Packet_1",
    "Management_Packet_2",
    "Stream_Status_Packet_0",
    "Stream_Status_Packet_1",
    "Stream_Command_Packet_0",
    "Stream_Command_Packet_1",
    "Data_Packet_0",
    "Data_Packet_1"
]