qla_gs.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  1. /*
  2. * QLOGIC LINUX SOFTWARE
  3. *
  4. * QLogic ISP2x00 device driver for Linux 2.6.x
  5. * Copyright (C) 2003-2005 QLogic Corporation
  6. * (www.qlogic.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2, or (at your option) any
  11. * later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. */
  19. #include "qla_def.h"
  20. static inline struct ct_sns_req *
  21. qla2x00_prep_ct_req(struct ct_sns_req *, uint16_t, uint16_t);
  22. static inline struct sns_cmd_pkt *
  23. qla2x00_prep_sns_cmd(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t);
  24. static int qla2x00_sns_ga_nxt(scsi_qla_host_t *, fc_port_t *);
  25. static int qla2x00_sns_gid_pt(scsi_qla_host_t *, sw_info_t *);
  26. static int qla2x00_sns_gpn_id(scsi_qla_host_t *, sw_info_t *);
  27. static int qla2x00_sns_gnn_id(scsi_qla_host_t *, sw_info_t *);
  28. static int qla2x00_sns_rft_id(scsi_qla_host_t *);
  29. static int qla2x00_sns_rnn_id(scsi_qla_host_t *);
  30. /**
  31. * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query.
  32. * @ha: HA context
  33. * @req_size: request size in bytes
  34. * @rsp_size: response size in bytes
  35. *
  36. * Returns a pointer to the @ha's ms_iocb.
  37. */
  38. void *
  39. qla2x00_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size)
  40. {
  41. ms_iocb_entry_t *ms_pkt;
  42. ms_pkt = ha->ms_iocb;
  43. memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
  44. ms_pkt->entry_type = MS_IOCB_TYPE;
  45. ms_pkt->entry_count = 1;
  46. SET_TARGET_ID(ha, ms_pkt->loop_id, SIMPLE_NAME_SERVER);
  47. ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG);
  48. ms_pkt->timeout = __constant_cpu_to_le16(25);
  49. ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
  50. ms_pkt->total_dsd_count = __constant_cpu_to_le16(2);
  51. ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size);
  52. ms_pkt->req_bytecount = cpu_to_le32(req_size);
  53. ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  54. ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  55. ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
  56. ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  57. ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  58. ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
  59. return (ms_pkt);
  60. }
  61. /**
  62. * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query.
  63. * @ha: HA context
  64. * @req_size: request size in bytes
  65. * @rsp_size: response size in bytes
  66. *
  67. * Returns a pointer to the @ha's ms_iocb.
  68. */
  69. void *
  70. qla24xx_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size)
  71. {
  72. struct ct_entry_24xx *ct_pkt;
  73. ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
  74. memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
  75. ct_pkt->entry_type = CT_IOCB_TYPE;
  76. ct_pkt->entry_count = 1;
  77. ct_pkt->nport_handle = __constant_cpu_to_le16(NPH_SNS);
  78. ct_pkt->timeout = __constant_cpu_to_le16(25);
  79. ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
  80. ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
  81. ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
  82. ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
  83. ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  84. ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  85. ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
  86. ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  87. ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  88. ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
  89. return (ct_pkt);
  90. }
  91. /**
  92. * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
  93. * @ct_req: CT request buffer
  94. * @cmd: GS command
  95. * @rsp_size: response size in bytes
  96. *
  97. * Returns a pointer to the intitialized @ct_req.
  98. */
  99. static inline struct ct_sns_req *
  100. qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size)
  101. {
  102. memset(ct_req, 0, sizeof(struct ct_sns_pkt));
  103. ct_req->header.revision = 0x01;
  104. ct_req->header.gs_type = 0xFC;
  105. ct_req->header.gs_subtype = 0x02;
  106. ct_req->command = cpu_to_be16(cmd);
  107. ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
  108. return (ct_req);
  109. }
  110. static int
  111. qla2x00_chk_ms_status(scsi_qla_host_t *ha, ms_iocb_entry_t *ms_pkt,
  112. struct ct_sns_rsp *ct_rsp, const char *routine)
  113. {
  114. int rval;
  115. uint16_t comp_status;
  116. rval = QLA_FUNCTION_FAILED;
  117. if (ms_pkt->entry_status != 0) {
  118. DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n",
  119. ha->host_no, routine, ms_pkt->entry_status));
  120. } else {
  121. if (IS_QLA24XX(ha) || IS_QLA25XX(ha))
  122. comp_status =
  123. ((struct ct_entry_24xx *)ms_pkt)->comp_status;
  124. else
  125. comp_status = le16_to_cpu(ms_pkt->status);
  126. switch (comp_status) {
  127. case CS_COMPLETE:
  128. case CS_DATA_UNDERRUN:
  129. case CS_DATA_OVERRUN: /* Overrun? */
  130. if (ct_rsp->header.response !=
  131. __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
  132. DEBUG2_3(printk("scsi(%ld): %s failed, "
  133. "rejected request:\n", ha->host_no,
  134. routine));
  135. DEBUG2_3(qla2x00_dump_buffer(
  136. (uint8_t *)&ct_rsp->header,
  137. sizeof(struct ct_rsp_hdr)));
  138. } else
  139. rval = QLA_SUCCESS;
  140. break;
  141. default:
  142. DEBUG2_3(printk("scsi(%ld): %s failed, completion "
  143. "status (%x).\n", ha->host_no, routine,
  144. comp_status));
  145. break;
  146. }
  147. }
  148. return rval;
  149. }
  150. /**
  151. * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
  152. * @ha: HA context
  153. * @fcport: fcport entry to updated
  154. *
  155. * Returns 0 on success.
  156. */
  157. int
  158. qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
  159. {
  160. int rval;
  161. ms_iocb_entry_t *ms_pkt;
  162. struct ct_sns_req *ct_req;
  163. struct ct_sns_rsp *ct_rsp;
  164. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  165. return (qla2x00_sns_ga_nxt(ha, fcport));
  166. }
  167. /* Issue GA_NXT */
  168. /* Prepare common MS IOCB */
  169. ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GA_NXT_REQ_SIZE, GA_NXT_RSP_SIZE);
  170. /* Prepare CT request */
  171. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD,
  172. GA_NXT_RSP_SIZE);
  173. ct_rsp = &ha->ct_sns->p.rsp;
  174. /* Prepare CT arguments -- port_id */
  175. ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain;
  176. ct_req->req.port_id.port_id[1] = fcport->d_id.b.area;
  177. ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa;
  178. /* Execute MS IOCB */
  179. rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
  180. sizeof(ms_iocb_entry_t));
  181. if (rval != QLA_SUCCESS) {
  182. /*EMPTY*/
  183. DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n",
  184. ha->host_no, rval));
  185. } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "GA_NXT") !=
  186. QLA_SUCCESS) {
  187. rval = QLA_FUNCTION_FAILED;
  188. } else {
  189. /* Populate fc_port_t entry. */
  190. fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0];
  191. fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1];
  192. fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2];
  193. memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name,
  194. WWN_SIZE);
  195. memcpy(fcport->port_name, ct_rsp->rsp.ga_nxt.port_name,
  196. WWN_SIZE);
  197. if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE &&
  198. ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE)
  199. fcport->d_id.b.domain = 0xf0;
  200. DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
  201. "nn %02x%02x%02x%02x%02x%02x%02x%02x "
  202. "pn %02x%02x%02x%02x%02x%02x%02x%02x "
  203. "portid=%02x%02x%02x.\n",
  204. ha->host_no,
  205. fcport->node_name[0], fcport->node_name[1],
  206. fcport->node_name[2], fcport->node_name[3],
  207. fcport->node_name[4], fcport->node_name[5],
  208. fcport->node_name[6], fcport->node_name[7],
  209. fcport->port_name[0], fcport->port_name[1],
  210. fcport->port_name[2], fcport->port_name[3],
  211. fcport->port_name[4], fcport->port_name[5],
  212. fcport->port_name[6], fcport->port_name[7],
  213. fcport->d_id.b.domain, fcport->d_id.b.area,
  214. fcport->d_id.b.al_pa));
  215. }
  216. return (rval);
  217. }
  218. /**
  219. * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command.
  220. * @ha: HA context
  221. * @list: switch info entries to populate
  222. *
  223. * NOTE: Non-Nx_Ports are not requested.
  224. *
  225. * Returns 0 on success.
  226. */
  227. int
  228. qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
  229. {
  230. int rval;
  231. uint16_t i;
  232. ms_iocb_entry_t *ms_pkt;
  233. struct ct_sns_req *ct_req;
  234. struct ct_sns_rsp *ct_rsp;
  235. struct ct_sns_gid_pt_data *gid_data;
  236. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  237. return (qla2x00_sns_gid_pt(ha, list));
  238. }
  239. gid_data = NULL;
  240. /* Issue GID_PT */
  241. /* Prepare common MS IOCB */
  242. ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GID_PT_REQ_SIZE, GID_PT_RSP_SIZE);
  243. /* Prepare CT request */
  244. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD,
  245. GID_PT_RSP_SIZE);
  246. ct_rsp = &ha->ct_sns->p.rsp;
  247. /* Prepare CT arguments -- port_type */
  248. ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE;
  249. /* Execute MS IOCB */
  250. rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
  251. sizeof(ms_iocb_entry_t));
  252. if (rval != QLA_SUCCESS) {
  253. /*EMPTY*/
  254. DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n",
  255. ha->host_no, rval));
  256. } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "GID_PT") !=
  257. QLA_SUCCESS) {
  258. rval = QLA_FUNCTION_FAILED;
  259. } else {
  260. /* Set port IDs in switch info list. */
  261. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  262. gid_data = &ct_rsp->rsp.gid_pt.entries[i];
  263. list[i].d_id.b.domain = gid_data->port_id[0];
  264. list[i].d_id.b.area = gid_data->port_id[1];
  265. list[i].d_id.b.al_pa = gid_data->port_id[2];
  266. /* Last one exit. */
  267. if (gid_data->control_byte & BIT_7) {
  268. list[i].d_id.b.rsvd_1 = gid_data->control_byte;
  269. break;
  270. }
  271. }
  272. /*
  273. * If we've used all available slots, then the switch is
  274. * reporting back more devices than we can handle with this
  275. * single call. Return a failed status, and let GA_NXT handle
  276. * the overload.
  277. */
  278. if (i == MAX_FIBRE_DEVICES)
  279. rval = QLA_FUNCTION_FAILED;
  280. }
  281. return (rval);
  282. }
  283. /**
  284. * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query.
  285. * @ha: HA context
  286. * @list: switch info entries to populate
  287. *
  288. * Returns 0 on success.
  289. */
  290. int
  291. qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
  292. {
  293. int rval;
  294. uint16_t i;
  295. ms_iocb_entry_t *ms_pkt;
  296. struct ct_sns_req *ct_req;
  297. struct ct_sns_rsp *ct_rsp;
  298. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  299. return (qla2x00_sns_gpn_id(ha, list));
  300. }
  301. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  302. /* Issue GPN_ID */
  303. /* Prepare common MS IOCB */
  304. ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GPN_ID_REQ_SIZE,
  305. GPN_ID_RSP_SIZE);
  306. /* Prepare CT request */
  307. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD,
  308. GPN_ID_RSP_SIZE);
  309. ct_rsp = &ha->ct_sns->p.rsp;
  310. /* Prepare CT arguments -- port_id */
  311. ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
  312. ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
  313. ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
  314. /* Execute MS IOCB */
  315. rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
  316. sizeof(ms_iocb_entry_t));
  317. if (rval != QLA_SUCCESS) {
  318. /*EMPTY*/
  319. DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed "
  320. "(%d).\n", ha->host_no, rval));
  321. } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp,
  322. "GPN_ID") != QLA_SUCCESS) {
  323. rval = QLA_FUNCTION_FAILED;
  324. } else {
  325. /* Save portname */
  326. memcpy(list[i].port_name,
  327. ct_rsp->rsp.gpn_id.port_name, WWN_SIZE);
  328. }
  329. /* Last device exit. */
  330. if (list[i].d_id.b.rsvd_1 != 0)
  331. break;
  332. }
  333. return (rval);
  334. }
  335. /**
  336. * qla2x00_gnn_id() - SNS Get Node Name (GNN_ID) query.
  337. * @ha: HA context
  338. * @list: switch info entries to populate
  339. *
  340. * Returns 0 on success.
  341. */
  342. int
  343. qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
  344. {
  345. int rval;
  346. uint16_t i;
  347. ms_iocb_entry_t *ms_pkt;
  348. struct ct_sns_req *ct_req;
  349. struct ct_sns_rsp *ct_rsp;
  350. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  351. return (qla2x00_sns_gnn_id(ha, list));
  352. }
  353. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  354. /* Issue GNN_ID */
  355. /* Prepare common MS IOCB */
  356. ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GNN_ID_REQ_SIZE,
  357. GNN_ID_RSP_SIZE);
  358. /* Prepare CT request */
  359. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GNN_ID_CMD,
  360. GNN_ID_RSP_SIZE);
  361. ct_rsp = &ha->ct_sns->p.rsp;
  362. /* Prepare CT arguments -- port_id */
  363. ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
  364. ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
  365. ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
  366. /* Execute MS IOCB */
  367. rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
  368. sizeof(ms_iocb_entry_t));
  369. if (rval != QLA_SUCCESS) {
  370. /*EMPTY*/
  371. DEBUG2_3(printk("scsi(%ld): GNN_ID issue IOCB failed "
  372. "(%d).\n", ha->host_no, rval));
  373. } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp,
  374. "GNN_ID") != QLA_SUCCESS) {
  375. rval = QLA_FUNCTION_FAILED;
  376. } else {
  377. /* Save nodename */
  378. memcpy(list[i].node_name,
  379. ct_rsp->rsp.gnn_id.node_name, WWN_SIZE);
  380. DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
  381. "nn %02x%02x%02x%02x%02x%02x%02x%02x "
  382. "pn %02x%02x%02x%02x%02x%02x%02x%02x "
  383. "portid=%02x%02x%02x.\n",
  384. ha->host_no,
  385. list[i].node_name[0], list[i].node_name[1],
  386. list[i].node_name[2], list[i].node_name[3],
  387. list[i].node_name[4], list[i].node_name[5],
  388. list[i].node_name[6], list[i].node_name[7],
  389. list[i].port_name[0], list[i].port_name[1],
  390. list[i].port_name[2], list[i].port_name[3],
  391. list[i].port_name[4], list[i].port_name[5],
  392. list[i].port_name[6], list[i].port_name[7],
  393. list[i].d_id.b.domain, list[i].d_id.b.area,
  394. list[i].d_id.b.al_pa));
  395. }
  396. /* Last device exit. */
  397. if (list[i].d_id.b.rsvd_1 != 0)
  398. break;
  399. }
  400. return (rval);
  401. }
  402. /**
  403. * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
  404. * @ha: HA context
  405. *
  406. * Returns 0 on success.
  407. */
  408. int
  409. qla2x00_rft_id(scsi_qla_host_t *ha)
  410. {
  411. int rval;
  412. ms_iocb_entry_t *ms_pkt;
  413. struct ct_sns_req *ct_req;
  414. struct ct_sns_rsp *ct_rsp;
  415. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  416. return (qla2x00_sns_rft_id(ha));
  417. }
  418. /* Issue RFT_ID */
  419. /* Prepare common MS IOCB */
  420. ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RFT_ID_REQ_SIZE, RFT_ID_RSP_SIZE);
  421. /* Prepare CT request */
  422. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD,
  423. RFT_ID_RSP_SIZE);
  424. ct_rsp = &ha->ct_sns->p.rsp;
  425. /* Prepare CT arguments -- port_id, FC-4 types */
  426. ct_req->req.rft_id.port_id[0] = ha->d_id.b.domain;
  427. ct_req->req.rft_id.port_id[1] = ha->d_id.b.area;
  428. ct_req->req.rft_id.port_id[2] = ha->d_id.b.al_pa;
  429. ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */
  430. /* Execute MS IOCB */
  431. rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
  432. sizeof(ms_iocb_entry_t));
  433. if (rval != QLA_SUCCESS) {
  434. /*EMPTY*/
  435. DEBUG2_3(printk("scsi(%ld): RFT_ID issue IOCB failed (%d).\n",
  436. ha->host_no, rval));
  437. } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RFT_ID") !=
  438. QLA_SUCCESS) {
  439. rval = QLA_FUNCTION_FAILED;
  440. } else {
  441. DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
  442. ha->host_no));
  443. }
  444. return (rval);
  445. }
  446. /**
  447. * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA.
  448. * @ha: HA context
  449. *
  450. * Returns 0 on success.
  451. */
  452. int
  453. qla2x00_rff_id(scsi_qla_host_t *ha)
  454. {
  455. int rval;
  456. ms_iocb_entry_t *ms_pkt;
  457. struct ct_sns_req *ct_req;
  458. struct ct_sns_rsp *ct_rsp;
  459. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  460. DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on "
  461. "ISP2100/ISP2200.\n", ha->host_no));
  462. return (QLA_SUCCESS);
  463. }
  464. /* Issue RFF_ID */
  465. /* Prepare common MS IOCB */
  466. ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE);
  467. /* Prepare CT request */
  468. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD,
  469. RFF_ID_RSP_SIZE);
  470. ct_rsp = &ha->ct_sns->p.rsp;
  471. /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
  472. ct_req->req.rff_id.port_id[0] = ha->d_id.b.domain;
  473. ct_req->req.rff_id.port_id[1] = ha->d_id.b.area;
  474. ct_req->req.rff_id.port_id[2] = ha->d_id.b.al_pa;
  475. ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */
  476. /* Execute MS IOCB */
  477. rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
  478. sizeof(ms_iocb_entry_t));
  479. if (rval != QLA_SUCCESS) {
  480. /*EMPTY*/
  481. DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n",
  482. ha->host_no, rval));
  483. } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RFF_ID") !=
  484. QLA_SUCCESS) {
  485. rval = QLA_FUNCTION_FAILED;
  486. } else {
  487. DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n",
  488. ha->host_no));
  489. }
  490. return (rval);
  491. }
  492. /**
  493. * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
  494. * @ha: HA context
  495. *
  496. * Returns 0 on success.
  497. */
  498. int
  499. qla2x00_rnn_id(scsi_qla_host_t *ha)
  500. {
  501. int rval;
  502. ms_iocb_entry_t *ms_pkt;
  503. struct ct_sns_req *ct_req;
  504. struct ct_sns_rsp *ct_rsp;
  505. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  506. return (qla2x00_sns_rnn_id(ha));
  507. }
  508. /* Issue RNN_ID */
  509. /* Prepare common MS IOCB */
  510. ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RNN_ID_REQ_SIZE, RNN_ID_RSP_SIZE);
  511. /* Prepare CT request */
  512. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD,
  513. RNN_ID_RSP_SIZE);
  514. ct_rsp = &ha->ct_sns->p.rsp;
  515. /* Prepare CT arguments -- port_id, node_name */
  516. ct_req->req.rnn_id.port_id[0] = ha->d_id.b.domain;
  517. ct_req->req.rnn_id.port_id[1] = ha->d_id.b.area;
  518. ct_req->req.rnn_id.port_id[2] = ha->d_id.b.al_pa;
  519. memcpy(ct_req->req.rnn_id.node_name, ha->node_name, WWN_SIZE);
  520. /* Execute MS IOCB */
  521. rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
  522. sizeof(ms_iocb_entry_t));
  523. if (rval != QLA_SUCCESS) {
  524. /*EMPTY*/
  525. DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n",
  526. ha->host_no, rval));
  527. } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RNN_ID") !=
  528. QLA_SUCCESS) {
  529. rval = QLA_FUNCTION_FAILED;
  530. } else {
  531. DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
  532. ha->host_no));
  533. }
  534. return (rval);
  535. }
  536. /**
  537. * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA.
  538. * @ha: HA context
  539. *
  540. * Returns 0 on success.
  541. */
  542. int
  543. qla2x00_rsnn_nn(scsi_qla_host_t *ha)
  544. {
  545. int rval;
  546. uint8_t *snn;
  547. uint8_t version[20];
  548. ms_iocb_entry_t *ms_pkt;
  549. struct ct_sns_req *ct_req;
  550. struct ct_sns_rsp *ct_rsp;
  551. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  552. DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on "
  553. "ISP2100/ISP2200.\n", ha->host_no));
  554. return (QLA_SUCCESS);
  555. }
  556. /* Issue RSNN_NN */
  557. /* Prepare common MS IOCB */
  558. /* Request size adjusted after CT preparation */
  559. ms_pkt = ha->isp_ops.prep_ms_iocb(ha, 0, RSNN_NN_RSP_SIZE);
  560. /* Prepare CT request */
  561. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD,
  562. RSNN_NN_RSP_SIZE);
  563. ct_rsp = &ha->ct_sns->p.rsp;
  564. /* Prepare CT arguments -- node_name, symbolic node_name, size */
  565. memcpy(ct_req->req.rsnn_nn.node_name, ha->node_name, WWN_SIZE);
  566. /* Prepare the Symbolic Node Name */
  567. /* Board type */
  568. snn = ct_req->req.rsnn_nn.sym_node_name;
  569. strcpy(snn, ha->model_number);
  570. /* Firmware version */
  571. strcat(snn, " FW:v");
  572. sprintf(version, "%d.%02d.%02d", ha->fw_major_version,
  573. ha->fw_minor_version, ha->fw_subminor_version);
  574. strcat(snn, version);
  575. /* Driver version */
  576. strcat(snn, " DVR:v");
  577. strcat(snn, qla2x00_version_str);
  578. /* Calculate SNN length */
  579. ct_req->req.rsnn_nn.name_len = (uint8_t)strlen(snn);
  580. /* Update MS IOCB request */
  581. ms_pkt->req_bytecount =
  582. cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len);
  583. ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
  584. /* Execute MS IOCB */
  585. rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
  586. sizeof(ms_iocb_entry_t));
  587. if (rval != QLA_SUCCESS) {
  588. /*EMPTY*/
  589. DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n",
  590. ha->host_no, rval));
  591. } else if (qla2x00_chk_ms_status(ha, ms_pkt, ct_rsp, "RSNN_NN") !=
  592. QLA_SUCCESS) {
  593. rval = QLA_FUNCTION_FAILED;
  594. } else {
  595. DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n",
  596. ha->host_no));
  597. }
  598. return (rval);
  599. }
  600. /**
  601. * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query.
  602. * @ha: HA context
  603. * @cmd: GS command
  604. * @scmd_len: Subcommand length
  605. * @data_size: response size in bytes
  606. *
  607. * Returns a pointer to the @ha's sns_cmd.
  608. */
  609. static inline struct sns_cmd_pkt *
  610. qla2x00_prep_sns_cmd(scsi_qla_host_t *ha, uint16_t cmd, uint16_t scmd_len,
  611. uint16_t data_size)
  612. {
  613. uint16_t wc;
  614. struct sns_cmd_pkt *sns_cmd;
  615. sns_cmd = ha->sns_cmd;
  616. memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt));
  617. wc = data_size / 2; /* Size in 16bit words. */
  618. sns_cmd->p.cmd.buffer_length = cpu_to_le16(wc);
  619. sns_cmd->p.cmd.buffer_address[0] = cpu_to_le32(LSD(ha->sns_cmd_dma));
  620. sns_cmd->p.cmd.buffer_address[1] = cpu_to_le32(MSD(ha->sns_cmd_dma));
  621. sns_cmd->p.cmd.subcommand_length = cpu_to_le16(scmd_len);
  622. sns_cmd->p.cmd.subcommand = cpu_to_le16(cmd);
  623. wc = (data_size - 16) / 4; /* Size in 32bit words. */
  624. sns_cmd->p.cmd.size = cpu_to_le16(wc);
  625. return (sns_cmd);
  626. }
  627. /**
  628. * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
  629. * @ha: HA context
  630. * @fcport: fcport entry to updated
  631. *
  632. * This command uses the old Exectute SNS Command mailbox routine.
  633. *
  634. * Returns 0 on success.
  635. */
  636. static int
  637. qla2x00_sns_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
  638. {
  639. int rval;
  640. struct sns_cmd_pkt *sns_cmd;
  641. /* Issue GA_NXT. */
  642. /* Prepare SNS command request. */
  643. sns_cmd = qla2x00_prep_sns_cmd(ha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN,
  644. GA_NXT_SNS_DATA_SIZE);
  645. /* Prepare SNS command arguments -- port_id. */
  646. sns_cmd->p.cmd.param[0] = fcport->d_id.b.al_pa;
  647. sns_cmd->p.cmd.param[1] = fcport->d_id.b.area;
  648. sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain;
  649. /* Execute SNS command. */
  650. rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2,
  651. sizeof(struct sns_cmd_pkt));
  652. if (rval != QLA_SUCCESS) {
  653. /*EMPTY*/
  654. DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n",
  655. ha->host_no, rval));
  656. } else if (sns_cmd->p.gan_data[8] != 0x80 ||
  657. sns_cmd->p.gan_data[9] != 0x02) {
  658. DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, "
  659. "ga_nxt_rsp:\n", ha->host_no));
  660. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gan_data, 16));
  661. rval = QLA_FUNCTION_FAILED;
  662. } else {
  663. /* Populate fc_port_t entry. */
  664. fcport->d_id.b.domain = sns_cmd->p.gan_data[17];
  665. fcport->d_id.b.area = sns_cmd->p.gan_data[18];
  666. fcport->d_id.b.al_pa = sns_cmd->p.gan_data[19];
  667. memcpy(fcport->node_name, &sns_cmd->p.gan_data[284], WWN_SIZE);
  668. memcpy(fcport->port_name, &sns_cmd->p.gan_data[20], WWN_SIZE);
  669. if (sns_cmd->p.gan_data[16] != NS_N_PORT_TYPE &&
  670. sns_cmd->p.gan_data[16] != NS_NL_PORT_TYPE)
  671. fcport->d_id.b.domain = 0xf0;
  672. DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
  673. "nn %02x%02x%02x%02x%02x%02x%02x%02x "
  674. "pn %02x%02x%02x%02x%02x%02x%02x%02x "
  675. "portid=%02x%02x%02x.\n",
  676. ha->host_no,
  677. fcport->node_name[0], fcport->node_name[1],
  678. fcport->node_name[2], fcport->node_name[3],
  679. fcport->node_name[4], fcport->node_name[5],
  680. fcport->node_name[6], fcport->node_name[7],
  681. fcport->port_name[0], fcport->port_name[1],
  682. fcport->port_name[2], fcport->port_name[3],
  683. fcport->port_name[4], fcport->port_name[5],
  684. fcport->port_name[6], fcport->port_name[7],
  685. fcport->d_id.b.domain, fcport->d_id.b.area,
  686. fcport->d_id.b.al_pa));
  687. }
  688. return (rval);
  689. }
  690. /**
  691. * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command.
  692. * @ha: HA context
  693. * @list: switch info entries to populate
  694. *
  695. * This command uses the old Exectute SNS Command mailbox routine.
  696. *
  697. * NOTE: Non-Nx_Ports are not requested.
  698. *
  699. * Returns 0 on success.
  700. */
  701. static int
  702. qla2x00_sns_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
  703. {
  704. int rval;
  705. uint16_t i;
  706. uint8_t *entry;
  707. struct sns_cmd_pkt *sns_cmd;
  708. /* Issue GID_PT. */
  709. /* Prepare SNS command request. */
  710. sns_cmd = qla2x00_prep_sns_cmd(ha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN,
  711. GID_PT_SNS_DATA_SIZE);
  712. /* Prepare SNS command arguments -- port_type. */
  713. sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE;
  714. /* Execute SNS command. */
  715. rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2,
  716. sizeof(struct sns_cmd_pkt));
  717. if (rval != QLA_SUCCESS) {
  718. /*EMPTY*/
  719. DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n",
  720. ha->host_no, rval));
  721. } else if (sns_cmd->p.gid_data[8] != 0x80 ||
  722. sns_cmd->p.gid_data[9] != 0x02) {
  723. DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, "
  724. "gid_rsp:\n", ha->host_no));
  725. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gid_data, 16));
  726. rval = QLA_FUNCTION_FAILED;
  727. } else {
  728. /* Set port IDs in switch info list. */
  729. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  730. entry = &sns_cmd->p.gid_data[(i * 4) + 16];
  731. list[i].d_id.b.domain = entry[1];
  732. list[i].d_id.b.area = entry[2];
  733. list[i].d_id.b.al_pa = entry[3];
  734. /* Last one exit. */
  735. if (entry[0] & BIT_7) {
  736. list[i].d_id.b.rsvd_1 = entry[0];
  737. break;
  738. }
  739. }
  740. /*
  741. * If we've used all available slots, then the switch is
  742. * reporting back more devices that we can handle with this
  743. * single call. Return a failed status, and let GA_NXT handle
  744. * the overload.
  745. */
  746. if (i == MAX_FIBRE_DEVICES)
  747. rval = QLA_FUNCTION_FAILED;
  748. }
  749. return (rval);
  750. }
  751. /**
  752. * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query.
  753. * @ha: HA context
  754. * @list: switch info entries to populate
  755. *
  756. * This command uses the old Exectute SNS Command mailbox routine.
  757. *
  758. * Returns 0 on success.
  759. */
  760. static int
  761. qla2x00_sns_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
  762. {
  763. int rval;
  764. uint16_t i;
  765. struct sns_cmd_pkt *sns_cmd;
  766. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  767. /* Issue GPN_ID */
  768. /* Prepare SNS command request. */
  769. sns_cmd = qla2x00_prep_sns_cmd(ha, GPN_ID_CMD,
  770. GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE);
  771. /* Prepare SNS command arguments -- port_id. */
  772. sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
  773. sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
  774. sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
  775. /* Execute SNS command. */
  776. rval = qla2x00_send_sns(ha, ha->sns_cmd_dma,
  777. GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
  778. if (rval != QLA_SUCCESS) {
  779. /*EMPTY*/
  780. DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed "
  781. "(%d).\n", ha->host_no, rval));
  782. } else if (sns_cmd->p.gpn_data[8] != 0x80 ||
  783. sns_cmd->p.gpn_data[9] != 0x02) {
  784. DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected "
  785. "request, gpn_rsp:\n", ha->host_no));
  786. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gpn_data, 16));
  787. rval = QLA_FUNCTION_FAILED;
  788. } else {
  789. /* Save portname */
  790. memcpy(list[i].port_name, &sns_cmd->p.gpn_data[16],
  791. WWN_SIZE);
  792. }
  793. /* Last device exit. */
  794. if (list[i].d_id.b.rsvd_1 != 0)
  795. break;
  796. }
  797. return (rval);
  798. }
  799. /**
  800. * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query.
  801. * @ha: HA context
  802. * @list: switch info entries to populate
  803. *
  804. * This command uses the old Exectute SNS Command mailbox routine.
  805. *
  806. * Returns 0 on success.
  807. */
  808. static int
  809. qla2x00_sns_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
  810. {
  811. int rval;
  812. uint16_t i;
  813. struct sns_cmd_pkt *sns_cmd;
  814. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  815. /* Issue GNN_ID */
  816. /* Prepare SNS command request. */
  817. sns_cmd = qla2x00_prep_sns_cmd(ha, GNN_ID_CMD,
  818. GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE);
  819. /* Prepare SNS command arguments -- port_id. */
  820. sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
  821. sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
  822. sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
  823. /* Execute SNS command. */
  824. rval = qla2x00_send_sns(ha, ha->sns_cmd_dma,
  825. GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
  826. if (rval != QLA_SUCCESS) {
  827. /*EMPTY*/
  828. DEBUG2_3(printk("scsi(%ld): GNN_ID Send SNS failed "
  829. "(%d).\n", ha->host_no, rval));
  830. } else if (sns_cmd->p.gnn_data[8] != 0x80 ||
  831. sns_cmd->p.gnn_data[9] != 0x02) {
  832. DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected "
  833. "request, gnn_rsp:\n", ha->host_no));
  834. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gnn_data, 16));
  835. rval = QLA_FUNCTION_FAILED;
  836. } else {
  837. /* Save nodename */
  838. memcpy(list[i].node_name, &sns_cmd->p.gnn_data[16],
  839. WWN_SIZE);
  840. DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
  841. "nn %02x%02x%02x%02x%02x%02x%02x%02x "
  842. "pn %02x%02x%02x%02x%02x%02x%02x%02x "
  843. "portid=%02x%02x%02x.\n",
  844. ha->host_no,
  845. list[i].node_name[0], list[i].node_name[1],
  846. list[i].node_name[2], list[i].node_name[3],
  847. list[i].node_name[4], list[i].node_name[5],
  848. list[i].node_name[6], list[i].node_name[7],
  849. list[i].port_name[0], list[i].port_name[1],
  850. list[i].port_name[2], list[i].port_name[3],
  851. list[i].port_name[4], list[i].port_name[5],
  852. list[i].port_name[6], list[i].port_name[7],
  853. list[i].d_id.b.domain, list[i].d_id.b.area,
  854. list[i].d_id.b.al_pa));
  855. }
  856. /* Last device exit. */
  857. if (list[i].d_id.b.rsvd_1 != 0)
  858. break;
  859. }
  860. return (rval);
  861. }
  862. /**
  863. * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
  864. * @ha: HA context
  865. *
  866. * This command uses the old Exectute SNS Command mailbox routine.
  867. *
  868. * Returns 0 on success.
  869. */
  870. static int
  871. qla2x00_sns_rft_id(scsi_qla_host_t *ha)
  872. {
  873. int rval;
  874. struct sns_cmd_pkt *sns_cmd;
  875. /* Issue RFT_ID. */
  876. /* Prepare SNS command request. */
  877. sns_cmd = qla2x00_prep_sns_cmd(ha, RFT_ID_CMD, RFT_ID_SNS_SCMD_LEN,
  878. RFT_ID_SNS_DATA_SIZE);
  879. /* Prepare SNS command arguments -- port_id, FC-4 types */
  880. sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa;
  881. sns_cmd->p.cmd.param[1] = ha->d_id.b.area;
  882. sns_cmd->p.cmd.param[2] = ha->d_id.b.domain;
  883. sns_cmd->p.cmd.param[5] = 0x01; /* FCP-3 */
  884. /* Execute SNS command. */
  885. rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RFT_ID_SNS_CMD_SIZE / 2,
  886. sizeof(struct sns_cmd_pkt));
  887. if (rval != QLA_SUCCESS) {
  888. /*EMPTY*/
  889. DEBUG2_3(printk("scsi(%ld): RFT_ID Send SNS failed (%d).\n",
  890. ha->host_no, rval));
  891. } else if (sns_cmd->p.rft_data[8] != 0x80 ||
  892. sns_cmd->p.rft_data[9] != 0x02) {
  893. DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected request, "
  894. "rft_rsp:\n", ha->host_no));
  895. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rft_data, 16));
  896. rval = QLA_FUNCTION_FAILED;
  897. } else {
  898. DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
  899. ha->host_no));
  900. }
  901. return (rval);
  902. }
  903. /**
  904. * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
  905. * HBA.
  906. * @ha: HA context
  907. *
  908. * This command uses the old Exectute SNS Command mailbox routine.
  909. *
  910. * Returns 0 on success.
  911. */
  912. static int
  913. qla2x00_sns_rnn_id(scsi_qla_host_t *ha)
  914. {
  915. int rval;
  916. struct sns_cmd_pkt *sns_cmd;
  917. /* Issue RNN_ID. */
  918. /* Prepare SNS command request. */
  919. sns_cmd = qla2x00_prep_sns_cmd(ha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN,
  920. RNN_ID_SNS_DATA_SIZE);
  921. /* Prepare SNS command arguments -- port_id, nodename. */
  922. sns_cmd->p.cmd.param[0] = ha->d_id.b.al_pa;
  923. sns_cmd->p.cmd.param[1] = ha->d_id.b.area;
  924. sns_cmd->p.cmd.param[2] = ha->d_id.b.domain;
  925. sns_cmd->p.cmd.param[4] = ha->node_name[7];
  926. sns_cmd->p.cmd.param[5] = ha->node_name[6];
  927. sns_cmd->p.cmd.param[6] = ha->node_name[5];
  928. sns_cmd->p.cmd.param[7] = ha->node_name[4];
  929. sns_cmd->p.cmd.param[8] = ha->node_name[3];
  930. sns_cmd->p.cmd.param[9] = ha->node_name[2];
  931. sns_cmd->p.cmd.param[10] = ha->node_name[1];
  932. sns_cmd->p.cmd.param[11] = ha->node_name[0];
  933. /* Execute SNS command. */
  934. rval = qla2x00_send_sns(ha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2,
  935. sizeof(struct sns_cmd_pkt));
  936. if (rval != QLA_SUCCESS) {
  937. /*EMPTY*/
  938. DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n",
  939. ha->host_no, rval));
  940. } else if (sns_cmd->p.rnn_data[8] != 0x80 ||
  941. sns_cmd->p.rnn_data[9] != 0x02) {
  942. DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, "
  943. "rnn_rsp:\n", ha->host_no));
  944. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rnn_data, 16));
  945. rval = QLA_FUNCTION_FAILED;
  946. } else {
  947. DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
  948. ha->host_no));
  949. }
  950. return (rval);
  951. }