Lines Matching defs:nc_path
225 * batadv_nc_path_release() - release nc_path from lists and queue for free
227 * @ref: kref pointer of the nc_path
231 struct batadv_nc_path *nc_path;
233 nc_path = container_of(ref, struct batadv_nc_path, refcount);
235 kfree_rcu(nc_path, rcu);
239 * batadv_nc_path_put() - decrement the nc_path refcounter and possibly
241 * @nc_path: nc_path to be free'd
243 static void batadv_nc_path_put(struct batadv_nc_path *nc_path)
245 if (!nc_path)
248 kref_put(&nc_path->refcount, batadv_nc_path_release);
264 batadv_nc_path_put(nc_packet->nc_path);
287 * @nc_path: the nc path to check
292 struct batadv_nc_path *nc_path)
300 return batadv_has_timed_out(nc_path->last_valid,
308 * @nc_path: the nc path to check
313 struct batadv_nc_path *nc_path)
321 return batadv_has_timed_out(nc_path->last_valid,
433 struct batadv_nc_path *nc_path;
441 /* For each nc_path in this bin */
443 hlist_for_each_entry_safe(nc_path, node_tmp, head, hash_entry) {
447 if (to_purge && !to_purge(bat_priv, nc_path))
450 /* purging an non-empty nc_path should never happen, but
455 if (!unlikely(list_empty(&nc_path->packet_list))) {
458 "Skipping free of non-empty nc_path (%pM -> %pM)!\n",
459 nc_path->prev_hop,
460 nc_path->next_hop);
464 /* nc_path is unused, so remove it */
466 "Remove nc_path %pM -> %pM\n",
467 nc_path->prev_hop, nc_path->next_hop);
468 hlist_del_rcu(&nc_path->hash_entry);
469 batadv_nc_path_put(nc_path);
476 * batadv_nc_hash_key_gen() - computes the nc_path hash key
497 const struct batadv_nc_path *nc_path = data;
500 hash = jhash(&nc_path->prev_hop, sizeof(nc_path->prev_hop), hash);
501 hash = jhash(&nc_path->next_hop, sizeof(nc_path->next_hop), hash);
537 * Return: the nc_path if found, NULL otherwise.
544 struct batadv_nc_path *nc_path, *nc_path_tmp = NULL;
554 hlist_for_each_entry_rcu(nc_path, head, hash_entry) {
555 if (!batadv_nc_hash_compare(&nc_path->hash_entry, data))
558 if (!kref_get_unless_zero(&nc_path->refcount))
561 nc_path_tmp = nc_path;
583 * @nc_path: the nc path the packet belongs to
594 struct batadv_nc_path *nc_path,
600 lockdep_assert_held(&nc_path->packet_list_lock);
622 * @nc_path: the nc path the packet belongs to
633 struct batadv_nc_path *nc_path,
638 lockdep_assert_held(&nc_path->packet_list_lock);
675 struct batadv_nc_path *nc_path;
688 hlist_for_each_entry_rcu(nc_path, head, hash_entry) {
690 spin_lock_bh(&nc_path->packet_list_lock);
692 &nc_path->packet_list, list) {
693 ret = process_fn(bat_priv, nc_path, nc_packet);
697 spin_unlock_bh(&nc_path->packet_list_lock);
942 * batadv_nc_get_path() - get existing nc_path or allocate a new one
948 * Return: pointer to nc_path if the path was found or created, returns NULL
957 struct batadv_nc_path *nc_path, nc_path_key;
961 /* Search for existing nc_path */
962 nc_path = batadv_nc_hash_find(hash, (void *)&nc_path_key);
964 if (nc_path) {
965 /* Set timestamp to delay removal of nc_path */
966 nc_path->last_valid = jiffies;
967 return nc_path;
970 /* No existing nc_path was found; create a new */
971 nc_path = kzalloc(sizeof(*nc_path), GFP_ATOMIC);
973 if (!nc_path)
976 /* Initialize nc_path */
977 INIT_LIST_HEAD(&nc_path->packet_list);
978 spin_lock_init(&nc_path->packet_list_lock);
979 kref_init(&nc_path->refcount);
980 nc_path->last_valid = jiffies;
981 ether_addr_copy(nc_path->next_hop, dst);
982 ether_addr_copy(nc_path->prev_hop, src);
984 batadv_dbg(BATADV_DBG_NC, bat_priv, "Adding nc_path %pM -> %pM\n",
985 nc_path->prev_hop,
986 nc_path->next_hop);
988 /* Add nc_path to hash table */
989 kref_get(&nc_path->refcount);
992 &nc_path->hash_entry);
995 kfree(nc_path);
999 return nc_path;
1102 first_source = nc_packet->nc_path->prev_hop;
1115 second_source = nc_packet->nc_path->prev_hop;
1263 struct batadv_nc_path *nc_path, nc_path_key;
1277 /* Check for coding opportunities in this nc_path */
1279 hlist_for_each_entry_rcu(nc_path, &hash->table[idx], hash_entry) {
1280 if (!batadv_compare_eth(nc_path->prev_hop, in_nc_node->addr))
1283 if (!batadv_compare_eth(nc_path->next_hop, out_nc_node->addr))
1286 spin_lock_bh(&nc_path->packet_list_lock);
1287 if (list_empty(&nc_path->packet_list)) {
1288 spin_unlock_bh(&nc_path->packet_list_lock);
1293 &nc_path->packet_list, list) {
1305 spin_unlock_bh(&nc_path->packet_list_lock);
1347 /* Search for an opportunity in this nc_path */
1455 * @nc_path: path to add skb to
1462 struct batadv_nc_path *nc_path,
1477 nc_packet->nc_path = nc_path;
1480 spin_lock_bh(&nc_path->packet_list_lock);
1481 list_add_tail(&nc_packet->list, &nc_path->packet_list);
1482 spin_unlock_bh(&nc_path->packet_list_lock);
1501 struct batadv_nc_path *nc_path;
1520 /* Find or create a nc_path for this src-dst pair */
1521 nc_path = batadv_nc_get_path(bat_priv,
1526 if (!nc_path)
1529 /* Add skb to nc_path */
1531 if (!batadv_nc_skb_add_to_path(skb, nc_path, neigh_node, packet_id))
1538 batadv_nc_path_put(nc_path);
1554 struct batadv_nc_path *nc_path;
1569 /* Find existing nc_path or create a new */
1570 nc_path = batadv_nc_get_path(bat_priv,
1575 if (!nc_path)
1589 /* Add skb to nc_path */
1591 if (!batadv_nc_skb_add_to_path(skb, nc_path, NULL, packet_id))
1600 batadv_nc_path_put(nc_path);
1735 struct batadv_nc_path *nc_path, nc_path_key;
1758 hlist_for_each_entry_rcu(nc_path, &hash->table[index], hash_entry) {
1760 spin_lock_bh(&nc_path->packet_list_lock);
1762 &nc_path->packet_list, list) {
1770 spin_unlock_bh(&nc_path->packet_list_lock);