Print this page
    
9042 multiples of tty streams modules cause weirdness
Reviewed by: Randy Fishel <randyf@sibernet.com>
Reviewed by: Carlos Neira <cneirabustos@gmail.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
NEX-16818 Add fksmbcl development tool
NEX-17264 SMB client test tp_smbutil_013 fails after NEX-14666
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
and: (fix ref leaks)
NEX-4083 Upstream changes from illumos 5917 and 5995
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
re #13613 rb4516 Tunables needs volatile keyword
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/sys/stream.h
          +++ new/usr/src/uts/common/sys/stream.h
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  
    | 
      ↓ open down ↓ | 
    13 lines elided | 
    
      ↑ open up ↑ | 
  
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
  24   25   */
       26 +/*
       27 + * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
       28 + */
  25   29  
  26   30  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  27   31  /*        All Rights Reserved   */
  28   32  
  29   33  
  30   34  #ifndef _SYS_STREAM_H
  31   35  #define _SYS_STREAM_H
  32   36  
  33   37  /*
  34   38   * For source compatibility
  35   39   */
  36   40  #include <sys/isa_defs.h>
  37      -#ifdef _KERNEL
       41 +#if defined(_KERNEL) || defined(_FAKE_KERNEL)
  38   42  #include <sys/kmem.h>
  39   43  #include <sys/uio.h>
  40   44  #endif
  41   45  #include <sys/poll.h>
  42   46  #include <sys/strmdep.h>
  43   47  #include <sys/cred.h>
  44   48  #include <sys/t_lock.h>
  45   49  #include <sys/model.h>
  46   50  
  47   51  #ifdef  __cplusplus
  48   52  extern "C" {
  49   53  #endif
  50   54  
  51   55  /*
  52   56   * Data queue.
  53   57   *
  54   58   * NOTE: The *only* public fields are documented in queue(9S).
  55   59   *       Everything else is implementation-private.
  56   60   *
  57   61   * The locking rules for the queue_t structure are extremely subtle and vary
  58   62   * widely depending on the field in question.  As such, each field is
  59   63   * annotated according to the following legend:
  60   64   *
  61   65   *   Q9S: The field is documented in queue(9S) and may be accessed without
  62   66   *        locks by a STREAMS module when inside an entry point (e.g., put(9E)).
  63   67   *        However, no fields can be directly modified unless q_lock is held
  64   68   *        (which is not possible in a DDI compliant STREAMS module), with the
  65   69   *        following exceptions:
  66   70   *
  67   71   *         - q_ptr: can be modified as per the rules of the STREAMS module.
  68   72   *                  The STREAMS framework ignores q_ptr and thus imposes *no*
  69   73   *                  locking rules on it.
  70   74   *         - q_qinfo: can be modified before qprocson().
  71   75   *
  72   76   *         - q_minpsz, q_maxpsz, q_hiwat, q_lowat: can be modified as per the
  73   77   *                  rules of the STREAMS module.  The STREAMS framework never
  74   78   *                  modifies these fields, and is tolerant of temporarily
  75   79   *                  stale field values.
  76   80   *
  77   81   *        In general, the STREAMS framework employs one of the following
  78   82   *        techniques to ensure STREAMS modules can safely access Q9S fields:
  79   83   *
  80   84   *         - The field is only modified by the framework when the stream is
  81   85   *           locked with strlock() (q_next).
  82   86   *
  83   87   *         - The field is modified by the framework, but the modifies are
  84   88   *           atomic, and temporarily stale values are harmless (q_count,
  85   89   *           q_first, q_last).
  86   90   *
  87   91   *         - The field is modified by the framework, but the field's visible
  88   92   *           values are either constant or directly under the control
  89   93   *           of the STREAMS module itself (q_flag).
  90   94   *
  91   95   *   QLK: The field must be accessed or modified under q_lock, except when
  92   96   *        the stream has been locked with strlock().  If multiple q_locks must
  93   97   *        be acquired, q_locks at higher addresses must be taken first.
  94   98   *
  95   99   *   STR: The field can be accessed without a lock, but must be modified under
  96  100   *        strlock().
  97  101   *
  98  102   *   SQLK: The field must be accessed or modified under SQLOCK().
  99  103   *
 100  104   *   NOLK: The field can be accessed without a lock, but can only be modified
 101  105   *         when the queue_t is not known to any other threads.
 102  106   *
 103  107   *   SVLK: The field must be accessed or modified under the service_queue lock.
 104  108   *         Note that service_lock must be taken after any needed q_locks,
 105  109   *         and that no other lock should be taken while service_lock is held.
 106  110   *
 107  111   * In addition, it is always acceptable to modify a field that is not yet
 108  112   * known to any other threads -- and other special case exceptions exist in
 109  113   * the code.  Also, q_lock is used with q_wait to implement a stream head
 110  114   * monitor for reads and writes.
 111  115   */
 112  116  typedef struct queue {
 113  117          struct qinit    *q_qinfo;       /* Q9S: Q processing procedure  */
 114  118          struct msgb     *q_first;       /* Q9S: first message in Q      */
 115  119          struct msgb     *q_last;        /* Q9S: last message in Q       */
 116  120          struct queue    *q_next;        /* Q9S: next Q in stream        */
 117  121          struct queue    *q_link;        /* SVLK: next Q for scheduling  */
 118  122          void            *q_ptr;         /* Q9S: module-specific data    */
 119  123          size_t          q_count;        /* Q9S: number of bytes on Q    */
 120  124          uint_t          q_flag;         /* Q9S: Q state                 */
 121  125          ssize_t         q_minpsz;       /* Q9S: smallest packet OK on Q */
 122  126          ssize_t         q_maxpsz;       /* Q9S: largest packet OK on Q  */
 123  127          size_t          q_hiwat;        /* Q9S: Q high water mark       */
 124  128          size_t          q_lowat;        /* Q9S: Q low water mark        */
 125  129          struct qband    *q_bandp;       /* QLK: band flow information   */
 126  130          kmutex_t        q_lock;         /* NOLK: structure lock         */
 127  131          struct stdata   *q_stream;      /* NOLK: stream backpointer     */
 128  132          struct syncq    *q_syncq;       /* NOLK: associated syncq       */
 129  133          unsigned char   q_nband;        /* QLK: number of bands         */
 130  134          kcondvar_t      q_wait;         /* NOLK: read/write sleep CV    */
 131  135          struct queue    *q_nfsrv;       /* STR: next Q with svc routine */
 132  136          ushort_t        q_draining;     /* QLK: Q is draining           */
 133  137          short           q_struiot;      /* QLK: sync streams Q UIO mode */
 134  138          clock_t         q_qtstamp;      /* QLK: when Q was enabled      */
 135  139          size_t          q_mblkcnt;      /* QLK: mblk count              */
 136  140          uint_t          q_syncqmsgs;    /* QLK: syncq message count     */
 137  141          size_t          q_rwcnt;        /* QLK: # threads in rwnext()   */
 138  142          pri_t           q_spri;         /* QLK: Q scheduling priority   */
 139  143  
 140  144          /*
 141  145           * Syncq scheduling
 142  146           */
 143  147          struct msgb     *q_sqhead;      /* QLK: first syncq message     */
 144  148          struct msgb     *q_sqtail;      /* QLK: last syncq message      */
 145  149          struct queue    *q_sqnext;      /* SQLK: next Q on syncq list   */
 146  150          struct queue    *q_sqprev;      /* SQLK: prev Q on syncq list   */
 147  151          uint_t          q_sqflags;      /* SQLK: syncq flags            */
 148  152          clock_t         q_sqtstamp;     /* SQLK: when Q was scheduled for sq */
 149  153  
 150  154          /*
 151  155           * NOLK: Reference to the queue's module's implementation
 152  156           * structure. This will be NULL for queues associated with drivers.
 153  157           */
 154  158          struct fmodsw_impl      *q_fp;
 155  159  } queue_t;
 156  160  
 157  161  /*
 158  162   * Queue flags; unused flags not documented in queue(9S) can be recycled.
 159  163   */
 160  164  #define QENAB           0x00000001      /* Queue is already enabled to run */
 161  165  #define QWANTR          0x00000002      /* Someone wants to read Q      */
 162  166  #define QWANTW          0x00000004      /* Someone wants to write Q     */
 163  167  #define QFULL           0x00000008      /* Q is considered full         */
 164  168  #define QREADR          0x00000010      /* This is the reader (first) Q */
 165  169  #define QUSE            0x00000020      /* This queue in use (allocation) */
 166  170  #define QNOENB          0x00000040      /* Don't enable Q via putq      */
 167  171  #define QWANTRMQSYNC    0x00000080      /* Want to remove sync stream Q */
 168  172  #define QBACK           0x00000100      /* queue has been back-enabled  */
 169  173  /*      UNUSED          0x00000200         was QHLIST                   */
 170  174  /*      UNUSED          0x00000400         was QUNSAFE                  */
 171  175  #define QPAIR           0x00000800      /* per queue-pair syncq         */
 172  176  #define QPERQ           0x00001000      /* per queue-instance syncq     */
 173  177  #define QPERMOD         0x00002000      /* per module syncq             */
 174  178  #define QMTSAFE         0x00004000      /* stream module is MT-safe     */
 175  179  #define QMTOUTPERIM     0x00008000      /* Has outer perimeter          */
 176  180  #define QMT_TYPEMASK    (QPAIR|QPERQ|QPERMOD|QMTSAFE|QMTOUTPERIM)
 177  181                                          /* all MT type flags            */
 178  182  #define QINSERVICE      0x00010000      /* service routine executing    */
 179  183  #define QWCLOSE         0x00020000      /* will not be enabled          */
 180  184  #define QEND            0x00040000      /* last queue in stream         */
 181  185  #define QWANTWSYNC      0x00080000      /* Streamhead wants to write Q  */
  
    | 
      ↓ open down ↓ | 
    134 lines elided | 
    
      ↑ open up ↑ | 
  
 182  186  #define QSYNCSTR        0x00100000      /* Q supports Synchronous STREAMS */
 183  187  #define QISDRV          0x00200000      /* the Queue is attached to a driver */
 184  188  /*      UNUSED          0x00400000         was QHOT                     */
 185  189  /*      UNUSED          0x00800000         was QNEXTHOT                 */
 186  190  /*      UNUSED          0x01000000         was _QNEXTLESS               */
 187  191  #define _QINSERTING     0x04000000      /* Private, module is being inserted */
 188  192  #define _QREMOVING      0x08000000      /* Private, module is being removed */
 189  193  #define _QASSOCIATED    0x10000000      /* queue is associated with a device */
 190  194  #define _QDIRECT        0x20000000      /* Private; transport module uses */
 191  195                                          /* direct interface to/from sockfs */
      196 +#define _QSINGLE_INSTANCE       0x40000000      /* Private; module may only */
      197 +                                                /* be pushed once */
 192  198  
 193  199  /* queue sqflags (protected by SQLOCK). */
 194  200  #define Q_SQQUEUED      0x01            /* Queue is in the syncq list */
 195  201  #define Q_SQDRAINING    0x02            /* Servicing syncq msgs.        */
 196  202                                          /* This is also noted by the    */
 197  203                                          /* q_draining field, but this one is */
 198  204                                          /* protected by SQLOCK */
 199  205  
 200  206  /*
 201  207   * Structure that describes the separate information
 202  208   * for each priority band in the queue.
 203  209   */
 204  210  typedef struct qband {
 205  211          struct qband    *qb_next;       /* next band's info */
 206  212          size_t          qb_count;       /* number of bytes in band */
 207  213          struct msgb     *qb_first;      /* beginning of band's data */
 208  214          struct msgb     *qb_last;       /* end of band's data */
 209  215          size_t          qb_hiwat;       /* high water mark for band */
 210  216          size_t          qb_lowat;       /* low water mark for band */
 211  217          uint_t          qb_flag;        /* see below */
 212  218          size_t          qb_mblkcnt;     /* mblk counter for runaway msgs */
 213  219  } qband_t;
 214  220  
 215  221  /*
 216  222   * qband flags
 217  223   */
 218  224  #define QB_FULL         0x01            /* band is considered full */
 219  225  #define QB_WANTW        0x02            /* Someone wants to write to band */
 220  226  #define QB_BACK         0x04            /* queue has been back-enabled */
 221  227  
 222  228  /*
 223  229   * Maximum number of bands.
 224  230   */
 225  231  #define NBAND   256
 226  232  
 227  233  /*
 228  234   * Fields that can be manipulated through strqset() and strqget().
 229  235   */
 230  236  typedef enum qfields {
 231  237          QHIWAT  = 0,            /* q_hiwat or qb_hiwat */
 232  238          QLOWAT  = 1,            /* q_lowat or qb_lowat */
 233  239          QMAXPSZ = 2,            /* q_maxpsz */
 234  240          QMINPSZ = 3,            /* q_minpsz */
 235  241          QCOUNT  = 4,            /* q_count or qb_count */
 236  242          QFIRST  = 5,            /* q_first or qb_first */
 237  243          QLAST   = 6,            /* q_last or qb_last */
 238  244          QFLAG   = 7,            /* q_flag or qb_flag */
 239  245          QSTRUIOT = 8,           /* q_struiot */
 240  246          QBAD    = 9
 241  247  } qfields_t;
 242  248  
 243  249  /*
 244  250   * Module information structure
 245  251   */
 246  252  struct module_info {
 247  253          ushort_t mi_idnum;              /* module id number */
 248  254          char    *mi_idname;             /* module name */
 249  255          ssize_t mi_minpsz;              /* min packet size accepted */
 250  256          ssize_t mi_maxpsz;              /* max packet size accepted */
 251  257          size_t  mi_hiwat;               /* hi-water mark */
 252  258          size_t  mi_lowat;               /* lo-water mark */
 253  259  };
 254  260  
 255  261  /*
 256  262   * queue information structure (with Synchronous STREAMS extensions)
 257  263   */
 258  264  struct  qinit {
 259  265          int     (*qi_putp)();           /* put procedure */
 260  266          int     (*qi_srvp)();           /* service procedure */
 261  267          int     (*qi_qopen)();          /* called on startup */
 262  268          int     (*qi_qclose)();         /* called on finish */
 263  269          int     (*qi_qadmin)();         /* for future use */
 264  270          struct module_info *qi_minfo;   /* module information structure */
 265  271          struct module_stat *qi_mstat;   /* module statistics structure */
 266  272          int     (*qi_rwp)();            /* r/w procedure */
 267  273          int     (*qi_infop)();          /* information procedure */
 268  274          int     qi_struiot;             /* stream uio type for struio() */
 269  275  };
 270  276  
 271  277  /*
 272  278   * Values for qi_struiot and q_struiot:
 273  279   */
 274  280  #define STRUIOT_NONE            -1      /* doesn't support struio() */
 275  281  #define STRUIOT_DONTCARE        0       /* use current uiomove() (default) */
 276  282  #define STRUIOT_STANDARD        1       /* use standard uiomove() */
 277  283  
 278  284  /*
 279  285   * Streamtab (used in cdevsw and fmodsw to point to module or driver)
 280  286   */
 281  287  struct streamtab {
 282  288          struct qinit *st_rdinit;
 283  289          struct qinit *st_wrinit;
 284  290          struct qinit *st_muxrinit;
 285  291          struct qinit *st_muxwinit;
 286  292  };
 287  293  
 288  294  /*
 289  295   * Structure sent to mux drivers to indicate a link.
 290  296   */
 291  297  struct linkblk {
 292  298          queue_t *l_qtop;        /* lowest level write queue of upper stream */
 293  299                                  /* (set to NULL for persistent links) */
 294  300          queue_t *l_qbot;        /* highest level write queue of lower stream */
 295  301          int     l_index;        /* index for lower stream. */
 296  302  };
 297  303  
 298  304  /*
 299  305   * Esballoc data buffer freeing routine
 300  306   */
 301  307  typedef struct free_rtn {
 302  308          void    (*free_func)();
 303  309          caddr_t free_arg;
 304  310  } frtn_t;
 305  311  
 306  312  /*
 307  313   * Data block descriptor
 308  314   *
 309  315   * NOTE: db_base, db_lim, db_ref and db_type are the *only* public fields,
 310  316   * as described in datab(9S).  Everything else is implementation-private.
 311  317   */
 312  318  
 313  319  #define DBLK_REFMAX     255U
 314  320  
 315  321  typedef struct datab {
 316  322          frtn_t          *db_frtnp;
 317  323          unsigned char   *db_base;
 318  324          unsigned char   *db_lim;
 319  325          unsigned char   db_ref;
 320  326          unsigned char   db_type;
 321  327          unsigned char   db_flags;
 322  328          unsigned char   db_struioflag;
 323  329          pid_t           db_cpid;        /* cached pid, needs verification */
 324  330          void            *db_cache;      /* kmem cache descriptor */
 325  331          struct msgb     *db_mblk;
 326  332          void            (*db_free)(struct msgb *, struct datab *);
 327  333          void            (*db_lastfree)(struct msgb *, struct datab *);
 328  334          intptr_t        db_cksumstart;
 329  335          intptr_t        db_cksumend;
 330  336          intptr_t        db_cksumstuff;
 331  337          union {
 332  338                  double enforce_alignment;
 333  339                  unsigned char data[8];
 334  340                  struct {
 335  341                          union {
 336  342                                  uint32_t u32;
 337  343                                  uint16_t u16;
 338  344                          } cksum_val;    /* used to store calculated cksum */
 339  345                          uint16_t flags;
 340  346                          uint16_t pad;
 341  347                  } cksum;
 342  348                  /*
 343  349                   * Union used for future extensions (pointer to data ?).
 344  350                   */
 345  351          } db_struioun;
 346  352          struct fthdr    *db_fthdr;
 347  353          cred_t          *db_credp;      /* credential */
 348  354  } dblk_t;
 349  355  
 350  356  #define db_cksum16      db_struioun.cksum.cksum_val.u16
 351  357  #define db_cksum32      db_struioun.cksum.cksum_val.u32
 352  358  
 353  359  /*
 354  360   * Accessor macros for private dblk_t fields (the rest are in <sys/strsun.h>).
 355  361   */
 356  362  #define DB_CPID(mp)             ((mp)->b_datap->db_cpid)
 357  363  #define DB_CRED(mp)             ((mp)->b_datap->db_credp)
 358  364  #define DB_FTHDR(mp)            ((mp)->b_datap->db_fthdr)
 359  365  /*
 360  366   * Used by GLDv2 to store the TCI information.
 361  367   */
 362  368  #define DB_TCI(mp)              ((mp)->b_datap->db_struioun.cksum.pad)
 363  369  
 364  370  /*
 365  371   * Message block descriptor
 366  372   */
 367  373  typedef struct  msgb {
 368  374          struct  msgb    *b_next;
 369  375          struct  msgb    *b_prev;
 370  376          struct  msgb    *b_cont;
 371  377          unsigned char   *b_rptr;
 372  378          unsigned char   *b_wptr;
 373  379          struct datab    *b_datap;
 374  380          unsigned char   b_band;
 375  381          unsigned char   b_tag;
 376  382          unsigned short  b_flag;
 377  383          queue_t         *b_queue;       /* for sync queues */
 378  384  } mblk_t;
 379  385  
 380  386  /*
 381  387   * bcache descriptor
 382  388   */
 383  389  typedef struct  bcache {
 384  390          kmutex_t                mutex;
 385  391          struct kmem_cache       *buffer_cache;
 386  392          struct kmem_cache       *dblk_cache;
 387  393          int                     alloc;
 388  394          int                     destroy;
 389  395          size_t                  size;
 390  396          uint_t                  align;
 391  397  } bcache_t;
 392  398  
 393  399  /*
 394  400   * db_flags values (all implementation private!)
 395  401   */
 396  402  #define DBLK_REFMIN             0x01    /* min refcnt stored in low bit */
 397  403  #define DBLK_COOKED             0x02    /* message has been processed once */
 398  404  #define DBLK_UIOA               0x04    /* uioamove() is pending */
 399  405  
 400  406  /*
 401  407   * db_struioflag values:
 402  408   */
 403  409  #define STRUIO_SPEC     0x01    /* struio{get,put}() special mblk */
 404  410  #define STRUIO_DONE     0x02    /* struio done (could be partial) */
 405  411  #define STRUIO_IP       0x04    /* IP checksum stored in db_struioun */
 406  412  #define STRUIO_ZC       0x08    /* mblk eligible for zero-copy */
 407  413  #define STRUIO_ZCNOTIFY 0x10    /* notify stream head when mblk acked */
 408  414  
 409  415  /*
 410  416   * Message flags.  These are interpreted by the stream head.
 411  417   */
 412  418  #define MSGMARK         0x01    /* last byte of message is "marked" */
 413  419  #define MSGNOLOOP       0x02    /* don't loop message around to */
 414  420                                  /* write side of stream */
 415  421  #define MSGDELIM        0x04    /* message is delimited */
 416  422  /*      UNUSED          0x08       was MSGNOGET (can be recycled) */
 417  423  #define MSGMARKNEXT     0x10    /* Private: first byte of next msg marked */
 418  424  #define MSGNOTMARKNEXT  0x20    /* Private: ... not marked */
 419  425  #define MSGWAITSYNC     0x40    /* Private: waiting for sync squeue enter */
 420  426  
 421  427  /*
 422  428   * Streams message types.
 423  429   */
 424  430  
 425  431  /*
 426  432   * Data and protocol messages (regular and priority)
 427  433   */
 428  434  #define M_DATA          0x00            /* regular data */
 429  435  #define M_PROTO         0x01            /* protocol control */
 430  436  #define M_MULTIDATA     0x02            /* reserved for Multidata use only */
 431  437  
 432  438  /*
 433  439   * Control messages (regular and priority)
 434  440   */
 435  441  #define M_BREAK         0x08            /* line break */
 436  442  #define M_PASSFP        0x09            /* pass file pointer */
 437  443  #define M_EVENT         0x0a            /* Obsoleted: do not use */
 438  444  #define M_SIG           0x0b            /* generate process signal */
 439  445  #define M_DELAY         0x0c            /* real-time xmit delay (1 param) */
 440  446  #define M_CTL           0x0d            /* device-specific control message */
 441  447  #define M_IOCTL         0x0e            /* ioctl; set/get params */
 442  448  #define M_SETOPTS       0x10            /* set various stream head options */
 443  449  #define M_RSE           0x11            /* reserved for RSE use only */
 444  450  
 445  451  /*
 446  452   * Control messages (high priority; go to head of queue)
 447  453   */
 448  454  #define M_IOCACK        0x81            /* acknowledge ioctl */
 449  455  #define M_IOCNAK        0x82            /* negative ioctl acknowledge */
 450  456  #define M_PCPROTO       0x83            /* priority proto message */
 451  457  #define M_PCSIG         0x84            /* generate process signal */
 452  458  #define M_READ          0x85            /* generate read notification */
 453  459  #define M_FLUSH         0x86            /* flush your queues */
 454  460  #define M_STOP          0x87            /* stop transmission immediately */
 455  461  #define M_START         0x88            /* restart transmission after stop */
 456  462  #define M_HANGUP        0x89            /* line disconnect */
 457  463  #define M_ERROR         0x8a            /* send error to stream head */
 458  464  #define M_COPYIN        0x8b            /* request to copyin data */
 459  465  #define M_COPYOUT       0x8c            /* request to copyout data */
 460  466  #define M_IOCDATA       0x8d            /* response to M_COPYIN and M_COPYOUT */
 461  467  #define M_PCRSE         0x8e            /* reserved for RSE use only */
 462  468  #define M_STOPI         0x8f            /* stop reception immediately */
 463  469  #define M_STARTI        0x90            /* restart reception after stop */
 464  470  #define M_PCEVENT       0x91            /* Obsoleted: do not use */
 465  471  #define M_UNHANGUP      0x92            /* line reconnect, sigh */
 466  472  #define M_CMD           0x93            /* out-of-band ioctl command */
 467  473  
 468  474  /*
 469  475   * Queue message class definitions.
 470  476   */
 471  477  #define QNORM           0x00            /* normal priority messages */
 472  478  #define QPCTL           0x80            /* high priority cntrl messages */
 473  479  
 474  480  /*
 475  481   *  IOCTL structure - this structure is the format of the M_IOCTL message type.
 476  482   */
 477  483  #if     defined(_LP64)
 478  484  struct iocblk {
 479  485          int     ioc_cmd;                /* ioctl command type */
 480  486          cred_t  *ioc_cr;                /* full credentials */
 481  487          uint_t  ioc_id;                 /* ioctl id */
 482  488          uint_t  ioc_flag;               /* see below */
 483  489          size_t  ioc_count;              /* count of bytes in data field */
 484  490          int     ioc_rval;               /* return value  */
 485  491          int     ioc_error;              /* error code */
 486  492  };
 487  493  #else
 488  494  struct iocblk {
 489  495          int     ioc_cmd;                /* ioctl command type */
 490  496          cred_t  *ioc_cr;                /* full credentials */
 491  497          uint_t  ioc_id;                 /* ioctl id */
 492  498          size_t  ioc_count;              /* count of bytes in data field */
 493  499          int     ioc_error;              /* error code */
 494  500          int     ioc_rval;               /* return value  */
 495  501          int     ioc_fill1;
 496  502          uint_t  ioc_flag;               /* see below */
 497  503          int     ioc_filler[2];          /* reserved for future use */
 498  504  };
 499  505  #endif  /* _LP64 */
 500  506  
 501  507  typedef struct iocblk   *IOCP;
 502  508  
 503  509  /* {ioc,cp}_flags values */
 504  510  
 505  511  #define IOC_MODELS      DATAMODEL_MASK  /* Note: 0x0FF00000 */
 506  512  #define IOC_ILP32       DATAMODEL_ILP32 /* ioctl origin is ILP32 */
 507  513  #define IOC_LP64        DATAMODEL_LP64  /* ioctl origin is LP64 */
 508  514  #define IOC_NATIVE      DATAMODEL_NATIVE
 509  515  #define IOC_NONE        DATAMODEL_NONE  /* dummy comparison value */
 510  516  
 511  517  /*
 512  518   *      Is the ioctl data formatted for our native model?
 513  519   */
 514  520  #define IOC_CONVERT_FROM(iocp)  ddi_model_convert_from( \
 515  521                                      ((struct iocblk *)iocp)->ioc_flag)
 516  522  
 517  523  /*
 518  524   * structure for the M_COPYIN and M_COPYOUT message types.
 519  525   */
 520  526  #if     defined(_LP64)
 521  527  struct copyreq {
 522  528          int     cq_cmd;                 /* ioctl command (from ioc_cmd) */
 523  529          cred_t  *cq_cr;                 /* full credentials (from ioc_cmd) */
 524  530          uint_t  cq_id;                  /* ioctl id (from ioc_id) */
 525  531          uint_t  cq_flag;                /* must be zero */
 526  532          mblk_t  *cq_private;            /* private state information */
 527  533          caddr_t cq_addr;                /* address to copy data to/from */
 528  534          size_t  cq_size;                /* number of bytes to copy */
 529  535  };
 530  536  #else
 531  537  struct copyreq {
 532  538          int     cq_cmd;                 /* ioctl command (from ioc_cmd) */
 533  539          cred_t  *cq_cr;                 /* full credentials */
 534  540          uint_t  cq_id;                  /* ioctl id (from ioc_id) */
 535  541          caddr_t cq_addr;                /* address to copy data to/from */
 536  542          size_t  cq_size;                /* number of bytes to copy */
 537  543          uint_t  cq_flag;                /* must be zero */
 538  544          mblk_t  *cq_private;            /* private state information */
 539  545          int     cq_filler[4];           /* reserved for future use */
 540  546  };
 541  547  #endif  /* _LP64 */
 542  548  
 543  549  /*
 544  550   * structure for the M_IOCDATA message type.
 545  551   */
 546  552  #if     defined(_LP64)
 547  553  struct copyresp {
 548  554          int     cp_cmd;                 /* ioctl command (from ioc_cmd) */
 549  555          cred_t  *cp_cr;                 /* full credentials (from ioc_cmd) */
 550  556          uint_t  cp_id;                  /* ioctl id (from ioc_id) */
 551  557          uint_t  cp_flag;                /* datamodel IOC_ flags; see above */
 552  558          mblk_t *cp_private;             /* private state information */
 553  559          caddr_t cp_rval;                /* status of request: 0 -> success */
 554  560                                          /*              non-zero -> failure */
 555  561  };
 556  562  #else
 557  563  struct copyresp {
 558  564          int     cp_cmd;                 /* ioctl command (from ioc_cmd) */
 559  565          cred_t  *cp_cr;                 /* full credentials */
 560  566          uint_t  cp_id;                  /* ioctl id (from ioc_id) */
 561  567          caddr_t cp_rval;                /* status of request: 0 -> success */
 562  568                                          /*              non-zero -> failure */
 563  569          size_t  cp_pad1;
 564  570          uint_t  cp_pad2;
 565  571          mblk_t *cp_private;             /* private state information */
 566  572          uint_t  cp_flag;                /* datamodel IOC_ flags; see above */
 567  573          int     cp_filler[3];
 568  574  };
 569  575  #endif  /* _LP64 */
 570  576  
 571  577  /*
 572  578   * Since these structures are all intended to travel in the same message
 573  579   * at different stages of a STREAMS ioctl, this union is used to determine
 574  580   * the message size in strdoioctl().
 575  581   */
 576  582  union ioctypes {
 577  583          struct iocblk   iocblk;
 578  584          struct copyreq  copyreq;
 579  585          struct copyresp copyresp;
 580  586  };
 581  587  
 582  588  /*
 583  589   * Options structure for M_SETOPTS message.  This is sent upstream
 584  590   * by a module or driver to set stream head options.
 585  591   */
 586  592  struct stroptions {
 587  593          uint_t  so_flags;               /* options to set */
 588  594          short   so_readopt;             /* read option */
 589  595          ushort_t so_wroff;              /* write offset */
 590  596          ssize_t so_minpsz;              /* minimum read packet size */
 591  597          ssize_t so_maxpsz;              /* maximum read packet size */
 592  598          size_t  so_hiwat;               /* read queue high water mark */
 593  599          size_t  so_lowat;               /* read queue low water mark */
 594  600          unsigned char so_band;          /* band for water marks */
 595  601          ushort_t so_erropt;             /* error option */
 596  602          ssize_t so_maxblk;              /* maximum message block size */
 597  603          ushort_t so_copyopt;            /* copy options (see stropts.h) */
 598  604          ushort_t so_tail;               /* space available at the end */
 599  605  };
 600  606  
 601  607  /* flags for stream options set message */
 602  608  
 603  609  #define SO_ALL          0x003f  /* set all old options */
 604  610  #define SO_READOPT      0x0001  /* set read option */
 605  611  #define SO_WROFF        0x0002  /* set write offset */
 606  612  #define SO_MINPSZ       0x0004  /* set min packet size */
 607  613  #define SO_MAXPSZ       0x0008  /* set max packet size */
 608  614  #define SO_HIWAT        0x0010  /* set high water mark */
 609  615  #define SO_LOWAT        0x0020  /* set low water mark */
 610  616  #define SO_MREADON      0x0040  /* set read notification ON */
 611  617  #define SO_MREADOFF     0x0080  /* set read notification OFF */
 612  618  #define SO_NDELON       0x0100  /* old TTY semantics for NDELAY reads/writes */
 613  619  #define SO_NDELOFF      0x0200  /* STREAMS semantics for NDELAY reads/writes */
 614  620  #define SO_ISTTY        0x0400  /* the stream is acting as a terminal */
 615  621  #define SO_ISNTTY       0x0800  /* the stream is not acting as a terminal */
 616  622  #define SO_TOSTOP       0x1000  /* stop on background writes to this stream */
  
    | 
      ↓ open down ↓ | 
    415 lines elided | 
    
      ↑ open up ↑ | 
  
 617  623  #define SO_TONSTOP      0x2000  /* do not stop on background writes to stream */
 618  624  #define SO_BAND         0x4000  /* water marks affect band */
 619  625  #define SO_DELIM        0x8000  /* messages are delimited */
 620  626  #define SO_NODELIM      0x010000        /* turn off delimiters */
 621  627  #define SO_STRHOLD      0x020000        /* No longer implemented */
 622  628  #define SO_ERROPT       0x040000        /* set error option */
 623  629  #define SO_COPYOPT      0x080000        /* copy option(s) present */
 624  630  #define SO_MAXBLK       0x100000        /* set maximum message block size */
 625  631  #define SO_TAIL         0x200000        /* set the extra allocated space */
 626  632  
 627      -#ifdef _KERNEL
      633 +#if defined(_KERNEL) || defined(_FAKE_KERNEL)
 628  634  /*
 629  635   * Structure for rw (read/write) procedure calls. A pointer
 630  636   * to a struiod_t is passed as a parameter to the rwnext() call.
 631  637   *
 632  638   * Note: DEF_IOV_MAX is defined and used as it is in "fs/vncalls.c"
 633  639   *       as there isn't a formal definition of IOV_MAX ???
 634  640   */
 635  641  #define DEF_IOV_MAX     16
 636  642  
 637  643  typedef struct struiod {
 638  644          mblk_t          *d_mp;          /* pointer to mblk (chain) */
 639  645          uio_t           d_uio;          /* uio info */
 640  646          iovec_t d_iov[DEF_IOV_MAX];     /* iov referenced by uio */
 641  647  } struiod_t;
 642  648  
 643  649  /*
 644  650   * Structure for information procedure calls.
 645  651   */
 646  652  typedef struct infod {
 647  653          unsigned char   d_cmd;          /* info info request command */
 648  654          unsigned char   d_res;          /* info info command results */
 649  655          int             d_bytes;        /* mblk(s) byte count */
 650  656          int             d_count;        /* count of mblk(s) */
 651  657          uio_t           *d_uiop;        /* pointer to uio struct */
 652  658  } infod_t;
 653  659  /*
 654  660   * Values for d_cmd & d_res.
 655  661   */
 656  662  #define INFOD_FIRSTBYTES        0x02    /* return msgbsize() of first mblk */
 657  663  #define INFOD_BYTES             0x04    /* return msgbsize() of all mblk(s) */
 658  664  #define INFOD_COUNT             0x08    /* return count of mblk(s) */
 659  665  #define INFOD_COPYOUT           0x10    /* copyout any M_DATA mblk(s) */
 660  666  
 661  667  /*
 662  668   * Structure used by _I_CMD mechanism, similar in spirit to iocblk.
 663  669   */
 664  670  typedef struct cmdblk {
 665  671          int             cb_cmd;         /* ioctl command type */
 666  672          cred_t          *cb_cr;         /* full credentials */
 667  673          uint_t          cb_len;         /* payload size */
 668  674          int             cb_error;       /* error code */
 669  675  } cmdblk_t;
 670  676  
 671  677  #endif /* _KERNEL */
 672  678  
 673  679  /*
 674  680   * Miscellaneous parameters and flags.
 675  681   */
 676  682  
 677  683  /*
 678  684   * Values for stream flag in open to indicate module open, clone open,
 679  685   * and the return value for failure.
 680  686   */
 681  687  #define MODOPEN         0x1             /* open as a module */
 682  688  #define CLONEOPEN       0x2             /* clone open; pick own minor dev */
 683  689  #define OPENFAIL        -1              /* returned for open failure */
 684  690  
 685  691  /*
 686  692   * Priority definitions for block allocation.
 687  693   */
 688  694  #define BPRI_LO         1
 689  695  #define BPRI_MED        2
 690  696  #define BPRI_HI         3
 691  697  
 692  698  /*
 693  699   * Value for packet size that denotes infinity
 694  700   */
 695  701  #define INFPSZ          -1
 696  702  
 697  703  /*
 698  704   * Flags for flushq()
 699  705   */
 700  706  #define FLUSHALL        1       /* flush all messages */
 701  707  #define FLUSHDATA       0       /* don't flush control messages */
 702  708  
 703  709  /*
 704  710   * Flag for transparent ioctls
 705  711   */
 706  712  #define TRANSPARENT     (unsigned int)(-1)
 707  713  
 708  714  /*
 709  715   * Stream head default high/low water marks
 710  716   */
 711  717  #define STRHIGH 5120
 712  718  #define STRLOW  1024
 713  719  
 714  720  /*
 715  721   * qwriter perimeter types
 716  722   */
 717  723  #define PERIM_INNER     1               /* The inner perimeter */
 718  724  #define PERIM_OUTER     2               /* The outer perimeter */
 719  725  
 720  726  /*
 721  727   * Definitions of Streams macros and function interfaces.
 722  728   */
 723  729  
 724  730  /*
 725  731   * canenable - check if queue can be enabled by putq().
 726  732   */
 727  733  #define canenable(q)    !((q)->q_flag & QNOENB)
 728  734  
 729  735  /*
 730  736   * Test if data block type is one of the data messages (i.e. not a control
 731  737   * message).
 732  738   */
 733  739  #define datamsg(type) \
 734  740                  ((type) == M_DATA || \
 735  741                      (type) == M_MULTIDATA || \
 736  742                      (type) == M_PROTO || \
 737  743                      (type) == M_PCPROTO || \
 738  744                      (type) == M_DELAY)
 739  745  
 740  746  /*
 741  747   * Extract queue class of message block.
 742  748   */
 743  749  #define queclass(bp) (((bp)->b_datap->db_type >= QPCTL) ? QPCTL : QNORM)
 744  750  
  
    | 
      ↓ open down ↓ | 
    107 lines elided | 
    
      ↑ open up ↑ | 
  
 745  751  /*
 746  752   * Align address on next lower word boundary.
 747  753   */
 748  754  #define straln(a)       (caddr_t)((intptr_t)(a) & -(sizeof (int)-1))
 749  755  
 750  756  /*
 751  757   * Find the max size of data block.
 752  758   */
 753  759  #define bpsize(bp) ((unsigned int)(bp->b_datap->db_lim - bp->b_datap->db_base))
 754  760  
 755      -#ifdef _KERNEL
      761 +#if defined(_KERNEL) || defined(_FAKE_KERNEL)
 756  762  
 757  763  /*
 758  764   * For two-byte M_ERROR messages: indication that a side does not have an error
 759  765   */
 760  766  #define NOERROR ((unsigned char)-1)
 761  767  
 762  768  /*
 763  769   * declarations of common routines
 764  770   */
 765  771  
 766  772  extern mblk_t *allocb(size_t, uint_t);
 767  773  extern mblk_t *desballoc(unsigned char *, size_t, uint_t, frtn_t *);
 768  774  extern mblk_t *esballoc(unsigned char *, size_t, uint_t, frtn_t *);
 769  775  extern bcache_t *bcache_create(char *, size_t, uint_t);
 770  776  extern void bcache_destroy(bcache_t *);
 771  777  extern mblk_t *bcache_allocb(bcache_t *, uint_t);
 772  778  extern mblk_t *mkiocb(uint_t);
 773  779  extern int testb(size_t, uint_t);
 774  780  extern bufcall_id_t bufcall(size_t, uint_t, void (*)(void *), void *);
 775  781  extern bufcall_id_t esbbcall(uint_t, void (*)(void *), void *);
 776  782  extern void freeb(struct msgb *);
 777  783  extern void freemsg(mblk_t *);
 778  784  extern mblk_t *dupb(mblk_t *);
 779  785  extern mblk_t *dupmsg(mblk_t *);
 780  786  extern mblk_t *dupmsg_noloan(mblk_t *);
 781  787  extern mblk_t *copyb(mblk_t *);
 782  788  extern mblk_t *copymsg(mblk_t *);
 783  789  extern void linkb(mblk_t *, mblk_t *);
 784  790  extern mblk_t *unlinkb(mblk_t *);
 785  791  extern mblk_t *reallocb(mblk_t *, size_t, uint_t);      /* private */
 786  792  extern mblk_t *rmvb(mblk_t *, mblk_t *);
 787  793  extern int pullupmsg(struct msgb *, ssize_t);
 788  794  extern mblk_t *msgpullup(struct msgb *, ssize_t);
 789  795  extern int adjmsg(struct msgb *, ssize_t);
 790  796  extern size_t msgdsize(struct msgb *);
 791  797  extern mblk_t *getq(queue_t *);
 792  798  extern void rmvq(queue_t *, mblk_t *);
 793  799  extern void flushq(queue_t *, int);
 794  800  extern void flushq_common(queue_t *, int, int);
 795  801  extern void flushband(queue_t *, unsigned char, int);
 796  802  extern int canput(queue_t *);
 797  803  extern int bcanput(queue_t *, unsigned char);
 798  804  extern int canputnext(queue_t *);
 799  805  extern int bcanputnext(queue_t *, unsigned char);
 800  806  extern int putq(queue_t *, mblk_t *);
 801  807  extern int putbq(queue_t *, mblk_t *);
 802  808  extern int insq(queue_t *, mblk_t *, mblk_t *);
 803  809  extern void put(queue_t *, mblk_t *);
 804  810  extern void putnext(queue_t *, mblk_t *);
 805  811  extern int putctl(queue_t *, int);
 806  812  extern int putctl1(queue_t *, int, int);
 807  813  extern int putnextctl(queue_t *, int);
 808  814  extern int putnextctl1(queue_t *, int, int);
 809  815  extern queue_t *backq(queue_t *);
 810  816  extern void qreply(queue_t *, mblk_t *);
 811  817  extern void qenable(queue_t *);
 812  818  extern int qsize(queue_t *);
 813  819  extern void noenable(queue_t *);
 814  820  extern void enableok(queue_t *);
 815  821  extern int strqset(queue_t *, qfields_t, unsigned char, intptr_t);
 816  822  extern int strqget(queue_t *, qfields_t, unsigned char, void *);
 817  823  extern void unbufcall(bufcall_id_t);
 818  824  extern void qprocson(queue_t *);
 819  825  extern void qprocsoff(queue_t *);
 820  826  extern void freezestr(queue_t *);
 821  827  extern void unfreezestr(queue_t *);
 822  828  extern void qwait(queue_t *);
 823  829  extern int qwait_sig(queue_t *);
 824  830  extern boolean_t qwait_rw(queue_t *);
 825  831  extern void qwriter(queue_t *, mblk_t *, void (*func)(), int);
 826  832  extern timeout_id_t qtimeout(queue_t *, void (*func)(void *), void *, clock_t);
 827  833  extern bufcall_id_t qbufcall(queue_t *, size_t, uint_t,
 828  834      void (*)(void *), void *);
 829  835  extern clock_t quntimeout(queue_t *, timeout_id_t);
 830  836  extern void qunbufcall(queue_t *, bufcall_id_t);
 831  837  extern void strwakeq(queue_t *, int);
  
    | 
      ↓ open down ↓ | 
    66 lines elided | 
    
      ↑ open up ↑ | 
  
 832  838  extern int struioget(queue_t *, mblk_t *, struiod_t *, int);
 833  839  extern int rwnext(queue_t *, struiod_t *);
 834  840  extern int infonext(queue_t *, infod_t *);
 835  841  extern int isuioq(queue_t *);
 836  842  extern void create_putlocks(queue_t *, int);
 837  843  extern int mp_cont_len(mblk_t *, int *);
 838  844  
 839  845  /*
 840  846   * shared or externally configured data structures
 841  847   */
 842      -extern int nstrpush;                    /* maximum number of pushes allowed */
      848 +extern volatile int nstrpush;           /* maximum number of pushes allowed */
 843  849  
 844  850  #endif /* _KERNEL */
 845  851  
 846  852  #ifdef  __cplusplus
 847  853  }
 848  854  #endif
 849  855  
 850  856  #endif  /* _SYS_STREAM_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX