aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c
Commit message (Collapse)AuthorAgeFilesLines
* realtek: Add missing headersOlliver Schinagl2023-06-121-0/+1
| | | | | | | | We are missing a bunch of headers, which trigger errors on 6.1, probably due to changed header-in-header dependencies. Best add them now. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl> (cherry picked from commit 9fb1dbb1df35911b407fa0faaa2443fbc0f0ddde)
* realtek: 5.15: comment unused part of realtek ethernet driverChristian Marangi2023-05-121-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Comment unused part of realtek phy driver. Fix compilation warning: drivers/net/phy/rtl83xx-phy.c: In function 'rtl8380_configure_int_rtl8218b': drivers/net/phy/rtl83xx-phy.c:747:21: error: unused variable 'ipd_flag' [-Werror=unused-variable] 747 | int ipd_flag = 1; | ^~~~~~~~ drivers/net/phy/rtl83xx-phy.c: At top level: drivers/net/phy/rtl83xx-phy.c:3333:13: error: 'rtl931x_sds_disable' defined but not used [-Werror=unused-function] 3333 | static void rtl931x_sds_disable(u32 sds) | ^~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Comment unused part of realtek dsa driver. Fix compilation warning: drivers/net/dsa/rtl83xx/common.c: In function 'rtl83xx_fib_event': drivers/net/dsa/rtl83xx/common.c:1430:58: error: unused variable 'fen6_info' [-Werror=unused-variable] 1430 | struct fib6_entry_notifier_info *fen6_info = ptr; | ^~~~~~~~~ drivers/net/dsa/rtl83xx/common.c: At top level: drivers/net/dsa/rtl83xx/common.c:531:12: error: 'rtl83xx_octet_cntr_alloc' defined but not used [-Werror=unused-function] 531 | static int rtl83xx_octet_cntr_alloc(struct rtl838x_switch_priv *priv) | ^~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Drop unused priv in realtek dsa driver. Fix compilation warning: drivers/net/dsa/rtl83xx/dsa.c: In function 'rtl83xx_port_lag_change': drivers/net/dsa/rtl83xx/dsa.c:2016:37: error: unused variable 'priv' [-Werror=unused-variable] 2016 | struct rtl838x_switch_priv *priv = ds->priv; | ^~~~ cc1: all warnings being treated as errors Comment rtl838x_pie_rule_dump in realtek dsa driver for rtl83xx Fix compilation warning: drivers/net/dsa/rtl83xx/rtl838x.c:1294:13: error: 'rtl838x_pie_rule_dump' defined but not used [-Werror=unused-function] 1294 | static void rtl838x_pie_rule_dump(struct pie_rule *pr) | ^~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Comment multiple function in realtek dsa driver for rtl930x Fix compilation warning: drivers/net/dsa/rtl83xx/rtl930x.c:1463:12: error: 'rtl930x_l3_intf_add' defined but not used [-Werror=unused-function] 1463 | static int rtl930x_l3_intf_add(struct rtl838x_switch_priv *priv, struct rtl838x_l3_intf *intf) | ^~~~~~~~~~~~~~~~~~~ drivers/net/dsa/rtl83xx/rtl930x.c:1414:12: error: 'rtl930x_l3_mtu_del' defined but not used [-Werror=unused-function] 1414 | static int rtl930x_l3_mtu_del(struct rtl838x_switch_priv *priv, int mtu) | ^~~~~~~~~~~~~~~~~~ drivers/net/dsa/rtl83xx/rtl930x.c:995:12: error: 'rtl930x_l3_hash6' defined but not used [-Werror=unused-function] 995 | static u32 rtl930x_l3_hash6(struct in6_addr *ip6, int algorithm, bool move_dip) | ^~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors drivers/net/dsa/rtl83xx/rtl930x.c:1690:13: error: 'rtl930x_read_pie_fixed_fields' defined but not used [-Werror=unused-function] 1690 | static void rtl930x_read_pie_fixed_fields(u32 r[], struct pie_rule *pr) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/dsa/rtl83xx/rtl930x.c:1432:12: error: 'rtl930x_l3_mtu_add' defined but not used [-Werror=unused-function] 1432 | static int rtl930x_l3_mtu_add(struct rtl838x_switch_priv *priv, int mtu) | ^~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Comment rtl931x_read_pie_fixed_fields in realtek dsa driver for rtl931x Fix compilation warning: drivers/net/dsa/rtl83xx/rtl931x.c:1116:13: error: 'rtl931x_read_pie_fixed_fields' defined but not used [-Werror=unused-function] 1116 | static void rtl931x_read_pie_fixed_fields(u32 r[], struct pie_rule *pr) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Comment rtl93xx_header_vlan_set in realtek ethernet driver for rtl838x Fix compilation warning: drivers/net/ethernet/rtl838x_eth.c: At top level: drivers/net/ethernet/rtl838x_eth.c:164:13: error: 'rtl93xx_header_vlan_set' defined but not used [-Werror=unused-function] 164 | static void rtl93xx_header_vlan_set(struct p_hdr *h, int vlan) | ^~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
* realtek: remove redundant is_lagmember checksJan Hoffmann2023-05-071-13/+2
| | | | | | | | | | | | | All callers of the rtl83xx_mc_group_* functions already do the same check, so these aren't needed. For rtl83xx_mc_group_alloc, this branch also incorrectly returned 0 instead of a negative value. If the branch wasn't effectively dead code anyway, this could potentially have caused bugs, as 0 is a valid multicast group entry index. Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: remove store_mcgroups/load_mcgroupsJan Hoffmann2023-05-071-26/+0
| | | | | | | | | | | | | | | | | | | The current implementation only works when store and load are called for the same port without any other calls in between. This is because the store function only saves a single port number instead of a portmask for each group. It also doesn't take into account that the allocation of multicast group entries might change between store/load calls. As a result, the multicast port mask table gets corrupted. This also includes the reserved entry for unknown multicast, which gets corrupted even when no other mdb entries have been added. Remove the code for storing/loading multicast groups entirely, as the original commit message doesn't offer a convincing reason why this would be necessary in the first place. Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable") Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: don't add CPU port to multicast portmasksJan Hoffmann2023-05-071-5/+2
| | | | | | | | | | | | | There shouldn't be any reason to forward all multicast to the CPU. The original commit message also doesn't provide a reason for this seemingly unrelated change. The current implementation of the delete method is also broken, as it entirely removes any entry when the portmask contains only the CPU port, even if it was explicitly created. Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable") Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: actually remove port from multicast portmaskJan Hoffmann2023-05-071-0/+1
| | | | | Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable") Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: don't treat first multicast portmask entry as reservedJan Hoffmann2023-05-071-1/+0
| | | | | | | | | | | | | | There doesn't appear to be a reason to do this, as only the last entry is actually reserved for unknown multicast. This also fixes two issues: - As the increment happened after the bounds check, the value of the actually reserved last entry could be overwritten. - On deletion of entries, a corresponding decrement was missing, causing the wrong entry to be marked as free. Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: fix writing/deletion of CAM entriesJan Hoffmann2023-05-071-4/+4
| | | | | | | Actually use the index returned by rtl83xx_find_l2_cam_entry. Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: handle changed flags in VLAN configurationJan Hoffmann2023-05-071-17/+21
| | | | | | | | | | | The port_vlan_add method may be called while a port is already a member of that VLAN, so it needs to be able to handle changed flags. Fix it to properly handle when the PVID or UNTAGGED flag was previously set, but now no longer is. To reduce duplication, move PVID configuration to a separate function. Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: fix standalone ports in presence of static fdb entriesJan Hoffmann2023-05-071-0/+15
| | | | | | | | | | | | | | | | | | | | The registers L2_PORT_STATIC_MV_ACT seem to specify the action to take when the source address of a packet exists as a static fdb entry on another port. By default the configured action is to drop such packets. For standalone ports, this behaviour is undesired, as all traffic should be forwarded to the CPU. So change the action to forward on standalone ports. A situation where this issue can occur is when a non-offloaded bond interface is part of a bridge. In that case, the CPU port will have fdb entries for devices connected to the bond interface, which are managed by the assisted learning feature. For now, this is only implemented for RTL838x/RTL839x, as the available set of registers differs for the other devices. Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: initialize port masks to match the default stateJan Hoffmann2023-05-071-12/+11
| | | | | | | | | | | | | All ports are disabled by default, so configure the port isolation masks and the pm field accordingly in the setup function. When port_enable is called for a port, the isolation masks will be set up so that traffic can flow between the port and the CPU. While at it, change the code to also use the traffic_set method in rtl83xx_setup, instead of writing to the RTL838x_PORT_ISO_CTRL(i) registers directly. Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: properly update port masks when port leaves bridgeJan Hoffmann2023-05-071-5/+5
| | | | | | | | | | | | | | | | | Correctly update the isolation mask of the port being configured. The port_bitmap variable should contain all other bridge members and needs to be actually removed from the isolation mask instead of added to it. Also actually remove the port being configured from the pm field of the other ports, so that any other ports that are currently disabled will be configured correctly when they are enabled. Fixes: df8e6be59a1f ("rtl838x: add new architecture") [fixed updating pm field of other ports] Fixes: 2b88563ee5aa ("realtek: update the tree to the latest refactored version") [reintroduced incorrect pm field update] Fixes: 27029277f98d ("realtek: add switch driver support for the RTL93XX based switches") Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: Reduce variable scopesOlliver Schinagl2022-12-271-37/+21
| | | | | | | | | | | | | | Linus prefers to have loop initializers nice and tightly scoped. In OpenWRT this has been possible since 41a1a652fbd4 ("kernel: backport gnu11 upgrade"). This patch cleans up variable scope while trying to do the above for 'simple for loops'. This cleans up and simplifies some functions and code, and pulls in variables to a smaller scope. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
* realtek: Replace C++ style commentsOlliver Schinagl2022-12-271-33/+33
| | | | | | | The only exception to C++ style comments are SPDX license identifier markers at the start of C files (even headers have C style markers). Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
* realtek: Whitespace and codestyle cleanupOlliver Schinagl2022-12-271-33/+42
| | | | | | | | Fix some ugly whitepsaces and codestyle issues around the realtek sources. While this is by no means perfect, it catches what it caught. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
* realtek: add cond_resched to loops accessing the FDB tableJan Hoffmann2022-12-271-0/+3
| | | | | | | | | A full loop accessing all FDB entries can take several milliseconds (on RTL839x about 20 ms), so give other kernel tasks a chance to run. This is especially important for rtl83xx_port_fdb_dump which is itself called in a loop for all ports by the kernel. Signed-off-by: Jan Hoffmann <jan@3e8.eu>
* realtek: update dsa.c of DSA driver for 5.15INAGAKI Hiroshi2022-12-151-101/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - rtl83xx_vlan_filtering() "struct switchdev_trans *trans" parameter was removed[1] and "struct netlink_ext_ack *extack" was added[2]. [1]: https://www.spinics.net/lists/netdev/msg712250.html [2]: https://www.spinics.net/lists/netdev/msg722496.html - rtl83xx_vlan_add/del() vlan->vid_begin and vlan->vid_end were removed and vlan->vid was added[3]. [3]: https://www.spinics.net/lists/netdev/msg712248.html - rtl83xx_vlan_prepare() "port_vlan_prepare" member was removed from "dsa_switch_ops" struct in dsa.h[4] and vlan_prepare function should be called from vlan_add function. Also, change return type of vlan_add function to int. [4]: https://www.spinics.net/lists/netdev/msg712252.html - rtl83xx_port_mdb_add() "port_mdb_prepare" member in "dsa_switch_ops" struct was removed and preparation need to be done in the function of "port_mdb_add" member instead. And also, int type need to be returned on "port_mdb_add" member[5]. [5]: https://www.spinics.net/lists/netdev/msg712251.html - rtl83xx_port_pre_bridge_flags(), rtl83xx_port_bridge_flags() The current "port_pre_bridge_flags" member and "port_bridge_flags" member in "dsa_switch_ops" in dsa.h has flags of "struct switchdev_brport_flags" type instead[6], so adjust to it. And, the changed features are passed by flags.mask[7] in rtl83xx_port_bridge_flags(), so check it before calling function to enable/disable fieature. [6]: https://lore.kernel.org/lkml/20210212151600.3357121-7-olteanv@gmail.com/ [7]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e18f4c18ab5b0dd47caaf8377c2e36d66f632a8c Suggested-by: Markus Stockhausen <markus.stockhausen@gmx.de> Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com> [shorten final return statement of rtl83xx_port_mdb_add()] Signed-off-by: Sander Vanheule <sander@svanheule.net>
* realtek: copy dts/files/patches/configs for 5.15INAGAKI Hiroshi2022-12-151-0/+2259
Copy dts/files/patches/configs from 5.10 to 5.15. Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com> [refresh with updated DGS-1210 dts files] Signed-off-by: Sander Vanheule <sander@svanheule.net>