From patchwork Fri Apr 10 10:26:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 47024 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AB588218D9 for ; Fri, 10 Apr 2015 10:28:17 +0000 (UTC) Received: by lbbrr5 with SMTP id rr5sf3080739lbb.3 for ; Fri, 10 Apr 2015 03:28:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=vAKec7XTJeFBjHGiPwKnxUgY/ZzelGfRRhcUInARcPU=; b=ND5OdRAZylW4/IiRWVMm8NCMqhysPvgxxUOihGXpEvapK0gKYHHp37nM2x9zIhZjH3 kRIjp/LT2pLceMwoNglaM8ehoTVGFbwk/IZ921xT9WHOSXlAoQntggf/8wW7qe0gGYu7 EjkHvDVXZPzAOBCxNjpiBxM+1wUJMhK902d+5JUoodELJrFIJ53weBUAMEFY6kRjk+aL gxCRSoXbkDVXhBF6PJNE0AtJMKpR+wE/pGexbDWOyg39OznjOrZdU7lffDeYfl/lZqqA kyZUs8Qvdm5RAO0/sQfmqz7qKYxkLl+2+QIB7TB6h78xCbCCM6BnTxCskIcPHYsg21yN l54g== X-Gm-Message-State: ALoCoQnYjHQxa3FlnOMYTJNB8+l6mwN/MnKqm/bn6Ini5szj2JkmazPSGNyQQ2NTUnY3DA1KWvGq X-Received: by 10.194.221.65 with SMTP id qc1mr185168wjc.7.1428661696262; Fri, 10 Apr 2015 03:28:16 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.171 with SMTP id az11ls441992lab.107.gmail; Fri, 10 Apr 2015 03:28:15 -0700 (PDT) X-Received: by 10.112.139.1 with SMTP id qu1mr834195lbb.8.1428661695897; Fri, 10 Apr 2015 03:28:15 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id w5si1144096lbb.37.2015.04.10.03.28.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Apr 2015 03:28:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by layy10 with SMTP id y10so9986041lay.0 for ; Fri, 10 Apr 2015 03:28:15 -0700 (PDT) X-Received: by 10.112.163.168 with SMTP id yj8mr401633lbb.36.1428661695455; Fri, 10 Apr 2015 03:28:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp999145lbt; Fri, 10 Apr 2015 03:28:14 -0700 (PDT) X-Received: by 10.140.144.139 with SMTP id 133mr846856qhq.1.1428661693983; Fri, 10 Apr 2015 03:28:13 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j207si1395793qhc.13.2015.04.10.03.28.13; Fri, 10 Apr 2015 03:28:13 -0700 (PDT) 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; Received: by lists.linaro.org (Postfix, from userid 109) id 41D67650A5; Fri, 10 Apr 2015 10:28:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id E2227650B6; Fri, 10 Apr 2015 10:27:39 +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 243D764E66; Fri, 10 Apr 2015 10:27:34 +0000 (UTC) Received: from mail-qk0-f171.google.com (mail-qk0-f171.google.com [209.85.220.171]) by lists.linaro.org (Postfix) with ESMTPS id 74AD264E66 for ; Fri, 10 Apr 2015 10:26:53 +0000 (UTC) Received: by qku63 with SMTP id 63so24024630qku.3 for ; Fri, 10 Apr 2015 03:26:53 -0700 (PDT) X-Received: by 10.140.106.227 with SMTP id e90mr747375qgf.63.1428661613287; Fri, 10 Apr 2015 03:26:53 -0700 (PDT) Received: from localhost.localdomain ([111.93.218.67]) by mx.google.com with ESMTPSA id 75sm1259769qhw.41.2015.04.10.03.26.51 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Apr 2015 03:26:52 -0700 (PDT) From: bala.manoharan@linaro.org To: lng-odp@lists.linaro.org Date: Fri, 10 Apr 2015 15:56:31 +0530 Message-Id: <1428661592-18311-2-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 2.0.1.472.g6f92e5f In-Reply-To: <1428661592-18311-1-git-send-email-bala.manoharan@linaro.org> References: <1428661592-18311-1-git-send-email-bala.manoharan@linaro.org> X-Topics: Classification patch Subject: [lng-odp] [API-NEXT PATCHv1 2/3] linux-generic: classification: remove odp_pmr_create_range() function implementation. X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bala.manoharan@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Balasubramanian Manoharan This patch removes the implementation of odp_pmr_create_range() function. Signed-off-by: Balasubramanian Manoharan --- .../include/odp_classification_datamodel.h | 15 +--- .../include/odp_classification_inlines.h | 88 ++++++---------------- platform/linux-generic/odp_classification.c | 83 +++++--------------- 3 files changed, 46 insertions(+), 140 deletions(-) diff --git a/platform/linux-generic/include/odp_classification_datamodel.h b/platform/linux-generic/include/odp_classification_datamodel.h index 6f9e1b8..9da54c7 100644 --- a/platform/linux-generic/include/odp_classification_datamodel.h +++ b/platform/linux-generic/include/odp_classification_datamodel.h @@ -54,18 +54,9 @@ Stores the Term and Value mapping for a PMR. The maximum size of value currently supported in 64 bits **/ typedef struct pmr_term_value { - odp_pmr_match_type_e match_type; /**< Packet Match Type*/ - odp_pmr_term_e term; /* PMR Term */ - union { - struct { - uint64_t val; - uint64_t mask; - } mask; /**< Match a masked set of bits */ - struct { - uint64_t val1; - uint64_t val2; - } range; /**< Match an integer range */ - }; + odp_pmr_term_e term; /* PMR Term */ + uint64_t val; /**< Value to be matched */ + uint64_t mask; /**< Masked set of bits to be matched */ } pmr_term_value_t; /* diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index bf76556..8d1e1c1 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -32,15 +32,10 @@ These following functions return 1 on success and 0 on failure static inline int verify_pmr_packet_len(odp_packet_hdr_t *pkt_hdr, pmr_term_value_t *term_value) { - if (term_value->match_type == ODP_PMR_MASK) { - if (term_value->mask.val == (pkt_hdr->frame_len & - term_value->mask.mask)) - return 1; - } else { - if ((term_value->range.val1 <= pkt_hdr->frame_len) && - (pkt_hdr->frame_len <= term_value->range.val2)) - return 1; - } + if (term_value->val == (pkt_hdr->frame_len & + term_value->mask)) + return 1; + return 0; } static inline int verify_pmr_ip_proto(uint8_t *pkt_addr, @@ -53,14 +48,9 @@ static inline int verify_pmr_ip_proto(uint8_t *pkt_addr, return 0; ip = (odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset); proto = ip->proto; - if (term_value->match_type == ODP_PMR_MASK) { - if (term_value->mask.val == (proto & term_value->mask.mask)) - return 1; - } else { - if ((term_value->range.val1 <= proto) && - (proto <= term_value->range.val2)) - return 1; - } + if (term_value->val == (proto & term_value->mask)) + return 1; + return 0; } @@ -74,14 +64,9 @@ static inline int verify_pmr_ipv4_saddr(uint8_t *pkt_addr, return 0; ip = (odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset); ipaddr = odp_be_to_cpu_32(ip->src_addr); - if (term_value->match_type == ODP_PMR_MASK) { - if (term_value->mask.val == (ipaddr & term_value->mask.mask)) - return 1; - } else { - if ((term_value->range.val1 <= ipaddr) && - (ipaddr <= term_value->range.val2)) - return 1; - } + if (term_value->val == (ipaddr & term_value->mask)) + return 1; + return 0; } @@ -95,14 +80,9 @@ static inline int verify_pmr_ipv4_daddr(uint8_t *pkt_addr, return 0; ip = (odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset); ipaddr = odp_be_to_cpu_32(ip->dst_addr); - if (term_value->match_type == ODP_PMR_MASK) { - if (term_value->mask.val == (ipaddr & term_value->mask.mask)) - return 1; - } else { - if ((term_value->range.val1 <= ipaddr) && - (ipaddr <= term_value->range.val2)) - return 1; - } + if (term_value->val == (ipaddr & term_value->mask)) + return 1; + return 0; } @@ -116,14 +96,9 @@ static inline int verify_pmr_tcp_sport(uint8_t *pkt_addr, return 0; tcp = (odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset); sport = odp_be_to_cpu_16(tcp->src_port); - if (term_value->match_type == ODP_PMR_MASK) { - if (term_value->mask.val == (sport & term_value->mask.mask)) - return 1; - } else { - if ((term_value->range.val1 <= sport) && - (sport <= term_value->range.val2)) - return 1; - } + if (term_value->val == (sport & term_value->mask)) + return 1; + return 0; } @@ -137,14 +112,9 @@ static inline int verify_pmr_tcp_dport(uint8_t *pkt_addr, return 0; tcp = (odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset); dport = odp_be_to_cpu_16(tcp->dst_port); - if (term_value->match_type == ODP_PMR_MASK) { - if (term_value->mask.val == (dport & term_value->mask.mask)) - return 1; - } else { - if ((term_value->range.val1 <= dport) && - (dport <= term_value->range.val2)) - return 1; - } + if (term_value->val == (dport & term_value->mask)) + return 1; + return 0; } @@ -158,14 +128,9 @@ static inline int verify_pmr_udp_dport(uint8_t *pkt_addr, return 0; udp = (odph_udphdr_t *)(pkt_addr + pkt_hdr->l4_offset); dport = odp_be_to_cpu_16(udp->dst_port); - if (term_value->match_type == ODP_PMR_MASK) { - if (term_value->mask.val == (dport & term_value->mask.mask)) + if (term_value->val == (dport & term_value->mask)) return 1; - } else { - if ((term_value->range.val1 <= dport) && - (dport <= term_value->range.val2)) - return 1; - } + return 0; } static inline int verify_pmr_udp_sport(uint8_t *pkt_addr, @@ -178,14 +143,9 @@ static inline int verify_pmr_udp_sport(uint8_t *pkt_addr, return 0; udp = (odph_udphdr_t *)(pkt_addr + pkt_hdr->l4_offset); sport = odp_be_to_cpu_16(udp->src_port); - if (term_value->match_type == ODP_PMR_MASK) { - if (term_value->mask.val == (sport & term_value->mask.mask)) - return 1; - } else { - if ((term_value->range.val1 <= sport) && - (sport <= term_value->range.val2)) - return 1; - } + if (term_value->val == (sport & term_value->mask)) + return 1; + return 0; } diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 609faa9..0e46b1b 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -414,10 +414,8 @@ int odp_cos_with_l3_qos(odp_pktio_t pktio_in, return 0; } -odp_pmr_t odp_pmr_create_match(odp_pmr_term_e term, - const void *val, - const void *mask, - uint32_t val_sz) +odp_pmr_t odp_pmr_create(odp_pmr_term_e term, const void *val, + const void *mask, uint32_t val_sz) { pmr_t *pmr; odp_pmr_t id; @@ -432,41 +430,12 @@ odp_pmr_t odp_pmr_create_match(odp_pmr_term_e term, return ODP_PMR_INVAL; pmr->s.num_pmr = 1; - pmr->s.pmr_term_value[0].match_type = ODP_PMR_MASK; pmr->s.pmr_term_value[0].term = term; - pmr->s.pmr_term_value[0].mask.val = 0; - pmr->s.pmr_term_value[0].mask.mask = 0; - memcpy(&pmr->s.pmr_term_value[0].mask.val, val, val_sz); - memcpy(&pmr->s.pmr_term_value[0].mask.mask, mask, val_sz); - pmr->s.pmr_term_value[0].mask.val &= pmr->s.pmr_term_value[0].mask.mask; - UNLOCK(&pmr->s.lock); - return id; -} - -odp_pmr_t odp_pmr_create_range(odp_pmr_term_e term, - const void *val1, - const void *val2, - uint32_t val_sz) -{ - pmr_t *pmr; - odp_pmr_t id; - - if (val_sz > ODP_PMR_TERM_BYTES_MAX) { - ODP_ERR("val_sz greater than max supported limit"); - return ODP_PMR_INVAL; - } - id = alloc_pmr(&pmr); - /*if alloc_pmr() is successful it returns with lock acquired*/ - if (id == ODP_PMR_INVAL) - return ODP_PMR_INVAL; - - pmr->s.num_pmr = 1; - pmr->s.pmr_term_value[0].match_type = ODP_PMR_RANGE; - pmr->s.pmr_term_value[0].term = term; - pmr->s.pmr_term_value[0].range.val1 = 0; - pmr->s.pmr_term_value[0].range.val2 = 0; - memcpy(&pmr->s.pmr_term_value[0].range.val1, val1, val_sz); - memcpy(&pmr->s.pmr_term_value[0].range.val2, val2, val_sz); + pmr->s.pmr_term_value[0].val = 0; + pmr->s.pmr_term_value[0].mask = 0; + memcpy(&pmr->s.pmr_term_value[0].val, val, val_sz); + memcpy(&pmr->s.pmr_term_value[0].mask, mask, val_sz); + pmr->s.pmr_term_value[0].val &= pmr->s.pmr_term_value[0].mask; UNLOCK(&pmr->s.lock); return id; } @@ -590,32 +559,18 @@ int odp_pmr_match_set_create(int num_terms, odp_pmr_match_t *terms, pmr->s.num_pmr = num_terms; for (i = 0; i < num_terms; i++) { - pmr->s.pmr_term_value[i].match_type = terms[i].match_type; - if (terms[i].match_type == ODP_PMR_MASK) { - val_sz = terms[i].mask.val_sz; - if (val_sz > ODP_PMR_TERM_BYTES_MAX) - continue; - pmr->s.pmr_term_value[i].term = terms[i].mask.term; - pmr->s.pmr_term_value[i].mask.val = 0; - pmr->s.pmr_term_value[i].mask.mask = 0; - memcpy(&pmr->s.pmr_term_value[i].mask.val, - terms[i].mask.val, val_sz); - memcpy(&pmr->s.pmr_term_value[i].mask.mask, - terms[i].mask.mask, val_sz); - pmr->s.pmr_term_value[i].mask.val &= pmr->s - .pmr_term_value[i].mask.mask; - } else { - val_sz = terms[i].range.val_sz; - if (val_sz > ODP_PMR_TERM_BYTES_MAX) - continue; - pmr->s.pmr_term_value[i].term = terms[i].range.term; - pmr->s.pmr_term_value[i].range.val1 = 0; - pmr->s.pmr_term_value[i].range.val2 = 0; - memcpy(&pmr->s.pmr_term_value[i].range.val1, - terms[i].range.val1, val_sz); - memcpy(&pmr->s.pmr_term_value[i].range.val2, - terms[i].range.val2, val_sz); - } + val_sz = terms[i].val_sz; + if (val_sz > ODP_PMR_TERM_BYTES_MAX) + continue; + pmr->s.pmr_term_value[i].term = terms[i].term; + pmr->s.pmr_term_value[i].val = 0; + pmr->s.pmr_term_value[i].mask = 0; + memcpy(&pmr->s.pmr_term_value[i].val, + terms[i].val, val_sz); + memcpy(&pmr->s.pmr_term_value[i].mask, + terms[i].mask, val_sz); + pmr->s.pmr_term_value[i].val &= pmr->s + .pmr_term_value[i].mask; count++; } *pmr_set_id = id;