Lines Matching refs:sw

106 static int prestera_util_nhc2nc_key(struct prestera_switch *sw,  in prestera_util_nhc2nc_key()  argument
133 prestera_util_nhc_eq_n_cache_key(struct prestera_switch *sw, in prestera_util_nhc_eq_n_cache_key() argument
140 err = prestera_util_nhc2nc_key(sw, nhc, &tk); in prestera_util_nhc_eq_n_cache_key()
151 prestera_util_neigh2nc_key(struct prestera_switch *sw, struct neighbour *n, in prestera_util_neigh2nc_key() argument
430 prestera_neigh_iface_init(struct prestera_switch *sw, in prestera_neigh_iface_init() argument
452 prestera_kern_neigh_cache_find(struct prestera_switch *sw, in prestera_kern_neigh_cache_find() argument
458 rhashtable_lookup_fast(&sw->router->kern_neigh_cache_ht, key, in prestera_kern_neigh_cache_find()
464 __prestera_kern_neigh_cache_destruct(struct prestera_switch *sw, in __prestera_kern_neigh_cache_destruct() argument
471 __prestera_kern_neigh_cache_destroy(struct prestera_switch *sw, in __prestera_kern_neigh_cache_destroy() argument
474 rhashtable_remove_fast(&sw->router->kern_neigh_cache_ht, in __prestera_kern_neigh_cache_destroy()
477 __prestera_kern_neigh_cache_destruct(sw, n_cache); in __prestera_kern_neigh_cache_destroy()
482 __prestera_kern_neigh_cache_create(struct prestera_switch *sw, in __prestera_kern_neigh_cache_create() argument
496 err = rhashtable_insert_fast(&sw->router->kern_neigh_cache_ht, in __prestera_kern_neigh_cache_create()
512 prestera_kern_neigh_cache_get(struct prestera_switch *sw, in prestera_kern_neigh_cache_get() argument
517 n_cache = prestera_kern_neigh_cache_find(sw, key); in prestera_kern_neigh_cache_get()
519 n_cache = __prestera_kern_neigh_cache_create(sw, key); in prestera_kern_neigh_cache_get()
525 prestera_kern_neigh_cache_put(struct prestera_switch *sw, in prestera_kern_neigh_cache_put() argument
530 __prestera_kern_neigh_cache_destroy(sw, n_cache); in prestera_kern_neigh_cache_put()
538 prestera_kern_fib_cache_find(struct prestera_switch *sw, in prestera_kern_fib_cache_find() argument
544 rhashtable_lookup_fast(&sw->router->kern_fib_cache_ht, key, in prestera_kern_fib_cache_find()
550 __prestera_kern_fib_cache_destruct(struct prestera_switch *sw, in __prestera_kern_fib_cache_destruct() argument
560 prestera_kern_neigh_cache_put(sw, n_cache); in __prestera_kern_fib_cache_destruct()
568 prestera_kern_fib_cache_destroy(struct prestera_switch *sw, in prestera_kern_fib_cache_destroy() argument
571 rhashtable_remove_fast(&sw->router->kern_fib_cache_ht, in prestera_kern_fib_cache_destroy()
574 __prestera_kern_fib_cache_destruct(sw, fib_cache); in prestera_kern_fib_cache_destroy()
579 __prestera_kern_fib_cache_create_nhs(struct prestera_switch *sw, in __prestera_kern_fib_cache_create_nhs() argument
596 err = prestera_util_nhc2nc_key(sw, nhc, &nc_key); in __prestera_kern_fib_cache_create_nhs()
600 n_cache = prestera_kern_neigh_cache_get(sw, &nc_key); in __prestera_kern_fib_cache_create_nhs()
617 prestera_kern_fib_cache_create(struct prestera_switch *sw, in prestera_kern_fib_cache_create() argument
634 err = rhashtable_insert_fast(&sw->router->kern_fib_cache_ht, in prestera_kern_fib_cache_create()
641 err = __prestera_kern_fib_cache_create_nhs(sw, fib_cache); in prestera_kern_fib_cache_create()
656 __prestera_k_arb_fib_nh_offload_set(struct prestera_switch *sw, in __prestera_k_arb_fib_nh_offload_set() argument
672 if (prestera_util_nhc_eq_n_cache_key(sw, nhc, &nc->key)) { in __prestera_k_arb_fib_nh_offload_set()
680 __prestera_k_arb_n_offload_set(struct prestera_switch *sw, in __prestera_k_arb_n_offload_set() argument
696 __prestera_k_arb_fib_lpm_offload_set(struct prestera_switch *sw, in __prestera_k_arb_fib_lpm_offload_set() argument
724 __prestera_k_arb_n_lpm_set(struct prestera_switch *sw, in __prestera_k_arb_n_lpm_set() argument
745 fib_cache = prestera_kern_fib_cache_find(sw, &fc_key); in __prestera_k_arb_n_lpm_set()
750 fib_node = prestera_fib_node_find(sw, &fib_key); in __prestera_k_arb_n_lpm_set()
754 prestera_fib_node_destroy(sw, fib_node); in __prestera_k_arb_n_lpm_set()
763 fib_node = prestera_fib_node_create(sw, &fib_key, in __prestera_k_arb_n_lpm_set()
774 __prestera_k_arb_nc_kern_fib_fetch(struct prestera_switch *sw, in __prestera_k_arb_nc_kern_fib_fetch() argument
786 __prestera_k_arb_nc_kern_n_fetch(struct prestera_switch *sw, in __prestera_k_arb_nc_kern_n_fetch() argument
799 err = prestera_neigh_iface_init(sw, &nc->nh_neigh_info.iface, in __prestera_k_arb_nc_kern_n_fetch()
817 __prestera_k_arb_nc_apply(struct prestera_switch *sw, in __prestera_k_arb_nc_apply() argument
825 __prestera_k_arb_n_lpm_set(sw, nc, nc->reachable && nc->in_kernel); in __prestera_k_arb_nc_apply()
826 __prestera_k_arb_n_offload_set(sw, nc, nc->reachable && nc->in_kernel); in __prestera_k_arb_nc_apply()
829 nh_neigh = prestera_nh_neigh_find(sw, &nh_key); in __prestera_k_arb_nc_apply()
838 err = prestera_nh_neigh_set(sw, nh_neigh); in __prestera_k_arb_nc_apply()
850 __prestera_k_arb_fib_nh_offload_set(sw, nhead->this, nc, in __prestera_k_arb_nc_apply()
857 __prestera_pr_k_arb_fc_lpm_info_calc(struct prestera_switch *sw, in __prestera_pr_k_arb_fc_lpm_info_calc() argument
918 dev_err(sw->dev->dev, "Unsupported fib_type"); in __prestera_pr_k_arb_fc_lpm_info_calc()
929 static int __prestera_k_arb_f_lpm_set(struct prestera_switch *sw, in __prestera_k_arb_f_lpm_set() argument
935 fib_node = prestera_fib_node_find(sw, &fc->lpm_info.fib_key); in __prestera_k_arb_f_lpm_set()
937 prestera_fib_node_destroy(sw, fib_node); in __prestera_k_arb_f_lpm_set()
942 fib_node = prestera_fib_node_create(sw, &fc->lpm_info.fib_key, in __prestera_k_arb_f_lpm_set()
947 dev_err(sw->dev->dev, "fib_node=NULL %pI4n/%d kern_tb_id = %d", in __prestera_k_arb_f_lpm_set()
956 static int __prestera_k_arb_fc_apply(struct prestera_switch *sw, in __prestera_k_arb_fc_apply() argument
961 err = __prestera_pr_k_arb_fc_lpm_info_calc(sw, fc); in __prestera_k_arb_fc_apply()
965 err = __prestera_k_arb_f_lpm_set(sw, fc, fc->reachable); in __prestera_k_arb_fc_apply()
967 __prestera_k_arb_fib_lpm_offload_set(sw, fc, in __prestera_k_arb_fc_apply()
974 __prestera_k_arb_fib_lpm_offload_set(sw, fc, false, in __prestera_k_arb_fc_apply()
978 __prestera_k_arb_fib_lpm_offload_set(sw, fc, false, in __prestera_k_arb_fc_apply()
982 __prestera_k_arb_fib_lpm_offload_set(sw, fc, false, true, in __prestera_k_arb_fc_apply()
993 __prestera_k_arb_util_fib_overlaps(struct prestera_switch *sw, in __prestera_k_arb_util_fib_overlaps() argument
1004 rfc = prestera_kern_fib_cache_find(sw, &fc_key); in __prestera_k_arb_util_fib_overlaps()
1011 __prestera_k_arb_util_fib_overlapped(struct prestera_switch *sw, in __prestera_k_arb_util_fib_overlapped() argument
1022 rfc = prestera_kern_fib_cache_find(sw, &fc_key); in __prestera_k_arb_util_fib_overlapped()
1028 static void __prestera_k_arb_hw_state_upd(struct prestera_switch *sw, in __prestera_k_arb_hw_state_upd() argument
1037 nh_neigh = prestera_nh_neigh_find(sw, &nh_key); in __prestera_k_arb_hw_state_upd()
1044 hw_active = prestera_nh_neigh_util_hw_state(sw, nh_neigh); in __prestera_k_arb_hw_state_upd()
1076 static void prestera_k_arb_hw_evt(struct prestera_switch *sw) in prestera_k_arb_hw_evt() argument
1081 rhashtable_walk_enter(&sw->router->kern_neigh_cache_ht, &iter); in prestera_k_arb_hw_evt()
1093 __prestera_k_arb_hw_state_upd(sw, n_cache); in prestera_k_arb_hw_evt()
1101 static void prestera_k_arb_n_evt(struct prestera_switch *sw, in prestera_k_arb_n_evt() argument
1108 err = prestera_util_neigh2nc_key(sw, n, &n_key); in prestera_k_arb_n_evt()
1112 n_cache = prestera_kern_neigh_cache_find(sw, &n_key); in prestera_k_arb_n_evt()
1114 n_cache = prestera_kern_neigh_cache_get(sw, &n_key); in prestera_k_arb_n_evt()
1117 __prestera_k_arb_nc_kern_fib_fetch(sw, n_cache); in prestera_k_arb_n_evt()
1120 __prestera_k_arb_nc_kern_n_fetch(sw, n_cache); in prestera_k_arb_n_evt()
1121 __prestera_k_arb_nc_apply(sw, n_cache); in prestera_k_arb_n_evt()
1123 prestera_kern_neigh_cache_put(sw, n_cache); in prestera_k_arb_n_evt()
1126 static void __prestera_k_arb_fib_evt2nc(struct prestera_switch *sw) in __prestera_k_arb_fib_evt2nc() argument
1131 rhashtable_walk_enter(&sw->router->kern_neigh_cache_ht, &iter); in __prestera_k_arb_fib_evt2nc()
1143 __prestera_k_arb_nc_kern_fib_fetch(sw, n_cache); in __prestera_k_arb_fib_evt2nc()
1144 __prestera_k_arb_nc_apply(sw, n_cache); in __prestera_k_arb_fib_evt2nc()
1152 prestera_k_arb_fib_evt(struct prestera_switch *sw, in prestera_k_arb_fib_evt() argument
1162 fib_cache = prestera_kern_fib_cache_find(sw, &fc_key); in prestera_k_arb_fib_evt()
1165 err = __prestera_k_arb_fc_apply(sw, fib_cache); in prestera_k_arb_fib_evt()
1167 dev_err(sw->dev->dev, in prestera_k_arb_fib_evt()
1170 bfib_cache = __prestera_k_arb_util_fib_overlaps(sw, fib_cache); in prestera_k_arb_fib_evt()
1171 tfib_cache = __prestera_k_arb_util_fib_overlapped(sw, fib_cache); in prestera_k_arb_fib_evt()
1174 err = __prestera_k_arb_fc_apply(sw, bfib_cache); in prestera_k_arb_fib_evt()
1176 dev_err(sw->dev->dev, in prestera_k_arb_fib_evt()
1180 prestera_kern_fib_cache_destroy(sw, fib_cache); in prestera_k_arb_fib_evt()
1184 fib_cache = prestera_kern_fib_cache_create(sw, &fc_key, info); in prestera_k_arb_fib_evt()
1186 dev_err(sw->dev->dev, "fib_cache == NULL"); in prestera_k_arb_fib_evt()
1190 bfib_cache = __prestera_k_arb_util_fib_overlaps(sw, fib_cache); in prestera_k_arb_fib_evt()
1191 tfib_cache = __prestera_k_arb_util_fib_overlapped(sw, fib_cache); in prestera_k_arb_fib_evt()
1197 err = __prestera_k_arb_fc_apply(sw, bfib_cache); in prestera_k_arb_fib_evt()
1199 dev_err(sw->dev->dev, in prestera_k_arb_fib_evt()
1203 err = __prestera_k_arb_fc_apply(sw, fib_cache); in prestera_k_arb_fib_evt()
1205 dev_err(sw->dev->dev, "Applying fib_cache failed"); in prestera_k_arb_fib_evt()
1209 __prestera_k_arb_fib_evt2nc(sw); in prestera_k_arb_fib_evt()
1217 struct prestera_switch *sw = arg; in __prestera_k_arb_abort_neigh_ht_cb() local
1223 __prestera_k_arb_n_offload_set(sw, n_cache, false); in __prestera_k_arb_abort_neigh_ht_cb()
1228 __prestera_kern_neigh_cache_destruct(sw, n_cache); in __prestera_k_arb_abort_neigh_ht_cb()
1235 struct prestera_switch *sw = arg; in __prestera_k_arb_abort_fib_ht_cb() local
1237 __prestera_k_arb_fib_lpm_offload_set(sw, fib_cache, in __prestera_k_arb_abort_fib_ht_cb()
1240 __prestera_k_arb_fib_nh_offload_set(sw, fib_cache, NULL, in __prestera_k_arb_abort_fib_ht_cb()
1245 __prestera_kern_fib_cache_destruct(sw, fib_cache); in __prestera_k_arb_abort_fib_ht_cb()
1249 static void prestera_k_arb_abort(struct prestera_switch *sw) in prestera_k_arb_abort() argument
1259 rhashtable_free_and_destroy(&sw->router->kern_fib_cache_ht, in prestera_k_arb_abort()
1261 sw); in prestera_k_arb_abort()
1262 rhashtable_free_and_destroy(&sw->router->kern_neigh_cache_ht, in prestera_k_arb_abort()
1264 sw); in prestera_k_arb_abort()
1287 re = prestera_rif_entry_find(port->sw, &re_key); in __prestera_inetaddr_port_event()
1295 re = prestera_rif_entry_create(port->sw, &re_key, in __prestera_inetaddr_port_event()
1309 prestera_rif_entry_destroy(port->sw, re); in __prestera_inetaddr_port_event()
1317 static int __prestera_inetaddr_event(struct prestera_switch *sw, in __prestera_inetaddr_event() argument
1348 err = __prestera_inetaddr_event(router->sw, dev, event, NULL); in __prestera_inetaddr_cb()
1379 err = __prestera_inetaddr_event(router->sw, dev, event, ivi->extack); in __prestera_inetaddr_valid_cb()
1386 struct prestera_switch *sw; member
1395 struct prestera_switch *sw = fib_work->sw; in __prestera_router_fib_event_work() local
1402 err = prestera_k_arb_fib_evt(sw, true, in __prestera_router_fib_event_work()
1409 err = prestera_k_arb_fib_evt(sw, false, in __prestera_router_fib_event_work()
1420 dev_err(sw->dev->dev, "Error when processing %pI4h/%d", in __prestera_router_fib_event_work()
1458 fib_work->sw = router->sw; in __prestera_router_fib_event()
1471 struct prestera_switch *sw; member
1479 struct prestera_switch *sw = net_work->sw; in prestera_router_neigh_event_work() local
1485 prestera_k_arb_n_evt(sw, n); in prestera_router_neigh_event_work()
1512 net_work->sw = router->sw; in prestera_router_netevent_event()
1528 prestera_k_arb_hw_evt(router->sw); in prestera_router_update_neighs_work()
1535 static int prestera_neigh_work_init(struct prestera_switch *sw) in prestera_neigh_work_init() argument
1537 INIT_DELAYED_WORK(&sw->router->neighs_update.dw, in prestera_neigh_work_init()
1539 prestera_queue_delayed_work(&sw->router->neighs_update.dw, 0); in prestera_neigh_work_init()
1543 static void prestera_neigh_work_fini(struct prestera_switch *sw) in prestera_neigh_work_fini() argument
1545 cancel_delayed_work_sync(&sw->router->neighs_update.dw); in prestera_neigh_work_fini()
1548 int prestera_router_init(struct prestera_switch *sw) in prestera_router_init() argument
1553 router = kzalloc(sizeof(*sw->router), GFP_KERNEL); in prestera_router_init()
1557 sw->router = router; in prestera_router_init()
1558 router->sw = sw; in prestera_router_init()
1560 err = prestera_router_hw_init(sw); in prestera_router_init()
1574 nhgrp_cache_bytes = sw->size_tbl_router_nexthop / 8 + 1; in prestera_router_init()
1581 err = prestera_neigh_work_init(sw); in prestera_router_init()
1615 prestera_neigh_work_fini(sw); in prestera_router_init()
1623 prestera_router_hw_fini(sw); in prestera_router_init()
1625 kfree(sw->router); in prestera_router_init()
1629 void prestera_router_fini(struct prestera_switch *sw) in prestera_router_fini() argument
1631 unregister_fib_notifier(&init_net, &sw->router->fib_nb); in prestera_router_fini()
1632 unregister_netevent_notifier(&sw->router->netevent_nb); in prestera_router_fini()
1633 unregister_inetaddr_notifier(&sw->router->inetaddr_nb); in prestera_router_fini()
1634 unregister_inetaddr_validator_notifier(&sw->router->inetaddr_valid_nb); in prestera_router_fini()
1635 prestera_neigh_work_fini(sw); in prestera_router_fini()
1638 prestera_k_arb_abort(sw); in prestera_router_fini()
1640 kfree(sw->router->nhgrp_hw_state_cache); in prestera_router_fini()
1641 rhashtable_destroy(&sw->router->kern_fib_cache_ht); in prestera_router_fini()
1642 prestera_router_hw_fini(sw); in prestera_router_fini()
1643 kfree(sw->router); in prestera_router_fini()
1644 sw->router = NULL; in prestera_router_fini()