Lines Matching refs:sparx5
44 static int sparx5_mact_get_status(struct sparx5 *sparx5) in sparx5_mact_get_status() argument
46 return spx5_rd(sparx5, LRN_COMMON_ACCESS_CTRL); in sparx5_mact_get_status()
49 static int sparx5_mact_wait_for_completion(struct sparx5 *sparx5) in sparx5_mact_wait_for_completion() argument
54 sparx5, val, in sparx5_mact_wait_for_completion()
59 static void sparx5_mact_select(struct sparx5 *sparx5, in sparx5_mact_select() argument
76 spx5_wr(mach, sparx5, LRN_MAC_ACCESS_CFG_0); in sparx5_mact_select()
77 spx5_wr(macl, sparx5, LRN_MAC_ACCESS_CFG_1); in sparx5_mact_select()
80 int sparx5_mact_learn(struct sparx5 *sparx5, int pgid, in sparx5_mact_learn() argument
94 mutex_lock(&sparx5->lock); in sparx5_mact_learn()
96 sparx5_mact_select(sparx5, mac, vid); in sparx5_mact_learn()
103 sparx5, LRN_MAC_ACCESS_CFG_2); in sparx5_mact_learn()
104 spx5_wr(0, sparx5, LRN_MAC_ACCESS_CFG_3); in sparx5_mact_learn()
109 sparx5, LRN_COMMON_ACCESS_CTRL); in sparx5_mact_learn()
111 ret = sparx5_mact_wait_for_completion(sparx5); in sparx5_mact_learn()
113 mutex_unlock(&sparx5->lock); in sparx5_mact_learn()
121 struct sparx5 *sparx5 = port->sparx5; in sparx5_mc_unsync() local
123 return sparx5_mact_forget(sparx5, addr, port->pvid); in sparx5_mc_unsync()
129 struct sparx5 *sparx5 = port->sparx5; in sparx5_mc_sync() local
131 return sparx5_mact_learn(sparx5, PGID_CPU, addr, port->pvid); in sparx5_mc_sync()
134 static int sparx5_mact_get(struct sparx5 *sparx5, in sparx5_mact_get() argument
141 cfg2 = spx5_rd(sparx5, LRN_MAC_ACCESS_CFG_2); in sparx5_mact_get()
143 mach = spx5_rd(sparx5, LRN_MAC_ACCESS_CFG_0); in sparx5_mact_get()
144 macl = spx5_rd(sparx5, LRN_MAC_ACCESS_CFG_1); in sparx5_mact_get()
159 bool sparx5_mact_getnext(struct sparx5 *sparx5, in sparx5_mact_getnext() argument
165 mutex_lock(&sparx5->lock); in sparx5_mact_getnext()
167 sparx5_mact_select(sparx5, mac, *vid); in sparx5_mact_getnext()
171 sparx5, LRN_SCAN_NEXT_CFG); in sparx5_mact_getnext()
175 sparx5, LRN_COMMON_ACCESS_CTRL); in sparx5_mact_getnext()
177 ret = sparx5_mact_wait_for_completion(sparx5); in sparx5_mact_getnext()
179 ret = sparx5_mact_get(sparx5, mac, vid, &cfg2); in sparx5_mact_getnext()
184 mutex_unlock(&sparx5->lock); in sparx5_mact_getnext()
189 int sparx5_mact_find(struct sparx5 *sparx5, in sparx5_mact_find() argument
195 mutex_lock(&sparx5->lock); in sparx5_mact_find()
197 sparx5_mact_select(sparx5, mac, vid); in sparx5_mact_find()
202 sparx5, LRN_COMMON_ACCESS_CTRL); in sparx5_mact_find()
204 ret = sparx5_mact_wait_for_completion(sparx5); in sparx5_mact_find()
206 cfg2 = spx5_rd(sparx5, LRN_MAC_ACCESS_CFG_2); in sparx5_mact_find()
213 mutex_unlock(&sparx5->lock); in sparx5_mact_find()
218 int sparx5_mact_forget(struct sparx5 *sparx5, in sparx5_mact_forget() argument
223 mutex_lock(&sparx5->lock); in sparx5_mact_forget()
225 sparx5_mact_select(sparx5, mac, vid); in sparx5_mact_forget()
230 sparx5, LRN_COMMON_ACCESS_CTRL); in sparx5_mact_forget()
232 ret = sparx5_mact_wait_for_completion(sparx5); in sparx5_mact_forget()
234 mutex_unlock(&sparx5->lock); in sparx5_mact_forget()
239 static struct sparx5_mact_entry *alloc_mact_entry(struct sparx5 *sparx5, in alloc_mact_entry() argument
245 mact_entry = devm_kzalloc(sparx5->dev, in alloc_mact_entry()
256 static struct sparx5_mact_entry *find_mact_entry(struct sparx5 *sparx5, in find_mact_entry() argument
263 mutex_lock(&sparx5->mact_lock); in find_mact_entry()
264 list_for_each_entry(mact_entry, &sparx5->mact_entries, list) { in find_mact_entry()
272 mutex_unlock(&sparx5->mact_lock); in find_mact_entry()
289 int sparx5_add_mact_entry(struct sparx5 *sparx5, in sparx5_add_mact_entry() argument
298 ret = sparx5_mact_find(sparx5, addr, vid, &cfg2); in sparx5_add_mact_entry()
308 mact_entry = find_mact_entry(sparx5, addr, vid, portno); in sparx5_add_mact_entry()
315 mact_entry = alloc_mact_entry(sparx5, addr, vid, portno); in sparx5_add_mact_entry()
319 mutex_lock(&sparx5->mact_lock); in sparx5_add_mact_entry()
320 list_add_tail(&mact_entry->list, &sparx5->mact_entries); in sparx5_add_mact_entry()
321 mutex_unlock(&sparx5->mact_lock); in sparx5_add_mact_entry()
324 ret = sparx5_mact_learn(sparx5, portno, addr, vid); in sparx5_add_mact_entry()
336 int sparx5_del_mact_entry(struct sparx5 *sparx5, in sparx5_del_mact_entry() argument
345 mutex_lock(&sparx5->mact_lock); in sparx5_del_mact_entry()
346 list_for_each_entry_safe(mact_entry, tmp, &sparx5->mact_entries, in sparx5_del_mact_entry()
350 sparx5_mact_forget(sparx5, addr, mact_entry->vid); in sparx5_del_mact_entry()
353 devm_kfree(sparx5->dev, mact_entry); in sparx5_del_mact_entry()
356 mutex_unlock(&sparx5->mact_lock); in sparx5_del_mact_entry()
361 static void sparx5_mact_handle_entry(struct sparx5 *sparx5, in sparx5_mact_handle_entry() argument
377 if (!test_bit(port, sparx5->bridge_mask)) in sparx5_mact_handle_entry()
380 mutex_lock(&sparx5->mact_lock); in sparx5_mact_handle_entry()
381 list_for_each_entry(mact_entry, &sparx5->mact_entries, list) { in sparx5_mact_handle_entry()
387 dev_warn(sparx5->dev, "Entry move: %d -> %d\n", in sparx5_mact_handle_entry()
396 mutex_unlock(&sparx5->mact_lock); in sparx5_mact_handle_entry()
404 mact_entry = alloc_mact_entry(sparx5, mac, vid, port); in sparx5_mact_handle_entry()
409 mutex_lock(&sparx5->mact_lock); in sparx5_mact_handle_entry()
410 list_add_tail(&mact_entry->list, &sparx5->mact_entries); in sparx5_mact_handle_entry()
411 mutex_unlock(&sparx5->mact_lock); in sparx5_mact_handle_entry()
416 mac, vid, sparx5->ports[port]->ndev, in sparx5_mact_handle_entry()
423 struct sparx5 *sparx5 = container_of(del_work, struct sparx5, in sparx5_mact_pull_work() local
432 mutex_lock(&sparx5->mact_lock); in sparx5_mact_pull_work()
433 list_for_each_entry(mact_entry, &sparx5->mact_entries, list) in sparx5_mact_pull_work()
435 mutex_unlock(&sparx5->mact_lock); in sparx5_mact_pull_work()
441 mutex_lock(&sparx5->lock); in sparx5_mact_pull_work()
442 sparx5_mact_select(sparx5, mac, vid); in sparx5_mact_pull_work()
444 sparx5, LRN_SCAN_NEXT_CFG); in sparx5_mact_pull_work()
448 sparx5, LRN_COMMON_ACCESS_CTRL); in sparx5_mact_pull_work()
449 ret = sparx5_mact_wait_for_completion(sparx5); in sparx5_mact_pull_work()
451 ret = sparx5_mact_get(sparx5, mac, &vid, &cfg2); in sparx5_mact_pull_work()
452 mutex_unlock(&sparx5->lock); in sparx5_mact_pull_work()
454 sparx5_mact_handle_entry(sparx5, mac, vid, cfg2); in sparx5_mact_pull_work()
457 mutex_lock(&sparx5->mact_lock); in sparx5_mact_pull_work()
458 list_for_each_entry_safe(mact_entry, tmp, &sparx5->mact_entries, in sparx5_mact_pull_work()
466 sparx5->ports[mact_entry->port]->ndev, in sparx5_mact_pull_work()
470 devm_kfree(sparx5->dev, mact_entry); in sparx5_mact_pull_work()
472 mutex_unlock(&sparx5->mact_lock); in sparx5_mact_pull_work()
474 queue_delayed_work(sparx5->mact_queue, &sparx5->mact_work, in sparx5_mact_pull_work()
478 void sparx5_set_ageing(struct sparx5 *sparx5, int msecs) in sparx5_set_ageing() argument
486 sparx5, in sparx5_set_ageing()
490 void sparx5_mact_init(struct sparx5 *sparx5) in sparx5_mact_init() argument
492 mutex_init(&sparx5->lock); in sparx5_mact_init()
497 sparx5, LRN_COMMON_ACCESS_CTRL); in sparx5_mact_init()
499 if (sparx5_mact_wait_for_completion(sparx5) != 0) in sparx5_mact_init()
500 dev_warn(sparx5->dev, "MAC flush error\n"); in sparx5_mact_init()
502 sparx5_set_ageing(sparx5, BR_DEFAULT_AGEING_TIME / HZ * 1000); in sparx5_mact_init()