diff --git a/home/nipa/nipa_out/981306/ynl/old-code/ethtool-user.c b/home/nipa/nipa_out/981306/ynl/new-code/ethtool-user.c index f06ccd8a73ba..7ba9b07e53cc 100644 --- a/home/nipa/nipa_out/981306/ynl/old-code/ethtool-user.c +++ b/home/nipa/nipa_out/981306/ynl/new-code/ethtool-user.c @@ -201,6 +201,18 @@ const char *ethtool_pse_event_str(enum ethtool_pse_event value) return ethtool_pse_event_strmap[value]; } +static const char * const ethtool_input_xfrm_strmap[] = { + [1] = "sym-xor", + [2] = "sym-or-xor", +}; + +const char *ethtool_input_xfrm_str(int value) +{ + if (value < 0 || value >= (int)YNL_ARRAY_SIZE(ethtool_input_xfrm_strmap)) + return NULL; + return ethtool_input_xfrm_strmap[value]; +} + static const char * const ethtool_rxfh_fields_strmap[] = { [1] = "l2da", [2] = "vlan", @@ -1329,6 +1341,71 @@ void ethtool_flow_free(struct ethtool_flow *obj) { } +int ethtool_flow_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct ethtool_flow *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.ether) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_ETHER, obj->ether); + if (obj->_present.ip4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_IP4, obj->ip4); + if (obj->_present.ip6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_IP6, obj->ip6); + if (obj->_present.tcp4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_TCP4, obj->tcp4); + if (obj->_present.tcp6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_TCP6, obj->tcp6); + if (obj->_present.udp4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_UDP4, obj->udp4); + if (obj->_present.udp6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_UDP6, obj->udp6); + if (obj->_present.sctp4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_SCTP4, obj->sctp4); + if (obj->_present.sctp6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_SCTP6, obj->sctp6); + if (obj->_present.ah4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_AH4, obj->ah4); + if (obj->_present.ah6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_AH6, obj->ah6); + if (obj->_present.esp4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_ESP4, obj->esp4); + if (obj->_present.esp6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_ESP6, obj->esp6); + if (obj->_present.ah_esp4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_AH_ESP4, obj->ah_esp4); + if (obj->_present.ah_esp6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_AH_ESP6, obj->ah_esp6); + if (obj->_present.gtpu4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPU4, obj->gtpu4); + if (obj->_present.gtpu6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPU6, obj->gtpu6); + if (obj->_present.gtpc4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPC4, obj->gtpc4); + if (obj->_present.gtpc6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPC6, obj->gtpc6); + if (obj->_present.gtpc_teid4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPC_TEID4, obj->gtpc_teid4); + if (obj->_present.gtpc_teid6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPC_TEID6, obj->gtpc_teid6); + if (obj->_present.gtpu_eh4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPU_EH4, obj->gtpu_eh4); + if (obj->_present.gtpu_eh6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPU_EH6, obj->gtpu_eh6); + if (obj->_present.gtpu_ul4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPU_UL4, obj->gtpu_ul4); + if (obj->_present.gtpu_ul6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPU_UL6, obj->gtpu_ul6); + if (obj->_present.gtpu_dl4) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPU_DL4, obj->gtpu_dl4); + if (obj->_present.gtpu_dl6) + ynl_attr_put_uint(nlh, ETHTOOL_A_FLOW_GTPU_DL6, obj->gtpu_dl6); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + int ethtool_flow_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) { struct ethtool_flow *dst = yarg->data; @@ -7943,6 +8020,52 @@ ethtool_tsconfig_set(struct ynl_sock *ys, struct ethtool_tsconfig_set_req *req) return NULL; } +/* ============== ETHTOOL_MSG_RSS_SET ============== */ +/* ETHTOOL_MSG_RSS_SET - do */ +void ethtool_rss_set_req_free(struct ethtool_rss_set_req *req) +{ + ethtool_header_free(&req->header); + free(req->indir); + free(req->hkey); + ethtool_flow_free(&req->flow_hash); + free(req); +} + +int ethtool_rss_set(struct ynl_sock *ys, struct ethtool_rss_set_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + unsigned int i; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, ETHTOOL_MSG_RSS_SET, 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); + 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); + if (req->_present.flow_hash) + ethtool_flow_put(nlh, ETHTOOL_A_RSS_FLOW_HASH, &req->flow_hash); + + 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) diff --git a/home/nipa/nipa_out/981306/ynl/old-code/ethtool-user.h b/home/nipa/nipa_out/981306/ynl/new-code/ethtool-user.h index 67943809f9d8..7dea8e95b6ad 100644 --- a/home/nipa/nipa_out/981306/ynl/old-code/ethtool-user.h +++ b/home/nipa/nipa_out/981306/ynl/new-code/ethtool-user.h @@ -30,6 +30,7 @@ const char *ethtool_phy_upstream_type_str(enum phy_upstream value); const char *ethtool_tcp_data_split_str(enum ethtool_tcp_data_split value); const char *ethtool_hwtstamp_source_str(enum hwtstamp_source value); const char *ethtool_pse_event_str(enum ethtool_pse_event value); +const char *ethtool_input_xfrm_str(int value); const char *ethtool_rxfh_fields_str(int value); /* Common nested types */ @@ -5958,7 +5959,7 @@ struct ethtool_rss_get_rsp { __u32 hfunc; __u32 *indir; void *hkey; - __u32 input_xfrm; + int input_xfrm; struct ethtool_flow flow_hash; }; @@ -7385,6 +7386,333 @@ void ethtool_tsconfig_set_rsp_free(struct ethtool_tsconfig_set_rsp *rsp); struct ethtool_tsconfig_set_rsp * ethtool_tsconfig_set(struct ynl_sock *ys, struct ethtool_tsconfig_set_req *req); +/* ============== ETHTOOL_MSG_RSS_SET ============== */ +/* ETHTOOL_MSG_RSS_SET - do */ +struct ethtool_rss_set_req { + struct { + __u32 header:1; + __u32 context:1; + __u32 hfunc:1; + __u32 input_xfrm:1; + __u32 flow_hash:1; + } _present; + struct { + __u32 hkey; + } _len; + struct { + __u32 indir; + } _count; + + struct ethtool_header header; + __u32 context; + __u32 hfunc; + __u32 *indir; + void *hkey; + int input_xfrm; + struct ethtool_flow flow_hash; +}; + +static inline struct ethtool_rss_set_req *ethtool_rss_set_req_alloc(void) +{ + return calloc(1, sizeof(struct ethtool_rss_set_req)); +} +void ethtool_rss_set_req_free(struct ethtool_rss_set_req *req); + +static inline void +ethtool_rss_set_req_set_header_dev_index(struct ethtool_rss_set_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_set_req_set_header_dev_name(struct ethtool_rss_set_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_set_req_set_header_flags(struct ethtool_rss_set_req *req, + __u32 flags) +{ + req->_present.header = 1; + req->header._present.flags = 1; + req->header.flags = flags; +} +static inline void +ethtool_rss_set_req_set_header_phy_index(struct ethtool_rss_set_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_set_req_set_context(struct ethtool_rss_set_req *req, __u32 context) +{ + req->_present.context = 1; + req->context = context; +} +static inline void +ethtool_rss_set_req_set_hfunc(struct ethtool_rss_set_req *req, __u32 hfunc) +{ + req->_present.hfunc = 1; + req->hfunc = hfunc; +} +static inline void +ethtool_rss_set_req_set_indir(struct ethtool_rss_set_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_set_req_set_hkey(struct ethtool_rss_set_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_set_req_set_input_xfrm(struct ethtool_rss_set_req *req, + int input_xfrm) +{ + req->_present.input_xfrm = 1; + req->input_xfrm = input_xfrm; +} +static inline void +ethtool_rss_set_req_set_flow_hash_ether(struct ethtool_rss_set_req *req, + __u64 ether) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.ether = 1; + req->flow_hash.ether = ether; +} +static inline void +ethtool_rss_set_req_set_flow_hash_ip4(struct ethtool_rss_set_req *req, + __u64 ip4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.ip4 = 1; + req->flow_hash.ip4 = ip4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_ip6(struct ethtool_rss_set_req *req, + __u64 ip6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.ip6 = 1; + req->flow_hash.ip6 = ip6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_tcp4(struct ethtool_rss_set_req *req, + __u64 tcp4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.tcp4 = 1; + req->flow_hash.tcp4 = tcp4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_tcp6(struct ethtool_rss_set_req *req, + __u64 tcp6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.tcp6 = 1; + req->flow_hash.tcp6 = tcp6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_udp4(struct ethtool_rss_set_req *req, + __u64 udp4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.udp4 = 1; + req->flow_hash.udp4 = udp4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_udp6(struct ethtool_rss_set_req *req, + __u64 udp6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.udp6 = 1; + req->flow_hash.udp6 = udp6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_sctp4(struct ethtool_rss_set_req *req, + __u64 sctp4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.sctp4 = 1; + req->flow_hash.sctp4 = sctp4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_sctp6(struct ethtool_rss_set_req *req, + __u64 sctp6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.sctp6 = 1; + req->flow_hash.sctp6 = sctp6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_ah4(struct ethtool_rss_set_req *req, + __u64 ah4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.ah4 = 1; + req->flow_hash.ah4 = ah4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_ah6(struct ethtool_rss_set_req *req, + __u64 ah6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.ah6 = 1; + req->flow_hash.ah6 = ah6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_esp4(struct ethtool_rss_set_req *req, + __u64 esp4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.esp4 = 1; + req->flow_hash.esp4 = esp4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_esp6(struct ethtool_rss_set_req *req, + __u64 esp6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.esp6 = 1; + req->flow_hash.esp6 = esp6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_ah_esp4(struct ethtool_rss_set_req *req, + __u64 ah_esp4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.ah_esp4 = 1; + req->flow_hash.ah_esp4 = ah_esp4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_ah_esp6(struct ethtool_rss_set_req *req, + __u64 ah_esp6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.ah_esp6 = 1; + req->flow_hash.ah_esp6 = ah_esp6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpu4(struct ethtool_rss_set_req *req, + __u64 gtpu4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpu4 = 1; + req->flow_hash.gtpu4 = gtpu4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpu6(struct ethtool_rss_set_req *req, + __u64 gtpu6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpu6 = 1; + req->flow_hash.gtpu6 = gtpu6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpc4(struct ethtool_rss_set_req *req, + __u64 gtpc4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpc4 = 1; + req->flow_hash.gtpc4 = gtpc4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpc6(struct ethtool_rss_set_req *req, + __u64 gtpc6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpc6 = 1; + req->flow_hash.gtpc6 = gtpc6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpc_teid4(struct ethtool_rss_set_req *req, + __u64 gtpc_teid4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpc_teid4 = 1; + req->flow_hash.gtpc_teid4 = gtpc_teid4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpc_teid6(struct ethtool_rss_set_req *req, + __u64 gtpc_teid6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpc_teid6 = 1; + req->flow_hash.gtpc_teid6 = gtpc_teid6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpu_eh4(struct ethtool_rss_set_req *req, + __u64 gtpu_eh4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpu_eh4 = 1; + req->flow_hash.gtpu_eh4 = gtpu_eh4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpu_eh6(struct ethtool_rss_set_req *req, + __u64 gtpu_eh6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpu_eh6 = 1; + req->flow_hash.gtpu_eh6 = gtpu_eh6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpu_ul4(struct ethtool_rss_set_req *req, + __u64 gtpu_ul4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpu_ul4 = 1; + req->flow_hash.gtpu_ul4 = gtpu_ul4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpu_ul6(struct ethtool_rss_set_req *req, + __u64 gtpu_ul6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpu_ul6 = 1; + req->flow_hash.gtpu_ul6 = gtpu_ul6; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpu_dl4(struct ethtool_rss_set_req *req, + __u64 gtpu_dl4) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpu_dl4 = 1; + req->flow_hash.gtpu_dl4 = gtpu_dl4; +} +static inline void +ethtool_rss_set_req_set_flow_hash_gtpu_dl6(struct ethtool_rss_set_req *req, + __u64 gtpu_dl6) +{ + req->_present.flow_hash = 1; + req->flow_hash._present.gtpu_dl6 = 1; + req->flow_hash.gtpu_dl6 = gtpu_dl6; +} + +/* + * Set RSS params. + */ +int ethtool_rss_set(struct ynl_sock *ys, struct ethtool_rss_set_req *req); + /* ETHTOOL_MSG_CABLE_TEST_NTF - event */ struct ethtool_cable_test_ntf_rsp { struct {