xref: /titanic_50/usr/src/cmd/devfsadm/cfg_link.h (revision ad86e48d1214c1b0ec33af482240d16fd15cb6ff)
13c4226f9Spjha /*
23c4226f9Spjha  * CDDL HEADER START
33c4226f9Spjha  *
43c4226f9Spjha  * The contents of this file are subject to the terms of the
53c4226f9Spjha  * Common Development and Distribution License (the "License").
63c4226f9Spjha  * You may not use this file except in compliance with the License.
73c4226f9Spjha  *
83c4226f9Spjha  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93c4226f9Spjha  * or http://www.opensolaris.org/os/licensing.
103c4226f9Spjha  * See the License for the specific language governing permissions
113c4226f9Spjha  * and limitations under the License.
123c4226f9Spjha  *
133c4226f9Spjha  * When distributing Covered Code, include this CDDL HEADER in each
143c4226f9Spjha  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153c4226f9Spjha  * If applicable, add the following below this CDDL HEADER, with the
163c4226f9Spjha  * fields enclosed by brackets "[]" replaced with your own identifying
173c4226f9Spjha  * information: Portions Copyright [yyyy] [name of copyright owner]
183c4226f9Spjha  *
193c4226f9Spjha  * CDDL HEADER END
203c4226f9Spjha  */
213c4226f9Spjha /*
223c4226f9Spjha  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
233c4226f9Spjha  * Use is subject to license terms.
243c4226f9Spjha  */
253c4226f9Spjha 
263c4226f9Spjha /* private devlink info interfaces */
273c4226f9Spjha 
283c4226f9Spjha #ifndef	_CFG_LINK_H
293c4226f9Spjha #define	_CFG_LINK_H
303c4226f9Spjha 
313c4226f9Spjha #pragma ident	"%Z%%M%	%I%	%E% SMI"
323c4226f9Spjha 
333c4226f9Spjha #include <devfsadm.h>
343c4226f9Spjha 
353c4226f9Spjha #ifdef	__cplusplus
363c4226f9Spjha extern "C" {
373c4226f9Spjha #endif
383c4226f9Spjha 
393c4226f9Spjha #define	SCSI_CFG_LINK_RE	"^cfg/c[0-9]+$"
403c4226f9Spjha #define	SBD_CFG_LINK_RE		"^cfg/((((N[0-9]+[.])?(SB|IB))?[0-9]+)|[abcd])$"
413c4226f9Spjha #define	USB_CFG_LINK_RE		"^cfg/((usb[0-9]+)/([0-9]+)([.]([0-9])+)*)$"
423c4226f9Spjha #define	PCI_CFG_LINK_RE		"^cfg/[:alnum:]$"
433c4226f9Spjha #define	IB_CFG_LINK_RE		"^cfg/(hca[0-9A-F]+)$"
443c4226f9Spjha #define	SATA_CFG_LINK_RE	"^cfg/((sata[0-9]+)/([0-9]+)([.]([0-9])+)*)$"
45*ad86e48dSpjha #define	PCI_CFG_PATH_LINK_RE	\
46*ad86e48dSpjha 	"^cfg/(.*(pci[0-9]|pcie[0-9]|Slot[0-9]|\\<pci\\>|\\<pcie\\>).*)$"
473c4226f9Spjha 
483c4226f9Spjha #define	CFG_DIRNAME		"cfg"
493c4226f9Spjha 
503c4226f9Spjha #define	PROP_FIRST_CHAS		"first-in-chassis"
513c4226f9Spjha #define	PROP_SLOT_NAMES		"slot-names"
523c4226f9Spjha #define	PROP_PHYS_SLOT		"physical-slot#"
533c4226f9Spjha #define	PROP_DEV_TYPE		"device_type"
543c4226f9Spjha #define	PROP_BUS_RANGE		"bus-range"
553c4226f9Spjha #define	PROP_SERID		"serialid#"
563c4226f9Spjha #define	PROP_REG		"reg"
573c4226f9Spjha #define	PROP_AP_NAMES		"ap-names"
583c4226f9Spjha #define	PROPVAL_PCIEX		"pciex"
593c4226f9Spjha #define	DEVTYPE_PCIE		"pcie"
603c4226f9Spjha #define	IOB_PRE			"iob"
613c4226f9Spjha #define	AP_PATH_SEP		":"
623c4226f9Spjha #define	AP_PATH_IOB_SEP		"."
633c4226f9Spjha #define	VENDID_SUN		0x108e
643c4226f9Spjha #define	APNODE_DEFNAME		0x1
65*ad86e48dSpjha #define	PCIDEV_NIL		((minor_t)-1)
663c4226f9Spjha 
673c4226f9Spjha /* converts size in bits to a mask covering those bit positions */
683c4226f9Spjha #define	SIZE2MASK(s)		((1 << (s)) - 1)
693c4226f9Spjha #define	SIZE2MASK64(s)		((1LL << (s)) - 1LL)
703c4226f9Spjha 
713c4226f9Spjha /*
723c4226f9Spjha  * macros for the ieee1275 "reg" property
733c4226f9Spjha  * naming format and semantics:
743c4226f9Spjha  *
753c4226f9Spjha  * REG_<cell>_SIZE_<field> = bit size of <field> in <cell>
763c4226f9Spjha  * REG_<cell>_OFF_<field> = starting bit position of <field> in <cell>
773c4226f9Spjha  *
783c4226f9Spjha  * REG_<cell>_<field>(r) = returns the value of <field> in <cell> using:
793c4226f9Spjha  *	(((r) >> REG_<cell>_OFF_<field>) & SIZE2MASK(REG_<cell>_SIZE_<field>))
803c4226f9Spjha  */
813c4226f9Spjha #define	REG_PHYSHI_SIZE_PCIDEV	5
823c4226f9Spjha #define	REG_PHYSHI_OFF_PCIDEV	11
833c4226f9Spjha #define	REG_PHYSHI_PCIDEV(r)	\
843c4226f9Spjha 	(((r) >> REG_PHYSHI_OFF_PCIDEV) & SIZE2MASK(REG_PHYSHI_SIZE_PCIDEV))
853c4226f9Spjha 
863c4226f9Spjha /* rp = ptr to 5-tuple int array */
873c4226f9Spjha #define	REG_PHYSHI_INDEX	0
883c4226f9Spjha #define	REG_PHYSHI(rp)		((rp)[REG_PHYSHI_INDEX])
893c4226f9Spjha 
903c4226f9Spjha #define	REG_PCIDEV(rp)		(REG_PHYSHI_PCIDEV(REG_PHYSHI(rp)))
913c4226f9Spjha 
923c4226f9Spjha 
933c4226f9Spjha #define	DEV "/dev"
943c4226f9Spjha #define	DEV_LEN 4
953c4226f9Spjha #define	DEVICES "/devices"
963c4226f9Spjha #define	DEVICES_LEN 8
973c4226f9Spjha 
983c4226f9Spjha #ifdef	__cplusplus
993c4226f9Spjha }
1003c4226f9Spjha #endif
1013c4226f9Spjha 
1023c4226f9Spjha #endif /* _CFG_LINK_H */
103