Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1957961lqe; Tue, 9 Apr 2024 05:59:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWaAha/rCW1/iZtwpLnnJALc+KF545aNpLIGKnzwHpt5ZzVvIAKdQANU6oA3pIOYbuMeJ52mRAuIzD3PB3rmWf9lGjOvs2W4dph5DNxaQ== X-Google-Smtp-Source: AGHT+IEM7ABuvcC3gV/wDDWnju/QOBs26hisgi41W/m/7/ldk310917sbJFypz3UkYLsdNFLqHiP X-Received: by 2002:a05:622a:1aa6:b0:432:e7ae:16ec with SMTP id s38-20020a05622a1aa600b00432e7ae16ecmr14798823qtc.43.1712667592975; Tue, 09 Apr 2024 05:59:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712667592; cv=pass; d=google.com; s=arc-20160816; b=PhxNBhoZmqZSrb2Q0N/xZ8xBPfN5vpi45fd0BtAs/Jed+tbEWMkqvNCqdgxZJXYw1A YXVQuSLWINw3rMJ+Lbkl2uH0xgJGE0UGnyn+Ec3cPpmcqYckqZX/VVi0pgb4iXNmUl4u tjnQnBttOmvcrmR3dB9mobwkZOMzQoWXSYTVY61xism/imyPAjWUvsYMjkqtWdzKWdHM E0Oadw+r1GSPoRCDNgko1WI40onU6Zc3296M6nVRLlSgDrb/ZO4WsmGNW+ocXns4TeDK 8NCZFngExri196E5mjys1qZickK3q+rmBigmpKj7kt4jScTdgt1Tv7qHv67bcMxRZzhH +JBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=bGHHnAjzHXOHKZAHNwNt7Xm//rgfn0lSUB+nM5VysgU=; fh=+XUdtXJX//aiHkYayI9Z7QY4Lq+Un2YMH7pk/9UJR48=; b=Pv069zSRYq9ovdE8ofLYysW2t00VMh0vCH25n5SkRGpMPqxt2xHD358aXplFVcnIlg j4cOG/Qn5FYrciifUc2oWddaRHRA99Bzh0FHzZ64MlkQZSy9xaLwYA7UQsW3HgifzNsz IT56KZWNW1JbPxYZD3B2hwfWSMBILWb4GfAHisjORJ8BEqcaY19l2unsFvRXbTBriunn AY6eRqtDCT1XkmrNt1WCEyaTfPkWpRO0txwhK6MsoMjK3IScmHg9GqaksbKifmnOvjuV 2qPpUb4NgXjMMRV1L6kqpkVocIDbh7lAQdl6fLVDc+wjgtPv5SOm9fKrFfoY6fNCmD2Q igHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-wireless+bounces-6016-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6016-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w34-20020a05622a192200b0043184988189si10594714qtc.706.2024.04.09.05.59.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 05:59:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6016-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-wireless+bounces-6016-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6016-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B201B1C22C32 for ; Tue, 9 Apr 2024 12:59:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C7AA1304A6; Tue, 9 Apr 2024 12:58:36 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B63412FB2A; Tue, 9 Apr 2024 12:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712667516; cv=none; b=XYxElxyNjKjTwAKSfc5JGXkc+i0davqjUCNmfUpN3zoJpyX/vQqtprzyOSo2/K+CvXokT1Gx1GBMXcOPt6y9yhkqs5XiK4u6iONMhHUVEJTtdBAmQLT+lr6DwawhRJpRVsEWdZ86yZvndWZJ9DqQEa4XYczoOBEEM1344LirJTs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712667516; c=relaxed/simple; bh=thNNGA+Buyv1A48P5cMpc4XXfCvRQSFmpwoRUX9PFQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TsKHlyxwgpSs7Lvqk8MMP41AI4I/aemKZ3FgHXaWIUl/WR61tk2vyDAHl+e2QfNZ8fMc3Z84AoHnaPRhyyXmlLobvBkNE+Ip3kScYZEpwx4jkNAvplRaF2CZGWETyXpEa0f8XYxV3fdyasl24JJYkoQLBgUYDJ3/NSTn46x65Y4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-56e6282dd72so2528791a12.3; 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=VSxZprjEP0h6rTJsNN3e+vqG1PcW1teuThnC0Jz81aMHFFqpGkPggdpEC5jGdrtJTr VGRFCt+EyD3HZKLuEcBCiHvcpPv9VlMrYkqY3lUwDTXalKvz5drkxdjvrPdayhrREG+5 rAT6vXE9UHXdgXf9fi76uc2VpZOyFyF7F7sLzEB8ccMqBmi9UbRqZJ2x7sP0SCrXGaEo micFw6Ot3hgawzAPtTnrOCSi/nrVA+gFWEveQRDp0vTu1cUHYgTIPjM5kgutWaZaMzGf NUkyhvAIOPG99F6Dqeg/I+A/IiEuPf6rjpXW/V/Kr7MdF/PZQxR3t6f/eAK3bpltvBDv 7mOQ== X-Forwarded-Encrypted: i=1; AJvYcCXmuBZycaH496Tie6Cez5jtHWAP8phOxXmfA50yRFUdjoG21jJL81WnTvan6/NH2poO7d3JoYMNOJuYLyZcLgqse8XBSTJpGSGuOcAvMYhKrwhC+THxime1Rvz+nCjYv9iZSAhI4WMPZiwpCzmGxIgn+hzLB94MCkUCPYGMAMlzEVUwlE6QIYFjb7ggUsA4KjA7GO/iAqgec9g= X-Gm-Message-State: AOJu0Yw+wDkTJ2m1MESNQfFVcHazO5OUsePPDcTWm8vOOwGAvp37vthm x4fnXgSYfcrY02ZtvufNwaBlqwgtod3fE3DRE59oiWwGkPUJehzt 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> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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]; -- 2.43.0