linux/drivers/net/ethernet/meta/fbnic/fbnic_tlv.h

/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) Meta Platforms, Inc. and affiliates. */

#ifndef _FBNIC_TLV_H_
#define _FBNIC_TLV_H_

#include <asm/byteorder.h>
#include <linux/bits.h>
#include <linux/const.h>
#include <linux/types.h>

#define FBNIC_TLV_MSG_ALIGN(len)
#define FBNIC_TLV_MSG_SIZE(len)

/* TLV Header Format
 *    3			  2		      1
 *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |		Length		   |M|I|RSV|	   Type / ID	   |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *
 * The TLV header format described above will be used for transferring
 * messages between the host and the firmware. To ensure byte ordering
 * we have defined all fields as being little endian.
 * Type/ID: Identifier for message and/or attribute
 * RSV: Reserved field for future use, likely as additional flags
 * I: cannot_ignore flag, identifies if unrecognized attribute can be ignored
 * M: is_msg, indicates that this is the start of a new message
 * Length: Total length of message in dwords including header
 *		or
 *	   Total length of attribute in bytes including header
 */
struct fbnic_tlv_hdr {};

#define FBNIC_TLV_RESULTS_MAX

struct fbnic_tlv_msg {};

#define FBNIC_TLV_MSG_ID_UNKNOWN

enum fbnic_tlv_type {};

/* TLV Index
 * Defines the relationship between the attribute IDs and their types.
 * For each entry in the index there will be a size and type associated
 * with it so that we can use this to parse the data and verify it matches
 * the expected layout.
 */
struct fbnic_tlv_index {};

#define TLV_MAX_DATA
#define FBNIC_TLV_ATTR_ID_UNKNOWN
#define FBNIC_TLV_ATTR_STRING(id, len)
#define FBNIC_TLV_ATTR_FLAG(id)
#define FBNIC_TLV_ATTR_U32(id)
#define FBNIC_TLV_ATTR_U64(id)
#define FBNIC_TLV_ATTR_S32(id)
#define FBNIC_TLV_ATTR_S64(id)
#define FBNIC_TLV_ATTR_MAC_ADDR(id)
#define FBNIC_TLV_ATTR_NESTED(id)
#define FBNIC_TLV_ATTR_ARRAY(id)
#define FBNIC_TLV_ATTR_RAW_DATA(id)
#define FBNIC_TLV_ATTR_LAST

struct fbnic_tlv_parser {};

#define FBNIC_TLV_PARSER(id, attr, func)

static inline void *
fbnic_tlv_attr_get_value_ptr(struct fbnic_tlv_msg *attr)
{}

static inline bool fbnic_tlv_attr_get_bool(struct fbnic_tlv_msg *attr)
{}

u64 fbnic_tlv_attr_get_unsigned(struct fbnic_tlv_msg *attr);
s64 fbnic_tlv_attr_get_signed(struct fbnic_tlv_msg *attr);
size_t fbnic_tlv_attr_get_string(struct fbnic_tlv_msg *attr, char *str,
				 size_t max_size);

#define get_unsigned_result(id, location)

#define get_signed_result(id, location)

#define get_string_result(id, size, str, max_size)

#define get_bool(id)

struct fbnic_tlv_msg *fbnic_tlv_msg_alloc(u16 msg_id);
int fbnic_tlv_attr_put_flag(struct fbnic_tlv_msg *msg, const u16 attr_id);
int fbnic_tlv_attr_put_value(struct fbnic_tlv_msg *msg, const u16 attr_id,
			     const void *value, const int len);
int __fbnic_tlv_attr_put_int(struct fbnic_tlv_msg *msg, const u16 attr_id,
			     s64 value, const int len);
#define fbnic_tlv_attr_put_int(msg, attr_id, value)
int fbnic_tlv_attr_put_mac_addr(struct fbnic_tlv_msg *msg, const u16 attr_id,
				const u8 *mac_addr);
int fbnic_tlv_attr_put_string(struct fbnic_tlv_msg *msg, u16 attr_id,
			      const char *string);
struct fbnic_tlv_msg *fbnic_tlv_attr_nest_start(struct fbnic_tlv_msg *msg,
						u16 attr_id);
void fbnic_tlv_attr_nest_stop(struct fbnic_tlv_msg *msg);
void fbnic_tlv_attr_addr_copy(u8 *dest, struct fbnic_tlv_msg *src);
int fbnic_tlv_attr_parse_array(struct fbnic_tlv_msg *attr, int len,
			       struct fbnic_tlv_msg **results,
			       const struct fbnic_tlv_index *tlv_index,
			       u16 tlv_attr_id, size_t array_len);
int fbnic_tlv_attr_parse(struct fbnic_tlv_msg *attr, int len,
			 struct fbnic_tlv_msg **results,
			 const struct fbnic_tlv_index *tlv_index);
int fbnic_tlv_msg_parse(void *opaque, struct fbnic_tlv_msg *msg,
			const struct fbnic_tlv_parser *parser);
int fbnic_tlv_parser_error(void *opaque, struct fbnic_tlv_msg **results);

#define FBNIC_TLV_MSG_ERROR
#endif /* _FBNIC_TLV_H_ */