qedi_iscsi.c 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619
  1. /*
  2. * QLogic iSCSI Offload Driver
  3. * Copyright (c) 2016 Cavium Inc.
  4. *
  5. * This software is available under the terms of the GNU General Public License
  6. * (GPL) Version 2, available from the file COPYING in the main directory of
  7. * this source tree.
  8. */
  9. #include <linux/blkdev.h>
  10. #include <linux/etherdevice.h>
  11. #include <linux/if_ether.h>
  12. #include <linux/if_vlan.h>
  13. #include <scsi/scsi_tcq.h>
  14. #include "qedi.h"
  15. #include "qedi_iscsi.h"
  16. #include "qedi_gbl.h"
  17. int qedi_recover_all_conns(struct qedi_ctx *qedi)
  18. {
  19. struct qedi_conn *qedi_conn;
  20. int i;
  21. for (i = 0; i < qedi->max_active_conns; i++) {
  22. qedi_conn = qedi_get_conn_from_id(qedi, i);
  23. if (!qedi_conn)
  24. continue;
  25. qedi_start_conn_recovery(qedi, qedi_conn);
  26. }
  27. return SUCCESS;
  28. }
  29. static int qedi_eh_host_reset(struct scsi_cmnd *cmd)
  30. {
  31. struct Scsi_Host *shost = cmd->device->host;
  32. struct qedi_ctx *qedi;
  33. qedi = iscsi_host_priv(shost);
  34. return qedi_recover_all_conns(qedi);
  35. }
  36. struct scsi_host_template qedi_host_template = {
  37. .module = THIS_MODULE,
  38. .name = "QLogic QEDI 25/40/100Gb iSCSI Initiator Driver",
  39. .proc_name = QEDI_MODULE_NAME,
  40. .queuecommand = iscsi_queuecommand,
  41. .eh_timed_out = iscsi_eh_cmd_timed_out,
  42. .eh_abort_handler = iscsi_eh_abort,
  43. .eh_device_reset_handler = iscsi_eh_device_reset,
  44. .eh_target_reset_handler = iscsi_eh_recover_target,
  45. .eh_host_reset_handler = qedi_eh_host_reset,
  46. .target_alloc = iscsi_target_alloc,
  47. .change_queue_depth = scsi_change_queue_depth,
  48. .can_queue = QEDI_MAX_ISCSI_TASK,
  49. .this_id = -1,
  50. .sg_tablesize = QEDI_ISCSI_MAX_BDS_PER_CMD,
  51. .max_sectors = 0xffff,
  52. .dma_boundary = QEDI_HW_DMA_BOUNDARY,
  53. .cmd_per_lun = 128,
  54. .use_clustering = ENABLE_CLUSTERING,
  55. .shost_attrs = qedi_shost_attrs,
  56. };
  57. static void qedi_conn_free_login_resources(struct qedi_ctx *qedi,
  58. struct qedi_conn *qedi_conn)
  59. {
  60. if (qedi_conn->gen_pdu.resp_bd_tbl) {
  61. dma_free_coherent(&qedi->pdev->dev, QEDI_PAGE_SIZE,
  62. qedi_conn->gen_pdu.resp_bd_tbl,
  63. qedi_conn->gen_pdu.resp_bd_dma);
  64. qedi_conn->gen_pdu.resp_bd_tbl = NULL;
  65. }
  66. if (qedi_conn->gen_pdu.req_bd_tbl) {
  67. dma_free_coherent(&qedi->pdev->dev, QEDI_PAGE_SIZE,
  68. qedi_conn->gen_pdu.req_bd_tbl,
  69. qedi_conn->gen_pdu.req_bd_dma);
  70. qedi_conn->gen_pdu.req_bd_tbl = NULL;
  71. }
  72. if (qedi_conn->gen_pdu.resp_buf) {
  73. dma_free_coherent(&qedi->pdev->dev,
  74. ISCSI_DEF_MAX_RECV_SEG_LEN,
  75. qedi_conn->gen_pdu.resp_buf,
  76. qedi_conn->gen_pdu.resp_dma_addr);
  77. qedi_conn->gen_pdu.resp_buf = NULL;
  78. }
  79. if (qedi_conn->gen_pdu.req_buf) {
  80. dma_free_coherent(&qedi->pdev->dev,
  81. ISCSI_DEF_MAX_RECV_SEG_LEN,
  82. qedi_conn->gen_pdu.req_buf,
  83. qedi_conn->gen_pdu.req_dma_addr);
  84. qedi_conn->gen_pdu.req_buf = NULL;
  85. }
  86. }
  87. static int qedi_conn_alloc_login_resources(struct qedi_ctx *qedi,
  88. struct qedi_conn *qedi_conn)
  89. {
  90. qedi_conn->gen_pdu.req_buf =
  91. dma_alloc_coherent(&qedi->pdev->dev,
  92. ISCSI_DEF_MAX_RECV_SEG_LEN,
  93. &qedi_conn->gen_pdu.req_dma_addr,
  94. GFP_KERNEL);
  95. if (!qedi_conn->gen_pdu.req_buf)
  96. goto login_req_buf_failure;
  97. qedi_conn->gen_pdu.req_buf_size = 0;
  98. qedi_conn->gen_pdu.req_wr_ptr = qedi_conn->gen_pdu.req_buf;
  99. qedi_conn->gen_pdu.resp_buf =
  100. dma_alloc_coherent(&qedi->pdev->dev,
  101. ISCSI_DEF_MAX_RECV_SEG_LEN,
  102. &qedi_conn->gen_pdu.resp_dma_addr,
  103. GFP_KERNEL);
  104. if (!qedi_conn->gen_pdu.resp_buf)
  105. goto login_resp_buf_failure;
  106. qedi_conn->gen_pdu.resp_buf_size = ISCSI_DEF_MAX_RECV_SEG_LEN;
  107. qedi_conn->gen_pdu.resp_wr_ptr = qedi_conn->gen_pdu.resp_buf;
  108. qedi_conn->gen_pdu.req_bd_tbl =
  109. dma_alloc_coherent(&qedi->pdev->dev, QEDI_PAGE_SIZE,
  110. &qedi_conn->gen_pdu.req_bd_dma, GFP_KERNEL);
  111. if (!qedi_conn->gen_pdu.req_bd_tbl)
  112. goto login_req_bd_tbl_failure;
  113. qedi_conn->gen_pdu.resp_bd_tbl =
  114. dma_alloc_coherent(&qedi->pdev->dev, QEDI_PAGE_SIZE,
  115. &qedi_conn->gen_pdu.resp_bd_dma,
  116. GFP_KERNEL);
  117. if (!qedi_conn->gen_pdu.resp_bd_tbl)
  118. goto login_resp_bd_tbl_failure;
  119. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SESS,
  120. "Allocation successful, cid=0x%x\n",
  121. qedi_conn->iscsi_conn_id);
  122. return 0;
  123. login_resp_bd_tbl_failure:
  124. dma_free_coherent(&qedi->pdev->dev, QEDI_PAGE_SIZE,
  125. qedi_conn->gen_pdu.req_bd_tbl,
  126. qedi_conn->gen_pdu.req_bd_dma);
  127. qedi_conn->gen_pdu.req_bd_tbl = NULL;
  128. login_req_bd_tbl_failure:
  129. dma_free_coherent(&qedi->pdev->dev, ISCSI_DEF_MAX_RECV_SEG_LEN,
  130. qedi_conn->gen_pdu.resp_buf,
  131. qedi_conn->gen_pdu.resp_dma_addr);
  132. qedi_conn->gen_pdu.resp_buf = NULL;
  133. login_resp_buf_failure:
  134. dma_free_coherent(&qedi->pdev->dev, ISCSI_DEF_MAX_RECV_SEG_LEN,
  135. qedi_conn->gen_pdu.req_buf,
  136. qedi_conn->gen_pdu.req_dma_addr);
  137. qedi_conn->gen_pdu.req_buf = NULL;
  138. login_req_buf_failure:
  139. iscsi_conn_printk(KERN_ERR, qedi_conn->cls_conn->dd_data,
  140. "login resource alloc failed!!\n");
  141. return -ENOMEM;
  142. }
  143. static void qedi_destroy_cmd_pool(struct qedi_ctx *qedi,
  144. struct iscsi_session *session)
  145. {
  146. int i;
  147. for (i = 0; i < session->cmds_max; i++) {
  148. struct iscsi_task *task = session->cmds[i];
  149. struct qedi_cmd *cmd = task->dd_data;
  150. if (cmd->io_tbl.sge_tbl)
  151. dma_free_coherent(&qedi->pdev->dev,
  152. QEDI_ISCSI_MAX_BDS_PER_CMD *
  153. sizeof(struct scsi_sge),
  154. cmd->io_tbl.sge_tbl,
  155. cmd->io_tbl.sge_tbl_dma);
  156. if (cmd->sense_buffer)
  157. dma_free_coherent(&qedi->pdev->dev,
  158. SCSI_SENSE_BUFFERSIZE,
  159. cmd->sense_buffer,
  160. cmd->sense_buffer_dma);
  161. }
  162. }
  163. static int qedi_alloc_sget(struct qedi_ctx *qedi, struct iscsi_session *session,
  164. struct qedi_cmd *cmd)
  165. {
  166. struct qedi_io_bdt *io = &cmd->io_tbl;
  167. struct scsi_sge *sge;
  168. io->sge_tbl = dma_alloc_coherent(&qedi->pdev->dev,
  169. QEDI_ISCSI_MAX_BDS_PER_CMD *
  170. sizeof(*sge),
  171. &io->sge_tbl_dma, GFP_KERNEL);
  172. if (!io->sge_tbl) {
  173. iscsi_session_printk(KERN_ERR, session,
  174. "Could not allocate BD table.\n");
  175. return -ENOMEM;
  176. }
  177. io->sge_valid = 0;
  178. return 0;
  179. }
  180. static int qedi_setup_cmd_pool(struct qedi_ctx *qedi,
  181. struct iscsi_session *session)
  182. {
  183. int i;
  184. for (i = 0; i < session->cmds_max; i++) {
  185. struct iscsi_task *task = session->cmds[i];
  186. struct qedi_cmd *cmd = task->dd_data;
  187. task->hdr = &cmd->hdr;
  188. task->hdr_max = sizeof(struct iscsi_hdr);
  189. if (qedi_alloc_sget(qedi, session, cmd))
  190. goto free_sgets;
  191. cmd->sense_buffer = dma_alloc_coherent(&qedi->pdev->dev,
  192. SCSI_SENSE_BUFFERSIZE,
  193. &cmd->sense_buffer_dma,
  194. GFP_KERNEL);
  195. if (!cmd->sense_buffer)
  196. goto free_sgets;
  197. }
  198. return 0;
  199. free_sgets:
  200. qedi_destroy_cmd_pool(qedi, session);
  201. return -ENOMEM;
  202. }
  203. static struct iscsi_cls_session *
  204. qedi_session_create(struct iscsi_endpoint *ep, u16 cmds_max,
  205. u16 qdepth, uint32_t initial_cmdsn)
  206. {
  207. struct Scsi_Host *shost;
  208. struct iscsi_cls_session *cls_session;
  209. struct qedi_ctx *qedi;
  210. struct qedi_endpoint *qedi_ep;
  211. if (!ep)
  212. return NULL;
  213. qedi_ep = ep->dd_data;
  214. shost = qedi_ep->qedi->shost;
  215. qedi = iscsi_host_priv(shost);
  216. if (cmds_max > qedi->max_sqes)
  217. cmds_max = qedi->max_sqes;
  218. else if (cmds_max < QEDI_SQ_WQES_MIN)
  219. cmds_max = QEDI_SQ_WQES_MIN;
  220. cls_session = iscsi_session_setup(&qedi_iscsi_transport, shost,
  221. cmds_max, 0, sizeof(struct qedi_cmd),
  222. initial_cmdsn, ISCSI_MAX_TARGET);
  223. if (!cls_session) {
  224. QEDI_ERR(&qedi->dbg_ctx,
  225. "Failed to setup session for ep=%p\n", qedi_ep);
  226. return NULL;
  227. }
  228. if (qedi_setup_cmd_pool(qedi, cls_session->dd_data)) {
  229. QEDI_ERR(&qedi->dbg_ctx,
  230. "Failed to setup cmd pool for ep=%p\n", qedi_ep);
  231. goto session_teardown;
  232. }
  233. return cls_session;
  234. session_teardown:
  235. iscsi_session_teardown(cls_session);
  236. return NULL;
  237. }
  238. static void qedi_session_destroy(struct iscsi_cls_session *cls_session)
  239. {
  240. struct iscsi_session *session = cls_session->dd_data;
  241. struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
  242. struct qedi_ctx *qedi = iscsi_host_priv(shost);
  243. qedi_destroy_cmd_pool(qedi, session);
  244. iscsi_session_teardown(cls_session);
  245. }
  246. static struct iscsi_cls_conn *
  247. qedi_conn_create(struct iscsi_cls_session *cls_session, uint32_t cid)
  248. {
  249. struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
  250. struct qedi_ctx *qedi = iscsi_host_priv(shost);
  251. struct iscsi_cls_conn *cls_conn;
  252. struct qedi_conn *qedi_conn;
  253. struct iscsi_conn *conn;
  254. cls_conn = iscsi_conn_setup(cls_session, sizeof(*qedi_conn),
  255. cid);
  256. if (!cls_conn) {
  257. QEDI_ERR(&qedi->dbg_ctx,
  258. "conn_new: iscsi conn setup failed, cid=0x%x, cls_sess=%p!\n",
  259. cid, cls_session);
  260. return NULL;
  261. }
  262. conn = cls_conn->dd_data;
  263. qedi_conn = conn->dd_data;
  264. qedi_conn->cls_conn = cls_conn;
  265. qedi_conn->qedi = qedi;
  266. qedi_conn->ep = NULL;
  267. qedi_conn->active_cmd_count = 0;
  268. INIT_LIST_HEAD(&qedi_conn->active_cmd_list);
  269. spin_lock_init(&qedi_conn->list_lock);
  270. if (qedi_conn_alloc_login_resources(qedi, qedi_conn)) {
  271. iscsi_conn_printk(KERN_ALERT, conn,
  272. "conn_new: login resc alloc failed, cid=0x%x, cls_sess=%p!!\n",
  273. cid, cls_session);
  274. goto free_conn;
  275. }
  276. return cls_conn;
  277. free_conn:
  278. iscsi_conn_teardown(cls_conn);
  279. return NULL;
  280. }
  281. void qedi_mark_device_missing(struct iscsi_cls_session *cls_session)
  282. {
  283. iscsi_block_session(cls_session);
  284. }
  285. void qedi_mark_device_available(struct iscsi_cls_session *cls_session)
  286. {
  287. iscsi_unblock_session(cls_session);
  288. }
  289. static int qedi_bind_conn_to_iscsi_cid(struct qedi_ctx *qedi,
  290. struct qedi_conn *qedi_conn)
  291. {
  292. u32 iscsi_cid = qedi_conn->iscsi_conn_id;
  293. if (qedi->cid_que.conn_cid_tbl[iscsi_cid]) {
  294. iscsi_conn_printk(KERN_ALERT, qedi_conn->cls_conn->dd_data,
  295. "conn bind - entry #%d not free\n",
  296. iscsi_cid);
  297. return -EBUSY;
  298. }
  299. qedi->cid_que.conn_cid_tbl[iscsi_cid] = qedi_conn;
  300. return 0;
  301. }
  302. struct qedi_conn *qedi_get_conn_from_id(struct qedi_ctx *qedi, u32 iscsi_cid)
  303. {
  304. if (!qedi->cid_que.conn_cid_tbl) {
  305. QEDI_ERR(&qedi->dbg_ctx, "missing conn<->cid table\n");
  306. return NULL;
  307. } else if (iscsi_cid >= qedi->max_active_conns) {
  308. QEDI_ERR(&qedi->dbg_ctx, "wrong cid #%d\n", iscsi_cid);
  309. return NULL;
  310. }
  311. return qedi->cid_que.conn_cid_tbl[iscsi_cid];
  312. }
  313. static int qedi_conn_bind(struct iscsi_cls_session *cls_session,
  314. struct iscsi_cls_conn *cls_conn,
  315. u64 transport_fd, int is_leading)
  316. {
  317. struct iscsi_conn *conn = cls_conn->dd_data;
  318. struct qedi_conn *qedi_conn = conn->dd_data;
  319. struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
  320. struct qedi_ctx *qedi = iscsi_host_priv(shost);
  321. struct qedi_endpoint *qedi_ep;
  322. struct iscsi_endpoint *ep;
  323. ep = iscsi_lookup_endpoint(transport_fd);
  324. if (!ep)
  325. return -EINVAL;
  326. qedi_ep = ep->dd_data;
  327. if ((qedi_ep->state == EP_STATE_TCP_FIN_RCVD) ||
  328. (qedi_ep->state == EP_STATE_TCP_RST_RCVD))
  329. return -EINVAL;
  330. if (iscsi_conn_bind(cls_session, cls_conn, is_leading))
  331. return -EINVAL;
  332. qedi_ep->conn = qedi_conn;
  333. qedi_conn->ep = qedi_ep;
  334. qedi_conn->iscsi_conn_id = qedi_ep->iscsi_cid;
  335. qedi_conn->fw_cid = qedi_ep->fw_cid;
  336. qedi_conn->cmd_cleanup_req = 0;
  337. qedi_conn->cmd_cleanup_cmpl = 0;
  338. if (qedi_bind_conn_to_iscsi_cid(qedi, qedi_conn))
  339. return -EINVAL;
  340. spin_lock_init(&qedi_conn->tmf_work_lock);
  341. INIT_LIST_HEAD(&qedi_conn->tmf_work_list);
  342. init_waitqueue_head(&qedi_conn->wait_queue);
  343. return 0;
  344. }
  345. static int qedi_iscsi_update_conn(struct qedi_ctx *qedi,
  346. struct qedi_conn *qedi_conn)
  347. {
  348. struct qed_iscsi_params_update *conn_info;
  349. struct iscsi_cls_conn *cls_conn = qedi_conn->cls_conn;
  350. struct iscsi_conn *conn = cls_conn->dd_data;
  351. struct qedi_endpoint *qedi_ep;
  352. int rval;
  353. qedi_ep = qedi_conn->ep;
  354. conn_info = kzalloc(sizeof(*conn_info), GFP_KERNEL);
  355. if (!conn_info) {
  356. QEDI_ERR(&qedi->dbg_ctx, "memory alloc failed\n");
  357. return -ENOMEM;
  358. }
  359. conn_info->update_flag = 0;
  360. if (conn->hdrdgst_en)
  361. SET_FIELD(conn_info->update_flag,
  362. ISCSI_CONN_UPDATE_RAMROD_PARAMS_HD_EN, true);
  363. if (conn->datadgst_en)
  364. SET_FIELD(conn_info->update_flag,
  365. ISCSI_CONN_UPDATE_RAMROD_PARAMS_DD_EN, true);
  366. if (conn->session->initial_r2t_en)
  367. SET_FIELD(conn_info->update_flag,
  368. ISCSI_CONN_UPDATE_RAMROD_PARAMS_INITIAL_R2T,
  369. true);
  370. if (conn->session->imm_data_en)
  371. SET_FIELD(conn_info->update_flag,
  372. ISCSI_CONN_UPDATE_RAMROD_PARAMS_IMMEDIATE_DATA,
  373. true);
  374. conn_info->max_seq_size = conn->session->max_burst;
  375. conn_info->max_recv_pdu_length = conn->max_recv_dlength;
  376. conn_info->max_send_pdu_length = conn->max_xmit_dlength;
  377. conn_info->first_seq_length = conn->session->first_burst;
  378. conn_info->exp_stat_sn = conn->exp_statsn;
  379. rval = qedi_ops->update_conn(qedi->cdev, qedi_ep->handle,
  380. conn_info);
  381. if (rval) {
  382. rval = -ENXIO;
  383. QEDI_ERR(&qedi->dbg_ctx, "Could not update connection\n");
  384. }
  385. kfree(conn_info);
  386. return rval;
  387. }
  388. static u16 qedi_calc_mss(u16 pmtu, u8 is_ipv6, u8 tcp_ts_en, u8 vlan_en)
  389. {
  390. u16 mss = 0;
  391. u16 hdrs = TCP_HDR_LEN;
  392. if (is_ipv6)
  393. hdrs += IPV6_HDR_LEN;
  394. else
  395. hdrs += IPV4_HDR_LEN;
  396. mss = pmtu - hdrs;
  397. if (!mss)
  398. mss = DEF_MSS;
  399. return mss;
  400. }
  401. static int qedi_iscsi_offload_conn(struct qedi_endpoint *qedi_ep)
  402. {
  403. struct qedi_ctx *qedi = qedi_ep->qedi;
  404. struct qed_iscsi_params_offload *conn_info;
  405. int rval;
  406. int i;
  407. conn_info = kzalloc(sizeof(*conn_info), GFP_KERNEL);
  408. if (!conn_info) {
  409. QEDI_ERR(&qedi->dbg_ctx,
  410. "Failed to allocate memory ep=%p\n", qedi_ep);
  411. return -ENOMEM;
  412. }
  413. ether_addr_copy(conn_info->src.mac, qedi_ep->src_mac);
  414. ether_addr_copy(conn_info->dst.mac, qedi_ep->dst_mac);
  415. conn_info->src.ip[0] = ntohl(qedi_ep->src_addr[0]);
  416. conn_info->dst.ip[0] = ntohl(qedi_ep->dst_addr[0]);
  417. if (qedi_ep->ip_type == TCP_IPV4) {
  418. conn_info->ip_version = 0;
  419. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_CONN,
  420. "After ntohl: src_addr=%pI4, dst_addr=%pI4\n",
  421. qedi_ep->src_addr, qedi_ep->dst_addr);
  422. } else {
  423. for (i = 1; i < 4; i++) {
  424. conn_info->src.ip[i] = ntohl(qedi_ep->src_addr[i]);
  425. conn_info->dst.ip[i] = ntohl(qedi_ep->dst_addr[i]);
  426. }
  427. conn_info->ip_version = 1;
  428. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_CONN,
  429. "After ntohl: src_addr=%pI6, dst_addr=%pI6\n",
  430. qedi_ep->src_addr, qedi_ep->dst_addr);
  431. }
  432. conn_info->src.port = qedi_ep->src_port;
  433. conn_info->dst.port = qedi_ep->dst_port;
  434. conn_info->layer_code = ISCSI_SLOW_PATH_LAYER_CODE;
  435. conn_info->sq_pbl_addr = qedi_ep->sq_pbl_dma;
  436. conn_info->vlan_id = qedi_ep->vlan_id;
  437. SET_FIELD(conn_info->tcp_flags, TCP_OFFLOAD_PARAMS_TS_EN, 1);
  438. SET_FIELD(conn_info->tcp_flags, TCP_OFFLOAD_PARAMS_DA_EN, 1);
  439. SET_FIELD(conn_info->tcp_flags, TCP_OFFLOAD_PARAMS_DA_CNT_EN, 1);
  440. SET_FIELD(conn_info->tcp_flags, TCP_OFFLOAD_PARAMS_KA_EN, 1);
  441. conn_info->default_cq = (qedi_ep->fw_cid % qedi->num_queues);
  442. conn_info->ka_max_probe_cnt = DEF_KA_MAX_PROBE_COUNT;
  443. conn_info->dup_ack_theshold = 3;
  444. conn_info->rcv_wnd = 65535;
  445. conn_info->ss_thresh = 65535;
  446. conn_info->srtt = 300;
  447. conn_info->rtt_var = 150;
  448. conn_info->flow_label = 0;
  449. conn_info->ka_timeout = DEF_KA_TIMEOUT;
  450. conn_info->ka_interval = DEF_KA_INTERVAL;
  451. conn_info->max_rt_time = DEF_MAX_RT_TIME;
  452. conn_info->ttl = DEF_TTL;
  453. conn_info->tos_or_tc = DEF_TOS;
  454. conn_info->remote_port = qedi_ep->dst_port;
  455. conn_info->local_port = qedi_ep->src_port;
  456. conn_info->mss = qedi_calc_mss(qedi_ep->pmtu,
  457. (qedi_ep->ip_type == TCP_IPV6),
  458. 1, (qedi_ep->vlan_id != 0));
  459. conn_info->cwnd = DEF_MAX_CWND * conn_info->mss;
  460. conn_info->rcv_wnd_scale = 4;
  461. conn_info->da_timeout_value = 200;
  462. conn_info->ack_frequency = 2;
  463. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
  464. "Default cq index [%d], mss [%d]\n",
  465. conn_info->default_cq, conn_info->mss);
  466. rval = qedi_ops->offload_conn(qedi->cdev, qedi_ep->handle, conn_info);
  467. if (rval)
  468. QEDI_ERR(&qedi->dbg_ctx, "offload_conn returned %d, ep=%p\n",
  469. rval, qedi_ep);
  470. kfree(conn_info);
  471. return rval;
  472. }
  473. static int qedi_conn_start(struct iscsi_cls_conn *cls_conn)
  474. {
  475. struct iscsi_conn *conn = cls_conn->dd_data;
  476. struct qedi_conn *qedi_conn = conn->dd_data;
  477. struct qedi_ctx *qedi;
  478. int rval;
  479. qedi = qedi_conn->qedi;
  480. rval = qedi_iscsi_update_conn(qedi, qedi_conn);
  481. if (rval) {
  482. iscsi_conn_printk(KERN_ALERT, conn,
  483. "conn_start: FW oflload conn failed.\n");
  484. rval = -EINVAL;
  485. goto start_err;
  486. }
  487. clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags);
  488. qedi_conn->abrt_conn = 0;
  489. rval = iscsi_conn_start(cls_conn);
  490. if (rval) {
  491. iscsi_conn_printk(KERN_ALERT, conn,
  492. "iscsi_conn_start: FW oflload conn failed!!\n");
  493. }
  494. start_err:
  495. return rval;
  496. }
  497. static void qedi_conn_destroy(struct iscsi_cls_conn *cls_conn)
  498. {
  499. struct iscsi_conn *conn = cls_conn->dd_data;
  500. struct qedi_conn *qedi_conn = conn->dd_data;
  501. struct Scsi_Host *shost;
  502. struct qedi_ctx *qedi;
  503. shost = iscsi_session_to_shost(iscsi_conn_to_session(cls_conn));
  504. qedi = iscsi_host_priv(shost);
  505. qedi_conn_free_login_resources(qedi, qedi_conn);
  506. iscsi_conn_teardown(cls_conn);
  507. }
  508. static int qedi_ep_get_param(struct iscsi_endpoint *ep,
  509. enum iscsi_param param, char *buf)
  510. {
  511. struct qedi_endpoint *qedi_ep = ep->dd_data;
  512. int len;
  513. if (!qedi_ep)
  514. return -ENOTCONN;
  515. switch (param) {
  516. case ISCSI_PARAM_CONN_PORT:
  517. len = sprintf(buf, "%hu\n", qedi_ep->dst_port);
  518. break;
  519. case ISCSI_PARAM_CONN_ADDRESS:
  520. if (qedi_ep->ip_type == TCP_IPV4)
  521. len = sprintf(buf, "%pI4\n", qedi_ep->dst_addr);
  522. else
  523. len = sprintf(buf, "%pI6\n", qedi_ep->dst_addr);
  524. break;
  525. default:
  526. return -ENOTCONN;
  527. }
  528. return len;
  529. }
  530. static int qedi_host_get_param(struct Scsi_Host *shost,
  531. enum iscsi_host_param param, char *buf)
  532. {
  533. struct qedi_ctx *qedi;
  534. int len;
  535. qedi = iscsi_host_priv(shost);
  536. switch (param) {
  537. case ISCSI_HOST_PARAM_HWADDRESS:
  538. len = sysfs_format_mac(buf, qedi->mac, 6);
  539. break;
  540. case ISCSI_HOST_PARAM_NETDEV_NAME:
  541. len = sprintf(buf, "host%d\n", shost->host_no);
  542. break;
  543. case ISCSI_HOST_PARAM_IPADDRESS:
  544. if (qedi->ip_type == TCP_IPV4)
  545. len = sprintf(buf, "%pI4\n", qedi->src_ip);
  546. else
  547. len = sprintf(buf, "%pI6\n", qedi->src_ip);
  548. break;
  549. default:
  550. return iscsi_host_get_param(shost, param, buf);
  551. }
  552. return len;
  553. }
  554. static void qedi_conn_get_stats(struct iscsi_cls_conn *cls_conn,
  555. struct iscsi_stats *stats)
  556. {
  557. struct iscsi_conn *conn = cls_conn->dd_data;
  558. struct qed_iscsi_stats iscsi_stats;
  559. struct Scsi_Host *shost;
  560. struct qedi_ctx *qedi;
  561. shost = iscsi_session_to_shost(iscsi_conn_to_session(cls_conn));
  562. qedi = iscsi_host_priv(shost);
  563. qedi_ops->get_stats(qedi->cdev, &iscsi_stats);
  564. conn->txdata_octets = iscsi_stats.iscsi_tx_bytes_cnt;
  565. conn->rxdata_octets = iscsi_stats.iscsi_rx_bytes_cnt;
  566. conn->dataout_pdus_cnt = (uint32_t)iscsi_stats.iscsi_tx_data_pdu_cnt;
  567. conn->datain_pdus_cnt = (uint32_t)iscsi_stats.iscsi_rx_data_pdu_cnt;
  568. conn->r2t_pdus_cnt = (uint32_t)iscsi_stats.iscsi_rx_r2t_pdu_cnt;
  569. stats->txdata_octets = conn->txdata_octets;
  570. stats->rxdata_octets = conn->rxdata_octets;
  571. stats->scsicmd_pdus = conn->scsicmd_pdus_cnt;
  572. stats->dataout_pdus = conn->dataout_pdus_cnt;
  573. stats->scsirsp_pdus = conn->scsirsp_pdus_cnt;
  574. stats->datain_pdus = conn->datain_pdus_cnt;
  575. stats->r2t_pdus = conn->r2t_pdus_cnt;
  576. stats->tmfcmd_pdus = conn->tmfcmd_pdus_cnt;
  577. stats->tmfrsp_pdus = conn->tmfrsp_pdus_cnt;
  578. stats->digest_err = 0;
  579. stats->timeout_err = 0;
  580. strcpy(stats->custom[0].desc, "eh_abort_cnt");
  581. stats->custom[0].value = conn->eh_abort_cnt;
  582. stats->custom_length = 1;
  583. }
  584. static void qedi_iscsi_prep_generic_pdu_bd(struct qedi_conn *qedi_conn)
  585. {
  586. struct scsi_sge *bd_tbl;
  587. bd_tbl = (struct scsi_sge *)qedi_conn->gen_pdu.req_bd_tbl;
  588. bd_tbl->sge_addr.hi =
  589. (u32)((u64)qedi_conn->gen_pdu.req_dma_addr >> 32);
  590. bd_tbl->sge_addr.lo = (u32)qedi_conn->gen_pdu.req_dma_addr;
  591. bd_tbl->sge_len = qedi_conn->gen_pdu.req_wr_ptr -
  592. qedi_conn->gen_pdu.req_buf;
  593. bd_tbl = (struct scsi_sge *)qedi_conn->gen_pdu.resp_bd_tbl;
  594. bd_tbl->sge_addr.hi =
  595. (u32)((u64)qedi_conn->gen_pdu.resp_dma_addr >> 32);
  596. bd_tbl->sge_addr.lo = (u32)qedi_conn->gen_pdu.resp_dma_addr;
  597. bd_tbl->sge_len = ISCSI_DEF_MAX_RECV_SEG_LEN;
  598. }
  599. static int qedi_iscsi_send_generic_request(struct iscsi_task *task)
  600. {
  601. struct qedi_cmd *cmd = task->dd_data;
  602. struct qedi_conn *qedi_conn = cmd->conn;
  603. char *buf;
  604. int data_len;
  605. int rc = 0;
  606. qedi_iscsi_prep_generic_pdu_bd(qedi_conn);
  607. switch (task->hdr->opcode & ISCSI_OPCODE_MASK) {
  608. case ISCSI_OP_LOGIN:
  609. qedi_send_iscsi_login(qedi_conn, task);
  610. break;
  611. case ISCSI_OP_NOOP_OUT:
  612. data_len = qedi_conn->gen_pdu.req_buf_size;
  613. buf = qedi_conn->gen_pdu.req_buf;
  614. if (data_len)
  615. rc = qedi_send_iscsi_nopout(qedi_conn, task,
  616. buf, data_len, 1);
  617. else
  618. rc = qedi_send_iscsi_nopout(qedi_conn, task,
  619. NULL, 0, 1);
  620. break;
  621. case ISCSI_OP_LOGOUT:
  622. rc = qedi_send_iscsi_logout(qedi_conn, task);
  623. break;
  624. case ISCSI_OP_SCSI_TMFUNC:
  625. rc = qedi_iscsi_abort_work(qedi_conn, task);
  626. break;
  627. case ISCSI_OP_TEXT:
  628. rc = qedi_send_iscsi_text(qedi_conn, task);
  629. break;
  630. default:
  631. iscsi_conn_printk(KERN_ALERT, qedi_conn->cls_conn->dd_data,
  632. "unsupported op 0x%x\n", task->hdr->opcode);
  633. }
  634. return rc;
  635. }
  636. static int qedi_mtask_xmit(struct iscsi_conn *conn, struct iscsi_task *task)
  637. {
  638. struct qedi_conn *qedi_conn = conn->dd_data;
  639. struct qedi_cmd *cmd = task->dd_data;
  640. memset(qedi_conn->gen_pdu.req_buf, 0, ISCSI_DEF_MAX_RECV_SEG_LEN);
  641. qedi_conn->gen_pdu.req_buf_size = task->data_count;
  642. if (task->data_count) {
  643. memcpy(qedi_conn->gen_pdu.req_buf, task->data,
  644. task->data_count);
  645. qedi_conn->gen_pdu.req_wr_ptr =
  646. qedi_conn->gen_pdu.req_buf + task->data_count;
  647. }
  648. cmd->conn = conn->dd_data;
  649. cmd->scsi_cmd = NULL;
  650. return qedi_iscsi_send_generic_request(task);
  651. }
  652. static int qedi_task_xmit(struct iscsi_task *task)
  653. {
  654. struct iscsi_conn *conn = task->conn;
  655. struct qedi_conn *qedi_conn = conn->dd_data;
  656. struct qedi_cmd *cmd = task->dd_data;
  657. struct scsi_cmnd *sc = task->sc;
  658. cmd->state = 0;
  659. cmd->task = NULL;
  660. cmd->use_slowpath = false;
  661. cmd->conn = qedi_conn;
  662. cmd->task = task;
  663. cmd->io_cmd_in_list = false;
  664. INIT_LIST_HEAD(&cmd->io_cmd);
  665. if (!sc)
  666. return qedi_mtask_xmit(conn, task);
  667. cmd->scsi_cmd = sc;
  668. return qedi_iscsi_send_ioreq(task);
  669. }
  670. static struct iscsi_endpoint *
  671. qedi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
  672. int non_blocking)
  673. {
  674. struct qedi_ctx *qedi;
  675. struct iscsi_endpoint *ep;
  676. struct qedi_endpoint *qedi_ep;
  677. struct sockaddr_in *addr;
  678. struct sockaddr_in6 *addr6;
  679. struct iscsi_path path_req;
  680. u32 msg_type = ISCSI_KEVENT_IF_DOWN;
  681. u32 iscsi_cid = QEDI_CID_RESERVED;
  682. u16 len = 0;
  683. char *buf = NULL;
  684. int ret, tmp;
  685. if (!shost) {
  686. ret = -ENXIO;
  687. QEDI_ERR(NULL, "shost is NULL\n");
  688. return ERR_PTR(ret);
  689. }
  690. if (qedi_do_not_recover) {
  691. ret = -ENOMEM;
  692. return ERR_PTR(ret);
  693. }
  694. qedi = iscsi_host_priv(shost);
  695. if (test_bit(QEDI_IN_OFFLINE, &qedi->flags) ||
  696. test_bit(QEDI_IN_RECOVERY, &qedi->flags)) {
  697. ret = -ENOMEM;
  698. return ERR_PTR(ret);
  699. }
  700. ep = iscsi_create_endpoint(sizeof(struct qedi_endpoint));
  701. if (!ep) {
  702. QEDI_ERR(&qedi->dbg_ctx, "endpoint create fail\n");
  703. ret = -ENOMEM;
  704. return ERR_PTR(ret);
  705. }
  706. qedi_ep = ep->dd_data;
  707. memset(qedi_ep, 0, sizeof(struct qedi_endpoint));
  708. qedi_ep->state = EP_STATE_IDLE;
  709. qedi_ep->iscsi_cid = (u32)-1;
  710. qedi_ep->qedi = qedi;
  711. if (dst_addr->sa_family == AF_INET) {
  712. addr = (struct sockaddr_in *)dst_addr;
  713. memcpy(qedi_ep->dst_addr, &addr->sin_addr.s_addr,
  714. sizeof(struct in_addr));
  715. qedi_ep->dst_port = ntohs(addr->sin_port);
  716. qedi_ep->ip_type = TCP_IPV4;
  717. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_CONN,
  718. "dst_addr=%pI4, dst_port=%u\n",
  719. qedi_ep->dst_addr, qedi_ep->dst_port);
  720. } else if (dst_addr->sa_family == AF_INET6) {
  721. addr6 = (struct sockaddr_in6 *)dst_addr;
  722. memcpy(qedi_ep->dst_addr, &addr6->sin6_addr,
  723. sizeof(struct in6_addr));
  724. qedi_ep->dst_port = ntohs(addr6->sin6_port);
  725. qedi_ep->ip_type = TCP_IPV6;
  726. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_CONN,
  727. "dst_addr=%pI6, dst_port=%u\n",
  728. qedi_ep->dst_addr, qedi_ep->dst_port);
  729. } else {
  730. QEDI_ERR(&qedi->dbg_ctx, "Invalid endpoint\n");
  731. }
  732. if (atomic_read(&qedi->link_state) != QEDI_LINK_UP) {
  733. QEDI_WARN(&qedi->dbg_ctx, "qedi link down\n");
  734. ret = -ENXIO;
  735. goto ep_conn_exit;
  736. }
  737. ret = qedi_alloc_sq(qedi, qedi_ep);
  738. if (ret)
  739. goto ep_conn_exit;
  740. ret = qedi_ops->acquire_conn(qedi->cdev, &qedi_ep->handle,
  741. &qedi_ep->fw_cid, &qedi_ep->p_doorbell);
  742. if (ret) {
  743. QEDI_ERR(&qedi->dbg_ctx, "Could not acquire connection\n");
  744. ret = -ENXIO;
  745. goto ep_free_sq;
  746. }
  747. iscsi_cid = qedi_ep->handle;
  748. qedi_ep->iscsi_cid = iscsi_cid;
  749. init_waitqueue_head(&qedi_ep->ofld_wait);
  750. init_waitqueue_head(&qedi_ep->tcp_ofld_wait);
  751. qedi_ep->state = EP_STATE_OFLDCONN_START;
  752. qedi->ep_tbl[iscsi_cid] = qedi_ep;
  753. buf = (char *)&path_req;
  754. len = sizeof(path_req);
  755. memset(&path_req, 0, len);
  756. msg_type = ISCSI_KEVENT_PATH_REQ;
  757. path_req.handle = (u64)qedi_ep->iscsi_cid;
  758. path_req.pmtu = qedi->ll2_mtu;
  759. qedi_ep->pmtu = qedi->ll2_mtu;
  760. if (qedi_ep->ip_type == TCP_IPV4) {
  761. memcpy(&path_req.dst.v4_addr, &qedi_ep->dst_addr,
  762. sizeof(struct in_addr));
  763. path_req.ip_addr_len = 4;
  764. } else {
  765. memcpy(&path_req.dst.v6_addr, &qedi_ep->dst_addr,
  766. sizeof(struct in6_addr));
  767. path_req.ip_addr_len = 16;
  768. }
  769. ret = iscsi_offload_mesg(shost, &qedi_iscsi_transport, msg_type, buf,
  770. len);
  771. if (ret) {
  772. QEDI_ERR(&qedi->dbg_ctx,
  773. "iscsi_offload_mesg() failed for cid=0x%x ret=%d\n",
  774. iscsi_cid, ret);
  775. goto ep_rel_conn;
  776. }
  777. atomic_inc(&qedi->num_offloads);
  778. return ep;
  779. ep_rel_conn:
  780. qedi->ep_tbl[iscsi_cid] = NULL;
  781. tmp = qedi_ops->release_conn(qedi->cdev, qedi_ep->handle);
  782. if (tmp)
  783. QEDI_WARN(&qedi->dbg_ctx, "release_conn returned %d\n",
  784. tmp);
  785. ep_free_sq:
  786. qedi_free_sq(qedi, qedi_ep);
  787. ep_conn_exit:
  788. iscsi_destroy_endpoint(ep);
  789. return ERR_PTR(ret);
  790. }
  791. static int qedi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)
  792. {
  793. struct qedi_endpoint *qedi_ep;
  794. int ret = 0;
  795. if (qedi_do_not_recover)
  796. return 1;
  797. qedi_ep = ep->dd_data;
  798. if (qedi_ep->state == EP_STATE_IDLE ||
  799. qedi_ep->state == EP_STATE_OFLDCONN_NONE ||
  800. qedi_ep->state == EP_STATE_OFLDCONN_FAILED)
  801. return -1;
  802. if (qedi_ep->state == EP_STATE_OFLDCONN_COMPL)
  803. ret = 1;
  804. ret = wait_event_interruptible_timeout(qedi_ep->ofld_wait,
  805. QEDI_OFLD_WAIT_STATE(qedi_ep),
  806. msecs_to_jiffies(timeout_ms));
  807. if (qedi_ep->state == EP_STATE_OFLDCONN_FAILED)
  808. ret = -1;
  809. if (ret > 0)
  810. return 1;
  811. else if (!ret)
  812. return 0;
  813. else
  814. return ret;
  815. }
  816. static void qedi_cleanup_active_cmd_list(struct qedi_conn *qedi_conn)
  817. {
  818. struct qedi_cmd *cmd, *cmd_tmp;
  819. list_for_each_entry_safe(cmd, cmd_tmp, &qedi_conn->active_cmd_list,
  820. io_cmd) {
  821. list_del_init(&cmd->io_cmd);
  822. qedi_conn->active_cmd_count--;
  823. }
  824. }
  825. static void qedi_ep_disconnect(struct iscsi_endpoint *ep)
  826. {
  827. struct qedi_endpoint *qedi_ep;
  828. struct qedi_conn *qedi_conn = NULL;
  829. struct iscsi_conn *conn = NULL;
  830. struct qedi_ctx *qedi;
  831. int ret = 0;
  832. int wait_delay = 20 * HZ;
  833. int abrt_conn = 0;
  834. int count = 10;
  835. qedi_ep = ep->dd_data;
  836. qedi = qedi_ep->qedi;
  837. if (qedi_ep->state == EP_STATE_OFLDCONN_START)
  838. goto ep_exit_recover;
  839. flush_work(&qedi_ep->offload_work);
  840. if (qedi_ep->conn) {
  841. qedi_conn = qedi_ep->conn;
  842. conn = qedi_conn->cls_conn->dd_data;
  843. iscsi_suspend_queue(conn);
  844. abrt_conn = qedi_conn->abrt_conn;
  845. while (count--) {
  846. if (!test_bit(QEDI_CONN_FW_CLEANUP,
  847. &qedi_conn->flags)) {
  848. break;
  849. }
  850. msleep(1000);
  851. }
  852. if (test_bit(QEDI_IN_RECOVERY, &qedi->flags)) {
  853. if (qedi_do_not_recover) {
  854. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
  855. "Do not recover cid=0x%x\n",
  856. qedi_ep->iscsi_cid);
  857. goto ep_exit_recover;
  858. }
  859. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
  860. "Reset recovery cid=0x%x, qedi_ep=%p, state=0x%x\n",
  861. qedi_ep->iscsi_cid, qedi_ep, qedi_ep->state);
  862. qedi_cleanup_active_cmd_list(qedi_conn);
  863. goto ep_release_conn;
  864. }
  865. }
  866. if (qedi_do_not_recover)
  867. goto ep_exit_recover;
  868. switch (qedi_ep->state) {
  869. case EP_STATE_OFLDCONN_START:
  870. case EP_STATE_OFLDCONN_NONE:
  871. goto ep_release_conn;
  872. case EP_STATE_OFLDCONN_FAILED:
  873. break;
  874. case EP_STATE_OFLDCONN_COMPL:
  875. if (unlikely(!qedi_conn))
  876. break;
  877. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
  878. "Active cmd count=%d, abrt_conn=%d, ep state=0x%x, cid=0x%x, qedi_conn=%p\n",
  879. qedi_conn->active_cmd_count, abrt_conn,
  880. qedi_ep->state,
  881. qedi_ep->iscsi_cid,
  882. qedi_ep->conn
  883. );
  884. if (!qedi_conn->active_cmd_count)
  885. abrt_conn = 0;
  886. else
  887. abrt_conn = 1;
  888. if (abrt_conn)
  889. qedi_clearsq(qedi, qedi_conn, NULL);
  890. break;
  891. default:
  892. break;
  893. }
  894. qedi_ep->state = EP_STATE_DISCONN_START;
  895. ret = qedi_ops->destroy_conn(qedi->cdev, qedi_ep->handle, abrt_conn);
  896. if (ret) {
  897. QEDI_WARN(&qedi->dbg_ctx,
  898. "destroy_conn failed returned %d\n", ret);
  899. } else {
  900. ret = wait_event_interruptible_timeout(
  901. qedi_ep->tcp_ofld_wait,
  902. (qedi_ep->state !=
  903. EP_STATE_DISCONN_START),
  904. wait_delay);
  905. if ((ret <= 0) || (qedi_ep->state == EP_STATE_DISCONN_START)) {
  906. QEDI_WARN(&qedi->dbg_ctx,
  907. "Destroy conn timedout or interrupted, ret=%d, delay=%d, cid=0x%x\n",
  908. ret, wait_delay, qedi_ep->iscsi_cid);
  909. }
  910. }
  911. ep_release_conn:
  912. ret = qedi_ops->release_conn(qedi->cdev, qedi_ep->handle);
  913. if (ret)
  914. QEDI_WARN(&qedi->dbg_ctx,
  915. "release_conn returned %d, cid=0x%x\n",
  916. ret, qedi_ep->iscsi_cid);
  917. ep_exit_recover:
  918. qedi_ep->state = EP_STATE_IDLE;
  919. qedi->ep_tbl[qedi_ep->iscsi_cid] = NULL;
  920. qedi->cid_que.conn_cid_tbl[qedi_ep->iscsi_cid] = NULL;
  921. qedi_free_id(&qedi->lcl_port_tbl, qedi_ep->src_port);
  922. qedi_free_sq(qedi, qedi_ep);
  923. if (qedi_conn)
  924. qedi_conn->ep = NULL;
  925. qedi_ep->conn = NULL;
  926. qedi_ep->qedi = NULL;
  927. atomic_dec(&qedi->num_offloads);
  928. iscsi_destroy_endpoint(ep);
  929. }
  930. static int qedi_data_avail(struct qedi_ctx *qedi, u16 vlanid)
  931. {
  932. struct qed_dev *cdev = qedi->cdev;
  933. struct qedi_uio_dev *udev;
  934. struct qedi_uio_ctrl *uctrl;
  935. struct sk_buff *skb;
  936. u32 len;
  937. int rc = 0;
  938. udev = qedi->udev;
  939. if (!udev) {
  940. QEDI_ERR(&qedi->dbg_ctx, "udev is NULL.\n");
  941. return -EINVAL;
  942. }
  943. uctrl = (struct qedi_uio_ctrl *)udev->uctrl;
  944. if (!uctrl) {
  945. QEDI_ERR(&qedi->dbg_ctx, "uctlr is NULL.\n");
  946. return -EINVAL;
  947. }
  948. len = uctrl->host_tx_pkt_len;
  949. if (!len) {
  950. QEDI_ERR(&qedi->dbg_ctx, "Invalid len %u\n", len);
  951. return -EINVAL;
  952. }
  953. skb = alloc_skb(len, GFP_ATOMIC);
  954. if (!skb) {
  955. QEDI_ERR(&qedi->dbg_ctx, "alloc_skb failed\n");
  956. return -EINVAL;
  957. }
  958. skb_put(skb, len);
  959. memcpy(skb->data, udev->tx_pkt, len);
  960. skb->ip_summed = CHECKSUM_NONE;
  961. if (vlanid)
  962. __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlanid);
  963. rc = qedi_ops->ll2->start_xmit(cdev, skb, 0);
  964. if (rc) {
  965. QEDI_ERR(&qedi->dbg_ctx, "ll2 start_xmit returned %d\n",
  966. rc);
  967. kfree_skb(skb);
  968. }
  969. uctrl->host_tx_pkt_len = 0;
  970. uctrl->hw_tx_cons++;
  971. return rc;
  972. }
  973. static void qedi_offload_work(struct work_struct *work)
  974. {
  975. struct qedi_endpoint *qedi_ep =
  976. container_of(work, struct qedi_endpoint, offload_work);
  977. struct qedi_ctx *qedi;
  978. int wait_delay = 20 * HZ;
  979. int ret;
  980. qedi = qedi_ep->qedi;
  981. ret = qedi_iscsi_offload_conn(qedi_ep);
  982. if (ret) {
  983. QEDI_ERR(&qedi->dbg_ctx,
  984. "offload error: iscsi_cid=%u, qedi_ep=%p, ret=%d\n",
  985. qedi_ep->iscsi_cid, qedi_ep, ret);
  986. qedi_ep->state = EP_STATE_OFLDCONN_FAILED;
  987. return;
  988. }
  989. ret = wait_event_interruptible_timeout(qedi_ep->tcp_ofld_wait,
  990. (qedi_ep->state ==
  991. EP_STATE_OFLDCONN_COMPL),
  992. wait_delay);
  993. if ((ret <= 0) || (qedi_ep->state != EP_STATE_OFLDCONN_COMPL)) {
  994. qedi_ep->state = EP_STATE_OFLDCONN_FAILED;
  995. QEDI_ERR(&qedi->dbg_ctx,
  996. "Offload conn TIMEOUT iscsi_cid=%u, qedi_ep=%p\n",
  997. qedi_ep->iscsi_cid, qedi_ep);
  998. }
  999. }
  1000. static int qedi_set_path(struct Scsi_Host *shost, struct iscsi_path *path_data)
  1001. {
  1002. struct qedi_ctx *qedi;
  1003. struct qedi_endpoint *qedi_ep;
  1004. int ret = 0;
  1005. u32 iscsi_cid;
  1006. u16 port_id = 0;
  1007. if (!shost) {
  1008. ret = -ENXIO;
  1009. QEDI_ERR(NULL, "shost is NULL\n");
  1010. return ret;
  1011. }
  1012. if (strcmp(shost->hostt->proc_name, "qedi")) {
  1013. ret = -ENXIO;
  1014. QEDI_ERR(NULL, "shost %s is invalid\n",
  1015. shost->hostt->proc_name);
  1016. return ret;
  1017. }
  1018. qedi = iscsi_host_priv(shost);
  1019. if (path_data->handle == QEDI_PATH_HANDLE) {
  1020. ret = qedi_data_avail(qedi, path_data->vlan_id);
  1021. goto set_path_exit;
  1022. }
  1023. iscsi_cid = (u32)path_data->handle;
  1024. qedi_ep = qedi->ep_tbl[iscsi_cid];
  1025. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
  1026. "iscsi_cid=0x%x, qedi_ep=%p\n", iscsi_cid, qedi_ep);
  1027. if (!qedi_ep) {
  1028. ret = -EINVAL;
  1029. goto set_path_exit;
  1030. }
  1031. if (!is_valid_ether_addr(&path_data->mac_addr[0])) {
  1032. QEDI_NOTICE(&qedi->dbg_ctx, "dst mac NOT VALID\n");
  1033. qedi_ep->state = EP_STATE_OFLDCONN_NONE;
  1034. ret = -EIO;
  1035. goto set_path_exit;
  1036. }
  1037. ether_addr_copy(&qedi_ep->src_mac[0], &qedi->mac[0]);
  1038. ether_addr_copy(&qedi_ep->dst_mac[0], &path_data->mac_addr[0]);
  1039. qedi_ep->vlan_id = path_data->vlan_id;
  1040. if (path_data->pmtu < DEF_PATH_MTU) {
  1041. qedi_ep->pmtu = qedi->ll2_mtu;
  1042. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
  1043. "MTU cannot be %u, using default MTU %u\n",
  1044. path_data->pmtu, qedi_ep->pmtu);
  1045. }
  1046. if (path_data->pmtu != qedi->ll2_mtu) {
  1047. if (path_data->pmtu > JUMBO_MTU) {
  1048. ret = -EINVAL;
  1049. QEDI_ERR(NULL, "Invalid MTU %u\n", path_data->pmtu);
  1050. goto set_path_exit;
  1051. }
  1052. qedi_reset_host_mtu(qedi, path_data->pmtu);
  1053. qedi_ep->pmtu = qedi->ll2_mtu;
  1054. }
  1055. port_id = qedi_ep->src_port;
  1056. if (port_id >= QEDI_LOCAL_PORT_MIN &&
  1057. port_id < QEDI_LOCAL_PORT_MAX) {
  1058. if (qedi_alloc_id(&qedi->lcl_port_tbl, port_id))
  1059. port_id = 0;
  1060. } else {
  1061. port_id = 0;
  1062. }
  1063. if (!port_id) {
  1064. port_id = qedi_alloc_new_id(&qedi->lcl_port_tbl);
  1065. if (port_id == QEDI_LOCAL_PORT_INVALID) {
  1066. QEDI_ERR(&qedi->dbg_ctx,
  1067. "Failed to allocate port id for iscsi_cid=0x%x\n",
  1068. iscsi_cid);
  1069. ret = -ENOMEM;
  1070. goto set_path_exit;
  1071. }
  1072. }
  1073. qedi_ep->src_port = port_id;
  1074. if (qedi_ep->ip_type == TCP_IPV4) {
  1075. memcpy(&qedi_ep->src_addr[0], &path_data->src.v4_addr,
  1076. sizeof(struct in_addr));
  1077. memcpy(&qedi->src_ip[0], &path_data->src.v4_addr,
  1078. sizeof(struct in_addr));
  1079. qedi->ip_type = TCP_IPV4;
  1080. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_CONN,
  1081. "src addr:port=%pI4:%u, dst addr:port=%pI4:%u\n",
  1082. qedi_ep->src_addr, qedi_ep->src_port,
  1083. qedi_ep->dst_addr, qedi_ep->dst_port);
  1084. } else {
  1085. memcpy(&qedi_ep->src_addr[0], &path_data->src.v6_addr,
  1086. sizeof(struct in6_addr));
  1087. memcpy(&qedi->src_ip[0], &path_data->src.v6_addr,
  1088. sizeof(struct in6_addr));
  1089. qedi->ip_type = TCP_IPV6;
  1090. QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_CONN,
  1091. "src addr:port=%pI6:%u, dst addr:port=%pI6:%u\n",
  1092. qedi_ep->src_addr, qedi_ep->src_port,
  1093. qedi_ep->dst_addr, qedi_ep->dst_port);
  1094. }
  1095. INIT_WORK(&qedi_ep->offload_work, qedi_offload_work);
  1096. queue_work(qedi->offload_thread, &qedi_ep->offload_work);
  1097. ret = 0;
  1098. set_path_exit:
  1099. return ret;
  1100. }
  1101. static umode_t qedi_attr_is_visible(int param_type, int param)
  1102. {
  1103. switch (param_type) {
  1104. case ISCSI_HOST_PARAM:
  1105. switch (param) {
  1106. case ISCSI_HOST_PARAM_NETDEV_NAME:
  1107. case ISCSI_HOST_PARAM_HWADDRESS:
  1108. case ISCSI_HOST_PARAM_IPADDRESS:
  1109. return 0444;
  1110. default:
  1111. return 0;
  1112. }
  1113. case ISCSI_PARAM:
  1114. switch (param) {
  1115. case ISCSI_PARAM_MAX_RECV_DLENGTH:
  1116. case ISCSI_PARAM_MAX_XMIT_DLENGTH:
  1117. case ISCSI_PARAM_HDRDGST_EN:
  1118. case ISCSI_PARAM_DATADGST_EN:
  1119. case ISCSI_PARAM_CONN_ADDRESS:
  1120. case ISCSI_PARAM_CONN_PORT:
  1121. case ISCSI_PARAM_EXP_STATSN:
  1122. case ISCSI_PARAM_PERSISTENT_ADDRESS:
  1123. case ISCSI_PARAM_PERSISTENT_PORT:
  1124. case ISCSI_PARAM_PING_TMO:
  1125. case ISCSI_PARAM_RECV_TMO:
  1126. case ISCSI_PARAM_INITIAL_R2T_EN:
  1127. case ISCSI_PARAM_MAX_R2T:
  1128. case ISCSI_PARAM_IMM_DATA_EN:
  1129. case ISCSI_PARAM_FIRST_BURST:
  1130. case ISCSI_PARAM_MAX_BURST:
  1131. case ISCSI_PARAM_PDU_INORDER_EN:
  1132. case ISCSI_PARAM_DATASEQ_INORDER_EN:
  1133. case ISCSI_PARAM_ERL:
  1134. case ISCSI_PARAM_TARGET_NAME:
  1135. case ISCSI_PARAM_TPGT:
  1136. case ISCSI_PARAM_USERNAME:
  1137. case ISCSI_PARAM_PASSWORD:
  1138. case ISCSI_PARAM_USERNAME_IN:
  1139. case ISCSI_PARAM_PASSWORD_IN:
  1140. case ISCSI_PARAM_FAST_ABORT:
  1141. case ISCSI_PARAM_ABORT_TMO:
  1142. case ISCSI_PARAM_LU_RESET_TMO:
  1143. case ISCSI_PARAM_TGT_RESET_TMO:
  1144. case ISCSI_PARAM_IFACE_NAME:
  1145. case ISCSI_PARAM_INITIATOR_NAME:
  1146. case ISCSI_PARAM_BOOT_ROOT:
  1147. case ISCSI_PARAM_BOOT_NIC:
  1148. case ISCSI_PARAM_BOOT_TARGET:
  1149. return 0444;
  1150. default:
  1151. return 0;
  1152. }
  1153. }
  1154. return 0;
  1155. }
  1156. static void qedi_cleanup_task(struct iscsi_task *task)
  1157. {
  1158. if (!task->sc || task->state == ISCSI_TASK_PENDING) {
  1159. QEDI_INFO(NULL, QEDI_LOG_IO, "Returning ref_cnt=%d\n",
  1160. refcount_read(&task->refcount));
  1161. return;
  1162. }
  1163. qedi_iscsi_unmap_sg_list(task->dd_data);
  1164. }
  1165. struct iscsi_transport qedi_iscsi_transport = {
  1166. .owner = THIS_MODULE,
  1167. .name = QEDI_MODULE_NAME,
  1168. .caps = CAP_RECOVERY_L0 | CAP_HDRDGST | CAP_MULTI_R2T | CAP_DATADGST |
  1169. CAP_DATA_PATH_OFFLOAD | CAP_TEXT_NEGO,
  1170. .create_session = qedi_session_create,
  1171. .destroy_session = qedi_session_destroy,
  1172. .create_conn = qedi_conn_create,
  1173. .bind_conn = qedi_conn_bind,
  1174. .start_conn = qedi_conn_start,
  1175. .stop_conn = iscsi_conn_stop,
  1176. .destroy_conn = qedi_conn_destroy,
  1177. .set_param = iscsi_set_param,
  1178. .get_ep_param = qedi_ep_get_param,
  1179. .get_conn_param = iscsi_conn_get_param,
  1180. .get_session_param = iscsi_session_get_param,
  1181. .get_host_param = qedi_host_get_param,
  1182. .send_pdu = iscsi_conn_send_pdu,
  1183. .get_stats = qedi_conn_get_stats,
  1184. .xmit_task = qedi_task_xmit,
  1185. .cleanup_task = qedi_cleanup_task,
  1186. .session_recovery_timedout = iscsi_session_recovery_timedout,
  1187. .ep_connect = qedi_ep_connect,
  1188. .ep_poll = qedi_ep_poll,
  1189. .ep_disconnect = qedi_ep_disconnect,
  1190. .set_path = qedi_set_path,
  1191. .attr_is_visible = qedi_attr_is_visible,
  1192. };
  1193. void qedi_start_conn_recovery(struct qedi_ctx *qedi,
  1194. struct qedi_conn *qedi_conn)
  1195. {
  1196. struct iscsi_cls_session *cls_sess;
  1197. struct iscsi_cls_conn *cls_conn;
  1198. struct iscsi_conn *conn;
  1199. cls_conn = qedi_conn->cls_conn;
  1200. conn = cls_conn->dd_data;
  1201. cls_sess = iscsi_conn_to_session(cls_conn);
  1202. if (iscsi_is_session_online(cls_sess)) {
  1203. qedi_conn->abrt_conn = 1;
  1204. QEDI_ERR(&qedi->dbg_ctx,
  1205. "Failing connection, state=0x%x, cid=0x%x\n",
  1206. conn->session->state, qedi_conn->iscsi_conn_id);
  1207. iscsi_conn_failure(qedi_conn->cls_conn->dd_data,
  1208. ISCSI_ERR_CONN_FAILED);
  1209. }
  1210. }
  1211. static const struct {
  1212. enum iscsi_error_types error_code;
  1213. char *err_string;
  1214. } qedi_iscsi_error[] = {
  1215. { ISCSI_STATUS_NONE,
  1216. "tcp_error none"
  1217. },
  1218. { ISCSI_CONN_ERROR_TASK_CID_MISMATCH,
  1219. "task cid mismatch"
  1220. },
  1221. { ISCSI_CONN_ERROR_TASK_NOT_VALID,
  1222. "invalid task"
  1223. },
  1224. { ISCSI_CONN_ERROR_RQ_RING_IS_FULL,
  1225. "rq ring full"
  1226. },
  1227. { ISCSI_CONN_ERROR_CMDQ_RING_IS_FULL,
  1228. "cmdq ring full"
  1229. },
  1230. { ISCSI_CONN_ERROR_HQE_CACHING_FAILED,
  1231. "sge caching failed"
  1232. },
  1233. { ISCSI_CONN_ERROR_HEADER_DIGEST_ERROR,
  1234. "hdr digest error"
  1235. },
  1236. { ISCSI_CONN_ERROR_LOCAL_COMPLETION_ERROR,
  1237. "local cmpl error"
  1238. },
  1239. { ISCSI_CONN_ERROR_DATA_OVERRUN,
  1240. "invalid task"
  1241. },
  1242. { ISCSI_CONN_ERROR_OUT_OF_SGES_ERROR,
  1243. "out of sge error"
  1244. },
  1245. { ISCSI_CONN_ERROR_TCP_IP_FRAGMENT_ERROR,
  1246. "tcp ip fragment error"
  1247. },
  1248. { ISCSI_CONN_ERROR_PROTOCOL_ERR_AHS_LEN,
  1249. "AHS len protocol error"
  1250. },
  1251. { ISCSI_CONN_ERROR_PROTOCOL_ERR_ITT_OUT_OF_RANGE,
  1252. "itt out of range error"
  1253. },
  1254. { ISCSI_CONN_ERROR_PROTOCOL_ERR_DATA_SEG_LEN_EXCEEDS_PDU_SIZE,
  1255. "data seg more than pdu size"
  1256. },
  1257. { ISCSI_CONN_ERROR_PROTOCOL_ERR_INVALID_OPCODE,
  1258. "invalid opcode"
  1259. },
  1260. { ISCSI_CONN_ERROR_PROTOCOL_ERR_INVALID_OPCODE_BEFORE_UPDATE,
  1261. "invalid opcode before update"
  1262. },
  1263. { ISCSI_CONN_ERROR_UNVALID_NOPIN_DSL,
  1264. "unexpected opcode"
  1265. },
  1266. { ISCSI_CONN_ERROR_PROTOCOL_ERR_R2T_CARRIES_NO_DATA,
  1267. "r2t carries no data"
  1268. },
  1269. { ISCSI_CONN_ERROR_PROTOCOL_ERR_DATA_SN,
  1270. "data sn error"
  1271. },
  1272. { ISCSI_CONN_ERROR_PROTOCOL_ERR_DATA_IN_TTT,
  1273. "data TTT error"
  1274. },
  1275. { ISCSI_CONN_ERROR_PROTOCOL_ERR_R2T_TTT,
  1276. "r2t TTT error"
  1277. },
  1278. { ISCSI_CONN_ERROR_PROTOCOL_ERR_R2T_BUFFER_OFFSET,
  1279. "buffer offset error"
  1280. },
  1281. { ISCSI_CONN_ERROR_PROTOCOL_ERR_BUFFER_OFFSET_OOO,
  1282. "buffer offset ooo"
  1283. },
  1284. { ISCSI_CONN_ERROR_PROTOCOL_ERR_R2T_SN,
  1285. "data seg len 0"
  1286. },
  1287. { ISCSI_CONN_ERROR_PROTOCOL_ERR_DESIRED_DATA_TRNS_LEN_0,
  1288. "data xer len error"
  1289. },
  1290. { ISCSI_CONN_ERROR_PROTOCOL_ERR_DESIRED_DATA_TRNS_LEN_1,
  1291. "data xer len1 error"
  1292. },
  1293. { ISCSI_CONN_ERROR_PROTOCOL_ERR_DESIRED_DATA_TRNS_LEN_2,
  1294. "data xer len2 error"
  1295. },
  1296. { ISCSI_CONN_ERROR_PROTOCOL_ERR_LUN,
  1297. "protocol lun error"
  1298. },
  1299. { ISCSI_CONN_ERROR_PROTOCOL_ERR_F_BIT_ZERO,
  1300. "f bit zero error"
  1301. },
  1302. { ISCSI_CONN_ERROR_PROTOCOL_ERR_EXP_STAT_SN,
  1303. "exp stat sn error"
  1304. },
  1305. { ISCSI_CONN_ERROR_PROTOCOL_ERR_DSL_NOT_ZERO,
  1306. "dsl not zero error"
  1307. },
  1308. { ISCSI_CONN_ERROR_PROTOCOL_ERR_INVALID_DSL,
  1309. "invalid dsl"
  1310. },
  1311. { ISCSI_CONN_ERROR_PROTOCOL_ERR_DATA_SEG_LEN_TOO_BIG,
  1312. "data seg len too big"
  1313. },
  1314. { ISCSI_CONN_ERROR_PROTOCOL_ERR_OUTSTANDING_R2T_COUNT,
  1315. "outstanding r2t count error"
  1316. },
  1317. { ISCSI_CONN_ERROR_SENSE_DATA_LENGTH,
  1318. "sense datalen error"
  1319. },
  1320. };
  1321. char *qedi_get_iscsi_error(enum iscsi_error_types err_code)
  1322. {
  1323. int i;
  1324. char *msg = NULL;
  1325. for (i = 0; i < ARRAY_SIZE(qedi_iscsi_error); i++) {
  1326. if (qedi_iscsi_error[i].error_code == err_code) {
  1327. msg = qedi_iscsi_error[i].err_string;
  1328. break;
  1329. }
  1330. }
  1331. return msg;
  1332. }
  1333. void qedi_process_iscsi_error(struct qedi_endpoint *ep,
  1334. struct iscsi_eqe_data *data)
  1335. {
  1336. struct qedi_conn *qedi_conn;
  1337. struct qedi_ctx *qedi;
  1338. char warn_notice[] = "iscsi_warning";
  1339. char error_notice[] = "iscsi_error";
  1340. char unknown_msg[] = "Unknown error";
  1341. char *message;
  1342. int need_recovery = 0;
  1343. u32 err_mask = 0;
  1344. char *msg;
  1345. if (!ep)
  1346. return;
  1347. qedi_conn = ep->conn;
  1348. if (!qedi_conn)
  1349. return;
  1350. qedi = ep->qedi;
  1351. QEDI_ERR(&qedi->dbg_ctx, "async event iscsi error:0x%x\n",
  1352. data->error_code);
  1353. if (err_mask) {
  1354. need_recovery = 0;
  1355. message = warn_notice;
  1356. } else {
  1357. need_recovery = 1;
  1358. message = error_notice;
  1359. }
  1360. msg = qedi_get_iscsi_error(data->error_code);
  1361. if (!msg) {
  1362. need_recovery = 0;
  1363. msg = unknown_msg;
  1364. }
  1365. iscsi_conn_printk(KERN_ALERT,
  1366. qedi_conn->cls_conn->dd_data,
  1367. "qedi: %s - %s\n", message, msg);
  1368. if (need_recovery)
  1369. qedi_start_conn_recovery(qedi_conn->qedi, qedi_conn);
  1370. }
  1371. void qedi_process_tcp_error(struct qedi_endpoint *ep,
  1372. struct iscsi_eqe_data *data)
  1373. {
  1374. struct qedi_conn *qedi_conn;
  1375. if (!ep)
  1376. return;
  1377. qedi_conn = ep->conn;
  1378. if (!qedi_conn)
  1379. return;
  1380. QEDI_ERR(&ep->qedi->dbg_ctx, "async event TCP error:0x%x\n",
  1381. data->error_code);
  1382. qedi_start_conn_recovery(qedi_conn->qedi, qedi_conn);
  1383. }