17725ccfdSJing Huang /* 27725ccfdSJing Huang * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 37725ccfdSJing Huang * All rights reserved 47725ccfdSJing Huang * www.brocade.com 57725ccfdSJing Huang * 67725ccfdSJing Huang * Linux driver for Brocade Fibre Channel Host Bus Adapter. 77725ccfdSJing Huang * 87725ccfdSJing Huang * This program is free software; you can redistribute it and/or modify it 97725ccfdSJing Huang * under the terms of the GNU General Public License (GPL) Version 2 as 107725ccfdSJing Huang * published by the Free Software Foundation 117725ccfdSJing Huang * 127725ccfdSJing Huang * This program is distributed in the hope that it will be useful, but 137725ccfdSJing Huang * WITHOUT ANY WARRANTY; without even the implied warranty of 147725ccfdSJing Huang * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 157725ccfdSJing Huang * General Public License for more details. 167725ccfdSJing Huang */ 177725ccfdSJing Huang 187725ccfdSJing Huang /** 197725ccfdSJing Huang * Contains base driver definitions. 207725ccfdSJing Huang */ 217725ccfdSJing Huang 227725ccfdSJing Huang /** 237725ccfdSJing Huang * bfa_drv.h Linux driver data structures. 247725ccfdSJing Huang */ 257725ccfdSJing Huang 267725ccfdSJing Huang #ifndef __BFAD_DRV_H__ 277725ccfdSJing Huang #define __BFAD_DRV_H__ 287725ccfdSJing Huang 297725ccfdSJing Huang #include "bfa_os_inc.h" 307725ccfdSJing Huang 317725ccfdSJing Huang #include <bfa.h> 327725ccfdSJing Huang #include <bfa_svc.h> 337725ccfdSJing Huang #include <fcs/bfa_fcs.h> 347725ccfdSJing Huang #include <defs/bfa_defs_pci.h> 357725ccfdSJing Huang #include <defs/bfa_defs_port.h> 367725ccfdSJing Huang #include <defs/bfa_defs_rport.h> 377725ccfdSJing Huang #include <fcs/bfa_fcs_rport.h> 387725ccfdSJing Huang #include <defs/bfa_defs_vport.h> 397725ccfdSJing Huang #include <fcs/bfa_fcs_vport.h> 407725ccfdSJing Huang 417725ccfdSJing Huang #include <cs/bfa_plog.h> 427725ccfdSJing Huang #include "aen/bfa_aen.h" 437725ccfdSJing Huang #include <log/bfa_log_linux.h> 447725ccfdSJing Huang 457725ccfdSJing Huang #define BFAD_DRIVER_NAME "bfa" 467725ccfdSJing Huang #ifdef BFA_DRIVER_VERSION 477725ccfdSJing Huang #define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION 487725ccfdSJing Huang #else 49d55f88f0SKrishna Gudipati #define BFAD_DRIVER_VERSION "2.1.2.1" 507725ccfdSJing Huang #endif 517725ccfdSJing Huang 527725ccfdSJing Huang 537725ccfdSJing Huang #define BFAD_IRQ_FLAGS IRQF_SHARED 547725ccfdSJing Huang 557725ccfdSJing Huang /* 567725ccfdSJing Huang * BFAD flags 577725ccfdSJing Huang */ 587725ccfdSJing Huang #define BFAD_MSIX_ON 0x00000001 597725ccfdSJing Huang #define BFAD_HAL_INIT_DONE 0x00000002 607725ccfdSJing Huang #define BFAD_DRV_INIT_DONE 0x00000004 617725ccfdSJing Huang #define BFAD_CFG_PPORT_DONE 0x00000008 627725ccfdSJing Huang #define BFAD_HAL_START_DONE 0x00000010 637725ccfdSJing Huang #define BFAD_PORT_ONLINE 0x00000020 647725ccfdSJing Huang #define BFAD_RPORT_ONLINE 0x00000040 65e6714324SKrishna Gudipati #define BFAD_FCS_INIT_DONE 0x00000080 66e6714324SKrishna Gudipati #define BFAD_HAL_INIT_FAIL 0x00000100 67e6714324SKrishna Gudipati #define BFAD_FC4_PROBE_DONE 0x00000200 687725ccfdSJing Huang #define BFAD_PORT_DELETE 0x00000001 697725ccfdSJing Huang 707725ccfdSJing Huang /* 717725ccfdSJing Huang * BFAD related definition 727725ccfdSJing Huang */ 737725ccfdSJing Huang #define SCSI_SCAN_DELAY HZ 747725ccfdSJing Huang #define BFAD_STOP_TIMEOUT 30 757725ccfdSJing Huang #define BFAD_SUSPEND_TIMEOUT BFAD_STOP_TIMEOUT 767725ccfdSJing Huang 777725ccfdSJing Huang /* 787725ccfdSJing Huang * BFAD configuration parameter default values 797725ccfdSJing Huang */ 807725ccfdSJing Huang #define BFAD_LUN_QUEUE_DEPTH 32 817725ccfdSJing Huang #define BFAD_IO_MAX_SGE SG_ALL 827725ccfdSJing Huang 837725ccfdSJing Huang #define bfad_isr_t irq_handler_t 847725ccfdSJing Huang 857725ccfdSJing Huang #define MAX_MSIX_ENTRY 22 867725ccfdSJing Huang 877725ccfdSJing Huang struct bfad_msix_s { 887725ccfdSJing Huang struct bfad_s *bfad; 897725ccfdSJing Huang struct msix_entry msix; 907725ccfdSJing Huang }; 917725ccfdSJing Huang 927725ccfdSJing Huang enum bfad_port_pvb_type { 937725ccfdSJing Huang BFAD_PORT_PHYS_BASE = 0, 947725ccfdSJing Huang BFAD_PORT_PHYS_VPORT = 1, 957725ccfdSJing Huang BFAD_PORT_VF_BASE = 2, 967725ccfdSJing Huang BFAD_PORT_VF_VPORT = 3, 977725ccfdSJing Huang }; 987725ccfdSJing Huang 997725ccfdSJing Huang /* 1007725ccfdSJing Huang * PORT data structure 1017725ccfdSJing Huang */ 1027725ccfdSJing Huang struct bfad_port_s { 1037725ccfdSJing Huang struct list_head list_entry; 1047725ccfdSJing Huang struct bfad_s *bfad; 1057725ccfdSJing Huang struct bfa_fcs_port_s *fcs_port; 1067725ccfdSJing Huang u32 roles; 1077725ccfdSJing Huang s32 flags; 1087725ccfdSJing Huang u32 supported_fc4s; 1097725ccfdSJing Huang u8 ipfc_flags; 1107725ccfdSJing Huang enum bfad_port_pvb_type pvb_type; 1117725ccfdSJing Huang struct bfad_im_port_s *im_port; /* IM specific data */ 1127725ccfdSJing Huang struct bfad_tm_port_s *tm_port; /* TM specific data */ 1137725ccfdSJing Huang struct bfad_ipfc_port_s *ipfc_port; /* IPFC specific data */ 1147725ccfdSJing Huang }; 1157725ccfdSJing Huang 1167725ccfdSJing Huang /* 1177725ccfdSJing Huang * VPORT data structure 1187725ccfdSJing Huang */ 1197725ccfdSJing Huang struct bfad_vport_s { 1207725ccfdSJing Huang struct bfad_port_s drv_port; 1217725ccfdSJing Huang struct bfa_fcs_vport_s fcs_vport; 1227725ccfdSJing Huang struct completion *comp_del; 1237725ccfdSJing Huang }; 1247725ccfdSJing Huang 1257725ccfdSJing Huang /* 1267725ccfdSJing Huang * VF data structure 1277725ccfdSJing Huang */ 1287725ccfdSJing Huang struct bfad_vf_s { 1297725ccfdSJing Huang bfa_fcs_vf_t fcs_vf; 1307725ccfdSJing Huang struct bfad_port_s base_port; /* base port for vf */ 1317725ccfdSJing Huang struct bfad_s *bfad; 1327725ccfdSJing Huang }; 1337725ccfdSJing Huang 1347725ccfdSJing Huang struct bfad_cfg_param_s { 1357725ccfdSJing Huang u32 rport_del_timeout; 1367725ccfdSJing Huang u32 ioc_queue_depth; 1377725ccfdSJing Huang u32 lun_queue_depth; 1387725ccfdSJing Huang u32 io_max_sge; 1397725ccfdSJing Huang u32 binding_method; 1407725ccfdSJing Huang }; 1417725ccfdSJing Huang 1420a4b1fc0SKrishna Gudipati union bfad_tmp_buf { 1430a4b1fc0SKrishna Gudipati /* From struct bfa_adapter_attr_s */ 1440a4b1fc0SKrishna Gudipati char manufacturer[BFA_ADAPTER_MFG_NAME_LEN]; 1450a4b1fc0SKrishna Gudipati char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN]; 1460a4b1fc0SKrishna Gudipati char model[BFA_ADAPTER_MODEL_NAME_LEN]; 1470a4b1fc0SKrishna Gudipati char fw_ver[BFA_VERSION_LEN]; 1480a4b1fc0SKrishna Gudipati char optrom_ver[BFA_VERSION_LEN]; 1490a4b1fc0SKrishna Gudipati 1500a4b1fc0SKrishna Gudipati /* From struct bfa_ioc_pci_attr_s */ 1510a4b1fc0SKrishna Gudipati u8 chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */ 1520a4b1fc0SKrishna Gudipati }; 1530a4b1fc0SKrishna Gudipati 1547725ccfdSJing Huang /* 1557725ccfdSJing Huang * BFAD (PCI function) data structure 1567725ccfdSJing Huang */ 1577725ccfdSJing Huang struct bfad_s { 1587725ccfdSJing Huang struct list_head list_entry; 1597725ccfdSJing Huang struct bfa_s bfa; 1607725ccfdSJing Huang struct bfa_fcs_s bfa_fcs; 1617725ccfdSJing Huang struct pci_dev *pcidev; 1627725ccfdSJing Huang const char *pci_name; 1637725ccfdSJing Huang struct bfa_pcidev_s hal_pcidev; 1647725ccfdSJing Huang struct bfa_ioc_pci_attr_s pci_attr; 1657725ccfdSJing Huang void __iomem *pci_bar0_kva; 1667725ccfdSJing Huang struct completion comp; 1677725ccfdSJing Huang struct completion suspend; 1687725ccfdSJing Huang struct completion disable_comp; 1697725ccfdSJing Huang bfa_boolean_t disable_active; 1707725ccfdSJing Huang struct bfad_port_s pport; /* physical port of the BFAD */ 1717725ccfdSJing Huang struct bfa_meminfo_s meminfo; 1727725ccfdSJing Huang struct bfa_iocfc_cfg_s ioc_cfg; 1737725ccfdSJing Huang u32 inst_no; /* BFAD instance number */ 1747725ccfdSJing Huang u32 bfad_flags; 1757725ccfdSJing Huang spinlock_t bfad_lock; 176e6714324SKrishna Gudipati struct task_struct *bfad_tsk; 1777725ccfdSJing Huang struct bfad_cfg_param_s cfg_data; 1787725ccfdSJing Huang struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY]; 1797725ccfdSJing Huang int nvec; 1807725ccfdSJing Huang char adapter_name[BFA_ADAPTER_SYM_NAME_LEN]; 1817725ccfdSJing Huang char port_name[BFA_ADAPTER_SYM_NAME_LEN]; 1827725ccfdSJing Huang struct timer_list hal_tmo; 1837725ccfdSJing Huang unsigned long hs_start; 1847725ccfdSJing Huang struct bfad_im_s *im; /* IM specific data */ 1857725ccfdSJing Huang struct bfad_tm_s *tm; /* TM specific data */ 1867725ccfdSJing Huang struct bfad_ipfc_s *ipfc; /* IPFC specific data */ 1877725ccfdSJing Huang struct bfa_log_mod_s log_data; 1887725ccfdSJing Huang struct bfa_trc_mod_s *trcmod; 1897725ccfdSJing Huang struct bfa_log_mod_s *logmod; 1907725ccfdSJing Huang struct bfa_aen_s *aen; 1917725ccfdSJing Huang struct bfa_aen_s aen_buf; 1922993cc71SKrishna Gudipati void *file_map[BFA_AEN_MAX_APP]; 1937725ccfdSJing Huang struct bfa_plog_s plog_buf; 1947725ccfdSJing Huang int ref_count; 1957725ccfdSJing Huang bfa_boolean_t ipfc_enabled; 1960a4b1fc0SKrishna Gudipati union bfad_tmp_buf tmp_buf; 1977725ccfdSJing Huang struct fc_host_statistics link_stats; 1987725ccfdSJing Huang }; 1997725ccfdSJing Huang 2007725ccfdSJing Huang /* 2017725ccfdSJing Huang * RPORT data structure 2027725ccfdSJing Huang */ 2037725ccfdSJing Huang struct bfad_rport_s { 2047725ccfdSJing Huang struct bfa_fcs_rport_s fcs_rport; 2057725ccfdSJing Huang }; 2067725ccfdSJing Huang 2077725ccfdSJing Huang struct bfad_buf_info { 2087725ccfdSJing Huang void *virt; 2097725ccfdSJing Huang dma_addr_t phys; 2107725ccfdSJing Huang u32 size; 2117725ccfdSJing Huang }; 2127725ccfdSJing Huang 2137725ccfdSJing Huang struct bfad_fcxp { 2147725ccfdSJing Huang struct bfad_port_s *port; 2157725ccfdSJing Huang struct bfa_rport_s *bfa_rport; 2167725ccfdSJing Huang bfa_status_t req_status; 2177725ccfdSJing Huang u16 tag; 2187725ccfdSJing Huang u16 rsp_len; 2197725ccfdSJing Huang u16 rsp_maxlen; 2207725ccfdSJing Huang u8 use_ireqbuf; 2217725ccfdSJing Huang u8 use_irspbuf; 2227725ccfdSJing Huang u32 num_req_sgles; 2237725ccfdSJing Huang u32 num_rsp_sgles; 2247725ccfdSJing Huang struct fchs_s fchs; 2257725ccfdSJing Huang void *reqbuf_info; 2267725ccfdSJing Huang void *rspbuf_info; 2277725ccfdSJing Huang struct bfa_sge_s *req_sge; 2287725ccfdSJing Huang struct bfa_sge_s *rsp_sge; 2297725ccfdSJing Huang fcxp_send_cb_t send_cbfn; 2307725ccfdSJing Huang void *send_cbarg; 2317725ccfdSJing Huang void *bfa_fcxp; 2327725ccfdSJing Huang struct completion comp; 2337725ccfdSJing Huang }; 2347725ccfdSJing Huang 2357725ccfdSJing Huang struct bfad_hal_comp { 2367725ccfdSJing Huang bfa_status_t status; 2377725ccfdSJing Huang struct completion comp; 2387725ccfdSJing Huang }; 2397725ccfdSJing Huang 2407725ccfdSJing Huang /* 2417725ccfdSJing Huang * Macro to obtain the immediate lower power 2427725ccfdSJing Huang * of two for the integer. 2437725ccfdSJing Huang */ 2447725ccfdSJing Huang #define nextLowerInt(x) \ 2457725ccfdSJing Huang do { \ 2467725ccfdSJing Huang int j; \ 2477725ccfdSJing Huang (*x)--; \ 2487725ccfdSJing Huang for (j = 1; j < (sizeof(int) * 8); j <<= 1) \ 2497725ccfdSJing Huang (*x) = (*x) | (*x) >> j; \ 2507725ccfdSJing Huang (*x)++; \ 2517725ccfdSJing Huang (*x) = (*x) >> 1; \ 2527725ccfdSJing Huang } while (0) 2537725ccfdSJing Huang 2547725ccfdSJing Huang 2557725ccfdSJing Huang bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id, 256b504293fSJing Huang struct bfa_port_cfg_s *port_cfg, struct device *dev); 2577725ccfdSJing Huang bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id, 2587725ccfdSJing Huang struct bfa_port_cfg_s *port_cfg); 2597725ccfdSJing Huang bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role); 2607725ccfdSJing Huang bfa_status_t bfad_drv_init(struct bfad_s *bfad); 261e6714324SKrishna Gudipati bfa_status_t bfad_start_ops(struct bfad_s *bfad); 2627725ccfdSJing Huang void bfad_drv_start(struct bfad_s *bfad); 2637725ccfdSJing Huang void bfad_uncfg_pport(struct bfad_s *bfad); 2647725ccfdSJing Huang void bfad_drv_stop(struct bfad_s *bfad); 2657725ccfdSJing Huang void bfad_remove_intr(struct bfad_s *bfad); 2667725ccfdSJing Huang void bfad_hal_mem_release(struct bfad_s *bfad); 2677725ccfdSJing Huang void bfad_hcb_comp(void *arg, bfa_status_t status); 2687725ccfdSJing Huang 2697725ccfdSJing Huang int bfad_setup_intr(struct bfad_s *bfad); 2707725ccfdSJing Huang void bfad_remove_intr(struct bfad_s *bfad); 2717725ccfdSJing Huang 2727725ccfdSJing Huang void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg); 2737725ccfdSJing Huang bfa_status_t bfad_hal_mem_alloc(struct bfad_s *bfad); 2747725ccfdSJing Huang void bfad_bfa_tmo(unsigned long data); 2757725ccfdSJing Huang void bfad_init_timer(struct bfad_s *bfad); 2767725ccfdSJing Huang int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad); 2777725ccfdSJing Huang void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad); 2787725ccfdSJing Huang void bfad_fcs_port_cfg(struct bfad_s *bfad); 2797725ccfdSJing Huang void bfad_drv_uninit(struct bfad_s *bfad); 2807725ccfdSJing Huang void bfad_drv_log_level_set(struct bfad_s *bfad); 2817725ccfdSJing Huang bfa_status_t bfad_fc4_module_init(void); 2827725ccfdSJing Huang void bfad_fc4_module_exit(void); 283e6714324SKrishna Gudipati int bfad_worker (void *ptr); 284e6714324SKrishna Gudipati 2857725ccfdSJing Huang void bfad_pci_remove(struct pci_dev *pdev); 2867725ccfdSJing Huang int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid); 2877725ccfdSJing Huang void bfad_os_rport_online_wait(struct bfad_s *bfad); 2887725ccfdSJing Huang int bfad_os_get_linkup_delay(struct bfad_s *bfad); 2897725ccfdSJing Huang int bfad_install_msix_handler(struct bfad_s *bfad); 2907725ccfdSJing Huang 2917725ccfdSJing Huang extern struct idr bfad_im_port_index; 2927725ccfdSJing Huang extern struct list_head bfad_list; 2937725ccfdSJing Huang extern int bfa_lun_queue_depth; 2947725ccfdSJing Huang extern int bfad_supported_fc4s; 2957725ccfdSJing Huang extern int bfa_linkup_delay; 296*42b426ecSJing Huang extern struct mutex bfad_mutex; 2977725ccfdSJing Huang 2987725ccfdSJing Huang #endif /* __BFAD_DRV_H__ */ 299