diff --git a/home/nipa/nipa_out/1000685/ynl/old-code/ethtool-user.c b/home/nipa/nipa_out/1000685/ynl/new-code/ethtool-user.c index 397701e52a10..2101fab16d7d 100644 --- a/home/nipa/nipa_out/1000685/ynl/old-code/ethtool-user.c +++ b/home/nipa/nipa_out/1000685/ynl/new-code/ethtool-user.c @@ -301,19 +301,6 @@ const struct ynl_policy_nest ethtool_cable_test_tdr_cfg_nest = { .table = ethtool_cable_test_tdr_cfg_policy, }; -const struct ynl_policy_attr ethtool_fec_stat_policy[ETHTOOL_A_FEC_STAT_MAX + 1] = { - [ETHTOOL_A_FEC_STAT_UNSPEC] = { .name = "unspec", .type = YNL_PT_REJECT, }, - [ETHTOOL_A_FEC_STAT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, - [ETHTOOL_A_FEC_STAT_CORRECTED] = { .name = "corrected", .type = YNL_PT_BINARY,}, - [ETHTOOL_A_FEC_STAT_UNCORR] = { .name = "uncorr", .type = YNL_PT_BINARY,}, - [ETHTOOL_A_FEC_STAT_CORR_BITS] = { .name = "corr-bits", .type = YNL_PT_BINARY,}, -}; - -const struct ynl_policy_nest ethtool_fec_stat_nest = { - .max_attr = ETHTOOL_A_FEC_STAT_MAX, - .table = ethtool_fec_stat_policy, -}; - const struct ynl_policy_attr ethtool_c33_pse_pw_limit_policy[__ETHTOOL_A_C33_PSE_PW_LIMIT_MAX + 1] = { [ETHTOOL_A_C33_PSE_PW_LIMIT_UNSPEC] = { .name = "unspec", .type = YNL_PT_REJECT, }, [ETHTOOL_A_C33_PSE_PW_LIMIT_MIN] = { .name = "min", .type = YNL_PT_U32, }, @@ -412,6 +399,18 @@ const struct ynl_policy_nest ethtool_cable_fault_length_nest = { .table = ethtool_cable_fault_length_policy, }; +const struct ynl_policy_attr ethtool_fec_hist_policy[ETHTOOL_A_FEC_HIST_MAX + 1] = { + [ETHTOOL_A_FEC_HIST_BIN_LOW] = { .name = "bin-low", .type = YNL_PT_U32, }, + [ETHTOOL_A_FEC_HIST_BIN_HIGH] = { .name = "bin-high", .type = YNL_PT_U32, }, + [ETHTOOL_A_FEC_HIST_BIN_VAL] = { .name = "bin-val", .type = YNL_PT_UINT, }, + [ETHTOOL_A_FEC_HIST_BIN_VAL_PER_LANE] = { .name = "bin-val-per-lane", .type = YNL_PT_UINT, }, +}; + +const struct ynl_policy_nest ethtool_fec_hist_nest = { + .max_attr = ETHTOOL_A_FEC_HIST_MAX, + .table = ethtool_fec_hist_policy, +}; + const struct ynl_policy_attr ethtool_bitset_bit_policy[ETHTOOL_A_BITSET_BIT_MAX + 1] = { [ETHTOOL_A_BITSET_BIT_UNSPEC] = { .name = "unspec", .type = YNL_PT_REJECT, }, [ETHTOOL_A_BITSET_BIT_INDEX] = { .name = "index", .type = YNL_PT_U32, }, @@ -467,6 +466,20 @@ const struct ynl_policy_nest ethtool_cable_nest_nest = { .table = ethtool_cable_nest_policy, }; +const struct ynl_policy_attr ethtool_fec_stat_policy[ETHTOOL_A_FEC_STAT_MAX + 1] = { + [ETHTOOL_A_FEC_STAT_UNSPEC] = { .name = "unspec", .type = YNL_PT_REJECT, }, + [ETHTOOL_A_FEC_STAT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [ETHTOOL_A_FEC_STAT_CORRECTED] = { .name = "corrected", .type = YNL_PT_BINARY,}, + [ETHTOOL_A_FEC_STAT_UNCORR] = { .name = "uncorr", .type = YNL_PT_BINARY,}, + [ETHTOOL_A_FEC_STAT_CORR_BITS] = { .name = "corr-bits", .type = YNL_PT_BINARY,}, + [ETHTOOL_A_FEC_STAT_HIST] = { .name = "hist", .type = YNL_PT_NEST, .nest = ðtool_fec_hist_nest, }, +}; + +const struct ynl_policy_nest ethtool_fec_stat_nest = { + .max_attr = ETHTOOL_A_FEC_STAT_MAX, + .table = ethtool_fec_stat_policy, +}; + const struct ynl_policy_attr ethtool_bitset_bits_policy[ETHTOOL_A_BITSET_BITS_MAX + 1] = { [ETHTOOL_A_BITSET_BITS_UNSPEC] = { .name = "unspec", .type = YNL_PT_REJECT, }, [ETHTOOL_A_BITSET_BITS_BIT] = { .name = "bit", .type = YNL_PT_NEST, .nest = ðtool_bitset_bit_nest, }, @@ -1234,85 +1247,6 @@ void ethtool_cable_test_tdr_cfg_free(struct ethtool_cable_test_tdr_cfg *obj) { } -void ethtool_fec_stat_free(struct ethtool_fec_stat *obj) -{ - free(obj->corrected); - free(obj->uncorr); - free(obj->corr_bits); -} - -int ethtool_fec_stat_put(struct nlmsghdr *nlh, unsigned int attr_type, - struct ethtool_fec_stat *obj) -{ - struct nlattr *nest; - unsigned int i; - - nest = ynl_attr_nest_start(nlh, attr_type); - if (obj->_count.corrected) { - i = obj->_count.corrected * sizeof(__u64); - ynl_attr_put(nlh, ETHTOOL_A_FEC_STAT_CORRECTED, obj->corrected, i); - } - if (obj->_count.uncorr) { - i = obj->_count.uncorr * sizeof(__u64); - ynl_attr_put(nlh, ETHTOOL_A_FEC_STAT_UNCORR, obj->uncorr, i); - } - if (obj->_count.corr_bits) { - i = obj->_count.corr_bits * sizeof(__u64); - ynl_attr_put(nlh, ETHTOOL_A_FEC_STAT_CORR_BITS, obj->corr_bits, i); - } - ynl_attr_nest_end(nlh, nest); - - return 0; -} - -int ethtool_fec_stat_parse(struct ynl_parse_arg *yarg, - const struct nlattr *nested) -{ - struct ethtool_fec_stat *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_FEC_STAT_CORRECTED) { - unsigned int len; - - if (ynl_attr_validate(yarg, attr)) - return YNL_PARSE_CB_ERROR; - - len = ynl_attr_data_len(attr); - dst->_count.corrected = len / sizeof(__u64); - len = dst->_count.corrected * sizeof(__u64); - dst->corrected = malloc(len); - memcpy(dst->corrected, ynl_attr_data(attr), len); - } else if (type == ETHTOOL_A_FEC_STAT_UNCORR) { - unsigned int len; - - if (ynl_attr_validate(yarg, attr)) - return YNL_PARSE_CB_ERROR; - - len = ynl_attr_data_len(attr); - dst->_count.uncorr = len / sizeof(__u64); - len = dst->_count.uncorr * sizeof(__u64); - dst->uncorr = malloc(len); - memcpy(dst->uncorr, ynl_attr_data(attr), len); - } else if (type == ETHTOOL_A_FEC_STAT_CORR_BITS) { - unsigned int len; - - if (ynl_attr_validate(yarg, attr)) - return YNL_PARSE_CB_ERROR; - - len = ynl_attr_data_len(attr); - dst->_count.corr_bits = len / sizeof(__u64); - len = dst->_count.corr_bits * sizeof(__u64); - dst->corr_bits = malloc(len); - memcpy(dst->corr_bits, ynl_attr_data(attr), len); - } - } - - return 0; -} - void ethtool_c33_pse_pw_limit_free(struct ethtool_c33_pse_pw_limit *obj) { } @@ -1728,6 +1662,80 @@ int ethtool_cable_fault_length_parse(struct ynl_parse_arg *yarg, return 0; } +void ethtool_fec_hist_free(struct ethtool_fec_hist *obj) +{ + free(obj->bin_val_per_lane); +} + +int ethtool_fec_hist_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct ethtool_fec_hist *obj) +{ + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.bin_low) + ynl_attr_put_u32(nlh, ETHTOOL_A_FEC_HIST_BIN_LOW, obj->bin_low); + if (obj->_present.bin_high) + ynl_attr_put_u32(nlh, ETHTOOL_A_FEC_HIST_BIN_HIGH, obj->bin_high); + if (obj->_present.bin_val) + ynl_attr_put_uint(nlh, ETHTOOL_A_FEC_HIST_BIN_VAL, obj->bin_val); + for (i = 0; i < obj->_count.bin_val_per_lane; i++) + ynl_attr_put_uint(nlh, ETHTOOL_A_FEC_HIST_BIN_VAL_PER_LANE, obj->bin_val_per_lane[i]); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int ethtool_fec_hist_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct ethtool_fec_hist *dst = yarg->data; + unsigned int n_bin_val_per_lane = 0; + const struct nlattr *attr; + int i; + + if (dst->bin_val_per_lane) + return ynl_error_parse(yarg, "attribute already present (fec-hist.bin-val-per-lane)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == ETHTOOL_A_FEC_HIST_BIN_LOW) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.bin_low = 1; + dst->bin_low = ynl_attr_get_u32(attr); + } else if (type == ETHTOOL_A_FEC_HIST_BIN_HIGH) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.bin_high = 1; + dst->bin_high = ynl_attr_get_u32(attr); + } else if (type == ETHTOOL_A_FEC_HIST_BIN_VAL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.bin_val = 1; + dst->bin_val = ynl_attr_get_uint(attr); + } else if (type == ETHTOOL_A_FEC_HIST_BIN_VAL_PER_LANE) { + n_bin_val_per_lane++; + } + } + + if (n_bin_val_per_lane) { + dst->bin_val_per_lane = calloc(n_bin_val_per_lane, sizeof(*dst->bin_val_per_lane)); + dst->_count.bin_val_per_lane = n_bin_val_per_lane; + i = 0; + ynl_attr_for_each_nested(attr, nested) { + if (ynl_attr_type(attr) == ETHTOOL_A_FEC_HIST_BIN_VAL_PER_LANE) { + dst->bin_val_per_lane[i] = ynl_attr_get_uint(attr); + i++; + } + } + } + + return 0; +} + void ethtool_bitset_bit_free(struct ethtool_bitset_bit *obj) { free(obj->name); @@ -1970,6 +1978,117 @@ int ethtool_cable_nest_parse(struct ynl_parse_arg *yarg, return 0; } +void ethtool_fec_stat_free(struct ethtool_fec_stat *obj) +{ + unsigned int i; + + free(obj->corrected); + free(obj->uncorr); + free(obj->corr_bits); + for (i = 0; i < obj->_count.hist; i++) + ethtool_fec_hist_free(&obj->hist[i]); + free(obj->hist); +} + +int ethtool_fec_stat_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct ethtool_fec_stat *obj) +{ + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_count.corrected) { + i = obj->_count.corrected * sizeof(__u64); + ynl_attr_put(nlh, ETHTOOL_A_FEC_STAT_CORRECTED, obj->corrected, i); + } + if (obj->_count.uncorr) { + i = obj->_count.uncorr * sizeof(__u64); + ynl_attr_put(nlh, ETHTOOL_A_FEC_STAT_UNCORR, obj->uncorr, i); + } + if (obj->_count.corr_bits) { + i = obj->_count.corr_bits * sizeof(__u64); + ynl_attr_put(nlh, ETHTOOL_A_FEC_STAT_CORR_BITS, obj->corr_bits, i); + } + for (i = 0; i < obj->_count.hist; i++) + ethtool_fec_hist_put(nlh, ETHTOOL_A_FEC_STAT_HIST, &obj->hist[i]); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int ethtool_fec_stat_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct ethtool_fec_stat *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_hist = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->hist) + return ynl_error_parse(yarg, "attribute already present (fec-stat.hist)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == ETHTOOL_A_FEC_STAT_CORRECTED) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_count.corrected = len / sizeof(__u64); + len = dst->_count.corrected * sizeof(__u64); + dst->corrected = malloc(len); + memcpy(dst->corrected, ynl_attr_data(attr), len); + } else if (type == ETHTOOL_A_FEC_STAT_UNCORR) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_count.uncorr = len / sizeof(__u64); + len = dst->_count.uncorr * sizeof(__u64); + dst->uncorr = malloc(len); + memcpy(dst->uncorr, ynl_attr_data(attr), len); + } else if (type == ETHTOOL_A_FEC_STAT_CORR_BITS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_count.corr_bits = len / sizeof(__u64); + len = dst->_count.corr_bits * sizeof(__u64); + dst->corr_bits = malloc(len); + memcpy(dst->corr_bits, ynl_attr_data(attr), len); + } else if (type == ETHTOOL_A_FEC_STAT_HIST) { + n_hist++; + } + } + + if (n_hist) { + dst->hist = calloc(n_hist, sizeof(*dst->hist)); + dst->_count.hist = n_hist; + i = 0; + parg.rsp_policy = ðtool_fec_hist_nest; + ynl_attr_for_each_nested(attr, nested) { + if (ynl_attr_type(attr) == ETHTOOL_A_FEC_STAT_HIST) { + parg.data = &dst->hist[i]; + if (ethtool_fec_hist_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + i++; + } + } + } + + return 0; +} + void ethtool_bitset_bits_free(struct ethtool_bitset_bits *obj) { unsigned int i; diff --git a/home/nipa/nipa_out/1000685/ynl/old-code/ethtool-user.h b/home/nipa/nipa_out/1000685/ynl/new-code/ethtool-user.h index 72ad01e33930..5861145f8e8c 100644 --- a/home/nipa/nipa_out/1000685/ynl/old-code/ethtool-user.h +++ b/home/nipa/nipa_out/1000685/ynl/new-code/ethtool-user.h @@ -98,18 +98,6 @@ struct ethtool_cable_test_tdr_cfg { __u8 pair; }; -struct ethtool_fec_stat { - struct { - __u32 corrected; - __u32 uncorr; - __u32 corr_bits; - } _count; - - __u64 *corrected; - __u64 *uncorr; - __u64 *corr_bits; -}; - struct ethtool_c33_pse_pw_limit { struct { __u32 min:1; @@ -262,6 +250,57 @@ struct ethtool_cable_fault_length { __u32 src; }; +struct ethtool_fec_hist { + struct { + __u32 bin_low:1; + __u32 bin_high:1; + __u32 bin_val:1; + } _present; + struct { + __u32 bin_val_per_lane; + } _count; + + __u32 bin_low; + __u32 bin_high; + __u64 bin_val; + __uint *bin_val_per_lane; +}; + +static inline struct ethtool_fec_hist *ethtool_fec_hist_alloc(unsigned int n) +{ + return calloc(n, sizeof(struct ethtool_fec_hist)); +} + +void ethtool_fec_hist_free(struct ethtool_fec_hist *obj); + +static inline void +ethtool_fec_hist_set_bin_low(struct ethtool_fec_hist *obj, __u32 bin_low) +{ + obj->_present.bin_low = 1; + obj->bin_low = bin_low; +} +static inline void +ethtool_fec_hist_set_bin_high(struct ethtool_fec_hist *obj, __u32 bin_high) +{ + obj->_present.bin_high = 1; + obj->bin_high = bin_high; +} +static inline void +ethtool_fec_hist_set_bin_val(struct ethtool_fec_hist *obj, __u64 bin_val) +{ + obj->_present.bin_val = 1; + obj->bin_val = bin_val; +} +static inline void +__ethtool_fec_hist_set_bin_val_per_lane(struct ethtool_fec_hist *obj, + __uint *bin_val_per_lane, + unsigned int n_bin_val_per_lane) +{ + free(obj->bin_val_per_lane); + obj->bin_val_per_lane = bin_val_per_lane; + obj->_count.bin_val_per_lane = n_bin_val_per_lane; +} + struct ethtool_bitset_bit { struct { __u32 index:1; @@ -366,6 +405,20 @@ struct ethtool_cable_nest { struct ethtool_cable_fault_length fault_length; }; +struct ethtool_fec_stat { + struct { + __u32 corrected; + __u32 uncorr; + __u32 corr_bits; + __u32 hist; + } _count; + + __u64 *corrected; + __u64 *uncorr; + __u64 *corr_bits; + struct ethtool_fec_hist *hist; +}; + struct ethtool_bitset_bits { struct { __u32 bit; @@ -5207,6 +5260,20 @@ ethtool_fec_set_req_set_stats_corr_bits(struct ethtool_fec_set_req *req, req->stats.corr_bits = malloc(count); memcpy(req->stats.corr_bits, corr_bits, count); } +static inline void +__ethtool_fec_set_req_set_stats_hist(struct ethtool_fec_set_req *req, + struct ethtool_fec_hist *hist, + unsigned int n_hist) +{ + unsigned int i; + + req->_present.stats = 1; + for (i = 0; i < req->stats._count.hist; i++) + ethtool_fec_hist_free(&req->stats.hist[i]); + free(req->stats.hist); + req->stats.hist = hist; + req->stats._count.hist = n_hist; +} /* * Set FEC params.