/*
* @file hv_drv_UsbStorageTransport.h
* @brief Header file of usb storage transport.
*
* @author HiView SoC Software Team
* @version 1.0.0
* @date 2022-06-15
*/

#ifndef __HV_DRV_USB_STORAGE_TRANSPORT_H
#define __HV_DRV_USB_STORAGE_TRANSPORT_H

#include "hv_drv_UsbStorageCommonScsi.h"
#include "hv_drv_UsbStorageUmass.h"

#define US_CBI_ADSC        0

/* Flag definitions: these entries are static */
#define US_FL_SINGLE_LUN      0x00000001 /* allow access to only LUN 0      */
#define US_FL_MODE_XLATE      0          /* [no longer used]                */
#define US_FL_NEED_OVERRIDE   0x00000004 /* unusual_devs entry is necessary */
#define US_FL_IGNORE_SER      0          /* [no longer used]                */
#define US_FL_SCM_MULT_TARG   0x00000020 /* supports multiple targets       */
#define US_FL_FIX_INQUIRY     0x00000040 /* INQUIRY response needs faking   */
#define US_FL_FIX_CAPACITY    0x00000080 /* READ CAPACITY response too big  */
#define US_FL_IGNORE_RESIDUE  0x00000100 /* reported residue is wrong       */
#define US_FL_BULK32          0x00000200 /* Uses 32-byte CBW length         */
#define US_FL_GO_SLOW         0x00000400
#define US_FL_INITIAL_READ10  0x00000800
#define US_FL_SANE_SENSE      0x00001000
#define US_FL_BAD_SENSE       0x00002000
#define US_FL_BULK_IGNORE_TAG 0x0004000

/*
 * usb_stor_bulk_transfer_xxx() return codes, in order of severity
 */
#define USB_STOR_XFER_GOOD      0    /* good transfer                 */
#define USB_STOR_XFER_SHORT     1    /* transferred less than expected */
#define USB_STOR_XFER_STALLED   2    /* endpoint stalled              */
#define USB_STOR_XFER_LONG      3    /* device tried to send too much */
#define USB_STOR_XFER_ERROR     4    /* transfer died in the middle   */


/*
 * Transport return codes
 */
#define USB_STOR_TRANSPORT_GOOD     0   /* Transport good, command good       */
#define USB_STOR_TRANSPORT_FAILED   1   /* Transport good, command failed   */
#define USB_STOR_TRANSPORT_NO_SENSE 2   /* Command failed, no auto-sense    */
#define USB_STOR_TRANSPORT_ERROR    3   /* Transport bad (i.e. device dead) */

extern int usb_stor_bulk_transport(struct scsi_cmnd *srb, struct us_data *us);
extern int usb_stor_bulk_reset(struct us_data *us);
extern int usb_stor_bulk_max_lun(struct us_data *us);
extern void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us);
#endif
