pcidb_subvd_t * pcidb_lookup_subvd_by_vendor(pcidb_vendor_t *v, uint16_t devid, uint16_t svid, uint16_t sdid) { pcidb_device_t *d; assert(v != NULL); d = pcidb_lookup_device_by_vendor(v, devid); if (d == NULL) return (NULL); return (pcidb_lookup_subvd_by_device(d, svid, sdid)); }
pcidb_subvd_t * pcidb_lookup_subvd(pcidb_hdl_t *h, uint16_t vid, uint16_t did, uint16_t svid, uint16_t sdid) { pcidb_device_t *d; assert(h != NULL); d = pcidb_lookup_device(h, vid, did); if (d == NULL) return (NULL); return (pcidb_lookup_subvd_by_device(d, svid, sdid)); }
static void print_arg(void) { pcidb_vendor_t *v; pcidb_device_t *d; pcidb_subvd_t *s; const char *vend, *dev, *sub; vend = NULL; dev = NULL; sub = NULL; assert(g_case != L_INVALID); v = pcidb_lookup_vendor(g_hdl, g_vid); if (v == NULL) fatal("unknown vendor id: %04x\n", g_vid); vend = pcidb_vendor_name(v); if (g_case == L_VENDOR) goto print; d = pcidb_lookup_device_by_vendor(v, g_did); if (d == NULL) fatal("unknown device id: %04x\n", g_did); dev = pcidb_device_name(d); if (g_case == L_DEVICE) goto print; s = pcidb_lookup_subvd_by_device(d, g_svid, g_sdid); if (s == NULL) fatal("uknown sub-vendor and sub-device id: %04x.%04x\n", g_svid, g_sdid); sub = pcidb_subvd_name(s); print: if (vend != NULL) printf("%s", vend); if (dev != NULL) printf("|%s", dev); if (sub != NULL) printf("|%s", sub); printf("\n"); }
/*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); }