From patchwork Fri Mar 11 12:54:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 12777975 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 A2B19C433F5 for ; Fri, 11 Mar 2022 13:09:32 +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=YjtODcSxHczXjOqzvw0gbkw8gtEZfAVDVk9rDSqk8/8=; b=4RxgoPXrILfeeq G9CPurlJHVz/7QnKq7xdPS2LNLcJhRsRSHkk4TdON6VA8iPFcFjZOKoVePM2KH8fa4Jx+Tl9UVTHp OE0CAuqLXAF08j+hmjAVUJqZp50+LKSlNWNwSP1zgQ4ErfIZxrTnktG2robPCgN2EEvSW0WkRSHAn Z7L/MCdEltUPtcqfIo8FcMtgTzP9+EaRenxkI7H9W+nGlY+3OSUzwYqgsFEVboJvDPdJE7yUS9MDz 4q+PhAQDxQs1chSk84YlxobZHWbUwU4ADPpW3x7GPIjQAz5Ei+uU05und8RVv1KRQrLEeb8pvkEwK tUeEn2/M4BBsx5LE1Onw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSf1Q-00GS6t-2V; Fri, 11 Mar 2022 13:09:32 +0000 Received: from mail-db5eur03on060b.outbound.protection.outlook.com ([2a01:111:f400:fe0a::60b] helo=EUR03-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSf1N-00GS3h-E7 for linux-phy@lists.infradead.org; Fri, 11 Mar 2022 13:09:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BFFoSqhDmPNPvJj+lPyt0pyXCqr8Dirayf79q/15i7dNY+978UYbENPLW5+jXMGvaip5pIBwtrAIx7CAN05RuWTJNP5hY31JTqR4Y42hi0gmqj2KQj40RLXx2Np6MSZhbqQa14EeLFeCpbHxwgoodX+YZf8GeCs+9Q8zikK8qC/Kzy7+tNB2751JenFdF2qim2sLNA20W0OiCMhcxG+SwHO/T6uniVgLC+J4lnM3MVH1SdJxCcV+t/FhWJIxn42nR6Q3feCjbkG+po95Uh4JYUq8DBbg5v15PmQlcDphSuFqNk/FOzDlLmywXbxaGQtajBM4o718qWf6tLq57UDjRQ== 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=FPm6jT54oslGsalXvOLA7AvwPpBLDeig2k74QYziVpA=; b=YykM7C9DNWAvG0SeBgNi9zKNWLLV2KOeo2l5WG/wRyIQ9/pKFJTA4gVjWFmmNPGIaqY5LqiZ6aMspOfMwGKBpYcuyr2+C31sXQ3ZvtzOto3f4cGWoc0Ttav53ktnWoYPIZWQ+s1dpbNUN+eE5Fp5s1uOGXw2WiUW89/1ebn+iY5qDET8stmXWHOVtFwfVIqYQDID/iDS+Muc/6q6+6DKxzuXnXM0TXwBVtzUecTuuBNFzvR0viiC/D90PWkruU6TfEkHlnMn8PWlXHkFdaJGAXBBTzyqBIcLLrBAzL2OLgvhaveb+Pew4A9cbZlNDIfSgkFiKamW9j73w7+xh943Mg== 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=FPm6jT54oslGsalXvOLA7AvwPpBLDeig2k74QYziVpA=; b=AwZ1Zq5O9J6Kw+0Gxsu6R7h5VNGTqf1+Ipbv9lA97GSKXF3DCpizD77mPAovwSB9qDduDoHWd+Aj+4nCGpPrQQKVAzWOOPH2pGxDDxg+GI4tA1lU51ReUxjJ+xPRN6eUyiCkQoD9PC5GjRSTlpECkfAzvjwf20EH2VwlqijVi/o= 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 AM6PR0402MB3431.eurprd04.prod.outlook.com (2603:10a6:209:e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.19; Fri, 11 Mar 2022 12:55:05 +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; Fri, 11 Mar 2022 12:55:05 +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 v4 5/8] dpaa2-mac: retrieve API version and detect features Date: Fri, 11 Mar 2022 14:54:34 +0200 Message-Id: <20220311125437.3854483-6-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220311125437.3854483-1-ioana.ciornei@nxp.com> References: <20220311125437.3854483-1-ioana.ciornei@nxp.com> X-ClientProxiedBy: AM5PR0402CA0014.eurprd04.prod.outlook.com (2603:10a6:203:90::24) 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: 316b5720-993b-4696-25c0-08da035e5d66 X-MS-TrafficTypeDiagnostic: AM6PR0402MB3431: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: 9kOOivPZGaKXOhSLwXAXWHfalRDlVyfLWfl9u6jSvoBGtTGT7p5AhE7J0+5TI3fuuZLCN0+0geQUCFtMrqFbTKP6UJqWsLCZ9/7yLfgGdzdUTgSNT/FT4Lu4js7umLwspLBh4tdfSOsUyRGGN5uhnEGSCfuWxFR3ARP/qVhakc5uhkhLEofUnETbxqmavtGhqa7dNOToO1ReLi/hQtBQ9JX8e4b4IpLT3dWwGtt0cr/r53iY0jyFPdyUEAlu7LwsgZeP2tJ83gJG2aIVK+rc25OryrDupjF6sE0vSYbMdJCcT43gWjEt8AJegoGtDm9srBod9p6+A1whWz6kvZ49054s5UikcmJC9qIN2lZk/V5PPhrM364bG/oobF0EVpYlwY5hgfzn9+yc3aMFePfW2Q2ESCMQdNXJVd6+oZ3pUEPhxooRZr6u0cTBFE9M6pIT3nv9oQLB2BkXF5z3Qubzfzt3zUk4UgviED3p8JHUx8uBdG+fnCSypr+lJ5iW7qlmpRH86Djqqitl8rBtjSvfYO6KLlBrZlR9a4iTV/ZU0ajmrqrIZ+qeWUJQzywyCu5hxKzVGG9r7g8dAnhG5fQQw/KQNaUEm5MyAWbjy4GhNbGWJty+9naqxAy34XxIFa/+CPl6taLrWLByrgcS2Worz7wXGMZbb4Q8WT5vH7Ol7ZOpdkQ1Ern+0xp8/gVdgztIS9eh6kJm3Vbm+9oQj0z3kg== 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)(8676002)(66946007)(7416002)(5660300002)(6486002)(8936002)(44832011)(508600001)(66476007)(66556008)(316002)(4326008)(83380400001)(1076003)(2616005)(6512007)(52116002)(6666004)(6506007)(2906002)(26005)(186003)(86362001)(36756003)(38350700002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sJLgJCTEWTIO1707TcCSiXkGs+q6Iu5INbweocHKfLN5mvTsMZRvprjN8OWaFg1LsrfYl/6SUGjvYpzIkAewKu1NDyW+IwhtXm7qVtfWIKecnKbFNc6+HRWMXCnCzx9EnwvTtLIRx2rLhITuY4ES1nOmzo9n7TkY1Xa2TMoEJZVUwlhiFAgzptTu5e7mDd/9g98rCZahmUSDUCOacr9B3pnrtVPdCM03/BfE3lATPND2zw+TIzvdaZApX/qkj5mx84kLQz7pknhvlfPlhBWkAm0/wsH/IoHDTS4jhuE2ji4tjlE68VWadEoP3KL+mJ+lBMemyiyYmwP9awkvU649bJhExsFDf9al0p+OpLGBrMewR8OaIghKKc84L6Ocwy/mZyWfnTRpwjCssggIzzVndCuuB9rkz2xbliTu09xXUPvt5L09woH6LO95XMak1xZvbvgh+uFydZyahSYtuRqDIkoKiRr91KSiHrNfkMHNTVxKXjDjkBGuxs/fXYLl8+8z3dh3ncRbOYvx3NiFicKkiNNKZA3Er5J2lxHGQLw0oY3DRJkhn2x6SRMprh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Yss= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 316b5720-993b-4696-25c0-08da035e5d66 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2022 12:55:05.7005 (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: JETLV/zXchirmZpbLxEPZ0sYjwrH1atFiNyrxX37NXLdt70Egc3x2uYgUmEfvuwZuQkPEjddRnGfOLo0dKmCJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3431 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220311_050929_488022_63A42C26 X-CRM114-Status: GOOD ( 12.29 ) 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 Changes in v3: - none Changes in v4: - 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;