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