Use the common IP definitions of DSCP rather than duplicating in the
policer code.
Type: improvement
Signed-off-by: Brian Russell <brian@graphiant.com>
Change-Id: Iff4bc789356edc290b9c31eca33e93cf5b6211bf
u8 *r = va_arg (*va, u8 *);
if (0);
u8 *r = va_arg (*va, u8 *);
if (0);
-#define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
- foreach_vnet_dscp
+#define _(v, f) else if (unformat (input, #f)) *r = IP_DSCP_##f;
+ foreach_ip_dscp
-#define _(v,f,str) case VNET_DSCP_##f: t = str; break;
- foreach_vnet_dscp
+#define _(v, f) \
+ case IP_DSCP_##f: \
+ return (format (s, "%s", #f));
+ foreach_ip_dscp
- default:
- return format (s, "ILLEGAL");
}
s = format (s, "%s", t);
}
s = format (s, "%s", t);
+ return (format (s, "ILLEGAL"));
u32 color_aware; // for hierarchical policing
u32 scale; // power-of-2 shift amount for lower rates
u8 action[3];
u32 color_aware; // for hierarchical policing
u32 scale; // power-of-2 shift amount for lower rates
u8 action[3];
+ ip_dscp_t mark_dscp[3];
u8 pad[2];
// Fields are marked as 2R if they are only used for a 2-rate policer,
u8 pad[2];
// Fields are marked as 2R if they are only used for a 2-rate policer,
#define IP6_DSCP_SHIFT 22
static_always_inline void
#define IP6_DSCP_SHIFT 22
static_always_inline void
-vnet_policer_mark (vlib_buffer_t * b, u8 dscp)
+vnet_policer_mark (vlib_buffer_t *b, ip_dscp_t dscp)
{
ethernet_header_t *eh;
ip4_header_t *ip4h;
{
ethernet_header_t *eh;
ip4_header_t *ip4h;
#include <vnet/policer/policer.h>
#include <vnet/policer/police_inlines.h>
#include <vnet/classify/vnet_classify.h>
#include <vnet/policer/policer.h>
#include <vnet/policer/police_inlines.h>
#include <vnet/classify/vnet_classify.h>
+#include <vnet/ip/ip_packet.h>
vnet_policer_main_t vnet_policer_main;
vnet_policer_main_t vnet_policer_main;
-static u8 *
-format_dscp (u8 * s, va_list * va)
-{
- u32 i = va_arg (*va, u32);
- char *t = 0;
-
- switch (i)
- {
-#define _(v,f,str) case VNET_DSCP_##f: t = str; break;
- foreach_vnet_dscp
-#undef _
- default:
- return format (s, "ILLEGAL");
- }
- s = format (s, "%s", t);
- return s;
-}
-
static u8 *
format_policer_action_type (u8 * s, va_list * va)
{
static u8 *
format_policer_action_type (u8 * s, va_list * va)
{
else if (a->action_type == SSE2_QOS_ACTION_TRANSMIT)
s = format (s, "transmit");
else if (a->action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
else if (a->action_type == SSE2_QOS_ACTION_TRANSMIT)
s = format (s, "transmit");
else if (a->action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
- s = format (s, "mark-and-transmit %U", format_dscp, a->dscp);
+ s = format (s, "mark-and-transmit %U", format_ip_dscp, a->dscp);
else
s = format (s, "ILLEGAL");
return s;
else
s = format (s, "ILLEGAL");
return s;
-static uword
-unformat_dscp (unformat_input_t * input, va_list * va)
-{
- u8 *r = va_arg (*va, u8 *);
-
- if (0);
-#define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
- foreach_vnet_dscp
-#undef _
- else
- return 0;
- return 1;
-}
-
static uword
unformat_policer_action_type (unformat_input_t * input, va_list * va)
{
static uword
unformat_policer_action_type (unformat_input_t * input, va_list * va)
{
a->action_type = SSE2_QOS_ACTION_DROP;
else if (unformat (input, "transmit"))
a->action_type = SSE2_QOS_ACTION_TRANSMIT;
a->action_type = SSE2_QOS_ACTION_DROP;
else if (unformat (input, "transmit"))
a->action_type = SSE2_QOS_ACTION_TRANSMIT;
- else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
+ else if (unformat (input, "mark-and-transmit %U", unformat_ip_dscp,
+ &a->dscp))
a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
else
return 0;
a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
else
return 0;
VNET_POLICER_N_NEXT,
} vnet_policer_next_t;
VNET_POLICER_N_NEXT,
} vnet_policer_next_t;
-#define foreach_vnet_dscp \
- _(0 , CS0, "CS0") \
- _(8 , CS1, "CS1") \
- _(10, AF11, "AF11") \
- _(12, AF12, "AF12") \
- _(14, AF13, "AF13") \
- _(16, CS2, "CS2") \
- _(18, AF21, "AF21") \
- _(20, AF22, "AF22") \
- _(22, AF23, "AF23") \
- _(24, CS3, "CS3") \
- _(26, AF31, "AF31") \
- _(28, AF32, "AF32") \
- _(30, AF33, "AF33") \
- _(32, CS4, "CS4") \
- _(34, AF41, "AF41") \
- _(36, AF42, "AF42") \
- _(38, AF43, "AF43") \
- _(40, CS5, "CS5") \
- _(46, EF, "EF") \
- _(48, CS6, "CS6") \
- _(50, CS7, "CS7")
-
-typedef enum
-{
-#define _(v,f,str) VNET_DSCP_##f = v,
- foreach_vnet_dscp
-#undef _
-} vnet_dscp_t;
-
u8 *format_policer_instance (u8 * s, va_list * va);
clib_error_t *policer_add_del (vlib_main_t * vm,
u8 * name,
u8 *format_policer_instance (u8 * s, va_list * va);
clib_error_t *policer_add_del (vlib_main_t * vm,
u8 * name,
#ifndef __included_xlate_h__
#define __included_xlate_h__
#ifndef __included_xlate_h__
#define __included_xlate_h__
+#include <vnet/ip/ip_packet.h>
#include <vnet/policer/police.h>
/*
#include <vnet/policer/police.h>
/*
typedef struct sse2_qos_pol_action_params_st_
{
u8 action_type;
typedef struct sse2_qos_pol_action_params_st_
{
u8 action_type;
} sse2_qos_pol_action_params_st;
/*
} sse2_qos_pol_action_params_st;
/*
{
u32 action = va_arg (*va, u32);
u32 dscp = va_arg (*va, u32);
{
u32 action = va_arg (*va, u32);
u32 dscp = va_arg (*va, u32);
if (action == SSE2_QOS_ACTION_DROP)
s = format (s, "drop");
if (action == SSE2_QOS_ACTION_DROP)
s = format (s, "drop");
s = format (s, "mark-and-transmit ");
switch (dscp)
{
s = format (s, "mark-and-transmit ");
switch (dscp)
{
-#define _(v,f,str) case VNET_DSCP_##f: t = str; break;
- foreach_vnet_dscp
+#define _(v, f) \
+ case IP_DSCP_##f: \
+ format (s, "%s", #f);
+ foreach_ip_dscp
- s = format (s, "%s", t);