@@ -80,6 +80,14 @@ config IOSM
If unsure, say N.
+config IOSM_DEBUGFS
+ bool "IOSM Debugfs support"
+ depends on IOSM && DEBUG_FS
+ help
+ Enables debugfs driver interface for traces collection.
+
+ If unsure, say N.
+
endif # WWAN
endmenu
@@ -21,7 +21,9 @@ iosm-y = \
iosm_ipc_mux_codec.o \
iosm_ipc_devlink.o \
iosm_ipc_flash.o \
- iosm_ipc_coredump.o \
+ iosm_ipc_coredump.o
+
+iosm-$(CONFIG_IOSM_DEBUGFS) += \
iosm_ipc_debugfs.o \
iosm_ipc_trace.o
@@ -6,7 +6,12 @@
#ifndef IOSM_IPC_DEBUGFS_H
#define IOSM_IPC_DEBUGFS_H
+#ifdef CONFIG_IOSM_DEBUGFS
void ipc_debugfs_init(struct iosm_imem *ipc_imem);
void ipc_debugfs_deinit(struct iosm_imem *ipc_imem);
+#else
+static inline void ipc_debugfs_init(struct iosm_imem *ipc_imem) {}
+static inline void ipc_debugfs_deinit(struct iosm_imem *ipc_imem) {}
+#endif
#endif
@@ -274,7 +274,7 @@ static void ipc_imem_dl_skb_process(struct iosm_imem *ipc_imem,
ipc_imem_sys_devlink_notify_rx(ipc_imem->ipc_devlink,
skb);
else if (ipc_is_trace_channel(ipc_imem, port_id))
- ipc_trace_port_rx(ipc_imem->trace, skb);
+ ipc_trace_port_rx(ipc_imem, skb);
else
wwan_port_rx(ipc_imem->ipc_port[port_id]->iosm_port,
skb);
@@ -350,7 +350,9 @@ struct iosm_imem {
struct iosm_mux *mux;
struct iosm_cdev *ipc_port[IPC_MEM_MAX_CHANNELS];
struct iosm_pcie *pcie;
+#ifdef CONFIG_IOSM_DEBUGFS
struct iosm_trace *trace;
+#endif
struct device *dev;
enum ipc_mem_device_ipc_state ipc_requested_state;
struct ipc_mem_channel channels[IPC_MEM_MAX_CHANNELS];
@@ -380,7 +382,9 @@ struct iosm_imem {
ev_mux_net_transmit_pending:1,
reset_det_n:1,
pcie_wake_n:1;
+#ifdef CONFIG_IOSM_DEBUGFS
struct dentry *debugfs_dir;
+#endif
};
/**
@@ -17,11 +17,13 @@
/**
* ipc_trace_port_rx - Receive trace packet from cp and write to relay buffer
- * @ipc_trace: Pointer to the ipc trace data-struct
+ * @ipc_imem: Pointer to iosm_imem structure
* @skb: Pointer to struct sk_buff
*/
-void ipc_trace_port_rx(struct iosm_trace *ipc_trace, struct sk_buff *skb)
+void ipc_trace_port_rx(struct iosm_imem *ipc_imem, struct sk_buff *skb)
{
+ struct iosm_trace *ipc_trace = ipc_imem->trace;
+
if (ipc_trace->ipc_rchan)
relay_write(ipc_trace->ipc_rchan, skb->data, skb->len);
@@ -45,6 +45,8 @@ struct iosm_trace {
enum trace_ctrl_mode mode;
};
+#ifdef CONFIG_IOSM_DEBUGFS
+
static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id)
{
return ipc_mem->trace && ipc_mem->trace->chl_id == chl_id;
@@ -52,5 +54,21 @@ static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id)
struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem);
void ipc_trace_deinit(struct iosm_trace *ipc_trace);
-void ipc_trace_port_rx(struct iosm_trace *ipc_trace, struct sk_buff *skb);
+void ipc_trace_port_rx(struct iosm_imem *ipc_imem, struct sk_buff *skb);
+
+#else
+
+static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id)
+{
+ return false;
+}
+
+static inline void ipc_trace_port_rx(struct iosm_imem *ipc_imem,
+ struct sk_buff *skb)
+{
+ dev_kfree_skb(skb);
+}
+
+#endif
+
#endif
Collecting modem firmware traces is optional for the regular modem use. Some distros and users will want to disable this feature for security or kernel size reasons. So add a configuration option that allows to completely disable the driver debugfs interface. Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> --- drivers/net/wwan/Kconfig | 8 ++++++++ drivers/net/wwan/iosm/Makefile | 4 +++- drivers/net/wwan/iosm/iosm_ipc_debugfs.h | 5 +++++ drivers/net/wwan/iosm/iosm_ipc_imem.c | 2 +- drivers/net/wwan/iosm/iosm_ipc_imem.h | 4 ++++ drivers/net/wwan/iosm/iosm_ipc_trace.c | 6 ++++-- drivers/net/wwan/iosm/iosm_ipc_trace.h | 20 +++++++++++++++++++- 7 files changed, 44 insertions(+), 5 deletions(-)