7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER START
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The contents of this file are subject to the terms of the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Common Development and Distribution License (the "License").
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You may not use this file except in compliance with the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * See the License for the specific language governing permissions
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * and limitations under the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * When distributing Covered Code, include this CDDL HEADER in each
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * If applicable, add the following below this CDDL HEADER, with the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * fields enclosed by brackets "[]" replaced with your own identifying
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * information: Portions Copyright [yyyy] [name of copyright owner]
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER END
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Use is subject to license terms.
29493bd8e037cbaea9095b34172305abb589cb6bvn { TOPO_PGROUP_IO, TOPO_STABILITY_PRIVATE, TOPO_STABILITY_PRIVATE, 1 };
29493bd8e037cbaea9095b34172305abb589cb6bvn { TOPO_PGROUP_PCI, TOPO_STABILITY_PRIVATE, TOPO_STABILITY_PRIVATE, 1 };
29493bd8e037cbaea9095b34172305abb589cb6bvn * get_rcs()
29493bd8e037cbaea9095b34172305abb589cb6bvn * Description:
29493bd8e037cbaea9095b34172305abb589cb6bvn * Return a list of PX instances in the dev tree.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /* Scan for buses, top-level devinfo nodes with the right driver */
29493bd8e037cbaea9095b34172305abb589cb6bvn * find_dnode()
29493bd8e037cbaea9095b34172305abb589cb6bvn * Description:
29493bd8e037cbaea9095b34172305abb589cb6bvn * Find the dev pointer of a rc given its bus address, ba
29493bd8e037cbaea9095b34172305abb589cb6bvn return (p->br_din);
29493bd8e037cbaea9095b34172305abb589cb6bvn * hb_tnode_create()
29493bd8e037cbaea9095b34172305abb589cb6bvn * Description:
29493bd8e037cbaea9095b34172305abb589cb6bvn * Create a topo node
29493bd8e037cbaea9095b34172305abb589cb6bvnhb_tnode_create(topo_mod_t *mod, tnode_t *parent, const char *name,
29493bd8e037cbaea9095b34172305abb589cb6bvn /* Create FMRI */
29493bd8e037cbaea9095b34172305abb589cb6bvn if ((fmri = topo_mod_hcfmri(mod, parent, FM_HC_SCHEME_VERSION, name,
29493bd8e037cbaea9095b34172305abb589cb6bvn topo_mod_dprintf(mod, "create of tnode for %s failed: %s\n",
29493bd8e037cbaea9095b34172305abb589cb6bvn /* Create and bind node */
29493bd8e037cbaea9095b34172305abb589cb6bvn /* Inherit the parent 's FRU and label */
29493bd8e037cbaea9095b34172305abb589cb6bvn * platform_pciexhostbridge_declare()
29493bd8e037cbaea9095b34172305abb589cb6bvn * Description:
29493bd8e037cbaea9095b34172305abb589cb6bvn * This is a sun4v specific function to create the hostbridge topo node.
29493bd8e037cbaea9095b34172305abb589cb6bvnplatform_pciexhostbridge_declare(topo_mod_t *mod, tnode_t *parent,
29493bd8e037cbaea9095b34172305abb589cb6bvn topo_mod_dprintf(mod, "Create node %s=%d\n", HOSTBRIDGE, inst);
29493bd8e037cbaea9095b34172305abb589cb6bvn hbn = hb_tnode_create(mod, parent, HOSTBRIDGE, inst, priv);
29493bd8e037cbaea9095b34172305abb589cb6bvn /* Make room for children */
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) topo_node_range_create(mod, hbn, PCIEX_ROOT, 0, MAX_HB_BUSES);
29493bd8e037cbaea9095b34172305abb589cb6bvn * platform_pciexhostbridge_declare()
29493bd8e037cbaea9095b34172305abb589cb6bvn * Description:
29493bd8e037cbaea9095b34172305abb589cb6bvn * This is a sun4v specific function to create a root complex topo node,
29493bd8e037cbaea9095b34172305abb589cb6bvn * but do not enumerate its pci buses.
29493bd8e037cbaea9095b34172305abb589cb6bvnplatform_pciexrc_declare(topo_mod_t *mod, tnode_t *parent, int inst,
29493bd8e037cbaea9095b34172305abb589cb6bvn topo_mod_dprintf(mod, "Create node %s=%d\n", PCIEX_ROOT, inst);
29493bd8e037cbaea9095b34172305abb589cb6bvn rcn = hb_tnode_create(mod, parent, PCIEX_ROOT, inst, NULL);
29493bd8e037cbaea9095b34172305abb589cb6bvn /* Set ASRU to be the dev-scheme asru */
29493bd8e037cbaea9095b34172305abb589cb6bvn (void) snprintf(dnpath, sizeof (dnpath), "/pci@%llx", ba);
29493bd8e037cbaea9095b34172305abb589cb6bvn fmri = topo_mod_devfmri(mod, FM_DEV_SCHEME_VERSION, dnpath, NULL);
29493bd8e037cbaea9095b34172305abb589cb6bvn topo_mod_dprintf(mod, "dev:///%s fmri creation failed.\n",
29493bd8e037cbaea9095b34172305abb589cb6bvn * Set properties of the root complex node pciexrc
29493bd8e037cbaea9095b34172305abb589cb6bvn /* Add the io and pci property groups */
29493bd8e037cbaea9095b34172305abb589cb6bvn topo_mod_dprintf(mod, "topo_pgroup_create(iogrp) failed\n");
29493bd8e037cbaea9095b34172305abb589cb6bvn topo_mod_dprintf(mod, "topo_pgroup_create(pcigrp) failed\n");
29493bd8e037cbaea9095b34172305abb589cb6bvn /* Add the devfs path property */
29493bd8e037cbaea9095b34172305abb589cb6bvn if (topo_prop_set_string(rcn, TOPO_PGROUP_IO, TOPO_IO_DEV,
29493bd8e037cbaea9095b34172305abb589cb6bvn /* for sun4v, device type is always pciex */
29493bd8e037cbaea9095b34172305abb589cb6bvn if (topo_prop_set_string(rcn, TOPO_PGROUP_IO, TOPO_IO_DEVTYPE,
29493bd8e037cbaea9095b34172305abb589cb6bvn /* sun4v rc driver is always "px" */
29493bd8e037cbaea9095b34172305abb589cb6bvn if (topo_prop_set_string(rcn, TOPO_PGROUP_IO, TOPO_IO_DRIVER,
29493bd8e037cbaea9095b34172305abb589cb6bvn if ((fmri = topo_mod_modfmri(mod, FM_MOD_SCHEME_VERSION, PX)) == NULL ||
29493bd8e037cbaea9095b34172305abb589cb6bvn /* This is a PCIEX Root Complex */
29493bd8e037cbaea9095b34172305abb589cb6bvn if (topo_prop_set_string(rcn, TOPO_PGROUP_PCI, TOPO_PCI_EXCAP,
29493bd8e037cbaea9095b34172305abb589cb6bvn /* Make room for children */
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) topo_node_range_create(mod, rcn, PCIEX_BUS, 0, MAX_HB_BUSES);
29493bd8e037cbaea9095b34172305abb589cb6bvn * platform_hb_enum()
29493bd8e037cbaea9095b34172305abb589cb6bvn * Description:
29493bd8e037cbaea9095b34172305abb589cb6bvn * This is an entry function to enumerate the sun4v hostbridges. First, it
29493bd8e037cbaea9095b34172305abb589cb6bvn * reads the hostbridges and their pciexrc root complexes from the PRI or
29493bd8e037cbaea9095b34172305abb589cb6bvn * For the current sun4v platforms, it is assummed that there is only one
29493bd8e037cbaea9095b34172305abb589cb6bvn * hostbridge. All the pciex root complexes belong to this single hostbridge.
29493bd8e037cbaea9095b34172305abb589cb6bvn * Given the hostbridge/pciexrc information, this enumerator creates the
29493bd8e037cbaea9095b34172305abb589cb6bvn * the hostbridge topo node and pciexrc nodes. If the domain owns the
29493bd8e037cbaea9095b34172305abb589cb6bvn * the root complex, it uses the common hostbridge code to enumerate the
29493bd8e037cbaea9095b34172305abb589cb6bvn * pcibus. If not, it simply create the hostbridge/pciexrc nodes without the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*ARGSUSED*/
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiplatform_hb_enum(topo_mod_t *mod, tnode_t *parent, const char *name,
29493bd8e037cbaea9095b34172305abb589cb6bvn topo_mod_dprintf(mod, "Invalid hb range(%d,%d)\n", imin, imax);
29493bd8e037cbaea9095b34172305abb589cb6bvn return (-1);
29493bd8e037cbaea9095b34172305abb589cb6bvn /* get the hostbrige and rootcomplex information in the PRI/MD */
29493bd8e037cbaea9095b34172305abb589cb6bvn topo_mod_dprintf(mod, "failed to get hb from the PRI/MD\n");
29493bd8e037cbaea9095b34172305abb589cb6bvn return (-1);
29493bd8e037cbaea9095b34172305abb589cb6bvn /* count the number of hb and rc in the PRI/MD */
29493bd8e037cbaea9095b34172305abb589cb6bvn topo_mod_dprintf(mod, "No hostbridge or pciex bus is found\n");
29493bd8e037cbaea9095b34172305abb589cb6bvn return (0);
29493bd8e037cbaea9095b34172305abb589cb6bvn hbnode = topo_mod_zalloc(mod, hbmd.shbs * sizeof (tnode_t *));
29493bd8e037cbaea9095b34172305abb589cb6bvn rcnode = topo_mod_zalloc(mod, nrcs * sizeof (tnode_t *));
29493bd8e037cbaea9095b34172305abb589cb6bvn /* process the hostbridge */
29493bd8e037cbaea9095b34172305abb589cb6bvn * If this hb has a rc in the dev tree, use the common code to
29493bd8e037cbaea9095b34172305abb589cb6bvn * create a hostbridge node
29493bd8e037cbaea9095b34172305abb589cb6bvn /* platformm specific */
29493bd8e037cbaea9095b34172305abb589cb6bvn * Create the pciexrc nodes under the hostbridge node
29493bd8e037cbaea9095b34172305abb589cb6bvn * If a rc exists in the dev tree, use the common code to
29493bd8e037cbaea9095b34172305abb589cb6bvn * create a pciexrc node and enumerate the fabric.
29493bd8e037cbaea9095b34172305abb589cb6bvn * Otherwise, only create the pciexrc node.
29493bd8e037cbaea9095b34172305abb589cb6bvn /* declare a pciexrc and enumerate its pcibus */
29493bd8e037cbaea9095b34172305abb589cb6bvn /* only declare the pciexrc */
29493bd8e037cbaea9095b34172305abb589cb6bvn /* failure: unbind all hb and rc tnodes */
29493bd8e037cbaea9095b34172305abb589cb6bvn if (err != 0) {
29493bd8e037cbaea9095b34172305abb589cb6bvn for (i = 0; i < nhbnode; i++)
29493bd8e037cbaea9095b34172305abb589cb6bvn for (i = 0; i < nrcnode; i++)
29493bd8e037cbaea9095b34172305abb589cb6bvn topo_mod_free(mod, hbnode, hbmd.shbs * sizeof (tnode_t *));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*ARGSUSED*/