diff --git a/home/nipa/nipa_out/830699/ynl/new-code/ulp_ddp-user.c b/home/nipa/nipa_out/830699/ynl/new-code/ulp_ddp-user.c new file mode 100644 index 000000000000..ed160cc57fc0 --- /dev/null +++ b/home/nipa/nipa_out/830699/ynl/new-code/ulp_ddp-user.c @@ -0,0 +1,365 @@ +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/ulp_ddp.yaml */ +/* YNL-GEN user source */ + +#include +#include +#include "ulp_ddp-user.h" +#include "ynl.h" +#include + +#include +#include + +/* Enums */ +static const char * const ulp_ddp_op_strmap[] = { + [ULP_DDP_CMD_CAPS_GET] = "caps-get", + [ULP_DDP_CMD_STATS_GET] = "stats-get", + [ULP_DDP_CMD_CAPS_SET] = "caps-set", + [ULP_DDP_CMD_CAPS_SET_NTF] = "caps-set-ntf", +}; + +const char *ulp_ddp_op_str(int op) +{ + if (op < 0 || op >= (int)MNL_ARRAY_SIZE(ulp_ddp_op_strmap)) + return NULL; + return ulp_ddp_op_strmap[op]; +} + +static const char * const ulp_ddp_cap_strmap[] = { + [0] = "nvme-tcp", + [1] = "nvme-tcp-ddgst-rx", +}; + +const char *ulp_ddp_cap_str(enum ulp_ddp_cap value) +{ + if (value < 0 || value >= (int)MNL_ARRAY_SIZE(ulp_ddp_cap_strmap)) + return NULL; + return ulp_ddp_cap_strmap[value]; +} + +/* Policies */ +struct ynl_policy_attr ulp_ddp_caps_policy[ULP_DDP_A_CAPS_MAX + 1] = { + [ULP_DDP_A_CAPS_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, }, + [ULP_DDP_A_CAPS_HW] = { .name = "hw", .type = YNL_PT_UINT, }, + [ULP_DDP_A_CAPS_ACTIVE] = { .name = "active", .type = YNL_PT_UINT, }, + [ULP_DDP_A_CAPS_WANTED] = { .name = "wanted", .type = YNL_PT_UINT, }, + [ULP_DDP_A_CAPS_WANTED_MASK] = { .name = "wanted_mask", .type = YNL_PT_UINT, }, +}; + +struct ynl_policy_nest ulp_ddp_caps_nest = { + .max_attr = ULP_DDP_A_CAPS_MAX, + .table = ulp_ddp_caps_policy, +}; + +struct ynl_policy_attr ulp_ddp_stats_policy[ULP_DDP_A_STATS_MAX + 1] = { + [ULP_DDP_A_STATS_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, }, + [ULP_DDP_A_STATS_RX_NVME_TCP_SK_ADD] = { .name = "rx-nvme-tcp-sk-add", .type = YNL_PT_UINT, }, + [ULP_DDP_A_STATS_RX_NVME_TCP_SK_ADD_FAIL] = { .name = "rx-nvme-tcp-sk-add-fail", .type = YNL_PT_UINT, }, + [ULP_DDP_A_STATS_RX_NVME_TCP_SK_DEL] = { .name = "rx-nvme-tcp-sk-del", .type = YNL_PT_UINT, }, + [ULP_DDP_A_STATS_RX_NVME_TCP_SETUP] = { .name = "rx-nvme-tcp-setup", .type = YNL_PT_UINT, }, + [ULP_DDP_A_STATS_RX_NVME_TCP_SETUP_FAIL] = { .name = "rx-nvme-tcp-setup-fail", .type = YNL_PT_UINT, }, + [ULP_DDP_A_STATS_RX_NVME_TCP_TEARDOWN] = { .name = "rx-nvme-tcp-teardown", .type = YNL_PT_UINT, }, + [ULP_DDP_A_STATS_RX_NVME_TCP_DROP] = { .name = "rx-nvme-tcp-drop", .type = YNL_PT_UINT, }, + [ULP_DDP_A_STATS_RX_NVME_TCP_RESYNC] = { .name = "rx-nvme-tcp-resync", .type = YNL_PT_UINT, }, + [ULP_DDP_A_STATS_RX_NVME_TCP_PACKETS] = { .name = "rx-nvme-tcp-packets", .type = YNL_PT_UINT, }, + [ULP_DDP_A_STATS_RX_NVME_TCP_BYTES] = { .name = "rx-nvme-tcp-bytes", .type = YNL_PT_UINT, }, +}; + +struct ynl_policy_nest ulp_ddp_stats_nest = { + .max_attr = ULP_DDP_A_STATS_MAX, + .table = ulp_ddp_stats_policy, +}; + +/* Common nested types */ +/* ============== ULP_DDP_CMD_CAPS_GET ============== */ +/* ULP_DDP_CMD_CAPS_GET - do */ +void ulp_ddp_caps_get_req_free(struct ulp_ddp_caps_get_req *req) +{ + free(req); +} + +void ulp_ddp_caps_get_rsp_free(struct ulp_ddp_caps_get_rsp *rsp) +{ + free(rsp); +} + +int ulp_ddp_caps_get_rsp_parse(const struct nlmsghdr *nlh, void *data) +{ + struct ynl_parse_arg *yarg = data; + struct ulp_ddp_caps_get_rsp *dst; + const struct nlattr *attr; + + dst = yarg->data; + + mnl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = mnl_attr_get_type(attr); + + if (type == ULP_DDP_A_CAPS_IFINDEX) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.ifindex = 1; + dst->ifindex = mnl_attr_get_u32(attr); + } else if (type == ULP_DDP_A_CAPS_HW) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.hw = 1; + dst->hw = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_CAPS_ACTIVE) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.active = 1; + dst->active = mnl_attr_get_uint(attr); + } + } + + return MNL_CB_OK; +} + +struct ulp_ddp_caps_get_rsp * +ulp_ddp_caps_get(struct ynl_sock *ys, struct ulp_ddp_caps_get_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct ulp_ddp_caps_get_rsp *rsp; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, ULP_DDP_CMD_CAPS_GET, 1); + ys->req_policy = &ulp_ddp_caps_nest; + yrs.yarg.rsp_policy = &ulp_ddp_caps_nest; + + if (req->_present.ifindex) + mnl_attr_put_u32(nlh, ULP_DDP_A_CAPS_IFINDEX, req->ifindex); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = ulp_ddp_caps_get_rsp_parse; + yrs.rsp_cmd = ULP_DDP_CMD_CAPS_GET; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + ulp_ddp_caps_get_rsp_free(rsp); + return NULL; +} + +/* ULP_DDP_CMD_CAPS_GET - notify */ +void ulp_ddp_caps_get_ntf_free(struct ulp_ddp_caps_get_ntf *rsp) +{ + free(rsp); +} + +/* ============== ULP_DDP_CMD_STATS_GET ============== */ +/* ULP_DDP_CMD_STATS_GET - do */ +void ulp_ddp_stats_get_req_free(struct ulp_ddp_stats_get_req *req) +{ + free(req); +} + +void ulp_ddp_stats_get_rsp_free(struct ulp_ddp_stats_get_rsp *rsp) +{ + free(rsp); +} + +int ulp_ddp_stats_get_rsp_parse(const struct nlmsghdr *nlh, void *data) +{ + struct ulp_ddp_stats_get_rsp *dst; + struct ynl_parse_arg *yarg = data; + const struct nlattr *attr; + + dst = yarg->data; + + mnl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = mnl_attr_get_type(attr); + + if (type == ULP_DDP_A_STATS_IFINDEX) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.ifindex = 1; + dst->ifindex = mnl_attr_get_u32(attr); + } else if (type == ULP_DDP_A_STATS_RX_NVME_TCP_SK_ADD) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.rx_nvme_tcp_sk_add = 1; + dst->rx_nvme_tcp_sk_add = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_STATS_RX_NVME_TCP_SK_ADD_FAIL) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.rx_nvme_tcp_sk_add_fail = 1; + dst->rx_nvme_tcp_sk_add_fail = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_STATS_RX_NVME_TCP_SK_DEL) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.rx_nvme_tcp_sk_del = 1; + dst->rx_nvme_tcp_sk_del = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_STATS_RX_NVME_TCP_SETUP) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.rx_nvme_tcp_setup = 1; + dst->rx_nvme_tcp_setup = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_STATS_RX_NVME_TCP_SETUP_FAIL) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.rx_nvme_tcp_setup_fail = 1; + dst->rx_nvme_tcp_setup_fail = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_STATS_RX_NVME_TCP_TEARDOWN) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.rx_nvme_tcp_teardown = 1; + dst->rx_nvme_tcp_teardown = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_STATS_RX_NVME_TCP_DROP) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.rx_nvme_tcp_drop = 1; + dst->rx_nvme_tcp_drop = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_STATS_RX_NVME_TCP_RESYNC) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.rx_nvme_tcp_resync = 1; + dst->rx_nvme_tcp_resync = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_STATS_RX_NVME_TCP_PACKETS) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.rx_nvme_tcp_packets = 1; + dst->rx_nvme_tcp_packets = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_STATS_RX_NVME_TCP_BYTES) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.rx_nvme_tcp_bytes = 1; + dst->rx_nvme_tcp_bytes = mnl_attr_get_uint(attr); + } + } + + return MNL_CB_OK; +} + +struct ulp_ddp_stats_get_rsp * +ulp_ddp_stats_get(struct ynl_sock *ys, struct ulp_ddp_stats_get_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct ulp_ddp_stats_get_rsp *rsp; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, ULP_DDP_CMD_STATS_GET, 1); + ys->req_policy = &ulp_ddp_stats_nest; + yrs.yarg.rsp_policy = &ulp_ddp_stats_nest; + + if (req->_present.ifindex) + mnl_attr_put_u32(nlh, ULP_DDP_A_STATS_IFINDEX, req->ifindex); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = ulp_ddp_stats_get_rsp_parse; + yrs.rsp_cmd = ULP_DDP_CMD_STATS_GET; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + ulp_ddp_stats_get_rsp_free(rsp); + return NULL; +} + +/* ============== ULP_DDP_CMD_CAPS_SET ============== */ +/* ULP_DDP_CMD_CAPS_SET - do */ +void ulp_ddp_caps_set_req_free(struct ulp_ddp_caps_set_req *req) +{ + free(req); +} + +void ulp_ddp_caps_set_rsp_free(struct ulp_ddp_caps_set_rsp *rsp) +{ + free(rsp); +} + +int ulp_ddp_caps_set_rsp_parse(const struct nlmsghdr *nlh, void *data) +{ + struct ynl_parse_arg *yarg = data; + struct ulp_ddp_caps_set_rsp *dst; + const struct nlattr *attr; + + dst = yarg->data; + + mnl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = mnl_attr_get_type(attr); + + if (type == ULP_DDP_A_CAPS_IFINDEX) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.ifindex = 1; + dst->ifindex = mnl_attr_get_u32(attr); + } else if (type == ULP_DDP_A_CAPS_HW) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.hw = 1; + dst->hw = mnl_attr_get_uint(attr); + } else if (type == ULP_DDP_A_CAPS_ACTIVE) { + if (ynl_attr_validate(yarg, attr)) + return MNL_CB_ERROR; + dst->_present.active = 1; + dst->active = mnl_attr_get_uint(attr); + } + } + + return MNL_CB_OK; +} + +struct ulp_ddp_caps_set_rsp * +ulp_ddp_caps_set(struct ynl_sock *ys, struct ulp_ddp_caps_set_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct ulp_ddp_caps_set_rsp *rsp; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, ULP_DDP_CMD_CAPS_SET, 1); + ys->req_policy = &ulp_ddp_caps_nest; + yrs.yarg.rsp_policy = &ulp_ddp_caps_nest; + + if (req->_present.ifindex) + mnl_attr_put_u32(nlh, ULP_DDP_A_CAPS_IFINDEX, req->ifindex); + if (req->_present.wanted) + mnl_attr_put_uint(nlh, ULP_DDP_A_CAPS_WANTED, req->wanted); + if (req->_present.wanted_mask) + mnl_attr_put_uint(nlh, ULP_DDP_A_CAPS_WANTED_MASK, req->wanted_mask); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = ulp_ddp_caps_set_rsp_parse; + yrs.rsp_cmd = ULP_DDP_CMD_CAPS_SET; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + ulp_ddp_caps_set_rsp_free(rsp); + return NULL; +} + +static const struct ynl_ntf_info ulp_ddp_ntf_info[] = { + [ULP_DDP_CMD_CAPS_SET_NTF] = { + .alloc_sz = sizeof(struct ulp_ddp_caps_get_ntf), + .cb = ulp_ddp_caps_get_rsp_parse, + .policy = &ulp_ddp_caps_nest, + .free = (void *)ulp_ddp_caps_get_ntf_free, + }, +}; + +const struct ynl_family ynl_ulp_ddp_family = { + .name = "ulp_ddp", + .hdr_len = sizeof(struct genlmsghdr), + .ntf_info = ulp_ddp_ntf_info, + .ntf_info_size = MNL_ARRAY_SIZE(ulp_ddp_ntf_info), +}; diff --git a/home/nipa/nipa_out/830699/ynl/new-code/ulp_ddp-user.h b/home/nipa/nipa_out/830699/ynl/new-code/ulp_ddp-user.h new file mode 100644 index 000000000000..2f5057489779 --- /dev/null +++ b/home/nipa/nipa_out/830699/ynl/new-code/ulp_ddp-user.h @@ -0,0 +1,199 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/ulp_ddp.yaml */ +/* YNL-GEN user header */ + +#ifndef _LINUX_ULP_DDP_GEN_H +#define _LINUX_ULP_DDP_GEN_H + +#include +#include +#include +#include + +struct ynl_sock; + +extern const struct ynl_family ynl_ulp_ddp_family; + +/* Enums */ +const char *ulp_ddp_op_str(int op); +const char *ulp_ddp_cap_str(enum ulp_ddp_cap value); + +/* Common nested types */ +/* ============== ULP_DDP_CMD_CAPS_GET ============== */ +/* ULP_DDP_CMD_CAPS_GET - do */ +struct ulp_ddp_caps_get_req { + struct { + __u32 ifindex:1; + } _present; + + __u32 ifindex; +}; + +static inline struct ulp_ddp_caps_get_req *ulp_ddp_caps_get_req_alloc(void) +{ + return calloc(1, sizeof(struct ulp_ddp_caps_get_req)); +} +void ulp_ddp_caps_get_req_free(struct ulp_ddp_caps_get_req *req); + +static inline void +ulp_ddp_caps_get_req_set_ifindex(struct ulp_ddp_caps_get_req *req, + __u32 ifindex) +{ + req->_present.ifindex = 1; + req->ifindex = ifindex; +} + +struct ulp_ddp_caps_get_rsp { + struct { + __u32 ifindex:1; + __u32 hw:1; + __u32 active:1; + } _present; + + __u32 ifindex; + __u64 hw; + __u64 active; +}; + +void ulp_ddp_caps_get_rsp_free(struct ulp_ddp_caps_get_rsp *rsp); + +/* + * Get ULP DDP capabilities. + */ +struct ulp_ddp_caps_get_rsp * +ulp_ddp_caps_get(struct ynl_sock *ys, struct ulp_ddp_caps_get_req *req); + +/* ULP_DDP_CMD_CAPS_GET - notify */ +struct ulp_ddp_caps_get_ntf { + __u16 family; + __u8 cmd; + struct ynl_ntf_base_type *next; + void (*free)(struct ulp_ddp_caps_get_ntf *ntf); + struct ulp_ddp_caps_get_rsp obj __attribute__((aligned(8))); +}; + +void ulp_ddp_caps_get_ntf_free(struct ulp_ddp_caps_get_ntf *rsp); + +/* ============== ULP_DDP_CMD_STATS_GET ============== */ +/* ULP_DDP_CMD_STATS_GET - do */ +struct ulp_ddp_stats_get_req { + struct { + __u32 ifindex:1; + } _present; + + __u32 ifindex; +}; + +static inline struct ulp_ddp_stats_get_req *ulp_ddp_stats_get_req_alloc(void) +{ + return calloc(1, sizeof(struct ulp_ddp_stats_get_req)); +} +void ulp_ddp_stats_get_req_free(struct ulp_ddp_stats_get_req *req); + +static inline void +ulp_ddp_stats_get_req_set_ifindex(struct ulp_ddp_stats_get_req *req, + __u32 ifindex) +{ + req->_present.ifindex = 1; + req->ifindex = ifindex; +} + +struct ulp_ddp_stats_get_rsp { + struct { + __u32 ifindex:1; + __u32 rx_nvme_tcp_sk_add:1; + __u32 rx_nvme_tcp_sk_add_fail:1; + __u32 rx_nvme_tcp_sk_del:1; + __u32 rx_nvme_tcp_setup:1; + __u32 rx_nvme_tcp_setup_fail:1; + __u32 rx_nvme_tcp_teardown:1; + __u32 rx_nvme_tcp_drop:1; + __u32 rx_nvme_tcp_resync:1; + __u32 rx_nvme_tcp_packets:1; + __u32 rx_nvme_tcp_bytes:1; + } _present; + + __u32 ifindex; + __u64 rx_nvme_tcp_sk_add; + __u64 rx_nvme_tcp_sk_add_fail; + __u64 rx_nvme_tcp_sk_del; + __u64 rx_nvme_tcp_setup; + __u64 rx_nvme_tcp_setup_fail; + __u64 rx_nvme_tcp_teardown; + __u64 rx_nvme_tcp_drop; + __u64 rx_nvme_tcp_resync; + __u64 rx_nvme_tcp_packets; + __u64 rx_nvme_tcp_bytes; +}; + +void ulp_ddp_stats_get_rsp_free(struct ulp_ddp_stats_get_rsp *rsp); + +/* + * Get ULP DDP stats. + */ +struct ulp_ddp_stats_get_rsp * +ulp_ddp_stats_get(struct ynl_sock *ys, struct ulp_ddp_stats_get_req *req); + +/* ============== ULP_DDP_CMD_CAPS_SET ============== */ +/* ULP_DDP_CMD_CAPS_SET - do */ +struct ulp_ddp_caps_set_req { + struct { + __u32 ifindex:1; + __u32 wanted:1; + __u32 wanted_mask:1; + } _present; + + __u32 ifindex; + __u64 wanted; + __u64 wanted_mask; +}; + +static inline struct ulp_ddp_caps_set_req *ulp_ddp_caps_set_req_alloc(void) +{ + return calloc(1, sizeof(struct ulp_ddp_caps_set_req)); +} +void ulp_ddp_caps_set_req_free(struct ulp_ddp_caps_set_req *req); + +static inline void +ulp_ddp_caps_set_req_set_ifindex(struct ulp_ddp_caps_set_req *req, + __u32 ifindex) +{ + req->_present.ifindex = 1; + req->ifindex = ifindex; +} +static inline void +ulp_ddp_caps_set_req_set_wanted(struct ulp_ddp_caps_set_req *req, __u64 wanted) +{ + req->_present.wanted = 1; + req->wanted = wanted; +} +static inline void +ulp_ddp_caps_set_req_set_wanted_mask(struct ulp_ddp_caps_set_req *req, + __u64 wanted_mask) +{ + req->_present.wanted_mask = 1; + req->wanted_mask = wanted_mask; +} + +struct ulp_ddp_caps_set_rsp { + struct { + __u32 ifindex:1; + __u32 hw:1; + __u32 active:1; + } _present; + + __u32 ifindex; + __u64 hw; + __u64 active; +}; + +void ulp_ddp_caps_set_rsp_free(struct ulp_ddp_caps_set_rsp *rsp); + +/* + * Set ULP DDP capabilities. + */ +struct ulp_ddp_caps_set_rsp * +ulp_ddp_caps_set(struct ynl_sock *ys, struct ulp_ddp_caps_set_req *req); + +#endif /* _LINUX_ULP_DDP_GEN_H */