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 #define CONFIG_MAX_L2_HANDLES 10
52 #define CONFIG_MAX_L3_HANDLES 20
53 #define CONFIG_MAX_L4_HANDLES 40
55 //NETCP FLOW
56 typedef struct NETCP_CFG_FLOW_Tag
57 {
58 int flowid;
59 } NETCP_CFG_FLOW_T;
60 typedef void * NETCP_CFG_FLOW_HANDLE_T;
63 //NETCP ROUTE
64 typedef struct NETCP_CFG_ROUTE_Tag
65 {
66 NETCP_CFG_FLOW_HANDLE_T p_flow;
67 PKTIO_HANDLE_T * p_dest_q;
68 int nextAction;
69 } NETCP_CFG_ROUTE_T;
70 typedef void * NETCP_CFG_ROUTE_HANDLE_T;
72 /*--------------flow management--------*/
73 NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T ,
74 int n,
75 Pktlib_HeapHandle handles[],
76 int * err );
77 void netcp_cfgDelFlow(NETAPI_T , NETCP_CFG_FLOW_HANDLE_T , int * err);
79 /*------------Routes------------------*/
80 NETCP_CFG_ROUTE_HANDLE_T netcp_cfgAddRoute(NETAPI_T ,int nh,
81 Pktlib_HeapHandle heaps[],
82 int *err );
83 void netcp_cfgDelRoute(NETAPI_T , NETCP_CFG_ROUTE_HANDLE_T, int *err );
85 /*-----------Actions----------*/
86 #define NETCP_CFG_ACTION_DISCARD 0
87 #define NETCP_CFG_ACTION_CONTINUE 1 //pass packet on to next classifier
88 #define NETCP_CFG_ACTION_TO_SW 2
90 /*------------L2----------------------*/
91 typedef void * NETCP_CFG_MACIF_T;
92 typedef void * NETCP_CFG_VLAN_T;
93 typedef void * NETCP_CFG_IP_T;
95 /* del mac i/f */
96 void netcp_cfgDelMac(NETAPI_T h,int iface_no, int *err);
97 void netcp_cfgDelIp(NETAPI_T h, int iface_no, nwal_IpType ipType,
98 nwalIpAddr_t * ip_addr,
99 nwalIpOpt_t * ip_qualifiers, int *err);
102 /*****************************************************************
103 * Create a MAC interface
104 ****************************************************************/
105 /*
106 * @brief API Creates a MAC interface
107 *
108 * @details This api is used to create a MAC interface.
109 * Once it is created, the MAC interface can be used to receive packets. The API
110 * adds a rule to the NETCP 1st level lookup tables to route all packets with destination
111 * MAC matching supplied argument and not matching any other lookup entry (see @ref netcp_cfgAddIp) to
112 * the supplied route, @ref NETCP_CFG_ROUTE_T, (or default route).
113 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_MAC
114 * Note: The internal SOC switch must be "taught" that this mac
115 * address is present by transmitting a packet with destination mac = this interface mac address.
116 * @param[in] @ref NETAPI_T: NETAPI instance
117 * @param[in] char *: pointer to 6 byte MAC address for interface
118 * @param[in] int : interface number (0,1,..)
119 * @param[in] int : switch port (0 don't care, 1 switch port 1, 1 switch port 2) [only 0 supported]
120 * @param[in] @ref NETCP_CFG_ROUTE_HANDLE_T : [future] handle of a created route or NULL to use internal default route
121 * @oaram[in] @ref NETCP_CFG_VLAN_T : [future[ vlan configuration . Set to NULL
122 * @param[in] int : [future] interface state (0=down, 1= up)
123 * @param[out] int * err: pointer to error return
124 * @retval @ref NETCP_CFG_MACIF_T : returned handle for interface.
125 * @pre @ref netapi_init
126 */
127 NETCP_CFG_MACIF_T netcp_cfgCreateMacInterface(
128 NETAPI_T h, //
129 uint8_t *p_mac, //mac address associated with interface
130 int iface_no, //0,1, ..
131 int switch_port,//0=don't care, 1=switch port 1, 2=switch port 2 , ..
132 NETCP_CFG_ROUTE_HANDLE_T route, //NULL to use default
133 NETCP_CFG_VLAN_T vlan, //future
134 int state, //0=down, 1=up //FUTURE
135 int * err
136 );
138 /*****************************************************************
139 * Add IP address/qualifier to MAC interface
140 ****************************************************************/
141 /*
142 * @brief API attaches an IP adderess and qualifier to a MAC interface
143 *
144 * @details This api is used to add an IP address to a MAC interface along
145 * with optional IP qualifier. A route, @ref NETCP_CFG_ROUTE_HANDLE_T,or NULL for default
146 * may be specified to indicate where to send packets matching the MAC interface MAC address, the
147 * supplied IP address and any qualifier. This API adds a rule to the NETCP level 1 lookup tables
148 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_IP
149 * Note: An IP address must be attached to enable NETCP Recevie Checksum offload feature
150 * @param[in] @ref NETAPI_T: NETAPI instance
151 * @param[in] int : interface number (0,1,..)
152 * @param[in] @ref nwal_IpType : type of IP address (V4 for V6)
153 * @oaram[in] @ref nwalIpAddr_t : ip_address
154 * @param[in] @ref nwalIpOpt_t : ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
155 * diffserv category for example
156 * @param[in] @ref NETCP_CFG_ROUTE_HANDLE_T : [future] handle of a created route or NULL to use internal default route
157 * @param[out] int * err: pointer to error return
158 * @retval @ref NETCP_CFG_IP_T : returned handle for attched rule.
159 * @pre @ref netapi_init , @ref netcp_cfgAddMac
160 */
161 NETCP_CFG_IP_T netcp_AddIp(
162 NETAPI_T h,
163 int iface_no,
164 nwal_IpType ipType,
165 nwalIpAddr_t * ip_addr,
166 nwalIpOpt_t * ip_qualifiers,
167 NETCP_CFG_ROUTE_HANDLE_T route, //NULL for default
168 int * err
169 );
171 /*------------------classification [FUTURE]-------------------*/
172 typedef void *NETCP_CFG_CLASS_T;
174 //add classifier
175 typedef struct NETCP_CFG_CLASSIFIER_Tag
176 {
177 //tbd a classisfier
179 } NETCP_CFG_CLASSIFIER_T;
181 NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
182 NETCP_CFG_CLASSIFIER_T *p_class,
183 NETCP_CFG_ROUTE_HANDLE_T p_route,
184 int action, int * err);
185 //del classifier
186 void netcp_cfgDelClass(NETAPI_T h,
187 NETCP_CFG_CLASS_T p_class,
188 int *err);
192 /***************************************************************************
193 ********************************STATS**************************************
194 **************************************************************************/
196 //stats CB
197 typedef void (*NETCP_CFG_STATS_CB)( NETAPI_T h, paSysStats_t* pPaStats);
200 //stats request
201 /*
202 * @brief API request statistics from NETCP
203 *
204 * @details This api is used to request a statistics from NETCP. This will generate a stats request
205 * command to NETCP. Sometime later, the statistics result will arrive and will be passed to
206 * the caller via the asynchronus callback @ref NETCP_CFG_STATS_CB that is registered in this call.
207 * Note: to receive the stats callback, the @ref netapi_netcpPoll funcition must be called
208 * @param[in] @ref NETAPI_T: NETAPI instance
209 * @param[in] @ref NETCP_CFG_STATS_CB : the function to call with the resulting statistics block
210 * @param[in] int : clear the stats in NETCP after the report (0=no, 1=yes)
211 * @param[out] int * err: pointer to error return
212 * @retval none
213 * @pre @ref netapi_init
214 */
215 void netcp_cfgReqStats(NETAPI_T h, //NEAPI instance
216 NETCP_CFG_STATS_CB c, //stats report callback function
217 int doClear, //0: don't clear, 1 clear
218 int *err);
220 /******************************************************************/
221 /***********************APP ids for rx meta data********************/
222 /******************************************************************/
224 // NWAL "AP ids"
225 #define NETAPI_NETCP_MATCH_GENERIC_MAC 0x10000000 //lower byte==interface
226 #define NETAPI_NETCP_MATCH_GENERIC_IP 0x20000000 //lower byte==interface
227 #define NETAPI_NETCP_MATCH_CLASS 0x80000000 //or' in classifier #
231 #endif