Skip to content

Commit

Permalink
gk: prefetch the transmission fields of packets
Browse files Browse the repository at this point in the history
This patch prefetches the transmission fields of a packet when
it is ready to be prepared for transmission.
  • Loading branch information
AltraMayor committed Nov 9, 2019
1 parent 618ec1d commit a93ecb0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions gk/co.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,30 @@ priority_from_delta_time(uint64_t present, uint64_t past)
return integer_log_base_2(delta_time);
}

/* TODO This should be part of DPDK. */
/**
* Prefetch the second part of the mbuf
*
* The next 64 bytes of the mbuf corresponds to fields that are used in the
* transmit path. If the cache line of the architecture is higher than 64B,
* this function does nothing as it is expected that the full mbuf is
* already in cache.
*
* @param m
* The pointer to the mbuf.
*/
static inline bool
rte_mbuf_prefetch_part2_non_temporal(struct rte_mbuf *m)
{
#if RTE_CACHE_LINE_SIZE == 64
rte_prefetch_non_temporal(&m->cacheline1);
return true;
#else
RTE_SET_USED(m);
return false;
#endif
}

/*
* When a flow entry is at request state, all the GK block processing
* that entry does is to:
Expand Down Expand Up @@ -389,6 +413,10 @@ gk_process_request(struct gk_co *this_co, struct flow_entry *fe,

/* The assigned priority is @priority. */

/* Prepare packet for transmission. */
if (likely(rte_mbuf_prefetch_part2_non_temporal(pkt)))
yield_next(this_co);

/* Encapsulate the packet as a request. */
ret = encapsulate(pkt, priority, back, &fib->u.grantor.gt_addr);
if (ret < 0)
Expand Down Expand Up @@ -462,6 +490,10 @@ gk_process_granted(struct gk_co *this_co, struct flow_entry *fe,
priority = PRIORITY_RENEW_CAP;
}

/* Prepare packet for transmission. */
if (likely(rte_mbuf_prefetch_part2_non_temporal(pkt)))
yield_next(this_co);

/*
* Encapsulate packet as a granted packet,
* mark it as a capability renewal request if @renew_cap is true,
Expand Down Expand Up @@ -537,6 +569,9 @@ gk_process_bpf(struct gk_co *this_co, struct flow_entry *fe,
if (unlikely(now >= fe->u.bpf.expire_at))
goto expired;

/*
* TODO Prepare packet for transmission before encapsulate() is called.
*/
program_index = fe->program_index;
rc = gk_bpf_decide_pkt(gk_conf, program_index, fe, packet, now,
&bpf_ret);
Expand Down

0 comments on commit a93ecb0

Please sign in to comment.