.. | .. |
---|
1 | | -/* |
---|
2 | | - * drivers/net/ethernet/mellanox/mlxfw/mlxfw.h |
---|
3 | | - * Copyright (c) 2017 Mellanox Technologies. All rights reserved. |
---|
4 | | - * Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com> |
---|
5 | | - * |
---|
6 | | - * Redistribution and use in source and binary forms, with or without |
---|
7 | | - * modification, are permitted provided that the following conditions are met: |
---|
8 | | - * |
---|
9 | | - * 1. Redistributions of source code must retain the above copyright |
---|
10 | | - * notice, this list of conditions and the following disclaimer. |
---|
11 | | - * 2. Redistributions in binary form must reproduce the above copyright |
---|
12 | | - * notice, this list of conditions and the following disclaimer in the |
---|
13 | | - * documentation and/or other materials provided with the distribution. |
---|
14 | | - * 3. Neither the names of the copyright holders nor the names of its |
---|
15 | | - * contributors may be used to endorse or promote products derived from |
---|
16 | | - * this software without specific prior written permission. |
---|
17 | | - * |
---|
18 | | - * Alternatively, this software may be distributed under the terms of the |
---|
19 | | - * GNU General Public License ("GPL") version 2 as published by the Free |
---|
20 | | - * Software Foundation. |
---|
21 | | - * |
---|
22 | | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
23 | | - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
24 | | - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
25 | | - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
26 | | - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
27 | | - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
28 | | - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
29 | | - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
30 | | - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
31 | | - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
32 | | - * POSSIBILITY OF SUCH DAMAGE. |
---|
33 | | - */ |
---|
| 1 | +/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ |
---|
| 2 | +/* Copyright (c) 2017-2019 Mellanox Technologies. All rights reserved */ |
---|
34 | 3 | |
---|
35 | 4 | #ifndef _MLXFW_H |
---|
36 | 5 | #define _MLXFW_H |
---|
37 | 6 | |
---|
38 | 7 | #include <linux/firmware.h> |
---|
| 8 | +#include <linux/netlink.h> |
---|
| 9 | +#include <linux/device.h> |
---|
| 10 | +#include <net/devlink.h> |
---|
| 11 | + |
---|
| 12 | +struct mlxfw_dev { |
---|
| 13 | + const struct mlxfw_dev_ops *ops; |
---|
| 14 | + const char *psid; |
---|
| 15 | + u16 psid_size; |
---|
| 16 | + struct devlink *devlink; |
---|
| 17 | +}; |
---|
| 18 | + |
---|
| 19 | +static inline |
---|
| 20 | +struct device *mlxfw_dev_dev(struct mlxfw_dev *mlxfw_dev) |
---|
| 21 | +{ |
---|
| 22 | + return mlxfw_dev->devlink->dev; |
---|
| 23 | +} |
---|
| 24 | + |
---|
| 25 | +#define MLXFW_PRFX "mlxfw: " |
---|
| 26 | + |
---|
| 27 | +#define mlxfw_info(mlxfw_dev, fmt, ...) \ |
---|
| 28 | + dev_info(mlxfw_dev_dev(mlxfw_dev), MLXFW_PRFX fmt, ## __VA_ARGS__) |
---|
| 29 | +#define mlxfw_err(mlxfw_dev, fmt, ...) \ |
---|
| 30 | + dev_err(mlxfw_dev_dev(mlxfw_dev), MLXFW_PRFX fmt, ## __VA_ARGS__) |
---|
| 31 | +#define mlxfw_dbg(mlxfw_dev, fmt, ...) \ |
---|
| 32 | + dev_dbg(mlxfw_dev_dev(mlxfw_dev), MLXFW_PRFX fmt, ## __VA_ARGS__) |
---|
39 | 33 | |
---|
40 | 34 | enum mlxfw_fsm_state { |
---|
41 | 35 | MLXFW_FSM_STATE_IDLE, |
---|
.. | .. |
---|
61 | 55 | MLXFW_FSM_STATE_ERR_MAX, |
---|
62 | 56 | }; |
---|
63 | 57 | |
---|
64 | | -struct mlxfw_dev; |
---|
| 58 | +enum mlxfw_fsm_reactivate_status { |
---|
| 59 | + MLXFW_FSM_REACTIVATE_STATUS_OK, |
---|
| 60 | + MLXFW_FSM_REACTIVATE_STATUS_BUSY, |
---|
| 61 | + MLXFW_FSM_REACTIVATE_STATUS_PROHIBITED_FW_VER_ERR, |
---|
| 62 | + MLXFW_FSM_REACTIVATE_STATUS_FIRST_PAGE_COPY_FAILED, |
---|
| 63 | + MLXFW_FSM_REACTIVATE_STATUS_FIRST_PAGE_ERASE_FAILED, |
---|
| 64 | + MLXFW_FSM_REACTIVATE_STATUS_FIRST_PAGE_RESTORE_FAILED, |
---|
| 65 | + MLXFW_FSM_REACTIVATE_STATUS_CANDIDATE_FW_DEACTIVATION_FAILED, |
---|
| 66 | + MLXFW_FSM_REACTIVATE_STATUS_FW_ALREADY_ACTIVATED, |
---|
| 67 | + MLXFW_FSM_REACTIVATE_STATUS_ERR_DEVICE_RESET_REQUIRED, |
---|
| 68 | + MLXFW_FSM_REACTIVATE_STATUS_ERR_FW_PROGRAMMING_NEEDED, |
---|
| 69 | + MLXFW_FSM_REACTIVATE_STATUS_MAX, |
---|
| 70 | +}; |
---|
65 | 71 | |
---|
66 | 72 | struct mlxfw_dev_ops { |
---|
67 | 73 | int (*component_query)(struct mlxfw_dev *mlxfw_dev, u16 component_index, |
---|
.. | .. |
---|
81 | 87 | |
---|
82 | 88 | int (*fsm_activate)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle); |
---|
83 | 89 | |
---|
| 90 | + int (*fsm_reactivate)(struct mlxfw_dev *mlxfw_dev, u8 *status); |
---|
| 91 | + |
---|
84 | 92 | int (*fsm_query_state)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, |
---|
85 | 93 | enum mlxfw_fsm_state *fsm_state, |
---|
86 | 94 | enum mlxfw_fsm_state_err *fsm_state_err); |
---|
.. | .. |
---|
90 | 98 | void (*fsm_release)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle); |
---|
91 | 99 | }; |
---|
92 | 100 | |
---|
93 | | -struct mlxfw_dev { |
---|
94 | | - const struct mlxfw_dev_ops *ops; |
---|
95 | | - const char *psid; |
---|
96 | | - u16 psid_size; |
---|
97 | | -}; |
---|
98 | | - |
---|
99 | 101 | #if IS_REACHABLE(CONFIG_MLXFW) |
---|
100 | 102 | int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, |
---|
101 | | - const struct firmware *firmware); |
---|
| 103 | + const struct firmware *firmware, |
---|
| 104 | + struct netlink_ext_ack *extack); |
---|
102 | 105 | #else |
---|
103 | 106 | static inline |
---|
104 | 107 | int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, |
---|
105 | | - const struct firmware *firmware) |
---|
| 108 | + const struct firmware *firmware, |
---|
| 109 | + struct netlink_ext_ack *extack) |
---|
106 | 110 | { |
---|
107 | 111 | return -EOPNOTSUPP; |
---|
108 | 112 | } |
---|