linux/drivers/usb/gadget/function/f_tcm.c

// SPDX-License-Identifier: GPL-2.0
/* Target based USB-Gadget
 *
 * UAS protocol handling, target callbacks, configfs handling,
 * BBB (USB Mass Storage Class Bulk-Only (BBB) and Transport protocol handling.
 *
 * Author: Sebastian Andrzej Siewior <bigeasy at linutronix dot de>
 */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/configfs.h>
#include <linux/ctype.h>
#include <linux/usb/ch9.h>
#include <linux/usb/composite.h>
#include <linux/usb/gadget.h>
#include <linux/usb/storage.h>
#include <scsi/scsi_tcq.h>
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <linux/unaligned.h>

#include "tcm.h"
#include "u_tcm.h"
#include "configfs.h"

#define TPG_INSTANCES

struct tpg_instance {};

static struct tpg_instance tpg_instances[TPG_INSTANCES];

static DEFINE_MUTEX(tpg_instances_lock);

static inline struct f_uas *to_f_uas(struct usb_function *f)
{}

/* Start bot.c code */

static int bot_enqueue_cmd_cbw(struct f_uas *fu)
{}

static void bot_status_complete(struct usb_ep *ep, struct usb_request *req)
{}

static void bot_enqueue_sense_code(struct f_uas *fu, struct usbg_cmd *cmd)
{}

static void bot_err_compl(struct usb_ep *ep, struct usb_request *req)
{}

static void bot_send_bad_status(struct usbg_cmd *cmd)
{}

static int bot_send_status(struct usbg_cmd *cmd, bool moved_data)
{}

/*
 * Called after command (no data transfer) or after the write (to device)
 * operation is completed
 */
static int bot_send_status_response(struct usbg_cmd *cmd)
{}

/* Read request completed, now we have to send the CSW */
static void bot_read_compl(struct usb_ep *ep, struct usb_request *req)
{}

static int bot_send_read_response(struct usbg_cmd *cmd)
{}

static void usbg_data_write_cmpl(struct usb_ep *, struct usb_request *);
static int usbg_prepare_w_request(struct usbg_cmd *, struct usb_request *);

static int bot_send_write_request(struct usbg_cmd *cmd)
{}

static int bot_submit_command(struct f_uas *, void *, unsigned int);

static void bot_cmd_complete(struct usb_ep *ep, struct usb_request *req)
{}

static int bot_prepare_reqs(struct f_uas *fu)
{}

static void bot_cleanup_old_alt(struct f_uas *fu)
{}

static void bot_set_alt(struct f_uas *fu)
{}

static int usbg_bot_setup(struct usb_function *f,
		const struct usb_ctrlrequest *ctrl)
{}

/* Start uas.c code */

static void uasp_cleanup_one_stream(struct f_uas *fu, struct uas_stream *stream)
{}

static void uasp_free_cmdreq(struct f_uas *fu)
{}

static void uasp_cleanup_old_alt(struct f_uas *fu)
{}

static void uasp_status_data_cmpl(struct usb_ep *ep, struct usb_request *req);

static int uasp_prepare_r_request(struct usbg_cmd *cmd)
{}

static void uasp_prepare_status(struct usbg_cmd *cmd)
{}

static void uasp_status_data_cmpl(struct usb_ep *ep, struct usb_request *req)
{}

static int uasp_send_status_response(struct usbg_cmd *cmd)
{}

static int uasp_send_read_response(struct usbg_cmd *cmd)
{}

static int uasp_send_write_request(struct usbg_cmd *cmd)
{}

static int usbg_submit_command(struct f_uas *, void *, unsigned int);

static void uasp_cmd_complete(struct usb_ep *ep, struct usb_request *req)
{}

static int uasp_alloc_stream_res(struct f_uas *fu, struct uas_stream *stream)
{}

static int uasp_alloc_cmd(struct f_uas *fu)
{}

static void uasp_setup_stream_res(struct f_uas *fu, int max_streams)
{}

static int uasp_prepare_reqs(struct f_uas *fu)
{}

static void uasp_set_alt(struct f_uas *fu)
{}

static int get_cmd_dir(const unsigned char *cdb)
{}

static void usbg_data_write_cmpl(struct usb_ep *ep, struct usb_request *req)
{}

static int usbg_prepare_w_request(struct usbg_cmd *cmd, struct usb_request *req)
{}

static int usbg_send_status_response(struct se_cmd *se_cmd)
{}

static int usbg_send_write_request(struct se_cmd *se_cmd)
{}

static int usbg_send_read_response(struct se_cmd *se_cmd)
{}

static void usbg_cmd_work(struct work_struct *work)
{}

static struct usbg_cmd *usbg_get_cmd(struct f_uas *fu,
		struct tcm_usbg_nexus *tv_nexus, u32 scsi_tag)
{}

static void usbg_release_cmd(struct se_cmd *);

static int usbg_submit_command(struct f_uas *fu,
		void *cmdbuf, unsigned int len)
{}

static void bot_cmd_work(struct work_struct *work)
{}

static int bot_submit_command(struct f_uas *fu,
		void *cmdbuf, unsigned int len)
{}

/* Start fabric.c code */

static int usbg_check_true(struct se_portal_group *se_tpg)
{}

static char *usbg_get_fabric_wwn(struct se_portal_group *se_tpg)
{}

static u16 usbg_get_tag(struct se_portal_group *se_tpg)
{}

static void usbg_release_cmd(struct se_cmd *se_cmd)
{}

static void usbg_queue_tm_rsp(struct se_cmd *se_cmd)
{}

static void usbg_aborted_task(struct se_cmd *se_cmd)
{}

static const char *usbg_check_wwn(const char *name)
{}

static int usbg_init_nodeacl(struct se_node_acl *se_nacl, const char *name)
{}

static struct se_portal_group *usbg_make_tpg(struct se_wwn *wwn,
					     const char *name)
{}

static int tcm_usbg_drop_nexus(struct usbg_tpg *);

static void usbg_drop_tpg(struct se_portal_group *se_tpg)
{}

static struct se_wwn *usbg_make_tport(
	struct target_fabric_configfs *tf,
	struct config_group *group,
	const char *name)
{}

static void usbg_drop_tport(struct se_wwn *wwn)
{}

/*
 * If somebody feels like dropping the version property, go ahead.
 */
static ssize_t usbg_wwn_version_show(struct config_item *item,  char *page)
{}

CONFIGFS_ATTR_RO();

static struct configfs_attribute *usbg_wwn_attrs[] =;

static int usbg_attach(struct usbg_tpg *);
static void usbg_detach(struct usbg_tpg *);

static int usbg_enable_tpg(struct se_portal_group *se_tpg, bool enable)
{}

static ssize_t tcm_usbg_tpg_nexus_show(struct config_item *item, char *page)
{}

static int usbg_alloc_sess_cb(struct se_portal_group *se_tpg,
			      struct se_session *se_sess, void *p)
{}

static int tcm_usbg_make_nexus(struct usbg_tpg *tpg, char *name)
{}

static int tcm_usbg_drop_nexus(struct usbg_tpg *tpg)
{}

static ssize_t tcm_usbg_tpg_nexus_store(struct config_item *item,
		const char *page, size_t count)
{}

CONFIGFS_ATTR();

static struct configfs_attribute *usbg_base_attrs[] =;

static int usbg_port_link(struct se_portal_group *se_tpg, struct se_lun *lun)
{}

static void usbg_port_unlink(struct se_portal_group *se_tpg,
		struct se_lun *se_lun)
{}

static int usbg_check_stop_free(struct se_cmd *se_cmd)
{}

static const struct target_core_fabric_ops usbg_ops =;

/* Start gadget.c code */

static struct usb_interface_descriptor bot_intf_desc =;

static struct usb_interface_descriptor uasp_intf_desc =;

static struct usb_endpoint_descriptor uasp_bi_desc =;

static struct usb_endpoint_descriptor uasp_fs_bi_desc =;

static struct usb_pipe_usage_descriptor uasp_bi_pipe_desc =;

static struct usb_endpoint_descriptor uasp_ss_bi_desc =;

static struct usb_ss_ep_comp_descriptor uasp_bi_ep_comp_desc =;

static struct usb_ss_ep_comp_descriptor bot_bi_ep_comp_desc =;

static struct usb_endpoint_descriptor uasp_bo_desc =;

static struct usb_endpoint_descriptor uasp_fs_bo_desc =;

static struct usb_pipe_usage_descriptor uasp_bo_pipe_desc =;

static struct usb_endpoint_descriptor uasp_ss_bo_desc =;

static struct usb_ss_ep_comp_descriptor uasp_bo_ep_comp_desc =;

static struct usb_ss_ep_comp_descriptor bot_bo_ep_comp_desc =;

static struct usb_endpoint_descriptor uasp_status_desc =;

static struct usb_endpoint_descriptor uasp_fs_status_desc =;

static struct usb_pipe_usage_descriptor uasp_status_pipe_desc =;

static struct usb_endpoint_descriptor uasp_ss_status_desc =;

static struct usb_ss_ep_comp_descriptor uasp_status_in_ep_comp_desc =;

static struct usb_endpoint_descriptor uasp_cmd_desc =;

static struct usb_endpoint_descriptor uasp_fs_cmd_desc =;

static struct usb_pipe_usage_descriptor uasp_cmd_pipe_desc =;

static struct usb_endpoint_descriptor uasp_ss_cmd_desc =;

static struct usb_ss_ep_comp_descriptor uasp_cmd_comp_desc =;

static struct usb_descriptor_header *uasp_fs_function_desc[] =;

static struct usb_descriptor_header *uasp_hs_function_desc[] =;

static struct usb_descriptor_header *uasp_ss_function_desc[] =;

static struct usb_string	tcm_us_strings[] =;

static struct usb_gadget_strings tcm_stringtab =;

static struct usb_gadget_strings *tcm_strings[] =;

static int tcm_bind(struct usb_configuration *c, struct usb_function *f)
{}

struct guas_setup_wq {};

static void tcm_delayed_set_alt(struct work_struct *wq)
{}

static int tcm_get_alt(struct usb_function *f, unsigned intf)
{}

static int tcm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
{}

static void tcm_disable(struct usb_function *f)
{}

static int tcm_setup(struct usb_function *f,
		const struct usb_ctrlrequest *ctrl)
{}

static inline struct f_tcm_opts *to_f_tcm_opts(struct config_item *item)
{}

static void tcm_attr_release(struct config_item *item)
{}

static struct configfs_item_operations tcm_item_ops =;

static const struct config_item_type tcm_func_type =;

static void tcm_free_inst(struct usb_function_instance *f)
{}

static int tcm_register_callback(struct usb_function_instance *f)
{}

static void tcm_unregister_callback(struct usb_function_instance *f)
{}

static int usbg_attach(struct usbg_tpg *tpg)
{}

static void usbg_detach(struct usbg_tpg *tpg)
{}

static int tcm_set_name(struct usb_function_instance *f, const char *name)
{}

static struct usb_function_instance *tcm_alloc_inst(void)
{}

static void tcm_free(struct usb_function *f)
{}

static void tcm_unbind(struct usb_configuration *c, struct usb_function *f)
{}

static struct usb_function *tcm_alloc(struct usb_function_instance *fi)
{}

DECLARE_USB_FUNCTION(tcm, tcm_alloc_inst, tcm_alloc);

static int __init tcm_init(void)
{}
module_init();

static void __exit tcm_exit(void)
{}
module_exit(tcm_exit);

MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_AUTHOR();