Changeset a5b3de6 in mainline


Ignore:
Timestamp:
2017-10-25T11:55:15Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2b35478
Parents:
c3d926f
Message:

usbhost endpoint: removed target

The reasons for having usb_target_t inside endpoint have been dismissed. Enpoint is not a target of a transaction, so this was just misleading.

Location:
uspace
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/ehci_rh.c

    rc3d926f ra5b3de6  
    144144        assert(instance);
    145145        assert(batch);
    146         const usb_target_t target = batch->ep->target;
    147         batch->error = virthub_base_request(&instance->base, target,
     146        batch->error = virthub_base_request(&instance->base, batch->target,
    148147            batch->dir, (void*) batch->setup.buffer,
    149148            batch->buffer, batch->buffer_size, &batch->transfered_size);
     
    179178            instance, batch);
    180179        if (batch) {
    181                 const usb_target_t target = batch->ep->target;
    182                 batch->error = virthub_base_request(&instance->base, target,
     180                batch->error = virthub_base_request(&instance->base, batch->target,
    183181                    batch->dir, (void*) batch->setup.buffer,
    184182                    batch->buffer, batch->buffer_size, &batch->transfered_size);
  • uspace/drv/bus/usb/ehci/hc.c

    rc3d926f ra5b3de6  
    215215        ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep);
    216216        usb_log_debug("HC(%p) enqueue EP(%d:%d:%s:%s)\n", instance,
    217             ep->target.address, ep->target.endpoint,
     217            ep->device->address, ep->endpoint,
    218218            usb_str_transfer_type_short(ep->transfer_type),
    219219            usb_str_direction(ep->direction));
     
    239239        ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep);
    240240        usb_log_debug("HC(%p) dequeue EP(%d:%d:%s:%s)\n", instance,
    241             ep->target.address, ep->target.endpoint,
     241            ep->device->address, ep->endpoint,
    242242            usb_str_transfer_type_short(ep->transfer_type),
    243243            usb_str_direction(ep->direction));
     
    291291
    292292        /* Check for root hub communication */
    293         if (batch->ep->target.address == ehci_rh_get_address(&instance->rh)) {
     293        if (batch->target.address == ehci_rh_get_address(&instance->rh)) {
    294294                usb_log_debug("HC(%p): Scheduling BATCH(%p) for RH(%p)",
    295295                    instance, batch, &instance->rh);
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.c

    rc3d926f ra5b3de6  
    6666        assert(ep->speed < ARRAY_SIZE(speed));
    6767        EHCI_MEM32_WR(instance->ep_char,
    68             QH_EP_CHAR_ADDR_SET(ep->target.address) |
    69             QH_EP_CHAR_EP_SET(ep->target.endpoint) |
     68            QH_EP_CHAR_ADDR_SET(ep->device->address) |
     69            QH_EP_CHAR_EP_SET(ep->endpoint) |
    7070            speed[ep->speed] |
    7171            QH_EP_CHAR_MAX_LENGTH_SET(ep->max_packet_size)
  • uspace/drv/bus/usb/ohci/hc.c

    rc3d926f ra5b3de6  
    287287
    288288        /* Check for root hub communication */
    289         if (batch->ep->target.address == ohci_rh_get_address(&instance->rh)) {
     289        if (batch->target.address == ohci_rh_get_address(&instance->rh)) {
    290290                usb_log_debug("OHCI root hub request.\n");
    291291                return ohci_rh_schedule(&instance->rh, batch);
  • uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c

    rc3d926f ra5b3de6  
    4040#include <usb/usb.h>
    4141#include <usb/host/utils/malloc32.h>
     42#include <usb/host/endpoint.h>
     43#include <usb/host/bus.h>
    4244
    4345#include "mem_access.h"
     
    7981        /* Status: address, endpoint nr, direction mask and max packet size. */
    8082        OHCI_MEM32_WR(instance->status,
    81             ((ep->target.address & ED_STATUS_FA_MASK) << ED_STATUS_FA_SHIFT)
    82             | ((ep->target.endpoint & ED_STATUS_EN_MASK) << ED_STATUS_EN_SHIFT)
     83            ((ep->device->address & ED_STATUS_FA_MASK) << ED_STATUS_FA_SHIFT)
     84            | ((ep->endpoint & ED_STATUS_EN_MASK) << ED_STATUS_EN_SHIFT)
    8385            | ((dir[ep->direction] & ED_STATUS_D_MASK) << ED_STATUS_D_SHIFT)
    8486            | ((ep->max_packet_size & ED_STATUS_MPS_MASK)
  • uspace/drv/bus/usb/ohci/ohci_rh.c

    rc3d926f ra5b3de6  
    178178        assert(instance);
    179179        assert(batch);
    180         const usb_target_t target = batch->ep->target;
    181         batch->error = virthub_base_request(&instance->base, target,
     180        batch->error = virthub_base_request(&instance->base, batch->target,
    182181            batch->dir, &batch->setup.packet,
    183182            batch->buffer, batch->buffer_size, &batch->transfered_size);
     
    207206        instance->unfinished_interrupt_transfer = NULL;
    208207        if (batch) {
    209                 const usb_target_t target = batch->ep->target;
    210                 batch->error = virthub_base_request(&instance->base, target,
     208                batch->error = virthub_base_request(&instance->base, batch->target,
    211209                    batch->dir, &batch->setup.packet,
    212210                    batch->buffer, batch->buffer_size, &batch->transfered_size);
  • uspace/drv/bus/usb/uhci/hc.c

    rc3d926f ra5b3de6  
    461461        assert(batch);
    462462
    463         if (batch->ep->target.address == uhci_rh_get_address(&instance->rh))
     463        if (batch->target.address == uhci_rh_get_address(&instance->rh))
    464464                return uhci_rh_schedule(&instance->rh, batch);
    465465
  • uspace/drv/bus/usb/uhci/uhci_batch.c

    rc3d926f ra5b3de6  
    222222            uhci_batch->base.ep->speed == USB_SPEED_LOW;
    223223        const size_t mps = uhci_batch->base.ep->max_packet_size;
    224         const usb_target_t target = uhci_batch->base.ep->target;
    225224
    226225        int toggle = endpoint_toggle_get(uhci_batch->base.ep);
     
    240239                td_init(
    241240                    &uhci_batch->tds[td], DEFAULT_ERROR_COUNT, packet_size,
    242                     toggle, false, low_speed, target, pid, buffer, next_td);
     241                    toggle, false, low_speed, uhci_batch->base.target, pid, buffer, next_td);
    243242
    244243                ++td;
     
    285284            uhci_batch->base.ep->speed == USB_SPEED_LOW;
    286285        const size_t mps = uhci_batch->base.ep->max_packet_size;
    287         const usb_target_t target = uhci_batch->base.ep->target;
     286        const usb_target_t target = uhci_batch->base.target;
    288287
    289288        /* setup stage */
  • uspace/drv/bus/usb/uhci/uhci_rh.c

    rc3d926f ra5b3de6  
    104104        assert(batch);
    105105
    106         const usb_target_t target = batch->ep->target;
    107106        do {
    108                 batch->error = virthub_base_request(&instance->base, target,
     107                batch->error = virthub_base_request(&instance->base, batch->target,
    109108                    batch->dir, (void*) batch->setup.buffer,
    110109                    batch->buffer, batch->buffer_size, &batch->transfered_size);
  • uspace/drv/bus/usb/vhc/transfer.c

    rc3d926f ra5b3de6  
    3838static bool is_set_address_transfer(vhc_transfer_t *transfer)
    3939{
    40         if (transfer->batch->ep->target.endpoint != 0) {
     40        if (transfer->batch->target.endpoint != 0) {
    4141                return false;
    4242        }
     
    8181                if (dir == USB_DIRECTION_IN) {
    8282                        rc = usbvirt_data_in(dev, batch->ep->transfer_type,
    83                             batch->ep->target.endpoint,
     83                            batch->ep->endpoint,
    8484                            batch->buffer, batch->buffer_size,
    8585                            actual_data_size);
     
    8787                        assert(dir == USB_DIRECTION_OUT);
    8888                        rc = usbvirt_data_out(dev, batch->ep->transfer_type,
    89                             batch->ep->target.endpoint,
     89                            batch->ep->endpoint,
    9090                            batch->buffer, batch->buffer_size);
    9191                }
     
    116116        } else {
    117117                if (dir == USB_DIRECTION_IN) {
    118                         rc = usbvirt_ipc_send_data_in(sess, batch->ep->target.endpoint,
     118                        rc = usbvirt_ipc_send_data_in(sess, batch->ep->endpoint,
    119119                            batch->ep->transfer_type,
    120120                            batch->buffer, batch->buffer_size,
     
    122122                } else {
    123123                        assert(dir == USB_DIRECTION_OUT);
    124                         rc = usbvirt_ipc_send_data_out(sess, batch->ep->target.endpoint,
     124                        rc = usbvirt_ipc_send_data_out(sess, batch->ep->endpoint,
    125125                            batch->ep->transfer_type,
    126126                            batch->buffer, batch->buffer_size);
     
    184184        list_foreach(vhc->devices, link, vhc_virtdev_t, dev) {
    185185                fibril_mutex_lock(&dev->guard);
    186                 if (dev->address == transfer->batch->ep->target.address) {
     186                if (dev->address == transfer->batch->target.address) {
    187187                        if (!targets) {
    188188                                list_append(&transfer->link, &dev->transfer_queue);
  • uspace/drv/bus/usb/xhci/bus.c

    rc3d926f ra5b3de6  
    6363{
    6464        /* Extract information from endpoint_desc */
    65         ep->base.target = (usb_target_t) {{
    66                 .address = ep->base.device->address,
    67                 .endpoint = desc->endpoint_no,
    68         }};
     65        ep->base.endpoint = desc->endpoint_no;
    6966        ep->base.direction = desc->direction;
    7067        ep->base.transfer_type = desc->transfer_type;
     
    109106
    110107        /* Register EP0, passing Temporary reference */
    111         ep0->base.target.address = dev->base.address;
    112108        dev->endpoints[0] = ep0;
    113109
     
    254250                return err;
    255251
    256         usb_log_info("Endpoint(%d:%d) registered to XHCI bus.", ep->target.address, ep->target.endpoint);
     252        usb_log_info("Endpoint(%d:%d) registered to XHCI bus.", ep->device->address, ep->endpoint);
    257253        return xhci_device_add_endpoint(xhci_dev, xhci_ep);
    258254}
     
    263259        assert(bus);
    264260
    265         usb_log_info("Endpoint(%d:%d) unregistered from XHCI bus.", ep->target.address, ep->target.endpoint);
     261        usb_log_info("Endpoint(%d:%d) unregistered from XHCI bus.", ep->device->address, ep->endpoint);
    266262
    267263        xhci_device_t *xhci_dev = xhci_device_get(ep->device);
  • uspace/drv/bus/usb/xhci/endpoint.c

    rc3d926f ra5b3de6  
    9494                /* Set up primary stream context array if needed. */
    9595                const size_t size = primary_stream_ctx_array_size(xhci_ep);
    96                 usb_log_debug2("Allocating primary stream context array of size %lu for endpoint %d:%d.",
    97                     size, xhci_ep->base.target.address, xhci_ep->base.target.endpoint);
     96                usb_log_debug2("Allocating primary stream context array of size %lu for endpoint " XHCI_EP_FMT,
     97                    size, XHCI_EP_ARGS(*xhci_ep));
    9898
    9999                xhci_ep->primary_stream_ctx_array = malloc32(size * sizeof(xhci_stream_ctx_t));
     
    104104                memset(xhci_ep->primary_stream_ctx_array, 0, size * sizeof(xhci_stream_ctx_t));
    105105        } else {
    106                 usb_log_debug2("Allocating main transfer ring for endpoint %d:%d.",
    107                     xhci_ep->base.target.address, xhci_ep->base.target.endpoint);
     106                usb_log_debug2("Allocating main transfer ring for endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));
    108107
    109108                xhci_ep->primary_stream_ctx_array = NULL;
     
    121120{
    122121        if (endpoint_uses_streams(xhci_ep)) {
    123                 usb_log_debug2("Freeing primary stream context array for endpoint %d:%d.",
    124                     xhci_ep->base.target.address, xhci_ep->base.target.endpoint);
     122                usb_log_debug2("Freeing primary stream context array for endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));
    125123
    126124                // maybe check if LSA, then skip?
     
    135133                free32(xhci_ep->primary_stream_ctx_array);
    136134        } else {
    137                 usb_log_debug2("Freeing main transfer ring for endpoint %d:%d.",
    138                     xhci_ep->base.target.address, xhci_ep->base.target.endpoint);
     135                usb_log_debug2("Freeing main transfer ring for endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));
    139136
    140137                int err;
     
    151148uint8_t xhci_endpoint_dci(xhci_endpoint_t *ep)
    152149{
    153         return (2 * ep->base.target.endpoint) +
     150        return (2 * ep->base.endpoint) +
    154151                (ep->base.transfer_type == USB_TRANSFER_CONTROL
    155152                 || ep->base.direction == USB_DIRECTION_IN);
     
    280277        }
    281278
    282         const usb_endpoint_t ep_num = ep->base.target.endpoint;
     279        const usb_endpoint_t ep_num = ep->base.endpoint;
    283280
    284281        assert(&dev->base == ep->base.device);
    285         assert(dev->base.address == ep->base.target.address);
    286282
    287283        // TODO Do not fail hard on runtime conditions
     
    307303{
    308304        assert(&dev->base == ep->base.device);
    309         assert(dev->base.address == ep->base.target.address);
    310         assert(dev->endpoints[ep->base.target.endpoint]);
     305        assert(dev->endpoints[ep->base.endpoint]);
    311306
    312307        int err = ENOMEM;
    313         const usb_endpoint_t ep_num = ep->base.target.endpoint;
    314 
    315         dev->endpoints[ep->base.target.endpoint] = NULL;
     308        const usb_endpoint_t ep_num = ep->base.endpoint;
     309
     310        dev->endpoints[ep->base.endpoint] = NULL;
    316311        --dev->active_endpoint_count;
    317312
  • uspace/drv/bus/usb/xhci/endpoint.h

    rc3d926f ra5b3de6  
    8686} xhci_endpoint_t;
    8787
     88#define XHCI_EP_FMT  "(%d:%d %s)"
     89#define XHCI_EP_ARGS(ep)                \
     90        ((ep).base.device->address),    \
     91        ((ep).base.endpoint),           \
     92        (usb_str_transfer_type((ep).base.transfer_type))
     93
    8894typedef struct xhci_device {
    8995        device_t base;          /**< Inheritance. Keep this first. */
  • uspace/drv/bus/usb/xhci/hc.c

    rc3d926f ra5b3de6  
    453453        assert(batch->ep);
    454454
    455         usb_log_debug2("Endpoint(%d:%d) started %s transfer of size %lu.",
    456                 batch->ep->target.address, batch->ep->target.endpoint,
    457                 usb_str_transfer_type(batch->ep->transfer_type),
    458                 batch->buffer_size);
    459 
    460         if (!batch->ep->target.address) {
     455        if (!batch->target.address) {
    461456                usb_log_error("Attempted to schedule transfer to address 0.");
    462457                return EINVAL;
  • uspace/drv/bus/usb/xhci/rh.c

    rc3d926f ra5b3de6  
    216216                            " endpoint %d of detached device '%s': %s",
    217217                            usb_str_transfer_type(ep->base.transfer_type),
    218                             ep->base.target.endpoint, ddf_fun_get_name(dev->base.fun),
     218                            ep->base.endpoint, ddf_fun_get_name(dev->base.fun),
    219219                            str_error(err));
    220220                }
  • uspace/drv/bus/usb/xhci/transfers.c

    rc3d926f ra5b3de6  
    316316
    317317        /* Offline devices don't schedule transfers other than on EP0. */
    318         if (!xhci_dev->online && xhci_ep->base.target.endpoint) {
     318        if (!xhci_dev->online && xhci_ep->base.endpoint) {
    319319                return EAGAIN;
    320320        }
  • uspace/lib/usbhost/include/usb/host/endpoint.h

    rc3d926f ra5b3de6  
    6060        /** USB device */
    6161        device_t *device;
    62         /** USB address. */
    63         usb_target_t target;
     62        /** Enpoint number */
     63        usb_endpoint_t endpoint;
    6464        /** Communication direction. */
    6565        usb_direction_t direction;
     
    108108        return item ? list_get_instance(item, endpoint_t, link) : NULL;
    109109}
     110
    110111#endif
    111112
  • uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h

    rc3d926f ra5b3de6  
    5555/** Structure stores additional data needed for communication with EP */
    5656typedef struct usb_transfer_batch {
     57        /** Target for communication */
     58        usb_target_t target;
     59
    5760        /** Endpoint used for communication */
    5861        endpoint_t *ep;
     62
    5963        /** Size reported to be sent */
    6064        size_t expected_size;
     
    96100 */
    97101#define USB_TRANSFER_BATCH_ARGS(batch) \
    98         (batch).ep->target.address, (batch).ep->target.endpoint, \
     102        (batch).target.address, (batch).target.endpoint, \
    99103        usb_str_speed((batch).ep->speed), \
    100104        usb_str_transfer_type_short((batch).ep->transfer_type), \
  • uspace/lib/usbhost/src/hcd.c

    rc3d926f ra5b3de6  
    109109                usb_log_error("Endpoint(%d:%d) %s needs %zu bw "
    110110                    "but only %zu is reserved.\n",
    111                     ep->target.address, ep->target.endpoint, name, bw, ep->bandwidth);
     111                    device->address, ep->endpoint, name, bw, ep->bandwidth);
    112112                return ENOSPC;
    113113        }
     
    119119        }
    120120
     121        batch->target = target;
    121122        batch->buffer = data;
    122123        batch->buffer_size = size;
  • uspace/lib/usbhost/src/usb2_bus.c

    rc3d926f ra5b3de6  
    273273        usb2_bus_t *bus = bus_to_usb2_bus(bus_base);
    274274
    275         if (!usb_address_is_valid(target.address))
    276                 return NULL;
     275        assert(device->address == target.address);
    277276
    278277        list_foreach(*get_list(bus, target.address), link, endpoint_t, ep) {
     
    280279                       || (ep->direction == USB_DIRECTION_BOTH)
    281280                       || (direction == USB_DIRECTION_BOTH))
    282                     && (target.packed == ep->target.packed))
     281                    && (target.endpoint == ep->endpoint))
    283282                        return ep;
    284283        }
     
    296295}
    297296
     297static usb_target_t usb2_ep_to_target(endpoint_t *ep)
     298{
     299        assert(ep);
     300        assert(ep->device);
     301
     302        return (usb_target_t) {{
     303                .address = ep->device->address,
     304                .endpoint = ep->endpoint,
     305        }};
     306}
     307
    298308/** Register an endpoint to the bus. Reserves bandwidth.
    299309 * @param bus usb_bus structure, non-null.
     
    308318
    309319        /* Extract USB2-related information from endpoint_desc */
    310         ep->target = (usb_target_t) {{
    311                 .address = ep->device->address,
    312                 .endpoint = desc->endpoint_no,
    313         }};
     320        ep->endpoint = desc->endpoint_no;
    314321        ep->direction = desc->direction;
    315322        ep->transfer_type = desc->transfer_type;
     
    320327
    321328        /* Check for existence */
    322         if (usb2_bus_find_ep(bus_base, ep->device, ep->target, ep->direction))
     329        if (usb2_bus_find_ep(bus_base, ep->device, usb2_ep_to_target(ep), ep->direction))
    323330                return EEXIST;
    324331
     
    356363
    357364        list_foreach(*get_list(bus, target.address), link, endpoint_t, ep) {
    358                 if ((ep->target.address == target.address)
    359                     && (all || ep->target.endpoint == target.endpoint)) {
     365                assert(ep->device->address == target.address);
     366
     367                if (all || ep->endpoint == target.endpoint) {
    360368                        endpoint_toggle_set(ep, 0);
    361369                        ret = EOK;
     
    386394                endpoint_t *ep = list_get_instance(link, endpoint_t, link);
    387395                link = list_next(link, list);
    388                 assert(ep->target.address == address);
     396
     397                assert(ep->device->address == address);
    389398                list_remove(&ep->link);
    390399
    391400                usb_log_warning("Endpoint %d:%d %s was left behind, removing.\n",
    392                     ep->target.address, ep->target.endpoint, usb_str_direction(ep->direction));
     401                    address, ep->endpoint, usb_str_direction(ep->direction));
    393402
    394403                /* Drop bus reference */
  • uspace/lib/usbhost/src/usb_transfer_batch.c

    rc3d926f ra5b3de6  
    8181
    8282        if (batch->error == EOK && batch->toggle_reset_mode != RESET_NONE) {
    83                 usb_log_debug2("Reseting %s due to transaction of %d:%d.\n",
    84                     batch->toggle_reset_mode == RESET_ALL ? "all EPs toggle" : "EP toggle",
    85                     batch->ep->target.address, batch->ep->target.endpoint);
    86                 bus_reset_toggle(batch->ep->bus,
    87                     batch->ep->target, batch->toggle_reset_mode == RESET_ALL);
     83                usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " resets %s",
     84                    batch, USB_TRANSFER_BATCH_ARGS(*batch),
     85                    batch->toggle_reset_mode == RESET_ALL ? "all EPs toggle" : "EP toggle");
     86                bus_reset_toggle(batch->ep->bus, 
     87                    batch->target, batch->toggle_reset_mode == RESET_ALL);
    8888        }
    8989
Note: See TracChangeset for help on using the changeset viewer.