From patchwork Mon Jul 19 11:33:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruud Bos X-Patchwork-Id: 480323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F7EEC07E9B for ; Mon, 19 Jul 2021 11:33:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F597610C7 for ; Mon, 19 Jul 2021 11:33:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236409AbhGSKwk (ORCPT ); Mon, 19 Jul 2021 06:52:40 -0400 Received: from mail-eopbgr70108.outbound.protection.outlook.com ([40.107.7.108]:20000 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232156AbhGSKwj (ORCPT ); Mon, 19 Jul 2021 06:52:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=huhUWh6f9pIax2alrY0L4AZnfLDmvl9HK2fAMqa+5uSKC7q/Mqp6jRIBzMdEVvvksDzfirDM1Wnz9dRSeFO9jgd/7YRzDZZi86wLifda3NxVwbULiwTTKLkhEbGAXEUgKH8oPsdTkVaJpdXX2bc7FylgUg1MwdXzQsxtfdFMzcaxPlNijf3T0k+JEaUNRUJZGj8LskOce9cft6BN6x/Pq3ohTtiB6ymnYHq6f4WhgwfRXIMzrIMgHmHsE+I9QHM6S5FxYaHRxsHLIoREDQEIyhnQAp0FDgSZrq99PfN/FLonn+jWWZss4291gAPpOB44QS5c8KVAED6uVCECoG7aEA== 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-SenderADCheck; bh=dS5a4c2ZKFzE8zL4AeAbXR18mkQsM5YX1LneI7g1I6o=; b=Qwx942aEqBEsYbk6sBr8oS3fgXsXdRsntYtidZpmCVZiuSB1EMD+VUwxRDNyG6G96RnR418W0JcSeAmvdP/mhHIWE0tgWIEDNYym2fFHhM2Rckx9oxO3gR96Tyb/jtVRaxQDq3cAVwR5q5pVu8QZOrEKciHFXy1/4pLBvFS4Gt2RNMr9oAiih1ci/p5H4EIlfCiBXbnjclGqASo3Nd1WAEULiJM0FNxt611+QzGIDX99OqJa1mjJEwRzmzBF4bjqhpDoc4npFhVaPvshprybKNfN/n6z8A/YeCr01aK5qEETMhPvfRMzEYbO8wH4Pv2zRzQteAjM/7hBiNqNYuyxYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hbkworld.com; dmarc=pass action=none header.from=hbkworld.com; dkim=pass header.d=hbkworld.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hbkworld.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dS5a4c2ZKFzE8zL4AeAbXR18mkQsM5YX1LneI7g1I6o=; b=dt2FBAWr+tvDsUF2Gp2eud1G/0cx6XBHRfWsowUnhO7WJowA8hOuku15hOrjwBeo84tsEb01NWVwGQLL6aEL9rJ6yj7BthgMJAZ6gY50nW6ZFB56q9wltDwp/ur6U27WnYuQlDtLuEhj7PSFcHQmKuWwr1cVkz/BofN3ZfeJU47xS3IcDmqGXp5kJiZvX200xA3HBMh+g9GkXa64qXNp1E6ItV9bZBlj0FQaZPNDotI7otf8Y9YYiNtEw8LrQIYXEwIaOvulZ4WoFBSWsqVorFWQ7v0t/TntNS5a3M9v2hRXYZYLUzpEos2R6zw2TBOOp94H4GaltHww/gGizazy3w== Received: from AM0PR09MB4276.eurprd09.prod.outlook.com (2603:10a6:20b:166::10) by AM8PR09MB5228.eurprd09.prod.outlook.com (2603:10a6:20b:3db::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Mon, 19 Jul 2021 11:33:17 +0000 Received: from AM0PR09MB4276.eurprd09.prod.outlook.com ([fe80::4d88:bf9c:b655:7a92]) by AM0PR09MB4276.eurprd09.prod.outlook.com ([fe80::4d88:bf9c:b655:7a92%7]) with mapi id 15.20.4331.032; Mon, 19 Jul 2021 11:33:17 +0000 From: Ruud Bos To: "netdev@vger.kernel.org" CC: "davem@davemloft.net" , "kuba@kernel.org" , "jesse.brandeburg@intel.com" , "anthony.l.nguyen@intel.com" Subject: [PATCH net-next 1/4 resend] igb: move SDP config initialization to separate function Thread-Topic: [PATCH net-next 1/4 resend] igb: move SDP config initialization to separate function Thread-Index: Add8kFEBf7R8NvzVR1qaYQ8/VtYXhA== Date: Mon, 19 Jul 2021 11:33:17 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Enabled=true; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_SetDate=2021-07-19T11:33:16Z; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Method=Privileged; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Name=Unrestricted; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_SiteId=6cce74a3-3975-45e0-9893-b072988b30b6; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_ActionId=80a0f707-28de-48c1-9f90-f80f8b6a5765; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_ContentBits=2 authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=hbkworld.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0c303a7d-3bc5-4d63-ad33-08d94aa900f0 x-ms-traffictypediagnostic: AM8PR09MB5228: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2958; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KXmiOwASyn3KfYEri6XKz5hDWg77ZFcP0jifDuxciL+DrSv+KVcRRnsu2Wmv+JWOyDj4up5RCn+ycCssFaRS1TFH4giUGE6lKrQRSwewWOvioiEcn4Ce859wCRj4j66f87QfVBA1OQNY+/wtly4oYZ0Fg9p7iB05x5JsARNjyAiqn6BXdeWWLrB1L2Gr7RtfS0QDEj/2qb8urp1/3Ma+1Q//9PQByz69GG9/uPIzkbpwGWNR6NL+XnUbE9SQ9Yu/IUu2px5P25W3QwzQEhsiHugbAD0MjbboyP3F1BtDlZ1O4Qx6SSvxGh0kqNUtuJC20ELRI79LmjzoaVlbdpFbA9abYwyEQtiCn1BA5lLLiVbjAMJ2mwIx+GbLkLLJq9iOAotSFCksu3XNd2xKm2aUj479JKGQbO5sI123rywQPg6Vh1eVZAdsNWNSSyP2UolE1JSWesO0RiN5WAz+EqiZUAXC869MIDMwmJbDQNTOKh3aOE2BInFoqZppCW5rx5FtGryoUgLBgwzyE6ckKdMbVs30lNnWi878TLnFexe1hCJPhiZZr90q3wG2ynFx9nCIXmLEuGsZGkx/mLF2YLHix0RhE2895yiw1l1Dl6JuueSS0WlEfCq291juXM/NGYXvVHkIZfllV/dL7xIg54nh9iveYqiTjoJpig5+Q4nAD/+0E4NC8ksPETVk6ZNG4ZcXav/EvxK83CnjxofvR4twYQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR09MB4276.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(366004)(136003)(396003)(346002)(376002)(8936002)(8676002)(5660300002)(6916009)(55016002)(33656002)(52536014)(83380400001)(38100700002)(2906002)(44832011)(122000001)(26005)(9686003)(54906003)(86362001)(186003)(15974865002)(66446008)(64756008)(66556008)(66476007)(4326008)(316002)(71200400001)(66946007)(478600001)(76116006)(7696005)(6506007)(38070700004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?r/1+JN2/1eiClGxasS/xRVFlU?= =?utf-8?q?TIpkx2iGFoRuDsnYxCfIluLTr9pZWzTGIWlIC9W3Dw4P/aAMwuhFImNe?= =?utf-8?q?i02NDKj80tmdVnUu/olfNcjggvHYsEoLaC1C3ciKRqam8FZ2zMDgkXfv?= =?utf-8?q?DwK897sFZGvlSlWNk9n2J2mtVmYGc1PAOOEw8mpnMrERXg8oRbUi2CZi?= =?utf-8?q?20Bo4kTqGVqyZbE3dTFF+wzolXmHGw/4V+MPuzC/Gm9GBAS8NIeNcZP0?= =?utf-8?q?DwSKZhfGvuxg9JhX0Q7vXsD59+7QEwKBmnCneUh25EzjEtyTkebeZwk7?= =?utf-8?q?2i1zrTxIgxPHbbi/I3PLNl2G3GfGmHu103tLuHjKSnAmCfCiPXlObN+d?= =?utf-8?q?725meLhrzSiIxIjJ0Pst2oSuulWsFNz98Jro0wC3pEDfh279aWOvKvon?= =?utf-8?q?JfJldj99XBySqJVDjtNehpXDqee36cZ3vcBpzyJL7VMhdW0+yDthumpj?= =?utf-8?q?lp2nm8TEp/C01/ks4aDF3QfQ0XHT5MPJPorGCgC7CJv/KbyeN3l7tnXl?= =?utf-8?q?Wh5j+9gNThpuOWZe8Wq2l5HzW6RMpykTUKq+IB1PV7AM1F6UhGJlOi8T?= =?utf-8?q?XGvdlgyDcyWuvU7FZWKEDSSZBOmRSoG4n5v4K6BDUn1ASaxkrCEIhOUU?= =?utf-8?q?Zm0UuCTI4eOFpEM551t9SRTUG5XlZ6nVYg5MY1z1TLO7qtk3iCkstH/p?= =?utf-8?q?L2DIeysSzc7Ml34JRXtJJ8xaNZj3mPlxPwuiPaCxpbLW52Yspy1SVn/i?= =?utf-8?q?UjZL5sa6wLLlNIRmfddKbT8lfyexh2pvB2TbXDNPiwnW7/TM/MVaoMVP?= =?utf-8?q?5QvptOliyxRr0s8jjmSTJK0puqdDaxPnBE6M+Erd0yvPi7e0/wZU0j8V?= =?utf-8?q?yff/ZzZQOeFGj9Rs1wR5GGy7GC8vLEnCI3n6hJYlEOW3oHJg9V4B1aCQ?= =?utf-8?q?4Lz8nrs6Md8yRzh7jH4rqm6iwq0SxyQhFe7UV8TejrxPIvOBySXpLlqR?= =?utf-8?q?D6inNjskvWcOAAtcXkZ4errx6sOBNZzIxq4wMuHD946y8mZWNyL+PhFH?= =?utf-8?q?ZJdiHG9n4FMHXvX50nErgswCiZj7HcToGzm8kLzueoVlm7SI84DJWGvG?= =?utf-8?q?XuKSclXC5dw8QCs40naM7QAA5sNAGzEEzyv4ysVgWq8yo6yAVZq2Whsv?= =?utf-8?q?V3JmhYiPkNnS8rgHHNd7vXRV4MFn3ABK7ruQon8pzbpCnhx4j0ZtWX9E?= =?utf-8?q?KTOl4PrhLvMms8SZdTDv5jP8AF0uyOvilWhkYbHNzOL9CFCCCqkeYeiP?= =?utf-8?q?Ldt7Sbw2UrYf2LsZsbxlPHMW4vjqFXXjXFEoJx9uzhDlBCU+l05jqzRq?= =?utf-8?q?cBWWum/Z88=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: hbkworld.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM0PR09MB4276.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c303a7d-3bc5-4d63-ad33-08d94aa900f0 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2021 11:33:17.4032 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6cce74a3-3975-45e0-9893-b072988b30b6 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: emqpzrKoZZm4fNCCHNc8UVby5unv3Ewv9iw6Vz8RFSLIJpH2HdhcInrwliSz+HT6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR09MB5228 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Allow reuse of SDP config struct initialization by moving it to a separate function. Signed-off-by: Ruud Bos --- drivers/net/ethernet/intel/igb/igb_ptp.c | 27 +++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) -- 2.30.2 UNRESTRICTED HBK Benelux B.V., Schutweg 15a, NL-5145 NP Waalwijk, The Netherlands www.hbkworld.com Registered as B.V. (Dutch limited liability company) in the Dutch commercial register 08183075 0000 Company domiciled in Waalwijk Managing Directors : Alexandra Hellemans, Jens Wiegand, Jorn Bagijn The information in this email is confidential. It is intended solely for the addressee. If you are not the intended recipient, please let me know and delete this email. diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index 0011b15e678c..c78d0c2a5341 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -69,6 +69,7 @@ #define IGB_NBITS_82580 40 static void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter); +static void igb_ptp_sdp_init(struct igb_adapter *adapter); /* SYSTIM read access for the 82576 */ static u64 igb_ptp_read_82576(const struct cyclecounter *cc) @@ -1192,7 +1193,6 @@ void igb_ptp_init(struct igb_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; - int i; switch (hw->mac.type) { case e1000_82576: @@ -1233,13 +1233,7 @@ void igb_ptp_init(struct igb_adapter *adapter) break; case e1000_i210: case e1000_i211: - for (i = 0; i < IGB_N_SDP; i++) { - struct ptp_pin_desc *ppd = &adapter->sdp_config[i]; - - snprintf(ppd->name, sizeof(ppd->name), "SDP%d", i); - ppd->index = i; - ppd->func = PTP_PF_NONE; - } + igb_ptp_sdp_init(adapter); snprintf(adapter->ptp_caps.name, 16, "%pm", netdev->dev_addr); adapter->ptp_caps.owner = THIS_MODULE; adapter->ptp_caps.max_adj = 62499999; @@ -1284,6 +1278,23 @@ void igb_ptp_init(struct igb_adapter *adapter) } } +/** + * igb_ptp_sdp_init - utility function which inits the SDP config structs + * @adapter: Board private structure. + **/ +void igb_ptp_sdp_init(struct igb_adapter *adapter) +{ + int i; + + for (i = 0; i < IGB_N_SDP; i++) { + struct ptp_pin_desc *ppd = &adapter->sdp_config[i]; + + snprintf(ppd->name, sizeof(ppd->name), "SDP%d", i); + ppd->index = i; + ppd->func = PTP_PF_NONE; + } +} + /** * igb_ptp_suspend - Disable PTP work items and prepare for suspend * @adapter: Board private structure From patchwork Mon Jul 19 11:33:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruud Bos X-Patchwork-Id: 482091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3FC8C07E9B for ; Mon, 19 Jul 2021 11:33:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A009B60FF3 for ; Mon, 19 Jul 2021 11:33:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236339AbhGSKws (ORCPT ); Mon, 19 Jul 2021 06:52:48 -0400 Received: from mail-eopbgr70131.outbound.protection.outlook.com ([40.107.7.131]:52133 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236487AbhGSKwq (ORCPT ); Mon, 19 Jul 2021 06:52:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oF9V3PcaG1+82lD6cHuj8/XH9vKKrFillti6X41ReexueuSaezG7/LutAjfL17dLqsbXsOVsvBzJk5SthqpTAlzt7abEvEDJQF8Kg3tTnYKRc7ZpQpeILGwxd/0OWGpPSNVfiidlEbqV4bHQgtHsBu5voP5KGq7vLon8HhKnY6rUYNBJtaBsEMN/Nxtxx9/MhySpGliTbInjKKMx7VXpndd5snmsgEHPvUzHNKwxDnK16dL6/bDjRSIY1bq30tqeGedKYgQNjAnildQ/l+yaHlJXm0hzW4nKBmaOHt3bi2aqSOOrW4WD1lMpWe9/9UEsznBymA/BNw4/CqKp1n9GOg== 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-SenderADCheck; bh=xVx49oXx8ozh5Ie97HOTLJgsHOOGeX/cdF9taFRmLrQ=; b=ACyWkCFXgI70Nl0JU6i1siSYBXhi54oab1GbdLlWfYrrvFvlpQG+es9kFamU+CUV1KTaTyE6bZrnR/eVFZ63bqiqKr4swU2lTkgC6an6AhEY87XS12kUWYKJUP4E62RhXWHvtbWvovu3lUJ3rfJMh5CvdWvVFWlIc5noRY8Uscv8L30IO4wWF6dAkwIAlRAmXNp9xcOT6ZEwftKQEvfOPlP4BBdfEtAJzobK//+QJL1hVKIird0f73zZmueoBXSEktgbbnGrw5WWsa0jGX5Tcv/ZJEYar16kb3YK3NgXhzbsFJEGFtHFtwX30PbRu8v7hEhqNQqve2XqGqUmGQoHaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hbkworld.com; dmarc=pass action=none header.from=hbkworld.com; dkim=pass header.d=hbkworld.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hbkworld.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xVx49oXx8ozh5Ie97HOTLJgsHOOGeX/cdF9taFRmLrQ=; b=BmJk7i7cgQ5DoRFcvUTzR+AGx+vXlNW8dCNXA69DWHWweq7OcGXYdzsN3k1jcgX3Gj7hASKjTt4keBGhERomemiY7Si956vNibpPpBK651lUJRJCLtXEucejM+ZDb3TOlcQwfYrQl7QqdUxCTdu/MCaz05uscL768VUd1Td46Mplz4sZpeiVOW4YiE3BtptckbNQ2d7LEYLNhbZBMSyt7uDwV3ll3TTAhG0fZg98HlZZI3tq//p11a6fL0LLaSG/QqP04VXScdvLfcnCsSMn3uX9cqxggsBSAKCPWO/sY5Hu0LgCQ5EIwDtUidUKuq61KWW/wUF0T3C4/Y70sgF+Eg== Received: from AM0PR09MB4276.eurprd09.prod.outlook.com (2603:10a6:20b:166::10) by AM8PR09MB5228.eurprd09.prod.outlook.com (2603:10a6:20b:3db::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Mon, 19 Jul 2021 11:33:24 +0000 Received: from AM0PR09MB4276.eurprd09.prod.outlook.com ([fe80::4d88:bf9c:b655:7a92]) by AM0PR09MB4276.eurprd09.prod.outlook.com ([fe80::4d88:bf9c:b655:7a92%7]) with mapi id 15.20.4331.032; Mon, 19 Jul 2021 11:33:24 +0000 From: Ruud Bos To: "netdev@vger.kernel.org" CC: "davem@davemloft.net" , "kuba@kernel.org" , "jesse.brandeburg@intel.com" , "anthony.l.nguyen@intel.com" Subject: [PATCH net-next 2/4 resend] igb: move PEROUT and EXTTS isr logic to separate functions Thread-Topic: [PATCH net-next 2/4 resend] igb: move PEROUT and EXTTS isr logic to separate functions Thread-Index: Add8kIuHE38TOLc3RwW+20k2b8PMBw== Date: Mon, 19 Jul 2021 11:33:24 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Enabled=true; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_SetDate=2021-07-19T11:33:23Z; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Method=Privileged; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Name=Unrestricted; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_SiteId=6cce74a3-3975-45e0-9893-b072988b30b6; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_ActionId=a45ba5d9-1ea5-455c-adae-95f5d990e4c7; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_ContentBits=2 authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=hbkworld.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: df9bc2d7-6cff-4d64-a73d-08d94aa90531 x-ms-traffictypediagnostic: AM8PR09MB5228: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qvcgO5fBFvyyPAHqr8J9KoPODjkUonXNrzyMztX5uHlBA1T5IddqL4547La52zoEQrELqiwQapjsbQBhofZ/RWpO2a0T3CPJbaReL8vk1NH+VG3dJBn3L5VhV1zgi+54fd5FgNkWYw9Lcu1RznWGI/pEB6kI6tWgQKBmNy2S8aMzb/9cqhtEkBbBR5zIhnxcvxLuVdc8NcBZCeCIBK4KoIJt3cMbrtf8YAgDlDMzhUPt11b4LEluBz3Rq7qePMTRXI8AmdEJhS28zqsgOm0r1yql6nnOMiEvKHR64KGr7+J3aL4mVw7jsW74SldzrYP3PoDQi0z4KP5n3kwW37U7hVZK7XH9g8FWbYHKbti0GH1DKdkbkkHlbfx0wYL78TVqZlDBxSd553wKiwvwpjJRudqIpmTINiEpcCuPEWz0/qEX2Oh0PSfpebq2GCdSRON6BkeyR6PKUBHbwXSYFTlHu4TvgXQuoOh3sRfQzAjZFf8RMF9rZ5vV+DX9HuT2ZgSrzspwQC0bPB8rIwcHYelLk+k+fZR+GHtqPQ3gyeaOJdoBMxEKfI4DwwumgL3+BwctgrFvFpo5xjwlSyCWPJwkYeZ8kk7yxN8D8aqoHSBT2AS+iv2QPCKV4Y+UK+HZNf8BmzDQiBUYffrf7i+dB70/S8TpwvSbgwGq7/UGBOwJXuegdontDpD4tqiucALvOFxtD0/WrIawUPu3zRZSaLTU2Q== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR09MB4276.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(366004)(136003)(396003)(346002)(376002)(8936002)(8676002)(5660300002)(6916009)(55016002)(33656002)(52536014)(83380400001)(38100700002)(2906002)(44832011)(122000001)(26005)(9686003)(54906003)(86362001)(186003)(15974865002)(66446008)(64756008)(66556008)(66476007)(4326008)(316002)(71200400001)(66946007)(478600001)(76116006)(7696005)(6506007)(38070700004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?tBZeGAZphWSwVgilbudQ8e5j7?= =?utf-8?q?Tc00SxcJSB2DAYD+7r9IlRIepQjZ01KvNKOFLd97EoEq2BVjdc5WQPh7?= =?utf-8?q?8N494+oRzfpuggLbQ1H6CKddVNAfTlIDrP9UlBD6LNAOGp0VUGB5hb+W?= =?utf-8?q?AVfLnh8UmhFbbVI77bDqJl7E6h8MQROWgcokLsUVOY6WNaDX1grtQP7z?= =?utf-8?q?xT48y9uOr6nMT49T1i4qQ0hsohxmJlM/tVavlzUvEFfvEZA2DwuOAPKf?= =?utf-8?q?nxW5kplMlUx3ry0O84HprKpGkpVFodkrYwtXDuvz9vae5/6PkvgTUrBb?= =?utf-8?q?tREduWnetQ6v731n63ylAydkdlMHEsZ5zvZfyo5Shq5Twrtj7CY6Pahb?= =?utf-8?q?jX5bisu07VsS1P/AMuzC6d5dk0/82AR3iByzC3ZzX8XPlZ9ieGJRImOE?= =?utf-8?q?i5NOL4iXkuq493ZOn0cWhqkO+bDBwHtDnHzW2/55dEkmmVftD7n9WoCD?= =?utf-8?q?FYr918S9Dxywpw8ukl+2gxw2lZXAnaPJKpecHik3xfbXSEKcSd8LnNVN?= =?utf-8?q?EhruAPJG/iMiobA2WyAjfrWbacWIHc0sSS8no3AgtPYICRm/xp9saa24?= =?utf-8?q?Lo+4VotaHFEikyMj3WSnU40JX1Z9pkUngIF4o9LHhu+Oj3sh4RWgHoP1?= =?utf-8?q?kGuORD796wUtLCU+NPqgTnPIvmQx7lBcgOBbdVpNAs7Dh5hjMidwQ+EB?= =?utf-8?q?aOJkFBp9GJ+ghAcKS1sQAdgI1A0lyvnSqzaSQ2DkkDznONCGR065DPH/?= =?utf-8?q?6QMy3meMvr5Ry1NqzNvjA1BXup5FllIQZJFO08TXXgNOYS06qOKgwW+c?= =?utf-8?q?2HCBnLQ4+kL8RhFshuNdJav7Wx3k0HDtNBGyC4TpzFMMaUnYs89fMCYI?= =?utf-8?q?vxpQZW2ZxET/MK7T/iWSM1HiXdLOsZq8QpMNdlP6oqOfmdlNUSDtz5pP?= =?utf-8?q?XBKRwWAC6hTpgMiGVdDoRiDkop6BWqdkvykt8F3fP387/RovahiE+I0K?= =?utf-8?q?uJ1cTrxCtpuPPGVoDpEuYYGfEnw5llRQyl4a3rHS0u+5NE85ttSq5Ofz?= =?utf-8?q?uDrX5PK1lSqpw7QAUIwied0tSjyEjH4/i1YWczMB5QDncEUlUjqUPTyV?= =?utf-8?q?2nhX345NwEjUU08LWXszhykYDX8x+Q9benIeV5U3vaPf1VBajyohAleh?= =?utf-8?q?aWCFNpC8fh2IRrvVYD4ke13Y4p6dS3Q3KqY0BRxf9P+7lMKmx+M5BQxC?= =?utf-8?q?Za7owdHQbqwB0U7bpX5UzBiDj9k4SvUBAIFo2TxMtFMiljewcC0BR0HR?= =?utf-8?q?o2CrkZq/9kEpkhCxpMe1gfTLfd653EIHKp6pylzUvICj7si9uYhwVbYO?= =?utf-8?q?PV3HYyG4nM=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: hbkworld.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM0PR09MB4276.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: df9bc2d7-6cff-4d64-a73d-08d94aa90531 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2021 11:33:24.6176 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6cce74a3-3975-45e0-9893-b072988b30b6 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uhkkg67Urnxh1vxVl43tq5wdyTZyeNH0zLFDDaMmVK0B1fmk5ZAUtA9Z7oOrvlj8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR09MB5228 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Remove code duplication in the tsync interrupt handler function by moving this logic to separate functions. This keeps the interrupt handler readable and allows the new functions to be extended for adapter types other than i210. Signed-off-by: Ruud Bos --- drivers/net/ethernet/intel/igb/igb_main.c | 79 +++++++++++++---------- 1 file changed, 44 insertions(+), 35 deletions(-) -- 2.30.2 UNRESTRICTED HBK Benelux B.V., Schutweg 15a, NL-5145 NP Waalwijk, The Netherlands www.hbkworld.com Registered as B.V. (Dutch limited liability company) in the Dutch commercial register 08183075 0000 Company domiciled in Waalwijk Managing Directors : Alexandra Hellemans, Jens Wiegand, Jorn Bagijn The information in this email is confidential. It is intended solely for the addressee. If you are not the intended recipient, please let me know and delete this email. diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 7e6435dc7e80..928ac9ba1c66 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -6721,12 +6721,50 @@ void igb_update_stats(struct igb_adapter *adapter) } } +static void igb_perout(struct igb_adapter *adapter, int sdp) +{ + struct e1000_hw *hw = &adapter->hw; + struct timespec64 ts; + u32 tsauxc; + + if (sdp < 0 || sdp >= IGB_N_PEROUT) + return; + + spin_lock(&adapter->tmreg_lock); + ts = timespec64_add(adapter->perout[sdp].start, + adapter->perout[sdp].period); + /* u32 conversion of tv_sec is safe until y2106 */ + wr32((sdp == 1) ? E1000_TRGTTIML1 : E1000_TRGTTIML0, ts.tv_nsec); + wr32((sdp == 1) ? E1000_TRGTTIMH1 : E1000_TRGTTIMH0, (u32)ts.tv_sec); + tsauxc = rd32(E1000_TSAUXC); + tsauxc |= TSAUXC_EN_TT0; + wr32(E1000_TSAUXC, tsauxc); + adapter->perout[sdp].start = ts; + spin_unlock(&adapter->tmreg_lock); +} + +static void igb_extts(struct igb_adapter *adapter, int sdp) +{ + struct e1000_hw *hw = &adapter->hw; + u32 sec, nsec; + struct ptp_clock_event event; + + if (sdp < 0 || sdp >= IGB_N_EXTTS) + return; + + nsec = rd32((sdp == 1) ? E1000_AUXSTMPL1 : E1000_AUXSTMPL0); + sec = rd32((sdp == 1) ? E1000_AUXSTMPH1 : E1000_AUXSTMPH0); + event.type = PTP_CLOCK_EXTTS; + event.index = sdp; + event.timestamp = sec * 1000000000ULL + nsec; + ptp_clock_event(adapter->ptp_clock, &event); +} + static void igb_tsync_interrupt(struct igb_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct ptp_clock_event event; - struct timespec64 ts; - u32 ack = 0, tsauxc, sec, nsec, tsicr = rd32(E1000_TSICR); + u32 ack = 0, tsicr = rd32(E1000_TSICR); if (tsicr & TSINTR_SYS_WRAP) { event.type = PTP_CLOCK_PPS; @@ -6742,51 +6780,22 @@ static void igb_tsync_interrupt(struct igb_adapter *adapter) } if (tsicr & TSINTR_TT0) { - spin_lock(&adapter->tmreg_lock); - ts = timespec64_add(adapter->perout[0].start, - adapter->perout[0].period); - /* u32 conversion of tv_sec is safe until y2106 */ - wr32(E1000_TRGTTIML0, ts.tv_nsec); - wr32(E1000_TRGTTIMH0, (u32)ts.tv_sec); - tsauxc = rd32(E1000_TSAUXC); - tsauxc |= TSAUXC_EN_TT0; - wr32(E1000_TSAUXC, tsauxc); - adapter->perout[0].start = ts; - spin_unlock(&adapter->tmreg_lock); + igb_perout(adapter, 0); ack |= TSINTR_TT0; } if (tsicr & TSINTR_TT1) { - spin_lock(&adapter->tmreg_lock); - ts = timespec64_add(adapter->perout[1].start, - adapter->perout[1].period); - wr32(E1000_TRGTTIML1, ts.tv_nsec); - wr32(E1000_TRGTTIMH1, (u32)ts.tv_sec); - tsauxc = rd32(E1000_TSAUXC); - tsauxc |= TSAUXC_EN_TT1; - wr32(E1000_TSAUXC, tsauxc); - adapter->perout[1].start = ts; - spin_unlock(&adapter->tmreg_lock); + igb_perout(adapter, 1); ack |= TSINTR_TT1; } if (tsicr & TSINTR_AUTT0) { - nsec = rd32(E1000_AUXSTMPL0); - sec = rd32(E1000_AUXSTMPH0); - event.type = PTP_CLOCK_EXTTS; - event.index = 0; - event.timestamp = sec * 1000000000ULL + nsec; - ptp_clock_event(adapter->ptp_clock, &event); + igb_extts(adapter, 0); ack |= TSINTR_AUTT0; } if (tsicr & TSINTR_AUTT1) { - nsec = rd32(E1000_AUXSTMPL1); - sec = rd32(E1000_AUXSTMPH1); - event.type = PTP_CLOCK_EXTTS; - event.index = 1; - event.timestamp = sec * 1000000000ULL + nsec; - ptp_clock_event(adapter->ptp_clock, &event); + igb_extts(adapter, 1); ack |= TSINTR_AUTT1; } From patchwork Mon Jul 19 11:33:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruud Bos X-Patchwork-Id: 480322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB17EC07E9B for ; Mon, 19 Jul 2021 11:33:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1F95610C7 for ; Mon, 19 Jul 2021 11:33:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236565AbhGSKww (ORCPT ); Mon, 19 Jul 2021 06:52:52 -0400 Received: from mail-eopbgr70139.outbound.protection.outlook.com ([40.107.7.139]:6885 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232156AbhGSKwu (ORCPT ); Mon, 19 Jul 2021 06:52:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VApSgfQ/eOhSql3PJPiLtG5VeKRalutq4pTo/+4zpippCzf24hLqI74uMXFd/o6iv9/OAKa9HsQBSnIuL7cWjp4nexNo2d1SdXM9WefsD5vzfT9OjcwNyKf5bSCdSgHEFCqCE52OuVZAsNVR4qKMCZFHWkXrUTna51+lCrwudaEcW9U/Dmfx1QxcSrCHiGBBPq+2B/OePv2gEr/2NUOQ3u2o+DwKPysAGm87hI+lKVhsq/nENDDoDKr0nPJCd238sp8QvqlqsusY4SwshxUcfo2YqU0NVdjY84BL7Aa1cgA5Nynd+1K7YSReYCEycdcVaVWZTIQvuuHdi1brtDxUIA== 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-SenderADCheck; bh=nPlZDvKhE4RraMfAtX7WizVBoBE/gFSrrYogCOBS6W0=; b=V9fMckpRVJR88r4z2r7Tmg7h1GB8AyINFsX1jwpa/gCiq1V8OLVY57zJ82WCrEVp4XdSZaZFm3DBfM/xCxzgirr34L5/GaRNf3NRXPte1oHRYP95pRtMN+Pl6j9kVIfWTSjR3CQSTulx6ZFC2QT9yXOXGKVfCDrB4swHmG83YOMy5Mq7K37D/Odtka6RsWdkmsvSC7vYUpgPQHRG7EsfyokR4sluMxWPBLI59YuVeT9DSP0hoeRaONcgqEDOR+m0VlAK+sl7Bhkc8P26v4cJvsXiFMpk7hYTxKrZL24bkHQLzI8hMxTcn2jung98bkuNDx1yo5PJoIlyKTiMT4SMbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hbkworld.com; dmarc=pass action=none header.from=hbkworld.com; dkim=pass header.d=hbkworld.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hbkworld.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nPlZDvKhE4RraMfAtX7WizVBoBE/gFSrrYogCOBS6W0=; b=bYZc8RPuM+1/p8Cy0jwYSYbGz90Z6Q79YxdqjhTj5btgm8oLIjXVzf4qP60l5rJB7QA/F+OXDlCLOw2MQ81DzMqBexj8GdMRleBms0HO/kpnCDeJ4pSpohWgxTOwrmZVS0Vpy+EVWJ52RueJEV3I5SdywbEmgJh+eIgiKAON+2PD9Hh+YCBvApLfUjNk5kWAqRM9DDP+1vzVMxSPCRxWbYvR6hA+6pd8Uarjt/iBNUakBhQCdVIes1/jHfF9RBAN/mnkcfucjI9y+sSrhg7Sftjzgy6WmSyTMqXvsysc/U1p7ehjgtRBFzi2EUMdHuNNo0Gpzeqw4OtSy7JVlsxkGQ== Received: from AM0PR09MB4276.eurprd09.prod.outlook.com (2603:10a6:20b:166::10) by AM8PR09MB5228.eurprd09.prod.outlook.com (2603:10a6:20b:3db::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Mon, 19 Jul 2021 11:33:29 +0000 Received: from AM0PR09MB4276.eurprd09.prod.outlook.com ([fe80::4d88:bf9c:b655:7a92]) by AM0PR09MB4276.eurprd09.prod.outlook.com ([fe80::4d88:bf9c:b655:7a92%7]) with mapi id 15.20.4331.032; Mon, 19 Jul 2021 11:33:29 +0000 From: Ruud Bos To: "netdev@vger.kernel.org" CC: "davem@davemloft.net" , "kuba@kernel.org" , "jesse.brandeburg@intel.com" , "anthony.l.nguyen@intel.com" Subject: [PATCH net-next 3/4 resend] igb: support PEROUT on 82580/i354/i350 Thread-Topic: [PATCH net-next 3/4 resend] igb: support PEROUT on 82580/i354/i350 Thread-Index: Add8kRi1xbauaCRJT4ayU1H8dQbl3w== Date: Mon, 19 Jul 2021 11:33:28 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Enabled=true; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_SetDate=2021-07-19T11:33:27Z; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Method=Privileged; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Name=Unrestricted; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_SiteId=6cce74a3-3975-45e0-9893-b072988b30b6; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_ActionId=c4f117e0-4206-4bd0-8874-c276b9c9b7e3; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_ContentBits=2 authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=hbkworld.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 16c20adc-4e9b-422d-b7bb-08d94aa907ce x-ms-traffictypediagnostic: AM8PR09MB5228: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:883; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: RR87MWxstV6yLRLXJgUspIoHy3BBzjezmfpspxvbyKvHNwcpPMdX3d4MsBNUyX0/qVmnuU0EklBOW3CG0lA+vRRVI1hIO7BkeXgvV5Aon+6IM4SIE5QkZ6lZ+TTOcnkf12fo9lnb09l+TZhyZyfUkV7DqKPaLC1Ryxw/SHwhykkleYrACfWUDgtytxLcyUIenRxGrrEmt91dij/gL9G6eoKOisqu5rKxEldmZOVu/m4ZMCFwGr9J0wwazU4hFzxByf68Zo/ci4iSPiY/+grQ3cw+XyGDLYo83GXUyrJzfa7siEr57/z9OU4uanqRUHIhdE7inTV4HZjqmSCzPgYrFvJY/eFcdM5wsqwP8WdvVSzzILB97uGojqMJ2eQolSzIS3SnhSVh4toP4YzuPA157kOgV3yO4UhIEJZ8N2fYEscCxmNr89L5KIG8P2YUrjRlgeYWqEeXMNRk+iVeAdmpXIiKbkgyQ/bGKCswsH6NeZaF3za4/fDpYEHYhy7bCBO1PfOb5tNkxLBz+CT/1gGmMZ/th/BH37ofoGEAG4P1+rpKtS/NknNVXa+lMG30+HgoRRQpctmkFRAfMiDfNDthlO+l01mTNejtrRf23loUrbMxVi9J059LeD4R2rG2Ph17dIaip5dT2huyxyng6YaFDr8r3QEbUyaSeRR5zEwvTGLLMAOUhZfbcuCg2HBWFqxVuhd3pFV7C4YrWfmfRQAEHA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR09MB4276.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(366004)(136003)(396003)(346002)(376002)(8936002)(8676002)(5660300002)(6916009)(55016002)(33656002)(52536014)(83380400001)(38100700002)(2906002)(44832011)(122000001)(26005)(9686003)(54906003)(86362001)(186003)(15974865002)(66446008)(64756008)(66556008)(66476007)(4326008)(316002)(71200400001)(66946007)(478600001)(76116006)(7696005)(6506007)(38070700004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?fCe4ARSVPrLabQgemBJkDoyva?= =?utf-8?q?YBwq9gUGefZcRovl7nTp+HikqKWuz6TbC50Ru0rzsJdIf5qlTqQbtthD?= =?utf-8?q?UXXTQsJsCktJ3R7aJwTGt1FV5yIHPmQaHa7E/yl/yB98t/WQwJhFT238?= =?utf-8?q?kVZsfsAPJqwz0wkkhKHpDutuFsZehHgG/WHY7MJkud91oeau91GzgVUI?= =?utf-8?q?0ciAHKXCZSnk9ikjTzbooZVw89qTNoigR1tmm7BxJO7hfuByzNvwvijA?= =?utf-8?q?kYIQFhXoWmXrhq/LxsUWT8+H8r5DmhMIpiL2cjhNRtDSbym/Besr1dL8?= =?utf-8?q?fydN5ygHuTGLN4eShoGRbuKmk0zmmvlfGEHkWxOKgz06TXRu3K8L5kxJ?= =?utf-8?q?ArYCSca1S2of49u/tRYTl+YoLwHAsFp4XlS6wIBKSys9nt2DTYrmSSnW?= =?utf-8?q?ps+EWyjHHtEU1B5SJOd4X4O7Hj3ZF52DyphMem+26PhfWMacYE9nUi8t?= =?utf-8?q?BRx0xqPbfiSOnKrjs8CJto32liG1vJtY2PrZACx/NdxdwXiez4I7xdSa?= =?utf-8?q?B6+jz+0PS1TYMPj91HamjqTiD/ra8cei/j/XW6Ch/sSQYU+kKheQifBp?= =?utf-8?q?HvP0v37a9ErAH0QCrE0z9KTJNUNXlxsmQSnjeD3HPJicyhHXsBPpXz+M?= =?utf-8?q?fy5nY4T/WsBG9RX4g7Z7nGri9D3GjwRT+/3YLxPWIlLwHHiSWNCp3uoi?= =?utf-8?q?EgVyycKEo0DeEY2pXGYSh4CeUfMp5NOjc20VlKITwbshovrzHhGMcaru?= =?utf-8?q?y18qEdGYidDeBNIh+qwJgRcn3UxMUrBPqfVk1zIpMDE5UaTmLOJMiJWv?= =?utf-8?q?ToI2Ul8izxkhBrrUCL1CSrFmJgTzNRTspDoauSrIBoJck5495ZcHGHbV?= =?utf-8?q?kmaNPHvjrnuL2PmTefkW5Fb/lUr8Jr/gROz4SzcDHtI8z4RcDHDC7tFY?= =?utf-8?q?vEei34n58oOz0qJA9BuTwoM9t3vC/dbVdsghpBV6i+ome67WTD29C4Mt?= =?utf-8?q?+x6LExR87Cjen3Aemkskr/kOw3i2fmjwdrQr3ya2w9vsl/Yo3sz86QCv?= =?utf-8?q?YEHlrUxrUQhYtYFAYEwNC26EOEfoVZ4UHQjA7G70EzFAlxTP3SuTwbUW?= =?utf-8?q?3eNmnn8xiYmZXlvxh+jXihkb9eAVZSNw/qEX69TPO1fyRK4SqpLuTxJ3?= =?utf-8?q?fFjvmFCML5g2TGlBGgBswp+3UNfk+PN4Y7/fFbQA02OYJYUssdXl53Qt?= =?utf-8?q?8z7ogKkYxW2/HkkRkjRWnXTLB+T9xRx8RdgL4zDLr95jX3jxOaKUTZuW?= =?utf-8?q?o1oiudRg1nNcDwPArsq4oB3KK8tnbyKHT2PdxbfyA/6RV7iqjbj+NeFD?= =?utf-8?q?cIOaWGWH1Q=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: hbkworld.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM0PR09MB4276.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16c20adc-4e9b-422d-b7bb-08d94aa907ce X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2021 11:33:28.9098 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6cce74a3-3975-45e0-9893-b072988b30b6 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: SWay+BNSEavygFw25WLsU3YBc3ZB1qsjpz6/BON8hKdoGTq9Mgn+QVVT1GIfz1Mv X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR09MB5228 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Support for the PEROUT PTP pin function on 82580/i354/i350 based adapters. Because the time registers of these adapters do not have the nice split in second rollovers as the i210 has, the implementation is slightly more complex compared to the i210 implementation. Signed-off-by: Ruud Bos --- drivers/net/ethernet/intel/igb/igb_main.c | 54 +++++++++- drivers/net/ethernet/intel/igb/igb_ptp.c | 122 +++++++++++++++++++++- 2 files changed, 172 insertions(+), 4 deletions(-) -- 2.30.2 UNRESTRICTED HBK Benelux B.V., Schutweg 15a, NL-5145 NP Waalwijk, The Netherlands www.hbkworld.com Registered as B.V. (Dutch limited liability company) in the Dutch commercial register 08183075 0000 Company domiciled in Waalwijk Managing Directors : Alexandra Hellemans, Jens Wiegand, Jorn Bagijn The information in this email is confidential. It is intended solely for the addressee. If you are not the intended recipient, please let me know and delete this email. diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 928ac9ba1c66..8d87166e5ecb 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -6731,8 +6731,57 @@ static void igb_perout(struct igb_adapter *adapter, int sdp) return; spin_lock(&adapter->tmreg_lock); - ts = timespec64_add(adapter->perout[sdp].start, - adapter->perout[sdp].period); + + if ((hw->mac.type == e1000_82580) || + (hw->mac.type == e1000_i354) || + (hw->mac.type == e1000_i350)) { + u32 systiml, systimh, level_mask, level, rem; + u64 systim, now; + s64 ns = timespec64_to_ns(&adapter->perout[sdp].period); + + /* read systim registers in sequence */ + rd32(E1000_SYSTIMR); + systiml = rd32(E1000_SYSTIML); + systimh = rd32(E1000_SYSTIMH); + systim = (((u64)(systimh & 0xFF)) << 32) | ((u64)systiml); + now = timecounter_cyc2time(&adapter->tc, systim); + + level_mask = (sdp == 1) ? 0x80000 : 0x40000; + level = (rd32(E1000_CTRL) & level_mask) ? 1 : 0; + + div_u64_rem(now, ns, &rem); + systim = systim + (ns - rem); + + /* synchronize pin level with rising/falling edges */ + div_u64_rem(now, ns << 1, &rem); + if (rem < ns) { + /* first half of period */ + if (level == 0) { + /* output is already low, skip this period */ + systim += ns; + pr_notice("igb: periodic output on %s missed falling edge\n", + adapter->sdp_config[sdp].name); + } + } else { + /* second half of period */ + if (level == 1) { + /* output is already high, skip this period */ + systim += ns; + pr_notice("igb: periodic output on %s missed rising edge\n", + adapter->sdp_config[sdp].name); + } + } + + /* for this chip family tv_sec is the upper part of the binary value, + * so not seconds + */ + ts.tv_nsec = (u32)systim; + ts.tv_sec = ((u32)(systim >> 32)) & 0xFF; + } else { + ts = timespec64_add(adapter->perout[sdp].start, + adapter->perout[sdp].period); + } + /* u32 conversion of tv_sec is safe until y2106 */ wr32((sdp == 1) ? E1000_TRGTTIML1 : E1000_TRGTTIML0, ts.tv_nsec); wr32((sdp == 1) ? E1000_TRGTTIMH1 : E1000_TRGTTIMH0, (u32)ts.tv_sec); @@ -6740,6 +6789,7 @@ static void igb_perout(struct igb_adapter *adapter, int sdp) tsauxc |= TSAUXC_EN_TT0; wr32(E1000_TSAUXC, tsauxc); adapter->perout[sdp].start = ts; + spin_unlock(&adapter->tmreg_lock); } diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index c78d0c2a5341..64a949bb5d8a 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -508,6 +508,119 @@ static void igb_pin_perout(struct igb_adapter *igb, int chan, int pin, int freq) wr32(E1000_CTRL_EXT, ctrl_ext); } +static int igb_ptp_feature_enable_82580(struct ptp_clock_info *ptp, + struct ptp_clock_request *rq, int on) +{ + struct igb_adapter *igb = + container_of(ptp, struct igb_adapter, ptp_caps); + struct e1000_hw *hw = &igb->hw; + u32 tsauxc, tsim, tsauxc_mask, tsim_mask, trgttiml, trgttimh, systiml, + systimh, level_mask, level, rem; + unsigned long flags; + struct timespec64 ts, start; + int pin = -1; + s64 ns; + u64 systim, now; + + switch (rq->type) { + case PTP_CLK_REQ_EXTTS: + return -EOPNOTSUPP; + + case PTP_CLK_REQ_PEROUT: + /* Reject requests with unsupported flags */ + if (rq->perout.flags) + return -EOPNOTSUPP; + + if (on) { + pin = ptp_find_pin(igb->ptp_clock, PTP_PF_PEROUT, + rq->perout.index); + if (pin < 0) + return -EBUSY; + } + ts.tv_sec = rq->perout.period.sec; + ts.tv_nsec = rq->perout.period.nsec; + ns = timespec64_to_ns(&ts); + ns = ns >> 1; + if (on && (ns < 8LL)) + return -EINVAL; + ts = ns_to_timespec64(ns); + if (rq->perout.index == 1) { + tsauxc_mask = TSAUXC_EN_TT1; + tsim_mask = TSINTR_TT1; + trgttiml = E1000_TRGTTIML1; + trgttimh = E1000_TRGTTIMH1; + } else { + tsauxc_mask = TSAUXC_EN_TT0; + tsim_mask = TSINTR_TT0; + trgttiml = E1000_TRGTTIML0; + trgttimh = E1000_TRGTTIMH0; + } + spin_lock_irqsave(&igb->tmreg_lock, flags); + tsauxc = rd32(E1000_TSAUXC); + tsim = rd32(E1000_TSIM); + if (rq->perout.index == 1) { + tsauxc &= ~(TSAUXC_EN_TT1 | TSAUXC_EN_CLK1 | TSAUXC_ST1); + tsim &= ~TSINTR_TT1; + } else { + tsauxc &= ~(TSAUXC_EN_TT0 | TSAUXC_EN_CLK0 | TSAUXC_ST0); + tsim &= ~TSINTR_TT0; + } + if (on) { + int i = rq->perout.index; + + /* read systim registers in sequence */ + rd32(E1000_SYSTIMR); + systiml = rd32(E1000_SYSTIML); + systimh = rd32(E1000_SYSTIMH); + systim = (((u64)(systimh & 0xFF)) << 32) | ((u64)systiml); + now = timecounter_cyc2time(&igb->tc, systim); + + level_mask = (pin == 1) ? 0x80000 : 0x40000; + level = (rd32(E1000_CTRL) & level_mask) ? 1 : 0; + + div_u64_rem(now, ns, &rem); + systim = systim + (ns - rem); + + /* synchronize pin level with rising/falling edges */ + div_u64_rem(now, ns << 1, &rem); + if (rem < ns) { + /* first half of period */ + if (level == 0) { + /* output is already low, skip this period */ + systim += ns; + } + } else { + /* second half of period */ + if (level == 1) { + /* output is already high, skip this period */ + systim += ns; + } + } + + start = ns_to_timespec64(systim + (ns - rem)); + igb_pin_perout(igb, i, pin, 0); + igb->perout[i].start.tv_sec = start.tv_sec; + igb->perout[i].start.tv_nsec = start.tv_nsec; + igb->perout[i].period.tv_sec = ts.tv_sec; + igb->perout[i].period.tv_nsec = ts.tv_nsec; + + wr32(trgttiml, (u32)systim); + wr32(trgttimh, ((u32)(systim >> 32)) & 0xFF); + tsauxc |= tsauxc_mask; + tsim |= tsim_mask; + } + wr32(E1000_TSAUXC, tsauxc); + wr32(E1000_TSIM, tsim); + spin_unlock_irqrestore(&igb->tmreg_lock, flags); + return 0; + + case PTP_CLK_REQ_PPS: + return -EOPNOTSUPP; + } + + return -EOPNOTSUPP; +} + static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp, struct ptp_clock_request *rq, int on) { @@ -1215,16 +1328,21 @@ void igb_ptp_init(struct igb_adapter *adapter) case e1000_82580: case e1000_i354: case e1000_i350: + igb_ptp_sdp_init(adapter); snprintf(adapter->ptp_caps.name, 16, "%pm", netdev->dev_addr); adapter->ptp_caps.owner = THIS_MODULE; adapter->ptp_caps.max_adj = 62499999; - adapter->ptp_caps.n_ext_ts = 0; + adapter->ptp_caps.n_ext_ts = IGB_N_EXTTS; + adapter->ptp_caps.n_per_out = IGB_N_PEROUT; + adapter->ptp_caps.n_pins = IGB_N_SDP; adapter->ptp_caps.pps = 0; + adapter->ptp_caps.pin_config = adapter->sdp_config; adapter->ptp_caps.adjfine = igb_ptp_adjfine_82580; adapter->ptp_caps.adjtime = igb_ptp_adjtime_82576; adapter->ptp_caps.gettimex64 = igb_ptp_gettimex_82580; adapter->ptp_caps.settime64 = igb_ptp_settime_82576; - adapter->ptp_caps.enable = igb_ptp_feature_enable; + adapter->ptp_caps.enable = igb_ptp_feature_enable_82580; + adapter->ptp_caps.verify = igb_ptp_verify_pin; adapter->cc.read = igb_ptp_read_82580; adapter->cc.mask = CYCLECOUNTER_MASK(IGB_NBITS_82580); adapter->cc.mult = 1; From patchwork Mon Jul 19 11:33:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruud Bos X-Patchwork-Id: 482090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99FA4C07E9D for ; Mon, 19 Jul 2021 11:33:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7837A60698 for ; Mon, 19 Jul 2021 11:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236590AbhGSKxB (ORCPT ); Mon, 19 Jul 2021 06:53:01 -0400 Received: from mail-eopbgr70123.outbound.protection.outlook.com ([40.107.7.123]:6422 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236567AbhGSKwz (ORCPT ); Mon, 19 Jul 2021 06:52:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YG32rV0u2dbn86jr/8dWsQdyYwtt3iwQHnCX9m90PLQDaWCGOqSqn6WOaqKdCSU97TwljmPkvn/GahX74PMLhgHEKI1tBWBYtnbfZDTiY5tIKCxbS6Vfg2rL/Y5gmaF/ejeT26bPCCjbhi0YrMThvNfYtbDgEo4nC5QqNa9WBg8a3CFoQ+m3auN0f2xwnfU7rj/ewPFw9n+0JT1WE+QDLMgfA/TYklOeYCsgJsigBx7TTxr6h0w95r/VnmmgOpzNtyhEAqOlPckO1EbbEB+OjwssoTXsPs46WJjD89Xb1p3FW/KlGRPr/oSbJjhLHw6VyRJ0S635Vg4fCo75scw87g== 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-SenderADCheck; bh=s95j8m7gT7PbaAgGJPHJ/JAr+kuGxWwLGbxaKQUKVrE=; b=dKOWHnSnV9hHBFOkH/xqXy269IRa2PLW+Dzy7TRbyST7JAK/y3uYdy0+2vNI3/ZczsMBSR+aEMgSVuPZ//3UzY1U/ddAiM6BulSs8UkgzEqb5AX7s8ISMv/gVzUwsIvAy+IDgOQOZxVvcQNNjAbw+WfOZvmxQHqFwp5F/g4BNdtDZtlTIaXYXdpcE4KBuFOSVFDHPkW0ZyBrOdoS3n69KgHG0yYz/uBg1+tqGJsYO/uajepDSBH5uh5qH3PegGXNOdcOPm6V+HsD3P8keF0ayFAPLdI4HwWd/vNkueDKP87R9132EvA3wVx2fEA7onUgL7JA5RmPfJ2xVCKl872uhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hbkworld.com; dmarc=pass action=none header.from=hbkworld.com; dkim=pass header.d=hbkworld.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hbkworld.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s95j8m7gT7PbaAgGJPHJ/JAr+kuGxWwLGbxaKQUKVrE=; b=jTnnBKSBpkG178ZrSm9QDIxwZKQLsTFj5aDWsCS2L8Q9e43PrcxvnPd7pz3jETGioxzqGQxA0RyGbC2FQq/kvuInvPJ+jVpEy4j/n/Tlh2Ggy5tRuIa3pQdQvCT0UQstluswwQGA+G0SBn9BYXMM4UT9LRmRoMMVM7D8EyigKtDlE8gpek4irahDqwZSVaXxF0Tc5YCzzbYgpDC12KqanLrIeKmGDqjToMNbSXaahKVcDvc2XUK/V53VG4r4k92/w9w7oDXNk9pPhp+nwMCabiiNfHX+qRvCS8OFmOH/JBkE5+vMflvwkR5191btleIQeq0Ep2hl5GtjkYGQL36zQQ== Received: from AM0PR09MB4276.eurprd09.prod.outlook.com (2603:10a6:20b:166::10) by AM8PR09MB5228.eurprd09.prod.outlook.com (2603:10a6:20b:3db::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.26; Mon, 19 Jul 2021 11:33:33 +0000 Received: from AM0PR09MB4276.eurprd09.prod.outlook.com ([fe80::4d88:bf9c:b655:7a92]) by AM0PR09MB4276.eurprd09.prod.outlook.com ([fe80::4d88:bf9c:b655:7a92%7]) with mapi id 15.20.4331.032; Mon, 19 Jul 2021 11:33:33 +0000 From: Ruud Bos To: "netdev@vger.kernel.org" CC: "davem@davemloft.net" , "kuba@kernel.org" , "jesse.brandeburg@intel.com" , "anthony.l.nguyen@intel.com" Subject: [PATCH net-next 4/4 resend] igb: support EXTTS on 82580/i354/i350 Thread-Topic: [PATCH net-next 4/4 resend] igb: support EXTTS on 82580/i354/i350 Thread-Index: Add8kVAUFLb2Ir95TSmaQsAHEgRgaA== Date: Mon, 19 Jul 2021 11:33:33 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Enabled=true; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_SetDate=2021-07-19T11:33:32Z; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Method=Privileged; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_Name=Unrestricted; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_SiteId=6cce74a3-3975-45e0-9893-b072988b30b6; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_ActionId=5b15ef8f-eaad-4dd1-af00-7a7d77787e6d; MSIP_Label_9208be00-d674-40fd-8399-cd3587f85bc0_ContentBits=2 authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=hbkworld.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: efb22734-b1d4-4f08-24ae-08d94aa90a98 x-ms-traffictypediagnostic: AM8PR09MB5228: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ekAC+oPBHc2KgXF8i5HLVVudb8hOgJUdlWwybhHcpKK/qM8n2fSMheywT0AkMZffnED03J7QhDkXz5M5OVaAlSwvdxZWiAmyzKpboOqiKaCDhDU7Sj7OQQ1KSbRGmqBKaXb9hg7cbtveOF0MZd6lsPt2Ef5DaD0oEnFJyV5bvAGz8IB8eabeDap/WJVhABGqLryfezdD0OtUjstEzDkP/neo8qp0z5xse5KjBRI/od/0fMg9Qy2k1WBS9y/FYCEc1b3vJee2vL8DAZJ6o3CRlcbYjVEo5BNMpK5COW8Ff0mwIfdN+KIHmC5CTYPRW51cIggksUY3h8aOnVkFEeDhXEMUxpLMhU7isynA7bexgHJu+exjoXfw+jfmDmxFm7U0zINDf6NXVB7xJFCyBZgQRbOFmeG/eEWFwhebjp/uqeGTsIUwVgaszsD4faXgh5Z6XfNrjx5OLyYdoOndUl/DcFtyvH8VZ75n8KXi8PXbfZm/bV8ZCZTmGLJlSxh9PBBYSy022yK7F5Skn9LgGet4365HdkQxm1pC+ilogC3htW0PrSpvzcsdc5mc2KiI1UBqH5vjZ8L2a4Rmp1Z/wT6T1veu28fplFM/7SBfcvsR7UgaORDejvMrz/QQD/psy056H3cEbBmatljoZAEK3QJZak0FuckFqXdfboD8VX52TyYZOgOigr0PIHUYfwjMWiQFox9fUamRg8B8qRVhmsK1Fg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR09MB4276.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(366004)(136003)(396003)(346002)(376002)(8936002)(8676002)(5660300002)(6916009)(55016002)(33656002)(52536014)(83380400001)(38100700002)(2906002)(44832011)(122000001)(26005)(9686003)(54906003)(86362001)(186003)(15974865002)(66446008)(64756008)(66556008)(66476007)(4326008)(316002)(71200400001)(66946007)(478600001)(76116006)(7696005)(6506007)(38070700004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?PnV6bSuvtw25uCKK1kcxn16vs?= =?utf-8?q?K5Bd4bAfJGNm/gO92Sh3/f3gFv8vzBRO4QeFqILwLnleR4eJwfbd+5Rv?= =?utf-8?q?jQUqvnbkMFFUi2GwaCILQY8WNOie2q6vYajKgAlBG4pRd8rDKiOUhgJ6?= =?utf-8?q?R/gvq1D2TRkgXYL/Z3DL1CH5OTwOZyYiBEfb3rQ7vCGb4qAI+L/U+LO7?= =?utf-8?q?NYpahPLBbN0+uXR5xpLwV0HWJoJ1TBqXel9QvLfwU15GD7Na/wANb/jO?= =?utf-8?q?9KFSLfL72+Z77CQvcDQl7XdZ/kzRnSagAZ/mFFRF8wDjJj95f3/KTdOy?= =?utf-8?q?8F5HaUY64yNW34n/cWGK4z96k/fw0rOpQ1Tlb8CPYB6d8wlGZPNBlH7X?= =?utf-8?q?Jbofr1b+oI4xHDvqyW7hef92XWE3/Zfq3yHPEdiDOqAVXBedL3xa90rl?= =?utf-8?q?7mL1obknkgDJYdl0NH4w9a//PyGdvdW2cjT9jLQEnqYQUm/Uxu9n1IaO?= =?utf-8?q?fIMzysevOfjE7q5P4qe9oTcnO/JXSKLx7+/aFTf1DWefT6FC0AoURMN3?= =?utf-8?q?xE03j6jmnTfomE986B3+t5pwy0duBOrLjd/wLEFi8xaXmVJDGA6vNNt3?= =?utf-8?q?J3HWHQ7I/2e+Uzq333Vw47OLb4WPAagbyqwBlnO7k19YqKSAwqDnTAFC?= =?utf-8?q?wUFVkKHV2u3nio+Jdt/dkzjucm0p2p33axP1nMDoAg4Tjy1aV9JvsaAh?= =?utf-8?q?R//oXttyZ+zSVHTzdhchEnd3zdIXlUuo9UyMGcgmZicp/tB2ll+wL4R5?= =?utf-8?q?n+o0+/huyy3rv5SWmiAFu6g2BcMeILUgCB5WiffmPkspT3cFKaPLfhK5?= =?utf-8?q?lqXpo7Wa62CWVf1wSDeAjpRGjRuuWIAcKgpkhKxe29k1zBaYZgw9CgEd?= =?utf-8?q?5ERFWSffbAkBFTR6dTeJJR8R12b6LCbo6eUWKaGJWWBi2q87v3PjENeo?= =?utf-8?q?YmV7j8xK1vNpbXmucC57ZnSVyUw14rX+l8jkgSZeA1+ykRZZs3aO0QIf?= =?utf-8?q?1Y7/lYlX6h6S5vtnfDH3DTO0A1P0lkkMvl9oXC/9eiW82g1moeOpyw79?= =?utf-8?q?2wAWoGFlKsskx213b4t0om7gnTKUsyEnIcVXQc3h75uOSyV6yPhKUYMu?= =?utf-8?q?RFr6r6c2rPrrovDaDao2UqQE2naJTJ4v81iTUz3s0QqaNLRifiLq12aY?= =?utf-8?q?NaAWcePn0q6QGSuW2xZwzVZ3VbmNd9bCHqCrMlZ5Hc046PXOBnuX39ER?= =?utf-8?q?FlXWG36T/kHNKN8tAtwomVRUXeUV3OA7IiPgPstrOVKnaIFJvThI66hW?= =?utf-8?q?O04V1x+N1W4hY4kQYIawmUbmA6dp3c7ciF2gbvVAf8ef+xnamMqveA6L?= =?utf-8?q?TLBOwbA4Jc=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: hbkworld.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM0PR09MB4276.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: efb22734-b1d4-4f08-24ae-08d94aa90a98 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2021 11:33:33.6172 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6cce74a3-3975-45e0-9893-b072988b30b6 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: N8Tv1fX1cQFHOKH+lZoDz95evh0az/uzLoveblklkymQfd0V7Ch60NE4Y4a8n6kX X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR09MB5228 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Support for the EXTTS PTP pin function on 82580/i354/i350 based adapters. Because the time registers of these adapters do not have the nice split in second rollovers as the i210 has, the implementation is slightly more complex compared to the i210 implementation. Signed-off-by: Ruud Bos --- drivers/net/ethernet/intel/igb/igb_main.c | 20 ++++++++++--- drivers/net/ethernet/intel/igb/igb_ptp.c | 36 ++++++++++++++++++++++- 2 files changed, 51 insertions(+), 5 deletions(-) -- 2.30.2 UNRESTRICTED HBK Benelux B.V., Schutweg 15a, NL-5145 NP Waalwijk, The Netherlands www.hbkworld.com Registered as B.V. (Dutch limited liability company) in the Dutch commercial register 08183075 0000 Company domiciled in Waalwijk Managing Directors : Alexandra Hellemans, Jens Wiegand, Jorn Bagijn The information in this email is confidential. It is intended solely for the addressee. If you are not the intended recipient, please let me know and delete this email. diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 8d87166e5ecb..3f76b45d7e65 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -6796,17 +6796,29 @@ static void igb_perout(struct igb_adapter *adapter, int sdp) static void igb_extts(struct igb_adapter *adapter, int sdp) { struct e1000_hw *hw = &adapter->hw; - u32 sec, nsec; + int auxstmpl = (sdp == 1) ? E1000_AUXSTMPL1 : E1000_AUXSTMPL0; + int auxstmph = (sdp == 1) ? E1000_AUXSTMPH1 : E1000_AUXSTMPH0; + struct timespec64 ts; struct ptp_clock_event event; if (sdp < 0 || sdp >= IGB_N_EXTTS) return; - nsec = rd32((sdp == 1) ? E1000_AUXSTMPL1 : E1000_AUXSTMPL0); - sec = rd32((sdp == 1) ? E1000_AUXSTMPH1 : E1000_AUXSTMPH0); + if ((hw->mac.type == e1000_82580) || + (hw->mac.type == e1000_i354) || + (hw->mac.type == e1000_i350)) { + s64 ns = rd32(auxstmpl); + + ns += ((s64)(rd32(auxstmph) & 0xFF)) << 32; + ts = ns_to_timespec64(ns); + } else { + ts.tv_nsec = rd32(auxstmpl); + ts.tv_sec = rd32(auxstmph); + } + event.type = PTP_CLOCK_EXTTS; event.index = sdp; - event.timestamp = sec * 1000000000ULL + nsec; + event.timestamp = ts.tv_sec * 1000000000ULL + ts.tv_nsec; ptp_clock_event(adapter->ptp_clock, &event); } diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index 64a949bb5d8a..bc24295b6b52 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -524,7 +524,41 @@ static int igb_ptp_feature_enable_82580(struct ptp_clock_info *ptp, switch (rq->type) { case PTP_CLK_REQ_EXTTS: - return -EOPNOTSUPP; + /* Reject requests with unsupported flags */ + if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | + PTP_RISING_EDGE | + PTP_FALLING_EDGE | + PTP_STRICT_FLAGS)) + return -EOPNOTSUPP; + + if (on) { + pin = ptp_find_pin(igb->ptp_clock, PTP_PF_EXTTS, + rq->extts.index); + if (pin < 0) + return -EBUSY; + } + if (rq->extts.index == 1) { + tsauxc_mask = TSAUXC_EN_TS1; + tsim_mask = TSINTR_AUTT1; + } else { + tsauxc_mask = TSAUXC_EN_TS0; + tsim_mask = TSINTR_AUTT0; + } + spin_lock_irqsave(&igb->tmreg_lock, flags); + tsauxc = rd32(E1000_TSAUXC); + tsim = rd32(E1000_TSIM); + if (on) { + igb_pin_extts(igb, rq->extts.index, pin); + tsauxc |= tsauxc_mask; + tsim |= tsim_mask; + } else { + tsauxc &= ~tsauxc_mask; + tsim &= ~tsim_mask; + } + wr32(E1000_TSAUXC, tsauxc); + wr32(E1000_TSIM, tsim); + spin_unlock_irqrestore(&igb->tmreg_lock, flags); + return 0; case PTP_CLK_REQ_PEROUT: /* Reject requests with unsupported flags */