diff --git a/home/nipa/nipa_out/850431/ynl/old-code/ethtool-user.c b/home/nipa/nipa_out/850431/ynl/new-code/ethtool-user.c index ba3e482b7e41..a76aba559afd 100644 --- a/home/nipa/nipa_out/850431/ynl/old-code/ethtool-user.c +++ b/home/nipa/nipa_out/850431/ynl/new-code/ethtool-user.c @@ -177,6 +177,17 @@ struct ynl_policy_nest ethtool_mm_stat_nest = { .table = ethtool_mm_stat_policy, }; +struct ynl_policy_attr ethtool_irq_moderation_policy[ETHTOOL_A_IRQ_MODERATION_MAX + 1] = { + [ETHTOOL_A_IRQ_MODERATION_USEC] = { .name = "usec", .type = YNL_PT_U32, }, + [ETHTOOL_A_IRQ_MODERATION_PKTS] = { .name = "pkts", .type = YNL_PT_U32, }, + [ETHTOOL_A_IRQ_MODERATION_COMPS] = { .name = "comps", .type = YNL_PT_U32, }, +}; + +struct ynl_policy_nest ethtool_irq_moderation_nest = { + .max_attr = ETHTOOL_A_IRQ_MODERATION_MAX, + .table = ethtool_irq_moderation_policy, +}; + struct ynl_policy_attr ethtool_cable_result_policy[ETHTOOL_A_CABLE_RESULT_MAX + 1] = { [ETHTOOL_A_CABLE_RESULT_PAIR] = { .name = "pair", .type = YNL_PT_U8, }, [ETHTOOL_A_CABLE_RESULT_CODE] = { .name = "code", .type = YNL_PT_U8, }, @@ -228,6 +239,15 @@ struct ynl_policy_nest ethtool_string_nest = { .table = ethtool_string_policy, }; +struct ynl_policy_attr ethtool_profile_policy[ETHTOOL_A_PROFILE_MAX + 1] = { + [ETHTOOL_A_PROFILE_IRQ_MODERATION] = { .name = "irq-moderation", .type = YNL_PT_NEST, .nest = ðtool_irq_moderation_nest, }, +}; + +struct ynl_policy_nest ethtool_profile_nest = { + .max_attr = ETHTOOL_A_PROFILE_MAX, + .table = ethtool_profile_policy, +}; + struct ynl_policy_attr ethtool_cable_nest_policy[ETHTOOL_A_CABLE_NEST_MAX + 1] = { [ETHTOOL_A_CABLE_NEST_RESULT] = { .name = "result", .type = YNL_PT_NEST, .nest = ðtool_cable_result_nest, }, [ETHTOOL_A_CABLE_NEST_FAULT_LENGTH] = { .name = "fault-length", .type = YNL_PT_NEST, .nest = ðtool_cable_fault_length_nest, }, @@ -479,6 +499,8 @@ struct ynl_policy_attr ethtool_coalesce_policy[ETHTOOL_A_COALESCE_MAX + 1] = { [ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES] = { .name = "tx-aggr-max-bytes", .type = YNL_PT_U32, }, [ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES] = { .name = "tx-aggr-max-frames", .type = YNL_PT_U32, }, [ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS] = { .name = "tx-aggr-time-usecs", .type = YNL_PT_U32, }, + [ETHTOOL_A_COALESCE_RX_PROFILE] = { .name = "rx-profile", .type = YNL_PT_NEST, .nest = ðtool_profile_nest, }, + [ETHTOOL_A_COALESCE_TX_PROFILE] = { .name = "tx-profile", .type = YNL_PT_NEST, .nest = ðtool_profile_nest, }, }; struct ynl_policy_nest ethtool_coalesce_nest = { @@ -954,6 +976,57 @@ int ethtool_mm_stat_parse(struct ynl_parse_arg *yarg, return 0; } +void ethtool_irq_moderation_free(struct ethtool_irq_moderation *obj) +{ +} + +int ethtool_irq_moderation_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct ethtool_irq_moderation *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.usec) + ynl_attr_put_u32(nlh, ETHTOOL_A_IRQ_MODERATION_USEC, obj->usec); + if (obj->_present.pkts) + ynl_attr_put_u32(nlh, ETHTOOL_A_IRQ_MODERATION_PKTS, obj->pkts); + if (obj->_present.comps) + ynl_attr_put_u32(nlh, ETHTOOL_A_IRQ_MODERATION_COMPS, obj->comps); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int ethtool_irq_moderation_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct ethtool_irq_moderation *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == ETHTOOL_A_IRQ_MODERATION_USEC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.usec = 1; + dst->usec = ynl_attr_get_u32(attr); + } else if (type == ETHTOOL_A_IRQ_MODERATION_PKTS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.pkts = 1; + dst->pkts = ynl_attr_get_u32(attr); + } else if (type == ETHTOOL_A_IRQ_MODERATION_COMPS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.comps = 1; + dst->comps = ynl_attr_get_u32(attr); + } + } + + return 0; +} + void ethtool_cable_result_free(struct ethtool_cable_result *obj) { } @@ -1149,6 +1222,68 @@ int ethtool_string_parse(struct ynl_parse_arg *yarg, return 0; } +void ethtool_profile_free(struct ethtool_profile *obj) +{ + unsigned int i; + + for (i = 0; i < obj->n_irq_moderation; i++) + ethtool_irq_moderation_free(&obj->irq_moderation[i]); + free(obj->irq_moderation); +} + +int ethtool_profile_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct ethtool_profile *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + for (unsigned int i = 0; i < obj->n_irq_moderation; i++) + ethtool_irq_moderation_put(nlh, ETHTOOL_A_PROFILE_IRQ_MODERATION, &obj->irq_moderation[i]); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int ethtool_profile_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct ethtool_profile *dst = yarg->data; + unsigned int n_irq_moderation = 0; + const struct nlattr *attr; + struct ynl_parse_arg parg; + int i; + + parg.ys = yarg->ys; + + if (dst->irq_moderation) + return ynl_error_parse(yarg, "attribute already present (profile.irq-moderation)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == ETHTOOL_A_PROFILE_IRQ_MODERATION) { + n_irq_moderation++; + } + } + + if (n_irq_moderation) { + dst->irq_moderation = calloc(n_irq_moderation, sizeof(*dst->irq_moderation)); + dst->n_irq_moderation = n_irq_moderation; + i = 0; + parg.rsp_policy = ðtool_irq_moderation_nest; + ynl_attr_for_each_nested(attr, nested) { + if (ynl_attr_type(attr) == ETHTOOL_A_PROFILE_IRQ_MODERATION) { + parg.data = &dst->irq_moderation[i]; + if (ethtool_irq_moderation_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + i++; + } + } + } + + return 0; +} + void ethtool_cable_nest_free(struct ethtool_cable_nest *obj) { ethtool_cable_result_free(&obj->result); @@ -3685,6 +3820,8 @@ void ethtool_coalesce_get_req_free(struct ethtool_coalesce_get_req *req) void ethtool_coalesce_get_rsp_free(struct ethtool_coalesce_get_rsp *rsp) { ethtool_header_free(&rsp->header); + ethtool_profile_free(&rsp->rx_profile); + ethtool_profile_free(&rsp->tx_profile); free(rsp); } @@ -3845,6 +3982,24 @@ int ethtool_coalesce_get_rsp_parse(const struct nlmsghdr *nlh, return YNL_PARSE_CB_ERROR; dst->_present.tx_aggr_time_usecs = 1; dst->tx_aggr_time_usecs = ynl_attr_get_u32(attr); + } else if (type == ETHTOOL_A_COALESCE_RX_PROFILE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.rx_profile = 1; + + parg.rsp_policy = ðtool_profile_nest; + parg.data = &dst->rx_profile; + if (ethtool_profile_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == ETHTOOL_A_COALESCE_TX_PROFILE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.tx_profile = 1; + + parg.rsp_policy = ðtool_profile_nest; + parg.data = &dst->tx_profile; + if (ethtool_profile_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; } } @@ -3899,6 +4054,8 @@ void ethtool_coalesce_get_list_free(struct ethtool_coalesce_get_list *rsp) next = rsp->next; ethtool_header_free(&rsp->obj.header); + ethtool_profile_free(&rsp->obj.rx_profile); + ethtool_profile_free(&rsp->obj.tx_profile); free(rsp); } } @@ -3939,6 +4096,8 @@ ethtool_coalesce_get_dump(struct ynl_sock *ys, void ethtool_coalesce_get_ntf_free(struct ethtool_coalesce_get_ntf *rsp) { ethtool_header_free(&rsp->obj.header); + ethtool_profile_free(&rsp->obj.rx_profile); + ethtool_profile_free(&rsp->obj.tx_profile); free(rsp); } @@ -3947,6 +4106,8 @@ void ethtool_coalesce_get_ntf_free(struct ethtool_coalesce_get_ntf *rsp) void ethtool_coalesce_set_req_free(struct ethtool_coalesce_set_req *req) { ethtool_header_free(&req->header); + ethtool_profile_free(&req->rx_profile); + ethtool_profile_free(&req->tx_profile); free(req); } @@ -4016,6 +4177,10 @@ int ethtool_coalesce_set(struct ynl_sock *ys, ynl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES, req->tx_aggr_max_frames); if (req->_present.tx_aggr_time_usecs) ynl_attr_put_u32(nlh, ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS, req->tx_aggr_time_usecs); + if (req->_present.rx_profile) + ethtool_profile_put(nlh, ETHTOOL_A_COALESCE_RX_PROFILE, &req->rx_profile); + if (req->_present.tx_profile) + ethtool_profile_put(nlh, ETHTOOL_A_COALESCE_TX_PROFILE, &req->tx_profile); err = ynl_exec(ys, nlh, &yrs); if (err < 0) diff --git a/home/nipa/nipa_out/850431/ynl/old-code/ethtool-user.h b/home/nipa/nipa_out/850431/ynl/new-code/ethtool-user.h index 20088a1862bf..f30e65bb576f 100644 --- a/home/nipa/nipa_out/850431/ynl/old-code/ethtool-user.h +++ b/home/nipa/nipa_out/850431/ynl/new-code/ethtool-user.h @@ -101,6 +101,18 @@ struct ethtool_mm_stat { __u64 hold_count; }; +struct ethtool_irq_moderation { + struct { + __u32 usec:1; + __u32 pkts:1; + __u32 comps:1; + } _present; + + __u32 usec; + __u32 pkts; + __u32 comps; +}; + struct ethtool_cable_result { struct { __u32 pair:1; @@ -152,6 +164,11 @@ struct ethtool_string { char *value; }; +struct ethtool_profile { + unsigned int n_irq_moderation; + struct ethtool_irq_moderation *irq_moderation; +}; + struct ethtool_cable_nest { struct { __u32 result:1; @@ -2673,6 +2690,8 @@ struct ethtool_coalesce_get_rsp { __u32 tx_aggr_max_bytes:1; __u32 tx_aggr_max_frames:1; __u32 tx_aggr_time_usecs:1; + __u32 rx_profile:1; + __u32 tx_profile:1; } _present; struct ethtool_header header; @@ -2703,6 +2722,8 @@ struct ethtool_coalesce_get_rsp { __u32 tx_aggr_max_bytes; __u32 tx_aggr_max_frames; __u32 tx_aggr_time_usecs; + struct ethtool_profile rx_profile; + struct ethtool_profile tx_profile; }; void ethtool_coalesce_get_rsp_free(struct ethtool_coalesce_get_rsp *rsp); @@ -2812,6 +2833,8 @@ struct ethtool_coalesce_set_req { __u32 tx_aggr_max_bytes:1; __u32 tx_aggr_max_frames:1; __u32 tx_aggr_time_usecs:1; + __u32 rx_profile:1; + __u32 tx_profile:1; } _present; struct ethtool_header header; @@ -2842,6 +2865,8 @@ struct ethtool_coalesce_set_req { __u32 tx_aggr_max_bytes; __u32 tx_aggr_max_frames; __u32 tx_aggr_time_usecs; + struct ethtool_profile rx_profile; + struct ethtool_profile tx_profile; }; static inline struct ethtool_coalesce_set_req * @@ -3067,6 +3092,26 @@ ethtool_coalesce_set_req_set_tx_aggr_time_usecs(struct ethtool_coalesce_set_req req->_present.tx_aggr_time_usecs = 1; req->tx_aggr_time_usecs = tx_aggr_time_usecs; } +static inline void +__ethtool_coalesce_set_req_set_rx_profile_irq_moderation(struct ethtool_coalesce_set_req *req, + struct ethtool_irq_moderation *irq_moderation, + unsigned int n_irq_moderation) +{ + req->_present.rx_profile = 1; + free(req->rx_profile.irq_moderation); + req->rx_profile.irq_moderation = irq_moderation; + req->rx_profile.n_irq_moderation = n_irq_moderation; +} +static inline void +__ethtool_coalesce_set_req_set_tx_profile_irq_moderation(struct ethtool_coalesce_set_req *req, + struct ethtool_irq_moderation *irq_moderation, + unsigned int n_irq_moderation) +{ + req->_present.tx_profile = 1; + free(req->tx_profile.irq_moderation); + req->tx_profile.irq_moderation = irq_moderation; + req->tx_profile.n_irq_moderation = n_irq_moderation; +} /* * Set coalesce params.