• Home
  • Raw
  • Download

Lines Matching +full:vcc +full:- +full:p

1 // SPDX-License-Identifier: GPL-2.0-only
2 /* net/sched/sch_atm.c - ATM VC selection "queueing discipline" */
4 /* Written 1998-2000 by Werner Almesberger, EPFL ICA */
36 * - sometimes messes up the IP stack
37 * - any manipulations besides the few operations described in the README, are
39 * - should lock the flow while there is data in the queue (?)
42 #define VCC2FLOW(vcc) ((struct atm_flow_data *) ((vcc)->user_back)) argument
49 struct atm_vcc *vcc; /* VCC; NULL if VCC is closed */ member
50 void (*old_pop)(struct atm_vcc *vcc,
71 /* ------------------------- Class/flow operations ------------------------- */
75 struct atm_qdisc_data *p = qdisc_priv(sch); in lookup_flow() local
78 list_for_each_entry(flow, &p->flows, list) { in lookup_flow()
79 if (flow->common.classid == classid) in lookup_flow()
89 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_graft() local
92 pr_debug("atm_tc_graft(sch %p,[qdisc %p],flow %p,new %p,old %p)\n", in atm_tc_graft()
93 sch, p, flow, new, old); in atm_tc_graft()
94 if (list_empty(&flow->list)) in atm_tc_graft()
95 return -EINVAL; in atm_tc_graft()
98 *old = flow->q; in atm_tc_graft()
99 flow->q = new; in atm_tc_graft()
109 pr_debug("atm_tc_leaf(sch %p,flow %p)\n", sch, flow); in atm_tc_leaf()
110 return flow ? flow->q : NULL; in atm_tc_leaf()
115 struct atm_qdisc_data *p __maybe_unused = qdisc_priv(sch); in atm_tc_find()
118 pr_debug("%s(sch %p,[qdisc %p],classid %x)\n", __func__, sch, p, classid); in atm_tc_find()
120 pr_debug("%s: flow %p\n", __func__, flow); in atm_tc_find()
127 struct atm_qdisc_data *p __maybe_unused = qdisc_priv(sch); in atm_tc_bind_filter()
130 pr_debug("%s(sch %p,[qdisc %p],classid %x)\n", __func__, sch, p, classid); in atm_tc_bind_filter()
133 flow->ref++; in atm_tc_bind_filter()
134 pr_debug("%s: flow %p\n", __func__, flow); in atm_tc_bind_filter()
145 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_put() local
148 pr_debug("atm_tc_put(sch %p,[qdisc %p],flow %p)\n", sch, p, flow); in atm_tc_put()
149 if (--flow->ref) in atm_tc_put()
152 list_del_init(&flow->list); in atm_tc_put()
153 pr_debug("atm_tc_put: qdisc %p\n", flow->q); in atm_tc_put()
154 qdisc_put(flow->q); in atm_tc_put()
155 tcf_block_put(flow->block); in atm_tc_put()
156 if (flow->sock) { in atm_tc_put()
158 file_count(flow->sock->file)); in atm_tc_put()
159 flow->vcc->pop = flow->old_pop; in atm_tc_put()
160 sockfd_put(flow->sock); in atm_tc_put()
162 if (flow->excess) in atm_tc_put()
163 atm_tc_put(sch, (unsigned long)flow->excess); in atm_tc_put()
164 if (flow != &p->link) in atm_tc_put()
167 * If flow == &p->link, the qdisc no longer works at this point and in atm_tc_put()
172 static void sch_atm_pop(struct atm_vcc *vcc, struct sk_buff *skb) in sch_atm_pop() argument
174 struct atm_qdisc_data *p = VCC2FLOW(vcc)->parent; in sch_atm_pop() local
176 pr_debug("sch_atm_pop(vcc %p,skb %p,[qdisc %p])\n", vcc, skb, p); in sch_atm_pop()
177 VCC2FLOW(vcc)->old_pop(vcc, skb); in sch_atm_pop()
178 tasklet_schedule(&p->task); in sch_atm_pop()
182 0xaa, /* DSAP: non-ISO */
183 0xaa, /* SSAP: non-ISO */
199 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_change() local
208 pr_debug("atm_tc_change(sch %p,[qdisc %p],classid %x,parent %x," in atm_tc_change()
209 "flow %p,opt %p)\n", sch, p, classid, parent, flow, opt); in atm_tc_change()
213 if (parent && parent != TC_H_ROOT && parent != sch->handle) in atm_tc_change()
214 return -EINVAL; in atm_tc_change()
223 return -EBUSY; in atm_tc_change()
225 return -EINVAL; in atm_tc_change()
233 return -EINVAL; in atm_tc_change()
249 return -ENOENT; in atm_tc_change()
252 opt->nla_type, nla_len(opt), hdr_len); in atm_tc_change()
256 pr_debug("atm_tc_change: f_count %ld\n", file_count(sock->file)); in atm_tc_change()
257 if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) { in atm_tc_change()
258 error = -EPROTOTYPE; in atm_tc_change()
262 on vcc->send */ in atm_tc_change()
264 if (TC_H_MAJ(classid ^ sch->handle)) { in atm_tc_change()
266 error = -EINVAL; in atm_tc_change()
274 classid = TC_H_MAKE(sch->handle, 0x8000 | i); in atm_tc_change()
282 pr_debug("atm_tc_change: flow %p\n", flow); in atm_tc_change()
284 error = -ENOBUFS; in atm_tc_change()
288 error = tcf_block_get(&flow->block, &flow->filter_list, sch, in atm_tc_change()
295 flow->q = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, classid, in atm_tc_change()
297 if (!flow->q) in atm_tc_change()
298 flow->q = &noop_qdisc; in atm_tc_change()
299 pr_debug("atm_tc_change: qdisc %p\n", flow->q); in atm_tc_change()
300 flow->sock = sock; in atm_tc_change()
301 flow->vcc = ATM_SD(sock); /* speedup */ in atm_tc_change()
302 flow->vcc->user_back = flow; in atm_tc_change()
303 pr_debug("atm_tc_change: vcc %p\n", flow->vcc); in atm_tc_change()
304 flow->old_pop = flow->vcc->pop; in atm_tc_change()
305 flow->parent = p; in atm_tc_change()
306 flow->vcc->pop = sch_atm_pop; in atm_tc_change()
307 flow->common.classid = classid; in atm_tc_change()
308 flow->ref = 1; in atm_tc_change()
309 flow->excess = excess; in atm_tc_change()
310 list_add(&flow->list, &p->link.list); in atm_tc_change()
311 flow->hdr_len = hdr_len; in atm_tc_change()
313 memcpy(flow->hdr, hdr, hdr_len); in atm_tc_change()
315 memcpy(flow->hdr, llc_oui_ip, sizeof(llc_oui_ip)); in atm_tc_change()
325 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_delete() local
328 pr_debug("atm_tc_delete(sch %p,[qdisc %p],flow %p)\n", sch, p, flow); in atm_tc_delete()
329 if (list_empty(&flow->list)) in atm_tc_delete()
330 return -EINVAL; in atm_tc_delete()
331 if (rcu_access_pointer(flow->filter_list) || flow == &p->link) in atm_tc_delete()
332 return -EBUSY; in atm_tc_delete()
337 if (flow->ref < 2) { in atm_tc_delete()
338 pr_err("atm_tc_delete: flow->ref == %d\n", flow->ref); in atm_tc_delete()
339 return -EINVAL; in atm_tc_delete()
341 if (flow->ref > 2) in atm_tc_delete()
342 return -EBUSY; /* catch references via excess, etc. */ in atm_tc_delete()
349 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_walk() local
352 pr_debug("atm_tc_walk(sch %p,[qdisc %p],walker %p)\n", sch, p, walker); in atm_tc_walk()
353 if (walker->stop) in atm_tc_walk()
355 list_for_each_entry(flow, &p->flows, list) { in atm_tc_walk()
356 if (walker->count >= walker->skip && in atm_tc_walk()
357 walker->fn(sch, (unsigned long)flow, walker) < 0) { in atm_tc_walk()
358 walker->stop = 1; in atm_tc_walk()
361 walker->count++; in atm_tc_walk()
368 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_tcf_block() local
371 pr_debug("atm_tc_find_tcf(sch %p,[qdisc %p],flow %p)\n", sch, p, flow); in atm_tc_tcf_block()
372 return flow ? flow->block : p->link.block; in atm_tc_tcf_block()
375 /* --------------------------- Qdisc operations ---------------------------- */
380 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_enqueue() local
386 pr_debug("atm_tc_enqueue(skb %p,sch %p,[qdisc %p])\n", skb, sch, p); in atm_tc_enqueue()
389 if (TC_H_MAJ(skb->priority) != sch->handle || in atm_tc_enqueue()
390 !(flow = (struct atm_flow_data *)atm_tc_find(sch, skb->priority))) { in atm_tc_enqueue()
393 list_for_each_entry(flow, &p->flows, list) { in atm_tc_enqueue()
394 fl = rcu_dereference_bh(flow->filter_list); in atm_tc_enqueue()
413 flow = &p->link; in atm_tc_enqueue()
415 if (flow->vcc) in atm_tc_enqueue()
416 ATM_SKB(skb)->atm_options = flow->vcc->atm_options; in atm_tc_enqueue()
417 /*@@@ looks good ... but it's not supposed to work :-) */ in atm_tc_enqueue()
429 if (flow->excess) in atm_tc_enqueue()
430 flow = flow->excess; in atm_tc_enqueue()
432 ATM_SKB(skb)->atm_options |= ATM_ATMOPT_CLP; in atm_tc_enqueue()
438 ret = qdisc_enqueue(skb, flow->q, to_free); in atm_tc_enqueue()
444 flow->qstats.drops++; in atm_tc_enqueue()
451 * expects to be able to q->dequeue the packet later on if we return in atm_tc_enqueue()
452 * success at this place. Also, sch->q.qdisc needs to reflect whether in atm_tc_enqueue()
457 if (flow == &p->link) { in atm_tc_enqueue()
458 sch->q.qlen++; in atm_tc_enqueue()
461 tasklet_schedule(&p->task); in atm_tc_enqueue()
469 * non-ATM interfaces.
475 struct atm_qdisc_data *p = qdisc_priv(sch); in sch_atm_dequeue() local
479 pr_debug("sch_atm_dequeue(sch %p,[qdisc %p])\n", sch, p); in sch_atm_dequeue()
480 list_for_each_entry(flow, &p->flows, list) { in sch_atm_dequeue()
481 if (flow == &p->link) in sch_atm_dequeue()
487 while ((skb = flow->q->ops->peek(flow->q))) { in sch_atm_dequeue()
488 if (!atm_may_send(flow->vcc, skb->truesize)) in sch_atm_dequeue()
491 skb = qdisc_dequeue_peeked(flow->q); in sch_atm_dequeue()
496 bstats_update(&flow->bstats, skb); in sch_atm_dequeue()
497 pr_debug("atm_tc_dequeue: sending on class %p\n", flow); in sch_atm_dequeue()
500 if (skb_headroom(skb) < flow->hdr_len) { in sch_atm_dequeue()
503 new = skb_realloc_headroom(skb, flow->hdr_len); in sch_atm_dequeue()
509 pr_debug("sch_atm_dequeue: ip %p, data %p\n", in sch_atm_dequeue()
510 skb_network_header(skb), skb->data); in sch_atm_dequeue()
511 ATM_SKB(skb)->vcc = flow->vcc; in sch_atm_dequeue()
512 memcpy(skb_push(skb, flow->hdr_len), flow->hdr, in sch_atm_dequeue()
513 flow->hdr_len); in sch_atm_dequeue()
514 refcount_add(skb->truesize, in sch_atm_dequeue()
515 &sk_atm(flow->vcc)->sk_wmem_alloc); in sch_atm_dequeue()
517 flow->vcc->send(flow->vcc, skb); in sch_atm_dequeue()
524 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_dequeue() local
527 pr_debug("atm_tc_dequeue(sch %p,[qdisc %p])\n", sch, p); in atm_tc_dequeue()
528 tasklet_schedule(&p->task); in atm_tc_dequeue()
529 skb = qdisc_dequeue_peeked(p->link.q); in atm_tc_dequeue()
531 sch->q.qlen--; in atm_tc_dequeue()
537 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_peek() local
539 pr_debug("atm_tc_peek(sch %p,[qdisc %p])\n", sch, p); in atm_tc_peek()
541 return p->link.q->ops->peek(p->link.q); in atm_tc_peek()
547 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_init() local
550 pr_debug("atm_tc_init(sch %p,[qdisc %p],opt %p)\n", sch, p, opt); in atm_tc_init()
551 INIT_LIST_HEAD(&p->flows); in atm_tc_init()
552 INIT_LIST_HEAD(&p->link.list); in atm_tc_init()
553 list_add(&p->link.list, &p->flows); in atm_tc_init()
554 p->link.q = qdisc_create_dflt(sch->dev_queue, in atm_tc_init()
555 &pfifo_qdisc_ops, sch->handle, extack); in atm_tc_init()
556 if (!p->link.q) in atm_tc_init()
557 p->link.q = &noop_qdisc; in atm_tc_init()
558 pr_debug("atm_tc_init: link (%p) qdisc %p\n", &p->link, p->link.q); in atm_tc_init()
559 p->link.vcc = NULL; in atm_tc_init()
560 p->link.sock = NULL; in atm_tc_init()
561 p->link.common.classid = sch->handle; in atm_tc_init()
562 p->link.ref = 1; in atm_tc_init()
564 err = tcf_block_get(&p->link.block, &p->link.filter_list, sch, in atm_tc_init()
569 tasklet_init(&p->task, sch_atm_dequeue, (unsigned long)sch); in atm_tc_init()
575 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_reset() local
578 pr_debug("atm_tc_reset(sch %p,[qdisc %p])\n", sch, p); in atm_tc_reset()
579 list_for_each_entry(flow, &p->flows, list) in atm_tc_reset()
580 qdisc_reset(flow->q); in atm_tc_reset()
585 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_destroy() local
588 pr_debug("atm_tc_destroy(sch %p,[qdisc %p])\n", sch, p); in atm_tc_destroy()
589 list_for_each_entry(flow, &p->flows, list) { in atm_tc_destroy()
590 tcf_block_put(flow->block); in atm_tc_destroy()
591 flow->block = NULL; in atm_tc_destroy()
594 list_for_each_entry_safe(flow, tmp, &p->flows, list) { in atm_tc_destroy()
595 if (flow->ref > 1) in atm_tc_destroy()
596 pr_err("atm_destroy: %p->ref = %d\n", flow, flow->ref); in atm_tc_destroy()
599 tasklet_kill(&p->task); in atm_tc_destroy()
605 struct atm_qdisc_data *p = qdisc_priv(sch); in atm_tc_dump_class() local
609 pr_debug("atm_tc_dump_class(sch %p,[qdisc %p],flow %p,skb %p,tcm %p)\n", in atm_tc_dump_class()
610 sch, p, flow, skb, tcm); in atm_tc_dump_class()
611 if (list_empty(&flow->list)) in atm_tc_dump_class()
612 return -EINVAL; in atm_tc_dump_class()
613 tcm->tcm_handle = flow->common.classid; in atm_tc_dump_class()
614 tcm->tcm_info = flow->q->handle; in atm_tc_dump_class()
620 if (nla_put(skb, TCA_ATM_HDR, flow->hdr_len, flow->hdr)) in atm_tc_dump_class()
622 if (flow->vcc) { in atm_tc_dump_class()
628 pvc.sap_addr.itf = flow->vcc->dev ? flow->vcc->dev->number : -1; in atm_tc_dump_class()
629 pvc.sap_addr.vpi = flow->vcc->vpi; in atm_tc_dump_class()
630 pvc.sap_addr.vci = flow->vcc->vci; in atm_tc_dump_class()
633 state = ATM_VF2VS(flow->vcc->flags); in atm_tc_dump_class()
637 if (flow->excess) { in atm_tc_dump_class()
638 if (nla_put_u32(skb, TCA_ATM_EXCESS, flow->common.classid)) in atm_tc_dump_class()
648 return -1; in atm_tc_dump_class()
657 d, NULL, &flow->bstats) < 0 || in atm_tc_dump_class_stats()
658 gnet_stats_copy_queue(d, NULL, &flow->qstats, flow->q->q.qlen) < 0) in atm_tc_dump_class_stats()
659 return -1; in atm_tc_dump_class_stats()