[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-101-g2616afb

Mike Christie michaelc at cs.wisc.edu
Mon May 2 18:56:45 UTC 2011


The following commit has been merged in the upstream-mnc branch:
commit ee115be828362653478e6fe7cd4c6ee3318223ff
Author: Mike Christie <michaelc at cs.wisc.edu>
Date:   Mon Apr 18 12:37:30 2011 -0500

    iscsi tools: fix bnx2i boot due to MAC mismatch
    
    The problem is current bnx2i boot firmware has 2 modes.
    
    1. hba mode - Will export the iscsi MAC in ibft.
    2. non hba mode - Will export the network MAC in ibft.
    
    [In both modes there should be a sysfs link to the network
    netdev from the ibft ethernet dir]
    
    For #1 we want to create a session using bnx2i. For #2 we want to use
    software iscsi (we can only use software iscsi since we do not know the
    MAC for the offload card).
    
    This patch fixes a bug where we would create a iscsi session using the
    offload card if the netdev that is found through the ibft sysfs tree was
    managed by a net driver that has a iscsi offload driver. With this patch
    we now determine if we use the offload card during boot based on if
    the /sys/class/iscsi_host/hostX/hwaddres matches the one in iBFT. If
    it does, then we know the iBFT MAC is the iscsi one and use the offload
    driver.
    
    Note that cxgb*i always uses 1 MAC for both iscsi and offload. So
    for that driver we always use offload. To get the netdev we follow
    the sysfs ethernet link to the netdev like is done with bnx2i.

diff --git a/usr/iface.c b/usr/iface.c
index 8a1683b..b10a1d4 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -788,42 +788,55 @@ void iface_link_ifaces(struct list_head *ifaces)
 int iface_setup_from_boot_context(struct iface_rec *iface,
 				   struct boot_context *context)
 {
+	struct iscsi_transport *t;
+	uint32_t hostno;
+	int rc;
+
 	if (strlen(context->initiatorname))
 		strlcpy(iface->iname, context->initiatorname,
 			sizeof(iface->iname));
 
 	if (strlen(context->scsi_host_name)) {
-		struct iscsi_transport *t;
-		uint32_t hostno;
-
 		if (sscanf(context->scsi_host_name, "iscsi_boot%u", &hostno) != 		    1) {
 			log_error("Could not parse %s's host no.",
 				  context->scsi_host_name);
 			return 0;
 		}
-		t = iscsi_sysfs_get_transport_by_hba(hostno);
-		if (!t) {
-			log_error("Could not get transport for %s. "
-				  "Make sure the iSCSI driver is loaded.",
-				  context->scsi_host_name);
+	} else if (strlen(context->iface)) {
+/* this ifdef is only temp until distros and firmwares are updated */
+#ifdef OFFLOAD_BOOT_SUPPORTED
+		hostno = iscsi_sysfs_get_host_no_from_hwaddress(context->mac,
+								&rc);
+		if (rc) {
+			/*
+			 * If the MAC in the boot info does not match a iscsi
+			 * host then the MAC must be for network card, so boot
+			 * is not going to be offloaded.
+			 */
+			log_debug(3, "Could not match %s to host\n",
+				  context->mac);
 			return 0;
 		}
 
-		log_debug(3, "boot context has %s transport %s",
-			  context->scsi_host_name, t->name);
-		strcpy(iface->transport_name, t->name);
-	} else if (strlen(context->iface) &&
-		 (!net_get_transport_name_from_netdev(context->iface,
-						iface->transport_name))) {
-		log_debug(3, "boot context has netdev %s",
-			  context->iface);
-		strlcpy(iface->netdev, context->iface,
-			sizeof(iface->netdev));
+		strlcpy(iface->netdev, context->iface, sizeof(iface->netdev));
+#else
+		return 0;
+#endif
 	} else
 		return 0;
+
 	/*
 	 * set up for access through a offload card.
 	 */
+	t = iscsi_sysfs_get_transport_by_hba(hostno);
+	if (!t) {
+		log_error("Could not get transport for host%u. "
+			  "Make sure the iSCSI driver is loaded.",
+			  hostno);
+		return 0;
+	}
+	strcpy(iface->transport_name, t->name);
+
 	memset(iface->name, 0, sizeof(iface->name));
 	snprintf(iface->name, sizeof(iface->name), "%s.%s",
 		 iface->transport_name, context->mac);
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index 7f66861..e82fe80 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -332,7 +332,7 @@ static int __get_host_no_from_hwaddress(void *data, struct host_info *info)
 	return 0;
 }
 
-static uint32_t get_host_no_from_hwaddress(char *address, int *rc)
+uint32_t iscsi_sysfs_get_host_no_from_hwaddress(char *hwaddress, int *rc)
 {
 	uint32_t host_no = -1;
 	struct host_info *info;
@@ -345,7 +345,7 @@ static uint32_t get_host_no_from_hwaddress(char *address, int *rc)
 		*rc = ISCSI_ERR_NOMEM;
 		return -1;
 	}
-	strcpy(info->iface.hwaddress, address);
+	strcpy(info->iface.hwaddress, hwaddress);
 
 	local_rc = iscsi_sysfs_for_each_host(info, &nr_found,
 					__get_host_no_from_hwaddress);
@@ -401,7 +401,8 @@ uint32_t iscsi_sysfs_get_host_no_from_hwinfo(struct iface_rec *iface, int *rc)
 
 	if (strlen(iface->hwaddress) &&
 	    strcasecmp(iface->hwaddress, DEFAULT_HWADDRESS))
-		host_no = get_host_no_from_hwaddress(iface->hwaddress, &tmp_rc);
+		host_no = iscsi_sysfs_get_host_no_from_hwaddress(
+						iface->hwaddress, &tmp_rc);
 	else if (strlen(iface->netdev) &&
 		strcasecmp(iface->netdev, DEFAULT_NETDEV))
 		host_no = get_host_no_from_netdev(iface->netdev, &tmp_rc);
diff --git a/usr/iscsi_sysfs.h b/usr/iscsi_sysfs.h
index 4afec64..3195c89 100644
--- a/usr/iscsi_sysfs.h
+++ b/usr/iscsi_sysfs.h
@@ -51,6 +51,7 @@ extern int iscsi_sysfs_for_each_host(void *data, int *nr_found,
 extern uint32_t iscsi_sysfs_get_host_no_from_sid(uint32_t sid, int *err);
 extern uint32_t iscsi_sysfs_get_host_no_from_hwinfo(struct iface_rec *iface,
 						    int *rc);
+extern uint32_t iscsi_sysfs_get_host_no_from_hwaddress(char *hwaddress, int *rc);
 extern int iscsi_sysfs_get_hostinfo_by_host_no(struct host_info *hinfo);
 extern int iscsi_sysfs_get_sid_from_path(char *session);
 extern char *iscsi_sysfs_get_blockdev_from_lun(int hostno, int target, int sid);

-- 
Debian Open-iSCSI Packaging



More information about the Pkg-iscsi-maintainers mailing list