18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * linux/drivers/message/fusion/mptdebug.h 48c2ecf20Sopenharmony_ci * For use with LSI PCI chip/adapter(s) 58c2ecf20Sopenharmony_ci * running LSI Fusion MPT (Message Passing Technology) firmware. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (c) 1999-2008 LSI Corporation 88c2ecf20Sopenharmony_ci * (mailto:DL-MPTFusionLinux@lsi.com) 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifndef MPTDEBUG_H_INCLUDED 148c2ecf20Sopenharmony_ci#define MPTDEBUG_H_INCLUDED 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* 178c2ecf20Sopenharmony_ci * debug level can be programmed on the fly via SysFS (hex values) 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * Example: (programming for MPT_DEBUG_EVENTS on host 5) 208c2ecf20Sopenharmony_ci * 218c2ecf20Sopenharmony_ci * echo 8 > /sys/class/scsi_host/host5/debug_level 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * -------------------------------------------------------- 248c2ecf20Sopenharmony_ci * mpt_debug_level - command line parameter 258c2ecf20Sopenharmony_ci * this allow enabling debug at driver load time (for all iocs) 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * Example (programming for MPT_DEBUG_EVENTS) 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * insmod mptbase.ko mpt_debug_level=8 308c2ecf20Sopenharmony_ci * 318c2ecf20Sopenharmony_ci * -------------------------------------------------------- 328c2ecf20Sopenharmony_ci * CONFIG_FUSION_LOGGING - enables compiling debug into driver 338c2ecf20Sopenharmony_ci * this can be enabled in the driver Makefile 348c2ecf20Sopenharmony_ci * 358c2ecf20Sopenharmony_ci * 368c2ecf20Sopenharmony_ci * -------------------------------------------------------- 378c2ecf20Sopenharmony_ci * Please note most debug prints are set to logging priority = debug 388c2ecf20Sopenharmony_ci * This is the lowest level, and most verbose. Please refer to manual 398c2ecf20Sopenharmony_ci * pages for syslogd or syslogd-ng on how to configure this. 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define MPT_DEBUG 0x00000001 438c2ecf20Sopenharmony_ci#define MPT_DEBUG_MSG_FRAME 0x00000002 448c2ecf20Sopenharmony_ci#define MPT_DEBUG_SG 0x00000004 458c2ecf20Sopenharmony_ci#define MPT_DEBUG_EVENTS 0x00000008 468c2ecf20Sopenharmony_ci#define MPT_DEBUG_VERBOSE_EVENTS 0x00000010 478c2ecf20Sopenharmony_ci#define MPT_DEBUG_INIT 0x00000020 488c2ecf20Sopenharmony_ci#define MPT_DEBUG_EXIT 0x00000040 498c2ecf20Sopenharmony_ci#define MPT_DEBUG_FAIL 0x00000080 508c2ecf20Sopenharmony_ci#define MPT_DEBUG_TM 0x00000100 518c2ecf20Sopenharmony_ci#define MPT_DEBUG_DV 0x00000200 528c2ecf20Sopenharmony_ci#define MPT_DEBUG_REPLY 0x00000400 538c2ecf20Sopenharmony_ci#define MPT_DEBUG_HANDSHAKE 0x00000800 548c2ecf20Sopenharmony_ci#define MPT_DEBUG_CONFIG 0x00001000 558c2ecf20Sopenharmony_ci#define MPT_DEBUG_DL 0x00002000 568c2ecf20Sopenharmony_ci#define MPT_DEBUG_RESET 0x00008000 578c2ecf20Sopenharmony_ci#define MPT_DEBUG_SCSI 0x00010000 588c2ecf20Sopenharmony_ci#define MPT_DEBUG_IOCTL 0x00020000 598c2ecf20Sopenharmony_ci#define MPT_DEBUG_FC 0x00080000 608c2ecf20Sopenharmony_ci#define MPT_DEBUG_SAS 0x00100000 618c2ecf20Sopenharmony_ci#define MPT_DEBUG_SAS_WIDE 0x00200000 628c2ecf20Sopenharmony_ci#define MPT_DEBUG_36GB_MEM 0x00400000 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* 658c2ecf20Sopenharmony_ci * CONFIG_FUSION_LOGGING - enabled in Kconfig 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#ifdef CONFIG_FUSION_LOGGING 698c2ecf20Sopenharmony_ci#define MPT_CHECK_LOGGING(IOC, CMD, BITS) \ 708c2ecf20Sopenharmony_ci{ \ 718c2ecf20Sopenharmony_ci if (IOC->debug_level & BITS) \ 728c2ecf20Sopenharmony_ci CMD; \ 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci#else 758c2ecf20Sopenharmony_ci#define MPT_CHECK_LOGGING(IOC, CMD, BITS) 768c2ecf20Sopenharmony_ci#endif 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* 808c2ecf20Sopenharmony_ci * debug macros 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define dprintk(IOC, CMD) \ 848c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG) 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#define dsgprintk(IOC, CMD) \ 878c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG) 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define devtprintk(IOC, CMD) \ 908c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS) 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define devtverboseprintk(IOC, CMD) \ 938c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_VERBOSE_EVENTS) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define dinitprintk(IOC, CMD) \ 968c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT) 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define dexitprintk(IOC, CMD) \ 998c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT) 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci#define dfailprintk(IOC, CMD) \ 1028c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL) 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#define dtmprintk(IOC, CMD) \ 1058c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM) 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#define ddvprintk(IOC, CMD) \ 1088c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DV) 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci#define dreplyprintk(IOC, CMD) \ 1118c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define dhsprintk(IOC, CMD) \ 1148c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#define dcprintk(IOC, CMD) \ 1178c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG) 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define ddlprintk(IOC, CMD) \ 1208c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci#define drsprintk(IOC, CMD) \ 1238c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET) 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci#define dsprintk(IOC, CMD) \ 1268c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI) 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci#define dctlprintk(IOC, CMD) \ 1298c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL) 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#define dfcprintk(IOC, CMD) \ 1328c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FC) 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define dsasprintk(IOC, CMD) \ 1358c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS) 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci#define dsaswideprintk(IOC, CMD) \ 1388c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE) 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#define d36memprintk(IOC, CMD) \ 1418c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_36GB_MEM) 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci/* 1458c2ecf20Sopenharmony_ci * Verbose logging 1468c2ecf20Sopenharmony_ci */ 1478c2ecf20Sopenharmony_ci#if defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING) 1488c2ecf20Sopenharmony_cistatic inline void 1498c2ecf20Sopenharmony_ciDBG_DUMP_FW_DOWNLOAD(MPT_ADAPTER *ioc, u32 *mfp, int numfrags) 1508c2ecf20Sopenharmony_ci{ 1518c2ecf20Sopenharmony_ci int i; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci if (!(ioc->debug_level & MPT_DEBUG)) 1548c2ecf20Sopenharmony_ci return; 1558c2ecf20Sopenharmony_ci printk(KERN_DEBUG "F/W download request:\n"); 1568c2ecf20Sopenharmony_ci for (i=0; i < 7+numfrags*2; i++) 1578c2ecf20Sopenharmony_ci printk(" %08x", le32_to_cpu(mfp[i])); 1588c2ecf20Sopenharmony_ci printk("\n"); 1598c2ecf20Sopenharmony_ci} 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_cistatic inline void 1628c2ecf20Sopenharmony_ciDBG_DUMP_PUT_MSG_FRAME(MPT_ADAPTER *ioc, u32 *mfp) 1638c2ecf20Sopenharmony_ci{ 1648c2ecf20Sopenharmony_ci int ii, n; 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME)) 1678c2ecf20Sopenharmony_ci return; 1688c2ecf20Sopenharmony_ci printk(KERN_DEBUG "%s: About to Put msg frame @ %p:\n", 1698c2ecf20Sopenharmony_ci ioc->name, mfp); 1708c2ecf20Sopenharmony_ci n = ioc->req_sz/4 - 1; 1718c2ecf20Sopenharmony_ci while (mfp[n] == 0) 1728c2ecf20Sopenharmony_ci n--; 1738c2ecf20Sopenharmony_ci for (ii=0; ii<=n; ii++) { 1748c2ecf20Sopenharmony_ci if (ii && ((ii%8)==0)) 1758c2ecf20Sopenharmony_ci printk("\n"); 1768c2ecf20Sopenharmony_ci printk(" %08x", le32_to_cpu(mfp[ii])); 1778c2ecf20Sopenharmony_ci } 1788c2ecf20Sopenharmony_ci printk("\n"); 1798c2ecf20Sopenharmony_ci} 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_cistatic inline void 1828c2ecf20Sopenharmony_ciDBG_DUMP_FW_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp) 1838c2ecf20Sopenharmony_ci{ 1848c2ecf20Sopenharmony_ci int i, n; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME)) 1878c2ecf20Sopenharmony_ci return; 1888c2ecf20Sopenharmony_ci n = 10; 1898c2ecf20Sopenharmony_ci printk(KERN_INFO " "); 1908c2ecf20Sopenharmony_ci for (i = 0; i < n; i++) 1918c2ecf20Sopenharmony_ci printk(" %08x", le32_to_cpu(mfp[i])); 1928c2ecf20Sopenharmony_ci printk("\n"); 1938c2ecf20Sopenharmony_ci} 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_cistatic inline void 1968c2ecf20Sopenharmony_ciDBG_DUMP_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp) 1978c2ecf20Sopenharmony_ci{ 1988c2ecf20Sopenharmony_ci int i, n; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME)) 2018c2ecf20Sopenharmony_ci return; 2028c2ecf20Sopenharmony_ci n = 24; 2038c2ecf20Sopenharmony_ci for (i=0; i<n; i++) { 2048c2ecf20Sopenharmony_ci if (i && ((i%8)==0)) 2058c2ecf20Sopenharmony_ci printk("\n"); 2068c2ecf20Sopenharmony_ci printk("%08x ", le32_to_cpu(mfp[i])); 2078c2ecf20Sopenharmony_ci } 2088c2ecf20Sopenharmony_ci printk("\n"); 2098c2ecf20Sopenharmony_ci} 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_cistatic inline void 2128c2ecf20Sopenharmony_ciDBG_DUMP_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp) 2138c2ecf20Sopenharmony_ci{ 2148c2ecf20Sopenharmony_ci int i, n; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME)) 2178c2ecf20Sopenharmony_ci return; 2188c2ecf20Sopenharmony_ci n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16; 2198c2ecf20Sopenharmony_ci printk(KERN_INFO " "); 2208c2ecf20Sopenharmony_ci for (i=0; i<n; i++) 2218c2ecf20Sopenharmony_ci printk(" %08x", le32_to_cpu(mfp[i])); 2228c2ecf20Sopenharmony_ci printk("\n"); 2238c2ecf20Sopenharmony_ci} 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_cistatic inline void 2268c2ecf20Sopenharmony_ciDBG_DUMP_REQUEST_FRAME_HDR(MPT_ADAPTER *ioc, u32 *mfp) 2278c2ecf20Sopenharmony_ci{ 2288c2ecf20Sopenharmony_ci int i, n; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME)) 2318c2ecf20Sopenharmony_ci return; 2328c2ecf20Sopenharmony_ci n = 3; 2338c2ecf20Sopenharmony_ci printk(KERN_INFO " "); 2348c2ecf20Sopenharmony_ci for (i=0; i<n; i++) 2358c2ecf20Sopenharmony_ci printk(" %08x", le32_to_cpu(mfp[i])); 2368c2ecf20Sopenharmony_ci printk("\n"); 2378c2ecf20Sopenharmony_ci} 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_cistatic inline void 2408c2ecf20Sopenharmony_ciDBG_DUMP_TM_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp) 2418c2ecf20Sopenharmony_ci{ 2428c2ecf20Sopenharmony_ci int i, n; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci if (!(ioc->debug_level & MPT_DEBUG_TM)) 2458c2ecf20Sopenharmony_ci return; 2468c2ecf20Sopenharmony_ci n = 13; 2478c2ecf20Sopenharmony_ci printk(KERN_DEBUG "TM_REQUEST:\n"); 2488c2ecf20Sopenharmony_ci for (i=0; i<n; i++) { 2498c2ecf20Sopenharmony_ci if (i && ((i%8)==0)) 2508c2ecf20Sopenharmony_ci printk("\n"); 2518c2ecf20Sopenharmony_ci printk("%08x ", le32_to_cpu(mfp[i])); 2528c2ecf20Sopenharmony_ci } 2538c2ecf20Sopenharmony_ci printk("\n"); 2548c2ecf20Sopenharmony_ci} 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_cistatic inline void 2578c2ecf20Sopenharmony_ciDBG_DUMP_TM_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp) 2588c2ecf20Sopenharmony_ci{ 2598c2ecf20Sopenharmony_ci int i, n; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci if (!(ioc->debug_level & MPT_DEBUG_TM)) 2628c2ecf20Sopenharmony_ci return; 2638c2ecf20Sopenharmony_ci n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16; 2648c2ecf20Sopenharmony_ci printk(KERN_DEBUG "TM_REPLY MessageLength=%d:\n", n); 2658c2ecf20Sopenharmony_ci for (i=0; i<n; i++) { 2668c2ecf20Sopenharmony_ci if (i && ((i%8)==0)) 2678c2ecf20Sopenharmony_ci printk("\n"); 2688c2ecf20Sopenharmony_ci printk(" %08x", le32_to_cpu(mfp[i])); 2698c2ecf20Sopenharmony_ci } 2708c2ecf20Sopenharmony_ci printk("\n"); 2718c2ecf20Sopenharmony_ci} 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci#define dmfprintk(IOC, CMD) \ 2748c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME) 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci# else /* ifdef MPT_DEBUG_MF */ 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci#define DBG_DUMP_FW_DOWNLOAD(IOC, mfp, numfrags) 2798c2ecf20Sopenharmony_ci#define DBG_DUMP_PUT_MSG_FRAME(IOC, mfp) 2808c2ecf20Sopenharmony_ci#define DBG_DUMP_FW_REQUEST_FRAME(IOC, mfp) 2818c2ecf20Sopenharmony_ci#define DBG_DUMP_REQUEST_FRAME(IOC, mfp) 2828c2ecf20Sopenharmony_ci#define DBG_DUMP_REPLY_FRAME(IOC, mfp) 2838c2ecf20Sopenharmony_ci#define DBG_DUMP_REQUEST_FRAME_HDR(IOC, mfp) 2848c2ecf20Sopenharmony_ci#define DBG_DUMP_TM_REQUEST_FRAME(IOC, mfp) 2858c2ecf20Sopenharmony_ci#define DBG_DUMP_TM_REPLY_FRAME(IOC, mfp) 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci#define dmfprintk(IOC, CMD) \ 2888c2ecf20Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME) 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci#endif /* defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING) */ 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci#endif /* ifndef MPTDEBUG_H_INCLUDED */ 293