ARMmbed / sal-driver-lwip-k64f-eth

LwIP platform-specific implementation for k64f
Other
1 stars 3 forks source link

Defer packet input processing to thread context #9

Open bremoran opened 8 years ago

bremoran commented 8 years ago

add a dependency on the scheduler. Add a new file that schedules netif->input Call defer_input instead of netif->input

cc @bogdanm @lws-team

This is a possible fix for https://github.com/ARMmbed/sal-driver-lwip-k64f-eth/issues/8 and https://github.com/ARMmbed/sockets/issues/41

lws-team commented 8 years ago

This kills ARP

09:15:32.262302 ARP, Request who-has 192.168.2.205 tell 192.168.2.233, length 28 09:15:33.263359 ARP, Request who-has 192.168.2.205 tell 192.168.2.233, length 28 09:15:34.265349 ARP, Request who-has 192.168.2.205 tell 192.168.2.233, length 28 09:15:35.267422 ARP, Request who-has 192.168.2.205 tell 192.168.2.233, length 28 09:15:36.269357 ARP, Request who-has 192.168.2.205 tell 192.168.2.233, length 28 09:15:37.271362 ARP, Request who-has 192.168.2.205 tell 192.168.2.233, length 28 ^C

bremoran commented 8 years ago

DO NOT MERGE This PR requires that EthernetInterface::connect() be non-blocking.

lws-team commented 8 years ago

What should the callback that connect() wants now look like / do ?

bremoran commented 8 years ago

I modified your test app like this:

static void onPhyChange(EthernetInterface* eth, bool linkUp, bool ifUp)
{
    if (linkUp && ifUp) {
        printf("Server IP Address is %s:%d\r\n", eth->getIPAddress(), 80);
        lwipv4_socket_init();

        srv = new listener;
        mbed::util::FunctionPointer1<void, uint16_t> fp(srv, &listener::start);
        minar::Scheduler::postCallback(fp.bind(SERVER_PORT));

        minar::Scheduler::postCallback(blinky).period(minar::milliseconds(500));
    }
}

extern "C" void sys_check_timeouts();
void app_start(int argc, char *argv[])
{
    minar::Scheduler::postCallback(sys_check_timeouts).period(minar::milliseconds(250));
    static Serial pc(USBTX, USBRX);

    (void) argc;
    (void) argv;

    pc.baud(115200);
    printf("\r\n\r\nStarting on port 80...\r\n");
    eth.init(); // Use DHCP
    eth.connect(onPhyChange);

}
lws-team commented 8 years ago

I have this, which is the same I think


static void eth_status_change(EthernetInterface *eth, bool linkup, bool ifup)
{
    (void)eth;
    printf("linkup %d, ifup %d\r\n", linkup, ifup);
    if (linkup && ifup) {
        mbed::util::FunctionPointer1<void, uint16_t> fp(srv, &listener::start);
        minar::Scheduler::postCallback(fp.bind(SERVER_PORT));
    }
}

extern "C" void sys_check_timeouts();
void app_start(int argc, char *argv[])
{
    static Serial pc(USBTX, USBRX);

    minar::Scheduler::postCallback(sys_check_timeouts).period(minar::milliseconds(250));
    minar::Scheduler::postCallback(blinky).period(minar::milliseconds(500));

    (void) argc;
    (void) argv;

    pc.baud(115200);
    printf("\r\n\r\nStarting on port 80...\r\n");
    eth.init("192.168.2.205", "255.255.255.0", "192.168.2.1");
    lwipv4_socket_init();
    srv = new listener;
    eth.connect(eth_status_change);
}