From patchwork Tue Jun 2 13:50:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1302468 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.a=rsa-sha256 header.s=20161025 header.b=g+ML++bV; 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 49btkb3QGZz9sSc for ; Tue, 2 Jun 2020 23:51:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 296AB864EF; Tue, 2 Jun 2020 13:51:48 +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 aLoVPBwUMCvm; Tue, 2 Jun 2020 13:51:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id E3BCF86422; Tue, 2 Jun 2020 13:51:45 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D721DC0178; Tue, 2 Jun 2020 13:51:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id CE39CC016E for ; Tue, 2 Jun 2020 13:51:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id BB9B78779F for ; Tue, 2 Jun 2020 13:51:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hy-dZkg1JeDG for ; Tue, 2 Jun 2020 13:51:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by whitealder.osuosl.org (Postfix) with ESMTPS id 93E7A87773 for ; Tue, 2 Jun 2020 13:51:43 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id i12so1389060pju.3 for ; Tue, 02 Jun 2020 06:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nX3RecM2aF+SUX4r0TRZRzi8c7lVhmj7QNstVaRVQpY=; b=g+ML++bVavehLkcPW84qV1CY+rXPDBTVtxKHFDdblDBIiCW+Md+L8G0qqW1bap7OYc fh7W8rQwh0fwbPDHL6WMn1Abcefnh8W3rtR35Riye0bb5JNToSkbkDGZ+qVUd7XkVKpG svn8yX9sfX+DdVL8iYpuYLNXhEmTzbRqfUWf+VgXUIX3fzL81hf+jBEkaPW2fDPd/tNn tqdXteCjwl4k1xmxDca1HA28X2VZUX/j3ptGTn4VAq/qah/nsi6J8MCBNoRRiVg7/QSc +b9+R6W10gYZCQ2Imyd5wwgVo/tctSXEh5cvVABJY4YCNHlNSrgngnLakgFeoRu6u1Q5 m9YA== 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:in-reply-to :references; bh=nX3RecM2aF+SUX4r0TRZRzi8c7lVhmj7QNstVaRVQpY=; b=BT3u5PIeHdMF3AKteUSWEzd+BvisnWDV6wE9siGXwmwakvJQA/0wgzHdaEG95PA7Fg UFVip+tGLzd2O23xkozc8X1/KrAM01uP9U5InfNv2GAOISKTy4CEngaAuxzZhdPzRv4v aGxn/vU7yoox0tBFIAvDrFeSRri3e7gibv2SldCm0N1pj1TZUcsyJE+3y7ySyCOoAAmX hcbVvjQCeBDwHLILEGo9H0XifOCc+3HYgRD7ivWbNrh+Bs2bjG4H+TQfXSmB0XFl4BVT dHZqwNzXoKuoqx6lqZn2fUJM6xP0FjRvLcLZ959ZyawXisN8YCl7kV6DDmL79nhYgIsE Y+8A== X-Gm-Message-State: AOAM531/x0Q0lysxqoA5HX6eQjN0WkSRRjE1MbhT/ZAAk4U2I9fIal6v 1qJ17tjUDTXOv/7m0wHgPezc+yf4cCzhPQ== X-Google-Smtp-Source: ABdhPJza+cDwagBW/MvJlMrn8y9chYbKyl/ot9nznBLtOSMLQfhWNo6rUNfH7pAAmCB4w8/Qx+QeWw== X-Received: by 2002:a17:90a:36af:: with SMTP id t44mr5912465pjb.49.1591105903061; Tue, 02 Jun 2020 06:51:43 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id h21sm2514622pjz.6.2020.06.02.06.51.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2020 06:51:42 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: dev@openvswitch.org Date: Tue, 2 Jun 2020 21:50:22 +0800 Message-Id: <20200602135025.20704-2-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200602135025.20704-1-xiangxia.m.yue@gmail.com> References: <20200602135025.20704-1-xiangxia.m.yue@gmail.com> Cc: simon.horman@netronome.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH v2 1/4] dpif-netlink: Generate ufids for installing TC flowers 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 To support installing the TC flowers to HW, via "ovs-appctl dpctl/add-flow" command, there should be an ufid. This patch will check whether ufid exists, if not, generate an ufid. Should to know that when processing upcall packets, ufid is generated in parse_odp_packet for kernel datapath. Configuring the max-idle/max-revalidator, may help testing this patch. Cc: Simon Horman Cc: Paul Blakey Cc: Roi Dayan Cc: Ben Pfaff Cc: William Tu Cc: Ilya Maximets Signed-off-by: Tonghao Zhang Acked-by: Roi Dayan --- lib/dpif-netlink.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index dc642100fc58..a19ed7e53566 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -2231,12 +2231,55 @@ dpif_netlink_operate_chunks(struct dpif_netlink *dpif, struct dpif_op **ops, } } +static void +dpif_netlink_try_update_ufid__(struct dpif_op *op, ovs_u128 *ufid) +{ + switch (op->type) { + case DPIF_OP_FLOW_PUT: + if (!op->flow_put.ufid) { + odp_flow_key_hash(op->flow_put.key, op->flow_put.key_len, + ufid); + op->flow_put.ufid = ufid; + } + break; + case DPIF_OP_FLOW_DEL: + if (!op->flow_del.ufid) { + odp_flow_key_hash(op->flow_del.key, op->flow_del.key_len, + ufid); + op->flow_del.ufid = ufid; + } + break; + case DPIF_OP_FLOW_GET: + if (!op->flow_get.ufid) { + odp_flow_key_hash(op->flow_get.key, op->flow_get.key_len, + ufid); + op->flow_get.ufid = ufid; + } + break; + case DPIF_OP_EXECUTE: + default: + break; + } +} + +static void +dpif_netlink_try_update_ufid(struct dpif_op **ops, ovs_u128 *ufid, + size_t n_ops) +{ + int i; + + for (i = 0; i < n_ops; i++) { + dpif_netlink_try_update_ufid__(ops[i], &ufid[i]); + } +} + static void dpif_netlink_operate(struct dpif *dpif_, struct dpif_op **ops, size_t n_ops, enum dpif_offload_type offload_type) { struct dpif_netlink *dpif = dpif_netlink_cast(dpif_); struct dpif_op *new_ops[OPERATE_MAX_OPS]; + ovs_u128 ufids[OPERATE_MAX_OPS]; int count = 0; int i = 0; int err = 0; @@ -2246,6 +2289,8 @@ dpif_netlink_operate(struct dpif *dpif_, struct dpif_op **ops, size_t n_ops, return; } + dpif_netlink_try_update_ufid(ops, ufids, n_ops); + if (offload_type != DPIF_OFFLOAD_NEVER && netdev_is_flow_api_enabled()) { while (n_ops > 0) { count = 0;