^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2014- QLogic Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * All rights reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * www.qlogic.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Contains base driver definitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * bfa_drv.h Linux driver data structures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #ifndef __BFAD_DRV_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define __BFAD_DRV_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/idr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/cdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/aer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <scsi/scsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <scsi/scsi_host.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <scsi/scsi_tcq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <scsi/scsi_transport_fc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <scsi/scsi_transport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <scsi/scsi_bsg_fc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <scsi/scsi_devinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include "bfa_modules.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include "bfa_fcs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include "bfa_defs_fcs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include "bfa_plog.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include "bfa_cs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define BFAD_DRIVER_NAME "bfa"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #ifdef BFA_DRIVER_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define BFAD_DRIVER_VERSION "3.2.25.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define BFAD_PROTO_NAME FCPI_NAME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define BFAD_IRQ_FLAGS IRQF_SHARED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #ifndef FC_PORTSPEED_8GBIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define FC_PORTSPEED_8GBIT 0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * BFAD flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define BFAD_MSIX_ON 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define BFAD_HAL_INIT_DONE 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define BFAD_DRV_INIT_DONE 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define BFAD_CFG_PPORT_DONE 0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define BFAD_HAL_START_DONE 0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define BFAD_PORT_ONLINE 0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define BFAD_RPORT_ONLINE 0x00000040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define BFAD_FCS_INIT_DONE 0x00000080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define BFAD_HAL_INIT_FAIL 0x00000100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define BFAD_FC4_PROBE_DONE 0x00000200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define BFAD_PORT_DELETE 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define BFAD_INTX_ON 0x00000400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define BFAD_EEH_BUSY 0x00000800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define BFAD_EEH_PCI_CHANNEL_IO_PERM_FAILURE 0x00001000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * BFAD related definition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define SCSI_SCAN_DELAY HZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define BFAD_STOP_TIMEOUT 30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define BFAD_SUSPEND_TIMEOUT BFAD_STOP_TIMEOUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * BFAD configuration parameter default values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define BFAD_LUN_QUEUE_DEPTH 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define BFAD_IO_MAX_SGE SG_ALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define BFAD_MIN_SECTORS 128 /* 64k */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define BFAD_MAX_SECTORS 0xFFFF /* 32 MB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define bfad_isr_t irq_handler_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define MAX_MSIX_ENTRY 22
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct bfad_msix_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct bfad_s *bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct msix_entry msix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) char name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * Only append to the enums defined here to avoid any versioning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * needed between trace utility and driver version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) BFA_TRC_LDRV_BFAD = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) BFA_TRC_LDRV_IM = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) BFA_TRC_LDRV_BSG = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) enum bfad_port_pvb_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) BFAD_PORT_PHYS_BASE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) BFAD_PORT_PHYS_VPORT = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) BFAD_PORT_VF_BASE = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) BFAD_PORT_VF_VPORT = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * PORT data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct bfad_port_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct list_head list_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct bfad_s *bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) struct bfa_fcs_lport_s *fcs_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) u32 roles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) s32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) u32 supported_fc4s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) enum bfad_port_pvb_type pvb_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct bfad_im_port_s *im_port; /* IM specific data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* port debugfs specific data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct dentry *port_debugfs_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * VPORT data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct bfad_vport_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct bfad_port_s drv_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct bfa_fcs_vport_s fcs_vport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct completion *comp_del;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct list_head list_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * VF data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct bfad_vf_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) bfa_fcs_vf_t fcs_vf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct bfad_port_s base_port; /* base port for vf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct bfad_s *bfad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct bfad_cfg_param_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) u32 rport_del_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) u32 ioc_queue_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) u32 lun_queue_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) u32 io_max_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) u32 binding_method;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) union bfad_tmp_buf {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /* From struct bfa_adapter_attr_s */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) char manufacturer[BFA_ADAPTER_MFG_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) char model[BFA_ADAPTER_MODEL_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) char fw_ver[BFA_VERSION_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) char optrom_ver[BFA_VERSION_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /* From struct bfa_ioc_pci_attr_s */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) u8 chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) wwn_t wwn[BFA_FCS_MAX_LPORTS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * BFAD (PCI function) data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct bfad_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) bfa_sm_t sm; /* state machine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct list_head list_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct bfa_s bfa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct bfa_fcs_s bfa_fcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct pci_dev *pcidev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) const char *pci_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) struct bfa_pcidev_s hal_pcidev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) struct bfa_ioc_pci_attr_s pci_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) void __iomem *pci_bar0_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) void __iomem *pci_bar2_kva;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct completion comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct completion suspend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct completion enable_comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct completion disable_comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) bfa_boolean_t disable_active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct bfad_port_s pport; /* physical port of the BFAD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct bfa_meminfo_s meminfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct bfa_iocfc_cfg_s ioc_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) u32 inst_no; /* BFAD instance number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) u32 bfad_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) spinlock_t bfad_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) struct task_struct *bfad_tsk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct bfad_cfg_param_s cfg_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) int nvec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) char adapter_name[BFA_ADAPTER_SYM_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) char port_name[BFA_ADAPTER_SYM_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct timer_list hal_tmo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) unsigned long hs_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct bfad_im_s *im; /* IM specific data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct bfa_trc_mod_s *trcmod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct bfa_plog_s plog_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int ref_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) union bfad_tmp_buf tmp_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) struct fc_host_statistics link_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct list_head pbc_vport_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) /* debugfs specific data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) char *regdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) u32 reglen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct dentry *bfad_dentry_files[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct list_head free_aen_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) struct list_head active_aen_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct bfa_aen_entry_s aen_list[BFA_AEN_MAX_ENTRY];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) spinlock_t bfad_aen_spinlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) struct list_head vport_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /* BFAD state machine events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) enum bfad_sm_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) BFAD_E_CREATE = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) BFAD_E_KTHREAD_CREATE_FAILED = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) BFAD_E_INIT = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) BFAD_E_INIT_SUCCESS = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) BFAD_E_HAL_INIT_FAILED = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) BFAD_E_INIT_FAILED = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) BFAD_E_FCS_EXIT_COMP = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) BFAD_E_EXIT_COMP = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) BFAD_E_STOP = 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * RPORT data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct bfad_rport_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct bfa_fcs_rport_s fcs_rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) struct bfad_buf_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) void *virt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) dma_addr_t phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) u32 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) struct bfad_fcxp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) struct bfad_port_s *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct bfa_rport_s *bfa_rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) bfa_status_t req_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) u16 tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) u16 rsp_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) u16 rsp_maxlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) u8 use_ireqbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) u8 use_irspbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) u32 num_req_sgles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) u32 num_rsp_sgles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) struct fchs_s fchs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) void *reqbuf_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) void *rspbuf_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct bfa_sge_s *req_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) struct bfa_sge_s *rsp_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) fcxp_send_cb_t send_cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) void *send_cbarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) void *bfa_fcxp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) struct completion comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) struct bfad_hal_comp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) bfa_status_t status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) struct completion comp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) #define BFA_LOG(level, bfad, mask, fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) if (((mask) == 4) || (level[1] <= '4')) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) dev_printk(level, &((bfad)->pcidev)->dev, fmt, ##arg); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct bfa_lport_cfg_s *port_cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) struct bfa_lport_cfg_s *port_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_lport_role role);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) bfa_status_t bfad_drv_init(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) bfa_status_t bfad_start_ops(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) void bfad_drv_start(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) void bfad_uncfg_pport(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) void bfad_stop(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) void bfad_fcs_stop(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) void bfad_remove_intr(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) void bfad_hal_mem_release(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) void bfad_hcb_comp(void *arg, bfa_status_t status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) int bfad_setup_intr(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) void bfad_remove_intr(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) bfa_status_t bfad_hal_mem_alloc(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) void bfad_bfa_tmo(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) void bfad_init_timer(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) void bfad_drv_uninit(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) int bfad_worker(void *ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) void bfad_debugfs_init(struct bfad_port_s *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) void bfad_debugfs_exit(struct bfad_port_s *port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) void bfad_pci_remove(struct pci_dev *pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) void bfad_rport_online_wait(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) int bfad_get_linkup_delay(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) int bfad_install_msix_handler(struct bfad_s *bfad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) extern struct idr bfad_im_port_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) extern struct pci_device_id bfad_id_table[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) extern struct list_head bfad_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) extern char *os_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) extern char *os_patch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) extern char *host_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) extern int num_rports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) extern int num_ios;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) extern int num_tms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) extern int num_fcxps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) extern int num_ufbufs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) extern int reqq_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) extern int rspq_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) extern int num_sgpgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) extern int rport_del_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) extern int bfa_lun_queue_depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) extern int bfa_io_max_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) extern int bfa_log_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) extern int ioc_auto_recover;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) extern int bfa_linkup_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) extern int msix_disable_cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) extern int msix_disable_ct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) extern int fdmi_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) extern int supported_fc4s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) extern int pcie_max_read_reqsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) extern int max_xfer_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) extern int bfa_debugfs_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) extern struct mutex bfad_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) #endif /* __BFAD_DRV_H__ */