netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: netdev@vger.kernel.org
Cc: oss-drivers@netronome.com, Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next 06/15] nfp: bpf: remove register rename
Date: Sun,  8 Oct 2017 21:04:08 -0700	[thread overview]
Message-ID: <20171009040417.22172-7-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20171009040417.22172-1-jakub.kicinski@netronome.com>

Remove the register renumbering optimization.  To implement calling
map and other helpers we need more strict register layout.  We can't
freely reassign register numbers.

This will have the effect of running in 4 context/thread mode, which
should be OK since we are moving towards integrating the BPF closer
with FW app datapath anyway, and the target datapath itself runs in
4 context mode.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/bpf/jit.c | 46 ++--------------------------
 1 file changed, 3 insertions(+), 43 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/bpf/jit.c b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
index 095cf50e8450..469dc8a055f2 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/jit.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/jit.c
@@ -1621,38 +1621,6 @@ static void nfp_bpf_opt_reg_init(struct nfp_prog *nfp_prog)
 	}
 }
 
-/* Try to rename registers so that program uses only low ones */
-static int nfp_bpf_opt_reg_rename(struct nfp_prog *nfp_prog)
-{
-	bool reg_used[MAX_BPF_REG] = {};
-	u8 tgt_reg[MAX_BPF_REG] = {};
-	struct nfp_insn_meta *meta;
-	unsigned int i, j;
-
-	list_for_each_entry(meta, &nfp_prog->insns, l) {
-		if (meta->skip)
-			continue;
-
-		reg_used[meta->insn.src_reg] = true;
-		reg_used[meta->insn.dst_reg] = true;
-	}
-
-	for (i = 0, j = 0; i < ARRAY_SIZE(tgt_reg); i++) {
-		if (!reg_used[i])
-			continue;
-
-		tgt_reg[i] = j++;
-	}
-	nfp_prog->num_regs = j;
-
-	list_for_each_entry(meta, &nfp_prog->insns, l) {
-		meta->insn.src_reg = tgt_reg[meta->insn.src_reg];
-		meta->insn.dst_reg = tgt_reg[meta->insn.dst_reg];
-	}
-
-	return 0;
-}
-
 /* Remove masking after load since our load guarantees this is not needed */
 static void nfp_bpf_opt_ld_mask(struct nfp_prog *nfp_prog)
 {
@@ -1729,14 +1697,8 @@ static void nfp_bpf_opt_ld_shift(struct nfp_prog *nfp_prog)
 
 static int nfp_bpf_optimize(struct nfp_prog *nfp_prog)
 {
-	int ret;
-
 	nfp_bpf_opt_reg_init(nfp_prog);
 
-	ret = nfp_bpf_opt_reg_rename(nfp_prog);
-	if (ret)
-		return ret;
-
 	nfp_bpf_opt_ld_mask(nfp_prog);
 	nfp_bpf_opt_ld_shift(nfp_prog);
 
@@ -1783,10 +1745,8 @@ nfp_bpf_jit(struct bpf_prog *filter, void *prog_mem,
 	if (ret)
 		goto out;
 
-	if (nfp_prog->num_regs <= 7)
-		nfp_prog->regs_per_thread = 16;
-	else
-		nfp_prog->regs_per_thread = 32;
+	nfp_prog->num_regs = MAX_BPF_REG;
+	nfp_prog->regs_per_thread = 32;
 
 	nfp_prog->prog = prog_mem;
 	nfp_prog->__prog_alloc_len = prog_sz;
@@ -1799,7 +1759,7 @@ nfp_bpf_jit(struct bpf_prog *filter, void *prog_mem,
 	}
 
 	res->n_instr = nfp_prog->prog_len;
-	res->dense_mode = nfp_prog->num_regs <= 7;
+	res->dense_mode = false;
 out:
 	nfp_prog_free(nfp_prog);
 
-- 
2.14.1

  parent reply	other threads:[~2017-10-09  4:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-09  4:04 [PATCH net-next 00/15] nfp: bpf ABIv2 and multi port Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 01/15] nfp: output control messages to trace_devlink_hwmsg() Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 02/15] nfp: bpf: lift the single-port limitation Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 03/15] nfp: bpf: use the power of sparse to check we encode registers right Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 04/15] nfp: bpf: move software reg helpers and cmd table out of translator Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 05/15] nfp: bpf: encode all 64bit shifts Jakub Kicinski
2017-10-09  4:04 ` Jakub Kicinski [this message]
2017-10-09  4:04 ` [PATCH net-next 07/15] nfp: bpf: remove packet marking support Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 08/15] nfp: add more white space to the instruction defines Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 09/15] nfp: bpf: encode LMEM accesses Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 10/15] nfp: bpf: encode extended LM pointer operands Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 11/15] nfp: bpf: move to datapath ABI version 2 Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 12/15] nfp: bpf: calculate code store ECC Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 13/15] nfp: bpf: pad code with valid nops Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 14/15] nfp: bpf: byte swap the instructions Jakub Kicinski
2017-10-09  4:04 ` [PATCH net-next 15/15] nfp: bpf: pass dst register to ld_field instruction Jakub Kicinski
2017-10-09 16:52 ` [PATCH net-next 00/15] nfp: bpf ABIv2 and multi port David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171009040417.22172-7-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).