Deleted Added
full compact
isp_freebsd.c (285155) isp_freebsd.c (285459)
1/*-
2 * Copyright (c) 1997-2009 by Matthew Jacob
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27/*
28 * Platform (FreeBSD) dependent common attachment code for Qlogic adapters.
29 */
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997-2009 by Matthew Jacob
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27/*
28 * Platform (FreeBSD) dependent common attachment code for Qlogic adapters.
29 */
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/isp/isp_freebsd.c 285155 2015-07-05 03:38:58Z mav $");
31__FBSDID("$FreeBSD: head/sys/dev/isp/isp_freebsd.c 285459 2015-07-13 15:11:05Z mav $");
32
33#include <dev/isp/isp_freebsd.h>
34#include <sys/unistd.h>
35#include <sys/kthread.h>
36#include <sys/conf.h>
37#include <sys/module.h>
38#include <sys/ioccom.h>
39#include <dev/isp/isp_ioctl.h>

--- 7 unchanged lines hidden (view full) ---

47#define THREAD_CREATE kproc_create
48#endif
49
50MODULE_VERSION(isp, 1);
51MODULE_DEPEND(isp, cam, 1, 1, 1);
52int isp_announced = 0;
53int isp_fabric_hysteresis = 5;
54int isp_loop_down_limit = 60; /* default loop down limit */
32
33#include <dev/isp/isp_freebsd.h>
34#include <sys/unistd.h>
35#include <sys/kthread.h>
36#include <sys/conf.h>
37#include <sys/module.h>
38#include <sys/ioccom.h>
39#include <dev/isp/isp_ioctl.h>

--- 7 unchanged lines hidden (view full) ---

47#define THREAD_CREATE kproc_create
48#endif
49
50MODULE_VERSION(isp, 1);
51MODULE_DEPEND(isp, cam, 1, 1, 1);
52int isp_announced = 0;
53int isp_fabric_hysteresis = 5;
54int isp_loop_down_limit = 60; /* default loop down limit */
55int isp_change_is_bad = 0; /* "changed" devices are bad */
56int isp_quickboot_time = 7; /* don't wait more than N secs for loop up */
57int isp_gone_device_time = 30; /* grace time before reporting device lost */
58int isp_autoconfig = 1; /* automatically attach/detach devices */
55int isp_quickboot_time = 7; /* don't wait more than N secs for loop up */
56int isp_gone_device_time = 30; /* grace time before reporting device lost */
57int isp_autoconfig = 1; /* automatically attach/detach devices */
59static const char prom3[] = "Chan %d PortID 0x%06x Departed from Target %u because of %s";
58static const char prom3[] = "Chan %d [%u] PortID 0x%06x Departed because of %s";
60
61static void isp_freeze_loopdown(ispsoftc_t *, int, char *);
62static d_ioctl_t ispioctl;
63static void isp_intr_enable(void *);
64static void isp_cam_async(void *, uint32_t, struct cam_path *, void *);
65static void isp_poll(struct cam_sim *);
66static timeout_t isp_watchdog;
67static timeout_t isp_gdt;

--- 401 unchanged lines hidden (view full) ---

469 *(int *)addr = SDPARAM(isp, chan)->role;
470 retval = isp_control(isp, ISPCTL_CHANGE_ROLE, chan, nr);
471 ISP_UNLOCK(isp);
472 retval = 0;
473 break;
474
475 case ISP_RESETHBA:
476 ISP_LOCK(isp);
59
60static void isp_freeze_loopdown(ispsoftc_t *, int, char *);
61static d_ioctl_t ispioctl;
62static void isp_intr_enable(void *);
63static void isp_cam_async(void *, uint32_t, struct cam_path *, void *);
64static void isp_poll(struct cam_sim *);
65static timeout_t isp_watchdog;
66static timeout_t isp_gdt;

--- 401 unchanged lines hidden (view full) ---

468 *(int *)addr = SDPARAM(isp, chan)->role;
469 retval = isp_control(isp, ISPCTL_CHANGE_ROLE, chan, nr);
470 ISP_UNLOCK(isp);
471 retval = 0;
472 break;
473
474 case ISP_RESETHBA:
475 ISP_LOCK(isp);
477#ifdef ISP_TARGET_MODE
478 isp_del_all_wwn_entries(isp, ISP_NOCHAN);
479#endif
480 isp_reinit(isp, 0);
481 ISP_UNLOCK(isp);
482 retval = 0;
483 break;
484
485 case ISP_RESCAN:
486 if (IS_FC(isp)) {
487 chan = *(int *)addr;

--- 35 unchanged lines hidden (view full) ---

523 if (IS_SCSI(isp)) {
524 break;
525 }
526 if (ifc->loopid >= MAX_FC_TARG) {
527 retval = EINVAL;
528 break;
529 }
530 lp = &FCPARAM(isp, ifc->chan)->portdb[ifc->loopid];
476 isp_reinit(isp, 0);
477 ISP_UNLOCK(isp);
478 retval = 0;
479 break;
480
481 case ISP_RESCAN:
482 if (IS_FC(isp)) {
483 chan = *(int *)addr;

--- 35 unchanged lines hidden (view full) ---

519 if (IS_SCSI(isp)) {
520 break;
521 }
522 if (ifc->loopid >= MAX_FC_TARG) {
523 retval = EINVAL;
524 break;
525 }
526 lp = &FCPARAM(isp, ifc->chan)->portdb[ifc->loopid];
531 if (lp->state == FC_PORTDB_STATE_VALID || lp->target_mode) {
527 if (lp->state != FC_PORTDB_STATE_NIL) {
532 ifc->role = (lp->prli_word3 & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
533 ifc->loopid = lp->handle;
534 ifc->portid = lp->portid;
535 ifc->node_wwn = lp->node_wwn;
536 ifc->port_wwn = lp->port_wwn;
537 retval = 0;
538 } else {
539 retval = ENODEV;

--- 967 unchanged lines hidden (view full) ---

1507 status = CAM_RESRC_UNAVAIL;
1508 } else {
1509 mtx_sleep(ccb, &isp->isp_lock, PRIBIO, "isp_disable_lun", 0);
1510 }
1511 isp->isp_osinfo.rptr = NULL;
1512done:
1513 if (status == CAM_REQ_CMP) {
1514 tptr->enabled = 0;
528 ifc->role = (lp->prli_word3 & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
529 ifc->loopid = lp->handle;
530 ifc->portid = lp->portid;
531 ifc->node_wwn = lp->node_wwn;
532 ifc->port_wwn = lp->port_wwn;
533 retval = 0;
534 } else {
535 retval = ENODEV;

--- 967 unchanged lines hidden (view full) ---

1503 status = CAM_RESRC_UNAVAIL;
1504 } else {
1505 mtx_sleep(ccb, &isp->isp_lock, PRIBIO, "isp_disable_lun", 0);
1506 }
1507 isp->isp_osinfo.rptr = NULL;
1508done:
1509 if (status == CAM_REQ_CMP) {
1510 tptr->enabled = 0;
1515 /*
1516 * If we have no more luns enabled for this bus,
1517 * delete all tracked wwns for it (if we are FC),
1518 * and disable target mode.
1519 */
1520 if (is_any_lun_enabled(isp, bus) == 0) {
1511 if (is_any_lun_enabled(isp, bus) == 0) {
1521 isp_del_all_wwn_entries(isp, bus);
1522 if (isp_disable_target_mode(isp, bus)) {
1523 status = CAM_REQ_CMP_ERR;
1524 }
1525 }
1526 }
1527 ccb->ccb_h.status = status;
1528 if (status == CAM_REQ_CMP) {
1529 destroy_lun_state(isp, tptr);

--- 932 unchanged lines hidden (view full) ---

2462 atiop->init_id = ((at2e_entry_t *)aep)->at_iid;
2463 } else {
2464 atiop->init_id = aep->at_iid;
2465 }
2466
2467 /*
2468 * If we're not in the port database, add ourselves.
2469 */
1512 if (isp_disable_target_mode(isp, bus)) {
1513 status = CAM_REQ_CMP_ERR;
1514 }
1515 }
1516 }
1517 ccb->ccb_h.status = status;
1518 if (status == CAM_REQ_CMP) {
1519 destroy_lun_state(isp, tptr);

--- 932 unchanged lines hidden (view full) ---

2452 atiop->init_id = ((at2e_entry_t *)aep)->at_iid;
2453 } else {
2454 atiop->init_id = aep->at_iid;
2455 }
2456
2457 /*
2458 * If we're not in the port database, add ourselves.
2459 */
2470 if (!IS_2100(isp) && isp_find_pdb_by_loopid(isp, 0, atiop->init_id, &lp) == 0) {
2460 if (!IS_2100(isp) &&
2461 (isp_find_pdb_by_handle(isp, 0, atiop->init_id, &lp) == 0 ||
2462 lp->state == FC_PORTDB_STATE_ZOMBIE)) {
2471 uint64_t iid =
2472 (((uint64_t) aep->at_wwpn[0]) << 48) |
2473 (((uint64_t) aep->at_wwpn[1]) << 32) |
2474 (((uint64_t) aep->at_wwpn[2]) << 16) |
2475 (((uint64_t) aep->at_wwpn[3]) << 0);
2476 isp_add_wwn_entry(isp, 0, iid, atiop->init_id, PORT_ANY, 0);
2477 }
2478 atiop->cdb_len = ATIO2_CDBLEN;

--- 110 unchanged lines hidden (view full) ---

2589 * Find the PDB entry for this initiator
2590 */
2591 if (isp_find_pdb_by_sid(isp, chan, sid, &lp) == 0) {
2592 /*
2593 * If we're not in the port database terminate the exchange.
2594 */
2595 isp_prt(isp, ISP_LOGTINFO, "%s: [RX_ID 0x%x] D_ID 0x%06x found on Chan %d for S_ID 0x%06x wasn't in PDB already",
2596 __func__, aep->at_rxid, did, chan, sid);
2463 uint64_t iid =
2464 (((uint64_t) aep->at_wwpn[0]) << 48) |
2465 (((uint64_t) aep->at_wwpn[1]) << 32) |
2466 (((uint64_t) aep->at_wwpn[2]) << 16) |
2467 (((uint64_t) aep->at_wwpn[3]) << 0);
2468 isp_add_wwn_entry(isp, 0, iid, atiop->init_id, PORT_ANY, 0);
2469 }
2470 atiop->cdb_len = ATIO2_CDBLEN;

--- 110 unchanged lines hidden (view full) ---

2581 * Find the PDB entry for this initiator
2582 */
2583 if (isp_find_pdb_by_sid(isp, chan, sid, &lp) == 0) {
2584 /*
2585 * If we're not in the port database terminate the exchange.
2586 */
2587 isp_prt(isp, ISP_LOGTINFO, "%s: [RX_ID 0x%x] D_ID 0x%06x found on Chan %d for S_ID 0x%06x wasn't in PDB already",
2588 __func__, aep->at_rxid, did, chan, sid);
2589 isp_dump_portdb(isp, chan);
2597 isp_endcmd(isp, aep, NIL_HANDLE, chan, ECMD_TERMINATE, 0);
2598 return;
2599 }
2600 nphdl = lp->handle;
2601 wwn = lp->port_wwn;
2602
2603 /*
2604 * Get the tstate pointer

--- 506 unchanged lines hidden (view full) ---

3111 } else {
3112 lun = inp->in_lun;
3113 }
3114 if (ISP_CAP_2KLOGIN(isp)) {
3115 loopid = ((in_fcentry_e_t *)inp)->in_iid;
3116 } else {
3117 loopid = inp->in_iid;
3118 }
2590 isp_endcmd(isp, aep, NIL_HANDLE, chan, ECMD_TERMINATE, 0);
2591 return;
2592 }
2593 nphdl = lp->handle;
2594 wwn = lp->port_wwn;
2595
2596 /*
2597 * Get the tstate pointer

--- 506 unchanged lines hidden (view full) ---

3104 } else {
3105 lun = inp->in_lun;
3106 }
3107 if (ISP_CAP_2KLOGIN(isp)) {
3108 loopid = ((in_fcentry_e_t *)inp)->in_iid;
3109 } else {
3110 loopid = inp->in_iid;
3111 }
3119 if (isp_find_pdb_by_loopid(isp, 0, loopid, &lp)) {
3112 if (isp_find_pdb_by_handle(isp, 0, loopid, &lp)) {
3120 wwn = lp->port_wwn;
3121 } else {
3122 wwn = INI_ANY;
3123 }
3124 tptr = get_lun_statep(isp, 0, lun);
3125 if (tptr == NULL) {
3126 tptr = get_lun_statep(isp, 0, CAM_LUN_WILDCARD);
3127 if (tptr == NULL) {

--- 137 unchanged lines hidden (view full) ---

3265 isp_prt(isp, ISP_LOGTDEBUG0, "%s Chan %d ELS N-port handle %x PortID 0x%06x RX_ID 0x%x OX_ID 0x%x", msg, chan, nphdl, portid,
3266 inot->in_rxid, inot->in_oxid);
3267 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
3268 break;
3269 }
3270
3271 case IN24XX_PORT_LOGOUT:
3272 ptr = "PORT LOGOUT";
3113 wwn = lp->port_wwn;
3114 } else {
3115 wwn = INI_ANY;
3116 }
3117 tptr = get_lun_statep(isp, 0, lun);
3118 if (tptr == NULL) {
3119 tptr = get_lun_statep(isp, 0, CAM_LUN_WILDCARD);
3120 if (tptr == NULL) {

--- 137 unchanged lines hidden (view full) ---

3258 isp_prt(isp, ISP_LOGTDEBUG0, "%s Chan %d ELS N-port handle %x PortID 0x%06x RX_ID 0x%x OX_ID 0x%x", msg, chan, nphdl, portid,
3259 inot->in_rxid, inot->in_oxid);
3260 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
3261 break;
3262 }
3263
3264 case IN24XX_PORT_LOGOUT:
3265 ptr = "PORT LOGOUT";
3273 if (isp_find_pdb_by_loopid(isp, ISP_GET_VPIDX(isp, inot->in_vpidx), nphdl, &lp)) {
3266 if (isp_find_pdb_by_handle(isp, ISP_GET_VPIDX(isp, inot->in_vpidx), nphdl, &lp)) {
3274 isp_del_wwn_entry(isp, ISP_GET_VPIDX(isp, inot->in_vpidx), lp->port_wwn, nphdl, lp->portid);
3275 }
3276 /* FALLTHROUGH */
3277 case IN24XX_PORT_CHANGED:
3278 if (ptr == NULL) {
3279 ptr = "PORT CHANGED";
3280 }
3281 /* FALLTHROUGH */

--- 1319 unchanged lines hidden (view full) ---

4601 return;
4602 }
4603 if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(fc->sim),
4604 tgt, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
4605 isp_prt(isp, ISP_LOGWARN, "unable to create path for rescan");
4606 xpt_free_ccb(ccb);
4607 return;
4608 }
3267 isp_del_wwn_entry(isp, ISP_GET_VPIDX(isp, inot->in_vpidx), lp->port_wwn, nphdl, lp->portid);
3268 }
3269 /* FALLTHROUGH */
3270 case IN24XX_PORT_CHANGED:
3271 if (ptr == NULL) {
3272 ptr = "PORT CHANGED";
3273 }
3274 /* FALLTHROUGH */

--- 1319 unchanged lines hidden (view full) ---

4594 return;
4595 }
4596 if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(fc->sim),
4597 tgt, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
4598 isp_prt(isp, ISP_LOGWARN, "unable to create path for rescan");
4599 xpt_free_ccb(ccb);
4600 return;
4601 }
4609
4610 /*
4611 * Since we're about to issue a rescan, mark this device as not
4612 * reported gone.
4613 */
4614 fcp->reported_gone = 0;
4615
4616 xpt_rescan(ccb);
4617}
4618
4619static void
4620isp_make_gone(ispsoftc_t *isp, fcportdb_t *fcp, int chan, int tgt)
4621{
4622 struct cam_path *tp;
4623 struct isp_fc *fc = ISP_FC_PC(isp, chan);
4624
4625 if (isp_autoconfig == 0) {
4626 return;
4627 }
4628 if (xpt_create_path(&tp, NULL, cam_sim_path(fc->sim), tgt, CAM_LUN_WILDCARD) == CAM_REQ_CMP) {
4602 xpt_rescan(ccb);
4603}
4604
4605static void
4606isp_make_gone(ispsoftc_t *isp, fcportdb_t *fcp, int chan, int tgt)
4607{
4608 struct cam_path *tp;
4609 struct isp_fc *fc = ISP_FC_PC(isp, chan);
4610
4611 if (isp_autoconfig == 0) {
4612 return;
4613 }
4614 if (xpt_create_path(&tp, NULL, cam_sim_path(fc->sim), tgt, CAM_LUN_WILDCARD) == CAM_REQ_CMP) {
4629 /*
4630 * We're about to send out the lost device async
4631 * notification, so indicate that we have reported it gone.
4632 */
4633 fcp->reported_gone = 1;
4634 xpt_async(AC_LOST_DEVICE, tp, NULL);
4635 xpt_free_path(tp);
4636 }
4637}
4638
4639/*
4640 * Gone Device Timer Function- when we have decided that a device has gone
4641 * away, we wait a specific period of time prior to telling the OS it has

--- 13 unchanged lines hidden (view full) ---

4655
4656static void
4657isp_gdt_task(void *arg, int pending)
4658{
4659 struct isp_fc *fc = arg;
4660 ispsoftc_t *isp = fc->isp;
4661 int chan = fc - isp->isp_osinfo.pc.fc;
4662 fcportdb_t *lp;
4615 xpt_async(AC_LOST_DEVICE, tp, NULL);
4616 xpt_free_path(tp);
4617 }
4618}
4619
4620/*
4621 * Gone Device Timer Function- when we have decided that a device has gone
4622 * away, we wait a specific period of time prior to telling the OS it has

--- 13 unchanged lines hidden (view full) ---

4636
4637static void
4638isp_gdt_task(void *arg, int pending)
4639{
4640 struct isp_fc *fc = arg;
4641 ispsoftc_t *isp = fc->isp;
4642 int chan = fc - isp->isp_osinfo.pc.fc;
4643 fcportdb_t *lp;
4644 struct ac_contract ac;
4645 struct ac_device_changed *adc;
4663 int dbidx, more_to_do = 0;
4664
4665 ISP_LOCK(isp);
4666 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d GDT timer expired", chan);
4667 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
4668 lp = &FCPARAM(isp, chan)->portdb[dbidx];
4669
4670 if (lp->state != FC_PORTDB_STATE_ZOMBIE) {
4671 continue;
4672 }
4646 int dbidx, more_to_do = 0;
4647
4648 ISP_LOCK(isp);
4649 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d GDT timer expired", chan);
4650 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
4651 lp = &FCPARAM(isp, chan)->portdb[dbidx];
4652
4653 if (lp->state != FC_PORTDB_STATE_ZOMBIE) {
4654 continue;
4655 }
4673 if (lp->dev_map_idx == 0 || lp->target_mode) {
4674 continue;
4675 }
4676 if (lp->gone_timer != 0) {
4656 if (lp->gone_timer != 0) {
4677 isp_prt(isp, ISP_LOG_SANCFG, "%s: Chan %d more to do for target %u (timer=%u)", __func__, chan, lp->dev_map_idx - 1, lp->gone_timer);
4678 lp->gone_timer -= 1;
4679 more_to_do++;
4680 continue;
4681 }
4657 lp->gone_timer -= 1;
4658 more_to_do++;
4659 continue;
4660 }
4682 lp->dev_map_idx = 0;
4661 isp_prt(isp, ISP_LOGCONFIG, prom3, chan, dbidx, lp->portid, "Gone Device Timeout");
4662 if (lp->is_target) {
4663 lp->is_target = 0;
4664 isp_make_gone(isp, lp, chan, dbidx);
4665 }
4666 if (lp->is_initiator) {
4667 lp->is_initiator = 0;
4668 ac.contract_number = AC_CONTRACT_DEV_CHG;
4669 adc = (struct ac_device_changed *) ac.contract_data;
4670 adc->wwpn = lp->port_wwn;
4671 adc->port = lp->portid;
4672 adc->target = lp->handle;
4673 adc->arrived = 0;
4674 xpt_async(AC_CONTRACT, fc->path, &ac);
4675 }
4683 lp->state = FC_PORTDB_STATE_NIL;
4676 lp->state = FC_PORTDB_STATE_NIL;
4684 isp_prt(isp, ISP_LOGCONFIG, prom3, chan, lp->portid, dbidx, "Gone Device Timeout");
4685 isp_make_gone(isp, lp, chan, dbidx);
4686 }
4687 if (fc->ready) {
4688 if (more_to_do) {
4689 callout_reset(&fc->gdt, hz, isp_gdt, fc);
4690 } else {
4691 callout_deactivate(&fc->gdt);
4692 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Stopping Gone Device Timer @ %lu", chan, (unsigned long) time_uptime);
4693 }

--- 19 unchanged lines hidden (view full) ---

4713
4714static void
4715isp_ldt_task(void *arg, int pending)
4716{
4717 struct isp_fc *fc = arg;
4718 ispsoftc_t *isp = fc->isp;
4719 int chan = fc - isp->isp_osinfo.pc.fc;
4720 fcportdb_t *lp;
4677 }
4678 if (fc->ready) {
4679 if (more_to_do) {
4680 callout_reset(&fc->gdt, hz, isp_gdt, fc);
4681 } else {
4682 callout_deactivate(&fc->gdt);
4683 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Stopping Gone Device Timer @ %lu", chan, (unsigned long) time_uptime);
4684 }

--- 19 unchanged lines hidden (view full) ---

4704
4705static void
4706isp_ldt_task(void *arg, int pending)
4707{
4708 struct isp_fc *fc = arg;
4709 ispsoftc_t *isp = fc->isp;
4710 int chan = fc - isp->isp_osinfo.pc.fc;
4711 fcportdb_t *lp;
4712 struct ac_contract ac;
4713 struct ac_device_changed *adc;
4721 int dbidx, i;
4722
4723 ISP_LOCK(isp);
4724 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Chan %d Loop Down Timer expired @ %lu", chan, (unsigned long) time_uptime);
4725 callout_deactivate(&fc->ldt);
4726
4727 /*
4728 * Notify to the OS all targets who we now consider have departed.
4729 */
4730 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
4731 lp = &FCPARAM(isp, chan)->portdb[dbidx];
4732
4714 int dbidx, i;
4715
4716 ISP_LOCK(isp);
4717 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Chan %d Loop Down Timer expired @ %lu", chan, (unsigned long) time_uptime);
4718 callout_deactivate(&fc->ldt);
4719
4720 /*
4721 * Notify to the OS all targets who we now consider have departed.
4722 */
4723 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
4724 lp = &FCPARAM(isp, chan)->portdb[dbidx];
4725
4733 if (lp->state != FC_PORTDB_STATE_PROBATIONAL) {
4726 if (lp->state == FC_PORTDB_STATE_NIL)
4734 continue;
4727 continue;
4735 }
4736 if (lp->dev_map_idx == 0 || lp->target_mode) {
4737 continue;
4738 }
4739
4740 /*
4741 * XXX: CLEAN UP AND COMPLETE ANY PENDING COMMANDS FIRST!
4742 */
4728
4729 /*
4730 * XXX: CLEAN UP AND COMPLETE ANY PENDING COMMANDS FIRST!
4731 */
4743
4744
4745 for (i = 0; i < isp->isp_maxcmds; i++) {
4746 struct ccb_scsiio *xs;
4747
4748 if (!ISP_VALID_HANDLE(isp, isp->isp_xflist[i].handle)) {
4749 continue;
4750 }
4751 if ((xs = isp->isp_xflist[i].cmd) == NULL) {
4752 continue;
4753 }
4754 if (dbidx != XS_TGT(xs)) {
4755 continue;
4756 }
4757 isp_prt(isp, ISP_LOGWARN, "command handle 0x%x for %d.%d.%d orphaned by loop down timeout",
4758 isp->isp_xflist[i].handle, chan, XS_TGT(xs), XS_LUN(xs));
4759 }
4760
4732 for (i = 0; i < isp->isp_maxcmds; i++) {
4733 struct ccb_scsiio *xs;
4734
4735 if (!ISP_VALID_HANDLE(isp, isp->isp_xflist[i].handle)) {
4736 continue;
4737 }
4738 if ((xs = isp->isp_xflist[i].cmd) == NULL) {
4739 continue;
4740 }
4741 if (dbidx != XS_TGT(xs)) {
4742 continue;
4743 }
4744 isp_prt(isp, ISP_LOGWARN, "command handle 0x%x for %d.%d.%d orphaned by loop down timeout",
4745 isp->isp_xflist[i].handle, chan, XS_TGT(xs), XS_LUN(xs));
4746 }
4747
4761 /*
4762 * Mark that we've announced that this device is gone....
4763 */
4764 lp->announced = 1;
4765 lp->dev_map_idx = 0;
4766 lp->state = FC_PORTDB_STATE_NIL;
4767 isp_prt(isp, ISP_LOGCONFIG, prom3, chan, lp->portid, dbidx, "Loop Down Timeout");
4768 isp_make_gone(isp, lp, chan, dbidx);
4748 isp_prt(isp, ISP_LOGCONFIG, prom3, chan, dbidx, lp->portid, "Loop Down Timeout");
4749 if (lp->is_target) {
4750 lp->is_target = 0;
4751 isp_make_gone(isp, lp, chan, dbidx);
4752 }
4753 if (lp->is_initiator) {
4754 lp->is_initiator = 0;
4755 ac.contract_number = AC_CONTRACT_DEV_CHG;
4756 adc = (struct ac_device_changed *) ac.contract_data;
4757 adc->wwpn = lp->port_wwn;
4758 adc->port = lp->portid;
4759 adc->target = lp->handle;
4760 adc->arrived = 0;
4761 xpt_async(AC_CONTRACT, fc->path, &ac);
4762 }
4769 }
4770
4763 }
4764
4771 if (FCPARAM(isp, chan)->role & ISP_ROLE_INITIATOR) {
4772 isp_unfreeze_loopdown(isp, chan);
4773 }
4765 isp_unfreeze_loopdown(isp, chan);
4774 /*
4775 * The loop down timer has expired. Wake up the kthread
4776 * to notice that fact (or make it false).
4777 */
4778 fc->loop_dead = 1;
4779 fc->loop_down_time = fc->loop_down_limit+1;
4780 wakeup(fc);
4781 ISP_UNLOCK(isp);

--- 798 unchanged lines hidden (view full) ---

5580 if (status != CAM_REQ_CMP) {
5581 if (status != CAM_SEL_TIMEOUT)
5582 isp_prt(isp, ISP_LOGDEBUG0, "target %d lun %d CAM status 0x%x SCSI status 0x%x", XS_TGT(sccb), XS_LUN(sccb), sccb->ccb_h.status, sccb->scsi_status);
5583 else if ((IS_FC(isp))
5584 && (XS_TGT(sccb) < MAX_FC_TARG)) {
5585 fcparam *fcp;
5586
5587 fcp = FCPARAM(isp, XS_CHANNEL(sccb));
4766 /*
4767 * The loop down timer has expired. Wake up the kthread
4768 * to notice that fact (or make it false).
4769 */
4770 fc->loop_dead = 1;
4771 fc->loop_down_time = fc->loop_down_limit+1;
4772 wakeup(fc);
4773 ISP_UNLOCK(isp);

--- 798 unchanged lines hidden (view full) ---

5572 if (status != CAM_REQ_CMP) {
5573 if (status != CAM_SEL_TIMEOUT)
5574 isp_prt(isp, ISP_LOGDEBUG0, "target %d lun %d CAM status 0x%x SCSI status 0x%x", XS_TGT(sccb), XS_LUN(sccb), sccb->ccb_h.status, sccb->scsi_status);
5575 else if ((IS_FC(isp))
5576 && (XS_TGT(sccb) < MAX_FC_TARG)) {
5577 fcparam *fcp;
5578
5579 fcp = FCPARAM(isp, XS_CHANNEL(sccb));
5588 fcp->portdb[XS_TGT(sccb)].reported_gone = 1;
5580 fcp->portdb[XS_TGT(sccb)].is_target = 0;
5589 }
5590 if ((sccb->ccb_h.status & CAM_DEV_QFRZN) == 0) {
5591 sccb->ccb_h.status |= CAM_DEV_QFRZN;
5592 xpt_freeze_devq(sccb->ccb_h.path, 1);
5593 }
5594 }
5595
5596 if ((CAM_DEBUGGED(sccb->ccb_h.path, ISPDDB)) && (sccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {

--- 6 unchanged lines hidden (view full) ---

5603 isp_free_pcmd(isp, (union ccb *) sccb);
5604 }
5605 xpt_done((union ccb *) sccb);
5606}
5607
5608void
5609isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
5610{
5581 }
5582 if ((sccb->ccb_h.status & CAM_DEV_QFRZN) == 0) {
5583 sccb->ccb_h.status |= CAM_DEV_QFRZN;
5584 xpt_freeze_devq(sccb->ccb_h.path, 1);
5585 }
5586 }
5587
5588 if ((CAM_DEBUGGED(sccb->ccb_h.path, ISPDDB)) && (sccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {

--- 6 unchanged lines hidden (view full) ---

5595 isp_free_pcmd(isp, (union ccb *) sccb);
5596 }
5597 xpt_done((union ccb *) sccb);
5598}
5599
5600void
5601isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
5602{
5611 int bus, now;
5612 static const char prom0[] = "Chan %d PortID 0x%06x handle 0x%x %s %s WWPN 0x%08x%08x";
5613 static const char prom2[] = "Chan %d PortID 0x%06x handle 0x%x %s %s tgt %u WWPN 0x%08x%08x";
5603 int bus;
5604 static const char prom[] = "Chan %d [%d] WWPN 0x%16jx PortID 0x%06x handle 0x%x %s %s";
5614 char buf[64];
5615 char *msg = NULL;
5616 target_id_t tgt;
5617 fcportdb_t *lp;
5618 struct isp_fc *fc;
5619 struct cam_path *tmppath;
5605 char buf[64];
5606 char *msg = NULL;
5607 target_id_t tgt;
5608 fcportdb_t *lp;
5609 struct isp_fc *fc;
5610 struct cam_path *tmppath;
5611 struct ac_contract ac;
5612 struct ac_device_changed *adc;
5620 va_list ap;
5621
5622 switch (cmd) {
5623 case ISPASYNC_NEW_TGT_PARAMS:
5624 {
5625 struct ccb_trans_settings_scsi *scsi;
5626 struct ccb_trans_settings_spi *spi;
5627 int flags, tgt;

--- 85 unchanged lines hidden (view full) ---

5713 if (cmd == ISPASYNC_LOOP_DOWN && fc->ready) {
5714 /*
5715 * We don't do any simq freezing if we are only in target mode
5716 */
5717 if (FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) {
5718 if (fc->path) {
5719 isp_freeze_loopdown(isp, bus, msg);
5720 }
5613 va_list ap;
5614
5615 switch (cmd) {
5616 case ISPASYNC_NEW_TGT_PARAMS:
5617 {
5618 struct ccb_trans_settings_scsi *scsi;
5619 struct ccb_trans_settings_spi *spi;
5620 int flags, tgt;

--- 85 unchanged lines hidden (view full) ---

5706 if (cmd == ISPASYNC_LOOP_DOWN && fc->ready) {
5707 /*
5708 * We don't do any simq freezing if we are only in target mode
5709 */
5710 if (FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) {
5711 if (fc->path) {
5712 isp_freeze_loopdown(isp, bus, msg);
5713 }
5721 if (!callout_active(&fc->ldt)) {
5722 callout_reset(&fc->ldt, fc->loop_down_limit * hz, isp_ldt, fc);
5723 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Starting Loop Down Timer @ %lu", (unsigned long) time_uptime);
5724 }
5725 }
5714 }
5715 if (!callout_active(&fc->ldt)) {
5716 callout_reset(&fc->ldt, fc->loop_down_limit * hz, isp_ldt, fc);
5717 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Starting Loop Down Timer @ %lu", (unsigned long) time_uptime);
5718 }
5726 }
5727 isp_fcp_reset_crn(fc, /*tgt*/0, /*tgt_set*/ 0);
5728
5729 isp_prt(isp, ISP_LOGINFO, "Chan %d: %s", bus, msg);
5730 break;
5731 }
5732 case ISPASYNC_LOOP_UP:
5733 va_start(ap, cmd);

--- 12 unchanged lines hidden (view full) ---

5746 isp_prt(isp, ISP_LOGINFO, "Chan %d Loop UP", bus);
5747 break;
5748 case ISPASYNC_DEV_ARRIVED:
5749 va_start(ap, cmd);
5750 bus = va_arg(ap, int);
5751 lp = va_arg(ap, fcportdb_t *);
5752 va_end(ap);
5753 fc = ISP_FC_PC(isp, bus);
5719 }
5720 isp_fcp_reset_crn(fc, /*tgt*/0, /*tgt_set*/ 0);
5721
5722 isp_prt(isp, ISP_LOGINFO, "Chan %d: %s", bus, msg);
5723 break;
5724 }
5725 case ISPASYNC_LOOP_UP:
5726 va_start(ap, cmd);

--- 12 unchanged lines hidden (view full) ---

5739 isp_prt(isp, ISP_LOGINFO, "Chan %d Loop UP", bus);
5740 break;
5741 case ISPASYNC_DEV_ARRIVED:
5742 va_start(ap, cmd);
5743 bus = va_arg(ap, int);
5744 lp = va_arg(ap, fcportdb_t *);
5745 va_end(ap);
5746 fc = ISP_FC_PC(isp, bus);
5754 lp->announced = 0;
5755 lp->gone_timer = 0;
5756 if ((FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) && (lp->prli_word3 & PRLI_WD3_TARGET_FUNCTION)) {
5757 lp->dev_map_idx = (lp - FCPARAM(isp, bus)->portdb) + 1;
5758 }
5747 tgt = FC_PORTDB_TGT(isp, bus, lp);
5759 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5748 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5760 if (lp->dev_map_idx) {
5761 tgt = lp->dev_map_idx - 1;
5762 isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, buf, "arrived at", tgt, (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5749 isp_prt(isp, ISP_LOGCONFIG, prom, bus, tgt, lp->port_wwn, lp->portid, lp->handle, buf, "arrived");
5750 if ((FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) &&
5751 (lp->prli_word3 & PRLI_WD3_TARGET_FUNCTION)) {
5752 lp->is_target = 1;
5763 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5764 isp_make_here(isp, lp, bus, tgt);
5753 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5754 isp_make_here(isp, lp, bus, tgt);
5765 } else {
5766 isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, buf, "arrived", (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5767 }
5755 }
5756 if ((FCPARAM(isp, bus)->role & ISP_ROLE_TARGET) &&
5757 (lp->prli_word3 & PRLI_WD3_INITIATOR_FUNCTION)) {
5758 lp->is_initiator = 1;
5759 ac.contract_number = AC_CONTRACT_DEV_CHG;
5760 adc = (struct ac_device_changed *) ac.contract_data;
5761 adc->wwpn = lp->port_wwn;
5762 adc->port = lp->portid;
5763 adc->target = lp->handle;
5764 adc->arrived = 1;
5765 xpt_async(AC_CONTRACT, fc->path, &ac);
5766 }
5768 break;
5769 case ISPASYNC_DEV_CHANGED:
5770 va_start(ap, cmd);
5771 bus = va_arg(ap, int);
5772 lp = va_arg(ap, fcportdb_t *);
5773 va_end(ap);
5774 fc = ISP_FC_PC(isp, bus);
5767 break;
5768 case ISPASYNC_DEV_CHANGED:
5769 va_start(ap, cmd);
5770 bus = va_arg(ap, int);
5771 lp = va_arg(ap, fcportdb_t *);
5772 va_end(ap);
5773 fc = ISP_FC_PC(isp, bus);
5775 lp->announced = 0;
5776 lp->gone_timer = 0;
5777 if (isp_change_is_bad) {
5778 lp->state = FC_PORTDB_STATE_NIL;
5779 if (lp->dev_map_idx) {
5780 tgt = lp->dev_map_idx - 1;
5781 lp->dev_map_idx = 0;
5782 isp_prt(isp, ISP_LOGCONFIG, prom3, bus, lp->portid, tgt, "change is bad");
5783 isp_make_gone(isp, lp, bus, tgt);
5784 } else {
5785 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5786 isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, buf, "changed and departed",
5787 (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5788 }
5789 } else {
5790 lp->portid = lp->new_portid;
5791 lp->prli_word3 = lp->new_prli_word3;
5792 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5793 if (lp->dev_map_idx) {
5794 tgt = lp->dev_map_idx - 1;
5795 isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, buf, "changed at", tgt,
5796 (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5774 tgt = FC_PORTDB_TGT(isp, bus, lp);
5775 isp_gen_role_str(buf, sizeof (buf), lp->new_prli_word3);
5776 isp_prt(isp, ISP_LOGCONFIG, prom, bus, tgt, lp->port_wwn, lp->new_portid, lp->handle, buf, "changed");
5777changed:
5778 if (lp->is_target !=
5779 ((FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) &&
5780 (lp->new_prli_word3 & PRLI_WD3_TARGET_FUNCTION))) {
5781 lp->is_target = !lp->is_target;
5782 if (lp->is_target) {
5797 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5783 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5784 isp_make_here(isp, lp, bus, tgt);
5798 } else {
5785 } else {
5799 isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, buf, "changed", (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5786 isp_make_gone(isp, lp, bus, tgt);
5787 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5800 }
5801 }
5788 }
5789 }
5790 if (lp->is_initiator !=
5791 ((FCPARAM(isp, bus)->role & ISP_ROLE_TARGET) &&
5792 (lp->new_prli_word3 & PRLI_WD3_INITIATOR_FUNCTION))) {
5793 lp->is_initiator = !lp->is_initiator;
5794 ac.contract_number = AC_CONTRACT_DEV_CHG;
5795 adc = (struct ac_device_changed *) ac.contract_data;
5796 adc->wwpn = lp->port_wwn;
5797 adc->port = lp->portid;
5798 adc->target = lp->handle;
5799 adc->arrived = lp->is_initiator;
5800 xpt_async(AC_CONTRACT, fc->path, &ac);
5801 }
5802 break;
5803 case ISPASYNC_DEV_STAYED:
5804 va_start(ap, cmd);
5805 bus = va_arg(ap, int);
5806 lp = va_arg(ap, fcportdb_t *);
5807 va_end(ap);
5802 break;
5803 case ISPASYNC_DEV_STAYED:
5804 va_start(ap, cmd);
5805 bus = va_arg(ap, int);
5806 lp = va_arg(ap, fcportdb_t *);
5807 va_end(ap);
5808 fc = ISP_FC_PC(isp, bus);
5809 tgt = FC_PORTDB_TGT(isp, bus, lp);
5808 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5810 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5809 if (lp->dev_map_idx) {
5810 fc = ISP_FC_PC(isp, bus);
5811 tgt = lp->dev_map_idx - 1;
5812 isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, buf, "stayed at", tgt,
5813 (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5814 /*
5815 * Only issue a rescan if we've actually reported
5816 * that this device is gone.
5817 */
5818 if (lp->reported_gone != 0) {
5819 isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, buf, "rescanned at", tgt,
5820 (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5821 isp_make_here(isp, lp, bus, tgt);
5822 }
5823 } else {
5824 isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, buf, "stayed",
5825 (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5826 }
5827 break;
5811 isp_prt(isp, ISP_LOGCONFIG, prom, bus, tgt, lp->port_wwn, lp->portid, lp->handle, buf, "stayed");
5812 goto changed;
5828 case ISPASYNC_DEV_GONE:
5829 va_start(ap, cmd);
5830 bus = va_arg(ap, int);
5831 lp = va_arg(ap, fcportdb_t *);
5813 case ISPASYNC_DEV_GONE:
5814 va_start(ap, cmd);
5815 bus = va_arg(ap, int);
5816 lp = va_arg(ap, fcportdb_t *);
5832 now = va_arg(ap, int);
5833 va_end(ap);
5834 fc = ISP_FC_PC(isp, bus);
5817 va_end(ap);
5818 fc = ISP_FC_PC(isp, bus);
5819 tgt = FC_PORTDB_TGT(isp, bus, lp);
5835 /*
5820 /*
5836 * If this has a virtual target and we haven't marked it
5837 * that we're going to have isp_gdt tell the OS it's gone,
5838 * set the isp_gdt timer running on it.
5839 *
5840 * If it isn't marked that isp_gdt is going to get rid of it,
5841 * announce that it's gone.
5842 *
5821 * If this has a virtual target or initiator set the isp_gdt
5822 * timer running on it to delay its departure.
5843 */
5844 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5823 */
5824 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5845 if (lp->dev_map_idx && lp->announced == 0 && now) {
5846 lp->announced = 1;
5847 tgt = lp->dev_map_idx - 1;
5848 lp->dev_map_idx = 0;
5849 isp_make_gone(isp, lp, bus, tgt);
5850 isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, buf, "gone at", tgt, (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5851 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5852 } else if (lp->dev_map_idx && lp->announced == 0) {
5853 lp->announced = 1;
5825 if (lp->is_target || lp->is_initiator) {
5854 lp->state = FC_PORTDB_STATE_ZOMBIE;
5826 lp->state = FC_PORTDB_STATE_ZOMBIE;
5855 lp->gone_timer = ISP_FC_PC(isp, bus)->gone_device_time;
5827 lp->gone_timer = fc->gone_device_time;
5828 isp_prt(isp, ISP_LOGCONFIG, prom, bus, tgt, lp->port_wwn, lp->portid, lp->handle, buf, "gone zombie");
5856 if (fc->ready && !callout_active(&fc->gdt)) {
5857 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Chan %d Starting Gone Device Timer with %u seconds time now %lu", bus, lp->gone_timer, (unsigned long)time_uptime);
5858 callout_reset(&fc->gdt, hz, isp_gdt, fc);
5859 }
5829 if (fc->ready && !callout_active(&fc->gdt)) {
5830 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Chan %d Starting Gone Device Timer with %u seconds time now %lu", bus, lp->gone_timer, (unsigned long)time_uptime);
5831 callout_reset(&fc->gdt, hz, isp_gdt, fc);
5832 }
5860 tgt = lp->dev_map_idx - 1;
5861 isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, buf, "gone zombie at", tgt, (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5862 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5863 } else if (lp->announced == 0) {
5864 isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, buf, "departed", (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5833 break;
5865 }
5834 }
5835 isp_prt(isp, ISP_LOGCONFIG, prom, bus, tgt, lp->port_wwn, lp->portid, lp->handle, buf, "gone");
5866 break;
5867 case ISPASYNC_CHANGE_NOTIFY:
5868 {
5869 char *msg;
5870 int evt, nphdl, nlstate, reason;
5871
5872 va_start(ap, cmd);
5873 bus = va_arg(ap, int);

--- 49 unchanged lines hidden (view full) ---

5923 * These are task management functions.
5924 */
5925 isp_handle_platform_target_tmf(isp, notify);
5926 break;
5927 case NT_BUS_RESET:
5928 case NT_LIP_RESET:
5929 case NT_LINK_UP:
5930 case NT_LINK_DOWN:
5836 break;
5837 case ISPASYNC_CHANGE_NOTIFY:
5838 {
5839 char *msg;
5840 int evt, nphdl, nlstate, reason;
5841
5842 va_start(ap, cmd);
5843 bus = va_arg(ap, int);

--- 49 unchanged lines hidden (view full) ---

5893 * These are task management functions.
5894 */
5895 isp_handle_platform_target_tmf(isp, notify);
5896 break;
5897 case NT_BUS_RESET:
5898 case NT_LIP_RESET:
5899 case NT_LINK_UP:
5900 case NT_LINK_DOWN:
5901 case NT_HBA_RESET:
5931 /*
5932 * No action need be taken here.
5933 */
5934 break;
5902 /*
5903 * No action need be taken here.
5904 */
5905 break;
5935 case NT_HBA_RESET:
5936 isp_del_all_wwn_entries(isp, ISP_NOCHAN);
5937 break;
5938 case NT_GLOBAL_LOGOUT:
5939 case NT_LOGOUT:
5940 /*
5941 * This is device arrival/departure notification
5942 */
5943 isp_handle_platform_target_notify_ack(isp, notify);
5944 break;
5906 case NT_GLOBAL_LOGOUT:
5907 case NT_LOGOUT:
5908 /*
5909 * This is device arrival/departure notification
5910 */
5911 isp_handle_platform_target_notify_ack(isp, notify);
5912 break;
5945 case NT_ARRIVED:
5946 {
5947 struct ac_contract ac;
5948 struct ac_device_changed *fc;
5949
5950 ac.contract_number = AC_CONTRACT_DEV_CHG;
5951 fc = (struct ac_device_changed *) ac.contract_data;
5952 fc->wwpn = notify->nt_wwn;
5953 fc->port = notify->nt_sid;
5954 fc->target = notify->nt_nphdl;
5955 fc->arrived = 1;
5956 xpt_async(AC_CONTRACT, ISP_FC_PC(isp, notify->nt_channel)->path, &ac);
5957 break;
5958 }
5959 case NT_DEPARTED:
5960 {
5961 struct ac_contract ac;
5962 struct ac_device_changed *fc;
5963
5964 ac.contract_number = AC_CONTRACT_DEV_CHG;
5965 fc = (struct ac_device_changed *) ac.contract_data;
5966 fc->wwpn = notify->nt_wwn;
5967 fc->port = notify->nt_sid;
5968 fc->target = notify->nt_nphdl;
5969 fc->arrived = 0;
5970 xpt_async(AC_CONTRACT, ISP_FC_PC(isp, notify->nt_channel)->path, &ac);
5971 break;
5972 }
5973 default:
5974 isp_prt(isp, ISP_LOGALL, "target notify code 0x%x", notify->nt_ncode);
5975 isp_handle_platform_target_notify_ack(isp, notify);
5976 break;
5977 }
5978 break;
5979 }
5980 case ISPASYNC_TARGET_NOTIFY_ACK:

--- 74 unchanged lines hidden (view full) ---

6055 nt->nt_did = did;
6056 nt->nt_nphdl = abts->abts_nphdl;
6057 nt->nt_sid = sid;
6058 isp_find_chan_by_did(isp, did, &chan);
6059 if (chan == ISP_NOCHAN) {
6060 nt->nt_tgt = TGT_ANY;
6061 } else {
6062 nt->nt_tgt = FCPARAM(isp, chan)->isp_wwpn;
5913 default:
5914 isp_prt(isp, ISP_LOGALL, "target notify code 0x%x", notify->nt_ncode);
5915 isp_handle_platform_target_notify_ack(isp, notify);
5916 break;
5917 }
5918 break;
5919 }
5920 case ISPASYNC_TARGET_NOTIFY_ACK:

--- 74 unchanged lines hidden (view full) ---

5995 nt->nt_did = did;
5996 nt->nt_nphdl = abts->abts_nphdl;
5997 nt->nt_sid = sid;
5998 isp_find_chan_by_did(isp, did, &chan);
5999 if (chan == ISP_NOCHAN) {
6000 nt->nt_tgt = TGT_ANY;
6001 } else {
6002 nt->nt_tgt = FCPARAM(isp, chan)->isp_wwpn;
6063 if (isp_find_pdb_by_loopid(isp, chan, abts->abts_nphdl, &lp)) {
6003 if (isp_find_pdb_by_handle(isp, chan, abts->abts_nphdl, &lp)) {
6064 nt->nt_wwn = lp->port_wwn;
6065 } else {
6066 nt->nt_wwn = INI_ANY;
6067 }
6068 }
6069 /*
6070 * Try hard to find the lun for this command.
6071 */

--- 444 unchanged lines hidden ---
6004 nt->nt_wwn = lp->port_wwn;
6005 } else {
6006 nt->nt_wwn = INI_ANY;
6007 }
6008 }
6009 /*
6010 * Try hard to find the lun for this command.
6011 */

--- 444 unchanged lines hidden ---