Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
  1#ifndef __TARGET_USB_GADGET_H__
  2#define __TARGET_USB_GADGET_H__
  3
  4#include <linux/kref.h>
  5/* #include <linux/usb/uas.h> */
  6#include <linux/usb/composite.h>
  7#include <linux/usb/uas.h>
  8#include <linux/usb/storage.h>
  9#include <scsi/scsi.h>
 10#include <target/target_core_base.h>
 11#include <target/target_core_fabric.h>
 12
 13#define USBG_NAMELEN 32
 14
 15#define fuas_to_gadget(f)	(f->function.config->cdev->gadget)
 16#define UASP_SS_EP_COMP_LOG_STREAMS 4
 17#define UASP_SS_EP_COMP_NUM_STREAMS (1 << UASP_SS_EP_COMP_LOG_STREAMS)
 18
 19enum {
 20	USB_G_STR_CONFIG = USB_GADGET_FIRST_AVAIL_IDX,
 21	USB_G_STR_INT_UAS,
 22	USB_G_STR_INT_BBB,
 23};
 24
 25#define USB_G_ALT_INT_BBB       0
 26#define USB_G_ALT_INT_UAS       1
 27
 28struct usbg_nacl {
 29	/* Binary World Wide unique Port Name for SAS Initiator port */
 30	u64 iport_wwpn;
 31	/* ASCII formatted WWPN for Sas Initiator port */
 32	char iport_name[USBG_NAMELEN];
 33	/* Returned by usbg_make_nodeacl() */
 34	struct se_node_acl se_node_acl;
 35};
 36
 37struct tcm_usbg_nexus {
 38	struct se_session *tvn_se_sess;
 39};
 40
 41struct usbg_tpg {
 42	struct mutex tpg_mutex;
 43	/* SAS port target portal group tag for TCM */
 44	u16 tport_tpgt;
 45	/* Pointer back to usbg_tport */
 46	struct usbg_tport *tport;
 47	struct workqueue_struct *workqueue;
 48	/* Returned by usbg_make_tpg() */
 49	struct se_portal_group se_tpg;
 50	u32 gadget_connect;
 51	struct tcm_usbg_nexus *tpg_nexus;
 52	atomic_t tpg_port_count;
 53};
 54
 55struct usbg_tport {
 56	/* SCSI protocol the tport is providing */
 57	u8 tport_proto_id;
 58	/* Binary World Wide unique Port Name for SAS Target port */
 59	u64 tport_wwpn;
 60	/* ASCII formatted WWPN for SAS Target port */
 61	char tport_name[USBG_NAMELEN];
 62	/* Returned by usbg_make_tport() */
 63	struct se_wwn tport_wwn;
 64};
 65
 66enum uas_state {
 67	UASP_SEND_DATA,
 68	UASP_RECEIVE_DATA,
 69	UASP_SEND_STATUS,
 70	UASP_QUEUE_COMMAND,
 71};
 72
 73#define USBG_MAX_CMD    64
 74struct usbg_cmd {
 75	/* common */
 76	u8 cmd_buf[USBG_MAX_CMD];
 77	u32 data_len;
 78	struct work_struct work;
 79	int unpacked_lun;
 80	struct se_cmd se_cmd;
 81	void *data_buf; /* used if no sg support available */
 82	struct f_uas *fu;
 83	struct completion write_complete;
 84	struct kref ref;
 85
 86	/* UAS only */
 87	u16 tag;
 88	u16 prio_attr;
 89	struct sense_iu sense_iu;
 90	enum uas_state state;
 91	struct uas_stream *stream;
 92
 93	/* BOT only */
 94	__le32 bot_tag;
 95	unsigned int csw_code;
 96	unsigned is_read:1;
 97
 98};
 99
100struct uas_stream {
101	struct usb_request	*req_in;
102	struct usb_request	*req_out;
103	struct usb_request	*req_status;
104};
105
106struct usbg_cdb {
107	struct usb_request	*req;
108	void			*buf;
109};
110
111struct bot_status {
112	struct usb_request	*req;
113	struct bulk_cs_wrap	csw;
114};
115
116struct f_uas {
117	struct usbg_tpg		*tpg;
118	struct usb_function	function;
119	u16			iface;
120
121	u32			flags;
122#define USBG_ENABLED		(1 << 0)
123#define USBG_IS_UAS		(1 << 1)
124#define USBG_USE_STREAMS	(1 << 2)
125#define USBG_IS_BOT		(1 << 3)
126#define USBG_BOT_CMD_PEND	(1 << 4)
127
128	struct usbg_cdb		cmd;
129	struct usb_ep		*ep_in;
130	struct usb_ep		*ep_out;
131
132	/* UAS */
133	struct usb_ep		*ep_status;
134	struct usb_ep		*ep_cmd;
135	struct uas_stream	stream[UASP_SS_EP_COMP_NUM_STREAMS];
136
137	/* BOT */
138	struct bot_status	bot_status;
139	struct usb_request	*bot_req_in;
140	struct usb_request	*bot_req_out;
141};
142
143extern struct usbg_tpg *the_only_tpg_I_currently_have;
144
145#endif