Lines Matching refs:map

29 static void sctp_tsnmap_update(struct sctp_tsnmap *map);
30 static void sctp_tsnmap_find_gap_ack(unsigned long *map, __u16 off,
32 static int sctp_tsnmap_grow(struct sctp_tsnmap *map, u16 size);
35 struct sctp_tsnmap *sctp_tsnmap_init(struct sctp_tsnmap *map, __u16 len, in sctp_tsnmap_init() argument
38 if (!map->tsn_map) { in sctp_tsnmap_init()
39 map->tsn_map = kzalloc(len>>3, gfp); in sctp_tsnmap_init()
40 if (map->tsn_map == NULL) in sctp_tsnmap_init()
43 map->len = len; in sctp_tsnmap_init()
45 bitmap_zero(map->tsn_map, map->len); in sctp_tsnmap_init()
49 map->base_tsn = initial_tsn; in sctp_tsnmap_init()
50 map->cumulative_tsn_ack_point = initial_tsn - 1; in sctp_tsnmap_init()
51 map->max_tsn_seen = map->cumulative_tsn_ack_point; in sctp_tsnmap_init()
52 map->num_dup_tsns = 0; in sctp_tsnmap_init()
54 return map; in sctp_tsnmap_init()
57 void sctp_tsnmap_free(struct sctp_tsnmap *map) in sctp_tsnmap_free() argument
59 map->len = 0; in sctp_tsnmap_free()
60 kfree(map->tsn_map); in sctp_tsnmap_free()
69 int sctp_tsnmap_check(const struct sctp_tsnmap *map, __u32 tsn) in sctp_tsnmap_check() argument
74 if (TSN_lte(tsn, map->cumulative_tsn_ack_point)) in sctp_tsnmap_check()
80 if (!TSN_lt(tsn, map->base_tsn + SCTP_TSN_MAP_SIZE)) in sctp_tsnmap_check()
84 gap = tsn - map->base_tsn; in sctp_tsnmap_check()
87 if (gap < map->len && test_bit(gap, map->tsn_map)) in sctp_tsnmap_check()
95 int sctp_tsnmap_mark(struct sctp_tsnmap *map, __u32 tsn, in sctp_tsnmap_mark() argument
100 if (TSN_lt(tsn, map->base_tsn)) in sctp_tsnmap_mark()
103 gap = tsn - map->base_tsn; in sctp_tsnmap_mark()
105 if (gap >= map->len && !sctp_tsnmap_grow(map, gap + 1)) in sctp_tsnmap_mark()
108 if (!sctp_tsnmap_has_gap(map) && gap == 0) { in sctp_tsnmap_mark()
113 map->max_tsn_seen++; in sctp_tsnmap_mark()
114 map->cumulative_tsn_ack_point++; in sctp_tsnmap_mark()
118 map->base_tsn++; in sctp_tsnmap_mark()
125 if (TSN_lt(map->max_tsn_seen, tsn)) in sctp_tsnmap_mark()
126 map->max_tsn_seen = tsn; in sctp_tsnmap_mark()
129 set_bit(gap, map->tsn_map); in sctp_tsnmap_mark()
134 sctp_tsnmap_update(map); in sctp_tsnmap_mark()
142 static void sctp_tsnmap_iter_init(const struct sctp_tsnmap *map, in sctp_tsnmap_iter_init() argument
146 iter->start = map->cumulative_tsn_ack_point + 1; in sctp_tsnmap_iter_init()
152 static int sctp_tsnmap_next_gap_ack(const struct sctp_tsnmap *map, in sctp_tsnmap_next_gap_ack() argument
160 if (TSN_lte(map->max_tsn_seen, iter->start)) in sctp_tsnmap_next_gap_ack()
163 offset = iter->start - map->base_tsn; in sctp_tsnmap_next_gap_ack()
164 sctp_tsnmap_find_gap_ack(map->tsn_map, offset, map->len, in sctp_tsnmap_next_gap_ack()
169 end_ = map->len - 1; in sctp_tsnmap_next_gap_ack()
182 iter->start = map->cumulative_tsn_ack_point + *end + 1; in sctp_tsnmap_next_gap_ack()
190 void sctp_tsnmap_skip(struct sctp_tsnmap *map, __u32 tsn) in sctp_tsnmap_skip() argument
194 if (TSN_lt(tsn, map->base_tsn)) in sctp_tsnmap_skip()
196 if (!TSN_lt(tsn, map->base_tsn + SCTP_TSN_MAP_SIZE)) in sctp_tsnmap_skip()
200 if (TSN_lt(map->max_tsn_seen, tsn)) in sctp_tsnmap_skip()
201 map->max_tsn_seen = tsn; in sctp_tsnmap_skip()
203 gap = tsn - map->base_tsn + 1; in sctp_tsnmap_skip()
205 map->base_tsn += gap; in sctp_tsnmap_skip()
206 map->cumulative_tsn_ack_point += gap; in sctp_tsnmap_skip()
207 if (gap >= map->len) { in sctp_tsnmap_skip()
211 bitmap_zero(map->tsn_map, map->len); in sctp_tsnmap_skip()
216 bitmap_shift_right(map->tsn_map, map->tsn_map, gap, map->len); in sctp_tsnmap_skip()
217 sctp_tsnmap_update(map); in sctp_tsnmap_skip()
228 static void sctp_tsnmap_update(struct sctp_tsnmap *map) in sctp_tsnmap_update() argument
234 len = map->max_tsn_seen - map->cumulative_tsn_ack_point; in sctp_tsnmap_update()
235 zero_bit = find_first_zero_bit(map->tsn_map, len); in sctp_tsnmap_update()
239 map->base_tsn += zero_bit; in sctp_tsnmap_update()
240 map->cumulative_tsn_ack_point += zero_bit; in sctp_tsnmap_update()
242 bitmap_shift_right(map->tsn_map, map->tsn_map, zero_bit, map->len); in sctp_tsnmap_update()
247 __u16 sctp_tsnmap_pending(struct sctp_tsnmap *map) in sctp_tsnmap_pending() argument
249 __u32 cum_tsn = map->cumulative_tsn_ack_point; in sctp_tsnmap_pending()
250 __u32 max_tsn = map->max_tsn_seen; in sctp_tsnmap_pending()
251 __u32 base_tsn = map->base_tsn; in sctp_tsnmap_pending()
258 if (gap == 0 || gap >= map->len) in sctp_tsnmap_pending()
261 pending_data -= bitmap_weight(map->tsn_map, gap + 1); in sctp_tsnmap_pending()
272 static void sctp_tsnmap_find_gap_ack(unsigned long *map, __u16 off, in sctp_tsnmap_find_gap_ack() argument
284 i = find_next_bit(map, len, off); in sctp_tsnmap_find_gap_ack()
293 i = find_next_zero_bit(map, len, i); in sctp_tsnmap_find_gap_ack()
300 void sctp_tsnmap_renege(struct sctp_tsnmap *map, __u32 tsn) in sctp_tsnmap_renege() argument
304 if (TSN_lt(tsn, map->base_tsn)) in sctp_tsnmap_renege()
307 if (!TSN_lt(tsn, map->base_tsn + map->len)) in sctp_tsnmap_renege()
310 gap = tsn - map->base_tsn; in sctp_tsnmap_renege()
313 clear_bit(gap, map->tsn_map); in sctp_tsnmap_renege()
317 __u16 sctp_tsnmap_num_gabs(struct sctp_tsnmap *map, in sctp_tsnmap_num_gabs() argument
324 if (sctp_tsnmap_has_gap(map)) { in sctp_tsnmap_num_gabs()
326 sctp_tsnmap_iter_init(map, &iter); in sctp_tsnmap_num_gabs()
327 while (sctp_tsnmap_next_gap_ack(map, &iter, in sctp_tsnmap_num_gabs()
341 static int sctp_tsnmap_grow(struct sctp_tsnmap *map, u16 size) in sctp_tsnmap_grow() argument
350 inc = ALIGN((size - map->len), BITS_PER_LONG) + SCTP_TSN_MAP_INCREMENT; in sctp_tsnmap_grow()
351 len = min_t(u16, map->len + inc, SCTP_TSN_MAP_SIZE); in sctp_tsnmap_grow()
357 bitmap_copy(new, map->tsn_map, in sctp_tsnmap_grow()
358 map->max_tsn_seen - map->cumulative_tsn_ack_point); in sctp_tsnmap_grow()
359 kfree(map->tsn_map); in sctp_tsnmap_grow()
360 map->tsn_map = new; in sctp_tsnmap_grow()
361 map->len = len; in sctp_tsnmap_grow()