@@ -1971,28 +1971,97 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id)
19711971 return err ;
19721972}
19731973
1974- static int rvu_dbg_cgx_stat_display (struct seq_file * filp , void * unused )
1974+ static int rvu_dbg_derive_lmacid (struct seq_file * filp , int * lmac_id )
19751975{
19761976 struct dentry * current_dir ;
1977- int err , lmac_id ;
19781977 char * buf ;
19791978
19801979 current_dir = filp -> file -> f_path .dentry -> d_parent ;
19811980 buf = strrchr (current_dir -> d_name .name , 'c' );
19821981 if (!buf )
19831982 return - EINVAL ;
19841983
1985- err = kstrtoint (buf + 1 , 10 , & lmac_id );
1986- if (!err ) {
1987- err = cgx_print_stats (filp , lmac_id );
1988- if (err )
1989- return err ;
1990- }
1984+ return kstrtoint (buf + 1 , 10 , lmac_id );
1985+ }
1986+
1987+ static int rvu_dbg_cgx_stat_display (struct seq_file * filp , void * unused )
1988+ {
1989+ int lmac_id , err ;
1990+
1991+ err = rvu_dbg_derive_lmacid (filp , & lmac_id );
1992+ if (!err )
1993+ return cgx_print_stats (filp , lmac_id );
1994+
19911995 return err ;
19921996}
19931997
19941998RVU_DEBUG_SEQ_FOPS (cgx_stat , cgx_stat_display , NULL );
19951999
2000+ static int cgx_print_dmac_flt (struct seq_file * s , int lmac_id )
2001+ {
2002+ struct pci_dev * pdev = NULL ;
2003+ void * cgxd = s -> private ;
2004+ char * bcast , * mcast ;
2005+ u16 index , domain ;
2006+ u8 dmac [ETH_ALEN ];
2007+ struct rvu * rvu ;
2008+ u64 cfg , mac ;
2009+ int pf ;
2010+
2011+ rvu = pci_get_drvdata (pci_get_device (PCI_VENDOR_ID_CAVIUM ,
2012+ PCI_DEVID_OCTEONTX2_RVU_AF , NULL ));
2013+ if (!rvu )
2014+ return - ENODEV ;
2015+
2016+ pf = cgxlmac_to_pf (rvu , cgx_get_cgxid (cgxd ), lmac_id );
2017+ domain = 2 ;
2018+
2019+ pdev = pci_get_domain_bus_and_slot (domain , pf + 1 , 0 );
2020+ if (!pdev )
2021+ return 0 ;
2022+
2023+ cfg = cgx_read_dmac_ctrl (cgxd , lmac_id );
2024+ bcast = cfg & CGX_DMAC_BCAST_MODE ? "ACCEPT" : "REJECT" ;
2025+ mcast = cfg & CGX_DMAC_MCAST_MODE ? "ACCEPT" : "REJECT" ;
2026+
2027+ seq_puts (s ,
2028+ "PCI dev RVUPF BROADCAST MULTICAST FILTER-MODE\n" );
2029+ seq_printf (s , "%s PF%d %9s %9s" ,
2030+ dev_name (& pdev -> dev ), pf , bcast , mcast );
2031+ if (cfg & CGX_DMAC_CAM_ACCEPT )
2032+ seq_printf (s , "%12s\n\n" , "UNICAST" );
2033+ else
2034+ seq_printf (s , "%16s\n\n" , "PROMISCUOUS" );
2035+
2036+ seq_puts (s , "\nDMAC-INDEX ADDRESS\n" );
2037+
2038+ for (index = 0 ; index < 32 ; index ++ ) {
2039+ cfg = cgx_read_dmac_entry (cgxd , index );
2040+ /* Display enabled dmac entries associated with current lmac */
2041+ if (lmac_id == FIELD_GET (CGX_DMAC_CAM_ENTRY_LMACID , cfg ) &&
2042+ FIELD_GET (CGX_DMAC_CAM_ADDR_ENABLE , cfg )) {
2043+ mac = FIELD_GET (CGX_RX_DMAC_ADR_MASK , cfg );
2044+ u64_to_ether_addr (mac , dmac );
2045+ seq_printf (s , "%7d %pM\n" , index , dmac );
2046+ }
2047+ }
2048+
2049+ return 0 ;
2050+ }
2051+
2052+ static int rvu_dbg_cgx_dmac_flt_display (struct seq_file * filp , void * unused )
2053+ {
2054+ int err , lmac_id ;
2055+
2056+ err = rvu_dbg_derive_lmacid (filp , & lmac_id );
2057+ if (!err )
2058+ return cgx_print_dmac_flt (filp , lmac_id );
2059+
2060+ return err ;
2061+ }
2062+
2063+ RVU_DEBUG_SEQ_FOPS (cgx_dmac_flt , cgx_dmac_flt_display , NULL );
2064+
19962065static void rvu_dbg_cgx_init (struct rvu * rvu )
19972066{
19982067 struct mac_ops * mac_ops ;
@@ -2029,6 +2098,9 @@ static void rvu_dbg_cgx_init(struct rvu *rvu)
20292098
20302099 debugfs_create_file ("stats" , 0600 , rvu -> rvu_dbg .lmac ,
20312100 cgx , & rvu_dbg_cgx_stat_fops );
2101+ debugfs_create_file ("mac_filter" , 0600 ,
2102+ rvu -> rvu_dbg .lmac , cgx ,
2103+ & rvu_dbg_cgx_dmac_flt_fops );
20322104 }
20332105 }
20342106}
0 commit comments