From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=66.163.189.148 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796264271; b=LiS0fSTu4zEqH6ZW7paydiBhKCJogoQ7H8OvVTcJGSqEzJlLp4xRdGw4SGBe6GMUL1RJ rfuttxKManhfsLhZ0yuR8frHYkZcFr2EVV+BB3Pm/ldEFrgvq9sBbpuGWeG5YetXEnRhc 5jGrRZ86k5eklNC7zEMab85rgbaHtMYLSBObJL2TozzXACIrZltnPIJGFRwoC+jadu9/z 4IoVGXodjr6MGcFAe6TFNSOf5qxWYqSIhj0m60VlvJejfZ0am0kVa+BZCXfz+ykXSIMoT A0n/+cwQr3csKiYfX/Y7mkIoKMx/RtjdGH14C4zSBp0SWix1qTxTgkFZ3PdbAOqr/jQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796264271; 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=3SCBXI/e440adzEFhVgqwBnGYLLlAypFVmEJ6rWz9KY=; b=q6khJiMknbbXQZIW6hScvWKS4beJhy1HX1idZ7b21Pcbc9e9tNGdIzuPkmEW+N6lWt4L 38cfqn2ULc1vORuVfH4VBhSPFaOZ5bo7jWERinXxZnC47ljqecY/tBoYYEim/2kM3uqsT Mit37ynd0hoUSuU4/Hmp43hZlOe5Z+mxuYYnQgAJY9Y6SOt5n4YZz/OiTsxK+ZEgR8Xeh ACgKD76gG5Xw7aLV/iU0eO361doEu8ClMgCgTZQ7ECb8nXJeGEFy+O9XHuE3FM1vyS+Tg mOqGA+2dhczh6FBDY18XWE0IE0lS5plvZHJ/1kJ0BbWBtx32l8Tnppbn9OeKi2OIQjw== 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=StAPbwcN; arc=none smtp.remote-ip=66.163.189.148 Received: from sonic314-22.consmr.mail.ne1.yahoo.com (sonic314-22.consmr.mail.ne1.yahoo.com [66.163.189.148]) (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 29DD0606A32D for ; Thu, 3 Dec 2026 02:17:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 29DD0606A32D 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=StAPbwcN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1796264270; bh=3SCBXI/e440adzEFhVgqwBnGYLLlAypFVmEJ6rWz9KY=; h=Date:Subject:To:References:In-Reply-To:From:Content-Type:From:Subject:Reply-To:Content-Type; b=StAPbwcNVTdjv5ZjlP1jjy1h5jknt7bvUUXeIlc8eZh4wPbTTPjH2XATwXxS2LsNbUEU/eFqfB7TiOkHl6uiyo0TrAQKJzGDr2sdti6PTz48GZ2ngIHxHmOVskDf77fdgO7TEGdV+YJvMVz8A++1Tgb7/m4OZZaHsMwchg0BLhuf2lNnbpUOD8zoYCGSjZ0NDTpdDLBJ+F0j4M6teiUW4JiFPrlgxJPU9b0G3U67mTNMqk30ez3IjTIpryTdQ11aLLVb1UpWDgcepqCVpMG8zZi+zhLqc2Li4rK5hGGaqyvg3dF4PUJSqBChDCpnEcSq75xggym1kykWeRF7YDnd5g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1796264270; bh=/TZqpAmcmLdJ37TkgL9+fTetGowNFlrEErJUcgMyN0N=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=ryARKLg2mCNzW4IPwkKTDa9i9Q6EKY3P7WIlHBUFQXaD8rF3CmtNmTV92OmMBKX9zN9mmRrGJreIvHmhwl10JP6UDVnI05X+D+sWOMsZx4oLcc1z/aILeIOx6teKT2ODVxG8aZA83r6tGiXkRz1eMY9uV9SmFer2HibYZWks4DLpOlbYpn5zbIoxOm0jNpdlfcKhzVxPhzqHNm/xLRdUZcYZ6qrzYuP8VAXkGCcXf8aiE1r0FkXK3UaBe9xglFRZx/0D3gDI0gWlC/+3oghWPzQGW83QLTYLCFhja4rYoVWTlV4L5TDMCRxU/k53V41kKTouiHAwcNcgjmeL0SC3+A== X-YMail-OSG: tnjeWRMVM1lEw_Ypcc_2wjkK6t0bFGcJSQ1Wcs9fP.duq8B143kMH1ZP_dQFhzQ dGhJjx9bDrssufpyNIW5QKqwnK55AWzKqCF3nJstzuP1M402qxYFfnAplWWshbe.eBL1b8oh_01k L.B.Uj3tKxfpo1Wxg7DMgOqXMnNqFlC2K6x7WgBg.F_N9Sd0wdL01TkXNDcTZJ8QA0qq5KWYxnsQ kG.rpmduTR7z0TnyN7E9a_jdzOYtU7kGzV1DY50.L692d6.KvHDz9bwzt8NOR5MZoOj82A_6xlL3 sHQueJ8VC4ASDdX2PjbzcpGu4d.c.rZNy_p0QJF54x3ef_AODyuftSYrH_okwtmsMeSIK6SSs8Nw FnJ.koZWPSdLkbBfWflDziUytmP2dladMJcVZ1_LRCEIbRFhKZYjM0ar4N8mLQu_674OBUczCGjt odtRdaqh9hVQODRKfU6DWbljp7EY.s.2FCVE3PuAOK5CLyyQ_lxu1vTMDGL3fVGqcpabh32akf9x swDq3LE2BkFs0ch1wHLYU0yptZXoXv2yHW9s1kkQYSVdHhIDmCxjIZWza_M1yhs0C5VodR20xprk n_lulCnF3Kn4eFtjpi05AilDY9vtNXhWS7BQIoXDnYVBDtFAoKrAg7az2qbLwezWgtLkf5l_Av66 rRHiG.4oj4xICKWFmbwgvvu28QKeiCd.jpxWd4co8Mfr6JCOjibasdxMd9F6U3JMshHLlO7s_Gjh tBrpwmB9WPzhOPhK0rmw_rdJoupDXRwhBXVr2BO6fmk5TjjBT4yGUT5UdLVOKVP6F06ileouhORt zzugFAxAWEvEBPKA6gB8xV5kkSvuAqpo8A5a0CFw4i_x41wnLTOlZBqobuhO34FcFmy8vSPe5OVa JmTp7OY0rnzxoEQADd76sqFInz7f9t3HJqTv7vO4nF2ysHHCQPgMSYlWsmJqb4eOuA3Fia4_ojzL mZoodxg17b765BpackynyJV5nAoTQFBx98VdId8KLn1XKGHpWLQk0zQBWfyto74rjjbUbsPH11SP Y0gNmpzjC7PGsQHgU1PNrvCGB4eqlwuTuw39iThBj.xwvf9BPg3OYr3RX_YquF1IAocBIApL_S1F HbDRu5wAuoAcBi6ANm9nC6wWSXoNfcdFUh6xysSW6gpP7LAwUmFeg_AOT29RYsZhhR8R1E5QUpN_ Hx4w3s3DGdCrSgdZqX20Mq1Hre9Q7oJYQTVCVL81B2bc3TTkiDAtl_MuKZPxJNEwABa4TI63SzZk cc5pvRhUaeJUxkew1YbVnDMONh2Lq4u5C2BQVJQeH_8DdU6A8.S0xnbZcGtMEmjxMuyhtUihMTe6 V1PQbD1K_pbSSDoWR9GF0DvHXh7eEknvnzkryZmdYqlDWI1kPu2oxGjM1K10orH5l_R8acENmZuW oLtK7Vnd_4pxz_suzl3ZForxiWePm0_hC7SPJjupkbFiToy7_YW1m8ftvh5tpeJ.YhcvvF2dILpP Mzcu0Pc6IwC1Ib_ZsGZFfTdIvBvoQ4Ojml5Qt_7IZZTUIDKmPHR78KNBBxF8ofRU87LORr2RO0Vy 5YPIzpwSQ2vy3z7JlFMnONDPyD_nqcpBJAxVSY8GRIe7EtDgPZDtUbozPD_2TtKJGTS8aAnA9H3U dnAq5FidY1VhVjpXnUEEnwjgPs6vG.jSB4MFxElX2CT36wTWsAD850yR7zy.DHaZrHAb540x7GR7 pSNF.CYDP4p1KulH7biChthUTTD_GQKn862htDy903Cax2gdebZSTkaXN672L8duG4kxPaVHTgFR fxT3Lzs1wukasTQbWyT5lE8pzrd9oYvyuB.S3blw44JWrD7LDStS4xhbHh2VSGXR93nraypA9kto mxSIHtWxm0uT8WJkqcVlvdr7hsGvdkLZICJaGAOM.nFRP3_.Uh9sfXSRjnj_UefwvFWXSwC0Ba5S a4UG1kwlz9.kdKoDTbjJAV8JOi1.GWJBcNfby9hJuPr8BHzHpD0ZRSVYwzSFppojM.5UD6Ij22XY J3Tj0F75s2hw6JHnK2L.zJXFuixrfip2wBqLOCMliXyhuog4tkfRkXwUGz7BAZU_7YTFWmrVvFH6 DFNvpDHQJkfeJsXkRTHrC0y75HPYKDD1t44w.7FmKkqv59o14KMXuqQwH6t81302BfUYnGUjIhkt R0CGEZ45CKwjwlmn25t9lEw8Bcx9rpnHqnqLkIhkByfz.BgtYK3RLt4CIXKZFuBv9CFN1EhoUSYA ahh3ey3oxe0wef5ul58ZLrkUVqfVc3f4cMyb6v_WLO25rFI3bTQlYzFB5a10I50z1RkpbcOOCYqg 386wJrF2KZ4JreDpjllBoMHQIiqxXpyYfyILZYLFM X-Sonic-MF: X-Sonic-ID: 3f777125-68e8-48c2-b2c9-790b6f3c0edf Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ne1.yahoo.com with HTTP; Thu, 3 Dec 2026 02:17:50 +0000 Received: by hermes--production-ir2-7c4859dc89-4mhg8 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 43b9cb958367d01a0c81a7ba4ed5bcea; Thu, 03 Dec 2026 02:17:44 +0000 (UTC) Message-ID: <8a4e4ee1-5d70-422a-b1dc-77d744a6a2e0@yahoo.com> Date: Thu, 3 Dec 2026 03:17:40 +0100 X-Mailing-List: netdev@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 v19 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: <59c7992d-1c83-4bf1-a2f4-c853d4777190@yahoo.com> Content-Language: pl In-Reply-To: <59c7992d-1c83-4bf1-a2f4-c853d4777190@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 0aa4d96..4fd79db 100644 --- a/drivers/net/dsa/realtek/rtl8365mb_main.c +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c @@ -2480,11 +2480,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 1463d5f..58e1c24 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 @@ -1228,3 +1238,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 62ee59c..d8187bc 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