From: Andrew Boyer <andrew.boyer@amd.com>
To: <dev@dpdk.org>
Cc: Andrew Boyer <andrew.boyer@amd.com>
Subject: [PATCH 23/35] net/ionic: add a lookup table for packet type
Date: Fri, 7 Oct 2022 10:43:24 -0700 [thread overview]
Message-ID: <20221007174336.54354-24-andrew.boyer@amd.com> (raw)
In-Reply-To: <20221007174336.54354-1-andrew.boyer@amd.com>
This improves performance by reducing branching.
Signed-off-by: Andrew Boyer <andrew.boyer@amd.com>
---
drivers/net/ionic/ionic_rxtx.c | 63 ++++++++++++++++------------------
1 file changed, 29 insertions(+), 34 deletions(-)
diff --git a/drivers/net/ionic/ionic_rxtx.c b/drivers/net/ionic/ionic_rxtx.c
index 5ee6573a50..bb09c4eb1f 100644
--- a/drivers/net/ionic/ionic_rxtx.c
+++ b/drivers/net/ionic/ionic_rxtx.c
@@ -804,6 +804,22 @@ ionic_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
return 0;
}
+/* RTE_PTYPE_UNKNOWN is 0x0 */
+static const uint32_t ionic_ptype_table[IONIC_RXQ_COMP_PKT_TYPE_MASK]
+ __rte_cache_aligned = {
+ [IONIC_PKT_TYPE_NON_IP] = RTE_PTYPE_UNKNOWN,
+ [IONIC_PKT_TYPE_IPV4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4,
+ [IONIC_PKT_TYPE_IPV4_TCP] =
+ RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP,
+ [IONIC_PKT_TYPE_IPV4_UDP] =
+ RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
+ [IONIC_PKT_TYPE_IPV6] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6,
+ [IONIC_PKT_TYPE_IPV6_TCP] =
+ RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP,
+ [IONIC_PKT_TYPE_IPV6_UDP] =
+ RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
+};
+
/*
* Cleans one descriptor. Connects the filled mbufs into a chain.
* Does not advance the tail index.
@@ -820,6 +836,7 @@ ionic_rx_clean_one(struct ionic_rx_qcq *rxq,
uint32_t pkt_type;
uint32_t left, i;
uint16_t cq_desc_len;
+ uint8_t ptype;
void **info;
cq_desc_len = rte_le_to_cpu_16(cq_desc->len);
@@ -895,41 +912,19 @@ ionic_rx_clean_one(struct ionic_rx_qcq *rxq,
rxm->ol_flags = pkt_flags;
/* Packet Type */
- switch (cq_desc->pkt_type_color & IONIC_RXQ_COMP_PKT_TYPE_MASK) {
- case IONIC_PKT_TYPE_IPV4:
- pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4;
- break;
- case IONIC_PKT_TYPE_IPV6:
- pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6;
- break;
- case IONIC_PKT_TYPE_IPV4_TCP:
- pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 |
- RTE_PTYPE_L4_TCP;
- break;
- case IONIC_PKT_TYPE_IPV6_TCP:
- pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 |
- RTE_PTYPE_L4_TCP;
- break;
- case IONIC_PKT_TYPE_IPV4_UDP:
- pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 |
- RTE_PTYPE_L4_UDP;
- break;
- case IONIC_PKT_TYPE_IPV6_UDP:
- pkt_type = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 |
- RTE_PTYPE_L4_UDP;
- break;
- default:
- {
- struct rte_ether_hdr *eth_h = rte_pktmbuf_mtod(rxm,
+ ptype = cq_desc->pkt_type_color & IONIC_RXQ_COMP_PKT_TYPE_MASK;
+ pkt_type = ionic_ptype_table[ptype];
+ if (pkt_type == RTE_PTYPE_UNKNOWN) {
+ struct rte_ether_hdr *eth_h = rte_pktmbuf_mtod(rxm,
struct rte_ether_hdr *);
- uint16_t ether_type = eth_h->ether_type;
- if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP))
- pkt_type = RTE_PTYPE_L2_ETHER_ARP;
- else
- pkt_type = RTE_PTYPE_UNKNOWN;
- stats->mtods++;
- break;
- }
+ uint16_t ether_type = eth_h->ether_type;
+ if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP))
+ pkt_type = RTE_PTYPE_L2_ETHER_ARP;
+ else if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_LLDP))
+ pkt_type = RTE_PTYPE_L2_ETHER_LLDP;
+ else if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_1588))
+ pkt_type = RTE_PTYPE_L2_ETHER_TIMESYNC;
+ stats->mtods++;
}
rxm->packet_type = pkt_type;
--
2.17.1
next prev parent reply other threads:[~2022-10-07 17:46 UTC|newest]
Thread overview: 113+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-07 17:43 [PATCH 00/35] net/ionic: updates for 22.11 release Andrew Boyer
2022-10-07 17:43 ` [PATCH 01/35] net/ionic: fix up endianness for Rx and Tx handling Andrew Boyer
2022-10-07 17:43 ` [PATCH 02/35] net/ionic: fix up endianness for RSS Andrew Boyer
2022-10-07 17:43 ` [PATCH 03/35] net/ionic: fix to set the adapter name for logging Andrew Boyer
2022-10-07 17:43 ` [PATCH 04/35] net/ionic: fix up the Rx filter save API Andrew Boyer
2022-10-07 17:43 ` [PATCH 05/35] net/ionic: fix up reported error stats Andrew Boyer
2022-10-07 17:43 ` [PATCH 06/35] net/ionic: update documentation and copyrights Andrew Boyer
2022-10-18 17:02 ` Ferruh Yigit
2022-10-07 17:43 ` [PATCH 07/35] net/ionic: update license terms to remove GPL Andrew Boyer
2022-10-18 17:02 ` Ferruh Yigit
2022-10-07 17:43 ` [PATCH 08/35] net/ionic: update MTU calculations Andrew Boyer
2022-10-07 17:43 ` [PATCH 09/35] net/ionic: simplify code by removing doorbell map helper Andrew Boyer
2022-10-07 17:43 ` [PATCH 10/35] net/ionic: remove unused identifiers Andrew Boyer
2022-10-07 17:43 ` [PATCH 11/35] net/ionic: only allocate interrupts if required Andrew Boyer
2022-10-07 17:43 ` [PATCH 12/35] net/ionic: move PCI-specific code to a separate file Andrew Boyer
2022-10-07 17:43 ` [PATCH 13/35] net/ionic: only request notifyq interrupt if supported Andrew Boyer
2022-10-07 17:43 ` [PATCH 14/35] net/ionic: replace void pointer with actual type Andrew Boyer
2022-10-07 17:43 ` [PATCH 15/35] net/ionic: free all buffers during Rx queue stop Andrew Boyer
2022-10-07 17:43 ` [PATCH 16/35] net/ionic: precalculate segment lengths on receive side Andrew Boyer
2022-10-07 17:43 ` [PATCH 17/35] net/ionic: use a helper variable in packet Tx function Andrew Boyer
2022-10-07 17:43 ` [PATCH 18/35] net/ionic: do one-time init of receive descriptors Andrew Boyer
2022-10-07 17:43 ` [PATCH 19/35] net/ionic: overhaul receive side for performance Andrew Boyer
2022-10-07 17:43 ` [PATCH 20/35] net/ionic: overhaul transmit " Andrew Boyer
2022-10-07 17:43 ` [PATCH 21/35] net/ionic: add support for mbuf fast free Andrew Boyer
2022-10-07 17:43 ` [PATCH 22/35] net/ionic: do bulk allocations of receive mbufs Andrew Boyer
2022-10-07 17:43 ` Andrew Boyer [this message]
2022-10-07 17:43 ` [PATCH 24/35] net/ionic: add a lookup table for checksum flags Andrew Boyer
2022-10-07 17:43 ` [PATCH 25/35] net/ionic: advertise supported packet types Andrew Boyer
2022-10-07 17:43 ` [PATCH 26/35] net/ionic: add Rx descriptor status functions Andrew Boyer
2022-10-07 17:43 ` [PATCH 27/35] net/ionic: add Tx descriptor status function Andrew Boyer
2022-10-07 17:43 ` [PATCH 28/35] net/ionic: add Q-in-CMB option controlled by devarg Andrew Boyer
2022-10-07 17:43 ` [PATCH 29/35] net/ionic: update array allocations to use calloc Andrew Boyer
2022-10-07 17:43 ` [PATCH 30/35] net/ionic: add alignment and socket info in allocations Andrew Boyer
2022-10-07 17:43 ` [PATCH 31/35] net/ionic: allow client to specify Tx free threshold Andrew Boyer
2022-10-07 17:43 ` [PATCH 32/35] net/ionic: add optimized handlers for non-scattered Rx/Tx Andrew Boyer
2022-10-07 17:43 ` [PATCH 33/35] net/ionic: use a helper variable for page size Andrew Boyer
2022-10-07 17:43 ` [PATCH 34/35] net/ionic: retry init commands up to five times Andrew Boyer
2022-10-07 17:43 ` [PATCH 35/35] net/ionic: add watchdogs to protect each queue type Andrew Boyer
2022-10-11 0:49 ` [PATCH v1 00/35] net/ionic: updates for 22.11 release Andrew Boyer
2022-10-18 17:05 ` Ferruh Yigit
2022-10-18 19:40 ` [PATCH v2 00/36] " Andrew Boyer
2022-10-18 21:56 ` Ferruh Yigit
2022-10-18 19:40 ` [PATCH v2 01/36] net/ionic: fix up endianness for Rx and Tx handling Andrew Boyer
2022-10-18 19:40 ` [PATCH v2 02/36] net/ionic: fix up endianness for RSS Andrew Boyer
2022-10-18 19:40 ` [PATCH v2 03/36] net/ionic: fix to set the adapter name for logging Andrew Boyer
2022-10-18 19:40 ` [PATCH v2 04/36] net/ionic: fix up the Rx filter save API Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 05/36] net/ionic: fix up reported error stats Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 06/36] net/ionic: update documentation and copyrights Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 07/36] net/ionic: update supported devices list Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 08/36] net/ionic: update license terms to remove GPL Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 09/36] net/ionic: update MTU calculations Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 10/36] net/ionic: simplify code by removing doorbell map helper Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 11/36] net/ionic: remove unused identifiers Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 12/36] net/ionic: only allocate interrupts if required Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 13/36] net/ionic: move PCI-specific code to a separate file Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 14/36] net/ionic: only request notifyq interrupt if supported Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 15/36] net/ionic: replace void pointer with actual type Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 16/36] net/ionic: free all buffers during Rx queue stop Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 17/36] net/ionic: precalculate segment lengths on receive side Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 18/36] net/ionic: use a helper variable in packet Tx function Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 19/36] net/ionic: do one-time init of receive descriptors Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 20/36] net/ionic: overhaul receive side for performance Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 21/36] net/ionic: overhaul transmit " Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 22/36] net/ionic: add support for mbuf fast free Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 23/36] net/ionic: do bulk allocations of receive mbufs Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 24/36] net/ionic: add a lookup table for packet type Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 25/36] net/ionic: add a lookup table for checksum flags Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 26/36] net/ionic: advertise supported packet types Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 27/36] net/ionic: add Rx descriptor status functions Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 28/36] net/ionic: add Tx descriptor status function Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 29/36] net/ionic: add Q-in-CMB option controlled by devarg Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 30/36] net/ionic: update array allocations to use calloc Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 31/36] net/ionic: add alignment and socket info in allocations Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 32/36] net/ionic: allow client to specify Tx free threshold Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 33/36] net/ionic: add optimized handlers for non-scattered Rx/Tx Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 34/36] net/ionic: use a helper variable for page size Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 35/36] net/ionic: retry init commands up to five times Andrew Boyer
2022-10-18 19:41 ` [PATCH v2 36/36] net/ionic: add watchdogs to protect each queue type Andrew Boyer
2022-10-11 0:49 ` [PATCH v1 01/35] net/ionic: fix up endianness for Rx and Tx handling Andrew Boyer
2022-10-11 0:49 ` [PATCH v1 02/35] net/ionic: fix up endianness for RSS Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 03/35] net/ionic: fix to set the adapter name for logging Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 04/35] net/ionic: fix up the Rx filter save API Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 05/35] net/ionic: fix up reported error stats Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 06/35] net/ionic: update documentation and copyrights Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 07/35] net/ionic: update license terms to remove GPL Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 08/35] net/ionic: update MTU calculations Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 09/35] net/ionic: simplify code by removing doorbell map helper Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 10/35] net/ionic: remove unused identifiers Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 11/35] net/ionic: only allocate interrupts if required Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 12/35] net/ionic: move PCI-specific code to a separate file Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 13/35] net/ionic: only request notifyq interrupt if supported Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 14/35] net/ionic: replace void pointer with actual type Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 15/35] net/ionic: free all buffers during Rx queue stop Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 16/35] net/ionic: precalculate segment lengths on receive side Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 17/35] net/ionic: use a helper variable in packet Tx function Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 18/35] net/ionic: do one-time init of receive descriptors Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 19/35] net/ionic: overhaul receive side for performance Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 20/35] net/ionic: overhaul transmit " Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 21/35] net/ionic: add support for mbuf fast free Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 22/35] net/ionic: do bulk allocations of receive mbufs Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 23/35] net/ionic: add a lookup table for packet type Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 24/35] net/ionic: add a lookup table for checksum flags Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 25/35] net/ionic: advertise supported packet types Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 26/35] net/ionic: add Rx descriptor status functions Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 27/35] net/ionic: add Tx descriptor status function Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 28/35] net/ionic: add Q-in-CMB option controlled by devarg Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 29/35] net/ionic: update array allocations to use calloc Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 30/35] net/ionic: add alignment and socket info in allocations Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 31/35] net/ionic: allow client to specify Tx free threshold Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 32/35] net/ionic: add optimized handlers for non-scattered Rx/Tx Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 33/35] net/ionic: use a helper variable for page size Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 34/35] net/ionic: retry init commands up to five times Andrew Boyer
2022-10-11 0:50 ` [PATCH v1 35/35] net/ionic: add watchdogs to protect each queue type Andrew Boyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221007174336.54354-24-andrew.boyer@amd.com \
--to=andrew.boyer@amd.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).