1818#include "cgx.h"
1919#include "lmac_common.h"
2020#include "npc.h"
21+ #include "rvu_npc_hash.h"
2122
2223#define DEBUGFS_DIR_NAME "octeontx2"
2324
@@ -2600,6 +2601,170 @@ static int rvu_dbg_npc_mcam_show_rules(struct seq_file *s, void *unused)
26002601
26012602RVU_DEBUG_SEQ_FOPS (npc_mcam_rules , npc_mcam_show_rules , NULL );
26022603
2604+ static int rvu_dbg_npc_exact_show_entries (struct seq_file * s , void * unused )
2605+ {
2606+ struct npc_exact_table_entry * mem_entry [NPC_EXACT_TBL_MAX_WAYS ] = { 0 };
2607+ struct npc_exact_table_entry * cam_entry ;
2608+ struct npc_exact_table * table ;
2609+ struct rvu * rvu = s -> private ;
2610+ int i , j ;
2611+
2612+ u8 bitmap = 0 ;
2613+
2614+ table = rvu -> hw -> table ;
2615+
2616+ mutex_lock (& table -> lock );
2617+
2618+ /* Check if there is at least one entry in mem table */
2619+ if (!table -> mem_tbl_entry_cnt )
2620+ goto dump_cam_table ;
2621+
2622+ /* Print table headers */
2623+ seq_puts (s , "\n\tExact Match MEM Table\n" );
2624+ seq_puts (s , "Index\t" );
2625+
2626+ for (i = 0 ; i < table -> mem_table .ways ; i ++ ) {
2627+ mem_entry [i ] = list_first_entry_or_null (& table -> lhead_mem_tbl_entry [i ],
2628+ struct npc_exact_table_entry , list );
2629+
2630+ seq_printf (s , "Way-%d\t\t\t\t\t" , i );
2631+ }
2632+
2633+ seq_puts (s , "\n" );
2634+ for (i = 0 ; i < table -> mem_table .ways ; i ++ )
2635+ seq_puts (s , "\tChan MAC \t" );
2636+
2637+ seq_puts (s , "\n\n" );
2638+
2639+ /* Print mem table entries */
2640+ for (i = 0 ; i < table -> mem_table .depth ; i ++ ) {
2641+ bitmap = 0 ;
2642+ for (j = 0 ; j < table -> mem_table .ways ; j ++ ) {
2643+ if (!mem_entry [j ])
2644+ continue ;
2645+
2646+ if (mem_entry [j ]-> index != i )
2647+ continue ;
2648+
2649+ bitmap |= BIT (j );
2650+ }
2651+
2652+ /* No valid entries */
2653+ if (!bitmap )
2654+ continue ;
2655+
2656+ seq_printf (s , "%d\t" , i );
2657+ for (j = 0 ; j < table -> mem_table .ways ; j ++ ) {
2658+ if (!(bitmap & BIT (j ))) {
2659+ seq_puts (s , "nil\t\t\t\t\t" );
2660+ continue ;
2661+ }
2662+
2663+ seq_printf (s , "0x%x %pM\t\t\t" , mem_entry [j ]-> chan ,
2664+ mem_entry [j ]-> mac );
2665+ mem_entry [j ] = list_next_entry (mem_entry [j ], list );
2666+ }
2667+ seq_puts (s , "\n" );
2668+ }
2669+
2670+ dump_cam_table :
2671+
2672+ if (!table -> cam_tbl_entry_cnt )
2673+ goto done ;
2674+
2675+ seq_puts (s , "\n\tExact Match CAM Table\n" );
2676+ seq_puts (s , "index\tchan\tMAC\n" );
2677+
2678+ /* Traverse cam table entries */
2679+ list_for_each_entry (cam_entry , & table -> lhead_cam_tbl_entry , list ) {
2680+ seq_printf (s , "%d\t0x%x\t%pM\n" , cam_entry -> index , cam_entry -> chan ,
2681+ cam_entry -> mac );
2682+ }
2683+
2684+ done :
2685+ mutex_unlock (& table -> lock );
2686+ return 0 ;
2687+ }
2688+
2689+ RVU_DEBUG_SEQ_FOPS (npc_exact_entries , npc_exact_show_entries , NULL );
2690+
2691+ static int rvu_dbg_npc_exact_show_info (struct seq_file * s , void * unused )
2692+ {
2693+ struct npc_exact_table * table ;
2694+ struct rvu * rvu = s -> private ;
2695+ int i ;
2696+
2697+ table = rvu -> hw -> table ;
2698+
2699+ seq_puts (s , "\n\tExact Table Info\n" );
2700+ seq_printf (s , "Exact Match Feature : %s\n" ,
2701+ rvu -> hw -> cap .npc_exact_match_enabled ? "enabled" : "disable" );
2702+ if (!rvu -> hw -> cap .npc_exact_match_enabled )
2703+ return 0 ;
2704+
2705+ seq_puts (s , "\nMCAM Index\tMAC Filter Rules Count\n" );
2706+ for (i = 0 ; i < table -> num_drop_rules ; i ++ )
2707+ seq_printf (s , "%d\t\t%d\n" , i , table -> cnt_cmd_rules [i ]);
2708+
2709+ seq_puts (s , "\nMcam Index\tPromisc Mode Status\n" );
2710+ for (i = 0 ; i < table -> num_drop_rules ; i ++ )
2711+ seq_printf (s , "%d\t\t%s\n" , i , table -> promisc_mode [i ] ? "on" : "off" );
2712+
2713+ seq_puts (s , "\n\tMEM Table Info\n" );
2714+ seq_printf (s , "Ways : %d\n" , table -> mem_table .ways );
2715+ seq_printf (s , "Depth : %d\n" , table -> mem_table .depth );
2716+ seq_printf (s , "Mask : 0x%llx\n" , table -> mem_table .mask );
2717+ seq_printf (s , "Hash Mask : 0x%x\n" , table -> mem_table .hash_mask );
2718+ seq_printf (s , "Hash Offset : 0x%x\n" , table -> mem_table .hash_offset );
2719+
2720+ seq_puts (s , "\n\tCAM Table Info\n" );
2721+ seq_printf (s , "Depth : %d\n" , table -> cam_table .depth );
2722+
2723+ return 0 ;
2724+ }
2725+
2726+ RVU_DEBUG_SEQ_FOPS (npc_exact_info , npc_exact_show_info , NULL );
2727+
2728+ static int rvu_dbg_npc_exact_drop_cnt (struct seq_file * s , void * unused )
2729+ {
2730+ struct npc_exact_table * table ;
2731+ struct rvu * rvu = s -> private ;
2732+ struct npc_key_field * field ;
2733+ u16 chan , pcifunc ;
2734+ int blkaddr , i ;
2735+ u64 cfg , cam1 ;
2736+ char * str ;
2737+
2738+ blkaddr = rvu_get_blkaddr (rvu , BLKTYPE_NPC , 0 );
2739+ table = rvu -> hw -> table ;
2740+
2741+ field = & rvu -> hw -> mcam .rx_key_fields [NPC_CHAN ];
2742+
2743+ seq_puts (s , "\n\t Exact Hit on drop status\n" );
2744+ seq_puts (s , "\npcifunc\tmcam_idx\tHits\tchan\tstatus\n" );
2745+
2746+ for (i = 0 ; i < table -> num_drop_rules ; i ++ ) {
2747+ pcifunc = rvu_npc_exact_drop_rule_to_pcifunc (rvu , i );
2748+ cfg = rvu_read64 (rvu , blkaddr , NPC_AF_MCAMEX_BANKX_CFG (i , 0 ));
2749+
2750+ /* channel will be always in keyword 0 */
2751+ cam1 = rvu_read64 (rvu , blkaddr ,
2752+ NPC_AF_MCAMEX_BANKX_CAMX_W0 (i , 0 , 1 ));
2753+ chan = field -> kw_mask [0 ] & cam1 ;
2754+
2755+ str = (cfg & 1 ) ? "enabled" : "disabled" ;
2756+
2757+ seq_printf (s , "0x%x\t%d\t\t%llu\t0x%x\t%s\n" , pcifunc , i ,
2758+ rvu_read64 (rvu , blkaddr ,
2759+ NPC_AF_MATCH_STATX (table -> counter_idx [i ])),
2760+ chan , str );
2761+ }
2762+
2763+ return 0 ;
2764+ }
2765+
2766+ RVU_DEBUG_SEQ_FOPS (npc_exact_drop_cnt , npc_exact_drop_cnt , NULL );
2767+
26032768static void rvu_dbg_npc_init (struct rvu * rvu )
26042769{
26052770 rvu -> rvu_dbg .npc = debugfs_create_dir ("npc" , rvu -> rvu_dbg .root );
@@ -2608,8 +2773,22 @@ static void rvu_dbg_npc_init(struct rvu *rvu)
26082773 & rvu_dbg_npc_mcam_info_fops );
26092774 debugfs_create_file ("mcam_rules" , 0444 , rvu -> rvu_dbg .npc , rvu ,
26102775 & rvu_dbg_npc_mcam_rules_fops );
2776+
26112777 debugfs_create_file ("rx_miss_act_stats" , 0444 , rvu -> rvu_dbg .npc , rvu ,
26122778 & rvu_dbg_npc_rx_miss_act_fops );
2779+
2780+ if (!rvu -> hw -> cap .npc_exact_match_enabled )
2781+ return ;
2782+
2783+ debugfs_create_file ("exact_entries" , 0444 , rvu -> rvu_dbg .npc , rvu ,
2784+ & rvu_dbg_npc_exact_entries_fops );
2785+
2786+ debugfs_create_file ("exact_info" , 0444 , rvu -> rvu_dbg .npc , rvu ,
2787+ & rvu_dbg_npc_exact_info_fops );
2788+
2789+ debugfs_create_file ("exact_drop_cnt" , 0444 , rvu -> rvu_dbg .npc , rvu ,
2790+ & rvu_dbg_npc_exact_drop_cnt_fops );
2791+
26132792}
26142793
26152794static int cpt_eng_sts_display (struct seq_file * filp , u8 eng_type )
0 commit comments