be_cmds.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. /**
  2. * Copyright (C) 2005 - 2012 Emulex
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation. The full GNU General
  8. * Public License is included in this distribution in the file called COPYING.
  9. *
  10. * Contact Information:
  11. * linux-drivers@emulex.com
  12. *
  13. * Emulex
  14. * 3333 Susan Street
  15. * Costa Mesa, CA 92626
  16. */
  17. #include <scsi/iscsi_proto.h>
  18. #include "be.h"
  19. #include "be_mgmt.h"
  20. #include "be_main.h"
  21. int beiscsi_pci_soft_reset(struct beiscsi_hba *phba)
  22. {
  23. u32 sreset;
  24. u8 *pci_reset_offset = 0;
  25. u8 *pci_online0_offset = 0;
  26. u8 *pci_online1_offset = 0;
  27. u32 pconline0 = 0;
  28. u32 pconline1 = 0;
  29. u32 i;
  30. pci_reset_offset = (u8 *)phba->pci_va + BE2_SOFT_RESET;
  31. pci_online0_offset = (u8 *)phba->pci_va + BE2_PCI_ONLINE0;
  32. pci_online1_offset = (u8 *)phba->pci_va + BE2_PCI_ONLINE1;
  33. sreset = readl((void *)pci_reset_offset);
  34. sreset |= BE2_SET_RESET;
  35. writel(sreset, (void *)pci_reset_offset);
  36. i = 0;
  37. while (sreset & BE2_SET_RESET) {
  38. if (i > 64)
  39. break;
  40. msleep(100);
  41. sreset = readl((void *)pci_reset_offset);
  42. i++;
  43. }
  44. if (sreset & BE2_SET_RESET) {
  45. printk(KERN_ERR DRV_NAME
  46. " Soft Reset did not deassert\n");
  47. return -EIO;
  48. }
  49. pconline1 = BE2_MPU_IRAM_ONLINE;
  50. writel(pconline0, (void *)pci_online0_offset);
  51. writel(pconline1, (void *)pci_online1_offset);
  52. sreset |= BE2_SET_RESET;
  53. writel(sreset, (void *)pci_reset_offset);
  54. i = 0;
  55. while (sreset & BE2_SET_RESET) {
  56. if (i > 64)
  57. break;
  58. msleep(1);
  59. sreset = readl((void *)pci_reset_offset);
  60. i++;
  61. }
  62. if (sreset & BE2_SET_RESET) {
  63. printk(KERN_ERR DRV_NAME
  64. " MPU Online Soft Reset did not deassert\n");
  65. return -EIO;
  66. }
  67. return 0;
  68. }
  69. int be_chk_reset_complete(struct beiscsi_hba *phba)
  70. {
  71. unsigned int num_loop;
  72. u8 *mpu_sem = 0;
  73. u32 status;
  74. num_loop = 1000;
  75. mpu_sem = (u8 *)phba->csr_va + MPU_EP_SEMAPHORE;
  76. msleep(5000);
  77. while (num_loop) {
  78. status = readl((void *)mpu_sem);
  79. if ((status & 0x80000000) || (status & 0x0000FFFF) == 0xC000)
  80. break;
  81. msleep(60);
  82. num_loop--;
  83. }
  84. if ((status & 0x80000000) || (!num_loop)) {
  85. beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
  86. "BC_%d : Failed in be_chk_reset_complete"
  87. "status = 0x%x\n", status);
  88. return -EIO;
  89. }
  90. return 0;
  91. }
  92. void be_mcc_notify(struct beiscsi_hba *phba)
  93. {
  94. struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
  95. u32 val = 0;
  96. val |= mccq->id & DB_MCCQ_RING_ID_MASK;
  97. val |= 1 << DB_MCCQ_NUM_POSTED_SHIFT;
  98. iowrite32(val, phba->db_va + DB_MCCQ_OFFSET);
  99. }
  100. unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
  101. {
  102. unsigned int tag = 0;
  103. if (phba->ctrl.mcc_tag_available) {
  104. tag = phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index];
  105. phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index] = 0;
  106. phba->ctrl.mcc_numtag[tag] = 0;
  107. }
  108. if (tag) {
  109. phba->ctrl.mcc_tag_available--;
  110. if (phba->ctrl.mcc_alloc_index == (MAX_MCC_CMD - 1))
  111. phba->ctrl.mcc_alloc_index = 0;
  112. else
  113. phba->ctrl.mcc_alloc_index++;
  114. }
  115. return tag;
  116. }
  117. /*
  118. * beiscsi_mccq_compl()- Wait for completion of MBX
  119. * @phba: Driver private structure
  120. * @tag: Tag for the MBX Command
  121. * @wrb: the WRB used for the MBX Command
  122. * @cmd_hdr: IOCTL Hdr for the MBX Cmd
  123. *
  124. * Waits for MBX completion with the passed TAG.
  125. *
  126. * return
  127. * Success: 0
  128. * Failure: Non-Zero
  129. **/
  130. int beiscsi_mccq_compl(struct beiscsi_hba *phba,
  131. uint32_t tag, struct be_mcc_wrb **wrb,
  132. void *cmd_hdr)
  133. {
  134. int rc = 0;
  135. uint32_t mcc_tag_response;
  136. uint16_t status = 0, addl_status = 0, wrb_num = 0;
  137. struct be_mcc_wrb *temp_wrb;
  138. struct be_cmd_req_hdr *ioctl_hdr;
  139. struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
  140. if (beiscsi_error(phba))
  141. return -EIO;
  142. /* wait for the mccq completion */
  143. rc = wait_event_interruptible_timeout(
  144. phba->ctrl.mcc_wait[tag],
  145. phba->ctrl.mcc_numtag[tag],
  146. msecs_to_jiffies(
  147. BEISCSI_HOST_MBX_TIMEOUT));
  148. if (rc <= 0) {
  149. beiscsi_log(phba, KERN_ERR,
  150. BEISCSI_LOG_INIT | BEISCSI_LOG_EH |
  151. BEISCSI_LOG_CONFIG,
  152. "BC_%d : MBX Cmd Completion timed out\n");
  153. rc = -EAGAIN;
  154. goto release_mcc_tag;
  155. } else
  156. rc = 0;
  157. mcc_tag_response = phba->ctrl.mcc_numtag[tag];
  158. status = (mcc_tag_response & CQE_STATUS_MASK);
  159. addl_status = ((mcc_tag_response & CQE_STATUS_ADDL_MASK) >>
  160. CQE_STATUS_ADDL_SHIFT);
  161. if (cmd_hdr) {
  162. ioctl_hdr = (struct be_cmd_req_hdr *)cmd_hdr;
  163. } else {
  164. wrb_num = (mcc_tag_response & CQE_STATUS_WRB_MASK) >>
  165. CQE_STATUS_WRB_SHIFT;
  166. temp_wrb = (struct be_mcc_wrb *)queue_get_wrb(mccq, wrb_num);
  167. ioctl_hdr = embedded_payload(temp_wrb);
  168. if (wrb)
  169. *wrb = temp_wrb;
  170. }
  171. if (status || addl_status) {
  172. beiscsi_log(phba, KERN_ERR,
  173. BEISCSI_LOG_INIT | BEISCSI_LOG_EH |
  174. BEISCSI_LOG_CONFIG,
  175. "BC_%d : MBX Cmd Failed for "
  176. "Subsys : %d Opcode : %d with "
  177. "Status : %d and Extd_Status : %d\n",
  178. ioctl_hdr->subsystem,
  179. ioctl_hdr->opcode,
  180. status, addl_status);
  181. rc = -EAGAIN;
  182. }
  183. release_mcc_tag:
  184. /* Release the MCC entry */
  185. free_mcc_tag(&phba->ctrl, tag);
  186. return rc;
  187. }
  188. void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag)
  189. {
  190. spin_lock(&ctrl->mbox_lock);
  191. tag = tag & 0x000000FF;
  192. ctrl->mcc_tag[ctrl->mcc_free_index] = tag;
  193. if (ctrl->mcc_free_index == (MAX_MCC_CMD - 1))
  194. ctrl->mcc_free_index = 0;
  195. else
  196. ctrl->mcc_free_index++;
  197. ctrl->mcc_tag_available++;
  198. spin_unlock(&ctrl->mbox_lock);
  199. }
  200. bool is_link_state_evt(u32 trailer)
  201. {
  202. return (((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) &
  203. ASYNC_TRAILER_EVENT_CODE_MASK) ==
  204. ASYNC_EVENT_CODE_LINK_STATE);
  205. }
  206. static inline bool be_mcc_compl_is_new(struct be_mcc_compl *compl)
  207. {
  208. if (compl->flags != 0) {
  209. compl->flags = le32_to_cpu(compl->flags);
  210. WARN_ON((compl->flags & CQE_FLAGS_VALID_MASK) == 0);
  211. return true;
  212. } else
  213. return false;
  214. }
  215. static inline void be_mcc_compl_use(struct be_mcc_compl *compl)
  216. {
  217. compl->flags = 0;
  218. }
  219. /*
  220. * be_mcc_compl_process()- Check the MBX comapletion status
  221. * @ctrl: Function specific MBX data structure
  222. * @compl: Completion status of MBX Command
  223. *
  224. * Check for the MBX completion status when BMBX method used
  225. *
  226. * return
  227. * Success: Zero
  228. * Failure: Non-Zero
  229. **/
  230. static int be_mcc_compl_process(struct be_ctrl_info *ctrl,
  231. struct be_mcc_compl *compl)
  232. {
  233. u16 compl_status, extd_status;
  234. struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
  235. struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
  236. struct be_cmd_req_hdr *hdr = embedded_payload(wrb);
  237. be_dws_le_to_cpu(compl, 4);
  238. compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) &
  239. CQE_STATUS_COMPL_MASK;
  240. if (compl_status != MCC_STATUS_SUCCESS) {
  241. extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) &
  242. CQE_STATUS_EXTD_MASK;
  243. beiscsi_log(phba, KERN_ERR,
  244. BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
  245. "BC_%d : error in cmd completion: "
  246. "Subsystem : %d Opcode : %d "
  247. "status(compl/extd)=%d/%d\n",
  248. hdr->subsystem, hdr->opcode,
  249. compl_status, extd_status);
  250. return -EBUSY;
  251. }
  252. return 0;
  253. }
  254. int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
  255. struct be_mcc_compl *compl)
  256. {
  257. u16 compl_status, extd_status;
  258. unsigned short tag;
  259. be_dws_le_to_cpu(compl, 4);
  260. compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) &
  261. CQE_STATUS_COMPL_MASK;
  262. /* The ctrl.mcc_numtag[tag] is filled with
  263. * [31] = valid, [30:24] = Rsvd, [23:16] = wrb, [15:8] = extd_status,
  264. * [7:0] = compl_status
  265. */
  266. tag = (compl->tag0 & 0x000000FF);
  267. extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) &
  268. CQE_STATUS_EXTD_MASK;
  269. ctrl->mcc_numtag[tag] = 0x80000000;
  270. ctrl->mcc_numtag[tag] |= (compl->tag0 & 0x00FF0000);
  271. ctrl->mcc_numtag[tag] |= (extd_status & 0x000000FF) << 8;
  272. ctrl->mcc_numtag[tag] |= (compl_status & 0x000000FF);
  273. wake_up_interruptible(&ctrl->mcc_wait[tag]);
  274. return 0;
  275. }
  276. static struct be_mcc_compl *be_mcc_compl_get(struct beiscsi_hba *phba)
  277. {
  278. struct be_queue_info *mcc_cq = &phba->ctrl.mcc_obj.cq;
  279. struct be_mcc_compl *compl = queue_tail_node(mcc_cq);
  280. if (be_mcc_compl_is_new(compl)) {
  281. queue_tail_inc(mcc_cq);
  282. return compl;
  283. }
  284. return NULL;
  285. }
  286. static void be2iscsi_fail_session(struct iscsi_cls_session *cls_session)
  287. {
  288. iscsi_session_failure(cls_session->dd_data, ISCSI_ERR_CONN_FAILED);
  289. }
  290. void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
  291. struct be_async_event_link_state *evt)
  292. {
  293. switch (evt->port_link_status) {
  294. case ASYNC_EVENT_LINK_DOWN:
  295. beiscsi_log(phba, KERN_ERR,
  296. BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT,
  297. "BC_%d : Link Down on Physical Port %d\n",
  298. evt->physical_port);
  299. phba->state |= BE_ADAPTER_LINK_DOWN;
  300. iscsi_host_for_each_session(phba->shost,
  301. be2iscsi_fail_session);
  302. break;
  303. case ASYNC_EVENT_LINK_UP:
  304. phba->state = BE_ADAPTER_UP;
  305. beiscsi_log(phba, KERN_ERR,
  306. BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT,
  307. "BC_%d : Link UP on Physical Port %d\n",
  308. evt->physical_port);
  309. break;
  310. default:
  311. beiscsi_log(phba, KERN_ERR,
  312. BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT,
  313. "BC_%d : Unexpected Async Notification %d on"
  314. "Physical Port %d\n",
  315. evt->port_link_status,
  316. evt->physical_port);
  317. }
  318. }
  319. static void beiscsi_cq_notify(struct beiscsi_hba *phba, u16 qid, bool arm,
  320. u16 num_popped)
  321. {
  322. u32 val = 0;
  323. val |= qid & DB_CQ_RING_ID_MASK;
  324. if (arm)
  325. val |= 1 << DB_CQ_REARM_SHIFT;
  326. val |= num_popped << DB_CQ_NUM_POPPED_SHIFT;
  327. iowrite32(val, phba->db_va + DB_CQ_OFFSET);
  328. }
  329. int beiscsi_process_mcc(struct beiscsi_hba *phba)
  330. {
  331. struct be_mcc_compl *compl;
  332. int num = 0, status = 0;
  333. struct be_ctrl_info *ctrl = &phba->ctrl;
  334. spin_lock_bh(&phba->ctrl.mcc_cq_lock);
  335. while ((compl = be_mcc_compl_get(phba))) {
  336. if (compl->flags & CQE_FLAGS_ASYNC_MASK) {
  337. /* Interpret flags as an async trailer */
  338. if (is_link_state_evt(compl->flags))
  339. /* Interpret compl as a async link evt */
  340. beiscsi_async_link_state_process(phba,
  341. (struct be_async_event_link_state *) compl);
  342. else
  343. beiscsi_log(phba, KERN_ERR,
  344. BEISCSI_LOG_CONFIG |
  345. BEISCSI_LOG_MBOX,
  346. "BC_%d : Unsupported Async Event, flags"
  347. " = 0x%08x\n", compl->flags);
  348. } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) {
  349. status = be_mcc_compl_process(ctrl, compl);
  350. atomic_dec(&phba->ctrl.mcc_obj.q.used);
  351. }
  352. be_mcc_compl_use(compl);
  353. num++;
  354. }
  355. if (num)
  356. beiscsi_cq_notify(phba, phba->ctrl.mcc_obj.cq.id, true, num);
  357. spin_unlock_bh(&phba->ctrl.mcc_cq_lock);
  358. return status;
  359. }
  360. /*
  361. * be_mcc_wait_compl()- Wait for MBX completion
  362. * @phba: driver private structure
  363. *
  364. * Wait till no more pending mcc requests are present
  365. *
  366. * return
  367. * Success: 0
  368. * Failure: Non-Zero
  369. *
  370. **/
  371. static int be_mcc_wait_compl(struct beiscsi_hba *phba)
  372. {
  373. int i, status;
  374. for (i = 0; i < mcc_timeout; i++) {
  375. if (beiscsi_error(phba))
  376. return -EIO;
  377. status = beiscsi_process_mcc(phba);
  378. if (status)
  379. return status;
  380. if (atomic_read(&phba->ctrl.mcc_obj.q.used) == 0)
  381. break;
  382. udelay(100);
  383. }
  384. if (i == mcc_timeout) {
  385. beiscsi_log(phba, KERN_ERR,
  386. BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
  387. "BC_%d : FW Timed Out\n");
  388. phba->fw_timeout = true;
  389. beiscsi_ue_detect(phba);
  390. return -EBUSY;
  391. }
  392. return 0;
  393. }
  394. /*
  395. * be_mcc_notify_wait()- Notify and wait for Compl
  396. * @phba: driver private structure
  397. *
  398. * Notify MCC requests and wait for completion
  399. *
  400. * return
  401. * Success: 0
  402. * Failure: Non-Zero
  403. **/
  404. int be_mcc_notify_wait(struct beiscsi_hba *phba)
  405. {
  406. be_mcc_notify(phba);
  407. return be_mcc_wait_compl(phba);
  408. }
  409. /*
  410. * be_mbox_db_ready_wait()- Check ready status
  411. * @ctrl: Function specific MBX data structure
  412. *
  413. * Check for the ready status of FW to send BMBX
  414. * commands to adapter.
  415. *
  416. * return
  417. * Success: 0
  418. * Failure: Non-Zero
  419. **/
  420. static int be_mbox_db_ready_wait(struct be_ctrl_info *ctrl)
  421. {
  422. void __iomem *db = ctrl->db + MPU_MAILBOX_DB_OFFSET;
  423. struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
  424. int wait = 0;
  425. u32 ready;
  426. do {
  427. if (beiscsi_error(phba))
  428. return -EIO;
  429. ready = ioread32(db) & MPU_MAILBOX_DB_RDY_MASK;
  430. if (ready)
  431. break;
  432. if (wait > BEISCSI_HOST_MBX_TIMEOUT) {
  433. beiscsi_log(phba, KERN_ERR,
  434. BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
  435. "BC_%d : FW Timed Out\n");
  436. phba->fw_timeout = true;
  437. beiscsi_ue_detect(phba);
  438. return -EBUSY;
  439. }
  440. mdelay(1);
  441. wait++;
  442. } while (true);
  443. return 0;
  444. }
  445. /*
  446. * be_mbox_notify: Notify adapter of new BMBX command
  447. * @ctrl: Function specific MBX data structure
  448. *
  449. * Ring doorbell to inform adapter of a BMBX command
  450. * to process
  451. *
  452. * return
  453. * Success: 0
  454. * Failure: Non-Zero
  455. **/
  456. int be_mbox_notify(struct be_ctrl_info *ctrl)
  457. {
  458. int status;
  459. u32 val = 0;
  460. void __iomem *db = ctrl->db + MPU_MAILBOX_DB_OFFSET;
  461. struct be_dma_mem *mbox_mem = &ctrl->mbox_mem;
  462. struct be_mcc_mailbox *mbox = mbox_mem->va;
  463. struct be_mcc_compl *compl = &mbox->compl;
  464. struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
  465. val &= ~MPU_MAILBOX_DB_RDY_MASK;
  466. val |= MPU_MAILBOX_DB_HI_MASK;
  467. val |= (upper_32_bits(mbox_mem->dma) >> 2) << 2;
  468. iowrite32(val, db);
  469. status = be_mbox_db_ready_wait(ctrl);
  470. if (status)
  471. return status;
  472. val = 0;
  473. val &= ~MPU_MAILBOX_DB_RDY_MASK;
  474. val &= ~MPU_MAILBOX_DB_HI_MASK;
  475. val |= (u32) (mbox_mem->dma >> 4) << 2;
  476. iowrite32(val, db);
  477. status = be_mbox_db_ready_wait(ctrl);
  478. if (status)
  479. return status;
  480. if (be_mcc_compl_is_new(compl)) {
  481. status = be_mcc_compl_process(ctrl, &mbox->compl);
  482. be_mcc_compl_use(compl);
  483. if (status) {
  484. beiscsi_log(phba, KERN_ERR,
  485. BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
  486. "BC_%d : After be_mcc_compl_process\n");
  487. return status;
  488. }
  489. } else {
  490. beiscsi_log(phba, KERN_ERR,
  491. BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
  492. "BC_%d : Invalid Mailbox Completion\n");
  493. return -EBUSY;
  494. }
  495. return 0;
  496. }
  497. /*
  498. * Insert the mailbox address into the doorbell in two steps
  499. * Polls on the mbox doorbell till a command completion (or a timeout) occurs
  500. */
  501. static int be_mbox_notify_wait(struct beiscsi_hba *phba)
  502. {
  503. int status;
  504. u32 val = 0;
  505. void __iomem *db = phba->ctrl.db + MPU_MAILBOX_DB_OFFSET;
  506. struct be_dma_mem *mbox_mem = &phba->ctrl.mbox_mem;
  507. struct be_mcc_mailbox *mbox = mbox_mem->va;
  508. struct be_mcc_compl *compl = &mbox->compl;
  509. struct be_ctrl_info *ctrl = &phba->ctrl;
  510. val |= MPU_MAILBOX_DB_HI_MASK;
  511. /* at bits 2 - 31 place mbox dma addr msb bits 34 - 63 */
  512. val |= (upper_32_bits(mbox_mem->dma) >> 2) << 2;
  513. iowrite32(val, db);
  514. /* wait for ready to be set */
  515. status = be_mbox_db_ready_wait(ctrl);
  516. if (status != 0)
  517. return status;
  518. val = 0;
  519. /* at bits 2 - 31 place mbox dma addr lsb bits 4 - 33 */
  520. val |= (u32)(mbox_mem->dma >> 4) << 2;
  521. iowrite32(val, db);
  522. status = be_mbox_db_ready_wait(ctrl);
  523. if (status != 0)
  524. return status;
  525. /* A cq entry has been made now */
  526. if (be_mcc_compl_is_new(compl)) {
  527. status = be_mcc_compl_process(ctrl, &mbox->compl);
  528. be_mcc_compl_use(compl);
  529. if (status)
  530. return status;
  531. } else {
  532. beiscsi_log(phba, KERN_ERR,
  533. BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
  534. "BC_%d : invalid mailbox completion\n");
  535. return -EBUSY;
  536. }
  537. return 0;
  538. }
  539. void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
  540. bool embedded, u8 sge_cnt)
  541. {
  542. if (embedded)
  543. wrb->embedded |= MCC_WRB_EMBEDDED_MASK;
  544. else
  545. wrb->embedded |= (sge_cnt & MCC_WRB_SGE_CNT_MASK) <<
  546. MCC_WRB_SGE_CNT_SHIFT;
  547. wrb->payload_length = payload_len;
  548. be_dws_cpu_to_le(wrb, 8);
  549. }
  550. void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
  551. u8 subsystem, u8 opcode, int cmd_len)
  552. {
  553. req_hdr->opcode = opcode;
  554. req_hdr->subsystem = subsystem;
  555. req_hdr->request_length = cpu_to_le32(cmd_len - sizeof(*req_hdr));
  556. req_hdr->timeout = BEISCSI_FW_MBX_TIMEOUT;
  557. }
  558. static void be_cmd_page_addrs_prepare(struct phys_addr *pages, u32 max_pages,
  559. struct be_dma_mem *mem)
  560. {
  561. int i, buf_pages;
  562. u64 dma = (u64) mem->dma;
  563. buf_pages = min(PAGES_4K_SPANNED(mem->va, mem->size), max_pages);
  564. for (i = 0; i < buf_pages; i++) {
  565. pages[i].lo = cpu_to_le32(dma & 0xFFFFFFFF);
  566. pages[i].hi = cpu_to_le32(upper_32_bits(dma));
  567. dma += PAGE_SIZE_4K;
  568. }
  569. }
  570. static u32 eq_delay_to_mult(u32 usec_delay)
  571. {
  572. #define MAX_INTR_RATE 651042
  573. const u32 round = 10;
  574. u32 multiplier;
  575. if (usec_delay == 0)
  576. multiplier = 0;
  577. else {
  578. u32 interrupt_rate = 1000000 / usec_delay;
  579. if (interrupt_rate == 0)
  580. multiplier = 1023;
  581. else {
  582. multiplier = (MAX_INTR_RATE - interrupt_rate) * round;
  583. multiplier /= interrupt_rate;
  584. multiplier = (multiplier + round / 2) / round;
  585. multiplier = min(multiplier, (u32) 1023);
  586. }
  587. }
  588. return multiplier;
  589. }
  590. struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem)
  591. {
  592. return &((struct be_mcc_mailbox *)(mbox_mem->va))->wrb;
  593. }
  594. struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba)
  595. {
  596. struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
  597. struct be_mcc_wrb *wrb;
  598. BUG_ON(atomic_read(&mccq->used) >= mccq->len);
  599. wrb = queue_head_node(mccq);
  600. memset(wrb, 0, sizeof(*wrb));
  601. wrb->tag0 = (mccq->head & 0x000000FF) << 16;
  602. queue_head_inc(mccq);
  603. atomic_inc(&mccq->used);
  604. return wrb;
  605. }
  606. int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
  607. struct be_queue_info *eq, int eq_delay)
  608. {
  609. struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
  610. struct be_cmd_req_eq_create *req = embedded_payload(wrb);
  611. struct be_cmd_resp_eq_create *resp = embedded_payload(wrb);
  612. struct be_dma_mem *q_mem = &eq->dma_mem;
  613. int status;
  614. spin_lock(&ctrl->mbox_lock);
  615. memset(wrb, 0, sizeof(*wrb));
  616. be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
  617. be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
  618. OPCODE_COMMON_EQ_CREATE, sizeof(*req));
  619. req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size));
  620. AMAP_SET_BITS(struct amap_eq_context, func, req->context,
  621. PCI_FUNC(ctrl->pdev->devfn));
  622. AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1);
  623. AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0);
  624. AMAP_SET_BITS(struct amap_eq_context, count, req->context,
  625. __ilog2_u32(eq->len / 256));
  626. AMAP_SET_BITS(struct amap_eq_context, delaymult, req->context,
  627. eq_delay_to_mult(eq_delay));
  628. be_dws_cpu_to_le(req->context, sizeof(req->context));
  629. be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
  630. status = be_mbox_notify(ctrl);
  631. if (!status) {
  632. eq->id = le16_to_cpu(resp->eq_id);
  633. eq->created = true;
  634. }
  635. spin_unlock(&ctrl->mbox_lock);
  636. return status;
  637. }
  638. int be_cmd_fw_initialize(struct be_ctrl_info *ctrl)
  639. {
  640. struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
  641. struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
  642. int status;
  643. u8 *endian_check;
  644. spin_lock(&ctrl->mbox_lock);
  645. memset(wrb, 0, sizeof(*wrb));
  646. endian_check = (u8 *) wrb;
  647. *endian_check++ = 0xFF;
  648. *endian_check++ = 0x12;
  649. *endian_check++ = 0x34;
  650. *endian_check++ = 0xFF;
  651. *endian_check++ = 0xFF;
  652. *endian_check++ = 0x56;
  653. *endian_check++ = 0x78;
  654. *endian_check++ = 0xFF;
  655. be_dws_cpu_to_le(wrb, sizeof(*wrb));
  656. status = be_mbox_notify(ctrl);
  657. if (status)
  658. beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
  659. "BC_%d : be_cmd_fw_initialize Failed\n");
  660. spin_unlock(&ctrl->mbox_lock);
  661. return status;
  662. }
  663. int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
  664. struct be_queue_info *cq, struct be_queue_info *eq,
  665. bool sol_evts, bool no_delay, int coalesce_wm)
  666. {
  667. struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
  668. struct be_cmd_req_cq_create *req = embedded_payload(wrb);
  669. struct be_cmd_resp_cq_create *resp = embedded_payload(wrb);
  670. struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
  671. struct be_dma_mem *q_mem = &cq->dma_mem;
  672. void *ctxt = &req->context;
  673. int status;
  674. spin_lock(&ctrl->mbox_lock);
  675. memset(wrb, 0, sizeof(*wrb));
  676. be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
  677. be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
  678. OPCODE_COMMON_CQ_CREATE, sizeof(*req));
  679. req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size));
  680. if (chip_skh_r(ctrl->pdev)) {
  681. req->hdr.version = MBX_CMD_VER2;
  682. req->page_size = 1;
  683. AMAP_SET_BITS(struct amap_cq_context_v2, coalescwm,
  684. ctxt, coalesce_wm);
  685. AMAP_SET_BITS(struct amap_cq_context_v2, nodelay,
  686. ctxt, no_delay);
  687. AMAP_SET_BITS(struct amap_cq_context_v2, count, ctxt,
  688. __ilog2_u32(cq->len / 256));
  689. AMAP_SET_BITS(struct amap_cq_context_v2, valid, ctxt, 1);
  690. AMAP_SET_BITS(struct amap_cq_context_v2, eventable, ctxt, 1);
  691. AMAP_SET_BITS(struct amap_cq_context_v2, eqid, ctxt, eq->id);
  692. AMAP_SET_BITS(struct amap_cq_context_v2, armed, ctxt, 1);
  693. } else {
  694. AMAP_SET_BITS(struct amap_cq_context, coalescwm,
  695. ctxt, coalesce_wm);
  696. AMAP_SET_BITS(struct amap_cq_context, nodelay, ctxt, no_delay);
  697. AMAP_SET_BITS(struct amap_cq_context, count, ctxt,
  698. __ilog2_u32(cq->len / 256));
  699. AMAP_SET_BITS(struct amap_cq_context, valid, ctxt, 1);
  700. AMAP_SET_BITS(struct amap_cq_context, solevent, ctxt, sol_evts);
  701. AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1);
  702. AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id);
  703. AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1);
  704. AMAP_SET_BITS(struct amap_cq_context, func, ctxt,
  705. PCI_FUNC(ctrl->pdev->devfn));
  706. }
  707. be_dws_cpu_to_le(ctxt, sizeof(req->context));
  708. be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
  709. status = be_mbox_notify(ctrl);
  710. if (!status) {
  711. cq->id = le16_to_cpu(resp->cq_id);
  712. cq->created = true;
  713. } else
  714. beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
  715. "BC_%d : In be_cmd_cq_create, status=ox%08x\n",
  716. status);
  717. spin_unlock(&ctrl->mbox_lock);
  718. return status;
  719. }
  720. static u32 be_encoded_q_len(int q_len)
  721. {
  722. u32 len_encoded = fls(q_len); /* log2(len) + 1 */
  723. if (len_encoded == 16)
  724. len_encoded = 0;
  725. return len_encoded;
  726. }
  727. int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
  728. struct be_queue_info *mccq,
  729. struct be_queue_info *cq)
  730. {
  731. struct be_mcc_wrb *wrb;
  732. struct be_cmd_req_mcc_create *req;
  733. struct be_dma_mem *q_mem = &mccq->dma_mem;
  734. struct be_ctrl_info *ctrl;
  735. void *ctxt;
  736. int status;
  737. spin_lock(&phba->ctrl.mbox_lock);
  738. ctrl = &phba->ctrl;
  739. wrb = wrb_from_mbox(&ctrl->mbox_mem);
  740. memset(wrb, 0, sizeof(*wrb));
  741. req = embedded_payload(wrb);
  742. ctxt = &req->context;
  743. be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
  744. be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
  745. OPCODE_COMMON_MCC_CREATE, sizeof(*req));
  746. req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size);
  747. AMAP_SET_BITS(struct amap_mcc_context, fid, ctxt,
  748. PCI_FUNC(phba->pcidev->devfn));
  749. AMAP_SET_BITS(struct amap_mcc_context, valid, ctxt, 1);
  750. AMAP_SET_BITS(struct amap_mcc_context, ring_size, ctxt,
  751. be_encoded_q_len(mccq->len));
  752. AMAP_SET_BITS(struct amap_mcc_context, cq_id, ctxt, cq->id);
  753. be_dws_cpu_to_le(ctxt, sizeof(req->context));
  754. be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
  755. status = be_mbox_notify_wait(phba);
  756. if (!status) {
  757. struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb);
  758. mccq->id = le16_to_cpu(resp->id);
  759. mccq->created = true;
  760. }
  761. spin_unlock(&phba->ctrl.mbox_lock);
  762. return status;
  763. }
  764. int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
  765. int queue_type)
  766. {
  767. struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
  768. struct be_cmd_req_q_destroy *req = embedded_payload(wrb);
  769. struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
  770. u8 subsys = 0, opcode = 0;
  771. int status;
  772. beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
  773. "BC_%d : In beiscsi_cmd_q_destroy "
  774. "queue_type : %d\n", queue_type);
  775. spin_lock(&ctrl->mbox_lock);
  776. memset(wrb, 0, sizeof(*wrb));
  777. be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
  778. switch (queue_type) {
  779. case QTYPE_EQ:
  780. subsys = CMD_SUBSYSTEM_COMMON;
  781. opcode = OPCODE_COMMON_EQ_DESTROY;
  782. break;
  783. case QTYPE_CQ:
  784. subsys = CMD_SUBSYSTEM_COMMON;
  785. opcode = OPCODE_COMMON_CQ_DESTROY;
  786. break;
  787. case QTYPE_MCCQ:
  788. subsys = CMD_SUBSYSTEM_COMMON;
  789. opcode = OPCODE_COMMON_MCC_DESTROY;
  790. break;
  791. case QTYPE_WRBQ:
  792. subsys = CMD_SUBSYSTEM_ISCSI;
  793. opcode = OPCODE_COMMON_ISCSI_WRBQ_DESTROY;
  794. break;
  795. case QTYPE_DPDUQ:
  796. subsys = CMD_SUBSYSTEM_ISCSI;
  797. opcode = OPCODE_COMMON_ISCSI_DEFQ_DESTROY;
  798. break;
  799. case QTYPE_SGL:
  800. subsys = CMD_SUBSYSTEM_ISCSI;
  801. opcode = OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES;
  802. break;
  803. default:
  804. spin_unlock(&ctrl->mbox_lock);
  805. BUG();
  806. return -ENXIO;
  807. }
  808. be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req));
  809. if (queue_type != QTYPE_SGL)
  810. req->id = cpu_to_le16(q->id);
  811. status = be_mbox_notify(ctrl);
  812. spin_unlock(&ctrl->mbox_lock);
  813. return status;
  814. }
  815. int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
  816. struct be_queue_info *cq,
  817. struct be_queue_info *dq, int length,
  818. int entry_size)
  819. {
  820. struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
  821. struct be_defq_create_req *req = embedded_payload(wrb);
  822. struct be_dma_mem *q_mem = &dq->dma_mem;
  823. void *ctxt = &req->context;
  824. int status;
  825. spin_lock(&ctrl->mbox_lock);
  826. memset(wrb, 0, sizeof(*wrb));
  827. be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
  828. be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
  829. OPCODE_COMMON_ISCSI_DEFQ_CREATE, sizeof(*req));
  830. req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size);
  831. AMAP_SET_BITS(struct amap_be_default_pdu_context, rx_pdid, ctxt, 0);
  832. AMAP_SET_BITS(struct amap_be_default_pdu_context, rx_pdid_valid, ctxt,
  833. 1);
  834. AMAP_SET_BITS(struct amap_be_default_pdu_context, pci_func_id, ctxt,
  835. PCI_FUNC(ctrl->pdev->devfn));
  836. AMAP_SET_BITS(struct amap_be_default_pdu_context, ring_size, ctxt,
  837. be_encoded_q_len(length / sizeof(struct phys_addr)));
  838. AMAP_SET_BITS(struct amap_be_default_pdu_context, default_buffer_size,
  839. ctxt, entry_size);
  840. AMAP_SET_BITS(struct amap_be_default_pdu_context, cq_id_recv, ctxt,
  841. cq->id);
  842. be_dws_cpu_to_le(ctxt, sizeof(req->context));
  843. be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
  844. status = be_mbox_notify(ctrl);
  845. if (!status) {
  846. struct be_defq_create_resp *resp = embedded_payload(wrb);
  847. dq->id = le16_to_cpu(resp->id);
  848. dq->created = true;
  849. }
  850. spin_unlock(&ctrl->mbox_lock);
  851. return status;
  852. }
  853. int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
  854. struct be_queue_info *wrbq)
  855. {
  856. struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
  857. struct be_wrbq_create_req *req = embedded_payload(wrb);
  858. struct be_wrbq_create_resp *resp = embedded_payload(wrb);
  859. int status;
  860. spin_lock(&ctrl->mbox_lock);
  861. memset(wrb, 0, sizeof(*wrb));
  862. be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
  863. be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
  864. OPCODE_COMMON_ISCSI_WRBQ_CREATE, sizeof(*req));
  865. req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size);
  866. be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
  867. status = be_mbox_notify(ctrl);
  868. if (!status) {
  869. wrbq->id = le16_to_cpu(resp->cid);
  870. wrbq->created = true;
  871. }
  872. spin_unlock(&ctrl->mbox_lock);
  873. return status;
  874. }
  875. int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
  876. struct be_dma_mem *q_mem,
  877. u32 page_offset, u32 num_pages)
  878. {
  879. struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
  880. struct be_post_sgl_pages_req *req = embedded_payload(wrb);
  881. struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);
  882. int status;
  883. unsigned int curr_pages;
  884. u32 internal_page_offset = 0;
  885. u32 temp_num_pages = num_pages;
  886. if (num_pages == 0xff)
  887. num_pages = 1;
  888. spin_lock(&ctrl->mbox_lock);
  889. do {
  890. memset(wrb, 0, sizeof(*wrb));
  891. be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
  892. be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
  893. OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES,
  894. sizeof(*req));
  895. curr_pages = BE_NUMBER_OF_FIELD(struct be_post_sgl_pages_req,
  896. pages);
  897. req->num_pages = min(num_pages, curr_pages);
  898. req->page_offset = page_offset;
  899. be_cmd_page_addrs_prepare(req->pages, req->num_pages, q_mem);
  900. q_mem->dma = q_mem->dma + (req->num_pages * PAGE_SIZE);
  901. internal_page_offset += req->num_pages;
  902. page_offset += req->num_pages;
  903. num_pages -= req->num_pages;
  904. if (temp_num_pages == 0xff)
  905. req->num_pages = temp_num_pages;
  906. status = be_mbox_notify(ctrl);
  907. if (status) {
  908. beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
  909. "BC_%d : FW CMD to map iscsi frags failed.\n");
  910. goto error;
  911. }
  912. } while (num_pages > 0);
  913. error:
  914. spin_unlock(&ctrl->mbox_lock);
  915. if (status != 0)
  916. beiscsi_cmd_q_destroy(ctrl, NULL, QTYPE_SGL);
  917. return status;
  918. }
  919. int beiscsi_cmd_reset_function(struct beiscsi_hba *phba)
  920. {
  921. struct be_ctrl_info *ctrl = &phba->ctrl;
  922. struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
  923. struct be_post_sgl_pages_req *req = embedded_payload(wrb);
  924. int status;
  925. spin_lock(&ctrl->mbox_lock);
  926. req = embedded_payload(wrb);
  927. be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
  928. be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
  929. OPCODE_COMMON_FUNCTION_RESET, sizeof(*req));
  930. status = be_mbox_notify_wait(phba);
  931. spin_unlock(&ctrl->mbox_lock);
  932. return status;
  933. }
  934. /**
  935. * be_cmd_set_vlan()- Configure VLAN paramters on the adapter
  936. * @phba: device priv structure instance
  937. * @vlan_tag: TAG to be set
  938. *
  939. * Set the VLAN_TAG for the adapter or Disable VLAN on adapter
  940. *
  941. * returns
  942. * TAG for the MBX Cmd
  943. * **/
  944. int be_cmd_set_vlan(struct beiscsi_hba *phba,
  945. uint16_t vlan_tag)
  946. {
  947. unsigned int tag = 0;
  948. struct be_mcc_wrb *wrb;
  949. struct be_cmd_set_vlan_req *req;
  950. struct be_ctrl_info *ctrl = &phba->ctrl;
  951. spin_lock(&ctrl->mbox_lock);
  952. tag = alloc_mcc_tag(phba);
  953. if (!tag) {
  954. spin_unlock(&ctrl->mbox_lock);
  955. return tag;
  956. }
  957. wrb = wrb_from_mccq(phba);
  958. req = embedded_payload(wrb);
  959. wrb->tag0 |= tag;
  960. be_wrb_hdr_prepare(wrb, sizeof(*wrb), true, 0);
  961. be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
  962. OPCODE_COMMON_ISCSI_NTWK_SET_VLAN,
  963. sizeof(*req));
  964. req->interface_hndl = phba->interface_handle;
  965. req->vlan_priority = vlan_tag;
  966. be_mcc_notify(phba);
  967. spin_unlock(&ctrl->mbox_lock);
  968. return tag;
  969. }