4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25 #include <strings.h>
26 #include <fm/topo_hc.h>
27 #include <sys/fm/util.h>
28 #include <libxml/xpath.h>
29 #include <libxml/parser.h>
30 #include <libxml/xpathInternals.h>
31 #include <libxml/tree.h>
32
33 #include "fabric-xlate.h"
34
35 #define HAS_PROP(node, name) xmlHasProp(node, (const xmlChar *)name)
36 #define GET_PROP(node, name) ((char *)xmlGetProp(node, (const xmlChar *)name))
37 #define FREE_PROP(prop) xmlFree((xmlChar *)prop)
38
39 extern xmlXPathContextPtr fab_xpathCtx;
40
41 /* ARGSUSED */
42 int
43 fab_prep_basic_erpt(fmd_hdl_t *hdl, nvlist_t *nvl, nvlist_t *erpt,
44 boolean_t isRC)
45 {
46 uint64_t *now;
47 uint64_t ena;
48 uint_t nelem;
49 nvlist_t *detector, *new_detector;
50 char rcpath[255];
51 int err = 0;
167 goto done;
168 fmd_hdl_strfree(hdl, fmri);
169 } else {
170 fmd_hdl_debug(hdl,
171 "Cannot find Target FMRI addr:0x%llx bdf 0x%x\n",
172 tgt_addr, tgt_bdf);
173 }
174
175 return;
176 done:
177 if (fmri)
178 xmlFree(fmri);
179 fmd_hdl_debug(hdl, "Failed to send Target PCI ereport\n");
180 }
181
182 void
183 fab_send_erpt(fmd_hdl_t *hdl, fab_data_t *data, fab_err_tbl_t *tbl)
184 {
185 fab_erpt_tbl_t *erpt_tbl, *entry;
186 nvlist_t *erpt;
187 uint32_t reg;
188
189 erpt_tbl = tbl->erpt_tbl;
190 if (tbl->reg_size == 16) {
191 reg = (uint32_t)*((uint16_t *)
192 ((uint32_t)data + tbl->reg_offset));
193 } else {
194 reg = *((uint32_t *)((uint32_t)data + tbl->reg_offset));
195 }
196
197 for (entry = erpt_tbl; entry->err_class; entry++) {
198 if (!(reg & entry->reg_bit))
199 continue;
200
201 if (nvlist_alloc(&erpt, NV_UNIQUE_NAME, 0) != 0)
202 goto done;
203 if (tbl->fab_prep(hdl, data, erpt, entry) != 0) {
204 fmd_hdl_debug(hdl, "Prepping ereport failed: "
205 "class = %s\n", entry->err_class);
206 nvlist_free(erpt);
207 continue;
208 }
209
210 if (data->pcie_rp_send_all) {
211 fab_send_erpt_all_rps(hdl, erpt);
212 nvlist_free(erpt);
213 return;
214 }
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2016 Jason King
25 */
26
27 #include <strings.h>
28 #include <fm/topo_hc.h>
29 #include <sys/fm/util.h>
30 #include <libxml/xpath.h>
31 #include <libxml/parser.h>
32 #include <libxml/xpathInternals.h>
33 #include <libxml/tree.h>
34 #include <sys/debug.h>
35
36 #include "fabric-xlate.h"
37
38 #define HAS_PROP(node, name) xmlHasProp(node, (const xmlChar *)name)
39 #define GET_PROP(node, name) ((char *)xmlGetProp(node, (const xmlChar *)name))
40 #define FREE_PROP(prop) xmlFree((xmlChar *)prop)
41
42 extern xmlXPathContextPtr fab_xpathCtx;
43
44 /* ARGSUSED */
45 int
46 fab_prep_basic_erpt(fmd_hdl_t *hdl, nvlist_t *nvl, nvlist_t *erpt,
47 boolean_t isRC)
48 {
49 uint64_t *now;
50 uint64_t ena;
51 uint_t nelem;
52 nvlist_t *detector, *new_detector;
53 char rcpath[255];
54 int err = 0;
170 goto done;
171 fmd_hdl_strfree(hdl, fmri);
172 } else {
173 fmd_hdl_debug(hdl,
174 "Cannot find Target FMRI addr:0x%llx bdf 0x%x\n",
175 tgt_addr, tgt_bdf);
176 }
177
178 return;
179 done:
180 if (fmri)
181 xmlFree(fmri);
182 fmd_hdl_debug(hdl, "Failed to send Target PCI ereport\n");
183 }
184
185 void
186 fab_send_erpt(fmd_hdl_t *hdl, fab_data_t *data, fab_err_tbl_t *tbl)
187 {
188 fab_erpt_tbl_t *erpt_tbl, *entry;
189 nvlist_t *erpt;
190 uintptr_t addr;
191 uint32_t reg;
192
193 erpt_tbl = tbl->erpt_tbl;
194 addr = (uintptr_t)data + tbl->reg_offset;
195
196 if (tbl->reg_size == 16) {
197 reg = (uint32_t)*((uint16_t *)addr);
198 } else {
199 ASSERT3U(tbl->reg_size, ==, 32);
200 reg = *((uint32_t *)addr);
201 }
202
203 for (entry = erpt_tbl; entry->err_class; entry++) {
204 if (!(reg & entry->reg_bit))
205 continue;
206
207 if (nvlist_alloc(&erpt, NV_UNIQUE_NAME, 0) != 0)
208 goto done;
209 if (tbl->fab_prep(hdl, data, erpt, entry) != 0) {
210 fmd_hdl_debug(hdl, "Prepping ereport failed: "
211 "class = %s\n", entry->err_class);
212 nvlist_free(erpt);
213 continue;
214 }
215
216 if (data->pcie_rp_send_all) {
217 fab_send_erpt_all_rps(hdl, erpt);
218 nvlist_free(erpt);
219 return;
220 }
|