drivers/net/dsa/realtek/rtl8365mb_main.c:1323:2-16: opportunity for str_enable_disable(vlan_filtering)
kernel test robot <[email protected]>
| Newsgroups | dev.linux.lists.oe-kbuild |
|---|---|
| Message-ID | <[email protected]> |
BCC: [email protected] CC: [email protected] CC: [email protected] TO: "Alvin Šipraga" <[email protected]> CC: Jakub Kicinski <[email protected]> CC: Linus Walleij <[email protected]> CC: Mieczyslaw Nalewaj <[email protected]> CC: Luiz Angelo Daros de Luca <[email protected]> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: bcc44b6785f216eb939226ade6e3910baa30516b commit: 9da2c8672f77108a1f09232320f22225ab53dde9 net: dsa: realtek: rtl8365mb: add VLAN support date: 8 weeks ago :::::: branch date: 4 hours ago :::::: commit date: 8 weeks ago config: arm64-randconfig-r062-20260808 (https://download.01.org/0day-ci/archive/20260808/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 8.5.0 If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Fixes: 9da2c8672f77 ("net: dsa: realtek: rtl8365mb: add VLAN support") | Reported-by: kernel test robot <[email protected]> | Reported-by: Julia Lawall <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/ cocci warnings: (new ones prefixed by >>) >> drivers/net/dsa/realtek/rtl8365mb_main.c:1323:2-16: opportunity for str_enable_disable(vlan_filtering) vim +1323 drivers/net/dsa/realtek/rtl8365mb_main.c 9da2c8672f7710 Alvin Šipraga 2026-06-06 1309 9da2c8672f7710 Alvin Šipraga 2026-06-06 1310 static int rtl8365mb_port_vlan_filtering(struct dsa_switch *ds, int port, 9da2c8672f7710 Alvin Šipraga 2026-06-06 1311 bool vlan_filtering, 9da2c8672f7710 Alvin Šipraga 2026-06-06 1312 struct netlink_ext_ack *extack) 9da2c8672f7710 Alvin Šipraga 2026-06-06 1313 { 9da2c8672f7710 Alvin Šipraga 2026-06-06 1314 enum rtl8365mb_frame_ingress accepted_frame, prev_accepted_frame; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1315 enum rtl8365mb_vlan_egress_mode mode; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1316 struct realtek_priv *priv = ds->priv; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1317 u32 configured_ports = 0; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1318 struct dsa_port *dp; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1319 u16 pvid_vid; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1320 int ret; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1321 9da2c8672f7710 Alvin Šipraga 2026-06-06 1322 dev_dbg(priv->dev, "port %d: %s VLAN filtering\n", port, 9da2c8672f7710 Alvin Šipraga 2026-06-06 @1323 vlan_filtering ? "enable" : "disable"); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1324 9da2c8672f7710 Alvin Šipraga 2026-06-06 1325 ret = rtl8365mb_vlan_port_get_framefilter(priv, port, 9da2c8672f7710 Alvin Šipraga 2026-06-06 1326 &prev_accepted_frame); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1327 if (ret) { 9da2c8672f7710 Alvin Šipraga 2026-06-06 1328 NL_SET_ERR_MSG_MOD(extack, 9da2c8672f7710 Alvin Šipraga 2026-06-06 1329 "Failed to get current framefilter"); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1330 return ret; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1331 } 9da2c8672f7710 Alvin Šipraga 2026-06-06 1332 9da2c8672f7710 Alvin Šipraga 2026-06-06 1333 /* While filtering, only accepts untagged frames if PVID is enabled */ 9da2c8672f7710 Alvin Šipraga 2026-06-06 1334 if (vlan_filtering) { 9da2c8672f7710 Alvin Šipraga 2026-06-06 1335 ret = rtl8365mb_vlan_port_get_pvid(priv, port, &pvid_vid); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1336 if (ret) 9da2c8672f7710 Alvin Šipraga 2026-06-06 1337 return ret; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1338 9da2c8672f7710 Alvin Šipraga 2026-06-06 1339 if (pvid_vid) 9da2c8672f7710 Alvin Šipraga 2026-06-06 1340 accepted_frame = RTL8365MB_FRAME_TYPE_ANY_FRAME; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1341 else 9da2c8672f7710 Alvin Šipraga 2026-06-06 1342 accepted_frame = RTL8365MB_FRAME_TYPE_TAGGED_ONLY; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1343 } else { 9da2c8672f7710 Alvin Šipraga 2026-06-06 1344 accepted_frame = RTL8365MB_FRAME_TYPE_ANY_FRAME; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1345 } 9da2c8672f7710 Alvin Šipraga 2026-06-06 1346 9da2c8672f7710 Alvin Šipraga 2026-06-06 1347 /* When vlan filter is enable/disabled in a bridge, this function is 9da2c8672f7710 Alvin Šipraga 2026-06-06 1348 * called for all member ports. We need to enable/disable ingress 9da2c8672f7710 Alvin Šipraga 2026-06-06 1349 * VLAN membership check. 9da2c8672f7710 Alvin Šipraga 2026-06-06 1350 */ 9da2c8672f7710 Alvin Šipraga 2026-06-06 1351 ret = rtl8365mb_port_set_ingress_filtering(priv, port, vlan_filtering); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1352 if (ret) 9da2c8672f7710 Alvin Šipraga 2026-06-06 1353 return ret; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1354 9da2c8672f7710 Alvin Šipraga 2026-06-06 1355 /* However, we also enable/disable egress filtering because the switch 9da2c8672f7710 Alvin Šipraga 2026-06-06 1356 * still consider the egress interface VLAN membership to forward the 9da2c8672f7710 Alvin Šipraga 2026-06-06 1357 * traffic. We enable/disable that check disabling/enabling transparent 9da2c8672f7710 Alvin Šipraga 2026-06-06 1358 * VLAN between the ingress port and all other available ports. 9da2c8672f7710 Alvin Šipraga 2026-06-06 1359 */ 9da2c8672f7710 Alvin Šipraga 2026-06-06 1360 dsa_switch_for_each_available_port(dp, ds) { 9da2c8672f7710 Alvin Šipraga 2026-06-06 1361 /* port isolation will still keep traffic inside the bridge */ 9da2c8672f7710 Alvin Šipraga 2026-06-06 1362 ret = rtl8365mb_port_set_transparent(priv, port, dp->index, 9da2c8672f7710 Alvin Šipraga 2026-06-06 1363 !vlan_filtering); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1364 if (ret) 9da2c8672f7710 Alvin Šipraga 2026-06-06 1365 goto undo_transparent; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1366 9da2c8672f7710 Alvin Šipraga 2026-06-06 1367 configured_ports |= BIT(dp->index); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1368 } 9da2c8672f7710 Alvin Šipraga 2026-06-06 1369 9da2c8672f7710 Alvin Šipraga 2026-06-06 1370 if (accepted_frame != prev_accepted_frame) { 9da2c8672f7710 Alvin Šipraga 2026-06-06 1371 ret = rtl8365mb_vlan_port_set_framefilter(priv, port, 9da2c8672f7710 Alvin Šipraga 2026-06-06 1372 accepted_frame); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1373 if (ret) { 9da2c8672f7710 Alvin Šipraga 2026-06-06 1374 NL_SET_ERR_MSG_MOD(extack, 9da2c8672f7710 Alvin Šipraga 2026-06-06 1375 "Failed to set port framefilter"); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1376 goto undo_transparent; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1377 } 9da2c8672f7710 Alvin Šipraga 2026-06-06 1378 } 9da2c8672f7710 Alvin Šipraga 2026-06-06 1379 9da2c8672f7710 Alvin Šipraga 2026-06-06 1380 /* When VLAN filtering is disabled, preserve frames exactly as received. 9da2c8672f7710 Alvin Šipraga 2026-06-06 1381 * Otherwise, the VLAN egress pipeline may still alter tag state 9da2c8672f7710 Alvin Šipraga 2026-06-06 1382 * according to VLAN membership and untag configuration. 9da2c8672f7710 Alvin Šipraga 2026-06-06 1383 */ 9da2c8672f7710 Alvin Šipraga 2026-06-06 1384 if (vlan_filtering) 9da2c8672f7710 Alvin Šipraga 2026-06-06 1385 mode = RTL8365MB_VLAN_EGRESS_MODE_ORIGINAL; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1386 else 9da2c8672f7710 Alvin Šipraga 2026-06-06 1387 mode = RTL8365MB_VLAN_EGRESS_MODE_REAL_KEEP; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1388 9da2c8672f7710 Alvin Šipraga 2026-06-06 1389 ret = rtl8365mb_port_set_vlan_egress_mode(priv, port, mode); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1390 if (ret) 9da2c8672f7710 Alvin Šipraga 2026-06-06 1391 goto undo_set_framefilter; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1392 9da2c8672f7710 Alvin Šipraga 2026-06-06 1393 return ret; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1394 9da2c8672f7710 Alvin Šipraga 2026-06-06 1395 undo_set_framefilter: 9da2c8672f7710 Alvin Šipraga 2026-06-06 1396 if (prev_accepted_frame != accepted_frame) 9da2c8672f7710 Alvin Šipraga 2026-06-06 1397 rtl8365mb_vlan_port_set_framefilter(priv, port, 9da2c8672f7710 Alvin Šipraga 2026-06-06 1398 prev_accepted_frame); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1399 undo_transparent: 9da2c8672f7710 Alvin Šipraga 2026-06-06 1400 /* The DSA core guarantees this callback is only invoked on an actual 9da2c8672f7710 Alvin Šipraga 2026-06-06 1401 * state transition, ensuring the previous hardware state was the 9da2c8672f7710 Alvin Šipraga 2026-06-06 1402 * opposite (!vlan_filtering). It is also called during setup but, in 9da2c8672f7710 Alvin Šipraga 2026-06-06 1403 * that case, any failure here aborts the entire switch initialization. 9da2c8672f7710 Alvin Šipraga 2026-06-06 1404 * 9da2c8672f7710 Alvin Šipraga 2026-06-06 1405 * VLAN_INGRESS and VLAN_EGRESS_TRANSPARENT states are directly derived 9da2c8672f7710 Alvin Šipraga 2026-06-06 1406 * from vlan_filtering. That way, we can simply undo it without 9da2c8672f7710 Alvin Šipraga 2026-06-06 1407 * checking the current HW state as we do with VLAN_EGRESS_MODE. 9da2c8672f7710 Alvin Šipraga 2026-06-06 1408 */ 9da2c8672f7710 Alvin Šipraga 2026-06-06 1409 dsa_switch_for_each_port(dp, ds) { 9da2c8672f7710 Alvin Šipraga 2026-06-06 1410 if (configured_ports & BIT(dp->index)) 9da2c8672f7710 Alvin Šipraga 2026-06-06 1411 rtl8365mb_port_set_transparent(priv, port, dp->index, 9da2c8672f7710 Alvin Šipraga 2026-06-06 1412 vlan_filtering); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1413 } 9da2c8672f7710 Alvin Šipraga 2026-06-06 1414 9da2c8672f7710 Alvin Šipraga 2026-06-06 1415 rtl8365mb_port_set_ingress_filtering(priv, port, !vlan_filtering); 9da2c8672f7710 Alvin Šipraga 2026-06-06 1416 9da2c8672f7710 Alvin Šipraga 2026-06-06 1417 return ret; 9da2c8672f7710 Alvin Šipraga 2026-06-06 1418 } 9da2c8672f7710 Alvin Šipraga 2026-06-06 1419 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki