]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/target/target_core_backend.h
spi-imx: Implements handling of the SPI_READY mode flag.
[mirror_ubuntu-bionic-kernel.git] / include / target / target_core_backend.h
1 #ifndef TARGET_CORE_BACKEND_H
2 #define TARGET_CORE_BACKEND_H
3
4 #include <linux/types.h>
5 #include <target/target_core_base.h>
6
7 #define TRANSPORT_FLAG_PASSTHROUGH 1
8
9 struct request_queue;
10 struct scatterlist;
11
12 struct target_backend_ops {
13 char name[16];
14 char inquiry_prod[16];
15 char inquiry_rev[4];
16 struct module *owner;
17
18 u8 transport_flags;
19
20 int (*attach_hba)(struct se_hba *, u32);
21 void (*detach_hba)(struct se_hba *);
22 int (*pmode_enable_hba)(struct se_hba *, unsigned long);
23
24 struct se_device *(*alloc_device)(struct se_hba *, const char *);
25 int (*configure_device)(struct se_device *);
26 void (*free_device)(struct se_device *device);
27
28 ssize_t (*set_configfs_dev_params)(struct se_device *,
29 const char *, ssize_t);
30 ssize_t (*show_configfs_dev_params)(struct se_device *, char *);
31
32 void (*transport_complete)(struct se_cmd *cmd,
33 struct scatterlist *,
34 unsigned char *);
35
36 sense_reason_t (*parse_cdb)(struct se_cmd *cmd);
37 u32 (*get_device_type)(struct se_device *);
38 sector_t (*get_blocks)(struct se_device *);
39 sector_t (*get_alignment_offset_lbas)(struct se_device *);
40 /* lbppbe = logical blocks per physical block exponent. see SBC-3 */
41 unsigned int (*get_lbppbe)(struct se_device *);
42 unsigned int (*get_io_min)(struct se_device *);
43 unsigned int (*get_io_opt)(struct se_device *);
44 unsigned char *(*get_sense_buffer)(struct se_cmd *);
45 bool (*get_write_cache)(struct se_device *);
46 int (*init_prot)(struct se_device *);
47 int (*format_prot)(struct se_device *);
48 void (*free_prot)(struct se_device *);
49
50 struct configfs_attribute **tb_dev_attrib_attrs;
51 };
52
53 struct sbc_ops {
54 sense_reason_t (*execute_rw)(struct se_cmd *cmd, struct scatterlist *,
55 u32, enum dma_data_direction);
56 sense_reason_t (*execute_sync_cache)(struct se_cmd *cmd);
57 sense_reason_t (*execute_write_same)(struct se_cmd *cmd);
58 sense_reason_t (*execute_unmap)(struct se_cmd *cmd,
59 sector_t lba, sector_t nolb);
60 };
61
62 int transport_backend_register(const struct target_backend_ops *);
63 void target_backend_unregister(const struct target_backend_ops *);
64
65 void target_complete_cmd(struct se_cmd *, u8);
66 void target_complete_cmd_with_length(struct se_cmd *, u8, int);
67
68 sense_reason_t spc_parse_cdb(struct se_cmd *cmd, unsigned int *size);
69 sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd);
70 sense_reason_t spc_emulate_inquiry_std(struct se_cmd *, unsigned char *);
71 sense_reason_t spc_emulate_evpd_83(struct se_cmd *, unsigned char *);
72
73 sense_reason_t sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops);
74 u32 sbc_get_device_rev(struct se_device *dev);
75 u32 sbc_get_device_type(struct se_device *dev);
76 sector_t sbc_get_write_same_sectors(struct se_cmd *cmd);
77 void sbc_dif_generate(struct se_cmd *);
78 sense_reason_t sbc_dif_verify(struct se_cmd *, sector_t, unsigned int,
79 unsigned int, struct scatterlist *, int);
80 void sbc_dif_copy_prot(struct se_cmd *, unsigned int, bool,
81 struct scatterlist *, int);
82 void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
83 int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *);
84 int transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *);
85 int transport_set_vpd_ident(struct t10_vpd *, unsigned char *);
86
87 extern struct configfs_attribute *sbc_attrib_attrs[];
88 extern struct configfs_attribute *passthrough_attrib_attrs[];
89
90 /* core helpers also used by command snooping in pscsi */
91 void *transport_kmap_data_sg(struct se_cmd *);
92 void transport_kunmap_data_sg(struct se_cmd *);
93 /* core helpers also used by xcopy during internal command setup */
94 sense_reason_t transport_generic_map_mem_to_cmd(struct se_cmd *,
95 struct scatterlist *, u32, struct scatterlist *, u32);
96
97 bool target_lun_is_rdonly(struct se_cmd *);
98 sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd,
99 sense_reason_t (*exec_cmd)(struct se_cmd *cmd));
100
101 bool target_sense_desc_format(struct se_device *dev);
102 sector_t target_to_linux_sector(struct se_device *dev, sector_t lb);
103 bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
104 struct request_queue *q);
105
106 #endif /* TARGET_CORE_BACKEND_H */