~ubuntu-branches/ubuntu/wily/openvswitch/wily

« back to all changes in this revision

Viewing changes to lib/ofp-util.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-08-10 11:35:15 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20150810113515-575vj06oq29emxsn
Tags: 2.4.0~git20150810.97bab95-0ubuntu1
* New upstream snapshot from 2.4 branch:
  - d/*: Align any relevant packaging changes with upstream.
* d/*: wrap-and-sort.
* d/openvswitch-{common,vswitch}.install: Correct install location for
  bash completion files.
* d/tests/openflow.py: Explicitly use ovs-testcontroller as provided
  by 2.4.0 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
 
2
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
3
3
 *
4
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
5
 * you may not use this file except in compliance with the License.
25
25
#include "flow.h"
26
26
#include "list.h"
27
27
#include "match.h"
 
28
#include "meta-flow.h"
28
29
#include "netdev.h"
 
30
#include "openflow/netronome-ext.h"
29
31
#include "openflow/nicira-ext.h"
30
32
#include "openvswitch/types.h"
31
33
#include "type-props.h"
163
165
/* A bitmap of version numbers
164
166
 *
165
167
 * Bit offsets correspond to ofp_version numbers which in turn correspond to
166
 
 * wire-protocol numbers for Open Flow versions..  E.g. (1u << OFP11_VERSION)
167
 
 * is the mask for Open Flow 1.1.  If the bit for a version is set then it is
 
168
 * wire-protocol numbers for OpenFlow versions, e.g. (1u << OFP11_VERSION)
 
169
 * is the mask for OpenFlow 1.1.  If the bit for a version is set then it is
168
170
 * allowed, otherwise it is disallowed. */
169
171
 
170
172
void ofputil_format_version_bitmap(struct ds *msg, uint32_t bitmap);
216
218
/* Work with ofp11_match. */
217
219
enum ofperr ofputil_pull_ofp11_match(struct ofpbuf *, struct match *,
218
220
                                     uint16_t *padded_match_len);
 
221
enum ofperr ofputil_pull_ofp11_mask(struct ofpbuf *, struct match *,
 
222
                                    struct mf_bitmap *bm);
219
223
enum ofperr ofputil_match_from_ofp11_match(const struct ofp11_match *,
220
224
                                           struct match *);
221
225
int ofputil_put_ofp11_match(struct ofpbuf *, const struct match *,
267
271
 * The handling of cookies across multiple versions of OpenFlow is a bit
268
272
 * confusing.  See DESIGN for the details. */
269
273
struct ofputil_flow_mod {
270
 
    struct list list_node;    /* For queuing flow_mods. */
 
274
    struct ovs_list list_node; /* For queuing flow_mods. */
271
275
 
272
276
    struct match match;
273
 
    unsigned int priority;
 
277
    int priority;
274
278
 
275
279
    /* Cookie matching.  The flow_mod affects only flows that have cookies that
276
280
     * bitwise match 'cookie' bits in positions where 'cookie_mask has 1-bits.
305
309
    ofp_port_t out_port;
306
310
    uint32_t out_group;
307
311
    enum ofputil_flow_mod_flags flags;
 
312
    uint16_t importance;     /* Eviction precedence. */
308
313
    struct ofpact *ofpacts;  /* Series of "struct ofpact"s. */
309
314
    size_t ofpacts_len;      /* Length of ofpacts, in bytes. */
 
315
 
 
316
    /* Reason for delete; ignored for non-delete commands */
 
317
    enum ofp_flow_removed_reason delete_reason;
310
318
};
311
319
 
312
320
enum ofperr ofputil_decode_flow_mod(struct ofputil_flow_mod *,
351
359
    const struct ofpact *ofpacts;
352
360
    size_t ofpacts_len;
353
361
    enum ofputil_flow_mod_flags flags;
 
362
    uint16_t importance;        /* Eviction precedence. */
354
363
};
355
364
 
356
365
int ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *,
358
367
                                    bool flow_age_extension,
359
368
                                    struct ofpbuf *ofpacts);
360
369
void ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *,
361
 
                                     struct list *replies);
 
370
                                     struct ovs_list *replies);
362
371
 
363
372
/* Aggregate stats reply, independent of protocol. */
364
373
struct ofputil_aggregate_stats {
404
413
    const void *packet;
405
414
    size_t packet_len;          /* Number of bytes in 'packet'. */
406
415
    size_t total_len;           /* Size of packet, pre-truncation. */
407
 
    struct flow_metadata fmd;
 
416
    struct match flow_metadata;
408
417
 
409
418
    /* Identifies a buffer in the switch that contains the full packet, to
410
419
     * allow the controller to reference it later without having to send the
524
533
    OFPUTIL_C_PORT_BLOCKED   = 1 << 8,  /* Switch will block looping ports */
525
534
};
526
535
 
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,
556
 
};
557
 
 
558
536
/* Abstract ofp_switch_features. */
559
537
struct ofputil_switch_features {
560
538
    uint64_t datapath_id;       /* Datapath unique ID. */
562
540
    uint8_t n_tables;           /* Number of tables supported by datapath. */
563
541
    uint8_t auxiliary_id;       /* Identify auxiliary connections */
564
542
    enum ofputil_capabilities capabilities;
565
 
    enum ofputil_action_bitmap actions;
 
543
    uint64_t ofpacts;           /* Bitmap of OFPACT_* bits. */
566
544
};
567
545
 
568
546
enum ofperr ofputil_decode_switch_features(const struct ofp_header *,
605
583
struct ofpbuf *ofputil_encode_port_mod(const struct ofputil_port_mod *,
606
584
                                       enum ofputil_protocol);
607
585
 
 
586
/* Abstract version of OFPTC11_TABLE_MISS_*.
 
587
 *
 
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.
 
590
 *
 
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".
 
593
 *
 
594
 * OpenFlow 1.3 and later never sends packets that miss to the controller.
 
595
 */
 
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.
 
600
     *
 
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. */
 
604
 
 
605
    /* These constants have the same meanings as those in OpenFlow with the
 
606
     * same names. */
 
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. */
 
610
};
 
611
 
 
612
ovs_be32 ofputil_table_miss_to_config(enum ofputil_table_miss,
 
613
                                      enum ofp_version);
 
614
 
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;
612
619
};
613
620
 
614
621
enum ofperr ofputil_decode_table_mod(const struct ofp_header *,
623
630
    char name[OFP_MAX_TABLE_NAME_LEN];
624
631
    ovs_be64 metadata_match;  /* Bits of metadata table can match. */
625
632
    ovs_be64 metadata_write;  /* Bits of metadata table can write. */
626
 
    uint32_t config;          /* Bitmap of OFPTC_* values */
 
633
    enum ofputil_table_miss miss_config;
627
634
    uint32_t max_entries;     /* Max number of entries supported. */
628
635
 
629
636
    /* Table features related to instructions.  There are two instances:
646
653
         *    - 'apply' reports features available in an "apply_actions"
647
654
         *      instruction. */
648
655
        struct ofputil_table_action_features {
649
 
            uint32_t actions;     /* Bitmap of supported OFPAT*. */
650
 
            uint64_t set_fields;  /* Bitmap of MFF_* "set-field" supports. */
 
656
            uint64_t ofpacts;     /* Bitmap of supported OFPACT_*. */
 
657
            struct mf_bitmap set_fields; /* Fields for "set-field". */
651
658
        } write, apply;
652
659
    } nonmiss, miss;
653
660
 
670
677
     *
671
678
     * Other combinations do not make sense.
672
679
     */
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. */
676
683
};
677
684
 
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);
 
688
 
682
689
void ofputil_append_table_features_reply(
683
 
                            const struct ofputil_table_features *tf,
684
 
                            struct list *replies);
685
 
 
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);
688
691
 
689
692
/* Meter band configuration for all supported band types. */
690
693
struct ofputil_meter_band {
746
749
void ofputil_decode_meter_request(const struct ofp_header *,
747
750
                                  uint32_t *meter_id);
748
751
 
749
 
void ofputil_append_meter_config(struct list *replies,
 
752
void ofputil_append_meter_config(struct ovs_list *replies,
750
753
                                 const struct ofputil_meter_config *);
751
754
 
752
 
void ofputil_append_meter_stats(struct list *replies,
 
755
void ofputil_append_meter_stats(struct ovs_list *replies,
753
756
                                const struct ofputil_meter_stats *);
754
757
 
755
758
enum ofputil_meter_request_type {
797
800
 
798
801
enum ofperr ofputil_decode_role_status(const struct ofp_header *oh,
799
802
                                       struct ofputil_role_status *rs);
 
803
 
800
804
/* Abstract table stats.
801
805
 *
802
 
 * For now we use ofp12_table_stats as a superset of the other protocol
803
 
 * versions' table stats. */
804
 
 
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. */
 
815
};
 
816
 
 
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 *);
 
821
 
 
822
int ofputil_decode_table_stats_reply(struct ofpbuf *reply,
 
823
                                     struct ofputil_table_stats *,
 
824
                                     struct ofputil_table_features *);
808
825
 
809
826
/* Queue configuration request. */
810
827
struct ofpbuf *ofputil_encode_queue_get_config_request(enum ofp_version,
869
886
 
870
887
int ofputil_decode_flow_update(struct ofputil_flow_update *,
871
888
                               struct ofpbuf *msg, struct ofpbuf *ofpacts);
872
 
void ofputil_start_flow_update(struct list *replies);
 
889
void ofputil_start_flow_update(struct ovs_list *replies);
873
890
void ofputil_append_flow_update(const struct ofputil_flow_update *,
874
 
                                struct list *replies);
 
891
                                struct ovs_list *replies);
875
892
 
876
893
/* Abstract nx_flow_monitor_cancel. */
877
894
uint32_t ofputil_decode_flow_monitor_cancel(const struct ofp_header *);
884
901
    enum ofp_version ofp_version, ofp_port_t);
885
902
 
886
903
void ofputil_append_port_desc_stats_reply(const struct ofputil_phy_port *pp,
887
 
                                          struct list *replies);
 
904
                                          struct ovs_list *replies);
888
905
 
889
906
/* Encoding simple OpenFlow messages. */
890
907
struct ofpbuf *make_echo_request(enum ofp_version);
898
915
 
899
916
/* Actions. */
900
917
 
901
 
/* The type of an action.
902
 
 *
903
 
 * For each implemented OFPAT10_* and NXAST_* action type, there is a
904
 
 * corresponding constant prefixed with OFPUTIL_, e.g.:
905
 
 *
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
925
 
 * OFPUTIL_NXAST_NOTE
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
935
 
 *
936
 
 * (The above list helps developers who want to "grep" for these definitions.)
937
 
 */
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"
945
 
};
946
 
 
947
 
/* The number of values of "enum ofputil_action_code". */
948
 
enum {
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"
955
 
};
956
 
 
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);
961
 
 
962
 
void *ofputil_put_action(enum ofputil_action_code, struct ofpbuf *buf);
963
 
 
964
 
/* For each OpenFlow action <ENUM> that has a corresponding action structure
965
 
 * struct <STRUCT>, this defines two functions:
966
 
 *
967
 
 *   void ofputil_init_<ENUM>(struct <STRUCT> *action);
968
 
 *
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>.
972
 
 *
973
 
 *  struct <STRUCT> *ofputil_put_<ENUM>(struct ofpbuf *buf);
974
 
 *
975
 
 *     Appends a new 'action', of length 'sizeof(struct <STRUCT>)', to 'buf',
976
 
 *     initializes it with ofputil_init_<ENUM>(), and returns it.
977
 
 */
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"
991
 
 
992
 
#define OFP_ACTION_ALIGN 8      /* Alignment of ofp_actions. */
993
 
 
994
918
bool action_outputs_to_port(const union ofp_action *, ovs_be16 port);
995
919
 
996
920
enum ofperr ofputil_pull_actions(struct ofpbuf *, unsigned int actions_len,
1012
936
 
1013
937
struct ofpbuf *ofputil_encode_dump_ports_request(enum ofp_version ofp_version,
1014
938
                                                 ofp_port_t port);
1015
 
void ofputil_append_port_stat(struct list *replies,
 
939
void ofputil_append_port_stat(struct ovs_list *replies,
1016
940
                              const struct ofputil_port_stats *ops);
1017
941
size_t ofputil_count_port_stats(const struct ofp_header *);
1018
942
int ofputil_decode_port_stats(struct ofputil_port_stats *, struct ofpbuf *msg);
1047
971
 
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);
1052
976
 
 
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. */
 
980
};
 
981
 
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. */
 
995
 
 
996
    struct bucket_counter stats;
 
997
};
 
998
 
 
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;
1065
1005
};
1066
1006
 
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. */
1073
 
};
1074
 
 
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
 
1015
                                   * execution.*/
 
1016
    struct ovs_list buckets;      /* Contains "struct ofputil_bucket"s. */
 
1017
    struct ofputil_group_props props; /* Group properties. */
1078
1018
};
1079
1019
 
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. */
1099
 
 
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_* */
1102
1040
};
1103
1041
 
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. */
1109
1048
};
1110
1049
 
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 *);
1112
1059
 
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);
1133
1081
 
1137
1085
int ofputil_decode_group_stats_reply(struct ofpbuf *,
1138
1086
                                     struct ofputil_group_stats *);
1139
1087
 
 
1088
void ofputil_uninit_group_desc(struct ofputil_group_desc *gd);
1140
1089
uint32_t ofputil_decode_group_desc_request(const struct ofp_header *);
1141
1090
struct ofpbuf *ofputil_encode_group_desc_request(enum ofp_version,
1142
1091
                                                 uint32_t group_id);
1145
1094
                                    struct ofpbuf *, enum ofp_version);
1146
1095
 
1147
1096
void ofputil_append_group_desc_reply(const struct ofputil_group_desc *,
1148
 
                                     struct list *buckets,
1149
 
                                     struct list *replies);
 
1097
                                     const struct ovs_list *buckets,
 
1098
                                     struct ovs_list *replies);
1150
1099
 
1151
1100
struct ofputil_bundle_ctrl_msg {
1152
1101
    uint32_t    bundle_id;
1160
1109
    const struct ofp_header   *msg;
1161
1110
};
1162
1111
 
 
1112
enum ofptype;
 
1113
 
1163
1114
enum ofperr ofputil_decode_bundle_ctrl(const struct ofp_header *,
1164
1115
                                       struct ofputil_bundle_ctrl_msg *);
1165
1116
 
 
1117
struct ofpbuf *ofputil_encode_bundle_ctrl_request(enum ofp_version,
 
1118
                                                  struct ofputil_bundle_ctrl_msg *);
1166
1119
struct ofpbuf *ofputil_encode_bundle_ctrl_reply(const struct ofp_header *,
1167
1120
                                                struct ofputil_bundle_ctrl_msg *);
1168
1121
 
1170
1123
                                         struct ofputil_bundle_add_msg *msg);
1171
1124
 
1172
1125
enum ofperr ofputil_decode_bundle_add(const struct ofp_header *,
1173
 
                                      struct ofputil_bundle_add_msg *);
 
1126
                                      struct ofputil_bundle_add_msg *,
 
1127
                                      enum ofptype *type);
1174
1128
#endif /* ofp-util.h */