[ovs-dev] [PATCH v4.3 1/5] ofp-actions: Complete ofp13_action_type and add function to use instructions.
Alexander Wu
alexander.wu at huawei.com
Mon Dec 9 10:41:09 UTC 2013
v4:
Add enums of ofp13_action_type and make them work.
v3:
Add func to get instruction/action name by OpenFlow instruction type directly.
---
include/openflow/openflow-1.3.h | 20 ++++++++++++++++++--
lib/ofp-actions.c | 19 +++++++++++++++++++
lib/ofp-actions.h | 3 +++
lib/ofp-parse.c | 19 +++++++++++++++++++
4 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/include/openflow/openflow-1.3.h b/include/openflow/openflow-1.3.h
index 767e048..4696f01 100644
--- a/include/openflow/openflow-1.3.h
+++ b/include/openflow/openflow-1.3.h
@@ -104,8 +104,24 @@ struct ofp13_instruction_meter {
OFP_ASSERT(sizeof(struct ofp13_instruction_meter) == 8);
enum ofp13_action_type {
- OFPAT13_PUSH_PBB = 26, /* Push a new PBB service tag (I-TAG) */
- OFPAT13_POP_PBB = 27 /* Pop the outer PBB service tag (I-TAG) */
+ OFPAT13_OUTPUT = 0, /* Output to switch port. */
+ OFPAT13_COPY_TTL_OUT = 11, /* Copy TTL "outwards" -- from next-to-outermost
+ to outermost */
+ OFPAT13_COPY_TTL_IN = 12, /* Copy TTL "inwards" -- from outermost to
+ next-to-outermost */
+ OFPAT13_SET_MPLS_TTL = 15, /* MPLS TTL */
+ OFPAT13_DEC_MPLS_TTL = 16, /* Decrement MPLS TTL */
+ OFPAT13_PUSH_VLAN = 17, /* Push a new VLAN tag */
+ OFPAT13_POP_VLAN = 18, /* Pop the outer VLAN tag */
+ OFPAT13_PUSH_MPLS = 19, /* Push a new MPLS Label Stack Entry */
+ OFPAT13_POP_MPLS = 20, /* Pop the outer MPLS Label Stack Entry */
+ OFPAT13_SET_QUEUE = 21, /* Set queue id when outputting to a port */
+ OFPAT13_GROUP = 22, /* Apply group. */
+ OFPAT13_SET_NW_TTL = 23, /* IP TTL. */
+ OFPAT13_DEC_NW_TTL = 24, /* Decrement IP TTL. */
+ OFPAT13_SET_FIELD = 25, /* Set a header field using OXM TLV format. */
+ OFPAT13_PUSH_PBB = 26, /* Push a new PBB service tag (I-TAG) */
+ OFPAT13_POP_PBB = 27 /* Pop the outer PBB service tag (I-TAG) */
};
/* enum ofp_config_flags value OFPC_INVALID_TTL_TO_CONTROLLER
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index a02f842..c8a9642 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -379,6 +379,7 @@ ofpact_from_nxast(const union ofp_action *a, enum ofputil_action_code code,
case OFPUTIL_ACTION_INVALID:
#define OFPAT10_ACTION(ENUM, STRUCT, NAME) case OFPUTIL_##ENUM:
#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) case OFPUTIL_##ENUM:
+#define OFPAT13_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) case OFPUTIL_##ENUM:
#include "ofp-util.def"
NOT_REACHED();
@@ -526,6 +527,7 @@ ofpact_from_openflow10(const union ofp_action *a,
switch (code) {
case OFPUTIL_ACTION_INVALID:
#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) case OFPUTIL_##ENUM:
+#define OFPAT13_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) case OFPUTIL_##ENUM:
#include "ofp-util.def"
NOT_REACHED();
@@ -1144,6 +1146,7 @@ ofpact_from_openflow11(const union ofp_action *a, enum ofp_version version,
switch (code) {
case OFPUTIL_ACTION_INVALID:
#define OFPAT10_ACTION(ENUM, STRUCT, NAME) case OFPUTIL_##ENUM:
+#define OFPAT13_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) case OFPUTIL_##ENUM:
#include "ofp-util.def"
NOT_REACHED();
@@ -1637,6 +1640,22 @@ ovs_instruction_type_from_ofpact_type(enum ofpact_type type)
}
}
+enum ovs_instruction_type
+ovs_instruction_type_from_inst_type(const uint16_t inst_type)
+{
+ switch (inst_type) {
+
+#define DEFINE_INST(ENUM, STRUCT, EXTENSIBLE, NAME) \
+ case ENUM: \
+ return OVSINST_##ENUM;
+OVS_INSTRUCTIONS
+#undef DEFINE_INST
+
+ default:
+ return OFPERR_OFPTFFC_BAD_ARGUMENT;
+ }
+}
+
static inline struct ofp11_instruction *
instruction_next(const struct ofp11_instruction *inst)
{
diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h
index 470a371..85b3d68 100644
--- a/lib/ofp-actions.h
+++ b/lib/ofp-actions.h
@@ -764,4 +764,7 @@ const char *ovs_instruction_name_from_type(enum ovs_instruction_type type);
int ovs_instruction_type_from_name(const char *name);
enum ovs_instruction_type ovs_instruction_type_from_ofpact_type(
enum ofpact_type);
+enum ovs_instruction_type ovs_instruction_type_from_inst_type(
+ const uint16_t oinst_type);
+
#endif /* ofp-actions.h */
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index 5b07d14..aa32052 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -648,6 +648,7 @@ parse_named_action(enum ofputil_action_code code,
case OFPUTIL_OFPAT10_OUTPUT:
case OFPUTIL_OFPAT11_OUTPUT:
+ case OFPUTIL_OFPAT13_OUTPUT:
error = parse_output(arg, ofpacts);
break;
@@ -684,14 +685,17 @@ parse_named_action(enum ofputil_action_code code,
break;
case OFPUTIL_OFPAT12_SET_FIELD:
+ case OFPUTIL_OFPAT13_SET_FIELD:
return set_field_parse(arg, ofpacts, usable_protocols);
case OFPUTIL_OFPAT10_STRIP_VLAN:
case OFPUTIL_OFPAT11_POP_VLAN:
+ case OFPUTIL_OFPAT13_POP_VLAN:
ofpact_put_STRIP_VLAN(ofpacts)->ofpact.compat = code;
break;
case OFPUTIL_OFPAT11_PUSH_VLAN:
+ case OFPUTIL_OFPAT13_PUSH_VLAN:
*usable_protocols &= OFPUTIL_P_OF11_UP;
error = str_to_u16(arg, "ethertype", ðertype);
if (error) {
@@ -707,6 +711,7 @@ parse_named_action(enum ofputil_action_code code,
break;
case OFPUTIL_OFPAT11_SET_QUEUE:
+ case OFPUTIL_OFPAT13_SET_QUEUE:
error = str_to_u32(arg, &ofpact_put_SET_QUEUE(ofpacts)->queue_id);
break;
@@ -756,6 +761,7 @@ parse_named_action(enum ofputil_action_code code,
break;
case OFPUTIL_OFPAT11_SET_NW_TTL:
+ case OFPUTIL_OFPAT13_SET_NW_TTL:
error = str_to_u8(arg, "TTL", &ttl);
if (error) {
return error;
@@ -765,6 +771,7 @@ parse_named_action(enum ofputil_action_code code,
break;
case OFPUTIL_OFPAT11_DEC_NW_TTL:
+ case OFPUTIL_OFPAT13_DEC_NW_TTL:
NOT_REACHED();
case OFPUTIL_OFPAT10_SET_TP_SRC:
@@ -859,10 +866,12 @@ parse_named_action(enum ofputil_action_code code,
case OFPUTIL_NXAST_SET_MPLS_TTL:
case OFPUTIL_OFPAT11_SET_MPLS_TTL:
+ case OFPUTIL_OFPAT13_SET_MPLS_TTL:
error = parse_set_mpls_ttl(ofpacts, arg);
break;
case OFPUTIL_OFPAT11_DEC_MPLS_TTL:
+ case OFPUTIL_OFPAT13_DEC_MPLS_TTL:
case OFPUTIL_NXAST_DEC_MPLS_TTL:
ofpact_put_DEC_MPLS_TTL(ofpacts);
break;
@@ -876,6 +885,7 @@ parse_named_action(enum ofputil_action_code code,
break;
case OFPUTIL_OFPAT11_PUSH_MPLS:
+ case OFPUTIL_OFPAT13_PUSH_MPLS:
case OFPUTIL_NXAST_PUSH_MPLS:
error = str_to_u16(arg, "push_mpls", ðertype);
if (!error) {
@@ -884,6 +894,7 @@ parse_named_action(enum ofputil_action_code code,
break;
case OFPUTIL_OFPAT11_POP_MPLS:
+ case OFPUTIL_OFPAT13_POP_MPLS:
case OFPUTIL_NXAST_POP_MPLS:
error = str_to_u16(arg, "pop_mpls", ðertype);
if (!error) {
@@ -892,9 +903,17 @@ parse_named_action(enum ofputil_action_code code,
break;
case OFPUTIL_OFPAT11_GROUP:
+ case OFPUTIL_OFPAT13_GROUP:
error = str_to_u32(arg, &ofpact_put_GROUP(ofpacts)->group_id);
break;
+ /* FIXME when implement OFPAT13_* */
+ case OFPUTIL_OFPAT13_COPY_TTL_OUT:
+ case OFPUTIL_OFPAT13_COPY_TTL_IN:
+ case OFPUTIL_OFPAT13_PUSH_PBB:
+ case OFPUTIL_OFPAT13_POP_PBB:
+ NOT_REACHED();
+
case OFPUTIL_NXAST_STACK_PUSH:
error = nxm_parse_stack_action(ofpact_put_STACK_PUSH(ofpacts), arg);
break;
--
1.7.3.1.msysgit.0
More information about the dev
mailing list