Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 2 | * QLogic Fibre Channel HBA Driver |
Saurav Kashyap | 1e63395 | 2013-02-08 01:57:54 -0500 | [diff] [blame] | 3 | * Copyright (c) 2003-2013 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #include "qla_def.h" |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 8 | #include "qla_target.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | static int qla2x00_sns_ga_nxt(scsi_qla_host_t *, fc_port_t *); |
| 11 | static int qla2x00_sns_gid_pt(scsi_qla_host_t *, sw_info_t *); |
| 12 | static int qla2x00_sns_gpn_id(scsi_qla_host_t *, sw_info_t *); |
| 13 | static int qla2x00_sns_gnn_id(scsi_qla_host_t *, sw_info_t *); |
| 14 | static int qla2x00_sns_rft_id(scsi_qla_host_t *); |
| 15 | static int qla2x00_sns_rnn_id(scsi_qla_host_t *); |
| 16 | |
| 17 | /** |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 18 | * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | * @ha: HA context |
| 20 | * @req_size: request size in bytes |
| 21 | * @rsp_size: response size in bytes |
| 22 | * |
| 23 | * Returns a pointer to the @ha's ms_iocb. |
| 24 | */ |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 25 | void * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 26 | qla2x00_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 28 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | ms_iocb_entry_t *ms_pkt; |
| 30 | |
| 31 | ms_pkt = ha->ms_iocb; |
| 32 | memset(ms_pkt, 0, sizeof(ms_iocb_entry_t)); |
| 33 | |
| 34 | ms_pkt->entry_type = MS_IOCB_TYPE; |
| 35 | ms_pkt->entry_count = 1; |
| 36 | SET_TARGET_ID(ha, ms_pkt->loop_id, SIMPLE_NAME_SERVER); |
| 37 | ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 38 | ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); |
| 40 | ms_pkt->total_dsd_count = __constant_cpu_to_le16(2); |
| 41 | ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size); |
| 42 | ms_pkt->req_bytecount = cpu_to_le32(req_size); |
| 43 | |
| 44 | ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 45 | ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 46 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; |
| 47 | |
| 48 | ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 49 | ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 50 | ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount; |
| 51 | |
| 52 | return (ms_pkt); |
| 53 | } |
| 54 | |
| 55 | /** |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 56 | * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query. |
| 57 | * @ha: HA context |
| 58 | * @req_size: request size in bytes |
| 59 | * @rsp_size: response size in bytes |
| 60 | * |
| 61 | * Returns a pointer to the @ha's ms_iocb. |
| 62 | */ |
| 63 | void * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 64 | qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size) |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 65 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 66 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 67 | struct ct_entry_24xx *ct_pkt; |
| 68 | |
| 69 | ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; |
| 70 | memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); |
| 71 | |
| 72 | ct_pkt->entry_type = CT_IOCB_TYPE; |
| 73 | ct_pkt->entry_count = 1; |
| 74 | ct_pkt->nport_handle = __constant_cpu_to_le16(NPH_SNS); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 75 | ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 76 | ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); |
| 77 | ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1); |
| 78 | ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size); |
| 79 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); |
| 80 | |
| 81 | ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 82 | ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 83 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; |
| 84 | |
| 85 | ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 86 | ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 87 | ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 88 | ct_pkt->vp_index = vha->vp_idx; |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 89 | |
| 90 | return (ct_pkt); |
| 91 | } |
| 92 | |
| 93 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query. |
| 95 | * @ct_req: CT request buffer |
| 96 | * @cmd: GS command |
| 97 | * @rsp_size: response size in bytes |
| 98 | * |
| 99 | * Returns a pointer to the intitialized @ct_req. |
| 100 | */ |
| 101 | static inline struct ct_sns_req * |
| 102 | qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size) |
| 103 | { |
| 104 | memset(ct_req, 0, sizeof(struct ct_sns_pkt)); |
| 105 | |
| 106 | ct_req->header.revision = 0x01; |
| 107 | ct_req->header.gs_type = 0xFC; |
| 108 | ct_req->header.gs_subtype = 0x02; |
| 109 | ct_req->command = cpu_to_be16(cmd); |
| 110 | ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); |
| 111 | |
| 112 | return (ct_req); |
| 113 | } |
| 114 | |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 115 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 116 | qla2x00_chk_ms_status(scsi_qla_host_t *vha, ms_iocb_entry_t *ms_pkt, |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 117 | struct ct_sns_rsp *ct_rsp, const char *routine) |
| 118 | { |
| 119 | int rval; |
| 120 | uint16_t comp_status; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 121 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 122 | |
| 123 | rval = QLA_FUNCTION_FAILED; |
| 124 | if (ms_pkt->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 125 | ql_dbg(ql_dbg_disc, vha, 0x2031, |
| 126 | "%s failed, error status (%x) on port_id: %02x%02x%02x.\n", |
| 127 | routine, ms_pkt->entry_status, vha->d_id.b.domain, |
| 128 | vha->d_id.b.area, vha->d_id.b.al_pa); |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 129 | } else { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 130 | if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | cdfc82a | 2006-12-13 19:20:26 -0800 | [diff] [blame] | 131 | comp_status = le16_to_cpu( |
| 132 | ((struct ct_entry_24xx *)ms_pkt)->comp_status); |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 133 | else |
| 134 | comp_status = le16_to_cpu(ms_pkt->status); |
| 135 | switch (comp_status) { |
| 136 | case CS_COMPLETE: |
| 137 | case CS_DATA_UNDERRUN: |
| 138 | case CS_DATA_OVERRUN: /* Overrun? */ |
| 139 | if (ct_rsp->header.response != |
| 140 | __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 141 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2077, |
| 142 | "%s failed rejected request on port_id: " |
| 143 | "%02x%02x%02x.\n", routine, |
Giridhar Malavali | cf2d771 | 2011-02-23 15:27:09 -0800 | [diff] [blame] | 144 | vha->d_id.b.domain, vha->d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 145 | vha->d_id.b.al_pa); |
| 146 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, |
| 147 | 0x2078, (uint8_t *)&ct_rsp->header, |
| 148 | sizeof(struct ct_rsp_hdr)); |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 149 | rval = QLA_INVALID_COMMAND; |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 150 | } else |
| 151 | rval = QLA_SUCCESS; |
| 152 | break; |
| 153 | default: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 154 | ql_dbg(ql_dbg_disc, vha, 0x2033, |
| 155 | "%s failed, completion status (%x) on port_id: " |
| 156 | "%02x%02x%02x.\n", routine, comp_status, |
Giridhar Malavali | cf2d771 | 2011-02-23 15:27:09 -0800 | [diff] [blame] | 157 | vha->d_id.b.domain, vha->d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 158 | vha->d_id.b.al_pa); |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 159 | break; |
| 160 | } |
| 161 | } |
| 162 | return rval; |
| 163 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
| 165 | /** |
| 166 | * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command. |
| 167 | * @ha: HA context |
| 168 | * @fcport: fcport entry to updated |
| 169 | * |
| 170 | * Returns 0 on success. |
| 171 | */ |
| 172 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 173 | qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | { |
| 175 | int rval; |
| 176 | |
| 177 | ms_iocb_entry_t *ms_pkt; |
| 178 | struct ct_sns_req *ct_req; |
| 179 | struct ct_sns_rsp *ct_rsp; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 180 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 182 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 183 | return qla2x00_sns_ga_nxt(vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | |
| 185 | /* Issue GA_NXT */ |
| 186 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 187 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GA_NXT_REQ_SIZE, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 188 | GA_NXT_RSP_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | |
| 190 | /* Prepare CT request */ |
| 191 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD, |
| 192 | GA_NXT_RSP_SIZE); |
| 193 | ct_rsp = &ha->ct_sns->p.rsp; |
| 194 | |
| 195 | /* Prepare CT arguments -- port_id */ |
| 196 | ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain; |
| 197 | ct_req->req.port_id.port_id[1] = fcport->d_id.b.area; |
| 198 | ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa; |
| 199 | |
| 200 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 201 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | sizeof(ms_iocb_entry_t)); |
| 203 | if (rval != QLA_SUCCESS) { |
| 204 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 205 | ql_dbg(ql_dbg_disc, vha, 0x2062, |
| 206 | "GA_NXT issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 207 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "GA_NXT") != |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 208 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | rval = QLA_FUNCTION_FAILED; |
| 210 | } else { |
| 211 | /* Populate fc_port_t entry. */ |
| 212 | fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0]; |
| 213 | fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1]; |
| 214 | fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2]; |
| 215 | |
| 216 | memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name, |
| 217 | WWN_SIZE); |
| 218 | memcpy(fcport->port_name, ct_rsp->rsp.ga_nxt.port_name, |
| 219 | WWN_SIZE); |
| 220 | |
Armen Baloyan | a72b990 | 2012-11-21 02:40:30 -0500 | [diff] [blame] | 221 | fcport->fc4_type = (ct_rsp->rsp.ga_nxt.fc4_types[2] & BIT_0) ? |
| 222 | FC4_TYPE_FCP_SCSI : FC4_TYPE_OTHER; |
| 223 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE && |
| 225 | ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE) |
| 226 | fcport->d_id.b.domain = 0xf0; |
| 227 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 228 | ql_dbg(ql_dbg_disc, vha, 0x2063, |
| 229 | "GA_NXT entry - nn %02x%02x%02x%02x%02x%02x%02x%02x " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | "pn %02x%02x%02x%02x%02x%02x%02x%02x " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 231 | "port_id=%02x%02x%02x.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | fcport->node_name[0], fcport->node_name[1], |
| 233 | fcport->node_name[2], fcport->node_name[3], |
| 234 | fcport->node_name[4], fcport->node_name[5], |
| 235 | fcport->node_name[6], fcport->node_name[7], |
| 236 | fcport->port_name[0], fcport->port_name[1], |
| 237 | fcport->port_name[2], fcport->port_name[3], |
| 238 | fcport->port_name[4], fcport->port_name[5], |
| 239 | fcport->port_name[6], fcport->port_name[7], |
| 240 | fcport->d_id.b.domain, fcport->d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 241 | fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | return (rval); |
| 245 | } |
| 246 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 247 | static inline int |
| 248 | qla2x00_gid_pt_rsp_size(scsi_qla_host_t *vha) |
| 249 | { |
| 250 | return vha->hw->max_fibre_devices * 4 + 16; |
| 251 | } |
| 252 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | /** |
| 254 | * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command. |
| 255 | * @ha: HA context |
| 256 | * @list: switch info entries to populate |
| 257 | * |
| 258 | * NOTE: Non-Nx_Ports are not requested. |
| 259 | * |
| 260 | * Returns 0 on success. |
| 261 | */ |
| 262 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 263 | qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | { |
| 265 | int rval; |
| 266 | uint16_t i; |
| 267 | |
| 268 | ms_iocb_entry_t *ms_pkt; |
| 269 | struct ct_sns_req *ct_req; |
| 270 | struct ct_sns_rsp *ct_rsp; |
| 271 | |
| 272 | struct ct_sns_gid_pt_data *gid_data; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 273 | struct qla_hw_data *ha = vha->hw; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 274 | uint16_t gid_pt_rsp_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 276 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 277 | return qla2x00_sns_gid_pt(vha, list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
| 279 | gid_data = NULL; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 280 | gid_pt_rsp_size = qla2x00_gid_pt_rsp_size(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | /* Issue GID_PT */ |
| 282 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 283 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GID_PT_REQ_SIZE, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 284 | gid_pt_rsp_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
| 286 | /* Prepare CT request */ |
| 287 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 288 | gid_pt_rsp_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | ct_rsp = &ha->ct_sns->p.rsp; |
| 290 | |
| 291 | /* Prepare CT arguments -- port_type */ |
| 292 | ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE; |
| 293 | |
| 294 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 295 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | sizeof(ms_iocb_entry_t)); |
| 297 | if (rval != QLA_SUCCESS) { |
| 298 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 299 | ql_dbg(ql_dbg_disc, vha, 0x2055, |
| 300 | "GID_PT issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 301 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "GID_PT") != |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 302 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | rval = QLA_FUNCTION_FAILED; |
| 304 | } else { |
| 305 | /* Set port IDs in switch info list. */ |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 306 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | gid_data = &ct_rsp->rsp.gid_pt.entries[i]; |
| 308 | list[i].d_id.b.domain = gid_data->port_id[0]; |
| 309 | list[i].d_id.b.area = gid_data->port_id[1]; |
| 310 | list[i].d_id.b.al_pa = gid_data->port_id[2]; |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 311 | memset(list[i].fabric_port_name, 0, WWN_SIZE); |
| 312 | list[i].fp_speed = PORT_SPEED_UNKNOWN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
| 314 | /* Last one exit. */ |
| 315 | if (gid_data->control_byte & BIT_7) { |
| 316 | list[i].d_id.b.rsvd_1 = gid_data->control_byte; |
| 317 | break; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | /* |
| 322 | * If we've used all available slots, then the switch is |
| 323 | * reporting back more devices than we can handle with this |
| 324 | * single call. Return a failed status, and let GA_NXT handle |
| 325 | * the overload. |
| 326 | */ |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 327 | if (i == ha->max_fibre_devices) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | rval = QLA_FUNCTION_FAILED; |
| 329 | } |
| 330 | |
| 331 | return (rval); |
| 332 | } |
| 333 | |
| 334 | /** |
| 335 | * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query. |
| 336 | * @ha: HA context |
| 337 | * @list: switch info entries to populate |
| 338 | * |
| 339 | * Returns 0 on success. |
| 340 | */ |
| 341 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 342 | qla2x00_gpn_id(scsi_qla_host_t *vha, sw_info_t *list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 344 | int rval = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | uint16_t i; |
| 346 | |
| 347 | ms_iocb_entry_t *ms_pkt; |
| 348 | struct ct_sns_req *ct_req; |
| 349 | struct ct_sns_rsp *ct_rsp; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 350 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 352 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 353 | return qla2x00_sns_gpn_id(vha, list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 355 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | /* Issue GPN_ID */ |
| 357 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 358 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GPN_ID_REQ_SIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | GPN_ID_RSP_SIZE); |
| 360 | |
| 361 | /* Prepare CT request */ |
| 362 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD, |
| 363 | GPN_ID_RSP_SIZE); |
| 364 | ct_rsp = &ha->ct_sns->p.rsp; |
| 365 | |
| 366 | /* Prepare CT arguments -- port_id */ |
| 367 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; |
| 368 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; |
| 369 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; |
| 370 | |
| 371 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 372 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | sizeof(ms_iocb_entry_t)); |
| 374 | if (rval != QLA_SUCCESS) { |
| 375 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 376 | ql_dbg(ql_dbg_disc, vha, 0x2056, |
| 377 | "GPN_ID issue IOCB failed (%d).\n", rval); |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 378 | break; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 379 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 380 | "GPN_ID") != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | rval = QLA_FUNCTION_FAILED; |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 382 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | } else { |
| 384 | /* Save portname */ |
| 385 | memcpy(list[i].port_name, |
| 386 | ct_rsp->rsp.gpn_id.port_name, WWN_SIZE); |
| 387 | } |
| 388 | |
| 389 | /* Last device exit. */ |
| 390 | if (list[i].d_id.b.rsvd_1 != 0) |
| 391 | break; |
| 392 | } |
| 393 | |
| 394 | return (rval); |
| 395 | } |
| 396 | |
| 397 | /** |
| 398 | * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query. |
| 399 | * @ha: HA context |
| 400 | * @list: switch info entries to populate |
| 401 | * |
| 402 | * Returns 0 on success. |
| 403 | */ |
| 404 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 405 | qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 407 | int rval = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | uint16_t i; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 409 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | ms_iocb_entry_t *ms_pkt; |
| 411 | struct ct_sns_req *ct_req; |
| 412 | struct ct_sns_rsp *ct_rsp; |
| 413 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 414 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 415 | return qla2x00_sns_gnn_id(vha, list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 417 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | /* Issue GNN_ID */ |
| 419 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 420 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GNN_ID_REQ_SIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | GNN_ID_RSP_SIZE); |
| 422 | |
| 423 | /* Prepare CT request */ |
| 424 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GNN_ID_CMD, |
| 425 | GNN_ID_RSP_SIZE); |
| 426 | ct_rsp = &ha->ct_sns->p.rsp; |
| 427 | |
| 428 | /* Prepare CT arguments -- port_id */ |
| 429 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; |
| 430 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; |
| 431 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; |
| 432 | |
| 433 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 434 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | sizeof(ms_iocb_entry_t)); |
| 436 | if (rval != QLA_SUCCESS) { |
| 437 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 438 | ql_dbg(ql_dbg_disc, vha, 0x2057, |
| 439 | "GNN_ID issue IOCB failed (%d).\n", rval); |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 440 | break; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 441 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 442 | "GNN_ID") != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | rval = QLA_FUNCTION_FAILED; |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 444 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | } else { |
| 446 | /* Save nodename */ |
| 447 | memcpy(list[i].node_name, |
| 448 | ct_rsp->rsp.gnn_id.node_name, WWN_SIZE); |
| 449 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 450 | ql_dbg(ql_dbg_disc, vha, 0x2058, |
| 451 | "GID_PT entry - nn %02x%02x%02x%02x%02x%02x%02X%02x " |
| 452 | "pn %02x%02x%02x%02x%02x%02x%02X%02x " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | "portid=%02x%02x%02x.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | list[i].node_name[0], list[i].node_name[1], |
| 455 | list[i].node_name[2], list[i].node_name[3], |
| 456 | list[i].node_name[4], list[i].node_name[5], |
| 457 | list[i].node_name[6], list[i].node_name[7], |
| 458 | list[i].port_name[0], list[i].port_name[1], |
| 459 | list[i].port_name[2], list[i].port_name[3], |
| 460 | list[i].port_name[4], list[i].port_name[5], |
| 461 | list[i].port_name[6], list[i].port_name[7], |
| 462 | list[i].d_id.b.domain, list[i].d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 463 | list[i].d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | /* Last device exit. */ |
| 467 | if (list[i].d_id.b.rsvd_1 != 0) |
| 468 | break; |
| 469 | } |
| 470 | |
| 471 | return (rval); |
| 472 | } |
| 473 | |
| 474 | /** |
| 475 | * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA. |
| 476 | * @ha: HA context |
| 477 | * |
| 478 | * Returns 0 on success. |
| 479 | */ |
| 480 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 481 | qla2x00_rft_id(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | { |
| 483 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 484 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | ms_iocb_entry_t *ms_pkt; |
| 486 | struct ct_sns_req *ct_req; |
| 487 | struct ct_sns_rsp *ct_rsp; |
| 488 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 489 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 490 | return qla2x00_sns_rft_id(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | |
| 492 | /* Issue RFT_ID */ |
| 493 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 494 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RFT_ID_REQ_SIZE, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 495 | RFT_ID_RSP_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | |
| 497 | /* Prepare CT request */ |
| 498 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD, |
| 499 | RFT_ID_RSP_SIZE); |
| 500 | ct_rsp = &ha->ct_sns->p.rsp; |
| 501 | |
| 502 | /* Prepare CT arguments -- port_id, FC-4 types */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 503 | ct_req->req.rft_id.port_id[0] = vha->d_id.b.domain; |
| 504 | ct_req->req.rft_id.port_id[1] = vha->d_id.b.area; |
| 505 | ct_req->req.rft_id.port_id[2] = vha->d_id.b.al_pa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | |
| 507 | ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */ |
| 508 | |
| 509 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 510 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | sizeof(ms_iocb_entry_t)); |
| 512 | if (rval != QLA_SUCCESS) { |
| 513 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 514 | ql_dbg(ql_dbg_disc, vha, 0x2043, |
| 515 | "RFT_ID issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 516 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RFT_ID") != |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 517 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | rval = QLA_FUNCTION_FAILED; |
| 519 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 520 | ql_dbg(ql_dbg_disc, vha, 0x2044, |
| 521 | "RFT_ID exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | return (rval); |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA. |
| 529 | * @ha: HA context |
| 530 | * |
| 531 | * Returns 0 on success. |
| 532 | */ |
| 533 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 534 | qla2x00_rff_id(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | { |
| 536 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 537 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | ms_iocb_entry_t *ms_pkt; |
| 539 | struct ct_sns_req *ct_req; |
| 540 | struct ct_sns_rsp *ct_rsp; |
| 541 | |
| 542 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 543 | ql_dbg(ql_dbg_disc, vha, 0x2046, |
| 544 | "RFF_ID call not supported on ISP2100/ISP2200.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | return (QLA_SUCCESS); |
| 546 | } |
| 547 | |
| 548 | /* Issue RFF_ID */ |
| 549 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 550 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RFF_ID_REQ_SIZE, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 551 | RFF_ID_RSP_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | |
| 553 | /* Prepare CT request */ |
| 554 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD, |
| 555 | RFF_ID_RSP_SIZE); |
| 556 | ct_rsp = &ha->ct_sns->p.rsp; |
| 557 | |
| 558 | /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 559 | ct_req->req.rff_id.port_id[0] = vha->d_id.b.domain; |
| 560 | ct_req->req.rff_id.port_id[1] = vha->d_id.b.area; |
| 561 | ct_req->req.rff_id.port_id[2] = vha->d_id.b.al_pa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 563 | qlt_rff_id(vha, ct_req); |
| 564 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */ |
| 566 | |
| 567 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 568 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | sizeof(ms_iocb_entry_t)); |
| 570 | if (rval != QLA_SUCCESS) { |
| 571 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 572 | ql_dbg(ql_dbg_disc, vha, 0x2047, |
| 573 | "RFF_ID issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 574 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RFF_ID") != |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 575 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | rval = QLA_FUNCTION_FAILED; |
| 577 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 578 | ql_dbg(ql_dbg_disc, vha, 0x2048, |
| 579 | "RFF_ID exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | return (rval); |
| 583 | } |
| 584 | |
| 585 | /** |
| 586 | * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA. |
| 587 | * @ha: HA context |
| 588 | * |
| 589 | * Returns 0 on success. |
| 590 | */ |
| 591 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 592 | qla2x00_rnn_id(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | { |
| 594 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 595 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | ms_iocb_entry_t *ms_pkt; |
| 597 | struct ct_sns_req *ct_req; |
| 598 | struct ct_sns_rsp *ct_rsp; |
| 599 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 600 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 601 | return qla2x00_sns_rnn_id(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | |
| 603 | /* Issue RNN_ID */ |
| 604 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 605 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RNN_ID_REQ_SIZE, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 606 | RNN_ID_RSP_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | |
| 608 | /* Prepare CT request */ |
| 609 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD, |
| 610 | RNN_ID_RSP_SIZE); |
| 611 | ct_rsp = &ha->ct_sns->p.rsp; |
| 612 | |
| 613 | /* Prepare CT arguments -- port_id, node_name */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 614 | ct_req->req.rnn_id.port_id[0] = vha->d_id.b.domain; |
| 615 | ct_req->req.rnn_id.port_id[1] = vha->d_id.b.area; |
| 616 | ct_req->req.rnn_id.port_id[2] = vha->d_id.b.al_pa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 618 | memcpy(ct_req->req.rnn_id.node_name, vha->node_name, WWN_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | |
| 620 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 621 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | sizeof(ms_iocb_entry_t)); |
| 623 | if (rval != QLA_SUCCESS) { |
| 624 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 625 | ql_dbg(ql_dbg_disc, vha, 0x204d, |
| 626 | "RNN_ID issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 627 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RNN_ID") != |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 628 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | rval = QLA_FUNCTION_FAILED; |
| 630 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 631 | ql_dbg(ql_dbg_disc, vha, 0x204e, |
| 632 | "RNN_ID exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | return (rval); |
| 636 | } |
| 637 | |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 638 | void |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 639 | qla2x00_get_sym_node_name(scsi_qla_host_t *vha, uint8_t *snn) |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 640 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 641 | struct qla_hw_data *ha = vha->hw; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 642 | |
| 643 | if (IS_QLAFX00(ha)) |
| 644 | sprintf(snn, "%s FW:v%s DVR:v%s", ha->model_number, |
| 645 | ha->mr.fw_version, qla2x00_version_str); |
| 646 | else |
| 647 | sprintf(snn, "%s FW:v%d.%02d.%02d DVR:v%s", ha->model_number, |
| 648 | ha->fw_major_version, ha->fw_minor_version, |
| 649 | ha->fw_subminor_version, qla2x00_version_str); |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 650 | } |
| 651 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | /** |
| 653 | * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA. |
| 654 | * @ha: HA context |
| 655 | * |
| 656 | * Returns 0 on success. |
| 657 | */ |
| 658 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 659 | qla2x00_rsnn_nn(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | { |
| 661 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 662 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | ms_iocb_entry_t *ms_pkt; |
| 664 | struct ct_sns_req *ct_req; |
| 665 | struct ct_sns_rsp *ct_rsp; |
| 666 | |
| 667 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 668 | ql_dbg(ql_dbg_disc, vha, 0x2050, |
| 669 | "RSNN_ID call unsupported on ISP2100/ISP2200.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | return (QLA_SUCCESS); |
| 671 | } |
| 672 | |
| 673 | /* Issue RSNN_NN */ |
| 674 | /* Prepare common MS IOCB */ |
| 675 | /* Request size adjusted after CT preparation */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 676 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, 0, RSNN_NN_RSP_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | |
| 678 | /* Prepare CT request */ |
| 679 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD, |
| 680 | RSNN_NN_RSP_SIZE); |
| 681 | ct_rsp = &ha->ct_sns->p.rsp; |
| 682 | |
| 683 | /* Prepare CT arguments -- node_name, symbolic node_name, size */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 684 | memcpy(ct_req->req.rsnn_nn.node_name, vha->node_name, WWN_SIZE); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 685 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | /* Prepare the Symbolic Node Name */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 687 | qla2x00_get_sym_node_name(vha, ct_req->req.rsnn_nn.sym_node_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | |
| 689 | /* Calculate SNN length */ |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 690 | ct_req->req.rsnn_nn.name_len = |
| 691 | (uint8_t)strlen(ct_req->req.rsnn_nn.sym_node_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | |
| 693 | /* Update MS IOCB request */ |
| 694 | ms_pkt->req_bytecount = |
| 695 | cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len); |
| 696 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; |
| 697 | |
| 698 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 699 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | sizeof(ms_iocb_entry_t)); |
| 701 | if (rval != QLA_SUCCESS) { |
| 702 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 703 | ql_dbg(ql_dbg_disc, vha, 0x2051, |
| 704 | "RSNN_NN issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 705 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RSNN_NN") != |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 706 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | rval = QLA_FUNCTION_FAILED; |
| 708 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 709 | ql_dbg(ql_dbg_disc, vha, 0x2052, |
| 710 | "RSNN_NN exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | return (rval); |
| 714 | } |
| 715 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | /** |
| 717 | * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query. |
| 718 | * @ha: HA context |
| 719 | * @cmd: GS command |
| 720 | * @scmd_len: Subcommand length |
| 721 | * @data_size: response size in bytes |
| 722 | * |
| 723 | * Returns a pointer to the @ha's sns_cmd. |
| 724 | */ |
| 725 | static inline struct sns_cmd_pkt * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 726 | qla2x00_prep_sns_cmd(scsi_qla_host_t *vha, uint16_t cmd, uint16_t scmd_len, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | uint16_t data_size) |
| 728 | { |
| 729 | uint16_t wc; |
| 730 | struct sns_cmd_pkt *sns_cmd; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 731 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | |
| 733 | sns_cmd = ha->sns_cmd; |
| 734 | memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt)); |
| 735 | wc = data_size / 2; /* Size in 16bit words. */ |
| 736 | sns_cmd->p.cmd.buffer_length = cpu_to_le16(wc); |
| 737 | sns_cmd->p.cmd.buffer_address[0] = cpu_to_le32(LSD(ha->sns_cmd_dma)); |
| 738 | sns_cmd->p.cmd.buffer_address[1] = cpu_to_le32(MSD(ha->sns_cmd_dma)); |
| 739 | sns_cmd->p.cmd.subcommand_length = cpu_to_le16(scmd_len); |
| 740 | sns_cmd->p.cmd.subcommand = cpu_to_le16(cmd); |
| 741 | wc = (data_size - 16) / 4; /* Size in 32bit words. */ |
| 742 | sns_cmd->p.cmd.size = cpu_to_le16(wc); |
| 743 | |
| 744 | return (sns_cmd); |
| 745 | } |
| 746 | |
| 747 | /** |
| 748 | * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command. |
| 749 | * @ha: HA context |
| 750 | * @fcport: fcport entry to updated |
| 751 | * |
| 752 | * This command uses the old Exectute SNS Command mailbox routine. |
| 753 | * |
| 754 | * Returns 0 on success. |
| 755 | */ |
| 756 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 757 | qla2x00_sns_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 759 | int rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 760 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | struct sns_cmd_pkt *sns_cmd; |
| 762 | |
| 763 | /* Issue GA_NXT. */ |
| 764 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 765 | sns_cmd = qla2x00_prep_sns_cmd(vha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | GA_NXT_SNS_DATA_SIZE); |
| 767 | |
| 768 | /* Prepare SNS command arguments -- port_id. */ |
| 769 | sns_cmd->p.cmd.param[0] = fcport->d_id.b.al_pa; |
| 770 | sns_cmd->p.cmd.param[1] = fcport->d_id.b.area; |
| 771 | sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain; |
| 772 | |
| 773 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 774 | rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | sizeof(struct sns_cmd_pkt)); |
| 776 | if (rval != QLA_SUCCESS) { |
| 777 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 778 | ql_dbg(ql_dbg_disc, vha, 0x205f, |
| 779 | "GA_NXT Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | } else if (sns_cmd->p.gan_data[8] != 0x80 || |
| 781 | sns_cmd->p.gan_data[9] != 0x02) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 782 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2084, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 783 | "GA_NXT failed, rejected request ga_nxt_rsp:\n"); |
| 784 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2074, |
| 785 | sns_cmd->p.gan_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | rval = QLA_FUNCTION_FAILED; |
| 787 | } else { |
| 788 | /* Populate fc_port_t entry. */ |
| 789 | fcport->d_id.b.domain = sns_cmd->p.gan_data[17]; |
| 790 | fcport->d_id.b.area = sns_cmd->p.gan_data[18]; |
| 791 | fcport->d_id.b.al_pa = sns_cmd->p.gan_data[19]; |
| 792 | |
| 793 | memcpy(fcport->node_name, &sns_cmd->p.gan_data[284], WWN_SIZE); |
| 794 | memcpy(fcport->port_name, &sns_cmd->p.gan_data[20], WWN_SIZE); |
| 795 | |
| 796 | if (sns_cmd->p.gan_data[16] != NS_N_PORT_TYPE && |
| 797 | sns_cmd->p.gan_data[16] != NS_NL_PORT_TYPE) |
| 798 | fcport->d_id.b.domain = 0xf0; |
| 799 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 800 | ql_dbg(ql_dbg_disc, vha, 0x2061, |
| 801 | "GA_NXT entry - nn %02x%02x%02x%02x%02x%02x%02x%02x " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | "pn %02x%02x%02x%02x%02x%02x%02x%02x " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 803 | "port_id=%02x%02x%02x.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | fcport->node_name[0], fcport->node_name[1], |
| 805 | fcport->node_name[2], fcport->node_name[3], |
| 806 | fcport->node_name[4], fcport->node_name[5], |
| 807 | fcport->node_name[6], fcport->node_name[7], |
| 808 | fcport->port_name[0], fcport->port_name[1], |
| 809 | fcport->port_name[2], fcport->port_name[3], |
| 810 | fcport->port_name[4], fcport->port_name[5], |
| 811 | fcport->port_name[6], fcport->port_name[7], |
| 812 | fcport->d_id.b.domain, fcport->d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 813 | fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | } |
| 815 | |
| 816 | return (rval); |
| 817 | } |
| 818 | |
| 819 | /** |
| 820 | * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command. |
| 821 | * @ha: HA context |
| 822 | * @list: switch info entries to populate |
| 823 | * |
| 824 | * This command uses the old Exectute SNS Command mailbox routine. |
| 825 | * |
| 826 | * NOTE: Non-Nx_Ports are not requested. |
| 827 | * |
| 828 | * Returns 0 on success. |
| 829 | */ |
| 830 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 831 | qla2x00_sns_gid_pt(scsi_qla_host_t *vha, sw_info_t *list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | { |
| 833 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 834 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | uint16_t i; |
| 836 | uint8_t *entry; |
| 837 | struct sns_cmd_pkt *sns_cmd; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 838 | uint16_t gid_pt_sns_data_size; |
| 839 | |
| 840 | gid_pt_sns_data_size = qla2x00_gid_pt_rsp_size(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | |
| 842 | /* Issue GID_PT. */ |
| 843 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 844 | sns_cmd = qla2x00_prep_sns_cmd(vha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 845 | gid_pt_sns_data_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | |
| 847 | /* Prepare SNS command arguments -- port_type. */ |
| 848 | sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE; |
| 849 | |
| 850 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 851 | rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | sizeof(struct sns_cmd_pkt)); |
| 853 | if (rval != QLA_SUCCESS) { |
| 854 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 855 | ql_dbg(ql_dbg_disc, vha, 0x206d, |
| 856 | "GID_PT Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | } else if (sns_cmd->p.gid_data[8] != 0x80 || |
| 858 | sns_cmd->p.gid_data[9] != 0x02) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 859 | ql_dbg(ql_dbg_disc, vha, 0x202f, |
| 860 | "GID_PT failed, rejected request, gid_rsp:\n"); |
| 861 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2081, |
| 862 | sns_cmd->p.gid_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | rval = QLA_FUNCTION_FAILED; |
| 864 | } else { |
| 865 | /* Set port IDs in switch info list. */ |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 866 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | entry = &sns_cmd->p.gid_data[(i * 4) + 16]; |
| 868 | list[i].d_id.b.domain = entry[1]; |
| 869 | list[i].d_id.b.area = entry[2]; |
| 870 | list[i].d_id.b.al_pa = entry[3]; |
| 871 | |
| 872 | /* Last one exit. */ |
| 873 | if (entry[0] & BIT_7) { |
| 874 | list[i].d_id.b.rsvd_1 = entry[0]; |
| 875 | break; |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | /* |
| 880 | * If we've used all available slots, then the switch is |
| 881 | * reporting back more devices that we can handle with this |
| 882 | * single call. Return a failed status, and let GA_NXT handle |
| 883 | * the overload. |
| 884 | */ |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 885 | if (i == ha->max_fibre_devices) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | rval = QLA_FUNCTION_FAILED; |
| 887 | } |
| 888 | |
| 889 | return (rval); |
| 890 | } |
| 891 | |
| 892 | /** |
| 893 | * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query. |
| 894 | * @ha: HA context |
| 895 | * @list: switch info entries to populate |
| 896 | * |
| 897 | * This command uses the old Exectute SNS Command mailbox routine. |
| 898 | * |
| 899 | * Returns 0 on success. |
| 900 | */ |
| 901 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 902 | qla2x00_sns_gpn_id(scsi_qla_host_t *vha, sw_info_t *list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 904 | int rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 905 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | uint16_t i; |
| 907 | struct sns_cmd_pkt *sns_cmd; |
| 908 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 909 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | /* Issue GPN_ID */ |
| 911 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 912 | sns_cmd = qla2x00_prep_sns_cmd(vha, GPN_ID_CMD, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE); |
| 914 | |
| 915 | /* Prepare SNS command arguments -- port_id. */ |
| 916 | sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa; |
| 917 | sns_cmd->p.cmd.param[1] = list[i].d_id.b.area; |
| 918 | sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain; |
| 919 | |
| 920 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 921 | rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); |
| 923 | if (rval != QLA_SUCCESS) { |
| 924 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 925 | ql_dbg(ql_dbg_disc, vha, 0x2032, |
| 926 | "GPN_ID Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | } else if (sns_cmd->p.gpn_data[8] != 0x80 || |
| 928 | sns_cmd->p.gpn_data[9] != 0x02) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 929 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x207e, |
| 930 | "GPN_ID failed, rejected request, gpn_rsp:\n"); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 931 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x207f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 932 | sns_cmd->p.gpn_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | rval = QLA_FUNCTION_FAILED; |
| 934 | } else { |
| 935 | /* Save portname */ |
| 936 | memcpy(list[i].port_name, &sns_cmd->p.gpn_data[16], |
| 937 | WWN_SIZE); |
| 938 | } |
| 939 | |
| 940 | /* Last device exit. */ |
| 941 | if (list[i].d_id.b.rsvd_1 != 0) |
| 942 | break; |
| 943 | } |
| 944 | |
| 945 | return (rval); |
| 946 | } |
| 947 | |
| 948 | /** |
| 949 | * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query. |
| 950 | * @ha: HA context |
| 951 | * @list: switch info entries to populate |
| 952 | * |
| 953 | * This command uses the old Exectute SNS Command mailbox routine. |
| 954 | * |
| 955 | * Returns 0 on success. |
| 956 | */ |
| 957 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 958 | qla2x00_sns_gnn_id(scsi_qla_host_t *vha, sw_info_t *list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 960 | int rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 961 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | uint16_t i; |
| 963 | struct sns_cmd_pkt *sns_cmd; |
| 964 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 965 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | /* Issue GNN_ID */ |
| 967 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 968 | sns_cmd = qla2x00_prep_sns_cmd(vha, GNN_ID_CMD, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE); |
| 970 | |
| 971 | /* Prepare SNS command arguments -- port_id. */ |
| 972 | sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa; |
| 973 | sns_cmd->p.cmd.param[1] = list[i].d_id.b.area; |
| 974 | sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain; |
| 975 | |
| 976 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 977 | rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); |
| 979 | if (rval != QLA_SUCCESS) { |
| 980 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 981 | ql_dbg(ql_dbg_disc, vha, 0x203f, |
| 982 | "GNN_ID Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | } else if (sns_cmd->p.gnn_data[8] != 0x80 || |
| 984 | sns_cmd->p.gnn_data[9] != 0x02) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 985 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2082, |
| 986 | "GNN_ID failed, rejected request, gnn_rsp:\n"); |
| 987 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x207a, |
| 988 | sns_cmd->p.gnn_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | rval = QLA_FUNCTION_FAILED; |
| 990 | } else { |
| 991 | /* Save nodename */ |
| 992 | memcpy(list[i].node_name, &sns_cmd->p.gnn_data[16], |
| 993 | WWN_SIZE); |
| 994 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 995 | ql_dbg(ql_dbg_disc, vha, 0x206e, |
| 996 | "GID_PT entry - nn %02x%02x%02x%02x%02x%02x%02x%02x " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | "pn %02x%02x%02x%02x%02x%02x%02x%02x " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 998 | "port_id=%02x%02x%02x.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | list[i].node_name[0], list[i].node_name[1], |
| 1000 | list[i].node_name[2], list[i].node_name[3], |
| 1001 | list[i].node_name[4], list[i].node_name[5], |
| 1002 | list[i].node_name[6], list[i].node_name[7], |
| 1003 | list[i].port_name[0], list[i].port_name[1], |
| 1004 | list[i].port_name[2], list[i].port_name[3], |
| 1005 | list[i].port_name[4], list[i].port_name[5], |
| 1006 | list[i].port_name[6], list[i].port_name[7], |
| 1007 | list[i].d_id.b.domain, list[i].d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1008 | list[i].d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | } |
| 1010 | |
| 1011 | /* Last device exit. */ |
| 1012 | if (list[i].d_id.b.rsvd_1 != 0) |
| 1013 | break; |
| 1014 | } |
| 1015 | |
| 1016 | return (rval); |
| 1017 | } |
| 1018 | |
| 1019 | /** |
| 1020 | * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA. |
| 1021 | * @ha: HA context |
| 1022 | * |
| 1023 | * This command uses the old Exectute SNS Command mailbox routine. |
| 1024 | * |
| 1025 | * Returns 0 on success. |
| 1026 | */ |
| 1027 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1028 | qla2x00_sns_rft_id(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | { |
| 1030 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1031 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | struct sns_cmd_pkt *sns_cmd; |
| 1033 | |
| 1034 | /* Issue RFT_ID. */ |
| 1035 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1036 | sns_cmd = qla2x00_prep_sns_cmd(vha, RFT_ID_CMD, RFT_ID_SNS_SCMD_LEN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | RFT_ID_SNS_DATA_SIZE); |
| 1038 | |
| 1039 | /* Prepare SNS command arguments -- port_id, FC-4 types */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1040 | sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa; |
| 1041 | sns_cmd->p.cmd.param[1] = vha->d_id.b.area; |
| 1042 | sns_cmd->p.cmd.param[2] = vha->d_id.b.domain; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 | |
| 1044 | sns_cmd->p.cmd.param[5] = 0x01; /* FCP-3 */ |
| 1045 | |
| 1046 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1047 | rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, RFT_ID_SNS_CMD_SIZE / 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | sizeof(struct sns_cmd_pkt)); |
| 1049 | if (rval != QLA_SUCCESS) { |
| 1050 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1051 | ql_dbg(ql_dbg_disc, vha, 0x2060, |
| 1052 | "RFT_ID Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | } else if (sns_cmd->p.rft_data[8] != 0x80 || |
| 1054 | sns_cmd->p.rft_data[9] != 0x02) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1055 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2083, |
| 1056 | "RFT_ID failed, rejected request rft_rsp:\n"); |
| 1057 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2080, |
| 1058 | sns_cmd->p.rft_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | rval = QLA_FUNCTION_FAILED; |
| 1060 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1061 | ql_dbg(ql_dbg_disc, vha, 0x2073, |
| 1062 | "RFT_ID exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | } |
| 1064 | |
| 1065 | return (rval); |
| 1066 | } |
| 1067 | |
| 1068 | /** |
| 1069 | * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA. |
| 1070 | * HBA. |
| 1071 | * @ha: HA context |
| 1072 | * |
| 1073 | * This command uses the old Exectute SNS Command mailbox routine. |
| 1074 | * |
| 1075 | * Returns 0 on success. |
| 1076 | */ |
| 1077 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1078 | qla2x00_sns_rnn_id(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | { |
| 1080 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1081 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1082 | struct sns_cmd_pkt *sns_cmd; |
| 1083 | |
| 1084 | /* Issue RNN_ID. */ |
| 1085 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1086 | sns_cmd = qla2x00_prep_sns_cmd(vha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1087 | RNN_ID_SNS_DATA_SIZE); |
| 1088 | |
| 1089 | /* Prepare SNS command arguments -- port_id, nodename. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1090 | sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa; |
| 1091 | sns_cmd->p.cmd.param[1] = vha->d_id.b.area; |
| 1092 | sns_cmd->p.cmd.param[2] = vha->d_id.b.domain; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1094 | sns_cmd->p.cmd.param[4] = vha->node_name[7]; |
| 1095 | sns_cmd->p.cmd.param[5] = vha->node_name[6]; |
| 1096 | sns_cmd->p.cmd.param[6] = vha->node_name[5]; |
| 1097 | sns_cmd->p.cmd.param[7] = vha->node_name[4]; |
| 1098 | sns_cmd->p.cmd.param[8] = vha->node_name[3]; |
| 1099 | sns_cmd->p.cmd.param[9] = vha->node_name[2]; |
| 1100 | sns_cmd->p.cmd.param[10] = vha->node_name[1]; |
| 1101 | sns_cmd->p.cmd.param[11] = vha->node_name[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | |
| 1103 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1104 | rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | sizeof(struct sns_cmd_pkt)); |
| 1106 | if (rval != QLA_SUCCESS) { |
| 1107 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1108 | ql_dbg(ql_dbg_disc, vha, 0x204a, |
| 1109 | "RNN_ID Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | } else if (sns_cmd->p.rnn_data[8] != 0x80 || |
| 1111 | sns_cmd->p.rnn_data[9] != 0x02) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1112 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x207b, |
| 1113 | "RNN_ID failed, rejected request, rnn_rsp:\n"); |
| 1114 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x207c, |
| 1115 | sns_cmd->p.rnn_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | rval = QLA_FUNCTION_FAILED; |
| 1117 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1118 | ql_dbg(ql_dbg_disc, vha, 0x204c, |
| 1119 | "RNN_ID exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | } |
| 1121 | |
| 1122 | return (rval); |
| 1123 | } |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1124 | |
| 1125 | /** |
Joe Perches | b1c1181 | 2008-02-03 17:28:22 +0200 | [diff] [blame] | 1126 | * qla2x00_mgmt_svr_login() - Login to fabric Management Service. |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1127 | * @ha: HA context |
| 1128 | * |
| 1129 | * Returns 0 on success. |
| 1130 | */ |
| 1131 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1132 | qla2x00_mgmt_svr_login(scsi_qla_host_t *vha) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1133 | { |
Chad Dupuis | 0b91d11 | 2012-02-09 11:15:42 -0800 | [diff] [blame] | 1134 | int ret, rval; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1135 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1136 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1137 | ret = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1138 | if (vha->flags.management_server_logged_in) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1139 | return ret; |
| 1140 | |
Chad Dupuis | 0b91d11 | 2012-02-09 11:15:42 -0800 | [diff] [blame] | 1141 | rval = ha->isp_ops->fabric_login(vha, vha->mgmt_svr_loop_id, 0xff, 0xff, |
Andrew Vasquez | 58570ac | 2012-08-22 14:21:18 -0400 | [diff] [blame] | 1142 | 0xfa, mb, BIT_1); |
Chad Dupuis | 0b91d11 | 2012-02-09 11:15:42 -0800 | [diff] [blame] | 1143 | if (rval != QLA_SUCCESS || mb[0] != MBS_COMMAND_COMPLETE) { |
| 1144 | if (rval == QLA_MEMORY_ALLOC_FAILED) |
| 1145 | ql_dbg(ql_dbg_disc, vha, 0x2085, |
| 1146 | "Failed management_server login: loopid=%x " |
| 1147 | "rval=%d\n", vha->mgmt_svr_loop_id, rval); |
| 1148 | else |
| 1149 | ql_dbg(ql_dbg_disc, vha, 0x2024, |
| 1150 | "Failed management_server login: loopid=%x " |
| 1151 | "mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x.\n", |
| 1152 | vha->mgmt_svr_loop_id, mb[0], mb[1], mb[2], mb[6], |
| 1153 | mb[7]); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1154 | ret = QLA_FUNCTION_FAILED; |
| 1155 | } else |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1156 | vha->flags.management_server_logged_in = 1; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1157 | |
| 1158 | return ret; |
| 1159 | } |
| 1160 | |
| 1161 | /** |
| 1162 | * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query. |
| 1163 | * @ha: HA context |
| 1164 | * @req_size: request size in bytes |
| 1165 | * @rsp_size: response size in bytes |
| 1166 | * |
| 1167 | * Returns a pointer to the @ha's ms_iocb. |
| 1168 | */ |
| 1169 | void * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1170 | qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size, |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1171 | uint32_t rsp_size) |
| 1172 | { |
| 1173 | ms_iocb_entry_t *ms_pkt; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1174 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1175 | ms_pkt = ha->ms_iocb; |
| 1176 | memset(ms_pkt, 0, sizeof(ms_iocb_entry_t)); |
| 1177 | |
| 1178 | ms_pkt->entry_type = MS_IOCB_TYPE; |
| 1179 | ms_pkt->entry_count = 1; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1180 | SET_TARGET_ID(ha, ms_pkt->loop_id, vha->mgmt_svr_loop_id); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1181 | ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 1182 | ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1183 | ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); |
| 1184 | ms_pkt->total_dsd_count = __constant_cpu_to_le16(2); |
| 1185 | ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size); |
| 1186 | ms_pkt->req_bytecount = cpu_to_le32(req_size); |
| 1187 | |
| 1188 | ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 1189 | ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 1190 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; |
| 1191 | |
| 1192 | ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 1193 | ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 1194 | ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount; |
| 1195 | |
| 1196 | return ms_pkt; |
| 1197 | } |
| 1198 | |
| 1199 | /** |
| 1200 | * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query. |
| 1201 | * @ha: HA context |
| 1202 | * @req_size: request size in bytes |
| 1203 | * @rsp_size: response size in bytes |
| 1204 | * |
| 1205 | * Returns a pointer to the @ha's ms_iocb. |
| 1206 | */ |
| 1207 | void * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1208 | qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size, |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1209 | uint32_t rsp_size) |
| 1210 | { |
| 1211 | struct ct_entry_24xx *ct_pkt; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1212 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1213 | |
| 1214 | ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; |
| 1215 | memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); |
| 1216 | |
| 1217 | ct_pkt->entry_type = CT_IOCB_TYPE; |
| 1218 | ct_pkt->entry_count = 1; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1219 | ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 1220 | ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1221 | ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); |
| 1222 | ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1); |
| 1223 | ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size); |
| 1224 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); |
| 1225 | |
| 1226 | ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 1227 | ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 1228 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; |
| 1229 | |
| 1230 | ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 1231 | ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 1232 | ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1233 | ct_pkt->vp_index = vha->vp_idx; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1234 | |
| 1235 | return ct_pkt; |
| 1236 | } |
| 1237 | |
| 1238 | static inline ms_iocb_entry_t * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1239 | qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1240 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1241 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1242 | ms_iocb_entry_t *ms_pkt = ha->ms_iocb; |
| 1243 | struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; |
| 1244 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1245 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1246 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); |
| 1247 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; |
| 1248 | } else { |
| 1249 | ms_pkt->req_bytecount = cpu_to_le32(req_size); |
| 1250 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; |
| 1251 | } |
| 1252 | |
| 1253 | return ms_pkt; |
| 1254 | } |
| 1255 | |
| 1256 | /** |
| 1257 | * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query. |
| 1258 | * @ct_req: CT request buffer |
| 1259 | * @cmd: GS command |
| 1260 | * @rsp_size: response size in bytes |
| 1261 | * |
| 1262 | * Returns a pointer to the intitialized @ct_req. |
| 1263 | */ |
| 1264 | static inline struct ct_sns_req * |
| 1265 | qla2x00_prep_ct_fdmi_req(struct ct_sns_req *ct_req, uint16_t cmd, |
| 1266 | uint16_t rsp_size) |
| 1267 | { |
| 1268 | memset(ct_req, 0, sizeof(struct ct_sns_pkt)); |
| 1269 | |
| 1270 | ct_req->header.revision = 0x01; |
| 1271 | ct_req->header.gs_type = 0xFA; |
| 1272 | ct_req->header.gs_subtype = 0x10; |
| 1273 | ct_req->command = cpu_to_be16(cmd); |
| 1274 | ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); |
| 1275 | |
| 1276 | return ct_req; |
| 1277 | } |
| 1278 | |
| 1279 | /** |
| 1280 | * qla2x00_fdmi_rhba() - |
| 1281 | * @ha: HA context |
| 1282 | * |
| 1283 | * Returns 0 on success. |
| 1284 | */ |
| 1285 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1286 | qla2x00_fdmi_rhba(scsi_qla_host_t *vha) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1287 | { |
| 1288 | int rval, alen; |
| 1289 | uint32_t size, sn; |
| 1290 | |
| 1291 | ms_iocb_entry_t *ms_pkt; |
| 1292 | struct ct_sns_req *ct_req; |
| 1293 | struct ct_sns_rsp *ct_rsp; |
| 1294 | uint8_t *entries; |
| 1295 | struct ct_fdmi_hba_attr *eiter; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1296 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1297 | |
| 1298 | /* Issue RHBA */ |
| 1299 | /* Prepare common MS IOCB */ |
| 1300 | /* Request size adjusted after CT preparation */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1301 | ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1302 | |
| 1303 | /* Prepare CT request */ |
| 1304 | ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, |
| 1305 | RHBA_RSP_SIZE); |
| 1306 | ct_rsp = &ha->ct_sns->p.rsp; |
| 1307 | |
| 1308 | /* Prepare FDMI command arguments -- attribute block, attributes. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1309 | memcpy(ct_req->req.rhba.hba_identifier, vha->port_name, WWN_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1310 | ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1311 | memcpy(ct_req->req.rhba.port_name, vha->port_name, WWN_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1312 | size = 2 * WWN_SIZE + 4 + 4; |
| 1313 | |
| 1314 | /* Attributes */ |
| 1315 | ct_req->req.rhba.attrs.count = |
| 1316 | __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT); |
| 1317 | entries = ct_req->req.rhba.hba_identifier; |
| 1318 | |
| 1319 | /* Nodename. */ |
| 1320 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); |
| 1321 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME); |
| 1322 | eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1323 | memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1324 | size += 4 + WWN_SIZE; |
| 1325 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1326 | ql_dbg(ql_dbg_disc, vha, 0x2025, |
| 1327 | "NodeName = %02x%02x%02x%02x%02x%02x%02x%02x.\n", |
| 1328 | eiter->a.node_name[0], eiter->a.node_name[1], |
| 1329 | eiter->a.node_name[2], eiter->a.node_name[3], |
| 1330 | eiter->a.node_name[4], eiter->a.node_name[5], |
| 1331 | eiter->a.node_name[6], eiter->a.node_name[7]); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1332 | |
| 1333 | /* Manufacturer. */ |
| 1334 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); |
| 1335 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER); |
Paul Bolle | f24b697 | 2013-02-08 01:57:55 -0500 | [diff] [blame] | 1336 | alen = strlen(QLA2XXX_MANUFACTURER); |
| 1337 | strncpy(eiter->a.manufacturer, QLA2XXX_MANUFACTURER, alen + 1); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1338 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; |
| 1339 | eiter->len = cpu_to_be16(4 + alen); |
| 1340 | size += 4 + alen; |
| 1341 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1342 | ql_dbg(ql_dbg_disc, vha, 0x2026, |
| 1343 | "Manufacturer = %s.\n", eiter->a.manufacturer); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1344 | |
| 1345 | /* Serial number. */ |
| 1346 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); |
| 1347 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER); |
| 1348 | sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; |
| 1349 | sprintf(eiter->a.serial_num, "%c%05d", 'A' + sn / 100000, sn % 100000); |
| 1350 | alen = strlen(eiter->a.serial_num); |
| 1351 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; |
| 1352 | eiter->len = cpu_to_be16(4 + alen); |
| 1353 | size += 4 + alen; |
| 1354 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1355 | ql_dbg(ql_dbg_disc, vha, 0x2027, |
| 1356 | "Serial no. = %s.\n", eiter->a.serial_num); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1357 | |
| 1358 | /* Model name. */ |
| 1359 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); |
| 1360 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL); |
| 1361 | strcpy(eiter->a.model, ha->model_number); |
| 1362 | alen = strlen(eiter->a.model); |
| 1363 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; |
| 1364 | eiter->len = cpu_to_be16(4 + alen); |
| 1365 | size += 4 + alen; |
| 1366 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1367 | ql_dbg(ql_dbg_disc, vha, 0x2028, |
| 1368 | "Model Name = %s.\n", eiter->a.model); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1369 | |
| 1370 | /* Model description. */ |
| 1371 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); |
| 1372 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); |
Bart Van Assche | c5dcfaa | 2013-06-25 11:27:25 -0400 | [diff] [blame] | 1373 | strncpy(eiter->a.model_desc, ha->model_desc, 80); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1374 | alen = strlen(eiter->a.model_desc); |
| 1375 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; |
| 1376 | eiter->len = cpu_to_be16(4 + alen); |
| 1377 | size += 4 + alen; |
| 1378 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1379 | ql_dbg(ql_dbg_disc, vha, 0x2029, |
| 1380 | "Model Desc = %s.\n", eiter->a.model_desc); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1381 | |
| 1382 | /* Hardware version. */ |
| 1383 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); |
| 1384 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); |
| 1385 | strcpy(eiter->a.hw_version, ha->adapter_id); |
| 1386 | alen = strlen(eiter->a.hw_version); |
| 1387 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; |
| 1388 | eiter->len = cpu_to_be16(4 + alen); |
| 1389 | size += 4 + alen; |
| 1390 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1391 | ql_dbg(ql_dbg_disc, vha, 0x202a, |
| 1392 | "Hardware ver = %s.\n", eiter->a.hw_version); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1393 | |
| 1394 | /* Driver version. */ |
| 1395 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); |
| 1396 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION); |
| 1397 | strcpy(eiter->a.driver_version, qla2x00_version_str); |
| 1398 | alen = strlen(eiter->a.driver_version); |
| 1399 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; |
| 1400 | eiter->len = cpu_to_be16(4 + alen); |
| 1401 | size += 4 + alen; |
| 1402 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1403 | ql_dbg(ql_dbg_disc, vha, 0x202b, |
| 1404 | "Driver ver = %s.\n", eiter->a.driver_version); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1405 | |
| 1406 | /* Option ROM version. */ |
| 1407 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); |
| 1408 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION); |
| 1409 | strcpy(eiter->a.orom_version, "0.00"); |
| 1410 | alen = strlen(eiter->a.orom_version); |
| 1411 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; |
| 1412 | eiter->len = cpu_to_be16(4 + alen); |
| 1413 | size += 4 + alen; |
| 1414 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1415 | ql_dbg(ql_dbg_disc, vha , 0x202c, |
| 1416 | "Optrom vers = %s.\n", eiter->a.orom_version); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1417 | |
| 1418 | /* Firmware version */ |
| 1419 | eiter = (struct ct_fdmi_hba_attr *) (entries + size); |
| 1420 | eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1421 | ha->isp_ops->fw_version_str(vha, eiter->a.fw_version); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1422 | alen = strlen(eiter->a.fw_version); |
| 1423 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; |
| 1424 | eiter->len = cpu_to_be16(4 + alen); |
| 1425 | size += 4 + alen; |
| 1426 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1427 | ql_dbg(ql_dbg_disc, vha, 0x202d, |
| 1428 | "Firmware vers = %s.\n", eiter->a.fw_version); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1429 | |
| 1430 | /* Update MS request size. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1431 | qla2x00_update_ms_fdmi_iocb(vha, size + 16); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1432 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1433 | ql_dbg(ql_dbg_disc, vha, 0x202e, |
| 1434 | "RHBA identifier = " |
| 1435 | "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", |
| 1436 | ct_req->req.rhba.hba_identifier[0], |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1437 | ct_req->req.rhba.hba_identifier[1], |
| 1438 | ct_req->req.rhba.hba_identifier[2], |
| 1439 | ct_req->req.rhba.hba_identifier[3], |
| 1440 | ct_req->req.rhba.hba_identifier[4], |
| 1441 | ct_req->req.rhba.hba_identifier[5], |
| 1442 | ct_req->req.rhba.hba_identifier[6], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1443 | ct_req->req.rhba.hba_identifier[7], size); |
| 1444 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2076, |
| 1445 | entries, size); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1446 | |
| 1447 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1448 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1449 | sizeof(ms_iocb_entry_t)); |
| 1450 | if (rval != QLA_SUCCESS) { |
| 1451 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1452 | ql_dbg(ql_dbg_disc, vha, 0x2030, |
| 1453 | "RHBA issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1454 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RHBA") != |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1455 | QLA_SUCCESS) { |
| 1456 | rval = QLA_FUNCTION_FAILED; |
| 1457 | if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && |
| 1458 | ct_rsp->header.explanation_code == |
| 1459 | CT_EXPL_ALREADY_REGISTERED) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1460 | ql_dbg(ql_dbg_disc, vha, 0x2034, |
| 1461 | "HBA already registered.\n"); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1462 | rval = QLA_ALREADY_REGISTERED; |
| 1463 | } |
| 1464 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1465 | ql_dbg(ql_dbg_disc, vha, 0x2035, |
| 1466 | "RHBA exiting normally.\n"); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1467 | } |
| 1468 | |
| 1469 | return rval; |
| 1470 | } |
| 1471 | |
| 1472 | /** |
| 1473 | * qla2x00_fdmi_dhba() - |
| 1474 | * @ha: HA context |
| 1475 | * |
| 1476 | * Returns 0 on success. |
| 1477 | */ |
| 1478 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1479 | qla2x00_fdmi_dhba(scsi_qla_host_t *vha) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1480 | { |
| 1481 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1482 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1483 | ms_iocb_entry_t *ms_pkt; |
| 1484 | struct ct_sns_req *ct_req; |
| 1485 | struct ct_sns_rsp *ct_rsp; |
| 1486 | |
| 1487 | /* Issue RPA */ |
| 1488 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1489 | ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, DHBA_REQ_SIZE, |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1490 | DHBA_RSP_SIZE); |
| 1491 | |
| 1492 | /* Prepare CT request */ |
| 1493 | ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, DHBA_CMD, |
| 1494 | DHBA_RSP_SIZE); |
| 1495 | ct_rsp = &ha->ct_sns->p.rsp; |
| 1496 | |
| 1497 | /* Prepare FDMI command arguments -- portname. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1498 | memcpy(ct_req->req.dhba.port_name, vha->port_name, WWN_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1499 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1500 | ql_dbg(ql_dbg_disc, vha, 0x2036, |
| 1501 | "DHBA portname = %02x%02x%02x%02x%02x%02x%02x%02x.\n", |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1502 | ct_req->req.dhba.port_name[0], ct_req->req.dhba.port_name[1], |
| 1503 | ct_req->req.dhba.port_name[2], ct_req->req.dhba.port_name[3], |
| 1504 | ct_req->req.dhba.port_name[4], ct_req->req.dhba.port_name[5], |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1505 | ct_req->req.dhba.port_name[6], ct_req->req.dhba.port_name[7]); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1506 | |
| 1507 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1508 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1509 | sizeof(ms_iocb_entry_t)); |
| 1510 | if (rval != QLA_SUCCESS) { |
| 1511 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1512 | ql_dbg(ql_dbg_disc, vha, 0x2037, |
| 1513 | "DHBA issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1514 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "DHBA") != |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1515 | QLA_SUCCESS) { |
| 1516 | rval = QLA_FUNCTION_FAILED; |
| 1517 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1518 | ql_dbg(ql_dbg_disc, vha, 0x2038, |
| 1519 | "DHBA exiting normally.\n"); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1520 | } |
| 1521 | |
| 1522 | return rval; |
| 1523 | } |
| 1524 | |
| 1525 | /** |
| 1526 | * qla2x00_fdmi_rpa() - |
| 1527 | * @ha: HA context |
| 1528 | * |
| 1529 | * Returns 0 on success. |
| 1530 | */ |
| 1531 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1532 | qla2x00_fdmi_rpa(scsi_qla_host_t *vha) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1533 | { |
| 1534 | int rval, alen; |
| 1535 | uint32_t size, max_frame_size; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1536 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1537 | ms_iocb_entry_t *ms_pkt; |
| 1538 | struct ct_sns_req *ct_req; |
| 1539 | struct ct_sns_rsp *ct_rsp; |
| 1540 | uint8_t *entries; |
| 1541 | struct ct_fdmi_port_attr *eiter; |
| 1542 | struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb; |
| 1543 | |
| 1544 | /* Issue RPA */ |
| 1545 | /* Prepare common MS IOCB */ |
| 1546 | /* Request size adjusted after CT preparation */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1547 | ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1548 | |
| 1549 | /* Prepare CT request */ |
| 1550 | ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD, |
| 1551 | RPA_RSP_SIZE); |
| 1552 | ct_rsp = &ha->ct_sns->p.rsp; |
| 1553 | |
| 1554 | /* Prepare FDMI command arguments -- attribute block, attributes. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1555 | memcpy(ct_req->req.rpa.port_name, vha->port_name, WWN_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1556 | size = WWN_SIZE + 4; |
| 1557 | |
| 1558 | /* Attributes */ |
| 1559 | ct_req->req.rpa.attrs.count = |
Andrew Vasquez | 8a85e171 | 2007-09-20 14:07:41 -0700 | [diff] [blame] | 1560 | __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT - 1); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1561 | entries = ct_req->req.rpa.port_name; |
| 1562 | |
| 1563 | /* FC4 types. */ |
| 1564 | eiter = (struct ct_fdmi_port_attr *) (entries + size); |
| 1565 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_FC4_TYPES); |
| 1566 | eiter->len = __constant_cpu_to_be16(4 + 32); |
| 1567 | eiter->a.fc4_types[2] = 0x01; |
| 1568 | size += 4 + 32; |
| 1569 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1570 | ql_dbg(ql_dbg_disc, vha, 0x2039, |
| 1571 | "FC4_TYPES=%02x %02x.\n", |
| 1572 | eiter->a.fc4_types[2], |
| 1573 | eiter->a.fc4_types[1]); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1574 | |
| 1575 | /* Supported speed. */ |
| 1576 | eiter = (struct ct_fdmi_port_attr *) (entries + size); |
| 1577 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); |
| 1578 | eiter->len = __constant_cpu_to_be16(4 + 4); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1579 | if (IS_CNA_CAPABLE(ha)) |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1580 | eiter->a.sup_speed = __constant_cpu_to_be32( |
| 1581 | FDMI_PORT_SPEED_10GB); |
| 1582 | else if (IS_QLA25XX(ha)) |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1583 | eiter->a.sup_speed = __constant_cpu_to_be32( |
| 1584 | FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB| |
| 1585 | FDMI_PORT_SPEED_4GB|FDMI_PORT_SPEED_8GB); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1586 | else if (IS_QLA24XX_TYPE(ha)) |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 1587 | eiter->a.sup_speed = __constant_cpu_to_be32( |
| 1588 | FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB| |
| 1589 | FDMI_PORT_SPEED_4GB); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1590 | else if (IS_QLA23XX(ha)) |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 1591 | eiter->a.sup_speed =__constant_cpu_to_be32( |
| 1592 | FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1593 | else |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 1594 | eiter->a.sup_speed = __constant_cpu_to_be32( |
| 1595 | FDMI_PORT_SPEED_1GB); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1596 | size += 4 + 4; |
| 1597 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1598 | ql_dbg(ql_dbg_disc, vha, 0x203a, |
| 1599 | "Supported_Speed=%x.\n", eiter->a.sup_speed); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1600 | |
| 1601 | /* Current speed. */ |
| 1602 | eiter = (struct ct_fdmi_port_attr *) (entries + size); |
| 1603 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED); |
| 1604 | eiter->len = __constant_cpu_to_be16(4 + 4); |
| 1605 | switch (ha->link_data_rate) { |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 1606 | case PORT_SPEED_1GB: |
| 1607 | eiter->a.cur_speed = |
| 1608 | __constant_cpu_to_be32(FDMI_PORT_SPEED_1GB); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1609 | break; |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 1610 | case PORT_SPEED_2GB: |
| 1611 | eiter->a.cur_speed = |
| 1612 | __constant_cpu_to_be32(FDMI_PORT_SPEED_2GB); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1613 | break; |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 1614 | case PORT_SPEED_4GB: |
| 1615 | eiter->a.cur_speed = |
| 1616 | __constant_cpu_to_be32(FDMI_PORT_SPEED_4GB); |
| 1617 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1618 | case PORT_SPEED_8GB: |
| 1619 | eiter->a.cur_speed = |
| 1620 | __constant_cpu_to_be32(FDMI_PORT_SPEED_8GB); |
| 1621 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1622 | case PORT_SPEED_10GB: |
| 1623 | eiter->a.cur_speed = |
| 1624 | __constant_cpu_to_be32(FDMI_PORT_SPEED_10GB); |
| 1625 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1626 | case PORT_SPEED_16GB: |
| 1627 | eiter->a.cur_speed = |
| 1628 | __constant_cpu_to_be32(FDMI_PORT_SPEED_16GB); |
| 1629 | break; |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 1630 | default: |
| 1631 | eiter->a.cur_speed = |
| 1632 | __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1633 | break; |
| 1634 | } |
| 1635 | size += 4 + 4; |
| 1636 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1637 | ql_dbg(ql_dbg_disc, vha, 0x203b, |
| 1638 | "Current_Speed=%x.\n", eiter->a.cur_speed); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1639 | |
| 1640 | /* Max frame size. */ |
| 1641 | eiter = (struct ct_fdmi_port_attr *) (entries + size); |
| 1642 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE); |
| 1643 | eiter->len = __constant_cpu_to_be16(4 + 4); |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1644 | max_frame_size = IS_FWI2_CAPABLE(ha) ? |
Seokmann Ju | c6852c4 | 2008-04-24 15:21:29 -0700 | [diff] [blame] | 1645 | le16_to_cpu(icb24->frame_payload_size): |
| 1646 | le16_to_cpu(ha->init_cb->frame_payload_size); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1647 | eiter->a.max_frame_size = cpu_to_be32(max_frame_size); |
| 1648 | size += 4 + 4; |
| 1649 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1650 | ql_dbg(ql_dbg_disc, vha, 0x203c, |
| 1651 | "Max_Frame_Size=%x.\n", eiter->a.max_frame_size); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1652 | |
| 1653 | /* OS device name. */ |
| 1654 | eiter = (struct ct_fdmi_port_attr *) (entries + size); |
| 1655 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME); |
Paul Bolle | f24b697 | 2013-02-08 01:57:55 -0500 | [diff] [blame] | 1656 | alen = strlen(QLA2XXX_DRIVER_NAME); |
| 1657 | strncpy(eiter->a.os_dev_name, QLA2XXX_DRIVER_NAME, alen + 1); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1658 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; |
| 1659 | eiter->len = cpu_to_be16(4 + alen); |
| 1660 | size += 4 + alen; |
| 1661 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1662 | ql_dbg(ql_dbg_disc, vha, 0x204b, |
| 1663 | "OS_Device_Name=%s.\n", eiter->a.os_dev_name); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1664 | |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1665 | /* Hostname. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1666 | if (strlen(fc_host_system_hostname(vha->host))) { |
Andrew Vasquez | 8a85e171 | 2007-09-20 14:07:41 -0700 | [diff] [blame] | 1667 | ct_req->req.rpa.attrs.count = |
| 1668 | __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT); |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1669 | eiter = (struct ct_fdmi_port_attr *) (entries + size); |
| 1670 | eiter->type = __constant_cpu_to_be16(FDMI_PORT_HOST_NAME); |
| 1671 | snprintf(eiter->a.host_name, sizeof(eiter->a.host_name), |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1672 | "%s", fc_host_system_hostname(vha->host)); |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1673 | alen = strlen(eiter->a.host_name); |
| 1674 | alen += (alen & 3) ? (4 - (alen & 3)) : 4; |
| 1675 | eiter->len = cpu_to_be16(4 + alen); |
| 1676 | size += 4 + alen; |
| 1677 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1678 | ql_dbg(ql_dbg_disc, vha, 0x203d, |
| 1679 | "HostName=%s.\n", eiter->a.host_name); |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 1680 | } |
| 1681 | |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1682 | /* Update MS request size. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1683 | qla2x00_update_ms_fdmi_iocb(vha, size + 16); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1684 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1685 | ql_dbg(ql_dbg_disc, vha, 0x203e, |
| 1686 | "RPA portname= %02x%02x%02x%02x%02X%02x%02x%02x size=%d.\n", |
| 1687 | ct_req->req.rpa.port_name[0], ct_req->req.rpa.port_name[1], |
| 1688 | ct_req->req.rpa.port_name[2], ct_req->req.rpa.port_name[3], |
| 1689 | ct_req->req.rpa.port_name[4], ct_req->req.rpa.port_name[5], |
| 1690 | ct_req->req.rpa.port_name[6], ct_req->req.rpa.port_name[7], |
| 1691 | size); |
| 1692 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2079, |
| 1693 | entries, size); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1694 | |
| 1695 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1696 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1697 | sizeof(ms_iocb_entry_t)); |
| 1698 | if (rval != QLA_SUCCESS) { |
| 1699 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1700 | ql_dbg(ql_dbg_disc, vha, 0x2040, |
| 1701 | "RPA issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1702 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RPA") != |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1703 | QLA_SUCCESS) { |
| 1704 | rval = QLA_FUNCTION_FAILED; |
| 1705 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1706 | ql_dbg(ql_dbg_disc, vha, 0x2041, |
| 1707 | "RPA exiting nornally.\n"); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1708 | } |
| 1709 | |
| 1710 | return rval; |
| 1711 | } |
| 1712 | |
| 1713 | /** |
| 1714 | * qla2x00_fdmi_register() - |
| 1715 | * @ha: HA context |
| 1716 | * |
| 1717 | * Returns 0 on success. |
| 1718 | */ |
| 1719 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1720 | qla2x00_fdmi_register(scsi_qla_host_t *vha) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1721 | { |
| 1722 | int rval; |
Andrew Vasquez | 80de7ef | 2009-07-31 15:09:33 -0700 | [diff] [blame] | 1723 | struct qla_hw_data *ha = vha->hw; |
| 1724 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1725 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || |
| 1726 | IS_QLAFX00(ha)) |
Andrew Vasquez | 80de7ef | 2009-07-31 15:09:33 -0700 | [diff] [blame] | 1727 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1728 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1729 | rval = qla2x00_mgmt_svr_login(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1730 | if (rval) |
| 1731 | return rval; |
| 1732 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1733 | rval = qla2x00_fdmi_rhba(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1734 | if (rval) { |
| 1735 | if (rval != QLA_ALREADY_REGISTERED) |
| 1736 | return rval; |
| 1737 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1738 | rval = qla2x00_fdmi_dhba(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1739 | if (rval) |
| 1740 | return rval; |
| 1741 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1742 | rval = qla2x00_fdmi_rhba(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1743 | if (rval) |
| 1744 | return rval; |
| 1745 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1746 | rval = qla2x00_fdmi_rpa(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1747 | |
| 1748 | return rval; |
| 1749 | } |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1750 | |
| 1751 | /** |
| 1752 | * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query. |
| 1753 | * @ha: HA context |
| 1754 | * @list: switch info entries to populate |
| 1755 | * |
| 1756 | * Returns 0 on success. |
| 1757 | */ |
| 1758 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1759 | qla2x00_gfpn_id(scsi_qla_host_t *vha, sw_info_t *list) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1760 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 1761 | int rval = QLA_SUCCESS; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1762 | uint16_t i; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1763 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1764 | ms_iocb_entry_t *ms_pkt; |
| 1765 | struct ct_sns_req *ct_req; |
| 1766 | struct ct_sns_rsp *ct_rsp; |
| 1767 | |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 1768 | if (!IS_IIDMA_CAPABLE(ha)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1769 | return QLA_FUNCTION_FAILED; |
| 1770 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 1771 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1772 | /* Issue GFPN_ID */ |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1773 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1774 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GFPN_ID_REQ_SIZE, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1775 | GFPN_ID_RSP_SIZE); |
| 1776 | |
| 1777 | /* Prepare CT request */ |
| 1778 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFPN_ID_CMD, |
| 1779 | GFPN_ID_RSP_SIZE); |
| 1780 | ct_rsp = &ha->ct_sns->p.rsp; |
| 1781 | |
| 1782 | /* Prepare CT arguments -- port_id */ |
| 1783 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; |
| 1784 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; |
| 1785 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; |
| 1786 | |
| 1787 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1788 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1789 | sizeof(ms_iocb_entry_t)); |
| 1790 | if (rval != QLA_SUCCESS) { |
| 1791 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1792 | ql_dbg(ql_dbg_disc, vha, 0x2023, |
| 1793 | "GFPN_ID issue IOCB failed (%d).\n", rval); |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 1794 | break; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1795 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1796 | "GFPN_ID") != QLA_SUCCESS) { |
| 1797 | rval = QLA_FUNCTION_FAILED; |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 1798 | break; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1799 | } else { |
| 1800 | /* Save fabric portname */ |
| 1801 | memcpy(list[i].fabric_port_name, |
| 1802 | ct_rsp->rsp.gfpn_id.port_name, WWN_SIZE); |
| 1803 | } |
| 1804 | |
| 1805 | /* Last device exit. */ |
| 1806 | if (list[i].d_id.b.rsvd_1 != 0) |
| 1807 | break; |
| 1808 | } |
| 1809 | |
| 1810 | return (rval); |
| 1811 | } |
| 1812 | |
| 1813 | static inline void * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1814 | qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *vha, uint32_t req_size, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1815 | uint32_t rsp_size) |
| 1816 | { |
| 1817 | struct ct_entry_24xx *ct_pkt; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1818 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1819 | ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; |
| 1820 | memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); |
| 1821 | |
| 1822 | ct_pkt->entry_type = CT_IOCB_TYPE; |
| 1823 | ct_pkt->entry_count = 1; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1824 | ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 1825 | ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1826 | ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1); |
| 1827 | ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1); |
| 1828 | ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size); |
| 1829 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); |
| 1830 | |
| 1831 | ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 1832 | ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 1833 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; |
| 1834 | |
| 1835 | ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 1836 | ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 1837 | ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1838 | ct_pkt->vp_index = vha->vp_idx; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1839 | |
| 1840 | return ct_pkt; |
| 1841 | } |
| 1842 | |
| 1843 | |
| 1844 | static inline struct ct_sns_req * |
| 1845 | qla24xx_prep_ct_fm_req(struct ct_sns_req *ct_req, uint16_t cmd, |
| 1846 | uint16_t rsp_size) |
| 1847 | { |
| 1848 | memset(ct_req, 0, sizeof(struct ct_sns_pkt)); |
| 1849 | |
| 1850 | ct_req->header.revision = 0x01; |
| 1851 | ct_req->header.gs_type = 0xFA; |
| 1852 | ct_req->header.gs_subtype = 0x01; |
| 1853 | ct_req->command = cpu_to_be16(cmd); |
| 1854 | ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); |
| 1855 | |
| 1856 | return ct_req; |
| 1857 | } |
| 1858 | |
| 1859 | /** |
| 1860 | * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query. |
| 1861 | * @ha: HA context |
| 1862 | * @list: switch info entries to populate |
| 1863 | * |
| 1864 | * Returns 0 on success. |
| 1865 | */ |
| 1866 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1867 | qla2x00_gpsc(scsi_qla_host_t *vha, sw_info_t *list) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1868 | { |
| 1869 | int rval; |
| 1870 | uint16_t i; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1871 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1872 | ms_iocb_entry_t *ms_pkt; |
| 1873 | struct ct_sns_req *ct_req; |
| 1874 | struct ct_sns_rsp *ct_rsp; |
| 1875 | |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 1876 | if (!IS_IIDMA_CAPABLE(ha)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1877 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 1878 | if (!ha->flags.gpsc_supported) |
| 1879 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1880 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1881 | rval = qla2x00_mgmt_svr_login(vha); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1882 | if (rval) |
| 1883 | return rval; |
| 1884 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 1885 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1886 | /* Issue GFPN_ID */ |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1887 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1888 | ms_pkt = qla24xx_prep_ms_fm_iocb(vha, GPSC_REQ_SIZE, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1889 | GPSC_RSP_SIZE); |
| 1890 | |
| 1891 | /* Prepare CT request */ |
| 1892 | ct_req = qla24xx_prep_ct_fm_req(&ha->ct_sns->p.req, |
| 1893 | GPSC_CMD, GPSC_RSP_SIZE); |
| 1894 | ct_rsp = &ha->ct_sns->p.rsp; |
| 1895 | |
| 1896 | /* Prepare CT arguments -- port_name */ |
| 1897 | memcpy(ct_req->req.gpsc.port_name, list[i].fabric_port_name, |
| 1898 | WWN_SIZE); |
| 1899 | |
| 1900 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1901 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1902 | sizeof(ms_iocb_entry_t)); |
| 1903 | if (rval != QLA_SUCCESS) { |
| 1904 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1905 | ql_dbg(ql_dbg_disc, vha, 0x2059, |
| 1906 | "GPSC issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1907 | } else if ((rval = qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 1908 | "GPSC")) != QLA_SUCCESS) { |
| 1909 | /* FM command unsupported? */ |
| 1910 | if (rval == QLA_INVALID_COMMAND && |
Andrew Vasquez | 3fe7cfb | 2008-04-03 13:13:23 -0700 | [diff] [blame] | 1911 | (ct_rsp->header.reason_code == |
| 1912 | CT_REASON_INVALID_COMMAND_CODE || |
| 1913 | ct_rsp->header.reason_code == |
| 1914 | CT_REASON_COMMAND_UNSUPPORTED)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1915 | ql_dbg(ql_dbg_disc, vha, 0x205a, |
| 1916 | "GPSC command unsupported, disabling " |
| 1917 | "query.\n"); |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 1918 | ha->flags.gpsc_supported = 0; |
| 1919 | rval = QLA_FUNCTION_FAILED; |
| 1920 | break; |
| 1921 | } |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1922 | rval = QLA_FUNCTION_FAILED; |
| 1923 | } else { |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 1924 | /* Save port-speed */ |
| 1925 | switch (be16_to_cpu(ct_rsp->rsp.gpsc.speed)) { |
| 1926 | case BIT_15: |
| 1927 | list[i].fp_speed = PORT_SPEED_1GB; |
| 1928 | break; |
| 1929 | case BIT_14: |
| 1930 | list[i].fp_speed = PORT_SPEED_2GB; |
| 1931 | break; |
| 1932 | case BIT_13: |
| 1933 | list[i].fp_speed = PORT_SPEED_4GB; |
| 1934 | break; |
Andrew Vasquez | 9f8fdde | 2009-06-03 09:55:22 -0700 | [diff] [blame] | 1935 | case BIT_12: |
| 1936 | list[i].fp_speed = PORT_SPEED_10GB; |
| 1937 | break; |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 1938 | case BIT_11: |
| 1939 | list[i].fp_speed = PORT_SPEED_8GB; |
| 1940 | break; |
Joe Carnuccio | c53dfac | 2012-11-21 02:40:39 -0500 | [diff] [blame] | 1941 | case BIT_10: |
| 1942 | list[i].fp_speed = PORT_SPEED_16GB; |
| 1943 | break; |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 1944 | } |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1945 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1946 | ql_dbg(ql_dbg_disc, vha, 0x205b, |
| 1947 | "GPSC ext entry - fpn " |
| 1948 | "%02x%02x%02x%02x%02x%02x%02x%02x speeds=%04x " |
| 1949 | "speed=%04x.\n", |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1950 | list[i].fabric_port_name[0], |
| 1951 | list[i].fabric_port_name[1], |
| 1952 | list[i].fabric_port_name[2], |
| 1953 | list[i].fabric_port_name[3], |
| 1954 | list[i].fabric_port_name[4], |
| 1955 | list[i].fabric_port_name[5], |
| 1956 | list[i].fabric_port_name[6], |
| 1957 | list[i].fabric_port_name[7], |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 1958 | be16_to_cpu(ct_rsp->rsp.gpsc.speeds), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1959 | be16_to_cpu(ct_rsp->rsp.gpsc.speed)); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1960 | } |
| 1961 | |
| 1962 | /* Last device exit. */ |
| 1963 | if (list[i].d_id.b.rsvd_1 != 0) |
| 1964 | break; |
| 1965 | } |
| 1966 | |
| 1967 | return (rval); |
| 1968 | } |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 1969 | |
| 1970 | /** |
| 1971 | * qla2x00_gff_id() - SNS Get FC-4 Features (GFF_ID) query. |
| 1972 | * |
| 1973 | * @ha: HA context |
| 1974 | * @list: switch info entries to populate |
| 1975 | * |
| 1976 | */ |
| 1977 | void |
| 1978 | qla2x00_gff_id(scsi_qla_host_t *vha, sw_info_t *list) |
| 1979 | { |
| 1980 | int rval; |
| 1981 | uint16_t i; |
| 1982 | |
| 1983 | ms_iocb_entry_t *ms_pkt; |
| 1984 | struct ct_sns_req *ct_req; |
| 1985 | struct ct_sns_rsp *ct_rsp; |
| 1986 | struct qla_hw_data *ha = vha->hw; |
| 1987 | uint8_t fcp_scsi_features = 0; |
| 1988 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 1989 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 1990 | /* Set default FC4 Type as UNKNOWN so the default is to |
| 1991 | * Process this port */ |
| 1992 | list[i].fc4_type = FC4_TYPE_UNKNOWN; |
| 1993 | |
| 1994 | /* Do not attempt GFF_ID if we are not FWI_2 capable */ |
| 1995 | if (!IS_FWI2_CAPABLE(ha)) |
| 1996 | continue; |
| 1997 | |
| 1998 | /* Prepare common MS IOCB */ |
| 1999 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GFF_ID_REQ_SIZE, |
| 2000 | GFF_ID_RSP_SIZE); |
| 2001 | |
| 2002 | /* Prepare CT request */ |
| 2003 | ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFF_ID_CMD, |
| 2004 | GFF_ID_RSP_SIZE); |
| 2005 | ct_rsp = &ha->ct_sns->p.rsp; |
| 2006 | |
| 2007 | /* Prepare CT arguments -- port_id */ |
| 2008 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; |
| 2009 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; |
| 2010 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; |
| 2011 | |
| 2012 | /* Execute MS IOCB */ |
| 2013 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
| 2014 | sizeof(ms_iocb_entry_t)); |
| 2015 | |
| 2016 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2017 | ql_dbg(ql_dbg_disc, vha, 0x205c, |
| 2018 | "GFF_ID issue IOCB failed (%d).\n", rval); |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2019 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, |
Andrew Vasquez | 7a78ced | 2011-02-23 15:27:12 -0800 | [diff] [blame] | 2020 | "GFF_ID") != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2021 | ql_dbg(ql_dbg_disc, vha, 0x205d, |
| 2022 | "GFF_ID IOCB status had a failure status code.\n"); |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2023 | } else { |
| 2024 | fcp_scsi_features = |
| 2025 | ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET]; |
| 2026 | fcp_scsi_features &= 0x0f; |
| 2027 | |
| 2028 | if (fcp_scsi_features) |
| 2029 | list[i].fc4_type = FC4_TYPE_FCP_SCSI; |
| 2030 | else |
| 2031 | list[i].fc4_type = FC4_TYPE_OTHER; |
| 2032 | } |
| 2033 | |
| 2034 | /* Last device exit. */ |
| 2035 | if (list[i].d_id.b.rsvd_1 != 0) |
| 2036 | break; |
| 2037 | } |
| 2038 | } |