tcp_lro.c (297265) | tcp_lro.c (297482) |
---|---|
1/*- 2 * Copyright (c) 2007, Myricom Inc. 3 * Copyright (c) 2008, Intel Corporation. 4 * Copyright (c) 2012 The FreeBSD Foundation 5 * Copyright (c) 2016 Mellanox Technologies. 6 * All rights reserved. 7 * 8 * Portions of this software were developed by Bjoern Zeeb --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2007, Myricom Inc. 3 * Copyright (c) 2008, Intel Corporation. 4 * Copyright (c) 2012 The FreeBSD Foundation 5 * Copyright (c) 2016 Mellanox Technologies. 6 * All rights reserved. 7 * 8 * Portions of this software were developed by Bjoern Zeeb --- 17 unchanged lines hidden (view full) --- 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netinet/tcp_lro.c 297265 2016-03-25 02:54:13Z sephe $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/tcp_lro.c 297482 2016-04-01 06:28:33Z sephe $"); |
35 36#include "opt_inet.h" 37#include "opt_inet6.h" 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/kernel.h> 42#include <sys/malloc.h> --- 19 unchanged lines hidden (view full) --- 62 63static MALLOC_DEFINE(M_LRO, "LRO", "LRO control structures"); 64 65#define TCP_LRO_UPDATE_CSUM 1 66#ifndef TCP_LRO_UPDATE_CSUM 67#define TCP_LRO_INVALID_CSUM 0x0000 68#endif 69 | 35 36#include "opt_inet.h" 37#include "opt_inet6.h" 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/kernel.h> 42#include <sys/malloc.h> --- 19 unchanged lines hidden (view full) --- 62 63static MALLOC_DEFINE(M_LRO, "LRO", "LRO control structures"); 64 65#define TCP_LRO_UPDATE_CSUM 1 66#ifndef TCP_LRO_UPDATE_CSUM 67#define TCP_LRO_INVALID_CSUM 0x0000 68#endif 69 |
70static void tcp_lro_rx_done(struct lro_ctrl *lc); 71 |
|
70int 71tcp_lro_init(struct lro_ctrl *lc) 72{ 73 return (tcp_lro_init_args(lc, NULL, TCP_LRO_ENTRIES, 0)); 74} 75 76int 77tcp_lro_init_args(struct lro_ctrl *lc, struct ifnet *ifp, --- 143 unchanged lines hidden (view full) --- 221 c += cs; 222 while (c > 0xffff) 223 c = (c >> 16) + (c & 0xffff); 224 225 return (c & 0xffff); 226} 227#endif 228 | 72int 73tcp_lro_init(struct lro_ctrl *lc) 74{ 75 return (tcp_lro_init_args(lc, NULL, TCP_LRO_ENTRIES, 0)); 76} 77 78int 79tcp_lro_init_args(struct lro_ctrl *lc, struct ifnet *ifp, --- 143 unchanged lines hidden (view full) --- 223 c += cs; 224 while (c > 0xffff) 225 c = (c >> 16) + (c & 0xffff); 226 227 return (c & 0xffff); 228} 229#endif 230 |
231static void 232tcp_lro_rx_done(struct lro_ctrl *lc) 233{ 234 struct lro_entry *le; 235 236 while ((le = SLIST_FIRST(&lc->lro_active)) != NULL) { 237 SLIST_REMOVE_HEAD(&lc->lro_active, next); 238 tcp_lro_flush(lc, le); 239 } 240} 241 |
|
229void 230tcp_lro_flush_inactive(struct lro_ctrl *lc, const struct timeval *timeout) 231{ 232 struct lro_entry *le, *le_tmp; 233 struct timeval tv; 234 235 if (SLIST_EMPTY(&lc->lro_active)) 236 return; --- 120 unchanged lines hidden (view full) --- 357 ret = TCP_LRO_SEQUENCE(ma) - TCP_LRO_SEQUENCE(mb); 358done: 359 return (ret); 360} 361 362void 363tcp_lro_flush_all(struct lro_ctrl *lc) 364{ | 242void 243tcp_lro_flush_inactive(struct lro_ctrl *lc, const struct timeval *timeout) 244{ 245 struct lro_entry *le, *le_tmp; 246 struct timeval tv; 247 248 if (SLIST_EMPTY(&lc->lro_active)) 249 return; --- 120 unchanged lines hidden (view full) --- 370 ret = TCP_LRO_SEQUENCE(ma) - TCP_LRO_SEQUENCE(mb); 371done: 372 return (ret); 373} 374 375void 376tcp_lro_flush_all(struct lro_ctrl *lc) 377{ |
365 struct lro_entry *le; | |
366 uint32_t hashtype; 367 uint32_t flowid; 368 unsigned x; 369 370 /* check if no mbufs to flush */ | 378 uint32_t hashtype; 379 uint32_t flowid; 380 unsigned x; 381 382 /* check if no mbufs to flush */ |
371 if (__predict_false(lc->lro_mbuf_count == 0)) | 383 if (lc->lro_mbuf_count == 0) |
372 goto done; 373 374 /* sort all mbufs according to stream */ 375 qsort(lc->lro_mbuf_data, lc->lro_mbuf_count, sizeof(struct mbuf *), 376 &tcp_lro_mbuf_compare_header); 377 378 /* input data into LRO engine, stream by stream */ 379 flowid = 0; --- 5 unchanged lines hidden (view full) --- 385 386 /* check for new stream */ 387 if (mb->m_pkthdr.flowid != flowid || 388 M_HASHTYPE_GET(mb) != hashtype) { 389 flowid = mb->m_pkthdr.flowid; 390 hashtype = M_HASHTYPE_GET(mb); 391 392 /* flush active streams */ | 384 goto done; 385 386 /* sort all mbufs according to stream */ 387 qsort(lc->lro_mbuf_data, lc->lro_mbuf_count, sizeof(struct mbuf *), 388 &tcp_lro_mbuf_compare_header); 389 390 /* input data into LRO engine, stream by stream */ 391 flowid = 0; --- 5 unchanged lines hidden (view full) --- 397 398 /* check for new stream */ 399 if (mb->m_pkthdr.flowid != flowid || 400 M_HASHTYPE_GET(mb) != hashtype) { 401 flowid = mb->m_pkthdr.flowid; 402 hashtype = M_HASHTYPE_GET(mb); 403 404 /* flush active streams */ |
393 while ((le = SLIST_FIRST(&lc->lro_active)) != NULL) { 394 SLIST_REMOVE_HEAD(&lc->lro_active, next); 395 tcp_lro_flush(lc, le); 396 } | 405 tcp_lro_rx_done(lc); |
397 } 398#ifdef TCP_LRO_RESET_SEQUENCE 399 /* reset sequence number */ 400 TCP_LRO_SEQUENCE(mb) = 0; 401#endif 402 /* add packet to LRO engine */ 403 if (tcp_lro_rx(lc, mb, 0) != 0) { 404 /* input packet to network layer */ 405 (*lc->ifp->if_input)(lc->ifp, mb); 406 lc->lro_queued++; 407 lc->lro_flushed++; 408 } 409 } 410done: 411 /* flush active streams */ | 406 } 407#ifdef TCP_LRO_RESET_SEQUENCE 408 /* reset sequence number */ 409 TCP_LRO_SEQUENCE(mb) = 0; 410#endif 411 /* add packet to LRO engine */ 412 if (tcp_lro_rx(lc, mb, 0) != 0) { 413 /* input packet to network layer */ 414 (*lc->ifp->if_input)(lc->ifp, mb); 415 lc->lro_queued++; 416 lc->lro_flushed++; 417 } 418 } 419done: 420 /* flush active streams */ |
412 while ((le = SLIST_FIRST(&lc->lro_active)) != NULL) { 413 SLIST_REMOVE_HEAD(&lc->lro_active, next); 414 tcp_lro_flush(lc, le); 415 } | 421 tcp_lro_rx_done(lc); 422 |
416 lc->lro_mbuf_count = 0; 417} 418 419#ifdef INET6 420static int 421tcp_lro_rx_ipv6(struct lro_ctrl *lc, struct mbuf *m, struct ip6_hdr *ip6, 422 struct tcphdr **th) 423{ --- 366 unchanged lines hidden --- | 423 lc->lro_mbuf_count = 0; 424} 425 426#ifdef INET6 427static int 428tcp_lro_rx_ipv6(struct lro_ctrl *lc, struct mbuf *m, struct ip6_hdr *ip6, 429 struct tcphdr **th) 430{ --- 366 unchanged lines hidden --- |