t4_listen.c (303686) | t4_listen.c (309560) |
---|---|
1/*- 2 * Copyright (c) 2012 Chelsio Communications, Inc. 3 * All rights reserved. 4 * Written by: Navdeep Parhar <np@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2012 Chelsio Communications, Inc. 3 * All rights reserved. 4 * Written by: Navdeep Parhar <np@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: stable/11/sys/dev/cxgbe/tom/t4_listen.c 303686 2016-08-02 23:34:59Z ngie $"); | 29__FBSDID("$FreeBSD: stable/11/sys/dev/cxgbe/tom/t4_listen.c 309560 2016-12-05 20:43:25Z jhb $"); |
30 31#include "opt_inet.h" 32#include "opt_inet6.h" 33 34#ifdef TCP_OFFLOAD 35#include <sys/param.h> 36#include <sys/types.h> 37#include <sys/kernel.h> --- 651 unchanged lines hidden (view full) --- 689 bzero(&to, sizeof(to)); 690 tcp_dooptions(&to, (void *)(th + 1), (th->th_off << 2) - sizeof(*th), 691 TO_SYN); 692 693 /* save these for later */ 694 synqe->iss = be32toh(th->th_seq); 695 synqe->ts = to.to_tsval; 696 | 30 31#include "opt_inet.h" 32#include "opt_inet6.h" 33 34#ifdef TCP_OFFLOAD 35#include <sys/param.h> 36#include <sys/types.h> 37#include <sys/kernel.h> --- 651 unchanged lines hidden (view full) --- 689 bzero(&to, sizeof(to)); 690 tcp_dooptions(&to, (void *)(th + 1), (th->th_off << 2) - sizeof(*th), 691 TO_SYN); 692 693 /* save these for later */ 694 synqe->iss = be32toh(th->th_seq); 695 synqe->ts = to.to_tsval; 696 |
697 if (is_t5(sc)) { | 697 if (chip_id(sc) >= CHELSIO_T5) { |
698 struct cpl_t5_pass_accept_rpl *rpl5 = wrtod(wr); 699 700 rpl5->iss = th->th_seq; 701 } 702 703 e = &sc->l2t->l2tab[synqe->l2e_idx]; 704 t4_l2t_send(sc, wr, e); 705 --- 342 unchanged lines hidden (view full) --- 1048 if (ulp_mode == ULP_MODE_TCPDDP) 1049 opt2 |= F_RX_FC_VALID | F_RX_FC_DDP; 1050#endif 1051 1052 return htobe32(opt2); 1053} 1054 1055static void | 698 struct cpl_t5_pass_accept_rpl *rpl5 = wrtod(wr); 699 700 rpl5->iss = th->th_seq; 701 } 702 703 e = &sc->l2t->l2tab[synqe->l2e_idx]; 704 t4_l2t_send(sc, wr, e); 705 --- 342 unchanged lines hidden (view full) --- 1048 if (ulp_mode == ULP_MODE_TCPDDP) 1049 opt2 |= F_RX_FC_VALID | F_RX_FC_DDP; 1050#endif 1051 1052 return htobe32(opt2); 1053} 1054 1055static void |
1056pass_accept_req_to_protohdrs(const struct mbuf *m, struct in_conninfo *inc, 1057 struct tcphdr *th) | 1056pass_accept_req_to_protohdrs(struct adapter *sc, const struct mbuf *m, 1057 struct in_conninfo *inc, struct tcphdr *th) |
1058{ 1059 const struct cpl_pass_accept_req *cpl = mtod(m, const void *); 1060 const struct ether_header *eh; 1061 unsigned int hlen = be32toh(cpl->hdr_len); 1062 uintptr_t l3hdr; 1063 const struct tcphdr *tcp; 1064 1065 eh = (const void *)(cpl + 1); | 1058{ 1059 const struct cpl_pass_accept_req *cpl = mtod(m, const void *); 1060 const struct ether_header *eh; 1061 unsigned int hlen = be32toh(cpl->hdr_len); 1062 uintptr_t l3hdr; 1063 const struct tcphdr *tcp; 1064 1065 eh = (const void *)(cpl + 1); |
1066 l3hdr = ((uintptr_t)eh + G_ETH_HDR_LEN(hlen)); 1067 tcp = (const void *)(l3hdr + G_IP_HDR_LEN(hlen)); | 1066 if (chip_id(sc) >= CHELSIO_T6) { 1067 l3hdr = ((uintptr_t)eh + G_T6_ETH_HDR_LEN(hlen)); 1068 tcp = (const void *)(l3hdr + G_T6_IP_HDR_LEN(hlen)); 1069 } else { 1070 l3hdr = ((uintptr_t)eh + G_ETH_HDR_LEN(hlen)); 1071 tcp = (const void *)(l3hdr + G_IP_HDR_LEN(hlen)); 1072 } |
1068 1069 if (inc) { 1070 bzero(inc, sizeof(*inc)); 1071 inc->inc_fport = tcp->th_sport; 1072 inc->inc_lport = tcp->th_dport; 1073 if (((struct ip *)l3hdr)->ip_v == IPVERSION) { 1074 const struct ip *ip = (const void *)l3hdr; 1075 --- 107 unchanged lines hidden (view full) --- 1183 1184 KASSERT(opcode == CPL_PASS_ACCEPT_REQ, 1185 ("%s: unexpected opcode 0x%x", __func__, opcode)); 1186 KASSERT(lctx->stid == stid, ("%s: lctx stid mismatch", __func__)); 1187 1188 CTR4(KTR_CXGBE, "%s: stid %u, tid %u, lctx %p", __func__, stid, tid, 1189 lctx); 1190 | 1073 1074 if (inc) { 1075 bzero(inc, sizeof(*inc)); 1076 inc->inc_fport = tcp->th_sport; 1077 inc->inc_lport = tcp->th_dport; 1078 if (((struct ip *)l3hdr)->ip_v == IPVERSION) { 1079 const struct ip *ip = (const void *)l3hdr; 1080 --- 107 unchanged lines hidden (view full) --- 1188 1189 KASSERT(opcode == CPL_PASS_ACCEPT_REQ, 1190 ("%s: unexpected opcode 0x%x", __func__, opcode)); 1191 KASSERT(lctx->stid == stid, ("%s: lctx stid mismatch", __func__)); 1192 1193 CTR4(KTR_CXGBE, "%s: stid %u, tid %u, lctx %p", __func__, stid, tid, 1194 lctx); 1195 |
1191 pass_accept_req_to_protohdrs(m, &inc, &th); | 1196 pass_accept_req_to_protohdrs(sc, m, &inc, &th); |
1192 t4opt_to_tcpopt(&cpl->tcpopt, &to); 1193 1194 pi = sc->port[G_SYN_INTF(be16toh(cpl->l2info))]; 1195 1196 /* 1197 * Use the MAC index to lookup the associated VI. If this SYN 1198 * didn't match a perfect MAC filter, punt. 1199 */ --- 222 unchanged lines hidden (view full) --- 1422 m->m_pkthdr.csum_data = 0xffff; 1423 hw_ifp->if_input(hw_ifp, m); 1424 } 1425 1426 return (reject_reason); 1427} 1428 1429static void | 1197 t4opt_to_tcpopt(&cpl->tcpopt, &to); 1198 1199 pi = sc->port[G_SYN_INTF(be16toh(cpl->l2info))]; 1200 1201 /* 1202 * Use the MAC index to lookup the associated VI. If this SYN 1203 * didn't match a perfect MAC filter, punt. 1204 */ --- 222 unchanged lines hidden (view full) --- 1427 m->m_pkthdr.csum_data = 0xffff; 1428 hw_ifp->if_input(hw_ifp, m); 1429 } 1430 1431 return (reject_reason); 1432} 1433 1434static void |
1430synqe_to_protohdrs(struct synq_entry *synqe, | 1435synqe_to_protohdrs(struct adapter *sc, struct synq_entry *synqe, |
1431 const struct cpl_pass_establish *cpl, struct in_conninfo *inc, 1432 struct tcphdr *th, struct tcpopt *to) 1433{ 1434 uint16_t tcp_opt = be16toh(cpl->tcp_opt); 1435 1436 /* start off with the original SYN */ | 1436 const struct cpl_pass_establish *cpl, struct in_conninfo *inc, 1437 struct tcphdr *th, struct tcpopt *to) 1438{ 1439 uint16_t tcp_opt = be16toh(cpl->tcp_opt); 1440 1441 /* start off with the original SYN */ |
1437 pass_accept_req_to_protohdrs(synqe->syn, inc, th); | 1442 pass_accept_req_to_protohdrs(sc, synqe->syn, inc, th); |
1438 1439 /* modify parts to make it look like the ACK to our SYN|ACK */ 1440 th->th_flags = TH_ACK; 1441 th->th_ack = synqe->iss + 1; 1442 th->th_seq = be32toh(cpl->rcv_isn); 1443 bzero(to, sizeof(*to)); 1444 if (G_TCPOPT_TSTAMP(tcp_opt)) { 1445 to->to_flags |= TOF_TS; --- 85 unchanged lines hidden (view full) --- 1531 toep->ulp_mode = ULP_MODE_NONE; 1532 /* opt0 rcv_bufsiz initially, assumes its normal meaning later */ 1533 toep->rx_credits = synqe->rcv_bufsize; 1534 1535 so = inp->inp_socket; 1536 KASSERT(so != NULL, ("%s: socket is NULL", __func__)); 1537 1538 /* Come up with something that syncache_expand should be ok with. */ | 1443 1444 /* modify parts to make it look like the ACK to our SYN|ACK */ 1445 th->th_flags = TH_ACK; 1446 th->th_ack = synqe->iss + 1; 1447 th->th_seq = be32toh(cpl->rcv_isn); 1448 bzero(to, sizeof(*to)); 1449 if (G_TCPOPT_TSTAMP(tcp_opt)) { 1450 to->to_flags |= TOF_TS; --- 85 unchanged lines hidden (view full) --- 1536 toep->ulp_mode = ULP_MODE_NONE; 1537 /* opt0 rcv_bufsiz initially, assumes its normal meaning later */ 1538 toep->rx_credits = synqe->rcv_bufsize; 1539 1540 so = inp->inp_socket; 1541 KASSERT(so != NULL, ("%s: socket is NULL", __func__)); 1542 1543 /* Come up with something that syncache_expand should be ok with. */ |
1539 synqe_to_protohdrs(synqe, cpl, &inc, &th, &to); | 1544 synqe_to_protohdrs(sc, synqe, cpl, &inc, &th, &to); |
1540 1541 /* 1542 * No more need for anything in the mbuf that carried the 1543 * CPL_PASS_ACCEPT_REQ. Drop the CPL_PASS_ESTABLISH and toep pointer 1544 * there. XXX: bad form but I don't want to increase the size of synqe. 1545 */ 1546 m = synqe->syn; 1547 KASSERT(sizeof(*cpl) + sizeof(toep) <= m->m_len, --- 50 unchanged lines hidden --- | 1545 1546 /* 1547 * No more need for anything in the mbuf that carried the 1548 * CPL_PASS_ACCEPT_REQ. Drop the CPL_PASS_ESTABLISH and toep pointer 1549 * there. XXX: bad form but I don't want to increase the size of synqe. 1550 */ 1551 m = synqe->syn; 1552 KASSERT(sizeof(*cpl) + sizeof(toep) <= m->m_len, --- 50 unchanged lines hidden --- |