Lines Matching +full:emc +full:- +full:tables
3 * Copyright (c) 2006 - 2013 Broadcom Corporation
14 * Maintained by: QLogic-Storage-Upstream@qlogic.com
25 * bnx2i_get_cid_num - get cid from ep
34 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) in bnx2i_get_cid_num()
35 cid = ep->ep_cid; in bnx2i_get_cid_num()
37 cid = GET_CID_NUM(ep->ep_cid); in bnx2i_get_cid_num()
43 * bnx2i_adjust_qp_size - Adjust SQ/RQ/CQ size for 57710 device type
52 if (test_bit(BNX2I_NX2_DEV_5706, &hba->cnic_dev_type) || in bnx2i_adjust_qp_size()
53 test_bit(BNX2I_NX2_DEV_5708, &hba->cnic_dev_type) || in bnx2i_adjust_qp_size()
54 test_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type)) { in bnx2i_adjust_qp_size()
55 if (!is_power_of_2(hba->max_sqes)) in bnx2i_adjust_qp_size()
56 hba->max_sqes = rounddown_pow_of_two(hba->max_sqes); in bnx2i_adjust_qp_size()
58 if (!is_power_of_2(hba->max_rqes)) in bnx2i_adjust_qp_size()
59 hba->max_rqes = rounddown_pow_of_two(hba->max_rqes); in bnx2i_adjust_qp_size()
67 if (hba->max_sqes < num_elements_per_pg) in bnx2i_adjust_qp_size()
68 hba->max_sqes = num_elements_per_pg; in bnx2i_adjust_qp_size()
69 else if (hba->max_sqes % num_elements_per_pg) in bnx2i_adjust_qp_size()
70 hba->max_sqes = (hba->max_sqes + num_elements_per_pg - 1) & in bnx2i_adjust_qp_size()
71 ~(num_elements_per_pg - 1); in bnx2i_adjust_qp_size()
75 if (hba->max_cqes < num_elements_per_pg) in bnx2i_adjust_qp_size()
76 hba->max_cqes = num_elements_per_pg; in bnx2i_adjust_qp_size()
77 else if (hba->max_cqes % num_elements_per_pg) in bnx2i_adjust_qp_size()
78 hba->max_cqes = (hba->max_cqes + num_elements_per_pg - 1) & in bnx2i_adjust_qp_size()
79 ~(num_elements_per_pg - 1); in bnx2i_adjust_qp_size()
83 if (hba->max_rqes < num_elements_per_pg) in bnx2i_adjust_qp_size()
84 hba->max_rqes = num_elements_per_pg; in bnx2i_adjust_qp_size()
85 else if (hba->max_rqes % num_elements_per_pg) in bnx2i_adjust_qp_size()
86 hba->max_rqes = (hba->max_rqes + num_elements_per_pg - 1) & in bnx2i_adjust_qp_size()
87 ~(num_elements_per_pg - 1); in bnx2i_adjust_qp_size()
92 * bnx2i_get_link_state - get network interface link state
99 if (test_bit(__LINK_STATE_NOCARRIER, &hba->netdev->state)) in bnx2i_get_link_state()
100 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2i_get_link_state()
102 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2i_get_link_state()
107 * bnx2i_iscsi_license_error - displays iscsi license related error message
119 hba->netdev->name); in bnx2i_iscsi_license_error()
124 hba->netdev->name); in bnx2i_iscsi_license_error()
125 set_bit(ADAPTER_STATE_INIT_FAILED, &hba->adapter_state); in bnx2i_iscsi_license_error()
130 * bnx2i_arm_cq_event_coalescing - arms CQ to enable EQ notification
146 if (!test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) in bnx2i_arm_cq_event_coalescing()
150 * '0xFFFF' to CQDB->SQN field. Deviation may cause spurious in bnx2i_arm_cq_event_coalescing()
153 cq_db = (struct bnx2i_5771x_cq_db *) ep->qp.cq_pgtbl_virt; in bnx2i_arm_cq_event_coalescing()
156 if (cq_db->sqn[0] && cq_db->sqn[0] != 0xFFFF) in bnx2i_arm_cq_event_coalescing()
160 num_active_cmds = atomic_read(&ep->num_active_cmds); in bnx2i_arm_cq_event_coalescing()
164 next_index = num_active_cmds >> ep->ec_shift; in bnx2i_arm_cq_event_coalescing()
165 if (next_index > num_active_cmds - event_coal_min) in bnx2i_arm_cq_event_coalescing()
166 next_index = num_active_cmds - event_coal_min; in bnx2i_arm_cq_event_coalescing()
170 cq_index = ep->qp.cqe_exp_seq_sn + next_index - 1; in bnx2i_arm_cq_event_coalescing()
171 if (cq_index > ep->qp.cqe_size * 2) in bnx2i_arm_cq_event_coalescing()
172 cq_index -= ep->qp.cqe_size * 2; in bnx2i_arm_cq_event_coalescing()
176 cq_db->sqn[0] = cq_index; in bnx2i_arm_cq_event_coalescing()
183 * bnx2i_get_rq_buf - copy RQ buffer contents to driver buffer
195 if (!bnx2i_conn->ep->qp.rqe_left) in bnx2i_get_rq_buf()
198 bnx2i_conn->ep->qp.rqe_left--; in bnx2i_get_rq_buf()
199 memcpy(ptr, (u8 *) bnx2i_conn->ep->qp.rq_cons_qe, len); in bnx2i_get_rq_buf()
200 if (bnx2i_conn->ep->qp.rq_cons_qe == bnx2i_conn->ep->qp.rq_last_qe) { in bnx2i_get_rq_buf()
201 bnx2i_conn->ep->qp.rq_cons_qe = bnx2i_conn->ep->qp.rq_first_qe; in bnx2i_get_rq_buf()
202 bnx2i_conn->ep->qp.rq_cons_idx = 0; in bnx2i_get_rq_buf()
204 bnx2i_conn->ep->qp.rq_cons_qe++; in bnx2i_get_rq_buf()
205 bnx2i_conn->ep->qp.rq_cons_idx++; in bnx2i_get_rq_buf()
220 writel(cpu_to_le32(msg), conn->ep->qp.ctx_base); in bnx2i_ring_577xx_doorbell()
225 * bnx2i_put_rq_buf - Replenish RQ buffer, if required ring on chip doorbell
234 u16 hi_bit = (bnx2i_conn->ep->qp.rq_prod_idx & 0x8000); in bnx2i_put_rq_buf()
235 struct bnx2i_endpoint *ep = bnx2i_conn->ep; in bnx2i_put_rq_buf()
237 ep->qp.rqe_left += count; in bnx2i_put_rq_buf()
238 ep->qp.rq_prod_idx &= 0x7FFF; in bnx2i_put_rq_buf()
239 ep->qp.rq_prod_idx += count; in bnx2i_put_rq_buf()
241 if (ep->qp.rq_prod_idx > bnx2i_conn->hba->max_rqes) { in bnx2i_put_rq_buf()
242 ep->qp.rq_prod_idx %= bnx2i_conn->hba->max_rqes; in bnx2i_put_rq_buf()
244 ep->qp.rq_prod_idx |= 0x8000; in bnx2i_put_rq_buf()
246 ep->qp.rq_prod_idx |= hi_bit; in bnx2i_put_rq_buf()
248 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) { in bnx2i_put_rq_buf()
249 rq_db = (struct bnx2i_5771x_sq_rq_db *) ep->qp.rq_pgtbl_virt; in bnx2i_put_rq_buf()
250 rq_db->prod_idx = ep->qp.rq_prod_idx; in bnx2i_put_rq_buf()
253 writew(ep->qp.rq_prod_idx, in bnx2i_put_rq_buf()
254 ep->qp.ctx_base + CNIC_RECV_DOORBELL); in bnx2i_put_rq_buf()
260 * bnx2i_ring_sq_dbell - Ring SQ doorbell to wake-up the processing engine
271 struct bnx2i_endpoint *ep = bnx2i_conn->ep; in bnx2i_ring_sq_dbell()
273 atomic_inc(&ep->num_active_cmds); in bnx2i_ring_sq_dbell()
275 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) { in bnx2i_ring_sq_dbell()
276 sq_db = (struct bnx2i_5771x_sq_rq_db *) ep->qp.sq_pgtbl_virt; in bnx2i_ring_sq_dbell()
277 sq_db->prod_idx = ep->qp.sq_prod_idx; in bnx2i_ring_sq_dbell()
280 writew(count, ep->qp.ctx_base + CNIC_SEND_DOORBELL); in bnx2i_ring_sq_dbell()
285 * bnx2i_ring_dbell_update_sq_params - update SQ driver parameters
297 if (bnx2i_conn->ep->qp.sq_prod_qe == in bnx2i_ring_dbell_update_sq_params()
298 bnx2i_conn->ep->qp.sq_last_qe) in bnx2i_ring_dbell_update_sq_params()
299 bnx2i_conn->ep->qp.sq_prod_qe = in bnx2i_ring_dbell_update_sq_params()
300 bnx2i_conn->ep->qp.sq_first_qe; in bnx2i_ring_dbell_update_sq_params()
302 bnx2i_conn->ep->qp.sq_prod_qe++; in bnx2i_ring_dbell_update_sq_params()
304 if ((bnx2i_conn->ep->qp.sq_prod_qe + count) <= in bnx2i_ring_dbell_update_sq_params()
305 bnx2i_conn->ep->qp.sq_last_qe) in bnx2i_ring_dbell_update_sq_params()
306 bnx2i_conn->ep->qp.sq_prod_qe += count; in bnx2i_ring_dbell_update_sq_params()
308 tmp_cnt = bnx2i_conn->ep->qp.sq_last_qe - in bnx2i_ring_dbell_update_sq_params()
309 bnx2i_conn->ep->qp.sq_prod_qe; in bnx2i_ring_dbell_update_sq_params()
310 bnx2i_conn->ep->qp.sq_prod_qe = in bnx2i_ring_dbell_update_sq_params()
311 &bnx2i_conn->ep->qp.sq_first_qe[count - in bnx2i_ring_dbell_update_sq_params()
315 bnx2i_conn->ep->qp.sq_prod_idx += count; in bnx2i_ring_dbell_update_sq_params()
317 bnx2i_ring_sq_dbell(bnx2i_conn, bnx2i_conn->ep->qp.sq_prod_idx); in bnx2i_ring_dbell_update_sq_params()
322 * bnx2i_send_iscsi_login - post iSCSI login request MP WQE to hardware
336 login_hdr = (struct iscsi_login_req *)task->hdr; in bnx2i_send_iscsi_login()
338 bnx2i_conn->ep->qp.sq_prod_qe; in bnx2i_send_iscsi_login()
340 login_wqe->op_code = login_hdr->opcode; in bnx2i_send_iscsi_login()
341 login_wqe->op_attr = login_hdr->flags; in bnx2i_send_iscsi_login()
342 login_wqe->version_max = login_hdr->max_version; in bnx2i_send_iscsi_login()
343 login_wqe->version_min = login_hdr->min_version; in bnx2i_send_iscsi_login()
344 login_wqe->data_length = ntoh24(login_hdr->dlength); in bnx2i_send_iscsi_login()
345 login_wqe->isid_lo = *((u32 *) login_hdr->isid); in bnx2i_send_iscsi_login()
346 login_wqe->isid_hi = *((u16 *) login_hdr->isid + 2); in bnx2i_send_iscsi_login()
347 login_wqe->tsih = login_hdr->tsih; in bnx2i_send_iscsi_login()
348 login_wqe->itt = task->itt | in bnx2i_send_iscsi_login()
350 login_wqe->cid = login_hdr->cid; in bnx2i_send_iscsi_login()
352 login_wqe->cmd_sn = be32_to_cpu(login_hdr->cmdsn); in bnx2i_send_iscsi_login()
353 login_wqe->exp_stat_sn = be32_to_cpu(login_hdr->exp_statsn); in bnx2i_send_iscsi_login()
354 login_wqe->flags = ISCSI_LOGIN_REQUEST_UPDATE_EXP_STAT_SN; in bnx2i_send_iscsi_login()
356 login_wqe->resp_bd_list_addr_lo = (u32) bnx2i_conn->gen_pdu.resp_bd_dma; in bnx2i_send_iscsi_login()
357 login_wqe->resp_bd_list_addr_hi = in bnx2i_send_iscsi_login()
358 (u32) ((u64) bnx2i_conn->gen_pdu.resp_bd_dma >> 32); in bnx2i_send_iscsi_login()
361 (bnx2i_conn->gen_pdu.resp_buf_size << in bnx2i_send_iscsi_login()
363 login_wqe->resp_buffer = dword; in bnx2i_send_iscsi_login()
364 login_wqe->bd_list_addr_lo = (u32) bnx2i_conn->gen_pdu.req_bd_dma; in bnx2i_send_iscsi_login()
365 login_wqe->bd_list_addr_hi = in bnx2i_send_iscsi_login()
366 (u32) ((u64) bnx2i_conn->gen_pdu.req_bd_dma >> 32); in bnx2i_send_iscsi_login()
367 login_wqe->num_bds = 1; in bnx2i_send_iscsi_login()
368 login_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ in bnx2i_send_iscsi_login()
375 * bnx2i_send_iscsi_tmf - post iSCSI task management request MP WQE to hardware
385 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_send_iscsi_tmf()
393 tmfabort_hdr = (struct iscsi_tm *)mtask->hdr; in bnx2i_send_iscsi_tmf()
395 bnx2i_conn->ep->qp.sq_prod_qe; in bnx2i_send_iscsi_tmf()
397 tmfabort_wqe->op_code = tmfabort_hdr->opcode; in bnx2i_send_iscsi_tmf()
398 tmfabort_wqe->op_attr = tmfabort_hdr->flags; in bnx2i_send_iscsi_tmf()
400 tmfabort_wqe->itt = (mtask->itt | (ISCSI_TASK_TYPE_MPATH << 14)); in bnx2i_send_iscsi_tmf()
401 tmfabort_wqe->reserved2 = 0; in bnx2i_send_iscsi_tmf()
402 tmfabort_wqe->cmd_sn = be32_to_cpu(tmfabort_hdr->cmdsn); in bnx2i_send_iscsi_tmf()
404 switch (tmfabort_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) { in bnx2i_send_iscsi_tmf()
407 ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt); in bnx2i_send_iscsi_tmf()
408 if (!ctask || !ctask->sc) in bnx2i_send_iscsi_tmf()
414 * sc is still active; hence ctask->sc != 0 in bnx2i_send_iscsi_tmf()
419 ref_sc = ctask->sc; in bnx2i_send_iscsi_tmf()
420 if (ref_sc->sc_data_direction == DMA_TO_DEVICE) in bnx2i_send_iscsi_tmf()
426 tmfabort_wqe->ref_itt = (dword | in bnx2i_send_iscsi_tmf()
427 (tmfabort_hdr->rtt & ISCSI_ITT_MASK)); in bnx2i_send_iscsi_tmf()
430 tmfabort_wqe->ref_itt = RESERVED_ITT; in bnx2i_send_iscsi_tmf()
432 memcpy(scsi_lun, &tmfabort_hdr->lun, sizeof(struct scsi_lun)); in bnx2i_send_iscsi_tmf()
433 tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]); in bnx2i_send_iscsi_tmf()
434 tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]); in bnx2i_send_iscsi_tmf()
436 tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn); in bnx2i_send_iscsi_tmf()
438 tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma; in bnx2i_send_iscsi_tmf()
439 tmfabort_wqe->bd_list_addr_hi = (u32) in bnx2i_send_iscsi_tmf()
440 ((u64) bnx2i_conn->hba->mp_bd_dma >> 32); in bnx2i_send_iscsi_tmf()
441 tmfabort_wqe->num_bds = 1; in bnx2i_send_iscsi_tmf()
442 tmfabort_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ in bnx2i_send_iscsi_tmf()
449 * bnx2i_send_iscsi_text - post iSCSI text WQE to hardware
463 text_hdr = (struct iscsi_text *)mtask->hdr; in bnx2i_send_iscsi_text()
464 text_wqe = (struct bnx2i_text_request *) bnx2i_conn->ep->qp.sq_prod_qe; in bnx2i_send_iscsi_text()
468 text_wqe->op_code = text_hdr->opcode; in bnx2i_send_iscsi_text()
469 text_wqe->op_attr = text_hdr->flags; in bnx2i_send_iscsi_text()
470 text_wqe->data_length = ntoh24(text_hdr->dlength); in bnx2i_send_iscsi_text()
471 text_wqe->itt = mtask->itt | in bnx2i_send_iscsi_text()
473 text_wqe->ttt = be32_to_cpu(text_hdr->ttt); in bnx2i_send_iscsi_text()
475 text_wqe->cmd_sn = be32_to_cpu(text_hdr->cmdsn); in bnx2i_send_iscsi_text()
477 text_wqe->resp_bd_list_addr_lo = (u32) bnx2i_conn->gen_pdu.resp_bd_dma; in bnx2i_send_iscsi_text()
478 text_wqe->resp_bd_list_addr_hi = in bnx2i_send_iscsi_text()
479 (u32) ((u64) bnx2i_conn->gen_pdu.resp_bd_dma >> 32); in bnx2i_send_iscsi_text()
482 (bnx2i_conn->gen_pdu.resp_buf_size << in bnx2i_send_iscsi_text()
484 text_wqe->resp_buffer = dword; in bnx2i_send_iscsi_text()
485 text_wqe->bd_list_addr_lo = (u32) bnx2i_conn->gen_pdu.req_bd_dma; in bnx2i_send_iscsi_text()
486 text_wqe->bd_list_addr_hi = in bnx2i_send_iscsi_text()
487 (u32) ((u64) bnx2i_conn->gen_pdu.req_bd_dma >> 32); in bnx2i_send_iscsi_text()
488 text_wqe->num_bds = 1; in bnx2i_send_iscsi_text()
489 text_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ in bnx2i_send_iscsi_text()
497 * bnx2i_send_iscsi_scsicmd - post iSCSI scsicmd request WQE to hardware
502 * prepare and post an iSCSI SCSI-CMD request WQE to CNIC firmware
510 bnx2i_conn->ep->qp.sq_prod_qe; in bnx2i_send_iscsi_scsicmd()
511 memcpy(scsi_cmd_wqe, &cmd->req, sizeof(struct bnx2i_cmd_request)); in bnx2i_send_iscsi_scsicmd()
512 scsi_cmd_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ in bnx2i_send_iscsi_scsicmd()
519 * bnx2i_send_iscsi_nopout - post iSCSI NOPOUT request WQE to hardware
534 struct bnx2i_endpoint *ep = bnx2i_conn->ep; in bnx2i_send_iscsi_nopout()
538 nopout_hdr = (struct iscsi_nopout *)task->hdr; in bnx2i_send_iscsi_nopout()
539 nopout_wqe = (struct bnx2i_nop_out_request *)ep->qp.sq_prod_qe; in bnx2i_send_iscsi_nopout()
543 nopout_wqe->op_code = nopout_hdr->opcode; in bnx2i_send_iscsi_nopout()
544 nopout_wqe->op_attr = ISCSI_FLAG_CMD_FINAL; in bnx2i_send_iscsi_nopout()
545 memcpy(nopout_wqe->lun, &nopout_hdr->lun, 8); in bnx2i_send_iscsi_nopout()
548 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) in bnx2i_send_iscsi_nopout()
549 swap(nopout_wqe->lun[0], nopout_wqe->lun[1]); in bnx2i_send_iscsi_nopout()
551 nopout_wqe->itt = ((u16)task->itt | in bnx2i_send_iscsi_nopout()
554 nopout_wqe->ttt = be32_to_cpu(nopout_hdr->ttt); in bnx2i_send_iscsi_nopout()
555 nopout_wqe->flags = 0; in bnx2i_send_iscsi_nopout()
557 nopout_wqe->flags = ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION; in bnx2i_send_iscsi_nopout()
558 else if (nopout_hdr->itt == RESERVED_ITT) in bnx2i_send_iscsi_nopout()
559 nopout_wqe->flags = ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION; in bnx2i_send_iscsi_nopout()
561 nopout_wqe->cmd_sn = be32_to_cpu(nopout_hdr->cmdsn); in bnx2i_send_iscsi_nopout()
562 nopout_wqe->data_length = data_len; in bnx2i_send_iscsi_nopout()
567 nopout_wqe->bd_list_addr_lo = (u32) in bnx2i_send_iscsi_nopout()
568 bnx2i_conn->hba->mp_bd_dma; in bnx2i_send_iscsi_nopout()
569 nopout_wqe->bd_list_addr_hi = in bnx2i_send_iscsi_nopout()
570 (u32) ((u64) bnx2i_conn->hba->mp_bd_dma >> 32); in bnx2i_send_iscsi_nopout()
571 nopout_wqe->num_bds = 1; in bnx2i_send_iscsi_nopout()
573 nopout_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ in bnx2i_send_iscsi_nopout()
581 * bnx2i_send_iscsi_logout - post iSCSI logout request WQE to hardware
594 logout_hdr = (struct iscsi_logout *)task->hdr; in bnx2i_send_iscsi_logout()
597 bnx2i_conn->ep->qp.sq_prod_qe; in bnx2i_send_iscsi_logout()
600 logout_wqe->op_code = logout_hdr->opcode; in bnx2i_send_iscsi_logout()
601 logout_wqe->cmd_sn = be32_to_cpu(logout_hdr->cmdsn); in bnx2i_send_iscsi_logout()
602 logout_wqe->op_attr = in bnx2i_send_iscsi_logout()
603 logout_hdr->flags | ISCSI_LOGOUT_REQUEST_ALWAYS_ONE; in bnx2i_send_iscsi_logout()
604 logout_wqe->itt = ((u16)task->itt | in bnx2i_send_iscsi_logout()
607 logout_wqe->data_length = 0; in bnx2i_send_iscsi_logout()
608 logout_wqe->cid = 0; in bnx2i_send_iscsi_logout()
610 logout_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma; in bnx2i_send_iscsi_logout()
611 logout_wqe->bd_list_addr_hi = (u32) in bnx2i_send_iscsi_logout()
612 ((u64) bnx2i_conn->hba->mp_bd_dma >> 32); in bnx2i_send_iscsi_logout()
613 logout_wqe->num_bds = 1; in bnx2i_send_iscsi_logout()
614 logout_wqe->cq_index = 0; /* CQ# used for completion, 5771x only */ in bnx2i_send_iscsi_logout()
616 bnx2i_conn->ep->state = EP_STATE_LOGOUT_SENT; in bnx2i_send_iscsi_logout()
624 * bnx2i_update_iscsi_conn - post iSCSI logout request WQE to hardware
631 struct bnx2i_conn *bnx2i_conn = conn->dd_data; in bnx2i_update_iscsi_conn()
632 struct bnx2i_hba *hba = bnx2i_conn->hba; in bnx2i_update_iscsi_conn()
639 update_wqe->hdr.op_code = ISCSI_KWQE_OPCODE_UPDATE_CONN; in bnx2i_update_iscsi_conn()
640 update_wqe->hdr.flags = in bnx2i_update_iscsi_conn()
644 if (test_bit(BNX2I_NX2_DEV_57710, &bnx2i_conn->ep->hba->cnic_dev_type)) in bnx2i_update_iscsi_conn()
645 update_wqe->context_id = bnx2i_conn->ep->ep_cid; in bnx2i_update_iscsi_conn()
647 update_wqe->context_id = (bnx2i_conn->ep->ep_cid >> 7); in bnx2i_update_iscsi_conn()
648 update_wqe->conn_flags = 0; in bnx2i_update_iscsi_conn()
649 if (conn->hdrdgst_en) in bnx2i_update_iscsi_conn()
650 update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_HEADER_DIGEST; in bnx2i_update_iscsi_conn()
651 if (conn->datadgst_en) in bnx2i_update_iscsi_conn()
652 update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_DATA_DIGEST; in bnx2i_update_iscsi_conn()
653 if (conn->session->initial_r2t_en) in bnx2i_update_iscsi_conn()
654 update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_INITIAL_R2T; in bnx2i_update_iscsi_conn()
655 if (conn->session->imm_data_en) in bnx2i_update_iscsi_conn()
656 update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_IMMEDIATE_DATA; in bnx2i_update_iscsi_conn()
658 update_wqe->max_send_pdu_length = conn->max_xmit_dlength; in bnx2i_update_iscsi_conn()
659 update_wqe->max_recv_pdu_length = conn->max_recv_dlength; in bnx2i_update_iscsi_conn()
660 update_wqe->first_burst_length = conn->session->first_burst; in bnx2i_update_iscsi_conn()
661 update_wqe->max_burst_length = conn->session->max_burst; in bnx2i_update_iscsi_conn()
662 update_wqe->exp_stat_sn = conn->exp_statsn; in bnx2i_update_iscsi_conn()
663 update_wqe->max_outstanding_r2ts = conn->session->max_r2t; in bnx2i_update_iscsi_conn()
664 update_wqe->session_error_recovery_level = conn->session->erl; in bnx2i_update_iscsi_conn()
666 "bnx2i: conn update - MBL 0x%x FBL 0x%x" in bnx2i_update_iscsi_conn()
668 update_wqe->max_burst_length, in bnx2i_update_iscsi_conn()
669 update_wqe->first_burst_length, in bnx2i_update_iscsi_conn()
670 update_wqe->max_recv_pdu_length, in bnx2i_update_iscsi_conn()
671 update_wqe->max_send_pdu_length); in bnx2i_update_iscsi_conn()
674 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2i_update_iscsi_conn()
675 hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 1); in bnx2i_update_iscsi_conn()
680 * bnx2i_ep_ofld_timer - post iSCSI logout request WQE to hardware
690 if (ep->state == EP_STATE_OFLD_START) { in bnx2i_ep_ofld_timer()
692 ep->state = EP_STATE_OFLD_FAILED; in bnx2i_ep_ofld_timer()
693 } else if (ep->state == EP_STATE_DISCONN_START) { in bnx2i_ep_ofld_timer()
695 ep->state = EP_STATE_DISCONN_TIMEDOUT; in bnx2i_ep_ofld_timer()
696 } else if (ep->state == EP_STATE_CLEANUP_START) { in bnx2i_ep_ofld_timer()
698 ep->state = EP_STATE_CLEANUP_FAILED; in bnx2i_ep_ofld_timer()
701 wake_up_interruptible(&ep->ofld_wait); in bnx2i_ep_ofld_timer()
708 if (val & (val - 1)) in bnx2i_power_of2()
710 val--; in bnx2i_power_of2()
720 * bnx2i_send_cmd_cleanup_req - send iscsi cmd context clean-up request
732 (struct bnx2i_cleanup_request *)cmd->conn->ep->qp.sq_prod_qe; in bnx2i_send_cmd_cleanup_req()
735 cmd_cleanup->op_code = ISCSI_OPCODE_CLEANUP_REQUEST; in bnx2i_send_cmd_cleanup_req()
736 cmd_cleanup->itt = cmd->req.itt; in bnx2i_send_cmd_cleanup_req()
737 cmd_cleanup->cq_index = 0; /* CQ# used for completion, 5771x only */ in bnx2i_send_cmd_cleanup_req()
739 bnx2i_ring_dbell_update_sq_params(cmd->conn, 1); in bnx2i_send_cmd_cleanup_req()
744 * bnx2i_send_conn_destroy - initiates iscsi connection teardown process
749 * iscsi connection context clean-up process
755 int rc = -EINVAL; in bnx2i_send_conn_destroy()
763 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) in bnx2i_send_conn_destroy()
764 conn_cleanup.context_id = ep->ep_cid; in bnx2i_send_conn_destroy()
766 conn_cleanup.context_id = (ep->ep_cid >> 7); in bnx2i_send_conn_destroy()
768 conn_cleanup.reserved0 = (u16)ep->ep_iscsi_cid; in bnx2i_send_conn_destroy()
771 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2i_send_conn_destroy()
772 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 1); in bnx2i_send_conn_destroy()
779 * bnx2i_570x_send_conn_ofld_req - initiates iscsi conn context setup process
783 * 5706/5708/5709 specific - prepares and posts CONN_OFLD_REQ1/2 KWQE
794 int rc = -EINVAL; in bnx2i_570x_send_conn_ofld_req()
800 ofld_req1.iscsi_conn_id = (u16) ep->ep_iscsi_cid; in bnx2i_570x_send_conn_ofld_req()
802 dma_addr = ep->qp.sq_pgtbl_phys; in bnx2i_570x_send_conn_ofld_req()
806 dma_addr = ep->qp.cq_pgtbl_phys; in bnx2i_570x_send_conn_ofld_req()
814 dma_addr = ep->qp.rq_pgtbl_phys; in bnx2i_570x_send_conn_ofld_req()
818 ptbl = (u32 *) ep->qp.sq_pgtbl_virt; in bnx2i_570x_send_conn_ofld_req()
823 ptbl = (u32 *) ep->qp.cq_pgtbl_virt; in bnx2i_570x_send_conn_ofld_req()
831 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2i_570x_send_conn_ofld_req()
832 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); in bnx2i_570x_send_conn_ofld_req()
839 * bnx2i_5771x_send_conn_ofld_req - initiates iscsi connection context creation
843 * 57710 specific - prepares and posts CONN_OFLD_REQ1/2 KWQE
855 int rc = -EINVAL; in bnx2i_5771x_send_conn_ofld_req()
861 ofld_req1.iscsi_conn_id = (u16) ep->ep_iscsi_cid; in bnx2i_5771x_send_conn_ofld_req()
863 dma_addr = ep->qp.sq_pgtbl_phys + ISCSI_SQ_DB_SIZE; in bnx2i_5771x_send_conn_ofld_req()
867 dma_addr = ep->qp.cq_pgtbl_phys + ISCSI_CQ_DB_SIZE; in bnx2i_5771x_send_conn_ofld_req()
875 dma_addr = ep->qp.rq_pgtbl_phys + ISCSI_RQ_DB_SIZE; in bnx2i_5771x_send_conn_ofld_req()
879 ptbl = (u32 *)((u8 *)ep->qp.sq_pgtbl_virt + ISCSI_SQ_DB_SIZE); in bnx2i_5771x_send_conn_ofld_req()
883 ptbl = (u32 *)((u8 *)ep->qp.cq_pgtbl_virt + ISCSI_CQ_DB_SIZE); in bnx2i_5771x_send_conn_ofld_req()
892 ptbl = (u32 *)((u8 *)ep->qp.rq_pgtbl_virt + ISCSI_RQ_DB_SIZE); in bnx2i_5771x_send_conn_ofld_req()
900 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2i_5771x_send_conn_ofld_req()
901 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); in bnx2i_5771x_send_conn_ofld_req()
907 * bnx2i_send_conn_ofld_req - initiates iscsi connection context setup process
918 if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type)) in bnx2i_send_conn_ofld_req()
928 * setup_qp_page_tables - iscsi QP page table setup function
931 * Sets up page tables for SQ/RQ/CQ, 1G/sec (5706/5708/5709) devices requires
932 * 64-bit address in big endian format. Whereas 10G/sec (57710) requires
942 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) in setup_qp_page_tables()
948 memset(ep->qp.sq_pgtbl_virt, 0, ep->qp.sq_pgtbl_size); in setup_qp_page_tables()
949 num_pages = ep->qp.sq_mem_size / CNIC_PAGE_SIZE; in setup_qp_page_tables()
950 page = ep->qp.sq_phys; in setup_qp_page_tables()
953 ptbl = (u32 *)((u8 *)ep->qp.sq_pgtbl_virt + ISCSI_SQ_DB_SIZE); in setup_qp_page_tables()
955 ptbl = (u32 *) ep->qp.sq_pgtbl_virt; in setup_qp_page_tables()
956 while (num_pages--) { in setup_qp_page_tables()
976 memset(ep->qp.rq_pgtbl_virt, 0, ep->qp.rq_pgtbl_size); in setup_qp_page_tables()
977 num_pages = ep->qp.rq_mem_size / CNIC_PAGE_SIZE; in setup_qp_page_tables()
978 page = ep->qp.rq_phys; in setup_qp_page_tables()
981 ptbl = (u32 *)((u8 *)ep->qp.rq_pgtbl_virt + ISCSI_RQ_DB_SIZE); in setup_qp_page_tables()
983 ptbl = (u32 *) ep->qp.rq_pgtbl_virt; in setup_qp_page_tables()
984 while (num_pages--) { in setup_qp_page_tables()
1004 memset(ep->qp.cq_pgtbl_virt, 0, ep->qp.cq_pgtbl_size); in setup_qp_page_tables()
1005 num_pages = ep->qp.cq_mem_size / CNIC_PAGE_SIZE; in setup_qp_page_tables()
1006 page = ep->qp.cq_phys; in setup_qp_page_tables()
1009 ptbl = (u32 *)((u8 *)ep->qp.cq_pgtbl_virt + ISCSI_CQ_DB_SIZE); in setup_qp_page_tables()
1011 ptbl = (u32 *) ep->qp.cq_pgtbl_virt; in setup_qp_page_tables()
1012 while (num_pages--) { in setup_qp_page_tables()
1034 * bnx2i_alloc_qp_resc - allocates required resources for QP.
1039 * memory for SQ/RQ/CQ and page tables. EP structure elements such
1047 ep->hba = hba; in bnx2i_alloc_qp_resc()
1048 ep->conn = NULL; in bnx2i_alloc_qp_resc()
1049 ep->ep_cid = ep->ep_iscsi_cid = ep->ep_pg_cid = 0; in bnx2i_alloc_qp_resc()
1052 ep->qp.sq_mem_size = hba->max_sqes * BNX2I_SQ_WQE_SIZE; in bnx2i_alloc_qp_resc()
1053 ep->qp.sq_mem_size = in bnx2i_alloc_qp_resc()
1054 (ep->qp.sq_mem_size + (CNIC_PAGE_SIZE - 1)) & CNIC_PAGE_MASK; in bnx2i_alloc_qp_resc()
1055 ep->qp.sq_pgtbl_size = in bnx2i_alloc_qp_resc()
1056 (ep->qp.sq_mem_size / CNIC_PAGE_SIZE) * sizeof(void *); in bnx2i_alloc_qp_resc()
1057 ep->qp.sq_pgtbl_size = in bnx2i_alloc_qp_resc()
1058 (ep->qp.sq_pgtbl_size + (CNIC_PAGE_SIZE - 1)) & CNIC_PAGE_MASK; in bnx2i_alloc_qp_resc()
1060 ep->qp.sq_pgtbl_virt = in bnx2i_alloc_qp_resc()
1061 dma_alloc_coherent(&hba->pcidev->dev, ep->qp.sq_pgtbl_size, in bnx2i_alloc_qp_resc()
1062 &ep->qp.sq_pgtbl_phys, GFP_KERNEL); in bnx2i_alloc_qp_resc()
1063 if (!ep->qp.sq_pgtbl_virt) { in bnx2i_alloc_qp_resc()
1065 ep->qp.sq_pgtbl_size); in bnx2i_alloc_qp_resc()
1070 ep->qp.sq_virt = in bnx2i_alloc_qp_resc()
1071 dma_alloc_coherent(&hba->pcidev->dev, ep->qp.sq_mem_size, in bnx2i_alloc_qp_resc()
1072 &ep->qp.sq_phys, GFP_KERNEL); in bnx2i_alloc_qp_resc()
1073 if (!ep->qp.sq_virt) { in bnx2i_alloc_qp_resc()
1075 ep->qp.sq_mem_size); in bnx2i_alloc_qp_resc()
1079 ep->qp.sq_first_qe = ep->qp.sq_virt; in bnx2i_alloc_qp_resc()
1080 ep->qp.sq_prod_qe = ep->qp.sq_first_qe; in bnx2i_alloc_qp_resc()
1081 ep->qp.sq_cons_qe = ep->qp.sq_first_qe; in bnx2i_alloc_qp_resc()
1082 ep->qp.sq_last_qe = &ep->qp.sq_first_qe[hba->max_sqes - 1]; in bnx2i_alloc_qp_resc()
1083 ep->qp.sq_prod_idx = 0; in bnx2i_alloc_qp_resc()
1084 ep->qp.sq_cons_idx = 0; in bnx2i_alloc_qp_resc()
1085 ep->qp.sqe_left = hba->max_sqes; in bnx2i_alloc_qp_resc()
1088 ep->qp.cq_mem_size = hba->max_cqes * BNX2I_CQE_SIZE; in bnx2i_alloc_qp_resc()
1089 ep->qp.cq_mem_size = in bnx2i_alloc_qp_resc()
1090 (ep->qp.cq_mem_size + (CNIC_PAGE_SIZE - 1)) & CNIC_PAGE_MASK; in bnx2i_alloc_qp_resc()
1091 ep->qp.cq_pgtbl_size = in bnx2i_alloc_qp_resc()
1092 (ep->qp.cq_mem_size / CNIC_PAGE_SIZE) * sizeof(void *); in bnx2i_alloc_qp_resc()
1093 ep->qp.cq_pgtbl_size = in bnx2i_alloc_qp_resc()
1094 (ep->qp.cq_pgtbl_size + (CNIC_PAGE_SIZE - 1)) & CNIC_PAGE_MASK; in bnx2i_alloc_qp_resc()
1096 ep->qp.cq_pgtbl_virt = in bnx2i_alloc_qp_resc()
1097 dma_alloc_coherent(&hba->pcidev->dev, ep->qp.cq_pgtbl_size, in bnx2i_alloc_qp_resc()
1098 &ep->qp.cq_pgtbl_phys, GFP_KERNEL); in bnx2i_alloc_qp_resc()
1099 if (!ep->qp.cq_pgtbl_virt) { in bnx2i_alloc_qp_resc()
1101 ep->qp.cq_pgtbl_size); in bnx2i_alloc_qp_resc()
1106 ep->qp.cq_virt = in bnx2i_alloc_qp_resc()
1107 dma_alloc_coherent(&hba->pcidev->dev, ep->qp.cq_mem_size, in bnx2i_alloc_qp_resc()
1108 &ep->qp.cq_phys, GFP_KERNEL); in bnx2i_alloc_qp_resc()
1109 if (!ep->qp.cq_virt) { in bnx2i_alloc_qp_resc()
1111 ep->qp.cq_mem_size); in bnx2i_alloc_qp_resc()
1115 ep->qp.cq_first_qe = ep->qp.cq_virt; in bnx2i_alloc_qp_resc()
1116 ep->qp.cq_prod_qe = ep->qp.cq_first_qe; in bnx2i_alloc_qp_resc()
1117 ep->qp.cq_cons_qe = ep->qp.cq_first_qe; in bnx2i_alloc_qp_resc()
1118 ep->qp.cq_last_qe = &ep->qp.cq_first_qe[hba->max_cqes - 1]; in bnx2i_alloc_qp_resc()
1119 ep->qp.cq_prod_idx = 0; in bnx2i_alloc_qp_resc()
1120 ep->qp.cq_cons_idx = 0; in bnx2i_alloc_qp_resc()
1121 ep->qp.cqe_left = hba->max_cqes; in bnx2i_alloc_qp_resc()
1122 ep->qp.cqe_exp_seq_sn = ISCSI_INITIAL_SN; in bnx2i_alloc_qp_resc()
1123 ep->qp.cqe_size = hba->max_cqes; in bnx2i_alloc_qp_resc()
1126 cq_db = (struct bnx2i_5771x_cq_db *) ep->qp.cq_pgtbl_virt; in bnx2i_alloc_qp_resc()
1127 memset(cq_db->sqn, 0xFF, sizeof(cq_db->sqn[0]) * BNX2X_MAX_CQS); in bnx2i_alloc_qp_resc()
1130 ep->qp.rq_mem_size = hba->max_rqes * BNX2I_RQ_WQE_SIZE; in bnx2i_alloc_qp_resc()
1131 ep->qp.rq_mem_size = in bnx2i_alloc_qp_resc()
1132 (ep->qp.rq_mem_size + (CNIC_PAGE_SIZE - 1)) & CNIC_PAGE_MASK; in bnx2i_alloc_qp_resc()
1133 ep->qp.rq_pgtbl_size = in bnx2i_alloc_qp_resc()
1134 (ep->qp.rq_mem_size / CNIC_PAGE_SIZE) * sizeof(void *); in bnx2i_alloc_qp_resc()
1135 ep->qp.rq_pgtbl_size = in bnx2i_alloc_qp_resc()
1136 (ep->qp.rq_pgtbl_size + (CNIC_PAGE_SIZE - 1)) & CNIC_PAGE_MASK; in bnx2i_alloc_qp_resc()
1138 ep->qp.rq_pgtbl_virt = in bnx2i_alloc_qp_resc()
1139 dma_alloc_coherent(&hba->pcidev->dev, ep->qp.rq_pgtbl_size, in bnx2i_alloc_qp_resc()
1140 &ep->qp.rq_pgtbl_phys, GFP_KERNEL); in bnx2i_alloc_qp_resc()
1141 if (!ep->qp.rq_pgtbl_virt) { in bnx2i_alloc_qp_resc()
1143 ep->qp.rq_pgtbl_size); in bnx2i_alloc_qp_resc()
1148 ep->qp.rq_virt = in bnx2i_alloc_qp_resc()
1149 dma_alloc_coherent(&hba->pcidev->dev, ep->qp.rq_mem_size, in bnx2i_alloc_qp_resc()
1150 &ep->qp.rq_phys, GFP_KERNEL); in bnx2i_alloc_qp_resc()
1151 if (!ep->qp.rq_virt) { in bnx2i_alloc_qp_resc()
1153 ep->qp.rq_mem_size); in bnx2i_alloc_qp_resc()
1157 ep->qp.rq_first_qe = ep->qp.rq_virt; in bnx2i_alloc_qp_resc()
1158 ep->qp.rq_prod_qe = ep->qp.rq_first_qe; in bnx2i_alloc_qp_resc()
1159 ep->qp.rq_cons_qe = ep->qp.rq_first_qe; in bnx2i_alloc_qp_resc()
1160 ep->qp.rq_last_qe = &ep->qp.rq_first_qe[hba->max_rqes - 1]; in bnx2i_alloc_qp_resc()
1161 ep->qp.rq_prod_idx = 0x8000; in bnx2i_alloc_qp_resc()
1162 ep->qp.rq_cons_idx = 0; in bnx2i_alloc_qp_resc()
1163 ep->qp.rqe_left = hba->max_rqes; in bnx2i_alloc_qp_resc()
1171 return -ENOMEM; in bnx2i_alloc_qp_resc()
1177 * bnx2i_free_qp_resc - free memory resources held by QP
1181 * Free QP resources - SQ/RQ/CQ memory and page tables.
1185 if (ep->qp.ctx_base) { in bnx2i_free_qp_resc()
1186 iounmap(ep->qp.ctx_base); in bnx2i_free_qp_resc()
1187 ep->qp.ctx_base = NULL; in bnx2i_free_qp_resc()
1190 if (ep->qp.sq_pgtbl_virt) { in bnx2i_free_qp_resc()
1191 dma_free_coherent(&hba->pcidev->dev, ep->qp.sq_pgtbl_size, in bnx2i_free_qp_resc()
1192 ep->qp.sq_pgtbl_virt, ep->qp.sq_pgtbl_phys); in bnx2i_free_qp_resc()
1193 ep->qp.sq_pgtbl_virt = NULL; in bnx2i_free_qp_resc()
1194 ep->qp.sq_pgtbl_phys = 0; in bnx2i_free_qp_resc()
1196 if (ep->qp.sq_virt) { in bnx2i_free_qp_resc()
1197 dma_free_coherent(&hba->pcidev->dev, ep->qp.sq_mem_size, in bnx2i_free_qp_resc()
1198 ep->qp.sq_virt, ep->qp.sq_phys); in bnx2i_free_qp_resc()
1199 ep->qp.sq_virt = NULL; in bnx2i_free_qp_resc()
1200 ep->qp.sq_phys = 0; in bnx2i_free_qp_resc()
1204 if (ep->qp.rq_pgtbl_virt) { in bnx2i_free_qp_resc()
1205 dma_free_coherent(&hba->pcidev->dev, ep->qp.rq_pgtbl_size, in bnx2i_free_qp_resc()
1206 ep->qp.rq_pgtbl_virt, ep->qp.rq_pgtbl_phys); in bnx2i_free_qp_resc()
1207 ep->qp.rq_pgtbl_virt = NULL; in bnx2i_free_qp_resc()
1208 ep->qp.rq_pgtbl_phys = 0; in bnx2i_free_qp_resc()
1210 if (ep->qp.rq_virt) { in bnx2i_free_qp_resc()
1211 dma_free_coherent(&hba->pcidev->dev, ep->qp.rq_mem_size, in bnx2i_free_qp_resc()
1212 ep->qp.rq_virt, ep->qp.rq_phys); in bnx2i_free_qp_resc()
1213 ep->qp.rq_virt = NULL; in bnx2i_free_qp_resc()
1214 ep->qp.rq_phys = 0; in bnx2i_free_qp_resc()
1218 if (ep->qp.cq_pgtbl_virt) { in bnx2i_free_qp_resc()
1219 dma_free_coherent(&hba->pcidev->dev, ep->qp.cq_pgtbl_size, in bnx2i_free_qp_resc()
1220 ep->qp.cq_pgtbl_virt, ep->qp.cq_pgtbl_phys); in bnx2i_free_qp_resc()
1221 ep->qp.cq_pgtbl_virt = NULL; in bnx2i_free_qp_resc()
1222 ep->qp.cq_pgtbl_phys = 0; in bnx2i_free_qp_resc()
1224 if (ep->qp.cq_virt) { in bnx2i_free_qp_resc()
1225 dma_free_coherent(&hba->pcidev->dev, ep->qp.cq_mem_size, in bnx2i_free_qp_resc()
1226 ep->qp.cq_virt, ep->qp.cq_phys); in bnx2i_free_qp_resc()
1227 ep->qp.cq_virt = NULL; in bnx2i_free_qp_resc()
1228 ep->qp.cq_phys = 0; in bnx2i_free_qp_resc()
1234 * bnx2i_send_fw_iscsi_init_msg - initiates initial handshake with iscsi f/w
1238 * This results in iSCSi support validation and on-chip context manager
1258 (CNIC_PAGE_BITS - 8) << ISCSI_KWQE_INIT1_PAGE_SIZE_SHIFT; in bnx2i_send_fw_iscsi_init_msg()
1267 iscsi_init.dummy_buffer_addr_lo = (u32) hba->dummy_buf_dma; in bnx2i_send_fw_iscsi_init_msg()
1269 (u32) ((u64) hba->dummy_buf_dma >> 32); in bnx2i_send_fw_iscsi_init_msg()
1271 hba->num_ccell = hba->max_sqes >> 1; in bnx2i_send_fw_iscsi_init_msg()
1272 hba->ctx_ccell_tasks = in bnx2i_send_fw_iscsi_init_msg()
1273 ((hba->num_ccell & 0xFFFF) | (hba->max_sqes << 16)); in bnx2i_send_fw_iscsi_init_msg()
1274 iscsi_init.num_ccells_per_conn = hba->num_ccell; in bnx2i_send_fw_iscsi_init_msg()
1275 iscsi_init.num_tasks_per_conn = hba->max_sqes; in bnx2i_send_fw_iscsi_init_msg()
1277 iscsi_init.sq_num_wqes = hba->max_sqes; in bnx2i_send_fw_iscsi_init_msg()
1280 iscsi_init.cq_num_wqes = hba->max_cqes; in bnx2i_send_fw_iscsi_init_msg()
1281 iscsi_init.cq_num_pages = (hba->max_cqes * BNX2I_CQE_SIZE + in bnx2i_send_fw_iscsi_init_msg()
1282 (CNIC_PAGE_SIZE - 1)) / CNIC_PAGE_SIZE; in bnx2i_send_fw_iscsi_init_msg()
1283 iscsi_init.sq_num_pages = (hba->max_sqes * BNX2I_SQ_WQE_SIZE + in bnx2i_send_fw_iscsi_init_msg()
1284 (CNIC_PAGE_SIZE - 1)) / CNIC_PAGE_SIZE; in bnx2i_send_fw_iscsi_init_msg()
1286 iscsi_init.rq_num_wqes = hba->max_rqes; in bnx2i_send_fw_iscsi_init_msg()
1292 iscsi_init2.max_cq_sqn = hba->max_cqes * 2 + 1; in bnx2i_send_fw_iscsi_init_msg()
1301 /* EMC */ in bnx2i_send_fw_iscsi_init_msg()
1322 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2i_send_fw_iscsi_init_msg()
1323 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, 2); in bnx2i_send_fw_iscsi_init_msg()
1329 * bnx2i_process_scsi_cmd_resp - this function handles scsi cmd completion.
1334 * process SCSI CMD Response CQE & complete the request to SCSI-ML
1340 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_process_scsi_cmd_resp()
1341 struct bnx2i_hba *hba = bnx2i_conn->hba; in bnx2i_process_scsi_cmd_resp()
1349 spin_lock_bh(&session->back_lock); in bnx2i_process_scsi_cmd_resp()
1351 resp_cqe->itt & ISCSI_CMD_RESPONSE_INDEX); in bnx2i_process_scsi_cmd_resp()
1355 bnx2i_cmd = task->dd_data; in bnx2i_process_scsi_cmd_resp()
1357 if (bnx2i_cmd->req.op_attr & ISCSI_CMD_REQUEST_READ) { in bnx2i_process_scsi_cmd_resp()
1358 conn->datain_pdus_cnt += in bnx2i_process_scsi_cmd_resp()
1359 resp_cqe->task_stat.read_stat.num_data_ins; in bnx2i_process_scsi_cmd_resp()
1360 conn->rxdata_octets += in bnx2i_process_scsi_cmd_resp()
1361 bnx2i_cmd->req.total_data_transfer_length; in bnx2i_process_scsi_cmd_resp()
1363 resp_cqe->task_stat.read_stat.num_data_ins); in bnx2i_process_scsi_cmd_resp()
1365 bnx2i_cmd->req.total_data_transfer_length); in bnx2i_process_scsi_cmd_resp()
1367 conn->dataout_pdus_cnt += in bnx2i_process_scsi_cmd_resp()
1368 resp_cqe->task_stat.write_stat.num_data_outs; in bnx2i_process_scsi_cmd_resp()
1369 conn->r2t_pdus_cnt += in bnx2i_process_scsi_cmd_resp()
1370 resp_cqe->task_stat.write_stat.num_r2ts; in bnx2i_process_scsi_cmd_resp()
1371 conn->txdata_octets += in bnx2i_process_scsi_cmd_resp()
1372 bnx2i_cmd->req.total_data_transfer_length; in bnx2i_process_scsi_cmd_resp()
1374 resp_cqe->task_stat.write_stat.num_data_outs); in bnx2i_process_scsi_cmd_resp()
1376 bnx2i_cmd->req.total_data_transfer_length); in bnx2i_process_scsi_cmd_resp()
1378 resp_cqe->task_stat.write_stat.num_r2ts); in bnx2i_process_scsi_cmd_resp()
1382 hdr = (struct iscsi_scsi_rsp *)task->hdr; in bnx2i_process_scsi_cmd_resp()
1384 hdr->opcode = resp_cqe->op_code; in bnx2i_process_scsi_cmd_resp()
1385 hdr->max_cmdsn = cpu_to_be32(resp_cqe->max_cmd_sn); in bnx2i_process_scsi_cmd_resp()
1386 hdr->exp_cmdsn = cpu_to_be32(resp_cqe->exp_cmd_sn); in bnx2i_process_scsi_cmd_resp()
1387 hdr->response = resp_cqe->response; in bnx2i_process_scsi_cmd_resp()
1388 hdr->cmd_status = resp_cqe->status; in bnx2i_process_scsi_cmd_resp()
1389 hdr->flags = resp_cqe->response_flags; in bnx2i_process_scsi_cmd_resp()
1390 hdr->residual_count = cpu_to_be32(resp_cqe->residual_count); in bnx2i_process_scsi_cmd_resp()
1392 if (resp_cqe->op_code == ISCSI_OP_SCSI_DATA_IN) in bnx2i_process_scsi_cmd_resp()
1395 if (resp_cqe->status == SAM_STAT_CHECK_CONDITION) { in bnx2i_process_scsi_cmd_resp()
1396 datalen = resp_cqe->data_length; in bnx2i_process_scsi_cmd_resp()
1412 bnx2i_get_rq_buf(bnx2i_cmd->conn, conn->data, datalen); in bnx2i_process_scsi_cmd_resp()
1413 bnx2i_put_rq_buf(bnx2i_cmd->conn, 1); in bnx2i_process_scsi_cmd_resp()
1418 conn->data, datalen); in bnx2i_process_scsi_cmd_resp()
1420 spin_unlock_bh(&session->back_lock); in bnx2i_process_scsi_cmd_resp()
1426 * bnx2i_process_login_resp - this function handles iscsi login response
1431 * process Login Response CQE & complete it to open-iscsi user daemon
1437 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_process_login_resp()
1445 spin_lock(&session->back_lock); in bnx2i_process_login_resp()
1447 login->itt & ISCSI_LOGIN_RESPONSE_INDEX); in bnx2i_process_login_resp()
1451 resp_hdr = (struct iscsi_login_rsp *) &bnx2i_conn->gen_pdu.resp_hdr; in bnx2i_process_login_resp()
1453 resp_hdr->opcode = login->op_code; in bnx2i_process_login_resp()
1454 resp_hdr->flags = login->response_flags; in bnx2i_process_login_resp()
1455 resp_hdr->max_version = login->version_max; in bnx2i_process_login_resp()
1456 resp_hdr->active_version = login->version_active; in bnx2i_process_login_resp()
1457 resp_hdr->hlength = 0; in bnx2i_process_login_resp()
1459 hton24(resp_hdr->dlength, login->data_length); in bnx2i_process_login_resp()
1460 memcpy(resp_hdr->isid, &login->isid_lo, 6); in bnx2i_process_login_resp()
1461 resp_hdr->tsih = cpu_to_be16(login->tsih); in bnx2i_process_login_resp()
1462 resp_hdr->itt = task->hdr->itt; in bnx2i_process_login_resp()
1463 resp_hdr->statsn = cpu_to_be32(login->stat_sn); in bnx2i_process_login_resp()
1464 resp_hdr->exp_cmdsn = cpu_to_be32(login->exp_cmd_sn); in bnx2i_process_login_resp()
1465 resp_hdr->max_cmdsn = cpu_to_be32(login->max_cmd_sn); in bnx2i_process_login_resp()
1466 resp_hdr->status_class = login->status_class; in bnx2i_process_login_resp()
1467 resp_hdr->status_detail = login->status_detail; in bnx2i_process_login_resp()
1468 pld_len = login->data_length; in bnx2i_process_login_resp()
1469 bnx2i_conn->gen_pdu.resp_wr_ptr = in bnx2i_process_login_resp()
1470 bnx2i_conn->gen_pdu.resp_buf + pld_len; in bnx2i_process_login_resp()
1474 pad_len = 4 - (pld_len % 4); in bnx2i_process_login_resp()
1479 bnx2i_conn->gen_pdu.resp_wr_ptr[0] = 0; in bnx2i_process_login_resp()
1480 bnx2i_conn->gen_pdu.resp_wr_ptr++; in bnx2i_process_login_resp()
1485 bnx2i_conn->gen_pdu.resp_buf, in bnx2i_process_login_resp()
1486 bnx2i_conn->gen_pdu.resp_wr_ptr - bnx2i_conn->gen_pdu.resp_buf); in bnx2i_process_login_resp()
1488 spin_unlock(&session->back_lock); in bnx2i_process_login_resp()
1494 * bnx2i_process_text_resp - this function handles iscsi text response
1499 * process iSCSI Text Response CQE& complete it to open-iscsi user daemon
1505 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_process_text_resp()
1513 spin_lock(&session->back_lock); in bnx2i_process_text_resp()
1514 task = iscsi_itt_to_task(conn, text->itt & ISCSI_LOGIN_RESPONSE_INDEX); in bnx2i_process_text_resp()
1518 resp_hdr = (struct iscsi_text_rsp *)&bnx2i_conn->gen_pdu.resp_hdr; in bnx2i_process_text_resp()
1520 resp_hdr->opcode = text->op_code; in bnx2i_process_text_resp()
1521 resp_hdr->flags = text->response_flags; in bnx2i_process_text_resp()
1522 resp_hdr->hlength = 0; in bnx2i_process_text_resp()
1524 hton24(resp_hdr->dlength, text->data_length); in bnx2i_process_text_resp()
1525 resp_hdr->itt = task->hdr->itt; in bnx2i_process_text_resp()
1526 resp_hdr->ttt = cpu_to_be32(text->ttt); in bnx2i_process_text_resp()
1527 resp_hdr->statsn = task->hdr->exp_statsn; in bnx2i_process_text_resp()
1528 resp_hdr->exp_cmdsn = cpu_to_be32(text->exp_cmd_sn); in bnx2i_process_text_resp()
1529 resp_hdr->max_cmdsn = cpu_to_be32(text->max_cmd_sn); in bnx2i_process_text_resp()
1530 pld_len = text->data_length; in bnx2i_process_text_resp()
1531 bnx2i_conn->gen_pdu.resp_wr_ptr = bnx2i_conn->gen_pdu.resp_buf + in bnx2i_process_text_resp()
1535 pad_len = 4 - (pld_len % 4); in bnx2i_process_text_resp()
1540 bnx2i_conn->gen_pdu.resp_wr_ptr[0] = 0; in bnx2i_process_text_resp()
1541 bnx2i_conn->gen_pdu.resp_wr_ptr++; in bnx2i_process_text_resp()
1545 bnx2i_conn->gen_pdu.resp_buf, in bnx2i_process_text_resp()
1546 bnx2i_conn->gen_pdu.resp_wr_ptr - in bnx2i_process_text_resp()
1547 bnx2i_conn->gen_pdu.resp_buf); in bnx2i_process_text_resp()
1549 spin_unlock(&session->back_lock); in bnx2i_process_text_resp()
1555 * bnx2i_process_tmf_resp - this function handles iscsi TMF response
1566 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_process_tmf_resp()
1572 spin_lock(&session->back_lock); in bnx2i_process_tmf_resp()
1574 tmf_cqe->itt & ISCSI_TMF_RESPONSE_INDEX); in bnx2i_process_tmf_resp()
1578 resp_hdr = (struct iscsi_tm_rsp *) &bnx2i_conn->gen_pdu.resp_hdr; in bnx2i_process_tmf_resp()
1580 resp_hdr->opcode = tmf_cqe->op_code; in bnx2i_process_tmf_resp()
1581 resp_hdr->max_cmdsn = cpu_to_be32(tmf_cqe->max_cmd_sn); in bnx2i_process_tmf_resp()
1582 resp_hdr->exp_cmdsn = cpu_to_be32(tmf_cqe->exp_cmd_sn); in bnx2i_process_tmf_resp()
1583 resp_hdr->itt = task->hdr->itt; in bnx2i_process_tmf_resp()
1584 resp_hdr->response = tmf_cqe->response; in bnx2i_process_tmf_resp()
1588 spin_unlock(&session->back_lock); in bnx2i_process_tmf_resp()
1593 * bnx2i_process_logout_resp - this function handles iscsi logout response
1605 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_process_logout_resp()
1611 spin_lock(&session->back_lock); in bnx2i_process_logout_resp()
1613 logout->itt & ISCSI_LOGOUT_RESPONSE_INDEX); in bnx2i_process_logout_resp()
1617 resp_hdr = (struct iscsi_logout_rsp *) &bnx2i_conn->gen_pdu.resp_hdr; in bnx2i_process_logout_resp()
1619 resp_hdr->opcode = logout->op_code; in bnx2i_process_logout_resp()
1620 resp_hdr->flags = logout->response; in bnx2i_process_logout_resp()
1621 resp_hdr->hlength = 0; in bnx2i_process_logout_resp()
1623 resp_hdr->itt = task->hdr->itt; in bnx2i_process_logout_resp()
1624 resp_hdr->statsn = task->hdr->exp_statsn; in bnx2i_process_logout_resp()
1625 resp_hdr->exp_cmdsn = cpu_to_be32(logout->exp_cmd_sn); in bnx2i_process_logout_resp()
1626 resp_hdr->max_cmdsn = cpu_to_be32(logout->max_cmd_sn); in bnx2i_process_logout_resp()
1628 resp_hdr->t2wait = cpu_to_be32(logout->time_to_wait); in bnx2i_process_logout_resp()
1629 resp_hdr->t2retain = cpu_to_be32(logout->time_to_retain); in bnx2i_process_logout_resp()
1633 bnx2i_conn->ep->state = EP_STATE_LOGOUT_RESP_RCVD; in bnx2i_process_logout_resp()
1635 spin_unlock(&session->back_lock); in bnx2i_process_logout_resp()
1640 * bnx2i_process_nopin_local_cmpl - this function handles iscsi nopin CQE
1651 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_process_nopin_local_cmpl()
1656 spin_lock(&session->back_lock); in bnx2i_process_nopin_local_cmpl()
1658 nop_in->itt & ISCSI_NOP_IN_MSG_INDEX); in bnx2i_process_nopin_local_cmpl()
1661 spin_unlock(&session->back_lock); in bnx2i_process_nopin_local_cmpl()
1665 * bnx2i_unsol_pdu_adjust_rq - makes adjustments to RQ after unsol pdu is recvd
1681 * bnx2i_process_nopin_mesg - this function handles iscsi nopin CQE
1692 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_process_nopin_mesg()
1700 spin_lock(&session->back_lock); in bnx2i_process_nopin_mesg()
1701 hdr = (struct iscsi_nopin *)&bnx2i_conn->gen_pdu.resp_hdr; in bnx2i_process_nopin_mesg()
1703 hdr->opcode = nop_in->op_code; in bnx2i_process_nopin_mesg()
1704 hdr->max_cmdsn = cpu_to_be32(nop_in->max_cmd_sn); in bnx2i_process_nopin_mesg()
1705 hdr->exp_cmdsn = cpu_to_be32(nop_in->exp_cmd_sn); in bnx2i_process_nopin_mesg()
1706 hdr->ttt = cpu_to_be32(nop_in->ttt); in bnx2i_process_nopin_mesg()
1708 if (nop_in->itt == (u16) RESERVED_ITT) { in bnx2i_process_nopin_mesg()
1710 hdr->itt = RESERVED_ITT; in bnx2i_process_nopin_mesg()
1715 /* this is a response to one of our nop-outs */ in bnx2i_process_nopin_mesg()
1717 (itt_t) (nop_in->itt & ISCSI_NOP_IN_MSG_INDEX)); in bnx2i_process_nopin_mesg()
1719 hdr->flags = ISCSI_FLAG_CMD_FINAL; in bnx2i_process_nopin_mesg()
1720 hdr->itt = task->hdr->itt; in bnx2i_process_nopin_mesg()
1721 hdr->ttt = cpu_to_be32(nop_in->ttt); in bnx2i_process_nopin_mesg()
1722 memcpy(&hdr->lun, nop_in->lun, 8); in bnx2i_process_nopin_mesg()
1726 spin_unlock(&session->back_lock); in bnx2i_process_nopin_mesg()
1733 * bnx2i_process_async_mesg - this function handles iscsi async message
1751 async_event = async_cqe->async_event; in bnx2i_process_async_mesg()
1754 iscsi_conn_printk(KERN_ALERT, bnx2i_conn->cls_conn->dd_data, in bnx2i_process_async_mesg()
1759 spin_lock(&session->back_lock); in bnx2i_process_async_mesg()
1760 resp_hdr = (struct iscsi_async *) &bnx2i_conn->gen_pdu.resp_hdr; in bnx2i_process_async_mesg()
1762 resp_hdr->opcode = async_cqe->op_code; in bnx2i_process_async_mesg()
1763 resp_hdr->flags = 0x80; in bnx2i_process_async_mesg()
1765 memcpy(&resp_hdr->lun, async_cqe->lun, 8); in bnx2i_process_async_mesg()
1766 resp_hdr->exp_cmdsn = cpu_to_be32(async_cqe->exp_cmd_sn); in bnx2i_process_async_mesg()
1767 resp_hdr->max_cmdsn = cpu_to_be32(async_cqe->max_cmd_sn); in bnx2i_process_async_mesg()
1769 resp_hdr->async_event = async_cqe->async_event; in bnx2i_process_async_mesg()
1770 resp_hdr->async_vcode = async_cqe->async_vcode; in bnx2i_process_async_mesg()
1772 resp_hdr->param1 = cpu_to_be16(async_cqe->param1); in bnx2i_process_async_mesg()
1773 resp_hdr->param2 = cpu_to_be16(async_cqe->param2); in bnx2i_process_async_mesg()
1774 resp_hdr->param3 = cpu_to_be16(async_cqe->param3); in bnx2i_process_async_mesg()
1776 __iscsi_complete_pdu(bnx2i_conn->cls_conn->dd_data, in bnx2i_process_async_mesg()
1778 spin_unlock(&session->back_lock); in bnx2i_process_async_mesg()
1783 * bnx2i_process_reject_mesg - process iscsi reject pdu
1794 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_process_reject_mesg()
1799 if (reject->data_length) { in bnx2i_process_reject_mesg()
1800 bnx2i_get_rq_buf(bnx2i_conn, conn->data, reject->data_length); in bnx2i_process_reject_mesg()
1805 spin_lock(&session->back_lock); in bnx2i_process_reject_mesg()
1806 hdr = (struct iscsi_reject *) &bnx2i_conn->gen_pdu.resp_hdr; in bnx2i_process_reject_mesg()
1808 hdr->opcode = reject->op_code; in bnx2i_process_reject_mesg()
1809 hdr->reason = reject->reason; in bnx2i_process_reject_mesg()
1810 hton24(hdr->dlength, reject->data_length); in bnx2i_process_reject_mesg()
1811 hdr->max_cmdsn = cpu_to_be32(reject->max_cmd_sn); in bnx2i_process_reject_mesg()
1812 hdr->exp_cmdsn = cpu_to_be32(reject->exp_cmd_sn); in bnx2i_process_reject_mesg()
1813 hdr->ffffffff = cpu_to_be32(RESERVED_ITT); in bnx2i_process_reject_mesg()
1814 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, conn->data, in bnx2i_process_reject_mesg()
1815 reject->data_length); in bnx2i_process_reject_mesg()
1816 spin_unlock(&session->back_lock); in bnx2i_process_reject_mesg()
1820 * bnx2i_process_cmd_cleanup_resp - process scsi command clean-up completion
1832 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_process_cmd_cleanup_resp()
1836 spin_lock(&session->back_lock); in bnx2i_process_cmd_cleanup_resp()
1838 cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX); in bnx2i_process_cmd_cleanup_resp()
1841 cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX); in bnx2i_process_cmd_cleanup_resp()
1842 spin_unlock(&session->back_lock); in bnx2i_process_cmd_cleanup_resp()
1843 complete(&bnx2i_conn->cmd_cleanup_cmpl); in bnx2i_process_cmd_cleanup_resp()
1848 * bnx2i_percpu_io_thread - thread per cpu for ios
1861 spin_lock_bh(&p->p_work_lock); in bnx2i_percpu_io_thread()
1862 while (!list_empty(&p->work_list)) { in bnx2i_percpu_io_thread()
1863 list_splice_init(&p->work_list, &work_list); in bnx2i_percpu_io_thread()
1864 spin_unlock_bh(&p->p_work_lock); in bnx2i_percpu_io_thread()
1867 list_del_init(&work->list); in bnx2i_percpu_io_thread()
1869 bnx2i_process_scsi_cmd_resp(work->session, in bnx2i_percpu_io_thread()
1870 work->bnx2i_conn, in bnx2i_percpu_io_thread()
1871 &work->cqe); in bnx2i_percpu_io_thread()
1872 atomic_dec(&work->bnx2i_conn->work_cnt); in bnx2i_percpu_io_thread()
1875 spin_lock_bh(&p->p_work_lock); in bnx2i_percpu_io_thread()
1878 spin_unlock_bh(&p->p_work_lock); in bnx2i_percpu_io_thread()
1888 * bnx2i_queue_scsi_cmd_resp - queue cmd completion to the percpu thread
1898 * cpu_id gets recorded upon task_xmit. No out-of-order completion!
1910 spin_lock(&session->back_lock); in bnx2i_queue_scsi_cmd_resp()
1911 task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data, in bnx2i_queue_scsi_cmd_resp()
1912 cqe->itt & ISCSI_CMD_RESPONSE_INDEX); in bnx2i_queue_scsi_cmd_resp()
1913 if (!task || !task->sc) { in bnx2i_queue_scsi_cmd_resp()
1914 spin_unlock(&session->back_lock); in bnx2i_queue_scsi_cmd_resp()
1915 return -EINVAL; in bnx2i_queue_scsi_cmd_resp()
1917 sc = task->sc; in bnx2i_queue_scsi_cmd_resp()
1919 spin_unlock(&session->back_lock); in bnx2i_queue_scsi_cmd_resp()
1922 spin_lock(&p->p_work_lock); in bnx2i_queue_scsi_cmd_resp()
1923 if (unlikely(!p->iothread)) { in bnx2i_queue_scsi_cmd_resp()
1924 rc = -EINVAL; in bnx2i_queue_scsi_cmd_resp()
1930 INIT_LIST_HEAD(&bnx2i_work->list); in bnx2i_queue_scsi_cmd_resp()
1931 bnx2i_work->session = session; in bnx2i_queue_scsi_cmd_resp()
1932 bnx2i_work->bnx2i_conn = bnx2i_conn; in bnx2i_queue_scsi_cmd_resp()
1933 memcpy(&bnx2i_work->cqe, cqe, sizeof(struct cqe)); in bnx2i_queue_scsi_cmd_resp()
1934 list_add_tail(&bnx2i_work->list, &p->work_list); in bnx2i_queue_scsi_cmd_resp()
1935 atomic_inc(&bnx2i_conn->work_cnt); in bnx2i_queue_scsi_cmd_resp()
1936 wake_up_process(p->iothread); in bnx2i_queue_scsi_cmd_resp()
1937 spin_unlock(&p->p_work_lock); in bnx2i_queue_scsi_cmd_resp()
1940 rc = -ENOMEM; in bnx2i_queue_scsi_cmd_resp()
1942 spin_unlock(&p->p_work_lock); in bnx2i_queue_scsi_cmd_resp()
1950 * bnx2i_process_new_cqes - process newly DMA'ed CQE's
1957 struct iscsi_conn *conn = bnx2i_conn->cls_conn->dd_data; in bnx2i_process_new_cqes()
1958 struct iscsi_session *session = conn->session; in bnx2i_process_new_cqes()
1959 struct bnx2i_hba *hba = bnx2i_conn->hba; in bnx2i_process_new_cqes()
1965 if (bnx2i_conn->ep == NULL) in bnx2i_process_new_cqes()
1968 qp = &bnx2i_conn->ep->qp; in bnx2i_process_new_cqes()
1970 if (!qp->cq_virt) { in bnx2i_process_new_cqes()
1972 hba->netdev->name); in bnx2i_process_new_cqes()
1976 nopin = (struct bnx2i_nop_in_msg *) qp->cq_cons_qe; in bnx2i_process_new_cqes()
1977 if (nopin->cq_req_sn != qp->cqe_exp_seq_sn) in bnx2i_process_new_cqes()
1980 if (unlikely(test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags))) { in bnx2i_process_new_cqes()
1981 if (nopin->op_code == ISCSI_OP_NOOP_IN && in bnx2i_process_new_cqes()
1982 nopin->itt == (u16) RESERVED_ITT) { in bnx2i_process_new_cqes()
1984 "NOP-In detected for suspended " in bnx2i_process_new_cqes()
1986 hba->netdev->name); in bnx2i_process_new_cqes()
1994 switch (nopin->op_code) { in bnx2i_process_new_cqes()
2003 qp->cq_cons_qe); in bnx2i_process_new_cqes()
2007 qp->cq_cons_qe); in bnx2i_process_new_cqes()
2011 qp->cq_cons_qe); in bnx2i_process_new_cqes()
2015 qp->cq_cons_qe); in bnx2i_process_new_cqes()
2019 qp->cq_cons_qe)) in bnx2i_process_new_cqes()
2024 qp->cq_cons_qe); in bnx2i_process_new_cqes()
2028 qp->cq_cons_qe); in bnx2i_process_new_cqes()
2033 qp->cq_cons_qe); in bnx2i_process_new_cqes()
2037 qp->cq_cons_qe); in bnx2i_process_new_cqes()
2041 nopin->op_code); in bnx2i_process_new_cqes()
2045 ADD_STATS_64(hba, rx_bytes, nopin->data_length); in bnx2i_process_new_cqes()
2048 if (!atomic_read(&bnx2i_conn->ep->num_active_cmds)) in bnx2i_process_new_cqes()
2051 hba->netdev->name, in bnx2i_process_new_cqes()
2052 nopin->op_code); in bnx2i_process_new_cqes()
2054 atomic_dec(&bnx2i_conn->ep->num_active_cmds); in bnx2i_process_new_cqes()
2059 * nopin->op_code = 0; in bnx2i_process_new_cqes()
2062 qp->cqe_exp_seq_sn++; in bnx2i_process_new_cqes()
2063 if (qp->cqe_exp_seq_sn == (qp->cqe_size * 2 + 1)) in bnx2i_process_new_cqes()
2064 qp->cqe_exp_seq_sn = ISCSI_INITIAL_SN; in bnx2i_process_new_cqes()
2066 if (qp->cq_cons_qe == qp->cq_last_qe) { in bnx2i_process_new_cqes()
2067 qp->cq_cons_qe = qp->cq_first_qe; in bnx2i_process_new_cqes()
2068 qp->cq_cons_idx = 0; in bnx2i_process_new_cqes()
2070 qp->cq_cons_qe++; in bnx2i_process_new_cqes()
2071 qp->cq_cons_idx++; in bnx2i_process_new_cqes()
2079 * bnx2i_fastpath_notification - process global event queue (KCQ)
2093 iscsi_cid = new_cqe_kcqe->iscsi_conn_id; in bnx2i_fastpath_notification()
2100 if (!bnx2i_conn->ep) { in bnx2i_fastpath_notification()
2101 printk(KERN_ALERT "cid #%x - ep not bound\n", iscsi_cid); in bnx2i_fastpath_notification()
2106 nxt_idx = bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, in bnx2i_fastpath_notification()
2109 bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE_FP); in bnx2i_fastpath_notification()
2114 * bnx2i_process_update_conn_cmpl - process iscsi conn update completion KCQE
2126 iscsi_cid = update_kcqe->iscsi_conn_id; in bnx2i_process_update_conn_cmpl()
2133 if (!conn->ep) { in bnx2i_process_update_conn_cmpl()
2138 if (update_kcqe->completion_status) { in bnx2i_process_update_conn_cmpl()
2140 conn->ep->state = EP_STATE_ULP_UPDATE_FAILED; in bnx2i_process_update_conn_cmpl()
2142 conn->ep->state = EP_STATE_ULP_UPDATE_COMPL; in bnx2i_process_update_conn_cmpl()
2144 wake_up_interruptible(&conn->ep->ofld_wait); in bnx2i_process_update_conn_cmpl()
2149 * bnx2i_recovery_que_add_conn - add connection to recovery queue
2158 iscsi_conn_failure(bnx2i_conn->cls_conn->dd_data, in bnx2i_recovery_que_add_conn()
2164 * bnx2i_process_tcp_error - process error notification on a given connection
2177 iscsi_cid = tcp_err->iscsi_conn_id; in bnx2i_process_tcp_error()
2181 printk(KERN_ALERT "bnx2i - cid 0x%x not valid\n", iscsi_cid); in bnx2i_process_tcp_error()
2185 printk(KERN_ALERT "bnx2i - cid 0x%x had TCP errors, error code 0x%x\n", in bnx2i_process_tcp_error()
2186 iscsi_cid, tcp_err->completion_status); in bnx2i_process_tcp_error()
2187 bnx2i_recovery_que_add_conn(bnx2i_conn->hba, bnx2i_conn); in bnx2i_process_tcp_error()
2192 * bnx2i_process_iscsi_error - process error notification on a given connection
2202 * session, this is to avoid un-necessarily overloading the system)
2214 iscsi_cid = iscsi_err->iscsi_conn_id; in bnx2i_process_iscsi_error()
2217 printk(KERN_ALERT "bnx2i - cid 0x%x not valid\n", iscsi_cid); in bnx2i_process_iscsi_error()
2221 err_mask64 = (0x1ULL << iscsi_err->completion_status); in bnx2i_process_iscsi_error()
2231 switch (iscsi_err->completion_status) { in bnx2i_process_iscsi_error()
2284 additional_notice = "F-bit not set"; in bnx2i_process_iscsi_error()
2353 printk(KERN_ALERT "iscsi_err - unknown err %x\n", in bnx2i_process_iscsi_error()
2354 iscsi_err->completion_status); in bnx2i_process_iscsi_error()
2359 bnx2i_conn->cls_conn->dd_data, in bnx2i_process_iscsi_error()
2360 "bnx2i: %s - %s\n", in bnx2i_process_iscsi_error()
2364 bnx2i_conn->cls_conn->dd_data, in bnx2i_process_iscsi_error()
2365 "conn_err - hostno %d conn %p, " in bnx2i_process_iscsi_error()
2367 bnx2i_conn->hba->shost->host_no, in bnx2i_process_iscsi_error()
2368 bnx2i_conn, bnx2i_conn->ep->ep_iscsi_cid, in bnx2i_process_iscsi_error()
2369 bnx2i_conn->ep->ep_cid); in bnx2i_process_iscsi_error()
2370 bnx2i_recovery_que_add_conn(bnx2i_conn->hba, bnx2i_conn); in bnx2i_process_iscsi_error()
2372 if (!test_and_set_bit(iscsi_err->completion_status, in bnx2i_process_iscsi_error()
2373 (void *) &bnx2i_conn->violation_notified)) in bnx2i_process_iscsi_error()
2375 bnx2i_conn->cls_conn->dd_data, in bnx2i_process_iscsi_error()
2376 "bnx2i: %s - %s\n", in bnx2i_process_iscsi_error()
2382 * bnx2i_process_conn_destroy_cmpl - process iscsi conn destroy completion
2393 ep = bnx2i_find_ep_in_destroy_list(hba, conn_destroy->iscsi_conn_id); in bnx2i_process_conn_destroy_cmpl()
2400 if (hba != ep->hba) { in bnx2i_process_conn_destroy_cmpl()
2401 printk(KERN_ALERT "conn destroy- error hba mismatch\n"); in bnx2i_process_conn_destroy_cmpl()
2405 if (conn_destroy->completion_status) { in bnx2i_process_conn_destroy_cmpl()
2407 ep->state = EP_STATE_CLEANUP_FAILED; in bnx2i_process_conn_destroy_cmpl()
2409 ep->state = EP_STATE_CLEANUP_CMPL; in bnx2i_process_conn_destroy_cmpl()
2410 wake_up_interruptible(&ep->ofld_wait); in bnx2i_process_conn_destroy_cmpl()
2415 * bnx2i_process_ofld_cmpl - process initial iscsi conn offload completion
2420 * woken-up to continue with LLP connect process
2428 ep = bnx2i_find_ep_in_ofld_list(hba, ofld_kcqe->iscsi_conn_id); in bnx2i_process_ofld_cmpl()
2434 if (hba != ep->hba) { in bnx2i_process_ofld_cmpl()
2439 if (ofld_kcqe->completion_status) { in bnx2i_process_ofld_cmpl()
2440 ep->state = EP_STATE_OFLD_FAILED; in bnx2i_process_ofld_cmpl()
2441 if (ofld_kcqe->completion_status == in bnx2i_process_ofld_cmpl()
2443 printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - unable " in bnx2i_process_ofld_cmpl()
2445 hba->netdev->name); in bnx2i_process_ofld_cmpl()
2446 else if (ofld_kcqe->completion_status == in bnx2i_process_ofld_cmpl()
2448 printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid " in bnx2i_process_ofld_cmpl()
2449 "opcode\n", hba->netdev->name); in bnx2i_process_ofld_cmpl()
2450 else if (ofld_kcqe->completion_status == in bnx2i_process_ofld_cmpl()
2453 ep->state = EP_STATE_OFLD_FAILED_CID_BUSY; in bnx2i_process_ofld_cmpl()
2455 printk(KERN_ALERT "bnx2i (%s): ofld1 cmpl - invalid " in bnx2i_process_ofld_cmpl()
2456 "error code %d\n", hba->netdev->name, in bnx2i_process_ofld_cmpl()
2457 ofld_kcqe->completion_status); in bnx2i_process_ofld_cmpl()
2459 ep->state = EP_STATE_OFLD_COMPL; in bnx2i_process_ofld_cmpl()
2460 cid_addr = ofld_kcqe->iscsi_conn_context_id; in bnx2i_process_ofld_cmpl()
2461 ep->ep_cid = cid_addr; in bnx2i_process_ofld_cmpl()
2462 ep->qp.ctx_base = NULL; in bnx2i_process_ofld_cmpl()
2464 wake_up_interruptible(&ep->ofld_wait); in bnx2i_process_ofld_cmpl()
2468 * bnx2i_indicate_kcqe - process iscsi conn update completion KCQE
2485 if (ikcqe->op_code == in bnx2i_indicate_kcqe()
2488 else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_OFFLOAD_CONN) in bnx2i_indicate_kcqe()
2490 else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_UPDATE_CONN) in bnx2i_indicate_kcqe()
2492 else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_INIT) { in bnx2i_indicate_kcqe()
2493 if (ikcqe->completion_status != in bnx2i_indicate_kcqe()
2495 bnx2i_iscsi_license_error(hba, ikcqe->\ in bnx2i_indicate_kcqe()
2498 set_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2i_indicate_kcqe()
2502 (u8)hba->pcidev->bus->number, in bnx2i_indicate_kcqe()
2503 hba->pci_devno, in bnx2i_indicate_kcqe()
2504 (u8)hba->pci_func); in bnx2i_indicate_kcqe()
2508 } else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_DESTROY_CONN) in bnx2i_indicate_kcqe()
2510 else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_ISCSI_ERROR) in bnx2i_indicate_kcqe()
2512 else if (ikcqe->op_code == ISCSI_KCQE_OPCODE_TCP_ERROR) in bnx2i_indicate_kcqe()
2516 ikcqe->op_code); in bnx2i_indicate_kcqe()
2522 * bnx2i_indicate_netevent - Generic netdev event handler
2525 * @vlan_id: vlans id - associated vlan id with this event
2541 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) in bnx2i_indicate_netevent()
2545 clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); in bnx2i_indicate_netevent()
2546 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2i_indicate_netevent()
2549 set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); in bnx2i_indicate_netevent()
2550 iscsi_host_for_each_session(hba->shost, in bnx2i_indicate_netevent()
2563 * bnx2i_cm_connect_cmpl - process iscsi conn establishment completion
2566 * function callback exported via bnx2i - cnic driver interface to
2567 * indicate completion of option-2 TCP connect request.
2571 struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context; in bnx2i_cm_connect_cmpl()
2573 if (test_bit(ADAPTER_STATE_GOING_DOWN, &ep->hba->adapter_state)) in bnx2i_cm_connect_cmpl()
2574 ep->state = EP_STATE_CONNECT_FAILED; in bnx2i_cm_connect_cmpl()
2575 else if (test_bit(SK_F_OFFLD_COMPLETE, &cm_sk->flags)) in bnx2i_cm_connect_cmpl()
2576 ep->state = EP_STATE_CONNECT_COMPL; in bnx2i_cm_connect_cmpl()
2578 ep->state = EP_STATE_CONNECT_FAILED; in bnx2i_cm_connect_cmpl()
2580 wake_up_interruptible(&ep->ofld_wait); in bnx2i_cm_connect_cmpl()
2585 * bnx2i_cm_close_cmpl - process tcp conn close completion
2588 * function callback exported via bnx2i - cnic driver interface to
2589 * indicate completion of option-2 graceful TCP connect shutdown
2593 struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context; in bnx2i_cm_close_cmpl()
2595 ep->state = EP_STATE_DISCONN_COMPL; in bnx2i_cm_close_cmpl()
2596 wake_up_interruptible(&ep->ofld_wait); in bnx2i_cm_close_cmpl()
2601 * bnx2i_cm_abort_cmpl - process abortive tcp conn teardown completion
2604 * function callback exported via bnx2i - cnic driver interface to
2605 * indicate completion of option-2 abortive TCP connect termination
2609 struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context; in bnx2i_cm_abort_cmpl()
2611 ep->state = EP_STATE_DISCONN_COMPL; in bnx2i_cm_abort_cmpl()
2612 wake_up_interruptible(&ep->ofld_wait); in bnx2i_cm_abort_cmpl()
2617 * bnx2i_cm_remote_close - process received TCP FIN
2620 * function callback exported via bnx2i - cnic driver interface to indicate
2625 struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context; in bnx2i_cm_remote_close()
2627 ep->state = EP_STATE_TCP_FIN_RCVD; in bnx2i_cm_remote_close()
2628 if (ep->conn) in bnx2i_cm_remote_close()
2629 bnx2i_recovery_que_add_conn(ep->hba, ep->conn); in bnx2i_cm_remote_close()
2633 * bnx2i_cm_remote_abort - process TCP RST and start conn cleanup
2636 * function callback exported via bnx2i - cnic driver interface to
2641 struct bnx2i_endpoint *ep = (struct bnx2i_endpoint *) cm_sk->context; in bnx2i_cm_remote_abort()
2642 u32 old_state = ep->state; in bnx2i_cm_remote_abort()
2644 ep->state = EP_STATE_TCP_RST_RCVD; in bnx2i_cm_remote_abort()
2646 wake_up_interruptible(&ep->ofld_wait); in bnx2i_cm_remote_abort()
2648 if (ep->conn) in bnx2i_cm_remote_abort()
2649 bnx2i_recovery_que_add_conn(ep->hba, ep->conn); in bnx2i_cm_remote_abort()
2660 return -ENODEV; in bnx2i_send_nl_mesg()
2662 rc = iscsi_offload_mesg(hba->shost, &bnx2i_iscsi_transport, in bnx2i_send_nl_mesg()
2672 * bnx2i_cnic_cb - global template of bnx2i - cnic driver interface structure
2694 * bnx2i_map_ep_dbell_regs - map connection doorbell registers
2712 if (test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type)) { in bnx2i_map_ep_dbell_regs()
2713 reg_base = pci_resource_start(ep->hba->pcidev, in bnx2i_map_ep_dbell_regs()
2716 ep->qp.ctx_base = ioremap(reg_base + reg_off, 4); in bnx2i_map_ep_dbell_regs()
2717 if (!ep->qp.ctx_base) in bnx2i_map_ep_dbell_regs()
2718 return -ENOMEM; in bnx2i_map_ep_dbell_regs()
2722 if ((test_bit(BNX2I_NX2_DEV_5709, &ep->hba->cnic_dev_type)) && in bnx2i_map_ep_dbell_regs()
2723 (ep->hba->mail_queue_access == BNX2I_MQ_BIN_MODE)) { in bnx2i_map_ep_dbell_regs()
2724 config2 = REG_RD(ep->hba, BNX2_MQ_CONFIG2); in bnx2i_map_ep_dbell_regs()
2730 (((cid_num - first_l4l5) / ctx_sz) + 256); in bnx2i_map_ep_dbell_regs()
2737 ep->qp.ctx_base = ioremap(ep->hba->reg_base + reg_off, in bnx2i_map_ep_dbell_regs()
2739 if (!ep->qp.ctx_base) in bnx2i_map_ep_dbell_regs()
2740 return -ENOMEM; in bnx2i_map_ep_dbell_regs()