Deleted Added
full compact
isp_freebsd.c (205698) isp_freebsd.c (208119)
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 205698 2010-03-26 15:13:31Z mjacob $");
31__FBSDID("$FreeBSD: head/sys/dev/isp/isp_freebsd.c 208119 2010-05-15 20:26:10Z mjacob $");
32#include <dev/isp/isp_freebsd.h>
33#include <sys/unistd.h>
34#include <sys/kthread.h>
35#include <sys/conf.h>
36#include <sys/module.h>
37#include <sys/ioccom.h>
38#include <dev/isp/isp_ioctl.h>
39#include <sys/devicestat.h>

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

44#define THREAD_CREATE kthread_create
45#else
46#define THREAD_CREATE kproc_create
47#endif
48
49MODULE_VERSION(isp, 1);
50MODULE_DEPEND(isp, cam, 1, 1, 1);
51int isp_announced = 0;
32#include <dev/isp/isp_freebsd.h>
33#include <sys/unistd.h>
34#include <sys/kthread.h>
35#include <sys/conf.h>
36#include <sys/module.h>
37#include <sys/ioccom.h>
38#include <dev/isp/isp_ioctl.h>
39#include <sys/devicestat.h>

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

44#define THREAD_CREATE kthread_create
45#else
46#define THREAD_CREATE kproc_create
47#endif
48
49MODULE_VERSION(isp, 1);
50MODULE_DEPEND(isp, cam, 1, 1, 1);
51int isp_announced = 0;
52int isp_fabric_hysteresis = 3;
52int isp_fabric_hysteresis = 5;
53int isp_loop_down_limit = 60; /* default loop down limit */
54int isp_change_is_bad = 0; /* "changed" devices are bad */
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 */
58static const char *roles[4] = {
59 "(none)", "Target", "Initiator", "Target/Initiator"
60};

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

136 fcparam *fcp = FCPARAM(isp, chan);
137 struct isp_fc *fc = ISP_FC_PC(isp, chan);
138
139 ISP_LOCK(isp);
140 fc->sim = sim;
141 fc->path = path;
142 fc->isp = isp;
143 fc->ready = 1;
53int isp_loop_down_limit = 60; /* default loop down limit */
54int isp_change_is_bad = 0; /* "changed" devices are bad */
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 */
58static const char *roles[4] = {
59 "(none)", "Target", "Initiator", "Target/Initiator"
60};

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

136 fcparam *fcp = FCPARAM(isp, chan);
137 struct isp_fc *fc = ISP_FC_PC(isp, chan);
138
139 ISP_LOCK(isp);
140 fc->sim = sim;
141 fc->path = path;
142 fc->isp = isp;
143 fc->ready = 1;
144
144 fc->gone_device_time = isp_gone_device_time;
145 fc->loop_down_limit = isp_loop_down_limit;
146 fc->hysteresis = isp_fabric_hysteresis;
145 callout_init_mtx(&fc->ldt, &isp->isp_osinfo.lock, 0);
146 callout_init_mtx(&fc->gdt, &isp->isp_osinfo.lock, 0);
147 callout_init_mtx(&fc->ldt, &isp->isp_osinfo.lock, 0);
148 callout_init_mtx(&fc->gdt, &isp->isp_osinfo.lock, 0);
149
147 /*
148 * We start by being "loop down" if we have an initiator role
149 */
150 if (fcp->role & ISP_ROLE_INITIATOR) {
151 isp_freeze_loopdown(isp, chan, "isp_attach");
152 callout_reset(&fc->ldt, isp_quickboot_time * hz, isp_ldt, fc);
153 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Starting Initial Loop Down Timer @ %lu", (unsigned long) time_uptime);
154 }

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

3935isp_gdt(void *arg)
3936{
3937 struct isp_fc *fc = arg;
3938 ispsoftc_t *isp = fc->isp;
3939 int chan = fc - isp->isp_osinfo.pc.fc;
3940 fcportdb_t *lp;
3941 int dbidx, tgt, more_to_do = 0;
3942
150 /*
151 * We start by being "loop down" if we have an initiator role
152 */
153 if (fcp->role & ISP_ROLE_INITIATOR) {
154 isp_freeze_loopdown(isp, chan, "isp_attach");
155 callout_reset(&fc->ldt, isp_quickboot_time * hz, isp_ldt, fc);
156 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Starting Initial Loop Down Timer @ %lu", (unsigned long) time_uptime);
157 }

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

3938isp_gdt(void *arg)
3939{
3940 struct isp_fc *fc = arg;
3941 ispsoftc_t *isp = fc->isp;
3942 int chan = fc - isp->isp_osinfo.pc.fc;
3943 fcportdb_t *lp;
3944 int dbidx, tgt, more_to_do = 0;
3945
3943 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d GDT timer expired", chan);
3946 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d GDT timer expired @ %lu", chan, time_uptime);
3944 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3945 lp = &FCPARAM(isp, chan)->portdb[dbidx];
3946
3947 if (lp->state != FC_PORTDB_STATE_ZOMBIE) {
3948 continue;
3949 }
3950 if (lp->dev_map_idx == 0 || lp->target_mode) {
3951 continue;
3952 }
3947 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3948 lp = &FCPARAM(isp, chan)->portdb[dbidx];
3949
3950 if (lp->state != FC_PORTDB_STATE_ZOMBIE) {
3951 continue;
3952 }
3953 if (lp->dev_map_idx == 0 || lp->target_mode) {
3954 continue;
3955 }
3953 /*
3954 * We can use new_portid here because it is untouched
3955 * while the state is ZOMBIE
3956 */
3957 if (lp->new_portid == 0) {
3958 continue;
3959 }
3960 lp->new_portid -= 1;
3961 if (lp->new_portid != 0) {
3956 if (lp->gone_timer != 0) {
3957 lp->gone_timer -= 1;
3962 more_to_do++;
3963 continue;
3964 }
3965 tgt = lp->dev_map_idx - 1;
3966 FCPARAM(isp, chan)->isp_dev_map[tgt] = 0;
3967 lp->dev_map_idx = 0;
3968 lp->state = FC_PORTDB_STATE_NIL;
3969 isp_prt(isp, ISP_LOGCONFIG, prom3, chan, lp->portid, tgt, "Gone Device Timeout");
3970 isp_make_gone(isp, chan, tgt);
3971 }
3972 if (fc->ready) {
3973 if (more_to_do) {
3974 callout_reset(&fc->gdt, hz, isp_gdt, fc);
3975 } else {
3958 more_to_do++;
3959 continue;
3960 }
3961 tgt = lp->dev_map_idx - 1;
3962 FCPARAM(isp, chan)->isp_dev_map[tgt] = 0;
3963 lp->dev_map_idx = 0;
3964 lp->state = FC_PORTDB_STATE_NIL;
3965 isp_prt(isp, ISP_LOGCONFIG, prom3, chan, lp->portid, tgt, "Gone Device Timeout");
3966 isp_make_gone(isp, chan, tgt);
3967 }
3968 if (fc->ready) {
3969 if (more_to_do) {
3970 callout_reset(&fc->gdt, hz, isp_gdt, fc);
3971 } else {
3976 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d stopping Gone Device Timer", chan);
3972 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d Stopping Gone Device Timer", chan);
3977 }
3978 }
3979}
3980
3981/*
3982 * Loop Down Timer Function- when loop goes down, a timer is started and
3983 * and after it expires we come here and take all probational devices that
3984 * the OS knows about and the tell the OS that they've gone away.

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

4937 * We don't do any simq freezing if we are only in target mode
4938 */
4939 if (FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) {
4940 if (fc->path) {
4941 isp_freeze_loopdown(isp, bus, msg);
4942 }
4943 if (!callout_active(&fc->ldt)) {
4944 callout_reset(&fc->ldt, fc->loop_down_limit * hz, isp_ldt, fc);
3973 }
3974 }
3975}
3976
3977/*
3978 * Loop Down Timer Function- when loop goes down, a timer is started and
3979 * and after it expires we come here and take all probational devices that
3980 * the OS knows about and the tell the OS that they've gone away.

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

4933 * We don't do any simq freezing if we are only in target mode
4934 */
4935 if (FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) {
4936 if (fc->path) {
4937 isp_freeze_loopdown(isp, bus, msg);
4938 }
4939 if (!callout_active(&fc->ldt)) {
4940 callout_reset(&fc->ldt, fc->loop_down_limit * hz, isp_ldt, fc);
4945 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "starting Loop Down Timer @ %lu", (unsigned long) time_uptime);
4941 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Starting Loop Down Timer @ %lu", (unsigned long) time_uptime);
4946 }
4947 }
4948 }
4949 isp_prt(isp, ISP_LOGINFO, "Chan %d: %s", bus, msg);
4950 break;
4951 }
4952 case ISPASYNC_LOOP_UP:
4953 va_start(ap, cmd);

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

4967 break;
4968 case ISPASYNC_DEV_ARRIVED:
4969 va_start(ap, cmd);
4970 bus = va_arg(ap, int);
4971 lp = va_arg(ap, fcportdb_t *);
4972 va_end(ap);
4973 fc = ISP_FC_PC(isp, bus);
4974 lp->reserved = 0;
4942 }
4943 }
4944 }
4945 isp_prt(isp, ISP_LOGINFO, "Chan %d: %s", bus, msg);
4946 break;
4947 }
4948 case ISPASYNC_LOOP_UP:
4949 va_start(ap, cmd);

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

4963 break;
4964 case ISPASYNC_DEV_ARRIVED:
4965 va_start(ap, cmd);
4966 bus = va_arg(ap, int);
4967 lp = va_arg(ap, fcportdb_t *);
4968 va_end(ap);
4969 fc = ISP_FC_PC(isp, bus);
4970 lp->reserved = 0;
4971 lp->gone_timer = 0;
4975 if ((FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) && (lp->roles & (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT))) {
4976 int dbidx = lp - FCPARAM(isp, bus)->portdb;
4977 int i;
4978
4979 for (i = 0; i < MAX_FC_TARG; i++) {
4980 if (i >= FL_ID && i <= SNS_ID) {
4981 continue;
4982 }

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

5002 break;
5003 case ISPASYNC_DEV_CHANGED:
5004 va_start(ap, cmd);
5005 bus = va_arg(ap, int);
5006 lp = va_arg(ap, fcportdb_t *);
5007 va_end(ap);
5008 fc = ISP_FC_PC(isp, bus);
5009 lp->reserved = 0;
4972 if ((FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) && (lp->roles & (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT))) {
4973 int dbidx = lp - FCPARAM(isp, bus)->portdb;
4974 int i;
4975
4976 for (i = 0; i < MAX_FC_TARG; i++) {
4977 if (i >= FL_ID && i <= SNS_ID) {
4978 continue;
4979 }

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

4999 break;
5000 case ISPASYNC_DEV_CHANGED:
5001 va_start(ap, cmd);
5002 bus = va_arg(ap, int);
5003 lp = va_arg(ap, fcportdb_t *);
5004 va_end(ap);
5005 fc = ISP_FC_PC(isp, bus);
5006 lp->reserved = 0;
5007 lp->gone_timer = 0;
5010 if (isp_change_is_bad) {
5011 lp->state = FC_PORTDB_STATE_NIL;
5012 if (lp->dev_map_idx) {
5013 tgt = lp->dev_map_idx - 1;
5014 FCPARAM(isp, bus)->isp_dev_map[tgt] = 0;
5015 lp->dev_map_idx = 0;
5016 isp_prt(isp, ISP_LOGCONFIG, prom3, bus, lp->portid, tgt, "change is bad");
5017 isp_make_gone(isp, bus, tgt);

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

5056 /*
5057 * If this has a virtual target and we haven't marked it
5058 * that we're going to have isp_gdt tell the OS it's gone,
5059 * set the isp_gdt timer running on it.
5060 *
5061 * If it isn't marked that isp_gdt is going to get rid of it,
5062 * announce that it's gone.
5063 *
5008 if (isp_change_is_bad) {
5009 lp->state = FC_PORTDB_STATE_NIL;
5010 if (lp->dev_map_idx) {
5011 tgt = lp->dev_map_idx - 1;
5012 FCPARAM(isp, bus)->isp_dev_map[tgt] = 0;
5013 lp->dev_map_idx = 0;
5014 isp_prt(isp, ISP_LOGCONFIG, prom3, bus, lp->portid, tgt, "change is bad");
5015 isp_make_gone(isp, bus, tgt);

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

5054 /*
5055 * If this has a virtual target and we haven't marked it
5056 * that we're going to have isp_gdt tell the OS it's gone,
5057 * set the isp_gdt timer running on it.
5058 *
5059 * If it isn't marked that isp_gdt is going to get rid of it,
5060 * announce that it's gone.
5061 *
5064 * We can use new_portid for the gone timer because it's
5065 * undefined while the state is ZOMBIE.
5066 */
5067 if (lp->dev_map_idx && lp->reserved == 0) {
5068 lp->reserved = 1;
5062 */
5063 if (lp->dev_map_idx && lp->reserved == 0) {
5064 lp->reserved = 1;
5069 lp->new_portid = ISP_FC_PC(isp, bus)->gone_device_time;
5070 lp->state = FC_PORTDB_STATE_ZOMBIE;
5065 lp->state = FC_PORTDB_STATE_ZOMBIE;
5066 lp->gone_timer = ISP_FC_PC(isp, bus)->gone_device_time;
5071 if (fc->ready && !callout_active(&fc->gdt)) {
5067 if (fc->ready && !callout_active(&fc->gdt)) {
5072 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d starting Gone Device Timer", bus);
5068 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d Starting Gone Device Timer with %u seconds time now %lu", bus, lp->gone_timer, time_uptime);
5073 callout_reset(&fc->gdt, hz, isp_gdt, fc);
5074 }
5075 tgt = lp->dev_map_idx - 1;
5076 isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, roles[lp->roles], "gone zombie at", tgt, (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5077 } else if (lp->reserved == 0) {
5078 isp_prt(isp, ISP_LOGCONFIG, prom, bus, lp->portid, lp->handle, roles[lp->roles], "departed", (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5079 }
5080 break;

--- 526 unchanged lines hidden ---
5069 callout_reset(&fc->gdt, hz, isp_gdt, fc);
5070 }
5071 tgt = lp->dev_map_idx - 1;
5072 isp_prt(isp, ISP_LOGCONFIG, prom2, bus, lp->portid, lp->handle, roles[lp->roles], "gone zombie at", tgt, (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5073 } else if (lp->reserved == 0) {
5074 isp_prt(isp, ISP_LOGCONFIG, prom, bus, lp->portid, lp->handle, roles[lp->roles], "departed", (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5075 }
5076 break;

--- 526 unchanged lines hidden ---