linux/drivers/scsi/lpfc/lpfc_sli4.h

/*******************************************************************
 * This file is part of the Emulex Linux Device Driver for         *
 * Fibre Channel Host Bus Adapters.                                *
 * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term *
 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
 * Copyright (C) 2009-2016 Emulex.  All rights reserved.           *
 * EMULEX and SLI are trademarks of Emulex.                        *
 * www.broadcom.com                                                *
 *                                                                 *
 * This program is free software; you can redistribute it and/or   *
 * modify it under the terms of version 2 of the GNU General       *
 * Public License as published by the Free Software Foundation.    *
 * This program is distributed in the hope that it will be useful. *
 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
 * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
 * more details, a copy of which can be found in the file COPYING  *
 * included with this package.                                     *
 *******************************************************************/

#include <linux/irq_poll.h>
#include <linux/cpufreq.h>

#if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_SCSI_LPFC_DEBUG_FS)
#define CONFIG_SCSI_LPFC_DEBUG_FS
#endif

#define LPFC_ACTIVE_MBOX_WAIT_CNT
#define LPFC_XRI_EXCH_BUSY_WAIT_TMO
#define LPFC_XRI_EXCH_BUSY_WAIT_T1
#define LPFC_XRI_EXCH_BUSY_WAIT_T2
#define LPFC_RPI_LOW_WATER_MARK

#define LPFC_UNREG_FCF
#define LPFC_SKIP_UNREG_FCF

/* Amount of time in seconds for waiting FCF rediscovery to complete */
#define LPFC_FCF_REDISCOVER_WAIT_TMO

/* Number of SGL entries can be posted in a 4KB nonembedded mbox command */
#define LPFC_NEMBED_MBOX_SGL_CNT

/* Multi-queue arrangement for FCP EQ/CQ/WQ tuples */
#define LPFC_HBA_HDWQ_MIN
#define LPFC_HBA_HDWQ_MAX
#define LPFC_HBA_HDWQ_DEF

/* irq_chann range, values */
#define LPFC_IRQ_CHANN_MIN
#define LPFC_IRQ_CHANN_MAX
#define LPFC_IRQ_CHANN_DEF

/* FCP MQ queue count limiting */
#define LPFC_FCP_MQ_THRESHOLD_MIN
#define LPFC_FCP_MQ_THRESHOLD_MAX
#define LPFC_FCP_MQ_THRESHOLD_DEF

/*
 * Provide the default FCF Record attributes used by the driver
 * when nonFIP mode is configured and there is no other default
 * FCF Record attributes.
 */
#define LPFC_FCOE_FCF_DEF_INDEX
#define LPFC_FCOE_FCF_GET_FIRST
#define LPFC_FCOE_FCF_NEXT_NONE

#define LPFC_FCOE_NULL_VID
#define LPFC_FCOE_IGNORE_VID

/* First 3 bytes of default FCF MAC is specified by FC_MAP */
#define LPFC_FCOE_FCF_MAC3
#define LPFC_FCOE_FCF_MAC4
#define LPFC_FCOE_FCF_MAC5
#define LPFC_FCOE_FCF_MAP0
#define LPFC_FCOE_FCF_MAP1
#define LPFC_FCOE_FCF_MAP2
#define LPFC_FCOE_MAX_RCV_SIZE
#define LPFC_FCOE_FKA_ADV_PER
#define LPFC_FCOE_FIP_PRIORITY

#define sli4_sid_from_fc_hdr(fc_hdr)

#define sli4_did_from_fc_hdr(fc_hdr)

#define sli4_fctl_from_fc_hdr(fc_hdr)

#define sli4_type_from_fc_hdr(fc_hdr)

#define LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT

#define INT_FW_UPGRADE
#define RUN_FW_UPGRADE

enum lpfc_sli4_queue_type {};

/* The queue sub-type defines the functional purpose of the queue */
enum lpfc_sli4_queue_subtype {};

/* RQ buffer list */
struct lpfc_rqb {};

enum lpfc_poll_mode {};

struct lpfc_idle_stat {};

struct lpfc_queue {};

struct lpfc_sli4_link {};

struct lpfc_fcf_rec {};

struct lpfc_fcf_pri_rec {};

struct lpfc_fcf_pri {};

/*
 * Maximum FCF table index, it is for driver internal book keeping, it
 * just needs to be no less than the supported HBA's FCF table size.
 */
#define LPFC_SLI4_FCF_TBL_INDX_MAX

struct lpfc_fcf {};


#define LPFC_REGION23_SIGNATURE
#define LPFC_REGION23_VERSION
#define LPFC_REGION23_LAST_REC
#define DRIVER_SPECIFIC_TYPE
#define LINUX_DRIVER_ID
#define PORT_STE_TYPE

struct lpfc_fip_param_hdr {};

struct lpfc_fcoe_params {};

struct lpfc_fcf_conn_hdr {};

struct lpfc_fcf_conn_rec {};

struct lpfc_fcf_conn_entry {};

/*
 * Define the host's bootstrap mailbox.  This structure contains
 * the member attributes needed to create, use, and destroy the
 * bootstrap mailbox region.
 *
 * The macro definitions for the bmbx data structure are defined
 * in lpfc_hw4.h with the register definition.
 */
struct lpfc_bmbx {};

#define LPFC_EQE_SIZE

#define LPFC_EQE_SIZE_4B
#define LPFC_EQE_SIZE_16B
#define LPFC_CQE_SIZE
#define LPFC_WQE_SIZE
#define LPFC_WQE128_SIZE
#define LPFC_MQE_SIZE
#define LPFC_RQE_SIZE

#define LPFC_EQE_DEF_COUNT
#define LPFC_CQE_DEF_COUNT
#define LPFC_CQE_EXP_COUNT
#define LPFC_WQE_DEF_COUNT
#define LPFC_WQE_EXP_COUNT
#define LPFC_MQE_DEF_COUNT
#define LPFC_RQE_DEF_COUNT

#define LPFC_QUEUE_NOARM
#define LPFC_QUEUE_REARM


/*
 * SLI4 CT field defines
 */
#define SLI4_CT_RPI
#define SLI4_CT_VPI
#define SLI4_CT_VFI
#define SLI4_CT_FCFI

/*
 * SLI4 specific data structures
 */
struct lpfc_max_cfg_param {};

struct lpfc_hba;
/* SLI4 HBA multi-fcp queue handler struct */
#define LPFC_SLI4_HANDLER_NAME_SZ
struct lpfc_hba_eq_hdl {};

#define lpfc_get_eq_hdl(eqidx)
#define lpfc_get_aff_mask(eqidx)
#define lpfc_get_irq(eqidx)

/*BB Credit recovery value*/
struct lpfc_bbscn_params {};

/* Port Capabilities for SLI4 Parameters */
struct lpfc_pc_sli4_params {};

#define LPFC_CQ_4K_PAGE_SZ
#define LPFC_CQ_16K_PAGE_SZ
#define LPFC_WQ_4K_PAGE_SZ
#define LPFC_WQ_16K_PAGE_SZ

struct lpfc_iov {};

struct lpfc_sli4_lnk_info {};

#define LPFC_SLI4_HANDLER_CNT

/* Used for tracking CPU mapping attributes */
struct lpfc_vector_map_info {};
#define LPFC_VECTOR_MAP_EMPTY

#define LPFC_IRQ_EMPTY

/* Multi-XRI pool */
#define XRI_BATCH

struct lpfc_pbl_pool {};

struct lpfc_pvt_pool {};

struct lpfc_multixri_pool {};

struct lpfc_fc4_ctrl_stat {};

#ifdef LPFC_HDWQ_LOCK_STAT
struct lpfc_lock_stat {
	uint32_t alloc_xri_get;
	uint32_t alloc_xri_put;
	uint32_t free_xri;
	uint32_t wq_access;
	uint32_t alloc_pvt_pool;
	uint32_t mv_from_pvt_pool;
	uint32_t mv_to_pub_pool;
	uint32_t mv_to_pvt_pool;
	uint32_t free_pub_pool;
	uint32_t free_pvt_pool;
};
#endif

struct lpfc_eq_intr_info {};

/* SLI4 HBA data structure entries */
struct lpfc_sli4_hdw_queue {};

#ifdef LPFC_HDWQ_LOCK_STAT
/* compile time trylock stats */
#define lpfc_qp_spin_lock_irqsave
#define lpfc_qp_spin_lock
#else
#define lpfc_qp_spin_lock_irqsave(lock, flag, qp, lstat)
#define lpfc_qp_spin_lock(lock, qp, lstat)
#endif

#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
struct lpfc_hdwq_stat {};
#endif

struct lpfc_sli4_hba {};

enum lpfc_sge_type {};

enum lpfc_sgl_state {};

struct lpfc_sglq {};

struct lpfc_rpi_hdr {};

struct lpfc_rsrc_blks {};

struct lpfc_rdp_context {};

struct lpfc_lcb_context {};


/*
 * SLI4 specific function prototypes
 */
int lpfc_pci_function_reset(struct lpfc_hba *);
int lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *);
int lpfc_sli4_hba_setup(struct lpfc_hba *);
int lpfc_sli4_config(struct lpfc_hba *, struct lpfcMboxq *, uint8_t,
		     uint8_t, uint32_t, bool);
void lpfc_sli4_mbox_cmd_free(struct lpfc_hba *, struct lpfcMboxq *);
void lpfc_sli4_mbx_sge_set(struct lpfcMboxq *, uint32_t, dma_addr_t, uint32_t);
void lpfc_sli4_mbx_sge_get(struct lpfcMboxq *, uint32_t,
			   struct lpfc_mbx_sge *);
int lpfc_sli4_mbx_read_fcf_rec(struct lpfc_hba *, struct lpfcMboxq *,
			       uint16_t);

void lpfc_sli4_hba_reset(struct lpfc_hba *);
struct lpfc_queue *lpfc_sli4_queue_alloc(struct lpfc_hba *phba,
					 uint32_t page_size,
					 uint32_t entry_size,
					 uint32_t entry_count, int cpu);
void lpfc_sli4_queue_free(struct lpfc_queue *);
int lpfc_eq_create(struct lpfc_hba *, struct lpfc_queue *, uint32_t);
void lpfc_modify_hba_eq_delay(struct lpfc_hba *phba, uint32_t startq,
			     uint32_t numq, uint32_t usdelay);
int lpfc_cq_create(struct lpfc_hba *, struct lpfc_queue *,
			struct lpfc_queue *, uint32_t, uint32_t);
int lpfc_cq_create_set(struct lpfc_hba *phba, struct lpfc_queue **cqp,
			struct lpfc_sli4_hdw_queue *hdwq, uint32_t type,
			uint32_t subtype);
int32_t lpfc_mq_create(struct lpfc_hba *, struct lpfc_queue *,
		       struct lpfc_queue *, uint32_t);
int lpfc_wq_create(struct lpfc_hba *, struct lpfc_queue *,
			struct lpfc_queue *, uint32_t);
int lpfc_rq_create(struct lpfc_hba *, struct lpfc_queue *,
			struct lpfc_queue *, struct lpfc_queue *, uint32_t);
int lpfc_mrq_create(struct lpfc_hba *phba, struct lpfc_queue **hrqp,
			struct lpfc_queue **drqp, struct lpfc_queue **cqp,
			uint32_t subtype);
int lpfc_eq_destroy(struct lpfc_hba *, struct lpfc_queue *);
int lpfc_cq_destroy(struct lpfc_hba *, struct lpfc_queue *);
int lpfc_mq_destroy(struct lpfc_hba *, struct lpfc_queue *);
int lpfc_wq_destroy(struct lpfc_hba *, struct lpfc_queue *);
int lpfc_rq_destroy(struct lpfc_hba *, struct lpfc_queue *,
			 struct lpfc_queue *);
int lpfc_sli4_queue_setup(struct lpfc_hba *);
void lpfc_sli4_queue_unset(struct lpfc_hba *);
int lpfc_sli4_post_sgl(struct lpfc_hba *, dma_addr_t, dma_addr_t, uint16_t);
int lpfc_repost_io_sgl_list(struct lpfc_hba *phba);
uint16_t lpfc_sli4_next_xritag(struct lpfc_hba *);
void lpfc_sli4_free_xri(struct lpfc_hba *, int);
int lpfc_sli4_post_async_mbox(struct lpfc_hba *);
struct lpfc_cq_event *__lpfc_sli4_cq_event_alloc(struct lpfc_hba *);
struct lpfc_cq_event *lpfc_sli4_cq_event_alloc(struct lpfc_hba *);
void __lpfc_sli4_cq_event_release(struct lpfc_hba *, struct lpfc_cq_event *);
void lpfc_sli4_cq_event_release(struct lpfc_hba *, struct lpfc_cq_event *);
int lpfc_sli4_init_rpi_hdrs(struct lpfc_hba *);
int lpfc_sli4_post_rpi_hdr(struct lpfc_hba *, struct lpfc_rpi_hdr *);
int lpfc_sli4_post_all_rpi_hdrs(struct lpfc_hba *);
struct lpfc_rpi_hdr *lpfc_sli4_create_rpi_hdr(struct lpfc_hba *);
void lpfc_sli4_remove_rpi_hdrs(struct lpfc_hba *);
int lpfc_sli4_alloc_rpi(struct lpfc_hba *);
void lpfc_sli4_free_rpi(struct lpfc_hba *, int);
void lpfc_sli4_remove_rpis(struct lpfc_hba *);
void lpfc_sli4_async_event_proc(struct lpfc_hba *);
void lpfc_sli4_fcf_redisc_event_proc(struct lpfc_hba *);
int lpfc_sli4_resume_rpi(struct lpfc_nodelist *ndlp,
			 void (*cmpl)(struct lpfc_hba *, LPFC_MBOXQ_t *),
			 struct lpfc_iocbq *iocbq);
void lpfc_sli4_els_xri_abort_event_proc(struct lpfc_hba *phba);
void lpfc_sli4_nvme_pci_offline_aborted(struct lpfc_hba *phba,
					struct lpfc_io_buf *lpfc_ncmd);
void lpfc_sli4_nvme_xri_aborted(struct lpfc_hba *phba,
				struct sli4_wcqe_xri_aborted *axri,
				struct lpfc_io_buf *lpfc_ncmd);
void lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba,
			      struct sli4_wcqe_xri_aborted *axri, int idx);
void lpfc_sli4_nvmet_xri_aborted(struct lpfc_hba *phba,
				 struct sli4_wcqe_xri_aborted *axri);
void lpfc_sli4_els_xri_aborted(struct lpfc_hba *,
			       struct sli4_wcqe_xri_aborted *);
void lpfc_sli4_vport_delete_els_xri_aborted(struct lpfc_vport *);
void lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *);
int lpfc_sli4_brdreset(struct lpfc_hba *);
int lpfc_sli4_add_fcf_record(struct lpfc_hba *, struct fcf_record *);
void lpfc_sli_remove_dflt_fcf(struct lpfc_hba *);
int lpfc_sli4_get_els_iocb_cnt(struct lpfc_hba *);
int lpfc_sli4_get_iocb_cnt(struct lpfc_hba *phba);
int lpfc_sli4_init_vpi(struct lpfc_vport *);
void lpfc_sli4_eq_clr_intr(struct lpfc_queue *);
void lpfc_sli4_write_cq_db(struct lpfc_hba *phba, struct lpfc_queue *q,
			   uint32_t count, bool arm);
void lpfc_sli4_write_eq_db(struct lpfc_hba *phba, struct lpfc_queue *q,
			   uint32_t count, bool arm);
void lpfc_sli4_if6_eq_clr_intr(struct lpfc_queue *q);
void lpfc_sli4_if6_write_cq_db(struct lpfc_hba *phba, struct lpfc_queue *q,
			       uint32_t count, bool arm);
void lpfc_sli4_if6_write_eq_db(struct lpfc_hba *phba, struct lpfc_queue *q,
			       uint32_t count, bool arm);
void lpfc_sli4_fcfi_unreg(struct lpfc_hba *, uint16_t);
int lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *, uint16_t);
int lpfc_sli4_fcf_rr_read_fcf_rec(struct lpfc_hba *, uint16_t);
int lpfc_sli4_read_fcf_rec(struct lpfc_hba *, uint16_t);
void lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
void lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
void lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
int lpfc_sli4_unregister_fcf(struct lpfc_hba *);
int lpfc_sli4_post_status_check(struct lpfc_hba *);
uint8_t lpfc_sli_config_mbox_subsys_get(struct lpfc_hba *, LPFC_MBOXQ_t *);
uint8_t lpfc_sli_config_mbox_opcode_get(struct lpfc_hba *, LPFC_MBOXQ_t *);
void lpfc_sli4_ras_dma_free(struct lpfc_hba *phba);
struct sli4_hybrid_sgl *lpfc_get_sgl_per_hdwq(struct lpfc_hba *phba,
					      struct lpfc_io_buf *buf);
struct fcp_cmd_rsp_buf *lpfc_get_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
						      struct lpfc_io_buf *buf);
int lpfc_put_sgl_per_hdwq(struct lpfc_hba *phba, struct lpfc_io_buf *buf);
int lpfc_put_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
				  struct lpfc_io_buf *buf);
void lpfc_free_sgl_per_hdwq(struct lpfc_hba *phba,
			    struct lpfc_sli4_hdw_queue *hdwq);
void lpfc_free_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
				    struct lpfc_sli4_hdw_queue *hdwq);
static inline void *lpfc_sli4_qe(struct lpfc_queue *q, uint16_t idx)
{}

/**
 * lpfc_sli4_unrecoverable_port - Check ERR and RN bits in portstat_reg
 * @portstat_reg: portstat_reg pointer containing portstat_reg contents
 *
 * Description:
 * Use only for SLI4 interface type-2 or later.  If ERR is set && RN is 0, then
 * port is deemed unrecoverable.
 *
 * Returns:
 * true		- ERR && !RN
 * false	- otherwise
 */
static inline bool
lpfc_sli4_unrecoverable_port(struct lpfc_register *portstat_reg)
{}