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] First pass at allowing multiple NIC device drivers in kernel #1338

Merged
merged 2 commits into from
Jun 20, 2022
Merged

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Jun 20, 2022

First pass of request for multiple ethernet NIC device drivers compiled into kernel from discussion in #1312 (comment).

Implements "master" ethernet character device driver that passes ethernet I/O requests to subdrivers, which are currently ne2k.c, wd.c, and el3.c. Currently still implemented as /dev/eth for all drivers.

Only a single NIC sub driver may be compiled-in, however each now requests IRQ from kernel at open time, and frees IRQ at close time. This is tested by running net stop, net start and works.

NIC subdrivers need to have their kernel-boot-time init code moved to their open routine (@Mellvik) and tested. For the time being, the init code can fail if the NIC card is not found for the driver that is being opened, and return an appropriate errno from open. We need to eliminate the ne2k_drv_init, wd_drv_initm, and el3_drv_init routines. (Don't confuse the boot time xxx_drv_init routines with the driver-internal named xxx_init routines also!)

Next steps would be to commit this PR, then move init code to open routines for each subdriver, then allow multiple drivers to be compiled into kernel and implement multiple /dev/xxx char device names, then add net start eth NIC to pass the new /dev/ne2k etc char device to ktcp, and proceed with multiple NIC testing.

Major issue is that IRQ, BASE and RAM addresses will need to be somehow kept separate for each driver. Not sure how to do that yet.

As long as only a single NIC subdriver is compiled into the kernel, we don't have to worry too much about some of the above difficulties, and we can proceed slowly as time permits in getting multiple NICs working. I figured it would be better to make this small jump now to get it out of the way, while still making it easy for ongoing NIC driver development already in process. In that way, the major kernel changes (which are mostly in this PR) are finished, and only the individual subdrivers will need updating.

Adds free_irq and disable_irq kernel routines for IBM PC (and PC-98). @cocus, we'll need to have you implement disable_irq(unsigned int irq), which I have stubbed out in irq-8018x.c for you. This routine should set the CPU to mask off interrupts for the passed irq; freeing the vector in low core is performed by free_irq and should work on 8018X already.

All three drivers tested for compilation, but only NE2K tested on QEMU.

@ghaerr ghaerr mentioned this pull request Jun 20, 2022
@ghaerr ghaerr merged commit 6ce5756 into ghaerr:master Jun 20, 2022
@ghaerr ghaerr deleted the eth branch June 21, 2022 03:12
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.

None yet

1 participant