linux/drivers/usb/storage/uas.c

// SPDX-License-Identifier: GPL-2.0
/*
 * USB Attached SCSI
 * Note that this is not the same as the USB Mass Storage driver
 *
 * Copyright Hans de Goede <[email protected]> for Red Hat, Inc. 2013 - 2016
 * Copyright Matthew Wilcox for Intel Corp, 2010
 * Copyright Sarah Sharp for Intel Corp, 2010
 */

#include <linux/blkdev.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb_usual.h>
#include <linux/usb/hcd.h>
#include <linux/usb/storage.h>
#include <linux/usb/uas.h>

#include <scsi/scsi.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_dbg.h>
#include <scsi/scsi_devinfo.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_tcq.h>

#include "uas-detect.h"
#include "scsiglue.h"

#define MAX_CMNDS

struct uas_dev_info {};

enum {};

/* Overrides scsi_pointer */
struct uas_cmd_info {};

/* I hate forward declarations, but I actually have a loop */
static int uas_submit_urbs(struct scsi_cmnd *cmnd,
				struct uas_dev_info *devinfo);
static void uas_do_work(struct work_struct *work);
static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller);
static void uas_free_streams(struct uas_dev_info *devinfo);
static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *prefix,
				int status);

/*
 * This driver needs its own workqueue, as we need to control memory allocation.
 *
 * In the course of error handling and power management uas_wait_for_pending_cmnds()
 * needs to flush pending work items. In these contexts we cannot allocate memory
 * by doing block IO as we would deadlock. For the same reason we cannot wait
 * for anything allocating memory not heeding these constraints.
 *
 * So we have to control all work items that can be on the workqueue we flush.
 * Hence we cannot share a queue and need our own.
 */
static struct workqueue_struct *workqueue;

static void uas_do_work(struct work_struct *work)
{}

static void uas_scan_work(struct work_struct *work)
{}

static void uas_add_work(struct scsi_cmnd *cmnd)
{}

static void uas_zap_pending(struct uas_dev_info *devinfo, int result)
{}

static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd)
{}

static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *prefix,
			      int status)
{}

static void uas_free_unsubmitted_urbs(struct scsi_cmnd *cmnd)
{}

static int uas_try_complete(struct scsi_cmnd *cmnd, const char *caller)
{}

static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd,
			  unsigned direction)
{}

static bool uas_evaluate_response_iu(struct response_iu *riu, struct scsi_cmnd *cmnd)
{}

static void uas_stat_cmplt(struct urb *urb)
{}

static void uas_data_cmplt(struct urb *urb)
{}

static void uas_cmd_cmplt(struct urb *urb)
{}

static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
				      struct scsi_cmnd *cmnd,
				      enum dma_data_direction dir)
{}

static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp,
				       struct scsi_cmnd *cmnd)
{}

static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp,
					struct scsi_cmnd *cmnd)
{}

/*
 * Why should I request the Status IU before sending the Command IU?  Spec
 * says to, but also says the device may receive them in any order.  Seems
 * daft to me.
 */

static int uas_submit_sense_urb(struct scsi_cmnd *cmnd, gfp_t gfp)
{}

static int uas_submit_urbs(struct scsi_cmnd *cmnd,
			   struct uas_dev_info *devinfo)
{}

static int uas_queuecommand_lck(struct scsi_cmnd *cmnd)
{}

static DEF_SCSI_QCMD(uas_queuecommand)

/*
 * For now we do not support actually sending an abort to the device, so
 * this eh always fails. Still we must define it to make sure that we've
 * dropped all references to the cmnd in question once this function exits.
 */
static int uas_eh_abort_handler(struct scsi_cmnd *cmnd)
{}

static int uas_eh_device_reset_handler(struct scsi_cmnd *cmnd)
{}

static int uas_target_alloc(struct scsi_target *starget)
{}

static int uas_slave_alloc(struct scsi_device *sdev)
{}

static int uas_device_configure(struct scsi_device *sdev,
		struct queue_limits *lim)
{}

static const struct scsi_host_template uas_host_template =;

#define UNUSUAL_DEV

static struct usb_device_id uas_usb_ids[] =;
MODULE_DEVICE_TABLE(usb, uas_usb_ids);

#undef UNUSUAL_DEV

static int uas_switch_interface(struct usb_device *udev,
				struct usb_interface *intf)
{}

static int uas_configure_endpoints(struct uas_dev_info *devinfo)
{}

static void uas_free_streams(struct uas_dev_info *devinfo)
{}

static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
{}

static int uas_cmnd_list_empty(struct uas_dev_info *devinfo)
{}

/*
 * Wait for any pending cmnds to complete, on usb-2 sense_urbs may temporarily
 * get empty while there still is more work to do due to sense-urbs completing
 * with a READ/WRITE_READY iu code, so keep waiting until the list gets empty.
 */
static int uas_wait_for_pending_cmnds(struct uas_dev_info *devinfo)
{}

static int uas_pre_reset(struct usb_interface *intf)
{}

static int uas_post_reset(struct usb_interface *intf)
{}

static int uas_suspend(struct usb_interface *intf, pm_message_t message)
{}

static int uas_resume(struct usb_interface *intf)
{}

static int uas_reset_resume(struct usb_interface *intf)
{}

static void uas_disconnect(struct usb_interface *intf)
{}

/*
 * Put the device back in usb-storage mode on shutdown, as some BIOS-es
 * hang on reboot when the device is still in uas mode. Note the reset is
 * necessary as some devices won't revert to usb-storage mode without it.
 */
static void uas_shutdown(struct usb_interface *intf)
{}

static struct usb_driver uas_driver =;

static int __init uas_init(void)
{}

static void __exit uas_exit(void)
{}

module_init();
module_exit(uas_exit);

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