DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/vhost: get csum offload capabilities of vhost backend
@ 2022-02-17 15:16 Wenwu Ma
  2022-03-15  2:56 ` Hu, Jiayu
  2022-05-05 14:15 ` Maxime Coquelin
  0 siblings, 2 replies; 3+ messages in thread
From: Wenwu Ma @ 2022-02-17 15:16 UTC (permalink / raw)
  To: maxime.coquelin, chenbo.xia
  Cc: dev, jiayu.hu, yinan.wang, xingguang.he, Wenwu Ma

The current vhost backend lacks csum offloads information,
which will cause testpmd command such as "csum set tcp hw
<port_id>" to fail. This patch adds the information according
to the device features.

Signed-off-by: Wenwu Ma <wenwux.ma@intel.com>
---
 drivers/net/vhost/rte_eth_vhost.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 070f0e6dfd..7593d5a9ae 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -1281,6 +1281,24 @@ eth_dev_info(struct rte_eth_dev *dev,
 				RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
 	dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
+	if (internal->vid != -1) {
+		uint64_t features = 0;
+		if (rte_vhost_get_negotiated_features(internal->vid, &features) != 0)
+			return 0;
+
+		if (features & (1ULL << VIRTIO_NET_F_CSUM)) {
+			dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
+						RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
+						RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
+		}
+
+		if (features & (1ULL << VIRTIO_NET_F_GUEST_CSUM)) {
+			dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
+						RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
+						RTE_ETH_RX_OFFLOAD_IPV4_CKSUM;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-05 14:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17 15:16 [PATCH] net/vhost: get csum offload capabilities of vhost backend Wenwu Ma
2022-03-15  2:56 ` Hu, Jiayu
2022-05-05 14:15 ` Maxime Coquelin

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).