Lines Matching +full:tx +full:- +full:fifo +full:- +full:resize
1 // SPDX-License-Identifier: GPL-2.0
4 * Martin Hundebøll, Jeppe Ledet-Pedersen
7 #include "network-coding.h"
55 * batadv_nc_init() - one-time initialization for network coding
67 * batadv_nc_start_timer() - initialise the nc periodic worker
72 queue_delayed_work(batadv_event_workqueue, &bat_priv->nc.work, in batadv_nc_start_timer()
77 * batadv_nc_tvlv_container_update() - update the network coding tvlv container
85 nc_mode = atomic_read(&bat_priv->network_coding); in batadv_nc_tvlv_container_update()
99 * batadv_nc_status_update() - update the network coding tvlv container after
111 * batadv_nc_tvlv_ogm_handler_v1() - process incoming nc tvlv container
124 clear_bit(BATADV_ORIG_CAPA_HAS_NC, &orig->capabilities); in batadv_nc_tvlv_ogm_handler_v1()
126 set_bit(BATADV_ORIG_CAPA_HAS_NC, &orig->capabilities); in batadv_nc_tvlv_ogm_handler_v1()
130 * batadv_nc_mesh_init() - initialise coding hash table and start housekeeping
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()
169 return -ENOMEM; in batadv_nc_mesh_init()
173 * batadv_nc_init_bat_priv() - initialise the nc specific bat_priv variables
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()
185 * batadv_nc_init_orig() - initialise the nc fields of an orig_node
190 INIT_LIST_HEAD(&orig_node->in_coding_list); in batadv_nc_init_orig()
191 INIT_LIST_HEAD(&orig_node->out_coding_list); in batadv_nc_init_orig()
192 spin_lock_init(&orig_node->in_coding_list_lock); in batadv_nc_init_orig()
193 spin_lock_init(&orig_node->out_coding_list_lock); in batadv_nc_init_orig()
197 * batadv_nc_node_release() - release nc_node from lists and queue for free
207 batadv_orig_node_put(nc_node->orig_node); in batadv_nc_node_release()
212 * batadv_nc_node_put() - decrement the nc_node refcounter and possibly
221 kref_put(&nc_node->refcount, batadv_nc_node_release); in batadv_nc_node_put()
225 * batadv_nc_path_release() - release nc_path from lists and queue for free
239 * batadv_nc_path_put() - decrement the nc_path refcounter and possibly
248 kref_put(&nc_path->refcount, batadv_nc_path_release); in batadv_nc_path_put()
252 * batadv_nc_packet_free() - frees nc packet
260 kfree_skb(nc_packet->skb); in batadv_nc_packet_free()
262 consume_skb(nc_packet->skb); in batadv_nc_packet_free()
264 batadv_nc_path_put(nc_packet->nc_path); in batadv_nc_packet_free()
269 * batadv_nc_to_purge_nc_node() - checks whether an nc node has to be purged
278 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_nc_to_purge_nc_node()
281 return batadv_has_timed_out(nc_node->last_seen, BATADV_NC_NODE_TIMEOUT); in batadv_nc_to_purge_nc_node()
285 * batadv_nc_to_purge_nc_path_coding() - checks whether an nc path has timed out
294 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_nc_to_purge_nc_path_coding()
300 return batadv_has_timed_out(nc_path->last_valid, in batadv_nc_to_purge_nc_path_coding()
301 bat_priv->nc.max_fwd_delay * 10); in batadv_nc_to_purge_nc_path_coding()
305 * batadv_nc_to_purge_nc_path_decoding() - checks whether an nc path has timed
315 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) in batadv_nc_to_purge_nc_path_decoding()
321 return batadv_has_timed_out(nc_path->last_valid, in batadv_nc_to_purge_nc_path_decoding()
322 bat_priv->nc.max_buffer_time * 10); in batadv_nc_to_purge_nc_path_decoding()
326 * batadv_nc_purge_orig_nc_nodes() - go through list of nc nodes and purge stale
355 "Removing nc_node %pM -> %pM\n", in batadv_nc_purge_orig_nc_nodes()
356 nc_node->addr, nc_node->orig_node->orig); in batadv_nc_purge_orig_nc_nodes()
357 list_del_rcu(&nc_node->list); in batadv_nc_purge_orig_nc_nodes()
364 * batadv_nc_purge_orig() - purges all nc node data attached of the given
379 batadv_nc_purge_orig_nc_nodes(bat_priv, &orig_node->in_coding_list, in batadv_nc_purge_orig()
380 &orig_node->in_coding_list_lock, in batadv_nc_purge_orig()
384 batadv_nc_purge_orig_nc_nodes(bat_priv, &orig_node->out_coding_list, in batadv_nc_purge_orig()
385 &orig_node->out_coding_list_lock, in batadv_nc_purge_orig()
390 * batadv_nc_purge_orig_hash() - traverse entire originator hash to check if
396 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_nc_purge_orig_hash()
405 for (i = 0; i < hash->size; i++) { in batadv_nc_purge_orig_hash()
406 head = &hash->table[i]; in batadv_nc_purge_orig_hash()
417 * batadv_nc_purge_paths() - traverse all nc paths part of the hash and remove
437 for (i = 0; i < hash->size; i++) { in batadv_nc_purge_paths()
438 head = &hash->table[i]; in batadv_nc_purge_paths()
439 lock = &hash->list_locks[i]; in batadv_nc_purge_paths()
450 /* purging an non-empty nc_path should never happen, but in batadv_nc_purge_paths()
455 if (!unlikely(list_empty(&nc_path->packet_list))) { in batadv_nc_purge_paths()
458 "Skipping free of non-empty nc_path (%pM -> %pM)!\n", in batadv_nc_purge_paths()
459 nc_path->prev_hop, in batadv_nc_purge_paths()
460 nc_path->next_hop); in batadv_nc_purge_paths()
466 "Remove nc_path %pM -> %pM\n", in batadv_nc_purge_paths()
467 nc_path->prev_hop, nc_path->next_hop); in batadv_nc_purge_paths()
468 hlist_del_rcu(&nc_path->hash_entry); in batadv_nc_purge_paths()
476 * batadv_nc_hash_key_gen() - computes the nc_path hash key
484 memcpy(key->prev_hop, src, sizeof(key->prev_hop)); in batadv_nc_hash_key_gen()
485 memcpy(key->next_hop, dst, sizeof(key->next_hop)); in batadv_nc_hash_key_gen()
489 * batadv_nc_hash_choose() - compute the hash value for an nc path
500 hash = jhash(&nc_path->prev_hop, sizeof(nc_path->prev_hop), hash); in batadv_nc_hash_choose()
501 hash = jhash(&nc_path->next_hop, sizeof(nc_path->next_hop), hash); in batadv_nc_hash_choose()
507 * batadv_nc_hash_compare() - comparing function used in the network coding hash
523 if (!batadv_compare_eth(nc_path1->prev_hop, nc_path2->prev_hop)) in batadv_nc_hash_compare()
526 if (!batadv_compare_eth(nc_path1->next_hop, nc_path2->next_hop)) in batadv_nc_hash_compare()
533 * batadv_nc_hash_find() - search for an existing nc path and return it
550 index = batadv_nc_hash_choose(data, hash->size); in batadv_nc_hash_find()
551 head = &hash->table[index]; in batadv_nc_hash_find()
555 if (!batadv_nc_hash_compare(&nc_path->hash_entry, data)) in batadv_nc_hash_find()
558 if (!kref_get_unless_zero(&nc_path->refcount)) in batadv_nc_hash_find()
570 * batadv_nc_send_packet() - send non-coded packet and free nc_packet struct
575 batadv_send_unicast_skb(nc_packet->skb, nc_packet->neigh_node); in batadv_nc_send_packet()
576 nc_packet->skb = NULL; in batadv_nc_send_packet()
581 * batadv_nc_sniffed_purge() - Checks timestamp of given sniffed nc_packet.
590 * Return: false as soon as the entry in the fifo queue has not been timed out
597 unsigned long timeout = bat_priv->nc.max_buffer_time; in batadv_nc_sniffed_purge()
600 lockdep_assert_held(&nc_path->packet_list_lock); in batadv_nc_sniffed_purge()
605 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE && in batadv_nc_sniffed_purge()
606 !batadv_has_timed_out(nc_packet->timestamp, timeout)) in batadv_nc_sniffed_purge()
610 list_del(&nc_packet->list); in batadv_nc_sniffed_purge()
620 * batadv_nc_fwd_flush() - Checks the timestamp of the given nc packet.
629 * Return: false as soon as the entry in the fifo queue has not been timed out
636 unsigned long timeout = bat_priv->nc.max_fwd_delay; in batadv_nc_fwd_flush()
638 lockdep_assert_held(&nc_path->packet_list_lock); in batadv_nc_fwd_flush()
643 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE && in batadv_nc_fwd_flush()
644 !batadv_has_timed_out(nc_packet->timestamp, timeout)) in batadv_nc_fwd_flush()
650 nc_packet->skb->len + ETH_HLEN); in batadv_nc_fwd_flush()
651 list_del(&nc_packet->list); in batadv_nc_fwd_flush()
658 * batadv_nc_process_nc_paths() - traverse given nc packet pool and free timed
683 for (i = 0; i < hash->size; i++) { in batadv_nc_process_nc_paths()
684 head = &hash->table[i]; in batadv_nc_process_nc_paths()
690 spin_lock_bh(&nc_path->packet_list_lock); in batadv_nc_process_nc_paths()
692 &nc_path->packet_list, list) { in batadv_nc_process_nc_paths()
697 spin_unlock_bh(&nc_path->packet_list_lock); in batadv_nc_process_nc_paths()
704 * batadv_nc_worker() - periodic task for housekeeping related to network
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()
745 * batadv_can_nc_with_orig() - checks whether the given orig node is suitable
755 * 4) The TQ value of the OGM must be above bat_priv->nc.min_tq.
769 last_ttl = orig_ifinfo->last_ttl; in batadv_can_nc_with_orig()
770 last_real_seqno = orig_ifinfo->last_real_seqno; in batadv_can_nc_with_orig()
773 if (last_real_seqno != ntohl(ogm_packet->seqno)) in batadv_can_nc_with_orig()
775 if (last_ttl != ogm_packet->ttl + 1) in batadv_can_nc_with_orig()
777 if (!batadv_compare_eth(ogm_packet->orig, ogm_packet->prev_sender)) in batadv_can_nc_with_orig()
779 if (ogm_packet->tq < bat_priv->nc.min_tq) in batadv_can_nc_with_orig()
786 * batadv_nc_find_nc_node() - search for an existing nc node and return it
803 list = &orig_neigh_node->in_coding_list; in batadv_nc_find_nc_node()
805 list = &orig_neigh_node->out_coding_list; in batadv_nc_find_nc_node()
810 if (!batadv_compare_eth(nc_node->addr, orig_node->orig)) in batadv_nc_find_nc_node()
813 if (!kref_get_unless_zero(&nc_node->refcount)) in batadv_nc_find_nc_node()
826 * batadv_nc_get_nc_node() - retrieves an nc node or creates the entry if it was
848 lock = &orig_neigh_node->in_coding_list_lock; in batadv_nc_get_nc_node()
849 list = &orig_neigh_node->in_coding_list; in batadv_nc_get_nc_node()
851 lock = &orig_neigh_node->out_coding_list_lock; in batadv_nc_get_nc_node()
852 list = &orig_neigh_node->out_coding_list; in batadv_nc_get_nc_node()
869 INIT_LIST_HEAD(&nc_node->list); in batadv_nc_get_nc_node()
870 kref_init(&nc_node->refcount); in batadv_nc_get_nc_node()
871 ether_addr_copy(nc_node->addr, orig_node->orig); in batadv_nc_get_nc_node()
872 kref_get(&orig_neigh_node->refcount); in batadv_nc_get_nc_node()
873 nc_node->orig_node = orig_neigh_node; in batadv_nc_get_nc_node()
875 batadv_dbg(BATADV_DBG_NC, bat_priv, "Adding nc_node %pM -> %pM\n", in batadv_nc_get_nc_node()
876 nc_node->addr, nc_node->orig_node->orig); in batadv_nc_get_nc_node()
879 kref_get(&nc_node->refcount); in batadv_nc_get_nc_node()
880 list_add_tail_rcu(&nc_node->list, list); in batadv_nc_get_nc_node()
889 * batadv_nc_update_nc_node() - updates stored incoming and outgoing nc node
908 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_update_nc_node()
912 if (!test_bit(BATADV_ORIG_CAPA_HAS_NC, &orig_node->capabilities)) in batadv_nc_update_nc_node()
926 in_nc_node->last_seen = jiffies; in batadv_nc_update_nc_node()
934 out_nc_node->last_seen = jiffies; in batadv_nc_update_nc_node()
942 * batadv_nc_get_path() - get existing nc_path or allocate a new one
945 * @src: ethernet source address - first half of the nc path search key
946 * @dst: ethernet destination address - second half of the nc path search key
966 nc_path->last_valid = jiffies; in batadv_nc_get_path()
977 INIT_LIST_HEAD(&nc_path->packet_list); in batadv_nc_get_path()
978 spin_lock_init(&nc_path->packet_list_lock); in batadv_nc_get_path()
979 kref_init(&nc_path->refcount); in batadv_nc_get_path()
980 nc_path->last_valid = jiffies; in batadv_nc_get_path()
981 ether_addr_copy(nc_path->next_hop, dst); in batadv_nc_get_path()
982 ether_addr_copy(nc_path->prev_hop, src); in batadv_nc_get_path()
984 batadv_dbg(BATADV_DBG_NC, bat_priv, "Adding nc_path %pM -> %pM\n", in batadv_nc_get_path()
985 nc_path->prev_hop, in batadv_nc_get_path()
986 nc_path->next_hop); in batadv_nc_get_path()
989 kref_get(&nc_path->refcount); in batadv_nc_get_path()
992 &nc_path->hash_entry); in batadv_nc_get_path()
1003 * batadv_nc_random_weight_tq() - scale the receivers TQ-value to avoid unfair
1011 /* randomize the estimated packet loss (max TQ - estimated TQ) */ in batadv_nc_random_weight_tq()
1012 u8 rand_tq = get_random_u32_below(BATADV_TQ_MAX_VALUE + 1 - tq); in batadv_nc_random_weight_tq()
1015 return BATADV_TQ_MAX_VALUE - rand_tq; in batadv_nc_random_weight_tq()
1019 * batadv_nc_memxor() - XOR destination with source
1033 * batadv_nc_code_packets() - code a received unicast_packet with an nc packet
1065 int header_add = coded_size - unicast_size; in batadv_nc_code_packets()
1070 router_neigh = batadv_orig_router_get(neigh_node->orig_node, in batadv_nc_code_packets()
1080 neigh_tmp = nc_packet->neigh_node; in batadv_nc_code_packets()
1081 router_coding = batadv_orig_router_get(neigh_tmp->orig_node, in batadv_nc_code_packets()
1091 tq_tmp = router_neigh_ifinfo->bat_iv.tq_avg; in batadv_nc_code_packets()
1093 tq_tmp = router_coding_ifinfo->bat_iv.tq_avg; in batadv_nc_code_packets()
1096 /* Select one destination for the MAC-header dst-field based on in batadv_nc_code_packets()
1097 * weighted TQ-values. in batadv_nc_code_packets()
1100 /* Destination from nc_packet is selected for MAC-header */ in batadv_nc_code_packets()
1101 first_dest = nc_packet->neigh_node; in batadv_nc_code_packets()
1102 first_source = nc_packet->nc_path->prev_hop; in batadv_nc_code_packets()
1104 second_source = ethhdr->h_source; in batadv_nc_code_packets()
1105 packet1 = (struct batadv_unicast_packet *)nc_packet->skb->data; in batadv_nc_code_packets()
1106 packet2 = (struct batadv_unicast_packet *)skb->data; in batadv_nc_code_packets()
1107 packet_id1 = nc_packet->packet_id; in batadv_nc_code_packets()
1109 skb->data + sizeof(*packet2)); in batadv_nc_code_packets()
1111 /* Destination for skb is selected for MAC-header */ in batadv_nc_code_packets()
1113 first_source = ethhdr->h_source; in batadv_nc_code_packets()
1114 second_dest = nc_packet->neigh_node; in batadv_nc_code_packets()
1115 second_source = nc_packet->nc_path->prev_hop; in batadv_nc_code_packets()
1116 packet1 = (struct batadv_unicast_packet *)skb->data; in batadv_nc_code_packets()
1117 packet2 = (struct batadv_unicast_packet *)nc_packet->skb->data; in batadv_nc_code_packets()
1119 skb->data + sizeof(*packet1)); in batadv_nc_code_packets()
1120 packet_id2 = nc_packet->packet_id; in batadv_nc_code_packets()
1126 if (skb->len <= nc_packet->skb->len) { in batadv_nc_code_packets()
1127 skb_dest = nc_packet->skb; in batadv_nc_code_packets()
1131 skb_src = nc_packet->skb; in batadv_nc_code_packets()
1135 coding_len = skb_src->len - unicast_size; in batadv_nc_code_packets()
1142 coded_packet = (struct batadv_coded_packet *)skb_dest->data; in batadv_nc_code_packets()
1145 coded_packet->packet_type = BATADV_CODED; in batadv_nc_code_packets()
1146 coded_packet->version = BATADV_COMPAT_VERSION; in batadv_nc_code_packets()
1147 coded_packet->ttl = packet1->ttl; in batadv_nc_code_packets()
1150 ether_addr_copy(coded_packet->first_source, first_source); in batadv_nc_code_packets()
1151 ether_addr_copy(coded_packet->first_orig_dest, packet1->dest); in batadv_nc_code_packets()
1152 coded_packet->first_crc = packet_id1; in batadv_nc_code_packets()
1153 coded_packet->first_ttvn = packet1->ttvn; in batadv_nc_code_packets()
1156 ether_addr_copy(coded_packet->second_dest, second_dest->addr); in batadv_nc_code_packets()
1157 ether_addr_copy(coded_packet->second_source, second_source); in batadv_nc_code_packets()
1158 ether_addr_copy(coded_packet->second_orig_dest, packet2->dest); in batadv_nc_code_packets()
1159 coded_packet->second_crc = packet_id2; in batadv_nc_code_packets()
1160 coded_packet->second_ttl = packet2->ttl; in batadv_nc_code_packets()
1161 coded_packet->second_ttvn = packet2->ttvn; in batadv_nc_code_packets()
1162 coded_packet->coded_len = htons(coding_len); in batadv_nc_code_packets()
1165 batadv_nc_memxor(skb_dest->data + coded_size, in batadv_nc_code_packets()
1166 skb_src->data + unicast_size, coding_len); in batadv_nc_code_packets()
1169 if (BATADV_SKB_CB(skb_src)->decoded && in batadv_nc_code_packets()
1170 BATADV_SKB_CB(skb_dest)->decoded) { in batadv_nc_code_packets()
1172 count = skb_src->len + ETH_HLEN; in batadv_nc_code_packets()
1173 count += skb_dest->len + ETH_HLEN; in batadv_nc_code_packets()
1176 } else if (!BATADV_SKB_CB(skb_src)->decoded && in batadv_nc_code_packets()
1177 !BATADV_SKB_CB(skb_dest)->decoded) { in batadv_nc_code_packets()
1179 count = skb_src->len + ETH_HLEN; in batadv_nc_code_packets()
1180 count += skb_dest->len + ETH_HLEN; in batadv_nc_code_packets()
1183 } else if (BATADV_SKB_CB(skb_src)->decoded && in batadv_nc_code_packets()
1184 !BATADV_SKB_CB(skb_dest)->decoded) { in batadv_nc_code_packets()
1188 skb_src->len + ETH_HLEN); in batadv_nc_code_packets()
1191 skb_dest->len + ETH_HLEN); in batadv_nc_code_packets()
1192 } else if (!BATADV_SKB_CB(skb_src)->decoded && in batadv_nc_code_packets()
1193 BATADV_SKB_CB(skb_dest)->decoded) { in batadv_nc_code_packets()
1197 skb_src->len + ETH_HLEN); in batadv_nc_code_packets()
1200 skb_dest->len + ETH_HLEN); in batadv_nc_code_packets()
1207 nc_packet->skb = NULL; in batadv_nc_code_packets()
1222 * batadv_nc_skb_coding_possible() - true if a decoded skb is available at dst.
1232 * re-code the packet if the source of the previous encoded packet is involved.
1240 if (BATADV_SKB_CB(skb)->decoded && !batadv_compare_eth(dst, src)) in batadv_nc_skb_coding_possible()
1246 * batadv_nc_path_search() - Find the coding path matching in_nc_node and
1266 struct batadv_hashtable *hash = bat_priv->nc.coding_hash; in batadv_nc_path_search()
1273 batadv_nc_hash_key_gen(&nc_path_key, in_nc_node->addr, in batadv_nc_path_search()
1274 out_nc_node->addr); in batadv_nc_path_search()
1275 idx = batadv_nc_hash_choose(&nc_path_key, hash->size); in batadv_nc_path_search()
1279 hlist_for_each_entry_rcu(nc_path, &hash->table[idx], hash_entry) { in batadv_nc_path_search()
1280 if (!batadv_compare_eth(nc_path->prev_hop, in_nc_node->addr)) in batadv_nc_path_search()
1283 if (!batadv_compare_eth(nc_path->next_hop, out_nc_node->addr)) in batadv_nc_path_search()
1286 spin_lock_bh(&nc_path->packet_list_lock); in batadv_nc_path_search()
1287 if (list_empty(&nc_path->packet_list)) { in batadv_nc_path_search()
1288 spin_unlock_bh(&nc_path->packet_list_lock); in batadv_nc_path_search()
1293 &nc_path->packet_list, list) { in batadv_nc_path_search()
1294 if (!batadv_nc_skb_coding_possible(nc_packet->skb, in batadv_nc_path_search()
1296 in_nc_node->addr)) in batadv_nc_path_search()
1300 list_del(&nc_packet->list); in batadv_nc_path_search()
1305 spin_unlock_bh(&nc_path->packet_list_lock); in batadv_nc_path_search()
1314 * batadv_nc_skb_src_search() - Loops through the list of neighboring nodes of
1341 &orig_node->out_coding_list, list) { in batadv_nc_skb_src_search()
1344 out_nc_node->addr, eth_src)) in batadv_nc_skb_src_search()
1360 * batadv_nc_skb_store_before_coding() - set the ethernet src and dst of the
1379 ether_addr_copy(ethhdr->h_source, ethhdr->h_dest); in batadv_nc_skb_store_before_coding()
1380 ether_addr_copy(ethhdr->h_dest, eth_dst_new); in batadv_nc_skb_store_before_coding()
1382 /* Set data pointer to MAC header to mimic packets from our tx path */ in batadv_nc_skb_store_before_coding()
1395 * batadv_nc_skb_dst_search() - Loops through list of neighboring nodes to dst.
1411 struct net_device *netdev = neigh_node->if_incoming->soft_iface; in batadv_nc_skb_dst_search()
1413 struct batadv_orig_node *orig_node = neigh_node->orig_node; in batadv_nc_skb_dst_search()
1418 list_for_each_entry_rcu(nc_node, &orig_node->in_coding_list, list) { in batadv_nc_skb_dst_search()
1421 neigh_node->addr, in batadv_nc_skb_dst_search()
1422 ethhdr->h_source, nc_node); in batadv_nc_skb_dst_search()
1435 neigh_node->addr); in batadv_nc_skb_dst_search()
1436 batadv_nc_skb_store_before_coding(bat_priv, nc_packet->skb, in batadv_nc_skb_dst_search()
1437 nc_packet->neigh_node->addr); in batadv_nc_skb_dst_search()
1444 /* out of mem ? Coding failed - we have to free the buffered packet in batadv_nc_skb_dst_search()
1453 * batadv_nc_skb_add_to_path() - buffer skb for later encoding / decoding
1473 nc_packet->timestamp = jiffies; in batadv_nc_skb_add_to_path()
1474 nc_packet->packet_id = packet_id; in batadv_nc_skb_add_to_path()
1475 nc_packet->skb = skb; in batadv_nc_skb_add_to_path()
1476 nc_packet->neigh_node = neigh_node; in batadv_nc_skb_add_to_path()
1477 nc_packet->nc_path = nc_path; in batadv_nc_skb_add_to_path()
1480 spin_lock_bh(&nc_path->packet_list_lock); in batadv_nc_skb_add_to_path()
1481 list_add_tail(&nc_packet->list, &nc_path->packet_list); in batadv_nc_skb_add_to_path()
1482 spin_unlock_bh(&nc_path->packet_list_lock); in batadv_nc_skb_add_to_path()
1488 * batadv_nc_skb_forward() - try to code a packet or add it to the coding packet
1498 const struct net_device *netdev = neigh_node->if_incoming->soft_iface; in batadv_nc_skb_forward()
1507 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_skb_forward()
1513 if (packet->packet_type != BATADV_UNICAST) in batadv_nc_skb_forward()
1520 /* Find or create a nc_path for this src-dst pair */ in batadv_nc_skb_forward()
1522 bat_priv->nc.coding_hash, in batadv_nc_skb_forward()
1523 ethhdr->h_source, in batadv_nc_skb_forward()
1524 neigh_node->addr); in batadv_nc_skb_forward()
1545 * batadv_nc_skb_store_for_decoding() - save a clone of the skb which can be
1560 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_skb_store_for_decoding()
1566 if (packet->packet_type != BATADV_UNICAST) in batadv_nc_skb_store_for_decoding()
1571 bat_priv->nc.decoding_hash, in batadv_nc_skb_store_for_decoding()
1572 ethhdr->h_source, in batadv_nc_skb_store_for_decoding()
1573 ethhdr->h_dest); in batadv_nc_skb_store_for_decoding()
1578 /* Clone skb and adjust skb->data to point at batman header */ in batadv_nc_skb_store_for_decoding()
1606 * batadv_nc_skb_store_sniffed_unicast() - check if a received unicast packet
1616 if (batadv_is_my_mac(bat_priv, ethhdr->h_dest)) in batadv_nc_skb_store_sniffed_unicast()
1619 /* Set data pointer to MAC header to mimic packets from our tx path */ in batadv_nc_skb_store_sniffed_unicast()
1626 * batadv_nc_skb_decode_packet() - decode given skb using the decode data stored
1640 const int h_diff = sizeof(struct batadv_coded_packet) - h_size; in batadv_nc_skb_decode_packet()
1649 memcpy(&coded_packet_tmp, skb->data, sizeof(coded_packet_tmp)); in batadv_nc_skb_decode_packet()
1661 skb_set_mac_header(skb, -ETH_HLEN); in batadv_nc_skb_decode_packet()
1676 ether_addr_copy(ethhdr->h_dest, coded_packet_tmp.second_dest); in batadv_nc_skb_decode_packet()
1677 skb->pkt_type = PACKET_HOST; in batadv_nc_skb_decode_packet()
1690 if (coding_len > skb->len) in batadv_nc_skb_decode_packet()
1696 batadv_nc_memxor(skb->data + h_size, in batadv_nc_skb_decode_packet()
1697 nc_packet->skb->data + h_size, in batadv_nc_skb_decode_packet()
1700 /* Resize decoded skb if decoded with larger packet */ in batadv_nc_skb_decode_packet()
1701 if (nc_packet->skb->len > coding_len + h_size) { in batadv_nc_skb_decode_packet()
1708 unicast_packet = (struct batadv_unicast_packet *)skb->data; in batadv_nc_skb_decode_packet()
1709 unicast_packet->packet_type = BATADV_UNICAST; in batadv_nc_skb_decode_packet()
1710 unicast_packet->version = BATADV_COMPAT_VERSION; in batadv_nc_skb_decode_packet()
1711 unicast_packet->ttl = ttl; in batadv_nc_skb_decode_packet()
1712 ether_addr_copy(unicast_packet->dest, orig_dest); in batadv_nc_skb_decode_packet()
1713 unicast_packet->ttvn = ttvn; in batadv_nc_skb_decode_packet()
1720 * batadv_nc_find_decoding_packet() - search through buffered decoding data to
1733 struct batadv_hashtable *hash = bat_priv->nc.decoding_hash; in batadv_nc_find_decoding_packet()
1743 /* Select the correct packet id based on the location of our mac-addr */ in batadv_nc_find_decoding_packet()
1744 dest = ethhdr->h_source; in batadv_nc_find_decoding_packet()
1745 if (!batadv_is_my_mac(bat_priv, coded->second_dest)) { in batadv_nc_find_decoding_packet()
1746 source = coded->second_source; in batadv_nc_find_decoding_packet()
1747 packet_id = coded->second_crc; in batadv_nc_find_decoding_packet()
1749 source = coded->first_source; in batadv_nc_find_decoding_packet()
1750 packet_id = coded->first_crc; in batadv_nc_find_decoding_packet()
1754 index = batadv_nc_hash_choose(&nc_path_key, hash->size); in batadv_nc_find_decoding_packet()
1758 hlist_for_each_entry_rcu(nc_path, &hash->table[index], hash_entry) { in batadv_nc_find_decoding_packet()
1760 spin_lock_bh(&nc_path->packet_list_lock); in batadv_nc_find_decoding_packet()
1762 &nc_path->packet_list, list) { in batadv_nc_find_decoding_packet()
1763 if (packet_id == tmp_nc_packet->packet_id) { in batadv_nc_find_decoding_packet()
1764 list_del(&tmp_nc_packet->list); in batadv_nc_find_decoding_packet()
1770 spin_unlock_bh(&nc_path->packet_list_lock); in batadv_nc_find_decoding_packet()
1785 * batadv_nc_recv_coded_packet() - try to decode coded packet and enqueue the
1796 struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); in batadv_nc_recv_coded_packet()
1804 if (!atomic_read(&bat_priv->network_coding)) in batadv_nc_recv_coded_packet()
1811 coded_packet = (struct batadv_coded_packet *)skb->data; 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()
1834 if (skb_linearize(nc_packet->skb) < 0) in batadv_nc_recv_coded_packet()
1845 BATADV_SKB_CB(skb)->decoded = true; in batadv_nc_recv_coded_packet()
1848 skb->len + ETH_HLEN); in batadv_nc_recv_coded_packet()
1860 * batadv_nc_mesh_free() - clean up network coding memory
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()