From patchwork Thu Nov 6 06:02:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kirjanov X-Patchwork-Id: 407313 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EE8541400A8 for ; Thu, 6 Nov 2014 17:30:56 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id ADCD61A27EF for ; Thu, 6 Nov 2014 17:30:56 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id DB04B1A016E for ; Thu, 6 Nov 2014 17:30:24 +1100 (AEDT) Received: by ozlabs.org (Postfix) id B961C1400B6; Thu, 6 Nov 2014 17:30:24 +1100 (AEDT) Delivered-To: linuxppc-dev@ozlabs.org Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E46761400A8 for ; Thu, 6 Nov 2014 17:30:21 +1100 (AEDT) Received: by mail-la0-f50.google.com with SMTP id hz20so2020899lab.37 for ; Wed, 05 Nov 2014 22:30:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PGmHxmF2FUi5nTKJ90p+7wM+WtW513m6i4xBPQqQX6I=; b=bh8IFbjGZkU0fiIZgUrgiTIIFJfZ5VtCMf3ePqQaTjEAwQKDJg6xz3IXzfO8NNqbOe ynM0qcshpnWbkm5nkQyVYwZSZkdEzTP6fc+va7OwLhj5B2Sw7kDcvMW3lJzog56aYjkt rExP/fvaTVMkPXVy/QJqPfFgOEPW7VeC7pbqte8cdvrhuDpC2djI0DSEfRoll2i9E5Z4 PAdvBQt4gba+CrlgzlbH/Ah+OJMRaJrAyi2UGDnqjJmWQb0JtYl8lH8HJGWskrBOKAl/ n6t+LAwqOkfcQdXD991tIkJJD+f0Kxaj/1j3cCP7VQTeee1WGU2PoEpqxcI45pb7upvl WOqw== X-Gm-Message-State: ALoCoQnVUP9bJPSLKShT8Z3Jg0vAO6PgRqNUIES/PNJei9XxM4c1ATQ4rVknLAkscmpSpscp81JJ X-Received: by 10.152.45.98 with SMTP id l2mr2354945lam.85.1415255417296; Wed, 05 Nov 2014 22:30:17 -0800 (PST) Received: from hydra.kdaintranet ([87.228.41.15]) by mx.google.com with ESMTPSA id x8sm2154927lae.24.2014.11.05.22.30.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Nov 2014 22:30:16 -0800 (PST) From: Denis Kirjanov To: netdev@vger.kernel.org Subject: [PATCH net-next] PPC: bpf_jit_comp: add SKF_AD_HATYPE instruction Date: Thu, 6 Nov 2014 09:02:35 +0300 Message-Id: <1415253755-4001-1-git-send-email-kda@linux-powerpc.org> X-Mailer: git-send-email 2.1.0 Cc: Philippe Bergheaud , linuxppc-dev@ozlabs.org, Denis Kirjanov , Daniel Borkmann , Alexei Starovoitov X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Add BPF extension SKF_AD_HATYPE to ppc JIT to check the hw type of the interface JIT off: [ 69.106783] test_bpf: #20 LD_HATYPE 48 48 PASS JIT on: [ 64.721757] test_bpf: #20 LD_HATYPE 7 6 PASS CC: Alexei Starovoitov CC: Daniel Borkmann CC: Philippe Bergheaud Signed-off-by: Denis Kirjanov --- arch/powerpc/net/bpf_jit_comp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c index d110e28..8bf4fc2 100644 --- a/arch/powerpc/net/bpf_jit_comp.c +++ b/arch/powerpc/net/bpf_jit_comp.c @@ -412,6 +412,22 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, PPC_ANDI(r_A, r_A, PKT_TYPE_MAX); PPC_SRWI(r_A, r_A, 5); break; + case BPF_ANC | SKF_AD_HATYPE: + BUILD_BUG_ON(FIELD_SIZEOF(struct net_device, type) != 2); + PPC_LD_OFFS(r_scratch1, r_skb, offsetof(struct sk_buff, + dev)); + PPC_CMPDI(r_scratch1, 0); + if (ctx->pc_ret0 != -1) { + PPC_BCC(COND_EQ, addrs[ctx->pc_ret0]); + } else { + /* Exit, returning 0; first pass hits here. */ + PPC_BCC_SHORT(COND_NE, (ctx->idx*4)+12); + PPC_LI(r_ret, 0); + PPC_JMP(exit_addr); + } + PPC_LHZ_OFFS(r_A, r_scratch1, + offsetof(struct net_device, type)); + break; case BPF_ANC | SKF_AD_CPU: #ifdef CONFIG_SMP /*