Deleted Added
sdiff udiff text old ( 285147 ) new ( 285154 )
full compact
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 285154 2015-07-05 02:09:46Z 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>

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

4679
4680static void
4681isp_gdt_task(void *arg, int pending)
4682{
4683 struct isp_fc *fc = arg;
4684 ispsoftc_t *isp = fc->isp;
4685 int chan = fc - isp->isp_osinfo.pc.fc;
4686 fcportdb_t *lp;
4687 int dbidx, more_to_do = 0;
4688
4689 ISP_LOCK(isp);
4690 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d GDT timer expired", chan);
4691 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
4692 lp = &FCPARAM(isp, chan)->portdb[dbidx];
4693
4694 if (lp->state != FC_PORTDB_STATE_ZOMBIE) {
4695 continue;
4696 }
4697 if (lp->dev_map_idx == 0 || lp->target_mode) {
4698 continue;
4699 }
4700 if (lp->gone_timer != 0) {
4701 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);
4702 lp->gone_timer -= 1;
4703 more_to_do++;
4704 continue;
4705 }
4706 lp->dev_map_idx = 0;
4707 lp->state = FC_PORTDB_STATE_NIL;
4708 isp_prt(isp, ISP_LOGCONFIG, prom3, chan, lp->portid, dbidx, "Gone Device Timeout");
4709 isp_make_gone(isp, lp, chan, dbidx);
4710 }
4711 if (fc->ready) {
4712 if (more_to_do) {
4713 callout_reset(&fc->gdt, hz, isp_gdt, fc);
4714 } else {
4715 callout_deactivate(&fc->gdt);
4716 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Stopping Gone Device Timer @ %lu", chan, (unsigned long) time_uptime);
4717 }

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

4737
4738static void
4739isp_ldt_task(void *arg, int pending)
4740{
4741 struct isp_fc *fc = arg;
4742 ispsoftc_t *isp = fc->isp;
4743 int chan = fc - isp->isp_osinfo.pc.fc;
4744 fcportdb_t *lp;
4745 int dbidx, i;
4746
4747 ISP_LOCK(isp);
4748 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, "Chan %d Loop Down Timer expired @ %lu", chan, (unsigned long) time_uptime);
4749 callout_deactivate(&fc->ldt);
4750
4751 /*
4752 * Notify to the OS all targets who we now consider have departed.
4753 */

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

4770 struct ccb_scsiio *xs;
4771
4772 if (!ISP_VALID_HANDLE(isp, isp->isp_xflist[i].handle)) {
4773 continue;
4774 }
4775 if ((xs = isp->isp_xflist[i].cmd) == NULL) {
4776 continue;
4777 }
4778 if (dbidx != XS_TGT(xs)) {
4779 continue;
4780 }
4781 isp_prt(isp, ISP_LOGWARN, "command handle 0x%x for %d.%d.%d orphaned by loop down timeout",
4782 isp->isp_xflist[i].handle, chan, XS_TGT(xs), XS_LUN(xs));
4783 }
4784
4785 /*
4786 * Mark that we've announced that this device is gone....
4787 */
4788 lp->announced = 1;
4789 lp->dev_map_idx = 0;
4790 lp->state = FC_PORTDB_STATE_NIL;
4791 isp_prt(isp, ISP_LOGCONFIG, prom3, chan, lp->portid, dbidx, "Loop Down Timeout");
4792 isp_make_gone(isp, lp, chan, dbidx);
4793 }
4794
4795 if (FCPARAM(isp, chan)->role & ISP_ROLE_INITIATOR) {
4796 isp_unfreeze_loopdown(isp, chan);
4797 }
4798 /*
4799 * The loop down timer has expired. Wake up the kthread
4800 * to notice that fact (or make it false).

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

5280 case XPT_GET_TRAN_SETTINGS:
5281 cts = &ccb->cts;
5282 tgt = cts->ccb_h.target_id;
5283 bus = cam_sim_bus(xpt_path_sim(cts->ccb_h.path));
5284 if (IS_FC(isp)) {
5285 fcparam *fcp = FCPARAM(isp, bus);
5286 struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi;
5287 struct ccb_trans_settings_fc *fc = &cts->xport_specific.fc;
5288
5289 cts->protocol = PROTO_SCSI;
5290 cts->protocol_version = SCSI_REV_2;
5291 cts->transport = XPORT_FC;
5292 cts->transport_version = 0;
5293
5294 scsi->valid = CTS_SCSI_VALID_TQ;
5295 scsi->flags = CTS_SCSI_FLAGS_TAG_ENB;
5296 fc->valid = CTS_FC_VALID_SPEED;
5297 fc->bitrate = 100000;
5298 fc->bitrate *= fcp->isp_gbspeed;
5299 if (tgt < MAX_FC_TARG) {
5300 fcportdb_t *lp = &fcp->portdb[tgt];
5301 fc->wwnn = lp->node_wwn;
5302 fc->wwpn = lp->port_wwn;
5303 fc->port = lp->portid;
5304 fc->valid |= CTS_FC_VALID_WWNN | CTS_FC_VALID_WWPN | CTS_FC_VALID_PORT;
5305 }
5306 } else {
5307 struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi;
5308 struct ccb_trans_settings_spi *spi = &cts->xport_specific.spi;

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

5613 sccb->ccb_h.status &= ~CAM_SIM_QUEUED;
5614 status = sccb->ccb_h.status & CAM_STATUS_MASK;
5615 if (status != CAM_REQ_CMP) {
5616 if (status != CAM_SEL_TIMEOUT)
5617 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);
5618 else if ((IS_FC(isp))
5619 && (XS_TGT(sccb) < MAX_FC_TARG)) {
5620 fcparam *fcp;
5621
5622 fcp = FCPARAM(isp, XS_CHANNEL(sccb));
5623 fcp->portdb[XS_TGT(sccb)].reported_gone = 1;
5624 }
5625 if ((sccb->ccb_h.status & CAM_DEV_QFRZN) == 0) {
5626 sccb->ccb_h.status |= CAM_DEV_QFRZN;
5627 xpt_freeze_devq(sccb->ccb_h.path, 1);
5628 }
5629 }
5630
5631 if ((CAM_DEBUGGED(sccb->ccb_h.path, ISPDDB)) && (sccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {

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

5784 va_start(ap, cmd);
5785 bus = va_arg(ap, int);
5786 lp = va_arg(ap, fcportdb_t *);
5787 va_end(ap);
5788 fc = ISP_FC_PC(isp, bus);
5789 lp->announced = 0;
5790 lp->gone_timer = 0;
5791 if ((FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) && (lp->prli_word3 & PRLI_WD3_TARGET_FUNCTION)) {
5792 lp->dev_map_idx = (lp - FCPARAM(isp, bus)->portdb) + 1;
5793 }
5794 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5795 if (lp->dev_map_idx) {
5796 tgt = lp->dev_map_idx - 1;
5797 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);
5798 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5799 isp_make_here(isp, lp, bus, tgt);
5800 } else {

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

5808 va_end(ap);
5809 fc = ISP_FC_PC(isp, bus);
5810 lp->announced = 0;
5811 lp->gone_timer = 0;
5812 if (isp_change_is_bad) {
5813 lp->state = FC_PORTDB_STATE_NIL;
5814 if (lp->dev_map_idx) {
5815 tgt = lp->dev_map_idx - 1;
5816 lp->dev_map_idx = 0;
5817 isp_prt(isp, ISP_LOGCONFIG, prom3, bus, lp->portid, tgt, "change is bad");
5818 isp_make_gone(isp, lp, bus, tgt);
5819 } else {
5820 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5821 isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, buf, "changed and departed",
5822 (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5823 }
5824 } else {
5825 lp->portid = lp->new_portid;
5826 lp->prli_word3 = lp->new_prli_word3;
5827 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5828 if (lp->dev_map_idx) {
5829 tgt = lp->dev_map_idx - 1;
5830 isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, buf, "changed at", tgt,
5831 (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5832 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5833 } else {
5834 isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, buf, "changed", (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5835 }
5836 }

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

5875 * If it isn't marked that isp_gdt is going to get rid of it,
5876 * announce that it's gone.
5877 *
5878 */
5879 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5880 if (lp->dev_map_idx && lp->announced == 0 && now) {
5881 lp->announced = 1;
5882 tgt = lp->dev_map_idx - 1;
5883 lp->dev_map_idx = 0;
5884 isp_make_gone(isp, lp, bus, tgt);
5885 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);
5886 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5887 } else if (lp->dev_map_idx && lp->announced == 0) {
5888 lp->announced = 1;
5889 lp->state = FC_PORTDB_STATE_ZOMBIE;
5890 lp->gone_timer = ISP_FC_PC(isp, bus)->gone_device_time;

--- 660 unchanged lines hidden ---