root/drivers/scsi/qedi/qedi_iscsi.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* SPDX-License-Identifier: GPL-2.0-only */
   2 /*
   3  * QLogic iSCSI Offload Driver
   4  * Copyright (c) 2016 Cavium Inc.
   5  */
   6 
   7 #ifndef _QEDI_ISCSI_H_
   8 #define _QEDI_ISCSI_H_
   9 
  10 #include <linux/socket.h>
  11 #include <linux/completion.h>
  12 #include "qedi.h"
  13 
  14 #define ISCSI_MAX_SESS_PER_HBA  4096
  15 
  16 #define DEF_KA_TIMEOUT          7200000
  17 #define DEF_KA_INTERVAL         10000
  18 #define DEF_KA_MAX_PROBE_COUNT  10
  19 #define DEF_TOS                 0
  20 #define DEF_TTL                 0xfe
  21 #define DEF_SND_SEQ_SCALE       0
  22 #define DEF_RCV_BUF             0xffff
  23 #define DEF_SND_BUF             0xffff
  24 #define DEF_SEED                0
  25 #define DEF_MAX_RT_TIME         8000
  26 #define DEF_MAX_DA_COUNT        2
  27 #define DEF_SWS_TIMER           1000
  28 #define DEF_MAX_CWND            2
  29 #define DEF_PATH_MTU            1500
  30 #define DEF_MSS                 1460
  31 #define DEF_LL2_MTU             1560
  32 #define JUMBO_MTU               9000
  33 
  34 #define MIN_MTU         576 /* rfc 793 */
  35 #define IPV4_HDR_LEN    20
  36 #define IPV6_HDR_LEN    40
  37 #define TCP_HDR_LEN     20
  38 #define TCP_OPTION_LEN  12
  39 #define VLAN_LEN         4
  40 
  41 enum {
  42         EP_STATE_IDLE                   = 0x0,
  43         EP_STATE_ACQRCONN_START         = 0x1,
  44         EP_STATE_ACQRCONN_COMPL         = 0x2,
  45         EP_STATE_OFLDCONN_START         = 0x4,
  46         EP_STATE_OFLDCONN_COMPL         = 0x8,
  47         EP_STATE_DISCONN_START          = 0x10,
  48         EP_STATE_DISCONN_COMPL          = 0x20,
  49         EP_STATE_CLEANUP_START          = 0x40,
  50         EP_STATE_CLEANUP_CMPL           = 0x80,
  51         EP_STATE_TCP_FIN_RCVD           = 0x100,
  52         EP_STATE_TCP_RST_RCVD           = 0x200,
  53         EP_STATE_LOGOUT_SENT            = 0x400,
  54         EP_STATE_LOGOUT_RESP_RCVD       = 0x800,
  55         EP_STATE_CLEANUP_FAILED         = 0x1000,
  56         EP_STATE_OFLDCONN_FAILED        = 0x2000,
  57         EP_STATE_CONNECT_FAILED         = 0x4000,
  58         EP_STATE_DISCONN_TIMEDOUT       = 0x8000,
  59         EP_STATE_OFLDCONN_NONE          = 0x10000,
  60 };
  61 
  62 struct qedi_conn;
  63 
  64 struct qedi_endpoint {
  65         struct qedi_ctx *qedi;
  66         u32 dst_addr[4];
  67         u32 src_addr[4];
  68         u16 src_port;
  69         u16 dst_port;
  70         u16 vlan_id;
  71         u16 pmtu;
  72         u8 src_mac[ETH_ALEN];
  73         u8 dst_mac[ETH_ALEN];
  74         u8 ip_type;
  75         int state;
  76         wait_queue_head_t ofld_wait;
  77         wait_queue_head_t tcp_ofld_wait;
  78         u32 iscsi_cid;
  79         /* identifier of the connection from qed */
  80         u32 handle;
  81         u32 fw_cid;
  82         void __iomem *p_doorbell;
  83 
  84         /* Send queue management */
  85         struct iscsi_wqe *sq;
  86         dma_addr_t sq_dma;
  87 
  88         u16 sq_prod_idx;
  89         u16 fw_sq_prod_idx;
  90         u16 sq_con_idx;
  91         u32 sq_mem_size;
  92 
  93         void *sq_pbl;
  94         dma_addr_t sq_pbl_dma;
  95         u32 sq_pbl_size;
  96         struct qedi_conn *conn;
  97         struct work_struct offload_work;
  98 };
  99 
 100 #define QEDI_SQ_WQES_MIN        16
 101 
 102 struct qedi_io_bdt {
 103         struct scsi_sge *sge_tbl;
 104         dma_addr_t sge_tbl_dma;
 105         u16 sge_valid;
 106 };
 107 
 108 /**
 109  * struct generic_pdu_resc - login pdu resource structure
 110  *
 111  * @req_buf:            driver buffer used to stage payload associated with
 112  *                      the login request
 113  * @req_dma_addr:       dma address for iscsi login request payload buffer
 114  * @req_buf_size:       actual login request payload length
 115  * @req_wr_ptr:         pointer into login request buffer when next data is
 116  *                      to be written
 117  * @resp_hdr:           iscsi header where iscsi login response header is to
 118  *                      be recreated
 119  * @resp_buf:           buffer to stage login response payload
 120  * @resp_dma_addr:      login response payload buffer dma address
 121  * @resp_buf_size:      login response paylod length
 122  * @resp_wr_ptr:        pointer into login response buffer when next data is
 123  *                      to be written
 124  * @req_bd_tbl:         iscsi login request payload BD table
 125  * @req_bd_dma:         login request BD table dma address
 126  * @resp_bd_tbl:        iscsi login response payload BD table
 127  * @resp_bd_dma:        login request BD table dma address
 128  *
 129  * following structure defines buffer info for generic pdus such as iSCSI Login,
 130  *      Logout and NOP
 131  */
 132 struct generic_pdu_resc {
 133         char *req_buf;
 134         dma_addr_t req_dma_addr;
 135         u32 req_buf_size;
 136         char *req_wr_ptr;
 137         struct iscsi_hdr resp_hdr;
 138         char *resp_buf;
 139         dma_addr_t resp_dma_addr;
 140         u32 resp_buf_size;
 141         char *resp_wr_ptr;
 142         char *req_bd_tbl;
 143         dma_addr_t req_bd_dma;
 144         char *resp_bd_tbl;
 145         dma_addr_t resp_bd_dma;
 146 };
 147 
 148 struct qedi_conn {
 149         struct iscsi_cls_conn *cls_conn;
 150         struct qedi_ctx *qedi;
 151         struct qedi_endpoint *ep;
 152         struct list_head active_cmd_list;
 153         spinlock_t list_lock;           /* internal conn lock */
 154         u32 active_cmd_count;
 155         u32 cmd_cleanup_req;
 156         u32 cmd_cleanup_cmpl;
 157 
 158         u32 iscsi_conn_id;
 159         int itt;
 160         int abrt_conn;
 161 #define QEDI_CID_RESERVED       0x5AFF
 162         u32 fw_cid;
 163         /*
 164          * Buffer for login negotiation process
 165          */
 166         struct generic_pdu_resc gen_pdu;
 167 
 168         struct list_head tmf_work_list;
 169         wait_queue_head_t wait_queue;
 170         spinlock_t tmf_work_lock;       /* tmf work lock */
 171         unsigned long flags;
 172 #define QEDI_CONN_FW_CLEANUP    1
 173 };
 174 
 175 struct qedi_cmd {
 176         struct list_head io_cmd;
 177         bool io_cmd_in_list;
 178         struct iscsi_hdr hdr;
 179         struct qedi_conn *conn;
 180         struct scsi_cmnd *scsi_cmd;
 181         struct scatterlist *sg;
 182         struct qedi_io_bdt io_tbl;
 183         struct e4_iscsi_task_context request;
 184         unsigned char *sense_buffer;
 185         dma_addr_t sense_buffer_dma;
 186         u16 task_id;
 187 
 188         /* field populated for tmf work queue */
 189         struct iscsi_task *task;
 190         struct work_struct tmf_work;
 191         int state;
 192 #define CLEANUP_WAIT    1
 193 #define CLEANUP_RECV    2
 194 #define CLEANUP_WAIT_FAILED     3
 195 #define CLEANUP_NOT_REQUIRED    4
 196 #define LUN_RESET_RESPONSE_RECEIVED     5
 197 #define RESPONSE_RECEIVED       6
 198 
 199         int type;
 200 #define TYPEIO          1
 201 #define TYPERESET       2
 202 
 203         struct qedi_work_map *list_tmf_work;
 204         /* slowpath management */
 205         bool use_slowpath;
 206 
 207         struct iscsi_tm_rsp *tmf_resp_buf;
 208         struct qedi_work cqe_work;
 209 };
 210 
 211 struct qedi_work_map {
 212         struct list_head list;
 213         struct qedi_cmd *qedi_cmd;
 214         int rtid;
 215 
 216         int state;
 217 #define QEDI_WORK_QUEUED        1
 218 #define QEDI_WORK_SCHEDULED     2
 219 #define QEDI_WORK_EXIT          3
 220 
 221         struct work_struct *ptr_tmf_work;
 222 };
 223 
 224 struct qedi_boot_target {
 225         char ip_addr[64];
 226         char iscsi_name[255];
 227         u32 ipv6_en;
 228 };
 229 
 230 #define qedi_set_itt(task_id, itt) ((u32)(((task_id) & 0xffff) | ((itt) << 16)))
 231 #define qedi_get_itt(cqe) (cqe.iscsi_hdr.cmd.itt >> 16)
 232 
 233 #define QEDI_OFLD_WAIT_STATE(q) ((q)->state == EP_STATE_OFLDCONN_FAILED || \
 234                                 (q)->state == EP_STATE_OFLDCONN_COMPL)
 235 
 236 #endif /* _QEDI_ISCSI_H_ */

/* [<][>][^][v][top][bottom][index][help] */