Lines Matching refs:bat_priv
77 static void batadv_nc_start_timer(struct batadv_priv *bat_priv) in batadv_nc_start_timer() argument
79 queue_delayed_work(batadv_event_workqueue, &bat_priv->nc.work, in batadv_nc_start_timer()
88 static void batadv_nc_tvlv_container_update(struct batadv_priv *bat_priv) in batadv_nc_tvlv_container_update() argument
92 nc_mode = atomic_read(&bat_priv->network_coding); in batadv_nc_tvlv_container_update()
96 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_NC, 1); in batadv_nc_tvlv_container_update()
99 batadv_tvlv_container_register(bat_priv, BATADV_TVLV_NC, 1, in batadv_nc_tvlv_container_update()
112 struct batadv_priv *bat_priv = netdev_priv(net_dev); in batadv_nc_status_update() local
114 batadv_nc_tvlv_container_update(bat_priv); in batadv_nc_status_update()
125 static void batadv_nc_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, in batadv_nc_tvlv_ogm_handler_v1() argument
142 int batadv_nc_mesh_init(struct batadv_priv *bat_priv) in batadv_nc_mesh_init() argument
144 bat_priv->nc.timestamp_fwd_flush = jiffies; in batadv_nc_mesh_init()
145 bat_priv->nc.timestamp_sniffed_purge = jiffies; in batadv_nc_mesh_init()
147 if (bat_priv->nc.coding_hash || bat_priv->nc.decoding_hash) in batadv_nc_mesh_init()
150 bat_priv->nc.coding_hash = batadv_hash_new(128); in batadv_nc_mesh_init()
151 if (!bat_priv->nc.coding_hash) in batadv_nc_mesh_init()
154 batadv_hash_set_lock_class(bat_priv->nc.coding_hash, in batadv_nc_mesh_init()
157 bat_priv->nc.decoding_hash = batadv_hash_new(128); in batadv_nc_mesh_init()
158 if (!bat_priv->nc.decoding_hash) { in batadv_nc_mesh_init()
159 batadv_hash_destroy(bat_priv->nc.coding_hash); in batadv_nc_mesh_init()
163 batadv_hash_set_lock_class(bat_priv->nc.decoding_hash, in batadv_nc_mesh_init()
166 INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker); in batadv_nc_mesh_init()
167 batadv_nc_start_timer(bat_priv); in batadv_nc_mesh_init()
169 batadv_tvlv_handler_register(bat_priv, batadv_nc_tvlv_ogm_handler_v1, in batadv_nc_mesh_init()
172 batadv_nc_tvlv_container_update(bat_priv); in batadv_nc_mesh_init()
183 void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv) in batadv_nc_init_bat_priv() argument
185 atomic_set(&bat_priv->network_coding, 0); in batadv_nc_init_bat_priv()
186 bat_priv->nc.min_tq = 200; in batadv_nc_init_bat_priv()
187 bat_priv->nc.max_fwd_delay = 10; in batadv_nc_init_bat_priv()
188 bat_priv->nc.max_buffer_time = 200; in batadv_nc_init_bat_priv()
282 static bool batadv_nc_to_purge_nc_node(struct batadv_priv *bat_priv, in batadv_nc_to_purge_nc_node() argument
285 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_nc_to_purge_nc_node()
298 static bool batadv_nc_to_purge_nc_path_coding(struct batadv_priv *bat_priv, in batadv_nc_to_purge_nc_path_coding() argument
301 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_nc_to_purge_nc_path_coding()
308 bat_priv->nc.max_fwd_delay * 10); in batadv_nc_to_purge_nc_path_coding()
319 static bool batadv_nc_to_purge_nc_path_decoding(struct batadv_priv *bat_priv, in batadv_nc_to_purge_nc_path_decoding() argument
322 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_nc_to_purge_nc_path_decoding()
329 bat_priv->nc.max_buffer_time * 10); in batadv_nc_to_purge_nc_path_decoding()
344 batadv_nc_purge_orig_nc_nodes(struct batadv_priv *bat_priv, in batadv_nc_purge_orig_nc_nodes() argument
358 if (to_purge && !to_purge(bat_priv, nc_node)) in batadv_nc_purge_orig_nc_nodes()
361 batadv_dbg(BATADV_DBG_NC, bat_priv, in batadv_nc_purge_orig_nc_nodes()
380 void batadv_nc_purge_orig(struct batadv_priv *bat_priv, in batadv_nc_purge_orig() argument
386 batadv_nc_purge_orig_nc_nodes(bat_priv, &orig_node->in_coding_list, in batadv_nc_purge_orig()
391 batadv_nc_purge_orig_nc_nodes(bat_priv, &orig_node->out_coding_list, in batadv_nc_purge_orig()
401 static void batadv_nc_purge_orig_hash(struct batadv_priv *bat_priv) in batadv_nc_purge_orig_hash() argument
403 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_nc_purge_orig_hash()
417 batadv_nc_purge_orig(bat_priv, orig_node, in batadv_nc_purge_orig_hash()
433 static void batadv_nc_purge_paths(struct batadv_priv *bat_priv, in batadv_nc_purge_paths() argument
454 if (to_purge && !to_purge(bat_priv, nc_path)) in batadv_nc_purge_paths()
472 batadv_dbg(BATADV_DBG_NC, bat_priv, in batadv_nc_purge_paths()
600 static bool batadv_nc_sniffed_purge(struct batadv_priv *bat_priv, in batadv_nc_sniffed_purge() argument
604 unsigned long timeout = bat_priv->nc.max_buffer_time; in batadv_nc_sniffed_purge()
612 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE && in batadv_nc_sniffed_purge()
639 static bool batadv_nc_fwd_flush(struct batadv_priv *bat_priv, in batadv_nc_fwd_flush() argument
643 unsigned long timeout = bat_priv->nc.max_fwd_delay; in batadv_nc_fwd_flush()
650 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE && in batadv_nc_fwd_flush()
655 batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD); in batadv_nc_fwd_flush()
656 batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES, in batadv_nc_fwd_flush()
674 batadv_nc_process_nc_paths(struct batadv_priv *bat_priv, in batadv_nc_process_nc_paths() argument
700 ret = process_fn(bat_priv, nc_path, nc_packet); in batadv_nc_process_nc_paths()
719 struct batadv_priv *bat_priv; in batadv_nc_worker() local
724 bat_priv = container_of(priv_nc, struct batadv_priv, nc); in batadv_nc_worker()
726 batadv_nc_purge_orig_hash(bat_priv); in batadv_nc_worker()
727 batadv_nc_purge_paths(bat_priv, bat_priv->nc.coding_hash, in batadv_nc_worker()
729 batadv_nc_purge_paths(bat_priv, bat_priv->nc.decoding_hash, in batadv_nc_worker()
732 timeout = bat_priv->nc.max_fwd_delay; in batadv_nc_worker()
734 if (batadv_has_timed_out(bat_priv->nc.timestamp_fwd_flush, timeout)) { in batadv_nc_worker()
735 batadv_nc_process_nc_paths(bat_priv, bat_priv->nc.coding_hash, in batadv_nc_worker()
737 bat_priv->nc.timestamp_fwd_flush = jiffies; in batadv_nc_worker()
740 if (batadv_has_timed_out(bat_priv->nc.timestamp_sniffed_purge, in batadv_nc_worker()
741 bat_priv->nc.max_buffer_time)) { in batadv_nc_worker()
742 batadv_nc_process_nc_paths(bat_priv, bat_priv->nc.decoding_hash, in batadv_nc_worker()
744 bat_priv->nc.timestamp_sniffed_purge = jiffies; in batadv_nc_worker()
748 batadv_nc_start_timer(bat_priv); in batadv_nc_worker()
764 static bool batadv_can_nc_with_orig(struct batadv_priv *bat_priv, in batadv_can_nc_with_orig() argument
786 if (ogm_packet->tq < bat_priv->nc.min_tq) in batadv_can_nc_with_orig()
844 batadv_nc_get_nc_node(struct batadv_priv *bat_priv, in batadv_nc_get_nc_node() argument
882 batadv_dbg(BATADV_DBG_NC, bat_priv, "Adding nc_node %pM -> %pM\n", in batadv_nc_get_nc_node()
905 void batadv_nc_update_nc_node(struct batadv_priv *bat_priv, in batadv_nc_update_nc_node() argument
915 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_update_nc_node()
923 if (!batadv_can_nc_with_orig(bat_priv, orig_node, ogm_packet) && in batadv_nc_update_nc_node()
928 in_nc_node = batadv_nc_get_nc_node(bat_priv, orig_node, in batadv_nc_update_nc_node()
936 out_nc_node = batadv_nc_get_nc_node(bat_priv, orig_neigh_node, in batadv_nc_update_nc_node()
960 static struct batadv_nc_path *batadv_nc_get_path(struct batadv_priv *bat_priv, in batadv_nc_get_path() argument
993 batadv_dbg(BATADV_DBG_NC, bat_priv, "Adding nc_path %pM -> %pM\n", in batadv_nc_get_path()
1052 static bool batadv_nc_code_packets(struct batadv_priv *bat_priv, in batadv_nc_code_packets() argument
1183 batadv_add_counter(bat_priv, BATADV_CNT_NC_RECODE, 2); in batadv_nc_code_packets()
1184 batadv_add_counter(bat_priv, BATADV_CNT_NC_RECODE_BYTES, count); in batadv_nc_code_packets()
1190 batadv_add_counter(bat_priv, BATADV_CNT_NC_CODE, 2); in batadv_nc_code_packets()
1191 batadv_add_counter(bat_priv, BATADV_CNT_NC_CODE_BYTES, count); in batadv_nc_code_packets()
1195 batadv_inc_counter(bat_priv, BATADV_CNT_NC_RECODE); in batadv_nc_code_packets()
1196 batadv_add_counter(bat_priv, BATADV_CNT_NC_RECODE_BYTES, in batadv_nc_code_packets()
1198 batadv_inc_counter(bat_priv, BATADV_CNT_NC_CODE); in batadv_nc_code_packets()
1199 batadv_add_counter(bat_priv, BATADV_CNT_NC_CODE_BYTES, in batadv_nc_code_packets()
1204 batadv_inc_counter(bat_priv, BATADV_CNT_NC_CODE); in batadv_nc_code_packets()
1205 batadv_add_counter(bat_priv, BATADV_CNT_NC_CODE_BYTES, in batadv_nc_code_packets()
1207 batadv_inc_counter(bat_priv, BATADV_CNT_NC_RECODE); in batadv_nc_code_packets()
1208 batadv_add_counter(bat_priv, BATADV_CNT_NC_RECODE_BYTES, in batadv_nc_code_packets()
1270 batadv_nc_path_search(struct batadv_priv *bat_priv, in batadv_nc_path_search() argument
1279 struct batadv_hashtable *hash = bat_priv->nc.coding_hash; in batadv_nc_path_search()
1338 batadv_nc_skb_src_search(struct batadv_priv *bat_priv, in batadv_nc_skb_src_search() argument
1348 orig_node = batadv_orig_hash_find(bat_priv, eth_src); in batadv_nc_skb_src_search()
1361 nc_packet = batadv_nc_path_search(bat_priv, in_nc_node, in batadv_nc_skb_src_search()
1379 static void batadv_nc_skb_store_before_coding(struct batadv_priv *bat_priv, in batadv_nc_skb_store_before_coding() argument
1399 batadv_nc_skb_store_for_decoding(bat_priv, skb); in batadv_nc_skb_store_before_coding()
1425 struct batadv_priv *bat_priv = netdev_priv(netdev); in batadv_nc_skb_dst_search() local
1433 nc_packet = batadv_nc_skb_src_search(bat_priv, skb, in batadv_nc_skb_dst_search()
1447 batadv_nc_skb_store_before_coding(bat_priv, skb, in batadv_nc_skb_dst_search()
1449 batadv_nc_skb_store_before_coding(bat_priv, nc_packet->skb, in batadv_nc_skb_dst_search()
1453 if (batadv_nc_code_packets(bat_priv, skb, ethhdr, nc_packet, in batadv_nc_skb_dst_search()
1512 struct batadv_priv *bat_priv = netdev_priv(netdev); in batadv_nc_skb_forward() local
1520 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_skb_forward()
1534 nc_path = batadv_nc_get_path(bat_priv, in batadv_nc_skb_forward()
1535 bat_priv->nc.coding_hash, in batadv_nc_skb_forward()
1563 void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv, in batadv_nc_skb_store_for_decoding() argument
1573 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_skb_store_for_decoding()
1583 nc_path = batadv_nc_get_path(bat_priv, in batadv_nc_skb_store_for_decoding()
1584 bat_priv->nc.decoding_hash, in batadv_nc_skb_store_for_decoding()
1607 batadv_inc_counter(bat_priv, BATADV_CNT_NC_BUFFER); in batadv_nc_skb_store_for_decoding()
1624 void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv, in batadv_nc_skb_store_sniffed_unicast() argument
1629 if (batadv_is_my_mac(bat_priv, ethhdr->h_dest)) in batadv_nc_skb_store_sniffed_unicast()
1635 batadv_nc_skb_store_for_decoding(bat_priv, skb); in batadv_nc_skb_store_sniffed_unicast()
1649 batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb, in batadv_nc_skb_decode_packet() argument
1684 if (batadv_is_my_mac(bat_priv, coded_packet_tmp.second_dest)) { in batadv_nc_skb_decode_packet()
1742 batadv_nc_find_decoding_packet(struct batadv_priv *bat_priv, in batadv_nc_find_decoding_packet() argument
1746 struct batadv_hashtable *hash = bat_priv->nc.decoding_hash; in batadv_nc_find_decoding_packet()
1758 if (!batadv_is_my_mac(bat_priv, coded->second_dest)) { in batadv_nc_find_decoding_packet()
1791 batadv_dbg(BATADV_DBG_NC, bat_priv, in batadv_nc_find_decoding_packet()
1809 struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); in batadv_nc_recv_coded_packet() local
1817 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_recv_coded_packet()
1828 if (!batadv_is_my_mac(bat_priv, ethhdr->h_dest) && in batadv_nc_recv_coded_packet()
1829 !batadv_is_my_mac(bat_priv, coded_packet->second_dest)) in batadv_nc_recv_coded_packet()
1833 if (batadv_is_my_mac(bat_priv, coded_packet->second_dest)) in batadv_nc_recv_coded_packet()
1834 batadv_inc_counter(bat_priv, BATADV_CNT_NC_SNIFFED); in batadv_nc_recv_coded_packet()
1836 nc_packet = batadv_nc_find_decoding_packet(bat_priv, ethhdr, in batadv_nc_recv_coded_packet()
1839 batadv_inc_counter(bat_priv, BATADV_CNT_NC_DECODE_FAILED); in batadv_nc_recv_coded_packet()
1851 unicast_packet = batadv_nc_skb_decode_packet(bat_priv, skb, nc_packet); in batadv_nc_recv_coded_packet()
1853 batadv_inc_counter(bat_priv, BATADV_CNT_NC_DECODE_FAILED); in batadv_nc_recv_coded_packet()
1859 batadv_inc_counter(bat_priv, BATADV_CNT_NC_DECODE); in batadv_nc_recv_coded_packet()
1860 batadv_add_counter(bat_priv, BATADV_CNT_NC_DECODE_BYTES, in batadv_nc_recv_coded_packet()
1876 void batadv_nc_mesh_free(struct batadv_priv *bat_priv) in batadv_nc_mesh_free() argument
1878 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_NC, 1); in batadv_nc_mesh_free()
1879 batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_NC, 1); in batadv_nc_mesh_free()
1880 cancel_delayed_work_sync(&bat_priv->nc.work); in batadv_nc_mesh_free()
1882 batadv_nc_purge_paths(bat_priv, bat_priv->nc.coding_hash, NULL); in batadv_nc_mesh_free()
1883 batadv_hash_destroy(bat_priv->nc.coding_hash); in batadv_nc_mesh_free()
1884 batadv_nc_purge_paths(bat_priv, bat_priv->nc.decoding_hash, NULL); in batadv_nc_mesh_free()
1885 batadv_hash_destroy(bat_priv->nc.decoding_hash); in batadv_nc_mesh_free()
1899 struct batadv_priv *bat_priv = netdev_priv(net_dev); in batadv_nc_nodes_seq_print_text() local
1900 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_nc_nodes_seq_print_text()
1956 void batadv_nc_init_debugfs(struct batadv_priv *bat_priv) in batadv_nc_init_debugfs() argument
1960 nc_dir = debugfs_create_dir("nc", bat_priv->debug_dir); in batadv_nc_init_debugfs()
1962 debugfs_create_u8("min_tq", 0644, nc_dir, &bat_priv->nc.min_tq); in batadv_nc_init_debugfs()
1965 &bat_priv->nc.max_fwd_delay); in batadv_nc_init_debugfs()
1968 &bat_priv->nc.max_buffer_time); in batadv_nc_init_debugfs()