Lines Matching refs:bat_priv

70 static void batadv_nc_start_timer(struct batadv_priv *bat_priv)  in batadv_nc_start_timer()  argument
72 queue_delayed_work(batadv_event_workqueue, &bat_priv->nc.work, in batadv_nc_start_timer()
81 static void batadv_nc_tvlv_container_update(struct batadv_priv *bat_priv) in batadv_nc_tvlv_container_update() argument
85 nc_mode = atomic_read(&bat_priv->network_coding); in batadv_nc_tvlv_container_update()
89 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_NC, 1); in batadv_nc_tvlv_container_update()
92 batadv_tvlv_container_register(bat_priv, BATADV_TVLV_NC, 1, in batadv_nc_tvlv_container_update()
105 struct batadv_priv *bat_priv = netdev_priv(net_dev); in batadv_nc_status_update() local
107 batadv_nc_tvlv_container_update(bat_priv); in batadv_nc_status_update()
118 static void batadv_nc_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, in batadv_nc_tvlv_ogm_handler_v1() argument
135 int batadv_nc_mesh_init(struct batadv_priv *bat_priv) in batadv_nc_mesh_init() argument
137 bat_priv->nc.timestamp_fwd_flush = jiffies; in batadv_nc_mesh_init()
138 bat_priv->nc.timestamp_sniffed_purge = jiffies; in batadv_nc_mesh_init()
140 if (bat_priv->nc.coding_hash || bat_priv->nc.decoding_hash) in batadv_nc_mesh_init()
143 bat_priv->nc.coding_hash = batadv_hash_new(128); in batadv_nc_mesh_init()
144 if (!bat_priv->nc.coding_hash) in batadv_nc_mesh_init()
147 batadv_hash_set_lock_class(bat_priv->nc.coding_hash, in batadv_nc_mesh_init()
150 bat_priv->nc.decoding_hash = batadv_hash_new(128); in batadv_nc_mesh_init()
151 if (!bat_priv->nc.decoding_hash) { in batadv_nc_mesh_init()
152 batadv_hash_destroy(bat_priv->nc.coding_hash); in batadv_nc_mesh_init()
156 batadv_hash_set_lock_class(bat_priv->nc.decoding_hash, in batadv_nc_mesh_init()
159 INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker); in batadv_nc_mesh_init()
160 batadv_nc_start_timer(bat_priv); in batadv_nc_mesh_init()
162 batadv_tvlv_handler_register(bat_priv, batadv_nc_tvlv_ogm_handler_v1, in batadv_nc_mesh_init()
165 batadv_nc_tvlv_container_update(bat_priv); in batadv_nc_mesh_init()
176 void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv) in batadv_nc_init_bat_priv() argument
178 atomic_set(&bat_priv->network_coding, 0); in batadv_nc_init_bat_priv()
179 bat_priv->nc.min_tq = 200; in batadv_nc_init_bat_priv()
180 bat_priv->nc.max_fwd_delay = 10; in batadv_nc_init_bat_priv()
181 bat_priv->nc.max_buffer_time = 200; in batadv_nc_init_bat_priv()
275 static bool batadv_nc_to_purge_nc_node(struct batadv_priv *bat_priv, in batadv_nc_to_purge_nc_node() argument
278 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_nc_to_purge_nc_node()
291 static bool batadv_nc_to_purge_nc_path_coding(struct batadv_priv *bat_priv, in batadv_nc_to_purge_nc_path_coding() argument
294 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_nc_to_purge_nc_path_coding()
301 bat_priv->nc.max_fwd_delay * 10); in batadv_nc_to_purge_nc_path_coding()
312 static bool batadv_nc_to_purge_nc_path_decoding(struct batadv_priv *bat_priv, in batadv_nc_to_purge_nc_path_decoding() argument
315 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_nc_to_purge_nc_path_decoding()
322 bat_priv->nc.max_buffer_time * 10); in batadv_nc_to_purge_nc_path_decoding()
337 batadv_nc_purge_orig_nc_nodes(struct batadv_priv *bat_priv, in batadv_nc_purge_orig_nc_nodes() argument
351 if (to_purge && !to_purge(bat_priv, nc_node)) in batadv_nc_purge_orig_nc_nodes()
354 batadv_dbg(BATADV_DBG_NC, bat_priv, in batadv_nc_purge_orig_nc_nodes()
373 void batadv_nc_purge_orig(struct batadv_priv *bat_priv, in batadv_nc_purge_orig() argument
379 batadv_nc_purge_orig_nc_nodes(bat_priv, &orig_node->in_coding_list, in batadv_nc_purge_orig()
384 batadv_nc_purge_orig_nc_nodes(bat_priv, &orig_node->out_coding_list, in batadv_nc_purge_orig()
394 static void batadv_nc_purge_orig_hash(struct batadv_priv *bat_priv) in batadv_nc_purge_orig_hash() argument
396 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_nc_purge_orig_hash()
410 batadv_nc_purge_orig(bat_priv, orig_node, in batadv_nc_purge_orig_hash()
426 static void batadv_nc_purge_paths(struct batadv_priv *bat_priv, in batadv_nc_purge_paths() argument
447 if (to_purge && !to_purge(bat_priv, nc_path)) in batadv_nc_purge_paths()
465 batadv_dbg(BATADV_DBG_NC, bat_priv, in batadv_nc_purge_paths()
593 static bool batadv_nc_sniffed_purge(struct batadv_priv *bat_priv, in batadv_nc_sniffed_purge() argument
597 unsigned long timeout = bat_priv->nc.max_buffer_time; in batadv_nc_sniffed_purge()
605 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE && in batadv_nc_sniffed_purge()
632 static bool batadv_nc_fwd_flush(struct batadv_priv *bat_priv, in batadv_nc_fwd_flush() argument
636 unsigned long timeout = bat_priv->nc.max_fwd_delay; in batadv_nc_fwd_flush()
643 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE && in batadv_nc_fwd_flush()
648 batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD); in batadv_nc_fwd_flush()
649 batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES, in batadv_nc_fwd_flush()
667 batadv_nc_process_nc_paths(struct batadv_priv *bat_priv, in batadv_nc_process_nc_paths() argument
693 ret = process_fn(bat_priv, nc_path, nc_packet); in batadv_nc_process_nc_paths()
712 struct batadv_priv *bat_priv; in batadv_nc_worker() local
717 bat_priv = container_of(priv_nc, struct batadv_priv, nc); in batadv_nc_worker()
719 batadv_nc_purge_orig_hash(bat_priv); in batadv_nc_worker()
720 batadv_nc_purge_paths(bat_priv, bat_priv->nc.coding_hash, in batadv_nc_worker()
722 batadv_nc_purge_paths(bat_priv, bat_priv->nc.decoding_hash, in batadv_nc_worker()
725 timeout = bat_priv->nc.max_fwd_delay; in batadv_nc_worker()
727 if (batadv_has_timed_out(bat_priv->nc.timestamp_fwd_flush, timeout)) { in batadv_nc_worker()
728 batadv_nc_process_nc_paths(bat_priv, bat_priv->nc.coding_hash, in batadv_nc_worker()
730 bat_priv->nc.timestamp_fwd_flush = jiffies; in batadv_nc_worker()
733 if (batadv_has_timed_out(bat_priv->nc.timestamp_sniffed_purge, in batadv_nc_worker()
734 bat_priv->nc.max_buffer_time)) { in batadv_nc_worker()
735 batadv_nc_process_nc_paths(bat_priv, bat_priv->nc.decoding_hash, in batadv_nc_worker()
737 bat_priv->nc.timestamp_sniffed_purge = jiffies; in batadv_nc_worker()
741 batadv_nc_start_timer(bat_priv); in batadv_nc_worker()
757 static bool batadv_can_nc_with_orig(struct batadv_priv *bat_priv, in batadv_can_nc_with_orig() argument
779 if (ogm_packet->tq < bat_priv->nc.min_tq) in batadv_can_nc_with_orig()
837 batadv_nc_get_nc_node(struct batadv_priv *bat_priv, in batadv_nc_get_nc_node() argument
875 batadv_dbg(BATADV_DBG_NC, bat_priv, "Adding nc_node %pM -> %pM\n", in batadv_nc_get_nc_node()
898 void batadv_nc_update_nc_node(struct batadv_priv *bat_priv, in batadv_nc_update_nc_node() argument
908 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_update_nc_node()
916 if (!batadv_can_nc_with_orig(bat_priv, orig_node, ogm_packet) && in batadv_nc_update_nc_node()
921 in_nc_node = batadv_nc_get_nc_node(bat_priv, orig_node, in batadv_nc_update_nc_node()
929 out_nc_node = batadv_nc_get_nc_node(bat_priv, orig_neigh_node, in batadv_nc_update_nc_node()
951 static struct batadv_nc_path *batadv_nc_get_path(struct batadv_priv *bat_priv, in batadv_nc_get_path() argument
984 batadv_dbg(BATADV_DBG_NC, bat_priv, "Adding nc_path %pM -> %pM\n", in batadv_nc_get_path()
1043 static bool batadv_nc_code_packets(struct batadv_priv *bat_priv, in batadv_nc_code_packets() argument
1174 batadv_add_counter(bat_priv, BATADV_CNT_NC_RECODE, 2); in batadv_nc_code_packets()
1175 batadv_add_counter(bat_priv, BATADV_CNT_NC_RECODE_BYTES, count); in batadv_nc_code_packets()
1181 batadv_add_counter(bat_priv, BATADV_CNT_NC_CODE, 2); in batadv_nc_code_packets()
1182 batadv_add_counter(bat_priv, BATADV_CNT_NC_CODE_BYTES, count); in batadv_nc_code_packets()
1186 batadv_inc_counter(bat_priv, BATADV_CNT_NC_RECODE); in batadv_nc_code_packets()
1187 batadv_add_counter(bat_priv, BATADV_CNT_NC_RECODE_BYTES, in batadv_nc_code_packets()
1189 batadv_inc_counter(bat_priv, BATADV_CNT_NC_CODE); in batadv_nc_code_packets()
1190 batadv_add_counter(bat_priv, BATADV_CNT_NC_CODE_BYTES, in batadv_nc_code_packets()
1195 batadv_inc_counter(bat_priv, BATADV_CNT_NC_CODE); in batadv_nc_code_packets()
1196 batadv_add_counter(bat_priv, BATADV_CNT_NC_CODE_BYTES, in batadv_nc_code_packets()
1198 batadv_inc_counter(bat_priv, BATADV_CNT_NC_RECODE); in batadv_nc_code_packets()
1199 batadv_add_counter(bat_priv, BATADV_CNT_NC_RECODE_BYTES, in batadv_nc_code_packets()
1257 batadv_nc_path_search(struct batadv_priv *bat_priv, in batadv_nc_path_search() argument
1266 struct batadv_hashtable *hash = bat_priv->nc.coding_hash; in batadv_nc_path_search()
1325 batadv_nc_skb_src_search(struct batadv_priv *bat_priv, in batadv_nc_skb_src_search() argument
1335 orig_node = batadv_orig_hash_find(bat_priv, eth_src); in batadv_nc_skb_src_search()
1348 nc_packet = batadv_nc_path_search(bat_priv, in_nc_node, in batadv_nc_skb_src_search()
1366 static void batadv_nc_skb_store_before_coding(struct batadv_priv *bat_priv, in batadv_nc_skb_store_before_coding() argument
1386 batadv_nc_skb_store_for_decoding(bat_priv, skb); in batadv_nc_skb_store_before_coding()
1412 struct batadv_priv *bat_priv = netdev_priv(netdev); in batadv_nc_skb_dst_search() local
1420 nc_packet = batadv_nc_skb_src_search(bat_priv, skb, in batadv_nc_skb_dst_search()
1434 batadv_nc_skb_store_before_coding(bat_priv, skb, in batadv_nc_skb_dst_search()
1436 batadv_nc_skb_store_before_coding(bat_priv, nc_packet->skb, in batadv_nc_skb_dst_search()
1440 if (batadv_nc_code_packets(bat_priv, skb, ethhdr, nc_packet, in batadv_nc_skb_dst_search()
1499 struct batadv_priv *bat_priv = netdev_priv(netdev); in batadv_nc_skb_forward() local
1507 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_skb_forward()
1521 nc_path = batadv_nc_get_path(bat_priv, in batadv_nc_skb_forward()
1522 bat_priv->nc.coding_hash, in batadv_nc_skb_forward()
1550 void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv, in batadv_nc_skb_store_for_decoding() argument
1560 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_skb_store_for_decoding()
1570 nc_path = batadv_nc_get_path(bat_priv, in batadv_nc_skb_store_for_decoding()
1571 bat_priv->nc.decoding_hash, in batadv_nc_skb_store_for_decoding()
1594 batadv_inc_counter(bat_priv, BATADV_CNT_NC_BUFFER); in batadv_nc_skb_store_for_decoding()
1611 void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv, in batadv_nc_skb_store_sniffed_unicast() argument
1616 if (batadv_is_my_mac(bat_priv, ethhdr->h_dest)) in batadv_nc_skb_store_sniffed_unicast()
1622 batadv_nc_skb_store_for_decoding(bat_priv, skb); in batadv_nc_skb_store_sniffed_unicast()
1636 batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb, in batadv_nc_skb_decode_packet() argument
1671 if (batadv_is_my_mac(bat_priv, coded_packet_tmp.second_dest)) { in batadv_nc_skb_decode_packet()
1729 batadv_nc_find_decoding_packet(struct batadv_priv *bat_priv, in batadv_nc_find_decoding_packet() argument
1733 struct batadv_hashtable *hash = bat_priv->nc.decoding_hash; in batadv_nc_find_decoding_packet()
1745 if (!batadv_is_my_mac(bat_priv, coded->second_dest)) { in batadv_nc_find_decoding_packet()
1778 batadv_dbg(BATADV_DBG_NC, bat_priv, in batadv_nc_find_decoding_packet()
1796 struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); in batadv_nc_recv_coded_packet() local
1804 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_recv_coded_packet()
1815 if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest) && in batadv_nc_recv_coded_packet()
1816 !batadv_is_my_mac(bat_priv, coded_packet->second_dest)) in batadv_nc_recv_coded_packet()
1820 if (batadv_is_my_mac(bat_priv, coded_packet->second_dest)) in batadv_nc_recv_coded_packet()
1821 batadv_inc_counter(bat_priv, BATADV_CNT_NC_SNIFFED); in batadv_nc_recv_coded_packet()
1823 nc_packet = batadv_nc_find_decoding_packet(bat_priv, ethhdr, in batadv_nc_recv_coded_packet()
1826 batadv_inc_counter(bat_priv, BATADV_CNT_NC_DECODE_FAILED); in batadv_nc_recv_coded_packet()
1838 unicast_packet = batadv_nc_skb_decode_packet(bat_priv, skb, nc_packet); in batadv_nc_recv_coded_packet()
1840 batadv_inc_counter(bat_priv, BATADV_CNT_NC_DECODE_FAILED); in batadv_nc_recv_coded_packet()
1846 batadv_inc_counter(bat_priv, BATADV_CNT_NC_DECODE); in batadv_nc_recv_coded_packet()
1847 batadv_add_counter(bat_priv, BATADV_CNT_NC_DECODE_BYTES, in batadv_nc_recv_coded_packet()
1863 void batadv_nc_mesh_free(struct batadv_priv *bat_priv) in batadv_nc_mesh_free() argument
1865 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_NC, 1); in batadv_nc_mesh_free()
1866 batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_NC, 1); in batadv_nc_mesh_free()
1867 cancel_delayed_work_sync(&bat_priv->nc.work); in batadv_nc_mesh_free()
1869 batadv_nc_purge_paths(bat_priv, bat_priv->nc.coding_hash, NULL); in batadv_nc_mesh_free()
1870 batadv_hash_destroy(bat_priv->nc.coding_hash); in batadv_nc_mesh_free()
1871 batadv_nc_purge_paths(bat_priv, bat_priv->nc.decoding_hash, NULL); in batadv_nc_mesh_free()
1872 batadv_hash_destroy(bat_priv->nc.decoding_hash); in batadv_nc_mesh_free()