All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Vasquez <andrew.vasquez@qlogic.com>
To: James Bottomley <James.Bottomley@SteelEye.com>
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH] qla2xxx - perform proper SNS scans with ISP2200 HBAs. [1/3] (Resend)
Date: Tue, 27 Jan 2004 14:35:25 -0800	[thread overview]
Message-ID: <1075242925.6053.67.camel@dieplab1> (raw)

[-- Attachment #1: Type: text/plain, Size: 392 bytes --]

James,

The 2200 firmware doesn't support the MS IOCB interface the driver 
uses to issue CT commands to the SNS.  Basically, I had to 
forward-port some code from the 6.x driver to get the SNS calls 
to go through.  I've had several machines (mixture of 2200s/
2300s/others with loop and fabric connections) running with this
patch for the past week.

Please apply.

Regards,
Andrew Vasquez

[-- Attachment #2: QL3_sns_fix_2200-262rc2.diff --]
[-- Type: application/octet-stream, Size: 22904 bytes --]

diff -Nurd -X /root/Drivers/8.x/dontdiff-bk linux-2.6.2-rc2/drivers/scsi/qla2xxx-orig/qla_def.h linux-2.6.2-rc2/drivers/scsi/qla2xxx/qla_def.h
--- linux-2.6.2-rc2/drivers/scsi/qla2xxx-orig/qla_def.h	2004-01-22 08:45:20.023352632 -0800
+++ linux-2.6.2-rc2/drivers/scsi/qla2xxx/qla_def.h	2004-01-22 08:46:09.316858880 -0800
@@ -1890,6 +1890,60 @@
 	} p;
 };
 
+/*
+ * SNS command structures -- for 2200 compatability.
+ */
+#define	RFT_ID_SNS_SCMD_LEN	22
+#define	RFT_ID_SNS_CMD_SIZE	60
+#define	RFT_ID_SNS_DATA_SIZE	16
+
+#define	RFF_ID_SNS_SCMD_LEN	8
+#define	RFF_ID_SNS_CMD_SIZE	32
+#define	RFF_ID_SNS_DATA_SIZE	16
+
+#define	RNN_ID_SNS_SCMD_LEN	10
+#define	RNN_ID_SNS_CMD_SIZE	36
+#define	RNN_ID_SNS_DATA_SIZE	16
+
+#define	GA_NXT_SNS_SCMD_LEN	6
+#define	GA_NXT_SNS_CMD_SIZE	28
+#define	GA_NXT_SNS_DATA_SIZE	(620 + 16)
+
+#define	GID_PT_SNS_SCMD_LEN	6
+#define	GID_PT_SNS_CMD_SIZE	28
+#define	GID_PT_SNS_DATA_SIZE	(MAX_FIBRE_DEVICES * 4 + 16)
+
+#define	GPN_ID_SNS_SCMD_LEN	6
+#define	GPN_ID_SNS_CMD_SIZE	28
+#define	GPN_ID_SNS_DATA_SIZE	(8 + 16)
+
+#define	GNN_ID_SNS_SCMD_LEN	6
+#define	GNN_ID_SNS_CMD_SIZE	28
+#define	GNN_ID_SNS_DATA_SIZE	(8 + 16)
+
+struct sns_cmd_pkt {
+	union {
+		struct {
+			uint16_t buffer_length;
+			uint16_t reserved_1;
+			uint32_t buffer_address[2];
+			uint16_t subcommand_length;
+			uint16_t reserved_2;
+			uint16_t subcommand;
+			uint16_t size;
+			uint32_t reserved_3;
+			uint8_t param[36];
+		} cmd;
+
+		uint8_t rft_data[RFT_ID_SNS_DATA_SIZE];
+		uint8_t rff_data[RFF_ID_SNS_DATA_SIZE];
+		uint8_t rnn_data[RNN_ID_SNS_DATA_SIZE];
+		uint8_t gan_data[GA_NXT_SNS_DATA_SIZE];
+		uint8_t gid_data[GID_PT_SNS_DATA_SIZE];
+		uint8_t gpn_data[GPN_ID_SNS_DATA_SIZE];
+		uint8_t gnn_data[GNN_ID_SNS_DATA_SIZE];
+	} p;
+};
 
 /* IO descriptors */
 #define MAX_IO_DESCRIPTORS	32
@@ -2164,10 +2218,14 @@
 	uint8_t rscn_in_ptr;
 	uint8_t rscn_out_ptr;
 
+	/* SNS command interfaces. */
 	ms_iocb_entry_t		*ms_iocb;
 	dma_addr_t		ms_iocb_dma;
 	struct ct_sns_pkt	*ct_sns;
 	dma_addr_t		ct_sns_dma;
+	/* SNS command interfaces for 2200. */
+	struct sns_cmd_pkt	*sns_cmd;
+	dma_addr_t		sns_cmd_dma;
 
 	pid_t			dpc_pid;
 	int			dpc_should_die;
diff -Nurd -X /root/Drivers/8.x/dontdiff-bk linux-2.6.2-rc2/drivers/scsi/qla2xxx-orig/qla_gs.c linux-2.6.2-rc2/drivers/scsi/qla2xxx/qla_gs.c
--- linux-2.6.2-rc2/drivers/scsi/qla2xxx-orig/qla_gs.c	2004-01-22 08:45:20.024352480 -0800
+++ linux-2.6.2-rc2/drivers/scsi/qla2xxx/qla_gs.c	2004-01-22 08:46:09.320858272 -0800
@@ -31,6 +31,17 @@
 static inline struct ct_sns_req *
 qla2x00_prep_ct_req(struct ct_sns_req *, uint16_t, uint16_t);
 
+static inline struct sns_cmd_pkt *
+qla2x00_prep_sns_cmd(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t);
+
+static int qla2x00_sns_ga_nxt(scsi_qla_host_t *, fc_port_t *);
+static int qla2x00_sns_gid_pt(scsi_qla_host_t *, sw_info_t *);
+static int qla2x00_sns_gpn_id(scsi_qla_host_t *, sw_info_t *);
+static int qla2x00_sns_gnn_id(scsi_qla_host_t *, sw_info_t *);
+static int qla2x00_sns_rft_id(scsi_qla_host_t *);
+static int qla2x00_sns_rff_id(scsi_qla_host_t *);
+static int qla2x00_sns_rnn_id(scsi_qla_host_t *);
+
 /**
  * qla2x00_prep_ms_iocb() - Prepare common MS IOCB fields for SNS CT query.
  * @ha: HA context
@@ -90,6 +101,7 @@
 	return (ct_req);
 }
 
+
 /**
  * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
  * @ha: HA context
@@ -106,6 +118,10 @@
 	struct ct_sns_req	*ct_req;
 	struct ct_sns_rsp	*ct_rsp;
 
+	if (IS_QLA2200(ha)) {
+		return (qla2x00_sns_ga_nxt(ha, fcport));
+	}
+
 	/* Issue GA_NXT */
 	/* Prepare common MS IOCB */
 	ms_pkt = qla2x00_prep_ms_iocb(ha, GA_NXT_REQ_SIZE, GA_NXT_RSP_SIZE);
@@ -190,6 +206,10 @@
 
 	struct ct_sns_gid_pt_data *gid_data;
 
+	if (IS_QLA2200(ha)) {
+		return (qla2x00_sns_gid_pt(ha, list));
+	}
+
 	gid_data = NULL;
 
 	/* Issue GID_PT */
@@ -263,6 +283,10 @@
 	struct ct_sns_req	*ct_req;
 	struct ct_sns_rsp	*ct_rsp;
 
+	if (IS_QLA2200(ha)) {
+		return (qla2x00_sns_gpn_id(ha, list));
+	}
+
 	for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
 		/* Issue GPN_ID */
 		/* Prepare common MS IOCB */
@@ -308,7 +332,7 @@
 }
 
 /**
- * qla2x00_gnn_id() - SNS Get Node Name (GPN_ID) query.
+ * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query.
  * @ha: HA context
  * @list: switch info entries to populate
  *
@@ -324,6 +348,10 @@
 	struct ct_sns_req	*ct_req;
 	struct ct_sns_rsp	*ct_rsp;
 
+	if (IS_QLA2200(ha)) {
+		return (qla2x00_sns_gnn_id(ha, list));
+	}
+
 	for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
 		/* Issue GNN_ID */
 		/* Prepare common MS IOCB */
@@ -462,6 +490,10 @@
 	struct ct_sns_req	*ct_req;
 	struct ct_sns_rsp	*ct_rsp;
 
+	if (IS_QLA2200(ha)) {
+		return (qla2x00_sns_rft_id(ha));
+	}
+
 	/* Issue RFT_ID */
 	/* Prepare common MS IOCB */
 	ms_pkt = qla2x00_prep_ms_iocb(ha, RFT_ID_REQ_SIZE, RFT_ID_RSP_SIZE);
@@ -516,6 +548,10 @@
 	struct ct_sns_req	*ct_req;
 	struct ct_sns_rsp	*ct_rsp;
 
+	if (IS_QLA2200(ha)) {
+		return (qla2x00_sns_rff_id(ha));
+	}
+
 	/* Issue RFF_ID */
 	/* Prepare common MS IOCB */
 	ms_pkt = qla2x00_prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE);
@@ -569,6 +605,10 @@
 	struct ct_sns_req	*ct_req;
 	struct ct_sns_rsp	*ct_rsp;
 
+	if (IS_QLA2200(ha)) {
+		return (qla2x00_sns_rnn_id(ha));
+	}
+
 	/* Issue RNN_ID */
 	/* Prepare common MS IOCB */
 	ms_pkt = qla2x00_prep_ms_iocb(ha, RNN_ID_REQ_SIZE, RNN_ID_RSP_SIZE);
@@ -624,6 +664,12 @@
 	struct ct_sns_req	*ct_req;
 	struct ct_sns_rsp	*ct_rsp;
 
+	if (IS_QLA2200(ha)) {
+		DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on "
+		    "ISP2200.\n", ha->host_no));
+		return (QLA_SUCCESS);
+	}
+
 	/* Issue RSNN_NN */
 	/* Prepare common MS IOCB */
 	/*   Request size adjusted after CT preparation */
@@ -679,3 +725,454 @@
 
 	return (rval);
 }
+
+
+/**
+ * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query.
+ * @ha: HA context
+ * @cmd: GS command
+ * @scmd_len: Subcommand length
+ * @data_size: response size in bytes
+ *
+ * Returns a pointer to the @ha's sns_cmd.
+ */
+static inline struct sns_cmd_pkt *
+qla2x00_prep_sns_cmd(scsi_qla_host_t *ha, uint16_t cmd, uint16_t scmd_len,
+    uint16_t data_size)
+{
+	uint16_t		wc;
+	struct sns_cmd_pkt	*sns_cmd;
+
+	sns_cmd = ha->sns_cmd;
+	memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt));
+	wc = data_size / 2;			/* Size in 16bit words. */
+	sns_cmd->p.cmd.buffer_length = cpu_to_le16(wc);
+	sns_cmd->p.cmd.buffer_address[0] = cpu_to_le32(LSD(ha->sns_cmd_dma));
+	sns_cmd->p.cmd.buffer_address[1] = cpu_to_le32(MSD(ha->sns_cmd_dma));
+	sns_cmd->p.cmd.subcommand_length = cpu_to_le16(scmd_len);
+	sns_cmd->p.cmd.subcommand = cpu_to_le16(cmd);
+	wc = (data_size - 16) / 4;		/* Size in 32bit words. */
+	sns_cmd->p.cmd.size = cpu_to_le16(wc);
+
+	return (sns_cmd);
+}
+
+/**
+ * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
+ * @ha: HA context
+ * @fcport: fcport entry to updated
+ *
+ * This command uses the old Exectute SNS Command mailbox routine.
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_sns_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
+{
+	int		rval;
+
+	struct sns_cmd_pkt	*sns_cmd;
+
+	/* Issue GA_NXT. */
+	/* Prepare SNS command request. */
+	sns_cmd = qla2x00_prep_sns_cmd(ha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN,
+	    GA_NXT_SNS_DATA_SIZE);
+
+	/* Prepare SNS command arguments -- port_id. */
+	sns_cmd->p.cmd.param[0] = fcport->d_id.b.al_pa;
+	sns_cmd->p.cmd.param[1] = fcport->d_id.b.area;
+	sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain;
+
+	/* Execute SNS command. */
+	rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2,
+	    sizeof(struct sns_cmd_pkt));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (sns_cmd->p.gan_data[8] != 0x80 ||
+	    sns_cmd->p.gan_data[9] != 0x02) {
+		DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, "
+		    "ga_nxt_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gan_data, 16));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		/* Populate fc_port_t entry. */
+		fcport->d_id.b.domain = sns_cmd->p.gan_data[17];
+		fcport->d_id.b.area = sns_cmd->p.gan_data[18];
+		fcport->d_id.b.al_pa = sns_cmd->p.gan_data[19];
+
+		memcpy(fcport->node_name, &sns_cmd->p.gan_data[284], WWN_SIZE);
+		memcpy(fcport->port_name, &sns_cmd->p.gan_data[20], WWN_SIZE);
+
+		if (sns_cmd->p.gan_data[16] != NS_N_PORT_TYPE &&
+		    sns_cmd->p.gan_data[16] != NS_NL_PORT_TYPE)
+			fcport->d_id.b.domain = 0xf0;
+
+		DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
+		    "nn %02x%02x%02x%02x%02x%02x%02x%02x "
+		    "pn %02x%02x%02x%02x%02x%02x%02x%02x "
+		    "portid=%02x%02x%02x.\n",
+		    ha->host_no,
+		    fcport->node_name[0], fcport->node_name[1],
+		    fcport->node_name[2], fcport->node_name[3],
+		    fcport->node_name[4], fcport->node_name[5],
+		    fcport->node_name[6], fcport->node_name[7],
+		    fcport->port_name[0], fcport->port_name[1],
+		    fcport->port_name[2], fcport->port_name[3],
+		    fcport->port_name[4], fcport->port_name[5],
+		    fcport->port_name[6], fcport->port_name[7],
+		    fcport->d_id.b.domain, fcport->d_id.b.area,
+		    fcport->d_id.b.al_pa));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command.
+ * @ha: HA context
+ * @list: switch info entries to populate
+ *
+ * This command uses the old Exectute SNS Command mailbox routine.
+ *
+ * NOTE: Non-Nx_Ports are not requested.
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_sns_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
+{
+	int		rval;
+
+	uint16_t	i;
+	uint8_t		*entry;
+	struct sns_cmd_pkt	*sns_cmd;
+
+	/* Issue GID_PT. */
+	/* Prepare SNS command request. */
+	sns_cmd = qla2x00_prep_sns_cmd(ha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN,
+	    GID_PT_SNS_DATA_SIZE);
+
+	/* Prepare SNS command arguments -- port_type. */
+	sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE;
+
+	/* Execute SNS command. */
+	rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2,
+	    sizeof(struct sns_cmd_pkt));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (sns_cmd->p.gid_data[8] != 0x80 ||
+	    sns_cmd->p.gid_data[9] != 0x02) {
+		DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, "
+		    "gid_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gid_data, 16));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		/* Set port IDs in switch info list. */
+		for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
+			entry = &sns_cmd->p.gid_data[(i * 4) + 16];
+			list[i].d_id.b.domain = entry[1];
+			list[i].d_id.b.area = entry[2];
+			list[i].d_id.b.al_pa = entry[3];
+
+			/* Last one exit. */
+			if (entry[0] & BIT_7) {
+				list[i].d_id.b.rsvd_1 = entry[0];
+				break;
+			}
+		}
+
+		/*
+		 * If we've used all available slots, then the switch is
+		 * reporting back more devices that we can handle with this
+		 * single call.  Return a failed status, and let GA_NXT handle
+		 * the overload.
+		 */
+		if (i == MAX_FIBRE_DEVICES) 
+			rval = QLA_FUNCTION_FAILED;
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query.
+ * @ha: HA context
+ * @list: switch info entries to populate
+ *
+ * This command uses the old Exectute SNS Command mailbox routine.
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_sns_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
+{
+	int		rval;
+
+	uint16_t	i;
+	struct sns_cmd_pkt	*sns_cmd;
+
+	for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
+		/* Issue GPN_ID */
+		/* Prepare SNS command request. */
+		sns_cmd = qla2x00_prep_sns_cmd(ha, GPN_ID_CMD,
+		    GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE);
+
+		/* Prepare SNS command arguments -- port_id. */
+		sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
+		sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
+		sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
+
+		/* Execute SNS command. */
+		rval = qla2x00_send_sns(ha, ha->sns_cmd_dma,
+		    GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
+		if (rval != QLA_SUCCESS) {
+			/*EMPTY*/
+			DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed "
+			    "(%d).\n", ha->host_no, rval));
+		} else if (sns_cmd->p.gpn_data[8] != 0x80 ||
+		    sns_cmd->p.gpn_data[9] != 0x02) {
+			DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected "
+			    "request, gpn_rsp:\n", ha->host_no));
+			DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gpn_data, 16));
+			rval = QLA_FUNCTION_FAILED;
+		} else {
+			/* Save portname */
+			memcpy(list[i].port_name, &sns_cmd->p.gpn_data[16],
+			    WWN_SIZE);
+		}
+
+		/* Last device exit. */
+		if (list[i].d_id.b.rsvd_1 != 0)
+			break;
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query.
+ * @ha: HA context
+ * @list: switch info entries to populate
+ *
+ * This command uses the old Exectute SNS Command mailbox routine.
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_sns_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
+{
+	int		rval;
+
+	uint16_t	i;
+	struct sns_cmd_pkt	*sns_cmd;
+
+	for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
+		/* Issue GNN_ID */
+		/* Prepare SNS command request. */
+		sns_cmd = qla2x00_prep_sns_cmd(ha, GNN_ID_CMD,
+		    GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE);
+
+		/* Prepare SNS command arguments -- port_id. */
+		sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
+		sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
+		sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
+
+		/* Execute SNS command. */
+		rval = qla2x00_send_sns(ha, ha->sns_cmd_dma,
+		    GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
+		if (rval != QLA_SUCCESS) {
+			/*EMPTY*/
+			DEBUG2_3(printk("scsi(%ld): GNN_ID Send SNS failed "
+			    "(%d).\n", ha->host_no, rval));
+		} else if (sns_cmd->p.gnn_data[8] != 0x80 ||
+		    sns_cmd->p.gnn_data[9] != 0x02) {
+			DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected "
+			    "request, gnn_rsp:\n", ha->host_no));
+			DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gnn_data, 16));
+			rval = QLA_FUNCTION_FAILED;
+		} else {
+			/* Save nodename */
+			memcpy(list[i].node_name, &sns_cmd->p.gnn_data[16],
+			    WWN_SIZE);
+
+			DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
+			    "nn %02x%02x%02x%02x%02x%02x%02x%02x "
+			    "pn %02x%02x%02x%02x%02x%02x%02x%02x "
+			    "portid=%02x%02x%02x.\n",
+			    ha->host_no,
+			    list[i].node_name[0], list[i].node_name[1],
+			    list[i].node_name[2], list[i].node_name[3],
+			    list[i].node_name[4], list[i].node_name[5],
+			    list[i].node_name[6], list[i].node_name[7],
+			    list[i].port_name[0], list[i].port_name[1],
+			    list[i].port_name[2], list[i].port_name[3],
+			    list[i].port_name[4], list[i].port_name[5],
+			    list[i].port_name[6], list[i].port_name[7],
+			    list[i].d_id.b.domain, list[i].d_id.b.area,
+			    list[i].d_id.b.al_pa));
+		}
+
+		/* Last device exit. */
+		if (list[i].d_id.b.rsvd_1 != 0)
+			break;
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
+ * @ha: HA context
+ *
+ * This command uses the old Exectute SNS Command mailbox routine.
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_sns_rft_id(scsi_qla_host_t *ha)
+{
+	int		rval;
+
+	struct sns_cmd_pkt	*sns_cmd;
+
+	/* Issue RFT_ID. */
+	/* Prepare SNS command request. */
+	sns_cmd = qla2x00_prep_sns_cmd(ha, RFT_ID_CMD, RFT_ID_SNS_SCMD_LEN,
+	    RFT_ID_SNS_DATA_SIZE);
+
+	/* Prepare SNS command arguments -- port_id, FC-4 types */
+	sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa;
+	sns_cmd->p.cmd.param[1] = ha->d_id.b.area;
+	sns_cmd->p.cmd.param[2] = ha->d_id.b.domain;
+
+	sns_cmd->p.cmd.param[5] = 0x01;			/* FCP-3 */
+
+	/* Execute SNS command. */
+	rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RFT_ID_SNS_CMD_SIZE / 2,
+	    sizeof(struct sns_cmd_pkt));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): RFT_ID Send SNS failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (sns_cmd->p.rft_data[8] != 0x80 ||
+	    sns_cmd->p.rft_data[9] != 0x02) {
+		DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected request, "
+		    "rft_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rft_data, 16));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_sns_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the
+ * HBA.
+ * @ha: HA context
+ *
+ * This command uses the old Exectute SNS Command mailbox routine.
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_sns_rff_id(scsi_qla_host_t *ha)
+{
+	int		rval;
+
+	struct sns_cmd_pkt	*sns_cmd;
+
+	/* Issue RFF_ID. */
+	/* Prepare SNS command request. */
+	sns_cmd = qla2x00_prep_sns_cmd(ha, RFF_ID_CMD, RFF_ID_SNS_SCMD_LEN,
+	    RFF_ID_SNS_DATA_SIZE);
+
+	/* Prepare SNS command arguments -- port_id, FC-4 feature, FC-4 type */
+	sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa;
+	sns_cmd->p.cmd.param[1] = ha->d_id.b.area;
+	sns_cmd->p.cmd.param[2] = ha->d_id.b.domain;
+
+	sns_cmd->p.cmd.param[6] = 0x08;			/* SCSI - FCP */
+
+	/* Execute SNS command. */
+	rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RFF_ID_SNS_CMD_SIZE / 2,
+	    sizeof(struct sns_cmd_pkt));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): RFF_ID Send SNS failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (sns_cmd->p.rff_data[8] != 0x80 ||
+	    sns_cmd->p.rff_data[9] != 0x02) {
+		DEBUG2_3(printk("scsi(%ld): RFF_ID failed, rejected request, "
+		    "rff_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rff_data, 16));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
+ * HBA.
+ * @ha: HA context
+ *
+ * This command uses the old Exectute SNS Command mailbox routine.
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_sns_rnn_id(scsi_qla_host_t *ha)
+{
+	int		rval;
+
+	struct sns_cmd_pkt	*sns_cmd;
+
+	/* Issue RNN_ID. */
+	/* Prepare SNS command request. */
+	sns_cmd = qla2x00_prep_sns_cmd(ha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN,
+	    RNN_ID_SNS_DATA_SIZE);
+
+	/* Prepare SNS command arguments -- port_id, nodename. */
+	sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa;
+	sns_cmd->p.cmd.param[1] = ha->d_id.b.area;
+	sns_cmd->p.cmd.param[2] = ha->d_id.b.domain;
+
+	sns_cmd->p.cmd.param[4] = ha->init_cb->node_name[7];
+	sns_cmd->p.cmd.param[5] = ha->init_cb->node_name[6];
+	sns_cmd->p.cmd.param[6] = ha->init_cb->node_name[5];
+	sns_cmd->p.cmd.param[7] = ha->init_cb->node_name[4];
+	sns_cmd->p.cmd.param[8] = ha->init_cb->node_name[3];
+	sns_cmd->p.cmd.param[9] = ha->init_cb->node_name[2];
+	sns_cmd->p.cmd.param[10] = ha->init_cb->node_name[1];
+	sns_cmd->p.cmd.param[11] = ha->init_cb->node_name[0];
+
+	/* Execute SNS command. */
+	rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2,
+	    sizeof(struct sns_cmd_pkt));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (sns_cmd->p.rnn_data[8] != 0x80 ||
+	    sns_cmd->p.rnn_data[9] != 0x02) {
+		DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, "
+		    "rnn_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rnn_data, 16));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
diff -Nurd -X /root/Drivers/8.x/dontdiff-bk linux-2.6.2-rc2/drivers/scsi/qla2xxx-orig/qla_os.c linux-2.6.2-rc2/drivers/scsi/qla2xxx/qla_os.c
--- linux-2.6.2-rc2/drivers/scsi/qla2xxx-orig/qla_os.c	2004-01-22 08:45:20.029351720 -0800
+++ linux-2.6.2-rc2/drivers/scsi/qla2xxx/qla_os.c	2004-01-22 08:46:09.325857512 -0800
@@ -2998,37 +2998,59 @@
 		}
 		ha->mbx_sem_pool_tail = tmp_q_tail;
 
-		/* Get consistent memory allocated for MS IOCB */
-		ha->ms_iocb = pci_alloc_consistent(ha->pdev,
-		    sizeof(ms_iocb_entry_t), &ha->ms_iocb_dma);
-		if (ha->ms_iocb == NULL) {
-			/* error */
-			qla_printk(KERN_WARNING, ha,
-			    "Memory Allocation failed - ms_iocb\n");
+		/* Allocate memory for SNS commands */
+		if (IS_QLA2200(ha)) {
+			/* Get consistent memory allocated for SNS commands */
+			ha->sns_cmd = pci_alloc_consistent(ha->pdev,
+			    sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma);
+			if (ha->sns_cmd == NULL) {
+				/* error */
+				qla_printk(KERN_WARNING, ha,
+				    "Memory Allocation failed - sns_cmd\n");
 
-			qla2x00_mem_free(ha);
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(HZ/10);
+				qla2x00_mem_free(ha);
+				set_current_state(TASK_INTERRUPTIBLE);
+				schedule_timeout(HZ/10);
 
-			continue;
-		}
-		memset(ha->ms_iocb, 0, sizeof(ms_iocb_entry_t));
+				continue;
+			}
+			memset(ha->sns_cmd, 0, sizeof(struct sns_cmd_pkt));
+		} else if (!IS_QLA2100(ha)) {
+			/* Get consistent memory allocated for MS IOCB */
+			ha->ms_iocb = pci_alloc_consistent(ha->pdev,
+			    sizeof(ms_iocb_entry_t), &ha->ms_iocb_dma);
+			if (ha->ms_iocb == NULL) {
+				/* error */
+				qla_printk(KERN_WARNING, ha,
+				    "Memory Allocation failed - ms_iocb\n");
 
-		/* Get consistent memory allocated for CT SNS commands */
-		ha->ct_sns = pci_alloc_consistent(ha->pdev,
-		    sizeof(struct ct_sns_pkt), &ha->ct_sns_dma);
-		if (ha->ct_sns == NULL) {
-			/* error */
-			qla_printk(KERN_WARNING, ha,
-			    "Memory Allocation failed - ct_sns\n");
+				qla2x00_mem_free(ha);
+				set_current_state(TASK_INTERRUPTIBLE);
+				schedule_timeout(HZ/10);
 
-			qla2x00_mem_free(ha);
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(HZ/10);
+				continue;
+			}
+			memset(ha->ms_iocb, 0, sizeof(ms_iocb_entry_t));
 
-			continue;
+			/*
+			 * Get consistent memory allocated for CT SNS
+			 * commands
+			 */
+			ha->ct_sns = pci_alloc_consistent(ha->pdev,
+			    sizeof(struct ct_sns_pkt), &ha->ct_sns_dma);
+			if (ha->ct_sns == NULL) {
+				/* error */
+				qla_printk(KERN_WARNING, ha,
+				    "Memory Allocation failed - ct_sns\n");
+
+				qla2x00_mem_free(ha);
+				set_current_state(TASK_INTERRUPTIBLE);
+				schedule_timeout(HZ/10);
+
+				continue;
+			}
+			memset(ha->ct_sns, 0, sizeof(struct ct_sns_pkt));
 		}
-		memset(ha->ct_sns, 0, sizeof(struct ct_sns_pkt));
 
 		/* Get consistent memory allocated for Get Port Database cmd */
 		ha->iodesc_pd = pci_alloc_consistent(ha->pdev,
@@ -3119,6 +3141,12 @@
 		pci_free_consistent(ha->pdev, PORT_DATABASE_SIZE,
 		    ha->iodesc_pd, ha->iodesc_pd_dma);
 	}
+
+	if (ha->sns_cmd) {
+		pci_free_consistent(ha->pdev,
+		    sizeof(struct sns_cmd_pkt), ha->sns_cmd, ha->sns_cmd_dma);
+	}
+
 	if (ha->ct_sns) {
 		pci_free_consistent(ha->pdev,
 		    sizeof(struct ct_sns_pkt), ha->ct_sns, ha->ct_sns_dma);

                 reply	other threads:[~2004-01-27 22:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1075242925.6053.67.camel@dieplab1 \
    --to=andrew.vasquez@qlogic.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.