diff options
author | Damjan Marion <damarion@cisco.com> | 2023-11-13 17:33:32 +0000 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2023-11-16 16:01:35 +0000 |
commit | 69768d99eed0f44f6955370cb1ad83b8b73e5368 (patch) | |
tree | 00c689be86b41fe36aae2a9e6e0d3422e1272d81 /src/vnet/dev/dev_funcs.h | |
parent | f3be34e4433bb86509044290fa3cced543697a31 (diff) |
dev: device and port specific args
Type: improvement
Change-Id: I26124a50d8e05d6f01a2e6dbc4bc8183fb5a09c4
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/dev/dev_funcs.h')
-rw-r--r-- | src/vnet/dev/dev_funcs.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/vnet/dev/dev_funcs.h b/src/vnet/dev/dev_funcs.h index 33159ffa65d..a74d3399511 100644 --- a/src/vnet/dev/dev_funcs.h +++ b/src/vnet/dev/dev_funcs.h @@ -289,4 +289,34 @@ vnet_dev_set_hw_addr_eth_mac (vnet_dev_hw_addr_t *addr, const u8 *eth_mac_addr) *addr = ha; } +static_always_inline vnet_dev_arg_t * +vnet_dev_get_port_arg_by_id (vnet_dev_port_t *port, u32 id) +{ + foreach_vnet_dev_port_args (a, port) + if (a->id == id) + return a; + return 0; +} + +static_always_inline int +vnet_dev_arg_get_bool (vnet_dev_arg_t *arg) +{ + ASSERT (arg->type == VNET_DEV_ARG_TYPE_BOOL); + return arg->val_set ? arg->val.boolean : arg->default_val.boolean; +} + +static_always_inline u32 +vnet_dev_arg_get_uint32 (vnet_dev_arg_t *arg) +{ + ASSERT (arg->type == VNET_DEV_ARG_TYPE_UINT32); + return arg->val_set ? arg->val.uint32 : arg->default_val.uint32; +} + +static_always_inline u8 * +vnet_dev_arg_get_string (vnet_dev_arg_t *arg) +{ + ASSERT (arg->type == VNET_DEV_ARG_TYPE_STRING); + return arg->val_set ? arg->val.string : arg->default_val.string; +} + #endif /* _VNET_DEV_FUNCS_H_ */ |