File Index
Files and directories
Sign in
FILE

bng_tlv.h

File preview with syntax highlighting.

linux-6.19.14/drivers/infiniband/hw/bng_re/bng_tlv.h C
  1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2
  3#ifndef __BNG_TLV_H__
  4#define __BNG_TLV_H__
  5
  6#include "roce_hsi.h"
  7
  8struct roce_tlv {
  9	struct tlv tlv;
 10	u8 total_size; // in units of 16 byte chunks
 11	u8 unused[7];  // for 16 byte alignment
 12};
 13
 14/*
 15 * TLV size in units of 16 byte chunks
 16 */
 17#define TLV_SIZE ((sizeof(struct roce_tlv) + 15) / 16)
 18/*
 19 * TLV length in bytes
 20 */
 21#define TLV_BYTES (TLV_SIZE * 16)
 22
 23#define HAS_TLV_HEADER(msg) (le16_to_cpu(((struct tlv *)(msg))->cmd_discr) == CMD_DISCR_TLV_ENCAP)
 24#define GET_TLV_DATA(tlv)   ((void *)&((uint8_t *)(tlv))[TLV_BYTES])
 25
 26static inline u8 __get_cmdq_base_opcode(struct cmdq_base *req, u32 size)
 27{
 28	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
 29		return ((struct cmdq_base *)GET_TLV_DATA(req))->opcode;
 30	else
 31		return req->opcode;
 32}
 33
 34static inline void __set_cmdq_base_opcode(struct cmdq_base *req,
 35					  u32 size, u8 val)
 36{
 37	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
 38		((struct cmdq_base *)GET_TLV_DATA(req))->opcode = val;
 39	else
 40		req->opcode = val;
 41}
 42
 43static inline __le16 __get_cmdq_base_cookie(struct cmdq_base *req, u32 size)
 44{
 45	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
 46		return ((struct cmdq_base *)GET_TLV_DATA(req))->cookie;
 47	else
 48		return req->cookie;
 49}
 50
 51static inline void __set_cmdq_base_cookie(struct cmdq_base *req,
 52					  u32 size, __le16 val)
 53{
 54	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
 55		((struct cmdq_base *)GET_TLV_DATA(req))->cookie = val;
 56	else
 57		req->cookie = val;
 58}
 59
 60static inline __le64 __get_cmdq_base_resp_addr(struct cmdq_base *req, u32 size)
 61{
 62	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
 63		return ((struct cmdq_base *)GET_TLV_DATA(req))->resp_addr;
 64	else
 65		return req->resp_addr;
 66}
 67
 68static inline void __set_cmdq_base_resp_addr(struct cmdq_base *req,
 69					     u32 size, __le64 val)
 70{
 71	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
 72		((struct cmdq_base *)GET_TLV_DATA(req))->resp_addr = val;
 73	else
 74		req->resp_addr = val;
 75}
 76
 77static inline u8 __get_cmdq_base_resp_size(struct cmdq_base *req, u32 size)
 78{
 79	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
 80		return ((struct cmdq_base *)GET_TLV_DATA(req))->resp_size;
 81	else
 82		return req->resp_size;
 83}
 84
 85static inline void __set_cmdq_base_resp_size(struct cmdq_base *req,
 86					     u32 size, u8 val)
 87{
 88	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
 89		((struct cmdq_base *)GET_TLV_DATA(req))->resp_size = val;
 90	else
 91		req->resp_size = val;
 92}
 93
 94static inline u8 __get_cmdq_base_cmd_size(struct cmdq_base *req, u32 size)
 95{
 96	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
 97		return ((struct roce_tlv *)(req))->total_size;
 98	else
 99		return req->cmd_size;
100}
101
102static inline void __set_cmdq_base_cmd_size(struct cmdq_base *req,
103					    u32 size, u8 val)
104{
105	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
106		((struct cmdq_base *)GET_TLV_DATA(req))->cmd_size = val;
107	else
108		req->cmd_size = val;
109}
110
111static inline __le16 __get_cmdq_base_flags(struct cmdq_base *req, u32 size)
112{
113	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
114		return ((struct cmdq_base *)GET_TLV_DATA(req))->flags;
115	else
116		return req->flags;
117}
118
119static inline void __set_cmdq_base_flags(struct cmdq_base *req,
120					 u32 size, __le16 val)
121{
122	if (HAS_TLV_HEADER(req) && size > TLV_BYTES)
123		((struct cmdq_base *)GET_TLV_DATA(req))->flags = val;
124	else
125		req->flags = val;
126}
127
128#endif /* __BNG_TLV_H__ */
~/ Read-only file preview.