>While code reading of eepro100.c I got a problem in understanding
>one detail:
>
>In the probe section of the driver, the RxFD structure is
>initialized. Here the field
> ACCESS(rxfd)rx_buf_addr = (int) &nic->packet;
>is setup with the address of the packet frame POINTER inside
>the nic structure.
>
>What does the field rx_buf_addr expect ?
>The address to a buffer, or the address to a pointer, indicating
>the the buffer ?
Ok, I didn't write the code, so understand that this is my best guess.
ACCESS is a macro that expands ACCESS(x) to either x-> or x. depending
on a define. So ignoring why sometimes a pointer and sometimes a struct,
rx_buf_addr is a field in rxfd. Let's just say rxfd is a pointer to a
struct for the same of explanation.
>The point I cannot understand here is the following.
>The setup in the probe functions sets the `rx_buf_addr' to the
>packet buffer, defined in `config.c'. This means, that an received
>packet is transfered there by the i8255[789] chip. On the
>other hand, in the `poll' routine, I found following code:
>
> nic->packetlen = ACCESS(rxfd)count & 0x3fff;
> memcpy (nic->packet, ACCESS(rxfd)packet, nic->packetlen);
>
>Here the contents from the packet field of the `rxfd' is copied into
>the nic->packet frame. But how does the frame come in `rxfd'-packet
>field ?? The hardware has to send the data directly to nic->packet.
The frame is deposited into the memory region pointed to by rxfd by the
*hardware* of the ethernet adaptor. The EEPRO100 is quite a smart
adaptor. Very roughly speaking, you give the hardware a pointer to a
receive descriptor (the struct RxFD, which is a convenient way to
describe a set of consecutive memory locations), and in turn that struct
contains fields for the data, the packet receive status, the packet
length, etc. Thus when the status word indicates that the receive is
complete, the data field will "magically" have the requested data.
It is quite likely either the assignment to rx_buf_addr or the memcpy is
useless. I suspect the assignment to rx_buf_addr. To understand it
fully you would have to get hold of the data sheet of the EEPRO100
controller.
|