Example #1
0
void wlan_emac_recv(struct netif *netif, int len)
{
    struct eth_drv_sg sg_list[MAX_ETH_DRV_SG];
    emac_stack_mem_t *buf;
    struct pbuf *p;
    int sg_len = 0;

    if (!rltk_wlan_running(0)) {
        return;
    }

    if (len > MAX_ETH_MSG || len < 0) {
        len = MAX_ETH_MSG;
    }

    buf = emac_stack_mem_alloc(NULL, len, 0);
    if (buf == NULL) {
        return;
    }   

    p = (struct pbuf *)buf;
    for (; p != NULL && sg_len < MAX_ETH_DRV_SG; p = p->next) {
        sg_list[sg_len].buf = (uint32_t) p->payload;
        sg_list[sg_len].len = p->len;
        sg_len++;
    }
    rltk_wlan_recv(0, sg_list, sg_len);

    if (link_input_cb) {
        link_input_cb(link_input_data, buf);
    }
    return;
}
Example #2
0
void RTW_EMAC::wlan_emac_recv(void *param, struct netif *netif, uint32_t len)
{
    struct eth_drv_sg sg_list[MAX_ETH_DRV_SG] = {0};
    emac_mem_buf_t *buf;
    RTW_EMAC *enet = static_cast<RTW_EMAC *>(param);
    emac_mem_buf_t *p;
    int sg_len = 0;
    if (!rltk_wlan_running(0)) {
        return;
    }

    if (len > MAX_ETH_MSG || len < 0) {
        len = MAX_ETH_MSG;
    }

    buf = enet->memory_manager->alloc_heap(len, 0);
    if (buf == NULL) {
        return;
    }

    enet->memory_manager->set_len(buf, len);
    p = buf;
    for (; p != NULL && sg_len < MAX_ETH_DRV_SG; p = enet->memory_manager->get_next(p)) {
        sg_list[sg_len].buf = (unsigned int)(static_cast<uint8_t *>(enet->memory_manager->get_ptr(p)));
        sg_list[sg_len].len = enet->memory_manager->get_len(p);
        sg_len++;
    }

    rltk_wlan_recv(0, sg_list, sg_len);
    if (enet->emac_link_input_cb) {
        enet->emac_link_input_cb(buf);
    }
}