xref: /illumos-gate/usr/src/uts/common/io/ppp/sppp/sppp.h (revision 2bcc9601)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * sppp.h - Solaris STREAMS PPP multiplexing pseudo-driver definitions
37c478bd9Sstevel@tonic-gate  *
4f53eecf5SJames Carlson  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
57c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
67c478bd9Sstevel@tonic-gate  *
77c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software and its
87c478bd9Sstevel@tonic-gate  * documentation is hereby granted, provided that the above copyright
97c478bd9Sstevel@tonic-gate  * notice appears in all copies.
107c478bd9Sstevel@tonic-gate  *
117c478bd9Sstevel@tonic-gate  * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
127c478bd9Sstevel@tonic-gate  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
137c478bd9Sstevel@tonic-gate  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
147c478bd9Sstevel@tonic-gate  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT.  SUN SHALL NOT BE LIABLE FOR
157c478bd9Sstevel@tonic-gate  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
167c478bd9Sstevel@tonic-gate  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
177c478bd9Sstevel@tonic-gate  *
187c478bd9Sstevel@tonic-gate  * Copyright (c) 1994 The Australian National University.
197c478bd9Sstevel@tonic-gate  * All rights reserved.
207c478bd9Sstevel@tonic-gate  *
217c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software and its
227c478bd9Sstevel@tonic-gate  * documentation is hereby granted, provided that the above copyright
237c478bd9Sstevel@tonic-gate  * notice appears in all copies.  This software is provided without any
247c478bd9Sstevel@tonic-gate  * warranty, express or implied. The Australian National University
257c478bd9Sstevel@tonic-gate  * makes no representations about the suitability of this software for
267c478bd9Sstevel@tonic-gate  * any purpose.
277c478bd9Sstevel@tonic-gate  *
287c478bd9Sstevel@tonic-gate  * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
297c478bd9Sstevel@tonic-gate  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
307c478bd9Sstevel@tonic-gate  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
317c478bd9Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY
327c478bd9Sstevel@tonic-gate  * OF SUCH DAMAGE.
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
357c478bd9Sstevel@tonic-gate  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
367c478bd9Sstevel@tonic-gate  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
377c478bd9Sstevel@tonic-gate  * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
387c478bd9Sstevel@tonic-gate  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
397c478bd9Sstevel@tonic-gate  * OR MODIFICATIONS.
407c478bd9Sstevel@tonic-gate  *
417c478bd9Sstevel@tonic-gate  * This driver is derived from the original SVR4 STREAMS PPP driver
427c478bd9Sstevel@tonic-gate  * originally written by Paul Mackerras <paul.mackerras@cs.anu.edu.au>.
437c478bd9Sstevel@tonic-gate  *
447c478bd9Sstevel@tonic-gate  * Adi Masputra <adi.masputra@sun.com> rewrote and restructured the code
457c478bd9Sstevel@tonic-gate  * for improved performance and scalability.
467c478bd9Sstevel@tonic-gate  *
477c478bd9Sstevel@tonic-gate  * $Id: sppp.h,v 1.0 2000/05/08 01:10:12 masputra Exp $
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #ifndef __SPPP_H
517c478bd9Sstevel@tonic-gate #define	__SPPP_H
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate #include <sys/dlpi.h>
547c478bd9Sstevel@tonic-gate #include <net/ppp_defs.h>
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
577c478bd9Sstevel@tonic-gate extern "C" {
587c478bd9Sstevel@tonic-gate #endif
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #if !defined(ETHERTYPE_IP)
617c478bd9Sstevel@tonic-gate #define	ETHERTYPE_IP	0x800
627c478bd9Sstevel@tonic-gate #endif
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate #if !defined(ETHERTYPE_IPV6)
657c478bd9Sstevel@tonic-gate #define	ETHERTYPE_IPV6	0x86dd
667c478bd9Sstevel@tonic-gate #endif
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #if !defined(ETHERTYPE_PPP)
697c478bd9Sstevel@tonic-gate #define	ETHERTYPE_PPP	0x880b
707c478bd9Sstevel@tonic-gate #endif
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate #if !defined(ETHERTYPE_ALLSAP)
737c478bd9Sstevel@tonic-gate #define	ETHERTYPE_ALLSAP	0
747c478bd9Sstevel@tonic-gate #endif
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #if !defined(PPP_ALLSAP)
777c478bd9Sstevel@tonic-gate #define	PPP_ALLSAP	PPP_ALLSTATIONS
787c478bd9Sstevel@tonic-gate #endif
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /*
817c478bd9Sstevel@tonic-gate  * DLPI handler (function table item).
827c478bd9Sstevel@tonic-gate  */
837c478bd9Sstevel@tonic-gate struct  sppp_dlpi_pinfo_t {
847c478bd9Sstevel@tonic-gate 	int	pi_minlen;		/* minimum primitive length */
85f53eecf5SJames Carlson 	int	pi_state;		/* acceptable starting state */
867c478bd9Sstevel@tonic-gate 	int	(*pi_funcp)();		/* function() to call */
877c478bd9Sstevel@tonic-gate };
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #ifndef DL_MAXPRIM
907c478bd9Sstevel@tonic-gate #define	DL_MAXPRIM DL_GET_STATISTICS_ACK
917c478bd9Sstevel@tonic-gate #endif
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * Per-attachment kstats.
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate typedef struct sppp_kstats {
977c478bd9Sstevel@tonic-gate 	kstat_named_t	allocbfail;
987c478bd9Sstevel@tonic-gate 	kstat_named_t	rbytes;
997c478bd9Sstevel@tonic-gate 	kstat_named_t	ierrors;
1007c478bd9Sstevel@tonic-gate 	kstat_named_t	ierrors_lower;
1017c478bd9Sstevel@tonic-gate 	kstat_named_t	ioctlsfwd;
1027c478bd9Sstevel@tonic-gate 	kstat_named_t	ioctlsfwdok;
1037c478bd9Sstevel@tonic-gate 	kstat_named_t	ioctlsfwderr;
1047c478bd9Sstevel@tonic-gate 	kstat_named_t	ipackets;
1057c478bd9Sstevel@tonic-gate 	kstat_named_t	ipackets_ctl;
1067c478bd9Sstevel@tonic-gate 	kstat_named_t	iqdropped;
1077c478bd9Sstevel@tonic-gate 	kstat_named_t	irunts;
1087c478bd9Sstevel@tonic-gate 	kstat_named_t	itoolongs;
1097c478bd9Sstevel@tonic-gate 	kstat_named_t	lsneedup;
1107c478bd9Sstevel@tonic-gate 	kstat_named_t	lsdown;
1117c478bd9Sstevel@tonic-gate 	kstat_named_t	mctlsfwd;
1127c478bd9Sstevel@tonic-gate 	kstat_named_t	mctlsfwderr;
1137c478bd9Sstevel@tonic-gate 	kstat_named_t	mctlsknown;
1147c478bd9Sstevel@tonic-gate 	kstat_named_t	mctlsunknown;
1157c478bd9Sstevel@tonic-gate 	kstat_named_t	obytes;
1167c478bd9Sstevel@tonic-gate 	kstat_named_t	oerrors;
1177c478bd9Sstevel@tonic-gate 	kstat_named_t	oerrors_lower;
1187c478bd9Sstevel@tonic-gate 	kstat_named_t	opackets;
1197c478bd9Sstevel@tonic-gate 	kstat_named_t	opackets_ctl;
1207c478bd9Sstevel@tonic-gate 	kstat_named_t	oqdropped;
1217c478bd9Sstevel@tonic-gate 	kstat_named_t	otoolongs;
1227c478bd9Sstevel@tonic-gate 	kstat_named_t	orunts;
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 	/* 64 bit entries */
1257c478bd9Sstevel@tonic-gate 	kstat_named_t	ipackets64;
1267c478bd9Sstevel@tonic-gate 	kstat_named_t	opackets64;
1277c478bd9Sstevel@tonic-gate 	kstat_named_t	rbytes64;
1287c478bd9Sstevel@tonic-gate 	kstat_named_t	obytes64;
1297c478bd9Sstevel@tonic-gate } sppp_kstats_t;
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate /*
1327c478bd9Sstevel@tonic-gate  * Same order as above.  Note that for netstat -i to work, there needs
1337c478bd9Sstevel@tonic-gate  * to be "ipackets", "opackets", "ierrors", and "oerrors" kstat named
1347c478bd9Sstevel@tonic-gate  * variables.
1357c478bd9Sstevel@tonic-gate  */
1367c478bd9Sstevel@tonic-gate #define	SPPP_KSTATS_NAMES	\
1377c478bd9Sstevel@tonic-gate 	"allocbfail", "rbytes", "ierrors", "ierrors_lower", "ioctlsfwd", \
1387c478bd9Sstevel@tonic-gate 	"ioctlsfwdok", "ioctlsfwderr", "ipackets", "ipkts_ctl", \
1397c478bd9Sstevel@tonic-gate 	"ipkts_qdropped", "ipkts_runts", "ipkts_toolong", "lsneedup", \
1407c478bd9Sstevel@tonic-gate 	"lsdown", "mctlsfwd", "mctlsfwderr", "mctlsknown", "mctlsunknown", \
1417c478bd9Sstevel@tonic-gate 	"obytes", "oerrors", "oerrors_lower", "opackets", "opkts_ctl", \
1427c478bd9Sstevel@tonic-gate 	"opkts_qdropped", "opkts_toolong", "opkts_runts"
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate #define	SPPP_KSTATS64_NAMES	\
1457c478bd9Sstevel@tonic-gate 	"ipackets64", "opackets64", "rbytes64", "obytes64"
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate /*
1487c478bd9Sstevel@tonic-gate  * dl_addr_length needs to be equal to the absolute value of dl_sap_length,
1497c478bd9Sstevel@tonic-gate  * in order for IP to derive a default setting for IFF_POINTOPOINT flag.
1507c478bd9Sstevel@tonic-gate  */
1517c478bd9Sstevel@tonic-gate typedef t_uscalar_t	spppreqsap_t;
1527c478bd9Sstevel@tonic-gate #define	SPPP_SAPL	sizeof (spppreqsap_t)
1537c478bd9Sstevel@tonic-gate #define	SPPP_ADDRL	SPPP_SAPL
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate /*
1567c478bd9Sstevel@tonic-gate  * Per-Stream instance state information.
1577c478bd9Sstevel@tonic-gate  *
1587c478bd9Sstevel@tonic-gate  * Each instance is dynamically allocated at open() and free'd at close().
1597c478bd9Sstevel@tonic-gate  * Each per-Stream instance points to at most one per-attachment structure
1607c478bd9Sstevel@tonic-gate  * using the sps_ppa field. All instances are threaded together into one
1617c478bd9Sstevel@tonic-gate  * list of active instances ordered on minor device number, using the
1627c478bd9Sstevel@tonic-gate  * sps_nextmn field.
1637c478bd9Sstevel@tonic-gate  */
1647c478bd9Sstevel@tonic-gate typedef struct spppstr {
1657c478bd9Sstevel@tonic-gate 	/*
1667c478bd9Sstevel@tonic-gate 	 * Note that EX_st_nextmn field should never be referenced other
1677c478bd9Sstevel@tonic-gate 	 * than by the routines manipulating the global upper streams list,
1687c478bd9Sstevel@tonic-gate 	 * by first obtaining exclusive access at the outer perimeter.
1697c478bd9Sstevel@tonic-gate 	 */
1707c478bd9Sstevel@tonic-gate 	struct spppstr	*sps_nextmn;	/* next minor in global list */
1717c478bd9Sstevel@tonic-gate 	/*
1727c478bd9Sstevel@tonic-gate 	 * These fields are common to all upper streams. If this stream
1737c478bd9Sstevel@tonic-gate 	 * is attached to a ppa, then the sps_ppa field will point to the
1747c478bd9Sstevel@tonic-gate 	 * ppa structure associated with this particular upper stream.
1757c478bd9Sstevel@tonic-gate 	 */
1767c478bd9Sstevel@tonic-gate 	minor_t		sps_mn_id;	/* minor device number of this stream */
1777c478bd9Sstevel@tonic-gate 	queue_t		*sps_rq;	/* pointer to the read queue */
1787c478bd9Sstevel@tonic-gate 	uint32_t	sps_flags;	/* miscellaneous flags */
1797c478bd9Sstevel@tonic-gate 	uint32_t	sps_ioc_id;	/* last ioctl ID for this stream */
1807c478bd9Sstevel@tonic-gate 	struct sppa	*sps_ppa;	/* pointer to ppa structure */
1817c478bd9Sstevel@tonic-gate 	/*
1827c478bd9Sstevel@tonic-gate 	 * sps_nextsib is protected by the ppa's sibling lock (ppa_sib_lock),
1837c478bd9Sstevel@tonic-gate 	 * and access made to it should only be done by first ensuring that
1847c478bd9Sstevel@tonic-gate 	 * the sps_ppa field is valid, i.e., this stream has been attached.
1857c478bd9Sstevel@tonic-gate 	 */
1867c478bd9Sstevel@tonic-gate 	struct spppstr	*sps_nextsib;	/* next stream of same ppa (sibling) */
1877c478bd9Sstevel@tonic-gate 	/*
1887c478bd9Sstevel@tonic-gate 	 * These fields are common to all non-control streams, i.e., those
1897c478bd9Sstevel@tonic-gate 	 * in which a PPPIO_NEWPPA has not been issued on. Non-control
1907c478bd9Sstevel@tonic-gate 	 * streams are valid candidates for network streams, and they can
1917c478bd9Sstevel@tonic-gate 	 * only be considered network streams (ones which carry IP packets)
1927c478bd9Sstevel@tonic-gate 	 * if they are attached and bound. The only mandatory requirement
1937c478bd9Sstevel@tonic-gate 	 * for control stream is that its sps_npmode field should always
1947c478bd9Sstevel@tonic-gate 	 * be equal to NPMODE_PASS, as we obviously will never block the
1957c478bd9Sstevel@tonic-gate 	 * control stream from sending or receiving packets.
1967c478bd9Sstevel@tonic-gate 	 */
1977c478bd9Sstevel@tonic-gate 	t_scalar_t	sps_sap;	/* bound sap */
1987c478bd9Sstevel@tonic-gate 	spppreqsap_t	sps_req_sap;	/* requested sap */
1997c478bd9Sstevel@tonic-gate 	enum NPmode	sps_npmode;	/* network protocol mode */
2007c478bd9Sstevel@tonic-gate 	/*
2017c478bd9Sstevel@tonic-gate 	 * sps_dlstate is only valid for network streams in which DLPI
2027c478bd9Sstevel@tonic-gate 	 * is intended to be used to transfer network-layer data. It is set
2037c478bd9Sstevel@tonic-gate 	 * to DL_UNATTACHED for all other streams.
2047c478bd9Sstevel@tonic-gate 	 */
2057c478bd9Sstevel@tonic-gate 	t_uscalar_t	sps_dlstate;	/* current DLPI state */
2067c478bd9Sstevel@tonic-gate 	mblk_t		*sps_hangup;	/* preallocated M_HANGUP message */
207f53eecf5SJames Carlson 
208f53eecf5SJames Carlson 	zoneid_t	sps_zoneid;	/* zone in which we were opened */
2097c478bd9Sstevel@tonic-gate } spppstr_t;
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate /*
2127c478bd9Sstevel@tonic-gate  * Values for sps_flags, and their descriptions.
2137c478bd9Sstevel@tonic-gate  */
2147c478bd9Sstevel@tonic-gate /*			0x00000001	unused */
2157c478bd9Sstevel@tonic-gate #define	SPS_CONTROL	0x00000002	/* stream is a control stream */
2167c478bd9Sstevel@tonic-gate #define	SPS_FASTPATH	0x00000004	/* stream uses IP fastpath */
2177c478bd9Sstevel@tonic-gate #define	SPS_PROMISC	0x00000008	/* stream is promiscuous */
2187c478bd9Sstevel@tonic-gate #define	SPS_RAWDATA	0x00000010	/* raw M_DATA, no DLPI header */
2197c478bd9Sstevel@tonic-gate #define	SPS_PIOATTACH	0x00000020	/* attached using PPPIO_ATTACH */
2207c478bd9Sstevel@tonic-gate #define	SPS_KDEBUG	0x00000040	/* stream has kdebug turned on */
2217c478bd9Sstevel@tonic-gate #define	SPS_CACHED	0x00000080	/* network stream pointer is cached */
2229f7c4232SAnil udupa #define	SPS_IOCQ	0x00000100	/* queue ioctls */
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate #define	IS_SPS_CONTROL(x)	\
2257c478bd9Sstevel@tonic-gate 	((x)->sps_flags & SPS_CONTROL)
2267c478bd9Sstevel@tonic-gate #define	IS_SPS_FASTPATH(x)	\
2277c478bd9Sstevel@tonic-gate 	((x)->sps_flags & SPS_FASTPATH)
2287c478bd9Sstevel@tonic-gate #define	IS_SPS_PROMISC(x)	\
2297c478bd9Sstevel@tonic-gate 	((x)->sps_flags & SPS_PROMISC)
2307c478bd9Sstevel@tonic-gate #define	IS_SPS_RAWDATA(x)	\
2317c478bd9Sstevel@tonic-gate 	((x)->sps_flags & SPS_RAWDATA)
2327c478bd9Sstevel@tonic-gate #define	IS_SPS_PIOATTACH(x)	\
2337c478bd9Sstevel@tonic-gate 	((x)->sps_flags & SPS_PIOATTACH)
2347c478bd9Sstevel@tonic-gate #define	IS_SPS_KDEBUG(x)	\
2357c478bd9Sstevel@tonic-gate 	((x)->sps_flags & SPS_KDEBUG)
2367c478bd9Sstevel@tonic-gate #define	IS_SPS_CACHED(x)	\
2377c478bd9Sstevel@tonic-gate 	((x)->sps_flags & SPS_CACHED)
2389f7c4232SAnil udupa #define	IS_SPS_IOCQ(x)		\
2399f7c4232SAnil udupa 	((x)->sps_flags & SPS_IOCQ)
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate /*
2427c478bd9Sstevel@tonic-gate  * Bit format (octal based) string for cmn_err, which represents the flags.
2437c478bd9Sstevel@tonic-gate  */
2447c478bd9Sstevel@tonic-gate #define	SPS_FLAGS_STR	\
2457c478bd9Sstevel@tonic-gate 	"\020"		\
2467c478bd9Sstevel@tonic-gate 	"\1priv"	\
2477c478bd9Sstevel@tonic-gate 	"\2control"	\
2487c478bd9Sstevel@tonic-gate 	"\3fastpath"	\
2497c478bd9Sstevel@tonic-gate 	"\4promisc"	\
2507c478bd9Sstevel@tonic-gate 	"\5rawdata"	\
2517c478bd9Sstevel@tonic-gate 	"\6pioattach"	\
2527c478bd9Sstevel@tonic-gate 	"\7kdebug"	\
2537c478bd9Sstevel@tonic-gate 	"\10cached"
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate /*
2567c478bd9Sstevel@tonic-gate  * Per-Attachment instance state information.
2577c478bd9Sstevel@tonic-gate  *
2587c478bd9Sstevel@tonic-gate  * Each instance is dynamically allocated on first attach (PPPIO_NEWPPA).
2597c478bd9Sstevel@tonic-gate  * Allocation of this structure is only done once per control stream. A ppa
2607c478bd9Sstevel@tonic-gate  * instance may be shared by two or more upper streams, and it is always
2617c478bd9Sstevel@tonic-gate  * linked to the upper stream marked as the control stream (SPS_CONTROL)
2627c478bd9Sstevel@tonic-gate  * via the ppa_ctl field.  Non-control streams are linked to ppa_streams.
2637c478bd9Sstevel@tonic-gate  */
2647c478bd9Sstevel@tonic-gate typedef struct sppa {
2657c478bd9Sstevel@tonic-gate 	/*
2667c478bd9Sstevel@tonic-gate 	 * Note that EX_st_nextppa field should only be accessed (walked)
2677c478bd9Sstevel@tonic-gate 	 * by the ppa manipulation routines, i.e, those which affect
2687c478bd9Sstevel@tonic-gate 	 * the global ppa list, e.g: open, close, new_ppa, and XX_attach_upper.
2697c478bd9Sstevel@tonic-gate 	 */
2707c478bd9Sstevel@tonic-gate 	struct sppa	*ppa_nextppa;	/* next attachment instance */
2717c478bd9Sstevel@tonic-gate 	/*
2727c478bd9Sstevel@tonic-gate 	 * ppa_sib_lock guards the linkages between all upper streams related
2737c478bd9Sstevel@tonic-gate 	 * to this ppa. Walking the sps_nextsib of any upper streams should
2747c478bd9Sstevel@tonic-gate 	 * be done by first holding this lock.
2757c478bd9Sstevel@tonic-gate 	 */
2767c478bd9Sstevel@tonic-gate 	krwlock_t	ppa_sib_lock;	/* lock for sibling upper streams */
2777c478bd9Sstevel@tonic-gate 	uint32_t	ppa_flags;	/* miscellaneous flags */
2787c478bd9Sstevel@tonic-gate 	int32_t		ppa_refcnt;	/* upper stream reference count */
2797c478bd9Sstevel@tonic-gate 	uint32_t	ppa_ppa_id;	/* unique attachment id */
2807c478bd9Sstevel@tonic-gate 	spppstr_t	*ppa_streams;	/* list of all non-control streams */
2817c478bd9Sstevel@tonic-gate 	spppstr_t	*ppa_ctl;	/* back pointer to control stream */
2827c478bd9Sstevel@tonic-gate 	queue_t		*ppa_lower_wq;	/* pointer to lower write queue */
2837c478bd9Sstevel@tonic-gate 	uint16_t	ppa_mru;	/* link layer maximum receive unit */
2847c478bd9Sstevel@tonic-gate 	uint16_t	ppa_mtu;	/* link layer maximum transmit unit */
2857c478bd9Sstevel@tonic-gate 	hrtime_t	ppa_lasttx;	/* last transmit time for a packet */
2867c478bd9Sstevel@tonic-gate 	hrtime_t	ppa_lastrx;	/* last receive time for a packet */
2877c478bd9Sstevel@tonic-gate 	int32_t		ppa_promicnt;	/* promiscous stream count */
2887c478bd9Sstevel@tonic-gate 	/*
2897c478bd9Sstevel@tonic-gate 	 * ppa_sta_lock mutex guards the statistic fields of this ppa, since
2907c478bd9Sstevel@tonic-gate 	 * this structure is shared by upper streams of the same ppa.
2917c478bd9Sstevel@tonic-gate 	 */
2927c478bd9Sstevel@tonic-gate 	kmutex_t	ppa_sta_lock;	/* mutex to lock structure */
2937c478bd9Sstevel@tonic-gate 	struct ppp_stats64 ppa_stats;	/* legacy stats structure */
2947c478bd9Sstevel@tonic-gate 	uint32_t	ppa_allocbfail;	/* memory allocation failure count */
2957c478bd9Sstevel@tonic-gate 	uint32_t	ppa_ierr_low;	/* errors from below during receive */
2967c478bd9Sstevel@tonic-gate 	uint32_t	ppa_ioctlsfwd;	/* total ioctl forwarded down */
2977c478bd9Sstevel@tonic-gate 	uint32_t	ppa_ioctlsfwdok;  /* and the reply sent upward */
2987c478bd9Sstevel@tonic-gate 	uint32_t	ppa_ioctlsfwderr; /* or discarded replies */
2997c478bd9Sstevel@tonic-gate 	uint32_t	ppa_ipkt_ctl;	/* received control pkts */
3007c478bd9Sstevel@tonic-gate 	uint32_t	ppa_iqdropped;	/* msg dropped due to putq error */
3017c478bd9Sstevel@tonic-gate 	uint32_t	ppa_irunts;	/* packet rcvd is too short */
3027c478bd9Sstevel@tonic-gate 	uint32_t	ppa_itoolongs;	/* packet rcvd is larger than MRU */
3037c478bd9Sstevel@tonic-gate 	uint32_t	ppa_lsneedup;	/* total LINKSTAT_NEEDUP msg sent up */
3047c478bd9Sstevel@tonic-gate 	uint32_t	ppa_lsdown;	/* total LINKSTAT_DOWN msg sent up */
3057c478bd9Sstevel@tonic-gate 	uint32_t	ppa_mctlsfwd;	/* total M_{PC}PROTO forwarded down */
3067c478bd9Sstevel@tonic-gate 	uint32_t	ppa_mctlsfwderr; /*   and discarded count */
3077c478bd9Sstevel@tonic-gate 	uint32_t	ppa_mctlsknown;	/* total known M_CTL messages */
3087c478bd9Sstevel@tonic-gate 	uint32_t	ppa_mctlsunknown; /* total unknown M_CTL messages */
3097c478bd9Sstevel@tonic-gate 	uint32_t	ppa_oerr_low;	/* errors from below during transmit */
3107c478bd9Sstevel@tonic-gate 	uint32_t	ppa_opkt_ctl;	/* transmitted control pkts */
3117c478bd9Sstevel@tonic-gate 	uint32_t	ppa_oqdropped;	/* msg dropped due to putq error */
3127c478bd9Sstevel@tonic-gate 	uint32_t	ppa_orunts;	/* packet sent is too short */
3137c478bd9Sstevel@tonic-gate 	uint32_t	ppa_otoolongs;	/* packet sent is larger than MTU */
3147c478bd9Sstevel@tonic-gate 	kstat_t		*ppa_kstats;	/* pointer to kstats structure */
3157c478bd9Sstevel@tonic-gate 	/*
3167c478bd9Sstevel@tonic-gate 	 * We keep the following pointers for performance reasons. Instead
3177c478bd9Sstevel@tonic-gate 	 * of walking the list of attached upper streams to find the
3187c478bd9Sstevel@tonic-gate 	 * destination upper stream everytime we need to send a packet up,
3197c478bd9Sstevel@tonic-gate 	 * we keep them here for easy access.
3207c478bd9Sstevel@tonic-gate 	 */
3217c478bd9Sstevel@tonic-gate 	spppstr_t	*ppa_ip_cache;	/* ptr to PPP_IP upper stream */
3227c478bd9Sstevel@tonic-gate 	spppstr_t	*ppa_ip6_cache;	/* ptr to PPP_IPV6 upper stream */
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate 	kmutex_t	ppa_npmutex;	/* protects the 2 fields below */
325*2bcc9601SToomas Soome 	uint32_t	ppa_npflag;	/* network protocols blocked */
326*2bcc9601SToomas Soome 	uint32_t	ppa_holdpkts[3]; /* # of packets blocked per np */
327f53eecf5SJames Carlson 
328f53eecf5SJames Carlson 	zoneid_t	ppa_zoneid;	/* zone where PPA is in use */
3297c478bd9Sstevel@tonic-gate } sppa_t;
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate /* bit position (in ppa_npflag) for each ppp_protocol that can be blocked */
3327c478bd9Sstevel@tonic-gate #define	NP_IP	1
3337c478bd9Sstevel@tonic-gate #define	NP_IPV6	2
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate /*
3367c478bd9Sstevel@tonic-gate  * Values for ppa_flags, and their descriptions.
3377c478bd9Sstevel@tonic-gate  */
3387c478bd9Sstevel@tonic-gate #define	PPA_LASTMOD	0x00000001	/* last PPP entity on the stream */
3397c478bd9Sstevel@tonic-gate #define	PPA_TIMESTAMP	0x00000002	/* time-stamp each packet */
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate #define	IS_PPA_LASTMOD(x)	\
3427c478bd9Sstevel@tonic-gate 	((x)->ppa_flags & PPA_LASTMOD)
3437c478bd9Sstevel@tonic-gate #define	IS_PPA_TIMESTAMP(x)	\
3447c478bd9Sstevel@tonic-gate 	((x)->ppa_flags & PPA_TIMESTAMP)
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate /*
3477c478bd9Sstevel@tonic-gate  * Bit format (octal based) string for cmn_err, which represents the flags.
3487c478bd9Sstevel@tonic-gate  */
3497c478bd9Sstevel@tonic-gate #define	PPA_FLAGS_STR	\
3507c478bd9Sstevel@tonic-gate 	"\020"		\
3517c478bd9Sstevel@tonic-gate 	"\1lastmod"	\
3527c478bd9Sstevel@tonic-gate 	"\2timestamp"
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate /*
3557c478bd9Sstevel@tonic-gate  * General macros.
3567c478bd9Sstevel@tonic-gate  */
3577c478bd9Sstevel@tonic-gate #define	SPDEBUG	printf
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate /*
3607c478bd9Sstevel@tonic-gate  * Function declarations.
3617c478bd9Sstevel@tonic-gate  */
3625e1743f0SToomas Soome extern int	sppp_close(queue_t *, int, cred_t *);
3637c478bd9Sstevel@tonic-gate extern mblk_t	*sppp_dladdud(spppstr_t *, mblk_t *, t_scalar_t, boolean_t);
3647c478bd9Sstevel@tonic-gate extern void	sppp_dlpi_pinfoinit(void);
3657c478bd9Sstevel@tonic-gate extern void	sppp_dlprsendup(spppstr_t *, mblk_t *, t_scalar_t, boolean_t);
366*2bcc9601SToomas Soome extern int	sppp_lrput(queue_t *, mblk_t *);
367*2bcc9601SToomas Soome extern int	sppp_lrsrv(queue_t *);
368*2bcc9601SToomas Soome extern int	sppp_lwsrv(queue_t *);
3697c478bd9Sstevel@tonic-gate extern int	sppp_mproto(queue_t *, mblk_t *, spppstr_t *);
3707c478bd9Sstevel@tonic-gate extern int	sppp_open(queue_t *, dev_t *, int, int, cred_t *);
371*2bcc9601SToomas Soome extern int	sppp_uwput(queue_t *, mblk_t *);
372*2bcc9601SToomas Soome extern int	sppp_uwsrv(queue_t *);
3737c478bd9Sstevel@tonic-gate extern void	sppp_remove_ppa(spppstr_t *sps);
3747c478bd9Sstevel@tonic-gate extern sppa_t	*sppp_find_ppa(uint32_t ppa_id);
375f53eecf5SJames Carlson extern sppa_t	*sppp_create_ppa(uint32_t ppa_id, zoneid_t zoneid);
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3787c478bd9Sstevel@tonic-gate }
3797c478bd9Sstevel@tonic-gate #endif
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate #endif /* __SPPP_H */
382