Lines Matching full:lan966x
35 static int lan966x_mac_get_status(struct lan966x *lan966x) in lan966x_mac_get_status() argument
37 return lan_rd(lan966x, ANA_MACACCESS); in lan966x_mac_get_status()
40 static int lan966x_mac_wait_for_completion(struct lan966x *lan966x) in lan966x_mac_wait_for_completion() argument
45 lan966x, val, in lan966x_mac_wait_for_completion()
52 static void lan966x_mac_select(struct lan966x *lan966x, in lan966x_mac_select() argument
69 lan_wr(macl, lan966x, ANA_MACLDATA); in lan966x_mac_select()
70 lan_wr(mach, lan966x, ANA_MACHDATA); in lan966x_mac_select()
73 static int __lan966x_mac_learn_locked(struct lan966x *lan966x, int pgid, in __lan966x_mac_learn_locked() argument
79 lockdep_assert_held(&lan966x->mac_lock); in __lan966x_mac_learn_locked()
81 lan966x_mac_select(lan966x, mac, vid); in __lan966x_mac_learn_locked()
90 lan966x, ANA_MACACCESS); in __lan966x_mac_learn_locked()
92 return lan966x_mac_wait_for_completion(lan966x); in __lan966x_mac_learn_locked()
95 static int __lan966x_mac_learn(struct lan966x *lan966x, int pgid, in __lan966x_mac_learn() argument
103 spin_lock(&lan966x->mac_lock); in __lan966x_mac_learn()
104 ret = __lan966x_mac_learn_locked(lan966x, pgid, cpu_copy, mac, vid, type); in __lan966x_mac_learn()
105 spin_unlock(&lan966x->mac_lock); in __lan966x_mac_learn()
113 int lan966x_mac_ip_learn(struct lan966x *lan966x, in lan966x_mac_ip_learn() argument
121 return __lan966x_mac_learn(lan966x, 0, cpu_copy, mac, vid, type); in lan966x_mac_ip_learn()
124 int lan966x_mac_learn(struct lan966x *lan966x, int port, in lan966x_mac_learn() argument
131 return __lan966x_mac_learn(lan966x, port, false, mac, vid, type); in lan966x_mac_learn()
134 static int lan966x_mac_learn_locked(struct lan966x *lan966x, int port, in lan966x_mac_learn_locked() argument
141 return __lan966x_mac_learn_locked(lan966x, port, false, mac, vid, type); in lan966x_mac_learn_locked()
144 static int lan966x_mac_forget_locked(struct lan966x *lan966x, in lan966x_mac_forget_locked() argument
149 lockdep_assert_held(&lan966x->mac_lock); in lan966x_mac_forget_locked()
151 lan966x_mac_select(lan966x, mac, vid); in lan966x_mac_forget_locked()
156 lan966x, ANA_MACACCESS); in lan966x_mac_forget_locked()
158 return lan966x_mac_wait_for_completion(lan966x); in lan966x_mac_forget_locked()
161 int lan966x_mac_forget(struct lan966x *lan966x, in lan966x_mac_forget() argument
168 spin_lock(&lan966x->mac_lock); in lan966x_mac_forget()
169 ret = lan966x_mac_forget_locked(lan966x, mac, vid, type); in lan966x_mac_forget()
170 spin_unlock(&lan966x->mac_lock); in lan966x_mac_forget()
175 int lan966x_mac_cpu_learn(struct lan966x *lan966x, const char *addr, u16 vid) in lan966x_mac_cpu_learn() argument
177 return lan966x_mac_learn(lan966x, PGID_CPU, addr, vid, ENTRYTYPE_LOCKED); in lan966x_mac_cpu_learn()
180 int lan966x_mac_cpu_forget(struct lan966x *lan966x, const char *addr, u16 vid) in lan966x_mac_cpu_forget() argument
182 return lan966x_mac_forget(lan966x, addr, vid, ENTRYTYPE_LOCKED); in lan966x_mac_cpu_forget()
185 void lan966x_mac_set_ageing(struct lan966x *lan966x, in lan966x_mac_set_ageing() argument
190 lan966x, ANA_AUTOAGE); in lan966x_mac_set_ageing()
193 void lan966x_mac_init(struct lan966x *lan966x) in lan966x_mac_init() argument
196 lan_wr(MACACCESS_CMD_INIT, lan966x, ANA_MACACCESS); in lan966x_mac_init()
197 lan966x_mac_wait_for_completion(lan966x); in lan966x_mac_init()
199 spin_lock_init(&lan966x->mac_lock); in lan966x_mac_init()
200 INIT_LIST_HEAD(&lan966x->mac_entries); in lan966x_mac_init()
221 static struct lan966x_mac_entry *lan966x_mac_find_entry(struct lan966x *lan966x, in lan966x_mac_find_entry() argument
228 list_for_each_entry(mac_entry, &lan966x->mac_entries, list) { in lan966x_mac_find_entry()
240 static int lan966x_mac_lookup(struct lan966x *lan966x, in lan966x_mac_lookup() argument
246 lan966x_mac_select(lan966x, mac, vid); in lan966x_mac_lookup()
252 lan966x, ANA_MACACCESS); in lan966x_mac_lookup()
254 ret = lan966x_mac_wait_for_completion(lan966x); in lan966x_mac_lookup()
258 return ANA_MACACCESS_VALID_GET(lan_rd(lan966x, ANA_MACACCESS)); in lan966x_mac_lookup()
273 int lan966x_mac_add_entry(struct lan966x *lan966x, struct lan966x_port *port, in lan966x_mac_add_entry() argument
278 spin_lock(&lan966x->mac_lock); in lan966x_mac_add_entry()
279 if (lan966x_mac_lookup(lan966x, addr, vid, ENTRYTYPE_NORMAL)) { in lan966x_mac_add_entry()
280 spin_unlock(&lan966x->mac_lock); in lan966x_mac_add_entry()
290 mac_entry = lan966x_mac_find_entry(lan966x, addr, vid, port->chip_port); in lan966x_mac_add_entry()
292 spin_unlock(&lan966x->mac_lock); in lan966x_mac_add_entry()
298 spin_unlock(&lan966x->mac_lock); in lan966x_mac_add_entry()
302 list_add_tail(&mac_entry->list, &lan966x->mac_entries); in lan966x_mac_add_entry()
303 spin_unlock(&lan966x->mac_lock); in lan966x_mac_add_entry()
309 lan966x_mac_learn(lan966x, port->chip_port, addr, vid, ENTRYTYPE_LOCKED); in lan966x_mac_add_entry()
314 int lan966x_mac_del_entry(struct lan966x *lan966x, const unsigned char *addr, in lan966x_mac_del_entry() argument
319 spin_lock(&lan966x->mac_lock); in lan966x_mac_del_entry()
320 list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries, in lan966x_mac_del_entry()
324 lan966x_mac_forget_locked(lan966x, mac_entry->mac, in lan966x_mac_del_entry()
332 spin_unlock(&lan966x->mac_lock); in lan966x_mac_del_entry()
337 void lan966x_mac_lag_replace_port_entry(struct lan966x *lan966x, in lan966x_mac_lag_replace_port_entry() argument
343 spin_lock(&lan966x->mac_lock); in lan966x_mac_lag_replace_port_entry()
344 list_for_each_entry(mac_entry, &lan966x->mac_entries, list) { in lan966x_mac_lag_replace_port_entry()
347 lan966x_mac_forget_locked(lan966x, mac_entry->mac, in lan966x_mac_lag_replace_port_entry()
351 lan966x_mac_learn_locked(lan966x, dst->chip_port, in lan966x_mac_lag_replace_port_entry()
357 spin_unlock(&lan966x->mac_lock); in lan966x_mac_lag_replace_port_entry()
360 void lan966x_mac_lag_remove_port_entry(struct lan966x *lan966x, in lan966x_mac_lag_remove_port_entry() argument
365 spin_lock(&lan966x->mac_lock); in lan966x_mac_lag_remove_port_entry()
366 list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries, in lan966x_mac_lag_remove_port_entry()
370 lan966x_mac_forget_locked(lan966x, mac_entry->mac, in lan966x_mac_lag_remove_port_entry()
378 spin_unlock(&lan966x->mac_lock); in lan966x_mac_lag_remove_port_entry()
381 void lan966x_mac_purge_entries(struct lan966x *lan966x) in lan966x_mac_purge_entries() argument
385 spin_lock(&lan966x->mac_lock); in lan966x_mac_purge_entries()
386 list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries, in lan966x_mac_purge_entries()
388 lan966x_mac_forget_locked(lan966x, mac_entry->mac, in lan966x_mac_purge_entries()
394 spin_unlock(&lan966x->mac_lock); in lan966x_mac_purge_entries()
420 static void lan966x_mac_irq_process(struct lan966x *lan966x, u32 row, in lan966x_mac_irq_process() argument
433 spin_lock(&lan966x->mac_lock); in lan966x_mac_irq_process()
434 list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries, list) { in lan966x_mac_irq_process()
450 if (WARN_ON(dest_idx >= lan966x->num_phys_ports)) in lan966x_mac_irq_process()
473 spin_unlock(&lan966x->mac_lock); in lan966x_mac_irq_process()
479 port = lan966x->ports[mac_entry->port_index]; in lan966x_mac_irq_process()
504 if (WARN_ON(dest_idx >= lan966x->num_phys_ports)) in lan966x_mac_irq_process()
507 spin_lock(&lan966x->mac_lock); in lan966x_mac_irq_process()
508 mac_entry = lan966x_mac_find_entry(lan966x, mac, vid, dest_idx); in lan966x_mac_irq_process()
510 spin_unlock(&lan966x->mac_lock); in lan966x_mac_irq_process()
514 port = lan966x->ports[dest_idx]; in lan966x_mac_irq_process()
517 spin_unlock(&lan966x->mac_lock); in lan966x_mac_irq_process()
522 list_add_tail(&mac_entry->list, &lan966x->mac_entries); in lan966x_mac_irq_process()
523 spin_unlock(&lan966x->mac_lock); in lan966x_mac_irq_process()
530 irqreturn_t lan966x_mac_irq_handler(struct lan966x *lan966x) in lan966x_mac_irq_handler() argument
540 lan966x, ANA_MACTINDX); in lan966x_mac_irq_handler()
543 spin_lock(&lan966x->mac_lock); in lan966x_mac_irq_handler()
546 lan966x, ANA_MACACCESS); in lan966x_mac_irq_handler()
547 lan966x_mac_wait_for_completion(lan966x); in lan966x_mac_irq_handler()
549 val = lan_rd(lan966x, ANA_MACTINDX); in lan966x_mac_irq_handler()
568 spin_unlock(&lan966x->mac_lock); in lan966x_mac_irq_handler()
572 entry[column].mach = lan_rd(lan966x, ANA_MACHDATA); in lan966x_mac_irq_handler()
573 entry[column].macl = lan_rd(lan966x, ANA_MACLDATA); in lan966x_mac_irq_handler()
574 entry[column].maca = lan_rd(lan966x, ANA_MACACCESS); in lan966x_mac_irq_handler()
575 spin_unlock(&lan966x->mac_lock); in lan966x_mac_irq_handler()
579 lan966x_mac_irq_process(lan966x, index, entry); in lan966x_mac_irq_handler()
589 lan966x, ANA_ANAINTR); in lan966x_mac_irq_handler()