Lines Matching +full:hsi +full:- +full:mac
5 * Copyright (c) 2008-2013 Broadcom Corporation
6 * Copyright (c) 2014-2016 QLogic Corporation
7 * Copyright (c) 2016-2017 Cavium Inc.
42 stat_req.stat_params_addr_lo = (u32) hba->stats_buf_dma; in bnx2fc_send_stat_req()
43 stat_req.stat_params_addr_hi = (u32) ((u64)hba->stats_buf_dma >> 32); in bnx2fc_send_stat_req()
47 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2fc_send_stat_req()
48 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); in bnx2fc_send_stat_req()
54 * bnx2fc_send_fw_fcoe_init_msg - initiates initial handshake with FCoE f/w
71 if (!hba->cnic) { in bnx2fc_send_fw_fcoe_init_msg()
72 printk(KERN_ERR PFX "hba->cnic NULL during fcoe fw init\n"); in bnx2fc_send_fw_fcoe_init_msg()
73 return -ENODEV; in bnx2fc_send_fw_fcoe_init_msg()
82 fcoe_init1.num_tasks = hba->max_tasks; in bnx2fc_send_fw_fcoe_init_msg()
87 fcoe_init1.dummy_buffer_addr_lo = (u32) hba->dummy_buf_dma; in bnx2fc_send_fw_fcoe_init_msg()
88 fcoe_init1.dummy_buffer_addr_hi = (u32) ((u64)hba->dummy_buf_dma >> 32); in bnx2fc_send_fw_fcoe_init_msg()
89 fcoe_init1.task_list_pbl_addr_lo = (u32) hba->task_ctx_bd_dma; in bnx2fc_send_fw_fcoe_init_msg()
91 (u32) ((u64) hba->task_ctx_bd_dma >> 32); in bnx2fc_send_fw_fcoe_init_msg()
109 fcoe_init2.hash_tbl_pbl_addr_lo = (u32) hba->hash_tbl_pbl_dma; in bnx2fc_send_fw_fcoe_init_msg()
111 ((u64) hba->hash_tbl_pbl_dma >> 32); in bnx2fc_send_fw_fcoe_init_msg()
113 fcoe_init2.t2_hash_tbl_addr_lo = (u32) hba->t2_hash_tbl_dma; in bnx2fc_send_fw_fcoe_init_msg()
115 ((u64) hba->t2_hash_tbl_dma >> 32); in bnx2fc_send_fw_fcoe_init_msg()
117 fcoe_init2.t2_ptr_hash_tbl_addr_lo = (u32) hba->t2_hash_tbl_ptr_dma; in bnx2fc_send_fw_fcoe_init_msg()
119 ((u64) hba->t2_hash_tbl_ptr_dma >> 32); in bnx2fc_send_fw_fcoe_init_msg()
141 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2fc_send_fw_fcoe_init_msg()
142 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); in bnx2fc_send_fw_fcoe_init_msg()
151 int rc = -1; in bnx2fc_send_fw_fcoe_destroy_msg()
160 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2fc_send_fw_fcoe_destroy_msg()
161 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); in bnx2fc_send_fw_fcoe_destroy_msg()
166 * bnx2fc_send_session_ofld_req - initiates FCoE Session offload process
174 struct fc_lport *lport = port->lport; in bnx2fc_send_session_ofld_req()
175 struct bnx2fc_interface *interface = port->priv; in bnx2fc_send_session_ofld_req()
177 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_send_session_ofld_req()
183 struct fc_rport_priv *rdata = tgt->rdata; in bnx2fc_send_session_ofld_req()
184 struct fc_rport *rport = tgt->rport; in bnx2fc_send_session_ofld_req()
198 conn_id = (u16)tgt->fcoe_conn_id; in bnx2fc_send_session_ofld_req()
202 ofld_req1.sq_addr_lo = (u32) tgt->sq_dma; in bnx2fc_send_session_ofld_req()
203 ofld_req1.sq_addr_hi = (u32)((u64) tgt->sq_dma >> 32); in bnx2fc_send_session_ofld_req()
205 ofld_req1.rq_pbl_addr_lo = (u32) tgt->rq_pbl_dma; in bnx2fc_send_session_ofld_req()
206 ofld_req1.rq_pbl_addr_hi = (u32)((u64) tgt->rq_pbl_dma >> 32); in bnx2fc_send_session_ofld_req()
208 ofld_req1.rq_first_pbe_addr_lo = (u32) tgt->rq_dma; in bnx2fc_send_session_ofld_req()
210 (u32)((u64) tgt->rq_dma >> 32); in bnx2fc_send_session_ofld_req()
221 ofld_req2.tx_max_fc_pay_len = rdata->maxframe_size; in bnx2fc_send_session_ofld_req()
223 ofld_req2.cq_addr_lo = (u32) tgt->cq_dma; in bnx2fc_send_session_ofld_req()
224 ofld_req2.cq_addr_hi = (u32)((u64)tgt->cq_dma >> 32); in bnx2fc_send_session_ofld_req()
226 ofld_req2.xferq_addr_lo = (u32) tgt->xferq_dma; in bnx2fc_send_session_ofld_req()
227 ofld_req2.xferq_addr_hi = (u32)((u64)tgt->xferq_dma >> 32); in bnx2fc_send_session_ofld_req()
229 ofld_req2.conn_db_addr_lo = (u32)tgt->conn_db_dma; in bnx2fc_send_session_ofld_req()
230 ofld_req2.conn_db_addr_hi = (u32)((u64)tgt->conn_db_dma >> 32); in bnx2fc_send_session_ofld_req()
239 ofld_req3.vlan_tag = interface->vlan_id << in bnx2fc_send_session_ofld_req()
243 port_id = fc_host_port_id(lport->host); in bnx2fc_send_session_ofld_req()
246 return -EINVAL; in bnx2fc_send_session_ofld_req()
254 tgt->sid = port_id; in bnx2fc_send_session_ofld_req()
259 port_id = rport->port_id; in bnx2fc_send_session_ofld_req()
264 ofld_req3.tx_total_conc_seqs = rdata->max_seq; in bnx2fc_send_session_ofld_req()
266 ofld_req3.tx_max_conc_seqs_c3 = rdata->max_seq; in bnx2fc_send_session_ofld_req()
267 ofld_req3.rx_max_fc_pay_len = lport->mfs; in bnx2fc_send_session_ofld_req()
273 ofld_req3.confq_first_pbe_addr_lo = tgt->confq_dma; in bnx2fc_send_session_ofld_req()
274 ofld_req3.confq_first_pbe_addr_hi = (u32)((u64) tgt->confq_dma >> 32); in bnx2fc_send_session_ofld_req()
279 ofld_req3.flags |= (((lport->send_sp_features & FC_SP_FT_MNA) ? 1:0) << in bnx2fc_send_session_ofld_req()
283 ofld_req3.flags |= (((rdata->sp_features & FC_SP_FT_EDTR) ? 1 : 0) << in bnx2fc_send_session_ofld_req()
286 ofld_req3.flags |= (((rdata->sp_features & FC_SP_FT_SEQC) ? 1 : 0) << in bnx2fc_send_session_ofld_req()
293 if (tgt->dev_type == TYPE_TAPE) { in bnx2fc_send_session_ofld_req()
296 ofld_req3.flags |= (((rdata->flags & FC_RP_FLAGS_REC_SUPPORTED) in bnx2fc_send_session_ofld_req()
302 ofld_req3.flags |= (interface->vlan_enabled << in bnx2fc_send_session_ofld_req()
314 ofld_req4.e_d_tov_timer_val = lport->e_d_tov / 20; in bnx2fc_send_session_ofld_req()
317 ofld_req4.src_mac_addr_lo[0] = port->data_src_addr[5]; in bnx2fc_send_session_ofld_req()
318 /* local mac */ in bnx2fc_send_session_ofld_req()
319 ofld_req4.src_mac_addr_lo[1] = port->data_src_addr[4]; in bnx2fc_send_session_ofld_req()
320 ofld_req4.src_mac_addr_mid[0] = port->data_src_addr[3]; in bnx2fc_send_session_ofld_req()
321 ofld_req4.src_mac_addr_mid[1] = port->data_src_addr[2]; in bnx2fc_send_session_ofld_req()
322 ofld_req4.src_mac_addr_hi[0] = port->data_src_addr[1]; in bnx2fc_send_session_ofld_req()
323 ofld_req4.src_mac_addr_hi[1] = port->data_src_addr[0]; in bnx2fc_send_session_ofld_req()
324 ofld_req4.dst_mac_addr_lo[0] = ctlr->dest_addr[5]; in bnx2fc_send_session_ofld_req()
325 /* fcf mac */ in bnx2fc_send_session_ofld_req()
326 ofld_req4.dst_mac_addr_lo[1] = ctlr->dest_addr[4]; in bnx2fc_send_session_ofld_req()
327 ofld_req4.dst_mac_addr_mid[0] = ctlr->dest_addr[3]; in bnx2fc_send_session_ofld_req()
328 ofld_req4.dst_mac_addr_mid[1] = ctlr->dest_addr[2]; in bnx2fc_send_session_ofld_req()
329 ofld_req4.dst_mac_addr_hi[0] = ctlr->dest_addr[1]; in bnx2fc_send_session_ofld_req()
330 ofld_req4.dst_mac_addr_hi[1] = ctlr->dest_addr[0]; in bnx2fc_send_session_ofld_req()
332 ofld_req4.lcq_addr_lo = (u32) tgt->lcq_dma; in bnx2fc_send_session_ofld_req()
333 ofld_req4.lcq_addr_hi = (u32)((u64) tgt->lcq_dma >> 32); in bnx2fc_send_session_ofld_req()
335 ofld_req4.confq_pbl_base_addr_lo = (u32) tgt->confq_pbl_dma; in bnx2fc_send_session_ofld_req()
337 (u32)((u64) tgt->confq_pbl_dma >> 32); in bnx2fc_send_session_ofld_req()
344 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2fc_send_session_ofld_req()
345 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); in bnx2fc_send_session_ofld_req()
351 * bnx2fc_send_session_enable_req - initiates FCoE Session enablement
360 struct bnx2fc_interface *interface = port->priv; in bnx2fc_send_session_enable_req()
362 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_send_session_enable_req()
364 struct fc_lport *lport = port->lport; in bnx2fc_send_session_enable_req()
365 struct fc_rport *rport = tgt->rport; in bnx2fc_send_session_enable_req()
376 enbl_req.src_mac_addr_lo[0] = port->data_src_addr[5]; in bnx2fc_send_session_enable_req()
377 /* local mac */ in bnx2fc_send_session_enable_req()
378 enbl_req.src_mac_addr_lo[1] = port->data_src_addr[4]; in bnx2fc_send_session_enable_req()
379 enbl_req.src_mac_addr_mid[0] = port->data_src_addr[3]; in bnx2fc_send_session_enable_req()
380 enbl_req.src_mac_addr_mid[1] = port->data_src_addr[2]; in bnx2fc_send_session_enable_req()
381 enbl_req.src_mac_addr_hi[0] = port->data_src_addr[1]; in bnx2fc_send_session_enable_req()
382 enbl_req.src_mac_addr_hi[1] = port->data_src_addr[0]; in bnx2fc_send_session_enable_req()
383 memcpy(tgt->src_addr, port->data_src_addr, ETH_ALEN); in bnx2fc_send_session_enable_req()
385 enbl_req.dst_mac_addr_lo[0] = ctlr->dest_addr[5]; in bnx2fc_send_session_enable_req()
386 enbl_req.dst_mac_addr_lo[1] = ctlr->dest_addr[4]; in bnx2fc_send_session_enable_req()
387 enbl_req.dst_mac_addr_mid[0] = ctlr->dest_addr[3]; in bnx2fc_send_session_enable_req()
388 enbl_req.dst_mac_addr_mid[1] = ctlr->dest_addr[2]; in bnx2fc_send_session_enable_req()
389 enbl_req.dst_mac_addr_hi[0] = ctlr->dest_addr[1]; in bnx2fc_send_session_enable_req()
390 enbl_req.dst_mac_addr_hi[1] = ctlr->dest_addr[0]; in bnx2fc_send_session_enable_req()
392 port_id = fc_host_port_id(lport->host); in bnx2fc_send_session_enable_req()
393 if (port_id != tgt->sid) { in bnx2fc_send_session_enable_req()
395 "sid = 0x%x\n", port_id, tgt->sid); in bnx2fc_send_session_enable_req()
396 port_id = tgt->sid; in bnx2fc_send_session_enable_req()
402 port_id = rport->port_id; in bnx2fc_send_session_enable_req()
406 enbl_req.vlan_tag = interface->vlan_id << in bnx2fc_send_session_enable_req()
409 enbl_req.vlan_flag = interface->vlan_enabled; in bnx2fc_send_session_enable_req()
410 enbl_req.context_id = tgt->context_id; in bnx2fc_send_session_enable_req()
411 enbl_req.conn_id = tgt->fcoe_conn_id; in bnx2fc_send_session_enable_req()
415 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2fc_send_session_enable_req()
416 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); in bnx2fc_send_session_enable_req()
421 * bnx2fc_send_session_disable_req - initiates FCoE Session disable
429 struct bnx2fc_interface *interface = port->priv; in bnx2fc_send_session_disable_req()
431 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_send_session_disable_req()
434 struct fc_rport *rport = tgt->rport; in bnx2fc_send_session_disable_req()
445 disable_req.src_mac_addr_lo[0] = tgt->src_addr[5]; in bnx2fc_send_session_disable_req()
446 disable_req.src_mac_addr_lo[1] = tgt->src_addr[4]; in bnx2fc_send_session_disable_req()
447 disable_req.src_mac_addr_mid[0] = tgt->src_addr[3]; in bnx2fc_send_session_disable_req()
448 disable_req.src_mac_addr_mid[1] = tgt->src_addr[2]; in bnx2fc_send_session_disable_req()
449 disable_req.src_mac_addr_hi[0] = tgt->src_addr[1]; in bnx2fc_send_session_disable_req()
450 disable_req.src_mac_addr_hi[1] = tgt->src_addr[0]; in bnx2fc_send_session_disable_req()
452 disable_req.dst_mac_addr_lo[0] = ctlr->dest_addr[5]; in bnx2fc_send_session_disable_req()
453 disable_req.dst_mac_addr_lo[1] = ctlr->dest_addr[4]; in bnx2fc_send_session_disable_req()
454 disable_req.dst_mac_addr_mid[0] = ctlr->dest_addr[3]; in bnx2fc_send_session_disable_req()
455 disable_req.dst_mac_addr_mid[1] = ctlr->dest_addr[2]; in bnx2fc_send_session_disable_req()
456 disable_req.dst_mac_addr_hi[0] = ctlr->dest_addr[1]; in bnx2fc_send_session_disable_req()
457 disable_req.dst_mac_addr_hi[1] = ctlr->dest_addr[0]; in bnx2fc_send_session_disable_req()
459 port_id = tgt->sid; in bnx2fc_send_session_disable_req()
465 port_id = rport->port_id; in bnx2fc_send_session_disable_req()
469 disable_req.context_id = tgt->context_id; in bnx2fc_send_session_disable_req()
470 disable_req.conn_id = tgt->fcoe_conn_id; in bnx2fc_send_session_disable_req()
471 disable_req.vlan_tag = interface->vlan_id << in bnx2fc_send_session_disable_req()
475 disable_req.vlan_flag = interface->vlan_enabled; in bnx2fc_send_session_disable_req()
479 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2fc_send_session_disable_req()
480 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); in bnx2fc_send_session_disable_req()
486 * bnx2fc_send_session_destroy_req - initiates FCoE Session destroy
504 destroy_req.context_id = tgt->context_id; in bnx2fc_send_session_destroy_req()
505 destroy_req.conn_id = tgt->fcoe_conn_id; in bnx2fc_send_session_destroy_req()
509 if (hba->cnic && hba->cnic->submit_kwqes) in bnx2fc_send_session_destroy_req()
510 rc = hba->cnic->submit_kwqes(hba->cnic, kwqe_arr, num_kwqes); in bnx2fc_send_session_destroy_req()
519 spin_lock_bh(&hba->hba_lock); in is_valid_lport()
520 list_for_each_entry(blport, &hba->vports, list) { in is_valid_lport()
521 if (blport->lport == lport) { in is_valid_lport()
522 spin_unlock_bh(&hba->hba_lock); in is_valid_lport()
526 spin_unlock_bh(&hba->hba_lock); in is_valid_lport()
540 lport = unsol_els->lport; in bnx2fc_unsol_els_work()
541 fp = unsol_els->fp; in bnx2fc_unsol_els_work()
542 hba = unsol_els->hba; in bnx2fc_unsol_els_work()
552 struct fcoe_port *port = tgt->port; in bnx2fc_process_l2_frame_compl()
553 struct fc_lport *lport = port->lport; in bnx2fc_process_l2_frame_compl()
554 struct bnx2fc_interface *interface = port->priv; in bnx2fc_process_l2_frame_compl()
573 payload_len = frame_len - sizeof(struct fc_frame_header); in bnx2fc_process_l2_frame_compl()
587 fh->fh_ox_id = htons(l2_oxid); in bnx2fc_process_l2_frame_compl()
591 if ((fh->fh_r_ctl == FC_RCTL_ELS_REQ) || in bnx2fc_process_l2_frame_compl()
592 (fh->fh_r_ctl == FC_RCTL_ELS_REP)) { in bnx2fc_process_l2_frame_compl()
594 if (fh->fh_type == FC_TYPE_ELS) { in bnx2fc_process_l2_frame_compl()
614 unsol_els->lport = lport; in bnx2fc_process_l2_frame_compl()
615 unsol_els->hba = interface->hba; in bnx2fc_process_l2_frame_compl()
616 unsol_els->fp = fp; in bnx2fc_process_l2_frame_compl()
617 INIT_WORK(&unsol_els->unsol_els_work, bnx2fc_unsol_els_work); in bnx2fc_process_l2_frame_compl()
618 queue_work(bnx2fc_wq, &unsol_els->unsol_els_work); in bnx2fc_process_l2_frame_compl()
620 BNX2FC_HBA_DBG(lport, "fh_r_ctl = 0x%x\n", fh->fh_r_ctl); in bnx2fc_process_l2_frame_compl()
636 struct bnx2fc_interface *interface = tgt->port->priv; in bnx2fc_process_unsol_compl()
637 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_process_unsol_compl()
649 num_rq = (frame_len + BNX2FC_RQ_BUF_SZ - 1) / BNX2FC_RQ_BUF_SZ; in bnx2fc_process_unsol_compl()
651 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
653 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
667 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
670 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
681 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
683 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
691 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
695 xid = err_entry->fc_hdr.ox_id; in bnx2fc_process_unsol_compl()
698 err_entry->data.err_warn_bitmap_hi, in bnx2fc_process_unsol_compl()
699 err_entry->data.err_warn_bitmap_lo); in bnx2fc_process_unsol_compl()
700 BNX2FC_TGT_DBG(tgt, "buf_offsets - tx = 0x%x, rx = 0x%x\n", in bnx2fc_process_unsol_compl()
701 err_entry->data.tx_buf_off, err_entry->data.rx_buf_off); in bnx2fc_process_unsol_compl()
703 if (xid > hba->max_xid) { in bnx2fc_process_unsol_compl()
710 io_req = (struct bnx2fc_cmd *)hba->cmd_mgr->cmds[xid]; in bnx2fc_process_unsol_compl()
714 if (io_req->cmd_type != BNX2FC_SCSI_CMD) { in bnx2fc_process_unsol_compl()
720 &io_req->req_flags)) { in bnx2fc_process_unsol_compl()
727 ((u64)err_entry->data.err_warn_bitmap_hi << 32) | in bnx2fc_process_unsol_compl()
728 (u64)err_entry->data.err_warn_bitmap_lo; in bnx2fc_process_unsol_compl()
743 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) { in bnx2fc_process_unsol_compl()
749 if (tgt->dev_type != TYPE_TAPE) in bnx2fc_process_unsol_compl()
758 BNX2FC_TGT_DBG(tgt, "REC TOV popped for xid - 0x%x\n", in bnx2fc_process_unsol_compl()
760 memcpy(&io_req->err_entry, err_entry, in bnx2fc_process_unsol_compl()
763 &io_req->req_flags)) { in bnx2fc_process_unsol_compl()
764 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
766 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
778 set_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags); in bnx2fc_process_unsol_compl()
783 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_process_unsol_compl()
784 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_unsol_compl()
790 io_req->xid); in bnx2fc_process_unsol_compl()
795 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
803 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
807 xid = cpu_to_be16(err_entry->fc_hdr.ox_id); in bnx2fc_process_unsol_compl()
810 err_entry->data.err_warn_bitmap_hi, in bnx2fc_process_unsol_compl()
811 err_entry->data.err_warn_bitmap_lo); in bnx2fc_process_unsol_compl()
812 BNX2FC_TGT_DBG(tgt, "buf_offsets - tx = 0x%x, rx = 0x%x", in bnx2fc_process_unsol_compl()
813 err_entry->data.tx_buf_off, err_entry->data.rx_buf_off); in bnx2fc_process_unsol_compl()
815 if (xid > hba->max_xid) { in bnx2fc_process_unsol_compl()
821 ((u64)err_entry->data.err_warn_bitmap_hi << 32) | in bnx2fc_process_unsol_compl()
822 (u64)err_entry->data.err_warn_bitmap_lo; in bnx2fc_process_unsol_compl()
831 io_req = (struct bnx2fc_cmd *)hba->cmd_mgr->cmds[xid]; in bnx2fc_process_unsol_compl()
835 if (io_req->cmd_type != BNX2FC_SCSI_CMD) { in bnx2fc_process_unsol_compl()
840 memcpy(&io_req->err_entry, err_entry, in bnx2fc_process_unsol_compl()
850 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_process_unsol_compl()
863 struct fcoe_port *port = tgt->port; in bnx2fc_process_cq_compl()
864 struct bnx2fc_interface *interface = port->priv; in bnx2fc_process_cq_compl()
865 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_process_cq_compl()
872 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_process_cq_compl()
875 io_req = (struct bnx2fc_cmd *)hba->cmd_mgr->cmds[xid]; in bnx2fc_process_cq_compl()
878 printk(KERN_ERR PFX "ERROR? cq_compl - io_req is NULL\n"); in bnx2fc_process_cq_compl()
879 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_process_cq_compl()
884 cmd_type = io_req->cmd_type; in bnx2fc_process_cq_compl()
886 rx_state = ((task->rxwr_txrd.var_ctx.rx_flags & in bnx2fc_process_cq_compl()
896 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_process_cq_compl()
906 printk(KERN_ERR PFX "Invalid rx state - %d\n", in bnx2fc_process_cq_compl()
921 BNX2FC_IO_DBG(io_req, "cq_compl- ABTS sent out by fw\n"); in bnx2fc_process_cq_compl()
922 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_cq_compl()
939 BNX2FC_IO_DBG(io_req, "cq_compl- cleanup resp rcvd\n"); in bnx2fc_process_cq_compl()
940 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_cq_compl()
944 BNX2FC_IO_DBG(io_req, "cq_compl(0x%x) - seq cleanup resp\n", in bnx2fc_process_cq_compl()
945 io_req->xid); in bnx2fc_process_cq_compl()
947 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_cq_compl()
954 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_process_cq_compl()
959 struct b577xx_fcoe_rx_doorbell *rx_db = &tgt->rx_db; in bnx2fc_arm_cq()
963 rx_db->doorbell_cq_cons = tgt->cq_cons_idx | (tgt->cq_curr_toggle_bit << in bnx2fc_arm_cq()
966 writel(cpu_to_le32(msg), tgt->ctx_base); in bnx2fc_arm_cq()
979 INIT_LIST_HEAD(&work->list); in bnx2fc_alloc_work()
980 work->tgt = tgt; in bnx2fc_alloc_work()
981 work->wqe = wqe; in bnx2fc_alloc_work()
982 work->num_rq = num_rq; in bnx2fc_alloc_work()
983 work->task = task; in bnx2fc_alloc_work()
985 memcpy(work->rq_data, rq_data, BNX2FC_RQ_BUF_SZ); in bnx2fc_alloc_work()
998 struct fcoe_port *port = tgt->port; in bnx2fc_pending_work()
999 struct bnx2fc_interface *interface = port->priv; in bnx2fc_pending_work()
1000 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_pending_work()
1009 if (xid >= hba->max_tasks) { in bnx2fc_pending_work()
1016 task_page = (struct fcoe_task_ctx_entry *)hba->task_ctx[task_idx]; in bnx2fc_pending_work()
1019 num_rq = ((task->rxwr_txrd.var_ctx.rx_flags & in bnx2fc_pending_work()
1046 spin_lock_bh(&fps->fp_work_lock); in bnx2fc_pending_work()
1047 if (fps->iothread) { in bnx2fc_pending_work()
1051 list_add_tail(&work->list, &fps->work_list); in bnx2fc_pending_work()
1052 wake_up_process(fps->iothread); in bnx2fc_pending_work()
1053 spin_unlock_bh(&fps->fp_work_lock); in bnx2fc_pending_work()
1057 spin_unlock_bh(&fps->fp_work_lock); in bnx2fc_pending_work()
1078 spin_lock_bh(&tgt->cq_lock); in bnx2fc_process_new_cqes()
1080 if (!tgt->cq) { in bnx2fc_process_new_cqes()
1082 spin_unlock_bh(&tgt->cq_lock); in bnx2fc_process_new_cqes()
1085 cq = tgt->cq; in bnx2fc_process_new_cqes()
1086 cq_cons = tgt->cq_cons_idx; in bnx2fc_process_new_cqes()
1089 while (((wqe = cqe->wqe) & FCOE_CQE_TOGGLE_BIT) == in bnx2fc_process_new_cqes()
1090 (tgt->cq_curr_toggle_bit << in bnx2fc_process_new_cqes()
1102 tgt->cq_cons_idx++; in bnx2fc_process_new_cqes()
1105 if (tgt->cq_cons_idx == BNX2FC_CQ_WQES_MAX) { in bnx2fc_process_new_cqes()
1106 tgt->cq_cons_idx = 0; in bnx2fc_process_new_cqes()
1108 tgt->cq_curr_toggle_bit = in bnx2fc_process_new_cqes()
1109 1 - tgt->cq_curr_toggle_bit; in bnx2fc_process_new_cqes()
1114 if (tgt->ctx_base) in bnx2fc_process_new_cqes()
1116 atomic_add(num_free_sqes, &tgt->free_sqes); in bnx2fc_process_new_cqes()
1118 spin_unlock_bh(&tgt->cq_lock); in bnx2fc_process_new_cqes()
1123 * bnx2fc_fastpath_notification - process global event queue (KCQ)
1133 u32 conn_id = new_cqe_kcqe->fcoe_conn_id; in bnx2fc_fastpath_notification()
1134 struct bnx2fc_rport *tgt = hba->tgt_ofld_list[conn_id]; in bnx2fc_fastpath_notification()
1145 * bnx2fc_process_ofld_cmpl - process FCoE session offload completion
1161 conn_id = ofld_kcqe->fcoe_conn_id; in bnx2fc_process_ofld_cmpl()
1162 context_id = ofld_kcqe->fcoe_conn_context_id; in bnx2fc_process_ofld_cmpl()
1163 tgt = hba->tgt_ofld_list[conn_id]; in bnx2fc_process_ofld_cmpl()
1168 BNX2FC_TGT_DBG(tgt, "Entered ofld compl - context_id = 0x%x\n", in bnx2fc_process_ofld_cmpl()
1169 ofld_kcqe->fcoe_conn_context_id); in bnx2fc_process_ofld_cmpl()
1170 interface = tgt->port->priv; in bnx2fc_process_ofld_cmpl()
1171 if (hba != interface->hba) { in bnx2fc_process_ofld_cmpl()
1179 tgt->context_id = context_id; in bnx2fc_process_ofld_cmpl()
1180 if (ofld_kcqe->completion_status) { in bnx2fc_process_ofld_cmpl()
1181 if (ofld_kcqe->completion_status == in bnx2fc_process_ofld_cmpl()
1185 set_bit(BNX2FC_FLAG_CTX_ALLOC_FAILURE, &tgt->flags); in bnx2fc_process_ofld_cmpl()
1189 set_bit(BNX2FC_FLAG_OFFLOADED, &tgt->flags); in bnx2fc_process_ofld_cmpl()
1192 set_bit(BNX2FC_FLAG_OFLD_REQ_CMPL, &tgt->flags); in bnx2fc_process_ofld_cmpl()
1193 wake_up_interruptible(&tgt->ofld_wait); in bnx2fc_process_ofld_cmpl()
1197 * bnx2fc_process_enable_conn_cmpl - process FCoE session enable completion
1213 context_id = ofld_kcqe->fcoe_conn_context_id; in bnx2fc_process_enable_conn_cmpl()
1214 conn_id = ofld_kcqe->fcoe_conn_id; in bnx2fc_process_enable_conn_cmpl()
1215 tgt = hba->tgt_ofld_list[conn_id]; in bnx2fc_process_enable_conn_cmpl()
1221 BNX2FC_TGT_DBG(tgt, "Enable compl - context_id = 0x%x\n", in bnx2fc_process_enable_conn_cmpl()
1222 ofld_kcqe->fcoe_conn_context_id); in bnx2fc_process_enable_conn_cmpl()
1228 if (tgt->context_id != context_id) { in bnx2fc_process_enable_conn_cmpl()
1232 interface = tgt->port->priv; in bnx2fc_process_enable_conn_cmpl()
1233 if (hba != interface->hba) { in bnx2fc_process_enable_conn_cmpl()
1234 printk(KERN_ERR PFX "bnx2fc-enbl_cmpl: HBA mismatch\n"); in bnx2fc_process_enable_conn_cmpl()
1237 if (!ofld_kcqe->completion_status) in bnx2fc_process_enable_conn_cmpl()
1238 /* enable successful - rport ready for issuing IOs */ in bnx2fc_process_enable_conn_cmpl()
1239 set_bit(BNX2FC_FLAG_ENABLED, &tgt->flags); in bnx2fc_process_enable_conn_cmpl()
1242 set_bit(BNX2FC_FLAG_OFLD_REQ_CMPL, &tgt->flags); in bnx2fc_process_enable_conn_cmpl()
1243 wake_up_interruptible(&tgt->ofld_wait); in bnx2fc_process_enable_conn_cmpl()
1253 conn_id = disable_kcqe->fcoe_conn_id; in bnx2fc_process_conn_disable_cmpl()
1254 tgt = hba->tgt_ofld_list[conn_id]; in bnx2fc_process_conn_disable_cmpl()
1262 if (disable_kcqe->completion_status) { in bnx2fc_process_conn_disable_cmpl()
1264 disable_kcqe->completion_status); in bnx2fc_process_conn_disable_cmpl()
1265 set_bit(BNX2FC_FLAG_DISABLE_FAILED, &tgt->flags); in bnx2fc_process_conn_disable_cmpl()
1266 set_bit(BNX2FC_FLAG_UPLD_REQ_COMPL, &tgt->flags); in bnx2fc_process_conn_disable_cmpl()
1267 wake_up_interruptible(&tgt->upld_wait); in bnx2fc_process_conn_disable_cmpl()
1271 clear_bit(BNX2FC_FLAG_OFFLOADED, &tgt->flags); in bnx2fc_process_conn_disable_cmpl()
1272 clear_bit(BNX2FC_FLAG_ENABLED, &tgt->flags); in bnx2fc_process_conn_disable_cmpl()
1273 set_bit(BNX2FC_FLAG_DISABLED, &tgt->flags); in bnx2fc_process_conn_disable_cmpl()
1274 set_bit(BNX2FC_FLAG_UPLD_REQ_COMPL, &tgt->flags); in bnx2fc_process_conn_disable_cmpl()
1275 wake_up_interruptible(&tgt->upld_wait); in bnx2fc_process_conn_disable_cmpl()
1285 conn_id = destroy_kcqe->fcoe_conn_id; in bnx2fc_process_conn_destroy_cmpl()
1286 tgt = hba->tgt_ofld_list[conn_id]; in bnx2fc_process_conn_destroy_cmpl()
1294 if (destroy_kcqe->completion_status) { in bnx2fc_process_conn_destroy_cmpl()
1296 destroy_kcqe->completion_status); in bnx2fc_process_conn_destroy_cmpl()
1301 clear_bit(BNX2FC_FLAG_DISABLED, &tgt->flags); in bnx2fc_process_conn_destroy_cmpl()
1302 set_bit(BNX2FC_FLAG_DESTROYED, &tgt->flags); in bnx2fc_process_conn_destroy_cmpl()
1303 set_bit(BNX2FC_FLAG_UPLD_REQ_COMPL, &tgt->flags); in bnx2fc_process_conn_destroy_cmpl()
1304 wake_up_interruptible(&tgt->upld_wait); in bnx2fc_process_conn_destroy_cmpl()
1326 printk(KERN_ERR PFX "init failure due to HSI mismatch\n"); in bnx2fc_init_failure()
1334 * bnx2fc_indicate_kcqe() - process KCQE
1352 switch (kcqe->op_code) { in bnx2fc_indicate_kcqe()
1366 if (kcqe->completion_status != in bnx2fc_indicate_kcqe()
1369 kcqe->completion_status); in bnx2fc_indicate_kcqe()
1371 set_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2fc_indicate_kcqe()
1374 (u8)hba->pcidev->bus->number); in bnx2fc_indicate_kcqe()
1379 if (kcqe->completion_status != in bnx2fc_indicate_kcqe()
1386 set_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); in bnx2fc_indicate_kcqe()
1387 wake_up_interruptible(&hba->destroy_wait); in bnx2fc_indicate_kcqe()
1399 if (kcqe->completion_status != in bnx2fc_indicate_kcqe()
1402 complete(&hba->stat_req_done); in bnx2fc_indicate_kcqe()
1408 kcqe->op_code); in bnx2fc_indicate_kcqe()
1417 sqe = &tgt->sq[tgt->sq_prod_idx]; in bnx2fc_add_2_sq()
1420 sqe->wqe = xid << FCOE_SQE_TASK_ID_SHIFT; in bnx2fc_add_2_sq()
1421 sqe->wqe |= tgt->sq_curr_toggle_bit << FCOE_SQE_TOGGLE_BIT_SHIFT; in bnx2fc_add_2_sq()
1424 if (++tgt->sq_prod_idx == BNX2FC_SQ_WQES_MAX) { in bnx2fc_add_2_sq()
1425 tgt->sq_prod_idx = 0; in bnx2fc_add_2_sq()
1426 tgt->sq_curr_toggle_bit = 1 - tgt->sq_curr_toggle_bit; in bnx2fc_add_2_sq()
1432 struct b577xx_doorbell_set_prod *sq_db = &tgt->sq_db; in bnx2fc_ring_doorbell()
1436 sq_db->prod = tgt->sq_prod_idx | in bnx2fc_ring_doorbell()
1437 (tgt->sq_curr_toggle_bit << 15); in bnx2fc_ring_doorbell()
1439 writel(cpu_to_le32(msg), tgt->ctx_base); in bnx2fc_ring_doorbell()
1445 u32 context_id = tgt->context_id; in bnx2fc_map_doorbell()
1446 struct fcoe_port *port = tgt->port; in bnx2fc_map_doorbell()
1449 struct bnx2fc_interface *interface = port->priv; in bnx2fc_map_doorbell()
1450 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_map_doorbell()
1452 reg_base = pci_resource_start(hba->pcidev, in bnx2fc_map_doorbell()
1455 tgt->ctx_base = ioremap(reg_base + reg_off, 4); in bnx2fc_map_doorbell()
1456 if (!tgt->ctx_base) in bnx2fc_map_doorbell()
1457 return -ENOMEM; in bnx2fc_map_doorbell()
1463 char *buf = (char *)tgt->rq + (tgt->rq_cons_idx * BNX2FC_RQ_BUF_SZ); in bnx2fc_get_next_rqe()
1465 if (tgt->rq_cons_idx + num_items > BNX2FC_RQ_WQES_MAX) in bnx2fc_get_next_rqe()
1468 tgt->rq_cons_idx += num_items; in bnx2fc_get_next_rqe()
1470 if (tgt->rq_cons_idx >= BNX2FC_RQ_WQES_MAX) in bnx2fc_get_next_rqe()
1471 tgt->rq_cons_idx -= BNX2FC_RQ_WQES_MAX; in bnx2fc_get_next_rqe()
1479 u32 next_prod_idx = tgt->rq_prod_idx + num_items; in bnx2fc_return_rqe()
1482 next_prod_idx += 0x8000 - BNX2FC_RQ_WQES_MAX; in bnx2fc_return_rqe()
1484 tgt->rq_prod_idx = next_prod_idx; in bnx2fc_return_rqe()
1485 tgt->conn_db->rq_prod = tgt->rq_prod_idx; in bnx2fc_return_rqe()
1493 struct scsi_cmnd *sc_cmd = orig_io_req->sc_cmd; in bnx2fc_init_seq_cleanup_task()
1494 struct bnx2fc_rport *tgt = seq_clnp_req->tgt; in bnx2fc_init_seq_cleanup_task()
1495 struct fcoe_bd_ctx *bd = orig_io_req->bd_tbl->bd_tbl; in bnx2fc_init_seq_cleanup_task()
1499 u16 orig_xid = orig_io_req->xid; in bnx2fc_init_seq_cleanup_task()
1500 u32 context_id = tgt->context_id; in bnx2fc_init_seq_cleanup_task()
1501 u64 phys_addr = (u64)orig_io_req->bd_tbl->bd_tbl_dma; in bnx2fc_init_seq_cleanup_task()
1508 if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) in bnx2fc_init_seq_cleanup_task()
1514 task->txwr_rxrd.const_ctx.tx_flags = in bnx2fc_init_seq_cleanup_task()
1518 task->txwr_rxrd.const_ctx.init_flags = task_type << in bnx2fc_init_seq_cleanup_task()
1520 task->txwr_rxrd.const_ctx.init_flags |= FCOE_TASK_CLASS_TYPE_3 << in bnx2fc_init_seq_cleanup_task()
1522 task->rxwr_txrd.const_ctx.init_flags = context_id << in bnx2fc_init_seq_cleanup_task()
1524 task->rxwr_txrd.const_ctx.init_flags = context_id << in bnx2fc_init_seq_cleanup_task()
1527 task->txwr_rxrd.union_ctx.cleanup.ctx.cleaned_task_id = orig_xid; in bnx2fc_init_seq_cleanup_task()
1529 task->txwr_rxrd.union_ctx.cleanup.ctx.rolled_tx_seq_cnt = 0; in bnx2fc_init_seq_cleanup_task()
1530 task->txwr_rxrd.union_ctx.cleanup.ctx.rolled_tx_data_offset = offset; in bnx2fc_init_seq_cleanup_task()
1532 bd_count = orig_io_req->bd_tbl->bd_valid; in bnx2fc_init_seq_cleanup_task()
1538 offset -= bd[i].buf_len; in bnx2fc_init_seq_cleanup_task()
1543 task->txwr_only.sgl_ctx.sgl.mul_sgl.cur_sge_addr.lo = in bnx2fc_init_seq_cleanup_task()
1545 task->txwr_only.sgl_ctx.sgl.mul_sgl.cur_sge_addr.hi = in bnx2fc_init_seq_cleanup_task()
1547 task->txwr_only.sgl_ctx.sgl.mul_sgl.sgl_size = in bnx2fc_init_seq_cleanup_task()
1549 task->txwr_only.sgl_ctx.sgl.mul_sgl.cur_sge_off = in bnx2fc_init_seq_cleanup_task()
1551 task->txwr_only.sgl_ctx.sgl.mul_sgl.cur_sge_idx = i; in bnx2fc_init_seq_cleanup_task()
1555 sgl = &task->rxwr_only.union_ctx.read_info.sgl_ctx.sgl; in bnx2fc_init_seq_cleanup_task()
1556 sgl->mul_sgl.cur_sge_addr.lo = (u32)phys_addr; in bnx2fc_init_seq_cleanup_task()
1557 sgl->mul_sgl.cur_sge_addr.hi = (u32)((u64)phys_addr >> 32); in bnx2fc_init_seq_cleanup_task()
1558 sgl->mul_sgl.sgl_size = bd_count; in bnx2fc_init_seq_cleanup_task()
1559 sgl->mul_sgl.cur_sge_off = offset; /*adjusted offset */ in bnx2fc_init_seq_cleanup_task()
1560 sgl->mul_sgl.cur_sge_idx = i; in bnx2fc_init_seq_cleanup_task()
1562 memset(&task->rxwr_only.rx_seq_ctx, 0, in bnx2fc_init_seq_cleanup_task()
1564 task->rxwr_only.rx_seq_ctx.low_exp_ro = orig_offset; in bnx2fc_init_seq_cleanup_task()
1565 task->rxwr_only.rx_seq_ctx.high_exp_ro = orig_offset; in bnx2fc_init_seq_cleanup_task()
1573 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_init_cleanup_task()
1574 u32 context_id = tgt->context_id; in bnx2fc_init_cleanup_task()
1580 task->txwr_rxrd.const_ctx.init_flags = task_type << in bnx2fc_init_cleanup_task()
1582 task->txwr_rxrd.const_ctx.init_flags |= FCOE_TASK_CLASS_TYPE_3 << in bnx2fc_init_cleanup_task()
1584 if (tgt->dev_type == TYPE_TAPE) in bnx2fc_init_cleanup_task()
1585 task->txwr_rxrd.const_ctx.init_flags |= in bnx2fc_init_cleanup_task()
1589 task->txwr_rxrd.const_ctx.init_flags |= in bnx2fc_init_cleanup_task()
1592 task->txwr_rxrd.union_ctx.cleanup.ctx.cleaned_task_id = orig_xid; in bnx2fc_init_cleanup_task()
1595 task->txwr_rxrd.const_ctx.tx_flags = in bnx2fc_init_cleanup_task()
1600 task->rxwr_txrd.const_ctx.init_flags = context_id << in bnx2fc_init_cleanup_task()
1602 task->rxwr_txrd.var_ctx.rx_flags |= 1 << in bnx2fc_init_cleanup_task()
1609 struct bnx2fc_mp_req *mp_req = &(io_req->mp_req); in bnx2fc_init_mp_task()
1610 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_init_mp_task()
1620 if ((io_req->cmd_type == BNX2FC_TASK_MGMT_CMD) || in bnx2fc_init_mp_task()
1621 (io_req->cmd_type == BNX2FC_ELS)) { in bnx2fc_init_mp_task()
1623 } else if (io_req->cmd_type == BNX2FC_ABTS) { in bnx2fc_init_mp_task()
1630 io_req->task = task; in bnx2fc_init_mp_task()
1633 io_req->cmd_type, task_type); in bnx2fc_init_mp_task()
1638 task->txwr_only.sgl_ctx.sgl.mul_sgl.cur_sge_addr.lo = in bnx2fc_init_mp_task()
1639 (u32)mp_req->mp_req_bd_dma; in bnx2fc_init_mp_task()
1640 task->txwr_only.sgl_ctx.sgl.mul_sgl.cur_sge_addr.hi = in bnx2fc_init_mp_task()
1641 (u32)((u64)mp_req->mp_req_bd_dma >> 32); in bnx2fc_init_mp_task()
1642 task->txwr_only.sgl_ctx.sgl.mul_sgl.sgl_size = 1; in bnx2fc_init_mp_task()
1647 task->txwr_rxrd.const_ctx.init_flags = task_type << in bnx2fc_init_mp_task()
1649 if (tgt->dev_type == TYPE_TAPE) in bnx2fc_init_mp_task()
1650 task->txwr_rxrd.const_ctx.init_flags |= in bnx2fc_init_mp_task()
1654 task->txwr_rxrd.const_ctx.init_flags |= in bnx2fc_init_mp_task()
1657 task->txwr_rxrd.const_ctx.init_flags |= FCOE_TASK_CLASS_TYPE_3 << in bnx2fc_init_mp_task()
1661 task->txwr_rxrd.const_ctx.tx_flags = FCOE_TASK_TX_STATE_INIT << in bnx2fc_init_mp_task()
1665 task->rxwr_txrd.const_ctx.data_2_trns = io_req->data_xfer_len; in bnx2fc_init_mp_task()
1668 task->rxwr_txrd.var_ctx.rx_flags |= 1 << in bnx2fc_init_mp_task()
1671 context_id = tgt->context_id; in bnx2fc_init_mp_task()
1672 task->rxwr_txrd.const_ctx.init_flags = context_id << in bnx2fc_init_mp_task()
1675 fc_hdr = &(mp_req->req_fc_hdr); in bnx2fc_init_mp_task()
1677 fc_hdr->fh_ox_id = cpu_to_be16(io_req->xid); in bnx2fc_init_mp_task()
1678 fc_hdr->fh_rx_id = htons(0xffff); in bnx2fc_init_mp_task()
1679 task->rxwr_txrd.var_ctx.rx_id = 0xffff; in bnx2fc_init_mp_task()
1681 fc_hdr->fh_rx_id = cpu_to_be16(io_req->xid); in bnx2fc_init_mp_task()
1685 hdr = (u64 *) &task->txwr_rxrd.union_ctx.tx_frame.fc_hdr; in bnx2fc_init_mp_task()
1693 sgl = &task->rxwr_only.union_ctx.read_info.sgl_ctx.sgl; in bnx2fc_init_mp_task()
1695 sgl->mul_sgl.cur_sge_addr.lo = (u32)mp_req->mp_resp_bd_dma; in bnx2fc_init_mp_task()
1696 sgl->mul_sgl.cur_sge_addr.hi = in bnx2fc_init_mp_task()
1697 (u32)((u64)mp_req->mp_resp_bd_dma >> 32); in bnx2fc_init_mp_task()
1698 sgl->mul_sgl.sgl_size = 1; in bnx2fc_init_mp_task()
1706 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_init_task()
1707 struct io_bdt *bd_tbl = io_req->bd_tbl; in bnx2fc_init_task()
1708 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_init_task()
1711 int dev_type = tgt->dev_type; in bnx2fc_init_task()
1722 io_req->task = task; in bnx2fc_init_task()
1724 if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) in bnx2fc_init_task()
1730 bd_count = bd_tbl->bd_valid; in bnx2fc_init_task()
1731 cached_sge = &task->rxwr_only.union_ctx.read_info.sgl_ctx.cached_sge; in bnx2fc_init_task()
1734 struct fcoe_bd_ctx *fcoe_bd_tbl = bd_tbl->bd_tbl; in bnx2fc_init_task()
1736 task->txwr_only.sgl_ctx.cached_sge.cur_buf_addr.lo = in bnx2fc_init_task()
1737 cached_sge->cur_buf_addr.lo = in bnx2fc_init_task()
1738 fcoe_bd_tbl->buf_addr_lo; in bnx2fc_init_task()
1739 task->txwr_only.sgl_ctx.cached_sge.cur_buf_addr.hi = in bnx2fc_init_task()
1740 cached_sge->cur_buf_addr.hi = in bnx2fc_init_task()
1741 fcoe_bd_tbl->buf_addr_hi; in bnx2fc_init_task()
1742 task->txwr_only.sgl_ctx.cached_sge.cur_buf_rem = in bnx2fc_init_task()
1743 cached_sge->cur_buf_rem = in bnx2fc_init_task()
1744 fcoe_bd_tbl->buf_len; in bnx2fc_init_task()
1746 task->txwr_rxrd.const_ctx.init_flags |= 1 << in bnx2fc_init_task()
1749 task->txwr_only.sgl_ctx.sgl.mul_sgl.cur_sge_addr.lo = in bnx2fc_init_task()
1750 (u32)bd_tbl->bd_tbl_dma; in bnx2fc_init_task()
1751 task->txwr_only.sgl_ctx.sgl.mul_sgl.cur_sge_addr.hi = in bnx2fc_init_task()
1752 (u32)((u64)bd_tbl->bd_tbl_dma >> 32); in bnx2fc_init_task()
1753 task->txwr_only.sgl_ctx.sgl.mul_sgl.sgl_size = in bnx2fc_init_task()
1754 bd_tbl->bd_valid; in bnx2fc_init_task()
1760 task->txwr_rxrd.const_ctx.init_flags |= task_type << in bnx2fc_init_task()
1763 task->txwr_rxrd.const_ctx.init_flags |= in bnx2fc_init_task()
1766 io_req->rec_retry = 0; in bnx2fc_init_task()
1767 io_req->rec_retry = 0; in bnx2fc_init_task()
1769 task->txwr_rxrd.const_ctx.init_flags |= in bnx2fc_init_task()
1772 task->txwr_rxrd.const_ctx.init_flags |= FCOE_TASK_CLASS_TYPE_3 << in bnx2fc_init_task()
1775 task->txwr_rxrd.const_ctx.tx_flags = FCOE_TASK_TX_STATE_NORMAL << in bnx2fc_init_task()
1779 task->txwr_rxrd.union_ctx.tx_seq.ctx.seq_cnt = 1; in bnx2fc_init_task()
1784 int_to_scsilun(sc_cmd->device->lun, &fcp_cmnd->fc_lun); in bnx2fc_init_task()
1785 memcpy(fcp_cmnd->fc_cdb, sc_cmd->cmnd, sc_cmd->cmd_len); in bnx2fc_init_task()
1787 task->txwr_rxrd.union_ctx.fcp_cmd.opaque; in bnx2fc_init_task()
1798 task->rxwr_txrd.const_ctx.data_2_trns = io_req->data_xfer_len; in bnx2fc_init_task()
1800 context_id = tgt->context_id; in bnx2fc_init_task()
1801 task->rxwr_txrd.const_ctx.init_flags = context_id << in bnx2fc_init_task()
1806 task->rxwr_txrd.var_ctx.rx_flags |= 1 << in bnx2fc_init_task()
1809 task->rxwr_txrd.var_ctx.rx_id = 0xffff; in bnx2fc_init_task()
1815 sgl = &task->rxwr_only.union_ctx.read_info.sgl_ctx.sgl; in bnx2fc_init_task()
1816 bd_count = bd_tbl->bd_valid; in bnx2fc_init_task()
1821 struct fcoe_bd_ctx *fcoe_bd_tbl = bd_tbl->bd_tbl; in bnx2fc_init_task()
1823 cached_sge->cur_buf_addr.lo = fcoe_bd_tbl->buf_addr_lo; in bnx2fc_init_task()
1824 cached_sge->cur_buf_addr.hi = fcoe_bd_tbl->buf_addr_hi; in bnx2fc_init_task()
1825 cached_sge->cur_buf_rem = fcoe_bd_tbl->buf_len; in bnx2fc_init_task()
1826 task->txwr_rxrd.const_ctx.init_flags |= 1 << in bnx2fc_init_task()
1829 struct fcoe_bd_ctx *fcoe_bd_tbl = bd_tbl->bd_tbl; in bnx2fc_init_task()
1831 cached_sge->cur_buf_addr.lo = fcoe_bd_tbl->buf_addr_lo; in bnx2fc_init_task()
1832 cached_sge->cur_buf_addr.hi = fcoe_bd_tbl->buf_addr_hi; in bnx2fc_init_task()
1833 cached_sge->cur_buf_rem = fcoe_bd_tbl->buf_len; in bnx2fc_init_task()
1836 cached_sge->second_buf_addr.lo = in bnx2fc_init_task()
1837 fcoe_bd_tbl->buf_addr_lo; in bnx2fc_init_task()
1838 cached_sge->second_buf_addr.hi = in bnx2fc_init_task()
1839 fcoe_bd_tbl->buf_addr_hi; in bnx2fc_init_task()
1840 cached_sge->second_buf_rem = fcoe_bd_tbl->buf_len; in bnx2fc_init_task()
1841 task->txwr_rxrd.const_ctx.init_flags |= 1 << in bnx2fc_init_task()
1845 sgl->mul_sgl.cur_sge_addr.lo = (u32)bd_tbl->bd_tbl_dma; in bnx2fc_init_task()
1846 sgl->mul_sgl.cur_sge_addr.hi = in bnx2fc_init_task()
1847 (u32)((u64)bd_tbl->bd_tbl_dma >> 32); in bnx2fc_init_task()
1848 sgl->mul_sgl.sgl_size = bd_count; in bnx2fc_init_task()
1851 sgl->mul_sgl.cur_sge_addr.lo = (u32)bd_tbl->bd_tbl_dma; in bnx2fc_init_task()
1852 sgl->mul_sgl.cur_sge_addr.hi = in bnx2fc_init_task()
1853 (u32)((u64)bd_tbl->bd_tbl_dma >> 32); in bnx2fc_init_task()
1854 sgl->mul_sgl.sgl_size = bd_count; in bnx2fc_init_task()
1859 * bnx2fc_setup_task_ctx - allocate and map task context
1881 hba->task_ctx_bd_tbl = dma_alloc_coherent(&hba->pcidev->dev, in bnx2fc_setup_task_ctx()
1883 &hba->task_ctx_bd_dma, in bnx2fc_setup_task_ctx()
1885 if (!hba->task_ctx_bd_tbl) { in bnx2fc_setup_task_ctx()
1887 rc = -1; in bnx2fc_setup_task_ctx()
1895 task_ctx_arr_sz = (hba->max_tasks / BNX2FC_TASKS_PER_PAGE); in bnx2fc_setup_task_ctx()
1896 hba->task_ctx = kzalloc((task_ctx_arr_sz * sizeof(void *)), in bnx2fc_setup_task_ctx()
1898 if (!hba->task_ctx) { in bnx2fc_setup_task_ctx()
1900 rc = -1; in bnx2fc_setup_task_ctx()
1907 hba->task_ctx_dma = kmalloc((task_ctx_arr_sz * in bnx2fc_setup_task_ctx()
1909 if (!hba->task_ctx_dma) { in bnx2fc_setup_task_ctx()
1911 rc = -1; in bnx2fc_setup_task_ctx()
1915 task_ctx_bdt = (struct regpair *)hba->task_ctx_bd_tbl; in bnx2fc_setup_task_ctx()
1918 hba->task_ctx[i] = dma_alloc_coherent(&hba->pcidev->dev, in bnx2fc_setup_task_ctx()
1920 &hba->task_ctx_dma[i], in bnx2fc_setup_task_ctx()
1922 if (!hba->task_ctx[i]) { in bnx2fc_setup_task_ctx()
1924 rc = -1; in bnx2fc_setup_task_ctx()
1927 addr = (u64)hba->task_ctx_dma[i]; in bnx2fc_setup_task_ctx()
1928 task_ctx_bdt->hi = cpu_to_le32((u64)addr >> 32); in bnx2fc_setup_task_ctx()
1929 task_ctx_bdt->lo = cpu_to_le32((u32)addr); in bnx2fc_setup_task_ctx()
1936 if (hba->task_ctx[i]) { in bnx2fc_setup_task_ctx()
1938 dma_free_coherent(&hba->pcidev->dev, PAGE_SIZE, in bnx2fc_setup_task_ctx()
1939 hba->task_ctx[i], hba->task_ctx_dma[i]); in bnx2fc_setup_task_ctx()
1940 hba->task_ctx[i] = NULL; in bnx2fc_setup_task_ctx()
1944 kfree(hba->task_ctx_dma); in bnx2fc_setup_task_ctx()
1945 hba->task_ctx_dma = NULL; in bnx2fc_setup_task_ctx()
1947 kfree(hba->task_ctx); in bnx2fc_setup_task_ctx()
1948 hba->task_ctx = NULL; in bnx2fc_setup_task_ctx()
1950 dma_free_coherent(&hba->pcidev->dev, PAGE_SIZE, in bnx2fc_setup_task_ctx()
1951 hba->task_ctx_bd_tbl, hba->task_ctx_bd_dma); in bnx2fc_setup_task_ctx()
1952 hba->task_ctx_bd_tbl = NULL; in bnx2fc_setup_task_ctx()
1962 if (hba->task_ctx_bd_tbl) { in bnx2fc_free_task_ctx()
1963 dma_free_coherent(&hba->pcidev->dev, PAGE_SIZE, in bnx2fc_free_task_ctx()
1964 hba->task_ctx_bd_tbl, in bnx2fc_free_task_ctx()
1965 hba->task_ctx_bd_dma); in bnx2fc_free_task_ctx()
1966 hba->task_ctx_bd_tbl = NULL; in bnx2fc_free_task_ctx()
1969 task_ctx_arr_sz = (hba->max_tasks / BNX2FC_TASKS_PER_PAGE); in bnx2fc_free_task_ctx()
1970 if (hba->task_ctx) { in bnx2fc_free_task_ctx()
1972 if (hba->task_ctx[i]) { in bnx2fc_free_task_ctx()
1973 dma_free_coherent(&hba->pcidev->dev, PAGE_SIZE, in bnx2fc_free_task_ctx()
1974 hba->task_ctx[i], in bnx2fc_free_task_ctx()
1975 hba->task_ctx_dma[i]); in bnx2fc_free_task_ctx()
1976 hba->task_ctx[i] = NULL; in bnx2fc_free_task_ctx()
1979 kfree(hba->task_ctx); in bnx2fc_free_task_ctx()
1980 hba->task_ctx = NULL; in bnx2fc_free_task_ctx()
1983 kfree(hba->task_ctx_dma); in bnx2fc_free_task_ctx()
1984 hba->task_ctx_dma = NULL; in bnx2fc_free_task_ctx()
1993 if (hba->hash_tbl_segments) { in bnx2fc_free_hash_table()
1995 pbl = hba->hash_tbl_pbl; in bnx2fc_free_hash_table()
1997 segment_count = hba->hash_tbl_segment_count; in bnx2fc_free_hash_table()
2005 dma_free_coherent(&hba->pcidev->dev, in bnx2fc_free_hash_table()
2007 hba->hash_tbl_segments[i], in bnx2fc_free_hash_table()
2012 kfree(hba->hash_tbl_segments); in bnx2fc_free_hash_table()
2013 hba->hash_tbl_segments = NULL; in bnx2fc_free_hash_table()
2016 if (hba->hash_tbl_pbl) { in bnx2fc_free_hash_table()
2017 dma_free_coherent(&hba->pcidev->dev, PAGE_SIZE, in bnx2fc_free_hash_table()
2018 hba->hash_tbl_pbl, in bnx2fc_free_hash_table()
2019 hba->hash_tbl_pbl_dma); in bnx2fc_free_hash_table()
2020 hba->hash_tbl_pbl = NULL; in bnx2fc_free_hash_table()
2037 segment_count = hash_table_size + BNX2FC_HASH_TBL_CHUNK_SIZE - 1; in bnx2fc_allocate_hash_table()
2039 hba->hash_tbl_segment_count = segment_count; in bnx2fc_allocate_hash_table()
2041 segment_array_size = segment_count * sizeof(*hba->hash_tbl_segments); in bnx2fc_allocate_hash_table()
2042 hba->hash_tbl_segments = kzalloc(segment_array_size, GFP_KERNEL); in bnx2fc_allocate_hash_table()
2043 if (!hba->hash_tbl_segments) { in bnx2fc_allocate_hash_table()
2045 return -ENOMEM; in bnx2fc_allocate_hash_table()
2055 hba->hash_tbl_segments[i] = dma_alloc_coherent(&hba->pcidev->dev, in bnx2fc_allocate_hash_table()
2059 if (!hba->hash_tbl_segments[i]) { in bnx2fc_allocate_hash_table()
2065 hba->hash_tbl_pbl = dma_alloc_coherent(&hba->pcidev->dev, PAGE_SIZE, in bnx2fc_allocate_hash_table()
2066 &hba->hash_tbl_pbl_dma, in bnx2fc_allocate_hash_table()
2068 if (!hba->hash_tbl_pbl) { in bnx2fc_allocate_hash_table()
2073 pbl = hba->hash_tbl_pbl; in bnx2fc_allocate_hash_table()
2081 pbl = hba->hash_tbl_pbl; in bnx2fc_allocate_hash_table()
2093 if (hba->hash_tbl_segments[i]) in bnx2fc_allocate_hash_table()
2094 dma_free_coherent(&hba->pcidev->dev, in bnx2fc_allocate_hash_table()
2096 hba->hash_tbl_segments[i], in bnx2fc_allocate_hash_table()
2103 kfree(hba->hash_tbl_segments); in bnx2fc_allocate_hash_table()
2104 hba->hash_tbl_segments = NULL; in bnx2fc_allocate_hash_table()
2105 return -ENOMEM; in bnx2fc_allocate_hash_table()
2109 * bnx2fc_setup_fw_resc - Allocate and map hash table and dummy buffer
2121 return -ENOMEM; in bnx2fc_setup_fw_resc()
2124 hba->t2_hash_tbl_ptr = dma_alloc_coherent(&hba->pcidev->dev, mem_size, in bnx2fc_setup_fw_resc()
2125 &hba->t2_hash_tbl_ptr_dma, in bnx2fc_setup_fw_resc()
2127 if (!hba->t2_hash_tbl_ptr) { in bnx2fc_setup_fw_resc()
2130 return -ENOMEM; in bnx2fc_setup_fw_resc()
2135 hba->t2_hash_tbl = dma_alloc_coherent(&hba->pcidev->dev, mem_size, in bnx2fc_setup_fw_resc()
2136 &hba->t2_hash_tbl_dma, in bnx2fc_setup_fw_resc()
2138 if (!hba->t2_hash_tbl) { in bnx2fc_setup_fw_resc()
2141 return -ENOMEM; in bnx2fc_setup_fw_resc()
2144 addr = (unsigned long) hba->t2_hash_tbl_dma + in bnx2fc_setup_fw_resc()
2146 hba->t2_hash_tbl[i].next.lo = addr & 0xffffffff; in bnx2fc_setup_fw_resc()
2147 hba->t2_hash_tbl[i].next.hi = addr >> 32; in bnx2fc_setup_fw_resc()
2150 hba->dummy_buffer = dma_alloc_coherent(&hba->pcidev->dev, in bnx2fc_setup_fw_resc()
2151 PAGE_SIZE, &hba->dummy_buf_dma, in bnx2fc_setup_fw_resc()
2153 if (!hba->dummy_buffer) { in bnx2fc_setup_fw_resc()
2156 return -ENOMEM; in bnx2fc_setup_fw_resc()
2159 hba->stats_buffer = dma_alloc_coherent(&hba->pcidev->dev, PAGE_SIZE, in bnx2fc_setup_fw_resc()
2160 &hba->stats_buf_dma, in bnx2fc_setup_fw_resc()
2162 if (!hba->stats_buffer) { in bnx2fc_setup_fw_resc()
2165 return -ENOMEM; in bnx2fc_setup_fw_resc()
2175 if (hba->stats_buffer) { in bnx2fc_free_fw_resc()
2176 dma_free_coherent(&hba->pcidev->dev, PAGE_SIZE, in bnx2fc_free_fw_resc()
2177 hba->stats_buffer, hba->stats_buf_dma); in bnx2fc_free_fw_resc()
2178 hba->stats_buffer = NULL; in bnx2fc_free_fw_resc()
2181 if (hba->dummy_buffer) { in bnx2fc_free_fw_resc()
2182 dma_free_coherent(&hba->pcidev->dev, PAGE_SIZE, in bnx2fc_free_fw_resc()
2183 hba->dummy_buffer, hba->dummy_buf_dma); in bnx2fc_free_fw_resc()
2184 hba->dummy_buffer = NULL; in bnx2fc_free_fw_resc()
2187 if (hba->t2_hash_tbl_ptr) { in bnx2fc_free_fw_resc()
2189 dma_free_coherent(&hba->pcidev->dev, mem_size, in bnx2fc_free_fw_resc()
2190 hba->t2_hash_tbl_ptr, in bnx2fc_free_fw_resc()
2191 hba->t2_hash_tbl_ptr_dma); in bnx2fc_free_fw_resc()
2192 hba->t2_hash_tbl_ptr = NULL; in bnx2fc_free_fw_resc()
2195 if (hba->t2_hash_tbl) { in bnx2fc_free_fw_resc()
2198 dma_free_coherent(&hba->pcidev->dev, mem_size, in bnx2fc_free_fw_resc()
2199 hba->t2_hash_tbl, hba->t2_hash_tbl_dma); in bnx2fc_free_fw_resc()
2200 hba->t2_hash_tbl = NULL; in bnx2fc_free_fw_resc()