Back to home page

OSCL-LXR

 
 

    


0001 /*******************************************************************
0002  * This file is part of the Emulex Linux Device Driver for         *
0003  * Fibre Channel Host Bus Adapters.                                *
0004  * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
0005  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
0006  * Copyright (C) 2010-2015 Emulex.  All rights reserved.           *
0007  * EMULEX and SLI are trademarks of Emulex.                        *
0008  * www.broadcom.com                                                *
0009  *                                                                 *
0010  * This program is free software; you can redistribute it and/or   *
0011  * modify it under the terms of version 2 of the GNU General       *
0012  * Public License as published by the Free Software Foundation.    *
0013  * This program is distributed in the hope that it will be useful. *
0014  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
0015  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
0016  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
0017  * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
0018  * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
0019  * more details, a copy of which can be found in the file COPYING  *
0020  * included with this package.                                     *
0021  *******************************************************************/
0022 /* bsg definitions
0023  * No pointers to user data are allowed, all application buffers and sizes will
0024  * derived through the bsg interface.
0025  *
0026  * These are the vendor unique structures passed in using the bsg
0027  * FC_BSG_HST_VENDOR message code type.
0028  */
0029 #define LPFC_BSG_VENDOR_SET_CT_EVENT        1
0030 #define LPFC_BSG_VENDOR_GET_CT_EVENT        2
0031 #define LPFC_BSG_VENDOR_SEND_MGMT_RESP      3
0032 #define LPFC_BSG_VENDOR_DIAG_MODE       4
0033 #define LPFC_BSG_VENDOR_DIAG_RUN_LOOPBACK   5
0034 #define LPFC_BSG_VENDOR_GET_MGMT_REV        6
0035 #define LPFC_BSG_VENDOR_MBOX            7
0036 #define LPFC_BSG_VENDOR_DIAG_MODE_END       10
0037 #define LPFC_BSG_VENDOR_LINK_DIAG_TEST      11
0038 #define LPFC_BSG_VENDOR_FORCED_LINK_SPEED   14
0039 #define LPFC_BSG_VENDOR_RAS_GET_LWPD        16
0040 #define LPFC_BSG_VENDOR_RAS_GET_FWLOG       17
0041 #define LPFC_BSG_VENDOR_RAS_GET_CONFIG      18
0042 #define LPFC_BSG_VENDOR_RAS_SET_CONFIG      19
0043 #define LPFC_BSG_VENDOR_GET_TRUNK_INFO      20
0044 #define LPFC_BSG_VENDOR_GET_CGNBUF_INFO     21
0045 
0046 struct set_ct_event {
0047     uint32_t command;
0048     uint32_t type_mask;
0049     uint32_t ev_req_id;
0050     uint32_t ev_reg_id;
0051 };
0052 
0053 struct get_ct_event {
0054     uint32_t command;
0055     uint32_t ev_reg_id;
0056     uint32_t ev_req_id;
0057 };
0058 
0059 struct get_ct_event_reply {
0060     uint32_t immed_data;
0061     uint32_t type;
0062 };
0063 
0064 struct send_mgmt_resp {
0065     uint32_t command;
0066     uint32_t tag;
0067 };
0068 
0069 
0070 #define DISABLE_LOOP_BACK  0x0 /* disables loop back */
0071 #define INTERNAL_LOOP_BACK 0x1 /* adapter short cuts the loop internally */
0072 #define EXTERNAL_LOOP_BACK 0x2 /* requires an external loopback plug */
0073 
0074 struct diag_mode_set {
0075     uint32_t command;
0076     uint32_t type;
0077     uint32_t timeout;
0078     uint32_t physical_link;
0079 };
0080 
0081 struct sli4_link_diag {
0082     uint32_t command;
0083     uint32_t timeout;
0084     uint32_t test_id;
0085     uint32_t loops;
0086     uint32_t test_version;
0087     uint32_t error_action;
0088 };
0089 
0090 struct diag_mode_test {
0091     uint32_t command;
0092 };
0093 
0094 struct diag_status {
0095     uint32_t mbox_status;
0096     uint32_t shdr_status;
0097     uint32_t shdr_add_status;
0098 };
0099 
0100 #define LPFC_WWNN_TYPE      0
0101 #define LPFC_WWPN_TYPE      1
0102 
0103 struct get_mgmt_rev {
0104     uint32_t command;
0105 };
0106 
0107 #define MANAGEMENT_MAJOR_REV   1
0108 #define MANAGEMENT_MINOR_REV   1
0109 
0110 /* the MgmtRevInfo structure */
0111 struct MgmtRevInfo {
0112     uint32_t a_Major;
0113     uint32_t a_Minor;
0114 };
0115 
0116 struct get_mgmt_rev_reply {
0117     struct MgmtRevInfo info;
0118 };
0119 
0120 #define BSG_MBOX_SIZE 4096 /* mailbox command plus extended data */
0121 
0122 /* BSG mailbox request header */
0123 struct dfc_mbox_req {
0124     uint32_t command;
0125     uint32_t mbOffset;
0126     uint32_t inExtWLen;
0127     uint32_t outExtWLen;
0128     uint32_t extMboxTag;
0129     uint32_t extSeqNum;
0130 };
0131 
0132 /*
0133  * macros and data structures for handling sli-config mailbox command
0134  * pass-through support, this header file is shared between user and
0135  * kernel spaces, note the set of macros are duplicates from lpfc_hw4.h,
0136  * with macro names prefixed with bsg_, as the macros defined in
0137  * lpfc_hw4.h are not accessible from user space.
0138  */
0139 
0140 /* Macros to deal with bit fields. Each bit field must have 3 #defines
0141  * associated with it (_SHIFT, _MASK, and _WORD).
0142  * EG. For a bit field that is in the 7th bit of the "field4" field of a
0143  * structure and is 2 bits in size the following #defines must exist:
0144  *      struct temp {
0145  *              uint32_t        field1;
0146  *              uint32_t        field2;
0147  *              uint32_t        field3;
0148  *              uint32_t        field4;
0149  *      #define example_bit_field_SHIFT         7
0150  *      #define example_bit_field_MASK          0x03
0151  *      #define example_bit_field_WORD          field4
0152  *              uint32_t        field5;
0153  *      };
0154  * Then the macros below may be used to get or set the value of that field.
0155  * EG. To get the value of the bit field from the above example:
0156  *      struct temp t1;
0157  *      value = bsg_bf_get(example_bit_field, &t1);
0158  * And then to set that bit field:
0159  *      bsg_bf_set(example_bit_field, &t1, 2);
0160  * Or clear that bit field:
0161  *      bsg_bf_set(example_bit_field, &t1, 0);
0162  */
0163 #define bsg_bf_get_le32(name, ptr) \
0164     ((le32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK)
0165 #define bsg_bf_get(name, ptr) \
0166     (((ptr)->name##_WORD >> name##_SHIFT) & name##_MASK)
0167 #define bsg_bf_set_le32(name, ptr, value) \
0168     ((ptr)->name##_WORD = cpu_to_le32(((((value) & \
0169     name##_MASK) << name##_SHIFT) | (le32_to_cpu((ptr)->name##_WORD) & \
0170     ~(name##_MASK << name##_SHIFT)))))
0171 #define bsg_bf_set(name, ptr, value) \
0172     ((ptr)->name##_WORD = ((((value) & name##_MASK) << name##_SHIFT) | \
0173     ((ptr)->name##_WORD & ~(name##_MASK << name##_SHIFT))))
0174 
0175 /*
0176  * The sli_config structure specified here is based on the following
0177  * restriction:
0178  *
0179  * -- SLI_CONFIG EMB=0, carrying MSEs, will carry subcommands without
0180  *    carrying HBD.
0181  * -- SLI_CONFIG EMB=1, not carrying MSE, will carry subcommands with or
0182  *    without carrying HBDs.
0183  */
0184 
0185 struct lpfc_sli_config_mse {
0186     uint32_t pa_lo;
0187     uint32_t pa_hi;
0188     uint32_t buf_len;
0189 #define lpfc_mbox_sli_config_mse_len_SHIFT  0
0190 #define lpfc_mbox_sli_config_mse_len_MASK   0xffffff
0191 #define lpfc_mbox_sli_config_mse_len_WORD   buf_len
0192 };
0193 
0194 struct lpfc_sli_config_hbd {
0195     uint32_t buf_len;
0196 #define lpfc_mbox_sli_config_ecmn_hbd_len_SHIFT 0
0197 #define lpfc_mbox_sli_config_ecmn_hbd_len_MASK  0xffffff
0198 #define lpfc_mbox_sli_config_ecmn_hbd_len_WORD  buf_len
0199     uint32_t pa_lo;
0200     uint32_t pa_hi;
0201 };
0202 
0203 struct lpfc_sli_config_hdr {
0204     uint32_t word1;
0205 #define lpfc_mbox_hdr_emb_SHIFT     0
0206 #define lpfc_mbox_hdr_emb_MASK      0x00000001
0207 #define lpfc_mbox_hdr_emb_WORD      word1
0208 #define lpfc_mbox_hdr_mse_cnt_SHIFT 3
0209 #define lpfc_mbox_hdr_mse_cnt_MASK  0x0000001f
0210 #define lpfc_mbox_hdr_mse_cnt_WORD  word1
0211     uint32_t payload_length;
0212     uint32_t tag_lo;
0213     uint32_t tag_hi;
0214     uint32_t reserved5;
0215 };
0216 
0217 #define LPFC_CSF_BOOT_DEV       0x1D
0218 #define LPFC_CSF_QUERY          0
0219 #define LPFC_CSF_SAVE           1
0220 
0221 struct lpfc_sli_config_emb0_subsys {
0222     struct lpfc_sli_config_hdr  sli_config_hdr;
0223 #define LPFC_MBX_SLI_CONFIG_MAX_MSE     19
0224     struct lpfc_sli_config_mse  mse[LPFC_MBX_SLI_CONFIG_MAX_MSE];
0225     uint32_t padding;
0226     uint32_t word64;
0227 #define lpfc_emb0_subcmnd_opcode_SHIFT  0
0228 #define lpfc_emb0_subcmnd_opcode_MASK   0xff
0229 #define lpfc_emb0_subcmnd_opcode_WORD   word64
0230 #define lpfc_emb0_subcmnd_subsys_SHIFT  8
0231 #define lpfc_emb0_subcmnd_subsys_MASK   0xff
0232 #define lpfc_emb0_subcmnd_subsys_WORD   word64
0233 /* Subsystem FCOE (0x0C) OpCodes */
0234 #define SLI_CONFIG_SUBSYS_FCOE      0x0C
0235 #define FCOE_OPCODE_READ_FCF        0x08
0236 #define FCOE_OPCODE_ADD_FCF     0x09
0237 #define FCOE_OPCODE_SET_DPORT_MODE  0x27
0238 #define FCOE_OPCODE_GET_DPORT_RESULTS   0x28
0239     uint32_t timeout;       /* comn_set_feature timeout */
0240     uint32_t request_length;    /* comn_set_feature request len */
0241     uint32_t version;       /* comn_set_feature version */
0242     uint32_t csf_feature;       /* comn_set_feature feature */
0243     uint32_t word69;        /* comn_set_feature parameter len */
0244     uint32_t word70;        /* comn_set_feature parameter val0 */
0245 #define lpfc_emb0_subcmnd_csf_p0_SHIFT  0
0246 #define lpfc_emb0_subcmnd_csf_p0_MASK   0x3
0247 #define lpfc_emb0_subcmnd_csf_p0_WORD   word70
0248 };
0249 
0250 struct lpfc_sli_config_emb1_subsys {
0251     struct lpfc_sli_config_hdr  sli_config_hdr;
0252     uint32_t word6;
0253 #define lpfc_emb1_subcmnd_opcode_SHIFT  0
0254 #define lpfc_emb1_subcmnd_opcode_MASK   0xff
0255 #define lpfc_emb1_subcmnd_opcode_WORD   word6
0256 #define lpfc_emb1_subcmnd_subsys_SHIFT  8
0257 #define lpfc_emb1_subcmnd_subsys_MASK   0xff
0258 #define lpfc_emb1_subcmnd_subsys_WORD   word6
0259 /* Subsystem COMN (0x01) OpCodes */
0260 #define SLI_CONFIG_SUBSYS_COMN      0x01
0261 #define COMN_OPCODE_GET_PROFILE_CONFIG  0xA4
0262 #define COMN_OPCODE_READ_OBJECT     0xAB
0263 #define COMN_OPCODE_WRITE_OBJECT    0xAC
0264 #define COMN_OPCODE_READ_OBJECT_LIST    0xAD
0265 #define COMN_OPCODE_DELETE_OBJECT   0xAE
0266 #define COMN_OPCODE_SET_FEATURES    0xBF
0267 #define COMN_OPCODE_GET_CNTL_ADDL_ATTRIBUTES    0x79
0268 #define COMN_OPCODE_GET_CNTL_ATTRIBUTES 0x20
0269     uint32_t timeout;
0270     uint32_t request_length;
0271     uint32_t word9;
0272 #define lpfc_subcmnd_version_SHIFT  0
0273 #define lpfc_subcmnd_version_MASK   0xff
0274 #define lpfc_subcmnd_version_WORD   word9
0275     uint32_t word10;
0276 #define lpfc_subcmnd_ask_rd_len_SHIFT   0
0277 #define lpfc_subcmnd_ask_rd_len_MASK    0xffffff
0278 #define lpfc_subcmnd_ask_rd_len_WORD    word10
0279     uint32_t rd_offset;
0280     uint32_t obj_name[26];
0281     uint32_t hbd_count;
0282 #define LPFC_MBX_SLI_CONFIG_MAX_HBD 8
0283     struct lpfc_sli_config_hbd  hbd[LPFC_MBX_SLI_CONFIG_MAX_HBD];
0284 };
0285 
0286 struct lpfc_sli_config_mbox {
0287     uint32_t word0;
0288 #define lpfc_mqe_status_SHIFT       16
0289 #define lpfc_mqe_status_MASK        0x0000FFFF
0290 #define lpfc_mqe_status_WORD        word0
0291 #define lpfc_mqe_command_SHIFT      8
0292 #define lpfc_mqe_command_MASK       0x000000FF
0293 #define lpfc_mqe_command_WORD       word0
0294     union {
0295         struct lpfc_sli_config_emb0_subsys sli_config_emb0_subsys;
0296         struct lpfc_sli_config_emb1_subsys sli_config_emb1_subsys;
0297     } un;
0298 };
0299 
0300 #define LPFC_FORCED_LINK_SPEED_NOT_SUPPORTED    0
0301 #define LPFC_FORCED_LINK_SPEED_SUPPORTED    1
0302 struct get_forced_link_speed_support {
0303     uint32_t command;
0304 };
0305 struct forced_link_speed_support_reply {
0306     uint8_t supported;
0307 };
0308 
0309 struct lpfc_bsg_ras_req {
0310     uint32_t command;
0311 };
0312 
0313 struct lpfc_bsg_get_fwlog_req {
0314     uint32_t command;
0315     uint32_t read_size;
0316     uint32_t read_offset;
0317 };
0318 
0319 struct lpfc_bsg_get_ras_lwpd {
0320     uint32_t offset;
0321     uint32_t wrap_count;
0322 };
0323 
0324 struct lpfc_bsg_set_ras_config_req {
0325     uint32_t command;
0326     uint8_t action;
0327 #define LPFC_RASACTION_STOP_LOGGING     0x00
0328 #define LPFC_RASACTION_START_LOGGING    0x01
0329     uint8_t log_level;
0330 };
0331 
0332 struct lpfc_bsg_get_ras_config_reply {
0333     uint8_t state;
0334 #define LPFC_RASLOG_STATE_STOPPED 0x00
0335 #define LPFC_RASLOG_STATE_RUNNING 0x01
0336     uint8_t log_level;
0337     uint32_t log_buff_sz;
0338 };
0339 
0340 struct lpfc_trunk_info {
0341     uint32_t word0;
0342 #define lpfc_trunk_info_link_status_SHIFT      0
0343 #define lpfc_trunk_info_link_status_MASK       1
0344 #define lpfc_trunk_info_link_status_WORD       word0
0345 #define lpfc_trunk_info_trunk_active0_SHIFT    8
0346 #define lpfc_trunk_info_trunk_active0_MASK     1
0347 #define lpfc_trunk_info_trunk_active0_WORD     word0
0348 #define lpfc_trunk_info_trunk_active1_SHIFT    9
0349 #define lpfc_trunk_info_trunk_active1_MASK     1
0350 #define lpfc_trunk_info_trunk_active1_WORD     word0
0351 #define lpfc_trunk_info_trunk_active2_SHIFT    10
0352 #define lpfc_trunk_info_trunk_active2_MASK     1
0353 #define lpfc_trunk_info_trunk_active2_WORD     word0
0354 #define lpfc_trunk_info_trunk_active3_SHIFT    11
0355 #define lpfc_trunk_info_trunk_active3_MASK     1
0356 #define lpfc_trunk_info_trunk_active3_WORD     word0
0357 #define lpfc_trunk_info_trunk_config0_SHIFT    12
0358 #define lpfc_trunk_info_trunk_config0_MASK     1
0359 #define lpfc_trunk_info_trunk_config0_WORD     word0
0360 #define lpfc_trunk_info_trunk_config1_SHIFT    13
0361 #define lpfc_trunk_info_trunk_config1_MASK     1
0362 #define lpfc_trunk_info_trunk_config1_WORD     word0
0363 #define lpfc_trunk_info_trunk_config2_SHIFT    14
0364 #define lpfc_trunk_info_trunk_config2_MASK     1
0365 #define lpfc_trunk_info_trunk_config2_WORD     word0
0366 #define lpfc_trunk_info_trunk_config3_SHIFT    15
0367 #define lpfc_trunk_info_trunk_config3_MASK     1
0368 #define lpfc_trunk_info_trunk_config3_WORD     word0
0369     uint16_t    port_speed;
0370     uint16_t    logical_speed;
0371     uint32_t    reserved3;
0372 };
0373 
0374 struct get_trunk_info_req {
0375     uint32_t command;
0376 };
0377 
0378 struct get_cgnbuf_info_req {
0379     uint32_t command;
0380     uint32_t read_size;
0381     uint32_t reset;
0382 #define LPFC_BSG_CGN_RESET_STAT     1
0383 };
0384 
0385 /* driver only */
0386 #define SLI_CONFIG_NOT_HANDLED      0
0387 #define SLI_CONFIG_HANDLED      1