/********************************************************** * file: netcp_cfg.c * purpose: netcp configurations routines ************************************************************** * FILE: netcp_cfg.c * * DESCRIPTION: netcp configuration main source file for user space transport * library * * REVISION HISTORY: rev 0.0.1 * * Copyright (c) Texas Instruments Incorporated 2010-2011 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************/ #include #include #include #include #include "netapi.h" #include "netcp_cfg.h" #include "netapi_loc.h" /****************************************************************** ********************Utility************************************* *******************************************************************/ //get a free transaction id NetapiNwalTransInfo_t * netapip_GetFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwal_TransID_t *pTransId) { uint16_t count=0; count=0; while(count < TUNE_NETAPI_MAX_NUM_TRANS) { if((p_global->nwal_context.transInfos[count].inUse) != nwal_TRUE) { p_global->nwal_context.transInfos[count].inUse = nwal_TRUE; *pTransId = count; return(&p_global->nwal_context.transInfos[count]); } count++; } /* trouble. need to wait for one to free up*/ /* to do: handle this by forcing a poll of cntrl queue*/ printf(">netcp_cfg: trying to get free transaction slot but all full!!\n"); return NULL; } //internal: build route void netcp_cfgp_build_route(NETCP_CFG_ROUTE_T * p_route, int16_t * p_flow, Qmss_QueueHnd * p_q) { if (!p_route) return; if (p_route->p_flow) *p_flow= p_route->p_flow->flowid; else *p_flow = CPPI_PARAM_NOT_SPECIFIED; if (p_route->p_dest_q) *p_q = pktio_get_q(p_route->p_dest_q); else *p_q=QMSS_PARAM_NOT_SPECIFIED; } /*-----------------------------------------------------------*/ /*----------------database management stuff-------------------*/ /*-----------------------------------------------------------*/ /*=====================Policies=============================*/ //internal: find a free slot for an SA int netcp_cfgp_find_policy_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int tunnel) { int i; if ((tunnel <0 ) || (tunnel >=TUNE_NETAPI_MAX_SA)) return -1; //find a free entry for(i=0;ipolicy[i].in_use) { p->policy[i].in_use = 2; //pending p->policy[i].tunnel= tunnel; //save tunnel this is linked to return i; } } return -1; } //internal: delete a policy from list void netcp_cfgp_delete_policy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int policy_slot ) { if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY)) { return ; } p->policy[policy_slot].in_use=0; return; } //internal: insert an policy into the list void netcp_cfgp_insert_policy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int policy_slot, //we 'reserved it already' void * handle) { p->policy[policy_slot].in_use=1; p->policy[policy_slot].nwal_handle = handle; return; } //internal: return nwal_handle for policy void *netcp_cfgp_get_policy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int policy_slot) { if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY)) return NULL; if (!p->policy[policy_slot].in_use) return NULL; return p->policy[policy_slot].nwal_handle; } /*======================SAs==================================*/ //internal: find a free slot for an SA int netcp_cfgp_find_sa_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface) { int i; if (iface != NETCP_CFG_NO_INTERFACE) { if ((iface <0 ) || (iface >=TUNE_NETAPI_MAX_INTERFACES)) return -1; } //find a free entry for(i=0;itunnel[i].in_use) { p->tunnel[i].in_use = 2; //pending p->tunnel[i].iface= iface; //save iface return i; } } return -1; } //internal: delete an SAr from list void netcp_cfgp_delete_sa( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int sa_slot ) { if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA)) { return ; } p->tunnel[sa_slot].in_use=0; return; } //internal: insert an SA into the list void netcp_cfgp_insert_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int sa_slot, //we 'reserved it already' int dir, int mode, void * temp1, void * temp2, void * handle_inflow, void * handle_sideband) { p->tunnel[sa_slot].in_use=1; p->tunnel[sa_slot].inbound = dir; p->tunnel[sa_slot].sa_mode = mode; p->tunnel[sa_slot].sa_handle_inflow = handle_inflow; p->tunnel[sa_slot].sa_handle_sideband = handle_sideband; return; } //internal: return nwal_handles for SA void *netcp_cfgp_get_sa_handles( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int sa_slot, void ** p_sideband) { if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA)) return NULL; if (!p->tunnel[sa_slot].in_use) return NULL; *p_sideband = p->tunnel[sa_slot].sa_handle_sideband; return p->tunnel[sa_slot].sa_handle_inflow; } /*==============================fLOWS=============================*/ //internal: find a free slot for a flow static int netcp_cfgp_find_flow_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p) { int i; //find a free entry for(i=0;iflows[i].in_use) { p->flows[i].in_use = 2; //pending return i; } } return -1; } //internal: clear flow slot static void netcp_cfgp_delete_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int slot) { if ((slot >=0 ) && (slot < TUNE_NETAPI_MAX_FLOWS)) { p->flows[slot].in_use = 0; } } //internal: insert a flow into flow slot static NETCP_CFG_FLOW_HANDLE_T netcp_cfgp_insert_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int slot, //we 'reserved it already' void * handle) //cppi flow handle. Save this for delete { p->flows[slot].in_use=1; p->flows[slot].handle = handle; p->flows[slot].flow.flowid = Cppi_getFlowId(handle); return (NETCP_CFG_FLOW_HANDLE_T) &p->flows[slot].flow; } //find entry matching the flowid. return slot# and the cppi handle static int netcp_cfgp_find_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int flowid, void ** handle) { int i; *handle=NULL; for(i=0;iflows[i].in_use)&&(p->flows[i].flow.flowid == flowid)) { *handle = p->flows[i].handle; return i; } } return -1; } /*============================IP ADDRESSES==========================*/ //internal: find a free slot for IP rule static int netcp_cfgp_find_ip_slot(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface_no) { int i; //find a free entry for(i=0;iips[i].in_use) { p->ips[i].in_use = 2; //pending return i; } } return -1; } //internal: insert an IP address into iface static void netcp_cfgp_insert_ip(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, nwal_IpType ipType, nwalIpAddr_t *ip_addr, nwalIpOpt_t *ip_qualifiers, int iface_no, int ip_slot, //we 'reserved it already' void * handle) { p->ips[ip_slot].in_use=1; memcpy(&p->ips[ip_slot].ip_addr, ip_addr, sizeof(nwalIpAddr_t)); if(ip_qualifiers) memcpy(&p->ips[ip_slot].ip_qualifiers, ip_qualifiers, sizeof(nwalIpOpt_t)); else memset(&p->ips[ip_slot].ip_qualifiers, 0, sizeof(nwalIpOpt_t)); p->ips[ip_slot].ip_type = ipType; p->ips[ip_slot].nwal_handle = handle; return; } //internal: free IP slot associated with ip address static void netcp_cfgp_delete_ip( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface_no, int ip_slot ) { if ((ip_slot <0)||(ip_slot>TUNE_NETAPI_MAX_IP)) return ; p->ips[ip_slot].in_use=0; return; } //internal: get IP handle associated with ip address static void *netcp_cfgp_get_ip_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface_no, int ip_slot ) { if ((ip_slot <0)||(ip_slot>=TUNE_NETAPI_MAX_IP)) return NULL; if (!p->ips[ip_slot].in_use) return NULL; return (void *) p->ips[ip_slot].nwal_handle; } /*==========================MAC INTERFACES======================*/ //internal: insert interface info into global context static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char * p_mac, int iface_no, int state, NETCP_CFG_VLAN_T vlan, void * handle) { if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_INTERFACES)) { memset(&p->interfaces[iface_no],0,sizeof(NETCP_INTERFACE_T)); p->interfaces[iface_no].in_use = 1; memcpy(&p->interfaces[iface_no].mac[0], p_mac,6); p->interfaces[iface_no].state = state; //todo p->interfaces[iface_no].vlan = vlan; p->interfaces[iface_no].nwal_handle = handle; //save handle assoicated with this rule } else printf(">netcp_cfg insert interface # out of range %d\n",iface_no); } //internal: get handle associated with interface void* netcp_cfgp_get_mac_handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no) { if (iface_no == NETCP_CFG_NO_INTERFACE) return NULL; if ((iface_no <0 ) || (iface_no >= TUNE_NETAPI_MAX_INTERFACES)) { return NULL; } else if ( p->interfaces[iface_no].in_use) { return (void *) p->interfaces[iface_no].nwal_handle; } //no valid entry in slot return NULL; } //internal: clear inteface entry static void netcp_cfgp_delete_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no) { if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_INTERFACES)) { p->interfaces[iface_no].in_use = 0; } } /*========================CLASSIFIERS==========================*/ //internal: find a free slot for classifier rule static int netcp_cfgp_find_class_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p) { int i; //find a free entry for(i=0;iclassi[i].in_use) { p->classi[i].in_use = 2; //pending return i; } } return -1; } //internal: delete a classifer from list static void netcp_cfgp_delete_class( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int class_slot ) { if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS)) { return ; } p->classi[class_slot].in_use=0; return; } //internal: insert a classifier into list static void netcp_cfgp_insert_class(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int class_slot, //we 'reserved it already' int class_type, void * L2_handle, void * L3_handle, void * L4_handle) { p->classi[class_slot].in_use=1; p->classi[class_slot].nwal_L2_handle = L2_handle; p->classi[class_slot].nwal_L3_handle = L3_handle; p->classi[class_slot].nwal_L4_handle = L4_handle; p->classi[class_slot].class_type = class_type; return; } //internal: return L4 nwal_handle for class static void *netcp_cfgp_get_l4_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int class_slot) { if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS)) return NULL; if (!p->classi[class_slot].in_use) return NULL; return p->classi[class_slot].nwal_L4_handle; } //internal: return L3 nwal_handle for class static void *netcp_cfgp_get_l3_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int class_slot) { if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS)) return NULL; if (!p->classi[class_slot].in_use) return NULL; return p->classi[class_slot].nwal_L3_handle; } /***********************************************************************************/ /****************************************API****************************************/ /***********************************************************************************/ /***************************************************************** * Queury Stats ****************************************************************/ void netcp_cfgReqStats(NETAPI_T h, NETCP_CFG_STATS_CB cb, int doClear, int *err) { nwal_RetValue ret; NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h; NetapiNwalTransInfo_t *pTransInfo; nwal_TransID_t transId; if ((!n) || (!cb)) {*err = NETAPI_ERR_BAD_INPUT; return ;} *err =0; pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &transId); if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return ;} pTransInfo->transType = NETAPI_NWAL_HANDLE_STAT_REQUEST; pTransInfo->netapi_handle = h; n->nwal_local.stats_cb = cb; ret = nwal_getPAStats( ((NETAPI_GLOBAL_T *) n->global)->nwal_context.nwalInstHandle, transId, NULL, doClear); if(ret != nwal_OK) { pTransInfo->inUse = nwal_FALSE; *err = NETAPI_ERR_BUSY; //no resources?? printf("> netcp_cfg reqStats failed, err=%d\n",ret); } } /***************************************************************** * CREATE A MAC INTERFACE ****************************************************************/ NETCP_CFG_MACIF_T netcp_cfgCreateMacInterface( NETAPI_T h, uint8_t *p_mac, int iface_no, int switch_port, NETCP_CFG_ROUTE_HANDLE_T route, NETCP_CFG_VLAN_T vlan, //future int state, //0=down, 1=up //ignored int * err ) { NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h; nwalMacParam_t MacInfo= { 0, /* validParams */ 0, /* ifNum */ 0, /* vlanId */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Local mac */ NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE, /* Continue parsing to next route for match */ NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, /* For next route fail action by default is route to host */ CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */ QMSS_PARAM_NOT_SPECIFIED /* Use default queue configured to NWAL if packet is routed to host */ }; nwal_RetValue retValue; NetapiNwalTransInfo_t *pTransInfo; nwal_TransID_t trans_id; if ((!n) || (!p_mac)) {*err = NETAPI_ERR_BAD_INPUT; return -1;} *err =0; pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id); if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return -1;} pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_MAC; pTransInfo->netapi_handle = h; /* set up MacInfo */ memcpy(&MacInfo.macAddr,p_mac,6); /* todo: vlan */ MacInfo.ifNum = switch_port; /* todo: check for 0/1 relative*/ if (route != NULL) { netcp_cfgp_build_route(route,&MacInfo.appRxPktFlowId, &MacInfo.appRxPktQueue); } pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING; retValue = nwal_setMacIface( ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, trans_id, (nwal_AppId) (NETAPI_NETCP_MATCH_GENERIC_MAC | iface_no), &MacInfo, &pTransInfo->handle); if(retValue != nwal_OK) { *err = NETAPI_ERR_NWAL_ERR0; printf (">netcp cfg - ERROR: nwal_setMacIface returned Error Code %d\n", retValue); pTransInfo->inUse = nwal_FALSE; return -1; } //pTransInfo->inUse = nwal_FALSE; //wait here until its done since scheduler isn't running yet most likely.. // todo: make this handled by scheduler poll later ?? if(trans_id != NWAL_TRANSID_SPIN_WAIT) { n->nwal_local.numPendingCfg++; while ((volatile) n->nwal_local.numPendingCfg) { // if response is there, then this poll squirts out in the CTl poll callback, // which handles the rest (including decrmenting #pending!! nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL); } } printf (">netcp cfg: MAC i/f %d added\n", iface_no); netcp_cfgp_insert_mac(&netapi_get_global()->nwal_context, p_mac, iface_no, state,vlan, (void *) pTransInfo->handle); pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE; pTransInfo->inUse = nwal_FALSE; return (NETAPI_NETCP_MATCH_GENERIC_MAC | iface_no); } /*****************************************************************/ /***************Delete a mac interface****************************/ /*****************************************************************/ void netcp_cfgDelMac(NETAPI_T h,int iface_no, int *err) { nwal_RetValue ret; NetapiNwalTransInfo_t *pTransInfo; nwal_TransID_t trans_id; NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h; void * ifHandle; //get the nwal handle assoicated with this iface ifHandle = netcp_cfgp_get_mac_handle(&netapi_get_global()->nwal_context, iface_no ); if(!ifHandle) {*err = NETAPI_ERR_BAD_INPUT; return ;} *err =0; //get a transaction id pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id); if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return ;} pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_MAC; pTransInfo->netapi_handle = h; //issue request ret = nwal_delMacIface( ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, trans_id, ifHandle); if(ret != nwal_OK) { *err = NETAPI_ERR_NWAL_ERR0; printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n", ret); pTransInfo->inUse = nwal_FALSE; return ; } //wait here until its done since scheduler isn't running yet most likely.. // todo: make this handled by scheduler poll later ?? if(trans_id != NWAL_TRANSID_SPIN_WAIT) { n->nwal_local.numPendingCfg++; while ((volatile) n->nwal_local.numPendingCfg) { // if response is there, then this poll squirts out in the CTl poll callback, // which handles the rest (including decrmenting #pending!! nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL); } } printf (">netcp cfg: MAC i/f %d deleted\n",iface_no); pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE; pTransInfo->inUse = nwal_FALSE; //zap the entry netcp_cfgp_delete_mac(&netapi_get_global()->nwal_context, iface_no); return ; } /*****************************************************************/ /***************Add IP to MAC interface (internal)****************/ /*****************************************************************/ static NETCP_CFG_IP_T netcp_cfgAddIpInternal( NETAPI_T h, int iface_no, nwal_IpType ipType, nwalIpAddr_t * ip_addr, nwalIpOpt_t * ip_qualifiers, NETCP_CFG_ROUTE_HANDLE_T route, //NULL for default int * err, int flag) //TRUE: add IP to iface. False: add IP as part of classifier { NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h; void * n_handle=NULL; nwalIpParam_t nwalIpParam= { pa_IPV4, /* IP Type */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Dest IP */ { 0x0,0,0,0},/* IP Options */ NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE, /* Continue parsing to next route for match */ NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, /* For next route fail action by default is route to host */ CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */ QMSS_PARAM_NOT_SPECIFIED /* Use default queue configured to NWAL if packet is routed to host */ }; nwal_RetValue retValue; NetapiNwalTransInfo_t *pTransInfo; nwal_TransID_t trans_id; int ip_slot=-1; NETCP_CFG_IP_T ip_rule_id; NETCP_CFG_IP_T temp; //verify that iface has been configured if (iface_no != NETCP_CFG_NO_INTERFACE) { if ((iface_no<0) || (iface_no>= TUNE_NETAPI_MAX_INTERFACES)) {*err = NETAPI_ERR_BAD_INPUT; return -1;} } if (iface_no != NETCP_CFG_NO_INTERFACE) { if(netapi_get_global()->nwal_context.interfaces[iface_no].in_use) { n_handle = netapi_get_global()->nwal_context.interfaces[iface_no].nwal_handle; } else { *err = NETAPI_ERR_BAD_INPUT; return -1; } } if (flag) //if adding IP to MAC then reserve a slot to save info { //find free slot for IP & reserve ip_slot= netcp_cfgp_find_ip_slot(&netapi_get_global()->nwal_context, iface_no); if (ip_slot <0) { *err= NETAPI_ERR_NOMEM; //no room return -1; } } //get a transaction object for config action pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id); if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return -1;} pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP; pTransInfo->netapi_handle = h; //build nwalIpParam memcpy(&nwalIpParam.locIpAddr,ip_addr, sizeof(nwalIpAddr_t)); nwalIpParam.ipType=ipType; if(route) { netcp_cfgp_build_route(route,&nwalIpParam.appRxPktFlowId, &nwalIpParam.appRxPktQueue); } else{} //use nwal defaults if (ip_qualifiers) memcpy(&nwalIpParam.ipOpt,ip_qualifiers, sizeof(nwalIpOpt_t)); else memset(&nwalIpParam.ipOpt,0, sizeof(nwalIpOpt_t)); //build the rule id that will be returned when a packet matches if (flag) ip_rule_id = NETAPI_NETCP_MATCH_GENERIC_IP | iface_no | ((ip_slot&&0xff)<<8); else ip_rule_id = (NETAPI_NETCP_MATCH_CLASS_L3 | iface_no); //perform config action pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING; retValue = nwal_setIPAddr( netapi_get_global()->nwal_context.nwalInstHandle, trans_id, (nwal_AppId) (ip_rule_id), n_handle, &nwalIpParam, &pTransInfo->handle); if(retValue != nwal_OK) { *err = NETAPI_ERR_NWAL_ERR0; printf (">netcp cfg: nwal_setIP returned Error Code %d\n", retValue); pTransInfo->inUse = nwal_FALSE; //zap the entry if (flag) { netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context, iface_no, ip_slot); } return -1; } //wait here until its done since scheduler isn't running yet most likely.. // todo: make this handled by scheduler poll later ?? if(trans_id != NWAL_TRANSID_SPIN_WAIT) { n->nwal_local.numPendingCfg++; while ((volatile) n->nwal_local.numPendingCfg) { // if response is there, then this poll squirts out in the CTl poll callback, // which handles the rest (including decrmenting #pending!! nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL); } } if (flag) { printf (">netcp cfg: IP added to interface %d (slot%d)\n", iface_no, ip_slot); netcp_cfgp_insert_ip(&netapi_get_global()->nwal_context, ipType, ip_addr, ip_qualifiers, iface_no, ip_slot, pTransInfo->handle); } pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE; temp = (NETCP_CFG_IP_T) pTransInfo->handle; pTransInfo->inUse = nwal_FALSE; return (flag ? ip_rule_id: temp); } /*****************************************************************/ /***************Add IP to MAC interface **************************/ /*****************************************************************/ NETCP_CFG_IP_T netcp_cfgAddIp( NETAPI_T h, int iface_no, nwal_IpType ipType, nwalIpAddr_t * ip_addr, nwalIpOpt_t * ip_qualifiers, NETCP_CFG_ROUTE_HANDLE_T route, //NULL for default int * err ) { return netcp_cfgAddIpInternal( h, iface_no, ipType, ip_addr, ip_qualifiers, route, err, 1); } /*****************************************************************/ /***************Delete an attached IP*****************************/ /*****************************************************************/ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no, nwal_IpType ipType, nwalIpAddr_t * ip_addr, nwalIpOpt_t * ip_qualifiers, NETCP_CFG_IP_T ip_rule_id, int *err, void * handle, /* if flag==0, handle must be valid */ int flag) /* flag==0 => delete IP rule that was part of classifier, not interface */ { nwal_RetValue ret; NetapiNwalTransInfo_t *pTransInfo; nwal_TransID_t trans_id; NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h; void * ifHandle; int ip_slot = (ip_rule_id>>8)&0xff; //get the nwal handle assoicated with this ip if (flag) { ifHandle = netcp_cfgp_get_ip_handle( &netapi_get_global()->nwal_context, iface_no, ip_slot ); } else { ifHandle = handle; } if(!ifHandle) {*err = NETAPI_ERR_BAD_INPUT; return ;} *err =0; //get a transaction id pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id); if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return ;} pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP; pTransInfo->netapi_handle = h; //issue request ret = nwal_delIPAddr( ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, trans_id, ifHandle); if(ret != nwal_OK) { *err = NETAPI_ERR_NWAL_ERR0; printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n", ret); pTransInfo->inUse = nwal_FALSE; return ; } //wait here until its done since scheduler isn't running yet most likely.. // todo: make this handled by scheduler poll later ?? if(trans_id != NWAL_TRANSID_SPIN_WAIT) { n->nwal_local.numPendingCfg++; while ((volatile) n->nwal_local.numPendingCfg) { // if response is there, then this poll squirts out in the CTl poll callback, // which handles the rest (including decrmenting #pending!! nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL); } } if (flag) printf (">netcp cfg: attached IP deleted\n"); else printf (">netcp cfg: Classifier IP rule deleted\n"); pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE; pTransInfo->inUse = nwal_FALSE; //zap the entry if (flag) netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context, iface_no, ip_slot); return ; } /*****************************************************************/ /***************Delete an attached IP*****************************/ /*****************************************************************/ void netcp_cfgDelIp(NETAPI_T h, int iface_no, nwal_IpType ipType, nwalIpAddr_t * ip_addr, nwalIpOpt_t * ip_qualifiers, NETCP_CFG_IP_T ip_rule_id, int *err) { netcp_cfgDelIpInternal( h, iface_no, ipType, ip_addr, ip_qualifiers, ip_rule_id, err, NULL, 1); return; } /** * @def netcp_cfgAddClass * @brief add a classifier rule into NETCP **/ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h, NETCP_CFG_CLASSIFIER_T *p_class, NETCP_CFG_ROUTE_HANDLE_T route, int action, int * err) { NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h; void * l3_handle=NULL; //ip handle nwal_RetValue retValue; NetapiNwalTransInfo_t *pTransInfo; nwal_TransID_t trans_id; int class_slot=-1; int iface_no; int ip_slot=-1; NETCP_CFG_CLASS_T classHandle; //returned by us nwal_appProtoType_t proto; nwalRxConnCfg_t tempCfg={ 0, //nwal_handle: to be filled in {0}, // l4 ports: to be filled in 0, //core id (NA) 0, //action CPPI_PARAM_NOT_SPECIFIED, //flow id QMSS_PARAM_NOT_SPECIFIED, //dest queue }; if(!p_class) { *err=NETAPI_ERR_BAD_INPUT; return -1;} switch(p_class->classType) { default: printf(">netcp_cfg : classifier type %d not supported\n",p_class->classType); break; case(NETCP_CFG_CLASS_TYPE_L3_L4): case(NETCP_CFG_CLASS_TYPE_L4): //assume just type l4 only (L2, L3 defined by iface, l3 id ) iface_no = p_class->u.c_l4.iface; if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4) { ip_slot = (p_class->u.c_l4.ip>>8)&0xff; } //verify that iface has been configured if (iface_no != NETCP_CFG_NO_INTERFACE) { if(!netapi_get_global()->nwal_context.interfaces[iface_no].in_use) { *err = NETAPI_ERR_BAD_INPUT; return -1; } } if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4) { //verify that ip has been configured and get its handle l3_handle = netcp_cfgp_get_ip_handle( &netapi_get_global()->nwal_context, iface_no, ip_slot ); } else { nwalIpParam_t tempParam={ pa_IPV4, /* IP Type */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Dest IP */ { 0x0,0,0,0},/* IP Options */ NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE, /* Continue parsing to next route for match */ NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, /* For next route fail action by default is route to host */ CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */ QMSS_PARAM_NOT_SPECIFIED /* Use default queue configured to NWAL if packet is routed to host */ }; //build nwalIpParam memcpy(&tempParam.locIpAddr,p_class->u.c_l3_l4.ip_addr, sizeof(nwalIpAddr_t)); tempParam.ipType=p_class->u.c_l3_l4.ipType; //use nwal defauls for route if (p_class->u.c_l3_l4.ip_qualifiers) memcpy(&tempParam.ipOpt,p_class->u.c_l3_l4.ip_qualifiers, sizeof(nwalIpOpt_t)); else memset(&tempParam.ipOpt,0, sizeof(nwalIpOpt_t)); //find if we have a matching L3 handle for IP classifier; if not create it retValue = nwal_getIPAddr (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, &tempParam, netcp_cfgp_get_mac_handle(&netapi_get_global()->nwal_context, iface_no ), &l3_handle); if (retValue != nwal_TRUE) { int ret; //**NEW IP RULE //need to attach this IP RULE to the MAC l3_handle= (void *) netcp_cfgAddIpInternal( h, iface_no, p_class->u.c_l3_l4.ipType, p_class->u.c_l3_l4.ip_addr, p_class->u.c_l3_l4.ip_qualifiers, p_class->u.c_l3_l4.p_fail_route, &ret, FALSE); if(!ret) { l3_handle=NULL; } } } if(!l3_handle) {*err = NETAPI_ERR_BAD_INPUT; return -1 ;} //find free slot for CLASS & reserve class_slot= netcp_cfgp_find_class_slot(&netapi_get_global()->nwal_context); if(class_slot<0) {*err = NETAPI_ERR_NOMEM; return -1;} classHandle = NETAPI_NETCP_MATCH_CLASS | (class_slot<<8) | (iface_no&0xff); //build request from template tempCfg.inHandle=l3_handle; if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4) { memcpy(&tempCfg.appProto,&p_class->u.c_l4.appProto,sizeof(nwalAppProto_t)); proto = p_class->u.c_l4.proto; } else { memcpy(&tempCfg.appProto,&p_class->u.c_l3_l4.appProto,sizeof(nwalAppProto_t)); proto = p_class->u.c_l3_l4.proto; } tempCfg.matchAction = (action==NETCP_CFG_ACTION_TO_SW) ? NWAL_MATCH_ACTION_HOST : NWAL_MATCH_ACTION_DISCARD; if (route) { netcp_cfgp_build_route(route,&tempCfg.appRxPktFlowId, &tempCfg.appRxPktQueue); } //get a transaction id pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id); if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return -1 ;} pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP; /* todo: fix this to TRANS_L4*/ pTransInfo->netapi_handle = h; //issue request retValue = nwal_addConn(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, trans_id, (nwal_AppId) classHandle, proto, &tempCfg, NULL, &pTransInfo->handle); if(retValue != nwal_OK) { *err = NETAPI_ERR_NWAL_ERR0; printf (">netcp cfg - ERROR: nwal_addConn returned Error Code %d\n", retValue); pTransInfo->inUse = nwal_FALSE; netcp_cfgp_delete_class(&netapi_get_global()->nwal_context, class_slot); return -1; } //wait here until its done since scheduler isn't running yet most likely.. // todo: make this handled by scheduler poll later ?? if(trans_id != NWAL_TRANSID_SPIN_WAIT) { n->nwal_local.numPendingCfg++; while ((volatile) n->nwal_local.numPendingCfg) { // if response is there, then this poll squirts out in the CTl poll callback, // which handles the rest (including decrmenting #pending!! nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL); } } printf (">netcp cfg: L4 Classifer added to interface %d ip %d (slot%d)\n", iface_no, ip_slot, class_slot); netcp_cfgp_insert_class(&netapi_get_global()->nwal_context, class_slot, p_class->classType, NULL, //L2 we have (p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4? l3_handle : NULL), pTransInfo->handle); pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE; return classHandle; } //end switch return -1; } //delete classifier void netcp_cfgDelClass(NETAPI_T h, NETCP_CFG_CLASS_T classId, int *err) { NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h; void * L4_handle; //class handle -> L4 void * L3_handle; //class handle -> L3 nwal_RetValue retValue; NetapiNwalTransInfo_t *pTransInfo; nwal_TransID_t trans_id; int class_slot=-1; //int iface; //int ip_slot; class_slot = (classId>>8)&0xffff; L4_handle=netcp_cfgp_get_l4_handle( &netapi_get_global()->nwal_context, class_slot ); if(!L4_handle) {*err = NETAPI_ERR_BAD_INPUT; return ;} L3_handle = netcp_cfgp_get_l3_handle( &netapi_get_global()->nwal_context, class_slot ); /* l3 handle might be NULL,, depending on type of classifier */ netcp_cfgp_delete_class( &netapi_get_global()->nwal_context, class_slot ); //get a transaction id pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id); if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return ;} pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP; pTransInfo->netapi_handle = h; //issue request for L4 retValue = nwal_delConn(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, trans_id, L4_handle); if(retValue != nwal_OK) { *err = NETAPI_ERR_NWAL_ERR0; printf (">netcp cfg - ERROR: nwal_delConn returned Error Code %d\n", retValue); pTransInfo->inUse = nwal_FALSE; return ; /* todo: what about the L3? */ } //wait here until its done since scheduler isn't running yet most likely.. // todo: make this handled by scheduler poll later ?? if(trans_id != NWAL_TRANSID_SPIN_WAIT) { n->nwal_local.numPendingCfg++; while ((volatile) n->nwal_local.numPendingCfg) { // if response is there, then this poll squirts out in the CTl poll callback, // which handles the rest (including decrmenting #pending!! nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL); } } printf (">netcp cfg: Classifer deleted\n"); pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE; pTransInfo->inUse = nwal_FALSE; /* delete L3 if we have to */ if (L3_handle) { netcp_cfgDelIpInternal( h, 0, 0, NULL, NULL, 0, err, L3_handle, 0); } return ; } /*--------------flow management--------*/ // ADD A Flow NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h, int n, Pktlib_HeapHandle handles[], int sizes[], int byte_offset, int * err ) { Cppi_RxFlowCfg rxFlowCfg; Uint8 isAlloc; Qmss_QueueHnd rxBufQ[TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW]; Uint32 rxBufSize[TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW]; int i; Cppi_FlowHnd FlowHnd; int slot; NETCP_CFG_FLOW_HANDLE_T retVal; *err= 0; /* ok */ //get a slot to save new flow slot = netcp_cfgp_find_flow_slot(&netapi_get_global()->nwal_context); if (slot<0) { *err= NETAPI_ERR_NOMEM; return NULL; } //configure flow memset(&rxFlowCfg,0,sizeof(Cppi_RxFlowCfg)); for (i = 0; i < TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW; i++) { if (i >= n) { rxBufQ[i] = 0; rxBufSize[i] = 0; } else { rxBufQ[i] = Pktlib_getInternalHeapQueue(handles[i]); //todo: verity sizes< heapsize //todo: verify order rxBufSize[i]= sizes[i]; } if (i && (rxBufQ[i] <= 0)) { rxBufQ[i] = rxBufQ[i-1]; rxBufSize[i] = 0; } } /* Configure Rx flow */ rxFlowCfg.flowIdNum = CPPI_PARAM_NOT_SPECIFIED; rxFlowCfg.rx_dest_qnum = 100; //DANGEROUS> TODO PUT VALID Q HERE rxFlowCfg.rx_dest_qmgr = 0; rxFlowCfg.rx_sop_offset = byte_offset; rxFlowCfg.rx_ps_location = Cppi_PSLoc_PS_IN_DESC; rxFlowCfg.rx_desc_type = Cppi_DescType_HOST; rxFlowCfg.rx_error_handling = 0; rxFlowCfg.rx_psinfo_present = 1; rxFlowCfg.rx_einfo_present = 1; rxFlowCfg.rx_dest_tag_lo = 0; rxFlowCfg.rx_dest_tag_hi = 0; rxFlowCfg.rx_src_tag_lo = 0; rxFlowCfg.rx_src_tag_hi = 0; rxFlowCfg.rx_size_thresh0_en = rxBufSize[1] ? 1 : 0; rxFlowCfg.rx_size_thresh1_en = rxBufSize[2] ? 1 : 0; rxFlowCfg.rx_size_thresh2_en = rxBufSize[3] ? 1 : 0; rxFlowCfg.rx_dest_tag_lo_sel = 0; rxFlowCfg.rx_dest_tag_hi_sel = 0; rxFlowCfg.rx_src_tag_lo_sel = 0; rxFlowCfg.rx_src_tag_hi_sel = 0; rxFlowCfg.rx_fdq1_qnum = rxBufQ[1]; rxFlowCfg.rx_fdq1_qmgr = 0; rxFlowCfg.rx_fdq2_qnum = rxBufQ[2]; rxFlowCfg.rx_fdq2_qmgr = 0; rxFlowCfg.rx_fdq3_qnum = rxBufQ[3]; rxFlowCfg.rx_fdq3_qmgr = 0; rxFlowCfg.rx_size_thresh0 = rxBufSize[1] ? rxBufSize[0] : 0; rxFlowCfg.rx_size_thresh1 = rxBufSize[2] ? rxBufSize[1] : 0; rxFlowCfg.rx_size_thresh2 = rxBufSize[3] ? rxBufSize[2] : 0; rxFlowCfg.rx_fdq0_sz0_qnum = rxBufQ[0]; rxFlowCfg.rx_fdq0_sz0_qmgr = 0; rxFlowCfg.rx_fdq0_sz1_qnum = rxBufQ[1]; rxFlowCfg.rx_fdq0_sz1_qmgr = 0; rxFlowCfg.rx_fdq0_sz2_qnum = rxBufQ[2]; rxFlowCfg.rx_fdq0_sz2_qmgr = 0; rxFlowCfg.rx_fdq0_sz3_qnum = rxBufQ[3]; rxFlowCfg.rx_fdq0_sz3_qmgr = 0; { //todo: replace this with a nwal call to get global cntx info Cppi_CpDmaInitCfg cpdmaCfg; memset(&cpdmaCfg,0,sizeof(Cppi_CpDmaInitCfg)); cpdmaCfg.dmaNum = Cppi_CpDma_PASS_CPDMA; FlowHnd = Cppi_configureRxFlow (Cppi_open (&cpdmaCfg), &rxFlowCfg, &isAlloc); } if (FlowHnd == NULL) { *err= NETAPI_ERR_NORES; netcp_cfgp_delete_flow(&netapi_get_global()->nwal_context, slot); return (NULL); } //update slot retVal = netcp_cfgp_insert_flow(&netapi_get_global()->nwal_context, slot, (void*) FlowHnd); printf(">netcp cfg: flow %d created\n", ((NETCP_CFG_FLOW_T *) retVal)->flowid); return ( retVal); } //Delete a flow void netcp_cfgDelFlow(NETAPI_T h , NETCP_CFG_FLOW_HANDLE_T f , int * err) { int slot; void * handle; *err=0; /* find entry */ slot = netcp_cfgp_find_flow(&netapi_get_global()->nwal_context, ((NETCP_CFG_FLOW_T *) f) ->flowid, &handle); if (slot<0) {*err = NETAPI_ERR_BAD_INPUT; return;} Cppi_closeRxFlow( (Cppi_FlowHnd) handle); netcp_cfgp_delete_flow(&netapi_get_global()->nwal_context, slot); printf(">netcp cfg: flow %d deleted\n", ((NETCP_CFG_FLOW_T *) f)->flowid); return; } /*************************************************************************/ /*********************************INTERNAL*******************************/ /************************************************************************/ /*************************************************************** ********************METCP CMD Reply Callback****************** ***************************************************************/ void netapi_NWALCmdCallBack (nwal_AppId appHandle, uint16_t trans_id, nwal_RetValue ret) { NetapiNwalTransInfo_t * p_trans; NETAPI_NWAL_LOCAL_CONTEXT_T *p_local=NULL; if(trans_id == NWAL_TRANSID_SPIN_WAIT) { netapi_get_global()->nwal_context.numBogusTransIds++; return; } p_trans= &netapi_get_global()->nwal_context.transInfos[trans_id]; p_local =&((NETAPI_HANDLE_T*) (p_trans->netapi_handle))->nwal_local; if(ret != nwal_OK) { printf (">netcp cfg : NWALCmdCallBack returned Error Code %d\n", ret); //todo: atomic inc netapi_get_global()->nwal_context.numCmdFail++; } else { //todo: atomic inc netapi_get_global()->nwal_context.numCmdPass++; switch(p_trans->transType) { case NETAPI_NWAL_HANDLE_TRANS_MAC: { if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING) { p_trans->state =NETAPI_NWAL_HANDLE_STATE_OPEN; } else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING) { p_trans->state =NETAPI_NWAL_HANDLE_STATE_IDLE; } break; } case NETAPI_NWAL_HANDLE_TRANS_IP: { if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING) { p_trans->state =NETAPI_NWAL_HANDLE_STATE_OPEN; } else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING) { p_trans->state =NETAPI_NWAL_HANDLE_STATE_IDLE; } break; } case NETAPI_NWAL_HANDLE_TRANS_PORT: { if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING) { p_trans->state =NETAPI_NWAL_HANDLE_STATE_OPEN; } else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING) { p_trans->state =NETAPI_NWAL_HANDLE_STATE_IDLE; } break; } case NETAPI_NWAL_HANDLE_TRANS_SA: { if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING) { p_trans->state =NETAPI_NWAL_HANDLE_STATE_OPEN; } else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING) { p_trans->state =NETAPI_NWAL_HANDLE_STATE_IDLE; } break; } case NETAPI_NWAL_HANDLE_TRANS_SA_POLICY: { if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING) { p_trans->state =NETAPI_NWAL_HANDLE_STATE_OPEN; } else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING) { p_trans->state =NETAPI_NWAL_HANDLE_STATE_IDLE; } break; } default: { printf ("netcp cfg> Invalid transaction type %d for trans_id: %d\n", p_trans->transType,trans_id); break; } } } p_local->numPendingCfg--; if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_IDLE) { p_trans->inUse = nwal_FALSE; } } /*******************************************************/ /**************stats reply callback**********************/ /*******************************************************/ void netapi_NWALCmdPaStatsReply (nwal_AppId appHandle, nwal_TransID_t trans_id, paSysStats_t *stats) { NetapiNwalTransInfo_t * p_trans; NETAPI_NWAL_LOCAL_CONTEXT_T *p_local=NULL; if(trans_id == NWAL_TRANSID_SPIN_WAIT) { netapi_get_global()->nwal_context.numBogusTransIds++; return; } p_trans= &netapi_get_global()->nwal_context.transInfos[trans_id]; p_trans->inUse = nwal_FALSE; p_local =&((NETAPI_HANDLE_T*) (p_trans->netapi_handle))->nwal_local; //save a local copy of some stuff*/ p_local->numL2PktsRecvd=stats->classify1.nPackets; p_local->numL3PktsRecvd=stats->classify1.nIpv4Packets; #if 0 p_local->numL4PktsRecvd=stats->; p_local->numL4PktsSent=stats->; p_local->TxErrDrop=stats->; #endif //callout result to application !! if (p_local->stats_cb) (*p_local->stats_cb)(p_trans->netapi_handle,stats); }