3
3
4
4
#include <uapi/linux/bpf.h>
5
5
6
+ #include <linux/debugfs.h>
6
7
#include <linux/inetdevice.h>
7
8
#include <linux/etherdevice.h>
8
9
#include <linux/ethtool.h>
@@ -30,6 +31,21 @@ static void mana_adev_idx_free(int idx)
30
31
ida_free (& mana_adev_ida , idx );
31
32
}
32
33
34
+ static ssize_t mana_dbg_q_read (struct file * filp , char __user * buf , size_t count ,
35
+ loff_t * pos )
36
+ {
37
+ struct gdma_queue * gdma_q = filp -> private_data ;
38
+
39
+ return simple_read_from_buffer (buf , count , pos , gdma_q -> queue_mem_ptr ,
40
+ gdma_q -> queue_size );
41
+ }
42
+
43
+ static const struct file_operations mana_dbg_q_fops = {
44
+ .owner = THIS_MODULE ,
45
+ .open = simple_open ,
46
+ .read = mana_dbg_q_read ,
47
+ };
48
+
33
49
/* Microsoft Azure Network Adapter (MANA) functions */
34
50
35
51
static int mana_open (struct net_device * ndev )
@@ -721,6 +737,13 @@ static const struct net_device_ops mana_devops = {
721
737
722
738
static void mana_cleanup_port_context (struct mana_port_context * apc )
723
739
{
740
+ /*
741
+ * at this point all dir/files under the vport directory
742
+ * are already cleaned up.
743
+ * We are sure the apc->mana_port_debugfs remove will not
744
+ * cause any freed memory access issues
745
+ */
746
+ debugfs_remove (apc -> mana_port_debugfs );
724
747
kfree (apc -> rxqs );
725
748
apc -> rxqs = NULL ;
726
749
}
@@ -943,6 +966,8 @@ static int mana_query_device_cfg(struct mana_context *ac, u32 proto_major_ver,
943
966
else
944
967
gc -> adapter_mtu = ETH_FRAME_LEN ;
945
968
969
+ debugfs_create_u16 ("adapter-MTU" , 0400 , gc -> mana_pci_debugfs , & gc -> adapter_mtu );
970
+
946
971
return 0 ;
947
972
}
948
973
@@ -1228,6 +1253,8 @@ static void mana_destroy_eq(struct mana_context *ac)
1228
1253
if (!ac -> eqs )
1229
1254
return ;
1230
1255
1256
+ debugfs_remove_recursive (ac -> mana_eqs_debugfs );
1257
+
1231
1258
for (i = 0 ; i < gc -> max_num_queues ; i ++ ) {
1232
1259
eq = ac -> eqs [i ].eq ;
1233
1260
if (!eq )
@@ -1240,6 +1267,18 @@ static void mana_destroy_eq(struct mana_context *ac)
1240
1267
ac -> eqs = NULL ;
1241
1268
}
1242
1269
1270
+ static void mana_create_eq_debugfs (struct mana_context * ac , int i )
1271
+ {
1272
+ struct mana_eq eq = ac -> eqs [i ];
1273
+ char eqnum [32 ];
1274
+
1275
+ sprintf (eqnum , "eq%d" , i );
1276
+ eq .mana_eq_debugfs = debugfs_create_dir (eqnum , ac -> mana_eqs_debugfs );
1277
+ debugfs_create_u32 ("head" , 0400 , eq .mana_eq_debugfs , & eq .eq -> head );
1278
+ debugfs_create_u32 ("tail" , 0400 , eq .mana_eq_debugfs , & eq .eq -> tail );
1279
+ debugfs_create_file ("eq_dump" , 0400 , eq .mana_eq_debugfs , eq .eq , & mana_dbg_q_fops );
1280
+ }
1281
+
1243
1282
static int mana_create_eq (struct mana_context * ac )
1244
1283
{
1245
1284
struct gdma_dev * gd = ac -> gdma_dev ;
@@ -1260,11 +1299,14 @@ static int mana_create_eq(struct mana_context *ac)
1260
1299
spec .eq .context = ac -> eqs ;
1261
1300
spec .eq .log2_throttle_limit = LOG2_EQ_THROTTLE ;
1262
1301
1302
+ ac -> mana_eqs_debugfs = debugfs_create_dir ("EQs" , gc -> mana_pci_debugfs );
1303
+
1263
1304
for (i = 0 ; i < gc -> max_num_queues ; i ++ ) {
1264
1305
spec .eq .msix_index = (i + 1 ) % gc -> num_msix_usable ;
1265
1306
err = mana_gd_create_mana_eq (gd , & spec , & ac -> eqs [i ].eq );
1266
1307
if (err )
1267
1308
goto out ;
1309
+ mana_create_eq_debugfs (ac , i );
1268
1310
}
1269
1311
1270
1312
return 0 ;
@@ -1871,6 +1913,8 @@ static void mana_destroy_txq(struct mana_port_context *apc)
1871
1913
return ;
1872
1914
1873
1915
for (i = 0 ; i < apc -> num_queues ; i ++ ) {
1916
+ debugfs_remove_recursive (apc -> tx_qp [i ].mana_tx_debugfs );
1917
+
1874
1918
napi = & apc -> tx_qp [i ].tx_cq .napi ;
1875
1919
if (apc -> tx_qp [i ].txq .napi_initialized ) {
1876
1920
napi_synchronize (napi );
@@ -1889,6 +1933,31 @@ static void mana_destroy_txq(struct mana_port_context *apc)
1889
1933
apc -> tx_qp = NULL ;
1890
1934
}
1891
1935
1936
+ static void mana_create_txq_debugfs (struct mana_port_context * apc , int idx )
1937
+ {
1938
+ struct mana_tx_qp * tx_qp = & apc -> tx_qp [idx ];
1939
+ char qnum [32 ];
1940
+
1941
+ sprintf (qnum , "TX-%d" , idx );
1942
+ tx_qp -> mana_tx_debugfs = debugfs_create_dir (qnum , apc -> mana_port_debugfs );
1943
+ debugfs_create_u32 ("sq_head" , 0400 , tx_qp -> mana_tx_debugfs ,
1944
+ & tx_qp -> txq .gdma_sq -> head );
1945
+ debugfs_create_u32 ("sq_tail" , 0400 , tx_qp -> mana_tx_debugfs ,
1946
+ & tx_qp -> txq .gdma_sq -> tail );
1947
+ debugfs_create_u32 ("sq_pend_skb_qlen" , 0400 , tx_qp -> mana_tx_debugfs ,
1948
+ & tx_qp -> txq .pending_skbs .qlen );
1949
+ debugfs_create_u32 ("cq_head" , 0400 , tx_qp -> mana_tx_debugfs ,
1950
+ & tx_qp -> tx_cq .gdma_cq -> head );
1951
+ debugfs_create_u32 ("cq_tail" , 0400 , tx_qp -> mana_tx_debugfs ,
1952
+ & tx_qp -> tx_cq .gdma_cq -> tail );
1953
+ debugfs_create_u32 ("cq_budget" , 0400 , tx_qp -> mana_tx_debugfs ,
1954
+ & tx_qp -> tx_cq .budget );
1955
+ debugfs_create_file ("txq_dump" , 0400 , tx_qp -> mana_tx_debugfs ,
1956
+ tx_qp -> txq .gdma_sq , & mana_dbg_q_fops );
1957
+ debugfs_create_file ("cq_dump" , 0400 , tx_qp -> mana_tx_debugfs ,
1958
+ tx_qp -> tx_cq .gdma_cq , & mana_dbg_q_fops );
1959
+ }
1960
+
1892
1961
static int mana_create_txq (struct mana_port_context * apc ,
1893
1962
struct net_device * net )
1894
1963
{
@@ -2000,6 +2069,8 @@ static int mana_create_txq(struct mana_port_context *apc,
2000
2069
2001
2070
gc -> cq_table [cq -> gdma_id ] = cq -> gdma_cq ;
2002
2071
2072
+ mana_create_txq_debugfs (apc , i );
2073
+
2003
2074
netif_napi_add_tx (net , & cq -> napi , mana_poll );
2004
2075
napi_enable (& cq -> napi );
2005
2076
txq -> napi_initialized = true;
@@ -2027,6 +2098,8 @@ static void mana_destroy_rxq(struct mana_port_context *apc,
2027
2098
if (!rxq )
2028
2099
return ;
2029
2100
2101
+ debugfs_remove_recursive (rxq -> mana_rx_debugfs );
2102
+
2030
2103
napi = & rxq -> rx_cq .napi ;
2031
2104
2032
2105
if (napi_initialized ) {
@@ -2308,6 +2381,28 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
2308
2381
return NULL ;
2309
2382
}
2310
2383
2384
+ static void mana_create_rxq_debugfs (struct mana_port_context * apc , int idx )
2385
+ {
2386
+ struct mana_rxq * rxq ;
2387
+ char qnum [32 ];
2388
+
2389
+ rxq = apc -> rxqs [idx ];
2390
+
2391
+ sprintf (qnum , "RX-%d" , idx );
2392
+ rxq -> mana_rx_debugfs = debugfs_create_dir (qnum , apc -> mana_port_debugfs );
2393
+ debugfs_create_u32 ("rq_head" , 0400 , rxq -> mana_rx_debugfs , & rxq -> gdma_rq -> head );
2394
+ debugfs_create_u32 ("rq_tail" , 0400 , rxq -> mana_rx_debugfs , & rxq -> gdma_rq -> tail );
2395
+ debugfs_create_u32 ("rq_nbuf" , 0400 , rxq -> mana_rx_debugfs , & rxq -> num_rx_buf );
2396
+ debugfs_create_u32 ("cq_head" , 0400 , rxq -> mana_rx_debugfs ,
2397
+ & rxq -> rx_cq .gdma_cq -> head );
2398
+ debugfs_create_u32 ("cq_tail" , 0400 , rxq -> mana_rx_debugfs ,
2399
+ & rxq -> rx_cq .gdma_cq -> tail );
2400
+ debugfs_create_u32 ("cq_budget" , 0400 , rxq -> mana_rx_debugfs , & rxq -> rx_cq .budget );
2401
+ debugfs_create_file ("rxq_dump" , 0400 , rxq -> mana_rx_debugfs , rxq -> gdma_rq , & mana_dbg_q_fops );
2402
+ debugfs_create_file ("cq_dump" , 0400 , rxq -> mana_rx_debugfs , rxq -> rx_cq .gdma_cq ,
2403
+ & mana_dbg_q_fops );
2404
+ }
2405
+
2311
2406
static int mana_add_rx_queues (struct mana_port_context * apc ,
2312
2407
struct net_device * ndev )
2313
2408
{
@@ -2326,6 +2421,8 @@ static int mana_add_rx_queues(struct mana_port_context *apc,
2326
2421
u64_stats_init (& rxq -> stats .syncp );
2327
2422
2328
2423
apc -> rxqs [i ] = rxq ;
2424
+
2425
+ mana_create_rxq_debugfs (apc , i );
2329
2426
}
2330
2427
2331
2428
apc -> default_rxobj = apc -> rxqs [0 ]-> rxobj ;
@@ -2518,14 +2615,19 @@ void mana_query_gf_stats(struct mana_port_context *apc)
2518
2615
static int mana_init_port (struct net_device * ndev )
2519
2616
{
2520
2617
struct mana_port_context * apc = netdev_priv (ndev );
2618
+ struct gdma_dev * gd = apc -> ac -> gdma_dev ;
2521
2619
u32 max_txq , max_rxq , max_queues ;
2522
2620
int port_idx = apc -> port_idx ;
2621
+ struct gdma_context * gc ;
2622
+ char vport [32 ];
2523
2623
int err ;
2524
2624
2525
2625
err = mana_init_port_context (apc );
2526
2626
if (err )
2527
2627
return err ;
2528
2628
2629
+ gc = gd -> gdma_context ;
2630
+
2529
2631
err = mana_query_vport_cfg (apc , port_idx , & max_txq , & max_rxq ,
2530
2632
& apc -> indir_table_sz );
2531
2633
if (err ) {
@@ -2542,7 +2644,8 @@ static int mana_init_port(struct net_device *ndev)
2542
2644
apc -> num_queues = apc -> max_queues ;
2543
2645
2544
2646
eth_hw_addr_set (ndev , apc -> mac_addr );
2545
-
2647
+ sprintf (vport , "vport%d" , port_idx );
2648
+ apc -> mana_port_debugfs = debugfs_create_dir (vport , gc -> mana_pci_debugfs );
2546
2649
return 0 ;
2547
2650
2548
2651
reset_apc :
0 commit comments