efct_lio.h (4784B)
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Copyright (C) 2021 Broadcom. All Rights Reserved. The term 4 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 */ 6 7#ifndef __EFCT_LIO_H__ 8#define __EFCT_LIO_H__ 9 10#include "efct_scsi.h" 11#include <target/target_core_base.h> 12 13#define efct_lio_io_printf(io, fmt, ...) \ 14 efc_log_debug(io->efct, \ 15 "[%s] [%04x][i:%04x t:%04x h:%04x]" fmt,\ 16 io->node->display_name, io->instance_index, \ 17 io->init_task_tag, io->tgt_task_tag, io->hw_tag,\ 18 ##__VA_ARGS__) 19 20#define efct_lio_tmfio_printf(io, fmt, ...) \ 21 efc_log_debug(io->efct, \ 22 "[%s] [%04x][i:%04x t:%04x h:%04x][f:%02x]" fmt,\ 23 io->node->display_name, io->instance_index, \ 24 io->init_task_tag, io->tgt_task_tag, io->hw_tag,\ 25 io->tgt_io.tmf, ##__VA_ARGS__) 26 27#define efct_set_lio_io_state(io, value) (io->tgt_io.state |= value) 28 29struct efct_lio_wq_data { 30 struct efct *efct; 31 void *ptr; 32 struct work_struct work; 33}; 34 35/* Target private efct structure */ 36struct efct_scsi_tgt { 37 u32 max_sge; 38 u32 max_sgl; 39 40 /* 41 * Variables used to send task set full. We are using a high watermark 42 * method to send task set full. We will reserve a fixed number of IOs 43 * per initiator plus a fudge factor. Once we reach this number, 44 * then the target will start sending task set full/busy responses. 45 */ 46 atomic_t initiator_count; 47 atomic_t ios_in_use; 48 atomic_t io_high_watermark; 49 50 atomic_t watermark_hit; 51 int watermark_min; 52 int watermark_max; 53 54 struct efct_lio_nport *lio_nport; 55 struct efct_lio_tpg *tpg; 56 57 struct list_head vport_list; 58 /* Protects vport list*/ 59 spinlock_t efct_lio_lock; 60 61 u64 wwnn; 62}; 63 64struct efct_scsi_tgt_nport { 65 struct efct_lio_nport *lio_nport; 66}; 67 68struct efct_node { 69 struct list_head list_entry; 70 struct kref ref; 71 void (*release)(struct kref *arg); 72 struct efct *efct; 73 struct efc_node *node; 74 struct se_session *session; 75 spinlock_t active_ios_lock; 76 struct list_head active_ios; 77 char display_name[EFC_NAME_LENGTH]; 78 u32 port_fc_id; 79 u32 node_fc_id; 80 u32 vpi; 81 u32 rpi; 82 u32 abort_cnt; 83}; 84 85#define EFCT_LIO_STATE_SCSI_RECV_CMD (1 << 0) 86#define EFCT_LIO_STATE_TGT_SUBMIT_CMD (1 << 1) 87#define EFCT_LIO_STATE_TFO_QUEUE_DATA_IN (1 << 2) 88#define EFCT_LIO_STATE_TFO_WRITE_PENDING (1 << 3) 89#define EFCT_LIO_STATE_TGT_EXECUTE_CMD (1 << 4) 90#define EFCT_LIO_STATE_SCSI_SEND_RD_DATA (1 << 5) 91#define EFCT_LIO_STATE_TFO_CHK_STOP_FREE (1 << 6) 92#define EFCT_LIO_STATE_SCSI_DATA_DONE (1 << 7) 93#define EFCT_LIO_STATE_TFO_QUEUE_STATUS (1 << 8) 94#define EFCT_LIO_STATE_SCSI_SEND_RSP (1 << 9) 95#define EFCT_LIO_STATE_SCSI_RSP_DONE (1 << 10) 96#define EFCT_LIO_STATE_TGT_GENERIC_FREE (1 << 11) 97#define EFCT_LIO_STATE_SCSI_RECV_TMF (1 << 12) 98#define EFCT_LIO_STATE_TGT_SUBMIT_TMR (1 << 13) 99#define EFCT_LIO_STATE_TFO_WRITE_PEND_STATUS (1 << 14) 100#define EFCT_LIO_STATE_TGT_GENERIC_REQ_FAILURE (1 << 15) 101 102#define EFCT_LIO_STATE_TFO_ABORTED_TASK (1 << 29) 103#define EFCT_LIO_STATE_TFO_RELEASE_CMD (1 << 30) 104#define EFCT_LIO_STATE_SCSI_CMPL_CMD (1u << 31) 105 106struct efct_scsi_tgt_io { 107 struct se_cmd cmd; 108 unsigned char sense_buffer[TRANSPORT_SENSE_BUFFER]; 109 enum dma_data_direction ddir; 110 int task_attr; 111 u64 lun; 112 113 u32 state; 114 u8 tmf; 115 struct efct_io *io_to_abort; 116 u32 seg_map_cnt; 117 u32 seg_cnt; 118 u32 cur_seg; 119 enum efct_scsi_io_status err; 120 bool aborting; 121 bool rsp_sent; 122 u32 transferred_len; 123}; 124 125/* Handler return codes */ 126enum { 127 SCSI_HANDLER_DATAPHASE_STARTED = 1, 128 SCSI_HANDLER_RESP_STARTED, 129 SCSI_HANDLER_VALIDATED_DATAPHASE_STARTED, 130 SCSI_CMD_NOT_SUPPORTED, 131}; 132 133#define WWN_NAME_LEN 32 134struct efct_lio_vport { 135 u64 wwpn; 136 u64 npiv_wwpn; 137 u64 npiv_wwnn; 138 unsigned char wwpn_str[WWN_NAME_LEN]; 139 struct se_wwn vport_wwn; 140 struct efct_lio_tpg *tpg; 141 struct efct *efct; 142 struct Scsi_Host *shost; 143 struct fc_vport *fc_vport; 144 atomic_t enable; 145}; 146 147struct efct_lio_nport { 148 u64 wwpn; 149 unsigned char wwpn_str[WWN_NAME_LEN]; 150 struct se_wwn nport_wwn; 151 struct efct_lio_tpg *tpg; 152 struct efct *efct; 153 atomic_t enable; 154}; 155 156struct efct_lio_tpg_attrib { 157 u32 generate_node_acls; 158 u32 cache_dynamic_acls; 159 u32 demo_mode_write_protect; 160 u32 prod_mode_write_protect; 161 u32 demo_mode_login_only; 162 bool session_deletion_wait; 163}; 164 165struct efct_lio_tpg { 166 struct se_portal_group tpg; 167 struct efct_lio_nport *nport; 168 struct efct_lio_vport *vport; 169 struct efct_lio_tpg_attrib tpg_attrib; 170 unsigned short tpgt; 171 bool enabled; 172}; 173 174struct efct_lio_nacl { 175 u64 nport_wwnn; 176 char nport_name[WWN_NAME_LEN]; 177 struct se_session *session; 178 struct se_node_acl se_node_acl; 179}; 180 181struct efct_lio_vport_list_t { 182 struct list_head list_entry; 183 struct efct_lio_vport *lio_vport; 184}; 185 186int efct_scsi_tgt_driver_init(void); 187int efct_scsi_tgt_driver_exit(void); 188 189#endif /*__EFCT_LIO_H__ */