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