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
34 #include <linux/types.h>
36 #include <linux/kernel.h>
37 #include <linux/slab.h>
38 #include <linux/qed/qed_eth_if.h>
42 struct qed_rss_params {
46 u8 update_rss_capabilities;
47 u8 update_rss_ind_table;
50 u8 rss_table_size_log;
52 /* Indirection table consist of rx queue handles */
53 void *rss_ind_table[QED_RSS_IND_TABLE_SIZE];
54 u32 rss_key[QED_RSS_KEY_SIZE];
57 struct qed_sge_tpa_params {
58 u8 max_buffers_per_cqe;
63 u8 tpa_ipv4_tunn_en_flg;
64 u8 tpa_ipv6_tunn_en_flg;
66 u8 update_tpa_param_flg;
68 u8 tpa_hdr_data_split_flg;
69 u8 tpa_gro_consistent_flg;
72 u16 tpa_min_size_to_start;
73 u16 tpa_min_size_to_cont;
76 enum qed_filter_opcode {
80 QED_FILTER_REPLACE, /* Delete all MACs and add new one instead */
81 QED_FILTER_FLUSH, /* Removes all filters */
84 enum qed_filter_ucast_type {
89 QED_FILTER_INNER_VLAN,
90 QED_FILTER_INNER_PAIR,
91 QED_FILTER_INNER_MAC_VNI_PAIR,
92 QED_FILTER_MAC_VNI_PAIR,
96 struct qed_filter_ucast {
97 enum qed_filter_opcode opcode;
98 enum qed_filter_ucast_type type;
102 u8 vport_to_remove_from;
103 unsigned char mac[ETH_ALEN];
109 struct qed_filter_mcast {
110 /* MOVE is not supported for multicast */
111 enum qed_filter_opcode opcode;
113 u8 vport_to_remove_from;
115 #define QED_MAX_MC_ADDRS 64
116 unsigned char mac[QED_MAX_MC_ADDRS][ETH_ALEN];
120 * @brief qed_eth_rx_queue_stop - This ramrod closes an Rx queue
123 * @param p_rxq Handler of queue to close
124 * @param eq_completion_only If True completion will be on
125 * EQe, if False completion will be
126 * on EQe if p_hwfn opaque
127 * different from the RXQ opaque
129 * @param cqe_completion If True completion will be
134 qed_eth_rx_queue_stop(struct qed_hwfn *p_hwfn,
136 bool eq_completion_only, bool cqe_completion);
139 * @brief qed_eth_tx_queue_stop - closes a Tx queue
142 * @param p_txq - handle to Tx queue needed to be closed
146 int qed_eth_tx_queue_stop(struct qed_hwfn *p_hwfn, void *p_txq);
155 struct qed_sp_vport_start_params {
156 enum qed_tpa_mode tpa_mode;
157 bool remove_inner_vlan;
159 bool handle_ptp_pkts;
162 u8 max_buffers_per_cqe;
171 int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
172 struct qed_sp_vport_start_params *p_params);
175 struct qed_filter_accept_flags {
176 u8 update_rx_mode_config;
177 u8 update_tx_mode_config;
180 #define QED_ACCEPT_NONE 0x01
181 #define QED_ACCEPT_UCAST_MATCHED 0x02
182 #define QED_ACCEPT_UCAST_UNMATCHED 0x04
183 #define QED_ACCEPT_MCAST_MATCHED 0x08
184 #define QED_ACCEPT_MCAST_UNMATCHED 0x10
185 #define QED_ACCEPT_BCAST 0x20
188 struct qed_arfs_config_params {
196 struct qed_sp_vport_update_params {
199 u8 update_vport_active_rx_flg;
200 u8 vport_active_rx_flg;
201 u8 update_vport_active_tx_flg;
202 u8 vport_active_tx_flg;
203 u8 update_inner_vlan_removal_flg;
204 u8 inner_vlan_removal_flg;
205 u8 silent_vlan_removal_flg;
206 u8 update_default_vlan_enable_flg;
207 u8 default_vlan_enable_flg;
208 u8 update_default_vlan_flg;
210 u8 update_tx_switching_flg;
212 u8 update_approx_mcast_flg;
213 u8 update_anti_spoofing_en_flg;
215 u8 update_accept_any_vlan_flg;
218 struct qed_rss_params *rss_params;
219 struct qed_filter_accept_flags accept_flags;
220 struct qed_sge_tpa_params *sge_tpa_params;
221 u8 update_ctl_frame_check;
226 int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
227 struct qed_sp_vport_update_params *p_params,
228 enum spq_mode comp_mode,
229 struct qed_spq_comp_cb *p_comp_data);
232 * @brief qed_sp_vport_stop -
234 * This ramrod closes a VPort after all its RX and TX queues are terminated.
235 * An Assert is generated if any queues are left open.
239 * @param vport_id VPort ID
243 int qed_sp_vport_stop(struct qed_hwfn *p_hwfn, u16 opaque_fid, u8 vport_id);
245 int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
247 struct qed_filter_ucast *p_filter_cmd,
248 enum spq_mode comp_mode,
249 struct qed_spq_comp_cb *p_comp_data);
252 * @brief qed_sp_rx_eth_queues_update -
254 * This ramrod updates an RX queue. It is used for setting the active state
255 * of the queue and updating the TPA and SGE parameters.
257 * @note At the moment - only used by non-linux VFs.
260 * @param pp_rxq_handlers An array of queue handlers to be updated.
261 * @param num_rxqs number of queues to update.
262 * @param complete_cqe_flg Post completion to the CQE Ring if set
263 * @param complete_event_flg Post completion to the Event Ring if set
271 qed_sp_eth_rx_queues_update(struct qed_hwfn *p_hwfn,
272 void **pp_rxq_handlers,
275 u8 complete_event_flg,
276 enum spq_mode comp_mode,
277 struct qed_spq_comp_cb *p_comp_data);
279 void qed_get_vport_stats(struct qed_dev *cdev, struct qed_eth_stats *stats);
281 void qed_reset_vport_stats(struct qed_dev *cdev);
283 #define MAX_QUEUES_PER_QZONE (sizeof(unsigned long) * 8)
284 #define QED_QUEUE_CID_SELF (0xff)
286 /* Almost identical to the qed_queue_start_common_params,
287 * but here we maintain the SB index in IGU CAM.
289 struct qed_queue_cid_params {
295 /* Additional parameters required for initialization of the queue_cid
296 * and are relevant only for a PF initializing one for its VFs.
298 struct qed_queue_cid_vf_params {
299 /* Should match the VF's relative index */
302 /* 0-based queue index. Should reflect the relative qzone the
303 * VF thinks is associated with it [in its range].
307 /* Indicates a VF is legacy, making it differ in several things:
308 * - Producers would be placed in a different place.
309 * - Makes assumptions regarding the CIDs.
316 struct qed_queue_cid {
317 /* For stats-id, the `rel' is actually absolute as well */
318 struct qed_queue_cid_params rel;
319 struct qed_queue_cid_params abs;
321 /* These have no 'relative' meaning */
330 /* VFs queues are mapped differently, so we need to know the
331 * relative queue associated with them [0-based].
332 * Notice this is relevant on the *PF* queue-cid of its VF's queues,
333 * and not on the VF itself.
338 /* We need an additional index to differentiate between queues opened
339 * for same queue-zone, as VFs would have to communicate the info
340 * to the PF [otherwise PF has no way to differentiate].
345 #define QED_QCID_LEGACY_VF_RX_PROD (BIT(0))
346 #define QED_QCID_LEGACY_VF_CID (BIT(1))
348 struct qed_hwfn *p_owner;
351 int qed_l2_alloc(struct qed_hwfn *p_hwfn);
352 void qed_l2_setup(struct qed_hwfn *p_hwfn);
353 void qed_l2_free(struct qed_hwfn *p_hwfn);
355 void qed_eth_queue_cid_release(struct qed_hwfn *p_hwfn,
356 struct qed_queue_cid *p_cid);
358 struct qed_queue_cid *
359 qed_eth_queue_to_cid(struct qed_hwfn *p_hwfn,
361 struct qed_queue_start_common_params *p_params,
363 struct qed_queue_cid_vf_params *p_vf_params);
366 qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
367 struct qed_sp_vport_start_params *p_params);
370 * @brief - Starts an Rx queue, when queue_cid is already prepared
374 * @param bd_max_bytes
375 * @param bd_chain_phys_addr
376 * @param cqe_pbl_addr
377 * @param cqe_pbl_size
382 qed_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
383 struct qed_queue_cid *p_cid,
385 dma_addr_t bd_chain_phys_addr,
386 dma_addr_t cqe_pbl_addr, u16 cqe_pbl_size);
389 * @brief - Starts a Tx queue, where queue_cid is already prepared
395 * @param p_pq_params - parameters for choosing the PQ for this Tx queue
400 qed_eth_txq_start_ramrod(struct qed_hwfn *p_hwfn,
401 struct qed_queue_cid *p_cid,
402 dma_addr_t pbl_addr, u16 pbl_size, u16 pq_id);
404 u8 qed_mcast_bin_from_mac(u8 *mac);
406 int qed_set_rxq_coalesce(struct qed_hwfn *p_hwfn,
407 struct qed_ptt *p_ptt,
408 u16 coalesce, struct qed_queue_cid *p_cid);
410 int qed_set_txq_coalesce(struct qed_hwfn *p_hwfn,
411 struct qed_ptt *p_ptt,
412 u16 coalesce, struct qed_queue_cid *p_cid);
414 int qed_get_rxq_coalesce(struct qed_hwfn *p_hwfn,
415 struct qed_ptt *p_ptt,
416 struct qed_queue_cid *p_cid, u16 *p_hw_coal);
418 int qed_get_txq_coalesce(struct qed_hwfn *p_hwfn,
419 struct qed_ptt *p_ptt,
420 struct qed_queue_cid *p_cid, u16 *p_hw_coal);