index 63ae7fb30b2be69f217a1e554e5431d562d53687..41988cb77571a224f3839cd1831949f88f558d76 100755 (executable)
* DESCRIPTION: netapi sample scheduler source file for user space transport
* library
*
- * REVISION HISTORY: rev 0.0.1
+ * REVISION HISTORY:
*
- * Copyright (c) Texas Instruments Incorporated 2010-2011
+ * Copyright (c) Texas Instruments Incorporated 2013
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
****************************************/
-#include "netapi.h"
#include "netapi_sched.h"
#define NO_TIMER //turn off timer related scheduling
/********************************************************************
- * FUNCTION PURPOSE: API to get scheduling context statistics
+ * FUNCTION PURPOSE: API to get scheduling context statistics
********************************************************************
- * DESCRIPTION: API to get scheduling context statistics
+ * DESCRIPTION: API to get scheduling context statistics
********************************************************************/
void netapi_schedGetStats(NETAPI_SCHED_HANDLE_T *s,
- unsigned long long * p_pkts,
- unsigned long long * p_cycles,
- unsigned long long * p_cache_cycles)
+ unsigned long long * p_pkts,
+ unsigned long long * p_cycles,
+ unsigned long long * p_cache_cycles)
{
*p_pkts= s->stats.num_pkts;
*p_cycles= s->stats.busy_cycles;
{
*p_err=0;
NETAPI_SCHED_HANDLE_T * ph = (NETAPI_SCHED_HANDLE_T *) netapi_get_scheduler(n);
- if(!ph) {*p_err= NETAPI_ERR_NOMEM; return NULL;}
- if(!p_config) {*p_err= NETAPI_ERR_BAD_INPUT; return NULL;}
+ if(!ph)
+ {
+ *p_err= NETAPI_ERR_NOMEM;
+ return NULL;
+ }
+ if(!p_config)
+ {
+ *p_err= NETAPI_ERR_BAD_INPUT;
+ return NULL;
+ }
memcpy(&ph->config,p_config,sizeof(NETAPI_SCHED_CONFIG_T));
ph->start = hplib_mUtilGetTimestamp();
ph->back = (void *) n;
if (ph->config.valid_flags & NETAPI_SCHED_DURATION)
{
- if (ph->config.duration == NETAPI_SCHED_FOREVER)
- {
- ph->shutdown_time=(uint64_t) -1;
- }
- else
- {
- ph->shutdown_time = ph->start + ph->config.duration;
- }
+ if (ph->config.duration == NETAPI_SCHED_FOREVER)
+ {
+ ph->shutdown_time=(uint64_t) -1;
+ }
+ else
+ {
+ ph->shutdown_time = ph->start + ph->config.duration;
+ }
+ }
+ else
+ {
+ ph->shutdown_time = (uint64_t) -1;
}
- else ph->shutdown_time = (uint64_t) -1;
ph->state =NETAPI_SCHED_STATE_OPEN;
return(ph);
}
* DESCRIPTION: API to get NETAPI scheduling context statistics
********************************************************************/
/* main entry point. caller gives up control to scheduler */
-int netapi_schedRun(NETAPI_SCHED_HANDLE_T *s, int *p_err)
+int netapi_schedRun(NETAPI_SCHED_HANDLE_T *s,
+ int *p_err)
{
int err;
*p_err=0;
t = hplib_mUtilGetTimestamp();
#endif
next_house -=1;
- //poll all pktio channels we have open in RX mode
- //Osal_cache_op_measure_reset();
+
cache_op_b2= Osal_cache_op_measure(&n_c_ops);
t1=hplib_mUtilGetPmuCCNT();
- pkts=pktio_pollAll((NETAPI_T) s->back, NULL, &err);
+ /* poll all pktio channels we have open in RX mode */
+ pkts=netapi_pktioPollAll((NETAPI_T) s->back, NULL, &err);
if (!pkts && (s->config.yield == TRUE))
{
sched_yield();
s->stats.cache_cycles += (unsigned long long) cache_op_b2;
}
- //poll pktlib garbage collections for registered heaps
+ /* poll pktlib garbage collections for registered heaps */
if (TRUE == s->config.pollGarbageQ)
{
netapi_pollHeapGarbage((NETAPI_T) s->back);
}
- //poll NETCP/PA control channels
+ /*poll NETCP/PA control channels */
if (TRUE == s->config.pollCtrlQ)
{
netapi_netcpPoll((NETAPI_T) s->back);
}
- //see if time to do a house keeping callback
+ /* see if time to do a house keeping callback */
if ((s->config.valid_flags & NETAPI_SCHED_CBV) && s->config.house_cb)
if (next_house<=0)
{
s->config.house_cb(s);
next_house = s->config.interval;
}
- //see if we were closed and/or its time to close
+ /* see if we were closed and/or its time to close */
if (s->state!= NETAPI_SCHED_STATE_OPEN)
{
s->state=NETAPI_SCHED_STATE_CLOSE;
* DESCRIPTION: API to close a scheduling context
********************************************************************/
/* shutdown scheduler context */
-int netapi_schedClose(NETAPI_SCHED_HANDLE_T * s, NETAPI_SCHED_SHUTDOWN_T * p_close, int * p_err)
+int netapi_schedClose(NETAPI_SCHED_HANDLE_T * s,
+ NETAPI_SCHED_SHUTDOWN_T * p_close,
+ int * p_err)
{
*p_err=0;
if (p_close->shutdown_type == NETAPI_SCHED_SHUTDOWN_NOW)
{
- s->state=NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS; //say we are closing
+ s->state=NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS;
}
return 1;
}