From patchwork Tue Jan 30 23:13:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 194383 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1555341dyb; Tue, 30 Jan 2024 15:18:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEF1iQ1ohnY2fgUJ9t6SvQ0X+UJsclm508NFgtv/asusZ5E7wKBOavAsjdYg4VePqLupvTJ X-Received: by 2002:aa7:c61a:0:b0:55e:b155:260b with SMTP id h26-20020aa7c61a000000b0055eb155260bmr5886922edq.33.1706656690674; Tue, 30 Jan 2024 15:18:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706656690; cv=pass; d=google.com; s=arc-20160816; b=T0nO+m/8fciovZXlyrEK7+4EoZ/qbGpCoyKePJL9WQyF7pzjLa6G9ObIbXdTsfZLqX 3/9WaMBzOxDpCJXZ4sg1WejykZkcjc74dcUg/J+YsRjPyrEYHzdPwxvetaQQgJf0aWNz LUEE8W6hq/XT3CaSbt1hjZMa4jNyvg2Vn7mY6Jqbvw53nBQkyuiDZoMkm8GKjtBsxYdP SKT43ajEwfzy+adl2uVVryD49p9OTnUuJK1n3gsFY/EdT8w26gtkMkMzYd48rQPInEel I3X1KxhYhIhLW6980ONaRnHUa4lyf+begQ8O1qx67W9BBlOmw3RKA5KyTCsuKcUCCcfA 1ukw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=Cmf6IXAOX4sOtXhjJ9bPGawS7c4pqgm3fjtDF1AA0Pw=; fh=BU4RSkB+Q4EYbEXM8vpZ5rnbcSjfYSNW9lfntnZ9xiw=; b=oJNnd84nonFaqsnkf2QEZaLvyVNB/+CN9BR90YuqJdNoOLOXnrrTurt/OhQWg/1cZq /JcH/rahWX2T23L6G35vhj1ID3G6QbQ4zXQWXQHAzk75kN8ZnAr2sBVLiuvt+Yos8Urx r74H6wncojQGXIIzaL2C60qq7tAOIsMAcq80RTwPZ7FqKwFs6fwBk++9+Blz2hBgR1g6 uG9Hw/IDPKCuOHQ1aM5XR4lSWJiGsLDXSPOizH0FLmacIgQmc39QmCCqsvm7cMQs9JDC ZJLbaWalsE7vuFprr+haolcMg2irVJWewOkjX2MG5815eDfuxUlDMl/TRNRkd1a3vAu8 oZoQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hTq83wgH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-45461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45461-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id w21-20020aa7dcd5000000b0055f5c0d3f29si508951edu.598.2024.01.30.15.18.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 15:18:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hTq83wgH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-45461-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45461-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1E9D01F2205C for ; Tue, 30 Jan 2024 23:18:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D28B584A50; Tue, 30 Jan 2024 23:14:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hTq83wgH" Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 9AA9384A29; Tue, 30 Jan 2024 23:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706656487; cv=none; b=qEU9fhPcL40J82aX2eUxT+vh+11irFf7Kvv5TePbQlHBelvVUauB3JumLqQyh64fgVDqAg7oe+C9NW05wwEnsgUTfsX+R+oEyPrDxEp/N2OVeNLO6m/VmID4gToV9Mv/LlJg2H8ZpoPvsyi96vt4Amko8fVd+I4Opt+d+42BKFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706656487; c=relaxed/simple; bh=BG5ESZ6S3xcp89l1N+mS5Clo2oqsEkk72iSZeToz9kM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Sewm4FsRPmP7i2mxhCNjt85stdigPecgKrFgSkRPrX51wipW1eRMuocflhtQViZdkvXVROVB76SaSdW6TXPXtf1es61pz5lhNhJ9Y3/tl17ekVulKodyP/4a3e6B3Sdd7FV6ptaNm5Nd5p3PVh1f7CqfDnO71FmKpKrq1gFiCKI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hTq83wgH; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d731314e67so21933725ad.1; Tue, 30 Jan 2024 15:14:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706656485; x=1707261285; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Cmf6IXAOX4sOtXhjJ9bPGawS7c4pqgm3fjtDF1AA0Pw=; b=hTq83wgHCQC4CmXVm9hxyZNKqilf49H52VEHD7dQOT5QqZ7oA/mWv2VpUQLZWcS/SM 86/2HZbEfwoZUCYCbsBh6+KqWu0w0w9U7wGOmZ8jJVUURRD3P9ZGo2WWY7dV9YUUDcFY k/F1ye6oZ//fB2ux9NhLhH3n095g+u5Q2HgxjRnDKI1WWU1yTQHGbax/susytkxAXgwl S1QO1O/BvDbiTXrl7Xcx5qk/80Wk4ssacUs+EkC5mYpZEkjSNh2UNSUZU+0qeU5LBB12 wM0bfdDrMQ8+UC1DNC+XToiPK+54wwDb6bsEq/bB/T/vd18f2dX+lYVtQMSxQHLEBPGy GfHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706656485; x=1707261285; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cmf6IXAOX4sOtXhjJ9bPGawS7c4pqgm3fjtDF1AA0Pw=; b=U9Xkswov4NC18cgH718huhNHJ6FBPKS4rvK7sLCX6s+ne5J2izlfTTcHL6h6mLrKOm uV42fqt5504v8NuzWuFyoMFNdhFHRierAs2x5pTtpqb5OMCilruK1VWPkcH5hW5rWjfM wdaPObDTaC6yysR2cM27sbT1rHBuTkCx8kOOvMnQlGFiZ932HZFnKpUNvWZQeZIePGzm A0vgpBk+P3v6lzL7374A9HjTkmyQzoOHwad5bjcsdrVEyBiCgfFaQFPK/SOrkybx0SwL Ns5D+fnjYswTClJu9gpyb80aiGLZgueKC3ypFLZFW70uQCRtU93V3x5WRzVigS9/Ir6F rzFw== X-Gm-Message-State: AOJu0YzF02ZU3jDnZIZxZLVlqp+i4eJwo4KD+1XwgoNUpnSCuXSwjLxD 9CgkuCVv/Qe/LcXCFWvglOhnBFh/MC9mUvD+91VwuQ17YuZ2xXvo X-Received: by 2002:a17:903:11cf:b0:1d8:ac08:3cb7 with SMTP id q15-20020a17090311cf00b001d8ac083cb7mr52810plh.33.1706656484948; Tue, 30 Jan 2024 15:14:44 -0800 (PST) Received: from tresc054937.tre-sc.gov.br ([2804:c:204:200:2be:43ff:febc:c2fb]) by smtp.gmail.com with ESMTPSA id jx2-20020a170903138200b001d8f251c8b2sm3473203plb.221.2024.01.30.15.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 15:14:44 -0800 (PST) From: Luiz Angelo Daros de Luca Date: Tue, 30 Jan 2024 20:13:30 -0300 Subject: [PATCH net-next v5 11/11] net: dsa: realtek: embed dsa_switch into realtek_priv Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240130-realtek_reverse-v5-11-ecafd9283a07@gmail.com> References: <20240130-realtek_reverse-v5-0-ecafd9283a07@gmail.com> In-Reply-To: <20240130-realtek_reverse-v5-0-ecafd9283a07@gmail.com> To: Linus Walleij , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Luiz Angelo Daros de Luca X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=5204; i=luizluca@gmail.com; h=from:subject:message-id; bh=BG5ESZ6S3xcp89l1N+mS5Clo2oqsEkk72iSZeToz9kM=; b=owEBbQGS/pANAwAIAbsR27rRBztWAcsmYgBluYKxnBF4fse//mhC/q5GitrBp5Vnid95kwo0N dDwY2RkwciJATMEAAEIAB0WIQQRByhHhc1bOhL6L/i7Edu60Qc7VgUCZbmCsQAKCRC7Edu60Qc7 Vi+nB/4zPlKfX2EjMeiuYd9mmY1iicYxLG5bzkJLKDPKw9NyqSnlouwY2KGAUk24+jWjtnT2mvf /gO+5+bk0kfBuifuYDXgULj0YiBRp2xAohla4ccECAxrdGrR0qKd/cPyLZtFeY9ULcxcbI6SnTd CcavS3u2F3ypfcDzAd27DQqxKtPyPlKVVgeqL7KUGjaZPPsnmeqwGjNVyDv8se5IHKoS8m/IGii +KvV8+ld1JAvgApXrlL9G8UU9ohuShnOd7nzDMb2KjCMjYAWKKEZPAlf3bz5bFJcQc7K1UVxH86 ogcqtJ9MHcOcq6UemIUaCu9JMPUyZi6P1ipJAI759lXe6K3b X-Developer-Key: i=luizluca@gmail.com; a=openpgp; fpr=1107284785CD5B3A12FA2FF8BB11DBBAD1073B56 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789559245650937664 X-GMAIL-MSGID: 1789559245650937664 To eliminate the need for a second memory allocation for dsa_switch, it has been embedded within realtek_priv. Suggested-by: Alvin Šipraga Signed-off-by: Luiz Angelo Daros de Luca Reviewed-by: Vladimir Oltean --- drivers/net/dsa/realtek/realtek.h | 2 +- drivers/net/dsa/realtek/rtl8365mb.c | 12 ++++++------ drivers/net/dsa/realtek/rtl8366rb.c | 2 +- drivers/net/dsa/realtek/rtl83xx.c | 18 +++++++----------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h index 864bb9a88f14..b80bfde1ad04 100644 --- a/drivers/net/dsa/realtek/realtek.h +++ b/drivers/net/dsa/realtek/realtek.h @@ -61,7 +61,7 @@ struct realtek_priv { const struct realtek_variant *variant; spinlock_t lock; /* Locks around command writes */ - struct dsa_switch *ds; + struct dsa_switch ds; struct irq_domain *irqdomain; bool leds_disabled; diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c index 778a962727ab..9066e34e9ace 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -880,7 +880,7 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port, if (!extint) return -ENODEV; - dp = dsa_to_port(priv->ds, port); + dp = dsa_to_port(&priv->ds, port); dn = dp->dn; /* Set the RGMII TX/RX delay @@ -1543,7 +1543,7 @@ static void rtl8365mb_stats_setup(struct realtek_priv *priv) for (i = 0; i < priv->num_ports; i++) { struct rtl8365mb_port *p = &mb->ports[i]; - if (dsa_is_unused_port(priv->ds, i)) + if (dsa_is_unused_port(&priv->ds, i)) continue; /* Per-port spinlock to protect the stats64 data */ @@ -1564,7 +1564,7 @@ static void rtl8365mb_stats_teardown(struct realtek_priv *priv) for (i = 0; i < priv->num_ports; i++) { struct rtl8365mb_port *p = &mb->ports[i]; - if (dsa_is_unused_port(priv->ds, i)) + if (dsa_is_unused_port(&priv->ds, i)) continue; cancel_delayed_work_sync(&p->mib_work); @@ -1963,7 +1963,7 @@ static int rtl8365mb_setup(struct dsa_switch *ds) dev_info(priv->dev, "no interrupt support\n"); /* Configure CPU tagging */ - dsa_switch_for_each_cpu_port(cpu_dp, priv->ds) { + dsa_switch_for_each_cpu_port(cpu_dp, &priv->ds) { cpu->mask |= BIT(cpu_dp->index); if (cpu->trap_port == RTL8365MB_MAX_NUM_PORTS) @@ -1978,7 +1978,7 @@ static int rtl8365mb_setup(struct dsa_switch *ds) for (i = 0; i < priv->num_ports; i++) { struct rtl8365mb_port *p = &mb->ports[i]; - if (dsa_is_unused_port(priv->ds, i)) + if (dsa_is_unused_port(&priv->ds, i)) continue; /* Forward only to the CPU */ @@ -1995,7 +1995,7 @@ static int rtl8365mb_setup(struct dsa_switch *ds) * ports will still forward frames to the CPU despite being * administratively down by default. */ - rtl8365mb_port_stp_state_set(priv->ds, i, BR_STATE_DISABLED); + rtl8365mb_port_stp_state_set(&priv->ds, i, BR_STATE_DISABLED); /* Set up per-port private data */ p->priv = priv; diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c index 54eff9cd0c03..cdc37be1ed2c 100644 --- a/drivers/net/dsa/realtek/rtl8366rb.c +++ b/drivers/net/dsa/realtek/rtl8366rb.c @@ -1675,7 +1675,7 @@ static int rtl8366rb_set_mc_index(struct realtek_priv *priv, int port, int index * not drop any untagged or C-tagged frames. Make sure to update the * filtering setting. */ - if (dsa_port_is_vlan_filtering(dsa_to_port(priv->ds, port))) + if (dsa_port_is_vlan_filtering(dsa_to_port(&priv->ds, port))) ret = rtl8366rb_drop_untagged(priv, port, !pvid_enabled); return ret; diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c index aa998e15c42b..f65e47339d5b 100644 --- a/drivers/net/dsa/realtek/rtl83xx.c +++ b/drivers/net/dsa/realtek/rtl83xx.c @@ -226,16 +226,12 @@ int rtl83xx_register_switch(struct realtek_priv *priv) return ret; } - priv->ds = devm_kzalloc(priv->dev, sizeof(*priv->ds), GFP_KERNEL); - if (!priv->ds) - return -ENOMEM; + priv->ds.priv = priv; + priv->ds.dev = priv->dev; + priv->ds.ops = priv->variant->ds_ops; + priv->ds.num_ports = priv->num_ports; - priv->ds->priv = priv; - priv->ds->dev = priv->dev; - priv->ds->ops = priv->variant->ds_ops; - priv->ds->num_ports = priv->num_ports; - - ret = dsa_register_switch(priv->ds); + ret = dsa_register_switch(&priv->ds); if (ret) { dev_err_probe(priv->dev, ret, "unable to register switch\n"); return ret; @@ -256,7 +252,7 @@ EXPORT_SYMBOL_NS_GPL(rtl83xx_register_switch, REALTEK_DSA); */ void rtl83xx_unregister_switch(struct realtek_priv *priv) { - dsa_unregister_switch(priv->ds); + dsa_unregister_switch(&priv->ds); } EXPORT_SYMBOL_NS_GPL(rtl83xx_unregister_switch, REALTEK_DSA); @@ -273,7 +269,7 @@ EXPORT_SYMBOL_NS_GPL(rtl83xx_unregister_switch, REALTEK_DSA); */ void rtl83xx_shutdown(struct realtek_priv *priv) { - dsa_switch_shutdown(priv->ds); + dsa_switch_shutdown(&priv->ds); dev_set_drvdata(priv->dev, NULL); }