Lines Matching defs:bat_priv

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