linux/drivers/net/ethernet/qlogic/qed/qed_l2.h

/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
/* QLogic qed NIC Driver
 * Copyright (c) 2015-2017  QLogic Corporation
 * Copyright (c) 2019-2020 Marvell International Ltd.
 */

#ifndef _QED_L2_H
#define _QED_L2_H
#include <linux/types.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/qed/qed_eth_if.h>
#include "qed.h"
#include "qed_hw.h"
#include "qed_sp.h"
struct qed_rss_params {};

struct qed_sge_tpa_params {};

enum qed_filter_opcode {};

enum qed_filter_ucast_type {};

struct qed_filter_ucast {};

struct qed_filter_mcast {};

/**
 * qed_eth_rx_queue_stop(): This ramrod closes an Rx queue.
 *
 * @p_hwfn: HW device data.
 * @p_rxq: Handler of queue to close
 * @eq_completion_only: If True completion will be on
 *                      EQe, if False completion will be
 *                      on EQe if p_hwfn opaque
 *                      different from the RXQ opaque
 *                      otherwise on CQe.
 * @cqe_completion: If True completion will be receive on CQe.
 *
 * Return: Int.
 */
int
qed_eth_rx_queue_stop(struct qed_hwfn *p_hwfn,
		      void *p_rxq,
		      bool eq_completion_only, bool cqe_completion);

/**
 * qed_eth_tx_queue_stop(): Closes a Tx queue.
 *
 * @p_hwfn: HW device data.
 * @p_txq: handle to Tx queue needed to be closed.
 *
 * Return: Int.
 */
int qed_eth_tx_queue_stop(struct qed_hwfn *p_hwfn, void *p_txq);

enum qed_tpa_mode {};

struct qed_sp_vport_start_params {};

int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
			   struct qed_sp_vport_start_params *p_params);

struct qed_filter_accept_flags {};

struct qed_arfs_config_params {};

struct qed_sp_vport_update_params {};

int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
			struct qed_sp_vport_update_params *p_params,
			enum spq_mode comp_mode,
			struct qed_spq_comp_cb *p_comp_data);

/**
 * qed_sp_vport_stop: This ramrod closes a VPort after all its
 *                    RX and TX queues are terminated.
 *                    An Assert is generated if any queues are left open.
 *
 * @p_hwfn: HW device data.
 * @opaque_fid: Opaque FID
 * @vport_id: VPort ID.
 *
 * Return: Int.
 */
int qed_sp_vport_stop(struct qed_hwfn *p_hwfn, u16 opaque_fid, u8 vport_id);

int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
			    u16 opaque_fid,
			    struct qed_filter_ucast *p_filter_cmd,
			    enum spq_mode comp_mode,
			    struct qed_spq_comp_cb *p_comp_data);

/**
 * qed_sp_eth_rx_queues_update(): This ramrod updates an RX queue.
 *                                It is used for setting the active state
 *                                of the queue and updating the TPA and
 *                                SGE parameters.
 * @p_hwfn: HW device data.
 * @pp_rxq_handlers: An array of queue handlers to be updated.
 * @num_rxqs: number of queues to update.
 * @complete_cqe_flg: Post completion to the CQE Ring if set.
 * @complete_event_flg: Post completion to the Event Ring if set.
 * @comp_mode: Comp mode.
 * @p_comp_data: Pointer Comp data.
 *
 * Return: Int.
 *
 * Note At the moment - only used by non-linux VFs.
 */

int
qed_sp_eth_rx_queues_update(struct qed_hwfn *p_hwfn,
			    void **pp_rxq_handlers,
			    u8 num_rxqs,
			    u8 complete_cqe_flg,
			    u8 complete_event_flg,
			    enum spq_mode comp_mode,
			    struct qed_spq_comp_cb *p_comp_data);

/**
 * qed_get_vport_stats(): Fills provided statistics
 *			  struct with statistics.
 *
 * @cdev: Qed dev pointer.
 * @stats: Points to struct that will be filled with statistics.
 *
 * Return: Void.
 */
void qed_get_vport_stats(struct qed_dev *cdev, struct qed_eth_stats *stats);

/**
 * qed_get_vport_stats_context(): Fills provided statistics
 *				  struct with statistics.
 *
 * @cdev: Qed dev pointer.
 * @stats: Points to struct that will be filled with statistics.
 * @is_atomic: Hint from the caller - if the func can sleep or not.
 *
 * Context: The function should not sleep in case is_atomic == true.
 * Return: Void.
 */
void qed_get_vport_stats_context(struct qed_dev *cdev,
				 struct qed_eth_stats *stats,
				 bool is_atomic);

void qed_reset_vport_stats(struct qed_dev *cdev);

/**
 * qed_arfs_mode_configure(): Enable or disable rfs mode.
 *                            It must accept at least one of tcp or udp true
 *                            and at least one of ipv4 or ipv6 true to enable
 *                            rfs mode.
 *
 * @p_hwfn: HW device data.
 * @p_ptt: P_ptt.
 * @p_cfg_params: arfs mode configuration parameters.
 *
 * Return. Void.
 */
void qed_arfs_mode_configure(struct qed_hwfn *p_hwfn,
			     struct qed_ptt *p_ptt,
			     struct qed_arfs_config_params *p_cfg_params);

/**
 * qed_configure_rfs_ntuple_filter(): This ramrod should be used to add
 *                                     or remove arfs hw filter
 *
 * @p_hwfn: HW device data.
 * @p_cb: Used for QED_SPQ_MODE_CB,where client would initialize
 *        it with cookie and callback function address, if not
 *        using this mode then client must pass NULL.
 * @p_params: Pointer to params.
 *
 * Return: Void.
 */
int
qed_configure_rfs_ntuple_filter(struct qed_hwfn *p_hwfn,
				struct qed_spq_comp_cb *p_cb,
				struct qed_ntuple_filter_params *p_params);

#define MAX_QUEUES_PER_QZONE
#define QED_QUEUE_CID_SELF

/* Almost identical to the qed_queue_start_common_params,
 * but here we maintain the SB index in IGU CAM.
 */
struct qed_queue_cid_params {};

/* Additional parameters required for initialization of the queue_cid
 * and are relevant only for a PF initializing one for its VFs.
 */
struct qed_queue_cid_vf_params {};

struct qed_queue_cid {};

int qed_l2_alloc(struct qed_hwfn *p_hwfn);
void qed_l2_setup(struct qed_hwfn *p_hwfn);
void qed_l2_free(struct qed_hwfn *p_hwfn);

void qed_eth_queue_cid_release(struct qed_hwfn *p_hwfn,
			       struct qed_queue_cid *p_cid);

struct qed_queue_cid *
qed_eth_queue_to_cid(struct qed_hwfn *p_hwfn,
		     u16 opaque_fid,
		     struct qed_queue_start_common_params *p_params,
		     bool b_is_rx,
		     struct qed_queue_cid_vf_params *p_vf_params);

int
qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
		       struct qed_sp_vport_start_params *p_params);

/**
 * qed_eth_rxq_start_ramrod(): Starts an Rx queue, when queue_cid is
 *                             already prepared
 *
 * @p_hwfn: HW device data.
 * @p_cid: Pointer CID.
 * @bd_max_bytes: Max bytes.
 * @bd_chain_phys_addr: Chain physcial address.
 * @cqe_pbl_addr: PBL address.
 * @cqe_pbl_size: PBL size.
 *
 * Return: Int.
 */
int
qed_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
			 struct qed_queue_cid *p_cid,
			 u16 bd_max_bytes,
			 dma_addr_t bd_chain_phys_addr,
			 dma_addr_t cqe_pbl_addr, u16 cqe_pbl_size);

/**
 * qed_eth_txq_start_ramrod(): Starts a Tx queue, where queue_cid is
 *                             already prepared
 *
 * @p_hwfn: HW device data.
 * @p_cid: Pointer CID.
 * @pbl_addr: PBL address.
 * @pbl_size: PBL size.
 * @pq_id: Parameters for choosing the PQ for this Tx queue.
 *
 * Return: Int.
 */
int
qed_eth_txq_start_ramrod(struct qed_hwfn *p_hwfn,
			 struct qed_queue_cid *p_cid,
			 dma_addr_t pbl_addr, u16 pbl_size, u16 pq_id);

u8 qed_mcast_bin_from_mac(u8 *mac);

int qed_set_rxq_coalesce(struct qed_hwfn *p_hwfn,
			 struct qed_ptt *p_ptt,
			 u16 coalesce, struct qed_queue_cid *p_cid);

int qed_set_txq_coalesce(struct qed_hwfn *p_hwfn,
			 struct qed_ptt *p_ptt,
			 u16 coalesce, struct qed_queue_cid *p_cid);

int qed_get_rxq_coalesce(struct qed_hwfn *p_hwfn,
			 struct qed_ptt *p_ptt,
			 struct qed_queue_cid *p_cid, u16 *p_hw_coal);

int qed_get_txq_coalesce(struct qed_hwfn *p_hwfn,
			 struct qed_ptt *p_ptt,
			 struct qed_queue_cid *p_cid, u16 *p_hw_coal);

#endif