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