WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / ethernet / qlogic / qed / qed_hw.h
blob2734f49956f76dc02873e6ed4a753455e982ef09
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /* QLogic qed NIC Driver
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
5 */
7 #ifndef _QED_HW_H
8 #define _QED_HW_H
10 #include <linux/types.h>
11 #include <linux/bitops.h>
12 #include <linux/slab.h>
13 #include <linux/string.h>
14 #include "qed.h"
15 #include "qed_dev_api.h"
17 /* Forward decleration */
18 struct qed_ptt;
20 enum reserved_ptts {
21 RESERVED_PTT_EDIAG,
22 RESERVED_PTT_USER_SPACE,
23 RESERVED_PTT_MAIN,
24 RESERVED_PTT_DPC,
25 RESERVED_PTT_MAX
28 enum _dmae_cmd_dst_mask {
29 DMAE_CMD_DST_MASK_NONE = 0,
30 DMAE_CMD_DST_MASK_PCIE = 1,
31 DMAE_CMD_DST_MASK_GRC = 2
34 enum _dmae_cmd_src_mask {
35 DMAE_CMD_SRC_MASK_PCIE = 0,
36 DMAE_CMD_SRC_MASK_GRC = 1
39 enum _dmae_cmd_crc_mask {
40 DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0,
41 DMAE_CMD_COMP_CRC_EN_MASK_SET = 1
44 /* definitions for DMA constants */
45 #define DMAE_GO_VALUE 0x1
47 #define DMAE_COMPLETION_VAL 0xD1AE
48 #define DMAE_CMD_ENDIANITY 0x2
50 #define DMAE_CMD_SIZE 14
51 #define DMAE_CMD_SIZE_TO_FILL (DMAE_CMD_SIZE - 5)
52 #define DMAE_MIN_WAIT_TIME 0x2
53 #define DMAE_MAX_CLIENTS 32
55 /**
56 * @brief qed_gtt_init - Initialize GTT windows
58 * @param p_hwfn
60 void qed_gtt_init(struct qed_hwfn *p_hwfn);
62 /**
63 * @brief qed_ptt_invalidate - Forces all ptt entries to be re-configured
65 * @param p_hwfn
67 void qed_ptt_invalidate(struct qed_hwfn *p_hwfn);
69 /**
70 * @brief qed_ptt_pool_alloc - Allocate and initialize PTT pool
72 * @param p_hwfn
74 * @return struct _qed_status - success (0), negative - error.
76 int qed_ptt_pool_alloc(struct qed_hwfn *p_hwfn);
78 /**
79 * @brief qed_ptt_pool_free -
81 * @param p_hwfn
83 void qed_ptt_pool_free(struct qed_hwfn *p_hwfn);
85 /**
86 * @brief qed_ptt_get_hw_addr - Get PTT's GRC/HW address
88 * @param p_hwfn
89 * @param p_ptt
91 * @return u32
93 u32 qed_ptt_get_hw_addr(struct qed_hwfn *p_hwfn,
94 struct qed_ptt *p_ptt);
96 /**
97 * @brief qed_ptt_get_bar_addr - Get PPT's external BAR address
99 * @param p_hwfn
100 * @param p_ptt
102 * @return u32
104 u32 qed_ptt_get_bar_addr(struct qed_ptt *p_ptt);
107 * @brief qed_ptt_set_win - Set PTT Window's GRC BAR address
109 * @param p_hwfn
110 * @param new_hw_addr
111 * @param p_ptt
113 void qed_ptt_set_win(struct qed_hwfn *p_hwfn,
114 struct qed_ptt *p_ptt,
115 u32 new_hw_addr);
118 * @brief qed_get_reserved_ptt - Get a specific reserved PTT
120 * @param p_hwfn
121 * @param ptt_idx
123 * @return struct qed_ptt *
125 struct qed_ptt *qed_get_reserved_ptt(struct qed_hwfn *p_hwfn,
126 enum reserved_ptts ptt_idx);
129 * @brief qed_wr - Write value to BAR using the given ptt
131 * @param p_hwfn
132 * @param p_ptt
133 * @param val
134 * @param hw_addr
136 void qed_wr(struct qed_hwfn *p_hwfn,
137 struct qed_ptt *p_ptt,
138 u32 hw_addr,
139 u32 val);
142 * @brief qed_rd - Read value from BAR using the given ptt
144 * @param p_hwfn
145 * @param p_ptt
146 * @param val
147 * @param hw_addr
149 u32 qed_rd(struct qed_hwfn *p_hwfn,
150 struct qed_ptt *p_ptt,
151 u32 hw_addr);
154 * @brief qed_memcpy_from - copy n bytes from BAR using the given
155 * ptt
157 * @param p_hwfn
158 * @param p_ptt
159 * @param dest
160 * @param hw_addr
161 * @param n
163 void qed_memcpy_from(struct qed_hwfn *p_hwfn,
164 struct qed_ptt *p_ptt,
165 void *dest,
166 u32 hw_addr,
167 size_t n);
170 * @brief qed_memcpy_to - copy n bytes to BAR using the given
171 * ptt
173 * @param p_hwfn
174 * @param p_ptt
175 * @param hw_addr
176 * @param src
177 * @param n
179 void qed_memcpy_to(struct qed_hwfn *p_hwfn,
180 struct qed_ptt *p_ptt,
181 u32 hw_addr,
182 void *src,
183 size_t n);
185 * @brief qed_fid_pretend - pretend to another function when
186 * accessing the ptt window. There is no way to unpretend
187 * a function. The only way to cancel a pretend is to
188 * pretend back to the original function.
190 * @param p_hwfn
191 * @param p_ptt
192 * @param fid - fid field of pxp_pretend structure. Can contain
193 * either pf / vf, port/path fields are don't care.
195 void qed_fid_pretend(struct qed_hwfn *p_hwfn,
196 struct qed_ptt *p_ptt,
197 u16 fid);
200 * @brief qed_port_pretend - pretend to another port when
201 * accessing the ptt window
203 * @param p_hwfn
204 * @param p_ptt
205 * @param port_id - the port to pretend to
207 void qed_port_pretend(struct qed_hwfn *p_hwfn,
208 struct qed_ptt *p_ptt,
209 u8 port_id);
212 * @brief qed_port_unpretend - cancel any previously set port
213 * pretend
215 * @param p_hwfn
216 * @param p_ptt
218 void qed_port_unpretend(struct qed_hwfn *p_hwfn,
219 struct qed_ptt *p_ptt);
222 * @brief qed_port_fid_pretend - pretend to another port and another function
223 * when accessing the ptt window
225 * @param p_hwfn
226 * @param p_ptt
227 * @param port_id - the port to pretend to
228 * @param fid - fid field of pxp_pretend structure. Can contain either pf / vf.
230 void qed_port_fid_pretend(struct qed_hwfn *p_hwfn,
231 struct qed_ptt *p_ptt, u8 port_id, u16 fid);
234 * @brief qed_vfid_to_concrete - build a concrete FID for a
235 * given VF ID
237 * @param p_hwfn
238 * @param p_ptt
239 * @param vfid
241 u32 qed_vfid_to_concrete(struct qed_hwfn *p_hwfn, u8 vfid);
244 * @brief qed_dmae_idx_to_go_cmd - map the idx to dmae cmd
245 * this is declared here since other files will require it.
246 * @param idx
248 u32 qed_dmae_idx_to_go_cmd(u8 idx);
251 * @brief qed_dmae_info_alloc - Init the dmae_info structure
252 * which is part of p_hwfn.
253 * @param p_hwfn
255 int qed_dmae_info_alloc(struct qed_hwfn *p_hwfn);
258 * @brief qed_dmae_info_free - Free the dmae_info structure
259 * which is part of p_hwfn
261 * @param p_hwfn
263 void qed_dmae_info_free(struct qed_hwfn *p_hwfn);
265 union qed_qm_pq_params {
266 struct {
267 u8 q_idx;
268 } iscsi;
270 struct {
271 u8 tc;
272 } core;
274 struct {
275 u8 is_vf;
276 u8 vf_id;
277 u8 tc;
278 } eth;
280 struct {
281 u8 dcqcn;
282 u8 qpid; /* roce relative */
283 } roce;
286 int qed_init_fw_data(struct qed_dev *cdev,
287 const u8 *fw_data);
289 int qed_dmae_sanity(struct qed_hwfn *p_hwfn,
290 struct qed_ptt *p_ptt, const char *phase);
292 #define QED_HW_ERR_MAX_STR_SIZE 256
295 * @brief qed_hw_err_notify - Notify upper layer driver and management FW
296 * about a HW error.
298 * @param p_hwfn
299 * @param p_ptt
300 * @param err_type
301 * @param fmt - debug data buffer to send to the MFW
302 * @param ... - buffer format args
304 void __printf(4, 5) __cold qed_hw_err_notify(struct qed_hwfn *p_hwfn,
305 struct qed_ptt *p_ptt,
306 enum qed_hw_err_type err_type,
307 const char *fmt, ...);
308 #endif