Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Sending And Receiving Data

Once the port has been opened and the proper mask has been set the application can send and receive frames using the PGP Card.

Sending

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:

  • int fd = file descriptor from previous open
  • void *buf = Buffer containing data to send
  • size_t size = Number of 32-bit values contained in buffer. 
  • uint lane = Lane to send data on
  • uint vc = Virtual channel within the lane to send data on
  • uint cont = Set to '1' if this is not the last transfer in a frame. Normally the application can set this to '0'.

The return value is the total number of 32-bit values transferred or a negative number on error.

  • -1 is returned if there is an error
  • -EAGAIN is returned if the buffer was not ready

Receiving

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:

  • int fd = file descriptor from previous open
  • void *buf = Buffer for received data
  • size_t maxSize = Maximum number of 32-bit values that can be received.
  • uint *lane = Pointer to integer which will be updated with the lane associated with received data
  • uint *vc = Pointer to integer which will be updated with the virtual channel associated with received data
  • uint *eofe = Pointer to integer which will be set to '1' if there was an EOFE received with the frame
  • uint *fifoErr = Pointer to integer which will be set to '1' if there was a FIFO overflow errror (flow control) in the frame
  • uint lengthErr = Pointer to integer which will be set to '1' if there was length error. Either the frame was larger than the allowed buffer or the user buffer was too small.
  • uint cont = Pointer to continue flag. Will be set to '1' if more frame data is expected.

The return value is the total number of 32-bit values received or a negative number on error.

  • -1 is returned if there is an error
  • -EAGAIN is returned if the buffer was not ready

...

Additional Functions

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:

  • __u32 Version = Current firmware version of PGPCard
  • __u32 Pgp#LoopBack = Current loop back status for a lane
  • __u32 Pgp#RxReset; = Current RX reset state for a lane
  • __u32 Pgp#TxReset; = Current TX reset state for a lane
  • __u32 Pgp#LocLinkReady; = Local PGP core is showing link
  • __u32 Pgp#RemLinkReady; = Remote PGP core is showing link (only valid if local is linked)
  • __u32 Pgp#RxReady; = Local RX PHY is ready
  • __u32 Pgp#TxReady; = Local TX PHY is ready
  • __u32 Pgp#RxCount; = Number of received frames for a lane
  • __u32 Pgp#CellErrCnt; = Number of cell errors for a lane
  • __u32 Pgp#LinkDownCnt; = Number of link down events for a lane
  • __u32 Pgp#LinkErrCnt; = Number of link errors for a lane
  • __u32 Pgp#FifoErr; = Number of FIFO overruns for a lane
  • __u32 Pgp#RemData; = Current received side band data for a lane
  • __u32 Pgp#RemBuffStatus; = Flow control status of remote end of the link

All other fields are reserved for development use.

...

Distributed Applications

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.

  • xstatus /dev/pgpcard0 = Will read and display the current status record from the PGP Card
  • xloop lane value = Will set or clear the loopback of a PGP lane. Assume /dev/pgpcard0 is the device. 

...

    • xloop 0 1 = Sets loopback for lane 0
    • xloop 0 0 = Clears loopback for lane 0
  • xrate2 = Will test the card by generating write and read routines for all 4 ports. An optional arg defines the number of virtual channels to test. All four ports must be set in loopback mode for this application to run.
  • xPromLoad = Will program the PgpCard firmware. Use only under the direction of the developer.
  • xPromVerify = Will veriify the PgpCard firmware. Use only under the direction of the developer.

...