diff options
author | 2018-06-08 07:14:02 +0000 | |
---|---|---|
committer | 2018-06-08 07:14:02 +0000 | |
commit | 22ebd35f906ff64d3a3c3ff02d5c93bc570f1585 (patch) | |
tree | 2831e72ad86268d7f41347e3e97280879fc3d534 | |
parent | Rework sensors and bio(4) support to use the target number from the logical (diff) | |
download | wireguard-openbsd-22ebd35f906ff64d3a3c3ff02d5c93bc570f1585.tar.xz wireguard-openbsd-22ebd35f906ff64d3a3c3ff02d5c93bc570f1585.zip |
Handle AENs for logical disk creation and deletion.
SAS3 and newer controllers allow these operations at any time
through the server management interface - tested on a SAS3108
(Lenovo x3650 M5) and SAS3508 (Dell R6415).
ok dlg@
-rw-r--r-- | sys/dev/pci/mfii.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/sys/dev/pci/mfii.c b/sys/dev/pci/mfii.c index e28f7c341f9..d3ac5475a43 100644 --- a/sys/dev/pci/mfii.c +++ b/sys/dev/pci/mfii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfii.c,v 1.56 2018/06/08 07:09:50 jmatthew Exp $ */ +/* $OpenBSD: mfii.c,v 1.57 2018/06/08 07:14:02 jmatthew Exp $ */ /* * Copyright (c) 2012 David Gwynne <dlg@openbsd.org> @@ -465,6 +465,7 @@ void mfii_aen_pd_remove(struct mfii_softc *, const struct mfi_evtarg_pd_address *); void mfii_aen_pd_state_change(struct mfii_softc *, const struct mfi_evtarg_pd_state *); +void mfii_aen_ld_update(struct mfii_softc *); #if NBIO > 0 int mfii_ioctl(struct device *, u_long, caddr_t); @@ -1186,6 +1187,11 @@ mfii_aen(void *arg) mfii_aen_pd_state_change(sc, &med->args.pd_state); break; + case MFI_EVT_LD_CREATED: + case MFI_EVT_LD_DELETED: + mfii_aen_ld_update(sc); + break; + default: break; } @@ -1260,6 +1266,60 @@ mfii_aen_pd_state_change(struct mfii_softc *sc, } void +mfii_aen_ld_update(struct mfii_softc *sc) +{ + int i, state, target, old, nld; + int newlds[MFI_MAX_LD]; + + if (mfii_mgmt(sc, MR_DCMD_LD_GET_LIST, NULL, &sc->sc_ld_list, + sizeof(sc->sc_ld_list), SCSI_DATA_IN) != 0) { + DNPRINTF(MFII_D_MISC, "%s: getting list of logical disks failed\n", + DEVNAME(sc)); + return; + } + + memset(newlds, -1, sizeof(newlds)); + + for (i = 0; i < sc->sc_ld_list.mll_no_ld; i++) { + state = sc->sc_ld_list.mll_list[i].mll_state; + target = sc->sc_ld_list.mll_list[i].mll_ld.mld_target; + DNPRINTF(MFII_D_MISC, "%s: target %d: state %d\n", + DEVNAME(sc), target, state); + newlds[target] = i; + } + + for (i = 0; i < MFI_MAX_LD; i++) { + old = sc->sc_target_lds[i]; + nld = newlds[i]; + + if (old == -1 && nld != -1) { + DNPRINTF(MFII_D_MISC, "%s: attaching target %d\n", + DEVNAME(sc), i); + + scsi_probe_target(sc->sc_scsibus, i); + +#ifndef SMALL_KERNEL + mfii_init_ld_sensor(sc, nld); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensors[i]); +#endif + } else if (nld == -1 && old != -1) { + DNPRINTF(MFII_D_MISC, "%s: detaching target %d\n", + DEVNAME(sc), i); + + scsi_activate(sc->sc_scsibus, i, -1, + DVACT_DEACTIVATE); + scsi_detach_target(sc->sc_scsibus, i, + DETACH_FORCE); +#ifndef SMALL_KERNEL + sensor_detach(&sc->sc_sensordev, &sc->sc_sensors[i]); +#endif + } + } + + memcpy(sc->sc_target_lds, newlds, sizeof(sc->sc_target_lds)); +} + +void mfii_aen_unregister(struct mfii_softc *sc) { /* XXX */ |