524
533
OFPUTIL_C_PORT_BLOCKED = 1 << 8, /* Switch will block looping ports */
527
enum ofputil_action_bitmap {
528
OFPUTIL_A_OUTPUT = 1 << 0,
529
OFPUTIL_A_SET_VLAN_VID = 1 << 1,
530
OFPUTIL_A_SET_VLAN_PCP = 1 << 2,
531
OFPUTIL_A_STRIP_VLAN = 1 << 3,
532
OFPUTIL_A_SET_DL_SRC = 1 << 4,
533
OFPUTIL_A_SET_DL_DST = 1 << 5,
534
OFPUTIL_A_SET_NW_SRC = 1 << 6,
535
OFPUTIL_A_SET_NW_DST = 1 << 7,
536
OFPUTIL_A_SET_NW_ECN = 1 << 8,
537
OFPUTIL_A_SET_NW_TOS = 1 << 9,
538
OFPUTIL_A_SET_TP_SRC = 1 << 10,
539
OFPUTIL_A_SET_TP_DST = 1 << 11,
540
OFPUTIL_A_ENQUEUE = 1 << 12,
541
OFPUTIL_A_COPY_TTL_OUT = 1 << 13,
542
OFPUTIL_A_COPY_TTL_IN = 1 << 14,
543
OFPUTIL_A_SET_MPLS_LABEL = 1 << 15,
544
OFPUTIL_A_SET_MPLS_TC = 1 << 16,
545
OFPUTIL_A_SET_MPLS_TTL = 1 << 17,
546
OFPUTIL_A_DEC_MPLS_TTL = 1 << 18,
547
OFPUTIL_A_PUSH_VLAN = 1 << 19,
548
OFPUTIL_A_POP_VLAN = 1 << 20,
549
OFPUTIL_A_PUSH_MPLS = 1 << 21,
550
OFPUTIL_A_POP_MPLS = 1 << 22,
551
OFPUTIL_A_SET_QUEUE = 1 << 23,
552
OFPUTIL_A_GROUP = 1 << 24,
553
OFPUTIL_A_SET_NW_TTL = 1 << 25,
554
OFPUTIL_A_DEC_NW_TTL = 1 << 26,
555
OFPUTIL_A_SET_FIELD = 1 << 27,
558
536
/* Abstract ofp_switch_features. */
559
537
struct ofputil_switch_features {
560
538
uint64_t datapath_id; /* Datapath unique ID. */
605
583
struct ofpbuf *ofputil_encode_port_mod(const struct ofputil_port_mod *,
606
584
enum ofputil_protocol);
586
/* Abstract version of OFPTC11_TABLE_MISS_*.
588
* OpenFlow 1.0 always sends packets that miss to the next flow table, or to
589
* the controller if they miss in the last flow table.
591
* OpenFlow 1.1 and 1.2 can configure table miss behavior via a "table-mod"
592
* that specifies "send to controller", "miss", or "drop".
594
* OpenFlow 1.3 and later never sends packets that miss to the controller.
596
enum ofputil_table_miss {
597
/* Protocol-specific default behavior. On OpenFlow 1.0 through 1.2
598
* connections, the packet is sent to the controller, and on OpenFlow 1.3
599
* and later connections, the packet is dropped.
601
* This is also used as a result of decoding OpenFlow 1.3+ "config" values
602
* in table-mods, to indicate that no table-miss was specified. */
603
OFPUTIL_TABLE_MISS_DEFAULT, /* Protocol default behavior. */
605
/* These constants have the same meanings as those in OpenFlow with the
607
OFPUTIL_TABLE_MISS_CONTROLLER, /* Send to controller. */
608
OFPUTIL_TABLE_MISS_CONTINUE, /* Go to next table. */
609
OFPUTIL_TABLE_MISS_DROP, /* Drop the packet. */
612
ovs_be32 ofputil_table_miss_to_config(enum ofputil_table_miss,
608
615
/* Abstract ofp_table_mod. */
609
616
struct ofputil_table_mod {
610
617
uint8_t table_id; /* ID of the table, 0xff indicates all tables. */
611
enum ofp_table_config config;
618
enum ofputil_table_miss miss_config;
614
621
enum ofperr ofputil_decode_table_mod(const struct ofp_header *,
671
678
* Other combinations do not make sense.
673
uint64_t match; /* Fields that may be matched. */
674
uint64_t mask; /* Subset of 'match' that may have masks. */
675
uint64_t wildcard; /* Subset of 'match' that may be wildcarded. */
680
struct mf_bitmap match; /* Fields that may be matched. */
681
struct mf_bitmap mask; /* Subset of 'match' that may have masks. */
682
struct mf_bitmap wildcard; /* Subset of 'match' that may be wildcarded. */
678
685
int ofputil_decode_table_features(struct ofpbuf *,
679
686
struct ofputil_table_features *, bool loose);
680
struct ofpbuf *ofputil_encode_table_features_request(
681
enum ofp_version ofp_version);
687
struct ofpbuf *ofputil_encode_table_features_request(enum ofp_version);
682
689
void ofputil_append_table_features_reply(
683
const struct ofputil_table_features *tf,
684
struct list *replies);
686
uint16_t table_feature_prop_get_size(enum ofp13_table_feature_prop_type type);
687
char *table_feature_prop_get_name(enum ofp13_table_feature_prop_type type);
690
const struct ofputil_table_features *tf, struct ovs_list *replies);
689
692
/* Meter band configuration for all supported band types. */
690
693
struct ofputil_meter_band {
798
801
enum ofperr ofputil_decode_role_status(const struct ofp_header *oh,
799
802
struct ofputil_role_status *rs);
800
804
/* Abstract table stats.
802
* For now we use ofp12_table_stats as a superset of the other protocol
803
* versions' table stats. */
805
struct ofpbuf *ofputil_encode_table_stats_reply(
806
const struct ofp12_table_stats[], int n,
807
const struct ofp_header *request);
806
* This corresponds to the OpenFlow 1.3 table statistics structure, which only
807
* includes actual statistics. In earlier versions of OpenFlow, several
808
* members describe table features, so this structure has to be paired with
809
* struct ofputil_table_features to get all information. */
810
struct ofputil_table_stats {
811
uint8_t table_id; /* Identifier of table. */
812
uint32_t active_count; /* Number of active entries. */
813
uint64_t lookup_count; /* Number of packets looked up in table. */
814
uint64_t matched_count; /* Number of packets that hit table. */
817
struct ofpbuf *ofputil_encode_table_stats_reply(const struct ofp_header *rq);
818
void ofputil_append_table_stats_reply(struct ofpbuf *reply,
819
const struct ofputil_table_stats *,
820
const struct ofputil_table_features *);
822
int ofputil_decode_table_stats_reply(struct ofpbuf *reply,
823
struct ofputil_table_stats *,
824
struct ofputil_table_features *);
809
826
/* Queue configuration request. */
810
827
struct ofpbuf *ofputil_encode_queue_get_config_request(enum ofp_version,
901
/* The type of an action.
903
* For each implemented OFPAT10_* and NXAST_* action type, there is a
904
* corresponding constant prefixed with OFPUTIL_, e.g.:
906
* OFPUTIL_OFPAT10_OUTPUT
907
* OFPUTIL_OFPAT10_SET_VLAN_VID
908
* OFPUTIL_OFPAT10_SET_VLAN_PCP
909
* OFPUTIL_OFPAT10_STRIP_VLAN
910
* OFPUTIL_OFPAT10_SET_DL_SRC
911
* OFPUTIL_OFPAT10_SET_DL_DST
912
* OFPUTIL_OFPAT10_SET_NW_SRC
913
* OFPUTIL_OFPAT10_SET_NW_DST
914
* OFPUTIL_OFPAT10_SET_NW_TOS
915
* OFPUTIL_OFPAT10_SET_TP_SRC
916
* OFPUTIL_OFPAT10_SET_TP_DST
917
* OFPUTIL_OFPAT10_ENQUEUE
918
* OFPUTIL_NXAST_RESUBMIT
919
* OFPUTIL_NXAST_SET_TUNNEL
920
* OFPUTIL_NXAST_SET_METADATA
921
* OFPUTIL_NXAST_SET_QUEUE
922
* OFPUTIL_NXAST_POP_QUEUE
923
* OFPUTIL_NXAST_REG_MOVE
924
* OFPUTIL_NXAST_REG_LOAD
926
* OFPUTIL_NXAST_SET_TUNNEL64
927
* OFPUTIL_NXAST_MULTIPATH
928
* OFPUTIL_NXAST_BUNDLE
929
* OFPUTIL_NXAST_BUNDLE_LOAD
930
* OFPUTIL_NXAST_RESUBMIT_TABLE
931
* OFPUTIL_NXAST_OUTPUT_REG
932
* OFPUTIL_NXAST_LEARN
933
* OFPUTIL_NXAST_DEC_TTL
934
* OFPUTIL_NXAST_FIN_TIMEOUT
936
* (The above list helps developers who want to "grep" for these definitions.)
938
enum OVS_PACKED_ENUM ofputil_action_code {
939
OFPUTIL_ACTION_INVALID,
940
#define OFPAT10_ACTION(ENUM, STRUCT, NAME) OFPUTIL_##ENUM,
941
#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) OFPUTIL_##ENUM,
942
#define OFPAT13_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) OFPUTIL_##ENUM,
943
#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) OFPUTIL_##ENUM,
944
#include "ofp-util.def"
947
/* The number of values of "enum ofputil_action_code". */
949
#define OFPAT10_ACTION(ENUM, STRUCT, NAME) + 1
950
#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
951
#define OFPAT13_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
952
#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
953
OFPUTIL_N_ACTIONS = 1
954
#include "ofp-util.def"
957
int ofputil_action_code_from_name(const char *);
958
const char * ofputil_action_name_from_code(enum ofputil_action_code code);
959
enum ofputil_action_code ofputil_action_code_from_ofp13_action(
960
enum ofp13_action_type type);
962
void *ofputil_put_action(enum ofputil_action_code, struct ofpbuf *buf);
964
/* For each OpenFlow action <ENUM> that has a corresponding action structure
965
* struct <STRUCT>, this defines two functions:
967
* void ofputil_init_<ENUM>(struct <STRUCT> *action);
969
* Initializes the parts of 'action' that identify it as having type <ENUM>
970
* and length 'sizeof *action' and zeros the rest. For actions that have
971
* variable length, the length used and cleared is that of struct <STRUCT>.
973
* struct <STRUCT> *ofputil_put_<ENUM>(struct ofpbuf *buf);
975
* Appends a new 'action', of length 'sizeof(struct <STRUCT>)', to 'buf',
976
* initializes it with ofputil_init_<ENUM>(), and returns it.
978
#define OFPAT10_ACTION(ENUM, STRUCT, NAME) \
979
void ofputil_init_##ENUM(struct STRUCT *); \
980
struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
981
#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \
982
void ofputil_init_##ENUM(struct STRUCT *); \
983
struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
984
#define OFPAT13_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \
985
void ofputil_init_##ENUM(struct STRUCT *); \
986
struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
987
#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) \
988
void ofputil_init_##ENUM(struct STRUCT *); \
989
struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
990
#include "ofp-util.def"
992
#define OFP_ACTION_ALIGN 8 /* Alignment of ofp_actions. */
994
918
bool action_outputs_to_port(const union ofp_action *, ovs_be16 port);
996
920
enum ofperr ofputil_pull_actions(struct ofpbuf *, unsigned int actions_len,
1048
972
size_t ofputil_count_queue_stats(const struct ofp_header *);
1049
973
int ofputil_decode_queue_stats(struct ofputil_queue_stats *qs, struct ofpbuf *msg);
1050
void ofputil_append_queue_stat(struct list *replies,
974
void ofputil_append_queue_stat(struct ovs_list *replies,
1051
975
const struct ofputil_queue_stats *oqs);
977
struct bucket_counter {
978
uint64_t packet_count; /* Number of packets processed by bucket. */
979
uint64_t byte_count; /* Number of bytes processed by bucket. */
1053
982
/* Bucket for use in groups. */
1054
983
struct ofputil_bucket {
1055
struct list list_node;
984
struct ovs_list list_node;
1056
985
uint16_t weight; /* Relative weight, for "select" groups. */
1057
986
ofp_port_t watch_port; /* Port whose state affects whether this bucket
1058
987
* is live. Only required for fast failover
1060
989
uint32_t watch_group; /* Group whose state affects whether this
1061
990
* bucket is live. Only required for fast
1062
991
* failover groups. */
992
uint32_t bucket_id; /* Bucket Id used to identify bucket*/
1063
993
struct ofpact *ofpacts; /* Series of "struct ofpact"s. */
1064
994
size_t ofpacts_len; /* Length of ofpacts, in bytes. */
996
struct bucket_counter stats;
999
/* Protocol-independent group_mod. */
1000
struct ofputil_group_props {
1001
/* NTR selection method */
1002
char selection_method[NTR_MAX_SELECTION_METHOD_LEN];
1003
uint64_t selection_method_param;
1004
struct field_array fields;
1067
1007
/* Protocol-independent group_mod. */
1068
1008
struct ofputil_group_mod {
1069
uint16_t command; /* One of OFPGC11_*. */
1009
uint16_t command; /* One of OFPGC15_*. */
1070
1010
uint8_t type; /* One of OFPGT11_*. */
1071
1011
uint32_t group_id; /* Group identifier. */
1072
struct list buckets; /* Contains "struct ofputil_bucket"s. */
1075
struct bucket_counter {
1076
uint64_t packet_count; /* Number of packets processed by bucket. */
1077
uint64_t byte_count; /* Number of bytes processed by bucket. */
1012
uint32_t command_bucket_id; /* Bucket Id used as part of
1013
* OFPGC15_INSERT_BUCKET and
1014
* OFPGC15_REMOVE_BUCKET commands
1016
struct ovs_list buckets; /* Contains "struct ofputil_bucket"s. */
1017
struct ofputil_group_props props; /* Group properties. */
1080
1020
/* Group stats reply, independent of protocol. */
1096
1036
uint32_t types; /* Bitmap of OFPGT_* values supported. */
1097
1037
uint32_t capabilities; /* Bitmap of OFPGFC12_* capability supported. */
1098
1038
uint32_t max_groups[4]; /* Maximum number of groups for each type. */
1100
/* Bitmaps of OFPAT_* that are supported. OF1.2+ actions only. */
1101
uint32_t actions[4];
1039
uint64_t ofpacts[4]; /* Bitmaps of supported OFPACT_* */
1104
1042
/* Group desc reply, independent of protocol. */
1105
1043
struct ofputil_group_desc {
1106
1044
uint8_t type; /* One of OFPGT_*. */
1107
1045
uint32_t group_id; /* Group identifier. */
1108
struct list buckets; /* Contains "struct ofputil_bucket"s. */
1046
struct ovs_list buckets; /* Contains "struct ofputil_bucket"s. */
1047
struct ofputil_group_props props; /* Group properties. */
1111
void ofputil_bucket_list_destroy(struct list *buckets);
1050
void ofputil_bucket_list_destroy(struct ovs_list *buckets);
1051
void ofputil_bucket_clone_list(struct ovs_list *dest,
1052
const struct ovs_list *src,
1053
const struct ofputil_bucket *);
1054
struct ofputil_bucket *ofputil_bucket_find(const struct ovs_list *,
1055
uint32_t bucket_id);
1056
bool ofputil_bucket_check_duplicate_id(const struct ovs_list *);
1057
struct ofputil_bucket *ofputil_bucket_list_front(const struct ovs_list *);
1058
struct ofputil_bucket *ofputil_bucket_list_back(const struct ovs_list *);
1113
1060
static inline bool
1114
1061
ofputil_bucket_has_liveness(const struct ofputil_bucket *bucket)
1121
1068
uint32_t group_id);
1122
1069
enum ofperr ofputil_decode_group_stats_request(
1123
1070
const struct ofp_header *request, uint32_t *group_id);
1124
void ofputil_append_group_stats(struct list *replies,
1071
void ofputil_append_group_stats(struct ovs_list *replies,
1125
1072
const struct ofputil_group_stats *);
1126
1073
struct ofpbuf *ofputil_encode_group_features_request(enum ofp_version);
1127
1074
struct ofpbuf *ofputil_encode_group_features_reply(
1128
1075
const struct ofputil_group_features *, const struct ofp_header *request);
1129
1076
void ofputil_decode_group_features_reply(const struct ofp_header *,
1130
1077
struct ofputil_group_features *);
1078
void ofputil_uninit_group_mod(struct ofputil_group_mod *gm);
1131
1079
struct ofpbuf *ofputil_encode_group_mod(enum ofp_version ofp_version,
1132
1080
const struct ofputil_group_mod *gm);