1*12eb87fbSAlex Wilson/*
2*12eb87fbSAlex Wilson * This file and its contents are supplied under the terms of the
3*12eb87fbSAlex Wilson * Common Development and Distribution License ("CDDL"), version 1.0.
4*12eb87fbSAlex Wilson * You may only use this file in accordance with the terms of version
5*12eb87fbSAlex Wilson * 1.0 of the CDDL.
6*12eb87fbSAlex Wilson *
7*12eb87fbSAlex Wilson * A full copy of the text of the CDDL should have accompanied this
8*12eb87fbSAlex Wilson * source.  A copy of the CDDL is also available via the Internet at
9*12eb87fbSAlex Wilson * http://www.illumos.org/license/CDDL.
10*12eb87fbSAlex Wilson */
11*12eb87fbSAlex Wilson/*
12*12eb87fbSAlex Wilson * Copyright 2020, the University of Queensland
13*12eb87fbSAlex Wilson */
14*12eb87fbSAlex Wilson
15*12eb87fbSAlex Wilson#pragma dictionary "NIC"
16*12eb87fbSAlex Wilson
17*12eb87fbSAlex Wilson/*
18*12eb87fbSAlex Wilson * Rules for the generic NIC (non-driver-specific) fault events.
19*12eb87fbSAlex Wilson */
20*12eb87fbSAlex Wilson
21*12eb87fbSAlex Wilson/*
22*12eb87fbSAlex Wilson * Transceiver events are emitted by drivers under ereport.io.nic.txr-err.
23*12eb87fbSAlex Wilson *
24*12eb87fbSAlex Wilson * These are emitted with detector = the PCI/PCIex function of the NIC.
25*12eb87fbSAlex Wilson * They must always have a string property "error", set to one of the
26*12eb87fbSAlex Wilson * generic transceiver fault type names (notsupp, whitelist, overtemp etc).
27*12eb87fbSAlex Wilson *
28*12eb87fbSAlex Wilson * As well as "error", they must have both the "port_index" and "txr_index"
29*12eb87fbSAlex Wilson * properties set in the event payload (both integer types).
30*12eb87fbSAlex Wilson *
31*12eb87fbSAlex Wilson * It is expected that drivers will call ddi_fm_service_impact() immediately
32*12eb87fbSAlex Wilson * after noticing a transceiver error, with an argument of DDI_SERVICE_LOST or
33*12eb87fbSAlex Wilson * DDI_SERVICE_DEGRADED (depending on the specific error -- at time of writing
34*12eb87fbSAlex Wilson * all the supported events expect DDI_SERVICE_LOST).
35*12eb87fbSAlex Wilson */
36*12eb87fbSAlex Wilson
37*12eb87fbSAlex Wilsonasru pcifn;
38*12eb87fbSAlex Wilsonfru  pcifn/port/transceiver;
39*12eb87fbSAlex Wilson
40*12eb87fbSAlex Wilsonasru pciexfn;
41*12eb87fbSAlex Wilsonfru  pciexfn/port/transceiver;
42*12eb87fbSAlex Wilson
43*12eb87fbSAlex Wilson#define	EV_DECL_TXR_FAULT(TYPE)		\
44*12eb87fbSAlex Wilson	event fault.io.nic.transceiver.TYPE@pcifn/port/transceiver \
45*12eb87fbSAlex Wilson	    FRU=pcifn/port/transceiver, ASRU=pcifn; \
46*12eb87fbSAlex Wilson	event fault.io.nic.transceiver.TYPE@pciexfn/port/transceiver \
47*12eb87fbSAlex Wilson	    FRU=pciexfn/port/transceiver, ASRU=pciexfn;
48*12eb87fbSAlex Wilson
49*12eb87fbSAlex WilsonEV_DECL_TXR_FAULT(notsupp)
50*12eb87fbSAlex WilsonEV_DECL_TXR_FAULT(whitelist)
51*12eb87fbSAlex WilsonEV_DECL_TXR_FAULT(overtemp)
52*12eb87fbSAlex WilsonEV_DECL_TXR_FAULT(hwfail)
53*12eb87fbSAlex WilsonEV_DECL_TXR_FAULT(unknown)
54*12eb87fbSAlex Wilson
55*12eb87fbSAlex Wilsonevent ereport.io.nic.txr-err@pcifn;
56*12eb87fbSAlex Wilsonevent ereport.io.service.lost@pcifn;
57*12eb87fbSAlex Wilson
58*12eb87fbSAlex Wilsonevent ereport.io.nic.txr-err@pciexfn;
59*12eb87fbSAlex Wilsonevent ereport.io.service.lost@pciexfn;
60*12eb87fbSAlex Wilson
61*12eb87fbSAlex Wilson#define	EV_PROP_TXR_FAULT(TYPE)		\
62*12eb87fbSAlex Wilson	prop fault.io.nic.transceiver.TYPE@pcifn/port[pn]/transceiver[tn] (2) -> \
63*12eb87fbSAlex Wilson	    ereport.io.nic.txr-err@pcifn { \
64*12eb87fbSAlex Wilson	      payloadprop("txr_index") == tn && \
65*12eb87fbSAlex Wilson	      payloadprop("port_index") == pn && \
66*12eb87fbSAlex Wilson	      payloadprop("error") == "TYPE" && \
67*12eb87fbSAlex Wilson	      setpayloadprop("txr_index", tn) && \
68*12eb87fbSAlex Wilson	      setpayloadprop("link-name", confprop(pcifn/port[pn], "link-name")) && \
69*12eb87fbSAlex Wilson	      setpayloadprop("primary-mac-address", confprop(pcifn/port[pn], "primary-mac-address")) && \
70*12eb87fbSAlex Wilson	      (!confprop_defined(pcifn/port[pn]/transceiver[tn], "vendor") || \
71*12eb87fbSAlex Wilson	       setpayloadprop("vendor", confprop(pcifn/port[pn]/transceiver[tn], "vendor"))) \
72*12eb87fbSAlex Wilson	    }, \
73*12eb87fbSAlex Wilson	    ereport.io.service.lost@pcifn { within(1s) }; \
74*12eb87fbSAlex Wilson	prop fault.io.nic.transceiver.TYPE@pciexfn/port[pn]/transceiver[tn] (2) -> \
75*12eb87fbSAlex Wilson	    ereport.io.nic.txr-err@pciexfn { \
76*12eb87fbSAlex Wilson	      payloadprop("txr_index") == tn && \
77*12eb87fbSAlex Wilson	      payloadprop("port_index") == pn && \
78*12eb87fbSAlex Wilson	      payloadprop("error") == "TYPE" && \
79*12eb87fbSAlex Wilson	      setpayloadprop("txr_index", tn) && \
80*12eb87fbSAlex Wilson	      setpayloadprop("link-name", confprop(pciexfn/port[pn], "link-name")) && \
81*12eb87fbSAlex Wilson	      setpayloadprop("primary-mac-address", confprop(pciexfn/port[pn], "primary-mac-address")) && \
82*12eb87fbSAlex Wilson	      (!confprop_defined(pciexfn/port[pn]/transceiver[tn], "vendor") || \
83*12eb87fbSAlex Wilson	       setpayloadprop("vendor", confprop(pciexfn/port[pn]/transceiver[tn], "vendor"))) \
84*12eb87fbSAlex Wilson	    }, \
85*12eb87fbSAlex Wilson	    ereport.io.service.lost@pciexfn { within(1s) };
86*12eb87fbSAlex Wilson
87*12eb87fbSAlex WilsonEV_PROP_TXR_FAULT(notsupp)
88*12eb87fbSAlex WilsonEV_PROP_TXR_FAULT(whitelist)
89*12eb87fbSAlex WilsonEV_PROP_TXR_FAULT(overtemp)
90*12eb87fbSAlex WilsonEV_PROP_TXR_FAULT(hwfail)
91*12eb87fbSAlex WilsonEV_PROP_TXR_FAULT(unknown)
92*12eb87fbSAlex Wilson
93*12eb87fbSAlex Wilson/*
94*12eb87fbSAlex Wilson * Allow drivers (e.g. i40e) which can't tell the difference between the events
95*12eb87fbSAlex Wilson * notsupp/unknown/whitelist to generate a single ereport covering all 3.
96*12eb87fbSAlex Wilson *
97*12eb87fbSAlex Wilson * If transceiver information is available in topo, we will turn it into
98*12eb87fbSAlex Wilson * a "notsupp" fault. If it isn't, we'll turn it into an "unknown" fault
99*12eb87fbSAlex Wilson * instead. The text in "notsupp" explicitly notes that certain drivers might
100*12eb87fbSAlex Wilson * have difficulty telling the difference between it and "whitelist".
101*12eb87fbSAlex Wilson *
102*12eb87fbSAlex Wilson * If you want this for a pcifn driver rather than pciexfn, you'll have to
103*12eb87fbSAlex Wilson * make another copy.
104*12eb87fbSAlex Wilson */
105*12eb87fbSAlex Wilsonprop fault.io.nic.transceiver.notsupp@pciexfn/port[pn]/transceiver[tn] (2) ->
106*12eb87fbSAlex Wilson    ereport.io.nic.txr-err@pciexfn {
107*12eb87fbSAlex Wilson      payloadprop("txr_index") == tn &&
108*12eb87fbSAlex Wilson      payloadprop("port_index") == pn &&
109*12eb87fbSAlex Wilson      payloadprop("error") == "notsupp/unknown" &&
110*12eb87fbSAlex Wilson      confprop_defined(pciexfn/port[pn]/transceiver[tn], "vendor") &&
111*12eb87fbSAlex Wilson      setpayloadprop("txr_index", tn) &&
112*12eb87fbSAlex Wilson      setpayloadprop("link-name", confprop(pciexfn/port[pn], "link-name")) &&
113*12eb87fbSAlex Wilson      setpayloadprop("primary-mac-address", confprop(pciexfn/port[pn], "primary-mac-address")) &&
114*12eb87fbSAlex Wilson      setpayloadprop("vendor", confprop(pciexfn/port[pn]/transceiver[tn], "vendor"))
115*12eb87fbSAlex Wilson    },
116*12eb87fbSAlex Wilson    ereport.io.service.lost@pciexfn { within(1s) };
117*12eb87fbSAlex Wilsonprop fault.io.nic.transceiver.unknown@pciexfn/port[pn]/transceiver[tn] (2) ->
118*12eb87fbSAlex Wilson    ereport.io.nic.txr-err@pciexfn {
119*12eb87fbSAlex Wilson      payloadprop("txr_index") == tn &&
120*12eb87fbSAlex Wilson      payloadprop("port_index") == pn &&
121*12eb87fbSAlex Wilson      payloadprop("error") == "notsupp/unknown" &&
122*12eb87fbSAlex Wilson      !confprop_defined(pciexfn/port[pn]/transceiver[tn], "vendor") &&
123*12eb87fbSAlex Wilson      setpayloadprop("txr_index", tn) &&
124*12eb87fbSAlex Wilson      setpayloadprop("link-name", confprop(pciexfn/port[pn], "link-name")) &&
125*12eb87fbSAlex Wilson      setpayloadprop("primary-mac-address", confprop(pciexfn/port[pn], "primary-mac-address"))
126*12eb87fbSAlex Wilson    },
127*12eb87fbSAlex Wilson    ereport.io.service.lost@pciexfn { within(1s) };
128