n_tty: Reduce branching in canon_copy_from_read_buf()
[linux/fpc-iii.git] / drivers / net / ethernet / qlogic / qed / qed_hw.h
blobe56d433793be5f19dc57d8b1d3e1cb6d33908db8
1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015 QLogic Corporation
4 * This software is available under the terms of the GNU General Public License
5 * (GPL) Version 2, available from the file COPYING in the main directory of
6 * this source tree.
7 */
9 #ifndef _QED_HW_H
10 #define _QED_HW_H
12 #include <linux/types.h>
13 #include <linux/bitops.h>
14 #include <linux/slab.h>
15 #include <linux/string.h>
16 #include "qed.h"
17 #include "qed_dev_api.h"
19 /* Forward decleration */
20 struct qed_ptt;
22 enum reserved_ptts {
23 RESERVED_PTT_EDIAG,
24 RESERVED_PTT_USER_SPACE,
25 RESERVED_PTT_MAIN,
26 RESERVED_PTT_DPC,
27 RESERVED_PTT_MAX
30 enum _dmae_cmd_dst_mask {
31 DMAE_CMD_DST_MASK_NONE = 0,
32 DMAE_CMD_DST_MASK_PCIE = 1,
33 DMAE_CMD_DST_MASK_GRC = 2
36 enum _dmae_cmd_src_mask {
37 DMAE_CMD_SRC_MASK_PCIE = 0,
38 DMAE_CMD_SRC_MASK_GRC = 1
41 enum _dmae_cmd_crc_mask {
42 DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0,
43 DMAE_CMD_COMP_CRC_EN_MASK_SET = 1
46 /* definitions for DMA constants */
47 #define DMAE_GO_VALUE 0x1
49 #define DMAE_COMPLETION_VAL 0xD1AE
50 #define DMAE_CMD_ENDIANITY 0x2
52 #define DMAE_CMD_SIZE 14
53 #define DMAE_CMD_SIZE_TO_FILL (DMAE_CMD_SIZE - 5)
54 #define DMAE_MIN_WAIT_TIME 0x2
55 #define DMAE_MAX_CLIENTS 32
57 /**
58 * @brief qed_gtt_init - Initialize GTT windows
60 * @param p_hwfn
62 void qed_gtt_init(struct qed_hwfn *p_hwfn);
64 /**
65 * @brief qed_ptt_invalidate - Forces all ptt entries to be re-configured
67 * @param p_hwfn
69 void qed_ptt_invalidate(struct qed_hwfn *p_hwfn);
71 /**
72 * @brief qed_ptt_pool_alloc - Allocate and initialize PTT pool
74 * @param p_hwfn
76 * @return struct _qed_status - success (0), negative - error.
78 int qed_ptt_pool_alloc(struct qed_hwfn *p_hwfn);
80 /**
81 * @brief qed_ptt_pool_free -
83 * @param p_hwfn
85 void qed_ptt_pool_free(struct qed_hwfn *p_hwfn);
87 /**
88 * @brief qed_ptt_get_hw_addr - Get PTT's GRC/HW address
90 * @param p_hwfn
91 * @param p_ptt
93 * @return u32
95 u32 qed_ptt_get_hw_addr(struct qed_hwfn *p_hwfn,
96 struct qed_ptt *p_ptt);
98 /**
99 * @brief qed_ptt_get_bar_addr - Get PPT's external BAR address
101 * @param p_hwfn
102 * @param p_ptt
104 * @return u32
106 u32 qed_ptt_get_bar_addr(struct qed_ptt *p_ptt);
109 * @brief qed_ptt_set_win - Set PTT Window's GRC BAR address
111 * @param p_hwfn
112 * @param new_hw_addr
113 * @param p_ptt
115 void qed_ptt_set_win(struct qed_hwfn *p_hwfn,
116 struct qed_ptt *p_ptt,
117 u32 new_hw_addr);
120 * @brief qed_get_reserved_ptt - Get a specific reserved PTT
122 * @param p_hwfn
123 * @param ptt_idx
125 * @return struct qed_ptt *
127 struct qed_ptt *qed_get_reserved_ptt(struct qed_hwfn *p_hwfn,
128 enum reserved_ptts ptt_idx);
131 * @brief qed_wr - Write value to BAR using the given ptt
133 * @param p_hwfn
134 * @param p_ptt
135 * @param val
136 * @param hw_addr
138 void qed_wr(struct qed_hwfn *p_hwfn,
139 struct qed_ptt *p_ptt,
140 u32 hw_addr,
141 u32 val);
144 * @brief qed_rd - Read value from BAR using the given ptt
146 * @param p_hwfn
147 * @param p_ptt
148 * @param val
149 * @param hw_addr
151 u32 qed_rd(struct qed_hwfn *p_hwfn,
152 struct qed_ptt *p_ptt,
153 u32 hw_addr);
156 * @brief qed_memcpy_from - copy n bytes from BAR using the given
157 * ptt
159 * @param p_hwfn
160 * @param p_ptt
161 * @param dest
162 * @param hw_addr
163 * @param n
165 void qed_memcpy_from(struct qed_hwfn *p_hwfn,
166 struct qed_ptt *p_ptt,
167 void *dest,
168 u32 hw_addr,
169 size_t n);
172 * @brief qed_memcpy_to - copy n bytes to BAR using the given
173 * ptt
175 * @param p_hwfn
176 * @param p_ptt
177 * @param hw_addr
178 * @param src
179 * @param n
181 void qed_memcpy_to(struct qed_hwfn *p_hwfn,
182 struct qed_ptt *p_ptt,
183 u32 hw_addr,
184 void *src,
185 size_t n);
187 * @brief qed_fid_pretend - pretend to another function when
188 * accessing the ptt window. There is no way to unpretend
189 * a function. The only way to cancel a pretend is to
190 * pretend back to the original function.
192 * @param p_hwfn
193 * @param p_ptt
194 * @param fid - fid field of pxp_pretend structure. Can contain
195 * either pf / vf, port/path fields are don't care.
197 void qed_fid_pretend(struct qed_hwfn *p_hwfn,
198 struct qed_ptt *p_ptt,
199 u16 fid);
202 * @brief qed_port_pretend - pretend to another port when
203 * accessing the ptt window
205 * @param p_hwfn
206 * @param p_ptt
207 * @param port_id - the port to pretend to
209 void qed_port_pretend(struct qed_hwfn *p_hwfn,
210 struct qed_ptt *p_ptt,
211 u8 port_id);
214 * @brief qed_port_unpretend - cancel any previously set port
215 * pretend
217 * @param p_hwfn
218 * @param p_ptt
220 void qed_port_unpretend(struct qed_hwfn *p_hwfn,
221 struct qed_ptt *p_ptt);
224 * @brief qed_dmae_idx_to_go_cmd - map the idx to dmae cmd
225 * this is declared here since other files will require it.
226 * @param idx
228 u32 qed_dmae_idx_to_go_cmd(u8 idx);
231 * @brief qed_dmae_info_alloc - Init the dmae_info structure
232 * which is part of p_hwfn.
233 * @param p_hwfn
235 int qed_dmae_info_alloc(struct qed_hwfn *p_hwfn);
238 * @brief qed_dmae_info_free - Free the dmae_info structure
239 * which is part of p_hwfn
241 * @param p_hwfn
243 void qed_dmae_info_free(struct qed_hwfn *p_hwfn);
245 union qed_qm_pq_params {
246 struct {
247 u8 tc;
248 } core;
250 struct {
251 u8 is_vf;
252 u8 vf_id;
253 u8 tc;
254 } eth;
257 u16 qed_get_qm_pq(struct qed_hwfn *p_hwfn,
258 enum protocol_type proto,
259 union qed_qm_pq_params *params);
261 int qed_init_fw_data(struct qed_dev *cdev,
262 const u8 *fw_data);
263 #endif