18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This file is part of the Chelsio FCoE driver for Linux.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
78c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
88c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
98c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
108c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
138c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
148c2ecf20Sopenharmony_ci *     conditions are met:
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
178c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
188c2ecf20Sopenharmony_ci *        disclaimer.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
218c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
228c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
238c2ecf20Sopenharmony_ci *        provided with the distribution.
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
268c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
278c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
288c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
298c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
308c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
318c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
328c2ecf20Sopenharmony_ci * SOFTWARE.
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#ifndef __CSIO_SCSI_H__
368c2ecf20Sopenharmony_ci#define __CSIO_SCSI_H__
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#include <linux/spinlock_types.h>
398c2ecf20Sopenharmony_ci#include <linux/completion.h>
408c2ecf20Sopenharmony_ci#include <scsi/scsi.h>
418c2ecf20Sopenharmony_ci#include <scsi/scsi_cmnd.h>
428c2ecf20Sopenharmony_ci#include <scsi/scsi_device.h>
438c2ecf20Sopenharmony_ci#include <scsi/scsi_host.h>
448c2ecf20Sopenharmony_ci#include <scsi/scsi_eh.h>
458c2ecf20Sopenharmony_ci#include <scsi/scsi_tcq.h>
468c2ecf20Sopenharmony_ci#include <scsi/fc/fc_fcp.h>
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#include "csio_defs.h"
498c2ecf20Sopenharmony_ci#include "csio_wr.h"
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ciextern struct scsi_host_template csio_fcoe_shost_template;
528c2ecf20Sopenharmony_ciextern struct scsi_host_template csio_fcoe_shost_vport_template;
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciextern int csio_scsi_eqsize;
558c2ecf20Sopenharmony_ciextern int csio_scsi_iqlen;
568c2ecf20Sopenharmony_ciextern int csio_scsi_ioreqs;
578c2ecf20Sopenharmony_ciextern uint32_t csio_max_scan_tmo;
588c2ecf20Sopenharmony_ciextern uint32_t csio_delta_scan_tmo;
598c2ecf20Sopenharmony_ciextern int csio_lun_qdepth;
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/*
628c2ecf20Sopenharmony_ci **************************** NOTE *******************************
638c2ecf20Sopenharmony_ci * How do we calculate MAX FCoE SCSI SGEs? Here is the math:
648c2ecf20Sopenharmony_ci * Max Egress WR size = 512 bytes
658c2ecf20Sopenharmony_ci * One SCSI egress WR has the following fixed no of bytes:
668c2ecf20Sopenharmony_ci *      48 (sizeof(struct fw_scsi_write[read]_wr)) - FW WR
678c2ecf20Sopenharmony_ci *    + 32 (sizeof(struct fc_fcp_cmnd)) - Immediate FCP_CMD
688c2ecf20Sopenharmony_ci *    ------
698c2ecf20Sopenharmony_ci *      80
708c2ecf20Sopenharmony_ci *    ------
718c2ecf20Sopenharmony_ci * That leaves us with 512 - 96 = 432 bytes for data SGE. Using
728c2ecf20Sopenharmony_ci * struct ulptx_sgl header for the SGE consumes:
738c2ecf20Sopenharmony_ci *	- 4 bytes for cmnd_sge.
748c2ecf20Sopenharmony_ci *	- 12 bytes for the first SGL.
758c2ecf20Sopenharmony_ci * That leaves us with 416 bytes for the remaining SGE pairs. Which is
768c2ecf20Sopenharmony_ci * is 416 / 24 (size(struct ulptx_sge_pair)) = 17 SGE pairs,
778c2ecf20Sopenharmony_ci * or 34 SGEs. Adding the first SGE fetches us 35 SGEs.
788c2ecf20Sopenharmony_ci */
798c2ecf20Sopenharmony_ci#define CSIO_SCSI_MAX_SGE		35
808c2ecf20Sopenharmony_ci#define CSIO_SCSI_ABRT_TMO_MS		60000
818c2ecf20Sopenharmony_ci#define CSIO_SCSI_LUNRST_TMO_MS		60000
828c2ecf20Sopenharmony_ci#define CSIO_SCSI_TM_POLL_MS		2000	/* should be less than
838c2ecf20Sopenharmony_ci						 * all TM timeouts.
848c2ecf20Sopenharmony_ci						 */
858c2ecf20Sopenharmony_ci#define CSIO_SCSI_IQ_WRSZ		128
868c2ecf20Sopenharmony_ci#define CSIO_SCSI_IQSIZE		(csio_scsi_iqlen * CSIO_SCSI_IQ_WRSZ)
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define	CSIO_MAX_SNS_LEN		128
898c2ecf20Sopenharmony_ci#define	CSIO_SCSI_RSP_LEN	(FCP_RESP_WITH_EXT + 4 + CSIO_MAX_SNS_LEN)
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci/* Reference to scsi_cmnd */
928c2ecf20Sopenharmony_ci#define csio_scsi_cmnd(req)		((req)->scratch1)
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_cistruct csio_scsi_stats {
958c2ecf20Sopenharmony_ci	uint64_t		n_tot_success;	/* Total number of good I/Os */
968c2ecf20Sopenharmony_ci	uint32_t		n_rn_nr_error;	/* No. of remote-node-not-
978c2ecf20Sopenharmony_ci						 * ready errors
988c2ecf20Sopenharmony_ci						 */
998c2ecf20Sopenharmony_ci	uint32_t		n_hw_nr_error;	/* No. of hw-module-not-
1008c2ecf20Sopenharmony_ci						 * ready errors
1018c2ecf20Sopenharmony_ci						 */
1028c2ecf20Sopenharmony_ci	uint32_t		n_dmamap_error;	/* No. of DMA map erros */
1038c2ecf20Sopenharmony_ci	uint32_t		n_unsupp_sge_error; /* No. of too-many-SGes
1048c2ecf20Sopenharmony_ci						     * errors.
1058c2ecf20Sopenharmony_ci						     */
1068c2ecf20Sopenharmony_ci	uint32_t		n_no_req_error;	/* No. of Out-of-ioreqs error */
1078c2ecf20Sopenharmony_ci	uint32_t		n_busy_error;	/* No. of -EBUSY errors */
1088c2ecf20Sopenharmony_ci	uint32_t		n_hosterror;	/* No. of FW_HOSTERROR I/O */
1098c2ecf20Sopenharmony_ci	uint32_t		n_rsperror;	/* No. of response errors */
1108c2ecf20Sopenharmony_ci	uint32_t		n_autosense;	/* No. of auto sense replies */
1118c2ecf20Sopenharmony_ci	uint32_t		n_ovflerror;	/* No. of overflow errors */
1128c2ecf20Sopenharmony_ci	uint32_t		n_unflerror;	/* No. of underflow errors */
1138c2ecf20Sopenharmony_ci	uint32_t		n_rdev_nr_error;/* No. of rdev not
1148c2ecf20Sopenharmony_ci						 * ready errors
1158c2ecf20Sopenharmony_ci						 */
1168c2ecf20Sopenharmony_ci	uint32_t		n_rdev_lost_error;/* No. of rdev lost errors */
1178c2ecf20Sopenharmony_ci	uint32_t		n_rdev_logo_error;/* No. of rdev logo errors */
1188c2ecf20Sopenharmony_ci	uint32_t		n_link_down_error;/* No. of link down errors */
1198c2ecf20Sopenharmony_ci	uint32_t		n_no_xchg_error; /* No. no exchange error */
1208c2ecf20Sopenharmony_ci	uint32_t		n_unknown_error;/* No. of unhandled errors */
1218c2ecf20Sopenharmony_ci	uint32_t		n_aborted;	/* No. of aborted I/Os */
1228c2ecf20Sopenharmony_ci	uint32_t		n_abrt_timedout; /* No. of abort timedouts */
1238c2ecf20Sopenharmony_ci	uint32_t		n_abrt_fail;	/* No. of abort failures */
1248c2ecf20Sopenharmony_ci	uint32_t		n_abrt_dups;	/* No. of duplicate aborts */
1258c2ecf20Sopenharmony_ci	uint32_t		n_abrt_race_comp; /* No. of aborts that raced
1268c2ecf20Sopenharmony_ci						   * with completions.
1278c2ecf20Sopenharmony_ci						   */
1288c2ecf20Sopenharmony_ci	uint32_t		n_abrt_busy_error;/* No. of abort failures
1298c2ecf20Sopenharmony_ci						   * due to -EBUSY.
1308c2ecf20Sopenharmony_ci						   */
1318c2ecf20Sopenharmony_ci	uint32_t		n_closed;	/* No. of closed I/Os */
1328c2ecf20Sopenharmony_ci	uint32_t		n_cls_busy_error; /* No. of close failures
1338c2ecf20Sopenharmony_ci						   * due to -EBUSY.
1348c2ecf20Sopenharmony_ci						   */
1358c2ecf20Sopenharmony_ci	uint32_t		n_active;	/* No. of IOs in active_q */
1368c2ecf20Sopenharmony_ci	uint32_t		n_tm_active;	/* No. of TMs in active_q */
1378c2ecf20Sopenharmony_ci	uint32_t		n_wcbfn;	/* No. of I/Os in worker
1388c2ecf20Sopenharmony_ci						 * cbfn q
1398c2ecf20Sopenharmony_ci						 */
1408c2ecf20Sopenharmony_ci	uint32_t		n_free_ioreq;	/* No. of freelist entries */
1418c2ecf20Sopenharmony_ci	uint32_t		n_free_ddp;	/* No. of DDP freelist */
1428c2ecf20Sopenharmony_ci	uint32_t		n_unaligned;	/* No. of Unaligned SGls */
1438c2ecf20Sopenharmony_ci	uint32_t		n_inval_cplop;	/* No. invalid CPL op's in IQ */
1448c2ecf20Sopenharmony_ci	uint32_t		n_inval_scsiop;	/* No. invalid scsi op's in IQ*/
1458c2ecf20Sopenharmony_ci};
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_cistruct csio_scsim {
1488c2ecf20Sopenharmony_ci	struct csio_hw		*hw;		/* Pointer to HW moduel */
1498c2ecf20Sopenharmony_ci	uint8_t			max_sge;	/* Max SGE */
1508c2ecf20Sopenharmony_ci	uint8_t			proto_cmd_len;	/* Proto specific SCSI
1518c2ecf20Sopenharmony_ci						 * cmd length
1528c2ecf20Sopenharmony_ci						 */
1538c2ecf20Sopenharmony_ci	uint16_t		proto_rsp_len;	/* Proto specific SCSI
1548c2ecf20Sopenharmony_ci						 * response length
1558c2ecf20Sopenharmony_ci						 */
1568c2ecf20Sopenharmony_ci	spinlock_t		freelist_lock;	/* Lock for ioreq freelist */
1578c2ecf20Sopenharmony_ci	struct list_head	active_q;	/* Outstanding SCSI I/Os */
1588c2ecf20Sopenharmony_ci	struct list_head	ioreq_freelist;	/* Free list of ioreq's */
1598c2ecf20Sopenharmony_ci	struct list_head	ddp_freelist;	/* DDP descriptor freelist */
1608c2ecf20Sopenharmony_ci	struct csio_scsi_stats	stats;		/* This module's statistics */
1618c2ecf20Sopenharmony_ci};
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci/* State machine defines */
1648c2ecf20Sopenharmony_cienum csio_scsi_ev {
1658c2ecf20Sopenharmony_ci	CSIO_SCSIE_START_IO = 1,		/* Start a regular SCSI IO */
1668c2ecf20Sopenharmony_ci	CSIO_SCSIE_START_TM,			/* Start a TM IO */
1678c2ecf20Sopenharmony_ci	CSIO_SCSIE_COMPLETED,			/* IO Completed */
1688c2ecf20Sopenharmony_ci	CSIO_SCSIE_ABORT,			/* Abort IO */
1698c2ecf20Sopenharmony_ci	CSIO_SCSIE_ABORTED,			/* IO Aborted */
1708c2ecf20Sopenharmony_ci	CSIO_SCSIE_CLOSE,			/* Close exchange */
1718c2ecf20Sopenharmony_ci	CSIO_SCSIE_CLOSED,			/* Exchange closed */
1728c2ecf20Sopenharmony_ci	CSIO_SCSIE_DRVCLEANUP,			/* Driver wants to manually
1738c2ecf20Sopenharmony_ci						 * cleanup this I/O.
1748c2ecf20Sopenharmony_ci						 */
1758c2ecf20Sopenharmony_ci};
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_cienum csio_scsi_lev {
1788c2ecf20Sopenharmony_ci	CSIO_LEV_ALL = 1,
1798c2ecf20Sopenharmony_ci	CSIO_LEV_LNODE,
1808c2ecf20Sopenharmony_ci	CSIO_LEV_RNODE,
1818c2ecf20Sopenharmony_ci	CSIO_LEV_LUN,
1828c2ecf20Sopenharmony_ci};
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_cistruct csio_scsi_level_data {
1858c2ecf20Sopenharmony_ci	enum csio_scsi_lev	level;
1868c2ecf20Sopenharmony_ci	struct csio_rnode	*rnode;
1878c2ecf20Sopenharmony_ci	struct csio_lnode	*lnode;
1888c2ecf20Sopenharmony_ci	uint64_t		oslun;
1898c2ecf20Sopenharmony_ci};
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_cistatic inline struct csio_ioreq *
1928c2ecf20Sopenharmony_cicsio_get_scsi_ioreq(struct csio_scsim *scm)
1938c2ecf20Sopenharmony_ci{
1948c2ecf20Sopenharmony_ci	struct csio_sm *req;
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci	if (likely(!list_empty(&scm->ioreq_freelist))) {
1978c2ecf20Sopenharmony_ci		req = list_first_entry(&scm->ioreq_freelist,
1988c2ecf20Sopenharmony_ci				       struct csio_sm, sm_list);
1998c2ecf20Sopenharmony_ci		list_del_init(&req->sm_list);
2008c2ecf20Sopenharmony_ci		CSIO_DEC_STATS(scm, n_free_ioreq);
2018c2ecf20Sopenharmony_ci		return (struct csio_ioreq *)req;
2028c2ecf20Sopenharmony_ci	} else
2038c2ecf20Sopenharmony_ci		return NULL;
2048c2ecf20Sopenharmony_ci}
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_cistatic inline void
2078c2ecf20Sopenharmony_cicsio_put_scsi_ioreq(struct csio_scsim *scm, struct csio_ioreq *ioreq)
2088c2ecf20Sopenharmony_ci{
2098c2ecf20Sopenharmony_ci	list_add_tail(&ioreq->sm.sm_list, &scm->ioreq_freelist);
2108c2ecf20Sopenharmony_ci	CSIO_INC_STATS(scm, n_free_ioreq);
2118c2ecf20Sopenharmony_ci}
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_cistatic inline void
2148c2ecf20Sopenharmony_cicsio_put_scsi_ioreq_list(struct csio_scsim *scm, struct list_head *reqlist,
2158c2ecf20Sopenharmony_ci			 int n)
2168c2ecf20Sopenharmony_ci{
2178c2ecf20Sopenharmony_ci	list_splice_init(reqlist, &scm->ioreq_freelist);
2188c2ecf20Sopenharmony_ci	scm->stats.n_free_ioreq += n;
2198c2ecf20Sopenharmony_ci}
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_cistatic inline struct csio_dma_buf *
2228c2ecf20Sopenharmony_cicsio_get_scsi_ddp(struct csio_scsim *scm)
2238c2ecf20Sopenharmony_ci{
2248c2ecf20Sopenharmony_ci	struct csio_dma_buf *ddp;
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci	if (likely(!list_empty(&scm->ddp_freelist))) {
2278c2ecf20Sopenharmony_ci		ddp = list_first_entry(&scm->ddp_freelist,
2288c2ecf20Sopenharmony_ci				       struct csio_dma_buf, list);
2298c2ecf20Sopenharmony_ci		list_del_init(&ddp->list);
2308c2ecf20Sopenharmony_ci		CSIO_DEC_STATS(scm, n_free_ddp);
2318c2ecf20Sopenharmony_ci		return ddp;
2328c2ecf20Sopenharmony_ci	} else
2338c2ecf20Sopenharmony_ci		return NULL;
2348c2ecf20Sopenharmony_ci}
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_cistatic inline void
2378c2ecf20Sopenharmony_cicsio_put_scsi_ddp(struct csio_scsim *scm, struct csio_dma_buf *ddp)
2388c2ecf20Sopenharmony_ci{
2398c2ecf20Sopenharmony_ci	list_add_tail(&ddp->list, &scm->ddp_freelist);
2408c2ecf20Sopenharmony_ci	CSIO_INC_STATS(scm, n_free_ddp);
2418c2ecf20Sopenharmony_ci}
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_cistatic inline void
2448c2ecf20Sopenharmony_cicsio_put_scsi_ddp_list(struct csio_scsim *scm, struct list_head *reqlist,
2458c2ecf20Sopenharmony_ci			 int n)
2468c2ecf20Sopenharmony_ci{
2478c2ecf20Sopenharmony_ci	list_splice_tail_init(reqlist, &scm->ddp_freelist);
2488c2ecf20Sopenharmony_ci	scm->stats.n_free_ddp += n;
2498c2ecf20Sopenharmony_ci}
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_cistatic inline void
2528c2ecf20Sopenharmony_cicsio_scsi_completed(struct csio_ioreq *ioreq, struct list_head *cbfn_q)
2538c2ecf20Sopenharmony_ci{
2548c2ecf20Sopenharmony_ci	csio_post_event(&ioreq->sm, CSIO_SCSIE_COMPLETED);
2558c2ecf20Sopenharmony_ci	if (csio_list_deleted(&ioreq->sm.sm_list))
2568c2ecf20Sopenharmony_ci		list_add_tail(&ioreq->sm.sm_list, cbfn_q);
2578c2ecf20Sopenharmony_ci}
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_cistatic inline void
2608c2ecf20Sopenharmony_cicsio_scsi_aborted(struct csio_ioreq *ioreq, struct list_head *cbfn_q)
2618c2ecf20Sopenharmony_ci{
2628c2ecf20Sopenharmony_ci	csio_post_event(&ioreq->sm, CSIO_SCSIE_ABORTED);
2638c2ecf20Sopenharmony_ci	list_add_tail(&ioreq->sm.sm_list, cbfn_q);
2648c2ecf20Sopenharmony_ci}
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_cistatic inline void
2678c2ecf20Sopenharmony_cicsio_scsi_closed(struct csio_ioreq *ioreq, struct list_head *cbfn_q)
2688c2ecf20Sopenharmony_ci{
2698c2ecf20Sopenharmony_ci	csio_post_event(&ioreq->sm, CSIO_SCSIE_CLOSED);
2708c2ecf20Sopenharmony_ci	list_add_tail(&ioreq->sm.sm_list, cbfn_q);
2718c2ecf20Sopenharmony_ci}
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_cistatic inline void
2748c2ecf20Sopenharmony_cicsio_scsi_drvcleanup(struct csio_ioreq *ioreq)
2758c2ecf20Sopenharmony_ci{
2768c2ecf20Sopenharmony_ci	csio_post_event(&ioreq->sm, CSIO_SCSIE_DRVCLEANUP);
2778c2ecf20Sopenharmony_ci}
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci/*
2808c2ecf20Sopenharmony_ci * csio_scsi_start_io - Kick starts the IO SM.
2818c2ecf20Sopenharmony_ci * @req: io request SM.
2828c2ecf20Sopenharmony_ci *
2838c2ecf20Sopenharmony_ci * needs to be called with lock held.
2848c2ecf20Sopenharmony_ci */
2858c2ecf20Sopenharmony_cistatic inline int
2868c2ecf20Sopenharmony_cicsio_scsi_start_io(struct csio_ioreq *ioreq)
2878c2ecf20Sopenharmony_ci{
2888c2ecf20Sopenharmony_ci	csio_post_event(&ioreq->sm, CSIO_SCSIE_START_IO);
2898c2ecf20Sopenharmony_ci	return ioreq->drv_status;
2908c2ecf20Sopenharmony_ci}
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci/*
2938c2ecf20Sopenharmony_ci * csio_scsi_start_tm - Kicks off the Task management IO SM.
2948c2ecf20Sopenharmony_ci * @req: io request SM.
2958c2ecf20Sopenharmony_ci *
2968c2ecf20Sopenharmony_ci * needs to be called with lock held.
2978c2ecf20Sopenharmony_ci */
2988c2ecf20Sopenharmony_cistatic inline int
2998c2ecf20Sopenharmony_cicsio_scsi_start_tm(struct csio_ioreq *ioreq)
3008c2ecf20Sopenharmony_ci{
3018c2ecf20Sopenharmony_ci	csio_post_event(&ioreq->sm, CSIO_SCSIE_START_TM);
3028c2ecf20Sopenharmony_ci	return ioreq->drv_status;
3038c2ecf20Sopenharmony_ci}
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci/*
3068c2ecf20Sopenharmony_ci * csio_scsi_abort - Abort an IO request
3078c2ecf20Sopenharmony_ci * @req: io request SM.
3088c2ecf20Sopenharmony_ci *
3098c2ecf20Sopenharmony_ci * needs to be called with lock held.
3108c2ecf20Sopenharmony_ci */
3118c2ecf20Sopenharmony_cistatic inline int
3128c2ecf20Sopenharmony_cicsio_scsi_abort(struct csio_ioreq *ioreq)
3138c2ecf20Sopenharmony_ci{
3148c2ecf20Sopenharmony_ci	csio_post_event(&ioreq->sm, CSIO_SCSIE_ABORT);
3158c2ecf20Sopenharmony_ci	return ioreq->drv_status;
3168c2ecf20Sopenharmony_ci}
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci/*
3198c2ecf20Sopenharmony_ci * csio_scsi_close - Close an IO request
3208c2ecf20Sopenharmony_ci * @req: io request SM.
3218c2ecf20Sopenharmony_ci *
3228c2ecf20Sopenharmony_ci * needs to be called with lock held.
3238c2ecf20Sopenharmony_ci */
3248c2ecf20Sopenharmony_cistatic inline int
3258c2ecf20Sopenharmony_cicsio_scsi_close(struct csio_ioreq *ioreq)
3268c2ecf20Sopenharmony_ci{
3278c2ecf20Sopenharmony_ci	csio_post_event(&ioreq->sm, CSIO_SCSIE_CLOSE);
3288c2ecf20Sopenharmony_ci	return ioreq->drv_status;
3298c2ecf20Sopenharmony_ci}
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_civoid csio_scsi_cleanup_io_q(struct csio_scsim *, struct list_head *);
3328c2ecf20Sopenharmony_ciint csio_scsim_cleanup_io(struct csio_scsim *, bool abort);
3338c2ecf20Sopenharmony_ciint csio_scsim_cleanup_io_lnode(struct csio_scsim *,
3348c2ecf20Sopenharmony_ci					  struct csio_lnode *);
3358c2ecf20Sopenharmony_cistruct csio_ioreq *csio_scsi_cmpl_handler(struct csio_hw *, void *, uint32_t,
3368c2ecf20Sopenharmony_ci					  struct csio_fl_dma_buf *,
3378c2ecf20Sopenharmony_ci					  void *, uint8_t **);
3388c2ecf20Sopenharmony_ciint csio_scsi_qconfig(struct csio_hw *);
3398c2ecf20Sopenharmony_ciint csio_scsim_init(struct csio_scsim *, struct csio_hw *);
3408c2ecf20Sopenharmony_civoid csio_scsim_exit(struct csio_scsim *);
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci#endif /* __CSIO_SCSI_H__ */
343