Lines Matching defs:nc_path
232 * batadv_nc_path_release() - release nc_path from lists and queue for free
234 * @ref: kref pointer of the nc_path
238 struct batadv_nc_path *nc_path;
240 nc_path = container_of(ref, struct batadv_nc_path, refcount);
242 kfree_rcu(nc_path, rcu);
246 * batadv_nc_path_put() - decrement the nc_path refcounter and possibly
248 * @nc_path: nc_path to be free'd
250 static void batadv_nc_path_put(struct batadv_nc_path *nc_path)
252 if (!nc_path)
255 kref_put(&nc_path->refcount, batadv_nc_path_release);
271 batadv_nc_path_put(nc_packet->nc_path);
294 * @nc_path: the nc path to check
299 struct batadv_nc_path *nc_path)
307 return batadv_has_timed_out(nc_path->last_valid,
315 * @nc_path: the nc path to check
320 struct batadv_nc_path *nc_path)
328 return batadv_has_timed_out(nc_path->last_valid,
440 struct batadv_nc_path *nc_path;
448 /* For each nc_path in this bin */
450 hlist_for_each_entry_safe(nc_path, node_tmp, head, hash_entry) {
454 if (to_purge && !to_purge(bat_priv, nc_path))
457 /* purging an non-empty nc_path should never happen, but
462 if (!unlikely(list_empty(&nc_path->packet_list))) {
465 "Skipping free of non-empty nc_path (%pM -> %pM)!\n",
466 nc_path->prev_hop,
467 nc_path->next_hop);
471 /* nc_path is unused, so remove it */
473 "Remove nc_path %pM -> %pM\n",
474 nc_path->prev_hop, nc_path->next_hop);
475 hlist_del_rcu(&nc_path->hash_entry);
476 batadv_nc_path_put(nc_path);
483 * batadv_nc_hash_key_gen() - computes the nc_path hash key
504 const struct batadv_nc_path *nc_path = data;
507 hash = jhash(&nc_path->prev_hop, sizeof(nc_path->prev_hop), hash);
508 hash = jhash(&nc_path->next_hop, sizeof(nc_path->next_hop), hash);
544 * Return: the nc_path if found, NULL otherwise.
551 struct batadv_nc_path *nc_path, *nc_path_tmp = NULL;
561 hlist_for_each_entry_rcu(nc_path, head, hash_entry) {
562 if (!batadv_nc_hash_compare(&nc_path->hash_entry, data))
565 if (!kref_get_unless_zero(&nc_path->refcount))
568 nc_path_tmp = nc_path;
590 * @nc_path: the nc path the packet belongs to
601 struct batadv_nc_path *nc_path,
607 lockdep_assert_held(&nc_path->packet_list_lock);
629 * @nc_path: the nc path the packet belongs to
640 struct batadv_nc_path *nc_path,
645 lockdep_assert_held(&nc_path->packet_list_lock);
682 struct batadv_nc_path *nc_path;
695 hlist_for_each_entry_rcu(nc_path, head, hash_entry) {
697 spin_lock_bh(&nc_path->packet_list_lock);
699 &nc_path->packet_list, list) {
700 ret = process_fn(bat_priv, nc_path, nc_packet);
704 spin_unlock_bh(&nc_path->packet_list_lock);
951 * batadv_nc_get_path() - get existing nc_path or allocate a new one
957 * Return: pointer to nc_path if the path was found or created, returns NULL
966 struct batadv_nc_path *nc_path, nc_path_key;
970 /* Search for existing nc_path */
971 nc_path = batadv_nc_hash_find(hash, (void *)&nc_path_key);
973 if (nc_path) {
974 /* Set timestamp to delay removal of nc_path */
975 nc_path->last_valid = jiffies;
976 return nc_path;
979 /* No existing nc_path was found; create a new */
980 nc_path = kzalloc(sizeof(*nc_path), GFP_ATOMIC);
982 if (!nc_path)
985 /* Initialize nc_path */
986 INIT_LIST_HEAD(&nc_path->packet_list);
987 spin_lock_init(&nc_path->packet_list_lock);
988 kref_init(&nc_path->refcount);
989 nc_path->last_valid = jiffies;
990 ether_addr_copy(nc_path->next_hop, dst);
991 ether_addr_copy(nc_path->prev_hop, src);
993 batadv_dbg(BATADV_DBG_NC, bat_priv, "Adding nc_path %pM -> %pM\n",
994 nc_path->prev_hop,
995 nc_path->next_hop);
997 /* Add nc_path to hash table */
998 kref_get(&nc_path->refcount);
1001 &nc_path->hash_entry);
1004 kfree(nc_path);
1008 return nc_path;
1111 first_source = nc_packet->nc_path->prev_hop;
1124 second_source = nc_packet->nc_path->prev_hop;
1276 struct batadv_nc_path *nc_path, nc_path_key;
1290 /* Check for coding opportunities in this nc_path */
1292 hlist_for_each_entry_rcu(nc_path, &hash->table[idx], hash_entry) {
1293 if (!batadv_compare_eth(nc_path->prev_hop, in_nc_node->addr))
1296 if (!batadv_compare_eth(nc_path->next_hop, out_nc_node->addr))
1299 spin_lock_bh(&nc_path->packet_list_lock);
1300 if (list_empty(&nc_path->packet_list)) {
1301 spin_unlock_bh(&nc_path->packet_list_lock);
1306 &nc_path->packet_list, list) {
1318 spin_unlock_bh(&nc_path->packet_list_lock);
1360 /* Search for an opportunity in this nc_path */
1468 * @nc_path: path to add skb to
1475 struct batadv_nc_path *nc_path,
1490 nc_packet->nc_path = nc_path;
1493 spin_lock_bh(&nc_path->packet_list_lock);
1494 list_add_tail(&nc_packet->list, &nc_path->packet_list);
1495 spin_unlock_bh(&nc_path->packet_list_lock);
1514 struct batadv_nc_path *nc_path;
1533 /* Find or create a nc_path for this src-dst pair */
1534 nc_path = batadv_nc_get_path(bat_priv,
1539 if (!nc_path)
1542 /* Add skb to nc_path */
1544 if (!batadv_nc_skb_add_to_path(skb, nc_path, neigh_node, packet_id))
1551 batadv_nc_path_put(nc_path);
1567 struct batadv_nc_path *nc_path;
1582 /* Find existing nc_path or create a new */
1583 nc_path = batadv_nc_get_path(bat_priv,
1588 if (!nc_path)
1602 /* Add skb to nc_path */
1604 if (!batadv_nc_skb_add_to_path(skb, nc_path, NULL, packet_id))
1613 batadv_nc_path_put(nc_path);
1748 struct batadv_nc_path *nc_path, nc_path_key;
1771 hlist_for_each_entry_rcu(nc_path, &hash->table[index], hash_entry) {
1773 spin_lock_bh(&nc_path->packet_list_lock);
1775 &nc_path->packet_list, list) {
1783 spin_unlock_bh(&nc_path->packet_list_lock);