Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2021 Broadcom. All Rights Reserved. The term
0004  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
0005  */
0006 
0007 #if !defined(__EFCT_IO_H__)
0008 #define __EFCT_IO_H__
0009 
0010 #include "efct_lio.h"
0011 
0012 #define EFCT_LOG_ENABLE_IO_ERRORS(efct)     \
0013         (((efct) != NULL) ? (((efct)->logmask & (1U << 6)) != 0) : 0)
0014 
0015 #define io_error_log(io, fmt, ...)  \
0016     do { \
0017         if (EFCT_LOG_ENABLE_IO_ERRORS(io->efct)) \
0018             efc_log_warn(io->efct, fmt, ##__VA_ARGS__); \
0019     } while (0)
0020 
0021 #define SCSI_CMD_BUF_LENGTH 48
0022 #define SCSI_RSP_BUF_LENGTH (FCP_RESP_WITH_EXT + SCSI_SENSE_BUFFERSIZE)
0023 #define EFCT_NUM_SCSI_IOS   8192
0024 
0025 enum efct_io_type {
0026     EFCT_IO_TYPE_IO = 0,
0027     EFCT_IO_TYPE_ELS,
0028     EFCT_IO_TYPE_CT,
0029     EFCT_IO_TYPE_CT_RESP,
0030     EFCT_IO_TYPE_BLS_RESP,
0031     EFCT_IO_TYPE_ABORT,
0032 
0033     EFCT_IO_TYPE_MAX,
0034 };
0035 
0036 enum efct_els_state {
0037     EFCT_ELS_REQUEST = 0,
0038     EFCT_ELS_REQUEST_DELAYED,
0039     EFCT_ELS_REQUEST_DELAY_ABORT,
0040     EFCT_ELS_REQ_ABORT,
0041     EFCT_ELS_REQ_ABORTED,
0042     EFCT_ELS_ABORT_IO_COMPL,
0043 };
0044 
0045 /**
0046  * Scsi target IO object
0047  * @efct:       pointer back to efct
0048  * @instance_index: unique instance index value
0049  * @io:         IO display name
0050  * @node:       pointer to node
0051  * @list_entry:     io list entry
0052  * @io_pending_link:    io pending list entry
0053  * @ref:        reference counter
0054  * @release:        release callback function
0055  * @init_task_tag:  initiator task tag (OX_ID) for back-end and SCSI logging
0056  * @tgt_task_tag:   target task tag (RX_ID) for back-end and SCSI logging
0057  * @hw_tag:     HW layer unique IO id
0058  * @tag:        unique IO identifier
0059  * @sgl:        SGL
0060  * @sgl_allocated:  Number of allocated SGEs
0061  * @sgl_count:      Number of SGEs in this SGL
0062  * @tgt_io:     backend target private IO data
0063  * @exp_xfer_len:   expected data transfer length, based on FC header
0064  * @hw_priv:        Declarations private to HW/SLI
0065  * @io_type:        indicates what this struct efct_io structure is used for
0066  * @hio:        hw io object
0067  * @transferred:    Number of bytes transferred
0068  * @auto_resp:      set if auto_trsp was set
0069  * @low_latency:    set if low latency request
0070  * @wq_steering:    selected WQ steering request
0071  * @wq_class:       selected WQ class if steering is class
0072  * @xfer_req:       transfer size for current request
0073  * @scsi_tgt_cb:    target callback function
0074  * @scsi_tgt_cb_arg:    target callback function argument
0075  * @abort_cb:       abort callback function
0076  * @abort_cb_arg:   abort callback function argument
0077  * @bls_cb:     BLS callback function
0078  * @bls_cb_arg:     BLS callback function argument
0079  * @tmf_cmd:        TMF command being processed
0080  * @abort_rx_id:    rx_id from the ABTS that initiated the command abort
0081  * @cmd_tgt:        True if this is a Target command
0082  * @send_abts:      when aborting, indicates ABTS is to be sent
0083  * @cmd_ini:        True if this is an Initiator command
0084  * @seq_init:       True if local node has sequence initiative
0085  * @iparam:     iparams for hw io send call
0086  * @hio_type:       HW IO type
0087  * @wire_len:       wire length
0088  * @hw_cb:      saved HW callback
0089  * @io_to_abort:    for abort handling, pointer to IO to abort
0090  * @rspbuf:     SCSI Response buffer
0091  * @timeout:        Timeout value in seconds for this IO
0092  * @cs_ctl:     CS_CTL priority for this IO
0093  * @io_free:        Is io object in freelist
0094  * @app_id:     application id
0095  */
0096 struct efct_io {
0097     struct efct     *efct;
0098     u32         instance_index;
0099     const char      *display_name;
0100     struct efct_node    *node;
0101 
0102     struct list_head    list_entry;
0103     struct list_head    io_pending_link;
0104     struct kref     ref;
0105     void (*release)(struct kref *arg);
0106     u32         init_task_tag;
0107     u32         tgt_task_tag;
0108     u32         hw_tag;
0109     u32         tag;
0110     struct efct_scsi_sgl    *sgl;
0111     u32         sgl_allocated;
0112     u32         sgl_count;
0113     struct efct_scsi_tgt_io tgt_io;
0114     u32         exp_xfer_len;
0115 
0116     void            *hw_priv;
0117 
0118     enum efct_io_type   io_type;
0119     struct efct_hw_io   *hio;
0120     size_t          transferred;
0121 
0122     bool            auto_resp;
0123     bool            low_latency;
0124     u8          wq_steering;
0125     u8          wq_class;
0126     u64         xfer_req;
0127     efct_scsi_io_cb_t   scsi_tgt_cb;
0128     void            *scsi_tgt_cb_arg;
0129     efct_scsi_io_cb_t   abort_cb;
0130     void            *abort_cb_arg;
0131     efct_scsi_io_cb_t   bls_cb;
0132     void            *bls_cb_arg;
0133     enum efct_scsi_tmf_cmd  tmf_cmd;
0134     u16         abort_rx_id;
0135 
0136     bool            cmd_tgt;
0137     bool            send_abts;
0138     bool            cmd_ini;
0139     bool            seq_init;
0140     union efct_hw_io_param_u iparam;
0141     enum efct_hw_io_type    hio_type;
0142     u64         wire_len;
0143     void            *hw_cb;
0144 
0145     struct efct_io      *io_to_abort;
0146 
0147     struct efc_dma      rspbuf;
0148     u32         timeout;
0149     u8          cs_ctl;
0150     u8          io_free;
0151     u32         app_id;
0152 };
0153 
0154 struct efct_io_cb_arg {
0155     int status;
0156     int ext_status;
0157     void *app;
0158 };
0159 
0160 struct efct_io_pool *
0161 efct_io_pool_create(struct efct *efct, u32 num_sgl);
0162 int
0163 efct_io_pool_free(struct efct_io_pool *io_pool);
0164 u32
0165 efct_io_pool_allocated(struct efct_io_pool *io_pool);
0166 
0167 struct efct_io *
0168 efct_io_pool_io_alloc(struct efct_io_pool *io_pool);
0169 void
0170 efct_io_pool_io_free(struct efct_io_pool *io_pool, struct efct_io *io);
0171 struct efct_io *
0172 efct_io_find_tgt_io(struct efct *efct, struct efct_node *node,
0173             u16 ox_id, u16 rx_id);
0174 #endif /* __EFCT_IO_H__ */