From patchwork Wed Jan 8 09:32:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1219494 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HR3bi4+K"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47t3vV0N7zz9sPn for ; Wed, 8 Jan 2020 20:33:09 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9276185E25; Wed, 8 Jan 2020 09:33:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cNxTp7-s_Olu; Wed, 8 Jan 2020 09:33:04 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 47D1585D52; Wed, 8 Jan 2020 09:33:04 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1833CC1D81; Wed, 8 Jan 2020 09:33:04 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 406A5C0881 for ; Wed, 8 Jan 2020 09:33:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 2CE7D2048D for ; Wed, 8 Jan 2020 09:33:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vSbBeynsLUDs for ; Wed, 8 Jan 2020 09:33:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by silver.osuosl.org (Postfix) with ESMTPS id E12C320431 for ; Wed, 8 Jan 2020 09:33:00 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id az3so889122plb.11 for ; Wed, 08 Jan 2020 01:33:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=hulcuoHRWQamYrmrpIIFJ61taC6Ghbq7qCtKX5yVKaY=; b=HR3bi4+K6GC05KeiQOQxslR8Lh3jfHe9UHNDbuK5dcrOV+j4hrGcdUCKDl47evFsNn EO7hrnNMlIjh36uQWFE7aKfuL6+VLHIXIm0igYdftwTb/Ui6095shKFV92NCv9CZhkLJ dl9/B6KFz/jGgTLuGsTB7DVzl503L35mRDX7K6CcOTKOcrg1+yv5YfFWAv3yA4iS7yQU fR1Enez6JjZpQqvLNLYAGNxMvIqwK1BJ9MVM7t50akFO5ut3p4H/k+GVCZxvLlpniFRC man9+asH9bjVBeI1AYCWQAVt7fABq4/n5VXzcT2/rF5eSD3MBVDUI1zzMUJBRpWj3JaF hDAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hulcuoHRWQamYrmrpIIFJ61taC6Ghbq7qCtKX5yVKaY=; b=EM3etX7BFisDHntf94CgJxDOCqEKxWQrIEZya+N1HbDuIpcO7UyFgOUcitMDnpLI/b Y0vSKXJNK6N8ItG5cyRQkZygZdiKUznRTYLK8v/rss6CHf9x5cu3NftaXjUQjWBlpDpm RxxdK9KQbqcICFXXCKChH+ajcTF8UzXe2W5dT/smKLXwm+iYOZGqFrRdCr6CBm4iqSV9 +jBcZ23+fka7f8qdVE+D3T+bMXXrEM6N/TR83WeWdf/i5fmq6RIiqDhE3fQ8TlfFMiJ8 ik+Op23m7z7jw1lQO8wxyLDbp14HKadt8LMq+n5OqFP+dR3s7/UMkS55qAkC8Gl1Cw2+ 9crw== X-Gm-Message-State: APjAAAX1PvpZ6B2g6+RWcEM1BE+ZFR/BlCnEo1Z9QB8f0SOnzRok89Q+ WYhC6r1ZILXx6OGcirrjY9Y= X-Google-Smtp-Source: APXvYqwJdUby9aqsF94+ooMPmVCSqSSfjbWDXl3+FBSejnK+FcA7bUbt+OtUw/y/OnMarTXFhVOchQ== X-Received: by 2002:a17:90a:bc41:: with SMTP id t1mr3277929pjv.137.1578475980420; Wed, 08 Jan 2020 01:33:00 -0800 (PST) Received: from local.opencloud.tech.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id r30sm2923011pfl.162.2020.01.08.01.32.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jan 2020 01:32:59 -0800 (PST) From: xiangxia.m.yue@gmail.com To: blp@ovn.org Date: Wed, 8 Jan 2020 17:32:48 +0800 Message-Id: <1578475968-36897-1-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 Cc: dev@openvswitch.org Subject: [ovs-dev] [ovs-dev v2] dpif-netdev: Allow to set max capacity of flow on netdev X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang 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 --- 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;