Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp612872pxb; Wed, 27 Jan 2021 16:47:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMdv7WscDApoD6bql3SZi61CAPitsU0vBWUb9v7dsYnYDHi1p7Zs/Mq9/2tPUsuINcQrrS X-Received: by 2002:aa7:cc98:: with SMTP id p24mr11840916edt.126.1611794824707; Wed, 27 Jan 2021 16:47:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611794824; cv=none; d=google.com; s=arc-20160816; b=E55nlVDUFutKpVVFiBd4wUXNz/5Oi5eTk1GZ0g6rDxB7ew2twoAAQ0JXYNdnxd9lKJ jFCA/IqCvLsSe80DzLjXV1QGsPxjN4Eh6Rz1eOeb+BN5/weN1R7xYlSD4H5p+3U0rTHy 3ul+ci1ox/xazdwWsWsw3YEL9b5x741ZaCE6KhzGvRtq3uzy6SJL4CIbvDxCF3GpukAq duSjHrKuJr9Ys/IbnUQSRA2XtaX5b4g8Bc7fDQY7fLOdC9MeDkFRGBAF1wTnjmVX4BD4 EYNgxIbG2jnQLgxp+BrYmjm7hitJs+9oAtQ1UwEKndwHZu0qF6vGjAlPFsVTgEUyE/5s hSng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=rEqPHN/vXpUxCcR94qjaCZwUuD3VC8aOff0YhJQQ10k=; b=AWMONkZ3inBIlJSKxR0n//AEhcFY1GFuN2PDSkCCYDWUu/o2bVHhyxWqb/H+3piQDF 6moXUGmrR3UAguZoTnZCpvmGkNSVG3alOr4fxtEh4fA9oWIYXPUSAMDP3fJAEpIcLFxX 8bH7XL3tOaPBHCdAZYsDbLrXuJ0UBfKMnwxVmYZgOpg3i350iJSnmadeEJP2Qp+e+7v1 cF2yB4aJdCNW4NzwgSk6MOq3SHGkmug0yEM0UaE1SxMfv2cdUkMG5dh0P+E8sf9hig4R IbA5sYaweeQ6yMx93t6uz5EV5qoYdaB9EQldiNs8IKS8wu14Os37QZu7hke/HwDTsSHz 4nlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q16si1493570ejd.199.2021.01.27.16.46.39; Wed, 27 Jan 2021 16:47:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234976AbhA0XKe (ORCPT + 99 others); Wed, 27 Jan 2021 18:10:34 -0500 Received: from mga12.intel.com ([192.55.52.136]:17431 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234209AbhA0XEV (ORCPT ); Wed, 27 Jan 2021 18:04:21 -0500 IronPort-SDR: ao+8sgaeQTRa36pVJFE9MjPgoi642rKk6oxbs3qgTBxXLpJQhifdQgcuVVESvB6/csaBKx6F48 cOjUD1qIVMNA== X-IronPort-AV: E=McAfee;i="6000,8403,9877"; a="159319102" X-IronPort-AV: E=Sophos;i="5.79,380,1602572400"; d="scan'208";a="159319102" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2021 14:56:51 -0800 IronPort-SDR: lx08J7q2O1GhKuVLLSh3nDAYJGZR0aqNs7epZOLHuQ4oM+ovm81YqvCPahBBIms6O/JuEul7WZ FWfZyWhvgYIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,380,1602572400"; d="scan'208";a="388494319" Received: from txasoft-yocto.an.intel.com ([10.123.72.192]) by orsmga008.jf.intel.com with ESMTP; 27 Jan 2021 14:56:50 -0800 From: Mike Ximing Chen To: linux-kernel@vger.kernel.org Cc: arnd@arndb.de, gregkh@linuxfoundation.org, dan.j.williams@intel.com, pierre-louis.bossart@linux.intel.com, Gage Eads Subject: [PATCH v10 14/20] dlb: add start domain ioctl Date: Wed, 27 Jan 2021 16:56:35 -0600 Message-Id: <20210127225641.1342-15-mike.ximing.chen@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20210127225641.1342-1-mike.ximing.chen@intel.com> References: <20210127225641.1342-1-mike.ximing.chen@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add ioctl to start a domain. Once a scheduling domain and its resources have been configured, this ioctl is called to allow the domain's ports to begin enqueueing to the device. Once started, the domain's resources cannot be configured again until after the domain is reset. This ioctl instructs the DLB device to start load-balancing operations. It corresponds to rte_event_dev_start() function in DPDK' eventdev library. Signed-off-by: Gage Eads Signed-off-by: Mike Ximing Chen Reviewed-by: Björn Töpel Reviewed-by: Dan Williams --- drivers/misc/dlb/dlb_ioctl.c | 3 + drivers/misc/dlb/dlb_main.h | 4 ++ drivers/misc/dlb/dlb_pf_ops.c | 9 +++ drivers/misc/dlb/dlb_resource.c | 116 ++++++++++++++++++++++++++++++++ drivers/misc/dlb/dlb_resource.h | 4 ++ include/uapi/linux/dlb.h | 22 ++++++ 6 files changed, 158 insertions(+) diff --git a/drivers/misc/dlb/dlb_ioctl.c b/drivers/misc/dlb/dlb_ioctl.c index 6a311b969643..9b05344f03c8 100644 --- a/drivers/misc/dlb/dlb_ioctl.c +++ b/drivers/misc/dlb/dlb_ioctl.c @@ -51,6 +51,7 @@ DLB_DOMAIN_IOCTL_CALLBACK_TEMPLATE(create_ldb_queue) DLB_DOMAIN_IOCTL_CALLBACK_TEMPLATE(create_dir_queue) DLB_DOMAIN_IOCTL_CALLBACK_TEMPLATE(get_ldb_queue_depth) DLB_DOMAIN_IOCTL_CALLBACK_TEMPLATE(get_dir_queue_depth) +DLB_DOMAIN_IOCTL_CALLBACK_TEMPLATE(start_domain) /* * Port creation ioctls don't use the callback template macro. @@ -322,6 +323,8 @@ long dlb_domain_ioctl(struct file *f, unsigned int cmd, unsigned long arg) return dlb_domain_ioctl_get_dir_port_pp_fd(dlb, dom, arg); case DLB_IOC_GET_DIR_PORT_CQ_FD: return dlb_domain_ioctl_get_dir_port_cq_fd(dlb, dom, arg); + case DLB_IOC_START_DOMAIN: + return dlb_domain_ioctl_start_domain(dlb, dom, arg); default: return -ENOTTY; } diff --git a/drivers/misc/dlb/dlb_main.h b/drivers/misc/dlb/dlb_main.h index 477974e1a178..2f3096a45b1e 100644 --- a/drivers/misc/dlb/dlb_main.h +++ b/drivers/misc/dlb/dlb_main.h @@ -63,6 +63,10 @@ struct dlb_device_ops { struct dlb_create_dir_port_args *args, uintptr_t cq_dma_base, struct dlb_cmd_response *resp); + int (*start_domain)(struct dlb_hw *hw, + u32 domain_id, + struct dlb_start_domain_args *args, + struct dlb_cmd_response *resp); int (*get_num_resources)(struct dlb_hw *hw, struct dlb_get_num_resources_args *args); int (*reset_domain)(struct dlb_hw *hw, u32 domain_id); diff --git a/drivers/misc/dlb/dlb_pf_ops.c b/drivers/misc/dlb/dlb_pf_ops.c index 02a188aa5a60..ce9d29b94a55 100644 --- a/drivers/misc/dlb/dlb_pf_ops.c +++ b/drivers/misc/dlb/dlb_pf_ops.c @@ -160,6 +160,14 @@ dlb_pf_create_dir_port(struct dlb_hw *hw, u32 id, resp, false, 0); } +static int +dlb_pf_start_domain(struct dlb_hw *hw, u32 id, + struct dlb_start_domain_args *args, + struct dlb_cmd_response *resp) +{ + return dlb_hw_start_domain(hw, id, args, resp, false, 0); +} + static int dlb_pf_get_num_resources(struct dlb_hw *hw, struct dlb_get_num_resources_args *args) { @@ -232,6 +240,7 @@ struct dlb_device_ops dlb_pf_ops = { .create_dir_queue = dlb_pf_create_dir_queue, .create_ldb_port = dlb_pf_create_ldb_port, .create_dir_port = dlb_pf_create_dir_port, + .start_domain = dlb_pf_start_domain, .get_num_resources = dlb_pf_get_num_resources, .reset_domain = dlb_pf_reset_domain, .ldb_port_owned_by_domain = dlb_pf_ldb_port_owned_by_domain, diff --git a/drivers/misc/dlb/dlb_resource.c b/drivers/misc/dlb/dlb_resource.c index 2659190527a7..ee95c93aac7b 100644 --- a/drivers/misc/dlb/dlb_resource.c +++ b/drivers/misc/dlb/dlb_resource.c @@ -1217,6 +1217,35 @@ dlb_verify_create_dir_port_args(struct dlb_hw *hw, u32 domain_id, return 0; } +static int dlb_verify_start_domain_args(struct dlb_hw *hw, u32 domain_id, + struct dlb_cmd_response *resp, + bool vdev_req, unsigned int vdev_id, + struct dlb_hw_domain **out_domain) +{ + struct dlb_hw_domain *domain; + + domain = dlb_get_domain_from_id(hw, domain_id, vdev_req, vdev_id); + + if (!domain) { + resp->status = DLB_ST_INVALID_DOMAIN_ID; + return -EINVAL; + } + + if (!domain->configured) { + resp->status = DLB_ST_DOMAIN_NOT_CONFIGURED; + return -EINVAL; + } + + if (domain->started) { + resp->status = DLB_ST_DOMAIN_STARTED; + return -EINVAL; + } + + *out_domain = domain; + + return 0; +} + static void dlb_configure_domain_credits(struct dlb_hw *hw, struct dlb_hw_domain *domain) { @@ -2712,6 +2741,93 @@ static void dlb_domain_reset_ldb_port_registers(struct dlb_hw *hw, } } +static void dlb_log_start_domain(struct dlb_hw *hw, u32 domain_id, + bool vdev_req, unsigned int vdev_id) +{ + DLB_HW_DBG(hw, "DLB start domain arguments:\n"); + if (vdev_req) + DLB_HW_DBG(hw, "(Request from vdev %d)\n", vdev_id); + DLB_HW_DBG(hw, "\tDomain ID: %d\n", domain_id); +} + +/** + * dlb_hw_start_domain() - start a scheduling domain + * @hw: dlb_hw handle for a particular device. + * @domain_id: domain ID. + * @unused: unused. + * @resp: response structure. + * @vdev_req: indicates whether this request came from a vdev. + * @vdev_id: If vdev_req is true, this contains the vdev's ID. + * + * This function starts a scheduling domain, which allows applications to send + * traffic through it. Once a domain is started, its resources can no longer be + * configured (besides QID remapping and port enable/disable). + * + * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual + * device. + * + * Return: + * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is + * assigned a detailed error code from enum dlb_error. + * + * Errors: + * EINVAL - the domain is not configured, or the domain is already started. + */ +int +dlb_hw_start_domain(struct dlb_hw *hw, u32 domain_id, void *unused, + struct dlb_cmd_response *resp, bool vdev_req, + unsigned int vdev_id) +{ + struct dlb_dir_pq_pair *dir_queue; + struct dlb_ldb_queue *ldb_queue; + struct dlb_hw_domain *domain; + int ret; + + dlb_log_start_domain(hw, domain_id, vdev_req, vdev_id); + + ret = dlb_verify_start_domain_args(hw, domain_id, resp, + vdev_req, vdev_id, &domain); + if (ret) + return ret; + + /* + * Enable load-balanced and directed queue write permissions for the + * queues this domain owns. Without this, the DLB will drop all + * incoming traffic to those queues. + */ + list_for_each_entry(ldb_queue, &domain->used_ldb_queues, domain_list) { + u32 vasqid_v = 0; + unsigned int offs; + + vasqid_v |= SYS_LDB_VASQID_V_VASQID_V; + + offs = domain->id.phys_id * DLB_MAX_NUM_LDB_QUEUES + + ldb_queue->id.phys_id; + + DLB_CSR_WR(hw, SYS_LDB_VASQID_V(offs), vasqid_v); + } + + list_for_each_entry(dir_queue, &domain->used_dir_pq_pairs, domain_list) { + u32 vasqid_v = 0; + unsigned int offs; + + vasqid_v |= SYS_DIR_VASQID_V_VASQID_V; + + offs = domain->id.phys_id * DLB_MAX_NUM_DIR_PORTS + + dir_queue->id.phys_id; + + DLB_CSR_WR(hw, SYS_DIR_VASQID_V(offs), vasqid_v); + } + + dlb_flush_csr(hw); + + domain->started = true; + + resp->status = 0; + + return 0; +} + static void __dlb_domain_reset_dir_port_registers(struct dlb_hw *hw, struct dlb_dir_pq_pair *port) diff --git a/drivers/misc/dlb/dlb_resource.h b/drivers/misc/dlb/dlb_resource.h index 8a3c37b6ab92..f4852d744dca 100644 --- a/drivers/misc/dlb/dlb_resource.h +++ b/drivers/misc/dlb/dlb_resource.h @@ -41,6 +41,10 @@ int dlb_hw_create_ldb_port(struct dlb_hw *hw, u32 domain_id, struct dlb_cmd_response *resp, bool vdev_req, unsigned int vdev_id); +int dlb_hw_start_domain(struct dlb_hw *hw, u32 domain_id, void *unused, + struct dlb_cmd_response *resp, + bool vdev_req, unsigned int vdev_id); + int dlb_reset_domain(struct dlb_hw *hw, u32 domain_id, bool vdev_req, unsigned int vdev_id); diff --git a/include/uapi/linux/dlb.h b/include/uapi/linux/dlb.h index 6b7eceecae8a..84a877ad6824 100644 --- a/include/uapi/linux/dlb.h +++ b/include/uapi/linux/dlb.h @@ -408,6 +408,23 @@ struct dlb_get_port_fd_args { __u32 padding0; }; +/* + * DLB_DOMAIN_CMD_START_DOMAIN: Mark the end of the domain configuration. This + * must be called before passing QEs into the device, and no configuration + * ioctls can be issued once the domain has started. Sending QEs into the + * device before calling this ioctl will result in undefined behavior. + * Input parameters: + * - (None) + * + * Output parameters: + * @response.status: Detailed error code. In certain cases, such as if the + * ioctl request arg is invalid, the driver won't set status. + */ +struct dlb_start_domain_args { + /* Output parameters */ + struct dlb_cmd_response response; +}; + enum dlb_domain_user_interface_commands { DLB_DOMAIN_CMD_CREATE_LDB_QUEUE, DLB_DOMAIN_CMD_CREATE_DIR_QUEUE, @@ -419,6 +436,7 @@ enum dlb_domain_user_interface_commands { DLB_DOMAIN_CMD_GET_LDB_PORT_CQ_FD, DLB_DOMAIN_CMD_GET_DIR_PORT_PP_FD, DLB_DOMAIN_CMD_GET_DIR_PORT_CQ_FD, + DLB_DOMAIN_CMD_START_DOMAIN, /* NUM_DLB_DOMAIN_CMD must be last */ NUM_DLB_DOMAIN_CMD, @@ -493,5 +511,9 @@ enum dlb_domain_user_interface_commands { _IOWR(DLB_IOC_MAGIC, \ DLB_DOMAIN_CMD_GET_DIR_PORT_CQ_FD, \ struct dlb_get_port_fd_args) +#define DLB_IOC_START_DOMAIN \ + _IOR(DLB_IOC_MAGIC, \ + DLB_DOMAIN_CMD_START_DOMAIN, \ + struct dlb_start_domain_args) #endif /* __DLB_H */ -- 2.17.1