item.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. /*
  2. * drivers/net/ethernet/mellanox/mlxsw/item.h
  3. * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved.
  4. * Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com>
  5. * Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the names of the copyright holders nor the names of its
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * Alternatively, this software may be distributed under the terms of the
  20. * GNU General Public License ("GPL") version 2 as published by the Free
  21. * Software Foundation.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef _MLXSW_ITEM_H
  36. #define _MLXSW_ITEM_H
  37. #include <linux/types.h>
  38. #include <linux/string.h>
  39. #include <linux/bitops.h>
  40. struct mlxsw_item {
  41. unsigned short offset; /* bytes in container */
  42. unsigned short step; /* step in bytes for indexed items */
  43. unsigned short in_step_offset; /* offset within one step */
  44. unsigned char shift; /* shift in bits */
  45. unsigned char element_size; /* size of element in bit array */
  46. bool no_real_shift;
  47. union {
  48. unsigned char bits;
  49. unsigned short bytes;
  50. } size;
  51. const char *name;
  52. };
  53. static inline unsigned int
  54. __mlxsw_item_offset(const struct mlxsw_item *item, unsigned short index,
  55. size_t typesize)
  56. {
  57. BUG_ON(index && !item->step);
  58. if (item->offset % typesize != 0 ||
  59. item->step % typesize != 0 ||
  60. item->in_step_offset % typesize != 0) {
  61. pr_err("mlxsw: item bug (name=%s,offset=%x,step=%x,in_step_offset=%x,typesize=%zx)\n",
  62. item->name, item->offset, item->step,
  63. item->in_step_offset, typesize);
  64. BUG();
  65. }
  66. return ((item->offset + item->step * index + item->in_step_offset) /
  67. typesize);
  68. }
  69. static inline u8 __mlxsw_item_get8(const char *buf,
  70. const struct mlxsw_item *item,
  71. unsigned short index)
  72. {
  73. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u8));
  74. u8 *b = (u8 *) buf;
  75. u8 tmp;
  76. tmp = b[offset];
  77. tmp >>= item->shift;
  78. tmp &= GENMASK(item->size.bits - 1, 0);
  79. if (item->no_real_shift)
  80. tmp <<= item->shift;
  81. return tmp;
  82. }
  83. static inline void __mlxsw_item_set8(char *buf, const struct mlxsw_item *item,
  84. unsigned short index, u8 val)
  85. {
  86. unsigned int offset = __mlxsw_item_offset(item, index,
  87. sizeof(u8));
  88. u8 *b = (u8 *) buf;
  89. u8 mask = GENMASK(item->size.bits - 1, 0) << item->shift;
  90. u8 tmp;
  91. if (!item->no_real_shift)
  92. val <<= item->shift;
  93. val &= mask;
  94. tmp = b[offset];
  95. tmp &= ~mask;
  96. tmp |= val;
  97. b[offset] = tmp;
  98. }
  99. static inline u16 __mlxsw_item_get16(const char *buf,
  100. const struct mlxsw_item *item,
  101. unsigned short index)
  102. {
  103. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u16));
  104. __be16 *b = (__be16 *) buf;
  105. u16 tmp;
  106. tmp = be16_to_cpu(b[offset]);
  107. tmp >>= item->shift;
  108. tmp &= GENMASK(item->size.bits - 1, 0);
  109. if (item->no_real_shift)
  110. tmp <<= item->shift;
  111. return tmp;
  112. }
  113. static inline void __mlxsw_item_set16(char *buf, const struct mlxsw_item *item,
  114. unsigned short index, u16 val)
  115. {
  116. unsigned int offset = __mlxsw_item_offset(item, index,
  117. sizeof(u16));
  118. __be16 *b = (__be16 *) buf;
  119. u16 mask = GENMASK(item->size.bits - 1, 0) << item->shift;
  120. u16 tmp;
  121. if (!item->no_real_shift)
  122. val <<= item->shift;
  123. val &= mask;
  124. tmp = be16_to_cpu(b[offset]);
  125. tmp &= ~mask;
  126. tmp |= val;
  127. b[offset] = cpu_to_be16(tmp);
  128. }
  129. static inline u32 __mlxsw_item_get32(const char *buf,
  130. const struct mlxsw_item *item,
  131. unsigned short index)
  132. {
  133. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u32));
  134. __be32 *b = (__be32 *) buf;
  135. u32 tmp;
  136. tmp = be32_to_cpu(b[offset]);
  137. tmp >>= item->shift;
  138. tmp &= GENMASK(item->size.bits - 1, 0);
  139. if (item->no_real_shift)
  140. tmp <<= item->shift;
  141. return tmp;
  142. }
  143. static inline void __mlxsw_item_set32(char *buf, const struct mlxsw_item *item,
  144. unsigned short index, u32 val)
  145. {
  146. unsigned int offset = __mlxsw_item_offset(item, index,
  147. sizeof(u32));
  148. __be32 *b = (__be32 *) buf;
  149. u32 mask = GENMASK(item->size.bits - 1, 0) << item->shift;
  150. u32 tmp;
  151. if (!item->no_real_shift)
  152. val <<= item->shift;
  153. val &= mask;
  154. tmp = be32_to_cpu(b[offset]);
  155. tmp &= ~mask;
  156. tmp |= val;
  157. b[offset] = cpu_to_be32(tmp);
  158. }
  159. static inline u64 __mlxsw_item_get64(const char *buf,
  160. const struct mlxsw_item *item,
  161. unsigned short index)
  162. {
  163. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u64));
  164. __be64 *b = (__be64 *) buf;
  165. u64 tmp;
  166. tmp = be64_to_cpu(b[offset]);
  167. tmp >>= item->shift;
  168. tmp &= GENMASK_ULL(item->size.bits - 1, 0);
  169. if (item->no_real_shift)
  170. tmp <<= item->shift;
  171. return tmp;
  172. }
  173. static inline void __mlxsw_item_set64(char *buf, const struct mlxsw_item *item,
  174. unsigned short index, u64 val)
  175. {
  176. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(u64));
  177. __be64 *b = (__be64 *) buf;
  178. u64 mask = GENMASK_ULL(item->size.bits - 1, 0) << item->shift;
  179. u64 tmp;
  180. if (!item->no_real_shift)
  181. val <<= item->shift;
  182. val &= mask;
  183. tmp = be64_to_cpu(b[offset]);
  184. tmp &= ~mask;
  185. tmp |= val;
  186. b[offset] = cpu_to_be64(tmp);
  187. }
  188. static inline void __mlxsw_item_memcpy_from(const char *buf, char *dst,
  189. const struct mlxsw_item *item,
  190. unsigned short index)
  191. {
  192. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(char));
  193. memcpy(dst, &buf[offset], item->size.bytes);
  194. }
  195. static inline void __mlxsw_item_memcpy_to(char *buf, const char *src,
  196. const struct mlxsw_item *item,
  197. unsigned short index)
  198. {
  199. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(char));
  200. memcpy(&buf[offset], src, item->size.bytes);
  201. }
  202. static inline char *__mlxsw_item_data(char *buf, const struct mlxsw_item *item,
  203. unsigned short index)
  204. {
  205. unsigned int offset = __mlxsw_item_offset(item, index, sizeof(char));
  206. return &buf[offset];
  207. }
  208. static inline u16
  209. __mlxsw_item_bit_array_offset(const struct mlxsw_item *item,
  210. u16 index, u8 *shift)
  211. {
  212. u16 max_index, be_index;
  213. u16 offset; /* byte offset inside the array */
  214. u8 in_byte_index;
  215. BUG_ON(index && !item->element_size);
  216. if (item->offset % sizeof(u32) != 0 ||
  217. BITS_PER_BYTE % item->element_size != 0) {
  218. pr_err("mlxsw: item bug (name=%s,offset=%x,element_size=%x)\n",
  219. item->name, item->offset, item->element_size);
  220. BUG();
  221. }
  222. max_index = (item->size.bytes << 3) / item->element_size - 1;
  223. be_index = max_index - index;
  224. offset = be_index * item->element_size >> 3;
  225. in_byte_index = index % (BITS_PER_BYTE / item->element_size);
  226. *shift = in_byte_index * item->element_size;
  227. return item->offset + offset;
  228. }
  229. static inline u8 __mlxsw_item_bit_array_get(const char *buf,
  230. const struct mlxsw_item *item,
  231. u16 index)
  232. {
  233. u8 shift, tmp;
  234. u16 offset = __mlxsw_item_bit_array_offset(item, index, &shift);
  235. tmp = buf[offset];
  236. tmp >>= shift;
  237. tmp &= GENMASK(item->element_size - 1, 0);
  238. return tmp;
  239. }
  240. static inline void __mlxsw_item_bit_array_set(char *buf,
  241. const struct mlxsw_item *item,
  242. u16 index, u8 val)
  243. {
  244. u8 shift, tmp;
  245. u16 offset = __mlxsw_item_bit_array_offset(item, index, &shift);
  246. u8 mask = GENMASK(item->element_size - 1, 0) << shift;
  247. val <<= shift;
  248. val &= mask;
  249. tmp = buf[offset];
  250. tmp &= ~mask;
  251. tmp |= val;
  252. buf[offset] = tmp;
  253. }
  254. #define __ITEM_NAME(_type, _cname, _iname) \
  255. mlxsw_##_type##_##_cname##_##_iname##_item
  256. /* _type: cmd_mbox, reg, etc.
  257. * _cname: containter name (e.g. command name, register name)
  258. * _iname: item name within the container
  259. */
  260. #define MLXSW_ITEM8(_type, _cname, _iname, _offset, _shift, _sizebits) \
  261. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  262. .offset = _offset, \
  263. .shift = _shift, \
  264. .size = {.bits = _sizebits,}, \
  265. .name = #_type "_" #_cname "_" #_iname, \
  266. }; \
  267. static inline u8 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
  268. { \
  269. return __mlxsw_item_get8(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
  270. } \
  271. static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u8 val)\
  272. { \
  273. __mlxsw_item_set8(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
  274. }
  275. #define MLXSW_ITEM8_INDEXED(_type, _cname, _iname, _offset, _shift, _sizebits, \
  276. _step, _instepoffset, _norealshift) \
  277. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  278. .offset = _offset, \
  279. .step = _step, \
  280. .in_step_offset = _instepoffset, \
  281. .shift = _shift, \
  282. .no_real_shift = _norealshift, \
  283. .size = {.bits = _sizebits,}, \
  284. .name = #_type "_" #_cname "_" #_iname, \
  285. }; \
  286. static inline u8 \
  287. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
  288. { \
  289. return __mlxsw_item_get8(buf, &__ITEM_NAME(_type, _cname, _iname), \
  290. index); \
  291. } \
  292. static inline void \
  293. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
  294. u8 val) \
  295. { \
  296. __mlxsw_item_set8(buf, &__ITEM_NAME(_type, _cname, _iname), \
  297. index, val); \
  298. }
  299. #define MLXSW_ITEM16(_type, _cname, _iname, _offset, _shift, _sizebits) \
  300. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  301. .offset = _offset, \
  302. .shift = _shift, \
  303. .size = {.bits = _sizebits,}, \
  304. .name = #_type "_" #_cname "_" #_iname, \
  305. }; \
  306. static inline u16 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
  307. { \
  308. return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
  309. } \
  310. static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 val)\
  311. { \
  312. __mlxsw_item_set16(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
  313. }
  314. #define MLXSW_ITEM16_INDEXED(_type, _cname, _iname, _offset, _shift, _sizebits, \
  315. _step, _instepoffset, _norealshift) \
  316. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  317. .offset = _offset, \
  318. .step = _step, \
  319. .in_step_offset = _instepoffset, \
  320. .shift = _shift, \
  321. .no_real_shift = _norealshift, \
  322. .size = {.bits = _sizebits,}, \
  323. .name = #_type "_" #_cname "_" #_iname, \
  324. }; \
  325. static inline u16 \
  326. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
  327. { \
  328. return __mlxsw_item_get16(buf, &__ITEM_NAME(_type, _cname, _iname), \
  329. index); \
  330. } \
  331. static inline void \
  332. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
  333. u16 val) \
  334. { \
  335. __mlxsw_item_set16(buf, &__ITEM_NAME(_type, _cname, _iname), \
  336. index, val); \
  337. }
  338. #define MLXSW_ITEM32(_type, _cname, _iname, _offset, _shift, _sizebits) \
  339. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  340. .offset = _offset, \
  341. .shift = _shift, \
  342. .size = {.bits = _sizebits,}, \
  343. .name = #_type "_" #_cname "_" #_iname, \
  344. }; \
  345. static inline u32 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
  346. { \
  347. return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
  348. } \
  349. static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u32 val)\
  350. { \
  351. __mlxsw_item_set32(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
  352. }
  353. #define MLXSW_ITEM32_INDEXED(_type, _cname, _iname, _offset, _shift, _sizebits, \
  354. _step, _instepoffset, _norealshift) \
  355. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  356. .offset = _offset, \
  357. .step = _step, \
  358. .in_step_offset = _instepoffset, \
  359. .shift = _shift, \
  360. .no_real_shift = _norealshift, \
  361. .size = {.bits = _sizebits,}, \
  362. .name = #_type "_" #_cname "_" #_iname, \
  363. }; \
  364. static inline u32 \
  365. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
  366. { \
  367. return __mlxsw_item_get32(buf, &__ITEM_NAME(_type, _cname, _iname), \
  368. index); \
  369. } \
  370. static inline void \
  371. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
  372. u32 val) \
  373. { \
  374. __mlxsw_item_set32(buf, &__ITEM_NAME(_type, _cname, _iname), \
  375. index, val); \
  376. }
  377. #define MLXSW_ITEM64(_type, _cname, _iname, _offset, _shift, _sizebits) \
  378. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  379. .offset = _offset, \
  380. .shift = _shift, \
  381. .size = {.bits = _sizebits,}, \
  382. .name = #_type "_" #_cname "_" #_iname, \
  383. }; \
  384. static inline u64 mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf) \
  385. { \
  386. return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
  387. } \
  388. static inline void mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u64 val)\
  389. { \
  390. __mlxsw_item_set64(buf, &__ITEM_NAME(_type, _cname, _iname), 0, val); \
  391. }
  392. #define MLXSW_ITEM64_INDEXED(_type, _cname, _iname, _offset, _shift, \
  393. _sizebits, _step, _instepoffset, _norealshift) \
  394. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  395. .offset = _offset, \
  396. .step = _step, \
  397. .in_step_offset = _instepoffset, \
  398. .shift = _shift, \
  399. .no_real_shift = _norealshift, \
  400. .size = {.bits = _sizebits,}, \
  401. .name = #_type "_" #_cname "_" #_iname, \
  402. }; \
  403. static inline u64 \
  404. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, unsigned short index)\
  405. { \
  406. return __mlxsw_item_get64(buf, &__ITEM_NAME(_type, _cname, _iname), \
  407. index); \
  408. } \
  409. static inline void \
  410. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, unsigned short index, \
  411. u64 val) \
  412. { \
  413. __mlxsw_item_set64(buf, &__ITEM_NAME(_type, _cname, _iname), \
  414. index, val); \
  415. }
  416. #define MLXSW_ITEM_BUF(_type, _cname, _iname, _offset, _sizebytes) \
  417. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  418. .offset = _offset, \
  419. .size = {.bytes = _sizebytes,}, \
  420. .name = #_type "_" #_cname "_" #_iname, \
  421. }; \
  422. static inline void \
  423. mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, char *dst) \
  424. { \
  425. __mlxsw_item_memcpy_from(buf, dst, \
  426. &__ITEM_NAME(_type, _cname, _iname), 0); \
  427. } \
  428. static inline void \
  429. mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, const char *src) \
  430. { \
  431. __mlxsw_item_memcpy_to(buf, src, \
  432. &__ITEM_NAME(_type, _cname, _iname), 0); \
  433. } \
  434. static inline char * \
  435. mlxsw_##_type##_##_cname##_##_iname##_data(char *buf) \
  436. { \
  437. return __mlxsw_item_data(buf, &__ITEM_NAME(_type, _cname, _iname), 0); \
  438. }
  439. #define MLXSW_ITEM_BUF_INDEXED(_type, _cname, _iname, _offset, _sizebytes, \
  440. _step, _instepoffset) \
  441. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  442. .offset = _offset, \
  443. .step = _step, \
  444. .in_step_offset = _instepoffset, \
  445. .size = {.bytes = _sizebytes,}, \
  446. .name = #_type "_" #_cname "_" #_iname, \
  447. }; \
  448. static inline void \
  449. mlxsw_##_type##_##_cname##_##_iname##_memcpy_from(const char *buf, \
  450. unsigned short index, \
  451. char *dst) \
  452. { \
  453. __mlxsw_item_memcpy_from(buf, dst, \
  454. &__ITEM_NAME(_type, _cname, _iname), index); \
  455. } \
  456. static inline void \
  457. mlxsw_##_type##_##_cname##_##_iname##_memcpy_to(char *buf, \
  458. unsigned short index, \
  459. const char *src) \
  460. { \
  461. __mlxsw_item_memcpy_to(buf, src, \
  462. &__ITEM_NAME(_type, _cname, _iname), index); \
  463. } \
  464. static inline char * \
  465. mlxsw_##_type##_##_cname##_##_iname##_data(char *buf, unsigned short index) \
  466. { \
  467. return __mlxsw_item_data(buf, \
  468. &__ITEM_NAME(_type, _cname, _iname), index); \
  469. }
  470. #define MLXSW_ITEM_BIT_ARRAY(_type, _cname, _iname, _offset, _sizebytes, \
  471. _element_size) \
  472. static struct mlxsw_item __ITEM_NAME(_type, _cname, _iname) = { \
  473. .offset = _offset, \
  474. .element_size = _element_size, \
  475. .size = {.bytes = _sizebytes,}, \
  476. .name = #_type "_" #_cname "_" #_iname, \
  477. }; \
  478. static inline u8 \
  479. mlxsw_##_type##_##_cname##_##_iname##_get(const char *buf, u16 index) \
  480. { \
  481. return __mlxsw_item_bit_array_get(buf, \
  482. &__ITEM_NAME(_type, _cname, _iname), \
  483. index); \
  484. } \
  485. static inline void \
  486. mlxsw_##_type##_##_cname##_##_iname##_set(char *buf, u16 index, u8 val) \
  487. { \
  488. return __mlxsw_item_bit_array_set(buf, \
  489. &__ITEM_NAME(_type, _cname, _iname), \
  490. index, val); \
  491. } \
  492. #endif