]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/blob - ti/runtime/netapi/netcp_cfg.h
misc changes/cleanup/ bug fixes
[keystone-rtos/netapi.git] / ti / runtime / netapi / netcp_cfg.h
1 /***************************************************
2  * File: netcp_cfg.h 
3  * Purpose: netcp config API
4  **************************************************************
5  * FILE: netcp_cfg.h
6  * 
7  * DESCRIPTION:  netapi NETCP configuration API header  file 
8  *          for user space transport library
9  * 
10  * REVISION HISTORY:  rev 0.0.1 
11  *
12  *  Copyright (c) Texas Instruments Incorporated 2010-2011
13  * 
14  *  Redistribution and use in source and binary forms, with or without 
15  *  modification, are permitted provided that the following conditions 
16  *  are met:
17  *
18  *    Redistributions of source code must retain the above copyright 
19  *    notice, this list of conditions and the following disclaimer.
20  *
21  *    Redistributions in binary form must reproduce the above copyright
22  *    notice, this list of conditions and the following disclaimer in the 
23  *    documentation and/or other materials provided with the   
24  *    distribution.
25  *
26  *    Neither the name of Texas Instruments Incorporated nor the names of
27  *    its contributors may be used to endorse or promote products derived
28  *    from this software without specific prior written permission.
29  *
30  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
31  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
32  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
34  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
35  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
36  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
39  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
40  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42  ***************************************************/
44 #ifndef __NETCP_CFG__H
45 #define __NETCP_CFG__H
47 #include "netapi.h"
48 #include "ti/drv/pa/pa.h"
49 #include "ti/runtime/pktlib/pktlib.h"
51 //NETCP FLOW
52 typedef struct NETCP_CFG_FLOW_Tag
53 {
54         int flowid;
55 } NETCP_CFG_FLOW_T;
56 typedef void *  NETCP_CFG_FLOW_HANDLE_T;
59 //NETCP ROUTE
60 typedef struct NETCP_CFG_ROUTE_Tag
61 {
62    NETCP_CFG_FLOW_HANDLE_T p_flow;
63    PKTIO_HANDLE_T * p_dest_q;
64    int nextAction;
65 } NETCP_CFG_ROUTE_T;
66 typedef void * NETCP_CFG_ROUTE_HANDLE_T;
68 /*--------------flow management--------*/
69 NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T ,
70                                             int n, 
71                                             Pktlib_HeapHandle handles[],
72                                             int * err );
73 void netcp_cfgDelFlow(NETAPI_T , NETCP_CFG_FLOW_HANDLE_T , int * err);
75 /*------------Routes------------------*/
76 NETCP_CFG_ROUTE_HANDLE_T netcp_cfgAddRoute(NETAPI_T ,int nh, 
77                                                Pktlib_HeapHandle heaps[],
78                                                int *err );
79 void netcp_cfgDelRoute(NETAPI_T , NETCP_CFG_ROUTE_HANDLE_T, int *err );
81 /*-----------Actions----------*/
82 #define NETCP_CFG_ACTION_DISCARD 0
83 #define NETCP_CFG_ACTION_CONTINUE 1  //pass packet on to next classifier
84 #define NETCP_CFG_ACTION_TO_SW    2
86 /******************************************************************/
87 /***********************APP ids for rx meta data********************/
88 /******************************************************************/
89 // NWAL "AP ids" for PA Rules that are added
90 #define NETAPI_NETCP_MATCH_GENERIC_MAC   0x10000000  //lower byte==interface
91 #define NETAPI_NETCP_MATCH_GENERIC_IP    0x20000000  //lower byte==interface
92 #define NETAPI_NETCP_MATCH_CLASS         0x80000000  //or' in classifier #, lower byte==interface
95 /*---------MAC APPID------------------*/
96 typedef uint32_t NETCP_CFG_MACIF_T;
98 /*------------L2----------------------*/
99 typedef void * NETCP_CFG_VLAN_T;
101 /*---------------IP APPID-------------------*/
102 typedef uint32_t NETCP_CFG_IP_T;
104 /* del mac i/f */
105 void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err);
106 void netcp_cfgDelIp(NETAPI_T h, int iface_no,  nwal_IpType ipType,
107                   nwalIpAddr_t  * ip_addr,
108                   nwalIpOpt_t * ip_qualifiers, int *err);
109  
111 /*****************************************************************
112  * Create a  MAC interface 
113  ****************************************************************/
114 /*
115 *  @brief  API Creates a MAC interface  
116  *
117  *  @details This api is used to create a MAC interface.
118  *      Once it is created, the MAC interface can be used to receive packets. The API
119  *      adds a rule to the NETCP 1st level lookup tables to route all packets with destination
120  *      MAC matching supplied argument and not matching any other lookup entry (see @ref netcp_cfgAddIp) to
121  *      the supplied route, @ref NETCP_CFG_ROUTE_T, (or default route).
122  *      Packets arriving that match this rule are identified in meta data with Appid=  NETAPI_NETCP_MATCH_GENERIC_MAC
123  *  Note: The internal SOC switch must be "taught" that this mac
124  *      address is present by transmitting a packet with destination mac = this interface mac address.
125  *  @param[in]  @ref NETAPI_T: NETAPI instance 
126  *  @param[in]  char *: pointer to 6 byte MAC address for interface
127  *  @param[in]  int : interface number (0,1,..) 
128  *  @param[in]  int : switch port (0 don't care, 1 switch port 1, 1 switch port 2) [only 0 supported] 
129  *  @param[in]  @ref NETCP_CFG_ROUTE_HANDLE_T : [future] handle of a created route or NULL to use internal default route 
130  *  @oaram[in]  @ref NETCP_CFG_VLAN_T : [future[ vlan configuration . Set to NULL
131  *  @param[in]  int : [future] interface state (0=down, 1= up)
132  *  @param[out] int * err:  pointer to error return
133  *  @retval     @ref NETCP_CFG_MACIF_T : returned AppID for interface (this is returned in meta data for
134  *                 received packets matching this rule an no others)
135  *  @pre       @ref netapi_init 
136  */
137 NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
138                   NETAPI_T  h,     //
139                   uint8_t *p_mac, //mac address associated with interface
140                   int iface_no, //0,1, ..
141                   int switch_port,//0=don't care, 1=switch port 1, 2=switch port 2 , ..
142                   NETCP_CFG_ROUTE_HANDLE_T  route, //NULL to use default
143                   NETCP_CFG_VLAN_T  vlan,  //future
144                   int state,  //0=down, 1=up  //FUTURE
145                   int * err
146                   );
148 /*****************************************************************
149  * Add IP address/qualifier to MAC interface 
150  ****************************************************************/
151 /*
152 *  @brief  API attaches an IP adderess and qualifier to a MAC interface 
153  *
154  *  @details This api is used to add an IP address to a MAC interface along
155  *           with optional IP qualifier. A route, @ref NETCP_CFG_ROUTE_HANDLE_T,or NULL for default 
156  *            may be specified to indicate where to send packets matching the MAC interface MAC address, the
157  *            supplied IP address and any qualifier.  This API adds a rule to the NETCP level 1 lookup tables
158  *            Packets arriving that match this rule are identified in meta data with Appid=  NETAPI_NETCP_MATCH_GENERIC_IP
159  * Note: An IP address must be attached to enable NETCP Recevie Checksum offload feature
160  *  @param[in]  @ref NETAPI_T: NETAPI instance
161  *  @param[in]  int : interface number (0,1,..)
162  *  @param[in]  @ref nwal_IpType : type of IP address (V4 for V6) 
163  *  @oaram[in]  @ref nwalIpAddr_t : ip_address
164  *  @param[in]  @ref nwalIpOpt_t : ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
165  *                  diffserv category for example
166  *  @param[in]  @ref NETCP_CFG_ROUTE_HANDLE_T : [future] handle of a created route or NULL to use internal default route 
167  *  @param[out] int * err:  pointer to error return
168  *  @retval     @ref NETCP_CFG_IP_T : returned AppID for attached rule. This is returned in RX meta data for
169  *              packets matching this rule and no other.
170  *  @pre       @ref netapi_init , @ref netcp_cfgAddMac 
171  */
172 NETCP_CFG_IP_T  netcp_AddIp(
173                   NETAPI_T  h,
174                   int  iface_no,
175                   nwal_IpType ipType,
176                   nwalIpAddr_t  * ip_addr,
177                   nwalIpOpt_t * ip_qualifiers,
178                   NETCP_CFG_ROUTE_HANDLE_T  route,  //NULL for default
179                   int * err
180                   );
182 /*------------------classification [FUTURE]-------------------*/
183 typedef void *NETCP_CFG_CLASS_T;
185 //add classifier
186 typedef struct NETCP_CFG_CLASSIFIER_Tag
188   //tbd a classisfier
190 } NETCP_CFG_CLASSIFIER_T;
192 NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
193                                       NETCP_CFG_CLASSIFIER_T *p_class,
194                                       NETCP_CFG_ROUTE_HANDLE_T p_route,
195                                       int action, int * err);
196 //del classifier
197 void netcp_cfgDelClass(NETAPI_T h,
198                          NETCP_CFG_CLASS_T p_class,
199                          int *err);
203 /***************************************************************************
204 ********************************STATS**************************************
205 **************************************************************************/
207 /*
208  *  @brief  This is the callback function that is used to return statistics from NETCP 
209  *
210  *  @details The application provides a callback function that NETAPI  uses to report statistics.
211 *    The request for stats is generated from the @ref netcp_cfgReqStats API.
212  *   Note: to receive ths stats callback, the @ref netapi_netcpPoll funcition must be called
213  *  @param[in]  @ref NETAPI_T: NETAPI instance
214  *  @param[in]  @ref paSysStats_t * : the PA (NETCP packet accelerator subsystem) statistics block 
215  *  @retval     none 
216  *  @pre       @ref netapi_init , @ref netapi_cfgReqStats, @ref netapi_netcpPoll
217  */
218 //stats CB
219 typedef void (*NETCP_CFG_STATS_CB)( NETAPI_T h, paSysStats_t* pPaStats);
222 //stats request
223 /*
224  *  @brief  API request statistics from NETCP 
225  *
226  *  @details This api is used to request a statistics from NETCP.  This will generate a stats request
227  *           command to NETCP. Sometime later, the statistics result will arrive and will be passed to 
228  *           the caller via the asynchronus callback @ref NETCP_CFG_STATS_CB that is registered in this call.
229  *       Note: to receive the stats callback, the @ref netapi_netcpPoll funcition must be called
230  *  @param[in]  @ref NETAPI_T: NETAPI instance
231  *  @param[in]  @ref NETCP_CFG_STATS_CB : the function to call with the resulting statistics block
232  *  @param[in]  int :  clear the stats in NETCP after the report (0=no, 1=yes)                                          
233  *  @param[out] int * err:  pointer to error return
234  *  @retval     none 
235  *  @pre       @ref netapi_init 
236  */
237 void netcp_cfgReqStats(NETAPI_T  h,  //NEAPI instance
238                        NETCP_CFG_STATS_CB c, //stats report callback function
239                        int doClear,   //0: don't clear, 1 clear
240                        int *err);
242 #endif