oem-meta: drop host-requested sled-wide power control

The power control command let a host ask for a sled cycle or a NIC power
cycle. Both act on hardware the requester shares with other hosts, and
the request says nothing about whether the sender may do that, so the
handler has no way to tell one request from another.

Remove both. What is left, the 12V and DC slot cycles, acts on the slot
derived from the sender's TID, so a host can still cycle itself.

Tested: builds clean. Not exercised on hardware.

Change-Id: I44e5256c179f2a0ad25471e632be0483aabd3c8b
Signed-off-by: Pete O_o <pmb@meta.com>
diff --git a/oem/meta/libpldmresponder/file_io_type_power_control.cpp b/oem/meta/libpldmresponder/file_io_type_power_control.cpp
index 55fe429..6c9fe81 100644
--- a/oem/meta/libpldmresponder/file_io_type_power_control.cpp
+++ b/oem/meta/libpldmresponder/file_io_type_power_control.cpp
@@ -13,15 +13,17 @@
 {
 
 uint8_t power_control_len = 1;
+
+/* The options a host may ask for. Options 0x00 (sled cycle) and 0x03..0x06
+ * (NIC power cycle) are deliberately absent: they act on hardware the
+ * requester shares with other hosts, and the request says nothing about
+ * whether the sender may do that, so they fall through to the default case
+ * and are rejected. What is left acts only on the requester's own slot.
+ */
 enum class POWER_CONTROL_OPTION
 {
-    SLED_CYCLE = 0x00,
     SLOT_12V_CYCLE = 0x01,
     SLOT_DC_CYCLE = 0x02,
-    NIC0_POWER_CYCLE = 0x03,
-    NIC1_POWER_CYCLE = 0x04,
-    NIC2_POWER_CYCLE = 0x05,
-    NIC3_POWER_CYCLE = 0x06,
 };
 
 int PowerControlHandler::write(const message& data)
@@ -41,14 +43,6 @@
     std::string property{};
     switch (option)
     {
-        case static_cast<uint8_t>(POWER_CONTROL_OPTION::SLED_CYCLE):
-            dbusMapping.objectPath =
-                std::string("/xyz/openbmc_project/state/chassis0");
-            dbusMapping.interface = "xyz.openbmc_project.State.Chassis";
-            dbusMapping.propertyName = "RequestedPowerTransition";
-            property =
-                "xyz.openbmc_project.State.Chassis.Transition.PowerCycle";
-            break;
         case static_cast<uint8_t>(POWER_CONTROL_OPTION::SLOT_12V_CYCLE):
             dbusMapping.objectPath =
                 std::string("/xyz/openbmc_project/state/chassis") + slotNum;
@@ -66,40 +60,10 @@
                 HostState::property_names::requested_host_transition;
             property = "xyz.openbmc_project.State.Host.Transition.Reboot";
             break;
-        case static_cast<uint8_t>(POWER_CONTROL_OPTION::NIC0_POWER_CYCLE):
-        case static_cast<uint8_t>(POWER_CONTROL_OPTION::NIC1_POWER_CYCLE):
-        case static_cast<uint8_t>(POWER_CONTROL_OPTION::NIC2_POWER_CYCLE):
-        case static_cast<uint8_t>(POWER_CONTROL_OPTION::NIC3_POWER_CYCLE):
-        {
-            static constexpr auto systemd_busname = "org.freedesktop.systemd1";
-            static constexpr auto systemd_path = "/org/freedesktop/systemd1";
-            static constexpr auto systemd_interface =
-                "org.freedesktop.systemd1.Manager";
-            uint8_t nic_index =
-                option -
-                static_cast<uint8_t>(POWER_CONTROL_OPTION::NIC0_POWER_CYCLE);
-            try
-            {
-                auto& bus = pldm::utils::DBusHandler::getBus();
-                auto method =
-                    bus.new_method_call(systemd_busname, systemd_path,
-                                        systemd_interface, "StartUnit");
-                method.append("nic-powercycle@" + std::to_string(nic_index) +
-                                  ".service",
-                              "replace");
-                bus.call_noreply(method);
-            }
-            catch (const std::exception& e)
-            {
-                error("Control NIC{NUM} power fail. ERROR={ERROR}", "NUM",
-                      nic_index, "ERROR", e);
-                return PLDM_ERROR;
-            }
-            return PLDM_SUCCESS;
-        }
         default:
-            error("Get invalid power control option, option={OPTION}", "OPTION",
-                  option);
+            error(
+                "Refusing power control option {OPTION} from TID {TID}, slot {SLOT}",
+                "OPTION", option, "TID", tid, "SLOT", slotNum);
             return PLDM_ERROR;
     }
 
diff --git a/oem/meta/libpldmresponder/file_io_type_power_control.hpp b/oem/meta/libpldmresponder/file_io_type_power_control.hpp
index f7e6c33..09f6ca8 100644
--- a/oem/meta/libpldmresponder/file_io_type_power_control.hpp
+++ b/oem/meta/libpldmresponder/file_io_type_power_control.hpp
@@ -8,7 +8,7 @@
 /** @class PowerControlHandler
  *
  *  @brief Inherits and implements FileHandler. This class is used
- *  to handle incoming sled cycle request from Hosts
+ *  to handle incoming slot power control requests from Hosts
  */
 class PowerControlHandler : public FileHandler
 {
@@ -27,12 +27,14 @@
     ~PowerControlHandler() override = default;
 
     /** @brief Method to add handler for write-file command
-     *         "SLED_CYCLE, 12V-CYCLE and DC-cycle" to let
-     *         Host can trigger power control to the system.
+     *         "12V-CYCLE and DC-cycle" to let a host trigger power
+     *         control on its own slot.
      *         - Option:
-     *             - 0x00: Sled-cycle
      *             - 0x01: Slot 12V-cycle
      *             - 0x02: Slot DC-cycle
+     *
+     *         Both act on the slot derived from the sender's TID, so a host
+     *         can only cycle itself. Any other option is rejected.
      *  @param[in] data - APML alert raw data.
      *  @return  PLDM completion code.
      */