item.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
  2. /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */
  3. #ifndef _MLXSW_ITEM_H
  4. #define _MLXSW_ITEM_H
  5. #include <linux/types.h>
  6. #include <linux/string.h>
  7. #include <linux/bitops.h>
  8. struct mlxsw_item {
  9. unsigned short offset; /* bytes in container */
  10. short step; /* step in bytes for indexed items */
  11. unsigned short in_step_offset; /* offset within one step */
  12. unsigned char shift; /* shift in bits */
  13. unsigned char element_size; /* size of element in bit array */
  14. bool no_real_shift;
  15. union {
  16. unsigned char bits;
  17. unsigned short bytes;
  18. } size;
  19. const char *name;
  20. };
  21. static inline unsigned int
  22. __mlxsw_item_offset(const struct mlxsw_item *item, unsigned short index,
  23. size_t typesize)
  24. {
  25. BUG_ON(index && !item->step);
  26. if (item->offset % typesize != 0 ||
  27. item->step % typesize != 0 ||
  28. item->in_step_offset % typesize != 0) {
  29. pr_err("mlxsw: item bug (name=%s,offset=%x,step=%x,in_step_offset=%x,typesize=%zx)\n",
  30. item->name, item->offset, item->step,
  31. item->in_step_offset, typesize);
  32. BUG();
  33. }
  34. return ((item->offset + item->step * index + item->in_step_offset) /
  35. typesize);
  36. }
  37. static inline u8 __mlxsw_item_get8(const char *buf,
  38. const struct mlxsw_item *item,
  39. unsigned short index)
  40. {
  41. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u8));
  42. u8 *b = (u8 *) buf;
  43. u8 tmp;
  44. tmp = b[offset];
  45. tmp >>= item->shift;
  46. tmp &= GENMASK(item->size.bits - 1, 0);
  47. if (item->no_real_shift)
  48. tmp <<= item->shift;
  49. return tmp;
  50. }
  51. static inline void __mlxsw_item_set8(char *buf, const struct mlxsw_item *item,
  52. unsigned short index, u8 val)
  53. {
  54. unsigned int offset = __mlxsw_item_offset(item, index,
  55. sizeof(u8));
  56. u8 *b = (u8 *) buf;
  57. u8 mask = GENMASK(item->size.bits - 1, 0) << item->shift;
  58. u8 tmp;
  59. if (!item->no_real_shift)
  60. val <<= item->shift;
  61. val &= mask;
  62. tmp = b[offset];
  63. tmp &= ~mask;
  64. tmp |= val;
  65. b[offset] = tmp;
  66. }
  67. static inline u16 __mlxsw_item_get16(const char *buf,
  68. const struct mlxsw_item *item,
  69. unsigned short index)
  70. {
  71. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u16));
  72. __be16 *b = (__be16 *) buf;
  73. u16 tmp;
  74. tmp = be16_to_cpu(b[offset]);
  75. tmp >>= item->shift;
  76. tmp &= GENMASK(item->size.bits - 1, 0);
  77. if (item->no_real_shift)
  78. tmp <<= item->shift;
  79. return tmp;
  80. }
  81. static inline void __mlxsw_item_set16(char *buf, const struct mlxsw_item *item,
  82. unsigned short index, u16 val)
  83. {
  84. unsigned int offset = __mlxsw_item_offset(item, index,
  85. sizeof(u16));
  86. __be16 *b = (__be16 *) buf;
  87. u16 mask = GENMASK(item->size.bits - 1, 0) << item->shift;
  88. u16 tmp;
  89. if (!item->no_real_shift)
  90. val <<= item->shift;
  91. val &= mask;
  92. tmp = be16_to_cpu(b[offset]);
  93. tmp &= ~mask;
  94. tmp |= val;
  95. b[offset] = cpu_to_be16(tmp);
  96. }
  97. static inline u32 __mlxsw_item_get32(const char *buf,
  98. const struct mlxsw_item *item,
  99. unsigned short index)
  100. {
  101. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u32));
  102. __be32 *b = (__be32 *) buf;
  103. u32 tmp;
  104. tmp = be32_to_cpu(b[offset]);
  105. tmp >>= item->shift;
  106. tmp &= GENMASK(item->size.bits - 1, 0);
  107. if (item->no_real_shift)
  108. tmp <<= item->shift;
  109. return tmp;
  110. }
  111. static inline void __mlxsw_item_set32(char *buf, const struct mlxsw_item *item,
  112. unsigned short index, u32 val)
  113. {
  114. unsigned int offset = __mlxsw_item_offset(item, index,
  115. sizeof(u32));
  116. __be32 *b = (__be32 *) buf;
  117. u32 mask = GENMASK(item->size.bits - 1, 0) << item->shift;
  118. u32 tmp;
  119. if (!item->no_real_shift)
  120. val <<= item->shift;
  121. val &= mask;
  122. tmp = be32_to_cpu(b[offset]);
  123. tmp &= ~mask;
  124. tmp |= val;
  125. b[offset] = cpu_to_be32(tmp);
  126. }
  127. static inline u64 __mlxsw_item_get64(const char *buf,
  128. const struct mlxsw_item *item,
  129. unsigned short index)
  130. {
  131. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u64));
  132. __be64 *b = (__be64 *) buf;
  133. u64 tmp;
  134. tmp = be64_to_cpu(b[offset]);
  135. tmp >>= item->shift;
  136. tmp &= GENMASK_ULL(item->size.bits - 1, 0);
  137. if (item->no_real_shift)
  138. tmp <<= item->shift;
  139. return tmp;
  140. }
  141. static inline void __mlxsw_item_set64(char *buf, const struct mlxsw_item *item,
  142. unsigned short index, u64 val)
  143. {
  144. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u64));
  145. __be64 *b = (__be64 *) buf;
  146. u64 mask = GENMASK_ULL(item->size.bits - 1, 0) << item->shift;
  147. u64 tmp;
  148. if (!item->no_real_shift)
  149. val <<= item->shift;
  150. val &= mask;
  151. tmp = be64_to_cpu(b[offset]);
  152. tmp &= ~mask;
  153. tmp |= val;
  154. b[offset] = cpu_to_be64(tmp);
  155. }
  156. static inline void __mlxsw_item_memcpy_from(const char *buf, char *dst,
  157. const struct mlxsw_item *item,
  158. unsigned short index)
  159. {
  160. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(char));
  161. memcpy(dst, &buf[offset], item->size.bytes);
  162. }
  163. static inline void __mlxsw_item_memcpy_to(char *buf, const char *src,
  164. const struct mlxsw_item *item,
  165. unsigned short index)
  166. {
  167. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(char));
  168. memcpy(&buf[offset], src, item->size.bytes);
  169. }
  170. static inline char *__mlxsw_item_data(char *buf, const struct mlxsw_item *item,
  171. unsigned short index)
  172. {
  173. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(char));
  174. return &buf[offset];
  175. }
  176. static inline u16
  177. __mlxsw_item_bit_array_offset(const struct mlxsw_item *item,
  178. u16 index, u8 *shift)
  179. {
  180. u16 max_index, be_index;
  181. u16 offset; /* byte offset inside the array */
  182. u8 in_byte_index;
  183. BUG_ON(index && !item->element_size);
  184. if (item->offset % sizeof(u32) != 0 ||
  185. BITS_PER_BYTE % item->element_size != 0) {
  186. pr_err("mlxsw: item bug (name=%s,offset=%x,element_size=%x)\n",
  187. item->name, item->offset, item->element_size);
  188. BUG();
  189. }
  190. max_index = (item->size.bytes << 3) / item->element_size - 1;
  191. be_index = max_index - index;
  192. offset = be_index * item->element_size >> 3;
  193. in_byte_index = index % (BITS_PER_BYTE / item->element_size);
  194. *shift = in_byte_index * item->element_size;
  195. return item->offset + offset;
  196. }
  197. static inline u8 __mlxsw_item_bit_array_get(const char *buf,
  198. const struct mlxsw_item *item,
  199. u16 index)
  200. {
  201. u8 shift, tmp;
  202. u16 offset = __mlxsw_item_bit_array_offset(item, index, &shift);
  203. tmp = buf[offset];
  204. tmp >>= shift;
  205. tmp &= GENMASK(item->element_size - 1, 0);
  206. return tmp;
  207. }
  208. static inline void __mlxsw_item_bit_array_set(char *buf,
  209. const struct mlxsw_item *item,
  210. u16 index, u8 val)
  211. {
  212. u8 shift, tmp;
  213. u16 offset = __mlxsw_item_bit_array_offset(item, index, &shift);
  214. u8 mask = GENMASK(item->element_size - 1, 0) << shift;
  215. val <<= shift;
  216. val &= mask;
  217. tmp = buf[offset];
  218. tmp &= ~mask;
  219. tmp |= val;
  220. buf[offset] = tmp;
  221. }
  222. #define __ITEM_NAME(_type, _cname, _iname) \
  223. mlxsw_##_type##_##_cname##_##_iname##_item
  224. /* _type: cmd_mbox, reg, etc.
  225. * _cname: containter name (e.g. command name, register name)
  226. * _iname: item name within the container
  227. */
  228. #define MLXSW_ITEM8(_type, _cname, _iname, _offset, _shift, _sizebits) \
  229. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  230. .offset = _offset, \
  231. .shift = _shift, \
  232. .size = {.bits = _sizebits,}, \
  233. .name = #_type "_" #_cname "_" #_iname, \
  234. }; \
  235. static inline u8 __maybe_unused \
  236. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
  237. { \
  238. return __mlxsw_item_get8(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
  239. } \
  240. static inline void __maybe_unused \
  241. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u8 val) \
  242. { \
  243. __mlxsw_item_set8(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
  244. }
  245. #define MLXSW_ITEM8_INDEXED(_type, _cname, _iname, _offset, _shift, _sizebits, \
  246. _step, _instepoffset, _norealshift) \
  247. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  248. .offset = _offset, \
  249. .step = _step, \
  250. .in_step_offset = _instepoffset, \
  251. .shift = _shift, \
  252. .no_real_shift = _norealshift, \
  253. .size = {.bits = _sizebits,}, \
  254. .name = #_type "_" #_cname "_" #_iname, \
  255. }; \
  256. static inline u8 __maybe_unused \
  257. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
  258. { \
  259. return __mlxsw_item_get8(buf, &__ITEM_NAME(_type, _cname, _iname), \
  260. index); \
  261. } \
  262. static inline void __maybe_unused \
  263. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
  264. u8 val) \
  265. { \
  266. __mlxsw_item_set8(buf, &__ITEM_NAME(_type, _cname, _iname), \
  267. index, val); \
  268. }
  269. #define MLXSW_ITEM16(_type, _cname, _iname, _offset, _shift, _sizebits) \
  270. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  271. .offset = _offset, \
  272. .shift = _shift, \
  273. .size = {.bits = _sizebits,}, \
  274. .name = #_type "_" #_cname "_" #_iname, \
  275. }; \
  276. static inline u16 __maybe_unused \
  277. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
  278. { \
  279. return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
  280. } \
  281. static inline void __maybe_unused \
  282. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 val) \
  283. { \
  284. __mlxsw_item_set16(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
  285. }
  286. #define MLXSW_ITEM16_INDEXED(_type, _cname, _iname, _offset, _shift, _sizebits, \
  287. _step, _instepoffset, _norealshift) \
  288. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  289. .offset = _offset, \
  290. .step = _step, \
  291. .in_step_offset = _instepoffset, \
  292. .shift = _shift, \
  293. .no_real_shift = _norealshift, \
  294. .size = {.bits = _sizebits,}, \
  295. .name = #_type "_" #_cname "_" #_iname, \
  296. }; \
  297. static inline u16 __maybe_unused \
  298. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
  299. { \
  300. return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), \
  301. index); \
  302. } \
  303. static inline void __maybe_unused \
  304. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
  305. u16 val) \
  306. { \
  307. __mlxsw_item_set16(buf, &__ITEM_NAME(_type, _cname, _iname), \
  308. index, val); \
  309. }
  310. #define MLXSW_ITEM32(_type, _cname, _iname, _offset, _shift, _sizebits) \
  311. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  312. .offset = _offset, \
  313. .shift = _shift, \
  314. .size = {.bits = _sizebits,}, \
  315. .name = #_type "_" #_cname "_" #_iname, \
  316. }; \
  317. static inline u32 __maybe_unused \
  318. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
  319. { \
  320. return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
  321. } \
  322. static inline void __maybe_unused \
  323. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u32 val) \
  324. { \
  325. __mlxsw_item_set32(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
  326. }
  327. #define LOCAL_PORT_LSB_SIZE 8
  328. #define LOCAL_PORT_MSB_SIZE 2
  329. #define MLXSW_ITEM32_LP(_type, _cname, _offset1, _shift1, _offset2, _shift2) \
  330. static struct mlxsw_item __ITEM_NAME(_type, _cname, local_port) = { \
  331. .offset = _offset1, \
  332. .shift = _shift1, \
  333. .size = {.bits = LOCAL_PORT_LSB_SIZE,}, \
  334. .name = #_type "_" #_cname "_local_port", \
  335. }; \
  336. static struct mlxsw_item __ITEM_NAME(_type, _cname, lp_msb) = { \
  337. .offset = _offset2, \
  338. .shift = _shift2, \
  339. .size = {.bits = LOCAL_PORT_MSB_SIZE,}, \
  340. .name = #_type "_" #_cname "_lp_msb", \
  341. }; \
  342. static inline u32 __maybe_unused \
  343. mlxsw_##_type##_##_cname##_local_port_get(const char *buf) \
  344. { \
  345. u32 local_port, lp_msb; \
  346. \
  347. local_port = __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, \
  348. local_port), 0); \
  349. lp_msb = __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, lp_msb), \
  350. 0); \
  351. return (lp_msb << LOCAL_PORT_LSB_SIZE) + local_port; \
  352. } \
  353. static inline void __maybe_unused \
  354. mlxsw_##_type##_##_cname##_local_port_set(char *buf, u32 val) \
  355. { \
  356. __mlxsw_item_set32(buf, &__ITEM_NAME(_type, _cname, local_port), 0, \
  357. val & ((1 << LOCAL_PORT_LSB_SIZE) - 1)); \
  358. __mlxsw_item_set32(buf, &__ITEM_NAME(_type, _cname, lp_msb), 0, \
  359. val >> LOCAL_PORT_LSB_SIZE); \
  360. }
  361. #define MLXSW_ITEM32_INDEXED(_type, _cname, _iname, _offset, _shift, _sizebits, \
  362. _step, _instepoffset, _norealshift) \
  363. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  364. .offset = _offset, \
  365. .step = _step, \
  366. .in_step_offset = _instepoffset, \
  367. .shift = _shift, \
  368. .no_real_shift = _norealshift, \
  369. .size = {.bits = _sizebits,}, \
  370. .name = #_type "_" #_cname "_" #_iname, \
  371. }; \
  372. static inline u32 __maybe_unused \
  373. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
  374. { \
  375. return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), \
  376. index); \
  377. } \
  378. static inline void __maybe_unused \
  379. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
  380. u32 val) \
  381. { \
  382. __mlxsw_item_set32(buf, &__ITEM_NAME(_type, _cname, _iname), \
  383. index, val); \
  384. }
  385. #define MLXSW_ITEM64(_type, _cname, _iname, _offset, _shift, _sizebits) \
  386. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  387. .offset = _offset, \
  388. .shift = _shift, \
  389. .size = {.bits = _sizebits,}, \
  390. .name = #_type "_" #_cname "_" #_iname, \
  391. }; \
  392. static inline u64 __maybe_unused \
  393. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
  394. { \
  395. return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
  396. } \
  397. static inline void __maybe_unused \
  398. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u64 val) \
  399. { \
  400. __mlxsw_item_set64(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
  401. }
  402. #define MLXSW_ITEM64_INDEXED(_type, _cname, _iname, _offset, _shift, \
  403. _sizebits, _step, _instepoffset, _norealshift) \
  404. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  405. .offset = _offset, \
  406. .step = _step, \
  407. .in_step_offset = _instepoffset, \
  408. .shift = _shift, \
  409. .no_real_shift = _norealshift, \
  410. .size = {.bits = _sizebits,}, \
  411. .name = #_type "_" #_cname "_" #_iname, \
  412. }; \
  413. static inline u64 __maybe_unused \
  414. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
  415. { \
  416. return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), \
  417. index); \
  418. } \
  419. static inline void __maybe_unused \
  420. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
  421. u64 val) \
  422. { \
  423. __mlxsw_item_set64(buf, &__ITEM_NAME(_type, _cname, _iname), \
  424. index, val); \
  425. }
  426. #define MLXSW_ITEM_BUF(_type, _cname, _iname, _offset, _sizebytes) \
  427. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  428. .offset = _offset, \
  429. .size = {.bytes = _sizebytes,}, \
  430. .name = #_type "_" #_cname "_" #_iname, \
  431. }; \
  432. static inline void __maybe_unused \
  433. mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, char *dst) \
  434. { \
  435. __mlxsw_item_memcpy_from(buf, dst, \
  436. &__ITEM_NAME(_type, _cname, _iname), 0); \
  437. } \
  438. static inline void __maybe_unused \
  439. mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, const char *src) \
  440. { \
  441. __mlxsw_item_memcpy_to(buf, src, \
  442. &__ITEM_NAME(_type, _cname, _iname), 0); \
  443. } \
  444. static inline char * __maybe_unused \
  445. mlxsw_##_type##_##_cname##_##_iname##_data(char *buf) \
  446. { \
  447. return __mlxsw_item_data(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
  448. }
  449. #define MLXSW_ITEM_BUF_INDEXED(_type, _cname, _iname, _offset, _sizebytes, \
  450. _step, _instepoffset) \
  451. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  452. .offset = _offset, \
  453. .step = _step, \
  454. .in_step_offset = _instepoffset, \
  455. .size = {.bytes = _sizebytes,}, \
  456. .name = #_type "_" #_cname "_" #_iname, \
  457. }; \
  458. static inline void __maybe_unused \
  459. mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, \
  460. unsigned short index, \
  461. char *dst) \
  462. { \
  463. __mlxsw_item_memcpy_from(buf, dst, \
  464. &__ITEM_NAME(_type, _cname, _iname), index); \
  465. } \
  466. static inline void __maybe_unused \
  467. mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, \
  468. unsigned short index, \
  469. const char *src) \
  470. { \
  471. __mlxsw_item_memcpy_to(buf, src, \
  472. &__ITEM_NAME(_type, _cname, _iname), index); \
  473. } \
  474. static inline char * __maybe_unused \
  475. mlxsw_##_type##_##_cname##_##_iname##_data(char *buf, unsigned short index) \
  476. { \
  477. return __mlxsw_item_data(buf, \
  478. &__ITEM_NAME(_type, _cname, _iname), index); \
  479. }
  480. #define MLXSW_ITEM_BIT_ARRAY(_type, _cname, _iname, _offset, _sizebytes, \
  481. _element_size) \
  482. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  483. .offset = _offset, \
  484. .element_size = _element_size, \
  485. .size = {.bytes = _sizebytes,}, \
  486. .name = #_type "_" #_cname "_" #_iname, \
  487. }; \
  488. static inline u8 __maybe_unused \
  489. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, u16 index) \
  490. { \
  491. return __mlxsw_item_bit_array_get(buf, \
  492. &__ITEM_NAME(_type, _cname, _iname), \
  493. index); \
  494. } \
  495. static inline void __maybe_unused \
  496. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 index, u8 val) \
  497. { \
  498. return __mlxsw_item_bit_array_set(buf, \
  499. &__ITEM_NAME(_type, _cname, _iname), \
  500. index, val); \
  501. } \
  502. #endif