bna: Generic Netlink Interface to collect FW trace
Subsystems (2)
RFC PATCH 1/1 bna: Generic Netlink Interface to collect FW trace
This is a RFC patch to Brocade BNA 10G Ethernet driver. It adds the generic netlink communication interface to the BNA driver to collect firmware traces using the in-kernel generic netlink infrastructure. The driver uses the "dumpit" handler provided by the generic netlink layer to accomplish this. The driver can extend this interface later if required.
As of today, there seems to be no standard mechanism to collect debug information such as firmware trace for a given hardware. Generic Netlinki seems to provide a suitable option to do the same, without any further addition/modification to the existing kernel implementation.
This is a RFC patch inviting suggestions/opinions for improvement/modification and requesting consideration for possible inclusion in net-next tree.
--- drivers/net/bna/bfa_ioc.c | 59 +++++++++++ drivers/net/bna/bfa_ioc.h | 4 + drivers/net/bna/bfi.h | 2 + drivers/net/bna/bnad.c | 39 ++++++++ drivers/net/bna/bnad.h | 9 ++- drivers/net/bna/bnad_genl.c | 228 +++++++++++++++++++++++++++++++++++++++++++ drivers/net/bna/bnad_genl.h | 63 ++++++++++++ 7 files changed, 402 insertions(+), 2 deletions(-) create mode 100644 drivers/net/bna/bnad_genl.c create mode 100644 drivers/net/bna/bnad_genl.h
drivers/net/bna/bfa_ioc.c +59 -0
@@ -2209,6 +2209,65 @@ bfa_nw_ioc_get_mac(struct bfa_ioc *ioc)return ioc->attr->mac; } +static int +bfa_nw_ioc_smem_read (struct bfa_ioc *ioc,void *tbuf,u32 soff,u32 sz) +{ +u32 pgnum, loff; +__be32 r32; +int i, len; +u32 *buf = tbuf; + + pgnum =PSS_SMEM_PGNUM (ioc->ioc_regs.smem_pg0, soff); + loff =PSS_SMEM_PGOFF (soff); + +/* +* Hold semaphore to serialize pll init and fwtrc. +*/ +if (!(bfa_nw_ioc_sem_get (ioc->ioc_regs.ioc_init_sem_reg))) +return 1 ; + +writel (pgnum, ioc->ioc_regs.host_page_num_fn); + + len = sz/sizeof (u32); +for (i =0 ; i < len; i++) { + r32 =swab32 (readl (ioc->ioc_regs.smem_page_start + loff)); + buf[i] =be32_to_cpu (r32); + loff +=sizeof (u32); + +/* +* handle page offset wrap around +*/ + loff =PSS_SMEM_PGOFF (loff); +if (loff ==0 ) { + pgnum++; +writel (pgnum, ioc->ioc_regs.host_page_num_fn); + } + } +writel (PSS_SMEM_PGNUM (ioc->ioc_regs.smem_pg0,0 ), + ioc->ioc_regs.host_page_num_fn); +/* +* release semaphore. +*/ +writel (1 , ioc->ioc_regs.ioc_init_sem_reg); + +return 0 ; +} + +int +bfa_nw_ioc_debug_fwtrc (struct bfa_ioc *ioc,void *trcdata,int *trclen) +{ +u32 loff = (BFI_IOC_TRC_OFF +BFA_DBG_FWTRC_LEN * (ioc->port_id)); +int tlen, status =0 ; + + tlen = *trclen; +if (tlen >BFA_DBG_FWTRC_LEN ) + tlen =BFA_DBG_FWTRC_LEN ; + + status =bfa_nw_ioc_smem_read (ioc, trcdata, loff, tlen); + *trclen = tlen; +return status; +} +/** * Firmware failure detected. Start recovery actions. */
drivers/net/bna/bfa_ioc.h +4 -0
@@ -23,6 +23,9 @@#include "bfi.h" #include "cna.h" +#define BFA_DBG_FWTRC_LEN (BFI_IOC_TRC_ENTS * BFI_IOC_TRC_ENT_SZ + \ + BFI_IOC_TRC_HDR_SZ) +#define BFA_IOC_TOV 3000/* msecs */ #define BFA_IOC_HWSEM_TOV 500/* msecs */ #define BFA_IOC_HB_TOV 500/* msecs */
@@ -269,6 +272,7 @@ void bfa_nw_ioc_hbfail_register(struct bfa_ioc *ioc,bool bfa_nw_ioc_sem_get (void __iomem *sem_reg);void bfa_nw_ioc_sem_release (void __iomem *sem_reg);void bfa_nw_ioc_hw_sem_release (struct bfa_ioc *ioc); +int bfa_nw_ioc_debug_fwtrc (struct bfa_ioc *ioc,void *trcdata,int *trclen);void bfa_nw_ioc_fwver_get (struct bfa_ioc *ioc,struct bfi_ioc_image_hdr *fwhdr); bool bfa_nw_ioc_fwver_cmp(struct bfa_ioc *ioc,
drivers/net/bna/bfi.h +2 -0
@@ -277,6 +277,8 @@ struct bfi_ioc_getattr_reply {*/ #define BFI_IOC_TRC_OFF (0x4b00)#define BFI_IOC_TRC_ENTS 256 +#define BFI_IOC_TRC_ENT_SZ 16 +#define BFI_IOC_TRC_HDR_SZ 32#define BFI_IOC_FW_SIGNATURE (0xbfadbfad)#define BFI_IOC_MD5SUM_SZ 4
drivers/net/bna/bnad.c +39 -0
@@ -25,6 +25,7 @@#include <linux/ip.h> #include "bnad.h" +#include "bnad_genl.h" #include "bna.h" #include "cna.h"
@@ -44,8 +45,12 @@ MODULE_PARM_DESC(bnad_ioc_auto_recover, "Enable / Disable auto recovery");/* * Global variables */ +u32 bna_id;u32 bnad_rxqs_per_cq =2 ; +struct mutex bnad_list_mutex; +LIST_HEAD (bnad_list); +static const u8 bnad_bcast_addr[] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff };/*
@@ -72,6 +77,23 @@ do { \#define BNAD_TXRX_SYNC_MDELAY 250/* 250 msecs */ +static void +bnad_add_to_list (struct bnad *bnad) +{ +mutex_lock (&bnad_list_mutex); +list_add_tail (&bnad->list_entry, &bnad_list); + bna_id++; +mutex_unlock (&bnad_list_mutex); +} + +static void +bnad_remove_from_list (struct bnad *bnad) +{ +mutex_lock (&bnad_list_mutex); +list_del (&bnad->list_entry); +mutex_unlock (&bnad_list_mutex); +} +/* * Reinitialize completions in CQ, once Rx is taken down */
@@ -3087,6 +3109,11 @@ bnad_pci_probe(struct pci_dev *pdev, } bnad =netdev_priv (netdev); +mutex_lock (&bnad_list_mutex); + bnad->id = bna_id; +mutex_unlock (&bnad_list_mutex); + +bnad_add_to_list (bnad);/* * PCI initialization * Output : using_dac = 1 for 64 bit DMA
@@ -3189,6 +3216,7 @@ disable_device:bnad_res_free (bnad);bnad_disable_msix (bnad); pci_uninit: +bnad_remove_from_list (bnad);bnad_pci_uninit (pdev);bnad_lock_uninit (bnad);bnad_uninit (bnad);
@@ -3226,6 +3254,7 @@ bnad_pci_remove(struct pci_dev *pdev)bnad_res_free (bnad);bnad_disable_msix (bnad); +bnad_remove_from_list (bnad);bnad_pci_uninit (pdev);bnad_lock_uninit (bnad);bnad_uninit (bnad);
@@ -3257,6 +3286,7 @@ bnad_module_init(void)pr_info ("Brocade 10G Ethernet driver\n" ); +mutex_init (&bnad_list_mutex);bfa_nw_ioc_auto_recover (bnad_ioc_auto_recover); err =pci_register_driver (&bnad_pci_driver);
@@ -3266,6 +3296,10 @@ bnad_module_init(void)return err; } +/* Register with generic netlink */ +if (bnad_genl_init ()) +pr_err ("bna: Generic Netlink Register failed\n" ); +return 0 ; }
@@ -3273,6 +3307,11 @@ static void __exitbnad_module_exit (void) {pci_unregister_driver (&bnad_pci_driver); +mutex_destroy (&bnad_list_mutex); + +/* Unegister with generic netlink */ +if (bnad_genl_uninit ()) +pr_err ("bna: Generic Netlink Unregister failed\n" );if (bfi_fw)release_firmware (bfi_fw);
drivers/net/bna/bnad.h +7 -2
@@ -279,13 +279,18 @@ struct bnad {char adapter_name[BNAD_NAME_LEN ];char port_name[BNAD_NAME_LEN ];char mbox_irq_name[BNAD_NAME_LEN ]; + +int id; +struct list_head list_entry; };/* * EXTERN VARIABLES */ -extern struct firmware *bfi_fw; -extern u32 bnad_rxqs_per_cq; +extern struct firmware *bfi_fw; +extern struct mutex bnad_list_mutex; +extern struct list_head bnad_list; +extern u32 bnad_rxqs_per_cq;/* * EXTERN PROTOTYPES
drivers/net/bna/bnad_genl.c new file +228 -0
228 lines not on this page · raw message
drivers/net/bna/bnad_genl.h new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
1.7.1
Quoted 11 lines · On Tue, 26 Apr 2011 18:51:57 -0700 Rasesh Mody <[email protected]> wrote:
This is a RFC patch to Brocade BNA 10G Ethernet driver. It adds the generic netlink communication interface to the BNA driver to collect firmware traces using the in-kernel generic netlink infrastructure. The driver uses the "dumpit" handler provided by the generic netlink layer to accomplish this. The driver can extend this interface later if required.
As of today, there seems to be no standard mechanism to collect debug information such as firmware trace for a given hardware. Generic Netlinki seems to provide a suitable option to do the same, without any further addition/modification to the existing kernel implementation.
Quoted 5 lines
This is a RFC patch inviting suggestions/opinions for improvement/modification and requesting consideration for possible inclusion in net-next tree.
Signed-off-by Debashis Dutt <[email protected]>Signed-off-by Rasesh Mody <[email protected]>
Seems like a lot of work for a debug interface. What about debugfs? Or is that out of favor now, I can never keep track...
Quoted 14 lines · Stephen Hemminger
Quoted 11 lines · On Tue, 26 Apr 2011 18:51:57 -0700 Rasesh Mody <[email protected]> wrote:
This is a RFC patch to Brocade BNA 10G Ethernet driver. It adds the generic netlink communication interface to the BNA driver to collect firmware traces using the in-kernel generic netlink infrastructure. The driver uses the "dumpit" handler provided by the generic netlink layer to accomplish this. The driver can extend this interface later if required.
As of today, there seems to be no standard mechanism to collect debug information such as firmware trace for a given hardware. Generic Netlinki seems to provide a suitable option to do the same, without any further addition/modification to the existing kernel implementation.
Quoted 8 lines
Quoted 5 lines
This is a RFC patch inviting suggestions/opinions for improvement/modification and requesting consideration for possible inclusion in net-next tree.
Signed-off-by Debashis Dutt <[email protected]>Signed-off-by Rasesh Mody <[email protected]>Seems like a lot of work for a debug interface. What about debugfs? Or is that out of favor now, I can never keep track...
Stephen,
Well, I think debugfs isn't always available, but there could always be a driver
configuration option for that.
However, since the generic netlink is a more generic interface, we could use this infrastructure in the driver for commands which are not part of other standard tools.
Thanks
--Debashis
Quoted 7 lines
--
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
maintainerFrom: Debashis Dutt <[email protected]>
Date: Tue, 26 Apr 2011 19:16:29 -0700
Quoted 3 lines
However, since the generic netlink is a more generic interface, we could use this infrastructure in the driver for commands which are not part of other standard tools.
You aren't the only device in the world that might want to provide a facility to fetch firmware traces.
This isn't really a niche thing specific to your device at all.
Quoted 12 lines · David Miller
From: Debashis Dutt <[email protected]>
Date: Tue, 26 Apr 2011 19:16:29 -0700Quoted 3 lines
However, since the generic netlink is a more generic interface, we could use this infrastructure in the driver for commands which are not part of other standard tools.
You aren't the only device in the world that might want to provide a facility to fetch firmware traces.
This isn't really a niche thing specific to your device at all.
David,
Agreed.
In that case should we use debugfs for collecting f/w trace, but use generic netlink for other h/w specific commands?
Thanks
--Debashis
David Miller
maintainerFrom: Debashis Dutt <[email protected]>
Date: Thu, 28 Apr 2011 10:51:27 -0700
Quoted 2 lines
In that case should we use debugfs for collecting f/w trace, but use generic netlink for other h/w specific commands?
Sure.