openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

soc_schan_fifo.h (4543B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  *
      8  * File:        soc_schan_fifo.h
      9  * Purpose:     Maps out structures used for SCHAN FIFO ASYNC/SYNC operations and
     10  *              exports routines.
     11  */
     12 
     13 #ifndef _SOC_SCHAN_FIFO_H
     14 #define _SOC_SCHAN_FIFO_H
     15 
     16 #include <soc/defs.h>
     17 #include <soc/types.h>
     18 #include <sal/types.h>
     19 #include <soc/schanmsg.h>
     20 #include <soc/soc_async.h>
     21 
     22 
     23 /* This structure will be related to single SCHAN message
     24  * Following message type will be supported
     25  * READ_MEMORY_CMD_MSG
     26  * WRITE_MEMORY_CMD_MSG
     27  * READ_REGISTER_CMD_MSG
     28  * WRITE_REGISTER_CMD_MSG
     29  * TABLE_INSERT_CMD_MSG
     30  * TABLE_DELETE_CMD_MSG
     31  * TABLE_LOOKUP_CMD_MSG
     32  * FIFO_POP_CMD_MSG
     33  * FIFO_PUSH_CMD_MSG
     34  */
     35 
     36 /* This structure supports  bunch of SCHAN meesages
     37  * in single transaction. In case of blocked call
     38  * max value size can be 2* CMIC_SCHAN_FIFO_CMD_SIZE_MAX
     39  * Both the channels can be used to process the message in
     40  * parallel. In case of non blocked call the max value of
     41  * size should be CMIC_SCHAN_FIFO_CMD_SIZE_MAX because
     42  * API can be called again to post the next message
     43  */
     44 
     45 #define CMIC_SCHANFIFO_RESP_ALLOC     (32)
     46 
     47 typedef enum {
     48     CTL_FIFO_START = 1,
     49     CTL_FIFO_STOP,
     50     CTL_FIFO_ABORT,
     51     CTL_FIFO_FLUSH,
     52     CTL_FIFO_MAX_MSG_GET,
     53     CTL_FIFO_RESP_ALLOC,
     54     CTL_FIFO_RESP_FREE
     55 } schan_fifo_ctl_t;
     56 
     57 
     58 typedef struct schan_fifo_cmd_s {
     59     schan_header_t header;  /*schan header */
     60     uint32        address;
     61     uint32         data[1]; /*c90 doesn't support fleaxible array e.g.  data[] */
     62 } schan_fifo_cmd_t;
     63 
     64 typedef struct schan_fifo_resp_s {
     65     schan_header_t header;
     66     uint32 data[CMIC_SCHANFIFO_RESP_ALLOC - 1];
     67 } schan_fifo_resp_t;
     68 
     69 
     70 typedef struct schan_fifo_alloc_s {
     71     int  num;  /* in , number of structures to be allocated */
     72     schan_fifo_resp_t *resp; /* out, response buffer pointer */
     73 }schan_fifo_alloc_t;
     74 
     75 
     76 typedef struct soc_schan_fifo_msg_s {
     77     int                    num;      /* number of commands */
     78     int                    interval; /* update interval, should be -1 for messge done only */
     79     size_t                 size;     /* size of the  command buffer in words */
     80     schan_fifo_cmd_t       *cmd;     /* packed command buffer */
     81     schan_fifo_resp_t      *resp;    /* Response buffer, NULL or (num*sizeof(schan_fifo_resp_t)) */
     82 } soc_schan_fifo_msg_t;
     83 
     84 /* This structure is used to configure the SCHAN FIFO Op */
     85 
     86 typedef struct soc_schan_fifo_config_s {
     87     int intrEnb; /* 0-> polling, 1-> interrupt */
     88     int timeout; /* timeout(usecs) for wait complete */
     89     int dma;     /* 0-> No ccmDMA, 1->ccmDMA */
     90 } soc_schan_fifo_config_t;
     91 
     92 /*******************************************
     93 * @function soc_schan_fifo_msg_send
     94 * purpose cmic SCHAN FIFO operation
     95 *
     96 * @param unit [in] unit
     97 * @param msg [in, out] soc_schan_fifo_msg_t
     98 * @param cookie [in] pointer to void, user data
     99 * @param cbf [in] soc_async_cb_f, call back function
    100 *
    101 * @returns SOC_E_NONE
    102 * @returns SOC_E_XXX
    103  */
    104 extern int
    105 soc_schan_fifo_msg_send(int unit,
    106              soc_schan_fifo_msg_t *msg,
    107              void *cookie,
    108              soc_async_cb_f cbf);
    109 
    110 /*******************************************
    111 * @function soc_schan_fifo_control
    112 * purpose API to control SCHAN FIFO
    113 *
    114 * @param unit [in] unit
    115 * @param ctl [in] schan_fifo_ctl_t
    116 * @param data [in, out] pointer to void
    117 *
    118 * @returns SOC_E_NONE
    119 *
    120 * @end
    121  */
    122 extern int
    123 soc_schan_fifo_control(int unit,
    124                  schan_fifo_ctl_t ctl, void *data);
    125 
    126 
    127 /*******************************************
    128 * @function soc_schan_fifo_deinit
    129 * purpose API to deInitialize and config SCHAN FIFO
    130 * It will abort the current operation, flush the queue
    131 * and release all the resources.
    132 *
    133 * @param unit [in] unit
    134 *
    135 * @returns SOC_E_NONE
    136 *
    137 * @end
    138  */
    139 extern int
    140 soc_schan_fifo_deinit(int unit);
    141 
    142 
    143 /*******************************************
    144 * @function soc_schan_fifo_init
    145 * purpose API to Initialize and config SCHAN FIFO
    146 * It will initialize the SCHAN FIFO hardware and
    147 * allocate resources for async operation.
    148 * In case of sync only set soc_async_prop_t pointer
    149 * to be NULL.
    150 *
    151 * @param unit [in] unit
    152 * @param prop [in] pointer to soc_async_prop_t
    153 * @param config [in] pointer to soc_schan_fifo_config_t
    154 *
    155 * @returns SOC_E_NONE
    156 * @returns SOC_E_XXX
    157 *
    158 * @end
    159  */
    160 extern int
    161 soc_schan_fifo_init(int unit,
    162                    soc_async_prop_t  *prop,
    163                    soc_schan_fifo_config_t *config);
    164 
    165 #endif
    166