next up previous
Next: Dequeue Up: Queuing Disciplines Previous: Queuing Disciplines

Enqueue

The enqueue function enqueues a packet with the queueing discipline. Packets are enqueued in the following manner. As already shown in the previous section, when the IP layer calls dev_queue_xmit, the enqueue function of the queuing discipline attached to the device is called. This portion of the code in net/core/dev.c is shown below:
q = dev->qdisc;
if (q->enqueue) {
    q->enqueue(skb, q);
    qdisc_wakeup(dev);
    return 0;
}

In the enqueue function of a queuing discipline, the filters are run one by one until a match occurs. Once the match occurs, the enqueue function of the queueing discipline "owned" by that class is executed. For example, in the cbq_enqueue function (in net/sched/sch_cbq.c),

struct cbq_class *cl = cbq_classify(skb, sch);
int len = skb->len;

if (cl && cl->q->enqueue(skb, cl->q) == 1) 
.
.

The function cbq_classify is used to apply the filters and determine the class to which to the packet belongs. After that, the enqueue function of the queuing discipline owned by that class is called. This queuing discipline may have its own classes, which in turn may be associated with some other queuing discipline, and so on, which makes the usage flexible, as was discussed earlier.

At this point, it is worth mentioning that when a class is created, the default queuing discipline that it owns is a Priority FIFO queue. The portion of the code (in net/sched/sch_cbq.c) that does this is shown below.

static int cbq_init(struct Qdisc *sch, struct rtattr *opt)
{
.
.
.

if (!(q->link.q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops)))
    q->link.q = &noop_qdisc;
.
.
.
}

This can be changed by doing a graft operation, that will be discussed later in the section on classes.


next up previous
Next: Dequeue Up: Queuing Disciplines Previous: Queuing Disciplines
Saravanan Radhakrishnan
1999-09-30