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 |
Armen Baloyan | bd21eaf | 2014-04-11 16:54:24 -0400 | [diff] [blame] | 3 | * Copyright (c) 2003-2014 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" |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 9 | #include <linux/utsname.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | static int qla2x00_sns_ga_nxt(scsi_qla_host_t *, fc_port_t *); |
| 12 | static int qla2x00_sns_gid_pt(scsi_qla_host_t *, sw_info_t *); |
| 13 | static int qla2x00_sns_gpn_id(scsi_qla_host_t *, sw_info_t *); |
| 14 | static int qla2x00_sns_gnn_id(scsi_qla_host_t *, sw_info_t *); |
| 15 | static int qla2x00_sns_rft_id(scsi_qla_host_t *); |
| 16 | static int qla2x00_sns_rnn_id(scsi_qla_host_t *); |
| 17 | |
| 18 | /** |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 19 | * 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] | 20 | * @ha: HA context |
| 21 | * @req_size: request size in bytes |
| 22 | * @rsp_size: response size in bytes |
| 23 | * |
| 24 | * Returns a pointer to the @ha's ms_iocb. |
| 25 | */ |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 26 | void * |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 27 | qla2x00_prep_ms_iocb(scsi_qla_host_t *vha, struct ct_arg *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 29 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | ms_iocb_entry_t *ms_pkt; |
| 31 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 32 | ms_pkt = (ms_iocb_entry_t *)arg->iocb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | memset(ms_pkt, 0, sizeof(ms_iocb_entry_t)); |
| 34 | |
| 35 | ms_pkt->entry_type = MS_IOCB_TYPE; |
| 36 | ms_pkt->entry_count = 1; |
| 37 | SET_TARGET_ID(ha, ms_pkt->loop_id, SIMPLE_NAME_SERVER); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 38 | ms_pkt->control_flags = cpu_to_le16(CF_READ | CF_HEAD_TAG); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 39 | ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 40 | ms_pkt->cmd_dsd_count = cpu_to_le16(1); |
| 41 | ms_pkt->total_dsd_count = cpu_to_le16(2); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 42 | ms_pkt->rsp_bytecount = cpu_to_le32(arg->rsp_size); |
| 43 | ms_pkt->req_bytecount = cpu_to_le32(arg->req_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 45 | ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(arg->req_dma)); |
| 46 | ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(arg->req_dma)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; |
| 48 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 49 | ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(arg->rsp_dma)); |
| 50 | ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(arg->rsp_dma)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount; |
| 52 | |
Joe Carnuccio | fabbb8d | 2013-08-27 01:37:40 -0400 | [diff] [blame] | 53 | vha->qla_stats.control_requests++; |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | return (ms_pkt); |
| 56 | } |
| 57 | |
| 58 | /** |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 59 | * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query. |
| 60 | * @ha: HA context |
| 61 | * @req_size: request size in bytes |
| 62 | * @rsp_size: response size in bytes |
| 63 | * |
| 64 | * Returns a pointer to the @ha's ms_iocb. |
| 65 | */ |
| 66 | void * |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 67 | qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, struct ct_arg *arg) |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 68 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 69 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 70 | struct ct_entry_24xx *ct_pkt; |
| 71 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 72 | ct_pkt = (struct ct_entry_24xx *)arg->iocb; |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 73 | memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); |
| 74 | |
| 75 | ct_pkt->entry_type = CT_IOCB_TYPE; |
| 76 | ct_pkt->entry_count = 1; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 77 | ct_pkt->nport_handle = cpu_to_le16(arg->nport_handle); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 78 | ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 79 | ct_pkt->cmd_dsd_count = cpu_to_le16(1); |
| 80 | ct_pkt->rsp_dsd_count = cpu_to_le16(1); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 81 | ct_pkt->rsp_byte_count = cpu_to_le32(arg->rsp_size); |
| 82 | ct_pkt->cmd_byte_count = cpu_to_le32(arg->req_size); |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 83 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 84 | ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(arg->req_dma)); |
| 85 | ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(arg->req_dma)); |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 86 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; |
| 87 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 88 | ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(arg->rsp_dma)); |
| 89 | ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(arg->rsp_dma)); |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 90 | ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 91 | ct_pkt->vp_index = vha->vp_idx; |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 92 | |
Joe Carnuccio | fabbb8d | 2013-08-27 01:37:40 -0400 | [diff] [blame] | 93 | vha->qla_stats.control_requests++; |
| 94 | |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 95 | return (ct_pkt); |
| 96 | } |
| 97 | |
| 98 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query. |
| 100 | * @ct_req: CT request buffer |
| 101 | * @cmd: GS command |
| 102 | * @rsp_size: response size in bytes |
| 103 | * |
| 104 | * Returns a pointer to the intitialized @ct_req. |
| 105 | */ |
| 106 | static inline struct ct_sns_req * |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 107 | 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] | 108 | { |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 109 | memset(p, 0, sizeof(struct ct_sns_pkt)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 111 | p->p.req.header.revision = 0x01; |
| 112 | p->p.req.header.gs_type = 0xFC; |
| 113 | p->p.req.header.gs_subtype = 0x02; |
| 114 | p->p.req.command = cpu_to_be16(cmd); |
| 115 | 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] | 116 | |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 117 | return &p->p.req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | } |
| 119 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 120 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 121 | 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] | 122 | struct ct_sns_rsp *ct_rsp, const char *routine) |
| 123 | { |
| 124 | int rval; |
| 125 | uint16_t comp_status; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 126 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | b98ae0d | 2017-06-02 09:12:00 -0700 | [diff] [blame] | 127 | bool lid_is_sns = false; |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 128 | |
| 129 | rval = QLA_FUNCTION_FAILED; |
| 130 | if (ms_pkt->entry_status != 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 131 | ql_dbg(ql_dbg_disc, vha, 0x2031, |
| 132 | "%s failed, error status (%x) on port_id: %02x%02x%02x.\n", |
| 133 | routine, ms_pkt->entry_status, vha->d_id.b.domain, |
| 134 | vha->d_id.b.area, vha->d_id.b.al_pa); |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 135 | } else { |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 136 | if (IS_FWI2_CAPABLE(ha)) |
Andrew Vasquez | cdfc82a | 2006-12-13 19:20:26 -0800 | [diff] [blame] | 137 | comp_status = le16_to_cpu( |
| 138 | ((struct ct_entry_24xx *)ms_pkt)->comp_status); |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 139 | else |
| 140 | comp_status = le16_to_cpu(ms_pkt->status); |
| 141 | switch (comp_status) { |
| 142 | case CS_COMPLETE: |
| 143 | case CS_DATA_UNDERRUN: |
| 144 | case CS_DATA_OVERRUN: /* Overrun? */ |
| 145 | if (ct_rsp->header.response != |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 146 | cpu_to_be16(CT_ACCEPT_RESPONSE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 147 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2077, |
Milan P Gandhi | 5a68a1c | 2017-03-31 14:37:04 -0700 | [diff] [blame] | 148 | "%s failed rejected request on port_id: %02x%02x%02x Completion status 0x%x, response 0x%x\n", |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 149 | routine, vha->d_id.b.domain, |
| 150 | vha->d_id.b.area, vha->d_id.b.al_pa, |
| 151 | comp_status, ct_rsp->header.response); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 152 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, |
| 153 | 0x2078, (uint8_t *)&ct_rsp->header, |
| 154 | sizeof(struct ct_rsp_hdr)); |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 155 | rval = QLA_INVALID_COMMAND; |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 156 | } else |
| 157 | rval = QLA_SUCCESS; |
| 158 | break; |
Quinn Tran | b98ae0d | 2017-06-02 09:12:00 -0700 | [diff] [blame] | 159 | case CS_PORT_LOGGED_OUT: |
| 160 | if (IS_FWI2_CAPABLE(ha)) { |
| 161 | if (le16_to_cpu(ms_pkt->loop_id.extended) == |
| 162 | NPH_SNS) |
| 163 | lid_is_sns = true; |
| 164 | } else { |
| 165 | if (le16_to_cpu(ms_pkt->loop_id.extended) == |
| 166 | SIMPLE_NAME_SERVER) |
| 167 | lid_is_sns = true; |
| 168 | } |
| 169 | if (lid_is_sns) { |
| 170 | ql_dbg(ql_dbg_async, vha, 0x502b, |
| 171 | "%s failed, Name server has logged out", |
| 172 | routine); |
| 173 | rval = QLA_NOT_LOGGED_IN; |
| 174 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 175 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 176 | } |
| 177 | break; |
Quinn Tran | 25ad76b | 2017-12-04 14:45:01 -0800 | [diff] [blame] | 178 | case CS_TIMEOUT: |
| 179 | rval = QLA_FUNCTION_TIMEOUT; |
| 180 | /* drop through */ |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 181 | default: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 182 | ql_dbg(ql_dbg_disc, vha, 0x2033, |
| 183 | "%s failed, completion status (%x) on port_id: " |
| 184 | "%02x%02x%02x.\n", routine, comp_status, |
Giridhar Malavali | cf2d771 | 2011-02-23 15:27:09 -0800 | [diff] [blame] | 185 | vha->d_id.b.domain, vha->d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 186 | vha->d_id.b.al_pa); |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 187 | break; |
| 188 | } |
| 189 | } |
| 190 | return rval; |
| 191 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
| 193 | /** |
| 194 | * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command. |
| 195 | * @ha: HA context |
| 196 | * @fcport: fcport entry to updated |
| 197 | * |
| 198 | * Returns 0 on success. |
| 199 | */ |
| 200 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 201 | qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | { |
| 203 | int rval; |
| 204 | |
| 205 | ms_iocb_entry_t *ms_pkt; |
| 206 | struct ct_sns_req *ct_req; |
| 207 | struct ct_sns_rsp *ct_rsp; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 208 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 209 | struct ct_arg arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 211 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 212 | return qla2x00_sns_ga_nxt(vha, fcport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 214 | arg.iocb = ha->ms_iocb; |
| 215 | arg.req_dma = ha->ct_sns_dma; |
| 216 | arg.rsp_dma = ha->ct_sns_dma; |
| 217 | arg.req_size = GA_NXT_REQ_SIZE; |
| 218 | arg.rsp_size = GA_NXT_RSP_SIZE; |
| 219 | arg.nport_handle = NPH_SNS; |
| 220 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | /* Issue GA_NXT */ |
| 222 | /* Prepare common MS IOCB */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 223 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, &arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
| 225 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 226 | ct_req = qla2x00_prep_ct_req(ha->ct_sns, GA_NXT_CMD, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | GA_NXT_RSP_SIZE); |
| 228 | ct_rsp = &ha->ct_sns->p.rsp; |
| 229 | |
| 230 | /* Prepare CT arguments -- port_id */ |
| 231 | ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain; |
| 232 | ct_req->req.port_id.port_id[1] = fcport->d_id.b.area; |
| 233 | ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa; |
| 234 | |
| 235 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 236 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | sizeof(ms_iocb_entry_t)); |
| 238 | if (rval != QLA_SUCCESS) { |
| 239 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 240 | ql_dbg(ql_dbg_disc, vha, 0x2062, |
| 241 | "GA_NXT issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 242 | } 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] | 243 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | rval = QLA_FUNCTION_FAILED; |
| 245 | } else { |
| 246 | /* Populate fc_port_t entry. */ |
| 247 | fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0]; |
| 248 | fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1]; |
| 249 | fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2]; |
| 250 | |
| 251 | memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name, |
| 252 | WWN_SIZE); |
| 253 | memcpy(fcport->port_name, ct_rsp->rsp.ga_nxt.port_name, |
| 254 | WWN_SIZE); |
| 255 | |
Armen Baloyan | a72b990 | 2012-11-21 02:40:30 -0500 | [diff] [blame] | 256 | fcport->fc4_type = (ct_rsp->rsp.ga_nxt.fc4_types[2] & BIT_0) ? |
| 257 | FC4_TYPE_FCP_SCSI : FC4_TYPE_OTHER; |
| 258 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE && |
| 260 | ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE) |
| 261 | fcport->d_id.b.domain = 0xf0; |
| 262 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 263 | ql_dbg(ql_dbg_disc, vha, 0x2063, |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 264 | "GA_NXT entry - nn %8phN pn %8phN " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 265 | "port_id=%02x%02x%02x.\n", |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 266 | fcport->node_name, fcport->port_name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | fcport->d_id.b.domain, fcport->d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 268 | fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | return (rval); |
| 272 | } |
| 273 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 274 | static inline int |
| 275 | qla2x00_gid_pt_rsp_size(scsi_qla_host_t *vha) |
| 276 | { |
| 277 | return vha->hw->max_fibre_devices * 4 + 16; |
| 278 | } |
| 279 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | /** |
| 281 | * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command. |
| 282 | * @ha: HA context |
| 283 | * @list: switch info entries to populate |
| 284 | * |
| 285 | * NOTE: Non-Nx_Ports are not requested. |
| 286 | * |
| 287 | * Returns 0 on success. |
| 288 | */ |
| 289 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 290 | qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | { |
| 292 | int rval; |
| 293 | uint16_t i; |
| 294 | |
| 295 | ms_iocb_entry_t *ms_pkt; |
| 296 | struct ct_sns_req *ct_req; |
| 297 | struct ct_sns_rsp *ct_rsp; |
| 298 | |
| 299 | struct ct_sns_gid_pt_data *gid_data; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 300 | struct qla_hw_data *ha = vha->hw; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 301 | uint16_t gid_pt_rsp_size; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 302 | struct ct_arg arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 304 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 305 | return qla2x00_sns_gid_pt(vha, list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
| 307 | gid_data = NULL; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 308 | gid_pt_rsp_size = qla2x00_gid_pt_rsp_size(vha); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 309 | |
| 310 | arg.iocb = ha->ms_iocb; |
| 311 | arg.req_dma = ha->ct_sns_dma; |
| 312 | arg.rsp_dma = ha->ct_sns_dma; |
| 313 | arg.req_size = GID_PT_REQ_SIZE; |
| 314 | arg.rsp_size = gid_pt_rsp_size; |
| 315 | arg.nport_handle = NPH_SNS; |
| 316 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | /* Issue GID_PT */ |
| 318 | /* Prepare common MS IOCB */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 319 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, &arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | |
| 321 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 322 | 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] | 323 | ct_rsp = &ha->ct_sns->p.rsp; |
| 324 | |
| 325 | /* Prepare CT arguments -- port_type */ |
| 326 | ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE; |
| 327 | |
| 328 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 329 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | sizeof(ms_iocb_entry_t)); |
| 331 | if (rval != QLA_SUCCESS) { |
| 332 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 333 | ql_dbg(ql_dbg_disc, vha, 0x2055, |
| 334 | "GID_PT issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 335 | } 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] | 336 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | rval = QLA_FUNCTION_FAILED; |
| 338 | } else { |
| 339 | /* Set port IDs in switch info list. */ |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 340 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | gid_data = &ct_rsp->rsp.gid_pt.entries[i]; |
| 342 | list[i].d_id.b.domain = gid_data->port_id[0]; |
| 343 | list[i].d_id.b.area = gid_data->port_id[1]; |
| 344 | list[i].d_id.b.al_pa = gid_data->port_id[2]; |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 345 | memset(list[i].fabric_port_name, 0, WWN_SIZE); |
| 346 | list[i].fp_speed = PORT_SPEED_UNKNOWN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | |
| 348 | /* Last one exit. */ |
| 349 | if (gid_data->control_byte & BIT_7) { |
| 350 | list[i].d_id.b.rsvd_1 = gid_data->control_byte; |
| 351 | break; |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | /* |
| 356 | * If we've used all available slots, then the switch is |
| 357 | * reporting back more devices than we can handle with this |
| 358 | * single call. Return a failed status, and let GA_NXT handle |
| 359 | * the overload. |
| 360 | */ |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 361 | if (i == ha->max_fibre_devices) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | rval = QLA_FUNCTION_FAILED; |
| 363 | } |
| 364 | |
| 365 | return (rval); |
| 366 | } |
| 367 | |
| 368 | /** |
| 369 | * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query. |
| 370 | * @ha: HA context |
| 371 | * @list: switch info entries to populate |
| 372 | * |
| 373 | * Returns 0 on success. |
| 374 | */ |
| 375 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 376 | qla2x00_gpn_id(scsi_qla_host_t *vha, sw_info_t *list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 378 | int rval = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | uint16_t i; |
| 380 | |
| 381 | ms_iocb_entry_t *ms_pkt; |
| 382 | struct ct_sns_req *ct_req; |
| 383 | struct ct_sns_rsp *ct_rsp; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 384 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 385 | struct ct_arg arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 387 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 388 | return qla2x00_sns_gpn_id(vha, list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 390 | arg.iocb = ha->ms_iocb; |
| 391 | arg.req_dma = ha->ct_sns_dma; |
| 392 | arg.rsp_dma = ha->ct_sns_dma; |
| 393 | arg.req_size = GPN_ID_REQ_SIZE; |
| 394 | arg.rsp_size = GPN_ID_RSP_SIZE; |
| 395 | arg.nport_handle = NPH_SNS; |
| 396 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 397 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | /* Issue GPN_ID */ |
| 399 | /* Prepare common MS IOCB */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 400 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, &arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | |
| 402 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 403 | ct_req = qla2x00_prep_ct_req(ha->ct_sns, GPN_ID_CMD, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | GPN_ID_RSP_SIZE); |
| 405 | ct_rsp = &ha->ct_sns->p.rsp; |
| 406 | |
| 407 | /* Prepare CT arguments -- port_id */ |
| 408 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; |
| 409 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; |
| 410 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; |
| 411 | |
| 412 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 413 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | sizeof(ms_iocb_entry_t)); |
| 415 | if (rval != QLA_SUCCESS) { |
| 416 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 417 | ql_dbg(ql_dbg_disc, vha, 0x2056, |
| 418 | "GPN_ID issue IOCB failed (%d).\n", rval); |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 419 | break; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 420 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 421 | "GPN_ID") != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | rval = QLA_FUNCTION_FAILED; |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 423 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | } else { |
| 425 | /* Save portname */ |
| 426 | memcpy(list[i].port_name, |
| 427 | ct_rsp->rsp.gpn_id.port_name, WWN_SIZE); |
| 428 | } |
| 429 | |
| 430 | /* Last device exit. */ |
| 431 | if (list[i].d_id.b.rsvd_1 != 0) |
| 432 | break; |
| 433 | } |
| 434 | |
| 435 | return (rval); |
| 436 | } |
| 437 | |
| 438 | /** |
| 439 | * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query. |
| 440 | * @ha: HA context |
| 441 | * @list: switch info entries to populate |
| 442 | * |
| 443 | * Returns 0 on success. |
| 444 | */ |
| 445 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 446 | qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 448 | int rval = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | uint16_t i; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 450 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | ms_iocb_entry_t *ms_pkt; |
| 452 | struct ct_sns_req *ct_req; |
| 453 | struct ct_sns_rsp *ct_rsp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 454 | struct ct_arg arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 456 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 457 | return qla2x00_sns_gnn_id(vha, list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 459 | arg.iocb = ha->ms_iocb; |
| 460 | arg.req_dma = ha->ct_sns_dma; |
| 461 | arg.rsp_dma = ha->ct_sns_dma; |
| 462 | arg.req_size = GNN_ID_REQ_SIZE; |
| 463 | arg.rsp_size = GNN_ID_RSP_SIZE; |
| 464 | arg.nport_handle = NPH_SNS; |
| 465 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 466 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | /* Issue GNN_ID */ |
| 468 | /* Prepare common MS IOCB */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 469 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, &arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | |
| 471 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 472 | ct_req = qla2x00_prep_ct_req(ha->ct_sns, GNN_ID_CMD, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | GNN_ID_RSP_SIZE); |
| 474 | ct_rsp = &ha->ct_sns->p.rsp; |
| 475 | |
| 476 | /* Prepare CT arguments -- port_id */ |
| 477 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; |
| 478 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; |
| 479 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; |
| 480 | |
| 481 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 482 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | sizeof(ms_iocb_entry_t)); |
| 484 | if (rval != QLA_SUCCESS) { |
| 485 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 486 | ql_dbg(ql_dbg_disc, vha, 0x2057, |
| 487 | "GNN_ID issue IOCB failed (%d).\n", rval); |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 488 | break; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 489 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, |
Andrew Vasquez | 8c958a9 | 2005-07-06 10:30:47 -0700 | [diff] [blame] | 490 | "GNN_ID") != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | rval = QLA_FUNCTION_FAILED; |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 492 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | } else { |
| 494 | /* Save nodename */ |
| 495 | memcpy(list[i].node_name, |
| 496 | ct_rsp->rsp.gnn_id.node_name, WWN_SIZE); |
| 497 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 498 | ql_dbg(ql_dbg_disc, vha, 0x2058, |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 499 | "GID_PT entry - nn %8phN pn %8phN " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | "portid=%02x%02x%02x.\n", |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 501 | list[i].node_name, list[i].port_name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | list[i].d_id.b.domain, list[i].d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 503 | list[i].d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | /* Last device exit. */ |
| 507 | if (list[i].d_id.b.rsvd_1 != 0) |
| 508 | break; |
| 509 | } |
| 510 | |
| 511 | return (rval); |
| 512 | } |
| 513 | |
| 514 | /** |
| 515 | * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA. |
| 516 | * @ha: HA context |
| 517 | * |
| 518 | * Returns 0 on success. |
| 519 | */ |
| 520 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 521 | qla2x00_rft_id(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | { |
| 523 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 524 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | ms_iocb_entry_t *ms_pkt; |
| 526 | struct ct_sns_req *ct_req; |
| 527 | struct ct_sns_rsp *ct_rsp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 528 | struct ct_arg arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 530 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 531 | return qla2x00_sns_rft_id(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 533 | arg.iocb = ha->ms_iocb; |
| 534 | arg.req_dma = ha->ct_sns_dma; |
| 535 | arg.rsp_dma = ha->ct_sns_dma; |
| 536 | arg.req_size = RFT_ID_REQ_SIZE; |
| 537 | arg.rsp_size = RFT_ID_RSP_SIZE; |
| 538 | arg.nport_handle = NPH_SNS; |
| 539 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | /* Issue RFT_ID */ |
| 541 | /* Prepare common MS IOCB */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 542 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, &arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
| 544 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 545 | ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFT_ID_CMD, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | RFT_ID_RSP_SIZE); |
| 547 | ct_rsp = &ha->ct_sns->p.rsp; |
| 548 | |
| 549 | /* Prepare CT arguments -- port_id, FC-4 types */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 550 | ct_req->req.rft_id.port_id[0] = vha->d_id.b.domain; |
| 551 | ct_req->req.rft_id.port_id[1] = vha->d_id.b.area; |
| 552 | 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] | 553 | |
| 554 | ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */ |
| 555 | |
Duane Grigsby | d3bae93 | 2017-06-21 13:48:44 -0700 | [diff] [blame] | 556 | if (vha->flags.nvme_enabled) |
| 557 | ct_req->req.rft_id.fc4_types[6] = 1; /* NVMe type 28h */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 559 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | sizeof(ms_iocb_entry_t)); |
| 561 | if (rval != QLA_SUCCESS) { |
| 562 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 563 | ql_dbg(ql_dbg_disc, vha, 0x2043, |
| 564 | "RFT_ID issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 565 | } 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] | 566 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | rval = QLA_FUNCTION_FAILED; |
| 568 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 569 | ql_dbg(ql_dbg_disc, vha, 0x2044, |
| 570 | "RFT_ID exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | return (rval); |
| 574 | } |
| 575 | |
| 576 | /** |
| 577 | * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA. |
| 578 | * @ha: HA context |
| 579 | * |
| 580 | * Returns 0 on success. |
| 581 | */ |
| 582 | int |
Duane Grigsby | d3bae93 | 2017-06-21 13:48:44 -0700 | [diff] [blame] | 583 | qla2x00_rff_id(scsi_qla_host_t *vha, u8 type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | { |
| 585 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 586 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | ms_iocb_entry_t *ms_pkt; |
| 588 | struct ct_sns_req *ct_req; |
| 589 | struct ct_sns_rsp *ct_rsp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 590 | struct ct_arg arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | |
| 592 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 593 | ql_dbg(ql_dbg_disc, vha, 0x2046, |
| 594 | "RFF_ID call not supported on ISP2100/ISP2200.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | return (QLA_SUCCESS); |
| 596 | } |
| 597 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 598 | arg.iocb = ha->ms_iocb; |
| 599 | arg.req_dma = ha->ct_sns_dma; |
| 600 | arg.rsp_dma = ha->ct_sns_dma; |
| 601 | arg.req_size = RFF_ID_REQ_SIZE; |
| 602 | arg.rsp_size = RFF_ID_RSP_SIZE; |
| 603 | arg.nport_handle = NPH_SNS; |
| 604 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | /* Issue RFF_ID */ |
| 606 | /* Prepare common MS IOCB */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 607 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, &arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | |
| 609 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 610 | ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFF_ID_CMD, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | RFF_ID_RSP_SIZE); |
| 612 | ct_rsp = &ha->ct_sns->p.rsp; |
| 613 | |
| 614 | /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 615 | ct_req->req.rff_id.port_id[0] = vha->d_id.b.domain; |
| 616 | ct_req->req.rff_id.port_id[1] = vha->d_id.b.area; |
| 617 | 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] | 618 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 619 | qlt_rff_id(vha, ct_req); |
| 620 | |
Duane Grigsby | d3bae93 | 2017-06-21 13:48:44 -0700 | [diff] [blame] | 621 | ct_req->req.rff_id.fc4_type = type; /* SCSI - FCP */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | |
| 623 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 624 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | sizeof(ms_iocb_entry_t)); |
| 626 | if (rval != QLA_SUCCESS) { |
| 627 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 628 | ql_dbg(ql_dbg_disc, vha, 0x2047, |
| 629 | "RFF_ID issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 630 | } 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] | 631 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | rval = QLA_FUNCTION_FAILED; |
| 633 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 634 | ql_dbg(ql_dbg_disc, vha, 0x2048, |
| 635 | "RFF_ID exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | return (rval); |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA. |
| 643 | * @ha: HA context |
| 644 | * |
| 645 | * Returns 0 on success. |
| 646 | */ |
| 647 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 648 | qla2x00_rnn_id(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | { |
| 650 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 651 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | ms_iocb_entry_t *ms_pkt; |
| 653 | struct ct_sns_req *ct_req; |
| 654 | struct ct_sns_rsp *ct_rsp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 655 | struct ct_arg arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 657 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
| 658 | return qla2x00_sns_rnn_id(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 660 | arg.iocb = ha->ms_iocb; |
| 661 | arg.req_dma = ha->ct_sns_dma; |
| 662 | arg.rsp_dma = ha->ct_sns_dma; |
| 663 | arg.req_size = RNN_ID_REQ_SIZE; |
| 664 | arg.rsp_size = RNN_ID_RSP_SIZE; |
| 665 | arg.nport_handle = NPH_SNS; |
| 666 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | /* Issue RNN_ID */ |
| 668 | /* Prepare common MS IOCB */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 669 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, &arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | |
| 671 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 672 | 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] | 673 | ct_rsp = &ha->ct_sns->p.rsp; |
| 674 | |
| 675 | /* Prepare CT arguments -- port_id, node_name */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 676 | ct_req->req.rnn_id.port_id[0] = vha->d_id.b.domain; |
| 677 | ct_req->req.rnn_id.port_id[1] = vha->d_id.b.area; |
| 678 | 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] | 679 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 680 | 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] | 681 | |
| 682 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 683 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | sizeof(ms_iocb_entry_t)); |
| 685 | if (rval != QLA_SUCCESS) { |
| 686 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 687 | ql_dbg(ql_dbg_disc, vha, 0x204d, |
| 688 | "RNN_ID issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 689 | } 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] | 690 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | rval = QLA_FUNCTION_FAILED; |
| 692 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 693 | ql_dbg(ql_dbg_disc, vha, 0x204e, |
| 694 | "RNN_ID exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | return (rval); |
| 698 | } |
| 699 | |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 700 | void |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 701 | qla2x00_get_sym_node_name(scsi_qla_host_t *vha, uint8_t *snn, size_t size) |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 702 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 703 | struct qla_hw_data *ha = vha->hw; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 704 | |
| 705 | if (IS_QLAFX00(ha)) |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 706 | snprintf(snn, size, "%s FW:v%s DVR:v%s", ha->model_number, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 707 | ha->mr.fw_version, qla2x00_version_str); |
| 708 | else |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 709 | snprintf(snn, size, |
| 710 | "%s FW:v%d.%02d.%02d DVR:v%s", ha->model_number, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 711 | ha->fw_major_version, ha->fw_minor_version, |
| 712 | ha->fw_subminor_version, qla2x00_version_str); |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 713 | } |
| 714 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | /** |
| 716 | * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA. |
| 717 | * @ha: HA context |
| 718 | * |
| 719 | * Returns 0 on success. |
| 720 | */ |
| 721 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 722 | qla2x00_rsnn_nn(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | { |
| 724 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 725 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | ms_iocb_entry_t *ms_pkt; |
| 727 | struct ct_sns_req *ct_req; |
| 728 | struct ct_sns_rsp *ct_rsp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 729 | struct ct_arg arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | |
| 731 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 732 | ql_dbg(ql_dbg_disc, vha, 0x2050, |
| 733 | "RSNN_ID call unsupported on ISP2100/ISP2200.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | return (QLA_SUCCESS); |
| 735 | } |
| 736 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 737 | arg.iocb = ha->ms_iocb; |
| 738 | arg.req_dma = ha->ct_sns_dma; |
| 739 | arg.rsp_dma = ha->ct_sns_dma; |
| 740 | arg.req_size = 0; |
| 741 | arg.rsp_size = RSNN_NN_RSP_SIZE; |
| 742 | arg.nport_handle = NPH_SNS; |
| 743 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | /* Issue RSNN_NN */ |
| 745 | /* Prepare common MS IOCB */ |
| 746 | /* Request size adjusted after CT preparation */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 747 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, &arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | |
| 749 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 750 | ct_req = qla2x00_prep_ct_req(ha->ct_sns, RSNN_NN_CMD, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | RSNN_NN_RSP_SIZE); |
| 752 | ct_rsp = &ha->ct_sns->p.rsp; |
| 753 | |
| 754 | /* Prepare CT arguments -- node_name, symbolic node_name, size */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 755 | 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] | 756 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | /* Prepare the Symbolic Node Name */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 758 | qla2x00_get_sym_node_name(vha, ct_req->req.rsnn_nn.sym_node_name, |
| 759 | sizeof(ct_req->req.rsnn_nn.sym_node_name)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | |
| 761 | /* Calculate SNN length */ |
Andrew Vasquez | 1620f7c | 2006-10-02 12:00:44 -0700 | [diff] [blame] | 762 | ct_req->req.rsnn_nn.name_len = |
| 763 | (uint8_t)strlen(ct_req->req.rsnn_nn.sym_node_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | |
| 765 | /* Update MS IOCB request */ |
| 766 | ms_pkt->req_bytecount = |
| 767 | cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len); |
| 768 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; |
| 769 | |
| 770 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 771 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | sizeof(ms_iocb_entry_t)); |
| 773 | if (rval != QLA_SUCCESS) { |
| 774 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 775 | ql_dbg(ql_dbg_disc, vha, 0x2051, |
| 776 | "RSNN_NN issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 777 | } 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] | 778 | QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | rval = QLA_FUNCTION_FAILED; |
| 780 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 781 | ql_dbg(ql_dbg_disc, vha, 0x2052, |
| 782 | "RSNN_NN exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | return (rval); |
| 786 | } |
| 787 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | /** |
| 789 | * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query. |
| 790 | * @ha: HA context |
| 791 | * @cmd: GS command |
| 792 | * @scmd_len: Subcommand length |
| 793 | * @data_size: response size in bytes |
| 794 | * |
| 795 | * Returns a pointer to the @ha's sns_cmd. |
| 796 | */ |
| 797 | static inline struct sns_cmd_pkt * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 798 | 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] | 799 | uint16_t data_size) |
| 800 | { |
| 801 | uint16_t wc; |
| 802 | struct sns_cmd_pkt *sns_cmd; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 803 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | |
| 805 | sns_cmd = ha->sns_cmd; |
| 806 | memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt)); |
| 807 | wc = data_size / 2; /* Size in 16bit words. */ |
| 808 | sns_cmd->p.cmd.buffer_length = cpu_to_le16(wc); |
| 809 | sns_cmd->p.cmd.buffer_address[0] = cpu_to_le32(LSD(ha->sns_cmd_dma)); |
| 810 | sns_cmd->p.cmd.buffer_address[1] = cpu_to_le32(MSD(ha->sns_cmd_dma)); |
| 811 | sns_cmd->p.cmd.subcommand_length = cpu_to_le16(scmd_len); |
| 812 | sns_cmd->p.cmd.subcommand = cpu_to_le16(cmd); |
| 813 | wc = (data_size - 16) / 4; /* Size in 32bit words. */ |
| 814 | sns_cmd->p.cmd.size = cpu_to_le16(wc); |
| 815 | |
Joe Carnuccio | fabbb8d | 2013-08-27 01:37:40 -0400 | [diff] [blame] | 816 | vha->qla_stats.control_requests++; |
| 817 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | return (sns_cmd); |
| 819 | } |
| 820 | |
| 821 | /** |
| 822 | * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command. |
| 823 | * @ha: HA context |
| 824 | * @fcport: fcport entry to updated |
| 825 | * |
| 826 | * This command uses the old Exectute SNS Command mailbox routine. |
| 827 | * |
| 828 | * Returns 0 on success. |
| 829 | */ |
| 830 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 831 | qla2x00_sns_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 833 | int rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 834 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | struct sns_cmd_pkt *sns_cmd; |
| 836 | |
| 837 | /* Issue GA_NXT. */ |
| 838 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 839 | 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] | 840 | GA_NXT_SNS_DATA_SIZE); |
| 841 | |
| 842 | /* Prepare SNS command arguments -- port_id. */ |
| 843 | sns_cmd->p.cmd.param[0] = fcport->d_id.b.al_pa; |
| 844 | sns_cmd->p.cmd.param[1] = fcport->d_id.b.area; |
| 845 | sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain; |
| 846 | |
| 847 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 848 | 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] | 849 | sizeof(struct sns_cmd_pkt)); |
| 850 | if (rval != QLA_SUCCESS) { |
| 851 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 852 | ql_dbg(ql_dbg_disc, vha, 0x205f, |
| 853 | "GA_NXT Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | } else if (sns_cmd->p.gan_data[8] != 0x80 || |
| 855 | sns_cmd->p.gan_data[9] != 0x02) { |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 856 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2084, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 857 | "GA_NXT failed, rejected request ga_nxt_rsp:\n"); |
| 858 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2074, |
| 859 | sns_cmd->p.gan_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | rval = QLA_FUNCTION_FAILED; |
| 861 | } else { |
| 862 | /* Populate fc_port_t entry. */ |
| 863 | fcport->d_id.b.domain = sns_cmd->p.gan_data[17]; |
| 864 | fcport->d_id.b.area = sns_cmd->p.gan_data[18]; |
| 865 | fcport->d_id.b.al_pa = sns_cmd->p.gan_data[19]; |
| 866 | |
| 867 | memcpy(fcport->node_name, &sns_cmd->p.gan_data[284], WWN_SIZE); |
| 868 | memcpy(fcport->port_name, &sns_cmd->p.gan_data[20], WWN_SIZE); |
| 869 | |
| 870 | if (sns_cmd->p.gan_data[16] != NS_N_PORT_TYPE && |
| 871 | sns_cmd->p.gan_data[16] != NS_NL_PORT_TYPE) |
| 872 | fcport->d_id.b.domain = 0xf0; |
| 873 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 874 | ql_dbg(ql_dbg_disc, vha, 0x2061, |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 875 | "GA_NXT entry - nn %8phN pn %8phN " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 876 | "port_id=%02x%02x%02x.\n", |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 877 | fcport->node_name, fcport->port_name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | fcport->d_id.b.domain, fcport->d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 879 | fcport->d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | return (rval); |
| 883 | } |
| 884 | |
| 885 | /** |
| 886 | * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command. |
| 887 | * @ha: HA context |
| 888 | * @list: switch info entries to populate |
| 889 | * |
| 890 | * This command uses the old Exectute SNS Command mailbox routine. |
| 891 | * |
| 892 | * NOTE: Non-Nx_Ports are not requested. |
| 893 | * |
| 894 | * Returns 0 on success. |
| 895 | */ |
| 896 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 897 | 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] | 898 | { |
| 899 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 900 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | uint16_t i; |
| 902 | uint8_t *entry; |
| 903 | struct sns_cmd_pkt *sns_cmd; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 904 | uint16_t gid_pt_sns_data_size; |
| 905 | |
| 906 | gid_pt_sns_data_size = qla2x00_gid_pt_rsp_size(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | |
| 908 | /* Issue GID_PT. */ |
| 909 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 910 | 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] | 911 | gid_pt_sns_data_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | |
| 913 | /* Prepare SNS command arguments -- port_type. */ |
| 914 | sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE; |
| 915 | |
| 916 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 917 | 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] | 918 | sizeof(struct sns_cmd_pkt)); |
| 919 | if (rval != QLA_SUCCESS) { |
| 920 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 921 | ql_dbg(ql_dbg_disc, vha, 0x206d, |
| 922 | "GID_PT Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | } else if (sns_cmd->p.gid_data[8] != 0x80 || |
| 924 | sns_cmd->p.gid_data[9] != 0x02) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 925 | ql_dbg(ql_dbg_disc, vha, 0x202f, |
| 926 | "GID_PT failed, rejected request, gid_rsp:\n"); |
| 927 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2081, |
| 928 | sns_cmd->p.gid_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | rval = QLA_FUNCTION_FAILED; |
| 930 | } else { |
| 931 | /* Set port IDs in switch info list. */ |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 932 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | entry = &sns_cmd->p.gid_data[(i * 4) + 16]; |
| 934 | list[i].d_id.b.domain = entry[1]; |
| 935 | list[i].d_id.b.area = entry[2]; |
| 936 | list[i].d_id.b.al_pa = entry[3]; |
| 937 | |
| 938 | /* Last one exit. */ |
| 939 | if (entry[0] & BIT_7) { |
| 940 | list[i].d_id.b.rsvd_1 = entry[0]; |
| 941 | break; |
| 942 | } |
| 943 | } |
| 944 | |
| 945 | /* |
| 946 | * If we've used all available slots, then the switch is |
| 947 | * reporting back more devices that we can handle with this |
| 948 | * single call. Return a failed status, and let GA_NXT handle |
| 949 | * the overload. |
| 950 | */ |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 951 | if (i == ha->max_fibre_devices) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | rval = QLA_FUNCTION_FAILED; |
| 953 | } |
| 954 | |
| 955 | return (rval); |
| 956 | } |
| 957 | |
| 958 | /** |
| 959 | * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query. |
| 960 | * @ha: HA context |
| 961 | * @list: switch info entries to populate |
| 962 | * |
| 963 | * This command uses the old Exectute SNS Command mailbox routine. |
| 964 | * |
| 965 | * Returns 0 on success. |
| 966 | */ |
| 967 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 968 | 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] | 969 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 970 | int rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 971 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | uint16_t i; |
| 973 | struct sns_cmd_pkt *sns_cmd; |
| 974 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 975 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | /* Issue GPN_ID */ |
| 977 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 978 | sns_cmd = qla2x00_prep_sns_cmd(vha, GPN_ID_CMD, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE); |
| 980 | |
| 981 | /* Prepare SNS command arguments -- port_id. */ |
| 982 | sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa; |
| 983 | sns_cmd->p.cmd.param[1] = list[i].d_id.b.area; |
| 984 | sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain; |
| 985 | |
| 986 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 987 | rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); |
| 989 | if (rval != QLA_SUCCESS) { |
| 990 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 991 | ql_dbg(ql_dbg_disc, vha, 0x2032, |
| 992 | "GPN_ID Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | } else if (sns_cmd->p.gpn_data[8] != 0x80 || |
| 994 | sns_cmd->p.gpn_data[9] != 0x02) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 995 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x207e, |
| 996 | "GPN_ID failed, rejected request, gpn_rsp:\n"); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 997 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x207f, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 998 | sns_cmd->p.gpn_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | rval = QLA_FUNCTION_FAILED; |
| 1000 | } else { |
| 1001 | /* Save portname */ |
| 1002 | memcpy(list[i].port_name, &sns_cmd->p.gpn_data[16], |
| 1003 | WWN_SIZE); |
| 1004 | } |
| 1005 | |
| 1006 | /* Last device exit. */ |
| 1007 | if (list[i].d_id.b.rsvd_1 != 0) |
| 1008 | break; |
| 1009 | } |
| 1010 | |
| 1011 | return (rval); |
| 1012 | } |
| 1013 | |
| 1014 | /** |
| 1015 | * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query. |
| 1016 | * @ha: HA context |
| 1017 | * @list: switch info entries to populate |
| 1018 | * |
| 1019 | * This command uses the old Exectute SNS Command mailbox routine. |
| 1020 | * |
| 1021 | * Returns 0 on success. |
| 1022 | */ |
| 1023 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1024 | 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] | 1025 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 1026 | int rval = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1027 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1028 | uint16_t i; |
| 1029 | struct sns_cmd_pkt *sns_cmd; |
| 1030 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 1031 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | /* Issue GNN_ID */ |
| 1033 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1034 | sns_cmd = qla2x00_prep_sns_cmd(vha, GNN_ID_CMD, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE); |
| 1036 | |
| 1037 | /* Prepare SNS command arguments -- port_id. */ |
| 1038 | sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa; |
| 1039 | sns_cmd->p.cmd.param[1] = list[i].d_id.b.area; |
| 1040 | sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain; |
| 1041 | |
| 1042 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1043 | rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt)); |
| 1045 | if (rval != QLA_SUCCESS) { |
| 1046 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1047 | ql_dbg(ql_dbg_disc, vha, 0x203f, |
| 1048 | "GNN_ID Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | } else if (sns_cmd->p.gnn_data[8] != 0x80 || |
| 1050 | sns_cmd->p.gnn_data[9] != 0x02) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1051 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2082, |
| 1052 | "GNN_ID failed, rejected request, gnn_rsp:\n"); |
| 1053 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x207a, |
| 1054 | sns_cmd->p.gnn_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | rval = QLA_FUNCTION_FAILED; |
| 1056 | } else { |
| 1057 | /* Save nodename */ |
| 1058 | memcpy(list[i].node_name, &sns_cmd->p.gnn_data[16], |
| 1059 | WWN_SIZE); |
| 1060 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1061 | ql_dbg(ql_dbg_disc, vha, 0x206e, |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 1062 | "GID_PT entry - nn %8phN pn %8phN " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1063 | "port_id=%02x%02x%02x.\n", |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 1064 | list[i].node_name, list[i].port_name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | list[i].d_id.b.domain, list[i].d_id.b.area, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1066 | list[i].d_id.b.al_pa); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | } |
| 1068 | |
| 1069 | /* Last device exit. */ |
| 1070 | if (list[i].d_id.b.rsvd_1 != 0) |
| 1071 | break; |
| 1072 | } |
| 1073 | |
| 1074 | return (rval); |
| 1075 | } |
| 1076 | |
| 1077 | /** |
| 1078 | * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA. |
| 1079 | * @ha: HA context |
| 1080 | * |
| 1081 | * This command uses the old Exectute SNS Command mailbox routine. |
| 1082 | * |
| 1083 | * Returns 0 on success. |
| 1084 | */ |
| 1085 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1086 | qla2x00_sns_rft_id(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1087 | { |
| 1088 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1089 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1090 | struct sns_cmd_pkt *sns_cmd; |
| 1091 | |
| 1092 | /* Issue RFT_ID. */ |
| 1093 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1094 | 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] | 1095 | RFT_ID_SNS_DATA_SIZE); |
| 1096 | |
| 1097 | /* Prepare SNS command arguments -- port_id, FC-4 types */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1098 | sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa; |
| 1099 | sns_cmd->p.cmd.param[1] = vha->d_id.b.area; |
| 1100 | sns_cmd->p.cmd.param[2] = vha->d_id.b.domain; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | |
| 1102 | sns_cmd->p.cmd.param[5] = 0x01; /* FCP-3 */ |
| 1103 | |
| 1104 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1105 | 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] | 1106 | sizeof(struct sns_cmd_pkt)); |
| 1107 | if (rval != QLA_SUCCESS) { |
| 1108 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1109 | ql_dbg(ql_dbg_disc, vha, 0x2060, |
| 1110 | "RFT_ID Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | } else if (sns_cmd->p.rft_data[8] != 0x80 || |
| 1112 | sns_cmd->p.rft_data[9] != 0x02) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1113 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x2083, |
| 1114 | "RFT_ID failed, rejected request rft_rsp:\n"); |
| 1115 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2080, |
| 1116 | sns_cmd->p.rft_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1117 | rval = QLA_FUNCTION_FAILED; |
| 1118 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1119 | ql_dbg(ql_dbg_disc, vha, 0x2073, |
| 1120 | "RFT_ID exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | return (rval); |
| 1124 | } |
| 1125 | |
| 1126 | /** |
| 1127 | * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA. |
| 1128 | * HBA. |
| 1129 | * @ha: HA context |
| 1130 | * |
| 1131 | * This command uses the old Exectute SNS Command mailbox routine. |
| 1132 | * |
| 1133 | * Returns 0 on success. |
| 1134 | */ |
| 1135 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1136 | qla2x00_sns_rnn_id(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | { |
| 1138 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1139 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | struct sns_cmd_pkt *sns_cmd; |
| 1141 | |
| 1142 | /* Issue RNN_ID. */ |
| 1143 | /* Prepare SNS command request. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1144 | 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] | 1145 | RNN_ID_SNS_DATA_SIZE); |
| 1146 | |
| 1147 | /* Prepare SNS command arguments -- port_id, nodename. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1148 | sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa; |
| 1149 | sns_cmd->p.cmd.param[1] = vha->d_id.b.area; |
| 1150 | sns_cmd->p.cmd.param[2] = vha->d_id.b.domain; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1152 | sns_cmd->p.cmd.param[4] = vha->node_name[7]; |
| 1153 | sns_cmd->p.cmd.param[5] = vha->node_name[6]; |
| 1154 | sns_cmd->p.cmd.param[6] = vha->node_name[5]; |
| 1155 | sns_cmd->p.cmd.param[7] = vha->node_name[4]; |
| 1156 | sns_cmd->p.cmd.param[8] = vha->node_name[3]; |
| 1157 | sns_cmd->p.cmd.param[9] = vha->node_name[2]; |
| 1158 | sns_cmd->p.cmd.param[10] = vha->node_name[1]; |
| 1159 | sns_cmd->p.cmd.param[11] = vha->node_name[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | |
| 1161 | /* Execute SNS command. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1162 | 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] | 1163 | sizeof(struct sns_cmd_pkt)); |
| 1164 | if (rval != QLA_SUCCESS) { |
| 1165 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1166 | ql_dbg(ql_dbg_disc, vha, 0x204a, |
| 1167 | "RNN_ID Send SNS failed (%d).\n", rval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | } else if (sns_cmd->p.rnn_data[8] != 0x80 || |
| 1169 | sns_cmd->p.rnn_data[9] != 0x02) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1170 | ql_dbg(ql_dbg_disc + ql_dbg_buffer, vha, 0x207b, |
| 1171 | "RNN_ID failed, rejected request, rnn_rsp:\n"); |
| 1172 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x207c, |
| 1173 | sns_cmd->p.rnn_data, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1174 | rval = QLA_FUNCTION_FAILED; |
| 1175 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1176 | ql_dbg(ql_dbg_disc, vha, 0x204c, |
| 1177 | "RNN_ID exiting normally.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | } |
| 1179 | |
| 1180 | return (rval); |
| 1181 | } |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1182 | |
| 1183 | /** |
Joe Perches | b1c1181 | 2008-02-03 17:28:22 +0200 | [diff] [blame] | 1184 | * qla2x00_mgmt_svr_login() - Login to fabric Management Service. |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1185 | * @ha: HA context |
| 1186 | * |
| 1187 | * Returns 0 on success. |
| 1188 | */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 1189 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1190 | qla2x00_mgmt_svr_login(scsi_qla_host_t *vha) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1191 | { |
Chad Dupuis | 0b91d11 | 2012-02-09 11:15:42 -0800 | [diff] [blame] | 1192 | int ret, rval; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1193 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1194 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1195 | ret = QLA_SUCCESS; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1196 | if (vha->flags.management_server_logged_in) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1197 | return ret; |
| 1198 | |
Chad Dupuis | 0b91d11 | 2012-02-09 11:15:42 -0800 | [diff] [blame] | 1199 | 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] | 1200 | 0xfa, mb, BIT_1); |
Chad Dupuis | 0b91d11 | 2012-02-09 11:15:42 -0800 | [diff] [blame] | 1201 | if (rval != QLA_SUCCESS || mb[0] != MBS_COMMAND_COMPLETE) { |
| 1202 | if (rval == QLA_MEMORY_ALLOC_FAILED) |
| 1203 | ql_dbg(ql_dbg_disc, vha, 0x2085, |
| 1204 | "Failed management_server login: loopid=%x " |
| 1205 | "rval=%d\n", vha->mgmt_svr_loop_id, rval); |
| 1206 | else |
| 1207 | ql_dbg(ql_dbg_disc, vha, 0x2024, |
| 1208 | "Failed management_server login: loopid=%x " |
| 1209 | "mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x.\n", |
| 1210 | vha->mgmt_svr_loop_id, mb[0], mb[1], mb[2], mb[6], |
| 1211 | mb[7]); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1212 | ret = QLA_FUNCTION_FAILED; |
| 1213 | } else |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1214 | vha->flags.management_server_logged_in = 1; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1215 | |
| 1216 | return ret; |
| 1217 | } |
| 1218 | |
| 1219 | /** |
| 1220 | * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query. |
| 1221 | * @ha: HA context |
| 1222 | * @req_size: request size in bytes |
| 1223 | * @rsp_size: response size in bytes |
| 1224 | * |
| 1225 | * Returns a pointer to the @ha's ms_iocb. |
| 1226 | */ |
| 1227 | void * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1228 | 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] | 1229 | uint32_t rsp_size) |
| 1230 | { |
| 1231 | ms_iocb_entry_t *ms_pkt; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1232 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1233 | ms_pkt = ha->ms_iocb; |
| 1234 | memset(ms_pkt, 0, sizeof(ms_iocb_entry_t)); |
| 1235 | |
| 1236 | ms_pkt->entry_type = MS_IOCB_TYPE; |
| 1237 | ms_pkt->entry_count = 1; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1238 | SET_TARGET_ID(ha, ms_pkt->loop_id, vha->mgmt_svr_loop_id); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1239 | ms_pkt->control_flags = cpu_to_le16(CF_READ | CF_HEAD_TAG); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 1240 | ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1241 | ms_pkt->cmd_dsd_count = cpu_to_le16(1); |
| 1242 | ms_pkt->total_dsd_count = cpu_to_le16(2); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1243 | ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size); |
| 1244 | ms_pkt->req_bytecount = cpu_to_le32(req_size); |
| 1245 | |
| 1246 | ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 1247 | ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 1248 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; |
| 1249 | |
| 1250 | ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 1251 | ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 1252 | ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount; |
| 1253 | |
| 1254 | return ms_pkt; |
| 1255 | } |
| 1256 | |
| 1257 | /** |
| 1258 | * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query. |
| 1259 | * @ha: HA context |
| 1260 | * @req_size: request size in bytes |
| 1261 | * @rsp_size: response size in bytes |
| 1262 | * |
| 1263 | * Returns a pointer to the @ha's ms_iocb. |
| 1264 | */ |
| 1265 | void * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1266 | 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] | 1267 | uint32_t rsp_size) |
| 1268 | { |
| 1269 | struct ct_entry_24xx *ct_pkt; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1270 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1271 | |
| 1272 | ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; |
| 1273 | memset(ct_pkt, 0, sizeof(struct ct_entry_24xx)); |
| 1274 | |
| 1275 | ct_pkt->entry_type = CT_IOCB_TYPE; |
| 1276 | ct_pkt->entry_count = 1; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1277 | ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id); |
Andrew Vasquez | 00a537b | 2008-02-28 14:06:11 -0800 | [diff] [blame] | 1278 | ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1279 | ct_pkt->cmd_dsd_count = cpu_to_le16(1); |
| 1280 | ct_pkt->rsp_dsd_count = cpu_to_le16(1); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1281 | ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size); |
| 1282 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); |
| 1283 | |
| 1284 | ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 1285 | ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 1286 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; |
| 1287 | |
| 1288 | ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma)); |
| 1289 | ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma)); |
| 1290 | ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1291 | ct_pkt->vp_index = vha->vp_idx; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1292 | |
| 1293 | return ct_pkt; |
| 1294 | } |
| 1295 | |
| 1296 | static inline ms_iocb_entry_t * |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1297 | 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] | 1298 | { |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1299 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1300 | ms_iocb_entry_t *ms_pkt = ha->ms_iocb; |
| 1301 | struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; |
| 1302 | |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1303 | if (IS_FWI2_CAPABLE(ha)) { |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1304 | ct_pkt->cmd_byte_count = cpu_to_le32(req_size); |
| 1305 | ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; |
| 1306 | } else { |
| 1307 | ms_pkt->req_bytecount = cpu_to_le32(req_size); |
| 1308 | ms_pkt->dseg_req_length = ms_pkt->req_bytecount; |
| 1309 | } |
| 1310 | |
| 1311 | return ms_pkt; |
| 1312 | } |
| 1313 | |
| 1314 | /** |
| 1315 | * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query. |
| 1316 | * @ct_req: CT request buffer |
| 1317 | * @cmd: GS command |
| 1318 | * @rsp_size: response size in bytes |
| 1319 | * |
| 1320 | * Returns a pointer to the intitialized @ct_req. |
| 1321 | */ |
| 1322 | static inline struct ct_sns_req * |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 1323 | 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] | 1324 | uint16_t rsp_size) |
| 1325 | { |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 1326 | memset(p, 0, sizeof(struct ct_sns_pkt)); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1327 | |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 1328 | p->p.req.header.revision = 0x01; |
| 1329 | p->p.req.header.gs_type = 0xFA; |
| 1330 | p->p.req.header.gs_subtype = 0x10; |
| 1331 | p->p.req.command = cpu_to_be16(cmd); |
| 1332 | 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] | 1333 | |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 1334 | return &p->p.req; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1335 | } |
| 1336 | |
| 1337 | /** |
| 1338 | * qla2x00_fdmi_rhba() - |
| 1339 | * @ha: HA context |
| 1340 | * |
| 1341 | * Returns 0 on success. |
| 1342 | */ |
| 1343 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1344 | qla2x00_fdmi_rhba(scsi_qla_host_t *vha) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1345 | { |
| 1346 | int rval, alen; |
| 1347 | uint32_t size, sn; |
| 1348 | |
| 1349 | ms_iocb_entry_t *ms_pkt; |
| 1350 | struct ct_sns_req *ct_req; |
| 1351 | struct ct_sns_rsp *ct_rsp; |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1352 | void *entries; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1353 | struct ct_fdmi_hba_attr *eiter; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1354 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1355 | |
| 1356 | /* Issue RHBA */ |
| 1357 | /* Prepare common MS IOCB */ |
| 1358 | /* Request size adjusted after CT preparation */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1359 | 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] | 1360 | |
| 1361 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 1362 | 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] | 1363 | ct_rsp = &ha->ct_sns->p.rsp; |
| 1364 | |
| 1365 | /* Prepare FDMI command arguments -- attribute block, attributes. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1366 | memcpy(ct_req->req.rhba.hba_identifier, vha->port_name, WWN_SIZE); |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1367 | ct_req->req.rhba.entry_count = cpu_to_be32(1); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1368 | memcpy(ct_req->req.rhba.port_name, vha->port_name, WWN_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1369 | size = 2 * WWN_SIZE + 4 + 4; |
| 1370 | |
| 1371 | /* Attributes */ |
| 1372 | ct_req->req.rhba.attrs.count = |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1373 | cpu_to_be32(FDMI_HBA_ATTR_COUNT); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1374 | entries = ct_req->req.rhba.hba_identifier; |
| 1375 | |
| 1376 | /* Nodename. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1377 | eiter = entries + size; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1378 | eiter->type = cpu_to_be16(FDMI_HBA_NODE_NAME); |
| 1379 | eiter->len = cpu_to_be16(4 + WWN_SIZE); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1380 | memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1381 | size += 4 + WWN_SIZE; |
| 1382 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1383 | ql_dbg(ql_dbg_disc, vha, 0x2025, |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 1384 | "NodeName = %8phN.\n", eiter->a.node_name); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1385 | |
| 1386 | /* Manufacturer. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1387 | eiter = entries + size; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1388 | eiter->type = cpu_to_be16(FDMI_HBA_MANUFACTURER); |
Paul Bolle | f24b697 | 2013-02-08 01:57:55 -0500 | [diff] [blame] | 1389 | alen = strlen(QLA2XXX_MANUFACTURER); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1390 | snprintf(eiter->a.manufacturer, sizeof(eiter->a.manufacturer), |
| 1391 | "%s", "QLogic Corporation"); |
| 1392 | alen += 4 - (alen & 3); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1393 | eiter->len = cpu_to_be16(4 + alen); |
| 1394 | size += 4 + alen; |
| 1395 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1396 | ql_dbg(ql_dbg_disc, vha, 0x2026, |
| 1397 | "Manufacturer = %s.\n", eiter->a.manufacturer); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1398 | |
| 1399 | /* Serial number. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1400 | eiter = entries + size; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1401 | eiter->type = cpu_to_be16(FDMI_HBA_SERIAL_NUMBER); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1402 | if (IS_FWI2_CAPABLE(ha)) |
| 1403 | qla2xxx_get_vpd_field(vha, "SN", eiter->a.serial_num, |
| 1404 | sizeof(eiter->a.serial_num)); |
| 1405 | else { |
| 1406 | sn = ((ha->serial0 & 0x1f) << 16) | |
| 1407 | (ha->serial2 << 8) | ha->serial1; |
| 1408 | snprintf(eiter->a.serial_num, sizeof(eiter->a.serial_num), |
| 1409 | "%c%05d", 'A' + sn / 100000, sn % 100000); |
| 1410 | } |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1411 | alen = strlen(eiter->a.serial_num); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1412 | alen += 4 - (alen & 3); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1413 | eiter->len = cpu_to_be16(4 + alen); |
| 1414 | size += 4 + alen; |
| 1415 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1416 | ql_dbg(ql_dbg_disc, vha, 0x2027, |
| 1417 | "Serial no. = %s.\n", eiter->a.serial_num); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1418 | |
| 1419 | /* Model name. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1420 | eiter = entries + size; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1421 | eiter->type = cpu_to_be16(FDMI_HBA_MODEL); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1422 | snprintf(eiter->a.model, sizeof(eiter->a.model), |
| 1423 | "%s", ha->model_number); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1424 | alen = strlen(eiter->a.model); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1425 | alen += 4 - (alen & 3); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1426 | eiter->len = cpu_to_be16(4 + alen); |
| 1427 | size += 4 + alen; |
| 1428 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1429 | ql_dbg(ql_dbg_disc, vha, 0x2028, |
| 1430 | "Model Name = %s.\n", eiter->a.model); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1431 | |
| 1432 | /* Model description. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1433 | eiter = entries + size; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1434 | eiter->type = cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1435 | snprintf(eiter->a.model_desc, sizeof(eiter->a.model_desc), |
| 1436 | "%s", ha->model_desc); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1437 | alen = strlen(eiter->a.model_desc); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1438 | alen += 4 - (alen & 3); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1439 | eiter->len = cpu_to_be16(4 + alen); |
| 1440 | size += 4 + alen; |
| 1441 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1442 | ql_dbg(ql_dbg_disc, vha, 0x2029, |
| 1443 | "Model Desc = %s.\n", eiter->a.model_desc); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1444 | |
| 1445 | /* Hardware version. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1446 | eiter = entries + size; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1447 | eiter->type = cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1448 | if (!IS_FWI2_CAPABLE(ha)) { |
| 1449 | snprintf(eiter->a.hw_version, sizeof(eiter->a.hw_version), |
| 1450 | "HW:%s", ha->adapter_id); |
| 1451 | } else if (qla2xxx_get_vpd_field(vha, "MN", eiter->a.hw_version, |
| 1452 | sizeof(eiter->a.hw_version))) { |
| 1453 | ; |
| 1454 | } else if (qla2xxx_get_vpd_field(vha, "EC", eiter->a.hw_version, |
| 1455 | sizeof(eiter->a.hw_version))) { |
| 1456 | ; |
| 1457 | } else { |
| 1458 | snprintf(eiter->a.hw_version, sizeof(eiter->a.hw_version), |
| 1459 | "HW:%s", ha->adapter_id); |
| 1460 | } |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1461 | alen = strlen(eiter->a.hw_version); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1462 | alen += 4 - (alen & 3); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1463 | eiter->len = cpu_to_be16(4 + alen); |
| 1464 | size += 4 + alen; |
| 1465 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1466 | ql_dbg(ql_dbg_disc, vha, 0x202a, |
| 1467 | "Hardware ver = %s.\n", eiter->a.hw_version); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1468 | |
| 1469 | /* Driver version. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1470 | eiter = entries + size; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1471 | eiter->type = cpu_to_be16(FDMI_HBA_DRIVER_VERSION); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1472 | snprintf(eiter->a.driver_version, sizeof(eiter->a.driver_version), |
| 1473 | "%s", qla2x00_version_str); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1474 | alen = strlen(eiter->a.driver_version); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1475 | alen += 4 - (alen & 3); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1476 | eiter->len = cpu_to_be16(4 + alen); |
| 1477 | size += 4 + alen; |
| 1478 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1479 | ql_dbg(ql_dbg_disc, vha, 0x202b, |
| 1480 | "Driver ver = %s.\n", eiter->a.driver_version); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1481 | |
| 1482 | /* Option ROM version. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1483 | eiter = entries + size; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1484 | eiter->type = cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1485 | snprintf(eiter->a.orom_version, sizeof(eiter->a.orom_version), |
| 1486 | "%d.%02d", ha->bios_revision[1], ha->bios_revision[0]); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1487 | alen = strlen(eiter->a.orom_version); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1488 | alen += 4 - (alen & 3); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1489 | eiter->len = cpu_to_be16(4 + alen); |
| 1490 | size += 4 + alen; |
| 1491 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1492 | ql_dbg(ql_dbg_disc, vha , 0x202c, |
| 1493 | "Optrom vers = %s.\n", eiter->a.orom_version); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1494 | |
| 1495 | /* Firmware version */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1496 | eiter = entries + size; |
Bart Van Assche | ad95036 | 2015-07-09 07:24:08 -0700 | [diff] [blame] | 1497 | eiter->type = cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1498 | ha->isp_ops->fw_version_str(vha, eiter->a.fw_version, |
| 1499 | sizeof(eiter->a.fw_version)); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1500 | alen = strlen(eiter->a.fw_version); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1501 | alen += 4 - (alen & 3); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1502 | eiter->len = cpu_to_be16(4 + alen); |
| 1503 | size += 4 + alen; |
| 1504 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1505 | ql_dbg(ql_dbg_disc, vha, 0x202d, |
| 1506 | "Firmware vers = %s.\n", eiter->a.fw_version); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1507 | |
| 1508 | /* Update MS request size. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1509 | qla2x00_update_ms_fdmi_iocb(vha, size + 16); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1510 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1511 | ql_dbg(ql_dbg_disc, vha, 0x202e, |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 1512 | "RHBA identifier = %8phN size=%d.\n", |
| 1513 | ct_req->req.rhba.hba_identifier, size); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1514 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2076, |
| 1515 | entries, size); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1516 | |
| 1517 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1518 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1519 | sizeof(ms_iocb_entry_t)); |
| 1520 | if (rval != QLA_SUCCESS) { |
| 1521 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1522 | ql_dbg(ql_dbg_disc, vha, 0x2030, |
| 1523 | "RHBA issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 1524 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RHBA") != |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1525 | QLA_SUCCESS) { |
| 1526 | rval = QLA_FUNCTION_FAILED; |
| 1527 | if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && |
| 1528 | ct_rsp->header.explanation_code == |
| 1529 | CT_EXPL_ALREADY_REGISTERED) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1530 | ql_dbg(ql_dbg_disc, vha, 0x2034, |
| 1531 | "HBA already registered.\n"); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1532 | rval = QLA_ALREADY_REGISTERED; |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1533 | } else { |
| 1534 | ql_dbg(ql_dbg_disc, vha, 0x20ad, |
| 1535 | "RHBA FDMI registration failed, CT Reason code: 0x%x, CT Explanation 0x%x\n", |
| 1536 | ct_rsp->header.reason_code, |
| 1537 | ct_rsp->header.explanation_code); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1538 | } |
| 1539 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1540 | ql_dbg(ql_dbg_disc, vha, 0x2035, |
| 1541 | "RHBA exiting normally.\n"); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 1542 | } |
| 1543 | |
| 1544 | return rval; |
| 1545 | } |
| 1546 | |
| 1547 | /** |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 1548 | * qla2x00_fdmi_rpa() - |
| 1549 | * @ha: HA context |
| 1550 | * |
| 1551 | * Returns 0 on success. |
| 1552 | */ |
| 1553 | static int |
| 1554 | qla2x00_fdmi_rpa(scsi_qla_host_t *vha) |
| 1555 | { |
| 1556 | int rval, alen; |
| 1557 | uint32_t size; |
| 1558 | struct qla_hw_data *ha = vha->hw; |
| 1559 | ms_iocb_entry_t *ms_pkt; |
| 1560 | struct ct_sns_req *ct_req; |
| 1561 | struct ct_sns_rsp *ct_rsp; |
| 1562 | void *entries; |
| 1563 | struct ct_fdmi_port_attr *eiter; |
| 1564 | struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb; |
| 1565 | struct new_utsname *p_sysid = NULL; |
| 1566 | |
| 1567 | /* Issue RPA */ |
| 1568 | /* Prepare common MS IOCB */ |
| 1569 | /* Request size adjusted after CT preparation */ |
| 1570 | ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE); |
| 1571 | |
| 1572 | /* Prepare CT request */ |
| 1573 | ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, RPA_CMD, |
| 1574 | RPA_RSP_SIZE); |
| 1575 | ct_rsp = &ha->ct_sns->p.rsp; |
| 1576 | |
| 1577 | /* Prepare FDMI command arguments -- attribute block, attributes. */ |
| 1578 | memcpy(ct_req->req.rpa.port_name, vha->port_name, WWN_SIZE); |
| 1579 | size = WWN_SIZE + 4; |
| 1580 | |
| 1581 | /* Attributes */ |
| 1582 | ct_req->req.rpa.attrs.count = cpu_to_be32(FDMI_PORT_ATTR_COUNT); |
| 1583 | entries = ct_req->req.rpa.port_name; |
| 1584 | |
| 1585 | /* FC4 types. */ |
| 1586 | eiter = entries + size; |
| 1587 | eiter->type = cpu_to_be16(FDMI_PORT_FC4_TYPES); |
| 1588 | eiter->len = cpu_to_be16(4 + 32); |
| 1589 | eiter->a.fc4_types[2] = 0x01; |
| 1590 | size += 4 + 32; |
| 1591 | |
| 1592 | ql_dbg(ql_dbg_disc, vha, 0x2039, |
| 1593 | "FC4_TYPES=%02x %02x.\n", |
| 1594 | eiter->a.fc4_types[2], |
| 1595 | eiter->a.fc4_types[1]); |
| 1596 | |
| 1597 | /* Supported speed. */ |
| 1598 | eiter = entries + size; |
| 1599 | eiter->type = cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); |
| 1600 | eiter->len = cpu_to_be16(4 + 4); |
| 1601 | if (IS_CNA_CAPABLE(ha)) |
| 1602 | eiter->a.sup_speed = cpu_to_be32( |
| 1603 | FDMI_PORT_SPEED_10GB); |
| 1604 | else if (IS_QLA27XX(ha)) |
| 1605 | eiter->a.sup_speed = cpu_to_be32( |
| 1606 | FDMI_PORT_SPEED_32GB| |
| 1607 | FDMI_PORT_SPEED_16GB| |
| 1608 | FDMI_PORT_SPEED_8GB); |
| 1609 | else if (IS_QLA2031(ha)) |
| 1610 | eiter->a.sup_speed = cpu_to_be32( |
| 1611 | FDMI_PORT_SPEED_16GB| |
| 1612 | FDMI_PORT_SPEED_8GB| |
| 1613 | FDMI_PORT_SPEED_4GB); |
| 1614 | else if (IS_QLA25XX(ha)) |
| 1615 | eiter->a.sup_speed = cpu_to_be32( |
| 1616 | FDMI_PORT_SPEED_8GB| |
| 1617 | FDMI_PORT_SPEED_4GB| |
| 1618 | FDMI_PORT_SPEED_2GB| |
| 1619 | FDMI_PORT_SPEED_1GB); |
| 1620 | else if (IS_QLA24XX_TYPE(ha)) |
| 1621 | eiter->a.sup_speed = cpu_to_be32( |
| 1622 | FDMI_PORT_SPEED_4GB| |
| 1623 | FDMI_PORT_SPEED_2GB| |
| 1624 | FDMI_PORT_SPEED_1GB); |
| 1625 | else if (IS_QLA23XX(ha)) |
| 1626 | eiter->a.sup_speed = cpu_to_be32( |
| 1627 | FDMI_PORT_SPEED_2GB| |
| 1628 | FDMI_PORT_SPEED_1GB); |
| 1629 | else |
| 1630 | eiter->a.sup_speed = cpu_to_be32( |
| 1631 | FDMI_PORT_SPEED_1GB); |
| 1632 | size += 4 + 4; |
| 1633 | |
| 1634 | ql_dbg(ql_dbg_disc, vha, 0x203a, |
| 1635 | "Supported_Speed=%x.\n", eiter->a.sup_speed); |
| 1636 | |
| 1637 | /* Current speed. */ |
| 1638 | eiter = entries + size; |
| 1639 | eiter->type = cpu_to_be16(FDMI_PORT_CURRENT_SPEED); |
| 1640 | eiter->len = cpu_to_be16(4 + 4); |
| 1641 | switch (ha->link_data_rate) { |
| 1642 | case PORT_SPEED_1GB: |
| 1643 | eiter->a.cur_speed = |
| 1644 | cpu_to_be32(FDMI_PORT_SPEED_1GB); |
| 1645 | break; |
| 1646 | case PORT_SPEED_2GB: |
| 1647 | eiter->a.cur_speed = |
| 1648 | cpu_to_be32(FDMI_PORT_SPEED_2GB); |
| 1649 | break; |
| 1650 | case PORT_SPEED_4GB: |
| 1651 | eiter->a.cur_speed = |
| 1652 | cpu_to_be32(FDMI_PORT_SPEED_4GB); |
| 1653 | break; |
| 1654 | case PORT_SPEED_8GB: |
| 1655 | eiter->a.cur_speed = |
| 1656 | cpu_to_be32(FDMI_PORT_SPEED_8GB); |
| 1657 | break; |
| 1658 | case PORT_SPEED_10GB: |
| 1659 | eiter->a.cur_speed = |
| 1660 | cpu_to_be32(FDMI_PORT_SPEED_10GB); |
| 1661 | break; |
| 1662 | case PORT_SPEED_16GB: |
| 1663 | eiter->a.cur_speed = |
| 1664 | cpu_to_be32(FDMI_PORT_SPEED_16GB); |
| 1665 | break; |
| 1666 | case PORT_SPEED_32GB: |
| 1667 | eiter->a.cur_speed = |
| 1668 | cpu_to_be32(FDMI_PORT_SPEED_32GB); |
| 1669 | break; |
| 1670 | default: |
| 1671 | eiter->a.cur_speed = |
| 1672 | cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN); |
| 1673 | break; |
| 1674 | } |
| 1675 | size += 4 + 4; |
| 1676 | |
| 1677 | ql_dbg(ql_dbg_disc, vha, 0x203b, |
| 1678 | "Current_Speed=%x.\n", eiter->a.cur_speed); |
| 1679 | |
| 1680 | /* Max frame size. */ |
| 1681 | eiter = entries + size; |
| 1682 | eiter->type = cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE); |
| 1683 | eiter->len = cpu_to_be16(4 + 4); |
| 1684 | eiter->a.max_frame_size = IS_FWI2_CAPABLE(ha) ? |
| 1685 | le16_to_cpu(icb24->frame_payload_size) : |
| 1686 | le16_to_cpu(ha->init_cb->frame_payload_size); |
| 1687 | eiter->a.max_frame_size = cpu_to_be32(eiter->a.max_frame_size); |
| 1688 | size += 4 + 4; |
| 1689 | |
| 1690 | ql_dbg(ql_dbg_disc, vha, 0x203c, |
| 1691 | "Max_Frame_Size=%x.\n", eiter->a.max_frame_size); |
| 1692 | |
| 1693 | /* OS device name. */ |
| 1694 | eiter = entries + size; |
| 1695 | eiter->type = cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME); |
| 1696 | snprintf(eiter->a.os_dev_name, sizeof(eiter->a.os_dev_name), |
| 1697 | "%s:host%lu", QLA2XXX_DRIVER_NAME, vha->host_no); |
| 1698 | alen = strlen(eiter->a.os_dev_name); |
| 1699 | alen += 4 - (alen & 3); |
| 1700 | eiter->len = cpu_to_be16(4 + alen); |
| 1701 | size += 4 + alen; |
| 1702 | |
| 1703 | ql_dbg(ql_dbg_disc, vha, 0x204b, |
| 1704 | "OS_Device_Name=%s.\n", eiter->a.os_dev_name); |
| 1705 | |
| 1706 | /* Hostname. */ |
| 1707 | eiter = entries + size; |
| 1708 | eiter->type = cpu_to_be16(FDMI_PORT_HOST_NAME); |
| 1709 | p_sysid = utsname(); |
| 1710 | if (p_sysid) { |
| 1711 | snprintf(eiter->a.host_name, sizeof(eiter->a.host_name), |
| 1712 | "%s", p_sysid->nodename); |
| 1713 | } else { |
| 1714 | snprintf(eiter->a.host_name, sizeof(eiter->a.host_name), |
| 1715 | "%s", fc_host_system_hostname(vha->host)); |
| 1716 | } |
| 1717 | alen = strlen(eiter->a.host_name); |
| 1718 | alen += 4 - (alen & 3); |
| 1719 | eiter->len = cpu_to_be16(4 + alen); |
| 1720 | size += 4 + alen; |
| 1721 | |
| 1722 | ql_dbg(ql_dbg_disc, vha, 0x203d, "HostName=%s.\n", eiter->a.host_name); |
| 1723 | |
| 1724 | /* Update MS request size. */ |
| 1725 | qla2x00_update_ms_fdmi_iocb(vha, size + 16); |
| 1726 | |
| 1727 | ql_dbg(ql_dbg_disc, vha, 0x203e, |
| 1728 | "RPA portname %016llx, size = %d.\n", |
| 1729 | wwn_to_u64(ct_req->req.rpa.port_name), size); |
| 1730 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2079, |
| 1731 | entries, size); |
| 1732 | |
| 1733 | /* Execute MS IOCB */ |
| 1734 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
| 1735 | sizeof(ms_iocb_entry_t)); |
| 1736 | if (rval != QLA_SUCCESS) { |
| 1737 | /*EMPTY*/ |
| 1738 | ql_dbg(ql_dbg_disc, vha, 0x2040, |
| 1739 | "RPA issue IOCB failed (%d).\n", rval); |
| 1740 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RPA") != |
| 1741 | QLA_SUCCESS) { |
| 1742 | rval = QLA_FUNCTION_FAILED; |
| 1743 | if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && |
| 1744 | ct_rsp->header.explanation_code == |
| 1745 | CT_EXPL_ALREADY_REGISTERED) { |
| 1746 | ql_dbg(ql_dbg_disc, vha, 0x20cd, |
| 1747 | "RPA already registered.\n"); |
| 1748 | rval = QLA_ALREADY_REGISTERED; |
| 1749 | } |
| 1750 | |
| 1751 | } else { |
| 1752 | ql_dbg(ql_dbg_disc, vha, 0x2041, |
| 1753 | "RPA exiting normally.\n"); |
| 1754 | } |
| 1755 | |
| 1756 | return rval; |
| 1757 | } |
| 1758 | |
| 1759 | /** |
| 1760 | * qla2x00_fdmiv2_rhba() - |
| 1761 | * @ha: HA context |
| 1762 | * |
| 1763 | * Returns 0 on success. |
| 1764 | */ |
| 1765 | static int |
| 1766 | qla2x00_fdmiv2_rhba(scsi_qla_host_t *vha) |
| 1767 | { |
| 1768 | int rval, alen; |
| 1769 | uint32_t size, sn; |
| 1770 | ms_iocb_entry_t *ms_pkt; |
| 1771 | struct ct_sns_req *ct_req; |
| 1772 | struct ct_sns_rsp *ct_rsp; |
| 1773 | void *entries; |
| 1774 | struct ct_fdmiv2_hba_attr *eiter; |
| 1775 | struct qla_hw_data *ha = vha->hw; |
| 1776 | struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb; |
| 1777 | struct new_utsname *p_sysid = NULL; |
| 1778 | |
| 1779 | /* Issue RHBA */ |
| 1780 | /* Prepare common MS IOCB */ |
| 1781 | /* Request size adjusted after CT preparation */ |
| 1782 | ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE); |
| 1783 | |
| 1784 | /* Prepare CT request */ |
| 1785 | ct_req = qla2x00_prep_ct_fdmi_req(ha->ct_sns, RHBA_CMD, |
| 1786 | RHBA_RSP_SIZE); |
| 1787 | ct_rsp = &ha->ct_sns->p.rsp; |
| 1788 | |
| 1789 | /* Prepare FDMI command arguments -- attribute block, attributes. */ |
| 1790 | memcpy(ct_req->req.rhba2.hba_identifier, vha->port_name, WWN_SIZE); |
| 1791 | ct_req->req.rhba2.entry_count = cpu_to_be32(1); |
| 1792 | memcpy(ct_req->req.rhba2.port_name, vha->port_name, WWN_SIZE); |
| 1793 | size = 2 * WWN_SIZE + 4 + 4; |
| 1794 | |
| 1795 | /* Attributes */ |
| 1796 | ct_req->req.rhba2.attrs.count = cpu_to_be32(FDMIV2_HBA_ATTR_COUNT); |
| 1797 | entries = ct_req->req.rhba2.hba_identifier; |
| 1798 | |
| 1799 | /* Nodename. */ |
| 1800 | eiter = entries + size; |
| 1801 | eiter->type = cpu_to_be16(FDMI_HBA_NODE_NAME); |
| 1802 | eiter->len = cpu_to_be16(4 + WWN_SIZE); |
| 1803 | memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE); |
| 1804 | size += 4 + WWN_SIZE; |
| 1805 | |
| 1806 | ql_dbg(ql_dbg_disc, vha, 0x207d, |
| 1807 | "NodeName = %016llx.\n", wwn_to_u64(eiter->a.node_name)); |
| 1808 | |
| 1809 | /* Manufacturer. */ |
| 1810 | eiter = entries + size; |
| 1811 | eiter->type = cpu_to_be16(FDMI_HBA_MANUFACTURER); |
| 1812 | snprintf(eiter->a.manufacturer, sizeof(eiter->a.manufacturer), |
| 1813 | "%s", "QLogic Corporation"); |
| 1814 | eiter->a.manufacturer[strlen("QLogic Corporation")] = '\0'; |
| 1815 | alen = strlen(eiter->a.manufacturer); |
| 1816 | alen += 4 - (alen & 3); |
| 1817 | eiter->len = cpu_to_be16(4 + alen); |
| 1818 | size += 4 + alen; |
| 1819 | |
| 1820 | ql_dbg(ql_dbg_disc, vha, 0x20a5, |
| 1821 | "Manufacturer = %s.\n", eiter->a.manufacturer); |
| 1822 | |
| 1823 | /* Serial number. */ |
| 1824 | eiter = entries + size; |
| 1825 | eiter->type = cpu_to_be16(FDMI_HBA_SERIAL_NUMBER); |
| 1826 | if (IS_FWI2_CAPABLE(ha)) |
| 1827 | qla2xxx_get_vpd_field(vha, "SN", eiter->a.serial_num, |
| 1828 | sizeof(eiter->a.serial_num)); |
| 1829 | else { |
| 1830 | sn = ((ha->serial0 & 0x1f) << 16) | |
| 1831 | (ha->serial2 << 8) | ha->serial1; |
| 1832 | snprintf(eiter->a.serial_num, sizeof(eiter->a.serial_num), |
| 1833 | "%c%05d", 'A' + sn / 100000, sn % 100000); |
| 1834 | } |
| 1835 | alen = strlen(eiter->a.serial_num); |
| 1836 | alen += 4 - (alen & 3); |
| 1837 | eiter->len = cpu_to_be16(4 + alen); |
| 1838 | size += 4 + alen; |
| 1839 | |
| 1840 | ql_dbg(ql_dbg_disc, vha, 0x20a6, |
| 1841 | "Serial no. = %s.\n", eiter->a.serial_num); |
| 1842 | |
| 1843 | /* Model name. */ |
| 1844 | eiter = entries + size; |
| 1845 | eiter->type = cpu_to_be16(FDMI_HBA_MODEL); |
| 1846 | snprintf(eiter->a.model, sizeof(eiter->a.model), |
| 1847 | "%s", ha->model_number); |
| 1848 | alen = strlen(eiter->a.model); |
| 1849 | alen += 4 - (alen & 3); |
| 1850 | eiter->len = cpu_to_be16(4 + alen); |
| 1851 | size += 4 + alen; |
| 1852 | |
| 1853 | ql_dbg(ql_dbg_disc, vha, 0x20a7, |
| 1854 | "Model Name = %s.\n", eiter->a.model); |
| 1855 | |
| 1856 | /* Model description. */ |
| 1857 | eiter = entries + size; |
| 1858 | eiter->type = cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); |
| 1859 | snprintf(eiter->a.model_desc, sizeof(eiter->a.model_desc), |
| 1860 | "%s", ha->model_desc); |
| 1861 | alen = strlen(eiter->a.model_desc); |
| 1862 | alen += 4 - (alen & 3); |
| 1863 | eiter->len = cpu_to_be16(4 + alen); |
| 1864 | size += 4 + alen; |
| 1865 | |
| 1866 | ql_dbg(ql_dbg_disc, vha, 0x20a8, |
| 1867 | "Model Desc = %s.\n", eiter->a.model_desc); |
| 1868 | |
| 1869 | /* Hardware version. */ |
| 1870 | eiter = entries + size; |
| 1871 | eiter->type = cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); |
| 1872 | if (!IS_FWI2_CAPABLE(ha)) { |
| 1873 | snprintf(eiter->a.hw_version, sizeof(eiter->a.hw_version), |
| 1874 | "HW:%s", ha->adapter_id); |
| 1875 | } else if (qla2xxx_get_vpd_field(vha, "MN", eiter->a.hw_version, |
| 1876 | sizeof(eiter->a.hw_version))) { |
| 1877 | ; |
| 1878 | } else if (qla2xxx_get_vpd_field(vha, "EC", eiter->a.hw_version, |
| 1879 | sizeof(eiter->a.hw_version))) { |
| 1880 | ; |
| 1881 | } else { |
| 1882 | snprintf(eiter->a.hw_version, sizeof(eiter->a.hw_version), |
| 1883 | "HW:%s", ha->adapter_id); |
| 1884 | } |
| 1885 | alen = strlen(eiter->a.hw_version); |
| 1886 | alen += 4 - (alen & 3); |
| 1887 | eiter->len = cpu_to_be16(4 + alen); |
| 1888 | size += 4 + alen; |
| 1889 | |
| 1890 | ql_dbg(ql_dbg_disc, vha, 0x20a9, |
| 1891 | "Hardware ver = %s.\n", eiter->a.hw_version); |
| 1892 | |
| 1893 | /* Driver version. */ |
| 1894 | eiter = entries + size; |
| 1895 | eiter->type = cpu_to_be16(FDMI_HBA_DRIVER_VERSION); |
| 1896 | snprintf(eiter->a.driver_version, sizeof(eiter->a.driver_version), |
| 1897 | "%s", qla2x00_version_str); |
| 1898 | alen = strlen(eiter->a.driver_version); |
| 1899 | alen += 4 - (alen & 3); |
| 1900 | eiter->len = cpu_to_be16(4 + alen); |
| 1901 | size += 4 + alen; |
| 1902 | |
| 1903 | ql_dbg(ql_dbg_disc, vha, 0x20aa, |
| 1904 | "Driver ver = %s.\n", eiter->a.driver_version); |
| 1905 | |
| 1906 | /* Option ROM version. */ |
| 1907 | eiter = entries + size; |
| 1908 | eiter->type = cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION); |
| 1909 | snprintf(eiter->a.orom_version, sizeof(eiter->a.orom_version), |
| 1910 | "%d.%02d", ha->bios_revision[1], ha->bios_revision[0]); |
| 1911 | alen = strlen(eiter->a.orom_version); |
| 1912 | alen += 4 - (alen & 3); |
| 1913 | eiter->len = cpu_to_be16(4 + alen); |
| 1914 | size += 4 + alen; |
| 1915 | |
| 1916 | ql_dbg(ql_dbg_disc, vha , 0x20ab, |
| 1917 | "Optrom version = %d.%02d.\n", eiter->a.orom_version[1], |
| 1918 | eiter->a.orom_version[0]); |
| 1919 | |
| 1920 | /* Firmware version */ |
| 1921 | eiter = entries + size; |
| 1922 | eiter->type = cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION); |
| 1923 | ha->isp_ops->fw_version_str(vha, eiter->a.fw_version, |
| 1924 | sizeof(eiter->a.fw_version)); |
| 1925 | alen = strlen(eiter->a.fw_version); |
| 1926 | alen += 4 - (alen & 3); |
| 1927 | eiter->len = cpu_to_be16(4 + alen); |
| 1928 | size += 4 + alen; |
| 1929 | |
| 1930 | ql_dbg(ql_dbg_disc, vha, 0x20ac, |
| 1931 | "Firmware vers = %s.\n", eiter->a.fw_version); |
| 1932 | |
| 1933 | /* OS Name and Version */ |
| 1934 | eiter = entries + size; |
| 1935 | eiter->type = cpu_to_be16(FDMI_HBA_OS_NAME_AND_VERSION); |
| 1936 | p_sysid = utsname(); |
| 1937 | if (p_sysid) { |
| 1938 | snprintf(eiter->a.os_version, sizeof(eiter->a.os_version), |
| 1939 | "%s %s %s", |
| 1940 | p_sysid->sysname, p_sysid->release, p_sysid->version); |
| 1941 | } else { |
| 1942 | snprintf(eiter->a.os_version, sizeof(eiter->a.os_version), |
| 1943 | "%s %s", "Linux", fc_host_system_hostname(vha->host)); |
| 1944 | } |
| 1945 | alen = strlen(eiter->a.os_version); |
| 1946 | alen += 4 - (alen & 3); |
| 1947 | eiter->len = cpu_to_be16(4 + alen); |
| 1948 | size += 4 + alen; |
| 1949 | |
| 1950 | ql_dbg(ql_dbg_disc, vha, 0x20ae, |
| 1951 | "OS Name and Version = %s.\n", eiter->a.os_version); |
| 1952 | |
| 1953 | /* MAX CT Payload Length */ |
| 1954 | eiter = entries + size; |
| 1955 | eiter->type = cpu_to_be16(FDMI_HBA_MAXIMUM_CT_PAYLOAD_LENGTH); |
| 1956 | eiter->a.max_ct_len = IS_FWI2_CAPABLE(ha) ? |
| 1957 | le16_to_cpu(icb24->frame_payload_size) : |
| 1958 | le16_to_cpu(ha->init_cb->frame_payload_size); |
| 1959 | eiter->a.max_ct_len = cpu_to_be32(eiter->a.max_ct_len); |
| 1960 | eiter->len = cpu_to_be16(4 + 4); |
| 1961 | size += 4 + 4; |
| 1962 | |
| 1963 | ql_dbg(ql_dbg_disc, vha, 0x20af, |
| 1964 | "CT Payload Length = 0x%x.\n", eiter->a.max_ct_len); |
| 1965 | |
| 1966 | /* Node Sybolic Name */ |
| 1967 | eiter = entries + size; |
| 1968 | eiter->type = cpu_to_be16(FDMI_HBA_NODE_SYMBOLIC_NAME); |
| 1969 | qla2x00_get_sym_node_name(vha, eiter->a.sym_name, |
| 1970 | sizeof(eiter->a.sym_name)); |
| 1971 | alen = strlen(eiter->a.sym_name); |
| 1972 | alen += 4 - (alen & 3); |
| 1973 | eiter->len = cpu_to_be16(4 + alen); |
| 1974 | size += 4 + alen; |
| 1975 | |
| 1976 | ql_dbg(ql_dbg_disc, vha, 0x20b0, |
| 1977 | "Symbolic Name = %s.\n", eiter->a.sym_name); |
| 1978 | |
| 1979 | /* Vendor Id */ |
| 1980 | eiter = entries + size; |
| 1981 | eiter->type = cpu_to_be16(FDMI_HBA_VENDOR_ID); |
| 1982 | eiter->a.vendor_id = cpu_to_be32(0x1077); |
| 1983 | eiter->len = cpu_to_be16(4 + 4); |
| 1984 | size += 4 + 4; |
| 1985 | |
| 1986 | ql_dbg(ql_dbg_disc, vha, 0x20b1, |
| 1987 | "Vendor Id = %x.\n", eiter->a.vendor_id); |
| 1988 | |
| 1989 | /* Num Ports */ |
| 1990 | eiter = entries + size; |
| 1991 | eiter->type = cpu_to_be16(FDMI_HBA_NUM_PORTS); |
| 1992 | eiter->a.num_ports = cpu_to_be32(1); |
| 1993 | eiter->len = cpu_to_be16(4 + 4); |
| 1994 | size += 4 + 4; |
| 1995 | |
| 1996 | ql_dbg(ql_dbg_disc, vha, 0x20b2, |
| 1997 | "Port Num = %x.\n", eiter->a.num_ports); |
| 1998 | |
| 1999 | /* Fabric Name */ |
| 2000 | eiter = entries + size; |
| 2001 | eiter->type = cpu_to_be16(FDMI_HBA_FABRIC_NAME); |
| 2002 | memcpy(eiter->a.fabric_name, vha->fabric_node_name, WWN_SIZE); |
| 2003 | eiter->len = cpu_to_be16(4 + WWN_SIZE); |
| 2004 | size += 4 + WWN_SIZE; |
| 2005 | |
| 2006 | ql_dbg(ql_dbg_disc, vha, 0x20b3, |
| 2007 | "Fabric Name = %016llx.\n", wwn_to_u64(eiter->a.fabric_name)); |
| 2008 | |
| 2009 | /* BIOS Version */ |
| 2010 | eiter = entries + size; |
| 2011 | eiter->type = cpu_to_be16(FDMI_HBA_BOOT_BIOS_NAME); |
| 2012 | snprintf(eiter->a.bios_name, sizeof(eiter->a.bios_name), |
| 2013 | "BIOS %d.%02d", ha->bios_revision[1], ha->bios_revision[0]); |
| 2014 | alen = strlen(eiter->a.bios_name); |
| 2015 | alen += 4 - (alen & 3); |
| 2016 | eiter->len = cpu_to_be16(4 + alen); |
| 2017 | size += 4 + alen; |
| 2018 | |
| 2019 | ql_dbg(ql_dbg_disc, vha, 0x20b4, |
| 2020 | "BIOS Name = %s\n", eiter->a.bios_name); |
| 2021 | |
| 2022 | /* Vendor Identifier */ |
| 2023 | eiter = entries + size; |
| 2024 | eiter->type = cpu_to_be16(FDMI_HBA_TYPE_VENDOR_IDENTIFIER); |
Colin Ian King | 577419f | 2016-12-29 22:20:38 +0000 | [diff] [blame] | 2025 | snprintf(eiter->a.vendor_identifier, sizeof(eiter->a.vendor_identifier), |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2026 | "%s", "QLGC"); |
Colin Ian King | 577419f | 2016-12-29 22:20:38 +0000 | [diff] [blame] | 2027 | alen = strlen(eiter->a.vendor_identifier); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2028 | alen += 4 - (alen & 3); |
| 2029 | eiter->len = cpu_to_be16(4 + alen); |
| 2030 | size += 4 + alen; |
| 2031 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2032 | ql_dbg(ql_dbg_disc, vha, 0x201b, |
Colin Ian King | 577419f | 2016-12-29 22:20:38 +0000 | [diff] [blame] | 2033 | "Vendor Identifier = %s.\n", eiter->a.vendor_identifier); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2034 | |
| 2035 | /* Update MS request size. */ |
| 2036 | qla2x00_update_ms_fdmi_iocb(vha, size + 16); |
| 2037 | |
| 2038 | ql_dbg(ql_dbg_disc, vha, 0x20b5, |
| 2039 | "RHBA identifier = %016llx.\n", |
| 2040 | wwn_to_u64(ct_req->req.rhba2.hba_identifier)); |
| 2041 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x20b6, |
| 2042 | entries, size); |
| 2043 | |
| 2044 | /* Execute MS IOCB */ |
| 2045 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
| 2046 | sizeof(ms_iocb_entry_t)); |
| 2047 | if (rval != QLA_SUCCESS) { |
| 2048 | /*EMPTY*/ |
| 2049 | ql_dbg(ql_dbg_disc, vha, 0x20b7, |
| 2050 | "RHBA issue IOCB failed (%d).\n", rval); |
| 2051 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RHBA") != |
| 2052 | QLA_SUCCESS) { |
| 2053 | rval = QLA_FUNCTION_FAILED; |
| 2054 | |
| 2055 | if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && |
| 2056 | ct_rsp->header.explanation_code == |
| 2057 | CT_EXPL_ALREADY_REGISTERED) { |
| 2058 | ql_dbg(ql_dbg_disc, vha, 0x20b8, |
| 2059 | "HBA already registered.\n"); |
| 2060 | rval = QLA_ALREADY_REGISTERED; |
| 2061 | } else { |
| 2062 | ql_dbg(ql_dbg_disc, vha, 0x2016, |
| 2063 | "RHBA FDMI v2 failed, CT Reason code: 0x%x, CT Explanation 0x%x\n", |
| 2064 | ct_rsp->header.reason_code, |
| 2065 | ct_rsp->header.explanation_code); |
| 2066 | } |
| 2067 | } else { |
| 2068 | ql_dbg(ql_dbg_disc, vha, 0x20b9, |
| 2069 | "RHBA FDMI V2 exiting normally.\n"); |
| 2070 | } |
| 2071 | |
| 2072 | return rval; |
| 2073 | } |
| 2074 | |
| 2075 | /** |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2076 | * qla2x00_fdmi_dhba() - |
| 2077 | * @ha: HA context |
| 2078 | * |
| 2079 | * Returns 0 on success. |
| 2080 | */ |
| 2081 | static int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2082 | qla2x00_fdmi_dhba(scsi_qla_host_t *vha) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2083 | { |
| 2084 | int rval; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2085 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2086 | ms_iocb_entry_t *ms_pkt; |
| 2087 | struct ct_sns_req *ct_req; |
| 2088 | struct ct_sns_rsp *ct_rsp; |
| 2089 | |
| 2090 | /* Issue RPA */ |
| 2091 | /* Prepare common MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2092 | 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] | 2093 | DHBA_RSP_SIZE); |
| 2094 | |
| 2095 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 2096 | 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] | 2097 | ct_rsp = &ha->ct_sns->p.rsp; |
| 2098 | |
| 2099 | /* Prepare FDMI command arguments -- portname. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2100 | memcpy(ct_req->req.dhba.port_name, vha->port_name, WWN_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2101 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2102 | ql_dbg(ql_dbg_disc, vha, 0x2036, |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 2103 | "DHBA portname = %8phN.\n", ct_req->req.dhba.port_name); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2104 | |
| 2105 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2106 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2107 | sizeof(ms_iocb_entry_t)); |
| 2108 | if (rval != QLA_SUCCESS) { |
| 2109 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2110 | ql_dbg(ql_dbg_disc, vha, 0x2037, |
| 2111 | "DHBA issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2112 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "DHBA") != |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2113 | QLA_SUCCESS) { |
| 2114 | rval = QLA_FUNCTION_FAILED; |
| 2115 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2116 | ql_dbg(ql_dbg_disc, vha, 0x2038, |
| 2117 | "DHBA exiting normally.\n"); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2118 | } |
| 2119 | |
| 2120 | return rval; |
| 2121 | } |
| 2122 | |
| 2123 | /** |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2124 | * qla2x00_fdmiv2_rpa() - |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2125 | * @ha: HA context |
| 2126 | * |
| 2127 | * Returns 0 on success. |
| 2128 | */ |
| 2129 | static int |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2130 | qla2x00_fdmiv2_rpa(scsi_qla_host_t *vha) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2131 | { |
| 2132 | int rval, alen; |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2133 | uint32_t size; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2134 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2135 | ms_iocb_entry_t *ms_pkt; |
| 2136 | struct ct_sns_req *ct_req; |
| 2137 | struct ct_sns_rsp *ct_rsp; |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2138 | void *entries; |
| 2139 | struct ct_fdmiv2_port_attr *eiter; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2140 | struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb; |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2141 | struct new_utsname *p_sysid = NULL; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2142 | |
| 2143 | /* Issue RPA */ |
| 2144 | /* Prepare common MS IOCB */ |
| 2145 | /* Request size adjusted after CT preparation */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2146 | 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] | 2147 | |
| 2148 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 2149 | 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] | 2150 | ct_rsp = &ha->ct_sns->p.rsp; |
| 2151 | |
| 2152 | /* Prepare FDMI command arguments -- attribute block, attributes. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2153 | memcpy(ct_req->req.rpa2.port_name, vha->port_name, WWN_SIZE); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2154 | size = WWN_SIZE + 4; |
| 2155 | |
| 2156 | /* Attributes */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2157 | ct_req->req.rpa2.attrs.count = cpu_to_be32(FDMIV2_PORT_ATTR_COUNT); |
| 2158 | entries = ct_req->req.rpa2.port_name; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2159 | |
| 2160 | /* FC4 types. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2161 | eiter = entries + size; |
| 2162 | eiter->type = cpu_to_be16(FDMI_PORT_FC4_TYPES); |
| 2163 | eiter->len = cpu_to_be16(4 + 32); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2164 | eiter->a.fc4_types[2] = 0x01; |
| 2165 | size += 4 + 32; |
| 2166 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2167 | ql_dbg(ql_dbg_disc, vha, 0x20ba, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2168 | "FC4_TYPES=%02x %02x.\n", |
| 2169 | eiter->a.fc4_types[2], |
| 2170 | eiter->a.fc4_types[1]); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2171 | |
Duane Grigsby | 7d23648 | 2017-06-21 13:48:45 -0700 | [diff] [blame] | 2172 | if (vha->flags.nvme_enabled) { |
| 2173 | eiter->a.fc4_types[6] = 1; /* NVMe type 28h */ |
| 2174 | ql_dbg(ql_dbg_disc, vha, 0x211f, |
| 2175 | "NVME FC4 Type = %02x 0x0 0x0 0x0 0x0 0x0.\n", |
| 2176 | eiter->a.fc4_types[6]); |
| 2177 | } |
| 2178 | |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2179 | /* Supported speed. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2180 | eiter = entries + size; |
| 2181 | eiter->type = cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); |
| 2182 | eiter->len = cpu_to_be16(4 + 4); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2183 | if (IS_CNA_CAPABLE(ha)) |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2184 | eiter->a.sup_speed = cpu_to_be32( |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2185 | FDMI_PORT_SPEED_10GB); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2186 | else if (IS_QLA27XX(ha)) |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2187 | eiter->a.sup_speed = cpu_to_be32( |
| 2188 | FDMI_PORT_SPEED_32GB| |
| 2189 | FDMI_PORT_SPEED_16GB| |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2190 | FDMI_PORT_SPEED_8GB); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2191 | else if (IS_QLA2031(ha)) |
| 2192 | eiter->a.sup_speed = cpu_to_be32( |
| 2193 | FDMI_PORT_SPEED_16GB| |
| 2194 | FDMI_PORT_SPEED_8GB| |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 2195 | FDMI_PORT_SPEED_4GB); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2196 | else if (IS_QLA25XX(ha)) |
| 2197 | eiter->a.sup_speed = cpu_to_be32( |
| 2198 | FDMI_PORT_SPEED_8GB| |
| 2199 | FDMI_PORT_SPEED_4GB| |
| 2200 | FDMI_PORT_SPEED_2GB| |
| 2201 | FDMI_PORT_SPEED_1GB); |
| 2202 | else if (IS_QLA24XX_TYPE(ha)) |
| 2203 | eiter->a.sup_speed = cpu_to_be32( |
| 2204 | FDMI_PORT_SPEED_4GB| |
| 2205 | FDMI_PORT_SPEED_2GB| |
| 2206 | FDMI_PORT_SPEED_1GB); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2207 | else if (IS_QLA23XX(ha)) |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2208 | eiter->a.sup_speed = cpu_to_be32( |
| 2209 | FDMI_PORT_SPEED_2GB| |
| 2210 | FDMI_PORT_SPEED_1GB); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2211 | else |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2212 | eiter->a.sup_speed = cpu_to_be32( |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 2213 | FDMI_PORT_SPEED_1GB); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2214 | size += 4 + 4; |
| 2215 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2216 | ql_dbg(ql_dbg_disc, vha, 0x20bb, |
| 2217 | "Supported Port Speed = %x.\n", eiter->a.sup_speed); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2218 | |
| 2219 | /* Current speed. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2220 | eiter = entries + size; |
| 2221 | eiter->type = cpu_to_be16(FDMI_PORT_CURRENT_SPEED); |
| 2222 | eiter->len = cpu_to_be16(4 + 4); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2223 | switch (ha->link_data_rate) { |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 2224 | case PORT_SPEED_1GB: |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2225 | eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_1GB); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2226 | break; |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 2227 | case PORT_SPEED_2GB: |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2228 | eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_2GB); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2229 | break; |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 2230 | case PORT_SPEED_4GB: |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2231 | eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_4GB); |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 2232 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2233 | case PORT_SPEED_8GB: |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2234 | eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_8GB); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2235 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2236 | case PORT_SPEED_10GB: |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2237 | eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_10GB); |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2238 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2239 | case PORT_SPEED_16GB: |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2240 | eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_16GB); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2241 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2242 | case PORT_SPEED_32GB: |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2243 | eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_32GB); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2244 | break; |
Andrew Vasquez | 5881569 | 2007-07-19 15:05:58 -0700 | [diff] [blame] | 2245 | default: |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2246 | eiter->a.cur_speed = cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2247 | break; |
| 2248 | } |
| 2249 | size += 4 + 4; |
| 2250 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2251 | ql_dbg(ql_dbg_disc, vha, 0x2017, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2252 | "Current_Speed = %x.\n", eiter->a.cur_speed); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2253 | |
| 2254 | /* Max frame size. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2255 | eiter = entries + size; |
| 2256 | eiter->type = cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE); |
| 2257 | eiter->len = cpu_to_be16(4 + 4); |
| 2258 | eiter->a.max_frame_size = IS_FWI2_CAPABLE(ha) ? |
Seokmann Ju | c6852c4 | 2008-04-24 15:21:29 -0700 | [diff] [blame] | 2259 | le16_to_cpu(icb24->frame_payload_size): |
| 2260 | le16_to_cpu(ha->init_cb->frame_payload_size); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2261 | eiter->a.max_frame_size = cpu_to_be32(eiter->a.max_frame_size); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2262 | size += 4 + 4; |
| 2263 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2264 | ql_dbg(ql_dbg_disc, vha, 0x20bc, |
| 2265 | "Max_Frame_Size = %x.\n", eiter->a.max_frame_size); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2266 | |
| 2267 | /* OS device name. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2268 | eiter = entries + size; |
| 2269 | eiter->type = cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME); |
Paul Bolle | f24b697 | 2013-02-08 01:57:55 -0500 | [diff] [blame] | 2270 | alen = strlen(QLA2XXX_DRIVER_NAME); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2271 | snprintf(eiter->a.os_dev_name, sizeof(eiter->a.os_dev_name), |
| 2272 | "%s:host%lu", QLA2XXX_DRIVER_NAME, vha->host_no); |
| 2273 | alen += 4 - (alen & 3); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2274 | eiter->len = cpu_to_be16(4 + alen); |
| 2275 | size += 4 + alen; |
| 2276 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2277 | ql_dbg(ql_dbg_disc, vha, 0x20be, |
| 2278 | "OS_Device_Name = %s.\n", eiter->a.os_dev_name); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2279 | |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 2280 | /* Hostname. */ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2281 | eiter = entries + size; |
| 2282 | eiter->type = cpu_to_be16(FDMI_PORT_HOST_NAME); |
| 2283 | p_sysid = utsname(); |
| 2284 | if (p_sysid) { |
| 2285 | snprintf(eiter->a.host_name, sizeof(eiter->a.host_name), |
| 2286 | "%s", p_sysid->nodename); |
| 2287 | } else { |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 2288 | snprintf(eiter->a.host_name, sizeof(eiter->a.host_name), |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2289 | "%s", fc_host_system_hostname(vha->host)); |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 2290 | } |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2291 | alen = strlen(eiter->a.host_name); |
| 2292 | alen += 4 - (alen & 3); |
| 2293 | eiter->len = cpu_to_be16(4 + alen); |
| 2294 | size += 4 + alen; |
| 2295 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2296 | ql_dbg(ql_dbg_disc, vha, 0x201a, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2297 | "HostName=%s.\n", eiter->a.host_name); |
| 2298 | |
| 2299 | /* Node Name */ |
| 2300 | eiter = entries + size; |
| 2301 | eiter->type = cpu_to_be16(FDMI_PORT_NODE_NAME); |
| 2302 | memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE); |
| 2303 | eiter->len = cpu_to_be16(4 + WWN_SIZE); |
| 2304 | size += 4 + WWN_SIZE; |
| 2305 | |
| 2306 | ql_dbg(ql_dbg_disc, vha, 0x20c0, |
| 2307 | "Node Name = %016llx.\n", wwn_to_u64(eiter->a.node_name)); |
| 2308 | |
| 2309 | /* Port Name */ |
| 2310 | eiter = entries + size; |
| 2311 | eiter->type = cpu_to_be16(FDMI_PORT_NAME); |
| 2312 | memcpy(eiter->a.port_name, vha->port_name, WWN_SIZE); |
| 2313 | eiter->len = cpu_to_be16(4 + WWN_SIZE); |
| 2314 | size += 4 + WWN_SIZE; |
| 2315 | |
| 2316 | ql_dbg(ql_dbg_disc, vha, 0x20c1, |
| 2317 | "Port Name = %016llx.\n", wwn_to_u64(eiter->a.port_name)); |
| 2318 | |
| 2319 | /* Port Symbolic Name */ |
| 2320 | eiter = entries + size; |
| 2321 | eiter->type = cpu_to_be16(FDMI_PORT_SYM_NAME); |
| 2322 | qla2x00_get_sym_node_name(vha, eiter->a.port_sym_name, |
| 2323 | sizeof(eiter->a.port_sym_name)); |
| 2324 | alen = strlen(eiter->a.port_sym_name); |
| 2325 | alen += 4 - (alen & 3); |
| 2326 | eiter->len = cpu_to_be16(4 + alen); |
| 2327 | size += 4 + alen; |
| 2328 | |
| 2329 | ql_dbg(ql_dbg_disc, vha, 0x20c2, |
| 2330 | "port symbolic name = %s\n", eiter->a.port_sym_name); |
| 2331 | |
| 2332 | /* Port Type */ |
| 2333 | eiter = entries + size; |
| 2334 | eiter->type = cpu_to_be16(FDMI_PORT_TYPE); |
| 2335 | eiter->a.port_type = cpu_to_be32(NS_NX_PORT_TYPE); |
| 2336 | eiter->len = cpu_to_be16(4 + 4); |
| 2337 | size += 4 + 4; |
| 2338 | |
| 2339 | ql_dbg(ql_dbg_disc, vha, 0x20c3, |
| 2340 | "Port Type = %x.\n", eiter->a.port_type); |
| 2341 | |
| 2342 | /* Class of Service */ |
| 2343 | eiter = entries + size; |
| 2344 | eiter->type = cpu_to_be16(FDMI_PORT_SUPP_COS); |
| 2345 | eiter->a.port_supported_cos = cpu_to_be32(FC_CLASS_3); |
| 2346 | eiter->len = cpu_to_be16(4 + 4); |
| 2347 | size += 4 + 4; |
| 2348 | |
| 2349 | ql_dbg(ql_dbg_disc, vha, 0x20c4, |
| 2350 | "Supported COS = %08x\n", eiter->a.port_supported_cos); |
| 2351 | |
| 2352 | /* Port Fabric Name */ |
| 2353 | eiter = entries + size; |
| 2354 | eiter->type = cpu_to_be16(FDMI_PORT_FABRIC_NAME); |
| 2355 | memcpy(eiter->a.fabric_name, vha->fabric_node_name, WWN_SIZE); |
| 2356 | eiter->len = cpu_to_be16(4 + WWN_SIZE); |
| 2357 | size += 4 + WWN_SIZE; |
| 2358 | |
| 2359 | ql_dbg(ql_dbg_disc, vha, 0x20c5, |
| 2360 | "Fabric Name = %016llx.\n", wwn_to_u64(eiter->a.fabric_name)); |
| 2361 | |
| 2362 | /* FC4_type */ |
| 2363 | eiter = entries + size; |
| 2364 | eiter->type = cpu_to_be16(FDMI_PORT_FC4_TYPE); |
| 2365 | eiter->a.port_fc4_type[0] = 0; |
| 2366 | eiter->a.port_fc4_type[1] = 0; |
| 2367 | eiter->a.port_fc4_type[2] = 1; |
| 2368 | eiter->a.port_fc4_type[3] = 0; |
| 2369 | eiter->len = cpu_to_be16(4 + 32); |
| 2370 | size += 4 + 32; |
| 2371 | |
| 2372 | ql_dbg(ql_dbg_disc, vha, 0x20c6, |
| 2373 | "Port Active FC4 Type = %02x %02x.\n", |
| 2374 | eiter->a.port_fc4_type[2], eiter->a.port_fc4_type[1]); |
| 2375 | |
Duane Grigsby | 7d23648 | 2017-06-21 13:48:45 -0700 | [diff] [blame] | 2376 | if (vha->flags.nvme_enabled) { |
| 2377 | eiter->a.port_fc4_type[4] = 0; |
| 2378 | eiter->a.port_fc4_type[5] = 0; |
| 2379 | eiter->a.port_fc4_type[6] = 1; /* NVMe type 28h */ |
| 2380 | ql_dbg(ql_dbg_disc, vha, 0x2120, |
| 2381 | "NVME Port Active FC4 Type = %02x 0x0 0x0 0x0 0x0 0x0.\n", |
| 2382 | eiter->a.port_fc4_type[6]); |
| 2383 | } |
| 2384 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2385 | /* Port State */ |
| 2386 | eiter = entries + size; |
| 2387 | eiter->type = cpu_to_be16(FDMI_PORT_STATE); |
| 2388 | eiter->a.port_state = cpu_to_be32(1); |
| 2389 | eiter->len = cpu_to_be16(4 + 4); |
| 2390 | size += 4 + 4; |
| 2391 | |
| 2392 | ql_dbg(ql_dbg_disc, vha, 0x20c7, |
| 2393 | "Port State = %x.\n", eiter->a.port_state); |
| 2394 | |
| 2395 | /* Number of Ports */ |
| 2396 | eiter = entries + size; |
| 2397 | eiter->type = cpu_to_be16(FDMI_PORT_COUNT); |
| 2398 | eiter->a.num_ports = cpu_to_be32(1); |
| 2399 | eiter->len = cpu_to_be16(4 + 4); |
| 2400 | size += 4 + 4; |
| 2401 | |
| 2402 | ql_dbg(ql_dbg_disc, vha, 0x20c8, |
| 2403 | "Number of ports = %x.\n", eiter->a.num_ports); |
| 2404 | |
| 2405 | /* Port Id */ |
| 2406 | eiter = entries + size; |
| 2407 | eiter->type = cpu_to_be16(FDMI_PORT_ID); |
| 2408 | eiter->a.port_id = cpu_to_be32(vha->d_id.b24); |
| 2409 | eiter->len = cpu_to_be16(4 + 4); |
| 2410 | size += 4 + 4; |
| 2411 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2412 | ql_dbg(ql_dbg_disc, vha, 0x201c, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2413 | "Port Id = %x.\n", eiter->a.port_id); |
Andrew Vasquez | a740a3f | 2006-10-02 12:00:45 -0700 | [diff] [blame] | 2414 | |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2415 | /* Update MS request size. */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2416 | qla2x00_update_ms_fdmi_iocb(vha, size + 16); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2417 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2418 | ql_dbg(ql_dbg_disc, vha, 0x2018, |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 2419 | "RPA portname= %8phN size=%d.\n", ct_req->req.rpa.port_name, size); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2420 | ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x20ca, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2421 | entries, size); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2422 | |
| 2423 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2424 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2425 | sizeof(ms_iocb_entry_t)); |
| 2426 | if (rval != QLA_SUCCESS) { |
| 2427 | /*EMPTY*/ |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2428 | ql_dbg(ql_dbg_disc, vha, 0x20cb, |
| 2429 | "RPA FDMI v2 issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2430 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RPA") != |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2431 | QLA_SUCCESS) { |
| 2432 | rval = QLA_FUNCTION_FAILED; |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2433 | if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM && |
| 2434 | ct_rsp->header.explanation_code == |
| 2435 | CT_EXPL_ALREADY_REGISTERED) { |
| 2436 | ql_dbg(ql_dbg_disc, vha, 0x20ce, |
| 2437 | "RPA FDMI v2 already registered\n"); |
| 2438 | rval = QLA_ALREADY_REGISTERED; |
| 2439 | } else { |
| 2440 | ql_dbg(ql_dbg_disc, vha, 0x2020, |
| 2441 | "RPA FDMI v2 failed, CT Reason code: 0x%x, CT Explanation 0x%x\n", |
| 2442 | ct_rsp->header.reason_code, |
| 2443 | ct_rsp->header.explanation_code); |
| 2444 | } |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2445 | } else { |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2446 | ql_dbg(ql_dbg_disc, vha, 0x20cc, |
| 2447 | "RPA FDMI V2 exiting normally.\n"); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2448 | } |
| 2449 | |
| 2450 | return rval; |
| 2451 | } |
| 2452 | |
| 2453 | /** |
| 2454 | * qla2x00_fdmi_register() - |
| 2455 | * @ha: HA context |
| 2456 | * |
| 2457 | * Returns 0 on success. |
| 2458 | */ |
| 2459 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2460 | qla2x00_fdmi_register(scsi_qla_host_t *vha) |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2461 | { |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2462 | int rval = QLA_FUNCTION_FAILED; |
| 2463 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 80de7ef | 2009-07-31 15:09:33 -0700 | [diff] [blame] | 2464 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2465 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || |
| 2466 | IS_QLAFX00(ha)) |
Andrew Vasquez | 80de7ef | 2009-07-31 15:09:33 -0700 | [diff] [blame] | 2467 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2468 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2469 | rval = qla2x00_mgmt_svr_login(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2470 | if (rval) |
| 2471 | return rval; |
| 2472 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2473 | rval = qla2x00_fdmiv2_rhba(vha); |
| 2474 | if (rval) { |
| 2475 | if (rval != QLA_ALREADY_REGISTERED) |
| 2476 | goto try_fdmi; |
| 2477 | |
| 2478 | rval = qla2x00_fdmi_dhba(vha); |
| 2479 | if (rval) |
| 2480 | goto try_fdmi; |
| 2481 | |
| 2482 | rval = qla2x00_fdmiv2_rhba(vha); |
| 2483 | if (rval) |
| 2484 | goto try_fdmi; |
| 2485 | } |
| 2486 | rval = qla2x00_fdmiv2_rpa(vha); |
| 2487 | if (rval) |
| 2488 | goto try_fdmi; |
| 2489 | |
| 2490 | goto out; |
| 2491 | |
| 2492 | try_fdmi: |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2493 | rval = qla2x00_fdmi_rhba(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2494 | if (rval) { |
| 2495 | if (rval != QLA_ALREADY_REGISTERED) |
| 2496 | return rval; |
| 2497 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2498 | rval = qla2x00_fdmi_dhba(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2499 | if (rval) |
| 2500 | return rval; |
| 2501 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2502 | rval = qla2x00_fdmi_rhba(vha); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2503 | if (rval) |
| 2504 | return rval; |
| 2505 | } |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2506 | rval = qla2x00_fdmi_rpa(vha); |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2507 | out: |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 2508 | return rval; |
| 2509 | } |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2510 | |
| 2511 | /** |
| 2512 | * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query. |
| 2513 | * @ha: HA context |
| 2514 | * @list: switch info entries to populate |
| 2515 | * |
| 2516 | * Returns 0 on success. |
| 2517 | */ |
| 2518 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2519 | qla2x00_gfpn_id(scsi_qla_host_t *vha, sw_info_t *list) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2520 | { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2521 | int rval = QLA_SUCCESS; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2522 | uint16_t i; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2523 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2524 | ms_iocb_entry_t *ms_pkt; |
| 2525 | struct ct_sns_req *ct_req; |
| 2526 | struct ct_sns_rsp *ct_rsp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2527 | struct ct_arg arg; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2528 | |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2529 | if (!IS_IIDMA_CAPABLE(ha)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2530 | return QLA_FUNCTION_FAILED; |
| 2531 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2532 | arg.iocb = ha->ms_iocb; |
| 2533 | arg.req_dma = ha->ct_sns_dma; |
| 2534 | arg.rsp_dma = ha->ct_sns_dma; |
| 2535 | arg.req_size = GFPN_ID_REQ_SIZE; |
| 2536 | arg.rsp_size = GFPN_ID_RSP_SIZE; |
| 2537 | arg.nport_handle = NPH_SNS; |
| 2538 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2539 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2540 | /* Issue GFPN_ID */ |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2541 | /* Prepare common MS IOCB */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2542 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, &arg); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2543 | |
| 2544 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 2545 | ct_req = qla2x00_prep_ct_req(ha->ct_sns, GFPN_ID_CMD, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2546 | GFPN_ID_RSP_SIZE); |
| 2547 | ct_rsp = &ha->ct_sns->p.rsp; |
| 2548 | |
| 2549 | /* Prepare CT arguments -- port_id */ |
| 2550 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; |
| 2551 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; |
| 2552 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; |
| 2553 | |
| 2554 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2555 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2556 | sizeof(ms_iocb_entry_t)); |
| 2557 | if (rval != QLA_SUCCESS) { |
| 2558 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2559 | ql_dbg(ql_dbg_disc, vha, 0x2023, |
| 2560 | "GFPN_ID issue IOCB failed (%d).\n", rval); |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 2561 | break; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2562 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2563 | "GFPN_ID") != QLA_SUCCESS) { |
| 2564 | rval = QLA_FUNCTION_FAILED; |
Arun Easi | dafdf89 | 2012-02-09 11:16:00 -0800 | [diff] [blame] | 2565 | break; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2566 | } else { |
| 2567 | /* Save fabric portname */ |
| 2568 | memcpy(list[i].fabric_port_name, |
| 2569 | ct_rsp->rsp.gfpn_id.port_name, WWN_SIZE); |
| 2570 | } |
| 2571 | |
| 2572 | /* Last device exit. */ |
| 2573 | if (list[i].d_id.b.rsvd_1 != 0) |
| 2574 | break; |
| 2575 | } |
| 2576 | |
| 2577 | return (rval); |
| 2578 | } |
| 2579 | |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2580 | |
| 2581 | static inline struct ct_sns_req * |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 2582 | 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] | 2583 | uint16_t rsp_size) |
| 2584 | { |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 2585 | memset(p, 0, sizeof(struct ct_sns_pkt)); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2586 | |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 2587 | p->p.req.header.revision = 0x01; |
| 2588 | p->p.req.header.gs_type = 0xFA; |
| 2589 | p->p.req.header.gs_subtype = 0x01; |
| 2590 | p->p.req.command = cpu_to_be16(cmd); |
| 2591 | 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] | 2592 | |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 2593 | return &p->p.req; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2594 | } |
| 2595 | |
| 2596 | /** |
| 2597 | * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query. |
| 2598 | * @ha: HA context |
| 2599 | * @list: switch info entries to populate |
| 2600 | * |
| 2601 | * Returns 0 on success. |
| 2602 | */ |
| 2603 | int |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2604 | qla2x00_gpsc(scsi_qla_host_t *vha, sw_info_t *list) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2605 | { |
| 2606 | int rval; |
| 2607 | uint16_t i; |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2608 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2609 | ms_iocb_entry_t *ms_pkt; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2610 | struct ct_sns_req *ct_req; |
| 2611 | struct ct_sns_rsp *ct_rsp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2612 | struct ct_arg arg; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2613 | |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2614 | if (!IS_IIDMA_CAPABLE(ha)) |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2615 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 2616 | if (!ha->flags.gpsc_supported) |
| 2617 | return QLA_FUNCTION_FAILED; |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2618 | |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2619 | rval = qla2x00_mgmt_svr_login(vha); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2620 | if (rval) |
| 2621 | return rval; |
| 2622 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2623 | arg.iocb = ha->ms_iocb; |
| 2624 | arg.req_dma = ha->ct_sns_dma; |
| 2625 | arg.rsp_dma = ha->ct_sns_dma; |
| 2626 | arg.req_size = GPSC_REQ_SIZE; |
| 2627 | arg.rsp_size = GPSC_RSP_SIZE; |
| 2628 | arg.nport_handle = vha->mgmt_svr_loop_id; |
| 2629 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2630 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2631 | /* Issue GFPN_ID */ |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2632 | /* Prepare common MS IOCB */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2633 | ms_pkt = qla24xx_prep_ms_iocb(vha, &arg); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2634 | |
| 2635 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 2636 | ct_req = qla24xx_prep_ct_fm_req(ha->ct_sns, GPSC_CMD, |
| 2637 | GPSC_RSP_SIZE); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2638 | ct_rsp = &ha->ct_sns->p.rsp; |
| 2639 | |
| 2640 | /* Prepare CT arguments -- port_name */ |
| 2641 | memcpy(ct_req->req.gpsc.port_name, list[i].fabric_port_name, |
| 2642 | WWN_SIZE); |
| 2643 | |
| 2644 | /* Execute MS IOCB */ |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2645 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2646 | sizeof(ms_iocb_entry_t)); |
| 2647 | if (rval != QLA_SUCCESS) { |
| 2648 | /*EMPTY*/ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2649 | ql_dbg(ql_dbg_disc, vha, 0x2059, |
| 2650 | "GPSC issue IOCB failed (%d).\n", rval); |
Anirban Chakraborty | 7b867cf | 2008-11-06 10:40:19 -0800 | [diff] [blame] | 2651 | } else if ((rval = qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 2652 | "GPSC")) != QLA_SUCCESS) { |
| 2653 | /* FM command unsupported? */ |
| 2654 | if (rval == QLA_INVALID_COMMAND && |
Andrew Vasquez | 3fe7cfb | 2008-04-03 13:13:23 -0700 | [diff] [blame] | 2655 | (ct_rsp->header.reason_code == |
| 2656 | CT_REASON_INVALID_COMMAND_CODE || |
| 2657 | ct_rsp->header.reason_code == |
| 2658 | CT_REASON_COMMAND_UNSUPPORTED)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2659 | ql_dbg(ql_dbg_disc, vha, 0x205a, |
| 2660 | "GPSC command unsupported, disabling " |
| 2661 | "query.\n"); |
Andrew Vasquez | 4346b14 | 2006-12-13 19:20:28 -0800 | [diff] [blame] | 2662 | ha->flags.gpsc_supported = 0; |
| 2663 | rval = QLA_FUNCTION_FAILED; |
| 2664 | break; |
| 2665 | } |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2666 | rval = QLA_FUNCTION_FAILED; |
| 2667 | } else { |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 2668 | /* Save port-speed */ |
| 2669 | switch (be16_to_cpu(ct_rsp->rsp.gpsc.speed)) { |
| 2670 | case BIT_15: |
| 2671 | list[i].fp_speed = PORT_SPEED_1GB; |
| 2672 | break; |
| 2673 | case BIT_14: |
| 2674 | list[i].fp_speed = PORT_SPEED_2GB; |
| 2675 | break; |
| 2676 | case BIT_13: |
| 2677 | list[i].fp_speed = PORT_SPEED_4GB; |
| 2678 | break; |
Andrew Vasquez | 9f8fdde | 2009-06-03 09:55:22 -0700 | [diff] [blame] | 2679 | case BIT_12: |
| 2680 | list[i].fp_speed = PORT_SPEED_10GB; |
| 2681 | break; |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 2682 | case BIT_11: |
| 2683 | list[i].fp_speed = PORT_SPEED_8GB; |
| 2684 | break; |
Joe Carnuccio | c53dfac | 2012-11-21 02:40:39 -0500 | [diff] [blame] | 2685 | case BIT_10: |
| 2686 | list[i].fp_speed = PORT_SPEED_16GB; |
| 2687 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2688 | case BIT_8: |
| 2689 | list[i].fp_speed = PORT_SPEED_32GB; |
| 2690 | break; |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 2691 | } |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2692 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2693 | ql_dbg(ql_dbg_disc, vha, 0x205b, |
| 2694 | "GPSC ext entry - fpn " |
Oleksandr Khoshaba | 7b833558 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 2695 | "%8phN speeds=%04x speed=%04x.\n", |
| 2696 | list[i].fabric_port_name, |
Andrew Vasquez | a3cbdfa | 2007-08-13 10:13:18 -0700 | [diff] [blame] | 2697 | be16_to_cpu(ct_rsp->rsp.gpsc.speeds), |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2698 | be16_to_cpu(ct_rsp->rsp.gpsc.speed)); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 2699 | } |
| 2700 | |
| 2701 | /* Last device exit. */ |
| 2702 | if (list[i].d_id.b.rsvd_1 != 0) |
| 2703 | break; |
| 2704 | } |
| 2705 | |
| 2706 | return (rval); |
| 2707 | } |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2708 | |
| 2709 | /** |
| 2710 | * qla2x00_gff_id() - SNS Get FC-4 Features (GFF_ID) query. |
| 2711 | * |
| 2712 | * @ha: HA context |
| 2713 | * @list: switch info entries to populate |
| 2714 | * |
| 2715 | */ |
| 2716 | void |
| 2717 | qla2x00_gff_id(scsi_qla_host_t *vha, sw_info_t *list) |
| 2718 | { |
| 2719 | int rval; |
| 2720 | uint16_t i; |
| 2721 | |
| 2722 | ms_iocb_entry_t *ms_pkt; |
| 2723 | struct ct_sns_req *ct_req; |
| 2724 | struct ct_sns_rsp *ct_rsp; |
| 2725 | struct qla_hw_data *ha = vha->hw; |
| 2726 | uint8_t fcp_scsi_features = 0; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2727 | struct ct_arg arg; |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2728 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2729 | for (i = 0; i < ha->max_fibre_devices; i++) { |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2730 | /* Set default FC4 Type as UNKNOWN so the default is to |
| 2731 | * Process this port */ |
| 2732 | list[i].fc4_type = FC4_TYPE_UNKNOWN; |
| 2733 | |
| 2734 | /* Do not attempt GFF_ID if we are not FWI_2 capable */ |
| 2735 | if (!IS_FWI2_CAPABLE(ha)) |
| 2736 | continue; |
| 2737 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2738 | arg.iocb = ha->ms_iocb; |
| 2739 | arg.req_dma = ha->ct_sns_dma; |
| 2740 | arg.rsp_dma = ha->ct_sns_dma; |
| 2741 | arg.req_size = GFF_ID_REQ_SIZE; |
| 2742 | arg.rsp_size = GFF_ID_RSP_SIZE; |
| 2743 | arg.nport_handle = NPH_SNS; |
| 2744 | |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2745 | /* Prepare common MS IOCB */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2746 | ms_pkt = ha->isp_ops->prep_ms_iocb(vha, &arg); |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2747 | |
| 2748 | /* Prepare CT request */ |
Bart Van Assche | 6ec6f90 | 2013-06-25 11:27:28 -0400 | [diff] [blame] | 2749 | ct_req = qla2x00_prep_ct_req(ha->ct_sns, GFF_ID_CMD, |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2750 | GFF_ID_RSP_SIZE); |
| 2751 | ct_rsp = &ha->ct_sns->p.rsp; |
| 2752 | |
| 2753 | /* Prepare CT arguments -- port_id */ |
| 2754 | ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain; |
| 2755 | ct_req->req.port_id.port_id[1] = list[i].d_id.b.area; |
| 2756 | ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa; |
| 2757 | |
| 2758 | /* Execute MS IOCB */ |
| 2759 | rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma, |
| 2760 | sizeof(ms_iocb_entry_t)); |
| 2761 | |
| 2762 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2763 | ql_dbg(ql_dbg_disc, vha, 0x205c, |
| 2764 | "GFF_ID issue IOCB failed (%d).\n", rval); |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2765 | } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, |
Andrew Vasquez | 7a78ced | 2011-02-23 15:27:12 -0800 | [diff] [blame] | 2766 | "GFF_ID") != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2767 | ql_dbg(ql_dbg_disc, vha, 0x205d, |
| 2768 | "GFF_ID IOCB status had a failure status code.\n"); |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2769 | } else { |
| 2770 | fcp_scsi_features = |
| 2771 | ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET]; |
| 2772 | fcp_scsi_features &= 0x0f; |
| 2773 | |
| 2774 | if (fcp_scsi_features) |
| 2775 | list[i].fc4_type = FC4_TYPE_FCP_SCSI; |
| 2776 | else |
| 2777 | list[i].fc4_type = FC4_TYPE_OTHER; |
Duane Grigsby | d3bae93 | 2017-06-21 13:48:44 -0700 | [diff] [blame] | 2778 | |
| 2779 | list[i].fc4f_nvme = |
| 2780 | ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET]; |
| 2781 | list[i].fc4f_nvme &= 0xf; |
Chad Dupuis | e8c72ba | 2010-07-23 15:28:25 +0500 | [diff] [blame] | 2782 | } |
| 2783 | |
| 2784 | /* Last device exit. */ |
| 2785 | if (list[i].d_id.b.rsvd_1 != 0) |
| 2786 | break; |
| 2787 | } |
| 2788 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2789 | |
| 2790 | /* GID_PN completion processing. */ |
| 2791 | void qla24xx_handle_gidpn_event(scsi_qla_host_t *vha, struct event_arg *ea) |
| 2792 | { |
| 2793 | fc_port_t *fcport = ea->fcport; |
| 2794 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2795 | ql_dbg(ql_dbg_disc, vha, 0x201d, |
| 2796 | "%s %8phC login state %d\n", |
| 2797 | __func__, fcport->port_name, fcport->fw_login_state); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2798 | |
| 2799 | if (ea->sp->gen2 != fcport->login_gen) { |
| 2800 | /* PLOGI/PRLI/LOGO came in while cmd was out.*/ |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2801 | ql_dbg(ql_dbg_disc, vha, 0x201e, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2802 | "%s %8phC generation changed rscn %d|%d login %d|%d \n", |
| 2803 | __func__, fcport->port_name, fcport->last_rscn_gen, |
| 2804 | fcport->rscn_gen, fcport->last_login_gen, fcport->login_gen); |
| 2805 | return; |
| 2806 | } |
| 2807 | |
| 2808 | if (!ea->rc) { |
| 2809 | if (ea->sp->gen1 == fcport->rscn_gen) { |
| 2810 | fcport->scan_state = QLA_FCPORT_FOUND; |
| 2811 | fcport->flags |= FCF_FABRIC_DEVICE; |
| 2812 | |
| 2813 | if (fcport->d_id.b24 == ea->id.b24) { |
| 2814 | /* cable plugged into the same place */ |
| 2815 | switch (vha->host->active_mode) { |
| 2816 | case MODE_TARGET: |
| 2817 | /* NOOP. let the other guy login to us.*/ |
| 2818 | break; |
| 2819 | case MODE_INITIATOR: |
| 2820 | case MODE_DUAL: |
| 2821 | default: |
Quinn Tran | a07fc0a | 2017-08-23 15:05:21 -0700 | [diff] [blame] | 2822 | ql_dbg(ql_dbg_disc, vha, 0x201f, |
| 2823 | "%s %d %8phC post %s\n", __func__, |
| 2824 | __LINE__, fcport->port_name, |
| 2825 | (atomic_read(&fcport->state) == |
| 2826 | FCS_ONLINE) ? "gpdb" : "gnl"); |
| 2827 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2828 | if (atomic_read(&fcport->state) == |
| 2829 | FCS_ONLINE) |
Quinn Tran | a07fc0a | 2017-08-23 15:05:21 -0700 | [diff] [blame] | 2830 | qla24xx_post_gpdb_work(vha, |
| 2831 | fcport, PDO_FORCE_ADISC); |
| 2832 | else |
| 2833 | qla24xx_post_gnl_work(vha, |
| 2834 | fcport); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2835 | break; |
| 2836 | } |
| 2837 | } else { /* fcport->d_id.b24 != ea->id.b24 */ |
| 2838 | fcport->d_id.b24 = ea->id.b24; |
Quinn Tran | a084fd6 | 2017-12-04 14:45:00 -0800 | [diff] [blame] | 2839 | if (fcport->deleted != QLA_SESS_DELETED) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2840 | ql_dbg(ql_dbg_disc, vha, 0x2021, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2841 | "%s %d %8phC post del sess\n", |
| 2842 | __func__, __LINE__, fcport->port_name); |
| 2843 | qlt_schedule_sess_for_deletion_lock(fcport); |
| 2844 | } |
| 2845 | } |
| 2846 | } else { /* ea->sp->gen1 != fcport->rscn_gen */ |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2847 | ql_dbg(ql_dbg_disc, vha, 0x2022, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2848 | "%s %d %8phC post gidpn\n", |
| 2849 | __func__, __LINE__, fcport->port_name); |
| 2850 | /* rscn came in while cmd was out */ |
| 2851 | qla24xx_post_gidpn_work(vha, fcport); |
| 2852 | } |
| 2853 | } else { /* ea->rc */ |
| 2854 | /* cable pulled */ |
| 2855 | if (ea->sp->gen1 == fcport->rscn_gen) { |
| 2856 | if (ea->sp->gen2 == fcport->login_gen) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2857 | ql_dbg(ql_dbg_disc, vha, 0x2042, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2858 | "%s %d %8phC post del sess\n", __func__, |
| 2859 | __LINE__, fcport->port_name); |
| 2860 | qlt_schedule_sess_for_deletion_lock(fcport); |
| 2861 | } else { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2862 | ql_dbg(ql_dbg_disc, vha, 0x2045, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2863 | "%s %d %8phC login\n", __func__, __LINE__, |
| 2864 | fcport->port_name); |
| 2865 | qla24xx_fcport_handle_login(vha, fcport); |
| 2866 | } |
| 2867 | } else { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2868 | ql_dbg(ql_dbg_disc, vha, 0x2049, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2869 | "%s %d %8phC post gidpn\n", __func__, __LINE__, |
| 2870 | fcport->port_name); |
| 2871 | qla24xx_post_gidpn_work(vha, fcport); |
| 2872 | } |
| 2873 | } |
| 2874 | } /* gidpn_event */ |
| 2875 | |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 2876 | static void qla2x00_async_gidpn_sp_done(void *s, int res) |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2877 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 2878 | struct srb *sp = s; |
| 2879 | struct scsi_qla_host *vha = sp->vha; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2880 | fc_port_t *fcport = sp->fcport; |
| 2881 | u8 *id = fcport->ct_desc.ct_sns->p.rsp.rsp.gid_pn.port_id; |
| 2882 | struct event_arg ea; |
| 2883 | |
| 2884 | fcport->flags &= ~FCF_ASYNC_SENT; |
| 2885 | |
| 2886 | memset(&ea, 0, sizeof(ea)); |
| 2887 | ea.fcport = fcport; |
| 2888 | ea.id.b.domain = id[0]; |
| 2889 | ea.id.b.area = id[1]; |
| 2890 | ea.id.b.al_pa = id[2]; |
| 2891 | ea.sp = sp; |
| 2892 | ea.rc = res; |
| 2893 | ea.event = FCME_GIDPN_DONE; |
| 2894 | |
Quinn Tran | 25ad76b | 2017-12-04 14:45:01 -0800 | [diff] [blame] | 2895 | if (res == QLA_FUNCTION_TIMEOUT) { |
| 2896 | ql_dbg(ql_dbg_disc, sp->vha, 0xffff, |
| 2897 | "Async done-%s WWPN %8phC timed out.\n", |
| 2898 | sp->name, fcport->port_name); |
| 2899 | qla24xx_post_gidpn_work(sp->vha, fcport); |
| 2900 | sp->free(sp); |
| 2901 | return; |
| 2902 | } else if (res) { |
| 2903 | ql_dbg(ql_dbg_disc, sp->vha, 0xffff, |
| 2904 | "Async done-%s fail res %x, WWPN %8phC\n", |
| 2905 | sp->name, res, fcport->port_name); |
| 2906 | } else { |
| 2907 | ql_dbg(ql_dbg_disc, vha, 0x204f, |
| 2908 | "Async done-%s good WWPN %8phC ID %3phC\n", |
| 2909 | sp->name, fcport->port_name, id); |
| 2910 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2911 | |
| 2912 | qla2x00_fcport_event_handler(vha, &ea); |
| 2913 | |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 2914 | sp->free(sp); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2915 | } |
| 2916 | |
| 2917 | int qla24xx_async_gidpn(scsi_qla_host_t *vha, fc_port_t *fcport) |
| 2918 | { |
| 2919 | int rval = QLA_FUNCTION_FAILED; |
| 2920 | struct ct_sns_req *ct_req; |
| 2921 | srb_t *sp; |
| 2922 | |
| 2923 | if (!vha->flags.online) |
| 2924 | goto done; |
| 2925 | |
| 2926 | fcport->flags |= FCF_ASYNC_SENT; |
| 2927 | fcport->disc_state = DSC_GID_PN; |
| 2928 | fcport->scan_state = QLA_FCPORT_SCAN; |
| 2929 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
| 2930 | if (!sp) |
| 2931 | goto done; |
| 2932 | |
| 2933 | sp->type = SRB_CT_PTHRU_CMD; |
| 2934 | sp->name = "gidpn"; |
| 2935 | sp->gen1 = fcport->rscn_gen; |
| 2936 | sp->gen2 = fcport->login_gen; |
| 2937 | |
| 2938 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 2939 | |
| 2940 | /* CT_IU preamble */ |
| 2941 | ct_req = qla2x00_prep_ct_req(fcport->ct_desc.ct_sns, GID_PN_CMD, |
| 2942 | GID_PN_RSP_SIZE); |
| 2943 | |
| 2944 | /* GIDPN req */ |
| 2945 | memcpy(ct_req->req.gid_pn.port_name, fcport->port_name, |
| 2946 | WWN_SIZE); |
| 2947 | |
| 2948 | /* req & rsp use the same buffer */ |
| 2949 | sp->u.iocb_cmd.u.ctarg.req = fcport->ct_desc.ct_sns; |
| 2950 | sp->u.iocb_cmd.u.ctarg.req_dma = fcport->ct_desc.ct_sns_dma; |
| 2951 | sp->u.iocb_cmd.u.ctarg.rsp = fcport->ct_desc.ct_sns; |
| 2952 | sp->u.iocb_cmd.u.ctarg.rsp_dma = fcport->ct_desc.ct_sns_dma; |
| 2953 | sp->u.iocb_cmd.u.ctarg.req_size = GID_PN_REQ_SIZE; |
| 2954 | sp->u.iocb_cmd.u.ctarg.rsp_size = GID_PN_RSP_SIZE; |
| 2955 | sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS; |
| 2956 | |
| 2957 | sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; |
| 2958 | sp->done = qla2x00_async_gidpn_sp_done; |
| 2959 | |
| 2960 | rval = qla2x00_start_sp(sp); |
| 2961 | if (rval != QLA_SUCCESS) |
| 2962 | goto done_free_sp; |
| 2963 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 2964 | ql_dbg(ql_dbg_disc, vha, 0x20a4, |
| 2965 | "Async-%s - %8phC hdl=%x loopid=%x portid %02x%02x%02x.\n", |
| 2966 | sp->name, fcport->port_name, |
| 2967 | sp->handle, fcport->loop_id, fcport->d_id.b.domain, |
| 2968 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2969 | return rval; |
| 2970 | |
| 2971 | done_free_sp: |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 2972 | sp->free(sp); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2973 | done: |
| 2974 | fcport->flags &= ~FCF_ASYNC_SENT; |
| 2975 | return rval; |
| 2976 | } |
| 2977 | |
| 2978 | int qla24xx_post_gidpn_work(struct scsi_qla_host *vha, fc_port_t *fcport) |
| 2979 | { |
| 2980 | struct qla_work_evt *e; |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 2981 | int ls; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2982 | |
Quinn Tran | 41dc529 | 2017-01-19 22:28:03 -0800 | [diff] [blame] | 2983 | ls = atomic_read(&vha->loop_state); |
| 2984 | if (((ls != LOOP_READY) && (ls != LOOP_UP)) || |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 2985 | test_bit(UNLOADING, &vha->dpc_flags)) |
| 2986 | return 0; |
| 2987 | |
| 2988 | e = qla2x00_alloc_work(vha, QLA_EVT_GIDPN); |
| 2989 | if (!e) |
| 2990 | return QLA_FUNCTION_FAILED; |
| 2991 | |
| 2992 | e->u.fcport.fcport = fcport; |
| 2993 | return qla2x00_post_work(vha, e); |
| 2994 | } |
| 2995 | |
| 2996 | int qla24xx_post_gpsc_work(struct scsi_qla_host *vha, fc_port_t *fcport) |
| 2997 | { |
| 2998 | struct qla_work_evt *e; |
| 2999 | |
| 3000 | e = qla2x00_alloc_work(vha, QLA_EVT_GPSC); |
| 3001 | if (!e) |
| 3002 | return QLA_FUNCTION_FAILED; |
| 3003 | |
| 3004 | e->u.fcport.fcport = fcport; |
| 3005 | return qla2x00_post_work(vha, e); |
| 3006 | } |
| 3007 | |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 3008 | static void qla24xx_async_gpsc_sp_done(void *s, int res) |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3009 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 3010 | struct srb *sp = s; |
| 3011 | struct scsi_qla_host *vha = sp->vha; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3012 | struct qla_hw_data *ha = vha->hw; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3013 | fc_port_t *fcport = sp->fcport; |
| 3014 | struct ct_sns_rsp *ct_rsp; |
| 3015 | struct event_arg ea; |
| 3016 | |
| 3017 | ct_rsp = &fcport->ct_desc.ct_sns->p.rsp; |
| 3018 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3019 | ql_dbg(ql_dbg_disc, vha, 0x2053, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3020 | "Async done-%s res %x, WWPN %8phC \n", |
| 3021 | sp->name, res, fcport->port_name); |
| 3022 | |
| 3023 | fcport->flags &= ~FCF_ASYNC_SENT; |
| 3024 | |
| 3025 | if (res == (DID_ERROR << 16)) { |
| 3026 | /* entry status error */ |
| 3027 | goto done; |
| 3028 | } else if (res) { |
| 3029 | if ((ct_rsp->header.reason_code == |
| 3030 | CT_REASON_INVALID_COMMAND_CODE) || |
| 3031 | (ct_rsp->header.reason_code == |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3032 | CT_REASON_COMMAND_UNSUPPORTED)) { |
| 3033 | ql_dbg(ql_dbg_disc, vha, 0x2019, |
| 3034 | "GPSC command unsupported, disabling query.\n"); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3035 | ha->flags.gpsc_supported = 0; |
| 3036 | res = QLA_SUCCESS; |
| 3037 | } |
| 3038 | } else { |
| 3039 | switch (be16_to_cpu(ct_rsp->rsp.gpsc.speed)) { |
| 3040 | case BIT_15: |
| 3041 | fcport->fp_speed = PORT_SPEED_1GB; |
| 3042 | break; |
| 3043 | case BIT_14: |
| 3044 | fcport->fp_speed = PORT_SPEED_2GB; |
| 3045 | break; |
| 3046 | case BIT_13: |
| 3047 | fcport->fp_speed = PORT_SPEED_4GB; |
| 3048 | break; |
| 3049 | case BIT_12: |
| 3050 | fcport->fp_speed = PORT_SPEED_10GB; |
| 3051 | break; |
| 3052 | case BIT_11: |
| 3053 | fcport->fp_speed = PORT_SPEED_8GB; |
| 3054 | break; |
| 3055 | case BIT_10: |
| 3056 | fcport->fp_speed = PORT_SPEED_16GB; |
| 3057 | break; |
| 3058 | case BIT_8: |
| 3059 | fcport->fp_speed = PORT_SPEED_32GB; |
| 3060 | break; |
| 3061 | } |
| 3062 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3063 | ql_dbg(ql_dbg_disc, vha, 0x2054, |
| 3064 | "Async-%s OUT WWPN %8phC speeds=%04x speed=%04x.\n", |
| 3065 | sp->name, fcport->fabric_port_name, |
| 3066 | be16_to_cpu(ct_rsp->rsp.gpsc.speeds), |
| 3067 | be16_to_cpu(ct_rsp->rsp.gpsc.speed)); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3068 | } |
| 3069 | done: |
| 3070 | memset(&ea, 0, sizeof(ea)); |
| 3071 | ea.event = FCME_GPSC_DONE; |
| 3072 | ea.rc = res; |
| 3073 | ea.fcport = fcport; |
| 3074 | qla2x00_fcport_event_handler(vha, &ea); |
| 3075 | |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 3076 | sp->free(sp); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3077 | } |
| 3078 | |
| 3079 | int qla24xx_async_gpsc(scsi_qla_host_t *vha, fc_port_t *fcport) |
| 3080 | { |
| 3081 | int rval = QLA_FUNCTION_FAILED; |
| 3082 | struct ct_sns_req *ct_req; |
| 3083 | srb_t *sp; |
| 3084 | |
| 3085 | if (!vha->flags.online) |
| 3086 | goto done; |
| 3087 | |
| 3088 | fcport->flags |= FCF_ASYNC_SENT; |
| 3089 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
| 3090 | if (!sp) |
| 3091 | goto done; |
| 3092 | |
| 3093 | sp->type = SRB_CT_PTHRU_CMD; |
| 3094 | sp->name = "gpsc"; |
| 3095 | sp->gen1 = fcport->rscn_gen; |
| 3096 | sp->gen2 = fcport->login_gen; |
| 3097 | |
| 3098 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 3099 | |
| 3100 | /* CT_IU preamble */ |
| 3101 | ct_req = qla24xx_prep_ct_fm_req(fcport->ct_desc.ct_sns, GPSC_CMD, |
| 3102 | GPSC_RSP_SIZE); |
| 3103 | |
| 3104 | /* GPSC req */ |
Quinn Tran | b2e8ae3 | 2017-08-23 15:05:06 -0700 | [diff] [blame] | 3105 | memcpy(ct_req->req.gpsc.port_name, fcport->fabric_port_name, |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3106 | WWN_SIZE); |
| 3107 | |
| 3108 | sp->u.iocb_cmd.u.ctarg.req = fcport->ct_desc.ct_sns; |
| 3109 | sp->u.iocb_cmd.u.ctarg.req_dma = fcport->ct_desc.ct_sns_dma; |
| 3110 | sp->u.iocb_cmd.u.ctarg.rsp = fcport->ct_desc.ct_sns; |
| 3111 | sp->u.iocb_cmd.u.ctarg.rsp_dma = fcport->ct_desc.ct_sns_dma; |
| 3112 | sp->u.iocb_cmd.u.ctarg.req_size = GPSC_REQ_SIZE; |
| 3113 | sp->u.iocb_cmd.u.ctarg.rsp_size = GPSC_RSP_SIZE; |
| 3114 | sp->u.iocb_cmd.u.ctarg.nport_handle = vha->mgmt_svr_loop_id; |
| 3115 | |
| 3116 | sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; |
| 3117 | sp->done = qla24xx_async_gpsc_sp_done; |
| 3118 | |
| 3119 | rval = qla2x00_start_sp(sp); |
| 3120 | if (rval != QLA_SUCCESS) |
| 3121 | goto done_free_sp; |
| 3122 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3123 | ql_dbg(ql_dbg_disc, vha, 0x205e, |
| 3124 | "Async-%s %8phC hdl=%x loopid=%x portid=%02x%02x%02x.\n", |
| 3125 | sp->name, fcport->port_name, sp->handle, |
| 3126 | fcport->loop_id, fcport->d_id.b.domain, |
| 3127 | fcport->d_id.b.area, fcport->d_id.b.al_pa); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3128 | return rval; |
| 3129 | |
| 3130 | done_free_sp: |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 3131 | sp->free(sp); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3132 | done: |
| 3133 | fcport->flags &= ~FCF_ASYNC_SENT; |
| 3134 | return rval; |
| 3135 | } |
| 3136 | |
| 3137 | int qla24xx_post_gpnid_work(struct scsi_qla_host *vha, port_id_t *id) |
| 3138 | { |
| 3139 | struct qla_work_evt *e; |
| 3140 | |
| 3141 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 3142 | return 0; |
| 3143 | |
| 3144 | e = qla2x00_alloc_work(vha, QLA_EVT_GPNID); |
| 3145 | if (!e) |
| 3146 | return QLA_FUNCTION_FAILED; |
| 3147 | |
| 3148 | e->u.gpnid.id = *id; |
| 3149 | return qla2x00_post_work(vha, e); |
| 3150 | } |
| 3151 | |
| 3152 | void qla24xx_async_gpnid_done(scsi_qla_host_t *vha, srb_t *sp) |
| 3153 | { |
| 3154 | if (sp->u.iocb_cmd.u.ctarg.req) { |
| 3155 | dma_free_coherent(&vha->hw->pdev->dev, |
| 3156 | sizeof(struct ct_sns_pkt), |
| 3157 | sp->u.iocb_cmd.u.ctarg.req, |
| 3158 | sp->u.iocb_cmd.u.ctarg.req_dma); |
| 3159 | sp->u.iocb_cmd.u.ctarg.req = NULL; |
| 3160 | } |
| 3161 | if (sp->u.iocb_cmd.u.ctarg.rsp) { |
| 3162 | dma_free_coherent(&vha->hw->pdev->dev, |
| 3163 | sizeof(struct ct_sns_pkt), |
| 3164 | sp->u.iocb_cmd.u.ctarg.rsp, |
| 3165 | sp->u.iocb_cmd.u.ctarg.rsp_dma); |
| 3166 | sp->u.iocb_cmd.u.ctarg.rsp = NULL; |
| 3167 | } |
| 3168 | |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 3169 | sp->free(sp); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3170 | } |
| 3171 | |
| 3172 | void qla24xx_handle_gpnid_event(scsi_qla_host_t *vha, struct event_arg *ea) |
| 3173 | { |
| 3174 | fc_port_t *fcport; |
| 3175 | unsigned long flags; |
| 3176 | |
| 3177 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 3178 | fcport = qla2x00_find_fcport_by_wwpn(vha, ea->port_name, 1); |
| 3179 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 3180 | |
| 3181 | if (fcport) { |
| 3182 | /* cable moved. just plugged in */ |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3183 | fcport->rscn_gen++; |
| 3184 | fcport->d_id = ea->id; |
| 3185 | fcport->scan_state = QLA_FCPORT_FOUND; |
| 3186 | fcport->flags |= FCF_FABRIC_DEVICE; |
| 3187 | |
Quinn Tran | 66ee0fe | 2017-06-02 09:11:56 -0700 | [diff] [blame] | 3188 | switch (fcport->disc_state) { |
| 3189 | case DSC_DELETED: |
| 3190 | ql_dbg(ql_dbg_disc, vha, 0x210d, |
| 3191 | "%s %d %8phC login\n", __func__, __LINE__, |
| 3192 | fcport->port_name); |
| 3193 | qla24xx_fcport_handle_login(vha, fcport); |
| 3194 | break; |
| 3195 | case DSC_DELETE_PEND: |
| 3196 | break; |
| 3197 | default: |
| 3198 | ql_dbg(ql_dbg_disc, vha, 0x2064, |
| 3199 | "%s %d %8phC post del sess\n", |
| 3200 | __func__, __LINE__, fcport->port_name); |
| 3201 | qlt_schedule_sess_for_deletion_lock(fcport); |
| 3202 | break; |
| 3203 | } |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3204 | } else { |
| 3205 | /* create new fcport */ |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3206 | ql_dbg(ql_dbg_disc, vha, 0x2065, |
| 3207 | "%s %d %8phC post new sess\n", |
| 3208 | __func__, __LINE__, ea->port_name); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3209 | |
| 3210 | qla24xx_post_newsess_work(vha, &ea->id, ea->port_name, NULL); |
| 3211 | } |
| 3212 | } |
| 3213 | |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 3214 | static void qla2x00_async_gpnid_sp_done(void *s, int res) |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3215 | { |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 3216 | struct srb *sp = s; |
| 3217 | struct scsi_qla_host *vha = sp->vha; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3218 | struct ct_sns_req *ct_req = |
| 3219 | (struct ct_sns_req *)sp->u.iocb_cmd.u.ctarg.req; |
| 3220 | struct ct_sns_rsp *ct_rsp = |
| 3221 | (struct ct_sns_rsp *)sp->u.iocb_cmd.u.ctarg.rsp; |
| 3222 | struct event_arg ea; |
| 3223 | struct qla_work_evt *e; |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame^] | 3224 | unsigned long flags; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3225 | |
Quinn Tran | a084fd6 | 2017-12-04 14:45:00 -0800 | [diff] [blame] | 3226 | if (res) |
| 3227 | ql_dbg(ql_dbg_disc, vha, 0x2066, |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame^] | 3228 | "Async done-%s fail res %x rscn gen %d ID %3phC. %8phC\n", |
| 3229 | sp->name, res, sp->gen1, ct_req->req.port_id.port_id, |
Quinn Tran | a084fd6 | 2017-12-04 14:45:00 -0800 | [diff] [blame] | 3230 | ct_rsp->rsp.gpn_id.port_name); |
| 3231 | else |
| 3232 | ql_dbg(ql_dbg_disc, vha, 0x2066, |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame^] | 3233 | "Async done-%s good rscn gen %d ID %3phC. %8phC\n", |
| 3234 | sp->name, sp->gen1, ct_req->req.port_id.port_id, |
Quinn Tran | a084fd6 | 2017-12-04 14:45:00 -0800 | [diff] [blame] | 3235 | ct_rsp->rsp.gpn_id.port_name); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3236 | |
| 3237 | memset(&ea, 0, sizeof(ea)); |
| 3238 | memcpy(ea.port_name, ct_rsp->rsp.gpn_id.port_name, WWN_SIZE); |
| 3239 | ea.sp = sp; |
| 3240 | ea.id.b.domain = ct_req->req.port_id.port_id[0]; |
| 3241 | ea.id.b.area = ct_req->req.port_id.port_id[1]; |
| 3242 | ea.id.b.al_pa = ct_req->req.port_id.port_id[2]; |
| 3243 | ea.rc = res; |
| 3244 | ea.event = FCME_GPNID_DONE; |
| 3245 | |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame^] | 3246 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 3247 | list_del(&sp->elem); |
| 3248 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 3249 | |
Quinn Tran | 25ad76b | 2017-12-04 14:45:01 -0800 | [diff] [blame] | 3250 | if (res) { |
| 3251 | if (res == QLA_FUNCTION_TIMEOUT) |
| 3252 | qla24xx_post_gpnid_work(sp->vha, &ea.id); |
| 3253 | sp->free(sp); |
| 3254 | return; |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame^] | 3255 | } else if (sp->gen1) { |
| 3256 | /* There was anoter RSNC for this Nport ID */ |
| 3257 | qla24xx_post_gpnid_work(sp->vha, &ea.id); |
| 3258 | sp->free(sp); |
| 3259 | return; |
Quinn Tran | 25ad76b | 2017-12-04 14:45:01 -0800 | [diff] [blame] | 3260 | } |
| 3261 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3262 | qla2x00_fcport_event_handler(vha, &ea); |
| 3263 | |
| 3264 | e = qla2x00_alloc_work(vha, QLA_EVT_GPNID_DONE); |
| 3265 | if (!e) { |
| 3266 | /* please ignore kernel warning. otherwise, we have mem leak. */ |
| 3267 | if (sp->u.iocb_cmd.u.ctarg.req) { |
| 3268 | dma_free_coherent(&vha->hw->pdev->dev, |
| 3269 | sizeof(struct ct_sns_pkt), |
| 3270 | sp->u.iocb_cmd.u.ctarg.req, |
| 3271 | sp->u.iocb_cmd.u.ctarg.req_dma); |
| 3272 | sp->u.iocb_cmd.u.ctarg.req = NULL; |
| 3273 | } |
| 3274 | if (sp->u.iocb_cmd.u.ctarg.rsp) { |
| 3275 | dma_free_coherent(&vha->hw->pdev->dev, |
| 3276 | sizeof(struct ct_sns_pkt), |
| 3277 | sp->u.iocb_cmd.u.ctarg.rsp, |
| 3278 | sp->u.iocb_cmd.u.ctarg.rsp_dma); |
| 3279 | sp->u.iocb_cmd.u.ctarg.rsp = NULL; |
| 3280 | } |
| 3281 | |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 3282 | sp->free(sp); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3283 | return; |
| 3284 | } |
| 3285 | |
| 3286 | e->u.iosb.sp = sp; |
| 3287 | qla2x00_post_work(vha, e); |
| 3288 | } |
| 3289 | |
| 3290 | /* Get WWPN with Nport ID. */ |
| 3291 | int qla24xx_async_gpnid(scsi_qla_host_t *vha, port_id_t *id) |
| 3292 | { |
| 3293 | int rval = QLA_FUNCTION_FAILED; |
| 3294 | struct ct_sns_req *ct_req; |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame^] | 3295 | srb_t *sp, *tsp; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3296 | struct ct_sns_pkt *ct_sns; |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame^] | 3297 | unsigned long flags; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3298 | |
| 3299 | if (!vha->flags.online) |
| 3300 | goto done; |
| 3301 | |
| 3302 | sp = qla2x00_get_sp(vha, NULL, GFP_KERNEL); |
| 3303 | if (!sp) |
| 3304 | goto done; |
| 3305 | |
| 3306 | sp->type = SRB_CT_PTHRU_CMD; |
| 3307 | sp->name = "gpnid"; |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame^] | 3308 | sp->u.iocb_cmd.u.ctarg.id = *id; |
| 3309 | sp->gen1 = 0; |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3310 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 3311 | |
Quinn Tran | 2d73ac6 | 2017-12-04 14:45:02 -0800 | [diff] [blame^] | 3312 | spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); |
| 3313 | list_for_each_entry(tsp, &vha->gpnid_list, elem) { |
| 3314 | if (tsp->u.iocb_cmd.u.ctarg.id.b24 == id->b24) { |
| 3315 | tsp->gen1++; |
| 3316 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 3317 | sp->free(sp); |
| 3318 | goto done; |
| 3319 | } |
| 3320 | } |
| 3321 | list_add_tail(&sp->elem, &vha->gpnid_list); |
| 3322 | spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); |
| 3323 | |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3324 | sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev, |
| 3325 | sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma, |
| 3326 | GFP_KERNEL); |
| 3327 | if (!sp->u.iocb_cmd.u.ctarg.req) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3328 | ql_log(ql_log_warn, vha, 0xd041, |
| 3329 | "Failed to allocate ct_sns request.\n"); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3330 | goto done_free_sp; |
| 3331 | } |
| 3332 | |
| 3333 | sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev, |
| 3334 | sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma, |
| 3335 | GFP_KERNEL); |
| 3336 | if (!sp->u.iocb_cmd.u.ctarg.rsp) { |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3337 | ql_log(ql_log_warn, vha, 0xd042, |
| 3338 | "Failed to allocate ct_sns request.\n"); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3339 | goto done_free_sp; |
| 3340 | } |
| 3341 | |
| 3342 | ct_sns = (struct ct_sns_pkt *)sp->u.iocb_cmd.u.ctarg.rsp; |
| 3343 | memset(ct_sns, 0, sizeof(*ct_sns)); |
| 3344 | |
| 3345 | ct_sns = (struct ct_sns_pkt *)sp->u.iocb_cmd.u.ctarg.req; |
| 3346 | /* CT_IU preamble */ |
| 3347 | ct_req = qla2x00_prep_ct_req(ct_sns, GPN_ID_CMD, GPN_ID_RSP_SIZE); |
| 3348 | |
| 3349 | /* GPN_ID req */ |
| 3350 | ct_req->req.port_id.port_id[0] = id->b.domain; |
| 3351 | ct_req->req.port_id.port_id[1] = id->b.area; |
| 3352 | ct_req->req.port_id.port_id[2] = id->b.al_pa; |
| 3353 | |
| 3354 | sp->u.iocb_cmd.u.ctarg.req_size = GPN_ID_REQ_SIZE; |
| 3355 | sp->u.iocb_cmd.u.ctarg.rsp_size = GPN_ID_RSP_SIZE; |
| 3356 | sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS; |
| 3357 | |
| 3358 | sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; |
| 3359 | sp->done = qla2x00_async_gpnid_sp_done; |
| 3360 | |
| 3361 | rval = qla2x00_start_sp(sp); |
| 3362 | if (rval != QLA_SUCCESS) |
| 3363 | goto done_free_sp; |
| 3364 | |
Quinn Tran | 83548fe | 2017-06-02 09:12:01 -0700 | [diff] [blame] | 3365 | ql_dbg(ql_dbg_disc, vha, 0x2067, |
| 3366 | "Async-%s hdl=%x ID %3phC.\n", sp->name, |
| 3367 | sp->handle, ct_req->req.port_id.port_id); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3368 | return rval; |
| 3369 | |
| 3370 | done_free_sp: |
| 3371 | if (sp->u.iocb_cmd.u.ctarg.req) { |
| 3372 | dma_free_coherent(&vha->hw->pdev->dev, |
| 3373 | sizeof(struct ct_sns_pkt), |
| 3374 | sp->u.iocb_cmd.u.ctarg.req, |
| 3375 | sp->u.iocb_cmd.u.ctarg.req_dma); |
| 3376 | sp->u.iocb_cmd.u.ctarg.req = NULL; |
| 3377 | } |
| 3378 | if (sp->u.iocb_cmd.u.ctarg.rsp) { |
| 3379 | dma_free_coherent(&vha->hw->pdev->dev, |
| 3380 | sizeof(struct ct_sns_pkt), |
| 3381 | sp->u.iocb_cmd.u.ctarg.rsp, |
| 3382 | sp->u.iocb_cmd.u.ctarg.rsp_dma); |
| 3383 | sp->u.iocb_cmd.u.ctarg.rsp = NULL; |
| 3384 | } |
| 3385 | |
Joe Carnuccio | 25ff6af | 2017-01-19 22:28:04 -0800 | [diff] [blame] | 3386 | sp->free(sp); |
Quinn Tran | 726b854 | 2017-01-19 22:28:00 -0800 | [diff] [blame] | 3387 | done: |
| 3388 | return rval; |
| 3389 | } |
Duane Grigsby | d3bae93 | 2017-06-21 13:48:44 -0700 | [diff] [blame] | 3390 | |
| 3391 | void qla24xx_handle_gffid_event(scsi_qla_host_t *vha, struct event_arg *ea) |
| 3392 | { |
| 3393 | fc_port_t *fcport = ea->fcport; |
| 3394 | |
| 3395 | qla24xx_post_gnl_work(vha, fcport); |
| 3396 | } |
| 3397 | |
| 3398 | void qla24xx_async_gffid_sp_done(void *s, int res) |
| 3399 | { |
| 3400 | struct srb *sp = s; |
| 3401 | struct scsi_qla_host *vha = sp->vha; |
| 3402 | fc_port_t *fcport = sp->fcport; |
| 3403 | struct ct_sns_rsp *ct_rsp; |
| 3404 | struct event_arg ea; |
| 3405 | |
| 3406 | ql_dbg(ql_dbg_disc, vha, 0x2133, |
| 3407 | "Async done-%s res %x ID %x. %8phC\n", |
| 3408 | sp->name, res, fcport->d_id.b24, fcport->port_name); |
| 3409 | |
| 3410 | fcport->flags &= ~FCF_ASYNC_SENT; |
| 3411 | ct_rsp = &fcport->ct_desc.ct_sns->p.rsp; |
| 3412 | /* |
| 3413 | * FC-GS-7, 5.2.3.12 FC-4 Features - format |
| 3414 | * The format of the FC-4 Features object, as defined by the FC-4, |
| 3415 | * Shall be an array of 4-bit values, one for each type code value |
| 3416 | */ |
| 3417 | if (!res) { |
| 3418 | if (ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET] & 0xf) { |
| 3419 | /* w1 b00:03 */ |
| 3420 | fcport->fc4_type = |
| 3421 | ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET]; |
| 3422 | fcport->fc4_type &= 0xf; |
| 3423 | } |
| 3424 | |
| 3425 | if (ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET] & 0xf) { |
| 3426 | /* w5 [00:03]/28h */ |
| 3427 | fcport->fc4f_nvme = |
| 3428 | ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET]; |
| 3429 | fcport->fc4f_nvme &= 0xf; |
| 3430 | } |
| 3431 | } |
| 3432 | |
| 3433 | memset(&ea, 0, sizeof(ea)); |
| 3434 | ea.sp = sp; |
| 3435 | ea.fcport = sp->fcport; |
| 3436 | ea.rc = res; |
| 3437 | ea.event = FCME_GFFID_DONE; |
| 3438 | |
| 3439 | qla2x00_fcport_event_handler(vha, &ea); |
| 3440 | sp->free(sp); |
| 3441 | } |
| 3442 | |
| 3443 | /* Get FC4 Feature with Nport ID. */ |
| 3444 | int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport) |
| 3445 | { |
| 3446 | int rval = QLA_FUNCTION_FAILED; |
| 3447 | struct ct_sns_req *ct_req; |
| 3448 | srb_t *sp; |
| 3449 | |
| 3450 | if (!vha->flags.online) |
| 3451 | return rval; |
| 3452 | |
| 3453 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
| 3454 | if (!sp) |
| 3455 | return rval; |
| 3456 | |
| 3457 | fcport->flags |= FCF_ASYNC_SENT; |
| 3458 | sp->type = SRB_CT_PTHRU_CMD; |
| 3459 | sp->name = "gffid"; |
| 3460 | sp->gen1 = fcport->rscn_gen; |
| 3461 | sp->gen2 = fcport->login_gen; |
| 3462 | |
| 3463 | qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); |
| 3464 | |
| 3465 | /* CT_IU preamble */ |
| 3466 | ct_req = qla2x00_prep_ct_req(fcport->ct_desc.ct_sns, GFF_ID_CMD, |
| 3467 | GFF_ID_RSP_SIZE); |
| 3468 | |
| 3469 | ct_req->req.gff_id.port_id[0] = fcport->d_id.b.domain; |
| 3470 | ct_req->req.gff_id.port_id[1] = fcport->d_id.b.area; |
| 3471 | ct_req->req.gff_id.port_id[2] = fcport->d_id.b.al_pa; |
| 3472 | |
| 3473 | sp->u.iocb_cmd.u.ctarg.req = fcport->ct_desc.ct_sns; |
| 3474 | sp->u.iocb_cmd.u.ctarg.req_dma = fcport->ct_desc.ct_sns_dma; |
| 3475 | sp->u.iocb_cmd.u.ctarg.rsp = fcport->ct_desc.ct_sns; |
| 3476 | sp->u.iocb_cmd.u.ctarg.rsp_dma = fcport->ct_desc.ct_sns_dma; |
| 3477 | sp->u.iocb_cmd.u.ctarg.req_size = GFF_ID_REQ_SIZE; |
| 3478 | sp->u.iocb_cmd.u.ctarg.rsp_size = GFF_ID_RSP_SIZE; |
| 3479 | sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS; |
| 3480 | |
| 3481 | sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; |
| 3482 | sp->done = qla24xx_async_gffid_sp_done; |
| 3483 | |
| 3484 | rval = qla2x00_start_sp(sp); |
| 3485 | if (rval != QLA_SUCCESS) |
| 3486 | goto done_free_sp; |
| 3487 | |
| 3488 | ql_dbg(ql_dbg_disc, vha, 0x2132, |
| 3489 | "Async-%s hdl=%x %8phC.\n", sp->name, |
| 3490 | sp->handle, fcport->port_name); |
| 3491 | |
| 3492 | return rval; |
| 3493 | done_free_sp: |
| 3494 | sp->free(sp); |
| 3495 | fcport->flags &= ~FCF_ASYNC_SENT; |
| 3496 | return rval; |
| 3497 | } |