From f0b00d983e384137eb3388f9b92b1406de832d69 Mon Sep 17 00:00:00 2001 From: Miao Li Date: Mon, 25 Oct 2021 14:47:25 +0000 Subject: [PATCH] examples/l3fwd-power: support virtio/vhost In l3fwd-power, there is default port configuration which requires RSS and IPv4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error. This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost. Signed-off-by: Miao Li Reviewed-by: Chenbo Xia Acked-by: David Hunt --- examples/l3fwd-power/main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 21c79567b1..6988a0ed34 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -505,7 +505,15 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len) return -1; /* 2. The IP checksum must be correct. */ - /* this is checked in H/W */ + /* if this is not checked in H/W, check it. */ + if ((port_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) == 0) { + uint16_t actual_cksum, expected_cksum; + actual_cksum = pkt->hdr_checksum; + pkt->hdr_checksum = 0; + expected_cksum = rte_ipv4_cksum(pkt); + if (actual_cksum != expected_cksum) + return -2; + } /* * 3. The IP version number must be 4. If the version number is not 4 @@ -2652,6 +2660,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } + if (local_port_conf.rx_adv_conf.rss_conf.rss_hf == 0) + local_port_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_NONE; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret = rte_eth_dev_configure(portid, nb_rx_queue, (uint16_t)n_tx_queue, &local_port_conf); if (ret < 0)