]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - drivers/scsi/qla2xxx/qla_def.h
scsi: qla2xxx: Convert MAKE_HANDLE() from a define into an inline function
[mirror_ubuntu-hirsute-kernel.git] / drivers / scsi / qla2xxx / qla_def.h
index 22f859bef778d962ddc0ed879b98bbae4b880763..4d07c6e902feff048341dce0910aa6b1c1d8931b 100644 (file)
@@ -119,7 +119,10 @@ typedef struct {
 #define LSD(x) ((uint32_t)((uint64_t)(x)))
 #define MSD(x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16))
 
-#define MAKE_HANDLE(x, y) ((uint32_t)((((uint32_t)(x)) << 16) | (uint32_t)(y)))
+static inline uint32_t make_handle(uint16_t x, uint16_t y)
+{
+       return ((uint32_t)x << 16) | y;
+}
 
 /*
  * I/O register
@@ -414,7 +417,7 @@ struct els_logo_payload {
 struct els_plogi_payload {
        uint8_t opcode;
        uint8_t rsvd[3];
-       uint8_t data[112];
+       __be32  data[112 / 4];
 };
 
 struct ct_arg {
@@ -597,9 +600,6 @@ typedef struct srb {
        struct fc_port *fcport;
        struct scsi_qla_host *vha;
        unsigned int start_timer:1;
-       unsigned int abort:1;
-       unsigned int aborted:1;
-       unsigned int completed:1;
 
        uint32_t handle;
        uint16_t flags;
@@ -1261,10 +1261,15 @@ static inline bool qla2xxx_is_valid_mbs(unsigned int mbs)
 #define        MBX_1           BIT_1
 #define        MBX_0           BIT_0
 
+#define RNID_TYPE_ELS_CMD      0x5
 #define RNID_TYPE_PORT_LOGIN   0x7
+#define RNID_BUFFER_CREDITS    0x8
 #define RNID_TYPE_SET_VERSION  0x9
 #define RNID_TYPE_ASIC_TEMP    0xC
 
+#define ELS_CMD_MAP_SIZE       32
+#define ELS_COMMAND_RDP                0x18
+
 /*
  * Firmware state codes from get firmware state mailbox command
  */
@@ -1475,47 +1480,44 @@ typedef struct {
 #define GLSO_USE_DID   BIT_3
 
 struct link_statistics {
-       uint32_t link_fail_cnt;
-       uint32_t loss_sync_cnt;
-       uint32_t loss_sig_cnt;
-       uint32_t prim_seq_err_cnt;
-       uint32_t inval_xmit_word_cnt;
-       uint32_t inval_crc_cnt;
-       uint32_t lip_cnt;
-       uint32_t link_up_cnt;
-       uint32_t link_down_loop_init_tmo;
-       uint32_t link_down_los;
-       uint32_t link_down_loss_rcv_clk;
+       __le32 link_fail_cnt;
+       __le32 loss_sync_cnt;
+       __le32 loss_sig_cnt;
+       __le32 prim_seq_err_cnt;
+       __le32 inval_xmit_word_cnt;
+       __le32 inval_crc_cnt;
+       __le32 lip_cnt;
+       __le32 link_up_cnt;
+       __le32 link_down_loop_init_tmo;
+       __le32 link_down_los;
+       __le32 link_down_loss_rcv_clk;
        uint32_t reserved0[5];
-       uint32_t port_cfg_chg;
+       __le32 port_cfg_chg;
        uint32_t reserved1[11];
-       uint32_t rsp_q_full;
-       uint32_t atio_q_full;
-       uint32_t drop_ae;
-       uint32_t els_proto_err;
-       uint32_t reserved2;
-       uint32_t tx_frames;
-       uint32_t rx_frames;
-       uint32_t discarded_frames;
-       uint32_t dropped_frames;
+       __le32 rsp_q_full;
+       __le32 atio_q_full;
+       __le32 drop_ae;
+       __le32 els_proto_err;
+       __le32 reserved2;
+       __le32 tx_frames;
+       __le32 rx_frames;
+       __le32 discarded_frames;
+       __le32 dropped_frames;
        uint32_t reserved3;
-       uint32_t nos_rcvd;
+       __le32 nos_rcvd;
        uint32_t reserved4[4];
-       uint32_t tx_prjt;
-       uint32_t rcv_exfail;
-       uint32_t rcv_abts;
-       uint32_t seq_frm_miss;
-       uint32_t corr_err;
-       uint32_t mb_rqst;
-       uint32_t nport_full;
-       uint32_t eofa;
+       __le32 tx_prjt;
+       __le32 rcv_exfail;
+       __le32 rcv_abts;
+       __le32 seq_frm_miss;
+       __le32 corr_err;
+       __le32 mb_rqst;
+       __le32 nport_full;
+       __le32 eofa;
        uint32_t reserved5;
-       uint32_t fpm_recv_word_cnt_lo;
-       uint32_t fpm_recv_word_cnt_hi;
-       uint32_t fpm_disc_word_cnt_lo;
-       uint32_t fpm_disc_word_cnt_hi;
-       uint32_t fpm_xmit_word_cnt_lo;
-       uint32_t fpm_xmit_word_cnt_hi;
+       __le64 fpm_recv_word_cnt;
+       __le64 fpm_disc_word_cnt;
+       __le64 fpm_xmit_word_cnt;
        uint32_t reserved6[70];
 };
 
@@ -2625,10 +2627,11 @@ static const char * const port_dstate_str[] = {
 #define GFF_ID_RSP_SIZE (16 + 128)
 
 /*
- * HBA attribute types.
+ * FDMI HBA attribute types.
  */
-#define FDMI_HBA_ATTR_COUNT                    9
-#define FDMIV2_HBA_ATTR_COUNT                  17
+#define FDMI1_HBA_ATTR_COUNT                   9
+#define FDMI2_HBA_ATTR_COUNT                   17
+
 #define FDMI_HBA_NODE_NAME                     0x1
 #define FDMI_HBA_MANUFACTURER                  0x2
 #define FDMI_HBA_SERIAL_NUMBER                 0x3
@@ -2640,12 +2643,13 @@ static const char * const port_dstate_str[] = {
 #define FDMI_HBA_FIRMWARE_VERSION              0x9
 #define FDMI_HBA_OS_NAME_AND_VERSION           0xa
 #define FDMI_HBA_MAXIMUM_CT_PAYLOAD_LENGTH     0xb
+
 #define FDMI_HBA_NODE_SYMBOLIC_NAME            0xc
-#define FDMI_HBA_VENDOR_ID                     0xd
+#define FDMI_HBA_VENDOR_SPECIFIC_INFO          0xd
 #define FDMI_HBA_NUM_PORTS                     0xe
 #define FDMI_HBA_FABRIC_NAME                   0xf
 #define FDMI_HBA_BOOT_BIOS_NAME                        0x10
-#define FDMI_HBA_TYPE_VENDOR_IDENTIFIER                0xe0
+#define FDMI_HBA_VENDOR_IDENTIFIER             0xe0
 
 struct ct_fdmi_hba_attr {
        uint16_t type;
@@ -2662,31 +2666,9 @@ struct ct_fdmi_hba_attr {
                uint8_t fw_version[32];
                uint8_t os_version[128];
                uint32_t max_ct_len;
-       } a;
-};
-
-struct ct_fdmi_hba_attributes {
-       uint32_t count;
-       struct ct_fdmi_hba_attr entry[FDMI_HBA_ATTR_COUNT];
-};
 
-struct ct_fdmiv2_hba_attr {
-       uint16_t type;
-       uint16_t len;
-       union {
-               uint8_t node_name[WWN_SIZE];
-               uint8_t manufacturer[64];
-               uint8_t serial_num[32];
-               uint8_t model[16+1];
-               uint8_t model_desc[80];
-               uint8_t hw_version[16];
-               uint8_t driver_version[32];
-               uint8_t orom_version[16];
-               uint8_t fw_version[32];
-               uint8_t os_version[128];
-               uint32_t max_ct_len;
                uint8_t sym_name[256];
-               uint32_t vendor_id;
+               uint32_t vendor_specific_info;
                uint32_t num_ports;
                uint8_t fabric_name[WWN_SIZE];
                uint8_t bios_name[32];
@@ -2694,22 +2676,30 @@ struct ct_fdmiv2_hba_attr {
        } a;
 };
 
-struct ct_fdmiv2_hba_attributes {
+struct ct_fdmi1_hba_attributes {
        uint32_t count;
-       struct ct_fdmiv2_hba_attr entry[FDMIV2_HBA_ATTR_COUNT];
+       struct ct_fdmi_hba_attr entry[FDMI1_HBA_ATTR_COUNT];
+};
+
+struct ct_fdmi2_hba_attributes {
+       uint32_t count;
+       struct ct_fdmi_hba_attr entry[FDMI2_HBA_ATTR_COUNT];
 };
 
 /*
- * Port attribute types.
+ * FDMI Port attribute types.
  */
-#define FDMI_PORT_ATTR_COUNT           6
-#define FDMIV2_PORT_ATTR_COUNT         16
+#define FDMI1_PORT_ATTR_COUNT          6
+#define FDMI2_PORT_ATTR_COUNT          16
+#define FDMI2_SMARTSAN_PORT_ATTR_COUNT 23
+
 #define FDMI_PORT_FC4_TYPES            0x1
 #define FDMI_PORT_SUPPORT_SPEED                0x2
 #define FDMI_PORT_CURRENT_SPEED                0x3
 #define FDMI_PORT_MAX_FRAME_SIZE       0x4
 #define FDMI_PORT_OS_DEVICE_NAME       0x5
 #define FDMI_PORT_HOST_NAME            0x6
+
 #define FDMI_PORT_NODE_NAME            0x7
 #define FDMI_PORT_NAME                 0x8
 #define FDMI_PORT_SYM_NAME             0x9
@@ -2719,7 +2709,15 @@ struct ct_fdmiv2_hba_attributes {
 #define FDMI_PORT_FC4_TYPE             0xd
 #define FDMI_PORT_STATE                        0x101
 #define FDMI_PORT_COUNT                        0x102
-#define FDMI_PORT_ID                   0x103
+#define FDMI_PORT_IDENTIFIER           0x103
+
+#define FDMI_SMARTSAN_SERVICE          0xF100
+#define FDMI_SMARTSAN_GUID             0xF101
+#define FDMI_SMARTSAN_VERSION          0xF102
+#define FDMI_SMARTSAN_PROD_NAME                0xF103
+#define FDMI_SMARTSAN_PORT_INFO                0xF104
+#define FDMI_SMARTSAN_QOS_SUPPORT      0xF105
+#define FDMI_SMARTSAN_SECURITY_SUPPORT 0xF106
 
 #define FDMI_PORT_SPEED_1GB            0x1
 #define FDMI_PORT_SPEED_2GB            0x2
@@ -2735,7 +2733,7 @@ struct ct_fdmiv2_hba_attributes {
 #define FC_CLASS_3     0x08
 #define FC_CLASS_2_3   0x0C
 
-struct ct_fdmiv2_port_attr {
+struct ct_fdmi_port_attr {
        uint16_t type;
        uint16_t len;
        union {
@@ -2745,6 +2743,7 @@ struct ct_fdmiv2_port_attr {
                uint32_t max_frame_size;
                uint8_t os_dev_name[32];
                uint8_t host_name[256];
+
                uint8_t node_name[WWN_SIZE];
                uint8_t port_name[WWN_SIZE];
                uint8_t port_sym_name[128];
@@ -2755,35 +2754,38 @@ struct ct_fdmiv2_port_attr {
                uint32_t port_state;
                uint32_t num_ports;
                uint32_t port_id;
+
+               uint8_t smartsan_service[24];
+               uint8_t smartsan_guid[16];
+               uint8_t smartsan_version[24];
+               uint8_t smartsan_prod_name[16];
+               uint32_t smartsan_port_info;
+               uint32_t smartsan_qos_support;
+               uint32_t smartsan_security_support;
        } a;
 };
 
-/*
- * Port Attribute Block.
- */
-struct ct_fdmiv2_port_attributes {
+struct ct_fdmi1_port_attributes {
        uint32_t count;
-       struct ct_fdmiv2_port_attr entry[FDMIV2_PORT_ATTR_COUNT];
-};
-
-struct ct_fdmi_port_attr {
-       uint16_t type;
-       uint16_t len;
-       union {
-               uint8_t fc4_types[32];
-               uint32_t sup_speed;
-               uint32_t cur_speed;
-               uint32_t max_frame_size;
-               uint8_t os_dev_name[32];
-               uint8_t host_name[256];
-       } a;
+       struct ct_fdmi_port_attr entry[FDMI1_PORT_ATTR_COUNT];
 };
 
-struct ct_fdmi_port_attributes {
+struct ct_fdmi2_port_attributes {
        uint32_t count;
-       struct ct_fdmi_port_attr entry[FDMI_PORT_ATTR_COUNT];
+       struct ct_fdmi_port_attr entry[FDMI2_PORT_ATTR_COUNT];
 };
 
+#define FDMI_ATTR_TYPELEN(obj) \
+       (sizeof((obj)->type) + sizeof((obj)->len))
+
+#define FDMI_ATTR_ALIGNMENT(len) \
+       (4 - ((len) & 3))
+
+/* FDMI register call options */
+#define CALLOPT_FDMI1          0
+#define CALLOPT_FDMI2          1
+#define CALLOPT_FDMI2_SMARTSAN 2
+
 /* FDMI definitions. */
 #define GRHL_CMD       0x100
 #define GHAT_CMD       0x101
@@ -2794,10 +2796,13 @@ struct ct_fdmi_port_attributes {
 #define RHBA_RSP_SIZE  16
 
 #define RHAT_CMD       0x201
+
 #define RPRT_CMD       0x210
+#define RPRT_RSP_SIZE  24
 
 #define RPA_CMD                0x211
 #define RPA_RSP_SIZE   16
+#define SMARTSAN_RPA_RSP_SIZE  24
 
 #define DHBA_CMD       0x300
 #define DHBA_REQ_SIZE  (16 + 8)
@@ -2880,30 +2885,24 @@ struct ct_sns_req {
                        uint8_t hba_identifier[8];
                        uint32_t entry_count;
                        uint8_t port_name[8];
-                       struct ct_fdmi_hba_attributes attrs;
+                       struct ct_fdmi2_hba_attributes attrs;
                } rhba;
 
                struct {
                        uint8_t hba_identifier[8];
-                       uint32_t entry_count;
-                       uint8_t port_name[8];
-                       struct ct_fdmiv2_hba_attributes attrs;
-               } rhba2;
-
-               struct {
-                       uint8_t hba_identifier[8];
-                       struct ct_fdmi_hba_attributes attrs;
+                       struct ct_fdmi1_hba_attributes attrs;
                } rhat;
 
                struct {
                        uint8_t port_name[8];
-                       struct ct_fdmi_port_attributes attrs;
+                       struct ct_fdmi2_port_attributes attrs;
                } rpa;
 
                struct {
+                       uint8_t hba_identifier[8];
                        uint8_t port_name[8];
-                       struct ct_fdmiv2_port_attributes attrs;
-               } rpa2;
+                       struct ct_fdmi2_port_attributes attrs;
+               } rprt;
 
                struct {
                        uint8_t port_name[8];
@@ -3017,7 +3016,7 @@ struct ct_sns_rsp {
                struct {
                        uint32_t entry_count;
                        uint8_t port_name[8];
-                       struct ct_fdmi_hba_attributes attrs;
+                       struct ct_fdmi1_hba_attributes attrs;
                } ghat;
 
                struct {
@@ -3563,6 +3562,134 @@ struct qlfc_fw {
        uint32_t len;
 };
 
+struct rdp_req_payload {
+       uint32_t        els_request;
+       uint32_t        desc_list_len;
+
+       /* NPIV descriptor */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint8_t  reserved;
+               uint8_t  nport_id[3];
+       } npiv_desc;
+};
+
+struct rdp_rsp_payload {
+       struct {
+               uint32_t cmd;
+               uint32_t len;
+       } hdr;
+
+       /* LS Request Info descriptor */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint32_t req_payload_word_0;
+       } ls_req_info_desc;
+
+       /* LS Request Info descriptor */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint32_t req_payload_word_0;
+       } ls_req_info_desc2;
+
+       /* SFP diagnostic param descriptor */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint16_t temperature;
+               uint16_t vcc;
+               uint16_t tx_bias;
+               uint16_t tx_power;
+               uint16_t rx_power;
+               uint16_t sfp_flags;
+       } sfp_diag_desc;
+
+       /* Port Speed Descriptor */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint16_t speed_capab;
+               uint16_t operating_speed;
+       } port_speed_desc;
+
+       /* Link Error Status Descriptor */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint32_t link_fail_cnt;
+               uint32_t loss_sync_cnt;
+               uint32_t loss_sig_cnt;
+               uint32_t prim_seq_err_cnt;
+               uint32_t inval_xmit_word_cnt;
+               uint32_t inval_crc_cnt;
+               uint8_t  pn_port_phy_type;
+               uint8_t  reserved[3];
+       } ls_err_desc;
+
+       /* Port name description with diag param */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint8_t WWNN[WWN_SIZE];
+               uint8_t WWPN[WWN_SIZE];
+       } port_name_diag_desc;
+
+       /* Port Name desc for Direct attached Fx_Port or Nx_Port */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint8_t WWNN[WWN_SIZE];
+               uint8_t WWPN[WWN_SIZE];
+       } port_name_direct_desc;
+
+       /* Buffer Credit descriptor */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint32_t fcport_b2b;
+               uint32_t attached_fcport_b2b;
+               uint32_t fcport_rtt;
+       } buffer_credit_desc;
+
+       /* Optical Element Data Descriptor */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint16_t high_alarm;
+               uint16_t low_alarm;
+               uint16_t high_warn;
+               uint16_t low_warn;
+               uint32_t element_flags;
+       } optical_elmt_desc[5];
+
+       /* Optical Product Data Descriptor */
+       struct {
+               uint32_t desc_tag;
+               uint32_t desc_len;
+               uint8_t  vendor_name[16];
+               uint8_t  part_number[16];
+               uint8_t  serial_number[16];
+               uint8_t  revision[4];
+               uint8_t  date[8];
+       } optical_prod_desc;
+};
+
+#define RDP_DESC_LEN(obj) \
+       (sizeof(obj) - sizeof((obj).desc_tag) - sizeof((obj).desc_len))
+
+#define RDP_PORT_SPEED_1GB             BIT_15
+#define RDP_PORT_SPEED_2GB             BIT_14
+#define RDP_PORT_SPEED_4GB             BIT_13
+#define RDP_PORT_SPEED_10GB            BIT_12
+#define RDP_PORT_SPEED_8GB             BIT_11
+#define RDP_PORT_SPEED_16GB            BIT_10
+#define RDP_PORT_SPEED_32GB            BIT_9
+#define RDP_PORT_SPEED_64GB             BIT_8
+#define RDP_PORT_SPEED_UNKNOWN         BIT_0
+
 struct scsi_qlt_host {
        void *target_lport_ptr;
        struct mutex tgt_mutex;
@@ -3966,6 +4093,8 @@ struct qla_hw_data {
 
 #define SFP_DEV_SIZE    512
 #define SFP_BLOCK_SIZE  64
+#define SFP_RTDI_LEN   SFP_BLOCK_SIZE
+
        void            *sfp_data;
        dma_addr_t      sfp_data_dma;
 
@@ -4345,6 +4474,15 @@ struct active_regions {
 #define QLA_SET_DATA_RATE_NOLR 1
 #define QLA_SET_DATA_RATE_LR   2 /* Set speed and initiate LR */
 
+struct purex_item {
+       struct list_head list;
+       struct scsi_qla_host *vha;
+       void (*process_item)(struct scsi_qla_host *vha, void *pkt);
+       struct {
+               uint8_t iocb[64];
+       } iocb;
+};
+
 /*
  * Qlogic scsi host structure
  */
@@ -4425,6 +4563,8 @@ typedef struct scsi_qla_host {
 #define ISP_ABORT_TO_ROM       33
 #define VPORT_DELETE           34
 
+#define PROCESS_PUREX_IOCB     63
+
        unsigned long   pci_flags;
 #define PFLG_DISCONNECTED      0       /* PCI device removed */
 #define PFLG_DRIVER_REMOVING   1       /* PCI driver .remove */
@@ -4462,6 +4602,7 @@ typedef struct scsi_qla_host {
        uint8_t         node_name[WWN_SIZE];
        uint8_t         port_name[WWN_SIZE];
        uint8_t         fabric_node_name[WWN_SIZE];
+       uint8_t         fabric_port_name[WWN_SIZE];
 
        struct          nvme_fc_local_port *nvme_local_port;
        struct completion nvme_del_done;
@@ -4532,6 +4673,11 @@ typedef struct scsi_qla_host {
        uint16_t ql2xexchoffld;
        uint16_t ql2xiniexchg;
 
+       struct purex_list {
+               struct list_head head;
+               spinlock_t lock;
+       } purex_list;
+
        struct name_list_extended gnl;
        /* Count of active session/fcport */
        int fcport_count;