Lines Matching refs:map

44 static void sctp_tsnmap_update(struct sctp_tsnmap *map);
45 static void sctp_tsnmap_find_gap_ack(unsigned long *map, __u16 off,
47 static int sctp_tsnmap_grow(struct sctp_tsnmap *map, u16 size);
50 struct sctp_tsnmap *sctp_tsnmap_init(struct sctp_tsnmap *map, __u16 len, in sctp_tsnmap_init() argument
53 if (!map->tsn_map) { in sctp_tsnmap_init()
54 map->tsn_map = kzalloc(len>>3, gfp); in sctp_tsnmap_init()
55 if (map->tsn_map == NULL) in sctp_tsnmap_init()
58 map->len = len; in sctp_tsnmap_init()
60 bitmap_zero(map->tsn_map, map->len); in sctp_tsnmap_init()
64 map->base_tsn = initial_tsn; in sctp_tsnmap_init()
65 map->cumulative_tsn_ack_point = initial_tsn - 1; in sctp_tsnmap_init()
66 map->max_tsn_seen = map->cumulative_tsn_ack_point; in sctp_tsnmap_init()
67 map->num_dup_tsns = 0; in sctp_tsnmap_init()
69 return map; in sctp_tsnmap_init()
72 void sctp_tsnmap_free(struct sctp_tsnmap *map) in sctp_tsnmap_free() argument
74 map->len = 0; in sctp_tsnmap_free()
75 kfree(map->tsn_map); in sctp_tsnmap_free()
84 int sctp_tsnmap_check(const struct sctp_tsnmap *map, __u32 tsn) in sctp_tsnmap_check() argument
89 if (TSN_lte(tsn, map->cumulative_tsn_ack_point)) in sctp_tsnmap_check()
95 if (!TSN_lt(tsn, map->base_tsn + SCTP_TSN_MAP_SIZE)) in sctp_tsnmap_check()
99 gap = tsn - map->base_tsn; in sctp_tsnmap_check()
102 if (gap < map->len && test_bit(gap, map->tsn_map)) in sctp_tsnmap_check()
110 int sctp_tsnmap_mark(struct sctp_tsnmap *map, __u32 tsn, in sctp_tsnmap_mark() argument
115 if (TSN_lt(tsn, map->base_tsn)) in sctp_tsnmap_mark()
118 gap = tsn - map->base_tsn; in sctp_tsnmap_mark()
120 if (gap >= map->len && !sctp_tsnmap_grow(map, gap + 1)) in sctp_tsnmap_mark()
123 if (!sctp_tsnmap_has_gap(map) && gap == 0) { in sctp_tsnmap_mark()
128 map->max_tsn_seen++; in sctp_tsnmap_mark()
129 map->cumulative_tsn_ack_point++; in sctp_tsnmap_mark()
133 map->base_tsn++; in sctp_tsnmap_mark()
140 if (TSN_lt(map->max_tsn_seen, tsn)) in sctp_tsnmap_mark()
141 map->max_tsn_seen = tsn; in sctp_tsnmap_mark()
144 set_bit(gap, map->tsn_map); in sctp_tsnmap_mark()
149 sctp_tsnmap_update(map); in sctp_tsnmap_mark()
157 static void sctp_tsnmap_iter_init(const struct sctp_tsnmap *map, in sctp_tsnmap_iter_init() argument
161 iter->start = map->cumulative_tsn_ack_point + 1; in sctp_tsnmap_iter_init()
167 static int sctp_tsnmap_next_gap_ack(const struct sctp_tsnmap *map, in sctp_tsnmap_next_gap_ack() argument
175 if (TSN_lte(map->max_tsn_seen, iter->start)) in sctp_tsnmap_next_gap_ack()
178 offset = iter->start - map->base_tsn; in sctp_tsnmap_next_gap_ack()
179 sctp_tsnmap_find_gap_ack(map->tsn_map, offset, map->len, in sctp_tsnmap_next_gap_ack()
184 end_ = map->len - 1; in sctp_tsnmap_next_gap_ack()
197 iter->start = map->cumulative_tsn_ack_point + *end + 1; in sctp_tsnmap_next_gap_ack()
205 void sctp_tsnmap_skip(struct sctp_tsnmap *map, __u32 tsn) in sctp_tsnmap_skip() argument
209 if (TSN_lt(tsn, map->base_tsn)) in sctp_tsnmap_skip()
211 if (!TSN_lt(tsn, map->base_tsn + SCTP_TSN_MAP_SIZE)) in sctp_tsnmap_skip()
215 if (TSN_lt(map->max_tsn_seen, tsn)) in sctp_tsnmap_skip()
216 map->max_tsn_seen = tsn; in sctp_tsnmap_skip()
218 gap = tsn - map->base_tsn + 1; in sctp_tsnmap_skip()
220 map->base_tsn += gap; in sctp_tsnmap_skip()
221 map->cumulative_tsn_ack_point += gap; in sctp_tsnmap_skip()
222 if (gap >= map->len) { in sctp_tsnmap_skip()
226 bitmap_zero(map->tsn_map, map->len); in sctp_tsnmap_skip()
231 bitmap_shift_right(map->tsn_map, map->tsn_map, gap, map->len); in sctp_tsnmap_skip()
232 sctp_tsnmap_update(map); in sctp_tsnmap_skip()
243 static void sctp_tsnmap_update(struct sctp_tsnmap *map) in sctp_tsnmap_update() argument
249 len = map->max_tsn_seen - map->cumulative_tsn_ack_point; in sctp_tsnmap_update()
250 zero_bit = find_first_zero_bit(map->tsn_map, len); in sctp_tsnmap_update()
254 map->base_tsn += zero_bit; in sctp_tsnmap_update()
255 map->cumulative_tsn_ack_point += zero_bit; in sctp_tsnmap_update()
257 bitmap_shift_right(map->tsn_map, map->tsn_map, zero_bit, map->len); in sctp_tsnmap_update()
262 __u16 sctp_tsnmap_pending(struct sctp_tsnmap *map) in sctp_tsnmap_pending() argument
264 __u32 cum_tsn = map->cumulative_tsn_ack_point; in sctp_tsnmap_pending()
265 __u32 max_tsn = map->max_tsn_seen; in sctp_tsnmap_pending()
266 __u32 base_tsn = map->base_tsn; in sctp_tsnmap_pending()
273 if (gap == 0 || gap >= map->len) in sctp_tsnmap_pending()
276 pending_data -= bitmap_weight(map->tsn_map, gap + 1); in sctp_tsnmap_pending()
287 static void sctp_tsnmap_find_gap_ack(unsigned long *map, __u16 off, in sctp_tsnmap_find_gap_ack() argument
299 i = find_next_bit(map, len, off); in sctp_tsnmap_find_gap_ack()
308 i = find_next_zero_bit(map, len, i); in sctp_tsnmap_find_gap_ack()
315 void sctp_tsnmap_renege(struct sctp_tsnmap *map, __u32 tsn) in sctp_tsnmap_renege() argument
319 if (TSN_lt(tsn, map->base_tsn)) in sctp_tsnmap_renege()
322 if (!TSN_lt(tsn, map->base_tsn + map->len)) in sctp_tsnmap_renege()
325 gap = tsn - map->base_tsn; in sctp_tsnmap_renege()
328 clear_bit(gap, map->tsn_map); in sctp_tsnmap_renege()
332 __u16 sctp_tsnmap_num_gabs(struct sctp_tsnmap *map, in sctp_tsnmap_num_gabs() argument
339 if (sctp_tsnmap_has_gap(map)) { in sctp_tsnmap_num_gabs()
341 sctp_tsnmap_iter_init(map, &iter); in sctp_tsnmap_num_gabs()
342 while (sctp_tsnmap_next_gap_ack(map, &iter, in sctp_tsnmap_num_gabs()
356 static int sctp_tsnmap_grow(struct sctp_tsnmap *map, u16 size) in sctp_tsnmap_grow() argument
365 inc = ALIGN((size - map->len), BITS_PER_LONG) + SCTP_TSN_MAP_INCREMENT; in sctp_tsnmap_grow()
366 len = min_t(u16, map->len + inc, SCTP_TSN_MAP_SIZE); in sctp_tsnmap_grow()
372 bitmap_copy(new, map->tsn_map, in sctp_tsnmap_grow()
373 map->max_tsn_seen - map->cumulative_tsn_ack_point); in sctp_tsnmap_grow()
374 kfree(map->tsn_map); in sctp_tsnmap_grow()
375 map->tsn_map = new; in sctp_tsnmap_grow()
376 map->len = len; in sctp_tsnmap_grow()