From patchwork Wed Jan 27 01:18:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 60553 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2303952lbb; Tue, 26 Jan 2016 17:20:14 -0800 (PST) X-Received: by 10.55.82.214 with SMTP id g205mr32147135qkb.72.1453857613946; Tue, 26 Jan 2016 17:20:13 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d70si453274qhd.60.2016.01.26.17.20.12; Tue, 26 Jan 2016 17:20:13 -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 B2102617EB; Wed, 27 Jan 2016 01:20:12 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=hizlSu4v; 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_H3, RCVD_IN_MSPIKE_WL, 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 47B5F617EF; Wed, 27 Jan 2016 01:18:48 +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 79C6D617D7; Wed, 27 Jan 2016 01:18:26 +0000 (UTC) Received: from mail-ob0-f179.google.com (mail-ob0-f179.google.com [209.85.214.179]) by lists.linaro.org (Postfix) with ESMTPS id 8AFD5617CC for ; Wed, 27 Jan 2016 01:18:24 +0000 (UTC) Received: by mail-ob0-f179.google.com with SMTP id vt7so156622950obb.1 for ; Tue, 26 Jan 2016 17:18:24 -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=saoNj3I3hJ1CzCnUme9RBlaCUl39GQO4+hAYFn2vDFs=; b=hizlSu4vKqjzPYBgH8fVSO9C1sbHlToEuB4kZiQEG0g9mLHOsvaIeqopPGXH57QDGL /BmAglA90Zczp53cvTLVrv9j2WrmjtdXHUmJjSCGV0qLB+iBCsAYYrBtrXrXQhnI7e+I HBLjjuB1v4Cc/oFZZaBhcFIgXzkx0oR80m6CI= 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=saoNj3I3hJ1CzCnUme9RBlaCUl39GQO4+hAYFn2vDFs=; b=PtKGzgNwMtCaVdn4JfKa5lnm5mKNsRNXRumi9aLweiB+Fp9HG9/H9NEHPMs9/pIH41 RB65G0IPz2O9WOK62M6tLHS6sOFZy2uxj+ZwoKPMCS1VdfQpvtew01Gn9BnwQclIv8lE p5DXoXA/q/y9q1JlEsPaASbM4ho198e6+pAlok5TbtYSlXRtwMiZb13mr+NEbV/KkWat 1PtYYvzKS0l4DUMkgznF0WT4qrvQ5p5as1imYfLIIWFjWfzqYLaeKjnw/BTlhLCeEKYt Y/kGB4V5aDjicVps58MbttaudL8MZUfoQ2f3tQRecs7aeElKubqiE58JMalFv8wxJ4oA NTDA== X-Gm-Message-State: AG10YOTzQMUdxwn/qOXGEQX3/mVxEhecV8lMbKLDQQYm5w72ykJG6yTpJwDy6bFI+7g1lVTV9ak= X-Received: by 10.60.73.170 with SMTP id m10mr21006486oev.51.1453857504081; Tue, 26 Jan 2016 17:18:24 -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 e4sm1886973oic.1.2016.01.26.17.18.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Jan 2016 17:18:23 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 26 Jan 2016 19:18:13 -0600 Message-Id: <1453857496-12895-3-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453857496-12895-1-git-send-email-bill.fischofer@linaro.org> References: <1453857496-12895-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 2/5] 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, 28 insertions(+), 13 deletions(-) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index db85b5e..fea149a 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 & 0xff) == 0xff; + 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,18 @@ 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 = + dstaddr0 == 0xff010000 && + ipv6->dst_addr[1] == 0 && + ipv6->dst_addr[2] == 0 && + odp_be_to_cpu_32(ipv6->dst_addr[3]) == 1; + /* 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 +863,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 +952,24 @@ 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; 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)); - } else { - eth = (const odph_ethhdr_t *)ptr; - 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; + pkt_hdr->input_flags.eth_bcast = (macaddr0 == 0xffff); + /* 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) {