| Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. | 
|  | 3 | * All rights reserved | 
|  | 4 | * www.brocade.com | 
|  | 5 | * | 
|  | 6 | * Linux driver for Brocade Fibre Channel Host Bus Adapter. | 
|  | 7 | * | 
|  | 8 | * This program is free software; you can redistribute it and/or modify it | 
|  | 9 | * under the terms of the GNU General Public License (GPL) Version 2 as | 
|  | 10 | * published by the Free Software Foundation | 
|  | 11 | * | 
|  | 12 | * This program is distributed in the hope that it will be useful, but | 
|  | 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|  | 15 | * General Public License for more details. | 
|  | 16 | */ | 
|  | 17 |  | 
|  | 18 | #ifndef __BFAD_IM_H__ | 
|  | 19 | #define __BFAD_IM_H__ | 
|  | 20 |  | 
|  | 21 | #include "fcs/bfa_fcs_fcpim.h" | 
|  | 22 | #include "bfad_im_compat.h" | 
|  | 23 |  | 
|  | 24 | #define FCPI_NAME " fcpim" | 
|  | 25 |  | 
| Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 26 | bfa_status_t bfad_im_module_init(void); | 
|  | 27 | void bfad_im_module_exit(void); | 
|  | 28 | bfa_status_t bfad_im_probe(struct bfad_s *bfad); | 
|  | 29 | void bfad_im_probe_undo(struct bfad_s *bfad); | 
|  | 30 | void bfad_im_probe_post(struct bfad_im_s *im); | 
|  | 31 | bfa_status_t bfad_im_port_new(struct bfad_s *bfad, struct bfad_port_s *port); | 
|  | 32 | void bfad_im_port_delete(struct bfad_s *bfad, struct bfad_port_s *port); | 
|  | 33 | void bfad_im_port_online(struct bfad_s *bfad, struct bfad_port_s *port); | 
|  | 34 | void bfad_im_port_offline(struct bfad_s *bfad, struct bfad_port_s *port); | 
|  | 35 | void bfad_im_port_clean(struct bfad_im_port_s *im_port); | 
|  | 36 | int  bfad_im_scsi_host_alloc(struct bfad_s *bfad, | 
|  | 37 | struct bfad_im_port_s *im_port); | 
|  | 38 | void bfad_im_scsi_host_free(struct bfad_s *bfad, | 
|  | 39 | struct bfad_im_port_s *im_port); | 
|  | 40 |  | 
|  | 41 | #define MAX_FCP_TARGET 1024 | 
|  | 42 | #define MAX_FCP_LUN 16384 | 
|  | 43 | #define BFAD_TARGET_RESET_TMO 60 | 
|  | 44 | #define BFAD_LUN_RESET_TMO 60 | 
|  | 45 | #define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code) | 
|  | 46 | #define BFA_QUEUE_FULL_RAMP_UP_TIME 120 | 
|  | 47 | #define BFAD_KOBJ_NAME_LEN 20 | 
|  | 48 |  | 
|  | 49 | /* | 
|  | 50 | * itnim flags | 
|  | 51 | */ | 
|  | 52 | #define ITNIM_MAPPED		0x00000001 | 
|  | 53 |  | 
|  | 54 | #define SCSI_TASK_MGMT		0x00000001 | 
|  | 55 | #define IO_DONE_BIT			0 | 
|  | 56 |  | 
|  | 57 | struct bfad_itnim_data_s { | 
|  | 58 | struct bfad_itnim_s *itnim; | 
|  | 59 | }; | 
|  | 60 |  | 
|  | 61 | struct bfad_im_port_s { | 
|  | 62 | struct bfad_s         *bfad; | 
|  | 63 | struct bfad_port_s    *port; | 
|  | 64 | struct work_struct port_delete_work; | 
|  | 65 | int             idr_id; | 
|  | 66 | u16        cur_scsi_id; | 
|  | 67 | struct list_head binding_list; | 
|  | 68 | struct Scsi_Host *shost; | 
|  | 69 | struct list_head itnim_mapped_list; | 
|  | 70 | }; | 
|  | 71 |  | 
|  | 72 | enum bfad_itnim_state { | 
|  | 73 | ITNIM_STATE_NONE, | 
|  | 74 | ITNIM_STATE_ONLINE, | 
|  | 75 | ITNIM_STATE_OFFLINE_PENDING, | 
|  | 76 | ITNIM_STATE_OFFLINE, | 
|  | 77 | ITNIM_STATE_TIMEOUT, | 
|  | 78 | ITNIM_STATE_FREE, | 
|  | 79 | }; | 
|  | 80 |  | 
|  | 81 | /* | 
|  | 82 | * Per itnim data structure | 
|  | 83 | */ | 
|  | 84 | struct bfad_itnim_s { | 
|  | 85 | struct list_head list_entry; | 
|  | 86 | struct bfa_fcs_itnim_s fcs_itnim; | 
|  | 87 | struct work_struct itnim_work; | 
|  | 88 | u32        flags; | 
|  | 89 | enum bfad_itnim_state state; | 
|  | 90 | struct bfad_im_s *im; | 
|  | 91 | struct bfad_im_port_s *im_port; | 
|  | 92 | struct bfad_rport_s *drv_rport; | 
|  | 93 | struct fc_rport *fc_rport; | 
|  | 94 | struct bfa_itnim_s *bfa_itnim; | 
|  | 95 | u16        scsi_tgt_id; | 
|  | 96 | u16        queue_work; | 
|  | 97 | unsigned long	last_ramp_up_time; | 
|  | 98 | unsigned long	last_queue_full_time; | 
|  | 99 | }; | 
|  | 100 |  | 
|  | 101 | enum bfad_binding_type { | 
|  | 102 | FCP_PWWN_BINDING = 0x1, | 
|  | 103 | FCP_NWWN_BINDING = 0x2, | 
|  | 104 | FCP_FCID_BINDING = 0x3, | 
|  | 105 | }; | 
|  | 106 |  | 
|  | 107 | struct bfad_fcp_binding { | 
|  | 108 | struct list_head list_entry; | 
|  | 109 | enum bfad_binding_type binding_type; | 
|  | 110 | u16        scsi_target_id; | 
|  | 111 | u32        fc_id; | 
|  | 112 | wwn_t           nwwn; | 
|  | 113 | wwn_t           pwwn; | 
|  | 114 | }; | 
|  | 115 |  | 
|  | 116 | struct bfad_im_s { | 
|  | 117 | struct bfad_s         *bfad; | 
|  | 118 | struct workqueue_struct *drv_workq; | 
|  | 119 | char   drv_workq_name[BFAD_KOBJ_NAME_LEN]; | 
|  | 120 | }; | 
|  | 121 |  | 
|  | 122 | struct Scsi_Host *bfad_os_scsi_host_alloc(struct bfad_im_port_s *im_port, | 
|  | 123 | struct bfad_s *); | 
|  | 124 | bfa_status_t bfad_os_thread_workq(struct bfad_s *bfad); | 
|  | 125 | void bfad_os_destroy_workq(struct bfad_im_s *im); | 
|  | 126 | void bfad_os_itnim_process(struct bfad_itnim_s *itnim_drv); | 
|  | 127 | void bfad_os_fc_host_init(struct bfad_im_port_s *im_port); | 
| Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 128 | void bfad_os_scsi_host_free(struct bfad_s *bfad, | 
|  | 129 | struct bfad_im_port_s *im_port); | 
|  | 130 | void bfad_os_ramp_up_qdepth(struct bfad_itnim_s *itnim, | 
|  | 131 | struct scsi_device *sdev); | 
|  | 132 | void bfad_os_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev); | 
|  | 133 | struct bfad_itnim_s *bfad_os_get_itnim(struct bfad_im_port_s *im_port, int id); | 
|  | 134 | int bfad_os_scsi_add_host(struct Scsi_Host *shost, | 
|  | 135 | struct bfad_im_port_s *im_port, struct bfad_s *bfad); | 
|  | 136 |  | 
| Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 137 | void bfad_im_itnim_unmap(struct bfad_im_port_s  *im_port, | 
|  | 138 | struct bfad_itnim_s *itnim); | 
|  | 139 |  | 
|  | 140 | extern struct scsi_host_template bfad_im_scsi_host_template; | 
|  | 141 | extern struct scsi_host_template bfad_im_vport_template; | 
|  | 142 | extern struct fc_function_template bfad_im_fc_function_template; | 
|  | 143 | extern struct scsi_transport_template *bfad_im_scsi_transport_template; | 
|  | 144 |  | 
|  | 145 | #endif |