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/io/usb/usba/usbai_register.c
          +++ new/usr/src/uts/common/io/usb/usba/usbai_register.c
↓ 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  /*
  27   29   * USBA: Solaris USB Architecture support
  28   30   *
  29   31   * This module builds a tree of parsed USB standard descriptors and unparsed
  30   32   * Class/Vendor specific (C/V) descriptors.  Routines are grouped into three
  31   33   * groups: those which build the tree, those which take it down, and those which
  32   34   * dump it.
  33   35   *
↓ open down ↓ 71 lines elided ↑ open up ↑
 105  107  int usb_log_descr_tree(usb_client_dev_data_t *, usb_log_handle_t,
 106  108                                  uint_t, uint_t);
 107  109  
 108  110  /* Debug stuff */
 109  111  usb_log_handle_t        usbai_reg_log_handle;
 110  112  uint_t                  usbai_register_errlevel = USB_LOG_L2;
 111  113  uint_t                  usbai_register_dump_errlevel = USB_LOG_L2;
 112  114  uint_t                  usbai_register_errmask = (uint_t)-1;
 113  115  
 114  116  /* Function prototypes */
 115      -static int usba_build_bos(usba_device_t *, usb_client_dev_data_t *);
 116  117  static int usba_build_descr_tree(dev_info_t *, usba_device_t *,
 117  118                                  usb_client_dev_data_t *);
 118  119  static void usba_process_cfg_descr(usba_reg_state_t *);
 119  120  static int usba_process_if_descr(usba_reg_state_t *, boolean_t *);
 120  121  static int usba_process_ep_descr(usba_reg_state_t *);
 121  122  static int usba_process_cv_descr(usba_reg_state_t *);
 122      -static int usba_process_ep_comp_descr(usba_reg_state_t *);
 123  123  static int usba_set_parse_values(dev_info_t *dip, usba_device_t *usba_device,
 124  124      usba_reg_state_t *state);
 125  125  static void* usba_kmem_realloc(void *, int, int);
 126  126  static void usba_augment_array(void **, uint_t, uint_t);
 127  127  static void usba_make_alts_sparse(usb_alt_if_data_t **, uint_t *);
 128  128  
 129  129  static void usba_order_tree(usba_reg_state_t *);
 130  130  
 131  131  static void usba_free_if_array(usb_if_data_t *, uint_t);
 132  132  static void usba_free_ep_array(usb_ep_data_t *, uint_t);
↓ open down ↓ 287 lines elided ↑ open up ↑
 420  420          usb_reg = kmem_zalloc(sizeof (usb_client_dev_data_t), KM_SLEEP);
 421  421          usba_device = usba_get_usba_device(dip);
 422  422          usb_reg->dev_descr = usba_device->usb_dev_descr;
 423  423          usb_reg->dev_default_ph = usba_get_dflt_pipe_handle(dip);
 424  424          if (usb_reg->dev_default_ph == NULL) {
 425  425                  kmem_free(usb_reg, sizeof (usb_client_dev_data_t));
 426  426  
 427  427                  return (USB_FAILURE);
 428  428          }
 429  429  
 430      -        /* get parsed bos for wusb device */
 431      -        if (usba_device->usb_is_wireless) {
 432      -                if ((rval = usba_build_bos(usba_device, usb_reg)) !=
 433      -                    USB_SUCCESS) {
 434      -                        kmem_free(usb_reg, sizeof (usb_client_dev_data_t));
 435      -
 436      -                        return (rval);
 437      -                }
 438      -        }
 439      -
 440  430          usb_reg->dev_iblock_cookie = usba_hcdi_get_hcdi(
 441  431              usba_device->usb_root_hub_dip)->hcdi_soft_iblock_cookie;
 442  432  
 443  433          USB_DPRINTF_L4(DPRINT_MASK_REGISTER, usbai_reg_log_handle,
 444  434              "cookie = 0x%p", (void *)usb_reg->dev_iblock_cookie);
 445  435  
 446  436          tmpbuf = (char *)kmem_zalloc(USB_MAXSTRINGLEN, KM_SLEEP);
 447  437  
 448  438          if (usba_device->usb_mfg_str != NULL) {
 449  439                  usb_reg->dev_mfg = kmem_zalloc(
↓ open down ↓ 138 lines elided ↑ open up ↑
 588  578                  if (reg->dev_mfg != NULL) {
 589  579                          kmem_free((char *)reg->dev_mfg,
 590  580                              strlen((char *)reg->dev_mfg) + 1);
 591  581                  }
 592  582  
 593  583                  /* Free config tree under reg->dev_cfg. */
 594  584                  if (reg->dev_cfg != NULL) {
 595  585                          usb_free_descr_tree(dip, reg);
 596  586                  }
 597  587  
 598      -                if (reg->dev_bos != NULL) {
 599      -                        kmem_free(reg->dev_bos, sizeof (usb_bos_data_t));
 600      -                }
 601      -
 602  588                  mutex_enter(&usba_device->usb_mutex);
 603  589                  prev = &usba_device->usb_client_dev_data_list;
 604  590                  entry = usba_device->usb_client_dev_data_list.cddl_next;
 605  591  
 606  592                  /* free the entries in usb_client_data_list */
 607  593                  while (entry) {
 608  594                          next = entry->cddl_next;
 609  595                          if ((dip == entry->cddl_dip) &&
 610  596                              (reg == entry->cddl_dev_data)) {
 611  597                                  prev->cddl_next = entry->cddl_next;
↓ open down ↓ 28 lines elided ↑ open up ↑
 640  626                  mutex_exit(&usba_device->usb_mutex);
 641  627  
 642  628                  kmem_free(reg, sizeof (usb_client_dev_data_t));
 643  629          }
 644  630  
 645  631          USB_DPRINTF_L4(DPRINT_MASK_REGISTER, usbai_reg_log_handle,
 646  632              "usb_free_dev_data done");
 647  633  }
 648  634  
 649  635  /*
 650      - * This builds the BOS descriptors for WUSB device
 651      - */
 652      -static int
 653      -usba_build_bos(usba_device_t *usba_device, usb_client_dev_data_t *usb_reg)
 654      -{
 655      -        uint8_t         *buf;
 656      -        size_t          size, buflen;
 657      -
 658      -        buf = usba_device->usb_wireless_data->wusb_bos;
 659      -        buflen = usba_device->usb_wireless_data->wusb_bos_length;
 660      -
 661      -        usb_reg->dev_bos = kmem_zalloc(sizeof (usb_bos_data_t),
 662      -            KM_SLEEP);
 663      -        size = usb_parse_bos_descr(buf, buflen, &usb_reg->dev_bos->bos_descr,
 664      -            sizeof (usb_bos_descr_t));
 665      -        if (size != USB_BOS_DESCR_SIZE) {
 666      -                kmem_free(usb_reg->dev_bos, sizeof (usb_bos_data_t));
 667      -
 668      -                return (USB_FAILURE);
 669      -        }
 670      -
 671      -        size = usb_parse_uwb_bos_descr(buf, buflen,
 672      -            &usb_reg->dev_bos->bos_uwb_cap, sizeof (usb_uwb_cap_descr_t));
 673      -        if (size != USB_UWB_CAP_DESCR_SIZE) {
 674      -                kmem_free(usb_reg->dev_bos, sizeof (usb_bos_data_t));
 675      -
 676      -                return (USB_FAILURE);
 677      -        }
 678      -
 679      -        return (USB_SUCCESS);
 680      -}
 681      -
 682      -
 683      -/*
 684  636   * usba_build_descr_tree:
 685  637   *      This builds the descriptor tree.  See module header comment for tree
 686  638   *      description.
 687  639   *
 688  640   * Arguments:
 689  641   *      dip             - devinfo pointer - cannot be NULL.
 690  642   *      usba_device     - pointer to usba_device structure.
 691  643   *      usb_reg         - pointer to area returned to client describing device.
 692  644   *                        number of configuration (dev_n_cfg) and array of
 693  645   *                        configurations (dev_cfg) are initialized here -
↓ open down ↓ 146 lines elided ↑ open up ↑
 840  792                                          if (usba_process_ep_descr(&state) !=
 841  793                                              USB_SUCCESS) {
 842  794  
 843  795                                                  return (USB_FAILURE);
 844  796                                          }
 845  797                                          state.st_last_processed_descr_type =
 846  798                                              USB_DESCR_TYPE_EP;
 847  799                                  }
 848  800  
 849  801                                  break;
 850      -                        case USB_DESCR_TYPE_WIRELESS_EP_COMP:
 851      -                                /* for WUSB devices */
 852      -                                if (process_this_if_tree &&
 853      -                                    state.st_build_ep_comp) {
 854      -                                        if (usba_process_ep_comp_descr(
 855      -                                            &state) != USB_SUCCESS) {
 856      -
 857      -                                                return (USB_FAILURE);
 858      -                                        }
 859      -                                }
 860      -
 861      -                                break;
 862  802                          case USB_DESCR_TYPE_STRING:
 863  803                                  USB_DPRINTF_L2(DPRINT_MASK_ALL,
 864  804                                      usbai_reg_log_handle,
 865  805                                      "usb_get_dev_data: "
 866  806                                      "Found unexpected str descr at addr 0x%p",
 867  807                                      (void *)state.st_curr_raw_descr);
 868  808  
 869  809                                  break;  /* Shouldn't be any here.  Skip. */
 870  810  
 871  811                          default:
↓ open down ↓ 228 lines elided ↑ open up ↑
1100 1040              state->st_curr_raw_descr_len,
1101 1041              &state->st_curr_ep->ep_descr, sizeof (usb_ep_descr_t));
1102 1042  
1103 1043          USB_DPRINTF_L4(DPRINT_MASK_REGISTER, usbai_reg_log_handle,
1104 1044              "usba_process_ep_descr done");
1105 1045  
1106 1046          return (USB_SUCCESS);
1107 1047  }
1108 1048  
1109 1049  
1110      -static int
1111      -usba_process_ep_comp_descr(usba_reg_state_t *state)
1112      -{
1113      -        USB_DPRINTF_L4(DPRINT_MASK_REGISTER, usbai_reg_log_handle,
1114      -            "usba_process_ep_comp_descr starting");
1115      -
1116      -        /* No endpoint descr preceeds this descr */
1117      -        if (state->st_curr_ep == NULL) {
1118      -                USB_DPRINTF_L2(DPRINT_MASK_REGISTER, usbai_reg_log_handle,
1119      -                    "usba_process_ep_comp_descr: no endpt before the descr");
1120      -
1121      -                return (USB_FAILURE);
1122      -        }
1123      -
1124      -        (void) usb_parse_data("ccccsscc", state->st_curr_raw_descr,
1125      -            state->st_curr_raw_descr_len,
1126      -            &state->st_curr_ep->ep_comp_descr,
1127      -            sizeof (usb_ep_comp_descr_t));
1128      -        USB_DPRINTF_L4(DPRINT_MASK_REGISTER, usbai_reg_log_handle,
1129      -            "usba_process_ep_comp_descr done");
1130      -
1131      -        return (USB_SUCCESS);
1132      -}
1133      -
1134 1050  /*
1135 1051   * usba_process_cv_descr:
1136 1052   *      This processes a raw endpoint descriptor, and sets up an analogous
1137 1053   *      endpoint descriptor in the descriptor tree.  C/Vs are associated with
1138 1054   *      other descriptors they follow in the raw data.
1139 1055   *      last_processed_descr_type indicates the type of descr this c/v follows.
1140 1056   *
1141 1057   * Arguments:
1142 1058   *      state           - Pointer to this module's state structure.
1143 1059   *
↓ open down ↓ 76 lines elided ↑ open up ↑
1220 1136   *      USB_SUCCESS     - success
1221 1137   *      USB_INVALID_ARGS - state->st_dev_parse_level is invalid.
1222 1138   */
1223 1139  static int
1224 1140  usba_set_parse_values(dev_info_t *dip, usba_device_t *usba_device,
1225 1141      usba_reg_state_t *state)
1226 1142  {
1227 1143          /* Default to *all* in case configuration# prop not set. */
1228 1144          mutex_enter(&usba_device->usb_mutex);
1229 1145          state->st_cfg_to_build = usba_device->usb_active_cfg_ndx;
1230      -        state->st_build_ep_comp = usba_device->usb_is_wireless;
1231 1146          mutex_exit(&usba_device->usb_mutex);
1232 1147          if (state->st_cfg_to_build == USBA_DEV_CONFIG_INDEX_UNDEFINED) {
1233 1148                  state->st_cfg_to_build = USBA_ALL;
1234 1149          }
1235 1150          state->st_if_to_build = usb_get_if_number(dip);
1236 1151  
1237 1152          switch (state->st_dev_parse_level) {
1238 1153          case USB_PARSE_LVL_ALL:         /* Parse all configurations */
1239 1154                  state->st_cfg_to_build = USBA_ALL;
1240 1155                  state->st_if_to_build = USBA_ALL;
↓ open down ↓ 766 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX