//alloc os related resource in struct recv_buf int rtw_os_recvbuf_resource_alloc(_adapter *padapter, struct recv_buf *precvbuf) { int res=_SUCCESS; #ifdef CONFIG_USB_HCI struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); struct usb_device *pusbd = pdvobjpriv->pusbdev; precvbuf->irp_pending = _FALSE; precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); if(precvbuf->purb == NULL){ res = _FAIL; } precvbuf->pskb = NULL; precvbuf->pallocated_buf = precvbuf->pbuf = NULL; precvbuf->pdata = precvbuf->phead = precvbuf->ptail = precvbuf->pend = NULL; precvbuf->transfer_len = 0; precvbuf->len = 0; #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX precvbuf->pallocated_buf = rtw_usb_buffer_alloc(pusbd, (size_t)precvbuf->alloc_sz, &precvbuf->dma_transfer_addr); precvbuf->pbuf = precvbuf->pallocated_buf; if(precvbuf->pallocated_buf == NULL) return _FAIL; #endif //CONFIG_USE_USB_BUFFER_ALLOC_RX #endif //CONFIG_USB_HCI return res; }
int rtw_os_xmit_resource_alloc(_adapter *padapter, struct xmit_buf *pxmitbuf,u32 alloc_sz) { #ifdef CONFIG_USB_HCI int i; struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); struct usb_device *pusbd = pdvobjpriv->pusbdev; #ifdef CONFIG_USE_USB_BUFFER_ALLOC_TX pxmitbuf->pallocated_buf = rtw_usb_buffer_alloc(pusbd, (size_t)alloc_sz, &pxmitbuf->dma_transfer_addr); pxmitbuf->pbuf = pxmitbuf->pallocated_buf; if(pxmitbuf->pallocated_buf == NULL) return _FAIL; #else // CONFIG_USE_USB_BUFFER_ALLOC_TX pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz); if (pxmitbuf->pallocated_buf == NULL) { return _FAIL; } pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ); pxmitbuf->dma_transfer_addr = 0; #endif // CONFIG_USE_USB_BUFFER_ALLOC_TX for(i=0; i<8; i++) { pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); if(pxmitbuf->pxmit_urb[i] == NULL) { DBG_871X("pxmitbuf->pxmit_urb[i]==NULL"); return _FAIL; } } #endif #if defined(CONFIG_PCI_HCI) || defined(CONFIG_SDIO_HCI) pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz); if (pxmitbuf->pallocated_buf == NULL) { return _FAIL; } pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ); #endif return _SUCCESS; }
int rtw_os_xmit_resource_alloc(_adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz, u8 flag) { if (alloc_sz > 0) { #ifdef CONFIG_USE_USB_BUFFER_ALLOC_TX struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); struct usb_device *pusbd = pdvobjpriv->pusbdev; pxmitbuf->pallocated_buf = rtw_usb_buffer_alloc(pusbd, (size_t)alloc_sz, &pxmitbuf->dma_transfer_addr); pxmitbuf->pbuf = pxmitbuf->pallocated_buf; if (pxmitbuf->pallocated_buf == NULL) return _FAIL; #else /* CONFIG_USE_USB_BUFFER_ALLOC_TX */ pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz); if (pxmitbuf->pallocated_buf == NULL) return _FAIL; pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ); #endif /* CONFIG_USE_USB_BUFFER_ALLOC_TX */ } if (flag) { #ifdef CONFIG_USB_HCI int i; for (i = 0; i < 8; i++) { pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); if (pxmitbuf->pxmit_urb[i] == NULL) { RTW_INFO("pxmitbuf->pxmit_urb[i]==NULL"); return _FAIL; } } #endif } return _SUCCESS; }