From patchwork Mon Jul 19 06:25:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruud Bos X-Patchwork-Id: 482110 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 A1FDDC636C9 for ; Mon, 19 Jul 2021 06:26:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8536961073 for ; Mon, 19 Jul 2021 06:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234097AbhGSG3A (ORCPT ); Mon, 19 Jul 2021 02:29:00 -0400 Received: from mail-eopbgr20127.outbound.protection.outlook.com ([40.107.2.127]:29104 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234489AbhGSG26 (ORCPT ); Mon, 19 Jul 2021 02:28:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Du5arjW4UPl08Cj1sOy5kyHU05X/eVC2qkzrvX9OOoFSKjU+i8uL7qGV+G1Vz+96eymY1njrs+9JcSP2+m3iazyhdKqlGVaZoKtxlbJQSaOd4/9RfvBKnplKcnmiZxL379iAUV99L6x/cmpYIVVrRhbXpXeAn94gzAfjWNRY2cQENrUq1DjqOtrXT5qSUEr0wP7G/2rVKR3cD1qz3BewCZOyTM4oUl4lLGH/VsDqYcvbYkbjy+xAldLT60lRhqibV1HK2XBogq0YYrvvgMuHVqSTTHYO8wpXdeQ8G7XxdxkflChsNgx2iuYhWtIndeh0TbT5biSov9QxkO8L4DrK5g== 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=PL0MUEBp13V1QIg5yyhCYmrn9O2JHfbWV21X3Z7Q/3L1t4liqc3Ej/Tr9O+GfaG4W88hNO09O9us8mNn8NeM7twIvB5KeSF68/QmAXoFr4Lb8dREog0bZ8aI9KLObDUQEpbG/yclBaHyoIJtsbtcsiB+NEJrLO43nSoVx50UNmyXrKLuGJO5AhB85j9SFcpoPUqzfGx2nQBhOUBjOPiY/duDPwgQJoqcbuDbXeW+uMnpk4Y6bz5y7gdmTJPa6/4IlBNfohiJAGjpwOQddPo7BMrlslmQLt16rWyjScvYLWIEwQe1c7cI1IXKSD8q6Fj8WZfLzKNLompFXxGB+PExLg== 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=n0wZTeu4j9MRyq0sW4ELQCJXD5WBHpah3nMFRiq6MEUMdkFpCM06C0MlnPcFEI941oGatOgGPf+hXC6zFcve098usIpDPs0hkL+3j2xcu9uSPM5b3O90wZJ/QHIyZZdr/lh/ytJUDjW8hxoSO6nhNCQmWeBfOpPME0Lh0Pdmy7ywLxWC+gThCIM8Ufb+rJUgQc9VZrDFLSBElQnDThZHuB+T2mMoGXp864NQIcFvH92neTrEnWI3RXbrhaKWWhsYdjcphYEJPhi78Lj6vQ3fEo+OKFfg6LAu77F94qlvw/nrkPl5sckD0wQ6JB8iDL/imf0ShyN2LGUhJth7kKpUYQ== Received: from AM0PR09MB4276.eurprd09.prod.outlook.com (2603:10a6:20b:166::10) by AM4PR0902MB1700.eurprd09.prod.outlook.com (2603:10a6:200:91::23) 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:54 +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:54 +0000 From: Ruud Bos To: "netdev@vger.kernel.org" Subject: [PATCH net-next 4/4] igb: support EXTTS on 82580/i354/i350 Thread-Topic: [PATCH net-next 4/4] igb: support EXTTS on 82580/i354/i350 Thread-Index: Add8Zle2A1UU0nbxSC2+juLWttqTWA== Date: Mon, 19 Jul 2021 06:25:54 +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:53Z; 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=5738b05a-9c4b-4bdf-894d-4df06591fc59; 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: 02fad29b-8b8e-4213-75d0-08d94a7e1037 x-ms-traffictypediagnostic: AM4PR0902MB1700: 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: fq8MiYJYmbYhbdBQAGaj3jHuk1Ope81LGXtuJQBM457MHZYlcJO+LoHlukeHxenYAZZOp4BEm6hlL8G3CEZc3A3D9sC6Z35/YJ8HrBRSnDQKboy7Mv0+rwwCVHcT1IrfyhGbMNNSgWex6paHWODkZI1XPN8tSPFdKzy4ms3e2U4NR0DGgA2mKjcElF5QvH63WywcPXhM6Yg6XfZDNvoqn71W9ogAr3BlUH8KweG6hEvgQbfwx/w8TMNr6DwMowc0DVsHeAYo84KiMh6fKEKnBRSKR5bZ1fGP7SqfLMYZCkTzpMjS8MG2KjmO4LJTXuZUxrhghwZdxleXEhN7g6EIqQRQkA7Fipb/B3wT6EqQ6b/jaSD9to4alAh1pff9nIOigIim7WKwcd6lO7QEqTt8JoP8sGGOix/hUYV4BbHUgxsmlPLYR0OBMfUL0S2Bg27w/1cxpgjOn60/w5cwBgclUrLCFZpTz+e3V5yjBRju/oPSYyXA518e60qirPAedsmlfS2auai3ekhs3EWmWDq5gzCz7+A5NARIiplrX0pRotlfTvUHaH/nsJgiln0MXcNfC/E7lQOYN3g3F05talHAUgGnUliFaKMYl8IMArHAmxM0kFsmjm3QA1EbpNDzSUJXUCOKy0IK8E1ll0p3NXrguR8IAHprl7J1fFjK3oJysFDwcY1x7BVoc/yZFgweD22yNVx1zph9iFeISdXRUpBsvg== 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)(396003)(376002)(366004)(136003)(346002)(39850400004)(52536014)(2906002)(5660300002)(66446008)(64756008)(8936002)(83380400001)(8676002)(6916009)(186003)(66556008)(478600001)(86362001)(33656002)(76116006)(44832011)(26005)(71200400001)(7696005)(38100700002)(6506007)(122000001)(316002)(15974865002)(66946007)(66476007)(9686003)(55016002)(38070700004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?HTiwB3qn32cPrm9D/kb5ss79J?= =?utf-8?q?8cZl6mokASkEOQL6twVeY/KlK97h3y5fvRtkYlXMpZOl/4SYG8Oy7qqZ?= =?utf-8?q?XrHqmRM8jfxl800Drj6p59IXoh+eA9fOeMyMMBGeqcr6gywGobbK+HNo?= =?utf-8?q?2Q91eboLhe1lvJ7tsNCOticVhGNix6BDdjKjqn9cmLN6n/OiUtwNt0Ck?= =?utf-8?q?yqRyPepjZzl1eohUDqJQDHkcQE5OKEsG4sHpJ5BnA7OY4T4iSDuS+gAM?= =?utf-8?q?KK2u+FNwLYyyvFiGfO1CTFNpv41LNNcporEpiqLjvmiJpzwLBROEaFZ/?= =?utf-8?q?pSSRq9lMRAI8vTrbh85vGYei0k+AKw2WV/ps6RBqQTzt/8bAhzHHQ31M?= =?utf-8?q?dLo0XKuCL/PQg0W6eoNd1TibSn++AKzKmEKXtbXQclcDCXqq1emI2Sm8?= =?utf-8?q?7Svq/ljic3/TmxFFkPcLohGvMbyAqSovK9NzUnS5p+3SdA8FFbaJqyGB?= =?utf-8?q?oN3Ir+qjw35ElwZAR/VHb6PFxpK+xcrWGQ8Le75e7Mf02tyFzbJj5xV+?= =?utf-8?q?8skYHznqucBSLwG5Hma/aBRniyGEER+fgW2UHcKdiiB6q9pskJtplELU?= =?utf-8?q?ZgYin53aL3G+dENsmAlSIJHwNH2lKwKnKaRXKHozVP9l00+94vQI7sGf?= =?utf-8?q?eYH4mnIxQy5RgyXFklhcrv1lq/Je5+1kL+S6u7md+HKASkspVJaAeFXA?= =?utf-8?q?iV7/jJUXjlDnnXQJAbwiEx8Zo8WB9tYXGe4RXEaWqwJdZNUSvKeJYzlw?= =?utf-8?q?+uoYAaTfs3XzBSj102EHHdE1u/UjRC0uIXhwUaSpG+vwwXGcnEyzNE9f?= =?utf-8?q?/mMY3wYJ3vK9yzfj1flCcB6T5czNSnCuo8mc30wgI8ipxZOBzS2MF6B/?= =?utf-8?q?XtY8QyCreUiQor/hmbOolmpmganGCS8HkfcoX+j/6aBF2vuJMG03gIVW?= =?utf-8?q?zVcUHFaWRfQNoP25L4W+I1eKyr6AkFNkKairqk2Rt0wyClbK1kcATlBa?= =?utf-8?q?pBFaPRR7S0TeCqZTtlFE4SHEb2bpC4E+LyLESWvxaLG2CfRjQmvtPhMS?= =?utf-8?q?jzry1hahTxyydj+UsIT4qpjfXN7EpaiJrAyXtCktFnmQeS6yIsQS78XE?= =?utf-8?q?L2ub6rANiXj00RFK7pkwLUaNhdQ0uldkBWDosMgngJ4qyZ7ImyTf9Abf?= =?utf-8?q?5gWDfooOTwObcPb2GtBOm5vZdwVzm+LLGk6rb66lTOmHPLl3Em7sq6mZ?= =?utf-8?q?8wSKFnJ70mYJvExl/R9Mt4VohSpH/4rBVTBCN9eskLprgNrX5ip7Q3Vs?= =?utf-8?q?ICuw1J7KuRHWdxpCCsILYBzQWVeDPsaojVvHOsKWMk4zvJTAHH+oJkO7?= =?utf-8?q?2+bnYzYUBM=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: 02fad29b-8b8e-4213-75d0-08d94a7e1037 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2021 06:25:54.7015 (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: Ncpj2MAhfwkGkMa+A6MJt31B/6GAdCAc3QOdx2yJZwkAsGnkEztyOZuEpCAcbuIs X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0902MB1700 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 */