@@ -433,6 +433,136 @@ static const struct file_operations devlog_fops = {
433
433
.release = seq_release_private
434
434
};
435
435
436
+ static inline void tcamxy2valmask (u64 x , u64 y , u8 * addr , u64 * mask )
437
+ {
438
+ * mask = x | y ;
439
+ y = (__force u64 )cpu_to_be64 (y );
440
+ memcpy (addr , (char * )& y + 2 , ETH_ALEN );
441
+ }
442
+
443
+ static int mps_tcam_show (struct seq_file * seq , void * v )
444
+ {
445
+ if (v == SEQ_START_TOKEN )
446
+ seq_puts (seq , "Idx Ethernet address Mask Vld Ports PF"
447
+ " VF Replication "
448
+ "P0 P1 P2 P3 ML\n" );
449
+ else {
450
+ u64 mask ;
451
+ u8 addr [ETH_ALEN ];
452
+ struct adapter * adap = seq -> private ;
453
+ unsigned int idx = (uintptr_t )v - 2 ;
454
+ u64 tcamy = t4_read_reg64 (adap , MPS_CLS_TCAM_Y_L (idx ));
455
+ u64 tcamx = t4_read_reg64 (adap , MPS_CLS_TCAM_X_L (idx ));
456
+ u32 cls_lo = t4_read_reg (adap , MPS_CLS_SRAM_L (idx ));
457
+ u32 cls_hi = t4_read_reg (adap , MPS_CLS_SRAM_H (idx ));
458
+ u32 rplc [4 ] = {0 , 0 , 0 , 0 };
459
+
460
+ if (tcamx & tcamy ) {
461
+ seq_printf (seq , "%3u -\n" , idx );
462
+ goto out ;
463
+ }
464
+
465
+ if (cls_lo & REPLICATE_F ) {
466
+ struct fw_ldst_cmd ldst_cmd ;
467
+ int ret ;
468
+
469
+ memset (& ldst_cmd , 0 , sizeof (ldst_cmd ));
470
+ ldst_cmd .op_to_addrspace =
471
+ htonl (FW_CMD_OP_V (FW_LDST_CMD ) |
472
+ FW_CMD_REQUEST_F |
473
+ FW_CMD_READ_F |
474
+ FW_LDST_CMD_ADDRSPACE_V (
475
+ FW_LDST_ADDRSPC_MPS ));
476
+ ldst_cmd .cycles_to_len16 = htonl (FW_LEN16 (ldst_cmd ));
477
+ ldst_cmd .u .mps .fid_ctl =
478
+ htons (FW_LDST_CMD_FID_V (FW_LDST_MPS_RPLC ) |
479
+ FW_LDST_CMD_CTL_V (idx ));
480
+ ret = t4_wr_mbox (adap , adap -> mbox , & ldst_cmd ,
481
+ sizeof (ldst_cmd ), & ldst_cmd );
482
+ if (ret )
483
+ dev_warn (adap -> pdev_dev , "Can't read MPS "
484
+ "replication map for idx %d: %d\n" ,
485
+ idx , - ret );
486
+ else {
487
+ rplc [0 ] = ntohl (ldst_cmd .u .mps .rplc31_0 );
488
+ rplc [1 ] = ntohl (ldst_cmd .u .mps .rplc63_32 );
489
+ rplc [2 ] = ntohl (ldst_cmd .u .mps .rplc95_64 );
490
+ rplc [3 ] = ntohl (ldst_cmd .u .mps .rplc127_96 );
491
+ }
492
+ }
493
+
494
+ tcamxy2valmask (tcamx , tcamy , addr , & mask );
495
+ seq_printf (seq , "%3u %02x:%02x:%02x:%02x:%02x:%02x %012llx"
496
+ "%3c %#x%4u%4d" ,
497
+ idx , addr [0 ], addr [1 ], addr [2 ], addr [3 ], addr [4 ],
498
+ addr [5 ], (unsigned long long )mask ,
499
+ (cls_lo & SRAM_VLD_F ) ? 'Y' : 'N' , PORTMAP_G (cls_hi ),
500
+ PF_G (cls_lo ),
501
+ (cls_lo & VF_VALID_F ) ? VF_G (cls_lo ) : -1 );
502
+ if (cls_lo & REPLICATE_F )
503
+ seq_printf (seq , " %08x %08x %08x %08x" ,
504
+ rplc [3 ], rplc [2 ], rplc [1 ], rplc [0 ]);
505
+ else
506
+ seq_printf (seq , "%36c" , ' ' );
507
+ seq_printf (seq , "%4u%3u%3u%3u %#x\n" ,
508
+ SRAM_PRIO0_G (cls_lo ), SRAM_PRIO1_G (cls_lo ),
509
+ SRAM_PRIO2_G (cls_lo ), SRAM_PRIO3_G (cls_lo ),
510
+ (cls_lo >> MULTILISTEN0_S ) & 0xf );
511
+ }
512
+ out : return 0 ;
513
+ }
514
+
515
+ static inline void * mps_tcam_get_idx (struct seq_file * seq , loff_t pos )
516
+ {
517
+ struct adapter * adap = seq -> private ;
518
+ int max_mac_addr = is_t4 (adap -> params .chip ) ?
519
+ NUM_MPS_CLS_SRAM_L_INSTANCES :
520
+ NUM_MPS_T5_CLS_SRAM_L_INSTANCES ;
521
+ return ((pos <= max_mac_addr ) ? (void * )(uintptr_t )(pos + 1 ) : NULL );
522
+ }
523
+
524
+ static void * mps_tcam_start (struct seq_file * seq , loff_t * pos )
525
+ {
526
+ return * pos ? mps_tcam_get_idx (seq , * pos ) : SEQ_START_TOKEN ;
527
+ }
528
+
529
+ static void * mps_tcam_next (struct seq_file * seq , void * v , loff_t * pos )
530
+ {
531
+ ++ * pos ;
532
+ return mps_tcam_get_idx (seq , * pos );
533
+ }
534
+
535
+ static void mps_tcam_stop (struct seq_file * seq , void * v )
536
+ {
537
+ }
538
+
539
+ static const struct seq_operations mps_tcam_seq_ops = {
540
+ .start = mps_tcam_start ,
541
+ .next = mps_tcam_next ,
542
+ .stop = mps_tcam_stop ,
543
+ .show = mps_tcam_show
544
+ };
545
+
546
+ static int mps_tcam_open (struct inode * inode , struct file * file )
547
+ {
548
+ int res = seq_open (file , & mps_tcam_seq_ops );
549
+
550
+ if (!res ) {
551
+ struct seq_file * seq = file -> private_data ;
552
+
553
+ seq -> private = inode -> i_private ;
554
+ }
555
+ return res ;
556
+ }
557
+
558
+ static const struct file_operations mps_tcam_debugfs_fops = {
559
+ .owner = THIS_MODULE ,
560
+ .open = mps_tcam_open ,
561
+ .read = seq_read ,
562
+ .llseek = seq_lseek ,
563
+ .release = seq_release ,
564
+ };
565
+
436
566
static ssize_t mem_read (struct file * file , char __user * buf , size_t count ,
437
567
loff_t * ppos )
438
568
{
@@ -515,6 +645,7 @@ int t4_setup_debugfs(struct adapter *adap)
515
645
{ "cim_qcfg" , & cim_qcfg_fops , S_IRUSR , 0 },
516
646
{ "devlog" , & devlog_fops , S_IRUSR , 0 },
517
647
{ "l2t" , & t4_l2t_fops , S_IRUSR , 0 },
648
+ { "mps_tcam" , & mps_tcam_debugfs_fops , S_IRUSR , 0 },
518
649
};
519
650
520
651
add_debugfs_files (adap ,
0 commit comments