Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2607749rdb; Mon, 4 Dec 2023 02:21:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCMLCJQ87hw6BjHcXNMvwr2OnJNQDMhZbxoaO6lQOTq6CY47+FZcV/5E6gon0cKHYYNngh X-Received: by 2002:a05:6870:ab0d:b0:1fb:3241:be3c with SMTP id gu13-20020a056870ab0d00b001fb3241be3cmr2147121oab.34.1701685272420; Mon, 04 Dec 2023 02:21:12 -0800 (PST) Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id z15-20020a63e10f000000b005c684e1f2ecsi1872156pgh.400.2023.12.04.02.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 02:21:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Zm6/kVaw"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4F8998075955; Mon, 4 Dec 2023 02:20:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbjLDKUF (ORCPT + 99 others); Mon, 4 Dec 2023 05:20:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbjLDKUD (ORCPT ); Mon, 4 Dec 2023 05:20:03 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03A8C85; Mon, 4 Dec 2023 02:20:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701685209; x=1733221209; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=gKB5T9b0vzI/brXFkTTNPTdC3EvJjR8ByNrznFb2NfQ=; b=Zm6/kVawNgtV6IDw1JZs+gWZ3TTON9qfnKidcHhR+0TdvOeGVt8npBoM MXioGbjAmWThWVk7CwUy5nYiqJsD6d9G718g31JYM459o7etnkuTREeMZ OiOynKvA1oGcrwlpGjfeCL5tPIyqoZyJFW3kOLslFnAM11QW/XrlqolX5 GqX2YTPjpMnE2VgGOFi4IZJ/n14ohUmIxxl6AA5ZhJBUJgBdc71vLOKAR WrJEqDZbRvP1JhYrzN0dMC/lyRNy+Tx7oVo6bd0kiiNoONZqCV5H/4h/1 zd+SxtqJQNLZcpn7xoU1UaOn5I/4Md1mMOlrd6L1iR8AYvdFesussgsNL g==; X-IronPort-AV: E=McAfee;i="6600,9927,10913"; a="390871652" X-IronPort-AV: E=Sophos;i="6.04,249,1695711600"; d="scan'208";a="390871652" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2023 02:20:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10913"; a="774211502" X-IronPort-AV: E=Sophos;i="6.04,249,1695711600"; d="scan'208";a="774211502" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga007.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 04 Dec 2023 02:20:08 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 4 Dec 2023 02:20:08 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 4 Dec 2023 02:20:07 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Mon, 4 Dec 2023 02:20:07 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.100) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Mon, 4 Dec 2023 02:20:07 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HLQtKWvREB/sYuM5RPEz4ptZhj3aGSK0Hw3ppyuRfS1jMVmoeNXhGkc7Qph6s3ihidMbb6VGl+Enk1t3BLuuhgDy7PS6aKdJHu7pjNe5916R3QkA2VUqEMzQnFpky7JkHltMHZnvPzn42rNq11DYUlpDp3+OA5xrcS5H2PdAv0HgAbD91Et2Gl6RiWB9kWEY7UAYhyjYZb5s5I44B1N5V+LjgYO2qPxvP8kOtHTI7hb8AqZdeJDxSFKlAGDF2l5ihKYJChTwwV0mdc1C5C4Xb/8lHiSIKBBlLLPyyA3E6EgY10/wxeZM+Ujs0yX+25tcWp+R9zf34JUrUwR6gtcWtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cYi893dj0YDa0EHLnoF74UN+h7gFoT7V4VOB77yivWk=; b=OY//DXwNMLGEm58FET66ijQ5hJgoeg879G85n5MZZF1HKZGfRtd+R9VKca5/38v05STdwrJl+YGH9d86P6hXI/cWxAj6ZtDFATf3pW+sK6oNbl9xnLDhvc2TAqvVuKHYbN/6v3b36wa32MIYvsReW5eQEwo4GXTEauzDcep0Q3S1ZM2CLWj8XpgM0wiI7Om1lUTKd8m6GmOCKRNS2sIjYy3wWDS41Ynjj3ATUVhhVLy3sb4opf83bbI+PdnndlPss++qxHLipJSq7QX272HcyWPSBTb7xnoleGQGBi+GVm7i9MO1Tbi2aCCVbGm8fs3o/8ZisUbbxbEAvsb471WCQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MW4PR11MB5776.namprd11.prod.outlook.com (2603:10b6:303:183::9) by DS7PR11MB6222.namprd11.prod.outlook.com (2603:10b6:8:99::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.33; Mon, 4 Dec 2023 10:20:05 +0000 Received: from MW4PR11MB5776.namprd11.prod.outlook.com ([fe80::49fc:ba56:787e:1fb3]) by MW4PR11MB5776.namprd11.prod.outlook.com ([fe80::49fc:ba56:787e:1fb3%7]) with mapi id 15.20.7046.033; Mon, 4 Dec 2023 10:20:04 +0000 Message-ID: Date: Mon, 4 Dec 2023 11:19:59 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V2 net 2/2] net: hns: fix fake link up on xge port Content-Language: en-US To: Jijie Shao , , , , , , CC: , , , , References: <20231204011051.4055031-1-shaojijie@huawei.com> <20231204011051.4055031-3-shaojijie@huawei.com> From: Wojciech Drewek In-Reply-To: <20231204011051.4055031-3-shaojijie@huawei.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: WA2P291CA0012.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1e::27) To MW4PR11MB5776.namprd11.prod.outlook.com (2603:10b6:303:183::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR11MB5776:EE_|DS7PR11MB6222:EE_ X-MS-Office365-Filtering-Correlation-Id: d4c8e81f-09a5-4598-36eb-08dbf4b2951c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ASieUdXiYC9Ffz6nZkhM1Kyhyaw4uK4EjY/qeyA6WQJH757u0mk81T4MgXyHMKy4XRMdo+ss6kTHCNc2yZScqyL4fIwQWrPYcIgIjWPzSLVExvCI6bcYAe6OMz59DqrE2ib5YEDEweaCu+u1Te3Uvq/MgulUeKf7QDBCQer3KGjrHfTZih/mIGWG2AhkKNC7py43SGcc3Jx3YrC8mkmH3IkFtb3QGafM0VHLTtFLNlnHC3pFr3z+IY1wJRq0nelgJLNurhtAcTWFRFuf48LH2vv+G4TSWELqXfZBl4a4eXvEhlOJAEX0rIPz7l0DZx2XIINAhU0TSrRf21foeo7J9D6rvIIuXXXKpwQgeZLH/XHx8ybaSPDe9R3+E+xwbeoELiDLw01ONyt3qV2TU+Cjy0db0HOkOKGXoxVza1ctoqENxfdD/zUTQub1vMtqiR+IJ+LwOzkPhmTid83Sf2G3BAZ0gyGS4aQdocEikxvzHwepQ20XTd3sfgS1d7fFjMhE6pQbVxzi5Q9hZUFvCk+WQBMOqxe8SHZNIZfTpITJBidgFqjmbYFg8b0CD2ah/iZJu2ieQ+Ini4n7+2QdxuCxSmHE2v80pwpRqQEz0MTr9KLPwGXgCD06kxCi5mMkOgXIg7hV2bvLuMj2SQWz3xOtTg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5776.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(396003)(136003)(346002)(376002)(39860400002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(316002)(66556008)(31696002)(86362001)(4326008)(8936002)(8676002)(66946007)(66476007)(44832011)(478600001)(6486002)(41300700001)(36756003)(7416002)(5660300002)(2906002)(38100700002)(2616005)(26005)(6506007)(6666004)(53546011)(82960400001)(6512007)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Umo2QklGeHVDK0dDalE5OE1TTkJPMG5NbHBLL0wxd2JzL1EzVG5aNWtnTyty?= =?utf-8?B?TXRsWnZMbHdPaUFoTGw0U3FXUXVsakJCb2hXQTdUU3FUZ1Y0ZGFvVndiZ2Vx?= =?utf-8?B?L0pQUnRlV0FWcUdQejg0eXZLQVFJZWdHbzNucVpQR0txZGFyTEEvRHpFMWpx?= =?utf-8?B?TVVUYm9JYmlNQUtjWE5OK05xRVFEUENtRGRGeVdXcVcxRVg3YkxiUkNLNkEy?= =?utf-8?B?cE43dHhvcjlTVzRWMkkyQWhjRGk2RWhhL0R1MU9oRlpwOG5mYjNJRWFFQlI0?= =?utf-8?B?NGwwZmpvRVErL05CeUNSMyszbDc5ZGk2eTR6Z29OTUEyN0VhNENuYWNJVUtZ?= =?utf-8?B?eThrQ0ZPNzZwNEx3UUM3blUzbDlyZHUrY1JKaER6NFZzekRuMG5zdGtPTmow?= =?utf-8?B?SWY2dEhYUi9MRThncmhTTHpnRVIyUjZTZG9WenIwc0N6eHlhcjZQWFN6ZWIr?= =?utf-8?B?bE9yTU9mRkRQWXZkRmt1a0RNd1llZWRBdThoSU5kTHkyWGozdW5DY2t6Zytm?= =?utf-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bmJjYnpE?= =?utf-8?B?ejJlN3BmbVlTN3JqazFZYmV3a0R2ckI5cFN4RWg1cnhMU2I0QjU0dFdyMGcx?= =?utf-8?B?cWhOUFhXbjdpMk9yRHJzem9OeFlhbmMyc3R6bnJCeFBreEpwUWNXNGNrNUZU?= =?utf-8?B?WjVtWFRaVkpjSUJTM05SNTNMcDJLbWlFZktySGl5elJzbngyWWpZMWdZamNY?= =?utf-8?B?QjhQZ3hQTzVwVnd3UjdSZFQ5NFowVzUzVEg1aXgvZXJPOUxDQnQ1N0ZQSmtF?= =?utf-8?B?Uk5UMXhJV0VBdjQ0bUFHTGpBSVl2NmwvR0krM1A3ZTVvTFJFMG5kN0ZJR05p?= =?utf-8?B?MnlWQm04K1FPay93RUdYSGVTRWZuY1JnN1Y2ZWhMVUt1QVBVYTJ4SjBIZ210?= =?utf-8?B?Yzl3OEZKQ2JKdVV1ZVY0Yjk4YXZHMmQyTUFKVEl2c0FnYUpRVjAyYXY0a2Zv?= =?utf-8?B?OTZneHFtNTBWeGdwUVZ4NFN3QlZKekptNEIvSzk0aWZMbnAvVXJoTWhnRlJG?= =?utf-8?B?aGlUK0llbVovSEhoUGFoZlpiaUtOZ0YyMTFaL0lZNWdMaG52MEJvNm1IMTV1?= =?utf-8?B?R1Q2K1hqTnBmTU4vZnduRzRLSndYK0h1YzQxcmxON2c3cHljR2NkR2twRXhK?= =?utf-8?B?Mk5YYWhtNWxUcFh4RUFWZXlnckhhVGZUaWFFL1FZN2ppZGlOcXFCUmM1RjI0?= =?utf-8?B?bmZyOGRZcDBINXp3V295N3MycXRtcDhOY0tQMFhKcDlsSDlPeG92bEJmZlVs?= =?utf-8?B?N1E9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: d4c8e81f-09a5-4598-36eb-08dbf4b2951c X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5776.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2023 10:20:04.8721 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 65sScq61ZGdgLefgjCsGGS8FcUyXk6GuWLj0wZzW76bo6SJzqbFDwPw/fVWtktHBvMvZW3h8TMmVIY279YtkLtGknqTh+l8DUngCKL+FwLA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR11MB6222 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,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 howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 02:20:23 -0800 (PST) On 04.12.2023 02:10, Jijie Shao wrote: > From: Yonglong Liu > > If a xge port just connect with an optical module and no fiber, > it may have a fake link up because there may be interference on > the hardware. This patch adds an anti-shake to avoid the problem. > And the time of anti-shake is base on tests. > > Fixes: b917078c1c10 ("net: hns: Add ACPI support to check SFP present") > Signed-off-by: Yonglong Liu > Signed-off-by: Jijie Shao > --- > .../net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 29 +++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c > index 928d934cb21a..c3abb14edd51 100644 > --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c > +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c > @@ -66,6 +66,27 @@ static enum mac_mode hns_get_enet_interface(const struct hns_mac_cb *mac_cb) > } > } > > +static void hns_mac_link_anti_shake(struct mac_driver *mac_ctrl_drv, > + u32 *link_status) > +{ It would be cleaner to return the link status than using output arg IMO > +#define HNS_MAC_LINK_WAIT_TIME 5 > +#define HNS_MAC_LINK_WAIT_CNT 40 > + > + int i; > + > + if (!mac_ctrl_drv->get_link_status) { > + *link_status = 0; > + return; > + } > + > + for (i = 0; i < HNS_MAC_LINK_WAIT_CNT; i++) { > + msleep(HNS_MAC_LINK_WAIT_TIME); > + mac_ctrl_drv->get_link_status(mac_ctrl_drv, link_status); > + if (!*link_status) > + break; > + } > +} > + > void hns_mac_get_link_status(struct hns_mac_cb *mac_cb, u32 *link_status) > { > struct mac_driver *mac_ctrl_drv; > @@ -83,6 +104,14 @@ void hns_mac_get_link_status(struct hns_mac_cb *mac_cb, u32 *link_status) > &sfp_prsnt); > if (!ret) > *link_status = *link_status && sfp_prsnt; > + > + /* for FIBER port, it may have a fake link up. > + * when the link status changes from down to up, we need to do > + * anti-shake. the anti-shake time is base on tests. > + * only FIBER port need to do this. > + */ > + if (*link_status && !mac_cb->link) > + hns_mac_link_anti_shake(mac_ctrl_drv, link_status); > } > > mac_cb->link = *link_status;