Skip to content

Commit fc44449

Browse files
Ranjan Kumarmartinkpetersen
authored andcommitted
scsi: mpi3mr: HDB allocation and posting for hardware and firmware buffers
To be able to debug controller problems it is beneficial to allocate and configure system/host memory buffers which can be used to capture hardware and firmware diagnostic information. Add functions required to allocate and post firmware and hardware diagnostic buffers to the controller and to set up automatic diagnostic capture triggers. Captures will be triggered under the following circumstances: 1. Firmware is in FAULT state. 2. Admin commands time out. 3. Controller reset caused due to I/O timeout Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Co-developed-by: Sathya Prakash <[email protected]> Signed-off-by: Sathya Prakash <[email protected]> Signed-off-by: Ranjan Kumar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 1613e60 commit fc44449

File tree

4 files changed

+790
-1
lines changed

4 files changed

+790
-1
lines changed

drivers/scsi/mpi3mr/mpi/mpi30_tool.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
/*
3+
* Copyright 2016-2024 Broadcom Inc. All rights reserved.
4+
*/
5+
#ifndef MPI30_TOOL_H
6+
#define MPI30_TOOL_H 1
7+
8+
#define MPI3_DIAG_BUFFER_TYPE_TRACE (0x01)
9+
#define MPI3_DIAG_BUFFER_TYPE_FW (0x02)
10+
#define MPI3_DIAG_BUFFER_ACTION_RELEASE (0x01)
11+
12+
struct mpi3_diag_buffer_post_request {
13+
__le16 host_tag;
14+
u8 ioc_use_only02;
15+
u8 function;
16+
__le16 ioc_use_only04;
17+
u8 ioc_use_only06;
18+
u8 msg_flags;
19+
__le16 change_count;
20+
__le16 reserved0a;
21+
u8 type;
22+
u8 reserved0d;
23+
__le16 reserved0e;
24+
__le64 address;
25+
__le32 length;
26+
__le32 reserved1c;
27+
};
28+
29+
struct mpi3_diag_buffer_manage_request {
30+
__le16 host_tag;
31+
u8 ioc_use_only02;
32+
u8 function;
33+
__le16 ioc_use_only04;
34+
u8 ioc_use_only06;
35+
u8 msg_flags;
36+
__le16 change_count;
37+
__le16 reserved0a;
38+
u8 type;
39+
u8 action;
40+
__le16 reserved0e;
41+
};
42+
43+
44+
#endif

drivers/scsi/mpi3mr/mpi3mr.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "mpi/mpi30_ioc.h"
4848
#include "mpi/mpi30_sas.h"
4949
#include "mpi/mpi30_pci.h"
50+
#include "mpi/mpi30_tool.h"
5051
#include "mpi3mr_debug.h"
5152

5253
/* Global list and lock for storing multiple adapters managed by the driver */
@@ -187,6 +188,13 @@ extern atomic64_t event_counter;
187188
#define MPI3MR_HARD_SECURE_DEVICE 0x08
188189
#define MPI3MR_TAMPERED_DEVICE 0x0C
189190

191+
#define MPI3MR_DEFAULT_HDB_MAX_SZ (4 * 1024 * 1024)
192+
#define MPI3MR_DEFAULT_HDB_DEC_SZ (1 * 1024 * 1024)
193+
#define MPI3MR_DEFAULT_HDB_MIN_SZ (2 * 1024 * 1024)
194+
#define MPI3MR_MAX_NUM_HDB 2
195+
196+
#define MPI3MR_HDB_TRIGGER_TYPE_GLOBAL 3
197+
190198
/* SGE Flag definition */
191199
#define MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST \
192200
(MPI3_SGE_FLAGS_ELEMENT_TYPE_SIMPLE | MPI3_SGE_FLAGS_DLAS_SYSTEM | \
@@ -210,6 +218,7 @@ extern atomic64_t event_counter;
210218
#define MPI3MR_WRITE_SAME_MAX_LEN_256_BLKS 256
211219
#define MPI3MR_WRITE_SAME_MAX_LEN_2048_BLKS 2048
212220

221+
213222
/**
214223
* struct mpi3mr_nvme_pt_sge - Structure to store SGEs for NVMe
215224
* Encapsulated commands.
@@ -289,6 +298,8 @@ enum mpi3mr_reset_reason {
289298
MPI3MR_RESET_FROM_PELABORT_TIMEOUT = 22,
290299
MPI3MR_RESET_FROM_SYSFS = 23,
291300
MPI3MR_RESET_FROM_SYSFS_TIMEOUT = 24,
301+
MPI3MR_RESET_FROM_DIAG_BUFFER_POST_TIMEOUT = 25,
302+
MPI3MR_RESET_FROM_DIAG_BUFFER_RELEASE_TIMEOUT = 26,
292303
MPI3MR_RESET_FROM_FIRMWARE = 27,
293304
MPI3MR_RESET_FROM_CFG_REQ_TIMEOUT = 29,
294305
MPI3MR_RESET_FROM_SAS_TRANSPORT_TIMEOUT = 30,
@@ -327,6 +338,9 @@ struct mpi3mr_ioc_facts {
327338
u32 ioc_capabilities;
328339
struct mpi3mr_compimg_ver fw_ver;
329340
u32 mpi_version;
341+
u32 diag_trace_sz;
342+
u32 diag_fw_sz;
343+
u32 diag_drvr_sz;
330344
u16 max_reqs;
331345
u16 product_id;
332346
u16 op_req_sz;
@@ -852,6 +866,41 @@ struct mpi3mr_drv_cmd {
852866
struct mpi3mr_drv_cmd *drv_cmd);
853867
};
854868

869+
/**
870+
* union mpi3mr_trigger_data - Trigger data information
871+
* @fault: Fault code
872+
* @global: Global trigger data
873+
* @element: element trigger data
874+
*/
875+
union mpi3mr_trigger_data {
876+
u16 fault;
877+
u64 global;
878+
union mpi3_driver2_trigger_element element;
879+
};
880+
881+
/**
882+
* struct diag_buffer_desc - memory descriptor structure to
883+
* store virtual, dma addresses, size, buffer status for host
884+
* diagnostic buffers.
885+
*
886+
* @type: Buffer type
887+
* @trigger_data: Trigger data
888+
* @trigger_type: Trigger type
889+
* @status: Buffer status
890+
* @size: Buffer size
891+
* @addr: Virtual address
892+
* @dma_addr: Buffer DMA address
893+
*/
894+
struct diag_buffer_desc {
895+
u8 type;
896+
union mpi3mr_trigger_data trigger_data;
897+
u8 trigger_type;
898+
u8 status;
899+
u32 size;
900+
void *addr;
901+
dma_addr_t dma_addr;
902+
};
903+
855904
/**
856905
* struct dma_memory_desc - memory descriptor structure to store
857906
* virtual address, dma address and size for any generic dma
@@ -1054,6 +1103,11 @@ struct scmd_priv {
10541103
* @sas_node_lock: Lock to protect SAS node list
10551104
* @hba_port_table_list: List of HBA Ports
10561105
* @enclosure_list: List of Enclosure objects
1106+
* @diag_buffers: Host diagnostic buffers
1107+
* @driver_pg2: Driver page 2 pointer
1108+
* @reply_trigger_present: Reply trigger present flag
1109+
* @event_trigger_present: Event trigger present flag
1110+
* @scsisense_trigger_present: Scsi sense trigger present flag
10571111
* @ioctl_dma_pool: DMA pool for IOCTL data buffers
10581112
* @ioctl_sge: DMA buffer descriptors for IOCTL data
10591113
* @ioctl_chain_sge: DMA buffer descriptor for IOCTL chain
@@ -1250,6 +1304,12 @@ struct mpi3mr_ioc {
12501304
struct dma_memory_desc ioctl_chain_sge;
12511305
struct dma_memory_desc ioctl_resp_sge;
12521306
bool ioctl_sges_allocated;
1307+
bool reply_trigger_present;
1308+
bool event_trigger_present;
1309+
bool scsisense_trigger_present;
1310+
struct diag_buffer_desc diag_buffers[MPI3MR_MAX_NUM_HDB];
1311+
struct mpi3_driver_page2 *driver_pg2;
1312+
spinlock_t trigger_lock;
12531313
};
12541314

12551315
/**
@@ -1406,6 +1466,8 @@ int mpi3mr_cfg_set_sas_io_unit_pg1(struct mpi3mr_ioc *mrioc,
14061466
struct mpi3_sas_io_unit_page1 *sas_io_unit_pg1, u16 pg_sz);
14071467
int mpi3mr_cfg_get_driver_pg1(struct mpi3mr_ioc *mrioc,
14081468
struct mpi3_driver_page1 *driver_pg1, u16 pg_sz);
1469+
int mpi3mr_cfg_get_driver_pg2(struct mpi3mr_ioc *mrioc,
1470+
struct mpi3_driver_page2 *driver_pg2, u16 pg_sz, u8 page_type);
14091471

14101472
u8 mpi3mr_is_expander_device(u16 device_info);
14111473
int mpi3mr_expander_add(struct mpi3mr_ioc *mrioc, u16 handle);
@@ -1439,4 +1501,16 @@ void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc);
14391501
int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc);
14401502
void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
14411503
struct mpi3mr_sas_node *sas_expander);
1504+
void mpi3mr_alloc_diag_bufs(struct mpi3mr_ioc *mrioc);
1505+
int mpi3mr_post_diag_bufs(struct mpi3mr_ioc *mrioc);
1506+
int mpi3mr_issue_diag_buf_release(struct mpi3mr_ioc *mrioc,
1507+
struct diag_buffer_desc *diag_buffer);
1508+
void mpi3mr_release_diag_bufs(struct mpi3mr_ioc *mrioc, u8 skip_rel_action);
1509+
void mpi3mr_set_trigger_data_in_hdb(struct diag_buffer_desc *hdb,
1510+
u8 type, union mpi3mr_trigger_data *trigger_data, bool force);
1511+
int mpi3mr_refresh_trigger(struct mpi3mr_ioc *mrioc, u8 page_type);
1512+
struct diag_buffer_desc *mpi3mr_diag_buffer_for_type(struct mpi3mr_ioc *mrioc,
1513+
u8 buf_type);
1514+
int mpi3mr_issue_diag_buf_post(struct mpi3mr_ioc *mrioc,
1515+
struct diag_buffer_desc *diag_buffer);
14421516
#endif /*MPI3MR_H_INCLUDED*/

0 commit comments

Comments
 (0)