Re: [ovs-dev] how to use ovn-scale-test when i do not use git repo

2020-01-11 Thread shenjian . gc


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH ovn 2/2] Refactor physical module functions to take context argument - physical_ctx.

2020-01-11 Thread Han Zhou
On Fri, Jan 10, 2020 at 11:26 AM  wrote:
>
> From: Numan Siddique 
>
> No functional changes are introduced in this patch.
>

Similar comment to what I had for the patch 1, but here since the output
parameter is only one - the desired flow table, so I think we could just
move it out from the ctx structure instead of two structures.

> Signed-off-by: Numan Siddique 
> ---
>  controller/ovn-controller.c | 185 ++--
>  controller/physical.c   | 126 +++-
>  controller/physical.h   |  46 -
>  3 files changed, 144 insertions(+), 213 deletions(-)
>
> diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
> index 4942df6c4..390057ee2 100644
> --- a/controller/ovn-controller.c
> +++ b/controller/ovn-controller.c
> @@ -1213,6 +1213,68 @@ struct ed_type_flow_output {
>  struct lflow_resource_ref lflow_resource_ref;
>  };
>
> +static void init_physical_ctx(struct engine_node *node,
> +  struct ed_type_runtime_data *rt_data,
> +  struct ovn_desired_flow_table *flow_table,
> +  struct physical_ctx *p_ctx)
> +{
> +struct ovsdb_idl_index *sbrec_port_binding_by_name =
> +engine_ovsdb_node_get_index(
> +engine_get_input("SB_port_binding", node),
> +"name");
> +
> +struct sbrec_multicast_group_table *multicast_group_table =
> +(struct sbrec_multicast_group_table *)EN_OVSDB_GET(
> +engine_get_input("SB_multicast_group", node));
> +
> +struct sbrec_port_binding_table *port_binding_table =
> +(struct sbrec_port_binding_table *)EN_OVSDB_GET(
> +engine_get_input("SB_port_binding", node));
> +
> +struct sbrec_chassis_table *chassis_table =
> +(struct sbrec_chassis_table *)EN_OVSDB_GET(
> +engine_get_input("SB_chassis", node));
> +
> +struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve =
> +engine_get_input_data("mff_ovn_geneve", node);
> +
> +struct ovsrec_open_vswitch_table *ovs_table =
> +(struct ovsrec_open_vswitch_table *)EN_OVSDB_GET(
> +engine_get_input("OVS_open_vswitch", node));
> +struct ovsrec_bridge_table *bridge_table =
> +(struct ovsrec_bridge_table *)EN_OVSDB_GET(
> +engine_get_input("OVS_bridge", node));
> +const struct ovsrec_bridge *br_int = get_br_int(bridge_table,
ovs_table);
> +const char *chassis_id = chassis_get_id();
> +const struct sbrec_chassis *chassis = NULL;
> +struct ovsdb_idl_index *sbrec_chassis_by_name =
> +engine_ovsdb_node_get_index(
> +engine_get_input("SB_chassis", node),
> +"name");
> +if (chassis_id) {
> +chassis = chassis_lookup_by_name(sbrec_chassis_by_name,
chassis_id);
> +}
> +
> +ovs_assert(br_int && chassis);
> +
> +struct ed_type_ct_zones *ct_zones_data =
> +engine_get_input_data("ct_zones", node);
> +struct simap *ct_zones = &ct_zones_data->current;
> +
> +p_ctx->sbrec_port_binding_by_name = sbrec_port_binding_by_name;
> +p_ctx->port_binding_table = port_binding_table;
> +p_ctx->mc_group_table = multicast_group_table;
> +p_ctx->br_int = br_int;
> +p_ctx->chassis_table = chassis_table;
> +p_ctx->chassis = chassis;
> +p_ctx->flow_table = flow_table;
> +p_ctx->active_tunnels = &rt_data->active_tunnels;
> +p_ctx->local_datapaths = &rt_data->local_datapaths;
> +p_ctx->local_lports = &rt_data->local_lports;
> +p_ctx->ct_zones = ct_zones;
> +p_ctx->mff_ovn_geneve = ed_mff_ovn_geneve->mff_ovn_geneve;
> +}
> +
>  static void init_lflow_ctx(struct engine_node *node,
> struct ed_type_runtime_data *rt_data,
> struct ed_type_flow_output *fo,
> @@ -1317,17 +1379,6 @@ en_flow_output_run(struct engine_node *node, void
*data)
>  {
>  struct ed_type_runtime_data *rt_data =
>  engine_get_input_data("runtime_data", node);
> -struct hmap *local_datapaths = &rt_data->local_datapaths;
> -struct sset *local_lports = &rt_data->local_lports;
> -struct sset *active_tunnels = &rt_data->active_tunnels;
> -
> -struct ed_type_ct_zones *ct_zones_data =
> -engine_get_input_data("ct_zones", node);
> -struct simap *ct_zones = &ct_zones_data->current;
> -
> -struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve =
> -engine_get_input_data("mff_ovn_geneve", node);
> -enum mf_field_id mff_ovn_geneve = ed_mff_ovn_geneve->mff_ovn_geneve;
>
>  struct ovsrec_open_vswitch_table *ovs_table =
>  (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET(
> @@ -1367,37 +1418,15 @@ en_flow_output_run(struct engine_node *node, void
*data)
>  lflow_resource_clear(lfrr);
>  }
>
> -struct ovsdb_idl_index *sbrec_port_binding_by_name =
> -engine_ovsdb_node_get_index(
> -engine_get_input("SB_port_binding", node),
> -  

Re: [ovs-dev] [PATCH ovn 1/2] Refactor lflow functions to take one context argument - lflow_ctx.

2020-01-11 Thread Han Zhou
On Fri, Jan 10, 2020 at 11:26 AM  wrote:
>
> From: Numan Siddique 
>
> Presently most of the lflow_*() functions called from ovn-controller.c
> takes lots of arguments. This patch adds 'struct lflow_ctx' to simplify
> the code a bit. This also reduces some code in ovn-controller.c and
> improves readability to some degree.
>
> No functional changes are introduced in this patch.

Thanks Numan for the patch. Please see my comments below.

>
> Signed-off-by: Numan Siddique 
> ---
>  controller/lflow.c  | 255 ++--
>  controller/lflow.h  |  83 
>  controller/ovn-controller.c | 240 -
>  3 files changed, 186 insertions(+), 392 deletions(-)
>
> diff --git a/controller/lflow.c b/controller/lflow.c
> index a6893201e..311f8e2be 100644
> --- a/controller/lflow.c
> +++ b/controller/lflow.c
> @@ -61,25 +61,12 @@ struct condition_aux {
>  const struct sset *active_tunnels;
>  };
>
> -static bool consider_logical_flow(
> -struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath,
> -struct ovsdb_idl_index *sbrec_port_binding_by_name,
> -const struct sbrec_logical_flow *,
> -const struct hmap *local_datapaths,
> -const struct sbrec_chassis *,
> -struct hmap *dhcp_opts,
> -struct hmap *dhcpv6_opts,
> -struct hmap *nd_ra_opts,
> -struct controller_event_options *controller_event_opts,
> -const struct shash *addr_sets,
> -const struct shash *port_groups,
> -const struct sset *active_tunnels,
> -const struct sset *local_lport_ids,
> -struct ovn_desired_flow_table *,
> -struct ovn_extend_table *group_table,
> -struct ovn_extend_table *meter_table,
> -struct lflow_resource_ref *lfrr,
> -uint32_t *conj_id_ofs);
> +static bool
> +consider_logical_flow(struct lflow_ctx *l_ctx,
> +  const struct sbrec_logical_flow *lflow,
> +  struct hmap *dhcp_opts, struct hmap *dhcpv6_opts,
> +  struct hmap *nd_ra_opts,
> +  struct controller_event_options
*controller_event_opts);
>
>  static bool
>  lookup_port_cb(const void *aux_, const char *port_name, unsigned int
*portp)
> @@ -257,30 +244,15 @@ lflow_resource_destroy_lflow(struct
lflow_resource_ref *lfrr,
>
>  /* Adds the logical flows from the Logical_Flow table to flow tables. */
>  static void
> -add_logical_flows(
> -struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath,
> -struct ovsdb_idl_index *sbrec_port_binding_by_name,
> -const struct sbrec_dhcp_options_table *dhcp_options_table,
> -const struct sbrec_dhcpv6_options_table *dhcpv6_options_table,
> -const struct sbrec_logical_flow_table *logical_flow_table,
> -const struct hmap *local_datapaths,
> -const struct sbrec_chassis *chassis,
> -const struct shash *addr_sets,
> -const struct shash *port_groups,
> -const struct sset *active_tunnels,
> -const struct sset *local_lport_ids,
> -struct ovn_desired_flow_table *flow_table,
> -struct ovn_extend_table *group_table,
> -struct ovn_extend_table *meter_table,
> -struct lflow_resource_ref *lfrr,
> -uint32_t *conj_id_ofs)
> +add_logical_flows(struct lflow_ctx *l_ctx)
>  {
>  const struct sbrec_logical_flow *lflow;
>
>  struct hmap dhcp_opts = HMAP_INITIALIZER(&dhcp_opts);
>  struct hmap dhcpv6_opts = HMAP_INITIALIZER(&dhcpv6_opts);
>  const struct sbrec_dhcp_options *dhcp_opt_row;
> -SBREC_DHCP_OPTIONS_TABLE_FOR_EACH (dhcp_opt_row, dhcp_options_table)
{
> +SBREC_DHCP_OPTIONS_TABLE_FOR_EACH (dhcp_opt_row,
> +   l_ctx->dhcp_options_table) {
>  dhcp_opt_add(&dhcp_opts, dhcp_opt_row->name, dhcp_opt_row->code,
>   dhcp_opt_row->type);
>  }
> @@ -288,7 +260,7 @@ add_logical_flows(
>
>  const struct sbrec_dhcpv6_options *dhcpv6_opt_row;
>  SBREC_DHCPV6_OPTIONS_TABLE_FOR_EACH (dhcpv6_opt_row,
> - dhcpv6_options_table) {
> + l_ctx->dhcpv6_options_table) {
> dhcp_opt_add(&dhcpv6_opts, dhcpv6_opt_row->name,
dhcpv6_opt_row->code,
>  dhcpv6_opt_row->type);
>  }
> @@ -299,16 +271,9 @@ add_logical_flows(
>  struct controller_event_options controller_event_opts;
>  controller_event_opts_init(&controller_event_opts);
>
> -SBREC_LOGICAL_FLOW_TABLE_FOR_EACH (lflow, logical_flow_table) {
> -if
(!consider_logical_flow(sbrec_multicast_group_by_name_datapath,
> -   sbrec_port_binding_by_name,
> -   lflow, local_datapaths,
> -   chassis, &dhcp_opts, &dhcpv6_opts,
> -   &nd_ra_opts, &controller_event_opts,
> -   addr_sets, port_groups,
> -   active_tunnels, local_lport_ids,
> -