* Re: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls @ 2021-01-28 15:38 Chen, Mike Ximing 0 siblings, 0 replies; 8+ messages in thread From: Chen, Mike Ximing @ 2021-01-28 15:38 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 85 bytes --] A new patch set with the fix was submitted. https://lkml.org/lkml/2021/1/27/1328 [-- Attachment #2: attachment.htm --] [-- Type: text/html, Size: 37032 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v9 00/20] dlb: introduce DLB device driver @ 2021-01-22 19:01 Mike Ximing Chen 2021-01-22 19:01 ` [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls Mike Ximing Chen 0 siblings, 1 reply; 8+ messages in thread From: Mike Ximing Chen @ 2021-01-22 19:01 UTC (permalink / raw) To: linux-kernel; +Cc: arnd, gregkh, dan.j.williams, pierre-louis.bossart Introduce a new misc device driver for the Intel(r) Dynamic Load Balancer (Intel(r) DLB). The Intel DLB is a PCIe device that provides load-balanced, prioritized scheduling of core-to-core communication. Intel DLB is an accelerator for the event-driven programming model of DPDK's Event Device Library[2]. The library is used in packet processing pipelines that arrange for multi-core scalability, dynamic load-balancing, and variety of packet distribution and synchronization schemes These distribution schemes include "parallel" (packets are load-balanced across multiple cores and processed in parallel), "ordered" (similar to "parallel" but packets are reordered into ingress order by the device), and "atomic" (packet flows are scheduled to a single core at a time such that locks are not required to access per-flow data, and dynamically migrated to ensure load-balance). This submission supports Intel DLB 2.0 only. The Intel DLB consists of queues and arbiters that connect producer cores and consumer cores. The device implements load-balanced queueing features including: - Lock-free multi-producer/multi-consumer operation. - Multiple priority levels for varying traffic types. - 'Direct' traffic (i.e. multi-producer/single-consumer) - Simple unordered load-balanced distribution. - Atomic lock free load balancing across multiple consumers. - Queue element reordering feature allowing ordered load-balanced distribution. The fundamental unit of communication through the device is a queue entry (QE), which consists of 8B of data and 8B of metadata (destination queue, priority, etc.). The data field can be any type that fits within 8B. A core's interface to the device, a "port," consists of a memory-mappable region through which the core enqueues a queue entry, and an in-memory queue (the "consumer queue") to which the device schedules QEs. Each QE is enqueued to a device-managed queue, and from there scheduled to a port. Software specifies the "linking" of queues and ports; i.e. which ports the device is allowed to schedule to for a given queue. The device uses a credit scheme to prevent overflow of the on-device queue storage. Applications can interface directly with the device by mapping the port's memory and MMIO regions into the application's address space for enqueue and dequeue operations, but call into the kernel driver for configuration operations. An application can also be polling- or interrupt-driven; Intel DLB supports both modes of operation. Device resources -- i.e. ports, queues, and credits -- are contained within a scheduling domain. Scheduling domains are isolated from one another; a port can only enqueue to and dequeue from queues within its scheduling domain. A scheduling domain's resources are configured through a scheduling domain file, which is acquired through an ioctl. Intel DLB supports SR-IOV and Scalable IOV, and allows for a flexible division of its resources among the PF and its virtual devices. The virtual devices are incapable of configuring the device directly; they use a hardware mailbox to proxy configuration requests to the PF driver. This driver supports both PF and virtual devices, as there is significant code re-use between the two, with device-specific behavior handled through a callback interface. Virtualization support will be added in a later patch set. The dlb driver uses ioctls as its primary interface (it makes use of sysfs as well, to a lesser extent). The dlb device file supports a different ioctl interface than the scheduling domain file; the dlb device file is used for device-wide operations (including scheduling domain creation), and the scheduling domain file supports operations on the scheduling domain's resources (primarily resource configuration). Scheduling domains are created dynamically (using a dlb device file ioctl) by user-space software, and the scheduling domain file is created from an anonymous file that is installed in the ioctl's calling process's file descriptor table. [1] https://builders.intel.com/docs/networkbuilders/SKU-343247-001US-queue-management-and-load-balancing-on-intel-architecture.pdf [2] https://doc.dpdk.org/guides/prog_guide/eventdev.html v9: - Addressed all of Greg's feecback on v8, including -- Remove function name (__func__) from dev_err() messages, that could spam log. -- Replace list and function pointer calls in dlb_ioctl() with switch-case and real function callsi for ioctl. -- Drop the compat_ptr_ioctl in dlb_ops (struct file_operations). -- Change ioctl magic number for DLB to unused 0x81 (from 'h'). -- Remove all placeholder/dummy functions in the patch set. -- Re-arrange the comments in dlb.h so that the order is consistent with that of data structures referred. -- Correct the comments on SPDX License and DLB versions in dlb.h. -- Replace BIT_SET() and BITS_CLR() marcos with direct coding. -- Remove NULL pointer checking (f->private_data) in dlb_ioctl(). -- Use whole line whenever possible and not wrapping lines unnecessarily. -- Remove __attribute__((unused)). -- Merge dlb_ioctl.h and dlb_file.h into dlb_main.h v8: - Add a functional block diagram in dlb.rst - Modify change logs to reflect the links between patches and DPDK eventdev library. - Add a check of power-of-2 for CQ depth. - Move call to INIT_WORK() to dlb_open(). - Clean dlb workqueue by calling flush_scheduled_work(). - Add unmap_mapping_range() in dlb_port_close(). v7 (Intel internal version): - Address all of Dan's feedback, including -- Drop DLB 2.0 throughout the patch set, use DLB only. -- Fix license and copyright statements -- Use pcim_enable_device() and pcim_iomap_regions(), instead of unmanaged version. -- Move cdev_add() to dlb_init() and add all devices at once. -- Fix Makefile, using "+=" style. -- Remove FLR description and mention movdir64/enqcmd usage in doc. -- Make the permission for the domain same as that for device for ioctl access. -- Use idr instead of ida. -- Add a lock in dlb_close() to prevent driver unbinding while ioctl coomands are in progress. -- Remove wrappers that are used for code sharing between kernel driver and DPDK. - Address Pierre-Louis' feedback, including -- Clean the warinings from checkpatch -- Fix the warnings from "make W=1" v6 (Intel internal version): - Change the module name to dlb(from dlb2), which currently supports Intel DLB 2.0 only. - Address all of Pierre-Louis' feedback on v5, including -- Consolidate the two near-identical for loops in dlb2_release_domain_memory(). -- Remove an unnecessary "port = NULL" initialization -- Consistently use curly braces on the *_LIST_FOR macros when the for-loop contents spans multiple lines. -- Add a comment to the definition of DLB2FS_MAGIC -- Remove always true if statemnets -- Move the get_cos_bw mutex unlock call earlier to shorten the critical section. - Address all of Dan's feedbacks, including -- Replace the unions for register bits access with bitmask and shifts -- Centralize the "to/from" user memory copies for ioctl functions. -- Review ioctl design against Documentation/process/botching-up-ioctls.rst -- Remove wraper functions for memory barriers. -- Use ilog() to simplify a switch code block. -- Add base-commit to cover letter. v5 (Intel internal version): - Reduce the scope of the initial patch set (drop the last 8 patches) - Further decompose some of the remaining patches into multiple patches. - Address all of Pierre-Louis' feedback, including: -- Move kerneldoc to *.c files -- Fix SPDX comment style -- Add BAR macros -- Improve/clarify struct dlb2_dev and struct device variable naming -- Add const where missing -- Clarify existing comments and add new ones in various places -- Remove unnecessary memsets and zero-initialization -- Remove PM abstraction, fix missing pm_runtime_allow(), and don't update PM refcnt when port files are opened and closed. -- Convert certain ternary operations into if-statements -- Out-line the CQ depth valid check -- De-duplicate the logic in dlb2_release_device_memory() -- Limit use of devm functions to allocating/freeing struct dlb2 - Address Ira's comments on dlb2.rst and correct commit messages that don't use the imperative voice. v4: - Move PCI device ID definitions into dlb2_hw_types.h, drop the VF definition - Remove dlb2_dev_list - Remove open/close functions and fops structure (unused) - Remove "(char *)" cast from PCI driver name - Unwind init failures properly - Remove ID alloc helper functions and call IDA interfaces directly instead v3: - Remove DLB2_PCI_REG_READ/WRITE macros v2: - Change driver license to GPLv2 only - Expand Kconfig help text and remove unnecessary (R)s - Remove unnecessary prints - Add a new entry in ioctl-number.rst - Convert the ioctl handler into a switch statement - Correct some instances of IOWR that should have been IOR - Align macro blocks - Don't break ioctl ABI when introducing new commands - Remove indirect pointers from ioctl data structures - Remove the get-sched-domain-fd ioctl command Mike Ximing Chen (20): dlb: add skeleton for DLB driver dlb: initialize device dlb: add resource and device initialization dlb: add device ioctl layer and first three ioctls dlb: add scheduling domain configuration dlb: add domain software reset dlb: add low-level register reset operations dlb: add runtime power-management support dlb: add queue create, reset, get-depth ioctls dlb: add register operations for queue management dlb: add ioctl to configure ports and query poll mode dlb: add register operations for port management dlb: add port mmap support dlb: add start domain ioctl dlb: add queue map, unmap, and pending unmap operations dlb: add port map/unmap state machine dlb: add static queue map register operations dlb: add dynamic queue map register operations dlb: add queue unmap register operations dlb: queue map/unmap workqueue Documentation/misc-devices/dlb.rst | 259 + Documentation/misc-devices/index.rst | 1 + .../userspace-api/ioctl/ioctl-number.rst | 1 + MAINTAINERS | 8 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/dlb/Kconfig | 18 + drivers/misc/dlb/Makefile | 11 + drivers/misc/dlb/dlb_bitmap.h | 210 + drivers/misc/dlb/dlb_file.c | 149 + drivers/misc/dlb/dlb_hw_types.h | 311 + drivers/misc/dlb/dlb_ioctl.c | 498 ++ drivers/misc/dlb/dlb_main.c | 614 ++ drivers/misc/dlb/dlb_main.h | 178 + drivers/misc/dlb/dlb_pf_ops.c | 277 + drivers/misc/dlb/dlb_regs.h | 3640 +++++++++++ drivers/misc/dlb/dlb_resource.c | 5469 +++++++++++++++++ drivers/misc/dlb/dlb_resource.h | 94 + include/uapi/linux/dlb.h | 602 ++ 19 files changed, 12342 insertions(+) create mode 100644 Documentation/misc-devices/dlb.rst create mode 100644 drivers/misc/dlb/Kconfig create mode 100644 drivers/misc/dlb/Makefile create mode 100644 drivers/misc/dlb/dlb_bitmap.h create mode 100644 drivers/misc/dlb/dlb_file.c create mode 100644 drivers/misc/dlb/dlb_hw_types.h create mode 100644 drivers/misc/dlb/dlb_ioctl.c create mode 100644 drivers/misc/dlb/dlb_main.c create mode 100644 drivers/misc/dlb/dlb_main.h create mode 100644 drivers/misc/dlb/dlb_pf_ops.c create mode 100644 drivers/misc/dlb/dlb_regs.h create mode 100644 drivers/misc/dlb/dlb_resource.c create mode 100644 drivers/misc/dlb/dlb_resource.h create mode 100644 include/uapi/linux/dlb.h base-commit: e71ba9452f0b5b2e8dc8aa5445198cd9214a6a62 -- 2.17.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls 2021-01-22 19:01 [PATCH v9 00/20] dlb: introduce DLB device driver Mike Ximing Chen @ 2021-01-22 19:01 ` Mike Ximing Chen 2021-01-27 1:25 ` kernel test robot 2021-01-27 12:29 ` Greg KH 0 siblings, 2 replies; 8+ messages in thread From: Mike Ximing Chen @ 2021-01-22 19:01 UTC (permalink / raw) To: linux-kernel Cc: arnd, gregkh, dan.j.williams, pierre-louis.bossart, Gage Eads Introduce the dlb device ioctl layer and the first three ioctls: query device version, query available resources, and create a scheduling domain. Also introduce the user-space interface file dlb_user.h. The device version query is designed to allow each DLB device version/type to have its own unique ioctl API through the /dev/dlb%d node. Each such API would share in common the device version command as its first command, and all subsequent commands can be unique to the particular device. The hardware operation for scheduling domain creation will be added in a subsequent commit. Signed-off-by: Gage Eads <gage.eads@intel.com> Signed-off-by: Mike Ximing Chen <mike.ximing.chen@intel.com> Reviewed-by: Magnus Karlsson <magnus.karlsson@intel.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> --- .../userspace-api/ioctl/ioctl-number.rst | 1 + drivers/misc/dlb/Makefile | 2 +- drivers/misc/dlb/dlb_bitmap.h | 32 ++++ drivers/misc/dlb/dlb_ioctl.c | 103 +++++++++++ drivers/misc/dlb/dlb_main.c | 1 + drivers/misc/dlb/dlb_main.h | 10 ++ drivers/misc/dlb/dlb_pf_ops.c | 22 +++ drivers/misc/dlb/dlb_resource.c | 62 +++++++ drivers/misc/dlb/dlb_resource.h | 4 + include/uapi/linux/dlb.h | 167 ++++++++++++++++++ 10 files changed, 403 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/dlb/dlb_ioctl.c create mode 100644 include/uapi/linux/dlb.h diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst index a4c75a28c839..747b48b141c8 100644 --- a/Documentation/userspace-api/ioctl/ioctl-number.rst +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst @@ -300,6 +300,7 @@ Code Seq# Include File Comments 'z' 10-4F drivers/s390/crypto/zcrypt_api.h conflict! '|' 00-7F linux/media.h 0x80 00-1F linux/fb.h +0x81 00-1F uapi/linux/dlb.h 0x89 00-06 arch/x86/include/asm/sockios.h 0x89 0B-DF linux/sockios.h 0x89 E0-EF linux/sockios.h SIOCPROTOPRIVATE range diff --git a/drivers/misc/dlb/Makefile b/drivers/misc/dlb/Makefile index 8a49ea5fd752..aaafb3086d8d 100644 --- a/drivers/misc/dlb/Makefile +++ b/drivers/misc/dlb/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_INTEL_DLB) := dlb.o dlb-objs := dlb_main.o -dlb-objs += dlb_pf_ops.o dlb_resource.o +dlb-objs += dlb_pf_ops.o dlb_resource.o dlb_ioctl.o diff --git a/drivers/misc/dlb/dlb_bitmap.h b/drivers/misc/dlb/dlb_bitmap.h index fb3ef52a306d..3ea78b42c79f 100644 --- a/drivers/misc/dlb/dlb_bitmap.h +++ b/drivers/misc/dlb/dlb_bitmap.h @@ -73,4 +73,36 @@ static inline void dlb_bitmap_free(struct dlb_bitmap *bitmap) kfree(bitmap); } +/** + * dlb_bitmap_longest_set_range() - returns longest contiguous range of set + * bits + * @bitmap: pointer to dlb_bitmap structure. + * + * Return: + * Returns the bitmap's longest contiguous range of set bits upon success, + * <0 otherwise. + * + * Errors: + * EINVAL - bitmap is NULL or is uninitialized. + */ +static inline int dlb_bitmap_longest_set_range(struct dlb_bitmap *bitmap) +{ + int max_len, len; + int start, end; + + if (!bitmap || !bitmap->map) + return -EINVAL; + + if (bitmap_weight(bitmap->map, bitmap->len) == 0) + return 0; + + max_len = 0; + bitmap_for_each_set_region(bitmap->map, start, end, 0, bitmap->len) { + len = end - start; + if (max_len < len) + max_len = len; + } + return max_len; +} + #endif /* __DLB_OSDEP_BITMAP_H */ diff --git a/drivers/misc/dlb/dlb_ioctl.c b/drivers/misc/dlb/dlb_ioctl.c new file mode 100644 index 000000000000..47d6cab773d4 --- /dev/null +++ b/drivers/misc/dlb/dlb_ioctl.c @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright(C) 2016-2020 Intel Corporation. All rights reserved. */ + +#include <linux/uaccess.h> + +#include <uapi/linux/dlb.h> + +#include "dlb_main.h" + +/* [7:0]: device revision, [15:8]: device version */ +#define DLB_SET_DEVICE_VERSION(ver, rev) (((ver) << 8) | (rev)) + +static int dlb_ioctl_get_device_version(unsigned long user_arg) +{ + struct dlb_get_device_version_args arg; + u8 revision; + + switch (boot_cpu_data.x86_stepping) { + case 0: + revision = DLB_REV_A0; + break; + case 1: + revision = DLB_REV_A1; + break; + case 2: + revision = DLB_REV_A2; + break; + default: + /* Treat all revisions >= 3 as B0 */ + revision = DLB_REV_B0; + break; + } + + arg.response.status = 0; + arg.response.id = DLB_SET_DEVICE_VERSION(2, revision); + + if (copy_to_user((void __user *)user_arg, &arg, sizeof(arg))) + return -EFAULT; + + return 0; +} + +static int dlb_ioctl_create_sched_domain(struct dlb *dlb, unsigned long user_arg) +{ + struct dlb_create_sched_domain_args __user *uarg; + struct dlb_create_sched_domain_args arg; + struct dlb_cmd_response response = {0}; + int ret; + + uarg = (void __user *)user_arg; + if (copy_from_user(&arg, uarg, sizeof(arg))) + return -EFAULT; + + mutex_lock(&dlb->resource_mutex); + + ret = dlb->ops->create_sched_domain(&dlb->hw, &arg, &response); + + mutex_unlock(&dlb->resource_mutex); + + response.status = ret; + BUILD_BUG_ON(offsetof(typeof(arg), response) != 0); + + if (copy_to_user((void __user *)&uarg->response, &response, sizeof(response))) + return -EFAULT; + + return ret; +} + +static int dlb_ioctl_get_num_resources(struct dlb *dlb, unsigned long user_arg) +{ + struct dlb_get_num_resources_args arg = {0}; + int ret; + + mutex_lock(&dlb->resource_mutex); + + ret = dlb->ops->get_num_resources(&dlb->hw, &arg); + + mutex_unlock(&dlb->resource_mutex); + + BUILD_BUG_ON(offsetof(typeof(arg), response) != 0); + arg.response.status = ret; + + if (copy_to_user((void __user *)user_arg, &arg, sizeof(arg))) + return -EFAULT; + + return ret; +} + +long dlb_ioctl(struct file *f, unsigned int cmd, unsigned long arg) +{ + struct dlb *dlb = f->private_data; + + switch (cmd) { + case DLB_IOC_GET_DEVICE_VERSION: + return dlb_ioctl_get_device_version(arg); + case DLB_IOC_CREATE_SCHED_DOMAIN: + return dlb_ioctl_create_sched_domain(dlb, arg); + case DLB_IOC_GET_NUM_RESOURCES: + return dlb_ioctl_get_num_resources(dlb, arg); + default: + return -ENOTTY; + } +} diff --git a/drivers/misc/dlb/dlb_main.c b/drivers/misc/dlb/dlb_main.c index 12707b23ab3e..d92956b1643d 100644 --- a/drivers/misc/dlb/dlb_main.c +++ b/drivers/misc/dlb/dlb_main.c @@ -64,6 +64,7 @@ static int dlb_device_create(struct dlb *dlb, struct pci_dev *pdev) static const struct file_operations dlb_fops = { .owner = THIS_MODULE, + .unlocked_ioctl = dlb_ioctl, }; /**********************************/ diff --git a/drivers/misc/dlb/dlb_main.h b/drivers/misc/dlb/dlb_main.h index ec5eb7bd8f54..3089a66a3560 100644 --- a/drivers/misc/dlb/dlb_main.h +++ b/drivers/misc/dlb/dlb_main.h @@ -12,6 +12,8 @@ #include <linux/pci.h> #include <linux/types.h> +#include <uapi/linux/dlb.h> + #include "dlb_hw_types.h" /* @@ -37,6 +39,11 @@ struct dlb_device_ops { int (*init_driver_state)(struct dlb *dlb); void (*enable_pm)(struct dlb *dlb); int (*wait_for_device_ready)(struct dlb *dlb, struct pci_dev *pdev); + int (*create_sched_domain)(struct dlb_hw *hw, + struct dlb_create_sched_domain_args *args, + struct dlb_cmd_response *resp); + int (*get_num_resources)(struct dlb_hw *hw, + struct dlb_get_num_resources_args *args); }; extern struct dlb_device_ops dlb_pf_ops; @@ -56,4 +63,7 @@ struct dlb { dev_t dev_number; }; +/* Prototypes for dlb_ioctl.c */ +long dlb_ioctl(struct file *f, unsigned int cmd, unsigned long arg); + #endif /* __DLB_MAIN_H */ diff --git a/drivers/misc/dlb/dlb_pf_ops.c b/drivers/misc/dlb/dlb_pf_ops.c index 124b4fee8564..125ef6fe6c70 100644 --- a/drivers/misc/dlb/dlb_pf_ops.c +++ b/drivers/misc/dlb/dlb_pf_ops.c @@ -95,6 +95,26 @@ static int dlb_pf_wait_for_device_ready(struct dlb *dlb, struct pci_dev *pdev) return 0; } +/*****************************/ +/****** IOCTL callbacks ******/ +/*****************************/ + +static int dlb_pf_create_sched_domain(struct dlb_hw *hw, + struct dlb_create_sched_domain_args *args, + struct dlb_cmd_response *resp) +{ + resp->id = 0; + resp->status = 0; + + return 0; +} + +static int dlb_pf_get_num_resources(struct dlb_hw *hw, + struct dlb_get_num_resources_args *args) +{ + return dlb_hw_get_num_resources(hw, args, false, 0); +} + /********************************/ /****** DLB PF Device Ops ******/ /********************************/ @@ -105,4 +125,6 @@ struct dlb_device_ops dlb_pf_ops = { .init_driver_state = dlb_pf_init_driver_state, .enable_pm = dlb_pf_enable_pm, .wait_for_device_ready = dlb_pf_wait_for_device_ready, + .create_sched_domain = dlb_pf_create_sched_domain, + .get_num_resources = dlb_pf_get_num_resources, }; diff --git a/drivers/misc/dlb/dlb_resource.c b/drivers/misc/dlb/dlb_resource.c index fca444c46aca..9d75b12eb793 100644 --- a/drivers/misc/dlb/dlb_resource.c +++ b/drivers/misc/dlb/dlb_resource.c @@ -200,6 +200,68 @@ int dlb_resource_init(struct dlb_hw *hw) return ret; } +/** + * dlb_hw_get_num_resources() - query the PCI function's available resources + * @hw: dlb_hw handle for a particular device. + * @arg: pointer to resource counts. + * @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 returns the number of available resources for the PF or for a + * VF. + * + * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual + * device. + * + * Return: + * Returns 0 upon success, -EINVAL if vdev_req is true and vdev_id is + * invalid. + */ +int dlb_hw_get_num_resources(struct dlb_hw *hw, + struct dlb_get_num_resources_args *arg, + bool vdev_req, unsigned int vdev_id) +{ + struct dlb_function_resources *rsrcs; + struct dlb_bitmap *map; + int i; + + if (vdev_req && vdev_id >= DLB_MAX_NUM_VDEVS) + return -EINVAL; + + if (vdev_req) + rsrcs = &hw->vdev[vdev_id]; + else + rsrcs = &hw->pf; + + arg->num_sched_domains = rsrcs->num_avail_domains; + + arg->num_ldb_queues = rsrcs->num_avail_ldb_queues; + + arg->num_ldb_ports = 0; + for (i = 0; i < DLB_NUM_COS_DOMAINS; i++) + arg->num_ldb_ports += rsrcs->num_avail_ldb_ports[i]; + + for (i = 0; i < DLB_NUM_COS_DOMAINS; i++) + arg->num_cos_ldb_ports[i] = rsrcs->num_avail_ldb_ports[i]; + + arg->num_dir_ports = rsrcs->num_avail_dir_pq_pairs; + + arg->num_atomic_inflights = rsrcs->num_avail_aqed_entries; + + map = rsrcs->avail_hist_list_entries; + + arg->num_hist_list_entries = bitmap_weight(map->map, map->len); + + arg->max_contiguous_hist_list_entries = + dlb_bitmap_longest_set_range(map); + + arg->num_ldb_credits = rsrcs->num_avail_qed_entries; + + arg->num_dir_credits = rsrcs->num_avail_dqed_entries; + + return 0; +} + /** * dlb_clr_pmcsr_disable() - power on bulk of DLB 2.0 logic * @hw: dlb_hw handle for a particular device. diff --git a/drivers/misc/dlb/dlb_resource.h b/drivers/misc/dlb/dlb_resource.h index 2229813d9c45..3e6d419796bc 100644 --- a/drivers/misc/dlb/dlb_resource.h +++ b/drivers/misc/dlb/dlb_resource.h @@ -12,6 +12,10 @@ int dlb_resource_init(struct dlb_hw *hw); void dlb_resource_free(struct dlb_hw *hw); +int dlb_hw_get_num_resources(struct dlb_hw *hw, + struct dlb_get_num_resources_args *arg, + bool vdev_req, unsigned int vdev_id); + void dlb_clr_pmcsr_disable(struct dlb_hw *hw); #endif /* __DLB_RESOURCE_H */ diff --git a/include/uapi/linux/dlb.h b/include/uapi/linux/dlb.h new file mode 100644 index 000000000000..b31c67de7fb4 --- /dev/null +++ b/include/uapi/linux/dlb.h @@ -0,0 +1,167 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(C) 2016-2020 Intel Corporation. All rights reserved. */ + +#ifndef __DLB_H +#define __DLB_H + +#include <linux/types.h> + +struct dlb_cmd_response { + __u32 status; /* Interpret using enum dlb_error */ + __u32 id; +}; + +/********************************/ +/* 'dlb' device file commands */ +/********************************/ + +#define DLB_DEVICE_VERSION(x) (((x) >> 8) & 0xFF) +#define DLB_DEVICE_REVISION(x) ((x) & 0xFF) + +enum dlb_revisions { + DLB_REV_A0 = 0, + DLB_REV_A1, + DLB_REV_A2, + DLB_REV_B0, +}; + +/* + * DLB_CMD_GET_DEVICE_VERSION: Query the DLB device version. + * + * All DLB device versions have the same ioctl API. Each version may have + * different resource and feature set. The device revision is provided + * in case of any hardware errata. + * + * 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. + * @response.id[7:0]: Device revision. + * @response.id[15:8]: Device version. + */ + +struct dlb_get_device_version_args { + /* Output parameters */ + struct dlb_cmd_response response; +}; + +/* + * DLB_CMD_CREATE_SCHED_DOMAIN: Create a DLB 2.0 scheduling domain and reserve + * its hardware resources. This command returns the newly created domain + * ID and a file descriptor for accessing the domain. + * + * 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. + * @response.id: domain ID. + * @domain_fd: file descriptor for performing the domain's ioctl operations + * @padding0: Reserved for future use. + * + * Input parameters: + * @num_ldb_queues: Number of load-balanced queues. + * @num_ldb_ports: Number of load-balanced ports that can be allocated from + * any class-of-service with available ports. + * @num_cos_ldb_ports[4]: Number of load-balanced ports from + * classes-of-service 0-3. + * @num_dir_ports: Number of directed ports. A directed port has one directed + * queue, so no num_dir_queues argument is necessary. + * @num_atomic_inflights: This specifies the amount of temporary atomic QE + * storage for the domain. This storage is divided among the domain's + * load-balanced queues that are configured for atomic scheduling. + * @num_hist_list_entries: Amount of history list storage. This is divided + * among the domain's CQs. + * @num_ldb_credits: Amount of load-balanced QE storage (QED). QEs occupy this + * space until they are scheduled to a load-balanced CQ. One credit + * represents the storage for one QE. + * @num_dir_credits: Amount of directed QE storage (DQED). QEs occupy this + * space until they are scheduled to a directed CQ. One credit represents + * the storage for one QE. + * @cos_strict: If set, return an error if there are insufficient ports in + * class-of-service N to satisfy the num_ldb_ports_cosN argument. If + * unset, attempt to fulfill num_ldb_ports_cosN arguments from other + * classes-of-service if class N does not contain enough free ports. + * @padding1: Reserved for future use. + */ +struct dlb_create_sched_domain_args { + /* Output parameters */ + struct dlb_cmd_response response; + __u32 domain_fd; + __u32 padding0; + /* Input parameters */ + __u32 num_ldb_queues; + __u32 num_ldb_ports; + __u32 num_cos_ldb_ports[4]; + __u32 num_dir_ports; + __u32 num_atomic_inflights; + __u32 num_hist_list_entries; + __u32 num_ldb_credits; + __u32 num_dir_credits; + __u8 cos_strict; + __u8 padding1[3]; +}; + +/* + * DLB_CMD_GET_NUM_RESOURCES: Return the number of available resources + * (queues, ports, etc.) that this device owns. + * + * 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. + * @num_domains: Number of available scheduling domains. + * @num_ldb_queues: Number of available load-balanced queues. + * @num_ldb_ports: Total number of available load-balanced ports. + * @num_cos_ldb_ports[4]: Number of available load-balanced ports from + * classes-of-service 0-3. + * @num_dir_ports: Number of available directed ports. There is one directed + * queue for every directed port. + * @num_atomic_inflights: Amount of available temporary atomic QE storage. + * @num_hist_list_entries: Amount of history list storage. + * @max_contiguous_hist_list_entries: History list storage is allocated in + * a contiguous chunk, and this return value is the longest available + * contiguous range of history list entries. + * @num_ldb_credits: Amount of available load-balanced QE storage. + * @num_dir_credits: Amount of available directed QE storage. + */ +struct dlb_get_num_resources_args { + /* Output parameters */ + struct dlb_cmd_response response; + __u32 num_sched_domains; + __u32 num_ldb_queues; + __u32 num_ldb_ports; + __u32 num_cos_ldb_ports[4]; + __u32 num_dir_ports; + __u32 num_atomic_inflights; + __u32 num_hist_list_entries; + __u32 max_contiguous_hist_list_entries; + __u32 num_ldb_credits; + __u32 num_dir_credits; +}; + +enum dlb_user_interface_commands { + DLB_CMD_GET_DEVICE_VERSION, + DLB_CMD_CREATE_SCHED_DOMAIN, + DLB_CMD_GET_NUM_RESOURCES, + + /* NUM_DLB_CMD must be last */ + NUM_DLB_CMD, +}; + +/********************/ +/* dlb ioctl codes */ +/********************/ + +#define DLB_IOC_MAGIC 0x81 + +#define DLB_IOC_GET_DEVICE_VERSION \ + _IOR(DLB_IOC_MAGIC, \ + DLB_CMD_GET_DEVICE_VERSION, \ + struct dlb_get_device_version_args) +#define DLB_IOC_CREATE_SCHED_DOMAIN \ + _IOWR(DLB_IOC_MAGIC, \ + DLB_CMD_CREATE_SCHED_DOMAIN, \ + struct dlb_create_sched_domain_args) +#define DLB_IOC_GET_NUM_RESOURCES \ + _IOR(DLB_IOC_MAGIC, \ + DLB_CMD_GET_NUM_RESOURCES, \ + struct dlb_get_num_resources_args) + +#endif /* __DLB_H */ -- 2.17.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls 2021-01-22 19:01 ` [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls Mike Ximing Chen @ 2021-01-27 1:25 ` kernel test robot 2021-01-27 12:29 ` Greg KH 1 sibling, 0 replies; 8+ messages in thread From: kernel test robot @ 2021-01-27 1:25 UTC (permalink / raw) To: Mike Ximing Chen, linux-kernel Cc: kbuild-all, arnd, gregkh, dan.j.williams, pierre-louis.bossart, Gage Eads [-- Attachment #1: Type: text/plain, Size: 1851 bytes --] Hi Mike, I love your patch! Yet something to improve: [auto build test ERROR on soc/arm/dt] [also build test ERROR on linus/master char-misc/char-misc-testing linux/master soc/for-next v5.11-rc5 next-20210125] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Mike-Ximing-Chen/dlb-introduce-DLB-device-driver/20210125-155257 base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git arm/dt config: x86_64-rhel (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/693738625d24e95e7cf8f92c937f5981b3dad3d9 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Mike-Ximing-Chen/dlb-introduce-DLB-device-driver/20210125-155257 git checkout 693738625d24e95e7cf8f92c937f5981b3dad3d9 # save the attached .config to linux build tree make W=1 ARCH=x86_64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> error: include/uapi/linux/dlb.h: missing "WITH Linux-syscall-note" for SPDX-License-Identifier make[2]: *** [scripts/Makefile.headersinst:63: usr/include/linux/dlb.h] Error 1 make[2]: Target '__headers' not remade because of errors. make[1]: *** [Makefile:1294: headers] Error 2 make[1]: Target 'headers_install' not remade because of errors. make: *** [Makefile:185: __sub-make] Error 2 make: Target 'headers_install' not remade because of errors. --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 45962 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls @ 2021-01-27 1:25 ` kernel test robot 0 siblings, 0 replies; 8+ messages in thread From: kernel test robot @ 2021-01-27 1:25 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 1891 bytes --] Hi Mike, I love your patch! Yet something to improve: [auto build test ERROR on soc/arm/dt] [also build test ERROR on linus/master char-misc/char-misc-testing linux/master soc/for-next v5.11-rc5 next-20210125] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Mike-Ximing-Chen/dlb-introduce-DLB-device-driver/20210125-155257 base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git arm/dt config: x86_64-rhel (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/693738625d24e95e7cf8f92c937f5981b3dad3d9 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Mike-Ximing-Chen/dlb-introduce-DLB-device-driver/20210125-155257 git checkout 693738625d24e95e7cf8f92c937f5981b3dad3d9 # save the attached .config to linux build tree make W=1 ARCH=x86_64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> error: include/uapi/linux/dlb.h: missing "WITH Linux-syscall-note" for SPDX-License-Identifier make[2]: *** [scripts/Makefile.headersinst:63: usr/include/linux/dlb.h] Error 1 make[2]: Target '__headers' not remade because of errors. make[1]: *** [Makefile:1294: headers] Error 2 make[1]: Target 'headers_install' not remade because of errors. make: *** [Makefile:185: __sub-make] Error 2 make: Target 'headers_install' not remade because of errors. --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 45962 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls 2021-01-22 19:01 ` [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls Mike Ximing Chen 2021-01-27 1:25 ` kernel test robot @ 2021-01-27 12:29 ` Greg KH 2021-01-27 13:59 ` Chen, Mike Ximing 1 sibling, 1 reply; 8+ messages in thread From: Greg KH @ 2021-01-27 12:29 UTC (permalink / raw) To: Mike Ximing Chen Cc: linux-kernel, arnd, dan.j.williams, pierre-louis.bossart, Gage Eads On Fri, Jan 22, 2021 at 01:01:22PM -0600, Mike Ximing Chen wrote: > --- /dev/null > +++ b/include/uapi/linux/dlb.h > @@ -0,0 +1,167 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ As the bot points out, this is an "odd" license for a uapi .h file, are you SURE about this? If so, I need an Intel lawyer's signed-off-by on it as well, so we know to talk to in the future about it. thanks, greg k-h ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls 2021-01-27 12:29 ` Greg KH @ 2021-01-27 13:59 ` Chen, Mike Ximing 2021-01-27 14:03 ` Greg KH 0 siblings, 1 reply; 8+ messages in thread From: Chen, Mike Ximing @ 2021-01-27 13:59 UTC (permalink / raw) To: Greg KH; +Cc: linux-kernel, arnd, Williams, Dan J, pierre-louis.bossart > -----Original Message----- > From: Greg KH <gregkh@linuxfoundation.org> > Sent: Wednesday, January 27, 2021 7:29 AM > To: Chen, Mike Ximing <mike.ximing.chen@intel.com> > Cc: linux-kernel@vger.kernel.org; arnd@arndb.de; Williams, Dan J > <dan.j.williams@intel.com>; pierre-louis.bossart@linux.intel.com; Gage Eads > <gage.eads@intel.com> > Subject: Re: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls > > On Fri, Jan 22, 2021 at 01:01:22PM -0600, Mike Ximing Chen wrote: > > --- /dev/null > > +++ b/include/uapi/linux/dlb.h > > @@ -0,0 +1,167 @@ > > +/* SPDX-License-Identifier: GPL-2.0-only */ > > As the bot points out, this is an "odd" license for a uapi .h file, are > you SURE about this? > > If so, I need an Intel lawyer's signed-off-by on it as well, so we know > to talk to in the future about it. > > thanks, > > greg k-h Sorry, it should be "GPL-2.0-only WITH Linux-syscall-note". Should I correct it and submit a new patch set (v10) now, or wait for more feedback on the current patch set? Thanks Mike ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls 2021-01-27 13:59 ` Chen, Mike Ximing @ 2021-01-27 14:03 ` Greg KH 2021-01-27 23:15 ` Chen, Mike Ximing 0 siblings, 1 reply; 8+ messages in thread From: Greg KH @ 2021-01-27 14:03 UTC (permalink / raw) To: Chen, Mike Ximing Cc: linux-kernel, arnd, Williams, Dan J, pierre-louis.bossart On Wed, Jan 27, 2021 at 01:59:50PM +0000, Chen, Mike Ximing wrote: > > > -----Original Message----- > > From: Greg KH <gregkh@linuxfoundation.org> > > Sent: Wednesday, January 27, 2021 7:29 AM > > To: Chen, Mike Ximing <mike.ximing.chen@intel.com> > > Cc: linux-kernel@vger.kernel.org; arnd@arndb.de; Williams, Dan J > > <dan.j.williams@intel.com>; pierre-louis.bossart@linux.intel.com; Gage Eads > > <gage.eads@intel.com> > > Subject: Re: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls > > > > On Fri, Jan 22, 2021 at 01:01:22PM -0600, Mike Ximing Chen wrote: > > > --- /dev/null > > > +++ b/include/uapi/linux/dlb.h > > > @@ -0,0 +1,167 @@ > > > +/* SPDX-License-Identifier: GPL-2.0-only */ > > > > As the bot points out, this is an "odd" license for a uapi .h file, are > > you SURE about this? > > > > If so, I need an Intel lawyer's signed-off-by on it as well, so we know > > to talk to in the future about it. > > > > thanks, > > > > greg k-h > > Sorry, it should be "GPL-2.0-only WITH Linux-syscall-note". > Should I correct it and submit a new patch set (v10) now, or wait for more feedback on the current patch set? Please consult your corporate lawyers when picking licenses for your kernel files. I doubt they want me telling you what to do :) good luck! greg k-h ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls 2021-01-27 14:03 ` Greg KH @ 2021-01-27 23:15 ` Chen, Mike Ximing 0 siblings, 0 replies; 8+ messages in thread From: Chen, Mike Ximing @ 2021-01-27 23:15 UTC (permalink / raw) To: Greg KH; +Cc: linux-kernel, arnd, Williams, Dan J, pierre-louis.bossart > -----Original Message----- > From: Greg KH <gregkh@linuxfoundation.org> > Sent: Wednesday, January 27, 2021 9:04 AM > To: Chen, Mike Ximing <mike.ximing.chen@intel.com> > Cc: linux-kernel@vger.kernel.org; arnd@arndb.de; Williams, Dan J > <dan.j.williams@intel.com>; pierre-louis.bossart@linux.intel.com > Subject: Re: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls > > On Wed, Jan 27, 2021 at 01:59:50PM +0000, Chen, Mike Ximing wrote: > > > > > -----Original Message----- > > > From: Greg KH <gregkh@linuxfoundation.org> > > > Sent: Wednesday, January 27, 2021 7:29 AM > > > To: Chen, Mike Ximing <mike.ximing.chen@intel.com> > > > Cc: linux-kernel@vger.kernel.org; arnd@arndb.de; Williams, Dan J > > > <dan.j.williams@intel.com>; pierre-louis.bossart@linux.intel.com; Gage Eads > > > <gage.eads@intel.com> > > > Subject: Re: [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls > > > > > > On Fri, Jan 22, 2021 at 01:01:22PM -0600, Mike Ximing Chen wrote: > > > > --- /dev/null > > > > +++ b/include/uapi/linux/dlb.h > > > > @@ -0,0 +1,167 @@ > > > > +/* SPDX-License-Identifier: GPL-2.0-only */ > > > > > > As the bot points out, this is an "odd" license for a uapi .h file, are > > > you SURE about this? > > > > > > If so, I need an Intel lawyer's signed-off-by on it as well, so we know > > > to talk to in the future about it. > > > > > > thanks, > > > > > > greg k-h > > > > Sorry, it should be "GPL-2.0-only WITH Linux-syscall-note". > > Should I correct it and submit a new patch set (v10) now, or wait for more > feedback on the current patch set? > > Please consult your corporate lawyers when picking licenses for your > kernel files. I doubt they want me telling you what to do :) > > good luck! > > greg k-h OK. I submitted a new patch set (v10) with the fix on license. Thanks for the help. Mike ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-01-28 15:38 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-01-28 15:38 [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls Chen, Mike Ximing -- strict thread matches above, loose matches on Subject: below -- 2021-01-22 19:01 [PATCH v9 00/20] dlb: introduce DLB device driver Mike Ximing Chen 2021-01-22 19:01 ` [PATCH v9 04/20] dlb: add device ioctl layer and first three ioctls Mike Ximing Chen 2021-01-27 1:25 ` kernel test robot 2021-01-27 1:25 ` kernel test robot 2021-01-27 12:29 ` Greg KH 2021-01-27 13:59 ` Chen, Mike Ximing 2021-01-27 14:03 ` Greg KH 2021-01-27 23:15 ` Chen, Mike Ximing
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.