1 // SPDX-License-Identifier: GPL-2.0-only
3 #include <linux/ethtool_netlink.h>
4 #include <linux/bitmap.h>
8 /* Some bitmaps are internally represented as an array of unsigned long, some
9 * as an array of u32 (some even as single u32 for now). To avoid the need of
10 * wrappers on caller side, we provide two set of functions: those with "32"
11 * suffix in their names expect u32 based bitmaps, those without it expect
12 * unsigned long bitmaps.
15 static u32 ethnl_lower_bits(unsigned int n)
17 return ~(u32)0 >> (32 - n % 32);
20 static u32 ethnl_upper_bits(unsigned int n)
22 return ~(u32)0 << (n % 32);
26 * ethnl_bitmap32_clear() - Clear u32 based bitmap
27 * @dst: bitmap to clear
28 * @start: beginning of the interval
29 * @end: end of the interval
30 * @mod: set if bitmap was modified
32 * Clear @nbits bits of a bitmap with indices @start <= i < @end
34 static void ethnl_bitmap32_clear(u32 *dst, unsigned int start, unsigned int end,
37 unsigned int start_word = start / 32;
38 unsigned int end_word = end / 32;
46 mask = ethnl_upper_bits(start);
47 if (end_word == start_word) {
48 mask &= ethnl_lower_bits(end);
49 if (dst[start_word] & mask) {
50 dst[start_word] &= ~mask;
55 if (dst[start_word] & mask) {
56 dst[start_word] &= ~mask;
62 for (i = start_word; i < end_word; i++) {
69 mask = ethnl_lower_bits(end);
70 if (dst[end_word] & mask) {
71 dst[end_word] &= ~mask;
78 * ethnl_bitmap32_not_zero() - Check if any bit is set in an interval
79 * @map: bitmap to test
80 * @start: beginning of the interval
81 * @end: end of the interval
83 * Return: true if there is non-zero bit with index @start <= i < @end,
84 * false if the whole interval is zero
86 static bool ethnl_bitmap32_not_zero(const u32 *map, unsigned int start,
89 unsigned int start_word = start / 32;
90 unsigned int end_word = end / 32;
97 mask = ethnl_upper_bits(start);
98 if (end_word == start_word) {
99 mask &= ethnl_lower_bits(end);
100 return map[start_word] & mask;
102 if (map[start_word] & mask)
107 if (!memchr_inv(map + start_word, '\0',
108 (end_word - start_word) * sizeof(u32)))
112 return map[end_word] & ethnl_lower_bits(end);
116 * ethnl_bitmap32_update() - Modify u32 based bitmap according to value/mask
118 * @dst: bitmap to update
119 * @nbits: bit size of the bitmap
120 * @value: values to set
121 * @mask: mask of bits to set
122 * @mod: set to true if bitmap is modified, preserve if not
124 * Set bits in @dst bitmap which are set in @mask to values from @value, leave
125 * the rest untouched. If destination bitmap was modified, set @mod to true,
126 * leave as it is if not.
128 static void ethnl_bitmap32_update(u32 *dst, unsigned int nbits,
129 const u32 *value, const u32 *mask, bool *mod)
132 u32 real_mask = mask ? *mask : ~(u32)0;
136 real_mask &= ethnl_lower_bits(nbits);
137 new_value = (*dst & ~real_mask) | (*value & real_mask);
138 if (new_value != *dst) {
153 static bool ethnl_bitmap32_test_bit(const u32 *map, unsigned int index)
155 return map[index / 32] & (1U << (index % 32));
159 * ethnl_bitset32_size() - Calculate size of bitset nested attribute
160 * @val: value bitmap (u32 based)
161 * @mask: mask bitmap (u32 based, optional)
162 * @nbits: bit length of the bitset
163 * @names: array of bit names (optional)
164 * @compact: assume compact format for output
166 * Estimate length of netlink attribute composed by a later call to
167 * ethnl_put_bitset32() call with the same arguments.
169 * Return: negative error code or attribute length estimate
171 int ethnl_bitset32_size(const u32 *val, const u32 *mask, unsigned int nbits,
172 ethnl_string_array_t names, bool compact)
174 unsigned int len = 0;
178 len += nla_total_size(sizeof(u32));
180 len += nla_total_size(sizeof(u32));
183 unsigned int nwords = DIV_ROUND_UP(nbits, 32);
186 len += (mask ? 2 : 1) * nla_total_size(nwords * sizeof(u32));
188 unsigned int bits_len = 0;
189 unsigned int bit_len, i;
191 for (i = 0; i < nbits; i++) {
192 const char *name = names ? names[i] : NULL;
194 if (!ethnl_bitmap32_test_bit(mask ?: val, i))
197 bit_len = nla_total_size(sizeof(u32));
200 bit_len += ethnl_strz_size(name);
202 if (mask && ethnl_bitmap32_test_bit(val, i))
203 bit_len += nla_total_size(0);
206 bits_len += nla_total_size(bit_len);
209 len += nla_total_size(bits_len);
213 return nla_total_size(len);
217 * ethnl_put_bitset32() - Put a bitset nest into a message
218 * @skb: skb with the message
219 * @attrtype: attribute type for the bitset nest
220 * @val: value bitmap (u32 based)
221 * @mask: mask bitmap (u32 based, optional)
222 * @nbits: bit length of the bitset
223 * @names: array of bit names (optional)
224 * @compact: use compact format for the output
226 * Compose a nested attribute representing a bitset. If @mask is null, simple
227 * bitmap (bit list) is created, if @mask is provided, represent a value/mask
228 * pair. Bit names are only used in verbose mode and when provided by calller.
230 * Return: 0 on success, negative error value on error
232 int ethnl_put_bitset32(struct sk_buff *skb, int attrtype, const u32 *val,
233 const u32 *mask, unsigned int nbits,
234 ethnl_string_array_t names, bool compact)
239 nest = nla_nest_start(skb, attrtype);
243 if (!mask && nla_put_flag(skb, ETHTOOL_A_BITSET_NOMASK))
244 goto nla_put_failure;
245 if (nla_put_u32(skb, ETHTOOL_A_BITSET_SIZE, nbits))
246 goto nla_put_failure;
248 unsigned int nwords = DIV_ROUND_UP(nbits, 32);
249 unsigned int nbytes = nwords * sizeof(u32);
252 attr = nla_reserve(skb, ETHTOOL_A_BITSET_VALUE, nbytes);
254 goto nla_put_failure;
255 dst = nla_data(attr);
256 memcpy(dst, val, nbytes);
258 dst[nwords - 1] &= ethnl_lower_bits(nbits);
261 attr = nla_reserve(skb, ETHTOOL_A_BITSET_MASK, nbytes);
263 goto nla_put_failure;
264 dst = nla_data(attr);
265 memcpy(dst, mask, nbytes);
267 dst[nwords - 1] &= ethnl_lower_bits(nbits);
273 bits = nla_nest_start(skb, ETHTOOL_A_BITSET_BITS);
275 goto nla_put_failure;
276 for (i = 0; i < nbits; i++) {
277 const char *name = names ? names[i] : NULL;
279 if (!ethnl_bitmap32_test_bit(mask ?: val, i))
281 attr = nla_nest_start(skb, ETHTOOL_A_BITSET_BITS_BIT);
283 goto nla_put_failure;
284 if (nla_put_u32(skb, ETHTOOL_A_BITSET_BIT_INDEX, i))
285 goto nla_put_failure;
287 ethnl_put_strz(skb, ETHTOOL_A_BITSET_BIT_NAME, name))
288 goto nla_put_failure;
289 if (mask && ethnl_bitmap32_test_bit(val, i) &&
290 nla_put_flag(skb, ETHTOOL_A_BITSET_BIT_VALUE))
291 goto nla_put_failure;
292 nla_nest_end(skb, attr);
294 nla_nest_end(skb, bits);
297 nla_nest_end(skb, nest);
301 nla_nest_cancel(skb, nest);
305 static const struct nla_policy bitset_policy[] = {
306 [ETHTOOL_A_BITSET_NOMASK] = { .type = NLA_FLAG },
307 [ETHTOOL_A_BITSET_SIZE] = NLA_POLICY_MAX(NLA_U32,
308 ETHNL_MAX_BITSET_SIZE),
309 [ETHTOOL_A_BITSET_BITS] = { .type = NLA_NESTED },
310 [ETHTOOL_A_BITSET_VALUE] = { .type = NLA_BINARY },
311 [ETHTOOL_A_BITSET_MASK] = { .type = NLA_BINARY },
314 static const struct nla_policy bit_policy[] = {
315 [ETHTOOL_A_BITSET_BIT_INDEX] = { .type = NLA_U32 },
316 [ETHTOOL_A_BITSET_BIT_NAME] = { .type = NLA_NUL_STRING },
317 [ETHTOOL_A_BITSET_BIT_VALUE] = { .type = NLA_FLAG },
321 * ethnl_bitset_is_compact() - check if bitset attribute represents a compact
323 * @bitset: nested attribute representing a bitset
324 * @compact: pointer for return value
326 * Return: 0 on success, negative error code on failure
328 int ethnl_bitset_is_compact(const struct nlattr *bitset, bool *compact)
330 struct nlattr *tb[ARRAY_SIZE(bitset_policy)];
333 ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, bitset,
334 bitset_policy, NULL);
338 if (tb[ETHTOOL_A_BITSET_BITS]) {
339 if (tb[ETHTOOL_A_BITSET_VALUE] || tb[ETHTOOL_A_BITSET_MASK])
344 if (!tb[ETHTOOL_A_BITSET_SIZE] || !tb[ETHTOOL_A_BITSET_VALUE])
352 * ethnl_name_to_idx() - look up string index for a name
353 * @names: array of ETH_GSTRING_LEN sized strings
354 * @n_names: number of strings in the array
355 * @name: name to look up
357 * Return: index of the string if found, -ENOENT if not found
359 static int ethnl_name_to_idx(ethnl_string_array_t names, unsigned int n_names,
367 for (i = 0; i < n_names; i++) {
368 /* names[i] may not be null terminated */
369 if (!strncmp(names[i], name, ETH_GSTRING_LEN) &&
370 strlen(name) <= ETH_GSTRING_LEN)
377 static int ethnl_parse_bit(unsigned int *index, bool *val, unsigned int nbits,
378 const struct nlattr *bit_attr, bool no_mask,
379 ethnl_string_array_t names,
380 struct netlink_ext_ack *extack)
382 struct nlattr *tb[ARRAY_SIZE(bit_policy)];
385 ret = nla_parse_nested(tb, ARRAY_SIZE(bit_policy) - 1, bit_attr,
390 if (tb[ETHTOOL_A_BITSET_BIT_INDEX]) {
393 idx = nla_get_u32(tb[ETHTOOL_A_BITSET_BIT_INDEX]);
395 NL_SET_ERR_MSG_ATTR(extack,
396 tb[ETHTOOL_A_BITSET_BIT_INDEX],
397 "bit index too high");
400 name = names ? names[idx] : NULL;
401 if (tb[ETHTOOL_A_BITSET_BIT_NAME] && name &&
402 strncmp(nla_data(tb[ETHTOOL_A_BITSET_BIT_NAME]), name,
403 nla_len(tb[ETHTOOL_A_BITSET_BIT_NAME]))) {
404 NL_SET_ERR_MSG_ATTR(extack, bit_attr,
405 "bit index and name mismatch");
408 } else if (tb[ETHTOOL_A_BITSET_BIT_NAME]) {
409 idx = ethnl_name_to_idx(names, nbits,
410 nla_data(tb[ETHTOOL_A_BITSET_BIT_NAME]));
412 NL_SET_ERR_MSG_ATTR(extack,
413 tb[ETHTOOL_A_BITSET_BIT_NAME],
414 "bit name not found");
418 NL_SET_ERR_MSG_ATTR(extack, bit_attr,
419 "neither bit index nor name specified");
424 *val = no_mask || tb[ETHTOOL_A_BITSET_BIT_VALUE];
429 ethnl_update_bitset32_verbose(u32 *bitmap, unsigned int nbits,
430 const struct nlattr *attr, struct nlattr **tb,
431 ethnl_string_array_t names,
432 struct netlink_ext_ack *extack, bool *mod)
434 u32 *orig_bitmap, *saved_bitmap = NULL;
435 struct nlattr *bit_attr;
441 if (tb[ETHTOOL_A_BITSET_VALUE]) {
442 NL_SET_ERR_MSG_ATTR(extack, tb[ETHTOOL_A_BITSET_VALUE],
443 "value only allowed in compact bitset");
446 if (tb[ETHTOOL_A_BITSET_MASK]) {
447 NL_SET_ERR_MSG_ATTR(extack, tb[ETHTOOL_A_BITSET_MASK],
448 "mask only allowed in compact bitset");
452 no_mask = tb[ETHTOOL_A_BITSET_NOMASK];
454 unsigned int nwords = DIV_ROUND_UP(nbits, 32);
455 unsigned int nbytes = nwords * sizeof(u32);
457 /* The bitmap size is only the size of the map part without
460 saved_bitmap = kcalloc(nwords, sizeof(u32), GFP_KERNEL);
463 memcpy(saved_bitmap, bitmap, nbytes);
464 ethnl_bitmap32_clear(bitmap, 0, nbits, &dummy);
465 orig_bitmap = saved_bitmap;
467 orig_bitmap = bitmap;
470 nla_for_each_nested(bit_attr, tb[ETHTOOL_A_BITSET_BITS], rem) {
471 bool old_val, new_val;
474 if (nla_type(bit_attr) != ETHTOOL_A_BITSET_BITS_BIT) {
475 NL_SET_ERR_MSG_ATTR(extack, bit_attr,
476 "only ETHTOOL_A_BITSET_BITS_BIT allowed in ETHTOOL_A_BITSET_BITS");
480 ret = ethnl_parse_bit(&idx, &new_val, nbits, bit_attr, no_mask,
484 old_val = orig_bitmap[idx / 32] & ((u32)1 << (idx % 32));
485 if (new_val != old_val) {
487 bitmap[idx / 32] |= ((u32)1 << (idx % 32));
489 bitmap[idx / 32] &= ~((u32)1 << (idx % 32));
500 static int ethnl_compact_sanity_checks(unsigned int nbits,
501 const struct nlattr *nest,
503 struct netlink_ext_ack *extack)
505 bool no_mask = tb[ETHTOOL_A_BITSET_NOMASK];
506 unsigned int attr_nbits, attr_nwords;
507 const struct nlattr *test_attr;
509 if (no_mask && tb[ETHTOOL_A_BITSET_MASK]) {
510 NL_SET_ERR_MSG_ATTR(extack, tb[ETHTOOL_A_BITSET_MASK],
511 "mask not allowed in list bitset");
514 if (!tb[ETHTOOL_A_BITSET_SIZE]) {
515 NL_SET_ERR_MSG_ATTR(extack, nest,
516 "missing size in compact bitset");
519 if (!tb[ETHTOOL_A_BITSET_VALUE]) {
520 NL_SET_ERR_MSG_ATTR(extack, nest,
521 "missing value in compact bitset");
524 if (!no_mask && !tb[ETHTOOL_A_BITSET_MASK]) {
525 NL_SET_ERR_MSG_ATTR(extack, nest,
526 "missing mask in compact nonlist bitset");
530 attr_nbits = nla_get_u32(tb[ETHTOOL_A_BITSET_SIZE]);
531 attr_nwords = DIV_ROUND_UP(attr_nbits, 32);
532 if (nla_len(tb[ETHTOOL_A_BITSET_VALUE]) != attr_nwords * sizeof(u32)) {
533 NL_SET_ERR_MSG_ATTR(extack, tb[ETHTOOL_A_BITSET_VALUE],
534 "bitset value length does not match size");
537 if (tb[ETHTOOL_A_BITSET_MASK] &&
538 nla_len(tb[ETHTOOL_A_BITSET_MASK]) != attr_nwords * sizeof(u32)) {
539 NL_SET_ERR_MSG_ATTR(extack, tb[ETHTOOL_A_BITSET_MASK],
540 "bitset mask length does not match size");
543 if (attr_nbits <= nbits)
546 test_attr = no_mask ? tb[ETHTOOL_A_BITSET_VALUE] :
547 tb[ETHTOOL_A_BITSET_MASK];
548 if (ethnl_bitmap32_not_zero(nla_data(test_attr), nbits, attr_nbits)) {
549 NL_SET_ERR_MSG_ATTR(extack, test_attr,
550 "cannot modify bits past kernel bitset size");
557 * ethnl_update_bitset32() - Apply a bitset nest to a u32 based bitmap
558 * @bitmap: bitmap to update
559 * @nbits: size of the updated bitmap in bits
560 * @attr: nest attribute to parse and apply
561 * @names: array of bit names; may be null for compact format
562 * @extack: extack for error reporting
563 * @mod: set this to true if bitmap is modified, leave as it is if not
565 * Apply bitset netsted attribute to a bitmap. If the attribute represents
566 * a bit list, @bitmap is set to its contents; otherwise, bits in mask are
567 * set to values from value. Bitmaps in the attribute may be longer than
568 * @nbits but the message must not request modifying any bits past @nbits.
570 * Return: negative error code on failure, 0 on success
572 int ethnl_update_bitset32(u32 *bitmap, unsigned int nbits,
573 const struct nlattr *attr, ethnl_string_array_t names,
574 struct netlink_ext_ack *extack, bool *mod)
576 struct nlattr *tb[ARRAY_SIZE(bitset_policy)];
577 unsigned int change_bits;
583 ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, attr,
584 bitset_policy, extack);
588 if (tb[ETHTOOL_A_BITSET_BITS])
589 return ethnl_update_bitset32_verbose(bitmap, nbits, attr, tb,
591 ret = ethnl_compact_sanity_checks(nbits, attr, tb, extack);
595 no_mask = tb[ETHTOOL_A_BITSET_NOMASK];
596 change_bits = min_t(unsigned int,
597 nla_get_u32(tb[ETHTOOL_A_BITSET_SIZE]), nbits);
598 ethnl_bitmap32_update(bitmap, change_bits,
599 nla_data(tb[ETHTOOL_A_BITSET_VALUE]),
601 nla_data(tb[ETHTOOL_A_BITSET_MASK]),
603 if (no_mask && change_bits < nbits)
604 ethnl_bitmap32_clear(bitmap, change_bits, nbits, mod);
610 * ethnl_parse_bitset() - Compute effective value and mask from bitset nest
611 * @val: unsigned long based bitmap to put value into
612 * @mask: unsigned long based bitmap to put mask into
613 * @nbits: size of @val and @mask bitmaps
614 * @attr: nest attribute to parse and apply
615 * @names: array of bit names; may be null for compact format
616 * @extack: extack for error reporting
618 * Provide @nbits size long bitmaps for value and mask so that
619 * x = (val & mask) | (x & ~mask) would modify any @nbits sized bitmap x
620 * the same way ethnl_update_bitset() with the same bitset attribute would.
622 * Return: negative error code on failure, 0 on success
624 int ethnl_parse_bitset(unsigned long *val, unsigned long *mask,
625 unsigned int nbits, const struct nlattr *attr,
626 ethnl_string_array_t names,
627 struct netlink_ext_ack *extack)
629 struct nlattr *tb[ARRAY_SIZE(bitset_policy)];
630 const struct nlattr *bit_attr;
637 ret = nla_parse_nested(tb, ARRAY_SIZE(bitset_policy) - 1, attr,
638 bitset_policy, extack);
641 no_mask = tb[ETHTOOL_A_BITSET_NOMASK];
643 if (!tb[ETHTOOL_A_BITSET_BITS]) {
644 unsigned int change_bits;
646 ret = ethnl_compact_sanity_checks(nbits, attr, tb, extack);
650 change_bits = nla_get_u32(tb[ETHTOOL_A_BITSET_SIZE]);
651 if (change_bits > nbits)
653 bitmap_from_arr32(val, nla_data(tb[ETHTOOL_A_BITSET_VALUE]),
655 if (change_bits < nbits)
656 bitmap_clear(val, change_bits, nbits - change_bits);
658 bitmap_fill(mask, nbits);
660 bitmap_from_arr32(mask,
661 nla_data(tb[ETHTOOL_A_BITSET_MASK]),
663 if (change_bits < nbits)
664 bitmap_clear(mask, change_bits,
665 nbits - change_bits);
671 if (tb[ETHTOOL_A_BITSET_VALUE]) {
672 NL_SET_ERR_MSG_ATTR(extack, tb[ETHTOOL_A_BITSET_VALUE],
673 "value only allowed in compact bitset");
676 if (tb[ETHTOOL_A_BITSET_MASK]) {
677 NL_SET_ERR_MSG_ATTR(extack, tb[ETHTOOL_A_BITSET_MASK],
678 "mask only allowed in compact bitset");
682 bitmap_zero(val, nbits);
684 bitmap_fill(mask, nbits);
686 bitmap_zero(mask, nbits);
688 nla_for_each_nested(bit_attr, tb[ETHTOOL_A_BITSET_BITS], rem) {
692 ret = ethnl_parse_bit(&idx, &bit_val, nbits, bit_attr, no_mask,
699 __set_bit(idx, mask);
705 #if BITS_PER_LONG == 64 && defined(__BIG_ENDIAN)
707 /* 64-bit big endian architectures are the only case when u32 based bitmaps
708 * and unsigned long based bitmaps have different memory layout so that we
709 * cannot simply cast the latter to the former and need actual wrappers
710 * converting the latter to the former.
712 * To reduce the number of slab allocations, the wrappers use fixed size local
713 * variables for bitmaps up to ETHNL_SMALL_BITMAP_BITS bits which is the
714 * majority of bitmaps used by ethtool.
716 #define ETHNL_SMALL_BITMAP_BITS 128
717 #define ETHNL_SMALL_BITMAP_WORDS DIV_ROUND_UP(ETHNL_SMALL_BITMAP_BITS, 32)
719 int ethnl_bitset_size(const unsigned long *val, const unsigned long *mask,
720 unsigned int nbits, ethnl_string_array_t names,
723 u32 small_mask32[ETHNL_SMALL_BITMAP_WORDS];
724 u32 small_val32[ETHNL_SMALL_BITMAP_WORDS];
729 if (nbits > ETHNL_SMALL_BITMAP_BITS) {
730 unsigned int nwords = DIV_ROUND_UP(nbits, 32);
732 val32 = kmalloc_array(2 * nwords, sizeof(u32), GFP_KERNEL);
735 mask32 = val32 + nwords;
738 mask32 = small_mask32;
741 bitmap_to_arr32(val32, val, nbits);
743 bitmap_to_arr32(mask32, mask, nbits);
746 ret = ethnl_bitset32_size(val32, mask32, nbits, names, compact);
748 if (nbits > ETHNL_SMALL_BITMAP_BITS)
754 int ethnl_put_bitset(struct sk_buff *skb, int attrtype,
755 const unsigned long *val, const unsigned long *mask,
756 unsigned int nbits, ethnl_string_array_t names,
759 u32 small_mask32[ETHNL_SMALL_BITMAP_WORDS];
760 u32 small_val32[ETHNL_SMALL_BITMAP_WORDS];
765 if (nbits > ETHNL_SMALL_BITMAP_BITS) {
766 unsigned int nwords = DIV_ROUND_UP(nbits, 32);
768 val32 = kmalloc_array(2 * nwords, sizeof(u32), GFP_KERNEL);
771 mask32 = val32 + nwords;
774 mask32 = small_mask32;
777 bitmap_to_arr32(val32, val, nbits);
779 bitmap_to_arr32(mask32, mask, nbits);
782 ret = ethnl_put_bitset32(skb, attrtype, val32, mask32, nbits, names,
785 if (nbits > ETHNL_SMALL_BITMAP_BITS)
791 int ethnl_update_bitset(unsigned long *bitmap, unsigned int nbits,
792 const struct nlattr *attr, ethnl_string_array_t names,
793 struct netlink_ext_ack *extack, bool *mod)
795 u32 small_bitmap32[ETHNL_SMALL_BITMAP_WORDS];
796 u32 *bitmap32 = small_bitmap32;
797 bool u32_mod = false;
800 if (nbits > ETHNL_SMALL_BITMAP_BITS) {
801 unsigned int dst_words = DIV_ROUND_UP(nbits, 32);
803 bitmap32 = kmalloc_array(dst_words, sizeof(u32), GFP_KERNEL);
808 bitmap_to_arr32(bitmap32, bitmap, nbits);
809 ret = ethnl_update_bitset32(bitmap32, nbits, attr, names, extack,
812 bitmap_from_arr32(bitmap, bitmap32, nbits);
816 if (nbits > ETHNL_SMALL_BITMAP_BITS)
824 /* On little endian 64-bit and all 32-bit architectures, an unsigned long
825 * based bitmap can be interpreted as u32 based one using a simple cast.
828 int ethnl_bitset_size(const unsigned long *val, const unsigned long *mask,
829 unsigned int nbits, ethnl_string_array_t names,
832 return ethnl_bitset32_size((const u32 *)val, (const u32 *)mask, nbits,
836 int ethnl_put_bitset(struct sk_buff *skb, int attrtype,
837 const unsigned long *val, const unsigned long *mask,
838 unsigned int nbits, ethnl_string_array_t names,
841 return ethnl_put_bitset32(skb, attrtype, (const u32 *)val,
842 (const u32 *)mask, nbits, names, compact);
845 int ethnl_update_bitset(unsigned long *bitmap, unsigned int nbits,
846 const struct nlattr *attr, ethnl_string_array_t names,
847 struct netlink_ext_ack *extack, bool *mod)
849 return ethnl_update_bitset32((u32 *)bitmap, nbits, attr, names, extack,
853 #endif /* BITS_PER_LONG == 64 && defined(__BIG_ENDIAN) */