#ifndef _IPP_METERS_METER_IMPL_H
#define _IPP_METERS_METER_IMPL_H
#include <sys/types.h>
#include <sys/cmn_err.h>
#include <sys/debug.h>
#include <sys/spl.h>
#include <ipp/ipp.h>
#include <inet/ipp_common.h>
#include <ipp/meters/meter.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
enum meter_colour {
TOKENMT_GREEN = 0x01,
TOKENMT_YELLOW = 0x02,
TOKENMT_RED = 0x04
};
#define TOKENMT_NO_ACTION 0x7fffffff
#define METER_SEC_TO_NSEC 1000000000
#define METER_MSEC_TO_NSEC 1000000
#define _TOKENMT_DEBUG
#define _TSWTCL_DEBUG
#ifdef _TOKENMT_DEBUG
#define tokenmt0dbg(a) printf a
#define tokenmt1dbg(a) if (tokenmt_debug > 2) printf a
#define tokenmt2dbg(a) if (tokenmt_debug > 3) printf a
#else
#define tokenmt0dbg(a)
#define tokenmt1dbg(a)
#define tokenmt2dbg(a)
#endif
#ifdef _TSWTCL_DEBUG
#define tswtcl0dbg(a) printf a
#define tswtcl1dbg(a) if (tswtcl_debug > 2) printf a
#define tswtcl2dbg(a) if (tswtcl_debug > 3) printf a
#else
#define tswtcl0dbg(a)
#define tswtcl1dbg(a)
#define tswtcl2dbg(a)
#endif
#define SRTCL_TOKENMT 0x01
#define TRTCL_TOKENMT 0x02
#define DROP_PRECD_MASK 0x07
typedef struct meter_stat_t {
ipp_named_t red_bits;
ipp_named_t yellow_bits;
ipp_named_t green_bits;
ipp_named_t red_packets;
ipp_named_t yellow_packets;
ipp_named_t green_packets;
ipp_named_t epackets;
} meter_stat_t;
#define TOKENMT_STATS_STRING "tokenmt statistics"
#define TSWTCL_STATS_STRING "tswtclmtr statistics"
#define METER_STATS_COUNT 7
typedef struct tokenmt_cfg_s {
ipp_action_id_t red_action;
ipp_action_id_t yellow_action;
ipp_action_id_t green_action;
uint_t tokenmt_type;
uint32_t committed_rate;
uint32_t peak_rate;
uint32_t committed_burst;
uint32_t peak_burst;
boolean_t stats;
boolean_t colour_aware;
enum meter_colour dscp_to_colour[64];
timeout_id_t timer;
}tokenmt_cfg_t;
typedef struct tokenmt_data_s {
ipp_stat_t *stats;
uint64_t red_packets;
uint64_t yellow_packets;
uint64_t green_packets;
uint64_t red_bits;
uint64_t yellow_bits;
uint64_t green_bits;
uint64_t epackets;
tokenmt_cfg_t *cfg_parms;
uint64_t committed_tokens;
uint64_t peak_tokens;
uint64_t last_seen;
kmutex_t tokenmt_lock;
} tokenmt_data_t;
typedef struct tswtcl_cfg_s {
ipp_action_id_t red_action;
ipp_action_id_t yellow_action;
ipp_action_id_t green_action;
uint32_t committed_rate;
uint32_t peak_rate;
uint32_t window;
boolean_t stats;
uint64_t nsecwindow;
uint32_t pminusc;
}tswtcl_cfg_t;
typedef struct tswtcl_data_s {
ipp_stat_t *stats;
uint32_t avg_rate;
hrtime_t win_front;
uint64_t red_packets;
uint64_t yellow_packets;
uint64_t green_packets;
uint64_t red_bits;
uint64_t yellow_bits;
uint64_t green_bits;
uint64_t epackets;
tswtcl_cfg_t *cfg_parms;
kmutex_t tswtcl_lock;
} tswtcl_data_t;
#define TOKENMT_DATA_SZ sizeof (tokenmt_data_t)
#define TOKENMT_CFG_SZ sizeof (tokenmt_cfg_t)
#define TSWTCL_DATA_SZ sizeof (tswtcl_data_t)
#define TSWTCL_CFG_SZ sizeof (tswtcl_cfg_t)
extern int tokenmt_process(mblk_t **, tokenmt_data_t *, ipp_action_id_t *);
extern int tswtcl_process(mblk_t **, tswtcl_data_t *, ipp_action_id_t *);
#endif
#ifdef __cplusplus
}
#endif
#endif