From patchwork Fri Jun 17 20:32:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12885994 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 3533CC43334 for ; Fri, 17 Jun 2022 20:36:53 +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=l8fHiWOf/wmEfnwfZ4+iQfycyL62zSXT+wuCBP8IiSg=; b=BQLAxBbPy9xQgO x7+sQIyTPfXfGXzH1kquvKeKqiNJ7DAP7e8NPs0hTnSYMZWPhXzQhvbWEH3W3BkrGOwZMdMaOh2zD ysqmYh3qkLiTwmktY/3NQITxYjsFr9EDXsPOhyPelSFbmQXh0o2na5uLnlhIU+TDwIYDIITc1mgyf NfKguFktqdBCfq4rnB128zyXHF+em0tRL9v5v0UjmpS4yG2MWBDloOzZ11DSdjyaLJ0hJzkswJREJ ucDhhte9WTOjYGvFBcKAe/bVkUJrhVbu/wKuBb2JGEfnKpZxG+8mTMmxxyrKA8/xYP3WneNSCI8l5 6B2o8f5fhWjQT/phK1TQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2Igg-008xyh-Sx; Fri, 17 Jun 2022 20:35:27 +0000 Received: from mail-am6eur05on20610.outbound.protection.outlook.com ([2a01:111:f400:7e1b::610] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2IfG-008xGJ-PN for linux-arm-kernel@lists.infradead.org; Fri, 17 Jun 2022 20:34:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J0YGyp72V0ATCQ1jWW/XdVwPdTuXgQ+DldbIGu3IpVoSA9VbrIpn1p84T2PEd7lQx+Cs/vIJ8CVej3l3/ehbkEoHfqKj5lqE0UYR5kexB7uw9U3zNJach/btlQOat3HOPnwuTWiCaECNBYfSWlHOfqJAhzuvbjrO/+E8ZlSex3hG22DGWgJcthv975q3Zr069oVhlCkIsaDwJowV46nY8yFA632xIBPqkHvKnnudOe0i6gnRXXVtK7c1Aw5UPhrAOQwnmTuNhuaHz82cwWEC8ONXUS3GZpPVJbC5WiOj2wb2YQQYRSli2OZRpu8Rq4G0C+Kh68YSbbuBbpr4o+E8OQ== 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=m68xkMFd/AoKjcLPvwuWpU3iQVhr5xuJq4ud4EtZaIU=; b=cOaSoZ+KkEH2qcZs3+fq70bVDqSRciijQRG1gPGnVS4q7lidal+GI/ZKmXP0sHcsWZC5x2fi+T3FLy6sDcupkKrOsAh0BXhCpCsDtsu/a2oCubmDv/Oulyopyh2zFCx47UpHoTYDN8LmDbcIpmM+aCgX8UjICAUPmrBcAxavSdg2zZmvWilv52qgGc8Z9QKvpOcnwMfOziLIoGrb1utyk8+2wgvXZJtX3CycKp5RTv75122lFIWwfFN7FZNa4cYN5mAJZf5gBZ0HPK+cMimFGKueFa5KXGok2EPYbDRsMjXmn+c8Qmth5ha619eGDvx1wfIo8kQt2QDmQM3iyXNq/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m68xkMFd/AoKjcLPvwuWpU3iQVhr5xuJq4ud4EtZaIU=; b=YzrNtWYIx/yh6FiyRjQv81buZFNWDLb8aURb6m9mDXtmvZtWHT3olU+75uiowueUoQ7A4LtYR6z5B1zxsBvKgkTsDvQ+j4n+Jx/Y1GS7bEyMpkk6KG7hLyjdJG6SNwBoVma8O1QHSbYUEyeSjIzLn+DlIX9dtj1jvhruNM0WYidmIc97J+5mNwYG6yCTQUKOZgGQEMqvua4+r4/OmNB/UFMfuUxXa2sjJ1ohVZJ9ZFTEBrg8Nky7G2hUkUvkZa9P6jck+AtPN1SAw2O/C4g7otRPznXWzwhrhrz99+ZFKvysl0z/6aqPdYziCq1FPnDXa6Ez28Hxi8hC+w/aWFVVbA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from VI1PR03MB4973.eurprd03.prod.outlook.com (2603:10a6:803:c5::12) by DBAPR03MB6438.eurprd03.prod.outlook.com (2603:10a6:10:19f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.16; Fri, 17 Jun 2022 20:33:47 +0000 Received: from VI1PR03MB4973.eurprd03.prod.outlook.com ([fe80::d18f:e481:f1fa:3e8d]) by VI1PR03MB4973.eurprd03.prod.outlook.com ([fe80::d18f:e481:f1fa:3e8d%7]) with mapi id 15.20.5353.016; Fri, 17 Jun 2022 20:33:47 +0000 From: Sean Anderson To: "David S . Miller" , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Paolo Abeni , Russell King , Eric Dumazet , Sean Anderson , Camelia Groza Subject: [PATCH net-next 06/28] net: fman: Store en/disable in mac_device instead of mac_priv_s Date: Fri, 17 Jun 2022 16:32:50 -0400 Message-Id: <20220617203312.3799646-7-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220617203312.3799646-1-sean.anderson@seco.com> References: <20220617203312.3799646-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0384.namprd13.prod.outlook.com (2603:10b6:208:2c0::29) To VI1PR03MB4973.eurprd03.prod.outlook.com (2603:10a6:803:c5::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30eacf82-b138-4235-5955-08da50a0adfe X-MS-TrafficTypeDiagnostic: DBAPR03MB6438: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: EtTVloty4EVAQ2jIWW8Hv+/ExScCSMt+linDGUYtBtnQFb2SGQMwsxB4m12XQTEW81VHM65Q7fMzkmLMaMr1BqJ5DGPrmYk7lmU/+6P9HPUV/ydw9UeYluzU8xuo7fJt3GavGr7LLs/JbYAzakYz6xN4DXwDkDJV+fPGgm/og3o/bpPtw9Y0dZ9ojvN+SJQKvLc7ndHoV3nEdoJZNK9gCAVsx21UFNHNauVl/lK2uruRe0nU45DqWiZp+K6UHb9oGW+7ev9OcAp8zkgdBuJA48VSbcol1BstOqS+cVOYil9Ms1TlJO2oxkpYZcR6NycqqV89mZTOZ78siKQTze85QNXdRbsJhtyqK6Fvfow4U3dKWxF5Pv+5DpW9YjvtGqxeH71qP6NBtdgmieO4Q/KbLhKvEyk6Li7VUq34ZmzfTRMSO8+4NH4t6NRXQzyAQelV7JcACUdXwRB5e+T9M2rLPvU/vTugF1y2WrD892hWbwsbRipZ3SL9GkPlKyLN9zC4Ok6OGCYcTIJ50E+dMTHc3xqsYh4UYELK+UYPU4oqObd3d30L0rrMRkgLq/F6UEbna1IXB2cAkUCJu/KZp6y41h6AzaT0NVaswybBf60X9I0Yb4fqFESz5W/Dymm6Hp7ZxWSR4P+l6cWzQV8nzf+gVxxai83+ACdHxXgYoUhYmUgER8sY4eErSG0t2XOdyqy5ioLXFaBRUbbGieRVSgYZ5A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB4973.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(366004)(44832011)(38350700002)(86362001)(7416002)(38100700002)(186003)(2616005)(5660300002)(6512007)(6486002)(52116002)(2906002)(6506007)(110136005)(8936002)(54906003)(498600001)(316002)(1076003)(66946007)(6666004)(36756003)(8676002)(26005)(83380400001)(4326008)(66556008)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HI9z9PkIh0V6iq/a1hMdhaVBnaK9PmYgHhdEMnk3Ud6rITf9fmGjrMf58iec4Sk7ZOjwuI4LWsMYGQB5L9bJ/D3fI1gaDzOyF1YrNuUQP2S1vUl0h1ZB1S6EziAr1JkLl4EC5TCcNAE06gRI7gSEFZ30m99Vi6vAPSEYlwIhBbLIojhCn9Xb8S6ixNBrfXhEDYt89tO3WyHbsbiT86tnrN21KJ1KbnP1qZQv2ybUyGwSpbJUxuUTfTLX7T0XdCU4TLlEUWghkhgWzX7QbCxi5hDL7Dlc5UKDLBIZQfEp3ZWm7wLrr8fI1bM282GLNWDI5D/JvUW7FkbWu+J/xz9szVsAa6w3tO0Jt7Nbjl5A5bGd1PeHFQWEa6Prjphj5b6/HXpWt4Qs/MygkLl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rSUq2Hq3I3nExwHGo4WVconigYQPFbYMIDtj6BRPF+qhfk8Ge4QJeFm6Tb7UfJJ37bQyqw5LjeizFr3Ub2xj5QO+oQ1gVV/kulAtecWrD8GrIKvwAXwW4MuAcJbK9pkmjLZfFGKH/nwwQfjnn0cpxotpMWYcjIloa5xvNq+/kpI/VWjw4An5fS8IXkvrDrtm9VBeG3yOMpyU+T4loPsVMI417EHRyiKeYGUSuf+da5KTtSgMmt7bExZV84XpN0B+e51U0ukckz+UvSFdSl6PyATB+HZBDiM0Qja8= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30eacf82-b138-4235-5955-08da50a0adfe X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB4973.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2022 20:33:47.1557 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 66fMePz3JmxWsIEZlpfuzOK6ld8aHuDYxVmIzZANlvApXP9HPoDiRnVxH1g6fDZ9ja3M4weOtKw3g7GxKRb4pQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR03MB6438 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220617_133358_892411_70B695CE X-CRM114-Status: GOOD ( 13.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org All macs use the same start/stop functions. The actual mac-specific code lives in enable/disable. Move these functions to an appropriate struct, and inline the phy enable/disable calls to the caller of start/stop. Signed-off-by: Sean Anderson Acked-by: Camelia Groza Tested-by: Camelia Groza --- .../net/ethernet/freescale/dpaa/dpaa_eth.c | 11 +++-- drivers/net/ethernet/freescale/fman/mac.c | 44 +++---------------- drivers/net/ethernet/freescale/fman/mac.h | 4 +- 3 files changed, 15 insertions(+), 44 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 45634579adb6..a548598b2e2d 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -288,9 +288,11 @@ static int dpaa_stop(struct net_device *net_dev) */ msleep(200); - err = mac_dev->stop(mac_dev); + if (mac_dev->phy_dev) + phy_stop(mac_dev->phy_dev); + err = mac_dev->disable(mac_dev->fman_mac); if (err < 0) - netif_err(priv, ifdown, net_dev, "mac_dev->stop() = %d\n", + netif_err(priv, ifdown, net_dev, "mac_dev->disable() = %d\n", err); for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) { @@ -2942,11 +2944,12 @@ static int dpaa_open(struct net_device *net_dev) goto mac_start_failed; } - err = priv->mac_dev->start(mac_dev); + err = priv->mac_dev->enable(mac_dev->fman_mac); if (err < 0) { - netif_err(priv, ifup, net_dev, "mac_dev->start() = %d\n", err); + netif_err(priv, ifup, net_dev, "mac_dev->enable() = %d\n", err); goto mac_start_failed; } + phy_start(priv->mac_dev->phy_dev); netif_tx_start_all_queues(net_dev); diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c index a8d521760ffc..6a4eaca83700 100644 --- a/drivers/net/ethernet/freescale/fman/mac.c +++ b/drivers/net/ethernet/freescale/fman/mac.c @@ -39,9 +39,6 @@ struct mac_priv_s { struct fixed_phy_status *fixed_link; u16 speed; u16 max_speed; - - int (*enable)(struct fman_mac *mac_dev); - int (*disable)(struct fman_mac *mac_dev); }; struct mac_address { @@ -241,29 +238,6 @@ static int memac_initialization(struct mac_device *mac_dev) return err; } -static int start(struct mac_device *mac_dev) -{ - int err; - struct phy_device *phy_dev = mac_dev->phy_dev; - struct mac_priv_s *priv = mac_dev->priv; - - err = priv->enable(mac_dev->fman_mac); - if (!err && phy_dev) - phy_start(phy_dev); - - return err; -} - -static int stop(struct mac_device *mac_dev) -{ - struct mac_priv_s *priv = mac_dev->priv; - - if (mac_dev->phy_dev) - phy_stop(mac_dev->phy_dev); - - return priv->disable(mac_dev->fman_mac); -} - static int set_multi(struct net_device *net_dev, struct mac_device *mac_dev) { struct mac_priv_s *priv; @@ -454,11 +428,9 @@ static void setup_dtsec(struct mac_device *mac_dev) mac_dev->set_allmulti = dtsec_set_allmulti; mac_dev->set_tstamp = dtsec_set_tstamp; mac_dev->set_multi = set_multi; - mac_dev->start = start; - mac_dev->stop = stop; mac_dev->adjust_link = adjust_link_dtsec; - mac_dev->priv->enable = dtsec_enable; - mac_dev->priv->disable = dtsec_disable; + mac_dev->enable = dtsec_enable; + mac_dev->disable = dtsec_disable; } static void setup_tgec(struct mac_device *mac_dev) @@ -474,11 +446,9 @@ static void setup_tgec(struct mac_device *mac_dev) mac_dev->set_allmulti = tgec_set_allmulti; mac_dev->set_tstamp = tgec_set_tstamp; mac_dev->set_multi = set_multi; - mac_dev->start = start; - mac_dev->stop = stop; mac_dev->adjust_link = adjust_link_void; - mac_dev->priv->enable = tgec_enable; - mac_dev->priv->disable = tgec_disable; + mac_dev->enable = tgec_enable; + mac_dev->disable = tgec_disable; } static void setup_memac(struct mac_device *mac_dev) @@ -494,11 +464,9 @@ static void setup_memac(struct mac_device *mac_dev) mac_dev->set_allmulti = memac_set_allmulti; mac_dev->set_tstamp = memac_set_tstamp; mac_dev->set_multi = set_multi; - mac_dev->start = start; - mac_dev->stop = stop; mac_dev->adjust_link = adjust_link_memac; - mac_dev->priv->enable = memac_enable; - mac_dev->priv->disable = memac_disable; + mac_dev->enable = memac_enable; + mac_dev->disable = memac_disable; } #define DTSEC_SUPPORTED \ diff --git a/drivers/net/ethernet/freescale/fman/mac.h b/drivers/net/ethernet/freescale/fman/mac.h index 909faf5fa2fe..95f67b4efb61 100644 --- a/drivers/net/ethernet/freescale/fman/mac.h +++ b/drivers/net/ethernet/freescale/fman/mac.h @@ -36,8 +36,8 @@ struct mac_device { bool allmulti; int (*init)(struct mac_device *mac_dev); - int (*start)(struct mac_device *mac_dev); - int (*stop)(struct mac_device *mac_dev); + int (*enable)(struct fman_mac *mac_dev); + int (*disable)(struct fman_mac *mac_dev); void (*adjust_link)(struct mac_device *mac_dev); int (*set_promisc)(struct fman_mac *mac_dev, bool enable); int (*change_addr)(struct fman_mac *mac_dev, const enet_addr_t *enet_addr);