From 56349dc9f389b4b9ed75d5e2212c35089625da8f Mon Sep 17 00:00:00 2001 From: Andrew Rybchenko Date: Thu, 15 Dec 2016 12:51:05 +0000 Subject: [PATCH] net/sfc: handle received packet type info from HW Signed-off-by: Andrew Rybchenko Reviewed-by: Andrew Lee Reviewed-by: Robert Stonehouse --- doc/guides/nics/features/sfc_efx.ini | 1 + doc/guides/nics/sfc_efx.rst | 2 ++ drivers/net/sfc/sfc_ethdev.c | 19 +++++++++++++++++++ drivers/net/sfc/sfc_rx.c | 14 +++++++++++++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/sfc_efx.ini b/doc/guides/nics/features/sfc_efx.ini index ec1d1db2d1..b5887d5a24 100644 --- a/doc/guides/nics/features/sfc_efx.ini +++ b/doc/guides/nics/features/sfc_efx.ini @@ -15,6 +15,7 @@ Multicast MAC filter = Y Flow control = Y L3 checksum offload = Y L4 checksum offload = Y +Packet type parsing = Y Basic stats = Y Extended stats = Y BSD nic_uio = Y diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 8724eae83d..1333f8b1f5 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -67,6 +67,8 @@ SFC EFX PMD has support for: - IPv4/IPv6 TCP/UDP receive checksum offload +- Received packet type information + Non-supported Features ---------------------- diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 4e49180b9b..469df34da3 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -96,6 +96,24 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->tx_desc_lim.nb_align = EFX_TXQ_MINNDESCS; } +static const uint32_t * +sfc_dev_supported_ptypes_get(struct rte_eth_dev *dev) +{ + static const uint32_t ptypes[] = { + RTE_PTYPE_L2_ETHER, + RTE_PTYPE_L3_IPV4_EXT_UNKNOWN, + RTE_PTYPE_L3_IPV6_EXT_UNKNOWN, + RTE_PTYPE_L4_TCP, + RTE_PTYPE_L4_UDP, + RTE_PTYPE_UNKNOWN + }; + + if (dev->rx_pkt_burst == sfc_recv_pkts) + return ptypes; + + return NULL; +} + static int sfc_dev_configure(struct rte_eth_dev *dev) { @@ -818,6 +836,7 @@ static const struct eth_dev_ops sfc_eth_dev_ops = { .xstats_get = sfc_xstats_get, .xstats_get_names = sfc_xstats_get_names, .dev_infos_get = sfc_dev_infos_get, + .dev_supported_ptypes_get = sfc_dev_supported_ptypes_get, .mtu_set = sfc_dev_set_mtu, .rx_queue_setup = sfc_rx_queue_setup, .rx_queue_release = sfc_rx_queue_release, diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index 4df41329fc..be8fa23903 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -169,6 +169,18 @@ sfc_rx_desc_flags_to_offload_flags(const unsigned int desc_flags) return mbuf_flags; } +static uint32_t +sfc_rx_desc_flags_to_packet_type(const unsigned int desc_flags) +{ + return RTE_PTYPE_L2_ETHER | + ((desc_flags & EFX_PKT_IPV4) ? + RTE_PTYPE_L3_IPV4_EXT_UNKNOWN : 0) | + ((desc_flags & EFX_PKT_IPV6) ? + RTE_PTYPE_L3_IPV6_EXT_UNKNOWN : 0) | + ((desc_flags & EFX_PKT_TCP) ? RTE_PTYPE_L4_TCP : 0) | + ((desc_flags & EFX_PKT_UDP) ? RTE_PTYPE_L4_UDP : 0); +} + uint16_t sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) { @@ -222,7 +234,7 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rte_pktmbuf_pkt_len(m) = seg_len; m->ol_flags = sfc_rx_desc_flags_to_offload_flags(desc_flags); - m->packet_type = RTE_PTYPE_L2_ETHER; + m->packet_type = sfc_rx_desc_flags_to_packet_type(desc_flags); *rx_pkts++ = m; done_pkts++; -- 2.20.1