Blame view
include/target/target_core_backend.h
4.49 KB
b24413180
|
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
c4795fb20
|
2 3 |
#ifndef TARGET_CORE_BACKEND_H #define TARGET_CORE_BACKEND_H |
8dcf07be2
|
4 |
#include <linux/types.h> |
a85d667e5
|
5 |
#include <asm/unaligned.h> |
8dcf07be2
|
6 |
#include <target/target_core_base.h> |
530c6891b
|
7 8 9 10 11 12 |
#define TRANSPORT_FLAG_PASSTHROUGH 0x1 /* * ALUA commands, state checks and setup operations are handled by the * backend module. */ #define TRANSPORT_FLAG_PASSTHROUGH_ALUA 0x2 |
4ec5bf0ea
|
13 |
#define TRANSPORT_FLAG_PASSTHROUGH_PGR 0x4 |
c4795fb20
|
14 |
|
8dcf07be2
|
15 16 |
struct request_queue; struct scatterlist; |
0a06d4309
|
17 |
struct target_backend_ops { |
c4795fb20
|
18 |
char name[16]; |
0fd97ccf4
|
19 20 |
char inquiry_prod[16]; char inquiry_rev[4]; |
c4795fb20
|
21 |
struct module *owner; |
a3541703e
|
22 |
u8 transport_flags; |
c4795fb20
|
23 |
|
c4795fb20
|
24 25 26 |
int (*attach_hba)(struct se_hba *, u32); void (*detach_hba)(struct se_hba *); int (*pmode_enable_hba)(struct se_hba *, unsigned long); |
0fd97ccf4
|
27 28 29 |
struct se_device *(*alloc_device)(struct se_hba *, const char *); int (*configure_device)(struct se_device *); |
926347061
|
30 |
void (*destroy_device)(struct se_device *); |
0fd97ccf4
|
31 32 33 34 35 |
void (*free_device)(struct se_device *device); ssize_t (*set_configfs_dev_params)(struct se_device *, const char *, ssize_t); ssize_t (*show_configfs_dev_params)(struct se_device *, char *); |
de103c93a
|
36 |
sense_reason_t (*parse_cdb)(struct se_cmd *cmd); |
c4795fb20
|
37 38 |
u32 (*get_device_type)(struct se_device *); sector_t (*get_blocks)(struct se_device *); |
7f7caf6aa
|
39 40 41 42 43 |
sector_t (*get_alignment_offset_lbas)(struct se_device *); /* lbppbe = logical blocks per physical block exponent. see SBC-3 */ unsigned int (*get_lbppbe)(struct se_device *); unsigned int (*get_io_min)(struct se_device *); unsigned int (*get_io_opt)(struct se_device *); |
5787cacd0
|
44 |
unsigned char *(*get_sense_buffer)(struct se_cmd *); |
d0c8b259f
|
45 |
bool (*get_write_cache)(struct se_device *); |
ce65e5b97
|
46 47 48 |
int (*init_prot)(struct se_device *); int (*format_prot)(struct se_device *); void (*free_prot)(struct se_device *); |
73112edca
|
49 |
|
0a06d4309
|
50 |
struct configfs_attribute **tb_dev_attrib_attrs; |
c4795fb20
|
51 |
}; |
9e999a6c5
|
52 |
struct sbc_ops { |
a82a9538d
|
53 54 |
sense_reason_t (*execute_rw)(struct se_cmd *cmd, struct scatterlist *, u32, enum dma_data_direction); |
de103c93a
|
55 56 |
sense_reason_t (*execute_sync_cache)(struct se_cmd *cmd); sense_reason_t (*execute_write_same)(struct se_cmd *cmd); |
62e469425
|
57 58 |
sense_reason_t (*execute_unmap)(struct se_cmd *cmd, sector_t lba, sector_t nolb); |
0c2ad7d11
|
59 |
}; |
0a06d4309
|
60 61 |
int transport_backend_register(const struct target_backend_ops *); void target_backend_unregister(const struct target_backend_ops *); |
c4795fb20
|
62 |
|
6bb35e009
|
63 |
void target_complete_cmd(struct se_cmd *, u8); |
2426bd456
|
64 |
void target_complete_cmd_with_length(struct se_cmd *, u8, int); |
c4795fb20
|
65 |
|
c6d66aba9
|
66 |
void transport_copy_sense_to_cmd(struct se_cmd *, unsigned char *); |
de103c93a
|
67 68 |
sense_reason_t spc_parse_cdb(struct se_cmd *cmd, unsigned int *size); sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd); |
0dfa1c5da
|
69 70 |
sense_reason_t spc_emulate_inquiry_std(struct se_cmd *, unsigned char *); sense_reason_t spc_emulate_evpd_83(struct se_cmd *, unsigned char *); |
d6e0175cf
|
71 |
|
de103c93a
|
72 |
sense_reason_t sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops); |
6f23ac8a3
|
73 74 |
u32 sbc_get_device_rev(struct se_device *dev); u32 sbc_get_device_type(struct se_device *dev); |
972b29c8f
|
75 |
sector_t sbc_get_write_same_sectors(struct se_cmd *cmd); |
66a3d5bc4
|
76 |
void sbc_dif_generate(struct se_cmd *); |
f75b6fae1
|
77 |
sense_reason_t sbc_dif_verify(struct se_cmd *, sector_t, unsigned int, |
41861fa83
|
78 |
unsigned int, struct scatterlist *, int); |
f75b6fae1
|
79 80 |
void sbc_dif_copy_prot(struct se_cmd *, unsigned int, bool, struct scatterlist *, int); |
c4795fb20
|
81 82 83 84 |
void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *); int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *); int transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *); int transport_set_vpd_ident(struct t10_vpd *, unsigned char *); |
5873c4d15
|
85 86 |
extern struct configfs_attribute *sbc_attrib_attrs[]; extern struct configfs_attribute *passthrough_attrib_attrs[]; |
c4795fb20
|
87 |
/* core helpers also used by command snooping in pscsi */ |
4949314c7
|
88 89 |
void *transport_kmap_data_sg(struct se_cmd *); void transport_kunmap_data_sg(struct se_cmd *); |
c5ff8d6bc
|
90 |
/* core helpers also used by xcopy during internal command setup */ |
c5ff8d6bc
|
91 92 |
sense_reason_t transport_generic_map_mem_to_cmd(struct se_cmd *, struct scatterlist *, u32, struct scatterlist *, u32); |
c4795fb20
|
93 |
|
29a05deeb
|
94 |
bool target_lun_is_rdonly(struct se_cmd *); |
7bfea53b5
|
95 96 |
sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd, sense_reason_t (*exec_cmd)(struct se_cmd *cmd)); |
d30cd1238
|
97 |
|
85441e6b8
|
98 |
struct se_device *target_find_device(int id, bool do_depend); |
4e4937e8a
|
99 |
bool target_sense_desc_format(struct se_device *dev); |
8a9ebe717
|
100 101 |
sector_t target_to_linux_sector(struct se_device *dev, sector_t lb); bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib, |
ea263c7fa
|
102 |
struct request_queue *q); |
4e4937e8a
|
103 |
|
a85d667e5
|
104 105 106 107 108 109 |
/* Only use get_unaligned_be24() if reading p - 1 is allowed. */ static inline uint32_t get_unaligned_be24(const uint8_t *const p) { return get_unaligned_be32(p - 1) & 0xffffffU; } |
c4795fb20
|
110 |
#endif /* TARGET_CORE_BACKEND_H */ |