/** * \fn wlanDrvIf_Stop * \brief Stop driver * * Called by network stack upon closing network interface (ifconfig down). * Can also be called from user application or CLI for flight mode. * Stop the driver and turn off the device. * * \note * \param dev - The driver network-interface handle * \return 0 (OK) * \sa wlanDrvIf_Start */ int wlanDrvIf_Stop (struct net_device *dev) { TWlanDrvIfObj *drv = (TWlanDrvIfObj *)NETDEV_GET_PRIVATE(dev); ti_dprintf (TIWLAN_LOG_OTHER, "wlanDrvIf_Stop()\n"); if (DRV_STATE_FAILED == drv->tCommon.eDriverState) { return -ENODEV; } /* * Insert Stop command in DrvMain action queue, request driver scheduling * and wait for Stop process completion. */ os_printf("%s LINE %d\n", __func__, __LINE__); os_wake_lock_timeout_enable(drv); os_printf("%s LINE %d\n", __func__, __LINE__); if (TI_OK != drvMain_InsertAction (drv->tCommon.hDrvMain, ACTION_TYPE_STOP)) { return -ENODEV; } os_printf("%s\n", __func__); return 0; }
/** * \fn wlanDrvIf_Start * \brief Start driver * * Called by network stack upon opening network interface (ifconfig up). * Can also be called from user application or CLI for flight mode. * Start the driver initialization process up to OPERATIONAL state. * * \note * \param dev - The driver network-interface handle * \return 0 if succeeded, error if driver not available * \sa wlanDrvIf_Stop */ int wlanDrvIf_Start (struct net_device *dev) { TWlanDrvIfObj *drv = (TWlanDrvIfObj *)NETDEV_GET_PRIVATE(dev); ti_dprintf (TIWLAN_LOG_OTHER, "wlanDrvIf_Start()\n"); printk("%s\n", __func__); if (!drv->tCommon.hDrvMain) { ti_dprintf (TIWLAN_LOG_ERROR, "wlanDrvIf_Start() Driver not created!\n"); return -ENODEV; } if (DRV_STATE_FAILED == drv->tCommon.eDriverState) { ti_dprintf (TIWLAN_LOG_ERROR, "wlanDrvIf_Start() Driver failed!\n"); return -ENODEV; } /* * Insert Start command in DrvMain action queue, request driver scheduling * and wait for action completion (all init process). */ os_wake_lock_timeout_enable(drv); if (TI_OK != drvMain_InsertAction (drv->tCommon.hDrvMain, ACTION_TYPE_START)) { return -ENODEV; } return 0; }
TI_BOOL os_receivePacket(TI_HANDLE OsContext, void *pRxDesc ,void *pPacket, TI_UINT16 Length) { TWlanDrvIfObj *drv = (TWlanDrvIfObj *)OsContext; unsigned char *pdata = (unsigned char *)((TI_UINT32)pPacket & ~(TI_UINT32)0x3); rx_head_t *rx_head = (rx_head_t *)(pdata - WSPI_PAD_BYTES - RX_HEAD_LEN_ALIGNED); struct sk_buff *skb = rx_head->skb; #ifdef TI_DBG if ((TI_UINT32)pPacket & 0x3) { if ((TI_UINT32)pPacket - (TI_UINT32)skb->data != 2) { printk("os_receivePacket() address error skb=0x%x skb->data=0x%x pPacket=0x%x !!!\n",(int)skb, (int)skb->data, (int)pPacket); } } else { if ((TI_UINT32)skb->data != (TI_UINT32)pPacket) { printk("os_receivePacket() address error skb=0x%x skb->data=0x%x pPacket=0x%x !!!\n",(int)skb, (int)skb->data, (int)pPacket); } } if (Length != RX_ETH_PKT_LEN(pPacket)) { printk("os_receivePacket() Length=%d != RX_ETH_PKT_LEN(pPacket)=%d!!!\n",(int)Length, RX_ETH_PKT_LEN(pPacket)); } #endif /* printk("-->> os_receivePacket() pPacket=0x%x Length=%d skb=0x%x skb->data=0x%x skb->head=0x%x skb->len=%d\n", (int)pPacket, (int)Length, (int)skb, (int)skb->data, (int)skb->head, (int)skb->len); */ /* Use skb_reserve, it updates both skb->data and skb->tail. */ skb->data = RX_ETH_PKT_DATA(pPacket); skb->tail = skb->data; skb_put(skb, RX_ETH_PKT_LEN(pPacket)); /* printk("-->> os_receivePacket() skb=0x%x skb->data=0x%x skb->head=0x%x skb->len=%d\n", (int)skb, (int)skb->data, (int)skb->head, (int)skb->len); */ ti_nodprintf(TIWLAN_LOG_INFO, "os_receivePacket - Received EAPOL len-%d\n", WBUF_LEN(pWbuf)); skb->dev = drv->netdev; skb->protocol = eth_type_trans(skb, drv->netdev); skb->ip_summed = CHECKSUM_NONE; drv->stats.rx_packets++; drv->stats.rx_bytes += skb->len; /* Send the skb to the TCP stack. * it responsibly of the Linux kernel to free the skb */ { CL_TRACE_START_L1(); os_wake_lock_timeout_enable(drv); netif_rx_ni(skb); /* Note: Don't change this trace (needed to exclude OS processing from Rx CPU utilization) */ CL_TRACE_END_L1("tiwlan_drv.ko", "OS", "RX", ""); } return TI_TRUE; }
TI_INT32 IPC_EventSend(TI_HANDLE hAdapter, TI_UINT8* pEvData, TI_UINT32 EvDataSize) { struct sk_buff *skb; int res; TWlanDrvIfObj *drv = (TWlanDrvIfObj *) hAdapter; TI_UINT32 realSize = 0; TI_UINT32 msgSize; struct nlmsghdr *nlh; TI_UINT8 *msg; os_wake_lock_timeout_enable(drv); /* This event is targetted to the OS process Id 0 is not a valid pId for LINUX*/ if ((( IPC_EVENT_PARAMS *) pEvData) ->uProcessID == 0) { (( IPC_EVENT_PARAMS *) pEvData) ->pfEventCallback(( IPC_EV_DATA *) pEvData); return 0; } /* set the payload size */ msgSize = (( IPC_EV_DATA *) pEvData) ->uBufferSize + offsetof(IPC_EV_DATA,uBuffer); /* add the netlink header size */ realSize = NLMSG_SPACE(msgSize); /* allocate the complete message */ skb = dev_alloc_skb(realSize); if (!skb) { printk(KERN_ERR "Failed to allocate new skb with size=%u.\n",realSize); return -1; } /* set the netlink header params */ nlh = NLMSG_PUT(skb, 0, 0, NLMSG_DONE, realSize - sizeof(*nlh)); /* get the payload pointer */ msg = (char *)NLMSG_DATA(nlh); /* copy the data to the payload */ memcpy(msg,pEvData,msgSize); NETLINK_CB(skb).pid = 0; /* from kernel */ #define RTMGRP_LINK 1 NETLINK_CB(skb).dst_group = RTMGRP_LINK; /* send the message*/ res = netlink_unicast(drv->wl_sock, skb, (( IPC_EVENT_PARAMS *) pEvData) ->uProcessID, MSG_DONTWAIT); /* Sanity checks. As far as we're concerned this error is unrecovarable.*/ if (res >= 0) { return 0; } nlmsg_failure: ti_dprintf(TIWLAN_LOG_INFO,"IPC kernel: did not send the netlink message\n"); return -1; }
/** * \fn wlanDrvIf_Start * \brief Start driver * * Called by network stack upon opening network interface (ifconfig up). * Can also be called from user application or CLI for flight mode. * Start the driver initialization process up to OPERATIONAL state. * * \note * \param dev - The driver network-interface handle * \return 0 if succeeded, error if driver not available * \sa wlanDrvIf_Stop */ int wlanDrvIf_Start (struct net_device *dev) { TWlanDrvIfObj *drv = (TWlanDrvIfObj *)NETDEV_GET_PRIVATE(dev); ti_dprintf (TIWLAN_LOG_OTHER, "wlanDrvIf_Start()\n"); if (!drv->tCommon.hDrvMain) { ti_dprintf (TIWLAN_LOG_ERROR, "wlanDrvIf_Start() Driver not created!\n"); return -ENODEV; } /*before inserting an action - check driver state*/ if (DRV_STATE_FAILED == drv->tCommon.eDriverState) { return -ENODEV; } os_wake_lock_timeout_enable(drv); drvMain_InsertAction (drv->tCommon.hDrvMain, ACTION_TYPE_START); return 0; }