123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
#ifndef __SNIC_FWINT_H
#define __SNIC_FWINT_H
#define SNIC_CDB_LEN 32 /* SCSI CDB size 32, can be used for 16 bytes */
#define LUN_ADDR_LEN 8
enum snic_io_type {
SNIC_REQ_REPORT_TGTS = 0x2,
SNIC_REQ_ICMND,
SNIC_REQ_ITMF,
SNIC_REQ_HBA_RESET,
SNIC_REQ_EXCH_VER,
SNIC_REQ_TGT_INFO,
SNIC_REQ_BOOT_LUNS,
SNIC_RSP_REPORT_TGTS_CMPL = 0x12,
SNIC_RSP_ICMND_CMPL,
SNIC_RSP_ITMF_CMPL,
SNIC_RSP_HBA_RESET_CMPL,
SNIC_RSP_EXCH_VER_CMPL,
SNIC_RSP_BOOT_LUNS_CMPL,
SNIC_MSG_ACK = 0x80,
SNIC_MSG_ASYNC_EVNOTIFY,
};
enum snic_io_status {
SNIC_STAT_IO_SUCCESS = 0,
SNIC_STAT_INVALID_HDR,
SNIC_STAT_OUT_OF_RES,
SNIC_STAT_INVALID_PARM,
SNIC_STAT_REQ_NOT_SUP,
SNIC_STAT_IO_NOT_FOUND,
SNIC_STAT_ABORTED,
SNIC_STAT_TIMEOUT,
SNIC_STAT_SGL_INVALID,
SNIC_STAT_DATA_CNT_MISMATCH,
SNIC_STAT_FW_ERR,
SNIC_STAT_ITMF_REJECT,
SNIC_STAT_ITMF_FAIL,
SNIC_STAT_ITMF_INCORRECT_LUN,
SNIC_STAT_CMND_REJECT,
SNIC_STAT_DEV_OFFLINE,
SNIC_STAT_NO_BOOTLUN,
SNIC_STAT_SCSI_ERR,
SNIC_STAT_NOT_READY,
SNIC_STAT_FATAL_ERROR,
};
struct snic_io_hdr {
__le32 hid;
__le32 cmnd_id;
ulong init_ctx;
u8 type;
u8 status;
u8 protocol;
u8 flags;
__le16 sg_cnt;
u16 resvd;
};
static inline void
snic_io_hdr_enc(struct snic_io_hdr *hdr, u8 typ, u8 status, u32 id, u32 hid,
u16 sg_cnt, ulong ctx)
{
hdr->type = typ;
hdr->status = status;
hdr->protocol = 0;
hdr->hid = cpu_to_le32(hid);
hdr->cmnd_id = cpu_to_le32(id);
hdr->sg_cnt = cpu_to_le16(sg_cnt);
hdr->init_ctx = ctx;
hdr->flags = 0;
}
static inline void
snic_io_hdr_dec(struct snic_io_hdr *hdr, u8 *typ, u8 *stat, u32 *cmnd_id,
u32 *hid, ulong *ctx)
{
*typ = hdr->type;
*stat = hdr->status;
*hid = le32_to_cpu(hdr->hid);
*cmnd_id = le32_to_cpu(hdr->cmnd_id);
*ctx = hdr->init_ctx;
}
struct snic_exch_ver_req {
__le32 drvr_ver;
__le32 os_type;
};
#define SNIC_OS_LINUX 0x1
#define SNIC_OS_WIN 0x2
#define SNIC_OS_ESX 0x3
#define SNIC_HBA_CAP_DDL 0x02 /* Supports Dynamic Discovery of LUNs */
#define SNIC_HBA_CAP_AEN 0x04 /* Supports Async Event Noitifcation */
#define SNIC_HBA_CAP_TMO 0x08 /* Supports IO timeout in FW */
struct snic_exch_ver_rsp {
__le32 version;
__le32 hid;
__le32 max_concur_ios;
__le32 max_sgs_per_cmd;
__le32 max_io_sz;
__le32 hba_cap;
__le32 max_tgts;
__le16 io_timeout;
u16 rsvd;
};
struct snic_report_tgts {
__le16 sg_cnt;
__le16 flags;
u8 _resvd[4];
__le64 sg_addr;
__le64 sense_addr;
};
enum snic_type {
SNIC_NONE = 0x0,
SNIC_DAS,
SNIC_SAN,
};
enum snic_tgt_type {
SNIC_TGT_NONE = 0x0,
SNIC_TGT_DAS,
SNIC_TGT_SAN,
};
struct snic_tgt_id {
__le32 tgt_id;
__le16 tgt_type;
__le16 vnic_id;
};
struct snic_report_tgts_cmpl {
__le32 tgt_cnt;
u32 _resvd;
};
#define SNIC_ICMND_WR 0x01 /* write command */
#define SNIC_ICMND_RD 0x02 /* read command */
#define SNIC_ICMND_ESGL 0x04 /* SGE/ESGE array contains valid data*/
#define SNIC_ICMND_TSK_SHIFT 2 /* task attr starts at bit 2 */
#define SNIC_ICMND_TSK_MASK(x) ((x>>SNIC_ICMND_TSK_SHIFT) & ~(0xffff))
#define SNIC_ICMND_TSK_SIMPLE 0 /* simple task attr */
#define SNIC_ICMND_TSK_HEAD_OF_QUEUE 1 /* head of qeuue task attr */
#define SNIC_ICMND_TSK_ORDERED 2 /* ordered task attr */
#define SNIC_ICMND_PRI_SHIFT 5 /* prio val starts at bit 5 */
struct snic_icmnd {
__le16 sg_cnt;
__le16 flags;
__le32 sense_len;
__le64 tgt_id;
__le64 lun_id;
u8 cdb_len;
u8 _resvd;
__le16 time_out;
__le32 data_len;
u8 cdb[SNIC_CDB_LEN];
__le64 sg_addr;
__le64 sense_addr;
};
#define SNIC_ICMND_CMPL_UNDR_RUN 0x01 /* resid under and valid */
#define SNIC_ICMND_CMPL_OVER_RUN 0x02 /* resid over and valid */
struct snic_icmnd_cmpl {
u8 scsi_status;
u8 flags;
__le16 sense_len;
__le32 resid;
};
struct snic_itmf {
u8 tm_type;
u8 resvd;
__le16 flags;
__le32 req_id;
__le64 tgt_id;
__le64 lun_id;
__le16 timeout;
};
enum snic_itmf_tm_type {
SNIC_ITMF_ABTS_TASK = 0x01,
SNIC_ITMF_ABTS_TASK_SET,
SNIC_ITMF_CLR_TASK,
SNIC_ITMF_CLR_TASKSET,
SNIC_ITMF_LUN_RESET,
SNIC_ITMF_ABTS_TASK_TERM,
};
struct snic_itmf_cmpl {
__le32 nterminated;
u8 flags;
u8 _resvd[3];
};
#define SNIC_NUM_TERM_VALID 0x01 /* Number of IOs terminated */
struct snic_hba_reset {
__le16 flags;
u8 _resvd[6];
};
struct snic_hba_reset_cmpl {
u8 flags;
u8 _resvd[7];
};
struct snic_notify_msg {
__le32 wqe_num;
u8 flags;
u8 _resvd[4];
};
#define SNIC_EVDATA_LEN 24 /* in bytes */
struct snic_async_evnotify {
u8 FLS_EVENT_DESC;
u8 vnic;
u8 _resvd[2];
__le32 ev_id;
u8 ev_data[SNIC_EVDATA_LEN];
u8 _resvd2[4];
};
enum snic_ev_type {
SNIC_EV_TGT_OFFLINE = 0x01,
SNIC_EV_TGT_ONLINE,
SNIC_EV_LUN_OFFLINE,
SNIC_EV_LUN_ONLINE,
SNIC_EV_CONF_CHG,
SNIC_EV_TGT_ADDED,
SNIC_EV_TGT_DELTD,
SNIC_EV_LUN_ADDED,
SNIC_EV_LUN_DELTD,
SNIC_EV_DISC_CMPL = 0x10,
};
#define SNIC_HOST_REQ_LEN 128 /*Exp length of host req, wq desc sz*/
#define SNIC_HOST_REQ_PAYLOAD ((int)(SNIC_HOST_REQ_LEN - \
sizeof(struct snic_io_hdr) - \
(2 * sizeof(u64)) - sizeof(ulong)))
struct snic_host_req {
u64 ctrl_data[2];
struct snic_io_hdr hdr;
union {
u8 buf[SNIC_HOST_REQ_PAYLOAD];
struct snic_exch_ver_req exch_ver;
struct snic_report_tgts rpt_tgts;
struct snic_icmnd icmnd;
struct snic_itmf itmf;
struct snic_hba_reset reset;
} u;
ulong req_pa;
};
#define SNIC_FW_REQ_LEN 64 /* Expected length of fw req */
struct snic_fw_req {
struct snic_io_hdr hdr;
union {
u8 buf[SNIC_FW_REQ_LEN - sizeof(struct snic_io_hdr)];
struct snic_exch_ver_rsp exch_ver_cmpl;
struct snic_report_tgts_cmpl rpt_tgts_cmpl;
struct snic_icmnd_cmpl icmnd_cmpl;
struct snic_itmf_cmpl itmf_cmpl;
struct snic_hba_reset_cmpl reset_cmpl;
struct snic_notify_msg ack;
struct snic_async_evnotify async_ev;
} u;
};
#define VERIFY_REQ_SZ(x)
#define VERIFY_CMPL_SZ(x)
static inline void
snic_color_enc(struct snic_fw_req *req, u8 color)
{
u8 *c = ((u8 *) req) + sizeof(struct snic_fw_req) - 1;
if (color)
*c |= 0x80;
else
*c &= ~0x80;
}
static inline void
snic_color_dec(struct snic_fw_req *req, u8 *color)
{
u8 *c = ((u8 *) req) + sizeof(struct snic_fw_req) - 1;
*color = *c >> 7;
rmb();
}
#endif /* end of __SNIC_FWINT_H */