[RFC,bpf-next,1/2] nfp: bpf: set new jit info fields

Message ID 20180112220624.14424-1-jakub.kicinski@netronome.com
State RFC
Delegated to: BPF Maintainers
Headers show
Series
  • [RFC,bpf-next,1/2] nfp: bpf: set new jit info fields
Related show

Commit Message

Jakub Kicinski Jan. 12, 2018, 10:06 p.m.
From: Jiong Wang <jiong.wang@netronome.com>

This patch set those new jit info fields introduced in previous patch for NFP.

Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/bpf/main.h    |  2 ++
 drivers/net/ethernet/netronome/nfp/bpf/offload.c | 12 +++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.h b/drivers/net/ethernet/netronome/nfp/bpf/main.h
index 66381afee2a9..41ee68eb7ddc 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/main.h
+++ b/drivers/net/ethernet/netronome/nfp/bpf/main.h
@@ -42,6 +42,8 @@ 
 
 #include "../nfp_asm.h"
 
+#define NFP_ARCH_NAME	"NFP-6xxx"
+
 /* For relocation logic use up-most byte of branch instruction as scratch
  * area.  Remember to clear this before sending instructions to HW!
  */
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/offload.c b/drivers/net/ethernet/netronome/nfp/bpf/offload.c
index 320b2250d29a..8862d1e50bf5 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/offload.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/offload.c
@@ -124,6 +124,7 @@  static int nfp_bpf_translate(struct nfp_net *nn, struct bpf_prog *prog)
 	struct nfp_prog *nfp_prog = prog->aux->offload->dev_priv;
 	unsigned int stack_size;
 	unsigned int max_instr;
+	int err;
 
 	stack_size = nn_readb(nn, NFP_NET_CFG_BPF_STACK_SZ) * 64;
 	if (prog->aux->stack_depth > stack_size) {
@@ -140,7 +141,16 @@  static int nfp_bpf_translate(struct nfp_net *nn, struct bpf_prog *prog)
 	if (!nfp_prog->prog)
 		return -ENOMEM;
 
-	return nfp_bpf_jit(nfp_prog);
+	err = nfp_bpf_jit(nfp_prog);
+	if (err)
+		return err;
+
+	prog->aux->offload->jited_len = nfp_prog->prog_len * sizeof(u64);
+	prog->aux->offload->jited_image = nfp_prog->prog;
+	memcpy(prog->aux->offload->jited_arch_name, NFP_ARCH_NAME,
+	       sizeof(NFP_ARCH_NAME));
+
+	return 0;
 }
 
 static int nfp_bpf_destroy(struct nfp_net *nn, struct bpf_prog *prog)