From patchwork Wed Mar 9 17:27:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12775360 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D832EC433FE for ; Wed, 9 Mar 2022 17:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3/acS8DQ4rLjUCZBKLYfgi+paaoPXO6jR/YVz7zJhaQ=; b=ei+mKaJ+LdfMKJ FC8uZJWzNj/GeZF/yFJGgNnD44mLXZbBT43NGTT86dcGTqdln2fMK6FQY7f8PuftIkzD4T7+NHyU6 UV0tbcrX0xfLY7mIEAqFWYS999RLU/CPiIFlLbcW8IaMjirJKePqtdsHUBU62eRfAWzH+DaBpx0hr awqfgK7dPIWJku+eVRrwrLoK69cJK7Qsi4cXyHzebnvNyb4jIM582cPrF0ZRY+Zj62OeI/QAVwkp4 O3cGwZX6FaQtVRwVty6RheN9rT3fjiVbeLJtZUiddjW9DicZTfW298SMxI0LvuNmYOFwuNCcmOW99 8Va23UbZ1tnrw5yU+tIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nS06n-009oEl-A5; Wed, 09 Mar 2022 17:28:21 +0000 Received: from mail-vi1eur05on20618.outbound.protection.outlook.com ([2a01:111:f400:7d00::618] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nS06k-009oAh-6L for linux-phy@lists.infradead.org; Wed, 09 Mar 2022 17:28:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BUxR30WEs6d1pBWipjvJ2rO2TnAyatt0CVFr8kjGSOwvdM0B/iltGsl+JpQR/3bmcPuPFfuHXoGOvfrufuNMcGvrqMnnJgaX3EAta/EqtnDPmyWyWMJ+72Kb3nN8fPrewgdQtEPrOPTnHJ0XMDannw73Pvz4pXPgoQ44HphNbhEqH34KCwjKz3pSFhmyeKMBwN5JIGcVsm5xGc04H168s+QHGfEpnWFZRFV5kLCbwKkzWS8hsEBSnaXHgLpPg4dQt2slS+pe4CCXj7boOTE8FPbLiHNkFQPFkiDt5ukzvX8GjogYqQqOCPY/oWdCrGOmlAY/ig+08SoBizdAeWkqIA== 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=6iw6H1oq8NBU1T86z6PJXqDg4QgGdGR3GK7d3DGjptc=; b=OuQCdzspZJ2qZwACXYPAhQx3TwDi2qt+ynAkgclKJyOvEeXr8xvu9T7pVTCkvRRRG5Uk6XU2oohahCD2RP23A6abgMylI7hq016wHNdF8nFAPKHseq/3hxSTfJrhNhy3K+7sO298M1Ch3cnljIhdIg5cUcWkkLjsbzU8RFZG5P2LgXxTxOVu+huiKNS31p2lvI5QTPwB1nhhWrGQhnwMj9SKgwJvXVQy1KnRPlgDNqB6oGuo25r+NArSjOICJm5lhUsOFNBylEnmXMQeZWKk4jb59VZUEQts+u8v+3NQKwENwDHRfirA/B4FIjwLAFd+S80kqOnsdM0jeWxE/7lYQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6iw6H1oq8NBU1T86z6PJXqDg4QgGdGR3GK7d3DGjptc=; b=GjTrUGqLp32nfWLwihHI7buNRLrvn8gC6fx4gB2faBfgLOxM0u6mG3KwmCbIviu3aeAoEY0VdhF4yvwTfNs9UvCWf5TISyh/z5INld4GddyyDQBbHc/9xf0acZMd82eVHq94h3i7W2DeDnrX/sge/QvKWQdbVv/FhsLxhenyejI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) by GV1PR04MB9101.eurprd04.prod.outlook.com (2603:10a6:150:20::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.25; Wed, 9 Mar 2022 17:28:12 +0000 Received: from AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::c58c:4cac:5bf9:5579]) by AM9PR04MB8555.eurprd04.prod.outlook.com ([fe80::c58c:4cac:5bf9:5579%7]) with mapi id 15.20.5038.027; Wed, 9 Mar 2022 17:28:12 +0000 From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: kishon@ti.com, vkoul@kernel.org, robh+dt@kernel.org, leoyang.li@nxp.com, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux@armlinux.org.uk, shawnguo@kernel.org, hongxing.zhu@nxp.com, Ioana Ciornei Subject: [PATCH net-next v2 5/8] dpaa2-mac: retrieve API version and detect features Date: Wed, 9 Mar 2022 19:27:45 +0200 Message-Id: <20220309172748.3460862-6-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220309172748.3460862-1-ioana.ciornei@nxp.com> References: <20220309172748.3460862-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM4PR07CA0014.eurprd07.prod.outlook.com (2603:10a6:205:1::27) To AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f551cb7f-b39e-42f3-4951-08da01f22fe5 X-MS-TrafficTypeDiagnostic: GV1PR04MB9101:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OQWrtwdwaIGrrrXZljC8DjeJ5s3IEBDjzGM3CVPA4ZSW4PoJNmLSHIrHa4rZ3OBQfDPQRJdzeFRLYV4PyCco356yChG1EtrHuhKgf1nnZ6DWZ1Qjve7h7gNBxIY/DPUhywuGHiCH1+NiHIGFOTRYp95KJhcgrZhxxLyIgwExZOuxdA/V6mIQoSLU4DT3mJUQPQyWKbABv4C8vIynoZrGRr4XiFXhRZWiv0oUFFNEOHM/BQ7lskkMJerdnls878+3nE4IS8GIgYQx6OVVafshBFsIcUpBW6Nn2CqXOWMTCVLAKBp8onen+hgpdFi2wnXYFDzac8koccgtzVqFBYlHN5YN9o1qXT3dMZgUTOsXVpQi+qgSm0STNTq8QEG5gaE9g99Wqn800WFtrsebAo0hhqQ1e3cov3nJbnRpNBttksXrntYxPdySmzEE/QPSk/wid8ySvIBpL/XzwJb7skXrfC6ZqYa+C7j7K+nwia10a4GxTtf9ZWJODwsnwAdz4pYc/5UgvmbSd2G5pDCKAMWmxV56WFFRZ7tS19tRD+3pz0br8VUo5nAaHnulUMZLuUH1Izz/OHFhjhPPq5Sb33eKwGxiFxdyoH789VtZfWI+K5BmrfWOAbksr8hDEom+4+09KORZvdMJ27ChE7vIeAjX0yyULb0beQzzFc25p/PJaw/ezMr4HcbYIkvrpJ2ILuZSB2y9ASsHTYhAyKzV71w4+A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8555.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(5660300002)(36756003)(6512007)(52116002)(8936002)(498600001)(83380400001)(44832011)(2906002)(6486002)(7416002)(38350700002)(38100700002)(1076003)(4326008)(66556008)(8676002)(26005)(66476007)(186003)(2616005)(6666004)(86362001)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Etd6F8Nn0wBxlyQOiAenFn/0Y7p2VyiBrrlvpJVJNjNZ0PQ3Vh7eGSqu9F+sC7ZOoVSksebRrUhCwKiRF3SV3lIIKjsgw7zeJNWrQvbIJOR1kLIKLzU88LdxvMgRBa4SdO3bMBbzLpcusWDMm0yEYXAuhlaNipDwksAnbBD3yO/982CHfaEgqGQPyZYemlYzE55nRLsSscRBUb5ZelHB8QoTJaokLJwk13oB1A9mCpmlooLc8agQ5Lz5GfMLeXv2HRWk5iFxrlWGVhKx35b3ZxxzxRp29Rp7JytGaPrA8/MsfCQwjY56xEbNzk2sSbeTBtwUXrxy9zxsUQf/v9uL6SCGMZYlkU3EorYHmhtTml/R5crmTPJ5VDii+k/tXRCC02byrmkgdNPWNbuEiKeMBrsjyI/IX4OIxnnFOYiyA3ipAzMaZyBOKp5iSrWxpWz4rdOix1whcVzd0DEwA80NYiuZeLPIEqTGqHAyJmr9awlVW5kX625YyYZ0u9wzrePn+BfKXxL+AIhjaW+beiaamUVgm5n9ApPqdSXv9LEAgltW2HEy9PVcZ3fknoUSWAEp7kh+VSd1sW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ant-Network-Message-Id: f551cb7f-b39e-42f3-4951-08da01f22fe5 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2022 17:28:12.4865 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /D9zuNYQN+zbBQ6jjX/7jnXQfRFZy2+evp4EDwxBfOcAkaG8DDzuQ0LmMc8Mh8y5Kz279VTAbVw5USE+BwBMYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9101 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220309_092818_295405_A717E833 X-CRM114-Status: GOOD ( 13.36 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Retrieve the API version running on the firmware and based on it detect which features are available for usage. The first one to be listed is the capability to change the MAC protocol at runtime. Signed-off-by: Ioana Ciornei --- Changes in v2: - none .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 30 +++++++++++++++++++ .../net/ethernet/freescale/dpaa2/dpaa2-mac.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 521f036d1c00..c4a49bf10156 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -11,6 +11,28 @@ #define phylink_to_dpaa2_mac(config) \ container_of((config), struct dpaa2_mac, phylink_config) +#define DPMAC_PROTOCOL_CHANGE_VER_MAJOR 4 +#define DPMAC_PROTOCOL_CHANGE_VER_MINOR 8 + +#define DPAA2_MAC_FEATURE_PROTOCOL_CHANGE BIT(0) + +static int dpaa2_mac_cmp_ver(struct dpaa2_mac *mac, + u16 ver_major, u16 ver_minor) +{ + if (mac->ver_major == ver_major) + return mac->ver_minor - ver_minor; + return mac->ver_major - ver_major; +} + +static void dpaa2_mac_detect_features(struct dpaa2_mac *mac) +{ + mac->features = 0; + + if (dpaa2_mac_cmp_ver(mac, DPMAC_PROTOCOL_CHANGE_VER_MAJOR, + DPMAC_PROTOCOL_CHANGE_VER_MINOR) >= 0) + mac->features |= DPAA2_MAC_FEATURE_PROTOCOL_CHANGE; +} + static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode) { *if_mode = PHY_INTERFACE_MODE_NA; @@ -359,6 +381,14 @@ int dpaa2_mac_open(struct dpaa2_mac *mac) goto err_close_dpmac; } + err = dpmac_get_api_version(mac->mc_io, 0, &mac->ver_major, &mac->ver_minor); + if (err) { + netdev_err(net_dev, "dpmac_get_api_version() = %d\n", err); + goto err_close_dpmac; + } + + dpaa2_mac_detect_features(mac); + /* Find the device node representing the MAC device and link the device * behind the associated netdev to it. */ diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h index 1331a8477fe4..d2e51d21c80c 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h @@ -17,6 +17,8 @@ struct dpaa2_mac { struct net_device *net_dev; struct fsl_mc_io *mc_io; struct dpmac_attr attr; + u16 ver_major, ver_minor; + unsigned long features; struct phylink_config phylink_config; struct phylink *phylink;