Show Contents...Hide Contents...
NetFPGA internals
This page is dedicated for people doing very intrussive development
related with NetFPGA card. It basically contains stuff that is needed to
implement kernel-related code and is dedicated to OS developers willing
to provide kernel drivers for NetFPGA hardware.
Information present on this page at the time of writing (2009.09.05) should
be actual for releases newer than 1.2.5 version.
As an addition,
libnetfpga API is mentioned each time particular
functionality can be operated from the user-space.
libnetfpga has
been created with ease of NetFPGA operation in mind.
Computer booting
From the host PC point of view, NetFPGA appears on the PCI bus as
a standard peripherial. It is identified with Device Identification and
Device Vendor information. Exact numbers can be seen in `nf2kernel.h`
file:
/* Define PCI Vendor and device IDs for the NF2 card */
#define PCI_VENDOR_ID_STANFORD 0xFEED
#define PCI_DEVICE_ID_STANFORD_NF2 0x0001
Once it's been done, it's up to the developer to allocate needed resources.
In terms of memory, card will operate on 2048-byte buffers, since it's the
maximum value of the card's DMA transfer.
CPCI (Spartan) reprogramming
Default bitstream with which NetFPGA ships is broken . If you try to setup
an interrupt handler, even if the data isn't present on any port and even
without
any cable plugged in, you'll be getting interrupts from DMA.
That's why CPCI reprogramming is
mandatory .
PCI register values for NetFPGA card must be saved prior to touching
CPCI. Reprogramming will change particular registers. After reprogramming,
PCI registers must be restored back to the original values. Otherwise, card
won't work properly.
Saving/receiving can be done either in the user-space (current code for
GNU/Linux does that) or in the kernel-space (FreeBSD kernel driver does that).
CPCI reprogramming can easily be done with
libnetfpga :
int nf_cpci_write(struct netfpga *nf, const char *fname);
Where 'nf' is a handler returned by 'nf_start()', and 'fname' is a path
to the bitstream file. Non-zero value is returned on error.
CNET (Virtex) reprogramming
Virtex programming is pretty straightforward.
With
libnetfpga it can be done with;
int nf_image_write(struct netfpga *nf, const char *fname)
Values of `nf' and 'fname' are respective to the 'nf_cpci_write' case.
Data receiving
Existance of data to parse is being done with 2 interrupts:
At this stage it's up to the kernel code to involve a DMA transfer
Data transmission
- Minimum transfer size is 60 bytes.
Transfers smaller than this size have to be explicitly handled by the developer.
Summary
Hopefully this description will provide help for people trying to write low-level
software for NetFPGA card.