From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 8036F37B2 for ; Fri, 7 Apr 2017 10:14:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491552890; x=1523088890; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=TfAB+vmOzeI0f+FQT8b9IvUU2w7D8K5scBJVl3FjSmo=; b=Rvqtzh3UNzfLAlQZGjtVtm9mXvSebiXMOZKjm6PMvO/BWyAfTZU+upu4 DnPEwA2v/fS9ScrZkcCBRZ9bS+HsRw==; Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Apr 2017 01:14:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,164,1488873600"; d="scan'208";a="953273282" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by orsmga003.jf.intel.com with ESMTP; 07 Apr 2017 01:14:48 -0700 From: Yuanhan Liu To: Wei Dai Cc: Yuanhan Liu , Fangfang Wei , Konstantin Ananyev , dpdk stable Date: Fri, 7 Apr 2017 16:11:24 +0800 Message-Id: <1491552724-3034-7-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1491552724-3034-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1491552724-3034-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-stable] patch 'examples/ip_fragmentation: fix check of packet type' has been queued to LTS release 16.11.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Apr 2017 08:14:51 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 04/11/17. So please shout if anyone has objections. Thanks. --yliu --- >>From af67067d280646db649e8ede585d404075081d20 Mon Sep 17 00:00:00 2001 From: Wei Dai Date: Tue, 14 Mar 2017 22:47:49 +0800 Subject: [PATCH] examples/ip_fragmentation: fix check of packet type [ upstream commit 201d52bc0df70fd5dde9a79b5b6cd70a21f6fd34 ] The packet_type in mbuf is not correctly filled by ixgbe 82599 NIC. To use the ether_type in ethernet header to check packet type is more reliaber. Fixes: 3c0184cc0c60 ("examples: replace some offload flags with packet type") Fixes: ab351fe1c95c ("mbuf: remove packet type from offload flags") Reported-by: Fangfang Wei Signed-off-by: Wei Dai Tested-by: Fangfang Wei Acked-by: Konstantin Ananyev --- examples/ip_fragmentation/main.c | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c index e1e32c6..349a72c 100644 --- a/examples/ip_fragmentation/main.c +++ b/examples/ip_fragmentation/main.c @@ -653,6 +653,74 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) } } +/* Check L3 packet type detection capablity of the NIC port */ +static int +check_ptype(int portid) +{ + int i, ret; + int ptype_l3_ipv4 = 0, ptype_l3_ipv6 = 0; + uint32_t ptype_mask = RTE_PTYPE_L3_MASK; + + ret = rte_eth_dev_get_supported_ptypes(portid, ptype_mask, NULL, 0); + if (ret <= 0) + return 0; + + uint32_t ptypes[ret]; + + ret = rte_eth_dev_get_supported_ptypes(portid, ptype_mask, ptypes, ret); + for (i = 0; i < ret; ++i) { + if (ptypes[i] & RTE_PTYPE_L3_IPV4) + ptype_l3_ipv4 = 1; + if (ptypes[i] & RTE_PTYPE_L3_IPV6) + ptype_l3_ipv6 = 1; + } + + if (ptype_l3_ipv4 == 0) + printf("port %d cannot parse RTE_PTYPE_L3_IPV4\n", portid); + + if (ptype_l3_ipv6 == 0) + printf("port %d cannot parse RTE_PTYPE_L3_IPV6\n", portid); + + if (ptype_l3_ipv4 && ptype_l3_ipv6) + return 1; + + return 0; + +} + +/* Parse packet type of a packet by SW */ +static inline void +parse_ptype(struct rte_mbuf *m) +{ + struct ether_hdr *eth_hdr; + uint32_t packet_type = RTE_PTYPE_UNKNOWN; + uint16_t ether_type; + + eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); + ether_type = eth_hdr->ether_type; + if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv4)) + packet_type |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; + else if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv6)) + packet_type |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; + + m->packet_type = packet_type; +} + +/* callback function to detect packet type for a queue of a port */ +static uint16_t +cb_parse_ptype(uint8_t port __rte_unused, uint16_t queue __rte_unused, + struct rte_mbuf *pkts[], uint16_t nb_pkts, + uint16_t max_pkts __rte_unused, + void *user_param __rte_unused) +{ + uint16_t i; + + for (i = 0; i < nb_pkts; ++i) + parse_ptype(pkts[i]); + + return nb_pkts; +} + static int init_routing_table(void) { @@ -944,6 +1012,12 @@ main(int argc, char **argv) ret, portid); rte_eth_promiscuous_enable(portid); + + if (check_ptype(portid) == 0) { + rte_eth_add_rx_callback(portid, 0, cb_parse_ptype, NULL); + printf("Add Rx callback funciton to detect L3 packet type by SW :" + " port = %d\n", portid); + } } if (init_routing_table() < 0) -- 1.9.0