This source file includes following definitions.
- cvmx_pip_config_port
- cvmx_pip_config_watcher
- cvmx_pip_config_vlan_qos
- cvmx_pip_config_diffserv_qos
- cvmx_pip_get_port_status
- cvmx_pip_config_crc
- cvmx_pip_tag_mask_clear
- cvmx_pip_tag_mask_set
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 #ifndef __CVMX_PIP_H__
34 #define __CVMX_PIP_H__
35
36 #include <asm/octeon/cvmx-wqe.h>
37 #include <asm/octeon/cvmx-fpa.h>
38 #include <asm/octeon/cvmx-pip-defs.h>
39
40 #define CVMX_PIP_NUM_INPUT_PORTS 48
41 #define CVMX_PIP_NUM_WATCHERS 4
42
43
44
45
46 typedef enum {
47 CVMX_PIP_L4_NO_ERR = 0ull,
48
49
50
51
52 CVMX_PIP_L4_MAL_ERR = 1ull,
53
54 CVMX_PIP_CHK_ERR = 2ull,
55
56
57
58
59 CVMX_PIP_L4_LENGTH_ERR = 3ull,
60
61 CVMX_PIP_BAD_PRT_ERR = 4ull,
62
63 CVMX_PIP_TCP_FLG8_ERR = 8ull,
64
65 CVMX_PIP_TCP_FLG9_ERR = 9ull,
66
67 CVMX_PIP_TCP_FLG10_ERR = 10ull,
68
69 CVMX_PIP_TCP_FLG11_ERR = 11ull,
70
71 CVMX_PIP_TCP_FLG12_ERR = 12ull,
72
73 CVMX_PIP_TCP_FLG13_ERR = 13ull
74 } cvmx_pip_l4_err_t;
75
76 typedef enum {
77
78 CVMX_PIP_IP_NO_ERR = 0ull,
79
80 CVMX_PIP_NOT_IP = 1ull,
81
82 CVMX_PIP_IPV4_HDR_CHK = 2ull,
83
84 CVMX_PIP_IP_MAL_HDR = 3ull,
85
86 CVMX_PIP_IP_MAL_PKT = 4ull,
87
88 CVMX_PIP_TTL_HOP = 5ull,
89
90 CVMX_PIP_OPTS = 6ull
91 } cvmx_pip_ip_exc_t;
92
93
94
95
96
97
98
99
100 typedef enum {
101
102 CVMX_PIP_RX_NO_ERR = 0ull,
103
104
105 CVMX_PIP_PARTIAL_ERR = 1ull,
106
107 CVMX_PIP_JABBER_ERR = 2ull,
108
109
110
111
112 CVMX_PIP_OVER_FCS_ERR = 3ull,
113
114 CVMX_PIP_OVER_ERR = 4ull,
115
116
117
118
119 CVMX_PIP_ALIGN_ERR = 5ull,
120
121
122
123
124 CVMX_PIP_UNDER_FCS_ERR = 6ull,
125
126 CVMX_PIP_GMX_FCS_ERR = 7ull,
127
128 CVMX_PIP_UNDER_ERR = 8ull,
129
130 CVMX_PIP_EXTEND_ERR = 9ull,
131
132
133
134
135 CVMX_PIP_LENGTH_ERR = 10ull,
136
137 CVMX_PIP_DAT_ERR = 11ull,
138
139 CVMX_PIP_DIP_ERR = 11ull,
140
141
142
143
144 CVMX_PIP_SKIP_ERR = 12ull,
145
146
147
148
149 CVMX_PIP_NIBBLE_ERR = 13ull,
150
151 CVMX_PIP_PIP_FCS = 16L,
152
153
154
155
156 CVMX_PIP_PIP_SKIP_ERR = 17L,
157
158
159
160
161 CVMX_PIP_PIP_L2_MAL_HDR = 18L
162
163
164
165
166
167
168
169 } cvmx_pip_rcv_err_t;
170
171
172
173
174 typedef union {
175 cvmx_pip_l4_err_t l4_err;
176 cvmx_pip_ip_exc_t ip_exc;
177 cvmx_pip_rcv_err_t rcv_err;
178 } cvmx_pip_err_t;
179
180
181
182
183 typedef struct {
184
185 uint32_t dropped_octets;
186
187 uint32_t dropped_packets;
188
189 uint32_t pci_raw_packets;
190
191 uint32_t octets;
192
193 uint32_t packets;
194
195
196
197
198
199 uint32_t multicast_packets;
200
201
202
203
204
205 uint32_t broadcast_packets;
206
207 uint32_t len_64_packets;
208
209 uint32_t len_65_127_packets;
210
211 uint32_t len_128_255_packets;
212
213 uint32_t len_256_511_packets;
214
215 uint32_t len_512_1023_packets;
216
217 uint32_t len_1024_1518_packets;
218
219 uint32_t len_1519_max_packets;
220
221 uint32_t fcs_align_err_packets;
222
223 uint32_t runt_packets;
224
225 uint32_t runt_crc_packets;
226
227 uint32_t oversize_packets;
228
229 uint32_t oversize_crc_packets;
230
231 uint32_t inb_packets;
232
233
234
235
236 uint64_t inb_octets;
237
238 uint16_t inb_errors;
239 } cvmx_pip_port_status_t;
240
241
242
243
244
245 typedef union {
246 uint64_t u64;
247 struct {
248
249
250
251
252 uint64_t rawfull:1;
253
254 uint64_t reserved0:5;
255
256 uint64_t parse_mode:2;
257
258 uint64_t reserved1:1;
259
260
261
262
263 uint64_t skip_len:7;
264
265 uint64_t reserved2:6;
266
267 uint64_t qos:3;
268
269 uint64_t grp:4;
270
271
272
273
274 uint64_t rs:1;
275
276 uint64_t tag_type:2;
277
278 uint64_t tag:32;
279 } s;
280 } cvmx_pip_pkt_inst_hdr_t;
281
282
283
284
285
286
287
288
289
290
291
292 static inline void cvmx_pip_config_port(uint64_t port_num,
293 union cvmx_pip_prt_cfgx port_cfg,
294 union cvmx_pip_prt_tagx port_tag_cfg)
295 {
296 cvmx_write_csr(CVMX_PIP_PRT_CFGX(port_num), port_cfg.u64);
297 cvmx_write_csr(CVMX_PIP_PRT_TAGX(port_num), port_tag_cfg.u64);
298 }
299 #if 0
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316 static inline void cvmx_pip_config_watcher(uint64_t watcher,
317 cvmx_pip_qos_watch_types match_type,
318 uint64_t match_value, uint64_t qos)
319 {
320 cvmx_pip_port_watcher_cfg_t watcher_config;
321
322 watcher_config.u64 = 0;
323 watcher_config.s.match_type = match_type;
324 watcher_config.s.match_value = match_value;
325 watcher_config.s.qos = qos;
326
327 cvmx_write_csr(CVMX_PIP_QOS_WATCHX(watcher), watcher_config.u64);
328 }
329 #endif
330
331
332
333
334
335
336
337 static inline void cvmx_pip_config_vlan_qos(uint64_t vlan_priority,
338 uint64_t qos)
339 {
340 union cvmx_pip_qos_vlanx pip_qos_vlanx;
341 pip_qos_vlanx.u64 = 0;
342 pip_qos_vlanx.s.qos = qos;
343 cvmx_write_csr(CVMX_PIP_QOS_VLANX(vlan_priority), pip_qos_vlanx.u64);
344 }
345
346
347
348
349
350
351
352 static inline void cvmx_pip_config_diffserv_qos(uint64_t diffserv, uint64_t qos)
353 {
354 union cvmx_pip_qos_diffx pip_qos_diffx;
355 pip_qos_diffx.u64 = 0;
356 pip_qos_diffx.s.qos = qos;
357 cvmx_write_csr(CVMX_PIP_QOS_DIFFX(diffserv), pip_qos_diffx.u64);
358 }
359
360
361
362
363
364
365
366
367 static inline void cvmx_pip_get_port_status(uint64_t port_num, uint64_t clear,
368 cvmx_pip_port_status_t *status)
369 {
370 union cvmx_pip_stat_ctl pip_stat_ctl;
371 union cvmx_pip_stat0_prtx stat0;
372 union cvmx_pip_stat1_prtx stat1;
373 union cvmx_pip_stat2_prtx stat2;
374 union cvmx_pip_stat3_prtx stat3;
375 union cvmx_pip_stat4_prtx stat4;
376 union cvmx_pip_stat5_prtx stat5;
377 union cvmx_pip_stat6_prtx stat6;
378 union cvmx_pip_stat7_prtx stat7;
379 union cvmx_pip_stat8_prtx stat8;
380 union cvmx_pip_stat9_prtx stat9;
381 union cvmx_pip_stat_inb_pktsx pip_stat_inb_pktsx;
382 union cvmx_pip_stat_inb_octsx pip_stat_inb_octsx;
383 union cvmx_pip_stat_inb_errsx pip_stat_inb_errsx;
384
385 pip_stat_ctl.u64 = 0;
386 pip_stat_ctl.s.rdclr = clear;
387 cvmx_write_csr(CVMX_PIP_STAT_CTL, pip_stat_ctl.u64);
388
389 stat0.u64 = cvmx_read_csr(CVMX_PIP_STAT0_PRTX(port_num));
390 stat1.u64 = cvmx_read_csr(CVMX_PIP_STAT1_PRTX(port_num));
391 stat2.u64 = cvmx_read_csr(CVMX_PIP_STAT2_PRTX(port_num));
392 stat3.u64 = cvmx_read_csr(CVMX_PIP_STAT3_PRTX(port_num));
393 stat4.u64 = cvmx_read_csr(CVMX_PIP_STAT4_PRTX(port_num));
394 stat5.u64 = cvmx_read_csr(CVMX_PIP_STAT5_PRTX(port_num));
395 stat6.u64 = cvmx_read_csr(CVMX_PIP_STAT6_PRTX(port_num));
396 stat7.u64 = cvmx_read_csr(CVMX_PIP_STAT7_PRTX(port_num));
397 stat8.u64 = cvmx_read_csr(CVMX_PIP_STAT8_PRTX(port_num));
398 stat9.u64 = cvmx_read_csr(CVMX_PIP_STAT9_PRTX(port_num));
399 pip_stat_inb_pktsx.u64 =
400 cvmx_read_csr(CVMX_PIP_STAT_INB_PKTSX(port_num));
401 pip_stat_inb_octsx.u64 =
402 cvmx_read_csr(CVMX_PIP_STAT_INB_OCTSX(port_num));
403 pip_stat_inb_errsx.u64 =
404 cvmx_read_csr(CVMX_PIP_STAT_INB_ERRSX(port_num));
405
406 status->dropped_octets = stat0.s.drp_octs;
407 status->dropped_packets = stat0.s.drp_pkts;
408 status->octets = stat1.s.octs;
409 status->pci_raw_packets = stat2.s.raw;
410 status->packets = stat2.s.pkts;
411 status->multicast_packets = stat3.s.mcst;
412 status->broadcast_packets = stat3.s.bcst;
413 status->len_64_packets = stat4.s.h64;
414 status->len_65_127_packets = stat4.s.h65to127;
415 status->len_128_255_packets = stat5.s.h128to255;
416 status->len_256_511_packets = stat5.s.h256to511;
417 status->len_512_1023_packets = stat6.s.h512to1023;
418 status->len_1024_1518_packets = stat6.s.h1024to1518;
419 status->len_1519_max_packets = stat7.s.h1519;
420 status->fcs_align_err_packets = stat7.s.fcs;
421 status->runt_packets = stat8.s.undersz;
422 status->runt_crc_packets = stat8.s.frag;
423 status->oversize_packets = stat9.s.oversz;
424 status->oversize_crc_packets = stat9.s.jabber;
425 status->inb_packets = pip_stat_inb_pktsx.s.pkts;
426 status->inb_octets = pip_stat_inb_octsx.s.octs;
427 status->inb_errors = pip_stat_inb_errsx.s.errs;
428
429 if (cvmx_octeon_is_pass1()) {
430
431
432
433
434 if (status->inb_packets > status->packets)
435 status->dropped_packets =
436 status->inb_packets - status->packets;
437 else
438 status->dropped_packets = 0;
439 if (status->inb_octets - status->inb_packets * 4 >
440 status->octets)
441 status->dropped_octets =
442 status->inb_octets - status->inb_packets * 4 -
443 status->octets;
444 else
445 status->dropped_octets = 0;
446 }
447 }
448
449
450
451
452
453
454
455
456
457
458
459 static inline void cvmx_pip_config_crc(uint64_t interface,
460 uint64_t invert_result, uint64_t reflect,
461 uint32_t initialization_vector)
462 {
463 if (OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX)) {
464 union cvmx_pip_crc_ctlx config;
465 union cvmx_pip_crc_ivx pip_crc_ivx;
466
467 config.u64 = 0;
468 config.s.invres = invert_result;
469 config.s.reflect = reflect;
470 cvmx_write_csr(CVMX_PIP_CRC_CTLX(interface), config.u64);
471
472 pip_crc_ivx.u64 = 0;
473 pip_crc_ivx.s.iv = initialization_vector;
474 cvmx_write_csr(CVMX_PIP_CRC_IVX(interface), pip_crc_ivx.u64);
475 }
476 }
477
478
479
480
481
482
483
484
485
486 static inline void cvmx_pip_tag_mask_clear(uint64_t mask_index)
487 {
488 uint64_t index;
489 union cvmx_pip_tag_incx pip_tag_incx;
490 pip_tag_incx.u64 = 0;
491 pip_tag_incx.s.en = 0;
492 for (index = mask_index * 16; index < (mask_index + 1) * 16; index++)
493 cvmx_write_csr(CVMX_PIP_TAG_INCX(index), pip_tag_incx.u64);
494 }
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511 static inline void cvmx_pip_tag_mask_set(uint64_t mask_index, uint64_t offset,
512 uint64_t len)
513 {
514 while (len--) {
515 union cvmx_pip_tag_incx pip_tag_incx;
516 uint64_t index = mask_index * 16 + offset / 8;
517 pip_tag_incx.u64 = cvmx_read_csr(CVMX_PIP_TAG_INCX(index));
518 pip_tag_incx.s.en |= 0x80 >> (offset & 0x7);
519 cvmx_write_csr(CVMX_PIP_TAG_INCX(index), pip_tag_incx.u64);
520 offset++;
521 }
522 }
523
524 #endif