mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
port: read a trunk's members through one function
The member mask of an aggregation group is decoded by hand in two places, the lag command and the JSON behind the aggregation page, and every branch that touches trunks adds another copy. port_lag_members_get() sits next to port_lag_members_set() and both readers call it. It answers from the hardware, so it covers a group configured with lag and one a protocol brought up, without either having to say so. It reads through reg_read() rather than reg_read_m(), so sfr_data is left alone. Neither caller looked at it afterwards; both read the hash register next.
This commit is contained in:
+1
-2
@@ -250,8 +250,7 @@ void parse_lag(void)
|
||||
print_string("LAG status:\n");
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
write_char(' '); write_char('1' + i);
|
||||
reg_read_m(RTL837X_TRK_MBR_CTRL_BASE + (i << 2));
|
||||
members = ((uint16_t)sfr_data[2]) << 8 | sfr_data[3];
|
||||
members = port_lag_members_get(i);
|
||||
if (!members) {
|
||||
print_string(" disabled\n");
|
||||
continue;
|
||||
|
||||
+1
-2
@@ -518,8 +518,7 @@ void send_lag(void)
|
||||
slen += strtox(outbuf + slen, "{\"lagNum\":");
|
||||
itoa_html(l);
|
||||
slen += strtox(outbuf + slen, ",\"members\":\"");
|
||||
reg_read_m(RTL837X_TRK_MBR_CTRL_BASE + (l << 2));
|
||||
uint16_t ports = ((uint16_t)sfr_data[2] << 8) | sfr_data[3];
|
||||
uint16_t ports = port_lag_members_get(l);
|
||||
for (uint8_t i = 0; i < 16; i++) {
|
||||
bool_to_html(!!(ports & 0x8000));
|
||||
ports <<= 1;
|
||||
|
||||
@@ -733,6 +733,19 @@ void port_rldp_on(__xdata uint16_t p_ms)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Reads the member port bitmask of a Link Aggregation Group.
|
||||
* The groups have numbers 0-3; bit n is set when logical port n is a member.
|
||||
* The bitmask reflects what the hardware holds, so it covers groups set up
|
||||
* statically and groups a protocol brought up, without either having to say so.
|
||||
*/
|
||||
uint16_t port_lag_members_get(uint8_t lag) __banked
|
||||
{
|
||||
reg_read(RTL837X_TRK_MBR_CTRL_BASE + (lag << 2));
|
||||
return ((uint16_t)SFR_DATA_8 << 8) | SFR_DATA_0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Configure LAGs
|
||||
* Sets the members via port bitmask of a given Link Aggregation Group
|
||||
|
||||
@@ -61,6 +61,7 @@ void port_mirror_set(register uint8_t port, __xdata uint16_t rx_pmask, __xdata u
|
||||
void port_mirror_del(void) __banked;
|
||||
bool port_ingress_filter(__xdata uint8_t port, __xdata vlan_ingress_mode_t type) __banked;
|
||||
void port_l2_setup(void) __banked;
|
||||
uint16_t port_lag_members_get(uint8_t lag) __banked;
|
||||
void port_lag_members_set(__xdata uint8_t lag, __xdata uint16_t members) __banked;
|
||||
void port_lag_hash_set(__xdata uint8_t lag, __xdata uint8_t hash) __banked;
|
||||
void port_eee_enable_all(__xdata uint8_t speed) __banked;
|
||||
|
||||
Reference in New Issue
Block a user