From patchwork Wed Apr 26 08:03:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 87711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp79963vqo; Wed, 26 Apr 2023 01:10:47 -0700 (PDT) X-Google-Smtp-Source: AKy350YZz/u17hz0X3n6DCc4v6yk84gxRTUrShHEZaZ1816b2jwbJcs6BkJbkVvQRCEzTd+8Y/BN X-Received: by 2002:a05:6a00:21cf:b0:627:f0e1:4fbf with SMTP id t15-20020a056a0021cf00b00627f0e14fbfmr30510587pfj.33.1682496647415; Wed, 26 Apr 2023 01:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682496647; cv=none; d=google.com; s=arc-20160816; b=VHivDj52pV3fKTRAFd2zZ9wUxNUFk5BreqjANThAycTMUiIgOuz9q/Y268PZ57V15/ zTFnacx9OK/XmpmfnS3o38ElkOs5kNrvj1ZxgfjHrdvX0FMoKW1R0/n+XfqYu7w2XJlI 6jD9Dk96SvrJL+RAunoR5f+WFE7kmP51QdxeyTVnL/DDw6u66/UBP3np7m1JAh24j9yq APCIDipyxRE+QcK2beeExIAuPoZ6T6tLJP/b6WFtyH1rCv72H36mQp36hpahZxUZHFK/ 5l7d7vwQvKcKAr1JO9XuJ95EC/Khd1+UFFRxz6X79dxzrCcA/QX8eDXlXHIyGHKy9PVx BG5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=btnpjanps7GZuVDl1HyLhoOR3uwTdi+jFgZdJzn8lO8=; b=x6fvOgCssM4yE6yyCPJCtHwQ7eISy8zfX1I4i33Z6rdvo+IGu7T+efZkb1MtnHBj8I MDaX4AFCXoWfBA6rrqrvM0EUtDUbS7KqXQ4sgyACg8fniDtigSM6WWkxja7eH73dXStj cOEnn7LNhTveaeU2+ocLvXE+8L4M38KqyU/1VOUfvUUBtNwtXZR3fbOPxzwp1vZro8BT zp6+yUpqtc7QSDjZS2a8cyU/164svMOG/AFPBjHpRTusOw+6Xr7FTkLNxWwGl6b0QKJI 4oYS8CemqL3AxortVQ+uyTvSITiwWIfWrXszCQn/a/J0UiSv6CrufoIeREu0ui7ZVgh0 22nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=W5lRVWft; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020aa79902000000b0063d33dc49e8si15423962pff.363.2023.04.26.01.10.33; Wed, 26 Apr 2023 01:10:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=W5lRVWft; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239998AbjDZIDr (ORCPT + 99 others); Wed, 26 Apr 2023 04:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239686AbjDZIDg (ORCPT ); Wed, 26 Apr 2023 04:03:36 -0400 Received: from mta-65-227.siemens.flowmailer.net (mta-65-227.siemens.flowmailer.net [185.136.65.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12EDF3C03 for ; Wed, 26 Apr 2023 01:03:32 -0700 (PDT) Received: by mta-65-227.siemens.flowmailer.net with ESMTPSA id 2023042608033045f25e7b2df527a7a6 for ; Wed, 26 Apr 2023 10:03:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc; bh=btnpjanps7GZuVDl1HyLhoOR3uwTdi+jFgZdJzn8lO8=; b=W5lRVWftuxQ4NVdnxx0NWP7jI7LdRTLWA1YNChTZ29wLWaE4GfdqQf5dZzFXItnI1kdeRh W3yvJuZ/H0lNGx+fSsEaHFHhL/zVScNUR5u78WS+aws60YBQzCDiw1f1kJxL+Db4wmFbbb+N lh/lSTsV82AlfnHts8V0yqXXxFsXw=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v4 1/8] tty: n_gsm: add restart flag to DLC specific ioctl config Date: Wed, 26 Apr 2023 10:03:08 +0200 Message-Id: <20230426080315.7595-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764225604788707258?= X-GMAIL-MSGID: =?utf-8?q?1764225604788707258?= From: Daniel Starke Currently, changing the parameters of a DLCI gives no direct control to the user whether this should trigger a channel reset or not. The decision is solely made by the driver based on the assumption which parameter changes are compatible or not. Therefore, the user has no means to perform an automatic channel reset after parameter configuration for non-conflicting changes. Add the parameter 'flags' to 'gsm_dlci_config' to force a channel reset after ioctl setting regardless of whether the changes made require this or not by setting this to 'GSM_FL_RESTART'. Note that 'GSM_FL_RESTART' is currently the only allow flag to allow additions here. Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 4 ++++ include/uapi/linux/gsmmux.h | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) v3 -> v4: Changed gsm_dlci_config field name from 'restart' to 'flags' and introduced 'GSM_FL_RESTART' to set the restart flag. The patch description was changed accordingly. This was done as suggested during the review. The remarked kernel doc compatible field comment is done in patch 2/8. Link: https://lore.kernel.org/all/2023042453-dubbed-botany-2ed9@gregkh/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index b411a26cc092..66edcf65a4dd 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2532,6 +2532,8 @@ static int gsm_dlci_config(struct gsm_dlci *dlci, struct gsm_dlci_config *dc, in return -EINVAL; if (dc->k > 7) return -EINVAL; + if (dc->flags & ~GSM_FL_RESTART) /* allow future extensions */ + return -EINVAL; /* * See what is needed for reconfiguration @@ -2546,6 +2548,8 @@ static int gsm_dlci_config(struct gsm_dlci *dlci, struct gsm_dlci_config *dc, in /* Requires care */ if (dc->priority != dlci->prio) need_restart = true; + if (dc->flags & GSM_FL_RESTART) + need_restart = true; if ((open && gsm->wait_config) || need_restart) need_open = true; diff --git a/include/uapi/linux/gsmmux.h b/include/uapi/linux/gsmmux.h index eb67884e5f38..958257af05ab 100644 --- a/include/uapi/linux/gsmmux.h +++ b/include/uapi/linux/gsmmux.h @@ -2,10 +2,20 @@ #ifndef _LINUX_GSMMUX_H #define _LINUX_GSMMUX_H +#include #include #include #include +/* + * flags definition for n_gsm + * + * Used by: + * struct gsm_dlci_config.flags + */ +/* Force DLCI channel reset? Always cleared on retrieval. */ +#define GSM_FL_RESTART _BITUL(0) + struct gsm_config { unsigned int adaption; @@ -58,7 +68,8 @@ struct gsm_dlci_config { __u32 priority; /* Priority (0 for default value) */ __u32 i; /* Frame type (1 = UIH, 2 = UI) */ __u32 k; /* Window size (0 for default value) */ - __u32 reserved[8]; /* For future use, must be initialized to zero */ + __u32 flags; /* DLCI specific flags. */ + __u32 reserved[7]; /* For future use, must be initialized to zero */ }; #define GSMIOC_GETCONF_DLCI _IOWR('G', 7, struct gsm_dlci_config) From patchwork Wed Apr 26 08:03:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 87706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp78131vqo; Wed, 26 Apr 2023 01:06:28 -0700 (PDT) X-Google-Smtp-Source: AKy350Z1iZ0wdwwvSRF2w2FxIT4nDe1wPrBVb2oSTpOGvmou7drWAO4BArF0TrK77pPWKbhqM8E4 X-Received: by 2002:a05:6a00:13aa:b0:637:f447:9916 with SMTP id t42-20020a056a0013aa00b00637f4479916mr28808278pfg.16.1682496388216; Wed, 26 Apr 2023 01:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682496388; cv=none; d=google.com; s=arc-20160816; b=VO+Bv12npHwfFlG2yLrVkLx2MhS7kCiFUQZEzuUD//5c9J36zhMjTb7QEAhKe0g4oH tGxB1/G0vs5hqWMA6yjfps99qm46w47OhjQCS/LgSLBoaLEaye5yxxS4GY75Nl3TapQ4 uYG2IChKty5ddQufykKfmVToQhM1qTE0O8oTpkkjnTs1EvQ7Fn48k7dwDTFP8V8enpjD wltBVC6f1sPxljQvUUiWxgvPlCBg+U646Rsr98qsrkPwJHFJv4Lj5S49f395g/BpznAz y3OJNOxBZ4W6GogbtrVXfXOKzeHkseiYPuoLY3DbGI7LrsIM1kMQNhcSfEmqRx+GGcJx AHHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yEGcgQ5Kvtx1tgonDU+9HHY5hBo4q5pCkYVLeZOHs5M=; b=TT2vso7d5wNgjTZflTt6jXTV+2ZAcUmM4EVaMKcHfq0zu9bh+t+9XErOXHclMuSRl6 2JB1i5OhDzYrLbeoi2mVzetaiJuBVWC6++gMZ/QpkGx/onwpcarJm+aIIJ7I64Qj7YmA A2AlAY9zZCUGCisRPme1ad9mJpMQzZ2/+hbCbnqL/ZMYabBbXpntPvdPZWzGiTflun2N 5qQZtPngaPx5ubqsH7LBR1IoBnY8s8KASii0ZFowlwKMOJIjrpZWpJqJK16GyZ+WPXaz XGEw3S4Cgv110LFgc3ci6pMF6P2haxaQiyc6yxk4aSFeZWrnMtKcfuTTu2Ll09N7j58x u7SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=pPtLUQAU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v20-20020a634654000000b005139e0d2b5csi10763006pgk.487.2023.04.26.01.06.11; Wed, 26 Apr 2023 01:06:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=pPtLUQAU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239988AbjDZIDn (ORCPT + 99 others); Wed, 26 Apr 2023 04:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239640AbjDZIDg (ORCPT ); Wed, 26 Apr 2023 04:03:36 -0400 Received: from mta-65-227.siemens.flowmailer.net (mta-65-227.siemens.flowmailer.net [185.136.65.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12DEE3AAD for ; Wed, 26 Apr 2023 01:03:32 -0700 (PDT) Received: by mta-65-227.siemens.flowmailer.net with ESMTPSA id 20230426080330429f5db1f9e012e83b for ; Wed, 26 Apr 2023 10:03:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=yEGcgQ5Kvtx1tgonDU+9HHY5hBo4q5pCkYVLeZOHs5M=; b=pPtLUQAUadLjVnVs6hB73r7wlCQNX66VtpS9hgOjmZx+bjh7yUSUhnk0wqiOJfmvmymY+G 2S+2knT+AGT5BWzXKSI8Gbcrl4ZSGDaFINdQnhtioG1csliGbRngHDJu8RYd7pjT6FrIDCEB YkC8PZxduG2jn/ql1GQBoTVWeHf90=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v4 2/8] tty: n_gsm: add missing description to structs in gsmmux.h Date: Wed, 26 Apr 2023 10:03:09 +0200 Message-Id: <20230426080315.7595-2-daniel.starke@siemens.com> In-Reply-To: <20230426080315.7595-1-daniel.starke@siemens.com> References: <20230426080315.7595-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764225332787311916?= X-GMAIL-MSGID: =?utf-8?q?1764225332787311916?= From: Daniel Starke Currently, all available structure fields in gsmmux.h except those for gsm_config are commented. Furthermore, no kernel doc comments are used. Fix this by adding appropriate comments to the not commented fields of gsm_config. Convert the comments of the other structs to kernel doc format. Note that 'mru' and 'mtu' refer to the size without basic/advanced option mode header and byte stuffing as defined in the standard in chapter 5.7.2. Link: https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516 Signed-off-by: Daniel Starke --- include/uapi/linux/gsmmux.h | 104 +++++++++++++++++++++++++++++------- 1 file changed, 84 insertions(+), 20 deletions(-) v3 -> v4: Changed comments of all other structs in gsmmux.h to kernel doc format as suggested during review. The patch description and subject was changed to match this. Link: https://lore.kernel.org/all/2023042438-whole-cannot-1945@gregkh/ Link: https://lore.kernel.org/all/20230424075251.5216-2-daniel.starke@siemens.com/ diff --git a/include/uapi/linux/gsmmux.h b/include/uapi/linux/gsmmux.h index 958257af05ab..54bc8767bd75 100644 --- a/include/uapi/linux/gsmmux.h +++ b/include/uapi/linux/gsmmux.h @@ -16,6 +16,28 @@ /* Force DLCI channel reset? Always cleared on retrieval. */ #define GSM_FL_RESTART _BITUL(0) +/** + * struct gsm_config - n_gsm basic configuration parameters + * + * This structure is used in combination with GSMIOC_GETCONF and GSMIOC_SETCONF + * to retrieve and set the basic parameters of an n_gsm ldisc. + * struct gsm_config_ext can be used to configure extended ldisc parameters. + * + * All timers are in units of 1/100th of a second. + * + * @adaption: Convergence layer type + * @encapsulation: Framing (0 = basic option, 1 = advanced option) + * @initiator: Initiator or responder + * @t1: Acknowledgment timer + * @t2: Response timer for multiplexer control channel + * @t3: Response timer for wake-up procedure + * @n2: Maximum number of retransmissions + * @mru: Maximum incoming frame payload size + * @mtu: Maximum outgoing frame payload size + * @k: Window size + * @i: Frame type (1 = UIH, 2 = UI) + * @unused: Can not be used + */ struct gsm_config { unsigned int adaption; @@ -29,18 +51,32 @@ struct gsm_config unsigned int mtu; unsigned int k; unsigned int i; - unsigned int unused[8]; /* Can not be used */ + unsigned int unused[8]; }; #define GSMIOC_GETCONF _IOR('G', 0, struct gsm_config) #define GSMIOC_SETCONF _IOW('G', 1, struct gsm_config) +/** + * struct gsm_netconfig - n_gsm network configuration parameters + * + * This structure is used in combination with GSMIOC_ENABLE_NET and + * GSMIOC_DISABLE_NET to enable or disable a network data connection + * over a mux virtual tty channel. This is for modems that support + * data connections with raw IP frames instead of PPP. + * + * @adaption: Adaption to use in network mode. + * @protocol: Protocol to use - only ETH_P_IP supported. + * @unused2: Can not be used. + * @if_name: Interface name format string. + * @unused: Can not be used. + */ struct gsm_netconfig { - unsigned int adaption; /* Adaption to use in network mode */ - unsigned short protocol;/* Protocol to use - only ETH_P_IP supported */ - unsigned short unused2; /* Can not be used */ - char if_name[IFNAMSIZ]; /* interface name format string */ - __u8 unused[28]; /* Can not be used */ + unsigned int adaption; + unsigned short protocol; + unsigned short unused2; + char if_name[IFNAMSIZ]; + __u8 unused[28]; }; #define GSMIOC_ENABLE_NET _IOW('G', 2, struct gsm_netconfig) @@ -49,27 +85,55 @@ struct gsm_netconfig { /* get the base tty number for a configured gsmmux tty */ #define GSMIOC_GETFIRST _IOR('G', 4, __u32) +/** + * struct gsm_config_ext - n_gsm extended configuration parameters + * + * This structure is used in combination with GSMIOC_GETCONF_EXT and + * GSMIOC_SETCONF_EXT to retrieve and set the extended parameters of an + * n_gsm ldisc. + * + * All timers are in units of 1/100th of a second. + * + * @keep_alive: Control channel keep-alive in 1/100th of a second (0 to disable). + * @wait_config: Wait for DLCI config before opening virtual link? + * @reserved: For future use, must be initialized to zero. + */ struct gsm_config_ext { - __u32 keep_alive; /* Control channel keep-alive in 1/100th of a - * second (0 to disable) - */ - __u32 wait_config; /* Wait for DLCI config before opening virtual link? */ - __u32 reserved[6]; /* For future use, must be initialized to zero */ + __u32 keep_alive; + __u32 wait_config; + __u32 reserved[6]; }; #define GSMIOC_GETCONF_EXT _IOR('G', 5, struct gsm_config_ext) #define GSMIOC_SETCONF_EXT _IOW('G', 6, struct gsm_config_ext) -/* Set channel accordingly before calling GSMIOC_GETCONF_DLCI. */ +/** + * struct gsm_dlci_config - n_gsm channel configuration parameters + * + * This structure is used in combination with GSMIOC_GETCONF_DLCI and + * GSMIOC_SETCONF_DLCI to retrieve and set the channel specific parameters + * of an n_gsm ldisc. + * + * Set the channel accordingly before calling GSMIOC_GETCONF_DLCI. + * + * @channel: DLCI (0 for the associated DLCI). + * @adaption: Convergence layer type. + * @mtu: Maximum transfer unit. + * @priority: Priority (0 for default value). + * @i: Frame type (1 = UIH, 2 = UI). + * @k: Window size (0 for default value). + * @flags: DLCI specific flags. + * @reserved: For future use, must be initialized to zero. + */ struct gsm_dlci_config { - __u32 channel; /* DLCI (0 for the associated DLCI) */ - __u32 adaption; /* Convergence layer type */ - __u32 mtu; /* Maximum transfer unit */ - __u32 priority; /* Priority (0 for default value) */ - __u32 i; /* Frame type (1 = UIH, 2 = UI) */ - __u32 k; /* Window size (0 for default value) */ - __u32 flags; /* DLCI specific flags. */ - __u32 reserved[7]; /* For future use, must be initialized to zero */ + __u32 channel; + __u32 adaption; + __u32 mtu; + __u32 priority; + __u32 i; + __u32 k; + __u32 flags; + __u32 reserved[7]; }; #define GSMIOC_GETCONF_DLCI _IOWR('G', 7, struct gsm_dlci_config) From patchwork Wed Apr 26 08:03:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 87707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp78368vqo; Wed, 26 Apr 2023 01:07:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6O1cvd5CG1Zc8Du3j++PAVAZeWjO2RZNNQ3utN3WYF0MuNK9i9CHJ6P9MHoONJLhpObgiJ X-Received: by 2002:a05:6a00:18a5:b0:63b:5f0f:94f1 with SMTP id x37-20020a056a0018a500b0063b5f0f94f1mr2247462pfh.4.1682496422240; Wed, 26 Apr 2023 01:07:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682496422; cv=none; d=google.com; s=arc-20160816; b=Yc1bqBjm5ZZ6GSTGs80UDjyFR4tYspgsXlseN1fD41SqnN3zTRb3qGM86xnIzwZ9yh ugvmiZLL1ZalOYfbr+UMEo0N5d3IOmDo5jUo6I0TiR+dTQdDfUajWX/vcZ04c1ZTW7oR jgQF7uQWuloLHSJ4jfbMXVEFjakLHVEndYmv73TE2GnmnI4AjdR2UfYkFEtWjvYMC2Ul 11ZLM5O4lT/EzDKeyDqhxTb4YAjz0NOOfWT+aaVFINiIU3cipl8u4kOrDAtlJODCxtdC M6YchxG9ir/q0i0hEzCs4WO1eElE7CrigfhHIRFrqVqJgQPVV2HKxpROTaHKiL+KJ25c US+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xx1dZ9evczfWs6mTbL4YlHvxtmGbUbagLFOnGgHTeoI=; b=BGxroAQf42WvtMYT9E4clM3rTeBMr28+9spl01cRzebjN89JtKKFrTCs+00d0i1St6 27SntYOCiRA6oasezhcKF1hb9w+21RhS49TR0l0ljgx1SWu9rZVXgKFh5pq3i8xVwazp Z86Ye+ennoTUywPKtKB2frMOsqx4WDFf+384Z5ZMXjRXJ2NtzJ4OtZ06hvDXbKk731go EQdRAozPQpRIEjpnkeN/STvN+/YJuZsdUrPSLNiLLx0AhVBgjQSSYmctpDJOACVzOihR EM1I/T/al1KBis0eO5OR8QcH/KefK+xgE1AFk7aj7AN9ldmLa53qF+uW+e3lNJTWLlqP 2IFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=XuUQJT2W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p10-20020aa79e8a000000b0063b7ab0b1aasi15984676pfq.242.2023.04.26.01.06.47; Wed, 26 Apr 2023 01:07:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=XuUQJT2W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240011AbjDZIDt (ORCPT + 99 others); Wed, 26 Apr 2023 04:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239935AbjDZIDg (ORCPT ); Wed, 26 Apr 2023 04:03:36 -0400 Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net [185.136.65.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AE2B3C1B for ; Wed, 26 Apr 2023 01:03:33 -0700 (PDT) Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 20230426080330e6d6439e587acad12f for ; Wed, 26 Apr 2023 10:03:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=xx1dZ9evczfWs6mTbL4YlHvxtmGbUbagLFOnGgHTeoI=; b=XuUQJT2WG5DehG0o+Dj51+tV8lafeJCVbcaZuMDf8dYR67lzQL/AqNjJLnFn9gXOV71c/Q 5AT1vNnUH+9cqPWiQuK8B4KYaNfrYKSXOHpvtzzdvyNcKN29LlzVz0HnjuDMxVvicFL1foqe Wg74gBZMyeFqdzevY96QvVERuEPtg=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v4 3/8] tty: n_gsm: remove unneeded initialization of ret in gsm_dlci_config Date: Wed, 26 Apr 2023 10:03:10 +0200 Message-Id: <20230426080315.7595-3-daniel.starke@siemens.com> In-Reply-To: <20230426080315.7595-1-daniel.starke@siemens.com> References: <20230426080315.7595-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764225368370106879?= X-GMAIL-MSGID: =?utf-8?q?1764225368370106879?= From: Daniel Starke The variable 'ret' is not used before assignment from gsm_activate_mux(). Still it gets initialized to zero at declaration. Fix this as remarked in the link below by moving the declaration to the first assignment. Link: https://lore.kernel.org/all/b42bc4d1-cc9d-d115-c981-aaa053bdc59f@kernel.org/ Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) v3 -> v4: No changes. Link: https://lore.kernel.org/all/20230424075251.5216-3-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 66edcf65a4dd..ebb71957f783 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3277,7 +3277,6 @@ static void gsm_copy_config_values(struct gsm_mux *gsm, static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c) { - int ret = 0; int need_close = 0; int need_restart = 0; @@ -3356,7 +3355,7 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c) * and removing from the mux array */ if (gsm->dead) { - ret = gsm_activate_mux(gsm); + int ret = gsm_activate_mux(gsm); if (ret) return ret; if (gsm->initiator) From patchwork Wed Apr 26 08:03:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 87705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp77951vqo; Wed, 26 Apr 2023 01:06:07 -0700 (PDT) X-Google-Smtp-Source: AKy350ZQh30YQKp7DE5BuUrD49FpZ0ZkjkunHp8+nfytZfkiU6BGc0hsJY263Z6NRfgm/1L+e3zS X-Received: by 2002:a05:6a00:148e:b0:63b:6911:8928 with SMTP id v14-20020a056a00148e00b0063b69118928mr27440615pfu.3.1682496366890; Wed, 26 Apr 2023 01:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682496366; cv=none; d=google.com; s=arc-20160816; b=SQ1rR1lVfhykpUekdQ6U5ZESzK8ObE/Esp5MoIEykd1TYnb37iKkd2+yZYiIxByNI9 TgI/YBnQ+v4C1S+zZ1DdtpT4vlfIzNsZFAy6rNCUHDwagZMpP6lgoHSeHB8S4puA1g0U 2QMr4RtUfE5vN0N2IGaY4ui7YVyCTmcHNPXRdAYiOUMBVuSkQ93EOz9XokU17SqXqHyy pE7ifzbROCinC+SGx0mFdcXSaVOLbRMNyAWG4dg/Hbl0a5crR0cMqkmpBd/Y+/9gwqX1 7W73My5rwjaGJItJFcFaXjpzQ2eLQGXuRNaZ2UHTAGeZjD4yLVdjXHkKvKMnH+mXHD97 cnxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p6b7aAXTOy3vsIR4rxhbr+q8rc2g+ZY+H/rSFp5TQGY=; b=BhHVYjwmyq70DZm2OMK0FR/zh0BZuOTh2guw3oSzuLMoCzN4u6tAmJ+d6I36qY9ZTX w8sytBdIbUeJlx2qzn3a+Fja/00yuh1SQZ79iRTpBkdViFPMHr4pQlUXPzI6lsC5CTPv YC11mBGdgWo5ZDTZ26L0/ctx4r+R2fFmaeuJGafjHx8let/lgpDAB/g7SXrI6FglDryV 3lCFcrHLbbWrBd0YRxgNSyrf3LaashD81Nm76p7y/HsKWH0pH0pASOX3tbnreo83X8Bj 0aCgrfGGH1X2CUp7ObXH3KsBTK5dY/yrL9CdsWQ3OU/FC8kZJxJsjoSOfUWay5d0i2X7 GLkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=LqDNIFJm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p10-20020aa79e8a000000b0063b7ab0b1aasi15984676pfq.242.2023.04.26.01.05.52; Wed, 26 Apr 2023 01:06:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=LqDNIFJm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239967AbjDZIDj (ORCPT + 99 others); Wed, 26 Apr 2023 04:03:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231467AbjDZIDg (ORCPT ); Wed, 26 Apr 2023 04:03:36 -0400 Received: from mta-64-227.siemens.flowmailer.net (mta-64-227.siemens.flowmailer.net [185.136.64.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F0053C20 for ; Wed, 26 Apr 2023 01:03:33 -0700 (PDT) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 2023042608033169ae164e96aed67dc3 for ; Wed, 26 Apr 2023 10:03:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=p6b7aAXTOy3vsIR4rxhbr+q8rc2g+ZY+H/rSFp5TQGY=; b=LqDNIFJmKyyINdmHMrgjdtlcucp/LjFeNDXynofdo4G/e32VT5YAMlQ5Z4MXqdPUouHhHi Cg2nQrAuo05jE7gZJj0uPufgdAMN73kbr49SNovSNnaAFuTdVENdeYqs620LhcddCNvloSzC POJ/URDsS2myMWx+X1e4Qvi1HxvLo=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v4 4/8] tty: n_gsm: add open_error counter to gsm_mux Date: Wed, 26 Apr 2023 10:03:11 +0200 Message-Id: <20230426080315.7595-4-daniel.starke@siemens.com> In-Reply-To: <20230426080315.7595-1-daniel.starke@siemens.com> References: <20230426080315.7595-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764225310498830066?= X-GMAIL-MSGID: =?utf-8?q?1764225310498830066?= From: Daniel Starke Extend the n_gsm link statistics by a failed link open counter in preparation for an upcoming patch which will expose these. This counter is increased whenever an attempt to open the control channel failed. This is true in the following cases: - new DLCI allocation failed - connection request (SAMB) with invalid CR flag has been received - connection response (UA) timed out - parameter negotiation timed out or failed Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) v3 -> v4: No changes. Link: https://lore.kernel.org/all/20230424075251.5216-4-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index ebb71957f783..186f463f0f11 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -339,6 +339,7 @@ struct gsm_mux { unsigned long bad_fcs; unsigned long malformed; unsigned long io_error; + unsigned long open_error; unsigned long bad_size; unsigned long unsupported; }; @@ -1730,25 +1731,32 @@ static void gsm_control_negotiation(struct gsm_mux *gsm, unsigned int cr, struct gsm_dlci *dlci; struct gsm_dlci_param_bits *params; - if (dlen < sizeof(struct gsm_dlci_param_bits)) + if (dlen < sizeof(struct gsm_dlci_param_bits)) { + gsm->open_error++; return; + } /* Invalid DLCI? */ params = (struct gsm_dlci_param_bits *)data; addr = FIELD_GET(PN_D_FIELD_DLCI, params->d_bits); - if (addr == 0 || addr >= NUM_DLCI || !gsm->dlci[addr]) + if (addr == 0 || addr >= NUM_DLCI || !gsm->dlci[addr]) { + gsm->open_error++; return; + } dlci = gsm->dlci[addr]; /* Too late for parameter negotiation? */ - if ((!cr && dlci->state == DLCI_OPENING) || dlci->state == DLCI_OPEN) + if ((!cr && dlci->state == DLCI_OPENING) || dlci->state == DLCI_OPEN) { + gsm->open_error++; return; + } /* Process the received parameters */ if (gsm_process_negotiation(gsm, addr, cr, params) != 0) { /* Negotiation failed. Close the link. */ if (debug & DBG_ERRORS) pr_info("%s PN failed\n", __func__); + gsm->open_error++; gsm_dlci_close(dlci); return; } @@ -1768,6 +1776,7 @@ static void gsm_control_negotiation(struct gsm_mux *gsm, unsigned int cr, } else { if (debug & DBG_ERRORS) pr_info("%s PN in invalid state\n", __func__); + gsm->open_error++; } } @@ -2221,6 +2230,7 @@ static void gsm_dlci_t1(struct timer_list *t) dlci->retries--; mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100); } else { + gsm->open_error++; gsm_dlci_begin_close(dlci); /* prevent half open link */ } break; @@ -2236,6 +2246,7 @@ static void gsm_dlci_t1(struct timer_list *t) dlci->mode = DLCI_MODE_ADM; gsm_dlci_open(dlci); } else { + gsm->open_error++; gsm_dlci_begin_close(dlci); /* prevent half open link */ } @@ -2757,12 +2768,16 @@ static void gsm_queue(struct gsm_mux *gsm) switch (gsm->control) { case SABM|PF: - if (cr == 1) + if (cr == 1) { + gsm->open_error++; goto invalid; + } if (dlci == NULL) dlci = gsm_dlci_alloc(gsm, address); - if (dlci == NULL) + if (dlci == NULL) { + gsm->open_error++; return; + } if (dlci->dead) gsm_response(gsm, address, DM|PF); else { From patchwork Wed Apr 26 08:03:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 87708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp78426vqo; Wed, 26 Apr 2023 01:07:11 -0700 (PDT) X-Google-Smtp-Source: AKy350Y1oZPZo9QJsNM9nGKB1uoNqlPiXba8BmZMbADyWTmL0EZFhKCwYajWQvr1IvkcAfhM0qoY X-Received: by 2002:a05:6a20:2443:b0:f0:3e78:715b with SMTP id t3-20020a056a20244300b000f03e78715bmr25119357pzc.40.1682496431647; Wed, 26 Apr 2023 01:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682496431; cv=none; d=google.com; s=arc-20160816; b=CjJbbGLWdSZaPCv+SzJTKvqx9wWlUPNUdvL1Q4qmsj3VsBBC2Z/3PGfzcBcyWf+uOo 2ZHcm8Cy4LicrfQluchRkBFZCmHme9KH9MAlPBSNHPb+yzPACxCwv7CCt28vWiMBGfYR gAMNjhpSp823tOCxZtQeECPFaM20jm5PLnLoqeyukOFye0X2I5gViExOq+tsnMuPvJTH Tji1OxgCzWyyw3w3H+6RSWvnrtD8KvlvwLW0PnZG2qKtbHp/6N1OkwLPlzblGotQYrDF 2qYE4MnwjdWhjYt3vK3/hP/H75kUCnxxU+n3gru16P9ANT2yRa1xE19LbpxAoqnjQi6w X+Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n93VBue8YLe4OhiAewOGivq1aA7fZ4cftiwPcFyOEGA=; b=qZhs+NtDdA0shPooTahijfz13/STfCE1URaTWAXCLnV7MfRX7yxiMUXFnXLXYvQvJS uwOR7ahakJwj3OGVEPrhrZkIXGKEQj2EZpXuQ0dNu+PTk32VdOCRmxxNLL4iF4RmUcvr q1s4sn18ibl3unOyLqEUyYXq2XnuQvjaiX7w7qfoftckFmaZsN5cm2VyngcbGbHfSMte D761chmitfrNzu6Q/SE5TNqHyZcfsc0w7Qzf4jcKbBZOOK2YalZZqCGjCuzY5D14fn3L Qs/50hR2MolWY1xyzSWiC1bh31SLRbP0LYCrfKsCLYdz/GqOakuTVwR1qALWdLgXL/mB WOgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=iHhg3PN6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v20-20020a634654000000b005139e0d2b5csi10763006pgk.487.2023.04.26.01.06.56; Wed, 26 Apr 2023 01:07:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=iHhg3PN6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240028AbjDZIDw (ORCPT + 99 others); Wed, 26 Apr 2023 04:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239943AbjDZIDg (ORCPT ); Wed, 26 Apr 2023 04:03:36 -0400 Received: from mta-64-228.siemens.flowmailer.net (mta-64-228.siemens.flowmailer.net [185.136.64.228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D26233C39 for ; Wed, 26 Apr 2023 01:03:33 -0700 (PDT) Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 20230426080331e894376af7320373af for ; Wed, 26 Apr 2023 10:03:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=n93VBue8YLe4OhiAewOGivq1aA7fZ4cftiwPcFyOEGA=; b=iHhg3PN6pCQYgTPCN2tI8Jn7nBEpR5m7L9OP1UZleR07/97xPskAQLDJAPcOpaj6/MLISf RxGW/4L8VGia4AjNB+bOs21NVemge0kmuMzc3N7d2S54tpe/V0FIsgP6o+L8E+/XWscLi98d HT3/Oz0kCM08cEwWspWuNjoy3a2dU=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v4 5/8] tty: n_gsm: increase malformed counter for malformed control frames Date: Wed, 26 Apr 2023 10:03:12 +0200 Message-Id: <20230426080315.7595-5-daniel.starke@siemens.com> In-Reply-To: <20230426080315.7595-1-daniel.starke@siemens.com> References: <20230426080315.7595-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764225378618796783?= X-GMAIL-MSGID: =?utf-8?q?1764225378618796783?= From: Daniel Starke The malformed counter in gsm_mux is already increased in case of errors detected in gsm_queue() and gsm1_receive(). gsm_dlci_command() also detects a case for a malformed frame but does not increase the malformed counter yet. Fix this by also increasing the gsm_mux malformed counter in case of a malformed frame in gsm_dlci_command(). Note that the malformed counter is not yet exposed and only set internally. Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) v3 -> v4: No changes. Link: https://lore.kernel.org/all/20230424075251.5216-5-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 186f463f0f11..5b6a03668c78 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2455,8 +2455,10 @@ static void gsm_dlci_command(struct gsm_dlci *dlci, const u8 *data, int len) data += dlen; /* Malformed command? */ - if (clen > len) + if (clen > len) { + dlci->gsm->malformed++; return; + } if (command & 1) gsm_control_message(dlci->gsm, command, data, clen); From patchwork Wed Apr 26 08:03:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 87714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp80662vqo; Wed, 26 Apr 2023 01:12:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7eqiodFFKFHkViABGYndNfVjGQLLmrL6PYTZtTh09IpD1xYEa9fHnpg7QdICCULf62LpSV X-Received: by 2002:a17:903:244f:b0:1a6:98a4:e941 with SMTP id l15-20020a170903244f00b001a698a4e941mr2200109pls.2.1682496746621; Wed, 26 Apr 2023 01:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682496746; cv=none; d=google.com; s=arc-20160816; b=LGPtIcB+rue126CgDNhhbxNm6DZxCrpcjV/TIgLVpWh0cfNs/AuRJrI+R/Iw4nbA1C LNiGlKfQmtlXXW3SDjmEE54K73xIBC8nvp2R4SltRcMuwkJZPP2FmmtzdXzVZfnjEk3Y EAFavCAIARmeRwSa6kPuYFEf8SnOFMIckKmEMrj596Pv7F8f0Um6vbEiMv+XstBVllQ9 qDcLrukdm4W+VHfUbVAdGdxpewfxtW+n5dsp0oLuwDzKm5ebiGCqBp5oRi1ke/kY6S0r 5ujI3pFSczJv4EbOsfPxkE7hlxAjDyDRH2hL7Lstat5Rks5hGetUoEeuOHcAhNvJragM kDww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=saTOVTX775J8QuM0f3QiYXo+gF2XB4EnX95vsbsYgmg=; b=Nz/bHP19liTx8IubzP73sPkeSAcS8AZL9Z4ajLJXqAB8kuOlf+I30D0/xL96YCnpdh JyVDkg2GX/aAnmQsjUw1DodGv9HfPY0r1yZuHQJF7uSG1iMYVXa+5ZdX11mtNx561fVl WVjgOIodNzhyAqfxwKF93x4JnKdgvihp/f7hEjj8fHyAFfViMLPeubGv0sMoCMMyWSWt bqyhdmxKCoYSpZP2Z3pzDl1lhMt/35dX4KPTMFICSq6ZOF9dXz2VKNRlJ011AnzYmdnL a4ZsCk97/Iii0K4wve6e4uHSQYHDhYBMgG04Q9+vEIcDU0+GC7C3YiRtJLp6lLzIHmyl rRUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=H4A9kP5Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020a170902e84600b001a66c501a46si17278178plg.136.2023.04.26.01.12.11; Wed, 26 Apr 2023 01:12:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=H4A9kP5Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239987AbjDZIDy (ORCPT + 99 others); Wed, 26 Apr 2023 04:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239962AbjDZIDh (ORCPT ); Wed, 26 Apr 2023 04:03:37 -0400 Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net [185.136.65.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1196CDC for ; Wed, 26 Apr 2023 01:03:34 -0700 (PDT) Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 20230426080332c5d2d6dab017c90b88 for ; Wed, 26 Apr 2023 10:03:32 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=saTOVTX775J8QuM0f3QiYXo+gF2XB4EnX95vsbsYgmg=; b=H4A9kP5YhkfD+yrRnUdwwGuDj+lWE7tRshaKZLg3c2yOrbUb7TVnK6QQZHQmcYUNMgbaBN TDTWPD4BcK+9YqPawXyq4EtNO7s13h1TPu9TIuHvMrp4jX86gjUE+V7pVLGyT7kFodwJLUdd aOYfaHspkuG36aDzD02WLeeGbF3WQ=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v4 6/8] tty: n_gsm: increase gsm_mux unsupported counted where appropriate Date: Wed, 26 Apr 2023 10:03:13 +0200 Message-Id: <20230426080315.7595-6-daniel.starke@siemens.com> In-Reply-To: <20230426080315.7595-1-daniel.starke@siemens.com> References: <20230426080315.7595-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764225708464304933?= X-GMAIL-MSGID: =?utf-8?q?1764225708464304933?= From: Daniel Starke The structure gsm_mux contains the 'unsupported' field. However, there is currently no place in the code which increases this counter. Increase the 'unsupported' statistics counter in the following case: - an unsupported frame type has been requested by the peer via parameter negotiation - a control frame with an unsupported but known command has been received Note that we have no means to detect an inconsistent/unsupported adaptation sufficient accuracy as this changes the structure of the UI/UIH frames. E.g. a one byte header is added in case of convergence layer type 2 instead of 1 and contains the modem signal octet with the state of the signal lines. There is no checksum or other value which indicates of this field is correct or should be present. Therefore, we can only assume protocol correctness here. See also 'gsm_dlci_data()' where this is handled. Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 3 +++ 1 file changed, 3 insertions(+) v3 -> v4: No changes. Link: https://lore.kernel.org/all/20230424075251.5216-6-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 5b6a03668c78..42a8507aae4a 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1590,6 +1590,7 @@ static int gsm_process_negotiation(struct gsm_mux *gsm, unsigned int addr, if (debug & DBG_ERRORS) pr_info("%s unsupported I frame request in PN\n", __func__); + gsm->unsupported++; return -EINVAL; default: if (debug & DBG_ERRORS) @@ -1897,6 +1898,8 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command, /* Optional unsupported commands */ case CMD_RPN: /* Remote port negotiation */ case CMD_SNC: /* Service negotiation command */ + gsm->unsupported++; + fallthrough; default: /* Reply to bad commands with an NSC */ buf[0] = command; From patchwork Wed Apr 26 08:03:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 87717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp82297vqo; Wed, 26 Apr 2023 01:16:15 -0700 (PDT) X-Google-Smtp-Source: AKy350YPvQQflCyeBYqj//wjgYhMB+4sC1ieMrNuvSyKGdgtuYDwaGQJV4EHAp6f3Kie23nyuW3f X-Received: by 2002:a05:6a00:1a50:b0:627:e49a:871a with SMTP id h16-20020a056a001a5000b00627e49a871amr28769824pfv.23.1682496975379; Wed, 26 Apr 2023 01:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682496975; cv=none; d=google.com; s=arc-20160816; b=AKT7m8ZH42qZyV2pj8zUDKkLPpZTGa/Zlq9HeZxEkQiI9tsSewc3+rbJMGgCUyNk6m 091H4oc5Hh7dRieyBRDYtAEBOqI0UjZtNZCb85RsUeN2V4jo5TqV6EUQtWekTil9v+Wj v3coxWf5MafgAPky5wPY+XGC2Cpdww8/LouPfUnI3rzm9wx036PBveOkSU/Tf0LAEZuF 2TZZrsEfD48FMKMQlx8vdcbSdNo0nXnx5IQFRbenuqf9XUEE1UfXXYX5yPQ7RMLUNhVi WdBQf3qCQMwAGcl+BpuYrjd6FshyDUoC7EOpzzIIkw95+koRcxCl1FDL5AUiTOXex2lU ELow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g/POsgYzx0iNIkOXHjUNfsg79fBTNv1rDvs7utfEfXM=; b=jtH1JN3JB3rUqmMXAAXY4bsze8PXarrVHcPVfJG0mwX39HSZrPWiU+9fXI8k3mYYUs 7ovEjOCdvobYCb5UTSLZpRfiMPfVRNMFqjB4uwFNLzRBOXBQGLtf4KsYJPiYnd7QiCFj +9JlKsUYQmFlpuGLAFsHKNahOUz22PORYEANAFsJr6hFyIjnS9h2PaLL7jyPuGX8COpp MLrNz1jWXcnIRDLrjCHjwzL+chbCO6FiWYvSL7d1Ip514Ersza0dRaFL9Lw0HfWSgA/u ZsAYUqA60NGuPULDMEl+NY5dHt55M69vIzELxi1vOmvPwwWiMWaXeUn1ojypd0Vbghs9 j0Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=cvdcFMRd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020aa7984f000000b0063b13efdd06si13286988pfq.345.2023.04.26.01.16.00; Wed, 26 Apr 2023 01:16:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=cvdcFMRd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239943AbjDZIFT (ORCPT + 99 others); Wed, 26 Apr 2023 04:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240106AbjDZIFE (ORCPT ); Wed, 26 Apr 2023 04:05:04 -0400 X-Greylist: delayed 61 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 26 Apr 2023 01:04:37 PDT Received: from mta-65-226.siemens.flowmailer.net (mta-65-226.siemens.flowmailer.net [185.136.65.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04D1140F4 for ; Wed, 26 Apr 2023 01:04:36 -0700 (PDT) Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 2023042608033228aa3e9bc3d44d7d04 for ; Wed, 26 Apr 2023 10:03:32 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=g/POsgYzx0iNIkOXHjUNfsg79fBTNv1rDvs7utfEfXM=; b=cvdcFMRdlJamOkipMgieO06dzyWVLe0EQdcpYtvw0PWGAJBs42zxXYwuqB+A8+jcNmRisV RGC4oAnWGH8+0ckTdHRh8q7MFKnY/YmJpPLXH5zPYm9J7Wjj+dt9lAPqxNnvFED0xIZ5KUnW JhVDxKNHveQk41ZRz0NG0wQcdwyzQ=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v4 7/8] tty: n_gsm: cleanup gsm_control_command and gsm_control_reply Date: Wed, 26 Apr 2023 10:03:14 +0200 Message-Id: <20230426080315.7595-7-daniel.starke@siemens.com> In-Reply-To: <20230426080315.7595-1-daniel.starke@siemens.com> References: <20230426080315.7595-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764225948122808822?= X-GMAIL-MSGID: =?utf-8?q?1764225948122808822?= From: Daniel Starke There are multiple places in gsm_control_command and gsm_control_reply that derive the specific DLCI handle directly out of the DLCI table in gsm. Add a local variable which holds this handle and use it instead to improve code readability. Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) v3 -> v4: No changes. Link: https://lore.kernel.org/all/20230424075251.5216-7-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 42a8507aae4a..62bff4474b57 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1451,15 +1451,16 @@ static int gsm_control_command(struct gsm_mux *gsm, int cmd, const u8 *data, int dlen) { struct gsm_msg *msg; + struct gsm_dlci *dlci = gsm->dlci[0]; - msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->dlci[0]->ftype); + msg = gsm_data_alloc(gsm, 0, dlen + 2, dlci->ftype); if (msg == NULL) return -ENOMEM; msg->data[0] = (cmd << 1) | CR | EA; /* Set C/R */ msg->data[1] = (dlen << 1) | EA; memcpy(msg->data + 2, data, dlen); - gsm_data_queue(gsm->dlci[0], msg); + gsm_data_queue(dlci, msg); return 0; } @@ -1478,14 +1479,15 @@ static void gsm_control_reply(struct gsm_mux *gsm, int cmd, const u8 *data, int dlen) { struct gsm_msg *msg; + struct gsm_dlci *dlci = gsm->dlci[0]; - msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->dlci[0]->ftype); + msg = gsm_data_alloc(gsm, 0, dlen + 2, dlci->ftype); if (msg == NULL) return; msg->data[0] = (cmd & 0xFE) << 1 | EA; /* Clear C/R */ msg->data[1] = (dlen << 1) | EA; memcpy(msg->data + 2, data, dlen); - gsm_data_queue(gsm->dlci[0], msg); + gsm_data_queue(dlci, msg); } /** From patchwork Wed Apr 26 08:03:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 87720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp83073vqo; Wed, 26 Apr 2023 01:18:25 -0700 (PDT) X-Google-Smtp-Source: AKy350ZSCbbB6kT6rT477YzuO0iinddKicPR1aMbO5KRO4/cCtqMRcEXUAsGD26a1XdIQE8fcQz4 X-Received: by 2002:a17:902:eb87:b0:1a7:c058:a167 with SMTP id q7-20020a170902eb8700b001a7c058a167mr19444814plg.25.1682497105094; Wed, 26 Apr 2023 01:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682497105; cv=none; d=google.com; s=arc-20160816; b=eYzc2Mv72wr5pBeVbcRiWGm1IwtIOdN5znH8Y2RUL0MY7OIMpWRNJ+YOeGsjIab0GI b/hAz1y1/8cQK1NFOMJI3Rk0pbwhejkHn9p37AfziM8lk3vCgNiG9ljA5WiW99YPeHAS dgimygz0SlLy1wV3fGSe7sGFYzfR3otxZvzv7zOg8z69pMfPgfxT/KFCxcCuE3zbgStk TlkMUy6suykP0kpMHKpojwyfI7pGXHOVqQnCqE3XaG8ZYLXhmXkLrybYVQ7GRKDul6+3 faguPDHUZWRz3+myvregsHLqVvD61qd75mwSTNj/KTvrL2fggrpKfCpU4B+QPr7VcsqE r7XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lC6w6yfdqndEz513xywOwMNVxUGFN+4gfRNRaxuBxcE=; b=Oulz69Bhkn1XMNSC2Tu0O0zHwyw8y+oVIysoBBBRtpU7AcdGVl48IJxhyTRbrtyez2 QJdgcsPshA0UxoX9Z3xuYNmqc3VQWZVAW2VlE8O0QnxdlhzYhhCtv3foUT1LyIfU/+jo Xxs60ZkeDOl2nE1l49AeN4C1TX9rdwv/uedFy/U+7lG/q1A3PxsPkCReLXsAhZVuT493 wGbmy/1t5NpleOh5F+wgp/QEcY5mpilmJ4jly6qQ+62k3I0tJURUaOYmQSYhLVxeyJF6 hVMt+mjyqXjyz2aSkhWMtltbLw8kae6MqiN4ytWe9XCJ6Ee/PlaSUAM8UM8lgmeBhWUO 4i0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=NV7Vm5uI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020a170902e81100b001a69cb35b3asi16346508plg.601.2023.04.26.01.18.10; Wed, 26 Apr 2023 01:18:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=NV7Vm5uI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239944AbjDZIFP (ORCPT + 99 others); Wed, 26 Apr 2023 04:05:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240107AbjDZIFE (ORCPT ); Wed, 26 Apr 2023 04:05:04 -0400 Received: from mta-65-226.siemens.flowmailer.net (mta-65-226.siemens.flowmailer.net [185.136.65.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 050124481 for ; Wed, 26 Apr 2023 01:04:36 -0700 (PDT) Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 20230426080333613b1a8ebe0ca6762f for ; Wed, 26 Apr 2023 10:03:33 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=lC6w6yfdqndEz513xywOwMNVxUGFN+4gfRNRaxuBxcE=; b=NV7Vm5uIsTst6KZMgfww/S0vuoLU6RshrikuGmbEbRXyJHXfZ6xhUASUAjBxxveZVKrxA/ qgliGtYy2TAaXn69LsBR18MbtD5XMdIqcHibqCh0idvmIcknjoYQMETjGXXoMAJjS+EzZW/8 R9XdKoBj3rDBYXY0lN7sNWtjFXpiU=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v4 8/8] tty: n_gsm: add DLCI specific rx/tx statistics Date: Wed, 26 Apr 2023 10:03:15 +0200 Message-Id: <20230426080315.7595-8-daniel.starke@siemens.com> In-Reply-To: <20230426080315.7595-1-daniel.starke@siemens.com> References: <20230426080315.7595-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764226084692821867?= X-GMAIL-MSGID: =?utf-8?q?1764226084692821867?= From: Daniel Starke Add counters for the number of data bytes received/transmitted per DLCI in for preparation for an upcoming patch which will expose these values to the user. Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) v3 -> v4: No changes. Link: https://lore.kernel.org/all/20230424075251.5216-8-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 62bff4474b57..2e2e1dafcf40 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -186,6 +186,9 @@ struct gsm_dlci { void (*data)(struct gsm_dlci *dlci, const u8 *data, int len); void (*prev_data)(struct gsm_dlci *dlci, const u8 *data, int len); struct net_device *net; /* network interface, if created */ + /* Statistics (not currently exposed) */ + u64 tx; /* Data bytes sent on this DLCI */ + u64 rx; /* Data bytes received on this DLCI */ }; /* @@ -1216,6 +1219,7 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci) tty_port_tty_wakeup(&dlci->port); __gsm_data_queue(dlci, msg); + dlci->tx += len; /* Bytes of data we used up */ return size; } @@ -1283,6 +1287,7 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm, memcpy(dp, dlci->skb->data, len); skb_pull(dlci->skb, len); __gsm_data_queue(dlci, msg); + dlci->tx += len; if (last) { dev_kfree_skb_any(dlci->skb); dlci->skb = NULL; @@ -1461,6 +1466,7 @@ static int gsm_control_command(struct gsm_mux *gsm, int cmd, const u8 *data, msg->data[1] = (dlen << 1) | EA; memcpy(msg->data + 2, data, dlen); gsm_data_queue(dlci, msg); + dlci->tx += dlen; return 0; } @@ -1488,6 +1494,7 @@ static void gsm_control_reply(struct gsm_mux *gsm, int cmd, const u8 *data, msg->data[1] = (dlen << 1) | EA; memcpy(msg->data + 2, data, dlen); gsm_data_queue(dlci, msg); + dlci->tx += dlen; } /** @@ -1852,10 +1859,13 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command, const u8 *data, int clen) { u8 buf[1]; + struct gsm_dlci *dlci = gsm->dlci[0]; + + if (dlci) + dlci->rx += clen; switch (command) { case CMD_CLD: { - struct gsm_dlci *dlci = gsm->dlci[0]; /* Modem wishes to close down */ if (dlci) { dlci->dead = true; @@ -1934,6 +1944,8 @@ static void gsm_control_response(struct gsm_mux *gsm, unsigned int command, ctrl = gsm->pending_cmd; dlci = gsm->dlci[0]; + if (dlci) + dlci->rx += clen; command |= 1; /* Does the reply match our command */ if (ctrl != NULL && (command == ctrl->cmd || command == CMD_NSC)) { @@ -2298,6 +2310,9 @@ static void gsm_dlci_begin_open(struct gsm_dlci *dlci) need_pn = true; } + dlci->tx = 0; + dlci->rx = 0; + switch (dlci->state) { case DLCI_CLOSED: case DLCI_WAITING_CONFIG: @@ -2330,6 +2345,9 @@ static void gsm_dlci_begin_open(struct gsm_dlci *dlci) */ static void gsm_dlci_set_opening(struct gsm_dlci *dlci) { + dlci->tx = 0; + dlci->rx = 0; + switch (dlci->state) { case DLCI_CLOSED: case DLCI_WAITING_CONFIG: @@ -2349,6 +2367,9 @@ static void gsm_dlci_set_opening(struct gsm_dlci *dlci) */ static void gsm_dlci_set_wait_config(struct gsm_dlci *dlci) { + dlci->tx = 0; + dlci->rx = 0; + switch (dlci->state) { case DLCI_CLOSED: case DLCI_CLOSING: @@ -2425,6 +2446,7 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, const u8 *data, int clen) fallthrough; case 1: /* Line state will go via DLCI 0 controls only */ default: + dlci->rx += clen; tty_insert_flip_string(port, data, clen); tty_flip_buffer_push(port); } @@ -2785,6 +2807,7 @@ static void gsm_queue(struct gsm_mux *gsm) gsm->open_error++; return; } + dlci->rx += gsm->len; if (dlci->dead) gsm_response(gsm, address, DM|PF); else {