/* move packts from src to destination */ static int move(struct my_ring *src, struct my_ring *dst, u_int limit) { struct netmap_ring *txring, *rxring; u_int m = 0, si = src->begin, di = dst->begin; const char *msg = (src->queueid & NETMAP_SW_RING) ? "host->net" : "net->host"; while (si < src->end && di < dst->end) { rxring = NETMAP_RXRING(src->nifp, si); txring = NETMAP_TXRING(dst->nifp, di); ND("txring %p rxring %p", txring, rxring); if (rxring->avail == 0) { si++; continue; } if (txring->avail == 0) { di++; continue; } m += process_rings(rxring, txring, limit, msg); } return (m); }
/* move packts from src to destination */ static int move(struct thr_ctx *th, struct nm_desc *src, struct nm_desc *dst, u_int limit) { struct netmap_ring *txring, *rxring; u_int m = 0, si = src->first_rx_ring, di = dst->first_tx_ring; const char *msg = (src->req.nr_ringid & NETMAP_SW_RING) ? "host->net" : "net->host"; while (si <= src->last_rx_ring && di <= dst->last_tx_ring) { rxring = NETMAP_RXRING(src->nifp, si); txring = NETMAP_TXRING(dst->nifp, di); ND("txring %p rxring %p", txring, rxring); if (nm_ring_empty(rxring)) { si++; continue; } if (nm_ring_empty(txring)) { di++; continue; } m += process_rings(th, rxring, txring, limit, msg); } return (m); }
int Scheduler(int block) /* should we block in the select ? */ { /* One wants to be a bit careful about setting returnValue * to one, since a one implies we did some useful work, * and therefore probably won't be called to block next * time (TN3270 mode only). */ int returnValue; int netin, netout, netex, ttyin, ttyout; /* Decide which rings should be processed */ netout = ring_full_count(&netoring) && (flushline || (my_want_state_is_wont(TELOPT_LINEMODE) #ifdef KLUDGELINEMODE && (!kludgelinemode || my_want_state_is_do(TELOPT_SGA)) #endif ) || my_want_state_is_will(TELOPT_BINARY)); ttyout = ring_full_count(&ttyoring); ttyin = ring_empty_count(&ttyiring); netin = !ISend && ring_empty_count(&netiring); netex = !SYNCHing; /* If we have seen a signal recently, reset things */ if (scheduler_lockout_tty) { ttyin = ttyout = 0; } /* Call to system code to process rings */ returnValue = process_rings(netin, netout, netex, ttyin, ttyout, !block); /* Now, look at the input rings, looking for work to do. */ if (ring_full_count(&ttyiring)) { returnValue |= telsnd(); } if (ring_full_count(&netiring)) { returnValue |= telrcv(); } return returnValue; }
static int rx(struct thread_args_t *arg, struct nm_desc *src, u_int limit) { struct netmap_ring *rxring; u_int si = src->first_rx_ring; while (si <= src->last_rx_ring) { rxring = NETMAP_RXRING(src->nifp, si); if (nm_ring_empty(rxring)) { si++; continue; } g_rings_counts[si] ++; u_int m = process_rings(rxring, limit); arg->count += m; } return (1); }