Changeset 5f0b366 in mainline
- Timestamp:
- 2018-01-25T02:05:57Z (7 years ago)
- 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)
- Location:
- uspace/lib/usbhost
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/endpoint.h
re8277c0 r5f0b366 87 87 fibril_condvar_t avail; 88 88 89 /** Reserved bandwidth. Needed for USB2 bus. */90 size_t bandwidth;91 89 /** Endpoint number */ 92 90 usb_endpoint_t endpoint; … … 121 119 extern void endpoint_deactivate_locked(endpoint_t *); 122 120 123 /* Calculate bandwidth */124 ssize_t endpoint_count_bw(endpoint_t *, size_t);125 126 121 int endpoint_send_batch(endpoint_t *, usb_target_t, usb_direction_t, 127 122 char *, size_t, uint64_t, usbhc_iface_transfer_callback_t, void *, -
uspace/lib/usbhost/src/endpoint.c
re8277c0 r5f0b366 74 74 75 75 ep->max_transfer_size = ep->max_packet_size * ep->packets_per_uframe; 76 77 ep->bandwidth = endpoint_count_bw(ep, ep->max_transfer_size);78 76 } 79 77 … … 201 199 ep->active_batch = NULL; 202 200 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);220 201 } 221 202 … … 262 243 } 263 244 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 264 251 /* Offline devices don't schedule transfers other than on EP0. */ 265 if (!device->online && ep->endpoint > 0) {252 if (!device->online && ep->endpoint > 0) 266 253 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 }277 254 278 255 usb_transfer_batch_t *batch = usb_transfer_batch_create(ep); -
uspace/lib/usbhost/src/usb2_bus.c
re8277c0 r5f0b366 210 210 211 211 /** 212 * Call the bus operation to count bandwidth. 213 * 214 * @param ep Endpoint on which the transfer will take place. 215 * @param size The payload size. 216 */ 217 static ssize_t endpoint_count_bw(endpoint_t *ep) 218 { 219 assert(ep); 220 221 bus_t *bus = ep->device->bus; 222 const bus_ops_t *ops = BUS_OPS_LOOKUP(bus->ops, endpoint_count_bw); 223 if (!ops) 224 return 0; 225 226 return ops->endpoint_count_bw(ep, ep->max_transfer_size); 227 } 228 229 /** 212 230 * Register an endpoint to the bus. Reserves bandwidth. 213 231 */ … … 218 236 assert(ep); 219 237 238 size_t bw = endpoint_count_bw(ep); 239 220 240 /* Check for available bandwidth */ 221 if ( ep->bandwidth> bus->free_bw)241 if (bw > bus->free_bw) 222 242 return ENOSPC; 223 243 224 bus->free_bw -= ep->bandwidth;244 bus->free_bw -= bw; 225 245 226 246 return EOK; … … 235 255 assert(ep); 236 256 237 bus->free_bw += e p->bandwidth;257 bus->free_bw += endpoint_count_bw(ep); 238 258 } 239 259
Note:
See TracChangeset
for help on using the changeset viewer.