From patchwork Tue Apr 9 12:57:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13622477 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 4F7AFCD129C for ; Tue, 9 Apr 2024 12:59:25 +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=nuTmGGQtVFSwFhYBZRnqccdMgMO0olpCQkm+/RhU/A0=; b=bFUOarHxfda+q4 EYmsyE1C6ryEPDobEhVFP0pKhLDoKQhezILfGdCTjI91t356hWoZEWHduc+Ji2zj+RcsWE9HqSIJs GBFY0hqUdbY93/+n95ABFagJPIIOZoBMznyE73/8tHDGUCMEf/GJVeylK8fR3qT1H7ZKTjqPHGWpa UPF0qoICL7XhRl6zqYtLxd5DfbST3WZopigC58oaUbCXpNg/4orYDSSvHki8R3BOnVatwe36J3LpS 0ZQg8sw6CLZQIoa6UfJmPOWkb7GW1cUVbQxqoC3pP02E4Kj9spaojvDJ3zxlqrgjDkrEKEUOWVlnk tRbd6k8BZDSZKgGYg+AA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruB47-000000020Rb-1AuM; Tue, 09 Apr 2024 12:59:08 +0000 Received: from mail-ej1-f42.google.com ([209.85.218.42]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruB3b-0000000201E-0Y0i; Tue, 09 Apr 2024 12:58:41 +0000 Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a51d3193e54so260786266b.2; Tue, 09 Apr 2024 05:58:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712667513; x=1713272313; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bGHHnAjzHXOHKZAHNwNt7Xm//rgfn0lSUB+nM5VysgU=; b=lZSNbR/coIge5VMg5F6Yf23Yxw61bF9Hju7xpAHuN/HikKukDSF+cwVYWQtqqZAJ6+ RAaoKUxtjcAJFTnlEpiJ2TLkYJnx7tCZfpw0AzTv6e6gbVgZm80Dt+V1kliRGjfrwcQ3 Vt3fVaqSDNcfiMKy4zmWZp6Lc/1+58QIPSr+cW7TqEzKYzcdndc+BTnQnAbkHDfdFORm UMSSw1jHMxmX1h3xIsBSi55y2EvcRKFRAnkbPWXxqNck+5Rk55hvUMxz9/IgrKATuaxx eQtK1Yy02dYvn1CMB2QFJpGCN31jyF854AfvscM06E6Oeman/vGZHj/o6z1PQE+RDP/W rj8g== X-Forwarded-Encrypted: i=1; AJvYcCXsi1+L0Nr63JBIOyaS1nvogSUx9izzv7mWTWPoFt333O8tWEjU7JxI+iFkKpKV6fTr5WOIbB0IrG6VCpRicsNndjYBFKSntG8vOEs2aIGDfvZ0gobi5UlYIdyhPsUQ83FbnGHrKKiYEHt2dQD+JOKoCUiuUlxrzPfDJMWp5sC3QzShIvPquENQucW/r2StYThj+08CaKDZYHE2d7+Q49h5LEeLXB+kmR3O56p8NCNWBQ== X-Gm-Message-State: AOJu0YzEHwOjuJ4maaQsXoufs25Vjmh7ELHHhdYgkqqV/Tm+5nCEdkOe PZ8bRsbhJqLE6m5RDXzpLJxTuUfjcoQMmzrisk/fXxgMzjwfnxad X-Google-Smtp-Source: AGHT+IGMgSFXt7t2xIbiDfP6KwVGUdieuhC7/Y1prTMT8Szxp9BfUspk13DMg+jmJkRrU6tRzs6JxA== X-Received: by 2002:a17:907:1c1f:b0:a51:d1f6:393b with SMTP id nc31-20020a1709071c1f00b00a51d1f6393bmr4812180ejc.40.1712667512608; Tue, 09 Apr 2024 05:58:32 -0700 (PDT) Received: from localhost (fwdproxy-lla-120.fbsv.net. [2a03:2880:30ff:78::face:b00c]) by smtp.gmail.com with ESMTPSA id hx17-20020a170906847100b00a4e393b6349sm5669943ejc.5.2024.04.09.05.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 05:58:32 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org, Matthias Brugger , AngeloGioacchino Del Regno , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next v4 4/9] net: mediatek: mtk_eth_sock: allocate dummy net_device dynamically Date: Tue, 9 Apr 2024 05:57:18 -0700 Message-ID: <20240409125738.1824983-5-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240409125738.1824983-1-leitao@debian.org> References: <20240409125738.1824983-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240409_055835_212840_AE5B8F40 X-CRM114-Status: GOOD ( 15.63 ) 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 Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1]. Un-embed the net_device from the private struct by converting it into a pointer. Then use the leverage the new alloc_netdev_dummy() helper to allocate and initialize dummy devices. [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ Signed-off-by: Breno Leitao --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 17 +++++++++++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index caa13b9cedff..d7a96dc11c07 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1710,7 +1710,7 @@ static struct page_pool *mtk_create_page_pool(struct mtk_eth *eth, if (IS_ERR(pp)) return pp; - err = __xdp_rxq_info_reg(xdp_q, ð->dummy_dev, id, + err = __xdp_rxq_info_reg(xdp_q, eth->dummy_dev, id, eth->rx_napi.napi_id, PAGE_SIZE); if (err < 0) goto err_free_pp; @@ -4188,6 +4188,8 @@ static int mtk_free_dev(struct mtk_eth *eth) metadata_dst_free(eth->dsa_meta[i]); } + free_netdev(eth->dummy_dev); + return 0; } @@ -4983,9 +4985,14 @@ static int mtk_probe(struct platform_device *pdev) /* we run 2 devices on the same DMA ring so we need a dummy device * for NAPI to work */ - init_dummy_netdev(ð->dummy_dev); - netif_napi_add(ð->dummy_dev, ð->tx_napi, mtk_napi_tx); - netif_napi_add(ð->dummy_dev, ð->rx_napi, mtk_napi_rx); + eth->dummy_dev = alloc_netdev_dummy(0); + if (!eth->dummy_dev) { + err = -ENOMEM; + dev_err(eth->dev, "failed to allocated dummy device\n"); + goto err_unreg_netdev; + } + netif_napi_add(eth->dummy_dev, ð->tx_napi, mtk_napi_tx); + netif_napi_add(eth->dummy_dev, ð->rx_napi, mtk_napi_rx); platform_set_drvdata(pdev, eth); schedule_delayed_work(ð->reset.monitor_work, @@ -4993,6 +5000,8 @@ static int mtk_probe(struct platform_device *pdev) return 0; +err_unreg_netdev: + mtk_unreg_dev(eth); err_deinit_ppe: mtk_ppe_deinit(eth); mtk_mdio_cleanup(eth); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 9ae3b8a71d0e..723fc637027c 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -1242,7 +1242,7 @@ struct mtk_eth { spinlock_t page_lock; spinlock_t tx_irq_lock; spinlock_t rx_irq_lock; - struct net_device dummy_dev; + struct net_device *dummy_dev; struct net_device *netdev[MTK_MAX_DEVS]; struct mtk_mac *mac[MTK_MAX_DEVS]; int irq[3];