staging: octeon: replace pr_* with dev_* logging
v7 cover staging: octeon: replace pr_* with dev_* logging
This patch series replaces pr_warn(), pr_err(), and pr_info() calls with device-aware logging functions (dev_warn(), dev_err(), netdev_err(), and netdev_info()) throughout the Octeon ethernet driver. To support this, struct platform_device is passed through the memory allocation and receive call chains. Additionally, the receive group state (oct_rx_group) and the rx refill delayed work (rx_refill_work) are refactored from static globals into the per-device platform data structure (octeon_ethernet_platform).
Changes in v7:
- Fix @pdev doc comment alignment from 6 to 5 spaces to match existing parameter descriptions in ethernet-mem.c
- Remove extra blank line added in cvm_oct_remove() between atomic_inc_return() and cancel_delayed_work_sync()
- Shorten patch 3 subject line to meet length guidelines
- Rebase onto latest gregkh/staging-testing
Changes in v6:
- Squash the structural refactoring into the same patch that introduces the platform data, so each patch is a self-contained logical change with no inconsistent intermediate states (Greg)
- Rename local platform device data variables from plt to plat to adhere to standard kernel naming conventions (Dan Carpenter)
Changes in v5:
- Pass struct platform_device instead of struct device through ethernet-mem and ethernet-rx call chains (Greg)
- Move static oct_rx_group[16] array into the platform device private structure to eliminate file-scoped global state (Greg)
- Update kdoc parameter names to match renamed parameters Changes in v4:
- Broke the series into much smaller, focused patches to ease review
- Removed the global cvm_oct_rx_refill_work by introducing a per-device struct octeon_ethernet_platform, allocated during probe
- Retrieved the device pointer via platform_get_drvdata() and passed it down the call chain (NAPI poll -> rx refill -> mem free/fill) as the first argument to avoid global state
- Note: Dropped the ethernet-spi.c IRQ handler conversions from this series for now, as those errors are SPI4 bus-level
Changes in v3:
- Use netdev_err() instead of dev_err() in ethernet-spi.c
- Pass the netdev pointer directly to request_irq/free_irq instead of dev->dev.parent
- Move the device pointer to be the first argument in helper functions
- Fix checkpatch alignment and line-length warnings
- Add missing @dev kernel-doc parameter descriptions
- Wrap commit message body to 75 characters
- Fix author name formatting
Changes in v2:
- Instead of adding pr_fmt() macros, replace pr_*() calls with proper dev_*() and netdev_*() calls
- Thread device pointer through call chains via function parameters
- Introduce struct octeon_ethernet_platform to pass device pointer through work queue callbacks via container_of
- Store device pointer in oct_rx_group for NAPI poll functions
- Use dev_id in interrupt handler to pass and retrieve device pointer
Ayush Mukkanwar (3):
staging: octeon: ethernet-mem: replace pr_warn with dev_warn in free
functions
staging: octeon: ethernet: replace pr_err and pr_info with dev_err and
netdev_err
staging: octeon: replace pr_warn with dev_warn in fill and rx paths
drivers/staging/octeon/ethernet-mem.c | 43 +++++++++------- drivers/staging/octeon/ethernet-mem.h | 8 ++- drivers/staging/octeon/ethernet-rx.c | 49 +++++++++--------- drivers/staging/octeon/ethernet-rx.h | 11 +++-- drivers/staging/octeon/ethernet.c | 63 ++++++++++++++---------- drivers/staging/octeon/octeon-ethernet.h | 14 ++++++ 6 files changed, 113 insertions(+), 75 deletions(-)
--
2.53.0
PATCH v7 1/3 staging: octeon: ethernet-mem: replace pr_warn with dev_warn in free functions
Add struct platform_device parameter to cvm_oct_free_hw_skbuff, cvm_oct_free_hw_memory and cvm_oct_mem_empty_fpa. Replace pr_warn calls with dev_warn, using &pdev->dev for device-aware logging.
--- drivers/staging/octeon/ethernet-mem.c | 31 ++++++++++++++++----------- drivers/staging/octeon/ethernet-mem.h | 5 ++++- drivers/staging/octeon/ethernet.c | 6 +++--- 3 files changed, 25 insertions(+), 17 deletions(-)
drivers/staging/octeon/ethernet-mem.c +18 -13
@@ -5,6 +5,7 @@* Copyright (c) 2003-2010 Cavium Networks */ +#include <linux/platform_device.h> #include <linux/kernel.h> #include <linux/netdevice.h> #include <linux/slab.h>
@@ -40,11 +41,13 @@ static int cvm_oct_fill_hw_skbuff(int pool, int size, int elements)/** * cvm_oct_free_hw_skbuff- free hardware pool skbuffs +* @pdev: Platform device for logging * @pool: Pool to allocate an skbuff for * @size: Size of the buffer needed for the pool * @elements: Number of buffers to allocate */ -static void cvm_oct_free_hw_skbuff (int pool,int size,int elements) +static void cvm_oct_free_hw_skbuff (struct platform_device *pdev, +int pool,int size,int elements) {char *memory;
@@ -59,11 +62,11 @@ static void cvm_oct_free_hw_skbuff(int pool, int size, int elements) }while (memory);if (elements <0 ) -pr_warn ("Freeing of pool %u had too many skbuffs (%d)\n" , - pool, elements); +dev_warn (&pdev->dev,"Freeing of pool %u had too many skbuffs (%d)\n" , + pool, elements);else if (elements >0 ) -pr_warn ("Freeing of pool %u is missing %d skbuffs\n" , - pool, elements); +dev_warn (&pdev->dev,"Freeing of pool %u is missing %d skbuffs\n" , + pool, elements); }/**
@@ -107,11 +110,13 @@ static int cvm_oct_fill_hw_memory(int pool, int size, int elements)/** * cvm_oct_free_hw_memory - Free memory allocated by cvm_oct_fill_hw_memory +* @pdev: Platform device for logging * @pool: FPA pool to free * @size: Size of each buffer in the pool * @elements: Number of buffers that should be in the pool */ -static void cvm_oct_free_hw_memory (int pool,int size,int elements) +static void cvm_oct_free_hw_memory (struct platform_device *pdev, +int pool,int size,int elements) {char *memory;char *fpa;
@@ -127,11 +132,11 @@ static void cvm_oct_free_hw_memory(int pool, int size, int elements) }while (fpa);if (elements <0 ) -pr_warn ("Freeing of pool %u had too many buffers (%d)\n" , - pool, elements); +dev_warn (&pdev->dev,"Freeing of pool %u had too many buffers (%d)\n" , + pool, elements);else if (elements >0 ) -pr_warn ("Warning: Freeing of pool %u is missing %d buffers\n" , - pool, elements); +dev_warn (&pdev->dev,"Freeing of pool %u is missing %d buffers\n" , + pool, elements); }int cvm_oct_mem_fill_fpa (int pool,int size,int elements)
@@ -145,10 +150,10 @@ int cvm_oct_mem_fill_fpa(int pool, int size, int elements)return freed; } -void cvm_oct_mem_empty_fpa (int pool,int size,int elements) +void cvm_oct_mem_empty_fpa (struct platform_device *pdev,int pool,int size,int elements) {if (pool ==CVMX_FPA_PACKET_POOL ) -cvm_oct_free_hw_skbuff (pool, size, elements); +cvm_oct_free_hw_skbuff (pdev, pool, size, elements);else -cvm_oct_free_hw_memory (pool, size, elements); +cvm_oct_free_hw_memory (pdev, pool, size, elements); }
drivers/staging/octeon/ethernet-mem.h +4 -1
@@ -6,4 +6,7 @@*/ int cvm_oct_mem_fill_fpa (int pool,int size,int elements); -void cvm_oct_mem_empty_fpa (int pool,int size,int elements); +struct platform_device ; + +void cvm_oct_mem_empty_fpa (struct platform_device *pdev,int pool,int size, +int elements);
drivers/staging/octeon/ethernet.c +3 -3
@@ -958,12 +958,12 @@ static void cvm_oct_remove(struct platform_device *pdev)cvmx_ipd_free_ptr ();/* Free the HW pools */ -cvm_oct_mem_empty_fpa (CVMX_FPA_PACKET_POOL ,CVMX_FPA_PACKET_POOL_SIZE , +cvm_oct_mem_empty_fpa (pdev,CVMX_FPA_PACKET_POOL ,CVMX_FPA_PACKET_POOL_SIZE , num_packet_buffers); -cvm_oct_mem_empty_fpa (CVMX_FPA_WQE_POOL ,CVMX_FPA_WQE_POOL_SIZE , +cvm_oct_mem_empty_fpa (pdev,CVMX_FPA_WQE_POOL ,CVMX_FPA_WQE_POOL_SIZE , num_packet_buffers);if (CVMX_FPA_OUTPUT_BUFFER_POOL !=CVMX_FPA_PACKET_POOL ) -cvm_oct_mem_empty_fpa (CVMX_FPA_OUTPUT_BUFFER_POOL , +cvm_oct_mem_empty_fpa (pdev,CVMX_FPA_OUTPUT_BUFFER_POOL ,CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE ,128 ); }
Signature · 1 line
2.53.0
PATCH v7 2/3 staging: octeon: ethernet: replace pr_err and pr_info with dev_err and netdev_err
In reply to Ayush MukkanwarReplace pr_err() and pr_info() calls in cvm_oct_probe() with dev_err(), netdev_err(), and netdev_info() to include device information in log messages. Use dev_err() where no net_device is available (allocation failures), and netdev_err()/netdev_info() where a net_device exists.
--- drivers/staging/octeon/ethernet.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/octeon/ethernet.c +10 -10
@@ -685,7 +685,7 @@ static int cvm_oct_probe(struct platform_device *pdev) pip = pdev->dev.of_node;if (!pip) { -pr_err ("Error: No 'pip' in /aliases\n" ); +dev_err (&pdev->dev,"No 'pip' in /aliases\n" );return -EINVAL ; }
@@ -783,16 +783,16 @@ static int cvm_oct_probe(struct platform_device *pdev) dev->max_mtu =OCTEON_MAX_MTU - mtu_overhead;if (register_netdev (dev) <0 ) { -pr_err ("Failed to register ethernet device for POW\n" ); +netdev_err (dev,"Failed to register ethernet device for POW\n" );free_netdev (dev); }else { cvm_oct_device[CVMX_PIP_NUM_INPUT_PORTS ] = dev; -pr_info ("%s: POW send group %d, receive group %d\n" , - dev->name, pow_send_group, - pow_receive_group); +netdev_info (dev,"POW send group %d, receive group %d\n" , + pow_send_group, + pow_receive_group); } }else { -pr_err ("Failed to allocate ethernet device for POW\n" ); +dev_err (&pdev->dev,"Failed to allocate ethernet device for POW\n" ); } }
@@ -812,8 +812,8 @@ static int cvm_oct_probe(struct platform_device *pdev)struct net_device *dev =alloc_etherdev (sizeof (struct octeon_ethernet ));if (!dev) { -pr_err ("Failed to allocate ethernet device for port %d\n" , - port); +dev_err (&pdev->dev,"Failed to allocate ethernet device for port %d\n" , + port);continue ; }
@@ -897,8 +897,8 @@ static int cvm_oct_probe(struct platform_device *pdev)if (!dev->netdev_ops) {free_netdev (dev); }else if (register_netdev (dev) <0 ) { -pr_err ("Failed to register ethernet device for interface %d, port %d\n" , - interface, priv->port); +netdev_err (dev,"Failed to register ethernet device for interface %d, port %d\n" , + interface, priv->port);free_netdev (dev); }else { cvm_oct_device[priv->port] = dev;
Signature · 1 line
2.53.0
PATCH v7 3/3 staging: octeon: replace pr_warn with dev_warn in fill and rx paths
In reply to Ayush MukkanwarAdd struct platform_device parameter to cvm_oct_fill_hw_memory, cvm_oct_mem_fill_fpa, cvm_oct_rx_refill_pool and cvm_oct_rx_initialize to support device-aware logging. Replace pr_warn with dev_warn using &pdev->dev.
To avoid passing these parameters through global state, introduce struct octeon_ethernet_platform to hold per-device state including the rx_refill_work and the oct_rx_group array. This ensures all receive group state and workers are correctly associated with the platform device.
Define struct oct_rx_group and struct octeon_ethernet_platform in octeon-ethernet.h so they are shared across compilation units.
--- drivers/staging/octeon/ethernet-mem.c | 12 +++--- drivers/staging/octeon/ethernet-mem.h | 3 +- drivers/staging/octeon/ethernet-rx.c | 49 ++++++++++++------------ drivers/staging/octeon/ethernet-rx.h | 11 ++++-- drivers/staging/octeon/ethernet.c | 37 +++++++++++------- drivers/staging/octeon/octeon-ethernet.h | 14 +++++++ 6 files changed, 78 insertions(+), 48 deletions(-)
drivers/staging/octeon/ethernet-mem.c +7 -5
@@ -71,13 +71,15 @@ static void cvm_oct_free_hw_skbuff(struct platform_device *pdev,/** * cvm_oct_fill_hw_memory - fill a hardware pool with memory. +* @pdev: Platform device for logging * @pool: Pool to populate * @size: Size of each buffer in the pool * @elements: Number of buffers to allocate * * Returns the actual number of buffers allocated. */ -static int cvm_oct_fill_hw_memory (int pool,int size,int elements) +static int cvm_oct_fill_hw_memory (struct platform_device *pdev,int pool,int size, +int elements) {char *memory;char *fpa;
@@ -96,8 +98,8 @@ static int cvm_oct_fill_hw_memory(int pool, int size, int elements)*/ memory =kmalloc (size +256 ,GFP_ATOMIC );if (unlikely (!memory)) { -pr_warn ("Unable to allocate %u bytes for FPA pool %d\n" , - elements * size, pool); +dev_warn (&pdev->dev,"Unable to allocate %u bytes for FPA pool %d\n" , + elements * size, pool);break ; } fpa = (char *)(((unsigned long )memory +256 ) & ~0x7fUL );
@@ -139,14 +141,14 @@ static void cvm_oct_free_hw_memory(struct platform_device *pdev, pool, elements); } -int cvm_oct_mem_fill_fpa (int pool,int size,int elements) +int cvm_oct_mem_fill_fpa (struct platform_device *pdev,int pool,int size,int elements) {int freed;if (pool ==CVMX_FPA_PACKET_POOL ) freed =cvm_oct_fill_hw_skbuff (pool, size, elements);else - freed =cvm_oct_fill_hw_memory (pool, size, elements); + freed =cvm_oct_fill_hw_memory (pdev, pool, size, elements);return freed; }
drivers/staging/octeon/ethernet-mem.h +2 -1
@@ -5,8 +5,9 @@* Copyright (c) 2003-2007 Cavium Networks */ -int cvm_oct_mem_fill_fpa (int pool,int size,int elements);struct platform_device ; +int cvm_oct_mem_fill_fpa (struct platform_device *pdev,int pool,int size, +int elements);void cvm_oct_mem_empty_fpa (struct platform_device *pdev,int pool,int size,int elements);
drivers/staging/octeon/ethernet-rx.c +25 -24
125 lines not on this page · raw message
drivers/staging/octeon/ethernet-rx.h +7 -4
@@ -5,11 +5,14 @@* Copyright (c) 2003-2007 Cavium Networks */ +struct platform_device ; +void cvm_oct_poll_controller (struct net_device *dev); -void cvm_oct_rx_initialize (void ); -void cvm_oct_rx_shutdown (void ); +void cvm_oct_rx_initialize (struct platform_device *pdev); +void cvm_oct_rx_shutdown (struct platform_device *pdev); -static inline void cvm_oct_rx_refill_pool (int fill_threshold) +static inline void cvm_oct_rx_refill_pool (struct platform_device *pdev, +int fill_threshold) {int number_to_free;int num_freed;
@@ -20,7 +23,7 @@ static inline void cvm_oct_rx_refill_pool(int fill_threshold)if (number_to_free > fill_threshold) {cvmx_fau_atomic_add32 (FAU_NUM_PACKET_BUFFERS_TO_FREE , -number_to_free); - num_freed =cvm_oct_mem_fill_fpa (CVMX_FPA_PACKET_POOL , + num_freed =cvm_oct_mem_fill_fpa (pdev,CVMX_FPA_PACKET_POOL ,CVMX_FPA_PACKET_POOL_SIZE , number_to_free);if (num_freed != number_to_free) {
drivers/staging/octeon/ethernet.c +23 -14
@@ -104,11 +104,10 @@ struct net_device *cvm_oct_device[TOTAL_NUMBER_OF_PORTS];u64 cvm_oct_tx_poll_interval; -static void cvm_oct_rx_refill_worker (struct work_struct *work); -static DECLARE_DELAYED_WORK(cvm_oct_rx_refill_work, cvm_oct_rx_refill_worker); -static void cvm_oct_rx_refill_worker (struct work_struct *work) { +struct octeon_ethernet_platform *plat =container_of (work, + struct octeon_ethernet_platform, rx_refill_work.work);/* * FPA 0 may have been drained, try to refill it if we need * more than num_packet_buffers / 2, otherwise normal receive
@@ -116,10 +115,10 @@ static void cvm_oct_rx_refill_worker(struct work_struct *work)* could be received so cvm_oct_napi_poll would never be * invoked to do the refill. */ -cvm_oct_rx_refill_pool (num_packet_buffers /2 ); +cvm_oct_rx_refill_pool (plat->pdev, num_packet_buffers /2 );if (!atomic_read (&cvm_oct_poll_queue_stopping)) -schedule_delayed_work (&cvm_oct_rx_refill_work,HZ ); +schedule_delayed_work (&plat->rx_refill_work,HZ ); }static void cvm_oct_periodic_worker (struct work_struct *work)
@@ -138,16 +137,16 @@ static void cvm_oct_periodic_worker(struct work_struct *work)schedule_delayed_work (&priv->port_periodic_work,HZ ); } -static void cvm_oct_configure_common_hw (void ) +static void cvm_oct_configure_common_hw (struct platform_device *pdev) {/* Setup the FPA */ cvmx_fpa_enable (); -cvm_oct_mem_fill_fpa (CVMX_FPA_PACKET_POOL ,CVMX_FPA_PACKET_POOL_SIZE , +cvm_oct_mem_fill_fpa (pdev,CVMX_FPA_PACKET_POOL ,CVMX_FPA_PACKET_POOL_SIZE , num_packet_buffers); -cvm_oct_mem_fill_fpa (CVMX_FPA_WQE_POOL ,CVMX_FPA_WQE_POOL_SIZE , +cvm_oct_mem_fill_fpa (pdev,CVMX_FPA_WQE_POOL ,CVMX_FPA_WQE_POOL_SIZE , num_packet_buffers);if (CVMX_FPA_OUTPUT_BUFFER_POOL !=CVMX_FPA_PACKET_POOL ) -cvm_oct_mem_fill_fpa (CVMX_FPA_OUTPUT_BUFFER_POOL , +cvm_oct_mem_fill_fpa (pdev,CVMX_FPA_OUTPUT_BUFFER_POOL ,CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE ,1024 );#ifdef __LITTLE_ENDIAN
@@ -678,6 +677,15 @@ static int cvm_oct_probe(struct platform_device *pdev)int qos;struct device_node *pip;int mtu_overhead =ETH_HLEN +ETH_FCS_LEN ; +struct octeon_ethernet_platform *plat; + + plat =devm_kzalloc (&pdev->dev,sizeof (*plat),GFP_KERNEL ); +if (!plat) +return -ENOMEM ; + + plat->pdev = pdev; +INIT_DELAYED_WORK (&plat->rx_refill_work, cvm_oct_rx_refill_worker); +platform_set_drvdata (pdev, plat);#if IS_ENABLED (CONFIG_VLAN_8021Q ) mtu_overhead +=VLAN_HLEN ;
@@ -689,7 +697,7 @@ static int cvm_oct_probe(struct platform_device *pdev)return -EINVAL ; } -cvm_oct_configure_common_hw (); +cvm_oct_configure_common_hw (pdev);cvmx_helper_initialize_packet_io_global ();
@@ -912,28 +920,29 @@ static int cvm_oct_probe(struct platform_device *pdev) }cvm_oct_tx_initialize (); -cvm_oct_rx_initialize (); +cvm_oct_rx_initialize (pdev);/* * 150 uS: about 10 1500-byte packets at 1GE. */ cvm_oct_tx_poll_interval =150 * (octeon_get_clock_rate () /1000000 ); -schedule_delayed_work (&cvm_oct_rx_refill_work,HZ ); +schedule_delayed_work (&plat->rx_refill_work,HZ );return 0 ; }static void cvm_oct_remove (struct platform_device *pdev) { +struct octeon_ethernet_platform *plat =platform_get_drvdata (pdev);int port;cvmx_ipd_disable ();atomic_inc_return (&cvm_oct_poll_queue_stopping); -cancel_delayed_work_sync (&cvm_oct_rx_refill_work); +cancel_delayed_work_sync (&plat->rx_refill_work); -cvm_oct_rx_shutdown (); +cvm_oct_rx_shutdown (pdev);cvm_oct_tx_shutdown ();cvmx_pko_disable ();
drivers/staging/octeon/octeon-ethernet.h +14 -0
@@ -11,6 +11,7 @@#ifndef OCTEON_ETHERNET_H #define OCTEON_ETHERNET_H +#include <linux/netdevice.h> #include <linux/of.h> #include <linux/phy.h>
@@ -74,6 +75,19 @@ struct octeon_ethernet {struct device_node *of_node; }; +struct oct_rx_group { +int irq; +int group; +struct napi_struct napi; +struct platform_device *pdev; +}; + +struct octeon_ethernet_platform { +struct platform_device *pdev; +struct delayed_work rx_refill_work; +struct oct_rx_group rx_group[16 ]; +}; +int cvm_oct_free_work (void *work_queue_entry);int cvm_oct_rgmii_open (struct net_device *dev);
Signature · 1 line
2.53.0