From patchwork Thu Jan 28 15:05:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 60738 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp532865lbb; Thu, 28 Jan 2016 07:07:20 -0800 (PST) X-Received: by 10.55.77.17 with SMTP id a17mr4106158qkb.40.1453993640774; Thu, 28 Jan 2016 07:07:20 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t37si12536282qgt.88.2016.01.28.07.07.20; Thu, 28 Jan 2016 07:07:20 -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 52469617E5; Thu, 28 Jan 2016 15:07:20 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=hVYjZ6K9; 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 04BE4618E0; Thu, 28 Jan 2016 15:05:40 +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 A8FF26181D; Thu, 28 Jan 2016 15:05:20 +0000 (UTC) Received: from mail-ob0-f172.google.com (mail-ob0-f172.google.com [209.85.214.172]) by lists.linaro.org (Postfix) with ESMTPS id 1F09B617B4 for ; Thu, 28 Jan 2016 15:05:14 +0000 (UTC) Received: by mail-ob0-f172.google.com with SMTP id ba1so37517612obb.3 for ; Thu, 28 Jan 2016 07:05:14 -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:in-reply-to:references; bh=1Dl8NAR+BK4y1Veje3AYN8E7plyzFdiDRlqN54DxT3I=; b=hVYjZ6K9aVUhJHSK7cWQrjffWl8SKLyREgy3urXN28QAcHMTp9V1spOr0kNDApGNWv N4i1e7MRNF1d50vnMeQBYxywA+6Fb9nEt1rE18b2NT7/v/QTCxDIUald6xRLaFpVn7a/ Wo2E9O/DJrcXhfE03HhkSnC5Smy7rZ8RLanIM= 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:in-reply-to :references; bh=1Dl8NAR+BK4y1Veje3AYN8E7plyzFdiDRlqN54DxT3I=; b=KejpGOZL7cvpKgenLly3QeBl209dovLRzQ83PUcpvD/wnQ604Q9jUhxuDMQSxHA9fs plR7va1YQxA1IQRMd5yQd1dDZkynOLo4so5EpCokY9d2yTIP3HRO6Kkp014FP9rYDx4g QjKsaOMsnyRjT7jx47obqLTdRjM41rXoUhy79XzGQqDuvqSiz8+mwEE89rgEgDJY//oa MA/kvz3rk59sGMvjbyg6YqHCD9WHC2Yf9VBgUuntz7XUZEsNQzmrcwaQ0aXBb0OmpuDH 7HTuiPPz7DDbt51hwMhpQa7tAfXJJDjRabMkjSFjBkXfShOfv0w8s8jIey6ZRJOLKbBG Ed/g== X-Gm-Message-State: AG10YORajrbt1m4DOCCDymybse76ibmY693+Mg2VjLHf5vu0hJOtst0L1QEoyEsg3dtLYWlLpgo= X-Received: by 10.60.57.134 with SMTP id i6mr2511142oeq.11.1453993513655; Thu, 28 Jan 2016 07:05:13 -0800 (PST) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id k186sm5632766oif.13.2016.01.28.07.05.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jan 2016 07:05:13 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 28 Jan 2016 09:05:02 -0600 Message-Id: <1453993505-32024-4-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453993505-32024-1-git-send-email-bill.fischofer@linaro.org> References: <1453993505-32024-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv5 3/6] linux-generic: packet: implement parser extensions for broadcast and multicast 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" Signed-off-by: Bill Fischofer --- platform/linux-generic/odp_packet.c | 41 +++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index db85b5e..a14135f 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -784,6 +784,7 @@ static inline uint8_t parse_ipv4(odp_packet_hdr_t *pkt_hdr, uint8_t ver = ODPH_IPV4HDR_VER(ipv4->ver_ihl); uint8_t ihl = ODPH_IPV4HDR_IHL(ipv4->ver_ihl); uint16_t frag_offset; + uint32_t dstaddr = odp_be_to_cpu_32(ipv4->dst_addr); pkt_hdr->l3_len = odp_be_to_cpu_16(ipv4->tot_len); @@ -809,6 +810,10 @@ static inline uint8_t parse_ipv4(odp_packet_hdr_t *pkt_hdr, if (odp_unlikely(ODPH_IPV4HDR_IS_FRAGMENT(frag_offset))) pkt_hdr->input_flags.ipfrag = 1; + /* Handle IPv4 broadcast / multicast */ + pkt_hdr->input_flags.ip_bcast = (dstaddr == 0xffffffff); + pkt_hdr->input_flags.ip_mcast = (dstaddr >> 28) == 0xd; + return ipv4->proto; } @@ -820,6 +825,7 @@ static inline uint8_t parse_ipv6(odp_packet_hdr_t *pkt_hdr, { const odph_ipv6hdr_t *ipv6 = (const odph_ipv6hdr_t *)*parseptr; const odph_ipv6hdr_ext_t *ipv6ext; + uint32_t dstaddr0 = odp_be_to_cpu_32(ipv6->dst_addr[0]); pkt_hdr->l3_len = odp_be_to_cpu_16(ipv6->payload_len); @@ -830,11 +836,14 @@ static inline uint8_t parse_ipv6(odp_packet_hdr_t *pkt_hdr, return 0; } + /* IPv6 broadcast / multicast flags */ + pkt_hdr->input_flags.ip_mcast = (dstaddr0 & 0xff000000) == 0xff000000; + pkt_hdr->input_flags.ip_bcast = 0; + /* Skip past IPv6 header */ *offset += sizeof(odph_ipv6hdr_t); *parseptr += sizeof(odph_ipv6hdr_t); - /* Skip past any IPv6 extension headers */ if (ipv6->next_hdr == ODPH_IPPROTO_HOPOPTS || ipv6->next_hdr == ODPH_IPPROTO_ROUTE) { @@ -850,7 +859,8 @@ static inline uint8_t parse_ipv6(odp_packet_hdr_t *pkt_hdr, ipv6ext->next_hdr == ODPH_IPPROTO_ROUTE) && *offset < pkt_hdr->frame_len); - if (*offset >= pkt_hdr->l3_offset + odp_be_to_cpu_16(ipv6->payload_len)) { + if (*offset >= pkt_hdr->l3_offset + + odp_be_to_cpu_16(ipv6->payload_len)) { pkt_hdr->error_flags.ip_err = 1; return 0; } @@ -938,23 +948,32 @@ int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr) uint32_t offset, seglen; uint8_t ip_proto = 0; const uint8_t *parseptr; + uint16_t macaddr0, macaddr2, macaddr4; offset = sizeof(odph_ethhdr_t); if (packet_parse_l2_not_done(pkt_hdr)) packet_parse_l2(pkt_hdr); - if (ptr == NULL) { - eth = (odph_ethhdr_t *)packet_map(pkt_hdr, 0, &seglen); - parseptr = (const uint8_t *)ð->type; - ethtype = odp_be_to_cpu_16(*((const uint16_t *) - (const void *)parseptr)); + eth = ptr ? (const odph_ethhdr_t *)ptr : + (odph_ethhdr_t *)packet_map(pkt_hdr, 0, &seglen); + + /* Handle Ethernet broadcast/multicast addresses */ + macaddr0 = odp_be_to_cpu_16(*((const uint16_t *)(const void *)eth)); + pkt_hdr->input_flags.eth_mcast = (macaddr0 & 0x0100) == 0x0100; + + if (macaddr0 == 0xffff) { + macaddr2 = odp_be_to_cpu_16(*((const uint16_t *)eth + 1)); + macaddr4 = odp_be_to_cpu_16(*((const uint16_t *)eth + 2)); + pkt_hdr->input_flags.eth_bcast = + (macaddr2 == 0xffff) && (macaddr4 == 0xffff); } else { - eth = (const odph_ethhdr_t *)ptr; - parseptr = (const uint8_t *)ð->type; - ethtype = odp_be_to_cpu_16(*((const uint16_t *) - (const void *)parseptr)); + pkt_hdr->input_flags.eth_bcast = 0; } + /* Get Ethertype */ + parseptr = (const uint8_t *)ð->type; + ethtype = odp_be_to_cpu_16(*((const uint16_t *) + (const void *)parseptr)); /* Parse the VLAN header(s), if present */ if (ethtype == ODPH_ETHTYPE_VLAN_OUTER) {