15 #define RESERVE_FREE_LIST_INDEX num_possible_cpus()
28 unsigned int timer_msec)
50 "req_flags = %lx\n", cmd_type, io_req->
req_flags);
83 lport = io_req->
port->lport;
84 rdata = io_req->
tgt->rdata;
94 "logo - tgt flags = 0x%lx\n",
98 lport->
tt.rport_logoff(rdata);
122 lport = io_req->
port->lport;
123 rdata = io_req->
tgt->rdata;
132 "logo - tgt flags = 0x%lx\n",
137 lport->
tt.rport_logoff(rdata);
143 "ABTS processing\n");
154 lport = io_req->
port->lport;
155 rdata = io_req->
tgt->rdata;
167 lport->
tt.rport_logoff(rdata);
218 BNX2FC_IO_DBG(io_req,
"scsi_done. err_code = 0x%x\n", err_code);
224 bnx2fc_unmap_sg_list(io_req);
228 "IO(0x%x) already cleaned up\n",
232 sc_cmd->
result = err_code << 16;
234 BNX2FC_IO_DBG(io_req,
"sc=%p, result=0x%x, retries=%d, allowed=%d\n",
237 scsi_set_resid(sc_cmd, scsi_bufflen(sc_cmd));
258 and max_xid 0x%x\n", min_xid, max_xid);
263 num_ios = max_xid - min_xid + 1;
264 len = (num_ios * (
sizeof(
struct bnx2fc_cmd *)));
290 for (i = 0; i < arr_sz; i++) {
302 for (i = 0; i <
num_ios; i++) {
303 io_req = kzalloc(
sizeof(*io_req),
GFP_KERNEL);
310 INIT_LIST_HEAD(&io_req->
link);
325 mem_size = num_ios *
sizeof(
struct io_bdt *);
332 mem_size =
sizeof(
struct io_bdt);
333 for (i = 0; i <
num_ios; i++) {
337 "io_bdt_pool[%d]\n", i);
344 for (i = 0; i <
num_ios; i++) {
374 num_ios = max_xid - min_xid + 1;
381 for (i = 0; i <
num_ios; i++) {
392 for (i = 0; i <
num_ios; i++) {
453 if ((list_empty(&(cmd_mgr->
free_list[index]))) ||
457 "ios(%d):sqes(%d)\n",
459 if (list_empty(&(cmd_mgr->
free_list[index])))
467 list_del_init(listp);
475 INIT_LIST_HEAD(&io_req->
link);
512 if ((list_empty(&cmd_mgr->
free_list[index])) ||
522 list_del_init(listp);
531 INIT_LIST_HEAD(&io_req->
link);
562 bnx2fc_free_mp_resc(io_req);
565 list_del_init(&io_req->
link);
567 list_add(&io_req->
link,
574 static void bnx2fc_free_mp_resc(
struct bnx2fc_cmd *io_req)
629 bnx2fc_free_mp_resc(io_req);
638 bnx2fc_free_mp_resc(io_req);
651 bnx2fc_free_mp_resc(io_req);
659 bnx2fc_free_mp_resc(io_req);
668 mp_req_bd->
flags = 0;
680 mp_resp_bd->
flags = 0;
685 static int bnx2fc_initiate_tmf(
struct scsi_cmnd *sc_cmd,
u8 tm_flags)
706 lport = shost_priv(host);
707 port = lport_priv(lport);
708 interface = port->
priv;
766 fcp_cmnd = (
struct fcp_cmnd *)tm_req->
req_buf;
786 interface->
hba->task_ctx[task_idx];
787 task = &(task_page[index]);
790 sc_cmd->
SCp.ptr = (
char *)io_req;
800 init_completion(&io_req->
tm_done);
815 list_del_init(&io_req->
link);
865 interface = port->priv;
896 abts_io_req->
tgt = tgt;
916 xid = abts_io_req->
xid;
923 interface->
hba->task_ctx[task_idx];
924 task = &(task_page[index]);
966 BNX2FC_IO_DBG(orig_io_req,
"bnx2fc_initiate_seq_cleanup xid = 0x%x\n",
970 port = orig_io_req->
port;
971 interface = port->priv;
991 seq_clnp_req->
tgt = tgt;
994 xid = seq_clnp_req->
xid;
1001 interface->
hba->task_ctx[task_idx];
1002 task = &(task_page[index]);
1004 cb_arg->
io_req = seq_clnp_req;
1005 cb_arg->
r_ctl = r_ctl;
1007 seq_clnp_req->
cb_arg = cb_arg;
1030 int task_idx,
index;
1037 port = io_req->
port;
1038 interface = port->priv;
1039 lport = port->
lport;
1042 if (!cleanup_io_req) {
1051 cleanup_io_req->
tgt = tgt;
1054 xid = cleanup_io_req->
xid;
1061 interface->
hba->task_ctx[task_idx];
1062 task = &(task_page[index]);
1063 orig_xid = io_req->
xid;
1134 lport->
tt.rport_logoff(rdata);
1169 lport = shost_priv(sc_cmd->
device->host);
1188 io_req->
refcount.refcount.counter);
1203 "flush in progress\n", io_req->
xid);
1211 "not on active_q\n", io_req->
xid);
1232 list_del_init(&io_req->
link);
1237 init_completion(&io_req->
tm_done);
1241 "already in abts processing\n", io_req->
xid);
1307 BNX2FC_IO_DBG(orig_io_req,
"Entered process_cleanup_compl xid = 0x%x"
1323 " IO will abort\n");
1336 "refcnt = %d, cmd_type = %d\n",
1353 BNX2FC_IO_DBG(io_req,
"Entered process_abts_compl xid = 0x%x"
1354 "refcnt = %d, cmd_type = %d\n",
1381 r_ctl = (
u8)task->
rxwr_only.union_ctx.comp_info.abts_rsp.r_ctl;
1424 list_del_init(&io_req->
link);
1434 static void bnx2fc_lun_reset_cmpl(
struct bnx2fc_cmd *io_req)
1439 int tm_lun = sc_cmd->
device->lun;
1451 lun = cmd->
sc_cmd->device->lun;
1452 if (lun == tm_lun) {
1466 " progress for this IO 0x%x\n",
1472 static void bnx2fc_tgt_reset_cmpl(
struct bnx2fc_cmd *io_req)
1499 " for this IO 0x%x\n", cmd->
xid);
1526 tm_req = &(io_req->
mp_req);
1528 hdr = (
u64 *)fc_hdr;
1530 &task->
rxwr_only.union_ctx.comp_info.mp_rsp.fc_hdr;
1536 task->
rxwr_only.union_ctx.comp_info.mp_rsp.mp_payload_len;
1541 bnx2fc_parse_fcp_rsp(io_req,
1547 bnx2fc_lun_reset_cmpl(io_req);
1549 bnx2fc_tgt_reset_cmpl(io_req);
1555 if (!sc_cmd->
SCp.ptr) {
1569 scsi_set_resid(sc_cmd, io_req->
fcp_resid);
1573 BNX2FC_IO_DBG(io_req,
"process_tm_compl: fcp_status = %d\n",
1584 list_del_init(&io_req->
link);
1606 int frag_size, sg_frags;
1614 bd[bd_index + sg_frags].
buf_addr_lo = addr & 0xffffffff;
1616 bd[bd_index + sg_frags].
buf_len = (
u16)frag_size;
1617 bd[bd_index + sg_frags].
flags = 0;
1619 addr += (
u64) frag_size;
1621 sg_len -= frag_size;
1627 static int bnx2fc_map_sg(
struct bnx2fc_cmd *io_req)
1638 unsigned int sg_len;
1648 sg_frags = bnx2fc_split_bd(io_req, addr, sg_len,
1656 bd[bd_count].
flags = 0;
1658 bd_count += sg_frags;
1659 byte_count += sg_len;
1661 if (byte_count != scsi_bufflen(sc))
1663 "task_id = 0x%x\n", byte_count, scsi_bufflen(sc),
1668 static int bnx2fc_build_bd_list_from_sg(
struct bnx2fc_cmd *io_req)
1674 if (scsi_sg_count(sc)) {
1675 bd_count = bnx2fc_map_sg(io_req);
1683 io_req->
bd_tbl->bd_valid = bd_count;
1688 static void bnx2fc_unmap_sg_list(
struct bnx2fc_cmd *io_req)
1692 if (io_req->
bd_tbl->bd_valid && sc) {
1694 io_req->
bd_tbl->bd_valid = 0;
1699 struct fcp_cmnd *fcp_cmnd)
1704 memset(fcp_cmnd, 0,
sizeof(
struct fcp_cmnd));
1716 if (scsi_populate_tag_msg(sc_cmd, tag)) {
1733 static void bnx2fc_parse_fcp_rsp(
struct bnx2fc_cmd *io_req,
1740 u32 rq_buff_len = 0;
1742 unsigned char *rq_data;
1743 unsigned char *
dummy;
1744 int fcp_sns_len = 0;
1765 fcp_rsp_len = rq_buff_len
1790 for (i = 1; i < num_rq; i++)
1795 if ((fcp_rsp_len == 4) || (fcp_rsp_len == 8)) {
1815 for (i = 0; i < num_rq; i++)
1831 struct fc_lport *lport = shost_priv(host);
1839 rval = fc_remote_port_chkready(rport);
1903 if (sc_cmd ==
NULL) {
1910 &(task->
rxwr_only.union_ctx.comp_info.fcp_rsp.payload);
1913 bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq);
1915 host = sc_cmd->
device->host;
1916 if (!sc_cmd->
SCp.ptr) {
1922 list_del_init(&io_req->
link);
1938 bnx2fc_unmap_sg_list(io_req);
1949 " fcp_resid = 0x%x\n",
1954 scsi_set_resid(sc_cmd, io_req->
fcp_resid);
1977 int task_idx,
index;
1985 sc_cmd->
SCp.ptr = (
char *)io_req;
2005 if (bnx2fc_build_bd_list_from_sg(io_req)) {
2018 task = &(task_page[index]);