treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / ethernet / qlogic / qed / qed_hw.h
blob505e94db939dbc4c51aba338c8142463bd2043ca
1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015-2017 QLogic Corporation
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and /or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
33 #ifndef _QED_HW_H
34 #define _QED_HW_H
36 #include <linux/types.h>
37 #include <linux/bitops.h>
38 #include <linux/slab.h>
39 #include <linux/string.h>
40 #include "qed.h"
41 #include "qed_dev_api.h"
43 /* Forward decleration */
44 struct qed_ptt;
46 enum reserved_ptts {
47 RESERVED_PTT_EDIAG,
48 RESERVED_PTT_USER_SPACE,
49 RESERVED_PTT_MAIN,
50 RESERVED_PTT_DPC,
51 RESERVED_PTT_MAX
54 enum _dmae_cmd_dst_mask {
55 DMAE_CMD_DST_MASK_NONE = 0,
56 DMAE_CMD_DST_MASK_PCIE = 1,
57 DMAE_CMD_DST_MASK_GRC = 2
60 enum _dmae_cmd_src_mask {
61 DMAE_CMD_SRC_MASK_PCIE = 0,
62 DMAE_CMD_SRC_MASK_GRC = 1
65 enum _dmae_cmd_crc_mask {
66 DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0,
67 DMAE_CMD_COMP_CRC_EN_MASK_SET = 1
70 /* definitions for DMA constants */
71 #define DMAE_GO_VALUE 0x1
73 #define DMAE_COMPLETION_VAL 0xD1AE
74 #define DMAE_CMD_ENDIANITY 0x2
76 #define DMAE_CMD_SIZE 14
77 #define DMAE_CMD_SIZE_TO_FILL (DMAE_CMD_SIZE - 5)
78 #define DMAE_MIN_WAIT_TIME 0x2
79 #define DMAE_MAX_CLIENTS 32
81 /**
82 * @brief qed_gtt_init - Initialize GTT windows
84 * @param p_hwfn
86 void qed_gtt_init(struct qed_hwfn *p_hwfn);
88 /**
89 * @brief qed_ptt_invalidate - Forces all ptt entries to be re-configured
91 * @param p_hwfn
93 void qed_ptt_invalidate(struct qed_hwfn *p_hwfn);
95 /**
96 * @brief qed_ptt_pool_alloc - Allocate and initialize PTT pool
98 * @param p_hwfn
100 * @return struct _qed_status - success (0), negative - error.
102 int qed_ptt_pool_alloc(struct qed_hwfn *p_hwfn);
105 * @brief qed_ptt_pool_free -
107 * @param p_hwfn
109 void qed_ptt_pool_free(struct qed_hwfn *p_hwfn);
112 * @brief qed_ptt_get_hw_addr - Get PTT's GRC/HW address
114 * @param p_hwfn
115 * @param p_ptt
117 * @return u32
119 u32 qed_ptt_get_hw_addr(struct qed_hwfn *p_hwfn,
120 struct qed_ptt *p_ptt);
123 * @brief qed_ptt_get_bar_addr - Get PPT's external BAR address
125 * @param p_hwfn
126 * @param p_ptt
128 * @return u32
130 u32 qed_ptt_get_bar_addr(struct qed_ptt *p_ptt);
133 * @brief qed_ptt_set_win - Set PTT Window's GRC BAR address
135 * @param p_hwfn
136 * @param new_hw_addr
137 * @param p_ptt
139 void qed_ptt_set_win(struct qed_hwfn *p_hwfn,
140 struct qed_ptt *p_ptt,
141 u32 new_hw_addr);
144 * @brief qed_get_reserved_ptt - Get a specific reserved PTT
146 * @param p_hwfn
147 * @param ptt_idx
149 * @return struct qed_ptt *
151 struct qed_ptt *qed_get_reserved_ptt(struct qed_hwfn *p_hwfn,
152 enum reserved_ptts ptt_idx);
155 * @brief qed_wr - Write value to BAR using the given ptt
157 * @param p_hwfn
158 * @param p_ptt
159 * @param val
160 * @param hw_addr
162 void qed_wr(struct qed_hwfn *p_hwfn,
163 struct qed_ptt *p_ptt,
164 u32 hw_addr,
165 u32 val);
168 * @brief qed_rd - Read value from BAR using the given ptt
170 * @param p_hwfn
171 * @param p_ptt
172 * @param val
173 * @param hw_addr
175 u32 qed_rd(struct qed_hwfn *p_hwfn,
176 struct qed_ptt *p_ptt,
177 u32 hw_addr);
180 * @brief qed_memcpy_from - copy n bytes from BAR using the given
181 * ptt
183 * @param p_hwfn
184 * @param p_ptt
185 * @param dest
186 * @param hw_addr
187 * @param n
189 void qed_memcpy_from(struct qed_hwfn *p_hwfn,
190 struct qed_ptt *p_ptt,
191 void *dest,
192 u32 hw_addr,
193 size_t n);
196 * @brief qed_memcpy_to - copy n bytes to BAR using the given
197 * ptt
199 * @param p_hwfn
200 * @param p_ptt
201 * @param hw_addr
202 * @param src
203 * @param n
205 void qed_memcpy_to(struct qed_hwfn *p_hwfn,
206 struct qed_ptt *p_ptt,
207 u32 hw_addr,
208 void *src,
209 size_t n);
211 * @brief qed_fid_pretend - pretend to another function when
212 * accessing the ptt window. There is no way to unpretend
213 * a function. The only way to cancel a pretend is to
214 * pretend back to the original function.
216 * @param p_hwfn
217 * @param p_ptt
218 * @param fid - fid field of pxp_pretend structure. Can contain
219 * either pf / vf, port/path fields are don't care.
221 void qed_fid_pretend(struct qed_hwfn *p_hwfn,
222 struct qed_ptt *p_ptt,
223 u16 fid);
226 * @brief qed_port_pretend - pretend to another port when
227 * accessing the ptt window
229 * @param p_hwfn
230 * @param p_ptt
231 * @param port_id - the port to pretend to
233 void qed_port_pretend(struct qed_hwfn *p_hwfn,
234 struct qed_ptt *p_ptt,
235 u8 port_id);
238 * @brief qed_port_unpretend - cancel any previously set port
239 * pretend
241 * @param p_hwfn
242 * @param p_ptt
244 void qed_port_unpretend(struct qed_hwfn *p_hwfn,
245 struct qed_ptt *p_ptt);
248 * @brief qed_port_fid_pretend - pretend to another port and another function
249 * when accessing the ptt window
251 * @param p_hwfn
252 * @param p_ptt
253 * @param port_id - the port to pretend to
254 * @param fid - fid field of pxp_pretend structure. Can contain either pf / vf.
256 void qed_port_fid_pretend(struct qed_hwfn *p_hwfn,
257 struct qed_ptt *p_ptt, u8 port_id, u16 fid);
260 * @brief qed_vfid_to_concrete - build a concrete FID for a
261 * given VF ID
263 * @param p_hwfn
264 * @param p_ptt
265 * @param vfid
267 u32 qed_vfid_to_concrete(struct qed_hwfn *p_hwfn, u8 vfid);
270 * @brief qed_dmae_idx_to_go_cmd - map the idx to dmae cmd
271 * this is declared here since other files will require it.
272 * @param idx
274 u32 qed_dmae_idx_to_go_cmd(u8 idx);
277 * @brief qed_dmae_info_alloc - Init the dmae_info structure
278 * which is part of p_hwfn.
279 * @param p_hwfn
281 int qed_dmae_info_alloc(struct qed_hwfn *p_hwfn);
284 * @brief qed_dmae_info_free - Free the dmae_info structure
285 * which is part of p_hwfn
287 * @param p_hwfn
289 void qed_dmae_info_free(struct qed_hwfn *p_hwfn);
291 union qed_qm_pq_params {
292 struct {
293 u8 q_idx;
294 } iscsi;
296 struct {
297 u8 tc;
298 } core;
300 struct {
301 u8 is_vf;
302 u8 vf_id;
303 u8 tc;
304 } eth;
306 struct {
307 u8 dcqcn;
308 u8 qpid; /* roce relative */
309 } roce;
312 int qed_init_fw_data(struct qed_dev *cdev,
313 const u8 *fw_data);
315 int qed_dmae_sanity(struct qed_hwfn *p_hwfn,
316 struct qed_ptt *p_ptt, const char *phase);
318 #endif