18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * QLogic Fibre Channel HBA Driver 48c2ecf20Sopenharmony_ci * Copyright (c) 2003-2017 QLogic Corporation 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef __QLA_NVME_H 78c2ecf20Sopenharmony_ci#define __QLA_NVME_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <uapi/scsi/fc/fc_fs.h> 108c2ecf20Sopenharmony_ci#include <uapi/scsi/fc/fc_els.h> 118c2ecf20Sopenharmony_ci#include <linux/nvme-fc-driver.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include "qla_def.h" 148c2ecf20Sopenharmony_ci#include "qla_dsd.h" 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define NVME_ATIO_CMD_OFF 32 178c2ecf20Sopenharmony_ci#define NVME_FIRST_PACKET_CMDLEN (64 - NVME_ATIO_CMD_OFF) 188c2ecf20Sopenharmony_ci#define Q2T_NVME_NUM_TAGS 2048 198c2ecf20Sopenharmony_ci#define QLA_MAX_FC_SEGMENTS 64 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistruct scsi_qla_host; 228c2ecf20Sopenharmony_cistruct qla_hw_data; 238c2ecf20Sopenharmony_cistruct req_que; 248c2ecf20Sopenharmony_cistruct srb; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistruct nvme_private { 278c2ecf20Sopenharmony_ci struct srb *sp; 288c2ecf20Sopenharmony_ci struct nvmefc_ls_req *fd; 298c2ecf20Sopenharmony_ci struct work_struct ls_work; 308c2ecf20Sopenharmony_ci struct work_struct abort_work; 318c2ecf20Sopenharmony_ci int comp_status; 328c2ecf20Sopenharmony_ci spinlock_t cmd_lock; 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct qla_nvme_rport { 368c2ecf20Sopenharmony_ci struct fc_port *fcport; 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define COMMAND_NVME 0x88 /* Command Type FC-NVMe IOCB */ 408c2ecf20Sopenharmony_cistruct cmd_nvme { 418c2ecf20Sopenharmony_ci uint8_t entry_type; /* Entry type. */ 428c2ecf20Sopenharmony_ci uint8_t entry_count; /* Entry count. */ 438c2ecf20Sopenharmony_ci uint8_t sys_define; /* System defined. */ 448c2ecf20Sopenharmony_ci uint8_t entry_status; /* Entry Status. */ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci uint32_t handle; /* System handle. */ 478c2ecf20Sopenharmony_ci __le16 nport_handle; /* N_PORT handle. */ 488c2ecf20Sopenharmony_ci __le16 timeout; /* Command timeout. */ 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci __le16 dseg_count; /* Data segment count. */ 518c2ecf20Sopenharmony_ci __le16 nvme_rsp_dsd_len; /* NVMe RSP DSD length */ 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci uint64_t rsvd; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci __le16 control_flags; /* Control Flags */ 568c2ecf20Sopenharmony_ci#define CF_ADMIN_ASYNC_EVENT BIT_13 578c2ecf20Sopenharmony_ci#define CF_NVME_FIRST_BURST_ENABLE BIT_11 588c2ecf20Sopenharmony_ci#define CF_DIF_SEG_DESCR_ENABLE BIT_3 598c2ecf20Sopenharmony_ci#define CF_DATA_SEG_DESCR_ENABLE BIT_2 608c2ecf20Sopenharmony_ci#define CF_READ_DATA BIT_1 618c2ecf20Sopenharmony_ci#define CF_WRITE_DATA BIT_0 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci __le16 nvme_cmnd_dseg_len; /* Data segment length. */ 648c2ecf20Sopenharmony_ci __le64 nvme_cmnd_dseg_address __packed;/* Data segment address. */ 658c2ecf20Sopenharmony_ci __le64 nvme_rsp_dseg_address __packed; /* Data segment address. */ 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci __le32 byte_count; /* Total byte count. */ 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci uint8_t port_id[3]; /* PortID of destination port. */ 708c2ecf20Sopenharmony_ci uint8_t vp_index; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci struct dsd64 nvme_dsd; 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define PT_LS4_REQUEST 0x89 /* Link Service pass-through IOCB (request) */ 768c2ecf20Sopenharmony_cistruct pt_ls4_request { 778c2ecf20Sopenharmony_ci uint8_t entry_type; 788c2ecf20Sopenharmony_ci uint8_t entry_count; 798c2ecf20Sopenharmony_ci uint8_t sys_define; 808c2ecf20Sopenharmony_ci uint8_t entry_status; 818c2ecf20Sopenharmony_ci uint32_t handle; 828c2ecf20Sopenharmony_ci __le16 status; 838c2ecf20Sopenharmony_ci __le16 nport_handle; 848c2ecf20Sopenharmony_ci __le16 tx_dseg_count; 858c2ecf20Sopenharmony_ci uint8_t vp_index; 868c2ecf20Sopenharmony_ci uint8_t rsvd; 878c2ecf20Sopenharmony_ci __le16 timeout; 888c2ecf20Sopenharmony_ci __le16 control_flags; 898c2ecf20Sopenharmony_ci#define CF_LS4_SHIFT 13 908c2ecf20Sopenharmony_ci#define CF_LS4_ORIGINATOR 0 918c2ecf20Sopenharmony_ci#define CF_LS4_RESPONDER 1 928c2ecf20Sopenharmony_ci#define CF_LS4_RESPONDER_TERM 2 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci __le16 rx_dseg_count; 958c2ecf20Sopenharmony_ci __le16 rsvd2; 968c2ecf20Sopenharmony_ci __le32 exchange_address; 978c2ecf20Sopenharmony_ci __le32 rsvd3; 988c2ecf20Sopenharmony_ci __le32 rx_byte_count; 998c2ecf20Sopenharmony_ci __le32 tx_byte_count; 1008c2ecf20Sopenharmony_ci struct dsd64 dsd[2]; 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#define PT_LS4_UNSOL 0x56 /* pass-up unsolicited rec FC-NVMe request */ 1048c2ecf20Sopenharmony_cistruct pt_ls4_rx_unsol { 1058c2ecf20Sopenharmony_ci uint8_t entry_type; 1068c2ecf20Sopenharmony_ci uint8_t entry_count; 1078c2ecf20Sopenharmony_ci __le16 rsvd0; 1088c2ecf20Sopenharmony_ci __le16 rsvd1; 1098c2ecf20Sopenharmony_ci uint8_t vp_index; 1108c2ecf20Sopenharmony_ci uint8_t rsvd2; 1118c2ecf20Sopenharmony_ci __le16 rsvd3; 1128c2ecf20Sopenharmony_ci __le16 nport_handle; 1138c2ecf20Sopenharmony_ci __le16 frame_size; 1148c2ecf20Sopenharmony_ci __le16 rsvd4; 1158c2ecf20Sopenharmony_ci __le32 exchange_address; 1168c2ecf20Sopenharmony_ci uint8_t d_id[3]; 1178c2ecf20Sopenharmony_ci uint8_t r_ctl; 1188c2ecf20Sopenharmony_ci be_id_t s_id; 1198c2ecf20Sopenharmony_ci uint8_t cs_ctl; 1208c2ecf20Sopenharmony_ci uint8_t f_ctl[3]; 1218c2ecf20Sopenharmony_ci uint8_t type; 1228c2ecf20Sopenharmony_ci __le16 seq_cnt; 1238c2ecf20Sopenharmony_ci uint8_t df_ctl; 1248c2ecf20Sopenharmony_ci uint8_t seq_id; 1258c2ecf20Sopenharmony_ci __le16 rx_id; 1268c2ecf20Sopenharmony_ci __le16 ox_id; 1278c2ecf20Sopenharmony_ci __le32 param; 1288c2ecf20Sopenharmony_ci __le32 desc0; 1298c2ecf20Sopenharmony_ci#define PT_LS4_PAYLOAD_OFFSET 0x2c 1308c2ecf20Sopenharmony_ci#define PT_LS4_FIRST_PACKET_LEN 20 1318c2ecf20Sopenharmony_ci __le32 desc_len; 1328c2ecf20Sopenharmony_ci __le32 payload[3]; 1338c2ecf20Sopenharmony_ci}; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci/* 1368c2ecf20Sopenharmony_ci * Global functions prototype in qla_nvme.c source file. 1378c2ecf20Sopenharmony_ci */ 1388c2ecf20Sopenharmony_ciint qla_nvme_register_hba(struct scsi_qla_host *); 1398c2ecf20Sopenharmony_ciint qla_nvme_register_remote(struct scsi_qla_host *, struct fc_port *); 1408c2ecf20Sopenharmony_civoid qla_nvme_delete(struct scsi_qla_host *); 1418c2ecf20Sopenharmony_civoid qla24xx_nvme_ls4_iocb(struct scsi_qla_host *, struct pt_ls4_request *, 1428c2ecf20Sopenharmony_ci struct req_que *); 1438c2ecf20Sopenharmony_civoid qla24xx_async_gffid_sp_done(struct srb *sp, int); 1448c2ecf20Sopenharmony_ci#endif 145