2 // Copyright (c) 2010-2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
19 #include "task_base.h"
20 #include "task_init.h"
26 struct task_base base;
29 static int handle_read_bulk(struct task_base *tbase, struct rte_mbuf **mbufs, uint16_t n_pkts)
31 struct task_read *task = (struct task_read *)tbase;
32 uint8_t out[MAX_PKT_BURST];
36 #ifdef PROX_PREFETCH_OFFSET
37 for (j = 0; j < PROX_PREFETCH_OFFSET && j < n_pkts; ++j) {
40 for (j = 1; j < PROX_PREFETCH_OFFSET && j < n_pkts; ++j) {
41 PREFETCH0(rte_pktmbuf_mtod(mbufs[j - 1], void *));
44 for (j = 0; j + PREFETCH_OFFSET < n_pkts; ++j) {
45 #ifdef PROX_PREFETCH_OFFSET
46 PREFETCH0(mbufs[j + PREFETCH_OFFSET]);
47 PREFETCH0(rte_pktmbuf_mtod(mbufs[j + PREFETCH_OFFSET - 1], void *));
49 first = rte_pktmbuf_mtod(mbufs[j], uint64_t *);
50 out[j] = *first != 0? 0: OUT_DISCARD;
52 #ifdef PROX_PREFETCH_OFFSET
53 prefetch_nta(rte_pktmbuf_mtod(mbufs[n_pkts - 1], void *));
54 for (; j < n_pkts; ++j) {
55 first = rte_pktmbuf_mtod(mbufs[j], uint64_t *);
56 out[j] = *first != 0? 0: OUT_DISCARD;
60 return task->base.tx_pkt(&task->base, mbufs, n_pkts, out);
63 static void init_task_read(__attribute__((unused)) struct task_base *tbase,
64 __attribute__((unused)) struct task_args *targ)
68 static struct task_init task_init_read = {
70 .init = init_task_read,
71 .handle = handle_read_bulk,
72 .size = sizeof(struct task_read)
75 __attribute__((constructor)) static void reg_task_read(void)
77 reg_task(&task_init_read);