qla_gs.c 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995
  1. /*
  2. * QLogic Fibre Channel HBA Driver
  3. * Copyright (c) 2003-2011 QLogic Corporation
  4. *
  5. * See LICENSE.qla2xxx for copyright and licensing details.
  6. */
  7. #include "qla_def.h"
  8. static int qla2x00_sns_ga_nxt(scsi_qla_host_t *, fc_port_t *);
  9. static int qla2x00_sns_gid_pt(scsi_qla_host_t *, sw_info_t *);
  10. static int qla2x00_sns_gpn_id(scsi_qla_host_t *, sw_info_t *);
  11. static int qla2x00_sns_gnn_id(scsi_qla_host_t *, sw_info_t *);
  12. static int qla2x00_sns_rft_id(scsi_qla_host_t *);
  13. static int qla2x00_sns_rnn_id(scsi_qla_host_t *);
  14. /**
  15. * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query.
  16. * @ha: HA context
  17. * @req_size: request size in bytes
  18. * @rsp_size: response size in bytes
  19. *
  20. * Returns a pointer to the @ha's ms_iocb.
  21. */
  22. void *
  23. qla2x00_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
  24. {
  25. struct qla_hw_data *ha = vha->hw;
  26. ms_iocb_entry_t *ms_pkt;
  27. ms_pkt = ha->ms_iocb;
  28. memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
  29. ms_pkt->entry_type = MS_IOCB_TYPE;
  30. ms_pkt->entry_count = 1;
  31. SET_TARGET_ID(ha, ms_pkt->loop_id, SIMPLE_NAME_SERVER);
  32. ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG);
  33. ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
  34. ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
  35. ms_pkt->total_dsd_count = __constant_cpu_to_le16(2);
  36. ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size);
  37. ms_pkt->req_bytecount = cpu_to_le32(req_size);
  38. ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  39. ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  40. ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
  41. ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  42. ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  43. ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
  44. return (ms_pkt);
  45. }
  46. /**
  47. * qla24xx_prep_ms_iocb() - Prepare common CT IOCB fields for SNS CT query.
  48. * @ha: HA context
  49. * @req_size: request size in bytes
  50. * @rsp_size: response size in bytes
  51. *
  52. * Returns a pointer to the @ha's ms_iocb.
  53. */
  54. void *
  55. qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size)
  56. {
  57. struct qla_hw_data *ha = vha->hw;
  58. struct ct_entry_24xx *ct_pkt;
  59. ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
  60. memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
  61. ct_pkt->entry_type = CT_IOCB_TYPE;
  62. ct_pkt->entry_count = 1;
  63. ct_pkt->nport_handle = __constant_cpu_to_le16(NPH_SNS);
  64. ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
  65. ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
  66. ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
  67. ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
  68. ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
  69. ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  70. ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  71. ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
  72. ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  73. ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  74. ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
  75. ct_pkt->vp_index = vha->vp_idx;
  76. return (ct_pkt);
  77. }
  78. /**
  79. * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
  80. * @ct_req: CT request buffer
  81. * @cmd: GS command
  82. * @rsp_size: response size in bytes
  83. *
  84. * Returns a pointer to the intitialized @ct_req.
  85. */
  86. static inline struct ct_sns_req *
  87. qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size)
  88. {
  89. memset(ct_req, 0, sizeof(struct ct_sns_pkt));
  90. ct_req->header.revision = 0x01;
  91. ct_req->header.gs_type = 0xFC;
  92. ct_req->header.gs_subtype = 0x02;
  93. ct_req->command = cpu_to_be16(cmd);
  94. ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
  95. return (ct_req);
  96. }
  97. static int
  98. qla2x00_chk_ms_status(scsi_qla_host_t *vha, ms_iocb_entry_t *ms_pkt,
  99. struct ct_sns_rsp *ct_rsp, const char *routine)
  100. {
  101. int rval;
  102. uint16_t comp_status;
  103. struct qla_hw_data *ha = vha->hw;
  104. rval = QLA_FUNCTION_FAILED;
  105. if (ms_pkt->entry_status != 0) {
  106. DEBUG2_3(printk(KERN_WARNING "scsi(%ld): %s failed, error status "
  107. "(%x) on port_id: %02x%02x%02x.\n",
  108. vha->host_no, routine, ms_pkt->entry_status,
  109. vha->d_id.b.domain, vha->d_id.b.area,
  110. vha->d_id.b.al_pa));
  111. } else {
  112. if (IS_FWI2_CAPABLE(ha))
  113. comp_status = le16_to_cpu(
  114. ((struct ct_entry_24xx *)ms_pkt)->comp_status);
  115. else
  116. comp_status = le16_to_cpu(ms_pkt->status);
  117. switch (comp_status) {
  118. case CS_COMPLETE:
  119. case CS_DATA_UNDERRUN:
  120. case CS_DATA_OVERRUN: /* Overrun? */
  121. if (ct_rsp->header.response !=
  122. __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
  123. DEBUG2_3(printk("scsi(%ld): %s failed, "
  124. "rejected request on port_id: %02x%02x%02x\n",
  125. vha->host_no, routine,
  126. vha->d_id.b.domain, vha->d_id.b.area,
  127. vha->d_id.b.al_pa));
  128. DEBUG2_3(qla2x00_dump_buffer(
  129. (uint8_t *)&ct_rsp->header,
  130. sizeof(struct ct_rsp_hdr)));
  131. rval = QLA_INVALID_COMMAND;
  132. } else
  133. rval = QLA_SUCCESS;
  134. break;
  135. default:
  136. DEBUG2_3(printk("scsi(%ld): %s failed, completion "
  137. "status (%x) on port_id: %02x%02x%02x.\n",
  138. vha->host_no, routine, comp_status,
  139. vha->d_id.b.domain, vha->d_id.b.area,
  140. vha->d_id.b.al_pa));
  141. break;
  142. }
  143. }
  144. return rval;
  145. }
  146. /**
  147. * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
  148. * @ha: HA context
  149. * @fcport: fcport entry to updated
  150. *
  151. * Returns 0 on success.
  152. */
  153. int
  154. qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
  155. {
  156. int rval;
  157. ms_iocb_entry_t *ms_pkt;
  158. struct ct_sns_req *ct_req;
  159. struct ct_sns_rsp *ct_rsp;
  160. struct qla_hw_data *ha = vha->hw;
  161. if (IS_QLA2100(ha) || IS_QLA2200(ha))
  162. return qla2x00_sns_ga_nxt(vha, fcport);
  163. /* Issue GA_NXT */
  164. /* Prepare common MS IOCB */
  165. ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GA_NXT_REQ_SIZE,
  166. GA_NXT_RSP_SIZE);
  167. /* Prepare CT request */
  168. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD,
  169. GA_NXT_RSP_SIZE);
  170. ct_rsp = &ha->ct_sns->p.rsp;
  171. /* Prepare CT arguments -- port_id */
  172. ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain;
  173. ct_req->req.port_id.port_id[1] = fcport->d_id.b.area;
  174. ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa;
  175. /* Execute MS IOCB */
  176. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  177. sizeof(ms_iocb_entry_t));
  178. if (rval != QLA_SUCCESS) {
  179. /*EMPTY*/
  180. DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n",
  181. vha->host_no, rval));
  182. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "GA_NXT") !=
  183. QLA_SUCCESS) {
  184. rval = QLA_FUNCTION_FAILED;
  185. } else {
  186. /* Populate fc_port_t entry. */
  187. fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0];
  188. fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1];
  189. fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2];
  190. memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name,
  191. WWN_SIZE);
  192. memcpy(fcport->port_name, ct_rsp->rsp.ga_nxt.port_name,
  193. WWN_SIZE);
  194. if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE &&
  195. ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE)
  196. fcport->d_id.b.domain = 0xf0;
  197. DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
  198. "nn %02x%02x%02x%02x%02x%02x%02x%02x "
  199. "pn %02x%02x%02x%02x%02x%02x%02x%02x "
  200. "portid=%02x%02x%02x.\n",
  201. vha->host_no,
  202. fcport->node_name[0], fcport->node_name[1],
  203. fcport->node_name[2], fcport->node_name[3],
  204. fcport->node_name[4], fcport->node_name[5],
  205. fcport->node_name[6], fcport->node_name[7],
  206. fcport->port_name[0], fcport->port_name[1],
  207. fcport->port_name[2], fcport->port_name[3],
  208. fcport->port_name[4], fcport->port_name[5],
  209. fcport->port_name[6], fcport->port_name[7],
  210. fcport->d_id.b.domain, fcport->d_id.b.area,
  211. fcport->d_id.b.al_pa));
  212. }
  213. return (rval);
  214. }
  215. /**
  216. * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command.
  217. * @ha: HA context
  218. * @list: switch info entries to populate
  219. *
  220. * NOTE: Non-Nx_Ports are not requested.
  221. *
  222. * Returns 0 on success.
  223. */
  224. int
  225. qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list)
  226. {
  227. int rval;
  228. uint16_t i;
  229. ms_iocb_entry_t *ms_pkt;
  230. struct ct_sns_req *ct_req;
  231. struct ct_sns_rsp *ct_rsp;
  232. struct ct_sns_gid_pt_data *gid_data;
  233. struct qla_hw_data *ha = vha->hw;
  234. if (IS_QLA2100(ha) || IS_QLA2200(ha))
  235. return qla2x00_sns_gid_pt(vha, list);
  236. gid_data = NULL;
  237. /* Issue GID_PT */
  238. /* Prepare common MS IOCB */
  239. ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GID_PT_REQ_SIZE,
  240. GID_PT_RSP_SIZE);
  241. /* Prepare CT request */
  242. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD,
  243. GID_PT_RSP_SIZE);
  244. ct_rsp = &ha->ct_sns->p.rsp;
  245. /* Prepare CT arguments -- port_type */
  246. ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE;
  247. /* Execute MS IOCB */
  248. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  249. sizeof(ms_iocb_entry_t));
  250. if (rval != QLA_SUCCESS) {
  251. /*EMPTY*/
  252. DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n",
  253. vha->host_no, rval));
  254. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "GID_PT") !=
  255. QLA_SUCCESS) {
  256. rval = QLA_FUNCTION_FAILED;
  257. } else {
  258. /* Set port IDs in switch info list. */
  259. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  260. gid_data = &ct_rsp->rsp.gid_pt.entries[i];
  261. list[i].d_id.b.domain = gid_data->port_id[0];
  262. list[i].d_id.b.area = gid_data->port_id[1];
  263. list[i].d_id.b.al_pa = gid_data->port_id[2];
  264. memset(list[i].fabric_port_name, 0, WWN_SIZE);
  265. list[i].fp_speed = PORT_SPEED_UNKNOWN;
  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 *vha, 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. struct qla_hw_data *ha = vha->hw;
  299. if (IS_QLA2100(ha) || IS_QLA2200(ha))
  300. return qla2x00_sns_gpn_id(vha, list);
  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(vha, 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(vha, 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", vha->host_no, rval));
  321. } else if (qla2x00_chk_ms_status(vha, 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 *vha, sw_info_t *list)
  344. {
  345. int rval;
  346. uint16_t i;
  347. struct qla_hw_data *ha = vha->hw;
  348. ms_iocb_entry_t *ms_pkt;
  349. struct ct_sns_req *ct_req;
  350. struct ct_sns_rsp *ct_rsp;
  351. if (IS_QLA2100(ha) || IS_QLA2200(ha))
  352. return qla2x00_sns_gnn_id(vha, list);
  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(vha, 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(vha, 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", vha->host_no, rval));
  373. } else if (qla2x00_chk_ms_status(vha, 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. vha->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 *vha)
  410. {
  411. int rval;
  412. struct qla_hw_data *ha = vha->hw;
  413. ms_iocb_entry_t *ms_pkt;
  414. struct ct_sns_req *ct_req;
  415. struct ct_sns_rsp *ct_rsp;
  416. if (IS_QLA2100(ha) || IS_QLA2200(ha))
  417. return qla2x00_sns_rft_id(vha);
  418. /* Issue RFT_ID */
  419. /* Prepare common MS IOCB */
  420. ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RFT_ID_REQ_SIZE,
  421. RFT_ID_RSP_SIZE);
  422. /* Prepare CT request */
  423. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD,
  424. RFT_ID_RSP_SIZE);
  425. ct_rsp = &ha->ct_sns->p.rsp;
  426. /* Prepare CT arguments -- port_id, FC-4 types */
  427. ct_req->req.rft_id.port_id[0] = vha->d_id.b.domain;
  428. ct_req->req.rft_id.port_id[1] = vha->d_id.b.area;
  429. ct_req->req.rft_id.port_id[2] = vha->d_id.b.al_pa;
  430. ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */
  431. /* Execute MS IOCB */
  432. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  433. sizeof(ms_iocb_entry_t));
  434. if (rval != QLA_SUCCESS) {
  435. /*EMPTY*/
  436. DEBUG2_3(printk("scsi(%ld): RFT_ID issue IOCB failed (%d).\n",
  437. vha->host_no, rval));
  438. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RFT_ID") !=
  439. QLA_SUCCESS) {
  440. rval = QLA_FUNCTION_FAILED;
  441. } else {
  442. DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
  443. vha->host_no));
  444. }
  445. return (rval);
  446. }
  447. /**
  448. * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA.
  449. * @ha: HA context
  450. *
  451. * Returns 0 on success.
  452. */
  453. int
  454. qla2x00_rff_id(scsi_qla_host_t *vha)
  455. {
  456. int rval;
  457. struct qla_hw_data *ha = vha->hw;
  458. ms_iocb_entry_t *ms_pkt;
  459. struct ct_sns_req *ct_req;
  460. struct ct_sns_rsp *ct_rsp;
  461. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  462. DEBUG2(printk("scsi(%ld): RFF_ID call unsupported on "
  463. "ISP2100/ISP2200.\n", vha->host_no));
  464. return (QLA_SUCCESS);
  465. }
  466. /* Issue RFF_ID */
  467. /* Prepare common MS IOCB */
  468. ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RFF_ID_REQ_SIZE,
  469. RFF_ID_RSP_SIZE);
  470. /* Prepare CT request */
  471. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD,
  472. RFF_ID_RSP_SIZE);
  473. ct_rsp = &ha->ct_sns->p.rsp;
  474. /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
  475. ct_req->req.rff_id.port_id[0] = vha->d_id.b.domain;
  476. ct_req->req.rff_id.port_id[1] = vha->d_id.b.area;
  477. ct_req->req.rff_id.port_id[2] = vha->d_id.b.al_pa;
  478. ct_req->req.rff_id.fc4_feature = BIT_1;
  479. ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */
  480. /* Execute MS IOCB */
  481. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  482. sizeof(ms_iocb_entry_t));
  483. if (rval != QLA_SUCCESS) {
  484. /*EMPTY*/
  485. DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n",
  486. vha->host_no, rval));
  487. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RFF_ID") !=
  488. QLA_SUCCESS) {
  489. rval = QLA_FUNCTION_FAILED;
  490. } else {
  491. DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n",
  492. vha->host_no));
  493. }
  494. return (rval);
  495. }
  496. /**
  497. * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
  498. * @ha: HA context
  499. *
  500. * Returns 0 on success.
  501. */
  502. int
  503. qla2x00_rnn_id(scsi_qla_host_t *vha)
  504. {
  505. int rval;
  506. struct qla_hw_data *ha = vha->hw;
  507. ms_iocb_entry_t *ms_pkt;
  508. struct ct_sns_req *ct_req;
  509. struct ct_sns_rsp *ct_rsp;
  510. if (IS_QLA2100(ha) || IS_QLA2200(ha))
  511. return qla2x00_sns_rnn_id(vha);
  512. /* Issue RNN_ID */
  513. /* Prepare common MS IOCB */
  514. ms_pkt = ha->isp_ops->prep_ms_iocb(vha, RNN_ID_REQ_SIZE,
  515. RNN_ID_RSP_SIZE);
  516. /* Prepare CT request */
  517. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD,
  518. RNN_ID_RSP_SIZE);
  519. ct_rsp = &ha->ct_sns->p.rsp;
  520. /* Prepare CT arguments -- port_id, node_name */
  521. ct_req->req.rnn_id.port_id[0] = vha->d_id.b.domain;
  522. ct_req->req.rnn_id.port_id[1] = vha->d_id.b.area;
  523. ct_req->req.rnn_id.port_id[2] = vha->d_id.b.al_pa;
  524. memcpy(ct_req->req.rnn_id.node_name, vha->node_name, WWN_SIZE);
  525. /* Execute MS IOCB */
  526. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  527. sizeof(ms_iocb_entry_t));
  528. if (rval != QLA_SUCCESS) {
  529. /*EMPTY*/
  530. DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n",
  531. vha->host_no, rval));
  532. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RNN_ID") !=
  533. QLA_SUCCESS) {
  534. rval = QLA_FUNCTION_FAILED;
  535. } else {
  536. DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
  537. vha->host_no));
  538. }
  539. return (rval);
  540. }
  541. void
  542. qla2x00_get_sym_node_name(scsi_qla_host_t *vha, uint8_t *snn)
  543. {
  544. struct qla_hw_data *ha = vha->hw;
  545. sprintf(snn, "%s FW:v%d.%02d.%02d DVR:v%s",ha->model_number,
  546. ha->fw_major_version, ha->fw_minor_version,
  547. ha->fw_subminor_version, qla2x00_version_str);
  548. }
  549. /**
  550. * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA.
  551. * @ha: HA context
  552. *
  553. * Returns 0 on success.
  554. */
  555. int
  556. qla2x00_rsnn_nn(scsi_qla_host_t *vha)
  557. {
  558. int rval;
  559. struct qla_hw_data *ha = vha->hw;
  560. ms_iocb_entry_t *ms_pkt;
  561. struct ct_sns_req *ct_req;
  562. struct ct_sns_rsp *ct_rsp;
  563. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  564. DEBUG2(printk("scsi(%ld): RSNN_ID call unsupported on "
  565. "ISP2100/ISP2200.\n", vha->host_no));
  566. return (QLA_SUCCESS);
  567. }
  568. /* Issue RSNN_NN */
  569. /* Prepare common MS IOCB */
  570. /* Request size adjusted after CT preparation */
  571. ms_pkt = ha->isp_ops->prep_ms_iocb(vha, 0, RSNN_NN_RSP_SIZE);
  572. /* Prepare CT request */
  573. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD,
  574. RSNN_NN_RSP_SIZE);
  575. ct_rsp = &ha->ct_sns->p.rsp;
  576. /* Prepare CT arguments -- node_name, symbolic node_name, size */
  577. memcpy(ct_req->req.rsnn_nn.node_name, vha->node_name, WWN_SIZE);
  578. /* Prepare the Symbolic Node Name */
  579. qla2x00_get_sym_node_name(vha, ct_req->req.rsnn_nn.sym_node_name);
  580. /* Calculate SNN length */
  581. ct_req->req.rsnn_nn.name_len =
  582. (uint8_t)strlen(ct_req->req.rsnn_nn.sym_node_name);
  583. /* Update MS IOCB request */
  584. ms_pkt->req_bytecount =
  585. cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len);
  586. ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
  587. /* Execute MS IOCB */
  588. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  589. sizeof(ms_iocb_entry_t));
  590. if (rval != QLA_SUCCESS) {
  591. /*EMPTY*/
  592. DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n",
  593. vha->host_no, rval));
  594. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RSNN_NN") !=
  595. QLA_SUCCESS) {
  596. rval = QLA_FUNCTION_FAILED;
  597. } else {
  598. DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n",
  599. vha->host_no));
  600. }
  601. return (rval);
  602. }
  603. /**
  604. * qla2x00_prep_sns_cmd() - Prepare common SNS command request fields for query.
  605. * @ha: HA context
  606. * @cmd: GS command
  607. * @scmd_len: Subcommand length
  608. * @data_size: response size in bytes
  609. *
  610. * Returns a pointer to the @ha's sns_cmd.
  611. */
  612. static inline struct sns_cmd_pkt *
  613. qla2x00_prep_sns_cmd(scsi_qla_host_t *vha, uint16_t cmd, uint16_t scmd_len,
  614. uint16_t data_size)
  615. {
  616. uint16_t wc;
  617. struct sns_cmd_pkt *sns_cmd;
  618. struct qla_hw_data *ha = vha->hw;
  619. sns_cmd = ha->sns_cmd;
  620. memset(sns_cmd, 0, sizeof(struct sns_cmd_pkt));
  621. wc = data_size / 2; /* Size in 16bit words. */
  622. sns_cmd->p.cmd.buffer_length = cpu_to_le16(wc);
  623. sns_cmd->p.cmd.buffer_address[0] = cpu_to_le32(LSD(ha->sns_cmd_dma));
  624. sns_cmd->p.cmd.buffer_address[1] = cpu_to_le32(MSD(ha->sns_cmd_dma));
  625. sns_cmd->p.cmd.subcommand_length = cpu_to_le16(scmd_len);
  626. sns_cmd->p.cmd.subcommand = cpu_to_le16(cmd);
  627. wc = (data_size - 16) / 4; /* Size in 32bit words. */
  628. sns_cmd->p.cmd.size = cpu_to_le16(wc);
  629. return (sns_cmd);
  630. }
  631. /**
  632. * qla2x00_sns_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
  633. * @ha: HA context
  634. * @fcport: fcport entry to updated
  635. *
  636. * This command uses the old Exectute SNS Command mailbox routine.
  637. *
  638. * Returns 0 on success.
  639. */
  640. static int
  641. qla2x00_sns_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport)
  642. {
  643. int rval;
  644. struct qla_hw_data *ha = vha->hw;
  645. struct sns_cmd_pkt *sns_cmd;
  646. /* Issue GA_NXT. */
  647. /* Prepare SNS command request. */
  648. sns_cmd = qla2x00_prep_sns_cmd(vha, GA_NXT_CMD, GA_NXT_SNS_SCMD_LEN,
  649. GA_NXT_SNS_DATA_SIZE);
  650. /* Prepare SNS command arguments -- port_id. */
  651. sns_cmd->p.cmd.param[0] = fcport->d_id.b.al_pa;
  652. sns_cmd->p.cmd.param[1] = fcport->d_id.b.area;
  653. sns_cmd->p.cmd.param[2] = fcport->d_id.b.domain;
  654. /* Execute SNS command. */
  655. rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, GA_NXT_SNS_CMD_SIZE / 2,
  656. sizeof(struct sns_cmd_pkt));
  657. if (rval != QLA_SUCCESS) {
  658. /*EMPTY*/
  659. DEBUG2_3(printk("scsi(%ld): GA_NXT Send SNS failed (%d).\n",
  660. vha->host_no, rval));
  661. } else if (sns_cmd->p.gan_data[8] != 0x80 ||
  662. sns_cmd->p.gan_data[9] != 0x02) {
  663. DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, "
  664. "ga_nxt_rsp:\n", vha->host_no));
  665. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gan_data, 16));
  666. rval = QLA_FUNCTION_FAILED;
  667. } else {
  668. /* Populate fc_port_t entry. */
  669. fcport->d_id.b.domain = sns_cmd->p.gan_data[17];
  670. fcport->d_id.b.area = sns_cmd->p.gan_data[18];
  671. fcport->d_id.b.al_pa = sns_cmd->p.gan_data[19];
  672. memcpy(fcport->node_name, &sns_cmd->p.gan_data[284], WWN_SIZE);
  673. memcpy(fcport->port_name, &sns_cmd->p.gan_data[20], WWN_SIZE);
  674. if (sns_cmd->p.gan_data[16] != NS_N_PORT_TYPE &&
  675. sns_cmd->p.gan_data[16] != NS_NL_PORT_TYPE)
  676. fcport->d_id.b.domain = 0xf0;
  677. DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
  678. "nn %02x%02x%02x%02x%02x%02x%02x%02x "
  679. "pn %02x%02x%02x%02x%02x%02x%02x%02x "
  680. "portid=%02x%02x%02x.\n",
  681. vha->host_no,
  682. fcport->node_name[0], fcport->node_name[1],
  683. fcport->node_name[2], fcport->node_name[3],
  684. fcport->node_name[4], fcport->node_name[5],
  685. fcport->node_name[6], fcport->node_name[7],
  686. fcport->port_name[0], fcport->port_name[1],
  687. fcport->port_name[2], fcport->port_name[3],
  688. fcport->port_name[4], fcport->port_name[5],
  689. fcport->port_name[6], fcport->port_name[7],
  690. fcport->d_id.b.domain, fcport->d_id.b.area,
  691. fcport->d_id.b.al_pa));
  692. }
  693. return (rval);
  694. }
  695. /**
  696. * qla2x00_sns_gid_pt() - SNS scan for fabric devices via GID_PT command.
  697. * @ha: HA context
  698. * @list: switch info entries to populate
  699. *
  700. * This command uses the old Exectute SNS Command mailbox routine.
  701. *
  702. * NOTE: Non-Nx_Ports are not requested.
  703. *
  704. * Returns 0 on success.
  705. */
  706. static int
  707. qla2x00_sns_gid_pt(scsi_qla_host_t *vha, sw_info_t *list)
  708. {
  709. int rval;
  710. struct qla_hw_data *ha = vha->hw;
  711. uint16_t i;
  712. uint8_t *entry;
  713. struct sns_cmd_pkt *sns_cmd;
  714. /* Issue GID_PT. */
  715. /* Prepare SNS command request. */
  716. sns_cmd = qla2x00_prep_sns_cmd(vha, GID_PT_CMD, GID_PT_SNS_SCMD_LEN,
  717. GID_PT_SNS_DATA_SIZE);
  718. /* Prepare SNS command arguments -- port_type. */
  719. sns_cmd->p.cmd.param[0] = NS_NX_PORT_TYPE;
  720. /* Execute SNS command. */
  721. rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, GID_PT_SNS_CMD_SIZE / 2,
  722. sizeof(struct sns_cmd_pkt));
  723. if (rval != QLA_SUCCESS) {
  724. /*EMPTY*/
  725. DEBUG2_3(printk("scsi(%ld): GID_PT Send SNS failed (%d).\n",
  726. vha->host_no, rval));
  727. } else if (sns_cmd->p.gid_data[8] != 0x80 ||
  728. sns_cmd->p.gid_data[9] != 0x02) {
  729. DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, "
  730. "gid_rsp:\n", vha->host_no));
  731. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gid_data, 16));
  732. rval = QLA_FUNCTION_FAILED;
  733. } else {
  734. /* Set port IDs in switch info list. */
  735. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  736. entry = &sns_cmd->p.gid_data[(i * 4) + 16];
  737. list[i].d_id.b.domain = entry[1];
  738. list[i].d_id.b.area = entry[2];
  739. list[i].d_id.b.al_pa = entry[3];
  740. /* Last one exit. */
  741. if (entry[0] & BIT_7) {
  742. list[i].d_id.b.rsvd_1 = entry[0];
  743. break;
  744. }
  745. }
  746. /*
  747. * If we've used all available slots, then the switch is
  748. * reporting back more devices that we can handle with this
  749. * single call. Return a failed status, and let GA_NXT handle
  750. * the overload.
  751. */
  752. if (i == MAX_FIBRE_DEVICES)
  753. rval = QLA_FUNCTION_FAILED;
  754. }
  755. return (rval);
  756. }
  757. /**
  758. * qla2x00_sns_gpn_id() - SNS Get Port Name (GPN_ID) query.
  759. * @ha: HA context
  760. * @list: switch info entries to populate
  761. *
  762. * This command uses the old Exectute SNS Command mailbox routine.
  763. *
  764. * Returns 0 on success.
  765. */
  766. static int
  767. qla2x00_sns_gpn_id(scsi_qla_host_t *vha, sw_info_t *list)
  768. {
  769. int rval;
  770. struct qla_hw_data *ha = vha->hw;
  771. uint16_t i;
  772. struct sns_cmd_pkt *sns_cmd;
  773. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  774. /* Issue GPN_ID */
  775. /* Prepare SNS command request. */
  776. sns_cmd = qla2x00_prep_sns_cmd(vha, GPN_ID_CMD,
  777. GPN_ID_SNS_SCMD_LEN, GPN_ID_SNS_DATA_SIZE);
  778. /* Prepare SNS command arguments -- port_id. */
  779. sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
  780. sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
  781. sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
  782. /* Execute SNS command. */
  783. rval = qla2x00_send_sns(vha, ha->sns_cmd_dma,
  784. GPN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
  785. if (rval != QLA_SUCCESS) {
  786. /*EMPTY*/
  787. DEBUG2_3(printk("scsi(%ld): GPN_ID Send SNS failed "
  788. "(%d).\n", vha->host_no, rval));
  789. } else if (sns_cmd->p.gpn_data[8] != 0x80 ||
  790. sns_cmd->p.gpn_data[9] != 0x02) {
  791. DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected "
  792. "request, gpn_rsp:\n", vha->host_no));
  793. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gpn_data, 16));
  794. rval = QLA_FUNCTION_FAILED;
  795. } else {
  796. /* Save portname */
  797. memcpy(list[i].port_name, &sns_cmd->p.gpn_data[16],
  798. WWN_SIZE);
  799. }
  800. /* Last device exit. */
  801. if (list[i].d_id.b.rsvd_1 != 0)
  802. break;
  803. }
  804. return (rval);
  805. }
  806. /**
  807. * qla2x00_sns_gnn_id() - SNS Get Node Name (GNN_ID) query.
  808. * @ha: HA context
  809. * @list: switch info entries to populate
  810. *
  811. * This command uses the old Exectute SNS Command mailbox routine.
  812. *
  813. * Returns 0 on success.
  814. */
  815. static int
  816. qla2x00_sns_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
  817. {
  818. int rval;
  819. struct qla_hw_data *ha = vha->hw;
  820. uint16_t i;
  821. struct sns_cmd_pkt *sns_cmd;
  822. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  823. /* Issue GNN_ID */
  824. /* Prepare SNS command request. */
  825. sns_cmd = qla2x00_prep_sns_cmd(vha, GNN_ID_CMD,
  826. GNN_ID_SNS_SCMD_LEN, GNN_ID_SNS_DATA_SIZE);
  827. /* Prepare SNS command arguments -- port_id. */
  828. sns_cmd->p.cmd.param[0] = list[i].d_id.b.al_pa;
  829. sns_cmd->p.cmd.param[1] = list[i].d_id.b.area;
  830. sns_cmd->p.cmd.param[2] = list[i].d_id.b.domain;
  831. /* Execute SNS command. */
  832. rval = qla2x00_send_sns(vha, ha->sns_cmd_dma,
  833. GNN_ID_SNS_CMD_SIZE / 2, sizeof(struct sns_cmd_pkt));
  834. if (rval != QLA_SUCCESS) {
  835. /*EMPTY*/
  836. DEBUG2_3(printk("scsi(%ld): GNN_ID Send SNS failed "
  837. "(%d).\n", vha->host_no, rval));
  838. } else if (sns_cmd->p.gnn_data[8] != 0x80 ||
  839. sns_cmd->p.gnn_data[9] != 0x02) {
  840. DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected "
  841. "request, gnn_rsp:\n", vha->host_no));
  842. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.gnn_data, 16));
  843. rval = QLA_FUNCTION_FAILED;
  844. } else {
  845. /* Save nodename */
  846. memcpy(list[i].node_name, &sns_cmd->p.gnn_data[16],
  847. WWN_SIZE);
  848. DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
  849. "nn %02x%02x%02x%02x%02x%02x%02x%02x "
  850. "pn %02x%02x%02x%02x%02x%02x%02x%02x "
  851. "portid=%02x%02x%02x.\n",
  852. vha->host_no,
  853. list[i].node_name[0], list[i].node_name[1],
  854. list[i].node_name[2], list[i].node_name[3],
  855. list[i].node_name[4], list[i].node_name[5],
  856. list[i].node_name[6], list[i].node_name[7],
  857. list[i].port_name[0], list[i].port_name[1],
  858. list[i].port_name[2], list[i].port_name[3],
  859. list[i].port_name[4], list[i].port_name[5],
  860. list[i].port_name[6], list[i].port_name[7],
  861. list[i].d_id.b.domain, list[i].d_id.b.area,
  862. list[i].d_id.b.al_pa));
  863. }
  864. /* Last device exit. */
  865. if (list[i].d_id.b.rsvd_1 != 0)
  866. break;
  867. }
  868. return (rval);
  869. }
  870. /**
  871. * qla2x00_snd_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
  872. * @ha: HA context
  873. *
  874. * This command uses the old Exectute SNS Command mailbox routine.
  875. *
  876. * Returns 0 on success.
  877. */
  878. static int
  879. qla2x00_sns_rft_id(scsi_qla_host_t *vha)
  880. {
  881. int rval;
  882. struct qla_hw_data *ha = vha->hw;
  883. struct sns_cmd_pkt *sns_cmd;
  884. /* Issue RFT_ID. */
  885. /* Prepare SNS command request. */
  886. sns_cmd = qla2x00_prep_sns_cmd(vha, RFT_ID_CMD, RFT_ID_SNS_SCMD_LEN,
  887. RFT_ID_SNS_DATA_SIZE);
  888. /* Prepare SNS command arguments -- port_id, FC-4 types */
  889. sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa;
  890. sns_cmd->p.cmd.param[1] = vha->d_id.b.area;
  891. sns_cmd->p.cmd.param[2] = vha->d_id.b.domain;
  892. sns_cmd->p.cmd.param[5] = 0x01; /* FCP-3 */
  893. /* Execute SNS command. */
  894. rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, RFT_ID_SNS_CMD_SIZE / 2,
  895. sizeof(struct sns_cmd_pkt));
  896. if (rval != QLA_SUCCESS) {
  897. /*EMPTY*/
  898. DEBUG2_3(printk("scsi(%ld): RFT_ID Send SNS failed (%d).\n",
  899. vha->host_no, rval));
  900. } else if (sns_cmd->p.rft_data[8] != 0x80 ||
  901. sns_cmd->p.rft_data[9] != 0x02) {
  902. DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected request, "
  903. "rft_rsp:\n", vha->host_no));
  904. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rft_data, 16));
  905. rval = QLA_FUNCTION_FAILED;
  906. } else {
  907. DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
  908. vha->host_no));
  909. }
  910. return (rval);
  911. }
  912. /**
  913. * qla2x00_sns_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
  914. * HBA.
  915. * @ha: HA context
  916. *
  917. * This command uses the old Exectute SNS Command mailbox routine.
  918. *
  919. * Returns 0 on success.
  920. */
  921. static int
  922. qla2x00_sns_rnn_id(scsi_qla_host_t *vha)
  923. {
  924. int rval;
  925. struct qla_hw_data *ha = vha->hw;
  926. struct sns_cmd_pkt *sns_cmd;
  927. /* Issue RNN_ID. */
  928. /* Prepare SNS command request. */
  929. sns_cmd = qla2x00_prep_sns_cmd(vha, RNN_ID_CMD, RNN_ID_SNS_SCMD_LEN,
  930. RNN_ID_SNS_DATA_SIZE);
  931. /* Prepare SNS command arguments -- port_id, nodename. */
  932. sns_cmd->p.cmd.param[0] = vha->d_id.b.al_pa;
  933. sns_cmd->p.cmd.param[1] = vha->d_id.b.area;
  934. sns_cmd->p.cmd.param[2] = vha->d_id.b.domain;
  935. sns_cmd->p.cmd.param[4] = vha->node_name[7];
  936. sns_cmd->p.cmd.param[5] = vha->node_name[6];
  937. sns_cmd->p.cmd.param[6] = vha->node_name[5];
  938. sns_cmd->p.cmd.param[7] = vha->node_name[4];
  939. sns_cmd->p.cmd.param[8] = vha->node_name[3];
  940. sns_cmd->p.cmd.param[9] = vha->node_name[2];
  941. sns_cmd->p.cmd.param[10] = vha->node_name[1];
  942. sns_cmd->p.cmd.param[11] = vha->node_name[0];
  943. /* Execute SNS command. */
  944. rval = qla2x00_send_sns(vha, ha->sns_cmd_dma, RNN_ID_SNS_CMD_SIZE / 2,
  945. sizeof(struct sns_cmd_pkt));
  946. if (rval != QLA_SUCCESS) {
  947. /*EMPTY*/
  948. DEBUG2_3(printk("scsi(%ld): RNN_ID Send SNS failed (%d).\n",
  949. vha->host_no, rval));
  950. } else if (sns_cmd->p.rnn_data[8] != 0x80 ||
  951. sns_cmd->p.rnn_data[9] != 0x02) {
  952. DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected request, "
  953. "rnn_rsp:\n", vha->host_no));
  954. DEBUG2_3(qla2x00_dump_buffer(sns_cmd->p.rnn_data, 16));
  955. rval = QLA_FUNCTION_FAILED;
  956. } else {
  957. DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
  958. vha->host_no));
  959. }
  960. return (rval);
  961. }
  962. /**
  963. * qla2x00_mgmt_svr_login() - Login to fabric Management Service.
  964. * @ha: HA context
  965. *
  966. * Returns 0 on success.
  967. */
  968. static int
  969. qla2x00_mgmt_svr_login(scsi_qla_host_t *vha)
  970. {
  971. int ret;
  972. uint16_t mb[MAILBOX_REGISTER_COUNT];
  973. struct qla_hw_data *ha = vha->hw;
  974. ret = QLA_SUCCESS;
  975. if (vha->flags.management_server_logged_in)
  976. return ret;
  977. ha->isp_ops->fabric_login(vha, vha->mgmt_svr_loop_id, 0xff, 0xff, 0xfa,
  978. mb, BIT_1|BIT_0);
  979. if (mb[0] != MBS_COMMAND_COMPLETE) {
  980. DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: "
  981. "loop_id=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[6]=%x mb[7]=%x\n",
  982. __func__, vha->host_no, vha->mgmt_svr_loop_id, mb[0], mb[1],
  983. mb[2], mb[6], mb[7]));
  984. ret = QLA_FUNCTION_FAILED;
  985. } else
  986. vha->flags.management_server_logged_in = 1;
  987. return ret;
  988. }
  989. /**
  990. * qla2x00_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
  991. * @ha: HA context
  992. * @req_size: request size in bytes
  993. * @rsp_size: response size in bytes
  994. *
  995. * Returns a pointer to the @ha's ms_iocb.
  996. */
  997. void *
  998. qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size,
  999. uint32_t rsp_size)
  1000. {
  1001. ms_iocb_entry_t *ms_pkt;
  1002. struct qla_hw_data *ha = vha->hw;
  1003. ms_pkt = ha->ms_iocb;
  1004. memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
  1005. ms_pkt->entry_type = MS_IOCB_TYPE;
  1006. ms_pkt->entry_count = 1;
  1007. SET_TARGET_ID(ha, ms_pkt->loop_id, vha->mgmt_svr_loop_id);
  1008. ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG);
  1009. ms_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
  1010. ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
  1011. ms_pkt->total_dsd_count = __constant_cpu_to_le16(2);
  1012. ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size);
  1013. ms_pkt->req_bytecount = cpu_to_le32(req_size);
  1014. ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  1015. ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  1016. ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
  1017. ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  1018. ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  1019. ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
  1020. return ms_pkt;
  1021. }
  1022. /**
  1023. * qla24xx_prep_ms_fdmi_iocb() - Prepare common MS IOCB fields for FDMI query.
  1024. * @ha: HA context
  1025. * @req_size: request size in bytes
  1026. * @rsp_size: response size in bytes
  1027. *
  1028. * Returns a pointer to the @ha's ms_iocb.
  1029. */
  1030. void *
  1031. qla24xx_prep_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size,
  1032. uint32_t rsp_size)
  1033. {
  1034. struct ct_entry_24xx *ct_pkt;
  1035. struct qla_hw_data *ha = vha->hw;
  1036. ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
  1037. memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
  1038. ct_pkt->entry_type = CT_IOCB_TYPE;
  1039. ct_pkt->entry_count = 1;
  1040. ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id);
  1041. ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
  1042. ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
  1043. ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
  1044. ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
  1045. ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
  1046. ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  1047. ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  1048. ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
  1049. ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  1050. ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  1051. ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
  1052. ct_pkt->vp_index = vha->vp_idx;
  1053. return ct_pkt;
  1054. }
  1055. static inline ms_iocb_entry_t *
  1056. qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size)
  1057. {
  1058. struct qla_hw_data *ha = vha->hw;
  1059. ms_iocb_entry_t *ms_pkt = ha->ms_iocb;
  1060. struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
  1061. if (IS_FWI2_CAPABLE(ha)) {
  1062. ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
  1063. ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
  1064. } else {
  1065. ms_pkt->req_bytecount = cpu_to_le32(req_size);
  1066. ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
  1067. }
  1068. return ms_pkt;
  1069. }
  1070. /**
  1071. * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
  1072. * @ct_req: CT request buffer
  1073. * @cmd: GS command
  1074. * @rsp_size: response size in bytes
  1075. *
  1076. * Returns a pointer to the intitialized @ct_req.
  1077. */
  1078. static inline struct ct_sns_req *
  1079. qla2x00_prep_ct_fdmi_req(struct ct_sns_req *ct_req, uint16_t cmd,
  1080. uint16_t rsp_size)
  1081. {
  1082. memset(ct_req, 0, sizeof(struct ct_sns_pkt));
  1083. ct_req->header.revision = 0x01;
  1084. ct_req->header.gs_type = 0xFA;
  1085. ct_req->header.gs_subtype = 0x10;
  1086. ct_req->command = cpu_to_be16(cmd);
  1087. ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
  1088. return ct_req;
  1089. }
  1090. /**
  1091. * qla2x00_fdmi_rhba() -
  1092. * @ha: HA context
  1093. *
  1094. * Returns 0 on success.
  1095. */
  1096. static int
  1097. qla2x00_fdmi_rhba(scsi_qla_host_t *vha)
  1098. {
  1099. int rval, alen;
  1100. uint32_t size, sn;
  1101. ms_iocb_entry_t *ms_pkt;
  1102. struct ct_sns_req *ct_req;
  1103. struct ct_sns_rsp *ct_rsp;
  1104. uint8_t *entries;
  1105. struct ct_fdmi_hba_attr *eiter;
  1106. struct qla_hw_data *ha = vha->hw;
  1107. /* Issue RHBA */
  1108. /* Prepare common MS IOCB */
  1109. /* Request size adjusted after CT preparation */
  1110. ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RHBA_RSP_SIZE);
  1111. /* Prepare CT request */
  1112. ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD,
  1113. RHBA_RSP_SIZE);
  1114. ct_rsp = &ha->ct_sns->p.rsp;
  1115. /* Prepare FDMI command arguments -- attribute block, attributes. */
  1116. memcpy(ct_req->req.rhba.hba_identifier, vha->port_name, WWN_SIZE);
  1117. ct_req->req.rhba.entry_count = __constant_cpu_to_be32(1);
  1118. memcpy(ct_req->req.rhba.port_name, vha->port_name, WWN_SIZE);
  1119. size = 2 * WWN_SIZE + 4 + 4;
  1120. /* Attributes */
  1121. ct_req->req.rhba.attrs.count =
  1122. __constant_cpu_to_be32(FDMI_HBA_ATTR_COUNT);
  1123. entries = ct_req->req.rhba.hba_identifier;
  1124. /* Nodename. */
  1125. eiter = (struct ct_fdmi_hba_attr *) (entries + size);
  1126. eiter->type = __constant_cpu_to_be16(FDMI_HBA_NODE_NAME);
  1127. eiter->len = __constant_cpu_to_be16(4 + WWN_SIZE);
  1128. memcpy(eiter->a.node_name, vha->node_name, WWN_SIZE);
  1129. size += 4 + WWN_SIZE;
  1130. DEBUG13(printk("%s(%ld): NODENAME=%02x%02x%02x%02x%02x%02x%02x%02x.\n",
  1131. __func__, vha->host_no,
  1132. eiter->a.node_name[0], eiter->a.node_name[1], eiter->a.node_name[2],
  1133. eiter->a.node_name[3], eiter->a.node_name[4], eiter->a.node_name[5],
  1134. eiter->a.node_name[6], eiter->a.node_name[7]));
  1135. /* Manufacturer. */
  1136. eiter = (struct ct_fdmi_hba_attr *) (entries + size);
  1137. eiter->type = __constant_cpu_to_be16(FDMI_HBA_MANUFACTURER);
  1138. strcpy(eiter->a.manufacturer, "QLogic Corporation");
  1139. alen = strlen(eiter->a.manufacturer);
  1140. alen += (alen & 3) ? (4 - (alen & 3)) : 4;
  1141. eiter->len = cpu_to_be16(4 + alen);
  1142. size += 4 + alen;
  1143. DEBUG13(printk("%s(%ld): MANUFACTURER=%s.\n", __func__, vha->host_no,
  1144. eiter->a.manufacturer));
  1145. /* Serial number. */
  1146. eiter = (struct ct_fdmi_hba_attr *) (entries + size);
  1147. eiter->type = __constant_cpu_to_be16(FDMI_HBA_SERIAL_NUMBER);
  1148. sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1;
  1149. sprintf(eiter->a.serial_num, "%c%05d", 'A' + sn / 100000, sn % 100000);
  1150. alen = strlen(eiter->a.serial_num);
  1151. alen += (alen & 3) ? (4 - (alen & 3)) : 4;
  1152. eiter->len = cpu_to_be16(4 + alen);
  1153. size += 4 + alen;
  1154. DEBUG13(printk("%s(%ld): SERIALNO=%s.\n", __func__, vha->host_no,
  1155. eiter->a.serial_num));
  1156. /* Model name. */
  1157. eiter = (struct ct_fdmi_hba_attr *) (entries + size);
  1158. eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL);
  1159. strcpy(eiter->a.model, ha->model_number);
  1160. alen = strlen(eiter->a.model);
  1161. alen += (alen & 3) ? (4 - (alen & 3)) : 4;
  1162. eiter->len = cpu_to_be16(4 + alen);
  1163. size += 4 + alen;
  1164. DEBUG13(printk("%s(%ld): MODEL_NAME=%s.\n", __func__, vha->host_no,
  1165. eiter->a.model));
  1166. /* Model description. */
  1167. eiter = (struct ct_fdmi_hba_attr *) (entries + size);
  1168. eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION);
  1169. if (ha->model_desc)
  1170. strncpy(eiter->a.model_desc, ha->model_desc, 80);
  1171. alen = strlen(eiter->a.model_desc);
  1172. alen += (alen & 3) ? (4 - (alen & 3)) : 4;
  1173. eiter->len = cpu_to_be16(4 + alen);
  1174. size += 4 + alen;
  1175. DEBUG13(printk("%s(%ld): MODEL_DESC=%s.\n", __func__, vha->host_no,
  1176. eiter->a.model_desc));
  1177. /* Hardware version. */
  1178. eiter = (struct ct_fdmi_hba_attr *) (entries + size);
  1179. eiter->type = __constant_cpu_to_be16(FDMI_HBA_HARDWARE_VERSION);
  1180. strcpy(eiter->a.hw_version, ha->adapter_id);
  1181. alen = strlen(eiter->a.hw_version);
  1182. alen += (alen & 3) ? (4 - (alen & 3)) : 4;
  1183. eiter->len = cpu_to_be16(4 + alen);
  1184. size += 4 + alen;
  1185. DEBUG13(printk("%s(%ld): HARDWAREVER=%s.\n", __func__, vha->host_no,
  1186. eiter->a.hw_version));
  1187. /* Driver version. */
  1188. eiter = (struct ct_fdmi_hba_attr *) (entries + size);
  1189. eiter->type = __constant_cpu_to_be16(FDMI_HBA_DRIVER_VERSION);
  1190. strcpy(eiter->a.driver_version, qla2x00_version_str);
  1191. alen = strlen(eiter->a.driver_version);
  1192. alen += (alen & 3) ? (4 - (alen & 3)) : 4;
  1193. eiter->len = cpu_to_be16(4 + alen);
  1194. size += 4 + alen;
  1195. DEBUG13(printk("%s(%ld): DRIVERVER=%s.\n", __func__, vha->host_no,
  1196. eiter->a.driver_version));
  1197. /* Option ROM version. */
  1198. eiter = (struct ct_fdmi_hba_attr *) (entries + size);
  1199. eiter->type = __constant_cpu_to_be16(FDMI_HBA_OPTION_ROM_VERSION);
  1200. strcpy(eiter->a.orom_version, "0.00");
  1201. alen = strlen(eiter->a.orom_version);
  1202. alen += (alen & 3) ? (4 - (alen & 3)) : 4;
  1203. eiter->len = cpu_to_be16(4 + alen);
  1204. size += 4 + alen;
  1205. DEBUG13(printk("%s(%ld): OPTROMVER=%s.\n", __func__, vha->host_no,
  1206. eiter->a.orom_version));
  1207. /* Firmware version */
  1208. eiter = (struct ct_fdmi_hba_attr *) (entries + size);
  1209. eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION);
  1210. ha->isp_ops->fw_version_str(vha, eiter->a.fw_version);
  1211. alen = strlen(eiter->a.fw_version);
  1212. alen += (alen & 3) ? (4 - (alen & 3)) : 4;
  1213. eiter->len = cpu_to_be16(4 + alen);
  1214. size += 4 + alen;
  1215. DEBUG13(printk("%s(%ld): FIRMWAREVER=%s.\n", __func__, vha->host_no,
  1216. eiter->a.fw_version));
  1217. /* Update MS request size. */
  1218. qla2x00_update_ms_fdmi_iocb(vha, size + 16);
  1219. DEBUG13(printk("%s(%ld): RHBA identifier="
  1220. "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__,
  1221. vha->host_no, ct_req->req.rhba.hba_identifier[0],
  1222. ct_req->req.rhba.hba_identifier[1],
  1223. ct_req->req.rhba.hba_identifier[2],
  1224. ct_req->req.rhba.hba_identifier[3],
  1225. ct_req->req.rhba.hba_identifier[4],
  1226. ct_req->req.rhba.hba_identifier[5],
  1227. ct_req->req.rhba.hba_identifier[6],
  1228. ct_req->req.rhba.hba_identifier[7], size));
  1229. DEBUG13(qla2x00_dump_buffer(entries, size));
  1230. /* Execute MS IOCB */
  1231. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  1232. sizeof(ms_iocb_entry_t));
  1233. if (rval != QLA_SUCCESS) {
  1234. /*EMPTY*/
  1235. DEBUG2_3(printk("scsi(%ld): RHBA issue IOCB failed (%d).\n",
  1236. vha->host_no, rval));
  1237. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RHBA") !=
  1238. QLA_SUCCESS) {
  1239. rval = QLA_FUNCTION_FAILED;
  1240. if (ct_rsp->header.reason_code == CT_REASON_CANNOT_PERFORM &&
  1241. ct_rsp->header.explanation_code ==
  1242. CT_EXPL_ALREADY_REGISTERED) {
  1243. DEBUG2_13(printk("%s(%ld): HBA already registered.\n",
  1244. __func__, vha->host_no));
  1245. rval = QLA_ALREADY_REGISTERED;
  1246. }
  1247. } else {
  1248. DEBUG2(printk("scsi(%ld): RHBA exiting normally.\n",
  1249. vha->host_no));
  1250. }
  1251. return rval;
  1252. }
  1253. /**
  1254. * qla2x00_fdmi_dhba() -
  1255. * @ha: HA context
  1256. *
  1257. * Returns 0 on success.
  1258. */
  1259. static int
  1260. qla2x00_fdmi_dhba(scsi_qla_host_t *vha)
  1261. {
  1262. int rval;
  1263. struct qla_hw_data *ha = vha->hw;
  1264. ms_iocb_entry_t *ms_pkt;
  1265. struct ct_sns_req *ct_req;
  1266. struct ct_sns_rsp *ct_rsp;
  1267. /* Issue RPA */
  1268. /* Prepare common MS IOCB */
  1269. ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, DHBA_REQ_SIZE,
  1270. DHBA_RSP_SIZE);
  1271. /* Prepare CT request */
  1272. ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, DHBA_CMD,
  1273. DHBA_RSP_SIZE);
  1274. ct_rsp = &ha->ct_sns->p.rsp;
  1275. /* Prepare FDMI command arguments -- portname. */
  1276. memcpy(ct_req->req.dhba.port_name, vha->port_name, WWN_SIZE);
  1277. DEBUG13(printk("%s(%ld): DHBA portname="
  1278. "%02x%02x%02x%02x%02x%02x%02x%02x.\n", __func__, vha->host_no,
  1279. ct_req->req.dhba.port_name[0], ct_req->req.dhba.port_name[1],
  1280. ct_req->req.dhba.port_name[2], ct_req->req.dhba.port_name[3],
  1281. ct_req->req.dhba.port_name[4], ct_req->req.dhba.port_name[5],
  1282. ct_req->req.dhba.port_name[6], ct_req->req.dhba.port_name[7]));
  1283. /* Execute MS IOCB */
  1284. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  1285. sizeof(ms_iocb_entry_t));
  1286. if (rval != QLA_SUCCESS) {
  1287. /*EMPTY*/
  1288. DEBUG2_3(printk("scsi(%ld): DHBA issue IOCB failed (%d).\n",
  1289. vha->host_no, rval));
  1290. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "DHBA") !=
  1291. QLA_SUCCESS) {
  1292. rval = QLA_FUNCTION_FAILED;
  1293. } else {
  1294. DEBUG2(printk("scsi(%ld): DHBA exiting normally.\n",
  1295. vha->host_no));
  1296. }
  1297. return rval;
  1298. }
  1299. /**
  1300. * qla2x00_fdmi_rpa() -
  1301. * @ha: HA context
  1302. *
  1303. * Returns 0 on success.
  1304. */
  1305. static int
  1306. qla2x00_fdmi_rpa(scsi_qla_host_t *vha)
  1307. {
  1308. int rval, alen;
  1309. uint32_t size, max_frame_size;
  1310. struct qla_hw_data *ha = vha->hw;
  1311. ms_iocb_entry_t *ms_pkt;
  1312. struct ct_sns_req *ct_req;
  1313. struct ct_sns_rsp *ct_rsp;
  1314. uint8_t *entries;
  1315. struct ct_fdmi_port_attr *eiter;
  1316. struct init_cb_24xx *icb24 = (struct init_cb_24xx *)ha->init_cb;
  1317. /* Issue RPA */
  1318. /* Prepare common MS IOCB */
  1319. /* Request size adjusted after CT preparation */
  1320. ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(vha, 0, RPA_RSP_SIZE);
  1321. /* Prepare CT request */
  1322. ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD,
  1323. RPA_RSP_SIZE);
  1324. ct_rsp = &ha->ct_sns->p.rsp;
  1325. /* Prepare FDMI command arguments -- attribute block, attributes. */
  1326. memcpy(ct_req->req.rpa.port_name, vha->port_name, WWN_SIZE);
  1327. size = WWN_SIZE + 4;
  1328. /* Attributes */
  1329. ct_req->req.rpa.attrs.count =
  1330. __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT - 1);
  1331. entries = ct_req->req.rpa.port_name;
  1332. /* FC4 types. */
  1333. eiter = (struct ct_fdmi_port_attr *) (entries + size);
  1334. eiter->type = __constant_cpu_to_be16(FDMI_PORT_FC4_TYPES);
  1335. eiter->len = __constant_cpu_to_be16(4 + 32);
  1336. eiter->a.fc4_types[2] = 0x01;
  1337. size += 4 + 32;
  1338. DEBUG13(printk("%s(%ld): FC4_TYPES=%02x %02x.\n", __func__,
  1339. vha->host_no, eiter->a.fc4_types[2],
  1340. eiter->a.fc4_types[1]));
  1341. /* Supported speed. */
  1342. eiter = (struct ct_fdmi_port_attr *) (entries + size);
  1343. eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED);
  1344. eiter->len = __constant_cpu_to_be16(4 + 4);
  1345. if (IS_QLA8XXX_TYPE(ha))
  1346. eiter->a.sup_speed = __constant_cpu_to_be32(
  1347. FDMI_PORT_SPEED_10GB);
  1348. else if (IS_QLA25XX(ha))
  1349. eiter->a.sup_speed = __constant_cpu_to_be32(
  1350. FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB|
  1351. FDMI_PORT_SPEED_4GB|FDMI_PORT_SPEED_8GB);
  1352. else if (IS_QLA24XX_TYPE(ha))
  1353. eiter->a.sup_speed = __constant_cpu_to_be32(
  1354. FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB|
  1355. FDMI_PORT_SPEED_4GB);
  1356. else if (IS_QLA23XX(ha))
  1357. eiter->a.sup_speed =__constant_cpu_to_be32(
  1358. FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB);
  1359. else
  1360. eiter->a.sup_speed = __constant_cpu_to_be32(
  1361. FDMI_PORT_SPEED_1GB);
  1362. size += 4 + 4;
  1363. DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, vha->host_no,
  1364. eiter->a.sup_speed));
  1365. /* Current speed. */
  1366. eiter = (struct ct_fdmi_port_attr *) (entries + size);
  1367. eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED);
  1368. eiter->len = __constant_cpu_to_be16(4 + 4);
  1369. switch (ha->link_data_rate) {
  1370. case PORT_SPEED_1GB:
  1371. eiter->a.cur_speed =
  1372. __constant_cpu_to_be32(FDMI_PORT_SPEED_1GB);
  1373. break;
  1374. case PORT_SPEED_2GB:
  1375. eiter->a.cur_speed =
  1376. __constant_cpu_to_be32(FDMI_PORT_SPEED_2GB);
  1377. break;
  1378. case PORT_SPEED_4GB:
  1379. eiter->a.cur_speed =
  1380. __constant_cpu_to_be32(FDMI_PORT_SPEED_4GB);
  1381. break;
  1382. case PORT_SPEED_8GB:
  1383. eiter->a.cur_speed =
  1384. __constant_cpu_to_be32(FDMI_PORT_SPEED_8GB);
  1385. break;
  1386. case PORT_SPEED_10GB:
  1387. eiter->a.cur_speed =
  1388. __constant_cpu_to_be32(FDMI_PORT_SPEED_10GB);
  1389. break;
  1390. default:
  1391. eiter->a.cur_speed =
  1392. __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN);
  1393. break;
  1394. }
  1395. size += 4 + 4;
  1396. DEBUG13(printk("%s(%ld): CURRENT_SPEED=%x.\n", __func__, vha->host_no,
  1397. eiter->a.cur_speed));
  1398. /* Max frame size. */
  1399. eiter = (struct ct_fdmi_port_attr *) (entries + size);
  1400. eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE);
  1401. eiter->len = __constant_cpu_to_be16(4 + 4);
  1402. max_frame_size = IS_FWI2_CAPABLE(ha) ?
  1403. le16_to_cpu(icb24->frame_payload_size):
  1404. le16_to_cpu(ha->init_cb->frame_payload_size);
  1405. eiter->a.max_frame_size = cpu_to_be32(max_frame_size);
  1406. size += 4 + 4;
  1407. DEBUG13(printk("%s(%ld): MAX_FRAME_SIZE=%x.\n", __func__, vha->host_no,
  1408. eiter->a.max_frame_size));
  1409. /* OS device name. */
  1410. eiter = (struct ct_fdmi_port_attr *) (entries + size);
  1411. eiter->type = __constant_cpu_to_be16(FDMI_PORT_OS_DEVICE_NAME);
  1412. strcpy(eiter->a.os_dev_name, QLA2XXX_DRIVER_NAME);
  1413. alen = strlen(eiter->a.os_dev_name);
  1414. alen += (alen & 3) ? (4 - (alen & 3)) : 4;
  1415. eiter->len = cpu_to_be16(4 + alen);
  1416. size += 4 + alen;
  1417. DEBUG13(printk("%s(%ld): OS_DEVICE_NAME=%s.\n", __func__, vha->host_no,
  1418. eiter->a.os_dev_name));
  1419. /* Hostname. */
  1420. if (strlen(fc_host_system_hostname(vha->host))) {
  1421. ct_req->req.rpa.attrs.count =
  1422. __constant_cpu_to_be32(FDMI_PORT_ATTR_COUNT);
  1423. eiter = (struct ct_fdmi_port_attr *) (entries + size);
  1424. eiter->type = __constant_cpu_to_be16(FDMI_PORT_HOST_NAME);
  1425. snprintf(eiter->a.host_name, sizeof(eiter->a.host_name),
  1426. "%s", fc_host_system_hostname(vha->host));
  1427. alen = strlen(eiter->a.host_name);
  1428. alen += (alen & 3) ? (4 - (alen & 3)) : 4;
  1429. eiter->len = cpu_to_be16(4 + alen);
  1430. size += 4 + alen;
  1431. DEBUG13(printk("%s(%ld): HOSTNAME=%s.\n", __func__,
  1432. vha->host_no, eiter->a.host_name));
  1433. }
  1434. /* Update MS request size. */
  1435. qla2x00_update_ms_fdmi_iocb(vha, size + 16);
  1436. DEBUG13(printk("%s(%ld): RPA portname="
  1437. "%02x%02x%02x%02x%02x%02x%02x%02x size=%d.\n", __func__,
  1438. vha->host_no, ct_req->req.rpa.port_name[0],
  1439. ct_req->req.rpa.port_name[1], ct_req->req.rpa.port_name[2],
  1440. ct_req->req.rpa.port_name[3], ct_req->req.rpa.port_name[4],
  1441. ct_req->req.rpa.port_name[5], ct_req->req.rpa.port_name[6],
  1442. ct_req->req.rpa.port_name[7], size));
  1443. DEBUG13(qla2x00_dump_buffer(entries, size));
  1444. /* Execute MS IOCB */
  1445. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  1446. sizeof(ms_iocb_entry_t));
  1447. if (rval != QLA_SUCCESS) {
  1448. /*EMPTY*/
  1449. DEBUG2_3(printk("scsi(%ld): RPA issue IOCB failed (%d).\n",
  1450. vha->host_no, rval));
  1451. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp, "RPA") !=
  1452. QLA_SUCCESS) {
  1453. rval = QLA_FUNCTION_FAILED;
  1454. } else {
  1455. DEBUG2(printk("scsi(%ld): RPA exiting normally.\n",
  1456. vha->host_no));
  1457. }
  1458. return rval;
  1459. }
  1460. /**
  1461. * qla2x00_fdmi_register() -
  1462. * @ha: HA context
  1463. *
  1464. * Returns 0 on success.
  1465. */
  1466. int
  1467. qla2x00_fdmi_register(scsi_qla_host_t *vha)
  1468. {
  1469. int rval;
  1470. struct qla_hw_data *ha = vha->hw;
  1471. if (IS_QLA2100(ha) || IS_QLA2200(ha))
  1472. return QLA_FUNCTION_FAILED;
  1473. rval = qla2x00_mgmt_svr_login(vha);
  1474. if (rval)
  1475. return rval;
  1476. rval = qla2x00_fdmi_rhba(vha);
  1477. if (rval) {
  1478. if (rval != QLA_ALREADY_REGISTERED)
  1479. return rval;
  1480. rval = qla2x00_fdmi_dhba(vha);
  1481. if (rval)
  1482. return rval;
  1483. rval = qla2x00_fdmi_rhba(vha);
  1484. if (rval)
  1485. return rval;
  1486. }
  1487. rval = qla2x00_fdmi_rpa(vha);
  1488. return rval;
  1489. }
  1490. /**
  1491. * qla2x00_gfpn_id() - SNS Get Fabric Port Name (GFPN_ID) query.
  1492. * @ha: HA context
  1493. * @list: switch info entries to populate
  1494. *
  1495. * Returns 0 on success.
  1496. */
  1497. int
  1498. qla2x00_gfpn_id(scsi_qla_host_t *vha, sw_info_t *list)
  1499. {
  1500. int rval;
  1501. uint16_t i;
  1502. struct qla_hw_data *ha = vha->hw;
  1503. ms_iocb_entry_t *ms_pkt;
  1504. struct ct_sns_req *ct_req;
  1505. struct ct_sns_rsp *ct_rsp;
  1506. if (!IS_IIDMA_CAPABLE(ha))
  1507. return QLA_FUNCTION_FAILED;
  1508. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  1509. /* Issue GFPN_ID */
  1510. /* Prepare common MS IOCB */
  1511. ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GFPN_ID_REQ_SIZE,
  1512. GFPN_ID_RSP_SIZE);
  1513. /* Prepare CT request */
  1514. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFPN_ID_CMD,
  1515. GFPN_ID_RSP_SIZE);
  1516. ct_rsp = &ha->ct_sns->p.rsp;
  1517. /* Prepare CT arguments -- port_id */
  1518. ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
  1519. ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
  1520. ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
  1521. /* Execute MS IOCB */
  1522. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  1523. sizeof(ms_iocb_entry_t));
  1524. if (rval != QLA_SUCCESS) {
  1525. /*EMPTY*/
  1526. DEBUG2_3(printk("scsi(%ld): GFPN_ID issue IOCB "
  1527. "failed (%d).\n", vha->host_no, rval));
  1528. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
  1529. "GFPN_ID") != QLA_SUCCESS) {
  1530. rval = QLA_FUNCTION_FAILED;
  1531. } else {
  1532. /* Save fabric portname */
  1533. memcpy(list[i].fabric_port_name,
  1534. ct_rsp->rsp.gfpn_id.port_name, WWN_SIZE);
  1535. }
  1536. /* Last device exit. */
  1537. if (list[i].d_id.b.rsvd_1 != 0)
  1538. break;
  1539. }
  1540. return (rval);
  1541. }
  1542. static inline void *
  1543. qla24xx_prep_ms_fm_iocb(scsi_qla_host_t *vha, uint32_t req_size,
  1544. uint32_t rsp_size)
  1545. {
  1546. struct ct_entry_24xx *ct_pkt;
  1547. struct qla_hw_data *ha = vha->hw;
  1548. ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
  1549. memset(ct_pkt, 0, sizeof(struct ct_entry_24xx));
  1550. ct_pkt->entry_type = CT_IOCB_TYPE;
  1551. ct_pkt->entry_count = 1;
  1552. ct_pkt->nport_handle = cpu_to_le16(vha->mgmt_svr_loop_id);
  1553. ct_pkt->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2);
  1554. ct_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
  1555. ct_pkt->rsp_dsd_count = __constant_cpu_to_le16(1);
  1556. ct_pkt->rsp_byte_count = cpu_to_le32(rsp_size);
  1557. ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
  1558. ct_pkt->dseg_0_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  1559. ct_pkt->dseg_0_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  1560. ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
  1561. ct_pkt->dseg_1_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
  1562. ct_pkt->dseg_1_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
  1563. ct_pkt->dseg_1_len = ct_pkt->rsp_byte_count;
  1564. ct_pkt->vp_index = vha->vp_idx;
  1565. return ct_pkt;
  1566. }
  1567. static inline struct ct_sns_req *
  1568. qla24xx_prep_ct_fm_req(struct ct_sns_req *ct_req, uint16_t cmd,
  1569. uint16_t rsp_size)
  1570. {
  1571. memset(ct_req, 0, sizeof(struct ct_sns_pkt));
  1572. ct_req->header.revision = 0x01;
  1573. ct_req->header.gs_type = 0xFA;
  1574. ct_req->header.gs_subtype = 0x01;
  1575. ct_req->command = cpu_to_be16(cmd);
  1576. ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
  1577. return ct_req;
  1578. }
  1579. /**
  1580. * qla2x00_gpsc() - FCS Get Port Speed Capabilities (GPSC) query.
  1581. * @ha: HA context
  1582. * @list: switch info entries to populate
  1583. *
  1584. * Returns 0 on success.
  1585. */
  1586. int
  1587. qla2x00_gpsc(scsi_qla_host_t *vha, sw_info_t *list)
  1588. {
  1589. int rval;
  1590. uint16_t i;
  1591. struct qla_hw_data *ha = vha->hw;
  1592. ms_iocb_entry_t *ms_pkt;
  1593. struct ct_sns_req *ct_req;
  1594. struct ct_sns_rsp *ct_rsp;
  1595. if (!IS_IIDMA_CAPABLE(ha))
  1596. return QLA_FUNCTION_FAILED;
  1597. if (!ha->flags.gpsc_supported)
  1598. return QLA_FUNCTION_FAILED;
  1599. rval = qla2x00_mgmt_svr_login(vha);
  1600. if (rval)
  1601. return rval;
  1602. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  1603. /* Issue GFPN_ID */
  1604. /* Prepare common MS IOCB */
  1605. ms_pkt = qla24xx_prep_ms_fm_iocb(vha, GPSC_REQ_SIZE,
  1606. GPSC_RSP_SIZE);
  1607. /* Prepare CT request */
  1608. ct_req = qla24xx_prep_ct_fm_req(&ha->ct_sns->p.req,
  1609. GPSC_CMD, GPSC_RSP_SIZE);
  1610. ct_rsp = &ha->ct_sns->p.rsp;
  1611. /* Prepare CT arguments -- port_name */
  1612. memcpy(ct_req->req.gpsc.port_name, list[i].fabric_port_name,
  1613. WWN_SIZE);
  1614. /* Execute MS IOCB */
  1615. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  1616. sizeof(ms_iocb_entry_t));
  1617. if (rval != QLA_SUCCESS) {
  1618. /*EMPTY*/
  1619. DEBUG2_3(printk("scsi(%ld): GPSC issue IOCB "
  1620. "failed (%d).\n", vha->host_no, rval));
  1621. } else if ((rval = qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
  1622. "GPSC")) != QLA_SUCCESS) {
  1623. /* FM command unsupported? */
  1624. if (rval == QLA_INVALID_COMMAND &&
  1625. (ct_rsp->header.reason_code ==
  1626. CT_REASON_INVALID_COMMAND_CODE ||
  1627. ct_rsp->header.reason_code ==
  1628. CT_REASON_COMMAND_UNSUPPORTED)) {
  1629. DEBUG2(printk("scsi(%ld): GPSC command "
  1630. "unsupported, disabling query...\n",
  1631. vha->host_no));
  1632. ha->flags.gpsc_supported = 0;
  1633. rval = QLA_FUNCTION_FAILED;
  1634. break;
  1635. }
  1636. rval = QLA_FUNCTION_FAILED;
  1637. } else {
  1638. /* Save port-speed */
  1639. switch (be16_to_cpu(ct_rsp->rsp.gpsc.speed)) {
  1640. case BIT_15:
  1641. list[i].fp_speed = PORT_SPEED_1GB;
  1642. break;
  1643. case BIT_14:
  1644. list[i].fp_speed = PORT_SPEED_2GB;
  1645. break;
  1646. case BIT_13:
  1647. list[i].fp_speed = PORT_SPEED_4GB;
  1648. break;
  1649. case BIT_12:
  1650. list[i].fp_speed = PORT_SPEED_10GB;
  1651. break;
  1652. case BIT_11:
  1653. list[i].fp_speed = PORT_SPEED_8GB;
  1654. break;
  1655. }
  1656. DEBUG2_3(printk("scsi(%ld): GPSC ext entry - "
  1657. "fpn %02x%02x%02x%02x%02x%02x%02x%02x speeds=%04x "
  1658. "speed=%04x.\n", vha->host_no,
  1659. list[i].fabric_port_name[0],
  1660. list[i].fabric_port_name[1],
  1661. list[i].fabric_port_name[2],
  1662. list[i].fabric_port_name[3],
  1663. list[i].fabric_port_name[4],
  1664. list[i].fabric_port_name[5],
  1665. list[i].fabric_port_name[6],
  1666. list[i].fabric_port_name[7],
  1667. be16_to_cpu(ct_rsp->rsp.gpsc.speeds),
  1668. be16_to_cpu(ct_rsp->rsp.gpsc.speed)));
  1669. }
  1670. /* Last device exit. */
  1671. if (list[i].d_id.b.rsvd_1 != 0)
  1672. break;
  1673. }
  1674. return (rval);
  1675. }
  1676. /**
  1677. * qla2x00_gff_id() - SNS Get FC-4 Features (GFF_ID) query.
  1678. *
  1679. * @ha: HA context
  1680. * @list: switch info entries to populate
  1681. *
  1682. */
  1683. void
  1684. qla2x00_gff_id(scsi_qla_host_t *vha, sw_info_t *list)
  1685. {
  1686. int rval;
  1687. uint16_t i;
  1688. ms_iocb_entry_t *ms_pkt;
  1689. struct ct_sns_req *ct_req;
  1690. struct ct_sns_rsp *ct_rsp;
  1691. struct qla_hw_data *ha = vha->hw;
  1692. uint8_t fcp_scsi_features = 0;
  1693. for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
  1694. /* Set default FC4 Type as UNKNOWN so the default is to
  1695. * Process this port */
  1696. list[i].fc4_type = FC4_TYPE_UNKNOWN;
  1697. /* Do not attempt GFF_ID if we are not FWI_2 capable */
  1698. if (!IS_FWI2_CAPABLE(ha))
  1699. continue;
  1700. /* Prepare common MS IOCB */
  1701. ms_pkt = ha->isp_ops->prep_ms_iocb(vha, GFF_ID_REQ_SIZE,
  1702. GFF_ID_RSP_SIZE);
  1703. /* Prepare CT request */
  1704. ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFF_ID_CMD,
  1705. GFF_ID_RSP_SIZE);
  1706. ct_rsp = &ha->ct_sns->p.rsp;
  1707. /* Prepare CT arguments -- port_id */
  1708. ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
  1709. ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
  1710. ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
  1711. /* Execute MS IOCB */
  1712. rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
  1713. sizeof(ms_iocb_entry_t));
  1714. if (rval != QLA_SUCCESS) {
  1715. DEBUG2_3(printk(KERN_INFO
  1716. "scsi(%ld): GFF_ID issue IOCB failed "
  1717. "(%d).\n", vha->host_no, rval));
  1718. } else if (qla2x00_chk_ms_status(vha, ms_pkt, ct_rsp,
  1719. "GFF_ID") != QLA_SUCCESS) {
  1720. DEBUG2_3(printk(KERN_INFO
  1721. "scsi(%ld): GFF_ID IOCB status had a "
  1722. "failure status code\n", vha->host_no));
  1723. } else {
  1724. fcp_scsi_features =
  1725. ct_rsp->rsp.gff_id.fc4_features[GFF_FCP_SCSI_OFFSET];
  1726. fcp_scsi_features &= 0x0f;
  1727. if (fcp_scsi_features)
  1728. list[i].fc4_type = FC4_TYPE_FCP_SCSI;
  1729. else
  1730. list[i].fc4_type = FC4_TYPE_OTHER;
  1731. }
  1732. /* Last device exit. */
  1733. if (list[i].d_id.b.rsvd_1 != 0)
  1734. break;
  1735. }
  1736. }