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