Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
0004  * Copyright (c) 2014- QLogic Corporation.
0005  * All rights reserved
0006  * www.qlogic.com
0007  *
0008  * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
0009  */
0010 #ifndef __BFA_PORTLOG_H__
0011 #define __BFA_PORTLOG_H__
0012 
0013 #include "bfa_fc.h"
0014 #include "bfa_defs.h"
0015 
0016 #define BFA_PL_NLOG_ENTS 256
0017 #define BFA_PL_LOG_REC_INCR(_x) ((_x)++, (_x) %= BFA_PL_NLOG_ENTS)
0018 
0019 #define BFA_PL_STRING_LOG_SZ   32   /* number of chars in string log */
0020 #define BFA_PL_INT_LOG_SZ      8    /* number of integers in the integer log */
0021 
0022 enum bfa_plog_log_type {
0023     BFA_PL_LOG_TYPE_INVALID = 0,
0024     BFA_PL_LOG_TYPE_INT = 1,
0025     BFA_PL_LOG_TYPE_STRING  = 2,
0026 };
0027 
0028 /*
0029  * the (fixed size) record format for each entry in the portlog
0030  */
0031 struct bfa_plog_rec_s {
0032     u64 tv; /* timestamp */
0033     u8   port;  /* Source port that logged this entry */
0034     u8   mid;   /* module id */
0035     u8   eid;   /* indicates Rx, Tx, IOCTL, etc.  bfa_plog_eid */
0036     u8   log_type; /* string/integer log, bfa_plog_log_type_t */
0037     u8   log_num_ints;
0038     /*
0039      * interpreted only if log_type is INT_LOG. indicates number of
0040      * integers in the int_log[] (0-PL_INT_LOG_SZ).
0041      */
0042     u8   rsvd;
0043     u16 misc;   /* can be used to indicate fc frame length */
0044     union {
0045         char        string_log[BFA_PL_STRING_LOG_SZ];
0046         u32 int_log[BFA_PL_INT_LOG_SZ];
0047     } log_entry;
0048 
0049 };
0050 
0051 /*
0052  * the following #defines will be used by the logging entities to indicate
0053  * their module id. BFAL will convert the integer value to string format
0054  *
0055 * process to be used while changing the following #defines:
0056  *  - Always add new entries at the end
0057  *  - define corresponding string in BFAL
0058  *  - Do not remove any entry or rearrange the order.
0059  */
0060 enum bfa_plog_mid {
0061     BFA_PL_MID_INVALID  = 0,
0062     BFA_PL_MID_DEBUG    = 1,
0063     BFA_PL_MID_DRVR     = 2,
0064     BFA_PL_MID_HAL      = 3,
0065     BFA_PL_MID_HAL_FCXP = 4,
0066     BFA_PL_MID_HAL_UF   = 5,
0067     BFA_PL_MID_FCS      = 6,
0068     BFA_PL_MID_LPS      = 7,
0069     BFA_PL_MID_MAX      = 8
0070 };
0071 
0072 #define BFA_PL_MID_STRLEN    8
0073 struct bfa_plog_mid_strings_s {
0074     char        m_str[BFA_PL_MID_STRLEN];
0075 };
0076 
0077 /*
0078  * the following #defines will be used by the logging entities to indicate
0079  * their event type. BFAL will convert the integer value to string format
0080  *
0081 * process to be used while changing the following #defines:
0082  *  - Always add new entries at the end
0083  *  - define corresponding string in BFAL
0084  *  - Do not remove any entry or rearrange the order.
0085  */
0086 enum bfa_plog_eid {
0087     BFA_PL_EID_INVALID      = 0,
0088     BFA_PL_EID_IOC_DISABLE      = 1,
0089     BFA_PL_EID_IOC_ENABLE       = 2,
0090     BFA_PL_EID_PORT_DISABLE     = 3,
0091     BFA_PL_EID_PORT_ENABLE      = 4,
0092     BFA_PL_EID_PORT_ST_CHANGE   = 5,
0093     BFA_PL_EID_TX           = 6,
0094     BFA_PL_EID_TX_ACK1      = 7,
0095     BFA_PL_EID_TX_RJT       = 8,
0096     BFA_PL_EID_TX_BSY       = 9,
0097     BFA_PL_EID_RX           = 10,
0098     BFA_PL_EID_RX_ACK1      = 11,
0099     BFA_PL_EID_RX_RJT       = 12,
0100     BFA_PL_EID_RX_BSY       = 13,
0101     BFA_PL_EID_CT_IN        = 14,
0102     BFA_PL_EID_CT_OUT       = 15,
0103     BFA_PL_EID_DRIVER_START     = 16,
0104     BFA_PL_EID_RSCN         = 17,
0105     BFA_PL_EID_DEBUG        = 18,
0106     BFA_PL_EID_MISC         = 19,
0107     BFA_PL_EID_FIP_FCF_DISC     = 20,
0108     BFA_PL_EID_FIP_FCF_CVL      = 21,
0109     BFA_PL_EID_LOGIN        = 22,
0110     BFA_PL_EID_LOGO         = 23,
0111     BFA_PL_EID_TRUNK_SCN        = 24,
0112     BFA_PL_EID_MAX
0113 };
0114 
0115 #define BFA_PL_ENAME_STRLEN 8
0116 struct bfa_plog_eid_strings_s {
0117     char        e_str[BFA_PL_ENAME_STRLEN];
0118 };
0119 
0120 #define BFA_PL_SIG_LEN  8
0121 #define BFA_PL_SIG_STR  "12pl123"
0122 
0123 /*
0124  * per port circular log buffer
0125  */
0126 struct bfa_plog_s {
0127     char        plog_sig[BFA_PL_SIG_LEN];   /* Start signature */
0128     u8   plog_enabled;
0129     u8   rsvd[7];
0130     u32 ticks;
0131     u16 head;
0132     u16 tail;
0133     struct bfa_plog_rec_s  plog_recs[BFA_PL_NLOG_ENTS];
0134 };
0135 
0136 void bfa_plog_init(struct bfa_plog_s *plog);
0137 void bfa_plog_str(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
0138             enum bfa_plog_eid event, u16 misc, char *log_str);
0139 void bfa_plog_intarr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
0140             enum bfa_plog_eid event, u16 misc,
0141             u32 *intarr, u32 num_ints);
0142 void bfa_plog_fchdr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
0143         enum bfa_plog_eid event, u16 misc, struct fchs_s *fchdr);
0144 void bfa_plog_fchdr_and_pl(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
0145             enum bfa_plog_eid event, u16 misc,
0146             struct fchs_s *fchdr, u32 pld_w0);
0147 
0148 #endif /* __BFA_PORTLOG_H__ */