Lines Matching refs:bat_priv

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