From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=66.163.191.205 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796169346; b=MUppt0OBY11+NfTAxA5B1h3x5CYcy0fUVs1TNPTgS6po/D8uIYqtvjYeNwV8fxB+ejI+ vFVS7c87cuAbdl2yS3FizJRJDTKd/jRFcKLJuSrroU79qPwH1D128XKE4tSOEPA+F6id+ Q2pEd9AkGHzM5TbM+21xmTgqXrdqWquM8iJ0e4Ym4dZRSWVwV4UpnuufMJZlT4BtFXRnr ZvY8Qmnxr1z0GPAX7AP1R8LNcO7+ILcDt/XfyTkU9trqvx9EwGkpDLssPbA8QIfPStUd/ X4eoI7bWj5dTlC3e9962QbkZ5WPNdf0XKXIjv1JSuVVLsd46L9oOHvMb8EOxs3+ocNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796169346; 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=3xItWhvUCyX2XnSyb/fhGXtgCw2R0S/zyADUYWsWIVg=; b=ut0mWHcrmt8BygnMZYiLE9Kg0o9k+0pVdbtcs8i3Xnm3LJnH8Y3XuZ/FRWXG1Covl28g OMXYsSnKznTHb9xxIgP06I6Tpy9S+YE/fh6w/NCJeEQn0cSABi6RKj0cmVmIJcYuG6UzZ Mv0h3shdT39OokVUOPUlJ3FO+7M8us2PFl6CyBoJRCv58z1zJaPXny4x05h4I/F+afBJV KGGd8R+oEH7+Voct7CUM0SqWPvgR8dIEPoc/SVritrvK8rfc5hCEdAkSKDsLkoOijVqvr HYSH04qB2QJeoaYuEvg2Kj9Pq7+4DsBMZcNxIqgefmtKBB2274r7gClqxrCjBzfrb7w== 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=XuiRI9fF; arc=none smtp.remote-ip=66.163.191.205 Received: from sonic312-24.consmr.mail.ne1.yahoo.com (sonic312-24.consmr.mail.ne1.yahoo.com [66.163.191.205]) (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 01BDC606A31A for ; Tue, 1 Dec 2026 23:55:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 01BDC606A31A 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=XuiRI9fF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1796169345; bh=3xItWhvUCyX2XnSyb/fhGXtgCw2R0S/zyADUYWsWIVg=; h=Date:Subject:To:References:In-Reply-To:From:Content-Type:From:Subject:Reply-To:Content-Type; b=XuiRI9fFiXrA1vr/uDwGK6FAOGkW1Bsr1mb/do5Nrys6y75Nh/TGz+7jssYc9JPX3dRmLoS90MMg/SjGiPYNA5ylrdIQoQ7P4hazzOaZ6UDANCapSltnIWz4ah5sU+aYgdiAJe868Q5B/wAUMO5mBRqe8z190UYl1zdfghK3C2XoNPBdo7gwUQQTb3xchRwTmg3dhaXhPmSSluUTdmCRMfLSP/ZrxqAWE1s2YEkvCDFTLTppgPhzd/5kw7mpqd1+Ui3xpzX/l+rAHx35rVncaSmB/HpO2LvWizWn/iFKlHe4qwcrZzGjcswUs/P76d8/YQ9Plunl6R12oKpawGVU1w== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1796169345; bh=aU+3KkBPHuTu/jh6QJ+8C+DKqzAtp+83/cvKd/q6u+p=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=I2dH0sH51uvQYtdOdsTH5NExMt8PgJ4L5sZOr6nAfk7v0tYvXA2RL4F/suuRhlxgi20GxucbX60JJ31xutUwxzlJfrIffgjnNrKrgv0pj/N8X3oAhOcL7otvsyNHQ0FWOAqZk35pCg6YlJf2RpbbVPzzr1dY4iB822K5LXZdzInXC6yfK+yPvenKn5WWslS7Q7n+U5abSIZ4CWmiPCLqIURKKmmCceB3YAyzboy5aPlKrCiwYOaHHTXqLjILoTZY/h9cFPgflx4Q55w1SUKXfA1VFD+U7YiU6L2bCeHGLsDKtNJohKTuI5cznCYgCwvasIjWlvix1sXI6NCKBFStYQ== X-YMail-OSG: ns9wt3MVM1lTS79cykjUwe.JPysOTyVAbyBRwzlAvnnKbfmCtW9fyGFX9vON06T U8pX_aJmxx2A719MRoSLw4ufnfY6gq7tAnrDkOAYrar976pIeeJUSgLdRKxoicxPkWY_k08.mfvT OnzBp6z.OwVbZUht_hKMQYx5Oz7leQuKema.0J2VdGi.jUzGQ7BIfzwB_Gw8YV6q3rs05jZYenAu rgERwkEB_6c7WpD2PwcgFHga94vQJO2s7XBmaWTqmommZ5g7IuMkMO0j.eryEbr98Hv7iJozBKLL QrOjD0PZXNu1WS8WnhxgrTYmjRgGDYTiTR3h2CnTm6_wQVK1ylcog_BflqHfXZUo0E9j6aKKAqCT bOAEXl0QtMsK7S_n9tNiT1Ymz6z7x0Re8D_H68BMwSm.MPoqYcPk6a7iveOiquN2aEY6wJCMgDmN JNwo5_rZrMyoD4ZIFCZrYtKV4oKKhfAbY8eO_WBoqDbokp8p8OlFYNxvvisWXLu604KBhUbMiQHF gVURvdmNlOYwvGvcRB5mK2Ombc43PpXW4HCjvBMpap_BRd4XMM771y9K7XQV.91XPxPGLl6c_TMk zF3aAOE4_jU4haH0hH7lwApOLarpoaw4hf1eAMwtqpbLrfxxB7JaHvBe6EM0vTCqLFd3ukBmAhKo qUVrEQoT3guSOI7VK9t8Apd7O59sWscZJ669qLgQ88BrvPEh9u_NzrW3ZYSn.fA8hBdcPMIAFIwb GNvErb04E_Kmhs4ZWaFAI.Ohnj.MMUK3E_KsH0L_wO.eVEUtKmB3WDXMeoOY67kDgkbbt_oVhQBL 3BFrx6roRML3K9nXHWozt5FrbbvH3Mk_u8OceyT06Zz9Ej2mhVXYvB2D01cRwRiU01tFWbB4wUVx XzbydXqI9v2dx_6fqCGxv8L9dX6CNg40PaYQL3A12Gj_TdbmLw1PUxr.p9kzNphTdsjL8ydfI0ZC 4dgPYwIADpVscDIqrMlJXyTC06k.3fHNgH0_4x7A4gPs171PhAk3fbhF5AZa3Y79e2G7G6Guob3T ZZ_NRvHU6T5VqQqBeRwNINDh5E0.MMgxvA35J65lv33WsvlcsRX.Vx_YgtMzbwulwNknC57_4NA9 oatXmjOxvyP2RMOex2ji9DzvacQ1IgaAoQysDNjXf8u3TCrcC9a4XjYQF1gU7yFaGMC1etRg0uGT idWaCBqynIJgMr.ofkw252vsjP2W8156BgwAGMWwIJGwqqJRB__up_EcptErgpT7Nx.rxz.xFEIG OmQuxfnUPJH7340Zgra3Yc.87.ugcIJoKuw9czXmOB0T8vOrYFxW_Ndo.clHqSPCpdV4D5kJBuHq CtYr5CdXGBtJXJ4EPvEKBzhZ_YIjkpjjmEo.5d_PQI7CZYm1fkNcYUR_YhP8IPbMFVwnf6ADf_2E YsEkb01VQb936V3HnFmRVAaC5ZlRTlsdzWFp1nNsXnpXMkhHZzIuGczKw9WWOMorLgPH60aYtEVz 5rpgDLV5w32zWsxH5OgB76676W3bgHbpccgmOIwxM1bVqAKUNZg7ouldYbB5sSS4X30jad3mR3fV CLFx.L4r3ys8TF2qy_F6fYCf9WP_aKjemXk8KckhxQtdHBbLqL8W3hn89JTRXKjp4qhWz1An2pyq C2Yhv6y65QedEx0RhXwGVVReDhrsi7gefJHloN8QeJzrV67eXAhJMPOS58ollmXtwKdA3jWxU8om ffHOsNxGeWsbHaW2tkahovPozGwAf_Imf3ePhuvkPKvjpUV53x65LMX5Ni_fR1pMC_YtUfE.RyFB wqRYeKowjC8y_Wl.gUxebZQ36lm2Qr2ThcLYy1Dy1xi46_Dys5BKeLfAOvd4oLjgkuF66dFUy_UV b0GhlpVgzEXVsc9cfqMJbEm_G8CCgdgcfYldB_Z02d4CffMcOMqXV4D8sD.knIlEo_f2yoweqBM0 Ykle1JM0h9VYTKbLqDqNNjZJi8SXhHjnbWf7RAHkjDTGkABGlKnc60ytpL4VsAtvrI4TZCz3ScUJ fDgYO_YfTD6ww0CzkfY8sAqTEIIfQ3ornHfASGS9TfEQZZnQwHD38kzUt0TXKkJa_j5gNNHWJnb9 6xwj9hZEwfd_5ZZ0t7bI0vnhCUWSa28Nst8O9MEX4V9S9XYL8q4vWKb0ApM1gajcjW7kYZK.2aVL DFR5lrfiRCtH_UseislHp8gzfZsCn5w4l0TNU8f5LnLPju0itVJ9NIYRF9YTBev_wa1LQ9cd2S4k B4exsGLIK89dNRF7V9r7B9f_uhgujXTz84YpwsJLu6lcxHheM12pDNjaALMwDfsbe5hWfQ.6gLEe X83FuA1ZreKUcYNURYybbM672ThezPLmoaSgiFbMkrJBtEIY- X-Sonic-MF: X-Sonic-ID: 59bf907a-2116-44ab-a7e1-76dc4caa72e1 Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Tue, 1 Dec 2026 23:55:45 +0000 Received: by hermes--production-ir2-7c4859dc89-8w8b5 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 6ccf6a48e43262c93511329ff595c16d; Tue, 01 Dec 2026 23:55:41 +0000 (UTC) Message-ID: <1930e5c1-8026-4b16-98c4-8f447429770b@yahoo.com> Date: Wed, 2 Dec 2026 00:55:37 +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 v18 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: <1383a67b-15e4-4c76-8bbf-65d3cbfa1fc1@yahoo.com> Content-Language: pl In-Reply-To: <1383a67b-15e4-4c76-8bbf-65d3cbfa1fc1@yahoo.com> 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. They are non-static and declared in rtl8365mb_vlan.h because struct rtl8365mb_family_info in rtl8365mb_main.c references them. 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 c3c55b8..974e7e0 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 @@ -1222,3 +1232,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