From: Tonghao Zhang <[email protected]> For installing more than MAX_FLOWS (65536) flows to netdev datapath. Add the ovs-appctl subcommand "dpif-netdev/pmd-set-max-flow" which can change the flow number which netdev datapath support.
Signed-off-by: Tonghao Zhang <[email protected]> --- v2: * change int type to atomic_uint32_t * check max flow number is whether valid (0 < max-flow < UINT_MAX). --- lib/dpif-netdev.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 8485b54db0d8..b5ce70f7d1d1 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -97,7 +97,6 @@ DEFINE_STATIC_PER_THREAD_DATA(uint32_t, recirc_depth, 0) #define DEFAULT_TX_FLUSH_INTERVAL 0 /* Configuration parameters. */ -enum { MAX_FLOWS = 65536 }; /* Maximum number of flows in flow table. */ enum { MAX_METERS = 65536 }; /* Maximum number of meters. */ enum { MAX_BANDS = 8 }; /* Maximum number of bands / meter. */ enum { N_METER_LOCKS = 64 }; /* Maximum number of meters. */ @@ -105,6 +104,9 @@ enum { N_METER_LOCKS = 64 }; /* Maximum number of meters. */ /* Protects against changes to 'dp_netdevs'. */ static struct ovs_mutex dp_netdev_mutex = OVS_MUTEX_INITIALIZER; +/* Maximum number of flows in flow table. */ +static atomic_uint32_t netdev_max_flow = ATOMIC_VAR_INIT(65536); + /* Contains all 'struct dp_netdev's. */ static struct shash dp_netdevs OVS_GUARDED_BY(dp_netdev_mutex) = SHASH_INITIALIZER(&dp_netdevs); @@ -1112,6 +1114,40 @@ pmd_info_show_perf(struct ds *reply, } } +static void +dpif_netdev_set_max_flow(struct unixctl_conn *conn, + int argc OVS_UNUSED, + const char *argv[], + void *aux OVS_UNUSED) +{ + long long max_flow = atoll(argv[1]); + + if (max_flow <= 0 || max_flow >= UINT_MAX) { + unixctl_command_reply_error(conn, + "max-flow should: > 0 and < UINT_MAX\n"); + return; + } + + atomic_store_relaxed(&netdev_max_flow, max_flow); + unixctl_command_reply(conn, NULL); +} + +static void +dpif_netdev_show_max_flow(struct unixctl_conn *conn, + int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, + void *aux OVS_UNUSED) +{ + struct ds reply = DS_EMPTY_INITIALIZER; + uint32_t max_flow; + + atomic_read_relaxed(&netdev_max_flow, &max_flow); + + ds_put_format(&reply,"%u\n", max_flow); + unixctl_command_reply(conn, ds_cstr(&reply)); + ds_destroy(&reply); +} + static int compare_poll_list(const void *a_, const void *b_) { @@ -1416,6 +1452,14 @@ dpif_netdev_init(void) "[-us usec] [-q qlen]", 0, 10, pmd_perf_log_set_cmd, NULL); + unixctl_command_register("dpif-netdev/pmd-set-max-flow", + "number", + 1, 1, dpif_netdev_set_max_flow, + NULL); + unixctl_command_register("dpif-netdev/pmd-show-max-flow", + "", + 0, 0, dpif_netdev_show_max_flow, + NULL); return 0; } @@ -3335,6 +3379,7 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd, struct dpif_flow_stats *stats) { struct dp_netdev_flow *netdev_flow; + uint32_t max_flow; int error = 0; if (stats) { @@ -3345,7 +3390,8 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd, netdev_flow = dp_netdev_pmd_lookup_flow(pmd, key, NULL); if (!netdev_flow) { if (put->flags & DPIF_FP_CREATE) { - if (cmap_count(&pmd->flow_table) < MAX_FLOWS) { + atomic_read_relaxed(&netdev_max_flow, &max_flow); + if (cmap_count(&pmd->flow_table) < max_flow) { dp_netdev_flow_add(pmd, match, ufid, put->actions, put->actions_len); error = 0; -- 2.23.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
