Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kernel] High speed serial driver and slip networking fixes #664

Merged
merged 3 commits into from
Jul 1, 2020
Merged

[kernel] High speed serial driver and slip networking fixes #664

merged 3 commits into from
Jul 1, 2020

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Jun 30, 2020

Fixes all outstanding serial port speed and reliability issues, including #454, #515, and some issues brought up in #539.
Fixes and improvements made to SLIP networking now allow speeds up to 115200 baud between Linux and ELKS.
Adds "net start" script for starting networking on SLIP and ethernet.
Adds "slattach.sh" script to setup SLIP to ELKS link.
Tested on Compaq 386 Portable with working miniterm and SLIP up to 57600 baud.
ktcp networking now working quickly with telnet in both direction simultaneously over serial but many networking problems remain.

Details:
Fix serial receive ring buffer corruption bug due to no cli/sti protection on serial received characters.
Wrote fast optional asm com1/com2 interrupt driver; runs without any ELKS interrupt stack and processing overhead, uses timer interrupt for process wakeup.
Set via CONFIG_FAST_IRQ4 (default) and CONFIG_FAST_IRQ3 in include/arch/ports.h. No ISIG tty line signal handling, for use in CSLIP/SLIP networking or very fast terminal emulation access. Original serial port driver now runs well up to 19200 baud.
Speed up serial transmit to use transmitter holding buffer empty rather than transmitter empty.
Fix serial receiver buffer size not a power-of-two bug which lost characters.
Remove inb_p/outb_p 1us pause after all serial I/O, move to INB/OUTB macros.
Add SLIP packet write buffering for speed.
Fix SLIP packet overflow bug.
Fix ktcp deveth_process perror message bug.
Fix miniterm ^C exit son slip/hex dump mode, dump mode still broken.
Testing SLIP now, CSLIP coming.
Change NE2K driver non-probe to compilation printk

Add "net start" script for starting (and eventually stopping) networking. Exists as shell script in /bin/net. Add "net start" to /etc/rc.d/rc.sys for network startup at boot.

Usage: net [start|stop] [eth|skip|cslip] [baud] [device]
    net start eth
    net start slip 19200
    net start cslip 4800 /dev/ttyS1

Default no network startup at boot for time being.
Default single user mode (init 1) for now (init 3 for serial gettys)

@ghaerr
Copy link
Owner Author

ghaerr commented Jul 1, 2020

CSLIP still not working well, generates bad TCP checksums. Use SLIP.

Rewrite ktcp start options for ease of operation and testing:
Add ktcp -p [slip|cslip|eth]
Add ktcp -l device (default /dev/ttyS0 @ 57600 baud)
Add ktcp -m MTU

Usage: ktcp [-b] [-d] [-p eth|slip|cslip] [-m mtu] [-s baud] [-l device] [localip] [interface] [gateway] [netmask]
Examples:        
        ktcp -p slip -s 19200 -l /dev/ttyS1
        ktcp -b -p cslip (starts cslip in background)
        ktcp -b (starts ethernet in background)
        ktcp -p slip -m 512 (sets MTU)
Preferably use "net start" command documented above.

Set default MTU to 1024 to match serial ring buffer size
Ignore menuconfig CONFIG_CSLIP option, CSLIP always compiled in, set with "ktcp -p cslip" or "net start cslip"
Exit ktcp on SIGHUP or SIGINT (for coming "net stop")
Can restart ktcp without reboot after kill -1 PID
Repair miniterm from first commit

@ghaerr ghaerr merged commit 4852359 into ghaerr:master Jul 1, 2020
@Mellvik
Copy link
Contributor

Mellvik commented Jul 1, 2020 via email

@pawosm-arm
Copy link
Contributor

pawosm-arm commented Jul 1, 2020

Just quick observation before I started testing it:

static void usage(void)
{
    printf("Usage: ktcp [-b] [-d] [-m MTU] [-p eth|slip|cslip] [-s baud] [-l device] [local_ip] [interface] [gateway] [netmask]\n");
    exit(1);
}

the [interface] part does not seem to correspond with the code below:

    local_ip = in_aton(optind < argc? argv[optind++]: DEFAULT_IP);
    gateway_ip = in_aton(optind < argc? argv[optind++]: DEFAULT_GATEWAY);
    netmask_ip = in_aton(optind < argc? argv[optind++]: DEFAULT_NETMASK);

    printf("ktcp: ip %s, ", in_ntoa(local_ip));
    printf("gateway %s, ", in_ntoa(gateway_ip));
    printf("netmask %s\n", in_ntoa(netmask_ip));
    printf("link %d serdev %s baud %lu mtu %u\n", linkprotocol, serdev, baudrate, MTU);

@pawosm-arm
Copy link
Contributor

while ((ch = getopt(argc, argv, "bdp:s:l:")) != -1) does not seem to list -m (MTU).

@ghaerr
Copy link
Owner Author

ghaerr commented Jul 1, 2020

Hello @pawosm-arm,

You have a keen eye, I added the -m MTU option without testing it, and forgot the getopt() parameters for it.
Also, the [interface] portion in usage() is incorrect, the code that reads the parameters is correct.
I'll submit a PR to fix both of these.

Did you fix the -m MTU prior to your testing? Without it, it is possible your Linux box was sending packets larger than 1024, which would overrun the ring buffer and cause checksum errors.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants