xref: /illumos-gate/usr/src/uts/common/io/nxge/npi/npi_fflp.h (revision b1d7ec75953cd517f5b7c3d9cb427ff8ec5d7d07)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _NPI_FFLP_H
27 #define	_NPI_FFLP_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 
34 #include <npi.h>
35 #include <nxge_hw.h>
36 #include <nxge_fflp_hw.h>
37 #include <nxge_fflp.h>
38 
39 
40 typedef uint8_t part_id_t;
41 typedef uint8_t tcam_location_t;
42 typedef uint16_t vlan_id_t;
43 
44 typedef	enum _tcam_op {
45 	TCAM_RWC_STAT	= 0x1,
46 	TCAM_RWC_MATCH	= 0x2
47 } tcam_op_t;
48 
49 
50 #define	NPI_TCAM_COMP_NO_MATCH	0x8000000000000ULL
51 
52 /*
53  * NPI FFLP ERROR Codes
54  */
55 
56 #define	NPI_FFLP_BLK_CODE	FFLP_BLK_ID << 8
57 #define	NPI_FFLP_ERROR		(NPI_FAILURE | NPI_FFLP_BLK_CODE)
58 #define	NPI_TCAM_ERROR		0x10
59 #define	NPI_FCRAM_ERROR		0x20
60 #define	NPI_GEN_FFLP		0x30
61 #define	NPI_FFLP_SW_PARAM_ERROR	0x40
62 #define	NPI_FFLP_HW_ERROR	0x80
63 
64 
65 #define	NPI_FFLP_RESET_ERROR	(NPI_FFLP_ERROR | NPI_GEN_FFLP | RESET_FAILED)
66 #define	NPI_FFLP_RDC_TABLE_INVALID	(NPI_FFLP_ERROR | RDC_TAB_INVALID)
67 #define	NPI_FFLP_VLAN_INVALID		(NPI_FFLP_ERROR | VLAN_INVALID)
68 #define	NPI_FFLP_PORT_INVALID		(NPI_FFLP_ERROR | PORT_INVALID)
69 #define	NPI_FFLP_TCAM_RD_ERROR		\
70 	(NPI_FFLP_ERROR | NPI_TCAM_ERROR | READ_FAILED)
71 #define	NPI_FFLP_TCAM_WR_ERROR		\
72 	(NPI_FFLP_ERROR | NPI_TCAM_ERROR | WRITE_FAILED)
73 #define	NPI_FFLP_TCAM_LOC_INVALID	\
74 	(NPI_FFLP_ERROR | NPI_TCAM_ERROR | LOCATION_INVALID)
75 #define	NPI_FFLP_ASC_RAM_RD_ERROR	\
76 	(NPI_FFLP_ERROR | NPI_TCAM_ERROR | READ_FAILED)
77 #define	NPI_FFLP_ASC_RAM_WR_ERROR	\
78 	(NPI_FFLP_ERROR | NPI_TCAM_ERROR | WRITE_FAILED)
79 #define	NPI_FFLP_FCRAM_READ_ERROR	\
80 	(NPI_FFLP_ERROR | NPI_FCRAM_ERROR | READ_FAILED)
81 #define	NPI_FFLP_FCRAM_WR_ERROR		\
82 	(NPI_FFLP_ERROR | NPI_FCRAM_ERROR | WRITE_FAILED)
83 #define	NPI_FFLP_FCRAM_PART_INVALID	\
84 	(NPI_FFLP_ERROR | NPI_FCRAM_ERROR | RDC_TAB_INVALID)
85 #define	NPI_FFLP_FCRAM_LOC_INVALID	\
86 	(NPI_FFLP_ERROR | NPI_FCRAM_ERROR | LOCATION_INVALID)
87 
88 #define	TCAM_CLASS_INVALID		\
89 	(NPI_FFLP_SW_PARAM_ERROR | 0xb)
90 /* have only 0xc, 0xd, 0xe and 0xf left for sw error codes */
91 #define	NPI_FFLP_TCAM_CLASS_INVALID	\
92 	(NPI_FFLP_ERROR | NPI_TCAM_ERROR | TCAM_CLASS_INVALID)
93 #define	NPI_FFLP_TCAM_HW_ERROR		\
94 	(NPI_FFLP_ERROR | NPI_FFLP_HW_ERROR | NPI_TCAM_ERROR)
95 #define	NPI_FFLP_FCRAM_HW_ERROR		\
96 	(NPI_FFLP_ERROR | NPI_FFLP_HW_ERROR | NPI_FCRAM_ERROR)
97 
98 
99 /*
100  * FFLP NPI defined event masks (mapped to the hardware defined masks).
101  */
102 typedef	enum _fflp_event_mask_cfg_e {
103 	CFG_FFLP_ENT_MSK_VLAN_MASK = FFLP_ERR_VLAN_MASK,
104 	CFG_FFLP_ENT_MSK_TCAM_MASK = FFLP_ERR_TCAM_MASK,
105 	CFG_FFLP_ENT_MSK_HASH_TBL_LKUP_MASK = FFLP_ERR_HASH_TBL_LKUP_MASK,
106 	CFG_FFLP_ENT_MSK_HASH_TBL_DAT_MASK = FFLP_ERR_HASH_TBL_DAT_MASK,
107 
108 	CFG_FFLP_MASK_ALL	= (FFLP_ERR_VLAN_MASK | FFLP_ERR_TCAM_MASK |
109 						FFLP_ERR_HASH_TBL_LKUP_MASK |
110 						FFLP_ERR_HASH_TBL_DAT_MASK)
111 } fflp_event_mask_cfg_t;
112 
113 
114 /* FFLP FCRAM Related Functions */
115 /* The following are FCRAM datapath functions */
116 
117 /*
118  * npi_fflp_fcram_entry_write ()
119  * Populates an FCRAM entry
120  * Inputs:
121  *         handle:	opaque handle interpreted by the underlying OS
122  *	   partid:	Partition ID
123  *	   location:	Index to the FCRAM.
124  *			Corresponds to last 20 bits of H1 value
125  *	   fcram_ptr:	Pointer to the FCRAM contents to be used for writing
126  *	   format:	Entry Format. Determines the size of the write.
127  *			      FCRAM_ENTRY_OPTIM:   8 bytes (a 64 bit write)
128  *			      FCRAM_ENTRY_EX_IP4:  32 bytes (4 X 64 bit write)
129  *			      FCRAM_ENTRY_EX_IP6:  56 bytes (7 X 64 bit write)
130  *
131  * Return:
132  * NPI_SUCCESS
133  * NPI_FAILURE
134  * NPI_HW_ERR
135  * NPI_SW_ERR
136  *
137  */
138 
139 npi_status_t npi_fflp_fcram_entry_write(npi_handle_t, part_id_t,
140 			    uint32_t, fcram_entry_t *,
141 			    fcram_entry_format_t);
142 
143 /*
144  * npi_fflp_fcram_entry_read ()
145  * Reads an FCRAM entry
146  * Inputs:
147  *         handle:	opaque handle interpreted by the underlying OS
148  *	   partid:	Partition ID
149  *	   location:	Index to the FCRAM.
150  *			Corresponds to last 20 bits of H1 value
151  *	   fcram_ptr:	Pointer to the FCRAM contents to be updated
152  *	   format:	Entry Format. Determines the size of the read.
153  *			      FCRAM_ENTRY_OPTIM:   8 bytes (a 64 bit read)
154  *			      FCRAM_ENTRY_EX_IP4:  32 bytes (4 X 64 bit read )
155  *			      FCRAM_ENTRY_EX_IP6:  56 bytes (7 X 64 bit read )
156  *
157  * Return:
158  * NPI_SUCCESS
159  * NPI_FAILURE
160  * NPI_HW_ERR
161  * NPI_SW_ERR
162  */
163 
164 npi_status_t npi_fflp_fcram_entry_read(npi_handle_t,  part_id_t,
165 				    uint32_t, fcram_entry_t *,
166 				    fcram_entry_format_t);
167 
168 /*
169  * npi_fflp_fcram_entry_invalidate ()
170  * Invalidate FCRAM entry at the given location
171  * Inputs:
172  *	handle:		opaque handle interpreted by the underlying OS
173  *	partid:		Partition ID
174  *	location:	location of the FCRAM/hash entry.
175  *
176  * Return:
177  * NPI_SUCCESS
178  * NPI_FAILURE
179  * NPI_HW_ERR
180  * NPI_SW_ERR
181  *
182  */
183 
184 npi_status_t
185 npi_fflp_fcram_entry_invalidate(npi_handle_t, part_id_t,
186 				    uint32_t);
187 
188 /*
189  * npi_fflp_fcram_subarea_write ()
190  * Writes to FCRAM entry subarea i.e the 8 bytes within the 64 bytes pointed by
191  * last 20 bits of  H1. Effectively, this accesses specific 8 bytes within the
192  * hash table bucket.
193  *
194  *    |-----------------| <-- H1
195  *	   |	subarea 0    |
196  *	   |_________________|
197  *	   | Subarea 1	     |
198  *	   |_________________|
199  *	   | .......	     |
200  *	   |_________________|
201  *	   | Subarea 7       |
202  *	   |_________________|
203  *
204  * Inputs:
205  *         handle:	opaque handle interpreted by the underlying OS
206  *	   partid:	Partition ID
207  *	   location:	location of the subarea. It is derived from:
208  *			Bucket = [19:15][14:0]       (20 bits of H1)
209  *			location = (Bucket << 3 ) + subarea * 8
210  *				 = [22:18][17:3] || subarea * 8
211  *	   data:	Data
212  * Return:
213  * NPI_SUCCESS
214  * NPI_FAILURE
215  * NPI_HW_ERR
216  * NPI_SW_ERR
217  *
218  */
219 
220 
221 npi_status_t npi_fflp_fcram_subarea_write(npi_handle_t, part_id_t,
222 				    uint32_t, uint64_t);
223 /*
224  * npi_fflp_fcram_subarea_read ()
225  * Reads an FCRAM entry subarea i.e the 8 bytes within the 64 bytes pointed by
226  * last 20 bits of  H1. Effectively, this accesses specific 8 bytes within the
227  * hash table bucket.
228  *
229  *  H1-->  |-----------------|
230  *	   |	subarea 0    |
231  *	   |_________________|
232  *	   | Subarea 1	     |
233  *	   |_________________|
234  *	   | .......	     |
235  *	   |_________________|
236  *	   | Subarea 7       |
237  *	   |_________________|
238  *
239  * Inputs:
240  *         handle:	opaque handle interpreted by the underlying OS
241  *	   partid:	Partition ID
242  *	   location:	location of the subarea. It is derived from:
243  *			Bucket = [19:15][14:0]       (20 bits of H1)
244  *			location = (Bucket << 3 ) + subarea * 8
245  *				 = [22:18][17:3] || subarea * 8
246  *	   data:	ptr do write subarea contents to.
247  *
248  * Return:
249  * NPI_SUCCESS
250  * NPI_FAILURE
251  * NPI_HW_ERR
252  * NPI_SW_ERR
253  *
254  */
255 
256 npi_status_t npi_fflp_fcram_subarea_read  (npi_handle_t,
257 			part_id_t, uint32_t, uint64_t *);
258 
259 
260 /* The following are zero function fflp configuration functions */
261 /*
262  * npi_fflp_fcram_config_partition()
263  * Partitions and configures the FCRAM
264  *
265  * Input
266  *     partid			partition ID
267  *				Corresponds to the RDC table
268  *     part_size		Size of the partition
269  *
270  * Return:
271  * NPI_SUCCESS
272  * NPI_FAILURE
273  * NPI_HW_ERR
274  * NPI_SW_ERR
275  *
276  */
277 npi_status_t npi_fflp_cfg_fcram_partition(npi_handle_t, part_id_t,
278 				uint8_t, uint8_t);
279 
280 /*
281  * npi_fflp_fcram_partition_enable
282  * Enable previously configured FCRAM partition
283  *
284  * Input
285  *     partid			partition ID
286  *				Corresponds to the RDC table
287  *
288  * Return
289  *      0			Successful
290  *      Non zero  error code    Enable failed, and reason.
291  *
292  */
293 npi_status_t npi_fflp_cfg_fcram_partition_enable(npi_handle_t,
294 				part_id_t);
295 
296 /*
297  * npi_fflp_fcram_partition_disable
298  * Disable previously configured FCRAM partition
299  *
300  * Input
301  *     partid			partition ID
302  *				Corresponds to the RDC table
303  *
304  * Return:
305  * NPI_SUCCESS
306  * NPI_FAILURE
307  * NPI_HW_ERR
308  * NPI_SW_ERR
309  *
310  */
311 
312 npi_status_t npi_fflp_cfg_fcram_partition_disable(npi_handle_t,
313 				part_id_t);
314 
315 
316 /*
317  *  npi_fflp_cfg_fcram_reset
318  *  Initializes the FCRAM reset sequence (including FFLP).
319  *
320  *  Input
321  *	strength:		FCRAM Drive strength
322  *				   strong, weak or normal
323  *				   HW recommended value:
324  *	qs:			FCRAM QS mode selection
325  *				   qs mode or free running
326  *				   HW recommended value is:
327  *
328  * Return:
329  * NPI_SUCCESS
330  * NPI_FAILURE
331  * NPI_HW_ERR
332  * NPI_SW_ERR
333  *
334  */
335 
336 npi_status_t npi_fflp_cfg_fcram_reset(npi_handle_t,
337 				    fflp_fcram_output_drive_t,
338 				    fflp_fcram_qs_t);
339 
340 
341 
342 /*
343  *  npi_fflp_cfg_tcam_reset
344  *  Initializes the FFLP reset sequence
345  * Doesn't configure the FCRAM params.
346  *
347  *  Input
348  *
349  * Return:
350  * NPI_SUCCESS
351  * NPI_FAILURE
352  * NPI_HW_ERR
353  * NPI_SW_ERR
354  *
355  */
356 
357 npi_status_t npi_fflp_cfg_tcam_reset(npi_handle_t);
358 
359 /*
360  *  npi_fflp_cfg_tcam_enable
361  *  Enables the TCAM function
362  *
363  *  Input
364  *
365  * Return:
366  * NPI_SUCCESS
367  * NPI_FAILURE
368  * NPI_HW_ERR
369  * NPI_SW_ERR
370  *
371  */
372 
373 npi_status_t npi_fflp_cfg_tcam_enable(npi_handle_t);
374 
375 /*
376  *  npi_fflp_cfg_tcam_disable
377  *  Enables the TCAM function
378  *
379  *  Input
380  *
381  * Return:
382  * NPI_SUCCESS
383  * NPI_FAILURE
384  * NPI_HW_ERR
385  * NPI_SW_ERR
386  *
387  */
388 
389 npi_status_t npi_fflp_cfg_tcam_disable(npi_handle_t);
390 
391 
392 /*
393  *  npi_fflp_cfg_cam_errorcheck_disable
394  *  Disables FCRAM and TCAM error checking
395  *
396  *  Input
397  *
398  *
399  * Return:
400  * NPI_SUCCESS
401  * NPI_FAILURE
402  * NPI_HW_ERR
403  * NPI_SW_ERR
404  *
405  */
406 
407 npi_status_t npi_fflp_cfg_cam_errorcheck_disable(npi_handle_t);
408 
409 /*
410  *  npi_fflp_cfg_cam_errorcheck_enable
411  *  Enables FCRAM and TCAM error checking
412  *
413  *  Input
414  *
415  *
416  *  Return
417  *      0			Successful
418  *      Non zero  error code    Enable failed, and reason.
419  *
420  */
421 npi_status_t npi_fflp_cfg_cam_errorcheck_enable(npi_handle_t);
422 
423 
424 /*
425  *  npi_fflp_cfg_llcsnap_enable
426  *  Enables input parser llcsnap recognition
427  *
428  *  Input
429  *
430  *
431  * Return:
432  * NPI_SUCCESS
433  * NPI_FAILURE
434  * NPI_HW_ERR
435  * NPI_SW_ERR
436  *
437  *
438  */
439 npi_status_t npi_fflp_cfg_llcsnap_enable(npi_handle_t);
440 
441 /*
442  *  npi_fflp_cam_llcsnap_disable
443  *  Disables input parser llcsnap recognition
444  *
445  *  Input
446  *
447  *
448  * Return:
449  * NPI_SUCCESS
450  * NPI_FAILURE
451  * NPI_HW_ERR
452  * NPI_SW_ERR
453  *
454  *
455  */
456 
457 npi_status_t npi_fflp_cfg_llcsnap_disable(npi_handle_t);
458 
459 /*
460  * npi_fflp_config_fcram_refresh
461  * Set FCRAM min and max refresh time.
462  *
463  * Input
464  *	min_time		Minimum Refresh time count
465  *	max_time		maximum Refresh Time count
466  *	sys_time		System Clock rate
467  *
468  *	The counters are 16 bit counters. The maximum refresh time is
469  *      3.9us/clock cycle. The minimum is 400ns/clock cycle.
470  *	Clock cycle is the FCRAM clock cycle?????
471  *	If the cycle is FCRAM clock cycle, then sys_time parameter
472  *      is not needed as there wont be configuration variation due to
473  *      system clock cycle.
474  *
475  * Return:
476  * NPI_SUCCESS
477  * NPI_FAILURE
478  * NPI_HW_ERR
479  * NPI_SW_ERR
480  *
481  */
482 
483 npi_status_t npi_fflp_cfg_fcram_refresh_time(npi_handle_t,
484 		uint32_t, uint32_t, uint32_t);
485 
486 
487 /*
488  * npi_fflp_cfg_fcram_access ()
489  *
490  * Sets the ratio between the FCRAM pio and lookup access
491  * Input:
492  * access_ratio: 0  Lookup has the highest priority
493  *		 15 PIO has maximum possible priority
494  *
495  */
496 
497 npi_status_t npi_fflp_cfg_fcram_access(npi_handle_t,
498 					uint8_t);
499 
500 
501 /*
502  * npi_fflp_cfg_tcam_access ()
503  *
504  * Sets the ratio between the TCAM pio and lookup access
505  * Input:
506  * access_ratio: 0  Lookup has the highest priority
507  *		 15 PIO has maximum possible priority
508  *
509  */
510 
511 npi_status_t npi_fflp_cfg_tcam_access(npi_handle_t, uint8_t);
512 
513 
514 /*
515  *  npi_fflp_hash_lookup_err_report
516  *  Reports hash table (fcram) lookup errors
517  *
518  *  Input
519  *      status			Pointer to return Error bits
520  *
521  *
522  * Return:
523  * NPI_SUCCESS
524  * NPI_FAILURE
525  * NPI_HW_ERR
526  * NPI_SW_ERR
527  *
528  */
529 
530 npi_status_t npi_fflp_fcram_get_lookup_err_log(npi_handle_t,
531 				    hash_lookup_err_log_t *);
532 
533 
534 
535 /*
536  * npi_fflp_fcram_get_pio_err_log
537  * Reports hash table PIO read errors.
538  *
539  * Input
540  *	partid:		partition ID
541  *      err_stat	pointer to return Error bits
542  *
543  * Return:
544  * NPI_SUCCESS
545  * NPI_FAILURE
546  * NPI_HW_ERR
547  * NPI_SW_ERR
548  *
549  */
550 npi_status_t npi_fflp_fcram_get_pio_err_log(npi_handle_t,
551 				part_id_t, hash_pio_err_log_t *);
552 
553 
554 /*
555  * npi_fflp_fcram_clr_pio_err_log
556  * Clears FCRAM PIO  error status for the partition.
557  * If there are TCAM errors as indicated by err bit set by HW,
558  *  then the SW will clear it by clearing the bit.
559  *
560  * Input
561  *	partid:		partition ID
562  *
563  *
564  * Return
565  *	NPI_SUCCESS	Success
566  *
567  *
568  */
569 
570 npi_status_t npi_fflp_fcram_clr_pio_err_log(npi_handle_t,
571 						part_id_t);
572 
573 
574 
575 /*
576  * npi_fflp_fcram_err_data_test
577  * Tests the FCRAM error detection logic.
578  * The error detection logic for the datapath is tested.
579  * bits [63:0] are set to select the data bits to be xored
580  *
581  * Input
582  *	data:	 data bits to select bits to be xored
583  *
584  *
585  * Return
586  *	NPI_SUCCESS	Success
587  *
588  *
589  */
590 npi_status_t npi_fflp_fcram_err_data_test(npi_handle_t, fcram_err_data_t *);
591 
592 
593 /*
594  * npi_fflp_fcram_err_synd_test
595  * Tests the FCRAM error detection logic.
596  * The error detection logic for the syndrome is tested.
597  * tst0->synd (8bits) are set to select the syndrome bits
598  * to be XOR'ed
599  *
600  * Input
601  *	syndrome_bits:	 Syndrome bits to select bits to be xor'ed
602  *
603  *
604  * Return
605  *	NPI_SUCCESS	Success
606  *
607  *
608  */
609 npi_status_t npi_fflp_fcram_err_synd_test(npi_handle_t, uint8_t);
610 
611 
612 /*
613  * npi_fflp_cfg_vlan_table_clear
614  * Clears the vlan RDC table
615  *
616  * Input
617  *     vlan_id		VLAN ID
618  *
619  * Output
620  *
621  *	NPI_SUCCESS			Successful
622  *
623  */
624 
625 npi_status_t npi_fflp_cfg_vlan_table_clear(npi_handle_t, vlan_id_t);
626 
627 /*
628  * npi_fflp_cfg_enet_vlan_table_assoc
629  * associates port vlan id to rdc table and sets the priority
630  * in respect to L2DA rdc table.
631  *
632  * Input
633  *     mac_portn		port number
634  *     vlan_id			VLAN ID
635  *     rdc_table		RDC Table #
636  *     priority			priority
637  *				1: vlan classification has higher priority
638  *				0: l2da classification has higher priority
639  *
640  * Return:
641  * NPI_SUCCESS
642  * NPI_FAILURE
643  * NPI_HW_ERR
644  * NPI_SW_ERR
645  *
646  */
647 
648 npi_status_t npi_fflp_cfg_enet_vlan_table_assoc(npi_handle_t,
649 				    uint8_t, vlan_id_t,
650 				    uint8_t, uint8_t);
651 
652 
653 /*
654  * npi_fflp_cfg_enet_vlan_table_set_pri
655  * sets the  vlan based classification priority in respect to
656  * L2DA classification.
657  *
658  * Input
659  *     mac_portn	port number
660  *     vlan_id		VLAN ID
661  *     priority 	priority
662  *			1: vlan classification has higher priority
663  *			0: l2da classification has higher priority
664  *
665  * Return:
666  * NPI_SUCCESS
667  * NPI_FAILURE
668  * NPI_HW_ERR
669  * NPI_SW_ERR
670  *
671  */
672 
673 npi_status_t npi_fflp_cfg_enet_vlan_table_set_pri(npi_handle_t,
674 				    uint8_t, vlan_id_t,
675 				    uint8_t);
676 
677 /*
678  * npi_fflp_cfg_enet_usr_cls_set()
679  * Configures a user configurable ethernet class
680  *
681  * Input
682  *      class:       Ethernet Class
683  *		     class (TCAM_CLASS_ETYPE or  TCAM_CLASS_ETYPE_2)
684  *      enet_type:   16 bit Ethernet Type value, corresponding ethernet bytes
685  *                        [13:14] in the frame.
686  *
687  *  by default, the class will be disabled until explicitly enabled.
688  *
689  * Return
690  * NPI_SUCCESS
691  * NPI_FAILURE
692  * NPI_HW_ERR
693  * NPI_SW_ERR
694  *
695  *
696  *
697  */
698 
699 npi_status_t npi_fflp_cfg_enet_usr_cls_set(npi_handle_t,
700 				    tcam_class_t, uint16_t);
701 
702 /*
703  * npi_fflp_cfg_enet_usr_cls_enable()
704  * Enable previously configured TCAM user configurable Ethernet classes.
705  *
706  * Input
707  *      class:       Ethernet Class  class
708  *		     (TCAM_CLASS_ETYPE or  TCAM_CLASS_ETYPE_2)
709  *
710  * Return
711  * NPI_SUCCESS
712  * NPI_FAILURE
713  * NPI_HW_ERR
714  * NPI_SW_ERR
715  *
716  */
717 
718 npi_status_t npi_fflp_cfg_enet_usr_cls_enable(npi_handle_t, tcam_class_t);
719 
720 /*
721  * npi_fflp_cfg_enet_usr_cls_disable()
722  * Disables previously configured TCAM user configurable Ethernet classes.
723  *
724  * Input
725  *      class:       Ethernet Class
726  *		     class = (TCAM_CLASS_ETYPE or  TCAM_CLASS_ETYPE_2)
727  *
728  * Return
729  * NPI_SUCCESS
730  * NPI_FAILURE
731  * NPI_HW_ERR
732  * NPI_SW_ERR
733  *
734  */
735 
736 
737 npi_status_t npi_fflp_cfg_enet_usr_cls_disable(npi_handle_t, tcam_class_t);
738 
739 
740 /*
741  * npi_fflp_cfg_ip_usr_cls_set()
742  * Configures the TCAM user configurable IP classes.
743  *
744  * Input
745  *      class:       IP Class
746  *		     (TCAM_CLASS_IP_USER_4 <= class <= TCAM_CLASS_IP_USER_7)
747  *      tos:         IP TOS bits
748  *      tos_mask:    IP TOS bits mask. bits with mask bits set will be used
749  *      proto:       IP Proto
750  *      ver:         IP Version
751  * by default, will the class is disabled until explicitly enabled
752  *
753  * Return
754  * NPI_SUCCESS
755  * NPI_FAILURE
756  * NPI_HW_ERR
757  * NPI_SW_ERR
758  *
759  */
760 
761 npi_status_t npi_fflp_cfg_ip_usr_cls_set(npi_handle_t,
762 					tcam_class_t,
763 					uint8_t, uint8_t,
764 					uint8_t, uint8_t);
765 
766 npi_status_t npi_fflp_cfg_ip_usr_cls_set_iptun(npi_handle_t,
767 		tcam_class_t, uint8_t, uint8_t, uint16_t, uint8_t);
768 
769 npi_status_t npi_fflp_cfg_ip_usr_cls_get_iptun(npi_handle_t,
770 		tcam_class_t, uint8_t *, uint8_t *, uint16_t *, uint8_t *);
771 
772 /*
773  * npi_fflp_cfg_ip_usr_cls_enable()
774  * Enable previously configured TCAM user configurable IP classes.
775  *
776  * Input
777  *      class:       IP Class
778  *		     (TCAM_CLASS_IP_USER_4 <= class <= TCAM_CLASS_IP_USER_7)
779  *
780  * Return
781  * NPI_SUCCESS
782  * NPI_FAILURE
783  * NPI_HW_ERR
784  * NPI_SW_ERR
785  *
786  */
787 
788 npi_status_t npi_fflp_cfg_ip_usr_cls_enable(npi_handle_t, tcam_class_t);
789 
790 /*
791  * npi_fflp_cfg_ip_usr_cls_disable()
792  * Disables previously configured TCAM user configurable IP classes.
793  *
794  * Input
795  *      class:       IP Class
796  *		     (TCAM_CLASS_IP_USER_4 <= class <= TCAM_CLASS_IP_USER_7)
797  *
798  * Return
799  * NPI_SUCCESS
800  * NPI_FAILURE
801  * NPI_HW_ERR
802  * NPI_SW_ERR
803  *
804  */
805 
806 
807 npi_status_t npi_fflp_cfg_ip_usr_cls_disable(npi_handle_t, tcam_class_t);
808 
809 
810 /*
811  * npi_fflp_cfg_ip_cls_tcam_key ()
812  *
813  * Configures the TCAM key generation for the IP classes
814  *
815  * Input
816  *      l3_class:        IP class to configure key generation
817  *      cfg:             Configuration bits:
818  *                   discard:      Discard all frames of this class
819  *                   use_ip_saddr: use ip src address (for ipv6)
820  *                   use_ip_daddr: use ip dest address (for ipv6)
821  *                   lookup_enable: Enable Lookup
822  *
823  *
824  * Return
825  * NPI_SUCCESS
826  * NPI_HW_ERR
827  * NPI_SW_ERR
828  *
829  */
830 
831 
832 npi_status_t npi_fflp_cfg_ip_cls_tcam_key(npi_handle_t,
833 				    tcam_class_t, tcam_key_cfg_t *);
834 
835 /*
836  * npi_fflp_cfg_ip_cls_flow_key ()
837  *
838  * Configures the flow key generation for the IP classes
839  * Flow key is used to generate the H1 hash function value
840  * The fields used for the generation are configured using this
841  * NPI function.
842  *
843  * Input
844  *      l3_class:        IP class to configure flow key generation
845  *      cfg:             Configuration bits:
846  *                   use_proto:     Use IP proto field
847  *                   use_dport:     use l4 destination port
848  *                   use_sport:     use l4 source port
849  *                   ip_opts_exist: IP Options Present
850  *                   use_daddr:     use ip dest address
851  *                   use_saddr:     use ip source address
852  *                   use_vlan:      use VLAN ID
853  *                   use_l2da:      use L2 Dest MAC Address
854  *                   use_portnum:   use L2 virtual port number
855  *
856  *
857  * Return
858  * NPI_SUCCESS
859  * NPI_HW_ERR
860  * NPI_SW_ERR
861  *
862  */
863 
864 npi_status_t npi_fflp_cfg_ip_cls_flow_key(npi_handle_t,
865 			    tcam_class_t, flow_key_cfg_t *);
866 
867 npi_status_t npi_fflp_cfg_ip_cls_flow_key_get(npi_handle_t,
868 				    tcam_class_t,
869 				    flow_key_cfg_t *);
870 
871 npi_status_t npi_fflp_cfg_ip_cls_flow_key_rfnl(npi_handle_t,
872 		tcam_class_t, flow_key_cfg_t *);
873 
874 npi_status_t npi_fflp_cfg_sym_ip_cls_flow_key(npi_handle_t, tcam_class_t,
875 					boolean_t);
876 
877 npi_status_t npi_fflp_cfg_ip_cls_flow_key_get_rfnl(npi_handle_t,
878 			tcam_class_t, flow_key_cfg_t *);
879 
880 npi_status_t npi_fflp_cfg_ip_cls_tcam_key_get(npi_handle_t,
881 			tcam_class_t, tcam_key_cfg_t *);
882 /*
883  * npi_fflp_cfg_hash_h1poly()
884  * Initializes the H1 hash generation logic.
885  *
886  * Input
887  *      init_value:       The initial value (seed)
888  *
889  * Return
890  * NPI_SUCCESS
891  * NPI_FAILURE
892  * NPI_HW_ERR
893  * NPI_SW_ERR
894  *
895  */
896 
897 npi_status_t npi_fflp_cfg_hash_h1poly(npi_handle_t, uint32_t);
898 
899 
900 
901 /*
902  * npi_fflp_cfg_hash_h2poly()
903  * Initializes the H2 hash generation logic.
904  *
905  * Input
906  *      init_value:       The initial value (seed)
907  *
908  * Return
909  * NPI_SUCCESS
910  * NPI_FAILURE
911  * NPI_HW_ERR
912  * NPI_SW_ERR
913  *
914  */
915 
916 npi_status_t npi_fflp_cfg_hash_h2poly(npi_handle_t, uint16_t);
917 
918 
919 /*
920  * Reset the fflp block (actually the FCRAM)
921  * Waits until reset is completed
922  *
923  * input
924  * strength	fcram output drive strength: weak, normal or strong
925  * qs		qs mode. Normal or free running
926  *
927  * return value
928  *	  NPI_SUCCESS
929  *	  NPI_SW_ERR
930  *	  NPI_HW_ERR
931  */
932 
933 npi_status_t npi_fflp_fcram_reset(npi_handle_t,
934 			    fflp_fcram_output_drive_t,
935 			    fflp_fcram_qs_t);
936 
937 
938 /* FFLP TCAM Related Functions */
939 
940 
941 /*
942  * npi_fflp_tcam_entry_match()
943  *
944  * Tests for TCAM match of the tcam entry
945  *
946  * Input
947  * tcam_ptr
948  *
949  * Return
950  *   NPI_SUCCESS
951  *   NPI_SW_ERR
952  *   NPI_HW_ERR
953  *
954  */
955 
956 int npi_fflp_tcam_entry_match(npi_handle_t, tcam_entry_t *);
957 
958 /*
959  * npi_fflp_tcam_entry_write()
960  *
961  * writes a tcam entry at the TCAM location, location
962  *
963  * Input
964  * location
965  * tcam_ptr
966  *
967  * Return
968  *   NPI_SUCCESS
969  *   NPI_SW_ERR
970  *   NPI_HW_ERR
971  *
972  */
973 
974 npi_status_t npi_fflp_tcam_entry_write(npi_handle_t,
975 				tcam_location_t,
976 				tcam_entry_t *);
977 
978 /*
979  * npi_fflp_tcam_entry_read ()
980  *
981  * Reads a tcam entry from the TCAM location, location
982  *
983  * Input:
984  * location
985  * tcam_ptr
986  *
987  * Return:
988  * NPI_SUCCESS
989  * NPI_HW_ERR
990  * NPI_SW_ERR
991  *
992  */
993 
994 
995 npi_status_t npi_fflp_tcam_entry_read(npi_handle_t,
996 					tcam_location_t,
997 					tcam_entry_t *);
998 
999 /*
1000  * npi_fflp_tcam_entry_invalidate()
1001  *
1002  * invalidates entry at tcam location
1003  *
1004  * Input
1005  * location
1006  *
1007  * Return
1008  *   NPI_SUCCESS
1009  *   NPI_SW_ERR
1010  *   NPI_HW_ERR
1011  *
1012  */
1013 
1014 npi_status_t npi_fflp_tcam_entry_invalidate(npi_handle_t,
1015 				    tcam_location_t);
1016 
1017 
1018 /*
1019  * npi_fflp_tcam_asc_ram_entry_write()
1020  *
1021  * writes a tcam associatedRAM at the TCAM location, location
1022  *
1023  * Input:
1024  * location	tcam associatedRAM location
1025  * ram_data	Value to write
1026  *
1027  * Return:
1028  * NPI_SUCCESS
1029  * NPI_HW_ERR
1030  * NPI_SW_ERR
1031  *
1032  */
1033 
1034 npi_status_t npi_fflp_tcam_asc_ram_entry_write(npi_handle_t,
1035 				    tcam_location_t,
1036 				    uint64_t);
1037 
1038 
1039 /*
1040  * npi_fflp_tcam_asc_ram_entry_read()
1041  *
1042  * reads a tcam associatedRAM content at the TCAM location, location
1043  *
1044  * Input:
1045  * location	tcam associatedRAM location
1046  * ram_data	ptr to return contents
1047  *
1048  * Return:
1049  * NPI_SUCCESS
1050  * NPI_HW_ERR
1051  * NPI_SW_ERR
1052  *
1053  */
1054 
1055 npi_status_t npi_fflp_tcam_asc_ram_entry_read(npi_handle_t,
1056 				    tcam_location_t,
1057 				    uint64_t *);
1058 
1059 /*
1060  * npi_fflp_tcam_get_err_log
1061  * Reports TCAM PIO read and lookup errors.
1062  * If there are TCAM errors as indicated by err bit set by HW,
1063  *  then the SW will clear it by clearing the bit.
1064  *
1065  * Input
1066  *	err_stat:	 structure to report various TCAM errors.
1067  *                       will be updated if there are TCAM errors.
1068  *
1069  *
1070  * Return
1071  *	NPI_SUCCESS	Success
1072  *
1073  *
1074  */
1075 npi_status_t npi_fflp_tcam_get_err_log(npi_handle_t, tcam_err_log_t *);
1076 
1077 
1078 
1079 /*
1080  * npi_fflp_tcam_clr_err_log
1081  * Clears TCAM PIO read and lookup error status.
1082  * If there are TCAM errors as indicated by err bit set by HW,
1083  *  then the SW will clear it by clearing the bit.
1084  *
1085  * Input
1086  *	err_stat:	 structure to report various TCAM errors.
1087  *                       will be updated if there are TCAM errors.
1088  *
1089  *
1090  * Return
1091  *	NPI_SUCCESS	Success
1092  *
1093  *
1094  */
1095 
1096 npi_status_t npi_fflp_tcam_clr_err_log(npi_handle_t);
1097 
1098 
1099 
1100 
1101 
1102 /*
1103  * npi_fflp_vlan_tbl_clr_err_log
1104  * Clears VLAN Table PIO  error status.
1105  * If there are VLAN Table errors as indicated by err bit set by HW,
1106  *  then the SW will clear it by clearing the bit.
1107  *
1108  * Input
1109  *	err_stat:	 structure to report various VLAN Table errors.
1110  *                       will be updated if there are  errors.
1111  *
1112  *
1113  * Return
1114  *	NPI_SUCCESS	Success
1115  *
1116  *
1117  */
1118 
1119 npi_status_t npi_fflp_vlan_tbl_clr_err_log(npi_handle_t);
1120 
1121 
1122 /*
1123  * npi_fflp_vlan_tbl_get_err_log
1124  * Reports VLAN Table  errors.
1125  * If there are VLAN Table errors as indicated by err bit set by HW,
1126  *  then the SW will clear it by clearing the bit.
1127  *
1128  * Input
1129  *	err_stat:	 structure to report various VLAN table errors.
1130  *                       will be updated if there are errors.
1131  *
1132  *
1133  * Return
1134  *	NPI_SUCCESS	Success
1135  *
1136  *
1137  */
1138 npi_status_t npi_fflp_vlan_tbl_get_err_log(npi_handle_t,
1139 				    vlan_tbl_err_log_t *);
1140 
1141 
1142 
1143 
1144 /*
1145  * npi_rxdma_event_mask_config():
1146  *	This function is called to operate on the event mask
1147  *	register which is used for generating interrupts
1148  *	and status register.
1149  *
1150  * Parameters:
1151  *	handle		- NPI handle
1152  *	op_mode		- OP_GET: get hardware event mask
1153  *			  OP_SET: set hardware interrupt event masks
1154  *	channel		- hardware RXDMA channel from 0 to 23.
1155  *	cfgp		- pointer to NPI defined event mask
1156  *			  enum data type.
1157  * Return:
1158  *	NPI_SUCCESS		- If set is complete successfully.
1159  *
1160  *	Error:
1161  *	NPI_FAILURE		-
1162  *	NPI_FFLP_ERROR | NPI_FFLP_SW_PARAM_ERROR
1163  *
1164  */
1165 npi_status_t
1166 npi_fflp_event_mask_config(npi_handle_t, io_op_t,
1167 			    fflp_event_mask_cfg_t *);
1168 
1169 npi_status_t npi_fflp_dump_regs(npi_handle_t);
1170 
1171 
1172 /* Error status read and clear functions */
1173 
1174 void	npi_fflp_vlan_error_get(npi_handle_t,
1175 				    p_vlan_par_err_t);
1176 void	npi_fflp_vlan_error_clear(npi_handle_t);
1177 void	npi_fflp_tcam_error_get(npi_handle_t,
1178 				    p_tcam_err_t);
1179 void	npi_fflp_tcam_error_clear(npi_handle_t);
1180 
1181 void	npi_fflp_fcram_error_get(npi_handle_t,
1182 				    p_hash_tbl_data_log_t,
1183 				    uint8_t);
1184 void npi_fflp_fcram_error_clear(npi_handle_t, uint8_t);
1185 
1186 void npi_fflp_fcram_error_log1_get(npi_handle_t,
1187 				    p_hash_lookup_err_log1_t);
1188 
1189 void npi_fflp_fcram_error_log2_get(npi_handle_t,
1190 			    p_hash_lookup_err_log2_t);
1191 
1192 void npi_fflp_vlan_tbl_dump(npi_handle_t);
1193 
1194 #ifdef	__cplusplus
1195 }
1196 #endif
1197 
1198 #endif	/* _NPI_FFLP_H */
1199