From 54f5a270c74c405d3bb0e15d5b69d6d0e1e96c49 Mon Sep 17 00:00:00 2001 From: "satish.karunanithi" Date: Mon, 13 Aug 2018 19:39:55 +0530 Subject: Feat : LWIP integration part3 Change-Id: I62998963da110827a410287eed90a22da7ae4222 Signed-off-by: satish.karunanithi --- .../lwip_helper_files/lwip/arch/atomic_32.h | 53 +++++++++ .../release/lwip_helper_files/lwip/arch/cc.h | 82 ++++++++++++++ .../release/lwip_helper_files/lwip/arch/queue.h | 30 ++++++ .../release/lwip_helper_files/lwip/arch/sys_arch.h | 29 +++++ .../lwip_helper_files/lwip/arch/win_minmax.h | 120 +++++++++++++++++++++ 5 files changed, 314 insertions(+) create mode 100644 stacks/lwip_stack/release/lwip_helper_files/lwip/arch/atomic_32.h create mode 100644 stacks/lwip_stack/release/lwip_helper_files/lwip/arch/cc.h create mode 100644 stacks/lwip_stack/release/lwip_helper_files/lwip/arch/queue.h create mode 100644 stacks/lwip_stack/release/lwip_helper_files/lwip/arch/sys_arch.h create mode 100644 stacks/lwip_stack/release/lwip_helper_files/lwip/arch/win_minmax.h (limited to 'stacks/lwip_stack/release/lwip_helper_files/lwip') diff --git a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/atomic_32.h b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/atomic_32.h new file mode 100644 index 0000000..15a058b --- /dev/null +++ b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/atomic_32.h @@ -0,0 +1,53 @@ +/* + * atomic_32.h + * + */ + +#ifndef ATOMIC_32_H_ +#define ATOMIC_32_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct + { + volatile int counter; + } atomic_t; + +#define ATOMIC_INIT(i) {(i)} +#define atomic_read(v) (*(volatile int *)&(v)->counter) +#define atomic_set(v, i) (((v)->counter) = (i)) + + static inline void atomic_add (int i, atomic_t * v) + { + __asm__ __volatile__ ( + /*LOCK_PREFIX "addl %1,%0" */ + "addl %1,%0":"+m" (v->counter):"ir" (i)); + } + + static inline void atomic_sub (int i, atomic_t * v) + { + __asm__ __volatile__ ( + /*LOCK_PREFIX "subl %1,%0" */ + "subl %1,%0":"+m" (v->counter):"ir" (i)); + } + + static __inline__ void atomic_inc (atomic_t * v) + { + __asm__ __volatile__ ( + /*LOCK_PREFIX "incl %0" */ + "incl %0":"+m" (v->counter)); + } + + static __inline__ void atomic_dec (atomic_t * v) + { + __asm__ __volatile__ ( + /*LOCK_PREFIX "decl %0" */ + "decl %0":"+m" (v->counter)); + } +#ifdef __cplusplus +} +#endif +#endif /* ATOMIC_32_H_ */ diff --git a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/cc.h b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/cc.h new file mode 100644 index 0000000..4e21a75 --- /dev/null +++ b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/cc.h @@ -0,0 +1,82 @@ +#ifndef LWIP_ARCH_CC_H +#define LWIP_ARCH_CC_H + +#include +#include +#include +#include +#include +#include + +#ifndef LWIP_MAX_S16_NUM +#define LWIP_MAX_S16_NUM ((s16_t)0x7fff) +#endif + +#ifndef LWIP_MAX_U16_NUM +#define LWIP_MAX_U16_NUM ((u16_t)0xFfff) +#endif + +#ifndef LWIP_MAX_U32_NUM +#define LWIP_MAX_U32_NUM ((u32_t)0xffffffff) +#endif + +#ifndef LWIP_MAX_S32_NUM +#define LWIP_MAX_S32_NUM ((s32_t)0x7fffffff) +#endif + +#ifndef LWIP_MAX_U64_NUM +#define LWIP_MAX_U64_NUM ((u64_t)0xffffffffffffffff) +#endif + +#ifndef LWIP_MAX_S64_NUM +#define LWIP_MAX_S64_NUM ((s64_t)0x7fffffffffffffff) +#endif + +#define NONBLOCK_MODE_FOR_ALG 2 /* it is possible to get fail */ +#define BLOCK_MODE_FOR_ALG 1 /* will block till success */ +#define NONBLOCK_MODE_NOT_FOR_ALG 0 + +typedef uint64_t u64_t; +typedef int64_t s64_t; + +typedef uint32_t u32_t; +typedef int32_t s32_t; + +typedef uint16_t u16_t; +typedef int16_t s16_t; + +typedef uint8_t u8_t; +typedef int8_t s8_t; + +typedef uintptr_t mem_ptr_t; + +#define PACK_STRUCT_FIELD(x) x +#define PACK_STRUCT_STRUCT +#define PACK_STRUCT_BEGIN +#define PACK_STRUCT_END + +#define S16_F "d" +#define U16_F "u" +#define X16_F "x" + +#define S32_F "d" +#define U32_F "u" +#define X32_F "x" + +#define S64_F "ld" +#define U64_F "lu" +#define X64_F "x" + +#ifndef BYTE_ORDER +#define BYTE_ORDER LITTLE_ENDIAN +#endif + +//#define LWIP_PROVIDE_ERRNO + +#ifndef LWIP_PLATFORM_DIAG +#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0) +#endif +#ifndef LWIP_DEBUG +#define LWIP_DEBUG 1 +#endif +#endif diff --git a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/queue.h b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/queue.h new file mode 100644 index 0000000..238ef05 --- /dev/null +++ b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/queue.h @@ -0,0 +1,30 @@ +#ifndef __QUEUE_H__ +#define __QUEUE_H__ +#ifdef __cplusplus +extern "C" +{ + +#endif +#include "common_mem_base_type.h" +#ifdef HAL_LIB +#else +#include "rte_ring.h" +#endif +#include "nsfw_mem_api.h" +//#include "stackx_dfx_api.h" + +#include "sys.h" + + typedef struct queue + { + PRIMARY_ADDR mring_handle llring; + } queue_t; + + err_t queue_push (queue_t * q, void *msg, int isTrypush); + void *queue_pop (queue_t * q, u32_t * timeout, int isTryPop); + +#ifdef __cplusplus + +} +#endif +#endif diff --git a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/sys_arch.h b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/sys_arch.h new file mode 100644 index 0000000..92ff049 --- /dev/null +++ b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/sys_arch.h @@ -0,0 +1,29 @@ +#ifndef STACKX_ARCH_SYS_ARCH_H +#define STACKX_ARCH_SYS_ARCH_H +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +#include "cc.h" + +/*add by daifen 2012.7.27*/ + typedef uint64_t sys_thread_t; + + extern u64_t hz_per_ms; + + void stackx_global_lock (void); + void stackx_global_unlock (void); + +#define SYS_ARCH_PROTECT(lev) stackx_global_lock() +#define SYS_ARCH_UNPROTECT(lev) stackx_global_unlock() +#define SYS_ARCH_DECL_PROTECT(lev) + +#ifdef __cplusplus + +} +#endif +#endif diff --git a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/win_minmax.h b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/win_minmax.h new file mode 100644 index 0000000..e1e64ac --- /dev/null +++ b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/win_minmax.h @@ -0,0 +1,120 @@ +/** + * lib/minmax.c: windowed min/max tracker by Kathleen Nichols. + * + */ +#ifndef MINMAX_H +#define MINMAX_H + +#include "types.h" +#include "rtp_branch_prediction.h" + +/* A single data point for our parameterized min-max tracker */ +struct minmax_sample +{ + u32_t t; /* time measurement was taken */ + u32_t v; /* value measured */ +}; + +/* State for the parameterized min-max tracker */ +struct minmax +{ + struct minmax_sample s[3]; +}; + +static inline u32_t +minmax_get (const struct minmax *m) +{ + return m->s[0].v; +} + +static inline u32_t +minmax_reset (struct minmax *m, u32_t t, u32_t meas) +{ + struct minmax_sample val = {.t = t,.v = meas }; + + m->s[2] = m->s[1] = m->s[0] = val; + return m->s[0].v; +} + +/* As time advances, update the 1st, 2nd, and 3rd choices. */ +static u32_t +minmax_subwin_update (struct minmax *m, u32_t win, + const struct minmax_sample *val) +{ + u32_t dt = val->t - m->s[0].t; + + if (unlikely (dt > win)) + { + /* + * Passed entire window without a new val so make 2nd + * choice the new val & 3rd choice the new 2nd choice. + * we may have to iterate this since our 2nd choice + * may also be outside the window (we checked on entry + * that the third choice was in the window). + */ + m->s[0] = m->s[1]; + m->s[1] = m->s[2]; + m->s[2] = *val; + if (unlikely (val->t - m->s[0].t > win)) + { + m->s[0] = m->s[1]; + m->s[1] = m->s[2]; + m->s[2] = *val; + } + } + else if (unlikely (m->s[1].t == m->s[0].t) && dt > win / 4) + { + /* + * We've passed a quarter of the window without a new val + * so take a 2nd choice from the 2nd quarter of the window. + */ + m->s[2] = m->s[1] = *val; + } + else if (unlikely (m->s[2].t == m->s[1].t) && dt > win / 2) + { + /* + * We've passed half the window without finding a new val + * so take a 3rd choice from the last half of the window + */ + m->s[2] = *val; + } + return m->s[0].v; +} + +/* Check if new measurement updates the 1st, 2nd or 3rd choice max. */ +static inline u32_t +minmax_running_max (struct minmax *m, u32_t win, u32_t t, u32_t meas) +{ + struct minmax_sample val = {.t = t,.v = meas }; + + if (unlikely (val.v >= m->s[0].v) || /* found new max? */ + unlikely (val.t - m->s[2].t > win)) /* nothing left in window? */ + return minmax_reset (m, t, meas); /* forget earlier samples */ + + if (unlikely (val.v >= m->s[1].v)) + m->s[2] = m->s[1] = val; + else if (unlikely (val.v >= m->s[2].v)) + m->s[2] = val; + + return minmax_subwin_update (m, win, &val); +} + +/* Check if new measurement updates the 1st, 2nd or 3rd choice min. */ +static inline u32_t +minmax_running_min (struct minmax *m, u32_t win, u32_t t, u32_t meas) +{ + struct minmax_sample val = {.t = t,.v = meas }; + + if (unlikely (val.v <= m->s[0].v) || /* found new min? */ + unlikely (val.t - m->s[2].t > win)) /* nothing left in window? */ + return minmax_reset (m, t, meas); /* forget earlier samples */ + + if (unlikely (val.v <= m->s[1].v)) + m->s[2] = m->s[1] = val; + else if (unlikely (val.v <= m->s[2].v)) + m->s[2] = val; + + return minmax_subwin_update (m, win, &val); +} + +#endif -- cgit 1.2.3-korg