/* * FUNCTION: Allocate a packet buffer for DMA * ARGUMENTS: * AdapterHandle: AdapterHandle * Length: Number of bytes to allocate * Cached: Whether or not the memory can be cached * VirtualAddress: Pointer to memory is returned here * PhysicalAddress: Physical address corresponding to virtual address * Notes: * Cached is ignored: always cached memory */ PNDIS_PACKET RTMP_AllocateRxPacketBuffer( IN VOID *pReserved, IN VOID *pPciDev, IN ULONG Length, IN BOOLEAN Cached, OUT PVOID *VirtualAddress, OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress) { struct sk_buff *pkt; /* pkt = dev_alloc_skb(Length); */ DEV_ALLOC_SKB(pReserved, pkt, Length); if (pkt == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("can't allocate rx %ld size packet\n",Length)); } if (pkt) { RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS); *VirtualAddress = (PVOID) pkt->data; /*#ifdef CONFIG_5VT_ENHANCE */ /* *PhysicalAddress = PCI_MAP_SINGLE(pAd, *VirtualAddress, 1600, RTMP_PCI_DMA_FROMDEVICE); */ /*#else */ *PhysicalAddress = PCI_MAP_SINGLE_DEV(pPciDev, *VirtualAddress, Length, -1, RTMP_PCI_DMA_FROMDEVICE); /*#endif */ } else { *VirtualAddress = (PVOID) NULL; *PhysicalAddress = (NDIS_PHYSICAL_ADDRESS) 0; } return (PNDIS_PACKET) pkt; }
__IMEM #endif PNDIS_PACKET RTMP_AllocateRxPacketBuffer( IN VOID *pReserved, IN VOID *pPciDev, IN ULONG Length, IN BOOLEAN Cached, OUT PVOID *VirtualAddress, OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress) { struct sk_buff *pkt; /* pkt = dev_alloc_skb(Length); */ #ifdef BB_SOC pkt = skbmgr_dev_alloc_skb4k(); #else DEV_ALLOC_SKB(pReserved, pkt, Length); #endif if (pkt == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("can't allocate rx %ld size packet\n",Length)); } if (pkt) { *VirtualAddress = (PVOID) pkt->data; *PhysicalAddress = PCI_MAP_SINGLE_DEV(pPciDev, *VirtualAddress, Length, -1, RTMP_PCI_DMA_FROMDEVICE); } else { *VirtualAddress = (PVOID) NULL; *PhysicalAddress = (NDIS_PHYSICAL_ADDRESS) 0; } return (PNDIS_PACKET) pkt; }
PNDIS_PACKET RTMP_AllocateRxPacketBuffer( IN PRTMP_ADAPTER pAd, IN ULONG Length, IN BOOLEAN Cached, OUT PVOID *VirtualAddress, OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress) { PNDIS_PACKET pkt; pkt = RTPKT_TO_OSPKT(DEV_ALLOC_SKB(Length)); if (pkt == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("can't allocate rx %ld size packet\n",Length)); } if (pkt) { RTMP_SET_PACKET_SOURCE(pkt, PKTSRC_NDIS); *VirtualAddress = (PVOID) RTPKT_TO_OSPKT(pkt)->data; *PhysicalAddress = PCI_MAP_SINGLE(pAd, *VirtualAddress, Length, -1, PCI_DMA_FROMDEVICE); } else { *VirtualAddress = (PVOID) NULL; *PhysicalAddress = (NDIS_PHYSICAL_ADDRESS) NULL; } return (PNDIS_PACKET) pkt; }
__IMEM #endif PNDIS_PACKET RTMP_AllocateRxPacketBuffer( IN VOID *pReserved, IN VOID *pPciDev, IN ULONG Length, IN BOOLEAN Cached, OUT VOID **VirtualAddress, OUT PNDIS_PHYSICAL_ADDRESS phy_addr) { struct sk_buff *pkt; #ifdef BB_SOC pkt = skbmgr_dev_alloc_skb4k(); #else /* pkt = dev_alloc_skb(Length); */ DEV_ALLOC_SKB(pReserved, pkt, Length); #endif if (pkt == NULL) { MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR, ("can't allocate rx %ld size packet\n",Length)); } if (pkt) { *VirtualAddress = (PVOID) pkt->data; *phy_addr = PCI_MAP_SINGLE_DEV(pPciDev, *VirtualAddress, Length, -1, RTMP_PCI_DMA_FROMDEVICE); //if (DMA_MAPPING_ERROR(pPciDev, *phy_addr)) //{ // MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR, ("%s: dma mapping error\n", __FUNCTION__)); //} } else { *VirtualAddress = (PVOID) NULL; *phy_addr = (NDIS_PHYSICAL_ADDRESS) 0; } return (PNDIS_PACKET) pkt; }