GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LCBD / dev > lcbd / rhel4-32
#include <LCBD/LCBD_drv.h>
#include <LCBD/LCBD_pci.h>
#include <LCBD/LCBD_msgs.h>
#include <LCBD/LCB.h>
#include <LCBD/LCB_cr.h>
#include <LCBD/LCBC.h>
#include <LCBD_p.h>
#include <PBS/L.ih>
#include <PBS/FORK.h>
#include <PBS/MBA.h>
#include <PBS/SPIN.h>
#include <PBS/RW.ih>
#include <PBS/RW_protos.h>
#include <PBI/Attribute.h>
#include <string.h>
#include <PBS/INT.ih>
#include <stdio.h>
Classes | |
struct | _FpgaList |
Structure defining the list of supported Fpgas. More... | |
Defines | |
#define | FABRIC_SELECT_TIMEOUT 10000 |
The timeout period, in nanoseconds, that one is willing to wait for the clock to show up after doing a fabric select. | |
Typedefs | |
typedef struct _FpgaList | FpgaList |
Typedef for struct _FpgaList. | |
Functions | |
static unsigned int | connect (LCBD lcb, unsigned int options) |
Connects the LCBD to the interrupt source. | |
static unsigned int | disconnect (LCBD lcb) |
Disconnects the LCBD from the interrupt source. | |
static unsigned int | clk_handler (void *unused, LCBD lcb) |
Default clock off -> on and clock on -> off handler. | |
static unsigned int | evt_def_handler (void *unused, unsigned int ed, LCBD_evt *evt) |
Default event handler. | |
static unsigned int | init_pci (LCBD lcb) |
Initializes the LCBD structure -- probes the PCI bus. | |
static unsigned int | init_latp (LCBD lcb, unsigned int options, unsigned int *event_base, LCBD_load_cb notify, void *prm) |
Laundry list of LCBD initializations to do on the LATp side. | |
static unsigned int | init_latp_clk_on (LCBD lcb, unsigned int options, unsigned int *event_base) |
Complete LCBD initializations of LATp side. | |
static unsigned int | init_latp_clk_on_isr (SEM semaphore, LCBD lcb) ATTR_UNUSED_OK |
Clock interrupt callback routine to complete LATp-side initialization. | |
static unsigned int | init_latp_clk_on_entry (LCBD lcb) ATTR_UNUSED_OK |
The asynchronous LATp-side initialization call back handler. | |
static unsigned int | init_circ (LCBD lcb, unsigned int *event_base, int fill) |
Allocates memory for and sets it up to be used as the circular buffer. | |
static unsigned int | init_sw (LCBD lcb) |
Laundry list of LCBD initializations to do on the software side. | |
static unsigned int | destroy_sw (LCBD lcb) |
Laundry list of LCBD shutdowns to do on the software side. | |
static unsigned int | drain_result (LCBD lcb) |
Drains the result FIFOs. | |
static unsigned int | drain_event (LCBD lcb) |
Drains the event FIFOs. | |
static unsigned int | check (unsigned int rd, unsigned int error, const char *name) |
Checks for and reports both IO and ITEM errors. | |
static unsigned int | poll (LCBD lcb, unsigned int nsecs, int iterations) |
Polls the RESULT FIFO every nsecs for @ iterations. | |
static unsigned int | destroy_handler (LCBD_hcb *hcb, unsigned int failure) |
Destroys a FORK processing task, iff it was created by the LCBD driver. | |
static void | select_fabric (unsigned int volatile *fabric, unsigned int select) |
Accesses the fabric select register, writing the fabric select bit and waits for either the clock to show up or a timeout period to expire. | |
static unsigned int | submit (LCBD lcb, unsigned int request) |
Submits the specified request list to the LCB for execution. | |
static unsigned int | poll_reg_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur, unsigned int header) |
Performs an access to the LATP register. | |
static unsigned int | poll_csr_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur) |
Performs an access to the LATP CSR register. | |
static unsigned int | poll_faults_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur) |
Performs an access to the LATP FAULTS register. | |
static unsigned int | clear_faults (LCBD lcb, unsigned short int stall) |
Clears the FIFO faults register. | |
static void | lcbd_isr (LCBD lcb) |
Central ISR that dispatches LCB result descriptors. | |
unsigned int | lcbd_csr_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur) |
Utility routine to compose and execute an access command to LCB's CSR register independent of whether the driver is offline or online. | |
unsigned int | lcbd_faults_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur) |
Utility routine to compose and execute an access command to LCB's FAULTS register independent of whether the driver is offline or online. | |
unsigned int | LCBD_allow (unsigned char pci_version, unsigned char latp_version) |
Adds the specified PCI and LATP version number combination as being supported by this driver. | |
unsigned int | LCBD_board_id_set (LCBD lcb, int new_board_id, int *org_board_id) |
Sets the LATp board Id, returning the orginal board id. | |
unsigned int | LCBD_clk_edge_set (LCBD lcb, unsigned int new_options, unsigned int *org_options) |
Sets the clock options. | |
LCBD | LCBD_create (LCBD lcb) |
Preinitializes the LCBD device control block. | |
const LCBD_dib * | LCBD_dib_locate (LCBD lcb) |
Returns a readonly pointer to the LCB's device information block. | |
void | LCBD_dib_show (const LCBD_dib *dib) |
Shows (prints to the terminal) the Device Information Block. | |
unsigned int | LCBD_drain (LCBD lcb, int which) |
Drains the specified ques. | |
unsigned int | LCBD_enable (LCBD lcb, unsigned int enables) |
Sets the enable/disable flags controlling the EVENT and RESULT interrupts. | |
unsigned int | LCBD_fabric_read (LCBD lcb) |
Reads the fabric select register. | |
unsigned int | LCBD_fabric_select (LCBD lcb, unsigned int fabric) |
Sets the fabric to specified value. | |
unsigned int | LCBD_faults_read (LCBD lcb, unsigned int clear, unsigned int *prv, unsigned int *cur) |
Reads the LATp faults register and, optionally, clears the specified bits. | |
LCBD | LCBD_get (void) |
Returns a pointer to the driver control structute. | |
unsigned int | LCBD_load (LCBD lcb, unsigned int options, unsigned int *event_base) |
Initializes the LCB hardware and LCBD software. | |
unsigned int | LCBD_load_cancel (LCBD lcb) |
Cancels the Waiting for the LCBD_load_init completion. | |
unsigned int | LCBD_load_init (LCBD lcb, unsigned int options, unsigned int *event_base, LCBD_load_cb notify, void *prm) |
Initializes the LCB hardware and LCBD software. | |
void | LCBD_load_notify (void *semaphore, LCBD lcb, unsigned int status) |
Pre-canned LCBD load notification callback routine. | |
unsigned int | LCBD_load_wait (LCBD lcb) |
Waits for the LCBD_load_init completion. | |
unsigned int | LCBD_pci_cfg_status_clear (LCBD lcb) |
Clears the PCI configuration space status word. | |
LCBD_state | LCBD_state_get (LCBD lcb) |
Returns the current state of the driver. | |
unsigned int | LCBD_unload (LCBD lcb) |
Unloads the LCB driver. | |
unsigned int | LCBD_width_set (LCBD lcb, int new_width, int *org_width) |
Sets the LATp event fabric data path width, returning the original data path width setting. | |
static __inline unsigned int | init_dib (LCBD_dib *dib) |
Initializes the Device Information Block. | |
static __inline unsigned int | check_pci_version (const FpgaList *fpga, unsigned char pci_version) |
Checks if the pci version is in the list of acceptable versions. | |
static __inline unsigned int | check_fpgas_version (const FpgaList *fpga, unsigned char pci_version, unsigned char latp_version) |
Checks if the combined PCI/LATP versions is in the list of acceptable versions. | |
static __inline void | init_evt_cbp (LCBD_evt_cbp evt[LCBD_EVT_PROTO_CNT], LCBD_evt_cb defaultHandler, void *defaultParameter) |
Initializes all event fabric protocol handlers to a default callback and parameter. | |
static __inline unsigned int | init_evt_fcb (LCBD_evt_fcb *fcb, unsigned int *event_base) |
Initializes the event free control block. | |
static __inline int | init_ucb (LCBD_ucb *ucb, LCBD lcb) |
Initializes the Unit Control block. | |
static __inline int | destroy_ucb (LCBD_ucb *ucb, LCBD lcb) |
Shutsdown the Unit(s) Control block. | |
static __inline unsigned int | destroy_result_handler (LCBD lcb) |
Destroys the result que service task, iff it was created by the LCBD driver. | |
static __inline unsigned int | destroy_event_handler (LCBD lcb) |
Destroys the event que service task, iff it was created by the LCBD driver. | |
unsigned int | lcbd_create_handler (LCBD_hcb *hcb, const char *name, int priority, LCBD lcb, int que_cnt, const FORK_que_cfg *que_cfg, int que_id, unsigned int failure) |
Creates a FORK processing task. | |
static __inline unsigned int | handle_clks (LCBD_clk_ucb *clk, LCBD_stats_isr *stats, LCBD lcb, unsigned int clock, unsigned int pending, unsigned int enabled) |
Handles the clock interrupts. | |
Variables | |
static FpgaList | Fpga |
List of correlated PCI,LATP FPGA versions that this driver is compatiable with. | |
static struct _LCBD | Lcb |
The actual storage for the driver control block. |
The next step is to drain the FIFOs, but this depends on whether the LCB is a commander or a responder
Problems associated with the draining of each FIFOs must be considered separately.
If the LCB is being used as a responder, then it is very possible that one will find a result item sent by the commander (SIU) that contains the board address to assign to this LCB. This is also a signal that the LCB LATp side clock is now running, so one can now perform operations to the LATp side (ie proceed with the LATp side initialization phase.
#define FABRIC_SELECT_TIMEOUT 10000 |
The timeout period, in nanoseconds, that one is willing to wait for the clock to show up after doing a fabric select.
Referenced by select_fabric().
static unsigned int check | ( | unsigned int | rd, | |
unsigned int | error, | |||
const char * | name | |||
) | [static] |
Checks for and reports both IO and ITEM errors.
0,If | OK | |
!=0,An | LCB message code if not OK |
rd | The result descriptor | |
error | The item error field | |
name | The name of the calling function. |
References LCB_RST_DSC_M_XSTATUS, LCB_RST_ERR_XFR_CNT, LCBD_rst_rcv_err_map(), and LCBD_rst_xfr_err_map().
Referenced by drain_result(), notify(), and poll_reg_access().
static __inline LCBD_FPGA_SUP_K check_fpgas_version | ( | const FpgaList * | fpga, | |
unsigned char | pci_version, | |||
unsigned char | latp_version | |||
) | [static] |
Checks if the combined PCI/LATP versions is in the list of acceptable versions.
References _FpgaList::dcnt, LCBD_FPGA_SUP_K_BACKWARD, LCBD_FPGA_SUP_K_GOLDEN, LCBD_FPGA_SUP_K_NOT, LCBD_FPGA_SUP_K_USER, _FpgaList::pairs, and _FpgaList::tcnt.
Referenced by init_latp_clk_on().
static __inline unsigned int check_pci_version | ( | const FpgaList * | fpga, | |
unsigned char | pci_version | |||
) | [static] |
Checks if the pci version is in the list of acceptable versions.
fpga | The counted list of acceptable correlated PCI/LATp FPGAs to scan | |
pci_version | The PCI FPGA version number |
References _FpgaList::pairs, and _FpgaList::tcnt.
Referenced by init_pci().
static unsigned int clear_faults | ( | LCBD | lcb, | |
unsigned short int | stall | |||
) | [static] |
Clears the FIFO faults register.
lcb | The LCB driver handle | |
stall | A stall value (in units of LATp clocks) |
References poll_faults_access().
Referenced by init_latp_clk_on().
static unsigned int clk_handler | ( | void * | unused, | |
LCBD | lcb | |||
) | [static] |
Default clock off -> on and clock on -> off handler.
0,always |
unused | Not used | |
lcb | The LCBD control structure |
Referenced by init_ucb().
static unsigned int connect | ( | LCBD | lcb, | |
unsigned int | options | |||
) | [static] |
Connects the LCBD to the interrupt source.
lcb | Pointer to private LCBD structure | |
options | The connect options |
References lcbd_isr(), and LCBD_OK.
Referenced by LCBD_load_init().
static __inline unsigned int destroy_event_handler | ( | LCBD | lcb | ) | [static] |
Destroys the event que service task, iff it was created by the LCBD driver.
lcb | The LCBD driver handle |
References destroy_handler().
Referenced by destroy_sw().
static unsigned int destroy_handler | ( | LCBD_hcb * | hcb, | |
unsigned int | failure | |||
) | [static] |
Destroys a FORK processing task, iff it was created by the LCBD driver.
hcb | The LCBD handler control block, upon success, this is filled in with information about the newly created FORK task. | |
failure | Status code to use in case of failure |
References _LCBD_hcb::fcb, LCBD_OK, and _LCBD_hcb::que.
Referenced by destroy_event_handler(), and destroy_result_handler().
static __inline unsigned int destroy_result_handler | ( | LCBD | lcb | ) | [static] |
Destroys the result que service task, iff it was created by the LCBD driver.
lcb | The LCBD driver handle |
References destroy_handler().
Referenced by destroy_sw().
static unsigned int destroy_sw | ( | LCBD | lcb | ) | [static] |
Laundry list of LCBD shutdowns to do on the software side.
lcb | A previously PCI/LATp initialized LCBD handle |
References destroy_event_handler(), destroy_result_handler(), destroy_ucb(), lcbd_nut_handler_destroy(), LCBD_OK, and LCBD_stats_destroy().
Referenced by LCBD_unload().
static __inline int destroy_ucb | ( | LCBD_ucb * | ucb, | |
LCBD | lcb | |||
) | [static] |
Shutsdown the Unit(s) Control block.
ucb | The dispatch control block | |
lcb | The LCB driver handle |
References _LCBD_rst_ucb::ccb, _LCBD_ucb::evt, _LCBD_evt_ucb::fcb, _LCBD_rst_ucb::fmsg, LCBD_OK, _LCBD_evt_fcb::mutex, _LCBD_rst_ccb::pend, _LCBD_rst_ccb::post, _LCBD_rst_flush_msg::que, _LCBD_ucb::rst, and _LCBD_rst_ccb::rw.
Referenced by destroy_sw().
static unsigned int disconnect | ( | LCBD | lcb | ) | [static] |
Disconnects the LCBD from the interrupt source.
lcb | Pointer to private LCBD structure |
References lcbd_isr(), and LCBD_OK.
Referenced by LCBD_unload().
static unsigned int drain_event | ( | LCBD | lcb | ) | [static] |
Drains the event FIFOs.
0 | if successfully drained |
lcb | Initialized LCBD handle |
References _LCB_evt_dsc::bf, LCB_RST_ERR_XFR_OUT_Q_EMPTY, LCBD__pciLoad32(), LCBD_OK, _LCB_evt_dsc::ui, and _LCB_evt_dsc_bf::xstatus.
Referenced by init_latp_clk_on(), and LCBD_drain().
static unsigned int drain_result | ( | LCBD | lcb | ) | [static] |
Drains the result FIFOs.
0 | if successfully drained |
lcb | Initialized LCBD handle |
In the last case, an attempt is made to clear an remaining transactions. Could one get into trouble here be taking too long. Don't think so. The request FIFO can only execute 2 commands at a time so the only way there could be a lot of transactions to dispose of is if they are already in the result que. The result FIFO is a maximum of 4Kbytes or 1K transactions in length, Therefore the maximum time will be something like 1K * 2 usecs (the 2 usecs being a generous estimate of the PCI read of the result FIFO.) + the time of complete of the sweeping transaction (something like 10usecs) for a total of about .2msecs.
References _LCB_ri_err::bf, _LCB_rst_dsc::bf, check(), _LCB_ri_err_bf::err, _LCB_ri_simple::err, _LCB_cl_simple::hdr, _LCB_ci_simple::header, _LCB_rl_simple::item, _LCB_cl_simple::item, LCB_CI_HDR_MARK_TIME, LCB_RST_ERR_XFR_OUT_Q_EMPTY, poll(), _LCB_cl_hdr::result, _LCB_ci_simple::stall, submit(), _LCB_rst_dsc::ui, and _LCB_rst_dsc_bf::xstatus.
Referenced by init_latp_clk_on(), and LCBD_drain().
static unsigned int evt_def_handler | ( | void * | unused, | |
unsigned int | ed, | |||
LCBD_evt * | evt | |||
) | [static] |
Default event handler.
0,i.e,just | free the event |
unused | The user parameter | |
ed | The event descriptor | |
evt | The event |
Referenced by init_ucb().
static __inline unsigned int handle_clks | ( | LCBD_clk_ucb * | clk, | |
LCBD_stats_isr * | stats, | |||
LCBD | lcb, | |||
unsigned int | clock, | |||
unsigned int | pending, | |||
unsigned int | enabled | |||
) | [static] |
Handles the clock interrupts.
The | value to or into the source mask to remove the clock interrupts |
clk | Pointer to the clock control structure | |
stats | ISR statistics block | |
lcb | The LCBD driver handle | |
clock | The current state of the 20MHz clock | |
pending | Which clock interrupts are currently pending | |
enabled | Which clock interrupts are currently enabled |
References _LCBD_siv::bf, _LCBD_stats_isr::err, LCB_IRQ_K_CLK_OFF, LCB_IRQ_K_CLK_ON, LCB_IRQ_M_CLK_OFF, LCB_IRQ_M_CLK_ON, LCB_PCI_IRQ_M_ENABLE_CLK_OFF, LCB_PCI_IRQ_M_ENABLE_CLK_ON, LCB_PCI_IRQ_V_DISABLE, lcbd_nut_post(), lcbd_rst_flush_handler(), LCBD_STATE_OFFLINE, LCBD_STATE_ONLINE, _LCBD_clk_ucb::off, _LCBD_clk_ucb::on, _LCBD_clk_off_cbp::prm, _LCBD_clk_on_cbp::prm, _LCBD_clk_off_cbp::rtn, _LCBD_clk_on_cbp::rtn, _LCBD_clk_ucb::state, _LCBD_siv::ui, and _LCBD_siv::us.
Referenced by lcbd_isr().
static unsigned int init_circ | ( | LCBD | lcb, | |
unsigned int * | event_base, | |||
int | fill | |||
) | [static] |
Allocates memory for and sets it up to be used as the circular buffer.
LCBD_OK | If successful | |
LCBD_INSEBUF | If insufficient memory to allocate event buffer | |
LCBD_INVEBUF | If invalid event buffer (misaligned) |
lcb | The LCBD driver handle | |
event_base | The bae address of the event buffer. If NULL, an event buffer will be allocated. | |
fill | Flag indicating whether to fill the buffer |
References init_evt_fcb(), LCB_EVENT_BUFFER_ALIGN, LCB_EVENT_BUFFER_TOTAL, LCBD__pciStore32(), and LCBD_K_EVENT_BASE_ALLOCATE.
Referenced by init_latp_clk_on().
static __inline unsigned int init_dib | ( | LCBD_dib * | dib | ) | [static] |
Initializes the Device Information Block.
Status
dib | The Device Information Block to nitialize |
References _LCBD_dib::irq, _LCBD_dib::latp_rev, LCBD_OK, _LCBD_dib::lcl2pci, _LCBD_dib::pci2lcl, _LCBD_dib::pci_bus, _LCBD_dib::pci_dev, _LCBD_dib::pci_func, _LCBD_dib::pci_rev, and _LCBD_dib::reg.
Referenced by init_pci().
static __inline void init_evt_cbp | ( | LCBD_evt_cbp | evt[LCBD_EVT_PROTO_CNT], | |
LCBD_evt_cb | defaultHandler, | |||
void * | defaultParameter | |||
) | [static] |
Initializes all event fabric protocol handlers to a default callback and parameter.
evt | The array of event fabric protocol handlers | |
defaultHandler | The default handler | |
defaultParameter | The default parameter |
Referenced by init_ucb().
static __inline unsigned int init_evt_fcb | ( | LCBD_evt_fcb * | fcb, | |
unsigned int * | event_base | |||
) | [static] |
Initializes the event free control block.
LCBD_OK,if | OK, | |
LCBD_FCBMTXI,if | failed to create locking mutex |
fcb | Pointer to the event free control block | |
event_base | The event base pointer |
References _LCBD_evt_fcb::last, LCBD_OK, _LCBD_evt_fcb::mutex, _LCBD_evt_fcb::read, and _LCBD_evt_fcb::reenable.
Referenced by init_circ().
static unsigned int init_latp | ( | LCBD | lcb, | |
unsigned int | options, | |||
unsigned int * | event_base, | |||
LCBD_load_cb | notify, | |||
void * | prm | |||
) | [static] |
Laundry list of LCBD initializations to do on the LATp side.
LCBD_OK | ||
LCBD_NOCLK | ||
A | status code |
lcb | A previously PCI initialized LCBD handle | |
options | The options word. Currently this routine examines the path selection | |
event_base | The base address of the event buffer. Two special values can be used here
| |
notify | The notification callback | |
prm | The notification parameter |
References init_latp_clk_on(), init_latp_clk_on_entry(), init_latp_clk_on_isr(), LCB_PCI_CSR_M_CLK, LCBD__pciLoad32(), LCBD__pciStore32(), LCBD_AIB_ACTION_AVAILABLE, LCBD_AIB_ACTION_COMPLETE, LCBD_load_notify(), LCBD_load_wait(), LCBD_M_ENABLE_CLK_ON, LCBD_OK, LCBD_STATE_OFFLINE, and select_fabric().
Referenced by LCBD_load_init().
static unsigned int init_latp_clk_on | ( | LCBD | lcb, | |
unsigned int | options, | |||
unsigned int * | event_base | |||
) | [static] |
Complete LCBD initializations of LATp side.
LCBD_OK | ||
LCBD_NOCLK | ||
A | status code |
lcb | A previously PCI initialized LCBD handle | |
options | The options word. Currently this routine examines the path selection | |
event_base | The base address of the event buffer. |
References _LCB_csr::bf, check_fpgas_version(), clear_faults(), drain_event(), drain_result(), init_circ(), LCB_CSR_M_EVT_ENABLE, LCB_PCI_CSR_M_CLK, LCBD_K_EVENT_BASE_IGNORE, LCBD_K_INTERNAL_OP_STALL, poll_csr_access(), _LCB_csr::ui, and _LCB_csr_bf::version.
Referenced by init_latp(), and init_latp_clk_on_entry().
static unsigned int init_pci | ( | LCBD | lcb | ) | [static] |
Initializes the LCBD structure -- probes the PCI bus.
lcb | Pointer to private LCBD structure |
References check_pci_version(), init_dib(), LCB_PCI_IRQ_M_DISABLE_ALL, LCBD__pciStore32(), and LCBD_OK.
Referenced by LCBD_load_init().
static unsigned init_sw | ( | LCBD | lcb | ) | [static] |
Laundry list of LCBD initializations to do on the software side.
lcb | A previously PCI/LATp initialized LCBD handle |
References init_ucb(), LCBD_OK, and LCBD_stats_init().
Referenced by LCBD_load_init().
static __inline unsigned int init_ucb | ( | LCBD_ucb * | ucb, | |
LCBD | lcb | |||
) | [static] |
Initializes the Unit Control block.
ucb | The unit(s) control block | |
lcb | The LCB driver handle |
References _LCBD_rst_ucb::ccb, _LCBD_ucb::clk, clk_handler(), _LCBD_ucb::evt, evt_def_handler(), _LCBD_rst_ucb::fmsg, _LCBD_evt_ucb::handler, init_evt_cbp(), LCBD_OK, _LCBD_clk_ucb::off, _LCBD_clk_ucb::on, _LCBD_rst_ccb::pend, _LCBD_rst_ccb::post, _LCBD_clk_off_cbp::prm, _LCBD_clk_on_cbp::prm, _LCBD_rst_flush_msg::que, _LCBD_ucb::rst, _LCBD_clk_off_cbp::rtn, _LCBD_clk_on_cbp::rtn, and _LCBD_rst_ccb::rw.
Referenced by init_sw().
unsigned int LCBD_allow | ( | unsigned char | pci_version, | |
unsigned char | latp_version | |||
) |
Adds the specified PCI and LATP version number combination as being supported by this driver.
LCBD_OK,if | successfully added | |
LCBD_NOROOM,if | there is no room to add this version combination |
pci_version | The PCI FPGA version to allow | |
latp_version | The LATp FPGA version to allow |
References LCBD_OK, _FpgaList::pairs, and _FpgaList::tcnt.
unsigned int LCBD_board_id_set | ( | LCBD | lcb, | |
int | new_board_id, | |||
int * | org_board_id | |||
) |
Sets the LATp board Id, returning the orginal board id.
Status |
lcb | The LCB driver handle | |
new_board_id | The new board id | |
org_board_id | Returned as the value of the board id before it was changed. May be specified as NULL. |
References _LCB_csr::bf, _LCB_csr_bf::boardID, LCB_CSR_M_BOARD_ID, LCB_CSR_V_BOARD_ID, lcbd_csr_access(), LCBD_K_INTERNAL_OP_STALL, and _LCB_csr::ui.
unsigned int LCBD_clk_edge_set | ( | LCBD | lcb, | |
unsigned int | new_options, | |||
unsigned int * | org_options | |||
) |
Sets the clock options.
Status |
lcb | The LCB driver handle | |
new_options | The new options | |
org_options | Returned as the value of the options before they were changed. May be specified as NULL. |
References _LCB_csr::bf, _LCB_csr_bf::iclkTrailing, LCB_CSR_V_ICLK_TRAILING, lcbd_csr_access(), LCBD_K_INTERNAL_OP_STALL, _LCB_csr_bf::oclkTrailing, and _LCB_csr::ui.
LCBD_create | ( | LCBD | lcb | ) |
Preinitializes the LCBD device control block.
lcb | Pointer to the LCBD device control block to preinitialize. If this is NULL, then the block is located using LCBD_get () |
References Lcb.
unsigned int lcbd_create_handler | ( | LCBD_hcb * | hcb, | |
const char * | name, | |||
int | priority, | |||
LCBD | lcb, | |||
int | que_cnt, | |||
const FORK_que_cfg * | que_cfg, | |||
int | que_id, | |||
unsigned int | failure | |||
) |
Creates a FORK processing task.
hcb | The LCBD handler control block, upon success, this is filled in with information about the newly created FORK task. | |
name | The name of the FORK task | |
priority | The priority of the task | |
lcb | Used as the callback parameter to the handler | |
que_cnt | The number of queues to configure | |
que_cfg | The configuration of each que | |
que_id | The que id to use for the handler | |
failure | Status code to use in case of failure |
References _LCBD_hcb::fcb, LCBD_OK, and _LCBD_hcb::que.
Referenced by LCBD_evt_handler_create(), LCBD_nut_handler_create(), and LCBD_rst_handler_create().
unsigned int lcbd_csr_access | ( | LCBD | lcb, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall, | |||
unsigned int * | prv, | |||
unsigned int * | cur | |||
) |
Utility routine to compose and execute an access command to LCB's CSR register independent of whether the driver is offline or online.
lcb | The LCB driver handle | |
value | The value to write. Only bits matching those in the field_select parameter will actually be written. | |
field_select | Pattern of those bits in value to write | |
stall | The stall period, in units of 20MHz clock ticks, for the LCB to wait for completion. | |
prv | Pointer to receive the value of the register before modification. This may be NULL. | |
cur | Pointer to receive the value of the register after modification. This may be NULL. |
References LCBC_csr_access(), LCBD_STATE_ONLINE, and poll_csr_access().
Referenced by LCBD_board_id_set(), LCBD_clk_edge_set(), LCBD_evt_enable(), and LCBD_width_set().
const LCBD_dib * LCBD_dib_locate | ( | LCBD | lcb | ) |
Returns a readonly pointer to the LCB's device information block.
lcb | Pointer to private LCBD structure |
void LCBD_dib_show | ( | const LCBD_dib * | dib | ) |
Shows (prints to the terminal) the Device Information Block.
dib | The Device Information Block to show |
References _LCBD_dib::fpga_sup, _LCBD_dib::irq, _LCBD_dib::latp_rev, LCBD_FPGA_SUP_K_MIN, _LCBD_dib::lcl2pci, _LCBD_dib::pci2lcl, _LCBD_dib::pci_bus, _LCBD_dib::pci_dev, _LCBD_dib::pci_func, _LCBD_dib::pci_rev, and _LCBD_dib::reg.
unsigned int LCBD_drain | ( | LCBD | lcb, | |
int | which | |||
) |
Drains the specified ques.
lcb | The LCBD driver handle | |
which | Which ques to drain, a bit mask of LCBD_QUES_M_RESULT and LCBD_QUES_M_EVENT |
References drain_event(), drain_result(), LCBD_OK, LCBD_QUES_M_EVENT, and LCBD_QUES_M_RESULT.
Referenced by LCBD_unload().
unsigned int LCBD_enable | ( | LCBD | lcb, | |
unsigned int | enables | |||
) |
Sets the enable/disable flags controlling the EVENT and RESULT interrupts.
LCBD_OK,on | success | |
LCBD_ISRQUEUE,if | one or both of the result/event being enabled does not have a service FORK task/que associated with it. |
lcb | Pointer to private LCBD structure | |
enables | A bit mask of
|
Unless explicitly stated, when enabling or disabling the event interrupt, the sub-interrupt condition of the circular buffer full will also be enabled or disabled. To explicitly prohibit this action, specify LCBD_M_CBUF_ENABLE or LCBD_M_CBUF_DISABLE.
References _LCB_prb::csr, _LCB_prb::irq, LCB_IRQ_K_SRC_CNT, LCB_PCI_CSR_M_CLK, LCBD__pciLoad32(), LCBD__pciStore32(), LCBD_M_DISABLE_CBUF, LCBD_M_DISABLE_EVENT, LCBD_M_DISABLE_RESULT, LCBD_M_ENABLE_CBUF, LCBD_M_ENABLE_EVENT, LCBD_M_ENABLE_RESULT, LCBD_OK, LCBD_STATE_OFFLINE, and LCBD_STATE_ONLINE.
Referenced by LCBD_unload().
unsigned int LCBD_fabric_read | ( | LCBD | lcb | ) |
Reads the fabric select register.
lcb | Pointer to private LCBD structure |
References LCBD__pciLoad32().
unsigned int LCBD_fabric_select | ( | LCBD | lcb, | |
unsigned int | fabric | |||
) |
Sets the fabric to specified value.
lcb | Pointer to private LCBD structure | |
fabric | The value to set the fabric to, i.e. one of LCBD_FABRIC_PRIMARY or LCBD_FABRIC_REDUNDANT. |
References LCBD__pciLoad32(), and select_fabric().
unsigned int lcbd_faults_access | ( | LCBD | lcb, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall, | |||
unsigned int * | prv, | |||
unsigned int * | cur | |||
) |
Utility routine to compose and execute an access command to LCB's FAULTS register independent of whether the driver is offline or online.
lcb | The LCB driver handle | |
value | The value to write. Only bits matching those in the field_select parameter will actually be written. | |
field_select | Pattern of those bits in value to write | |
stall | The stall time, in units of 20MHz clock ticks, for the LCB to wait for completion. | |
prv | Pointer to receive the value of the register before modification. This may be NULL. | |
cur | Pointer to receive the value of the register after modification. This may be NULL. |
References LCBC_faults_access(), LCBD_STATE_ONLINE, and poll_faults_access().
Referenced by LCBD_faults_read().
unsigned int LCBD_faults_read | ( | LCBD | lcb, | |
unsigned int | clear, | |||
unsigned int * | prv, | |||
unsigned int * | cur | |||
) |
Reads the LATp faults register and, optionally, clears the specified bits.
// Just read the faults register status = LCBD_faults_read (lcb, 0, &faults, NULL); // Read and clear the faults register status = LCBD_faults_read (lcb, -1, &faults, NULL);
References lcbd_faults_access(), and LCBD_K_INTERNAL_OP_STALL.
LCBD LCBD_get | ( | void | ) |
Returns a pointer to the driver control structute.
References Lcb.
static void lcbd_isr | ( | LCBD | lcb | ) | [static] |
Central ISR that dispatches LCB result descriptors.
lcb | Pointer to private LCBD structure |
References _LCB_evt_dsc::bf, _LCB_prb::csr, _LCB_pci_irq_sets::enable, _LCBD_stats_isr::err, _LCB_prb::event_queue, _LCBD_stats_isr::evt, handle_clks(), _LCB_prb::irq, LCB_EVT_ERR_XFR_Q_EMPTY, LCB_IRQ_K_RESULT, LCB_IRQ_M_CLKS, LCB_IRQ_M_EVENT, LCB_IRQ_M_RESULT, LCB_PCI_CSR_M_CLK, LCB_PCI_IRQ_M_CBUF_DISABLE, LCB_PCI_IRQ_M_CBUF_ENABLE, LCB_PCI_IRQ_M_CBUF_PENDING_BUF, LCB_PCI_IRQ_M_CBUF_PENDING_QUE, LCB_PCI_IRQ_V_DISABLE, LCB_RST_ERR_XFR_OUT_Q_EMPTY, LCBD__pciLoad32(), LCBD__pciStore32(), lcbd_evt_handler(), lcbd_rst_handler(), LCBD_STATS_ISR_K_EVT_BUF_DISABLE, LCBD_STATS_ISR_K_EVT_BUF_QUIET, LCBD_STATS_ISR_K_EVT_QUE_EMPTY, LCBD_STATS_ISR_K_EVT_QUE_PRESENT, _LCB_pci_irq_sets::pending, _LCB_prb::result_queue, _LCB_pci_irq::set, _LCBD_stats_isr::srcs, _LCB_evt_dsc::ui, _LCB_pci_irq::ui, and _LCB_evt_dsc_bf::xstatus.
Referenced by connect(), and disconnect().
unsigned int LCBD_load | ( | LCBD | lcb, | |
unsigned int | options, | |||
unsigned int * | event_base | |||
) |
Initializes the LCB hardware and LCBD software.
lcb | The LCB device handle | |
options | Selects various options. This is done as a select/value field. This are enumerated in LCBD_LOAD_OPTIONS_M. | |
event_base | The base address of the event buffer. Two special values can be used here
|
References LCBD_load_init().
unsigned int LCBD_load_cancel | ( | LCBD | lcb | ) |
Cancels the Waiting for the LCBD_load_init completion.
LCBD_OK,operation | was cancelled | |
LCBD_AIBCOM,operation | was not cancelled because initialization is already completed. |
lcb | The LCB driver handle |
References LCBD_AIB_ACTION_AVAILABLE, LCBD_AIB_ACTION_CANCEL, and LCBD_OK.
unsigned int LCBD_load_init | ( | LCBD | lcb, | |
unsigned int | options, | |||
unsigned int * | event_base, | |||
LCBD_load_cb | notify, | |||
void * | prm | |||
) |
Initializes the LCB hardware and LCBD software.
lcb | The LCB device handle | |
options | Selects various options. This is done as a select/value field. This are enumerated in LCBD_LOAD_OPTIONS_M. | |
event_base | The base address of the event buffer. Two special values can be used here
| |
notify | A routine to be called back when the driver is fully initialized. The call signature is void notify (void *prm, LCBD lcb, unsigned int status) | |
prm | An arbitrary user parameter passed to the notify routine. |
status = LCBD_load_init (lcb, options, event_base, LBCD_load_notify, NULL); // The only errors are catastophic if (status != LCBD_OK) return status; // Now do a bunch of other stuff.... call_a_bunch_of_other_stuff (lots_of_parameters); // Done doing other stuff, now wait till the driver is fully initialized status = LCBD_load_wait (lcb); if (status != LCBD_OK) return status; .
References connect(), init_latp(), init_pci(), and init_sw().
Referenced by LCBD_load().
void LCBD_load_notify | ( | void * | semaphore, | |
LCBD | lcb, | |||
unsigned int | status | |||
) |
Pre-canned LCBD load notification callback routine.
semaphore | The synchronizing semaphore | |
lcb | The LCB driver handle | |
status | The completion status |
Referenced by init_latp().
unsigned int LCBD_load_wait | ( | LCBD | lcb | ) |
Waits for the LCBD_load_init completion.
lcb | The LCB driver handle |
Referenced by init_latp().
unsigned int LCBD_pci_cfg_status_clear | ( | LCBD | lcb | ) |
Clears the PCI configuration space status word.
status |
lcb | Pointer to private LCBD structure |
References LCBD_pci_cfg_outWord().
LCBD_state LCBD_state_get | ( | LCBD | lcb | ) |
Returns the current state of the driver.
lcb | The LCB driver handle |
unsigned int LCBD_unload | ( | LCBD | lcb | ) |
Unloads the LCB driver.
References _LCBD_siv::bf, destroy_sw(), disconnect(), LCBD_drain(), LCBD_enable(), LCBD_OK, LCBD_QUES_M_BOTH, LCBD_STATE_UNLOADING, and _LCBD_siv::ui.
unsigned int LCBD_width_set | ( | LCBD | lcb, | |
int | new_width, | |||
int * | org_width | |||
) |
Sets the LATp event fabric data path width, returning the original data path width setting.
Status. |
lcb | The LCB driver handle | |
new_width | The new data width, this should be specified as either
| |
org_width | Returned as the value of the data path width before it was changed. May be specified as NULL. The returned value will be either |
References _LCB_csr::bf, _LCB_csr_bf::latp8, LCB_CSR_M_LATP8, LCB_CSR_V_LATP8, lcbd_csr_access(), LCBD_K_INTERNAL_OP_STALL, and _LCB_csr::ui.
static unsigned int poll | ( | LCBD | lcb, | |
unsigned int | nsecs, | |||
int | iterations | |||
) | [static] |
Polls the RESULT FIFO every nsecs for @ iterations.
lcb | The LCBD driver handle | |
nsecs | The polling rate | |
iterations | The number of polling iterations |
References _LCB_rst_dsc::bf, LCB_RST_ERR_XFR_OUT_Q_EMPTY, LCBD__pciLoad32(), _LCB_rst_dsc::ui, and _LCB_rst_dsc_bf::xstatus.
Referenced by drain_result(), and poll_reg_access().
static unsigned int poll_csr_access | ( | LCBD | lcb, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall, | |||
unsigned int * | prv, | |||
unsigned int * | cur | |||
) | [static] |
Performs an access to the LATP CSR register.
lcb | The LCBD driver handle | |
value | The 32 value to write to the csr | |
field_select | A bit mask indicating which fields should be written | |
stall | A stall value (in units of LATp clocks) | |
prv | Pointer to return the old CSR value in, may be NULL | |
cur | Pointer to return the new CSR value in, may be NULL |
References LCB_CI_HDR_CSR, and poll_reg_access().
Referenced by init_latp_clk_on(), and lcbd_csr_access().
static unsigned int poll_faults_access | ( | LCBD | lcb, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall, | |||
unsigned int * | prv, | |||
unsigned int * | cur | |||
) | [static] |
Performs an access to the LATP FAULTS register.
lcb | The LCBD driver handle | |
value | The 32 value to write to the csr | |
field_select | A bit mask indicating which fields should be written | |
stall | A stall value (in units of LATp clocks) | |
prv | Pointer to return the old FAULTS value in, may be NULL | |
cur | Pointer to return the new FAULTS value in, may be NULL |
References LCB_CI_HDR_FAULTS, and poll_reg_access().
Referenced by clear_faults(), and lcbd_faults_access().
static unsigned int poll_reg_access | ( | LCBD | lcb, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall, | |||
unsigned int * | prv, | |||
unsigned int * | cur, | |||
unsigned int | header | |||
) | [static] |
Performs an access to the LATP register.
lcb | The LCBD driver handle | |
value | The 32 value to write to the csr | |
field_select | A bit mask indicating which fields should be written | |
stall | A stall value (in units of LATp clocks) | |
prv | Pointer to return the old register value in, may be NULL | |
cur | Pointer to return the new register value in, may be NULL | |
header | The command header |
References _LCB_ri_err::bf, check(), _LCB_ri_reg::cur, _LCB_ri_err_bf::err, _LCB_ri_reg::err, _LCB_ci_reg::field_select, _LCB_cl_reg::hdr, _LCB_ci_reg::header, _LCB_rl_reg::item, _LCB_cl_reg::item, LCBD_OK, poll(), _LCB_ri_reg::prv, _LCB_cl_hdr::result, _LCB_ci_reg::stall, submit(), and _LCB_ci_reg::value.
Referenced by poll_csr_access(), and poll_faults_access().
static void select_fabric | ( | unsigned int volatile * | fabric, | |
unsigned int | select | |||
) | [static] |
Accesses the fabric select register, writing the fabric select bit and waits for either the clock to show up or a timeout period to expire.
fabric | The address of the PCI fabric select register | |
select | The value (0 or 1) to set it to. |
References FABRIC_SELECT_TIMEOUT, and LCBD__pciStore32().
Referenced by init_latp(), and LCBD_fabric_select().
static unsigned int submit | ( | LCBD | lcb, | |
unsigned int | request | |||
) | [static] |
Submits the specified request list to the LCB for execution.
LCBD_OK,if | successfull | |
LCBD_REQFULL,if | the transaction could not be submitted because the request que is full |
lcb | The LCBD driver handle | |
request | A pointer to a properly built (address | length) request. The transformation for local to PCI space is done in this routine. |
References LCB_REQUEST_QUEUE_FULL, LCBD__pciLoad32(), LCBD__pciSynchStore32(), and LCBD_OK.
Referenced by drain_result(), LCBD_submit(), poll_reg_access(), and retire().
Initial value:
{ 9, 9, { FPGA (0x80, 0x80), FPGA (0x2c, 0x5e), FPGA (0x2c, 0x5d), FPGA (0x2c, 0x5c), FPGA (0x2b, 0x5c), FPGA (0x2a, 0x5c), FPGA (0x2c, 0x5b), FPGA (0x2b, 0x5b), FPGA (0x2a, 0x5b), 0,0, 0,0,0,0 } }
The actual storage for the driver control block.
Referenced by LCBD_create(), and LCBD_get().