Added support for routeType configurtion for exception rules.
authorTinku Mannan <tmannan@ti.com>
Mon, 4 Nov 2013 14:13:05 +0000 (09:13 -0500)
committerTinku Mannan <tmannan@ti.com>
Mon, 4 Nov 2013 14:13:05 +0000 (09:13 -0500)
Added support for remote/source IP configuration for IP rules.

ti/runtime/netapi/netcp_cfg.h
ti/runtime/netapi/src/netapi_init.c
ti/runtime/netapi/src/netcp_cfg.c
ti/runtime/netapi/test/net_test_utils.c

index d4decbcda461facd93ad3bcefd969b903026a103..f97dfa25c80e815ca1c64e2005cec4daa27fc952 100755 (executable)
@@ -139,36 +139,6 @@ typedef NETCP_CFG_FLOW_T* NETCP_CFG_FLOW_HANDLE_T;
 #define NETCP_DEFAULT_ROUTE (NETCP_CFG_ROUTE_HANDLE_T) NULL
 
 
-#if 0
-/**
- * @ingroup cfg_constants
- * @def  NETCP_CFG_ROUTE_VLAN_PRIORITY
-* @brief Route by using VLAN bits as priority
- */
-#define NETCP_CFG_ROUTE_VLAN_PRIORITY        0x1
-
-/**
- * @ingroup cfg_constants
- * @def  NETCP_CFG_ROUTE_DSCP_PRIORITY
-* @brief Route by using DSCP value as priority
- */
-#define NETCP_CFG_ROUTE_DSCP_PRIORITY        0x2
-
-/**
- * @ingroup cfg_constants
- * @def  NETCP_CFG_ROUTE_RX_INTF
-* @brief Route by using EMAC port (interface) number as destination queue offset
- */
-#define NETCP_CFG_ROUTE_RX_INTF              0x4
-
-/**
- * @ingroup cfg_constants
- * @def  NETCP_CFG_ROUTE_RX_INTF_W_FLOW
- * @brief Route by using EMAC port (interface) number as both
- *        destination queue and CPPI flow offset
- */
-#define NETCP_CFG_ROUTE_RX_INTF_W_FLOW       0x8
-#endif
 /**
  *  @ingroup cfg_constants
  *  @{
@@ -578,7 +548,8 @@ void netapi_netcpCfgDelFlow(NETAPI_T h ,
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
  *  @param[in]  iface_no    interface number (0,1,..)
  *  @param[in]  ipType  type of IP address (V4 for V6)
- *  @param[in]  ip_addr local
+ *  @param[in]  ip_addr destination or local
+ *  @param[in]  ip_rem_addr source or remote
  *  @param[in]  ip_qualifiers   ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
  *                              diffserv category for example.
  *  @param[in]  route       handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
@@ -593,6 +564,7 @@ NETCP_CFG_IP_T  netapi_netcpCfgAddIp(NETAPI_T                   h,
                                      int                        iface_no,
                                      nwal_IpType                ipType,
                                      nwalIpAddr_t*              ip_addr,
+                                     nwalIpAddr_t*              ip_rem_addr,
                                      nwalIpOpt_t*               ip_qualifiers,
                                      NETCP_CFG_ROUTE_HANDLE_T   route,
                                      void*                      user_data,
index b379104d3a677d3c8e8f9635f2931077bc0c1f73..0620a1cb7874b08739976bf93c2a948679c7f865 100755 (executable)
@@ -202,7 +202,7 @@ uint8_t nwalHandleMem[NWAL_CHAN_HANDLE_SIZE]ALIGN(CACHE_LINESZ);
 typedef struct NETAPI_PA_SHM_Tag
 {
 /* todo: Check if below size information can be made available from pa interface file */
-#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0      128
+#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0      256
 /* PA instance */
 /* Memory used for the PA Instance. Needs to be assigned global uncached memory for chip */
 uint8_t paBuf0[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0]ALIGN(CACHE_LINESZ);
@@ -345,7 +345,6 @@ int netapip_initNwal(
     nwalGlobCfg.paPowerOn = nwal_TRUE;
     nwalGlobCfg.saPowerOn = nwal_TRUE;
     nwalGlobCfg.paFwActive = nwal_TRUE;
-    nwalGlobCfg.paFwActive = nwal_FALSE;
     nwalGlobCfg.saFwActive = nwal_FALSE;
 
     /* Pick Default Physical Address */
index 4207166a75829bb5fb5358950f8f60b9229f3c57..1e8c0ea8214154536a2d8f985ee075d6cb23bf95 100755 (executable)
@@ -499,34 +499,6 @@ static void netapip_netcpCfgDeleteIp(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
     }
 }
 
-/***************************************************************************
- * FUNCTION PURPOSE:  Netapi internal function to see if this IP is associated
- *                    with any classifiers and if so, can only be deleted when
-                      its associated with only 1 classifier.
- ***************************************************************************
- * DESCRIPTION:Netapi internal function to check reference count of IP
- ***************************************************************************/
-static Bool netapip_netcpCfgCheckIpRefCount(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                                       int ip_slot)
-{
-
-#if 0
-    if ((ip_slot >=0) &&(ip_slot <=TUNE_NETAPI_MAX_NUM_IP))
-    {
-            /* IS IP is associated with alteast 2 rules, if yes, then dont delete IP */
-            if(p>ips[ip_slot].ref_count)
-                p->ips[ip_slot].ref_count--;
-            if (p>ips[ip_slot].ref_count)
-                return FALSE;
-            else
-                return TRUE;
-    }
-    else
-        return FALSE;
-#endif
-    return TRUE;
-}
-
 /***************************************************************************
  * FUNCTION PURPOSE:  Netapi internal function to get IP handle associated with IP address
  ***************************************************************************
@@ -779,6 +751,7 @@ NETCP_CFG_MACIF_T  netapi_netcpCfgCreateMacInterface(NETAPI_T  h,
         0,      /* ifNum */
         0,      /* vlanId      */
         { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },      /* Local mac */
+        { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },      /* Remote 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 */
@@ -961,23 +934,26 @@ static NETCP_CFG_IP_T  netapip_netcpCfgAddIpInternal(NETAPI_T  h,
                                                      int  iface_no,
                                                      nwal_IpType ipType,
                                                      nwalIpAddr_t  * ip_addr,
+                                                     nwalIpAddr_t  *ip_rem_addr,
                                                      nwalIpOpt_t * ip_qualifiers,
                                                      NETCP_CFG_ROUTE_HANDLE_T  route,/*NULL for default*/
                                                      void * user_data,
                                                      int * err,
                                                      int  flag) /*TRUE: add IP to iface,
                                                      FALSE: add IP as part of classifier */
-                            {
+{
+    static unsigned char zeroIP4[]={0,0,0,0};
+    static unsigned char zeroIP6[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     void * n_handle=NULL;
     nwalIpParam_t    nwalIpParam= {
     0,
     pa_IPV4,      /* IP Type */
     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Dest IP */
+    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Source 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 */
-    0,
     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 */
     0
@@ -998,7 +974,7 @@ static NETCP_CFG_IP_T  netapip_netcpCfgAddIpInternal(NETAPI_T  h,
     if (iface_no != NETCP_CFG_NO_INTERFACE)
     {
         netapi_Log("netapip_netcpCfgAddIpInternal, in_use %d\n", netapi_get_global()->nwal_context.interfaces[iface_no].in_use);
-        netapi_Log("netcp-cfgAddIpInternal, p 0x%x\n", &netapi_get_global()->nwal_context);
+        netapi_Log("netapip_netcpCfgAddIpInternal, p 0x%x\n", &netapi_get_global()->nwal_context);
         if(netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
         {
             n_handle =  netapi_get_global()->nwal_context.interfaces[iface_no].nwal_handle;
@@ -1044,6 +1020,25 @@ static NETCP_CFG_IP_T  netapip_netcpCfgAddIpInternal(NETAPI_T  h,
 
     //build nwalIpParam
     memcpy(&nwalIpParam.locIpAddr,ip_addr, sizeof(nwalIpAddr_t));
+    if (ip_rem_addr)
+    {
+        if (ipType == nwal_IPV4)
+        {
+            if(memcmp(ip_rem_addr, zeroIP4, sizeof(nwalIpv4Addr_t)))
+            {
+                nwalIpParam.validParams |= NWAL_SET_IP_VALID_PARAM_REMOTE_IP;
+                memcpy(&nwalIpParam.remIpAddr,ip_rem_addr, sizeof(nwalIpAddr_t));
+            }
+        }
+        else
+        {
+            if(memcmp(ip_rem_addr, zeroIP6, sizeof(nwalIpv6Addr_t)))
+            {
+                nwalIpParam.validParams |= NWAL_SET_IP_VALID_PARAM_REMOTE_IP;
+                memcpy(&nwalIpParam.remIpAddr,ip_rem_addr, sizeof(nwalIpAddr_t));
+            }
+        }
+    }
     nwalIpParam.ipType=ipType;
     if(route)
     {
@@ -1109,7 +1104,7 @@ static NETCP_CFG_IP_T  netapip_netcpCfgAddIpInternal(NETAPI_T  h,
         {
             netapip_freeTransInfo(pTransInfo);
             *err = NETAPI_ERR_PA_FW;
-            netapi_Log (">netapip_netcpCfgAddIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
+            netapi_Log ("netapip_netcpCfgAddIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
             return -1;
         }
     }
@@ -1140,13 +1135,22 @@ NETCP_CFG_IP_T  netapi_netcpCfgAddIp(NETAPI_T                  h,
                                      int                       iface_no,
                                      nwal_IpType               ipType,
                                      nwalIpAddr_t*             ip_addr,
+                                     nwalIpAddr_t*             ip_rem_addr,
                                      nwalIpOpt_t*              ip_qualifiers,
                                      NETCP_CFG_ROUTE_HANDLE_T  route,  //NULL for default
                                      void*                     user_data,
                                      int*                      err)
 {
-    return netapip_netcpCfgAddIpInternal(h, iface_no, ipType, ip_addr, 
-                                         ip_qualifiers, route, user_data,err, 1);
+    return netapip_netcpCfgAddIpInternal(h,
+                                         iface_no,
+                                         ipType,
+                                         ip_addr,
+                                         ip_rem_addr,
+                                         ip_qualifiers, 
+                                         route, 
+                                         user_data,
+                                         err,
+                                         1);
 }
 
 /********************************************************************
@@ -1188,15 +1192,6 @@ static void netapip_netcpCfgDelIpInternal(NETAPI_T h,
     }
     *err =0;
 
-    /* need to check to see if this IP is attached to a classifier(s)
-       and only delete if this is last classifier */
-    /* need to check to see if this IP is attached to  classifier
-       if referernce count is 1, this is only instance IP exists*/
-     if (!netapip_netcpCfgCheckIpRefCount(&netapi_get_global()->nwal_context, ip_slot))
-     {
-        return;
-     }
-    
     //get a transaction id
     pTransInfo = netapip_getFreeTransInfo(n,
                                           (NETAPI_PROC_GLOBAL_T *) n->proc_global,
@@ -1353,6 +1348,7 @@ NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T                  h,
                     0,
                     pa_IPV4,      /* IP Type */
                     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Dest IP */
+                    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  /* Source 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 */
@@ -1383,6 +1379,7 @@ NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T                  h,
                                       h, iface_no, 
                                       p_class->u.c_l3_l4.ipType,
                                       p_class->u.c_l3_l4.ip_addr,
+                                      NULL,
                                       p_class->u.c_l3_l4.ip_qualifiers,
                                       p_class->u.c_l3_l4.p_fail_route,
                                       user_data,
@@ -1782,16 +1779,16 @@ NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T
     nwal_RetValue retVal = 0;
     memset(&ctrl, 0, sizeof(nwalCtlInfo_t));
 
+
     if (p_route != NULL)
     {
-#if 0
         if((p_route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
             NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
         {
            ctrl.validParams |= 
-                    NWAL_SET_MAC_VALID_PARAM_ROUTE_TYPE;
+                    NWAL_CONTROL_VALID_PARAM_ROUTE_TYPE;
+           ctrl.routeType = p_route->routeType;
         }
-#endif
         netapip_netcpCfgBuildRoute(p_route,
                                    &ctrl.appRxPktFlowId,
                                    &ctrl.appRxPktQueue,
@@ -1820,6 +1817,7 @@ NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T
     retVal = nwal_control(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, &ctrl);
 
     return (NETCP_CFG_EXCEPTION_PKT_T) ctrl.appId;
+
 }
 
 /*************************************************************************/
index 22e4a97ce6d5e07eb566990d470b4daf607fad62..76dae0ef3d3909cd51fa8b468e3e2fbf5e0fc8e0 100755 (executable)
@@ -1358,6 +1358,7 @@ void netTest_utilCreateInterfaces(uint8_t num_macs, uint8_t num_ips)
                           netTestCfg.attach_iface[i],
                           nwal_IPV4,
                           (nwalIpAddr_t*)&netTestCfg.ip[i].ipv4[0],
+                          NULL,
                           NULL,  //all IP
                           (NETCP_CFG_ROUTE_HANDLE_T) NULL,
                           (void*)NULL,