Lines Matching refs:nbits

32  * Clear @nbits bits of a bitmap with indices @start <= i < @end
119 * @nbits: bit size of the bitmap
128 static void ethnl_bitmap32_update(u32 *dst, unsigned int nbits,
131 while (nbits > 0) {
135 if (nbits < 32)
136 real_mask &= ethnl_lower_bits(nbits);
143 if (nbits <= 32)
146 nbits -= 32;
162 * @nbits: bit length of the bitset
171 int ethnl_bitset32_size(const u32 *val, const u32 *mask, unsigned int nbits,
183 unsigned int nwords = DIV_ROUND_UP(nbits, 32);
191 for (i = 0; i < nbits; i++) {
222 * @nbits: bit length of the bitset
233 const u32 *mask, unsigned int nbits,
245 if (nla_put_u32(skb, ETHTOOL_A_BITSET_SIZE, nbits))
248 unsigned int nwords = DIV_ROUND_UP(nbits, 32);
257 if (nbits % 32)
258 dst[nwords - 1] &= ethnl_lower_bits(nbits);
266 if (nbits % 32)
267 dst[nwords - 1] &= ethnl_lower_bits(nbits);
276 for (i = 0; i < nbits; i++) {
377 static int ethnl_parse_bit(unsigned int *index, bool *val, unsigned int nbits,
394 if (idx >= nbits) {
409 idx = ethnl_name_to_idx(names, nbits,
429 ethnl_update_bitset32_verbose(u32 *bitmap, unsigned int nbits,
452 ethnl_bitmap32_clear(bitmap, 0, nbits, mod);
463 ret = ethnl_parse_bit(&idx, &new_val, nbits, bit_attr, no_mask,
480 static int ethnl_compact_sanity_checks(unsigned int nbits,
523 if (attr_nbits <= nbits)
528 if (ethnl_bitmap32_not_zero(nla_data(test_attr), nbits, attr_nbits)) {
539 * @nbits: size of the updated bitmap in bits
548 * @nbits but the message must not request modifying any bits past @nbits.
552 int ethnl_update_bitset32(u32 *bitmap, unsigned int nbits,
569 return ethnl_update_bitset32_verbose(bitmap, nbits, attr, tb,
571 ret = ethnl_compact_sanity_checks(nbits, attr, tb, extack);
577 nla_get_u32(tb[ETHTOOL_A_BITSET_SIZE]), nbits);
583 if (no_mask && change_bits < nbits)
584 ethnl_bitmap32_clear(bitmap, change_bits, nbits, mod);
593 * @nbits: size of @val and @mask bitmaps
598 * Provide @nbits size long bitmaps for value and mask so that
599 * x = (val & mask) | (x & ~mask) would modify any @nbits sized bitmap x
605 unsigned int nbits, const struct nlattr *attr,
626 ret = ethnl_compact_sanity_checks(nbits, attr, tb, extack);
631 if (change_bits > nbits)
632 change_bits = nbits;
635 if (change_bits < nbits)
636 bitmap_clear(val, change_bits, nbits - change_bits);
638 bitmap_fill(mask, nbits);
643 if (change_bits < nbits)
645 nbits - change_bits);
662 bitmap_zero(val, nbits);
664 bitmap_fill(mask, nbits);
666 bitmap_zero(mask, nbits);
672 ret = ethnl_parse_bit(&idx, &bit_val, nbits, bit_attr, no_mask,
700 unsigned int nbits, ethnl_string_array_t names,
709 if (nbits > ETHNL_SMALL_BITMAP_BITS) {
710 unsigned int nwords = DIV_ROUND_UP(nbits, 32);
721 bitmap_to_arr32(val32, val, nbits);
723 bitmap_to_arr32(mask32, mask, nbits);
726 ret = ethnl_bitset32_size(val32, mask32, nbits, names, compact);
728 if (nbits > ETHNL_SMALL_BITMAP_BITS)
736 unsigned int nbits, ethnl_string_array_t names,
745 if (nbits > ETHNL_SMALL_BITMAP_BITS) {
746 unsigned int nwords = DIV_ROUND_UP(nbits, 32);
757 bitmap_to_arr32(val32, val, nbits);
759 bitmap_to_arr32(mask32, mask, nbits);
762 ret = ethnl_put_bitset32(skb, attrtype, val32, mask32, nbits, names,
765 if (nbits > ETHNL_SMALL_BITMAP_BITS)
771 int ethnl_update_bitset(unsigned long *bitmap, unsigned int nbits,
780 if (nbits > ETHNL_SMALL_BITMAP_BITS) {
781 unsigned int dst_words = DIV_ROUND_UP(nbits, 32);
788 bitmap_to_arr32(bitmap32, bitmap, nbits);
789 ret = ethnl_update_bitset32(bitmap32, nbits, attr, names, extack,
792 bitmap_from_arr32(bitmap, bitmap32, nbits);
796 if (nbits > ETHNL_SMALL_BITMAP_BITS)
809 unsigned int nbits, ethnl_string_array_t names,
812 return ethnl_bitset32_size((const u32 *)val, (const u32 *)mask, nbits,
818 unsigned int nbits, ethnl_string_array_t names,
822 (const u32 *)mask, nbits, names, compact);
825 int ethnl_update_bitset(unsigned long *bitmap, unsigned int nbits,
829 return ethnl_update_bitset32((u32 *)bitmap, nbits, attr, names, extack,