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.
8 * Portions of this software were developed by Bjoern Zeeb
9 * under sponsorship from the FreeBSD Foundation.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
37 #include "opt_inet6.h"
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
42 #include <sys/malloc.h>
44 #include <sys/socket.h>
47 #include <net/if_var.h>
48 #include <net/ethernet.h>
51 #include <netinet/in_systm.h>
52 #include <netinet/in.h>
53 #include <netinet/ip6.h>
54 #include <netinet/ip.h>
55 #include <netinet/ip_var.h>
56 #include <netinet/tcp.h>
57 #include <netinet/tcp_lro.h>
59 #include <netinet6/ip6_var.h>
61 #include <machine/in_cksum.h>
63 static MALLOC_DEFINE(M_LRO, "LRO", "LRO control structures");
65 #define TCP_LRO_UPDATE_CSUM 1
66 #ifndef TCP_LRO_UPDATE_CSUM
67 #define TCP_LRO_INVALID_CSUM 0x0000
70 static void tcp_lro_rx_done(struct lro_ctrl *lc);
71 static int tcp_lro_rx2(struct lro_ctrl *lc, struct mbuf *m,
72 uint32_t csum, int use_hash);
75 tcp_lro_active_insert(struct lro_ctrl *lc, struct lro_head *bucket,
79 LIST_INSERT_HEAD(&lc->lro_active, le, next);
80 LIST_INSERT_HEAD(bucket, le, hash_next);
84 tcp_lro_active_remove(struct lro_entry *le)
87 LIST_REMOVE(le, next); /* active list */
88 LIST_REMOVE(le, hash_next); /* hash bucket */
92 tcp_lro_init(struct lro_ctrl *lc)
94 return (tcp_lro_init_args(lc, NULL, TCP_LRO_ENTRIES, 0));
98 tcp_lro_init_args(struct lro_ctrl *lc, struct ifnet *ifp,
99 unsigned lro_entries, unsigned lro_mbufs)
101 struct lro_entry *le;
103 unsigned i, elements;
105 lc->lro_bad_csum = 0;
109 lc->lro_mbuf_count = 0;
110 lc->lro_mbuf_max = lro_mbufs;
111 lc->lro_cnt = lro_entries;
112 lc->lro_ackcnt_lim = TCP_LRO_ACKCNT_MAX;
113 lc->lro_length_lim = TCP_LRO_LENGTH_MAX;
115 LIST_INIT(&lc->lro_free);
116 LIST_INIT(&lc->lro_active);
118 /* create hash table to accelerate entry lookup */
119 if (lro_entries > lro_mbufs)
120 elements = lro_entries;
122 elements = lro_mbufs;
123 lc->lro_hash = phashinit_flags(elements, M_LRO, &lc->lro_hashsz,
125 if (lc->lro_hash == NULL) {
126 memset(lc, 0, sizeof(*lc));
130 /* compute size to allocate */
131 size = (lro_mbufs * sizeof(struct lro_mbuf_sort)) +
132 (lro_entries * sizeof(*le));
133 lc->lro_mbuf_data = (struct lro_mbuf_sort *)
134 malloc(size, M_LRO, M_NOWAIT | M_ZERO);
136 /* check for out of memory */
137 if (lc->lro_mbuf_data == NULL) {
138 memset(lc, 0, sizeof(*lc));
141 /* compute offset for LRO entries */
142 le = (struct lro_entry *)
143 (lc->lro_mbuf_data + lro_mbufs);
145 /* setup linked list */
146 for (i = 0; i != lro_entries; i++)
147 LIST_INSERT_HEAD(&lc->lro_free, le + i, next);
153 tcp_lro_free(struct lro_ctrl *lc)
155 struct lro_entry *le;
158 /* reset LRO free list */
159 LIST_INIT(&lc->lro_free);
161 /* free active mbufs, if any */
162 while ((le = LIST_FIRST(&lc->lro_active)) != NULL) {
163 tcp_lro_active_remove(le);
167 /* free hash table */
168 if (lc->lro_hash != NULL) {
169 free(lc->lro_hash, M_LRO);
174 /* free mbuf array, if any */
175 for (x = 0; x != lc->lro_mbuf_count; x++)
176 m_freem(lc->lro_mbuf_data[x].mb);
177 lc->lro_mbuf_count = 0;
179 /* free allocated memory, if any */
180 free(lc->lro_mbuf_data, M_LRO);
181 lc->lro_mbuf_data = NULL;
184 #ifdef TCP_LRO_UPDATE_CSUM
186 tcp_lro_csum_th(struct tcphdr *th)
191 ch = th->th_sum = 0x0000;
202 ch = (ch >> 16) + (ch & 0xffff);
204 return (ch & 0xffff);
208 tcp_lro_rx_csum_fixup(struct lro_entry *le, void *l3hdr, struct tcphdr *th,
209 uint16_t tcp_data_len, uint16_t csum)
216 /* Remove length from checksum. */
217 switch (le->eh_type) {
223 ip6 = (struct ip6_hdr *)l3hdr;
224 if (le->append_cnt == 0)
229 cx = ntohs(ip6->ip6_plen);
230 cs = in6_cksum_pseudo(ip6, cx, ip6->ip6_nxt, 0);
240 ip4 = (struct ip *)l3hdr;
241 if (le->append_cnt == 0)
244 cs = in_addword(ntohs(ip4->ip_len) - sizeof(*ip4),
246 cs = in_pseudo(ip4->ip_src.s_addr, ip4->ip_dst.s_addr,
253 cs = 0; /* Keep compiler happy. */
259 /* Remove TCP header csum. */
260 cs = ~tcp_lro_csum_th(th);
263 c = (c >> 16) + (c & 0xffff);
270 tcp_lro_rx_done(struct lro_ctrl *lc)
272 struct lro_entry *le;
274 while ((le = LIST_FIRST(&lc->lro_active)) != NULL) {
275 tcp_lro_active_remove(le);
276 tcp_lro_flush(lc, le);
281 tcp_lro_flush_inactive(struct lro_ctrl *lc, const struct timeval *timeout)
283 struct lro_entry *le, *le_tmp;
286 if (LIST_EMPTY(&lc->lro_active))
290 timevalsub(&tv, timeout);
291 LIST_FOREACH_SAFE(le, &lc->lro_active, next, le_tmp) {
292 if (timevalcmp(&tv, &le->mtime, >=)) {
293 tcp_lro_active_remove(le);
294 tcp_lro_flush(lc, le);
300 tcp_lro_flush(struct lro_ctrl *lc, struct lro_entry *le)
303 if (le->append_cnt > 0) {
307 p_len = htons(le->p_len);
308 switch (le->eh_type) {
315 ip6->ip6_plen = p_len;
316 th = (struct tcphdr *)(ip6 + 1);
317 le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID |
319 le->p_len += ETHER_HDR_LEN + sizeof(*ip6);
327 #ifdef TCP_LRO_UPDATE_CSUM
333 #ifdef TCP_LRO_UPDATE_CSUM
334 /* Fix IP header checksum for new length. */
340 cl = (cl >> 16) + (cl & 0xffff);
344 ip4->ip_sum = TCP_LRO_INVALID_CSUM;
347 th = (struct tcphdr *)(ip4 + 1);
348 le->m_head->m_pkthdr.csum_flags = CSUM_DATA_VALID |
349 CSUM_PSEUDO_HDR | CSUM_IP_CHECKED | CSUM_IP_VALID;
350 le->p_len += ETHER_HDR_LEN;
355 th = NULL; /* Keep compiler happy. */
357 le->m_head->m_pkthdr.csum_data = 0xffff;
358 le->m_head->m_pkthdr.len = le->p_len;
360 /* Incorporate the latest ACK into the TCP header. */
361 th->th_ack = le->ack_seq;
362 th->th_win = le->window;
363 /* Incorporate latest timestamp into the TCP header. */
364 if (le->timestamp != 0) {
367 ts_ptr = (uint32_t *)(th + 1);
368 ts_ptr[1] = htonl(le->tsval);
369 ts_ptr[2] = le->tsecr;
371 #ifdef TCP_LRO_UPDATE_CSUM
372 /* Update the TCP header checksum. */
373 le->ulp_csum += p_len;
374 le->ulp_csum += tcp_lro_csum_th(th);
375 while (le->ulp_csum > 0xffff)
376 le->ulp_csum = (le->ulp_csum >> 16) +
377 (le->ulp_csum & 0xffff);
378 th->th_sum = (le->ulp_csum & 0xffff);
379 th->th_sum = ~th->th_sum;
381 th->th_sum = TCP_LRO_INVALID_CSUM;
385 (*lc->ifp->if_input)(lc->ifp, le->m_head);
386 lc->lro_queued += le->append_cnt + 1;
388 bzero(le, sizeof(*le));
389 LIST_INSERT_HEAD(&lc->lro_free, le, next);
392 #ifdef HAVE_INLINE_FLSLL
393 #define tcp_lro_msb_64(x) (1ULL << (flsll(x) - 1))
395 static inline uint64_t
396 tcp_lro_msb_64(uint64_t x)
404 return (x & ~(x >> 1));
409 * The tcp_lro_sort() routine is comparable to qsort(), except it has
410 * a worst case complexity limit of O(MIN(N,64)*N), where N is the
411 * number of elements to sort and 64 is the number of sequence bits
412 * available. The algorithm is bit-slicing the 64-bit sequence number,
413 * sorting one bit at a time from the most significant bit until the
414 * least significant one, skipping the constant bits. This is
415 * typically called a radix sort.
418 tcp_lro_sort(struct lro_mbuf_sort *parray, uint32_t size)
420 struct lro_mbuf_sort temp;
427 /* for small arrays insertion sort is faster */
429 for (x = 1; x < size; x++) {
431 for (y = x; y > 0 && temp.seq < parray[y - 1].seq; y--)
432 parray[y] = parray[y - 1];
438 /* compute sequence bits which are constant */
441 for (x = 0; x != size; x++) {
442 ones |= parray[x].seq;
443 zeros |= ~parray[x].seq;
446 /* compute bits which are not constant into "ones" */
451 /* pick the most significant bit which is not constant */
452 ones = tcp_lro_msb_64(ones);
455 * Move entries having cleared sequence bits to the beginning
458 for (x = y = 0; y != size; y++) {
460 if (parray[y].seq & ones)
464 parray[x] = parray[y];
469 KASSERT(x != 0 && x != size, ("Memory is corrupted\n"));
472 tcp_lro_sort(parray, x);
481 tcp_lro_flush_all(struct lro_ctrl *lc)
487 /* check if no mbufs to flush */
488 if (lc->lro_mbuf_count == 0)
491 /* sort all mbufs according to stream */
492 tcp_lro_sort(lc->lro_mbuf_data, lc->lro_mbuf_count);
494 /* input data into LRO engine, stream by stream */
496 for (x = 0; x != lc->lro_mbuf_count; x++) {
500 mb = lc->lro_mbuf_data[x].mb;
502 /* get sequence number, masking away the packet index */
503 nseq = lc->lro_mbuf_data[x].seq & (-1ULL << 24);
505 /* check for new stream */
509 /* flush active streams */
513 /* add packet to LRO engine */
514 if (tcp_lro_rx2(lc, mb, 0, 0) != 0) {
515 /* input packet to network layer */
516 (*lc->ifp->if_input)(lc->ifp, mb);
522 /* flush active streams */
525 lc->lro_mbuf_count = 0;
530 tcp_lro_rx_ipv6(struct lro_ctrl *lc, struct mbuf *m, struct ip6_hdr *ip6,
534 /* XXX-BZ we should check the flow-label. */
536 /* XXX-BZ We do not yet support ext. hdrs. */
537 if (ip6->ip6_nxt != IPPROTO_TCP)
538 return (TCP_LRO_NOT_SUPPORTED);
540 /* Find the TCP header. */
541 *th = (struct tcphdr *)(ip6 + 1);
549 tcp_lro_rx_ipv4(struct lro_ctrl *lc, struct mbuf *m, struct ip *ip4,
555 if (ip4->ip_p != IPPROTO_TCP)
556 return (TCP_LRO_NOT_SUPPORTED);
558 /* Ensure there are no options. */
559 if ((ip4->ip_hl << 2) != sizeof (*ip4))
560 return (TCP_LRO_CANNOT);
562 /* .. and the packet is not fragmented. */
563 if (ip4->ip_off & htons(IP_MF|IP_OFFMASK))
564 return (TCP_LRO_CANNOT);
566 /* Legacy IP has a header checksum that needs to be correct. */
567 csum_flags = m->m_pkthdr.csum_flags;
568 if (csum_flags & CSUM_IP_CHECKED) {
569 if (__predict_false((csum_flags & CSUM_IP_VALID) == 0)) {
571 return (TCP_LRO_CANNOT);
574 csum = in_cksum_hdr(ip4);
575 if (__predict_false((csum) != 0)) {
577 return (TCP_LRO_CANNOT);
581 /* Find the TCP header (we assured there are no IP options). */
582 *th = (struct tcphdr *)(ip4 + 1);
589 tcp_lro_rx2(struct lro_ctrl *lc, struct mbuf *m, uint32_t csum, int use_hash)
591 struct lro_entry *le;
592 struct ether_header *eh;
594 struct ip6_hdr *ip6 = NULL; /* Keep compiler happy. */
597 struct ip *ip4 = NULL; /* Keep compiler happy. */
600 void *l3hdr = NULL; /* Keep compiler happy. */
603 int error, ip_len, l;
604 uint16_t eh_type, tcp_data_len;
605 struct lro_head *bucket;
608 /* We expect a contiguous header [eh, ip, tcp]. */
610 eh = mtod(m, struct ether_header *);
611 eh_type = ntohs(eh->ether_type);
616 CURVNET_SET(lc->ifp->if_vnet);
617 if (V_ip6_forwarding != 0) {
618 /* XXX-BZ stats but changing lro_ctrl is a problem. */
620 return (TCP_LRO_CANNOT);
623 l3hdr = ip6 = (struct ip6_hdr *)(eh + 1);
624 error = tcp_lro_rx_ipv6(lc, m, ip6, &th);
627 tcp_data_len = ntohs(ip6->ip6_plen);
628 ip_len = sizeof(*ip6) + tcp_data_len;
635 CURVNET_SET(lc->ifp->if_vnet);
636 if (V_ipforwarding != 0) {
637 /* XXX-BZ stats but changing lro_ctrl is a problem. */
639 return (TCP_LRO_CANNOT);
642 l3hdr = ip4 = (struct ip *)(eh + 1);
643 error = tcp_lro_rx_ipv4(lc, m, ip4, &th);
646 ip_len = ntohs(ip4->ip_len);
647 tcp_data_len = ip_len - sizeof(*ip4);
651 /* XXX-BZ what happens in case of VLAN(s)? */
653 return (TCP_LRO_NOT_SUPPORTED);
657 * If the frame is padded beyond the end of the IP packet, then we must
658 * trim the extra bytes off.
660 l = m->m_pkthdr.len - (ETHER_HDR_LEN + ip_len);
663 /* Truncated packet. */
664 return (TCP_LRO_CANNOT);
670 * Check TCP header constraints.
672 /* Ensure no bits set besides ACK or PSH. */
673 if ((th->th_flags & ~(TH_ACK | TH_PUSH)) != 0) {
674 if (th->th_flags & TH_SYN)
675 return (TCP_LRO_CANNOT);
677 * Make sure that previously seen segements/ACKs are delivered
678 * before this segement, e.g. FIN.
683 /* XXX-BZ We lose a ACK|PUSH flag concatenating multiple segments. */
684 /* XXX-BZ Ideally we'd flush on PUSH? */
687 * Check for timestamps.
688 * Since the only option we handle are timestamps, we only have to
689 * handle the simple case of aligned timestamps.
691 l = (th->th_off << 2);
694 ts_ptr = (uint32_t *)(th + 1);
695 if (l != 0 && (__predict_false(l != TCPOLEN_TSTAMP_APPA) ||
696 (*ts_ptr != ntohl(TCPOPT_NOP<<24|TCPOPT_NOP<<16|
697 TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)))) {
699 * Make sure that previously seen segements/ACKs are delivered
700 * before this segement.
705 /* If the driver did not pass in the checksum, set it now. */
709 seq = ntohl(th->th_seq);
712 bucket = &lc->lro_hash[0];
713 } else if (M_HASHTYPE_ISHASH(m)) {
714 bucket = &lc->lro_hash[m->m_pkthdr.flowid % lc->lro_hashsz];
721 hash = ip4->ip_src.s_addr + ip4->ip_dst.s_addr;
726 hash = ip6->ip6_src.s6_addr32[0] +
727 ip6->ip6_dst.s6_addr32[0];
728 hash += ip6->ip6_src.s6_addr32[1] +
729 ip6->ip6_dst.s6_addr32[1];
730 hash += ip6->ip6_src.s6_addr32[2] +
731 ip6->ip6_dst.s6_addr32[2];
732 hash += ip6->ip6_src.s6_addr32[3] +
733 ip6->ip6_dst.s6_addr32[3];
740 hash += th->th_sport + th->th_dport;
741 bucket = &lc->lro_hash[hash % lc->lro_hashsz];
744 /* Try to find a matching previous segment. */
745 LIST_FOREACH(le, bucket, hash_next) {
746 if (le->eh_type != eh_type)
748 if (le->source_port != th->th_sport ||
749 le->dest_port != th->th_dport)
754 if (bcmp(&le->source_ip6, &ip6->ip6_src,
755 sizeof(struct in6_addr)) != 0 ||
756 bcmp(&le->dest_ip6, &ip6->ip6_dst,
757 sizeof(struct in6_addr)) != 0)
763 if (le->source_ip4 != ip4->ip_src.s_addr ||
764 le->dest_ip4 != ip4->ip_dst.s_addr)
771 /* Timestamps mismatch; this is a FIN, etc */
772 tcp_lro_active_remove(le);
773 tcp_lro_flush(lc, le);
774 return (TCP_LRO_CANNOT);
777 /* Flush now if appending will result in overflow. */
778 if (le->p_len > (lc->lro_length_lim - tcp_data_len)) {
779 tcp_lro_active_remove(le);
780 tcp_lro_flush(lc, le);
784 /* Try to append the new segment. */
785 if (__predict_false(seq != le->next_seq ||
786 (tcp_data_len == 0 && le->ack_seq == th->th_ack))) {
787 /* Out of order packet or duplicate ACK. */
788 tcp_lro_active_remove(le);
789 tcp_lro_flush(lc, le);
790 return (TCP_LRO_CANNOT);
794 uint32_t tsval = ntohl(*(ts_ptr + 1));
795 /* Make sure timestamp values are increasing. */
796 /* XXX-BZ flip and use TSTMP_GEQ macro for this? */
797 if (__predict_false(le->tsval > tsval ||
799 return (TCP_LRO_CANNOT);
801 le->tsecr = *(ts_ptr + 2);
804 le->next_seq += tcp_data_len;
805 le->ack_seq = th->th_ack;
806 le->window = th->th_win;
809 #ifdef TCP_LRO_UPDATE_CSUM
810 le->ulp_csum += tcp_lro_rx_csum_fixup(le, l3hdr, th,
811 tcp_data_len, ~csum);
814 if (tcp_data_len == 0) {
817 * Flush this LRO entry, if this ACK should not
818 * be further delayed.
820 if (le->append_cnt >= lc->lro_ackcnt_lim) {
821 tcp_lro_active_remove(le);
822 tcp_lro_flush(lc, le);
827 le->p_len += tcp_data_len;
830 * Adjust the mbuf so that m_data points to the first byte of
831 * the ULP payload. Adjust the mbuf to avoid complications and
832 * append new segment to existing mbuf chain.
834 m_adj(m, m->m_pkthdr.len - tcp_data_len);
837 le->m_tail->m_next = m;
838 le->m_tail = m_last(m);
841 * If a possible next full length packet would cause an
842 * overflow, pro-actively flush now.
844 if (le->p_len > (lc->lro_length_lim - lc->ifp->if_mtu)) {
845 tcp_lro_active_remove(le);
846 tcp_lro_flush(lc, le);
848 getmicrotime(&le->mtime);
855 * Nothing to flush, but this segment can not be further
856 * aggregated/delayed.
858 return (TCP_LRO_CANNOT);
861 /* Try to find an empty slot. */
862 if (LIST_EMPTY(&lc->lro_free))
863 return (TCP_LRO_NO_ENTRIES);
865 /* Start a new segment chain. */
866 le = LIST_FIRST(&lc->lro_free);
867 LIST_REMOVE(le, next);
868 tcp_lro_active_insert(lc, bucket, le);
869 getmicrotime(&le->mtime);
871 /* Start filling in details. */
876 le->source_ip6 = ip6->ip6_src;
877 le->dest_ip6 = ip6->ip6_dst;
878 le->eh_type = eh_type;
879 le->p_len = m->m_pkthdr.len - ETHER_HDR_LEN - sizeof(*ip6);
885 le->source_ip4 = ip4->ip_src.s_addr;
886 le->dest_ip4 = ip4->ip_dst.s_addr;
887 le->eh_type = eh_type;
888 le->p_len = m->m_pkthdr.len - ETHER_HDR_LEN;
892 le->source_port = th->th_sport;
893 le->dest_port = th->th_dport;
895 le->next_seq = seq + tcp_data_len;
896 le->ack_seq = th->th_ack;
897 le->window = th->th_win;
900 le->tsval = ntohl(*(ts_ptr + 1));
901 le->tsecr = *(ts_ptr + 2);
904 #ifdef TCP_LRO_UPDATE_CSUM
906 * Do not touch the csum of the first packet. However save the
907 * "adjusted" checksum of just the source and destination addresses,
908 * the next header and the TCP payload. The length and TCP header
909 * parts may change, so we remove those from the saved checksum and
910 * re-add with final values on tcp_lro_flush() if needed.
912 KASSERT(le->ulp_csum == 0, ("%s: le=%p le->ulp_csum=0x%04x\n",
913 __func__, le, le->ulp_csum));
915 le->ulp_csum = tcp_lro_rx_csum_fixup(le, l3hdr, th, tcp_data_len,
917 th->th_sum = csum; /* Restore checksum on first packet. */
921 le->m_tail = m_last(m);
927 tcp_lro_rx(struct lro_ctrl *lc, struct mbuf *m, uint32_t csum)
930 return tcp_lro_rx2(lc, m, csum, 1);
934 tcp_lro_queue_mbuf(struct lro_ctrl *lc, struct mbuf *mb)
937 if (__predict_false(lc->ifp == NULL || lc->lro_mbuf_data == NULL ||
938 lc->lro_mbuf_max == 0)) {
944 /* check if packet is not LRO capable */
945 if (__predict_false(mb->m_pkthdr.csum_flags == 0 ||
946 (lc->ifp->if_capenable & IFCAP_LRO) == 0)) {
950 /* input packet to network layer */
951 (*lc->ifp->if_input) (lc->ifp, mb);
955 /* check if array is full */
956 if (__predict_false(lc->lro_mbuf_count == lc->lro_mbuf_max))
957 tcp_lro_flush_all(lc);
959 /* create sequence number */
960 lc->lro_mbuf_data[lc->lro_mbuf_count].seq =
961 (((uint64_t)M_HASHTYPE_GET(mb)) << 56) |
962 (((uint64_t)mb->m_pkthdr.flowid) << 24) |
963 ((uint64_t)lc->lro_mbuf_count);
966 lc->lro_mbuf_data[lc->lro_mbuf_count++].mb = mb;