Author: mav
Date: Thu Sep 10 10:46:21 2015
New Revision: 287620
URL: https://svnweb.freebsd.org/changeset/base/287620

Log:
  Remove unused target and initiator IDs.

Modified:
  head/sys/cam/ctl/ctl.c
  head/sys/cam/ctl/ctl_frontend.h
  head/sys/cam/ctl/ctl_frontend_cam_sim.c
  head/sys/cam/ctl/ctl_frontend_iscsi.c
  head/sys/cam/ctl/ctl_io.h
  head/sys/cam/ctl/ctl_ioctl.h
  head/sys/cam/ctl/ctl_scsi_all.c
  head/sys/cam/ctl/ctl_tpc_local.c
  head/sys/cam/ctl/ctl_util.c
  head/sys/cam/ctl/ctl_util.h
  head/sys/cam/ctl/scsi_ctl.c
  head/usr.sbin/ctladm/ctladm.8
  head/usr.sbin/ctladm/ctladm.c

Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c      Thu Sep 10 10:23:23 2015        (r287619)
+++ head/sys/cam/ctl/ctl.c      Thu Sep 10 10:46:21 2015        (r287620)
@@ -569,15 +569,14 @@ ctl_isc_handler_finish_ser_only(struct c
                printf("%s: %p use after free!\n", __func__,
                       ctsio);
                printf("%s: type %d msg %d cdb %x iptl: "
-                      "%d:%d:%d:%d tag 0x%04x "
+                      "%u:%u:%u tag 0x%04x "
                       "flag %#x status %x\n",
                        __func__,
                        tmp_io->io_hdr.io_type,
                        tmp_io->io_hdr.msg_type,
                        tmp_io->scsiio.cdb[0],
-                       tmp_io->io_hdr.nexus.initid.id,
+                       tmp_io->io_hdr.nexus.initid,
                        tmp_io->io_hdr.nexus.targ_port,
-                       tmp_io->io_hdr.nexus.targ_target.id,
                        tmp_io->io_hdr.nexus.targ_lun,
                        (tmp_io->io_hdr.io_type ==
                        CTL_IO_TASK) ?
@@ -665,10 +664,9 @@ ctl_isc_event_handler(ctl_ha_channel cha
                                io->io_hdr.flags |= CTL_FLAG_INT_COPY;
                        io->io_hdr.nexus = msg_info.hdr.nexus;
 #if 0
-                       printf("targ %d, port %d, iid %d, lun %d\n",
-                              io->io_hdr.nexus.targ_target.id,
+                       printf("port %u, iid %u, lun %u\n",
                               io->io_hdr.nexus.targ_port,
-                              io->io_hdr.nexus.initid.id,
+                              io->io_hdr.nexus.initid,
                               io->io_hdr.nexus.targ_lun);
 #endif
                        io->scsiio.tag_num = msg_info.scsi.tag_num;
@@ -3068,10 +3066,10 @@ uint32_t
 ctl_get_initindex(struct ctl_nexus *nexus)
 {
        if (nexus->targ_port < CTL_MAX_PORTS)
-               return (nexus->initid.id +
+               return (nexus->initid +
                        (nexus->targ_port * CTL_MAX_INIT_PER_PORT));
        else
-               return (nexus->initid.id +
+               return (nexus->initid +
                       ((nexus->targ_port - CTL_MAX_PORTS) *
                        CTL_MAX_INIT_PER_PORT));
 }
@@ -3079,7 +3077,7 @@ ctl_get_initindex(struct ctl_nexus *nexu
 uint32_t
 ctl_get_resindex(struct ctl_nexus *nexus)
 {
-       return (nexus->initid.id + (nexus->targ_port * CTL_MAX_INIT_PER_PORT));
+       return (nexus->initid + (nexus->targ_port * CTL_MAX_INIT_PER_PORT));
 }
 
 uint32_t
@@ -10432,8 +10430,8 @@ ctl_check_for_blockage(struct ctl_lun *l
         && (ooa_io->scsiio.tag_type == CTL_TAG_UNTAGGED)
         && ((pending_io->io_hdr.nexus.targ_port ==
              ooa_io->io_hdr.nexus.targ_port)
-         && (pending_io->io_hdr.nexus.initid.id ==
-             ooa_io->io_hdr.nexus.initid.id))
+         && (pending_io->io_hdr.nexus.initid ==
+             ooa_io->io_hdr.nexus.initid))
         && ((ooa_io->io_hdr.flags & (CTL_FLAG_ABORT |
              CTL_FLAG_STATUS_SENT)) == 0))
                return (CTL_ACTION_OVERLAP);
@@ -10454,8 +10452,8 @@ ctl_check_for_blockage(struct ctl_lun *l
         && (pending_io->scsiio.tag_num == ooa_io->scsiio.tag_num)
         && ((pending_io->io_hdr.nexus.targ_port ==
              ooa_io->io_hdr.nexus.targ_port)
-         && (pending_io->io_hdr.nexus.initid.id ==
-             ooa_io->io_hdr.nexus.initid.id))
+         && (pending_io->io_hdr.nexus.initid ==
+             ooa_io->io_hdr.nexus.initid))
         && ((ooa_io->io_hdr.flags & (CTL_FLAG_ABORT |
              CTL_FLAG_STATUS_SENT)) == 0))
                return (CTL_ACTION_OVERLAP_TAG);
@@ -11569,9 +11567,9 @@ ctl_abort_tasks_lun(struct ctl_lun *lun,
                if ((targ_port == UINT32_MAX ||
                     targ_port == xio->io_hdr.nexus.targ_port) &&
                    (init_id == UINT32_MAX ||
-                    init_id == xio->io_hdr.nexus.initid.id)) {
+                    init_id == xio->io_hdr.nexus.initid)) {
                        if (targ_port != xio->io_hdr.nexus.targ_port ||
-                           init_id != xio->io_hdr.nexus.initid.id)
+                           init_id != xio->io_hdr.nexus.initid)
                                xio->io_hdr.flags |= CTL_FLAG_ABORT_STATUS;
                        xio->io_hdr.flags |= CTL_FLAG_ABORT;
                        if (!other_sc && !(lun->flags & CTL_LUN_PRIMARY_SC)) {
@@ -11614,7 +11612,7 @@ ctl_abort_task_set(union ctl_io *io)
        mtx_unlock(&softc->ctl_lock);
        if (io->taskio.task_action == CTL_TASK_ABORT_TASK_SET) {
                ctl_abort_tasks_lun(lun, io->io_hdr.nexus.targ_port,
-                   io->io_hdr.nexus.initid.id,
+                   io->io_hdr.nexus.initid,
                    (io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) != 0);
        } else { /* CTL_TASK_CLEAR_TASK_SET */
                ctl_abort_tasks_lun(lun, UINT32_MAX, UINT32_MAX,
@@ -11637,7 +11635,7 @@ ctl_i_t_nexus_reset(union ctl_io *io)
        STAILQ_FOREACH(lun, &softc->lun_list, links) {
                mtx_lock(&lun->lun_lock);
                ctl_abort_tasks_lun(lun, io->io_hdr.nexus.targ_port,
-                   io->io_hdr.nexus.initid.id,
+                   io->io_hdr.nexus.initid,
                    (io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) != 0);
 #ifdef CTL_WITH_CA
                ctl_clear_mask(lun->have_ca, initidx);
@@ -11716,7 +11714,7 @@ ctl_abort_task(union ctl_io *io)
 #endif
 
                if ((xio->io_hdr.nexus.targ_port != io->io_hdr.nexus.targ_port)
-                || (xio->io_hdr.nexus.initid.id != io->io_hdr.nexus.initid.id)
+                || (xio->io_hdr.nexus.initid != io->io_hdr.nexus.initid)
                 || (xio->io_hdr.flags & CTL_FLAG_ABORT))
                        continue;
 
@@ -11778,10 +11776,9 @@ ctl_abort_task(union ctl_io *io)
                 */
 #if 0
                printf("ctl_abort_task: ABORT sent for nonexistent I/O: "
-                      "%d:%d:%d:%d tag %d type %d\n",
-                      io->io_hdr.nexus.initid.id,
+                      "%u:%u:%u tag %d type %d\n",
+                      io->io_hdr.nexus.initid,
                       io->io_hdr.nexus.targ_port,
-                      io->io_hdr.nexus.targ_target.id,
                       io->io_hdr.nexus.targ_lun, io->taskio.tag_num,
                       io->taskio.tag_type);
 #endif
@@ -12208,10 +12205,9 @@ ctl_datamove(union ctl_io *io)
         * the data move.
         */
        if (io->io_hdr.flags & CTL_FLAG_ABORT) {
-               printf("ctl_datamove: tag 0x%04x on (%ju:%d:%ju:%d) aborted\n",
-                      io->scsiio.tag_num,(uintmax_t)io->io_hdr.nexus.initid.id,
+               printf("ctl_datamove: tag 0x%04x on (%u:%u:%u) aborted\n",
+                      io->scsiio.tag_num, io->io_hdr.nexus.initid,
                       io->io_hdr.nexus.targ_port,
-                      (uintmax_t)io->io_hdr.nexus.targ_target.id,
                       io->io_hdr.nexus.targ_lun);
                io->io_hdr.port_status = 31337;
                /*
@@ -12979,10 +12975,9 @@ ctl_datamove_remote(union ctl_io *io)
         * have been done if need be on the other controller.
         */
        if (io->io_hdr.flags & CTL_FLAG_ABORT) {
-               printf("%s: tag 0x%04x on (%d:%d:%d:%d) aborted\n", __func__,
-                      io->scsiio.tag_num, io->io_hdr.nexus.initid.id,
+               printf("%s: tag 0x%04x on (%u:%u:%u) aborted\n", __func__,
+                      io->scsiio.tag_num, io->io_hdr.nexus.initid,
                       io->io_hdr.nexus.targ_port,
-                      io->io_hdr.nexus.targ_target.id,
                       io->io_hdr.nexus.targ_lun);
                io->io_hdr.port_status = 31338;
                ctl_send_datamove_done(io, /*have_lock*/ 0);
@@ -13377,15 +13372,14 @@ ctl_done(union ctl_io *io)
 #if 0
        if (io->io_hdr.flags & CTL_FLAG_ALREADY_DONE) {
                printf("%s: type %d msg %d cdb %x iptl: "
-                      "%d:%d:%d:%d tag 0x%04x "
+                      "%u:%u:%u tag 0x%04x "
                       "flag %#x status %x\n",
                        __func__,
                        io->io_hdr.io_type,
                        io->io_hdr.msg_type,
                        io->scsiio.cdb[0],
-                       io->io_hdr.nexus.initid.id,
+                       io->io_hdr.nexus.initid,
                        io->io_hdr.nexus.targ_port,
-                       io->io_hdr.nexus.targ_target.id,
                        io->io_hdr.nexus.targ_lun,
                        (io->io_hdr.io_type ==
                        CTL_IO_TASK) ?
@@ -13649,7 +13643,7 @@ ctl_enqueue_incoming(union ctl_io *io)
        u_int idx;
 
        idx = (io->io_hdr.nexus.targ_port * 127 +
-              io->io_hdr.nexus.initid.id) % worker_threads;
+              io->io_hdr.nexus.initid) % worker_threads;
        thr = &softc->threads[idx];
        mtx_lock(&thr->queue_lock);
        STAILQ_INSERT_TAIL(&thr->incoming_queue, &io->io_hdr, links);

Modified: head/sys/cam/ctl/ctl_frontend.h
==============================================================================
--- head/sys/cam/ctl/ctl_frontend.h     Thu Sep 10 10:23:23 2015        
(r287619)
+++ head/sys/cam/ctl/ctl_frontend.h     Thu Sep 10 10:46:21 2015        
(r287620)
@@ -125,12 +125,12 @@ struct ctl_wwpn_iid {
  * port_online():        This function is called, with onoff_arg as its
  *                       argument, by the CTL layer when it wants the FETD
  *                       to start responding to selections on the specified
- *                       target ID.  (targ_target)
+ *                       target ID.
  *
  * port_offline():       This function is called, with onoff_arg as its
  *                       argument, by the CTL layer when it wants the FETD
  *                       to stop responding to selection on the specified
- *                       target ID.  (targ_target)
+ *                       target ID.
  *
  * onoff_arg:            This is supplied as an argument to port_online()
  *                       and port_offline().  This is specified by the

Modified: head/sys/cam/ctl/ctl_frontend_cam_sim.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend_cam_sim.c     Thu Sep 10 10:23:23 2015        
(r287619)
+++ head/sys/cam/ctl/ctl_frontend_cam_sim.c     Thu Sep 10 10:46:21 2015        
(r287620)
@@ -546,12 +546,8 @@ cfcs_action(struct cam_sim *sim, union c
                 * down via the XPT_RESET_BUS/LUN CCBs below.
                 */
                io->io_hdr.io_type = CTL_IO_SCSI;
-               io->io_hdr.nexus.initid.id = 1;
+               io->io_hdr.nexus.initid = 1;
                io->io_hdr.nexus.targ_port = softc->port.targ_port;
-               /*
-                * XXX KDM how do we handle target IDs?
-                */
-               io->io_hdr.nexus.targ_target.id = ccb->ccb_h.target_id;
                io->io_hdr.nexus.targ_lun = ccb->ccb_h.target_lun;
                /*
                 * This tag scheme isn't the best, since we could in theory
@@ -639,9 +635,8 @@ cfcs_action(struct cam_sim *sim, union c
                ccb->ccb_h.io_ptr = io;
 
                io->io_hdr.io_type = CTL_IO_TASK;
-               io->io_hdr.nexus.initid.id = 1;
+               io->io_hdr.nexus.initid = 1;
                io->io_hdr.nexus.targ_port = softc->port.targ_port;
-               io->io_hdr.nexus.targ_target.id = ccb->ccb_h.target_id;
                io->io_hdr.nexus.targ_lun = ccb->ccb_h.target_lun;
                io->taskio.task_action = CTL_TASK_ABORT_TASK;
                io->taskio.tag_num = abort_ccb->csio.tag_id;
@@ -735,9 +730,8 @@ cfcs_action(struct cam_sim *sim, union c
                ccb->ccb_h.io_ptr = io;
 
                io->io_hdr.io_type = CTL_IO_TASK;
-               io->io_hdr.nexus.initid.id = 0;
+               io->io_hdr.nexus.initid = 1;
                io->io_hdr.nexus.targ_port = softc->port.targ_port;
-               io->io_hdr.nexus.targ_target.id = ccb->ccb_h.target_id;
                io->io_hdr.nexus.targ_lun = ccb->ccb_h.target_lun;
                if (ccb->ccb_h.func_code == XPT_RESET_BUS)
                        io->taskio.task_action = CTL_TASK_BUS_RESET;

Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend_iscsi.c       Thu Sep 10 10:23:23 2015        
(r287619)
+++ head/sys/cam/ctl/ctl_frontend_iscsi.c       Thu Sep 10 10:46:21 2015        
(r287620)
@@ -564,9 +564,8 @@ cfiscsi_pdu_handle_scsi_command(struct i
        ctl_zero_io(io);
        io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = request;
        io->io_hdr.io_type = CTL_IO_SCSI;
-       io->io_hdr.nexus.initid.id = cs->cs_ctl_initid;
+       io->io_hdr.nexus.initid = cs->cs_ctl_initid;
        io->io_hdr.nexus.targ_port = cs->cs_target->ct_port.targ_port;
-       io->io_hdr.nexus.targ_target.id = 0;
        io->io_hdr.nexus.targ_lun = cfiscsi_decode_lun(bhssc->bhssc_lun);
        io->scsiio.tag_num = bhssc->bhssc_initiator_task_tag;
        switch ((bhssc->bhssc_flags & BHSSC_FLAGS_ATTR)) {
@@ -621,9 +620,8 @@ cfiscsi_pdu_handle_task_request(struct i
        ctl_zero_io(io);
        io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = request;
        io->io_hdr.io_type = CTL_IO_TASK;
-       io->io_hdr.nexus.initid.id = cs->cs_ctl_initid;
+       io->io_hdr.nexus.initid = cs->cs_ctl_initid;
        io->io_hdr.nexus.targ_port = cs->cs_target->ct_port.targ_port;
-       io->io_hdr.nexus.targ_target.id = 0;
        io->io_hdr.nexus.targ_lun = cfiscsi_decode_lun(bhstmr->bhstmr_lun);
        io->taskio.tag_type = CTL_TAG_SIMPLE; /* XXX */
 
@@ -1120,9 +1118,8 @@ cfiscsi_session_terminate_tasks(struct c
        ctl_zero_io(io);
        io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = cs;
        io->io_hdr.io_type = CTL_IO_TASK;
-       io->io_hdr.nexus.initid.id = cs->cs_ctl_initid;
+       io->io_hdr.nexus.initid = cs->cs_ctl_initid;
        io->io_hdr.nexus.targ_port = cs->cs_target->ct_port.targ_port;
-       io->io_hdr.nexus.targ_target.id = 0;
        io->io_hdr.nexus.targ_lun = 0;
        io->taskio.tag_type = CTL_TAG_SIMPLE; /* XXX */
        io->taskio.task_action = CTL_TASK_I_T_NEXUS_RESET;

Modified: head/sys/cam/ctl/ctl_io.h
==============================================================================
--- head/sys/cam/ctl/ctl_io.h   Thu Sep 10 10:23:23 2015        (r287619)
+++ head/sys/cam/ctl/ctl_io.h   Thu Sep 10 10:46:21 2015        (r287620)
@@ -183,11 +183,6 @@ struct ctl_sg_entry {
        size_t  len;
 };
 
-struct ctl_id {
-       uint32_t                id;
-       uint64_t                wwid[2];
-};
-
 typedef enum {
        CTL_IO_NONE,
        CTL_IO_SCSI,
@@ -195,9 +190,8 @@ typedef enum {
 } ctl_io_type;
 
 struct ctl_nexus {
-       struct ctl_id initid;           /* Initiator ID */
+       uint32_t initid;                /* Initiator ID */
        uint32_t targ_port;             /* Target port, filled in by PORT */
-       struct ctl_id targ_target;      /* Destination target */
        uint32_t targ_lun;              /* Destination lun */
        uint32_t targ_mapped_lun;       /* Destination lun CTL-wide */
 };

Modified: head/sys/cam/ctl/ctl_ioctl.h
==============================================================================
--- head/sys/cam/ctl/ctl_ioctl.h        Thu Sep 10 10:23:23 2015        
(r287619)
+++ head/sys/cam/ctl/ctl_ioctl.h        Thu Sep 10 10:46:21 2015        
(r287620)
@@ -86,7 +86,6 @@ typedef enum {
 } ctl_ooa_status;
 
 struct ctl_ooa_info {
-       uint32_t target_id;     /* Passed in to CTL */
        uint32_t lun_id;        /* Passed in to CTL */
        uint32_t num_entries;   /* Returned from CTL */
        ctl_ooa_status status;  /* Returned from CTL */
@@ -114,7 +113,6 @@ typedef enum {
 } ctl_delay_status;
 
 struct ctl_io_delay_info {
-       uint32_t                target_id;
        uint32_t                lun_id;
        ctl_delay_type          delay_type;
        ctl_delay_location      delay_loc;
@@ -133,7 +131,6 @@ typedef enum {
  * means that we will let through every N SYNCHRONIZE CACHE commands.
  */
 struct ctl_sync_info {
-       uint32_t                target_id;      /* passed to kernel */
        uint32_t                lun_id;         /* passed to kernel */
        int                     sync_interval;  /* depends on whether get/set */
        ctl_gs_sync_status      status;         /* passed from kernel */
@@ -262,7 +259,6 @@ struct ctl_error_desc_cmd {
 /*
  * Error injection descriptor.
  *
- * target_id:     Target ID to act on.
  * lun_id         LUN to act on.
  * lun_error:     The type of error to inject.  See above for descriptions.
  * error_pattern:  What kind of command to act on.  See above.
@@ -273,7 +269,6 @@ struct ctl_error_desc_cmd {
  * links:         Kernel use only.
  */
 struct ctl_error_desc {
-       uint32_t                        target_id;      /* To kernel */
        uint32_t                        lun_id;         /* To kernel */
        ctl_lun_error                   lun_error;      /* To kernel */
        ctl_lun_error_pattern           error_pattern;  /* To kernel */

Modified: head/sys/cam/ctl/ctl_scsi_all.c
==============================================================================
--- head/sys/cam/ctl/ctl_scsi_all.c     Thu Sep 10 10:23:23 2015        
(r287619)
+++ head/sys/cam/ctl/ctl_scsi_all.c     Thu Sep 10 10:46:21 2015        
(r287620)
@@ -114,7 +114,7 @@ ctl_scsi_path_string(union ctl_io *io, c
 {
 
        snprintf(path_str, len, "(%u:%u:%u/%u): ",
-           io->io_hdr.nexus.initid.id, io->io_hdr.nexus.targ_port,
+           io->io_hdr.nexus.initid, io->io_hdr.nexus.targ_port,
            io->io_hdr.nexus.targ_lun, io->io_hdr.nexus.targ_mapped_lun);
 }
 

Modified: head/sys/cam/ctl/ctl_tpc_local.c
==============================================================================
--- head/sys/cam/ctl/ctl_tpc_local.c    Thu Sep 10 10:23:23 2015        
(r287619)
+++ head/sys/cam/ctl/ctl_tpc_local.c    Thu Sep 10 10:46:21 2015        
(r287620)
@@ -328,9 +328,8 @@ tpcl_queue(union ctl_io *io, uint64_t lu
 {
        struct tpcl_softc *tsoftc = &tpcl_softc;
 
-       io->io_hdr.nexus.initid.id = 0;
+       io->io_hdr.nexus.initid = 0;
        io->io_hdr.nexus.targ_port = tsoftc->port.targ_port;
-       io->io_hdr.nexus.targ_target.id = 0;
        io->io_hdr.nexus.targ_lun = lun;
        io->scsiio.tag_num = atomic_fetchadd_int(&tsoftc->cur_tag_num, 1);
        io->scsiio.ext_data_filled = 0;

Modified: head/sys/cam/ctl/ctl_util.c
==============================================================================
--- head/sys/cam/ctl/ctl_util.c Thu Sep 10 10:23:23 2015        (r287619)
+++ head/sys/cam/ctl/ctl_util.c Thu Sep 10 10:46:21 2015        (r287620)
@@ -679,7 +679,7 @@ ctl_scsi_maintenance_in(union ctl_io *io
 
 #ifndef _KERNEL
 union ctl_io *
-ctl_scsi_alloc_io(struct ctl_id initid)
+ctl_scsi_alloc_io(uint32_t initid)
 {
        union ctl_io *io;
 

Modified: head/sys/cam/ctl/ctl_util.h
==============================================================================
--- head/sys/cam/ctl/ctl_util.h Thu Sep 10 10:23:23 2015        (r287619)
+++ head/sys/cam/ctl/ctl_util.h Thu Sep 10 10:46:21 2015        (r287620)
@@ -94,7 +94,7 @@ void ctl_scsi_maintenance_in(union ctl_i
                             uint32_t data_len, uint8_t action, 
                             ctl_tag_type tag_type, uint8_t control);
 #ifndef _KERNEL
-union ctl_io *ctl_scsi_alloc_io(struct ctl_id initid);
+union ctl_io *ctl_scsi_alloc_io(uint32_t initid);
 void ctl_scsi_free_io(union ctl_io *io);
 #endif /* !_KERNEL */
 void ctl_scsi_zero_io(union ctl_io *io);

Modified: head/sys/cam/ctl/scsi_ctl.c
==============================================================================
--- head/sys/cam/ctl/scsi_ctl.c Thu Sep 10 10:23:23 2015        (r287619)
+++ head/sys/cam/ctl/scsi_ctl.c Thu Sep 10 10:46:21 2015        (r287620)
@@ -1164,9 +1164,8 @@ ctlfedone(struct cam_periph *periph, uni
                 * down the immediate notify path below.
                 */
                io->io_hdr.io_type = CTL_IO_SCSI;
-               io->io_hdr.nexus.initid.id = atio->init_id;
+               io->io_hdr.nexus.initid = atio->init_id;
                io->io_hdr.nexus.targ_port = bus_softc->port.targ_port;
-               io->io_hdr.nexus.targ_target.id = atio->ccb_h.target_id;
                io->io_hdr.nexus.targ_lun = atio->ccb_h.target_lun;
                io->scsiio.tag_num = atio->tag_id;
                switch (atio->tag_action) {
@@ -1200,10 +1199,9 @@ ctlfedone(struct cam_periph *periph, uni
                      io->scsiio.cdb_len);
 
 #ifdef CTLFEDEBUG
-               printf("%s: %ju:%d:%ju:%d: tag %04x CDB %02x\n", __func__,
-                       (uintmax_t)io->io_hdr.nexus.initid.id,
+               printf("%s: %u:%u:%u: tag %04x CDB %02x\n", __func__,
+                       io->io_hdr.nexus.initid,
                        io->io_hdr.nexus.targ_port,
-                       (uintmax_t)io->io_hdr.nexus.targ_target.id,
                        io->io_hdr.nexus.targ_lun,
                        io->scsiio.tag_num, io->scsiio.cdb[0]);
 #endif
@@ -1440,9 +1438,8 @@ ctlfedone(struct cam_periph *periph, uni
                io->io_hdr.io_type = CTL_IO_TASK;
                io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr =done_ccb;
                inot->ccb_h.io_ptr = io;
-               io->io_hdr.nexus.initid.id = inot->initiator_id;
+               io->io_hdr.nexus.initid = inot->initiator_id;
                io->io_hdr.nexus.targ_port = bus_softc->port.targ_port;
-               io->io_hdr.nexus.targ_target.id = inot->ccb_h.target_id;
                io->io_hdr.nexus.targ_lun = inot->ccb_h.target_lun;
                /* XXX KDM should this be the tag_id? */
                io->taskio.tag_num = inot->seq_id;

Modified: head/usr.sbin/ctladm/ctladm.8
==============================================================================
--- head/usr.sbin/ctladm/ctladm.8       Thu Sep 10 10:23:23 2015        
(r287619)
+++ head/usr.sbin/ctladm/ctladm.8       Thu Sep 10 10:46:21 2015        
(r287620)
@@ -34,7 +34,7 @@
 .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
 .\" $FreeBSD$
 .\"
-.Dd September 6, 2015
+.Dd September 10, 2015
 .Dt CTLADM 8
 .Os
 .Sh NAME
@@ -43,28 +43,28 @@
 .Sh SYNOPSIS
 .Nm
 .Aq Ar command
-.Op target:lun
+.Op lun
 .Op generic args
 .Op command args
 .Nm
 .Ic tur
-.Aq target:lun
+.Aq lun
 .Op general options
 .Nm
 .Ic inquiry
-.Aq target:lun
+.Aq lun
 .Op general options
 .Nm
 .Ic reqsense
-.Aq target:lun
+.Aq lun
 .Op general options
 .Nm
 .Ic reportluns
-.Aq target:lun
+.Aq lun
 .Op general options
 .Nm
 .Ic read
-.Aq target:lun
+.Aq lun
 .Op general options
 .Aq Fl l Ar lba
 .Aq Fl d Ar datalen
@@ -74,7 +74,7 @@
 .Op Fl N
 .Nm
 .Ic write
-.Aq target:lun
+.Aq lun
 .Op general options
 .Aq Fl l Ar lba
 .Aq Fl d Ar datalen
@@ -84,12 +84,12 @@
 .Op Fl N
 .Nm
 .Ic readcap
-.Aq target:lun
+.Aq lun
 .Op general options
 .Op Fl c Ar cdbsize
 .Nm
 .Ic modesense
-.Aq target:lun
+.Aq lun
 .Aq Fl m Ar page | Fl l
 .Op Fl P Ar pc
 .Op Fl d
@@ -97,19 +97,19 @@
 .Op Fl c Ar size
 .Nm
 .Ic start
-.Aq target:lun
+.Aq lun
 .Op general options
 .Op Fl i
 .Op Fl o
 .Nm
 .Ic stop
-.Aq target:lun
+.Aq lun
 .Op general options
 .Op Fl i
 .Op Fl o
 .Nm
 .Ic synccache
-.Aq target:lun
+.Aq lun
 .Op general options
 .Op Fl l Ar lba
 .Op Fl b Ar blockcount
@@ -126,7 +126,7 @@
 .Ic lunlist
 .Nm
 .Ic delay
-.Aq target:lun
+.Aq lun
 .Aq Fl l Ar datamove|done
 .Aq Fl t Ar secs
 .Op Fl T Ar oneshot|cont
@@ -134,11 +134,11 @@
 .Ic realsync Aq on|off|query
 .Nm
 .Ic setsync interval
-.Aq target:lun
+.Aq lun
 .Aq Fl i Ar interval
 .Nm
 .Ic getsync
-.Aq target:lun
+.Aq lun
 .Nm
 .Ic inject
 .Aq Fl i Ar action
@@ -236,8 +236,8 @@ utility has a number of primary function
 identifier.
 The device identifier takes the following form:
 .Bl -tag -width 14n
-.It target:lun
-Specify the target (almost always 0) and LUN number to operate on.
+.It lun
+Specify the LUN number to operate on.
 .El
 Many of the primary functions of the
 .Nm
@@ -570,7 +570,7 @@ sending SYNCHRONIZE cache commands.  An 
 will be flushed for this LUN every time a SYNCHRONIZE CACHE command is
 received.
 .Pp
-You must specify the target and LUN you want to modify.
+You must specify the LUN you want to modify.
 .It Ic getsync
 Get the interval at which we actually service the SYNCHRONIZE CACHE
 command, as set by the
@@ -580,7 +580,7 @@ The reported number means that we will a
 Nth SYNCHRONIZE CACHE command.  A value of 0 means that we will flush the
 cache every time.
 .Pp
-You must specify the target and LUN you want to query.
+You must specify the LUN you want to query.
 .It Ic inject
 Inject the specified type of error for the LUN specified, when a command
 that matches the given pattern is seen.
@@ -1024,34 +1024,34 @@ Specifies file or device name to use for
 Specifies number of backend threads to use for this LUN.
 .El
 .Sh EXAMPLES
-.Dl ctladm tur 0:1
+.Dl ctladm tur 1
 .Pp
 Send a
 .Tn SCSI
 TEST UNIT READY command to LUN 1.
 .Pp
-.Dl ctladm modesense 0:1 -l
+.Dl ctladm modesense 1 -l
 .Pp
 Display the list of mode pages supported by LUN 1.
 .Pp
-.Dl ctladm modesense 0:0 -m 10 -P 3 -d -c 10
+.Dl ctladm modesense 0 -m 10 -P 3 -d -c 10
 .Pp
 Display the saved version of the Control mode page (page 10) on LUN 0.
 Disable fetching block descriptors, and use a 10 byte MODE SENSE command
 instead of the default 6 byte command.
 .Bd -literal
-ctladm read 0:2 -l 0 -d 1 -b 512 -f - > foo
+ctladm read 2 -l 0 -d 1 -b 512 -f - > foo
 .Ed
 .Pp
 Read the first 512 byte block from LUN 2 and dump it to the file
 .Pa foo .
 .Bd -literal
-ctladm write 0:3 -l 0xff432140 -d 20 -b 512 -f /tmp/bar
+ctladm write 3 -l 0xff432140 -d 20 -b 512 -f /tmp/bar
 .Ed
 .Pp
 Read 10240 bytes from the file
 .Pa /tmp/bar
-and write it to target 0, LUN 3.
+and write it to LUN 3.
 starting at LBA 0xff432140.
 .Pp
 .Dl ctladm create -b ramdisk -s 10485760000000000
@@ -1095,12 +1095,12 @@ List all LUNs in the system, along with 
 This only works when the FETDs are enabled, since the commands go through the
 ioctl port.
 .Pp
-.Dl ctladm inject 0:6 -i mediumerr -p read -r 0,512 -c
+.Dl ctladm inject 6 -i mediumerr -p read -r 0,512 -c
 .Pp
 Inject a medium error on LUN 6 for every read that covers the first 512
 blocks of the LUN.
 .Bd -literal -offset indent
-ctladm inject 0:6 -i custom -p tur -s 18 "f0 0 02 s12 04 02"
+ctladm inject 6 -i custom -p tur -s 18 "f0 0 02 s12 04 02"
 .Ed
 .Pp
 Inject a custom error on LUN 6 for the next TEST UNIT READY command only.

Modified: head/usr.sbin/ctladm/ctladm.c
==============================================================================
--- head/usr.sbin/ctladm/ctladm.c       Thu Sep 10 10:23:23 2015        
(r287619)
+++ head/usr.sbin/ctladm/ctladm.c       Thu Sep 10 10:46:21 2015        
(r287620)
@@ -211,49 +211,47 @@ static struct ctladm_opts option_table[]
 
 ctladm_optret getoption(struct ctladm_opts *table, char *arg, uint32_t *cmdnum,
                        ctladm_cmdargs *argnum, const char **subopt);
-static int cctl_parse_tl(char *str, int *target, int *lun);
 static int cctl_dump_ooa(int fd, int argc, char **argv);
 static int cctl_port_dump(int fd, int quiet, int xml, int32_t fe_num,
                          ctl_port_type port_type);
 static int cctl_port(int fd, int argc, char **argv, char *combinedopt);
 static int cctl_do_io(int fd, int retries, union ctl_io *io, const char *func);
-static int cctl_delay(int fd, int target, int lun, int argc, char **argv,
+static int cctl_delay(int fd, int lun, int argc, char **argv,
                      char *combinedopt);
 static int cctl_lunlist(int fd);
-static int cctl_startup_shutdown(int fd, int target, int lun, int iid,
+static int cctl_startup_shutdown(int fd, int lun, int iid,
                                 ctladm_cmdfunction command);
-static int cctl_sync_cache(int fd, int target, int lun, int iid, int retries,
+static int cctl_sync_cache(int fd, int lun, int iid, int retries,
                           int argc, char **argv, char *combinedopt);
-static int cctl_start_stop(int fd, int target, int lun, int iid, int retries,
+static int cctl_start_stop(int fd, int lun, int iid, int retries,
                           int start, int argc, char **argv, char *combinedopt);
-static int cctl_mode_sense(int fd, int target, int lun, int iid, int retries,
+static int cctl_mode_sense(int fd, int lun, int iid, int retries,
                           int argc, char **argv, char *combinedopt);
-static int cctl_read_capacity(int fd, int target, int lun, int iid,
+static int cctl_read_capacity(int fd, int lun, int iid,
                              int retries, int argc, char **argv,
                              char *combinedopt);
-static int cctl_read_write(int fd, int target, int lun, int iid, int retries,
+static int cctl_read_write(int fd, int lun, int iid, int retries,
                           int argc, char **argv, char *combinedopt,
                           ctladm_cmdfunction command);
-static int cctl_get_luns(int fd, int target, int lun, int iid, int retries,
+static int cctl_get_luns(int fd, int lun, int iid, int retries,
                         struct scsi_report_luns_data **lun_data,
                         uint32_t *num_luns);
-static int cctl_report_luns(int fd, int target, int lun, int iid, int retries);
-static int cctl_tur(int fd, int target, int lun, int iid, int retries);
-static int cctl_get_inquiry(int fd, int target, int lun, int iid, int retries,
+static int cctl_report_luns(int fd, int lun, int iid, int retries);
+static int cctl_tur(int fd, int lun, int iid, int retries);
+static int cctl_get_inquiry(int fd, int lun, int iid, int retries,
                            char *path_str, int path_len,
                            struct scsi_inquiry_data *inq_data);
-static int cctl_inquiry(int fd, int target, int lun, int iid, int retries);
-static int cctl_req_sense(int fd, int target, int lun, int iid, int retries);
-static int cctl_persistent_reserve_in(int fd, int target, int lun,
+static int cctl_inquiry(int fd, int lun, int iid, int retries);
+static int cctl_req_sense(int fd, int lun, int iid, int retries);
+static int cctl_persistent_reserve_in(int fd, int lun,
                                      int initiator, int argc, char **argv,
                                      char *combinedopt, int retry_count);
-static int cctl_persistent_reserve_out(int fd, int target, int lun,
+static int cctl_persistent_reserve_out(int fd, int lun,
                                       int initiator, int argc, char **argv,
                                       char *combinedopt, int retry_count);
 static int cctl_create_lun(int fd, int argc, char **argv, char *combinedopt);
-static int cctl_inquiry_vpd_devid(int fd, int target, int lun, int initiator);
-static int cctl_report_target_port_group(int fd, int target, int lun,
-                                        int initiator);
+static int cctl_inquiry_vpd_devid(int fd, int lun, int initiator);
+static int cctl_report_target_port_group(int fd, int lun, int initiator);
 static int cctl_modify_lun(int fd, int argc, char **argv, char *combinedopt);
 
 ctladm_optret
@@ -284,50 +282,20 @@ getoption(struct ctladm_opts *table, cha
                return(CC_OR_NOT_FOUND);
 }
 
-
-static int
-cctl_parse_tl(char *str, int *target, int *lun)
-{
-       char *tmpstr;
-       int retval;
-
-       retval = 0;
-
-       while (isspace(*str) && (*str != '\0'))
-               str++;
-
-       tmpstr = (char *)strtok(str, ":");
-       if ((tmpstr != NULL) && (*tmpstr != '\0')) {
-               *target = strtol(tmpstr, NULL, 0);
-               tmpstr = (char *)strtok(NULL, ":");
-               if ((tmpstr != NULL) && (*tmpstr != '\0')) {
-                       *lun = strtol(tmpstr, NULL, 0);
-               } else
-                       retval = -1;
-       } else
-               retval = -1;
-
-       return (retval);
-}
-
 static int
 cctl_dump_ooa(int fd, int argc, char **argv)
 {
        struct ctl_ooa ooa;
        long double cmd_latency;
        int num_entries, len;
-       int target = -1, lun = -1;
+       int lun = -1;
        int retval;
        unsigned int i;
 
        num_entries = 104;
 
-       if ((argc > 2)
-        && (isdigit(argv[2][0]))) {
-               retval = cctl_parse_tl(argv[2], &target, &lun);
-               if (retval != 0)
-                       warnx("invalid target:lun argument %s", argv[2]);
-       }
+       if ((argc > 2) && (isdigit(argv[2][0])))
+               lun = strtol(argv[2], NULL, 0);
 retry:
 
        len = num_entries * sizeof(struct ctl_ooa_entry);
@@ -776,7 +744,7 @@ cctl_do_io(int fd, int retries, union ct
 }
 
 static int
-cctl_delay(int fd, int target, int lun, int argc, char **argv,
+cctl_delay(int fd, int lun, int argc, char **argv,
           char *combinedopt)
 {
        struct ctl_io_delay_info delay_info;
@@ -831,7 +799,6 @@ cctl_delay(int fd, int target, int lun, 
                goto bailout;
        }
 
-       delay_info.target_id = target;
        delay_info.lun_id = lun;
        delay_info.delay_secs = delaytime;
 
@@ -938,7 +905,7 @@ bailout:
 }
 
 static int
-cctl_getsetsync(int fd, int target, int lun, ctladm_cmdfunction command,
+cctl_getsetsync(int fd, int lun, ctladm_cmdfunction command,
                int argc, char **argv, char *combinedopt)
 {
        struct ctl_sync_info sync_info;
@@ -950,7 +917,6 @@ cctl_getsetsync(int fd, int target, int 
        retval = 0;
 
        memset(&sync_info, 0, sizeof(sync_info));
-       sync_info.target_id = target;
        sync_info.lun_id = lun;
 
        while ((c = getopt(argc, argv, combinedopt)) != -1) {
@@ -986,12 +952,12 @@ cctl_getsetsync(int fd, int target, int 
        switch (sync_info.status) {
        case CTL_GS_SYNC_OK:
                if (command == CTLADM_CMD_GETSYNC) {
-                       fprintf(stdout, "%d:%d: sync interval: %d\n",
-                               target, lun, sync_info.sync_interval);
+                       fprintf(stdout, "%d: sync interval: %d\n",
+                               lun, sync_info.sync_interval);
                }
                break;
        case CTL_GS_SYNC_NO_LUN:
-               warnx("%s: unknown target:LUN %d:%d", __func__, target, lun);
+               warnx("%s: unknown LUN %d", __func__, lun);
                retval = 1;
                break;
        case CTL_GS_SYNC_NONE:
@@ -1030,7 +996,7 @@ static struct ctladm_opts cctl_err_patte
 };
 
 static int
-cctl_error_inject(int fd, uint32_t target, uint32_t lun, int argc, char **argv,
+cctl_error_inject(int fd, uint32_t lun, int argc, char **argv,
                  char *combinedopt)
 {
        int retval = 0;
@@ -1045,7 +1011,6 @@ cctl_error_inject(int fd, uint32_t targe
        int c;
 
        bzero(&err_desc, sizeof(err_desc));
-       err_desc.target_id = target;
        err_desc.lun_id = lun;
 
        while ((c = getopt(argc, argv, combinedopt)) != -1) {
@@ -1256,7 +1221,6 @@ cctl_lunlist(int fd)
        struct scsi_report_luns_data *lun_data;
        struct scsi_inquiry_data *inq_data;
        uint32_t num_luns;
-       int target;
        int initid;
        unsigned int i;
        int retval;
@@ -1264,14 +1228,13 @@ cctl_lunlist(int fd)
        retval = 0;
        inq_data = NULL;
 
-       target = 6;
        initid = 7;
 
        /*
         * XXX KDM assuming LUN 0 is fine, but we may need to change this
         * if we ever acquire the ability to have multiple targets.
         */
-       if ((retval = cctl_get_luns(fd, target, /*lun*/ 0, initid,
+       if ((retval = cctl_get_luns(fd, /*lun*/ 0, initid,
                                    /*retries*/ 2, &lun_data, &num_luns)) != 0)
                goto bailout;
 
@@ -1308,7 +1271,7 @@ cctl_lunlist(int fd)
                if (lun_val == -1)
                        continue;
 
-               if ((retval = cctl_get_inquiry(fd, target, lun_val, initid,
+               if ((retval = cctl_get_inquiry(fd, lun_val, initid,
                                               /*retries*/ 2, scsi_path,
                                               sizeof(scsi_path),
                                               inq_data)) != 0) {
@@ -1329,11 +1292,10 @@ bailout:
 }
 
 static int
-cctl_startup_shutdown(int fd, int target, int lun, int iid,
+cctl_startup_shutdown(int fd, int lun, int iid,
                      ctladm_cmdfunction command)
 {
        union ctl_io *io;
-       struct ctl_id id;
        struct scsi_report_luns_data *lun_data;
        struct scsi_inquiry_data *inq_data;
        uint32_t num_luns;
@@ -1353,15 +1315,13 @@ cctl_startup_shutdown(int fd, int target
         *     and reissue the stop with the offline bit set
         */
 
-       id.id = iid;
-
-       io = ctl_scsi_alloc_io(id);
+       io = ctl_scsi_alloc_io(iid);
        if (io == NULL) {
                warnx("%s: can't allocate memory", __func__);
                return (1);
        }
 
-       if ((retval = cctl_get_luns(fd, target, lun, iid, /*retries*/ 2,
+       if ((retval = cctl_get_luns(fd, lun, iid, /*retries*/ 2,
                                    &lun_data, &num_luns)) != 0)
                goto bailout;
 
@@ -1402,7 +1362,7 @@ cctl_startup_shutdown(int fd, int target
                if (lun_val == -1)
                        continue;
 
-               if ((retval = cctl_get_inquiry(fd, target, lun_val, iid,
+               if ((retval = cctl_get_inquiry(fd, lun_val, iid,
                                               /*retries*/ 2, scsi_path,
                                               sizeof(scsi_path),
                                               inq_data)) != 0) {
@@ -1422,7 +1382,6 @@ cctl_startup_shutdown(int fd, int target
                if (command == CTLADM_CMD_SHUTDOWN) {
                        struct ctl_ooa_info ooa_info;
 
-                       ooa_info.target_id = target;
                        ooa_info.lun_id = lun_val;
 
                        if (ioctl(fd, CTL_CHECK_OOA, &ooa_info) == -1) {
@@ -1457,9 +1416,8 @@ cctl_startup_shutdown(int fd, int target
                                    CTL_TAG_SIMPLE :CTL_TAG_ORDERED,
                                    /*control*/ 0);
 
-               io->io_hdr.nexus.targ_target.id = target;
                io->io_hdr.nexus.targ_lun = lun_val;
-               io->io_hdr.nexus.initid = id;
+               io->io_hdr.nexus.initid = iid;
 
                if (cctl_do_io(fd, /*retries*/ 3, io, __func__) != 0) {
                        retval = 1;
@@ -1488,11 +1446,10 @@ bailout:
 }
 
 static int
-cctl_sync_cache(int fd, int target, int lun, int iid, int retries,
+cctl_sync_cache(int fd, int lun, int iid, int retries,
                int argc, char **argv, char *combinedopt)
 {
        union ctl_io *io;
-       struct ctl_id id;
        int cdb_size = -1;
        int retval;
        uint64_t our_lba = 0;
@@ -1500,10 +1457,9 @@ cctl_sync_cache(int fd, int target, int 
        int reladr = 0, immed = 0;
        int c;
 
-       id.id = iid;
        retval = 0;
 
-       io = ctl_scsi_alloc_io(id);
+       io = ctl_scsi_alloc_io(iid);
        if (io == NULL) {
                warnx("%s: can't allocate memory", __func__);
                return (1);
@@ -1555,9 +1511,8 @@ cctl_sync_cache(int fd, int target, int 
                            /*tag_type*/ CTL_TAG_SIMPLE,
                            /*control*/ 0);
 
-       io->io_hdr.nexus.targ_target.id = target;
        io->io_hdr.nexus.targ_lun = lun;
-       io->io_hdr.nexus.initid = id;
+       io->io_hdr.nexus.initid = iid;
 
        if (cctl_do_io(fd, retries, io, __func__) != 0) {
                retval = 1;
@@ -1575,19 +1530,17 @@ bailout:
 }
 
 static int
-cctl_start_stop(int fd, int target, int lun, int iid, int retries, int start,
+cctl_start_stop(int fd, int lun, int iid, int retries, int start,
                int argc, char **argv, char *combinedopt)
 {
        union ctl_io *io;
-       struct ctl_id id;
        char scsi_path[40];
        int immed = 0, onoffline = 0;
        int retval, c;
 
-       id.id = iid;
        retval = 0;
 
-       io = ctl_scsi_alloc_io(id);
+       io = ctl_scsi_alloc_io(iid);
        if (io == NULL) {
                warnx("%s: can't allocate memory", __func__);
                return (1);
@@ -1622,9 +1575,8 @@ cctl_start_stop(int fd, int target, int 
                                                     CTL_TAG_ORDERED,
                            /*control*/ 0);
 
-       io->io_hdr.nexus.targ_target.id = target;
        io->io_hdr.nexus.targ_lun = lun;
-       io->io_hdr.nexus.initid = id;
+       io->io_hdr.nexus.initid = iid;
 
        if (cctl_do_io(fd, retries, io, __func__) != 0) {
                retval = 1;
@@ -1645,11 +1597,10 @@ bailout:
 }
 
 static int
-cctl_mode_sense(int fd, int target, int lun, int iid, int retries,
+cctl_mode_sense(int fd, int lun, int iid, int retries,
                int argc, char **argv, char *combinedopt)
 {
        union ctl_io *io;
-       struct ctl_id id;
        uint32_t datalen;
        uint8_t *dataptr;
        int pc = -1, cdbsize, retval, dbd = 0, subpage = -1;
@@ -1657,12 +1608,11 @@ cctl_mode_sense(int fd, int target, int 
        int page_code = -1;
        int c;
 
-       id.id = iid;
        cdbsize = 0;
        retval = 0;
        dataptr = NULL;
 
-       io = ctl_scsi_alloc_io(id);
+       io = ctl_scsi_alloc_io(iid);
        if (io == NULL) {
                warn("%s: can't allocate memory", __func__);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to