123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
#ifndef __MTIP32XX_H__
#define __MTIP32XX_H__
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include <linux/rwsem.h>
#include <linux/ata.h>
#include <linux/interrupt.h>
#define PCI_SUBSYSTEM_DEVICEID 0x2E
#define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48
#define MTIP_SEC_ERASE_MODE 0x2
#define MTIP_MAX_RETRIES 2
#define MTIP_NCQ_CMD_TIMEOUT_MS 15000
#define MTIP_IOCTL_CMD_TIMEOUT_MS 5000
#define MTIP_INT_CMD_TIMEOUT_MS 5000
#define MTIP_QUIESCE_IO_TIMEOUT_MS (MTIP_NCQ_CMD_TIMEOUT_MS * \
(MTIP_MAX_RETRIES + 1))
#define MTIP_TIMEOUT_CHECK_PERIOD 500
#define MTIP_FTL_REBUILD_OFFSET 142
#define MTIP_FTL_REBUILD_MAGIC 0xED51
#define MTIP_FTL_REBUILD_TIMEOUT_MS 2400000
#define MTIP_MAX_UNALIGNED_SLOTS 2
#define MTIP_TAG_BIT(tag) (tag & 0x1F)
#define MTIP_TAG_INDEX(tag) (tag >> 5)
#define MTIP_MAX_SG 504
#define MTIP_MAX_SLOT_GROUPS 8
#define MTIP_TAG_INTERNAL 0
#define PCI_VENDOR_ID_MICRON 0x1344
#define P320H_DEVICE_ID 0x5150
#define P320M_DEVICE_ID 0x5151
#define P320S_DEVICE_ID 0x5152
#define P325M_DEVICE_ID 0x5153
#define P420H_DEVICE_ID 0x5160
#define P420M_DEVICE_ID 0x5161
#define P425M_DEVICE_ID 0x5163
#define MTIP_DRV_NAME "mtip32xx"
#define MTIP_DRV_VERSION "1.3.1"
#define MTIP_MAX_MINORS 16
#define MTIP_MAX_COMMAND_SLOTS (MTIP_MAX_SLOT_GROUPS * 32)
#define U32_PER_LONG (sizeof(long) / sizeof(u32))
#define SLOTBITS_IN_LONGS ((MTIP_MAX_SLOT_GROUPS + \
(U32_PER_LONG-1))/U32_PER_LONG)
#define MTIP_ABAR 5
#ifdef DEBUG
#define dbg_printk(format, arg...) \
printk(pr_fmt(format), ##arg);
#else
#define dbg_printk(format, arg...)
#endif
#define MTIP_DFS_MAX_BUF_SIZE 1024
enum {
MTIP_PF_IC_ACTIVE_BIT = 0,
MTIP_PF_EH_ACTIVE_BIT = 1,
MTIP_PF_SE_ACTIVE_BIT = 2,
MTIP_PF_DM_ACTIVE_BIT = 3,
MTIP_PF_TO_ACTIVE_BIT = 9,
MTIP_PF_PAUSE_IO = ((1 << MTIP_PF_IC_ACTIVE_BIT) |
(1 << MTIP_PF_EH_ACTIVE_BIT) |
(1 << MTIP_PF_SE_ACTIVE_BIT) |
(1 << MTIP_PF_DM_ACTIVE_BIT) |
(1 << MTIP_PF_TO_ACTIVE_BIT)),
MTIP_PF_HOST_CAP_64 = 10,
MTIP_PF_SVC_THD_ACTIVE_BIT = 4,
MTIP_PF_ISSUE_CMDS_BIT = 5,
MTIP_PF_REBUILD_BIT = 6,
MTIP_PF_SVC_THD_STOP_BIT = 8,
MTIP_PF_SVC_THD_WORK = ((1 << MTIP_PF_EH_ACTIVE_BIT) |
(1 << MTIP_PF_ISSUE_CMDS_BIT) |
(1 << MTIP_PF_REBUILD_BIT) |
(1 << MTIP_PF_SVC_THD_STOP_BIT) |
(1 << MTIP_PF_TO_ACTIVE_BIT)),
MTIP_DDF_SEC_LOCK_BIT = 0,
MTIP_DDF_REMOVE_PENDING_BIT = 1,
MTIP_DDF_OVER_TEMP_BIT = 2,
MTIP_DDF_WRITE_PROTECT_BIT = 3,
MTIP_DDF_CLEANUP_BIT = 5,
MTIP_DDF_RESUME_BIT = 6,
MTIP_DDF_INIT_DONE_BIT = 7,
MTIP_DDF_REBUILD_FAILED_BIT = 8,
MTIP_DDF_STOP_IO = ((1 << MTIP_DDF_REMOVE_PENDING_BIT) |
(1 << MTIP_DDF_SEC_LOCK_BIT) |
(1 << MTIP_DDF_OVER_TEMP_BIT) |
(1 << MTIP_DDF_WRITE_PROTECT_BIT) |
(1 << MTIP_DDF_REBUILD_FAILED_BIT)),
};
struct smart_attr {
u8 attr_id;
__le16 flags;
u8 cur;
u8 worst;
__le32 data;
u8 res[3];
} __packed;
struct mtip_work {
struct work_struct work;
void *port;
int cpu_binding;
u32 completed;
} ____cacheline_aligned_in_smp;
#define DEFINE_HANDLER(group) \
void mtip_workq_sdbf##group(struct work_struct *work) \
{ \
struct mtip_work *w = (struct mtip_work *) work; \
mtip_workq_sdbfx(w->port, group, w->completed); \
}
struct host_to_dev_fis {
unsigned char type;
unsigned char opts;
unsigned char command;
unsigned char features;
union {
unsigned char lba_low;
unsigned char sector;
};
union {
unsigned char lba_mid;
unsigned char cyl_low;
};
union {
unsigned char lba_hi;
unsigned char cyl_hi;
};
union {
unsigned char device;
unsigned char head;
};
union {
unsigned char lba_low_ex;
unsigned char sector_ex;
};
union {
unsigned char lba_mid_ex;
unsigned char cyl_low_ex;
};
union {
unsigned char lba_hi_ex;
unsigned char cyl_hi_ex;
};
unsigned char features_ex;
unsigned char sect_count;
unsigned char sect_cnt_ex;
unsigned char res2;
unsigned char control;
unsigned int res3;
};
struct mtip_cmd_hdr {
__le32 opts;
union {
__le32 byte_count;
__le32 status;
};
__le32 ctba;
__le32 ctbau;
u32 res[4];
};
struct mtip_cmd_sg {
__le32 dba;
__le32 dba_upper;
__le32 reserved;
__le32 info;
};
struct mtip_port;
struct mtip_int_cmd;
struct mtip_cmd {
void *command;
dma_addr_t command_dma;
int scatter_ents;
int unaligned;
union {
struct scatterlist sg[MTIP_MAX_SG];
struct mtip_int_cmd *icmd;
};
int retries;
int direction;
blk_status_t status;
};
struct mtip_port {
struct driver_data *dd;
unsigned long identify_valid;
void __iomem *mmio;
void __iomem *s_active[MTIP_MAX_SLOT_GROUPS];
void __iomem *completed[MTIP_MAX_SLOT_GROUPS];
void __iomem *cmd_issue[MTIP_MAX_SLOT_GROUPS];
void *command_list;
dma_addr_t command_list_dma;
void *rxfis;
dma_addr_t rxfis_dma;
void *block1;
dma_addr_t block1_dma;
u16 *identify;
dma_addr_t identify_dma;
u16 *sector_buffer;
dma_addr_t sector_buffer_dma;
u16 *log_buf;
dma_addr_t log_buf_dma;
u8 *smart_buf;
dma_addr_t smart_buf_dma;
unsigned long cmds_to_issue[SLOTBITS_IN_LONGS];
wait_queue_head_t svc_wait;
unsigned long flags;
unsigned long ic_pause_timer;
atomic_t cmd_slot_unal;
spinlock_t cmd_issue_lock[MTIP_MAX_SLOT_GROUPS];
};
struct driver_data {
void __iomem *mmio;
int major;
int instance;
struct gendisk *disk;
struct pci_dev *pdev;
struct request_queue *queue;
struct blk_mq_tag_set tags;
struct mutex ioctl_mutex;
struct mtip_port *port;
unsigned product_type;
unsigned slot_groups;
unsigned long index;
unsigned long dd_flag;
struct task_struct *mtip_svc_handler;
struct dentry *dfs_node;
bool sr;
int numa_node;
char workq_name[32];
struct workqueue_struct *isr_workq;
atomic_t irq_workers_active;
struct mtip_work work[MTIP_MAX_SLOT_GROUPS];
int isr_binding;
int unal_qdepth;
};
#endif