Lines Matching refs:chain

31  * batadv_frag_clear_chain() - delete entries in the fragment buffer chain
32 * @head: head of chain with entries.
33 * @dropped: whether the chain is cleared because all fragments are dropped
62 struct batadv_frag_table_entry *chain;
66 chain = &orig_node->fragments[i];
67 spin_lock_bh(&chain->lock);
69 if (!check_cb || check_cb(chain)) {
70 batadv_frag_clear_chain(&chain->fragment_list, true);
71 chain->size = 0;
74 spin_unlock_bh(&chain->lock);
94 * batadv_frag_init_chain() - check and prepare fragment chain for new fragment
95 * @chain: chain in fragments table to init
98 * Make chain ready for a fragment with sequence number "seqno". Delete existing
101 * Caller must hold chain->lock.
103 * Return: true if chain is empty and the caller can just insert the new
106 static bool batadv_frag_init_chain(struct batadv_frag_table_entry *chain,
109 lockdep_assert_held(&chain->lock);
111 if (chain->seqno == seqno)
114 if (!hlist_empty(&chain->fragment_list))
115 batadv_frag_clear_chain(&chain->fragment_list, true);
117 chain->size = 0;
118 chain->seqno = seqno;
124 * batadv_frag_insert_packet() - insert a fragment into a fragment chain
129 * Insert a new fragment into the reverse ordered chain in the right table
132 * Return: true if skb is buffered, false on error. If the chain has all the
133 * fragments needed to merge the packet, the chain is moved to the passed head
134 * to avoid locking the chain in the table.
140 struct batadv_frag_table_entry *chain;
166 /* Select entry in the "chain table" and delete any prior fragments
170 chain = &orig_node->fragments[bucket];
171 spin_lock_bh(&chain->lock);
172 if (batadv_frag_init_chain(chain, seqno)) {
173 hlist_add_head(&frag_entry_new->list, &chain->fragment_list);
174 chain->size = skb->len - hdr_size;
175 chain->timestamp = jiffies;
176 chain->total_size = ntohs(frag_packet->total_size);
182 hlist_for_each_entry(frag_entry_curr, &chain->fragment_list, list) {
191 chain->size += skb->len - hdr_size;
192 chain->timestamp = jiffies;
204 chain->size += skb->len - hdr_size;
205 chain->timestamp = jiffies;
210 if (chain->size > batadv_frag_size_limit() ||
211 chain->total_size != ntohs(frag_packet->total_size) ||
212 chain->total_size > batadv_frag_size_limit()) {
213 /* Clear chain if total size of either the list or the packet
217 batadv_frag_clear_chain(&chain->fragment_list, true);
218 chain->size = 0;
219 } else if (ntohs(frag_packet->total_size) == chain->size) {
220 /* All fragments received. Hand over chain to caller. */
221 hlist_move_list(&chain->fragment_list, chain_out);
222 chain->size = 0;
226 spin_unlock_bh(&chain->lock);
238 * batadv_frag_merge_packets() - merge a chain of fragments
239 * @chain: head of chain with fragments
241 * Expand the first skb in the chain and copy the content of the remaining
242 * skb's into the expanded one. After doing so, clear the chain.
247 batadv_frag_merge_packets(struct hlist_head *chain)
258 entry = hlist_entry(chain->first, struct batadv_frag_list_entry, list);
285 hlist_for_each_entry(entry, chain, list) {
291 /* Locking is not needed, because 'chain' is not part of any orig. */
292 batadv_frag_clear_chain(chain, dropped);