[PATCH] -> [API-NEXT PATCH]
> -----Original Message----- > From: lng-odp [mailto:[email protected]] On Behalf Of EXT > Balasubramanian Manoharan > Sent: Tuesday, November 17, 2015 9:06 AM > To: [email protected] > Subject: [lng-odp] [PATCH] api: packet: add detailed packet error api > > Adds api to get packet error flags for L2, L3 and L4 errors. > > Signed-off-by: Balasubramanian Manoharan <[email protected]> > --- > include/odp/api/packet_flags.h | 33 > +++++++++++++++++++++++++++++++ > platform/linux-generic/odp_packet_flags.c | 32 > ++++++++++++++++++++++++++++++ > 2 files changed, 65 insertions(+) > > diff --git a/include/odp/api/packet_flags.h > b/include/odp/api/packet_flags.h > index 7c3b247..c4a6832 100644 > --- a/include/odp/api/packet_flags.h > +++ b/include/odp/api/packet_flags.h > @@ -38,6 +38,17 @@ extern "C" { > int odp_packet_has_error(odp_packet_t pkt); > > /** > + * check for packet L2 error Check for packet L2 errors ^ ^ Plural is important since it checks for *all* L2 errors. Later we can specify the errors and may have specific error flags. > + * > + * checks for all L2 errors > + * > + * @param pkt Packet handle > + * @retval non-zero packet has L2 errors > + * @retval 0 packet has no L2 error > + */ > +int odp_packet_has_l2_error(odp_packet_t pkt); > + > +/** > * Check for L2 header, e.g. ethernet > * > * @param pkt Packet handle > @@ -47,6 +58,17 @@ int odp_packet_has_error(odp_packet_t pkt); > int odp_packet_has_l2(odp_packet_t pkt); > > /** > + * check for packet L3 error Capital C and "errors" > + * > + * checks for all L3 errors > + * > + * @param pkt Packet handle > + * @retval non-zero packet has L3 errors > + * @retval 0 packet has no L3 error > + */ > +int odp_packet_has_l3_error(odp_packet_t pkt); > + > +/** > * Check for L3 header, e.g. IPv4, IPv6 > * > * @param pkt Packet handle > @@ -56,6 +78,17 @@ int odp_packet_has_l2(odp_packet_t pkt); > int odp_packet_has_l3(odp_packet_t pkt); > > /** > + * check for packet L4 error Capital C and "errors" > + * > + * checks for all L4 errors > + * > + * @param pkt Packet handle > + * @retval non-zero packet has L4 errors > + * @retval 0 packet has no L2 error ... has no L4 ... > + */ > +int odp_packet_has_l4_error(odp_packet_t pkt); > + > +/** > * Check for L4 header, e.g. UDP, TCP, SCTP (also ICMP) > * > * @param pkt Packet handle > diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux- > generic/odp_packet_flags.c > index dbc3137..68a79bc 100644 > --- a/platform/linux-generic/odp_packet_flags.c > +++ b/platform/linux-generic/odp_packet_flags.c > @@ -38,16 +38,48 @@ int odp_packet_has_l2(odp_packet_t pkt) > return pkt_hdr->input_flags.l2; > } > > +int odp_packet_has_l2_error(odp_packet_t pkt) > +{ > + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); > + > + if (packet_parse_not_complete(pkt_hdr)) > + packet_parse_full(pkt_hdr); L2 errors should not need additional parsing. Always, fill in (or clear) these flags by default in packet input. This is a performance optimization that I did earlier: L2 is filled in by default, upper layers launch full SW parse. -Petri > + > + return pkt_hdr->error_flags.frame_len > + | pkt_hdr->error_flags.snap_len > + | pkt_hdr->error_flags.l2_chksum; > +} > + > int odp_packet_has_l3(odp_packet_t pkt) > { > retflag(pkt, input_flags.l3); > } > > +int odp_packet_has_l3_error(odp_packet_t pkt) > +{ > + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); > + > + if (packet_parse_not_complete(pkt_hdr)) > + packet_parse_full(pkt_hdr); > + > + return pkt_hdr->error_flags.ip_err; > +} > + > int odp_packet_has_l4(odp_packet_t pkt) > { > retflag(pkt, input_flags.l4); > } > > +int odp_packet_has_l4_error(odp_packet_t pkt) > +{ > + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); > + > + if (packet_parse_not_complete(pkt_hdr)) > + packet_parse_full(pkt_hdr); > + > + return pkt_hdr->error_flags.tcp_err | pkt_hdr->error_flags.udp_err; > +} > + > int odp_packet_has_eth(odp_packet_t pkt) > { > odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); > -- > 1.9.1 > > _______________________________________________ > lng-odp mailing list > [email protected] > https://lists.linaro.org/mailman/listinfo/lng-odp _______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
