]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
eth fbnic: Add debugfs hooks for firmware mailbox
authorMike Marciniszyn (Meta) <mike.marciniszyn@gmail.com>
Tue, 27 Jan 2026 20:06:43 +0000 (15:06 -0500)
committerJakub Kicinski <kuba@kernel.org>
Sat, 31 Jan 2026 01:57:12 +0000 (17:57 -0800)
This patch adds reporting the Rx and Tx information
interfacing with the firmware.

The result of reading fbnic/fw_mbx is:

 Rx
 Rdy: 1 Head: 11 Tail: 10
 Idx Len  E  Addr        F H   Raw
 ----------------------------------
 00  4096 0 000101fea000 0 1   1000000101fea001
 01  4096 0 000101feb000 0 1   1000000101feb001
  .
  .
  .
 15  4096 0 000101fe9000 0 1   1000000101fe9001

 Tx
 Rdy: 1 Head: 4 Tail: 4
 Idx Len  E  Addr        F H   Raw
 ----------------------------------
 00  0004 1 00010321b000 1 1   000440010321b003
 01  0004 1 00010228d000 1 1   000440010228d003
  .
  .
  .
 15  0004 1 00010321b000 1 1   000440010321b003

Signed-off-by: Mike Marciniszyn (Meta) <mike.marciniszyn@gmail.com>
Link: https://patch.msgid.link/20260127200644.11640-2-mike.marciniszyn@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
drivers/net/ethernet/meta/fbnic/fbnic_fw.c
drivers/net/ethernet/meta/fbnic/fbnic_fw.h

index b7238dd967fe446c751a1b10fe988230e7908e3f..9cdd03bfec34085061b2b2d3693d9873ff062879 100644 (file)
@@ -170,6 +170,52 @@ static int fbnic_dbg_ipo_dst_show(struct seq_file *s, void *v)
 }
 DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_ipo_dst);
 
+static void fbnic_dbg_fw_mbx_display(struct seq_file *s,
+                                    struct fbnic_dev *fbd, int mbx_idx)
+{
+       struct fbnic_fw_mbx *mbx = &fbd->mbx[mbx_idx];
+       char hdr[80];
+       int i;
+
+       /* Generate header */
+       seq_puts(s, mbx_idx == FBNIC_IPC_MBX_RX_IDX ? "Rx\n" : "Tx\n");
+
+       seq_printf(s, "Rdy: %d Head: %d Tail: %d\n",
+                  mbx->ready, mbx->head, mbx->tail);
+
+       snprintf(hdr, sizeof(hdr), "%3s %-4s %s %-12s %s %-3s %-16s\n",
+                "Idx", "Len", "E", "Addr", "F", "H", "Raw");
+       seq_puts(s, hdr);
+       fbnic_dbg_desc_break(s, strnlen(hdr, sizeof(hdr)));
+
+       for (i = 0; i < FBNIC_IPC_MBX_DESC_LEN; i++) {
+               u64 desc = __fbnic_mbx_rd_desc(fbd, mbx_idx, i);
+
+               seq_printf(s, "%-3.2d %04lld %d %012llx %d %-3d %016llx\n",
+                          i, FIELD_GET(FBNIC_IPC_MBX_DESC_LEN_MASK, desc),
+                          !!(desc & FBNIC_IPC_MBX_DESC_EOM),
+                          desc & FBNIC_IPC_MBX_DESC_ADDR_MASK,
+                          !!(desc & FBNIC_IPC_MBX_DESC_FW_CMPL),
+                          !!(desc & FBNIC_IPC_MBX_DESC_HOST_CMPL),
+                          desc);
+       }
+}
+
+static int fbnic_dbg_fw_mbx_show(struct seq_file *s, void *v)
+{
+       struct fbnic_dev *fbd = s->private;
+
+       fbnic_dbg_fw_mbx_display(s, fbd, FBNIC_IPC_MBX_RX_IDX);
+
+       /* Add blank line between Rx and Tx */
+       seq_puts(s, "\n");
+
+       fbnic_dbg_fw_mbx_display(s, fbd, FBNIC_IPC_MBX_TX_IDX);
+
+       return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_fw_mbx);
+
 static int fbnic_dbg_fw_log_show(struct seq_file *s, void *v)
 {
        struct fbnic_dev *fbd = s->private;
@@ -249,6 +295,8 @@ void fbnic_dbg_fbd_init(struct fbnic_dev *fbd)
                            &fbnic_dbg_ipo_src_fops);
        debugfs_create_file("ipo_dst", 0400, fbd->dbg_fbd, fbd,
                            &fbnic_dbg_ipo_dst_fops);
+       debugfs_create_file("fw_mbx", 0400, fbd->dbg_fbd, fbd,
+                           &fbnic_dbg_fw_mbx_fops);
        debugfs_create_file("fw_log", 0400, fbd->dbg_fbd, fbd,
                            &fbnic_dbg_fw_log_fops);
 }
index 66c9412f4057a8a8c00ae90f4750a37bff894ffe..1f0b6350bef4493d81744ca5d67de4c88adc4c1c 100644 (file)
@@ -40,7 +40,7 @@ static void __fbnic_mbx_invalidate_desc(struct fbnic_dev *fbd, int mbx_idx,
        fw_wr32(fbd, desc_offset + 1, 0);
 }
 
-static u64 __fbnic_mbx_rd_desc(struct fbnic_dev *fbd, int mbx_idx, int desc_idx)
+u64 __fbnic_mbx_rd_desc(struct fbnic_dev *fbd, int mbx_idx, int desc_idx)
 {
        u32 desc_offset = FBNIC_IPC_MBX(mbx_idx, desc_idx);
        u64 desc;
index b40f68187ad58e6befc8783eae5b699ed462d327..8f7218900562ebbf50eb26e667fdb6d3be40850b 100644 (file)
@@ -94,6 +94,7 @@ struct fbnic_fw_completion {
        } u;
 };
 
+u64 __fbnic_mbx_rd_desc(struct fbnic_dev *fbd, int mbx_idx, int desc_idx);
 void fbnic_mbx_init(struct fbnic_dev *fbd);
 void fbnic_mbx_clean(struct fbnic_dev *fbd);
 int fbnic_mbx_set_cmpl(struct fbnic_dev *fbd,