From patchwork Thu Jan 7 16:25:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 59297 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp16476lbb; Thu, 7 Jan 2016 08:27:44 -0800 (PST) X-Received: by 10.140.218.72 with SMTP id o69mr10703527qhb.22.1452184063892; Thu, 07 Jan 2016 08:27:43 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v140si47385105qka.56.2016.01.07.08.27.43; Thu, 07 Jan 2016 08:27:43 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 46E08616F3; Thu, 7 Jan 2016 16:27:43 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=RJuJVxrT; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,T_DKIM_INVALID,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1DBA16197B; Thu, 7 Jan 2016 16:26:26 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id ADB1B616F3; Thu, 7 Jan 2016 16:26:20 +0000 (UTC) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by lists.linaro.org (Postfix) with ESMTPS id 569F06197B for ; Thu, 7 Jan 2016 16:26:09 +0000 (UTC) Received: by mail-pa0-f44.google.com with SMTP id ho8so1511223pac.2 for ; Thu, 07 Jan 2016 08:26:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=JnIx6DPlijkyo76BndeP8P60yv3/p6pRQa8rl2CUKSY=; b=RJuJVxrT4MGxsz/izIUZLvZtOCu/Rb2ye+Rtso1RczznqwvhrePfJYOzQceFDL1fHS yeqRWHeZLOvC/LA+t455WWA9oAMaYMNlCgsEfQh4LH+TYTtkPtCrqfXzRC102mb5tKti uTumTANvko+f4Fm8IVTFNlvaaJIYG7H6EGtFI= 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=JnIx6DPlijkyo76BndeP8P60yv3/p6pRQa8rl2CUKSY=; b=DJMuGchJMWzT4oOW5FBBiYdwXTxY8vvvHJdgRLGVFjh13Ymc2McgdfiddGNxHmEzKg MjKhYD1F0800wLl2Fbb57rdemhbXITKXt2q7QLrDK2NE+FzxyO0YSDLD9JEkmP8ighx3 ejUwGC5YCv20+1peDlHpFWKatDyi9epD3qr+bxRRC5kAvWaVKtLT4KwmS8CAWT4oVl0e AKCdNy7r3ocGNB36XrknqmRJu7jZhhKoQn4NG0p74ZwKXOxJbdIiezf3wwu5IGyVMR5U nhE++RH8jDOtrnUGbC7SgCLd51a1P+i9V/0eEVAPCbfmqk4N7FOH3fpbXgW5Ou6hY3ZU Bmug== X-Gm-Message-State: ALoCoQl15w93/r9F40y+WU6wqALMedkss8yjkQmNrXr8vxDHCkbn9a9WjHnzZQ6QmekGIzCJn4Xpr0weneg5gCVpy7lYAJ/MTQ== X-Received: by 10.66.255.70 with SMTP id ao6mr92206169pad.64.1452183968655; Thu, 07 Jan 2016 08:26:08 -0800 (PST) Received: from localhost.localdomain ([122.166.219.57]) by smtp.gmail.com with ESMTPSA id d8sm82955093pas.14.2016.01.07.08.26.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jan 2016 08:26:08 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 7 Jan 2016 21:55:53 +0530 Message-Id: <1452183954-30413-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: Classification patch Subject: [lng-odp] [API-NEXT PATCH 1/2] linux-generic: classification: implement verify_pmr_dmac X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Implements Ethernet destination mac address verification Signed-off-by: Balasubramanian Manoharan --- .../include/odp_classification_inlines.h | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index e9739aa..a4c05d3 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -153,11 +153,28 @@ static inline int verify_pmr_udp_sport(const uint8_t *pkt_addr, return 0; } -static inline int verify_pmr_dmac(const uint8_t *pkt_addr ODP_UNUSED, - odp_packet_hdr_t *pkt_hdr ODP_UNUSED, - pmr_term_value_t *term_value ODP_UNUSED) +static inline int verify_pmr_dmac(const uint8_t *pkt_addr, + odp_packet_hdr_t *pkt_hdr, + pmr_term_value_t *term_value) { - ODP_UNIMPLEMENTED(); + uint64_t dmac = 0; + uint64_t dmac_be = 0; + const odph_ethhdr_t *eth; + + if (!pkt_hdr->input_flags.eth) + return 0; + + eth = (const odph_ethhdr_t *)(pkt_addr + pkt_hdr->l2_offset); + memcpy(&dmac_be, eth->dst.addr, ODPH_ETHADDR_LEN); + dmac = odp_be_to_cpu_64(dmac_be); + /* since we are converting a 48 bit ethernet address from BE to cpu + format using odp_be_to_cpu_64() the last 16 bits needs to be right + shifted */ + if (dmac_be != dmac) + dmac = dmac >> (64 - (ODPH_ETHADDR_LEN * 8)); + + if (term_value->val == (dmac & term_value->mask)) + return 1; return 0; }