From patchwork Fri Apr 26 07:51:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Wang X-Patchwork-Id: 239708 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0413B2C0112 for ; Fri, 26 Apr 2013 17:54:04 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932094Ab3DZHxr (ORCPT ); Fri, 26 Apr 2013 03:53:47 -0400 Received: from mail-qa0-f46.google.com ([209.85.216.46]:55273 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759275Ab3DZHww (ORCPT ); Fri, 26 Apr 2013 03:52:52 -0400 Received: by mail-qa0-f46.google.com with SMTP id p6so104056qad.12 for ; Fri, 26 Apr 2013 00:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=WhkHkfnpkgrDUFX21U3gBWg0mpplYEU/S4U6T5LHOl0=; b=h5iSjV7x5b8N1hH6LDskv1gMhg2ANM8RWvJOPSJd+Mk8IlcYSxFWQluPnaJLUKthGk n9JsEfPxcmrtHjrT/y9NDPoz3V9TW6Y+blgnT34Av2utMnbXKbYgtJwREbegZEm3g3Hf 48y4VDG89VRV/1r3PzML/swJWbkMOt2oM2eOc6br5EevMqMYxbz27VW0ao+Zx+xtnoXk rdGxaaS3a677613UTmMJ2isREfLACjI2UYEIsAT2F+NTtBYh40XInSQiqC04z6q5q99v o/AH2sCkdhMhfL03XrsJ2tqiXW48nCN4TStLCFCnvEouwbkVPGIeGUNIlBNAb1xNtL0e fHeQ== X-Received: by 10.229.8.133 with SMTP id h5mr15122992qch.148.1366962772004; Fri, 26 Apr 2013 00:52:52 -0700 (PDT) Received: from hchen.csail.mit.edu (hchen.csail.mit.edu. [18.26.5.5]) by mx.google.com with ESMTPSA id h5sm15736932qai.9.2013.04.26.00.52.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Apr 2013 00:52:51 -0700 (PDT) From: Xi Wang To: Daniel Borkmann , "David S. Miller" , Russell King , Heiko Carstens , Eric Dumazet , Will Drewry , Andrew Morton Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Xi Wang Subject: [RFC PATCH net-next 5/6] sparc: bpf_jit_comp: refactor the BPF JIT interface Date: Fri, 26 Apr 2013 03:51:45 -0400 Message-Id: <1366962706-24204-6-git-send-email-xi.wang@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1366962706-24204-1-git-send-email-xi.wang@gmail.com> References: <1366962706-24204-1-git-send-email-xi.wang@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Implement the refactored bpf_jit_compile() and bpf_jit_free(). Signed-off-by: Xi Wang --- arch/sparc/net/bpf_jit_comp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c index d36a85e..15e6513 100644 --- a/arch/sparc/net/bpf_jit_comp.c +++ b/arch/sparc/net/bpf_jit_comp.c @@ -354,21 +354,21 @@ do { *prog++ = BR_OPC | WDISP22(OFF); \ * emit_jump() calls with adjusted offsets. */ -void bpf_jit_compile(struct sk_filter *fp) +bpf_func_t bpf_jit_compile(struct sock_filter *filter, unsigned int flen) { unsigned int cleanup_addr, proglen, oldproglen = 0; u32 temp[8], *prog, *func, seen = 0, pass; - const struct sock_filter *filter = fp->insns; - int i, flen = fp->len, pc_ret0 = -1; + int i, pc_ret0 = -1; unsigned int *addrs; void *image; + bpf_func_t bpf_func = sk_run_filter; if (!bpf_jit_enable) - return; + return bpf_func; addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL); if (addrs == NULL) - return; + return bpf_func; /* Before first pass, make a rough estimation of addrs[] * each bpf instruction is translated to less than 64 bytes @@ -763,7 +763,7 @@ cond_branch: f_offset = addrs[i + filter[i].jf]; pr_err("bpb_jit_compile fatal error\n"); kfree(addrs); module_free(NULL, image); - return; + return bpf_func; } memcpy(image + proglen, temp, ilen); } @@ -799,11 +799,11 @@ cond_branch: f_offset = addrs[i + filter[i].jf]; if (image) { bpf_flush_icache(image, image + proglen); - fp->bpf_func = (void *)image; + bpf_func = (void *)image; } out: kfree(addrs); - return; + return bpf_func; } static void jit_free_defer(struct work_struct *arg) @@ -814,10 +814,10 @@ static void jit_free_defer(struct work_struct *arg) /* run from softirq, we must use a work_struct to call * module_free() from process context */ -void bpf_jit_free(struct sk_filter *fp) +void bpf_jit_free(bpf_func_t bpf_func) { - if (fp->bpf_func != sk_run_filter) { - struct work_struct *work = (struct work_struct *)fp->bpf_func; + if (bpf_func != sk_run_filter) { + struct work_struct *work = (struct work_struct *)bpf_func; INIT_WORK(work, jit_free_defer); schedule_work(work);