Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=66.163.191.204 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795965071; b=ksvhYSAOiY2KmFgUhfLQf7xO4KOb5Rhg1K6Y/raCJDBvxM5FgFS74IJgkpBXKY9GUYTk /Fo5hVYgO998liyiPFGD24xGn4slTqwdpCAmBRHSk3cIjsddvY6yX61mj+D+q/0nojgzH UXSeKbF2+1AH0QQ3qcfeaFteaaPr5Lt2AGYJFZ55Snztk0kHcO8UNE47czzo3zfaAXON8 +SO2mSheOJIWKRuR1bLCng29kFVTtxjPQR7u1gyZZIkJE+TTfiB6KdGiW+JyTBDa+lfF0 7RI/wUqSY0Lhca7WYqW91HXVvToNcoJ6jbq7XYecdEuWZN5wpEFrGUlrySab5yQpbqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795965071; h=DMARC-Filter:DKIM-Signature:X-SONIC-DKIM-SIGN:X-YMail-OSG:X-Sonic-MF: X-Sonic-ID:Received:Received:Message-ID:Date:MIME-Version:User-Agent: Subject:To:References:Content-Language:In-Reply-To:From:Content-Type: Content-Transfer-Encoding:X-Mailer; bh=WpB7cbwbXFaMWTRT8/vs86QRNJyDX+BFj7/c/TTTU4M=; b=hBy49IttmG0WfMbQ0zsWaUoZz1ssfILCSwqcYoi/LkWo0TuA1ORm7/4nAq3sM7tK4fJN Icxt2daNkDrgv9/GerwxhyFqfHJJCC7/b5dJJ2Anzno56qL3MdKcDNCY4Z0mhsjHa4F5g aZTOCD/vHZrs9w/eCx/2wun+dFBGZMZoY8DTeu3Z5dcRNRpdy8LUbc73x3/rPL1SrpBjn MjJRh5Qvdy6ZhSLhPhdtlFUjnOJjyTcisz+vJ5QjfVIlB4ztEvfCGWky3cgtsZ7tDcrUx Bmn7N8O8S3JKT3pQ17aXcNDMnwBwYPHtH4dDGVDJBX5kOkYkAx3pWILELLZ7RNbSLlA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=yahoo.com; spf=pass smtp.mailfrom=yahoo.com; dkim=pass header.d=yahoo.com header.i=@yahoo.com header.a=rsa-sha256 header.s=s2048 header.b=QjyaXLmx; arc=none smtp.remote-ip=66.163.191.204 Received: from sonic312-23.consmr.mail.ne1.yahoo.com (sonic312-23.consmr.mail.ne1.yahoo.com [66.163.191.204]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66348606A323 for ; Sun, 29 Nov 2026 15:11:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 66348606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=yahoo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yahoo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.a=rsa-sha256 header.s=s2048 header.b=QjyaXLmx DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1795965069; bh=WpB7cbwbXFaMWTRT8/vs86QRNJyDX+BFj7/c/TTTU4M=; h=Date:Subject:To:References:In-Reply-To:From:Content-Type:From:Subject:Reply-To:Content-Type; b=QjyaXLmxdxtJQmAZRKyuKtd+Z39j87+4i8wZ5BYSbHRUFu2lw+1tp6CkMIu+2zOzZuuD1NaHVGsDO9DP7GBrr5Du00tR7Y9qcgbwvSoiZIvmHQQTOWEnuKAY1dz8vtj7kUi6JTiqb5OBvBYXXANnE0Dc/bCERowHu9Oln3aANc5bedet/yc9Lu3zd0ZPAJl8d55iZn5Xopyafow65pKSRKrGbLF4HfF8Nr6ITXLHw2jn9vycYUAxUAQAn4+vrZI0A5ATKjUxG0fDYRu3quwfQVq6Y48kSjGtc8liUhsZBPySE/n+fPeGhVyHw1Rz2zmQs2E4iODJVEkxByPKgphwhA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1795965069; bh=EhYyv80p21AYkHvG1z5gcMo9+K6opN/mhlvzcRF03Hi=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=Bhsx57sBlNITabcJkqdvyx87B39Qz352zH1QbhDRXyKC/UwMD/t2PbjLC/YM1GHqS+WDoKp5OFVIYPCOBTg4t2hw4d0l3F/Jall+F3598inUBtDm851U1cv9PKT+Z3cVeDVZB9qu+HbwWgD0OEFYW+UokZc2OLAc45HBPFY19h+ri1NmzwaZkrk8a9t+Tv8VWxzxowZd+3rVs2sOzaMwMiXawHQ+ng9HLCAh3w0N5qNk9UeW6lOsIjZiZFh6O08OFweFY2b1QTe/8GyPB2TPsUfiKDaMBfi13lkmgV/PfE9VUsvijFAjpcK4jPP2/rPfUbe/ceYnLYmb7t1InrlsTg== X-YMail-OSG: yXkfFfMVM1msIVai0abJPpxUueUO.rRStGzRdrZaxhk6UOZVEuREZ8rGSv8m3Lj EYaZ3PkHAqghy.YQWb5qRV5hPjw8mpAOYgfLnBFkr.xWYk4.7aB8oPPG0D_j2sxuH0GhU0JBKRtI nglP5tEtyQBXdzVj19SOlERSAlCXaExqqev_PK9BvUv_lyu5rALMg0VzdI_vFf289JY3H.AI5FKZ fbJGWKSprGkEwii0sCaWy.dekLby2JkAjFmD.RbHZUn3C3W3Bp5VXPlPbTCJmiFoT5VQedxpWyT6 xZuCulscJp90l5_l7vtpVaZFTPgX1abpQV3bTilMWiZNolNESuX9IjofyewCjUq.UaJrB1okvs2Z raeDkCjl_DTNmdn2yQqjUSqaMRaDgk.Af8VMikkLsWA4X79v_WAbyuYtd1okIFaozvAo1uB60V3y iX3FrtfoV4we.flW72yqbAiLeuIWNSW7MtCaQPilJgGHJCSizZMtUhrN1ccUmgnbRY_rTYZ7hBeg l0NKJf84CHOKp4X_aieYASvdLTG3sHJr73y2x_TCS3.YYM99G_knPJ6Hj1epXuLrjmJvg7ShZURx mKr4VOKhyT_v9NQZBD6.Qda0TM4bjz_h9wvTAz6MU.9gmnps_3zBw0AtN4sQgGMtMIKm8T8epGTt SrnVlIoxYd13eDIx12UsLwG6oqZ0l7DAUoJtqAnH5aQXhIj4fISnVAe9qk4brCfNMAAAZxMB4sp_ K9byRncwhet752BA8XuAoGHMsCjAQbw0Uzi4IQ1hYFePL.r4Tqdd3HOj2rPNFCk_Z7T17wfkIxum z0gu1m0PGQsx09kTjpG8H53nMAZFJtjzEsj0C6q7.Iv1YOx.3ojSPewr7QSOHo2i47YI0CSTjlbo SKFCVJ7tno2SvCN4wzvCMgTDYJOpHEy781GLfmz.k800bUCQ7Sj_DK927gKx4nqOOtTYhmJc4T1q Ft8gm.Q1XwKuDZ.luQxXr_ygTK1nS9upW61j5QsIw9u3wQdc1WNYO0homkbhWPykHqHZNrMqNqbJ T1GWlcewZpu4OXuyrnit8u1FmznYFlQ5t6.zSri.58y.uNx0aU3kKzFotQSAST5JvWvn6wLZQIg2 XR30LkuXQLZoH6LJEpVcSSNWmCx5C0AkvcGK6FC.roA1l05D0o6q_9m2z9sbIvsAgKcfkulysfVa 1RhWri.HFmwBwY2v9hZ1EsLGcPf17ZLbcFR4TgJjzBA_9H36THNUNJ8zYcrf2dahQufV0d1HgEm9 OATRk97TmAf.fkZ6nPNnCtMwhlA74gDmrkql0_Ak189TJRpt5g8j1YdwEyxPdhlAyxtfZ7PZGQVO nDVN6dIHHs62QfU0xbAW1qw1QM135wP.UwINwscB90QOL5BzjbVxzqOKw1LLcEI1mSs2gdBfG7g1 6z9KcSzKR2l998i_.U.xfzNVtOrpVDCmvT0O3Bht6xaWZS_df50qe2Fl1er38iob2_buvu9lPmlJ XVvRjT2L3JMSW6K5OkKO.qNT94RXHXQHlsM_N2RuKN.E3up1CTXwIjux23PexseCAToM4.0ZWisq emu3RVdSI0X8ralZgU9zRqWTQbnRAVyLNn8o.jcLW_hg10eCuLrc7QGplWm6NyGoeBxUU23HOq_l Ay6ZQmT_oW.vOO9OHomdpWyogkZ7fN.6WFBkRx6glq4jsoo7Qbm_311Ha1eIoYjeCsyGLzaX9a7c opNXu9pC6nvKbtvfowGNQtKh9FcQIgJeNUgrdJ_k8OYfsIEaOWC86YWD8PWWctdt1bbo7gGcy26I GXYu.Vcyb0ZQqlIpGLtBvLHc4ql_6NihKrWMQ4DMfEElPMyYWuKNUQEV4hLTR_zpXl6C4hl80iLK UNLVz4nkMiOnQp7hghVMbhjF8diMm44kK8LYTKZlrR505G.jg_ewAXCkPp.v3qZvBeSk.Lq48Fqx LsMvXZARSuqyNNhDGaCFdQCNMeUrCUk_VBF3IGqgNb9G1LMXiWK9ELQLGnjOXqjhccdWxo0qWyBZ I8ypJzJOQYOSuh7Ix.F8G32nbc8CrwRYij.xcT_Mm2QqCS_1G_gCYif2lJTZLLXvv8kmcdfNpvV7 p0Mf46K.uZkaD2rhkg7OZNGYTBGop2ruC7DFAkzYAskuoW4WAfeVhzJNf_mSl9ZqisducJT.rpI2 mvrEL8jVyRg9bvff7lyYhwJ40gcnS8WyG3sB9p3.FwjVuAVNxEf_gniwCSVi2mwEGOLnv_ojHxk3 JVZKcRa5RrTB6tpKf7xXFlCh91SUvkLXNUczTa3W5MXbyYgnreQ6fP9loI7b5KSW2c35O5EhDa7Z 1TH_6LbYsV7pLCxrTdDfyGtnSRy8GXhaau6r4vP0JdI9_ X-Sonic-MF: X-Sonic-ID: db12fa21-08ce-4bb8-bf64-c964690307b7 Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Sun, 29 Nov 2026 15:11:09 +0000 Received: by hermes--production-ir2-7c4859dc89-8w8b5 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 15552cd90d36103f344e74810fb7b26b; Sun, 29 Nov 2026 15:11:04 +0000 (UTC) Message-ID: Date: Sun, 29 Nov 2026 16:11:01 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH net-next v16 09/15] net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D To: linusw@kernel.org, andrew@lunn.ch, olteanv@gmail.com, kuba@kernel.org, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, linux@armlinux.org.uk, luizluca@gmail.com, maxime.chevallier@bootlin.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, alvin.sipraga@analog.com, gusfmora@gmail.com, kuncy7@gmail.com, fabianotassotti@gmail.com, gabonpivovich@gmail.com, contact@c127.dev, o.rempel@pengutronix.de References: Content-Language: pl In-Reply-To: From: Mieczyslaw Nalewaj Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.27100 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Family D has no working VLAN member config (MC) table. Its PVID is a raw 12-bit VID in a per-port register at 0x0700 + port, whereas family C stores a 5-bit MC table index, two ports per register, at 0x0700 + (port >> 1). Running the family C code on family D therefore reads an MC table that does not exist, and writes an MC index into the VID register of port (port >> 1) instead of the one of the port being configured. Add the family D implementations of the PVID helpers, rtl8365mb_d_vlan_port_get_pvid(), rtl8365mb_d_vlan_port_reset_pvid(), rtl8365mb_d_vlan_pvid_port_set() and rtl8365mb_d_vlan_pvid_port_clear(), which skip the MC table. They keep the family C frame filter handling and rollback on error. The shared code reaches them through the vlan_port_get_pvid, vlan_port_reset_pvid, vlan_pvid_port_set and vlan_pvid_port_clear pointers in struct rtl8365mb_family_info, so it needs no is_d() check. Also clear the family D PVID registers when the VLAN support is set up. Unlike on family C, where VLANMC index 0 is the neutral PVID, the register holds a raw VID, and after a reset it keeps its hardware (or EEPROM) default. Without clearing it an unconfigured port could report a stale PVID from rtl8365mb_vlan_port_get_pvid(), and rtl8365mb_port_vlan_filtering() would accept untagged frames into it. rtl8365mb_c_vlan_port_reset_pvid() does nothing on family C. No functional change for family C. Nothing points to the new functions until the family D info is added together with the chip table entry in the last patch. Until then they are not static and are declared in rtl8365mb_vlan.h, so that the build does not warn about unused functions. Tested-by: Gustavo Foletto Mora Signed-off-by: Mieczyslaw Nalewaj --- drivers/net/dsa/realtek/rtl8365mb_main.c | 11 ++ drivers/net/dsa/realtek/rtl8365mb_vlan.c | 201 ++++++++++++++++++++++- drivers/net/dsa/realtek/rtl8365mb_vlan.h | 6 + 3 files changed, 217 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c index a521eb6..7500ea9 100644 --- a/drivers/net/dsa/realtek/rtl8365mb_main.c +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c @@ -2479,11 +2479,22 @@ out_unlock: */ static int rtl8365mb_vlan_setup(struct dsa_switch *ds) { + const struct rtl8365mb_family_info *fi; struct realtek_priv *priv = ds->priv; struct dsa_port *dp; int ret; + fi = rtl8365mb_get_family_info(priv); dsa_switch_for_each_available_port(dp, ds) { + /* Put the PVID in its neutral state, if the chip needs it */ + ret = fi->vlan_port_reset_pvid(priv, dp->index); + if (ret) { + dev_err(priv->dev, + "Failed to reset PVID on port %d\n", + dp->index); + return ret; + } + /* Disable vlan-filtering for all ports */ ret = rtl8365mb_port_vlan_filtering(ds, dp->index, false, NULL); if (ret) { diff --git a/drivers/net/dsa/realtek/rtl8365mb_vlan.c b/drivers/net/dsa/realtek/rtl8365mb_vlan.c index 509e9fc..aecfcf5 100644 --- a/drivers/net/dsa/realtek/rtl8365mb_vlan.c +++ b/drivers/net/dsa/realtek/rtl8365mb_vlan.c @@ -44,6 +44,10 @@ * * VLANMC index 0 is reserved as a neutral PVID, used for standalone ports. * + * Everything above describes chips that have a VLAN membership configuration + * table. RTL8365MB_FAMILY_D chips do not have one: their PVID is a raw 12-bit + * VID in a per-port register, and no VLANMC entries are allocated. + * */ #include "rtl8365mb_vlan.h" @@ -123,6 +127,12 @@ #define RTL8365MB_VLAN_PVID_CTRL_PORT_MCIDX_MASK(_p) \ (0x1F << RTL8365MB_VLAN_PVID_CTRL_PORT_MCIDX_OFFSET(_p)) +/* Family D: the PVID is a raw VID, one register per port */ +#define RTL8365MB_D_VLAN_PVID_CTRL_BASE 0x0700 +#define RTL8365MB_D_VLAN_PVID_CTRL_REG(port) \ + (RTL8365MB_D_VLAN_PVID_CTRL_BASE + (port)) +#define RTL8365MB_D_VLAN_PVID_CTRL_MASK GENMASK(11, 0) + /* Frame type filtering registers */ #define RTL8365MB_VLAN_ACCEPT_FRAME_TYPE_BASE 0x07aa #define RTL8365MB_VLAN_ACCEPT_FRAME_TYPE_REG(port) \ @@ -174,7 +184,7 @@ struct rtl8365mb_vlan4k { * This structure is used to get/set entries in the VLAN membership * configuration database. This feature is largely vestigial, but * still needed for at least the following features: - * - PVID configuration + * - PVID configuration (family C only, family D has no VLAN MC table) * - ACL configuration * - selection of VLAN by the CPU tag when VSEL=1, although the switch * can also select VLAN based on the VLAN tag if VSEL=0 @@ -1220,3 +1230,192 @@ int rtl8365mb_vlan_pvid_port_clear(struct dsa_switch *ds, int port, u16 vid) return fi->vlan_pvid_port_clear(ds, port, vid); } + +/** + * rtl8365mb_d_vlan_port_reset_pvid() - Put a port's PVID in its neutral state + * (family D) + * @priv: realtek_priv pointer + * @port: the port number + * + * On family D the PVID is a raw VID in a per-port register whose value after + * reset is not defined by the driver (it may come from the hardware default or + * from an EEPROM), so clear it to 0. + * + * Context: Can sleep. Takes and releases &priv->map_lock. + * Return: 0 on success, or a negative error code on failure. + */ +int rtl8365mb_d_vlan_port_reset_pvid(struct realtek_priv *priv, int port) +{ + return regmap_update_bits(priv->map, + RTL8365MB_D_VLAN_PVID_CTRL_REG(port), + RTL8365MB_D_VLAN_PVID_CTRL_MASK, 0); +} + +/** + * rtl8365mb_d_vlan_port_get_pvid() - Retrieve the port PVID (family D) + * @priv: realtek_priv pointer + * @port: port index + * @pvid: pointer to store the retrieved VLAN ID + * + * Family D has no VLAN MC table: the PVID is read straight from the per-port + * register. + * + * Context: Can sleep. Takes and releases &priv->map_lock. + * Return: 0 on success or a negative error code on failure. + */ +int rtl8365mb_d_vlan_port_get_pvid(struct realtek_priv *priv, int port, + u16 *pvid) +{ + u32 data; + int ret; + + ret = regmap_read(priv->map, RTL8365MB_D_VLAN_PVID_CTRL_REG(port), + &data); + if (ret) + return ret; + + *pvid = data & RTL8365MB_D_VLAN_PVID_CTRL_MASK; + return 0; +} + +/** + * rtl8365mb_d_vlan_pvid_port_set() - Configure a port's PVID as a raw VID + * written to its dedicated register (family D) + * @ds: DSA switch instance + * @port: port index + * @vid: target VID + * @extack: netlink extended ACK for error reporting + * + * Reads back the previous PVID and frame filter first so both can be + * restored if enabling the new PVID fails partway through, matching the + * rollback behavior of the family C implementation. + * + * Context: Can sleep. Must be called with &priv->vlan_lock held. + * Return: 0 on success, or a negative error code on failure. + */ +int rtl8365mb_d_vlan_pvid_port_set(struct dsa_switch *ds, int port, u16 vid, + struct netlink_ext_ack *extack) +{ + enum rtl8365mb_frame_ingress prev_accepted_frame; + struct realtek_priv *priv = ds->priv; + u32 prev_pvid; + int ret; + + lockdep_assert_held(&priv->vlan_lock); + + ret = regmap_read(priv->map, RTL8365MB_D_VLAN_PVID_CTRL_REG(port), + &prev_pvid); + if (ret) { + dev_err(priv->dev, "Failed to read current PVID\n"); + return ret; + } + prev_pvid &= RTL8365MB_D_VLAN_PVID_CTRL_MASK; + + ret = rtl8365mb_vlan_port_get_framefilter(priv, port, + &prev_accepted_frame); + if (ret) { + dev_err(priv->dev, "Failed to get current framefilter\n"); + return ret; + } + + ret = regmap_update_bits(priv->map, + RTL8365MB_D_VLAN_PVID_CTRL_REG(port), + RTL8365MB_D_VLAN_PVID_CTRL_MASK, + vid & RTL8365MB_D_VLAN_PVID_CTRL_MASK); + if (ret) { + dev_err(priv->dev, "Failed to set port PVID\n"); + return ret; + } + + /* Changing accept frame is what enables PVID (if not enabled before) */ + ret = rtl8365mb_vlan_port_set_framefilter(priv, port, + RTL8365MB_FRAME_TYPE_ANY_FRAME); + if (ret) { + dev_err(priv->dev, "Failed to set port frame filter\n"); + goto undo_pvid_write; + } + + return 0; + +undo_pvid_write: + (void)regmap_update_bits(priv->map, + RTL8365MB_D_VLAN_PVID_CTRL_REG(port), + RTL8365MB_D_VLAN_PVID_CTRL_MASK, prev_pvid); + (void)rtl8365mb_vlan_port_set_framefilter(priv, port, + prev_accepted_frame); + return ret; +} + +/** + * rtl8365mb_d_vlan_pvid_port_clear() - Remove a port's raw-VID PVID + * configuration (family D) + * @ds: DSA switch instance + * @port: port index + * @vid: VLAN VID for PVID + * + * Reads back the previous frame filter first so it can be restored if + * clearing the PVID register fails. + * + * Context: Can sleep. Must be called with &priv->vlan_lock held. + * Return: 0 on success, or a negative error code on failure. + */ +int rtl8365mb_d_vlan_pvid_port_clear(struct dsa_switch *ds, int port, u16 vid) +{ + enum rtl8365mb_frame_ingress prev_accepted_frame = + RTL8365MB_FRAME_TYPE_ANY_FRAME; + struct realtek_priv *priv = ds->priv; + bool filtering; + u32 cur_pvid; + int ret; + + lockdep_assert_held(&priv->vlan_lock); + + ret = regmap_read(priv->map, RTL8365MB_D_VLAN_PVID_CTRL_REG(port), + &cur_pvid); + if (ret) { + dev_err(priv->dev, "Failed to read current PVID\n"); + return ret; + } + + /* Port is not using this VID as PVID. Nothing to remove. */ + if ((cur_pvid & RTL8365MB_D_VLAN_PVID_CTRL_MASK) != vid) + return 0; + + filtering = dsa_port_is_vlan_filtering(dsa_to_port(ds, port)); + + /* Changing accept frame is what really removes PVID. But only do + * that if VLAN filtering is enabled. + */ + if (filtering) { + ret = rtl8365mb_vlan_port_get_framefilter(priv, port, + &prev_accepted_frame); + if (ret) { + dev_err(priv->dev, + "Failed to get current framefilter\n"); + return ret; + } + + ret = rtl8365mb_vlan_port_set_framefilter(priv, port, + RTL8365MB_FRAME_TYPE_TAGGED_ONLY); + if (ret) { + dev_err(priv->dev, "Failed to set port frame filter\n"); + return ret; + } + } + + ret = regmap_update_bits(priv->map, + RTL8365MB_D_VLAN_PVID_CTRL_REG(port), + RTL8365MB_D_VLAN_PVID_CTRL_MASK, 0); + if (ret) { + dev_err(priv->dev, "Failed to set port PVID to 0\n"); + goto undo_set_framefilter; + } + + return 0; + +undo_set_framefilter: + if (filtering) + (void)rtl8365mb_vlan_port_set_framefilter(priv, port, + prev_accepted_frame); + return ret; +} diff --git a/drivers/net/dsa/realtek/rtl8365mb_vlan.h b/drivers/net/dsa/realtek/rtl8365mb_vlan.h index b5b56ae..270f88b 100644 --- a/drivers/net/dsa/realtek/rtl8365mb_vlan.h +++ b/drivers/net/dsa/realtek/rtl8365mb_vlan.h @@ -34,6 +34,12 @@ int rtl8365mb_c_vlan_port_reset_pvid(struct realtek_priv *priv, int port); int rtl8365mb_c_vlan_pvid_port_set(struct dsa_switch *ds, int port, u16 vid, struct netlink_ext_ack *extack); int rtl8365mb_c_vlan_pvid_port_clear(struct dsa_switch *ds, int port, u16 vid); +int rtl8365mb_d_vlan_port_get_pvid(struct realtek_priv *priv, int port, + u16 *pvid); +int rtl8365mb_d_vlan_port_reset_pvid(struct realtek_priv *priv, int port); +int rtl8365mb_d_vlan_pvid_port_set(struct dsa_switch *ds, int port, u16 vid, + struct netlink_ext_ack *extack); +int rtl8365mb_d_vlan_pvid_port_clear(struct dsa_switch *ds, int port, u16 vid); int rtl8365mb_vlan_port_get_pvid(struct realtek_priv *priv, int port, u16 *pvid); -- 2.53.0