162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Logging Support for MPT (Message Passing Technology) based controllers 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c 562306a36Sopenharmony_ci * Copyright (C) 2012-2014 LSI Corporation 662306a36Sopenharmony_ci * Copyright (C) 2013-2014 Avago Technologies 762306a36Sopenharmony_ci * (mailto: MPT-FusionLinux.pdl@avagotech.com) 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or 1062306a36Sopenharmony_ci * modify it under the terms of the GNU General Public License 1162306a36Sopenharmony_ci * as published by the Free Software Foundation; either version 2 1262306a36Sopenharmony_ci * of the License, or (at your option) any later version. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * This program is distributed in the hope that it will be useful, 1562306a36Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 1662306a36Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1762306a36Sopenharmony_ci * GNU General Public License for more details. 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * NO WARRANTY 2062306a36Sopenharmony_ci * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 2162306a36Sopenharmony_ci * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 2262306a36Sopenharmony_ci * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 2362306a36Sopenharmony_ci * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 2462306a36Sopenharmony_ci * solely responsible for determining the appropriateness of using and 2562306a36Sopenharmony_ci * distributing the Program and assumes all risks associated with its 2662306a36Sopenharmony_ci * exercise of rights under this Agreement, including but not limited to 2762306a36Sopenharmony_ci * the risks and costs of program errors, damage to or loss of data, 2862306a36Sopenharmony_ci * programs or equipment, and unavailability or interruption of operations. 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci * DISCLAIMER OF LIABILITY 3162306a36Sopenharmony_ci * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 3262306a36Sopenharmony_ci * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3362306a36Sopenharmony_ci * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 3462306a36Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 3562306a36Sopenharmony_ci * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 3662306a36Sopenharmony_ci * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 3762306a36Sopenharmony_ci * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License 4062306a36Sopenharmony_ci * along with this program; if not, write to the Free Software 4162306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 4262306a36Sopenharmony_ci * USA. 4362306a36Sopenharmony_ci */ 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#ifndef MPT3SAS_DEBUG_H_INCLUDED 4662306a36Sopenharmony_ci#define MPT3SAS_DEBUG_H_INCLUDED 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci#define MPT_DEBUG 0x00000001 4962306a36Sopenharmony_ci#define MPT_DEBUG_MSG_FRAME 0x00000002 5062306a36Sopenharmony_ci#define MPT_DEBUG_SG 0x00000004 5162306a36Sopenharmony_ci#define MPT_DEBUG_EVENTS 0x00000008 5262306a36Sopenharmony_ci#define MPT_DEBUG_EVENT_WORK_TASK 0x00000010 5362306a36Sopenharmony_ci#define MPT_DEBUG_INIT 0x00000020 5462306a36Sopenharmony_ci#define MPT_DEBUG_EXIT 0x00000040 5562306a36Sopenharmony_ci#define MPT_DEBUG_FAIL 0x00000080 5662306a36Sopenharmony_ci#define MPT_DEBUG_TM 0x00000100 5762306a36Sopenharmony_ci#define MPT_DEBUG_REPLY 0x00000200 5862306a36Sopenharmony_ci#define MPT_DEBUG_HANDSHAKE 0x00000400 5962306a36Sopenharmony_ci#define MPT_DEBUG_CONFIG 0x00000800 6062306a36Sopenharmony_ci#define MPT_DEBUG_DL 0x00001000 6162306a36Sopenharmony_ci#define MPT_DEBUG_RESET 0x00002000 6262306a36Sopenharmony_ci#define MPT_DEBUG_SCSI 0x00004000 6362306a36Sopenharmony_ci#define MPT_DEBUG_IOCTL 0x00008000 6462306a36Sopenharmony_ci#define MPT_DEBUG_SAS 0x00020000 6562306a36Sopenharmony_ci#define MPT_DEBUG_TRANSPORT 0x00040000 6662306a36Sopenharmony_ci#define MPT_DEBUG_TASK_SET_FULL 0x00080000 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#define MPT_DEBUG_TRIGGER_DIAG 0x00200000 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci#define MPT_CHECK_LOGGING(IOC, CMD, BITS) \ 7262306a36Sopenharmony_ci{ \ 7362306a36Sopenharmony_ci if (IOC->logging_level & BITS) \ 7462306a36Sopenharmony_ci CMD; \ 7562306a36Sopenharmony_ci} 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci/* 7862306a36Sopenharmony_ci * debug macros 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define dprintk(IOC, CMD) \ 8262306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG) 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define dsgprintk(IOC, CMD) \ 8562306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG) 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#define devtprintk(IOC, CMD) \ 8862306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS) 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#define dewtprintk(IOC, CMD) \ 9162306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENT_WORK_TASK) 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define dinitprintk(IOC, CMD) \ 9462306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define dexitprintk(IOC, CMD) \ 9762306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT) 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci#define dfailprintk(IOC, CMD) \ 10062306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL) 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci#define dtmprintk(IOC, CMD) \ 10362306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM) 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci#define dreplyprintk(IOC, CMD) \ 10662306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY) 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci#define dhsprintk(IOC, CMD) \ 10962306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE) 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci#define dcprintk(IOC, CMD) \ 11262306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG) 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#define ddlprintk(IOC, CMD) \ 11562306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL) 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#define drsprintk(IOC, CMD) \ 11862306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET) 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#define dsprintk(IOC, CMD) \ 12162306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI) 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci#define dctlprintk(IOC, CMD) \ 12462306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL) 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci#define dsasprintk(IOC, CMD) \ 12762306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS) 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci#define dsastransport(IOC, CMD) \ 13062306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE) 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci#define dmfprintk(IOC, CMD) \ 13362306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME) 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci#define dtsfprintk(IOC, CMD) \ 13662306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TASK_SET_FULL) 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci#define dtransportprintk(IOC, CMD) \ 13962306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRANSPORT) 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci#define dTriggerDiagPrintk(IOC, CMD) \ 14262306a36Sopenharmony_ci MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRIGGER_DIAG) 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci/* inline functions for dumping debug data*/ 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci/** 14962306a36Sopenharmony_ci * _debug_dump_mf - print message frame contents 15062306a36Sopenharmony_ci * @mpi_request: pointer to message frame 15162306a36Sopenharmony_ci * @sz: number of dwords 15262306a36Sopenharmony_ci */ 15362306a36Sopenharmony_cistatic inline void 15462306a36Sopenharmony_ci_debug_dump_mf(void *mpi_request, int sz) 15562306a36Sopenharmony_ci{ 15662306a36Sopenharmony_ci int i; 15762306a36Sopenharmony_ci __le32 *mfp = (__le32 *)mpi_request; 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci pr_info("mf:\n\t"); 16062306a36Sopenharmony_ci for (i = 0; i < sz; i++) { 16162306a36Sopenharmony_ci if (i && ((i % 8) == 0)) 16262306a36Sopenharmony_ci pr_info("\n\t"); 16362306a36Sopenharmony_ci pr_info("%08x ", le32_to_cpu(mfp[i])); 16462306a36Sopenharmony_ci } 16562306a36Sopenharmony_ci pr_info("\n"); 16662306a36Sopenharmony_ci} 16762306a36Sopenharmony_ci/** 16862306a36Sopenharmony_ci * _debug_dump_reply - print message frame contents 16962306a36Sopenharmony_ci * @mpi_request: pointer to message frame 17062306a36Sopenharmony_ci * @sz: number of dwords 17162306a36Sopenharmony_ci */ 17262306a36Sopenharmony_cistatic inline void 17362306a36Sopenharmony_ci_debug_dump_reply(void *mpi_request, int sz) 17462306a36Sopenharmony_ci{ 17562306a36Sopenharmony_ci int i; 17662306a36Sopenharmony_ci __le32 *mfp = (__le32 *)mpi_request; 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci pr_info("reply:\n\t"); 17962306a36Sopenharmony_ci for (i = 0; i < sz; i++) { 18062306a36Sopenharmony_ci if (i && ((i % 8) == 0)) 18162306a36Sopenharmony_ci pr_info("\n\t"); 18262306a36Sopenharmony_ci pr_info("%08x ", le32_to_cpu(mfp[i])); 18362306a36Sopenharmony_ci } 18462306a36Sopenharmony_ci pr_info("\n"); 18562306a36Sopenharmony_ci} 18662306a36Sopenharmony_ci/** 18762306a36Sopenharmony_ci * _debug_dump_config - print config page contents 18862306a36Sopenharmony_ci * @mpi_request: pointer to message frame 18962306a36Sopenharmony_ci * @sz: number of dwords 19062306a36Sopenharmony_ci */ 19162306a36Sopenharmony_cistatic inline void 19262306a36Sopenharmony_ci_debug_dump_config(void *mpi_request, int sz) 19362306a36Sopenharmony_ci{ 19462306a36Sopenharmony_ci int i; 19562306a36Sopenharmony_ci __le32 *mfp = (__le32 *)mpi_request; 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci pr_info("config:\n\t"); 19862306a36Sopenharmony_ci for (i = 0; i < sz; i++) { 19962306a36Sopenharmony_ci if (i && ((i % 8) == 0)) 20062306a36Sopenharmony_ci pr_info("\n\t"); 20162306a36Sopenharmony_ci pr_info("%08x ", le32_to_cpu(mfp[i])); 20262306a36Sopenharmony_ci } 20362306a36Sopenharmony_ci pr_info("\n"); 20462306a36Sopenharmony_ci} 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_ci#endif /* MPT3SAS_DEBUG_H_INCLUDED */ 207