From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DB14FA0547; Fri, 29 Oct 2021 16:48:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D7D4C426EC; Fri, 29 Oct 2021 16:48:37 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2076.outbound.protection.outlook.com [40.107.237.76]) by mails.dpdk.org (Postfix) with ESMTP id 1D504426DE for ; Fri, 29 Oct 2021 16:48:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cu6Vo1sSOasm88aQN7t1ZuvEIPMbkjfzMCZx/SoMu/wBi0XSGS95oXXSv+jk7o/3rPyDNHXa/TwLjwercPUUG463l/k0aoao9wlq3r42YGBL7uT5SMHmD+ytaJs4EedSZAtuHGMixjkqiRa/5EoMhaNJBZCaiTvnqvXhO7RsR/6N0ZW5NIhkNYOR/0+zY+1z6jDGcA6JJOkXBBgbtj6qyupBHRuuV+2A3S3LCXpDXZT5nklhJDhXi6Cl7IzSJ6FK9TGWDOp5TFTMbDjuzgQdzMITvpTXGEbDFwd405tv1pa/po3wmWQbCFbu0g1M/NNGx220/RFz5GS9iFweiVxdrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OtGk3zGLxR6dKwsJ6nDOQeb77Ss3fPHg2Y0NMPRIhq4=; b=YRdjtHXvwoJX5jnZo9KL8IR8ZVpsoSg0hIKYh8Fg+zp+p4m2gS3LCI5Rx1P6km+sGscgx+dHlnhbGoHx7aay1wdzXpBBdNcs3VsXyBHeEsSO0RS4n+PhWlwA4x51gsLWCY8BrsJMQED7YHyZL6V7UWnl1jYHFnHKnEOh3DBgBLjslFR9inDUzF1uYfibUPGv810yc3mD3ogEsILj8FmJ9QhI+QqVwFVXKCmSYhCbivp0xtYDe9/L0NBeTWNFJ7u6PfIDcBwG6/kK8rdcDtWOdvHVDV6eXdfsyQ/YAF2BWFaKRLhFAnHuG4+d9q0Ozs66fmPX+vd1BK9A2M/C5JwrXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=dpdk.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OtGk3zGLxR6dKwsJ6nDOQeb77Ss3fPHg2Y0NMPRIhq4=; b=N+4KpQjPiqt6LZ7ewc3BEOSqKt0MkzDT7PCwOWjX2+EehNgIxhUsJjNr3zsxMjN9mzohRkAlw8ha74VF+6lrkxZAR3RWoDEhku8+WBLkzUqLwy9W2RmlGUo/0iVQYz0/+W1L4kOj9YuPOoME4YSw/lP26bCV8lstET83R39B3V4= Received: from DM5PR05CA0006.namprd05.prod.outlook.com (2603:10b6:3:d4::16) by DM8PR02MB8261.namprd02.prod.outlook.com (2603:10b6:8:f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Fri, 29 Oct 2021 14:48:32 +0000 Received: from DM3NAM02FT018.eop-nam02.prod.protection.outlook.com (2603:10b6:3:d4:cafe::e) by DM5PR05CA0006.outlook.office365.com (2603:10b6:3:d4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.6 via Frontend Transport; Fri, 29 Oct 2021 14:48:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT018.mail.protection.outlook.com (10.13.4.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4649.14 via Frontend Transport; Fri, 29 Oct 2021 14:48:32 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 29 Oct 2021 07:48:31 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 29 Oct 2021 07:48:31 -0700 Envelope-to: dev@dpdk.org, maxime.coquelin@redhat.com, chenbo.xia@intel.com, andrew.rybchenko@oktetlabs.ru Received: from [10.170.66.108] (port=36706 helo=xndengvm004108.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1mgTBG-0008YO-Qp; Fri, 29 Oct 2021 07:48:31 -0700 From: Vijay Srivastava To: CC: , , , Vijay Kumar Srivastava Date: Fri, 29 Oct 2021 20:16:38 +0530 Message-ID: <20211029144645.30295-4-vsrivast@xilinx.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20211029144645.30295-1-vsrivast@xilinx.com> References: <20210706164418.32615-1-vsrivast@xilinx.com> <20211029144645.30295-1-vsrivast@xilinx.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ff7e9958-5fd3-4a73-dbec-08d99aeb2d92 X-MS-TrafficTypeDiagnostic: DM8PR02MB8261: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pb/rFpjhBqlPDS3RZosRC9YPTO0lHea0YUkOP0aIRKaV5B8oj0nGcwm7OhqKSw9YiEtIHYetNJHjf/8TU0H3/9hLB77xKIo8jX9tTMwXnC3u5za2PdspPnPP+XUpGaDLV/Lh9eo8Xu/fZoXq6L3YkYSUkRjOGYqMw0ZBSAJUXrZthchVw4toDDaucsNuA8cvDxoeuSLxSbL7EGnr29dxo82pnPAb6+Z92kPsfIXEAQsXROjhX7nwNYdsPFZYjb03bHZ7OAbbTV8PpiIKoCoRE/Vuydm7SuP0NC6hhWrdXmwIbmZmWC+vIOuPkZB6OvJ5Qlo8dDh+ggt04NNIBBBMaOZEFCjJ9miJe0vZtz4kafPB4EULVCVbxYMxYHGN8DJSp14vduXVE3tvumvniJx46hiCR6wnkvEHbXdPzlH1disYgGjv1dF1zsb1WNVYaW8QXLlWw2ULWbdWVaPEQ9pVUTQ9vsv9lpCTiL1uuLmhrBUOxIh/bjBf5iZmDb8JTlE3g8OZoLLdc/0El92sK1lRccRSINEa+yp1OKb1OlocpQvW0+Rk7jeF0ING4CO0pDpuQQTlFcIwXxV4w4q0WB+UXQtwWrHEwm2yyBCLLTI7w3SMdjFRXr/xcRSKlwmygNJ0xiLNqHeJ+Q5ifoZEEvvkt3yrqom3P6TfD7iEKMzyn0ubigI3XV2HJy+//ftvvqAjp/ZMzcpZWj3bLJREn6ssULEtGpFiqp4JhR1FDOxjimw= X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(36840700001)(46966006)(9786002)(36756003)(44832011)(83380400001)(1076003)(6916009)(82310400003)(8936002)(26005)(7636003)(7696005)(356005)(70206006)(70586007)(336012)(508600001)(186003)(426003)(107886003)(2906002)(2616005)(36860700001)(5660300002)(316002)(54906003)(4326008)(36906005)(47076005)(8676002)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2021 14:48:32.1307 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff7e9958-5fd3-4a73-dbec-08d99aeb2d92 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT018.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR02MB8261 Subject: [dpdk-dev] [PATCH v3 03/10] vdpa/sfc: add support to get device and protocol features X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Vijay Kumar Srivastava Implement vDPA ops get_feature and get_protocol_features. This patch retrieves device supported features and enables protocol features. Signed-off-by: Vijay Kumar Srivastava Acked-by: Andrew Rybchenko Reviewed-by: Maxime Coquelin --- doc/guides/vdpadevs/features/sfc.ini | 10 ++++ drivers/common/sfc_efx/efsys.h | 2 +- drivers/common/sfc_efx/version.map | 10 ++++ drivers/vdpa/sfc/sfc_vdpa.c | 20 ++++++++ drivers/vdpa/sfc/sfc_vdpa.h | 2 + drivers/vdpa/sfc/sfc_vdpa_hw.c | 13 ++++++ drivers/vdpa/sfc/sfc_vdpa_ops.c | 91 ++++++++++++++++++++++++++++++++---- drivers/vdpa/sfc/sfc_vdpa_ops.h | 3 ++ 8 files changed, 142 insertions(+), 9 deletions(-) diff --git a/doc/guides/vdpadevs/features/sfc.ini b/doc/guides/vdpadevs/features/sfc.ini index 71b6158..700d061 100644 --- a/doc/guides/vdpadevs/features/sfc.ini +++ b/doc/guides/vdpadevs/features/sfc.ini @@ -4,6 +4,16 @@ ; Refer to default.ini for the full list of available driver features. ; [Features] +csum = Y +guest csum = Y +host tso4 = Y +host tso6 = Y +version 1 = Y +mrg rxbuf = Y +any layout = Y +in_order = Y +proto host notifier = Y +IOMMU platform = Y Linux = Y x86-64 = Y Usage doc = Y diff --git a/drivers/common/sfc_efx/efsys.h b/drivers/common/sfc_efx/efsys.h index d133d61..37ec6b9 100644 --- a/drivers/common/sfc_efx/efsys.h +++ b/drivers/common/sfc_efx/efsys.h @@ -187,7 +187,7 @@ #define EFSYS_OPT_MAE 1 -#define EFSYS_OPT_VIRTIO 0 +#define EFSYS_OPT_VIRTIO 1 /* ID */ diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index 642a62e..ec86220 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -247,6 +247,16 @@ INTERNAL { efx_txq_nbufs; efx_txq_size; + efx_virtio_fini; + efx_virtio_get_doorbell_offset; + efx_virtio_get_features; + efx_virtio_init; + efx_virtio_qcreate; + efx_virtio_qdestroy; + efx_virtio_qstart; + efx_virtio_qstop; + efx_virtio_verify_features; + sfc_efx_dev_class_get; sfc_efx_family; diff --git a/drivers/vdpa/sfc/sfc_vdpa.c b/drivers/vdpa/sfc/sfc_vdpa.c index b7eca56..ccbd243 100644 --- a/drivers/vdpa/sfc/sfc_vdpa.c +++ b/drivers/vdpa/sfc/sfc_vdpa.c @@ -43,6 +43,26 @@ struct sfc_vdpa_adapter * return found ? sva : NULL; } +struct sfc_vdpa_ops_data * +sfc_vdpa_get_data_by_dev(struct rte_vdpa_device *vdpa_dev) +{ + bool found = false; + struct sfc_vdpa_adapter *sva; + + pthread_mutex_lock(&sfc_vdpa_adapter_list_lock); + + TAILQ_FOREACH(sva, &sfc_vdpa_adapter_list, next) { + if (vdpa_dev == sva->ops_data->vdpa_dev) { + found = true; + break; + } + } + + pthread_mutex_unlock(&sfc_vdpa_adapter_list_lock); + + return found ? sva->ops_data : NULL; +} + static int sfc_vdpa_vfio_setup(struct sfc_vdpa_adapter *sva) { diff --git a/drivers/vdpa/sfc/sfc_vdpa.h b/drivers/vdpa/sfc/sfc_vdpa.h index 046f25d..c10c3d3 100644 --- a/drivers/vdpa/sfc/sfc_vdpa.h +++ b/drivers/vdpa/sfc/sfc_vdpa.h @@ -60,6 +60,8 @@ struct sfc_vdpa_adapter { struct sfc_vdpa_adapter * sfc_vdpa_get_adapter_by_dev(struct rte_pci_device *pdev); +struct sfc_vdpa_ops_data * +sfc_vdpa_get_data_by_dev(struct rte_vdpa_device *vdpa_dev); int sfc_vdpa_hw_init(struct sfc_vdpa_adapter *sva); diff --git a/drivers/vdpa/sfc/sfc_vdpa_hw.c b/drivers/vdpa/sfc/sfc_vdpa_hw.c index 7c256ff..7a67bd8 100644 --- a/drivers/vdpa/sfc/sfc_vdpa_hw.c +++ b/drivers/vdpa/sfc/sfc_vdpa_hw.c @@ -278,10 +278,20 @@ if (rc != 0) goto fail_estimate_rsrc_limits; + sfc_vdpa_log_init(sva, "init virtio"); + rc = efx_virtio_init(enp); + if (rc != 0) { + sfc_vdpa_err(sva, "virtio init failed: %s", rte_strerror(rc)); + goto fail_virtio_init; + } + sfc_vdpa_log_init(sva, "done"); return 0; +fail_virtio_init: + efx_nic_fini(enp); + fail_estimate_rsrc_limits: fail_nic_reset: efx_nic_unprobe(enp); @@ -310,6 +320,9 @@ sfc_vdpa_log_init(sva, "entry"); + sfc_vdpa_log_init(sva, "virtio fini"); + efx_virtio_fini(enp); + sfc_vdpa_log_init(sva, "unprobe nic"); efx_nic_unprobe(enp); diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.c b/drivers/vdpa/sfc/sfc_vdpa_ops.c index 71696be..5750944 100644 --- a/drivers/vdpa/sfc/sfc_vdpa_ops.c +++ b/drivers/vdpa/sfc/sfc_vdpa_ops.c @@ -3,17 +3,31 @@ * Copyright(c) 2020-2021 Xilinx, Inc. */ +#include #include #include #include #include +#include "efx.h" #include "sfc_vdpa_ops.h" #include "sfc_vdpa.h" -/* Dummy functions for mandatory vDPA ops to pass vDPA device registration. - * In subsequent patches these ops would be implemented. +/* These protocol features are needed to enable notifier ctrl */ +#define SFC_VDPA_PROTOCOL_FEATURES \ + ((1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK) | \ + (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)) + +/* + * Set of features which are enabled by default. + * Protocol feature bit is needed to enable notification notifier ctrl. */ +#define SFC_VDPA_DEFAULT_FEATURES \ + (1ULL << VHOST_USER_F_PROTOCOL_FEATURES) + static int sfc_vdpa_get_queue_num(struct rte_vdpa_device *vdpa_dev, uint32_t *queue_num) { @@ -24,22 +38,67 @@ } static int +sfc_vdpa_get_device_features(struct sfc_vdpa_ops_data *ops_data) +{ + int rc; + uint64_t dev_features; + efx_nic_t *nic; + + nic = sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)->nic; + + rc = efx_virtio_get_features(nic, EFX_VIRTIO_DEVICE_TYPE_NET, + &dev_features); + if (rc != 0) { + sfc_vdpa_err(ops_data->dev_handle, + "could not read device feature: %s", + rte_strerror(rc)); + return rc; + } + + ops_data->dev_features = dev_features; + + sfc_vdpa_info(ops_data->dev_handle, + "device supported virtio features : 0x%" PRIx64, + ops_data->dev_features); + + return 0; +} + +static int sfc_vdpa_get_features(struct rte_vdpa_device *vdpa_dev, uint64_t *features) { - RTE_SET_USED(vdpa_dev); - RTE_SET_USED(features); + struct sfc_vdpa_ops_data *ops_data; - return -1; + ops_data = sfc_vdpa_get_data_by_dev(vdpa_dev); + if (ops_data == NULL) + return -1; + + *features = ops_data->drv_features; + + sfc_vdpa_info(ops_data->dev_handle, + "vDPA ops get_feature :: features : 0x%" PRIx64, + *features); + + return 0; } static int sfc_vdpa_get_protocol_features(struct rte_vdpa_device *vdpa_dev, uint64_t *features) { - RTE_SET_USED(vdpa_dev); - RTE_SET_USED(features); + struct sfc_vdpa_ops_data *ops_data; - return -1; + ops_data = sfc_vdpa_get_data_by_dev(vdpa_dev); + if (ops_data == NULL) + return -1; + + *features = SFC_VDPA_PROTOCOL_FEATURES; + + sfc_vdpa_info(ops_data->dev_handle, + "vDPA ops get_protocol_feature :: features : 0x%" PRIx64, + *features); + + return 0; } static int @@ -91,6 +150,7 @@ struct sfc_vdpa_ops_data * { struct sfc_vdpa_ops_data *ops_data; struct rte_pci_device *pci_dev; + int rc; /* Create vDPA ops context */ ops_data = rte_zmalloc("vdpa", sizeof(struct sfc_vdpa_ops_data), 0); @@ -111,10 +171,25 @@ struct sfc_vdpa_ops_data * goto fail_register_device; } + /* Read supported device features */ + sfc_vdpa_log_init(dev_handle, "get device feature"); + rc = sfc_vdpa_get_device_features(ops_data); + if (rc != 0) + goto fail_get_dev_feature; + + /* Driver features are superset of device supported feature + * and any additional features supported by the driver. + */ + ops_data->drv_features = + ops_data->dev_features | SFC_VDPA_DEFAULT_FEATURES; + ops_data->state = SFC_VDPA_STATE_INITIALIZED; return ops_data; +fail_get_dev_feature: + rte_vdpa_unregister_device(ops_data->vdpa_dev); + fail_register_device: rte_free(ops_data); return NULL; diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.h b/drivers/vdpa/sfc/sfc_vdpa_ops.h index 817b302..21cbb73 100644 --- a/drivers/vdpa/sfc/sfc_vdpa_ops.h +++ b/drivers/vdpa/sfc/sfc_vdpa_ops.h @@ -26,6 +26,9 @@ struct sfc_vdpa_ops_data { struct rte_vdpa_device *vdpa_dev; enum sfc_vdpa_context vdpa_context; enum sfc_vdpa_state state; + + uint64_t dev_features; + uint64_t drv_features; }; struct sfc_vdpa_ops_data * -- 1.8.3.1