1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /* QLogic qed NIC Driver
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
9 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/slab.h>
13 #include <linux/qed/qed_eth_if.h>
17 struct qed_rss_params
{
21 u8 update_rss_capabilities
;
22 u8 update_rss_ind_table
;
25 u8 rss_table_size_log
;
27 /* Indirection table consist of rx queue handles */
28 void *rss_ind_table
[QED_RSS_IND_TABLE_SIZE
];
29 u32 rss_key
[QED_RSS_KEY_SIZE
];
32 struct qed_sge_tpa_params
{
33 u8 max_buffers_per_cqe
;
38 u8 tpa_ipv4_tunn_en_flg
;
39 u8 tpa_ipv6_tunn_en_flg
;
41 u8 update_tpa_param_flg
;
43 u8 tpa_hdr_data_split_flg
;
44 u8 tpa_gro_consistent_flg
;
47 u16 tpa_min_size_to_start
;
48 u16 tpa_min_size_to_cont
;
51 enum qed_filter_opcode
{
55 QED_FILTER_REPLACE
, /* Delete all MACs and add new one instead */
56 QED_FILTER_FLUSH
, /* Removes all filters */
59 enum qed_filter_ucast_type
{
64 QED_FILTER_INNER_VLAN
,
65 QED_FILTER_INNER_PAIR
,
66 QED_FILTER_INNER_MAC_VNI_PAIR
,
67 QED_FILTER_MAC_VNI_PAIR
,
71 struct qed_filter_ucast
{
72 enum qed_filter_opcode opcode
;
73 enum qed_filter_ucast_type type
;
77 u8 vport_to_remove_from
;
78 unsigned char mac
[ETH_ALEN
];
84 struct qed_filter_mcast
{
85 /* MOVE is not supported for multicast */
86 enum qed_filter_opcode opcode
;
88 u8 vport_to_remove_from
;
90 #define QED_MAX_MC_ADDRS 64
91 unsigned char mac
[QED_MAX_MC_ADDRS
][ETH_ALEN
];
95 * qed_eth_rx_queue_stop(): This ramrod closes an Rx queue.
97 * @p_hwfn: HW device data.
98 * @p_rxq: Handler of queue to close
99 * @eq_completion_only: If True completion will be on
100 * EQe, if False completion will be
101 * on EQe if p_hwfn opaque
102 * different from the RXQ opaque
104 * @cqe_completion: If True completion will be receive on CQe.
109 qed_eth_rx_queue_stop(struct qed_hwfn
*p_hwfn
,
111 bool eq_completion_only
, bool cqe_completion
);
114 * qed_eth_tx_queue_stop(): Closes a Tx queue.
116 * @p_hwfn: HW device data.
117 * @p_txq: handle to Tx queue needed to be closed.
121 int qed_eth_tx_queue_stop(struct qed_hwfn
*p_hwfn
, void *p_txq
);
130 struct qed_sp_vport_start_params
{
131 enum qed_tpa_mode tpa_mode
;
132 bool remove_inner_vlan
;
134 bool handle_ptp_pkts
;
137 u8 max_buffers_per_cqe
;
146 int qed_sp_eth_vport_start(struct qed_hwfn
*p_hwfn
,
147 struct qed_sp_vport_start_params
*p_params
);
149 struct qed_filter_accept_flags
{
150 u8 update_rx_mode_config
;
151 u8 update_tx_mode_config
;
154 #define QED_ACCEPT_NONE 0x01
155 #define QED_ACCEPT_UCAST_MATCHED 0x02
156 #define QED_ACCEPT_UCAST_UNMATCHED 0x04
157 #define QED_ACCEPT_MCAST_MATCHED 0x08
158 #define QED_ACCEPT_MCAST_UNMATCHED 0x10
159 #define QED_ACCEPT_BCAST 0x20
160 #define QED_ACCEPT_ANY_VNI 0x40
163 struct qed_arfs_config_params
{
168 enum qed_filter_config_mode mode
;
171 struct qed_sp_vport_update_params
{
174 u8 update_vport_active_rx_flg
;
175 u8 vport_active_rx_flg
;
176 u8 update_vport_active_tx_flg
;
177 u8 vport_active_tx_flg
;
178 u8 update_inner_vlan_removal_flg
;
179 u8 inner_vlan_removal_flg
;
180 u8 silent_vlan_removal_flg
;
181 u8 update_default_vlan_enable_flg
;
182 u8 default_vlan_enable_flg
;
183 u8 update_default_vlan_flg
;
185 u8 update_tx_switching_flg
;
187 u8 update_approx_mcast_flg
;
188 u8 update_anti_spoofing_en_flg
;
190 u8 update_accept_any_vlan_flg
;
193 struct qed_rss_params
*rss_params
;
194 struct qed_filter_accept_flags accept_flags
;
195 struct qed_sge_tpa_params
*sge_tpa_params
;
196 u8 update_ctl_frame_check
;
201 int qed_sp_vport_update(struct qed_hwfn
*p_hwfn
,
202 struct qed_sp_vport_update_params
*p_params
,
203 enum spq_mode comp_mode
,
204 struct qed_spq_comp_cb
*p_comp_data
);
207 * qed_sp_vport_stop: This ramrod closes a VPort after all its
208 * RX and TX queues are terminated.
209 * An Assert is generated if any queues are left open.
211 * @p_hwfn: HW device data.
212 * @opaque_fid: Opaque FID
213 * @vport_id: VPort ID.
217 int qed_sp_vport_stop(struct qed_hwfn
*p_hwfn
, u16 opaque_fid
, u8 vport_id
);
219 int qed_sp_eth_filter_ucast(struct qed_hwfn
*p_hwfn
,
221 struct qed_filter_ucast
*p_filter_cmd
,
222 enum spq_mode comp_mode
,
223 struct qed_spq_comp_cb
*p_comp_data
);
226 * qed_sp_eth_rx_queues_update(): This ramrod updates an RX queue.
227 * It is used for setting the active state
228 * of the queue and updating the TPA and
230 * @p_hwfn: HW device data.
231 * @pp_rxq_handlers: An array of queue handlers to be updated.
232 * @num_rxqs: number of queues to update.
233 * @complete_cqe_flg: Post completion to the CQE Ring if set.
234 * @complete_event_flg: Post completion to the Event Ring if set.
235 * @comp_mode: Comp mode.
236 * @p_comp_data: Pointer Comp data.
240 * Note At the moment - only used by non-linux VFs.
244 qed_sp_eth_rx_queues_update(struct qed_hwfn
*p_hwfn
,
245 void **pp_rxq_handlers
,
248 u8 complete_event_flg
,
249 enum spq_mode comp_mode
,
250 struct qed_spq_comp_cb
*p_comp_data
);
253 * qed_get_vport_stats(): Fills provided statistics
254 * struct with statistics.
256 * @cdev: Qed dev pointer.
257 * @stats: Points to struct that will be filled with statistics.
261 void qed_get_vport_stats(struct qed_dev
*cdev
, struct qed_eth_stats
*stats
);
264 * qed_get_vport_stats_context(): Fills provided statistics
265 * struct with statistics.
267 * @cdev: Qed dev pointer.
268 * @stats: Points to struct that will be filled with statistics.
269 * @is_atomic: Hint from the caller - if the func can sleep or not.
271 * Context: The function should not sleep in case is_atomic == true.
274 void qed_get_vport_stats_context(struct qed_dev
*cdev
,
275 struct qed_eth_stats
*stats
,
278 void qed_reset_vport_stats(struct qed_dev
*cdev
);
281 * qed_arfs_mode_configure(): Enable or disable rfs mode.
282 * It must accept at least one of tcp or udp true
283 * and at least one of ipv4 or ipv6 true to enable
286 * @p_hwfn: HW device data.
288 * @p_cfg_params: arfs mode configuration parameters.
292 void qed_arfs_mode_configure(struct qed_hwfn
*p_hwfn
,
293 struct qed_ptt
*p_ptt
,
294 struct qed_arfs_config_params
*p_cfg_params
);
297 * qed_configure_rfs_ntuple_filter(): This ramrod should be used to add
298 * or remove arfs hw filter
300 * @p_hwfn: HW device data.
301 * @p_cb: Used for QED_SPQ_MODE_CB,where client would initialize
302 * it with cookie and callback function address, if not
303 * using this mode then client must pass NULL.
304 * @p_params: Pointer to params.
309 qed_configure_rfs_ntuple_filter(struct qed_hwfn
*p_hwfn
,
310 struct qed_spq_comp_cb
*p_cb
,
311 struct qed_ntuple_filter_params
*p_params
);
313 #define MAX_QUEUES_PER_QZONE (sizeof(unsigned long) * 8)
314 #define QED_QUEUE_CID_SELF (0xff)
316 /* Almost identical to the qed_queue_start_common_params,
317 * but here we maintain the SB index in IGU CAM.
319 struct qed_queue_cid_params
{
325 /* Additional parameters required for initialization of the queue_cid
326 * and are relevant only for a PF initializing one for its VFs.
328 struct qed_queue_cid_vf_params
{
329 /* Should match the VF's relative index */
332 /* 0-based queue index. Should reflect the relative qzone the
333 * VF thinks is associated with it [in its range].
337 /* Indicates a VF is legacy, making it differ in several things:
338 * - Producers would be placed in a different place.
339 * - Makes assumptions regarding the CIDs.
346 struct qed_queue_cid
{
347 /* For stats-id, the `rel' is actually absolute as well */
348 struct qed_queue_cid_params rel
;
349 struct qed_queue_cid_params abs
;
351 /* These have no 'relative' meaning */
360 /* VFs queues are mapped differently, so we need to know the
361 * relative queue associated with them [0-based].
362 * Notice this is relevant on the *PF* queue-cid of its VF's queues,
363 * and not on the VF itself.
368 /* We need an additional index to differentiate between queues opened
369 * for same queue-zone, as VFs would have to communicate the info
370 * to the PF [otherwise PF has no way to differentiate].
375 #define QED_QCID_LEGACY_VF_RX_PROD (BIT(0))
376 #define QED_QCID_LEGACY_VF_CID (BIT(1))
378 struct qed_hwfn
*p_owner
;
381 int qed_l2_alloc(struct qed_hwfn
*p_hwfn
);
382 void qed_l2_setup(struct qed_hwfn
*p_hwfn
);
383 void qed_l2_free(struct qed_hwfn
*p_hwfn
);
385 void qed_eth_queue_cid_release(struct qed_hwfn
*p_hwfn
,
386 struct qed_queue_cid
*p_cid
);
388 struct qed_queue_cid
*
389 qed_eth_queue_to_cid(struct qed_hwfn
*p_hwfn
,
391 struct qed_queue_start_common_params
*p_params
,
393 struct qed_queue_cid_vf_params
*p_vf_params
);
396 qed_sp_eth_vport_start(struct qed_hwfn
*p_hwfn
,
397 struct qed_sp_vport_start_params
*p_params
);
400 * qed_eth_rxq_start_ramrod(): Starts an Rx queue, when queue_cid is
403 * @p_hwfn: HW device data.
404 * @p_cid: Pointer CID.
405 * @bd_max_bytes: Max bytes.
406 * @bd_chain_phys_addr: Chain physcial address.
407 * @cqe_pbl_addr: PBL address.
408 * @cqe_pbl_size: PBL size.
413 qed_eth_rxq_start_ramrod(struct qed_hwfn
*p_hwfn
,
414 struct qed_queue_cid
*p_cid
,
416 dma_addr_t bd_chain_phys_addr
,
417 dma_addr_t cqe_pbl_addr
, u16 cqe_pbl_size
);
420 * qed_eth_txq_start_ramrod(): Starts a Tx queue, where queue_cid is
423 * @p_hwfn: HW device data.
424 * @p_cid: Pointer CID.
425 * @pbl_addr: PBL address.
426 * @pbl_size: PBL size.
427 * @pq_id: Parameters for choosing the PQ for this Tx queue.
432 qed_eth_txq_start_ramrod(struct qed_hwfn
*p_hwfn
,
433 struct qed_queue_cid
*p_cid
,
434 dma_addr_t pbl_addr
, u16 pbl_size
, u16 pq_id
);
436 u8
qed_mcast_bin_from_mac(u8
*mac
);
438 int qed_set_rxq_coalesce(struct qed_hwfn
*p_hwfn
,
439 struct qed_ptt
*p_ptt
,
440 u16 coalesce
, struct qed_queue_cid
*p_cid
);
442 int qed_set_txq_coalesce(struct qed_hwfn
*p_hwfn
,
443 struct qed_ptt
*p_ptt
,
444 u16 coalesce
, struct qed_queue_cid
*p_cid
);
446 int qed_get_rxq_coalesce(struct qed_hwfn
*p_hwfn
,
447 struct qed_ptt
*p_ptt
,
448 struct qed_queue_cid
*p_cid
, u16
*p_hw_coal
);
450 int qed_get_txq_coalesce(struct qed_hwfn
*p_hwfn
,
451 struct qed_ptt
*p_ptt
,
452 struct qed_queue_cid
*p_cid
, u16
*p_hw_coal
);