diff --git a/home/nipa/nipa_out/983554/ynl/old-code/ethtool-user.c b/home/nipa/nipa_out/983554/ynl/new-code/ethtool-user.c index 8af9746d9b4d..485d9224547f 100644 --- a/home/nipa/nipa_out/983554/ynl/old-code/ethtool-user.c +++ b/home/nipa/nipa_out/983554/ynl/new-code/ethtool-user.c @@ -66,6 +66,9 @@ static const char * const ethtool_op_strmap[] = { [48] = "tsconfig-set", [49] = "pse-ntf", [50] = "rss-ntf", + [51] = "rss-create-act", + [52] = "rss-create-ntf", + [53] = "rss-delete-ntf", }; const char *ethtool_op_str(int op) @@ -8067,6 +8070,174 @@ int ethtool_rss_set(struct ynl_sock *ys, struct ethtool_rss_set_req *req) return 0; } +/* ============== ETHTOOL_MSG_RSS_CREATE_ACT ============== */ +/* ETHTOOL_MSG_RSS_CREATE_ACT - do */ +void ethtool_rss_create_act_req_free(struct ethtool_rss_create_act_req *req) +{ + ethtool_header_free(&req->header); + free(req->indir); + free(req->hkey); + free(req); +} + +void ethtool_rss_create_act_rsp_free(struct ethtool_rss_create_act_rsp *rsp) +{ + ethtool_header_free(&rsp->header); + free(rsp->indir); + free(rsp->hkey); + free(rsp); +} + +int ethtool_rss_create_act_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct ethtool_rss_create_act_rsp *dst; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + dst = yarg->data; + parg.ys = yarg->ys; + + ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = ynl_attr_type(attr); + + if (type == ETHTOOL_A_RSS_HEADER) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.header = 1; + + parg.rsp_policy = ðtool_header_nest; + parg.data = &dst->header; + if (ethtool_header_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == ETHTOOL_A_RSS_CONTEXT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.context = 1; + dst->context = ynl_attr_get_u32(attr); + } else if (type == ETHTOOL_A_RSS_HFUNC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.hfunc = 1; + dst->hfunc = ynl_attr_get_u32(attr); + } else if (type == ETHTOOL_A_RSS_INDIR) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_count.indir = len / sizeof(__u32); + len = dst->_count.indir * sizeof(__u32); + dst->indir = malloc(len); + memcpy(dst->indir, ynl_attr_data(attr), len); + } else if (type == ETHTOOL_A_RSS_HKEY) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.hkey = len; + dst->hkey = malloc(len); + memcpy(dst->hkey, ynl_attr_data(attr), len); + } else if (type == ETHTOOL_A_RSS_INPUT_XFRM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.input_xfrm = 1; + dst->input_xfrm = ynl_attr_get_u32(attr); + } + } + + return YNL_PARSE_CB_OK; +} + +struct ethtool_rss_create_act_rsp * +ethtool_rss_create_act(struct ynl_sock *ys, + struct ethtool_rss_create_act_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct ethtool_rss_create_act_rsp *rsp; + struct nlmsghdr *nlh; + unsigned int i; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_RSS_CREATE_ACT, 1); + ys->req_policy = ðtool_rss_nest; + ys->req_hdr_len = ys->family->hdr_len; + yrs.yarg.rsp_policy = ðtool_rss_nest; + + if (req->_present.header) + ethtool_header_put(nlh, ETHTOOL_A_RSS_HEADER, &req->header); + if (req->_present.context) + ynl_attr_put_u32(nlh, ETHTOOL_A_RSS_CONTEXT, req->context); + if (req->_present.hfunc) + ynl_attr_put_u32(nlh, ETHTOOL_A_RSS_HFUNC, req->hfunc); + if (req->_count.indir) { + i = req->_count.indir * sizeof(__u32); + ynl_attr_put(nlh, ETHTOOL_A_RSS_INDIR, req->indir, i); + } + if (req->_len.hkey) + ynl_attr_put(nlh, ETHTOOL_A_RSS_HKEY, req->hkey, req->_len.hkey); + if (req->_present.input_xfrm) + ynl_attr_put_u32(nlh, ETHTOOL_A_RSS_INPUT_XFRM, req->input_xfrm); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = ethtool_rss_create_act_rsp_parse; + yrs.rsp_cmd = 51; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + ethtool_rss_create_act_rsp_free(rsp); + return NULL; +} + +/* ETHTOOL_MSG_RSS_CREATE_ACT - notify */ +void ethtool_rss_create_act_ntf_free(struct ethtool_rss_create_act_ntf *rsp) +{ + ethtool_header_free(&rsp->obj.header); + free(rsp->obj.indir); + free(rsp->obj.hkey); + free(rsp); +} + +/* ============== ETHTOOL_MSG_RSS_DELETE_ACT ============== */ +/* ETHTOOL_MSG_RSS_DELETE_ACT - do */ +void ethtool_rss_delete_act_req_free(struct ethtool_rss_delete_act_req *req) +{ + ethtool_header_free(&req->header); + free(req); +} + +int ethtool_rss_delete_act(struct ynl_sock *ys, + struct ethtool_rss_delete_act_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_RSS_DELETE_ACT, 1); + ys->req_policy = ðtool_rss_nest; + ys->req_hdr_len = ys->family->hdr_len; + + if (req->_present.header) + ethtool_header_put(nlh, ETHTOOL_A_RSS_HEADER, &req->header); + if (req->_present.context) + ynl_attr_put_u32(nlh, ETHTOOL_A_RSS_CONTEXT, req->context); + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + return -1; + + return 0; +} + /* ETHTOOL_MSG_CABLE_TEST_NTF - event */ int ethtool_cable_test_ntf_rsp_parse(const struct nlmsghdr *nlh, struct ynl_parse_arg *yarg) @@ -8259,6 +8430,46 @@ void ethtool_pse_ntf_free(struct ethtool_pse_ntf *rsp) free(rsp); } +/* ETHTOOL_MSG_RSS_DELETE_NTF - event */ +int ethtool_rss_delete_ntf_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct ethtool_rss_delete_ntf_rsp *dst; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + dst = yarg->data; + parg.ys = yarg->ys; + + ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = ynl_attr_type(attr); + + if (type == ETHTOOL_A_RSS_HEADER) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.header = 1; + + parg.rsp_policy = ðtool_header_nest; + parg.data = &dst->header; + if (ethtool_header_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == ETHTOOL_A_RSS_CONTEXT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.context = 1; + dst->context = ynl_attr_get_u32(attr); + } + } + + return YNL_PARSE_CB_OK; +} + +void ethtool_rss_delete_ntf_free(struct ethtool_rss_delete_ntf *rsp) +{ + ethtool_header_free(&rsp->obj.header); + free(rsp); +} + static const struct ynl_ntf_info ethtool_ntf_info[] = { [ETHTOOL_MSG_LINKINFO_NTF] = { .alloc_sz = sizeof(struct ethtool_linkinfo_get_ntf), @@ -8386,6 +8597,18 @@ static const struct ynl_ntf_info ethtool_ntf_info[] = { .policy = ðtool_rss_nest, .free = (void *)ethtool_rss_get_ntf_free, }, + [ETHTOOL_MSG_RSS_CREATE_NTF] = { + .alloc_sz = sizeof(struct ethtool_rss_create_act_ntf), + .cb = ethtool_rss_create_act_rsp_parse, + .policy = ðtool_rss_nest, + .free = (void *)ethtool_rss_create_act_ntf_free, + }, + [ETHTOOL_MSG_RSS_DELETE_NTF] = { + .alloc_sz = sizeof(struct ethtool_rss_delete_ntf), + .cb = ethtool_rss_delete_ntf_rsp_parse, + .policy = ðtool_rss_nest, + .free = (void *)ethtool_rss_delete_ntf_free, + }, }; const struct ynl_family ynl_ethtool_family = { diff --git a/home/nipa/nipa_out/983554/ynl/old-code/ethtool-user.h b/home/nipa/nipa_out/983554/ynl/new-code/ethtool-user.h index 0491547826af..56b3b29fa283 100644 --- a/home/nipa/nipa_out/983554/ynl/old-code/ethtool-user.h +++ b/home/nipa/nipa_out/983554/ynl/new-code/ethtool-user.h @@ -7713,6 +7713,223 @@ ethtool_rss_set_req_set_flow_hash_gtpu_dl6(struct ethtool_rss_set_req *req, */ int ethtool_rss_set(struct ynl_sock *ys, struct ethtool_rss_set_req *req); +/* ============== ETHTOOL_MSG_RSS_CREATE_ACT ============== */ +/* ETHTOOL_MSG_RSS_CREATE_ACT - do */ +struct ethtool_rss_create_act_req { + struct { + __u32 header:1; + __u32 context:1; + __u32 hfunc:1; + __u32 input_xfrm:1; + } _present; + struct { + __u32 hkey; + } _len; + struct { + __u32 indir; + } _count; + + struct ethtool_header header; + __u32 context; + __u32 hfunc; + __u32 *indir; + void *hkey; + __u32 input_xfrm; +}; + +static inline struct ethtool_rss_create_act_req * +ethtool_rss_create_act_req_alloc(void) +{ + return calloc(1, sizeof(struct ethtool_rss_create_act_req)); +} +void ethtool_rss_create_act_req_free(struct ethtool_rss_create_act_req *req); + +static inline void +ethtool_rss_create_act_req_set_header_dev_index(struct ethtool_rss_create_act_req *req, + __u32 dev_index) +{ + req->_present.header = 1; + req->header._present.dev_index = 1; + req->header.dev_index = dev_index; +} +static inline void +ethtool_rss_create_act_req_set_header_dev_name(struct ethtool_rss_create_act_req *req, + const char *dev_name) +{ + req->_present.header = 1; + free(req->header.dev_name); + req->header._len.dev_name = strlen(dev_name); + req->header.dev_name = malloc(req->header._len.dev_name + 1); + memcpy(req->header.dev_name, dev_name, req->header._len.dev_name); + req->header.dev_name[req->header._len.dev_name] = 0; +} +static inline void +ethtool_rss_create_act_req_set_header_flags(struct ethtool_rss_create_act_req *req, + __u32 flags) +{ + req->_present.header = 1; + req->header._present.flags = 1; + req->header.flags = flags; +} +static inline void +ethtool_rss_create_act_req_set_header_phy_index(struct ethtool_rss_create_act_req *req, + __u32 phy_index) +{ + req->_present.header = 1; + req->header._present.phy_index = 1; + req->header.phy_index = phy_index; +} +static inline void +ethtool_rss_create_act_req_set_context(struct ethtool_rss_create_act_req *req, + __u32 context) +{ + req->_present.context = 1; + req->context = context; +} +static inline void +ethtool_rss_create_act_req_set_hfunc(struct ethtool_rss_create_act_req *req, + __u32 hfunc) +{ + req->_present.hfunc = 1; + req->hfunc = hfunc; +} +static inline void +ethtool_rss_create_act_req_set_indir(struct ethtool_rss_create_act_req *req, + __u32 *indir, size_t count) +{ + free(req->indir); + req->_count.indir = count; + count *= sizeof(__u32); + req->indir = malloc(count); + memcpy(req->indir, indir, count); +} +static inline void +ethtool_rss_create_act_req_set_hkey(struct ethtool_rss_create_act_req *req, + const void *hkey, size_t len) +{ + free(req->hkey); + req->_len.hkey = len; + req->hkey = malloc(req->_len.hkey); + memcpy(req->hkey, hkey, req->_len.hkey); +} +static inline void +ethtool_rss_create_act_req_set_input_xfrm(struct ethtool_rss_create_act_req *req, + __u32 input_xfrm) +{ + req->_present.input_xfrm = 1; + req->input_xfrm = input_xfrm; +} + +struct ethtool_rss_create_act_rsp { + struct { + __u32 header:1; + __u32 context:1; + __u32 hfunc:1; + __u32 input_xfrm:1; + } _present; + struct { + __u32 hkey; + } _len; + struct { + __u32 indir; + } _count; + + struct ethtool_header header; + __u32 context; + __u32 hfunc; + __u32 *indir; + void *hkey; + __u32 input_xfrm; +}; + +void ethtool_rss_create_act_rsp_free(struct ethtool_rss_create_act_rsp *rsp); + +/* + * Create an RSS context. + */ +struct ethtool_rss_create_act_rsp * +ethtool_rss_create_act(struct ynl_sock *ys, + struct ethtool_rss_create_act_req *req); + +/* ETHTOOL_MSG_RSS_CREATE_ACT - notify */ +struct ethtool_rss_create_act_ntf { + __u16 family; + __u8 cmd; + struct ynl_ntf_base_type *next; + void (*free)(struct ethtool_rss_create_act_ntf *ntf); + struct ethtool_rss_create_act_rsp obj __attribute__((aligned(8))); +}; + +void ethtool_rss_create_act_ntf_free(struct ethtool_rss_create_act_ntf *rsp); + +/* ============== ETHTOOL_MSG_RSS_DELETE_ACT ============== */ +/* ETHTOOL_MSG_RSS_DELETE_ACT - do */ +struct ethtool_rss_delete_act_req { + struct { + __u32 header:1; + __u32 context:1; + } _present; + + struct ethtool_header header; + __u32 context; +}; + +static inline struct ethtool_rss_delete_act_req * +ethtool_rss_delete_act_req_alloc(void) +{ + return calloc(1, sizeof(struct ethtool_rss_delete_act_req)); +} +void ethtool_rss_delete_act_req_free(struct ethtool_rss_delete_act_req *req); + +static inline void +ethtool_rss_delete_act_req_set_header_dev_index(struct ethtool_rss_delete_act_req *req, + __u32 dev_index) +{ + req->_present.header = 1; + req->header._present.dev_index = 1; + req->header.dev_index = dev_index; +} +static inline void +ethtool_rss_delete_act_req_set_header_dev_name(struct ethtool_rss_delete_act_req *req, + const char *dev_name) +{ + req->_present.header = 1; + free(req->header.dev_name); + req->header._len.dev_name = strlen(dev_name); + req->header.dev_name = malloc(req->header._len.dev_name + 1); + memcpy(req->header.dev_name, dev_name, req->header._len.dev_name); + req->header.dev_name[req->header._len.dev_name] = 0; +} +static inline void +ethtool_rss_delete_act_req_set_header_flags(struct ethtool_rss_delete_act_req *req, + __u32 flags) +{ + req->_present.header = 1; + req->header._present.flags = 1; + req->header.flags = flags; +} +static inline void +ethtool_rss_delete_act_req_set_header_phy_index(struct ethtool_rss_delete_act_req *req, + __u32 phy_index) +{ + req->_present.header = 1; + req->header._present.phy_index = 1; + req->header.phy_index = phy_index; +} +static inline void +ethtool_rss_delete_act_req_set_context(struct ethtool_rss_delete_act_req *req, + __u32 context) +{ + req->_present.context = 1; + req->context = context; +} + +/* + * Delete an RSS context. + */ +int ethtool_rss_delete_act(struct ynl_sock *ys, + struct ethtool_rss_delete_act_req *req); + /* ETHTOOL_MSG_CABLE_TEST_NTF - event */ struct ethtool_cable_test_ntf_rsp { struct { @@ -7807,4 +8024,25 @@ struct ethtool_pse_ntf { void ethtool_pse_ntf_free(struct ethtool_pse_ntf *rsp); +/* ETHTOOL_MSG_RSS_DELETE_NTF - event */ +struct ethtool_rss_delete_ntf_rsp { + struct { + __u32 header:1; + __u32 context:1; + } _present; + + struct ethtool_header header; + __u32 context; +}; + +struct ethtool_rss_delete_ntf { + __u16 family; + __u8 cmd; + struct ynl_ntf_base_type *next; + void (*free)(struct ethtool_rss_delete_ntf *ntf); + struct ethtool_rss_delete_ntf_rsp obj __attribute__((aligned(8))); +}; + +void ethtool_rss_delete_ntf_free(struct ethtool_rss_delete_ntf *rsp); + #endif /* _LINUX_ETHTOOL_GEN_H */