48 u32 num_elements_per_pg;
65 if (hba->
max_sqes < num_elements_per_pg)
67 else if (hba->
max_sqes % num_elements_per_pg)
69 ~(num_elements_per_pg - 1);
73 if (hba->
max_cqes < num_elements_per_pg)
75 else if (hba->
max_cqes % num_elements_per_pg)
77 ~(num_elements_per_pg - 1);
81 if (hba->
max_rqes < num_elements_per_pg)
83 else if (hba->
max_rqes % num_elements_per_pg)
85 ~(num_elements_per_pg - 1);
95 static void bnx2i_get_link_state(
struct bnx2i_hba *hba)
121 "offload iSCSI connections, dev=%s\n",
154 if (cq_db->
sqn[0] && cq_db->
sqn[0] != 0xFFFF)
162 next_index = num_active_cmds >> ep->
ec_shift;
168 cq_index = ep->
qp.cqe_exp_seq_sn + next_index - 1;
169 if (cq_index > ep->
qp.cqe_size * 2)
170 cq_index -= ep->
qp.cqe_size * 2;
174 cq_db->
sqn[0] = cq_index;
193 if (!bnx2i_conn->
ep->qp.rqe_left)
196 bnx2i_conn->
ep->qp.rqe_left--;
197 memcpy(ptr, (
u8 *) bnx2i_conn->
ep->qp.rq_cons_qe, len);
198 if (bnx2i_conn->
ep->qp.rq_cons_qe == bnx2i_conn->
ep->qp.rq_last_qe) {
199 bnx2i_conn->
ep->qp.rq_cons_qe = bnx2i_conn->
ep->qp.rq_first_qe;
200 bnx2i_conn->
ep->qp.rq_cons_idx = 0;
202 bnx2i_conn->
ep->qp.rq_cons_qe++;
203 bnx2i_conn->
ep->qp.rq_cons_idx++;
208 static void bnx2i_ring_577xx_doorbell(
struct bnx2i_conn *conn)
232 u16 hi_bit = (bnx2i_conn->
ep->qp.rq_prod_idx & 0x8000);
236 ep->
qp.rq_prod_idx &= 0x7FFF;
239 if (ep->
qp.rq_prod_idx > bnx2i_conn->
hba->max_rqes) {
240 ep->
qp.rq_prod_idx %= bnx2i_conn->
hba->max_rqes;
242 ep->
qp.rq_prod_idx |= 0x8000;
244 ep->
qp.rq_prod_idx |= hi_bit;
252 ep->
qp.ctx_base + CNIC_RECV_DOORBELL);
277 bnx2i_ring_577xx_doorbell(bnx2i_conn);
279 writew(count, ep->
qp.ctx_base + CNIC_SEND_DOORBELL);
292 static void bnx2i_ring_dbell_update_sq_params(
struct bnx2i_conn *bnx2i_conn,
298 if (bnx2i_conn->
ep->qp.sq_prod_qe ==
299 bnx2i_conn->
ep->qp.sq_last_qe)
300 bnx2i_conn->
ep->qp.sq_prod_qe =
301 bnx2i_conn->
ep->qp.sq_first_qe;
303 bnx2i_conn->
ep->qp.sq_prod_qe++;
305 if ((bnx2i_conn->
ep->qp.sq_prod_qe + count) <=
306 bnx2i_conn->
ep->qp.sq_last_qe)
307 bnx2i_conn->
ep->qp.sq_prod_qe +=
count;
309 tmp_cnt = bnx2i_conn->
ep->qp.sq_last_qe -
310 bnx2i_conn->
ep->qp.sq_prod_qe;
311 bnx2i_conn->
ep->qp.sq_prod_qe =
312 &bnx2i_conn->
ep->qp.sq_first_qe[count -
316 bnx2i_conn->
ep->qp.sq_prod_idx +=
count;
318 bnx2i_ring_sq_dbell(bnx2i_conn, bnx2i_conn->
ep->qp.sq_prod_idx);
338 bnx2i_cmd = (
struct bnx2i_cmd *)task->
dd_data;
341 bnx2i_conn->
ep->qp.sq_prod_qe;
343 login_wqe->op_code = login_hdr->
opcode;
344 login_wqe->op_attr = login_hdr->
flags;
349 login_wqe->isid_hi = *((
u16 *) login_hdr->
isid + 2);
350 login_wqe->tsih = login_hdr->
tsih;
351 login_wqe->itt = task->
itt |
353 login_wqe->cid = login_hdr->
cid;
357 login_wqe->flags = ISCSI_LOGIN_REQUEST_UPDATE_EXP_STAT_SN;
364 (bnx2i_conn->
gen_pdu.resp_buf_size <<
370 login_wqe->num_bds = 1;
371 login_wqe->cq_index = 0;
373 bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1);
397 bnx2i_cmd = (
struct bnx2i_cmd *)mtask->
dd_data;
400 bnx2i_conn->
ep->qp.sq_prod_qe;
402 tmfabort_wqe->op_code = tmfabort_hdr->
opcode;
403 tmfabort_wqe->op_attr = tmfabort_hdr->
flags;
413 if (!ctask || !ctask->
sc)
427 ISCSI_CMD_REQUEST_TYPE_SHIFT);
430 ISCSI_CMD_REQUEST_TYPE_SHIFT);
431 tmfabort_wqe->
ref_itt = (dword |
437 memcpy(scsi_lun, &tmfabort_hdr->
lun,
sizeof(
struct scsi_lun));
445 ((
u64) bnx2i_conn->
hba->mp_bd_dma >> 32);
446 tmfabort_wqe->num_bds = 1;
447 tmfabort_wqe->cq_index = 0;
449 bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1);
469 bnx2i_cmd = (
struct bnx2i_cmd *)mtask->
dd_data;
475 text_wqe->op_code = text_hdr->
opcode;
476 text_wqe->op_attr = text_hdr->
flags;
478 text_wqe->itt = mtask->
itt |
489 (bnx2i_conn->
gen_pdu.resp_buf_size <<
495 text_wqe->num_bds = 1;
496 text_wqe->cq_index = 0;
498 bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1);
517 bnx2i_conn->
ep->qp.sq_prod_qe;
519 scsi_cmd_wqe->cq_index = 0;
521 bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1);
539 char *datap,
int data_len,
int unsol)
546 bnx2i_cmd = (
struct bnx2i_cmd *)task->
dd_data;
552 nopout_wqe->op_code = nopout_hdr->
opcode;
559 nopout_wqe->
lun[0] = nopout_wqe->
lun[1];
563 nopout_wqe->itt = ((
u16)task->
itt |
565 ISCSI_TMF_REQUEST_TYPE_SHIFT));
567 nopout_wqe->flags = 0;
569 nopout_wqe->flags = ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION;
571 nopout_wqe->flags = ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION;
580 bnx2i_conn->
hba->mp_bd_dma;
582 (
u32) ((
u64) bnx2i_conn->
hba->mp_bd_dma >> 32);
583 nopout_wqe->num_bds = 1;
585 nopout_wqe->cq_index = 0;
587 bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1);
607 bnx2i_cmd = (
struct bnx2i_cmd *)task->
dd_data;
611 bnx2i_conn->
ep->qp.sq_prod_qe;
614 logout_wqe->op_code = logout_hdr->
opcode;
616 logout_wqe->op_attr =
617 logout_hdr->
flags | ISCSI_LOGOUT_REQUEST_ALWAYS_ONE;
618 logout_wqe->itt = ((
u16)task->
itt |
620 ISCSI_LOGOUT_REQUEST_TYPE_SHIFT));
626 ((
u64) bnx2i_conn->
hba->mp_bd_dma >> 32);
627 logout_wqe->num_bds = 1;
628 logout_wqe->cq_index = 0;
632 bnx2i_ring_dbell_update_sq_params(bnx2i_conn, 1);
645 struct bnx2i_conn *bnx2i_conn = conn->
dd_data;
647 struct kwqe *kwqe_arr[2];
651 update_wqe = &conn_update_kwqe;
654 update_wqe->hdr.flags =
659 update_wqe->context_id = bnx2i_conn->
ep->ep_cid;
661 update_wqe->context_id = (bnx2i_conn->
ep->ep_cid >> 7);
662 update_wqe->conn_flags = 0;
664 update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_HEADER_DIGEST;
666 update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_DATA_DIGEST;
667 if (conn->
session->initial_r2t_en)
668 update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_INITIAL_R2T;
669 if (conn->
session->imm_data_en)
670 update_wqe->conn_flags |= ISCSI_KWQE_CONN_UPDATE_IMMEDIATE_DATA;
674 update_wqe->first_burst_length = conn->
session->first_burst;
675 update_wqe->max_burst_length = conn->
session->max_burst;
677 update_wqe->max_outstanding_r2ts = conn->
session->max_r2t;
678 update_wqe->session_error_recovery_level = conn->
session->erl;
680 "bnx2i: conn update - MBL 0x%x FBL 0x%x"
681 "MRDSL_I 0x%x MRDSL_T 0x%x \n",
682 update_wqe->max_burst_length,
683 update_wqe->first_burst_length,
684 update_wqe->max_recv_pdu_length,
685 update_wqe->max_send_pdu_length);
687 kwqe_arr[0] = (
struct kwqe *) update_wqe;
688 if (hba->
cnic && hba->
cnic->submit_kwqes)
689 hba->
cnic->submit_kwqes(hba->
cnic, kwqe_arr, 1);
718 static int bnx2i_power_of2(
u32 val)
749 cmd_cleanup->itt = cmd->
req.itt;
750 cmd_cleanup->cq_index = 0;
752 bnx2i_ring_dbell_update_sq_params(cmd->
conn, 1);
766 struct kwqe *kwqe_arr[2];
773 conn_cleanup.hdr.flags =
781 conn_cleanup.reserved0 = (
u16)ep->ep_iscsi_cid;
783 kwqe_arr[0] = (
struct kwqe *) &conn_cleanup;
784 if (hba->
cnic && hba->
cnic->submit_kwqes)
785 rc = hba->
cnic->submit_kwqes(hba->
cnic, kwqe_arr, 1);
798 static int bnx2i_570x_send_conn_ofld_req(
struct bnx2i_hba *hba,
801 struct kwqe *kwqe_arr[2];
810 ofld_req1.hdr.flags =
813 ofld_req1.iscsi_conn_id = (
u16) ep->ep_iscsi_cid;
815 dma_addr = ep->
qp.sq_pgtbl_phys;
817 ofld_req1.sq_page_table_addr_hi = (
u32) ((
u64) dma_addr >> 32);
819 dma_addr = ep->
qp.cq_pgtbl_phys;
820 ofld_req1.cq_page_table_addr_lo = (
u32) dma_addr;
821 ofld_req1.cq_page_table_addr_hi = (
u32) ((
u64) dma_addr >> 32);
824 ofld_req2.hdr.flags =
827 dma_addr = ep->
qp.rq_pgtbl_phys;
828 ofld_req2.rq_page_table_addr_lo = (
u32) dma_addr;
829 ofld_req2.rq_page_table_addr_hi = (
u32) ((
u64) dma_addr >> 32);
831 ptbl = (
u32 *) ep->
qp.sq_pgtbl_virt;
833 ofld_req2.sq_first_pte.hi = *ptbl++;
834 ofld_req2.sq_first_pte.lo = *ptbl;
836 ptbl = (
u32 *) ep->
qp.cq_pgtbl_virt;
837 ofld_req2.cq_first_pte.hi = *ptbl++;
838 ofld_req2.cq_first_pte.lo = *ptbl;
840 kwqe_arr[0] = (
struct kwqe *) &ofld_req1;
841 kwqe_arr[1] = (
struct kwqe *) &ofld_req2;
842 ofld_req2.num_additional_wqes = 0;
844 if (hba->
cnic && hba->
cnic->submit_kwqes)
845 rc = hba->
cnic->submit_kwqes(hba->
cnic, kwqe_arr, num_kwqes);
858 static int bnx2i_5771x_send_conn_ofld_req(
struct bnx2i_hba *hba,
861 struct kwqe *kwqe_arr[5];
871 ofld_req1.hdr.flags =
874 ofld_req1.iscsi_conn_id = (
u16) ep->ep_iscsi_cid;
878 ofld_req1.sq_page_table_addr_hi = (
u32) ((
u64) dma_addr >> 32);
881 ofld_req1.cq_page_table_addr_lo = (
u32) dma_addr;
882 ofld_req1.cq_page_table_addr_hi = (
u32) ((
u64) dma_addr >> 32);
885 ofld_req2.hdr.flags =
889 ofld_req2.rq_page_table_addr_lo = (
u32) dma_addr;
890 ofld_req2.rq_page_table_addr_hi = (
u32) ((
u64) dma_addr >> 32);
893 ofld_req2.sq_first_pte.hi = *ptbl++;
894 ofld_req2.sq_first_pte.lo = *ptbl;
897 ofld_req2.cq_first_pte.hi = *ptbl++;
898 ofld_req2.cq_first_pte.lo = *ptbl;
900 kwqe_arr[0] = (
struct kwqe *) &ofld_req1;
901 kwqe_arr[1] = (
struct kwqe *) &ofld_req2;
903 ofld_req2.num_additional_wqes = 1;
904 memset(ofld_req3, 0x00,
sizeof(ofld_req3[0]));
906 ofld_req3[0].qp_first_pte[0].hi = *ptbl++;
907 ofld_req3[0].qp_first_pte[0].lo = *ptbl;
909 kwqe_arr[2] = (
struct kwqe *) ofld_req3;
913 if (hba->
cnic && hba->
cnic->submit_kwqes)
914 rc = hba->
cnic->submit_kwqes(hba->
cnic, kwqe_arr, num_kwqes);
932 rc = bnx2i_5771x_send_conn_ofld_req(hba, ep);
934 rc = bnx2i_570x_send_conn_ofld_req(hba, ep);
961 memset(ep->
qp.sq_pgtbl_virt, 0, ep->
qp.sq_pgtbl_size);
963 page = ep->
qp.sq_phys;
968 ptbl = (
u32 *) ep->
qp.sq_pgtbl_virt;
969 while (num_pages--) {
974 *ptbl = (
u32) ((
u64) page >> 32);
980 *ptbl = (
u32) ((
u64) page >> 32);
989 memset(ep->
qp.rq_pgtbl_virt, 0, ep->
qp.rq_pgtbl_size);
991 page = ep->
qp.rq_phys;
996 ptbl = (
u32 *) ep->
qp.rq_pgtbl_virt;
997 while (num_pages--) {
1002 *ptbl = (
u32) ((
u64) page >> 32);
1008 *ptbl = (
u32) ((
u64) page >> 32);
1017 memset(ep->
qp.cq_pgtbl_virt, 0, ep->
qp.cq_pgtbl_size);
1019 page = ep->
qp.cq_phys;
1024 ptbl = (
u32 *) ep->
qp.cq_pgtbl_virt;
1025 while (num_pages--) {
1030 *ptbl = (
u32) ((
u64) page >> 32);
1036 *ptbl = (
u32) ((
u64) page >> 32);
1062 ep->ep_cid = ep->ep_iscsi_cid = ep->ep_pg_cid = 0;
1066 ep->
qp.sq_mem_size =
1068 ep->
qp.sq_pgtbl_size =
1069 (ep->
qp.sq_mem_size /
PAGE_SIZE) *
sizeof(
void *);
1070 ep->
qp.sq_pgtbl_size =
1073 ep->
qp.sq_pgtbl_virt =
1076 if (!ep->
qp.sq_pgtbl_virt) {
1078 ep->
qp.sq_pgtbl_size);
1086 if (!ep->
qp.sq_virt) {
1088 ep->
qp.sq_mem_size);
1092 memset(ep->
qp.sq_virt, 0x00, ep->
qp.sq_mem_size);
1093 ep->
qp.sq_first_qe = ep->
qp.sq_virt;
1094 ep->
qp.sq_prod_qe = ep->
qp.sq_first_qe;
1095 ep->
qp.sq_cons_qe = ep->
qp.sq_first_qe;
1096 ep->
qp.sq_last_qe = &ep->
qp.sq_first_qe[hba->
max_sqes - 1];
1097 ep->
qp.sq_prod_idx = 0;
1098 ep->
qp.sq_cons_idx = 0;
1103 ep->
qp.cq_mem_size =
1105 ep->
qp.cq_pgtbl_size =
1106 (ep->
qp.cq_mem_size /
PAGE_SIZE) *
sizeof(
void *);
1107 ep->
qp.cq_pgtbl_size =
1110 ep->
qp.cq_pgtbl_virt =
1113 if (!ep->
qp.cq_pgtbl_virt) {
1115 ep->
qp.cq_pgtbl_size);
1123 if (!ep->
qp.cq_virt) {
1125 ep->
qp.cq_mem_size);
1128 memset(ep->
qp.cq_virt, 0x00, ep->
qp.cq_mem_size);
1130 ep->
qp.cq_first_qe = ep->
qp.cq_virt;
1131 ep->
qp.cq_prod_qe = ep->
qp.cq_first_qe;
1132 ep->
qp.cq_cons_qe = ep->
qp.cq_first_qe;
1133 ep->
qp.cq_last_qe = &ep->
qp.cq_first_qe[hba->
max_cqes - 1];
1134 ep->
qp.cq_prod_idx = 0;
1135 ep->
qp.cq_cons_idx = 0;
1146 ep->
qp.rq_mem_size =
1148 ep->
qp.rq_pgtbl_size =
1149 (ep->
qp.rq_mem_size /
PAGE_SIZE) *
sizeof(
void *);
1150 ep->
qp.rq_pgtbl_size =
1153 ep->
qp.rq_pgtbl_virt =
1156 if (!ep->
qp.rq_pgtbl_virt) {
1158 ep->
qp.rq_pgtbl_size);
1166 if (!ep->
qp.rq_virt) {
1168 ep->
qp.rq_mem_size);
1172 ep->
qp.rq_first_qe = ep->
qp.rq_virt;
1173 ep->
qp.rq_prod_qe = ep->
qp.rq_first_qe;
1174 ep->
qp.rq_cons_qe = ep->
qp.rq_first_qe;
1175 ep->
qp.rq_last_qe = &ep->
qp.rq_first_qe[hba->
max_rqes - 1];
1176 ep->
qp.rq_prod_idx = 0x8000;
1177 ep->
qp.rq_cons_idx = 0;
1180 setup_qp_page_tables(ep);
1200 if (ep->
qp.ctx_base) {
1205 if (ep->
qp.sq_pgtbl_virt) {
1207 ep->
qp.sq_pgtbl_virt, ep->
qp.sq_pgtbl_phys);
1208 ep->
qp.sq_pgtbl_virt =
NULL;
1209 ep->
qp.sq_pgtbl_phys = 0;
1211 if (ep->
qp.sq_virt) {
1213 ep->
qp.sq_virt, ep->
qp.sq_phys);
1219 if (ep->
qp.rq_pgtbl_virt) {
1221 ep->
qp.rq_pgtbl_virt, ep->
qp.rq_pgtbl_phys);
1222 ep->
qp.rq_pgtbl_virt =
NULL;
1223 ep->
qp.rq_pgtbl_phys = 0;
1225 if (ep->
qp.rq_virt) {
1227 ep->
qp.rq_virt, ep->
qp.rq_phys);
1233 if (ep->
qp.cq_pgtbl_virt) {
1235 ep->
qp.cq_pgtbl_virt, ep->
qp.cq_pgtbl_phys);
1236 ep->
qp.cq_pgtbl_virt =
NULL;
1237 ep->
qp.cq_pgtbl_phys = 0;
1239 if (ep->
qp.cq_virt) {
1241 ep->
qp.cq_virt, ep->
qp.cq_phys);
1261 struct kwqe *kwqe_arr[3];
1270 bnx2i_adjust_qp_size(hba);
1275 iscsi_init.flags |= ISCSI_KWQE_INIT1_DELAYED_ACK_ENABLE;
1276 iscsi_init.reserved0 = 0;
1277 iscsi_init.num_cqs = 1;
1279 iscsi_init.hdr.flags =
1289 iscsi_init.num_ccells_per_conn = hba->
num_ccell;
1290 iscsi_init.num_tasks_per_conn = hba->
max_sqes;
1292 iscsi_init.sq_num_wqes = hba->
max_sqes;
1293 iscsi_init.cq_log_wqes_per_page =
1295 iscsi_init.cq_num_wqes = hba->
max_cqes;
1301 iscsi_init.rq_num_wqes = hba->
max_rqes;
1305 iscsi_init2.hdr.flags =
1307 iscsi_init2.max_cq_sqn = hba->
max_cqes * 2 + 1;
1320 mask64 &= (
u32)(~mask64);
1327 mask64 &= 0xffffffff;
1334 kwqe_arr[0] = (
struct kwqe *) &iscsi_init;
1335 kwqe_arr[1] = (
struct kwqe *) &iscsi_init2;
1337 if (hba->
cnic && hba->
cnic->submit_kwqes)
1338 rc = hba->
cnic->submit_kwqes(hba->
cnic, kwqe_arr, 2);
1352 struct bnx2i_conn *bnx2i_conn,
1364 spin_lock_bh(&session->
lock);
1366 resp_cqe->itt & ISCSI_CMD_RESPONSE_INDEX);
1372 if (bnx2i_cmd->
req.op_attr & ISCSI_CMD_REQUEST_READ) {
1376 bnx2i_cmd->
req.total_data_transfer_length;
1380 bnx2i_cmd->
req.total_data_transfer_length);
1387 bnx2i_cmd->
req.total_data_transfer_length;
1391 bnx2i_cmd->
req.total_data_transfer_length);
1399 hdr->
opcode = resp_cqe->op_code;
1402 hdr->
response = resp_cqe->response;
1404 hdr->
flags = resp_cqe->response_flags;
1417 "sense data len %d > RQ sz\n",
1422 "sense data len %d > conn data\n",
1433 conn->
data, datalen);
1435 spin_unlock_bh(&session->
lock);
1448 static int bnx2i_process_login_resp(
struct iscsi_session *session,
1449 struct bnx2i_conn *bnx2i_conn,
1460 spin_lock(&session->
lock);
1462 login->itt & ISCSI_LOGIN_RESPONSE_INDEX);
1468 resp_hdr->
opcode = login->op_code;
1469 resp_hdr->
flags = login->response_flags;
1477 resp_hdr->
itt = task->
hdr->itt;
1484 bnx2i_conn->
gen_pdu.resp_wr_ptr =
1485 bnx2i_conn->
gen_pdu.resp_buf + pld_len;
1489 pad_len = 4 - (pld_len % 4);
1493 for (i = 0; i <
pad_len; i++) {
1494 bnx2i_conn->
gen_pdu.resp_wr_ptr[0] = 0;
1495 bnx2i_conn->
gen_pdu.resp_wr_ptr++;
1503 spin_unlock(&session->
lock);
1516 static int bnx2i_process_text_resp(
struct iscsi_session *session,
1517 struct bnx2i_conn *bnx2i_conn,
1528 spin_lock(&session->
lock);
1535 resp_hdr->
opcode = text->op_code;
1536 resp_hdr->
flags = text->response_flags;
1540 resp_hdr->
itt = task->
hdr->itt;
1542 resp_hdr->
statsn = task->
hdr->exp_statsn;
1550 pad_len = 4 - (pld_len % 4);
1554 for (i = 0; i <
pad_len; i++) {
1555 bnx2i_conn->
gen_pdu.resp_wr_ptr[0] = 0;
1556 bnx2i_conn->
gen_pdu.resp_wr_ptr++;
1561 bnx2i_conn->
gen_pdu.resp_wr_ptr -
1562 bnx2i_conn->
gen_pdu.resp_buf);
1564 spin_unlock(&session->
lock);
1577 static int bnx2i_process_tmf_resp(
struct iscsi_session *session,
1578 struct bnx2i_conn *bnx2i_conn,
1587 spin_lock(&session->
lock);
1589 tmf_cqe->itt & ISCSI_TMF_RESPONSE_INDEX);
1595 resp_hdr->
opcode = tmf_cqe->op_code;
1598 resp_hdr->
itt = task->
hdr->itt;
1599 resp_hdr->
response = tmf_cqe->response;
1603 spin_unlock(&session->
lock);
1616 static int bnx2i_process_logout_resp(
struct iscsi_session *session,
1617 struct bnx2i_conn *bnx2i_conn,
1626 spin_lock(&session->
lock);
1628 logout->itt & ISCSI_LOGOUT_RESPONSE_INDEX);
1634 resp_hdr->
opcode = logout->op_code;
1635 resp_hdr->
flags = logout->response;
1638 resp_hdr->
itt = task->
hdr->itt;
1639 resp_hdr->
statsn = task->
hdr->exp_statsn;
1650 spin_unlock(&session->
lock);
1662 static void bnx2i_process_nopin_local_cmpl(
struct iscsi_session *session,
1663 struct bnx2i_conn *bnx2i_conn,
1671 spin_lock(&session->
lock);
1673 nop_in->itt & ISCSI_NOP_IN_MSG_INDEX);
1676 spin_unlock(&session->
lock);
1687 static void bnx2i_unsol_pdu_adjust_rq(
struct bnx2i_conn *bnx2i_conn)
1689 char dummy_rq_data[2];
1703 static int bnx2i_process_nopin_mesg(
struct iscsi_session *session,
1704 struct bnx2i_conn *bnx2i_conn,
1711 int tgt_async_nop = 0;
1715 spin_lock(&session->
lock);
1718 hdr->
opcode = nop_in->op_code;
1724 bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
1732 (
itt_t) (nop_in->itt & ISCSI_NOP_IN_MSG_INDEX));
1735 hdr->
itt = task->
hdr->itt;
1741 spin_unlock(&session->
lock);
1743 return tgt_async_nop;
1755 static void bnx2i_process_async_mesg(
struct iscsi_session *session,
1756 struct bnx2i_conn *bnx2i_conn,
1763 bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
1766 async_event = async_cqe->async_event;
1770 "async: scsi events not supported\n");
1774 spin_lock(&session->
lock);
1777 resp_hdr->
opcode = async_cqe->op_code;
1778 resp_hdr->
flags = 0x80;
1793 spin_unlock(&session->
lock);
1805 static void bnx2i_process_reject_mesg(
struct iscsi_session *session,
1806 struct bnx2i_conn *bnx2i_conn,
1818 bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
1820 spin_lock(&session->
lock);
1823 hdr->
opcode = reject->op_code;
1824 hdr->
reason = reject->reason;
1831 spin_unlock(&session->
lock);
1842 static void bnx2i_process_cmd_cleanup_resp(
struct iscsi_session *session,
1843 struct bnx2i_conn *bnx2i_conn,
1851 spin_lock(&session->
lock);
1853 cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX);
1856 cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX);
1857 spin_unlock(&session->
lock);
1878 list_splice_init(&p->
work_list, &work_list);
1882 list_del_init(&work->
list);
1913 static int bnx2i_queue_scsi_cmd_resp(
struct iscsi_session *session,
1914 struct bnx2i_conn *bnx2i_conn,
1924 spin_lock(&session->
lock);
1926 cqe->itt & ISCSI_CMD_RESPONSE_INDEX);
1927 if (!task || !task->
sc) {
1928 spin_unlock(&session->
lock);
1933 if (!blk_rq_cpu_valid(sc->
request))
1938 spin_unlock(&session->
lock);
1940 p = &
per_cpu(bnx2i_percpu, cpu);
1947 bnx2i_work = kzalloc(
sizeof(
struct bnx2i_work),
GFP_ATOMIC);
1949 INIT_LIST_HEAD(&bnx2i_work->
list);
1950 bnx2i_work->
session = session;
1952 memcpy(&bnx2i_work->
cqe, cqe,
sizeof(
struct cqe));
1974 static int bnx2i_process_new_cqes(
struct bnx2i_conn *bnx2i_conn)
1984 if (bnx2i_conn->
ep ==
NULL)
1987 qp = &bnx2i_conn->
ep->qp;
2003 "NOP-In detected for suspended "
2004 "connection dev=%s!\n",
2006 bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
2013 switch (nopin->op_code) {
2018 bnx2i_queue_scsi_cmd_resp(session, bnx2i_conn, nopin);
2021 bnx2i_process_login_resp(session, bnx2i_conn,
2025 bnx2i_process_tmf_resp(session, bnx2i_conn,
2029 bnx2i_process_text_resp(session, bnx2i_conn,
2033 bnx2i_process_logout_resp(session, bnx2i_conn,
2037 if (bnx2i_process_nopin_mesg(session, bnx2i_conn,
2042 bnx2i_process_nopin_local_cmpl(session, bnx2i_conn,
2046 bnx2i_process_async_mesg(session, bnx2i_conn,
2051 bnx2i_process_reject_mesg(session, bnx2i_conn,
2055 bnx2i_process_cmd_cleanup_resp(session, bnx2i_conn,
2066 if (!tgt_async_msg) {
2105 static void bnx2i_fastpath_notification(
struct bnx2i_hba *hba,
2108 struct bnx2i_conn *bnx2i_conn;
2119 if (!bnx2i_conn->
ep) {
2124 bnx2i_process_new_cqes(bnx2i_conn);
2127 if (nxt_idx && nxt_idx == bnx2i_process_new_cqes(bnx2i_conn))
2139 static void bnx2i_process_update_conn_cmpl(
struct bnx2i_hba *hba,
2142 struct bnx2i_conn *conn;
2174 static void bnx2i_recovery_que_add_conn(
struct bnx2i_hba *hba,
2175 struct bnx2i_conn *bnx2i_conn)
2190 static void bnx2i_process_tcp_error(
struct bnx2i_hba *hba,
2193 struct bnx2i_conn *bnx2i_conn;
2206 bnx2i_recovery_que_add_conn(bnx2i_conn->
hba, bnx2i_conn);
2223 static void bnx2i_process_iscsi_error(
struct bnx2i_hba *hba,
2226 struct bnx2i_conn *bnx2i_conn;
2228 char warn_notice[] =
"iscsi_warning";
2229 char error_notice[] =
"iscsi_error";
2230 char additional_notice[64];
2246 message = warn_notice;
2249 message = error_notice;
2254 strcpy(additional_notice,
"hdr digest err");
2257 strcpy(additional_notice,
"data digest err");
2260 strcpy(additional_notice,
"wrong opcode rcvd");
2263 strcpy(additional_notice,
"AHS len > 0 rcvd");
2266 strcpy(additional_notice,
"invalid ITT rcvd");
2269 strcpy(additional_notice,
"wrong StatSN rcvd");
2272 strcpy(additional_notice,
"wrong DataSN rcvd");
2275 strcpy(additional_notice,
"pend R2T violation");
2278 strcpy(additional_notice,
"ERL0, UO");
2281 strcpy(additional_notice,
"ERL0, U1");
2284 strcpy(additional_notice,
"ERL0, U2");
2287 strcpy(additional_notice,
"ERL0, U3");
2290 strcpy(additional_notice,
"ERL0, U4");
2293 strcpy(additional_notice,
"ERL0, U5");
2296 strcpy(additional_notice,
"ERL0, U6");
2299 strcpy(additional_notice,
"invalid resi len");
2302 strcpy(additional_notice,
"MRDSL violation");
2305 strcpy(additional_notice,
"F-bit not set");
2308 strcpy(additional_notice,
"invalid TTT");
2311 strcpy(additional_notice,
"invalid DataSN");
2314 strcpy(additional_notice,
"burst len violation");
2317 strcpy(additional_notice,
"buf offset violation");
2320 strcpy(additional_notice,
"invalid LUN field");
2323 strcpy(additional_notice,
"invalid R2TSN field");
2325 #define BNX2I_ERR_DESIRED_DATA_TRNS_LEN_0 \
2326 ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DESIRED_DATA_TRNS_LEN_0
2328 strcpy(additional_notice,
"invalid cmd len1");
2330 #define BNX2I_ERR_DESIRED_DATA_TRNS_LEN_1 \
2331 ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DESIRED_DATA_TRNS_LEN_1
2333 strcpy(additional_notice,
"invalid cmd len2");
2336 strcpy(additional_notice,
2337 "pend r2t exceeds MaxOutstandingR2T value");
2340 strcpy(additional_notice,
"TTT is rsvd");
2343 strcpy(additional_notice,
"MBL violation");
2345 #define BNX2I_ERR_DATA_SEG_LEN_NOT_ZERO \
2346 ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DATA_SEG_LEN_NOT_ZERO
2348 strcpy(additional_notice,
"data seg len != 0");
2351 strcpy(additional_notice,
"reject pdu len error");
2354 strcpy(additional_notice,
"async pdu len error");
2357 strcpy(additional_notice,
"nopin pdu len error");
2359 #define BNX2_ERR_PEND_R2T_IN_CLEANUP \
2360 ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_PEND_R2T_IN_CLEANUP
2362 strcpy(additional_notice,
"pend r2t in cleanup");
2366 strcpy(additional_notice,
"IP fragments rcvd");
2369 strcpy(additional_notice,
"IP options error");
2372 strcpy(additional_notice,
"urgent flag error");
2379 if (need_recovery) {
2383 message, additional_notice);
2387 "conn_err - hostno %d conn %p, "
2388 "iscsi_cid %x cid %x\n",
2389 bnx2i_conn->
hba->shost->host_no,
2390 bnx2i_conn, bnx2i_conn->
ep->ep_iscsi_cid,
2391 bnx2i_conn->
ep->ep_cid);
2392 bnx2i_recovery_que_add_conn(bnx2i_conn->
hba, bnx2i_conn);
2399 message, additional_notice);
2410 static void bnx2i_process_conn_destroy_cmpl(
struct bnx2i_hba *hba,
2418 "offload request, unexpected complection\n");
2422 if (hba != ep->
hba) {
2444 static void bnx2i_process_ofld_cmpl(
struct bnx2i_hba *hba,
2457 if (hba != ep->
hba) {
2467 "to allocate iSCSI context resources\n",
2472 "opcode\n", hba->
netdev->name);
2479 "error code %d\n", hba->
netdev->name,
2484 cid_num = bnx2i_get_cid_num(ep);
2485 ep->ep_cid = cid_addr;
2505 while (i < num_cqe) {
2508 if (ikcqe->op_code ==
2510 bnx2i_fastpath_notification(hba, ikcqe);
2512 bnx2i_process_ofld_cmpl(hba, ikcqe);
2514 bnx2i_process_update_conn_cmpl(hba, ikcqe);
2518 bnx2i_iscsi_license_error(hba, ikcqe->\
completion_status);
2521 bnx2i_get_link_state(hba);
2523 "ISCSI_INIT passed\n",
2531 bnx2i_process_conn_destroy_cmpl(hba, ikcqe);
2533 bnx2i_process_iscsi_error(hba, ikcqe);
2535 bnx2i_process_tcp_error(hba, ikcqe);
2552 static void bnx2i_indicate_netevent(
void *context,
unsigned long event,
2576 bnx2i_get_link_state(hba);
2591 static void bnx2i_cm_connect_cmpl(
struct cnic_sock *cm_sk)
2613 static void bnx2i_cm_close_cmpl(
struct cnic_sock *cm_sk)
2629 static void bnx2i_cm_abort_cmpl(
struct cnic_sock *cm_sk)
2646 static void bnx2i_cm_remote_close(
struct cnic_sock *cm_sk)
2652 bnx2i_recovery_que_add_conn(ep->
hba, ep->
conn);
2663 static void bnx2i_cm_remote_abort(
struct cnic_sock *cm_sk)
2673 bnx2i_recovery_que_add_conn(ep->
hba, ep->
conn);
2677 static int bnx2i_send_nl_mesg(
void *context,
u32 msg_type,
2687 msg_type, buf, buflen);
2705 .indicate_kcqes = bnx2i_indicate_kcqe,
2706 .indicate_netevent = bnx2i_indicate_netevent,
2707 .cm_connect_complete = bnx2i_cm_connect_cmpl,
2708 .cm_close_complete = bnx2i_cm_close_cmpl,
2709 .cm_abort_complete = bnx2i_cm_abort_cmpl,
2710 .cm_remote_close = bnx2i_cm_remote_close,
2711 .cm_remote_abort = bnx2i_cm_remote_abort,
2712 .iscsi_nl_send_msg = bnx2i_send_nl_mesg,
2735 cid_num = bnx2i_get_cid_num(ep);
2754 (((cid_num - first_l4l5) / ctx_sz) + 256);
2763 if (!ep->
qp.ctx_base)