1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Huawei HiNIC PCI Express Linux driver
3 * Copyright(c) 2017 Huawei Technologies Co., Ltd
6 #ifndef __HINIC_DEVLINK_H__
7 #define __HINIC_DEVLINK_H__
9 #include <net/devlink.h>
10 #include "hinic_dev.h"
12 #define MAX_FW_TYPE_NUM 30
13 #define HINIC_MAGIC_NUM 0x18221100
14 #define UPDATEFW_IMAGE_HEAD_SIZE 1024
15 #define FW_UPDATE_COLD 0
16 #define FW_UPDATE_HOT 1
21 #define MAX_FW_FRAGMENT_LEN 1536
22 #define HINIC_FW_DISMATCH_ERROR 10
25 UP_FW_UPDATE_UP_TEXT_A
= 0x0,
26 UP_FW_UPDATE_UP_DATA_A
,
27 UP_FW_UPDATE_UP_TEXT_B
,
28 UP_FW_UPDATE_UP_DATA_B
,
31 UP_FW_UPDATE_HLINK_ONE
= 0x5,
32 UP_FW_UPDATE_HLINK_TWO
,
33 UP_FW_UPDATE_HLINK_THR
,
35 UP_FW_UPDATE_TILE_TEXT
,
37 UP_FW_UPDATE_TILE_DATA
= 0xa,
38 UP_FW_UPDATE_TILE_DICT
,
39 UP_FW_UPDATE_PPE_STATE
,
40 UP_FW_UPDATE_PPE_BRANCH
,
41 UP_FW_UPDATE_PPE_EXTACT
,
43 UP_FW_UPDATE_CLP_LEGACY
= 0xf,
44 UP_FW_UPDATE_PXE_LEGACY
,
45 UP_FW_UPDATE_ISCSI_LEGACY
,
49 UP_FW_UPDATE_ISCSI_EFI
= 0x14,
56 #define _IMAGE_UP_ALL_IN ((1 << UP_FW_UPDATE_UP_TEXT_A) | \
57 (1 << UP_FW_UPDATE_UP_DATA_A) | \
58 (1 << UP_FW_UPDATE_UP_TEXT_B) | \
59 (1 << UP_FW_UPDATE_UP_DATA_B) | \
60 (1 << UP_FW_UPDATE_UP_DICT) | \
61 (1 << UP_FW_UPDATE_BOOT) | \
62 (1 << UP_FW_UPDATE_HLINK_ONE) | \
63 (1 << UP_FW_UPDATE_HLINK_TWO) | \
64 (1 << UP_FW_UPDATE_HLINK_THR))
66 #define _IMAGE_UCODE_ALL_IN ((1 << UP_FW_UPDATE_TILE_TEXT) | \
67 (1 << UP_FW_UPDATE_TILE_DICT) | \
68 (1 << UP_FW_UPDATE_PPE_STATE) | \
69 (1 << UP_FW_UPDATE_PPE_BRANCH) | \
70 (1 << UP_FW_UPDATE_PPE_EXTACT))
72 #define _IMAGE_COLD_SUB_MODULES_MUST_IN (_IMAGE_UP_ALL_IN | _IMAGE_UCODE_ALL_IN)
73 #define _IMAGE_HOT_SUB_MODULES_MUST_IN (_IMAGE_UP_ALL_IN | _IMAGE_UCODE_ALL_IN)
74 #define _IMAGE_CFG_SUB_MODULES_MUST_IN BIT(UP_FW_UPDATE_CFG)
75 #define UP_FW_UPDATE_UP_TEXT 0x0
76 #define UP_FW_UPDATE_UP_DATA 0x1
77 #define UP_FW_UPDATE_VPD_B 0x15
79 struct fw_section_info_st
{
81 u32 fw_section_offset
;
82 u32 fw_section_version
;
92 u32 fw_section_cnt
:16;
95 struct fw_section_info_st fw_section_info
[MAX_FW_TYPE_NUM
];
101 struct host_image_st
{
102 struct fw_section_info_st image_section_info
[MAX_FW_TYPE_NUM
];
107 u32 section_type_num
;
111 struct devlink
*hinic_devlink_alloc(void);
112 void hinic_devlink_free(struct devlink
*devlink
);
113 int hinic_devlink_register(struct hinic_devlink_priv
*priv
, struct device
*dev
);
114 void hinic_devlink_unregister(struct hinic_devlink_priv
*priv
);
116 int hinic_health_reporters_create(struct hinic_devlink_priv
*priv
);
117 void hinic_health_reporters_destroy(struct hinic_devlink_priv
*priv
);
119 #endif /* __HINIC_DEVLINK_H__ */