Print this page
    
5832 EOF wireless usb (aka UWB)
Reviewed by: TBD
Reviewed by: TBD
Approved by: TBD
    
      
        | Split | Close | 
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/sys/usb/usba/usba_private.h
          +++ new/usr/src/uts/common/sys/usb/usba/usba_private.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 + *
       25 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  24   26   */
  25   27  
  26   28  #ifndef _SYS_USB_USBA_USBA_PRIVATE_H
  27   29  #define _SYS_USB_USBA_USBA_PRIVATE_H
  28   30  
  29   31  
  30   32  #include <sys/sunndi.h>
  31   33  
  32   34  /*
  33   35   * Header file for items to be shared within usba but not to be used
  34   36   * by drivers
  35   37   */
  36   38  
  37   39  #ifdef  __cplusplus
  38   40  extern "C" {
  39   41  #endif
  40   42  
  41   43  /*
  42   44   * **************************************************************************
  43   45   * DDK version 0.8 binaries are supported.
  44   46   * **************************************************************************
  45   47   */
  46   48  
  47   49  /* USBA supports (obsolete) legacy version 0.8 of the S8/S9 DDK. */
  48   50  #define USBA_LEG_MAJOR_VER      0
  49   51  #define USBA_LEG_MINOR_VER      8
  50   52  
  51   53  /*
  52   54   * **************************************************************************
  53   55   * Descriptor definitions and parsing functions.
  54   56   * **************************************************************************
  55   57   */
  56   58  
  57   59  /*
  58   60   * functions to return a pre-processed device descriptor to the client driver.
  59   61   * These all extract data from the raw config cloud  returned by a
  60   62   * usb_get_raw_cfg_data()
  61   63   *
  62   64   * The pre-processed descriptor is returned into a buffer supplied by
  63   65   * the caller
  64   66   * The size of the buffer should allow for padding
  65   67   *
  66   68   * In the following:
  67   69   *      buf             buffer containing data returned by GET_DESCRIPTOR
  68   70   *      buflen          length of the data at buf
  69   71   *      ret_descr       buffer the data is to be returned in
  70   72   *      ret_buf_len     size of the buffer at ret_descr
  71   73   *
  72   74   *      first_if        the first interace associated with current iad
  73   75   *      if_index        the index in the array of concurrent interfaces
  74   76   *                      supported by this configuration
  75   77   *      alt_if_setting  alternate setting for the interface identified
  76   78   *                      by if_index
  77   79   *      ep_index        the index in the array of endpoints supported by
  78   80   *                      this configuration
  79   81   *
  80   82   * These functions return the length of the returned descriptor structure,
  81   83   * or USB_PARSE_ERROR on error.
  82   84   *
  83   85   * No error is returned if ret_buf_len is too small but
  84   86   * the data is truncated
  85   87   * This allows successful parsing of descriptors that have been
  86   88   * extended in a later rev of the spec.
  87   89   */
  88   90  size_t usb_parse_dev_descr(
  89   91          uchar_t                 *buf,   /* from GET_DESCRIPTOR(DEVICE) */
  90   92          size_t                  buflen,
  91   93          usb_dev_descr_t         *ret_descr,
  92   94          size_t                  ret_buf_len);
  93   95  
  94   96  
  95   97  size_t usb_parse_cfg_descr(
  96   98          uchar_t                 *buf,   /* from GET_DESCRIPTOR(CONFIGURATION) */
  97   99          size_t                  buflen,
  98  100          usb_cfg_descr_t         *ret_descr,
  99  101          size_t                  ret_buf_len);
 100  102  
 101  103  
 102  104  size_t usb_parse_ia_descr(
 103  105          uchar_t                 *buf,   /* from GET_DESCRIPTOR(CONFIGURATION) */
 104  106          size_t                  buflen,
 105  107          size_t                  first_if,
 106  108          usb_ia_descr_t          *ret_descr,
 107  109          size_t                  ret_buf_len);
 108  110  
 109  111  
 110  112  size_t usb_parse_if_descr(
 111  113          uchar_t                 *buf,   /* from GET_DESCRIPTOR(CONFIGURATION) */
 112  114          size_t                  buflen,
 113  115          uint_t                  if_index,
 114  116          uint_t                  alt_if_setting,
 115  117          usb_if_descr_t          *ret_descr,
 116  118          size_t                  ret_buf_len);
 117  119  
 118  120  
 119  121  /*
 120  122   * the endpoint index is relative to the interface. index 0 is
 121  123   * the first endpoint
 122  124   */
 123  125  size_t usb_parse_ep_descr(
 124  126          uchar_t                 *buf,   /* from GET_DESCRIPTOR(CONFIGURATION) */
 125  127          size_t                  buflen,
 126  128          uint_t                  if_index,
 127  129          uint_t                  alt_if_setting,
 128  130          uint_t                  ep_index,
 129  131          usb_ep_descr_t          *ret_descr,
 130  132          size_t                  ret_buf_len);
 131  133  
 132  134  /*
 133  135   * functions to handle arbitrary descriptors. USBA doesn't know the format
 134  136   * and therefore cannot do any automatic pre-processing.
 135  137   *
 136  138   * In the following:
 137  139   *      buf             buffer containing data returned by GET_DESCRIPTOR
 138  140   *      buflen          length of the data at buf allowing for padding
 139  141   *      fmt             a null terminated string describing the format of
 140  142   *                      the data structure for general-purpose byte swapping,
 141  143   *                      use NULL for raw access.
 142  144   *                      The letters "c", "s", "l", and "L"
 143  145   *                      represent 1, 2, 4, and 8 byte quantities,
 144  146   *                      respectively.  A descriptor that consists of a
 145  147   *                      short and two bytes would be described by "scc\0".
 146  148   *      descr_type      type of the desired descriptor, USB_DESCR_TYPE_ANY
 147  149   *                      to get any type.
 148  150   *      descr_index     index of the desired descriptor
 149  151   *      ret_descr       buffer the data is to be returned in
 150  152   *      ret_buf_len     size of the buffer at ret_descr
 151  153   *
 152  154   * Specifying descr_index=0 returns the first descriptor of the specified
 153  155   * type, specifying descr_index=1 returns the second, and so on.
 154  156   *
 155  157   * No error is returned if ret_buf_len is too small. This allows successful
 156  158   * parsing of descriptors that have been extended in a later rev of the spec.
 157  159   */
 158  160  #define USB_DESCR_TYPE_ANY                      -1      /* Wild card */
 159  161  
 160  162  size_t usb_parse_CV_cfg_descr(
 161  163          uchar_t                 *buf,   /* from GET_DESCRIPTOR(CONFIGURATION) */
 162  164          size_t                  buflen,
 163  165          char                    *fmt,
 164  166          uint_t                  descr_type,
 165  167          uint_t                  descr_index,
 166  168          void                    *ret_descr,
 167  169          size_t                  ret_buf_len);
 168  170  
 169  171  
 170  172  size_t usb_parse_CV_if_descr(
 171  173          uchar_t                 *buf,   /* from GET_DESCRIPTOR(CONFIGURATION) */
 172  174          size_t                  buflen,
 173  175          char                    *fmt,
 174  176          uint_t                  if_index,
 175  177          uint_t                  alt_if_setting,
 176  178          uint_t                  descr_type,
 177  179          uint_t                  descr_index,
 178  180          void                    *ret_descr,
 179  181          size_t                  ret_buf_len);
 180  182  
 181  183  
 182  184  size_t usb_parse_CV_ep_descr(
 183  185          uchar_t                 *buf,   /* from GET_DESCRIPTOR(CONFIGURATION) */
 184  186          size_t                  buflen,
 185  187          char                    *fmt,
 186  188          uint_t                  if_index,
 187  189          uint_t                  alt_if_setting,
 188  190          uint_t                  ep_index,
 189  191          uint_t                  descr_type,
 190  192          uint_t                  descr_index,
 191  193          void                    *ret_descr,
 192  194          size_t                  ret_buf_len);
 193  195  
 194  196  
 195  197  /*
  
    | ↓ open down ↓ | 162 lines elided | ↑ open up ↑ | 
 196  198   * for unpacking any kind of LE data
 197  199   */
 198  200  size_t usb_parse_CV_descr(
 199  201          char                    *format,
 200  202          uchar_t                 *data,
 201  203          size_t                  datalen,
 202  204          void                    *structure,
 203  205          size_t                  structlen);
 204  206  
 205  207  /*
 206      - * For WUSB extended descriptors
 207      - */
 208      -size_t
 209      -usb_parse_bos_descr(uchar_t     *buf,   /* from GET_DESCRIPTOR(BOS) */
 210      -        size_t                  buflen,
 211      -        usb_bos_descr_t         *ret_descr,
 212      -        size_t                  ret_buf_len);
 213      -
 214      -size_t
 215      -usb_parse_uwb_bos_descr(uchar_t *buf,   /* from GET_DESCRIPTOR(BOS) */
 216      -        size_t                  buflen,
 217      -        usb_uwb_cap_descr_t             *ret_descr,
 218      -        size_t                  ret_buf_len);
 219      -
 220      -size_t
 221      -usb_parse_comp_ep_descr(uchar_t *buf,   /* from GET_DESCRIPTOR(CONFIGURATION) */
 222      -        size_t                  buflen,
 223      -        uint_t                  if_number,
 224      -        uint_t                  alt_if_setting,
 225      -        uint_t                  ep_index,
 226      -        usb_ep_comp_descr_t     *ret_descr,
 227      -        size_t                  ret_buf_len);
 228      -
 229      -/*
 230  208   * Returns pointer to the raw config cloud. The client should
 231  209   * not free this space.
 232  210   */
 233  211  uchar_t *usb_get_raw_cfg_data(
 234  212          dev_info_t              *dip,
 235  213          size_t                  *length);
 236  214  
 237  215  /*
 238  216   * Return pointer to device descriptor
 239  217   */
 240  218  usb_dev_descr_t *usb_get_dev_descr(
 241  219          dev_info_t              *dip);
 242  220  
 243  221  
 244  222  /*
 245  223   * **************************************************************************
 246  224   * List entry functions and definitions
 247  225   * **************************************************************************
 248  226   */
 249  227  
 250  228  /*
 251  229   * Data structure for maintaining lists
 252  230   * This data structure private to USBA and not exposed to HCD or client
 253  231   * driver or hub driver
 254  232   */
 255  233  typedef struct usba_list_entry {
 256  234          struct usba_list_entry  *next;          /* ptr to next element */
 257  235          struct usba_list_entry  *prev;          /* ptr to previous element */
 258  236          kmutex_t                list_mutex;     /* mutex that protects queue */
 259  237          usb_opaque_t            private;        /* ptr to private data */
 260  238          int                     count;          /* for head of the list */
 261  239                                                  /* counts of entries */
 262  240  } usba_list_entry_t;
 263  241  
 264  242  _NOTE(MUTEX_PROTECTS_DATA(usba_list_entry::list_mutex, usba_list_entry))
 265  243  
 266  244  
 267  245  /* list entry functions. */
 268  246  void    usba_init_list(usba_list_entry_t *, usb_opaque_t,
 269  247                                          ddi_iblock_cookie_t);
 270  248  void    usba_destroy_list(usba_list_entry_t *);
 271  249  void    usba_add_to_list(usba_list_entry_t *, usba_list_entry_t *);
 272  250  int     usba_rm_from_list(usba_list_entry_t *, usba_list_entry_t *);
 273  251  void    usba_move_list(usba_list_entry_t *, usba_list_entry_t *,
 274  252                                          ddi_iblock_cookie_t);
 275  253  int     usba_check_in_list(usba_list_entry_t *, usba_list_entry_t *);
 276  254  int     usba_list_entry_leaks(usba_list_entry_t *, char *);
 277  255  int     usba_list_entry_count(usba_list_entry_t *);
 278  256  
 279  257  usb_opaque_t usba_rm_first_pvt_from_list(usba_list_entry_t *);
 280  258  usba_list_entry_t *usba_rm_first_from_list(usba_list_entry_t *);
 281  259  
 282  260  /*
 283  261   * **************************************************************************
 284  262   * Kernel interface definitions and functionality
 285  263   * **************************************************************************
 286  264   */
 287  265  
 288  266  /*
 289  267   * USBA private event definitions
 290  268   */
 291  269  typedef enum usba_event {
 292  270          USBA_EVENT_TAG_HOT_REMOVAL = 0,
 293  271          USBA_EVENT_TAG_HOT_INSERTION = 1,
 294  272          USBA_EVENT_TAG_PRE_SUSPEND = 2,
 295  273          USBA_EVENT_TAG_POST_RESUME = 3,
 296  274          USBA_EVENT_TAG_CPR = -1
 297  275  } usba_event_t;
 298  276  
 299  277  #define USBA_PRE_SUSPEND_EVENT  "SUNW,USBA:USBA_PRE_SUSPEND"
 300  278  #define USBA_POST_RESUME_EVENT  "SUNW,USBA:USBA_POST_RESUME"
 301  279  
 302  280  /*
 303  281   * Get dma attributes from HC.
 304  282   */
 305  283  ddi_dma_attr_t *usba_get_hc_dma_attr(dev_info_t *dip);
 306  284  
 307  285  /*
 308  286   * This function calls ndi_devi_bind_driver() to bind the
 309  287   * driver to the device. If the call fails it reports an
 310  288   * error on the console. Attaching of the driver is done
 311  289   * later by devfs framework.
 312  290   */
 313  291  int usba_bind_driver(dev_info_t *);
 314  292  
 315  293  /* check whether the dip owns an interface-associaiton */
 316  294  boolean_t usba_owns_ia(dev_info_t *dip);
 317  295  
 318  296  /*
 319  297   * Driver binding functions
 320  298   */
 321  299  dev_info_t *usba_ready_device_node(dev_info_t *);
 322  300  dev_info_t *usba_ready_interface_association_node(dev_info_t *,
 323  301                                          uint_t, uint_t *);
 324  302  dev_info_t *usba_ready_interface_node(dev_info_t *, uint_t);
 325  303  
 326  304  /* Some Nexus driver functions. */
 327  305  
 328  306  /*
 329  307   * Common bus ctl for hcd, usb_mid and hubd.
 330  308   */
 331  309  int     usba_bus_ctl(dev_info_t *, dev_info_t *, ddi_ctl_enum_t,
 332  310                                          void *, void *);
 333  311  
 334  312  void    usb_enable_parent_notification(dev_info_t *);
 335  313  
 336  314  /*
 337  315   * Some functions for setting/getting usba_device from dip.
 338  316   */
 339  317  struct  usba_device     *usba_get_usba_device(dev_info_t *);
 340  318  struct  usba_device     *usba_polled_get_usba_device(dev_info_t *);
 341  319  void    usba_set_usba_device(dev_info_t *, struct usba_device *);
 342  320  
 343  321  /* extract NDI event registration info */
 344  322  struct  usba_evdata     *usba_get_evdata(dev_info_t *);
 345  323  
 346  324  /*
 347  325   * **************************************************************************
 348  326   * Misc private USBA functions
 349  327   * **************************************************************************
 350  328   */
 351  329  
 352  330  /*
 353  331   * Get policy of a pipe while holding only opaque pipe handle.
 354  332   */
 355  333  usb_pipe_policy_t *usba_pipe_get_policy(usb_pipe_handle_t);
 356  334  
 357  335  /*
 358  336   * Check interrupt context and or in USB_CB_INTR_CONTEXT to cb_flags as needed.
 359  337   */
 360  338  usb_cb_flags_t  usba_check_intr_context(usb_cb_flags_t);
 361  339  
 362  340  /* returns interface number, zero if driver owns the device */
 363  341  uint8_t usba_get_ifno(dev_info_t *);
 364  342  
 365  343  /*
 366  344   * **************************************************************************
 367  345   * Misc private descriptor definitions and functionality
 368  346   * **************************************************************************
 369  347   */
 370  348  
 371  349  /* default endpoint descriptor */
 372  350  extern usb_ep_descr_t   usba_default_ep_descr;
 373  351  
 374  352  /*
 375  353   * The compiler pads the above structures;  the following represent the
 376  354   * unpadded, aggregate data sizes.
 377  355   */
 378  356  #define USB_DEV_DESCR_SIZE      18      /* device descr size */
 379  357  #define USB_CFG_DESCR_SIZE       9      /* configuration desc. size */
 380  358  #define USBA_CFG_PWR_DESCR_SIZE 18      /* configuration pwr desc. size */
 381  359  #define USB_IF_DESCR_SIZE        9      /* interface descr size */
 382  360  #define USBA_IF_PWR_DESCR_SIZE  15      /* interface pwr descr size */
 383  361  #define USB_EP_DESCR_SIZE        7      /* endpoint descr size */
 384  362  #define USB_IA_DESCR_SIZE        8      /* interface association descr size */
 385  363  
 386  364  /*
 387  365   * For compatibility with old code.
 388  366   */
 389  367  #define USBA_DESCR_TYPE_CFG_PWR_1_1     0xfe
 390  368  #define USBA_DESCR_TYPE_IF_PWR_1_1      0xff
 391  369  
 392  370  /*
 393  371   * Configuration Power Descriptor
 394  372   *      This reports the power consuption of the device core
 395  373   *      for all types of USB devices.
 396  374   */
 397  375  typedef struct usba_cfg_pwr_descr {
 398  376          uint8_t         bLength;        /* size of this descriptor 0x12 */
 399  377          uint8_t         bDescriptorType;        /* config pwr descr 0x07 */
 400  378          uint16_t        SelfPowerConsumedD0_l;  /* power consumed lower word */
 401  379          uint8_t         SelfPowerConsumedD0_h;  /* power consumed upper byte */
 402  380          uint8_t         bPowerSummaryId;        /* ID for own power devices */
 403  381          uint8_t         bBusPowerSavingD1;      /* power saving in D1 */
 404  382          uint8_t         bSelfPowerSavingD1;     /* power saving in D1 */
 405  383          uint8_t         bBusPowerSavingD2;      /* power saving in D2 */
 406  384          uint8_t         bSelfPowerSavingD2;     /* power saving in D2 */
 407  385          uint8_t         bBusPowerSavingD3;      /* power saving in D3 */
 408  386          uint8_t         bSelfPowerSavingD3;     /* power saving in D3 */
 409  387          uint16_t        TransitionTimeFromD1;   /* D1 -> D0 transition time */
 410  388          uint16_t        TransitionTimeFromD2;   /* D2 -> D0 transition time */
 411  389          uint16_t        TransitionTimeFromD3;   /* D3 -> D0 transition time */
 412  390  } usba_cfg_pwr_descr_t;
 413  391  
 414  392  /*
 415  393   * Interface Power Descriptor
 416  394   *      This reports the power states implemented by the interface
 417  395   *      and its wake-up capabilities.
 418  396   */
 419  397  typedef struct usba_if_pwr_descr {
 420  398          uint8_t         bLength;        /* size of this descriptor 0x0F */
 421  399          uint8_t         bDescriptorType;        /* i/f pwr descr 0x08 */
 422  400          uint8_t         bmCapabilitiesFlags;    /* wakeup & pwr transition */
 423  401          uint8_t         bBusPowerSavingD1;      /* power saving in D1 */
 424  402          uint8_t         bSelfPowerSavingD1;     /* power saving in D1 */
 425  403          uint8_t         bBusPowerSavingD2;      /* power saving in D2 */
 426  404          uint8_t         bSelfPowerSavingD2;     /* power saving in D2 */
 427  405          uint8_t         bBusPowerSavingD3;      /* power saving in D3 */
 428  406          uint8_t         bSelfPowerSavingD3;     /* power saving in D3 */
 429  407          uint16_t        TransitionTimeFromD1;   /* D1 -> D0 transition time */
 430  408          uint16_t        TransitionTimeFromD2;   /* D2 -> D0 transition time */
 431  409          uint16_t        TransitionTimeFromD3;   /* D3 -> D0 transition time */
 432  410  } usba_if_pwr_descr_t;
 433  411  
 434  412  size_t usba_parse_cfg_pwr_descr(uchar_t *, size_t, usba_cfg_pwr_descr_t *,
 435  413                                                  size_t);
 436  414  
 437  415  size_t usba_parse_if_pwr_descr(uchar_t *, size_t buflen, uint_t,
 438  416          uint_t, usba_if_pwr_descr_t *, size_t);
 439  417  
 440  418  /*
 441  419   * Returns (at ret_descr) a null-terminated string.  Null termination is
 442  420   * guaranteed, even if the string is longer than the buffer.  Thus, a
 443  421   * maximum of (ret_buf_len - 1) characters are returned.
 444  422   *
 445  423   * XXX is this needed when there is usb_get_string_descriptor
 446  424   * If so, then more comments about how it differs?
 447  425   */
 448  426  size_t usba_ascii_string_descr(uchar_t *, size_t, char *, size_t);
 449  427  
 450  428  
 451  429  /*
 452  430   * usb common power management, for usb_mid, usb_ia and maybe other simple
 453  431   * drivers.
 454  432   */
 455  433  typedef struct usb_common_power_struct {
 456  434          void            *uc_usb_statep; /* points back to state structure */
 457  435  
 458  436          uint8_t         uc_wakeup_enabled;
 459  437  
 460  438          /* this is the bit mask of the power states that device has */
 461  439          uint8_t         uc_pwr_states;
 462  440  
 463  441          /* wakeup and power transition capabilites of an interface */
 464  442          uint8_t         uc_pm_capabilities;
 465  443  
 466  444          uint8_t         uc_current_power;       /* current power level */
 467  445  } usb_common_power_t;
 468  446  
 469  447  /* warlock directives, stable data */
 470  448  
 471  449  _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_common_power_t::uc_usb_statep))
 472  450  _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_common_power_t::uc_wakeup_enabled))
 473  451  _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_common_power_t::uc_pwr_states))
 474  452  _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_common_power_t::uc_pm_capabilities))
 475  453  _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_common_power_t::uc_current_power))
 476  454  
 477  455  /* power management */
 478  456  int usba_common_power(dev_info_t *, uint8_t *, int *, int);
 479  457  
 480  458  /*
 481  459   * usb common events handler for usb_mid, usb_ia and maybe other nexus
 482  460   * drivers.
 483  461   */
 484  462  
 485  463  void usba_common_register_events(dev_info_t *, uint_t,
 486  464          void (*)(dev_info_t *, ddi_eventcookie_t, void *, void *));
 487  465  
 488  466  void usba_common_unregister_events(dev_info_t *, uint_t);
 489  467  
 490  468  
 491  469  #ifdef  __cplusplus
 492  470  }
 493  471  #endif
 494  472  
 495  473  #endif  /* _SYS_USB_USBA_USBA_PRIVATE_H */
  
    | ↓ open down ↓ | 256 lines elided | ↑ open up ↑ | 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX