From patchwork Thu Jun 8 11:46:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roi Dayan X-Patchwork-Id: 772979 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wk3qQ3Fr9z9s7B for ; Thu, 8 Jun 2017 21:58:58 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id BC251BEE; Thu, 8 Jun 2017 11:47:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp2.linuxfoundation.org (smtp2.linux-foundation.org [172.17.192.36]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 9BFECBD7 for ; Thu, 8 Jun 2017 11:47:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by smtp2.linuxfoundation.org (Postfix) with ESMTP id 7A47B1DB0A for ; Thu, 8 Jun 2017 11:47:38 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from roid@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Jun 2017 14:47:03 +0300 Received: from dev-r-vrt-189.mtr.labs.mlnx (dev-r-vrt-189.mtr.labs.mlnx [10.212.189.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v58Bkvqq018658; Thu, 8 Jun 2017 14:47:03 +0300 From: Roi Dayan To: dev@openvswitch.org Date: Thu, 8 Jun 2017 14:46:39 +0300 Message-Id: <1496922410-36853-23-git-send-email-roid@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1496922410-36853-1-git-send-email-roid@mellanox.com> References: <1496922410-36853-1-git-send-email-roid@mellanox.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp2.linux-foundation.org Cc: Shahar Klein , Hadar Hen Zion , Rony Efraim , Flavio Leitner , Jiri Pirko , Marcelo Ricardo Leitner , Simon Horman , Or Gerlitz , Andy Gospodarek Subject: [ovs-dev] [PATCH V10 22/33] netdev-tc-offloads: Implement flow get using tc interface X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Paul Blakey Search the requested ufid for a offloaded flow, and if found, dump and parse it back to required format. Signed-off-by: Paul Blakey Reviewed-by: Roi Dayan Reviewed-by: Simon Horman Acked-by: Flavio Leitner --- lib/netdev-tc-offloads.c | 50 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c index 287d7cd..d1036d1 100644 --- a/lib/netdev-tc-offloads.c +++ b/lib/netdev-tc-offloads.c @@ -840,13 +840,51 @@ netdev_tc_flow_put(struct netdev *netdev, int netdev_tc_flow_get(struct netdev *netdev OVS_UNUSED, - struct match *match OVS_UNUSED, - struct nlattr **actions OVS_UNUSED, - const ovs_u128 *ufid OVS_UNUSED, - struct dpif_flow_stats *stats OVS_UNUSED, - struct ofpbuf *buf OVS_UNUSED) + struct match *match, + struct nlattr **actions, + const ovs_u128 *ufid, + struct dpif_flow_stats *stats, + struct ofpbuf *buf) { - return EOPNOTSUPP; + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + struct netdev *dev; + struct tc_flower flower; + odp_port_t in_port; + int prio = 0; + int ifindex; + int handle; + int err; + + handle = get_ufid_tc_mapping(ufid, &prio, &dev); + if (!handle) { + return ENOENT; + } + + ifindex = netdev_get_ifindex(dev); + if (ifindex < 0) { + VLOG_ERR_RL(&error_rl, "failed to get ifindex for %s: %s", + netdev_get_name(dev), ovs_strerror(-ifindex)); + netdev_close(dev); + return -ifindex; + } + + VLOG_DBG_RL(&rl, "flow get (dev %s prio %d handle %d)", + netdev_get_name(dev), prio, handle); + err = tc_get_flower(ifindex, prio, handle, &flower); + netdev_close(dev); + if (err) { + VLOG_ERR_RL(&error_rl, "flow get failed (dev %s prio %d handle %d): %s", + netdev_get_name(dev), prio, handle, ovs_strerror(err)); + return err; + } + + in_port = netdev_ifindex_to_odp_port(ifindex); + parse_tc_flower_to_match(&flower, match, actions, stats, buf); + + match->wc.masks.in_port.odp_port = u32_to_odp(UINT32_MAX); + match->flow.in_port.odp_port = in_port; + + return 0; } int