summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: adea848)
raw | patch | inline | side by side (parent: adea848)
author | David Lide <a0216552@gtudci01.(none)> | |
Wed, 22 Feb 2012 16:12:50 +0000 (11:12 -0500) | ||
committer | David Lide <a0216552@gtudci01.(none)> | |
Wed, 22 Feb 2012 16:12:50 +0000 (11:12 -0500) |
ti/runtime/netapi/netapi_tune.h | patch | blob | history | |
ti/runtime/netapi/netcp_cfg.h | patch | blob | history | |
ti/runtime/netapi/src/netcp_cfg.c | [changed mode: 0644->0755] | patch | blob | history |
ti/runtime/netapi/test/net_test.c | patch | blob | history |
index bfd651d16d815ab9075440c75a05d6d7f71356ae..858e68a6447a02ca649dba8c3048d841d94581de 100644 (file)
#define TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC 16\r
\r
#define TUNE_NETAPI_MAX_NUM_MAC 2 //2 'logical' mac addresses\r
-#define TUNE_NETAPI_MAX_NUM_IP 2 //2 ip addresses \r
+#define TUNE_NETAPI_MAX_NUM_IP 4 //2 ip addresses \r
#define TUNE_NETAPI_MAX_NUM_PORTS_PER_CORE 4 //udp/tcp ports -> for lUT2 ) \r
#define TUNE_NETAPI_MAX_NUM_PORTS (TUNE_NETAPI_MAX_NUM_PORTS_PER_CORE * (TUNE_NETAPI_NUM_CORES)) \r
\r
index ae07c6d0cc2fab05fe25178d0d31a8eaf051ad86..ce16af86a81e789b39aa919384dce9e798db5cff 100644 (file)
// NWAL "AP ids" for PA Rules that are added\r
#define NETAPI_NETCP_MATCH_GENERIC_MAC 0x10000000 //lower byte==interface\r
#define NETAPI_NETCP_MATCH_GENERIC_IP 0x20000000 //lower byte==interface\r
-#define NETAPI_NETCP_MATCH_CLASS 0x80000000 //or' in classifier #, lower byte==interface\r
+#define NETAPI_NETCP_MATCH_CLASS 0x80000000 //FULL MATCH or' in classifier #, lower byte==interface\r
+#define NETAPI_NETCP_MATCH_CLASS_L3 0x40000000 //MATCHED L3 but not L4. lower byte==interface\r
\r
\r
/*---------MAC APPID------------------*/\r
{\r
//which mac interface pkt is from, \r
int iface;\r
-#define NETCP_CFG_CLASS_IFACE_ANY 255 //don't care\r
\r
- //iP address: IP type, destination addr, qualifiers\r
- //ip_addr=NULL => don't care\r
+ //L3 - iP address: IP type, destination addr, qualifiers\r
nwal_IpType ipType;\r
nwalIpAddr_t * ip_addr;\r
nwalIpOpt_t * ip_qualifiers;\r
+ NETCP_CFG_ROUTE_HANDLE_T p_fail_route; //what to do if L3 matches but L4 fails AND L3 is a \r
+ // new rule.(if exisitng rule, then existing fail\r
+ //route will be used.\r
\r
//L4 (port)\r
nwal_appProtoType_t proto; //L4 proto (-1 for don't care)\r
\r
//Instert a classifier.\r
NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,\r
- NETCP_CFG_CLASSIFIER_T *p_class,\r
- NETCP_CFG_ROUTE_HANDLE_T p_route,\r
- int action, int * err);\r
+ NETCP_CFG_CLASSIFIER_T *p_class,\r
+ NETCP_CFG_ROUTE_HANDLE_T p_route,\r
+ int action, int * err);\r
//delete classifier\r
void netcp_cfgDelClass(NETAPI_T h,\r
NETCP_CFG_CLASS_T classId,\r
//internal: insert a classifier into list \r
static void netcp_cfgp_insert_class(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,\r
int class_slot, //we 'reserved it already'\r
+ int class_type,\r
void * L2_handle,\r
void * L3_handle,\r
void * L4_handle)\r
p->classi[class_slot].nwal_L2_handle = L2_handle;\r
p->classi[class_slot].nwal_L3_handle = L3_handle;\r
p->classi[class_slot].nwal_L4_handle = L4_handle;\r
+ p->classi[class_slot].class_type = class_type;\r
return;\r
}\r
\r
\r
\r
/*****************************************************************/\r
-/***************Add IP to MAC interface****************************/\r
+/***************Add IP to MAC interface (internal)****************/\r
/*****************************************************************/\r
-NETCP_CFG_IP_T netcp_cfgAddIp(\r
+static NETCP_CFG_IP_T netcp_cfgAddIpInternal(\r
NETAPI_T h,\r
int iface_no,\r
nwal_IpType ipType,\r
- nwalIpAddr_t * ip_addr,\r
- nwalIpOpt_t * ip_qualifiers,\r
+ nwalIpAddr_t * ip_addr,\r
+ nwalIpOpt_t * ip_qualifiers,\r
NETCP_CFG_ROUTE_HANDLE_T route, //NULL for default\r
- int * err\r
- )\r
+ int * err,\r
+ int flag) //TRUE: add IP to iface. False: add IP as part of classifier\r
{\r
NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;\r
void * n_handle;\r
nwal_TransID_t trans_id;\r
int ip_slot=-1;\r
NETCP_CFG_IP_T ip_rule_id;\r
+NETCP_CFG_IP_T temp;\r
\r
//verify that iface has been configurred \r
if ((iface_no<0) || (iface_no>= TUNE_NETAPI_MAX_INTERFACES)) {*err = NETAPI_ERR_BAD_INPUT; return -1;}\r
*err = NETAPI_ERR_BAD_INPUT;\r
return -1;\r
}\r
- //find free slot for IP & reserve\r
- ip_slot= netcp_cfgp_find_ip_slot(&netapi_get_global()->nwal_context, \r
- iface_no);\r
- if (ip_slot <0) \r
+\r
+ if (flag) //if adding IP to MAC then reserve a slot to save info\r
{\r
- *err= NETAPI_ERR_NOMEM; //no room \r
+ //find free slot for IP & reserve\r
+ ip_slot= netcp_cfgp_find_ip_slot(&netapi_get_global()->nwal_context, \r
+ iface_no);\r
+ if (ip_slot <0) \r
+ {\r
+ *err= NETAPI_ERR_NOMEM; //no room \r
+ return -1;\r
+ }\r
}\r
\r
//get a transaction object for config action\r
memset(&nwalIpParam.ipOpt,0, sizeof(nwalIpOpt_t));\r
\r
//build the rule id that will be returned when a packet matches \r
- ip_rule_id = NETAPI_NETCP_MATCH_GENERIC_IP | iface_no | ((ip_slot&&0xff)<<8);\r
+ if (flag)\r
+ ip_rule_id = NETAPI_NETCP_MATCH_GENERIC_IP | iface_no | ((ip_slot&&0xff)<<8);\r
+ else\r
+ ip_rule_id = (NETAPI_NETCP_MATCH_CLASS_L3 | iface_no);\r
+\r
//perform config action\r
pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;\r
retValue = nwal_setIPAddr( netapi_get_global()->nwal_context.nwalInstHandle,\r
retValue);\r
pTransInfo->inUse = nwal_FALSE;\r
//zap the entry\r
- netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context,\r
+ if (flag)\r
+ {\r
+ netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context,\r
iface_no,\r
ip_slot);\r
-\r
+ }\r
return -1;\r
}\r
//wait here until its done since scheduler isn't running yet most likely..\r
nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);\r
}\r
}\r
- printf (">netcp cfg: IP added to interface %d (slot%d)\n", iface_no, ip_slot);\r
- netcp_cfgp_insert_ip(&netapi_get_global()->nwal_context, ipType, \r
+ if (flag)\r
+ {\r
+ printf (">netcp cfg: IP added to interface %d (slot%d)\n", iface_no, ip_slot);\r
+ netcp_cfgp_insert_ip(&netapi_get_global()->nwal_context, ipType, \r
ip_addr, ip_qualifiers, iface_no, ip_slot,\r
pTransInfo->handle);\r
+ }\r
pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;\r
+ temp = (NETCP_CFG_IP_T) pTransInfo->handle;\r
pTransInfo->inUse = nwal_FALSE;\r
- return (ip_rule_id);\r
+ return (flag ? ip_rule_id: temp);\r
+}\r
+/*****************************************************************/\r
+/***************Add IP to MAC interface **************************/\r
+/*****************************************************************/\r
+NETCP_CFG_IP_T netcp_cfgAddIp(\r
+ NETAPI_T h,\r
+ int iface_no,\r
+ nwal_IpType ipType,\r
+ nwalIpAddr_t * ip_addr,\r
+ nwalIpOpt_t * ip_qualifiers,\r
+ NETCP_CFG_ROUTE_HANDLE_T route, //NULL for default\r
+ int * err\r
+ )\r
+{\r
+ return netcp_cfgAddIpInternal(\r
+ h, iface_no, ipType, ip_addr, ip_qualifiers, route, err, \r
+ 1);\r
}\r
\r
/*****************************************************************/\r
int action, int * err)\r
{\r
NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;\r
-void * l3_handle; //ip handle\r
+void * l3_handle=NULL; //ip handle\r
nwal_RetValue retValue;\r
NetapiNwalTransInfo_t *pTransInfo;\r
nwal_TransID_t trans_id;\r
int class_slot=-1;\r
-int iface;\r
-int ip_slot;\r
+int iface_no;\r
+int ip_slot=-1;\r
NETCP_CFG_CLASS_T classHandle; //returned by us\r
nwal_appProtoType_t proto;\r
nwalLocConnCfg_t tempCfg={\r
default:\r
printf(">netcp_cfg : classifier type %d not supported\n",p_class->classType);\r
break;\r
-\r
+case(NETCP_CFG_CLASS_TYPE_L3_L4):\r
case(NETCP_CFG_CLASS_TYPE_L4):\r
//assume just type l4 only (L2, L3 defined by iface, l3 id )\r
- iface = p_class->u.c_l4.iface;\r
- ip_slot = (p_class->u.c_l4.ip>>8)&0xff;\r
+ iface_no = p_class->u.c_l4.iface;\r
+ if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)\r
+ { \r
+ ip_slot = (p_class->u.c_l4.ip>>8)&0xff;\r
+ }\r
\r
//verify that iface has been configured \r
- if(!netapi_get_global()->nwal_context.interfaces[iface].in_use)\r
+ if(!netapi_get_global()->nwal_context.interfaces[iface_no].in_use)\r
{\r
*err = NETAPI_ERR_BAD_INPUT;\r
return -1;\r
}\r
- //verify that ip has been configured and get its handle\r
- l3_handle = netcp_cfgp_get_ip_handle(\r
- &netapi_get_global()->nwal_context, iface,\r
+\r
+ if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)\r
+ {\r
+ //verify that ip has been configured and get its handle\r
+ l3_handle = netcp_cfgp_get_ip_handle(\r
+ &netapi_get_global()->nwal_context, iface_no,\r
ip_slot );\r
+ }\r
+ else\r
+ {\r
+ nwalIpParam_t tempParam={\r
+ pa_IPV4, /* IP Type */\r
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Dest IP */\r
+ { 0x0,0,0,0},/* IP Options */\r
+ NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE, /* Continue parsing to next route for match */\r
+ NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, /* For next route fail action by default is route to host */\r
+ CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */\r
+ QMSS_PARAM_NOT_SPECIFIED /* Use default queue configured to NWAL if packet is routed to host */\r
+ };\r
+ //build nwalIpParam\r
+ memcpy(&tempParam.locIpAddr,p_class->u.c_l3_l4.ip_addr, sizeof(nwalIpAddr_t));\r
+ tempParam.ipType=p_class->u.c_l3_l4.ipType;\r
+ //use nwal defauls for route\r
+ if (p_class->u.c_l3_l4.ip_qualifiers)\r
+ memcpy(&tempParam.ipOpt,p_class->u.c_l3_l4.ip_qualifiers, sizeof(nwalIpOpt_t));\r
+ else\r
+ memset(&tempParam.ipOpt,0, sizeof(nwalIpOpt_t));\r
+\r
+\r
+ //find if we have a matching L3 handle for IP classifier; if not create it\r
+ retValue = nwal_getIPAddr (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,\r
+ &tempParam,\r
+ netcp_cfgp_get_mac_handle(&netapi_get_global()->nwal_context, iface_no ),\r
+ &l3_handle); \r
+ if (retValue != nwal_TRUE) \r
+ {\r
+ int ret;\r
+ //**NEW IP RULE \r
+ //need to attach this IP RULE to the MAC\r
+ l3_handle= (void *) netcp_cfgAddIpInternal(\r
+ h, iface_no, \r
+ p_class->u.c_l3_l4.ipType,\r
+ p_class->u.c_l3_l4.ip_addr,\r
+ p_class->u.c_l3_l4.ip_qualifiers,\r
+ p_class->u.c_l3_l4.p_fail_route,\r
+ &ret,\r
+ FALSE);\r
+ if(!ret)\r
+ {\r
+ l3_handle=NULL;\r
+ }\r
+ }\r
+ } \r
if(!l3_handle)\r
{*err = NETAPI_ERR_BAD_INPUT; return -1 ;}\r
\r
//find free slot for CLASS & reserve\r
class_slot= netcp_cfgp_find_class_slot(&netapi_get_global()->nwal_context);\r
if(class_slot<0) {*err = NETAPI_ERR_NOMEM; return -1;}\r
- classHandle = NETAPI_NETCP_MATCH_CLASS | (class_slot<<8) | (iface&0xff);\r
+ classHandle = NETAPI_NETCP_MATCH_CLASS | (class_slot<<8) | (iface_no&0xff);\r
//build request from template\r
tempCfg.inHandle=l3_handle;\r
- memcpy(&tempCfg.appProto,&p_class->u.c_l4.appProto,sizeof(nwalAppProto_t));\r
+ if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)\r
+ { \r
+ memcpy(&tempCfg.appProto,&p_class->u.c_l4.appProto,sizeof(nwalAppProto_t));\r
+ proto = p_class->u.c_l4.proto;\r
+ }\r
+ else\r
+ {\r
+ memcpy(&tempCfg.appProto,&p_class->u.c_l3_l4.appProto,sizeof(nwalAppProto_t));\r
+ proto = p_class->u.c_l3_l4.proto;\r
+ }\r
+ \r
tempCfg.matchAction = (action==NETCP_CFG_ACTION_TO_SW) ? NWAL_MATCH_ACTION_HOST : NWAL_MATCH_ACTION_DISCARD;\r
- proto = p_class->u.c_l4.proto;\r
//todo: flowid and route \r
//get a transaction id\r
pTransInfo = netapi_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);\r
if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return -1 ;}\r
- pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP;\r
+ pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP; /* todo: fix this to TRANS_L4*/\r
pTransInfo->netapi_handle = h;\r
//issue request\r
retValue = nwal_addConn(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,\r
nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);\r
}\r
}\r
- printf (">netcp cfg: L4 Classifer added to interface %d ip %d (slot%d)\n", iface, ip_slot, class_slot);\r
+ printf (">netcp cfg: L4 Classifer added to interface %d ip %d (slot%d)\n", iface_no, ip_slot, class_slot);\r
netcp_cfgp_insert_class(&netapi_get_global()->nwal_context, \r
class_slot,\r
+ p_class->classType, \r
NULL, //L2 we have\r
- NULL, //L3 we have\r
+ (p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4? l3_handle : NULL),\r
pTransInfo->handle);\r
pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;\r
-\r
- \r
- return classHandle;\r
+ return classHandle;\r
} //end switch\r
return -1;\r
}\r
index 2073b432e481eda611fe1df6c7d15366fe5b0a35..7d933b74e36af0f62bed8db98bbeb32ac2c20717 100755 (executable)
long n_new;\r
long n_class0_rx; //count of pkts classified \r
long n_class1_rx; //count of pkts classified \r
+ long n_class2_rx; //count of pkts classified \r
long n_t1;\r
long n_t2;\r
long n_t3;\r
unsigned char mac1[]={0x00,0x01,0x02,0x03,0x04,0x06}; //interface 1\r
nwalIpAddr_t OurIp0={ 10, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
nwalIpAddr_t OurIp1={ 10, 0, 1, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
+nwalIpAddr_t OurIp2={ 10, 0, 2, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
+\r
\r
#if 1 //goes with real tx (to laptop) \r
unsigned char real_mac_header[]={0xd4,0xbe,0xd9,0x00,0xd3,0x7e,\r
NETCP_CFG_IP_T ip_rule1;\r
NETCP_CFG_CLASS_T class_0;\r
NETCP_CFG_CLASS_T class_1;\r
+NETCP_CFG_CLASS_T class_2;\r
\r
NETCP_CFG_CLASSIFIER_T class_0_cfg=\r
{\r
}\r
};\r
\r
+NETCP_CFG_CLASSIFIER_T class_2_cfg=\r
+{\r
+ NETCP_CFG_CLASS_TYPE_L3_L4,\r
+ {\r
+ {0, 4 ,0/*fill in below*/ , NULL, NULL, //L2/L3\r
+ NWAL_APP_PLOAD_PROTO_UDP, {2504}} //L4\r
+ }\r
+};\r
+\r
PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};\r
\r
/*************************END NETAPI OBJECTS***********************/\r
@@ -398,8 +411,9 @@ lpInfo.l4csum = (p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_MAS
if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_CLASS)\r
{\r
int c= ((unsigned int)p_meta->u.rx_meta->appId >>8)&0xffff;\r
- if (c==0) stats.n_class0_rx +=1;\r
+ if (c==0) stats.n_class0_rx +=1;\r
else if (c==1) stats.n_class1_rx +=1;\r
+ else if (c==2) stats.n_class2_rx +=1;\r
else printf("**NET_TEST RX -unknown class: %x\n", p_meta->u.rx_meta->appId);\r
}\r
}\r
if (err) {printf("addclass1 failed %d\n",err); exit(1);}\r
\r
\r
+class_2_cfg.u.c_l3_l4.ip_addr = &OurIp2;\r
+class_2 = netcp_cfgAddClass(netapi_handle,\r
+ &class_2_cfg,\r
+ NULL,\r
+ NETCP_CFG_ACTION_TO_SW,\r
+ &err);\r
+if (err) {printf("addclass2 failed %d\n",err); exit(1);}\r
#endif\r
\r
ourTimerBlock = netapi_TimerGroupCreate(\r
//delete Classifiers\r
netcp_cfgDelClass(netapi_handle, class_0, &err); \r
netcp_cfgDelClass(netapi_handle, class_1, &err); \r
+netcp_cfgDelClass(netapi_handle, class_2, &err); \r
\r
//delete IPs and MAC Interfacess\r
netcp_cfgDelIp(netapi_handle, 0, 0, NULL, NULL, ip_rule0, &err);\r