Lines Matching refs:chain

33  * batadv_frag_clear_chain() - delete entries in the fragment buffer chain
34 * @head: head of chain with entries.
35 * @dropped: whether the chain is cleared because all fragments are dropped
64 struct batadv_frag_table_entry *chain;
68 chain = &orig_node->fragments[i];
69 spin_lock_bh(&chain->lock);
71 if (!check_cb || check_cb(chain)) {
72 batadv_frag_clear_chain(&chain->fragment_list, true);
73 chain->size = 0;
76 spin_unlock_bh(&chain->lock);
96 * batadv_frag_init_chain() - check and prepare fragment chain for new fragment
97 * @chain: chain in fragments table to init
100 * Make chain ready for a fragment with sequence number "seqno". Delete existing
103 * Caller must hold chain->lock.
105 * Return: true if chain is empty and the caller can just insert the new
108 static bool batadv_frag_init_chain(struct batadv_frag_table_entry *chain,
111 lockdep_assert_held(&chain->lock);
113 if (chain->seqno == seqno)
116 if (!hlist_empty(&chain->fragment_list))
117 batadv_frag_clear_chain(&chain->fragment_list, true);
119 chain->size = 0;
120 chain->seqno = seqno;
126 * batadv_frag_insert_packet() - insert a fragment into a fragment chain
131 * Insert a new fragment into the reverse ordered chain in the right table
134 * Return: true if skb is buffered, false on error. If the chain has all the
135 * fragments needed to merge the packet, the chain is moved to the passed head
136 * to avoid locking the chain in the table.
142 struct batadv_frag_table_entry *chain;
168 /* Select entry in the "chain table" and delete any prior fragments
172 chain = &orig_node->fragments[bucket];
173 spin_lock_bh(&chain->lock);
174 if (batadv_frag_init_chain(chain, seqno)) {
175 hlist_add_head(&frag_entry_new->list, &chain->fragment_list);
176 chain->size = skb->len - hdr_size;
177 chain->timestamp = jiffies;
178 chain->total_size = ntohs(frag_packet->total_size);
184 hlist_for_each_entry(frag_entry_curr, &chain->fragment_list, list) {
193 chain->size += skb->len - hdr_size;
194 chain->timestamp = jiffies;
206 chain->size += skb->len - hdr_size;
207 chain->timestamp = jiffies;
212 if (chain->size > batadv_frag_size_limit() ||
213 chain->total_size != ntohs(frag_packet->total_size) ||
214 chain->total_size > batadv_frag_size_limit()) {
215 /* Clear chain if total size of either the list or the packet
219 batadv_frag_clear_chain(&chain->fragment_list, true);
220 chain->size = 0;
221 } else if (ntohs(frag_packet->total_size) == chain->size) {
222 /* All fragments received. Hand over chain to caller. */
223 hlist_move_list(&chain->fragment_list, chain_out);
224 chain->size = 0;
228 spin_unlock_bh(&chain->lock);
240 * batadv_frag_merge_packets() - merge a chain of fragments
241 * @chain: head of chain with fragments
243 * Expand the first skb in the chain and copy the content of the remaining
244 * skb's into the expanded one. After doing so, clear the chain.
249 batadv_frag_merge_packets(struct hlist_head *chain)
260 entry = hlist_entry(chain->first, struct batadv_frag_list_entry, list);
287 hlist_for_each_entry(entry, chain, list) {
293 /* Locking is not needed, because 'chain' is not part of any orig. */
294 batadv_frag_clear_chain(chain, dropped);