static int maybe_di_uint_to_dec_str(tnode_t *tn, did_t *pd, const char *dpnm, const char *tpgrp, const char *tpnm) { uint_t v; if (di_uintprop_get(did_mod(pd), did_dinode(pd), dpnm, &v) < 0) return (0); return (uint_to_dec_strprop(did_mod(pd), v, tn, tpgrp, tpnm)); }
/*ARGSUSED*/ static int maybe_pcidb_set(tnode_t *tn, did_t *pd, const char *dpnm, const char *tpgrp, const char *tpnm) { const char *vname, *dname = NULL, *ssname = NULL; uint_t vid, pid, svid, ssid; pcidb_vendor_t *pciv; pcidb_device_t *pcid; pcidb_subvd_t *pcis = NULL; pcidb_hdl_t *pcih; topo_mod_t *mod = did_mod(pd); int err; /* * At a minimum, we need the vid/devid of the device to be able to * lookup anything in the PCI database. So if we fail to look either * of those up, bail out. */ if (di_uintprop_get(did_mod(pd), did_dinode(pd), DI_VENDIDPROP, &vid) < 0 || di_uintprop_get(did_mod(pd), did_dinode(pd), DI_DEVIDPROP, &pid) < 0) { return (0); } /* * If we fail to lookup the vendor, by the vid that's also a * deal-breaker. */ if ((pcih = topo_mod_pcidb(mod)) == NULL || (pciv = pcidb_lookup_vendor(pcih, vid)) == NULL) { return (0); } /* lookup vendor-name and set the topo property, if found */ vname = pcidb_vendor_name(pciv); if (vname != NULL && topo_prop_set_string(tn, tpgrp, TOPO_PCI_VENDNM, TOPO_PROP_IMMUTABLE, vname, &err) != 0) { return (topo_mod_seterrno(mod, err)); } /* lookup device-name and set the topo property, if found */ if ((pcid = pcidb_lookup_device_by_vendor(pciv, pid)) != NULL) { dname = pcidb_device_name(pcid); } if (dname != NULL && topo_prop_set_string(tn, tpgrp, TOPO_PCI_DEVNM, TOPO_PROP_IMMUTABLE, dname, &err) != 0) { return (topo_mod_seterrno(mod, err)); } /* * Not all devices will have a subsystem-name that we can lookup, * but if both subsystem-vendorid and subsystem-id exist in devinfo and * if we were previously able to find the device by devid then we can * at least attempt a lookup. If found, set the topo property. */ if (pcid != NULL && di_uintprop_get(did_mod(pd), did_dinode(pd), DI_SUBVENDIDPROP, &svid) == 0 && di_uintprop_get(did_mod(pd), did_dinode(pd), DI_SUBSYSTEMID, &ssid) == 0) { pcis = pcidb_lookup_subvd_by_device(pcid, svid, ssid); } if (pcis != NULL) { ssname = pcidb_subvd_name(pcis); } if (ssname != NULL && strlen(ssname) > 0 && topo_prop_set_string(tn, tpgrp, TOPO_PCI_SUBSYSNM, TOPO_PROP_IMMUTABLE, ssname, &err) != 0) { return (topo_mod_seterrno(mod, err)); } return (0); }