Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: htp_db.vr | |
4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | // | |
7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | // | |
9 | // This program is free software; you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation; version 2 of the License. | |
12 | // | |
13 | // This program is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License | |
19 | // along with this program; if not, write to the Free Software | |
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | // | |
22 | // For the avoidance of doubt, and except that if any non-GPL license | |
23 | // choice is available it will apply instead, Sun elects to use only | |
24 | // the General Public License version 2 (GPLv2) at this time for any | |
25 | // software where a choice of GPL license versions is made | |
26 | // available with the language indicating that GPLv2 or any later version | |
27 | // may be used, or where a choice of which version of the GPL is applied is | |
28 | // otherwise unspecified. | |
29 | // | |
30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | // have any questions. | |
33 | // | |
34 | // ========== Copyright Header End ============================================ | |
35 | #define HTP_DB | |
36 | ||
37 | class htp_db { | |
38 | ||
39 | //======================================================= | |
40 | //= HTP Transmitter Descriptor structure === | |
41 | //======================================================= | |
42 | ||
43 | bit [13:0] packet_length = 14'h0040; // packet_length | |
44 | ||
45 | bit [13:0] buffer_length[]; // buffer_length | |
46 | ||
47 | bit [4:0] chksum_start = 5'h00; // check sum start | |
48 | ||
49 | bit [7:0] chksum_stuff = 8'h00; // check sum stuff | |
50 | ||
51 | bit chksum_enable = 1'b1; // check sum enable | |
52 | ||
53 | bit no_crc = 1'b1; // when set crc not inserted | |
54 | // into the outgoing frame | |
55 | ||
56 | bit int_me = 1'b0; // when set TX_INT_ME | |
57 | // will be set upon | |
58 | // loading the entire | |
59 | // frame into the TX_FIFO | |
60 | ||
61 | ||
62 | bit [3:0] qos = 4'h0; // service level of packet | |
63 | ||
64 | ||
65 | bit [7:0] qp = 8'h00; | |
66 | ||
67 | ||
68 | bit [3:0] fdst = 4'h0; // final destination | |
69 | // 4'b0000 - None | |
70 | // 4'b0001 - IB | |
71 | // 4'b0010 - Network | |
72 | // 4'b1000 - IPSec | |
73 | // 4'b1010 - TE | |
74 | // 4'b1011 - CPU | |
75 | ||
76 | bit [3:0] idst = 4'h0; // initial destination | |
77 | ||
78 | ||
79 | bit [3:0] pkt_src = 4'h0; // Packet source | |
80 | // 4'b0000 - None | |
81 | // 4'b0001 - IB | |
82 | // 4'b0010 - Network | |
83 | // 4'b1000 - IPSec | |
84 | // 4'b1010 - TE | |
85 | // 4'b1011 - CPU | |
86 | ||
87 | bit [3:0] pkt_type = 4'bx; // Packet type | |
88 | // 4'b0xxx - Reserved | |
89 | // 4'b0001 - IB Management | |
90 | // 4'b0010 - Ethernet Packet | |
91 | // 4'b0011 - IPSec(decrypted) | |
92 | // 4'b0100 - IPSec(encrypted) | |
93 | // 4'b0101 - Reserved | |
94 | // 4'b0110 - TCP Termiantion | |
95 | // 4'b0111 - Rdma Read | |
96 | // 4'b1000 - Rdma Write | |
97 | // 4'b1001 - CPU-host management packet | |
98 | // - for other QP(2-127) | |
99 | ||
100 | bit [7:0] packet_type =8'hxx; // irx_packet type | |
101 | ||
102 | bit [7:0] dst_port = 8'hxx; // destination mac port sent to irx cntrl wd | |
103 | ||
104 | bit [7:0] ib_dst_port = 8'hxx; // destination mac port sent to irx cntrl wd | |
105 | ||
106 | bit eop[]; // End of packet | |
107 | ||
108 | bit sop[]; // Start of packet | |
109 | ||
110 | bit [6:0] mac_index; // mac_index | |
111 | ||
112 | bit ib_port; // ib port | |
113 | ||
114 | bit [1:0] mac_port; // mac port | |
115 | ||
116 | // fields of the IRX CONTROL WD | |
117 | ||
118 | bit [15:0] chksum_data = 16'h0000; | |
119 | ||
120 | bit [10:0] bucket_cnt = 11'h000; | |
121 | ||
122 | bit [10:0] eop_offset = 11'h000; | |
123 | ||
124 | bit [3:0] VL = 4'h00; | |
125 | ||
126 | bit [6:0] data_offset = 7'h00; | |
127 | ||
128 | bit single_bkt = 1'b0; | |
129 | ||
130 | bit strip = 1'b0; | |
131 | ||
132 | bit [5:0] reserved = 6'h00; | |
133 | ||
134 | bit [127:0] status_wd = 128'b0; // status word for IRX INTF | |
135 | ||
136 | bit bad_pkt = 1'b0; // bad pkt bit | |
137 | ||
138 | bit [1:0] la4_prot = 2'b00; // 00 -> uninterested | |
139 | // 01 -> tcp | |
140 | // 10 -> udp | |
141 | // 11 -> reserved | |
142 | ||
143 | bit [1:0] la3_vers = 2'b00; // 00 -> uninterested | |
144 | // 01 -> ipv4 | |
145 | // 10 -> ipv6 | |
146 | // 11 -> reserved | |
147 | ||
148 | bit [2:0] la2_opti = 3'b000; // 000 -> ethernet | |
149 | // 001 -> vlan | |
150 | // 010 -> llc | |
151 | // 011 -> vlan-llc | |
152 | // 1xx -> oc192 | |
153 | ||
154 | // adding the null pkt bit | |
155 | ||
156 | bit null_pkt = 1'b0; // default not a null pkt | |
157 | // if set to 1 null pkt | |
158 | ||
159 | bit err_pkt = 1'b0; // default not a err pkt | |
160 | // if set to 1 err_pkt | |
161 | ||
162 | bit no_sop_pkt = 1'b0; // default the pkt has sop | |
163 | // if set to 1 no sop | |
164 | ||
165 | bit no_eop_pkt = 1'b0; // default the pkt has eop | |
166 | // if set to 1 no eop | |
167 | ||
168 | bit pkt_len_err = 1'b0; // default pkt has no len err | |
169 | // if 1 pkt has len err | |
170 | ||
171 | // bit [127:0] htp_txdesc = 128'hx; // This is the descriptor | |
172 | // written into the host memory | |
173 | ||
174 | // bit [127:0] htp_irx_ctrlwd = 128'hx; // This is the control word | |
175 | // passed to IRX by HTP | |
176 | ||
177 | // new bits of IBTP control word1 (BMC) | |
178 | ||
179 | bit [4:0] ipsec_reserved = 5'h00; | |
180 | bit [2:0] ipsec_reserved2 = 3'b000; | |
181 | bit [5:0] ipsec_reserved3 = 5'h00; | |
182 | bit [15:0] tcp_chksum = 16'hffff; | |
183 | bit tcp_fullchksum_ok = 1'b1; | |
184 | bit tcp_fullchksum = 1'b1; | |
185 | bit partial_chksum = 1'b0; | |
186 | bit ip_hdr_chksum_ok = 1'b0; | |
187 | bit [7:0] ipsec_mac_index = 8'h00; | |
188 | bit [11:0] mac_default = 12'h000; | |
189 | bit [3:0] ipsec_mac_port = 4'hf; | |
190 | bit jumbo_pkt = 1'b0; | |
191 | bit [10:0] ipsec_eop_offset = 11'h000; | |
192 | bit [10:0] ipsec_bucket_cnt = 11'h000; | |
193 | ||
194 | // other bits for the control word two | |
195 | ||
196 | bit [7:0] QPN_bypass = 8'h00; | |
197 | bit [1:0] mode_bit = 2'b00; | |
198 | bit [7:0] hdr_len = 8'h00; | |
199 | bit use_mc_index = 1'b0; | |
200 | bit [15:0] tt_index = 16'h0000; | |
201 | bit [31:0] TCP_seq = 32'h0000_0000; | |
202 | bit [15:0] tcp_seg_len = 16'h0000; | |
203 | bit push_bit = 1'b0; | |
204 | bit TOE_wbn = 1'b0; | |
205 | bit [12:0] first_bkt_ptr = 13'h0000; | |
206 | bit [12:0] last_bkt_ptr = 13'h0000; | |
207 | ||
208 | // htp-fflp driver values after the look up | |
209 | ||
210 | // cycle one data | |
211 | ||
212 | bit multicast = 1'b0; | |
213 | bit [2:0] l2_option = 3'b000; | |
214 | bit [1:0] l3_option = 2'b01; | |
215 | bit [1:0] l4_option = 2'b01; | |
216 | bit [3:0] l4_hdr_len = 4'h0; | |
217 | bit solicited_event = 1'b0; | |
218 | bit [31:0] seq_num = 32'h0000_0000; | |
219 | ||
220 | // cycle two data | |
221 | ||
222 | bit [15:0] cam_index = 16'h0000; | |
223 | ||
224 | // cycle three data | |
225 | ||
226 | bit drop_pkt = 1'b0; | |
227 | bit [1:0] pkt_dest = 2'b00; | |
228 | bit [1:0] pkt_mode = 2'b00; | |
229 | bit vlan_match = 1'b0; | |
230 | bit cfg_def_vlan_ena = 1'b0; | |
231 | bit reserved_fflp = 1'b0; | |
232 | bit [7:0] ehp_qp_info = 8'h00; | |
233 | bit cam_match = 1'b0; | |
234 | ||
235 | ||
236 | // completion data handle | |
237 | ||
238 | integer comp_data = 1; | |
239 | bit last_pkt = 1'b0; | |
240 | ||
241 | // buffer pointer of the pkt | |
242 | ||
243 | bit [39:0] buffer_ptr = 40'h00_00000_0000; | |
244 | ||
245 | bit [15:0] comp_offset = 16'h0000; | |
246 | ||
247 | // adding the task definition | |
248 | ||
249 | task new(); | |
250 | ||
251 | function bit [127:0] get_tx_descriptor(bit [39:0] pkt_bufptr, integer i); | |
252 | ||
253 | function bit [127:0] get_htp_irx_ctrlwd(); | |
254 | ||
255 | function bit [31:0] get_irx_route_tag(); | |
256 | ||
257 | function bit [127:0] get_status_wd(); | |
258 | ||
259 | // functions to get the control word for htp_bmc in case of IPSED decrypted packet | |
260 | ||
261 | function bit [127:0] get_htp_bmc_ctrlwd1(); | |
262 | ||
263 | function bit [127:0] get_htp_bmc_ctrlwd2(); | |
264 | ||
265 | // completion wr back word | |
266 | ||
267 | function bit [127:0] get_comp_wrbk_wd(integer buf_indx, bit [1:0] chnl); | |
268 | ||
269 | } // end of class htp_txdesc_db | |
270 | ||
271 | ||
272 | // initializing the commonc parameters | |
273 | ||
274 | task htp_db :: new () | |
275 | { | |
276 | integer i,j,k; | |
277 | ||
278 | printf("Intializing the buffer length array\n"); | |
279 | for(i=0;i<128;i++) { | |
280 | buffer_length[i] = 14'h0000; | |
281 | } | |
282 | ||
283 | printf("Intializing the EOP array\n"); | |
284 | for(j=0;j<128;j++) { | |
285 | eop[j] = 1'b0; | |
286 | } | |
287 | ||
288 | printf("Intializing the SOP array\n"); | |
289 | for(k=0;k<128;k++) { | |
290 | sop[k] = 1'b0; | |
291 | } | |
292 | } | |
293 | ||
294 | function bit [127:0] htp_db :: get_tx_descriptor(bit [39:0] pkt_bufptr, integer i) | |
295 | { | |
296 | bit [127:0] htp_txdesc; | |
297 | ||
298 | // idst = fdst; | |
299 | ||
300 | htp_txdesc = {ib_port, | |
301 | mac_port, | |
302 | mac_index, | |
303 | packet_length, | |
304 | pkt_bufptr, | |
305 | sop[i], | |
306 | eop[i], | |
307 | pkt_type, | |
308 | pkt_src, | |
309 | idst, | |
310 | fdst, | |
311 | qos, | |
312 | qp, | |
313 | VL, | |
314 | int_me, | |
315 | no_crc, | |
316 | chksum_enable, | |
317 | chksum_stuff, | |
318 | chksum_start, | |
319 | buffer_length[i]}; | |
320 | ||
321 | buffer_ptr = pkt_bufptr; | |
322 | get_tx_descriptor = htp_txdesc; | |
323 | } | |
324 | ||
325 | function bit [127:0] htp_db :: get_htp_irx_ctrlwd() | |
326 | { | |
327 | bit [127:0] htp_irx_ctrlwd; | |
328 | ||
329 | dst_port = {6'h00,mac_port}; | |
330 | ||
331 | case(pkt_type) { | |
332 | 4'b0000 : packet_type = 8'b0xxx_xxxx; | |
333 | 4'b0001 : packet_type = 8'b1000_0001; | |
334 | 4'b0010 : packet_type = 8'b1000_0010; | |
335 | 4'b0011 : packet_type = 8'b1000_0011; | |
336 | 4'b0100 : packet_type = 8'b1000_0100; | |
337 | 4'b0101 : packet_type = 8'b1000_0101; | |
338 | 4'b0110 : packet_type = 8'b1000_0110; | |
339 | 4'b0111 : packet_type = 8'b1000_0111; | |
340 | 4'b1000 : packet_type = 8'b1000_1000; | |
341 | 4'b1001 : packet_type = 8'b1000_1001; | |
342 | } | |
343 | ||
344 | ||
345 | // idst = fdst; | |
346 | ||
347 | htp_irx_ctrlwd = {packet_type, | |
348 | pkt_src, | |
349 | idst, | |
350 | fdst, | |
351 | dst_port, | |
352 | 2'b00,qos[1:0], | |
353 | chksum_enable, | |
354 | chksum_stuff, | |
355 | qos[2],chksum_start, | |
356 | chksum_data, | |
357 | bucket_cnt, | |
358 | eop_offset, | |
359 | ib_port, | |
360 | VL, | |
361 | qp, | |
362 | data_offset, | |
363 | packet_length, | |
364 | no_crc, | |
365 | single_bkt, | |
366 | strip, | |
367 | reserved}; | |
368 | ||
369 | get_htp_irx_ctrlwd = htp_irx_ctrlwd; | |
370 | } | |
371 | ||
372 | function bit [31:0] htp_db :: get_irx_route_tag() | |
373 | { | |
374 | bit [31:0] htp_irx_route_tag; | |
375 | ||
376 | // idst = fdst; | |
377 | ||
378 | htp_irx_route_tag = {packet_type,pkt_src,idst,fdst,dst_port,qos}; | |
379 | ||
380 | get_irx_route_tag = htp_irx_route_tag; | |
381 | } | |
382 | ||
383 | ||
384 | // status word for IRX interface | |
385 | ||
386 | function bit [127:0] htp_db :: get_status_wd() | |
387 | { | |
388 | bit [127:0] htp_irx_status_wd; | |
389 | ||
390 | htp_irx_status_wd = {bad_pkt,111'b0,chksum_data}; | |
391 | ||
392 | get_status_wd = htp_irx_status_wd; | |
393 | } | |
394 | ||
395 | // this is used for IPSEC packet in the TCP flow mode going to the IB_PORT | |
396 | ||
397 | function bit [127:0] htp_db :: get_htp_bmc_ctrlwd1() | |
398 | { | |
399 | bit [127:0] htp_bmc_ctrlwd1; | |
400 | ||
401 | // dst_port = {6'h00,mac_port}; | |
402 | ||
403 | case(pkt_type) { | |
404 | 4'b0000 : packet_type = 8'b0xxx_xxxx; | |
405 | 4'b0001 : packet_type = 8'b1000_0001; | |
406 | 4'b0010 : packet_type = 8'b1000_0010; | |
407 | 4'b0011 : packet_type = 8'b1000_0011; | |
408 | 4'b0100 : packet_type = 8'b1000_0100; | |
409 | 4'b0101 : packet_type = 8'b1000_0101; | |
410 | 4'b0110 : packet_type = 8'b1000_0110; | |
411 | 4'b0111 : packet_type = 8'b1000_0111; | |
412 | 4'b1000 : packet_type = 8'b1000_1000; | |
413 | 4'b1001 : packet_type = 8'b1000_1001; | |
414 | } | |
415 | ||
416 | ||
417 | htp_bmc_ctrlwd1 = {packet_type, | |
418 | pkt_src, | |
419 | idst, | |
420 | fdst, | |
421 | ib_dst_port, | |
422 | qos, | |
423 | ipsec_reserved3, | |
424 | jumbo_pkt, | |
425 | ipsec_mac_port, | |
426 | mac_default, | |
427 | ipsec_mac_index, | |
428 | ipsec_bucket_cnt, | |
429 | ipsec_eop_offset, | |
430 | ip_hdr_chksum_ok, | |
431 | partial_chksum, | |
432 | tcp_fullchksum, | |
433 | tcp_fullchksum_ok, | |
434 | tcp_chksum, | |
435 | packet_length, | |
436 | ipsec_reserved2,1'b0, | |
437 | ipsec_reserved}; | |
438 | ||
439 | get_htp_bmc_ctrlwd1 = htp_bmc_ctrlwd1; | |
440 | } | |
441 | ||
442 | // this is used for IPSEC packet in the TCP flow mode going to the IB_PORT | |
443 | ||
444 | function bit [127:0] htp_db :: get_htp_bmc_ctrlwd2() | |
445 | { | |
446 | bit [127:0] htp_bmc_ctrlwd2; | |
447 | ||
448 | // mode_bit = chksum_start[4:3]; | |
449 | // use_mc_index = chksum_start[2]; | |
450 | // push_bit = chksum_start[1]; | |
451 | // TOE_wbn = chksum_start[0]; | |
452 | ||
453 | ||
454 | ||
455 | htp_bmc_ctrlwd2 = {1'b0, | |
456 | last_bkt_ptr, | |
457 | first_bkt_ptr, | |
458 | TOE_wbn, | |
459 | push_bit, | |
460 | tcp_seg_len, | |
461 | TCP_seq, | |
462 | tt_index, | |
463 | use_mc_index, | |
464 | hdr_len, | |
465 | 2'b00,packet_length, | |
466 | mode_bit, | |
467 | QPN_bypass}; | |
468 | ||
469 | ||
470 | get_htp_bmc_ctrlwd2 = htp_bmc_ctrlwd2; | |
471 | } | |
472 | ||
473 | ||
474 | //-------------------------------------------------- | |
475 | //----- comp write back word function -------------- | |
476 | //-------------------------------------------------- | |
477 | ||
478 | function bit [127:0] htp_db :: get_comp_wrbk_wd(integer buf_indx, bit [1:0] chnl) | |
479 | { | |
480 | bit [127:0] htp_cp_wrbk_wd; | |
481 | comp_offset = buf_indx; | |
482 | ||
483 | htp_cp_wrbk_wd = { | |
484 | pkt_type, | |
485 | pkt_src, | |
486 | idst, | |
487 | fdst, | |
488 | 8'h0, | |
489 | buffer_ptr, | |
490 | 2'b00, | |
491 | packet_length, | |
492 | 2'b00, | |
493 | buffer_length[buf_indx], | |
494 | sop[buf_indx], | |
495 | eop[buf_indx], | |
496 | 1'b0, | |
497 | err_pkt, | |
498 | 2'b00, | |
499 | chnl, | |
500 | qp, | |
501 | comp_offset | |
502 | }; | |
503 | ||
504 | get_comp_wrbk_wd = htp_cp_wrbk_wd; | |
505 | } | |
506 | ||
507 | ||
508 | ||
509 | ||
510 | ||
511 | ||
512 |