GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > GNAT / V2-0-0

Constituent: gnat_cio     Tag: sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

latp.c File Reference

Implements LATp networking protocol functions. More...

#include "latp_p.h"
#include "GNAT/gio.h"
#include "GNAT/bndl.h"
#include "GNAT/latp.h"
#include "gnat_p.h"
#include <string.h>
#include <stdio.h>

Include dependency graph for latp.c:

Include dependency graph

Defines

#define LATP_TYPE_CMD_RSP   (0)
 Expect cmd/rsp data in FIFO.

#define LATP_TYPE_EVENT   (1)
 Expect event data in FIFO.


Functions

int calcParity (unsigned int nWords, unsigned int *arr)
 Calculates the odd parity in arr.

void srvIntr (gnatHandle gh)
 ISR that gives the m_syncSem semaphore when the record FIFO has a packet ready.

int gWaitPacketIRQ (gnatHandle gh)
 Blocks on the ISR semaphore waiting for LATp packet ready IRQ.

int __dumpFIFO (gnatHandle gh, unsigned short nWords)
 Dumps nWords from FIFO (if FIFO is non-empty).

int __errDump (gnatHandle gh)
 Dumps response buffers and response FIFO.

int gReadRsp (gnatHandle gh, gResponse *rspInfo)
 Transfers data from the record FIFO to the rspInfo structure.

int sendLATpCell (gnatHandle gh, LATp_Cell *pCell, unsigned char lastCell)
 Loads a LATp cell into the playback FIFO.

int gLoadPacket (gnatHandle gh, gResponse *rspInfo, unsigned short dest, unsigned short nWord16, unsigned short *payload)
 Loads a LATp packet into the COMM board FIFO.

int gSendPacket (gnatHandle gh, gResponse *rspInfo, unsigned short dest, unsigned short nWord16, unsigned short *payload)
 Sends a LATp packet on the LAT network.

int gSendLAM (gnatHandle gh, unsigned short destAddr)
 Sends the "Look At Me" message to the LAT node destAddr.

int gSetAddr (gnatHandle gh, unsigned short addr)
 Sets the source address of the LATp interface associated with gh.

int gGetAddr (gnatHandle gh, unsigned short *addr)
 Gets the source address of the LATp interface associated with gh.

int gResetCommStats (gnatHandle gh)
 Resets the network statistics for the LATp interface associated with gh.

int gGetTXstats (gnatHandle gh, LATp_TXstats *txStats)
 Returns the current transmission statistics.

int gSetTXstats (gnatHandle gh, LATp_TXstats *txStats)
 Sets the current transmission statistics from txStats.

int gGetRXstats (gnatHandle gh, LATp_RXstats *rxStats)
 Returns the current recieve statistics.

int gSetRXstats (gnatHandle gh, LATp_RXstats *rxStats)
 Sets the current recieve statistics from rxStats.

int gSetLATpChnl (gnatHandle gh, unsigned char chnl)
 Sets the incoming LATp channel number for the board.

int gSetLATpMode (gnatHandle gh, unsigned char mode)
 Sets the running mode of the board.

int gSetProtocol (gnatHandle gh, unsigned short proto)
 Sets the protocol to use.

int gGetProtocol (gnatHandle gh, unsigned short *proto)
 Gets the current LATp protocol.

int gSetTimeout (gnatHandle gh, unsigned short timeout)
 Sets the timeout to use for LATp interface.

int setLATpCellHeaderParity (gnatHandle gh, unsigned short p)
 p determines if the LATp CellHeader Parity is inverted

int getLATpCellHeaderParity (gnatHandle gh, unsigned short *p)
 Returns the current LATp cell header parity setting in p.

int setLATpCellBodyParity (gnatHandle gh, unsigned short p)
 p determines if the LATp CellBody Parity is inverted

int getLATpCellBodyParity (gnatHandle gh, unsigned short *p)
 Returns current LATp CellBody Parity in p.

int setLATpSkipRspWords (gnatHandle gh, unsigned short nSkip)
 nSkip controls how many FIFO words to skip before storing read back data.


Variables

int gnat_irqDelay = 0
 Delay used in taskDelay() before reading FIFO.

unsigned short _LAMpayload []
 Array of 16-bit words to use at paylod for Look At Me command.


Detailed Description

Implements LATp networking protocol functions.

Author:
Curt Brune -- curt@slac.stanford.edu

Function Documentation

__dumpFIFO gnatHandle  gh,
unsigned short  nWords
[static]
 

Dumps nWords from FIFO (if FIFO is non-empty).

Parameters:
gh handle of device
nWords number of words to drain from FIFO.
Returns:
OK on success

Here is the call graph for this function:

__errDump gnatHandle  gh  )  [static]
 

Dumps response buffers and response FIFO.

Parameters:
gh gnat driver handle previously allocated
Returns:
OK on success

Here is the call graph for this function:

int calcParity unsigned int  nWords,
unsigned int *  arr
 

Calculates the odd parity in arr.

Parameters:
nWords Number of unsigned ints in @ arr
arr Array of unsigned ints
Returns:
odd parity of the bits contained in @ arr.

int getLATpCellBodyParity gnatHandle  gh,
unsigned short *  p
 

Returns current LATp CellBody Parity in p.

Parameters:
gh handle of device
p pointer to hold boolean value
Returns:
STATUS
If p is non-zero then all out going LATp packets will have their cell body parity inverted. This is used for testing parity errors. The default value is 0.

int getLATpCellHeaderParity gnatHandle  gh,
unsigned short *  p
 

Returns the current LATp cell header parity setting in p.

Parameters:
gh handle of device
p pointer to hold boolean value
Returns:
STATUS
If p is non-zero then all out going LATp packets will have their cell header parity inverted. This is used for testing parity errors. The default value is 0.

gGetAddr gnatHandle  gh,
unsigned short *  addr
 

Gets the source address of the LATp interface associated with gh.

Parameters:
gh gnat driver handle previously allocated
addr pointer to storage for holding LATp address on return
Returns:
OK for success
See also:
gSetAddr()

gGetProtocol gnatHandle  gh,
unsigned short *  proto
 

Gets the current LATp protocol.

Parameters:
gh handle of device
proto pointer to storage to hold the protocol
See also:
gSetProtocol()
Returns:
OK on success
This gets the protocol field, which is applied to the cell header for all subsequent out bound packets.

gGetRXstats gnatHandle  gh,
LATp_RXstats rxStats
 

Returns the current recieve statistics.

Parameters:
gh gnat driver handle previously allocated
rxStats pointer to storage for holding the RX stats on return
Returns:
OK for success
See also:
gGetTXstats(), gResetCommStats()

gGetTXstats gnatHandle  gh,
LATp_TXstats txStats
 

Returns the current transmission statistics.

Parameters:
gh gnat driver handle previously allocated
txStats pointer to storage for holding the TX stats on return
Returns:
OK for success
See also:
gGetRXstats(), gResetCommStats()

gLoadPacket gnatHandle  gh,
gResponse rspInfo,
unsigned short  dest,
unsigned short  nWord16,
unsigned short *  payload
 

Loads a LATp packet into the COMM board FIFO.

Parameters:
gh gnat driver handle previously allocated
rspInfo pointer to storage for response
dest 6 bit LAT address of destination
nWord16 length of the 16-bit wide payload vector
payload pointer to an array of 16-bit words of length nWord16
Returns:
OK for success
See also:
sendLATpCell

Loads a LATp packet into the COMM board FIFO. Using rspInfo, dest, source it constructs a 16 bit header word for the control cell of the packet. It fills the remainder of the 128-bit control cell with data from payload (up to 14 bytes). The control cell is preceded by a 2 bit delineator and follow by a truncate bit and parity bit -- if the payload is larger than 14 bytes then additional data cells are created and injected with the appropriate delineator and suffix bits.

Caller is responsible for initializing FIFO and for initiating the playback.

Here is the call graph for this function:

gReadRsp gnatHandle  gh,
gResponse rspInfo
 

Transfers data from the record FIFO to the rspInfo structure.

Parameters:
gh gnat driver handle previously allocated
rspInfo pointer to storage to hold response data
After recieving the interrupt for "record FIFO packet ready" readRsp() transfers the packet from the record FIFO to rspInfo->m_rspBuffer;

The routine checks bits 17 and 18 of every 9th FIFO word to determine when the last packet has been processed -- when these bits are both zero we have reached the end of the packet chain (potentially multiple packets, if the packets are back-to-back).

Updates the LATp interface reciever statistics for packets received, cell parity errors and cell header parity errors. The response could contain multiple packets.

Coming off the response FIFO LATp cells are 9 words long. Word 1 has the cell announce and cell type bits, while word 9 has the truncate and parity error bits.

Additionally word 1 also has the cell header if the cell type is a control cell.

Here is the call graph for this function:

gResetCommStats gnatHandle  gh  ) 
 

Resets the network statistics for the LATp interface associated with gh.

Parameters:
gh gnat driver handle previously allocated
Returns:
OK for success
See also:
gGetTXstats(), gGetRXstats()

int gSendLAM gnatHandle  gh,
unsigned short  destAddr
 

Sends the "Look At Me" message to the LAT node destAddr.

Parameters:
gh gnat driver handle previously allocated
destAddr destination address of command
Returns:
G_OK on success
Sends the "Look At Me" message to the LAT node specified by destAddr. This is used to switch the command/response wire used by the LAT node. If the LAT node decodes the "Look At Me" message on either it's A or B command channel it will switch to that channel for future commanding.

Here is the call graph for this function:

gSendPacket gnatHandle  gh,
gResponse rspInfo,
unsigned short  dest,
unsigned short  nWord16,
unsigned short *  payload
 

Sends a LATp packet on the LAT network.

Parameters:
gh gnat driver handle previously allocated
rspInfo pointer to extra information required if command expects a response.
dest 6 bit LAT address of destination
nWord16 length of the 16-bit wide payload vector
payload pointer to an array of 16-bit words of length nWord16
Returns:
OK for success
See also:
sendLATpCell

Sends a LATp packet on the network. Using rspInfo, dest, source it constructs a 16 bit header word for the control cell of the packet. It fills the remainder of the 128-bit control cell with data from payload (up to 14 bytes). The control cell is injected in the network preceded by a 2 bit delineator and follow by a truncate bit and parity bit -- if the payload is larger than 14 bytes then additional data cells are created and injected with the appropriate delineator and suffix bits.

Here is the call graph for this function:

gSetAddr gnatHandle  gh,
unsigned short  addr
 

Sets the source address of the LATp interface associated with gh.

Parameters:
gh gnat driver handle previously allocated
addr LATp address
Returns:
OK for success
See also:
gGetAddr()

gSetLATpChnl gnatHandle  gh,
unsigned char  chnl
 

Sets the incoming LATp channel number for the board.

Parameters:
gh handle of device
chnl channel number
Returns:
OK on success
Sets the incoming LATp channel number of the COMM I/O board when running in LATp mode. Causes a read-modify-write of the COMM I/O control register.

gSetLATpMode gnatHandle  gh,
unsigned char  mode
 

Sets the running mode of the board.

Parameters:
gh handle of device
mode boolean for LATp mode
Returns:
OK on success
Sets the running mode of the COMM I/O board based on the boolean value of mode. When mode is non-zero the mode bit of the COMM I/O control register is set to 1, which puts the board in "LATp mode". When mode is zero the mode bit is cleared, which puts the board in "dumb record FIFO mode".

gSetProtocol gnatHandle  gh,
unsigned short  proto
 

Sets the protocol to use.

Parameters:
gh handle of device
proto 2 LSB define the protocol to use
See also:
gGetProtocol()
Returns:
OK on success
This sets the protocol field of the cell header for all subsequent out bound packets.

gSetRXstats gnatHandle  gh,
LATp_RXstats rxStats
 

Sets the current recieve statistics from rxStats.

Parameters:
gh gnat driver handle previously allocated
rxStats pointer to RX stats to set
Returns:
OK for success
See also:
gGetTXstats(), gResetCommStats()

gSetTimeout gnatHandle  gh,
unsigned short  timeout
 

Sets the timeout to use for LATp interface.

Parameters:
gh handle of device
timeout time in sysclk ticks to wait for response
Returns:
OK on success

gSetTXstats gnatHandle  gh,
LATp_TXstats txStats
 

Sets the current transmission statistics from txStats.

Parameters:
gh gnat driver handle previously allocated
txStats pointer to TX stats to set.
Returns:
OK for success
See also:
gGetRXstats(), gResetCommStats()

gWaitPacketIRQ gnatHandle  gh  ) 
 

Blocks on the ISR semaphore waiting for LATp packet ready IRQ.

Parameters:
gh handle of device
Returns:
OK on success
See also:
gSetTimeout()
Blocks waiting for the ISR semaphore. The timeout value is set using gSetTimeout().

static int sendLATpCell gnatHandle  gh,
LATp_Cell pCell,
unsigned char  lastCell
[static]
 

Loads a LATp cell into the playback FIFO.

Parameters:
gh gnat driver handle previously allocated
pCell pointer to cell to send
lastCell boolean flag, true if this cell is the last cell of a packet.
Returns:
OK for success
See also:
gSendPacket

Loads a 128-bit LATp cell into the GNAT playback FIFO. The cell is preceded by a 2 bit delineator and followed by a truncate bit and parity bit.

Delineator:

  • bit 1 -- always 1 when sending a cell
  • bit 2 -- 1 for control cell, 0 for data cell

Suffix:

  • bit 1 -- truncate bit, set if not last cell in packet, cleared otherwise
  • bit 2 -- odd parity over previous 129 bits

If this cell is the last cell in the packet then two additional trailing zeros are added after the parity bit

Here is the call graph for this function:

int setLATpCellBodyParity gnatHandle  gh,
unsigned short  p
 

p determines if the LATp CellBody Parity is inverted

Parameters:
gh handle of device
p boolean value
Returns:
STATUS
If p is non-zero then all out going LATp packets will have their cell body parity inverted. This is used for testing parity errors. The default value is 0.

int setLATpCellHeaderParity gnatHandle  gh,
unsigned short  p
 

p determines if the LATp CellHeader Parity is inverted

Parameters:
gh handle of device
p boolean value
Returns:
STATUS
If p is non-zero then all out going LATp packets will have their cell header parity inverted. This is used for testing parity errors. The default value is 0.

int setLATpSkipRspWords gnatHandle  gh,
unsigned short  nSkip
 

nSkip controls how many FIFO words to skip before storing read back data.

Parameters:
gh handle of device
nSkip number of read back FIFO words to skip
Returns:
STATUS
Warning: This is only used for testing. The default value is 0 and should never be changed in normal operation.

Setting nSkip to a non-zero value causes the read back routine to skip nSkip FIFO words (read and discard) before storing the data.

This allows us to arbitrarily fill the record FIFO with N junk words and then instruct the read back routines to skip over the N junk words before reading and storing the data. With this technique we can probe the TEM to COMM flow control based on the Almost Full Flag of the record FIFO.

void srvIntr gnatHandle  gh  ) 
 

ISR that gives the m_syncSem semaphore when the record FIFO has a packet ready.

Parameters:
gh gnat driver handle previously allocated
Returns:
void


Variable Documentation

static unsigned short _LAMpayload[] [static]
 

Initial value:

 {
  0x9C3E, 
  0x07F0, 
  0x0FF8, 
  0x01FF, 
  0xC003, 
  0xFFE0, 
  0x007F, 
}
Array of 16-bit words to use at paylod for Look At Me command.


Generated on Thu Oct 21 08:29:13 2004 by doxygen 1.3.3