22 #include <linux/export.h>
35 static int bfad_im_slave_alloc(
struct scsi_device *sdev);
42 int sns_len,
u8 *sns_info,
s32 residue)
53 scsi_set_resid(cmnd, 0);
64 scsi_set_resid(cmnd, residue);
66 (scsi_bufflen(cmnd) - residue) <
91 itnim_data = cmnd->
device->hostdata;
93 itnim = itnim_data->
itnim;
94 if (!cmnd->
result && itnim &&
124 itnim_data = cmnd->
device->hostdata;
126 itnim = itnim_data->
itnim;
139 struct bfad_s *bfad = drv;
158 cmnd->
SCp.Status |= tsk_status << 1;
176 static char bfa_buf[256];
181 memset(bfa_buf, 0,
sizeof(bfa_buf));
183 "Brocade FC/FCOE Adapter, " "hwpath: %s driver: %s",
195 bfad_im_abort_handler(
struct scsi_cmnd *cmnd)
213 if (hal_io->dio != (
struct bfad_ioim_s *) cmnd) {
220 "scsi%d: abort cmnd %p iotag %x\n",
221 im_port->
shost->host_no, cmnd, hal_io->iotag);
223 spin_unlock_irqrestore(&bfad->bfad_lock,
flags);
230 if (timeout < 4 *
HZ)
237 "scsi%d: complete abort 0x%p iotag 0x%x\n",
238 im_port->
shost->host_no, cmnd, hal_io->iotag);
241 spin_unlock_irqrestore(&bfad->bfad_lock,
flags);
257 "target reset, fail to allocate tskim\n");
267 cmnd->
SCp.Status = 0;
268 bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->
fcs_itnim);
269 memset(&scsilun, 0,
sizeof(scsilun));
283 bfad_im_reset_lun_handler(
struct scsi_cmnd *cmnd)
300 itnim = itnim_data->itnim;
302 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
310 "LUN reset, fail to allocate tskim");
311 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
321 cmnd->
SCp.ptr = (
char *)&wq;
322 cmnd->
SCp.Status = 0;
323 bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->
fcs_itnim);
327 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
330 (
unsigned long *)&cmnd->
SCp.Status));
332 task_status = cmnd->
SCp.Status >> 1;
335 "LUN reset failure, status: %d\n", task_status);
347 bfad_im_reset_bus_handler(
struct scsi_cmnd *cmnd)
355 u32 i, rc, err_cnt = 0;
363 cmnd->
SCp.ptr = (
char *)&wq;
364 rc = bfad_im_target_reset_send(bfad, cmnd, itnim);
371 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
373 (
unsigned long *)&cmnd->
SCp.Status));
376 task_status = cmnd->
SCp.Status >> 1;
379 "target reset failure,"
380 " status: %d\n", task_status);
385 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
416 if (*itnim_drv ==
NULL)
419 (*itnim_drv)->im = bfad->
im;
420 *itnim = &(*itnim_drv)->fcs_itnim;
426 INIT_WORK(&(*itnim_drv)->itnim_work, bfad_im_itnim_work_handler);
440 char wwpn_str[32], fcid_str[16];
452 port = bfa_fcs_itnim_get_drvport(&itnim_drv->
fcs_itnim);
454 wwpn = bfa_fcs_itnim_get_pwwn(&itnim_drv->
fcs_itnim);
455 fcid = bfa_fcs_itnim_get_fcid(&itnim_drv->
fcs_itnim);
456 wwn2str(wwpn_str, wwpn);
457 fcid2str(fcid_str, fcid);
459 "ITNIM FREE scsi%d: FCID: %s WWPN: %s\n",
479 port = bfa_fcs_itnim_get_drvport(&itnim_drv->
fcs_itnim);
500 port = bfa_fcs_itnim_get_drvport(&itnim_drv->
fcs_itnim);
543 if (!im_port->
shost) {
548 im_port->
shost->hostdata[0] = (
unsigned long)im_port;
550 im_port->
shost->this_id = -1;
553 im_port->
shost->max_cmd_len = 16;
558 im_port->
shost->transportt =
585 im_port->
shost->host_no);
616 if (im_port ==
NULL) {
658 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
661 static void bfad_aen_im_notify_handler(
struct work_struct *work)
675 event_data = (
char *)aen_entry +
sizeof(
struct list_head);
792 .info = bfad_im_info,
793 .queuecommand = bfad_im_queuecommand,
794 .eh_abort_handler = bfad_im_abort_handler,
795 .eh_device_reset_handler = bfad_im_reset_lun_handler,
796 .eh_bus_reset_handler = bfad_im_reset_bus_handler,
798 .slave_alloc = bfad_im_slave_alloc,
799 .slave_configure = bfad_im_slave_configure,
800 .slave_destroy = bfad_im_slave_destroy,
814 .info = bfad_im_info,
815 .queuecommand = bfad_im_queuecommand,
816 .eh_abort_handler = bfad_im_abort_handler,
817 .eh_device_reset_handler = bfad_im_reset_lun_handler,
818 .eh_bus_reset_handler = bfad_im_reset_bus_handler,
820 .slave_alloc = bfad_im_slave_alloc,
821 .slave_configure = bfad_im_slave_configure,
822 .slave_destroy = bfad_im_slave_destroy,
835 bfad_im_scsi_transport_template =
837 if (!bfad_im_scsi_transport_template)
840 bfad_im_scsi_vport_transport_template =
842 if (!bfad_im_scsi_vport_transport_template) {
853 if (bfad_im_scsi_transport_template)
856 if (bfad_im_scsi_vport_transport_template)
871 if (tmp_sdev->
id != sdev->
id)
896 if (tmp_sdev->
id != sdev->
id)
925 bfad_im_check_if_make_lun_visible(
struct scsi_device *sdev,
930 struct bfa_s *bfa = itnim_data->
itnim->bfa_itnim->bfa;
938 lun_list[
i].rp_tag == bfa_rport->rport_tag &&
939 lun_list[
i].lp_tag == (
u8)bfa_rport->rport_info.lp_tag) {
956 struct bfa_s *bfa = itnim_data->
itnim->bfa_itnim->bfa;
958 if (!rport || fc_remote_port_chkready(rport))
966 if (sdev->
lun == 0) {
976 if (bfad_im_check_if_make_lun_visible(sdev, rport) !=
1045 strncpy(symname, bfad->
bfa_fcs.fabric.bport.port_cfg.sym_name.symname,
1060 rport_ids.node_name =
1062 rport_ids.port_name =
1075 bfa_fcs_itnim_get_maxfrsize(&itnim->
fcs_itnim);
1078 itnim_data = fc_rport->
dd_data;
1100 bfad_im_itnim_work_handler(
struct work_struct *work)
1107 unsigned long flags;
1108 struct fc_rport *fc_rport;
1111 char wwpn_str[32], fcid_str[16];
1116 switch (itnim->
state) {
1119 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
1120 bfad_im_fc_rport_add(im_port, itnim);
1122 wwpn = bfa_fcs_itnim_get_pwwn(&itnim->
fcs_itnim);
1123 fcid = bfa_fcs_itnim_get_fcid(&itnim->
fcs_itnim);
1124 wwn2str(wwpn_str, wwpn);
1125 fcid2str(fcid_str, fcid);
1129 "ITNIM ONLINE Target: %d:0:%d "
1130 "FCID: %s WWPN: %s\n",
1131 im_port->
shost->host_no,
1133 fcid_str, wwpn_str);
1136 "%s: itnim %llx is already in online state\n",
1138 bfa_fcs_itnim_get_pwwn(&itnim->
fcs_itnim));
1150 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
1156 wwpn = bfa_fcs_itnim_get_pwwn(&itnim->
fcs_itnim);
1157 fcid = bfa_fcs_itnim_get_fcid(&itnim->
fcs_itnim);
1158 wwn2str(wwpn_str, wwpn);
1159 fcid2str(fcid_str, fcid);
1162 "ITNIM OFFLINE Target: %d:0:%d "
1163 "FCID: %s WWPN: %s\n",
1164 im_port->
shost->host_no,
1166 fcid_str, wwpn_str);
1176 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
1192 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
1207 unsigned long flags;
1212 rc = fc_remote_port_chkready(rport);
1237 "bfad%d, queuecommand %p %x failed, BFA stopped\n",
1244 itnim = itnim_data->
itnim;
1254 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
1261 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
1266 spin_unlock_irqrestore(&bfad->
bfad_lock, flags);
1280 int rport_delay = 10;
1292 && i < rport_delay; i++) {
1327 return linkup_delay;