Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_ras.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018, Emulex
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 /**
34  * @file
35  *
36  */
37 
38 #include "ocs_os.h"
39 
40 
41 #if !defined(__OCS_RAS_H__)
42 #define __OCS_RAS_H__
43 
44 #define OCS_RAS_BUFFER_COUNT_MAX 16
45 
46 /* RAS diagnostic log memory consists of #n equal sized buffers. Each of these buffers
47  * can be multiples of 4KB, range is 4K to 64KB. Value of #n (number of memory chunks)
48  * is 1 - 16. So logical buffer can be 4K to 1MB, however OCS limits the range to
49  * 128KB - 1MB.
50  */
51 #define OCS_RAS_BUFFER_UNIT_MIN (16 * 1024)
52 #define OCS_RAS_BUFFER_UNIT_MAX (64 * 1024)
53 #define OCS_RAS_LOGICAL_BUFFER_SIZE_MIN (128 * 1024)
54 #define OCS_RAS_LOGICAL_BUFFER_SIZE_MAX (1024 * 1024)
55 
56 #define OCS_RAS_FW_LOG_LEVEL_MIN 0
57 #define OCS_RAS_FW_LOG_LEVEL_MAX 4
58 
59 #define OCS_RAS_DMA_ADDR_LOW_MASK 0xFFFFFFFF
60 #define OCS_RAS_DMA_ADDR_HI_SHIFT 32
61 
62 #define OCS_RAS_MOD_INIT_DONE 1
63 
64 typedef struct ocs_diag_log_buf_s {
65  char *addr;
66  uint32_t offset;
67  uint32_t length;
69 
70 
71 typedef struct ocs_ras_adapter_desc_s {
73  uint32_t pci_busdev;
74  ocs_ref_t refcnt;
75  struct pci_dev *pdev;
76  uint32_t buf_unit_size;
77  uint32_t log_buf_size;
78  uint32_t log_buf_count;
79  uint32_t fw_log_level;
81  ocs_dma_t lwpd_buffer; // Log Write Position Data
82  ocs_dma_t buffers[OCS_RAS_BUFFER_COUNT_MAX];
84 
85 
86 typedef struct ocs_ras_subsystem_s {
87  bool init_done;
88  uint32_t log_buf_size;
89  uint32_t fw_log_level;
90  uint32_t num_adapters;
91  ocs_lock_t lock;
92  ocs_list_t adapter_list;
94 
95 extern void ocs_ras_init(uint32_t fw_log_level, uint32_t log_buf_size);
96 extern int ocs_ras_allocate_resc(ocs_os_handle_t *ocs_os);
97 extern int ocs_ras_free_resc(ocs_os_handle_t *ocs_os);
98 extern uintptr_t ocs_ras_get_lwpd_dma_addr(ocs_os_handle_t *ocs_os);
99 extern uint32_t * ocs_ras_get_dma_addr_list(ocs_os_handle_t *ocs_os, int32_t *buf_count);
100 extern int ocs_ras_copy_logs(ocs_t *ocs, void *user_buf, int32_t user_buf_size);
101 
102 #endif // __OCS_RAS_H__
uint32_t length
Definition: ocs_ras.h:67
ocs_list_t ocs_list_link_t
Definition: ocs_list.h:84
int ocs_ras_copy_logs(ocs_t *ocs, void *user_buf, int32_t user_buf_len)
Definition: ocs_ras.c:237
struct pci_dev * pdev
Definition: ocs_ras.h:75
uint32_t buf_unit_size
Definition: ocs_ras.h:76
uintptr_t ocs_ras_get_lwpd_dma_addr(ocs_os_handle_t *ocs_os)
Definition: ocs_ras.c:172
uint32_t fw_log_level
Definition: ocs_ras.h:89
ocs_ref_t refcnt
Definition: ocs_ras.h:74
uint32_t pci_busdev
Definition: ocs_ras.h:73
uint32_t log_buf_size
Definition: ocs_ras.h:77
#define OCS_RAS_BUFFER_COUNT_MAX
Definition: ocs_ras.h:44
ocs_list_t adapter_list
Definition: ocs_ras.h:92
ocs_dma_t lwpd_buffer
Definition: ocs_ras.h:81
uint32_t * ocs_ras_get_dma_addr_list(ocs_os_handle_t *ocs_os, int32_t *buf_count)
Definition: ocs_ras.c:185
void ocs_ras_init(uint32_t fw_log_level, uint32_t log_buf_size)
Definition: ocs_ras.c:395
uint32_t log_buf_count
Definition: ocs_ras.h:78
int ocs_ras_free_resc(ocs_os_handle_t *ocs_os)
Definition: ocs_ras.c:315
ocs_list_link_t link
Definition: ocs_ras.h:72
uint32_t fw_log_level
Definition: ocs_ras.h:79
ocs_lock_t lock
Definition: ocs_ras.h:91
uint32_t offset
Definition: ocs_ras.h:66
int32_t ocs_ras_allocate_resc(ocs_os_handle_t *ocs_os)
Definition: ocs_ras.c:343
uint32_t num_adapters
Definition: ocs_ras.h:90
uint32_t log_buf_size
Definition: ocs_ras.h:88