3 * Copyright (c) 2020 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <vppinfra/clib.h>
18 #include <vppinfra/vec.h>
19 #include <vppinfra/interrupt.h>
20 #include <vppinfra/format.h>
23 clib_interrupt_init (void **data, uword n_int)
25 clib_interrupt_header_t *h;
26 uword sz = sizeof (clib_interrupt_header_t);
27 uword data_size = round_pow2 (n_int, CLIB_CACHE_LINE_BYTES * 8) / 8;
30 h = data[0] = clib_mem_alloc_aligned (sz, CLIB_CACHE_LINE_BYTES);
31 clib_memset (data[0], 0, sz);
33 h->n_uword_alloc = (data_size * 8) >> log2_uword_bits;
37 clib_interrupt_resize (void **data, uword n_int)
39 clib_interrupt_header_t *h = data[0];
43 clib_interrupt_init (data, n_int);
49 uword *old_bmp, *old_abp, v;
50 old_bmp = clib_interrupt_get_bitmap (data[0]);
51 old_abp = clib_interrupt_get_atomic_bitmap (data[0]);
52 for (uword i = 0; i < h->n_uword_alloc; i++)
56 if (n_int > ((i + 1) * uword_bits))
58 else if (n_int > (i * uword_bits))
59 old_bmp[i] = (old_bmp[i] | v) & pow2_mask (n_int - i * uword_bits);
64 else if (n_int > h->n_uword_alloc * uword_bits)
67 uword *old_bmp, *old_abp, *new_bmp;
68 uword n_uwords = round_pow2 (h->n_int, uword_bits) / uword_bits;
70 clib_interrupt_init (data, n_int);
73 new_bmp = clib_interrupt_get_bitmap (data[0]);
74 old_bmp = clib_interrupt_get_bitmap (old);
75 old_abp = clib_interrupt_get_atomic_bitmap (old);
77 for (uword i = 0; i < n_uwords; i++)
78 new_bmp[i] = old_bmp[i] | old_abp[i];
86 * fd.io coding-style-patch-verification: ON
89 * eval: (c-set-style "gnu")