Print this page
OS-1997 mpt_sas: expose LED controls to libtopo
Reviewed by: Keith Wesolowski <keith.wesolowski@joyent.com>


1359 
1360 
1361 static int
1362 fac_enum_process(topo_mod_t *mp, xmlNodePtr pn, tnode_t *ptn)
1363 {
1364         xmlNodePtr cn;
1365         xmlChar *fprov = NULL;
1366         int rv = 0;
1367 
1368         topo_dprintf(mp->tm_hdl, TOPO_DBG_XML,
1369             "fac_enum_process() called for %s=%d\n", topo_node_name(ptn),
1370             topo_node_instance(ptn));
1371 
1372         for (cn = pn->xmlChildrenNode; cn != NULL; cn = cn->next) {
1373 
1374                 if (xmlStrcmp(cn->name, (xmlChar *)"fac-enum") != 0)
1375                         continue;
1376 
1377                 if ((fprov = xmlGetProp(cn, (xmlChar *)Provider)) == NULL)
1378                         goto fenumdone;
1379 
1380                 if (xmlStrcmp(fprov, (xmlChar *)"fac_prov_ipmi") != 0) {
1381                         topo_dprintf(mp->tm_hdl, TOPO_DBG_XML,
1382                             "Invalid provider specified: %s\n", fprov);
1383                         goto fenumdone;
1384                 }
1385 
1386                 /*
1387                  * Invoke enum entry point in fac provider which will cause the
1388                  * facility enumeration node method to be registered.

1389                  */
1390                 if (fac_enum_run(mp, ptn, (const char *)fprov) != 0) {
1391                         topo_dprintf(mp->tm_hdl, TOPO_DBG_ERR,
1392                             "fac_enum_process: enum entry point failed!\n");
1393                         goto fenumdone;
1394                 }
1395                 xmlFree(fprov);
1396         }
1397         return (0);
1398 fenumdone:
1399         topo_dprintf(mp->tm_hdl, TOPO_DBG_XML, "fac-enum processing failed\n");
1400 
1401         if (fprov != NULL)
1402                 xmlFree(fprov);
1403 
1404         return (rv);
1405 }
1406 
1407 
1408 static int


1423 
1424                 if (xmlStrcmp(cn->name, (xmlChar *)Facility) != 0)
1425                         continue;
1426 
1427                 if ((fname = xmlGetProp(cn, (xmlChar *)Name)) == NULL)
1428                         goto facdone;
1429 
1430                 topo_dprintf(mp->tm_hdl, TOPO_DBG_XML,
1431                     "processing facility node '%s'\n", fname);
1432 
1433                 if ((ftype = xmlGetProp(cn, (xmlChar *)Type)) == NULL)
1434                         goto facdone;
1435 
1436                 if ((provider = xmlGetProp(cn, (xmlChar *)Provider)) == NULL)
1437                         goto facdone;
1438 
1439                 if (xmlStrcmp(ftype, (xmlChar *)Sensor) != 0 &&
1440                     xmlStrcmp(ftype, (xmlChar *)Indicator) != 0)
1441                         goto facdone;
1442 
1443                 if (xmlStrcmp(provider, (xmlChar *)"fac_prov_ipmi") != 0) {
1444                         topo_dprintf(mp->tm_hdl, TOPO_DBG_XML, "fac_process: "
1445                             "Invalid provider attr value: %s\n", provider);
1446                         goto facdone;
1447                 }
1448 
1449                 if ((ntn = topo_node_facbind(mp, ptn, (char *)fname,
1450                     (char *)ftype)) == NULL)
1451                         goto facdone;
1452 
1453                 pgi.tpi_name = TOPO_PGROUP_FACILITY;
1454                 pgi.tpi_namestab = TOPO_STABILITY_PRIVATE;
1455                 pgi.tpi_datastab = TOPO_STABILITY_PRIVATE;
1456                 pgi.tpi_version = 1;
1457                 if (topo_pgroup_create(ntn, &pgi, &err) != 0) {
1458                         if (err != ETOPO_PROP_DEFD) {
1459                                 topo_dprintf(mp->tm_hdl, TOPO_DBG_ERR,
1460                                     "pgroups create failure: %s\n",
1461                                     topo_strerror(err));
1462                                 return (-1);
1463                         }
1464                 }
1465                 /*
1466                  * Invoke enum entry point in fac_prov_ipmi module, which will
1467                  * cause the provider methods to be registered on this node

1468                  */
1469                 if (fac_enum_run(mp, ntn, (const char *)provider) != 0) {
1470                         topo_dprintf(mp->tm_hdl, TOPO_DBG_ERR, "fac_process: "
1471                             "enum entry point failed for provider %s!\n",
1472                             provider);
1473                         goto facdone;
1474                 }
1475 
1476                 if ((newi = tf_idata_new(mp, 0, ntn)) == NULL)
1477                         goto facdone;
1478 
1479                 if (tf_idata_insert(&rd->rd_instances, newi) < 0)
1480                         goto facdone;
1481 
1482                 if (pad_process(mp, rd, cn, ntn, &newi->ti_pad) < 0)
1483                         goto facdone;
1484 
1485                 topo_dprintf(mp->tm_hdl, TOPO_DBG_XML, "done with "
1486                     "facility %s=%s.\n", ftype, fname);
1487 




1359 
1360 
1361 static int
1362 fac_enum_process(topo_mod_t *mp, xmlNodePtr pn, tnode_t *ptn)
1363 {
1364         xmlNodePtr cn;
1365         xmlChar *fprov = NULL;
1366         int rv = 0;
1367 
1368         topo_dprintf(mp->tm_hdl, TOPO_DBG_XML,
1369             "fac_enum_process() called for %s=%d\n", topo_node_name(ptn),
1370             topo_node_instance(ptn));
1371 
1372         for (cn = pn->xmlChildrenNode; cn != NULL; cn = cn->next) {
1373 
1374                 if (xmlStrcmp(cn->name, (xmlChar *)"fac-enum") != 0)
1375                         continue;
1376 
1377                 if ((fprov = xmlGetProp(cn, (xmlChar *)Provider)) == NULL)
1378                         goto fenumdone;







1379                 /*
1380                  * Invoke enum entry point in facility provider which will
1381                  * cause the facility enumeration node method to be
1382                  * registered.
1383                  */
1384                 if (fac_enum_run(mp, ptn, (const char *)fprov) != 0) {
1385                         topo_dprintf(mp->tm_hdl, TOPO_DBG_ERR,
1386                             "fac_enum_process: enum entry point failed!\n");
1387                         goto fenumdone;
1388                 }
1389                 xmlFree(fprov);
1390         }
1391         return (0);
1392 fenumdone:
1393         topo_dprintf(mp->tm_hdl, TOPO_DBG_XML, "fac-enum processing failed\n");
1394 
1395         if (fprov != NULL)
1396                 xmlFree(fprov);
1397 
1398         return (rv);
1399 }
1400 
1401 
1402 static int


1417 
1418                 if (xmlStrcmp(cn->name, (xmlChar *)Facility) != 0)
1419                         continue;
1420 
1421                 if ((fname = xmlGetProp(cn, (xmlChar *)Name)) == NULL)
1422                         goto facdone;
1423 
1424                 topo_dprintf(mp->tm_hdl, TOPO_DBG_XML,
1425                     "processing facility node '%s'\n", fname);
1426 
1427                 if ((ftype = xmlGetProp(cn, (xmlChar *)Type)) == NULL)
1428                         goto facdone;
1429 
1430                 if ((provider = xmlGetProp(cn, (xmlChar *)Provider)) == NULL)
1431                         goto facdone;
1432 
1433                 if (xmlStrcmp(ftype, (xmlChar *)Sensor) != 0 &&
1434                     xmlStrcmp(ftype, (xmlChar *)Indicator) != 0)
1435                         goto facdone;
1436 






1437                 if ((ntn = topo_node_facbind(mp, ptn, (char *)fname,
1438                     (char *)ftype)) == NULL)
1439                         goto facdone;
1440 
1441                 pgi.tpi_name = TOPO_PGROUP_FACILITY;
1442                 pgi.tpi_namestab = TOPO_STABILITY_PRIVATE;
1443                 pgi.tpi_datastab = TOPO_STABILITY_PRIVATE;
1444                 pgi.tpi_version = 1;
1445                 if (topo_pgroup_create(ntn, &pgi, &err) != 0) {
1446                         if (err != ETOPO_PROP_DEFD) {
1447                                 topo_dprintf(mp->tm_hdl, TOPO_DBG_ERR,
1448                                     "pgroups create failure: %s\n",
1449                                     topo_strerror(err));
1450                                 return (-1);
1451                         }
1452                 }
1453                 /*
1454                  * Invoke enum entry point in the facility provider module,
1455                  * which will cause the provider methods to be registered on
1456                  * this node
1457                  */
1458                 if (fac_enum_run(mp, ntn, (const char *)provider) != 0) {
1459                         topo_dprintf(mp->tm_hdl, TOPO_DBG_ERR, "fac_process: "
1460                             "enum entry point failed for provider %s!\n",
1461                             provider);
1462                         goto facdone;
1463                 }
1464 
1465                 if ((newi = tf_idata_new(mp, 0, ntn)) == NULL)
1466                         goto facdone;
1467 
1468                 if (tf_idata_insert(&rd->rd_instances, newi) < 0)
1469                         goto facdone;
1470 
1471                 if (pad_process(mp, rd, cn, ntn, &newi->ti_pad) < 0)
1472                         goto facdone;
1473 
1474                 topo_dprintf(mp->tm_hdl, TOPO_DBG_XML, "done with "
1475                     "facility %s=%s.\n", ftype, fname);
1476