blob: 0c49d1fcfe2353e50f1123baf195055f2ae07499 [file] [log] [blame]
/* SPDX-License-Identifier: Apache-2.0
* Copyright (c) 2023 Cisco Systems, Inc.
*/
#ifndef _VNET_DEV_ARGS_H_
#define _VNET_DEV_ARGS_H_
#include <vppinfra/clib.h>
#include <vnet/dev/errors.h>
#define foreach_vnet_dev_arg_type \
_ (BOOL, "%u", boolean) \
_ (UINT32, "%u", uint32) \
_ (STRING, "\'%v\'", string)
typedef enum
{
VNET_DEV_ARG_END,
#define _(n, f, v) VNET_DEV_ARG_TYPE_##n,
foreach_vnet_dev_arg_type
#undef _
} __clib_packed vnet_dev_arg_type_t;
typedef union
{
u8 boolean;
u8 uint32;
u8 *string;
} vnet_dev_arg_value_t;
typedef struct
{
char *name;
char *desc;
vnet_dev_arg_type_t type;
u8 val_set;
u32 min;
u32 max;
u64 id;
vnet_dev_arg_value_t val;
vnet_dev_arg_value_t default_val;
} vnet_dev_arg_t;
#define VNET_DEV_ARG_BOOL(ud, n, d, ...) \
{ \
.type = VNET_DEV_ARG_TYPE_BOOL, .id = ud, .name = n, .desc = d, \
__VA_ARGS__ \
}
#define VNET_DEV_ARG_UINT32(ud, n, d, ...) \
{ \
.type = VNET_DEV_ARG_TYPE_UINT32, .id = ud, .name = n, .desc = d, \
__VA_ARGS__ \
}
#define VNET_DEV_ARG_STRING(ud, n, d, ...) \
{ \
.type = VNET_DEV_ARG_TYPE_STRING, .id = ud, .name = n, .desc = d, \
__VA_ARGS__ \
}
#define VNET_DEV_ARG_END() \
{ \
.type = VNET_DEV_ARG_END \
}
#define VNET_DEV_ARGS(...) \
(vnet_dev_arg_t[]) { __VA_ARGS__, VNET_DEV_ARG_END () }
#define foreach_vnet_dev_args(a, d) \
for (typeof ((d)->args[0]) *(a) = (d)->args; (a) < vec_end ((d)->args); \
(a)++)
#define foreach_vnet_dev_port_args(a, p) \
for (typeof ((p)->args[0]) *(a) = (p)->args; (a) < vec_end ((p)->args); \
(a)++)
#endif /* _VNET_DEV_ARGS_H_ */