Merge with Linux 2.5.59.
[linux-2.6/linux-mips.git] / net / sched / sch_atm.c
blob5fb95c9c463c7d92eb11deb02495bce9d9e7741d
1 /* net/sched/sch_atm.c - ATM VC selection "queueing discipline" */
3 /* Written 1998-2000 by Werner Almesberger, EPFL ICA */
6 #include <linux/config.h>
7 #include <linux/module.h>
8 #include <linux/string.h>
9 #include <linux/errno.h>
10 #include <linux/skbuff.h>
11 #include <linux/interrupt.h>
12 #include <linux/atmdev.h>
13 #include <linux/atmclip.h>
14 #include <linux/netdevice.h>
15 #include <linux/rtnetlink.h>
16 #include <linux/file.h> /* for fput */
17 #include <net/pkt_sched.h>
18 #include <net/sock.h>
21 extern struct socket *sockfd_lookup(int fd, int *err); /* @@@ fix this */
23 #if 0 /* control */
24 #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
25 #else
26 #define DPRINTK(format,args...)
27 #endif
29 #if 0 /* data */
30 #define D2PRINTK(format,args...) printk(KERN_DEBUG format,##args)
31 #else
32 #define D2PRINTK(format,args...)
33 #endif
37 * The ATM queuing discipline provides a framework for invoking classifiers
38 * (aka "filters"), which in turn select classes of this queuing discipline.
39 * Each class maps the flow(s) it is handling to a given VC. Multiple classes
40 * may share the same VC.
42 * When creating a class, VCs are specified by passing the number of the open
43 * socket descriptor by which the calling process references the VC. The kernel
44 * keeps the VC open at least until all classes using it are removed.
46 * In this file, most functions are named atm_tc_* to avoid confusion with all
47 * the atm_* in net/atm. This naming convention differs from what's used in the
48 * rest of net/sched.
50 * Known bugs:
51 * - sometimes messes up the IP stack
52 * - any manipulations besides the few operations described in the README, are
53 * untested and likely to crash the system
54 * - should lock the flow while there is data in the queue (?)
58 #define PRIV(sch) ((struct atm_qdisc_data *) (sch)->data)
59 #define VCC2FLOW(vcc) ((struct atm_flow_data *) ((vcc)->user_back))
62 struct atm_flow_data {
63 struct Qdisc *q; /* FIFO, TBF, etc. */
64 struct tcf_proto *filter_list;
65 struct atm_vcc *vcc; /* VCC; NULL if VCC is closed */
66 void (*old_pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* chaining */
67 struct atm_qdisc_data *parent; /* parent qdisc */
68 struct socket *sock; /* for closing */
69 u32 classid; /* x:y type ID */
70 int ref; /* reference count */
71 struct tc_stats stats;
72 struct atm_flow_data *next;
73 struct atm_flow_data *excess; /* flow for excess traffic;
74 NULL to set CLP instead */
75 int hdr_len;
76 unsigned char hdr[0]; /* header data; MUST BE LAST */
79 struct atm_qdisc_data {
80 struct atm_flow_data link; /* unclassified skbs go here */
81 struct atm_flow_data *flows; /* NB: "link" is also on this
82 list */
83 struct tasklet_struct task; /* requeue tasklet */
87 /* ------------------------- Class/flow operations ------------------------- */
90 static int find_flow(struct atm_qdisc_data *qdisc,struct atm_flow_data *flow)
92 struct atm_flow_data *walk;
94 DPRINTK("find_flow(qdisc %p,flow %p)\n",qdisc,flow);
95 for (walk = qdisc->flows; walk; walk = walk->next)
96 if (walk == flow) return 1;
97 DPRINTK("find_flow: not found\n");
98 return 0;
102 static __inline__ struct atm_flow_data *lookup_flow(struct Qdisc *sch,
103 u32 classid)
105 struct atm_flow_data *flow;
107 for (flow = PRIV(sch)->flows; flow; flow = flow->next)
108 if (flow->classid == classid) break;
109 return flow;
113 static int atm_tc_graft(struct Qdisc *sch,unsigned long arg,
114 struct Qdisc *new,struct Qdisc **old)
116 struct atm_qdisc_data *p = PRIV(sch);
117 struct atm_flow_data *flow = (struct atm_flow_data *) arg;
119 DPRINTK("atm_tc_graft(sch %p,[qdisc %p],flow %p,new %p,old %p)\n",sch,
120 p,flow,new,old);
121 if (!find_flow(p,flow)) return -EINVAL;
122 if (!new) new = &noop_qdisc;
123 *old = xchg(&flow->q,new);
124 if (*old) qdisc_reset(*old);
125 return 0;
129 static struct Qdisc *atm_tc_leaf(struct Qdisc *sch,unsigned long cl)
131 struct atm_flow_data *flow = (struct atm_flow_data *) cl;
133 DPRINTK("atm_tc_leaf(sch %p,flow %p)\n",sch,flow);
134 return flow ? flow->q : NULL;
138 static unsigned long atm_tc_get(struct Qdisc *sch,u32 classid)
140 struct atm_qdisc_data *p __attribute__((unused)) = PRIV(sch);
141 struct atm_flow_data *flow;
143 DPRINTK("atm_tc_get(sch %p,[qdisc %p],classid %x)\n",sch,p,classid);
144 flow = lookup_flow(sch,classid);
145 if (flow) flow->ref++;
146 DPRINTK("atm_tc_get: flow %p\n",flow);
147 return (unsigned long) flow;
151 static unsigned long atm_tc_bind_filter(struct Qdisc *sch,
152 unsigned long parent, u32 classid)
154 return atm_tc_get(sch,classid);
158 static void destroy_filters(struct atm_flow_data *flow)
160 struct tcf_proto *filter;
162 while ((filter = flow->filter_list)) {
163 DPRINTK("destroy_filters: destroying filter %p\n",filter);
164 flow->filter_list = filter->next;
165 filter->ops->destroy(filter);
171 * atm_tc_put handles all destructions, including the ones that are explicitly
172 * requested (atm_tc_destroy, etc.). The assumption here is that we never drop
173 * anything that still seems to be in use.
176 static void atm_tc_put(struct Qdisc *sch, unsigned long cl)
178 struct atm_qdisc_data *p = PRIV(sch);
179 struct atm_flow_data *flow = (struct atm_flow_data *) cl;
180 struct atm_flow_data **prev;
182 DPRINTK("atm_tc_put(sch %p,[qdisc %p],flow %p)\n",sch,p,flow);
183 if (--flow->ref) return;
184 DPRINTK("atm_tc_put: destroying\n");
185 for (prev = &p->flows; *prev; prev = &(*prev)->next)
186 if (*prev == flow) break;
187 if (!*prev) {
188 printk(KERN_CRIT "atm_tc_put: class %p not found\n",flow);
189 return;
191 *prev = flow->next;
192 DPRINTK("atm_tc_put: qdisc %p\n",flow->q);
193 qdisc_destroy(flow->q);
194 destroy_filters(flow);
195 if (flow->sock) {
196 DPRINTK("atm_tc_put: f_count %d\n",
197 file_count(flow->sock->file));
198 flow->vcc->pop = flow->old_pop;
199 sockfd_put(flow->sock);
201 if (flow->excess) atm_tc_put(sch,(unsigned long) flow->excess);
202 if (flow != &p->link) kfree(flow);
204 * If flow == &p->link, the qdisc no longer works at this point and
205 * needs to be removed. (By the caller of atm_tc_put.)
210 static void sch_atm_pop(struct atm_vcc *vcc,struct sk_buff *skb)
212 struct atm_qdisc_data *p = VCC2FLOW(vcc)->parent;
214 D2PRINTK("sch_atm_pop(vcc %p,skb %p,[qdisc %p])\n",vcc,skb,p);
215 VCC2FLOW(vcc)->old_pop(vcc,skb);
216 tasklet_schedule(&p->task);
220 static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
221 struct rtattr **tca, unsigned long *arg)
223 struct atm_qdisc_data *p = PRIV(sch);
224 struct atm_flow_data *flow = (struct atm_flow_data *) *arg;
225 struct atm_flow_data *excess = NULL;
226 struct rtattr *opt = tca[TCA_OPTIONS-1];
227 struct rtattr *tb[TCA_ATM_MAX];
228 struct socket *sock;
229 int fd,error,hdr_len;
230 void *hdr;
232 DPRINTK("atm_tc_change(sch %p,[qdisc %p],classid %x,parent %x,"
233 "flow %p,opt %p)\n",sch,p,classid,parent,flow,opt);
235 * The concept of parents doesn't apply for this qdisc.
237 if (parent && parent != TC_H_ROOT && parent != sch->handle)
238 return -EINVAL;
240 * ATM classes cannot be changed. In order to change properties of the
241 * ATM connection, that socket needs to be modified directly (via the
242 * native ATM API. In order to send a flow to a different VC, the old
243 * class needs to be removed and a new one added. (This may be changed
244 * later.)
246 if (flow) return -EBUSY;
247 if (opt == NULL || rtattr_parse(tb,TCA_ATM_MAX,RTA_DATA(opt),
248 RTA_PAYLOAD(opt))) return -EINVAL;
249 if (!tb[TCA_ATM_FD-1] || RTA_PAYLOAD(tb[TCA_ATM_FD-1]) < sizeof(fd))
250 return -EINVAL;
251 fd = *(int *) RTA_DATA(tb[TCA_ATM_FD-1]);
252 DPRINTK("atm_tc_change: fd %d\n",fd);
253 if (tb[TCA_ATM_HDR-1]) {
254 hdr_len = RTA_PAYLOAD(tb[TCA_ATM_HDR-1]);
255 hdr = RTA_DATA(tb[TCA_ATM_HDR-1]);
257 else {
258 hdr_len = RFC1483LLC_LEN;
259 hdr = NULL; /* default LLC/SNAP for IP */
261 if (!tb[TCA_ATM_EXCESS-1]) excess = NULL;
262 else {
263 if (RTA_PAYLOAD(tb[TCA_ATM_EXCESS-1]) != sizeof(u32))
264 return -EINVAL;
265 excess = (struct atm_flow_data *) atm_tc_get(sch,
266 *(u32 *) RTA_DATA(tb[TCA_ATM_EXCESS-1]));
267 if (!excess) return -ENOENT;
269 DPRINTK("atm_tc_change: type %d, payload %d, hdr_len %d\n",
270 opt->rta_type,RTA_PAYLOAD(opt),hdr_len);
271 if (!(sock = sockfd_lookup(fd,&error))) return error; /* f_count++ */
272 DPRINTK("atm_tc_change: f_count %d\n",file_count(sock->file));
273 if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) {
274 error = -EPROTOTYPE;
275 goto err_out;
277 /* @@@ should check if the socket is really operational or we'll crash
278 on vcc->send */
279 if (classid) {
280 if (TC_H_MAJ(classid ^ sch->handle)) {
281 DPRINTK("atm_tc_change: classid mismatch\n");
282 error = -EINVAL;
283 goto err_out;
285 if (find_flow(p,flow)) {
286 error = -EEXIST;
287 goto err_out;
290 else {
291 int i;
292 unsigned long cl;
294 for (i = 1; i < 0x8000; i++) {
295 classid = TC_H_MAKE(sch->handle,0x8000 | i);
296 if (!(cl = atm_tc_get(sch,classid))) break;
297 atm_tc_put(sch,cl);
300 DPRINTK("atm_tc_change: new id %x\n",classid);
301 flow = kmalloc(sizeof(struct atm_flow_data)+hdr_len,GFP_KERNEL);
302 DPRINTK("atm_tc_change: flow %p\n",flow);
303 if (!flow) {
304 error = -ENOBUFS;
305 goto err_out;
307 memset(flow,0,sizeof(*flow));
308 flow->filter_list = NULL;
309 if (!(flow->q = qdisc_create_dflt(sch->dev,&pfifo_qdisc_ops)))
310 flow->q = &noop_qdisc;
311 DPRINTK("atm_tc_change: qdisc %p\n",flow->q);
312 flow->sock = sock;
313 flow->vcc = ATM_SD(sock); /* speedup */
314 flow->vcc->user_back = flow;
315 DPRINTK("atm_tc_change: vcc %p\n",flow->vcc);
316 flow->old_pop = flow->vcc->pop;
317 flow->parent = p;
318 flow->vcc->pop = sch_atm_pop;
319 flow->classid = classid;
320 flow->ref = 1;
321 flow->excess = excess;
322 flow->next = p->link.next;
323 p->link.next = flow;
324 flow->hdr_len = hdr_len;
325 if (hdr) memcpy(flow->hdr,hdr,hdr_len);
326 else {
327 memcpy(flow->hdr,llc_oui,sizeof(llc_oui));
328 ((u16 *) flow->hdr)[3] = htons(ETH_P_IP);
330 *arg = (unsigned long) flow;
331 return 0;
332 err_out:
333 if (excess) atm_tc_put(sch,(unsigned long) excess);
334 sockfd_put(sock);
335 return error;
339 static int atm_tc_delete(struct Qdisc *sch,unsigned long arg)
341 struct atm_qdisc_data *p = PRIV(sch);
342 struct atm_flow_data *flow = (struct atm_flow_data *) arg;
344 DPRINTK("atm_tc_delete(sch %p,[qdisc %p],flow %p)\n",sch,p,flow);
345 if (!find_flow(PRIV(sch),flow)) return -EINVAL;
346 if (flow->filter_list || flow == &p->link) return -EBUSY;
348 * Reference count must be 2: one for "keepalive" (set at class
349 * creation), and one for the reference held when calling delete.
351 if (flow->ref < 2) {
352 printk(KERN_ERR "atm_tc_delete: flow->ref == %d\n",flow->ref);
353 return -EINVAL;
355 if (flow->ref > 2) return -EBUSY; /* catch references via excess, etc.*/
356 atm_tc_put(sch,arg);
357 return 0;
361 static void atm_tc_walk(struct Qdisc *sch,struct qdisc_walker *walker)
363 struct atm_qdisc_data *p = PRIV(sch);
364 struct atm_flow_data *flow;
366 DPRINTK("atm_tc_walk(sch %p,[qdisc %p],walker %p)\n",sch,p,walker);
367 if (walker->stop) return;
368 for (flow = p->flows; flow; flow = flow->next) {
369 if (walker->count >= walker->skip)
370 if (walker->fn(sch,(unsigned long) flow,walker) < 0) {
371 walker->stop = 1;
372 break;
374 walker->count++;
379 static struct tcf_proto **atm_tc_find_tcf(struct Qdisc *sch,unsigned long cl)
381 struct atm_qdisc_data *p = PRIV(sch);
382 struct atm_flow_data *flow = (struct atm_flow_data *) cl;
384 DPRINTK("atm_tc_find_tcf(sch %p,[qdisc %p],flow %p)\n",sch,p,flow);
385 return flow ? &flow->filter_list : &p->link.filter_list;
389 /* --------------------------- Qdisc operations ---------------------------- */
392 static int atm_tc_enqueue(struct sk_buff *skb,struct Qdisc *sch)
394 struct atm_qdisc_data *p = PRIV(sch);
395 struct atm_flow_data *flow = NULL ; /* @@@ */
396 struct tcf_result res;
397 int result;
398 int ret = NET_XMIT_POLICED;
400 D2PRINTK("atm_tc_enqueue(skb %p,sch %p,[qdisc %p])\n",skb,sch,p);
401 result = TC_POLICE_OK; /* be nice to gcc */
402 if (TC_H_MAJ(skb->priority) != sch->handle ||
403 !(flow = (struct atm_flow_data *) atm_tc_get(sch,skb->priority)))
404 for (flow = p->flows; flow; flow = flow->next)
405 if (flow->filter_list) {
406 result = tc_classify(skb,flow->filter_list,
407 &res);
408 if (result < 0) continue;
409 flow = (struct atm_flow_data *) res.class;
410 if (!flow) flow = lookup_flow(sch,res.classid);
411 break;
413 if (!flow) flow = &p->link;
414 else {
415 if (flow->vcc)
416 ATM_SKB(skb)->atm_options = flow->vcc->atm_options;
417 /*@@@ looks good ... but it's not supposed to work :-)*/
418 #ifdef CONFIG_NET_CLS_POLICE
419 switch (result) {
420 case TC_POLICE_SHOT:
421 kfree_skb(skb);
422 break;
423 case TC_POLICE_RECLASSIFY:
424 if (flow->excess) flow = flow->excess;
425 else {
426 ATM_SKB(skb)->atm_options |=
427 ATM_ATMOPT_CLP;
428 break;
430 /* fall through */
431 case TC_POLICE_OK:
432 /* fall through */
433 default:
434 break;
436 #endif
438 if (
439 #ifdef CONFIG_NET_CLS_POLICE
440 result == TC_POLICE_SHOT ||
441 #endif
442 (ret = flow->q->enqueue(skb,flow->q)) != 0) {
443 sch->stats.drops++;
444 if (flow) flow->stats.drops++;
445 return ret;
447 sch->stats.bytes += skb->len;
448 sch->stats.packets++;
449 flow->stats.bytes += skb->len;
450 flow->stats.packets++;
452 * Okay, this may seem weird. We pretend we've dropped the packet if
453 * it goes via ATM. The reason for this is that the outer qdisc
454 * expects to be able to q->dequeue the packet later on if we return
455 * success at this place. Also, sch->q.qdisc needs to reflect whether
456 * there is a packet egligible for dequeuing or not. Note that the
457 * statistics of the outer qdisc are necessarily wrong because of all
458 * this. There's currently no correct solution for this.
460 if (flow == &p->link) {
461 sch->q.qlen++;
462 return 0;
464 tasklet_schedule(&p->task);
465 return NET_XMIT_BYPASS;
470 * Dequeue packets and send them over ATM. Note that we quite deliberately
471 * avoid checking net_device's flow control here, simply because sch_atm
472 * uses its own channels, which have nothing to do with any CLIP/LANE/or
473 * non-ATM interfaces.
477 static void sch_atm_dequeue(unsigned long data)
479 struct Qdisc *sch = (struct Qdisc *) data;
480 struct atm_qdisc_data *p = PRIV(sch);
481 struct atm_flow_data *flow;
482 struct sk_buff *skb;
484 D2PRINTK("sch_atm_dequeue(sch %p,[qdisc %p])\n",sch,p);
485 for (flow = p->link.next; flow; flow = flow->next)
487 * If traffic is properly shaped, this won't generate nasty
488 * little bursts. Otherwise, it may ... (but that's okay)
490 while ((skb = flow->q->dequeue(flow->q))) {
491 if (!atm_may_send(flow->vcc,skb->truesize)) {
492 (void) flow->q->ops->requeue(skb,flow->q);
493 break;
495 D2PRINTK("atm_tc_deqeueue: sending on class %p\n",flow);
496 /* remove any LL header somebody else has attached */
497 skb_pull(skb,(char *) skb->nh.iph-(char *) skb->data);
498 if (skb_headroom(skb) < flow->hdr_len) {
499 struct sk_buff *new;
501 new = skb_realloc_headroom(skb,flow->hdr_len);
502 dev_kfree_skb(skb);
503 if (!new) continue;
504 skb = new;
506 D2PRINTK("sch_atm_dequeue: ip %p, data %p\n",
507 skb->nh.iph,skb->data);
508 ATM_SKB(skb)->vcc = flow->vcc;
509 memcpy(skb_push(skb,flow->hdr_len),flow->hdr,
510 flow->hdr_len);
511 atomic_add(skb->truesize,&flow->vcc->tx_inuse);
512 ATM_SKB(skb)->iovcnt = 0;
513 /* atm.atm_options are already set by atm_tc_enqueue */
514 (void) flow->vcc->send(flow->vcc,skb);
519 static struct sk_buff *atm_tc_dequeue(struct Qdisc *sch)
521 struct atm_qdisc_data *p = PRIV(sch);
522 struct sk_buff *skb;
524 D2PRINTK("atm_tc_dequeue(sch %p,[qdisc %p])\n",sch,p);
525 tasklet_schedule(&p->task);
526 skb = p->link.q->dequeue(p->link.q);
527 if (skb) sch->q.qlen--;
528 return skb;
532 static int atm_tc_requeue(struct sk_buff *skb,struct Qdisc *sch)
534 struct atm_qdisc_data *p = PRIV(sch);
535 int ret;
537 D2PRINTK("atm_tc_requeue(skb %p,sch %p,[qdisc %p])\n",skb,sch,p);
538 ret = p->link.q->ops->requeue(skb,p->link.q);
539 if (!ret) sch->q.qlen++;
540 else {
541 sch->stats.drops++;
542 p->link.stats.drops++;
544 return ret;
548 static int atm_tc_drop(struct Qdisc *sch)
550 struct atm_qdisc_data *p = PRIV(sch);
551 struct atm_flow_data *flow;
553 DPRINTK("atm_tc_drop(sch %p,[qdisc %p])\n",sch,p);
554 for (flow = p->flows; flow; flow = flow->next)
555 if (flow->q->ops->drop && flow->q->ops->drop(flow->q))
556 return 1;
557 return 0;
561 static int atm_tc_init(struct Qdisc *sch,struct rtattr *opt)
563 struct atm_qdisc_data *p = PRIV(sch);
565 DPRINTK("atm_tc_init(sch %p,[qdisc %p],opt %p)\n",sch,p,opt);
566 memset(p,0,sizeof(*p));
567 p->flows = &p->link;
568 if(!(p->link.q = qdisc_create_dflt(sch->dev,&pfifo_qdisc_ops)))
569 p->link.q = &noop_qdisc;
570 DPRINTK("atm_tc_init: link (%p) qdisc %p\n",&p->link,p->link.q);
571 p->link.filter_list = NULL;
572 p->link.vcc = NULL;
573 p->link.sock = NULL;
574 p->link.classid = sch->handle;
575 p->link.ref = 1;
576 p->link.next = NULL;
577 tasklet_init(&p->task,sch_atm_dequeue,(unsigned long) sch);
578 MOD_INC_USE_COUNT;
579 return 0;
583 static void atm_tc_reset(struct Qdisc *sch)
585 struct atm_qdisc_data *p = PRIV(sch);
586 struct atm_flow_data *flow;
588 DPRINTK("atm_tc_reset(sch %p,[qdisc %p])\n",sch,p);
589 for (flow = p->flows; flow; flow = flow->next) qdisc_reset(flow->q);
590 sch->q.qlen = 0;
594 static void atm_tc_destroy(struct Qdisc *sch)
596 struct atm_qdisc_data *p = PRIV(sch);
597 struct atm_flow_data *flow;
599 DPRINTK("atm_tc_destroy(sch %p,[qdisc %p])\n",sch,p);
600 /* races ? */
601 while ((flow = p->flows)) {
602 destroy_filters(flow);
603 if (flow->ref > 1)
604 printk(KERN_ERR "atm_destroy: %p->ref = %d\n",flow,
605 flow->ref);
606 atm_tc_put(sch,(unsigned long) flow);
607 if (p->flows == flow) {
608 printk(KERN_ERR "atm_destroy: putting flow %p didn't "
609 "kill it\n",flow);
610 p->flows = flow->next; /* brute force */
611 break;
614 tasklet_kill(&p->task);
615 MOD_DEC_USE_COUNT;
619 static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl,
620 struct sk_buff *skb, struct tcmsg *tcm)
622 struct atm_qdisc_data *p = PRIV(sch);
623 struct atm_flow_data *flow = (struct atm_flow_data *) cl;
624 unsigned char *b = skb->tail;
625 struct rtattr *rta;
627 DPRINTK("atm_tc_dump_class(sch %p,[qdisc %p],flow %p,skb %p,tcm %p)\n",
628 sch,p,flow,skb,tcm);
629 if (!find_flow(p,flow)) return -EINVAL;
630 tcm->tcm_handle = flow->classid;
631 rta = (struct rtattr *) b;
632 RTA_PUT(skb,TCA_OPTIONS,0,NULL);
633 RTA_PUT(skb,TCA_ATM_HDR,flow->hdr_len,flow->hdr);
634 if (flow->vcc) {
635 struct sockaddr_atmpvc pvc;
636 int state;
638 pvc.sap_family = AF_ATMPVC;
639 pvc.sap_addr.itf = flow->vcc->dev ? flow->vcc->dev->number : -1;
640 pvc.sap_addr.vpi = flow->vcc->vpi;
641 pvc.sap_addr.vci = flow->vcc->vci;
642 RTA_PUT(skb,TCA_ATM_ADDR,sizeof(pvc),&pvc);
643 state = ATM_VF2VS(flow->vcc->flags);
644 RTA_PUT(skb,TCA_ATM_STATE,sizeof(state),&state);
646 if (flow->excess)
647 RTA_PUT(skb,TCA_ATM_EXCESS,sizeof(u32),&flow->classid);
648 else {
649 static u32 zero = 0;
651 RTA_PUT(skb,TCA_ATM_EXCESS,sizeof(zero),&zero);
653 rta->rta_len = skb->tail-b;
654 return skb->len;
656 rtattr_failure:
657 skb_trim(skb,b-skb->data);
658 return -1;
661 static int atm_tc_dump(struct Qdisc *sch, struct sk_buff *skb)
663 return 0;
666 static struct Qdisc_class_ops atm_class_ops =
668 .graft = atm_tc_graft,
669 .leaf = atm_tc_leaf,
670 .get = atm_tc_get,
671 .put = atm_tc_put,
672 .change = atm_tc_change,
673 .delete = atm_tc_delete,
674 .walk = atm_tc_walk,
676 .tcf_chain = atm_tc_find_tcf,
677 .bind_tcf = atm_tc_bind_filter,
678 .unbind_tcf = atm_tc_put,
680 .dump = atm_tc_dump_class,
683 struct Qdisc_ops atm_qdisc_ops =
685 .next = NULL,
686 .cl_ops = &atm_class_ops,
687 .id = "atm",
688 .priv_size = sizeof(struct atm_qdisc_data),
690 .enqueue = atm_tc_enqueue,
691 .dequeue = atm_tc_dequeue,
692 .requeue = atm_tc_requeue,
693 .drop = atm_tc_drop,
695 .init = atm_tc_init,
696 .reset = atm_tc_reset,
697 .destroy = atm_tc_destroy,
698 .change = NULL,
700 .dump = atm_tc_dump
704 #ifdef MODULE
705 int init_module(void)
707 return register_qdisc(&atm_qdisc_ops);
711 void cleanup_module(void)
713 unregister_qdisc(&atm_qdisc_ops);
715 #endif