Print this page
OS-2444 richmond hardware maps need to support ivy bridge

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/fm/topo/modules/common/fac_prov_mptsas/fac_prov_mptsas.c
          +++ new/usr/src/lib/fm/topo/modules/common/fac_prov_mptsas/fac_prov_mptsas.c
↓ open down ↓ 64 lines elided ↑ open up ↑
  65   65  
  66   66          return (topo_mod_register(mod, &mptsas_info, TOPO_VERSION));
  67   67  }
  68   68  
  69   69  void
  70   70  _topo_fini(topo_mod_t *mod)
  71   71  {
  72   72          topo_mod_unregister(mod);
  73   73  }
  74   74  
       75 +/*
       76 + * Get or set LED state for a particular target attached to an mpt_sas
       77 + * instance at (Enclosure Number, Slot Number).
       78 + *
       79 + * Returns:
       80 + *   -2  /devices node (*devctl) does not exist
       81 + *   -1  All other failures
       82 + *    0  Success
       83 + */
  75   84  static int
  76   85  do_led_control(topo_mod_t *mod, char *devctl, uint16_t enclosure,
  77   86      uint16_t slot, uint8_t led, uint32_t *ledmode, boolean_t set)
  78   87  {
  79   88          int fd;
  80   89          mptsas_led_control_t lc;
  81   90  
  82   91          bzero(&lc, sizeof (lc));
  83   92  
  84   93          lc.Command = set ? MPTSAS_LEDCTL_FLAG_SET : MPTSAS_LEDCTL_FLAG_GET;
  85   94          lc.Enclosure = enclosure;
  86   95          lc.Slot = slot;
  87   96          lc.Led = led;
  88   97          lc.LedStatus = *ledmode;
  89   98  
  90   99          if ((fd = open(devctl, (set ? O_RDWR : O_RDONLY))) == -1) {
      100 +                int rc = (errno == ENOENT ? -2 : -1);
  91  101                  topo_mod_dprintf(mod, "devctl open failed: %s",
  92  102                      strerror(errno));
  93      -                return (-1);
      103 +                return (rc);
  94  104          }
  95  105  
  96  106          if (ioctl(fd, MPTIOCTL_LED_CONTROL, &lc) == -1) {
  97  107                  if (errno == ENOENT) {
  98  108                          /*
  99  109                           * If there is not presently a target attached for
 100  110                           * a particular enclosure/slot pair then the driver
 101  111                           * does not track LED status for this bay.  Assume
 102  112                           * all LEDs are off.
 103  113                           */
↓ open down ↓ 17 lines elided ↑ open up ↑
 121  131      nvlist_t *in, nvlist_t **nvout)
 122  132  {
 123  133          int err, ret = 0;
 124  134          tnode_t *pnode = topo_node_parent(node);
 125  135          uint32_t type, ledmode = 0;
 126  136          nvlist_t *pargs, *nvl;
 127  137          char *driver = NULL, *devctl = NULL;
 128  138          uint32_t enclosure, slot;
 129  139          uint8_t mptsas_led;
 130  140          boolean_t set;
      141 +        char *elem, *lastp;
 131  142  
 132  143          if (vers > TOPO_METH_MPTSAS_LED_MODE_VERSION)
 133  144                  return (topo_mod_seterrno(mod, ETOPO_METHOD_VERNEW));
 134  145  
 135  146          if (topo_prop_get_string(pnode, TOPO_PGROUP_BINDING,
 136  147              TOPO_BINDING_DRIVER, &driver, &err) != 0 ||
 137  148              strcmp("mpt_sas", driver) != 0) {
 138  149                  topo_mod_dprintf(mod, "%s: Facility driver was not mpt_sas",
 139  150                      __func__);
 140  151                  ret = topo_mod_seterrno(mod, EMOD_NVL_INVAL);
↓ open down ↓ 49 lines elided ↑ open up ↑
 190  201                  topo_mod_dprintf(mod, "%s: Setting LED mode to %s\n", __func__,
 191  202                      ledmode ? "ON" : "OFF");
 192  203          } else {
 193  204                  /*
 194  205                   * Get the LED mode
 195  206                   */
 196  207                  set = B_FALSE;
 197  208                  topo_mod_dprintf(mod, "%s: Getting LED mode\n", __func__);
 198  209          }
 199  210  
 200      -        if (do_led_control(mod, devctl, enclosure, slot, mptsas_led, &ledmode,
 201      -            set) != 0) {
      211 +        /*
      212 +         * devctl is a (potentially) pipe-separated list of different device
      213 +         * paths to try.
      214 +         */
      215 +        if ((elem = topo_mod_strsplit(mod, devctl, "|", &lastp)) == NULL) {
      216 +                topo_mod_dprintf(mod, "%s: could not parse devctl list",
      217 +                    __func__);
      218 +                ret = topo_mod_seterrno(mod, EMOD_UNKNOWN);
      219 +                goto out;
      220 +        }
      221 +        do {
      222 +                topo_mod_dprintf(mod, "%s: trying mpt_sas instance at %s\n",
      223 +                    __func__, elem);
      224 +
      225 +                ret = do_led_control(mod, elem, enclosure, slot,
      226 +                    mptsas_led, &ledmode, set);
      227 +
      228 +                topo_mod_strfree(mod, elem);
      229 +
      230 +                /*
      231 +                 * Only try further devctl paths from the list if this one
      232 +                 * was not found:
      233 +                 */
      234 +                if (ret != -2) {
      235 +                        break;
      236 +                } else {
      237 +                        topo_mod_dprintf(mod, "%s: instance not found\n",
      238 +                            __func__);
      239 +                }
      240 +
      241 +        } while ((elem = topo_mod_strsplit(mod, NULL, "|", &lastp)) != NULL);
      242 +
      243 +        if (ret != 0) {
 202  244                  topo_mod_dprintf(mod, "%s: do_led_control failed", __func__);
 203  245                  ret = topo_mod_seterrno(mod, EMOD_UNKNOWN);
 204  246                  goto out;
 205  247          }
 206  248  
 207  249          if (topo_mod_nvalloc(mod, &nvl, NV_UNIQUE_NAME) != 0 ||
 208  250              nvlist_add_string(nvl, TOPO_PROP_VAL_NAME, TOPO_LED_MODE) != 0 ||
 209  251              nvlist_add_uint32(nvl, TOPO_PROP_VAL_TYPE, TOPO_TYPE_UINT32) != 0 ||
 210  252              nvlist_add_uint32(nvl, TOPO_PROP_VAL_VAL, ledmode) != 0) {
 211  253                  topo_mod_dprintf(mod, "%s: Failed to allocate 'out' nvlist\n",
↓ open down ↓ 33 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX