Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2380784rdh; Wed, 27 Sep 2023 00:14:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnnloZnD4amHh8ts2qhaIjsoiJ0OPmoDoX9nxui7/IPPl7ld3zFXUFlr/TsrwrnDjvvRNI X-Received: by 2002:a17:90a:5915:b0:267:faf1:21bb with SMTP id k21-20020a17090a591500b00267faf121bbmr816165pji.15.1695798841147; Wed, 27 Sep 2023 00:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695798841; cv=none; d=google.com; s=arc-20160816; b=YPJV795llQVBI/DAQ0S9wxWKzq2t0C0WIzmPx/d6B18Y8nBeno3m4BxpAvH4hJeGiF piiCQjxM318qEC7CZ5VH6+3KTZ7WVnDsPIFUYfWrwyiaj+is/e3/ONgiWvKNYoubGIr6 LYA/+7MPX7ukHhboNINt4UwBHA85KasOaF0PE5yjn+Fp/6iT7Lmnkgy4/ZAUMmc8qgwR YyzXLWEzuLxdKChgCPz1vyQiFD1QqMZtzns5MRZYBunKEMSW13rbHklzXquQYoPacvFJ K1tSMMgMV+xnm19jvxEpGV1ApC3xe5zSGbT2/pwtW6wT5faTGnzXbBzYeW/piaf7azoV POag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c/iSvXWWLey35xMebjWWxYpSfWdN2RhpdyVtmLhr4RI=; fh=mQgLd3XuoBWeVfqGWAvlwRf/Gj+UVJ5qInbEaNM08Pc=; b=fns9cqt3Ly02XiIHUGpF1lRir+nEH3Jh5fH5UaDdTf1gOsU9KmhGKnPJwu9TgopaDe gY2jX0tvthCB8xHHYPXPeBWAiUba9ii16sshbhwJcx8nwJ4pkHg/AA6wQvm/fbecC7+H 5bSQXtYvbRRIeWE+gcbs7V+L5lW1EZZ4WgWb0m9arzis7QenfIQtl+LephjSyJTD5O3G tyP/DAwRvSjXDfNCMmawnHQgjXuNqVU/j997DVIb7hWUV43DNbDLwanyU3SFEcXtvi0k u3DnqAkhJ8v8L0UzTYUA3kGtipZe1crBfS6Blp9p+J5h0XGdE1N3rMbk7ZuLp2mYkHF4 qVwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RESCVAJP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id x5-20020a17090a8a8500b0027740192bc9si8712763pjn.152.2023.09.27.00.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 00:14:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RESCVAJP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9FC4B809342D; Tue, 26 Sep 2023 11:28:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235534AbjIZS2R (ORCPT + 99 others); Tue, 26 Sep 2023 14:28:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235516AbjIZS2M (ORCPT ); Tue, 26 Sep 2023 14:28:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CC601AE for ; Tue, 26 Sep 2023 11:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695752839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c/iSvXWWLey35xMebjWWxYpSfWdN2RhpdyVtmLhr4RI=; b=RESCVAJPft5Rg1nOK3i4nwQ0jDGcAiAVmF4Xpe2BZSzLQ3t1nQ8S6hVyZ4jDMUK5pFbRXJ NGNJlv/wYgN3HbjcmafeXi+RRO9VgRMXDWNsPw/QjwXlu9XXJBs+sqOWEzFMSs7ssZjhlJ gyxOjZANvPw1TUnvp3o+U1qneoyEt9w= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-14-g5Avd8A0P5OjiX21lj9-wA-1; Tue, 26 Sep 2023 14:27:15 -0400 X-MC-Unique: g5Avd8A0P5OjiX21lj9-wA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 65F5285A5BE; Tue, 26 Sep 2023 18:27:15 +0000 (UTC) Received: from p1.luc.cera.cz (unknown [10.45.225.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4BA040C6EA8; Tue, 26 Sep 2023 18:27:13 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: poros@redhat.com, mschmidt@redhat.com, jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/9] i40e: Remove back pointer from i40e_hw structure Date: Tue, 26 Sep 2023 20:27:02 +0200 Message-ID: <20230926182710.2517901-2-ivecera@redhat.com> In-Reply-To: <20230926182710.2517901-1-ivecera@redhat.com> References: <20230926182710.2517901-1-ivecera@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 26 Sep 2023 11:28:24 -0700 (PDT) The .back field placed in i40e_hw is used to get pointer to i40e_pf instance but it is not necessary as the i40e_hw is a part of i40e_pf and containerof macro can be used to obtain the pointer to i40e_pf. Remove .back field from i40e_hw structure, introduce i40e_hw_to_pf() and i40e_hw_to_dev() helpers and use them. Signed-off-by: Ivan Vecera --- drivers/net/ethernet/intel/i40e/i40e.h | 11 ++++++++++ drivers/net/ethernet/intel/i40e/i40e_main.c | 22 ++++++++++++++------ drivers/net/ethernet/intel/i40e/i40e_osdep.h | 5 ++++- drivers/net/ethernet/intel/i40e/i40e_type.h | 1 - 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index 6e310a539467..722b32b86e0f 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -1321,4 +1321,15 @@ static inline u32 i40e_is_tc_mqprio_enabled(struct i40e_pf *pf) return pf->flags & I40E_FLAG_TC_MQPRIO; } +/** + * i40e_hw_to_dev - get pf pointer from the hardware structure + * @hw: pointer to the device HW structure + **/ +static inline struct i40e_pf *i40e_hw_to_pf(struct i40e_hw *hw) +{ + return container_of(hw, struct i40e_pf, hw); +} + +struct device *i40e_hw_to_dev(struct i40e_hw *hw); + #endif /* _I40E_H_ */ diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 00ca2b88165c..c19d1b4cc32b 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -119,6 +119,17 @@ static void netdev_hw_addr_refcnt(struct i40e_mac_filter *f, } } +/** + * i40e_hw_to_dev - get device pointer from the hardware structure + * @hw: pointer to the device HW structure + **/ +struct device *i40e_hw_to_dev(struct i40e_hw *hw) +{ + struct i40e_pf *pf = i40e_hw_to_pf(hw); + + return &pf->pdev->dev; +} + /** * i40e_allocate_dma_mem_d - OS specific memory alloc for shared code * @hw: pointer to the HW structure @@ -129,7 +140,7 @@ static void netdev_hw_addr_refcnt(struct i40e_mac_filter *f, int i40e_allocate_dma_mem_d(struct i40e_hw *hw, struct i40e_dma_mem *mem, u64 size, u32 alignment) { - struct i40e_pf *pf = (struct i40e_pf *)hw->back; + struct i40e_pf *pf = i40e_hw_to_pf(hw); mem->size = ALIGN(size, alignment); mem->va = dma_alloc_coherent(&pf->pdev->dev, mem->size, &mem->pa, @@ -147,7 +158,7 @@ int i40e_allocate_dma_mem_d(struct i40e_hw *hw, struct i40e_dma_mem *mem, **/ int i40e_free_dma_mem_d(struct i40e_hw *hw, struct i40e_dma_mem *mem) { - struct i40e_pf *pf = (struct i40e_pf *)hw->back; + struct i40e_pf *pf = i40e_hw_to_pf(hw); dma_free_coherent(&pf->pdev->dev, mem->size, mem->va, mem->pa); mem->va = NULL; @@ -15623,10 +15634,10 @@ static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw) **/ static inline void i40e_set_subsystem_device_id(struct i40e_hw *hw) { - struct pci_dev *pdev = ((struct i40e_pf *)hw->back)->pdev; + struct i40e_pf *pf = i40e_hw_to_pf(hw); - hw->subsystem_device_id = pdev->subsystem_device ? - pdev->subsystem_device : + hw->subsystem_device_id = pf->pdev->subsystem_device ? + pf->pdev->subsystem_device : (ushort)(rd32(hw, I40E_PFPCI_SUBSYSID) & USHRT_MAX); } @@ -15696,7 +15707,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) set_bit(__I40E_DOWN, pf->state); hw = &pf->hw; - hw->back = pf; pf->ioremap_len = min_t(int, pci_resource_len(pdev, 0), I40E_MAX_CSR_SPACE); diff --git a/drivers/net/ethernet/intel/i40e/i40e_osdep.h b/drivers/net/ethernet/intel/i40e/i40e_osdep.h index 2bd4de03dafa..dc5096d4ba70 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_osdep.h +++ b/drivers/net/ethernet/intel/i40e/i40e_osdep.h @@ -18,9 +18,12 @@ * actual OS primitives */ +struct i40e_hw; +struct device *i40e_hw_to_dev(struct i40e_hw *hw); + #define hw_dbg(hw, S, A...) \ do { \ - dev_dbg(&((struct i40e_pf *)hw->back)->pdev->dev, S, ##A); \ + dev_dbg(i40e_hw_to_dev(hw), S, ##A); \ } while (0) #define wr32(a, reg, value) writel((value), ((a)->hw_addr + (reg))) diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h index 232131bedc3e..658bc8913278 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_type.h +++ b/drivers/net/ethernet/intel/i40e/i40e_type.h @@ -525,7 +525,6 @@ struct i40e_dcbx_config { /* Port hardware description */ struct i40e_hw { u8 __iomem *hw_addr; - void *back; /* subsystem structs */ struct i40e_phy_info phy; -- 2.41.0