^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* bnx2fc_io.c: QLogic Linux FCoE offload driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * IO manager and SCSI IO processing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2008-2013 Broadcom Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2014-2016 QLogic Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (c) 2016-2017 Cavium Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Written by: Bhanu Prakash Gollapudi (bprakash@broadcom.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "bnx2fc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define RESERVE_FREE_LIST_INDEX num_possible_cpus()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int bd_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static void bnx2fc_free_mp_resc(struct bnx2fc_cmd *io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct fcoe_fcp_rsp_payload *fcp_rsp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) u8 num_rq, unsigned char *rq_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) void bnx2fc_cmd_timer_set(struct bnx2fc_cmd *io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned int timer_msec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct bnx2fc_interface *interface = io_req->port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) if (queue_delayed_work(interface->timer_work_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) &io_req->timeout_work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) msecs_to_jiffies(timer_msec)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) kref_get(&io_req->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static void bnx2fc_cmd_timeout(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct bnx2fc_cmd *io_req = container_of(work, struct bnx2fc_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) timeout_work.work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) u8 cmd_type = io_req->cmd_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct bnx2fc_rport *tgt = io_req->tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) BNX2FC_IO_DBG(io_req, "cmd_timeout, cmd_type = %d,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) "req_flags = %lx\n", cmd_type, io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) if (test_and_clear_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * ideally we should hold the io_req until RRQ complets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * and release io_req from timeout hold.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) bnx2fc_send_rrq(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) if (test_and_clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) BNX2FC_IO_DBG(io_req, "IO ready for reuse now\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) switch (cmd_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) case BNX2FC_SCSI_CMD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) if (test_and_clear_bit(BNX2FC_FLAG_EH_ABORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* Handle eh_abort timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) BNX2FC_IO_DBG(io_req, "eh_abort timed out\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) complete(&io_req->abts_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) } else if (test_bit(BNX2FC_FLAG_ISSUE_ABTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /* Handle internally generated ABTS timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) BNX2FC_IO_DBG(io_req, "ABTS timed out refcnt = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) kref_read(&io_req->refcount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) if (!(test_and_set_bit(BNX2FC_FLAG_ABTS_DONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) &io_req->req_flags))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * Cleanup and return original command to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * mid-layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) bnx2fc_initiate_cleanup(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /* Hanlde IO timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) BNX2FC_IO_DBG(io_req, "IO timed out. issue ABTS\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (test_and_set_bit(BNX2FC_FLAG_IO_COMPL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) BNX2FC_IO_DBG(io_req, "IO completed before "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) " timer expiry\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (!test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) rc = bnx2fc_initiate_abts(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (rc == SUCCESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) BNX2FC_IO_DBG(io_req, "IO already in "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) "ABTS processing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) case BNX2FC_ELS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) BNX2FC_IO_DBG(io_req, "ABTS for ELS timed out\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (!test_and_set_bit(BNX2FC_FLAG_ABTS_DONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * Handle ELS timeout.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * tgt_lock is used to sync compl path and timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * path. If els compl path is processing this IO, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * have nothing to do here, just release the timer hold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) BNX2FC_IO_DBG(io_req, "ELS timed out\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) if (test_and_set_bit(BNX2FC_FLAG_ELS_DONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) &io_req->req_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /* Indicate the cb_func that this ELS is timed out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) set_bit(BNX2FC_FLAG_ELS_TIMEOUT, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if ((io_req->cb_func) && (io_req->cb_arg)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) io_req->cb_func(io_req->cb_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) io_req->cb_arg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) printk(KERN_ERR PFX "cmd_timeout: invalid cmd_type %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) cmd_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /* release the cmd that was held when timer was set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /* Called with host lock held */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * active_cmd_queue may have other command types as well,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * and during flush operation, we want to error back only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * scsi commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (io_req->cmd_type != BNX2FC_SCSI_CMD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) BNX2FC_IO_DBG(io_req, "scsi_done. err_code = 0x%x\n", err_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (test_bit(BNX2FC_FLAG_CMD_LOST, &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /* Do not call scsi done for this IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) bnx2fc_unmap_sg_list(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) io_req->sc_cmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /* Sanity checks before returning command to mid-layer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (!sc_cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) printk(KERN_ERR PFX "scsi_done - sc_cmd NULL. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) "IO(0x%x) already cleaned up\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (!sc_cmd->device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) pr_err(PFX "0x%x: sc_cmd->device is NULL.\n", io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (!sc_cmd->device->host) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) pr_err(PFX "0x%x: sc_cmd->device->host is NULL.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) sc_cmd->result = err_code << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) sc_cmd, host_byte(sc_cmd->result), sc_cmd->retries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) sc_cmd->allowed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) scsi_set_resid(sc_cmd, scsi_bufflen(sc_cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) sc_cmd->SCp.ptr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) sc_cmd->scsi_done(sc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct bnx2fc_cmd_mgr *cmgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct io_bdt *bdt_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) struct bnx2fc_cmd *io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) size_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) u32 mem_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) u16 xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) int num_ios, num_pri_ios;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) size_t bd_tbl_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) int arr_sz = num_possible_cpus() + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) u16 min_xid = BNX2FC_MIN_XID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) u16 max_xid = hba->max_xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) if (max_xid <= min_xid || max_xid == FC_XID_UNKNOWN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) printk(KERN_ERR PFX "cmd_mgr_alloc: Invalid min_xid 0x%x \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) and max_xid 0x%x\n", min_xid, max_xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) BNX2FC_MISC_DBG("min xid 0x%x, max xid 0x%x\n", min_xid, max_xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) num_ios = max_xid - min_xid + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) len = (num_ios * (sizeof(struct bnx2fc_cmd *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) len += sizeof(struct bnx2fc_cmd_mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) cmgr = kzalloc(len, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if (!cmgr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) printk(KERN_ERR PFX "failed to alloc cmgr\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) cmgr->hba = hba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) cmgr->free_list = kcalloc(arr_sz, sizeof(*cmgr->free_list),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) if (!cmgr->free_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) printk(KERN_ERR PFX "failed to alloc free_list\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) goto mem_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) cmgr->free_list_lock = kcalloc(arr_sz, sizeof(*cmgr->free_list_lock),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) if (!cmgr->free_list_lock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) printk(KERN_ERR PFX "failed to alloc free_list_lock\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) kfree(cmgr->free_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) cmgr->free_list = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) goto mem_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) cmgr->cmds = (struct bnx2fc_cmd **)(cmgr + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) for (i = 0; i < arr_sz; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) INIT_LIST_HEAD(&cmgr->free_list[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) spin_lock_init(&cmgr->free_list_lock[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) * Pre-allocated pool of bnx2fc_cmds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * Last entry in the free list array is the free list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * of slow path requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) xid = BNX2FC_MIN_XID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) num_pri_ios = num_ios - hba->elstm_xids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) for (i = 0; i < num_ios; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) io_req = kzalloc(sizeof(*io_req), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (!io_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) printk(KERN_ERR PFX "failed to alloc io_req\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) goto mem_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) INIT_LIST_HEAD(&io_req->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) INIT_DELAYED_WORK(&io_req->timeout_work, bnx2fc_cmd_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) io_req->xid = xid++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) if (i < num_pri_ios)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) list_add_tail(&io_req->link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) &cmgr->free_list[io_req->xid %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) num_possible_cpus()]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) list_add_tail(&io_req->link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) &cmgr->free_list[num_possible_cpus()]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) io_req++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) /* Allocate pool of io_bdts - one for each bnx2fc_cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) mem_size = num_ios * sizeof(struct io_bdt *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) cmgr->io_bdt_pool = kzalloc(mem_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) if (!cmgr->io_bdt_pool) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) printk(KERN_ERR PFX "failed to alloc io_bdt_pool\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) goto mem_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) mem_size = sizeof(struct io_bdt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) for (i = 0; i < num_ios; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) cmgr->io_bdt_pool[i] = kmalloc(mem_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if (!cmgr->io_bdt_pool[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) printk(KERN_ERR PFX "failed to alloc "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) "io_bdt_pool[%d]\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) goto mem_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /* Allocate an map fcoe_bdt_ctx structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) bd_tbl_sz = BNX2FC_MAX_BDS_PER_CMD * sizeof(struct fcoe_bd_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) for (i = 0; i < num_ios; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) bdt_info = cmgr->io_bdt_pool[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) bdt_info->bd_tbl = dma_alloc_coherent(&hba->pcidev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) bd_tbl_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) &bdt_info->bd_tbl_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) if (!bdt_info->bd_tbl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) printk(KERN_ERR PFX "failed to alloc "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) "bdt_tbl[%d]\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) goto mem_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) return cmgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) mem_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) bnx2fc_cmd_mgr_free(cmgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) void bnx2fc_cmd_mgr_free(struct bnx2fc_cmd_mgr *cmgr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) struct io_bdt *bdt_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) struct bnx2fc_hba *hba = cmgr->hba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) size_t bd_tbl_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) u16 min_xid = BNX2FC_MIN_XID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) u16 max_xid = hba->max_xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) int num_ios;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) num_ios = max_xid - min_xid + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) /* Free fcoe_bdt_ctx structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) if (!cmgr->io_bdt_pool)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) goto free_cmd_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) bd_tbl_sz = BNX2FC_MAX_BDS_PER_CMD * sizeof(struct fcoe_bd_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) for (i = 0; i < num_ios; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) bdt_info = cmgr->io_bdt_pool[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) if (bdt_info->bd_tbl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) dma_free_coherent(&hba->pcidev->dev, bd_tbl_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) bdt_info->bd_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) bdt_info->bd_tbl_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) bdt_info->bd_tbl = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /* Destroy io_bdt pool */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) for (i = 0; i < num_ios; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) kfree(cmgr->io_bdt_pool[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) cmgr->io_bdt_pool[i] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) kfree(cmgr->io_bdt_pool);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) cmgr->io_bdt_pool = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) free_cmd_pool:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) kfree(cmgr->free_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) /* Destroy cmd pool */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) if (!cmgr->free_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) goto free_cmgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) for (i = 0; i < num_possible_cpus() + 1; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) struct bnx2fc_cmd *tmp, *io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) list_for_each_entry_safe(io_req, tmp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) &cmgr->free_list[i], link) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) list_del(&io_req->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) kfree(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) kfree(cmgr->free_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) free_cmgr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) /* Free command manager itself */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) kfree(cmgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) struct bnx2fc_cmd *bnx2fc_elstm_alloc(struct bnx2fc_rport *tgt, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) struct fcoe_port *port = tgt->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) struct bnx2fc_interface *interface = port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) struct bnx2fc_cmd_mgr *cmd_mgr = interface->hba->cmd_mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) struct bnx2fc_cmd *io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) struct list_head *listp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) struct io_bdt *bd_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) int index = RESERVE_FREE_LIST_INDEX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) u32 free_sqes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) u32 max_sqes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) u16 xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) max_sqes = tgt->max_sqes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) case BNX2FC_TASK_MGMT_CMD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) max_sqes = BNX2FC_TM_MAX_SQES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) case BNX2FC_ELS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) max_sqes = BNX2FC_ELS_MAX_SQES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) * NOTE: Free list insertions and deletions are protected with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) * cmgr lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) spin_lock_bh(&cmd_mgr->free_list_lock[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) free_sqes = atomic_read(&tgt->free_sqes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) if ((list_empty(&(cmd_mgr->free_list[index]))) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) (tgt->num_active_ios.counter >= max_sqes) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) (free_sqes + max_sqes <= BNX2FC_SQ_WQES_MAX)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) BNX2FC_TGT_DBG(tgt, "No free els_tm cmds available "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) "ios(%d):sqes(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) tgt->num_active_ios.counter, tgt->max_sqes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) if (list_empty(&(cmd_mgr->free_list[index])))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) printk(KERN_ERR PFX "elstm_alloc: list_empty\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) spin_unlock_bh(&cmd_mgr->free_list_lock[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) listp = (struct list_head *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) cmd_mgr->free_list[index].next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) list_del_init(listp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) io_req = (struct bnx2fc_cmd *) listp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) xid = io_req->xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) cmd_mgr->cmds[xid] = io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) atomic_inc(&tgt->num_active_ios);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) atomic_dec(&tgt->free_sqes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) spin_unlock_bh(&cmd_mgr->free_list_lock[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) INIT_LIST_HEAD(&io_req->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) io_req->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) io_req->cmd_mgr = cmd_mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) io_req->req_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) io_req->cmd_type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) /* Bind io_bdt for this io_req */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) /* Have a static link between io_req and io_bdt_pool */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) bd_tbl->io_req = io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) /* Hold the io_req against deletion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) kref_init(&io_req->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) return io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) struct fcoe_port *port = tgt->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) struct bnx2fc_interface *interface = port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) struct bnx2fc_cmd_mgr *cmd_mgr = interface->hba->cmd_mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) struct bnx2fc_cmd *io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) struct list_head *listp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) struct io_bdt *bd_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) u32 free_sqes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) u32 max_sqes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) u16 xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) int index = get_cpu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) max_sqes = BNX2FC_SCSI_MAX_SQES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) * NOTE: Free list insertions and deletions are protected with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) * cmgr lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) spin_lock_bh(&cmd_mgr->free_list_lock[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) free_sqes = atomic_read(&tgt->free_sqes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) if ((list_empty(&cmd_mgr->free_list[index])) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) (tgt->num_active_ios.counter >= max_sqes) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) (free_sqes + max_sqes <= BNX2FC_SQ_WQES_MAX)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) spin_unlock_bh(&cmd_mgr->free_list_lock[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) put_cpu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) listp = (struct list_head *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) cmd_mgr->free_list[index].next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) list_del_init(listp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) io_req = (struct bnx2fc_cmd *) listp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) xid = io_req->xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) cmd_mgr->cmds[xid] = io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) atomic_inc(&tgt->num_active_ios);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) atomic_dec(&tgt->free_sqes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) spin_unlock_bh(&cmd_mgr->free_list_lock[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) put_cpu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) INIT_LIST_HEAD(&io_req->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) io_req->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) io_req->cmd_mgr = cmd_mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) io_req->req_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) /* Bind io_bdt for this io_req */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) /* Have a static link between io_req and io_bdt_pool */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) bd_tbl->io_req = io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) /* Hold the io_req against deletion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) kref_init(&io_req->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) return io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) void bnx2fc_cmd_release(struct kref *ref)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) struct bnx2fc_cmd *io_req = container_of(ref,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) struct bnx2fc_cmd, refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) struct bnx2fc_cmd_mgr *cmd_mgr = io_req->cmd_mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) if (io_req->cmd_type == BNX2FC_SCSI_CMD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) index = io_req->xid % num_possible_cpus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) index = RESERVE_FREE_LIST_INDEX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) spin_lock_bh(&cmd_mgr->free_list_lock[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) if (io_req->cmd_type != BNX2FC_SCSI_CMD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) bnx2fc_free_mp_resc(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) cmd_mgr->cmds[io_req->xid] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) /* Delete IO from retire queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) list_del_init(&io_req->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) /* Add it to the free list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) list_add(&io_req->link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) &cmd_mgr->free_list[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) atomic_dec(&io_req->tgt->num_active_ios);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) spin_unlock_bh(&cmd_mgr->free_list_lock[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) static void bnx2fc_free_mp_resc(struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) struct bnx2fc_mp_req *mp_req = &(io_req->mp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) struct bnx2fc_interface *interface = io_req->port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) struct bnx2fc_hba *hba = interface->hba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) size_t sz = sizeof(struct fcoe_bd_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) /* clear tm flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) mp_req->tm_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (mp_req->mp_req_bd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) dma_free_coherent(&hba->pcidev->dev, sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) mp_req->mp_req_bd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) mp_req->mp_req_bd_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) mp_req->mp_req_bd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) if (mp_req->mp_resp_bd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) dma_free_coherent(&hba->pcidev->dev, sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) mp_req->mp_resp_bd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) mp_req->mp_resp_bd_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) mp_req->mp_resp_bd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) if (mp_req->req_buf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) dma_free_coherent(&hba->pcidev->dev, CNIC_PAGE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) mp_req->req_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) mp_req->req_buf_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) mp_req->req_buf = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) if (mp_req->resp_buf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) dma_free_coherent(&hba->pcidev->dev, CNIC_PAGE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) mp_req->resp_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) mp_req->resp_buf_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) mp_req->resp_buf = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) struct bnx2fc_mp_req *mp_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) struct fcoe_bd_ctx *mp_req_bd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) struct fcoe_bd_ctx *mp_resp_bd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) struct bnx2fc_interface *interface = io_req->port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) struct bnx2fc_hba *hba = interface->hba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) dma_addr_t addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) size_t sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) mp_req = (struct bnx2fc_mp_req *)&(io_req->mp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) memset(mp_req, 0, sizeof(struct bnx2fc_mp_req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) if (io_req->cmd_type != BNX2FC_ELS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) mp_req->req_len = sizeof(struct fcp_cmnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) io_req->data_xfer_len = mp_req->req_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) mp_req->req_len = io_req->data_xfer_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) mp_req->req_buf = dma_alloc_coherent(&hba->pcidev->dev, CNIC_PAGE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) &mp_req->req_buf_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) if (!mp_req->req_buf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) printk(KERN_ERR PFX "unable to alloc MP req buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) bnx2fc_free_mp_resc(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) mp_req->resp_buf = dma_alloc_coherent(&hba->pcidev->dev, CNIC_PAGE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) &mp_req->resp_buf_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) if (!mp_req->resp_buf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) printk(KERN_ERR PFX "unable to alloc TM resp buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) bnx2fc_free_mp_resc(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) memset(mp_req->req_buf, 0, CNIC_PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) memset(mp_req->resp_buf, 0, CNIC_PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) /* Allocate and map mp_req_bd and mp_resp_bd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) sz = sizeof(struct fcoe_bd_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) mp_req->mp_req_bd = dma_alloc_coherent(&hba->pcidev->dev, sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) &mp_req->mp_req_bd_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) if (!mp_req->mp_req_bd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) printk(KERN_ERR PFX "unable to alloc MP req bd\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) bnx2fc_free_mp_resc(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) mp_req->mp_resp_bd = dma_alloc_coherent(&hba->pcidev->dev, sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) &mp_req->mp_resp_bd_dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) if (!mp_req->mp_resp_bd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) printk(KERN_ERR PFX "unable to alloc MP resp bd\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) bnx2fc_free_mp_resc(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) /* Fill bd table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) addr = mp_req->req_buf_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) mp_req_bd = mp_req->mp_req_bd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) mp_req_bd->buf_addr_lo = (u32)addr & 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) mp_req_bd->buf_addr_hi = (u32)((u64)addr >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) mp_req_bd->buf_len = CNIC_PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) mp_req_bd->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) * MP buffer is either a task mgmt command or an ELS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) * So the assumption is that it consumes a single bd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) * entry in the bd table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) mp_resp_bd = mp_req->mp_resp_bd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) addr = mp_req->resp_buf_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) mp_resp_bd->buf_addr_lo = (u32)addr & 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) mp_resp_bd->buf_addr_hi = (u32)((u64)addr >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) mp_resp_bd->buf_len = CNIC_PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) mp_resp_bd->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) struct fc_lport *lport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) struct fc_rport *rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) struct fc_rport_libfc_priv *rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) struct fcoe_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) struct bnx2fc_interface *interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) struct bnx2fc_rport *tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) struct bnx2fc_cmd *io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) struct bnx2fc_mp_req *tm_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) struct fcoe_task_ctx_entry *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) struct fcoe_task_ctx_entry *task_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) struct Scsi_Host *host = sc_cmd->device->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) struct fc_frame_header *fc_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) struct fcp_cmnd *fcp_cmnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) int task_idx, index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) int rc = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) u16 xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) u32 sid, did;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) unsigned long start = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) lport = shost_priv(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) rport = starget_to_rport(scsi_target(sc_cmd->device));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) port = lport_priv(lport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) interface = port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) if (rport == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) printk(KERN_ERR PFX "device_reset: rport is NULL\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) goto tmf_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) rp = rport->dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) rc = fc_block_scsi_eh(sc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) if (lport->state != LPORT_ST_READY || !(lport->link_up)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) printk(KERN_ERR PFX "device_reset: link is not ready\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) goto tmf_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) /* rport and tgt are allocated together, so tgt should be non-NULL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) tgt = (struct bnx2fc_rport *)&rp[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) if (!(test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) printk(KERN_ERR PFX "device_reset: tgt not offloaded\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) goto tmf_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) retry_tmf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) io_req = bnx2fc_elstm_alloc(tgt, BNX2FC_TASK_MGMT_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) if (!io_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) if (time_after(jiffies, start + HZ)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) printk(KERN_ERR PFX "tmf: Failed TMF");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) goto tmf_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) msleep(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) goto retry_tmf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) /* Initialize rest of io_req fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) io_req->sc_cmd = sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) io_req->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) io_req->tgt = tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) tm_req = (struct bnx2fc_mp_req *)&(io_req->mp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) rc = bnx2fc_init_mp_req(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) if (rc == FAILED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) printk(KERN_ERR PFX "Task mgmt MP request init failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) goto tmf_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) /* Set TM flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) io_req->io_req_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) tm_req->tm_flags = tm_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) /* Fill FCP_CMND */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) bnx2fc_build_fcp_cmnd(io_req, (struct fcp_cmnd *)tm_req->req_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) fcp_cmnd = (struct fcp_cmnd *)tm_req->req_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) memset(fcp_cmnd->fc_cdb, 0, sc_cmd->cmd_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) fcp_cmnd->fc_dl = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) /* Fill FC header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) fc_hdr = &(tm_req->req_fc_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) sid = tgt->sid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) did = rport->port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) __fc_fill_fc_hdr(fc_hdr, FC_RCTL_DD_UNSOL_CMD, did, sid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) FC_TYPE_FCP, FC_FC_FIRST_SEQ | FC_FC_END_SEQ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) FC_FC_SEQ_INIT, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) /* Obtain exchange id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) xid = io_req->xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) BNX2FC_TGT_DBG(tgt, "Initiate TMF - xid = 0x%x\n", xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) task_idx = xid/BNX2FC_TASKS_PER_PAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) index = xid % BNX2FC_TASKS_PER_PAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) /* Initialize task context for this IO request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) task_page = (struct fcoe_task_ctx_entry *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) interface->hba->task_ctx[task_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) task = &(task_page[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) bnx2fc_init_mp_task(io_req, task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) sc_cmd->SCp.ptr = (char *)io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) /* Obtain free SQ entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) bnx2fc_add_2_sq(tgt, xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) /* Enqueue the io_req to active_tm_queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) io_req->on_tmf_queue = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) list_add_tail(&io_req->link, &tgt->active_tm_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) init_completion(&io_req->abts_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) io_req->wait_for_abts_comp = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) /* Ring doorbell */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) bnx2fc_ring_doorbell(tgt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) rc = wait_for_completion_timeout(&io_req->abts_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) interface->tm_timeout * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) io_req->wait_for_abts_comp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) if (!(test_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) set_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) if (io_req->on_tmf_queue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) list_del_init(&io_req->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) io_req->on_tmf_queue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) io_req->wait_for_cleanup_comp = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) init_completion(&io_req->cleanup_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) bnx2fc_initiate_cleanup(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) rc = wait_for_completion_timeout(&io_req->cleanup_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) BNX2FC_FW_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) io_req->wait_for_cleanup_comp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) BNX2FC_TGT_DBG(tgt, "task mgmt command failed...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) BNX2FC_TGT_DBG(tgt, "task mgmt command success...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) rc = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) tmf_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) int bnx2fc_initiate_abts(struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) struct fc_lport *lport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) struct bnx2fc_rport *tgt = io_req->tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) struct fc_rport *rport = tgt->rport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) struct fc_rport_priv *rdata = tgt->rdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) struct bnx2fc_interface *interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) struct fcoe_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) struct bnx2fc_cmd *abts_io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) struct fcoe_task_ctx_entry *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) struct fcoe_task_ctx_entry *task_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) struct fc_frame_header *fc_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) struct bnx2fc_mp_req *abts_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) int task_idx, index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) u32 sid, did;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) u16 xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) int rc = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) u32 r_a_tov = rdata->r_a_tov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) /* called with tgt_lock held */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_abts\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) port = io_req->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) interface = port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) lport = port->lport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) printk(KERN_ERR PFX "initiate_abts: tgt not offloaded\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) goto abts_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) if (rport == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) printk(KERN_ERR PFX "initiate_abts: rport is NULL\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) goto abts_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) if (lport->state != LPORT_ST_READY || !(lport->link_up)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) printk(KERN_ERR PFX "initiate_abts: link is not ready\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) goto abts_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) abts_io_req = bnx2fc_elstm_alloc(tgt, BNX2FC_ABTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) if (!abts_io_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) printk(KERN_ERR PFX "abts: couldn't allocate cmd\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) goto abts_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) /* Initialize rest of io_req fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) abts_io_req->sc_cmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) abts_io_req->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) abts_io_req->tgt = tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) abts_io_req->data_xfer_len = 0; /* No data transfer for ABTS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) abts_req = (struct bnx2fc_mp_req *)&(abts_io_req->mp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) memset(abts_req, 0, sizeof(struct bnx2fc_mp_req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) /* Fill FC header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) fc_hdr = &(abts_req->req_fc_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) /* Obtain oxid and rxid for the original exchange to be aborted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) fc_hdr->fh_ox_id = htons(io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) fc_hdr->fh_rx_id = htons(io_req->task->rxwr_txrd.var_ctx.rx_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) sid = tgt->sid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) did = rport->port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) __fc_fill_fc_hdr(fc_hdr, FC_RCTL_BA_ABTS, did, sid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) FC_TYPE_BLS, FC_FC_FIRST_SEQ | FC_FC_END_SEQ |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) FC_FC_SEQ_INIT, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) xid = abts_io_req->xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) BNX2FC_IO_DBG(abts_io_req, "ABTS io_req\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) task_idx = xid/BNX2FC_TASKS_PER_PAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) index = xid % BNX2FC_TASKS_PER_PAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) /* Initialize task context for this IO request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) task_page = (struct fcoe_task_ctx_entry *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) interface->hba->task_ctx[task_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) task = &(task_page[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) bnx2fc_init_mp_task(abts_io_req, task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) * ABTS task is a temporary task that will be cleaned up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) * irrespective of ABTS response. We need to start the timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) * for the original exchange, as the CQE is posted for the original
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) * IO request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) * Timer for ABTS is started only when it is originated by a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) * TM request. For the ABTS issued as part of ULP timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) * scsi-ml maintains the timers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) /* if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags))*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) bnx2fc_cmd_timer_set(io_req, 2 * r_a_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) /* Obtain free SQ entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) bnx2fc_add_2_sq(tgt, xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) /* Ring doorbell */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) bnx2fc_ring_doorbell(tgt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) abts_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) int bnx2fc_initiate_seq_cleanup(struct bnx2fc_cmd *orig_io_req, u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) enum fc_rctl r_ctl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) struct bnx2fc_rport *tgt = orig_io_req->tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) struct bnx2fc_interface *interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) struct fcoe_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) struct bnx2fc_cmd *seq_clnp_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) struct fcoe_task_ctx_entry *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) struct fcoe_task_ctx_entry *task_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) struct bnx2fc_els_cb_arg *cb_arg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) int task_idx, index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) u16 xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) BNX2FC_IO_DBG(orig_io_req, "bnx2fc_initiate_seq_cleanup xid = 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) orig_io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) kref_get(&orig_io_req->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) port = orig_io_req->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) interface = port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) cb_arg = kzalloc(sizeof(struct bnx2fc_els_cb_arg), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) if (!cb_arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) printk(KERN_ERR PFX "Unable to alloc cb_arg for seq clnup\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) goto cleanup_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) seq_clnp_req = bnx2fc_elstm_alloc(tgt, BNX2FC_SEQ_CLEANUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) if (!seq_clnp_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) printk(KERN_ERR PFX "cleanup: couldn't allocate cmd\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) kfree(cb_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) goto cleanup_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) /* Initialize rest of io_req fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) seq_clnp_req->sc_cmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) seq_clnp_req->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) seq_clnp_req->tgt = tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) seq_clnp_req->data_xfer_len = 0; /* No data transfer for cleanup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) xid = seq_clnp_req->xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) task_idx = xid/BNX2FC_TASKS_PER_PAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) index = xid % BNX2FC_TASKS_PER_PAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) /* Initialize task context for this IO request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) task_page = (struct fcoe_task_ctx_entry *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) interface->hba->task_ctx[task_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) task = &(task_page[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) cb_arg->aborted_io_req = orig_io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) cb_arg->io_req = seq_clnp_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) cb_arg->r_ctl = r_ctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) cb_arg->offset = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) seq_clnp_req->cb_arg = cb_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) printk(KERN_ERR PFX "call init_seq_cleanup_task\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) bnx2fc_init_seq_cleanup_task(seq_clnp_req, task, orig_io_req, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) /* Obtain free SQ entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) bnx2fc_add_2_sq(tgt, xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) /* Ring doorbell */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) bnx2fc_ring_doorbell(tgt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) cleanup_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) struct bnx2fc_rport *tgt = io_req->tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) struct bnx2fc_interface *interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) struct fcoe_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) struct bnx2fc_cmd *cleanup_io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) struct fcoe_task_ctx_entry *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) struct fcoe_task_ctx_entry *task_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) int task_idx, index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) u16 xid, orig_xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) /* ASSUMPTION: called with tgt_lock held */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_cleanup\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) port = io_req->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) interface = port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) cleanup_io_req = bnx2fc_elstm_alloc(tgt, BNX2FC_CLEANUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) if (!cleanup_io_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) printk(KERN_ERR PFX "cleanup: couldn't allocate cmd\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) rc = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) goto cleanup_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) /* Initialize rest of io_req fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) cleanup_io_req->sc_cmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) cleanup_io_req->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) cleanup_io_req->tgt = tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) cleanup_io_req->data_xfer_len = 0; /* No data transfer for cleanup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) xid = cleanup_io_req->xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) task_idx = xid/BNX2FC_TASKS_PER_PAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) index = xid % BNX2FC_TASKS_PER_PAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) /* Initialize task context for this IO request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) task_page = (struct fcoe_task_ctx_entry *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) interface->hba->task_ctx[task_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) task = &(task_page[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) orig_xid = io_req->xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) BNX2FC_IO_DBG(io_req, "CLEANUP io_req xid = 0x%x\n", xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) bnx2fc_init_cleanup_task(cleanup_io_req, task, orig_xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) /* Obtain free SQ entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) bnx2fc_add_2_sq(tgt, xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) /* Set flag that cleanup request is pending with the firmware */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) set_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) /* Ring doorbell */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) bnx2fc_ring_doorbell(tgt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) cleanup_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) * bnx2fc_eh_target_reset: Reset a target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) * @sc_cmd: SCSI command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) * Set from SCSI host template to send task mgmt command to the target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) * and wait for the response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) int bnx2fc_eh_target_reset(struct scsi_cmnd *sc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) return bnx2fc_initiate_tmf(sc_cmd, FCP_TMF_TGT_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) * bnx2fc_eh_device_reset - Reset a single LUN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) * @sc_cmd: SCSI command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) * Set from SCSI host template to send task mgmt command to the target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) * and wait for the response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) int bnx2fc_eh_device_reset(struct scsi_cmnd *sc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) return bnx2fc_initiate_tmf(sc_cmd, FCP_TMF_LUN_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) static int bnx2fc_abts_cleanup(struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) __must_hold(&tgt->tgt_lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) struct bnx2fc_rport *tgt = io_req->tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) unsigned int time_left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) init_completion(&io_req->cleanup_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) io_req->wait_for_cleanup_comp = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) bnx2fc_initiate_cleanup(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) * Can't wait forever on cleanup response lest we let the SCSI error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) * handler wait forever
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) time_left = wait_for_completion_timeout(&io_req->cleanup_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) BNX2FC_FW_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) if (!time_left) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) BNX2FC_IO_DBG(io_req, "%s(): Wait for cleanup timed out.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) * Put the extra reference to the SCSI command since it would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) * not have been returned in this case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) io_req->wait_for_cleanup_comp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) * bnx2fc_eh_abort - eh_abort_handler api to abort an outstanding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) * SCSI command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) * @sc_cmd: SCSI_ML command pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) * SCSI abort request handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) struct fc_rport_libfc_priv *rp = rport->dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) struct bnx2fc_cmd *io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) struct fc_lport *lport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) struct bnx2fc_rport *tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) unsigned int time_left;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) rc = fc_block_scsi_eh(sc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) lport = shost_priv(sc_cmd->device->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) if ((lport->state != LPORT_ST_READY) || !(lport->link_up)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) printk(KERN_ERR PFX "eh_abort: link not ready\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) tgt = (struct bnx2fc_rport *)&rp[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) BNX2FC_TGT_DBG(tgt, "Entered bnx2fc_eh_abort\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) io_req = (struct bnx2fc_cmd *)sc_cmd->SCp.ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) if (!io_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) /* Command might have just completed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) printk(KERN_ERR PFX "eh_abort: io_req is NULL\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) BNX2FC_IO_DBG(io_req, "eh_abort - refcnt = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) kref_read(&io_req->refcount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) /* Hold IO request across abort processing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) kref_get(&io_req->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) BUG_ON(tgt != io_req->tgt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) /* Remove the io_req from the active_q. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) * Task Mgmt functions (LUN RESET & TGT RESET) will not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) * issue an ABTS on this particular IO req, as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) * io_req is no longer in the active_q.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) if (tgt->flush_in_prog) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) "flush in progress\n", io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) return SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) if (io_req->on_active_queue == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) "not on active_q\n", io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) * The IO is still with the FW.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) * Return failure and let SCSI-ml retry eh_abort.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) return FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) * Only eh_abort processing will remove the IO from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) * active_cmd_q before processing the request. this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) * done to avoid race conditions between IOs aborted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) * as part of task management completion and eh_abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) * processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) list_del_init(&io_req->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) io_req->on_active_queue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) /* Move IO req to retire queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) list_add_tail(&io_req->link, &tgt->io_retire_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) init_completion(&io_req->abts_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) init_completion(&io_req->cleanup_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) if (test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) "already in abts processing\n", io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) if (cancel_delayed_work(&io_req->timeout_work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) kref_put(&io_req->refcount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) bnx2fc_cmd_release); /* drop timer hold */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) * We don't want to hold off the upper layer timer so simply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) * cleanup the command and return that I/O was successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) * aborted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) rc = bnx2fc_abts_cleanup(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) /* This only occurs when an task abort was requested while ABTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) is in progress. Setting the IO_CLEANUP flag will skip the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) RRQ process in the case when the fw generated SCSI_CMD cmpl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) was a result from the ABTS request rather than the CLEANUP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) rc = FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) /* Cancel the current timer running on this io_req */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) if (cancel_delayed_work(&io_req->timeout_work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) kref_put(&io_req->refcount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) bnx2fc_cmd_release); /* drop timer hold */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) set_bit(BNX2FC_FLAG_EH_ABORT, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) io_req->wait_for_abts_comp = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) rc = bnx2fc_initiate_abts(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) if (rc == FAILED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) io_req->wait_for_cleanup_comp = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) bnx2fc_initiate_cleanup(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) wait_for_completion(&io_req->cleanup_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) io_req->wait_for_cleanup_comp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) /* Wait 2 * RA_TOV + 1 to be sure timeout function hasn't fired */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) time_left = wait_for_completion_timeout(&io_req->abts_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) msecs_to_jiffies(2 * rp->r_a_tov + 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) if (time_left)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) BNX2FC_IO_DBG(io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) "Timed out in eh_abort waiting for abts_done");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) io_req->wait_for_abts_comp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) if (test_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) BNX2FC_IO_DBG(io_req, "IO completed in a different context\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) rc = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) } else if (!(test_and_set_bit(BNX2FC_FLAG_ABTS_DONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) &io_req->req_flags))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) /* Let the scsi-ml try to recover this command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) printk(KERN_ERR PFX "abort failed, xid = 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) * Cleanup firmware residuals before returning control back
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) * to SCSI ML.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) rc = bnx2fc_abts_cleanup(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) * We come here even when there was a race condition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) * between timeout and abts completion, and abts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) * completion happens just in time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) BNX2FC_IO_DBG(io_req, "abort succeeded\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) rc = SUCCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) bnx2fc_scsi_done(io_req, DID_ABORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) /* release the reference taken in eh_abort */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) void bnx2fc_process_seq_cleanup_compl(struct bnx2fc_cmd *seq_clnp_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) struct fcoe_task_ctx_entry *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) u8 rx_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) struct bnx2fc_els_cb_arg *cb_arg = seq_clnp_req->cb_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) struct bnx2fc_cmd *orig_io_req = cb_arg->aborted_io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) u32 offset = cb_arg->offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) enum fc_rctl r_ctl = cb_arg->r_ctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) struct bnx2fc_rport *tgt = orig_io_req->tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) BNX2FC_IO_DBG(orig_io_req, "Entered process_cleanup_compl xid = 0x%x"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) "cmd_type = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) seq_clnp_req->xid, seq_clnp_req->cmd_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) if (rx_state == FCOE_TASK_RX_STATE_IGNORED_SEQUENCE_CLEANUP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) printk(KERN_ERR PFX "seq cleanup ignored - xid = 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) seq_clnp_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) goto free_cb_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) rc = bnx2fc_send_srr(orig_io_req, offset, r_ctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) printk(KERN_ERR PFX "clnup_compl: Unable to send SRR"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) " IO will abort\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) seq_clnp_req->cb_arg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) kref_put(&orig_io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) free_cb_arg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) kfree(cb_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) void bnx2fc_process_cleanup_compl(struct bnx2fc_cmd *io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) struct fcoe_task_ctx_entry *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) u8 num_rq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) BNX2FC_IO_DBG(io_req, "Entered process_cleanup_compl "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) "refcnt = %d, cmd_type = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) kref_read(&io_req->refcount), io_req->cmd_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) * Test whether there is a cleanup request pending. If not just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) * exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) if (!test_and_clear_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) &io_req->req_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) * If we receive a cleanup completion for this request then the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) * firmware will not give us an abort completion for this request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) * so clear any ABTS pending flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) !test_bit(BNX2FC_FLAG_ABTS_DONE, &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) set_bit(BNX2FC_FLAG_ABTS_DONE, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) if (io_req->wait_for_abts_comp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) complete(&io_req->abts_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) bnx2fc_scsi_done(io_req, DID_ERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) if (io_req->wait_for_cleanup_comp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) complete(&io_req->cleanup_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) void bnx2fc_process_abts_compl(struct bnx2fc_cmd *io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) struct fcoe_task_ctx_entry *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) u8 num_rq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) u32 r_ctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) u32 r_a_tov = FC_DEF_R_A_TOV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) u8 issue_rrq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) struct bnx2fc_rport *tgt = io_req->tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) BNX2FC_IO_DBG(io_req, "Entered process_abts_compl xid = 0x%x"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) "refcnt = %d, cmd_type = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) io_req->xid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) kref_read(&io_req->refcount), io_req->cmd_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) if (test_and_set_bit(BNX2FC_FLAG_ABTS_DONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) BNX2FC_IO_DBG(io_req, "Timer context finished processing"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) " this io\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) * If we receive an ABTS completion here then we will not receive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) * a cleanup completion so clear any cleanup pending flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) if (test_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) clear_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) if (io_req->wait_for_cleanup_comp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) complete(&io_req->cleanup_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) /* Do not issue RRQ as this IO is already cleanedup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) if (test_and_set_bit(BNX2FC_FLAG_IO_CLEANUP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) &io_req->req_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) goto io_compl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) * For ABTS issued due to SCSI eh_abort_handler, timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) * values are maintained by scsi-ml itself. Cancel timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) * in case ABTS issued as part of task management function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) * or due to FW error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) if (cancel_delayed_work(&io_req->timeout_work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) kref_put(&io_req->refcount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) bnx2fc_cmd_release); /* drop timer hold */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) r_ctl = (u8)task->rxwr_only.union_ctx.comp_info.abts_rsp.r_ctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) switch (r_ctl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) case FC_RCTL_BA_ACC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) * Dont release this cmd yet. It will be relesed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) * after we get RRQ response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) BNX2FC_IO_DBG(io_req, "ABTS response - ACC Send RRQ\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) issue_rrq = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) case FC_RCTL_BA_RJT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) BNX2FC_IO_DBG(io_req, "ABTS response - RJT\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) printk(KERN_ERR PFX "Unknown ABTS response\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) if (issue_rrq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) BNX2FC_IO_DBG(io_req, "Issue RRQ after R_A_TOV\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) set_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) set_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) bnx2fc_cmd_timer_set(io_req, r_a_tov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) io_compl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) if (io_req->wait_for_abts_comp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) if (test_and_clear_bit(BNX2FC_FLAG_EH_ABORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) &io_req->req_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) complete(&io_req->abts_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) * We end up here when ABTS is issued as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) * in asynchronous context, i.e., as part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) * of task management completion, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) * when FW error is received or when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) * ABTS is issued when the IO is timed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) * out.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) if (io_req->on_active_queue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) list_del_init(&io_req->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) io_req->on_active_queue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) /* Move IO req to retire queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) list_add_tail(&io_req->link, &tgt->io_retire_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) bnx2fc_scsi_done(io_req, DID_ERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) struct bnx2fc_rport *tgt = io_req->tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) struct bnx2fc_cmd *cmd, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) u64 tm_lun = sc_cmd->device->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) u64 lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) /* called with tgt_lock held */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) BNX2FC_IO_DBG(io_req, "Entered bnx2fc_lun_reset_cmpl\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) * Walk thru the active_ios queue and ABORT the IO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) * that matches with the LUN that was reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) list_for_each_entry_safe(cmd, tmp, &tgt->active_cmd_queue, link) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) BNX2FC_TGT_DBG(tgt, "LUN RST cmpl: scan for pending IOs\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) lun = cmd->sc_cmd->device->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) if (lun == tm_lun) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) /* Initiate ABTS on this cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) if (!test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) &cmd->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) /* cancel the IO timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) if (cancel_delayed_work(&io_req->timeout_work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) kref_put(&io_req->refcount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) /* timer hold */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) rc = bnx2fc_initiate_abts(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) /* abts shouldn't fail in this context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) WARN_ON(rc != SUCCESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) printk(KERN_ERR PFX "lun_rst: abts already in"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) " progress for this IO 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) cmd->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) struct bnx2fc_rport *tgt = io_req->tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) struct bnx2fc_cmd *cmd, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) /* called with tgt_lock held */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) BNX2FC_IO_DBG(io_req, "Entered bnx2fc_tgt_reset_cmpl\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) * Walk thru the active_ios queue and ABORT the IO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) * that matches with the LUN that was reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) list_for_each_entry_safe(cmd, tmp, &tgt->active_cmd_queue, link) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) BNX2FC_TGT_DBG(tgt, "TGT RST cmpl: scan for pending IOs\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) /* Initiate ABTS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) if (!test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) &cmd->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) /* cancel the IO timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) if (cancel_delayed_work(&io_req->timeout_work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) kref_put(&io_req->refcount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) bnx2fc_cmd_release); /* timer hold */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) rc = bnx2fc_initiate_abts(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) /* abts shouldn't fail in this context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) WARN_ON(rc != SUCCESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) printk(KERN_ERR PFX "tgt_rst: abts already in progress"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) " for this IO 0x%x\n", cmd->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) struct fcoe_task_ctx_entry *task, u8 num_rq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) unsigned char *rq_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) struct bnx2fc_mp_req *tm_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) struct fc_frame_header *fc_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) u64 *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) u64 *temp_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) void *rsp_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) /* Called with tgt_lock held */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) BNX2FC_IO_DBG(io_req, "Entered process_tm_compl\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) if (!(test_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) set_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) /* TM has already timed out and we got
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) * delayed completion. Ignore completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) * processing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) tm_req = &(io_req->mp_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) fc_hdr = &(tm_req->resp_fc_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) hdr = (u64 *)fc_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) temp_hdr = (u64 *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) &task->rxwr_only.union_ctx.comp_info.mp_rsp.fc_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) hdr[0] = cpu_to_be64(temp_hdr[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) hdr[1] = cpu_to_be64(temp_hdr[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) hdr[2] = cpu_to_be64(temp_hdr[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) tm_req->resp_len =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) task->rxwr_only.union_ctx.comp_info.mp_rsp.mp_payload_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) rsp_buf = tm_req->resp_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) if (fc_hdr->fh_r_ctl == FC_RCTL_DD_CMD_STATUS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) bnx2fc_parse_fcp_rsp(io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) (struct fcoe_fcp_rsp_payload *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) rsp_buf, num_rq, rq_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) if (io_req->fcp_rsp_code == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) /* TM successful */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) if (tm_req->tm_flags & FCP_TMF_LUN_RESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) bnx2fc_lun_reset_cmpl(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) else if (tm_req->tm_flags & FCP_TMF_TGT_RESET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) bnx2fc_tgt_reset_cmpl(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) printk(KERN_ERR PFX "tmf's fc_hdr r_ctl = 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) fc_hdr->fh_r_ctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) if (!sc_cmd->SCp.ptr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) printk(KERN_ERR PFX "tm_compl: SCp.ptr is NULL\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) switch (io_req->fcp_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) case FC_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) if (io_req->cdb_status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) /* Good IO completion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) sc_cmd->result = DID_OK << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) /* Transport status is good, SCSI status not good */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) sc_cmd->result = (DID_OK << 16) | io_req->cdb_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) if (io_req->fcp_resid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) scsi_set_resid(sc_cmd, io_req->fcp_resid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) BNX2FC_IO_DBG(io_req, "process_tm_compl: fcp_status = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) io_req->fcp_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) sc_cmd = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) io_req->sc_cmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) /* check if the io_req exists in tgt's tmf_q */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) if (io_req->on_tmf_queue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) list_del_init(&io_req->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) io_req->on_tmf_queue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) printk(KERN_ERR PFX "Command not on active_cmd_queue!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) sc_cmd->SCp.ptr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) sc_cmd->scsi_done(sc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) if (io_req->wait_for_abts_comp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) BNX2FC_IO_DBG(io_req, "tm_compl - wake up the waiter\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) complete(&io_req->abts_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) int bd_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) int frag_size, sg_frags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) sg_frags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) while (sg_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) if (sg_len >= BNX2FC_BD_SPLIT_SZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) frag_size = BNX2FC_BD_SPLIT_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) frag_size = sg_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) bd[bd_index + sg_frags].buf_addr_lo = addr & 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) bd[bd_index + sg_frags].buf_addr_hi = addr >> 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) bd[bd_index + sg_frags].buf_len = (u16)frag_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) bd[bd_index + sg_frags].flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) addr += (u64) frag_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) sg_frags++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) sg_len -= frag_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) return sg_frags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) struct bnx2fc_interface *interface = io_req->port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) struct bnx2fc_hba *hba = interface->hba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) struct scsi_cmnd *sc = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) struct scatterlist *sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) int byte_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) int sg_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) int bd_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) int sg_frags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) unsigned int sg_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) u64 addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) WARN_ON(scsi_sg_count(sc) > BNX2FC_MAX_BDS_PER_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) * Use dma_map_sg directly to ensure we're using the correct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) * dev struct off of pcidev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) sg_count = dma_map_sg(&hba->pcidev->dev, scsi_sglist(sc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) scsi_sg_count(sc), sc->sc_data_direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) scsi_for_each_sg(sc, sg, sg_count, i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) sg_len = sg_dma_len(sg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) addr = sg_dma_address(sg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) if (sg_len > BNX2FC_MAX_BD_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) sg_frags = bnx2fc_split_bd(io_req, addr, sg_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) bd_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) sg_frags = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) bd[bd_count].buf_addr_lo = addr & 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) bd[bd_count].buf_addr_hi = addr >> 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) bd[bd_count].buf_len = (u16)sg_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) bd[bd_count].flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) bd_count += sg_frags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) byte_count += sg_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) if (byte_count != scsi_bufflen(sc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) printk(KERN_ERR PFX "byte_count = %d != scsi_bufflen = %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) "task_id = 0x%x\n", byte_count, scsi_bufflen(sc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) return bd_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) struct scsi_cmnd *sc = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) int bd_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) if (scsi_sg_count(sc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) bd_count = bnx2fc_map_sg(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) if (bd_count == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) bd_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) bd[0].buf_addr_lo = bd[0].buf_addr_hi = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) bd[0].buf_len = bd[0].flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) io_req->bd_tbl->bd_valid = bd_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) * Return the command to ML if BD count exceeds the max number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) * that can be handled by FW.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) if (bd_count > BNX2FC_FW_MAX_BDS_PER_CMD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) pr_err("bd_count = %d exceeded FW supported max BD(255), task_id = 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) bd_count, io_req->xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) struct scsi_cmnd *sc = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) struct bnx2fc_interface *interface = io_req->port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) struct bnx2fc_hba *hba = interface->hba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) * Use dma_unmap_sg directly to ensure we're using the correct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) * dev struct off of pcidev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) dma_unmap_sg(&hba->pcidev->dev, scsi_sglist(sc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) scsi_sg_count(sc), sc->sc_data_direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) io_req->bd_tbl->bd_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) struct fcp_cmnd *fcp_cmnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) memset(fcp_cmnd, 0, sizeof(struct fcp_cmnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) int_to_scsilun(sc_cmd->device->lun, &fcp_cmnd->fc_lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) fcp_cmnd->fc_dl = htonl(io_req->data_xfer_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) memcpy(fcp_cmnd->fc_cdb, sc_cmd->cmnd, sc_cmd->cmd_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) fcp_cmnd->fc_cmdref = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) fcp_cmnd->fc_pri_ta = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) fcp_cmnd->fc_flags = io_req->io_req_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) fcp_cmnd->fc_pri_ta = FCP_PTA_SIMPLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) struct fcoe_fcp_rsp_payload *fcp_rsp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) u8 num_rq, unsigned char *rq_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) u8 rsp_flags = fcp_rsp->fcp_flags.flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) u32 rq_buff_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) int fcp_sns_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) int fcp_rsp_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) io_req->fcp_status = FC_GOOD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) io_req->fcp_resid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) if (rsp_flags & (FCOE_FCP_RSP_FLAGS_FCP_RESID_OVER |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) FCOE_FCP_RSP_FLAGS_FCP_RESID_UNDER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) io_req->fcp_resid = fcp_rsp->fcp_resid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) io_req->scsi_comp_flags = rsp_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) fcp_rsp->scsi_status_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) /* Fetch fcp_rsp_info and fcp_sns_info if available */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) if (num_rq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) * We do not anticipate num_rq >1, as the linux defined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) * SCSI_SENSE_BUFFERSIZE is 96 bytes + 8 bytes of FCP_RSP_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) * 256 bytes of single rq buffer is good enough to hold this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) if (rsp_flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) FCOE_FCP_RSP_FLAGS_FCP_RSP_LEN_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) fcp_rsp_len = rq_buff_len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) = fcp_rsp->fcp_rsp_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) if (rsp_flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) FCOE_FCP_RSP_FLAGS_FCP_SNS_LEN_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) fcp_sns_len = fcp_rsp->fcp_sns_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) rq_buff_len += fcp_rsp->fcp_sns_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) io_req->fcp_rsp_len = fcp_rsp_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) io_req->fcp_sns_len = fcp_sns_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) if (rq_buff_len > num_rq * BNX2FC_RQ_BUF_SZ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) /* Invalid sense sense length. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) printk(KERN_ERR PFX "invalid sns length %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) rq_buff_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) /* reset rq_buff_len */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) rq_buff_len = num_rq * BNX2FC_RQ_BUF_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) /* fetch fcp_rsp_code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) if ((fcp_rsp_len == 4) || (fcp_rsp_len == 8)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) /* Only for task management function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) io_req->fcp_rsp_code = rq_data[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) BNX2FC_IO_DBG(io_req, "fcp_rsp_code = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) io_req->fcp_rsp_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) /* fetch sense data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) rq_data += fcp_rsp_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) if (fcp_sns_len > SCSI_SENSE_BUFFERSIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) printk(KERN_ERR PFX "Truncating sense buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) fcp_sns_len = SCSI_SENSE_BUFFERSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) if (fcp_sns_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) memcpy(sc_cmd->sense_buffer, rq_data, fcp_sns_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) * bnx2fc_queuecommand - Queuecommand function of the scsi template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) * @host: The Scsi_Host the command was issued to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) * @sc_cmd: struct scsi_cmnd to be executed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) * This is the IO strategy routine, called by SCSI-ML
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) int bnx2fc_queuecommand(struct Scsi_Host *host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) struct scsi_cmnd *sc_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) struct fc_lport *lport = shost_priv(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) struct fc_rport_libfc_priv *rp = rport->dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) struct bnx2fc_rport *tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) struct bnx2fc_cmd *io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) int rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) rval = fc_remote_port_chkready(rport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) if (rval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) sc_cmd->result = rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) sc_cmd->scsi_done(sc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) if ((lport->state != LPORT_ST_READY) || !(lport->link_up)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) rc = SCSI_MLQUEUE_HOST_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) goto exit_qcmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) /* rport and tgt are allocated together, so tgt should be non-NULL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) tgt = (struct bnx2fc_rport *)&rp[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) * Session is not offloaded yet. Let SCSI-ml retry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) * the command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) rc = SCSI_MLQUEUE_TARGET_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) goto exit_qcmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) if (tgt->retry_delay_timestamp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) if (time_after(jiffies, tgt->retry_delay_timestamp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) tgt->retry_delay_timestamp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) /* If retry_delay timer is active, flow off the ML */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) rc = SCSI_MLQUEUE_TARGET_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) goto exit_qcmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) spin_lock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) io_req = bnx2fc_cmd_alloc(tgt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) if (!io_req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) rc = SCSI_MLQUEUE_HOST_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) goto exit_qcmd_tgtlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) io_req->sc_cmd = sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) if (bnx2fc_post_io_req(tgt, io_req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) printk(KERN_ERR PFX "Unable to post io_req\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) rc = SCSI_MLQUEUE_HOST_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) goto exit_qcmd_tgtlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) exit_qcmd_tgtlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) spin_unlock_bh(&tgt->tgt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) exit_qcmd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) struct fcoe_task_ctx_entry *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) u8 num_rq, unsigned char *rq_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) struct fcoe_fcp_rsp_payload *fcp_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) struct bnx2fc_rport *tgt = io_req->tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) struct scsi_cmnd *sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) u16 scope = 0, qualifier = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) /* scsi_cmd_cmpl is called with tgt lock held */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) if (test_and_set_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) /* we will not receive ABTS response for this IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) BNX2FC_IO_DBG(io_req, "Timer context finished processing "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) "this scsi cmd\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) if (test_and_clear_bit(BNX2FC_FLAG_IO_CLEANUP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) &io_req->req_flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) BNX2FC_IO_DBG(io_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) "Actual completion after cleanup request cleaning up\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) bnx2fc_process_cleanup_compl(io_req, task, num_rq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) /* Cancel the timeout_work, as we received IO completion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) if (cancel_delayed_work(&io_req->timeout_work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) kref_put(&io_req->refcount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) bnx2fc_cmd_release); /* drop timer hold */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) sc_cmd = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) if (sc_cmd == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) printk(KERN_ERR PFX "scsi_cmd_compl - sc_cmd is NULL\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) /* Fetch fcp_rsp from task context and perform cmd completion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) fcp_rsp = (struct fcoe_fcp_rsp_payload *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) &(task->rxwr_only.union_ctx.comp_info.fcp_rsp.payload);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) /* parse fcp_rsp and obtain sense data from RQ if available */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq, rq_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) if (!sc_cmd->SCp.ptr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) printk(KERN_ERR PFX "SCp.ptr is NULL\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) if (io_req->on_active_queue) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) list_del_init(&io_req->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) io_req->on_active_queue = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) /* Move IO req to retire queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) list_add_tail(&io_req->link, &tgt->io_retire_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) /* This should not happen, but could have been pulled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) * by bnx2fc_flush_active_ios(), or during a race
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) * between command abort and (late) completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) BNX2FC_IO_DBG(io_req, "xid not on active_cmd_queue\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) if (io_req->wait_for_abts_comp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) if (test_and_clear_bit(BNX2FC_FLAG_EH_ABORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) &io_req->req_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) complete(&io_req->abts_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) bnx2fc_unmap_sg_list(io_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) io_req->sc_cmd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) switch (io_req->fcp_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) case FC_GOOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) if (io_req->cdb_status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) /* Good IO completion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) sc_cmd->result = DID_OK << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) /* Transport status is good, SCSI status not good */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) BNX2FC_IO_DBG(io_req, "scsi_cmpl: cdb_status = %d"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) " fcp_resid = 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) io_req->cdb_status, io_req->fcp_resid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) sc_cmd->result = (DID_OK << 16) | io_req->cdb_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) io_req->cdb_status == SAM_STAT_BUSY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) /* Newer array firmware with BUSY or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) * TASK_SET_FULL may return a status that needs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) * the scope bits masked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) * Or a huge delay timestamp up to 27 minutes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) * can result.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) if (fcp_rsp->retry_delay_timer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) /* Upper 2 bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) scope = fcp_rsp->retry_delay_timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) & 0xC000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) /* Lower 14 bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) qualifier = fcp_rsp->retry_delay_timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) & 0x3FFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) if (scope > 0 && qualifier > 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) qualifier <= 0x3FEF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) /* Set the jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) * retry_delay_timer * 100ms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) * for the rport/tgt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) tgt->retry_delay_timestamp = jiffies +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) (qualifier * HZ / 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) if (io_req->fcp_resid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) scsi_set_resid(sc_cmd, io_req->fcp_resid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) printk(KERN_ERR PFX "scsi_cmd_compl: fcp_status = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) io_req->fcp_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) sc_cmd->SCp.ptr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) sc_cmd->scsi_done(sc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) int bnx2fc_post_io_req(struct bnx2fc_rport *tgt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) struct bnx2fc_cmd *io_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) struct fcoe_task_ctx_entry *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) struct fcoe_task_ctx_entry *task_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) struct fcoe_port *port = tgt->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) struct bnx2fc_interface *interface = port->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) struct bnx2fc_hba *hba = interface->hba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) struct fc_lport *lport = port->lport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) struct fc_stats *stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) int task_idx, index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) u16 xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) /* bnx2fc_post_io_req() is called with the tgt_lock held */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) /* Initialize rest of io_req fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) io_req->cmd_type = BNX2FC_SCSI_CMD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) io_req->port = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) io_req->tgt = tgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) io_req->data_xfer_len = scsi_bufflen(sc_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) sc_cmd->SCp.ptr = (char *)io_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) stats = per_cpu_ptr(lport->stats, get_cpu());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) io_req->io_req_flags = BNX2FC_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) stats->InputRequests++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) stats->InputBytes += io_req->data_xfer_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) io_req->io_req_flags = BNX2FC_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) stats->OutputRequests++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) stats->OutputBytes += io_req->data_xfer_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) io_req->io_req_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) stats->ControlRequests++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) put_cpu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) xid = io_req->xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) /* Build buffer descriptor list for firmware from sg list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) if (bnx2fc_build_bd_list_from_sg(io_req)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) printk(KERN_ERR PFX "BD list creation failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) task_idx = xid / BNX2FC_TASKS_PER_PAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) index = xid % BNX2FC_TASKS_PER_PAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) /* Initialize task context for this IO request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) task_page = (struct fcoe_task_ctx_entry *) hba->task_ctx[task_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) task = &(task_page[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) bnx2fc_init_task(io_req, task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) if (tgt->flush_in_prog) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) printk(KERN_ERR PFX "Flush in progress..Host Busy\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) printk(KERN_ERR PFX "Session not ready...post_io\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) kref_put(&io_req->refcount, bnx2fc_cmd_release);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) /* Time IO req */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) if (tgt->io_timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) bnx2fc_cmd_timer_set(io_req, BNX2FC_IO_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) /* Obtain free SQ entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) bnx2fc_add_2_sq(tgt, xid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) /* Enqueue the io_req to active_cmd_queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) io_req->on_active_queue = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) /* move io_req from pending_queue to active_queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) list_add_tail(&io_req->link, &tgt->active_cmd_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) /* Ring doorbell */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) bnx2fc_ring_doorbell(tgt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) }