diff --git a/home/nipa/nipa_out/863424/ynl/old-code/ethtool-user.c b/home/nipa/nipa_out/863424/ynl/new-code/ethtool-user.c index a24a477247db..a5c04d32d75c 100644 --- a/home/nipa/nipa_out/863424/ynl/old-code/ethtool-user.c +++ b/home/nipa/nipa_out/863424/ynl/new-code/ethtool-user.c @@ -58,6 +58,7 @@ static const char * const ethtool_op_strmap[] = { [41] = "plca-ntf", [ETHTOOL_MSG_MM_GET] = "mm-get", [43] = "mm-ntf", + [44] = "module-fw-flash-ntf", }; const char *ethtool_op_str(int op) @@ -104,6 +105,21 @@ const char *ethtool_header_flags_str(enum ethtool_header_flags value) return ethtool_header_flags_strmap[value]; } +static const char * const ethtool_module_fw_flash_status_strmap[] = { + [0] = "started", + [1] = "in_progress", + [2] = "completed", + [3] = "error", +}; + +const char * +ethtool_module_fw_flash_status_str(enum ethtool_module_fw_flash_status value) +{ + if (value < 0 || value >= (int)YNL_ARRAY_SIZE(ethtool_module_fw_flash_status_strmap)) + return NULL; + return ethtool_module_fw_flash_status_strmap[value]; +} + /* Policies */ const struct ynl_policy_attr ethtool_header_policy[ETHTOOL_A_HEADER_MAX + 1] = { [ETHTOOL_A_HEADER_DEV_INDEX] = { .name = "dev-index", .type = YNL_PT_U32, }, @@ -695,6 +711,21 @@ const struct ynl_policy_nest ethtool_mm_nest = { .table = ethtool_mm_policy, }; +const struct ynl_policy_attr ethtool_module_fw_flash_policy[ETHTOOL_A_MODULE_FW_FLASH_MAX + 1] = { + [ETHTOOL_A_MODULE_FW_FLASH_HEADER] = { .name = "header", .type = YNL_PT_NEST, .nest = ðtool_header_nest, }, + [ETHTOOL_A_MODULE_FW_FLASH_FILE_NAME] = { .name = "file-name", .type = YNL_PT_NUL_STR, }, + [ETHTOOL_A_MODULE_FW_FLASH_PASSWORD] = { .name = "password", .type = YNL_PT_U32, }, + [ETHTOOL_A_MODULE_FW_FLASH_STATUS] = { .name = "status", .type = YNL_PT_U32, }, + [ETHTOOL_A_MODULE_FW_FLASH_STATUS_MSG] = { .name = "status-msg", .type = YNL_PT_NUL_STR, }, + [ETHTOOL_A_MODULE_FW_FLASH_DONE] = { .name = "done", .type = YNL_PT_UINT, }, + [ETHTOOL_A_MODULE_FW_FLASH_TOTAL] = { .name = "total", .type = YNL_PT_UINT, }, +}; + +const struct ynl_policy_nest ethtool_module_fw_flash_nest = { + .max_attr = ETHTOOL_A_MODULE_FW_FLASH_MAX, + .table = ethtool_module_fw_flash_policy, +}; + /* Common nested types */ void ethtool_header_free(struct ethtool_header *obj) { @@ -6448,6 +6479,40 @@ int ethtool_mm_set(struct ynl_sock *ys, struct ethtool_mm_set_req *req) return 0; } +/* ============== ETHTOOL_MSG_MODULE_FW_FLASH_ACT ============== */ +/* ETHTOOL_MSG_MODULE_FW_FLASH_ACT - do */ +void +ethtool_module_fw_flash_act_req_free(struct ethtool_module_fw_flash_act_req *req) +{ + ethtool_header_free(&req->header); + free(req->file_name); + free(req); +} + +int ethtool_module_fw_flash_act(struct ynl_sock *ys, + struct ethtool_module_fw_flash_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_MODULE_FW_FLASH_ACT, 1); + ys->req_policy = ðtool_module_fw_flash_nest; + + if (req->_present.header) + ethtool_header_put(nlh, ETHTOOL_A_MODULE_FW_FLASH_HEADER, &req->header); + if (req->_present.file_name_len) + ynl_attr_put_str(nlh, ETHTOOL_A_MODULE_FW_FLASH_FILE_NAME, req->file_name); + if (req->_present.password) + ynl_attr_put_u32(nlh, ETHTOOL_A_MODULE_FW_FLASH_PASSWORD, req->password); + + 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) @@ -6538,6 +6603,68 @@ void ethtool_cable_test_tdr_ntf_free(struct ethtool_cable_test_tdr_ntf *rsp) free(rsp); } +/* ETHTOOL_MSG_MODULE_FW_FLASH_NTF - event */ +int ethtool_module_fw_flash_ntf_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct ethtool_module_fw_flash_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_MODULE_FW_FLASH_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_MODULE_FW_FLASH_STATUS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.status = 1; + dst->status = ynl_attr_get_u32(attr); + } else if (type == ETHTOOL_A_MODULE_FW_FLASH_STATUS_MSG) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_present.status_msg_len = len; + dst->status_msg = malloc(len + 1); + memcpy(dst->status_msg, ynl_attr_get_str(attr), len); + dst->status_msg[len] = 0; + } else if (type == ETHTOOL_A_MODULE_FW_FLASH_DONE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.done = 1; + dst->done = ynl_attr_get_uint(attr); + } else if (type == ETHTOOL_A_MODULE_FW_FLASH_TOTAL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.total = 1; + dst->total = ynl_attr_get_uint(attr); + } + } + + return YNL_PARSE_CB_OK; +} + +void ethtool_module_fw_flash_ntf_free(struct ethtool_module_fw_flash_ntf *rsp) +{ + ethtool_header_free(&rsp->obj.header); + free(rsp->obj.status_msg); + free(rsp); +} + static const struct ynl_ntf_info ethtool_ntf_info[] = { [ETHTOOL_MSG_LINKINFO_NTF] = { .alloc_sz = sizeof(struct ethtool_linkinfo_get_ntf), @@ -6641,6 +6768,12 @@ static const struct ynl_ntf_info ethtool_ntf_info[] = { .policy = ðtool_mm_nest, .free = (void *)ethtool_mm_get_ntf_free, }, + [ETHTOOL_MSG_MODULE_FW_FLASH_NTF] = { + .alloc_sz = sizeof(struct ethtool_module_fw_flash_ntf), + .cb = ethtool_module_fw_flash_ntf_rsp_parse, + .policy = ðtool_module_fw_flash_nest, + .free = (void *)ethtool_module_fw_flash_ntf_free, + }, }; const struct ynl_family ynl_ethtool_family = { diff --git a/home/nipa/nipa_out/863424/ynl/old-code/ethtool-user.h b/home/nipa/nipa_out/863424/ynl/new-code/ethtool-user.h index 20088a1862bf..df9bdfd02b43 100644 --- a/home/nipa/nipa_out/863424/ynl/old-code/ethtool-user.h +++ b/home/nipa/nipa_out/863424/ynl/new-code/ethtool-user.h @@ -21,6 +21,8 @@ const char *ethtool_op_str(int op); const char *ethtool_udp_tunnel_type_str(int value); const char *ethtool_stringset_str(enum ethtool_stringset value); const char *ethtool_header_flags_str(enum ethtool_header_flags value); +const char * +ethtool_module_fw_flash_status_str(enum ethtool_module_fw_flash_status value); /* Common nested types */ struct ethtool_header { @@ -5633,6 +5635,79 @@ ethtool_mm_set_req_set_tx_min_frag_size(struct ethtool_mm_set_req *req, */ int ethtool_mm_set(struct ynl_sock *ys, struct ethtool_mm_set_req *req); +/* ============== ETHTOOL_MSG_MODULE_FW_FLASH_ACT ============== */ +/* ETHTOOL_MSG_MODULE_FW_FLASH_ACT - do */ +struct ethtool_module_fw_flash_act_req { + struct { + __u32 header:1; + __u32 file_name_len; + __u32 password:1; + } _present; + + struct ethtool_header header; + char *file_name; + __u32 password; +}; + +static inline struct ethtool_module_fw_flash_act_req * +ethtool_module_fw_flash_act_req_alloc(void) +{ + return calloc(1, sizeof(struct ethtool_module_fw_flash_act_req)); +} +void +ethtool_module_fw_flash_act_req_free(struct ethtool_module_fw_flash_act_req *req); + +static inline void +ethtool_module_fw_flash_act_req_set_header_dev_index(struct ethtool_module_fw_flash_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_module_fw_flash_act_req_set_header_dev_name(struct ethtool_module_fw_flash_act_req *req, + const char *dev_name) +{ + req->_present.header = 1; + free(req->header.dev_name); + req->header._present.dev_name_len = strlen(dev_name); + req->header.dev_name = malloc(req->header._present.dev_name_len + 1); + memcpy(req->header.dev_name, dev_name, req->header._present.dev_name_len); + req->header.dev_name[req->header._present.dev_name_len] = 0; +} +static inline void +ethtool_module_fw_flash_act_req_set_header_flags(struct ethtool_module_fw_flash_act_req *req, + __u32 flags) +{ + req->_present.header = 1; + req->header._present.flags = 1; + req->header.flags = flags; +} +static inline void +ethtool_module_fw_flash_act_req_set_file_name(struct ethtool_module_fw_flash_act_req *req, + const char *file_name) +{ + free(req->file_name); + req->_present.file_name_len = strlen(file_name); + req->file_name = malloc(req->_present.file_name_len + 1); + memcpy(req->file_name, file_name, req->_present.file_name_len); + req->file_name[req->_present.file_name_len] = 0; +} +static inline void +ethtool_module_fw_flash_act_req_set_password(struct ethtool_module_fw_flash_act_req *req, + __u32 password) +{ + req->_present.password = 1; + req->password = password; +} + +/* + * Flash transceiver module firmware. + */ +int ethtool_module_fw_flash_act(struct ynl_sock *ys, + struct ethtool_module_fw_flash_act_req *req); + /* ETHTOOL_MSG_CABLE_TEST_NTF - event */ struct ethtool_cable_test_ntf_rsp { struct { @@ -5677,4 +5752,31 @@ struct ethtool_cable_test_tdr_ntf { void ethtool_cable_test_tdr_ntf_free(struct ethtool_cable_test_tdr_ntf *rsp); +/* ETHTOOL_MSG_MODULE_FW_FLASH_NTF - event */ +struct ethtool_module_fw_flash_ntf_rsp { + struct { + __u32 header:1; + __u32 status:1; + __u32 status_msg_len; + __u32 done:1; + __u32 total:1; + } _present; + + struct ethtool_header header; + enum ethtool_module_fw_flash_status status; + char *status_msg; + __u64 done; + __u64 total; +}; + +struct ethtool_module_fw_flash_ntf { + __u16 family; + __u8 cmd; + struct ynl_ntf_base_type *next; + void (*free)(struct ethtool_module_fw_flash_ntf *ntf); + struct ethtool_module_fw_flash_ntf_rsp obj __attribute__((aligned(8))); +}; + +void ethtool_module_fw_flash_ntf_free(struct ethtool_module_fw_flash_ntf *rsp); + #endif /* _LINUX_ETHTOOL_GEN_H */