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
);
85 enum qed_override_force_load
{
86 QED_OVERRIDE_FORCE_LOAD_NONE
,
87 QED_OVERRIDE_FORCE_LOAD_ALWAYS
,
88 QED_OVERRIDE_FORCE_LOAD_NEVER
,
91 struct qed_drv_load_params
{
92 /* Indicates whether the driver is running over a crash kernel.
93 * As part of the load request, this will be used for providing the
94 * driver role to the MFW.
95 * In case of a crash kernel over PDA - this should be set to false.
99 /* The timeout value that the MFW should use when locking the engine for
100 * the driver load process.
101 * A value of '0' means the default value, and '255' means no timeout.
104 #define QED_LOAD_REQ_LOCK_TO_DEFAULT 0
105 #define QED_LOAD_REQ_LOCK_TO_NONE 255
107 /* Avoid engine reset when first PF loads on it */
108 bool avoid_eng_reset
;
110 /* Allow overriding the default force load behavior */
111 enum qed_override_force_load override_force_load
;
114 struct qed_hw_init_params
{
115 /* Tunneling parameters */
116 struct qed_tunnel_info
*p_tunn
;
120 /* Interrupt mode [msix, inta, etc.] to use */
121 enum qed_int_mode int_mode
;
123 /* NPAR tx switching to be used for vports for tx-switching */
124 bool allow_npar_tx_switch
;
126 /* Binary fw data pointer in binary fw file */
127 const u8
*bin_fw_data
;
129 /* Driver load parameters */
130 struct qed_drv_load_params
*p_drv_load_params
;
134 * @brief qed_hw_init -
141 int qed_hw_init(struct qed_dev
*cdev
, struct qed_hw_init_params
*p_params
);
144 * @brief qed_hw_timers_stop_all - stop the timers HW block
150 void qed_hw_timers_stop_all(struct qed_dev
*cdev
);
153 * @brief qed_hw_stop -
159 int qed_hw_stop(struct qed_dev
*cdev
);
162 * @brief qed_hw_stop_fastpath -should be called incase
163 * slowpath is still required for the device,
164 * but fastpath is not.
170 int qed_hw_stop_fastpath(struct qed_dev
*cdev
);
173 * @brief qed_hw_start_fastpath -restart fastpath traffic,
174 * only if hw_stop_fastpath was called
180 int qed_hw_start_fastpath(struct qed_hwfn
*p_hwfn
);
184 * @brief qed_hw_prepare -
187 * @param personality - personality to initialize
191 int qed_hw_prepare(struct qed_dev
*cdev
,
195 * @brief qed_hw_remove -
199 void qed_hw_remove(struct qed_dev
*cdev
);
202 * @brief qed_ptt_acquire - Allocate a PTT window
204 * Should be called at the entry point to the driver (at the beginning of an
209 * @return struct qed_ptt
211 struct qed_ptt
*qed_ptt_acquire(struct qed_hwfn
*p_hwfn
);
214 * @brief qed_ptt_release - Release PTT Window
216 * Should be called at the end of a flow - at the end of the function that
223 void qed_ptt_release(struct qed_hwfn
*p_hwfn
,
224 struct qed_ptt
*p_ptt
);
225 void qed_reset_vport_stats(struct qed_dev
*cdev
);
227 enum qed_dmae_address_type_t
{
228 QED_DMAE_ADDRESS_HOST_VIRT
,
229 QED_DMAE_ADDRESS_HOST_PHYS
,
234 * @brief qed_dmae_host2grc - copy data from source addr to
235 * dmae registers using the given ptt
240 * @param grc_addr (dmae_data_offset)
241 * @param size_in_dwords
242 * @param p_params (default parameters will be used in case of NULL)
245 qed_dmae_host2grc(struct qed_hwfn
*p_hwfn
,
246 struct qed_ptt
*p_ptt
,
250 struct qed_dmae_params
*p_params
);
253 * @brief qed_dmae_grc2host - Read data from dmae data offset
254 * to source address using the given ptt
257 * @param grc_addr (dmae_data_offset)
259 * @param size_in_dwords
260 * @param p_params (default parameters will be used in case of NULL)
262 int qed_dmae_grc2host(struct qed_hwfn
*p_hwfn
, struct qed_ptt
*p_ptt
,
263 u32 grc_addr
, dma_addr_t dest_addr
, u32 size_in_dwords
,
264 struct qed_dmae_params
*p_params
);
267 * @brief qed_dmae_host2host - copy data from to source address
268 * to a destination adress (for SRIOV) using the given ptt
274 * @param size_in_dwords
275 * @param p_params (default parameters will be used in case of NULL)
277 int qed_dmae_host2host(struct qed_hwfn
*p_hwfn
,
278 struct qed_ptt
*p_ptt
,
279 dma_addr_t source_addr
,
280 dma_addr_t dest_addr
,
281 u32 size_in_dwords
, struct qed_dmae_params
*p_params
);
284 * @brief qed_chain_alloc - Allocate and initialize a chain
287 * @param intended_use
292 * @param ext_pbl - a possible external PBL
297 qed_chain_alloc(struct qed_dev
*cdev
,
298 enum qed_chain_use_mode intended_use
,
299 enum qed_chain_mode mode
,
300 enum qed_chain_cnt_type cnt_type
,
303 struct qed_chain
*p_chain
, struct qed_chain_ext_pbl
*ext_pbl
);
306 * @brief qed_chain_free - Free chain DMA memory
311 void qed_chain_free(struct qed_dev
*cdev
, struct qed_chain
*p_chain
);
314 * @@brief qed_fw_l2_queue - Get absolute L2 queue ID
317 * @param src_id - relative to p_hwfn
318 * @param dst_id - absolute per engine
322 int qed_fw_l2_queue(struct qed_hwfn
*p_hwfn
,
327 * @@brief qed_fw_vport - Get absolute vport ID
330 * @param src_id - relative to p_hwfn
331 * @param dst_id - absolute per engine
335 int qed_fw_vport(struct qed_hwfn
*p_hwfn
,
340 * @@brief qed_fw_rss_eng - Get absolute RSS engine ID
343 * @param src_id - relative to p_hwfn
344 * @param dst_id - absolute per engine
348 int qed_fw_rss_eng(struct qed_hwfn
*p_hwfn
,
353 * @brief qed_llh_get_num_ppfid - Return the allocated number of LLH filter
354 * banks that are allocated to the PF.
358 * @return u8 - Number of LLH filter banks
360 u8
qed_llh_get_num_ppfid(struct qed_dev
*cdev
);
369 * @brief qed_llh_set_ppfid_affinity - Set the engine affinity for the given
373 * @param ppfid - relative within the allocated ppfids ('0' is the default one).
378 int qed_llh_set_ppfid_affinity(struct qed_dev
*cdev
,
379 u8 ppfid
, enum qed_eng eng
);
382 * @brief qed_llh_set_roce_affinity - Set the RoCE engine affinity
389 int qed_llh_set_roce_affinity(struct qed_dev
*cdev
, enum qed_eng eng
);
392 * @brief qed_llh_add_mac_filter - Add a LLH MAC filter into the given filter
396 * @param ppfid - relative within the allocated ppfids ('0' is the default one).
397 * @param mac_addr - MAC to add
399 int qed_llh_add_mac_filter(struct qed_dev
*cdev
,
400 u8 ppfid
, u8 mac_addr
[ETH_ALEN
]);
403 * @brief qed_llh_remove_mac_filter - Remove a LLH MAC filter from the given
407 * @param p_filter - MAC to remove
409 void qed_llh_remove_mac_filter(struct qed_dev
*cdev
,
410 u8 ppfid
, u8 mac_addr
[ETH_ALEN
]);
412 enum qed_llh_prot_filter_type_t
{
413 QED_LLH_FILTER_ETHERTYPE
,
414 QED_LLH_FILTER_TCP_SRC_PORT
,
415 QED_LLH_FILTER_TCP_DEST_PORT
,
416 QED_LLH_FILTER_TCP_SRC_AND_DEST_PORT
,
417 QED_LLH_FILTER_UDP_SRC_PORT
,
418 QED_LLH_FILTER_UDP_DEST_PORT
,
419 QED_LLH_FILTER_UDP_SRC_AND_DEST_PORT
423 * @brief qed_llh_add_protocol_filter - Add a LLH protocol filter into the
427 * @param ppfid - relative within the allocated ppfids ('0' is the default one).
428 * @param type - type of filters and comparing
429 * @param source_port_or_eth_type - source port or ethertype to add
430 * @param dest_port - destination port to add
431 * @param type - type of filters and comparing
434 qed_llh_add_protocol_filter(struct qed_dev
*cdev
,
436 enum qed_llh_prot_filter_type_t type
,
437 u16 source_port_or_eth_type
, u16 dest_port
);
440 * @brief qed_llh_remove_protocol_filter - Remove a LLH protocol filter from
441 * the given filter bank.
444 * @param ppfid - relative within the allocated ppfids ('0' is the default one).
445 * @param type - type of filters and comparing
446 * @param source_port_or_eth_type - source port or ethertype to add
447 * @param dest_port - destination port to add
450 qed_llh_remove_protocol_filter(struct qed_dev
*cdev
,
452 enum qed_llh_prot_filter_type_t type
,
453 u16 source_port_or_eth_type
, u16 dest_port
);
456 * *@brief Cleanup of previous driver remains prior to load
460 * @param id - For PF, engine-relative. For VF, PF-relative.
461 * @param is_vf - true iff cleanup is made for a VF.
465 int qed_final_cleanup(struct qed_hwfn
*p_hwfn
,
466 struct qed_ptt
*p_ptt
, u16 id
, bool is_vf
);
469 * @brief qed_get_queue_coalesce - Retrieve coalesce value for a given queue.
472 * @param p_coal - store coalesce value read from the hardware.
477 int qed_get_queue_coalesce(struct qed_hwfn
*p_hwfn
, u16
*coal
, void *handle
);
480 * @brief qed_set_queue_coalesce - Configure coalesce parameters for Rx and
481 * Tx queue. The fact that we can configure coalescing to up to 511, but on
482 * varying accuracy [the bigger the value the less accurate] up to a mistake
483 * of 3usec for the highest values.
484 * While the API allows setting coalescing per-qid, all queues sharing a SB
485 * should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
486 * otherwise configuration would break.
489 * @param rx_coal - Rx Coalesce value in micro seconds.
490 * @param tx_coal - TX Coalesce value in micro seconds.
496 qed_set_queue_coalesce(u16 rx_coal
, u16 tx_coal
, void *p_handle
);
499 * @brief qed_pglueb_set_pfid_enable - Enable or disable PCI BUS MASTER
503 * @param b_enable - true/false
507 int qed_pglueb_set_pfid_enable(struct qed_hwfn
*p_hwfn
,
508 struct qed_ptt
*p_ptt
, bool b_enable
);
511 * @brief db_recovery_add - add doorbell information to the doorbell
512 * recovery mechanism.
515 * @param db_addr - doorbell address
516 * @param db_data - address of where db_data is stored
517 * @param db_width - doorbell is 32b pr 64b
518 * @param db_space - doorbell recovery addresses are user or kernel space
520 int qed_db_recovery_add(struct qed_dev
*cdev
,
521 void __iomem
*db_addr
,
523 enum qed_db_rec_width db_width
,
524 enum qed_db_rec_space db_space
);
527 * @brief db_recovery_del - remove doorbell information from the doorbell
528 * recovery mechanism. db_data serves as key (db_addr is not unique).
531 * @param db_addr - doorbell address
532 * @param db_data - address where db_data is stored. Serves as key for the
535 int qed_db_recovery_del(struct qed_dev
*cdev
,
536 void __iomem
*db_addr
, void *db_data
);
539 const char *qed_hw_get_resc_name(enum qed_resources res_id
);