patch-2.2.13 linux/drivers/scsi/qlogicfc.c

Next file: linux/drivers/scsi/qlogicfc_asm.c
Previous file: linux/drivers/scsi/pluto.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.12/linux/drivers/scsi/qlogicfc.c linux/drivers/scsi/qlogicfc.c
@@ -629,13 +629,15 @@
 #define QLOGICFC_MAX_ID    0x7d
 #endif
 
-#define QLOGICFC_MAX_LOOP_ID 0x7d
+#define QLOGICFC_MAX_LUN	128
+#define QLOGICFC_MAX_LOOP_ID 	0x7d
 
 /* adapter_state values */
 #define AS_FIRMWARE_DEAD      -1
 #define AS_LOOP_DOWN           0
 #define AS_LOOP_GOOD           1
-#define AS_REDO_PORTDB         2
+#define AS_REDO_FABRIC_PORTDB  2
+#define AS_REDO_LOOP_PORTDB    4
 
 struct isp2x00_hostdata {
 	u_char revision;
@@ -743,6 +745,7 @@
 
 		        host = scsi_register(tmpt, sizeof(struct isp2x00_hostdata));
 			host->max_id = QLOGICFC_MAX_ID + 1;
+			host->max_lun = QLOGICFC_MAX_LUN;
 			host->hostt->use_new_eh_code = 1;
 			hostdata = (struct isp2x00_hostdata *) host->hostdata;
 
@@ -965,30 +968,31 @@
 	}
 	printk("qlogicfc%d : Fabric found.\n", hostdata->host_id);
 
-
-	memset(&req, 0, sizeof(req));
-	
-	req.len = 8;
-	req.response_low = virt_to_bus_low32(sns_response);
-	req.response_high = virt_to_bus_high32(sns_response);
-	req.sub_len = 22;
-	req.data[0] = 0x17;
-	req.data[1] = 0x02;
-	req.data[8] = (u_char) (hostdata->port_id & 0xff);
-	req.data[9] = (u_char) (hostdata->port_id >> 8 & 0xff);
-	req.data[10] = (u_char) (hostdata->port_id >> 16 & 0xff);
-	req.data[13] = 0x01;
-	param[0] = MBOX_SEND_SNS;
-	param[1] = 30;
-	param[2] = virt_to_bus_low32(&req) >> 16;
-	param[3] = virt_to_bus_low32(&req);
-	param[6] = virt_to_bus_high32(&req) >> 16;
-	param[7] = virt_to_bus_high32(&req);
+	if (hostdata->adapter_state & AS_REDO_LOOP_PORTDB){
+	        memset(&req, 0, sizeof(req));
 	
-	isp2x00_mbox_command(host, param);
+		req.len = 8;
+		req.response_low = virt_to_bus_low32(sns_response);
+		req.response_high = virt_to_bus_high32(sns_response);
+		req.sub_len = 22;
+		req.data[0] = 0x17;
+		req.data[1] = 0x02;
+		req.data[8] = (u_char) (hostdata->port_id & 0xff);
+		req.data[9] = (u_char) (hostdata->port_id >> 8 & 0xff);
+		req.data[10] = (u_char) (hostdata->port_id >> 16 & 0xff);
+		req.data[13] = 0x01;
+		param[0] = MBOX_SEND_SNS;
+		param[1] = 30;
+		param[2] = virt_to_bus_low32(&req) >> 16;
+		param[3] = virt_to_bus_low32(&req);
+		param[6] = virt_to_bus_high32(&req) >> 16;
+		param[7] = virt_to_bus_high32(&req);
+		
+		isp2x00_mbox_command(host, param);
 	
-	if (param[0] != MBOX_COMMAND_COMPLETE)
-	        printk("qlogicfc%d : error sending RFC-4\n", hostdata->host_id);	       
+		if (param[0] != MBOX_COMMAND_COMPLETE)
+		        printk("qlogicfc%d : error sending RFC-4\n", hostdata->host_id);	       
+	}
 
 	port_id = hostdata->port_id;
 	while (!done) {
@@ -1131,9 +1135,9 @@
 
 	DEBUG(isp2x00_print_scsi_cmd(Cmnd));
 
-	if (hostdata->adapter_state == AS_REDO_PORTDB) {
-		hostdata->adapter_state = AS_LOOP_GOOD;
+	if (hostdata->adapter_state & AS_REDO_FABRIC_PORTDB || hostdata->adapter_state & AS_REDO_LOOP_PORTDB) {
 		isp2x00_make_portdb(host);
+		hostdata->adapter_state = AS_LOOP_GOOD;
 		printk("qlogicfc%d : Port Database\n", hostdata->host_id);
 		for (i = 0; hostdata->port_db[i].wwn != 0; i++) {
 			printk("wwn: %08x%08x  scsi_id: %x  loop_id: %x\n", (u_int) (hostdata->port_db[i].wwn >> 32), (u_int) hostdata->port_db[i].wwn, i, hostdata->port_db[i].loop_id);
@@ -1270,6 +1274,9 @@
 	}
 
 	switch (Cmnd->cmnd[0]) {
+	case TEST_UNIT_READY:
+	case START_STOP:
+	        break;
 	case WRITE_10:
 	case WRITE_6:
 	case WRITE_BUFFER:
@@ -1378,7 +1385,7 @@
 		case LOOP_UP:
 		case POINT_TO_POINT_UP:
 		        printk("qlogicfc%d : link is up\n", hostdata->host_id);
-			hostdata->adapter_state = AS_REDO_PORTDB;
+			hostdata->adapter_state = AS_REDO_FABRIC_PORTDB | AS_REDO_LOOP_PORTDB;
 			break;
 		case LOOP_DOWN:
 		        printk("qlogicfc%d : link is down\n", hostdata->host_id);
@@ -1387,12 +1394,15 @@
 		case CONNECTION_MODE:
 		        printk("received CONNECTION_MODE irq %x\n", inw(host->io_port + MBOX1));
 			break;
-		case LIP_OCCURED:
 		case CHANGE_NOTIFICATION:
+			if (hostdata->adapter_state == AS_LOOP_GOOD)
+				hostdata->adapter_state = AS_REDO_FABRIC_PORTDB;
+			break;		        
+		case LIP_OCCURED:
 		case PORT_DB_CHANGED:
 		case LIP_RECEIVED:
 			if (hostdata->adapter_state == AS_LOOP_GOOD)
-				hostdata->adapter_state = AS_REDO_PORTDB;
+				hostdata->adapter_state = AS_REDO_LOOP_PORTDB;
 			break;
 		case SYSTEM_ERROR:
 			printk("qlogicfc%d : The firmware just choked.\n", hostdata->host_id);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)