From 232d5f7e05b2913931121b01b4daac1910e1110a Mon Sep 17 00:00:00 2001 From: mjacob Date: Tue, 26 Sep 2006 04:59:52 +0000 Subject: Begin the process of moving info to sysctl stuff for FreeBSD by providing OIDs for WWNN/WWPN and Initiator ID. --- sys/dev/isp/isp_freebsd.c | 39 ++++++++++++++++++++++++++++++++++++++- sys/dev/isp/isp_freebsd.h | 9 +++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index af81b13..a225963 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#if __FreeBSD_version >= 500000 +#include +#endif MODULE_VERSION(isp, 1); @@ -73,6 +76,7 @@ static struct cdevsw isp_cdevsw = { /* psize */ nopsize, /* flags */ D_TAPE, }; +#define isp_sysctl_update(x) do { ; } while (0) #else static struct cdevsw isp_cdevsw = { .d_version = D_VERSION, @@ -80,6 +84,7 @@ static struct cdevsw isp_cdevsw = { .d_ioctl = ispioctl, .d_name = "isp", }; +static void isp_sysctl_update(ispsoftc_t *); #endif static ispsoftc_t *isplist = NULL; @@ -248,7 +253,7 @@ isp_attach(ispsoftc_t *isp) } tmp->isp_osinfo.next = isp; } - + isp_sysctl_update(isp); } static __inline void @@ -615,6 +620,38 @@ ispioctl(_DEV dev, u_long c, caddr_t addr, int flags, _IOP *td) return (retval); } +#if __FreeBSD_version >= 500000 +static void +isp_sysctl_update(ispsoftc_t *isp) +{ + struct sysctl_ctx_list *ctx = + device_get_sysctl_ctx(isp->isp_osinfo.dev); + struct sysctl_oid *tree = device_get_sysctl_tree(isp->isp_osinfo.dev); + + if (IS_SCSI(isp)) { + isp->isp_osinfo.sysctl_info.spi.iid = DEFAULT_IID(isp); + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "iid", + CTLFLAG_RD, &isp->isp_osinfo.sysctl_info.spi.iid, 0, + "Initiator ID"); + return; + } + snprintf(isp->isp_osinfo.sysctl_info.fc.wwnn, + sizeof (isp->isp_osinfo.sysctl_info.fc.wwnn), "0x%08x%08x", + (uint32_t) (ISP_NODEWWN(isp) >> 32), (uint32_t) ISP_NODEWWN(isp)); + + snprintf(isp->isp_osinfo.sysctl_info.fc.wwpn, + sizeof (isp->isp_osinfo.sysctl_info.fc.wwpn), "0x%08x%08x", + (uint32_t) (ISP_PORTWWN(isp) >> 32), (uint32_t) ISP_PORTWWN(isp)); + + SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "wwnn", CTLFLAG_RD, isp->isp_osinfo.sysctl_info.fc.wwnn, 0, + "World Wide Node Name"); + SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "wwpn", CTLFLAG_RD, isp->isp_osinfo.sysctl_info.fc.wwpn, 0, + "World Wide Port Name"); +} +#endif + static void isp_intr_enable(void *arg) { diff --git a/sys/dev/isp/isp_freebsd.h b/sys/dev/isp/isp_freebsd.h index 6502dea..6b80137 100644 --- a/sys/dev/isp/isp_freebsd.h +++ b/sys/dev/isp/isp_freebsd.h @@ -160,6 +160,15 @@ struct isposinfo { struct firmware * fw; struct mtx lock; struct cv kthread_cv; + union { + struct { + char wwnn[17]; + char wwpn[17]; + } fc; + struct { + int iid; + } spi; + } sysctl_info; #endif struct proc *kproc; bus_dma_tag_t cdmat; -- cgit v1.1