Author: mjacob
Date: Tue Sep 15 02:25:03 2009
New Revision: 197214
URL: http://svn.freebsd.org/changeset/base/197214

Log:
  Accomodate old style XPT_IMMED_NOTIFY and XPT_NOTIFY_ACK so that
  we at least don't panic.
  
  We don't really support dual role mode (INITIATOR/TARGET) any more. We
  should but it's broken and will take a fair amount of effort to fix
  and correctly manage both initiator and target roles sharing the port
  database. So, for now, disallow it.

Modified:
  head/sys/dev/isp/isp.c
  head/sys/dev/isp/isp_freebsd.c

Modified: head/sys/dev/isp/isp.c
==============================================================================
--- head/sys/dev/isp/isp.c      Tue Sep 15 02:23:16 2009        (r197213)
+++ head/sys/dev/isp/isp.c      Tue Sep 15 02:25:03 2009        (r197214)
@@ -2771,21 +2771,15 @@ isp_pdb_sync(ispsoftc_t *isp, int chan)
        /*
         * Make sure we're okay for doing this right now.
         */
-       if (fcp->isp_loopstate != LOOP_PDB_RCVD &&
-           fcp->isp_loopstate != LOOP_FSCAN_DONE &&
-           fcp->isp_loopstate != LOOP_LSCAN_DONE) {
-               isp_prt(isp, ISP_LOGWARN, "isp_pdb_sync: bad loopstate %d",
-                   fcp->isp_loopstate);
+       if (fcp->isp_loopstate != LOOP_PDB_RCVD && fcp->isp_loopstate != 
LOOP_FSCAN_DONE && fcp->isp_loopstate != LOOP_LSCAN_DONE) {
+               isp_prt(isp, ISP_LOGWARN, "isp_pdb_sync: bad loopstate %d", 
fcp->isp_loopstate);
                return (-1);
        }
 
-       if (fcp->isp_topo == TOPO_FL_PORT ||
-           fcp->isp_topo == TOPO_NL_PORT ||
-           fcp->isp_topo == TOPO_N_PORT) {
+       if (fcp->isp_topo == TOPO_FL_PORT || fcp->isp_topo == TOPO_NL_PORT || 
fcp->isp_topo == TOPO_N_PORT) {
                if (fcp->isp_loopstate < LOOP_LSCAN_DONE) {
                        if (isp_scan_loop(isp, chan) != 0) {
-                               isp_prt(isp, ISP_LOGWARN,
-                                   "isp_pdb_sync: isp_scan_loop failed");
+                               isp_prt(isp, ISP_LOGWARN, "isp_pdb_sync: 
isp_scan_loop failed");
                                return (-1);
                        }
                }
@@ -2794,15 +2788,13 @@ isp_pdb_sync(ispsoftc_t *isp, int chan)
        if (fcp->isp_topo == TOPO_F_PORT || fcp->isp_topo == TOPO_FL_PORT) {
                if (fcp->isp_loopstate < LOOP_FSCAN_DONE) {
                        if (isp_scan_fabric(isp, chan) != 0) {
-                               isp_prt(isp, ISP_LOGWARN,
-                                   "isp_pdb_sync: isp_scan_fabric failed");
+                               isp_prt(isp, ISP_LOGWARN, "isp_pdb_sync: 
isp_scan_fabric failed");
                                return (-1);
                        }
                }
        }
 
-       isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
-           "Chan %d Synchronizing PDBs", chan);
+       isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d Synchronizing PDBs", 
chan);
 
        fcp->isp_loopstate = LOOP_SYNCING_PDB;
 
@@ -2831,11 +2823,7 @@ isp_pdb_sync(ispsoftc_t *isp, int chan)
                        lp->state = FC_PORTDB_STATE_NIL;
                        isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
                        if (lp->autologin == 0) {
-                               (void) isp_plogx(isp, chan, lp->handle,
-                                   lp->portid,
-                                   PLOGX_FLG_CMD_LOGO |
-                                   PLOGX_FLG_IMPLICIT |
-                                   PLOGX_FLG_FREE_NPHDL, 0);
+                               (void) isp_plogx(isp, chan, lp->handle, 
lp->portid, PLOGX_FLG_CMD_LOGO | PLOGX_FLG_IMPLICIT | PLOGX_FLG_FREE_NPHDL, 0);
                        } else {
                                lp->autologin = 0;
                        }
@@ -3081,8 +3069,7 @@ isp_scan_loop(ispsoftc_t *isp, int chan)
                for (i = 0; i < MAX_FC_TARG; i++) {
                        lp = &fcp->portdb[i];
 
-                       if (lp->state == FC_PORTDB_STATE_NIL ||
-                           lp->target_mode) {
+                       if (lp->state == FC_PORTDB_STATE_NIL || 
lp->target_mode) {
                                continue;
                        }
                        if (lp->node_wwn != tmp.node_wwn) {
@@ -3600,8 +3587,7 @@ isp_scan_fabric(ispsoftc_t *isp, int cha
                for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
                        lp = &fcp->portdb[dbidx];
 
-                       if (lp->state != FC_PORTDB_STATE_PROBATIONAL ||
-                           lp->target_mode) {
+                       if (lp->state != FC_PORTDB_STATE_PROBATIONAL || 
lp->target_mode) {
                                continue;
                        }
                        if (lp->portid == portid) {
@@ -3838,8 +3824,7 @@ isp_scan_fabric(ispsoftc_t *isp, int cha
                        if (fcp->portdb[dbidx].target_mode) {
                                continue;
                        }
-                       if (fcp->portdb[dbidx].node_wwn == wwnn &&
-                           fcp->portdb[dbidx].port_wwn == wwpn) {
+                       if (fcp->portdb[dbidx].node_wwn == wwnn && 
fcp->portdb[dbidx].port_wwn == wwpn) {
                                break;
                        }
                }

Modified: head/sys/dev/isp/isp_freebsd.c
==============================================================================
--- head/sys/dev/isp/isp_freebsd.c      Tue Sep 15 02:23:16 2009        
(r197213)
+++ head/sys/dev/isp/isp_freebsd.c      Tue Sep 15 02:25:03 2009        
(r197214)
@@ -343,6 +343,17 @@ ispioctl(struct cdev *dev, u_long c, cad
                        break;
                }
                if (IS_FC(isp)) {
+                       /*
+                        * We don't really support dual role at present on FC 
cards.
+                        *
+                        * We should, but a bunch of things are currently 
broken,
+                        * so don't allow it.
+                        */
+                       if (nr == ISP_ROLE_BOTH) {
+                               isp_prt(isp, ISP_LOGERR, "cannot support dual 
role at present");
+                               retval = EINVAL;
+                               break;
+                       }
                        *(int *)addr = FCPARAM(isp, chan)->role;
 #ifdef ISP_INTERNAL_TARGET
                        ISP_LOCK(isp);
@@ -2943,8 +2954,8 @@ isp_target_mark_aborted_early(ispsoftc_t
 
 #ifdef ISP_INTERNAL_TARGET
 // #define     ISP_FORCE_TIMEOUT               1
-#define        ISP_TEST_WWNS                   1
-#define        ISP_TEST_SEPARATE_STATUS        1
+// #define     ISP_TEST_WWNS                   1
+// #define     ISP_TEST_SEPARATE_STATUS        1
 
 #define        ccb_data_offset         ppriv_field0
 #define        ccb_atio                ppriv_ptr1
@@ -4238,6 +4249,7 @@ isp_action(struct cam_sim *sim, union cc
                        isp_disable_lun(isp, ccb);
                }
                break;
+       case XPT_IMMED_NOTIFY:
        case XPT_IMMEDIATE_NOTIFY:      /* Add Immediate Notify Resource */
        case XPT_ACCEPT_TARGET_IO:      /* Add Accept Target IO Resource */
        {
@@ -4287,11 +4299,19 @@ isp_action(struct cam_sim *sim, union cc
                        SLIST_INSERT_HEAD(&tptr->inots, &ccb->ccb_h, 
sim_links.sle);
                        ISP_PATH_PRT(isp, ISP_LOGTDEBUG0, ccb->ccb_h.path, "Put 
FREE INOT, (seq id 0x%x) count now %d\n",
                            ((struct ccb_immediate_notify *)ccb)->seq_id, 
tptr->inot_count);
+               } else if (ccb->ccb_h.func_code == XPT_IMMED_NOTIFY) {
+                       tptr->inot_count++;
+                       SLIST_INSERT_HEAD(&tptr->inots, &ccb->ccb_h, 
sim_links.sle);
+                       ISP_PATH_PRT(isp, ISP_LOGTDEBUG0, ccb->ccb_h.path, "Put 
FREE INOT, (seq id 0x%x) count now %d\n",
+                           ((struct ccb_immediate_notify *)ccb)->seq_id, 
tptr->inot_count);
                }
                rls_lun_statep(isp, tptr);
                ccb->ccb_h.status = CAM_REQ_INPROG;
                break;
        }
+       case XPT_NOTIFY_ACK:
+               ccb->ccb_h.status = CAM_REQ_CMP_ERR;
+               break;
        case XPT_NOTIFY_ACKNOWLEDGE:            /* notify ack */
        {
                tstate_t *tptr;
@@ -4601,10 +4621,21 @@ isp_prt(isp, ISP_LOGALL, "Setting Channe
                                }
                                break;
                        case KNOB_ROLE_BOTH:
+#if 0
                                if (fcp->role != ISP_ROLE_BOTH) {
                                        rchange = 1;
                                        newrole = ISP_ROLE_BOTH;
                                }
+#else
+                               /*
+                                * We don't really support dual role at present 
on FC cards.
+                                *
+                                * We should, but a bunch of things are 
currently broken,
+                                * so don't allow it.
+                                */
+                               isp_prt(isp, ISP_LOGERR, "cannot support dual 
role at present");
+                               ccb->ccb_h.status = CAM_REQ_INVALID;
+#endif
                                break;
                        }
                        if (rchange) {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to