From patchwork Fri Jan 12 04:29:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 859494 X-Patchwork-Delegate: bpf@iogearbox.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=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="o+WQP+nz"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zHqYL5P5jz9sQm for ; Fri, 12 Jan 2018 15:30:30 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933388AbeALEa3 (ORCPT ); Thu, 11 Jan 2018 23:30:29 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:37686 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933064AbeALE3w (ORCPT ); Thu, 11 Jan 2018 23:29:52 -0500 Received: by mail-pg0-f68.google.com with SMTP id z17so3818412pgc.4 for ; Thu, 11 Jan 2018 20:29:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KQ/b306AwpdCoDloaju8zY5Or1XVmQWjobfvY6q9RPw=; b=o+WQP+nzt9JsE8AX6rdTm7EPmuJi/qRLA4VhSMRmoLmTG6j2cseepweS8WYMMRrwC0 e1dGg79G5fuWl87kNIjOJe9swY776+6sE1Ldgk2qmc0I9UfvbAfn258q6/G5NrkB4++t F5/KsyMgRgkneh4lNWf+sUNmQHR/IjHN5y424T9tj3TLl2HqxEqTJLOdhJhsPMBMnVVu YCHQiGR67v4KB2sZoSYwx9wxVTl8914QCTiIDMGSghVYqaJ2U5foyvagYw86OC2tWvTd m5wctuB1iir0jqib3UNMbPhvl7FOTKVPMN8nYzxpebXUpNSgv3fr0WPB4ffAHIvPzUpR PSrw== 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=KQ/b306AwpdCoDloaju8zY5Or1XVmQWjobfvY6q9RPw=; b=F00Fm1tT84lX3G3R7Vul28dXePXI538+kzcGwlOy0iW/YiFX3407BN0bZVPYuPReh/ yAoKVl2GyWJcy+dhSDNZtqYdtu+0q40CwfsN5FtXPflmQpLKANPWFKlSkkNktJPnHJTB +VA9135p9sXnpwkY8oohPJ4N/q2SXV9BhWgm18BED0PYoWZwwM4vL2B2DyhIW0hmaZK1 aTUdVsaKIZ+xi1vk0fZy/8Gh4mvvJG3hyE+x35fpJe/CpTdUPyjhVF+Syk6m/iwrWLp0 w0Q9QQYcETx9ZqPZKIRzUL114QMP78kQnlEpnQexv75A1cehplqsoVLt5m6OZOe3+8nJ +jxg== X-Gm-Message-State: AKGB3mLpg4q2Dt8RE0wV74PIkBRC2H4azGzt+Ww/CP4ZCKcYR5Sfk3+T IZH+yQ7I/qxdf4qK6bDQM+AiDg== X-Google-Smtp-Source: ACJfBotTNOMheNlF55ZCtRFq5L/8D7R10luD6wUXDkJjaF2Y8Bg9oIRAYIbqbsHi1jwTx0lAV9vP6w== X-Received: by 10.84.130.78 with SMTP id 72mr24886751plc.278.1515731391893; Thu, 11 Jan 2018 20:29:51 -0800 (PST) Received: from jkicinski-Precision-T1700.netronome.com ([75.53.12.129]) by smtp.gmail.com with ESMTPSA id e8sm45863875pfk.6.2018.01.11.20.29.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Jan 2018 20:29:51 -0800 (PST) From: Jakub Kicinski To: alexei.starovoitov@gmail.com, daniel@iogearbox.net, davem@davemloft.net Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, tehnerd@fb.com, Jakub Kicinski Subject: [PATCH bpf-next v2 08/15] nfp: bpf: add map data structure Date: Thu, 11 Jan 2018 20:29:10 -0800 Message-Id: <20180112042917.10348-9-jakub.kicinski@netronome.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180112042917.10348-1-jakub.kicinski@netronome.com> References: <20180112042917.10348-1-jakub.kicinski@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org To be able to split code into reasonable chunks we need to add the map data structures already. Later patches will add code piece by piece. Signed-off-by: Jakub Kicinski Reviewed-by: Quentin Monnet --- drivers/net/ethernet/netronome/nfp/bpf/main.c | 7 ++++++- drivers/net/ethernet/netronome/nfp/bpf/main.h | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.c b/drivers/net/ethernet/netronome/nfp/bpf/main.c index e8cfe300c8c4..c9fd7d417d1a 100644 --- a/drivers/net/ethernet/netronome/nfp/bpf/main.c +++ b/drivers/net/ethernet/netronome/nfp/bpf/main.c @@ -313,6 +313,8 @@ static int nfp_bpf_init(struct nfp_app *app) bpf->app = app; app->priv = bpf; + INIT_LIST_HEAD(&bpf->map_list); + err = nfp_bpf_parse_capabilities(app); if (err) goto err_free_bpf; @@ -326,7 +328,10 @@ static int nfp_bpf_init(struct nfp_app *app) static void nfp_bpf_clean(struct nfp_app *app) { - kfree(app->priv); + struct nfp_app_bpf *bpf = app->priv; + + WARN_ON(!list_empty(&bpf->map_list)); + kfree(bpf); } const struct nfp_app_type app_bpf = { diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.h b/drivers/net/ethernet/netronome/nfp/bpf/main.h index 66381afee2a9..23763b22f8fc 100644 --- a/drivers/net/ethernet/netronome/nfp/bpf/main.h +++ b/drivers/net/ethernet/netronome/nfp/bpf/main.h @@ -93,6 +93,8 @@ enum pkt_vec { * struct nfp_app_bpf - bpf app priv structure * @app: backpointer to the app * + * @map_list: list of offloaded maps + * * @adjust_head: adjust head capability * @flags: extra flags for adjust head * @off_min: minimal packet offset within buffer required @@ -103,6 +105,8 @@ enum pkt_vec { struct nfp_app_bpf { struct nfp_app *app; + struct list_head map_list; + struct nfp_bpf_cap_adjust_head { u32 flags; int off_min; @@ -112,6 +116,20 @@ struct nfp_app_bpf { } adjust_head; }; +/** + * struct nfp_bpf_map - private per-map data attached to BPF maps for offload + * @offmap: pointer to the offloaded BPF map + * @bpf: back pointer to bpf app private structure + * @tid: table id identifying map on datapath + * @l: link on the nfp_app_bpf->map_list list + */ +struct nfp_bpf_map { + struct bpf_offloaded_map *offmap; + struct nfp_app_bpf *bpf; + u32 tid; + struct list_head l; +}; + struct nfp_prog; struct nfp_insn_meta; typedef int (*instr_cb_t)(struct nfp_prog *, struct nfp_insn_meta *);