What does a network card driver do?

2

Can't the operating system directly write data to the PCI bus and the network card would simply send it through the cable? What does the driver do, and in what way does that differ for each network card chipset?

futlib

Posted 2011-05-25T10:13:55.643

Reputation: 1 129

1I wasn't sure where to put it, but since it is about the behaviour of drivers, which are software, which is created by means of programming, I thought it would fit better on SO. – None – 2011-05-25T10:22:10.667

@futlib: I can see what you're saying, but unfortunately it isn't a specific programming question. General programming questions go to programmers.stackexchange.com, but I think this better off in SuperUser (it isn't something programmers really need to know). If your question was "I'm writing a network driver, what's the best way to structure packets in memory?", that's a Stack Overflow question. "I'm writing a network driver, where do I start?" is a programmers question. Hope this helps, and I hope you get a good answer to your question, which ever exchange it ends up on :) – Binary Worrier – 2011-05-25T10:31:22.200

@Binary Worrier Agree with you. But I don't think the super users can answer this well. He might be worry about that. – Benjamin – 2011-05-25T14:29:42.977

Answers

1

Each network chip will have different I/O registers, memory-mapped buffers, ways of detecting interface speeds, and all sorts of other fundamental technical differences.

The job of the driver is simply to abstract those differences away so that the O/S has a common API for moving packets from the higher network layers down to the hardware (and vice versa).

Alnitak

Posted 2011-05-25T10:13:55.643

Reputation: 656

So it isn't just a means of writing data to RJ45, similar to a RS232 to USB converter? Could you outline a bit what a network card has to do in order to transmit data? – None – 2011-05-25T10:28:44.767

@Anonymous (futlib?), check my answer. Networking is definitely more than just sending an electrical signal through a wire. – Synetech – 2011-05-27T03:56:27.910

0

In general terms, any device driver acts an an interface between the 'abstract' view of the hardware the the operating system has, and the 'physical' chipset that actually exists on the board.

This abstraction layer allows different hardware from different vendors to be used in many different operating systems. It also allows 'software' devices (such as a network loopback device) to be implemented that don't have any underlying hardware to control.

To find exactly what a particular driver does, you would need to understand the datasheets for the chips it controls.

Roddy

Posted 2011-05-25T10:13:55.643

Reputation: 2 040

0

It could, but the problem with that is each NIC chipset manufacturer designs their devices differently and therefore one model of NIC might require you to write at one address, and another model might require you to write at another address. In addition to looking at NIC chipset datasheets like @Roddy suggests to learn exactly how they go about it, you could also look at the source of Linux drivers for that chipset.

Some advanced NICs use DMA and such to pretty much operate the way you say. The driver in that case really doesn't do much.

It's easier to update a single operating system with a new driver than go around and update every single program that uses a NIC.

LawrenceC

Posted 2011-05-25T10:13:55.643

Reputation: 63 487

0

Each piece of hardware is different from others of the same class, even when adhering to standards. That’s why you need drivers; to simplify using the hardware by providing a common interface. You asked whether the OS can simply write to output. Yes it can; it does this via its drivers.

More specifically about network cards, you ask if the OS can write to PCI bus, through the card, out the cable, and over the Internet. The problem with that question is that you are not familiar with networking. It is a complex thing that is beyond just sending a voltage over a wire. You are forgetting about all the work that allows such a complex web to work like all the addressing and such—it’s not just encoding or decoding an electrical signal.

You will want to look over the OSI model to learn how networking works. It separates the work of transferring data between computers (or other devices) into seven “layers”. Each layers is responsible for its own part; the OS plays its role as do the driver and card itself.

Synetech

Posted 2011-05-25T10:13:55.643

Reputation: 63 242

But isn't the network card just responsible of layer 1? That's what I always thought. – futlib – 2011-05-27T13:19:01.967

Generally yes, and that’s all the more reason that some software is required to handle the other parts. The OS can only deal with so much (take a look at how graphics were handled in the DOS days, before DirectX came out). The driver is like a glue between the higher-level APIs of the OS and the lower level interfaces of the hardware. Yes, the OS could “do it itself”, but it would do so by having drivers built-in. – Synetech – 2011-05-27T15:53:04.790

What other parts in particular? I believe that the TCP/IP stack is usually device independent, so the NIC driver would implement just layer 2, considering that layer 1 is handled by the hardware? – futlib – 2011-06-04T13:38:24.350