net: wwan: t7xx: Add port for modem logging
PATCH v3 1/1 net: wwan: t7xx: Add port for modem logging
From: Moises Veleta <[email protected]>
The Modem Logging (MDL) port provides an interface to collect modem logs for debugging purposes. MDL is supported by the relay interface, and the mtk_t7xx port infrastructure. MDL allows user-space apps to control logging via mbim command and to collect logs via the relay interface, while port infrastructure facilitates communication between the driver and the modem.
--
v3:
* Return if wwan_get_debugfs_dir() returns error.
v2
* Removed debugfs control port.
* Initialize in Notify function upon handshake completion.
* Remove trace write function, MBIM will send commands.
--- drivers/net/wwan/Kconfig | 1 + drivers/net/wwan/t7xx/Makefile | 3 + drivers/net/wwan/t7xx/t7xx_hif_cldma.c | 2 + drivers/net/wwan/t7xx/t7xx_port.h | 5 ++ drivers/net/wwan/t7xx/t7xx_port_proxy.c | 12 +++ drivers/net/wwan/t7xx/t7xx_port_proxy.h | 4 + drivers/net/wwan/t7xx/t7xx_port_trace.c | 112 ++++++++++++++++++++++++ 7 files changed, 139 insertions(+) create mode 100644 drivers/net/wwan/t7xx/t7xx_port_trace.c
drivers/net/wwan/Kconfig +1 -0
@@ -108,6 +108,7 @@ config IOSM config MTK_T7XX tristate "MediaTek PCIe 5G WWAN modem T7xx device" depends on PCI + select RELAY if WWAN_DEBUGFS help Enables MediaTek PCIe based 5G WWAN modem (T7xx series) device. Adapts WWAN framework and provides network interface like wwan0
drivers/net/wwan/t7xx/Makefile +3 -0
@@ -18,3 +18,6 @@ mtk_t7xx-y:= t7xx_pci.o \ t7xx_hif_dpmaif_rx.o \ t7xx_dpmaif.o \ t7xx_netdev.o + +mtk_t7xx-$(CONFIG_WWAN_DEBUGFS) += \ + t7xx_port_trace.o \
drivers/net/wwan/t7xx/t7xx_hif_cldma.c +2 -0
@@ -1018,6 +1018,8 @@ static int t7xx_cldma_late_init(struct cldma_ctrl *md_ctrl)dev_err (md_ctrl->dev,"control TX ring init fail\n" ); goto err_free_tx_ring; } + + md_ctrl->tx_ring[i].pkt_size =CLDMA_MTU ; }for (j =0 ; j <CLDMA_RXQ_NUM ; j++) {
drivers/net/wwan/t7xx/t7xx_port.h +5 -0
@@ -122,6 +122,11 @@ struct t7xx_port {int rx_length_th;bool chan_enable;struct task_struct *thread; +#ifdef CONFIG_WWAN_DEBUGFS +void *relaych; +struct dentry *debugfs_dir; +struct dentry *debugfs_wwan_dir; +#endif };struct sk_buff *t7xx_port_alloc_skb (int payload);
drivers/net/wwan/t7xx/t7xx_port_proxy.c +12 -0
@@ -70,6 +70,18 @@ static const struct t7xx_port_conf t7xx_md_port_conf[] = { .name = "MBIM", .port_type = WWAN_PORT_MBIM, }, { +#ifdef CONFIG_WWAN_DEBUGFS + .tx_ch = PORT_CH_MD_LOG_TX, + .rx_ch = PORT_CH_MD_LOG_RX, + .txq_index = 7, + .rxq_index = 7, + .txq_exp_index = 7, + .rxq_exp_index = 7, + .path_id = CLDMA_ID_MD, + .ops = &t7xx_trace_port_ops, + .name = "mdlog", + }, { +#endif .tx_ch = PORT_CH_CONTROL_TX, .rx_ch = PORT_CH_CONTROL_RX, .txq_index = Q_IDX_CTRL,
drivers/net/wwan/t7xx/t7xx_port_proxy.h +4 -0
@@ -87,6 +87,10 @@ struct ctrl_msg_header {extern struct port_ops wwan_sub_port_ops;extern struct port_ops ctl_port_ops; +#ifdef CONFIG_WWAN_DEBUGFS +extern struct port_ops t7xx_trace_port_ops; +#endif +void t7xx_port_proxy_reset (struct port_proxy *port_prox);void t7xx_port_proxy_uninit (struct port_proxy *port_prox);int t7xx_port_proxy_init (struct t7xx_modem *md);
drivers/net/wwan/t7xx/t7xx_port_trace.c new file +112 -0
112 lines not on this page · raw message
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerQuoted 8 lines · On Mon, 3 Oct 2022 15:27:25 +0530 [email protected] wrote:
From: Moises Veleta <[email protected]>
The Modem Logging (MDL) port provides an interface to collect modem logs for debugging purposes. MDL is supported by the relay interface, and the
mtk_t7xxport infrastructure. MDL allows user-space apps to control logging via mbim command and to collect logs via the relay interface, while port infrastructure facilitates communication between the driver and the modem.
net-next is closed, please repost once Linus tags 6.1-rc1
Sergey Ryazanov
maintainerHello Chetan,
Quoted 6 lines · On Mon, Oct 3, 2022 at 8:29 AM <[email protected]> wrote:
The Modem Logging (MDL) port provides an interface to collect modem logs for debugging purposes. MDL is supported by the relay interface, and the
mtk_t7xxport infrastructure. MDL allows user-space apps to control logging via mbim command and to collect logs via the relay interface, while port infrastructure facilitates communication between the driver and the modem.
[skip]
drivers/net/wwan/t7xx/t7xx_port.h struct t7xx_port { · line 128
Quoted 12 lines
drivers/net/wwan/t7xx/t7xx_port.h +4
-0@@ -122,6 +122,11 @@ struct t7xx_port {int rx_length_th;bool chan_enable;struct task_struct *thread; +#ifdef CONFIG_WWAN_DEBUGFS +void *relaych; +struct dentry *debugfs_dir; +struct dentry *debugfs_wwan_dir;
Both of these debugfs directories are device-wide, why did you place these pointers in the item port context?
Signature · 1 line
Sergey
Hi Sergey,
Quoted 12 lines · Sergey Ryazanov
Hello Chetan,
Quoted 6 lines · On Mon, Oct 3, 2022 at 8:29 AM <[email protected]> wrote:
The Modem Logging (MDL) port provides an interface to collect modem logs for debugging purposes. MDL is supported by the relay interface, and the
mtk_t7xxport infrastructure. MDL allows user-space apps to control logging via mbim command and to collect logs via the relay interface, while port infrastructure facilitates communication between the driver and the modem.[skip]
Quoted 16 lines
drivers/net/wwan/t7xx/t7xx_port.h struct t7xx_port { · line 128
Quoted 12 lines
drivers/net/wwan/t7xx/t7xx_port.h +4
-0@@ -122,6 +122,11 @@ struct t7xx_port {int rx_length_th;bool chan_enable;struct task_struct *thread; +#ifdef CONFIG_WWAN_DEBUGFS +void *relaych; +struct dentry *debugfs_dir; +struct dentry *debugfs_wwan_dir;Both of these debugfs directories are device-wide, why did you place these pointers in the item port context?
I guess it was kept inside port so that it could be accessed directly from port context.
Thanks for pointing it out. I think we should move out the complete #ifdef CONFIG_WWAN_DEBUGFS block of port container.
I am planning to add trace.h file and put changes under it.
Below is the new code changes [1]. I am yet to verify. Please share your comments.
[1]
drivers/net/wwan/t7xx/t7xx_pci.h +3 -0
@@ -24,6 +24,7 @@#include <linux/spinlock.h> #include <linux/types.h> +#include "t7xx_port_trace.h" #include "t7xx_reg.h" /* struct t7xx_addr_base - holds base addresses
@@ -59,6 +60,7 @@ typedef irqreturn_t (*t7xx_intr_callback)(int irq, void *param);* @md_pm_lock: protects PCIe sleep lock * @sleep_disable_count: PCIe L1.2 lock counter * @sleep_lock_acquire: indicates that sleep has been disabled +* @trace: relayfs and debugfs data struct */ struct t7xx_pci_dev {t7xx_intr_callback intr_handler[EXT_INT_NUM ];
@@ -78,6 +80,7 @@ struct t7xx_pci_dev {spinlock_t md_pm_lock;/* Protects PCI resource lock */ unsigned int sleep_disable_count;struct completion sleep_lock_acquire; +struct t7xx_trace trace; };enum t7xx_pm_id {
drivers/net/wwan/t7xx/t7xx_port.h +0 -5
@@ -122,11 +122,6 @@ struct t7xx_port {int rx_length_th;bool chan_enable;struct task_struct *thread; -#ifdef CONFIG_WWAN_DEBUGFS -void *relaych; -struct dentry *debugfs_dir; -struct dentry *debugfs_wwan_dir; -#endif };struct sk_buff *t7xx_port_alloc_skb (int payload);
drivers/net/wwan/t7xx/t7xx_port_proxy.c +1 -0
@@ -35,6 +35,7 @@#include "t7xx_modem_ops.h" #include "t7xx_port.h" #include "t7xx_port_proxy.h" +#include "t7xx_port_trace.h" #include "t7xx_state_monitor.h" #define Q_IDX_CTRL 0
drivers/net/wwan/t7xx/t7xx_port_proxy.h +0 -3
@@ -87,9 +87,6 @@ struct ctrl_msg_header {extern struct port_ops wwan_sub_port_ops;extern struct port_ops ctl_port_ops; -#ifdef CONFIG_WWAN_DEBUGFS -extern struct port_ops t7xx_trace_port_ops; -#endif void t7xx_port_proxy_reset (struct port_proxy *port_prox);void t7xx_port_proxy_uninit (struct port_proxy *port_prox);
+++ b/drivers/net/wwan/t7xx/t7xx_port_trace.h
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2022 Intel Corporation.
+ */
+
+#ifndef __T7XX_PORT_TRACE_H__
+#define __T7XX_PORT_TRACE_H__
+
+struct t7xx_trace {
+#ifdef CONFIG_WWAN_DEBUGFS
+ void *relaych; + struct dentry *debugfs_dir; + struct dentry *debugfs_wwan_dir;
+#endif
+};
+
+#ifdef CONFIG_WWAN_DEBUGFS
+extern struct port_ops t7xx_trace_port_ops;
+#endif
+
+#endif /* __T7XX_PORT_TRACE_H__ */
drivers/net/wwan/t7xx/t7xx_port_trace.c +6 -5
@@ -10,6 +10,7 @@#include "t7xx_port.h" #include "t7xx_port_proxy.h" +#include "t7xx_port_trace.h" #include "t7xx_state_monitor.h" #define T7XX_TRC_SUB_BUFF_SIZE 131072
@@ -51,19 +52,19 @@ static struct rchan_callbacks relay_callbacks = {static void t7xx_trace_port_uninit (struct t7xx_port *port) { -struct rchan *relaych = port->relaych; +struct t7xx_trace *trace = &port->t7xx_dev->trace; -if (!relaych) +if (!trace->relaych)return ; -relay_close (relaych); -debugfs_remove_recursive (port->debugfs_dir); -wwan_put_debugfs_dir (port->debugfs_wwan_dir); +relay_close (trace->relaych); +debugfs_remove_recursive (trace->debugfs_dir); +wwan_put_debugfs_dir (trace->debugfs_wwan_dir); } static int t7xx_trace_port_recv_skb(struct t7xx_port *port, struct
sk_buff *skb)
{
- struct rchan *relaych = port->relaych;
+ struct rchan *relaych = port->t7xx_dev->trace.relaych;
if (!relaych)
return -EINVAL;
@@ -75,33 +76,34 @@ static int t7xx_trace_port_recv_skb(struct t7xx_port *port, struct sk_buff *skb)
static void t7xx_port_trace_md_state_notify(struct t7xx_port *port,
unsigned int state)
{
+ struct t7xx_trace *trace = &port->t7xx_dev->trace;
struct rchan *relaych;
- if (state != MD_STATE_READY || port->relaych) + if (state != MD_STATE_READY || trace->relaych)
return;
- port->debugfs_wwan_dir = wwan_get_debugfs_dir(port->dev);
- if (IS_ERR(port->debugfs_wwan_dir))
+ trace->debugfs_wwan_dir = wwan_get_debugfs_dir(port->dev);
+ if (IS_ERR(trace->debugfs_wwan_dir))
return;
- port->debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, port->debugfs_wwan_dir);
- if (IS_ERR_OR_NULL(port->debugfs_dir)) {
- wwan_put_debugfs_dir(port->debugfs_wwan_dir);
+ trace->debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, trace->debugfs_wwan_dir);
+ if (IS_ERR_OR_NULL(trace->debugfs_dir)) {
+ wwan_put_debugfs_dir(trace->debugfs_wwan_dir);
dev_err(port->dev, "Unable to create debugfs for trace"); return;
}
- relaych = relay_open("relay_ch", port->debugfs_dir, T7XX_TRC_SUB_BUFF_SIZE,
+ relaych = relay_open("relay_ch", trace->debugfs_dir, T7XX_TRC_SUB_BUFF_SIZE,
T7XX_TRC_N_SUB_BUFF, &relay_callbacks, NULL);
if (!relaych)
goto err_rm_debugfs_dir;
- port->relaych = relaych;
+ trace->relaych = relaych;
return;
err_rm_debugfs_dir:
- debugfs_remove_recursive(port->debugfs_dir);
- wwan_put_debugfs_dir(port->debugfs_wwan_dir);
+ debugfs_remove_recursive(trace->debugfs_dir);
+ wwan_put_debugfs_dir(trace->debugfs_wwan_dir);
dev_err(port->dev, "Unable to create trace port %s",port->port_conf->name);
}
Signature · 1 line
Chetan
Sergey Ryazanov
maintainerQuoted 27 lines · M Chetan
Quoted 10 lines · Sergey Ryazanov
Quoted 10 lines
Quoted 10 lines · On Mon, Oct 3, 2022 at 8:29 AM <[email protected]> wrote:
Quoted 6 lines
The Modem Logging (MDL) port provides an interface to collect modem logs for debugging purposes. MDL is supported by the relay interface, and the
mtk_t7xxport infrastructure. MDL allows user-space apps to control logging via mbim command and to collect logs via the relay interface, while port infrastructure facilitates communication between the driver and the modem.[skip]
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/wwan/t7xx/t7xx_port.h +0
-0@@ -122,6 +122,11 @@ struct t7xx_port {int rx_length_th;bool chan_enable;Quoted 8 lines
Quoted 8 lines
drivers/net/wwan/t7xx/t7xx_port.h struct t7xx_port { · line 128
Quoted 5 lines
drivers/net/wwan/t7xx/t7xx_port.h +4
-0struct task_struct *thread; +#ifdef CONFIG_WWAN_DEBUGFS +void *relaych; +struct dentry *debugfs_dir; +struct dentry *debugfs_wwan_dir;Both of these debugfs directories are device-wide, why did you place these pointers in the item port context?
Quoted 5 lines
I guess it was kept inside port so that it could be accessed directly from port context.
Thanks for pointing it out. I think we should move out the complete #ifdef
CONFIG_WWAN_DEBUGFSblock of port container.
Moving out debugfs directory pointers sounds like a good idea. Introduction of any new debugfs knob will be a much easier if these pointers are available in some device-wide state container. But the relaych pointer looks like a logging port specific element. Why should it be moved out?
Quoted 1 line
I am planning to add
trace.hfile and put changes under it.
The word 'trace' usually used for entities related to use of the kernel tracing framework, i.e. driver itself tracing. If you really need this dedicated header, can we entitle it like 'mdm_log' or 'logging' or something like that?
Quoted 84 lines
Below is the new code changes [1]. I am yet to verify. Please share your comments.
[1]
drivers/net/wwan/t7xx/t7xx_pci.h +2
-0@@ -24,6 +24,7 @@#include <linux/spinlock.h> #include <linux/types.h> +#include "t7xx_port_trace.h" #include "t7xx_reg.h" /* struct t7xx_addr_base - holds base addresses @@ -59,6 +60,7 @@ typedef irqreturn_t (*t7xx_intr_callback)(int irq,void *param); * @md_pm_lock: protects PCIe sleep lock * @sleep_disable_count: PCIe L1.2 lock counter * @sleep_lock_acquire: indicates that sleep has been disabled +* @trace: relayfs and debugfs data struct */ struct t7xx_pci_dev {t7xx_intr_callback intr_handler[EXT_INT_NUM];drivers/net/wwan/t7xx/t7xx_pci.h +1
-0@@ -78,6 +80,7 @@ struct t7xx_pci_dev {spinlock_t md_pm_lock;/* Protects PCI resource lock */ unsigned int sleep_disable_count;struct completion sleep_lock_acquire; +struct t7xx_trace trace; };enum t7xx_pm_id {drivers/net/wwan/t7xx/t7xx_port.h +0
-5@@ -122,11 +122,6 @@ struct t7xx_port {int rx_length_th;bool chan_enable;struct task_struct *thread; -#ifdef CONFIG_WWAN_DEBUGFS -void *relaych; -struct dentry *debugfs_dir; -struct dentry *debugfs_wwan_dir; -#endif };struct sk_buff *t7xx_port_alloc_skb (int payload);drivers/net/wwan/t7xx/t7xx_port_proxy.c +1
-0@@ -35,6 +35,7 @@#include "t7xx_modem_ops.h" #include "t7xx_port.h" #include "t7xx_port_proxy.h" +#include "t7xx_port_trace.h" #include "t7xx_state_monitor.h" #define Q_IDX_CTRL 0drivers/net/wwan/t7xx/t7xx_port_proxy.h +6
-3@@ -87,9 +87,6 @@ struct ctrl_msg_header {extern struct port_ops wwan_sub_port_ops;extern struct port_ops ctl_port_ops; -#ifdef CONFIG_WWAN_DEBUGFS -extern struct port_ops t7xx_trace_port_ops; -#endif void t7xx_port_proxy_reset (struct port_proxy *port_prox);void t7xx_port_proxy_uninit (struct port_proxy *port_prox); +++ b/drivers/net/wwan/t7xx/t7xx_port_trace.h@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2022 Intel Corporation. +*/ +
drivers/net/wwan/t7xx/t7xx_port_proxy.h line 15
Quoted 10 lines
drivers/net/wwan/t7xx/t7xx_port_proxy.h +10
-0+#ifndef __T7XX_PORT_TRACE_H__ +#define __T7XX_PORT_TRACE_H__ + +struct t7xx_trace { +#ifdef CONFIG_WWAN_DEBUGFS +void *relaych; +struct dentry *debugfs_dir; +struct dentry *debugfs_wwan_dir; +#endif +};
The relaych pointer is port specific, so it can be left in the port structure. We do not need to keep the debugfs_dir pointer. It is only needed during debugfs initialization to create the modem-specific subdirectory. So it can be a local variable. There is only one debugfs_wwan_dir pointer left, which can be placed somewhere in the t7xx_modem structure.
Quoted 97 lines
drivers/net/wwan/t7xx/t7xx_port_proxy.h +5
-0+#ifdef CONFIG_WWAN_DEBUGFS +extern struct port_ops t7xx_trace_port_ops; +#endif + +#endif /* __T7XX_PORT_TRACE_H__ */ drivers/net/wwan/t7xx/t7xx_port_trace.c +7
-6@@ -10,6 +10,7 @@#include "t7xx_port.h" #include "t7xx_port_proxy.h" +#include "t7xx_port_trace.h" #include "t7xx_state_monitor.h" #define T7XX_TRC_SUB_BUFF_SIZE 131072@@ -51,19 +52,19 @@ static struct rchan_callbacks relay_callbacks = {static void t7xx_trace_port_uninit (struct t7xx_port *port) { -struct rchan *relaych = port->relaych; +struct t7xx_trace *trace = &port->t7xx_dev->trace; -if (!relaych) +if (!trace->relaych)return ; -relay_close (relaych); -debugfs_remove_recursive (port->debugfs_dir); -wwan_put_debugfs_dir (port->debugfs_wwan_dir); +relay_close (trace->relaych); +debugfs_remove_recursive (trace->debugfs_dir); +wwan_put_debugfs_dir (trace->debugfs_wwan_dir); }static int t7xx_trace_port_recv_skb (struct t7xx_port *port,struct sk_buff *skb) { -struct rchan *relaych = port->relaych; +struct rchan *relaych = port->t7xx_dev->trace.relaych;if (!relaych)return -EINVAL;drivers/net/wwan/t7xx/t7xx_port_trace.c +9
-8@@ -75,33 +76,34 @@ static int t7xx_trace_port_recv_skb(struct t7xx_port *port, struct sk_buff *skb)static void t7xx_port_trace_md_state_notify (struct t7xx_port *port,unsigned int state) { +struct t7xx_trace *trace = &port->t7xx_dev->trace;struct rchan *relaych; -if (state !=MD_STATE_READY || port->relaych) +if (state !=MD_STATE_READY || trace->relaych)return ; - port->debugfs_wwan_dir =wwan_get_debugfs_dir (port->dev); -if (IS_ERR (port->debugfs_wwan_dir)) + trace->debugfs_wwan_dir =wwan_get_debugfs_dir (port->dev); +if (IS_ERR (trace->debugfs_wwan_dir))return ; - port->debugfs_dir =debugfs_create_dir (KBUILD_MODNAME , port->debugfs_wwan_dir); -if (IS_ERR_OR_NULL (port->debugfs_dir)) { -wwan_put_debugfs_dir (port->debugfs_wwan_dir); + trace->debugfs_dir =debugfs_create_dir (KBUILD_MODNAME , trace->debugfs_wwan_dir); +if (IS_ERR_OR_NULL (trace->debugfs_dir)) { +wwan_put_debugfs_dir (trace->debugfs_wwan_dir);dev_err (port->dev,"Unable to create debugfs for trace" );return ; } - relaych =relay_open ("relay_ch" , port->debugfs_dir,T7XX_TRC_SUB_BUFF_SIZE , + relaych =relay_open ("relay_ch" , trace->debugfs_dir,T7XX_TRC_SUB_BUFF_SIZE ,T7XX_TRC_N_SUB_BUFF , &relay_callbacks,NULL );if (!relaych) goto err_rm_debugfs_dir; - port->relaych = relaych; + trace->relaych = relaych;return ;
err_rm_debugfs_dir:drivers/net/wwan/t7xx/t7xx_port_trace.c +2
-2-debugfs_remove_recursive (port->debugfs_dir); -wwan_put_debugfs_dir (port->debugfs_wwan_dir); +debugfs_remove_recursive (trace->debugfs_dir); +wwan_put_debugfs_dir (trace->debugfs_wwan_dir); dev_err(port->dev, "Unable to create trace port %s",
port->port_conf->name);
}
Signature · 1 line
Sergey
Quoted 32 lines · Sergey Ryazanov
Quoted 30 lines · M Chetan
Quoted 10 lines · Sergey Ryazanov
Quoted 10 lines
Quoted 10 lines · On Mon, Oct 3, 2022 at 8:29 AM <[email protected]> wrote:
Quoted 6 lines
The Modem Logging (MDL) port provides an interface to collect modem logs for debugging purposes. MDL is supported by the relay interface, and the
mtk_t7xxport infrastructure. MDL allows user-space apps to control logging via mbim command and to collect logs via the relay interface, while port infrastructure facilitates communication between the driver and the modem.[skip]
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/wwan/t7xx/t7xx_port.h +0
-0@@ -122,6 +122,11 @@ struct t7xx_port {int rx_length_th;bool chan_enable;Quoted 8 lines
Quoted 8 lines
drivers/net/wwan/t7xx/t7xx_port.h struct t7xx_port { · line 128
Quoted 5 lines
drivers/net/wwan/t7xx/t7xx_port.h +4
-0struct task_struct *thread; +#ifdef CONFIG_WWAN_DEBUGFS +void *relaych; +struct dentry *debugfs_dir; +struct dentry *debugfs_wwan_dir;Both of these debugfs directories are device-wide, why did you place these pointers in the item port context?
I guess it was kept inside port so that it could be accessed directly from port context.
Quoted 8 lines
Quoted 2 lines
Thanks for pointing it out. I think we should move out the complete #ifdef
CONFIG_WWAN_DEBUGFSblock of port container.Moving out debugfs directory pointers sounds like a good idea. Introduction of any new debugfs knob will be a much easier if these pointers are available in some device-wide state container. But the relaych pointer looks like a logging port specific element. Why should it be moved out?
t7xx_port is a common port container. keeping relaych pointer inside port container is like having relaych pointer for all port instance (AT/MBIM) though it is not required for others. So planning to move out.
You suggest to keep it or move out ?
Quoted 100 lines
Quoted 2 lines
I am planning to add
trace.hfile and put changes under it.The word 'trace' usually used for entities related to use of the kernel tracing framework, i.e. driver itself tracing. If you really need this dedicated header, can we entitle it like '
mdm_log' or 'logging' or something like that? >Quoted 93 lines
Below is the new code changes [1]. I am yet to verify. Please share your comments.
[1]
drivers/net/wwan/t7xx/t7xx_pci.h +2
-0@@ -24,6 +24,7 @@#include <linux/spinlock.h> #include <linux/types.h> +#include "t7xx_port_trace.h" #include "t7xx_reg.h" /* struct t7xx_addr_base - holds base addresses @@ -59,6 +60,7 @@ typedef irqreturn_t (*t7xx_intr_callback)(int irq,void *param); * @md_pm_lock: protects PCIe sleep lock * @sleep_disable_count: PCIe L1.2 lock counter * @sleep_lock_acquire: indicates that sleep has been disabled +* @trace: relayfs and debugfs data struct */ struct t7xx_pci_dev {t7xx_intr_callback intr_handler[EXT_INT_NUM];drivers/net/wwan/t7xx/t7xx_pci.h +1
-0@@ -78,6 +80,7 @@ struct t7xx_pci_dev {spinlock_t md_pm_lock;/* Protects PCI resource lock */ unsigned int sleep_disable_count;struct completion sleep_lock_acquire; +struct t7xx_trace trace; };enum t7xx_pm_id {drivers/net/wwan/t7xx/t7xx_port.h +0
-5@@ -122,11 +122,6 @@ struct t7xx_port {int rx_length_th;bool chan_enable;struct task_struct *thread; -#ifdef CONFIG_WWAN_DEBUGFS -void *relaych; -struct dentry *debugfs_dir; -struct dentry *debugfs_wwan_dir; -#endif };struct sk_buff *t7xx_port_alloc_skb (int payload);drivers/net/wwan/t7xx/t7xx_port_proxy.c +1
-0@@ -35,6 +35,7 @@#include "t7xx_modem_ops.h" #include "t7xx_port.h" #include "t7xx_port_proxy.h" +#include "t7xx_port_trace.h" #include "t7xx_state_monitor.h" #define Q_IDX_CTRL 0drivers/net/wwan/t7xx/t7xx_port_proxy.h +15
-3@@ -87,9 +87,6 @@ struct ctrl_msg_header {extern struct port_ops wwan_sub_port_ops;extern struct port_ops ctl_port_ops; -#ifdef CONFIG_WWAN_DEBUGFS -extern struct port_ops t7xx_trace_port_ops; -#endif void t7xx_port_proxy_reset (struct port_proxy *port_prox);void t7xx_port_proxy_uninit (struct port_proxy *port_prox); +++ b/drivers/net/wwan/t7xx/t7xx_port_trace.h@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2022 Intel Corporation. +*/ + +#ifndef __T7XX_PORT_TRACE_H__ +#define __T7XX_PORT_TRACE_H__ + +struct t7xx_trace { +#ifdef CONFIG_WWAN_DEBUGFS + void *relaych; + struct dentry *debugfs_dir; + struct dentry *debugfs_wwan_dir; +#endif
Quoted 8 lines
drivers/net/wwan/t7xx/t7xx_port_proxy.h line 15
Quoted 1 line
drivers/net/wwan/t7xx/t7xx_port_proxy.h +1
-0+};The relaych pointer is port specific, so it can be left in the port structure. We do not need to keep the
debugfs_dirpointer. It is only needed during debugfs initialization to create the modem-specific subdirectory. So it can be a local variable. There is only onedebugfs_wwan_dirpointer left, which can be placed somewhere in thet7xx_modemstructure.
Ok. Will drop debugfs_dir and use local var instead.
Quoted 99 lines
Quoted 98 lines
drivers/net/wwan/t7xx/t7xx_port_proxy.h +5
-0+#ifdef CONFIG_WWAN_DEBUGFS +extern struct port_ops t7xx_trace_port_ops; +#endif + +#endif /* __T7XX_PORT_TRACE_H__ */ drivers/net/wwan/t7xx/t7xx_port_trace.c +7
-6@@ -10,6 +10,7 @@#include "t7xx_port.h" #include "t7xx_port_proxy.h" +#include "t7xx_port_trace.h" #include "t7xx_state_monitor.h" #define T7XX_TRC_SUB_BUFF_SIZE 131072@@ -51,19 +52,19 @@ static struct rchan_callbacks relay_callbacks = {static void t7xx_trace_port_uninit (struct t7xx_port *port) { -struct rchan *relaych = port->relaych; +struct t7xx_trace *trace = &port->t7xx_dev->trace; -if (!relaych) +if (!trace->relaych)return ; -relay_close (relaych); -debugfs_remove_recursive (port->debugfs_dir); -wwan_put_debugfs_dir (port->debugfs_wwan_dir); +relay_close (trace->relaych); +debugfs_remove_recursive (trace->debugfs_dir); +wwan_put_debugfs_dir (trace->debugfs_wwan_dir); }static int t7xx_trace_port_recv_skb (struct t7xx_port *port,struct sk_buff *skb) { -struct rchan *relaych = port->relaych; +struct rchan *relaych = port->t7xx_dev->trace.relaych;if (!relaych)return -EINVAL;drivers/net/wwan/t7xx/t7xx_port_trace.c +9
-8@@ -75,33 +76,34 @@ static int t7xx_trace_port_recv_skb(struct t7xx_port *port, struct sk_buff *skb)static void t7xx_port_trace_md_state_notify (struct t7xx_port *port,unsigned int state) { +struct t7xx_trace *trace = &port->t7xx_dev->trace;struct rchan *relaych; -if (state !=MD_STATE_READY || port->relaych) +if (state !=MD_STATE_READY || trace->relaych)return ; - port->debugfs_wwan_dir =wwan_get_debugfs_dir (port->dev); -if (IS_ERR (port->debugfs_wwan_dir)) + trace->debugfs_wwan_dir =wwan_get_debugfs_dir (port->dev); +if (IS_ERR (trace->debugfs_wwan_dir))return ; - port->debugfs_dir =debugfs_create_dir (KBUILD_MODNAME , port->debugfs_wwan_dir); -if (IS_ERR_OR_NULL (port->debugfs_dir)) { -wwan_put_debugfs_dir (port->debugfs_wwan_dir); + trace->debugfs_dir =debugfs_create_dir (KBUILD_MODNAME , trace->debugfs_wwan_dir); +if (IS_ERR_OR_NULL (trace->debugfs_dir)) { +wwan_put_debugfs_dir (trace->debugfs_wwan_dir);dev_err (port->dev,"Unable to create debugfs for trace" );return ; } - relaych =relay_open ("relay_ch" , port->debugfs_dir,T7XX_TRC_SUB_BUFF_SIZE , + relaych =relay_open ("relay_ch" , trace->debugfs_dir,T7XX_TRC_SUB_BUFF_SIZE ,T7XX_TRC_N_SUB_BUFF , &relay_callbacks,NULL );if (!relaych) goto err_rm_debugfs_dir; - port->relaych = relaych; + trace->relaych = relaych;return ;
err_rm_debugfs_dir:drivers/net/wwan/t7xx/t7xx_port_trace.c +2
-2-debugfs_remove_recursive (port->debugfs_dir); -wwan_put_debugfs_dir (port->debugfs_wwan_dir); +debugfs_remove_recursive (trace->debugfs_dir); +wwan_put_debugfs_dir (trace->debugfs_wwan_dir); dev_err(port->dev, "Unable to create trace port %s",port->port_conf->name); }
Signature · 1 line
Chetan
Sergey Ryazanov
maintainerQuoted 41 lines · M Chetan
Quoted 31 lines · Sergey Ryazanov
Quoted 30 lines · M Chetan
Quoted 10 lines · Sergey Ryazanov
Quoted 10 lines
Quoted 10 lines · On Mon, Oct 3, 2022 at 8:29 AM <[email protected]> wrote:
Quoted 6 lines
The Modem Logging (MDL) port provides an interface to collect modem logs for debugging purposes. MDL is supported by the relay interface, and the
mtk_t7xxport infrastructure. MDL allows user-space apps to control logging via mbim command and to collect logs via the relay interface, while port infrastructure facilitates communication between the driver and the modem.[skip]
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/wwan/t7xx/t7xx_port.h +0
-0@@ -122,6 +122,11 @@ struct t7xx_port {int rx_length_th;bool chan_enable;Quoted 8 lines
Quoted 8 lines
drivers/net/wwan/t7xx/t7xx_port.h struct t7xx_port { · line 128
Quoted 5 lines
drivers/net/wwan/t7xx/t7xx_port.h +4
-0struct task_struct *thread; +#ifdef CONFIG_WWAN_DEBUGFS +void *relaych; +struct dentry *debugfs_dir; +struct dentry *debugfs_wwan_dir;Both of these debugfs directories are device-wide, why did you place these pointers in the item port context?
I guess it was kept inside port so that it could be accessed directly from port context.
Quoted 8 lines
Quoted 2 lines
Thanks for pointing it out. I think we should move out the complete #ifdef
CONFIG_WWAN_DEBUGFSblock of port container.Moving out debugfs directory pointers sounds like a good idea. Introduction of any new debugfs knob will be a much easier if these pointers are available in some device-wide state container. But the relaych pointer looks like a logging port specific element. Why should it be moved out?
Quoted 5 lines
t7xx_portis a common port container. keeping relaych pointer inside port container is like having relaych pointer for all port instance (AT/MBIM) though it is not required for others. So planning to move out.You suggest to keep it or move out ?
The t7xx_port structure already has a WWAN port specific field - wwan_port.
We can group such specific and otherwise useless fields into a union. Like this:
drivers/net/wwan/t7xx/t7xx_port.h +0 -1
@@ -99,7 +99,6 @@ struct t7xx_port_conf {struct t7xx_port {/* Members not initialized in definition */ const struct t7xx_port_conf *port_conf; -struct wwan_port *wwan_port;struct t7xx_pci_dev *t7xx_dev;struct device *dev;u16 seq_nums[2 ];/* TX/RX
sequence numbers */
@@ -122,6 +121,10 @@ struct t7xx_port {
int rx_length_th;
bool chan_enable;
struct task_struct *thread;
+ union { /* Port type specific data */
+ struct wwan_port *wwan_port;
+ struct rchan *relaych;+ };
};
Or even like this:
drivers/net/wwan/t7xx/t7xx_port.h +0 -1
@@ -99,7 +99,6 @@ struct t7xx_port_conf {struct t7xx_port {/* Members not initialized in definition */ const struct t7xx_port_conf *port_conf; -struct wwan_port *wwan_port;struct t7xx_pci_dev *t7xx_dev;struct device *dev;u16 seq_nums[2 ];/* TX/RX
sequence numbers */
@@ -122,6 +121,14 @@ struct t7xx_port {
int rx_length_th;
bool chan_enable;
struct task_struct *thread;+ union { /* Port type specific data */
+ struct {
+ struct wwan_port *wwan_port;
+ } wwan;
+ struct {
+ struct rchan *relaych;
+ } log;
+ };
};
Or, if we want more isolation, we can define per port type structures and make the field in t7xx_port opaque:
@@ -99,7 +99,6 @@ struct t7xx_port_conf {
struct t7xx_port {
/* Members not initialized in definition */
const struct t7xx_port_conf *port_conf;
- struct wwan_port *wwan_port;
struct t7xx_pci_dev *t7xx_dev;
struct device *dev;
u16 seq_nums[2]; /* TX/RX
sequence numbers */
@@ -122,8 +121,23 @@ struct t7xx_port {
int rx_length_th;
bool chan_enable;
struct task_struct *thread;+ char priv[0x10]; /* Port type
private data */
};
+#define t7xx_port_priv(__p) ((void *)&((__p)->priv))
+
+struct t7xx_port_wwan {
+ struct wwan_port *wwan_port;
+};
+
+BUILD_BUG_ON(sizeof(struct t7xx_port_wwan) > sizeof(port->priv)); +
+struct t7xx_port_log {
+ struct rchan *relaych;
+};
+
+BUILD_BUG_ON(sizeof(struct t7xx_port_log) > sizeof(port->priv));
I do not want to suggest any specific solution, it is always up to you how to develop your code. I just wanted to point out the unexpected pointers location and the possible difficulty of accessing the debugfs directory pointer in the future.
Signature · 1 line
Sergey