bogdanPricope replied on github web page: platform/linux-generic/pktio/dpdk.c @@ -426,6 +430,96 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, return (i > 0 ? i : -1); } +static inline int packet_parse(void *l3_hdr, uint8_t *l3_proto_v4, + uint8_t *l4_proto) +{ + uint8_t l3_proto_ver = _ODP_IPV4HDR_VER(*(uint8_t *)l3_hdr); + + if (l3_proto_ver == _ODP_IPV4) { + struct ipv4_hdr *ip = (struct ipv4_hdr *)l3_hdr; + + *l3_proto_v4 = 1; + if (!rte_ipv4_frag_pkt_is_fragmented(ip)) + *l4_proto = ip->next_proto_id; + else + *l4_proto = 0; + + return 0; + } else if (l3_proto_ver == _ODP_IPV6) { + struct ipv6_hdr *ipv6 = (struct ipv6_hdr *)l3_hdr; + + *l3_proto_v4 = 0; + *l4_proto = ipv6->proto; + return 0; + } + + return -1; +} + +static inline uint16_t phdr_csum(int ipv4, void *l3_hdr, + uint64_t ol_flags) +{ + if (ipv4) + return rte_ipv4_phdr_cksum(l3_hdr, ol_flags); + else /*ipv6*/ + return rte_ipv6_phdr_cksum(l3_hdr, ol_flags); +} + +static inline int pkt_set_ol_tx(odp_pktout_config_opt_t *pktout_cfg, + odp_packet_hdr_t *pkt_hdr, + struct rte_mbuf *mbuf, + char *mbuf_data) +{ + void *l3_hdr, *l4_hdr; + uint8_t l3_proto_v4, l4_proto; + odp_bool_t ipv4_chksum_pkt, udp_chksum_pkt, tcp_chksum_pkt; + packet_parser_t *pkt_p = &pkt_hdr->p; + + l3_hdr = (void *)(mbuf_data + pkt_p->l3_offset);
Comment: /** * Packet output configuration options bit field * * Packet output configuration options listed in a bit field structure. Packet * output checksum insertion may be enabled or disabled. When it is enabled, * implementation will calculate and insert checksum into every outgoing packet * by default. Application may use a packet metadata flag to disable checksum * insertion per packet bases. For correct operation, packet metadata must * provide valid offsets for the appropriate protocols. For example, UDP * checksum calculation needs both L3 and L4 offsets (to access IP and UDP * headers). When application (e.g. a switch) does not modify L3/L4 data and * thus checksum does not need to be updated, output checksum insertion should * be disabled for optimal performance. */ Petri's comment from May 10th: "API already says that outgoing packet must have (L3/L4) offsets set correctly if (e.g. L4) checksum calculation is offloaded." Also, is not possible to determine if l3 and l4 offsets are incorrect (wrong values). https://github.com/Linaro/odp/pull/124#discussion_r136789915 updated_at 2017-09-04 10:16:23