Changeset 5f0b366 in mainline for uspace/lib/usbhost/src/endpoint.c


Ignore:
Timestamp:
2018-01-25T02:05:57Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b357377
Parents:
e8277c0
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-24 19:34:07)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-25 02:05:57)
Message:

usbhost: prepare bandwidth accounting privatization to usb2_bus

The endpoint does not account the bandwidth by default. The next step is
moving the count_bw callback to the usb2 bus.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/endpoint.c

    re8277c0 r5f0b366  
    7474
    7575        ep->max_transfer_size = ep->max_packet_size * ep->packets_per_uframe;
    76 
    77         ep->bandwidth = endpoint_count_bw(ep, ep->max_transfer_size);
    7876}
    7977
     
    201199        ep->active_batch = NULL;
    202200        fibril_condvar_signal(&ep->avail);
    203 }
    204 
    205 /**
    206  * Call the bus operation to count bandwidth.
    207  *
    208  * @param ep Endpoint on which the transfer will take place.
    209  * @param size The payload size.
    210  */
    211 ssize_t endpoint_count_bw(endpoint_t *ep, size_t size)
    212 {
    213         assert(ep);
    214 
    215         const bus_ops_t *ops = BUS_OPS_LOOKUP(get_bus_ops(ep), endpoint_count_bw);
    216         if (!ops)
    217                 return 0;
    218 
    219         return ops->endpoint_count_bw(ep, size);
    220201}
    221202
     
    262243        }
    263244
     245        /** Limit transfers with reserved bandwidth to the amount reserved */
     246        if ((ep->transfer_type == USB_TRANSFER_INTERRUPT
     247            || ep->transfer_type == USB_TRANSFER_ISOCHRONOUS)
     248            && size > ep->max_transfer_size)
     249                return ENOSPC;
     250
    264251        /* Offline devices don't schedule transfers other than on EP0. */
    265         if (!device->online && ep->endpoint > 0) {
     252        if (!device->online && ep->endpoint > 0)
    266253                return EAGAIN;
    267         }
    268 
    269         const size_t bw = endpoint_count_bw(ep, size);
    270         /* Check if we have enough bandwidth reserved */
    271         if (ep->bandwidth < bw) {
    272                 usb_log_error("Endpoint(%d:%d) %s needs %zu bw "
    273                     "but only %zu is reserved.\n",
    274                     device->address, ep->endpoint, name, bw, ep->bandwidth);
    275                 return ENOSPC;
    276         }
    277254
    278255        usb_transfer_batch_t *batch = usb_transfer_batch_create(ep);
Note: See TracChangeset for help on using the changeset viewer.