OSDN Git Service

Remove duplicate copy of if_ether.h and use the kernel provided one
[android-x86/external-modules-rtl8723au.git] / os_dep / xmit_linux.c
index e39d0a3..fe263b1 100644 (file)
@@ -23,7 +23,7 @@
 #include <osdep_service.h>
 #include <drv_types.h>
 
-#include <if_ether.h>
+#include <linux/if_ether.h>
 #include <ip.h>
 #include <wifi.h>
 #include <mlme_osdep.h>
@@ -33,7 +33,7 @@
 
 uint rtw_remainder_len(struct pkt_file *pfile)
 {
-       return (pfile->buf_len - ((SIZE_PTR)(pfile->cur_addr) - (SIZE_PTR)(pfile->buf_start)));
+       return (pfile->buf_len - ((unsigned long)(pfile->cur_addr) - (unsigned long)(pfile->buf_start)));
 }
 
 void _rtw_open_pktfile (_pkt *pktptr, struct pkt_file *pfile)
@@ -69,7 +69,7 @@ _func_exit_;
        return len;
 }
 
-sint rtw_endofpktfile(struct pkt_file *pfile)
+int rtw_endofpktfile(struct pkt_file *pfile)
 {
 _func_enter_;
 
@@ -124,7 +124,6 @@ void rtw_set_tx_chksum_offload(_pkt *pkt, struct pkt_attrib *pattrib)
 
 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;
@@ -136,13 +135,12 @@ int rtw_os_xmit_resource_alloc(_adapter *padapter, struct xmit_buf *pxmitbuf,u32
                return _FAIL;
 #else // CONFIG_USE_USB_BUFFER_ALLOC_TX
 
-       pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
-       if (pxmitbuf->pallocated_buf == NULL)
-       {
+       pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL);
+       if (pxmitbuf->pallocated_buf == NULL) {
                return _FAIL;
        }
 
-       pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
+       pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ);
        pxmitbuf->dma_transfer_addr = 0;
 
 #endif // CONFIG_USE_USB_BUFFER_ALLOC_TX
@@ -157,28 +155,15 @@ int rtw_os_xmit_resource_alloc(_adapter *padapter, struct xmit_buf *pxmitbuf,u32
                }
 
        }
-#endif
-#if defined(CONFIG_PCI_HCI) || defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_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;
 }
 
 void rtw_os_xmit_resource_free(_adapter *padapter, struct xmit_buf *pxmitbuf,u32 free_sz)
 {
-#ifdef CONFIG_USB_HCI
        int i;
        struct dvobj_priv       *pdvobjpriv = adapter_to_dvobj(padapter);
        struct usb_device       *pusbd = pdvobjpriv->pusbdev;
 
-
        for(i=0; i<8; i++)
        {
                if(pxmitbuf->pxmit_urb[i])
@@ -194,14 +179,9 @@ void rtw_os_xmit_resource_free(_adapter *padapter, struct xmit_buf *pxmitbuf,u32
        pxmitbuf->dma_transfer_addr = 0;
 #else  // CONFIG_USE_USB_BUFFER_ALLOC_TX
        if(pxmitbuf->pallocated_buf)
-               rtw_mfree(pxmitbuf->pallocated_buf, free_sz);
+               kfree(pxmitbuf->pallocated_buf);
 #endif // CONFIG_USE_USB_BUFFER_ALLOC_TX
 
-#endif
-#if defined(CONFIG_PCI_HCI) || defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
-       if(pxmitbuf->pallocated_buf)
-               rtw_mfree(pxmitbuf->pallocated_buf, free_sz);
-#endif
 }
 
 #define WMM_XMIT_THRESHOLD     (NR_XMITFRAME*2/5)
@@ -248,21 +228,6 @@ void rtw_os_xmit_complete(_adapter *padapter, struct xmit_frame *pxframe)
 void rtw_os_xmit_schedule(_adapter *padapter)
 {
        _adapter *pri_adapter = padapter;
-
-#if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
-       if(!padapter)
-               return;
-
-#ifdef CONFIG_CONCURRENT_MODE
-       if(padapter->adapter_type > PRIMARY_ADAPTER)
-               pri_adapter = padapter->pbuddy_adapter;
-#endif
-
-       if (_rtw_queue_empty(&pri_adapter->xmitpriv.pending_xmitbuf_queue) == _FALSE)
-               _rtw_up_sema(&pri_adapter->xmitpriv.xmit_sema);
-
-
-#else
        _irqL  irqL;
        struct xmit_priv *pxmitpriv;
 
@@ -271,15 +236,14 @@ void rtw_os_xmit_schedule(_adapter *padapter)
 
        pxmitpriv = &padapter->xmitpriv;
 
-       _enter_critical_bh(&pxmitpriv->lock, &irqL);
+       spin_lock_bh(&pxmitpriv->lock);
 
        if(rtw_txframes_pending(padapter))
        {
                tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
        }
 
-       _exit_critical_bh(&pxmitpriv->lock, &irqL);
-#endif
+       spin_unlock_bh(&pxmitpriv->lock);
 }
 
 static void rtw_check_xmit_resource(_adapter *padapter, _pkt *pkt)
@@ -327,7 +291,7 @@ int rtw_mlcst2unicst(_adapter *padapter, struct sk_buff *skb)
        int i;
        s32     res;
 
-       _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL);
+       spin_lock_bh(&pstapriv->asoc_list_lock);
        phead = &pstapriv->asoc_list;
        plist = get_next(phead);
 
@@ -342,7 +306,7 @@ int rtw_mlcst2unicst(_adapter *padapter, struct sk_buff *skb)
                        chk_alive_list[chk_alive_num++] = stainfo_offset;
                }
        }
-       _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL);
+       spin_unlock_bh(&pstapriv->asoc_list_lock);
 
        for (i = 0; i < chk_alive_num; i++) {
                psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
@@ -350,16 +314,15 @@ int rtw_mlcst2unicst(_adapter *padapter, struct sk_buff *skb)
                        continue;
 
                /* avoid come from STA1 and send back STA1 */
-               if (_rtw_memcmp(psta->hwaddr, &skb->data[6], 6) == _TRUE
-                       || _rtw_memcmp(psta->hwaddr, null_addr, 6) == _TRUE
-                       || _rtw_memcmp(psta->hwaddr, bc_addr, 6) == _TRUE
-               )
+               if (!memcmp(psta->hwaddr, &skb->data[6], 6) ||
+                   !memcmp(psta->hwaddr, null_addr, 6) ||
+                   !memcmp(psta->hwaddr, bc_addr, 6))
                        continue;
 
                newskb = skb_copy(skb, GFP_ATOMIC);
 
                if (newskb) {
-                       _rtw_memcpy(newskb->data, psta->hwaddr, 6);
+                       memcpy(newskb->data, psta->hwaddr, 6);
                        res = rtw_xmit(padapter, &newskb);
                        if (res < 0) {
                                DBG_8723A("%s()-%d: rtw_xmit() return error!\n", __FUNCTION__, __LINE__);