Lines Matching +full:comp +full:- +full:int

1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /* Copyright (c) 2017-2019 Mellanox Technologies. All rights reserved */
19 static const int mlxfw_fsm_state_errno[] = {
20 [MLXFW_FSM_STATE_ERR_ERROR] = -EIO,
21 [MLXFW_FSM_STATE_ERR_REJECTED_DIGEST_ERR] = -EBADMSG,
22 [MLXFW_FSM_STATE_ERR_REJECTED_NOT_APPLICABLE] = -ENOENT,
23 [MLXFW_FSM_STATE_ERR_REJECTED_UNKNOWN_KEY] = -ENOKEY,
24 [MLXFW_FSM_STATE_ERR_REJECTED_AUTH_FAILED] = -EACCES,
25 [MLXFW_FSM_STATE_ERR_REJECTED_UNSIGNED] = -EKEYREVOKED,
26 [MLXFW_FSM_STATE_ERR_REJECTED_KEY_NOT_APPLICABLE] = -EKEYREJECTED,
27 [MLXFW_FSM_STATE_ERR_REJECTED_BAD_FORMAT] = -ENOEXEC,
28 [MLXFW_FSM_STATE_ERR_BLOCKED_PENDING_RESET] = -EBUSY,
29 [MLXFW_FSM_STATE_ERR_MAX] = -EINVAL
38 static int mlxfw_fsm_state_err(struct mlxfw_dev *mlxfw_dev, in mlxfw_fsm_state_err()
84 static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, in mlxfw_fsm_state_wait()
90 int times; in mlxfw_fsm_state_wait()
91 int err; in mlxfw_fsm_state_wait()
95 err = mlxfw_dev->ops->fsm_query_state(mlxfw_dev, fwhandle, in mlxfw_fsm_state_wait()
106 if (--times == 0) { in mlxfw_fsm_state_wait()
108 "Timeout reached on FSM state change", -ETIMEDOUT); in mlxfw_fsm_state_wait()
109 return -ETIMEDOUT; in mlxfw_fsm_state_wait()
117 static int
163 return -EREMOTEIO; in mlxfw_fsm_reactivate_err()
166 static int mlxfw_fsm_reactivate(struct mlxfw_dev *mlxfw_dev, in mlxfw_fsm_reactivate()
171 int err; in mlxfw_fsm_reactivate()
173 if (!mlxfw_dev->ops->fsm_reactivate) in mlxfw_fsm_reactivate()
176 err = mlxfw_dev->ops->fsm_reactivate(mlxfw_dev, &status); in mlxfw_fsm_reactivate()
177 if (err == -EOPNOTSUPP) { in mlxfw_fsm_reactivate()
199 devlink_flash_update_status_notify(mlxfw_dev->devlink, msg, comp_name, in mlxfw_status_notify()
203 #define MLXFW_ALIGN_DOWN(x, align_bits) ((x) & ~((1 << (align_bits)) - 1))
205 MLXFW_ALIGN_DOWN((x) + ((1 << (align_bits)) - 1), (align_bits))
207 static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev, in mlxfw_flash_component()
209 struct mlxfw_mfa2_component *comp, in mlxfw_flash_component() argument
220 int err; in mlxfw_flash_component()
222 sprintf(comp_name, "%u", comp->index); in mlxfw_flash_component()
224 err = mlxfw_dev->ops->component_query(mlxfw_dev, comp->index, in mlxfw_flash_component()
233 if (comp->data_size > comp_max_size) { in mlxfw_flash_component()
235 "Component size is bigger than limit", -EINVAL); in mlxfw_flash_component()
236 return -EINVAL; in mlxfw_flash_component()
244 err = mlxfw_dev->ops->fsm_component_update(mlxfw_dev, fwhandle, in mlxfw_flash_component()
245 comp->index, in mlxfw_flash_component()
246 comp->data_size); in mlxfw_flash_component()
265 comp_name, 0, comp->data_size); in mlxfw_flash_component()
267 offset < MLXFW_ALIGN_UP(comp->data_size, comp_align_bits); in mlxfw_flash_component()
269 block_ptr = comp->data + offset; in mlxfw_flash_component()
270 block_size = (u16) min_t(u32, comp->data_size - offset, in mlxfw_flash_component()
272 err = mlxfw_dev->ops->fsm_block_download(mlxfw_dev, fwhandle, in mlxfw_flash_component()
282 comp->data_size); in mlxfw_flash_component()
287 err = mlxfw_dev->ops->fsm_component_verify(mlxfw_dev, fwhandle, in mlxfw_flash_component()
288 comp->index); in mlxfw_flash_component()
302 mlxfw_dev->ops->fsm_cancel(mlxfw_dev, fwhandle); in mlxfw_flash_component()
306 static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, in mlxfw_flash_components()
312 int err; in mlxfw_flash_components()
313 int i; in mlxfw_flash_components()
315 err = mlxfw_mfa2_file_component_count(mfa2_file, mlxfw_dev->psid, in mlxfw_flash_components()
316 mlxfw_dev->psid_size, in mlxfw_flash_components()
325 struct mlxfw_mfa2_component *comp; in mlxfw_flash_components() local
327 comp = mlxfw_mfa2_file_component_get(mfa2_file, mlxfw_dev->psid, in mlxfw_flash_components()
328 mlxfw_dev->psid_size, i); in mlxfw_flash_components()
329 if (IS_ERR(comp)) { in mlxfw_flash_components()
330 err = PTR_ERR(comp); in mlxfw_flash_components()
337 comp->index); in mlxfw_flash_components()
338 err = mlxfw_flash_component(mlxfw_dev, fwhandle, comp, in mlxfw_flash_components()
340 mlxfw_mfa2_file_component_put(comp); in mlxfw_flash_components()
347 int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, in mlxfw_firmware_flash()
354 int err; in mlxfw_firmware_flash()
358 "Firmware file is not MFA2", -EINVAL); in mlxfw_firmware_flash()
359 return -EINVAL; in mlxfw_firmware_flash()
373 err = mlxfw_dev->ops->fsm_lock(mlxfw_dev, &fwhandle); in mlxfw_firmware_flash()
401 err = mlxfw_dev->ops->fsm_activate(mlxfw_dev, fwhandle); in mlxfw_firmware_flash()
414 mlxfw_dev->ops->fsm_release(mlxfw_dev, fwhandle); in mlxfw_firmware_flash()
427 mlxfw_dev->ops->fsm_release(mlxfw_dev, fwhandle); in mlxfw_firmware_flash()