From patchwork Fri Jan 12 15:47:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 860011 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="QkAPE5hl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zJ6ZX0PJbz9t3B for ; Sat, 13 Jan 2018 02:47:32 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964823AbeALPrT (ORCPT ); Fri, 12 Jan 2018 10:47:19 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:45739 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964792AbeALPrQ (ORCPT ); Fri, 12 Jan 2018 10:47:16 -0500 Received: by mail-wm0-f67.google.com with SMTP id i186so12916997wmi.4 for ; Fri, 12 Jan 2018 07:47:15 -0800 (PST) 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=b3iOquWC3hpAhIyobeCtmMbwcQ+OQbEuLt7rvmpEyWs=; b=QkAPE5hl6SzwkgIeI4R5S6bk4psE+RqgaykvjpUxcpIRAWcysKXHzK/Y9SphyecM+o F1Cq3bTabA/9A5QA2nRI2fGtv7qKv4lIwtZXaxHbpH94croh5SJiNy9lasG80wAsK95k H3C0Aps/SgYHiOQ9OfIo/PqjBjbQjfqWvucG5WtWFYwZZEMZtsJ68dzkxy9WDhR3lxnI R8Ynne/v60b+D/oZO4nPn1LyLHtPtXQmhB0nJrvrO93AS9rhxi6+UmFQRwoQSv5wfeKv BsTaaRN01ZvwpPxGkRKeV5l/5uu5heEz7JSwx/V5c+Td9ihkxlKIoH5okHIa9HF/o4k8 lRQg== 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=b3iOquWC3hpAhIyobeCtmMbwcQ+OQbEuLt7rvmpEyWs=; b=XmBNFAkwCgDRay9Zy2W41aAKKYfgt2i+/xZKoWaJ9C95KmZ5RKOQX389VOdnivlule rbQwMasL2uKLZAU6JZFHJiHHgr4CtodtnyhvKel85n12XKV6G5RK6cMBjSYF30AsFrCD 9TetA6kzfce7vO7ICpG+QhjQX2I1lFBpLloR1qeCVofZiecJPUqAgd3yFkLgY4KdBFJZ WbOb03mmHMJ1hZl08GxvipMcz5RQ9KpQWqeTfQtzOKxviAKfi+uQKWMl1vks7p2eS0k9 KqmcBXu9oqa5hN913JK2u59OtCAlQGr/i8JjgjSXVEYbzU+jg4kGb3BInOlOutls0ZIe HDlw== X-Gm-Message-State: AKwxytdeL4tv99+6ad4RGNEN9bRX9nLiKyWB2gzG7pTAB+v+Lg12q1qQ nwNyjJbXH0ocqV+zdohyOEY1ibTA X-Google-Smtp-Source: ACJfBouxt1VoxVbWaEvdM7AH+33gfovTlcgvoolqvKzdD6bAP5+uZDrX2yRjpomRdjTRXPonNDneig== X-Received: by 10.28.126.87 with SMTP id z84mr4078006wmc.105.1515772035169; Fri, 12 Jan 2018 07:47:15 -0800 (PST) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id 187sm5648283wmu.19.2018.01.12.07.47.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jan 2018 07:47:14 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com, mlxsw@mellanox.com, andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com, michael.chan@broadcom.com, ganeshgr@chelsio.com, saeedm@mellanox.com, matanb@mellanox.com, leonro@mellanox.com, idosch@mellanox.com, jakub.kicinski@netronome.com, simon.horman@netronome.com, pieter.jansenvanvuuren@netronome.com, john.hurley@netronome.com, alexander.h.duyck@intel.com, ogerlitz@mellanox.com, john.fastabend@gmail.com, daniel@iogearbox.net, dsahern@gmail.com Subject: [patch net-next v8 10/14] net: sched: allow ingress and clsact qdiscs to share filter blocks Date: Fri, 12 Jan 2018 16:47:00 +0100 Message-Id: <20180112154704.1694-11-jiri@resnulli.us> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180112154704.1694-1-jiri@resnulli.us> References: <20180112154704.1694-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Benefit from the previously introduced shared filter blocks infrastructure and allow ingress and clsact qdisc instances to share filter blocks. The block index is coming from userspace as qdisc option. Signed-off-by: Jiri Pirko --- v7->v8: - base this on the patch that introduces qdisc-generic block index attributes parsing/dumping v6->v7: - adjust to the core changes and check block index attributes for being 0 v3->v4: - rebased on top of the current net-next v2->v3: - removed "p_" prefix from block index function args --- net/sched/sch_ingress.c | 76 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 14 deletions(-) diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c index 7ca2be2..5f0bf8e 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c @@ -61,6 +61,20 @@ static void clsact_chain_head_change(struct tcf_proto *tp_head, void *priv) struct mini_Qdisc_pair *miniqp = priv; mini_qdisc_pair_swap(miniqp, tp_head); +}; + +static void ingress_ingress_block_set(struct Qdisc *sch, u32 block_index) +{ + struct ingress_sched_data *q = qdisc_priv(sch); + + q->block_info.block_index = block_index; +} + +static u32 ingress_ingress_block_get(struct Qdisc *sch) +{ + struct ingress_sched_data *q = qdisc_priv(sch); + + return q->block_info.block_index; } static int ingress_init(struct Qdisc *sch, struct nlattr *opt, @@ -120,13 +134,15 @@ static const struct Qdisc_class_ops ingress_class_ops = { }; static struct Qdisc_ops ingress_qdisc_ops __read_mostly = { - .cl_ops = &ingress_class_ops, - .id = "ingress", - .priv_size = sizeof(struct ingress_sched_data), - .init = ingress_init, - .destroy = ingress_destroy, - .dump = ingress_dump, - .owner = THIS_MODULE, + .cl_ops = &ingress_class_ops, + .id = "ingress", + .priv_size = sizeof(struct ingress_sched_data), + .init = ingress_init, + .destroy = ingress_destroy, + .dump = ingress_dump, + .ingress_block_set = ingress_ingress_block_set, + .ingress_block_get = ingress_ingress_block_get, + .owner = THIS_MODULE, }; struct clsact_sched_data { @@ -170,6 +186,34 @@ static struct tcf_block *clsact_tcf_block(struct Qdisc *sch, unsigned long cl, } } +static void clsact_ingress_block_set(struct Qdisc *sch, u32 block_index) +{ + struct clsact_sched_data *q = qdisc_priv(sch); + + q->ingress_block_info.block_index = block_index; +} + +static void clsact_egress_block_set(struct Qdisc *sch, u32 block_index) +{ + struct clsact_sched_data *q = qdisc_priv(sch); + + q->egress_block_info.block_index = block_index; +} + +static u32 clsact_ingress_block_get(struct Qdisc *sch) +{ + struct clsact_sched_data *q = qdisc_priv(sch); + + return q->ingress_block_info.block_index; +} + +static u32 clsact_egress_block_get(struct Qdisc *sch) +{ + struct clsact_sched_data *q = qdisc_priv(sch); + + return q->egress_block_info.block_index; +} + static int clsact_init(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) { @@ -228,13 +272,17 @@ static const struct Qdisc_class_ops clsact_class_ops = { }; static struct Qdisc_ops clsact_qdisc_ops __read_mostly = { - .cl_ops = &clsact_class_ops, - .id = "clsact", - .priv_size = sizeof(struct clsact_sched_data), - .init = clsact_init, - .destroy = clsact_destroy, - .dump = ingress_dump, - .owner = THIS_MODULE, + .cl_ops = &clsact_class_ops, + .id = "clsact", + .priv_size = sizeof(struct clsact_sched_data), + .init = clsact_init, + .destroy = clsact_destroy, + .dump = ingress_dump, + .ingress_block_set = clsact_ingress_block_set, + .egress_block_set = clsact_egress_block_set, + .ingress_block_get = clsact_ingress_block_get, + .egress_block_get = clsact_egress_block_get, + .owner = THIS_MODULE, }; static int __init ingress_module_init(void)