1c4795fb2SChristoph Hellwig #ifndef TARGET_CORE_FABRIC_H 2c4795fb2SChristoph Hellwig #define TARGET_CORE_FABRIC_H 3c4795fb2SChristoph Hellwig 4c4795fb2SChristoph Hellwig struct target_core_fabric_ops { 5c4795fb2SChristoph Hellwig struct configfs_subsystem *tf_subsys; 6c4795fb2SChristoph Hellwig char *(*get_fabric_name)(void); 7c4795fb2SChristoph Hellwig u8 (*get_fabric_proto_ident)(struct se_portal_group *); 8c4795fb2SChristoph Hellwig char *(*tpg_get_wwn)(struct se_portal_group *); 9c4795fb2SChristoph Hellwig u16 (*tpg_get_tag)(struct se_portal_group *); 10c4795fb2SChristoph Hellwig u32 (*tpg_get_default_depth)(struct se_portal_group *); 11c4795fb2SChristoph Hellwig u32 (*tpg_get_pr_transport_id)(struct se_portal_group *, 12c4795fb2SChristoph Hellwig struct se_node_acl *, 13c4795fb2SChristoph Hellwig struct t10_pr_registration *, int *, 14c4795fb2SChristoph Hellwig unsigned char *); 15c4795fb2SChristoph Hellwig u32 (*tpg_get_pr_transport_id_len)(struct se_portal_group *, 16c4795fb2SChristoph Hellwig struct se_node_acl *, 17c4795fb2SChristoph Hellwig struct t10_pr_registration *, int *); 18c4795fb2SChristoph Hellwig char *(*tpg_parse_pr_out_transport_id)(struct se_portal_group *, 19c4795fb2SChristoph Hellwig const char *, u32 *, char **); 20c4795fb2SChristoph Hellwig int (*tpg_check_demo_mode)(struct se_portal_group *); 21c4795fb2SChristoph Hellwig int (*tpg_check_demo_mode_cache)(struct se_portal_group *); 22c4795fb2SChristoph Hellwig int (*tpg_check_demo_mode_write_protect)(struct se_portal_group *); 23c4795fb2SChristoph Hellwig int (*tpg_check_prod_mode_write_protect)(struct se_portal_group *); 24c4795fb2SChristoph Hellwig /* 25c4795fb2SChristoph Hellwig * Optionally used by fabrics to allow demo-mode login, but not 26c4795fb2SChristoph Hellwig * expose any TPG LUNs, and return 'not connected' in standard 27c4795fb2SChristoph Hellwig * inquiry response 28c4795fb2SChristoph Hellwig */ 29c4795fb2SChristoph Hellwig int (*tpg_check_demo_mode_login_only)(struct se_portal_group *); 30c4795fb2SChristoph Hellwig struct se_node_acl *(*tpg_alloc_fabric_acl)( 31c4795fb2SChristoph Hellwig struct se_portal_group *); 32c4795fb2SChristoph Hellwig void (*tpg_release_fabric_acl)(struct se_portal_group *, 33c4795fb2SChristoph Hellwig struct se_node_acl *); 34c4795fb2SChristoph Hellwig u32 (*tpg_get_inst_index)(struct se_portal_group *); 35c4795fb2SChristoph Hellwig /* 36c4795fb2SChristoph Hellwig * Optional function pointer for TCM to perform command map 37c4795fb2SChristoph Hellwig * from TCM processing thread context, for those struct se_cmd 38c4795fb2SChristoph Hellwig * initially allocated in interrupt context. 39c4795fb2SChristoph Hellwig */ 40c4795fb2SChristoph Hellwig int (*new_cmd_map)(struct se_cmd *); 41c4795fb2SChristoph Hellwig /* 42c4795fb2SChristoph Hellwig * Optional to release struct se_cmd and fabric dependent allocated 43c4795fb2SChristoph Hellwig * I/O descriptor in transport_cmd_check_stop(). 44c4795fb2SChristoph Hellwig * 45c4795fb2SChristoph Hellwig * Returning 1 will signal a descriptor has been released. 46c4795fb2SChristoph Hellwig * Returning 0 will signal a descriptor has not been released. 47c4795fb2SChristoph Hellwig */ 48c4795fb2SChristoph Hellwig int (*check_stop_free)(struct se_cmd *); 49c4795fb2SChristoph Hellwig void (*release_cmd)(struct se_cmd *); 50c4795fb2SChristoph Hellwig /* 51c4795fb2SChristoph Hellwig * Called with spin_lock_bh(struct se_portal_group->session_lock held. 52c4795fb2SChristoph Hellwig */ 53c4795fb2SChristoph Hellwig int (*shutdown_session)(struct se_session *); 54c4795fb2SChristoph Hellwig void (*close_session)(struct se_session *); 55c4795fb2SChristoph Hellwig u32 (*sess_get_index)(struct se_session *); 56c4795fb2SChristoph Hellwig /* 57c4795fb2SChristoph Hellwig * Used only for SCSI fabrics that contain multi-value TransportIDs 58c4795fb2SChristoph Hellwig * (like iSCSI). All other SCSI fabrics should set this to NULL. 59c4795fb2SChristoph Hellwig */ 60c4795fb2SChristoph Hellwig u32 (*sess_get_initiator_sid)(struct se_session *, 61c4795fb2SChristoph Hellwig unsigned char *, u32); 62c4795fb2SChristoph Hellwig int (*write_pending)(struct se_cmd *); 63c4795fb2SChristoph Hellwig int (*write_pending_status)(struct se_cmd *); 64c4795fb2SChristoph Hellwig void (*set_default_node_attributes)(struct se_node_acl *); 65c4795fb2SChristoph Hellwig u32 (*get_task_tag)(struct se_cmd *); 66c4795fb2SChristoph Hellwig int (*get_cmd_state)(struct se_cmd *); 67c4795fb2SChristoph Hellwig int (*queue_data_in)(struct se_cmd *); 68c4795fb2SChristoph Hellwig int (*queue_status)(struct se_cmd *); 69c4795fb2SChristoph Hellwig int (*queue_tm_rsp)(struct se_cmd *); 70c4795fb2SChristoph Hellwig u16 (*set_fabric_sense_len)(struct se_cmd *, u32); 71c4795fb2SChristoph Hellwig u16 (*get_fabric_sense_len)(void); 72c4795fb2SChristoph Hellwig /* 73c4795fb2SChristoph Hellwig * fabric module calls for target_core_fabric_configfs.c 74c4795fb2SChristoph Hellwig */ 75c4795fb2SChristoph Hellwig struct se_wwn *(*fabric_make_wwn)(struct target_fabric_configfs *, 76c4795fb2SChristoph Hellwig struct config_group *, const char *); 77c4795fb2SChristoph Hellwig void (*fabric_drop_wwn)(struct se_wwn *); 78c4795fb2SChristoph Hellwig struct se_portal_group *(*fabric_make_tpg)(struct se_wwn *, 79c4795fb2SChristoph Hellwig struct config_group *, const char *); 80c4795fb2SChristoph Hellwig void (*fabric_drop_tpg)(struct se_portal_group *); 81c4795fb2SChristoph Hellwig int (*fabric_post_link)(struct se_portal_group *, 82c4795fb2SChristoph Hellwig struct se_lun *); 83c4795fb2SChristoph Hellwig void (*fabric_pre_unlink)(struct se_portal_group *, 84c4795fb2SChristoph Hellwig struct se_lun *); 85c4795fb2SChristoph Hellwig struct se_tpg_np *(*fabric_make_np)(struct se_portal_group *, 86c4795fb2SChristoph Hellwig struct config_group *, const char *); 87c4795fb2SChristoph Hellwig void (*fabric_drop_np)(struct se_tpg_np *); 88c4795fb2SChristoph Hellwig struct se_node_acl *(*fabric_make_nodeacl)(struct se_portal_group *, 89c4795fb2SChristoph Hellwig struct config_group *, const char *); 90c4795fb2SChristoph Hellwig void (*fabric_drop_nodeacl)(struct se_node_acl *); 91c4795fb2SChristoph Hellwig }; 92c4795fb2SChristoph Hellwig 93c4795fb2SChristoph Hellwig struct se_session *transport_init_session(void); 94c4795fb2SChristoph Hellwig void __transport_register_session(struct se_portal_group *, 95c4795fb2SChristoph Hellwig struct se_node_acl *, struct se_session *, void *); 96c4795fb2SChristoph Hellwig void transport_register_session(struct se_portal_group *, 97c4795fb2SChristoph Hellwig struct se_node_acl *, struct se_session *, void *); 9841ac82b6SNicholas Bellinger void target_get_session(struct se_session *); 99*33933a0eSJörn Engel void target_put_session(struct se_session *); 100c4795fb2SChristoph Hellwig void transport_free_session(struct se_session *); 101afb999ffSNicholas Bellinger void target_put_nacl(struct se_node_acl *); 102c4795fb2SChristoph Hellwig void transport_deregister_session_configfs(struct se_session *); 103c4795fb2SChristoph Hellwig void transport_deregister_session(struct se_session *); 104c4795fb2SChristoph Hellwig 105c4795fb2SChristoph Hellwig 106c4795fb2SChristoph Hellwig void transport_init_se_cmd(struct se_cmd *, struct target_core_fabric_ops *, 107c4795fb2SChristoph Hellwig struct se_session *, u32, int, int, unsigned char *); 108c4795fb2SChristoph Hellwig int transport_lookup_cmd_lun(struct se_cmd *, u32); 109a12f41f8SAndy Grover int target_setup_cmd_from_cdb(struct se_cmd *, unsigned char *); 1101edcdb49SAndy Grover void target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *, 111a6360785SNicholas Bellinger unsigned char *, u32, u32, int, int, int); 112c7042caeSNicholas Bellinger int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, 113ea98d7f9SAndy Grover unsigned char *sense, u32 unpacked_lun, 114c0974f89SNicholas Bellinger void *fabric_tmr_ptr, unsigned char tm_type, 115c0974f89SNicholas Bellinger gfp_t, unsigned int, int); 116c4795fb2SChristoph Hellwig int transport_handle_cdb_direct(struct se_cmd *); 117c4795fb2SChristoph Hellwig int transport_generic_handle_cdb_map(struct se_cmd *); 118c4795fb2SChristoph Hellwig int transport_generic_handle_data(struct se_cmd *); 119c4795fb2SChristoph Hellwig int transport_generic_map_mem_to_cmd(struct se_cmd *cmd, 120c4795fb2SChristoph Hellwig struct scatterlist *, u32, struct scatterlist *, u32); 121c4795fb2SChristoph Hellwig int transport_generic_new_cmd(struct se_cmd *); 122c4795fb2SChristoph Hellwig 123c4795fb2SChristoph Hellwig void transport_generic_process_write(struct se_cmd *); 124c4795fb2SChristoph Hellwig 125c4795fb2SChristoph Hellwig void transport_generic_free_cmd(struct se_cmd *, int); 126c4795fb2SChristoph Hellwig 127c4795fb2SChristoph Hellwig bool transport_wait_for_tasks(struct se_cmd *); 128c4795fb2SChristoph Hellwig int transport_check_aborted_status(struct se_cmd *, int); 129c4795fb2SChristoph Hellwig int transport_send_check_condition_and_sense(struct se_cmd *, u8, int); 130c4795fb2SChristoph Hellwig 131a6360785SNicholas Bellinger void target_get_sess_cmd(struct se_session *, struct se_cmd *, bool); 132c4795fb2SChristoph Hellwig int target_put_sess_cmd(struct se_session *, struct se_cmd *); 133c4795fb2SChristoph Hellwig void target_splice_sess_cmd_list(struct se_session *); 134c4795fb2SChristoph Hellwig void target_wait_for_sess_cmds(struct se_session *, int); 135c4795fb2SChristoph Hellwig 136c4795fb2SChristoph Hellwig int core_alua_check_nonop_delay(struct se_cmd *); 137c4795fb2SChristoph Hellwig 138c8e31f26SAndy Grover int core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t); 139c4795fb2SChristoph Hellwig void core_tmr_release_req(struct se_tmr_req *); 140c4795fb2SChristoph Hellwig int transport_generic_handle_tmr(struct se_cmd *); 1412fbff127SNicholas Bellinger void transport_generic_request_failure(struct se_cmd *); 142c4795fb2SChristoph Hellwig int transport_lookup_tmr_lun(struct se_cmd *, u32); 143c4795fb2SChristoph Hellwig 144c4795fb2SChristoph Hellwig struct se_node_acl *core_tpg_check_initiator_node_acl(struct se_portal_group *, 145c4795fb2SChristoph Hellwig unsigned char *); 146c4795fb2SChristoph Hellwig void core_tpg_clear_object_luns(struct se_portal_group *); 147c4795fb2SChristoph Hellwig struct se_node_acl *core_tpg_add_initiator_node_acl(struct se_portal_group *, 148c4795fb2SChristoph Hellwig struct se_node_acl *, const char *, u32); 149c4795fb2SChristoph Hellwig int core_tpg_del_initiator_node_acl(struct se_portal_group *, 150c4795fb2SChristoph Hellwig struct se_node_acl *, int); 151c4795fb2SChristoph Hellwig int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *, 152c4795fb2SChristoph Hellwig unsigned char *, u32, int); 153c4795fb2SChristoph Hellwig int core_tpg_register(struct target_core_fabric_ops *, struct se_wwn *, 154c4795fb2SChristoph Hellwig struct se_portal_group *, void *, int); 155c4795fb2SChristoph Hellwig int core_tpg_deregister(struct se_portal_group *); 156c4795fb2SChristoph Hellwig 157c4795fb2SChristoph Hellwig /* SAS helpers */ 158c4795fb2SChristoph Hellwig u8 sas_get_fabric_proto_ident(struct se_portal_group *); 159c4795fb2SChristoph Hellwig u32 sas_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *, 160c4795fb2SChristoph Hellwig struct t10_pr_registration *, int *, unsigned char *); 161c4795fb2SChristoph Hellwig u32 sas_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *, 162c4795fb2SChristoph Hellwig struct t10_pr_registration *, int *); 163c4795fb2SChristoph Hellwig char *sas_parse_pr_out_transport_id(struct se_portal_group *, const char *, 164c4795fb2SChristoph Hellwig u32 *, char **); 165c4795fb2SChristoph Hellwig 166c4795fb2SChristoph Hellwig /* FC helpers */ 167c4795fb2SChristoph Hellwig u8 fc_get_fabric_proto_ident(struct se_portal_group *); 168c4795fb2SChristoph Hellwig u32 fc_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *, 169c4795fb2SChristoph Hellwig struct t10_pr_registration *, int *, unsigned char *); 170c4795fb2SChristoph Hellwig u32 fc_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *, 171c4795fb2SChristoph Hellwig struct t10_pr_registration *, int *); 172c4795fb2SChristoph Hellwig char *fc_parse_pr_out_transport_id(struct se_portal_group *, const char *, 173c4795fb2SChristoph Hellwig u32 *, char **); 174c4795fb2SChristoph Hellwig 175c4795fb2SChristoph Hellwig /* iSCSI helpers */ 176c4795fb2SChristoph Hellwig u8 iscsi_get_fabric_proto_ident(struct se_portal_group *); 177c4795fb2SChristoph Hellwig u32 iscsi_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *, 178c4795fb2SChristoph Hellwig struct t10_pr_registration *, int *, unsigned char *); 179c4795fb2SChristoph Hellwig u32 iscsi_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *, 180c4795fb2SChristoph Hellwig struct t10_pr_registration *, int *); 181c4795fb2SChristoph Hellwig char *iscsi_parse_pr_out_transport_id(struct se_portal_group *, const char *, 182c4795fb2SChristoph Hellwig u32 *, char **); 183c4795fb2SChristoph Hellwig 184c4795fb2SChristoph Hellwig #endif /* TARGET_CORE_FABRICH */ 185