Merge tag 'spi-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc
[cascardo/linux.git] / drivers / staging / csr / unifi_sme.c
index 6e7cbbf..ff639d4 100644 (file)
@@ -78,12 +78,6 @@ sme_log_event(ul_client_t *pcli,
     CsrResult result = CSR_RESULT_SUCCESS;
     int r;
 
-    /* Following bits are encoded in hostTag These are there to ensure that hostTags are unique*/
-#define CSR_SME_DATA     0x00000000  /* Frames Sent by SME */
-#define CSR_PAL_DATA     0X10000000  /* Frames Sent by PAL-D*/
-#define CSR_NME_DATA     0x20000000  /* Frames Sent by NME*/
-#define APPLICATION_DATA 0x30000000  /* Frames Sent by Application*/
-
     func_enter();
     /* Just a sanity check */
     if ((signal == NULL) || (signal_len <= 0)) {
@@ -120,15 +114,15 @@ sme_log_event(ul_client_t *pcli,
         }
         if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_INDICATION_ID)
         {
-            CsrUint16 frmCtrl;
-            CsrBool unicastPdu = TRUE;
-            CsrUint8 *macHdrLocation;
-            CsrUint8 *raddr = NULL, *taddr = NULL;
+            u16 frmCtrl;
+            u8 unicastPdu = TRUE;
+            u8 *macHdrLocation;
+            u8 *raddr = NULL, *taddr = NULL;
             CsrWifiMacAddress peerMacAddress;
             /* Check if we need to send CsrWifiRouterCtrlMicFailureInd*/
             CSR_MA_PACKET_INDICATION *ind = &unpacked_signal.u.MaPacketIndication;
 
-            macHdrLocation = (CsrUint8 *) bulkdata->d[0].os_data_ptr;
+            macHdrLocation = (u8 *) bulkdata->d[0].os_data_ptr;
             /* Fetch the frame control value from  mac header */
             frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
 
@@ -136,7 +130,7 @@ sme_log_event(ul_client_t *pcli,
             raddr = macHdrLocation + MAC_HEADER_ADDR1_OFFSET;
             taddr = macHdrLocation + MAC_HEADER_ADDR2_OFFSET;
 
-            CsrMemCpy(peerMacAddress.a, taddr, ETH_ALEN);
+            memcpy(peerMacAddress.a, taddr, ETH_ALEN);
 
             if(ind->ReceptionStatus == CSR_MICHAEL_MIC_ERROR)
             {
@@ -152,8 +146,8 @@ sme_log_event(ul_client_t *pcli,
             {
                 if(ind->ReceptionStatus == CSR_RX_SUCCESS)
                 {
-                    CsrUint8 pmBit = (frmCtrl & 0x1000)?0x01:0x00;
-                    CsrUint16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0xff);
+                    u8 pmBit = (frmCtrl & 0x1000)?0x01:0x00;
+                    u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0xff);
                     CsrWifiRouterCtrlStaInfo_t *srcStaInfo =  CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,taddr,interfaceTag);
                     if((srcStaInfo != NULL) && (uf_check_broadcast_bssid(priv, bulkdata)== FALSE))
                     {
@@ -169,7 +163,7 @@ sme_log_event(ul_client_t *pcli,
         if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_CONFIRM_ID)
         {
             CSR_MA_PACKET_CONFIRM *cfm = &unpacked_signal.u.MaPacketConfirm;
-            CsrUint16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
+            u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
             netInterface_priv_t *interfacePriv;
             CSR_MA_PACKET_REQUEST *req;
             CsrWifiMacAddress peerMacAddress;
@@ -218,7 +212,7 @@ sme_log_event(ul_client_t *pcli,
 #endif
                 /* If EAPOL was requested via router APIs then send cfm else ignore*/
                 if((cfm->HostTag & 0x80000000) != CSR_WIFI_EAPOL_M4_HOST_TAG) {
-                    CsrWifiRouterMaPacketCfmSend((CsrUint16)signal[2],
+                    CsrWifiRouterMaPacketCfmSend((u16)signal[2],
                         cfm->VirtualInterfaceIdentifier,
                         result,
                         (cfm->HostTag & 0x3fffffff), cfm->Rate);
@@ -232,11 +226,11 @@ sme_log_event(ul_client_t *pcli,
     }
 
     mlmeCommand.length = signal_len;
-    mlmeCommand.data = (CsrUint8*)signal;
+    mlmeCommand.data = (u8*)signal;
 
     dataref1.length = bulkdata->d[0].data_length;
     if (dataref1.length > 0) {
-        dataref1.data = (CsrUint8 *) bulkdata->d[0].os_data_ptr;
+        dataref1.data = (u8 *) bulkdata->d[0].os_data_ptr;
     } else
     {
         dataref1.data = NULL;
@@ -244,7 +238,7 @@ sme_log_event(ul_client_t *pcli,
 
     dataref2.length = bulkdata->d[1].data_length;
     if (dataref2.length > 0) {
-        dataref2.data = (CsrUint8 *) bulkdata->d[1].os_data_ptr;
+        dataref2.data = (u8 *) bulkdata->d[1].os_data_ptr;
     } else
     {
         dataref2.data = NULL;
@@ -274,7 +268,7 @@ sme_log_event(ul_client_t *pcli,
  * ---------------------------------------------------------------------------
  */
 CsrWifiRouterCtrlPortAction
-uf_sme_port_state(unifi_priv_t *priv, unsigned char *address, int queue, CsrUint16 interfaceTag)
+uf_sme_port_state(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
 {
     int i;
     unifi_port_config_t *port;
@@ -338,7 +332,7 @@ uf_sme_port_state(unifi_priv_t *priv, unsigned char *address, int queue, CsrUint
  * ---------------------------------------------------------------------------
  */
 unifi_port_cfg_t*
-uf_sme_port_config_handle(unifi_priv_t *priv, unsigned char *address, int queue, CsrUint16 interfaceTag)
+uf_sme_port_config_handle(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
 {
     int i;
     unifi_port_config_t *port;
@@ -393,7 +387,7 @@ uf_multicast_list_wq(struct work_struct *work)
     unifi_priv_t *priv = container_of(work, unifi_priv_t,
             multicast_list_task);
     int i;
-    CsrUint16 interfaceTag = 0;
+    u16 interfaceTag = 0;
     CsrWifiMacAddress* multicast_address_list = NULL;
     int mc_count;
     u8 *mc_list;
@@ -417,7 +411,7 @@ uf_multicast_list_wq(struct work_struct *work)
      * Allocate a new list, need to free it later
      * in unifi_mgt_multicast_address_cfm().
      */
-    multicast_address_list = CsrPmemAlloc(mc_count * sizeof(CsrWifiMacAddress));
+    multicast_address_list = kmalloc(mc_count * sizeof(CsrWifiMacAddress), GFP_KERNEL);
 
     if (multicast_address_list == NULL) {
         return;
@@ -429,7 +423,7 @@ uf_multicast_list_wq(struct work_struct *work)
     }
 
     if (priv->smepriv == NULL) {
-        CsrPmemFree(multicast_address_list);
+        kfree(multicast_address_list);
         return;
     }
 
@@ -439,7 +433,7 @@ uf_multicast_list_wq(struct work_struct *work)
             mc_count, multicast_address_list);
 
     /* The SME will take a copy of the addreses*/
-    CsrPmemFree(multicast_address_list);
+    kfree(multicast_address_list);
 }
 
 
@@ -578,7 +572,7 @@ int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg)
 
     /* Free any TCLASs previously allocated */
     if (priv->packet_filters.tclas_ies_length) {
-        CsrPmemFree(priv->filter_tclas_ies);
+        kfree(priv->filter_tclas_ies);
         priv->filter_tclas_ies = NULL;
     }
 
@@ -596,7 +590,7 @@ int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg)
         priv->packet_filters.tclas_ies_length += sizeof(tclas_t);
     }
     if (priv->packet_filters.tclas_ies_length > 0) {
-        priv->filter_tclas_ies = CsrPmemAlloc(priv->packet_filters.tclas_ies_length);
+        priv->filter_tclas_ies = kmalloc(priv->packet_filters.tclas_ies_length, GFP_KERNEL);
         if (priv->filter_tclas_ies == NULL) {
             return -ENOMEM;
         }
@@ -621,10 +615,10 @@ int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg)
         dhcp_tclas->user_priority = 0;
         dhcp_tclas->tcp_ip_cls_fr.cls_fr_type = 1;
         dhcp_tclas->tcp_ip_cls_fr.version = 4;
-        ((CsrUint8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[0] = 0x00;
-        ((CsrUint8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[1] = 0x44;
-        ((CsrUint8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[0] = 0x00;
-        ((CsrUint8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[1] = 0x43;
+        ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[0] = 0x00;
+        ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[1] = 0x44;
+        ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[0] = 0x00;
+        ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[1] = 0x43;
         dhcp_tclas->tcp_ip_cls_fr.protocol = 0x11;
         dhcp_tclas->tcp_ip_cls_fr.cls_fr_mask = 0x58; //bits: 3,4,6
     }
@@ -637,10 +631,10 @@ int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg)
 
 int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg)
 {
-    CsrUint8 wmm_qos_info;
+    u8 wmm_qos_info;
     int rc = 0;
 
-    if (get_user(wmm_qos_info, (CsrUint8*)(((unifi_cfg_command_t*)arg) + 1))) {
+    if (get_user(wmm_qos_info, (u8*)(((unifi_cfg_command_t*)arg) + 1))) {
         unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
         return -EFAULT;
     }
@@ -654,22 +648,22 @@ int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg)
 
 int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg)
 {
-    CsrUint32 addts_tid;
-    CsrUint8 addts_ie_length;
-    CsrUint8 *addts_ie;
-    CsrUint8 *addts_params;
+    u32 addts_tid;
+    u8 addts_ie_length;
+    u8 *addts_ie;
+    u8 *addts_params;
     CsrWifiSmeDataBlock tspec;
     CsrWifiSmeDataBlock tclas;
     int rc;
 
-    addts_params = (CsrUint8*)(((unifi_cfg_command_t*)arg) + 1);
-    if (get_user(addts_tid, (CsrUint32*)addts_params)) {
+    addts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
+    if (get_user(addts_tid, (u32*)addts_params)) {
         unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n");
         return -EFAULT;
     }
 
-    addts_params += sizeof(CsrUint32);
-    if (get_user(addts_ie_length, (CsrUint8*)addts_params)) {
+    addts_params += sizeof(u32);
+    if (get_user(addts_ie_length, (u8*)addts_params)) {
         unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n");
         return -EFAULT;
     }
@@ -677,7 +671,7 @@ int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg)
     unifi_trace(priv, UDBG4, "addts: tid = 0x%x ie_length = %d\n",
             addts_tid, addts_ie_length);
 
-    addts_ie = CsrPmemAlloc(addts_ie_length);
+    addts_ie = kmalloc(addts_ie_length, GFP_KERNEL);
     if (addts_ie == NULL) {
         unifi_error(priv,
                 "unifi_cfg_wmm_addts: Failed to malloc %d bytes for addts_ie buffer\n",
@@ -685,11 +679,11 @@ int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg)
         return -ENOMEM;
     }
 
-    addts_params += sizeof(CsrUint8);
+    addts_params += sizeof(u8);
     rc = copy_from_user(addts_ie, addts_params, addts_ie_length);
     if (rc) {
         unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the addts buffer\n");
-        CsrPmemFree(addts_ie);
+        kfree(addts_ie);
         return -EFAULT;
     }
 
@@ -701,21 +695,21 @@ int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg)
     rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_ADD, addts_tid,
             &tspec, &tclas);
 
-    CsrPmemFree(addts_ie);
+    kfree(addts_ie);
     return rc;
 }
 
 
 int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg)
 {
-    CsrUint32 delts_tid;
-    CsrUint8 *delts_params;
+    u32 delts_tid;
+    u8 *delts_params;
     CsrWifiSmeDataBlock tspec;
     CsrWifiSmeDataBlock tclas;
     int rc;
 
-    delts_params = (CsrUint8*)(((unifi_cfg_command_t*)arg) + 1);
-    if (get_user(delts_tid, (CsrUint32*)delts_params)) {
+    delts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
+    if (get_user(delts_tid, (u32*)delts_params)) {
         unifi_error(priv, "unifi_cfg_wmm_delts: Failed to get the argument\n");
         return -EFAULT;
     }
@@ -733,15 +727,15 @@ int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg)
 
 int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg)
 {
-    CsrBool strict_draft_n;
-    CsrUint8 *strict_draft_n_params;
+    u8 strict_draft_n;
+    u8 *strict_draft_n_params;
     int rc;
 
     CsrWifiSmeStaConfig  staConfig;
     CsrWifiSmeDeviceConfig  deviceConfig;
 
-    strict_draft_n_params = (CsrUint8*)(((unifi_cfg_command_t*)arg) + 1);
-    if (get_user(strict_draft_n, (CsrBool*)strict_draft_n_params)) {
+    strict_draft_n_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
+    if (get_user(strict_draft_n, (u8*)strict_draft_n_params)) {
         unifi_error(priv, "unifi_cfg_strict_draft_n: Failed to get the argument\n");
         return -EFAULT;
     }
@@ -769,15 +763,15 @@ int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg)
 
 int unifi_cfg_enable_okc(unifi_priv_t *priv, unsigned char *arg)
 {
-    CsrBool enable_okc;
-    CsrUint8 *enable_okc_params;
+    u8 enable_okc;
+    u8 *enable_okc_params;
     int rc;
 
     CsrWifiSmeStaConfig staConfig;
     CsrWifiSmeDeviceConfig deviceConfig;
 
-    enable_okc_params = (CsrUint8*)(((unifi_cfg_command_t*)arg) + 1);
-    if (get_user(enable_okc, (CsrBool*)enable_okc_params)) {
+    enable_okc_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
+    if (get_user(enable_okc, (u8*)enable_okc_params)) {
         unifi_error(priv, "unifi_cfg_enable_okc: Failed to get the argument\n");
         return -EFAULT;
     }
@@ -873,7 +867,7 @@ int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg)
             break;
         case UNIFI_CFG_GET_INSTANCE:
             {
-                CsrUint16 InterfaceId=0;
+                u16 InterfaceId=0;
                 uf_net_get_name(priv->netdev[InterfaceId], &inst_name[0], sizeof(inst_name));
 
                 /* Copy the info to the out buffer */
@@ -917,10 +911,10 @@ int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg)
 }
 #ifdef CSR_SUPPORT_WEXT_AP
 int
- uf_configure_supported_rates(CsrUint8 * supportedRates, CsrUint8 phySupportedBitmap)
+ uf_configure_supported_rates(u8 * supportedRates, u8 phySupportedBitmap)
 {
     int i=0;
-    CsrBool b=FALSE, g = FALSE, n = FALSE;
+    u8 b=FALSE, g = FALSE, n = FALSE;
     b = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_B;
     n = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_N;
     g = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_G;
@@ -1060,7 +1054,7 @@ uf_ta_ind_wq(struct work_struct *work)
 {
     struct ta_ind *ind = container_of(work, struct ta_ind, task);
     unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_ind_work);
-    CsrUint16 interfaceTag = 0;
+    u16 interfaceTag = 0;
 
 
     CsrWifiRouterCtrlTrafficProtocolIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,
@@ -1097,7 +1091,7 @@ uf_ta_sample_ind_wq(struct work_struct *work)
 {
     struct ta_sample_ind *ind = container_of(work, struct ta_sample_ind, task);
     unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_sample_ind_work);
-    CsrUint16 interfaceTag = 0;
+    u16 interfaceTag = 0;
 
      unifi_trace(priv, UDBG5, "rxtcp %d txtcp %d rxudp %d txudp %d prio %d\n",
         priv->rxTcpThroughput,
@@ -1158,7 +1152,7 @@ void
 uf_send_m4_ready_wq(struct work_struct *work)
 {
     netInterface_priv_t *InterfacePriv = container_of(work, netInterface_priv_t, send_m4_ready_task);
-    CsrUint16 iface = InterfacePriv->InterfaceTag;
+    u16 iface = InterfacePriv->InterfaceTag;
     unifi_priv_t *priv = InterfacePriv->privPtr;
     CSR_MA_PACKET_REQUEST *req = &InterfacePriv->m4_signal.u.MaPacketRequest;
     CsrWifiMacAddress peer;
@@ -1201,11 +1195,11 @@ uf_send_m4_ready_wq(struct work_struct *work)
 void uf_send_pkt_to_encrypt(struct work_struct *work)
 {
     netInterface_priv_t *interfacePriv = container_of(work, netInterface_priv_t, send_pkt_to_encrypt);
-    CsrUint16 interfaceTag = interfacePriv->InterfaceTag;
+    u16 interfaceTag = interfacePriv->InterfaceTag;
     unifi_priv_t *priv = interfacePriv->privPtr;
 
-    CsrUint32 pktBulkDataLength;
-    CsrUint8 *pktBulkData;
+    u32 pktBulkDataLength;
+    u8 *pktBulkData;
     unsigned long flags;
 
     if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) {
@@ -1215,8 +1209,8 @@ void uf_send_pkt_to_encrypt(struct work_struct *work)
         pktBulkDataLength = interfacePriv->wapi_unicast_bulk_data.data_length;
 
         if (pktBulkDataLength > 0) {
-                   pktBulkData = (CsrUint8 *)CsrPmemAlloc(pktBulkDataLength);
-                   CsrMemSet(pktBulkData, 0, pktBulkDataLength);
+                   pktBulkData = kmalloc(pktBulkDataLength, GFP_KERNEL);
+                   memset(pktBulkData, 0, pktBulkDataLength);
            } else {
                    unifi_error(priv, "uf_send_pkt_to_encrypt() : invalid buffer\n");
                    return;
@@ -1224,7 +1218,7 @@ void uf_send_pkt_to_encrypt(struct work_struct *work)
 
         spin_lock_irqsave(&priv->wapi_lock, flags);
         /* Copy over the MA PKT REQ bulk data */
-        CsrMemCpy(pktBulkData, (CsrUint8*)interfacePriv->wapi_unicast_bulk_data.os_data_ptr, pktBulkDataLength);
+        memcpy(pktBulkData, (u8*)interfacePriv->wapi_unicast_bulk_data.os_data_ptr, pktBulkDataLength);
         /* Free any bulk data buffers allocated for the WAPI Data pkt */
         unifi_net_data_free(priv, &interfacePriv->wapi_unicast_bulk_data);
         interfacePriv->wapi_unicast_bulk_data.net_buf_length = 0;
@@ -1235,7 +1229,7 @@ void uf_send_pkt_to_encrypt(struct work_struct *work)
         CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, pktBulkDataLength, pktBulkData);
         unifi_trace(priv, UDBG1, "WapiUnicastTxEncryptInd sent to SME\n");
 
-        CsrPmemFree(pktBulkData); /* Would have been copied over by the SME Handler */
+        kfree(pktBulkData); /* Would have been copied over by the SME Handler */
 
         func_exit();
     } else {