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
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
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
33 #ifndef _QED_DEV_API_H
34 #define _QED_DEV_API_H
36 #include <linux/types.h>
37 #include <linux/kernel.h>
38 #include <linux/slab.h>
39 #include <linux/qed/qed_chain.h>
40 #include <linux/qed/qed_if.h>
44 * @brief qed_init_dp - initialize the debug level
50 void qed_init_dp(struct qed_dev
*cdev
,
55 * @brief qed_init_struct - initialize the device structure to
60 void qed_init_struct(struct qed_dev
*cdev
);
63 * @brief qed_resc_free -
67 void qed_resc_free(struct qed_dev
*cdev
);
70 * @brief qed_resc_alloc -
76 int qed_resc_alloc(struct qed_dev
*cdev
);
79 * @brief qed_resc_setup -
83 void qed_resc_setup(struct qed_dev
*cdev
);
86 * @brief qed_hw_init -
91 * @param int_mode - interrupt mode [msix, inta, etc.] to use.
92 * @param allow_npar_tx_switch - npar tx switching to be used
93 * for vports configured for tx-switching.
94 * @param bin_fw_data - binary fw data pointer in binary fw file.
95 * Pass NULL if not using binary fw file.
99 int qed_hw_init(struct qed_dev
*cdev
,
100 struct qed_tunn_start_params
*p_tunn
,
102 enum qed_int_mode int_mode
,
103 bool allow_npar_tx_switch
,
104 const u8
*bin_fw_data
);
107 * @brief qed_hw_timers_stop_all - stop the timers HW block
113 void qed_hw_timers_stop_all(struct qed_dev
*cdev
);
116 * @brief qed_hw_stop -
122 int qed_hw_stop(struct qed_dev
*cdev
);
125 * @brief qed_hw_stop_fastpath -should be called incase
126 * slowpath is still required for the device,
127 * but fastpath is not.
132 void qed_hw_stop_fastpath(struct qed_dev
*cdev
);
135 * @brief qed_hw_start_fastpath -restart fastpath traffic,
136 * only if hw_stop_fastpath was called
141 void qed_hw_start_fastpath(struct qed_hwfn
*p_hwfn
);
144 * @brief qed_hw_reset -
150 int qed_hw_reset(struct qed_dev
*cdev
);
153 * @brief qed_hw_prepare -
156 * @param personality - personality to initialize
160 int qed_hw_prepare(struct qed_dev
*cdev
,
164 * @brief qed_hw_remove -
168 void qed_hw_remove(struct qed_dev
*cdev
);
171 * @brief qed_ptt_acquire - Allocate a PTT window
173 * Should be called at the entry point to the driver (at the beginning of an
178 * @return struct qed_ptt
180 struct qed_ptt
*qed_ptt_acquire(struct qed_hwfn
*p_hwfn
);
183 * @brief qed_ptt_release - Release PTT Window
185 * Should be called at the end of a flow - at the end of the function that
192 void qed_ptt_release(struct qed_hwfn
*p_hwfn
,
193 struct qed_ptt
*p_ptt
);
194 void qed_reset_vport_stats(struct qed_dev
*cdev
);
196 enum qed_dmae_address_type_t
{
197 QED_DMAE_ADDRESS_HOST_VIRT
,
198 QED_DMAE_ADDRESS_HOST_PHYS
,
202 /* value of flags If QED_DMAE_FLAG_RW_REPL_SRC flag is set and the
203 * source is a block of length DMAE_MAX_RW_SIZE and the
204 * destination is larger, the source block will be duplicated as
205 * many times as required to fill the destination block. This is
206 * used mostly to write a zeroed buffer to destination address
209 #define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
210 #define QED_DMAE_FLAG_VF_SRC 0x00000002
211 #define QED_DMAE_FLAG_VF_DST 0x00000004
212 #define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
214 struct qed_dmae_params
{
215 u32 flags
; /* consists of QED_DMAE_FLAG_* values */
221 * @brief qed_dmae_host2grc - copy data from source addr to
222 * dmae registers using the given ptt
227 * @param grc_addr (dmae_data_offset)
228 * @param size_in_dwords
229 * @param flags (one of the flags defined above)
232 qed_dmae_host2grc(struct qed_hwfn
*p_hwfn
,
233 struct qed_ptt
*p_ptt
,
240 * @brief qed_dmae_grc2host - Read data from dmae data offset
241 * to source address using the given ptt
244 * @param grc_addr (dmae_data_offset)
246 * @param size_in_dwords
247 * @param flags - one of the flags defined above
249 int qed_dmae_grc2host(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
,
250 u32 grc_addr
, dma_addr_t dest_addr
, u32 size_in_dwords
,
254 * @brief qed_dmae_host2host - copy data from to source address
255 * to a destination adress (for SRIOV) using the given ptt
261 * @param size_in_dwords
264 int qed_dmae_host2host(struct qed_hwfn
*p_hwfn
,
265 struct qed_ptt
*p_ptt
,
266 dma_addr_t source_addr
,
267 dma_addr_t dest_addr
,
268 u32 size_in_dwords
, struct qed_dmae_params
*p_params
);
271 * @brief qed_chain_alloc - Allocate and initialize a chain
274 * @param intended_use
283 qed_chain_alloc(struct qed_dev
*cdev
,
284 enum qed_chain_use_mode intended_use
,
285 enum qed_chain_mode mode
,
286 enum qed_chain_cnt_type cnt_type
,
287 u32 num_elems
, size_t elem_size
, struct qed_chain
*p_chain
);
290 * @brief qed_chain_free - Free chain DMA memory
295 void qed_chain_free(struct qed_dev
*cdev
, struct qed_chain
*p_chain
);
298 * @@brief qed_fw_l2_queue - Get absolute L2 queue ID
301 * @param src_id - relative to p_hwfn
302 * @param dst_id - absolute per engine
306 int qed_fw_l2_queue(struct qed_hwfn
*p_hwfn
,
311 * @@brief qed_fw_vport - Get absolute vport ID
314 * @param src_id - relative to p_hwfn
315 * @param dst_id - absolute per engine
319 int qed_fw_vport(struct qed_hwfn
*p_hwfn
,
324 * @@brief qed_fw_rss_eng - Get absolute RSS engine ID
327 * @param src_id - relative to p_hwfn
328 * @param dst_id - absolute per engine
332 int qed_fw_rss_eng(struct qed_hwfn
*p_hwfn
,
337 * @brief qed_llh_add_mac_filter - configures a MAC filter in llh
341 * @param p_filter - MAC to add
343 int qed_llh_add_mac_filter(struct qed_hwfn
*p_hwfn
,
344 struct qed_ptt
*p_ptt
, u8
*p_filter
);
347 * @brief qed_llh_remove_mac_filter - removes a MAC filter from llh
351 * @param p_filter - MAC to remove
353 void qed_llh_remove_mac_filter(struct qed_hwfn
*p_hwfn
,
354 struct qed_ptt
*p_ptt
, u8
*p_filter
);
356 enum qed_llh_port_filter_type_t
{
357 QED_LLH_FILTER_ETHERTYPE
,
358 QED_LLH_FILTER_TCP_SRC_PORT
,
359 QED_LLH_FILTER_TCP_DEST_PORT
,
360 QED_LLH_FILTER_TCP_SRC_AND_DEST_PORT
,
361 QED_LLH_FILTER_UDP_SRC_PORT
,
362 QED_LLH_FILTER_UDP_DEST_PORT
,
363 QED_LLH_FILTER_UDP_SRC_AND_DEST_PORT
367 * @brief qed_llh_add_protocol_filter - configures a protocol filter in llh
371 * @param source_port_or_eth_type - source port or ethertype to add
372 * @param dest_port - destination port to add
373 * @param type - type of filters and comparing
376 qed_llh_add_protocol_filter(struct qed_hwfn
*p_hwfn
,
377 struct qed_ptt
*p_ptt
,
378 u16 source_port_or_eth_type
,
380 enum qed_llh_port_filter_type_t type
);
383 * @brief qed_llh_remove_protocol_filter - remove a protocol filter in llh
387 * @param source_port_or_eth_type - source port or ethertype to add
388 * @param dest_port - destination port to add
389 * @param type - type of filters and comparing
392 qed_llh_remove_protocol_filter(struct qed_hwfn
*p_hwfn
,
393 struct qed_ptt
*p_ptt
,
394 u16 source_port_or_eth_type
,
396 enum qed_llh_port_filter_type_t type
);
399 * *@brief Cleanup of previous driver remains prior to load
403 * @param id - For PF, engine-relative. For VF, PF-relative.
404 * @param is_vf - true iff cleanup is made for a VF.
408 int qed_final_cleanup(struct qed_hwfn
*p_hwfn
,
409 struct qed_ptt
*p_ptt
, u16 id
, bool is_vf
);
412 * @brief qed_set_rxq_coalesce - Configure coalesce parameters for an Rx queue
413 * The fact that we can configure coalescing to up to 511, but on varying
414 * accuracy [the bigger the value the less accurate] up to a mistake of 3usec
415 * for the highest values.
419 * @param coalesce - Coalesce value in micro seconds.
420 * @param qid - Queue index.
425 int qed_set_rxq_coalesce(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
,
426 u16 coalesce
, u8 qid
, u16 sb_id
);
429 * @brief qed_set_txq_coalesce - Configure coalesce parameters for a Tx queue
430 * While the API allows setting coalescing per-qid, all tx queues sharing a
431 * SB should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
432 * otherwise configuration would break.
436 * @param coalesce - Coalesce value in micro seconds.
437 * @param qid - Queue index.
442 int qed_set_txq_coalesce(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
,
443 u16 coalesce
, u8 qid
, u16 sb_id
);