1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * spppcomp.h - Solaris STREAMS PPP compression module definitions 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * Copyright 2000-2002 Sun Microsystems, Inc. All rights reserved. 5*0Sstevel@tonic-gate * Use is subject to license terms. 6*0Sstevel@tonic-gate * 7*0Sstevel@tonic-gate * Permission to use, copy, modify, and distribute this software and its 8*0Sstevel@tonic-gate * documentation is hereby granted, provided that the above copyright 9*0Sstevel@tonic-gate * notice appears in all copies. 10*0Sstevel@tonic-gate * 11*0Sstevel@tonic-gate * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF 12*0Sstevel@tonic-gate * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 13*0Sstevel@tonic-gate * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 14*0Sstevel@tonic-gate * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR 15*0Sstevel@tonic-gate * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR 16*0Sstevel@tonic-gate * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES 17*0Sstevel@tonic-gate * 18*0Sstevel@tonic-gate * Copyright (c) 1994 The Australian National University. 19*0Sstevel@tonic-gate * All rights reserved. 20*0Sstevel@tonic-gate * 21*0Sstevel@tonic-gate * Permission to use, copy, modify, and distribute this software and its 22*0Sstevel@tonic-gate * documentation is hereby granted, provided that the above copyright 23*0Sstevel@tonic-gate * notice appears in all copies. This software is provided without any 24*0Sstevel@tonic-gate * warranty, express or implied. The Australian National University 25*0Sstevel@tonic-gate * makes no representations about the suitability of this software for 26*0Sstevel@tonic-gate * any purpose. 27*0Sstevel@tonic-gate * 28*0Sstevel@tonic-gate * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY 29*0Sstevel@tonic-gate * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 30*0Sstevel@tonic-gate * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 31*0Sstevel@tonic-gate * THE AUSTRALIAN NATIONAL UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY 32*0Sstevel@tonic-gate * OF SUCH DAMAGE. 33*0Sstevel@tonic-gate * 34*0Sstevel@tonic-gate * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, 35*0Sstevel@tonic-gate * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 36*0Sstevel@tonic-gate * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 37*0Sstevel@tonic-gate * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO 38*0Sstevel@tonic-gate * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, 39*0Sstevel@tonic-gate * OR MODIFICATIONS. 40*0Sstevel@tonic-gate * 41*0Sstevel@tonic-gate * This driver is derived from the original SVR4 STREAMS PPP driver 42*0Sstevel@tonic-gate * originally written by Paul Mackerras <paul.mackerras@cs.anu.edu.au>. 43*0Sstevel@tonic-gate * 44*0Sstevel@tonic-gate * Adi Masputra <adi.masputra@sun.com> rewrote and restructured the code 45*0Sstevel@tonic-gate * for improved performance and scalability. 46*0Sstevel@tonic-gate */ 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate #ifndef __SPPPCOMP_H 49*0Sstevel@tonic-gate #define __SPPPCOMP_H 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate #ifdef __cplusplus 54*0Sstevel@tonic-gate extern "C" { 55*0Sstevel@tonic-gate #endif 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate /* 58*0Sstevel@tonic-gate * Per-unit kstats. 59*0Sstevel@tonic-gate */ 60*0Sstevel@tonic-gate typedef struct spppcomp_kstats { 61*0Sstevel@tonic-gate kstat_named_t vj_out_pkts; 62*0Sstevel@tonic-gate kstat_named_t vj_out_pkts_comp; 63*0Sstevel@tonic-gate kstat_named_t vj_cs_searches; 64*0Sstevel@tonic-gate kstat_named_t vj_cs_misses; 65*0Sstevel@tonic-gate kstat_named_t vj_in_pkts_uncomp; 66*0Sstevel@tonic-gate kstat_named_t vj_in_pkts_comp; 67*0Sstevel@tonic-gate kstat_named_t vj_in_error; 68*0Sstevel@tonic-gate kstat_named_t vj_in_tossed; 69*0Sstevel@tonic-gate kstat_named_t out_errors_low; 70*0Sstevel@tonic-gate kstat_named_t out_uncomp_bytes; 71*0Sstevel@tonic-gate kstat_named_t out_uncomp_pkts; 72*0Sstevel@tonic-gate kstat_named_t out_comp_bytes; 73*0Sstevel@tonic-gate kstat_named_t out_comp_pkts; 74*0Sstevel@tonic-gate kstat_named_t out_incomp_bytes; 75*0Sstevel@tonic-gate kstat_named_t out_incomp_pkts; 76*0Sstevel@tonic-gate kstat_named_t in_errors_low; 77*0Sstevel@tonic-gate kstat_named_t in_uncomp_bytes; 78*0Sstevel@tonic-gate kstat_named_t in_uncomp_pkts; 79*0Sstevel@tonic-gate kstat_named_t in_comp_bytes; 80*0Sstevel@tonic-gate kstat_named_t in_comp_pkts; 81*0Sstevel@tonic-gate kstat_named_t in_incomp_bytes; 82*0Sstevel@tonic-gate kstat_named_t in_incomp_pkts; 83*0Sstevel@tonic-gate #ifdef SPC_DEBUG 84*0Sstevel@tonic-gate kstat_named_t in_msg_ccp_pulledup; 85*0Sstevel@tonic-gate kstat_named_t in_msg_vj_pulledup; 86*0Sstevel@tonic-gate kstat_named_t out_msg_pulledup; 87*0Sstevel@tonic-gate kstat_named_t out_msg_copied; 88*0Sstevel@tonic-gate kstat_named_t out_queued; 89*0Sstevel@tonic-gate kstat_named_t out_handled; 90*0Sstevel@tonic-gate kstat_named_t in_queued; 91*0Sstevel@tonic-gate kstat_named_t in_handled; 92*0Sstevel@tonic-gate #endif 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate /* 64 bit entries */ 95*0Sstevel@tonic-gate kstat_named_t out_bytes; 96*0Sstevel@tonic-gate kstat_named_t out_pkts; 97*0Sstevel@tonic-gate kstat_named_t out_errors; 98*0Sstevel@tonic-gate kstat_named_t in_bytes; 99*0Sstevel@tonic-gate kstat_named_t in_pkts; 100*0Sstevel@tonic-gate kstat_named_t in_errors; 101*0Sstevel@tonic-gate } spppcomp_kstats_t; 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate #define SPPPCOMP_KSTATS_NAMES \ 104*0Sstevel@tonic-gate "vj_out_pkts", "vj_out_pkts_comp", "vj_cs_searches", \ 105*0Sstevel@tonic-gate "vj_cs_misses", "vj_in_pkts_uncomp", "vj_in_pkts_comp", \ 106*0Sstevel@tonic-gate "vj_in_error", "vj_in_tossed", "out_errors_lower", \ 107*0Sstevel@tonic-gate "out_uncomp_bytes", "out_uncomp_pkts", "out_comp_bytes", \ 108*0Sstevel@tonic-gate "out_comp_pkts", "out_incomp_bytes", "out_incomp_pkts", \ 109*0Sstevel@tonic-gate "in_errors_lower", "in_uncomp_bytes", "in_uncomp_pkts", \ 110*0Sstevel@tonic-gate "in_comp_bytes", "in_comp_pkts", "in_incomp_bytes", \ 111*0Sstevel@tonic-gate "in_incomp_pkts" 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate #ifdef SPC_DEBUG 114*0Sstevel@tonic-gate #define SPCDEBUG_KSTATS_NAMES \ 115*0Sstevel@tonic-gate "in_msg_ccp_pulledup", "in_msg_vj_pulledup", "out_msg_pulledup", \ 116*0Sstevel@tonic-gate "out_msg_copied", "out_queued", "out_handled", \ 117*0Sstevel@tonic-gate "in_queued", "in_handled" 118*0Sstevel@tonic-gate #endif 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate #define SPPPCOMP_KSTATS64_NAMES \ 121*0Sstevel@tonic-gate "out_bytes", "out_pkts", "out_errors", \ 122*0Sstevel@tonic-gate "in_bytes", "in_pkts", "in_errors" 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate /* 125*0Sstevel@tonic-gate * Per-stream instance state information. 126*0Sstevel@tonic-gate * 127*0Sstevel@tonic-gate * Each instance is dynamically allocated at open() and freed at close(). 128*0Sstevel@tonic-gate * Each per-Stream instance points to at most one per-unit kstats structure 129*0Sstevel@tonic-gate * using the cp_kstats field, which is allocated once per-Stream when 130*0Sstevel@tonic-gate * PPPCTL_UNIT is received from above. 131*0Sstevel@tonic-gate */ 132*0Sstevel@tonic-gate typedef struct sppp_comp { 133*0Sstevel@tonic-gate uint32_t cp_flags; /* miscellaneous flags */ 134*0Sstevel@tonic-gate ushort_t cp_mru; /* link layer MRU */ 135*0Sstevel@tonic-gate ushort_t cp_mtu; /* link layer MTU */ 136*0Sstevel@tonic-gate uint32_t cp_unit; /* unique unit id */ 137*0Sstevel@tonic-gate struct compressor *cp_xcomp; /* compressor structure */ 138*0Sstevel@tonic-gate void *cp_xstate; /* compressor state */ 139*0Sstevel@tonic-gate struct compressor *cp_rcomp; /* de-compressor structure */ 140*0Sstevel@tonic-gate void *cp_rstate; /* de-compressor state */ 141*0Sstevel@tonic-gate struct vjcompress cp_vj; /* VJ compression state */ 142*0Sstevel@tonic-gate kmutex_t cp_pair_lock; /* lock for queue pair */ 143*0Sstevel@tonic-gate hrtime_t cp_lastfinish; /* last decode finish time */ 144*0Sstevel@tonic-gate int16_t cp_effort; /* configured effort level */ 145*0Sstevel@tonic-gate int16_t cp_nxslots; /* VJ compress slots */ 146*0Sstevel@tonic-gate uint16_t cp_fastin; /* count of fast inputs */ 147*0Sstevel@tonic-gate ppp_counter_t cp_vj_last_ierrors; /* last VJ input errors */ 148*0Sstevel@tonic-gate struct pppstat64 cp_stats; /* legacy stats structure */ 149*0Sstevel@tonic-gate kstat_t *cp_kstats; /* ptr to kstats structure */ 150*0Sstevel@tonic-gate uint32_t cp_ierr_low; /* in error from below */ 151*0Sstevel@tonic-gate uint32_t cp_oerr_low; /* out error from below */ 152*0Sstevel@tonic-gate #ifdef SPC_DEBUG 153*0Sstevel@tonic-gate uint32_t cp_imsg_ccp_pull; /* msgpullup on recv */ 154*0Sstevel@tonic-gate uint32_t cp_imsg_vj_pull; /* msgpullup on recv */ 155*0Sstevel@tonic-gate uint32_t cp_omsg_pull; /* msgpullup on send */ 156*0Sstevel@tonic-gate uint32_t cp_omsg_dcopy; /* copymsg on send */ 157*0Sstevel@tonic-gate uint32_t cp_out_queued; /* did putq */ 158*0Sstevel@tonic-gate uint32_t cp_out_handled; /* did putnext */ 159*0Sstevel@tonic-gate uint32_t cp_in_queued; /* did putq */ 160*0Sstevel@tonic-gate uint32_t cp_in_handled; /* did putnext */ 161*0Sstevel@tonic-gate #endif 162*0Sstevel@tonic-gate } sppp_comp_t; 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gate /* 165*0Sstevel@tonic-gate * Bits in flags are as defined in pppio.h 166*0Sstevel@tonic-gate * COMP_AC 0x00000001 compress address/control 167*0Sstevel@tonic-gate * DECOMP_AC 0x00000002 decompress address/control 168*0Sstevel@tonic-gate * COMP_PROT 0x00000004 compress PPP protocol 169*0Sstevel@tonic-gate * DECOMP_PROT 0x00000008 decompress PPP protocol 170*0Sstevel@tonic-gate * COMP_VJC 0x00000010 compress TCP/IP headers 171*0Sstevel@tonic-gate * COMP_VJCCID 0x00000020 compress connection ID as well 172*0Sstevel@tonic-gate * DECOMP_VJC 0x00000040 decompress TCP/IP headers 173*0Sstevel@tonic-gate * DECOMP_VJCCID 0x00000080 accept compressed connection ID 174*0Sstevel@tonic-gate * CCP_ISOPEN 0x00000100 look at CCP packets 175*0Sstevel@tonic-gate * CCP_ISUP 0x00000200 do packet comp/decomp 176*0Sstevel@tonic-gate * CCP_ERROR 0x00000400 (status) error in packet decomp 177*0Sstevel@tonic-gate * CCP_FATALERROR 0x00000800 (status) fatal error ditto 178*0Sstevel@tonic-gate * CCP_COMP_RUN 0x00001000 (status) seen CCP ack sent 179*0Sstevel@tonic-gate * CCP_DECOMP_RUN 0x00002000 (status) seen CCP ack rcvd 180*0Sstevel@tonic-gate */ 181*0Sstevel@tonic-gate #define CP_KDEBUG 0x02000000 /* log debugging stuff */ 182*0Sstevel@tonic-gate #define CP_HASUNIT 0x04000000 /* PPPCTL_UNIT has been issued on */ 183*0Sstevel@tonic-gate #define CP_LASTMOD 0x08000000 /* last PPP-aware module in stream */ 184*0Sstevel@tonic-gate #define CCP_ERR (CCP_ERROR | CCP_FATALERROR) 185*0Sstevel@tonic-gate 186*0Sstevel@tonic-gate #define IS_COMP_AC(x) \ 187*0Sstevel@tonic-gate ((x)->cp_flags & COMP_AC) 188*0Sstevel@tonic-gate #define IS_DECOMP_AC(x) \ 189*0Sstevel@tonic-gate ((x)->cp_flags & DECOMP_AC) 190*0Sstevel@tonic-gate #define IS_COMP_PROT(x) \ 191*0Sstevel@tonic-gate ((x)->cp_flags & COMP_PROT) 192*0Sstevel@tonic-gate #define IS_DECOMP_PROT(x) \ 193*0Sstevel@tonic-gate ((x)->cp_flags & DECOMP_PROT) 194*0Sstevel@tonic-gate #define IS_COMP_VJC(x) \ 195*0Sstevel@tonic-gate ((x)->cp_flags & COMP_VJC) 196*0Sstevel@tonic-gate #define IS_COMP_VJCCID(x) \ 197*0Sstevel@tonic-gate ((x)->cp_flags & COMP_VJCCID) 198*0Sstevel@tonic-gate #define IS_DECOMP_VJC(x) \ 199*0Sstevel@tonic-gate ((x)->cp_flags & DECOMP_VJC) 200*0Sstevel@tonic-gate #define IS_DECOMP_VJCCID(x) \ 201*0Sstevel@tonic-gate ((x)->cp_flags & DECOMP_VJCCID) 202*0Sstevel@tonic-gate #define IS_CCP_ISOPEN(x) \ 203*0Sstevel@tonic-gate ((x)->cp_flags & CCP_ISOPEN) 204*0Sstevel@tonic-gate #define IS_CCP_ISUP(x) \ 205*0Sstevel@tonic-gate ((x)->cp_flags & CCP_ISUP) 206*0Sstevel@tonic-gate #define IS_CCP_ERROR(x) \ 207*0Sstevel@tonic-gate ((x)->cp_flags & CCP_ERROR) 208*0Sstevel@tonic-gate #define IS_CCP_FATALERROR(x) \ 209*0Sstevel@tonic-gate ((x)->cp_flags & CCP_FATALERROR) 210*0Sstevel@tonic-gate #define IS_CCP_COMP_RUN(x) \ 211*0Sstevel@tonic-gate ((x)->cp_flags & CCP_COMP_RUN) 212*0Sstevel@tonic-gate #define IS_CCP_DECOMP_RUN(x) \ 213*0Sstevel@tonic-gate ((x)->cp_flags & CCP_DECOMP_RUN) 214*0Sstevel@tonic-gate #define IS_CP_KDEBUG(x) \ 215*0Sstevel@tonic-gate ((x)->cp_flags & CP_KDEBUG) 216*0Sstevel@tonic-gate #define IS_CP_HASUNIT(x) \ 217*0Sstevel@tonic-gate ((x)->cp_flags & CP_HASUNIT) 218*0Sstevel@tonic-gate #define IS_CP_LASTMOD(x) \ 219*0Sstevel@tonic-gate ((x)->cp_flags & CP_LASTMOD) 220*0Sstevel@tonic-gate 221*0Sstevel@tonic-gate /* 222*0Sstevel@tonic-gate * Bit format (octal based) string for cmn_err/printf, which 223*0Sstevel@tonic-gate * represents the flags. 224*0Sstevel@tonic-gate */ 225*0Sstevel@tonic-gate #define CP_FLAGSSTR \ 226*0Sstevel@tonic-gate "\020" \ 227*0Sstevel@tonic-gate "\1comp_ac" \ 228*0Sstevel@tonic-gate "\2decomp_ac" \ 229*0Sstevel@tonic-gate "\3comp_prot" \ 230*0Sstevel@tonic-gate "\4decomp_prot" \ 231*0Sstevel@tonic-gate "\5comp_vjc" \ 232*0Sstevel@tonic-gate "\6comp_vjccid" \ 233*0Sstevel@tonic-gate "\7decomp_vjc" \ 234*0Sstevel@tonic-gate "\10decomp_vjccid" \ 235*0Sstevel@tonic-gate "\11ccp_isopen" \ 236*0Sstevel@tonic-gate "\12ccp_isup" \ 237*0Sstevel@tonic-gate "\13ccp_error" \ 238*0Sstevel@tonic-gate "\14ccp_fatalerror" \ 239*0Sstevel@tonic-gate "\15ccp_comp_run" \ 240*0Sstevel@tonic-gate "\16ccp_decomp_run" \ 241*0Sstevel@tonic-gate "\32kdebug" \ 242*0Sstevel@tonic-gate "\33hasunit" \ 243*0Sstevel@tonic-gate "\34lastmod" 244*0Sstevel@tonic-gate 245*0Sstevel@tonic-gate #ifdef __cplusplus 246*0Sstevel@tonic-gate } 247*0Sstevel@tonic-gate #endif 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate #endif /* __SPPPCOMP_H */ 250