Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Oct 2014 17:52:54 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r272947 - head/sys/cam/ctl
Message-ID:  <201410111752.s9BHqsxD095729@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Oct 11 17:52:54 2014
New Revision: 272947
URL: https://svnweb.freebsd.org/changeset/base/272947

Log:
  Give physical and virtual ports numbers some more meaning.

Modified:
  head/sys/cam/ctl/ctl_frontend_iscsi.c
  head/sys/cam/ctl/ctl_frontend_iscsi.h
  head/sys/cam/ctl/scsi_ctl.c

Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend_iscsi.c	Sat Oct 11 17:49:51 2014	(r272946)
+++ head/sys/cam/ctl/ctl_frontend_iscsi.c	Sat Oct 11 17:52:54 2014	(r272947)
@@ -1996,7 +1996,8 @@ cfiscsi_ioctl_port_create(struct ctl_req
 	/* XXX KDM what should the real number be here? */
 	port->num_requested_ctl_io = 4096;
 	port->port_name = "iscsi";
-	port->virtual_port = strtoul(tag, NULL, 0);
+	port->physical_port = strtoul(tag, NULL, 0);
+	port->virtual_port = ct->ct_target_id;
 	port->port_online = cfiscsi_online;
 	port->port_offline = cfiscsi_offline;
 	port->port_info = cfiscsi_info;
@@ -2029,7 +2030,7 @@ cfiscsi_ioctl_port_create(struct ctl_req
 	    SVPD_ID_TYPE_SCSI_NAME;
 	desc->length = idlen;
 	snprintf(desc->identifier, idlen, "%s,t,0x%4.4x",
-	    target, port->virtual_port);
+	    target, port->physical_port);
 
 	/* Generate Target ID. */
 	idlen = strlen(target) + 1;
@@ -2257,6 +2258,9 @@ cfiscsi_target_find_or_create(struct cfi
 		strlcpy(newct->ct_alias, alias, sizeof(newct->ct_alias));
 	refcount_init(&newct->ct_refcount, 1);
 	newct->ct_softc = softc;
+	if (TAILQ_EMPTY(&softc->targets))
+		softc->last_target_id = 0;
+	newct->ct_target_id = ++softc->last_target_id;
 	TAILQ_INSERT_TAIL(&softc->targets, newct, ct_next);
 	mtx_unlock(&softc->lock);
 

Modified: head/sys/cam/ctl/ctl_frontend_iscsi.h
==============================================================================
--- head/sys/cam/ctl/ctl_frontend_iscsi.h	Sat Oct 11 17:49:51 2014	(r272946)
+++ head/sys/cam/ctl/ctl_frontend_iscsi.h	Sat Oct 11 17:52:54 2014	(r272947)
@@ -45,6 +45,7 @@ struct cfiscsi_target {
 	char				ct_alias[CTL_ISCSI_ALIAS_LEN];
 	int				ct_state;
 	int				ct_online;
+	int				ct_target_id;
 	struct ctl_port			ct_port;
 };
 
@@ -110,6 +111,7 @@ struct cfiscsi_softc {
 	struct mtx			lock;
 	char				port_name[32];
 	int				online;
+	int				last_target_id;
 	unsigned int			last_session_id;
 	TAILQ_HEAD(, cfiscsi_target)	targets;
 	TAILQ_HEAD(, cfiscsi_session)	sessions;

Modified: head/sys/cam/ctl/scsi_ctl.c
==============================================================================
--- head/sys/cam/ctl/scsi_ctl.c	Sat Oct 11 17:49:51 2014	(r272946)
+++ head/sys/cam/ctl/scsi_ctl.c	Sat Oct 11 17:52:54 2014	(r272947)
@@ -400,8 +400,8 @@ ctlfeasync(void *callback_arg, uint32_t 
 		 * frontend structure itself.
 	 	 */
 		port->port_name = softc->port_name;
-		port->physical_port = cpi->unit_number;
-		port->virtual_port = cpi->bus_id;
+		port->physical_port = cpi->bus_id;
+		port->virtual_port = 0;
 		port->port_online = ctlfe_online;
 		port->port_offline = ctlfe_offline;
 		port->onoff_arg = softc;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410111752.s9BHqsxD095729>