From 18daa0ee9adbfb92822e2843737ea4a29b8fd0e5 Mon Sep 17 00:00:00 2001 From: Andrew Rybchenko Date: Sat, 28 Feb 2015 19:01:43 +0000 Subject: [PATCH] sfxge: compile out LRO if kernel is compiled without IPv4 and IPv6 Sponsored by: Solarflare Communications, Inc. Approved by: gnn (mentor) --- sys/dev/sfxge/sfxge_rx.c | 40 ++++++++++++++++++++++++++++++++++++++ sys/dev/sfxge/sfxge_rx.h | 14 +++++++++++++ sys/modules/sfxge/Makefile | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/sys/dev/sfxge/sfxge_rx.c b/sys/dev/sfxge/sfxge_rx.c index 1d9814237c97..b0cbb8a3f5b6 100644 --- a/sys/dev/sfxge/sfxge_rx.c +++ b/sys/dev/sfxge/sfxge_rx.c @@ -56,6 +56,8 @@ __FBSDID("$FreeBSD$"); #define RX_REFILL_THRESHOLD(_entries) (EFX_RXQ_LIMIT(_entries) * 9 / 10) +#ifdef SFXGE_LRO + /* Size of the LRO hash table. Must be a power of 2. A larger table * means we can accelerate a larger number of streams. */ @@ -107,6 +109,8 @@ static unsigned long ipv6_addr_cmp(const struct in6_addr *left, #endif } +#endif /* SFXGE_LRO */ + void sfxge_rx_qflush_done(struct sfxge_rxq *rxq) { @@ -315,6 +319,8 @@ sfxge_rx_deliver(struct sfxge_softc *sc, struct sfxge_rx_sw_desc *rx_desc) rx_desc->mbuf = NULL; } +#ifdef SFXGE_LRO + static void sfxge_lro_deliver(struct sfxge_lro_state *st, struct sfxge_lro_conn *c) { @@ -734,6 +740,20 @@ static void sfxge_lro_end_of_burst(struct sfxge_rxq *rxq) sfxge_lro_purge_idle(rxq, t); } +#else /* !SFXGE_LRO */ + +static void +sfxge_lro(struct sfxge_rxq *rxq, struct sfxge_rx_sw_desc *rx_buf) +{ +} + +static void +sfxge_lro_end_of_burst(struct sfxge_rxq *rxq) +{ +} + +#endif /* SFXGE_LRO */ + void sfxge_rx_qcomplete(struct sfxge_rxq *rxq, boolean_t eop) { @@ -1014,6 +1034,8 @@ sfxge_rx_start(struct sfxge_softc *sc) return (rc); } +#ifdef SFXGE_LRO + static void sfxge_lro_init(struct sfxge_rxq *rxq) { struct sfxge_lro_state *st = &rxq->lro; @@ -1066,6 +1088,20 @@ static void sfxge_lro_fini(struct sfxge_rxq *rxq) st->conns = NULL; } +#else + +static void +sfxge_lro_init(struct sfxge_rxq *rxq) +{ +} + +static void +sfxge_lro_fini(struct sfxge_rxq *rxq) +{ +} + +#endif /* SFXGE_LRO */ + static void sfxge_rx_qfini(struct sfxge_softc *sc, unsigned int index) { @@ -1136,6 +1172,7 @@ static const struct { } sfxge_rx_stats[] = { #define SFXGE_RX_STAT(name, member) \ { #name, offsetof(struct sfxge_rxq, member) } +#ifdef SFXGE_LRO SFXGE_RX_STAT(lro_merges, lro.n_merges), SFXGE_RX_STAT(lro_bursts, lro.n_bursts), SFXGE_RX_STAT(lro_slow_start, lro.n_slow_start), @@ -1144,6 +1181,7 @@ static const struct { SFXGE_RX_STAT(lro_new_stream, lro.n_new_stream), SFXGE_RX_STAT(lro_drop_idle, lro.n_drop_idle), SFXGE_RX_STAT(lro_drop_closed, lro.n_drop_closed) +#endif }; static int @@ -1200,8 +1238,10 @@ sfxge_rx_init(struct sfxge_softc *sc) int index; int rc; +#ifdef SFXGE_LRO if (lro_idle_ticks == 0) lro_idle_ticks = hz / 10 + 1; /* 100 ms */ +#endif intr = &sc->intr; diff --git a/sys/dev/sfxge/sfxge_rx.h b/sys/dev/sfxge/sfxge_rx.h index 4b3e73a97d20..b24755326d4c 100644 --- a/sys/dev/sfxge/sfxge_rx.h +++ b/sys/dev/sfxge/sfxge_rx.h @@ -32,6 +32,14 @@ #ifndef _SFXGE_RX_H #define _SFXGE_RX_H +#include "opt_inet.h" +#include "opt_inet6.h" + +#if defined(INET) || defined(INET6) +#error LRO +#define SFXGE_LRO 1 +#endif + #define SFXGE_MAGIC_RESERVED 0x8000 #define SFXGE_MAGIC_DMAQ_LABEL_WIDTH 6 @@ -59,6 +67,8 @@ struct sfxge_rx_sw_desc { int size; }; +#ifdef SFXGE_LRO + /** * struct sfxge_lro_conn - Connection state for software LRO * @link: Link for hash table and free list. @@ -139,6 +149,8 @@ struct sfxge_lro_state { unsigned n_drop_closed; }; +#endif /* SFXGE_LRO */ + enum sfxge_flush_state { SFXGE_FLUSH_DONE = 0, SFXGE_FLUSH_PENDING, @@ -167,7 +179,9 @@ struct sfxge_rxq { unsigned int pending; unsigned int completed; unsigned int loopback; +#ifdef SFXGE_LRO struct sfxge_lro_state lro; +#endif unsigned int refill_threshold; struct callout refill_callout; unsigned int refill_delay; diff --git a/sys/modules/sfxge/Makefile b/sys/modules/sfxge/Makefile index 75a1ba0ae33b..3bb9770e891a 100644 --- a/sys/modules/sfxge/Makefile +++ b/sys/modules/sfxge/Makefile @@ -5,7 +5,7 @@ KMOD= sfxge SFXGE= ${.CURDIR}/../../dev/sfxge SRCS= device_if.h bus_if.h pci_if.h -SRCS+= opt_inet.h opt_sched.h +SRCS+= opt_inet.h opt_inet6.h opt_sched.h .PATH: ${.CURDIR}/../../dev/sfxge SRCS+= sfxge.c sfxge_dma.c sfxge_ev.c