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