/* copy a buffer into a pkt buffer chain */ uint pktfrombuf(osl_t *osh, void *p, uint offset, int len, uchar *buf) { uint n, ret = 0; /* skip 'offset' bytes */ for (; p && offset; p = PKTNEXT(osh, p)) { if (offset < (uint)PKTLEN(osh, p)) break; offset -= PKTLEN(osh, p); } if (!p) return 0; /* copy the data */ for (; p && len; p = PKTNEXT(osh, p)) { n = MIN((uint)PKTLEN(osh, p) - offset, (uint)len); bcopy(buf, PKTDATA(osh, p) + offset, n); buf += n; len -= n; ret += n; offset = 0; } return ret; }
/* Update flowid information on the packet */ int BCMFASTPATH dhd_flowid_update(dhd_pub_t *dhdp, uint8 ifindex, uint8 prio, void *pktbuf) { uint8 *pktdata = (uint8 *)PKTDATA(dhdp->osh, pktbuf); struct ether_header *eh = (struct ether_header *)pktdata; uint16 flowid; if (dhd_bus_is_txmode_push(dhdp->bus)) return BCME_OK; ASSERT(ifindex < DHD_MAX_IFS); if (ifindex >= DHD_MAX_IFS) { return BCME_BADARG; } if (!dhdp->flowid_allocator) { DHD_ERROR(("%s: Flow ring not intited yet \n", __FUNCTION__)); return BCME_ERROR; } if (dhd_flowid_lookup(dhdp, ifindex, prio, eh->ether_shost, eh->ether_dhost, &flowid) != BCME_OK) { return BCME_ERROR; } DHD_INFO(("%s: prio %d flowid %d\n", __FUNCTION__, prio, flowid)); /* Tag the packet with flowid */ DHD_PKTTAG_SET_FLOWID((dhd_pkttag_fr_t *)PKTTAG(pktbuf), flowid); return BCME_OK; }
static int BCMFASTPATH chiprxquota(ch_t *ch, int quota, void **rxpkts) { int rxcnt; void * pkt; uint8 * addr; ET_TRACE(("et%d: chiprxquota\n", ch->etc->unit)); ET_LOG("et%d: chiprxquota", ch->etc->unit, 0); rxcnt = 0; while ((quota > 0) && ((pkt = dma_rx(ch->di)) != NULL)) { addr = PKTDATA(ch->osh, pkt); #if !defined(_CFE_) bcm_prefetch_32B(addr + 32, 1); #endif /* _CFE_ */ rxpkts[rxcnt] = pkt; rxcnt++; quota--; } if (rxcnt < quota) { /* ring is "possibly" empty, enable et interrupts */ ch->intstatus &= ~I_RI; } return rxcnt; /* rxpkts[] has rxcnt number of pkts to be processed */ }
inline int dhd_tcpack_check_xmit(dhd_pub_t *dhdp, void *pkt) { uint8 i; tcpack_sup_module_t *tcpack_sup_mod; tcpack_info_t *tcpack_info_tbl; int tbl_cnt; int ret = BCME_OK; void *pdata; uint32 pktlen; if (dhdp->tcpack_sup_mode == TCPACK_SUP_OFF) goto exit; pdata = PKTDATA(dhdp->osh, pkt); pktlen = PKTLEN(dhdp->osh, pkt) - dhd_prot_hdrlen(dhdp, pdata); if (pktlen < TCPACKSZMIN || pktlen > TCPACKSZMAX) { DHD_TRACE(("%s %d: Too short or long length %d to be TCP ACK\n", __FUNCTION__, __LINE__, pktlen)); goto exit; } dhd_os_tcpacklock(dhdp); tcpack_sup_mod = dhdp->tcpack_sup_module; if (!tcpack_sup_mod) { DHD_ERROR(("%s %d: tcpack suppress module NULL!!\n", __FUNCTION__, __LINE__)); ret = BCME_ERROR; dhd_os_tcpackunlock(dhdp); goto exit; } tbl_cnt = tcpack_sup_mod->tcpack_info_cnt; tcpack_info_tbl = tcpack_sup_mod->tcpack_info_tbl; ASSERT(tbl_cnt <= TCPACK_INFO_MAXNUM); for (i = 0; i < tbl_cnt; i++) { if (tcpack_info_tbl[i].pkt_in_q == pkt) { DHD_TRACE(("%s %d: pkt %p sent out. idx %d, tbl_cnt %d\n", __FUNCTION__, __LINE__, pkt, i, tbl_cnt)); /* This pkt is being transmitted so remove the tcp_ack_info of it. */ if (i < tbl_cnt - 1) { bcopy(&tcpack_info_tbl[tbl_cnt - 1], &tcpack_info_tbl[i], sizeof(tcpack_info_t)); } bzero(&tcpack_info_tbl[tbl_cnt - 1], sizeof(tcpack_info_t)); if (--tcpack_sup_mod->tcpack_info_cnt < 0) { DHD_ERROR(("%s %d: ERROR!!! tcp_ack_info_cnt %d\n", __FUNCTION__, __LINE__, tcpack_sup_mod->tcpack_info_cnt)); ret = BCME_ERROR; } break; } } dhd_os_tcpackunlock(dhdp); exit: return ret; }
static void dhd_bta_flush_hcidata(dhd_pub_t *pub, uint16 llh) { int prec; struct pktq *q; uint count = 0; q = dhd_bus_txq(pub->bus); if (q == NULL) return; DHD_BTA(("dhd: flushing HCI ACL data for logical link %u...\n", llh)); dhd_os_sdlock_txq(pub); /* Walk through the txq and toss all HCI ACL data packets */ PKTQ_PREC_ITER(q, prec) { void *head_pkt = NULL; while (pktq_ppeek(q, prec) != head_pkt) { void *pkt = pktq_pdeq(q, prec); int ifidx; PKTPULL(pub->osh, pkt, dhd_bus_hdrlen(pub->bus)); dhd_prot_hdrpull(pub, &ifidx, pkt); if (PKTLEN(pub->osh, pkt) >= RFC1042_HDR_LEN) { struct ether_header *eh = (struct ether_header *)PKTDATA(pub->osh, pkt); if (ntoh16(eh->ether_type) < ETHER_TYPE_MIN) { struct dot11_llc_snap_header *lsh = (struct dot11_llc_snap_header *)&eh[1]; if (bcmp(lsh, BT_SIG_SNAP_MPROT, DOT11_LLC_SNAP_HDR_LEN - 2) == 0 && ntoh16(lsh->type) == BTA_PROT_L2CAP) { amp_hci_ACL_data_t *ACL_data = (amp_hci_ACL_data_t *)&lsh[1]; uint16 handle = ltoh16(ACL_data->handle); if (HCI_ACL_DATA_HANDLE(handle) == llh) { PKTFREE(pub->osh, pkt, TRUE); count ++; continue; } } } } dhd_prot_hdrpush(pub, ifidx, pkt); PKTPUSH(pub->osh, pkt, dhd_bus_hdrlen(pub->bus)); if (head_pkt == NULL) head_pkt = pkt; pktq_penq(q, prec, pkt); } }
/* pretty hex print a pkt buffer chain */ void prpkt(char *msg, void *drv, void *p0) { void *p; if (msg && (msg[0] != '\0')) printf("%s: ", msg); for (p = p0; p; p = PKTNEXT(drv, p)) prhex(NULL, PKTDATA(drv, p), PKTLEN(drv, p)); }
uint BCMFASTPATH osl_dma_map(osl_t *osh, void *va, uint size, int direction, void *p, hnddma_seg_map_t *dmah) { int dir; ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE; #if defined(__ARM_ARCH_7A__) && defined(BCMDMASGLISTOSL) if (dmah != NULL) { int32 nsegs, i, totsegs = 0, totlen = 0; struct scatterlist *sg, _sg[16]; struct sk_buff *skb; for (skb = (struct sk_buff *)p; skb != NULL; skb = PKTNEXT(osh, skb)) { sg = &_sg[totsegs]; if (skb_is_nonlinear(skb)) { nsegs = skb_to_sgvec(skb, sg, 0, PKTLEN(osh, skb)); ASSERT((nsegs > 0) && (nsegs <= 16)); pci_map_sg(osh->pdev, sg, nsegs, dir); } else { nsegs = 1; sg->page_link = 0; sg_set_buf(sg, PKTDATA(osh, skb), PKTLEN(osh, skb)); pci_map_single(osh->pdev, PKTDATA(osh, skb), PKTISCTF(osh, skb) ? CTFMAPSZ : PKTLEN(osh, skb), dir); } totsegs += nsegs; totlen += PKTLEN(osh, skb); } dmah->nsegs = totsegs; dmah->origsize = totlen; for (i = 0, sg = _sg; i < totsegs; i++, sg++) { dmah->segs[i].addr = sg_phys(sg); dmah->segs[i].length = sg->length; } return dmah->segs[0].addr; } #endif return (pci_map_single(osh->pdev, va, size, dir)); }
inline int dhd_tcpack_check_xmit(dhd_pub_t *dhdp, void *pkt) { uint8 i; tcp_ack_info_t *tcp_ack_info = NULL; int tbl_cnt; uint pushed_len; int ret = BCME_OK; void *pdata; uint32 pktlen; if (!dhdp->tcpack_sup_enabled) return ret; pdata = PKTDATA(dhdp->osh, pkt); /* Length of BDC(+WLFC) headers pushed */ pushed_len = BDC_HEADER_LEN + (((struct bdc_header *)pdata)->dataOffset * 4); pktlen = PKTLEN(dhdp->osh, pkt) - pushed_len; if (pktlen < TCPACKSZMIN || pktlen > TCPACKSZMAX) { DHD_TRACE(("%s %d: Too short or long length %d to be TCP ACK\n", __FUNCTION__, __LINE__, pktlen)); return ret; } dhd_os_tcpacklock(dhdp); tbl_cnt = dhdp->tcp_ack_info_cnt; for (i = 0; i < tbl_cnt; i++) { tcp_ack_info = &dhdp->tcp_ack_info_tbl[i]; if (tcp_ack_info->pkt_in_q == pkt) { DHD_TRACE(("%s %d: pkt %p sent out. idx %d, tbl_cnt %d\n", __FUNCTION__, __LINE__, pkt, i, tbl_cnt)); /* This pkt is being transmitted so remove the tcp_ack_info of it. */ if (i < tbl_cnt - 1) { bcopy(&dhdp->tcp_ack_info_tbl[tbl_cnt - 1], &dhdp->tcp_ack_info_tbl[i], sizeof(struct tcp_ack_info)); } bzero(&dhdp->tcp_ack_info_tbl[tbl_cnt - 1], sizeof(struct tcp_ack_info)); if (--dhdp->tcp_ack_info_cnt < 0) { DHD_ERROR(("%s %d: ERROR!!! tcp_ack_info_cnt %d\n", __FUNCTION__, __LINE__, dhdp->tcp_ack_info_cnt)); ret = BCME_ERROR; } break; } } dhd_os_tcpackunlock(dhdp); return ret; }
int dhd_prot_hdrpull(dhd_pub_t *dhd, int *ifidx, void *pktbuf) { #ifdef BDC struct bdc_header *h; #endif uint8 bdc_ver; DHD_TRACE(("%s: Enter\n", __FUNCTION__)); #ifdef BDC /* Pop BDC header used to convey priority for buses that don't */ if (PKTLEN(dhd->osh, pktbuf) < BDC_HEADER_LEN) { DHD_ERROR(("%s: rx data too short (%d < %d)\n", __FUNCTION__, PKTLEN(dhd->osh, pktbuf), BDC_HEADER_LEN)); return BCME_ERROR; } h = (struct bdc_header *)PKTDATA(dhd->osh, pktbuf); if ((*ifidx = BDC_GET_IF_IDX(h)) >= DHD_MAX_IFS) { DHD_ERROR(("%s: rx data ifnum out of range (%d)\n", __FUNCTION__, *ifidx)); return BCME_ERROR; } bdc_ver = (h->flags & BDC_FLAG_VER_MASK) >> BDC_FLAG_VER_SHIFT; if ((bdc_ver != BDC_PROTO_VER) && (bdc_ver != 2)) { DHD_ERROR(("%s: non-BDC packet received, flags 0x%x, BDC %d\n", dhd_ifname(dhd, *ifidx), h->flags, bdc_ver)); return BCME_ERROR; } if (h->flags & BDC_FLAG_SUM_GOOD) { DHD_INFO(("%s: BDC packet received with good rx-csum, flags 0x%x\n", dhd_ifname(dhd, *ifidx), h->flags)); PKTSETSUMGOOD(pktbuf, TRUE); } PKTSETPRIO(pktbuf, (h->priority & BDC_PRIORITY_MASK)); PKTPULL(dhd->osh, pktbuf, BDC_HEADER_LEN); #endif /* BDC */ return 0; }
/* * Description: This function is called by Netfilter when packet hits * the bridge pre routing hook. All IP packets are given * to EMFL for its processing. * * Input: pskb - Pointer to the packet buffer. Other parameters * are not used. * * Return: Returns the value indicating packet can be forwarded * or packet is stolen. */ static uint32 emf_br_pre_hook( uint32 hook, #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) struct sk_buff *skb, #else struct sk_buff **pskb, #endif const struct net_device *in, const struct net_device *out, int32 (*okfn)(struct sk_buff *)) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) struct sk_buff **pskb = &skb; #endif emf_info_t *emfi; EMF_INFO("Frame at BR_PRE_HOOK received from if %p %s\n", (*pskb)->dev, (*pskb)->dev->name); /* Find the bridge that the receive interface corresponds to */ emfi = emf_instance_find_by_ifptr(emf, (*pskb)->dev); if (emfi == NULL) { EMF_INFO("No EMF processing needed for unknown ports\n"); return (NF_ACCEPT); } /* Non IP packet received from LAN port is returned back to * bridge. */ if ((*pskb)->protocol != __constant_htons(ETH_P_IP)) { EMF_INFO("Ignoring non IP packets from LAN ports\n"); return (NF_ACCEPT); } EMF_DUMP_PKT((*pskb)->data); return (emfc_input(emfi->emfci, *pskb, (*pskb)->dev, PKTDATA(NULL, *pskb), FALSE)); }
bool dhd_proto_fcinfo(dhd_pub_t *dhd, void *pktbuf, uint8 *fcbits) { #ifdef BDC struct bdc_header *h; if (PKTLEN(dhd->osh, pktbuf) < BDC_HEADER_LEN) { DHD_ERROR(("%s: rx data too short (%d < %d)\n", __FUNCTION__, PKTLEN(dhd->osh, pktbuf), BDC_HEADER_LEN)); return BCME_ERROR; } h = (struct bdc_header *)PKTDATA(dhd->osh, pktbuf); *fcbits = h->priority >> BDC_PRIORITY_FC_SHIFT; if ((h->flags2 & BDC_FLAG2_FC_FLAG) == BDC_FLAG2_FC_FLAG) return TRUE; #endif return FALSE; }
/* totally bogus -- d11 hdr only + tx hdrs */ static void * wlc_olpc_get_pkt(wlc_info_t *wlc, uint ac, uint* fifo) { int buflen = (TXOFF + WL_OLPC_PKT_LEN); void* p = NULL; osl_t *osh = wlc->osh; const char* macaddr = NULL; struct dot11_header *hdr = NULL; if ((p = PKTGET(osh, buflen, TRUE)) == NULL) { WL_ERROR(("wl%d: %s: pktget error for len %d \n", wlc->pub->unit, __FUNCTION__, buflen)); goto fatal; } macaddr = WLC_MACADDR(wlc); WL_NONE(("pkt manip\n")); /* reserve TXOFF bytes of headroom */ PKTPULL(osh, p, TXOFF); PKTSETLEN(osh, p, WL_OLPC_PKT_LEN); WL_NONE(("d11_hdr\n")); hdr = (struct dot11_header*)PKTDATA(osh, p); bzero((char*)hdr, WL_OLPC_PKT_LEN); hdr->fc = htol16(FC_DATA); hdr->durid = 0; bcopy((const char*)macaddr, (char*)&(hdr->a1.octet), ETHER_ADDR_LEN); bcopy((const char*)macaddr, (char*)&(hdr->a2.octet), ETHER_ADDR_LEN); bcopy((const char*)macaddr, (char*)&(hdr->a3.octet), ETHER_ADDR_LEN); hdr->seq = 0; WL_NONE(("prep raw 80211\n")); wlc->olpc_info->tx_cal_pkts = TRUE; /* frameid returned here -- ignore for now -- may speed up using this */ (void)wlc_prep80211_raw(wlc, NULL, ac, TRUE, p, fifo); wlc->olpc_info->tx_cal_pkts = FALSE; return p; fatal: return (NULL); }
/* returns a pointer to the next frame received, or NULL if there are no more */ void* dma_rx(dma_info_t *di) { void *p; uint len; int skiplen = 0; while ((p = dma_getnextrxp(di, FALSE))) { /* skip giant packets which span multiple rx descriptors */ if (skiplen > 0) { skiplen -= di->rxbufsize; if (skiplen < 0) skiplen = 0; PKTFREE(di->drv, p, FALSE); continue; } len = ltoh16(*(uint16*)(PKTDATA(di->drv, p))); DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); /* bad frame length check */ if (len > (di->rxbufsize - di->rxoffset)) { DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len)); if (len > 0) skiplen = len - (di->rxbufsize - di->rxoffset); PKTFREE(di->drv, p, FALSE); di->hnddma.rxgiants++; continue; } /* set actual length */ PKTSETLEN(di->drv, p, (di->rxoffset + len)); break; } return (p); }
void* osl_pktdup(void *drv, void *p) { END_OBJ *end; M_BLK_ID m; int len = pkttotlen(drv, p); /* drv is a pointer to an END_OBJ in disguise */ end = (END_OBJ*)drv; /* dont use a real dup until PR14233 is fixed m = netMblkChainDup(end->pNetPool, (M_BLK_ID)p, 0, M_COPYALL, M_DONTWAIT); */ /* alloc a new mbuf */ if ((m = PKTGET(drv, len, TRUE)) == NULL) return (NULL); /* copy data into mbuf */ pktcopy(drv, p, 0, len, (uchar*)PKTDATA(drv, m)); ASSERT(len == PKTLEN(drv, m)); return (m); }
bool dhd_tcpdata_info_get(dhd_pub_t *dhdp, void *pkt) { uint8 *ether_hdr; /* Ethernet header of the new packet */ uint16 ether_type; /* Ethernet type of the new packet */ uint8 *ip_hdr; /* IP header of the new packet */ uint8 *tcp_hdr; /* TCP header of the new packet */ uint32 ip_hdr_len; /* IP header length of the new packet */ uint32 cur_framelen; uint16 ip_total_len; /* Total length of IP packet for the new packet */ uint32 tcp_hdr_len; /* TCP header length of the new packet */ uint32 tcp_seq_num; /* TCP sequence number of the new packet */ uint16 tcp_data_len; /* TCP DATA length that excludes IP and TCP headers */ uint32 end_tcp_seq_num; /* TCP seq number of the last byte in the new packet */ tcpack_sup_module_t *tcpack_sup_mod; tcpdata_info_t *tcpdata_info = NULL; tdata_psh_info_t *tdata_psh_info; int i; bool ret = FALSE; if (dhdp->tcpack_sup_mode != TCPACK_SUP_DELAYTX) goto exit; ether_hdr = PKTDATA(dhdp->osh, pkt); cur_framelen = PKTLEN(dhdp->osh, pkt); ether_type = ether_hdr[12] << 8 | ether_hdr[13]; if (ether_type != ETHER_TYPE_IP) { DHD_TRACE(("%s %d: Not a IP packet 0x%x\n", __FUNCTION__, __LINE__, ether_type)); goto exit; } DHD_TRACE(("%s %d: IP pkt! 0x%x\n", __FUNCTION__, __LINE__, ether_type)); ip_hdr = ether_hdr + ETHER_HDR_LEN; cur_framelen -= ETHER_HDR_LEN; ASSERT(cur_framelen >= IPV4_MIN_HEADER_LEN); ip_hdr_len = IPV4_HLEN(ip_hdr); if (IP_VER(ip_hdr) != IP_VER_4 || IPV4_PROT(ip_hdr) != IP_PROT_TCP) { DHD_TRACE(("%s %d: Not IPv4 nor TCP! ip ver %d, prot %d\n", __FUNCTION__, __LINE__, IP_VER(ip_hdr), IPV4_PROT(ip_hdr))); goto exit; } tcp_hdr = ip_hdr + ip_hdr_len; cur_framelen -= ip_hdr_len; ASSERT(cur_framelen >= TCP_MIN_HEADER_LEN); DHD_TRACE(("%s %d: TCP pkt!\n", __FUNCTION__, __LINE__)); ip_total_len = ntoh16_ua(&ip_hdr[IPV4_PKTLEN_OFFSET]); tcp_hdr_len = 4 * TCP_HDRLEN(tcp_hdr[TCP_HLEN_OFFSET]); /* This packet is mere TCP ACK, so do nothing */ if (ip_total_len == ip_hdr_len + tcp_hdr_len) { DHD_TRACE(("%s %d: Do nothing for no data TCP ACK\n", __FUNCTION__, __LINE__)); goto exit; } ASSERT(ip_total_len > ip_hdr_len + tcp_hdr_len); if ((tcp_hdr[TCP_FLAGS_OFFSET] & TCP_FLAG_PSH) == 0) { DHD_TRACE(("%s %d: Not interested TCP DATA packet\n", __FUNCTION__, __LINE__)); goto exit; } DHD_TRACE(("%s %d: TCP DATA with nonzero DATA length" " IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR" TCP port %d %d, flag 0x%x\n", __FUNCTION__, __LINE__, IPV4_ADDR_TO_STR(ntoh32_ua(&ip_hdr[IPV4_SRC_IP_OFFSET])), IPV4_ADDR_TO_STR(ntoh32_ua(&ip_hdr[IPV4_DEST_IP_OFFSET])), ntoh16_ua(&tcp_hdr[TCP_SRC_PORT_OFFSET]), ntoh16_ua(&tcp_hdr[TCP_DEST_PORT_OFFSET]), tcp_hdr[TCP_FLAGS_OFFSET])); dhd_os_tcpacklock(dhdp); tcpack_sup_mod = dhdp->tcpack_sup_module; if (!tcpack_sup_mod) { DHD_ERROR(("%s %d: tcpack suppress module NULL!!\n", __FUNCTION__, __LINE__)); ret = BCME_ERROR; dhd_os_tcpackunlock(dhdp); goto exit; } /* Look for tcpdata_info that has the same ip src/dst addrs and tcp src/dst ports */ i = 0; while (i < tcpack_sup_mod->tcpdata_info_cnt) { tcpdata_info_t *tdata_info_tmp = &tcpack_sup_mod->tcpdata_info_tbl[i]; uint32 now_in_ms = OSL_SYSUPTIME(); DHD_TRACE(("%s %d: data info[%d], IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR " TCP port %d %d\n", __FUNCTION__, __LINE__, i, IPV4_ADDR_TO_STR(ntoh32_ua(tdata_info_tmp->src_ip_addr)), IPV4_ADDR_TO_STR(ntoh32_ua(tdata_info_tmp->dst_ip_addr)), ntoh16_ua(tdata_info_tmp->src_tcp_port), ntoh16_ua(tdata_info_tmp->dst_tcp_port))); /* If both IP address and TCP port number match, we found it so break. */ if (memcmp(&ip_hdr[IPV4_SRC_IP_OFFSET], tdata_info_tmp->src_ip_addr, IPV4_ADDR_LEN * 2) == 0 && memcmp(&tcp_hdr[TCP_SRC_PORT_OFFSET], tdata_info_tmp->src_tcp_port, TCP_PORT_LEN * 2) == 0) { tcpdata_info = tdata_info_tmp; tcpdata_info->last_used_time = now_in_ms; break; } if (now_in_ms - tdata_info_tmp->last_used_time > TCPDATA_INFO_TIMEOUT) { tdata_psh_info_t *tdata_psh_info_tmp; tcpdata_info_t *last_tdata_info; while ((tdata_psh_info_tmp = tdata_info_tmp->tdata_psh_info_head)) { tdata_info_tmp->tdata_psh_info_head = tdata_psh_info_tmp->next; tdata_psh_info_tmp->next = NULL; DHD_TRACE(("%s %d: Clean tdata_psh_info(end_seq %u)!\n", __FUNCTION__, __LINE__, tdata_psh_info_tmp->end_seq)); _tdata_psh_info_pool_enq(tcpack_sup_mod, tdata_psh_info_tmp); } #ifdef DHDTCPACK_SUP_DBG DHD_ERROR(("%s %d: PSH INFO ENQ %d\n", __FUNCTION__, __LINE__, tcpack_sup_mod->psh_info_enq_num)); #endif /* DHDTCPACK_SUP_DBG */ tcpack_sup_mod->tcpdata_info_cnt--; ASSERT(tcpack_sup_mod->tcpdata_info_cnt >= 0); last_tdata_info = &tcpack_sup_mod->tcpdata_info_tbl[tcpack_sup_mod->tcpdata_info_cnt]; if (i < tcpack_sup_mod->tcpdata_info_cnt) { ASSERT(last_tdata_info != tdata_info_tmp); bcopy(last_tdata_info, tdata_info_tmp, sizeof(tcpdata_info_t)); } bzero(last_tdata_info, sizeof(tcpdata_info_t)); DHD_TRACE(("%s %d: tcpdata_info(idx %d) is aged out. ttl cnt is now %d\n", __FUNCTION__, __LINE__, i, tcpack_sup_mod->tcpdata_info_cnt)); /* Don't increase "i" here, so that the prev last tcpdata_info is checked */ } else i++; } tcp_seq_num = ntoh32_ua(&tcp_hdr[TCP_SEQ_NUM_OFFSET]); tcp_data_len = ip_total_len - ip_hdr_len - tcp_hdr_len; end_tcp_seq_num = tcp_seq_num + tcp_data_len; if (tcpdata_info == NULL) { ASSERT(i == tcpack_sup_mod->tcpdata_info_cnt); if (i >= TCPDATA_INFO_MAXNUM) { DHD_TRACE(("%s %d: tcp_data_info_tbl FULL! %d %d" " IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR" TCP port %d %d\n", __FUNCTION__, __LINE__, i, tcpack_sup_mod->tcpdata_info_cnt, IPV4_ADDR_TO_STR(ntoh32_ua(&ip_hdr[IPV4_SRC_IP_OFFSET])), IPV4_ADDR_TO_STR(ntoh32_ua(&ip_hdr[IPV4_DEST_IP_OFFSET])), ntoh16_ua(&tcp_hdr[TCP_SRC_PORT_OFFSET]), ntoh16_ua(&tcp_hdr[TCP_DEST_PORT_OFFSET]))); dhd_os_tcpackunlock(dhdp); goto exit; } tcpdata_info = &tcpack_sup_mod->tcpdata_info_tbl[i]; /* No TCP flow with the same IP addr and TCP port is found * in tcp_data_info_tbl. So add this flow to the table. */ DHD_TRACE(("%s %d: Add data info to tbl[%d]: IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR " TCP port %d %d\n", __FUNCTION__, __LINE__, tcpack_sup_mod->tcpdata_info_cnt, IPV4_ADDR_TO_STR(ntoh32_ua(&ip_hdr[IPV4_SRC_IP_OFFSET])), IPV4_ADDR_TO_STR(ntoh32_ua(&ip_hdr[IPV4_DEST_IP_OFFSET])), ntoh16_ua(&tcp_hdr[TCP_SRC_PORT_OFFSET]), ntoh16_ua(&tcp_hdr[TCP_DEST_PORT_OFFSET]))); bcopy(&ip_hdr[IPV4_SRC_IP_OFFSET], tcpdata_info->src_ip_addr, IPV4_ADDR_LEN * 2); bcopy(&tcp_hdr[TCP_SRC_PORT_OFFSET], tcpdata_info->src_tcp_port, TCP_PORT_LEN * 2); tcpdata_info->last_used_time = OSL_SYSUPTIME(); tcpack_sup_mod->tcpdata_info_cnt++; } ASSERT(tcpdata_info != NULL); tdata_psh_info = _tdata_psh_info_pool_deq(tcpack_sup_mod); #ifdef DHDTCPACK_SUP_DBG DHD_TRACE(("%s %d: PSH INFO ENQ %d\n", __FUNCTION__, __LINE__, tcpack_sup_mod->psh_info_enq_num)); #endif /* DHDTCPACK_SUP_DBG */ if (tdata_psh_info == NULL) { DHD_ERROR(("%s %d: No more free tdata_psh_info!!\n", __FUNCTION__, __LINE__)); ret = BCME_ERROR; dhd_os_tcpackunlock(dhdp); goto exit; } tdata_psh_info->end_seq = end_tcp_seq_num; #if defined(DEBUG_COUNTER) && defined(DHDTCPACK_SUP_DBG) tack_tbl.cnt[4]++; #endif /* DEBUG_COUNTER && DHDTCPACK_SUP_DBG */ DHD_TRACE(("%s %d: TCP PSH DATA recvd! end seq %u\n", __FUNCTION__, __LINE__, tdata_psh_info->end_seq)); ASSERT(tdata_psh_info->next == NULL); if (tcpdata_info->tdata_psh_info_head == NULL) tcpdata_info->tdata_psh_info_head = tdata_psh_info; else { ASSERT(tcpdata_info->tdata_psh_info_tail); tcpdata_info->tdata_psh_info_tail->next = tdata_psh_info; } tcpdata_info->tdata_psh_info_tail = tdata_psh_info; dhd_os_tcpackunlock(dhdp); exit: return ret; }
bool dhd_tcpack_suppress(dhd_pub_t *dhdp, void *pkt) { uint8 *new_ether_hdr; /* Ethernet header of the new packet */ uint16 new_ether_type; /* Ethernet type of the new packet */ uint8 *new_ip_hdr; /* IP header of the new packet */ uint8 *new_tcp_hdr; /* TCP header of the new packet */ uint32 new_ip_hdr_len; /* IP header length of the new packet */ uint32 cur_framelen; uint32 new_tcp_ack_num; /* TCP acknowledge number of the new packet */ uint16 new_ip_total_len; /* Total length of IP packet for the new packet */ uint32 new_tcp_hdr_len; /* TCP header length of the new packet */ tcpack_sup_module_t *tcpack_sup_mod; tcpack_info_t *tcpack_info_tbl; int i; bool ret = FALSE; bool set_dotxinrx = TRUE; if (dhdp->tcpack_sup_mode == TCPACK_SUP_OFF) goto exit; new_ether_hdr = PKTDATA(dhdp->osh, pkt); cur_framelen = PKTLEN(dhdp->osh, pkt); if (cur_framelen < TCPACKSZMIN || cur_framelen > TCPACKSZMAX) { DHD_TRACE(("%s %d: Too short or long length %d to be TCP ACK\n", __FUNCTION__, __LINE__, cur_framelen)); goto exit; } new_ether_type = new_ether_hdr[12] << 8 | new_ether_hdr[13]; if (new_ether_type != ETHER_TYPE_IP) { DHD_TRACE(("%s %d: Not a IP packet 0x%x\n", __FUNCTION__, __LINE__, new_ether_type)); goto exit; } DHD_TRACE(("%s %d: IP pkt! 0x%x\n", __FUNCTION__, __LINE__, new_ether_type)); new_ip_hdr = new_ether_hdr + ETHER_HDR_LEN; cur_framelen -= ETHER_HDR_LEN; ASSERT(cur_framelen >= IPV4_MIN_HEADER_LEN); new_ip_hdr_len = IPV4_HLEN(new_ip_hdr); if (IP_VER(new_ip_hdr) != IP_VER_4 || IPV4_PROT(new_ip_hdr) != IP_PROT_TCP) { DHD_TRACE(("%s %d: Not IPv4 nor TCP! ip ver %d, prot %d\n", __FUNCTION__, __LINE__, IP_VER(new_ip_hdr), IPV4_PROT(new_ip_hdr))); goto exit; } new_tcp_hdr = new_ip_hdr + new_ip_hdr_len; cur_framelen -= new_ip_hdr_len; ASSERT(cur_framelen >= TCP_MIN_HEADER_LEN); DHD_TRACE(("%s %d: TCP pkt!\n", __FUNCTION__, __LINE__)); /* is it an ack ? Allow only ACK flag, not to suppress others. */ if (new_tcp_hdr[TCP_FLAGS_OFFSET] != TCP_FLAG_ACK) { DHD_TRACE(("%s %d: Do not touch TCP flag 0x%x\n", __FUNCTION__, __LINE__, new_tcp_hdr[TCP_FLAGS_OFFSET])); goto exit; } new_ip_total_len = ntoh16_ua(&new_ip_hdr[IPV4_PKTLEN_OFFSET]); new_tcp_hdr_len = 4 * TCP_HDRLEN(new_tcp_hdr[TCP_HLEN_OFFSET]); /* This packet has TCP data, so just send */ if (new_ip_total_len > new_ip_hdr_len + new_tcp_hdr_len) { DHD_TRACE(("%s %d: Do nothing for TCP DATA\n", __FUNCTION__, __LINE__)); goto exit; } ASSERT(new_ip_total_len == new_ip_hdr_len + new_tcp_hdr_len); new_tcp_ack_num = ntoh32_ua(&new_tcp_hdr[TCP_ACK_NUM_OFFSET]); DHD_TRACE(("%s %d: TCP ACK with zero DATA length" " IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR" TCP port %d %d\n", __FUNCTION__, __LINE__, IPV4_ADDR_TO_STR(ntoh32_ua(&new_ip_hdr[IPV4_SRC_IP_OFFSET])), IPV4_ADDR_TO_STR(ntoh32_ua(&new_ip_hdr[IPV4_DEST_IP_OFFSET])), ntoh16_ua(&new_tcp_hdr[TCP_SRC_PORT_OFFSET]), ntoh16_ua(&new_tcp_hdr[TCP_DEST_PORT_OFFSET]))); /* Look for tcp_ack_info that has the same ip src/dst addrs and tcp src/dst ports */ dhd_os_tcpacklock(dhdp); #if defined(DEBUG_COUNTER) && defined(DHDTCPACK_SUP_DBG) counter_printlog(&tack_tbl); tack_tbl.cnt[0]++; #endif /* DEBUG_COUNTER && DHDTCPACK_SUP_DBG */ tcpack_sup_mod = dhdp->tcpack_sup_module; tcpack_info_tbl = tcpack_sup_mod->tcpack_info_tbl; if (!tcpack_sup_mod) { DHD_ERROR(("%s %d: tcpack suppress module NULL!!\n", __FUNCTION__, __LINE__)); ret = BCME_ERROR; dhd_os_tcpackunlock(dhdp); goto exit; } if (dhd_tcpdata_psh_acked(dhdp, new_ip_hdr, new_tcp_hdr, new_tcp_ack_num)) { /* This TCPACK is ACK to TCPDATA PSH pkt, so keep set_dotxinrx TRUE */ #if defined(DEBUG_COUNTER) && defined(DHDTCPACK_SUP_DBG) tack_tbl.cnt[5]++; #endif /* DEBUG_COUNTER && DHDTCPACK_SUP_DBG */ } else set_dotxinrx = FALSE; for (i = 0; i < tcpack_sup_mod->tcpack_info_cnt; i++) { void *oldpkt; /* TCPACK packet that is already in txq or DelayQ */ uint8 *old_ether_hdr, *old_ip_hdr, *old_tcp_hdr; uint32 old_ip_hdr_len, old_tcp_hdr_len; uint32 old_tcpack_num; /* TCP ACK number of old TCPACK packet in Q */ if ((oldpkt = tcpack_info_tbl[i].pkt_in_q) == NULL) { DHD_ERROR(("%s %d: Unexpected error!! cur idx %d, ttl cnt %d\n", __FUNCTION__, __LINE__, i, tcpack_sup_mod->tcpack_info_cnt)); break; } if (PKTDATA(dhdp->osh, oldpkt) == NULL) { DHD_ERROR(("%s %d: oldpkt data NULL!! cur idx %d, ttl cnt %d\n", __FUNCTION__, __LINE__, i, tcpack_sup_mod->tcpack_info_cnt)); break; } old_ether_hdr = tcpack_info_tbl[i].pkt_ether_hdr; old_ip_hdr = old_ether_hdr + ETHER_HDR_LEN; old_ip_hdr_len = IPV4_HLEN(old_ip_hdr); old_tcp_hdr = old_ip_hdr + old_ip_hdr_len; old_tcp_hdr_len = 4 * TCP_HDRLEN(old_tcp_hdr[TCP_HLEN_OFFSET]); DHD_TRACE(("%s %d: oldpkt %p[%d], IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR " TCP port %d %d\n", __FUNCTION__, __LINE__, oldpkt, i, IPV4_ADDR_TO_STR(ntoh32_ua(&old_ip_hdr[IPV4_SRC_IP_OFFSET])), IPV4_ADDR_TO_STR(ntoh32_ua(&old_ip_hdr[IPV4_DEST_IP_OFFSET])), ntoh16_ua(&old_tcp_hdr[TCP_SRC_PORT_OFFSET]), ntoh16_ua(&old_tcp_hdr[TCP_DEST_PORT_OFFSET]))); /* If either of IP address or TCP port number does not match, skip. */ if (memcmp(&new_ip_hdr[IPV4_SRC_IP_OFFSET], &old_ip_hdr[IPV4_SRC_IP_OFFSET], IPV4_ADDR_LEN * 2) || memcmp(&new_tcp_hdr[TCP_SRC_PORT_OFFSET], &old_tcp_hdr[TCP_SRC_PORT_OFFSET], TCP_PORT_LEN * 2)) continue; old_tcpack_num = ntoh32_ua(&old_tcp_hdr[TCP_ACK_NUM_OFFSET]); if (IS_TCPSEQ_GT(new_tcp_ack_num, old_tcpack_num)) { /* New packet has higher TCP ACK number, so it replaces the old packet */ if (new_ip_hdr_len == old_ip_hdr_len && new_tcp_hdr_len == old_tcp_hdr_len) { ASSERT(memcmp(new_ether_hdr, old_ether_hdr, ETHER_HDR_LEN) == 0); bcopy(new_ip_hdr, old_ip_hdr, new_ip_total_len); PKTFREE(dhdp->osh, pkt, FALSE); DHD_TRACE(("%s %d: TCP ACK replace %u -> %u\n", __FUNCTION__, __LINE__, old_tcpack_num, new_tcp_ack_num)); #if defined(DEBUG_COUNTER) && defined(DHDTCPACK_SUP_DBG) tack_tbl.cnt[2]++; #endif /* DEBUG_COUNTER && DHDTCPACK_SUP_DBG */ ret = TRUE; } else { #if defined(DEBUG_COUNTER) && defined(DHDTCPACK_SUP_DBG) tack_tbl.cnt[6]++; #endif /* DEBUG_COUNTER && DHDTCPACK_SUP_DBG */ DHD_TRACE(("%s %d: lenth mismatch %d != %d || %d != %d" " ACK %u -> %u\n", __FUNCTION__, __LINE__, new_ip_hdr_len, old_ip_hdr_len, new_tcp_hdr_len, old_tcp_hdr_len, old_tcpack_num, new_tcp_ack_num)); } } else if (new_tcp_ack_num == old_tcpack_num) { set_dotxinrx = TRUE; /* TCPACK retransmission */ #if defined(DEBUG_COUNTER) && defined(DHDTCPACK_SUP_DBG) tack_tbl.cnt[3]++; #endif /* DEBUG_COUNTER && DHDTCPACK_SUP_DBG */ } else { DHD_TRACE(("%s %d: ACK number reverse old %u(0x%p) new %u(0x%p)\n", __FUNCTION__, __LINE__, old_tcpack_num, oldpkt, new_tcp_ack_num, pkt)); } dhd_os_tcpackunlock(dhdp); goto exit; } if (i == tcpack_sup_mod->tcpack_info_cnt && i < TCPACK_INFO_MAXNUM) { /* No TCPACK packet with the same IP addr and TCP port is found * in tcp_ack_info_tbl. So add this packet to the table. */ DHD_TRACE(("%s %d: Add pkt 0x%p(ether_hdr 0x%p) to tbl[%d]\n", __FUNCTION__, __LINE__, pkt, new_ether_hdr, tcpack_sup_mod->tcpack_info_cnt)); tcpack_info_tbl[tcpack_sup_mod->tcpack_info_cnt].pkt_in_q = pkt; tcpack_info_tbl[tcpack_sup_mod->tcpack_info_cnt].pkt_ether_hdr = new_ether_hdr; tcpack_sup_mod->tcpack_info_cnt++; #if defined(DEBUG_COUNTER) && defined(DHDTCPACK_SUP_DBG) tack_tbl.cnt[1]++; #endif /* DEBUG_COUNTER && DHDTCPACK_SUP_DBG */ } else { ASSERT(i == tcpack_sup_mod->tcpack_info_cnt); DHD_TRACE(("%s %d: No empty tcp ack info tbl\n", __FUNCTION__, __LINE__)); } dhd_os_tcpackunlock(dhdp); exit: /* Unless TCPACK_SUP_DELAYTX, dotxinrx is alwasy TRUE, so no need to set here */ if (dhdp->tcpack_sup_mode == TCPACK_SUP_DELAYTX && set_dotxinrx) dhd_bus_set_dotxinrx(dhdp->bus, TRUE); return ret; }
/* * Just like above except go through the extra effort of splitting * buffers that cross 4Kbyte boundaries into multiple tx descriptors. */ int dma_tx(dma_info_t *di, void *p0, uint32 coreflags) { void *p, *next; uchar *data; uint plen, len; uchar *page, *start, *end; uint txout; uint32 ctrl; uint32 pa; DMA_TRACE(("%s: dma_tx\n", di->name)); txout = di->txout; ctrl = 0; /* * Walk the chain of packet buffers * splitting those that cross 4 Kbyte boundaries * allocating and initializing transmit descriptor entries. */ for (p = p0; p; p = next) { data = PKTDATA(di->drv, p); plen = PKTLEN(di->drv, p); next = PKTNEXT(di->drv, p); /* PR988 - skip zero length buffers */ if (plen == 0) continue; for (page = (uchar*)PAGEBASE(data); page <= (uchar*)PAGEBASE(data + plen - 1); page += PAGESZ) { /* return nonzero if out of tx descriptors */ if (NEXTTXD(txout) == di->txin) goto outoftxd; start = (page == (uchar*)PAGEBASE(data))? data: page; end = (page == (uchar*)PAGEBASE(data + plen))? (data + plen): (page + PAGESZ); len = end - start; /* build the descriptor control value */ ctrl = len & CTRL_BC_MASK; /* PR3697: Descriptor flags are not ignored for descriptors where SOF is clear */ ctrl |= coreflags; if ((p == p0) && (start == data)) ctrl |= CTRL_SOF; if ((next == NULL) && (end == (data + plen))) ctrl |= (CTRL_IOC | CTRL_EOF); if (txout == (di->ntxd - 1)) ctrl |= CTRL_EOT; /* get physical address of buffer start */ pa = (uint32) DMA_MAP(di->dev, start, len, DMA_TX, p); /* init the tx descriptor */ W_SM(&di->txd[txout].ctrl, BUS_SWAP32(ctrl)); W_SM(&di->txd[txout].addr, BUS_SWAP32(pa + di->dataoffset)); ASSERT(di->txp[txout] == NULL); txout = NEXTTXD(txout); } } /* if last txd eof not set, fix it */ if (!(ctrl & CTRL_EOF)) W_SM(&di->txd[PREVTXD(txout)].ctrl, BUS_SWAP32(ctrl | CTRL_IOC | CTRL_EOF)); /* save the packet */ di->txp[di->txout] = p0; /* bump the tx descriptor index */ di->txout = txout; /* kick the chip */ W_REG(&di->regs->xmtptr, I2B(txout)); /* tx flow control */ di->txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; return (0); outoftxd: DMA_ERROR(("%s: dma_tx: out of txds\n", di->name)); PKTFREE(di->drv, p0, TRUE); di->txavail = 0; di->hnddma.txnobuf++; return (-1); }
pkt_frag_t pkt_frag_info(osl_t *osh, void *p) { uint8 *frame; int length; uint8 *pt; /* Pointer to type field */ uint16 ethertype; struct ipv4_hdr *iph; /* IP frame pointer */ int ipl; /* IP frame length */ uint16 iph_frag; ASSERT(osh && p); frame = PKTDATA(osh, p); length = PKTLEN(osh, p); /* Process Ethernet II or SNAP-encapsulated 802.3 frames */ if (length < ETHER_HDR_LEN) { DHD_INFO(("%s: short eth frame (%d)\n", __FUNCTION__, length)); return DHD_PKT_FRAG_NONE; } else if (ntoh16(*(uint16 *)(frame + ETHER_TYPE_OFFSET)) >= ETHER_TYPE_MIN) { /* Frame is Ethernet II */ pt = frame + ETHER_TYPE_OFFSET; } else if (length >= ETHER_HDR_LEN + SNAP_HDR_LEN + ETHER_TYPE_LEN && !bcmp(llc_snap_hdr, frame + ETHER_HDR_LEN, SNAP_HDR_LEN)) { pt = frame + ETHER_HDR_LEN + SNAP_HDR_LEN; } else { DHD_INFO(("%s: non-SNAP 802.3 frame\n", __FUNCTION__)); return DHD_PKT_FRAG_NONE; } ethertype = ntoh16(*(uint16 *)pt); /* Skip VLAN tag, if any */ if (ethertype == ETHER_TYPE_8021Q) { pt += VLAN_TAG_LEN; if (pt + ETHER_TYPE_LEN > frame + length) { DHD_INFO(("%s: short VLAN frame (%d)\n", __FUNCTION__, length)); return DHD_PKT_FRAG_NONE; } ethertype = ntoh16(*(uint16 *)pt); } if (ethertype != ETHER_TYPE_IP) { DHD_INFO(("%s: non-IP frame (ethertype 0x%x, length %d)\n", __FUNCTION__, ethertype, length)); return DHD_PKT_FRAG_NONE; } iph = (struct ipv4_hdr *)(pt + ETHER_TYPE_LEN); ipl = (uint)(length - (pt + ETHER_TYPE_LEN - frame)); /* We support IPv4 only */ if ((ipl < IPV4_OPTIONS_OFFSET) || (IP_VER(iph) != IP_VER_4)) { DHD_INFO(("%s: short frame (%d) or non-IPv4\n", __FUNCTION__, ipl)); return DHD_PKT_FRAG_NONE; } iph_frag = ntoh16(iph->frag); if (iph_frag & IPV4_FRAG_DONT) { return DHD_PKT_FRAG_NONE; } else if ((iph_frag & IPV4_FRAG_MORE) == 0) { return DHD_PKT_FRAG_LAST; } else { return (iph_frag & IPV4_FRAG_OFFSET_MASK)? DHD_PKT_FRAG_CONT : DHD_PKT_FRAG_FIRST; } }
unsigned char* bcm_rpc_buf_data(rpc_tp_info_t * rpc_th, rpc_buf_t* b) { return PKTDATA(rpc_th->osh, b); }
void bcm_rpc_tp_rx_from_dnglbus(rpc_tp_info_t *rpc_th, struct lbuf *lb) { void *orig_p, *p; void *rpc_p, *rpc_prev; uint pktlen, tp_len, iter = 0; osl_t *osh; bool dbg_agg; uint dbg_data[16], i; /* must fit host agg limit BCM_RPC_TP_HOST_AGG_MAX_SFRAME+1 */ dbg_agg = FALSE; rpc_th->rx_cnt++; if (rpc_th->rx_pkt == NULL) { RPC_TP_ERR(("%s: no rpc rx fn, dropping\n", __FUNCTION__)); rpc_th->rxdrop_cnt++; lb_free(lb); return; } orig_p = PKTFRMNATIVE(rpc_th->osh, lb); osh = rpc_th->osh; /* take ownership of the dnglbus packet chain * since it will be freed by bcm_rpc_tp_buf_free() */ rpc_th->buf_cnt_inuse += pktsegcnt(rpc_th->osh, orig_p); dbg_data[0] = pktsegcnt(rpc_th->osh, orig_p); pktlen = PKTLEN(osh, orig_p); p = orig_p; /* while we have more data in the TP frame's packet chain, * create a packet chain(could be cloned) for the next RPC frame * then give it away to high layer for process(buffer not freed) */ while (p != NULL) { iter++; /* read TP_HDR(len of rpc frame) and pull the data pointer past the length word */ if (pktlen >= BCM_RPC_TP_ENCAP_LEN) { ASSERT(((uint)PKTDATA(osh, p) & 0x3) == 0); /* ensure aligned word read */ tp_len = ltoh32(*(uint32*)PKTDATA(osh, p)); PKTPULL(osh, p, BCM_RPC_TP_ENCAP_LEN); pktlen -= BCM_RPC_TP_ENCAP_LEN; } else { /* error case: less data than the encapsulation size * treat as an empty tp buffer, at end of current buffer */ tp_len = 0; pktlen = 0; rpc_th->tp_dngl_deagg_cnt_badsflen++; /* bad sf len */ } /* if TP header finished a buffer(rpc header in next chained buffer), open next */ if (pktlen == 0) { void *next_p = PKTNEXT(osh, p); PKTSETNEXT(osh, p, NULL); rpc_th->buf_cnt_inuse--; PKTFREE(osh, p, FALSE); p = next_p; if (p) pktlen = PKTLEN(osh, p); } dbg_data[iter] = tp_len; if (tp_len < pktlen || dbg_agg) { dbg_agg = TRUE; RPC_TP_DEAGG(("DEAGG: [%d] p %p data %p pktlen %d tp_len %d\n", iter, p, PKTDATA(osh, p), pktlen, tp_len)); rpc_th->tp_dngl_deagg_cnt_sf++; rpc_th->tp_dngl_deagg_cnt_bytes += tp_len; } /* empty TP buffer (special case: use tp_len to pad for some USB pktsize bugs) */ if (tp_len == 0) { rpc_th->tp_dngl_deagg_cnt_pass++; continue; } else if (tp_len > 10000 ) { /* something is wrong */ /* print out msgs according to value of p -- in case it is NULL */ if (p != NULL) { RPC_TP_ERR(("DEAGG: iter %d, p(%p data %p pktlen %d)\n", iter, p, PKTDATA(osh, p), PKTLEN(osh, p))); } else { RPC_TP_ERR(("DEAGG: iter %d, p is NULL", iter)); } } /* ========= For this TP subframe, find the end, build a chain, sendup ========= */ /* RPC frame packet chain starts with this packet */ rpc_prev = NULL; rpc_p = p; ASSERT(p != NULL); /* find the last frag in this rpc chain */ while ((tp_len >= pktlen) && p) { if (dbg_agg) RPC_TP_DEAGG(("DEAGG: tp_len %d consumes p(%p pktlen %d)\n", tp_len, p, pktlen)); rpc_prev = p; p = PKTNEXT(osh, p); tp_len -= pktlen; if (p != NULL) { pktlen = PKTLEN(osh, p); } else { if (tp_len != 0) { uint totlen, seg; totlen = pkttotlen(osh, rpc_p); seg = pktsegcnt(rpc_th->osh, rpc_p); RPC_TP_ERR(("DEAGG, toss[%d], orig_p %p segcnt %d", iter, orig_p, dbg_data[0])); RPC_TP_ERR(("DEAGG,rpc_p %p totlen %d pktl %d tp_len %d\n", rpc_p, totlen, pktlen, tp_len)); for (i = 1; i <= iter; i++) RPC_TP_ERR(("tplen[%d] = %d ", i, dbg_data[i])); RPC_TP_ERR(("\n")); p = rpc_p; while (p != NULL) { RPC_TP_ERR(("this seg len %d\n", PKTLEN(osh, p))); p = PKTNEXT(osh, p); } rpc_th->buf_cnt_inuse -= seg; PKTFREE(osh, rpc_p, FALSE); rpc_th->tp_dngl_deagg_cnt_badfmt++; /* big hammer to recover USB * extern void dngl_reboot(void); dngl_reboot(); */ goto end; } pktlen = 0; break; } } /* fix up the last frag */ if (tp_len == 0) { /* if the whole RPC buffer chain ended at the end of the prev TP buffer, * end the RPC buffer chain. we are done */ if (dbg_agg) RPC_TP_DEAGG(("DEAGG: END rpc chain p %p len %d\n\n", rpc_prev, pktlen)); PKTSETNEXT(osh, rpc_prev, NULL); if (iter > 1) { rpc_th->tp_dngl_deagg_cnt_chain++; RPC_TP_DEAGG(("this frag %d totlen %d\n", pktlen, pkttotlen(osh, orig_p))); } } else { /* if pktlen has more bytes than tp_len, another tp frame must follow * create a clone of the sub-range of the current TP buffer covered * by the RPC buffer, attach to the end of the RPC buffer chain * (cut off the original chain link) * continue chain looping(p != NULL) */ void *new_p; ASSERT(p != NULL); RPC_TP_DEAGG(("DEAGG: cloning %d bytes out of p(%p data %p) len %d\n", tp_len, p, PKTDATA(osh, p), pktlen)); new_p = osl_pktclone(osh, p, 0, tp_len); rpc_th->buf_cnt_inuse++; rpc_th->tp_dngl_deagg_cnt_clone++; RPC_TP_DEAGG(("DEAGG: after clone, newp(%p data %p pktlen %d)\n", new_p, PKTDATA(osh, new_p), PKTLEN(osh, new_p))); if (rpc_prev) { RPC_TP_DEAGG(("DEAGG: chaining: %p->%p(clone)\n", rpc_prev, new_p)); PKTSETNEXT(osh, rpc_prev, new_p); } else { RPC_TP_DEAGG(("DEAGG: clone %p is a complete rpc pkt\n", new_p)); rpc_p = new_p; } PKTPULL(osh, p, tp_len); pktlen -= tp_len; RPC_TP_DEAGG(("DEAGG: remainder packet p %p data %p pktlen %d\n", p, PKTDATA(osh, p), PKTLEN(osh, p))); } /* !! send up */ (rpc_th->rx_pkt)(rpc_th->rx_context, rpc_p); } end: ASSERT(p == NULL); }
/* post receive buffers */ void dma_rxfill(dma_info_t *di) { void *p; uint rxin, rxout; uint ctrl; uint n; uint i; uint32 pa; uint rxbufsize; /* * Determine how many receive buffers we're lacking * from the full complement, allocate, initialize, * and post them, then update the chip rx lastdscr. */ rxin = di->rxin; rxout = di->rxout; rxbufsize = di->rxbufsize; n = di->nrxpost - NRXDACTIVE(rxin, rxout); DMA_TRACE(("%s: dma_rxfill: post %d\n", di->name, n)); for (i = 0; i < n; i++) { if ((p = PKTGET(di->drv, rxbufsize, FALSE)) == NULL) { DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", di->name)); di->hnddma.rxnobuf++; break; } /* PR3263 & PR3387 & PR4642 war: rxh.len=0 means dma writes not complete */ *(uint32*)(OSL_UNCACHED(PKTDATA(di->drv, p))) = 0; pa = (uint32) DMA_MAP(di->dev, PKTDATA(di->drv, p), rxbufsize, DMA_RX, p); ASSERT(ISALIGNED(pa, 4)); /* save the free packet pointer */ #if 0 ASSERT(di->rxp[rxout] == NULL); #endif di->rxp[rxout] = p; /* paranoia */ ASSERT(R_SM(&di->rxd[rxout].addr) == 0); /* prep the descriptor control value */ ctrl = rxbufsize; if (rxout == (di->nrxd - 1)) ctrl |= CTRL_EOT; /* init the rx descriptor */ W_SM(&di->rxd[rxout].ctrl, BUS_SWAP32(ctrl)); W_SM(&di->rxd[rxout].addr, BUS_SWAP32(pa + di->dataoffset)); DMA_TRACE(("%s: dma_rxfill: ctrl %08x dataoffset: %08x\n", di->name, BUS_SWAP32(ctrl), BUS_SWAP32(pa + di->dataoffset))); rxout = NEXTRXD(rxout); } di->rxout = rxout; /* update the chip lastdscr pointer */ W_REG(&di->regs->rcvptr, I2B(rxout)); }
bool dhd_tcpack_hold(dhd_pub_t *dhdp, void *pkt, int ifidx) { uint8 *new_ether_hdr; /* Ethernet header of the new packet */ uint16 new_ether_type; /* Ethernet type of the new packet */ uint8 *new_ip_hdr; /* IP header of the new packet */ uint8 *new_tcp_hdr; /* TCP header of the new packet */ uint32 new_ip_hdr_len; /* IP header length of the new packet */ uint32 cur_framelen; uint32 new_tcp_ack_num; /* TCP acknowledge number of the new packet */ uint16 new_ip_total_len; /* Total length of IP packet for the new packet */ uint32 new_tcp_hdr_len; /* TCP header length of the new packet */ tcpack_sup_module_t *tcpack_sup_mod; tcpack_info_t *tcpack_info_tbl; int i, free_slot = TCPACK_INFO_MAXNUM; bool hold = FALSE; unsigned long flags; if (dhdp->tcpack_sup_mode != TCPACK_SUP_HOLD) { goto exit; } if (dhdp->tcpack_sup_ratio == 1) { goto exit; } new_ether_hdr = PKTDATA(dhdp->osh, pkt); cur_framelen = PKTLEN(dhdp->osh, pkt); if (cur_framelen < TCPACKSZMIN || cur_framelen > TCPACKSZMAX) { DHD_TRACE(("%s %d: Too short or long length %d to be TCP ACK\n", __FUNCTION__, __LINE__, cur_framelen)); goto exit; } new_ether_type = new_ether_hdr[12] << 8 | new_ether_hdr[13]; if (new_ether_type != ETHER_TYPE_IP) { DHD_TRACE(("%s %d: Not a IP packet 0x%x\n", __FUNCTION__, __LINE__, new_ether_type)); goto exit; } DHD_TRACE(("%s %d: IP pkt! 0x%x\n", __FUNCTION__, __LINE__, new_ether_type)); new_ip_hdr = new_ether_hdr + ETHER_HDR_LEN; cur_framelen -= ETHER_HDR_LEN; ASSERT(cur_framelen >= IPV4_MIN_HEADER_LEN); new_ip_hdr_len = IPV4_HLEN(new_ip_hdr); if (IP_VER(new_ip_hdr) != IP_VER_4 || IPV4_PROT(new_ip_hdr) != IP_PROT_TCP) { DHD_TRACE(("%s %d: Not IPv4 nor TCP! ip ver %d, prot %d\n", __FUNCTION__, __LINE__, IP_VER(new_ip_hdr), IPV4_PROT(new_ip_hdr))); goto exit; } new_tcp_hdr = new_ip_hdr + new_ip_hdr_len; cur_framelen -= new_ip_hdr_len; ASSERT(cur_framelen >= TCP_MIN_HEADER_LEN); DHD_TRACE(("%s %d: TCP pkt!\n", __FUNCTION__, __LINE__)); /* is it an ack ? Allow only ACK flag, not to suppress others. */ if (new_tcp_hdr[TCP_FLAGS_OFFSET] != TCP_FLAG_ACK) { DHD_TRACE(("%s %d: Do not touch TCP flag 0x%x\n", __FUNCTION__, __LINE__, new_tcp_hdr[TCP_FLAGS_OFFSET])); goto exit; } new_ip_total_len = ntoh16_ua(&new_ip_hdr[IPV4_PKTLEN_OFFSET]); new_tcp_hdr_len = 4 * TCP_HDRLEN(new_tcp_hdr[TCP_HLEN_OFFSET]); /* This packet has TCP data, so just send */ if (new_ip_total_len > new_ip_hdr_len + new_tcp_hdr_len) { DHD_TRACE(("%s %d: Do nothing for TCP DATA\n", __FUNCTION__, __LINE__)); goto exit; } ASSERT(new_ip_total_len == new_ip_hdr_len + new_tcp_hdr_len); new_tcp_ack_num = ntoh32_ua(&new_tcp_hdr[TCP_ACK_NUM_OFFSET]); DHD_TRACE(("%s %d: TCP ACK with zero DATA length" " IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR" TCP port %d %d\n", __FUNCTION__, __LINE__, IPV4_ADDR_TO_STR(ntoh32_ua(&new_ip_hdr[IPV4_SRC_IP_OFFSET])), IPV4_ADDR_TO_STR(ntoh32_ua(&new_ip_hdr[IPV4_DEST_IP_OFFSET])), ntoh16_ua(&new_tcp_hdr[TCP_SRC_PORT_OFFSET]), ntoh16_ua(&new_tcp_hdr[TCP_DEST_PORT_OFFSET]))); /* Look for tcp_ack_info that has the same ip src/dst addrs and tcp src/dst ports */ flags = dhd_os_tcpacklock(dhdp); tcpack_sup_mod = dhdp->tcpack_sup_module; tcpack_info_tbl = tcpack_sup_mod->tcpack_info_tbl; if (!tcpack_sup_mod) { DHD_ERROR(("%s %d: tcpack suppress module NULL!!\n", __FUNCTION__, __LINE__)); dhd_os_tcpackunlock(dhdp, flags); goto exit; } hold = TRUE; for (i = 0; i < TCPACK_INFO_MAXNUM; i++) { void *oldpkt; /* TCPACK packet that is already in txq or DelayQ */ uint8 *old_ether_hdr, *old_ip_hdr, *old_tcp_hdr; uint32 old_ip_hdr_len, old_tcp_hdr_len; uint32 old_tcpack_num; /* TCP ACK number of old TCPACK packet in Q */ if ((oldpkt = tcpack_info_tbl[i].pkt_in_q) == NULL) { if (free_slot == TCPACK_INFO_MAXNUM) { free_slot = i; } continue; } if (PKTDATA(dhdp->osh, oldpkt) == NULL) { DHD_ERROR(("%s %d: oldpkt data NULL!! cur idx %d\n", __FUNCTION__, __LINE__, i)); hold = FALSE; dhd_os_tcpackunlock(dhdp, flags); goto exit; } old_ether_hdr = tcpack_info_tbl[i].pkt_ether_hdr; old_ip_hdr = old_ether_hdr + ETHER_HDR_LEN; old_ip_hdr_len = IPV4_HLEN(old_ip_hdr); old_tcp_hdr = old_ip_hdr + old_ip_hdr_len; old_tcp_hdr_len = 4 * TCP_HDRLEN(old_tcp_hdr[TCP_HLEN_OFFSET]); DHD_TRACE(("%s %d: oldpkt %p[%d], IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR " TCP port %d %d\n", __FUNCTION__, __LINE__, oldpkt, i, IPV4_ADDR_TO_STR(ntoh32_ua(&old_ip_hdr[IPV4_SRC_IP_OFFSET])), IPV4_ADDR_TO_STR(ntoh32_ua(&old_ip_hdr[IPV4_DEST_IP_OFFSET])), ntoh16_ua(&old_tcp_hdr[TCP_SRC_PORT_OFFSET]), ntoh16_ua(&old_tcp_hdr[TCP_DEST_PORT_OFFSET]))); /* If either of IP address or TCP port number does not match, skip. */ if (memcmp(&new_ip_hdr[IPV4_SRC_IP_OFFSET], &old_ip_hdr[IPV4_SRC_IP_OFFSET], IPV4_ADDR_LEN * 2) || memcmp(&new_tcp_hdr[TCP_SRC_PORT_OFFSET], &old_tcp_hdr[TCP_SRC_PORT_OFFSET], TCP_PORT_LEN * 2)) { continue; } old_tcpack_num = ntoh32_ua(&old_tcp_hdr[TCP_ACK_NUM_OFFSET]); if (IS_TCPSEQ_GE(new_tcp_ack_num, old_tcpack_num)) { tcpack_info_tbl[i].supp_cnt++; if (tcpack_info_tbl[i].supp_cnt >= dhdp->tcpack_sup_ratio) { tcpack_info_tbl[i].pkt_in_q = NULL; tcpack_info_tbl[i].pkt_ether_hdr = NULL; tcpack_info_tbl[i].ifidx = 0; tcpack_info_tbl[i].supp_cnt = 0; hold = FALSE; } else { tcpack_info_tbl[i].pkt_in_q = pkt; tcpack_info_tbl[i].pkt_ether_hdr = new_ether_hdr; tcpack_info_tbl[i].ifidx = ifidx; } PKTFREE(dhdp->osh, oldpkt, TRUE); } else { PKTFREE(dhdp->osh, pkt, TRUE); } dhd_os_tcpackunlock(dhdp, flags); if (!hold) { del_timer_sync(&tcpack_info_tbl[i].timer); } goto exit; } if (free_slot < TCPACK_INFO_MAXNUM) { /* No TCPACK packet with the same IP addr and TCP port is found * in tcp_ack_info_tbl. So add this packet to the table. */ DHD_TRACE(("%s %d: Add pkt 0x%p(ether_hdr 0x%p) to tbl[%d]\n", __FUNCTION__, __LINE__, pkt, new_ether_hdr, free_slot)); tcpack_info_tbl[free_slot].pkt_in_q = pkt; tcpack_info_tbl[free_slot].pkt_ether_hdr = new_ether_hdr; tcpack_info_tbl[free_slot].ifidx = ifidx; tcpack_info_tbl[free_slot].supp_cnt = 1; mod_timer(&tcpack_sup_mod->tcpack_info_tbl[free_slot].timer, jiffies + msecs_to_jiffies(dhdp->tcpack_sup_delay)); tcpack_sup_mod->tcpack_info_cnt++; } else { DHD_TRACE(("%s %d: No empty tcp ack info tbl\n", __FUNCTION__, __LINE__)); } dhd_os_tcpackunlock(dhdp, flags); exit: return hold; }
bool dhd_tcpack_suppress(dhd_pub_t *dhdp, void *pkt) { uint8 *new_ether_hdr; /* Ethernet header of the new packet */ uint16 new_ether_type; /* Ethernet type of the new packet */ uint8 *new_ip_hdr; /* IP header of the new packet */ uint8 *new_tcp_hdr; /* TCP header of the new packet */ uint32 new_ip_hdr_len; /* IP header length of the new packet */ uint32 cur_framelen; #if defined(DHD_DEBUG) uint32 new_tcp_seq_num; /* TCP sequence number of the new packet */ #endif uint32 new_tcp_ack_num; /* TCP acknowledge number of the new packet */ uint16 new_ip_total_len; /* Total length of IP packet for the new packet */ uint32 new_tcp_hdr_len; /* TCP header length of the new packet */ int i; bool ret = FALSE; if (!dhdp->tcpack_sup_enabled) goto exit; new_ether_hdr = PKTDATA(dhdp->osh, pkt); cur_framelen = PKTLEN(dhdp->osh, pkt); if (cur_framelen < TCPACKSZMIN || cur_framelen > TCPACKSZMAX) { DHD_TRACE(("%s %d: Too short or long length %d to be TCP ACK\n", __FUNCTION__, __LINE__, cur_framelen)); goto exit; } new_ether_type = new_ether_hdr[12] << 8 | new_ether_hdr[13]; if (new_ether_type != ETHER_TYPE_IP) { DHD_TRACE(("%s %d: Not a IP packet 0x%x\n", __FUNCTION__, __LINE__, new_ether_type)); goto exit; } DHD_TRACE(("%s %d: IP pkt! 0x%x\n", __FUNCTION__, __LINE__, new_ether_type)); new_ip_hdr = new_ether_hdr + ETHER_HDR_LEN; cur_framelen -= ETHER_HDR_LEN; ASSERT(cur_framelen >= IPV4_MIN_HEADER_LEN); new_ip_hdr_len = IPV4_HLEN(new_ip_hdr); if (IP_VER(new_ip_hdr) != IP_VER_4 || IPV4_PROT(new_ip_hdr) != IP_PROT_TCP) { DHD_TRACE(("%s %d: Not IPv4 nor TCP! ip ver %d, prot %d\n", __FUNCTION__, __LINE__, IP_VER(new_ip_hdr), IPV4_PROT(new_ip_hdr))); goto exit; } new_tcp_hdr = new_ip_hdr + new_ip_hdr_len; cur_framelen -= new_ip_hdr_len; ASSERT(cur_framelen >= TCP_MIN_HEADER_LEN); DHD_TRACE(("%s %d: TCP pkt!\n", __FUNCTION__, __LINE__)); /* is it an ack ? Allow only ACK flag, not to suppress others. */ if (new_tcp_hdr[TCP_FLAGS_OFFSET] != TCP_FLAG_ACK) { DHD_TRACE(("%s %d: Do not touch TCP flag 0x%x\n", __FUNCTION__, __LINE__, new_tcp_hdr[TCP_FLAGS_OFFSET])); goto exit; } new_ip_total_len = ntoh16_ua(&new_ip_hdr[IPV4_PKTLEN_OFFSET]); new_tcp_hdr_len = 4 * TCP_HDRLEN(new_tcp_hdr[TCP_HLEN_OFFSET]); /* This packet has TCP data, so just send */ if (new_ip_total_len > new_ip_hdr_len + new_tcp_hdr_len) { DHD_TRACE(("%s %d: Do nothing for TCP DATA\n", __FUNCTION__, __LINE__)); goto exit; } ASSERT(new_ip_total_len == new_ip_hdr_len + new_tcp_hdr_len); new_tcp_ack_num = ntoh32_ua(&new_tcp_hdr[TCP_ACK_NUM_OFFSET]); #if defined(DHD_DEBUG) new_tcp_seq_num = ntoh32_ua(&new_tcp_hdr[TCP_SEQ_NUM_OFFSET]); DHD_TRACE(("%s %d: TCP ACK seq %u ack %u\n", __FUNCTION__, __LINE__, new_tcp_seq_num, new_tcp_ack_num)); #endif DHD_TRACE(("%s %d: TCP ACK with zero DATA length" " IP addr "IPv4_ADDR_STR" "IPv4_ADDR_STR" TCP port %d %d\n", __FUNCTION__, __LINE__, IPv4_ADDR_TO_STR(ntoh32_ua(&new_ip_hdr[IPV4_SRC_IP_OFFSET])), IPv4_ADDR_TO_STR(ntoh32_ua(&new_ip_hdr[IPV4_DEST_IP_OFFSET])), ntoh16_ua(&new_tcp_hdr[TCP_SRC_PORT_OFFSET]), ntoh16_ua(&new_tcp_hdr[TCP_DEST_PORT_OFFSET]))); /* Look for tcp_ack_info that has the same ip src/dst addrs and tcp src/dst ports */ dhd_os_tcpacklock(dhdp); for (i = 0; i < dhdp->tcp_ack_info_cnt; i++) { void *oldpkt; /* TCPACK packet that is already in txq or DelayQ */ uint8 *old_ether_hdr, *old_ip_hdr, *old_tcp_hdr; uint32 old_ip_hdr_len, old_tcp_hdr_len; uint32 old_tcpack_num; /* TCP ACK number of old TCPACK packet in Q */ if ((oldpkt = dhdp->tcp_ack_info_tbl[i].pkt_in_q) == NULL) { DHD_ERROR(("%s %d: Unexpected error!! cur idx %d, ttl cnt %d\n", __FUNCTION__, __LINE__, i, dhdp->tcp_ack_info_cnt)); break; } if (PKTDATA(dhdp->osh, oldpkt) == NULL) { DHD_ERROR(("%s %d: oldpkt data NULL!! cur idx %d, ttl cnt %d\n", __FUNCTION__, __LINE__, i, dhdp->tcp_ack_info_cnt)); break; } old_ether_hdr = dhdp->tcp_ack_info_tbl[i].pkt_ether_hdr; old_ip_hdr = old_ether_hdr + ETHER_HDR_LEN; old_ip_hdr_len = IPV4_HLEN(old_ip_hdr); old_tcp_hdr = old_ip_hdr + old_ip_hdr_len; old_tcp_hdr_len = 4 * TCP_HDRLEN(old_tcp_hdr[TCP_HLEN_OFFSET]); DHD_TRACE(("%s %d: oldpkt %p[%d], IP addr "IPv4_ADDR_STR" "IPv4_ADDR_STR " TCP port %d %d\n", __FUNCTION__, __LINE__, oldpkt, i, IPv4_ADDR_TO_STR(ntoh32_ua(&old_ip_hdr[IPV4_SRC_IP_OFFSET])), IPv4_ADDR_TO_STR(ntoh32_ua(&old_ip_hdr[IPV4_DEST_IP_OFFSET])), ntoh16_ua(&old_tcp_hdr[TCP_SRC_PORT_OFFSET]), ntoh16_ua(&old_tcp_hdr[TCP_DEST_PORT_OFFSET]))); /* If either of IP address or TCP port number does not match, skip. */ if (memcmp(&new_ip_hdr[IPV4_SRC_IP_OFFSET], &old_ip_hdr[IPV4_SRC_IP_OFFSET], IPV4_ADDR_LEN * 2) || memcmp(&new_tcp_hdr[TCP_SRC_PORT_OFFSET], &old_tcp_hdr[TCP_SRC_PORT_OFFSET], TCP_PORT_LEN * 2)) continue; old_tcpack_num = ntoh32_ua(&old_tcp_hdr[TCP_ACK_NUM_OFFSET]); if (new_tcp_ack_num > old_tcpack_num) { /* New packet has higher TCP ACK number, so it replaces the old packet */ if (new_ip_hdr_len == old_ip_hdr_len && new_tcp_hdr_len == old_tcp_hdr_len) { ASSERT(memcmp(new_ether_hdr, old_ether_hdr, ETHER_HDR_LEN) == 0); bcopy(new_ip_hdr, old_ip_hdr, new_ip_total_len); PKTFREE(dhdp->osh, pkt, FALSE); DHD_TRACE(("%s %d: TCP ACK replace %u -> %u\n", __FUNCTION__, __LINE__, old_tcpack_num, new_tcp_ack_num)); ret = TRUE; } else DHD_TRACE(("%s %d: lenth mismatch %d != %d || %d != %d\n", __FUNCTION__, __LINE__, new_ip_hdr_len, old_ip_hdr_len, new_tcp_hdr_len, old_tcp_hdr_len)); } else { DHD_TRACE(("%s %d: ACK number reverse old %u(0x%p) new %u(0x%p)\n", __FUNCTION__, __LINE__, old_tcpack_num, oldpkt, new_tcp_ack_num, pkt)); #ifdef TCPACK_TEST if (new_ip_hdr_len == old_ip_hdr_len && new_tcp_hdr_len == old_tcp_hdr_len) { PKTFREE(dhdp->osh, pkt, FALSE); ret = TRUE; } #endif } dhd_os_tcpackunlock(dhdp); goto exit; } if (i == dhdp->tcp_ack_info_cnt && i < MAXTCPSTREAMS) { /* No TCPACK packet with the same IP addr and TCP port is found * in tcp_ack_info_tbl. So add this packet to the table. */ DHD_TRACE(("%s %d: Add pkt 0x%p(ether_hdr 0x%p) to tbl[%d]\n", __FUNCTION__, __LINE__, pkt, new_ether_hdr, dhdp->tcp_ack_info_cnt)); dhdp->tcp_ack_info_tbl[dhdp->tcp_ack_info_cnt].pkt_in_q = pkt; dhdp->tcp_ack_info_tbl[dhdp->tcp_ack_info_cnt].pkt_ether_hdr = new_ether_hdr; dhdp->tcp_ack_info_cnt++; } else { ASSERT(i == dhdp->tcp_ack_info_cnt); DHD_TRACE(("%s %d: No empty tcp ack info tbl\n", __FUNCTION__, __LINE__)); } dhd_os_tcpackunlock(dhdp); exit: return ret; }