net: wwan: debugfs support for wwan device logging
Subsystems (4)
v3 cover net: wwan: debugfs support for wwan device logging
This patch series brings in
1) A common debugfs base directory i.e. /sys/kernel/debugfs/wwan/ in WWAN Subsystem for a WWAN device instance.
2) And support for Device trace collection in IOSM Diver using relayfs interface.
Changes since v2:
PATCH1:
* Removed unnecessary checks & empty lines before error checks.
PATCH2:
* Removed empty lines before error checks.
Changes since v1:
PATCH1:
* Changes in WWAN Subsystem to support common debugfs base directory.
PATCH2:
* IOSM Driver adaption to get WWAN device dentry.
* Removed unnecessary checks.
M Chetan Kumar (2):
net: wwan: common debugfs base dir for wwan device
net: wwan: iosm: device trace collection using relayfs
drivers/net/wwan/iosm/Makefile | 3 +- drivers/net/wwan/iosm/iosm_ipc_imem.c | 13 ++ drivers/net/wwan/iosm/iosm_ipc_imem.h | 2 + drivers/net/wwan/iosm/iosm_ipc_imem_ops.c | 31 +++- drivers/net/wwan/iosm/iosm_ipc_imem_ops.h | 9 +- drivers/net/wwan/iosm/iosm_ipc_port.c | 2 +- drivers/net/wwan/iosm/iosm_ipc_trace.c | 173 ++++++++++++++++++++++ drivers/net/wwan/iosm/iosm_ipc_trace.h | 51 +++++++ drivers/net/wwan/wwan_core.c | 31 +++- include/linux/wwan.h | 2 + 10 files changed, 302 insertions(+), 15 deletions(-) create mode 100644 drivers/net/wwan/iosm/iosm_ipc_trace.c create mode 100644 drivers/net/wwan/iosm/iosm_ipc_trace.h
--
2.25.1
PATCH v3 1/2 net: wwan: common debugfs base dir for wwan device
This patch set brings in a common debugfs base directory i.e. /sys/kernel/debugfs/wwan/ in WWAN Subsystem for a WWAN device instance. So that it avoids driver polluting debugfs root with unrelated directories & possible name collusion.
Having a common debugfs base directory for WWAN drivers eases user to match control devices with debugfs entries.
WWAN Subsystem creates dentry (/sys/kernel/debugfs/wwan) on module load & removes dentry on module unload.
When driver registers a new wwan device, dentry (wwanX) is created for WWAN device instance & on driver unregister dentry is removed.
New API is introduced to return the wwan device instance dentry so that driver can create debugfs entries under it.
---
v3:
* Removed unnecessary checks & empty lines before error checks.
--- drivers/net/wwan/wwan_core.c | 31 +++++++++++++++++++++++++++++-- include/linux/wwan.h | 2 ++ 2 files changed, 31 insertions(+), 2 deletions(-)
drivers/net/wwan/wwan_core.c +28 -2
@@ -3,6 +3,7 @@#include <linux/err.h> #include <linux/errno.h> +#include <linux/debugfs.h> #include <linux/fs.h> #include <linux/init.h> #include <linux/idr.h>
@@ -25,6 +26,7 @@ static DEFINE_IDA(minors); /* minors for WWAN port chardevs */static DEFINE_IDA (wwan_dev_ids);/* for unique WWAN device IDs */ static struct class *wwan_class;static int wwan_major; +static struct dentry *wwan_debugfs_dir;#define to_wwan_dev (d) container_of(d, struct wwan_device, dev)#define to_wwan_port (d) container_of(d, struct wwan_port, dev)
@@ -40,6 +42,7 @@ static int wwan_major;* @port_id: Current available port ID to pick. * @ops: wwan device ops * @ops_ctxt: context to pass to ops +* @debugfs_dir: WWAN device debugfs dir */ struct wwan_device {unsigned int id;
@@ -47,6 +50,7 @@ struct wwan_device {atomic_t port_id;const struct wwan_ops *ops;void *ops_ctxt; +struct dentry *debugfs_dir; };/**
@@ -142,6 +146,18 @@ static struct wwan_device *wwan_dev_get_by_name(const char *name)return to_wwan_dev (dev); } +struct dentry *wwan_get_debugfs_dir (struct device *parent) +{ +struct wwan_device *wwandev; + + wwandev =wwan_dev_get_by_parent (parent); +if (IS_ERR (wwandev)) +return ERR_CAST (wwandev); + +return wwandev->debugfs_dir; +} +EXPORT_SYMBOL_GPL (wwan_get_debugfs_dir); +/* This function allocates and registers a new WWAN device OR if a WWAN device * already exist for the given parent, it gets a reference and return it. * This function is not exported (for now), it is called indirectly via
@@ -150,6 +166,7 @@ static struct wwan_device *wwan_dev_get_by_name(const char *name)static struct wwan_device *wwan_create_dev (struct device *parent) {struct wwan_device *wwandev; +const char *wwandev_name;int err, id;/* The 'find-alloc-register' operation must be protected against
@@ -189,6 +206,10 @@ static struct wwan_device *wwan_create_dev(struct device *parent) goto done_unlock; } + wwandev_name =kobject_name (&wwandev->dev.kobj); + wwandev->debugfs_dir =debugfs_create_dir (wwandev_name, + wwan_debugfs_dir); + done_unlock:mutex_unlock (&wwan_register_lock);
@@ -218,10 +236,12 @@ static void wwan_remove_dev(struct wwan_device *wwandev)else ret =device_for_each_child (&wwandev->dev,NULL , is_wwan_child); -if (!ret) +if (!ret) { +debugfs_remove_recursive (wwandev->debugfs_dir);device_unregister (&wwandev->dev); -else + }else {put_device (&wwandev->dev); + }mutex_unlock (&wwan_register_lock); }
@@ -1117,6 +1140,8 @@ static int __init wwan_init(void) goto destroy; } + wwan_debugfs_dir =debugfs_create_dir ("wwan" ,NULL ); +return 0 ; destroy:
@@ -1128,6 +1153,7 @@ static int __init wwan_init(void) static void __exit wwan_exit(void) { +debugfs_remove_recursive (wwan_debugfs_dir);__unregister_chrdev (wwan_major,0 ,WWAN_MAX_MINORS ,"wwan_port" );rtnl_link_unregister (&wwan_rtnl_link_ops);class_destroy (wwan_class);
include/linux/wwan.h +2 -0
@@ -171,4 +171,6 @@ int wwan_register_ops(struct device *parent, const struct wwan_ops *ops,void wwan_unregister_ops (struct device *parent); +struct dentry *wwan_get_debugfs_dir (struct device *parent); +#endif /* __WWAN_H */
--
2.25.1
Re: [PATCH V3 net-next 1/2] net: wwan: common debugfs base dir for wwan device
Quoted 13 lines · M Chetan Kumar
This patch set brings in a common debugfs base directory i.e.
/sys/kernel/debugfs/wwan/in WWAN Subsystem for a WWAN device instance. So that it avoids driver polluting debugfs root with unrelated directories & possible name collusion.Having a common debugfs base directory for WWAN drivers eases user to match control devices with debugfs entries.
WWAN Subsystem creates dentry (
/sys/kernel/debugfs/wwan) on module load & removes dentry on module unload.
Quoted 8 lines
When driver registers a new wwan device, dentry (wwanX) is created for WWAN device instance & on driver unregister dentry is removed.
New API is introduced to return the wwan device instance dentry so that driver can create debugfs entries under it.
Signed-off-by M Chetan Kumar <[email protected]>
Sergey Ryazanov
maintainerRe: [PATCH V3 net-next 1/2] net: wwan: common debugfs base dir for wwan device
In reply to M Chetan KumarHello,
Quoted 12 lines · M Chetan Kumar
This patch set brings in a common debugfs base directory i.e.
/sys/kernel/debugfs/wwan/in WWAN Subsystem for a WWAN device instance. So that it avoids driver polluting debugfs root with unrelated directories & possible name collusion.Having a common debugfs base directory for WWAN drivers eases user to match control devices with debugfs entries.
WWAN Subsystem creates dentry (
/sys/kernel/debugfs/wwan) on module load & removes dentry on module unload.
Quoted 6 lines
When driver registers a new wwan device, dentry (wwanX) is created for WWAN device instance & on driver unregister dentry is removed.
New API is introduced to return the wwan device instance dentry so that driver can create debugfs entries under it.
Thank you for taking care of the debugfs implementation for the WWAN core.
Please find my follow-up series that tweak the IOSM/WWAN debugfs interface a bit:
https://lore.kernel.org/all/[email protected]
Signature · 1 line
Sergey
PATCH v3 2/2 net: wwan: iosm: device trace collection using relayfs
In reply to M Chetan KumarThis patch brings in support for device trace collection. It implements relayfs interface for pushing device trace from kernel space to user space.
Driver gets the debugfs base directory associated to WWAN Device and creates trace_control and trace debugfs for device tracing. Both trace_control & trace debugfs are created under /sys/kernel/debug/wwan/wwan0/.
In order to collect device trace on trace0 interface, user need to write 1 to trace_ctl interface.
---
v3:
* Removed empty lines before error checks.
v2:
* IOSM Driver adaption to get WWAN device dentry.
* Removed unnecessary checks.
--- drivers/net/wwan/iosm/Makefile | 3 +- drivers/net/wwan/iosm/iosm_ipc_imem.c | 13 ++ drivers/net/wwan/iosm/iosm_ipc_imem.h | 2 + drivers/net/wwan/iosm/iosm_ipc_imem_ops.c | 31 +++- drivers/net/wwan/iosm/iosm_ipc_imem_ops.h | 9 +- drivers/net/wwan/iosm/iosm_ipc_port.c | 2 +- drivers/net/wwan/iosm/iosm_ipc_trace.c | 173 ++++++++++++++++++++++ drivers/net/wwan/iosm/iosm_ipc_trace.h | 51 +++++++ 8 files changed, 271 insertions(+), 13 deletions(-) create mode 100644 drivers/net/wwan/iosm/iosm_ipc_trace.c create mode 100644 drivers/net/wwan/iosm/iosm_ipc_trace.h
drivers/net/wwan/iosm/Makefile +2 -1
@@ -21,6 +21,7 @@ iosm-y = \ iosm_ipc_mux_codec.o \ iosm_ipc_devlink.o \ iosm_ipc_flash.o \ - iosm_ipc_coredump.o + iosm_ipc_coredump.o \ + iosm_ipc_trace.o obj-$(CONFIG_IOSM) := iosm.o
drivers/net/wwan/iosm/iosm_ipc_imem.c +13 -0
@@ -10,6 +10,7 @@#include "iosm_ipc_flash.h" #include "iosm_ipc_imem.h" #include "iosm_ipc_port.h" +#include "iosm_ipc_trace.h" /* Check the wwan ips if it is valid with Channel as input. */ static int ipc_imem_check_wwan_ips (struct ipc_mem_channel *chnl)
@@ -265,9 +266,14 @@ static void ipc_imem_dl_skb_process(struct iosm_imem *ipc_imem,switch (pipe->channel->ctype) {case IPC_CTYPE_CTRL : port_id = pipe->channel->channel_id; +ipc_pcie_addr_unmap (ipc_imem->pcie,IPC_CB (skb)->len, +IPC_CB (skb)->mapping, +IPC_CB (skb)->direction);if (port_id ==IPC_MEM_CTRL_CHL_ID_7 )ipc_imem_sys_devlink_notify_rx (ipc_imem->ipc_devlink, skb); +else if (port_id == ipc_imem->trace->chl_id) +ipc_trace_port_rx (ipc_imem->trace, skb);else wwan_port_rx (ipc_imem->ipc_port[port_id]->iosm_port, skb);
@@ -548,6 +554,12 @@ static void ipc_imem_run_state_worker(struct work_struct *instance) ctrl_chl_idx++; } + ipc_imem->trace =ipc_imem_trace_channel_init (ipc_imem); +if (!ipc_imem->trace) { +dev_err (ipc_imem->dev,"trace channel init failed" ); +return ; + } +ipc_task_queue_send_task (ipc_imem, ipc_imem_send_mdm_rdy_cb,0 ,NULL ,0 , false);
@@ -1163,6 +1175,7 @@ void ipc_imem_cleanup(struct iosm_imem *ipc_imem)if (test_and_clear_bit (FULLY_FUNCTIONAL , &ipc_imem->flag)) {ipc_mux_deinit (ipc_imem->mux); +ipc_trace_deinit (ipc_imem->trace);ipc_wwan_deinit (ipc_imem->wwan);ipc_port_deinit (ipc_imem->ipc_port); }
drivers/net/wwan/iosm/iosm_ipc_imem.h +2 -0
@@ -304,6 +304,7 @@ enum ipc_phase {* @sio: IPC SIO data structure pointer * @ipc_port: IPC PORT data structure pointer * @pcie: IPC PCIe +* @trace: IPC trace data structure pointer * @dev: Pointer to device structure * @ipc_requested_state: Expected IPC state on CP. * @channels: Channel list with UL/DL pipe pairs.
@@ -349,6 +350,7 @@ struct iosm_imem {struct iosm_mux *mux;struct iosm_cdev *ipc_port[IPC_MEM_MAX_CHANNELS ];struct iosm_pcie *pcie; +struct iosm_trace *trace;struct device *dev;enum ipc_mem_device_ipc_state ipc_requested_state;struct ipc_mem_channel channels[IPC_MEM_MAX_CHANNELS ];
drivers/net/wwan/iosm/iosm_ipc_imem_ops.c +26 -5
@@ -11,6 +11,7 @@#include "iosm_ipc_imem_ops.h" #include "iosm_ipc_port.h" #include "iosm_ipc_task_queue.h" +#include "iosm_ipc_trace.h" /* Open a packet data online channel between the network layer and CP. */ int ipc_imem_sys_wwan_open (struct iosm_imem *ipc_imem,int if_id)
@@ -107,6 +108,23 @@ void ipc_imem_wwan_channel_init(struct iosm_imem *ipc_imem, "failed to register the ipc_wwan interfaces"); } +/** +* ipc_imem_trace_channel_init - Initializes trace channel. +* @ipc_imem: Pointer to iosm_imem struct. +* +* Returns: Pointer to trace instance on success else NULL +*/ +struct iosm_trace *ipc_imem_trace_channel_init (struct iosm_imem *ipc_imem) +{ +struct ipc_chnl_cfg chnl_cfg = {0 }; + +ipc_chnl_cfg_get (&chnl_cfg,IPC_MEM_CTRL_CHL_ID_3 ); +ipc_imem_channel_init (ipc_imem,IPC_CTYPE_CTRL , chnl_cfg, +IRQ_MOD_OFF ); + +return ipc_trace_init (ipc_imem); +} +/* Map SKB to DMA for transfer */ static int ipc_imem_map_skb_to_dma (struct iosm_imem *ipc_imem,struct sk_buff *skb)
@@ -182,11 +200,14 @@ static bool ipc_imem_is_channel_active(struct iosm_imem *ipc_imem,return false; } -/* Release a sio link to CP. */ -void ipc_imem_sys_cdev_close (struct iosm_cdev *ipc_cdev) +/** +* ipc_imem_sys_port_close - Release a sio link to CP. +* @ipc_imem: Imem instance. +* @channel: Channel instance. +*/ +void ipc_imem_sys_port_close (struct iosm_imem *ipc_imem, +struct ipc_mem_channel *channel) { -struct iosm_imem *ipc_imem = ipc_cdev->ipc_imem; -struct ipc_mem_channel *channel = ipc_cdev->channel;enum ipc_phase curr_phase;int status =0 ;u32 tail =0 ;
@@ -643,6 +664,6 @@ int ipc_imem_sys_devlink_read(struct iosm_devlink *devlink, u8 *data,memcpy (data, skb->data, skb->len); devlink_read_fail: -ipc_pcie_kfree_skb (devlink->pcie, skb); +dev_kfree_skb (skb);return rc; }
drivers/net/wwan/iosm/iosm_ipc_imem_ops.h +3 -6
@@ -43,12 +43,8 @@*/ struct ipc_mem_channel *ipc_imem_sys_port_open (struct iosm_imem *ipc_imem,int chl_id,int hp_id); - -/** -* ipc_imem_sys_cdev_close - Release a sio link to CP. -* @ipc_cdev: iosm sio instance. -*/ -void ipc_imem_sys_cdev_close (struct iosm_cdev *ipc_cdev); +void ipc_imem_sys_port_close (struct iosm_imem *ipc_imem, +struct ipc_mem_channel *channel);/** * ipc_imem_sys_cdev_write - Route the uplink buffer to CP.
@@ -145,4 +141,5 @@ int ipc_imem_sys_devlink_read(struct iosm_devlink *ipc_devlink, u8 *data,*/ int ipc_imem_sys_devlink_write (struct iosm_devlink *ipc_devlink,unsigned char *buf,int count); +struct iosm_trace *ipc_imem_trace_channel_init (struct iosm_imem *ipc_imem);#endif
drivers/net/wwan/iosm/iosm_ipc_port.c +1 -1
@@ -27,7 +27,7 @@ static void ipc_port_ctrl_stop(struct wwan_port *port) {struct iosm_cdev *ipc_port =wwan_port_get_drvdata (port); -ipc_imem_sys_cdev_close (ipc_port); +ipc_imem_sys_port_close (ipc_port->ipc_imem, ipc_port->channel); }/* transfer control data to modem */
drivers/net/wwan/iosm/iosm_ipc_trace.c new file +173 -0
173 lines not on this page · raw message
drivers/net/wwan/iosm/iosm_ipc_trace.h new file +51 -0
51 lines not on this page · raw message
--
2.25.1