hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
....@@ -1,41 +1,35 @@
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 */
343
354 #ifndef _MLXFW_H
365 #define _MLXFW_H
376
387 #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__)
3933
4034 enum mlxfw_fsm_state {
4135 MLXFW_FSM_STATE_IDLE,
....@@ -61,7 +55,19 @@
6155 MLXFW_FSM_STATE_ERR_MAX,
6256 };
6357
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
+};
6571
6672 struct mlxfw_dev_ops {
6773 int (*component_query)(struct mlxfw_dev *mlxfw_dev, u16 component_index,
....@@ -81,6 +87,8 @@
8187
8288 int (*fsm_activate)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle);
8389
90
+ int (*fsm_reactivate)(struct mlxfw_dev *mlxfw_dev, u8 *status);
91
+
8492 int (*fsm_query_state)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
8593 enum mlxfw_fsm_state *fsm_state,
8694 enum mlxfw_fsm_state_err *fsm_state_err);
....@@ -90,19 +98,15 @@
9098 void (*fsm_release)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle);
9199 };
92100
93
-struct mlxfw_dev {
94
- const struct mlxfw_dev_ops *ops;
95
- const char *psid;
96
- u16 psid_size;
97
-};
98
-
99101 #if IS_REACHABLE(CONFIG_MLXFW)
100102 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);
102105 #else
103106 static inline
104107 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)
106110 {
107111 return -EOPNOTSUPP;
108112 }