Lines Matching defs:sch_ep
199 struct mu3h_sch_ep_info *sch_ep;
214 sch_ep = kzalloc(mem_size, GFP_KERNEL);
215 if (!sch_ep)
221 kfree(sch_ep);
226 sch_ep->sch_tt = tt;
227 sch_ep->ep = ep;
228 INIT_LIST_HEAD(&sch_ep->endpoint);
229 INIT_LIST_HEAD(&sch_ep->tt_endpoint);
231 return sch_ep;
235 struct xhci_ep_ctx *ep_ctx, struct mu3h_sch_ep_info *sch_ep)
243 u32 *bwb_table = sch_ep->bw_budget_table;
255 sch_ep->esit = get_esit(ep_ctx);
256 sch_ep->ep_type = ep_type;
257 sch_ep->maxpkt = maxpkt;
258 sch_ep->offset = 0;
259 sch_ep->burst_mode = 0;
260 sch_ep->repeat = 0;
263 sch_ep->cs_count = 0;
270 sch_ep->num_budget_microframes = 1;
277 sch_ep->pkts = max_burst + 1;
278 sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts;
279 bwb_table[0] = sch_ep->bw_cost_per_microframe;
282 sch_ep->cs_count = 0;
283 sch_ep->burst_mode = 1;
294 sch_ep->pkts = esit_pkts;
295 sch_ep->num_budget_microframes = 1;
296 bwb_table[0] = maxpkt * sch_ep->pkts;
302 if (sch_ep->esit == 1)
303 sch_ep->pkts = esit_pkts;
304 else if (esit_pkts <= sch_ep->esit)
305 sch_ep->pkts = 1;
307 sch_ep->pkts = roundup_pow_of_two(esit_pkts)
308 / sch_ep->esit;
310 sch_ep->num_budget_microframes =
311 DIV_ROUND_UP(esit_pkts, sch_ep->pkts);
313 sch_ep->repeat = !!(sch_ep->num_budget_microframes > 1);
314 sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts;
316 remainder = sch_ep->bw_cost_per_microframe;
317 remainder *= sch_ep->num_budget_microframes;
319 for (i = 0; i < sch_ep->num_budget_microframes - 1; i++)
320 bwb_table[i] = sch_ep->bw_cost_per_microframe;
326 sch_ep->pkts = 1; /* at most one packet for each microframe */
332 sch_ep->cs_count = DIV_ROUND_UP(maxpkt, FS_PAYLOAD_MAX);
333 sch_ep->num_budget_microframes = sch_ep->cs_count;
334 sch_ep->bw_cost_per_microframe =
339 for (i = 0; i < sch_ep->num_budget_microframes; i++)
340 bwb_table[i] = sch_ep->bw_cost_per_microframe;
343 bwb_table[0] = sch_ep->bw_cost_per_microframe;
354 bwb_table[i] = sch_ep->bw_cost_per_microframe;
361 struct mu3h_sch_ep_info *sch_ep, u32 offset)
369 num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
371 u32 base = offset + i * sch_ep->esit;
373 for (j = 0; j < sch_ep->num_budget_microframes; j++) {
375 sch_ep->bw_budget_table[j];
384 struct mu3h_sch_ep_info *sch_ep, bool used)
391 num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
393 base = sch_ep->offset + i * sch_ep->esit;
394 for (j = 0; j < sch_ep->num_budget_microframes; j++) {
397 sch_ep->bw_budget_table[j];
400 sch_ep->bw_budget_table[j];
405 static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
407 struct mu3h_sch_tt *tt = sch_ep->sch_tt;
411 u8 uframes = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
413 num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
415 if (sch_ep->ep_type == INT_IN_EP || sch_ep->ep_type == ISOC_IN_EP)
419 base = offset + i * sch_ep->esit;
422 tmp = tt->fs_bus_bw[base + j] + sch_ep->bw_cost_per_microframe;
432 struct mu3h_sch_ep_info *sch_ep, u32 offset)
440 if (sch_ep->ep_type == ISOC_OUT_EP) {
441 last_ss = start_ss + sch_ep->cs_count - 1;
451 u32 cs_count = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
467 if (sch_ep->ep_type == ISOC_IN_EP)
476 sch_ep->cs_count = cs_count;
478 sch_ep->num_budget_microframes = cs_count + 2;
482 * than sch_ep->esit, will overstep boundary
484 if (sch_ep->num_budget_microframes > sch_ep->esit)
485 sch_ep->num_budget_microframes = sch_ep->esit;
488 return check_fs_bus_bw(sch_ep, offset);
492 struct mu3h_sch_ep_info *sch_ep, bool used)
494 struct mu3h_sch_tt *tt = sch_ep->sch_tt;
498 int offset = sch_ep->offset;
499 u8 uframes = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
501 num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
504 bw_updated = sch_ep->bw_cost_per_microframe;
506 bw_updated = -sch_ep->bw_cost_per_microframe;
508 if (sch_ep->ep_type == INT_IN_EP || sch_ep->ep_type == ISOC_IN_EP)
512 base = offset + i * sch_ep->esit;
519 list_add_tail(&sch_ep->tt_endpoint, &tt->ep_list);
521 list_del(&sch_ep->tt_endpoint);
525 struct mu3h_sch_ep_info *sch_ep, bool loaded)
527 if (sch_ep->sch_tt)
528 update_sch_tt(udev, sch_ep, loaded);
531 update_bus_bw(sch_bw, sch_ep, loaded);
532 sch_ep->allocated = loaded;
537 static u32 get_esit_boundary(struct mu3h_sch_ep_info *sch_ep)
539 u32 boundary = sch_ep->esit;
541 if (sch_ep->sch_tt) { /* LS/FS with TT */
547 if (sch_ep->ep_type == ISOC_OUT_EP && boundary > 1)
555 struct mu3h_sch_bw_info *sch_bw, struct mu3h_sch_ep_info *sch_ep)
573 min_cs_count = sch_ep->cs_count;
574 min_num_budget = sch_ep->num_budget_microframes;
575 esit_boundary = get_esit_boundary(sch_ep);
576 for (offset = 0; offset < sch_ep->esit; offset++) {
577 if (sch_ep->sch_tt) {
578 ret = check_sch_tt(udev, sch_ep, offset);
583 if ((offset + sch_ep->num_budget_microframes) > esit_boundary)
586 worst_bw = get_max_bw(sch_bw, sch_ep, offset);
590 min_cs_count = sch_ep->cs_count;
591 min_num_budget = sch_ep->num_budget_microframes;
608 sch_ep->offset = min_index;
609 sch_ep->cs_count = min_cs_count;
610 sch_ep->num_budget_microframes = min_num_budget;
612 return load_ep_bw(udev, sch_bw, sch_ep, true);
616 struct mu3h_sch_bw_info *sch_bw, struct mu3h_sch_ep_info *sch_ep)
619 if (sch_ep->allocated)
620 load_ep_bw(udev, sch_bw, sch_ep, false);
622 if (sch_ep->sch_tt)
625 list_del(&sch_ep->endpoint);
626 kfree(sch_ep);
691 struct mu3h_sch_ep_info *sch_ep;
717 sch_ep = create_sch_ep(udev, ep, ep_ctx);
718 if (IS_ERR_OR_NULL(sch_ep))
721 setup_sch_info(udev, ep_ctx, sch_ep);
723 list_add_tail(&sch_ep->endpoint, &mtk->bw_ep_chk_list);
738 struct mu3h_sch_ep_info *sch_ep, *tmp;
757 list_for_each_entry_safe(sch_ep, tmp, &sch_bw->bw_ep_list, endpoint) {
758 if (sch_ep->ep == ep) {
759 destroy_sch_ep(udev, sch_bw, sch_ep);
772 struct mu3h_sch_ep_info *sch_ep, *tmp;
777 list_for_each_entry(sch_ep, &mtk->bw_ep_chk_list, endpoint) {
778 bw_index = get_bw_index(xhci, udev, sch_ep->ep);
781 ret = check_sch_bw(udev, sch_bw, sch_ep);
789 list_for_each_entry_safe(sch_ep, tmp, &mtk->bw_ep_chk_list, endpoint) {
791 struct usb_host_endpoint *ep = sch_ep->ep;
797 list_move_tail(&sch_ep->endpoint, &sch_bw->bw_ep_list);
800 ep_ctx->reserved[0] = cpu_to_le32(EP_BPKTS(sch_ep->pkts)
801 | EP_BCSCOUNT(sch_ep->cs_count)
802 | EP_BBM(sch_ep->burst_mode));
803 ep_ctx->reserved[1] = cpu_to_le32(EP_BOFFSET(sch_ep->offset)
804 | EP_BREPEAT(sch_ep->repeat));
807 sch_ep->pkts, sch_ep->cs_count, sch_ep->burst_mode,
808 sch_ep->offset, sch_ep->repeat);
820 struct mu3h_sch_ep_info *sch_ep, *tmp;
825 list_for_each_entry_safe(sch_ep, tmp, &mtk->bw_ep_chk_list, endpoint) {
826 bw_index = get_bw_index(xhci, udev, sch_ep->ep);
828 destroy_sch_ep(udev, sch_bw, sch_ep);