1235474Sbz/*- 2235474Sbz * Copyright (c) 2006, Myricom Inc. 3235474Sbz * Copyright (c) 2008, Intel Corporation. 4235474Sbz * All rights reserved. 5235474Sbz * 6235474Sbz * Redistribution and use in source and binary forms, with or without 7235474Sbz * modification, are permitted provided that the following conditions 8235474Sbz * are met: 9235474Sbz * 1. Redistributions of source code must retain the above copyright 10235474Sbz * notice, this list of conditions and the following disclaimer. 11235474Sbz * 2. Redistributions in binary form must reproduce the above copyright 12235474Sbz * notice, this list of conditions and the following disclaimer in the 13235474Sbz * documentation and/or other materials provided with the distribution. 14235474Sbz * 15235474Sbz * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16235474Sbz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17235474Sbz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18235474Sbz * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19235474Sbz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20235474Sbz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21235474Sbz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22235474Sbz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23235474Sbz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24235474Sbz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25235474Sbz * SUCH DAMAGE. 26235474Sbz * 27235474Sbz * $FreeBSD$ 28235474Sbz */ 29179737Sjfv 30179737Sjfv#ifndef _TCP_LRO_H_ 31179737Sjfv#define _TCP_LRO_H_ 32179737Sjfv 33255010Snp#include <sys/time.h> 34255010Snp 35179737Sjfvstruct lro_entry 36179737Sjfv{ 37235944Sbz SLIST_ENTRY(lro_entry) next; 38235944Sbz struct mbuf *m_head; 39235944Sbz struct mbuf *m_tail; 40235944Sbz union { 41235944Sbz struct ip *ip4; 42235944Sbz struct ip6_hdr *ip6; 43235944Sbz } leip; 44235944Sbz union { 45235944Sbz in_addr_t s_ip4; 46235944Sbz struct in6_addr s_ip6; 47235944Sbz } lesource; 48235944Sbz union { 49235944Sbz in_addr_t d_ip4; 50235944Sbz struct in6_addr d_ip6; 51235944Sbz } ledest; 52235944Sbz uint16_t source_port; 53235944Sbz uint16_t dest_port; 54235944Sbz uint16_t eh_type; /* EthernetHeader type. */ 55235944Sbz uint16_t append_cnt; 56235944Sbz uint32_t p_len; /* IP header payload length. */ 57235944Sbz uint32_t ulp_csum; /* TCP, etc. checksum. */ 58235944Sbz uint32_t next_seq; /* tcp_seq */ 59235944Sbz uint32_t ack_seq; /* tcp_seq */ 60235944Sbz uint32_t tsval; 61235944Sbz uint32_t tsecr; 62235944Sbz uint16_t window; 63235944Sbz uint16_t timestamp; /* flag, not a TCP hdr field. */ 64255010Snp struct timeval mtime; 65179737Sjfv}; 66179737SjfvSLIST_HEAD(lro_head, lro_entry); 67179737Sjfv 68235944Sbz#define le_ip4 leip.ip4 69235944Sbz#define le_ip6 leip.ip6 70235944Sbz#define source_ip4 lesource.s_ip4 71235944Sbz#define dest_ip4 ledest.d_ip4 72235944Sbz#define source_ip6 lesource.s_ip6 73235944Sbz#define dest_ip6 ledest.d_ip6 74235944Sbz 75235944Sbz/* NB: This is part of driver structs. */ 76179737Sjfvstruct lro_ctrl { 77179737Sjfv struct ifnet *ifp; 78179737Sjfv int lro_queued; 79179737Sjfv int lro_flushed; 80179737Sjfv int lro_bad_csum; 81179737Sjfv int lro_cnt; 82179737Sjfv 83179737Sjfv struct lro_head lro_active; 84179737Sjfv struct lro_head lro_free; 85179737Sjfv}; 86179737Sjfv 87179737Sjfvint tcp_lro_init(struct lro_ctrl *); 88179737Sjfvvoid tcp_lro_free(struct lro_ctrl *); 89255010Snpvoid tcp_lro_flush_inactive(struct lro_ctrl *, const struct timeval *); 90179737Sjfvvoid tcp_lro_flush(struct lro_ctrl *, struct lro_entry *); 91179737Sjfvint tcp_lro_rx(struct lro_ctrl *, struct mbuf *, uint32_t); 92179737Sjfv 93235944Sbz#define TCP_LRO_CANNOT -1 94235944Sbz#define TCP_LRO_NOT_SUPPORTED 1 95179737Sjfv 96179737Sjfv#endif /* _TCP_LRO_H_ */ 97