Skip to content

Commit

Permalink
9585 extend pcibus enumerator to expose driver instance as property o…
Browse files Browse the repository at this point in the history
…n pcifn/pciexfn nodes

Reviewed by: Igor Kozhukhov <[email protected]>
Reviewed by: Yuri Pankov <[email protected]>
Reviewed by: Ken Mays <[email protected]>
Approved by: Dan McDonald <[email protected]>
  • Loading branch information
Rob Johnston authored and Dan McDonald committed Jun 8, 2018
1 parent 8dff726 commit 73797b8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion usr/src/lib/fm/topo/libtopo/common/topo_hc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, Joyent, Inc.
* Copyright (c) 2018, Joyent, Inc.
*/

#ifndef _TOPO_HC_H
Expand Down Expand Up @@ -101,6 +101,7 @@ extern "C" {
#define TOPO_PGROUP_IO "io"
#define TOPO_IO_DEVTYPE "devtype"
#define TOPO_IO_DRIVER "driver"
#define TOPO_IO_INSTANCE "instance"
#define TOPO_IO_MODULE "module"
#define TOPO_IO_DEV "dev"
#define TOPO_IO_DEVID "devid"
Expand Down
22 changes: 22 additions & 0 deletions usr/src/lib/fm/topo/modules/common/pcibus/did_props.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ static int DEVprop_set(tnode_t *, did_t *,
const char *, const char *, const char *);
static int DRIVERprop_set(tnode_t *, did_t *,
const char *, const char *, const char *);
static int INSTprop_set(tnode_t *, did_t *,
const char *, const char *, const char *);
static int MODULEprop_set(tnode_t *, did_t *,
const char *, const char *, const char *);
static int EXCAP_set(tnode_t *, did_t *,
Expand Down Expand Up @@ -101,6 +103,7 @@ txprop_t Fn_common_props[] = {
{ DI_DEVTYPPROP, &io_pgroup, TOPO_IO_DEVTYPE, maybe_di_chars_copy },
{ DI_DEVIDPROP, &pci_pgroup, TOPO_PCI_DEVID, maybe_di_uint_to_str },
{ NULL, &io_pgroup, TOPO_IO_DRIVER, DRIVERprop_set },
{ NULL, &io_pgroup, TOPO_IO_INSTANCE, INSTprop_set },
{ NULL, &io_pgroup, TOPO_IO_MODULE, MODULEprop_set },
{ "serd_io_device_nonfatal_n", &io_pgroup, "serd_io_device_nonfatal_n",
maybe_di_uint_to_dec_str },
Expand Down Expand Up @@ -172,6 +175,7 @@ txprop_t Dev_common_props[] = {
txprop_t Bus_common_props[] = {
{ DI_DEVTYPPROP, &io_pgroup, TOPO_IO_DEVTYPE, maybe_di_chars_copy },
{ NULL, &io_pgroup, TOPO_IO_DRIVER, DRIVERprop_set },
{ NULL, &io_pgroup, TOPO_IO_INSTANCE, INSTprop_set },
{ NULL, &io_pgroup, TOPO_IO_MODULE, MODULEprop_set },
{ NULL, &protocol_pgroup, TOPO_PROP_LABEL, label_set },
{ NULL, &protocol_pgroup, TOPO_PROP_FRU, FRU_set },
Expand All @@ -182,6 +186,7 @@ txprop_t RC_common_props[] = {
{ NULL, &io_pgroup, TOPO_IO_DEV, DEVprop_set },
{ DI_DEVTYPPROP, &io_pgroup, TOPO_IO_DEVTYPE, maybe_di_chars_copy },
{ NULL, &io_pgroup, TOPO_IO_DRIVER, DRIVERprop_set },
{ NULL, &io_pgroup, TOPO_IO_INSTANCE, INSTprop_set },
{ NULL, &io_pgroup, TOPO_IO_MODULE, MODULEprop_set },
{ NULL, &pci_pgroup, TOPO_PCI_EXCAP, EXCAP_set },
{ NULL, &pci_pgroup, TOPO_PCI_BDF, BDF_set },
Expand Down Expand Up @@ -213,6 +218,7 @@ txprop_t IOB_common_props[] = {
txprop_t HB_common_props[] = {
{ NULL, &io_pgroup, TOPO_IO_DEV, DEVprop_set },
{ NULL, &io_pgroup, TOPO_IO_DRIVER, DRIVERprop_set },
{ NULL, &io_pgroup, TOPO_IO_INSTANCE, INSTprop_set },
{ NULL, &io_pgroup, TOPO_IO_MODULE, MODULEprop_set },
{ NULL, &protocol_pgroup, TOPO_PROP_ASRU, ASRU_set },
/*
Expand Down Expand Up @@ -776,6 +782,22 @@ DRIVERprop_set(tnode_t *tn, did_t *pd,
return (0);
}

/*ARGSUSED*/
static int
INSTprop_set(tnode_t *tn, did_t *pd,
const char *dpnm, const char *tpgrp, const char *tpnm)
{
int inst, err;

if ((inst = di_instance(did_dinode(pd))) == -1)
return (0);
if (topo_prop_set_uint32(tn,
tpgrp, tpnm, TOPO_PROP_IMMUTABLE, inst, &err) < 0)
return (topo_mod_seterrno(did_mod(pd), err));

return (0);
}

/*ARGSUSED*/
static int
MODULEprop_set(tnode_t *tn, did_t *pd,
Expand Down

0 comments on commit 73797b8

Please sign in to comment.