From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0087.outbound.protection.outlook.com [104.47.37.87]) by dpdk.org (Postfix) with ESMTP id B9C57AA97 for ; Tue, 13 Mar 2018 14:40:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=AdSvoEQVOAGVYYWTsmjeJ/8PTO6aT/ayO1bOwyRewmk=; b=V3gVtuZRSPbYTSFeAVsaoluEsoE6a8chKlLfNEm/JfTCpogt20If5JST21Qfx3Nyb+N+NLyZD6sY8oCWUQsLLuj0PhJllVe4AorD4cTUWwX0IUfJTWAdTfUKWkWvtx/9XNql1G/aJYvCm8XaJXLRP9QWDtcyCr+po2FsUZUTjQU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin (111.93.218.67) by BN3PR07MB2513.namprd07.prod.outlook.com (2a01:111:e400:7bbf::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.12; Tue, 13 Mar 2018 13:39:58 +0000 Date: Tue, 13 Mar 2018 19:09:42 +0530 From: Jerin Jacob To: Konstantin Ananyev Cc: dev@dpdk.org Message-ID: <20180313133941.GB564@jerin> References: <1520613725-9176-1-git-send-email-konstantin.ananyev@intel.com> <1520613725-9176-4-git-send-email-konstantin.ananyev@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1520613725-9176-4-git-send-email-konstantin.ananyev@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR01CA0083.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::23) To BN3PR07MB2513.namprd07.prod.outlook.com (2a01:111:e400:7bbf::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86ee2832-c724-48e2-377e-08d588e7ea40 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BN3PR07MB2513; X-Microsoft-Exchange-Diagnostics: 1; BN3PR07MB2513; 3:dq053cpQJo0pUUZUNPFPcafgRrO24YlKoXV73cSlQKjHIlQQexWHpyHaZ2s/+CUFEiTFXoXFc8BRmwLt8FLOfAdwPZU+PyDW7lxPLWGQwey7DmG0lDBRvtxp6GT+TjFSWvkpfB2JXQ7ZE1jqy7+lTlV4DH8ggIEShytuR9aFNc+c4smmBubYtQFZpjg51tFAR8KxuteItLFFZg7KFJS2gel4yUP6BP3dKnoYJVAhkW2IpVd74ZpVf8uGX5RZiXKf; 25:5p9Ps7OsBScKXetDsek6rgUWJ5eBIbEFXbGNC+UOHyLvkvyWuckK/c3G9mXjaxKpViJaRQ1OYRZpmLYc72he+RwuwGTarX/BC8Ga4NbB7O9jzqZS1SQvfgkWTZ8xI5sPWU0ED+5ZWCSGfMPYKCs34Limc+CyQ/NJZaSUbzJPbhPjp5aNXqj0mpCJJwoPGdHqjBzrWq1fcUAMhgTTCbACk/EsLhilcTvrOKrESUffX/A4pIAFqHpMEm9xf9W+u2YjQAOk2b+AQep7OO+BEhlKtqRbyIpvDjwLPbMjK2BCph1KGhykw/sIi2qOaFZJs7c8cyLB/x3124gher2A7fUEzg==; 31:0BDY3OrA+Q98wlpljTH+fPlVpbrhThFE3utskK8/wspFOP53dNrnHrAV9BRMjr072fQtR+QK464+drDUkHsbL3aX+sh7hYewkhxT8tBupyHXKyUqZ5crgmeAzXgN1yib/UNPiR+FdBJVTEgGA/rN0x20mYzJstPuuD8bBfO4Cw2+HH/MsCBedSLGZFPxq/X9W9lVaW99mccaMoxygVCxjAeesTGIPsybt8oqN8hfZeU= X-MS-TrafficTypeDiagnostic: BN3PR07MB2513: X-Microsoft-Exchange-Diagnostics: 1; BN3PR07MB2513; 20:AhKjUxsk6lNbYLKyQRygTUVMdxgBtL7mhqRIjG4c2zulfwM0iCdZGEIIvk57e3u3m3DyoZ+wn5Esv7mIQq24FOfroE+qf2OaYwZb9m2pxJq6zNfWhWCJOg0hbcOTrTzDwr43reJiWn7nQsJaP3HZiJmkZ6UWDzcMGSEmkouXJSb39icTI5+1EI+GH56gwCrl/QXOeJYYUELjP4vc15d2rZY7fInoBcCUfOXQDOj/0Ra5MppDn+NIBfMiUt67oj/jk37akosUp417wZMXnYvB/WQSflvMxLSrI8mbmvfjFXUIWdhKlgQ02C3N/gu6DakRrl/UeKtxN+SJlqWV3xFf2IMYO2wHTU8cKhJYcDCiHz68kLgIS+pGxnEHyw679FiECCRwmdgmeO8rd4sf5Ofwp/GzFLdjh9pIPSxXm99lzTtef5CAnae0dHefQrpf3epBnSa5K/SwZrsE3dbkEktKqwBH9RALNhfI1od45C5ScJ3fm6dCrjKLPXq13SuEgOS4jwyJ5WGDkzLr3YV128rTxzqa97QekbMhqB9uHeUop398zL+J8mNTE6Mm2BevhOs37TJy7bRzI/0CTE2Pu/MXsgEG1PvLGs1srZPx/OC0oCg=; 4:Igw3iOpdPrcRps3sgLvah1pTUjSF1KPlAHIKPTUKxyDhLwNjnHQsfo8TDru9InJv/L7xnTErRPXR+F2KT2+tYMBduvIkIYcrmsKf2t9IT7F0HZMzCTHt0ANP2B1p77fjdTQ2ZwYAGBz+lHTCf/BsiEgrTc8Yb+sP+qZGn8Ljo7vTQDatIpzx5tvMZt5CgZaNzCvh0bk3zYdX6FKCBz+VDeLN8oGd7lh9kIujiF9rxjsjwVYpefyA4wPI8mP+iwEkFuKXf7gFgfuBS+eOvrFsQrxrHMeDZXrT4wB3eXjgZZxLhUy1zzrQlf9KxvuCNI+L X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(10201501046)(3231221)(944501244)(52105095)(6041310)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:BN3PR07MB2513; BCL:0; PCL:0; RULEID:; SRVR:BN3PR07MB2513; X-Forefront-PRVS: 0610D16BBE X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(396003)(39860400002)(346002)(39380400002)(189003)(199004)(13464003)(105586002)(50466002)(2950100002)(8676002)(316002)(55016002)(3846002)(72206003)(6666003)(2906002)(478600001)(81156014)(81166006)(9686003)(6916009)(53936002)(6246003)(16586007)(42882007)(229853002)(97736004)(58126008)(6116002)(5660300001)(5009440100003)(68736007)(66066001)(23726003)(47776003)(33896004)(33716001)(16526019)(33656002)(7736002)(6496006)(25786009)(8936002)(26005)(76176011)(1076002)(305945005)(186003)(52116002)(4326008)(106356001)(386003)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR07MB2513; H:jerin; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR07MB2513; 23:2Joe67V2icdUSDt60FKxbqUKD4AnQsaZdBYBVP/Nt?= =?us-ascii?Q?L3aH9aHzqbCcqh7VhsKLuM/0RUO5zhDTJ271PE9Ak/LCq5QPk9UbzZXRdeii?= =?us-ascii?Q?XlwvLddoaoQ+hCsu59SEro9f+ZiT0UuMZAkuM4wXPjhguMRVcDhbZ3gZNBHU?= =?us-ascii?Q?6rWMuXHaXj7H98jHcr7V48h0fseACgW5bAQkI+YEoxmQHT/uPsZ0bbq9yDeN?= =?us-ascii?Q?1Atzt4NqedwABmP9KpYkHukzzF0d07WJnfPeqlEAQiD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XOG3D6x776s/L84bxUqgEtGDofwU9JdYVhcfOJdbLZA=; 7:IxhvuT559utjJ0nmWanpZWKWs88nAoYE0UtaTBp19iGHv8biVhT1571OaGCPHEEZMI7FzCRgnu1Fvgp683Oi5259oaEGN3sQT5VDYuaFD+QUd7N22hVeLBcLgvBWgaposllCjjWS8tYFX3+XgExZzum2PW95UH2rSRxN531NR6LGlnYJvmtymZKshSukMK0D0IsspSxj3Znsy60JZcIDdbzsMCt0yXFxMm4Ndgnvg91O6Q9a5UOplrDWE8sP3P9x SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2018 13:39:58.2325 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86ee2832-c724-48e2-377e-08d588e7ea40 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR07MB2513 Subject: Re: [dpdk-dev] [PATCH v1 3/5] bpf: introduce basic RX/TX BPF filters X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Mar 2018 13:40:02 -0000 -----Original Message----- > Date: Fri, 9 Mar 2018 16:42:03 +0000 > From: Konstantin Ananyev > To: dev@dpdk.org > CC: Konstantin Ananyev > Subject: [dpdk-dev] [PATCH v1 3/5] bpf: introduce basic RX/TX BPF filters > X-Mailer: git-send-email 1.7.0.7 > > Introduce API to install BPF based filters on ethdev RX/TX path. > Current implementation is pure SW one, based on ethdev RX/TX > callback mechanism. > > Signed-off-by: Konstantin Ananyev > --- > lib/librte_bpf/Makefile | 2 + > lib/librte_bpf/bpf_pkt.c | 524 +++++++++++++++++++++++++++++++++++++ > lib/librte_bpf/rte_bpf_ethdev.h | 50 ++++ > lib/librte_bpf/rte_bpf_version.map | 4 + > 4 files changed, 580 insertions(+) > create mode 100644 lib/librte_bpf/bpf_pkt.c > create mode 100644 lib/librte_bpf/rte_bpf_ethdev.h > > diff --git a/lib/librte_bpf/Makefile b/lib/librte_bpf/Makefile > + > +/* > + * information about all installed BPF rx/tx callbacks > + */ > + > +struct bpf_eth_cbi { > + uint32_t use; /*usage counter */ > + void *cb; /* callback handle */ > + struct rte_bpf *bpf; > + struct rte_bpf_jit jit; > +} __rte_cache_aligned; > + > +/* > + * Odd number means that callback is used by datapath. > + * Even number means that callback is not used by datapath. > + */ > +#define BPF_ETH_CBI_INUSE 1 > + > +static struct bpf_eth_cbi rx_cbi[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT]; > +static struct bpf_eth_cbi tx_cbi[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT]; How about allocating this memory from huge page? > + > +/* > + * Marks given callback as used by datapath. > + */ > +static __rte_always_inline void > +bpf_eth_cbi_inuse(struct bpf_eth_cbi *cbi) > +{ > + cbi->use++; > + /* make sure no store/load reordering could happen */ > + rte_smp_mb(); This is an full barrier on non x86. How about a light version of this logic? See below. > +} > + > +/* > + * Marks given callback list as not used by datapath. > + */ > +static __rte_always_inline void > +bpf_eth_cbi_unuse(struct bpf_eth_cbi *cbi) > +{ > + /* make sure all previous loads are completed */ > + rte_smp_rmb(); > + cbi->use++; > +} > + > +/* > + * Waits till datapath finished using given callback. > + */ > +static void > +bpf_eth_cbi_wait(const struct bpf_eth_cbi *cbi) > +{ > + uint32_t nuse, puse; > + > + /* make sure all previous loads and stores are completed */ > + rte_smp_mb(); > + Read conjunction with below change #if 0 > + puse = cbi->use; > + > + /* in use, busy wait till current RX/TX iteration is finished */ > + if ((puse & BPF_ETH_CBI_INUSE) != 0) { > + do { > + rte_pause(); > + rte_compiler_barrier(); > + nuse = cbi->use; > + } while (nuse == puse); > + } #else cbi->cb = NULL; while (likely(cb->done != 1)) { rte_pause(); rte_smb_rmb(); } or any other logic using flag to wait until callback completes. #endif > +} > + > + > +/* > + * RX/TX callbacks for raw data bpf. > + */ > + > +static uint16_t > +bpf_rx_callback_vm(__rte_unused uint16_t port, __rte_unused uint16_t queue, > + struct rte_mbuf *pkt[], uint16_t nb_pkts, > + __rte_unused uint16_t max_pkts, void *user_param) > +{ > + struct bpf_eth_cbi *cbi; > + uint16_t rc; > + > + cbi = user_param; > + Read conjunction with above change #if 0 > + bpf_eth_cbi_inuse(cbi); > + rc = (cbi->cb != NULL) ? > + pkt_filter_vm(cbi->bpf, pkt, nb_pkts, 1) : > + nb_pkts; > + bpf_eth_cbi_unuse(cbi); #else if (likely(cbi->cb != NULL)) return pkt_filter_vm(cbi->bpf, pkt, nb_pkts, 1) : else { cbi->done = 1; rte_smb_wmb(); return nb_pkts; } #endif > + return rc; > +} > +