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: 676084 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83065C77B72 for ; Thu, 20 Apr 2023 08:56:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234195AbjDTI4F (ORCPT ); Thu, 20 Apr 2023 04:56:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234134AbjDTIyg (ORCPT ); Thu, 20 Apr 2023 04:54:36 -0400 X-Greylist: delayed 62 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 20 Apr 2023 01:53:02 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 B37D146B6 for ; Thu, 20 Apr 2023 01:53:02 -0700 (PDT) Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 20230420085158382ea5f5fa16b3fc4f 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: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 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 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: 676087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA910C77B73 for ; Thu, 20 Apr 2023 08:54:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234017AbjDTIyy (ORCPT ); Thu, 20 Apr 2023 04:54:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234192AbjDTIxq (ORCPT ); Thu, 20 Apr 2023 04:53:46 -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 7F05F6A7A for ; Thu, 20 Apr 2023 01:52:01 -0700 (PDT) Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 202304200851597bbd3e95150ce54b3e 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 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 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: 676086 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69AE6C77B78 for ; Thu, 20 Apr 2023 08:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234055AbjDTIyz (ORCPT ); Thu, 20 Apr 2023 04:54:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234084AbjDTIxq (ORCPT ); Thu, 20 Apr 2023 04:53:46 -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 828B86EBD for ; Thu, 20 Apr 2023 01:52:01 -0700 (PDT) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 202304200851598939b0e23a5e1de26d 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 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 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: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: 676085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A84A5C7EE20 for ; Thu, 20 Apr 2023 08:54:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234068AbjDTIy5 (ORCPT ); Thu, 20 Apr 2023 04:54:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234052AbjDTIxt (ORCPT ); Thu, 20 Apr 2023 04:53:49 -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 1BFFB6A69 for ; Thu, 20 Apr 2023 01:52:04 -0700 (PDT) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 202304200852025a934fdd58a7a110db 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 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 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); } /**