Deleted Added
sdiff udiff text old ( 284748 ) new ( 285146 )
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 285146 2015-07-04 18:38: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>

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

110
111 /* We don't allow target mode switch from here. */
112 if ((value ^ old) & ISP_ROLE_TARGET) {
113 ISP_UNLOCK(isp);
114 return (EPERM);
115 }
116
117 /* Actually change the role. */
118 error = isp_control(isp, ISPCTL_CHANGE_ROLE, chan, value);
119 ISP_UNLOCK(isp);
120 return (error);
121}
122
123static int
124isp_attach_chan(ispsoftc_t *isp, struct cam_devq *devq, int chan)
125{
126 struct ccb_setasync csa;

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

469 * We should, but a bunch of things are currently broken,
470 * so don't allow it.
471 */
472 if (nr == ISP_ROLE_BOTH) {
473 isp_prt(isp, ISP_LOGERR, "cannot support dual role at present");
474 retval = EINVAL;
475 break;
476 }
477 ISP_LOCK(isp);
478 *(int *)addr = FCPARAM(isp, chan)->role;
479 } else {
480 ISP_LOCK(isp);
481 *(int *)addr = SDPARAM(isp, chan)->role;
482 }
483 retval = isp_control(isp, ISPCTL_CHANGE_ROLE, chan, nr);
484 ISP_UNLOCK(isp);
485 retval = 0;
486 break;
487
488 case ISP_RESETHBA:
489 ISP_LOCK(isp);
490#ifdef ISP_TARGET_MODE
491 isp_del_all_wwn_entries(isp, ISP_NOCHAN);
492#endif

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

5469 break;
5470 }
5471 if (rchange) {
5472 ISP_PATH_PRT(isp, ISP_LOGCONFIG, ccb->ccb_h.path, "changing role on from %d to %d\n", fcp->role, newrole);
5473#ifdef ISP_TARGET_MODE
5474 ISP_SET_PC(isp, bus, tm_enabled, 0);
5475 ISP_SET_PC(isp, bus, tm_luns_enabled, 0);
5476#endif
5477 if (isp_control(isp, ISPCTL_CHANGE_ROLE,
5478 bus, newrole) != 0) {
5479 ccb->ccb_h.status = CAM_REQ_CMP_ERR;
5480 xpt_done(ccb);
5481 break;
5482 }
5483#ifdef ISP_TARGET_MODE
5484 if (newrole == ISP_ROLE_TARGET || newrole == ISP_ROLE_BOTH) {
5485 /*
5486 * Give the new role a chance to complain and settle

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

5660 isp_free_pcmd(isp, (union ccb *) sccb);
5661 }
5662 xpt_done((union ccb *) sccb);
5663}
5664
5665void
5666isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
5667{
5668 int bus, now;
5669 static const char prom0[] = "Chan %d PortID 0x%06x handle 0x%x %s %s WWPN 0x%08x%08x";
5670 static const char prom2[] = "Chan %d PortID 0x%06x handle 0x%x %s %s tgt %u WWPN 0x%08x%08x";
5671 char buf[64];
5672 char *msg = NULL;
5673 target_id_t tgt;
5674 fcportdb_t *lp;
5675 struct isp_fc *fc;
5676 struct cam_path *tmppath;

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

5901 isp_prt(isp, ISP_LOGCONFIG, prom0, bus, lp->portid, lp->handle, buf, "stayed",
5902 (uint32_t) (lp->port_wwn >> 32), (uint32_t) lp->port_wwn);
5903 }
5904 break;
5905 case ISPASYNC_DEV_GONE:
5906 va_start(ap, cmd);
5907 bus = va_arg(ap, int);
5908 lp = va_arg(ap, fcportdb_t *);
5909 now = va_arg(ap, int);
5910 va_end(ap);
5911 fc = ISP_FC_PC(isp, bus);
5912 /*
5913 * If this has a virtual target and we haven't marked it
5914 * that we're going to have isp_gdt tell the OS it's gone,
5915 * set the isp_gdt timer running on it.
5916 *
5917 * If it isn't marked that isp_gdt is going to get rid of it,
5918 * announce that it's gone.
5919 *
5920 */
5921 isp_gen_role_str(buf, sizeof (buf), lp->prli_word3);
5922 if (lp->dev_map_idx && lp->announced == 0 && now) {
5923 lp->announced = 1;
5924 tgt = lp->dev_map_idx - 1;
5925 FCPARAM(isp, bus)->isp_dev_map[tgt] = 0;
5926 lp->dev_map_idx = 0;
5927 isp_make_gone(isp, lp, bus, tgt);
5928 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);
5929 isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
5930 } else if (lp->dev_map_idx && lp->announced == 0) {
5931 lp->announced = 1;
5932 lp->state = FC_PORTDB_STATE_ZOMBIE;
5933 lp->gone_timer = ISP_FC_PC(isp, bus)->gone_device_time;
5934 if (fc->ready && !callout_active(&fc->gdt)) {
5935 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);
5936 callout_reset(&fc->gdt, hz, isp_gdt, fc);
5937 }
5938 tgt = lp->dev_map_idx - 1;
5939 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);

--- 654 unchanged lines hidden ---