Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1278353pxb; Fri, 22 Jan 2021 11:17:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEj33D/0R1QDwMUZYE06dDTFY5FxhA1F/7wjic8Z+bdiZtb3Othxg2FnIUqfH7xJ/E7IPe X-Received: by 2002:a17:906:8410:: with SMTP id n16mr4031393ejx.551.1611343061927; Fri, 22 Jan 2021 11:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611343061; cv=none; d=google.com; s=arc-20160816; b=HOHDYAU7Ttt37FdECzZptrQYu+3zzcFhsHA+5yeagJIXmTeEGM0gQs1JylmB9Cvfgq hMyCSwgWNl4/RQVYsjz3FbCOFDSIr9WDbhUsnRMspefeoDV9lFO4qqpIlStQWzLD126J 8KKfimG7alg/aushqNMZIiLgcMpyt2hozxUFi2QMRzpX8M+2hATK574BbEM/x3t5JKdF 9s/KqA/5o8LYZbRTTrJbHZtFpPZbLwL5PB4LxMUttiLs6QvHEAqRPvCvsX3AgO7hBNF6 MeJavnUiYhZCHqWBPdP5tzSNecRU2Tpa/Z2fDX90isxOBEZUDqJpZQ+GCj+5yPkonp2W KwcA== 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=8syBnebi0WFZPAOMZ921GW/N+u5DITrqadgQ/EWvLoE=; b=MloO1a+lpTkultBqvh83aHF8L6u4Dbqss9OcWmVW21KaOetC6Nq61ruMjC5e2iTDQp pwwQz+8sG5WINunv6wYrpBpVUJx7TbjTutILz0a3VifpxA04WQ6U++Qn9LCRU0VvEGcM 4Iyug4Cd1CtQqx4VUlLnRsmjM2+EChiOOeoi7HhQnJezltlwZG0bomyZbeQEOBIzT6ME Q/U947fkm6mHfTnVhz2hmSHqQr75uQlDv0MuN8FjsRZ7Ynk4ylwH2USeszblfxKoCCM9 kNSn45rERSUvutu0D31l7KmQF9oX7HBB42W50p0tAfwLH9Lhw/mZLkYsuHTHJaKywQX6 +51Q== 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 p17si3400741ejy.489.2021.01.22.11.17.16; Fri, 22 Jan 2021 11:17:41 -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 S1728965AbhAVTK6 (ORCPT + 99 others); Fri, 22 Jan 2021 14:10:58 -0500 Received: from mga17.intel.com ([192.55.52.151]:50701 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730514AbhAVTIa (ORCPT ); Fri, 22 Jan 2021 14:08:30 -0500 IronPort-SDR: 3fnHlxfyexeYEDwDaDaol0Rl7up2ynDop1164oVdPSSMYkdHEVShqqx+6ERbZ3kQpDl7Gm4DEq HBRTFWVhL1Kw== X-IronPort-AV: E=McAfee;i="6000,8403,9872"; a="159266142" X-IronPort-AV: E=Sophos;i="5.79,367,1602572400"; d="scan'208";a="159266142" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2021 11:02:30 -0800 IronPort-SDR: QvBJ1BjwZOjls2cDDbJRM7tue9DTT2Z4MjM45V6hzC1EucWJBgUXnSYGjxBOHnxGOgPWAi6rVV rMGlljMGgDwQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,367,1602572400"; d="scan'208";a="407936568" Received: from txasoft-yocto.an.intel.com ([10.123.72.192]) by FMSMGA003.fm.intel.com with ESMTP; 22 Jan 2021 11:02:29 -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 v9 14/20] dlb: add start domain ioctl Date: Fri, 22 Jan 2021 13:01:32 -0600 Message-Id: <20210122190138.7414-15-mike.ximing.chen@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20210122190138.7414-1-mike.ximing.chen@intel.com> References: <20210122190138.7414-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 7cfb70c57b50..d25c062058f9 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