From patchwork Wed Jun 13 13:47:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 10462261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8D4C960348 for ; Wed, 13 Jun 2018 13:49:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C65E2842B for ; Wed, 13 Jun 2018 13:49:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7144E28914; Wed, 13 Jun 2018 13:49:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B3C532842B for ; Wed, 13 Jun 2018 13:49:15 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 415Sls50w9zF09q for ; Wed, 13 Jun 2018 23:49:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="CohePvcM"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=resnulli.us (client-ip=2a00:1450:400c:c09::22e; helo=mail-wm0-x22e.google.com; envelope-from=jiri@resnulli.us; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="CohePvcM"; dkim-atps=neutral Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com [IPv6:2a00:1450:400c:c09::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 415SlG4gD5zDr9J for ; Wed, 13 Jun 2018 23:48:42 +1000 (AEST) Received: by mail-wm0-x22e.google.com with SMTP id n5-v6so5529643wmc.5 for ; Wed, 13 Jun 2018 06:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BvWsYIdm186LHjpLitfebB1wWpN4aYLZAgHUaRdWOYE=; b=CohePvcM6sXDs6CZfEd9fhdMrE52ZxCA9FoFK1jgm58hzFdRSJPgUvtamC/EEAdw81 XFNyYshQxWA5vYa+ijhgBGHUnl9yrPh0cRvANapN4D6cYL1D8VwDHR3LYcWktpwzpKHh EQJDSF8XeR9SH9e5oKAMHbtuDKEVPJF4XoF8Loalac6zV15Y7dGRHdcPV7bvaJ8d7MB6 abobkUBvd9j2ZyFYRI4nwip9Ojvj5FRTurTk00OSRH6o03S2uF3d8nFc5/i+QsEzNjBf M0xeswUcgjfWKXgubzrnq319uxD/VeJPmPce3HR41J7ao3y6SVer1HXkEbfuENRjORB4 Khgw== 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=BvWsYIdm186LHjpLitfebB1wWpN4aYLZAgHUaRdWOYE=; b=AhYW2uneacgFIz0HB/s7B6PwMK7sQUV37ud5JhImR9Opne9QxDmFe4VFqYn+h6D5ul bT+kCNitGnrQo3a0hK0xE1RiEu+fM+aiMQDRcFAVV6e5pyUJ04PVH/QV4nq/TtTCIFgA chYUkltybUT/yQhbljTgO91fPl9B5uCZ3RexrCo/hEoeNDTJIq0ZOBlKqQGK7afd4y5t Co74sCd9lo3iVHvuHxrECGHp/ye9VxjHhCPh01Nc73l25wjJO0/QdOHSJDlD3ETZLZVB +z2aOQN/oAWaFVV0G19jnyUqek54pU64BymBVfwwiL5MoZpStMLk0H/tlb9Nkn8sLd0G 1jGg== X-Gm-Message-State: APt69E1dWdcITwVW+HZRSc8kOxmvip2TmGSHyAvHY3kWOChtBfOnd3qp ylf9WloXCkikX+iMQz2P/bkruA== X-Google-Smtp-Source: ADUXVKK4E542UaD+SCphDsd8O6M7xLnY6aHvr+Vhpb1QH/deE6iGJ9NGkr7BxcMmYURdQP08MKRMLA== X-Received: by 2002:a1c:96c8:: with SMTP id y191-v6mr3438816wmd.37.1528897719671; Wed, 13 Jun 2018 06:48:39 -0700 (PDT) Received: from localhost (ip-89-177-135-115.net.upcbroadband.cz. [89.177.135.115]) by smtp.gmail.com with ESMTPSA id c10-v6sm2813829wrs.6.2018.06.13.06.48.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 06:48:39 -0700 (PDT) From: Jiri Pirko To: linux-internal@mellanox.com Subject: [patch net-next mlxsw/noapply 6/7] net: sched: cls_flower: propagate chain teplate creation and destruction to drivers Date: Wed, 13 Jun 2018 15:47:32 +0200 Message-Id: <20180613134733.2766-7-jiri@resnulli.us> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180613134733.2766-1-jiri@resnulli.us> References: <20180613134733.2766-1-jiri@resnulli.us> X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jiri Pirko Introduce a couple of flower offload commands in order to propagate template creation/destruction events down to device drivers. Drivers may use this information to prepare HW in an optimal way for future filter insertions. Signed-off-by: Jiri Pirko --- include/net/pkt_cls.h | 2 ++ net/sched/cls_flower.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index a3c1a2c47cd4..e83968cf9a70 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -715,6 +715,8 @@ enum tc_fl_command { TC_CLSFLOWER_REPLACE, TC_CLSFLOWER_DESTROY, TC_CLSFLOWER_STATS, + TC_CLSFLOWER_TMPLT_CREATE, + TC_CLSFLOWER_TMPLT_DESTROY, }; struct tc_cls_flower_offload { diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 18274b291ff2..a80f04d5fefb 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -1105,6 +1105,42 @@ static void fl_walk(struct tcf_proto *tp, struct tcf_walker *arg) } } +static void fl_hw_create_tmplt(struct tcf_chain *chain, + struct fl_flow_tmplt *tmplt) +{ + struct tc_cls_flower_offload cls_flower = {}; + struct tcf_block *block = chain->block; + struct tcf_exts dummy_exts = { 0, }; + + cls_flower.common.chain_index = chain->index; + cls_flower.command = TC_CLSFLOWER_TMPLT_CREATE; + cls_flower.cookie = (unsigned long) tmplt; + cls_flower.dissector = &tmplt->dissector; + cls_flower.mask = &tmplt->mask; + cls_flower.key = &tmplt->dummy_key; + cls_flower.exts = &dummy_exts; + + /* We don't care if driver (any of them) fails to handle this + * call. It serves just as a hint for it. + */ + tc_setup_cb_call(block, NULL, TC_SETUP_CLSFLOWER, + &cls_flower, false); +} + +static void fl_hw_destroy_tmplt(struct tcf_chain *chain, + struct fl_flow_tmplt *tmplt) +{ + struct tc_cls_flower_offload cls_flower = {}; + struct tcf_block *block = chain->block; + + cls_flower.common.chain_index = chain->index; + cls_flower.command = TC_CLSFLOWER_TMPLT_DESTROY; + cls_flower.cookie = (unsigned long) tmplt; + + tc_setup_cb_call(block, NULL, TC_SETUP_CLSFLOWER, + &cls_flower, false); +} + static void *fl_tmplt_create(struct net *net, struct tcf_chain *chain, struct nlattr **tca, struct netlink_ext_ack *extack) @@ -1135,6 +1171,8 @@ static void *fl_tmplt_create(struct net *net, struct tcf_chain *chain, fl_init_dissector(&tmplt->dissector, &tmplt->mask); + fl_hw_create_tmplt(chain, tmplt); + return tmplt; errout_tmplt: @@ -1148,6 +1186,7 @@ static void fl_tmplt_destroy(void *tmplt_priv) { struct fl_flow_tmplt *tmplt = tmplt_priv; + fl_hw_destroy_tmplt(tmplt->chain, tmplt); kfree(tmplt); }