From: Stephen Hemminger <stephen@networkplumber.org>
To: Sun Yuechi <sunyuechi@iscas.ac.cn>
Cc: dev@dpdk.org, Zijian <zijian.oerv@isrc.iscas.ac.cn>,
"Stanisław Kardach" <stanislaw.kardach@gmail.com>,
"Nithin Dabilpuram" <ndabilpuram@marvell.com>,
"Pavan Nikhilesh" <pbhagavatula@marvell.com>
Subject: Re: [PATCH v2] node: lookup with RISC-V vector extension
Date: Sun, 1 Feb 2026 11:04:05 -0800 [thread overview]
Message-ID: <20260201110405.0768a904@phoenix.local> (raw)
In-Reply-To: <20260201160931.1896432-1-sunyuechi@iscas.ac.cn>
On Mon, 2 Feb 2026 00:09:31 +0800
Sun Yuechi <sunyuechi@iscas.ac.cn> wrote:
> +static uint16_t
> +ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node,
> + void **objs, uint16_t nb_objs)
> +{
> + struct rte_mbuf **pkts;
> + struct rte_lpm *lpm = IP4_LOOKUP_NODE_LPM(node->ctx);
> + const int dyn = IP4_LOOKUP_NODE_PRIV1_OFF(node->ctx);
> + rte_edge_t next_index;
> + void **to_next, **from;
> + uint16_t last_spec = 0;
> + uint16_t n_left_from;
> + uint16_t held = 0;
> + uint32_t drop_nh;
> +
> + /* Temporary arrays for batch processing */
> + uint32_t ips[RVV_MAX_BURST];
> + uint32_t res[RVV_MAX_BURST];
> + rte_edge_t next_hops[RVV_MAX_BURST];
> +
> + /* Speculative next */
> + next_index = RTE_NODE_IP4_LOOKUP_NEXT_REWRITE;
> + /* Drop node */
> + drop_nh = ((uint32_t)RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP) << 16;
> +
> + pkts = (struct rte_mbuf **)objs;
> + from = objs;
> + n_left_from = nb_objs;
> +
> + /* Get stream for the speculated next node */
> + to_next = rte_node_next_stream_get(graph, node, next_index, nb_objs);
> +
> + while (n_left_from > 0) {
> + rte_edge_t fix_spec = 0;
> +
> + size_t vl = __riscv_vsetvl_e32m8(RTE_MIN(n_left_from, RVV_MAX_BURST));
> +
> + /* Extract IP addresses and metadata from current batch */
> + for (size_t i = 0; i < vl; i++) {
> + struct rte_ipv4_hdr *ipv4_hdr =
> + rte_pktmbuf_mtod_offset(pkts[i], struct rte_ipv4_hdr *,
> + sizeof(struct rte_ether_hdr));
> + ips[i] = ipv4_hdr->dst_addr;
> + node_mbuf_priv1(pkts[i], dyn)->cksum = ipv4_hdr->hdr_checksum;
> + node_mbuf_priv1(pkts[i], dyn)->ttl = ipv4_hdr->time_to_live;
> + }
> +
> + /* Perform LPM lookup */
> + rte_lpm_lookup_vec(lpm, ips, res, vl, drop_nh);
> +
> + for (size_t i = 0; i < vl; i++) {
> + /* Update statistics */
> + if ((res[i] >> 16) == (drop_nh >> 16))
> + NODE_INCREMENT_XSTAT_ID(node, 0, 1, 1);
> +
> + /* Extract next hop and next node */
> + node_mbuf_priv1(pkts[i], dyn)->nh = res[i] & 0xFFFF;
> + next_hops[i] = res[i] >> 16;
> +
> + /* Check speculation */
> + fix_spec |= (next_index ^ next_hops[i]);
> + }
> +
> + if (unlikely(fix_spec)) {
> + /* Copy successfully speculated packets before this batch */
> + rte_memcpy(to_next, from, last_spec * sizeof(from[0]));
Please use memcpy for this small copy
> + from += last_spec;
> + to_next += last_spec;
> + held += last_spec;
> + last_spec = 0;
> +
> + /* Process each packet in current batch individually */
> + for (size_t i = 0; i < vl; i++) {
> + if (next_index == next_hops[i]) {
> + *to_next++ = from[i];
> + held++;
> + } else {
> + rte_node_enqueue_x1(graph, node, next_hops[i], from[i]);
> + }
> + }
> +
> + from += vl;
> + } else {
> + last_spec += vl;
> + }
> +
> + pkts += vl;
> + n_left_from -= vl;
> + }
> +
> + /* Handle successfully speculated packets */
> + if (likely(last_spec == nb_objs)) {
> + rte_node_next_stream_move(graph, node, next_index);
> + return nb_objs;
> + }
> +
> + held += last_spec;
> + rte_memcpy(to_next, from, last_spec * sizeof(from[0]));
Since compiler doesn't bounds check rte_memcpy() use memcpy here please
prev parent reply other threads:[~2026-02-01 19:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-01 16:09 [PATCH v2] node: lookup with RISC-V vector extension Sun Yuechi
2026-02-01 16:10 ` sunyuechi
2026-02-01 19:04 ` Stephen Hemminger [this message]
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=20260201110405.0768a904@phoenix.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=ndabilpuram@marvell.com \
--cc=pbhagavatula@marvell.com \
--cc=stanislaw.kardach@gmail.com \
--cc=sunyuechi@iscas.ac.cn \
--cc=zijian.oerv@isrc.iscas.ac.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.