examples/ip_fragmentation: fix check of packet type
PATCH v2 1/1 examples/ip_fragmentation: fix check of packet type
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.
--- examples/ip_fragmentation/main.c | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+)
examples/ip_fragmentation/main.c +74 -0
@@ -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 )
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): 49759EB36A64CF4892C1AFEC9231E8D64E50CCDD@PGSMSX101.gar.corp.intel.com
PATCH v2 1/1 examples/ip_fragmentation: fix check of packet type
-----Original Message-----
From: Dai, Wei
Sent: Wednesday, March 15, 2017 9:39 AM
To: Wei, FangfangX <[email protected]>
Subject: FW: [PATCH v2] examples/ip_fragmentation: fix check of packet type
Quoted 12 lines
-----Original Message-----
From: Dai, Wei
Sent: Tuesday, March 14, 2017 10:48 PM
To: [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Dai, Wei <[email protected]>; [email protected]
Subject: [PATCH v2] examples/ip_fragmentation: fix check of packet typeThe
packet_typein mbuf is not correctly filled by ixgbe 82599 NIC. To use theether_typein ethernet header to check packet type is more reliaber.
Quoted 8 lines
Fixes 3c0184cc0c60 ("examples: replace some offload flags with packettype")
Fixes ab351fe1c95c ("mbuf: remove packet type from offload flags")Reported-by Fangfang Wei <[email protected]>Signed-off-by Wei Dai <[email protected]>
Quoted 99 lines
--- examples/ip_fragmentation/main.c | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+)examples/ip_fragmentation/main.c +68
-0@@ -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 bySW :"
examples/ip_fragmentation/main.c +2
-1+ " port = %d\n", portid); + } }if (init_routing_table () <0 ) --2.7.4
Quoted 13 lines
-----Original Message-----
From: Dai, Wei
Sent: Tuesday, March 14, 2017 2:48 PM
To: [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Dai, Wei <[email protected]>; [email protected]
Subject: [PATCH v2] examples/ip_fragmentation: fix check of packet typeThe
packet_typein mbuf is not correctly filled by ixgbe 82599 NIC. To use theether_typein ethernet header to check packet type is more reliaber.
Quoted 8 lines
Fixes 3c0184cc0c60 ("examples: replace some offload flags with packet type")Fixes ab351fe1c95c ("mbuf: remove packet type from offload flags")Reported-by Fangfang Wei <[email protected]>Signed-off-by Wei Dai <[email protected]>---
Thomas Monjalon
Applied2017-03-15 12:23, Ananyev, Konstantin:
Quoted 15 lines
Quoted 15 lines
-----Original Message-----
From: Dai, Wei
Sent: Tuesday, March 14, 2017 2:48 PM
To: [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Dai, Wei <[email protected]>; [email protected]
Subject: [PATCH v2] examples/ip_fragmentation: fix check of packet typeThe
packet_typein mbuf is not correctly filled by ixgbe 82599 NIC. To use theether_typein 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")
Quoted 7 lines
Quoted 5 lines
Reported-by Fangfang Wei <[email protected]>Signed-off-by Wei Dai <[email protected]>---
Applied, thanks