Commit 1a4320fa authored by James Bottomley's avatar James Bottomley

qla2xxx - perform proper SNS scans with ISP2200 HBAs. [1/3]

From: 	Andrew Vasquez <andrew.vasquez@qlogic.com>

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.
parent 36ce46ce
...@@ -1895,6 +1895,60 @@ struct ct_sns_pkt { ...@@ -1895,6 +1895,60 @@ struct ct_sns_pkt {
} p; } 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 */ /* IO descriptors */
#define MAX_IO_DESCRIPTORS 32 #define MAX_IO_DESCRIPTORS 32
...@@ -2162,10 +2216,14 @@ typedef struct scsi_qla_host { ...@@ -2162,10 +2216,14 @@ typedef struct scsi_qla_host {
uint8_t rscn_in_ptr; uint8_t rscn_in_ptr;
uint8_t rscn_out_ptr; uint8_t rscn_out_ptr;
/* SNS command interfaces. */
ms_iocb_entry_t *ms_iocb; ms_iocb_entry_t *ms_iocb;
dma_addr_t ms_iocb_dma; dma_addr_t ms_iocb_dma;
struct ct_sns_pkt *ct_sns; struct ct_sns_pkt *ct_sns;
dma_addr_t ct_sns_dma; 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; pid_t dpc_pid;
int dpc_should_die; int dpc_should_die;
......
...@@ -26,6 +26,17 @@ qla2x00_prep_ms_iocb(scsi_qla_host_t *, uint32_t, uint32_t); ...@@ -26,6 +26,17 @@ qla2x00_prep_ms_iocb(scsi_qla_host_t *, uint32_t, uint32_t);
static inline struct ct_sns_req * static inline struct ct_sns_req *
qla2x00_prep_ct_req(struct ct_sns_req *, uint16_t, uint16_t); 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. * qla2x00_prep_ms_iocb() - Prepare common MS IOCB fields for SNS CT query.
* @ha: HA context * @ha: HA context
...@@ -85,6 +96,7 @@ qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size) ...@@ -85,6 +96,7 @@ qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size)
return (ct_req); return (ct_req);
} }
/** /**
* qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command. * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
* @ha: HA context * @ha: HA context
...@@ -101,6 +113,10 @@ qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport) ...@@ -101,6 +113,10 @@ qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
struct ct_sns_rsp *ct_rsp; struct ct_sns_rsp *ct_rsp;
if (IS_QLA2200(ha)) {
return (qla2x00_sns_ga_nxt(ha, fcport));
}
/* Issue GA_NXT */ /* Issue GA_NXT */
/* Prepare common MS IOCB */ /* Prepare common MS IOCB */
ms_pkt = qla2x00_prep_ms_iocb(ha, GA_NXT_REQ_SIZE, GA_NXT_RSP_SIZE); ms_pkt = qla2x00_prep_ms_iocb(ha, GA_NXT_REQ_SIZE, GA_NXT_RSP_SIZE);
...@@ -185,6 +201,10 @@ qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list) ...@@ -185,6 +201,10 @@ qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
struct ct_sns_gid_pt_data *gid_data; struct ct_sns_gid_pt_data *gid_data;
if (IS_QLA2200(ha)) {
return (qla2x00_sns_gid_pt(ha, list));
}
gid_data = NULL; gid_data = NULL;
/* Issue GID_PT */ /* Issue GID_PT */
...@@ -258,6 +278,10 @@ qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list) ...@@ -258,6 +278,10 @@ qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
struct ct_sns_rsp *ct_rsp; 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++) { for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
/* Issue GPN_ID */ /* Issue GPN_ID */
/* Prepare common MS IOCB */ /* Prepare common MS IOCB */
...@@ -303,7 +327,7 @@ qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list) ...@@ -303,7 +327,7 @@ qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
} }
/** /**
* qla2x00_gnn_id() - SNS Get Node Name (GPN_ID) query. * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query.
* @ha: HA context * @ha: HA context
* @list: switch info entries to populate * @list: switch info entries to populate
* *
...@@ -319,6 +343,10 @@ qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list) ...@@ -319,6 +343,10 @@ qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
struct ct_sns_rsp *ct_rsp; 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++) { for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
/* Issue GNN_ID */ /* Issue GNN_ID */
/* Prepare common MS IOCB */ /* Prepare common MS IOCB */
...@@ -457,6 +485,10 @@ qla2x00_rft_id(scsi_qla_host_t *ha) ...@@ -457,6 +485,10 @@ qla2x00_rft_id(scsi_qla_host_t *ha)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
struct ct_sns_rsp *ct_rsp; struct ct_sns_rsp *ct_rsp;
if (IS_QLA2200(ha)) {
return (qla2x00_sns_rft_id(ha));
}
/* Issue RFT_ID */ /* Issue RFT_ID */
/* Prepare common MS IOCB */ /* Prepare common MS IOCB */
ms_pkt = qla2x00_prep_ms_iocb(ha, RFT_ID_REQ_SIZE, RFT_ID_RSP_SIZE); ms_pkt = qla2x00_prep_ms_iocb(ha, RFT_ID_REQ_SIZE, RFT_ID_RSP_SIZE);
...@@ -510,6 +542,10 @@ qla2x00_rff_id(scsi_qla_host_t *ha) ...@@ -510,6 +542,10 @@ qla2x00_rff_id(scsi_qla_host_t *ha)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
struct ct_sns_rsp *ct_rsp; struct ct_sns_rsp *ct_rsp;
if (IS_QLA2200(ha)) {
return (qla2x00_sns_rff_id(ha));
}
/* Issue RFF_ID */ /* Issue RFF_ID */
/* Prepare common MS IOCB */ /* Prepare common MS IOCB */
ms_pkt = qla2x00_prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE); ms_pkt = qla2x00_prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE);
...@@ -563,6 +599,10 @@ qla2x00_rnn_id(scsi_qla_host_t *ha) ...@@ -563,6 +599,10 @@ qla2x00_rnn_id(scsi_qla_host_t *ha)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
struct ct_sns_rsp *ct_rsp; struct ct_sns_rsp *ct_rsp;
if (IS_QLA2200(ha)) {
return (qla2x00_sns_rnn_id(ha));
}
/* Issue RNN_ID */ /* Issue RNN_ID */
/* Prepare common MS IOCB */ /* Prepare common MS IOCB */
ms_pkt = qla2x00_prep_ms_iocb(ha, RNN_ID_REQ_SIZE, RNN_ID_RSP_SIZE); ms_pkt = qla2x00_prep_ms_iocb(ha, RNN_ID_REQ_SIZE, RNN_ID_RSP_SIZE);
...@@ -618,6 +658,12 @@ qla2x00_rsnn_nn(scsi_qla_host_t *ha) ...@@ -618,6 +658,12 @@ qla2x00_rsnn_nn(scsi_qla_host_t *ha)
struct ct_sns_req *ct_req; struct ct_sns_req *ct_req;
struct ct_sns_rsp *ct_rsp; 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 */ /* Issue RSNN_NN */
/* Prepare common MS IOCB */ /* Prepare common MS IOCB */
/* Request size adjusted after CT preparation */ /* Request size adjusted after CT preparation */
...@@ -673,3 +719,454 @@ qla2x00_rsnn_nn(scsi_qla_host_t *ha) ...@@ -673,3 +719,454 @@ qla2x00_rsnn_nn(scsi_qla_host_t *ha)
return (rval); 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);
}
...@@ -2921,37 +2921,59 @@ qla2x00_mem_alloc(scsi_qla_host_t *ha) ...@@ -2921,37 +2921,59 @@ qla2x00_mem_alloc(scsi_qla_host_t *ha)
continue; continue;
} }
/* Get consistent memory allocated for MS IOCB */ /* Allocate memory for SNS commands */
ha->ms_iocb = pci_alloc_consistent(ha->pdev, if (IS_QLA2200(ha)) {
sizeof(ms_iocb_entry_t), &ha->ms_iocb_dma); /* Get consistent memory allocated for SNS commands */
if (ha->ms_iocb == NULL) { ha->sns_cmd = pci_alloc_consistent(ha->pdev,
/* error */ sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma);
qla_printk(KERN_WARNING, ha, if (ha->sns_cmd == NULL) {
"Memory Allocation failed - ms_iocb\n"); /* error */
qla_printk(KERN_WARNING, ha,
"Memory Allocation failed - sns_cmd\n");
qla2x00_mem_free(ha); qla2x00_mem_free(ha);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ/10); schedule_timeout(HZ/10);
continue; continue;
} }
memset(ha->ms_iocb, 0, sizeof(ms_iocb_entry_t)); 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 */ qla2x00_mem_free(ha);
ha->ct_sns = pci_alloc_consistent(ha->pdev, set_current_state(TASK_INTERRUPTIBLE);
sizeof(struct ct_sns_pkt), &ha->ct_sns_dma); schedule_timeout(HZ/10);
if (ha->ct_sns == NULL) {
/* error */
qla_printk(KERN_WARNING, ha,
"Memory Allocation failed - ct_sns\n");
qla2x00_mem_free(ha); continue;
set_current_state(TASK_INTERRUPTIBLE); }
schedule_timeout(HZ/10); 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 */ /* Get consistent memory allocated for Get Port Database cmd */
ha->iodesc_pd = pci_alloc_consistent(ha->pdev, ha->iodesc_pd = pci_alloc_consistent(ha->pdev,
...@@ -3027,6 +3049,12 @@ qla2x00_mem_free(scsi_qla_host_t *ha) ...@@ -3027,6 +3049,12 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
pci_free_consistent(ha->pdev, PORT_DATABASE_SIZE, pci_free_consistent(ha->pdev, PORT_DATABASE_SIZE,
ha->iodesc_pd, ha->iodesc_pd_dma); 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) { if (ha->ct_sns) {
pci_free_consistent(ha->pdev, pci_free_consistent(ha->pdev,
sizeof(struct ct_sns_pkt), ha->ct_sns, ha->ct_sns_dma); sizeof(struct ct_sns_pkt), ha->ct_sns, ha->ct_sns_dma);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment