From patchwork Mon Dec 12 07:50:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1714832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NVv1v0f40z240J for ; Mon, 12 Dec 2022 18:50:42 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1p4da6-0002yi-Ug; Mon, 12 Dec 2022 07:50:34 +0000 Received: from mail-pj1-f54.google.com ([209.85.216.54]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1p4da3-0002xj-Ez for kernel-team@lists.ubuntu.com; Mon, 12 Dec 2022 07:50:31 +0000 Received: by mail-pj1-f54.google.com with SMTP id q17-20020a17090aa01100b002194cba32e9so14802228pjp.1 for ; Sun, 11 Dec 2022 23:50:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vcbaQlCGENv0tokk63hMwjXFmGgKUpyyYuyu7J9MPpc=; b=YqYethwub6OLaij00cA1WAcEEZQeTADJRxeVsUUvcP/AWROLd/JbAIwhvKpmzhbiYO TMarzZPwl4NO0Yjn5Lb2AorOFiDkfwgIbsSJR+t67pzIyB+YdbIhMBN9JAtuWD4em5el itRfkXSVHAZNj7Ti9Q7FvwjfNhzP1N4r4KRqpwKLXCrJcCBWfD0LsO4yzrZMraFCOs7E GudzDujCSJuSglnLPBdWeZY+0LtHnVHWstXXpnANvcPY3KJ0PoggZMNoG5/cZSGRUnhJ tQ0lHixs+B7KcvLsYfJbCt3ACwyGA8tOKeN9eFbf7Z6SrUCJ/RNfSrvEMmXdvQj1IU80 8jTw== X-Gm-Message-State: ANoB5pmyFbndC2e0HwyLuOb//It4O9QW0oYpKuJlrQrGQAKWvn+lkxXz nOEKky0oBC19wp85cxHrvmvAwEBPvmg= X-Google-Smtp-Source: AA0mqf6bPci5pftDqJxV0bqm+AYYsyhDVt1ydkJqIbxLrsE0BFf4TVtHviOGA1ZZoDXVgwD7yPLEeg== X-Received: by 2002:a17:902:cf0f:b0:189:d193:91ff with SMTP id i15-20020a170902cf0f00b00189d19391ffmr17530673plg.61.1670831429369; Sun, 11 Dec 2022 23:50:29 -0800 (PST) Received: from yewun.. (61-227-116-5.dynamic-ip.hinet.net. [61.227.116.5]) by smtp.gmail.com with ESMTPSA id g10-20020a170902934a00b00189758e2b99sm5613615plp.92.2022.12.11.23.50.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Dec 2022 23:50:28 -0800 (PST) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/2][SRU][OEM-6.1] net: wwan: t7xx: use union to group port type specific data Date: Mon, 12 Dec 2022 15:50:23 +0800 Message-Id: <20221212075024.3165087-2-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221212075024.3165087-1-vicamo.yang@canonical.com> References: <20221212075024.3165087-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.54; envelope-from=vicamo@gmail.com; helo=mail-pj1-f54.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: M Chetan Kumar BugLink: https://bugs.launchpad.net/bugs/1997686 Use union inside t7xx_port to group port type specific data members. Signed-off-by: M Chetan Kumar Reviewed-by: Sergey Ryazanov Signed-off-by: David S. Miller (cherry picked from commit fece7a8c65d1476b901b969a07b2979e1b459e66 linux-next) Signed-off-by: You-Sheng Yang (vicamo) --- drivers/net/wwan/t7xx/t7xx_port.h | 6 +++++- drivers/net/wwan/t7xx/t7xx_port_wwan.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/wwan/t7xx/t7xx_port.h b/drivers/net/wwan/t7xx/t7xx_port.h index 4a29bd04cbe2..5177055521b8 100644 --- a/drivers/net/wwan/t7xx/t7xx_port.h +++ b/drivers/net/wwan/t7xx/t7xx_port.h @@ -105,7 +105,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 */ @@ -128,6 +127,11 @@ struct t7xx_port { int rx_length_th; bool chan_enable; struct task_struct *thread; + union { + struct { + struct wwan_port *wwan_port; + } wwan; + }; }; struct sk_buff *t7xx_port_alloc_skb(int payload); diff --git a/drivers/net/wwan/t7xx/t7xx_port_wwan.c b/drivers/net/wwan/t7xx/t7xx_port_wwan.c index 33931bfd78fd..24bd21942403 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_wwan.c +++ b/drivers/net/wwan/t7xx/t7xx_port_wwan.c @@ -109,12 +109,12 @@ static int t7xx_port_wwan_init(struct t7xx_port *port) static void t7xx_port_wwan_uninit(struct t7xx_port *port) { - if (!port->wwan_port) + if (!port->wwan.wwan_port) return; port->rx_length_th = 0; - wwan_remove_port(port->wwan_port); - port->wwan_port = NULL; + wwan_remove_port(port->wwan.wwan_port); + port->wwan.wwan_port = NULL; } static int t7xx_port_wwan_recv_skb(struct t7xx_port *port, struct sk_buff *skb) @@ -129,7 +129,7 @@ static int t7xx_port_wwan_recv_skb(struct t7xx_port *port, struct sk_buff *skb) return 0; } - wwan_port_rx(port->wwan_port, skb); + wwan_port_rx(port->wwan.wwan_port, skb); return 0; } @@ -158,10 +158,10 @@ static void t7xx_port_wwan_md_state_notify(struct t7xx_port *port, unsigned int if (state != MD_STATE_READY) return; - if (!port->wwan_port) { - port->wwan_port = wwan_create_port(port->dev, port_conf->port_type, - &wwan_ops, port); - if (IS_ERR(port->wwan_port)) + if (!port->wwan.wwan_port) { + port->wwan.wwan_port = wwan_create_port(port->dev, port_conf->port_type, + &wwan_ops, port); + if (IS_ERR(port->wwan.wwan_port)) dev_err(port->dev, "Unable to create WWWAN port %s", port_conf->name); } } From patchwork Mon Dec 12 07:50:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1714831 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NVv1t2hLnz23yh for ; Mon, 12 Dec 2022 18:50:42 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1p4da7-0002z6-4k; Mon, 12 Dec 2022 07:50:35 +0000 Received: from mail-pj1-f42.google.com ([209.85.216.42]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1p4da5-0002y4-1V for kernel-team@lists.ubuntu.com; Mon, 12 Dec 2022 07:50:33 +0000 Received: by mail-pj1-f42.google.com with SMTP id js9so10132811pjb.2 for ; Sun, 11 Dec 2022 23:50:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CN1HNGescqcexeBQtB8IFGKUAyIvC8kjGf3Jv0CgWaM=; b=WzZDddXUNMIxdCobz78mWIcahKwi6XjQBE1Gu/EZ9N1qVs4xPI6YXZyBuLtkTLXY1B e01t3HCldvcninflzvTQbBdOp3/3nD0YYI9jubtO9PUHtV+HSXhPG3AsIH1Z0R/MMMuI tSRM5xM/C1QNg0ojBfw4RcqIrVOWJ1FZTnJ+MRl7YozbPXxona0TQJkZHhpxJc9PbVic 04bhunv5Wgme8SEGPiY7DlbXmPwS/I3SoZ7oHuXCnrvV11oBGycd0G22Acq003fieUrd +nlEIaSmP9pQssfSpwFUnTERAfmSswL+JbQcCBqyH/X/F6/F5UnzolvMHaNFmkHeYn7k dQNw== X-Gm-Message-State: ANoB5plMRKAIbhVepSOgy3SUHtvkwZBymzeVnSsmZvTUWNQxkwKb3b6S zATpTpW8zhh6a7Xj2YtLSpZrsIzoFBE= X-Google-Smtp-Source: AA0mqf4aww6e0HPJUK+il7OKSBt2s+Mnp1Hpy2vGSuC7cRG2JRdgvtuz1H12jOKc2EPbTG/R9yLeWQ== X-Received: by 2002:a17:902:cec4:b0:189:eec5:ff71 with SMTP id d4-20020a170902cec400b00189eec5ff71mr23750832plg.44.1670831430910; Sun, 11 Dec 2022 23:50:30 -0800 (PST) Received: from yewun.. (61-227-116-5.dynamic-ip.hinet.net. [61.227.116.5]) by smtp.gmail.com with ESMTPSA id g10-20020a170902934a00b00189758e2b99sm5613615plp.92.2022.12.11.23.50.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Dec 2022 23:50:30 -0800 (PST) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/2][SRU][OEM-6.1] net: wwan: t7xx: Add port for modem logging Date: Mon, 12 Dec 2022 15:50:24 +0800 Message-Id: <20221212075024.3165087-3-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221212075024.3165087-1-vicamo.yang@canonical.com> References: <20221212075024.3165087-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.42; envelope-from=vicamo@gmail.com; helo=mail-pj1-f42.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: M Chetan Kumar BugLink: https://bugs.launchpad.net/bugs/1997686 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. Signed-off-by: Moises Veleta Signed-off-by: M Chetan Kumar Signed-off-by: Devegowda Chandrashekar Acked-by: Ricardo Martinez Reviewed-by: Sergey Ryazanov Signed-off-by: David S. Miller (cherry picked from commit 3349e4a48acb0923fa98d2beac82a833a76116cb linux-next) Signed-off-by: You-Sheng Yang (vicamo) --- 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_pci.h | 3 + drivers/net/wwan/t7xx/t7xx_port.h | 3 + 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 | 116 ++++++++++++++++++++++++ 8 files changed, 144 insertions(+) create mode 100644 drivers/net/wwan/t7xx/t7xx_port_trace.c diff --git a/drivers/net/wwan/Kconfig b/drivers/net/wwan/Kconfig index ac4d73b5626f..410b0245114e 100644 --- a/drivers/net/wwan/Kconfig +++ b/drivers/net/wwan/Kconfig @@ -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 diff --git a/drivers/net/wwan/t7xx/Makefile b/drivers/net/wwan/t7xx/Makefile index dc6a7d682c15..268ff9e87e5b 100644 --- a/drivers/net/wwan/t7xx/Makefile +++ b/drivers/net/wwan/t7xx/Makefile @@ -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 \ diff --git a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c index 37cd63d20b45..4f56d8cc0aea 100644 --- a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c +++ b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c @@ -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++) { diff --git a/drivers/net/wwan/t7xx/t7xx_pci.h b/drivers/net/wwan/t7xx/t7xx_pci.h index 50b37056ce5a..112efa534eac 100644 --- a/drivers/net/wwan/t7xx/t7xx_pci.h +++ b/drivers/net/wwan/t7xx/t7xx_pci.h @@ -78,6 +78,9 @@ struct t7xx_pci_dev { spinlock_t md_pm_lock; /* Protects PCI resource lock */ unsigned int sleep_disable_count; struct completion sleep_lock_acquire; +#ifdef CONFIG_WWAN_DEBUGFS + struct dentry *debugfs_dir; +#endif }; enum t7xx_pm_id { diff --git a/drivers/net/wwan/t7xx/t7xx_port.h b/drivers/net/wwan/t7xx/t7xx_port.h index 5177055521b8..7bf8608ce991 100644 --- a/drivers/net/wwan/t7xx/t7xx_port.h +++ b/drivers/net/wwan/t7xx/t7xx_port.h @@ -131,6 +131,9 @@ struct t7xx_port { struct { struct wwan_port *wwan_port; } wwan; + struct { + struct rchan *relaych; + } log; }; }; diff --git a/drivers/net/wwan/t7xx/t7xx_port_proxy.c b/drivers/net/wwan/t7xx/t7xx_port_proxy.c index 62305d59da90..6c24a38181f2 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_proxy.c +++ b/drivers/net/wwan/t7xx/t7xx_port_proxy.c @@ -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, diff --git a/drivers/net/wwan/t7xx/t7xx_port_proxy.h b/drivers/net/wwan/t7xx/t7xx_port_proxy.h index bc1ff5c6c700..81d059fbc0fb 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_proxy.h +++ b/drivers/net/wwan/t7xx/t7xx_port_proxy.h @@ -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); diff --git a/drivers/net/wwan/t7xx/t7xx_port_trace.c b/drivers/net/wwan/t7xx/t7xx_port_trace.c new file mode 100644 index 000000000000..6a3f36385865 --- /dev/null +++ b/drivers/net/wwan/t7xx/t7xx_port_trace.c @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2022 Intel Corporation. + */ + +#include +#include +#include +#include + +#include "t7xx_port.h" +#include "t7xx_port_proxy.h" +#include "t7xx_state_monitor.h" + +#define T7XX_TRC_SUB_BUFF_SIZE 131072 +#define T7XX_TRC_N_SUB_BUFF 32 + +static struct dentry *t7xx_trace_create_buf_file_handler(const char *filename, + struct dentry *parent, + umode_t mode, + struct rchan_buf *buf, + int *is_global) +{ + *is_global = 1; + return debugfs_create_file(filename, mode, parent, buf, + &relay_file_operations); +} + +static int t7xx_trace_remove_buf_file_handler(struct dentry *dentry) +{ + debugfs_remove(dentry); + return 0; +} + +static int t7xx_trace_subbuf_start_handler(struct rchan_buf *buf, void *subbuf, + void *prev_subbuf, size_t prev_padding) +{ + if (relay_buf_full(buf)) { + pr_err_ratelimited("Relay_buf full dropping traces"); + return 0; + } + + return 1; +} + +static struct rchan_callbacks relay_callbacks = { + .subbuf_start = t7xx_trace_subbuf_start_handler, + .create_buf_file = t7xx_trace_create_buf_file_handler, + .remove_buf_file = t7xx_trace_remove_buf_file_handler, +}; + +static void t7xx_trace_port_uninit(struct t7xx_port *port) +{ + struct dentry *debugfs_dir = port->t7xx_dev->debugfs_dir; + struct rchan *relaych = port->log.relaych; + + if (!relaych) + return; + + relay_close(relaych); + debugfs_remove_recursive(debugfs_dir); +} + +static int t7xx_trace_port_recv_skb(struct t7xx_port *port, struct sk_buff *skb) +{ + struct rchan *relaych = port->log.relaych; + + if (!relaych) + return -EINVAL; + + relay_write(relaych, skb->data, skb->len); + dev_kfree_skb(skb); + return 0; +} + +static void t7xx_port_trace_md_state_notify(struct t7xx_port *port, unsigned int state) +{ + struct rchan *relaych = port->log.relaych; + struct dentry *debugfs_wwan_dir; + struct dentry *debugfs_dir; + + if (state != MD_STATE_READY || relaych) + return; + + debugfs_wwan_dir = wwan_get_debugfs_dir(port->dev); + if (IS_ERR(debugfs_wwan_dir)) + return; + + debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, debugfs_wwan_dir); + if (IS_ERR_OR_NULL(debugfs_dir)) { + wwan_put_debugfs_dir(debugfs_wwan_dir); + dev_err(port->dev, "Unable to create debugfs for trace"); + return; + } + + relaych = relay_open("relay_ch", debugfs_dir, T7XX_TRC_SUB_BUFF_SIZE, + T7XX_TRC_N_SUB_BUFF, &relay_callbacks, NULL); + if (!relaych) + goto err_rm_debugfs_dir; + + wwan_put_debugfs_dir(debugfs_wwan_dir); + port->log.relaych = relaych; + port->t7xx_dev->debugfs_dir = debugfs_dir; + return; + +err_rm_debugfs_dir: + debugfs_remove_recursive(debugfs_dir); + wwan_put_debugfs_dir(debugfs_wwan_dir); + dev_err(port->dev, "Unable to create trace port %s", port->port_conf->name); +} + +struct port_ops t7xx_trace_port_ops = { + .recv_skb = t7xx_trace_port_recv_skb, + .uninit = t7xx_trace_port_uninit, + .md_state_notify = t7xx_port_trace_md_state_notify, +};