liquidio: update debug console logging mechanism
Subsystems (3)
PATCH 1/1 liquidio: update debug console logging mechanism
From: Rick Farrington <[email protected]>
- remove logging dependency upon global func octeon_console_debug_enabled()
- abstract debug console logging using console structure (via function ptr) to allow for more flexible logging
--- drivers/net/ethernet/cavium/liquidio/lio_main.c | 44 +++++++++++++++++- .../net/ethernet/cavium/liquidio/octeon_console.c | 54 ++++++++++++++-------- .../net/ethernet/cavium/liquidio/octeon_device.h | 17 +++++-- 3 files changed, 90 insertions(+), 25 deletions(-)
drivers/net/ethernet/cavium/liquidio/lio_main.c +42 -2
@@ -73,7 +73,7 @@* @param console console to check * @returns 1 = enabled. 0 otherwise */ -int octeon_console_debug_enabled (u32 console) +static int octeon_console_debug_enabled (u32 console) {return (console_bitmask >> (console)) &0x1 ; }
@@ -187,6 +187,9 @@ struct octeon_device_priv {static int liquidio_enable_sriov (struct pci_dev *dev,int num_vfs);#endif +static int octeon_dbg_console_print (struct octeon_device *oct,u32 console_num, +char *prefix,char *suffix); +static int octeon_device_init (struct octeon_device *);static int liquidio_stop (struct net_device *netdev);static void liquidio_remove (struct pci_dev *pdev);
@@ -4555,6 +4558,7 @@ static int octeon_device_init(struct octeon_device *octeon_dev)int j, ret;int fw_loaded =0 ;char bootcmd[] ="\n" ; +char *dbg_enb =NULL ;struct octeon_device_priv *oct_priv = (struct octeon_device_priv *)octeon_dev->priv;atomic_set (&octeon_dev->status,OCT_DEV_BEGIN_STATE );
@@ -4761,10 +4765,19 @@ static int octeon_device_init(struct octeon_device *octeon_dev)dev_err (&octeon_dev->pci_dev->dev,"Could not access board consoles\n" );return 1 ; } - ret =octeon_add_console (octeon_dev,0 ); +/* If console debug enabled, specify empty string to use default +* enablement ELSE specify NULL string for 'disabled'. +*/ + dbg_enb =octeon_console_debug_enabled (0 ) ?"" :NULL ; + ret =octeon_add_console (octeon_dev,0 , dbg_enb);if (ret) {dev_err (&octeon_dev->pci_dev->dev,"Could not access board console\n" );return 1 ; + }else if (octeon_console_debug_enabled (0 )) { +/* If console was added AND we're logging console output +* then set our console print function. +*/ + octeon_dev->console[0 ].print = octeon_dbg_console_print; }atomic_set (&octeon_dev->status,OCT_DEV_CONSOLE_INIT_DONE );
@@ -4800,6 +4813,33 @@ static int octeon_device_init(struct octeon_device *octeon_dev) }/** +* \brief Debug console print function +* @param octeon_dev octeon device +* @param console_num console number +* @param prefix first portion of line to display +* @param suffix second portion of line to display +* +* The OCTEON debug console outputs entire lines (excluding '\n'). +* Normally, the line will be passed in the 'prefix' parameter. +* However, due to buffering, it is possible for a line to be split into two +* parts, in which case they will be passed as the 'prefix' parameter and +* 'suffix' parameter. +*/ +static int octeon_dbg_console_print (struct octeon_device *oct,u32 console_num, +char *prefix,char *suffix) +{ +if (prefix && suffix) +dev_info (&oct->pci_dev->dev,"%u: %s%s\n" , console_num, prefix, + suffix); +else if (prefix) +dev_info (&oct->pci_dev->dev,"%u: %s\n" , console_num, prefix); +else if (suffix) +dev_info (&oct->pci_dev->dev,"%u: %s\n" , console_num, suffix); + +return 0 ; +} + +/** * \brief Exits the module */ static void __exit liquidio_exit(void)
drivers/net/ethernet/cavium/liquidio/octeon_console.c +36 -18
104 lines not on this page · raw message
drivers/net/ethernet/cavium/liquidio/octeon_device.h +12 -5
@@ -194,6 +194,8 @@ struct octeon_reg_list { };#define OCTEON_CONSOLE_MAX_READ_BYTES 512 +typedef int (*octeon_console_print_fn )(struct octeon_device *oct, +u32 num,char *pre,char *suf);struct octeon_console {u32 active;u32 waiting;
@@ -201,6 +203,7 @@ struct octeon_console {u32 buffer_size;u64 input_base_addr;u64 output_base_addr; +octeon_console_print_fn print;char leftover[OCTEON_CONSOLE_MAX_READ_BYTES ]; };
@@ -739,16 +742,20 @@ int octeon_wait_for_bootloader(struct octeon_device *oct,*/ int octeon_init_consoles (struct octeon_device *oct); -int octeon_console_debug_enabled (u32 console); -/** * Adds access to a console to the device. * -* @param oct which octeon to add to -* @param console_num which console +* @param oct: which octeon to add to +* @param console_num: which console +* @param dbg_enb: ptr to debug enablement string, one of: +* * NULL for no debug output (i.e. disabled) +* * empty string enables debug output (via default method) +* * specific string to enable debug console output +* * @return Zero on success, negative on failure. */ -int octeon_add_console (struct octeon_device *oct,u32 console_num); +int octeon_add_console (struct octeon_device *oct,u32 console_num, +char *dbg_enb);/** write or read from a console */ int octeon_console_write(struct octeon_device *oct, u32 console_num,
Signature · 1 line
1.8.3.1
Quoted 6 lines · Felix Manlunas
From: Rick Farrington <[email protected]>
- remove logging dependency upon global func
octeon_console_debug_enabled()
- abstract debug console logging using console structure (via function ptr) to allow for more flexible logging
Quoted 9 lines
Signed-off-by Rick Farrington <[email protected]>Signed-off-by Raghu Vatsavayi <[email protected]>Signed-off-by Felix Manlunas <[email protected]>--- drivers/net/ethernet/cavium/liquidio/lio_main.c | 44 +++++++++++++++++- .../net/ethernet/cavium/liquidio/octeon_console.c | 54 ++++++++++++++-------- .../net/ethernet/cavium/liquidio/octeon_device.h | 17 +++++-- 3 files changed, 90 insertions(+), 25 deletions(-)
I'm probably missing something important, but why do you need your custom console implementation if kernel is full of such built-in options?
Thanks
Hi Leon - the code to which this patch applies handles a data stream from our card's firmware to the host (over PCI). There are device-specific registers which are accessed to transfer log data from our firmware to the host. I don't think there is kernel code that we could use to perform this; this is not general purpose host driver logging.
Rick
-----Original Message-----
From: Leon Romanovsky [mailto:[email protected]]
Sent: Saturday, August 12, 2017 10:56 PM
To: Manlunas, Felix <[email protected]>
Cc: [email protected]; [email protected]; Vatsavayi, Raghu <[email protected]>; Chickles, Derek <[email protected]>; Burla, Satananda <[email protected]>; Ricardo Farrington <[email protected]>
Subject: Re: [PATCH net-next] liquidio: update debug console logging mechanism
Quoted 7 lines · Felix Manlunas
From: Rick Farrington <[email protected]>
- remove logging dependency upon global func
octeon_console_debug_enabled()
- abstract debug console logging using console structure (via function ptr) to allow for more flexible logging
Quoted 9 lines
Signed-off-by Rick Farrington <[email protected]>Signed-off-by Raghu Vatsavayi <[email protected]>Signed-off-by Felix Manlunas <[email protected]>--- drivers/net/ethernet/cavium/liquidio/lio_main.c | 44 +++++++++++++++++- .../net/ethernet/cavium/liquidio/octeon_console.c | 54 ++++++++++++++-------- .../net/ethernet/cavium/liquidio/octeon_device.h | 17 +++++-- 3 files changed, 90 insertions(+), 25 deletions(-)
I'm probably missing something important, but why do you need your custom console implementation if kernel is full of such built-in options?
Thanks
Quoted 3 lines · Ricardo Farrington
Hi Leon - the code to which this patch applies handles a data stream from our card's firmware to the host (over PCI). There are device-specific registers which are accessed to transfer log data from our firmware to the host. I don't think there is kernel code that we could use to perform this; this is not general purpose host driver logging.
I see, it is not really clear form the name "console".
Thanks
From: Felix Manlunas <[email protected]>
Date: Fri, 11 Aug 2017 18:43:14 -0700
Quoted 9 lines
From: Rick Farrington <[email protected]>
- remove logging dependency upon global func
octeon_console_debug_enabled()
- abstract debug console logging using console structure (via function ptr) to allow for more flexible loggingSigned-off-by Rick Farrington <[email protected]>Signed-off-by Raghu Vatsavayi <[email protected]>Signed-off-by Felix Manlunas <[email protected]>
Applied, thanks.