From: Tonghao Zhang <[email protected]>

There may be too many flows (> MAX_FLOWS 65536) on
dpif-netdev at same time. For this case, we support
the ovs-appctl command to change the flow max number.

Signed-off-by: Tonghao Zhang <[email protected]>
---
 lib/dpif-netdev.c | 51 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 8485b54db0d8..9d14268aa703 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 uint32_t netdev_max_flows = 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,43 @@ 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)
+{
+    struct ds ds = DS_EMPTY_INITIALIZER;
+    uint32_t max_flows = atoi(argv[1]);
+
+    if (!max_flows) {
+        unixctl_command_reply_error(conn,
+                                    "the max flow capacity should > 0\n");
+        return;
+    }
+
+    netdev_max_flows = max_flows;
+    ds_put_format(&ds, "set netdev_max_flows to %u\n", netdev_max_flows);
+    unixctl_command_reply(conn, ds_cstr(&ds));
+
+    ds_destroy(&ds);
+}
+
+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;
+
+    ds_put_format(&reply,"pmd flow capacity: %u\n",
+                  netdev_max_flows);
+    unixctl_command_reply(conn, ds_cstr(&reply));
+
+    ds_destroy(&reply);
+}
+
 static int
 compare_poll_list(const void *a_, const void *b_)
 {
@@ -1416,6 +1455,14 @@ dpif_netdev_init(void)
                              "[-us usec] [-q qlen]",
                              0, 10, pmd_perf_log_set_cmd,
                              NULL);
+    unixctl_command_register("dpif-netdev/pmd-set-flow-capacity",
+                             "max-flow-number",
+                             1, 1, dpif_netdev_set_max_flow,
+                             NULL);
+    unixctl_command_register("dpif-netdev/pmd-show-flow-capacity",
+                             "",
+                             0, 0, dpif_netdev_show_max_flow,
+                             NULL);
     return 0;
 }
 
@@ -3345,7 +3392,7 @@ 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) {
+            if (cmap_count(&pmd->flow_table) < netdev_max_flows) {
                 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

Reply via email to