From patchwork Mon Jul 19 06:25:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruud Bos X-Patchwork-Id: 482111 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 837FAC636C9 for ; Mon, 19 Jul 2021 06:25:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DA3C61182 for ; Mon, 19 Jul 2021 06:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234253AbhGSG2x (ORCPT ); Mon, 19 Jul 2021 02:28:53 -0400 Received: from mail-am6eur05on2092.outbound.protection.outlook.com ([40.107.22.92]:52480 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233580AbhGSG2u (ORCPT ); Mon, 19 Jul 2021 02:28:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VJFeoe4r1KcGJVxS5/fCb8XtDb/UxDvB1MxVr83LRNnzsiyGU0S93uTqCyrGsp+Kk/kD+PWuiiGX4m2wzNb/di618UpVWLhI1JucrHcSIA8lGZ+05fkzt9weNicjUS+uSCNc6IZVCyZYi58Dhjjt/fmnXJAHflUneOKWL1259yFW34COH9Ep0NASTFZrRqGaXZbXSx9qOnf7eUhj6fi0CBKO+dVKmUSnq1+7+39Krb+gA7TPSmSE9p2h9hqSdcdebX228qKsZh71pF57OeLH9CnUjr1gAv83rm2yiZpP0ruW3aeNz2tpBjJs3ikj1ueqSN+tMTnqT9BTCZ2Cr9IbfA== 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=cPXyCimblDXgZv2ShJTrt4BPsasL0G5QeQl+PwGwVjngdYLYvC+k5Hmx/L2DIlip4KUwYEq646nYcUjee9hn/c/d5b4eQHdgeirD2kYmy1PoxnTAtSkYMhKxk/3ryADtrObX9rf7jElPADv/BTghfJpi5rSNKdMxdzP0yD6O1sGHDi0GaN2re806c2zNSEUl8dXKqSqvM9FZbVtwA9lQNknhFJlxIjR3qmUDF8BaZv/x0Hbo1YESSkEDwmqVS34S4sSxmWz3hRyA/qwtDC+rqTPLw//VE7CKtevTOJMH1Mnam2CllR5v97WQVNhG3te2Zd2MBUOcNnHTU7if8VzQhw== 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=h155L9q6CcSNV96hoGNKDj1Fy2V0/kILFija68zbBHfsFmaIKUoKWLb7W7fcE0a2MqwILingKvkbXdgS8xgAHKwwBNw0KThW4azF4ghDJNSlWCf8B/aCQj7p8p6gwpbfALTJqrGd56MPuD3seSrqqKG6u0oKqZ6+JTTiHUX6yZLRWFzLdJbPNdldXyVgzWO/4D082HnWTbslHFboDJ/zbCW161czcz1b4X72IBC++On+r7QE0S3KR8rVz7EI9FcUgrMPG5xPksWOyJA7VDvPM/ZzBUT1MORp6sdiAyFGJyh4vzU9scmrfAn/StGcDRceLTqOgbn59p81Nh3Ru5UOqA== Received: from AM0PR09MB4276.eurprd09.prod.outlook.com (2603:10a6:20b:166::10) by AM0PR09MB2611.eurprd09.prod.outlook.com (2603:10a6:208:e1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.29; Mon, 19 Jul 2021 06:25:46 +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 06:25:46 +0000 From: Ruud Bos To: "netdev@vger.kernel.org" Subject: [PATCH net-next 2/4] igb: move PEROUT and EXTTS isr logic to separate functions Thread-Topic: [PATCH net-next 2/4] igb: move PEROUT and EXTTS isr logic to separate functions Thread-Index: Add8Zg2HsnagZRwHRyWVVy37Ak9WQA== Date: Mon, 19 Jul 2021 06:25:46 +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-19T06:25:45Z; 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=5eecda3c-6006-4c8d-9727-f6a9c7277be8; 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: 6422ff35-078e-4b62-2955-08d94a7e0b7e x-ms-traffictypediagnostic: AM0PR09MB2611: 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: Y9102dSofeyMaDTbVoJJybOXO9mJyZUVQcE6AIpiYLWNhQjTqBMiO94RhStXEQ4quw+52dJlpgeygcc/qR25HMEsq73RvAyaUVWUV6NE8RH2jAAdZSP0HXVSY1o8vgDTAGo5wR/2sU+1iZ655VeGGp/+PTNLQMxKuc+p01kRxNFX/uGzt5z3yxIWMcgmWrR1z0+B14QgWQyTLXMRUoIaSKWtqYpAbftFqP8WrSXQ9Y7cCE9meA4Wow5SJ1z595hePVevPsFc867FLsogiF1eV1bGu/QVKCo7XJZr0wlSHBJQxBFdtuRY0ckUFN8+PjJyZ97sLSFK1CR3z5xjUFFGxm8uJ5PCv7UFnvaA0v5U4z3HNbB7FRdhtqMxrb8GJJemZksxLB9f5zLyFYkTxisya9Y/eC+huxtsG35T0qsGbJcA/puTVAF/qDeqXr/3ObETDfjKPk/g5GCo07m+Gnc68WeY269bixZ9/0LOdUSJisyuAiKCuUo+UQ7oY1p2Bjq+dbWjaOs/eRD1O11AbNmMsbKN/l1DDV4PcdijjZACEikOE3/PQeGyl4qXn+buvZHQzPnx1xPJULjNxZxLFcifCbsWx5pbgIFPIkxU101xKehW8ucV4OE88scrXRuL1U4AdffRq6wwA3Uto5+mbZRK6b+9IH6Li9aV/4Cn1IzTMboAaIMQFJRXe68URloY6X/Tm0QUWzpPAGyuDX0oFzOnDg== 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)(346002)(396003)(366004)(136003)(376002)(478600001)(83380400001)(9686003)(52536014)(44832011)(71200400001)(5660300002)(55016002)(38100700002)(6506007)(2906002)(122000001)(316002)(33656002)(15974865002)(6916009)(76116006)(7696005)(86362001)(26005)(66476007)(186003)(66556008)(66446008)(8936002)(8676002)(66946007)(64756008)(38070700004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?Zf4VbOTrF2BPo9c3ZsmnDe9Di?= =?utf-8?q?HdzPNu6uw3gcvlaJoX9fkyjuUGfmYfXByG4ifzjxwtaednnGCENEIxIc?= =?utf-8?q?eYL1d4sxEqUjSQi3XuN6vrd9+k1YXvzBvBqTSFG9gAWsHLgFqftXa1hT?= =?utf-8?q?VHBJN7kjijfImZSvn2jnUbVAzq5qIWCg2Kk5XpvdWhDQbzzL7doiTWV1?= =?utf-8?q?TIk1tfxjZtA/VyjVPvcEuEJRG2MqiCpvvLeXEqpDSTEOCOFhV8AXjNNs?= =?utf-8?q?0jhUoiDksr0F3pu/shXt5xxLKJpPiGHtR+LTPr4Dmx2zdinvOxCp6G6Z?= =?utf-8?q?6qu2pU30JcQZkaGR72NhbABjuTCSL3cyLPTAcYeYLy76MLk30AZmr6Kv?= =?utf-8?q?A4soGvFKhIsQSZL7qeXclimtD/ClqbnBcO8g+bWqj4Wpn71VnZdEPBTH?= =?utf-8?q?vmHvBSrU4mrt7OQW5wxLzyFrD/jtS1/hli+D9Q2sfEEL0N3kKXP6F1fl?= =?utf-8?q?igsVTNHEEFQC5EYjRNaBMmiDT8EAhQUdABgUU8vGQ9TW5YLIKCuJEB8c?= =?utf-8?q?dd70iDUY4qR1Bb8BJbdCuggBCsBBBK9eoSWPhD9hHw11K7K64+xivKjo?= =?utf-8?q?XIKl2zCn5BdsxZdniKkXdvlM4XwcaGKHSh3beaQ3qA/zEDNInlmJAZ7A?= =?utf-8?q?yqnrfwlIVrO+MTWiz6V7+xMDujqGbeKbfd7u1YGq0OhWdcePZH52wajZ?= =?utf-8?q?uK2bokPbdEqISQYDQYaue+0XKOmINvYnTB+eb+gKtOP/Kd25EZ9BrUmy?= =?utf-8?q?xO2Xbw7vRYq69vRNzHaayIRaVWWVN+jFYMeX0S6YgR6gUGY6cghgsfvL?= =?utf-8?q?uz6nD77vwkw0m9BmWr3Wx5O+fhX/t6urbhtd4E8kpBzi+/UxSnLv42Q7?= =?utf-8?q?DMCvxZ6VStX2R32a9LZyjCpP4f/+S9NQiA8MYuhIJ2fDBviOXbOm2H92?= =?utf-8?q?qRbC+lPdaA+CBgE7WzSnNd9DOjggXpLx8YLzsJKEjEG5Q5J4ml7LB77n?= =?utf-8?q?fdyCB3FvSHjB2HmBifmGafRTXoM9lMNwH9i3g1a/cLJDMwJZy9Gr72OV?= =?utf-8?q?gjGVovSnLKfLVA1pMuY/w6kZzNbxD1u70YkRVFhZV00m3SL/Vb3LAugl?= =?utf-8?q?xRZlc4Vg+PChtt708TPLWLgFsBylYN+kcyKfvEtiSWNHJTuByM/S4hPv?= =?utf-8?q?X1FQPStgtzNpgi8SWZFjOZuSo8vfhUY0k5e1qFN05QXusz/OFxTO5PcC?= =?utf-8?q?/XUUwHZ2uePQLzAfJbkIFEuWenTzK8b4/ziozIiPAEpM9TFMvWMQbXYH?= =?utf-8?q?4aUho0x+8lrsjxc6ka7lC1kaiY6aMoUnevQOUWlGt4llkiRvCL6iampq?= =?utf-8?q?74xUV7g9E0=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: 6422ff35-078e-4b62-2955-08d94a7e0b7e X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2021 06:25:46.8210 (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: ncHn1nlVcWQvqNuHNybx73VGbhlWzIf0mFvYarS7VrpeiXXpH6cMRIvEROx9KyDL X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR09MB2611 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; }