Lines Matching refs:item
26 __mlxsw_item_offset(const struct mlxsw_item *item, unsigned short index, in __mlxsw_item_offset() argument
29 BUG_ON(index && !item->step); in __mlxsw_item_offset()
30 if (item->offset % typesize != 0 || in __mlxsw_item_offset()
31 item->step % typesize != 0 || in __mlxsw_item_offset()
32 item->in_step_offset % typesize != 0) { in __mlxsw_item_offset()
34 item->name, item->offset, item->step, in __mlxsw_item_offset()
35 item->in_step_offset, typesize); in __mlxsw_item_offset()
39 return ((item->offset + item->step * index + item->in_step_offset) / in __mlxsw_item_offset()
44 const struct mlxsw_item *item, in __mlxsw_item_get8() argument
47 unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u8)); in __mlxsw_item_get8()
52 tmp >>= item->shift; in __mlxsw_item_get8()
53 tmp &= GENMASK(item->size.bits - 1, 0); in __mlxsw_item_get8()
54 if (item->no_real_shift) in __mlxsw_item_get8()
55 tmp <<= item->shift; in __mlxsw_item_get8()
59 static inline void __mlxsw_item_set8(char *buf, const struct mlxsw_item *item, in __mlxsw_item_set8() argument
62 unsigned int offset = __mlxsw_item_offset(item, index, in __mlxsw_item_set8()
65 u8 mask = GENMASK(item->size.bits - 1, 0) << item->shift; in __mlxsw_item_set8()
68 if (!item->no_real_shift) in __mlxsw_item_set8()
69 val <<= item->shift; in __mlxsw_item_set8()
78 const struct mlxsw_item *item, in __mlxsw_item_get16() argument
81 unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u16)); in __mlxsw_item_get16()
86 tmp >>= item->shift; in __mlxsw_item_get16()
87 tmp &= GENMASK(item->size.bits - 1, 0); in __mlxsw_item_get16()
88 if (item->no_real_shift) in __mlxsw_item_get16()
89 tmp <<= item->shift; in __mlxsw_item_get16()
93 static inline void __mlxsw_item_set16(char *buf, const struct mlxsw_item *item, in __mlxsw_item_set16() argument
96 unsigned int offset = __mlxsw_item_offset(item, index, in __mlxsw_item_set16()
99 u16 mask = GENMASK(item->size.bits - 1, 0) << item->shift; in __mlxsw_item_set16()
102 if (!item->no_real_shift) in __mlxsw_item_set16()
103 val <<= item->shift; in __mlxsw_item_set16()
112 const struct mlxsw_item *item, in __mlxsw_item_get32() argument
115 unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u32)); in __mlxsw_item_get32()
120 tmp >>= item->shift; in __mlxsw_item_get32()
121 tmp &= GENMASK(item->size.bits - 1, 0); in __mlxsw_item_get32()
122 if (item->no_real_shift) in __mlxsw_item_get32()
123 tmp <<= item->shift; in __mlxsw_item_get32()
127 static inline void __mlxsw_item_set32(char *buf, const struct mlxsw_item *item, in __mlxsw_item_set32() argument
130 unsigned int offset = __mlxsw_item_offset(item, index, in __mlxsw_item_set32()
133 u32 mask = GENMASK(item->size.bits - 1, 0) << item->shift; in __mlxsw_item_set32()
136 if (!item->no_real_shift) in __mlxsw_item_set32()
137 val <<= item->shift; in __mlxsw_item_set32()
146 const struct mlxsw_item *item, in __mlxsw_item_get64() argument
149 unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u64)); in __mlxsw_item_get64()
154 tmp >>= item->shift; in __mlxsw_item_get64()
155 tmp &= GENMASK_ULL(item->size.bits - 1, 0); in __mlxsw_item_get64()
156 if (item->no_real_shift) in __mlxsw_item_get64()
157 tmp <<= item->shift; in __mlxsw_item_get64()
161 static inline void __mlxsw_item_set64(char *buf, const struct mlxsw_item *item, in __mlxsw_item_set64() argument
164 unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u64)); in __mlxsw_item_set64()
166 u64 mask = GENMASK_ULL(item->size.bits - 1, 0) << item->shift; in __mlxsw_item_set64()
169 if (!item->no_real_shift) in __mlxsw_item_set64()
170 val <<= item->shift; in __mlxsw_item_set64()
179 const struct mlxsw_item *item, in __mlxsw_item_memcpy_from() argument
182 unsigned int offset = __mlxsw_item_offset(item, index, sizeof(char)); in __mlxsw_item_memcpy_from()
184 memcpy(dst, &buf[offset], item->size.bytes); in __mlxsw_item_memcpy_from()
188 const struct mlxsw_item *item, in __mlxsw_item_memcpy_to() argument
191 unsigned int offset = __mlxsw_item_offset(item, index, sizeof(char)); in __mlxsw_item_memcpy_to()
193 memcpy(&buf[offset], src, item->size.bytes); in __mlxsw_item_memcpy_to()
196 static inline char *__mlxsw_item_data(char *buf, const struct mlxsw_item *item, in __mlxsw_item_data() argument
199 unsigned int offset = __mlxsw_item_offset(item, index, sizeof(char)); in __mlxsw_item_data()
205 __mlxsw_item_bit_array_offset(const struct mlxsw_item *item, in __mlxsw_item_bit_array_offset() argument
212 BUG_ON(index && !item->element_size); in __mlxsw_item_bit_array_offset()
213 if (item->offset % sizeof(u32) != 0 || in __mlxsw_item_bit_array_offset()
214 BITS_PER_BYTE % item->element_size != 0) { in __mlxsw_item_bit_array_offset()
216 item->name, item->offset, item->element_size); in __mlxsw_item_bit_array_offset()
220 max_index = (item->size.bytes << 3) / item->element_size - 1; in __mlxsw_item_bit_array_offset()
222 offset = be_index * item->element_size >> 3; in __mlxsw_item_bit_array_offset()
223 in_byte_index = index % (BITS_PER_BYTE / item->element_size); in __mlxsw_item_bit_array_offset()
224 *shift = in_byte_index * item->element_size; in __mlxsw_item_bit_array_offset()
226 return item->offset + offset; in __mlxsw_item_bit_array_offset()
230 const struct mlxsw_item *item, in __mlxsw_item_bit_array_get() argument
234 u16 offset = __mlxsw_item_bit_array_offset(item, index, &shift); in __mlxsw_item_bit_array_get()
238 tmp &= GENMASK(item->element_size - 1, 0); in __mlxsw_item_bit_array_get()
243 const struct mlxsw_item *item, in __mlxsw_item_bit_array_set() argument
247 u16 offset = __mlxsw_item_bit_array_offset(item, index, &shift); in __mlxsw_item_bit_array_set()
248 u8 mask = GENMASK(item->element_size - 1, 0) << shift; in __mlxsw_item_bit_array_set()