From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2505A04FA; Sun, 2 Feb 2020 17:04:30 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AEB121C014; Sun, 2 Feb 2020 17:04:12 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 8C9B91C013 for ; Sun, 2 Feb 2020 17:04:11 +0100 (CET) Received: from Internal Mail-Server by MTLPINE2 (envelope-from asafp@mellanox.com) with ESMTPS (AES256-SHA encrypted); 2 Feb 2020 18:04:10 +0200 Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 012G3uj1032300; Sun, 2 Feb 2020 18:04:10 +0200 From: Matan Azrad To: dev@dpdk.org, Viacheslav Ovsiienko Cc: Maxime Coquelin Date: Sun, 2 Feb 2020 16:03:43 +0000 Message-Id: <1580659433-25581-4-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1580659433-25581-1-git-send-email-matan@mellanox.com> References: <1580292549-27439-1-git-send-email-matan@mellanox.com> <1580659433-25581-1-git-send-email-matan@mellanox.com> Subject: [dpdk-dev] [PATCH v3 03/13] vdpa/mlx5: support features get operations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add support for get_features and get_protocol_features operations. Part of the features are reported by the DevX capabilities. Signed-off-by: Matan Azrad Acked-by: Viacheslav Ovsiienko Reviewed-by: Maxime Coquelin --- doc/guides/vdpadevs/features/mlx5.ini | 7 ++++ drivers/vdpa/mlx5/mlx5_vdpa.c | 66 +++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/doc/guides/vdpadevs/features/mlx5.ini b/doc/guides/vdpadevs/features/mlx5.ini index d635bdf..fea491d 100644 --- a/doc/guides/vdpadevs/features/mlx5.ini +++ b/doc/guides/vdpadevs/features/mlx5.ini @@ -4,6 +4,13 @@ ; Refer to default.ini for the full list of available driver features. ; [Features] + +any layout = Y +guest announce = Y +mq = Y +proto mq = Y +proto log shmfd = Y +proto host notifier = Y Other kdrv = Y ARMv8 = Y Power8 = Y diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 5246fd2..00d3a19 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright 2019 Mellanox Technologies, Ltd */ +#include + #include #include #include @@ -16,6 +18,7 @@ #include #include #include +#include #include "mlx5_vdpa_utils.h" @@ -28,6 +31,27 @@ struct mlx5_vdpa_priv { struct mlx5_hca_vdpa_attr caps; }; +#ifndef VIRTIO_F_ORDER_PLATFORM +#define VIRTIO_F_ORDER_PLATFORM 36 +#endif + +#ifndef VIRTIO_F_RING_PACKED +#define VIRTIO_F_RING_PACKED 34 +#endif + +#define MLX5_VDPA_DEFAULT_FEATURES ((1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \ + (1ULL << VIRTIO_F_ANY_LAYOUT) | \ + (1ULL << VIRTIO_NET_F_MQ) | \ + (1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE) | \ + (1ULL << VIRTIO_F_ORDER_PLATFORM)) + +#define MLX5_VDPA_PROTOCOL_FEATURES \ + ((1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \ + (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) | \ + (1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) | \ + (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \ + (1ULL << VHOST_USER_PROTOCOL_F_MQ)) + TAILQ_HEAD(mlx5_vdpa_privs, mlx5_vdpa_priv) priv_list = TAILQ_HEAD_INITIALIZER(priv_list); static pthread_mutex_t priv_list_lock = PTHREAD_MUTEX_INITIALIZER; @@ -68,10 +92,48 @@ struct mlx5_vdpa_priv { return 0; } +static int +mlx5_vdpa_get_vdpa_features(int did, uint64_t *features) +{ + struct mlx5_vdpa_priv *priv = mlx5_vdpa_find_priv_resource_by_did(did); + + if (priv == NULL) { + DRV_LOG(ERR, "Invalid device id: %d.", did); + return -1; + } + *features = MLX5_VDPA_DEFAULT_FEATURES; + if (priv->caps.virtio_queue_type & (1 << MLX5_VIRTQ_TYPE_PACKED)) + *features |= (1ULL << VIRTIO_F_RING_PACKED); + if (priv->caps.tso_ipv4) + *features |= (1ULL << VIRTIO_NET_F_HOST_TSO4); + if (priv->caps.tso_ipv6) + *features |= (1ULL << VIRTIO_NET_F_HOST_TSO6); + if (priv->caps.tx_csum) + *features |= (1ULL << VIRTIO_NET_F_CSUM); + if (priv->caps.rx_csum) + *features |= (1ULL << VIRTIO_NET_F_GUEST_CSUM); + if (priv->caps.virtio_version_1_0) + *features |= (1ULL << VIRTIO_F_VERSION_1); + return 0; +} + +static int +mlx5_vdpa_get_protocol_features(int did, uint64_t *features) +{ + struct mlx5_vdpa_priv *priv = mlx5_vdpa_find_priv_resource_by_did(did); + + if (priv == NULL) { + DRV_LOG(ERR, "Invalid device id: %d.", did); + return -1; + } + *features = MLX5_VDPA_PROTOCOL_FEATURES; + return 0; +} + static struct rte_vdpa_dev_ops mlx5_vdpa_ops = { .get_queue_num = mlx5_vdpa_get_queue_num, - .get_features = NULL, - .get_protocol_features = NULL, + .get_features = mlx5_vdpa_get_vdpa_features, + .get_protocol_features = mlx5_vdpa_get_protocol_features, .dev_conf = NULL, .dev_close = NULL, .set_vring_state = NULL, -- 1.8.3.1