-
-
Notifications
You must be signed in to change notification settings - Fork 11.5k
realtek: rtl93xx: add support for trapping management frames #19571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
realtek: rtl93xx: add support for trapping management frames #19571
Conversation
I'm not sure what Test Formalities is complaining about. maybe a missing space between name and mail address in the "Signed-off-by" line? |
0a285a0
to
ac5f274
Compare
285109a
to
26c0e18
Compare
Is this ready for testing with LLDP? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For other people reviewing the changes:
- https://svanheule.net/realtek/longan/register/rma_port_bpdu_ctrl
- https://svanheule.net/realtek/longan/register/rma_port_ptp_ctrl
- https://svanheule.net/realtek/longan/register/rma_port_lldp_ctrl
- https://svanheule.net/realtek/longan/register/rma_port_eapol_ctrl
- https://github.com/plappermaul/realtek-doc/blob/54589ff0afa70045abfdc71a3133aa55c76257bc/sources/rtk-xgs1210/system/include/private/drv/swcore/swcore_rtl9300.h#L6567
- https://github.com/plappermaul/realtek-doc/blob/54589ff0afa70045abfdc71a3133aa55c76257bc/sources/rtk-xgs1210/src/dal/longan/dal_longan_trap.c#L3263
case BPDU: | ||
reg = RTL930X_RMA_BPDU_CTRL + (port / 10) * 4; | ||
shift = (port % 10) * 3; | ||
sw_w32_mask(7 << shift, value << shift, reg); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
case FLOODALL: | ||
value = 4; | ||
break; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
What do you mean by testing? That LLDP is no longer forwarded to other ports but instead trapped to the CPU? After looking at the code, I would assume that this should work on RTL930x. |
/* hack for value mapping */ | ||
if (type == GRATARP && action == COPY2CPU) | ||
action = TRAP2MASTERCPU; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
case GRATARP: | ||
/* NOSUPPORT */ | ||
break; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
26c0e18
to
f198a03
Compare
EDIT - this build also appears to prevent tagged VLAN traffic, will test further. Tested on the Onti (clone of Xikestor SK8300X-8S) and while I do now see LLDP frames on the CPU port, there is also quite a lot of LLDP duplication occuring, which presents as the attached clients seeing frames from all active switch ports instead of just the attached interface:
|
Tagged VLAN traffic is accepted on the CPU port, but not forwarded to other tagged switch ports when this branch is used. |
This comment was marked as resolved.
This comment was marked as resolved.
I commented out the BPDU trap setup and tagged VLANs are working again:
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I meant that I can only send tagged traffic to the CPU port, the tagged traffic is not sent to the other access ports Tagged traffic reaches the CPU port, tagged traffic does not reach any other tagged ports which are members of the same VLAN. I am not running STP, so the lack of STP BPDU should not affect client reachability. |
@@ -529,6 +529,9 @@ static int rtl93xx_setup(struct dsa_switch *ds) | |||
|
|||
rtl83xx_vlan_setup(priv); | |||
|
|||
rtl83xx_setup_lldp_traps(priv); | |||
rtl83xx_setup_bpdu_traps(priv); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
f198a03
to
2ecc734
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. Please see comments.
switch (type) { | ||
case PTP: | ||
case PTP_UDP: | ||
case PTP_ETH2: | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this to the beginning and make a simple early-check / return.
default: | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm not understanding all possible combinations But that can leave value uninitialized (e.g for BDPU).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm not understanding all possible combinations But that can leave value uninitialized (e.g for BDPU).
No, the initialization of the value is directly below
case FLOODALL:
switch (type) {
case PTP:
case PTP_UDP:
case PTP_ETH2:
return;
default:
break;
}
value = 4;
break;
If it something wants FLOODALL
then it is getting the value 4. Only when it is PTP
, PTP_UDP
or PTP_ETH2
, nothing happens (because this value is invalid for it).
The break refers to the inner switch - not the outer one. Unfortunately, C doesn't have labels to correctly mark this for breaks/continues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another argument to move this sub-switch to the beginning with early return for better readability.
@@ -529,6 +529,8 @@ static int rtl93xx_setup(struct dsa_switch *ds) | |||
|
|||
rtl83xx_vlan_setup(priv); | |||
|
|||
rtl83xx_setup_lldp_traps(priv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you are here. Doesn't this miss also the rtl83xx_setup_bpdu_traps() from the RTL83xx initialization routine?
Regardeless if you add only this or both functions. Please directly rename the added functions to rtldsa_setup...() to end this generic prefix confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you are here. Doesn't this miss also the rtl83xx_setup_bpdu_traps() from the RTL83xx initialization routine?
I asked to remove this for now because @howels reported tagged VLAN problems when this line is added. And this PR needs to be merged (with #19802) to get LLDP working correctly.
I would show you my comment but github makes it hard to find old collapsed comments.
EDIT: #19571 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Then sinply rename rtl83xx_setup_lldp_traps to rtldsa_setup_lldp_traps() and change the two calling locations.
2ecc734
to
0751267
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
The functions to enable trapping of management frames are not RTL83xx specific. It is more appropriate to use the more generic "rtldsa" prefix for them. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Driver needs to configure management frame actions To support LLDP, EAPOL or MSTP, which needs to be trapped to the CPU instead of being forwarded Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Driver needs to configure management frame actions To support LLDP, EAPOL or MSTP, which needs to be trapped to the CPU instead of being forwarded. The function to implement the various management frame actions was already present but not yet registered correctly. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
LLDP packets must be transmitted on a single port and trapped on a port of a device which understands LLDP. It must not forward it to other ports to avoid confusing neighbor information on connected devices. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
0751267
to
18077d2
Compare
The functions to enable trapping of management frames are not RTL83xx specific. It is more appropriate to use the more generic "rtldsa" prefix for them. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Driver needs to configure management frame actions To support LLDP, EAPOL or MSTP, which needs to be trapped to the CPU instead of being forwarded Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Driver needs to configure management frame actions To support LLDP, EAPOL or MSTP, which needs to be trapped to the CPU instead of being forwarded. The function to implement the various management frame actions was already present but not yet registered correctly. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
LLDP packets must be transmitted on a single port and trapped on a port of a device which understands LLDP. It must not forward it to other ports to avoid confusing neighbor information on connected devices. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
The functions to enable trapping of management frames are not RTL83xx specific. It is more appropriate to use the more generic "rtldsa" prefix for them. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Driver needs to configure management frame actions To support LLDP, EAPOL or MSTP, which needs to be trapped to the CPU instead of being forwarded Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Driver needs to configure management frame actions To support LLDP, EAPOL or MSTP, which needs to be trapped to the CPU instead of being forwarded. The function to implement the various management frame actions was already present but not yet registered correctly. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
LLDP packets must be transmitted on a single port and trapped on a port of a device which understands LLDP. It must not forward it to other ports to avoid confusing neighbor information on connected devices. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
The functions to enable trapping of management frames are not RTL83xx specific. It is more appropriate to use the more generic "rtldsa" prefix for them. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt/openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Driver needs to configure management frame actions To support LLDP, EAPOL or MSTP, which needs to be trapped to the CPU instead of being forwarded Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt/openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Driver needs to configure management frame actions To support LLDP, EAPOL or MSTP, which needs to be trapped to the CPU instead of being forwarded. The function to implement the various management frame actions was already present but not yet registered correctly. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt/openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
LLDP packets must be transmitted on a single port and trapped on a port of a device which understands LLDP. It must not forward it to other ports to avoid confusing neighbor information on connected devices. Signed-off-by: Harshal Gohel <hg@simonwunderlich.de> Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de> Link: openwrt/openwrt#19571 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
To properly support protocols like LLDP, EAPOL, and MSTP, the driver must configure the switch to trap their management frames to the CPU rather than forwarding them. This commit adds support for configuring these frame traps on RTL93xx devices.