svn commit: r288798 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:01:18 2015
New Revision: 288798
URL: https://svnweb.freebsd.org/changeset/base/288798

Log:
  MFC r288215: Switch I/O time accounting from system time to uptime.
  
  While there, make num_dmas accounted independently of CTL_TIME_IO.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_backend_block.c
  stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
  stable/10/sys/cam/ctl/ctl_io.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:00:25 2015(r288797)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:01:18 2015(r288798)
@@ -1329,7 +1329,7 @@ ctl_isc_event_handler(ctl_ha_channel cha
io->scsiio.tag_type = msg->scsi.tag_type;
 #ifdef CTL_TIME_IO
io->io_hdr.start_time = time_uptime;
-   getbintime(>io_hdr.start_bt);
+   getbinuptime(>io_hdr.start_bt);
 #endif /* CTL_TIME_IO */
io->scsiio.cdb_len = msg->scsi.cdb_len;
memcpy(io->scsiio.cdb, msg->scsi.cdb,
@@ -1368,7 +1368,7 @@ ctl_isc_event_handler(ctl_ha_channel cha
 
if (msg->dt.sg_sequence == 0) {
 #ifdef CTL_TIME_IO
-   getbintime(>io_hdr.dma_start_bt);
+   getbinuptime(>io_hdr.dma_start_bt);
 #endif
i = msg->dt.kern_sg_entries +
msg->dt.kern_data_len /
@@ -1518,7 +1518,7 @@ ctl_isc_event_handler(ctl_ha_channel cha
taskio->tag_type = msg->task.tag_type;
 #ifdef CTL_TIME_IO
taskio->io_hdr.start_time = time_uptime;
-   getbintime(>io_hdr.start_bt);
+   getbinuptime(>io_hdr.start_bt);
 #endif /* CTL_TIME_IO */
ctl_run_task((union ctl_io *)taskio);
break;
@@ -2777,7 +2777,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
   __func__, ooa_hdr->fill_len);
}
 
-   getbintime(_hdr->cur_bt);
+   getbinuptime(_hdr->cur_bt);
 
if (cur_fill_num > ooa_hdr->alloc_num) {
ooa_hdr->dropped_num = cur_fill_num -ooa_hdr->alloc_num;
@@ -12656,11 +12656,11 @@ ctl_send_datamove_done(union ctl_io *io,
msg.scsi.sense_len, M_WAITOK);
 
 #ifdef CTL_TIME_IO
-   getbintime(_bt);
+   getbinuptime(_bt);
bintime_sub(_bt, >io_hdr.dma_start_bt);
bintime_add(>io_hdr.dma_bt, _bt);
-   io->io_hdr.num_dmas++;
 #endif
+   io->io_hdr.num_dmas++;
 }
 
 /*
@@ -13169,12 +13169,12 @@ ctl_process_done(union ctl_io *io)
 #ifdef CTL_TIME_IO
bintime_add(>stats.ports[targ_port].dma_time[type],
   >io_hdr.dma_bt);
-   lun->stats.ports[targ_port].num_dmas[type] +=
-   io->io_hdr.num_dmas;
-   getbintime(_bt);
+   getbinuptime(_bt);
bintime_sub(_bt, >io_hdr.start_bt);
bintime_add(>stats.ports[targ_port].time[type], _bt);
 #endif
+   lun->stats.ports[targ_port].num_dmas[type] +=
+   io->io_hdr.num_dmas;
}
 
/*
@@ -13319,7 +13319,7 @@ ctl_queue(union ctl_io *io)
 
 #ifdef CTL_TIME_IO
io->io_hdr.start_time = time_uptime;
-   getbintime(>io_hdr.start_bt);
+   getbinuptime(>io_hdr.start_bt);
 #endif /* CTL_TIME_IO */
 
/* Map FE-specific LUN ID into global one. */

Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==
--- stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 11:00:25 2015
(r288797)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 11:01:18 2015
(r288798)
@@ -408,11 +408,11 @@ ctl_be_block_move_done(union ctl_io *io)
DPRINTF("entered\n");
 
 #ifdef CTL_TIME_IO
-   getbintime(_bt);
+   getbinuptime(_bt);
bintime_sub(_bt, >io_hdr.dma_start_bt);
bintime_add(>io_hdr.dma_bt, _bt);
+#endif
io->io_hdr.num_dmas++;
-#endif  
io->scsiio.kern_rel_offset += io->scsiio.kern_data_len;
 
/*
@@ -566,8 +566,8 @@ ctl_be_block_biodone(struct bio *bio)
ctl_serseq_done(io);
}
 #ifdef CTL_TIME_IO
-   getbintime(>io_hdr.dma_start_bt);
-#endif  
+   getbinuptime(>io_hdr.dma_start_bt);
+#endif
ctl_datamove(io);
}
 }
@@ -788,8 +788,8 @@ ctl_be_block_dispatch_file(struct ctl_be
ctl_serseq_done(io);
}
 #ifdef CTL_TIME_IO
-   getbintime(>io_hdr.dma_start_bt);
-#endif  
+   getbinuptime(>io_hdr.dma_start_bt);
+#endif
ctl_datamove(io);
}
 }
@@ 

svn commit: r288781 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:46:24 2015
New Revision: 288781
URL: https://svnweb.freebsd.org/changeset/base/288781

Log:
  MFC r288020: Remove couple excess SGLIST I/O flags.
  
  Those flags duplicated respective (sg_entries > 0) values.

Modified:
  stable/10/sys/cam/ctl/ctl_backend_block.c
  stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
  stable/10/sys/cam/ctl/ctl_frontend_ioctl.c
  stable/10/sys/cam/ctl/ctl_io.h
  stable/10/sys/cam/ctl/ctl_tpc_local.c
  stable/10/sys/cam/ctl/ctl_util.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==
--- stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 10:45:52 2015
(r288780)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 10:46:24 2015
(r288781)
@@ -1652,7 +1652,7 @@ ctl_be_block_dispatch(struct ctl_be_bloc
io->scsiio.kern_data_len = beio->io_len;
io->scsiio.kern_data_resid = 0;
io->scsiio.kern_sg_entries = beio->num_segs;
-   io->io_hdr.flags |= CTL_FLAG_ALLOCATED | CTL_FLAG_KDPTR_SGLIST;
+   io->io_hdr.flags |= CTL_FLAG_ALLOCATED;
 
/*
 * For the read case, we need to read the data into our buffers and

Modified: stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
==
--- stable/10/sys/cam/ctl/ctl_backend_ramdisk.c Mon Oct  5 10:45:52 2015
(r288780)
+++ stable/10/sys/cam/ctl/ctl_backend_ramdisk.c Mon Oct  5 10:46:24 2015
(r288781)
@@ -321,7 +321,6 @@ ctl_backend_ramdisk_continue(union ctl_i
sg_entries[i].len = MIN(PAGE_SIZE, len - len_filled);
len_filled += sg_entries[i].len;
}
-   io->io_hdr.flags |= CTL_FLAG_KDPTR_SGLIST;
} else {
sg_filled = 0;
len_filled = len;

Modified: stable/10/sys/cam/ctl/ctl_frontend_ioctl.c
==
--- stable/10/sys/cam/ctl/ctl_frontend_ioctl.c  Mon Oct  5 10:45:52 2015
(r288780)
+++ stable/10/sys/cam/ctl/ctl_frontend_ioctl.c  Mon Oct  5 10:46:24 2015
(r288781)
@@ -149,7 +149,7 @@ ctl_ioctl_do_datamove(struct ctl_scsiio 
 * To simplify things here, if we have a single buffer, stick it in
 * a S/G entry and just make it a single entry S/G list.
 */
-   if (ctsio->io_hdr.flags & CTL_FLAG_EDPTR_SGLIST) {
+   if (ctsio->ext_sg_entries > 0) {
int len_seen;
 
ext_sglen = ctsio->ext_sg_entries * sizeof(*ext_sglist);

Modified: stable/10/sys/cam/ctl/ctl_io.h
==
--- stable/10/sys/cam/ctl/ctl_io.h  Mon Oct  5 10:45:52 2015
(r288780)
+++ stable/10/sys/cam/ctl/ctl_io.h  Mon Oct  5 10:46:24 2015
(r288781)
@@ -88,8 +88,6 @@ typedef enum {
CTL_FLAG_DATA_OUT   = 0x0002,   /* DATA OUT */
CTL_FLAG_DATA_NONE  = 0x0003,   /* no data */
CTL_FLAG_DATA_MASK  = 0x0003,
-   CTL_FLAG_KDPTR_SGLIST   = 0x0008,   /* kern_data_ptr is S/G list*/
-   CTL_FLAG_EDPTR_SGLIST   = 0x0010,   /* ext_data_ptr is S/G list */
CTL_FLAG_DO_AUTOSENSE   = 0x0020,   /* grab sense info */
CTL_FLAG_USER_REQ   = 0x0040,   /* request came from userland */
CTL_FLAG_ALLOCATED  = 0x0100,   /* data space allocated */

Modified: stable/10/sys/cam/ctl/ctl_tpc_local.c
==
--- stable/10/sys/cam/ctl/ctl_tpc_local.c   Mon Oct  5 10:45:52 2015
(r288780)
+++ stable/10/sys/cam/ctl/ctl_tpc_local.c   Mon Oct  5 10:46:24 2015
(r288781)
@@ -162,7 +162,7 @@ tpcl_datamove(union ctl_io *io)
 * To simplify things here, if we have a single buffer, stick it in
 * a S/G entry and just make it a single entry S/G list.
 */
-   if (ctsio->io_hdr.flags & CTL_FLAG_EDPTR_SGLIST) {
+   if (ctsio->ext_sg_entries > 0) {
int len_seen;
 
ext_sglist = (struct ctl_sg_entry *)ctsio->ext_data_ptr;

Modified: stable/10/sys/cam/ctl/ctl_util.c
==
--- stable/10/sys/cam/ctl/ctl_util.cMon Oct  5 10:45:52 2015
(r288780)
+++ stable/10/sys/cam/ctl/ctl_util.cMon Oct  5 10:46:24 2015
(r288781)
@@ -882,7 +882,7 @@ ctl_data_print(union ctl_io *io)
return;
if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR)
return;
-   if (io->io_hdr.flags & CTL_FLAG_EDPTR_SGLIST)   /* XXX: Implement */
+   if (io->scsiio.ext_sg_entries > 0)  /* XXX: Implement */
return;
ctl_scsi_path_string(io, path_str, sizeof(path_str));
len = min(io->scsiio.kern_data_len, 

svn commit: r288797 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:00:25 2015
New Revision: 288797
URL: https://svnweb.freebsd.org/changeset/base/288797

Log:
  MFC r288214: Collect DMA statistics on secondary HA node.

Modified:
  stable/10/sys/cam/ctl/ctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:59:37 2015(r288796)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:00:25 2015(r288797)
@@ -1367,6 +1367,9 @@ ctl_isc_event_handler(ctl_ha_channel cha
io->io_hdr.status = msg->hdr.status;
 
if (msg->dt.sg_sequence == 0) {
+#ifdef CTL_TIME_IO
+   getbintime(>io_hdr.dma_start_bt);
+#endif
i = msg->dt.kern_sg_entries +
msg->dt.kern_data_len /
CTL_HA_DATAMOVE_SEGMENT + 1;
@@ -12624,9 +12627,11 @@ static void
 ctl_send_datamove_done(union ctl_io *io, int have_lock)
 {
union ctl_ha_msg msg;
+#ifdef CTL_TIME_IO
+   struct bintime cur_bt;
+#endif
 
memset(, 0, sizeof(msg));
-
msg.hdr.msg_type = CTL_MSG_DATAMOVE_DONE;
msg.hdr.original_sc = io;
msg.hdr.serializing_sc = io->io_hdr.serializing_sc;
@@ -12642,15 +12647,20 @@ ctl_send_datamove_done(union ctl_io *io,
msg.scsi.fetd_status = io->io_hdr.port_status;
msg.scsi.residual = io->scsiio.residual;
io->io_hdr.flags &= ~CTL_FLAG_IO_ACTIVE;
-
if (io->io_hdr.flags & CTL_FLAG_FAILOVER) {
ctl_failover_io(io, /*have_lock*/ have_lock);
return;
}
-
ctl_ha_msg_send(CTL_HA_CHAN_CTL, ,
sizeof(msg.scsi) - sizeof(msg.scsi.sense_data) +
msg.scsi.sense_len, M_WAITOK);
+
+#ifdef CTL_TIME_IO
+   getbintime(_bt);
+   bintime_sub(_bt, >io_hdr.dma_start_bt);
+   bintime_add(>io_hdr.dma_bt, _bt);
+   io->io_hdr.num_dmas++;
+#endif
 }
 
 /*
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288818 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:46:23 2015
New Revision: 288818
URL: https://svnweb.freebsd.org/changeset/base/288818

Log:
  MFC r288427: Use proper STAILQ_* macros where possible.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:45:28 2015(r288817)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:46:23 2015(r288818)
@@ -1924,13 +1924,8 @@ ctl_shutdown(void)
 
mtx_lock(>ctl_lock);
 
-   /*
-* Free up each LUN.
-*/
-   for (lun = STAILQ_FIRST(>lun_list); lun != NULL; lun = next_lun){
-   next_lun = STAILQ_NEXT(lun, links);
+   STAILQ_FOREACH_SAFE(lun, >lun_list, links, next_lun)
ctl_free_lun(lun);
-   }
 
mtx_unlock(>ctl_lock);
 
@@ -2782,9 +2777,9 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 * XXX KDM no locking here.  If the LUN list changes,
 * things can blow up.
 */
-   for (i = 0, lun = STAILQ_FIRST(>lun_list); lun != NULL;
-i++, lun = STAILQ_NEXT(lun, links)) {
-   retval = copyout(>stats, >lun_stats[i],
+   i = 0;
+   STAILQ_FOREACH(lun, >lun_list, links) {
+   retval = copyout(>stats, >lun_stats[i++],
 sizeof(lun->stats));
if (retval != 0)
break;
@@ -4639,8 +4634,7 @@ ctl_enable_lun(struct ctl_be_lun *be_lun
lun->flags &= ~CTL_LUN_DISABLED;
mtx_unlock(>lun_lock);
 
-   for (port = STAILQ_FIRST(>port_list); port != NULL; port = 
nport) {
-   nport = STAILQ_NEXT(port, links);
+   STAILQ_FOREACH_SAFE(port, >port_list, links, nport) {
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0 ||
port->lun_map != NULL || port->lun_enable == NULL)
continue;
@@ -13132,7 +13126,7 @@ ctl_process_done(union ctl_io *io)
 * Check to see if we have any errors to inject here.  We only
 * inject errors for commands that don't already have errors set.
 */
-   if ((STAILQ_FIRST(>error_list) != NULL) &&
+   if (!STAILQ_EMPTY(>error_list) &&
((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS) &&
((io->io_hdr.flags & CTL_FLAG_STATUS_SENT) == 0))
ctl_inject_error(lun, io);

Modified: stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
==
--- stable/10/sys/cam/ctl/ctl_backend_ramdisk.c Mon Oct  5 11:45:28 2015
(r288817)
+++ stable/10/sys/cam/ctl/ctl_backend_ramdisk.c Mon Oct  5 11:46:23 2015
(r288818)
@@ -180,14 +180,7 @@ ctl_backend_ramdisk_shutdown(void)
 #endif
 
mtx_lock(>lock);
-   for (lun = STAILQ_FIRST(>lun_list); lun != NULL; lun = next_lun){
-   /*
-* Grab the next LUN.  The current LUN may get removed by
-* ctl_invalidate_lun(), which will call our LUN shutdown
-* routine, if there is no outstanding I/O for this LUN.
-*/
-   next_lun = STAILQ_NEXT(lun, links);
-
+   STAILQ_FOREACH_SAFE(lun, >lun_list, links, next_lun) {
/*
 * Drop our lock here.  Since ctl_invalidate_lun() can call
 * back into us, this could potentially lead to a recursive
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288771 - stable/10/sys/cam/scsi

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:38:32 2015
New Revision: 288771
URL: https://svnweb.freebsd.org/changeset/base/288771

Log:
  MFC r287955: Update list of ASC/ASCQ codes from 5/20/12 to 8/12/15.

Modified:
  stable/10/sys/cam/scsi/scsi_all.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/scsi/scsi_all.c
==
--- stable/10/sys/cam/scsi/scsi_all.c   Mon Oct  5 10:37:20 2015
(r288770)
+++ stable/10/sys/cam/scsi/scsi_all.c   Mon Oct  5 10:38:32 2015
(r288771)
@@ -969,7 +969,7 @@ static struct asc_table_entry asc_table[
 *
 * SCSI ASC/ASCQ Assignments
 * Numeric Sorted Listing
-* as of  5/20/12
+* as of  8/12/15
 *
 * D - DIRECT ACCESS DEVICE (SBC-2)   device column key
 * .T - SEQUENTIAL ACCESS DEVICE (SSC)   ---
@@ -1061,6 +1061,9 @@ static struct asc_table_entry asc_table[
/* DT P  B*/
{ SST(0x00, 0x20, SS_RDEF,  /* XXX TBD */
"Extended copy information available") },
+   /* D  */
+   { SST(0x00, 0x21, SS_RDEF,  /* XXX TBD */
+   "Atomic command aborted due to ACA") },
/* D   W O   BK   */
{ SST(0x01, 0x00, SS_RDEF,
"No index/sector signal") },
@@ -1118,6 +1121,9 @@ static struct asc_table_entry asc_table[
/*  F */
{ SST(0x04, 0x0D, SS_RDEF,  /* XXX TBD */
"Logical unit not ready, structure check required") },
+   /* DTL WR MAEBKVF */
+   { SST(0x04, 0x0E, SS_RDEF,  /* XXX TBD */
+   "Logical unit not ready, security session in progress") },
/* DT  WROM  B*/
{ SST(0x04, 0x10, SS_RDEF,  /* XXX TBD */
"Logical unit not ready, auxiliary memory not accessible") },
@@ -1157,6 +1163,24 @@ static struct asc_table_entry asc_table[
/* DT MAEB*/
{ SST(0x04, 0x1C, SS_RDEF,  /* XXX TBD */
"Logical unit not ready, additional power use not yet granted") },
+   /* D  */
+   { SST(0x04, 0x1D, SS_RDEF,  /* XXX TBD */
+   "Logical unit not ready, configuration in progress") },
+   /* D  */
+   { SST(0x04, 0x1E, SS_FATAL | ENXIO,
+   "Logical unit not ready, microcode activation required") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x04, 0x1F, SS_FATAL | ENXIO,
+   "Logical unit not ready, microcode download required") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x04, 0x20, SS_RDEF,  /* XXX TBD */
+   "Logical unit not ready, logical unit reset required") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x04, 0x21, SS_RDEF,  /* XXX TBD */
+   "Logical unit not ready, hard reset required") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x04, 0x22, SS_RDEF,  /* XXX TBD */
+   "Logical unit not ready, power cycle required") },
/* DTL WROMAEBKVF */
{ SST(0x05, 0x00, SS_RDEF,
"Logical unit does not respond to selection") },
@@ -1196,6 +1220,9 @@ static struct asc_table_entry asc_table[
/* DT  WRO   B*/
{ SST(0x09, 0x04, SS_RDEF,
"Head select fault") },
+   /* DT   RO   B*/
+   { SST(0x09, 0x05, SS_RDEF,
+   "Vibration induced tracking error") },
/* DTLPWROMAEBKVF */
{ SST(0x0A, 0x00, SS_FATAL | ENOSPC,
"Error log overflow") },
@@ -1229,6 +1256,30 @@ static struct asc_table_entry asc_table[
/* D  */
{ SST(0x0B, 0x09, SS_RDEF,  /* XXX TBD */
"Warning - device statistics notification available") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x0B, 0x0A, SS_RDEF,  /* XXX TBD */
+   "Warning - High critical temperature limit exceeded") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x0B, 0x0B, SS_RDEF,  /* XXX TBD */
+   "Warning - Low critical temperature limit exceeded") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x0B, 0x0C, SS_RDEF,  /* XXX TBD */
+   "Warning - High operating temperature limit exceeded") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x0B, 0x0D, SS_RDEF,  /* XXX TBD */
+   "Warning - Low operating temperature limit exceeded") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x0B, 0x0E, SS_RDEF,  /* XXX TBD */
+   "Warning - High citical humidity limit exceeded") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x0B, 0x0F, SS_RDEF,  /* XXX TBD */
+   "Warning - Low citical humidity limit exceeded") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x0B, 0x10, SS_RDEF,  /* XXX TBD */
+   "Warning - High operating humidity limit exceeded") },
+   /* DTLPWROMAEBKVF */
+   { SST(0x0B, 0x11, SS_RDEF,  /* XXX TBD */
+   "Warning - Low operating humidity limit exceeded") },
/*  T   R */
{ 

svn commit: r288776 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:42:58 2015
New Revision: 288776
URL: https://svnweb.freebsd.org/changeset/base/288776

Log:
  MFC r287986: Fix memory corruption when >128K transferred through HA link.
  
  While there, do some cleaning.

Modified:
  stable/10/sys/cam/ctl/ctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:42:07 2015(r288775)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:42:58 2015(r288776)
@@ -1082,7 +1082,7 @@ ctl_isc_event_handler(ctl_ha_channel cha
 
if (msg->dt.sg_sequence == 0) {
i = msg->dt.kern_sg_entries +
-   io->scsiio.kern_data_len /
+   msg->dt.kern_data_len /
CTL_HA_DATAMOVE_SEGMENT + 1;
sgl = malloc(sizeof(*sgl) * i, M_CTL,
M_WAITOK | M_ZERO);
@@ -1118,11 +1118,8 @@ ctl_isc_event_handler(ctl_ha_channel cha
sgl[i].len = msg->dt.sg_list[j].len;
 
 #if 0
-   printf("%s: L: %p,%d -> %p,%d j=%d, i=%d\n",
-  __func__,
-  msg->dt.sg_list[j].addr,
-  msg->dt.sg_list[j].len,
-  sgl[i].addr, sgl[i].len, j, i);
+   printf("%s: DATAMOVE: %p,%lu j=%d, i=%d\n",
+   __func__, sgl[i].addr, sgl[i].len, j, i);
 #endif
}
 
@@ -12539,11 +12536,8 @@ ctl_datamove_remote_dm_write_cb(union ct
 {
int retval;
 
-   retval = 0;
-
retval = ctl_datamove_remote_xfer(io, CTL_HA_DT_CMD_WRITE,
  ctl_datamove_remote_write_cb);
-
return (retval);
 }
 
@@ -12573,11 +12567,7 @@ ctl_datamove_remote_write(union ctl_io *
io->scsiio.be_move_done = ctl_datamove_remote_dm_write_cb;
 
fe_datamove = ctl_io_port(>io_hdr)->fe_datamove;
-
fe_datamove(io);
-
-   return;
-
 }
 
 static int
@@ -12652,14 +12642,13 @@ ctl_datamove_remote_read_cb(struct ctl_h
/* XXX KDM add checks like the ones in ctl_datamove? */
 
fe_datamove = ctl_io_port(>io_hdr)->fe_datamove;
-
fe_datamove(io);
 }
 
 static int
 ctl_datamove_remote_sgl_setup(union ctl_io *io)
 {
-   struct ctl_sg_entry *local_sglist, *remote_sglist;
+   struct ctl_sg_entry *local_sglist;
struct ctl_softc *softc;
uint32_t len_to_go;
int retval;
@@ -12668,7 +12657,6 @@ ctl_datamove_remote_sgl_setup(union ctl_
retval = 0;
softc = control_softc;
local_sglist = io->io_hdr.local_sglist;
-   remote_sglist = io->io_hdr.remote_sglist;
len_to_go = io->scsiio.kern_data_len;
 
/*
@@ -12694,7 +12682,7 @@ ctl_datamove_remote_sgl_setup(union ctl_
printf("%s: kern_sg_entries = %d\n", __func__,
   io->scsiio.kern_sg_entries);
for (i = 0; i < io->scsiio.kern_sg_entries; i++)
-   printf("%s: sg[%d] = %p, %d\n", __func__, i,
+   printf("%s: sg[%d] = %p, %lu\n", __func__, i,
   local_sglist[i].addr, local_sglist[i].len);
 #endif
 
@@ -12812,7 +12800,7 @@ ctl_datamove_remote_xfer(union ctl_io *i
rq->callback = callback;
 
 #if 0
-   printf("%s: %s: local %#x remote %#x size %d\n", __func__,
+   printf("%s: %s: local %p remote %p size %d\n", __func__,
   (command == CTL_HA_DT_CMD_WRITE) ? "WRITE" : "READ",
   rq->local, rq->remote, rq->size);
 #endif
@@ -12858,8 +12846,6 @@ ctl_datamove_remote_read(union ctl_io *i
io->io_hdr.remote_sglist = NULL;
io->io_hdr.local_sglist = NULL;
}
-
-   return;
 }
 
 /*
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288790 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:54:06 2015
New Revision: 288790
URL: https://svnweb.freebsd.org/changeset/base/288790

Log:
  MFC r288148: Synchronize mode pages between HA peers.
  
  We allow to modify only few fields in mode pages now, but still it is
  not good if they unexpectedly change during failover.  Also this fixes
  reporting of "Mode parameters changed" UAs on secondary node.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl.h
  stable/10/sys/cam/ctl/ctl_io.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:53:13 2015(r288789)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:54:06 2015(r288790)
@@ -613,6 +613,14 @@ alloc:
ctl_ha_msg_send(CTL_HA_CHAN_CTL, >port, sizeof(msg->port) + i,
M_WAITOK);
free(msg, M_CTL);
+
+   if (lun->flags & CTL_LUN_PRIMARY_SC) {
+   for (i = 0; i < CTL_NUM_MODE_PAGES; i++) {
+   ctl_isc_announce_mode(lun, -1,
+   lun->mode_pages.index[i].page_code & SMPH_PC_MASK,
+   lun->mode_pages.index[i].subpage);
+   }
+   }
 }
 
 void
@@ -712,6 +720,38 @@ ctl_isc_announce_iid(struct ctl_port *po
free(msg, M_CTL);
 }
 
+void
+ctl_isc_announce_mode(struct ctl_lun *lun, uint32_t initidx,
+uint8_t page, uint8_t subpage)
+{
+   struct ctl_softc *softc = lun->ctl_softc;
+   union ctl_ha_msg msg;
+   int i;
+
+   if (softc->ha_link != CTL_HA_LINK_ONLINE)
+   return;
+   for (i = 0; i < CTL_NUM_MODE_PAGES; i++) {
+   if ((lun->mode_pages.index[i].page_code & SMPH_PC_MASK) ==
+   page && lun->mode_pages.index[i].subpage == subpage)
+   break;
+   }
+   if (i == CTL_NUM_MODE_PAGES)
+   return;
+   bzero(, sizeof(msg.mode));
+   msg.hdr.msg_type = CTL_MSG_MODE_SYNC;
+   msg.hdr.nexus.targ_port = initidx / CTL_MAX_INIT_PER_PORT;
+   msg.hdr.nexus.initid = initidx % CTL_MAX_INIT_PER_PORT;
+   msg.hdr.nexus.targ_lun = lun->lun;
+   msg.hdr.nexus.targ_mapped_lun = lun->lun;
+   msg.mode.page_code = page;
+   msg.mode.subpage = subpage;
+   msg.mode.page_len = lun->mode_pages.index[i].page_len;
+   memcpy(msg.mode.data, lun->mode_pages.index[i].page_data,
+   msg.mode.page_len);
+   ctl_ha_msg_send(CTL_HA_CHAN_CTL, , sizeof(msg.mode),
+   M_WAITOK);
+}
+
 static void
 ctl_isc_ha_link_up(struct ctl_softc *softc)
 {
@@ -1043,6 +1083,44 @@ ctl_isc_login(struct ctl_softc *softc, u
}
 }
 
+static void
+ctl_isc_mode_sync(struct ctl_softc *softc, union ctl_ha_msg *msg, int len)
+{
+   struct ctl_lun *lun;
+   int i;
+   uint32_t initidx, targ_lun;
+
+   targ_lun = msg->hdr.nexus.targ_mapped_lun;
+   mtx_lock(>ctl_lock);
+   if ((targ_lun >= CTL_MAX_LUNS) ||
+   ((lun = softc->ctl_luns[targ_lun]) == NULL)) {
+   mtx_unlock(>ctl_lock);
+   return;
+   }
+   mtx_lock(>lun_lock);
+   mtx_unlock(>ctl_lock);
+   if (lun->flags & CTL_LUN_DISABLED) {
+   mtx_unlock(>lun_lock);
+   return;
+   }
+   for (i = 0; i < CTL_NUM_MODE_PAGES; i++) {
+   if ((lun->mode_pages.index[i].page_code & SMPH_PC_MASK) ==
+   msg->mode.page_code &&
+   lun->mode_pages.index[i].subpage == msg->mode.subpage)
+   break;
+   }
+   if (i == CTL_NUM_MODE_PAGES) {
+   mtx_unlock(>lun_lock);
+   return;
+   }
+   memcpy(lun->mode_pages.index[i].page_data, msg->mode.data,
+   lun->mode_pages.index[i].page_len);
+   initidx = ctl_get_initindex(>hdr.nexus);
+   if (initidx != -1)
+   ctl_est_ua_all(lun, initidx, CTL_UA_MODE_CHANGE);
+   mtx_unlock(>lun_lock);
+}
+
 /*
  * ISC (Inter Shelf Communication) event handler.  Events from the HA
  * subsystem come in here.
@@ -1322,6 +1400,9 @@ ctl_isc_event_handler(ctl_ha_channel cha
case CTL_MSG_LOGIN:
ctl_isc_login(softc, msg, param);
break;
+   case CTL_MSG_MODE_SYNC:
+   ctl_isc_mode_sync(softc, msg, param);
+   break;
default:
printf("Received HA message of unknown type %d\n",
msg->hdr.msg_type);
@@ -5954,7 +6035,11 @@ ctl_control_page_handler(struct ctl_scsi
if (set_ua != 0)
ctl_est_ua_all(lun, initidx, CTL_UA_MODE_CHANGE);
mtx_unlock(>lun_lock);
-
+   if (set_ua) {
+   ctl_isc_announce_mode(lun,
+   ctl_get_initindex(>io_hdr.nexus),
+   page_index->page_code, page_index->subpage);
+   }

svn commit: r288791 - in stable/10/sys/cam: ctl scsi

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:55:08 2015
New Revision: 288791
URL: https://svnweb.freebsd.org/changeset/base/288791

Log:
  MFC r288165: Add support for READ BUFFER(16) command.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_cmd_table.c
  stable/10/sys/cam/scsi/scsi_all.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:54:06 2015(r288790)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:55:08 2015(r288791)
@@ -5612,20 +5612,43 @@ bailout:
 int
 ctl_read_buffer(struct ctl_scsiio *ctsio)
 {
-   struct scsi_read_buffer *cdb;
struct ctl_lun *lun;
-   int buffer_offset, len;
+   uint64_t buffer_offset;
+   uint32_t len;
+   uint8_t byte2;
static uint8_t descr[4];
static uint8_t echo_descr[4] = { 0 };
 
CTL_DEBUG_PRINT(("ctl_read_buffer\n"));
-
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
-   cdb = (struct scsi_read_buffer *)ctsio->cdb;
+   switch (ctsio->cdb[0]) {
+   case READ_BUFFER: {
+   struct scsi_read_buffer *cdb;
 
-   if ((cdb->byte2 & RWB_MODE) != RWB_MODE_DATA &&
-   (cdb->byte2 & RWB_MODE) != RWB_MODE_ECHO_DESCR &&
-   (cdb->byte2 & RWB_MODE) != RWB_MODE_DESCR) {
+   cdb = (struct scsi_read_buffer *)ctsio->cdb;
+   buffer_offset = scsi_3btoul(cdb->offset);
+   len = scsi_3btoul(cdb->length);
+   byte2 = cdb->byte2;
+   break;
+   }
+   case READ_BUFFER_16: {
+   struct scsi_read_buffer_16 *cdb;
+
+   cdb = (struct scsi_read_buffer_16 *)ctsio->cdb;
+   buffer_offset = scsi_8btou64(cdb->offset);
+   len = scsi_4btoul(cdb->length);
+   byte2 = cdb->byte2;
+   break;
+   }
+   default: /* This shouldn't happen. */
+   ctl_set_invalid_opcode(ctsio);
+   ctl_done((union ctl_io *)ctsio);
+   return (CTL_RETVAL_COMPLETE);
+   }
+
+   if ((byte2 & RWB_MODE) != RWB_MODE_DATA &&
+   (byte2 & RWB_MODE) != RWB_MODE_ECHO_DESCR &&
+   (byte2 & RWB_MODE) != RWB_MODE_DESCR) {
ctl_set_invalid_field(ctsio,
  /*sks_valid*/ 1,
  /*command*/ 1,
@@ -5636,10 +5659,8 @@ ctl_read_buffer(struct ctl_scsiio *ctsio
return (CTL_RETVAL_COMPLETE);
}
 
-   len = scsi_3btoul(cdb->length);
-   buffer_offset = scsi_3btoul(cdb->offset);
-
-   if (buffer_offset + len > CTL_WRITE_BUFFER_SIZE) {
+   if (buffer_offset > CTL_WRITE_BUFFER_SIZE ||
+   buffer_offset + len > CTL_WRITE_BUFFER_SIZE) {
ctl_set_invalid_field(ctsio,
  /*sks_valid*/ 1,
  /*command*/ 1,
@@ -5650,12 +5671,12 @@ ctl_read_buffer(struct ctl_scsiio *ctsio
return (CTL_RETVAL_COMPLETE);
}
 
-   if ((cdb->byte2 & RWB_MODE) == RWB_MODE_DESCR) {
+   if ((byte2 & RWB_MODE) == RWB_MODE_DESCR) {
descr[0] = 0;
scsi_ulto3b(CTL_WRITE_BUFFER_SIZE, [1]);
ctsio->kern_data_ptr = descr;
len = min(len, sizeof(descr));
-   } else if ((cdb->byte2 & RWB_MODE) == RWB_MODE_ECHO_DESCR) {
+   } else if ((byte2 & RWB_MODE) == RWB_MODE_ECHO_DESCR) {
ctsio->kern_data_ptr = echo_descr;
len = min(len, sizeof(echo_descr));
} else {

Modified: stable/10/sys/cam/ctl/ctl_cmd_table.c
==
--- stable/10/sys/cam/ctl/ctl_cmd_table.c   Mon Oct  5 10:54:06 2015
(r288790)
+++ stable/10/sys/cam/ctl/ctl_cmd_table.c   Mon Oct  5 10:55:08 2015
(r288791)
@@ -1155,8 +1155,16 @@ const struct ctl_cmd_entry ctl_cmd_table
 /* 9A */
 {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},
 
-/* 9B */
-{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},
+/* 9B READ BUFFER(16) */
+{ctl_read_buffer, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH |
+CTL_CMD_FLAG_OK_ON_STOPPED |
+CTL_CMD_FLAG_OK_ON_INOPERABLE |
+CTL_CMD_FLAG_OK_ON_STANDBY |
+CTL_FLAG_DATA_IN |
+CTL_CMD_FLAG_ALLOW_ON_PR_WRESV,
+ CTL_LUN_PAT_NONE,
+ 10, {0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}},
 
 /* 9C WRITE ATOMIC (16) */
 {ctl_read_write, CTL_SERIDX_WRITE, CTL_CMD_FLAG_OK_ON_SLUN| CTL_FLAG_DATA_OUT,

Modified: stable/10/sys/cam/scsi/scsi_all.h
==
--- 

svn commit: r288801 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:04:13 2015
New Revision: 288801
URL: https://svnweb.freebsd.org/changeset/base/288801

Log:
  MFC r288229: Fix bit masks changed for the wrong commands in r288221.

Modified:
  stable/10/sys/cam/ctl/ctl_cmd_table.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_cmd_table.c
==
--- stable/10/sys/cam/ctl/ctl_cmd_table.c   Mon Oct  5 11:03:24 2015
(r288800)
+++ stable/10/sys/cam/ctl/ctl_cmd_table.c   Mon Oct  5 11:04:13 2015
(r288801)
@@ -134,7 +134,7 @@ const struct ctl_cmd_entry ctl_cmd_table
CTL_FLAG_DATA_OUT |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
  CTL_LUN_PAT_NONE,
- 10, { 0, 0, 0, 0, 0, 0, 0, 0, 0x07}},
+ 10, { 0x01, 0xff, 0, 0, 0xff, 0xff, 0xff, 0xff, 0x07}},
 
 /* 02 RELEASE */
 {ctl_persistent_reserve_out, CTL_SERIDX_RES, CTL_CMD_FLAG_ALLOW_ON_RESV |
@@ -145,7 +145,7 @@ const struct ctl_cmd_entry ctl_cmd_table
CTL_FLAG_DATA_OUT |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
  CTL_LUN_PAT_NONE,
- 10, { 0, 0, 0, 0, 0, 0, 0, 0, 0x07}},
+ 10, { 0x02, 0xff, 0, 0, 0xff, 0xff, 0xff, 0xff, 0x07}},
 
 /* 03 CLEAR */
 {ctl_persistent_reserve_out, CTL_SERIDX_RES, CTL_CMD_FLAG_ALLOW_ON_RESV |
@@ -907,7 +907,7 @@ const struct ctl_cmd_entry ctl_cmd_table
CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_STANDBY |
CTL_FLAG_DATA_OUT,
- CTL_LUN_PAT_NONE, 10, {0x02, 0, 0xff, 0, 0, 0, 0xff, 0xff, 0x07} },
+ CTL_LUN_PAT_NONE, 10, {0, 0, 0, 0, 0, 0, 0, 0, 0x07} },
 
 /* 57 RELEASE(10) */
 {ctl_scsi_release, CTL_SERIDX_RES, CTL_CMD_FLAG_ALLOW_ON_RESV |
@@ -916,7 +916,7 @@ const struct ctl_cmd_entry ctl_cmd_table
   CTL_CMD_FLAG_OK_ON_INOPERABLE |
   CTL_CMD_FLAG_OK_ON_STANDBY |
   CTL_FLAG_DATA_OUT,
- CTL_LUN_PAT_NONE, 10, {0x02, 0, 0xff, 0, 0, 0, 0xff, 0xff, 0x07} },
+ CTL_LUN_PAT_NONE, 10, {0, 0, 0, 0, 0, 0, 0, 0, 0x07}},
 
 /* 58 REPAIR TRACK */
 {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288809 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:29:23 2015
New Revision: 288809
URL: https://svnweb.freebsd.org/changeset/base/288809

Log:
  MFC r288264: Allow LOG SENSE command on non-disk devices.

Modified:
  stable/10/sys/cam/ctl/ctl_cmd_table.c
  stable/10/sys/cam/ctl/ctl_private.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_cmd_table.c
==
--- stable/10/sys/cam/ctl/ctl_cmd_table.c   Mon Oct  5 11:28:26 2015
(r288808)
+++ stable/10/sys/cam/ctl/ctl_cmd_table.c   Mon Oct  5 11:29:23 2015
(r288809)
@@ -866,7 +866,10 @@ const struct ctl_cmd_entry ctl_cmd_table
 {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},
 
 /* 4D LOG SENSE */
-{ctl_log_sense, CTL_SERIDX_LOG_SNS, CTL_CMD_FLAG_OK_ON_SLUN |
+{ctl_log_sense, CTL_SERIDX_LOG_SNS, CTL_CMD_FLAG_OK_ON_BOTH |
+   CTL_CMD_FLAG_OK_ON_STOPPED |
+   CTL_CMD_FLAG_OK_ON_INOPERABLE |
+   CTL_CMD_FLAG_OK_ON_STANDBY |
CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
  CTL_LUN_PAT_NONE, 10, {0, 0xff, 0xff, 0, 0xff, 0xff, 0xff, 0xff, 0x07} },

Modified: stable/10/sys/cam/ctl/ctl_private.h
==
--- stable/10/sys/cam/ctl/ctl_private.h Mon Oct  5 11:28:26 2015
(r288808)
+++ stable/10/sys/cam/ctl/ctl_private.h Mon Oct  5 11:29:23 2015
(r288809)
@@ -306,7 +306,7 @@ static const struct ctl_page_index log_p
{SLS_SUPPORTED_PAGES_PAGE, SLS_SUPPORTED_SUBPAGES_SUBPAGE, 0, NULL,
 CTL_PAGE_FLAG_NONE, NULL, NULL},
{SLS_LOGICAL_BLOCK_PROVISIONING, 0, 0, NULL,
-CTL_PAGE_FLAG_NONE, ctl_lbp_log_sense_handler, NULL},
+CTL_PAGE_FLAG_DISK_ONLY, ctl_lbp_log_sense_handler, NULL},
{SLS_STAT_AND_PERF, 0, 0, NULL,
 CTL_PAGE_FLAG_NONE, ctl_sap_log_sense_handler, NULL},
 };
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288816 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:42:44 2015
New Revision: 288816
URL: https://svnweb.freebsd.org/changeset/base/288816

Log:
  MFC r288369: Really implement PREVENT ALLOW MEDIUM REMOVAL command.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_backend_block.c
  stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
  stable/10/sys/cam/ctl/ctl_cmd_table.c
  stable/10/sys/cam/ctl/ctl_private.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:41:52 2015(r288815)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:42:44 2015(r288816)
@@ -5131,30 +5131,43 @@ ctl_start_stop(struct ctl_scsiio *ctsio)
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
cdb = (struct scsi_start_stop_unit *)ctsio->cdb;
 
-   if ((lun->flags & CTL_LUN_PR_RESERVED)
-&& ((cdb->how & SSS_START)==0)) {
-   uint32_t residx;
+   if ((cdb->how & SSS_PC_MASK) == 0) {
+   if ((lun->flags & CTL_LUN_PR_RESERVED) &&
+   (cdb->how & SSS_START) == 0) {
+   uint32_t residx;
+
+   residx = ctl_get_initindex(>io_hdr.nexus);
+   if (ctl_get_prkey(lun, residx) == 0 ||
+   (lun->pr_res_idx != residx && lun->res_type < 4)) {
 
-   residx = ctl_get_initindex(>io_hdr.nexus);
-   if (ctl_get_prkey(lun, residx) == 0
-|| (lun->pr_res_idx!=residx && lun->res_type < 4)) {
+   ctl_set_reservation_conflict(ctsio);
+   ctl_done((union ctl_io *)ctsio);
+   return (CTL_RETVAL_COMPLETE);
+   }
+   }
 
-   ctl_set_reservation_conflict(ctsio);
+   if ((cdb->how & SSS_LOEJ) &&
+   (lun->flags & CTL_LUN_REMOVABLE) == 0) {
+   ctl_set_invalid_field(ctsio,
+ /*sks_valid*/ 1,
+ /*command*/ 1,
+ /*field*/ 4,
+ /*bit_valid*/ 1,
+ /*bit*/ 1);
ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE);
}
-   }
 
-   if ((cdb->how & SSS_LOEJ) &&
-   (lun->flags & CTL_LUN_REMOVABLE) == 0) {
-   ctl_set_invalid_field(ctsio,
- /*sks_valid*/ 1,
- /*command*/ 1,
- /*field*/ 4,
- /*bit_valid*/ 1,
- /*bit*/ 1);
-   ctl_done((union ctl_io *)ctsio);
-   return (CTL_RETVAL_COMPLETE);
+   if ((cdb->how & SSS_START) == 0 && (cdb->how & SSS_LOEJ) &&
+   lun->prevent_count > 0) {
+   /* "Medium removal prevented" */
+   ctl_set_sense(ctsio, /*current_error*/ 1,
+   /*sense_key*/(lun->flags & CTL_LUN_NO_MEDIA) ?
+SSD_KEY_NOT_READY : SSD_KEY_ILLEGAL_REQUEST,
+   /*asc*/ 0x53, /*ascq*/ 0x02, SSD_ELEM_NONE);
+   ctl_done((union ctl_io *)ctsio);
+   return (CTL_RETVAL_COMPLETE);
+   }
}
 
retval = lun->backend->config_write((union ctl_io *)ctsio);
@@ -5165,11 +5178,14 @@ int
 ctl_prevent_allow(struct ctl_scsiio *ctsio)
 {
struct ctl_lun *lun;
+   struct scsi_prevent *cdb;
int retval;
+   uint32_t initidx;
 
CTL_DEBUG_PRINT(("ctl_prevent_allow\n"));
 
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
+   cdb = (struct scsi_prevent *)ctsio->cdb;
 
if ((lun->flags & CTL_LUN_REMOVABLE) == 0) {
ctl_set_invalid_opcode(ctsio);
@@ -5177,6 +5193,18 @@ ctl_prevent_allow(struct ctl_scsiio *cts
return (CTL_RETVAL_COMPLETE);
}
 
+   initidx = ctl_get_initindex(>io_hdr.nexus);
+   mtx_lock(>lun_lock);
+   if ((cdb->how & PR_PREVENT) &&
+   ctl_is_set(lun->prevent, initidx) == 0) {
+   ctl_set_mask(lun->prevent, initidx);
+   lun->prevent_count++;
+   } else if ((cdb->how & PR_PREVENT) == 0 &&
+   ctl_is_set(lun->prevent, initidx)) {
+   ctl_clear_mask(lun->prevent, initidx);
+   lun->prevent_count--;
+   }
+   mtx_unlock(>lun_lock);
retval = lun->backend->config_write((union ctl_io *)ctsio);
return (retval);
 }
@@ -11807,9 +11835,7 @@ ctl_do_lun_reset(struct ctl_lun *lun, un
 #if 0
uint32_t initidx;
 

svn commit: r288796 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:59:37 2015
New Revision: 288796
URL: https://svnweb.freebsd.org/changeset/base/288796

Log:
  MFC r288213:
  Make HA handle datamove and done in a universal way, using port methods.
  
  Now from primary node point of view requests transferred from secondary
  node should look almost normal and always have valid port.

Modified:
  stable/10/sys/cam/ctl/ctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:58:41 2015(r288795)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:59:37 2015(r288796)
@@ -517,6 +517,151 @@ static struct ctl_frontend ha_frontend =
 };
 
 static void
+ctl_ha_datamove(union ctl_io *io)
+{
+   struct ctl_lun *lun;
+   struct ctl_sg_entry *sgl;
+   union ctl_ha_msg msg;
+   uint32_t sg_entries_sent;
+   int do_sg_copy, i, j;
+
+   lun = (struct ctl_lun *)io->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
+   memset(, 0, sizeof(msg.dt));
+   msg.hdr.msg_type = CTL_MSG_DATAMOVE;
+   msg.hdr.original_sc = io->io_hdr.original_sc;
+   msg.hdr.serializing_sc = io;
+   msg.hdr.nexus = io->io_hdr.nexus;
+   msg.hdr.status = io->io_hdr.status;
+   msg.dt.flags = io->io_hdr.flags;
+
+   /*
+* We convert everything into a S/G list here.  We can't
+* pass by reference, only by value between controllers.
+* So we can't pass a pointer to the S/G list, only as many
+* S/G entries as we can fit in here.  If it's possible for
+* us to get more than CTL_HA_MAX_SG_ENTRIES S/G entries,
+* then we need to break this up into multiple transfers.
+*/
+   if (io->scsiio.kern_sg_entries == 0) {
+   msg.dt.kern_sg_entries = 1;
+#if 0
+   if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) {
+   msg.dt.sg_list[0].addr = io->scsiio.kern_data_ptr;
+   } else {
+   /* XXX KDM use busdma here! */
+   msg.dt.sg_list[0].addr =
+   (void *)vtophys(io->scsiio.kern_data_ptr);
+   }
+#else
+   KASSERT((io->io_hdr.flags & CTL_FLAG_BUS_ADDR) == 0,
+   ("HA does not support BUS_ADDR"));
+   msg.dt.sg_list[0].addr = io->scsiio.kern_data_ptr;
+#endif
+   msg.dt.sg_list[0].len = io->scsiio.kern_data_len;
+   do_sg_copy = 0;
+   } else {
+   msg.dt.kern_sg_entries = io->scsiio.kern_sg_entries;
+   do_sg_copy = 1;
+   }
+
+   msg.dt.kern_data_len = io->scsiio.kern_data_len;
+   msg.dt.kern_total_len = io->scsiio.kern_total_len;
+   msg.dt.kern_data_resid = io->scsiio.kern_data_resid;
+   msg.dt.kern_rel_offset = io->scsiio.kern_rel_offset;
+   msg.dt.sg_sequence = 0;
+
+   /*
+* Loop until we've sent all of the S/G entries.  On the
+* other end, we'll recompose these S/G entries into one
+* contiguous list before processing.
+*/
+   for (sg_entries_sent = 0; sg_entries_sent < msg.dt.kern_sg_entries;
+   msg.dt.sg_sequence++) {
+   msg.dt.cur_sg_entries = MIN((sizeof(msg.dt.sg_list) /
+   sizeof(msg.dt.sg_list[0])),
+   msg.dt.kern_sg_entries - sg_entries_sent);
+   if (do_sg_copy != 0) {
+   sgl = (struct ctl_sg_entry *)io->scsiio.kern_data_ptr;
+   for (i = sg_entries_sent, j = 0;
+i < msg.dt.cur_sg_entries; i++, j++) {
+#if 0
+   if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) {
+   msg.dt.sg_list[j].addr = sgl[i].addr;
+   } else {
+   /* XXX KDM use busdma here! */
+   msg.dt.sg_list[j].addr =
+   (void *)vtophys(sgl[i].addr);
+   }
+#else
+   KASSERT((io->io_hdr.flags &
+   CTL_FLAG_BUS_ADDR) == 0,
+   ("HA does not support BUS_ADDR"));
+   msg.dt.sg_list[j].addr = sgl[i].addr;
+#endif
+   msg.dt.sg_list[j].len = sgl[i].len;
+   }
+   }
+
+   sg_entries_sent += msg.dt.cur_sg_entries;
+   msg.dt.sg_last = (sg_entries_sent >= msg.dt.kern_sg_entries);
+   if (ctl_ha_msg_send(CTL_HA_CHAN_CTL, ,
+   sizeof(msg.dt) - sizeof(msg.dt.sg_list) +
+   sizeof(struct ctl_sg_entry) * msg.dt.cur_sg_entries,
+   M_WAITOK) > CTL_HA_STATUS_SUCCESS) {
+   io->io_hdr.port_status = 31341;
+   

svn commit: r288795 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:58:41 2015
New Revision: 288795
URL: https://svnweb.freebsd.org/changeset/base/288795

Log:
  MFC r288211: Remove some control_softc references.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_backend.c
  stable/10/sys/cam/ctl/ctl_frontend.c
  stable/10/sys/cam/ctl/ctl_frontend.h
  stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
  stable/10/sys/cam/ctl/ctl_ha.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:57:50 2015(r288794)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:58:41 2015(r288795)
@@ -626,7 +626,7 @@ alloc:
 void
 ctl_isc_announce_port(struct ctl_port *port)
 {
-   struct ctl_softc *softc = control_softc;
+   struct ctl_softc *softc = port->ctl_softc;
union ctl_ha_msg *msg;
int i;
 
@@ -687,7 +687,7 @@ ctl_isc_announce_port(struct ctl_port *p
 void
 ctl_isc_announce_iid(struct ctl_port *port, int iid)
 {
-   struct ctl_softc *softc = control_softc;
+   struct ctl_softc *softc = port->ctl_softc;
union ctl_ha_msg *msg;
int i, l;
 
@@ -1128,12 +1128,11 @@ ctl_isc_mode_sync(struct ctl_softc *soft
 static void
 ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_event event, int param)
 {
-   struct ctl_softc *softc;
+   struct ctl_softc *softc = control_softc;
union ctl_io *io;
struct ctl_prio *presio;
ctl_ha_status isc_status;
 
-   softc = control_softc;
CTL_DEBUG_PRINT(("CTL: Isc Msg event %d\n", event));
if (event == CTL_HA_EVT_MSG_RECV) {
union ctl_ha_msg *msg, msgbuf;
@@ -1584,13 +1583,11 @@ ctl_init(void)
int i, error, retval;
 
retval = 0;
-   control_softc = malloc(sizeof(*control_softc), M_DEVBUF,
+   softc = control_softc = malloc(sizeof(*control_softc), M_DEVBUF,
   M_WAITOK | M_ZERO);
-   softc = control_softc;
 
softc->dev = make_dev(_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0600,
  "cam/ctl");
-
softc->dev->si_drv1 = softc;
 
sysctl_ctx_init(>sysctl_ctx);
@@ -1722,11 +1719,9 @@ ctl_init(void)
 void
 ctl_shutdown(void)
 {
-   struct ctl_softc *softc;
+   struct ctl_softc *softc = control_softc;
struct ctl_lun *lun, *next_lun;
 
-   softc = (struct ctl_softc *)control_softc;
-
if (softc->is_single == 0) {
ctl_ha_msg_shutdown(softc);
if (ctl_ha_msg_deregister(CTL_HA_CHAN_CTL)
@@ -1803,7 +1798,7 @@ ctl_close(struct cdev *dev, int flags, i
 int
 ctl_remove_initiator(struct ctl_port *port, int iid)
 {
-   struct ctl_softc *softc = control_softc;
+   struct ctl_softc *softc = port->ctl_softc;
 
mtx_assert(>ctl_lock, MA_NOTOWNED);
 
@@ -1829,7 +1824,7 @@ ctl_remove_initiator(struct ctl_port *po
 int
 ctl_add_initiator(struct ctl_port *port, int iid, uint64_t wwpn, char *name)
 {
-   struct ctl_softc *softc = control_softc;
+   struct ctl_softc *softc = port->ctl_softc;
time_t best_time;
int i, best;
 
@@ -2004,15 +1999,13 @@ ctl_create_iid(struct ctl_port *port, in
 static int
 ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio)
 {
-   struct ctl_softc *softc;
+   struct ctl_softc *softc = control_softc;
union ctl_ha_msg msg_info;
struct ctl_lun *lun;
const struct ctl_cmd_entry *entry;
int retval = 0;
uint32_t targ_lun;
 
-   softc = control_softc;
-
targ_lun = ctsio->io_hdr.nexus.targ_mapped_lun;
mtx_lock(>ctl_lock);
if ((targ_lun < CTL_MAX_LUNS) &&
@@ -2379,12 +2372,10 @@ static int
 ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
  struct thread *td)
 {
-   struct ctl_softc *softc;
+   struct ctl_softc *softc = dev->si_drv1;
struct ctl_lun *lun;
int retval;
 
-   softc = control_softc;
-
retval = 0;
 
switch (cmd) {
@@ -3483,7 +3474,7 @@ ctl_get_initindex(struct ctl_nexus *nexu
 int
 ctl_lun_map_init(struct ctl_port *port)
 {
-   struct ctl_softc *softc = control_softc;
+   struct ctl_softc *softc = port->ctl_softc;
struct ctl_lun *lun;
uint32_t i;
 
@@ -3507,7 +3498,7 @@ ctl_lun_map_init(struct ctl_port *port)
 int
 ctl_lun_map_deinit(struct ctl_port *port)
 {
-   struct ctl_softc *softc = control_softc;
+   struct ctl_softc *softc = port->ctl_softc;
struct ctl_lun *lun;
 
if (port->lun_map == NULL)
@@ -4674,14 +4665,11 @@ ctl_free_lun(struct ctl_lun *lun)
 static void
 ctl_create_lun(struct ctl_be_lun *be_lun)
 {
-   struct ctl_softc *softc;
-
-   softc = control_softc;
 
/*
 * ctl_alloc_lun() should handle all potential failure cases.
 */
-   ctl_alloc_lun(softc, NULL, be_lun);
+   ctl_alloc_lun(control_softc, 

svn commit: r288814 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:41:05 2015
New Revision: 288814
URL: https://svnweb.freebsd.org/changeset/base/288814

Log:
  MFC r288367: Fix arguments order.

Modified:
  stable/10/sys/cam/ctl/ctl_tpc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_tpc.c
==
--- stable/10/sys/cam/ctl/ctl_tpc.c Mon Oct  5 11:39:43 2015
(r288813)
+++ stable/10/sys/cam/ctl/ctl_tpc.c Mon Oct  5 11:41:05 2015
(r288814)
@@ -837,7 +837,7 @@ tpc_process_b2b(struct tpc_list *list)
ctl_set_sense(list->ctsio, /*current_error*/ 1,
/*sense_key*/ SSD_KEY_COPY_ABORTED,
/*asc*/ 0x0d, /*ascq*/ 0x01,
-   SSD_ELEM_COMMAND, csi, sizeof(csi),
+   SSD_ELEM_COMMAND, sizeof(csi), csi,
SSD_ELEM_NONE);
return (CTL_RETVAL_ERROR);
}
@@ -854,7 +854,7 @@ tpc_process_b2b(struct tpc_list *list)
ctl_set_sense(list->ctsio, /*current_error*/ 1,
/*sense_key*/ SSD_KEY_COPY_ABORTED,
/*asc*/ 0x08, /*ascq*/ 0x04,
-   SSD_ELEM_COMMAND, csi, sizeof(csi),
+   SSD_ELEM_COMMAND, sizeof(csi), csi,
SSD_ELEM_NONE);
return (CTL_RETVAL_ERROR);
}
@@ -885,7 +885,7 @@ tpc_process_b2b(struct tpc_list *list)
ctl_set_sense(list->ctsio, /*current_error*/ 1,
/*sense_key*/ SSD_KEY_COPY_ABORTED,
/*asc*/ 0x26, /*ascq*/ 0x0A,
-   SSD_ELEM_COMMAND, csi, sizeof(csi),
+   SSD_ELEM_COMMAND, sizeof(csi), csi,
SSD_ELEM_NONE);
return (CTL_RETVAL_ERROR);
}
@@ -986,7 +986,7 @@ tpc_process_verify(struct tpc_list *list
ctl_set_sense(list->ctsio, /*current_error*/ 1,
/*sense_key*/ SSD_KEY_COPY_ABORTED,
/*asc*/ 0x0d, /*ascq*/ 0x01,
-   SSD_ELEM_COMMAND, csi, sizeof(csi),
+   SSD_ELEM_COMMAND, sizeof(csi), csi,
SSD_ELEM_NONE);
return (CTL_RETVAL_ERROR);
} else
@@ -1000,7 +1000,7 @@ tpc_process_verify(struct tpc_list *list
ctl_set_sense(list->ctsio, /*current_error*/ 1,
/*sense_key*/ SSD_KEY_COPY_ABORTED,
/*asc*/ 0x08, /*ascq*/ 0x04,
-   SSD_ELEM_COMMAND, csi, sizeof(csi),
+   SSD_ELEM_COMMAND, sizeof(csi), csi,
SSD_ELEM_NONE);
return (CTL_RETVAL_ERROR);
}
@@ -1050,7 +1050,7 @@ tpc_process_register_key(struct tpc_list
ctl_set_sense(list->ctsio, /*current_error*/ 1,
/*sense_key*/ SSD_KEY_COPY_ABORTED,
/*asc*/ 0x0d, /*ascq*/ 0x01,
-   SSD_ELEM_COMMAND, csi, sizeof(csi),
+   SSD_ELEM_COMMAND, sizeof(csi), csi,
SSD_ELEM_NONE);
return (CTL_RETVAL_ERROR);
} else
@@ -1064,7 +1064,7 @@ tpc_process_register_key(struct tpc_list
ctl_set_sense(list->ctsio, /*current_error*/ 1,
/*sense_key*/ SSD_KEY_COPY_ABORTED,
/*asc*/ 0x08, /*ascq*/ 0x04,
-   SSD_ELEM_COMMAND, csi, sizeof(csi),
+   SSD_ELEM_COMMAND, sizeof(csi), csi,
SSD_ELEM_NONE);
return (CTL_RETVAL_ERROR);
}
@@ -1398,7 +1398,7 @@ tpc_process(struct tpc_list *list)
ctl_set_sense(ctsio, /*current_error*/ 1,
/*sense_key*/ SSD_KEY_COPY_ABORTED,
/*asc*/ 0x26, /*ascq*/ 0x09,
-   SSD_ELEM_COMMAND, csi, sizeof(csi),
+   SSD_ELEM_COMMAND, sizeof(csi), csi,
SSD_ELEM_NONE);
goto done;
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288778 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:44:36 2015
New Revision: 288778
URL: https://svnweb.freebsd.org/changeset/base/288778

Log:
  MFC r287993: Split two command flags with different meaning.
  
  This is only a cosmetical change.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_cmd_table.c
  stable/10/sys/cam/ctl/ctl_private.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:43:45 2015(r288777)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:44:36 2015(r288778)
@@ -11176,7 +11176,7 @@ ctl_scsiio_precheck(struct ctl_softc *so
 * it on the rtr queue.
 */
if (lun == NULL) {
-   if (entry->flags & CTL_CMD_FLAG_OK_ON_ALL_LUNS) {
+   if (entry->flags & CTL_CMD_FLAG_OK_ON_NO_LUN) {
ctsio->io_hdr.flags |= CTL_FLAG_IS_WAS_ON_RTR;
ctl_enqueue_rtr((union ctl_io *)ctsio);
return (retval);
@@ -11394,13 +11394,11 @@ ctl_cmd_applicable(uint8_t lun_type, con
 
switch (lun_type) {
case T_PROCESSOR:
-   if (((entry->flags & CTL_CMD_FLAG_OK_ON_PROC) == 0) &&
-   ((entry->flags & CTL_CMD_FLAG_OK_ON_ALL_LUNS) == 0))
+   if ((entry->flags & CTL_CMD_FLAG_OK_ON_PROC) == 0)
return (0);
break;
case T_DIRECT:
-   if (((entry->flags & CTL_CMD_FLAG_OK_ON_SLUN) == 0) &&
-   ((entry->flags & CTL_CMD_FLAG_OK_ON_ALL_LUNS) == 0))
+   if ((entry->flags & CTL_CMD_FLAG_OK_ON_SLUN) == 0)
return (0);
break;
default:

Modified: stable/10/sys/cam/ctl/ctl_cmd_table.c
==
--- stable/10/sys/cam/ctl/ctl_cmd_table.c   Mon Oct  5 10:43:45 2015
(r288777)
+++ stable/10/sys/cam/ctl/ctl_cmd_table.c   Mon Oct  5 10:44:36 2015
(r288778)
@@ -546,7 +546,8 @@ const struct ctl_cmd_entry ctl_cmd_table
 
 /* 03 REQUEST SENSE */
 {ctl_request_sense, CTL_SERIDX_RQ_SNS, CTL_FLAG_DATA_IN |
-  CTL_CMD_FLAG_OK_ON_ALL_LUNS |
+  CTL_CMD_FLAG_OK_ON_NO_LUN |
+  CTL_CMD_FLAG_OK_ON_BOTH |
   CTL_CMD_FLAG_ALLOW_ON_RESV |
   CTL_CMD_FLAG_NO_SENSE |
   CTL_CMD_FLAG_OK_ON_STOPPED |
@@ -607,7 +608,8 @@ const struct ctl_cmd_entry ctl_cmd_table
 {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},
 
 /* 12 INQUIRY */
-{ctl_inquiry, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_ALL_LUNS |
+{ctl_inquiry, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_NO_LUN |
+ CTL_CMD_FLAG_OK_ON_BOTH |
  CTL_CMD_FLAG_ALLOW_ON_RESV |
  CTL_CMD_FLAG_NO_SENSE |
  CTL_CMD_FLAG_OK_ON_STOPPED |
@@ -1172,7 +1174,8 @@ const struct ctl_cmd_entry ctl_cmd_table
 {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},
 
 /* A0 REPORT LUNS */
-{ctl_report_luns, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_ALL_LUNS |
+{ctl_report_luns, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_NO_LUN |
+ CTL_CMD_FLAG_OK_ON_BOTH |
  CTL_CMD_FLAG_ALLOW_ON_RESV |
  CTL_CMD_FLAG_NO_SENSE |
  CTL_CMD_FLAG_OK_ON_STOPPED |

Modified: stable/10/sys/cam/ctl/ctl_private.h
==
--- stable/10/sys/cam/ctl/ctl_private.h Mon Oct  5 10:43:45 2015
(r288777)
+++ stable/10/sys/cam/ctl/ctl_private.h Mon Oct  5 10:44:36 2015
(r288778)
@@ -91,14 +91,14 @@ typedef enum {
  * WARNING:  Keep the bottom nibble here free, we OR in the data direction
  * flags for each command.
  *
- * Note:  "OK_ON_ALL_LUNS" == we don't have to have a lun configured
+ * Note:  "OK_ON_NO_LUN"   == we don't have to have a lun configured
  *"OK_ON_BOTH" == we have to have a lun configured
  *"SA5"== command has 5-bit service action at byte 1
  */
 typedef enum {
CTL_CMD_FLAG_NONE   = 0x,
CTL_CMD_FLAG_NO_SENSE   = 0x0010,
-   CTL_CMD_FLAG_OK_ON_ALL_LUNS = 0x0020,
+   CTL_CMD_FLAG_OK_ON_NO_LUN   = 0x0020,
CTL_CMD_FLAG_ALLOW_ON_RESV  = 0x0040,
CTL_CMD_FLAG_ALLOW_ON_PR_WRESV  = 0x0080,
CTL_CMD_FLAG_OK_ON_PROC = 0x0100,
@@ -109,7 +109,8 @@ typedef enum {
CTL_CMD_FLAG_OK_ON_STANDBY  = 0x1000,
CTL_CMD_FLAG_OK_ON_UNAVAIL  = 0x2000,
CTL_CMD_FLAG_ALLOW_ON_PR_RESV   = 0x4000,
-   CTL_CMD_FLAG_SA5= 0x8000

svn commit: r288777 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:43:45 2015
New Revision: 288777
URL: https://svnweb.freebsd.org/changeset/base/288777

Log:
  MFC r287991: Pack struct ctl_ha_msg_hdr by 8 bytes.

Modified:
  stable/10/sys/cam/ctl/ctl_io.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_io.h
==
--- stable/10/sys/cam/ctl/ctl_io.h  Mon Oct  5 10:42:58 2015
(r288776)
+++ stable/10/sys/cam/ctl/ctl_io.h  Mon Oct  5 10:43:45 2015
(r288777)
@@ -385,10 +385,10 @@ struct ctl_pr_info {
 
 struct ctl_ha_msg_hdr {
ctl_msg_typemsg_type;
+   uint32_tstatus;  /* transaction status */
union ctl_io*original_sc;
union ctl_io*serializing_sc;
struct ctl_nexusnexus;   /* Initiator, port, target, lun */
-   uint32_tstatus;  /* transaction status */
 };
 
 #defineCTL_HA_MAX_SG_ENTRIES   16
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288793 - in stable/10/sys/cam: ctl scsi

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:56:57 2015
New Revision: 288793
URL: https://svnweb.freebsd.org/changeset/base/288793

Log:
  MFC r288170: Add new report types to REPORT LUNS command.
  
  This is only for completeness, since we have nothing new to report there.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/scsi/scsi_all.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:56:04 2015(r288792)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:56:57 2015(r288793)
@@ -9267,12 +9267,10 @@ ctl_report_luns(struct ctl_scsiio *ctsio
struct ctl_port *port;
int num_luns, retval;
uint32_t alloc_len, lun_datalen;
-   int num_filled, well_known;
+   int num_filled;
uint32_t initidx, targ_lun_id, lun_id;
 
retval = CTL_RETVAL_COMPLETE;
-   well_known = 0;
-
cdb = (struct scsi_report_luns *)ctsio->cdb;
port = ctl_io_port(>io_hdr);
 
@@ -9289,9 +9287,11 @@ ctl_report_luns(struct ctl_scsiio *ctsio
switch (cdb->select_report) {
case RPL_REPORT_DEFAULT:
case RPL_REPORT_ALL:
+   case RPL_REPORT_NONSUBSID:
break;
case RPL_REPORT_WELLKNOWN:
-   well_known = 1;
+   case RPL_REPORT_ADMIN:
+   case RPL_REPORT_CONGLOM:
num_luns = 0;
break;
default:

Modified: stable/10/sys/cam/scsi/scsi_all.h
==
--- stable/10/sys/cam/scsi/scsi_all.h   Mon Oct  5 10:56:04 2015
(r288792)
+++ stable/10/sys/cam/scsi/scsi_all.h   Mon Oct  5 10:56:57 2015
(r288793)
@@ -2864,6 +2864,9 @@ struct scsi_report_luns
 #defineRPL_REPORT_DEFAULT  0x00
 #defineRPL_REPORT_WELLKNOWN0x01
 #defineRPL_REPORT_ALL  0x02
+#defineRPL_REPORT_ADMIN0x10
+#defineRPL_REPORT_NONSUBSID0x11
+#defineRPL_REPORT_CONGLOM  0x12
uint8_t select_report;
uint8_t reserved2[3];
uint8_t length[4];
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288794 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:57:50 2015
New Revision: 288794
URL: https://svnweb.freebsd.org/changeset/base/288794

Log:
  MFC r288175: Allow WRITE SAME with NDOB bit set but without UNMAP.
  
  This combination was originally forbidden, but allowed at spc4r3.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_backend_block.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:56:57 2015(r288793)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:57:50 2015(r288794)
@@ -5810,9 +5810,8 @@ ctl_write_same(struct ctl_scsiio *ctsio)
break; /* NOTREACHED */
}
 
-   /* NDOB and ANCHOR flags can be used only together with UNMAP */
-   if ((byte2 & SWS_UNMAP) == 0 &&
-   (byte2 & (SWS_NDOB | SWS_ANCHOR)) != 0) {
+   /* ANCHOR flag can be used only together with UNMAP */
+   if ((byte2 & SWS_UNMAP) == 0 && (byte2 & SWS_ANCHOR) != 0) {
ctl_set_invalid_field(ctsio, /*sks_valid*/ 1,
/*command*/ 1, /*field*/ 1, /*bit_valid*/ 1, /*bit*/ 0);
ctl_done((union ctl_io *)ctsio);

Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==
--- stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 10:56:57 2015
(r288793)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 10:57:50 2015
(r288794)
@@ -1360,7 +1360,12 @@ ctl_be_block_cw_dispatch_ws(struct ctl_b
buf = beio->sg_segs[i].addr;
end = buf + seglen;
for (; buf < end; buf += cbe_lun->blocksize) {
-   memcpy(buf, io->scsiio.kern_data_ptr, 
cbe_lun->blocksize);
+   if (lbalen->flags & SWS_NDOB) {
+   memset(buf, 0, cbe_lun->blocksize);
+   } else {
+   memcpy(buf, io->scsiio.kern_data_ptr,
+   cbe_lun->blocksize);
+   }
if (lbalen->flags & SWS_LBDATA)
scsi_ulto4b(lbalen->lba + lba, buf);
lba++;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288805 - in stable/10: sys/cam/ctl usr.sbin/ctladm usr.sbin/ctld

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:25:48 2015
New Revision: 288805
URL: https://svnweb.freebsd.org/changeset/base/288805

Log:
  MFC r288259: Remove some duplicate, legacy, dead and questionable code.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_backend_block.c
  stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
  stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c
  stable/10/sys/cam/ctl/ctl_ioctl.h
  stable/10/sys/cam/ctl/ctl_private.h
  stable/10/sys/cam/ctl/ctl_util.c
  stable/10/sys/cam/ctl/ctl_util.h
  stable/10/usr.sbin/ctladm/ctladm.8
  stable/10/usr.sbin/ctladm/ctladm.c
  stable/10/usr.sbin/ctld/kernel.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:24:51 2015(r288804)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:25:48 2015(r288805)
@@ -1756,12 +1756,7 @@ ctl_init(void)
softc->io_zone = uma_zcreate("CTL IO", sizeof(union ctl_io),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
softc->open_count = 0;
-
-   /*
-* Default to actually sending a SYNCHRONIZE CACHE command down to
-* the drive.
-*/
-   softc->flags = CTL_FLAG_REAL_SYNC;
+   softc->flags = 0;
 
SYSCTL_ADD_INT(>sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "ha_mode", CTLFLAG_RDTUN, (int *)>ha_mode, 0,
@@ -2588,112 +2583,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
mtx_unlock(>ctl_lock);
break;
}
-   case CTL_GET_PORT_LIST: {
-   struct ctl_port *port;
-   struct ctl_port_list *list;
-   int i;
-
-   list = (struct ctl_port_list *)addr;
-
-   if (list->alloc_len != (list->alloc_num *
-   sizeof(struct ctl_port_entry))) {
-   printf("%s: CTL_GET_PORT_LIST: alloc_len %u != "
-  "alloc_num %u * sizeof(struct ctl_port_entry) "
-  "%zu\n", __func__, list->alloc_len,
-  list->alloc_num, sizeof(struct ctl_port_entry));
-   retval = EINVAL;
-   break;
-   }
-   list->fill_len = 0;
-   list->fill_num = 0;
-   list->dropped_num = 0;
-   i = 0;
-   mtx_lock(>ctl_lock);
-   STAILQ_FOREACH(port, >port_list, links) {
-   struct ctl_port_entry entry, *list_entry;
-
-   if (list->fill_num >= list->alloc_num) {
-   list->dropped_num++;
-   continue;
-   }
-
-   entry.port_type = port->port_type;
-   strlcpy(entry.port_name, port->port_name,
-   sizeof(entry.port_name));
-   entry.targ_port = port->targ_port;
-   entry.physical_port = port->physical_port;
-   entry.virtual_port = port->virtual_port;
-   entry.wwnn = port->wwnn;
-   entry.wwpn = port->wwpn;
-   if (port->status & CTL_PORT_STATUS_ONLINE)
-   entry.online = 1;
-   else
-   entry.online = 0;
-
-   list_entry = >entries[i];
-
-   retval = copyout(, list_entry, sizeof(entry));
-   if (retval != 0) {
-   printf("%s: CTL_GET_PORT_LIST: copyout "
-  "returned %d\n", __func__, retval);
-   break;
-   }
-   i++;
-   list->fill_num++;
-   list->fill_len += sizeof(entry);
-   }
-   mtx_unlock(>ctl_lock);
-
-   /*
-* If this is non-zero, we had a copyout fault, so there's
-* probably no point in attempting to set the status inside
-* the structure.
-*/
-   if (retval != 0)
-   break;
-
-   if (list->dropped_num > 0)
-   list->status = CTL_PORT_LIST_NEED_MORE_SPACE;
-   else
-   list->status = CTL_PORT_LIST_OK;
-   break;
-   }
-   case CTL_DUMP_OOA: {
-   union ctl_io *io;
-   char printbuf[128];
-   struct sbuf sb;
-
-   mtx_lock(>ctl_lock);
-   printf("Dumping OOA queues:\n");
-   STAILQ_FOREACH(lun, >lun_list, links) {
-   mtx_lock(>lun_lock);
-   for (io = (union ctl_io *)TAILQ_FIRST(
->ooa_queue); io != NULL;
-

svn commit: r288804 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:24:51 2015
New Revision: 288804
URL: https://svnweb.freebsd.org/changeset/base/288804

Log:
  MFC r288247: Pass to sobind() copy of the address, not the original.

Modified:
  stable/10/sys/cam/ctl/ctl_ha.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_ha.c
==
--- stable/10/sys/cam/ctl/ctl_ha.c  Mon Oct  5 11:05:56 2015
(r288803)
+++ stable/10/sys/cam/ctl/ctl_ha.c  Mon Oct  5 11:24:51 2015
(r288804)
@@ -427,6 +427,7 @@ static int
 ctl_ha_connect(struct ha_softc *softc)
 {
struct thread *td = curthread;
+   struct sockaddr_in sa;
struct socket *so;
int error;
 
@@ -440,7 +441,8 @@ ctl_ha_connect(struct ha_softc *softc)
softc->ha_so = so;
ctl_ha_sock_setup(softc);
 
-   error = soconnect(so, (struct sockaddr *)>ha_peer_in, td);
+   memcpy(, >ha_peer_in, sizeof(sa));
+   error = soconnect(so, (struct sockaddr *), td);
if (error != 0) {
printf("%s: soconnect() error %d\n", __func__, error);
goto out;
@@ -517,6 +519,7 @@ static int
 ctl_ha_listen(struct ha_softc *softc)
 {
struct thread *td = curthread;
+   struct sockaddr_in sa;
struct sockopt opt;
int error, val;
 
@@ -557,7 +560,8 @@ ctl_ha_listen(struct ha_softc *softc)
SOCKBUF_UNLOCK(>ha_lso->so_rcv);
}
 
-   error = sobind(softc->ha_lso, (struct sockaddr *)>ha_peer_in, 
td);
+   memcpy(, >ha_peer_in, sizeof(sa));
+   error = sobind(softc->ha_lso, (struct sockaddr *), td);
if (error != 0) {
printf("%s: sobind() error %d\n", __func__, error);
goto out;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288773 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:40:15 2015
New Revision: 288773
URL: https://svnweb.freebsd.org/changeset/base/288773

Log:
  MFC r287957: Kill HA link and shutdown the threads on shutdown.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_ha.c
  stable/10/sys/cam/ctl/ctl_ha.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:39:21 2015(r288772)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:40:15 2015(r288773)
@@ -1583,13 +1583,12 @@ ctl_shutdown(void)
softc = (struct ctl_softc *)control_softc;
 
if (softc->is_single == 0) {
+   ctl_ha_msg_shutdown(softc);
if (ctl_ha_msg_deregister(CTL_HA_CHAN_CTL)
-   != CTL_HA_STATUS_SUCCESS) {
-   printf("ctl_shutdown: ctl_ha_msg_deregister failed.\n");
-   }
-   if (ctl_ha_msg_shutdown(softc) != CTL_HA_STATUS_SUCCESS) {
-   printf("ctl_shutdown: ctl_ha_msg_shutdown failed.\n");
-   }
+   != CTL_HA_STATUS_SUCCESS)
+   printf("%s: ctl_ha_msg_deregister failed.\n", __func__);
+   if (ctl_ha_msg_destroy(softc) != CTL_HA_STATUS_SUCCESS)
+   printf("%s: ctl_ha_msg_destroy failed.\n", __func__);
ctl_frontend_deregister(_frontend);
}
 

Modified: stable/10/sys/cam/ctl/ctl_ha.c
==
--- stable/10/sys/cam/ctl/ctl_ha.c  Mon Oct  5 10:39:21 2015
(r288772)
+++ stable/10/sys/cam/ctl/ctl_ha.c  Mon Oct  5 10:40:15 2015
(r288773)
@@ -155,6 +155,8 @@ struct ha_softc {
int  ha_receiving;
int  ha_wakeup;
int  ha_disconnect;
+   int  ha_shutdown;
+   eventhandler_tag ha_shutdown_eh;
TAILQ_HEAD(, ctl_ha_dt_req) ha_dts;
 } ha_softc;
 
@@ -568,10 +570,12 @@ ctl_ha_conn_thread(void *arg)
int error;
 
while (1) {
-   if (softc->ha_disconnect) {
+   if (softc->ha_disconnect || softc->ha_shutdown) {
ctl_ha_close(softc);
ctl_ha_lclose(softc);
softc->ha_disconnect = 0;
+   if (softc->ha_shutdown)
+   break;
} else if (softc->ha_so != NULL &&
(softc->ha_so->so_error ||
 softc->ha_so->so_rcv.sb_state & SBS_CANTRCVMORE))
@@ -614,6 +618,11 @@ ctl_ha_conn_thread(void *arg)
softc->ha_wakeup = 0;
mtx_unlock(>ha_lock);
}
+   mtx_lock(>ha_lock);
+   softc->ha_shutdown = 2;
+   wakeup(>ha_wakeup);
+   mtx_unlock(>ha_lock);
+   kthread_exit();
 }
 
 static int
@@ -936,6 +945,8 @@ ctl_ha_msg_init(struct ctl_softc *ctl_so
mtx_destroy(>ha_lock);
return (CTL_HA_STATUS_ERROR);
}
+   softc->ha_shutdown_eh = EVENTHANDLER_REGISTER(shutdown_pre_sync,
+   ctl_ha_msg_shutdown, ctl_softc, SHUTDOWN_PRI_FIRST);
SYSCTL_ADD_PROC(_softc->sysctl_ctx,
SYSCTL_CHILDREN(ctl_softc->sysctl_tree),
OID_AUTO, "ha_peer", CTLTYPE_STRING | CTLFLAG_RWTUN,
@@ -949,14 +960,40 @@ ctl_ha_msg_init(struct ctl_softc *ctl_so
return (CTL_HA_STATUS_SUCCESS);
 };
 
-ctl_ha_status
+void
 ctl_ha_msg_shutdown(struct ctl_softc *ctl_softc)
 {
struct ha_softc *softc = _softc;
 
-   if (ctl_ha_msg_deregister(CTL_HA_CHAN_DATA) != CTL_HA_STATUS_SUCCESS) {
-   printf("%s: ctl_ha_msg_deregister failed.\n", __func__);
+   /* Disconnect and shutdown threads. */
+   mtx_lock(>ha_lock);
+   if (softc->ha_shutdown < 2) {
+   softc->ha_shutdown = 1;
+   softc->ha_wakeup = 1;
+   wakeup(>ha_wakeup);
+   while (softc->ha_shutdown < 2) {
+   msleep(>ha_wakeup, >ha_lock, 0,
+   "shutdown", hz);
+   }
}
+   mtx_unlock(>ha_lock);
+};
+
+ctl_ha_status
+ctl_ha_msg_destroy(struct ctl_softc *ctl_softc)
+{
+   struct ha_softc *softc = _softc;
+
+   if (softc->ha_shutdown_eh != NULL) {
+   EVENTHANDLER_DEREGISTER(shutdown_pre_sync,
+   softc->ha_shutdown_eh);
+   softc->ha_shutdown_eh = NULL;
+   }
+
+   ctl_ha_msg_shutdown(ctl_softc); /* Just in case. */
+
+   if (ctl_ha_msg_deregister(CTL_HA_CHAN_DATA) != CTL_HA_STATUS_SUCCESS)
+   printf("%s: ctl_ha_msg_deregister failed.\n", __func__);
 
mtx_destroy(>ha_lock);
return (CTL_HA_STATUS_SUCCESS);

Modified: stable/10/sys/cam/ctl/ctl_ha.h
==
--- 

svn commit: r288774 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:41:08 2015
New Revision: 288774
URL: https://svnweb.freebsd.org/changeset/base/288774

Log:
  MFC r287967: Relax serseq option operation for reads.
  
  Previously, with serseq enabled, next command was unblocked only after
  previous completed.  With this change, for read operations, next command
  is unblocked as soon as last media read completed.  This is important
  for frontends that actually wait for data move completion (like camtgt),
  or when data are moved through the HA link, or especially when both.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl.h
  stable/10/sys/cam/ctl/ctl_backend_block.c
  stable/10/sys/cam/ctl/ctl_io.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:40:15 2015(r288773)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:41:08 2015(r288774)
@@ -10594,6 +10594,8 @@ ctl_extent_check(union ctl_io *io1, unio
if (ctl_get_lba_len(io1, , ) != 0)
return (CTL_ACTION_ERROR);
 
+   if (io1->io_hdr.flags & CTL_FLAG_SERSEQ_DONE)
+   seq = FALSE;
return (ctl_extent_check_lba(lba1, len1, lba2, len2, seq));
 }
 
@@ -10603,6 +10605,8 @@ ctl_extent_check_seq(union ctl_io *io1, 
uint64_t lba1, lba2;
uint64_t len1, len2;
 
+   if (io1->io_hdr.flags & CTL_FLAG_SERSEQ_DONE)
+   return (CTL_ACTION_PASS);
if (ctl_get_lba_len(io1, , ) != 0)
return (CTL_ACTION_ERROR);
if (ctl_get_lba_len(io2, , ) != 0)
@@ -13220,6 +13224,21 @@ ctl_done_timer_wakeup(void *arg)
 #endif /* CTL_IO_DELAY */
 
 void
+ctl_serseq_done(union ctl_io *io)
+{
+   struct ctl_lun *lun;
+
+   lun = (struct ctl_lun *)io->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
+   if (lun->be_lun == NULL ||
+   lun->be_lun->serseq == CTL_LUN_SERSEQ_OFF)
+   return;
+   mtx_lock(>lun_lock);
+   io->io_hdr.flags |= CTL_FLAG_SERSEQ_DONE;
+   ctl_check_blocked(lun);
+   mtx_unlock(>lun_lock);
+}
+
+void
 ctl_done(union ctl_io *io)
 {
 

Modified: stable/10/sys/cam/ctl/ctl.h
==
--- stable/10/sys/cam/ctl/ctl.h Mon Oct  5 10:40:15 2015(r288773)
+++ stable/10/sys/cam/ctl/ctl.h Mon Oct  5 10:41:08 2015(r288774)
@@ -172,6 +172,7 @@ int ctl_sap_log_sense_handler(struct ctl
   int pc);
 int ctl_config_move_done(union ctl_io *io);
 void ctl_datamove(union ctl_io *io);
+void ctl_serseq_done(union ctl_io *io);
 void ctl_done(union ctl_io *io);
 void ctl_data_submit_done(union ctl_io *io);
 void ctl_config_read_done(union ctl_io *io);

Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==
--- stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 10:40:15 2015
(r288773)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 10:41:08 2015
(r288774)
@@ -565,8 +565,10 @@ ctl_be_block_biodone(struct bio *bio)
ctl_complete_beio(beio);
} else {
if ((ARGS(io)->flags & CTL_LLF_READ) &&
-   beio->beio_cont == NULL)
+   beio->beio_cont == NULL) {
ctl_set_success(>scsiio);
+   ctl_serseq_done(io);
+   }
 #ifdef CTL_TIME_IO
getbintime(>io_hdr.dma_start_bt);
 #endif  
@@ -785,8 +787,10 @@ ctl_be_block_dispatch_file(struct ctl_be
ctl_complete_beio(beio);
} else {
if ((ARGS(io)->flags & CTL_LLF_READ) &&
-   beio->beio_cont == NULL)
+   beio->beio_cont == NULL) {
ctl_set_success(>scsiio);
+   ctl_serseq_done(io);
+   }
 #ifdef CTL_TIME_IO
getbintime(>io_hdr.dma_start_bt);
 #endif  
@@ -954,8 +958,10 @@ ctl_be_block_dispatch_zvol(struct ctl_be
ctl_complete_beio(beio);
} else {
if ((ARGS(io)->flags & CTL_LLF_READ) &&
-   beio->beio_cont == NULL)
+   beio->beio_cont == NULL) {
ctl_set_success(>scsiio);
+   ctl_serseq_done(io);
+   }
 #ifdef CTL_TIME_IO
getbintime(>io_hdr.dma_start_bt);
 #endif  

Modified: stable/10/sys/cam/ctl/ctl_io.h
==
--- stable/10/sys/cam/ctl/ctl_io.h  Mon Oct  5 10:40:15 2015
(r288773)
+++ stable/10/sys/cam/ctl/ctl_io.h  Mon Oct  5 10:41:08 2015
(r288774)
@@ -115,7 +115,8 @@ typedef enum {
 
CTL_FLAG_FAILOVER   = 0x0400,   /* Killed by a failover */
CTL_FLAG_IO_ACTIVE  = 0x0800,   /* I/O active on this SC 

svn commit: r288783 - stable/10/usr.bin/ctlstat

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:48:14 2015
New Revision: 288783
URL: https://svnweb.freebsd.org/changeset/base/288783

Log:
  MFC r288043:
  Output times as normal microseconds, rather then in bintime format.

Modified:
  stable/10/usr.bin/ctlstat/ctlstat.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/ctlstat/ctlstat.c
==
--- stable/10/usr.bin/ctlstat/ctlstat.c Mon Oct  5 10:47:18 2015
(r288782)
+++ stable/10/usr.bin/ctlstat/ctlstat.c Mon Oct  5 10:48:14 2015
(r288783)
@@ -326,8 +326,8 @@ compute_stats(struct ctl_lun_io_stats *c
  */
 
 #definePRINT_BINTIME(prefix, bt) \
-   printf("%s %jd s %ju frac\n", prefix, (intmax_t)(bt).sec, \
-  (uintmax_t)(bt).frac)
+   printf("%s %jd.%06ju\n", prefix, (intmax_t)(bt).sec, \
+  (uintmax_t)(((bt).frac >> 32) * 100 >> 32))
 static const char *iotypes[] = {"NO IO", "READ", "WRITE"};
 
 static void
@@ -360,9 +360,8 @@ ctlstat_dump(struct ctlstat_context *ctx
 }
 
 #defineJSON_BINTIME(prefix, bt) \
-   printf("\"%s\":{\"sec\":%jd,\"frac\":%ju},", \
-   prefix, (intmax_t)(bt).sec, (uintmax_t)(bt).frac)
-
+   printf("\"%s\":%jd.%06ju,", prefix, (intmax_t)(bt).sec, \
+   (uintmax_t)(((bt).frac >> 32) * 100 >> 32))
 static void
 ctlstat_json(struct ctlstat_context *ctx) {
int iotype, lun, port;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288782 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:47:18 2015
New Revision: 288782
URL: https://svnweb.freebsd.org/changeset/base/288782

Log:
  MFC r288021: Mark with DMA flag I/Os waiting for iSCSI write data after R2T.
  
  Reads and immediate writes are not blocking, so don't bother.

Modified:
  stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
==
--- stable/10/sys/cam/ctl/ctl_frontend_iscsi.c  Mon Oct  5 10:46:24 2015
(r288781)
+++ stable/10/sys/cam/ctl/ctl_frontend_iscsi.c  Mon Oct  5 10:47:18 2015
(r288782)
@@ -963,6 +963,7 @@ cfiscsi_pdu_handle_data_out(struct icl_p
done = (io->scsiio.ext_data_filled != cdw->cdw_r2t_end ||
io->scsiio.ext_data_filled == io->scsiio.kern_data_len);
uma_zfree(cfiscsi_data_wait_zone, cdw);
+   io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG;
if (done)
io->scsiio.be_move_done(io);
else
@@ -1136,6 +1137,7 @@ cfiscsi_session_terminate_tasks(struct c
 * assuming that the data transfer actually succeeded
 * and writing uninitialized data to disk.
 */
+   cdw->cdw_ctl_io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG;
cdw->cdw_ctl_io->scsiio.io_hdr.port_status = 42;
cdw->cdw_ctl_io->scsiio.be_move_done(cdw->cdw_ctl_io);
uma_zfree(cfiscsi_data_wait_zone, cdw);
@@ -2665,6 +2667,7 @@ cfiscsi_datamove_out(union ctl_io *io)
cfiscsi_session_terminate(cs);
return;
}
+   io->io_hdr.flags |= CTL_FLAG_DMA_INPROG;
bhsr2t = (struct iscsi_bhs_r2t *)response->ip_bhs;
bhsr2t->bhsr2t_opcode = ISCSI_BHS_OPCODE_R2T;
bhsr2t->bhsr2t_flags = 0x80;
@@ -2841,6 +2844,8 @@ cfiscsi_task_management_done(union ctl_i
 #endif
TAILQ_REMOVE(>cs_waiting_for_data_out,
cdw, cdw_next);
+   io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG;
+   cdw->cdw_ctl_io->scsiio.io_hdr.port_status = 43;
cdw->cdw_ctl_io->scsiio.be_move_done(cdw->cdw_ctl_io);
uma_zfree(cfiscsi_data_wait_zone, cdw);
}
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288810 - in stable/10: share/man/man4 sys/cam/ctl sys/cam/scsi usr.sbin/ctladm usr.sbin/ctld

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:30:18 2015
New Revision: 288810
URL: https://svnweb.freebsd.org/changeset/base/288810

Log:
  MFC r288310: Add to CTL initial support for CDROMs and removable devices.
  
  Relnotes:   yes

Modified:
  stable/10/share/man/man4/ctl.4
  stable/10/sys/cam/ctl/README.ctl.txt
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_backend_block.c
  stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
  stable/10/sys/cam/ctl/ctl_cmd_table.c
  stable/10/sys/cam/ctl/ctl_private.h
  stable/10/sys/cam/scsi/scsi_cd.h
  stable/10/usr.sbin/ctladm/ctladm.8
  stable/10/usr.sbin/ctld/ctl.conf.5
  stable/10/usr.sbin/ctld/ctld.c
  stable/10/usr.sbin/ctld/ctld.h
  stable/10/usr.sbin/ctld/kernel.c
  stable/10/usr.sbin/ctld/parse.y
  stable/10/usr.sbin/ctld/token.l
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man4/ctl.4
==
--- stable/10/share/man/man4/ctl.4  Mon Oct  5 11:29:23 2015
(r288809)
+++ stable/10/share/man/man4/ctl.4  Mon Oct  5 11:30:18 2015
(r288810)
@@ -24,7 +24,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
-.Dd September 12, 2015
+.Dd September 27, 2015
 .Dt CTL 4
 .Os
 .Sh NAME
@@ -53,7 +53,7 @@ It supports features such as:
 .Pp
 .Bl -bullet -compact
 .It
-Disk and processor device emulation
+Disk, processor and cdrom device emulation
 .It
 Tagged queueing
 .It

Modified: stable/10/sys/cam/ctl/README.ctl.txt
==
--- stable/10/sys/cam/ctl/README.ctl.txtMon Oct  5 11:29:23 2015
(r288809)
+++ stable/10/sys/cam/ctl/README.ctl.txtMon Oct  5 11:30:18 2015
(r288810)
@@ -19,9 +19,9 @@ Userland Commands
 Introduction:
 
 
-CTL is a disk and processor device emulation subsystem originally written
-for Copan Systems under Linux starting in 2003.  It has been shipping in
-Copan (now SGI) products since 2005.
+CTL is a disk, processor and cdrom device emulation subsystem originally
+written for Copan Systems under Linux starting in 2003.  It has been
+shipping in Copan (now SGI) products since 2005.
 
 It was ported to FreeBSD in 2008, and thanks to an agreement between SGI
 (who acquired Copan's assets in 2010) and Spectra Logic in 2010, CTL is
@@ -31,7 +31,7 @@ that Spectra would work to get CTL into 
 Features:
 
 
- - Disk and processor device emulation.
+ - Disk, processor and cdrom device emulation.
  - Tagged queueing
  - SCSI task attribute support (ordered, head of queue, simple tags)
  - SCSI implicit command ordering support.  (e.g. if a read follows a mode

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:29:23 2015(r288809)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:30:18 2015(r288810)
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3821,8 +3822,14 @@ ctl_init_page_index(struct ctl_lun *lun)
for (i = 0; i < CTL_NUM_MODE_PAGES; i++) {
 
page_index = >mode_pages.index[i];
-   if (lun->be_lun->lun_type != T_DIRECT &&
-   (page_index->page_flags & CTL_PAGE_FLAG_DISK_ONLY))
+   if (lun->be_lun->lun_type == T_DIRECT &&
+   (page_index->page_flags & CTL_PAGE_FLAG_DIRECT) == 0)
+   continue;
+   if (lun->be_lun->lun_type == T_PROCESSOR &&
+   (page_index->page_flags & CTL_PAGE_FLAG_PROC) == 0)
+   continue;
+   if (lun->be_lun->lun_type == T_CDROM &&
+   (page_index->page_flags & CTL_PAGE_FLAG_CDROM) == 0)
continue;
 
switch (page_index->page_code & SMPH_PC_MASK) {
@@ -4207,8 +4214,14 @@ ctl_init_log_page_index(struct ctl_lun *
for (i = 0, j = 0, k = 0; i < CTL_NUM_LOG_PAGES; i++) {
 
page_index = >log_pages.index[i];
-   if (lun->be_lun->lun_type != T_DIRECT &&
-   (page_index->page_flags & CTL_PAGE_FLAG_DISK_ONLY))
+   if (lun->be_lun->lun_type == T_DIRECT &&
+   (page_index->page_flags & CTL_PAGE_FLAG_DIRECT) == 0)
+   continue;
+   if (lun->be_lun->lun_type == T_PROCESSOR &&
+   (page_index->page_flags & CTL_PAGE_FLAG_PROC) == 0)
+   continue;
+   if (lun->be_lun->lun_type == T_CDROM &&
+   (page_index->page_flags & CTL_PAGE_FLAG_CDROM) == 0)
continue;
 
if (page_index->page_code == SLS_LOGICAL_BLOCK_PROVISIONING &&
@@ -4284,7 +4297,7 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft
struct ctl_lun *nlun, *lun;
struct scsi_vpd_id_descriptor *desc;
struct scsi_vpd_id_t10 *t10id;
-   const 

svn commit: r288769 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:36:28 2015
New Revision: 288769
URL: https://svnweb.freebsd.org/changeset/base/288769

Log:
  MFC r287933: Replicate port->init_devid to HA peer.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_io.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:35:36 2015(r288768)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:36:28 2015(r288769)
@@ -613,6 +613,8 @@ ctl_isc_announce_port(struct ctl_port *p
i += port->port_devid->len;
if (port->target_devid)
i += port->target_devid->len;
+   if (port->init_devid)
+   i += port->init_devid->len;
msg = malloc(i, M_CTL, M_WAITOK);
bzero(>port, sizeof(msg->port));
msg->hdr.msg_type = CTL_MSG_PORT_SYNC;
@@ -643,6 +645,12 @@ ctl_isc_announce_port(struct ctl_port *p
msg->port.target_devid_len);
i += msg->port.target_devid_len;
}
+   if (port->init_devid) {
+   msg->port.init_devid_len = port->init_devid->len;
+   memcpy(>port.data[i], port->init_devid->data,
+   msg->port.init_devid_len);
+   i += msg->port.init_devid_len;
+   }
ctl_ha_msg_send(CTL_HA_CHAN_CTL, >port, sizeof(msg->port) + i,
M_WAITOK);
free(msg, M_CTL);
@@ -867,8 +875,23 @@ ctl_isc_port_sync(struct ctl_softc *soft
port->target_devid->len = msg->port.target_devid_len;
i += msg->port.target_devid_len;
} else {
-   free(port->port_devid, M_CTL);
-   port->port_devid = NULL;
+   free(port->target_devid, M_CTL);
+   port->target_devid = NULL;
+   }
+   if (msg->port.init_devid_len != 0) {
+   if (port->init_devid == NULL ||
+   port->init_devid->len != msg->port.init_devid_len) {
+   free(port->init_devid, M_CTL);
+   port->init_devid = malloc(sizeof(struct ctl_devid) +
+   msg->port.init_devid_len, M_CTL, M_WAITOK);
+   }
+   memcpy(port->init_devid->data, >port.data[i],
+   msg->port.init_devid_len);
+   port->init_devid->len = msg->port.init_devid_len;
+   i += msg->port.init_devid_len;
+   } else {
+   free(port->init_devid, M_CTL);
+   port->init_devid = NULL;
}
if (new) {
if (ctl_port_register(port) != 0) {

Modified: stable/10/sys/cam/ctl/ctl_io.h
==
--- stable/10/sys/cam/ctl/ctl_io.h  Mon Oct  5 10:35:36 2015
(r288768)
+++ stable/10/sys/cam/ctl/ctl_io.h  Mon Oct  5 10:36:28 2015
(r288769)
@@ -479,6 +479,7 @@ struct ctl_ha_msg_port {
int lun_map_len;
int port_devid_len;
int target_devid_len;
+   int init_devid_len;
uint8_t data[];
 };
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288787 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:51:24 2015
New Revision: 288787
URL: https://svnweb.freebsd.org/changeset/base/288787

Log:
  MFC r288104: Remove duplicate and incomplete code handling LUN modify.
  
  Instead reuse code from LUN creation.  This allows most of LUN media
  options to be changed live with modify request without full restart.

Modified:
  stable/10/sys/cam/ctl/ctl_backend_block.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==
--- stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 10:50:35 2015
(r288786)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 10:51:24 2015
(r288787)
@@ -266,10 +266,6 @@ static int ctl_be_block_create(struct ct
   struct ctl_lun_req *req);
 static int ctl_be_block_rm(struct ctl_be_block_softc *softc,
   struct ctl_lun_req *req);
-static int ctl_be_block_modify_file(struct ctl_be_block_lun *be_lun,
- struct ctl_lun_req *req);
-static int ctl_be_block_modify_dev(struct ctl_be_block_lun *be_lun,
-struct ctl_lun_req *req);
 static int ctl_be_block_modify(struct ctl_be_block_softc *softc,
   struct ctl_lun_req *req);
 static void ctl_be_block_lun_shutdown(void *be_lun);
@@ -2607,85 +2603,6 @@ bailout_error:
 }
 
 static int
-ctl_be_block_modify_file(struct ctl_be_block_lun *be_lun,
-struct ctl_lun_req *req)
-{
-   struct ctl_be_lun *cbe_lun = _lun->cbe_lun;
-   struct vattr vattr;
-   int error;
-   struct ctl_lun_create_params *params = _lun->params;
-
-   if (params->lun_size_bytes != 0) {
-   be_lun->size_bytes = params->lun_size_bytes;
-   } else  {
-   vn_lock(be_lun->vn, LK_SHARED | LK_RETRY);
-   error = VOP_GETATTR(be_lun->vn, , curthread->td_ucred);
-   VOP_UNLOCK(be_lun->vn, 0);
-   if (error != 0) {
-   snprintf(req->error_str, sizeof(req->error_str),
-"error calling VOP_GETATTR() for file %s",
-be_lun->dev_path);
-   return (error);
-   }
-   be_lun->size_bytes = vattr.va_size;
-   }
-   be_lun->size_blocks = be_lun->size_bytes / cbe_lun->blocksize;
-   cbe_lun->maxlba = (be_lun->size_blocks == 0) ?
-   0 : (be_lun->size_blocks - 1);
-   return (0);
-}
-
-static int
-ctl_be_block_modify_dev(struct ctl_be_block_lun *be_lun,
-   struct ctl_lun_req *req)
-{
-   struct ctl_be_lun *cbe_lun = _lun->cbe_lun;
-   struct ctl_lun_create_params *params = _lun->params;
-   struct cdevsw *csw;
-   struct cdev *dev;
-   uint64_t size_bytes;
-   int error, ref;
-
-   csw = devvn_refthread(be_lun->vn, , );
-   if (csw == NULL)
-   return (ENXIO);
-   if (csw->d_ioctl == NULL) {
-   dev_relthread(dev, ref);
-   snprintf(req->error_str, sizeof(req->error_str),
-"no d_ioctl for device %s!", be_lun->dev_path);
-   return (ENODEV);
-   }
-
-   error = csw->d_ioctl(dev, DIOCGMEDIASIZE, (caddr_t)_bytes, FREAD,
-   curthread);
-   dev_relthread(dev, ref);
-   if (error) {
-   snprintf(req->error_str, sizeof(req->error_str),
-"error %d returned for DIOCGMEDIASIZE ioctl "
-"on %s!", error, be_lun->dev_path);
-   return (error);
-   }
-
-   if (params->lun_size_bytes != 0) {
-   if (params->lun_size_bytes > size_bytes) {
-   snprintf(req->error_str, sizeof(req->error_str),
-"requested LUN size %ju > backing device "
-"size %ju",
-(uintmax_t)params->lun_size_bytes,
-(uintmax_t)size_bytes);
-   return (EINVAL);
-   }
-   be_lun->size_bytes = params->lun_size_bytes;
-   } else {
-   be_lun->size_bytes = size_bytes;
-   }
-   be_lun->size_blocks = be_lun->size_bytes / cbe_lun->blocksize;
-   cbe_lun->maxlba = (be_lun->size_blocks == 0) ?
-   0 : (be_lun->size_blocks - 1);
-   return (0);
-}
-
-static int
 ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
 {
struct ctl_lun_modify_params *params;
@@ -2740,9 +2657,9 @@ ctl_be_block_modify(struct ctl_be_block_
if (be_lun->vn == NULL)
error = ctl_be_block_open(softc, be_lun, req);
else if (vn_isdisk(be_lun->vn, ))
-   error = ctl_be_block_modify_dev(be_lun, req);
+   error = 

svn commit: r288785 - stable/10/usr.sbin/ctld

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:49:47 2015
New Revision: 288785
URL: https://svnweb.freebsd.org/changeset/base/288785

Log:
  MFC r288061: Make cltd ignore HA ports.

Modified:
  stable/10/usr.sbin/ctld/kernel.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/ctld/kernel.c
==
--- stable/10/usr.sbin/ctld/kernel.cMon Oct  5 10:49:01 2015
(r288784)
+++ stable/10/usr.sbin/ctld/kernel.cMon Oct  5 10:49:47 2015
(r288785)
@@ -119,6 +119,7 @@ struct cctl_lun {
 
 struct cctl_port {
uint32_t port_id;
+   char *port_frontend;
char *port_name;
int pp;
int vp;
@@ -331,7 +332,10 @@ cctl_end_pelement(void *user_data, const
devlist->cur_sb[devlist->level] = NULL;
devlist->level--;
 
-   if (strcmp(name, "port_name") == 0) {
+   if (strcmp(name, "frontend_type") == 0) {
+   cur_port->port_frontend = str;
+   str = NULL;
+   } else if (strcmp(name, "port_name") == 0) {
cur_port->port_name = str;
str = NULL;
} else if (strcmp(name, "physical_port") == 0) {
@@ -506,6 +510,8 @@ retry_port:
 
name = NULL;
STAILQ_FOREACH(port, _list, links) {
+   if (strcmp(port->port_frontend, "ha") == 0)
+   continue;
if (name)
free(name);
if (port->pp == 0 && port->vp == 0)
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288786 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:50:35 2015
New Revision: 288786
URL: https://svnweb.freebsd.org/changeset/base/288786

Log:
  MFC r288067: Log iSCSI session reinstatements.
  
  False session reinstatements can be result of misconfiguration, when
  several initiators use the same initiator name and ISID.

Modified:
  stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c
==
--- stable/10/sys/cam/ctl/ctl_frontend_iscsi.c  Mon Oct  5 10:49:47 2015
(r288785)
+++ stable/10/sys/cam/ctl/ctl_frontend_iscsi.c  Mon Oct  5 10:50:35 2015
(r288786)
@@ -1565,6 +1565,16 @@ restart:
if (cs2 != cs && cs2->cs_tasks_aborted == false &&
cs->cs_target == cs2->cs_target &&
strcmp(cs->cs_initiator_id, cs2->cs_initiator_id) 
== 0) {
+   if (strcmp(cs->cs_initiator_addr,
+   cs2->cs_initiator_addr) != 0) {
+   CFISCSI_SESSION_WARN(cs2,
+   "session reinstatement from "
+   "different address %s",
+   cs->cs_initiator_addr);
+   } else {
+   CFISCSI_SESSION_DEBUG(cs2,
+   "session reinstatement");
+   }
cfiscsi_session_terminate(cs2);
mtx_unlock(>lock);
pause("cfiscsi_reinstate", 1);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288799 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:02:17 2015
New Revision: 288799
URL: https://svnweb.freebsd.org/changeset/base/288799

Log:
  MFC r288220: Remove stale comments and some excessive empty lines.

Modified:
  stable/10/sys/cam/ctl/ctl_backend_block.c
  stable/10/sys/cam/ctl/ctl_backend_ramdisk.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==
--- stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 11:01:18 2015
(r288798)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c   Mon Oct  5 11:02:17 2015
(r288799)
@@ -466,14 +466,8 @@ ctl_be_block_move_done(union ctl_io *io)
 * interrupt context, and therefore we cannot block.
 */
mtx_lock(_lun->queue_lock);
-   /*
-* XXX KDM make sure that links is okay to use at this point.
-* Otherwise, we either need to add another field to ctl_io_hdr,
-* or deal with resource allocation here.
-*/
STAILQ_INSERT_TAIL(_lun->datamove_queue, >io_hdr, links);
mtx_unlock(_lun->queue_lock);
-
taskqueue_enqueue(be_lun->io_taskqueue, _lun->io_task);
 
return (0);
@@ -589,15 +583,12 @@ ctl_be_block_flush_file(struct ctl_be_bl
 
(void) vn_start_write(be_lun->vn, , V_WAIT);
 
-   if (MNT_SHARED_WRITES(mountpoint)
-|| ((mountpoint == NULL)
- && MNT_SHARED_WRITES(be_lun->vn->v_mount)))
+   if (MNT_SHARED_WRITES(mountpoint) ||
+   ((mountpoint == NULL) && MNT_SHARED_WRITES(be_lun->vn->v_mount)))
lock_flags = LK_SHARED;
else
lock_flags = LK_EXCLUSIVE;
-
vn_lock(be_lun->vn, lock_flags | LK_RETRY);
-
error = VOP_FSYNC(be_lun->vn, beio->io_arg ? MNT_NOWAIT : MNT_WAIT,
curthread);
VOP_UNLOCK(be_lun->vn, 0);
@@ -719,13 +710,11 @@ ctl_be_block_dispatch_file(struct ctl_be
 
(void)vn_start_write(be_lun->vn, , V_WAIT);
 
-   if (MNT_SHARED_WRITES(mountpoint)
-|| ((mountpoint == NULL)
+   if (MNT_SHARED_WRITES(mountpoint) || ((mountpoint == NULL)
  && MNT_SHARED_WRITES(be_lun->vn->v_mount)))
lock_flags = LK_SHARED;
else
lock_flags = LK_EXCLUSIVE;
-
vn_lock(be_lun->vn, lock_flags | LK_RETRY);
 
/*
@@ -1543,14 +1532,8 @@ ctl_be_block_next(struct ctl_be_block_io
io->io_hdr.status |= CTL_STATUS_NONE;
 
mtx_lock(_lun->queue_lock);
-   /*
-* XXX KDM make sure that links is okay to use at this point.
-* Otherwise, we either need to add another field to ctl_io_hdr,
-* or deal with resource allocation here.
-*/
STAILQ_INSERT_TAIL(_lun->input_queue, >io_hdr, links);
mtx_unlock(_lun->queue_lock);
-
taskqueue_enqueue(be_lun->io_taskqueue, _lun->io_task);
 }
 
@@ -1781,11 +1764,6 @@ ctl_be_block_submit(union ctl_io *io)
PRIV(io)->len = 0;
 
mtx_lock(_lun->queue_lock);
-   /*
-* XXX KDM make sure that links is okay to use at this point.
-* Otherwise, we either need to add another field to ctl_io_hdr,
-* or deal with resource allocation here.
-*/
STAILQ_INSERT_TAIL(_lun->input_queue, >io_hdr, links);
mtx_unlock(_lun->queue_lock);
taskqueue_enqueue(be_lun->io_taskqueue, _lun->io_task);
@@ -2336,10 +2314,6 @@ ctl_be_block_create(struct ctl_be_block_
num_threads = 1;
}
 
-   /*
-* XXX This searching loop might be refactored to be combined with
-* the loop above,
-*/
value = ctl_get_opt(_lun->options, "num_threads");
if (value != NULL) {
tmp_num_threads = strtol(value, NULL, 0);
@@ -2529,7 +2503,6 @@ ctl_be_block_rm(struct ctl_be_block_soft
break;
}
mtx_unlock(>lock);
-
if (be_lun == NULL) {
snprintf(req->error_str, sizeof(req->error_str),
 "LUN %u is not managed by the block backend",
@@ -2597,13 +2570,10 @@ ctl_be_block_rm(struct ctl_be_block_soft
free(be_lun, M_CTLBLK);
 
req->status = CTL_LUN_OK;
-
return (0);
 
 bailout_error:
-
req->status = CTL_LUN_ERROR;
-
return (0);
 }
 
@@ -2625,7 +2595,6 @@ ctl_be_block_modify(struct ctl_be_block_
break;
}
mtx_unlock(>lock);
-
if (be_lun == NULL) {
snprintf(req->error_str, sizeof(req->error_str),
 "LUN %u is not managed by the block backend",
@@ -2702,7 +2671,6 @@ ctl_be_block_lun_shutdown(void *be_lun)
struct ctl_be_block_softc *softc;
 
lun = (struct ctl_be_block_lun *)be_lun;
-
softc = lun->softc;
 
mtx_lock(>lock);
@@ -2710,7 +2678,6 @@ ctl_be_block_lun_shutdown(void *be_lun)
  

svn commit: r288808 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:28:26 2015
New Revision: 288808
URL: https://svnweb.freebsd.org/changeset/base/288808

Log:
  MFC r288262: Remove concept of control device.

Modified:
  stable/10/sys/cam/ctl/ctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:27:35 2015(r288807)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:28:26 2015(r288808)
@@ -3821,14 +3821,8 @@ ctl_init_page_index(struct ctl_lun *lun)
for (i = 0; i < CTL_NUM_MODE_PAGES; i++) {
 
page_index = >mode_pages.index[i];
-   /*
-* If this is a disk-only mode page, there's no point in
-* setting it up.  For some pages, we have to have some
-* basic information about the disk in order to calculate the
-* mode page data.
-*/
-   if ((lun->be_lun->lun_type != T_DIRECT)
-&& (page_index->page_flags & CTL_PAGE_FLAG_DISK_ONLY))
+   if (lun->be_lun->lun_type != T_DIRECT &&
+   (page_index->page_flags & CTL_PAGE_FLAG_DISK_ONLY))
continue;
 
switch (page_index->page_code & SMPH_PC_MASK) {
@@ -4213,18 +4207,12 @@ ctl_init_log_page_index(struct ctl_lun *
for (i = 0, j = 0, k = 0; i < CTL_NUM_LOG_PAGES; i++) {
 
page_index = >log_pages.index[i];
-   /*
-* If this is a disk-only mode page, there's no point in
-* setting it up.  For some pages, we have to have some
-* basic information about the disk in order to calculate the
-* mode page data.
-*/
-   if ((lun->be_lun->lun_type != T_DIRECT)
-&& (page_index->page_flags & CTL_PAGE_FLAG_DISK_ONLY))
+   if (lun->be_lun->lun_type != T_DIRECT &&
+   (page_index->page_flags & CTL_PAGE_FLAG_DISK_ONLY))
continue;
 
if (page_index->page_code == SLS_LOGICAL_BLOCK_PROVISIONING &&
-lun->backend->lun_attr == NULL)
+   lun->backend->lun_attr == NULL)
continue;
 
if (page_index->page_code != prev) {
@@ -4496,9 +4484,8 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft
/* Setup statistics gathering */
lun->stats.device_type = be_lun->lun_type;
lun->stats.lun_number = lun_number;
-   if (lun->stats.device_type == T_DIRECT)
-   lun->stats.blocksize = be_lun->blocksize;
-   else
+   lun->stats.blocksize = be_lun->blocksize;
+   if (be_lun->blocksize == 0)
lun->stats.flags = CTL_LUN_STATS_NO_BLOCKSIZE;
for (i = 0;i < CTL_MAX_PORTS;i++)
lun->stats.ports[i].targ_port = i;
@@ -5901,8 +5888,7 @@ ctl_do_mode_select(union ctl_io *io)
struct scsi_mode_page_header *page_header;
struct ctl_page_index *page_index;
struct ctl_scsiio *ctsio;
-   int control_dev, page_len;
-   int page_len_offset, page_len_size;
+   int page_len, page_len_offset, page_len_size;
union ctl_modepage_info *modepage_info;
struct ctl_lun *lun;
int *len_left, *len_used;
@@ -5913,11 +5899,6 @@ ctl_do_mode_select(union ctl_io *io)
page_len = 0;
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
 
-   if (lun->be_lun->lun_type != T_DIRECT)
-   control_dev = 1;
-   else
-   control_dev = 0;
-
modepage_info = (union ctl_modepage_info *)
ctsio->io_hdr.ctl_private[CTL_PRIV_MODEPAGE].bytes;
len_left = _info->header.len_left;
@@ -5955,8 +5936,8 @@ do_next_page:
 */
for (i = 0; i < CTL_NUM_MODE_PAGES; i++) {
 
-   if ((control_dev != 0)
-&& (lun->mode_pages.index[i].page_flags &
+   if (lun->be_lun->lun_type != T_DIRECT &&
+   (lun->mode_pages.index[i].page_flags &
 CTL_PAGE_FLAG_DISK_ONLY))
continue;
 
@@ -6253,7 +6234,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio)
int alloc_len, page_len, header_len, total_len;
struct scsi_mode_block_descr *block_desc;
struct ctl_page_index *page_index;
-   int control_dev;
 
dbd = 0;
llba = 0;
@@ -6263,12 +6243,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio)
CTL_DEBUG_PRINT(("ctl_mode_sense\n"));
 
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
-
-   if (lun->be_lun->lun_type != T_DIRECT)
-   control_dev = 1;
-   else
-   control_dev = 0;
-
switch (ctsio->cdb[0]) {
case MODE_SENSE_6: {
struct scsi_mode_sense_6 *cdb;
@@ -6341,8 +6315,8 @@ ctl_mode_sense(struct ctl_scsiio 

svn commit: r288823 - stable/10/usr.sbin/ctld

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:51:13 2015
New Revision: 288823
URL: https://svnweb.freebsd.org/changeset/base/288823

Log:
  MFC r288486, r288488: Set default block size for CD to expected 2048 bytes.

Modified:
  stable/10/usr.sbin/ctld/ctl.conf.5
  stable/10/usr.sbin/ctld/ctld.c
  stable/10/usr.sbin/ctld/ctld.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/ctld/ctl.conf.5
==
--- stable/10/usr.sbin/ctld/ctl.conf.5  Mon Oct  5 11:49:56 2015
(r288822)
+++ stable/10/usr.sbin/ctld/ctl.conf.5  Mon Oct  5 11:51:13 2015
(r288823)
@@ -364,7 +364,7 @@ testing.
 The default backend is block.
 .It Ic blocksize Ar size
 The blocksize visible to the initiator.
-The default blocksize is 512.
+The default blocksize is 512 for disks, and 2048 for CD/DVDs.
 .It Ic ctl-lun Ar lun_id
 Global numeric identifier to use for a given LUN inside CTL.
 By default CTL allocates those IDs dynamically, but explicit specification

Modified: stable/10/usr.sbin/ctld/ctld.c
==
--- stable/10/usr.sbin/ctld/ctld.c  Mon Oct  5 11:49:56 2015
(r288822)
+++ stable/10/usr.sbin/ctld/ctld.c  Mon Oct  5 11:51:13 2015
(r288823)
@@ -1644,7 +1644,10 @@ conf_verify_lun(struct lun *lun)
}
}
if (lun->l_blocksize == 0) {
-   lun_set_blocksize(lun, DEFAULT_BLOCKSIZE);
+   if (lun->l_device_type == 5)
+   lun_set_blocksize(lun, DEFAULT_CD_BLOCKSIZE);
+   else
+   lun_set_blocksize(lun, DEFAULT_BLOCKSIZE);
} else if (lun->l_blocksize < 0) {
log_warnx("invalid blocksize for lun \"%s\"; "
"must be larger than 0", lun->l_name);

Modified: stable/10/usr.sbin/ctld/ctld.h
==
--- stable/10/usr.sbin/ctld/ctld.h  Mon Oct  5 11:49:56 2015
(r288822)
+++ stable/10/usr.sbin/ctld/ctld.h  Mon Oct  5 11:51:13 2015
(r288823)
@@ -43,6 +43,7 @@
 #defineDEFAULT_CONFIG_PATH "/etc/ctl.conf"
 #defineDEFAULT_PIDFILE "/var/run/ctld.pid"
 #defineDEFAULT_BLOCKSIZE   512
+#defineDEFAULT_CD_BLOCKSIZE2048
 
 #defineMAX_LUNS1024
 #defineMAX_NAME_LEN223
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288775 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:42:07 2015
New Revision: 288775
URL: https://svnweb.freebsd.org/changeset/base/288775

Log:
  MFC r287968: Mark I/Os with DMA flag while moving data through the HA link.

Modified:
  stable/10/sys/cam/ctl/ctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:41:08 2015(r288774)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:42:07 2015(r288775)
@@ -1150,6 +1150,7 @@ ctl_isc_event_handler(ctl_ha_channel cha
 */
io = msg->hdr.serializing_sc;
io->io_hdr.msg_type = CTL_MSG_DATAMOVE_DONE;
+   io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG;
io->io_hdr.flags |= CTL_FLAG_IO_ACTIVE;
io->io_hdr.port_status = msg->scsi.fetd_status;
io->scsiio.residual = msg->scsi.residual;
@@ -11060,6 +11061,7 @@ ctl_failover_lun(struct ctl_lun *lun)
io->flags |= CTL_FLAG_FAILOVER;
} else { /* This can be only due to DATAMOVE */
io->msg_type = CTL_MSG_DATAMOVE_DONE;
+   io->flags &= ~CTL_FLAG_DMA_INPROG;
io->flags |= CTL_FLAG_IO_ACTIVE;
io->port_status = 31340;
ctl_enqueue_isc((union ctl_io *)io);
@@ -12445,6 +12447,7 @@ ctl_datamove(union ctl_io *io)
return;
}
io->io_hdr.flags &= ~CTL_FLAG_IO_ACTIVE;
+   io->io_hdr.flags |= CTL_FLAG_DMA_INPROG;
if (lun)
mtx_unlock(>lun_lock);
} else {
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288820 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:48:14 2015
New Revision: 288820
URL: https://svnweb.freebsd.org/changeset/base/288820

Log:
  MFC r288449:
  Implement SPC-3 exceptions to SPC-2 RESERVE and RELEASE behavior.

Modified:
  stable/10/sys/cam/ctl/ctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:47:16 2015(r288819)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:48:14 2015(r288820)
@@ -5103,6 +5103,13 @@ ctl_scsi_reserve(struct ctl_scsiio *ctsi
ctl_set_reservation_conflict(ctsio);
goto bailout;
}
+
+   /* SPC-3 exceptions to SPC-2 RESERVE and RELEASE behavior. */
+   if (lun->flags & CTL_LUN_PR_RESERVED) {
+   ctl_set_success(ctsio);
+   goto bailout;
+   }
+
lun->flags |= CTL_LUN_RESERVED;
lun->res_idx = residx;
ctl_set_success(ctsio);
@@ -7626,7 +7633,8 @@ retry:
 
res_cap = (struct scsi_per_res_cap *)ctsio->kern_data_ptr;
scsi_ulto2b(sizeof(*res_cap), res_cap->length);
-   res_cap->flags2 |= SPRI_TMV | SPRI_ALLOW_5;
+   res_cap->flags1 = SPRI_CRH;
+   res_cap->flags2 = SPRI_TMV | SPRI_ALLOW_5;
type_mask = SPRI_TM_WR_EX_AR |
SPRI_TM_EX_AC_RO |
SPRI_TM_WR_EX_RO |
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288789 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:53:13 2015
New Revision: 288789
URL: https://svnweb.freebsd.org/changeset/base/288789

Log:
  MFC r288146: Make HA peers announce their parameters on connect.
  
  HA protocol requires strict version, parameters and configuration match.
  Differences there may cause full set of problems up to kernel panic.
  To avoid that, validate peer parameters on connect, and abort connection
  immediately if some mismatch detected.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_ha.c
  stable/10/sys/cam/ctl/ctl_ha.h
  stable/10/sys/cam/ctl/ctl_io.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:52:22 2015(r288788)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:53:13 2015(r288789)
@@ -717,8 +717,20 @@ ctl_isc_ha_link_up(struct ctl_softc *sof
 {
struct ctl_port *port;
struct ctl_lun *lun;
+   union ctl_ha_msg msg;
int i;
 
+   /* Announce this node parameters to peer for validation. */
+   msg.login.msg_type = CTL_MSG_LOGIN;
+   msg.login.version = CTL_HA_VERSION;
+   msg.login.ha_mode = softc->ha_mode;
+   msg.login.ha_id = softc->ha_id;
+   msg.login.max_luns = CTL_MAX_LUNS;
+   msg.login.max_ports = CTL_MAX_PORTS;
+   msg.login.max_init_per_port = CTL_MAX_INIT_PER_PORT;
+   ctl_ha_msg_send(CTL_HA_CHAN_CTL, , sizeof(msg.login),
+   M_WAITOK);
+
STAILQ_FOREACH(port, >port_list, links) {
ctl_isc_announce_port(port);
for (i = 0; i < CTL_MAX_INIT_PER_PORT; i++) {
@@ -1001,6 +1013,36 @@ ctl_isc_iid_sync(struct ctl_softc *softc
port->wwpn_iid[iid].name = NULL;
 }
 
+static void
+ctl_isc_login(struct ctl_softc *softc, union ctl_ha_msg *msg, int len)
+{
+
+   if (msg->login.version != CTL_HA_VERSION) {
+   printf("CTL HA peers have different versions %d != %d\n",
+   msg->login.version, CTL_HA_VERSION);
+   ctl_ha_msg_abort(CTL_HA_CHAN_CTL);
+   return;
+   }
+   if (msg->login.ha_mode != softc->ha_mode) {
+   printf("CTL HA peers have different ha_mode %d != %d\n",
+   msg->login.ha_mode, softc->ha_mode);
+   ctl_ha_msg_abort(CTL_HA_CHAN_CTL);
+   return;
+   }
+   if (msg->login.ha_id == softc->ha_id) {
+   printf("CTL HA peers have same ha_id %d\n", msg->login.ha_id);
+   ctl_ha_msg_abort(CTL_HA_CHAN_CTL);
+   return;
+   }
+   if (msg->login.max_luns != CTL_MAX_LUNS ||
+   msg->login.max_ports != CTL_MAX_PORTS ||
+   msg->login.max_init_per_port != CTL_MAX_INIT_PER_PORT) {
+   printf("CTL HA peers have different limits\n");
+   ctl_ha_msg_abort(CTL_HA_CHAN_CTL);
+   return;
+   }
+}
+
 /*
  * ISC (Inter Shelf Communication) event handler.  Events from the HA
  * subsystem come in here.
@@ -1277,9 +1319,13 @@ ctl_isc_event_handler(ctl_ha_channel cha
case CTL_MSG_IID_SYNC:
ctl_isc_iid_sync(softc, msg, param);
break;
+   case CTL_MSG_LOGIN:
+   ctl_isc_login(softc, msg, param);
+   break;
default:
printf("Received HA message of unknown type %d\n",
msg->hdr.msg_type);
+   ctl_ha_msg_abort(CTL_HA_CHAN_CTL);
break;
}
if (msg != )

Modified: stable/10/sys/cam/ctl/ctl_ha.c
==
--- stable/10/sys/cam/ctl/ctl_ha.c  Mon Oct  5 10:52:22 2015
(r288788)
+++ stable/10/sys/cam/ctl/ctl_ha.c  Mon Oct  5 10:53:13 2015
(r288789)
@@ -283,8 +283,9 @@ ctl_ha_rx_thread(void *arg)
else
next = sizeof(wire_hdr);
SOCKBUF_LOCK(>so_rcv);
-   while (sbavail(>so_rcv) < next) {
-   if (softc->ha_connected == 0 || so->so_error ||
+   while (sbavail(>so_rcv) < next || softc->ha_disconnect) {
+   if (softc->ha_connected == 0 || softc->ha_disconnect ||
+   so->so_error ||
(so->so_rcv.sb_state & SBS_CANTRCVMORE)) {
goto errout;
}
@@ -541,6 +542,18 @@ ctl_ha_listen(struct ha_softc *softc)
printf("%s: REUSEADDR setting failed %d\n",
__func__, error);
}
+   bzero(, sizeof(struct sockopt));
+   opt.sopt_dir = SOPT_SET;
+   opt.sopt_level = SOL_SOCKET;
+   opt.sopt_name = SO_REUSEPORT;
+  

svn commit: r288788 - in stable/10/sys/cam: ctl scsi

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 10:52:22 2015
New Revision: 288788
URL: https://svnweb.freebsd.org/changeset/base/288788

Log:
  MFC r288110: Add support for Control extension mode page.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_private.h
  stable/10/sys/cam/scsi/scsi_all.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:51:24 2015(r288787)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 10:52:22 2015(r288788)
@@ -261,6 +261,26 @@ const static struct scsi_control_page co
/*extended_selftest_completion_time*/{0, 0}
 };
 
+#define CTL_CEM_LEN(sizeof(struct scsi_control_ext_page) - 4)
+
+const static struct scsi_control_ext_page control_ext_page_default = {
+   /*page_code*/SMS_CONTROL_MODE_PAGE | SMPH_SPF,
+   /*subpage_code*/0x01,
+   /*page_length*/{CTL_CEM_LEN >> 8, CTL_CEM_LEN},
+   /*flags*/0,
+   /*prio*/0,
+   /*max_sense*/0
+};
+
+const static struct scsi_control_ext_page control_ext_page_changeable = {
+   /*page_code*/SMS_CONTROL_MODE_PAGE | SMPH_SPF,
+   /*subpage_code*/0x01,
+   /*page_length*/{CTL_CEM_LEN >> 8, CTL_CEM_LEN},
+   /*flags*/0,
+   /*prio*/0,
+   /*max_sense*/0
+};
+
 const static struct scsi_info_exceptions_page ie_page_default = {
/*page_code*/SMS_INFO_EXCEPTIONS_PAGE,
/*page_length*/sizeof(struct scsi_info_exceptions_page) - 2,
@@ -3958,35 +3978,65 @@ ctl_init_page_index(struct ctl_lun *lun)
break;
}
case SMS_CONTROL_MODE_PAGE: {
-   struct scsi_control_page *control_page;
-
-   if (page_index->subpage != SMS_SUBPAGE_PAGE_0)
-   panic("invalid subpage value %d",
- page_index->subpage);
+   switch (page_index->subpage) {
+   case SMS_SUBPAGE_PAGE_0: {
+   struct scsi_control_page *control_page;
 
-   memcpy(>mode_pages.control_page[CTL_PAGE_DEFAULT],
-  _page_default,
-  sizeof(control_page_default));
-   memcpy(>mode_pages.control_page[
-  CTL_PAGE_CHANGEABLE], _page_changeable,
-  sizeof(control_page_changeable));
-   memcpy(>mode_pages.control_page[CTL_PAGE_SAVED],
-  _page_default,
-  sizeof(control_page_default));
-   control_page = >mode_pages.control_page[
-   CTL_PAGE_SAVED];
-   value = ctl_get_opt(>be_lun->options, 
"reordering");
-   if (value != NULL && strcmp(value, "unrestricted") == 
0) {
-   control_page->queue_flags &= 
~SCP_QUEUE_ALG_MASK;
-   control_page->queue_flags |= 
SCP_QUEUE_ALG_UNRESTRICTED;
-   }
-   memcpy(>mode_pages.control_page[CTL_PAGE_CURRENT],
-  >mode_pages.control_page[CTL_PAGE_SAVED],
-  sizeof(control_page_default));
-   page_index->page_data =
-   (uint8_t *)lun->mode_pages.control_page;
+   memcpy(>mode_pages.control_page[
+   CTL_PAGE_DEFAULT],
+  _page_default,
+  sizeof(control_page_default));
+   memcpy(>mode_pages.control_page[
+   CTL_PAGE_CHANGEABLE],
+  _page_changeable,
+  sizeof(control_page_changeable));
+   memcpy(>mode_pages.control_page[
+   CTL_PAGE_SAVED],
+  _page_default,
+  sizeof(control_page_default));
+   control_page = >mode_pages.control_page[
+   CTL_PAGE_SAVED];
+   value = ctl_get_opt(>be_lun->options,
+   "reordering");
+   if (value != NULL &&
+   strcmp(value, "unrestricted") == 0) {
+   control_page->queue_flags &=
+   ~SCP_QUEUE_ALG_MASK;
+   control_page->queue_flags |=
+   SCP_QUEUE_ALG_UNRESTRICTED;
+   }
+   

svn commit: r288803 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:05:56 2015
New Revision: 288803
URL: https://svnweb.freebsd.org/changeset/base/288803

Log:
  MFC r288239: Properly lock LUN in ctl_failover_lun().

Modified:
  stable/10/sys/cam/ctl/ctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:05:04 2015(r288802)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:05:56 2015(r288803)
@@ -426,7 +426,7 @@ static int ctl_check_blocked(struct ctl_
 static int ctl_scsiio_lun_check(struct ctl_lun *lun,
const struct ctl_cmd_entry *entry,
struct ctl_scsiio *ctsio);
-static void ctl_failover_lun(struct ctl_lun *lun);
+static void ctl_failover_lun(union ctl_io *io);
 static int ctl_scsiio_precheck(struct ctl_softc *ctl_softc,
   struct ctl_scsiio *ctsio);
 static int ctl_scsiio(struct ctl_scsiio *ctsio);
@@ -11201,12 +11201,31 @@ ctl_failover_io(union ctl_io *io, int ha
 }
 
 static void
-ctl_failover_lun(struct ctl_lun *lun)
+ctl_failover_lun(union ctl_io *rio)
 {
-   struct ctl_softc *softc = lun->ctl_softc;
+   struct ctl_softc *softc = control_softc;
+   struct ctl_lun *lun;
struct ctl_io_hdr *io, *next_io;
+   uint32_t targ_lun;
+
+   targ_lun = rio->io_hdr.nexus.targ_mapped_lun;
+   CTL_DEBUG_PRINT(("FAILOVER for lun %ju\n", targ_lun));
+
+   /* Find and lock the LUN. */
+   mtx_lock(>ctl_lock);
+   if ((targ_lun < CTL_MAX_LUNS) &&
+   ((lun = softc->ctl_luns[targ_lun]) != NULL)) {
+   mtx_lock(>lun_lock);
+   mtx_unlock(>ctl_lock);
+   if (lun->flags & CTL_LUN_DISABLED) {
+   mtx_unlock(>lun_lock);
+   return;
+   }
+   } else {
+   mtx_unlock(>ctl_lock);
+   return;
+   }
 
-   CTL_DEBUG_PRINT(("FAILOVER for lun %ju\n", lun->lun));
if (softc->ha_mode == CTL_HA_MODE_XFER) {
TAILQ_FOREACH_SAFE(io, >ooa_queue, ooa_links, next_io) {
/* We are master */
@@ -11264,6 +11283,7 @@ ctl_failover_lun(struct ctl_lun *lun)
}
ctl_check_blocked(lun);
}
+   mtx_unlock(>lun_lock);
 }
 
 static int
@@ -12196,9 +12216,7 @@ ctl_handle_isc(union ctl_io *io)
io->scsiio.be_move_done(io);
break;
case CTL_MSG_FAILOVER:
-   mtx_lock(>lun_lock);
-   ctl_failover_lun(lun);
-   mtx_unlock(>lun_lock);
+   ctl_failover_lun(io);
free_io = 1;
break;
default:
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288813 - stable/10/sys/cam/ctl

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:39:43 2015
New Revision: 288813
URL: https://svnweb.freebsd.org/changeset/base/288813

Log:
  MFC r288359: Report that we can read all flavours of DVD.  Why not?

Modified:
  stable/10/sys/cam/ctl/ctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:38:51 2015(r288812)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:39:43 2015(r288813)
@@ -10273,6 +10273,10 @@ ctl_get_config(struct ctl_scsiio *ctsio)
sizeof(struct scsi_get_config_feature) + 8 +
sizeof(struct scsi_get_config_feature) +
sizeof(struct scsi_get_config_feature) + 4 +
+   sizeof(struct scsi_get_config_feature) + 4 +
+   sizeof(struct scsi_get_config_feature) + 4 +
+   sizeof(struct scsi_get_config_feature) + 4 +
+   sizeof(struct scsi_get_config_feature) + 4 +
sizeof(struct scsi_get_config_feature) + 4;
ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO);
ctsio->kern_sg_entries = 0;
@@ -10286,8 +10290,16 @@ ctl_get_config(struct ctl_scsiio *ctsio)
scsi_ulto2b(0x0010, hdr->current_profile);
feature = (struct scsi_get_config_feature *)(hdr + 1);
 
-   if (starting > 0x001f)
+   if (starting > 0x003b)
goto done;
+   if (starting > 0x003a)
+   goto f3b;
+   if (starting > 0x002b)
+   goto f3a;
+   if (starting > 0x002a)
+   goto f2b;
+   if (starting > 0x001f)
+   goto f2a;
if (starting > 0x001e)
goto f1f;
if (starting > 0x001d)
@@ -10384,6 +10396,48 @@ f1f:   /* DVD Read */
feature = (struct scsi_get_config_feature *)
>feature_data[feature->add_length];
 
+f2a:   /* DVD+RW */
+   scsi_ulto2b(0x002A, feature->feature_code);
+   feature->flags = 0x04;
+   if ((lun->flags & CTL_LUN_NO_MEDIA) == 0)
+   feature->flags |= SGC_F_CURRENT;
+   feature->add_length = 4;
+   feature->feature_data[0] = 0x00;
+   feature->feature_data[1] = 0x00;
+   feature = (struct scsi_get_config_feature *)
+   >feature_data[feature->add_length];
+
+f2b:   /* DVD+R */
+   scsi_ulto2b(0x002B, feature->feature_code);
+   feature->flags = 0x00;
+   if ((lun->flags & CTL_LUN_NO_MEDIA) == 0)
+   feature->flags |= SGC_F_CURRENT;
+   feature->add_length = 4;
+   feature->feature_data[0] = 0x00;
+   feature = (struct scsi_get_config_feature *)
+   >feature_data[feature->add_length];
+
+f3a:   /* DVD+RW Dual Layer */
+   scsi_ulto2b(0x003A, feature->feature_code);
+   feature->flags = 0x00;
+   if ((lun->flags & CTL_LUN_NO_MEDIA) == 0)
+   feature->flags |= SGC_F_CURRENT;
+   feature->add_length = 4;
+   feature->feature_data[0] = 0x00;
+   feature->feature_data[1] = 0x00;
+   feature = (struct scsi_get_config_feature *)
+   >feature_data[feature->add_length];
+
+f3b:   /* DVD+R Dual Layer */
+   scsi_ulto2b(0x003B, feature->feature_code);
+   feature->flags = 0x00;
+   if ((lun->flags & CTL_LUN_NO_MEDIA) == 0)
+   feature->flags |= SGC_F_CURRENT;
+   feature->add_length = 4;
+   feature->feature_data[0] = 0x00;
+   feature = (struct scsi_get_config_feature *)
+   >feature_data[feature->add_length];
+
 done:
data_len = (uint8_t *)feature - (uint8_t *)hdr;
if (rt == SGC_RT_SPECIFIC && data_len > 4) {
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r288812 - in stable/10/sys/cam: ctl scsi

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 11:38:51 2015
New Revision: 288812
URL: https://svnweb.freebsd.org/changeset/base/288812

Log:
  MFC r288358: Add CD/DVD Capabilities and Mechanical Status Page.
  
  This page is obsolete since MMC-4, but still used by some software.
  
  approved by:

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_private.h
  stable/10/sys/cam/scsi/scsi_cd.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:31:24 2015(r288811)
+++ stable/10/sys/cam/ctl/ctl.c Mon Oct  5 11:38:51 2015(r288812)
@@ -354,6 +354,52 @@ const static struct ctl_logical_block_pr
}
 };
 
+const static struct scsi_cddvd_capabilities_page cddvd_page_default = {
+   /*page_code*/SMS_CDDVD_CAPS_PAGE,
+   /*page_length*/sizeof(struct scsi_cddvd_capabilities_page) - 2,
+   /*caps1*/0x3f,
+   /*caps2*/0x00,
+   /*caps3*/0xf0,
+   /*caps4*/0x00,
+   /*caps5*/0x29,
+   /*caps6*/0x00,
+   /*obsolete*/{0, 0},
+   /*nvol_levels*/{0, 0},
+   /*buffer_size*/{8, 0},
+   /*obsolete2*/{0, 0},
+   /*reserved*/0,
+   /*digital*/0,
+   /*obsolete3*/0,
+   /*copy_management*/0,
+   /*reserved2*/0,
+   /*rotation_control*/0,
+   /*cur_write_speed*/0,
+   /*num_speed_descr*/0,
+};
+
+const static struct scsi_cddvd_capabilities_page cddvd_page_changeable = {
+   /*page_code*/SMS_CDDVD_CAPS_PAGE,
+   /*page_length*/sizeof(struct scsi_cddvd_capabilities_page) - 2,
+   /*caps1*/0,
+   /*caps2*/0,
+   /*caps3*/0,
+   /*caps4*/0,
+   /*caps5*/0,
+   /*caps6*/0,
+   /*obsolete*/{0, 0},
+   /*nvol_levels*/{0, 0},
+   /*buffer_size*/{0, 0},
+   /*obsolete2*/{0, 0},
+   /*reserved*/0,
+   /*digital*/0,
+   /*obsolete3*/0,
+   /*copy_management*/0,
+   /*reserved2*/0,
+   /*rotation_control*/0,
+   /*cur_write_speed*/0,
+   /*num_speed_descr*/0,
+};
+
 SYSCTL_NODE(_kern_cam, OID_AUTO, ctl, CTLFLAG_RD, 0, "CAM Target Layer");
 static int worker_threads = -1;
 TUNABLE_INT("kern.cam.ctl.worker_threads", _threads);
@@ -4121,6 +4167,23 @@ ctl_init_page_index(struct ctl_lun *lun)
}}
break;
}
+   case SMS_CDDVD_CAPS_PAGE:{
+   memcpy(>mode_pages.cddvd_page[CTL_PAGE_DEFAULT],
+  _page_default,
+  sizeof(cddvd_page_default));
+   memcpy(>mode_pages.cddvd_page[
+  CTL_PAGE_CHANGEABLE], _page_changeable,
+  sizeof(cddvd_page_changeable));
+   memcpy(>mode_pages.cddvd_page[CTL_PAGE_SAVED],
+  _page_default,
+  sizeof(cddvd_page_default));
+   memcpy(>mode_pages.cddvd_page[CTL_PAGE_CURRENT],
+  >mode_pages.cddvd_page[CTL_PAGE_SAVED],
+  sizeof(cddvd_page_default));
+   page_index->page_data =
+   (uint8_t *)lun->mode_pages.cddvd_page;
+   break;
+   }
case SMS_VENDOR_SPECIFIC_PAGE:{
switch (page_index->subpage) {
case DBGCNF_SUBPAGE_CODE: {

Modified: stable/10/sys/cam/ctl/ctl_private.h
==
--- stable/10/sys/cam/ctl/ctl_private.h Mon Oct  5 11:31:24 2015
(r288811)
+++ stable/10/sys/cam/ctl/ctl_private.h Mon Oct  5 11:38:51 2015
(r288812)
@@ -40,6 +40,10 @@
 #ifndef_CTL_PRIVATE_H_
 #define_CTL_PRIVATE_H_
 
+#include 
+#include 
+#include 
+
 /*
  * SCSI vendor and product names.
  */
@@ -286,6 +290,9 @@ static const struct ctl_page_index page_
{SMS_INFO_EXCEPTIONS_PAGE | SMPH_SPF, 0x02,
 sizeof(struct ctl_logical_block_provisioning_page), NULL,
 CTL_PAGE_FLAG_DIRECT, NULL, NULL},
+   {SMS_CDDVD_CAPS_PAGE, 0,
+sizeof(struct scsi_cddvd_capabilities_page), NULL,
+CTL_PAGE_FLAG_CDROM, NULL, NULL},
{SMS_VENDOR_SPECIFIC_PAGE | SMPH_SPF, DBGCNF_SUBPAGE_CODE,
 sizeof(struct copan_debugconf_subpage), NULL, CTL_PAGE_FLAG_ALL,
 ctl_debugconf_sp_sense_handler, ctl_debugconf_sp_select_handler},
@@ -303,6 +310,7 @@ struct ctl_mode_pages {
struct scsi_control_ext_pagecontrol_ext_page[4];
struct scsi_info_exceptions_page ie_page[4];
struct ctl_logical_block_provisioning_page lbp_page[4];
+   struct scsi_cddvd_capabilities_page cddvd_page[4];
struct copan_debugconf_subpage  debugconf_subpage[4];
struct ctl_page_index   index[CTL_NUM_MODE_PAGES];
 };

Modified: 

svn commit: r288825 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2015-10-05 Thread Alexander Motin
Author: mav
Date: Mon Oct  5 13:33:02 2015
New Revision: 288825
URL: https://svnweb.freebsd.org/changeset/base/288825

Log:
  MFC r288579: Restore original array_rd_sz semantics.
  
  Before r278702 prefetch was blocked for I/Os > 1MB, after -- >= 1MB.
  1MB I/Os are used for bulk operations in CTL (XCOPY, VERIFY), and disabling
  prefetch for them reduced the performance.

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c  Mon Oct 
 5 13:15:21 2015(r288824)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c  Mon Oct 
 5 13:33:02 2015(r288825)
@@ -450,7 +450,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn,
}
 
if ((flags & DMU_READ_NO_PREFETCH) == 0 && read &&
-   length < zfetch_array_rd_sz) {
+   length <= zfetch_array_rd_sz) {
dmu_zfetch(>dn_zfetch, blkid, nblks);
}
rw_exit(>dn_struct_rwlock);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291456 - stable/10/sys/dev/ata/chipsets

2015-11-29 Thread Alexander Motin
Author: mav
Date: Sun Nov 29 17:14:05 2015
New Revision: 291456
URL: https://svnweb.freebsd.org/changeset/base/291456

Log:
  MFC r290855: Increase reset assertion time from 10 to 100us.
  
  On my own tests I see no effect from this change, but I also can't
  reproduce the reported problem in general.
  
  PR:   127391
  PR:   204554
  Submitted by: s...@iranger.com

Modified:
  stable/10/sys/dev/ata/chipsets/ata-intel.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/ata/chipsets/ata-intel.c
==
--- stable/10/sys/dev/ata/chipsets/ata-intel.c  Sun Nov 29 16:28:40 2015
(r291455)
+++ stable/10/sys/dev/ata/chipsets/ata-intel.c  Sun Nov 29 17:14:05 2015
(r291456)
@@ -422,7 +422,7 @@ ata_intel_reset(device_t dev)
mask |= (1 << smap[1]);
pci_write_config(parent, 0x92,
pci_read_config(parent, 0x92, 2) & ~mask, 2);
-   DELAY(10);
+   DELAY(100);
pci_write_config(parent, 0x92,
pci_read_config(parent, 0x92, 2) | mask, 2);
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291503 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:32:12 2015
New Revision: 291503
URL: https://svnweb.freebsd.org/changeset/base/291503

Log:
  MFC r290504: Make ISP_SLEEP() really sleep instead of spinning.
  
  While there, simplify the wait logic.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_freebsd.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:31:34 2015(r291502)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:32:12 2015(r291503)
@@ -2756,12 +2756,13 @@ static int
 isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay)
 {
mbreg_t mbs;
-   int count, check_for_fabric, r;
+   int check_for_fabric, r;
uint8_t lwfs;
int loopid;
fcparam *fcp;
fcportdb_t *lp;
isp_pdb_t pdb;
+   NANOTIME_T hra, hrb;
 
fcp = FCPARAM(isp, chan);
 
@@ -2772,13 +2773,8 @@ isp_fclink_test(ispsoftc_t *isp, int cha
 * Wait up to N microseconds for F/W to go to a ready state.
 */
lwfs = FW_CONFIG_WAIT;
-   count = 0;
-   while (count < usdelay) {
-   uint64_t enano;
-   uint32_t wrk;
-   NANOTIME_T hra, hrb;
-
-   GET_NANOTIME();
+   GET_NANOTIME();
+   do {
isp_fw_state(isp, chan);
if (lwfs != fcp->isp_fwstate) {
isp_prt(isp, ISP_LOGCONFIG|ISP_LOG_SANCFG, "Chan %d 
Firmware State <%s->%s>", chan, isp_fc_fw_statename((int)lwfs), 
isp_fc_fw_statename((int)fcp->isp_fwstate));
@@ -2787,46 +2783,9 @@ isp_fclink_test(ispsoftc_t *isp, int cha
if (fcp->isp_fwstate == FW_READY) {
break;
}
+   ISP_SLEEP(isp, 1000);
GET_NANOTIME();
-
-   /*
-* Get the elapsed time in nanoseconds.
-* Always guaranteed to be non-zero.
-*/
-   enano = NANOTIME_SUB(, );
-
-   isp_prt(isp, ISP_LOGDEBUG1, "usec%d: 0x%lx->0x%lx enano 
0x%x%08x", count, (long) GET_NANOSEC(), (long) GET_NANOSEC(), 
(uint32_t)(enano >> 32), (uint32_t)(enano));
-
-   /*
-* If the elapsed time is less than 1 millisecond,
-* delay a period of time up to that millisecond of
-* waiting.
-*
-* This peculiar code is an attempt to try and avoid
-* invoking uint64_t math support functions for some
-* platforms where linkage is a problem.
-*/
-   if (enano < (1000 * 1000)) {
-   count += 1000;
-   enano = (1000 * 1000) - enano;
-   while (enano > (uint64_t) 40U) {
-   ISP_SLEEP(isp, 400);
-   enano -= (uint64_t) 40U;
-   }
-   wrk = enano;
-   wrk /= 1000;
-   ISP_SLEEP(isp, wrk);
-   } else {
-   while (enano > (uint64_t) 40U) {
-   count += 400;
-   enano -= (uint64_t) 40U;
-   }
-   wrk = enano;
-   count += (wrk / 1000);
-   }
-   }
-
-
+   } while (NANOTIME_SUB(, ) / 1000 < usdelay);
 
/*
 * If we haven't gone to 'ready' state, return.

Modified: stable/10/sys/dev/isp/isp_freebsd.h
==
--- stable/10/sys/dev/isp/isp_freebsd.h Mon Nov 30 21:31:34 2015
(r291502)
+++ stable/10/sys/dev/isp/isp_freebsd.h Mon Nov 30 21:32:12 2015
(r291503)
@@ -399,8 +399,14 @@ struct isposinfo {
 #defineISP_MEMZERO(a, b)   memset(a, 0, b)
 #defineISP_MEMCPY  memcpy
 #defineISP_SNPRINTFsnprintf
-#defineISP_DELAY   DELAY
-#defineISP_SLEEP(isp, x)   DELAY(x)
+#defineISP_DELAY(x)DELAY(x)
+#if __FreeBSD_version < 129
+#defineISP_SLEEP(isp, x)   msleep(&(isp)->isp_osinfo.lock, \
+&(isp)->isp_osinfo.lock, 0, "isp_sleep", ((x) + tick - 1) / tick)
+#else
+#defineISP_SLEEP(isp, x)   msleep_sbt(&(isp)->isp_osinfo.lock, \
+&(isp)->isp_osinfo.lock, 0, "isp_sleep", (x) * SBT_1US, 0, 0)
+#endif
 
 #defineISP_MIN imin
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291507 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:35:03 2015
New Revision: 291507
URL: https://svnweb.freebsd.org/changeset/base/291507

Log:
  MFC r290978: Add real initial support for RQSTYPE_RPT_ID_ACQ.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_library.c
  stable/10/sys/dev/isp/ispmbox.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:34:17 2015(r291506)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:35:03 2015(r291507)
@@ -6192,6 +6192,9 @@ isp_parse_async_fc(ispsoftc_t *isp, uint
 static int
 isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t 
*optrp)
 {
+   isp_ridacq_t rid;
+   int chan, c;
+
switch (type) {
case RQSTYPE_STATUS_CONT:
isp_prt(isp, ISP_LOG_WARN1, "Ignored Continuation Response");
@@ -6199,6 +6202,23 @@ isp_handle_other_response(ispsoftc_t *is
case RQSTYPE_MARKER:
isp_prt(isp, ISP_LOG_WARN1, "Marker Response");
return (1);
+   case RQSTYPE_RPT_ID_ACQ:
+   isp_get_ridacq(isp, (isp_ridacq_t *)hp, );
+   if (rid.ridacq_format == 0) {
+   for (chan = 0; chan < isp->isp_nchan; chan++) {
+   fcparam *fcp = FCPARAM(isp, chan);
+   if (fcp->role == ISP_ROLE_NONE)
+   continue;
+   c = (chan == 0) ? 127 : (chan - 1);
+   if (rid.ridacq_map[c / 16] & (1 << (c % 16)))
+   isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
+   chan, ISPASYNC_CHANGE_OTHER);
+   }
+   } else {
+   isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
+   rid.ridacq_vp_index, ISPASYNC_CHANGE_OTHER);
+   }
+   return (1);
case RQSTYPE_ATIO:
case RQSTYPE_CTIO:
case RQSTYPE_ENABLE_LUN:
@@ -6219,15 +6239,6 @@ isp_handle_other_response(ispsoftc_t *is
}
 #endif
/* FALLTHROUGH */
-   case RQSTYPE_RPT_ID_ACQ:
-   if (IS_24XX(isp)) {
-   isp_ridacq_t rid;
-   isp_get_ridacq(isp, (isp_ridacq_t *)hp, );
-   if (rid.ridacq_format == 0) {
-   }
-   return (1);
-   }
-   /* FALLTHROUGH */
case RQSTYPE_REQUEST:
default:
ISP_DELAY(100);

Modified: stable/10/sys/dev/isp/isp_library.c
==
--- stable/10/sys/dev/isp/isp_library.c Mon Nov 30 21:34:17 2015
(r291506)
+++ stable/10/sys/dev/isp/isp_library.c Mon Nov 30 21:35:03 2015
(r291507)
@@ -1733,6 +1733,10 @@ isp_get_ridacq(ispsoftc_t *isp, isp_rida
int i;
isp_get_hdr(isp, >ridacq_hdr, >ridacq_hdr);
ISP_IOXGET_32(isp, >ridacq_handle, dst->ridacq_handle);
+   ISP_IOXGET_8(isp, >ridacq_vp_acquired, dst->ridacq_vp_acquired);
+   ISP_IOXGET_8(isp, >ridacq_vp_setup, dst->ridacq_vp_setup);
+   ISP_IOXGET_8(isp, >ridacq_vp_index, dst->ridacq_vp_index);
+   ISP_IOXGET_8(isp, >ridacq_vp_status, dst->ridacq_vp_status);
ISP_IOXGET_16(isp, >ridacq_vp_port_lo, dst->ridacq_vp_port_lo);
ISP_IOXGET_8(isp, >ridacq_vp_port_hi, dst->ridacq_vp_port_hi);
ISP_IOXGET_8(isp, >ridacq_format, dst->ridacq_format);
@@ -1742,17 +1746,6 @@ isp_get_ridacq(ispsoftc_t *isp, isp_rida
for (i = 0; i < sizeof (src->ridacq_reserved1) / sizeof 
(src->ridacq_reserved1[0]); i++) {
ISP_IOXGET_16(isp, >ridacq_reserved1[i], 
dst->ridacq_reserved1[i]);
}
-   if (dst->ridacq_format == 0) {
-   ISP_IOXGET_8(isp, >un.type0.ridacq_vp_acquired, 
dst->un.type0.ridacq_vp_acquired);
-   ISP_IOXGET_8(isp, >un.type0.ridacq_vp_setup, 
dst->un.type0.ridacq_vp_setup);
-   ISP_IOXGET_16(isp, >un.type0.ridacq_reserved0, 
dst->un.type0.ridacq_reserved0);
-   } else if (dst->ridacq_format == 1) {
-   ISP_IOXGET_16(isp, >un.type1.ridacq_vp_count, 
dst->un.type1.ridacq_vp_count);
-   ISP_IOXGET_8(isp, >un.type1.ridacq_vp_index, 
dst->un.type1.ridacq_vp_index);
-   ISP_IOXGET_8(isp, >un.type1.ridacq_vp_status, 
dst->un.type1.ridacq_vp_status);
-   } else {
-   ISP_MEMZERO(>un, sizeof (dst->un));
-   }
 }
 
 

Modified: stable/10/sys/dev/isp/ispmbox.h
==
--- stable/10/sys/dev/isp/ispmbox.h Mon Nov 30 21:34:17 2015
(r291506)
+++ stable/10/sys/dev/isp/ispmbox.h Mon Nov 30 21:35:03 2015
(r291507)
@@ -1485,18 +1485,10 

svn commit: r291529 - in stable/10: share/man/man4 sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:56:31 2015
New Revision: 291529
URL: https://svnweb.freebsd.org/changeset/base/291529

Log:
  MFC r291209: Fix target mode support for Qlogic 2200 FC adapters.
  
  Now target mode works for all supported FC adapters except ancient 2100,
  which is not tested.

Modified:
  stable/10/share/man/man4/isp.4
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_freebsd.c
  stable/10/sys/dev/isp/isp_library.c
  stable/10/sys/dev/isp/isp_pci.c
  stable/10/sys/dev/isp/ispmbox.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man4/isp.4
==
--- stable/10/share/man/man4/isp.4  Mon Nov 30 21:55:35 2015
(r291528)
+++ stable/10/share/man/man4/isp.4  Mon Nov 30 21:56:31 2015
(r291529)
@@ -1,7 +1,6 @@
-.\" $NetBSD: isp.4,v 1.5 1999/12/18 18:33:05 mjacob Exp $
-.\"
-.\" Copyright (c) 1998, 1999, 2001
-.\" Matthew Jacob, for NASA/Ames Research Center
+.\" Copyright (c) 2009-2015 Alexander Motin <m...@freebsd.org>
+.\" Copyright (c) 2006 Marcus Alves Grando
+.\" Copyright (c) 1998-2001 Matthew Jacob, for NASA/Ames Research Center
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -25,8 +24,6 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" Additional Copyright (c) 2006 by Marcus Alves Grando
-.\"
 .\" $FreeBSD$
 .\"
 .Dd November 22, 2015
@@ -34,7 +31,7 @@
 .Os
 .Sh NAME
 .Nm isp
-.Nd Qlogic based SCSI and FibreChannel SCSI Host Adapters
+.Nd Qlogic based SPI and FibreChannel SCSI Host Adapters
 .Sh SYNOPSIS
 To compile this driver into the kernel,
 place the following lines in your
@@ -52,23 +49,19 @@ isp_load="YES"
 .Ed
 .Sh DESCRIPTION
 This driver provides access to
-.Tn SCSI
+.Tn SPI
 or
 .Tn FibreChannel
-devices.
+SCSI devices.
 .Pp
-SCSI features include support for Ultra SCSI and wide mode transactions
-for
+SPI supports initiator mode for Ultra SCSI and wide mode transactions for
 .Tn SCSI ,
 Ultra2 LVD (1080, 1280), and Ultra3 LVD (10160, 12160).
 .Pp
-Fibre Channel support uses FCP SCSI profile for
-.Tn FibreChannel ,
-and utilizes Class 3 and Class 2 (2200 and later) connections.
+Fibre Channel supports initiator and target modes of FCP SCSI profile,
+utilizing Class 3 and Class 2 (2200 and later) connections.
 Support is available for Public and Private loops, Point-to-Point
 and Fabric connections.
-The newer 2-Gigabit cards (2300, 2312, 2322), 4-Gigabit (2422, 2432)
-and 8-Gigabit (2532) are supported in both initiator and target modes.
 .Sh FIRMWARE
 Firmware loading is supported if the
 .Xr ispfw 4
@@ -120,8 +113,7 @@ Optical 4Gb Fibre Channel PCIe cards.
 Optical 8Gb Fibre Channel PCIe cards.
 .El
 .Sh CONFIGURATION OPTIONS
-Target mode support for 23xx and above Fibre Channel adapters may be
-enabled with the
+Target mode support for Fibre Channel adapters may be enabled with the
 .Pp
 .Cd options ISP_TARGET_MODE
 .Pp

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:55:35 2015(r291528)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:56:31 2015(r291529)
@@ -1733,7 +1733,12 @@ isp_fibre_init(ispsoftc_t *isp)
icbp->icb_fwoptions &= ~ICBOPT_TGT_ENABLE;
}
 
-   if (fcp->role & ISP_ROLE_INITIATOR) {
+   /*
+* For some reason my 2200 does not generate ATIOs in target mode
+* if initiator is disabled.  Extra logins are better then target
+* not working at all.
+*/
+   if ((fcp->role & ISP_ROLE_INITIATOR) || IS_2100(isp) || IS_2200(isp)) {
icbp->icb_fwoptions &= ~ICBOPT_INI_DISABLE;
} else {
icbp->icb_fwoptions |= ICBOPT_INI_DISABLE;
@@ -1954,6 +1959,8 @@ isp_fibre_init(ispsoftc_t *isp)
}
isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init: fwopt 0x%x xfwopt 0x%x 
zfwopt 0x%x",
icbp->icb_fwoptions, icbp->icb_xfwoptions, icbp->icb_zfwoptions);
+   if (isp->isp_dblev & ISP_LOGDEBUG1)
+   isp_print_bytes(isp, "isp_fibre_init", sizeof (*icbp), icbp);
 
isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch);
 
@@ -1966,17 +1973,14 @@ isp_fibre_init(ispsoftc_t *isp)
mbs.param[3] = DMA_WD0(fcp->isp_scdma);
mbs.param[6] = DMA_WD3(fcp->isp_scdma);
mbs.param[7] = DMA_WD2(fcp->isp_scdma);
-   mbs.logval = MBLOGALL;
isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %p (%08x%08x)",
fcp->isp_scratch, (uint32_t) ((uint

svn commit: r291499 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:29:38 2015
New Revision: 291499
URL: https://svnweb.freebsd.org/changeset/base/291499

Log:
  MFC r290118: Change the way how target mode is enabled on 23xx chips.
  
  Without docs I am not completely sure about this, but on my tests new
  method works better then previous, at least with our latest firmware.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_freebsd.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:28:53 2015(r291498)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:29:38 2015(r291499)
@@ -1895,7 +1895,7 @@ isp_fibre_init(ispsoftc_t *isp)
icbp->icb_logintime = ICB_LOGIN_TOV;
 
 #ifdef ISP_TARGET_MODE
-   if (ISP_FW_NEWER_THAN(isp, 3, 25, 0) && (icbp->icb_fwoptions & 
ICBOPT_TGT_ENABLE)) {
+   if (IS_23XX(isp) && (icbp->icb_fwoptions & ICBOPT_TGT_ENABLE)) {
icbp->icb_lunenables = 0x;
icbp->icb_ccnt = DFLT_CMND_CNT;
icbp->icb_icnt = DFLT_INOT_CNT;

Modified: stable/10/sys/dev/isp/isp_freebsd.c
==
--- stable/10/sys/dev/isp/isp_freebsd.c Mon Nov 30 21:28:53 2015
(r291498)
+++ stable/10/sys/dev/isp/isp_freebsd.c Mon Nov 30 21:29:38 2015
(r291499)
@@ -1414,7 +1414,8 @@ isp_enable_deferred(ispsoftc_t *isp, int
 
ISP_GET_PC(isp, bus, tm_luns_enabled, luns_already_enabled);
isp_prt(isp, ISP_LOGTINFO, "%s: bus %d lun %u luns_enabled %d", 
__func__, bus, lun, luns_already_enabled);
-   if (IS_24XX(isp) || (IS_FC(isp) && luns_already_enabled)) {
+   if (IS_23XX(isp) || IS_24XX(isp) ||
+   (IS_FC(isp) && luns_already_enabled)) {
status = CAM_REQ_CMP;
} else {
int cmd_cnt, not_cnt;
@@ -1485,7 +1486,7 @@ isp_disable_lun(ispsoftc_t *isp, union c
/*
 * If we're a 24XX card, we're done.
 */
-   if (IS_24XX(isp)) {
+   if (IS_23XX(isp) || IS_24XX(isp)) {
status = CAM_REQ_CMP;
goto done;
}
@@ -1501,7 +1502,7 @@ isp_disable_lun(ispsoftc_t *isp, union c
if (isp_lun_cmd(isp, RQSTYPE_ENABLE_LUN, bus, lun, 0, 0)) {
status = CAM_RESRC_UNAVAIL;
} else {
-   mtx_sleep(ccb, >isp_lock, PRIBIO, "isp_disable_lun", 0);
+   mtx_sleep(, >isp_lock, PRIBIO, "isp_disable_lun", 
0);
}
isp->isp_osinfo.rptr = NULL;
 done:
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291505 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:33:30 2015
New Revision: 291505
URL: https://svnweb.freebsd.org/changeset/base/291505

Log:
  MFC r290507: Rework r290504.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_freebsd.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:32:52 2015(r291504)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:33:30 2015(r291505)
@@ -2774,7 +2774,7 @@ isp_fclink_test(ispsoftc_t *isp, int cha
 */
lwfs = FW_CONFIG_WAIT;
GET_NANOTIME();
-   do {
+   while (1) {
isp_fw_state(isp, chan);
if (lwfs != fcp->isp_fwstate) {
isp_prt(isp, ISP_LOGCONFIG|ISP_LOG_SANCFG, "Chan %d 
Firmware State <%s->%s>", chan, isp_fc_fw_statename((int)lwfs), 
isp_fc_fw_statename((int)fcp->isp_fwstate));
@@ -2783,9 +2783,11 @@ isp_fclink_test(ispsoftc_t *isp, int cha
if (fcp->isp_fwstate == FW_READY) {
break;
}
-   ISP_SLEEP(isp, 1000);
GET_NANOTIME();
-   } while (NANOTIME_SUB(, ) / 1000 < usdelay);
+   if ((NANOTIME_SUB(, ) / 1000 + 1000 >= usdelay))
+   break;
+   ISP_SLEEP(isp, 1000);
+   }
 
/*
 * If we haven't gone to 'ready' state, return.

Modified: stable/10/sys/dev/isp/isp_freebsd.h
==
--- stable/10/sys/dev/isp/isp_freebsd.h Mon Nov 30 21:32:52 2015
(r291504)
+++ stable/10/sys/dev/isp/isp_freebsd.h Mon Nov 30 21:33:30 2015
(r291505)
@@ -401,10 +401,10 @@ struct isposinfo {
 #defineISP_SNPRINTFsnprintf
 #defineISP_DELAY(x)DELAY(x)
 #if __FreeBSD_version < 129
-#defineISP_SLEEP(isp, x)   msleep(&(isp)->isp_osinfo.lock, \
+#defineISP_SLEEP(isp, x)   msleep(&(isp)->isp_osinfo.is_exiting, \
 &(isp)->isp_osinfo.lock, 0, "isp_sleep", ((x) + tick - 1) / tick)
 #else
-#defineISP_SLEEP(isp, x)   msleep_sbt(&(isp)->isp_osinfo.lock, \
+#defineISP_SLEEP(isp, x)   
msleep_sbt(&(isp)->isp_osinfo.is_exiting, \
 &(isp)->isp_osinfo.lock, 0, "isp_sleep", (x) * SBT_1US, 0, 0)
 #endif
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291506 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:34:17 2015
New Revision: 291506
URL: https://svnweb.freebsd.org/changeset/base/291506

Log:
  MFC r290830: Fix/improve CRN tracking.

Modified:
  stable/10/sys/dev/isp/isp_freebsd.c
  stable/10/sys/dev/isp/isp_freebsd.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp_freebsd.c
==
--- stable/10/sys/dev/isp/isp_freebsd.c Mon Nov 30 21:33:30 2015
(r291505)
+++ stable/10/sys/dev/isp/isp_freebsd.c Mon Nov 30 21:34:17 2015
(r291506)
@@ -4249,16 +4249,9 @@ isp_action(struct cam_sim *sim, union cc
break;
 #endif
case XPT_RESET_DEV: /* BDR the specified SCSI device */
-   {
-   struct isp_fc *fc;
-
bus = cam_sim_bus(xpt_path_sim(ccb->ccb_h.path));
tgt = ccb->ccb_h.target_id;
tgt |= (bus << 16);
-   if (IS_FC(isp))
-   fc = ISP_FC_PC(isp, bus);
-   else
-   fc = NULL;
 
error = isp_control(isp, ISPCTL_RESET_DEV, bus, tgt);
if (error) {
@@ -4269,14 +4262,13 @@ isp_action(struct cam_sim *sim, union cc
 * Reference Number, because the target will expect
 * that we re-start the CRN at 1 after a reset.
 */
-   if (fc != NULL)
-   isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
+   if (IS_FC(isp))
+   isp_fcp_reset_crn(isp, bus, tgt, /*tgt_set*/ 1);
 
ccb->ccb_h.status = CAM_REQ_CMP;
}
xpt_done(ccb);
break;
-   }
case XPT_ABORT: /* Abort the specified CCB */
{
union ccb *accb = ccb->cab.abort_ccb;
@@ -4854,7 +4846,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cm
isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGDEBUG0, 
"Starting Loop Down Timer @ %lu", (unsigned long) time_uptime);
}
}
-   isp_fcp_reset_crn(fc, /*tgt*/0, /*tgt_set*/ 0);
+   isp_fcp_reset_crn(isp, bus, /*tgt*/0, /*tgt_set*/ 0);
 
isp_prt(isp, ISP_LOGINFO, "Chan %d: %s", bus, msg);
break;
@@ -4887,7 +4879,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cm
if ((FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) &&
(lp->prli_word3 & PRLI_WD3_TARGET_FUNCTION)) {
lp->is_target = 1;
-   isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
+   isp_fcp_reset_crn(isp, bus, tgt, /*tgt_set*/ 1);
isp_make_here(isp, lp, bus, tgt);
}
if ((FCPARAM(isp, bus)->role & ISP_ROLE_TARGET) &&
@@ -4917,11 +4909,11 @@ changed:
 (lp->new_prli_word3 & PRLI_WD3_TARGET_FUNCTION))) {
lp->is_target = !lp->is_target;
if (lp->is_target) {
-   isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
+   isp_fcp_reset_crn(isp, bus, tgt, /*tgt_set*/ 1);
isp_make_here(isp, lp, bus, tgt);
} else {
isp_make_gone(isp, lp, bus, tgt);
-   isp_fcp_reset_crn(fc, tgt, /*tgt_set*/ 1);
+   isp_fcp_reset_crn(isp, bus, tgt, /*tgt_set*/ 1);
}
}
if (lp->is_initiator !=
@@ -5490,23 +5482,23 @@ isp_common_dmateardown(ispsoftc_t *isp, 
  * (needed for events like a LIP).
  */
 void
-isp_fcp_reset_crn(struct isp_fc *fc, uint32_t tgt, int tgt_set)
+isp_fcp_reset_crn(ispsoftc_t *isp, int chan, uint32_t tgt, int tgt_set)
 {
-   int i;
+   struct isp_fc *fc = ISP_FC_PC(isp, chan);
struct isp_nexus *nxp;
+   int i;
 
if (tgt_set == 0)
-   isp_prt(fc->isp, ISP_LOG_SANCFG, "resetting CRN on all 
targets");
+   isp_prt(isp, ISP_LOGDEBUG0,
+   "Chan %d resetting CRN on all targets", chan);
else
-   isp_prt(fc->isp, ISP_LOG_SANCFG, "resetting CRN target %u", 
tgt);
+   isp_prt(isp, ISP_LOGDEBUG0,
+   "Chan %d resetting CRN on target %u", chan, tgt);
 
for (i = 0; i < NEXUS_HASH_WIDTH; i++) {
-   nxp = fc->nexus_hash[i];
-   while (nxp) {
-   if ((tgt_set != 0) && (tgt == nxp->tgt))
+   for (nxp = fc->nexus_hash[i]; nxp != NULL; nxp = nxp->next) {
+   if (tgt_set == 0 || tgt == nxp->tgt)
nxp->crnseed = 0;
-
-   nxp = nxp->next;
}
}
 }
@@ -5550,15 +5542,11 @@ 

svn commit: r291517 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:42:35 2015
New Revision: 291517
URL: https://svnweb.freebsd.org/changeset/base/291517

Log:
  MFC r291144: Fix target mode with fabric for pre-24xx chips.
  
  For those chips we are not receiving login events, adding initiators
  based on ATIO requests.  But there is no port ID in that structure, so
  in fabric mode we have to explicitly fetch it from firmware to be able
  to do normal scan after that.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_freebsd.c
  stable/10/sys/dev/isp/isp_library.c
  stable/10/sys/dev/isp/ispvar.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:41:56 2015(r291516)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:42:35 2015(r291517)
@@ -2320,7 +2320,8 @@ isp_mark_portdb(ispsoftc_t *isp, int cha
lp = >portdb[i];
if (lp->state == FC_PORTDB_STATE_NIL)
continue;
-   if ((lp->portid & 0xfffc00) == 0xfffc00)
+   if (lp->portid >= DOMAIN_CONTROLLER_BASE &&
+   lp->portid <= DOMAIN_CONTROLLER_END)
continue;
fcp->portdb[i].probational = 1;
}
@@ -2787,9 +2788,6 @@ isp_fclink_test(ispsoftc_t *isp, int cha
 
fcp = FCPARAM(isp, chan);
 
-   /* Mark port database entries probational for following scan. */
-   isp_mark_portdb(isp, chan);
-
if (fcp->isp_loopstate >= LOOP_LTEST_DONE)
return (0);
 
@@ -3079,6 +3077,48 @@ isp_pdb_add_update(ispsoftc_t *isp, int 
 }
 
 /*
+ * Fix port IDs for logged-in initiators on pre-2400 chips.
+ * For those chips we are not receiving login events, adding initiators
+ * based on ATIO requests, but there is no port ID in that structure.
+ */
+static void
+isp_fix_portids(ispsoftc_t *isp, int chan)
+{
+   fcparam *fcp = FCPARAM(isp, chan);
+   isp_pdb_t pdb;
+   uint64_t wwpn;
+   int i, r;
+
+   for (i = 0; i < MAX_FC_TARG; i++) {
+   fcportdb_t *lp = >portdb[i];
+
+   if (lp->state == FC_PORTDB_STATE_NIL ||
+   lp->state == FC_PORTDB_STATE_ZOMBIE)
+   continue;
+   if (VALID_PORT(lp->portid))
+   continue;
+
+   r = isp_getpdb(isp, chan, lp->handle, , 1);
+   if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
+   return;
+   if (r != 0) {
+   isp_prt(isp, ISP_LOGDEBUG1,
+   "Chan %d FC Scan Loop handle %d returned %x",
+   chan, lp->handle, r);
+   continue;
+   }
+
+   MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
+   if (lp->port_wwn != wwpn)
+   continue;
+   lp->portid = lp->new_portid = pdb.portid;
+   isp_prt(isp, ISP_LOG_SANCFG,
+   "Chan %d Port 0x%06x@0x%04x is fixed",
+   chan, pdb.portid, pdb.handle);
+   }
+}
+
+/*
  * Scan local loop for devices.
  */
 static int
@@ -3097,13 +3137,18 @@ isp_scan_loop(ispsoftc_t *isp, int chan)
return (0);
}
isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC loop scan", chan);
+   fcp->isp_loopstate = LOOP_SCANNING_LOOP;
if (TOPO_IS_FABRIC(fcp->isp_topo)) {
+   if (!IS_24XX(isp)) {
+   isp_fix_portids(isp, chan);
+   if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
+   goto abort;
+   }
isp_prt(isp, ISP_LOG_SANCFG,
"Chan %d FC loop scan done (no loop)", chan);
fcp->isp_loopstate = LOOP_LSCAN_DONE;
return (0);
}
-   fcp->isp_loopstate = LOOP_SCANNING_LOOP;
 
lim = LOCAL_LOOP_LIM;
r = isp_gethandles(isp, chan, handles, , 1, 1);
@@ -3121,6 +3166,7 @@ isp_scan_loop(ispsoftc_t *isp, int chan)
/*
 * Run through the list and get the port database info for each one.
 */
+   isp_mark_portdb(isp, chan);
for (idx = 0; idx < lim; idx++) {
handle = handles[idx];
 
@@ -3162,8 +3208,6 @@ abort:
isp_prt(isp, ISP_LOGDEBUG1,
"Chan %d FC Scan Loop handle %d returned %x",
chan, handle, r);
-   if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
-   goto abort;
continue;
}
 
@@ -3363,13 +3407,13 @@ isp_scan_fabric(ispsoftc_t *isp, int cha
return (0);
}
isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC fabric scan", chan);
+   fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
if (!TOPO_IS_FABRIC(fcp->isp_topo)) {
 

svn commit: r291530 - in stable/10: share/man/man4 sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:57:16 2015
New Revision: 291530
URL: https://svnweb.freebsd.org/changeset/base/291530

Log:
  MFC r291221: Remove "disable" hint, which duplicates system-wide "disabled".

Modified:
  stable/10/share/man/man4/isp.4
  stable/10/sys/dev/isp/isp_freebsd.h
  stable/10/sys/dev/isp/isp_pci.c
  stable/10/sys/dev/isp/isp_sbus.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man4/isp.4
==
--- stable/10/share/man/man4/isp.4  Mon Nov 30 21:56:31 2015
(r291529)
+++ stable/10/share/man/man4/isp.4  Mon Nov 30 21:57:16 2015
(r291530)
@@ -124,8 +124,6 @@ The following options are switchable by 
 .Pp
 They are:
 .Bl -tag -width indent
-.It Va hint.isp.0.disable
-A hint value to disable driver in kernel.
 .It Va hint.isp.0.fwload_disable
 A hint value to disable loading of firmware
 .Xr ispfw 4 .

Modified: stable/10/sys/dev/isp/isp_freebsd.h
==
--- stable/10/sys/dev/isp/isp_freebsd.h Mon Nov 30 21:56:31 2015
(r291529)
+++ stable/10/sys/dev/isp/isp_freebsd.h Mon Nov 30 21:57:16 2015
(r291530)
@@ -311,7 +311,6 @@ struct isposinfo {
timer_active: 1,
autoconf: 1,
ehook_active: 1,
-   disabled: 1,
mbox_sleeping   : 1,
mbox_sleep_ok   : 1,
mboxcmd_done: 1,

Modified: stable/10/sys/dev/isp/isp_pci.c
==
--- stable/10/sys/dev/isp/isp_pci.c Mon Nov 30 21:56:31 2015
(r291529)
+++ stable/10/sys/dev/isp/isp_pci.c Mon Nov 30 21:57:16 2015
(r291530)
@@ -456,16 +456,6 @@ isp_get_generic_options(device_t dev, is
 {
int tval;
 
-   /*
-* Figure out if we're supposed to skip this one.
-*/
-   tval = 0;
-   if (resource_int_value(device_get_name(dev), device_get_unit(dev), 
"disable", ) == 0 && tval) {
-   device_printf(dev, "disabled at user request\n");
-   isp->isp_osinfo.disabled = 1;
-   return;
-   }
-   
tval = 0;
if (resource_int_value(device_get_name(dev), device_get_unit(dev), 
"fwload_disable", ) == 0 && tval != 0) {
isp->isp_confopts |= ISP_CFG_NORELOAD;
@@ -710,16 +700,6 @@ isp_pci_attach(device_t dev)
isp_get_generic_options(dev, isp);
 
/*
-* Check to see if options have us disabled
-*/
-   if (isp->isp_osinfo.disabled) {
-   /*
-* But return zero to preserve unit numbering
-*/
-   return (0);
-   }
-
-   /*
 * Get PCI options- which in this case are just mapping preferences.
 */
isp_get_pci_options(dev, , );

Modified: stable/10/sys/dev/isp/isp_sbus.c
==
--- stable/10/sys/dev/isp/isp_sbus.cMon Nov 30 21:56:31 2015
(r291529)
+++ stable/10/sys/dev/isp/isp_sbus.cMon Nov 30 21:57:16 2015
(r291530)
@@ -155,19 +155,6 @@ isp_sbus_attach(device_t dev)
sbs->sbus_dev = dev;
sbs->sbus_mdvec = mdvec;
 
-   /*
-* Figure out if we're supposed to skip this one.
-* If we are, we actually go to ISP_ROLE_NONE.
-*/
-
-   tval = 0;
-   if (resource_int_value(device_get_name(dev), device_get_unit(dev),
-   "disable", ) == 0 && tval) {
-   device_printf(dev, "device is disabled\n");
-   /* but return 0 so the !$)$)*!$*) unit isn't reused */
-   return (0);
-   }
-   
role = 0;
if (resource_int_value(device_get_name(dev), device_get_unit(dev),
"role", ) == 0 &&
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291510 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:37:22 2015
New Revision: 291510
URL: https://svnweb.freebsd.org/changeset/base/291510

Log:
  MFC r290993, r290994: Unify and cleanup FC ports scan.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_library.c
  stable/10/sys/dev/isp/ispvar.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:36:23 2015(r291509)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:37:22 2015(r291510)
@@ -64,12 +64,6 @@ __FBSDID("$FreeBSD$");
  * General defines
  */
 #defineMBOX_DELAY_COUNT100 / 100
-#defineISP_MARK_PORTDB(a, b, c)\
-   do {\
-   isp_prt(isp, ISP_LOG_SANCFG,\
-   "Chan %d ISP_MARK_PORTDB@LINE %d", (b), __LINE__);  \
-   isp_mark_portdb((a), (b), (c)); \
-   } while (0)
 
 /*
  * Local static data
@@ -132,7 +126,7 @@ static int isp_login_device(ispsoftc_t *
 static int isp_register_fc4_type(ispsoftc_t *, int);
 static int isp_register_fc4_type_24xx(ispsoftc_t *, int);
 static uint16_t isp_next_handle(ispsoftc_t *, uint16_t *);
-static void isp_fw_state(ispsoftc_t *, int);
+static int isp_fw_state(ispsoftc_t *, int);
 static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int);
 static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
 
@@ -149,6 +143,19 @@ static void isp_parse_nvram_12160(ispsof
 static void isp_parse_nvram_2100(ispsoftc_t *, uint8_t *);
 static void isp_parse_nvram_2400(ispsoftc_t *, uint8_t *);
 
+static void
+isp_change_fw_state(ispsoftc_t *isp, int chan, int state)
+{
+   fcparam *fcp = FCPARAM(isp, chan);
+
+   if (fcp->isp_fwstate == state)
+   return;
+   isp_prt(isp, ISP_LOGCONFIG|ISP_LOG_SANCFG,
+   "Chan %d Firmware state <%s->%s>", chan,
+   isp_fc_fw_statename(fcp->isp_fwstate), isp_fc_fw_statename(state));
+   fcp->isp_fwstate = state;
+}
+
 /*
  * Reset Hardware.
  *
@@ -1267,8 +1274,9 @@ isp_reset(ispsoftc_t *isp, int do_load_d
isp->isp_nchan = 1;
}
}
-   for (i = 0; i < isp->isp_nchan; i++) {
-   isp_fw_state(isp, i);
+   if (IS_FC(isp)) {
+   for (i = 0; i < isp->isp_nchan; i++)
+   isp_change_fw_state(isp, i, FW_CONFIG_WAIT);
}
if (isp->isp_dead) {
isp_shutdown(isp);
@@ -2577,7 +2585,10 @@ isp_getpdb(ispsoftc_t *isp, int chan, ui
pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8);
-   isp_prt(isp, ISP_LOG_SANCFG, "Chan %d handle 0x%x Port 0x%06x 
flags 0x%x curstate %x", chan, id, pdb->portid, un.bill.pdb_flags, 
un.bill.pdb_curstate);
+   isp_prt(isp, ISP_LOGDEBUG1,
+   "Chan %d handle 0x%x Port 0x%06x flags 0x%x curstate %x",
+   chan, id, pdb->portid, un.bill.pdb_flags,
+   un.bill.pdb_curstate);
if (un.bill.pdb_curstate < PDB2400_STATE_PLOGI_DONE || 
un.bill.pdb_curstate > PDB2400_STATE_LOGGED_IN) {
mbs.param[0] = MBOX_NOT_LOGGED_IN;
if (dolock) {
@@ -2592,6 +2603,8 @@ isp_getpdb(ispsoftc_t *isp, int chan, ui
pdb->portid = BITS2WORD(un.fred.pdb_portid_bits);
ISP_MEMCPY(pdb->portname, un.fred.pdb_portname, 8);
ISP_MEMCPY(pdb->nodename, un.fred.pdb_nodename, 8);
+   isp_prt(isp, ISP_LOGDEBUG1,
+   "Chan %d handle 0x%x Port 0x%06x", chan, id, pdb->portid);
}
if (dolock) {
FC_SCRATCH_RELEASE(isp, chan);
@@ -2699,13 +2712,8 @@ static uint64_t
 isp_get_wwn(ispsoftc_t *isp, int chan, int loopid, int nodename)
 {
uint64_t wwn = INI_NONE;
-   fcparam *fcp = FCPARAM(isp, chan);
mbreg_t mbs;
 
-   if (fcp->isp_fwstate < FW_READY ||
-   fcp->isp_loopstate < LOOP_PDB_RCVD) {
-   return (wwn);
-   }
MBSINIT(, MBOX_GET_PORT_NAME,
MBLOGALL & ~MBLOGMASK(MBOX_COMMAND_PARAM_ERROR), 50);
if (ISP_CAP_2KLOGIN(isp)) {
@@ -2758,7 +2766,6 @@ isp_fclink_test(ispsoftc_t *isp, int cha
 {
mbreg_t mbs;
int check_for_fabric, r;
-   uint8_t lwfs;
int loopid;
fcparam *fcp;
fcportdb_t *lp;
@@ -2767,20 +2774,21 @@ isp_fclink_test(ispsoftc_t *isp, int cha
 
fcp = FCPARAM(isp, chan);
 
-   isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Link Test Entry", chan);
-   ISP_MARK_PORTDB(isp, chan, 1);
+   /* Mark port database entries for following scan. */
+   

svn commit: r291523 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:47:11 2015
New Revision: 291523
URL: https://svnweb.freebsd.org/changeset/base/291523

Log:
  MFC r291163:
  Explicitly call SEND CHANGE REQUEST for pre-24xx chips in target mode.
  
  While later firmware always registers for RSCN requests, older one does
  it only in initiator mode.  But in target mode there RSCN can be the only
  way to detect gone intiator.

Modified:
  stable/10/sys/dev/isp/isp.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:46:21 2015(r291522)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:47:11 2015(r291523)
@@ -122,6 +122,7 @@ static int isp_gid_ft_sns(ispsoftc_t *, 
 static int isp_gid_ft_ct_passthru(ispsoftc_t *, int);
 static int isp_scan_fabric(ispsoftc_t *, int);
 static int isp_login_device(ispsoftc_t *, int, uint32_t, isp_pdb_t *, uint16_t 
*);
+static int isp_send_change_request(ispsoftc_t *, int);
 static int isp_register_fc4_type(ispsoftc_t *, int);
 static int isp_register_fc4_type_24xx(ispsoftc_t *, int);
 static int isp_register_fc4_features_24xx(ispsoftc_t *, int);
@@ -2904,6 +2905,8 @@ isp_fclink_test(ispsoftc_t *isp, int cha
} else {
fcp->isp_sns_hdl = SNS_ID;
r = isp_register_fc4_type(isp, chan);
+   if (r == 0 && fcp->role == ISP_ROLE_TARGET)
+   isp_send_change_request(isp, chan);
}
if (r) {
isp_prt(isp, ISP_LOGWARN|ISP_LOG_SANCFG, "%s: register 
fc4 type failed", __func__);
@@ -3733,6 +3736,18 @@ isp_login_device(ispsoftc_t *isp, int ch
 }
 
 static int
+isp_send_change_request(ispsoftc_t *isp, int chan)
+{
+   mbreg_t mbs;
+
+   MBSINIT(, MBOX_SEND_CHANGE_REQUEST, MBLOGALL, 50);
+   mbs.param[1] = 0x03;
+   mbs.param[9] = chan;
+   isp_mboxcmd(isp, );
+   return (mbs.param[0] == MBOX_COMMAND_COMPLETE ? 0 : -1);
+}
+
+static int
 isp_register_fc4_type(ispsoftc_t *isp, int chan)
 {
fcparam *fcp = FCPARAM(isp, chan);
@@ -5815,8 +5830,8 @@ isp_parse_async_fc(ispsoftc_t *isp, uint
fcp = FCPARAM(isp, chan);
if (fcp->role == ISP_ROLE_NONE)
break;
-   if (fcp->isp_loopstate > LOOP_LSCAN_DONE)
-   fcp->isp_loopstate = LOOP_LSCAN_DONE;
+   if (fcp->isp_loopstate > LOOP_LTEST_DONE)
+   fcp->isp_loopstate = LOOP_LTEST_DONE;
isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan,
ISPASYNC_CHANGE_SNS, portid);
break;
@@ -6912,7 +6927,7 @@ static const uint32_t mbpfc[] = {
ISP_FC_OPMAP(0x00, 0x00),   /* 0x6d: */
ISP_FC_OPMAP(0xcf, 0x03),   /* 0x6e: MBOX_SEND_SNS */
ISP_FC_OPMAP(0x0f, 0x07),   /* 0x6f: MBOX_FABRIC_LOGIN */
-   ISP_FC_OPMAP(0x03, 0x01),   /* 0x70: MBOX_SEND_CHANGE_REQUEST */
+   ISP_FC_OPMAP_HALF(0x02, 0x03, 0x00, 0x03),  /* 0x70: 
MBOX_SEND_CHANGE_REQUEST */
ISP_FC_OPMAP(0x03, 0x03),   /* 0x71: MBOX_FABRIC_LOGOUT */
ISP_FC_OPMAP(0x0f, 0x0f),   /* 0x72: MBOX_INIT_LIP_LOGIN */
ISP_FC_OPMAP(0x00, 0x00),   /* 0x73: */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291531 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:57:54 2015
New Revision: 291531
URL: https://svnweb.freebsd.org/changeset/base/291531

Log:
  MFC r291265: Rename ASYNC_LIP_F8 to ASYNC_LIP_NOS_OLS_RECV.
  
  New name better repsents its meaning for modern chips.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_target.c
  stable/10/sys/dev/isp/ispmbox.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:57:16 2015(r291530)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:57:54 2015(r291531)
@@ -5646,7 +5646,7 @@ isp_parse_async_fc(ispsoftc_t *isp, uint
 #endif
break;
case ASYNC_LIP_ERROR:
-   case ASYNC_LIP_F8:
+   case ASYNC_LIP_NOS_OLS_RECV:
case ASYNC_LIP_OCCURRED:
case ASYNC_PTPMODE:
/*

Modified: stable/10/sys/dev/isp/isp_target.c
==
--- stable/10/sys/dev/isp/isp_target.c  Mon Nov 30 21:57:16 2015
(r291530)
+++ stable/10/sys/dev/isp/isp_target.c  Mon Nov 30 21:57:54 2015
(r291531)
@@ -639,7 +639,7 @@ isp_target_async(ispsoftc_t *isp, int bu
isp_async(isp, ISPASYNC_TARGET_NOTIFY, );
break;
case ASYNC_LIP_ERROR:
-   case ASYNC_LIP_F8:
+   case ASYNC_LIP_NOS_OLS_RECV:
case ASYNC_LIP_OCCURRED:
case ASYNC_LOOP_RESET:
isp_prt(isp, ISP_LOGTDEBUG0, "%s: LIP RESET", __func__);

Modified: stable/10/sys/dev/isp/ispmbox.h
==
--- stable/10/sys/dev/isp/ispmbox.h Mon Nov 30 21:57:16 2015
(r291530)
+++ stable/10/sys/dev/isp/ispmbox.h Mon Nov 30 21:57:54 2015
(r291531)
@@ -252,7 +252,7 @@
 #defineASYNC_LOOP_RESET0x8013  /* FC only */
 #defineASYNC_PDB_CHANGED   0x8014
 #defineASYNC_CHANGE_NOTIFY 0x8015
-#defineASYNC_LIP_F80x8016  /* FC only */
+#defineASYNC_LIP_NOS_OLS_RECV  0x8016  /* FC only */
 #defineASYNC_LIP_ERROR 0x8017  /* FC only */
 #defineASYNC_AUTO_PLOGI_RJT0x8018
 #defineASYNC_SECURITY_UPDATE   0x801B
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291500 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:30:18 2015
New Revision: 291500
URL: https://svnweb.freebsd.org/changeset/base/291500

Log:
  MFC r290147: Fix and improve error masking and reporting.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/ispmbox.h
  stable/10/sys/dev/isp/ispreg.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:29:38 2015(r291499)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:30:18 2015(r291500)
@@ -2562,7 +2562,8 @@ isp_getpdb(ispsoftc_t *isp, int chan, ui
isp_pdb_24xx_t bill;
} un;
 
-   MBSINIT(, MBOX_GET_PORT_DB, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR, 
25);
+   MBSINIT(, MBOX_GET_PORT_DB,
+   MBLOGALL & ~MBLOGMASK(MBOX_COMMAND_PARAM_ERROR), 25);
if (IS_24XX(isp)) {
mbs.ibits = (1 << 9)|(1 << 10);
mbs.param[1] = id;
@@ -2632,7 +2633,7 @@ isp_gethandles(ispsoftc_t *isp, int chan
uint32_t p;
uint16_t h;
 
-   MBSINIT(, MBOX_GET_ID_LIST, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR, 
25);
+   MBSINIT(, MBOX_GET_ID_LIST, MBLOGALL, 25);
if (IS_24XX(isp)) {
mbs.param[2] = DMA_WD1(fcp->isp_scdma);
mbs.param[3] = DMA_WD0(fcp->isp_scdma);
@@ -2726,7 +2727,8 @@ isp_get_wwn(ispsoftc_t *isp, int chan, i
fcp->isp_loopstate < LOOP_PDB_RCVD) {
return (wwn);
}
-   MBSINIT(, MBOX_GET_PORT_NAME, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR, 
50);
+   MBSINIT(, MBOX_GET_PORT_NAME,
+   MBLOGALL & ~MBLOGMASK(MBOX_COMMAND_PARAM_ERROR), 50);
if (ISP_CAP_2KLOGIN(isp)) {
mbs.param[1] = loopid;
if (nodename) {
@@ -4920,7 +4922,8 @@ isp_control(ispsoftc_t *isp, ispctl_t ct
} else {
mbs.param[1] = (chan << 15) | (tgt << 8) | XS_LUN(xs);
}
-   MBSINIT(, MBOX_ABORT, MBLOGALL & ~MBOX_COMMAND_ERROR, 0);
+   MBSINIT(, MBOX_ABORT,
+   MBLOGALL & ~MBLOGMASK(MBOX_COMMAND_ERROR), 0);
mbs.param[2] = handle;
isp_mboxcmd(isp, );
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
@@ -7431,7 +7434,7 @@ isp_mboxcmd_qnw(ispsoftc_t *isp, mbreg_t
 static void
 isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mbp)
 {
-   const char *cname, *xname;
+   const char *cname, *xname, *sname;
char tname[16], mname[16];
unsigned int ibits, obits, box, opcode;
 
@@ -7541,57 +7544,58 @@ isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mb
 
isp->isp_mboxbsy = 0;
MBOX_RELEASE(isp);
- out:
-   if (mbp->logval == 0 || opcode == MBOX_EXEC_FIRMWARE) {
+out:
+   if (mbp->logval == 0 || mbp->param[0] == MBOX_COMMAND_COMPLETE)
+   return;
+
+   if ((mbp->param[0] & 0xbfe0) == 0 &&
+   (mbp->logval & MBLOGMASK(mbp->param[0])) == 0)
return;
-   }
 
-   /*
-* Just to be chatty here...
-*/
xname = NULL;
+   sname = "";
switch (mbp->param[0]) {
-   case MBOX_COMMAND_COMPLETE:
-   break;
case MBOX_INVALID_COMMAND:
-   if (mbp->logval & MBLOGMASK(MBOX_COMMAND_COMPLETE)) {
-   xname = "INVALID COMMAND";
-   }
+   xname = "INVALID COMMAND";
break;
case MBOX_HOST_INTERFACE_ERROR:
-   if (mbp->logval & MBLOGMASK(MBOX_HOST_INTERFACE_ERROR)) {
-   xname = "HOST INTERFACE ERROR";
-   }
+   xname = "HOST INTERFACE ERROR";
break;
case MBOX_TEST_FAILED:
-   if (mbp->logval & MBLOGMASK(MBOX_TEST_FAILED)) {
-   xname = "TEST FAILED";
-   }
+   xname = "TEST FAILED";
break;
case MBOX_COMMAND_ERROR:
-   if (mbp->logval & MBLOGMASK(MBOX_COMMAND_ERROR)) {
-   xname = "COMMAND ERROR";
-   }
+   xname = "COMMAND ERROR";
+   ISP_SNPRINTF(mname, sizeof(mname), " subcode 0x%x",
+   mbp->param[1]);
+   sname = mname;
break;
case MBOX_COMMAND_PARAM_ERROR:
-   if (mbp->logval & MBLOGMASK(MBOX_COMMAND_PARAM_ERROR)) {
-   xname = "COMMAND PARAMETER ERROR";
-   }
-   break;
-   case MBOX_LOOP_ID_USED:
-   if (mbp->logval & MBLOGMASK(MBOX_LOOP_ID_USED)) {
-   xname = "LOOP ID ALREADY IN USE";
-   }
+   xname = "COMMAND PARAMETER ERROR";
break;
case MBOX_PORT_ID_USED:
-   if (mbp->logval & MBLOGMASK(MBOX_PORT_ID_USED)) {
-   xname = "PORT ID ALREADY IN USE";
- 

svn commit: r291501 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:30:56 2015
New Revision: 291501
URL: https://svnweb.freebsd.org/changeset/base/291501

Log:
  MFC r290159: Remove reset delays for which I see neither explanation nor need.

Modified:
  stable/10/sys/dev/isp/isp.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:30:18 2015(r291500)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:30:56 2015(r291501)
@@ -1011,33 +1011,15 @@ isp_reset(ispsoftc_t *isp, int do_load_d
}
}
 
-   /*
-* Give it a chance to finish starting up.
-* Give the 24XX more time.
-*/
-   if (IS_24XX(isp)) {
-   ISP_DELAY(50);
+   if (IS_SCSI(isp)) {
/*
-* Check to see if the 24XX firmware really started.
+* Set CLOCK RATE, but only if asked to.
 */
-   if (mbs.param[1] == 0xdead) {
-   isp_prt(isp, ISP_LOGERR, "f/w didn't *really* start");
-   ISP_RESET0(isp);
-   return;
-   }
-   } else {
-   ISP_DELAY(25);
-   if (IS_SCSI(isp)) {
-   /*
-* Set CLOCK RATE, but only if asked to.
-*/
-   if (isp->isp_clock) {
-   mbs.param[0] = MBOX_SET_CLOCK_RATE;
-   mbs.param[1] = isp->isp_clock;
-   mbs.logval = MBLOGNONE;
-   isp_mboxcmd(isp, );
-   /* we will try not to care if this fails */
-   }
+   if (isp->isp_clock) {
+   MBSINIT(, MBOX_SET_CLOCK_RATE, MBLOGALL, 0);
+   mbs.param[1] = isp->isp_clock;
+   isp_mboxcmd(isp, );
+   /* we will try not to care if this fails */
}
}
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291509 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:36:23 2015
New Revision: 291509
URL: https://svnweb.freebsd.org/changeset/base/291509

Log:
  MFC r290981: Off-by-one correctiont to r290980.

Modified:
  stable/10/sys/dev/isp/isp.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:35:43 2015(r291508)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:36:23 2015(r291509)
@@ -4268,7 +4268,7 @@ isp_next_handle(ispsoftc_t *isp, uint16_
handle = *ohp;
if (ISP_CAP_2KLOGIN(isp)) {
minh = 0;
-   maxh = NPH_RESERVED;
+   maxh = NPH_RESERVED - 1;
} else {
minh = SNS_ID + 1;
maxh = NPH_MAX - 1;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291515 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:41:06 2015
New Revision: 291515
URL: https://svnweb.freebsd.org/changeset/base/291515

Log:
  MFC r291092: Optimize SNS_GID_FT request scratch memory usage.
  
  Now with present 4K of scratch we can fetch up to 508 ports (16 more).

Modified:
  stable/10/sys/dev/isp/isp.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:40:20 2015(r291514)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:41:06 2015(r291515)
@@ -3193,16 +3193,16 @@ abort:
  */
 
 /*
- * Take less than half of our scratch area to store Port IDs
+ * Take half of our scratch area to store Port IDs
  */
-#defineGIDLEN  ((ISP_FC_SCRLEN >> 1) - 16 - SNS_GID_FT_REQ_SIZE)
+#defineGIDLEN  (ISP_FC_SCRLEN >> 1)
 #defineNGENT   ((GIDLEN - 16) >> 2)
 
-#defineIGPOFF  (2 * QENTRY_LEN)
+#defineIGPOFF  (0)
 #defineOGPOFF  (ISP_FC_SCRLEN >> 1)
-#defineZTXOFF  (ISP_FC_SCRLEN - (1 * QENTRY_LEN))
-#defineCTXOFF  (ISP_FC_SCRLEN - (2 * QENTRY_LEN))
-#defineXTXOFF  (ISP_FC_SCRLEN - (3 * QENTRY_LEN))
+#defineXTXOFF  (ISP_FC_SCRLEN - (3 * QENTRY_LEN))  /* CT request */
+#defineCTXOFF  (ISP_FC_SCRLEN - (2 * QENTRY_LEN))  /* Request IOCB 
*/
+#defineZTXOFF  (ISP_FC_SCRLEN - (1 * QENTRY_LEN))  /* Response 
IOCB */
 
 static int
 isp_gid_ft_sns(ispsoftc_t *isp, int chan)
@@ -3213,6 +3213,7 @@ isp_gid_ft_sns(ispsoftc_t *isp, int chan
} un;
fcparam *fcp = FCPARAM(isp, chan);
sns_gid_ft_req_t *rq = _x;
+   uint8_t *scp = fcp->isp_scratch;
mbreg_t mbs;
 
isp_prt(isp, ISP_LOGDEBUG0, "Chan %d scanning fabric (GID_FT) via SNS", 
chan);
@@ -3228,16 +3229,16 @@ isp_gid_ft_sns(ispsoftc_t *isp, int chan
rq->snscb_mword_div_2 = NGENT;
rq->snscb_fc4_type = FC4_SCSI;
 
-   isp_put_gid_ft_request(isp, rq, fcp->isp_scratch);
+   isp_put_gid_ft_request(isp, rq, (sns_gid_ft_req_t *)[CTXOFF]);
MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GID_FT_REQ_SIZE, chan);
 
MBSINIT(, MBOX_SEND_SNS, MBLOGALL, 1000);
mbs.param[0] = MBOX_SEND_SNS;
mbs.param[1] = SNS_GID_FT_REQ_SIZE >> 1;
-   mbs.param[2] = DMA_WD1(fcp->isp_scdma);
-   mbs.param[3] = DMA_WD0(fcp->isp_scdma);
-   mbs.param[6] = DMA_WD3(fcp->isp_scdma);
-   mbs.param[7] = DMA_WD2(fcp->isp_scdma);
+   mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
+   mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
+   mbs.param[6] = DMA_WD3(fcp->isp_scdma + CTXOFF);
+   mbs.param[7] = DMA_WD2(fcp->isp_scdma + CTXOFF);
isp_mboxcmd(isp, );
if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
if (mbs.param[0] == MBOX_INVALID_COMMAND) {
@@ -3337,9 +3338,9 @@ isp_gid_ft_ct_passthru(ispsoftc_t *isp, 
chan, pt->ctp_status);
return (-1);
}
-   MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN + 16, chan);
+   MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN, chan);
if (isp->isp_dblev & ISP_LOGDEBUG1) {
-   isp_print_bytes(isp, "CT response", GIDLEN+16, [IGPOFF]);
+   isp_print_bytes(isp, "CT response", GIDLEN, [IGPOFF]);
}
return (0);
 }
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291516 - stable/10/sys/dev/isp

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:41:56 2015
New Revision: 291516
URL: https://svnweb.freebsd.org/changeset/base/291516

Log:
  MFC r291099: Some cosmetics for ancient cards.

Modified:
  stable/10/sys/dev/isp/isp.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:41:06 2015(r291515)
+++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:41:56 2015(r291516)
@@ -2508,7 +2508,7 @@ isp_port_login(ispsoftc_t *isp, uint16_t
 
switch (mbs.param[0]) {
case MBOX_PORT_ID_USED:
-   isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: 
portid 0x%06x already logged in as %u", portid, mbs.param[1]);
+   isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: 
portid 0x%06x already logged in as 0x%x", portid, mbs.param[1]);
return (MBOX_PORT_ID_USED | (mbs.param[1] << 16));
 
case MBOX_LOOP_ID_USED:
@@ -5697,8 +5697,12 @@ isp_parse_async_fc(ispsoftc_t *isp, uint
{
int echan, nphdl, nlstate, reason;
 
-   nphdl = ISP_READ(isp, OUTMAILBOX1);
-   nlstate = ISP_READ(isp, OUTMAILBOX2);
+   if (IS_23XX(isp) || IS_24XX(isp)) {
+   nphdl = ISP_READ(isp, OUTMAILBOX1);
+   nlstate = ISP_READ(isp, OUTMAILBOX2);
+   } else {
+   nphdl = nlstate = 0x;
+   }
if (IS_24XX(isp))
reason = ISP_READ(isp, OUTMAILBOX3) >> 8;
else
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291526 - stable/10/share/man/man4

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 21:53:38 2015
New Revision: 291526
URL: https://svnweb.freebsd.org/changeset/base/291526

Log:
  MFC r290138, r290139: Some updates to isp(4) manual page.

Modified:
  stable/10/share/man/man4/isp.4
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man4/isp.4
==
--- stable/10/share/man/man4/isp.4  Mon Nov 30 21:53:24 2015
(r291525)
+++ stable/10/share/man/man4/isp.4  Mon Nov 30 21:53:38 2015
(r291526)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 1, 2014
+.Dd October 29, 2015
 .Dt ISP 4
 .Os
 .Sh NAME
@@ -60,8 +60,7 @@ devices.
 SCSI features include support for Ultra SCSI and wide mode transactions
 for
 .Tn SCSI ,
-Ultra2 LVD (for the ISP1080 and ISP1280), and Ultra3 LVD (for the
-ISP12160).
+Ultra2 LVD (ISP1080, ISP1280), and Ultra3 LVD (ISP12160).
 .Pp
 Fibre Channel support uses FCP SCSI profile for
 .Tn FibreChannel ,
@@ -69,15 +68,13 @@ and utilizes Class 3 and Class 2 connect
 3 only, minor patches to the Qlogic 2200 to force Class 2 mode).
 Support is available for Public and Private loops, and for
 point-to-point connections (Qlogic 2200 only).
-The newer 2-Gigabit cards (2300, 2312, 2322) and 4-Gigabit (2422, 2432)
-are also supported.
-Command tagging is
-supported for all (in fact,
+The newer 2-Gigabit cards (2300, 2312, 2322), 4-Gigabit (2422, 2432)
+and 8-Gigabit (2532) are also supported.
+Command tagging is supported for all (in fact,
 .Tn FibreChannel
 requires tagging).
 Fabric support is enabled by default for other than 2100 cards.
-Fabric
-support for 2100 cards has been so problematic and these cards are so
+Fabric support for 2100 cards has been so problematic and these cards are so
 old now that it is just not worth your time to try it.
 .Sh FIRMWARE
 Firmware is available if the
@@ -103,15 +100,16 @@ Qlogic 1020 Fast Wide and Differential F
 .It ISP1040
 Qlogic 1040 Ultra Wide and Differential Ultra Wide PCI cards.
 Also known as the DEC KZPBA-CA (single ended) and KZPBA-CB (HVD differential).
-.It Qlogic 1240
-Qlogic 1240 Dual Bus Ultra Wide and Differential Ultra Wide PCI
-cards.
 .It Qlogic 1020
 Qlogic 1020 SCSI cards.
 .It Qlogic 1040
 Qlogic 1040 Ultra SCSI cards.
 .It Qlogic 1080
-Qlogic 1280 LVD Ultra2 Wide PCI cards.
+Qlogic 1080 LVD Ultra2 Wide SCSI cards.
+.It Qlogic 10160
+Qlogic 10160 LVD Ultra3 Wide PCI cards.
+.It Qlogic 1240
+Qlogic 1240 Dual Bus Ultra Wide and Differential Ultra Wide PCI cards.
 .It Qlogic 1280
 Qlogic 1280 Dual Bus LVD Ultra2 Wide PCI cards.
 .It Qlogic 12160
@@ -123,21 +121,21 @@ Loop (single, dual).
 Qlogic 2200 Copper and Optical Fibre Channel Arbitrated Loop PCI
 cards (single, dual, quad).
 .It Qlogic 2300
-Qlogic 2300 Optical Fibre Channel PCI cards.
+Qlogic 2300 Optical 2Gb Fibre Channel PCI cards.
 .It Qlogic 2312
-Qlogic 2312 Optical Fibre Channel PCI cards.
+Qlogic 2312 Optical 2Gb Fibre Channel PCI cards.
 .It Qlogic 234X
-Qlogic 234X Optical Fibre Channel PCI cards (2312 chipset, single and dual 
attach).
+Qlogic 234X Optical 2Gb Fibre Channel PCI cards (2312 chipset, single and dual 
attach).
 .It Qlogic 2322
-Qlogic 2322 Optical Fibre Channel PCIe cards.
+Qlogic 2322 Optical 2Gb Fibre Channel PCIe cards.
 .It Qlogic 200
-Dell Branded version of the QLogic 2312 Fibre Channel PCI cards.
+Dell branded version of the QLogic 2312.
 .It Qlogic 2422
-Qlogic 2422 Optical Fibre Channel PCI cards (4 Gigabit)
-.It Qlogic 2432
-Qlogic 2432 Optical Fibre Channel PCIe cards (4 Gigabit)
+Qlogic 2422 Optical 4Gb Fibre Channel PCI cards.
 .It Qlogic 2432
-Qlogic 2532 Optical Fibre Channel PCIe cards (8 Gigabit)
+Qlogic 2432 Optical 4Gb Fibre Channel PCIe cards.
+.It Qlogic 2532
+Qlogic 2532 Optical 8Gb Fibre Channel PCIe cards.
 .El
 .Sh CONFIGURATION OPTIONS
 Target mode support may be enabled with the
@@ -230,13 +228,13 @@ This is the readonly World Wide Port Nam
 .Sh AUTHORS
 The
 .Nm
-driver was written by Matthew Jacob originally for NetBSD at
-NASA/Ames Research Center.
+driver was written by
+.An Matthew Jacob
+originally for NetBSD at NASA/Ames Research Center.
+Some later improvement was done by
+.An Alexander Motin Aq Mt m...@freebsd.org .
 .Sh BUGS
 The driver currently ignores some NVRAM settings.
 .Pp
-Target mode support is not completely reliable yet.
-It works reasonably
-well for Fibre Channel, somewhat well for Qlogic 1040 cards, but
-does not yet work for the other cards (due to last minute unannounced
-changes in firmware interfaces).
+Target mode support works reasonably well for 23xx and above Fibre Channel
+cards, but not really tested on older ones.
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r292590 - stable/10/sys/cam/ctl

2015-12-22 Thread Alexander Motin
Author: mav
Date: Tue Dec 22 09:02:51 2015
New Revision: 292590
URL: https://svnweb.freebsd.org/changeset/base/292590

Log:
  MFC r292290: Set DS flag, required for LPB log page by spec.

Modified:
  stable/10/sys/cam/ctl/ctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Tue Dec 22 08:08:41 2015(r292589)
+++ stable/10/sys/cam/ctl/ctl.c Tue Dec 22 09:02:51 2015(r292590)
@@ -6870,6 +6870,8 @@ ctl_log_sense(struct ctl_scsiio *ctsio)
 
header = (struct scsi_log_header *)ctsio->kern_data_ptr;
header->page = page_index->page_code;
+   if (page_index->page_code == SLS_LOGICAL_BLOCK_PROVISIONING)
+   header->page |= SL_DS;
if (page_index->subpage) {
header->page |= SL_SPF;
header->subpage = page_index->subpage;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r292598 - in stable/10: share/man/man4 sys/dev/isp

2015-12-22 Thread Alexander Motin
Author: mav
Date: Tue Dec 22 13:19:29 2015
New Revision: 292598
URL: https://svnweb.freebsd.org/changeset/base/292598

Log:
  MFC r291654, r291727, r291821, r291872, r292034, r292041, r292249, r292042:
  Add initial support for 16Gbps FC QLogic chips.

Modified:
  stable/10/share/man/man4/isp.4
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_freebsd.h
  stable/10/sys/dev/isp/isp_pci.c
  stable/10/sys/dev/isp/isp_sbus.c
  stable/10/sys/dev/isp/ispmbox.h
  stable/10/sys/dev/isp/ispvar.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man4/isp.4
==
--- stable/10/share/man/man4/isp.4  Tue Dec 22 12:54:13 2015
(r292597)
+++ stable/10/share/man/man4/isp.4  Tue Dec 22 13:19:29 2015
(r292598)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 22, 2015
+.Dd December 9, 2015
 .Dt ISP 4
 .Os
 .Sh NAME
@@ -107,10 +107,12 @@ Optical 2Gb Fibre Channel PCIe cards.
 Dell branded version of the QLogic 2312.
 .It Qlogic 2422
 Optical 4Gb Fibre Channel PCI cards.
-.It Qlogic 2432
+.It Qlogic 246x (aka 2432)
 Optical 4Gb Fibre Channel PCIe cards.
-.It Qlogic 2532
+.It Qlogic 256x (aka 2532)
 Optical 8Gb Fibre Channel PCIe cards.
+.It Qlogic 267x/836x (aka 2031/8031)
+Optical 16Gb FC/FCoE PCIe cards.
 .El
 .Sh CONFIGURATION OPTIONS
 Target mode support for Fibre Channel adapters may be enabled with the
@@ -127,12 +129,6 @@ They are:
 .It Va hint.isp.0.fwload_disable
 A hint value to disable loading of firmware
 .Xr ispfw 4 .
-.It Va hint.isp.0.prefer_memmap
-A hint value to use PCI memory space instead of I/O space
-access for.
-.It Va hint.isp.0.prefer_iomap
-A hint value to use PCI I/O space instead of Memory space
-access for.
 .It Va hint.isp.0.ignore_nvram
 A hint value to ignore board NVRAM settings for.
 Otherwise use NVRAM settings.

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Tue Dec 22 12:54:13 2015(r292597)
+++ stable/10/sys/dev/isp/isp.c Tue Dec 22 13:19:29 2015(r292598)
@@ -277,6 +277,9 @@ isp_reset(ispsoftc_t *isp, int do_load_d
case ISP_HA_FC_2500:
btype = "2532";
break;
+   case ISP_HA_FC_2600:
+   btype = "2031";
+   break;
default:
break;
}
@@ -655,8 +658,10 @@ isp_reset(ispsoftc_t *isp, int do_load_d
ISP_WRITE(isp, isp->isp_respinrp, 0);
ISP_WRITE(isp, isp->isp_respoutrp, 0);
if (IS_24XX(isp)) {
-   ISP_WRITE(isp, BIU2400_PRI_REQINP, 0);
-   ISP_WRITE(isp, BIU2400_PRI_REQOUTP, 0);
+   if (!IS_26XX(isp)) {
+   ISP_WRITE(isp, BIU2400_PRI_REQINP, 0);
+   ISP_WRITE(isp, BIU2400_PRI_REQOUTP, 0);
+   }
ISP_WRITE(isp, BIU2400_ATIO_RSPINP, 0);
ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, 0);
}
@@ -761,6 +766,7 @@ isp_reset(ispsoftc_t *isp, int do_load_d
code_org = ISP_CODE_ORG;
}
 
+   isp->isp_loaded_fw = 0;
if (dodnld && IS_24XX(isp)) {
const uint32_t *ptr = isp->isp_mdvec->dv_ispfw;
int wordload;
@@ -956,8 +962,17 @@ isp_reset(ispsoftc_t *isp, int do_load_d
ISP_RESET0(isp);
return;
}
+   } else if (IS_26XX(isp)) {
+   MBSINIT(, MBOX_LOAD_FLASH_FIRMWARE, MBLOGALL, 500);
+   mbs.ibitm = 0x01;
+   mbs.obitm = 0x07;
+   isp_mboxcmd(isp, );
+   if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
+   isp_prt(isp, ISP_LOGERR, "Flash F/W load failed");
+   ISP_RESET0(isp);
+   return;
+   }
} else {
-   isp->isp_loaded_fw = 0;
isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
}
 
@@ -966,7 +981,6 @@ isp_reset(ispsoftc_t *isp, int do_load_d
 */
if (isp->isp_loaded_fw) {
MBSINIT(, MBOX_VERIFY_CHECKSUM, MBLOGNONE, 0);
-   mbs.param[0] = MBOX_VERIFY_CHECKSUM;
if (IS_24XX(isp)) {
mbs.param[1] = code_org >> 16;
mbs.param[2] = code_org;
@@ -998,9 +1012,6 @@ isp_reset(ispsoftc_t *isp, int do_load_d
} else {
mbs.param[3] = 1;
}
-   if (IS_25XX(isp)) {
-   mbs.ibits |= 0x10;
-   }
} else if (IS_2322(isp)) {
mbs.param[1] = code_org;
if (isp->isp_loaded_fw) {
@@ -1861,16 +1872,16 @@ isp_fibre_init(ispsoftc_t *isp)
icbp->icb_idelaytimer = 10;
}
  

svn commit: r292596 - stable/10/sys/dev/isp

2015-12-22 Thread Alexander Motin
Author: mav
Date: Tue Dec 22 12:53:01 2015
New Revision: 292596
URL: https://svnweb.freebsd.org/changeset/base/292596

Log:
  MFC r291730: Update isp_put_icb_2400() for new structure fields.

Modified:
  stable/10/sys/dev/isp/isp_library.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp_library.c
==
--- stable/10/sys/dev/isp/isp_library.c Tue Dec 22 12:01:06 2015
(r292595)
+++ stable/10/sys/dev/isp/isp_library.c Tue Dec 22 12:53:01 2015
(r292596)
@@ -1402,7 +1402,9 @@ isp_put_icb_2400(ispsoftc_t *isp, isp_ic
for (i = 0; i < 4; i++) {
ISP_IOXPUT_16(isp, src->icb_priaddr[i], >icb_priaddr[i]);
}
-   for (i = 0; i < 4; i++) {
+   ISP_IOXPUT_16(isp, src->icb_msixresp, >icb_msixresp);
+   ISP_IOXPUT_16(isp, src->icb_msixatio, >icb_msixatio);
+   for (i = 0; i < 2; i++) {
ISP_IOXPUT_16(isp, src->icb_reserved1[i], 
>icb_reserved1[i]);
}
ISP_IOXPUT_16(isp, src->icb_atio_in, >icb_atio_in);
@@ -1415,9 +1417,14 @@ isp_put_icb_2400(ispsoftc_t *isp, isp_ic
ISP_IOXPUT_32(isp, src->icb_fwoptions1, >icb_fwoptions1);
ISP_IOXPUT_32(isp, src->icb_fwoptions2, >icb_fwoptions2);
ISP_IOXPUT_32(isp, src->icb_fwoptions3, >icb_fwoptions3);
-   for (i = 0; i < 12; i++) {
+   ISP_IOXPUT_16(isp, src->icb_qos, >icb_qos);
+   for (i = 0; i < 3; i++)
ISP_IOXPUT_16(isp, src->icb_reserved2[i], 
>icb_reserved2[i]);
-   }
+   for (i = 0; i < 3; i++)
+   ISP_IOXPUT_16(isp, src->icb_enodemac[i], >icb_enodemac[i]);
+   ISP_IOXPUT_16(isp, src->icb_disctime, >icb_disctime);
+   for (i = 0; i < 4; i++)
+   ISP_IOXPUT_16(isp, src->icb_reserved3[i], 
>icb_reserved3[i]);
 }
 
 void
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r292918 - stable/10/sys/dev/isp

2015-12-30 Thread Alexander Motin
Author: mav
Date: Wed Dec 30 11:48:17 2015
New Revision: 292918
URL: https://svnweb.freebsd.org/changeset/base/292918

Log:
  MFC r292690: Some polishing for command timeouts handling.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_freebsd.c
  stable/10/sys/dev/isp/ispmbox.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Wed Dec 30 11:48:06 2015(r292917)
+++ stable/10/sys/dev/isp/isp.c Wed Dec 30 11:48:17 2015(r292918)
@@ -2446,7 +2446,8 @@ isp_plogx(ispsoftc_t *isp, int chan, uin
scp = fcp->isp_scratch;
isp_put_plogx(isp, plp, (isp_plogx_t *) scp);
 
-   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 50);
+   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
+   MBCMD_DEFAULT_TIMEOUT + ICB_LOGIN_TOV * 100);
mbs.param[1] = QENTRY_LEN;
mbs.param[2] = DMA_WD1(fcp->isp_scdma);
mbs.param[3] = DMA_WD0(fcp->isp_scdma);
@@ -3390,7 +3391,7 @@ isp_gid_ft_ct_passthru(ispsoftc_t *isp, 
pt->ctp_nphdl = fcp->isp_sns_hdl;
pt->ctp_cmd_cnt = 1;
pt->ctp_vpidx = ISP_GET_VPIDX(isp, chan);
-   pt->ctp_time = 30;
+   pt->ctp_time = 10;
pt->ctp_rsp_cnt = 1;
pt->ctp_rsp_bcnt = GIDLEN;
pt->ctp_cmd_bcnt = sizeof (*ct) + sizeof (uint32_t);
@@ -3426,7 +3427,8 @@ isp_gid_ft_ct_passthru(ispsoftc_t *isp, 
sizeof (*ct) + sizeof (uint32_t), [XTXOFF]);
}
ISP_MEMZERO([ZTXOFF], QENTRY_LEN);
-   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 50);
+   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
+   MBCMD_DEFAULT_TIMEOUT + pt->ctp_time * 100);
mbs.param[1] = QENTRY_LEN;
mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
@@ -3861,7 +3863,7 @@ isp_register_fc4_type_24xx(ispsoftc_t *i
pt->ctp_nphdl = fcp->isp_sns_hdl;
pt->ctp_cmd_cnt = 1;
pt->ctp_vpidx = ISP_GET_VPIDX(isp, chan);
-   pt->ctp_time = 1;
+   pt->ctp_time = 4;
pt->ctp_rsp_cnt = 1;
pt->ctp_rsp_bcnt = sizeof (ct_hdr_t);
pt->ctp_cmd_bcnt = sizeof (rft_id_t);
@@ -3900,7 +3902,8 @@ isp_register_fc4_type_24xx(ispsoftc_t *i
 
ISP_MEMZERO([ZTXOFF], sizeof (ct_hdr_t));
 
-   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 100);
+   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
+   MBCMD_DEFAULT_TIMEOUT + pt->ctp_time * 100);
mbs.param[1] = QENTRY_LEN;
mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
@@ -3972,7 +3975,7 @@ isp_register_fc4_features_24xx(ispsoftc_
pt->ctp_nphdl = fcp->isp_sns_hdl;
pt->ctp_cmd_cnt = 1;
pt->ctp_vpidx = ISP_GET_VPIDX(isp, chan);
-   pt->ctp_time = 1;
+   pt->ctp_time = 4;
pt->ctp_rsp_cnt = 1;
pt->ctp_rsp_bcnt = sizeof (ct_hdr_t);
pt->ctp_cmd_bcnt = sizeof (rff_id_t);
@@ -4016,7 +4019,8 @@ isp_register_fc4_features_24xx(ispsoftc_
 
ISP_MEMZERO([ZTXOFF], sizeof (ct_hdr_t));
 
-   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 100);
+   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
+   MBCMD_DEFAULT_TIMEOUT + pt->ctp_time * 100);
mbs.param[1] = QENTRY_LEN;
mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
@@ -4403,10 +4407,7 @@ isp_start(XS_T *xs)
}
ISP_MEMCPY(cdbp, XS_CDBP(xs), cdblen);
 
-   *tptr = XS_TIME(xs) / 1000;
-   if (*tptr == 0 && XS_TIME(xs)) {
-   *tptr = 1;
-   }
+   *tptr = (XS_TIME(xs) + 999) / 1000;
if (IS_24XX(isp) && *tptr > 0x1999) {
*tptr = 0x1999;
}
@@ -4512,13 +4513,14 @@ isp_control(ispsoftc_t *isp, ispctl_t ct
tmf->tmf_header.rqs_entry_count = 1;
tmf->tmf_nphdl = lp->handle;
tmf->tmf_delay = 2;
-   tmf->tmf_timeout = 2;
+   tmf->tmf_timeout = 4;
tmf->tmf_flags = ISP24XX_TMF_TARGET_RESET;
tmf->tmf_tidlo = lp->portid;
tmf->tmf_tidhi = lp->portid >> 16;
tmf->tmf_vpidx = ISP_GET_VPIDX(isp, chan);
isp_prt(isp, ISP_LOGALL, "Chan %d Reset N-Port Handle 
0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid);
-   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 
500);
+   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
+   MBCMD_DEFAULT_TIMEOUT + tmf->tmf_timeout * 100);
mbs.param[1] = QENTRY_LEN;
mbs.param[2] = DMA_WD1(fcp->isp_scdma);
mbs.param[3] 

svn commit: r292916 - stable/10/sys/dev/isp

2015-12-30 Thread Alexander Motin
Author: mav
Date: Wed Dec 30 11:47:33 2015
New Revision: 292916
URL: https://svnweb.freebsd.org/changeset/base/292916

Log:
  MFC r292610: Fix speed setting by NVRAM for 24xx and above chips.

Modified:
  stable/10/sys/dev/isp/isp.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Wed Dec 30 11:46:15 2015(r292915)
+++ stable/10/sys/dev/isp/isp.c Wed Dec 30 11:47:33 2015(r292916)
@@ -2142,19 +2142,41 @@ isp_fibre_init_2400(ispsoftc_t *isp)
if ((icbp->icb_fwoptions3 & ICB2400_OPT3_RSPSZ_MASK) == 0) {
icbp->icb_fwoptions3 |= ICB2400_OPT3_RSPSZ_24;
}
-   icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_AUTO;
if (isp->isp_confopts & ISP_CFG_1GB) {
+   icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_1GB;
} else if (isp->isp_confopts & ISP_CFG_2GB) {
+   icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_2GB;
} else if (isp->isp_confopts & ISP_CFG_4GB) {
+   icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_4GB;
} else if (isp->isp_confopts & ISP_CFG_8GB) {
+   icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_8GB;
} else if (isp->isp_confopts & ISP_CFG_16GB) {
+   icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_16GB;
} else {
-   icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_AUTO;
+   switch (icbp->icb_fwoptions3 & ICB2400_OPT3_RATE_MASK) {
+   case ICB2400_OPT3_RATE_4GB:
+   case ICB2400_OPT3_RATE_8GB:
+   case ICB2400_OPT3_RATE_16GB:
+   case ICB2400_OPT3_RATE_AUTO:
+   break;
+   case ICB2400_OPT3_RATE_2GB:
+   if (isp->isp_type <= ISP_HA_FC_2500)
+   break;
+   /*FALLTHROUGH*/
+   case ICB2400_OPT3_RATE_1GB:
+   if (isp->isp_type <= ISP_HA_FC_2400)
+   break;
+   /*FALLTHROUGH*/
+   default:
+   icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_MASK;
+   icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_AUTO;
+   break;
+   }
}
icbp->icb_logintime = ICB_LOGIN_TOV;
 
@@ -7632,6 +7654,7 @@ isp_setdfltfcparm(ispsoftc_t *isp, int c
fcp->isp_fwoptions |= ICB2400_OPT1_FULL_DUPLEX;
}
fcp->isp_fwoptions |= ICB2400_OPT1_BOTH_WWNS;
+   fcp->isp_zfwoptions |= ICB2400_OPT3_RATE_AUTO;
} else {
fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
@@ -7644,6 +7667,7 @@ isp_setdfltfcparm(ispsoftc_t *isp, int c
 * extended options from NVRAM
 */
fcp->isp_fwoptions &= ~ICBOPT_EXTENDED;
+   fcp->isp_zfwoptions |= ICBZOPT_RATE_AUTO;
}
 
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r292921 - stable/10/sys/dev/isp

2015-12-30 Thread Alexander Motin
Author: mav
Date: Wed Dec 30 11:49:48 2015
New Revision: 292921
URL: https://svnweb.freebsd.org/changeset/base/292921

Log:
  MFC r292725: Unify handles allocation for initiator and target IOCBs.
  
  I am not sure why this was split long ago, but I see no reason for it.
  At this point this unification just slightly reduces memory usage, but
  as next step I plan to reuse shared handle space for other IOCB types.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_freebsd.c
  stable/10/sys/dev/isp/isp_library.c
  stable/10/sys/dev/isp/isp_library.h
  stable/10/sys/dev/isp/isp_pci.c
  stable/10/sys/dev/isp/isp_target.c
  stable/10/sys/dev/isp/ispvar.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Wed Dec 30 11:49:41 2015(r292920)
+++ stable/10/sys/dev/isp/isp.c Wed Dec 30 11:49:48 2015(r292921)
@@ -4269,7 +4269,7 @@ int
 isp_start(XS_T *xs)
 {
ispsoftc_t *isp;
-   uint32_t handle, cdblen;
+   uint32_t cdblen;
uint8_t local[QENTRY_LEN];
ispreq_t *reqp;
void *cdbp, *qep;
@@ -4565,13 +4565,13 @@ isp_start(XS_T *xs)
*tptr = 0x1999;
}
 
-   if (isp_allocate_xs(isp, xs, )) {
+   /* Whew. Thankfully the same for type 7 requests */
+   reqp->req_handle = isp_allocate_handle(isp, xs, ISP_HANDLE_INITIATOR);
+   if (reqp->req_handle == 0) {
isp_prt(isp, ISP_LOG_WARN1, "out of xflist pointers");
XS_SETERR(xs, HBA_BOTCH);
return (CMD_EAGAIN);
}
-   /* Whew. Thankfully the same for type 7 requests */
-   reqp->req_handle = handle;
 
/*
 * Set up DMA and/or do any platform dependent swizzling of the request 
entry
@@ -4581,7 +4581,7 @@ isp_start(XS_T *xs)
 */
dmaresult = ISP_DMASETUP(isp, xs, reqp);
if (dmaresult != CMD_QUEUED) {
-   isp_destroy_handle(isp, handle);
+   isp_destroy_handle(isp, reqp->req_handle);
/*
 * dmasetup sets actual error in packet, and
 * return what we were given to return.
@@ -5310,12 +5310,6 @@ again:
}
}
 
-   if (!ISP_VALID_HANDLE(isp, sp->req_handle)) {
-   isp_prt(isp, ISP_LOGERR, "bad request handle 0x%x (iocb 
type 0x%x)", sp->req_handle, etype);
-   ISP_MEMZERO(hp, QENTRY_LEN);/* PERF */
-   last_etype = etype;
-   continue;
-   }
xs = isp_find_xs(isp, sp->req_handle);
if (xs == NULL) {
uint8_t ts = completion_status & 0xff;

Modified: stable/10/sys/dev/isp/isp_freebsd.c
==
--- stable/10/sys/dev/isp/isp_freebsd.c Wed Dec 30 11:49:41 2015
(r292920)
+++ stable/10/sys/dev/isp/isp_freebsd.c Wed Dec 30 11:49:48 2015
(r292921)
@@ -1694,7 +1694,8 @@ isp_target_start_ctio(ispsoftc_t *isp, u
TAILQ_INSERT_HEAD(>waitq, >ccb_h, 
periph_links.tqe); 
break;
}
-   if (isp_allocate_xs_tgt(isp, ccb, )) {
+   handle = isp_allocate_handle(isp, ccb, ISP_HANDLE_TARGET);
+   if (handle == 0) {
ISP_PATH_PRT(isp, ISP_LOGWARN, ccb->ccb_h.path, "No 
XFLIST pointers for %s\n", __func__);
TAILQ_INSERT_HEAD(>waitq, >ccb_h, 
periph_links.tqe); 
isp_free_pcmd(isp, ccb);
@@ -1723,7 +1724,7 @@ isp_target_start_ctio(ispsoftc_t *isp, u
 
dmaresult = ISP_DMASETUP(isp, cso, (ispreq_t *) local);
if (dmaresult != CMD_QUEUED) {
-   isp_destroy_tgt_handle(isp, handle);
+   isp_destroy_handle(isp, handle);
isp_free_pcmd(isp, ccb);
if (dmaresult == CMD_EAGAIN) {
TAILQ_INSERT_HEAD(>waitq, >ccb_h, 
periph_links.tqe); 
@@ -2380,12 +2381,12 @@ isp_handle_platform_ctio(ispsoftc_t *isp
uint32_t handle, moved_data = 0, data_requested;
 
handle = ((ct2_entry_t *)arg)->ct_syshandle;
-   ccb = isp_find_xs_tgt(isp, handle);
+   ccb = isp_find_xs(isp, handle);
if (ccb == NULL) {
isp_print_bytes(isp, "null ccb in isp_handle_platform_ctio", 
QENTRY_LEN, arg);
return;
}
-   isp_destroy_tgt_handle(isp, handle);
+   isp_destroy_handle(isp, handle);
data_requested = PISP_PCMD(ccb)->datalen;
isp_free_pcmd(isp, ccb);
if (isp->isp_nactive) {
@@ -3321,7 +3322,7 @@ isp_loop_dead(ispsoftc_t *isp, int chan)
for (i = 0; i < isp->isp_maxcmds; i++) {
struct ccb_scsiio 

svn commit: r292924 - stable/10/sys/dev/isp

2015-12-30 Thread Alexander Motin
Author: mav
Date: Wed Dec 30 11:51:35 2015
New Revision: 292924
URL: https://svnweb.freebsd.org/changeset/base/292924

Log:
  MFC r292741: Make port logins asynchronous, following r292739 logic.
  
  This is even more important since it involves more network operations and
  more prone to delays and timeouts.

Modified:
  stable/10/sys/dev/isp/isp.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Wed Dec 30 11:51:13 2015(r292923)
+++ stable/10/sys/dev/isp/isp.c Wed Dec 30 11:51:35 2015(r292924)
@@ -108,7 +108,7 @@ static void isp_fibre_init(ispsoftc_t *)
 static void isp_fibre_init_2400(ispsoftc_t *);
 static void isp_clear_portdb(ispsoftc_t *, int);
 static void isp_mark_portdb(ispsoftc_t *, int);
-static int isp_plogx(ispsoftc_t *, int, uint16_t, uint32_t, int, int);
+static int isp_plogx(ispsoftc_t *, int, uint16_t, uint32_t, int);
 static int isp_port_login(ispsoftc_t *, uint16_t, uint32_t);
 static int isp_port_logout(ispsoftc_t *, uint16_t, uint32_t);
 static int isp_getpdb(ispsoftc_t *, int, uint16_t, isp_pdb_t *, int);
@@ -2550,13 +2550,11 @@ isp_mark_portdb(ispsoftc_t *isp, int cha
  * or via FABRIC LOGIN/FABRIC LOGOUT for other cards.
  */
 static int
-isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, uint32_t portid, int 
flags, int gs)
+isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, uint32_t portid, int 
flags)
 {
-   mbreg_t mbs;
-   uint8_t q[QENTRY_LEN];
-   isp_plogx_t *plp;
-   fcparam *fcp;
-   uint8_t *scp;
+   isp_plogx_t pl;
+   void *reqp;
+   uint8_t resp[QENTRY_LEN];
uint32_t sst, parm1;
int rval, lev;
const char *msg;
@@ -2576,64 +2574,58 @@ isp_plogx(ispsoftc_t *isp, int chan, uin
}
}
 
-   ISP_MEMZERO(q, QENTRY_LEN);
-   plp = (isp_plogx_t *) q;
-   plp->plogx_header.rqs_entry_count = 1;
-   plp->plogx_header.rqs_entry_type = RQSTYPE_LOGIN;
-   plp->plogx_handle = 0x;
-   plp->plogx_nphdl = handle;
-   plp->plogx_vphdl = chan;
-   plp->plogx_portlo = portid;
-   plp->plogx_rspsz_porthi = (portid >> 16) & 0xff;
-   plp->plogx_flags = flags;
+   ISP_MEMZERO(, sizeof(pl));
+   pl.plogx_header.rqs_entry_count = 1;
+   pl.plogx_header.rqs_entry_type = RQSTYPE_LOGIN;
+   pl.plogx_nphdl = handle;
+   pl.plogx_vphdl = chan;
+   pl.plogx_portlo = portid;
+   pl.plogx_rspsz_porthi = (portid >> 16) & 0xff;
+   pl.plogx_flags = flags;
 
-   if (isp->isp_dblev & ISP_LOGDEBUG1) {
-   isp_print_bytes(isp, "IOCB LOGX", QENTRY_LEN, plp);
-   }
-
-   if (gs == 0) {
-   if (FC_SCRATCH_ACQUIRE(isp, chan)) {
-   isp_prt(isp, ISP_LOGERR, sacq);
-   return (-1);
-   }
+   /* Prepare space for response in memory */
+   memset(resp, 0xff, sizeof(resp));
+   pl.plogx_handle = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
+   if (pl.plogx_handle == 0) {
+   isp_prt(isp, ISP_LOGERR,
+   "%s: PLOGX of Chan %d out of handles", __func__, chan);
+   return (-1);
}
-   fcp = FCPARAM(isp, chan);
-   scp = fcp->isp_scratch;
-   isp_put_plogx(isp, plp, (isp_plogx_t *) scp);
 
-   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
-   MBCMD_DEFAULT_TIMEOUT + ICB_LOGIN_TOV * 100);
-   mbs.param[1] = QENTRY_LEN;
-   mbs.param[2] = DMA_WD1(fcp->isp_scdma);
-   mbs.param[3] = DMA_WD0(fcp->isp_scdma);
-   mbs.param[6] = DMA_WD3(fcp->isp_scdma);
-   mbs.param[7] = DMA_WD2(fcp->isp_scdma);
-   MEMORYBARRIER(isp, SYNC_SFORDEV, 0, QENTRY_LEN, chan);
-   isp_mboxcmd(isp, );
-   if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-   rval = mbs.param[0];
-   goto out;
+   /* Send request and wait for response. */
+   reqp = isp_getrqentry(isp);
+   if (reqp == NULL) {
+   isp_prt(isp, ISP_LOGERR,
+   "%s: PLOGX of Chan %d out of rqent", __func__, chan);
+   isp_destroy_handle(isp, pl.plogx_handle);
+   return (-1);
}
-   MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
-   scp += QENTRY_LEN;
-   isp_get_plogx(isp, (isp_plogx_t *) scp, plp);
-   if (isp->isp_dblev & ISP_LOGDEBUG1) {
-   isp_print_bytes(isp, "IOCB LOGX response", QENTRY_LEN, plp);
+   if (isp->isp_dblev & ISP_LOGDEBUG1)
+   isp_print_bytes(isp, "IOCB LOGX", QENTRY_LEN, );
+   isp_put_plogx(isp, , (isp_plogx_t *)reqp);
+   ISP_SYNC_REQUEST(isp);
+   if (msleep(resp, >isp_lock, 0, "PLOGX", 3 * ICB_LOGIN_TOV * hz)
+   == EWOULDBLOCK) {
+   isp_prt(isp, ISP_LOGERR,
+   "%s: PLOGX of Chan %d timed out", __func__, chan);
+  

svn commit: r292927 - stable/10/sys/dev/isp

2015-12-30 Thread Alexander Motin
Author: mav
Date: Wed Dec 30 11:53:21 2015
New Revision: 292927
URL: https://svnweb.freebsd.org/changeset/base/292927

Log:
  MFC r292745: Use single DMA tag for scratch areas of all virtual ports.

Modified:
  stable/10/sys/dev/isp/isp_freebsd.h
  stable/10/sys/dev/isp/isp_pci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp_freebsd.h
==
--- stable/10/sys/dev/isp/isp_freebsd.h Wed Dec 30 11:53:15 2015
(r292926)
+++ stable/10/sys/dev/isp/isp_freebsd.h Wed Dec 30 11:53:21 2015
(r292927)
@@ -225,8 +225,7 @@ struct isp_fc {
struct cam_path *path;
struct ispsoftc *isp;
struct proc *kproc;
-   bus_dma_tag_t tdmat;
-   bus_dmamap_t tdmap;
+   bus_dmamap_t scmap;
uint64_t def_wwpn;
uint64_t def_wwnn;
time_t loop_down_time;
@@ -285,13 +284,14 @@ struct isposinfo {
const struct firmware * fw;
 
/*
-* DMA related sdtuff
+* DMA related stuff
 */
struct resource *   regs;
struct resource *   regs2;
bus_dma_tag_t   dmat;
bus_dma_tag_t   cdmat;
bus_dmamap_tcdmap;
+   bus_dma_tag_t   scdmat;
 
/*
 * Command and transaction related related stuff
@@ -409,7 +409,7 @@ switch (type) { 
\
 case SYNC_SFORDEV: \
 {  \
struct isp_fc *fc = ISP_FC_PC(isp, chan);   \
-   bus_dmamap_sync(fc->tdmat, fc->tdmap,   \
+   bus_dmamap_sync(isp->isp_osinfo.scdmat, fc->scmap,  \
   BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); \
break;  \
 }  \
@@ -421,7 +421,7 @@ case SYNC_REQUEST:  
\
 case SYNC_SFORCPU: \
 {  \
struct isp_fc *fc = ISP_FC_PC(isp, chan);   \
-   bus_dmamap_sync(fc->tdmat, fc->tdmap,   \
+   bus_dmamap_sync(isp->isp_osinfo.scdmat, fc->scmap,  \
   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);   \
break;  \
 }  \
@@ -443,7 +443,7 @@ switch (type) { 
\
 case SYNC_SFORDEV: \
 {  \
struct isp_fc *fc = ISP_FC_PC(isp, chan);   \
-   bus_dmamap_sync(fc->tdmat, fc->tdmap,   \
+   bus_dmamap_sync(isp->isp_osinfo.scdmat, fc->scmap,  \
   BUS_DMASYNC_PREWRITE);   \
break;  \
 }  \
@@ -454,7 +454,7 @@ case SYNC_REQUEST:  
\
 case SYNC_SFORCPU: \
 {  \
struct isp_fc *fc = ISP_FC_PC(isp, chan);   \
-   bus_dmamap_sync(fc->tdmat, fc->tdmap,   \
+   bus_dmamap_sync(isp->isp_osinfo.scdmat, fc->scmap,  \
   BUS_DMASYNC_POSTWRITE);  \
break;  \
 }  \

Modified: stable/10/sys/dev/isp/isp_pci.c
==
--- stable/10/sys/dev/isp/isp_pci.c Wed Dec 30 11:53:15 2015
(r292926)
+++ stable/10/sys/dev/isp/isp_pci.c Wed Dec 30 11:53:21 2015
(r292927)
@@ -1604,11 +1604,8 @@ imc1(void *arg, bus_dma_segment_t *segs,
imushp->error = error;
return;
}
-   if (nseg != 1) {
-   imushp->error = EINVAL;
-   return;
-   }
-   isp_prt(imushp->isp, ISP_LOGDEBUG0, "scdma @ 0x%jx/0x%jx", (uintmax_t) 
segs->ds_addr, (uintmax_t) segs->ds_len);
+   isp_prt(imushp->isp, ISP_LOGDEBUG0, "scdma @ 0x%jx/0x%jx",
+   (uintmax_t) segs->ds_addr, (uintmax_t) segs->ds_len);
FCPARAM(imushp->isp, imushp->chan)->isp_scdma = segs->ds_addr;
FCPARAM(imushp->isp, imushp->chan)->isp_scratch = imushp->vbase;
 }
@@ -1735,23 +1732,27 @@ isp_pci_mbxdma(ispsoftc_t *isp)
}
 
if (IS_FC(isp)) {
+   if (isp_dma_tag_create(isp->isp_osinfo.dmat, 64, slim,
+   BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, 

svn commit: r292919 - stable/10/sys/dev/isp

2015-12-30 Thread Alexander Motin
Author: mav
Date: Wed Dec 30 11:49:04 2015
New Revision: 292919
URL: https://svnweb.freebsd.org/changeset/base/292919

Log:
  MFC r292715: Clear virtual port's port database when disabling it.
  
  Previously it was done only on full chip reinit, that caused old ports
  resurrect in case of virtual port reenabling.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_library.c
  stable/10/sys/dev/isp/isp_library.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Wed Dec 30 11:48:17 2015(r292918)
+++ stable/10/sys/dev/isp/isp.c Wed Dec 30 11:49:04 2015(r292919)
@@ -2344,6 +2344,159 @@ isp_fibre_init_2400(ispsoftc_t *isp)
isp->isp_state = ISP_RUNSTATE;
 }
 
+static int
+isp_fc_enable_vp(ispsoftc_t *isp, int chan)
+{
+   fcparam *fcp = FCPARAM(isp, chan);
+   mbreg_t mbs;
+   vp_modify_t *vp;
+   uint8_t qe[QENTRY_LEN], *scp;
+
+   ISP_MEMZERO(qe, QENTRY_LEN);
+   if (FC_SCRATCH_ACQUIRE(isp, chan)) {
+   return (EBUSY);
+   }
+   scp = fcp->isp_scratch;
+
+   /* Build a VP MODIFY command in memory */
+   vp = (vp_modify_t *) qe;
+   vp->vp_mod_hdr.rqs_entry_type = RQSTYPE_VP_MODIFY;
+   vp->vp_mod_hdr.rqs_entry_count = 1;
+   vp->vp_mod_cnt = 1;
+   vp->vp_mod_idx0 = chan;
+   vp->vp_mod_cmd = VP_MODIFY_ENA;
+   vp->vp_mod_ports[0].options = ICB2400_VPOPT_ENABLED |
+   ICB2400_VPOPT_ENA_SNSLOGIN;
+   if (fcp->role & ISP_ROLE_INITIATOR) {
+   vp->vp_mod_ports[0].options |= ICB2400_VPOPT_INI_ENABLE;
+   }
+   if ((fcp->role & ISP_ROLE_TARGET) == 0) {
+   vp->vp_mod_ports[0].options |= ICB2400_VPOPT_TGT_DISABLE;
+   }
+   if (fcp->isp_loopid < LOCAL_LOOP_LIM) {
+   vp->vp_mod_ports[0].loopid = fcp->isp_loopid;
+   if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
+   vp->vp_mod_ports[0].options |=
+   ICB2400_VPOPT_HARD_ADDRESS;
+   else
+   vp->vp_mod_ports[0].options |=
+   ICB2400_VPOPT_PREV_ADDRESS;
+   }
+   MAKE_NODE_NAME_FROM_WWN(vp->vp_mod_ports[0].wwpn, fcp->isp_wwpn);
+   MAKE_NODE_NAME_FROM_WWN(vp->vp_mod_ports[0].wwnn, fcp->isp_wwnn);
+   isp_put_vp_modify(isp, vp, (vp_modify_t *) scp);
+
+   /* Build a EXEC IOCB A64 command that points to the VP MODIFY command */
+   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 0);
+   mbs.param[1] = QENTRY_LEN;
+   mbs.param[2] = DMA_WD1(fcp->isp_scdma);
+   mbs.param[3] = DMA_WD0(fcp->isp_scdma);
+   mbs.param[6] = DMA_WD3(fcp->isp_scdma);
+   mbs.param[7] = DMA_WD2(fcp->isp_scdma);
+   MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN, chan);
+   isp_control(isp, ISPCTL_RUN_MBOXCMD, );
+   if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
+   FC_SCRATCH_RELEASE(isp, chan);
+   return (EIO);
+   }
+   MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
+   isp_get_vp_modify(isp, (vp_modify_t *)[QENTRY_LEN], vp);
+
+   FC_SCRATCH_RELEASE(isp, chan);
+
+   if (vp->vp_mod_status != VP_STS_OK) {
+   isp_prt(isp, ISP_LOGERR, "%s: VP_MODIFY of Chan %d failed with 
status %d", __func__, chan, vp->vp_mod_status);
+   return (EIO);
+   }
+   return (0);
+}
+
+static int
+isp_fc_disable_vp(ispsoftc_t *isp, int chan)
+{
+   fcparam *fcp = FCPARAM(isp, chan);
+   mbreg_t mbs;
+   vp_ctrl_info_t *vp;
+   uint8_t qe[QENTRY_LEN], *scp;
+
+   ISP_MEMZERO(qe, QENTRY_LEN);
+   if (FC_SCRATCH_ACQUIRE(isp, chan)) {
+   return (EBUSY);
+   }
+   scp = fcp->isp_scratch;
+
+   /* Build a VP CTRL command in memory */
+   vp = (vp_ctrl_info_t *) qe;
+   vp->vp_ctrl_hdr.rqs_entry_type = RQSTYPE_VP_CTRL;
+   vp->vp_ctrl_hdr.rqs_entry_count = 1;
+   if (ISP_CAP_VP0(isp)) {
+   vp->vp_ctrl_status = 1;
+   } else {
+   vp->vp_ctrl_status = 0;
+   chan--; /* VP0 can not be controlled in this case. */
+   }
+   vp->vp_ctrl_command = VP_CTRL_CMD_DISABLE_VP_LOGO_ALL;
+   vp->vp_ctrl_vp_count = 1;
+   vp->vp_ctrl_idmap[chan / 16] |= (1 << chan % 16);
+   isp_put_vp_ctrl_info(isp, vp, (vp_ctrl_info_t *) scp);
+
+   /* Build a EXEC IOCB A64 command that points to the VP CTRL command */
+   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 0);
+   mbs.param[1] = QENTRY_LEN;
+   mbs.param[2] = DMA_WD1(fcp->isp_scdma);
+   mbs.param[3] = DMA_WD0(fcp->isp_scdma);
+   mbs.param[6] = DMA_WD3(fcp->isp_scdma);
+   mbs.param[7] = DMA_WD2(fcp->isp_scdma);
+   MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN, chan);
+   isp_control(isp, ISPCTL_RUN_MBOXCMD, );
+   if 

svn commit: r292922 - stable/10/sys/dev/isp

2015-12-30 Thread Alexander Motin
Author: mav
Date: Wed Dec 30 11:50:52 2015
New Revision: 292922
URL: https://svnweb.freebsd.org/changeset/base/292922

Log:
  MFC r292739: Make virtual ports control asynchronous.
  
  Before this change virtual ports control IOCBs were executed synchronously
  via Execute IOCB mailbox command.  It required exclusive use of scratch
  space of driver and mailbox registers of the hardware.  Because of that
  shared resources use this code could not really sleep, having to spin for
  completion, blocking any other operation.
  
  This change introduces new asynchronous design, sending the IOCBs directly
  on request queue and gracefully waiting for their return on response queue.
  Returned IOCBs are identified with unified handle space from r292725.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_library.c
  stable/10/sys/dev/isp/ispvar.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==
--- stable/10/sys/dev/isp/isp.c Wed Dec 30 11:49:48 2015(r292921)
+++ stable/10/sys/dev/isp/isp.c Wed Dec 30 11:50:52 2015(r292922)
@@ -2348,64 +2348,64 @@ static int
 isp_fc_enable_vp(ispsoftc_t *isp, int chan)
 {
fcparam *fcp = FCPARAM(isp, chan);
-   mbreg_t mbs;
-   vp_modify_t *vp;
-   uint8_t qe[QENTRY_LEN], *scp;
-
-   ISP_MEMZERO(qe, QENTRY_LEN);
-   if (FC_SCRATCH_ACQUIRE(isp, chan)) {
-   return (EBUSY);
-   }
-   scp = fcp->isp_scratch;
+   vp_modify_t vp;
+   void *reqp;
+   uint8_t resp[QENTRY_LEN];
 
/* Build a VP MODIFY command in memory */
-   vp = (vp_modify_t *) qe;
-   vp->vp_mod_hdr.rqs_entry_type = RQSTYPE_VP_MODIFY;
-   vp->vp_mod_hdr.rqs_entry_count = 1;
-   vp->vp_mod_cnt = 1;
-   vp->vp_mod_idx0 = chan;
-   vp->vp_mod_cmd = VP_MODIFY_ENA;
-   vp->vp_mod_ports[0].options = ICB2400_VPOPT_ENABLED |
+   ISP_MEMZERO(, sizeof(vp));
+   vp.vp_mod_hdr.rqs_entry_type = RQSTYPE_VP_MODIFY;
+   vp.vp_mod_hdr.rqs_entry_count = 1;
+   vp.vp_mod_cnt = 1;
+   vp.vp_mod_idx0 = chan;
+   vp.vp_mod_cmd = VP_MODIFY_ENA;
+   vp.vp_mod_ports[0].options = ICB2400_VPOPT_ENABLED |
ICB2400_VPOPT_ENA_SNSLOGIN;
-   if (fcp->role & ISP_ROLE_INITIATOR) {
-   vp->vp_mod_ports[0].options |= ICB2400_VPOPT_INI_ENABLE;
-   }
-   if ((fcp->role & ISP_ROLE_TARGET) == 0) {
-   vp->vp_mod_ports[0].options |= ICB2400_VPOPT_TGT_DISABLE;
-   }
+   if (fcp->role & ISP_ROLE_INITIATOR)
+   vp.vp_mod_ports[0].options |= ICB2400_VPOPT_INI_ENABLE;
+   if ((fcp->role & ISP_ROLE_TARGET) == 0)
+   vp.vp_mod_ports[0].options |= ICB2400_VPOPT_TGT_DISABLE;
if (fcp->isp_loopid < LOCAL_LOOP_LIM) {
-   vp->vp_mod_ports[0].loopid = fcp->isp_loopid;
+   vp.vp_mod_ports[0].loopid = fcp->isp_loopid;
if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
-   vp->vp_mod_ports[0].options |=
-   ICB2400_VPOPT_HARD_ADDRESS;
+   vp.vp_mod_ports[0].options |= 
ICB2400_VPOPT_HARD_ADDRESS;
else
-   vp->vp_mod_ports[0].options |=
-   ICB2400_VPOPT_PREV_ADDRESS;
+   vp.vp_mod_ports[0].options |= 
ICB2400_VPOPT_PREV_ADDRESS;
}
-   MAKE_NODE_NAME_FROM_WWN(vp->vp_mod_ports[0].wwpn, fcp->isp_wwpn);
-   MAKE_NODE_NAME_FROM_WWN(vp->vp_mod_ports[0].wwnn, fcp->isp_wwnn);
-   isp_put_vp_modify(isp, vp, (vp_modify_t *) scp);
+   MAKE_NODE_NAME_FROM_WWN(vp.vp_mod_ports[0].wwpn, fcp->isp_wwpn);
+   MAKE_NODE_NAME_FROM_WWN(vp.vp_mod_ports[0].wwnn, fcp->isp_wwnn);
 
-   /* Build a EXEC IOCB A64 command that points to the VP MODIFY command */
-   MBSINIT(, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 0);
-   mbs.param[1] = QENTRY_LEN;
-   mbs.param[2] = DMA_WD1(fcp->isp_scdma);
-   mbs.param[3] = DMA_WD0(fcp->isp_scdma);
-   mbs.param[6] = DMA_WD3(fcp->isp_scdma);
-   mbs.param[7] = DMA_WD2(fcp->isp_scdma);
-   MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN, chan);
-   isp_control(isp, ISPCTL_RUN_MBOXCMD, );
-   if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-   FC_SCRATCH_RELEASE(isp, chan);
+   /* Prepare space for response in memory */
+   memset(resp, 0xff, sizeof(resp));
+   vp.vp_mod_hdl = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
+   if (vp.vp_mod_hdl == 0) {
+   isp_prt(isp, ISP_LOGERR,
+   "%s: VP_MODIFY of Chan %d out of handles", __func__, chan);
return (EIO);
}
-   MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
-   isp_get_vp_modify(isp, (vp_modify_t *)[QENTRY_LEN], vp);
 
-   FC_SCRATCH_RELEASE(isp, chan);
+   /* Send request and wait for response. */
+ 

svn commit: r292929 - stable/10/sys/dev/isp

2015-12-30 Thread Alexander Motin
Author: mav
Date: Wed Dec 30 11:54:37 2015
New Revision: 292929
URL: https://svnweb.freebsd.org/changeset/base/292929

Log:
  MFC r292764: Split DMA buffers for request, response and ATIO queues.

Modified:
  stable/10/sys/dev/isp/isp_freebsd.h
  stable/10/sys/dev/isp/isp_pci.c
  stable/10/sys/dev/isp/isp_sbus.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp_freebsd.h
==
--- stable/10/sys/dev/isp/isp_freebsd.h Wed Dec 30 11:54:09 2015
(r292928)
+++ stable/10/sys/dev/isp/isp_freebsd.h Wed Dec 30 11:54:37 2015
(r292929)
@@ -289,9 +289,13 @@ struct isposinfo {
struct resource *   regs;
struct resource *   regs2;
bus_dma_tag_t   dmat;
-   bus_dma_tag_t   cdmat;
-   bus_dmamap_tcdmap;
+   bus_dma_tag_t   reqdmat;
+   bus_dma_tag_t   respdmat;
+   bus_dma_tag_t   atiodmat;
bus_dma_tag_t   scdmat;
+   bus_dmamap_treqmap;
+   bus_dmamap_trespmap;
+   bus_dmamap_tatiomap;
 
/*
 * Command and transaction related related stuff
@@ -406,6 +410,14 @@ struct isposinfo {
 
 #defineMEMORYBARRIER(isp, type, offset, size, chan)\
 switch (type) {\
+case SYNC_REQUEST: \
+   bus_dmamap_sync(isp->isp_osinfo.reqdmat,\
+  isp->isp_osinfo.reqmap, BUS_DMASYNC_PREWRITE);   \
+   break;  \
+case SYNC_RESULT:  \
+   bus_dmamap_sync(isp->isp_osinfo.respdmat,   \
+  isp->isp_osinfo.respmap, BUS_DMASYNC_POSTREAD);  \
+   break;  \
 case SYNC_SFORDEV: \
 {  \
struct isp_fc *fc = ISP_FC_PC(isp, chan);   \
@@ -413,11 +425,6 @@ case SYNC_SFORDEV: 
\
   BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); \
break;  \
 }  \
-case SYNC_REQUEST: \
-   bus_dmamap_sync(isp->isp_osinfo.cdmat,  \
-  isp->isp_osinfo.cdmap,   \
-  BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); \
-   break;  \
 case SYNC_SFORCPU: \
 {  \
struct isp_fc *fc = ISP_FC_PC(isp, chan);   \
@@ -425,21 +432,24 @@ case SYNC_SFORCPU:
\
   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);   \
break;  \
 }  \
-case SYNC_RESULT:  \
-   bus_dmamap_sync(isp->isp_osinfo.cdmat,  \
-  isp->isp_osinfo.cdmap,   \
-  BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);   \
-   break;  \
 case SYNC_REG: \
bus_barrier(isp->isp_osinfo.regs, offset, size, \
BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);  \
break;  \
+case SYNC_ATIOQ:   \
+   bus_dmamap_sync(isp->isp_osinfo.atiodmat,   \
+  isp->isp_osinfo.atiomap, BUS_DMASYNC_POSTREAD);  \
+   break;  \
 default:   \
break;  \
 }
 
 #defineMEMORYBARRIERW(isp, type, offset, size, chan)   \
 switch (type) {\
+case SYNC_REQUEST: \
+   bus_dmamap_sync(isp->isp_osinfo.reqdmat,\
+  isp->isp_osinfo.reqmap, BUS_DMASYNC_PREWRITE);   \
+   break;  \
 case SYNC_SFORDEV: \
 {  \
struct isp_fc *fc = ISP_FC_PC(isp, chan);   \
@@ -447,10 +457,6 @@ case SYNC_SFORDEV: 
\
   BUS_DMASYNC_PREWRITE);   

svn commit: r291384 - stable/10/sys/rpc

2015-11-27 Thread Alexander Motin
Author: mav
Date: Fri Nov 27 14:38:36 2015
New Revision: 291384
URL: https://svnweb.freebsd.org/changeset/base/291384

Log:
  MFC r291061: Improve locking of sg_threadcount.

Modified:
  stable/10/sys/rpc/svc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/rpc/svc.c
==
--- stable/10/sys/rpc/svc.c Fri Nov 27 14:29:04 2015(r291383)
+++ stable/10/sys/rpc/svc.c Fri Nov 27 14:38:36 2015(r291384)
@@ -1303,7 +1303,9 @@ svc_new_thread(SVCGROUP *grp)
SVCPOOL *pool = grp->sg_pool;
struct thread *td;
 
+   mtx_lock(>sg_lock);
grp->sg_threadcount++;
+   mtx_unlock(>sg_lock);
kthread_add(svc_thread_start, grp, pool->sp_proc, , 0, 0,
"%s: service", pool->sp_name);
 }
@@ -1336,12 +1338,12 @@ svc_run(SVCPOOL *pool)
}
 
/* Starting threads */
+   pool->sp_groups[0].sg_threadcount++;
for (g = 0; g < pool->sp_groupcount; g++) {
grp = >sp_groups[g];
for (i = ((g == 0) ? 1 : 0); i < grp->sg_minthreads; i++)
svc_new_thread(grp);
}
-   pool->sp_groups[0].sg_threadcount++;
svc_run_internal(>sp_groups[0], TRUE);
 
/* Waiting for threads to stop. */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291429 - in stable/10: share/examples/ses/srcs sys/cam/scsi

2015-11-28 Thread Alexander Motin
Author: mav
Date: Sat Nov 28 17:26:46 2015
New Revision: 291429
URL: https://svnweb.freebsd.org/changeset/base/291429

Log:
  MFC r291126:
  Add API to obtain primary enclosure name and ID for /dev/sesX devices.
  
  sesX device number may change between reboots, so to properly identify
  the instance we need more data.  Name and ID reported here may mach ones
  reported by SCSI device, but that is not really required by specs.
  
  Sponsored by: iXsystems, Inc.

Modified:
  stable/10/share/examples/ses/srcs/getencstat.c
  stable/10/sys/cam/scsi/scsi_enc.c
  stable/10/sys/cam/scsi/scsi_enc.h
  stable/10/sys/cam/scsi/scsi_enc_ses.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/examples/ses/srcs/getencstat.c
==
--- stable/10/share/examples/ses/srcs/getencstat.c  Sat Nov 28 15:22:46 
2015(r291428)
+++ stable/10/share/examples/ses/srcs/getencstat.c  Sat Nov 28 17:26:46 
2015(r291429)
@@ -48,12 +48,14 @@
 int
 main(int a, char **v)
 {
+   encioc_string_t stri;
encioc_element_t *objp;
encioc_elm_status_t ob;
encioc_elm_desc_t objd;
encioc_elm_devnames_t objdn;
int fd, nobj, f, i, verbose, quiet, errors;
u_char estat;
+   char str[32];
 
if (a < 2) {
fprintf(stderr, "usage: %s [ -v ] device [ device ... ]\n", *v);
@@ -78,6 +80,16 @@ main(int a, char **v)
perror(*v);
continue;
}
+   if (verbose > 1) {
+   stri.bufsiz = sizeof(str);
+   stri.buf = [0];
+   if (ioctl(fd, ENCIOC_GETENCNAME, (caddr_t) ) == 0)
+   printf("%s: Enclosure Name: %s\n", *v, 
stri.buf);
+   stri.bufsiz = sizeof(str);
+   stri.buf = [0];
+   if (ioctl(fd, ENCIOC_GETENCID, (caddr_t) ) == 0)
+   printf("%s: Enclosure ID: %s\n", *v, stri.buf);
+   }
if (ioctl(fd, ENCIOC_GETNELM, (caddr_t) ) < 0) {
perror("ENCIOC_GETNELM");
(void) close(fd);

Modified: stable/10/sys/cam/scsi/scsi_enc.c
==
--- stable/10/sys/cam/scsi/scsi_enc.c   Sat Nov 28 15:22:46 2015
(r291428)
+++ stable/10/sys/cam/scsi/scsi_enc.c   Sat Nov 28 17:26:46 2015
(r291429)
@@ -407,6 +407,8 @@ enc_ioctl(struct cdev *dev, u_long cmd, 
case ENCIOC_GETELMSTAT:
case ENCIOC_GETELMDESC:
case ENCIOC_GETELMDEVNAMES:
+   case ENCIOC_GETENCNAME:
+   case ENCIOC_GETENCID:
break;
default:
if ((flag & FWRITE) == 0) {
@@ -461,6 +463,8 @@ enc_ioctl(struct cdev *dev, u_long cmd, 
 
case ENCIOC_GETSTRING:
case ENCIOC_SETSTRING:
+   case ENCIOC_GETENCNAME:
+   case ENCIOC_GETENCID:
if (enc->enc_vec.handle_string == NULL) {
error = EINVAL;
break;

Modified: stable/10/sys/cam/scsi/scsi_enc.h
==
--- stable/10/sys/cam/scsi/scsi_enc.h   Sat Nov 28 15:22:46 2015
(r291428)
+++ stable/10/sys/cam/scsi/scsi_enc.h   Sat Nov 28 17:26:46 2015
(r291429)
@@ -46,6 +46,8 @@
 #defineENCIOC_GETELMDEVNAMES   _IO(ENCIOC, 10)
 #defineENCIOC_GETSTRING_IO(ENCIOC, 11)
 #defineENCIOC_SETSTRING_IO(ENCIOC, 12)
+#defineENCIOC_GETENCNAME   _IO(ENCIOC, 13)
+#defineENCIOC_GETENCID _IO(ENCIOC, 14)
 
 /*
  * Platform Independent Definitions for enclosure devices.

Modified: stable/10/sys/cam/scsi/scsi_enc_ses.c
==
--- stable/10/sys/cam/scsi/scsi_enc_ses.c   Sat Nov 28 15:22:46 2015
(r291428)
+++ stable/10/sys/cam/scsi/scsi_enc_ses.c   Sat Nov 28 17:26:46 2015
(r291429)
@@ -345,8 +345,9 @@ typedef struct ses_cache {
const struct ses_cfg_page   *cfg_page;
 
/* References into the config page. */
+   int  ses_nsubencs;
const struct ses_enc_desc * const   *subencs;
-   uint8_t  ses_ntypes;
+   int  ses_ntypes;
const ses_type_t*ses_types;
 
/* Source for all the status pointers */
@@ -1383,11 +1384,12 @@ ses_process_config(enc_softc_t *enc, str
 * The cast here is not required in C++ but C99 is not so
 * sophisticated (see C99 6.5.16.1(1)).
 */
+   ses_cache->ses_nsubencs = ses_cfg_page_get_num_subenc(cfg_page);
ses_cache->subencs = subencs;
 
buf_subenc = 

svn commit: r291388 - stable/10/sys/cam/ctl

2015-11-27 Thread Alexander Motin
Author: mav
Date: Fri Nov 27 15:26:19 2015
New Revision: 291388
URL: https://svnweb.freebsd.org/changeset/base/291388

Log:
  MFC r290670: Modify target port groups logic in CTL.
  
   - Introduce "ha_shared" port option, which being set to "on" moves the
  port into separate port group, shared between HA nodes.  This allows to
  better handle cases when iSCSI portals are bound to CARP address that can
  dynamically move between nodes.  Some initiators (at least VMware) don't
  detect that after iSCSI reconnect they've attached to different SCSI port
  from different port group, that totally breakes ALUA status parsing.
  In theory, I believe, it should be enough to have different iSCSI portal
  group tags on different nodes to make initiators detect this condition,
  but it seems like VMware ignores those values, and even full LUN retaste
  forced by UA does not help.
   - Make CTL report up to three port groups: 1 -- non-HA mode or ports
  with "ha_shared" option set, 2 -- HA node 1, 3 -- HA node 2.
   - Report Transitioning state for all port groups when HA interlink is
  connected, but neither of nodes is primary for the LUN.

Modified:
  stable/10/sys/cam/ctl/ctl.c
  stable/10/sys/cam/ctl/ctl_frontend.c
  stable/10/sys/cam/ctl/ctl_frontend.h
  stable/10/sys/cam/ctl/ctl_private.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Fri Nov 27 15:19:36 2015(r291387)
+++ stable/10/sys/cam/ctl/ctl.c Fri Nov 27 15:26:19 2015(r291388)
@@ -1821,13 +1821,13 @@ ctl_init(void)
SYSCTL_ADD_INT(>sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "ha_id", CTLFLAG_RDTUN, >ha_id, 0,
"HA head ID (0 - no HA)");
-   if (softc->ha_id == 0 || softc->ha_id > NUM_TARGET_PORT_GROUPS) {
+   if (softc->ha_id == 0 || softc->ha_id > NUM_HA_SHELVES) {
softc->flags |= CTL_FLAG_ACTIVE_SHELF;
softc->is_single = 1;
softc->port_cnt = CTL_MAX_PORTS;
softc->port_min = 0;
} else {
-   softc->port_cnt = CTL_MAX_PORTS / NUM_TARGET_PORT_GROUPS;
+   softc->port_cnt = CTL_MAX_PORTS / NUM_HA_SHELVES;
softc->port_min = (softc->ha_id - 1) * softc->port_cnt;
}
softc->port_max = softc->port_min + softc->port_cnt;
@@ -7139,8 +7139,8 @@ ctl_report_tagret_port_groups(struct ctl
 {
struct scsi_maintenance_in *cdb;
int retval;
-   int alloc_len, ext, total_len = 0, g, pc, pg, gs, os;
-   int num_target_port_groups, num_target_ports;
+   int alloc_len, ext, total_len = 0, g, pc, pg, ts, os;
+   int num_ha_groups, num_target_ports, shared_group;
struct ctl_lun *lun;
struct ctl_softc *softc;
struct ctl_port *port;
@@ -7174,11 +7174,8 @@ ctl_report_tagret_port_groups(struct ctl
return(retval);
}
 
-   if (softc->is_single)
-   num_target_port_groups = 1;
-   else
-   num_target_port_groups = NUM_TARGET_PORT_GROUPS;
num_target_ports = 0;
+   shared_group = (softc->is_single != 0);
mtx_lock(>ctl_lock);
STAILQ_FOREACH(port, >port_list, links) {
if ((port->status & CTL_PORT_STATUS_ONLINE) == 0)
@@ -7186,15 +7183,18 @@ ctl_report_tagret_port_groups(struct ctl
if (ctl_lun_map_to_port(port, lun->lun) >= CTL_MAX_LUNS)
continue;
num_target_ports++;
+   if (port->status & CTL_PORT_STATUS_HA_SHARED)
+   shared_group = 1;
}
mtx_unlock(>ctl_lock);
+   num_ha_groups = (softc->is_single) ? 0 : NUM_HA_SHELVES;
 
if (ext)
total_len = sizeof(struct scsi_target_group_data_extended);
else
total_len = sizeof(struct scsi_target_group_data);
total_len += sizeof(struct scsi_target_port_group_descriptor) *
-   num_target_port_groups +
+   (shared_group + num_ha_groups) +
sizeof(struct scsi_target_port_descriptor) * num_target_ports;
 
alloc_len = scsi_4btoul(cdb->length);
@@ -7231,24 +7231,62 @@ ctl_report_tagret_port_groups(struct ctl
 
mtx_lock(>ctl_lock);
pg = softc->port_min / softc->port_cnt;
-   if (softc->ha_link == CTL_HA_LINK_OFFLINE)
-   gs = TPG_ASYMMETRIC_ACCESS_UNAVAILABLE;
-   else if (softc->ha_link == CTL_HA_LINK_UNKNOWN)
-   gs = TPG_ASYMMETRIC_ACCESS_TRANSITIONING;
-   else if (softc->ha_mode == CTL_HA_MODE_ACT_STBY)
-   gs = TPG_ASYMMETRIC_ACCESS_STANDBY;
-   else
-   gs = TPG_ASYMMETRIC_ACCESS_NONOPTIMIZED;
-   if (lun->flags & CTL_LUN_PRIMARY_SC) {
-   os = gs;
-   gs = TPG_ASYMMETRIC_ACCESS_OPTIMIZED;
-   } else
-   os = 

svn commit: r291389 - stable/10/sys/cam/ctl

2015-11-27 Thread Alexander Motin
Author: mav
Date: Fri Nov 27 15:27:43 2015
New Revision: 291389
URL: https://svnweb.freebsd.org/changeset/base/291389

Log:
  MFC r290820: Add NULL check to make Coverity happy.

Modified:
  stable/10/sys/cam/ctl/ctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ctl/ctl.c
==
--- stable/10/sys/cam/ctl/ctl.c Fri Nov 27 15:26:19 2015(r291388)
+++ stable/10/sys/cam/ctl/ctl.c Fri Nov 27 15:27:43 2015(r291389)
@@ -9762,7 +9762,8 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio
desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT |
SVPD_ID_TYPE_TPORTGRP;
desc->length = 4;
-   if (softc->is_single || port->status & CTL_PORT_STATUS_HA_SHARED)
+   if (softc->is_single ||
+   (port && port->status & CTL_PORT_STATUS_HA_SHARED))
g = 1;
else
g = 2 + ctsio->io_hdr.nexus.targ_port / softc->port_cnt;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r291541 - stable/10/sys/dev/ispfw

2015-11-30 Thread Alexander Motin
Author: mav
Date: Mon Nov 30 22:58:48 2015
New Revision: 291541
URL: https://svnweb.freebsd.org/changeset/base/291541

Log:
  MFC r289755: Remove residual verbosity.
  
  firmware_register() already reports errors.

Modified:
  stable/10/sys/dev/ispfw/ispfw.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/ispfw/ispfw.c
==
--- stable/10/sys/dev/ispfw/ispfw.c Mon Nov 30 22:53:55 2015
(r291540)
+++ stable/10/sys/dev/ispfw/ispfw.c Mon Nov 30 22:58:48 2015
(r291541)
@@ -126,43 +126,27 @@ static intisp_2500_loaded;
 
 #defineISPFW_VERSION   1
 
-#if!defined(KLD_MODULE)
-#defineISPFW_KLD   0
-#else
-#defineISPFW_KLD   1
-#endif
-
 #defineRMACRO(token)   do {
\
if (token##_loaded) \
break;  \
if (firmware_register(#token, token##_risc_code,\
token##_risc_code[3] * sizeof(token##_risc_code[3]),\
-   ISPFW_VERSION, NULL) == NULL) { \
-   printf("%s: unable to register firmware <%s>\n",\
-   MODULE_NAME, #token);   \
+   ISPFW_VERSION, NULL) == NULL)   \
break;  \
-   }   \
token##_loaded++;   \
-   if (bootverbose || ISPFW_KLD)   \
-   printf("%s: registered firmware <%s>\n", MODULE_NAME,   \
-   #token);\
 } while (0)
 
 #defineUMACRO(token)   do {
\
if (!token##_loaded)\
break;  \
if (firmware_unregister(#token) != 0) { \
-   printf("%s: unable to unregister firmware <%s>\n",  \
-   MODULE_NAME, #token);   \
+   error = EBUSY;  \
break;  \
}   \
token##_loaded--;   \
-   if (bootverbose || ISPFW_KLD)   \
-   printf("%s: unregistered firmware <%s>\n", MODULE_NAME, \
-   #token);\
 } while (0)
 
-static void
+static int
 do_load_fw(void)
 {
 
@@ -196,11 +180,13 @@ do_load_fw(void)
 #ifdefined(ISP_2500)
RMACRO(isp_2500);
 #endif
+   return (0);
 }
 
-static void
+static int
 do_unload_fw(void)
 {
+   int error = 0;
 
 #ifdefined(ISP_1000)
UMACRO(isp_1000);
@@ -232,6 +218,7 @@ do_unload_fw(void)
 #ifdefined(ISP_2500)
UMACRO(isp_2500);
 #endif
+   return (error);
 }
 
 static int
@@ -240,17 +227,11 @@ module_handler(module_t mod, int what, v
 
switch (what) {
case MOD_LOAD:
-   do_load_fw();
-   break;
+   return (do_load_fw());
case MOD_UNLOAD:
-   do_unload_fw();
-   break;
-   case MOD_SHUTDOWN:
-   break;
-   default:
-   return (EOPNOTSUPP);
+   return (do_unload_fw());
}
-   return (0);
+   return (EOPNOTSUPP);
 }
 static moduledata_t ispfw_mod = {
MODULE_NAME, module_handler, NULL
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r301904 - stable/10/sys/dev/ntb/ntb_hw

2016-06-14 Thread Alexander Motin
Author: mav
Date: Wed Jun 15 01:42:53 2016
New Revision: 301904
URL: https://svnweb.freebsd.org/changeset/base/301904

Log:
  MFC r301293:
  When negotiating NTB_SB01BASE_LOCKUP workaround, don't try to limit the
  BAR size to 1MB.  According to Xeon v3 specifications and my tests, that
  size register is write-once and so not writeable after BIOS written it.
  
  Instead of that, make the code work with BAR of any sufficient size,
  properly calculating offset within its base.  It also simplifies the code.
  
  Sponsored by: iXsystems, Inc.

Modified:
  stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c
==
--- stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c   Wed Jun 15 01:41:43 2016
(r301903)
+++ stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c   Wed Jun 15 01:42:53 2016
(r301904)
@@ -75,7 +75,6 @@ __FBSDID("$FreeBSD$");
 
 #defineNTB_MSIX_VER_GUARD  0xaabbccdd
 #defineNTB_MSIX_RECEIVED   0xe0f0e0f0
-#defineONE_MB  (1024u * 1024)
 
 /*
  * PCI constants could be somewhere more generic, but aren't defined/used in
@@ -239,6 +238,7 @@ struct ntb_softc {
/* Memory window used to access peer bar0 */
 #define B2B_MW_DISABLEDUINT8_MAX
uint8_t b2b_mw_idx;
+   uint32_tmsix_xlat;
uint8_t msix_mw_idx;
 
uint8_t mw_count;
@@ -1375,12 +1375,12 @@ ntb_get_msix_info(struct ntb_softc *ntb)
 
laddr = bus_read_4(msix->msix_table_res, offset +
PCI_MSIX_ENTRY_LOWER_ADDR);
-   ntb_printf(2, "local lower MSIX addr(%u): 0x%x\n", i, laddr);
+   ntb_printf(2, "local MSIX addr(%u): 0x%x\n", i, laddr);
 
KASSERT((laddr & MSI_INTEL_ADDR_BASE) == MSI_INTEL_ADDR_BASE,
("local MSIX addr 0x%x not in MSI base 0x%x", laddr,
 MSI_INTEL_ADDR_BASE));
-   ntb->msix_data[i].nmd_ofs = laddr & ~MSI_INTEL_ADDR_BASE;
+   ntb->msix_data[i].nmd_ofs = laddr;
 
data = bus_read_4(msix->msix_table_res, offset +
PCI_MSIX_ENTRY_DATA);
@@ -1674,15 +1674,6 @@ xeon_reset_sbar_size(struct ntb_softc *n
bar_sz--;
else
bar_sz = 0;
-   } else if (HAS_FEATURE(NTB_SB01BASE_LOCKUP) &&
-   ntb_mw_to_bar(ntb, ntb->msix_mw_idx) == idx) {
-   /* Restrict LAPIC BAR to 1MB */
-   pci_write_config(ntb->device, bar->psz_off, 20, 1);
-   pci_write_config(ntb->device, bar->ssz_off, 20, 1);
-   bar_sz = pci_read_config(ntb->device, bar->psz_off, 1);
-   bar_sz = pci_read_config(ntb->device, bar->ssz_off, 1);
-   (void)bar_sz;
-   return;
}
pci_write_config(ntb->device, bar->ssz_off, bar_sz, 1);
bar_sz = pci_read_config(ntb->device, bar->ssz_off, 1);
@@ -1693,24 +1684,19 @@ static void
 xeon_set_sbar_base_and_limit(struct ntb_softc *ntb, uint64_t bar_addr,
 enum ntb_bar idx, enum ntb_bar regbar)
 {
-   uint64_t reg_val, lmt_addr;
+   uint64_t reg_val;
uint32_t base_reg, lmt_reg;
 
bar_get_xlat_params(ntb, idx, _reg, NULL, _reg);
if (idx == regbar)
bar_addr += ntb->b2b_off;
-   lmt_addr = bar_addr;
-
-   if (HAS_FEATURE(NTB_SB01BASE_LOCKUP) &&
-   ntb_mw_to_bar(ntb, ntb->msix_mw_idx) == idx)
-   lmt_addr += ONE_MB;
 
/*
 * Set limit registers first to avoid an errata where setting the base
 * registers locks the limit registers.
 */
if (!bar_is_64bit(ntb, idx)) {
-   ntb_reg_write(4, lmt_reg, lmt_addr);
+   ntb_reg_write(4, lmt_reg, bar_addr);
reg_val = ntb_reg_read(4, lmt_reg);
(void)reg_val;
 
@@ -1718,7 +1704,7 @@ xeon_set_sbar_base_and_limit(struct ntb_
reg_val = ntb_reg_read(4, base_reg);
(void)reg_val;
} else {
-   ntb_reg_write(8, lmt_reg, lmt_addr);
+   ntb_reg_write(8, lmt_reg, bar_addr);
reg_val = ntb_reg_read(8, lmt_reg);
(void)reg_val;
 
@@ -1747,31 +1733,13 @@ xeon_set_pbar_xlat(struct ntb_softc *ntb
 static int
 xeon_setup_msix_bar(struct ntb_softc *ntb)
 {
-   struct ntb_pci_bar_info *lapic_bar;
enum ntb_bar bar_num;
-   int rc;
 
if (!HAS_FEATURE(NTB_SB01BASE_LOCKUP))
return (0);
 
bar_num = ntb_mw_to_bar(ntb, ntb->msix_mw_idx);
-   lapic_bar = >bar_info[bar_num];
-
-   /* Restrict LAPIC BAR to 1MB */
-   if (lapic_bar->size > ONE_MB) {
-   rc = bus_adjust_resource(ntb->device, SYS_RES_MEMORY,
-

svn commit: r301903 - stable/10/sys/dev/ntb/ntb_hw

2016-06-14 Thread Alexander Motin
Author: mav
Date: Wed Jun 15 01:41:43 2016
New Revision: 301903
URL: https://svnweb.freebsd.org/changeset/base/301903

Log:
  MFC r301292: When negotiating MSIX parameters, give other head time to see
  our NTB_MSIX_RECEIVED status, before making upper layers overwrite it.
  
  This is not completely perfect, but now it works better then before.
  
  Sponsored by: iXsystems, Inc.

Modified:
  stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c
==
--- stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c   Wed Jun 15 01:39:43 2016
(r301902)
+++ stable/10/sys/dev/ntb/ntb_hw/ntb_hw.c   Wed Jun 15 01:41:43 2016
(r301903)
@@ -2820,6 +2820,8 @@ ntb_exchange_msix(void *ctx)
 
ntb = ctx;
 
+   if (ntb->peer_msix_good)
+   goto msix_good;
if (ntb->peer_msix_done)
goto msix_done;
 
@@ -2851,16 +2853,21 @@ msix_done:
goto reschedule;
 
ntb->peer_msix_good = true;
+   /* Give peer time to see our NTB_MSIX_RECEIVED. */
+   goto reschedule;
 
+msix_good:
ntb_poll_link(ntb);
ntb_link_event(ntb);
return;
 
 reschedule:
ntb->lnk_sta = pci_read_config(ntb->device, ntb->reg->lnk_sta, 2);
-   if (_xeon_link_is_up(ntb))
-   callout_reset(>peer_msix_work, hz / 100, 
ntb_exchange_msix, ntb);
-   else
+   if (_xeon_link_is_up(ntb)) {
+   callout_reset(>peer_msix_work,
+   hz * (ntb->peer_msix_good ? 2 : 1) / 100,
+   ntb_exchange_msix, ntb);
+   } else
ntb_spad_clear(ntb);
 }
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r301902 - stable/10/sys/dev/ntb/if_ntb

2016-06-14 Thread Alexander Motin
Author: mav
Date: Wed Jun 15 01:39:43 2016
New Revision: 301902
URL: https://svnweb.freebsd.org/changeset/base/301902

Log:
  MFC r300610: Re-enable write combining, disabled by default at r295486.
  
  if_ntb(4) strongly benefits from WC, improving throughput from 350Mbit/s
  to 8-10Gbit/s on my tests.

Modified:
  stable/10/sys/dev/ntb/if_ntb/if_ntb.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/ntb/if_ntb/if_ntb.c
==
--- stable/10/sys/dev/ntb/if_ntb/if_ntb.c   Tue Jun 14 23:58:02 2016
(r301901)
+++ stable/10/sys/dev/ntb/if_ntb/if_ntb.c   Wed Jun 15 01:39:43 2016
(r301902)
@@ -621,6 +621,10 @@ ntb_transport_probe(struct ntb_softc *nt
mw->xlat_size = 0;
mw->virt_addr = NULL;
mw->dma_addr = 0;
+
+   rc = ntb_mw_set_wc(nt->ntb, i, VM_MEMATTR_WRITE_COMBINING);
+   if (rc)
+   ntb_printf(0, "Unable to set mw%d caching\n", i);
}
 
qp_bitmap = ntb_db_valid_mask(ntb);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297019 - stable/10/sbin/geom/core

2016-03-18 Thread Alexander Motin
Author: mav
Date: Fri Mar 18 13:29:43 2016
New Revision: 297019
URL: https://svnweb.freebsd.org/changeset/base/297019

Log:
  MFC r296653: Allow standard commands for "unknown" classes in RESCUE mode.
  
  For example, it allows quite useful `geom disk list` command.

Modified:
  stable/10/sbin/geom/core/geom.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/geom/core/geom.c
==
--- stable/10/sbin/geom/core/geom.c Fri Mar 18 13:26:16 2016
(r297018)
+++ stable/10/sbin/geom/core/geom.c Fri Mar 18 13:29:43 2016
(r297019)
@@ -635,8 +635,7 @@ get_class(int *argc, char ***argv)
} else if (!strcasecmp(class_name, "label")) {
version = _version;
class_commands = glabel_class_commands;
-   } else
-   errx(EXIT_FAILURE, "Invalid class name.");
+   }
 #endif /* !STATIC_GEOM_CLASSES */
 
set_class_name();
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297852 - in stable/10/sys/dev: sound/pci/hda usb/controller

2016-04-12 Thread Alexander Motin
Author: mav
Date: Tue Apr 12 07:54:55 2016
New Revision: 297852
URL: https://svnweb.freebsd.org/changeset/base/297852

Log:
  MFC r297387: Add some device IDs found on AMD FCH shipsets.

Modified:
  stable/10/sys/dev/sound/pci/hda/hdac.c
  stable/10/sys/dev/sound/pci/hda/hdac.h
  stable/10/sys/dev/usb/controller/ehci_pci.c
  stable/10/sys/dev/usb/controller/ohci_pci.c
  stable/10/sys/dev/usb/controller/xhci_pci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sound/pci/hda/hdac.c
==
--- stable/10/sys/dev/sound/pci/hda/hdac.c  Tue Apr 12 07:54:03 2016
(r297851)
+++ stable/10/sys/dev/sound/pci/hda/hdac.c  Tue Apr 12 07:54:55 2016
(r297852)
@@ -159,6 +159,7 @@ static const struct {
{ HDA_ATI_RV940, "ATI RV940",   0, 0 },
{ HDA_ATI_RV970, "ATI RV970",   0, 0 },
{ HDA_ATI_R1000, "ATI R1000",   0, 0 },
+   { HDA_AMD_HUDSON2,   "AMD Hudson-2",0, 0 },
{ HDA_RDC_M3010, "RDC M3010",   0, 0 },
{ HDA_VIA_VT82XX,"VIA VT8251/8237A",0, 0 },
{ HDA_SIS_966,   "SiS 966", 0, 0 },
@@ -167,6 +168,7 @@ static const struct {
{ HDA_INTEL_ALL,  "Intel",  0, 0 },
{ HDA_NVIDIA_ALL, "NVIDIA", 0, 0 },
{ HDA_ATI_ALL,"ATI",0, 0 },
+   { HDA_AMD_ALL,"AMD",0, 0 },
{ HDA_VIA_ALL,"VIA",0, 0 },
{ HDA_SIS_ALL,"SiS",0, 0 },
{ HDA_ULI_ALL,"ULI",0, 0 },

Modified: stable/10/sys/dev/sound/pci/hda/hdac.h
==
--- stable/10/sys/dev/sound/pci/hda/hdac.h  Tue Apr 12 07:54:03 2016
(r297851)
+++ stable/10/sys/dev/sound/pci/hda/hdac.h  Tue Apr 12 07:54:55 2016
(r297852)
@@ -136,6 +136,10 @@
 #define HDA_ATI_R1000  HDA_MODEL_CONSTRUCT(ATI, 0xaaa0)
 #define HDA_ATI_ALLHDA_MODEL_CONSTRUCT(ATI, 0x)
 
+#define AMD_VENDORID   0x1022
+#define HDA_AMD_HUDSON2HDA_MODEL_CONSTRUCT(AMD, 0x780d)
+#define HDA_AMD_ALLHDA_MODEL_CONSTRUCT(AMD, 0x)
+
 /* RDC */
 #define RDC_VENDORID   0x17f3
 #define HDA_RDC_M3010  HDA_MODEL_CONSTRUCT(RDC, 0x3010)

Modified: stable/10/sys/dev/usb/controller/ehci_pci.c
==
--- stable/10/sys/dev/usb/controller/ehci_pci.c Tue Apr 12 07:54:03 2016
(r297851)
+++ stable/10/sys/dev/usb/controller/ehci_pci.c Tue Apr 12 07:54:55 2016
(r297852)
@@ -112,6 +112,8 @@ ehci_pci_match(device_t self)
 
case 0x20951022:
return ("AMD CS5536 (Geode) USB 2.0 controller");
+   case 0x78081022:
+   return ("AMD FCH USB 2.0 controller");
 
case 0x43451002:
return "ATI SB200 USB 2.0 controller";

Modified: stable/10/sys/dev/usb/controller/ohci_pci.c
==
--- stable/10/sys/dev/usb/controller/ohci_pci.c Tue Apr 12 07:54:03 2016
(r297851)
+++ stable/10/sys/dev/usb/controller/ohci_pci.c Tue Apr 12 07:54:55 2016
(r297852)
@@ -124,9 +124,10 @@ ohci_pci_match(device_t self)
 
case 0x740c1022:
return ("AMD-756 USB Controller");
-
case 0x74141022:
return ("AMD-766 USB Controller");
+   case 0x78071022:
+   return ("AMD FCH USB Controller");
 
case 0x43741002:
return "ATI SB400 USB Controller";

Modified: stable/10/sys/dev/usb/controller/xhci_pci.c
==
--- stable/10/sys/dev/usb/controller/xhci_pci.c Tue Apr 12 07:54:03 2016
(r297851)
+++ stable/10/sys/dev/usb/controller/xhci_pci.c Tue Apr 12 07:54:55 2016
(r297852)
@@ -95,6 +95,9 @@ xhci_pci_match(device_t self)
uint32_t device_id = pci_get_devid(self);
 
switch (device_id) {
+   case 0x78141022:
+   return ("AMD FCH USB 3.0 controller");
+
case 0x01941033:
return ("NEC uPD720200 USB 3.0 controller");
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297851 - in stable/10: share/man/man4 sys/dev/amdsbwd

2016-04-12 Thread Alexander Motin
Author: mav
Date: Tue Apr 12 07:54:03 2016
New Revision: 297851
URL: https://svnweb.freebsd.org/changeset/base/297851

Log:
  MFC r297386: Add support for AMD FCH watchdog timers.

Modified:
  stable/10/share/man/man4/amdsbwd.4
  stable/10/sys/dev/amdsbwd/amdsbwd.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man4/amdsbwd.4
==
--- stable/10/share/man/man4/amdsbwd.4  Tue Apr 12 07:21:22 2016
(r297850)
+++ stable/10/share/man/man4/amdsbwd.4  Tue Apr 12 07:54:03 2016
(r297851)
@@ -25,12 +25,12 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 7, 2011
+.Dd March 29, 2016
 .Dt AMDSBWD 4
 .Os
 .Sh NAME
 .Nm amdsbwd
-.Nd device driver for the AMD SB600/SB7xx/SB8xx watchdog timers
+.Nd device driver for the AMD southbridge watchdog timers
 .Sh SYNOPSIS
 To compile this driver into the kernel,
 place the following line in your
@@ -51,7 +51,7 @@ The
 driver provides
 .Xr watchdog 4
 support for the watchdog timers present on
-AMD SB600, SB7xx and SB8xx southbridges.
+AMD SB600, SB7xx, SB8xx and SB9xx southbridges and Axx FCHs.
 .Sh SEE ALSO
 .Xr watchdog 4 ,
 .Xr watchdog 8 ,

Modified: stable/10/sys/dev/amdsbwd/amdsbwd.c
==
--- stable/10/sys/dev/amdsbwd/amdsbwd.c Tue Apr 12 07:21:22 2016
(r297850)
+++ stable/10/sys/dev/amdsbwd/amdsbwd.c Tue Apr 12 07:54:03 2016
(r297851)
@@ -106,6 +106,8 @@ __FBSDID("$FreeBSD$");
 /* SB7xx RRG 2.3.1.1, SB600 RRG 2.3.1.1, SB8xx RRG 2.3.1.  */
 #defineAMDSB_SMBUS_DEVID   0x43851002
 #defineAMDSB8_SMBUS_REVID  0x40
+#defineAMDHUDSON_SMBUS_DEVID   0x780b1022
+#defineAMDKERNCZ_SMBUS_DEVID   0x790b1022
 
 #defineamdsbwd_verbose_printf(dev, ...)\
do {\
@@ -279,7 +281,9 @@ amdsbwd_identify(driver_t *driver, devic
smb_dev = pci_find_bsf(0, 20, 0);
if (smb_dev == NULL)
return;
-   if (pci_get_devid(smb_dev) != AMDSB_SMBUS_DEVID)
+   if (pci_get_devid(smb_dev) != AMDSB_SMBUS_DEVID &&
+   pci_get_devid(smb_dev) != AMDHUDSON_SMBUS_DEVID &&
+   pci_get_devid(smb_dev) != AMDKERNCZ_SMBUS_DEVID)
return;
 
child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "amdsbwd", -1);
@@ -309,10 +313,12 @@ amdsbwd_probe_sb7xx(device_t dev, struct
*addr <<= 8;
*addr |= pmio_read(pmres, AMDSB_PM_WDT_BASE_MSB - i);
}
+   *addr &= ~0x07u;
+
/* Set watchdog timer tick to 1s. */
val = pmio_read(pmres, AMDSB_PM_WDT_CTRL);
val &= ~AMDSB_WDT_RES_MASK;
-   val |= AMDSB_WDT_RES_10MS;
+   val |= AMDSB_WDT_RES_1S;
pmio_write(pmres, AMDSB_PM_WDT_CTRL, val);
 
/* Enable watchdog device (in stopped state). */
@@ -372,7 +378,7 @@ amdsbwd_probe_sb8xx(device_t dev, struct
val = pmio_read(pmres, AMDSB8_PM_WDT_EN);
device_printf(dev, "AMDSB8_PM_WDT_EN value = %#02x\n", val);
 #endif
-   device_set_desc(dev, "AMD SB8xx Watchdog Timer");
+   device_set_desc(dev, "AMD SB8xx/SB9xx/Axx Watchdog Timer");
 }
 
 static int
@@ -404,7 +410,8 @@ amdsbwd_probe(device_t dev)
 
smb_dev = pci_find_bsf(0, 20, 0);
KASSERT(smb_dev != NULL, ("can't find SMBus PCI device\n"));
-   if (pci_get_revid(smb_dev) < AMDSB8_SMBUS_REVID)
+   if (pci_get_devid(smb_dev) == AMDSB_SMBUS_DEVID &&
+   pci_get_revid(smb_dev) < AMDSB8_SMBUS_REVID)
amdsbwd_probe_sb7xx(dev, res, );
else
amdsbwd_probe_sb8xx(dev, res, );
@@ -440,10 +447,7 @@ amdsbwd_attach_sb(device_t dev, struct a
 
smb_dev = pci_find_bsf(0, 20, 0);
KASSERT(smb_dev != NULL, ("can't find SMBus PCI device\n"));
-   if (pci_get_revid(smb_dev) < AMDSB8_SMBUS_REVID)
-   sc->ms_per_tick = 10;
-   else
-   sc->ms_per_tick = 1000;
+   sc->ms_per_tick = 1000;
 
sc->res_ctrl = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
>rid_ctrl, RF_ACTIVE);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297021 - stable/10/sys/cddl/compat/opensolaris/kern

2016-03-19 Thread Alexander Motin
Author: mav
Date: Fri Mar 18 13:32:00 2016
New Revision: 297021
URL: https://svnweb.freebsd.org/changeset/base/297021

Log:
  MFC r296919: Fix small memory leak on attempt to access deleted snapshot.

Modified:
  stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
==
--- stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.cFri Mar 
18 13:30:40 2016(r297020)
+++ stable/10/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.cFri Mar 
18 13:32:00 2016(r297021)
@@ -196,6 +196,7 @@ mount_snapshot(kthread_t *td, vnode_t **
VI_UNLOCK(vp);
vrele(vp);
vfs_unbusy(mp);
+   vfs_freeopts(mp->mnt_optnew);
vfs_mount_destroy(mp);
*vpp = NULL;
return (error);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297144 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-21 Thread Alexander Motin
Author: mav
Date: Mon Mar 21 07:36:02 2016
New Revision: 297144
URL: https://svnweb.freebsd.org/changeset/base/297144

Log:
  MFC r277629 (by will):
  When creating or updating a node, use vfs_timestamp() for "now" instead
  of gethrestime(), to allow the administrator to decide the appropriate
  timestamp precision instead of always using nanosecond precision.

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
Mon Mar 21 07:16:30 2016(r297143)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
Mon Mar 21 07:36:02 2016(r297144)
@@ -795,7 +795,7 @@ zfs_mknode(znode_t *dzp, vattr_t *vap, d
gen = vap->va_nblocks;  /* ditto */
} else {
obj = 0;
-   gethrestime();
+   vfs_timestamp();
gen = dmu_tx_get_txg(tx);
}
 
@@ -1437,7 +1437,7 @@ zfs_tstamp_update_setup(znode_t *zp, uin
 {
timestruc_t now;
 
-   gethrestime();
+   vfs_timestamp();
 
if (have_tx) {  /* will sa_bulk_update happen really soon? */
zp->z_atime_dirty = 0;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297071 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 18:56:03 2016
New Revision: 297071
URL: https://svnweb.freebsd.org/changeset/base/297071

Log:
  MFC r271781i (by will):
  bpobj_iterate_impl(): Close a refcount leak iterating on a sublist.
  
  If bpobj_space() returned non-zero here, the sublist would have been
  left open, along with the bonus buffer hold it requires.  This call
  does not invoke any calls to bpobj_close() itself.
  
  This bug doesn't have any known vector, but was found on inspection.
  
  MFC after:  1 week
  Sponsored by:   Spectra Logic
  Affects:All ZFS versions starting 21 May 2010 (illumos cde58dbc)
  MFSpectraBSD:   r1050998 on 2014/03/26

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.cSun Mar 
20 18:31:30 2016(r297070)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.cSun Mar 
20 18:56:03 2016(r297071)
@@ -300,8 +300,10 @@ bpobj_iterate_impl(bpobj_t *bpo, bpobj_i
if (free) {
err = bpobj_space(,
_before, _before, _before);
-   if (err)
+   if (err != 0) {
+   bpobj_close();
break;
+   }
}
err = bpobj_iterate_impl(, func, arg, tx, free);
if (free) {
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297064 - stable/10/sys/kern

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 14:11:37 2016
New Revision: 297064
URL: https://svnweb.freebsd.org/changeset/base/297064

Log:
  MFC r256612: MFprojects/camlock r254685:
  Remove TQ_FLAGS_PENDING flag, softly duplicating queue emptiness status.

Modified:
  stable/10/sys/kern/subr_taskqueue.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/subr_taskqueue.c
==
--- stable/10/sys/kern/subr_taskqueue.c Sun Mar 20 14:06:27 2016
(r297063)
+++ stable/10/sys/kern/subr_taskqueue.c Sun Mar 20 14:11:37 2016
(r297064)
@@ -69,7 +69,6 @@ struct taskqueue {
 
 #defineTQ_FLAGS_ACTIVE (1 << 0)
 #defineTQ_FLAGS_BLOCKED(1 << 1)
-#defineTQ_FLAGS_PENDING(1 << 2)
 
 #defineDT_CALLOUT_ARMED(1 << 0)
 
@@ -222,8 +221,6 @@ taskqueue_enqueue_locked(struct taskqueu
task->ta_pending = 1;
if ((queue->tq_flags & TQ_FLAGS_BLOCKED) == 0)
queue->tq_enqueue(queue->tq_context);
-   else
-   queue->tq_flags |= TQ_FLAGS_PENDING;
 
return (0);
 }
@@ -309,10 +306,8 @@ taskqueue_unblock(struct taskqueue *queu
 
TQ_LOCK(queue);
queue->tq_flags &= ~TQ_FLAGS_BLOCKED;
-   if (queue->tq_flags & TQ_FLAGS_PENDING) {
-   queue->tq_flags &= ~TQ_FLAGS_PENDING;
+   if (!STAILQ_EMPTY(>tq_queue))
queue->tq_enqueue(queue->tq_context);
-   }
TQ_UNLOCK(queue);
 }
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297066 - stable/10/sys/kern

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 14:37:37 2016
New Revision: 297066
URL: https://svnweb.freebsd.org/changeset/base/297066

Log:
  MFC r256613, r256862: MFprojects/camlock r254763:
  Move tq_enqueue() call out of the queue lock for known handlers (actually
  I have found no others in the base system).  This reduces queue lock hold
  time and congestion spinning under active multithreaded enqueuing.

Modified:
  stable/10/sys/kern/subr_taskqueue.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/subr_taskqueue.c
==
--- stable/10/sys/kern/subr_taskqueue.c Sun Mar 20 14:21:07 2016
(r297065)
+++ stable/10/sys/kern/subr_taskqueue.c Sun Mar 20 14:37:37 2016
(r297066)
@@ -46,6 +46,9 @@ __FBSDID("$FreeBSD$");
 static MALLOC_DEFINE(M_TASKQUEUE, "taskqueue", "Task Queues");
 static void*taskqueue_giant_ih;
 static void*taskqueue_ih;
+static void taskqueue_fast_enqueue(void *);
+static void taskqueue_swi_enqueue(void *);
+static void taskqueue_swi_giant_enqueue(void *);
 
 struct taskqueue_busy {
struct task *tb_running;
@@ -69,6 +72,7 @@ struct taskqueue {
 
 #defineTQ_FLAGS_ACTIVE (1 << 0)
 #defineTQ_FLAGS_BLOCKED(1 << 1)
+#defineTQ_FLAGS_UNLOCKED_ENQUEUE   (1 << 2)
 
 #defineDT_CALLOUT_ARMED(1 << 0)
 
@@ -96,7 +100,8 @@ _timeout_task_init(struct taskqueue *que
 {
 
TASK_INIT(_task->t, priority, func, context);
-   callout_init_mtx(_task->c, >tq_mutex, 0);
+   callout_init_mtx(_task->c, >tq_mutex,
+   CALLOUT_RETURNUNLOCKED);
timeout_task->q = queue;
timeout_task->f = 0;
 }
@@ -127,6 +132,11 @@ _taskqueue_create(const char *name __unu
queue->tq_context = context;
queue->tq_spin = (mtxflags & MTX_SPIN) != 0;
queue->tq_flags |= TQ_FLAGS_ACTIVE;
+   if (enqueue == taskqueue_fast_enqueue ||
+   enqueue == taskqueue_swi_enqueue ||
+   enqueue == taskqueue_swi_giant_enqueue ||
+   enqueue == taskqueue_thread_enqueue)
+   queue->tq_flags |= TQ_FLAGS_UNLOCKED_ENQUEUE;
mtx_init(>tq_mutex, mtxname, NULL, mtxflags);
 
return queue;
@@ -196,6 +206,7 @@ taskqueue_enqueue_locked(struct taskqueu
if (task->ta_pending) {
if (task->ta_pending < USHRT_MAX)
task->ta_pending++;
+   TQ_UNLOCK(queue);
return (0);
}
 
@@ -219,9 +230,14 @@ taskqueue_enqueue_locked(struct taskqueu
}
 
task->ta_pending = 1;
+   if ((queue->tq_flags & TQ_FLAGS_UNLOCKED_ENQUEUE) != 0)
+   TQ_UNLOCK(queue);
if ((queue->tq_flags & TQ_FLAGS_BLOCKED) == 0)
queue->tq_enqueue(queue->tq_context);
+   if ((queue->tq_flags & TQ_FLAGS_UNLOCKED_ENQUEUE) == 0)
+   TQ_UNLOCK(queue);
 
+   /* Return with lock released. */
return (0);
 }
 int
@@ -231,7 +247,7 @@ taskqueue_enqueue(struct taskqueue *queu
 
TQ_LOCK(queue);
res = taskqueue_enqueue_locked(queue, task);
-   TQ_UNLOCK(queue);
+   /* The lock is released inside. */
 
return (res);
 }
@@ -248,6 +264,7 @@ taskqueue_timeout_func(void *arg)
timeout_task->f &= ~DT_CALLOUT_ARMED;
queue->tq_callouts--;
taskqueue_enqueue_locked(timeout_task->q, _task->t);
+   /* The lock is released inside. */
 }
 
 int
@@ -264,6 +281,7 @@ taskqueue_enqueue_timeout(struct taskque
res = timeout_task->t.ta_pending;
if (ticks == 0) {
taskqueue_enqueue_locked(queue, _task->t);
+   /* The lock is released inside. */
} else {
if ((timeout_task->f & DT_CALLOUT_ARMED) != 0) {
res++;
@@ -277,8 +295,8 @@ taskqueue_enqueue_timeout(struct taskque
callout_reset(_task->c, ticks,
taskqueue_timeout_func, timeout_task);
}
+   TQ_UNLOCK(queue);
}
-   TQ_UNLOCK(queue);
return (res);
 }
 
@@ -591,7 +609,6 @@ taskqueue_thread_enqueue(void *context)
tqp = context;
tq = *tqp;
 
-   TQ_ASSERT_LOCKED(tq);
wakeup_one(tq);
 }
 
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297067 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 16:00:05 2016
New Revision: 297067
URL: https://svnweb.freebsd.org/changeset/base/297067

Log:
  MFC r264670: MFV r264667:
  
  4752 fan out read zio taskqs
  
  illumos/illumos-gate@1b497ab83e8f1c58bba5da59c649207a442a4720

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c  Sun Mar 
20 14:37:37 2016(r297066)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c  Sun Mar 
20 16:00:05 2016(r297067)
@@ -21,7 +21,7 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
  * Copyright (c) 2015, Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2013 Martin Matuska . All rights reserved.
  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
@@ -140,7 +140,7 @@ static const char *const zio_taskq_types
 const zio_taskq_info_t zio_taskqs[ZIO_TYPES][ZIO_TASKQ_TYPES] = {
/* ISSUEISSUE_HIGH  INTRINTR_HIGH */
{ ZTI_ONE,  ZTI_NULL,   ZTI_ONE,ZTI_NULL }, /* NULL */
-   { ZTI_N(8), ZTI_NULL,   ZTI_BATCH,  ZTI_NULL }, /* READ */
+   { ZTI_N(8), ZTI_NULL,   ZTI_P(12, 8),   ZTI_NULL }, /* READ */
{ ZTI_BATCH,ZTI_N(5),   ZTI_N(8),   ZTI_N(5) }, /* WRITE */
{ ZTI_P(12, 8), ZTI_NULL,   ZTI_ONE,ZTI_NULL }, /* FREE */
{ ZTI_ONE,  ZTI_NULL,   ZTI_ONE,ZTI_NULL }, /* CLAIM */
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297075 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 19:14:51 2016
New Revision: 297075
URL: https://svnweb.freebsd.org/changeset/base/297075

Log:
  MFC r269222: Reschedule the 'deadman' callout after handling, this makes our
  code behave more like it is on Solaris.
  
  Differential Revision: https://phabric.freebsd.org/D457

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Sun Mar 
20 19:11:17 2016(r297074)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Sun Mar 
20 19:14:51 2016(r297075)
@@ -608,6 +608,12 @@ spa_deadman(void *arg)
++spa->spa_deadman_calls);
if (zfs_deadman_enabled)
vdev_deadman(spa->spa_root_vdev);
+#ifdef __FreeBSD__
+#ifdef _KERNEL
+   callout_schedule(>spa_deadman_cycid,
+   hz * zfs_deadman_checktime_ms / MILLISEC);
+#endif
+#endif
 }
 
 /*
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297082 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 20:27:52 2016
New Revision: 297082
URL: https://svnweb.freebsd.org/changeset/base/297082

Log:
  MFC r272359 (by will):
  zfsvfs_create(): Refuse to mount datasets whose names are too long.
  
  This is checked for in the zfs_snapshot_004_neg STF/ATF test (currently
  still in projects/zfsd rather than head).
  
  sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c:
  - zfsvfs_create(): Check whether the objset name fits into
statfs.f_mntfromname, and return ENAMETOOLONG if not.  Although
the filesystem can be unmounted via the umount(8) command, any
interface that relies on iterating on statfs (e.g. libzfs) will
fail to find the filesystem by its objset name, and thus assume
it's not mounted.  This causes "zfs unmount", "zfs destroy",
etc. to fail on these filesystems, whether or not -f is passed.
  
  MFSpectraBSD:   974872 on 2013/08/09

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c   
Sun Mar 20 20:25:36 2016(r297081)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c   
Sun Mar 20 20:27:52 2016(r297082)
@@ -855,6 +855,17 @@ zfsvfs_create(const char *osname, zfsvfs
int i, error;
uint64_t sa_obj;
 
+   /*
+* XXX: Fix struct statfs so this isn't necessary!
+*
+* The 'osname' is used as the filesystem's special node, which means
+* it must fit in statfs.f_mntfromname, or else it can't be
+* enumerated, so libzfs_mnttab_find() returns NULL, which causes
+* 'zfs unmount' to think it's not mounted when it is.
+*/
+   if (strlen(osname) >= MNAMELEN)
+   return (SET_ERROR(ENAMETOOLONG));
+
zfsvfs = kmem_zalloc(sizeof (zfsvfs_t), KM_SLEEP);
 
/*
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297078 - in stable/10: cddl/contrib/opensolaris/lib/libzpool/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 20:12:14 2016
New Revision: 297078
URL: https://svnweb.freebsd.org/changeset/base/297078

Log:
  MFC r274304 (by delphij): MFV r274272 and diff reduction with upstream.
  
  Illumos issue:
  5244 zio pipeline callers should explicitly invoke next stage

Modified:
  stable/10/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c
==
--- stable/10/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c  Sun Mar 
20 20:00:25 2016(r297077)
+++ stable/10/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c  Sun Mar 
20 20:12:14 2016(r297078)
@@ -25,6 +25,7 @@
 /*
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  * Copyright 2012 Garrett D'Amore .  All rights reserved.
+ * Copyright (c) 2014 by Delphix. All rights reserved.
  */
 
 #include 
@@ -33,8 +34,10 @@ int taskq_now;
 taskq_t *system_taskq;
 
 #defineTASKQ_ACTIVE0x0001
+#defineTASKQ_NAMELEN   31
 
 struct taskq {
+   chartq_name[TASKQ_NAMELEN + 1];
kmutex_ttq_lock;
krwlock_t   tq_threadlock;
kcondvar_t  tq_dispatch_cv;
@@ -247,6 +250,7 @@ taskq_create(const char *name, int nthre
cv_init(>tq_dispatch_cv, NULL, CV_DEFAULT, NULL);
cv_init(>tq_wait_cv, NULL, CV_DEFAULT, NULL);
cv_init(>tq_maxalloc_cv, NULL, CV_DEFAULT, NULL);
+   (void) strncpy(tq->tq_name, name, TASKQ_NAMELEN + 1);
tq->tq_flags = flags | TASKQ_ACTIVE;
tq->tq_active = nthreads;
tq->tq_nthreads = nthreads;

Modified: 
stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
Sun Mar 20 20:00:25 2016(r297077)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
Sun Mar 20 20:12:14 2016(r297078)
@@ -60,7 +60,7 @@ typedef int   vdev_open_func_t(vdev_t *vd,
 uint64_t *logical_ashift, uint64_t *physical_ashift);
 typedef void   vdev_close_func_t(vdev_t *vd);
 typedef uint64_t vdev_asize_func_t(vdev_t *vd, uint64_t psize);
-typedef intvdev_io_start_func_t(zio_t *zio);
+typedef void   vdev_io_start_func_t(zio_t *zio);
 typedef void   vdev_io_done_func_t(zio_t *zio);
 typedef void   vdev_state_change_func_t(vdev_t *vd, int, int);
 typedef void   vdev_hold_func_t(vdev_t *vd);

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h  Sun Mar 
20 20:00:25 2016(r297077)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h  Sun Mar 
20 20:12:14 2016(r297078)
@@ -150,9 +150,6 @@ enum zio_compress {
 #defineZIO_FAILURE_MODE_CONTINUE   1
 #defineZIO_FAILURE_MODE_PANIC  2
 
-#defineZIO_PIPELINE_CONTINUE   0x100
-#defineZIO_PIPELINE_STOP   0x101
-
 enum zio_flag {
/*
 * Flags inherited by gang, ddt, and vdev children,

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c
Sun Mar 20 20:00:25 2016(r297077)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c
Sun Mar 20 20:12:14 2016(r297078)
@@ -715,7 +715,7 @@ vdev_disk_ioctl_done(void *zio_arg, int 
zio_interrupt(zio);
 }
 
-static int
+static void
 vdev_disk_io_start(zio_t *zio)
 {
vdev_t *vd = zio->io_vd;
@@ -732,7 +732,7 @@ vdev_disk_io_start(zio_t *zio)
if (dvd == NULL || (dvd->vd_ldi_offline && dvd->vd_lh == NULL)) {
zio->io_error = SET_ERROR(ENXIO);
zio_interrupt(zio);
-   return (ZIO_PIPELINE_STOP);
+   return;
}
 
if (zio->io_type == ZIO_TYPE_IOCTL) {
@@ -740,7 +740,7 @@ 

svn commit: r297085 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 20:37:26 2016
New Revision: 297085
URL: https://svnweb.freebsd.org/changeset/base/297085

Log:
  MFC r274627 (by avg):
  Revert r269093 which introduced physical zio alignment transform
  
  Size of physical ZIOs must never be implicitly adjusted, it's
  a responsibility of a caller to make sure that such a ZIO has proper offset
  and size.
  
  Discussed with: delphij, gibbs

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c  Sun Mar 
20 20:33:03 2016(r297084)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c  Sun Mar 
20 20:37:26 2016(r297085)
@@ -2727,8 +2727,7 @@ zio_vdev_io_start(zio_t *zio)
 
align = 1ULL << vd->vdev_top->vdev_ashift;
 
-   if ((!(zio->io_flags & ZIO_FLAG_PHYSICAL) ||
-   (vd->vdev_top->vdev_physical_ashift > SPA_MINBLOCKSHIFT)) &&
+   if (!(zio->io_flags & ZIO_FLAG_PHYSICAL) &&
P2PHASE(zio->io_size, align) != 0) {
/* Transform logical writes to be a full physical block size. */
uint64_t asize = P2ROUNDUP(zio->io_size, align);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297073 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 19:07:12 2016
New Revision: 297073
URL: https://svnweb.freebsd.org/changeset/base/297073

Log:
  MFC r277492 (by will): Add vfs.zfs.reference_tracking_enable sysctl/tunable.
  
  This is primarily for developer/debugging use; it enables built-in tagged
  tracking of refcounts inside ZFS.  It can only be enabled from the loader,
  since it modifies how in-core state is managed.  Default remains disabled.

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c Sun Mar 
20 19:06:21 2016(r297072)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c Sun Mar 
20 19:07:12 2016(r297073)
@@ -30,6 +30,11 @@
 
 #ifdef _KERNEL
 int reference_tracking_enable = FALSE; /* runs out of memory too easily */
+SYSCTL_DECL(_vfs_zfs);
+TUNABLE_INT("vfs.zfs.reference_tracking_enable", _tracking_enable);
+SYSCTL_INT(_vfs_zfs, OID_AUTO, reference_tracking_enable, CTLFLAG_RDTUN,
+_tracking_enable, 0,
+"Track reference holders to refcount_t objects, used mostly by ZFS");
 #else
 int reference_tracking_enable = TRUE;
 #endif
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297079 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 20:20:37 2016
New Revision: 297079
URL: https://svnweb.freebsd.org/changeset/base/297079

Log:
  MFC r286223 (by smh): Fix KSTACK_PAGES check in ZFS module
  
  The check introduced by r285946 failed to add the dependency on
  opt_kstack_pages.h which meant the default value for the platform instead
  of the customised options KSTACK_PAGES=X was being tested.
  
  Also wrap in #ifdef __FreeBSD__ for portability.

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Sun Mar 20 20:12:14 2016(r297078)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Sun Mar 20 20:20:37 2016(r297079)
@@ -132,6 +132,9 @@
  * distinguish between the operation failing, and
  * deserialization failing.
  */
+#ifdef __FreeBSD__
+#include "opt_kstack_pages.h"
+#endif
 
 #include 
 #include 
@@ -6573,18 +6576,22 @@ static void zfs_shutdown(void *, int);
 
 static eventhandler_tag zfs_shutdown_event_tag;
 
+#ifdef __FreeBSD__
 #define ZFS_MIN_KSTACK_PAGES 4
+#endif
 
 int
 zfs__init(void)
 {
 
+#ifdef __FreeBSD__
 #if KSTACK_PAGES < ZFS_MIN_KSTACK_PAGES
printf("ZFS NOTICE: KSTACK_PAGES is %d which could result in stack "
"overflow panic!\nPlease consider adding "
"'options KSTACK_PAGES=%d' to your kernel config\n", KSTACK_PAGES,
ZFS_MIN_KSTACK_PAGES);
 #endif
+#endif
zfs_root_token = root_mount_hold("ZFS");
 
mutex_init(_share_lock, NULL, MUTEX_DEFAULT, NULL);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297074 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 19:11:17 2016
New Revision: 297074
URL: https://svnweb.freebsd.org/changeset/base/297074

Log:
  MFC r271788 (by will):
  Enable ZFS debug flags to be modified via vfs.zfs.debug_flags.
  
  This is primarily only of interest to ZFS developers, but it makes it
  easier to get additional debugging.
  
  MFSpectraBSD:   517074 on 2011/12/15 (by will), 662343 on 2013/03/20 (by 
gibbs)

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Sun Mar 
20 19:07:12 2016(r297073)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Sun Mar 
20 19:11:17 2016(r297074)
@@ -263,6 +263,33 @@ TUNABLE_INT("vfs.zfs.recover", _reco
 SYSCTL_INT(_vfs_zfs, OID_AUTO, recover, CTLFLAG_RWTUN, _recover, 0,
 "Try to recover from otherwise-fatal errors.");
 
+static int
+sysctl_vfs_zfs_debug_flags(SYSCTL_HANDLER_ARGS)
+{
+   int err, val;
+
+   val = zfs_flags;
+   err = sysctl_handle_int(oidp, , 0, req);
+   if (err != 0 || req->newptr == NULL)
+   return (err);
+
+   /*
+* ZFS_DEBUG_MODIFY must be enabled prior to boot so all
+* arc buffers in the system have the necessary additional
+* checksum data.  However, it is safe to disable at any
+* time.
+*/
+   if (!(zfs_flags & ZFS_DEBUG_MODIFY))
+   val &= ~ZFS_DEBUG_MODIFY;
+   zfs_flags = val;
+
+   return (0);
+}
+TUNABLE_INT("vfs.zfs.debug_flags", _flags);
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, debug_flags,
+CTLTYPE_UINT | CTLFLAG_MPSAFE | CTLFLAG_RW, 0, sizeof(int),
+sysctl_vfs_zfs_debug_flags, "IU", "Debug flags for ZFS testing.");
+
 /*
  * If destroy encounters an EIO while reading metadata (e.g. indirect
  * blocks), space referenced by the missing metadata can not be freed.
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297077 - in stable/10: cddl/contrib/opensolaris/cmd/dtrace cddl/contrib/opensolaris/cmd/lockstat cddl/contrib/opensolaris/cmd/mdb/tools/common cddl/contrib/opensolaris/cmd/plockstat cd...

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 20:00:25 2016
New Revision: 297077
URL: https://svnweb.freebsd.org/changeset/base/297077

Log:
  MFC r277300 (by smh): Mechanically convert cddl sun #ifdef's to illumos
  
  Since the upstream for cddl code is now illumos not sun, mechanically
  convert all sun #ifdef's to illumos #ifdef's which have been used in all
  newer code for some time.
  
  Also do a manual pass to correct the use if #ifdef comments as per style(9)
  as well as few uses of #if defined(__FreeBSD__) vs #ifndef illumos.

Modified:
  stable/10/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
  stable/10/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
  stable/10/cddl/contrib/opensolaris/cmd/lockstat/sym.c
  stable/10/cddl/contrib/opensolaris/cmd/mdb/tools/common/die.c
  stable/10/cddl/contrib/opensolaris/cmd/mdb/tools/common/util.h
  stable/10/cddl/contrib/opensolaris/cmd/plockstat/plockstat.c
  stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
  stable/10/cddl/contrib/opensolaris/common/util/strtolctype.h
  stable/10/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
  stable/10/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c
  stable/10/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c
  stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
  stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
  stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
  stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
  stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
  stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
  stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
  stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
  stable/10/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
  stable/10/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
  stable/10/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
  stable/10/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
  stable/10/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
  stable/10/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
  stable/10/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
  stable/10/cddl/contrib/opensolaris/tools/ctf/cvt/util.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
  

svn commit: r297081 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 20:25:36 2016
New Revision: 297081
URL: https://svnweb.freebsd.org/changeset/base/297081

Log:
  MFC r277503 (by will): Ignore sync requests from the system syncher,
  i.e. VFS_SYNC(waitfor=MNT_LAZY).
  
  ZFS already commits outstanding data every zfs_txg_timeout seconds, so these
  syncs are unnecessarily intrusive.
  
  MFSpectraBSD:   1105759 on 2014/12/11

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c   
Sun Mar 20 20:23:20 2016(r297080)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c   
Sun Mar 20 20:25:36 2016(r297081)
@@ -133,6 +133,13 @@ zfs_sync(vfs_t *vfsp, int waitfor)
if (panicstr)
return (0);
 
+   /*
+* Ignore the system syncher.  ZFS already commits async data
+* at zfs_txg_timeout intervals.
+*/
+   if (waitfor == MNT_LAZY)
+   return (0);
+
if (vfsp != NULL) {
/*
 * Sync a specific filesystem.
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297080 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 20:23:20 2016
New Revision: 297080
URL: https://svnweb.freebsd.org/changeset/base/297080

Log:
  MFC r277501 (by will): Eliminate an #ifdef illumos for zfs_ioc_rename().
  
  Since allow_mounted is a FreeBSD-specific change, default to B_TRUE, then
  locally check for the magic bit.  Unconditionally check allow_mounted below.
  Convert the setting of allow_mounted to an explicit boolean.
  
  MFSpectraBSD:   672578 (in part) on 2013/07/19

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Sun Mar 20 20:20:37 2016(r297079)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Sun Mar 20 20:23:20 2016(r297080)
@@ -3748,10 +3748,12 @@ static int
 zfs_ioc_rename(zfs_cmd_t *zc)
 {
boolean_t recursive = zc->zc_cookie & 1;
+   char *at;
+   boolean_t allow_mounted = B_TRUE;
+
 #ifdef __FreeBSD__
-   boolean_t allow_mounted = zc->zc_cookie & 2;
+   allow_mounted = (zc->zc_cookie & 2) != 0;
 #endif
-   char *at;
 
zc->zc_value[sizeof (zc->zc_value) - 1] = '\0';
if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
@@ -3766,11 +3768,7 @@ zfs_ioc_rename(zfs_cmd_t *zc)
if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1))
return (SET_ERROR(EXDEV));
*at = '\0';
-#ifdef illumos
-   if (zc->zc_objset_type == DMU_OST_ZFS) {
-#else
if (zc->zc_objset_type == DMU_OST_ZFS && allow_mounted) {
-#endif
error = dmu_objset_find(zc->zc_name,
recursive_unmount, at + 1,
recursive ? DS_FIND_CHILDREN : 0);
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297084 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 20:33:03 2016
New Revision: 297084
URL: https://svnweb.freebsd.org/changeset/base/297084

Log:
  MFV r258597 (by pjd):
  When append-only, immutable or read-only flag is set don't allow for
  hard links creation. This matches UFS behaviour.
  
  Reported by:Oleg Ginzburg 

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
Sun Mar 20 20:31:30 2016(r297083)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
Sun Mar 20 20:33:03 2016(r297084)
@@ -4402,6 +4402,11 @@ zfs_link(vnode_t *tdvp, vnode_t *svp, ch
szp = VTOZ(svp);
ZFS_VERIFY_ZP(szp);
 
+   if (szp->z_pflags & (ZFS_APPENDONLY | ZFS_IMMUTABLE | ZFS_READONLY)) {
+   ZFS_EXIT(zfsvfs);
+   return (SET_ERROR(EPERM));
+   }
+
/*
 * We check z_zfsvfs rather than v_vfsp here, because snapshots and the
 * ctldir appear to have the same v_vfsp.
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297090 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 23:43:26 2016
New Revision: 297090
URL: https://svnweb.freebsd.org/changeset/base/297090

Log:
  MFC r293677 (by asomers): Record physical path information in ZFS Vdevs
  
  sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c:
  If available, record the physical path of a vdev in ZFS meta-data.
  Do this both when opening the vdev, and when receiving an attribute
  change notification from GEOM.
  
  Make vdev_geom_close() synchronous instead of deferring its work to
  a GEOM event handler. There is no benefit to deferring the work and
  this prevents a future open call from referencing a consumer that is
  scheduled for destruction. The close followed by an immediate open
  will occur during a vdev reprobe triggered by any type of I/O error.
  
  Consolidate vdev_geom_close() and vdev_geom_detach() into
  vdev_geom_close() and vdev_geom_close_locked(). This also moves the
  cross linking operations between vdev and GEOM consumer into a
  single place (linking in vdev_geom_attach() and unlinking in
  vdev_geom_close_locked()).
  
  Differential Revision:  https://reviews.freebsd.org/D4524

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
Sun Mar 20 23:29:58 2016(r297089)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
Sun Mar 20 23:43:26 2016(r297090)
@@ -80,6 +80,9 @@ static void
 vdev_geom_attrchanged(struct g_consumer *cp, const char *attr)
 {
vdev_t *vd;
+   spa_t *spa;
+   char *physpath;
+   int error, physpath_len;
 
vd = cp->private;
if (vd == NULL)
@@ -89,6 +92,47 @@ vdev_geom_attrchanged(struct g_consumer 
vdev_geom_set_rotation_rate(vd, cp);
return;
}
+
+   if (strcmp(attr, "GEOM::physpath") != 0)
+   return;
+
+   if (g_access(cp, 1, 0, 0) != 0)
+   return;
+
+   /*
+* Record/Update physical path information for this device.
+*/
+   spa = vd->vdev_spa;
+   physpath_len = MAXPATHLEN;
+   physpath = g_malloc(physpath_len, M_WAITOK|M_ZERO);
+   error = g_io_getattr("GEOM::physpath", cp, _len, physpath);
+   g_access(cp, -1, 0, 0);
+   if (error == 0) {
+   char *old_physpath;
+
+   old_physpath = vd->vdev_physpath;
+   vd->vdev_physpath = spa_strdup(physpath);
+   spa_async_request(spa, SPA_ASYNC_CONFIG_UPDATE);
+
+   if (old_physpath != NULL) {
+   int held_lock;
+
+   held_lock = spa_config_held(spa, SCL_STATE, RW_WRITER);
+   if (held_lock == 0) {
+   g_topology_unlock();
+   spa_config_enter(spa, SCL_STATE, FTAG,
+   RW_WRITER);
+   }
+
+   spa_strfree(old_physpath);
+
+   if (held_lock == 0) {
+   spa_config_exit(spa, SCL_STATE, FTAG);
+   g_topology_lock();
+   }
+   }
+   }
+   g_free(physpath);
 }
 
 static void
@@ -99,8 +143,10 @@ vdev_geom_orphan(struct g_consumer *cp)
g_topology_assert();
 
vd = cp->private;
-   if (vd == NULL)
+   if (vd == NULL) {
+   /* Vdev close in progress.  Ignore the event. */
return;
+   }
 
/*
 * Orphan callbacks occur from the GEOM event thread.
@@ -121,7 +167,7 @@ vdev_geom_orphan(struct g_consumer *cp)
 }
 
 static struct g_consumer *
-vdev_geom_attach(struct g_provider *pp)
+vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
 {
struct g_geom *gp;
struct g_consumer *cp;
@@ -140,6 +186,7 @@ vdev_geom_attach(struct g_provider *pp)
if (gp == NULL) {
gp = g_new_geomf(_vdev_class, "zfs::vdev");
gp->orphan = vdev_geom_orphan;
+   gp->attrchanged = vdev_geom_attrchanged;
cp = g_new_consumer(gp);
if (g_attach(cp, pp) != 0) {
g_wither_geom(gp, ENXIO);
@@ -176,28 +223,56 @@ vdev_geom_attach(struct g_provider *pp)
ZFS_LOG(1, "Used existing consumer for %s.", pp->name);
}
}
+
+   /* 
+* BUG: cp may already belong to a vdev.  This could happen if:
+* 1) That vdev is a shared spare, or
+* 2) We are trying to reopen a missing vdev and we are scanning by
+*guid.  In that case, we'll 

svn commit: r297092 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 23:49:58 2016
New Revision: 297092
URL: https://svnweb.freebsd.org/changeset/base/297092

Log:
  MFC r294794: MFV r294793:
  6367 spa_config_tryenter incorrectly handles the multiple-lock case
  
  Reviewed by: Alek Pinchuk 
  Reviewed by: Josef 'Jeff' Sipek 
  Reviewed by: Prashanth Sreenivasa 
  Reviewed by: Matthew Ahrens 
  Reviewed by: Dan McDonald 
  Reviewed by: Steven Hartland 
  Approved by: Matthew Ahrens 
  
  illumos/illumos-gate@e495b6e6735b803e422025a630352ef9bba788c5

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Sun Mar 
20 23:48:26 2016(r297091)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Sun Mar 
20 23:49:58 2016(r297092)
@@ -21,7 +21,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  * Copyright 2013 Martin Matuska . All rights reserved.
  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
  * Copyright 2013 Saso Kiselkov. All rights reserved.
@@ -459,14 +459,16 @@ spa_config_tryenter(spa_t *spa, int lock
if (rw == RW_READER) {
if (scl->scl_writer || scl->scl_write_wanted) {
mutex_exit(>scl_lock);
-   spa_config_exit(spa, locks ^ (1 << i), tag);
+   spa_config_exit(spa, locks & ((1 << i) - 1),
+   tag);
return (0);
}
} else {
ASSERT(scl->scl_writer != curthread);
if (!refcount_is_zero(>scl_count)) {
mutex_exit(>scl_lock);
-   spa_config_exit(spa, locks ^ (1 << i), tag);
+   spa_config_exit(spa, locks & ((1 << i) - 1),
+   tag);
return (0);
}
scl->scl_writer = curthread;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


svn commit: r297093 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2016-03-20 Thread Alexander Motin
Author: mav
Date: Sun Mar 20 23:51:11 2016
New Revision: 297093
URL: https://svnweb.freebsd.org/changeset/base/297093

Log:
  MFC r294797: MFV r294796:
  6319 assertion failed in zio_ddt_write: bp->blk_birth == txg
  
  Reviewed by: George Wilson 
  Approved by: Dan McDonald 
  
  illumos/illumos-gate@b39b744be78c6327db43c1f69d11c2f5909f73cb
  
  This is revert of 5693.

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
==
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c  Sun Mar 
20 23:49:58 2016(r297092)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c  Sun Mar 
20 23:51:11 2016(r297093)
@@ -1222,6 +1222,8 @@ zio_write_bp_init(zio_t *zio)
zio->io_pipeline |= ZIO_STAGE_DDT_WRITE;
return (ZIO_PIPELINE_CONTINUE);
}
+   zio->io_bp_override = NULL;
+   BP_ZERO(bp);
}
 
if (!BP_IS_HOLE(bp) && bp->blk_birth == zio->io_txg) {
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"


<    1   2   3   4   5   6   7   >