/* Set the MAC address to handle and the vlan associated in a format * understood by the hardware.
*/
mach |= vid << 16;
mach |= mac[0] << 8;
mach |= mac[1] << 0;
macl |= mac[2] << 24;
macl |= mac[3] << 16;
macl |= mac[4] << 8;
macl |= mac[5] << 0;
staticint __lan966x_mac_learn(struct lan966x *lan966x, int pgid, bool cpu_copy, constunsignedchar mac[ETH_ALEN], unsignedint vid, enum macaccess_entry_type type)
{ int ret;
spin_lock(&lan966x->mac_lock);
ret = __lan966x_mac_learn_locked(lan966x, pgid, cpu_copy, mac, vid, type);
spin_unlock(&lan966x->mac_lock);
return ret;
}
/* The mask of the front ports is encoded inside the mac parameter via a call * to lan966x_mdb_encode_mac().
*/ int lan966x_mac_ip_learn(struct lan966x *lan966x, bool cpu_copy, constunsignedchar mac[ETH_ALEN], unsignedint vid, enum macaccess_entry_type type)
{
WARN_ON(type != ENTRYTYPE_MACV4 && type != ENTRYTYPE_MACV6);
/* In case the entry already exists, don't add it again to SW, * just update HW, but we need to look in the actual HW because * it is possible for an entry to be learn by HW and before we * get the interrupt the frame will reach CPU and the CPU will * add the entry but without the extern_learn flag.
*/
mac_entry = lan966x_mac_find_entry(lan966x, addr, vid, port->chip_port); if (mac_entry) {
spin_unlock(&lan966x->mac_lock); goto mac_learn;
}
spin_lock(&lan966x->mac_lock);
list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries, list) { bool found = false;
if (mac_entry->row != row) continue;
for (column = 0; column < LAN966X_MAC_COLUMNS; ++column) { /* All the valid entries are at the start of the row, * so when get one invalid entry it can just skip the * rest of the columns
*/ if (!ANA_MACACCESS_VALID_GET(raw_entries[column].maca)) break;
lan966x_mac_process_raw_entry(&raw_entries[column],
mac, &vid, &dest_idx); if (WARN_ON(dest_idx >= lan966x->num_phys_ports)) continue;
/* If the entry in SW is found, then there is nothing * to do
*/ if (mac_entry->vid == vid &&
ether_addr_equal(mac_entry->mac, mac) &&
mac_entry->port_index == dest_idx) {
raw_entries[column].processed = true;
found = true; break;
}
}
if (!found) {
list_del(&mac_entry->list); /* Move the entry from SW list to a tmp list such that * it would be deleted later
*/
list_add_tail(&mac_entry->list, &mac_deleted_entries);
}
}
spin_unlock(&lan966x->mac_lock);
list_for_each_entry_safe(mac_entry, tmp, &mac_deleted_entries, list) { /* Notify the bridge that the entry doesn't exist * anymore in the HW
*/
port = lan966x->ports[mac_entry->port_index];
lan966x_mac_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE,
mac_entry->mac, mac_entry->vid,
port->bond ?: port->dev);
list_del(&mac_entry->list);
kfree(mac_entry);
}
/* Now go to the list of columns and see if any entry was not in the SW * list, then that means that the entry is new so it needs to notify the * bridge.
*/ for (column = 0; column < LAN966X_MAC_COLUMNS; ++column) { /* All the valid entries are at the start of the row, so when * get one invalid entry it can just skip the rest of the columns
*/ if (!ANA_MACACCESS_VALID_GET(raw_entries[column].maca)) break;
/* If the entry already exists then don't do anything */ if (raw_entries[column].processed) continue;
lan966x_mac_process_raw_entry(&raw_entries[column],
mac, &vid, &dest_idx); if (WARN_ON(dest_idx >= lan966x->num_phys_ports)) continue;
/* Start the scan from 0, 0 */
lan_wr(ANA_MACTINDX_M_INDEX_SET(0) |
ANA_MACTINDX_BUCKET_SET(0),
lan966x, ANA_MACTINDX);
while (1) {
spin_lock(&lan966x->mac_lock);
lan_rmw(ANA_MACACCESS_MAC_TABLE_CMD_SET(MACACCESS_CMD_SYNC_GET_NEXT),
ANA_MACACCESS_MAC_TABLE_CMD,
lan966x, ANA_MACACCESS);
lan966x_mac_wait_for_completion(lan966x);
val = lan_rd(lan966x, ANA_MACTINDX);
index = ANA_MACTINDX_M_INDEX_GET(val);
column = ANA_MACTINDX_BUCKET_GET(val);
/* The SYNC-GET-NEXT returns all the entries(4) in a row in * which is suffered a change. By change it means that new entry * was added or an entry was removed because of ageing. * It would return all the columns for that row. And after that * it would return the next row The stop conditions of the * SYNC-GET-NEXT is when it reaches 'directly' to row 0 * column 3. So if SYNC-GET-NEXT returns row 0 and column 0 * then it is required to continue to read more even if it * reaches row 0 and column 3.
*/ if (index == 0 && column == 0)
stop = false;
if (column == LAN966X_MAC_COLUMNS - 1 &&
index == 0 && stop) {
spin_unlock(&lan966x->mac_lock); break;
}
/* Once all the columns are read process them */ if (column == LAN966X_MAC_COLUMNS - 1) {
lan966x_mac_irq_process(lan966x, index, entry); /* A row was processed so it is safe to assume that the * next row/column can be the stop condition
*/
stop = true;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.