Commit | Line | Data |
---|---|---|
c4795fb2 CH |
1 | #ifndef TARGET_CORE_BACKEND_H |
2 | #define TARGET_CORE_BACKEND_H | |
3 | ||
4 | #define TRANSPORT_PLUGIN_PHBA_PDEV 1 | |
5 | #define TRANSPORT_PLUGIN_VHBA_PDEV 2 | |
6 | #define TRANSPORT_PLUGIN_VHBA_VDEV 3 | |
7 | ||
73112edc NB |
8 | struct target_backend_cits { |
9 | struct config_item_type tb_dev_cit; | |
10 | }; | |
11 | ||
c4795fb2 CH |
12 | struct se_subsystem_api { |
13 | struct list_head sub_api_list; | |
14 | ||
15 | char name[16]; | |
0fd97ccf CH |
16 | char inquiry_prod[16]; |
17 | char inquiry_rev[4]; | |
c4795fb2 CH |
18 | struct module *owner; |
19 | ||
20 | u8 transport_type; | |
21 | ||
c4795fb2 CH |
22 | int (*attach_hba)(struct se_hba *, u32); |
23 | void (*detach_hba)(struct se_hba *); | |
24 | int (*pmode_enable_hba)(struct se_hba *, unsigned long); | |
0fd97ccf CH |
25 | |
26 | struct se_device *(*alloc_device)(struct se_hba *, const char *); | |
27 | int (*configure_device)(struct se_device *); | |
28 | void (*free_device)(struct se_device *device); | |
29 | ||
30 | ssize_t (*set_configfs_dev_params)(struct se_device *, | |
31 | const char *, ssize_t); | |
32 | ssize_t (*show_configfs_dev_params)(struct se_device *, char *); | |
33 | ||
d5829eac PB |
34 | void (*transport_complete)(struct se_cmd *cmd, |
35 | struct scatterlist *, | |
36 | unsigned char *); | |
d6e0175c | 37 | |
de103c93 | 38 | sense_reason_t (*parse_cdb)(struct se_cmd *cmd); |
c4795fb2 CH |
39 | u32 (*get_device_type)(struct se_device *); |
40 | sector_t (*get_blocks)(struct se_device *); | |
7f7caf6a AG |
41 | sector_t (*get_alignment_offset_lbas)(struct se_device *); |
42 | /* lbppbe = logical blocks per physical block exponent. see SBC-3 */ | |
43 | unsigned int (*get_lbppbe)(struct se_device *); | |
44 | unsigned int (*get_io_min)(struct se_device *); | |
45 | unsigned int (*get_io_opt)(struct se_device *); | |
5787cacd | 46 | unsigned char *(*get_sense_buffer)(struct se_cmd *); |
d0c8b259 | 47 | bool (*get_write_cache)(struct se_device *); |
ce65e5b9 NB |
48 | int (*init_prot)(struct se_device *); |
49 | int (*format_prot)(struct se_device *); | |
50 | void (*free_prot)(struct se_device *); | |
73112edc NB |
51 | |
52 | struct target_backend_cits tb_cits; | |
c4795fb2 CH |
53 | }; |
54 | ||
9e999a6c | 55 | struct sbc_ops { |
a82a9538 NB |
56 | sense_reason_t (*execute_rw)(struct se_cmd *cmd, struct scatterlist *, |
57 | u32, enum dma_data_direction); | |
de103c93 CH |
58 | sense_reason_t (*execute_sync_cache)(struct se_cmd *cmd); |
59 | sense_reason_t (*execute_write_same)(struct se_cmd *cmd); | |
cd063bef | 60 | sense_reason_t (*execute_write_same_unmap)(struct se_cmd *cmd); |
de103c93 | 61 | sense_reason_t (*execute_unmap)(struct se_cmd *cmd); |
0c2ad7d1 CH |
62 | }; |
63 | ||
c4795fb2 CH |
64 | int transport_subsystem_register(struct se_subsystem_api *); |
65 | void transport_subsystem_release(struct se_subsystem_api *); | |
66 | ||
6bb35e00 | 67 | void target_complete_cmd(struct se_cmd *, u8); |
2426bd45 | 68 | void target_complete_cmd_with_length(struct se_cmd *, u8, int); |
c4795fb2 | 69 | |
de103c93 CH |
70 | sense_reason_t spc_parse_cdb(struct se_cmd *cmd, unsigned int *size); |
71 | sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd); | |
0dfa1c5d HR |
72 | sense_reason_t spc_emulate_inquiry_std(struct se_cmd *, unsigned char *); |
73 | sense_reason_t spc_emulate_evpd_83(struct se_cmd *, unsigned char *); | |
d6e0175c | 74 | |
de103c93 | 75 | sense_reason_t sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops); |
6f23ac8a CH |
76 | u32 sbc_get_device_rev(struct se_device *dev); |
77 | u32 sbc_get_device_type(struct se_device *dev); | |
972b29c8 | 78 | sector_t sbc_get_write_same_sectors(struct se_cmd *cmd); |
86d71829 AH |
79 | sense_reason_t sbc_execute_unmap(struct se_cmd *cmd, |
80 | sense_reason_t (*do_unmap_fn)(struct se_cmd *cmd, void *priv, | |
81 | sector_t lba, sector_t nolb), | |
82 | void *priv); | |
66a3d5bc | 83 | void sbc_dif_generate(struct se_cmd *); |
41861fa8 NB |
84 | sense_reason_t sbc_dif_verify_write(struct se_cmd *, sector_t, unsigned int, |
85 | unsigned int, struct scatterlist *, int); | |
86 | sense_reason_t sbc_dif_verify_read(struct se_cmd *, sector_t, unsigned int, | |
87 | unsigned int, struct scatterlist *, int); | |
395ccb25 | 88 | sense_reason_t sbc_dif_read_strip(struct se_cmd *); |
6f23ac8a | 89 | |
c4795fb2 CH |
90 | void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *); |
91 | int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *); | |
92 | int transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *); | |
93 | int transport_set_vpd_ident(struct t10_vpd *, unsigned char *); | |
94 | ||
95 | /* core helpers also used by command snooping in pscsi */ | |
4949314c AG |
96 | void *transport_kmap_data_sg(struct se_cmd *); |
97 | void transport_kunmap_data_sg(struct se_cmd *); | |
c5ff8d6b NB |
98 | /* core helpers also used by xcopy during internal command setup */ |
99 | int target_alloc_sgl(struct scatterlist **, unsigned int *, u32, bool); | |
100 | sense_reason_t transport_generic_map_mem_to_cmd(struct se_cmd *, | |
101 | struct scatterlist *, u32, struct scatterlist *, u32); | |
c4795fb2 | 102 | |
4a5a75f3 JE |
103 | void array_free(void *array, int n); |
104 | ||
73112edc NB |
105 | /* From target_core_configfs.c to setup default backend config_item_types */ |
106 | void target_core_setup_sub_cits(struct se_subsystem_api *); | |
107 | ||
c4795fb2 | 108 | #endif /* TARGET_CORE_BACKEND_H */ |