From patchwork Wed Apr 26 08:03:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "D. Starke" X-Patchwork-Id: 87705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp77951vqo; Wed, 26 Apr 2023 01:06:07 -0700 (PDT) X-Google-Smtp-Source: AKy350ZQh30YQKp7DE5BuUrD49FpZ0ZkjkunHp8+nfytZfkiU6BGc0hsJY263Z6NRfgm/1L+e3zS X-Received: by 2002:a05:6a00:148e:b0:63b:6911:8928 with SMTP id v14-20020a056a00148e00b0063b69118928mr27440615pfu.3.1682496366890; Wed, 26 Apr 2023 01:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682496366; cv=none; d=google.com; s=arc-20160816; b=SQ1rR1lVfhykpUekdQ6U5ZESzK8ObE/Esp5MoIEykd1TYnb37iKkd2+yZYiIxByNI9 TgI/YBnQ+v4C1S+zZ1DdtpT4vlfIzNsZFAy6rNCUHDwagZMpP6lgoHSeHB8S4puA1g0U 2QMr4RtUfE5vN0N2IGaY4ui7YVyCTmcHNPXRdAYiOUMBVuSkQ93EOz9XokU17SqXqHyy pE7ifzbROCinC+SGx0mFdcXSaVOLbRMNyAWG4dg/Hbl0a5crR0cMqkmpBd/Y+/9gwqX1 7W73My5rwjaGJItJFcFaXjpzQ2eLQGXuRNaZ2UHTAGeZjD4yLVdjXHkKvKMnH+mXHD97 cnxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p6b7aAXTOy3vsIR4rxhbr+q8rc2g+ZY+H/rSFp5TQGY=; b=BhHVYjwmyq70DZm2OMK0FR/zh0BZuOTh2guw3oSzuLMoCzN4u6tAmJ+d6I36qY9ZTX w8sytBdIbUeJlx2qzn3a+Fja/00yuh1SQZ79iRTpBkdViFPMHr4pQlUXPzI6lsC5CTPv YC11mBGdgWo5ZDTZ26L0/ctx4r+R2fFmaeuJGafjHx8let/lgpDAB/g7SXrI6FglDryV 3lCFcrHLbbWrBd0YRxgNSyrf3LaashD81Nm76p7y/HsKWH0pH0pASOX3tbnreo83X8Bj 0aCgrfGGH1X2CUp7ObXH3KsBTK5dY/yrL9CdsWQ3OU/FC8kZJxJsjoSOfUWay5d0i2X7 GLkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=LqDNIFJm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p10-20020aa79e8a000000b0063b7ab0b1aasi15984676pfq.242.2023.04.26.01.05.52; Wed, 26 Apr 2023 01:06:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=LqDNIFJm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239967AbjDZIDj (ORCPT + 99 others); Wed, 26 Apr 2023 04:03:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231467AbjDZIDg (ORCPT ); Wed, 26 Apr 2023 04:03:36 -0400 Received: from mta-64-227.siemens.flowmailer.net (mta-64-227.siemens.flowmailer.net [185.136.64.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F0053C20 for ; Wed, 26 Apr 2023 01:03:33 -0700 (PDT) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 2023042608033169ae164e96aed67dc3 for ; Wed, 26 Apr 2023 10:03:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=p6b7aAXTOy3vsIR4rxhbr+q8rc2g+ZY+H/rSFp5TQGY=; b=LqDNIFJmKyyINdmHMrgjdtlcucp/LjFeNDXynofdo4G/e32VT5YAMlQ5Z4MXqdPUouHhHi Cg2nQrAuo05jE7gZJj0uPufgdAMN73kbr49SNovSNnaAFuTdVENdeYqs620LhcddCNvloSzC POJ/URDsS2myMWx+X1e4Qvi1HxvLo=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v4 4/8] tty: n_gsm: add open_error counter to gsm_mux Date: Wed, 26 Apr 2023 10:03:11 +0200 Message-Id: <20230426080315.7595-4-daniel.starke@siemens.com> In-Reply-To: <20230426080315.7595-1-daniel.starke@siemens.com> References: <20230426080315.7595-1-daniel.starke@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764225310498830066?= X-GMAIL-MSGID: =?utf-8?q?1764225310498830066?= From: Daniel Starke Extend the n_gsm link statistics by a failed link open counter in preparation for an upcoming patch which will expose these. This counter is increased whenever an attempt to open the control channel failed. This is true in the following cases: - new DLCI allocation failed - connection request (SAMB) with invalid CR flag has been received - connection response (UA) timed out - parameter negotiation timed out or failed Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) v3 -> v4: No changes. Link: https://lore.kernel.org/all/20230424075251.5216-4-daniel.starke@siemens.com/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index ebb71957f783..186f463f0f11 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -339,6 +339,7 @@ struct gsm_mux { unsigned long bad_fcs; unsigned long malformed; unsigned long io_error; + unsigned long open_error; unsigned long bad_size; unsigned long unsupported; }; @@ -1730,25 +1731,32 @@ static void gsm_control_negotiation(struct gsm_mux *gsm, unsigned int cr, struct gsm_dlci *dlci; struct gsm_dlci_param_bits *params; - if (dlen < sizeof(struct gsm_dlci_param_bits)) + if (dlen < sizeof(struct gsm_dlci_param_bits)) { + gsm->open_error++; return; + } /* Invalid DLCI? */ params = (struct gsm_dlci_param_bits *)data; addr = FIELD_GET(PN_D_FIELD_DLCI, params->d_bits); - if (addr == 0 || addr >= NUM_DLCI || !gsm->dlci[addr]) + if (addr == 0 || addr >= NUM_DLCI || !gsm->dlci[addr]) { + gsm->open_error++; return; + } dlci = gsm->dlci[addr]; /* Too late for parameter negotiation? */ - if ((!cr && dlci->state == DLCI_OPENING) || dlci->state == DLCI_OPEN) + if ((!cr && dlci->state == DLCI_OPENING) || dlci->state == DLCI_OPEN) { + gsm->open_error++; return; + } /* Process the received parameters */ if (gsm_process_negotiation(gsm, addr, cr, params) != 0) { /* Negotiation failed. Close the link. */ if (debug & DBG_ERRORS) pr_info("%s PN failed\n", __func__); + gsm->open_error++; gsm_dlci_close(dlci); return; } @@ -1768,6 +1776,7 @@ static void gsm_control_negotiation(struct gsm_mux *gsm, unsigned int cr, } else { if (debug & DBG_ERRORS) pr_info("%s PN in invalid state\n", __func__); + gsm->open_error++; } } @@ -2221,6 +2230,7 @@ static void gsm_dlci_t1(struct timer_list *t) dlci->retries--; mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100); } else { + gsm->open_error++; gsm_dlci_begin_close(dlci); /* prevent half open link */ } break; @@ -2236,6 +2246,7 @@ static void gsm_dlci_t1(struct timer_list *t) dlci->mode = DLCI_MODE_ADM; gsm_dlci_open(dlci); } else { + gsm->open_error++; gsm_dlci_begin_close(dlci); /* prevent half open link */ } @@ -2757,12 +2768,16 @@ static void gsm_queue(struct gsm_mux *gsm) switch (gsm->control) { case SABM|PF: - if (cr == 1) + if (cr == 1) { + gsm->open_error++; goto invalid; + } if (dlci == NULL) dlci = gsm_dlci_alloc(gsm, address); - if (dlci == NULL) + if (dlci == NULL) { + gsm->open_error++; return; + } if (dlci->dead) gsm_response(gsm, address, DM|PF); else {