libxcoder 5.8.0
Loading...
Searching...
No Matches
ni_quadraprobe.h
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Copyright (C) 2022 NETINT Technologies
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 * SOFTWARE.
19 *
20 ******************************************************************************/
21
22/*!*****************************************************************************
23 * \file ni_quadraprobe.h
24 *
25 * \brief Quadraprobe definitions
26 ******************************************************************************/
27
28#pragma once
29
30#ifdef __cplusplus
31extern "C"
32{
33#endif
34
35#include "ni_defs.h"
36
37#if defined(__linux__)
38#include <stdint.h>
39#include <stddef.h>
40#include <stdbool.h>
41#include <sys/types.h>
42
43#define NUM_CORES 6
44#define NUM_CORES_NO_FL 5
45
46#define NOR_CMD_WRITE 0x00000001
47#define NOR_CMD_READ 0x00000002
48#define NOR_CMD_ERASE 0x00000003
49#define NOR_CMD_EXCEPTION 0x00000004
50
51typedef struct {
52 char sysfs_path[256];
53 int domain;
54 int bus;
55 int slot;
56 int func;
57 int bar4_fd;
58 unsigned char *bar4_base;
59 off_t barsize;
60 uint32_t core_log_offsets[NUM_CORES];
61 int log_size;
62 uint32_t log_artifacts_offset;
63} QuadraDevice;
64
65/* Core names indexed [0..NUM_CORES-1]: "np","dp","ep","tp","fp","fl" */
66extern const char *const core_names[NUM_CORES];
67
68/*!*****************************************************************************
69 * \brief Dump raw firmware logs from all detected Quadra devices
70 *
71 * This function enumerates all detected Quadra cards in the system,
72 * mmaps each card's BAR4, and dumps per-core logs to files in the specified output directory.
73 * It summarizes success and captures partial failures across multiple devices.
74 *
75 * \param[in] outdir Directory to write log file outputs (use "." for current directory)
76 * \param[in] core_reset_log whether to get core reset log
77 *
78 * \return 0 if all device logs were dumped successfully,
79 * 1 if no Quadra devices were found,
80 * 2 if one or more logs failed to dump but some succeeded,
81 * <0 for unexpected fatal/internal errors.
82 ******************************************************************************/
83LIB_API int ni_rsrc_log_dump(const char *outdir, bool core_reset_log);
84
85/*!*****************************************************************************
86 * \brief Execute a NOR flash persistent log command on all detected devices.
87 * Enumerate every Quadra card on the host, decodes nor_commands (read,
88 * write, erase, exception) and dispatches them.
89 *
90 * \param[in] nor_cmd "w", "r", "e", or "ex"
91 * \param[in] outdir Output directory
92 *
93 * \return 0 - all succeeded,
94 * 1 - no devices,
95 * 2 - partial failure,
96 * -1 - invalid args.
97 ******************************************************************************/
98LIB_API int ni_rsrc_nor_log_command(const char *nor_cmd, const char *outdir);
99
100int quadra_device_find(QuadraDevice **qd);
101int quadra_init_mmap(QuadraDevice *qd);
102void quadra_cleanup(QuadraDevice *qd);
103
104void fill_core_log_offsets(QuadraDevice *qd);
105void fill_core_reset_log_offsets(QuadraDevice *qd);
106
107int dump_raw_logs(QuadraDevice *qd, const char *outdir, bool core_reset_log);
108int dump_nor_logs(QuadraDevice *qd, const char *outdir);
109
110int nor_cmd_decode(const char *nor_cmd, uint32_t *out_cmd);
111int quadra_nor_command(QuadraDevice *qd, uint32_t command);
112int ni_rsrc_nor_cmd_run(QuadraDevice *devs, int ndev,
113 uint32_t cmd, const char *outdir);
114
115int quadra_device_find_by_bdf(const char *domain_str,
116 const char *slot_str,
117 QuadraDevice **out);
118int quadra_device_find_by_block_dev(const char *blkdev, QuadraDevice **out);
119
120#endif /* __linux__ */
121
122#ifdef __cplusplus
123}
124#endif
Common NETINT definitions used by all modules.