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 *tolan966x_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);
spin_lock(&lan966x->mac_lock); if (lan966x_mac_lookup(lan966x, addr, vid, ENTRYTYPE_NORMAL)) {
spin_unlock(&lan966x->mac_lock); return0;
}
/* In case the entry already exists, don't add it again to SW, *justupdateHW,butweneedtolookintheactualHWbecause *itispossibleforanentrytobelearnbyHWandbeforewe *gettheinterrupttheframewillreachCPUandtheCPUwill *addtheentrybutwithouttheextern_learnflag.
*/
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, *sowhengetoneinvalidentryitcanjustskipthe *restofthecolumns
*/ 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 *todo
*/ 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 *itwouldbedeletedlater
*/
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 *anymoreintheHW
*/
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,thenthatmeansthattheentryisnewsoitneedstonotifythe *bridge.
*/ for (column = 0; column < LAN966X_MAC_COLUMNS; ++column) { /* All the valid entries are at the start of the row, so when *getoneinvalidentryitcanjustskiptherestofthecolumns
*/ 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 *whichissufferedachange.Bychangeitmeansthatnewentry *wasaddedoranentrywasremovedbecauseofageing. *Itwouldreturnallthecolumnsforthatrow.Andafterthat *itwouldreturnthenextrowThestopconditionsofthe *SYNC-GET-NEXTiswhenitreaches'directly'torow0 *column3.SoifSYNC-GET-NEXTreturnsrow0andcolumn0 *thenitisrequiredtocontinuetoreadmoreevenifit *reachesrow0andcolumn3.
*/ 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 *nextrow/columncanbethestopcondition
*/
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.