This page describes the LSST version of the PGP Card Gen2 driver. This version of the driver was setup to support additional features required for the LSST project.
These new features include:
This version of the driver will be converted to the baseline driver and may be renamed to PgpDriverMask.
The driver can be obtained in the SLAC subversion repository:
> svn checkout file:///afs/slac/g/reseng/svn/repos/pgpcard/trunk/software/lsst_driver
Or from your contact at SLAC.
Go to the driver sub-directory and build:
> cd driver
> make
You will need to make the appropriate kernel headers and development packages installed. Contact rherbst@slac.stanford.edu if you have any issues. The kernel has been compiled in all recent versions of the Linux kernel.
A script exists in the driver sub-directory to install the driver and create the appropriate device files (future versions of the driver will self-create the device files, but this has not yet been added).
> ./pgpcard_load
This will create the file /dev/pgpcard0 for driver access.
Accessing the PGP Card driver makes use of a set of inline wrapper functions defined in include/PgpCardWrap.h. This file must be included in applications along with include/PgpCardMod.h which includes the structures shared between the driver and user space code.
Example code for opening the device:
s = open("/dev/pgpcard0", O_RDWR);
The call will return a file descriptor if the operations success or -1 on failure. Multiple devices are allowed to open a pgpcard device.
After opening you will need to set the mask for the channels you will be receiving data for:
> pgpcard_setMask(s,0xFFFF);
The above call will allow reception for all 4 virtual channels on all 4 physical lanes supported by the PGP Card. The mapping of this mask is:
Currently the driver only uses the mask when receiving data. All processes/threads can write on all lanes and virtual channels.
The card then be closed using a standard close command
> close (s)
Any reserved lane/VCs will be released and the associated queues will be drained and released.
Once the port has been opened and the proper mask has been set the application can send and receive frames using the PGP Card.
The declaration for the send function is:
inline int pgpcard_send(int fd, void *buf, size_t size, uint lane, uint vc, uint cont=0);
The passed args are:
The return value is the total number of 32-bit values transferred or a negative number on error.
The declaration for the receive function is:
inline int pgpcard_recv(int fd, void *buf, size_t maxSize, uint *lane, uint *vc, uint *eofe, uint *fifoErr, uint *lengthErr, uint *cont=NULL);
The passed args are:
The return value is the total number of 32-bit values received or a negative number on error.
The PgpCardWrap.h file contains additional functions which can be used:
inline int pgpcard_status(int fd, PgpCardStatus *status);
Updates the passed status pointer with the current status of the card. The structure of the status record can be found in PgpCardMod.h
inline int pgpcard_setDebug(int fd, uint level);
This function enables addition debugging to the kernel log. Normally not used by users.
inline int pgpcard_setRxReset(int fd, uint lane);
inline int pgpcard_clrRxReset(int fd, uint lane);
inline int pgpcard_setTxReset(int fd, uint lane);
inline int pgpcard_clrTxReset(int fd, uint lane);
Assert or clear the receive or transmit reset for a PGP lane. Used when the receiver or transmitter won't link or is not behaving. Usually not needed in normal operation.
inline int pgpcard_setLoop(int fd, uint lane);
inline int pgpcard_clrLoop(int fd, uint lane);
Enable or disable loopback for a particular lane. Setting this will allow a PGP port to link to itself. Any sent frames will be received on the same lane.
inline int pgpcard_setData(int fd, uint lane, uint data);
Set the currently transmitted side band data for a lane. The currently received sideband data can be found in the status record. This is not used in most applications.
inline int pgpcard_rstCount(int fd);
Reset all counters reported in the status record.
inline int pgpcard_dumpDebug(int fd);
Dumps internal buffer states to the kernel log.
Status Record
The following fields are available in the status record:
All other fields are reserved for development use.
There is a sub directory called app in the distributed driver software. This directory contains a number of applications that are used to test and monitor the PGP Card. These applications can be compiled by typing 'make' in the app directory.