Skip to content

Commit

Permalink
Add Macro for Running Flow Table Lookup (#147)
Browse files Browse the repository at this point in the history
Running a flow table lookup on every packet is expensive and as the
functionality isn't always used we have decided to create a macro to
disable it. The functionality will still be enabled by default, but if
it is unused disabling it should boost performance. 

Commit log:

* Macros for running flow table lookup

* Updated comment about disabling flow table lookup
  • Loading branch information
kevindweb authored and koolzz committed Jun 28, 2019
1 parent 5a40435 commit 6bf1c9f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions onvm/onvm_mgr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# set this to 0 to disable flow table lookup for incoming packets
ENABLE_FLOW_LOOKUP=1

ifeq ($(RTE_SDK),)
$(error "Please define RTE_SDK environment variable")
endif
Expand Down Expand Up @@ -62,6 +65,10 @@ CFLAGS += -I$(SRCDIR)/../ -I$(SRCDIR)/../onvm_nflib/ -I$(SRCDIR)/../lib/
LDFLAGS += $(SRCDIR)/../lib/$(RTE_TARGET)/libonvmhelper.a
LDFLAGS += $(SRCDIR)/../onvm_nflib/$(RTE_TARGET)/libonvm.a

ifeq ($(ENABLE_FLOW_LOOKUP), 1)
CFLAGS +=-D FLOW_LOOKUP
endif

# for newer gcc, e.g. 4.4, no-strict-aliasing may not be necessary
# and so the next line can be removed in those cases.
EXTRA_CFLAGS += -fno-strict-aliasing
Expand Down
6 changes: 6 additions & 0 deletions onvm/onvm_mgr/onvm_pkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ void
onvm_pkt_process_rx_batch(struct queue_mgr *rx_mgr, struct rte_mbuf *pkts[], uint16_t rx_count) {
uint16_t i;
struct onvm_pkt_meta *meta;
#ifdef FLOW_LOOKUP
struct onvm_flow_entry *flow_entry;
struct onvm_service_chain *sc;
int ret;
#endif

if (rx_mgr == NULL || pkts == NULL)
return;
Expand All @@ -68,15 +70,19 @@ onvm_pkt_process_rx_batch(struct queue_mgr *rx_mgr, struct rte_mbuf *pkts[], uin
meta = (struct onvm_pkt_meta *)&(((struct rte_mbuf *)pkts[i])->udata64);
meta->src = 0;
meta->chain_index = 0;
#ifdef FLOW_LOOKUP
ret = onvm_flow_dir_get_pkt(pkts[i], &flow_entry);
if (ret >= 0) {
sc = flow_entry->sc;
meta->action = onvm_sc_next_action(sc, pkts[i]);
meta->destination = onvm_sc_next_destination(sc, pkts[i]);
} else {
#endif
meta->action = onvm_sc_next_action(default_chain, pkts[i]);
meta->destination = onvm_sc_next_destination(default_chain, pkts[i]);
#ifdef FLOW_LOOKUP
}
#endif
/* PERF: this might hurt performance since it will cause cache
* invalidations. Ideally the data modified by the NF manager
* would be a different line than that modified/read by NFs.
Expand Down

0 comments on commit 6bf1c9f

Please sign in to comment.