From patchwork Mon Apr 24 07:52:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 86892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2583481vqo; Mon, 24 Apr 2023 01:21:35 -0700 (PDT) X-Google-Smtp-Source: AKy350agmIf/icObjcKr9w6wlFhg2vI32cxU649Ah7ypeS/DrHDElBYD1ZEPkjcw4axa3hUPWosQ X-Received: by 2002:a05:6a20:4413:b0:f3:3810:8a89 with SMTP id ce19-20020a056a20441300b000f338108a89mr7245659pzb.51.1682324495400; Mon, 24 Apr 2023 01:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682324495; cv=none; d=google.com; s=arc-20160816; b=VaUsetuNWSR65iOPq6cJ6Dn4QGjukqE175cD1qUuC+hPj5EJtyiKg/fqp+KLxRel3M rZd6MI4FfYLRIDiqJb54hVH2vOjTk7KsMzLWHH19gb9S19eFiuLKN6kJykYXVgX4YThJ sXYrmHX0VRzhu8KLbdHjUACjiE6qQ3xDoCG5r6aCZBLjsRgyykjek8i6RVH8Jk4vhp9n TCTP4h/6sdHITHF9yUwuaVOAGOaW4ZecMaKqxipxkTDnwlbjN0+2t+5Ygtcnn5iQP2hJ fpWRLk/3avaBpHBTBlca7bwK3Cvc90KCDV0+le0Qw+rF5j3ifaNhK6eVpEgepwx3EmAx PM4w== 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=+v3MIb8PNZ4ZgxyCgk4r+KodnCwVlLhLxXYg0SWiEHo=; b=VdgrbctQDkzLDrbK9DQrEMgsCVoJ6xHIF/IWNWoaSlGrhJ93LA2WFv2SuqJVkoaDIM ZfR80LgO/0NdNPkURxNXQKmKi1ceCxx/mzBsr7FvewWeOrtCcIbr8UOaa5GTY0waONXw /0MnQqkDYsTFmJKBvsdT4wisDuQpWwc3UvUwGQ5CRc9X+lePOnD3UNXNBtldZpTiKYKD zGv4nBuK80eyE6MU3Qap6+mu1jN9IkbFGhKBGK6VVoQO8EkE2R1HwYd9XNLw030VP6Q+ 1C6vGdG8RzFo4pX7ALqiVuo76N+CtY+aKnx9nPS7cvrbhQVnZ6aFgJO5Q0fhshiw1U/L a8nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b="PUI5S/qZ"; 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 j5-20020a63e745000000b00517f0c53072si10707884pgk.170.2023.04.24.01.21.19; Mon, 24 Apr 2023 01:21: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="PUI5S/qZ"; 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 S231280AbjDXH4V (ORCPT + 99 others); Mon, 24 Apr 2023 03:56:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230311AbjDXH4R (ORCPT ); Mon, 24 Apr 2023 03:56:17 -0400 X-Greylist: delayed 78 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 24 Apr 2023 00:55:55 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 111C31737 for ; Mon, 24 Apr 2023 00:55:54 -0700 (PDT) Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 202304240754343fbeb7fb65f76aa97e for ; Mon, 24 Apr 2023 09:54:34 +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=+v3MIb8PNZ4ZgxyCgk4r+KodnCwVlLhLxXYg0SWiEHo=; b=PUI5S/qZHtiME/0oNhuHpCviJ3YzaxRqU25OBtOu7Lw8ANfD1ludQuEAyGuIB9nVHrgBnY 57GBs63dQxYNL+wabT8LutbGG6scReu7HhKMrAx7zaesgTN01oLka4qmDKpWsMfhRI/oerRo wmXDyiGtRY5wUe5WrIdxB2lu1qhVk=; 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 v3 1/8] tty: n_gsm: add restart parameter to DLC specific ioctl config Date: Mon, 24 Apr 2023 09:52:44 +0200 Message-Id: <20230424075251.5216-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?1764045090141278507?= X-GMAIL-MSGID: =?utf-8?q?1764045090141278507?= 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(-) v2 -> v3: No changes. Link: https://lore.kernel.org/all/20230420085017.7314-2-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index b411a26cc092..00f692e2e810 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->restart > 1) /* 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->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 Mon Apr 24 07:52:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 86895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2585746vqo; Mon, 24 Apr 2023 01:26:53 -0700 (PDT) X-Google-Smtp-Source: AKy350ZsprL8DniW26h8V1mrokyyBYNakWqw/AZu2Mxq8wDBSLyZ7y4rZqcOIWqVZHcnYTPrfnLz X-Received: by 2002:a05:6a20:160d:b0:e7:7844:903a with SMTP id l13-20020a056a20160d00b000e77844903amr17597211pzj.53.1682324813335; Mon, 24 Apr 2023 01:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682324813; cv=none; d=google.com; s=arc-20160816; b=p225I8ebt95YwDZfTUaMrUk/c5cKkNJ7wq+yot2XLvzKZ9e0ZqygATrOb9D+qIFYW/ a+3m4qG95DHHyojMtGGxphogigyC16ILhnrqm8A9qLBqXAK4Zg114RsPSbdr545AqZkk u0j8J9Lxl5oW9ikSi+Bo7PLL9dE5bMCLKe1Crsf6iHlmDg+pKHP09ppdujz8MlFzgwTZ X7YvzaYR2VXSDUhU0pk5raXDALLO98Qrrng4+MB6yhm++viadjv/J7Zw3tqRipzqc8Lf y26hfOZVpy5vJhfJG1aVCE4dbUVaKK2fUEthFSvCyBiGbazUUhqhAcKJlXgkP9n7xbTo cwxA== 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=cRH4nX3kvz4VCstupXacwcxAHkGzJLXypxwShXAZZ2M=; b=0J2xjIT8FKqiRaI45eFMkTbx3T5a0yKlwlGgd3TNZc4upxF3F9qw/FMPE4WcmCRaZK wtcJHzyJGbZBPbd8W259iD0QcAXZdu20iw7OI231HbHlca1vYcnDAwzXlb5eoM/5rnIq t8dUV/K9XeA9rdaO9j1Fs1C4KzLsgKO0deqwdjhexMp2/U9O6Kh4qu3t2+Wy+slijqez HmMydK3YuO4gfMWtjgUVLVDhSL3VgZAeJJGjZbUIUl2c1KsoZXPmj/5HHO9Hqu2ft2Hh hjVBcmnBnvRjkE/JNYRAvbrFkYCBtY1k6wM5DVawURc4XyOQoAKxm9oyaoD1xs6W3fhW 3xCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=kue6cTzm; 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 b12-20020a63930c000000b00520db8892b9si8374073pge.41.2023.04.24.01.26.40; Mon, 24 Apr 2023 01:26:53 -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=kue6cTzm; 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 S231464AbjDXHyl (ORCPT + 99 others); Mon, 24 Apr 2023 03:54:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231328AbjDXHyk (ORCPT ); Mon, 24 Apr 2023 03:54:40 -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 5AD95E65 for ; Mon, 24 Apr 2023 00:54:36 -0700 (PDT) Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 20230424075434f1c1d3583ff7c18645 for ; Mon, 24 Apr 2023 09:54:34 +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=cRH4nX3kvz4VCstupXacwcxAHkGzJLXypxwShXAZZ2M=; b=kue6cTzmaDbSfYeW6YTZMOGBGGHNT040b0t12m37SYwKO0peb9FAPlTRUFA+WbICtx9wTt h/iR0Xaidy2Vl713gfMVstd6aZkyyyHi3YAp89KQPCWNYJM6A6lCHoc6ZSgeCG/mOGzZ11rW EkP7Ur4tFflpqlYqQCEl0sGqb8Krg=; 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 v3 2/8] tty: n_gsm: add missing description to gsm_config Date: Mon, 24 Apr 2023 09:52:45 +0200 Message-Id: <20230424075251.5216-2-daniel.starke@siemens.com> In-Reply-To: <20230424075251.5216-1-daniel.starke@siemens.com> References: <20230424075251.5216-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?1764045423292116644?= X-GMAIL-MSGID: =?utf-8?q?1764045423292116644?= 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. Converting the other fields to kernel doc format remains an open task for future patches. Link: https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516 Signed-off-by: Daniel Starke --- include/uapi/linux/gsmmux.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) v2 -> v3: Changed added comments to kernel doc format as remarked in the review. Added remark regarding remaining documentation fields to commit message. Link: https://lore.kernel.org/all/ZEEd_oOvJYranmzN@kroah.com/ diff --git a/include/uapi/linux/gsmmux.h b/include/uapi/linux/gsmmux.h index 33ee7b857c52..d3b9b37a9082 100644 --- a/include/uapi/linux/gsmmux.h +++ b/include/uapi/linux/gsmmux.h @@ -6,6 +6,28 @@ #include #include +/** + * 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; @@ -19,7 +41,7 @@ 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) From patchwork Mon Apr 24 07:52:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 86901 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2588291vqo; Mon, 24 Apr 2023 01:32:35 -0700 (PDT) X-Google-Smtp-Source: AKy350Zj84JaMWDZXFTsgwyHQl3jqJ+n/40F0GW/ANaQals7429zngm7AIr2Zx9TwlDqojbFq0y1 X-Received: by 2002:a05:6a21:110c:b0:eb:6e43:8e1b with SMTP id oh12-20020a056a21110c00b000eb6e438e1bmr14450967pzb.30.1682325155457; Mon, 24 Apr 2023 01:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682325155; cv=none; d=google.com; s=arc-20160816; b=MAwH+8F+WarYAVsK3+6VQg2IBT8bNZeh0Z8qKRNPLm3YXlA+iVrxDfOvRi9c9/s8EJ kTEx8j8RZa49sCzuMpCRF9vDoYiN1JVtkQZUjiGgGoOc/pYPqUgWVl3rnLlbOQFLDX6V sCwWU7wVZm2hh+eLP9+mX93gsUkdqMvXhkbkk4R8OISCYjGrAsnHmHSOROk6MPjjeczR 2C28zIane/L2qGr7slQAHm7RUDzc+8Okgq1oEeuUaTpn4mGNOzN6Cz4QNo4/D2gx2H7o QQ8EydD3PN4xHGbAGA51v/UUNeutwt+hMkBNLjNz61+qGfZ3D1XQFMAFNcN22kTBszu1 quzA== 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=HYL648Ckr8RAxIMexFhAOmGJuIagv55uONwQN9AZSlE=; b=irIgxQJYXXNP927naHPWA7pdpDBx/pXBL7kHfyuD2nDk7LaODMDw9jQb8wz0XCrBL+ cTrgRbwfc71sQ7+qc8EhrVAoSaBKVJAe5iH7C/M+C2VkNGb9Bx8kCc39K4zyyt87pn0h xqX+/Y4qneel3qsut49x76CSHAFOZd6SgER/38hXH5ZRmRnKic81kH0m3I5TtGW8b36H 4EKBaYyRX5NuiRR0nTKHeC9YXgN0r0jhjIEwRbGnDYyVTY1g5plLnCr1wrjcvokhrfCx Hd6M0FNhTGgQbeVF0i5K5x/s6CJc/eXSI55TcPWxuwbCV5m01KdT1V/cjeZ19Yeo1yrH M/uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=UxpH9sQV; 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 g16-20020aa79f10000000b0063b82909b1esi10511889pfr.0.2023.04.24.01.32.23; Mon, 24 Apr 2023 01:32: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=UxpH9sQV; 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 S229841AbjDXH4Y (ORCPT + 99 others); Mon, 24 Apr 2023 03:56:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjDXH4R (ORCPT ); Mon, 24 Apr 2023 03:56:17 -0400 X-Greylist: delayed 78 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 24 Apr 2023 00:55:55 PDT Received: from mta-64-225.siemens.flowmailer.net (mta-64-225.siemens.flowmailer.net [185.136.64.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 620872115 for ; Mon, 24 Apr 2023 00:55:55 -0700 (PDT) Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 20230424075435d30a07f002aacfd3a3 for ; Mon, 24 Apr 2023 09:54:35 +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=HYL648Ckr8RAxIMexFhAOmGJuIagv55uONwQN9AZSlE=; b=UxpH9sQVTdMiZacKHkA4qRluMfxv+wC4NMvn1yR5OwpPJ+xSnSY8HjyBYn4I5AzdpCtsmF Rg8iOylfp2qu0pvnQutc8lNijVl2ZJrG1XzmN/Qrz1EqEfsib7BoqG+PuaaJLn4EhCq/X04E UluXDLbNxpdPPJBmuvvZ2FtB2t2Uw=; 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 v3 3/8] tty: n_gsm: remove unneeded initialization of ret in gsm_dlci_config Date: Mon, 24 Apr 2023 09:52:46 +0200 Message-Id: <20230424075251.5216-3-daniel.starke@siemens.com> In-Reply-To: <20230424075251.5216-1-daniel.starke@siemens.com> References: <20230424075251.5216-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?1764045782166568961?= X-GMAIL-MSGID: =?utf-8?q?1764045782166568961?= 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(-) v2 -> v3: No changes. Link: https://lore.kernel.org/all/20230420085017.7314-4-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 00f692e2e810..9a2cf3e14678 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 Mon Apr 24 07:52:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 86891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2576614vqo; Mon, 24 Apr 2023 01:05:26 -0700 (PDT) X-Google-Smtp-Source: AKy350aKgUhCXvgB7lPU6/IUkPjNMlmk12cTLNGDHNuEh/BAZXckIT1VRa8wMoS1Jju6y6wBeoRI X-Received: by 2002:a17:903:187:b0:1a6:e3e3:dbb8 with SMTP id z7-20020a170903018700b001a6e3e3dbb8mr14164706plg.44.1682323526608; Mon, 24 Apr 2023 01:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682323526; cv=none; d=google.com; s=arc-20160816; b=vHx+ZvhrlPidtUsb7xhpbJBsp2nZVE069EEvi3l8Tj324JINN8KS32lI4boFAxhJV7 oZ4MyyMtxUQthLY96iFRLR4IVD8jdGSyfWkVsUPtOsfc98tGbGNhwEGOXviD84c7WBTM rRk/TE3v1UIFlDN+m8idN7P218KMRFRFwt/22r7lNd+ZKysMgdlMiOhMcYyB71CJTLd4 yjBM94QhCq0AAyYEd+OnmOAZG+VMrFklipq9B/cblPfUvluApqorIxEm+6KkVYdimb1v Djodo0BpVEXkqwlfXKD4BfLbwLiBMeZiHOi99mM9+z9lWCLwp8iq/XU7DpAPuBiMcbKZ /6KQ== 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=ULLYgmbG/ykB1RRdK7/F/RuI/3VzvVuXKuXWTjBDDSs=; b=Nb1q15mcezyYY09046lCn7r7IQ7NA5p5TPGkXzncnvCLPLTmrse55sOZBV66p0EQ1B BVwEpHtTofZ1xjDgCRKyOIpiuwepi58f8hf4ydQiLyEA21ucPsCQf0TNP+hzbXhNibk1 tV48rGqmtqWH7XDbcH/+w8/JsXzKhVel55txtKS9ZY9uoBWQqJym7ZPvAGqAq7RdQU3k mVSiimOR33vrm3Doz2obH2IoGAk8moVi+ZFdOeJqZR43G5lVijljjq0NuRYbfSMwNy6s aljUWj7exWIrp20kXksKssYH3rdKlfinmyilyBRhvOhYg96XM2l0fUvRqfHRD1dcIn1w JVYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b="J5DfR/zR"; 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 j6-20020a170903028600b00194967b7badsi11133140plr.591.2023.04.24.01.05.10; Mon, 24 Apr 2023 01:05: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="J5DfR/zR"; 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 S231480AbjDXHyq (ORCPT + 99 others); Mon, 24 Apr 2023 03:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbjDXHyk (ORCPT ); Mon, 24 Apr 2023 03:54:40 -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 3B60410D7 for ; Mon, 24 Apr 2023 00:54:38 -0700 (PDT) Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 20230424075435b12437b73e3922ee85 for ; Mon, 24 Apr 2023 09:54:36 +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=ULLYgmbG/ykB1RRdK7/F/RuI/3VzvVuXKuXWTjBDDSs=; b=J5DfR/zRamnMR2A/mdk89g4pEaRG1IP+wLnRwMuVMv24OT2IBtHlltQ/FEW9HL4Hp238qs BuZyf/OhbT+b5S6GkZ89IuDCths74oqPh1aG8RHTTkaVAeJiWlppk9w9EcPK5h+b8/9s3cj3 QvaweLxZDH9Pv8dsVIMoM5+XNar+A=; 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 v3 4/8] tty: n_gsm: add open_error counter to gsm_mux Date: Mon, 24 Apr 2023 09:52:47 +0200 Message-Id: <20230424075251.5216-4-daniel.starke@siemens.com> In-Reply-To: <20230424075251.5216-1-daniel.starke@siemens.com> References: <20230424075251.5216-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?1764044073969097669?= X-GMAIL-MSGID: =?utf-8?q?1764044073969097669?= 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(-) v2 -> v3: Merged commit 2b3174c96696 ("n_gsm: Use array_index_nospec() with index that comes from userspace") No other changes. Link: https://lore.kernel.org/all/20230420085017.7314-5-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 9a2cf3e14678..6b6fafb1098a 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 Mon Apr 24 07:52:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 86899 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2587613vqo; Mon, 24 Apr 2023 01:31:09 -0700 (PDT) X-Google-Smtp-Source: AKy350bqUKNvjb4LMMCotBC8JcaVQzyvARDqcutHBURV7vJZlCy42aQsEofXRhHR+s48XnhVHfRi X-Received: by 2002:a17:90a:1481:b0:23f:9445:318e with SMTP id k1-20020a17090a148100b0023f9445318emr14542403pja.3.1682325069135; Mon, 24 Apr 2023 01:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682325069; cv=none; d=google.com; s=arc-20160816; b=l1dB6+8ECyAYOx77Ful3OSji0RCUO7m9Y/t4P10BrGhdIwYqd5WMwyL12x63B/+34o G87ncuDaj/WCqIRW00v6dUCB7VqeSffibe3euSaQ4farpLdOP+NEbT+cJ5C5OsVY/Anu pTnWFnsO8xgtdHzRtLrSFGrVI335gpvG7fFWuwBDKLxGf824AnyEeyBGhMryNamKiJ18 J7wGQQz0A7Fj2h4gz6LY8IqN8nG2rr8bC3SE1FdgKzI17jnykEXyf6WO/tFFilHmoL+f SUIzcNQjAllX25JYZqVq8Lw+b1+E1VAoiprRab5cij6UQ+BCPOIQQ4KOJCxyAxJkX3nH z+4Q== 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=qjQIn+HvmVUrb5AZ5u0C0kEC4MtX+YXbuwEE51kPmJA=; b=H7M+LB75geYdLGPLF8FPTK7sV32NWEZRJEatFXlC5DKaUXC7YCha02U+z3CId3lX8e HkzF4cPKAiKDu4bkwxrY0MVpyLjW6bVTvdOIds489uU+m+0URlO1S55FgEpvXrm9QaQP nU8Z6TfCy2Ak60RywSbFukVJUsFSAwmcXZQwwK8SP4bNCjPh0uFtH4nUb48lu9MvfW0A D5DvT4u6wYIGg7JF3/xgEmDvXb7M1xJYLpyMTjQqukE+UezIEH+NhTSPVbYk1E9o4w83 JBMvvy1Y8r3yEH2x3Xz154NbbA/NCSBl7z7v7445yuAKH1Zm5ITkLu5ZQFgsP04iJIPx BLrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=g4ekPUt7; 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 s14-20020a170902ea0e00b001a2104d7075si12066291plg.72.2023.04.24.01.30.56; Mon, 24 Apr 2023 01:31:09 -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=g4ekPUt7; 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 S231472AbjDXHyp (ORCPT + 99 others); Mon, 24 Apr 2023 03:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbjDXHyk (ORCPT ); Mon, 24 Apr 2023 03:54:40 -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 4D3B610DC for ; Mon, 24 Apr 2023 00:54:38 -0700 (PDT) Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 202304240754368306ba2628ecd55b54 for ; Mon, 24 Apr 2023 09:54:36 +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=qjQIn+HvmVUrb5AZ5u0C0kEC4MtX+YXbuwEE51kPmJA=; b=g4ekPUt7DHKdgaD2w3+YSP4VEx3pM64I89/4bb855ICW1UYYY7HE40PG0e1uIkdr40SIG8 grVnfQnDP4Nj0sLMilqJfqvjSQUmkpSvWtMcwIVJdbd6c8LqYvO9r3EdxKmw8QmWkYASTBMq xnw9dr6jWG6M4/XFjoq1ANZbiaP4c=; 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 v3 5/8] tty: n_gsm: increase malformed counter for malformed control frames Date: Mon, 24 Apr 2023 09:52:48 +0200 Message-Id: <20230424075251.5216-5-daniel.starke@siemens.com> In-Reply-To: <20230424075251.5216-1-daniel.starke@siemens.com> References: <20230424075251.5216-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?1764045691564693068?= X-GMAIL-MSGID: =?utf-8?q?1764045691564693068?= 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(-) v2 -> v3: No changes. Link: https://lore.kernel.org/all/20230420085017.7314-6-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 6b6fafb1098a..10fc02133efa 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 Mon Apr 24 07:52:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 86897 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2586693vqo; Mon, 24 Apr 2023 01:29:12 -0700 (PDT) X-Google-Smtp-Source: AKy350aG+g3+eSNhZdAhyAIj7MTQAvb/PfTz0pEDOQwIXyaib6ENYw+k5W8Ka0lwYp66qB7nUSyD X-Received: by 2002:a05:6a20:3952:b0:f0:1d03:5fe7 with SMTP id r18-20020a056a20395200b000f01d035fe7mr18280279pzg.38.1682324952243; Mon, 24 Apr 2023 01:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682324952; cv=none; d=google.com; s=arc-20160816; b=d47JaNX+6N6UeIGNfpqYymXiG44DbLlX1g7M0H5rPaxT+2CxYJu5R+buQr0TMJZGeR Ugo1UQKmeiOdfgCOEzgD37tiFnf7ktsVxYsfMEwJltsVIv6bs2La57krMDFJIS287l31 FplmFGbv292lGmVL4pJr0bWwwaN1jEwctwv00jJZye4BGRrT73RGxD30l0CCU/j0Hcqz dAfmFHtxMtzzyVT05PLrFEKXjRn8qXtTjjmV3xl7KunmN0xmbefCLWEPHv01QWRnXt4c hIZ++FoTXHcRV667c1IYCCcld1bP7cd/E0rUhGZPNb5l41j/KU6668xo+WtteL6Ro9Lz ZngQ== 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=RH+IPOwJITsK55x7GggxOQ9MIYHJ4riLL8mEAOOeoXc=; b=fADgJX3HdCoDXvGXId6Ety19+t0ckRlGSjtSv6Le5v66YZVtlVRxKkFDYbsu/9kyak Ld8O8FVu7aNwJvQbsrbdJ9OD/ITcO0FfMi3lSrxvwUWDSDlpYcMQXJHermnm2u5KVJmP dC4G8fbXJwrYVnK9x7CXBi9r4aK8OU/GryE6XH2J7SMRyfw17FKIbVTF5g/jDBNbXO/B 1tbk2LW7Q5SjgBa8XBUzmpUYfEuq4MHisbtASQcJ311BJ0wy8OA3YGkCtHK1H4X9TXqW i8mPQ7o+bbkjWJhCUD5Xhe7XiC3wEdAQEXS8wqIdH3jGUvCtulGpcC4n7YEvzCmLNzWL N8Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=SzKskAqA; 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 u11-20020a6540cb000000b0051ace49ded1si6148128pgp.886.2023.04.24.01.29.00; Mon, 24 Apr 2023 01:29:12 -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=SzKskAqA; 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 S231495AbjDXHyt (ORCPT + 99 others); Mon, 24 Apr 2023 03:54:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231441AbjDXHyk (ORCPT ); Mon, 24 Apr 2023 03:54:40 -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 271F010E7 for ; Mon, 24 Apr 2023 00:54:39 -0700 (PDT) Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 20230424075437c91b3f3775558fdb90 for ; Mon, 24 Apr 2023 09:54:37 +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=RH+IPOwJITsK55x7GggxOQ9MIYHJ4riLL8mEAOOeoXc=; b=SzKskAqAU1VFoE/Uv0dZm+lVtO9JrwPoRL43i05+A47eUJ1Gq2QWJ74nmZhFludD8f0vJL CEvajtupfrgJEa4JHVrFxU9gWTkjSx/r3Yz37kq0Bggso5aUulPBm1Hz0HLMLOx0UlaYshGa PWO4s5g2WPpWsmhEeD6qSkx/Wy/Ss=; 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 v3 6/8] tty: n_gsm: increase gsm_mux unsupported counted where appropriate Date: Mon, 24 Apr 2023 09:52:49 +0200 Message-Id: <20230424075251.5216-6-daniel.starke@siemens.com> In-Reply-To: <20230424075251.5216-1-daniel.starke@siemens.com> References: <20230424075251.5216-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?1764045569197415024?= X-GMAIL-MSGID: =?utf-8?q?1764045569197415024?= 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(+) v2 -> v3: No changes. Link: https://lore.kernel.org/all/20230420085017.7314-7-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 10fc02133efa..941489230f9f 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 Mon Apr 24 07:52:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 86893 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2583585vqo; Mon, 24 Apr 2023 01:21:48 -0700 (PDT) X-Google-Smtp-Source: AKy350YAxFJ1rZmgUFHKdN0MunvfsOFluT+QkmOk7A3hprWQbVa2lGOYwoNSXhrXT7DnogFT6iin X-Received: by 2002:a05:6a00:b8b:b0:63f:1926:5bb8 with SMTP id g11-20020a056a000b8b00b0063f19265bb8mr11816082pfj.30.1682324508636; Mon, 24 Apr 2023 01:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682324508; cv=none; d=google.com; s=arc-20160816; b=r2TiVtljnMKZoZ47+82s+RoV/Ix664Lgzf7StCvK31O3jygQoTKYivn8C1eotuUK7W MSbNRLA92jXVHwEvp4n4Uhv0hhHLD8hw9DNXep+6p4WXa10dYSinSDW0KcdQor03of47 o1/h9X+1bFdxXt/erwaQGY2xYlW0LhCTY0+pX72cxbLyEVa8SOXoqHarg79HLys49Dow P4ZWwaOiibDe0cVhr6cTjDYtj1Q1Zu5vQPSGH0Trdpvggl15Nmmoy8QULi5iee1lKoOS 96h6mzWq6spaarwjAZwTMPBN1u0xiRdNOTMX8w0kLoe4opLpA9S0YyX58lNA2M9N4o0a pVOw== 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=feocQKWZExwrMEVQOT46ezGWZ9/FaOQ9KuX24u8pJEU=; b=N8KmAbjnraaK25FXO73XC1cgfRnIa5A8imfawlPdbrt+6nxHeMMHvZE+eiOjMwrmth VxD6wk2ndV8tYkaXR814/K48KNqIcBQigCF+PIE34ScujSjIlIW8lhnQugfq+PVExkbR T2Qz8tTTg9spY2WIC4CJP2RCqEND5GKIlven7g24rU+74CH4sKm7HBnNRYM+MuxGdOWl BpY3jn2+mhJAJMgvAlrqAkBL4SB3XJaZYS+XuPXv/d9kjttDMu8XGRhPv8da79CAu/ga MgRdkUqYfoBAHUr3ALfg24D1TxpfSYAzcHYYe1dB8VYeNmArw02B2amQBnFCXxaAJULf 2/MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=Ra3ZcsRe; 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 v63-20020a638942000000b00518c9f4263fsi11224961pgd.468.2023.04.24.01.21.36; Mon, 24 Apr 2023 01:21:48 -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=Ra3ZcsRe; 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 S231502AbjDXHyw (ORCPT + 99 others); Mon, 24 Apr 2023 03:54:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231431AbjDXHyk (ORCPT ); Mon, 24 Apr 2023 03:54:40 -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 384CC10EC for ; Mon, 24 Apr 2023 00:54:39 -0700 (PDT) Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 2023042407543743762a8cacbf120a4a for ; Mon, 24 Apr 2023 09:54:37 +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=feocQKWZExwrMEVQOT46ezGWZ9/FaOQ9KuX24u8pJEU=; b=Ra3ZcsRewnbVNg6TqfmiSYS25wZ5890uajDaKA+3ceX2p56K7oTQxO6WL8gkTnF+PP7wJy PilADWXJyAObQVrZab2YKPzkx9OaoePOoEm426wR7RrcQqQWPuWkbtk1R9NFHYYyHHvMJwY5 EI3Ze0nIE7AdYiEZM8pOBUpMuc7rU=; 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 v3 7/8] tty: n_gsm: cleanup gsm_control_command and gsm_control_reply Date: Mon, 24 Apr 2023 09:52:50 +0200 Message-Id: <20230424075251.5216-7-daniel.starke@siemens.com> In-Reply-To: <20230424075251.5216-1-daniel.starke@siemens.com> References: <20230424075251.5216-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?1764045103580731909?= X-GMAIL-MSGID: =?utf-8?q?1764045103580731909?= 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(-) v2 -> v3: No changes. Link: https://lore.kernel.org/all/20230420085017.7314-8-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 941489230f9f..6bfcaf8fe54c 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 Mon Apr 24 07:52:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 86894 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2584278vqo; Mon, 24 Apr 2023 01:23:18 -0700 (PDT) X-Google-Smtp-Source: AKy350bg1559/zt+xO6fucriDI7TptY0/pDIARi/IPGISxo3DD+NaqKlZ7CsyT9ibXYyw5CqMAaX X-Received: by 2002:a17:90b:3110:b0:246:fd44:eb6f with SMTP id gc16-20020a17090b311000b00246fd44eb6fmr13015380pjb.39.1682324598144; Mon, 24 Apr 2023 01:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682324598; cv=none; d=google.com; s=arc-20160816; b=whzDnD8fglLdLsnyA/UlbOHN40vQlY4FhF2cEVJDGUcJ8xdz3LNR1J7cIFoUMyYjLR qOh++KZmi9o2c1mFpTnh/8exPcaqsKPFlhLBRau+Mxp7Ra9bpA9REDP3JyFIWfvnETDE ea1YY+1Yp4zrBRHPdEIEwNRi75PjR7WWjzxfX/C5LI1tGyDHto0KrxzytWJhL5+QBoBu eZjzLbnFPf54l0zXL7sv+Nx1dIUXb57nLSjdbwFFm2/aRUREr8U6U/tazik1UJ3jgzPC Y2U6UUPJKo8KQtELmnHosqb5//bB0rNEHhBdz5VcUFDCnbyG/oifJ8qTin9JOxCodMtt E61A== 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=TMiKHVqdPJJ94SJ7CYeAuedDKJjk5C6OoKfwHyNkX74=; b=JKSNUctaNogNqK/6P+xPS/giVSPsQaYYpvvzejYBZnXLv5A1sYBI59dm/M7NWOWuVa n45cxpB9FUULr8I0BfZcoQOhi2dkBKXJ6c5kXcHrRxvLlujt2xor6Pn6YaBEHxBhlWF0 x+Ag+lFpKGj5u30g1o3MQctX+WcHocfXQUPW6RC1FNTo0UyEkAcTbTZq6u1IxHFyqgBY 7YGq9hJfUpfyulgec2mY4TCj/PrkIJyZ4fab9009ESaz+/gYNiQQWtEgBnrL2BGpJDPS 9oirw6jITT15QrKfEtD5OZvEEhSJYPmWnHzl7SRJSr6jQJH7WuxRC3a3tyUuXl98dbMo CeMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=KcyPzwEz; 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 b2-20020a63cf42000000b0050bcfe667e7si10371571pgj.474.2023.04.24.01.23.05; Mon, 24 Apr 2023 01:23:18 -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=KcyPzwEz; 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 S231312AbjDXHzB (ORCPT + 99 others); Mon, 24 Apr 2023 03:55:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231461AbjDXHyl (ORCPT ); Mon, 24 Apr 2023 03:54:41 -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 0DB9010F5 for ; Mon, 24 Apr 2023 00:54:40 -0700 (PDT) Received: by mta-65-227.siemens.flowmailer.net with ESMTPSA id 2023042407543818b8085091f816099a for ; Mon, 24 Apr 2023 09:54:38 +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=TMiKHVqdPJJ94SJ7CYeAuedDKJjk5C6OoKfwHyNkX74=; b=KcyPzwEzxq2cT9bEVkBbcU6KeITsFXBmrV3DKv5X/CId4YV28+aCpg5P5nmoc5aSn7xmUV EaguzZ+QCskm9vYOt323mnEieR8xIa1+FgMX1Nw/0AvgtS4KMFWI4zQQ+AKDWq2QhbV1jWUs eINdAk2KwYh1y5eBJdr7K0YZi5gCg=; 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 v3 8/8] tty: n_gsm: add DLCI specific rx/tx statistics Date: Mon, 24 Apr 2023 09:52:51 +0200 Message-Id: <20230424075251.5216-8-daniel.starke@siemens.com> In-Reply-To: <20230424075251.5216-1-daniel.starke@siemens.com> References: <20230424075251.5216-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?1764045197763187437?= X-GMAIL-MSGID: =?utf-8?q?1764045197763187437?= 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(-) v2 -> v3: No changes. Link: https://lore.kernel.org/all/20230420085017.7314-9-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 6bfcaf8fe54c..7377a37320af 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 {