~fboudra/qemu-linaro/new-upstream-release-1.2.0-2012.09-0ubuntu1

« back to all changes in this revision

Viewing changes to slirp/if.c

  • Committer: Fathi Boudra
  • Author(s): Fathi Boudra
  • Date: 2012-08-21 06:47:11 UTC
  • mfrom: (0.1.16)
  • Revision ID: fathi.boudra@linaro.org-20120821064711-7yxmubp2v8a44xce
Tags: 1.1.50-2012.08-0ubuntu1
* New upstream release.
  - support emulated systems with more than 2G of memory. (LP: #1030588)
* Drop powerpc-missing-include.patch - merged upstream.
* Update debian/control: 
  - drop perl build dependency.
  - add libfdt-dev build dependency.
* Update debian/qemu-keymaps.install file.
* Update debian/rules:
  - update QEMU_CPU for ARM architecture: armv4l -> armv7l.
  - update conf_audio_drv: default to PulseAudio since PA is the default on
    Ubuntu.
  - enable KVM on ARM architecture.
  - enable flat device tree support (--enable-fdt). (LP: #1030594)

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
                        ifs_insque(ifm, ifq->ifs_prev);
97
97
                        goto diddit;
98
98
                }
99
 
        } else
 
99
        } else {
100
100
                ifq = slirp->if_batchq.ifq_prev;
 
101
                /* Set next_m if the queue was empty so far */
 
102
                if (slirp->next_m == &slirp->if_batchq) {
 
103
                    slirp->next_m = ifm;
 
104
                }
 
105
        }
101
106
 
102
107
        /* Create a new doubly linked list for this session */
103
108
        ifm->ifq_so = so;
105
110
        insque(ifm, ifq);
106
111
 
107
112
diddit:
108
 
        slirp->if_queued++;
109
 
 
110
113
        if (so) {
111
114
                /* Update *_queued */
112
115
                so->so_queued++;
152
155
void if_start(Slirp *slirp)
153
156
{
154
157
    uint64_t now = qemu_get_clock_ns(rt_clock);
155
 
    int requeued = 0;
156
 
    bool from_batchq = false;
157
 
    struct mbuf *ifm, *ifqt;
 
158
    bool from_batchq, next_from_batchq;
 
159
    struct mbuf *ifm, *ifm_next, *ifqt;
158
160
 
159
161
    DEBUG_CALL("if_start");
160
162
 
161
 
    while (slirp->if_queued) {
162
 
        /* check if we can really output */
163
 
        if (!slirp_can_output(slirp->opaque))
164
 
            return;
165
 
 
166
 
        /*
167
 
         * See which queue to get next packet from
168
 
         * If there's something in the fastq, select it immediately
169
 
         */
170
 
        if (slirp->if_fastq.ifq_next != &slirp->if_fastq) {
171
 
            ifm = slirp->if_fastq.ifq_next;
172
 
        } else {
173
 
            /* Nothing on fastq, see if next_m is valid */
174
 
            if (slirp->next_m != &slirp->if_batchq) {
175
 
                ifm = slirp->next_m;
176
 
            } else {
177
 
                ifm = slirp->if_batchq.ifq_next;
178
 
            }
179
 
 
180
 
            from_batchq = true;
181
 
        }
182
 
 
183
 
        slirp->if_queued--;
 
163
    if (slirp->if_start_busy) {
 
164
        return;
 
165
    }
 
166
    slirp->if_start_busy = true;
 
167
 
 
168
    if (slirp->if_fastq.ifq_next != &slirp->if_fastq) {
 
169
        ifm_next = slirp->if_fastq.ifq_next;
 
170
        next_from_batchq = false;
 
171
    } else if (slirp->next_m != &slirp->if_batchq) {
 
172
        /* Nothing on fastq, pick up from batchq via next_m */
 
173
        ifm_next = slirp->next_m;
 
174
        next_from_batchq = true;
 
175
    } else {
 
176
        ifm_next = NULL;
 
177
    }
 
178
 
 
179
    while (ifm_next) {
 
180
        ifm = ifm_next;
 
181
        from_batchq = next_from_batchq;
 
182
 
 
183
        ifm_next = ifm->ifq_next;
 
184
        if (ifm_next == &slirp->if_fastq) {
 
185
            /* No more packets in fastq, switch to batchq */
 
186
            ifm_next = slirp->next_m;
 
187
            next_from_batchq = true;
 
188
        }
 
189
        if (ifm_next == &slirp->if_batchq) {
 
190
            /* end of batchq */
 
191
            ifm_next = NULL;
 
192
        }
184
193
 
185
194
        /* Try to send packet unless it already expired */
186
195
        if (ifm->expiration_date >= now && !if_encap(slirp, ifm)) {
187
196
            /* Packet is delayed due to pending ARP resolution */
188
 
            requeued++;
189
197
            continue;
190
198
        }
191
199
 
192
 
        if (from_batchq) {
 
200
        if (ifm == slirp->next_m) {
193
201
            /* Set which packet to send on next iteration */
194
202
            slirp->next_m = ifm->ifq_next;
195
203
        }
200
208
 
201
209
        /* If there are more packets for this session, re-queue them */
202
210
        if (ifm->ifs_next != ifm) {
203
 
            insque(ifm->ifs_next, ifqt);
 
211
            struct mbuf *next = ifm->ifs_next;
 
212
 
 
213
            insque(next, ifqt);
204
214
            ifs_remque(ifm);
 
215
 
 
216
            if (!from_batchq) {
 
217
                /* Next packet in fastq is from the same session */
 
218
                ifm_next = next;
 
219
                next_from_batchq = false;
 
220
            } else if (slirp->next_m == &slirp->if_batchq) {
 
221
                /* Set next_m and ifm_next if the session packet is now the
 
222
                 * only one on batchq */
 
223
                slirp->next_m = ifm_next = next;
 
224
            }
205
225
        }
206
226
 
207
227
        /* Update so_queued */
211
231
        }
212
232
 
213
233
        m_free(ifm);
214
 
 
215
234
    }
216
235
 
217
 
    slirp->if_queued = requeued;
 
236
    slirp->if_start_busy = false;
218
237
}