diff options
author | 2016-10-24 01:50:09 +0000 | |
---|---|---|
committer | 2016-10-24 01:50:09 +0000 | |
commit | 23646fe4ceb8a3404ee885160b43dcb4d085400b (patch) | |
tree | e58dc82d3cc90f94c9fe0aee6a86706911490a44 /sys/dev/pci | |
parent | Remove dead breaks, found via opencoverage.net. ok deraadt@ (diff) | |
download | wireguard-openbsd-23646fe4ceb8a3404ee885160b43dcb4d085400b.tar.xz wireguard-openbsd-23646fe4ceb8a3404ee885160b43dcb4d085400b.zip |
augment the scsi_probe handler so it tries to query the sas dev pg 0
sas dev pg0 tells us interesting things, like the devices sas addresses
and if it is ATAPI or not.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/mpii.c | 40 | ||||
-rw-r--r-- | sys/dev/pci/mpiireg.h | 9 |
2 files changed, 43 insertions, 6 deletions
diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c index fc5e5ae9fc8..24c6dc84593 100644 --- a/sys/dev/pci/mpii.c +++ b/sys/dev/pci/mpii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpii.c,v 1.106 2016/10/21 05:38:53 dlg Exp $ */ +/* $OpenBSD: mpii.c,v 1.107 2016/10/24 01:50:09 dlg Exp $ */ /* * Copyright (c) 2010, 2012 Mike Belopuhov * Copyright (c) 2009 James Giannoules @@ -869,20 +869,50 @@ mpii_load_xs(struct mpii_ccb *ccb) int mpii_scsi_probe(struct scsi_link *link) { - struct mpii_softc *sc = link->adapter_softc; - int flags; + struct mpii_softc *sc = link->adapter_softc; + struct mpii_cfg_sas_dev_pg0 pg0; + struct mpii_ecfg_hdr ehdr; + struct mpii_device *dev; + uint32_t address; + int flags; if ((sc->sc_porttype != MPII_PORTFACTS_PORTTYPE_SAS_PHYSICAL) && (sc->sc_porttype != MPII_PORTFACTS_PORTTYPE_SAS_VIRTUAL)) return (ENXIO); - if (sc->sc_devs[link->target] == NULL) + dev = sc->sc_devs[link->target]; + if (dev == NULL) return (1); - flags = sc->sc_devs[link->target]->flags; + flags = dev->flags; if (ISSET(flags, MPII_DF_HIDDEN) || ISSET(flags, MPII_DF_UNUSED)) return (1); + memset(&ehdr, 0, sizeof(ehdr)); + ehdr.page_type = MPII_CONFIG_REQ_PAGE_TYPE_EXTENDED; + ehdr.page_number = 0; + ehdr.page_version = 0; + ehdr.ext_page_type = MPII_CONFIG_REQ_EXTPAGE_TYPE_SAS_DEVICE; + ehdr.ext_page_length = htole16(sizeof(pg0) / 4); /* dwords */ + + address = MPII_PGAD_SAS_DEVICE_FORM_HANDLE | (uint32_t)dev->dev_handle; + if (mpii_req_cfg_page(sc, address, MPII_PG_EXTENDED, + &ehdr, 1, &pg0, sizeof(pg0)) != 0) { + printf("%s: unable to fetch SAS device page 0 for target %u\n", + DEVNAME(sc), link->target); + + return (0); /* the handle should still work */ + } + + link->port_wwn = letoh64(pg0.sas_addr); + link->node_wwn = letoh64(pg0.device_name); + + if (ISSET(lemtoh32(&pg0.device_info), + MPII_CFG_SAS_DEV_0_DEVINFO_ATAPI_DEVICE)) { + link->flags |= SDEV_ATAPI; + link->quirks |= SDEV_ONLYBIG; + } + return (0); } diff --git a/sys/dev/pci/mpiireg.h b/sys/dev/pci/mpiireg.h index 79bc8d4d840..5131c4f75c3 100644 --- a/sys/dev/pci/mpiireg.h +++ b/sys/dev/pci/mpiireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mpiireg.h,v 1.10 2016/09/14 01:14:54 jmatthew Exp $ */ +/* $OpenBSD: mpiireg.h,v 1.11 2016/10/24 01:50:09 dlg Exp $ */ /* * Copyright (c) 2010 Mike Belopuhov * Copyright (c) 2009 James Giannoules @@ -1059,6 +1059,13 @@ struct mpii_ecfg_hdr { u_int8_t reserved2; } __packed __aligned(4); +/* config page address formats */ +#define MPII_PGAD_SAS_DEVICE_FORM_MASK (0xf0000000) +#define MPII_PGAD_SAS_DEVICE_FORM_GET_NEXT_HANDLE (0x00000000) +#define MPII_PGAD_SAS_DEVICE_FORM_HANDLE (0x20000000) + +#define MPII_PGAD_SAS_DEVICE_HANDLE_MASK (0x0000ffff) + struct mpii_msg_config_request { u_int8_t action; #define MPII_CONFIG_REQ_ACTION_PAGE_HEADER (0x00) |