static void process_batch(struct module *m, struct pkt_batch *batch) { for (int i = 0; i < batch->cnt; i++) { struct snbuf *pkt = batch->pkts[i]; char *ptr = snb_head_data(pkt); memmove(ptr + 4, ptr, 12); snb_adj(pkt, 4); } run_next_module(m, batch); }
static struct task_result port_inc_run_task(struct module *m, void *arg) { struct port_inc_priv *priv = get_priv(m); struct port *p = priv->port; const queue_t qid = 0; /* XXX */ struct pkt_batch batch; struct task_result ret; uint64_t received_bytes = 0; const int pkt_burst = MAX_PKT_BURST; const int pkt_overhead = 24; batch.cnt = p->driver->recv_pkts(p, qid, batch.pkts, pkt_burst); if (batch.cnt == 0) { ret.packets = 0; ret.bits = 0; return ret; } for (int i = 0; i < batch.cnt; i++) received_bytes += snb_total_len(batch.pkts[i]); ret.packets = batch.cnt; ret.bits = (received_bytes + pkt_overhead * batch.cnt) * 8; p->queue_stats[PACKET_DIR_INC][qid].packets += batch.cnt; p->queue_stats[PACKET_DIR_INC][qid].bytes += received_bytes; run_next_module(m, &batch); return ret; }