This creates an alternative to lflow_table_add_lflow(). This alternative, lflow_table_add_lflow_(), takes its arguments in a structure, rather than as individual function parameters.
This provides the basis for redefining the many ovn_lflow_add() macro variations. In this commit, we define ovn_lflow_add() as a VFUNC. The 7 argument version of ovn_lflow_add() is defined as ovn_flow_add_7(). This macro uses lflow_table_add_lflow_(). We do not touch northd.c in this commit, but this implicitly converts all pre-existing calls to ovn_lflow_add() to the new version which uses the struct argument. Upcoming commits will convert the other ovn_lflow_add()-related macros to use ovn_lflow_add() with different argument numbers. Signed-off-by: Mark Michelson <[email protected]> --- northd/lflow-mgr.c | 10 ++++++++++ northd/lflow-mgr.h | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/northd/lflow-mgr.c b/northd/lflow-mgr.c index 43dd1d947..dfa3c39e9 100644 --- a/northd/lflow-mgr.c +++ b/northd/lflow-mgr.c @@ -773,6 +773,16 @@ lflow_table_add_lflow(struct lflow_table *lflow_table, lflow_hash_unlock(hash_lock); } +void +lflow_table_add_lflow_(struct lflow_table_add_args args, const char *where) +{ + lflow_table_add_lflow(args.table, args.od, args.dp_bitmap, + args.dp_bitmap_len, args.stage, args.priority, + args.match, args.actions, args.io_port, + args.ctrl_meter, args.stage_hint, where, + args.flow_desc, args.lflow_ref); +} + struct ovn_dp_group * ovn_dp_group_get(struct hmap *dp_groups, const struct dynamic_bitmap *desired_bitmap, diff --git a/northd/lflow-mgr.h b/northd/lflow-mgr.h index c1e72d1be..4dc45fca3 100644 --- a/northd/lflow-mgr.h +++ b/northd/lflow-mgr.h @@ -76,6 +76,24 @@ bool lflow_ref_sync_lflows(struct lflow_ref *, const struct sbrec_logical_flow_table *, const struct sbrec_logical_dp_group_table *); +struct lflow_table_add_args { + struct lflow_table *table; + const struct ovn_datapath *od; + const unsigned long *dp_bitmap; + size_t dp_bitmap_len; + enum ovn_stage stage; + uint16_t priority; + const char *match; + const char *actions; + const char *io_port; + const char *ctrl_meter; + const struct ovsdb_idl_row *stage_hint; + const char *flow_desc; + struct lflow_ref *lflow_ref; +}; + +void lflow_table_add_lflow_(struct lflow_table_add_args args, + const char *where); void lflow_table_add_lflow(struct lflow_table *, const struct ovn_datapath *, const unsigned long *dp_bitmap, @@ -87,6 +105,18 @@ void lflow_table_add_lflow(struct lflow_table *, const struct ovn_datapath *, const char *where, const char *flow_desc, struct lflow_ref *); +#define ovn_lflow_add_7(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, ACTIONS, \ + LFLOW_REF) \ + lflow_table_add_lflow_((struct lflow_table_add_args) { \ + .table = LFLOW_TABLE, \ + .od = OD, \ + .stage = STAGE, \ + .priority = PRIORITY, \ + .match = MATCH, \ + .actions = ACTIONS, \ + .lflow_ref = LFLOW_REF, \ + }, OVS_SOURCE_LOCATOR) + /* Adds a row with the specified contents to the Logical_Flow table. */ #define ovn_lflow_add_with_hint__(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, \ ACTIONS, IN_OUT_PORT, CTRL_METER, \ @@ -131,11 +161,7 @@ void lflow_table_add_lflow(struct lflow_table *, const struct ovn_datapath *, ACTIONS, IN_OUT_PORT, NULL, STAGE_HINT, \ OVS_SOURCE_LOCATOR, NULL, LFLOW_REF) -#define ovn_lflow_add(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, ACTIONS, \ - LFLOW_REF) \ - lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \ - ACTIONS, NULL, NULL, NULL, OVS_SOURCE_LOCATOR, \ - NULL, LFLOW_REF) +#define ovn_lflow_add(...) VFUNC(ovn_lflow_add_, __VA_ARGS__) #define ovn_lflow_add_drop_with_desc(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, \ DESCRIPTION, LFLOW_REF) \ -- 2.51.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
