From patchwork Thu Apr 20 08:50:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 85789 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp186914vqo; Thu, 20 Apr 2023 02:07:46 -0700 (PDT) X-Google-Smtp-Source: AKy350ang2+RyTZZMhHa2uLdIUHMVXzDIyGz39UGnJH5lVMimaEjf9n7XcOoAW+N5vYsgEVl98l1 X-Received: by 2002:a05:6a21:99a1:b0:ee:d266:32b9 with SMTP id ve33-20020a056a2199a100b000eed26632b9mr1575212pzb.10.1681981666181; Thu, 20 Apr 2023 02:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981666; cv=none; d=google.com; s=arc-20160816; b=0KPrK5gXqBXV6pKwjMy3HogOCWyP34LNkGmcwrWKGT5XZl8RVjr0QbKvOsNbR8AFIR dBb+bM9FqI64XzqPDrN1Jh60J+YGCYKOSGj1yw1fOOfuI/gWddY6mRdrSCQDCnHoAaCq A5zrreR0Y0XChNTv0lA00NEmIs+HjGMczEJ6QF7Dn7XOPmIGJ7xg+/LMJuSXT3TN75gq PH3HUlkpJsMc99rucS19/nqMvqj9hiwxXPN2fOV1yMLPiQkuK13NIbVqUNG9j3qmXJ4Y StGLBz4w2k+YuUdoO3nDVSQMrtDbGnonTwnnCPy5bHk5TvHpumXPOhCAkDmldu2JCKVP W4kA== 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=oSulKytkzWMOv+kgWgQEjqlRjBDH0GiaM4Nt6CmQ6uE=; b=qX2F57pazmK2h+/vSGdi+bzvaoVAvkQRQxe4FI+s4VJBbKfzk/vu8r07YMGCphctf1 KFgfG2T6Iqmi16oKHNaGhsWE7WzpBLdHpgqi4EAvzfG5NpMT8PxZibjtSAterW1F3W8X WTcYCriB1mrUev7hOcYm+SZC+6f4mWQI2Wf2Yrx28tk05nWDnztxIclDLD5WWx2HcvVn +GnW+tPaTtdrpEcTGVZq/q/QGYva6kV2StOr0MiK9QvhGPYObBXscMKRSFUW+l/xL9jr rRL5mSsZ2Qt+y9JSgjyFvyzIT5XmF1wDUlqGl0k5HhCP4aVE7c5C/uNkYhSp7lQLb/Qr AebA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=H3Bf3Xfs; 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 h11-20020a65480b000000b0051352239dc2si999914pgs.839.2023.04.20.02.07.33; Thu, 20 Apr 2023 02:07:46 -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=H3Bf3Xfs; 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 S234520AbjDTI4N (ORCPT + 99 others); Thu, 20 Apr 2023 04:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234281AbjDTIyp (ORCPT ); Thu, 20 Apr 2023 04:54:45 -0400 X-Greylist: delayed 72 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 20 Apr 2023 01:53:12 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 BDD4B4C1E for ; Thu, 20 Apr 2023 01:53:12 -0700 (PDT) Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 20230420085158fa117b030f0e7ba1f0 for ; Thu, 20 Apr 2023 10:51:58 +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=oSulKytkzWMOv+kgWgQEjqlRjBDH0GiaM4Nt6CmQ6uE=; b=H3Bf3XfsSLywLif6PpgsJJi4WNvmVpQOlZLznH+PPooqlzDhVpOPeQtn6BggKtXLtvTtGD TQpgfkfrpoI3pShOkwRM9Oi8qqZZrk8935yV5syD9+qaHX2+gh8fkMHSEmDNmob2WuOmzwXJ j47+FWaZfErSPfnJZ4yQSQE15xMX8=; 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 v2 1/9] tty: n_gsm: fix redundant assignment of gsm->encoding Date: Thu, 20 Apr 2023 10:50:09 +0200 Message-Id: <20230420085017.7314-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 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?1763685607543844694?= X-GMAIL-MSGID: =?utf-8?q?1763685607543844694?= From: Daniel Starke The function gsmld_open() contains a redundant assignment of gsm->encoding. The same value of GSM_ADV_OPT is already assigned to it during the initialization of the struct in gsm_alloc_mux() a few lines earlier. Fix this by removing the redundant second assignment of gsm->encoding in gsmld_open(). Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Reviewed-by: Ilpo Järvinen Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 1 - 1 file changed, 1 deletion(-) v1 -> v2: Added Reviewed-by tag. Link: https://lore.kernel.org/all/adf7aae2-2fd8-b191-f37-75185167f418@linux.intel.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index b7e1369a035c..c42c8b89fd46 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3585,7 +3585,6 @@ static int gsmld_open(struct tty_struct *tty) tty->receive_room = 65536; /* Attach the initial passive connection */ - gsm->encoding = GSM_ADV_OPT; gsmld_attach_gsm(tty, gsm); /* The mux will not be activated yet, we wait for correct From patchwork Thu Apr 20 08:50: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: 85790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp186944vqo; Thu, 20 Apr 2023 02:07:50 -0700 (PDT) X-Google-Smtp-Source: AKy350ZK63QUP8YrzakT2DxOV2oAVGCmMe2jlS/UFA/Y43D97O6uwEOYD6zBHOCQ3wcBv0Xbk4R2 X-Received: by 2002:a05:6a00:13aa:b0:633:8cc7:bbd5 with SMTP id t42-20020a056a0013aa00b006338cc7bbd5mr964683pfg.11.1681981669718; Thu, 20 Apr 2023 02:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981669; cv=none; d=google.com; s=arc-20160816; b=ZF+tNBMIM3gVdvw/Vvfrv2kcEUZoYVshqkhWNRCVvemhzsnQMdyjKrm2W8ZDu9OUR2 1hpMemMWwf+CxlrDiTTyxBG41RZ3xQJ+hlvMxUEQpT/F6X2xFijaGVODO8oCOnbyniiG HsMwAaEwCGyLdMEBPlMKj4LSLls6hGvuo6CPMoD0rqBzHVqr2xnUxV96nm/ojfBdmLbQ z90argWczYQseiC97J9bHz0EowgIKhjR+qiLnr5sTfd3ylTj7DDt+5HKQ/D38S94Mzl2 bWrL4h++B3MyQupa4ZZ9CPP7GNUzsSCDAGEl3h0yOVDwNWT2Q5v7SQaEKWw4Ug6V/bX2 upTg== 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=Y2LTmzdIUeHUdjGT1TEFeLvtTYBm6sbII2BeByX9Cyo=; b=ZA4Fa98HQ1URdb/rJ1SmfHK7qm2Coatdr+KX5wt3OONRK312E4XM2kpmDc8I51XvmQ TaM0aravZgvii/go93LaYueKLr5CdzjlPHJmJKSwyVGTqWJ/j9Hp/r4e0VJnzRKE3jeo uehEfTltx0Q7F+xCU6RH568q7mqS34G/xZrKcESFUaBslHhX1qVjACOnYNYuatEUsxCZ +TWhUo9LbudA6qMm3mZNCBcqpQ0WBby/HqCB9xxB3qhVb1ShaNksahWIyC/SFt8B6ylP LNMLwZ7kgVmbU1n/wMbBiJc54RKKIUukS394p1m3ygIm64bZEtQ45+DRZcUfcf5ixOVG XmkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=TVE5mZ0y; 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 f189-20020a6251c6000000b0063286f81d35si1146644pfb.262.2023.04.20.02.07.36; Thu, 20 Apr 2023 02:07:49 -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=TVE5mZ0y; 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 S231989AbjDTIzD (ORCPT + 99 others); Thu, 20 Apr 2023 04:55:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234187AbjDTIxp (ORCPT ); Thu, 20 Apr 2023 04:53:45 -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 EFA975FE1 for ; Thu, 20 Apr 2023 01:52:00 -0700 (PDT) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 20230420085158890bcb4770add0d669 for ; Thu, 20 Apr 2023 10:51:59 +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=Y2LTmzdIUeHUdjGT1TEFeLvtTYBm6sbII2BeByX9Cyo=; b=TVE5mZ0ygCr3yjUkb74h5JCCCkbjlfuUUsG9EubKy+za7fBXiApvXJqU8xE6FFCwShHJIG zXjELbbG9bF7g2j0ZKrVWy7boHLYpCdfCyp0N8ECBHNTlN+75krikafr3SJu1zO3Pz7os5dW PabIdKzD6bBXunqVc6Sjmwse9+AkY=; 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 v2 2/9] tty: n_gsm: add restart parameter to DLC specific ioctl config Date: Thu, 20 Apr 2023 10:50:10 +0200 Message-Id: <20230420085017.7314-2-daniel.starke@siemens.com> In-Reply-To: <20230420085017.7314-1-daniel.starke@siemens.com> References: <20230420085017.7314-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 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?1763685611472912431?= X-GMAIL-MSGID: =?utf-8?q?1763685611472912431?= 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 'restart' to 'gsm_dlci_config' to force a channel reset after ioctl setting regardless of whether the changes made require this or not. Note that the parameter is limited to the values 0 and 1 to allow future additions here. Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 4 ++++ include/uapi/linux/gsmmux.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) v1 -> v2: Changed wording as remarked in the review. Link: https://lore.kernel.org/all/AS4PR10MB5895BA5B2ECFFF74DDBAB571E0919@AS4PR10MB5895.EURPRD10.PROD.OUTLOOK.COM/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index c42c8b89fd46..eb21ca583642 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2531,6 +2531,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->restart > 1) /* allow future extensions */ + return -EINVAL; /* * See what is needed for reconfiguration @@ -2545,6 +2547,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->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..33ee7b857c52 100644 --- a/include/uapi/linux/gsmmux.h +++ b/include/uapi/linux/gsmmux.h @@ -58,7 +58,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 restart; /* Force DLCI channel reset? */ + __u32 reserved[7]; /* For future use, must be initialized to zero */ }; #define GSMIOC_GETCONF_DLCI _IOWR('G', 7, struct gsm_dlci_config) From patchwork Thu Apr 20 08:50: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: 85796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp187569vqo; Thu, 20 Apr 2023 02:09:03 -0700 (PDT) X-Google-Smtp-Source: AKy350bFweDw+3aLlzlCPsog4P2NoAeGKsXMxsPH/qUyoc+GwbbVFMUk6Wz4yAU55ssoTua3CODv X-Received: by 2002:a05:6a20:729a:b0:ef:ead5:6fdf with SMTP id o26-20020a056a20729a00b000efead56fdfmr1493791pzk.33.1681981742921; Thu, 20 Apr 2023 02:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981742; cv=none; d=google.com; s=arc-20160816; b=a9zPTJUVx5EKp4NB6IUvpF+H1cK3XafrFJ47Nk66Vm5ABCFPxxl6nARVvak13EQFWC gU77PxVnO6aNCQ/I2ewtP4xGvEltoDOApcz+lObq4W+C6pisFIb7fSwgex4hcGoqr8IV VoYFEp+lO98jL83SOlNu8bM1Rm4IwYHB3Qu/JP6JektnsQYLYtRZqtOw8mmgJeA/zmFY BmQafn3/oQwwuj9NMGw8R9y9ZRx6pnE+zTtqetHSdX5n5K1ZIFFkT3XW5JkW1nQuEkK1 l29sgG1Qz4K7ogsqlR1ys6AYA3aEUwbnhP8RkvB8kw3Ae+xCOY9uKpU/DzJT/iVleITA ieYQ== 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=7MNaE1HTKvukMJ9m1g98lEt+XmsMRBduxzjINiIWnBE=; b=dt0kDM/pjm5HmsVDFTCTe5zq7Yy9h+gqutXEWWccqiUxUU+/PzyCthNLKvUSTcoUhA UK5L887BtXOmWuw8KCapb+neTrTQNl98aEdyYMx6zz8z2ZcOHuAjIn8hmdbCHfBZloWV 8bQWr0Q8BVxzgsEihFMR1AQH0K0mBARYw5ffeGY9qFFCdoUTffHCf3pDtxMTZ61+IF6/ zE5/kxe/48bfv2+qxo3D54dHq+sQgyetW8Y+skZFNtd37qZEJI0tUeAGiurseY2hqImU TeIBEiHw1PN1alR0mSGdwMfdIyRvVCPqURhJg5+RiCURPWf3ObGnJiltjktHO0q970Fp xe6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=m8YbMEjK; 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 j7-20020a654287000000b0050e7254402esi1121889pgp.208.2023.04.20.02.08.49; Thu, 20 Apr 2023 02:09: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=m8YbMEjK; 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 S234512AbjDTIy6 (ORCPT + 99 others); Thu, 20 Apr 2023 04:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234188AbjDTIxp (ORCPT ); Thu, 20 Apr 2023 04:53:45 -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 1B3D86A6F for ; Thu, 20 Apr 2023 01:52:01 -0700 (PDT) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 20230420085159c6afeecf08a1b5d7ef for ; Thu, 20 Apr 2023 10:51:59 +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=7MNaE1HTKvukMJ9m1g98lEt+XmsMRBduxzjINiIWnBE=; b=m8YbMEjKF+E6FgUq5fYKF2eWGxj7w+j9I3bjoFkFNp8aCCRvicaQk8PVd8ppp4prvwdKtZ X1JCTiDZupsxpka8ng9gldocD2BiRzMWIVQaRMVFTejbrTveDf/tVaWxj05Y7szJMecanHny 60I8IosV5p1r0QxwUxJtvRu6UnrtM=; 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 v2 3/9] tty: n_gsm: add missing description to gsm_config Date: Thu, 20 Apr 2023 10:50:11 +0200 Message-Id: <20230420085017.7314-3-daniel.starke@siemens.com> In-Reply-To: <20230420085017.7314-1-daniel.starke@siemens.com> References: <20230420085017.7314-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 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?1763685688184636898?= X-GMAIL-MSGID: =?utf-8?q?1763685688184636898?= From: Daniel Starke Currently, all available structure fields in gsmmux.h except those for gsm_config are commented. Fix this by adding appropriate comments to the not commented fields. 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 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) v1 -> v2: Added remark regarding the mru/mtu size comment as this was unclear in the review. Link: https://lore.kernel.org/all/AS4PR10MB5895ADDAF211A669CCF7F8C5E0919@AS4PR10MB5895.EURPRD10.PROD.OUTLOOK.COM/ diff --git a/include/uapi/linux/gsmmux.h b/include/uapi/linux/gsmmux.h index 33ee7b857c52..422a52e184b3 100644 --- a/include/uapi/linux/gsmmux.h +++ b/include/uapi/linux/gsmmux.h @@ -8,17 +8,17 @@ struct gsm_config { - unsigned int adaption; - unsigned int encapsulation; - unsigned int initiator; - unsigned int t1; - unsigned int t2; - unsigned int t3; - unsigned int n2; - unsigned int mru; - unsigned int mtu; - unsigned int k; - unsigned int i; + unsigned int adaption; /* Convergence layer type */ + unsigned int encapsulation; /* Framing (0 = basic option, 1 = advanced option) */ + unsigned int initiator; /* Initiator or responder */ + unsigned int t1; /* Acknowledgment timer */ + unsigned int t2; /* Response timer for multiplexer control channel */ + unsigned int t3; /* Response timer for wake-up procedure */ + unsigned int n2; /* Maximum number of retransmissions */ + unsigned int mru; /* Maximum incoming frame payload size */ + unsigned int mtu; /* Maximum outgoing frame payload size */ + unsigned int k; /* Window size */ + unsigned int i; /* Frame type (1 = UIH, 2 = UI) */ unsigned int unused[8]; /* Can not be used */ }; From patchwork Thu Apr 20 08:50: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: 85791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp187069vqo; Thu, 20 Apr 2023 02:08:04 -0700 (PDT) X-Google-Smtp-Source: AKy350Z/LU7tAZynINkxv0oFkVFNOnJAPjUuyR2cahpbJBM1IupNu69+ilvYRCUxuid9AMulByYa X-Received: by 2002:a05:6a00:1796:b0:634:7ba3:d140 with SMTP id s22-20020a056a00179600b006347ba3d140mr724393pfg.15.1681981684550; Thu, 20 Apr 2023 02:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981684; cv=none; d=google.com; s=arc-20160816; b=jHAcpBOGdn2f0bOaR3zIHc/u3OR1FZ4dxJAiI2MgITjDLrY6ItBntu08H/f96RRZwe 43JRUyQe1eZ9TdAJDB6loMtctnQ+LZ6dlEpYeS5cQokClaM1Go8M68ee5AkTVoe0IM/k WpG7fC7zMOINXfEF5kQMvNbgeZoB7Xb61/qYDsxNIYxhhmZC9uaZtZjQAW4Uxzh7y4ZC zEUSPUcgTbfT5yWadHHmcV0+4ZCo6GBQtiOAGUEYH8qV8kZ4mVUTaJ8rMhtSgCWri/6c x1As5c9/yKsFvaWkQFKENCuX5GMbvfbTfeBH/UkcuKrCt4eW2WiCcbSzZDxRl06upMfk ROiQ== 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=wbNM1vDNuJkkGCnV4LllCW3D4zhsGMii5QKdt4aDywU=; b=OYC1Y2hfjbLhFSpe2zGfM/Or+14GnA9b9vonOENCA49Qg3jq/mKwFGQZiPLsAGeeeI zwhwKKrtFHlWVT7/nWfOfVnDvYgo4gvXF3KH1PTsn9gAByIIzj/IcVOvG/CfWvDOv0fL p+OZxBICOyiysF/YWMXj7GaonGRbQ53DI0zaKvRtZlN9B7buUJZG2uxSUBYa7dl3mvz4 XC4Bu7exfbz23/h3IWGQWGugtPXo9iYzVHa9o7Kfo+3RWgLHOgv9TiS0mp4ucNawyjLD JlXhjhYd5uPF/6H6r5Cg/K2PJZ30fAQHpodDz+TzCAqujBBj5St4y3/P1A2PuM8ok0XP A4Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=nFgxN3fT; 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 83-20020a630556000000b00517a2ca5ecbsi1282264pgf.692.2023.04.20.02.07.51; Thu, 20 Apr 2023 02:08:04 -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=nFgxN3fT; 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 S234527AbjDTIzB (ORCPT + 99 others); Thu, 20 Apr 2023 04:55:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbjDTIxq (ORCPT ); Thu, 20 Apr 2023 04:53:46 -0400 Received: from mta-64-226.siemens.flowmailer.net (mta-64-226.siemens.flowmailer.net [185.136.64.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1BAA7281 for ; Thu, 20 Apr 2023 01:52:01 -0700 (PDT) Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 202304200851592d68004f396acc8667 for ; Thu, 20 Apr 2023 10:52:00 +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=wbNM1vDNuJkkGCnV4LllCW3D4zhsGMii5QKdt4aDywU=; b=nFgxN3fTDhl4D/1sb5sXltr6DKifW9wo3jUOoS/TzQp/uqoXRIBTWACOzJEsdh6P5iWq5K GLEE5XM0ad0EYLOwT2ekQPwV6iqpOWDP8GH5T2WUJGdqY5JRogSnvPSRpHrI0zN+Eha/M5a+ z2o7vgY1CwMkXJN54bHszEEhT3rkk=; 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 v2 4/9] tty: n_gsm: remove unneeded initialization of ret in gsm_dlci_config Date: Thu, 20 Apr 2023 10:50:12 +0200 Message-Id: <20230420085017.7314-4-daniel.starke@siemens.com> In-Reply-To: <20230420085017.7314-1-daniel.starke@siemens.com> References: <20230420085017.7314-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 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?1763685626860181924?= X-GMAIL-MSGID: =?utf-8?q?1763685626860181924?= 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(-) v1 -> v2: Removed Fixed tag in commit message as remarked in the review. Moved 'ret' declaration to the point of the assignment and changed commit message accordingly. This was done as suggested in the review. Link: https://lore.kernel.org/all/AS4PR10MB58958C282E7E0FB653BC9406E0919@AS4PR10MB5895.EURPRD10.PROD.OUTLOOK.COM/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index eb21ca583642..79850f616cca 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3276,7 +3276,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; @@ -3355,7 +3354,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 Thu Apr 20 08:50: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: 85782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp185618vqo; Thu, 20 Apr 2023 02:05:35 -0700 (PDT) X-Google-Smtp-Source: AKy350abh776Dkz/sfIuirU6sgA68pueq2aVo4KAKn1+v6ULmLAOfF9E6mFaebOPKCSDdnObB5ZC X-Received: by 2002:a0d:f3c3:0:b0:54b:fcc4:b3f4 with SMTP id c186-20020a0df3c3000000b0054bfcc4b3f4mr298802ywf.19.1681981535027; Thu, 20 Apr 2023 02:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981535; cv=none; d=google.com; s=arc-20160816; b=rmhLFCiI6TTaGVu546x5h5PUsVN6bnlzl9X1OPncDzfyl6w8XNTYQBjhSSWqMN5tX5 AiZKQ+0o4Rva9lYHvDprP+ewz0cBwDxIvTqHCZF3lkne4ifuVBEp3VaOx8Hdpq84m3LK 8s7wEhKt7AebmOMBA/jzO6/lisKhX9hQex/lOypxdgPZa2+wSslzJqeb0bTuT7XZO6+j 8UAD9ACwYoXBS4IBAeojVL6YmeTwZk34GdrHINo2tD7sHGwLsVWdB33lWGNFbS/X3T+c myimBYxdrzHwomC2l+0F3wC17oW+lv+gJKkPyEyKSvjUS0rfU5bj2K4FIsz4/BFD+BHB XNxA== 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=FaBnJcrBw5SD2Db5aFhM0VwRUH6Cu+Qn9ap7A0rxD1s=; b=VQG2PFq51epUGY6m8rIJugKtpjZzTTnMyd93HjG7lElxQ3leLEvRMaKW56f2MtA5tZ 362GYpES3K0KsBjQSBOaFApvHYtS2HMf/c5aXBfus4ShA1dmo3cexOplAFqy5ahVN6hB Pef5x7PSFANqBOv9uwqeN6zz/cLka5uFHzmw/SBcEDWTEU+yolOfOlyo04bBfTLLEvYX rIpoMtbqMybdCpZLyR71dqqhsf/Fd8YYjg1VFGWheG2G35TV7HSaT7toK3mMcZLYOe8R nUisQLWGvY6LaXhRgQPUfllkl1P16dBMzlDcwOz11dbIt6cuhZOksdhbJU81IrUOr6fV 3g6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=ImFoxsIK; 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 c66-20020a814e45000000b0054f6d611cacsi937059ywb.457.2023.04.20.02.05.21; Thu, 20 Apr 2023 02:05:35 -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=ImFoxsIK; 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 S234031AbjDTI4I (ORCPT + 99 others); Thu, 20 Apr 2023 04:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234262AbjDTIyh (ORCPT ); Thu, 20 Apr 2023 04:54:37 -0400 X-Greylist: delayed 62 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 20 Apr 2023 01:53:04 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 4CE534C1A for ; Thu, 20 Apr 2023 01:53:04 -0700 (PDT) Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 2023042008520087e616d99e8f12cd6b for ; Thu, 20 Apr 2023 10:52:00 +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=FaBnJcrBw5SD2Db5aFhM0VwRUH6Cu+Qn9ap7A0rxD1s=; b=ImFoxsIKw/3g5QLA6EIxxn6cyAAPE8g40MF9ZWM/raVLqhdpFP0trECvttIn5P8gLggLEK HKknhUcL7EzyDJZMKb7iBY65A5GxS7xa8DmL6XdLerTXJ5fAcU2cKrPDdXdGtXSmlOwHVKsH YvWO1XkzRNlPUYghtdmSRKZmuv3gQ=; 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 v2 5/9] tty: n_gsm: add open_error counter to gsm_mux Date: Thu, 20 Apr 2023 10:50:13 +0200 Message-Id: <20230420085017.7314-5-daniel.starke@siemens.com> In-Reply-To: <20230420085017.7314-1-daniel.starke@siemens.com> References: <20230420085017.7314-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 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?1763685470112496164?= X-GMAIL-MSGID: =?utf-8?q?1763685470112496164?= 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 | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) v1 -> v2: A cleanup of gsm_control_negotiation() remains open as this exceeds the purpose of this change. The commit message was extended by more details about the statistics counter cases as remarked in the review. Link: https://lore.kernel.org/all/AS4PR10MB58956955D236587153FDDA47E0919@AS4PR10MB5895.EURPRD10.PROD.OUTLOOK.COM/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 79850f616cca..1e97a41e6be9 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -338,6 +338,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; }; @@ -1729,25 +1730,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; } @@ -1767,6 +1775,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++; } } @@ -2220,6 +2229,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; @@ -2235,6 +2245,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 */ } @@ -2756,12 +2767,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 { @@ -3753,8 +3768,10 @@ static int gsmld_ioctl(struct tty_struct *tty, unsigned int cmd, dlci = gsm->dlci[dc.channel]; if (!dlci) { dlci = gsm_dlci_alloc(gsm, dc.channel); - if (!dlci) + if (!dlci) { + gsm->open_error++; return -ENOMEM; + } } gsm_dlci_copy_config_values(dlci, &dc); if (copy_to_user((void __user *)arg, &dc, sizeof(dc))) @@ -3768,8 +3785,10 @@ static int gsmld_ioctl(struct tty_struct *tty, unsigned int cmd, dlci = gsm->dlci[dc.channel]; if (!dlci) { dlci = gsm_dlci_alloc(gsm, dc.channel); - if (!dlci) + if (!dlci) { + gsm->open_error++; return -ENOMEM; + } } return gsm_dlci_config(dlci, &dc, 0); default: From patchwork Thu Apr 20 08:50: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: 85785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp186566vqo; Thu, 20 Apr 2023 02:07:13 -0700 (PDT) X-Google-Smtp-Source: AKy350ZTiOYu74cNQe30XrJa2R3nAnGixJIXV0q3jtI4hx8b2/KTHpxnDe4ZFW27cWg4qX3VYRd0 X-Received: by 2002:a05:6830:1d91:b0:69d:7a86:9875 with SMTP id y17-20020a0568301d9100b0069d7a869875mr316296oti.25.1681981633098; Thu, 20 Apr 2023 02:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981633; cv=none; d=google.com; s=arc-20160816; b=a6oHDSCUE/sTM9miN4ZrbJzwbi4icYjEJdcrYu93Lzzx6nhW/Hmkyv3PAaGKh8nDem g/ZpXVwiVHKESzTcqTfidUmA/5C9tHCO1WCuME90qH0Kdfb0R60qVbyzUSs8Ow2QDQg6 s855Qmue4trQk7nmgLLR0C0nvnSgqyyDCioVMKLWdR0fUspJhglUYKRrLFlJTMrxHLEz mOu69DUjWkPYK+0S55xOO1yjlH6UVKpfSrpbc3WsALh7yyav79N5XeR5jwtc2MyyDTSy /vHcsPCcTDAUf6S4rrM4/5gluHsGjCLFRtEf67fjpZ6vHt2cBWUHuqi1R4njSgq0ZdGu EEgw== 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=XYVykcI9EtHEvwVp8QrpLutUdz6E6nO+3d071pliXpo=; b=1Cn1HY4j9QTbu+RfqabL47d99+JIODjg7gQGIdA14FXvrTFGpTCYszpUhXY3fOPgsc /zb8Ji2Mxu610SWipAQ7H7KyCys1195Z3PlVFsfSb62rCO/JfcIf7gFtwoKhnCEeNqCt /aw6ZW5t3KNx8PjxMsrOPhsqAiTDfNUy4gQQsv7z5J2lYe1X1bOFswHoElNeKMNnL4wg kD5Z+qOYSreShf0cwT5SPQgO4N6SaYedbvB8MCiUb6FpvXYAcv5FUlbvJrubiq4a2VDw ZvDuuxu8Zv1n8BU6NYNIS9dW4pAwTrepFX2kiZR1nW3YvlXR3Oaukf7LYpg8fN+q6p7y cALQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=BPrlmz2i; 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 f12-20020a056830264c00b006a61b3b30b4si1779017otu.233.2023.04.20.02.07.00; Thu, 20 Apr 2023 02:07:13 -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=BPrlmz2i; 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 S234174AbjDTIyz (ORCPT + 99 others); Thu, 20 Apr 2023 04:54:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234068AbjDTIxs (ORCPT ); Thu, 20 Apr 2023 04:53:48 -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 D8C547292 for ; Thu, 20 Apr 2023 01:52:02 -0700 (PDT) Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 202304200852015290d3ae88502a98bf for ; Thu, 20 Apr 2023 10:52:01 +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=XYVykcI9EtHEvwVp8QrpLutUdz6E6nO+3d071pliXpo=; b=BPrlmz2iLtFt4KgsBHX92M5GrD9Pt3OJMqVBvib3Io93kFjCTv048H+b+o9JGp6y5uauV0 URbfPyELH+q3i8dtyQjSD8Vuace/REOIp4M2oTRWK0nKj7wklscF7p09uFQjB4D9hvHW8gmy fwuae2S8aP9bcOpkhr09thIbi/Scw=; 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 v2 6/9] tty: n_gsm: increase malformed counter for malformed control frames Date: Thu, 20 Apr 2023 10:50:14 +0200 Message-Id: <20230420085017.7314-6-daniel.starke@siemens.com> In-Reply-To: <20230420085017.7314-1-daniel.starke@siemens.com> References: <20230420085017.7314-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 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?1763685572950884020?= X-GMAIL-MSGID: =?utf-8?q?1763685572950884020?= 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(-) v1 -> v2: Added remark to the commit message that the malformed counter is not yet exposed to the user. This was remarked in the review. Link: https://lore.kernel.org/all/AS4PR10MB589597931E257D7CACB984BCE0919@AS4PR10MB5895.EURPRD10.PROD.OUTLOOK.COM/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 1e97a41e6be9..cc7be05c37ce 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2454,8 +2454,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 Thu Apr 20 08:50: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: 85787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp186879vqo; Thu, 20 Apr 2023 02:07:41 -0700 (PDT) X-Google-Smtp-Source: AKy350bFkYiDnC9ngpkst7aomt0/U5/Oe1uiaAbhuiJ4QV1NQIwyLD/jVda5uaOyZp6P64rW1IR6 X-Received: by 2002:a05:6a21:9982:b0:ec:8f81:e9f7 with SMTP id ve2-20020a056a21998200b000ec8f81e9f7mr1483963pzb.16.1681981660947; Thu, 20 Apr 2023 02:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981660; cv=none; d=google.com; s=arc-20160816; b=CloXfdtKRh7nMA3JxOuOV7ahZR+baJZH4bL7qBM5M0hT6KLcGzzma3Uki1sBkIb39A 4Q26QLtsUcAj0O/jOjVwwXpaFI45ztWdnrzN1Z8rVCsfnxi/O48u93RNrN3QkU1H6TtN fNJGK3kfBY8ehb7Zn0nXgO6lm6Y9a1I2k7xFqa7ZBcLf6+al5c5/EbK6vza+0qPuwPX7 vl6P02pej6CznqPxz3iKabbY2CG2dcYArjT64ky6HqVrhyHZw/Hjsu1vEJtJHm08+cl5 2bZSSNnNo19GorsKxy3eGdLdyGNhe0DTqH8WTrqJjgLSqKjn+upnY/1vm87NXd1dL1cQ OTGA== 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=3x2yGjeK5u1omGmfHkW7ePEBZf1+enMbPDW41ey/pcA=; b=AEx0FjsfRR+Ylg1Bp53Zk3SxOzLbmIQS6y4zAJ/4C29D2iI4gvIGz9xcBJ5FuoVkKN 5gHdT+JcntZo5JCKEOD6X8hI9zNkGZ1791ZB3Hzh/AA964In+B049kvlDnwmUvMxcNhB KtDNprnhB+6xnGlarRIU6HE+23AZ8KcmXlwn7lqRGRPf9w9sVcEmY8sX0THSfX6D5vl1 MYIY8Qe0xiYH444CqdItln7pE19CLaf/0aULRvxTIw29OkI9MLhMk3DT/aYyYlKhZjJ7 cWZFT73KSQU6HzGERnAjy6E8VpsgjdLNdAQJfT1x3BU54RULic5Ybx7vvw1Yp/0jRmRJ Q2gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=jC6VnpGp; 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 pf4-20020a17090b1d8400b002449fd20726si4276529pjb.64.2023.04.20.02.07.28; Thu, 20 Apr 2023 02:07:40 -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=jC6VnpGp; 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 S234289AbjDTIzN (ORCPT + 99 others); Thu, 20 Apr 2023 04:55:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234199AbjDTIx5 (ORCPT ); Thu, 20 Apr 2023 04:53:57 -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 568E846BB for ; Thu, 20 Apr 2023 01:52:06 -0700 (PDT) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 202304200852011396a59810ab83a424 for ; Thu, 20 Apr 2023 10:52:01 +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=3x2yGjeK5u1omGmfHkW7ePEBZf1+enMbPDW41ey/pcA=; b=jC6VnpGptfOYjt/kcGttoWZ0iYVUQEywQ1BjuMJ7ovnlexEs3HPeifOq1ZgRqGafxcj8qQ jvlLATkBil/ZBinzu123fmdn65aKhGVKJ4W9IhUFH94BNEuBOIdUGJcTrOo/7WghXGT6vWi2 IWDn2WVzvkkdHrkZZQAu4MDiJzsMY=; 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 v2 7/9] tty: n_gsm: increase gsm_mux unsupported counted where appropriate Date: Thu, 20 Apr 2023 10:50:15 +0200 Message-Id: <20230420085017.7314-7-daniel.starke@siemens.com> In-Reply-To: <20230420085017.7314-1-daniel.starke@siemens.com> References: <20230420085017.7314-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 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?1763685602308271658?= X-GMAIL-MSGID: =?utf-8?q?1763685602308271658?= 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(+) v1 -> v2: Added details about missing detection of inconsistent/unsupported adaption to the commit message. A question about this came up during the review. Link: https://lore.kernel.org/all/AS4PR10MB58955AB89CC251446B7509CBE0919@AS4PR10MB5895.EURPRD10.PROD.OUTLOOK.COM/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index cc7be05c37ce..ce06cbbe79af 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1589,6 +1589,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) @@ -1896,6 +1897,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 Thu Apr 20 08:50:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 85793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp187110vqo; Thu, 20 Apr 2023 02:08:08 -0700 (PDT) X-Google-Smtp-Source: AKy350artBBn2Vj6RlC6BFjxR8wShzlYMl1IOX8BtroENnxrBun8s5fLA6yggkU0pxv669KabHMs X-Received: by 2002:a17:90a:4989:b0:247:bdeb:594f with SMTP id d9-20020a17090a498900b00247bdeb594fmr1022222pjh.15.1681981688559; Thu, 20 Apr 2023 02:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981688; cv=none; d=google.com; s=arc-20160816; b=w0KEL5u0hUo7Um5muK/XiJmyooxlOzAb39aKaCLYtptMODmWDPC3r9QO9XBormzLEe LP5G27mxoECjF6cx3KlyFdvZDE8oI/GbcRPngD7ZwFpPajoP7IAcKZgpHXvlTJVNh0Tv ZOPeefiw3OoQwB/zs0IR22E0j29KFxgqcYx1HFO0EAoSkGFekJ7+d7YtqQWvr2MmlKKA CLQ9mQnWybiD/bCXVqiNdl5wg3sUu7YOaQj0kLjJtPtXgIa/kmmEAfwgffyV/skY8Lif /WzxN3SzElxJrIVHKwmojh+2qUxlzK+XwJGcgUzvKeAl09HVt4b9qLfD0IzG7u3lzWZv Ws6g== 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=FQjnwT4CT+XNGnJ3WBAhjs5ayKF62EGFFFeFaI41i8I=; b=KPACEi/L85zUSgvBh+Uxbo/w/PRccDa6CkUEbBEkpcyjxWViDvtV06IO/dSJc+nmW9 qpccadsUloYLCOPTOPPyS4wWRs3KQbO0k/tBgf7kQbwLUlXw9O81dWBTtEgzXM4UeOVj na2LiwNWq6vwrBN2m8Ws1Bw/+8pGROLyHItkjqGrpXl6h83keDvFA4jmLBAV9Ednhcws ni5JXCKIiBIfi+LQoxgJmYjaf2dhWpbaRR+J198EztMdpz2bFgFKIpS/1pya2H6kOS9P acs0bO8TSSSd5GgTsDvONRxNxvLHCxLMqspzE61aSFGG5ICUi0dGSjDXo/0NxSWSRd8B CLhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=bnvnMnlI; 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 ob8-20020a17090b390800b002474ddc6a90si4252541pjb.125.2023.04.20.02.07.55; Thu, 20 Apr 2023 02:08:08 -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=bnvnMnlI; 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 S233691AbjDTIzG (ORCPT + 99 others); Thu, 20 Apr 2023 04:55:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233961AbjDTIxw (ORCPT ); Thu, 20 Apr 2023 04:53:52 -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 B586259F0 for ; Thu, 20 Apr 2023 01:52:05 -0700 (PDT) Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 202304200852024fc8247067930246d1 for ; Thu, 20 Apr 2023 10:52:02 +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=FQjnwT4CT+XNGnJ3WBAhjs5ayKF62EGFFFeFaI41i8I=; b=bnvnMnlIfut6yLSrozGMcqdaqDs/eAsmxbnwQ7Apewajc35SQNMuMn4hsGNfjX/cnX9BDj 7tut/vgImnLi21LmFJeMgGqlanpYQJ7/ksJn3oFpriwu93Rdgi0nKVQ7OY5CDSAHSgQbNS+g PnCdpiiTTu1wligw9fSVAkjjcxQu4=; 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 v2 8/9] tty: n_gsm: cleanup gsm_control_command and gsm_control_reply Date: Thu, 20 Apr 2023 10:50:16 +0200 Message-Id: <20230420085017.7314-8-daniel.starke@siemens.com> In-Reply-To: <20230420085017.7314-1-daniel.starke@siemens.com> References: <20230420085017.7314-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 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?1763685631155017639?= X-GMAIL-MSGID: =?utf-8?q?1763685631155017639?= 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(-) v1 -> v2: Moved from patch 9 to 8 as suggested in the review. Link: https://lore.kernel.org/all/AS4PR10MB58953283D47928E265313660E0919@AS4PR10MB5895.EURPRD10.PROD.OUTLOOK.COM/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index ce06cbbe79af..bd6bddb185b9 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1450,15 +1450,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; } @@ -1477,14 +1478,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 Thu Apr 20 08:50:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 85784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp186086vqo; Thu, 20 Apr 2023 02:06:26 -0700 (PDT) X-Google-Smtp-Source: AKy350bjFEm9oG1GKAKfpDkspSDW1075z41REES9SLUsIjBog8g/KgMsfYivB9wr8X6ZZgyHCyGU X-Received: by 2002:a25:2b48:0:b0:b8b:f174:b83f with SMTP id r69-20020a252b48000000b00b8bf174b83fmr801034ybr.20.1681981586090; Thu, 20 Apr 2023 02:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681981586; cv=none; d=google.com; s=arc-20160816; b=zjqm0wIqWE766KHaDTrxLhEBAZ3+dQslM7uGhX8j1DwIhRuSHpUmCecpGSbSuQMQ/x g45gI8EK+mr642W1gbkvLhIycK1tweSv+GdkUIbWaKRKTJD3DhTM82U10lNToOqaKuAx mC0ZI/CKOaQGJqqbT6EBPEJ4OWNt0+NEZClhcUO+0IO1Cyg/LnONTblhJ6kjq+MYZ+Kq ufDST+pb2C3q+d8S12zRG0h9kn+zvom99zGYeQioe2fQEtUiyIEZQunNkCrEG299iDIP sqM87yAMFBYACq0PahwjMVGYbXV50aeBMl2L8kfQ/bWIn0POntsvRDNK4D1nzQ/pQBtJ 4s6g== 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=GMJnTQBjqNDmRCR9GVA4p1Mh+jUY2F8iX0UGlZoBzWI=; b=VW+8PCkcEJWWKNCoZMQP+5khnlwm91/odD1TfRjShH0iJq0f+sJIkaV4ptUMK6V96O fJnT81l6HMQPGBAn1flwgtkq6gC8Y9nbsQaFAUP2hTsGLTtQosWzknWGaYdauGjD/mjn suYIlTvL2Yv/FnYrMcxbPEWjQ/VwBCbxNwyMxM0kcaN1nfjlDes6bbL5D2nmcSbDREgG qYdUPm0cgnZENbmpzHRjghbb0HIf91PiL+Le7x19d8bcFfPte3j4S+DyhwHzSNGfibRH /23ZHTI+aOI5XVHG9C9kDAzFJy0vjsJ2d9oC1XQqfuo4HesVWcxkproQVxGloCK/18Tg jjAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b="AuyFbk//"; 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 c66-20020a814e45000000b0054f6d611cacsi937059ywb.457.2023.04.20.02.06.12; Thu, 20 Apr 2023 02:06: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="AuyFbk//"; 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 S234351AbjDTIzJ (ORCPT + 99 others); Thu, 20 Apr 2023 04:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233992AbjDTIxw (ORCPT ); Thu, 20 Apr 2023 04:53:52 -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 7F07F7297 for ; Thu, 20 Apr 2023 01:52:04 -0700 (PDT) Received: by mta-65-227.siemens.flowmailer.net with ESMTPSA id 20230420085202985c15d48e4d787d92 for ; Thu, 20 Apr 2023 10:52:02 +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=GMJnTQBjqNDmRCR9GVA4p1Mh+jUY2F8iX0UGlZoBzWI=; b=AuyFbk//3khrCXXs0xkWwn6u7UfH40FHgcDYoNUmV+ND4Luo7vLCO/ufVWrIGHDeiS609b TooMq2FIlpsMSNtbOixkvdMfhr3FL1DVkJZ7KK2AdALAOCGN4v0sWYsY35guW7KSd6yZa+1C vfdvz88uOIb3lQUk6J9NwcXksOmIA=; 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 v2 9/9] tty: n_gsm: add DLCI specific rx/tx statistics Date: Thu, 20 Apr 2023 10:50:17 +0200 Message-Id: <20230420085017.7314-9-daniel.starke@siemens.com> In-Reply-To: <20230420085017.7314-1-daniel.starke@siemens.com> References: <20230420085017.7314-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 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?1763685523812914253?= X-GMAIL-MSGID: =?utf-8?q?1763685523812914253?= 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(-) v1 -> v2: Moved from patch 8 to 9 as suggested in the review. Added missing change of gsm_dlci_data_output_framed() where dlci->tx also needs to be increased. This has been pointed out in the review. Link: https://lore.kernel.org/all/AS4PR10MB58956DDD178D33EC6CA3A73EE0919@AS4PR10MB5895.EURPRD10.PROD.OUTLOOK.COM/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index bd6bddb185b9..7f15c122a333 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -185,6 +185,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 */ }; /* @@ -1215,6 +1218,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; } @@ -1282,6 +1286,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; @@ -1460,6 +1465,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; } @@ -1487,6 +1493,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; } /** @@ -1851,10 +1858,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; @@ -1933,6 +1943,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)) { @@ -2297,6 +2309,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: @@ -2329,6 +2344,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: @@ -2348,6 +2366,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: @@ -2424,6 +2445,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); } @@ -2784,6 +2806,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 {