📄 atheros_2_0_function.patch
字号:
++static void ar6000_TxDataCleanup(AR_SOFTC_T *ar)+{+ /* flush all the data (non-control) streams+ * we only flush packets that are tagged as data, we leave any control packets that+ * were in the TX queues alone */+ HTCFlushEndpoint(ar->arHtcTarget,+ arWMIStream2EndpointID(ar,WMI_BEST_EFFORT_PRI),+ AR6K_DATA_PKT_TAG);+ HTCFlushEndpoint(ar->arHtcTarget,+ arWMIStream2EndpointID(ar,WMI_LOW_PRI),+ AR6K_DATA_PKT_TAG);+ HTCFlushEndpoint(ar->arHtcTarget,+ arWMIStream2EndpointID(ar,WMI_HIGH_PRI),+ AR6K_DATA_PKT_TAG);+ HTCFlushEndpoint(ar->arHtcTarget,+ arWMIStream2EndpointID(ar,WMI_HIGHEST_PRI),+ AR6K_DATA_PKT_TAG);+}++/* This function does one time initialization for the lifetime of the device */+int ar6000_init(struct net_device *dev)+{+ AR_SOFTC_T *ar;+ A_STATUS status;+ A_INT32 timeleft;++ if((ar = netdev_priv(dev)) == NULL)+ {+ return(-EIO);+ }++ /* Do we need to finish the BMI phase */+ if(BMIDone(ar->arHifDevice) != A_OK)+ {+ return -EIO;+ }++ if (!bypasswmi)+ {+#if 0 /* TBDXXX */+ if (ar->arVersion.host_ver != ar->arVersion.target_ver) {+ A_PRINTF("WARNING: Host version 0x%x does not match Target "+ " version 0x%x!\n",+ ar->arVersion.host_ver, ar->arVersion.target_ver);+ }+#endif++ /* Indicate that WMI is enabled (although not ready yet) */+ ar->arWmiEnabled = TRUE;+ if ((ar->arWmi = wmi_init((void *) ar)) == NULL)+ {+ AR_DEBUG_PRINTF("%s() Failed to initialize WMI.\n", __func__);+ return(-EIO);+ }++ AR_DEBUG_PRINTF("%s() Got WMI @ 0x%08x.\n", __func__,+ (unsigned int) ar->arWmi);+ }++ do {+ HTC_SERVICE_CONNECT_REQ connect;++ /* the reason we have to wait for the target here is that the driver layer+ * has to init BMI in order to set the host block size,+ */+ status = HTCWaitTarget(ar->arHtcTarget);++ if (A_FAILED(status)) {+ break;+ }++ A_MEMZERO(&connect,sizeof(connect));+ /* meta data is unused for now */+ connect.pMetaData = NULL;+ connect.MetaDataLength = 0;+ /* these fields are the same for all service endpoints */+ connect.EpCallbacks.pContext = ar;+ connect.EpCallbacks.EpTxComplete = ar6000_tx_complete;+ connect.EpCallbacks.EpRecv = ar6000_rx;+ connect.EpCallbacks.EpRecvRefill = ar6000_rx_refill;+ connect.EpCallbacks.EpSendFull = ar6000_tx_queue_full;+ /* set the max queue depth so that our ar6000_tx_queue_full handler gets called.+ * Linux has the peculiarity of not providing flow control between the+ * NIC and the network stack. There is no API to indicate that a TX packet+ * was sent which could provide some back pressure to the network stack.+ * Under linux you would have to wait till the network stack consumed all sk_buffs+ * before any back-flow kicked in. Which isn't very friendly.+ * So we have to manage this ourselves */+ connect.MaxSendQueueDepth = 32;++ /* connect to control service */+ connect.ServiceID = WMI_CONTROL_SVC;+ status = ar6000_connectservice(ar,+ &connect,+ WMI_CONTROL_PRI,+ "WMI CONTROL");+ if (A_FAILED(status)) {+ break;+ }++ /* for the remaining data services set the connection flag to reduce dribbling,+ * if configured to do so */+ if (reduce_credit_dribble) {+ connect.ConnectionFlags |= HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE;+ /* the credit dribble trigger threshold is (reduce_credit_dribble - 1) for a value+ * of 0-3 */+ connect.ConnectionFlags &= ~HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK;+ connect.ConnectionFlags |=+ ((A_UINT16)reduce_credit_dribble - 1) & HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK;+ }+ /* connect to best-effort service */+ connect.ServiceID = WMI_DATA_BE_SVC;++ status = ar6000_connectservice(ar,+ &connect,+ WMI_BEST_EFFORT_PRI,+ "WMI DATA BE");+ if (A_FAILED(status)) {+ break;+ }++ /* connect to back-ground+ * map this to WMI LOW_PRI */+ connect.ServiceID = WMI_DATA_BK_SVC;+ status = ar6000_connectservice(ar,+ &connect,+ WMI_LOW_PRI,+ "WMI DATA BK");+ if (A_FAILED(status)) {+ break;+ }++ /* connect to Video service, map this to+ * to HI PRI */+ connect.ServiceID = WMI_DATA_VI_SVC;+ status = ar6000_connectservice(ar,+ &connect,+ WMI_HIGH_PRI,+ "WMI DATA VI");+ if (A_FAILED(status)) {+ break;+ }++ /* connect to VO service, this is currently not+ * mapped to a WMI priority stream due to historical reasons.+ * WMI originally defined 3 priorities over 3 mailboxes+ * We can change this when WMI is reworked so that priorities are not+ * dependent on mailboxes */+ connect.ServiceID = WMI_DATA_VO_SVC;+ status = ar6000_connectservice(ar,+ &connect,+ WMI_HIGHEST_PRI,+ "WMI DATA VO");+ if (A_FAILED(status)) {+ break;+ }++ A_ASSERT(arWMIStream2EndpointID(ar,WMI_CONTROL_PRI) != 0);+ A_ASSERT(arWMIStream2EndpointID(ar,WMI_BEST_EFFORT_PRI) != 0);+ A_ASSERT(arWMIStream2EndpointID(ar,WMI_LOW_PRI) != 0);+ A_ASSERT(arWMIStream2EndpointID(ar,WMI_HIGH_PRI) != 0);+ A_ASSERT(arWMIStream2EndpointID(ar,WMI_HIGHEST_PRI) != 0);+ } while (FALSE);++ if (A_FAILED(status)) {+ return (-EIO);+ }++ /*+ * give our connected endpoints some buffers+ */+ ar6000_rx_refill(ar, arWMIStream2EndpointID(ar,WMI_CONTROL_PRI));++ ar6000_rx_refill(ar, arWMIStream2EndpointID(ar,WMI_BEST_EFFORT_PRI));++ /*+ * We will post the receive buffers only for SPE testing and so we are+ * making it conditional on the 'bypasswmi' flag.+ */+ if (bypasswmi) {+ ar6000_rx_refill(ar,arWMIStream2EndpointID(ar,WMI_LOW_PRI));+ ar6000_rx_refill(ar,arWMIStream2EndpointID(ar,WMI_HIGH_PRI));+ }++ /* setup credit distribution */+ ar6000_setup_credit_dist(ar->arHtcTarget, &ar->arCreditStateInfo);++ /* Since cookies are used for HTC transports, they should be */+ /* initialized prior to enabling HTC. */+ ar6000_cookie_init(ar);++ /* start HTC */+ status = HTCStart(ar->arHtcTarget);++ if (status != A_OK) {+ if (ar->arWmiEnabled == TRUE) {+ wmi_shutdown(ar->arWmi);+ ar->arWmiEnabled = FALSE;+ ar->arWmi = NULL;+ }+ ar6000_cookie_cleanup(ar);+ return -EIO;+ }++ if (!bypasswmi) {+ /* Wait for Wmi event to be ready */+ timeleft = wait_event_interruptible_timeout(arEvent,+ (ar->arWmiReady == TRUE), wmitimeout * HZ);++ if(!timeleft || signal_pending(current))+ {+ AR_DEBUG_PRINTF("WMI is not ready or wait was interrupted\n");+#if defined(DWSIM) /* TBDXXX */+ AR_DEBUG_PRINTF(".....but proceed anyway.\n");+#else+ return -EIO;+#endif+ }++ AR_DEBUG_PRINTF("%s() WMI is ready\n", __func__);++ /* Communicate the wmi protocol verision to the target */+ if ((ar6000_set_host_app_area(ar)) != A_OK) {+ AR_DEBUG_PRINTF("Unable to set the host app area\n");+ }+ }++ ar->arNumDataEndPts = 1;++ return(0);+}+++void+ar6000_bitrate_rx(void *devt, A_INT32 rateKbps)+{+ AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;++ ar->arBitRate = rateKbps;+ wake_up(&arEvent);+}++void+ar6000_ratemask_rx(void *devt, A_UINT16 ratemask)+{+ AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;++ ar->arRateMask = ratemask;+ wake_up(&arEvent);+}++void+ar6000_txPwr_rx(void *devt, A_UINT8 txPwr)+{+ AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;++ ar->arTxPwr = txPwr;+ wake_up(&arEvent);+}+++void+ar6000_channelList_rx(void *devt, A_INT8 numChan, A_UINT16 *chanList)+{+ AR_SOFTC_T *ar = (AR_SOFTC_T *)devt;++ A_MEMCPY(ar->arChannelList, chanList, numChan * sizeof (A_UINT16));+ ar->arNumChannels = numChan;++ wake_up(&arEvent);+}++A_UINT8+ar6000_ibss_map_epid(struct sk_buff *skb, struct net_device *dev, A_UINT32 * mapNo)+{+ AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;+ A_UINT8 *datap;+ ATH_MAC_HDR *macHdr;+ A_UINT32 i, eptMap;++ (*mapNo) = 0;+ datap = A_NETBUF_DATA(skb);+ macHdr = (ATH_MAC_HDR *)(datap + sizeof(WMI_DATA_HDR));+ if (IEEE80211_IS_MULTICAST(macHdr->dstMac)) {+ return ENDPOINT_2;+ }++ eptMap = -1;+ for (i = 0; i < ar->arNodeNum; i ++) {+ if (IEEE80211_ADDR_EQ(macHdr->dstMac, ar->arNodeMap[i].macAddress)) {+ (*mapNo) = i + 1;+ ar->arNodeMap[i].txPending ++;+ return ar->arNodeMap[i].epId;+ }++ if ((eptMap == -1) && !ar->arNodeMap[i].txPending) {+ eptMap = i;+ }+ }++ if (eptMap == -1) {+ eptMap = ar->arNodeNum;+ ar->arNodeNum ++;+ A_ASSERT(ar->arNodeNum <= MAX_NODE_NUM);+ }++ A_MEMCPY(ar->arNodeMap[eptMap].macAddress, macHdr->dstMac, IEEE80211_ADDR_LEN);++ for (i = ENDPOINT_2; i <= ENDPOINT_5; i ++) {+ if (!ar->arTxPending[i]) {+ ar->arNodeMap[eptMap].epId = i;+ break;+ }+ // No free endpoint is available, start redistribution on the inuse endpoints.+ if (i == ENDPOINT_5) {+ ar->arNodeMap[eptMap].epId = ar->arNexEpId;+ ar->arNexEpId ++;+ if (ar->arNexEpId > ENDPOINT_5) {+ ar->arNexEpId = ENDPOINT_2;+ }+ }+ }++ (*mapNo) = eptMap + 1;+ ar->arNodeMap[eptMap].txPending ++;++ return ar->arNodeMap[eptMap].epId;+}++#ifdef DEBUG+static void ar6000_dump_skb(struct sk_buff *skb)+{+ u_char *ch;+ for (ch = A_NETBUF_DATA(skb);+ (A_UINT32)ch < ((A_UINT32)A_NETBUF_DATA(skb) ++ A_NETBUF_LEN(skb)); ch++)+ {+ AR_DEBUG_PRINTF("%2.2x ", *ch);+ }+ AR_DEBUG_PRINTF("\n");+}+#endif++static int+ar6000_data_tx(struct sk_buff *skb, struct net_device *dev)+{+ AR_SOFTC_T *ar = (AR_SOFTC_T *)dev->priv;+ WMI_PRI_STREAM_ID streamID = WMI_NOT_MAPPED;+ A_UINT32 mapNo = 0;+ int len;+ struct ar_cookie *cookie;+ A_BOOL checkAdHocPsMapping = FALSE;++#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)+ skb->list = NULL;+#endif++ AR_DEBUG2_PRINTF("ar6000_data_tx start - skb=0x%x, data=0x%x, len=0x%x\n",+ (A_UINT32)skb, (A_UINT32)A_NETBUF_DATA(skb),+ A_NETBUF_LEN(skb));+#ifdef CONFIG_HOST_TCMD_SUPPORT+ /* TCMD doesnt support any data, free the buf and return */+ if(ar->arTargetMode == AR6000_TCMD_MODE) {+ A_NETBUF_FREE(skb);+ return 0;+ }+#endif+ do {++ if (ar->arWmiReady == FALSE && bypasswmi == 0) {+ break;+ }++#ifdef BLOCK_TX_PATH_FLAG+ if (blocktx) {+ break;+ }+#endif /* BLOCK_TX_PATH_FLAG */++ if (ar->arWmiEnabled) {+ if (A_NETBUF_HEADROOM(skb) < dev->hard_header_len) {+ struct sk_buff *newbuf;+ /*+ * We really should have gotten enough headroom but sometimes+ * we still get packets with not enough headroom. Copy the packet.+ */+ len = A_NETBUF_LEN(skb);+ newbuf = A_NETBUF_ALLOC(len);+ if (newbuf == NULL) {+ break;+ }+ A_NETBUF_PUT(newbuf, len);+ A_MEMCPY(A_NETBUF_DATA(newbuf), A_NETBUF_DATA(skb), len);+ A_NETBUF_FREE(skb);+ skb = newbuf;+ /* fall through and assemble header */+ }++ if (wmi_dix_2_dot3(ar->arWmi, skb) != A_OK) {+ AR_DEBUG_PRINTF("ar6000_data_tx - wmi_dix_2_dot3 failed\n");+ break;+ }++ if (wmi_data_hdr_add(ar->arWmi, skb, DATA_MSGTYPE) != A_OK) {+ AR_DEBUG_PRINTF("ar6000_data_tx - wmi_data_hdr_add failed\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -