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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <hxge_impl.h>
#include <hpi_pfc.h>
#define TCAM_COMPLETION_TRY_COUNT 10
#define HXGE_VLAN_TABLE_ENTRIES 128
#define HXGE_PFC_INT_STATUS_CLEAR 0x7ULL
static uint64_t
hpi_pfc_tcam_check_completion(hpi_handle_t handle, tcam_op_t op_type)
{
uint32_t try_counter, tcam_delay = 10;
pfc_tcam_ctrl_t tctl;
try_counter = TCAM_COMPLETION_TRY_COUNT;
switch (op_type) {
case TCAM_RWC_STAT:
READ_TCAM_REG_CTL(handle, &tctl.value);
while ((try_counter) &&
(tctl.bits.status != TCAM_CTL_RWC_RWC_STAT)) {
try_counter--;
HXGE_DELAY(tcam_delay);
READ_TCAM_REG_CTL(handle, &tctl.value);
}
if (!try_counter) {
HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
" TCAM RWC_STAT operation"
" failed to complete \n"));
return (HPI_PFC_TCAM_HW_ERROR);
}
tctl.value = 0;
break;
case TCAM_RWC_MATCH:
READ_TCAM_REG_CTL(handle, &tctl.value);
while ((try_counter) &&
(tctl.bits.match != TCAM_CTL_RWC_RWC_MATCH)) {
try_counter--;
HXGE_DELAY(tcam_delay);
READ_TCAM_REG_CTL(handle, &tctl.value);
}
if (!try_counter) {
HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
" TCAM Match operationfailed to find match \n"));
}
break;
default:
HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
" Invalid TCAM completion Request \n"));
return (HPI_PFC_ERROR | HPI_TCAM_ERROR | OPCODE_INVALID);
}
return (tctl.value);
}
hpi_status_t
hpi_pfc_tcam_entry_read(hpi_handle_t handle, uint32_t location,
hxge_tcam_entry_t *tcam_ptr)
{
pfc_tcam_ctrl_t tctl;
pfc_tcam_ctrl_t tctl_rv;
/*
* Hydra doesn't allow to read TCAM entries. Use compare instead.
*/
WRITE_TCAM_REG_MASK0(handle, tcam_ptr->mask0);
WRITE_TCAM_REG_MASK1(handle, tcam_ptr->mask1);
WRITE_TCAM_REG_KEY0(handle, tcam_ptr->key0);
WRITE_TCAM_REG_KEY1(handle, tcam_ptr->key1);
tctl.value = 0;
tctl.bits.addr = location;
tctl.bits.cmd = TCAM_CTL_RWC_TCAM_CMP;
WRITE_TCAM_REG_CTL(handle, tctl.value);
tctl_rv.value = hpi_pfc_tcam_check_completion(handle, TCAM_RWC_MATCH);
if (tctl_rv.bits.match)
return (HPI_SUCCESS);
else
return (HPI_FAILURE);
}
hpi_status_t
hpi_pfc_tcam_asc_ram_entry_read(hpi_handle_t handle,
uint32_t location, uint64_t *ram_data)
{
uint64_t tcam_stat;
pfc_tcam_ctrl_t tctl;
tctl.value = 0;
tctl.bits.addr = location;
tctl.bits.cmd = TCAM_CTL_RWC_RAM_RD;
WRITE_TCAM_REG_CTL(handle, tctl.value);
tcam_stat = hpi_pfc_tcam_check_completion(handle, TCAM_RWC_STAT);
if (tcam_stat & HPI_FAILURE) {
HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
"TCAM RAM read failed loc %d \n", location));
return (HPI_PFC_ASC_RAM_RD_ERROR);
}
READ_TCAM_REG_KEY0(handle, ram_data);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_tcam_asc_ram_entry_write(hpi_handle_t handle, uint32_t location,
uint64_t ram_data)
{
uint64_t tcam_stat = 0;
pfc_tcam_ctrl_t tctl;
WRITE_TCAM_REG_KEY0(handle, ram_data);
tctl.value = 0;
tctl.bits.addr = location;
tctl.bits.cmd = TCAM_CTL_RWC_RAM_WR;
HPI_DEBUG_MSG((handle.function, HPI_PFC_CTL,
" tcam ascr write: location %x data %llx ctl value %llx \n",
location, ram_data, tctl.value));
WRITE_TCAM_REG_CTL(handle, tctl.value);
tcam_stat = hpi_pfc_tcam_check_completion(handle, TCAM_RWC_STAT);
if (tcam_stat & HPI_FAILURE) {
HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
"TCAM RAM write failed loc %d \n", location));
return (HPI_PFC_ASC_RAM_WR_ERROR);
}
return (HPI_SUCCESS);
}
static hpi_status_t
hpi_pfc_set_config(hpi_handle_t handle, pfc_config_t config)
{
uint64_t offset;
offset = PFC_CONFIG;
REG_PIO_WRITE64(handle, offset, config.value);
return (HPI_SUCCESS);
}
static hpi_status_t
hpi_pfc_get_config(hpi_handle_t handle, pfc_config_t *configp)
{
uint64_t offset;
offset = PFC_CONFIG;
REG_PIO_READ64(handle, offset, &configp->value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_tcam_enable(hpi_handle_t handle, boolean_t tcam)
{
pfc_config_t config;
/*
* Read the register first.
*/
(void) hpi_pfc_get_config(handle, &config);
if (tcam)
config.bits.tcam_en = 1;
else
config.bits.tcam_en = 0;
return (hpi_pfc_set_config(handle, config));
}
hpi_status_t
hpi_pfc_set_l2_hash(hpi_handle_t handle, boolean_t l2_hash)
{
pfc_config_t config;
/*
* Read the register first.
*/
(void) hpi_pfc_get_config(handle, &config);
if (l2_hash)
config.bits.l2_hash_en = 1;
else
config.bits.l2_hash_en = 0;
return (hpi_pfc_set_config(handle, config));
}
hpi_status_t
hpi_pfc_set_tcp_cksum(hpi_handle_t handle, boolean_t cksum)
{
pfc_config_t config;
/*
* Read the register first.
*/
(void) hpi_pfc_get_config(handle, &config);
if (cksum)
config.bits.tcp_cs_en = 1;
else
config.bits.tcp_cs_en = 0;
return (hpi_pfc_set_config(handle, config));
}
hpi_status_t
hpi_pfc_set_default_dma(hpi_handle_t handle, uint32_t dma_channel_no)
{
pfc_config_t config;
(void) hpi_pfc_get_config(handle, &config);
if (dma_channel_no > PFC_MAX_DMA_CHANNELS)
return (HPI_FAILURE);
config.bits.default_dma = dma_channel_no;
return (hpi_pfc_set_config(handle, config));
}
hpi_status_t
hpi_pfc_mac_addr_enable(hpi_handle_t handle, uint32_t slot)
{
pfc_config_t config;
uint32_t bit;
if (slot >= PFC_N_MAC_ADDRESSES) {
return (HPI_FAILURE);
}
(void) hpi_pfc_get_config(handle, &config);
if (slot < 24) {
bit = 1 << slot;
config.bits.mac_addr_en_l = config.bits.mac_addr_en_l | bit;
} else {
bit = 1 << (slot - 24);
config.bits.mac_addr_en = config.bits.mac_addr_en | bit;
}
return (hpi_pfc_set_config(handle, config));
}
hpi_status_t
hpi_pfc_mac_addr_disable(hpi_handle_t handle, uint32_t slot)
{
pfc_config_t config;
uint32_t bit;
if (slot >= PFC_N_MAC_ADDRESSES) {
return (HPI_FAILURE);
}
(void) hpi_pfc_get_config(handle, &config);
if (slot < 24) {
bit = 1 << slot;
config.bits.mac_addr_en_l = config.bits.mac_addr_en_l & ~bit;
} else {
bit = 1 << (slot - 24);
config.bits.mac_addr_en = config.bits.mac_addr_en & ~bit;
}
return (hpi_pfc_set_config(handle, config));
}
hpi_status_t
hpi_pfc_set_force_csum(hpi_handle_t handle, boolean_t force)
{
pfc_config_t config;
(void) hpi_pfc_get_config(handle, &config);
if (force)
config.bits.force_cs_en = 1;
else
config.bits.force_cs_en = 0;
return (hpi_pfc_set_config(handle, config));
}
hpi_status_t
hpi_pfc_cfg_vlan_table_clear(hpi_handle_t handle)
{
int i;
int offset;
int step = 8;
pfc_vlan_table_t table_entry;
table_entry.value = 0;
for (i = 0; i < HXGE_VLAN_TABLE_ENTRIES; i++) {
table_entry.bits.member = 0;
offset = PFC_VLAN_TABLE + i * step;
REG_PIO_WRITE64(handle, offset, table_entry.value);
}
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_cfg_vlan_table_entry_clear(hpi_handle_t handle, vlan_id_t vlan_id)
{
uint64_t offset;
pfc_vlan_table_t vlan_tbl_entry;
uint64_t bit;
/*
* Assumes that the hardware will generate the new parity
* data.
*/
offset = PFC_VLAN_REG_OFFSET(vlan_id);
REG_PIO_READ64(handle, offset, (uint64_t *)&vlan_tbl_entry.value);
bit = PFC_VLAN_BIT_OFFSET(vlan_id);
bit = 1 << bit;
vlan_tbl_entry.bits.member = vlan_tbl_entry.bits.member & ~bit;
REG_PIO_WRITE64(handle, offset, vlan_tbl_entry.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_cfg_vlan_table_entry_set(hpi_handle_t handle, vlan_id_t vlan_id)
{
uint64_t offset;
pfc_vlan_table_t vlan_tbl_entry;
uint64_t bit;
/*
* Assumes that the hardware will generate the new parity
* data.
*/
offset = PFC_VLAN_REG_OFFSET(vlan_id);
REG_PIO_READ64(handle, offset, (uint64_t *)&vlan_tbl_entry.value);
bit = PFC_VLAN_BIT_OFFSET(vlan_id);
bit = 1 << bit;
vlan_tbl_entry.bits.member = vlan_tbl_entry.bits.member | bit;
REG_PIO_WRITE64(handle, offset, vlan_tbl_entry.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_cfg_vlan_control_set(hpi_handle_t handle, boolean_t parity,
boolean_t valid, vlan_id_t vlan_id)
{
pfc_vlan_ctrl_t vlan_control;
vlan_control.value = 0;
if (parity)
vlan_control.bits.par_en = 1;
else
vlan_control.bits.par_en = 0;
if (valid)
vlan_control.bits.valid = 1;
else
vlan_control.bits.valid = 0;
vlan_control.bits.id = vlan_id;
REG_PIO_WRITE64(handle, PFC_VLAN_CTRL, vlan_control.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_get_vlan_parity_log(hpi_handle_t handle, pfc_vlan_par_err_log_t *logp)
{
uint64_t offset;
offset = PFC_VLAN_PAR_ERR_LOG;
REG_PIO_READ64(handle, offset, &logp->value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_mac_address(hpi_handle_t handle, uint32_t slot, uint64_t address)
{
uint64_t offset;
uint64_t moffset;
pfc_mac_addr_mask_t mask;
pfc_mac_addr_t addr;
if (slot >= PFC_N_MAC_ADDRESSES)
return (HPI_FAILURE);
offset = PFC_MAC_ADDRESS(slot);
moffset = PFC_MAC_ADDRESS_MASK(slot);
addr.bits.addr = address >> 32;
addr.bits.addr_l = address & 0xffffffff;
mask.bits.mask = 0x0;
mask.bits.mask_l = 0x0;
REG_PIO_WRITE64(handle, offset, addr.value);
REG_PIO_WRITE64(handle, moffset, mask.value);
return (hpi_pfc_mac_addr_enable(handle, slot));
}
hpi_status_t
hpi_pfc_clear_mac_address(hpi_handle_t handle, uint32_t slot)
{
uint64_t offset, moffset;
uint64_t zaddr = 0x0ULL;
uint64_t zmask = 0x0ULL;
if (slot >= PFC_N_MAC_ADDRESSES)
return (HPI_FAILURE);
(void) hpi_pfc_mac_addr_disable(handle, slot);
offset = PFC_MAC_ADDRESS(slot);
moffset = PFC_MAC_ADDRESS_MASK(slot);
REG_PIO_WRITE64(handle, offset, zaddr);
REG_PIO_WRITE64(handle, moffset, zmask);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_clear_multicast_hash_table(hpi_handle_t handle, uint32_t slot)
{
uint64_t offset;
if (slot >= PFC_N_MAC_ADDRESSES)
return (HPI_FAILURE);
offset = PFC_HASH_ADDR(slot);
REG_PIO_WRITE64(handle, offset, 0ULL);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_multicast_hash_table(hpi_handle_t handle, uint32_t slot,
uint64_t address)
{
uint64_t offset;
if (slot >= PFC_N_MAC_ADDRESSES)
return (HPI_FAILURE);
offset = PFC_HASH_ADDR(slot);
REG_PIO_WRITE64(handle, offset, address);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_l2_class_slot(hpi_handle_t handle, uint16_t etype, boolean_t valid,
int slot)
{
pfc_l2_class_config_t l2_config;
uint64_t offset;
if (slot >= PFC_N_MAC_ADDRESSES)
return (HPI_FAILURE);
l2_config.value = 0;
if (valid)
l2_config.bits.valid = 1;
else
l2_config.bits.valid = 0;
l2_config.bits.etype = etype;
l2_config.bits.rsrvd = 0;
offset = PFC_L2_CONFIG(slot);
REG_PIO_WRITE64(handle, offset, l2_config.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_l3_class_config(hpi_handle_t handle, tcam_class_t slot,
tcam_key_cfg_t cfg)
{
pfc_l3_class_config_t l3_config;
uint64_t offset;
if (slot >= PFC_N_MAC_ADDRESSES)
return (HPI_FAILURE);
l3_config.value = 0;
if (cfg.lookup_enable)
l3_config.bits.tsel = 1;
else
l3_config.bits.tsel = 0;
if (cfg.discard)
l3_config.bits.discard = 1;
else
l3_config.bits.discard = 0;
offset = PFC_L3_CONFIG(slot);
REG_PIO_WRITE64(handle, offset, l3_config.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_get_l3_class_config(hpi_handle_t handle, tcam_class_t slot,
tcam_key_cfg_t *cfg)
{
pfc_l3_class_config_t l3_config;
uint64_t offset;
if (slot >= PFC_N_MAC_ADDRESSES)
return (HPI_FAILURE);
offset = PFC_L3_CONFIG(slot);
REG_PIO_READ64(handle, offset, &l3_config.value);
if (l3_config.bits.tsel)
cfg->lookup_enable = 1;
else
cfg->lookup_enable = 0;
if (l3_config.bits.discard)
cfg->discard = 1;
else
cfg->discard = 0;
return (HPI_SUCCESS);
}
static hpi_status_t
hpi_pfc_set_tcam_control(hpi_handle_t handle, pfc_tcam_ctrl_t *tcontrolp)
{
uint64_t offset;
offset = PFC_TCAM_CTRL;
REG_PIO_WRITE64(handle, offset, tcontrolp->value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_tcam_entry_invalidate(hpi_handle_t handle, uint32_t location)
{
hxge_tcam_entry_t tcam_ptr;
(void) memset(&tcam_ptr, 0, sizeof (hxge_tcam_entry_t));
(void) hpi_pfc_tcam_entry_write(handle, location, &tcam_ptr);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_tcam_invalidate_all(hpi_handle_t handle)
{
int i;
pfc_tcam_ctrl_t tcontrol;
tcontrol.value = 0;
for (i = 0; i < PFC_N_TCAM_ENTRIES; i++) {
(void) hpi_pfc_set_tcam_control(handle, &tcontrol);
(void) hpi_pfc_tcam_entry_invalidate(handle, i);
}
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_tcam_entry_write(hpi_handle_t handle, uint32_t location,
hxge_tcam_entry_t *tcam_ptr)
{
uint64_t tcam_stat;
pfc_tcam_ctrl_t tctl;
WRITE_TCAM_REG_MASK0(handle, tcam_ptr->mask0);
WRITE_TCAM_REG_MASK1(handle, tcam_ptr->mask1);
WRITE_TCAM_REG_KEY0(handle, tcam_ptr->key0);
WRITE_TCAM_REG_KEY1(handle, tcam_ptr->key1);
HPI_DEBUG_MSG((handle.function, HPI_PFC_CTL,
" tcam write: location %x\n key: %llx %llx\n mask: %llx %llx\n",
location, tcam_ptr->key0, tcam_ptr->key1,
tcam_ptr->mask0, tcam_ptr->mask1));
tctl.value = 0;
tctl.bits.addr = location;
tctl.bits.cmd = TCAM_CTL_RWC_TCAM_WR;
HPI_DEBUG_MSG((handle.function, HPI_PFC_CTL,
" tcam write: ctl value %llx \n", tctl.value));
WRITE_TCAM_REG_CTL(handle, tctl.value);
tcam_stat = hpi_pfc_tcam_check_completion(handle, TCAM_RWC_STAT);
if (tcam_stat & HPI_FAILURE) {
HPI_ERROR_MSG((handle.function, HPI_ERR_CTL,
"TCAM Write failed loc %d \n", location));
return (HPI_PFC_TCAM_WR_ERROR);
}
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_get_tcam_parity_log(hpi_handle_t handle, pfc_tcam_par_err_log_t *logp)
{
uint64_t offset;
offset = PFC_TCAM_PAR_ERR_LOG;
REG_PIO_READ64(handle, offset, &logp->value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_get_tcam_auto_init(hpi_handle_t handle, pfc_auto_init_t *autoinitp)
{
uint64_t offset;
offset = PFC_AUTO_INIT;
REG_PIO_READ64(handle, offset, &autoinitp->value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_tcp_control_discard(hpi_handle_t handle, boolean_t discard)
{
uint64_t offset;
tcp_ctrl_mask_t tcp;
tcp.value = 0;
offset = TCP_CTRL_MASK;
REG_PIO_READ64(handle, offset, &tcp.value);
if (discard)
tcp.bits.discard = 1;
else
tcp.bits.discard = 0;
REG_PIO_WRITE64(handle, offset, tcp.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_tcp_control_fin(hpi_handle_t handle, boolean_t fin)
{
uint64_t offset;
tcp_ctrl_mask_t tcp;
tcp.value = 0;
offset = TCP_CTRL_MASK;
REG_PIO_READ64(handle, offset, &tcp.value);
if (fin)
tcp.bits.fin = 1;
else
tcp.bits.fin = 0;
REG_PIO_WRITE64(handle, offset, tcp.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_tcp_control_syn(hpi_handle_t handle, boolean_t syn)
{
uint64_t offset;
tcp_ctrl_mask_t tcp;
tcp.value = 0;
offset = TCP_CTRL_MASK;
REG_PIO_READ64(handle, offset, &tcp.value);
if (syn)
tcp.bits.syn = 1;
else
tcp.bits.syn = 0;
REG_PIO_WRITE64(handle, offset, tcp.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_tcp_control_rst(hpi_handle_t handle, boolean_t rst)
{
uint64_t offset;
tcp_ctrl_mask_t tcp;
tcp.value = 0;
offset = TCP_CTRL_MASK;
REG_PIO_READ64(handle, offset, &tcp.value);
if (rst)
tcp.bits.rst = 1;
else
tcp.bits.rst = 0;
REG_PIO_WRITE64(handle, offset, tcp.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_tcp_control_psh(hpi_handle_t handle, boolean_t push)
{
uint64_t offset;
tcp_ctrl_mask_t tcp;
tcp.value = 0;
offset = TCP_CTRL_MASK;
REG_PIO_READ64(handle, offset, &tcp.value);
if (push)
tcp.bits.psh = 1;
else
tcp.bits.psh = 0;
REG_PIO_WRITE64(handle, offset, tcp.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_tcp_control_ack(hpi_handle_t handle, boolean_t ack)
{
uint64_t offset;
tcp_ctrl_mask_t tcp;
tcp.value = 0;
offset = TCP_CTRL_MASK;
REG_PIO_READ64(handle, offset, &tcp.value);
if (ack)
tcp.bits.ack = 1;
else
tcp.bits.ack = 0;
REG_PIO_WRITE64(handle, offset, tcp.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_hash_seed_value(hpi_handle_t handle, uint32_t seed)
{
uint64_t offset;
src_hash_val_t src_hash_seed;
src_hash_seed.value = 0;
src_hash_seed.bits.seed = seed;
offset = SRC_HASH_VAL;
REG_PIO_WRITE64(handle, offset, src_hash_seed.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_get_interrupt_status(hpi_handle_t handle, pfc_int_status_t *statusp)
{
uint64_t offset;
offset = PFC_INT_STATUS;
REG_PIO_READ64(handle, offset, &statusp->value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_clear_interrupt_status(hpi_handle_t handle)
{
uint64_t offset;
offset = PFC_INT_STATUS;
REG_PIO_WRITE64(handle, offset, HXGE_PFC_INT_STATUS_CLEAR);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_interrupt_mask(hpi_handle_t handle, boolean_t drop,
boolean_t tcam_parity_error, boolean_t vlan_parity_error)
{
pfc_int_mask_t mask;
uint64_t offset;
mask.value = 0;
if (drop)
mask.bits.pkt_drop_mask = 1;
else
mask.bits.pkt_drop_mask = 0;
if (tcam_parity_error)
mask.bits.tcam_parity_err_mask = 1;
else
mask.bits.tcam_parity_err_mask = 0;
if (vlan_parity_error)
mask.bits.vlan_parity_err_mask = 1;
else
mask.bits.vlan_parity_err_mask = 0;
offset = PFC_INT_MASK;
REG_PIO_WRITE64(handle, offset, mask.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_get_drop_log(hpi_handle_t handle, pfc_drop_log_t *logp)
{
uint64_t offset;
offset = PFC_DROP_LOG;
REG_PIO_READ64(handle, offset, &logp->value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_set_drop_log_mask(hpi_handle_t handle, boolean_t vlan_drop,
boolean_t tcam_drop, boolean_t class_code_drop, boolean_t l2_addr_drop,
boolean_t tcp_ctrl_drop)
{
uint64_t offset;
pfc_drop_log_mask_t log;
log.value = 0;
if (vlan_drop)
log.bits.vlan_drop_mask = 1;
if (tcam_drop)
log.bits.tcam_drop_mask = 1;
if (class_code_drop)
log.bits.class_code_drop_mask = 1;
if (l2_addr_drop)
log.bits.l2_addr_drop_mask = 1;
if (tcp_ctrl_drop)
log.bits.tcp_ctrl_drop_mask = 1;
offset = PFC_DROP_LOG_MASK;
REG_PIO_WRITE64(handle, offset, log.value);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_get_bad_csum_counter(hpi_handle_t handle, uint64_t *countp)
{
uint64_t offset;
offset = PFC_BAD_CS_COUNTER;
REG_PIO_READ64(handle, offset, countp);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_get_drop_counter(hpi_handle_t handle, uint64_t *countp)
{
uint64_t offset;
offset = PFC_DROP_COUNTER;
REG_PIO_READ64(handle, offset, countp);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_get_number_mac_addrs(hpi_handle_t handle, uint32_t *n_of_addrs)
{
HXGE_REG_RD32(handle, HCR_REG + HCR_N_MAC_ADDRS, n_of_addrs);
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_mac_addr_get_i(hpi_handle_t handle, uint8_t *data, int slot)
{
uint32_t step = sizeof (uint32_t);
uint32_t addr_hi = 0, addr_lo = 0;
if (slot >= PFC_N_MAC_ADDRESSES)
return (HPI_FAILURE);
/*
* Read the MAC address out of the SPROM at the blade's
* specific location.
*/
HXGE_REG_RD32(handle, HCR_REG + HCR_ADDR_LO + slot * step, &addr_lo);
HXGE_REG_RD32(handle, HCR_REG + HCR_ADDR_HI + slot * step, &addr_hi);
data[0] = addr_lo & 0x000000ff;
data[1] = (addr_lo & 0x0000ff00) >> 8;
data[2] = (addr_lo & 0x00ff0000) >> 16;
data[3] = (addr_lo & 0xff000000) >> 24;
data[4] = (addr_hi & 0x0000000ff);
data[5] = (addr_hi & 0x00000ff00) >> 8;
return (HPI_SUCCESS);
}
hpi_status_t
hpi_pfc_num_macs_get(hpi_handle_t handle, uint8_t *data)
{
uint8_t addr[6];
uint8_t num = 0;
int i;
for (i = 0; i < 16; i++) {
(void) hpi_pfc_mac_addr_get_i(handle, addr, i);
if (addr[0] || addr[1] || addr[2] ||
addr[3] || addr[4] || addr[5])
num++;
}
*data = num;
return (HPI_SUCCESS);
}
|