15433956dSTimothy McDaniel /* SPDX-License-Identifier: BSD-3-Clause 25433956dSTimothy McDaniel * Copyright(c) 2016-2020 Intel Corporation 35433956dSTimothy McDaniel */ 45433956dSTimothy McDaniel 55433956dSTimothy McDaniel #ifndef __DLB2_RESOURCE_H 65433956dSTimothy McDaniel #define __DLB2_RESOURCE_H 75433956dSTimothy McDaniel 85433956dSTimothy McDaniel #include "dlb2_user.h" 95433956dSTimothy McDaniel #include "dlb2_osdep_types.h" 105433956dSTimothy McDaniel 115433956dSTimothy McDaniel /** 12dfdd11a8STimothy McDaniel * dlb2_resource_init() - initialize the device 13dfdd11a8STimothy McDaniel * @hw: pointer to struct dlb2_hw. 14dfdd11a8STimothy McDaniel * @ver: device version. 15dfdd11a8STimothy McDaniel * 16dfdd11a8STimothy McDaniel * This function initializes the device's software state (pointed to by the hw 17dfdd11a8STimothy McDaniel * argument) and programs global scheduling QoS registers. This function should 18dfdd11a8STimothy McDaniel * be called during driver initialization. 19dfdd11a8STimothy McDaniel * 20dfdd11a8STimothy McDaniel * The dlb2_hw struct must be unique per DLB 2.0 device and persist until the 21dfdd11a8STimothy McDaniel * device is reset. 22dfdd11a8STimothy McDaniel * 23dfdd11a8STimothy McDaniel * Return: 24dfdd11a8STimothy McDaniel * Returns 0 upon success, <0 otherwise. 25dfdd11a8STimothy McDaniel */ 26*8d1d9070SAbdullah Sevincer int dlb2_resource_init(struct dlb2_hw *hw, enum dlb2_hw_ver ver, const void *probe_args); 27*8d1d9070SAbdullah Sevincer 28*8d1d9070SAbdullah Sevincer /** 29*8d1d9070SAbdullah Sevincer * dlb2_resource_probe() - probe hw resources 30*8d1d9070SAbdullah Sevincer * @hw: pointer to struct dlb2_hw. 31*8d1d9070SAbdullah Sevincer * 32*8d1d9070SAbdullah Sevincer * This function probes hw resources for best port allocation to producer 33*8d1d9070SAbdullah Sevincer * cores. 34*8d1d9070SAbdullah Sevincer * 35*8d1d9070SAbdullah Sevincer * Return: 36*8d1d9070SAbdullah Sevincer * Returns 0 upon success, <0 otherwise. 37*8d1d9070SAbdullah Sevincer */ 38*8d1d9070SAbdullah Sevincer int dlb2_resource_probe(struct dlb2_hw *hw, const void *probe_args); 39*8d1d9070SAbdullah Sevincer 40dfdd11a8STimothy McDaniel 41dfdd11a8STimothy McDaniel /** 42dfdd11a8STimothy McDaniel * dlb2_clr_pmcsr_disable() - power on bulk of DLB 2.0 logic 43dfdd11a8STimothy McDaniel * @hw: dlb2_hw handle for a particular device. 44dfdd11a8STimothy McDaniel * @ver: device version. 45dfdd11a8STimothy McDaniel * 46dfdd11a8STimothy McDaniel * Clearing the PMCSR must be done at initialization to make the device fully 47dfdd11a8STimothy McDaniel * operational. 48dfdd11a8STimothy McDaniel */ 49dfdd11a8STimothy McDaniel void dlb2_clr_pmcsr_disable(struct dlb2_hw *hw, enum dlb2_hw_ver ver); 50dfdd11a8STimothy McDaniel 51dfdd11a8STimothy McDaniel /** 52dfdd11a8STimothy McDaniel * dlb2_resource_free() - free device state memory 53dfdd11a8STimothy McDaniel * @hw: dlb2_hw handle for a particular device. 54dfdd11a8STimothy McDaniel * 55dfdd11a8STimothy McDaniel * This function frees software state pointed to by dlb2_hw. This function 56dfdd11a8STimothy McDaniel * should be called when resetting the device or unloading the driver. 57dfdd11a8STimothy McDaniel */ 58dfdd11a8STimothy McDaniel void dlb2_resource_free(struct dlb2_hw *hw); 59dfdd11a8STimothy McDaniel 60dfdd11a8STimothy McDaniel /** 615433956dSTimothy McDaniel * dlb2_resource_reset() - reset in-use resources to their initial state 625433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 635433956dSTimothy McDaniel * 645433956dSTimothy McDaniel * This function resets in-use resources, and makes them available for use. 655433956dSTimothy McDaniel * All resources go back to their owning function, whether a PF or a VF. 665433956dSTimothy McDaniel */ 675433956dSTimothy McDaniel void dlb2_resource_reset(struct dlb2_hw *hw); 685433956dSTimothy McDaniel 695433956dSTimothy McDaniel /** 705433956dSTimothy McDaniel * dlb2_hw_create_sched_domain() - create a scheduling domain 715433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 725433956dSTimothy McDaniel * @args: scheduling domain creation arguments. 735433956dSTimothy McDaniel * @resp: response structure. 745433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 755433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 765433956dSTimothy McDaniel * 775433956dSTimothy McDaniel * This function creates a scheduling domain containing the resources specified 785433956dSTimothy McDaniel * in args. The individual resources (queues, ports, credits) can be configured 795433956dSTimothy McDaniel * after creating a scheduling domain. 805433956dSTimothy McDaniel * 815433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 825433956dSTimothy McDaniel * device. 835433956dSTimothy McDaniel * 845433956dSTimothy McDaniel * Return: 855433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 865433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. If successful, resp->id 875433956dSTimothy McDaniel * contains the domain ID. 885433956dSTimothy McDaniel * 895433956dSTimothy McDaniel * resp->id contains a virtual ID if vdev_request is true. 905433956dSTimothy McDaniel * 915433956dSTimothy McDaniel * Errors: 925433956dSTimothy McDaniel * EINVAL - A requested resource is unavailable, or the requested domain name 935433956dSTimothy McDaniel * is already in use. 945433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 955433956dSTimothy McDaniel */ 965433956dSTimothy McDaniel int dlb2_hw_create_sched_domain(struct dlb2_hw *hw, 975433956dSTimothy McDaniel struct dlb2_create_sched_domain_args *args, 985433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 995433956dSTimothy McDaniel bool vdev_request, 1005433956dSTimothy McDaniel unsigned int vdev_id); 1015433956dSTimothy McDaniel 1025433956dSTimothy McDaniel /** 1035433956dSTimothy McDaniel * dlb2_hw_create_ldb_queue() - create a load-balanced queue 1045433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 1055433956dSTimothy McDaniel * @domain_id: domain ID. 1065433956dSTimothy McDaniel * @args: queue creation arguments. 1075433956dSTimothy McDaniel * @resp: response structure. 1085433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 1095433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 1105433956dSTimothy McDaniel * 1115433956dSTimothy McDaniel * This function creates a load-balanced queue. 1125433956dSTimothy McDaniel * 1135433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1145433956dSTimothy McDaniel * device. 1155433956dSTimothy McDaniel * 1165433956dSTimothy McDaniel * Return: 1175433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 1185433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. If successful, resp->id 1195433956dSTimothy McDaniel * contains the queue ID. 1205433956dSTimothy McDaniel * 1215433956dSTimothy McDaniel * resp->id contains a virtual ID if vdev_request is true. 1225433956dSTimothy McDaniel * 1235433956dSTimothy McDaniel * Errors: 1245433956dSTimothy McDaniel * EINVAL - A requested resource is unavailable, the domain is not configured, 1255433956dSTimothy McDaniel * the domain has already been started, or the requested queue name is 1265433956dSTimothy McDaniel * already in use. 1275433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 1285433956dSTimothy McDaniel */ 1295433956dSTimothy McDaniel int dlb2_hw_create_ldb_queue(struct dlb2_hw *hw, 1305433956dSTimothy McDaniel u32 domain_id, 1315433956dSTimothy McDaniel struct dlb2_create_ldb_queue_args *args, 1325433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 1335433956dSTimothy McDaniel bool vdev_request, 1345433956dSTimothy McDaniel unsigned int vdev_id); 1355433956dSTimothy McDaniel 1365433956dSTimothy McDaniel /** 1375433956dSTimothy McDaniel * dlb2_hw_create_dir_queue() - create a directed queue 1385433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 1395433956dSTimothy McDaniel * @domain_id: domain ID. 1405433956dSTimothy McDaniel * @args: queue creation arguments. 1415433956dSTimothy McDaniel * @resp: response structure. 1425433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 1435433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 1445433956dSTimothy McDaniel * 1455433956dSTimothy McDaniel * This function creates a directed queue. 1465433956dSTimothy McDaniel * 1475433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1485433956dSTimothy McDaniel * device. 1495433956dSTimothy McDaniel * 1505433956dSTimothy McDaniel * Return: 1515433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 1525433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. If successful, resp->id 1535433956dSTimothy McDaniel * contains the queue ID. 1545433956dSTimothy McDaniel * 1555433956dSTimothy McDaniel * resp->id contains a virtual ID if vdev_request is true. 1565433956dSTimothy McDaniel * 1575433956dSTimothy McDaniel * Errors: 1585433956dSTimothy McDaniel * EINVAL - A requested resource is unavailable, the domain is not configured, 1595433956dSTimothy McDaniel * or the domain has already been started. 1605433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 1615433956dSTimothy McDaniel */ 1625433956dSTimothy McDaniel int dlb2_hw_create_dir_queue(struct dlb2_hw *hw, 1635433956dSTimothy McDaniel u32 domain_id, 1645433956dSTimothy McDaniel struct dlb2_create_dir_queue_args *args, 1655433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 1665433956dSTimothy McDaniel bool vdev_request, 1675433956dSTimothy McDaniel unsigned int vdev_id); 1685433956dSTimothy McDaniel 1695433956dSTimothy McDaniel /** 1705433956dSTimothy McDaniel * dlb2_hw_create_dir_port() - create a directed port 1715433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 1725433956dSTimothy McDaniel * @domain_id: domain ID. 1735433956dSTimothy McDaniel * @args: port creation arguments. 1745433956dSTimothy McDaniel * @cq_dma_base: base address of the CQ memory. This can be a PA or an IOVA. 1755433956dSTimothy McDaniel * @resp: response structure. 1765433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 1775433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 1785433956dSTimothy McDaniel * 1795433956dSTimothy McDaniel * This function creates a directed port. 1805433956dSTimothy McDaniel * 1815433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1825433956dSTimothy McDaniel * device. 1835433956dSTimothy McDaniel * 1845433956dSTimothy McDaniel * Return: 1855433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 1865433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. If successful, resp->id 1875433956dSTimothy McDaniel * contains the port ID. 1885433956dSTimothy McDaniel * 1895433956dSTimothy McDaniel * resp->id contains a virtual ID if vdev_request is true. 1905433956dSTimothy McDaniel * 1915433956dSTimothy McDaniel * Errors: 1925433956dSTimothy McDaniel * EINVAL - A requested resource is unavailable, a credit setting is invalid, a 1935433956dSTimothy McDaniel * pointer address is not properly aligned, the domain is not 1945433956dSTimothy McDaniel * configured, or the domain has already been started. 1955433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 1965433956dSTimothy McDaniel */ 1975433956dSTimothy McDaniel int dlb2_hw_create_dir_port(struct dlb2_hw *hw, 1985433956dSTimothy McDaniel u32 domain_id, 1995433956dSTimothy McDaniel struct dlb2_create_dir_port_args *args, 2005433956dSTimothy McDaniel uintptr_t cq_dma_base, 2015433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 2025433956dSTimothy McDaniel bool vdev_request, 2035433956dSTimothy McDaniel unsigned int vdev_id); 2045433956dSTimothy McDaniel 2055433956dSTimothy McDaniel /** 2065433956dSTimothy McDaniel * dlb2_hw_create_ldb_port() - create a load-balanced port 2075433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 2085433956dSTimothy McDaniel * @domain_id: domain ID. 2095433956dSTimothy McDaniel * @args: port creation arguments. 2105433956dSTimothy McDaniel * @cq_dma_base: base address of the CQ memory. This can be a PA or an IOVA. 2115433956dSTimothy McDaniel * @resp: response structure. 2125433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 2135433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 2145433956dSTimothy McDaniel * 2155433956dSTimothy McDaniel * This function creates a load-balanced port. 2165433956dSTimothy McDaniel * 2175433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 2185433956dSTimothy McDaniel * device. 2195433956dSTimothy McDaniel * 2205433956dSTimothy McDaniel * Return: 2215433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 2225433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. If successful, resp->id 2235433956dSTimothy McDaniel * contains the port ID. 2245433956dSTimothy McDaniel * 2255433956dSTimothy McDaniel * resp->id contains a virtual ID if vdev_request is true. 2265433956dSTimothy McDaniel * 2275433956dSTimothy McDaniel * Errors: 2285433956dSTimothy McDaniel * EINVAL - A requested resource is unavailable, a credit setting is invalid, a 2295433956dSTimothy McDaniel * pointer address is not properly aligned, the domain is not 2305433956dSTimothy McDaniel * configured, or the domain has already been started. 2315433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 2325433956dSTimothy McDaniel */ 2335433956dSTimothy McDaniel int dlb2_hw_create_ldb_port(struct dlb2_hw *hw, 2345433956dSTimothy McDaniel u32 domain_id, 2355433956dSTimothy McDaniel struct dlb2_create_ldb_port_args *args, 2365433956dSTimothy McDaniel uintptr_t cq_dma_base, 2375433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 2385433956dSTimothy McDaniel bool vdev_request, 2395433956dSTimothy McDaniel unsigned int vdev_id); 2405433956dSTimothy McDaniel 2415433956dSTimothy McDaniel /** 2425433956dSTimothy McDaniel * dlb2_hw_start_domain() - start a scheduling domain 2435433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 2445433956dSTimothy McDaniel * @domain_id: domain ID. 2455433956dSTimothy McDaniel * @args: start domain arguments. 2465433956dSTimothy McDaniel * @resp: response structure. 2475433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 2485433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 2495433956dSTimothy McDaniel * 2505433956dSTimothy McDaniel * This function starts a scheduling domain, which allows applications to send 2515433956dSTimothy McDaniel * traffic through it. Once a domain is started, its resources can no longer be 2525433956dSTimothy McDaniel * configured (besides QID remapping and port enable/disable). 2535433956dSTimothy McDaniel * 2545433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 2555433956dSTimothy McDaniel * device. 2565433956dSTimothy McDaniel * 2575433956dSTimothy McDaniel * Return: 2585433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 2595433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. 2605433956dSTimothy McDaniel * 2615433956dSTimothy McDaniel * Errors: 2625433956dSTimothy McDaniel * EINVAL - the domain is not configured, or the domain is already started. 2635433956dSTimothy McDaniel */ 2645433956dSTimothy McDaniel int dlb2_hw_start_domain(struct dlb2_hw *hw, 2655433956dSTimothy McDaniel u32 domain_id, 2665433956dSTimothy McDaniel struct dlb2_start_domain_args *args, 2675433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 2685433956dSTimothy McDaniel bool vdev_request, 2695433956dSTimothy McDaniel unsigned int vdev_id); 2705433956dSTimothy McDaniel 2715433956dSTimothy McDaniel /** 2725433956dSTimothy McDaniel * dlb2_hw_map_qid() - map a load-balanced queue to a load-balanced port 2735433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 2745433956dSTimothy McDaniel * @domain_id: domain ID. 2755433956dSTimothy McDaniel * @args: map QID arguments. 2765433956dSTimothy McDaniel * @resp: response structure. 2775433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 2785433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 2795433956dSTimothy McDaniel * 2805433956dSTimothy McDaniel * This function configures the DLB to schedule QEs from the specified queue 2815433956dSTimothy McDaniel * to the specified port. Each load-balanced port can be mapped to up to 8 2825433956dSTimothy McDaniel * queues; each load-balanced queue can potentially map to all the 2835433956dSTimothy McDaniel * load-balanced ports. 2845433956dSTimothy McDaniel * 2855433956dSTimothy McDaniel * A successful return does not necessarily mean the mapping was configured. If 2865433956dSTimothy McDaniel * this function is unable to immediately map the queue to the port, it will 2875433956dSTimothy McDaniel * add the requested operation to a per-port list of pending map/unmap 2885433956dSTimothy McDaniel * operations, and (if it's not already running) launch a kernel thread that 2895433956dSTimothy McDaniel * periodically attempts to process all pending operations. In a sense, this is 2905433956dSTimothy McDaniel * an asynchronous function. 2915433956dSTimothy McDaniel * 2925433956dSTimothy McDaniel * This asynchronicity creates two views of the state of hardware: the actual 2935433956dSTimothy McDaniel * hardware state and the requested state (as if every request completed 2945433956dSTimothy McDaniel * immediately). If there are any pending map/unmap operations, the requested 2955433956dSTimothy McDaniel * state will differ from the actual state. All validation is performed with 2965433956dSTimothy McDaniel * respect to the pending state; for instance, if there are 8 pending map 2975433956dSTimothy McDaniel * operations for port X, a request for a 9th will fail because a load-balanced 2985433956dSTimothy McDaniel * port can only map up to 8 queues. 2995433956dSTimothy McDaniel * 3005433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 3015433956dSTimothy McDaniel * device. 3025433956dSTimothy McDaniel * 3035433956dSTimothy McDaniel * Return: 3045433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 3055433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. 3065433956dSTimothy McDaniel * 3075433956dSTimothy McDaniel * Errors: 3085433956dSTimothy McDaniel * EINVAL - A requested resource is unavailable, invalid port or queue ID, or 3095433956dSTimothy McDaniel * the domain is not configured. 3105433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 3115433956dSTimothy McDaniel */ 3125433956dSTimothy McDaniel int dlb2_hw_map_qid(struct dlb2_hw *hw, 3135433956dSTimothy McDaniel u32 domain_id, 3145433956dSTimothy McDaniel struct dlb2_map_qid_args *args, 3155433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 3165433956dSTimothy McDaniel bool vdev_request, 3175433956dSTimothy McDaniel unsigned int vdev_id); 3185433956dSTimothy McDaniel 3195433956dSTimothy McDaniel /** 3205433956dSTimothy McDaniel * dlb2_hw_unmap_qid() - Unmap a load-balanced queue from a load-balanced port 3215433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 3225433956dSTimothy McDaniel * @domain_id: domain ID. 3235433956dSTimothy McDaniel * @args: unmap QID arguments. 3245433956dSTimothy McDaniel * @resp: response structure. 3255433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 3265433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 3275433956dSTimothy McDaniel * 3285433956dSTimothy McDaniel * This function configures the DLB to stop scheduling QEs from the specified 3295433956dSTimothy McDaniel * queue to the specified port. 3305433956dSTimothy McDaniel * 3315433956dSTimothy McDaniel * A successful return does not necessarily mean the mapping was removed. If 3325433956dSTimothy McDaniel * this function is unable to immediately unmap the queue from the port, it 3335433956dSTimothy McDaniel * will add the requested operation to a per-port list of pending map/unmap 3345433956dSTimothy McDaniel * operations, and (if it's not already running) launch a kernel thread that 3355433956dSTimothy McDaniel * periodically attempts to process all pending operations. See 3365433956dSTimothy McDaniel * dlb2_hw_map_qid() for more details. 3375433956dSTimothy McDaniel * 3385433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 3395433956dSTimothy McDaniel * device. 3405433956dSTimothy McDaniel * 3415433956dSTimothy McDaniel * Return: 3425433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 3435433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. 3445433956dSTimothy McDaniel * 3455433956dSTimothy McDaniel * Errors: 3465433956dSTimothy McDaniel * EINVAL - A requested resource is unavailable, invalid port or queue ID, or 3475433956dSTimothy McDaniel * the domain is not configured. 3485433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 3495433956dSTimothy McDaniel */ 3505433956dSTimothy McDaniel int dlb2_hw_unmap_qid(struct dlb2_hw *hw, 3515433956dSTimothy McDaniel u32 domain_id, 3525433956dSTimothy McDaniel struct dlb2_unmap_qid_args *args, 3535433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 3545433956dSTimothy McDaniel bool vdev_request, 3555433956dSTimothy McDaniel unsigned int vdev_id); 3565433956dSTimothy McDaniel 3575433956dSTimothy McDaniel /** 3585433956dSTimothy McDaniel * dlb2_finish_unmap_qid_procedures() - finish any pending unmap procedures 3595433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 3605433956dSTimothy McDaniel * 3615433956dSTimothy McDaniel * This function attempts to finish any outstanding unmap procedures. 3625433956dSTimothy McDaniel * This function should be called by the kernel thread responsible for 3635433956dSTimothy McDaniel * finishing map/unmap procedures. 3645433956dSTimothy McDaniel * 3655433956dSTimothy McDaniel * Return: 3665433956dSTimothy McDaniel * Returns the number of procedures that weren't completed. 3675433956dSTimothy McDaniel */ 3685433956dSTimothy McDaniel unsigned int dlb2_finish_unmap_qid_procedures(struct dlb2_hw *hw); 3695433956dSTimothy McDaniel 3705433956dSTimothy McDaniel /** 3715433956dSTimothy McDaniel * dlb2_finish_map_qid_procedures() - finish any pending map procedures 3725433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 3735433956dSTimothy McDaniel * 3745433956dSTimothy McDaniel * This function attempts to finish any outstanding map procedures. 3755433956dSTimothy McDaniel * This function should be called by the kernel thread responsible for 3765433956dSTimothy McDaniel * finishing map/unmap procedures. 3775433956dSTimothy McDaniel * 3785433956dSTimothy McDaniel * Return: 3795433956dSTimothy McDaniel * Returns the number of procedures that weren't completed. 3805433956dSTimothy McDaniel */ 3815433956dSTimothy McDaniel unsigned int dlb2_finish_map_qid_procedures(struct dlb2_hw *hw); 3825433956dSTimothy McDaniel 3835433956dSTimothy McDaniel /** 3845433956dSTimothy McDaniel * dlb2_hw_enable_ldb_port() - enable a load-balanced port for scheduling 3855433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 3865433956dSTimothy McDaniel * @domain_id: domain ID. 3875433956dSTimothy McDaniel * @args: port enable arguments. 3885433956dSTimothy McDaniel * @resp: response structure. 3895433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 3905433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 3915433956dSTimothy McDaniel * 3925433956dSTimothy McDaniel * This function configures the DLB to schedule QEs to a load-balanced port. 3935433956dSTimothy McDaniel * Ports are enabled by default. 3945433956dSTimothy McDaniel * 3955433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 3965433956dSTimothy McDaniel * device. 3975433956dSTimothy McDaniel * 3985433956dSTimothy McDaniel * Return: 3995433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 4005433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. 4015433956dSTimothy McDaniel * 4025433956dSTimothy McDaniel * Errors: 4035433956dSTimothy McDaniel * EINVAL - The port ID is invalid or the domain is not configured. 4045433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 4055433956dSTimothy McDaniel */ 4065433956dSTimothy McDaniel int dlb2_hw_enable_ldb_port(struct dlb2_hw *hw, 4075433956dSTimothy McDaniel u32 domain_id, 4085433956dSTimothy McDaniel struct dlb2_enable_ldb_port_args *args, 4095433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 4105433956dSTimothy McDaniel bool vdev_request, 4115433956dSTimothy McDaniel unsigned int vdev_id); 4125433956dSTimothy McDaniel 4135433956dSTimothy McDaniel /** 4145433956dSTimothy McDaniel * dlb2_hw_disable_ldb_port() - disable a load-balanced port for scheduling 4155433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 4165433956dSTimothy McDaniel * @domain_id: domain ID. 4175433956dSTimothy McDaniel * @args: port disable arguments. 4185433956dSTimothy McDaniel * @resp: response structure. 4195433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 4205433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 4215433956dSTimothy McDaniel * 4225433956dSTimothy McDaniel * This function configures the DLB to stop scheduling QEs to a load-balanced 4235433956dSTimothy McDaniel * port. Ports are enabled by default. 4245433956dSTimothy McDaniel * 4255433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 4265433956dSTimothy McDaniel * device. 4275433956dSTimothy McDaniel * 4285433956dSTimothy McDaniel * Return: 4295433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 4305433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. 4315433956dSTimothy McDaniel * 4325433956dSTimothy McDaniel * Errors: 4335433956dSTimothy McDaniel * EINVAL - The port ID is invalid or the domain is not configured. 4345433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 4355433956dSTimothy McDaniel */ 4365433956dSTimothy McDaniel int dlb2_hw_disable_ldb_port(struct dlb2_hw *hw, 4375433956dSTimothy McDaniel u32 domain_id, 4385433956dSTimothy McDaniel struct dlb2_disable_ldb_port_args *args, 4395433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 4405433956dSTimothy McDaniel bool vdev_request, 4415433956dSTimothy McDaniel unsigned int vdev_id); 4425433956dSTimothy McDaniel 4435433956dSTimothy McDaniel /** 4445433956dSTimothy McDaniel * dlb2_hw_enable_dir_port() - enable a directed port for scheduling 4455433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 4465433956dSTimothy McDaniel * @domain_id: domain ID. 4475433956dSTimothy McDaniel * @args: port enable arguments. 4485433956dSTimothy McDaniel * @resp: response structure. 4495433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 4505433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 4515433956dSTimothy McDaniel * 4525433956dSTimothy McDaniel * This function configures the DLB to schedule QEs to a directed port. 4535433956dSTimothy McDaniel * Ports are enabled by default. 4545433956dSTimothy McDaniel * 4555433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 4565433956dSTimothy McDaniel * device. 4575433956dSTimothy McDaniel * 4585433956dSTimothy McDaniel * Return: 4595433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 4605433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. 4615433956dSTimothy McDaniel * 4625433956dSTimothy McDaniel * Errors: 4635433956dSTimothy McDaniel * EINVAL - The port ID is invalid or the domain is not configured. 4645433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 4655433956dSTimothy McDaniel */ 4665433956dSTimothy McDaniel int dlb2_hw_enable_dir_port(struct dlb2_hw *hw, 4675433956dSTimothy McDaniel u32 domain_id, 4685433956dSTimothy McDaniel struct dlb2_enable_dir_port_args *args, 4695433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 4705433956dSTimothy McDaniel bool vdev_request, 4715433956dSTimothy McDaniel unsigned int vdev_id); 4725433956dSTimothy McDaniel 4735433956dSTimothy McDaniel /** 4745433956dSTimothy McDaniel * dlb2_hw_disable_dir_port() - disable a directed port for scheduling 4755433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 4765433956dSTimothy McDaniel * @domain_id: domain ID. 4775433956dSTimothy McDaniel * @args: port disable arguments. 4785433956dSTimothy McDaniel * @resp: response structure. 4795433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 4805433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 4815433956dSTimothy McDaniel * 4825433956dSTimothy McDaniel * This function configures the DLB to stop scheduling QEs to a directed port. 4835433956dSTimothy McDaniel * Ports are enabled by default. 4845433956dSTimothy McDaniel * 4855433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 4865433956dSTimothy McDaniel * device. 4875433956dSTimothy McDaniel * 4885433956dSTimothy McDaniel * Return: 4895433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 4905433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. 4915433956dSTimothy McDaniel * 4925433956dSTimothy McDaniel * Errors: 4935433956dSTimothy McDaniel * EINVAL - The port ID is invalid or the domain is not configured. 4945433956dSTimothy McDaniel * EFAULT - Internal error (resp->status not set). 4955433956dSTimothy McDaniel */ 4965433956dSTimothy McDaniel int dlb2_hw_disable_dir_port(struct dlb2_hw *hw, 4975433956dSTimothy McDaniel u32 domain_id, 4985433956dSTimothy McDaniel struct dlb2_disable_dir_port_args *args, 4995433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 5005433956dSTimothy McDaniel bool vdev_request, 5015433956dSTimothy McDaniel unsigned int vdev_id); 5025433956dSTimothy McDaniel 5035433956dSTimothy McDaniel /** 5045433956dSTimothy McDaniel * dlb2_configure_ldb_cq_interrupt() - configure load-balanced CQ for 5055433956dSTimothy McDaniel * interrupts 5065433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 5075433956dSTimothy McDaniel * @port_id: load-balanced port ID. 5085433956dSTimothy McDaniel * @vector: interrupt vector ID. Should be 0 for MSI or compressed MSI-X mode, 5095433956dSTimothy McDaniel * else a value up to 64. 5105433956dSTimothy McDaniel * @mode: interrupt type (DLB2_CQ_ISR_MODE_MSI or DLB2_CQ_ISR_MODE_MSIX) 5115433956dSTimothy McDaniel * @vf: If the port is VF-owned, the VF's ID. This is used for translating the 5125433956dSTimothy McDaniel * virtual port ID to a physical port ID. Ignored if mode is not MSI. 5135433956dSTimothy McDaniel * @owner_vf: the VF to route the interrupt to. Ignore if mode is not MSI. 5145433956dSTimothy McDaniel * @threshold: the minimum CQ depth at which the interrupt can fire. Must be 5155433956dSTimothy McDaniel * greater than 0. 5165433956dSTimothy McDaniel * 5175433956dSTimothy McDaniel * This function configures the DLB registers for load-balanced CQ's 5185433956dSTimothy McDaniel * interrupts. This doesn't enable the CQ's interrupt; that can be done with 5195433956dSTimothy McDaniel * dlb2_arm_cq_interrupt() or through an interrupt arm QE. 5205433956dSTimothy McDaniel * 5215433956dSTimothy McDaniel * Return: 5225433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. 5235433956dSTimothy McDaniel * 5245433956dSTimothy McDaniel * Errors: 5255433956dSTimothy McDaniel * EINVAL - The port ID is invalid. 5265433956dSTimothy McDaniel */ 5275433956dSTimothy McDaniel int dlb2_configure_ldb_cq_interrupt(struct dlb2_hw *hw, 5285433956dSTimothy McDaniel int port_id, 5295433956dSTimothy McDaniel int vector, 5305433956dSTimothy McDaniel int mode, 5315433956dSTimothy McDaniel unsigned int vf, 5325433956dSTimothy McDaniel unsigned int owner_vf, 5335433956dSTimothy McDaniel u16 threshold); 5345433956dSTimothy McDaniel 5355433956dSTimothy McDaniel /** 5365433956dSTimothy McDaniel * dlb2_configure_dir_cq_interrupt() - configure directed CQ for interrupts 5375433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 5385433956dSTimothy McDaniel * @port_id: load-balanced port ID. 5395433956dSTimothy McDaniel * @vector: interrupt vector ID. Should be 0 for MSI or compressed MSI-X mode, 5405433956dSTimothy McDaniel * else a value up to 64. 5415433956dSTimothy McDaniel * @mode: interrupt type (DLB2_CQ_ISR_MODE_MSI or DLB2_CQ_ISR_MODE_MSIX) 5425433956dSTimothy McDaniel * @vf: If the port is VF-owned, the VF's ID. This is used for translating the 5435433956dSTimothy McDaniel * virtual port ID to a physical port ID. Ignored if mode is not MSI. 5445433956dSTimothy McDaniel * @owner_vf: the VF to route the interrupt to. Ignore if mode is not MSI. 5455433956dSTimothy McDaniel * @threshold: the minimum CQ depth at which the interrupt can fire. Must be 5465433956dSTimothy McDaniel * greater than 0. 5475433956dSTimothy McDaniel * 5485433956dSTimothy McDaniel * This function configures the DLB registers for directed CQ's interrupts. 5495433956dSTimothy McDaniel * This doesn't enable the CQ's interrupt; that can be done with 5505433956dSTimothy McDaniel * dlb2_arm_cq_interrupt() or through an interrupt arm QE. 5515433956dSTimothy McDaniel * 5525433956dSTimothy McDaniel * Return: 5535433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. 5545433956dSTimothy McDaniel * 5555433956dSTimothy McDaniel * Errors: 5565433956dSTimothy McDaniel * EINVAL - The port ID is invalid. 5575433956dSTimothy McDaniel */ 5585433956dSTimothy McDaniel int dlb2_configure_dir_cq_interrupt(struct dlb2_hw *hw, 5595433956dSTimothy McDaniel int port_id, 5605433956dSTimothy McDaniel int vector, 5615433956dSTimothy McDaniel int mode, 5625433956dSTimothy McDaniel unsigned int vf, 5635433956dSTimothy McDaniel unsigned int owner_vf, 5645433956dSTimothy McDaniel u16 threshold); 5655433956dSTimothy McDaniel 5665433956dSTimothy McDaniel /** 5675433956dSTimothy McDaniel * dlb2_enable_ingress_error_alarms() - enable ingress error alarm interrupts 5685433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 5695433956dSTimothy McDaniel */ 5705433956dSTimothy McDaniel void dlb2_enable_ingress_error_alarms(struct dlb2_hw *hw); 5715433956dSTimothy McDaniel 5725433956dSTimothy McDaniel /** 5735433956dSTimothy McDaniel * dlb2_disable_ingress_error_alarms() - disable ingress error alarm interrupts 5745433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 5755433956dSTimothy McDaniel */ 5765433956dSTimothy McDaniel void dlb2_disable_ingress_error_alarms(struct dlb2_hw *hw); 5775433956dSTimothy McDaniel 5785433956dSTimothy McDaniel /** 5795433956dSTimothy McDaniel * dlb2_set_msix_mode() - enable certain hardware alarm interrupts 5805433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 5815433956dSTimothy McDaniel * @mode: MSI-X mode (DLB2_MSIX_MODE_PACKED or DLB2_MSIX_MODE_COMPRESSED) 5825433956dSTimothy McDaniel * 5835433956dSTimothy McDaniel * This function configures the hardware to use either packed or compressed 5845433956dSTimothy McDaniel * mode. This function should not be called if using MSI interrupts. 5855433956dSTimothy McDaniel */ 5865433956dSTimothy McDaniel void dlb2_set_msix_mode(struct dlb2_hw *hw, int mode); 5875433956dSTimothy McDaniel 5885433956dSTimothy McDaniel /** 5895433956dSTimothy McDaniel * dlb2_ack_msix_interrupt() - Ack an MSI-X interrupt 5905433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 5915433956dSTimothy McDaniel * @vector: interrupt vector. 5925433956dSTimothy McDaniel * 5935433956dSTimothy McDaniel * Note: Only needed for PF service interrupts (vector 0). CQ interrupts are 5945433956dSTimothy McDaniel * acked in dlb2_ack_compressed_cq_intr(). 5955433956dSTimothy McDaniel */ 5965433956dSTimothy McDaniel void dlb2_ack_msix_interrupt(struct dlb2_hw *hw, int vector); 5975433956dSTimothy McDaniel 5985433956dSTimothy McDaniel /** 5995433956dSTimothy McDaniel * dlb2_arm_cq_interrupt() - arm a CQ's interrupt 6005433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 6015433956dSTimothy McDaniel * @port_id: port ID 6025433956dSTimothy McDaniel * @is_ldb: true for load-balanced port, false for a directed port 6035433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 6045433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 6055433956dSTimothy McDaniel * 6065433956dSTimothy McDaniel * This function arms the CQ's interrupt. The CQ must be configured prior to 6075433956dSTimothy McDaniel * calling this function. 6085433956dSTimothy McDaniel * 6095433956dSTimothy McDaniel * The function does no parameter validation; that is the caller's 6105433956dSTimothy McDaniel * responsibility. 6115433956dSTimothy McDaniel * 6125433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 6135433956dSTimothy McDaniel * device. 6145433956dSTimothy McDaniel * 6155433956dSTimothy McDaniel * Return: returns 0 upon success, <0 otherwise. 6165433956dSTimothy McDaniel * 6175433956dSTimothy McDaniel * EINVAL - Invalid port ID. 6185433956dSTimothy McDaniel */ 6195433956dSTimothy McDaniel int dlb2_arm_cq_interrupt(struct dlb2_hw *hw, 6205433956dSTimothy McDaniel int port_id, 6215433956dSTimothy McDaniel bool is_ldb, 6225433956dSTimothy McDaniel bool vdev_request, 6235433956dSTimothy McDaniel unsigned int vdev_id); 6245433956dSTimothy McDaniel 6255433956dSTimothy McDaniel /** 6265433956dSTimothy McDaniel * dlb2_read_compressed_cq_intr_status() - read compressed CQ interrupt status 6275433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 6285433956dSTimothy McDaniel * @ldb_interrupts: 2-entry array of u32 bitmaps 6295433956dSTimothy McDaniel * @dir_interrupts: 4-entry array of u32 bitmaps 6305433956dSTimothy McDaniel * 6315433956dSTimothy McDaniel * This function can be called from a compressed CQ interrupt handler to 6325433956dSTimothy McDaniel * determine which CQ interrupts have fired. The caller should take appropriate 6335433956dSTimothy McDaniel * (such as waking threads blocked on a CQ's interrupt) then ack the interrupts 6345433956dSTimothy McDaniel * with dlb2_ack_compressed_cq_intr(). 6355433956dSTimothy McDaniel */ 6365433956dSTimothy McDaniel void dlb2_read_compressed_cq_intr_status(struct dlb2_hw *hw, 6375433956dSTimothy McDaniel u32 *ldb_interrupts, 6385433956dSTimothy McDaniel u32 *dir_interrupts); 6395433956dSTimothy McDaniel 6405433956dSTimothy McDaniel /** 6415433956dSTimothy McDaniel * dlb2_ack_compressed_cq_intr_status() - ack compressed CQ interrupts 6425433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 6435433956dSTimothy McDaniel * @ldb_interrupts: 2-entry array of u32 bitmaps 6445433956dSTimothy McDaniel * @dir_interrupts: 4-entry array of u32 bitmaps 6455433956dSTimothy McDaniel * 6465433956dSTimothy McDaniel * This function ACKs compressed CQ interrupts. Its arguments should be the 6475433956dSTimothy McDaniel * same ones passed to dlb2_read_compressed_cq_intr_status(). 6485433956dSTimothy McDaniel */ 6495433956dSTimothy McDaniel void dlb2_ack_compressed_cq_intr(struct dlb2_hw *hw, 6505433956dSTimothy McDaniel u32 *ldb_interrupts, 6515433956dSTimothy McDaniel u32 *dir_interrupts); 6525433956dSTimothy McDaniel 6535433956dSTimothy McDaniel /** 6545433956dSTimothy McDaniel * dlb2_read_vf_intr_status() - read the VF interrupt status register 6555433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 6565433956dSTimothy McDaniel * 6575433956dSTimothy McDaniel * This function can be called from a VF's interrupt handler to determine 6585433956dSTimothy McDaniel * which interrupts have fired. The first 31 bits correspond to CQ interrupt 6595433956dSTimothy McDaniel * vectors, and the final bit is for the PF->VF mailbox interrupt vector. 6605433956dSTimothy McDaniel * 6615433956dSTimothy McDaniel * Return: 6625433956dSTimothy McDaniel * Returns a bit vector indicating which interrupt vectors are active. 6635433956dSTimothy McDaniel */ 6645433956dSTimothy McDaniel u32 dlb2_read_vf_intr_status(struct dlb2_hw *hw); 6655433956dSTimothy McDaniel 6665433956dSTimothy McDaniel /** 6675433956dSTimothy McDaniel * dlb2_ack_vf_intr_status() - ack VF interrupts 6685433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 6695433956dSTimothy McDaniel * @interrupts: 32-bit bitmap 6705433956dSTimothy McDaniel * 6715433956dSTimothy McDaniel * This function ACKs a VF's interrupts. Its interrupts argument should be the 6725433956dSTimothy McDaniel * value returned by dlb2_read_vf_intr_status(). 6735433956dSTimothy McDaniel */ 6745433956dSTimothy McDaniel void dlb2_ack_vf_intr_status(struct dlb2_hw *hw, u32 interrupts); 6755433956dSTimothy McDaniel 6765433956dSTimothy McDaniel /** 6775433956dSTimothy McDaniel * dlb2_ack_vf_msi_intr() - ack VF MSI interrupt 6785433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 6795433956dSTimothy McDaniel * @interrupts: 32-bit bitmap 6805433956dSTimothy McDaniel * 6815433956dSTimothy McDaniel * This function clears the VF's MSI interrupt pending register. Its interrupts 6825433956dSTimothy McDaniel * argument should be contain the MSI vectors to ACK. For example, if MSI MME 6835433956dSTimothy McDaniel * is in mode 0, then one bit 0 should ever be set. 6845433956dSTimothy McDaniel */ 6855433956dSTimothy McDaniel void dlb2_ack_vf_msi_intr(struct dlb2_hw *hw, u32 interrupts); 6865433956dSTimothy McDaniel 6875433956dSTimothy McDaniel /** 6885433956dSTimothy McDaniel * dlb2_ack_pf_mbox_int() - ack PF->VF mailbox interrupt 6895433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 6905433956dSTimothy McDaniel * 6915433956dSTimothy McDaniel * When done processing the PF mailbox request, this function unsets 6925433956dSTimothy McDaniel * the PF's mailbox ISR register. 6935433956dSTimothy McDaniel */ 6945433956dSTimothy McDaniel void dlb2_ack_pf_mbox_int(struct dlb2_hw *hw); 6955433956dSTimothy McDaniel 6965433956dSTimothy McDaniel /** 6975433956dSTimothy McDaniel * dlb2_read_vdev_to_pf_int_bitvec() - return a bit vector of all requesting 6985433956dSTimothy McDaniel * vdevs 6995433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 7005433956dSTimothy McDaniel * 7015433956dSTimothy McDaniel * When the vdev->PF ISR fires, this function can be called to determine which 7025433956dSTimothy McDaniel * vdev(s) are requesting service. This bitvector must be passed to 7035433956dSTimothy McDaniel * dlb2_ack_vdev_to_pf_int() when processing is complete for all requesting 7045433956dSTimothy McDaniel * vdevs. 7055433956dSTimothy McDaniel * 7065433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 7075433956dSTimothy McDaniel * device. 7085433956dSTimothy McDaniel * 7095433956dSTimothy McDaniel * Return: 7105433956dSTimothy McDaniel * Returns a bit vector indicating which VFs (0-15) have requested service. 7115433956dSTimothy McDaniel */ 7125433956dSTimothy McDaniel u32 dlb2_read_vdev_to_pf_int_bitvec(struct dlb2_hw *hw); 7135433956dSTimothy McDaniel 7145433956dSTimothy McDaniel /** 7155433956dSTimothy McDaniel * dlb2_ack_vdev_mbox_int() - ack processed vdev->PF mailbox interrupt 7165433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 7175433956dSTimothy McDaniel * @bitvec: bit vector returned by dlb2_read_vdev_to_pf_int_bitvec() 7185433956dSTimothy McDaniel * 7195433956dSTimothy McDaniel * When done processing all VF mailbox requests, this function unsets the VF's 7205433956dSTimothy McDaniel * mailbox ISR register. 7215433956dSTimothy McDaniel * 7225433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 7235433956dSTimothy McDaniel * device. 7245433956dSTimothy McDaniel */ 7255433956dSTimothy McDaniel void dlb2_ack_vdev_mbox_int(struct dlb2_hw *hw, u32 bitvec); 7265433956dSTimothy McDaniel 7275433956dSTimothy McDaniel /** 7285433956dSTimothy McDaniel * dlb2_read_vf_flr_int_bitvec() - return a bit vector of all VFs requesting 7295433956dSTimothy McDaniel * FLR 7305433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 7315433956dSTimothy McDaniel * 7325433956dSTimothy McDaniel * When the VF FLR ISR fires, this function can be called to determine which 7335433956dSTimothy McDaniel * VF(s) are requesting FLRs. This bitvector must passed to 7345433956dSTimothy McDaniel * dlb2_ack_vf_flr_int() when processing is complete for all requesting VFs. 7355433956dSTimothy McDaniel * 7365433956dSTimothy McDaniel * Return: 7375433956dSTimothy McDaniel * Returns a bit vector indicating which VFs (0-15) have requested FLRs. 7385433956dSTimothy McDaniel */ 7395433956dSTimothy McDaniel u32 dlb2_read_vf_flr_int_bitvec(struct dlb2_hw *hw); 7405433956dSTimothy McDaniel 7415433956dSTimothy McDaniel /** 7425433956dSTimothy McDaniel * dlb2_ack_vf_flr_int() - ack processed VF<->PF interrupt(s) 7435433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 7445433956dSTimothy McDaniel * @bitvec: bit vector returned by dlb2_read_vf_flr_int_bitvec() 7455433956dSTimothy McDaniel * 7465433956dSTimothy McDaniel * When done processing all VF FLR requests, this function unsets the VF's FLR 7475433956dSTimothy McDaniel * ISR register. 7485433956dSTimothy McDaniel */ 7495433956dSTimothy McDaniel void dlb2_ack_vf_flr_int(struct dlb2_hw *hw, u32 bitvec); 7505433956dSTimothy McDaniel 7515433956dSTimothy McDaniel /** 7525433956dSTimothy McDaniel * dlb2_ack_vdev_to_pf_int() - ack processed VF mbox and FLR interrupt(s) 7535433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 7545433956dSTimothy McDaniel * @mbox_bitvec: bit vector returned by dlb2_read_vdev_to_pf_int_bitvec() 7555433956dSTimothy McDaniel * @flr_bitvec: bit vector returned by dlb2_read_vf_flr_int_bitvec() 7565433956dSTimothy McDaniel * 7575433956dSTimothy McDaniel * When done processing all VF requests, this function communicates to the 7585433956dSTimothy McDaniel * hardware that processing is complete. 7595433956dSTimothy McDaniel * 7605433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 7615433956dSTimothy McDaniel * device. 7625433956dSTimothy McDaniel */ 7635433956dSTimothy McDaniel void dlb2_ack_vdev_to_pf_int(struct dlb2_hw *hw, 7645433956dSTimothy McDaniel u32 mbox_bitvec, 7655433956dSTimothy McDaniel u32 flr_bitvec); 7665433956dSTimothy McDaniel 7675433956dSTimothy McDaniel /** 7685433956dSTimothy McDaniel * dlb2_process_wdt_interrupt() - process watchdog timer interrupts 7695433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 7705433956dSTimothy McDaniel * 7715433956dSTimothy McDaniel * This function reads the watchdog timer interrupt cause registers to 7725433956dSTimothy McDaniel * determine which port(s) had a watchdog timeout, and notifies the 7735433956dSTimothy McDaniel * application(s) that own the port(s). 7745433956dSTimothy McDaniel */ 7755433956dSTimothy McDaniel void dlb2_process_wdt_interrupt(struct dlb2_hw *hw); 7765433956dSTimothy McDaniel 7775433956dSTimothy McDaniel /** 7785433956dSTimothy McDaniel * dlb2_process_alarm_interrupt() - process an alarm interrupt 7795433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 7805433956dSTimothy McDaniel * 7815433956dSTimothy McDaniel * This function reads and logs the alarm syndrome, then acks the interrupt. 7825433956dSTimothy McDaniel * This function should be called from the alarm interrupt handler when 7835433956dSTimothy McDaniel * interrupt vector DLB2_INT_ALARM fires. 7845433956dSTimothy McDaniel */ 7855433956dSTimothy McDaniel void dlb2_process_alarm_interrupt(struct dlb2_hw *hw); 7865433956dSTimothy McDaniel 7875433956dSTimothy McDaniel /** 7885433956dSTimothy McDaniel * dlb2_process_ingress_error_interrupt() - process ingress error interrupts 7895433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 7905433956dSTimothy McDaniel * 7915433956dSTimothy McDaniel * This function reads the alarm syndrome, logs it, notifies user-space, and 7925433956dSTimothy McDaniel * acks the interrupt. This function should be called from the alarm interrupt 7935433956dSTimothy McDaniel * handler when interrupt vector DLB2_INT_INGRESS_ERROR fires. 7945433956dSTimothy McDaniel * 7955433956dSTimothy McDaniel * Return: 7965433956dSTimothy McDaniel * Returns true if an ingress error interrupt occurred, false otherwise 7975433956dSTimothy McDaniel */ 7985433956dSTimothy McDaniel bool dlb2_process_ingress_error_interrupt(struct dlb2_hw *hw); 7995433956dSTimothy McDaniel 8005433956dSTimothy McDaniel /** 8015433956dSTimothy McDaniel * dlb2_get_group_sequence_numbers() - return a group's number of SNs per queue 8025433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 8035433956dSTimothy McDaniel * @group_id: sequence number group ID. 8045433956dSTimothy McDaniel * 8055433956dSTimothy McDaniel * This function returns the configured number of sequence numbers per queue 8065433956dSTimothy McDaniel * for the specified group. 8075433956dSTimothy McDaniel * 8085433956dSTimothy McDaniel * Return: 8095433956dSTimothy McDaniel * Returns -EINVAL if group_id is invalid, else the group's SNs per queue. 8105433956dSTimothy McDaniel */ 8115433956dSTimothy McDaniel int dlb2_get_group_sequence_numbers(struct dlb2_hw *hw, 8125433956dSTimothy McDaniel unsigned int group_id); 8135433956dSTimothy McDaniel 8145433956dSTimothy McDaniel /** 8155433956dSTimothy McDaniel * dlb2_get_group_sequence_number_occupancy() - return a group's in-use slots 8165433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 8175433956dSTimothy McDaniel * @group_id: sequence number group ID. 8185433956dSTimothy McDaniel * 8195433956dSTimothy McDaniel * This function returns the group's number of in-use slots (i.e. load-balanced 8205433956dSTimothy McDaniel * queues using the specified group). 8215433956dSTimothy McDaniel * 8225433956dSTimothy McDaniel * Return: 8235433956dSTimothy McDaniel * Returns -EINVAL if group_id is invalid, else the group's SNs per queue. 8245433956dSTimothy McDaniel */ 8255433956dSTimothy McDaniel int dlb2_get_group_sequence_number_occupancy(struct dlb2_hw *hw, 8265433956dSTimothy McDaniel unsigned int group_id); 8275433956dSTimothy McDaniel 8285433956dSTimothy McDaniel /** 8295433956dSTimothy McDaniel * dlb2_set_group_sequence_numbers() - assign a group's number of SNs per queue 8305433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 8315433956dSTimothy McDaniel * @group_id: sequence number group ID. 8325433956dSTimothy McDaniel * @val: requested amount of sequence numbers per queue. 8335433956dSTimothy McDaniel * 8345433956dSTimothy McDaniel * This function configures the group's number of sequence numbers per queue. 8355433956dSTimothy McDaniel * val can be a power-of-two between 32 and 1024, inclusive. This setting can 8365433956dSTimothy McDaniel * be configured until the first ordered load-balanced queue is configured, at 8375433956dSTimothy McDaniel * which point the configuration is locked. 8385433956dSTimothy McDaniel * 8395433956dSTimothy McDaniel * Return: 8405433956dSTimothy McDaniel * Returns 0 upon success; -EINVAL if group_id or val is invalid, -EPERM if an 8415433956dSTimothy McDaniel * ordered queue is configured. 8425433956dSTimothy McDaniel */ 8435433956dSTimothy McDaniel int dlb2_set_group_sequence_numbers(struct dlb2_hw *hw, 844537399a9STimothy McDaniel u32 group_id, 845537399a9STimothy McDaniel u32 val); 8465433956dSTimothy McDaniel 8475433956dSTimothy McDaniel /** 8485433956dSTimothy McDaniel * dlb2_reset_domain() - reset a scheduling domain 8495433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 8505433956dSTimothy McDaniel * @domain_id: domain ID. 8515433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 8525433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 8535433956dSTimothy McDaniel * 8545433956dSTimothy McDaniel * This function resets and frees a DLB 2.0 scheduling domain and its associated 8555433956dSTimothy McDaniel * resources. 8565433956dSTimothy McDaniel * 8575433956dSTimothy McDaniel * Pre-condition: the driver must ensure software has stopped sending QEs 8585433956dSTimothy McDaniel * through this domain's producer ports before invoking this function, or 8595433956dSTimothy McDaniel * undefined behavior will result. 8605433956dSTimothy McDaniel * 8615433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 8625433956dSTimothy McDaniel * device. 8635433956dSTimothy McDaniel * 8645433956dSTimothy McDaniel * Return: 8655433956dSTimothy McDaniel * Returns 0 upon success, -1 otherwise. 8665433956dSTimothy McDaniel * 8675433956dSTimothy McDaniel * EINVAL - Invalid domain ID, or the domain is not configured. 8685433956dSTimothy McDaniel * EFAULT - Internal error. (Possibly caused if software is the pre-condition 8695433956dSTimothy McDaniel * is not met.) 8705433956dSTimothy McDaniel * ETIMEDOUT - Hardware component didn't reset in the expected time. 8715433956dSTimothy McDaniel */ 8725433956dSTimothy McDaniel int dlb2_reset_domain(struct dlb2_hw *hw, 8735433956dSTimothy McDaniel u32 domain_id, 8745433956dSTimothy McDaniel bool vdev_request, 8755433956dSTimothy McDaniel unsigned int vdev_id); 8765433956dSTimothy McDaniel 8775433956dSTimothy McDaniel /** 8785433956dSTimothy McDaniel * dlb2_ldb_port_owned_by_domain() - query whether a port is owned by a domain 8795433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 8805433956dSTimothy McDaniel * @domain_id: domain ID. 8815433956dSTimothy McDaniel * @port_id: indicates whether this request came from a VF. 8825433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 8835433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 8845433956dSTimothy McDaniel * 8855433956dSTimothy McDaniel * This function returns whether a load-balanced port is owned by a specified 8865433956dSTimothy McDaniel * domain. 8875433956dSTimothy McDaniel * 8885433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 8895433956dSTimothy McDaniel * device. 8905433956dSTimothy McDaniel * 8915433956dSTimothy McDaniel * Return: 8925433956dSTimothy McDaniel * Returns 0 if false, 1 if true, <0 otherwise. 8935433956dSTimothy McDaniel * 8945433956dSTimothy McDaniel * EINVAL - Invalid domain or port ID, or the domain is not configured. 8955433956dSTimothy McDaniel */ 8965433956dSTimothy McDaniel int dlb2_ldb_port_owned_by_domain(struct dlb2_hw *hw, 8975433956dSTimothy McDaniel u32 domain_id, 8985433956dSTimothy McDaniel u32 port_id, 8995433956dSTimothy McDaniel bool vdev_request, 9005433956dSTimothy McDaniel unsigned int vdev_id); 9015433956dSTimothy McDaniel 9025433956dSTimothy McDaniel /** 9035433956dSTimothy McDaniel * dlb2_dir_port_owned_by_domain() - query whether a port is owned by a domain 9045433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 9055433956dSTimothy McDaniel * @domain_id: domain ID. 9065433956dSTimothy McDaniel * @port_id: indicates whether this request came from a VF. 9075433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 9085433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 9095433956dSTimothy McDaniel * 9105433956dSTimothy McDaniel * This function returns whether a directed port is owned by a specified 9115433956dSTimothy McDaniel * domain. 9125433956dSTimothy McDaniel * 9135433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 9145433956dSTimothy McDaniel * device. 9155433956dSTimothy McDaniel * 9165433956dSTimothy McDaniel * Return: 9175433956dSTimothy McDaniel * Returns 0 if false, 1 if true, <0 otherwise. 9185433956dSTimothy McDaniel * 9195433956dSTimothy McDaniel * EINVAL - Invalid domain or port ID, or the domain is not configured. 9205433956dSTimothy McDaniel */ 9215433956dSTimothy McDaniel int dlb2_dir_port_owned_by_domain(struct dlb2_hw *hw, 9225433956dSTimothy McDaniel u32 domain_id, 9235433956dSTimothy McDaniel u32 port_id, 9245433956dSTimothy McDaniel bool vdev_request, 9255433956dSTimothy McDaniel unsigned int vdev_id); 9265433956dSTimothy McDaniel 9275433956dSTimothy McDaniel /** 9285433956dSTimothy McDaniel * dlb2_hw_get_num_resources() - query the PCI function's available resources 9295433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 9305433956dSTimothy McDaniel * @arg: pointer to resource counts. 9315433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 9325433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 9335433956dSTimothy McDaniel * 9345433956dSTimothy McDaniel * This function returns the number of available resources for the PF or for a 9355433956dSTimothy McDaniel * VF. 9365433956dSTimothy McDaniel * 9375433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 9385433956dSTimothy McDaniel * device. 9395433956dSTimothy McDaniel * 9405433956dSTimothy McDaniel * Return: 9415433956dSTimothy McDaniel * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is 9425433956dSTimothy McDaniel * invalid. 9435433956dSTimothy McDaniel */ 9445433956dSTimothy McDaniel int dlb2_hw_get_num_resources(struct dlb2_hw *hw, 9455433956dSTimothy McDaniel struct dlb2_get_num_resources_args *arg, 9465433956dSTimothy McDaniel bool vdev_request, 9475433956dSTimothy McDaniel unsigned int vdev_id); 9485433956dSTimothy McDaniel 9495433956dSTimothy McDaniel /** 9505433956dSTimothy McDaniel * dlb2_hw_get_num_used_resources() - query the PCI function's used resources 9515433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 9525433956dSTimothy McDaniel * @arg: pointer to resource counts. 9535433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 9545433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 9555433956dSTimothy McDaniel * 9565433956dSTimothy McDaniel * This function returns the number of resources in use by the PF or a VF. It 9575433956dSTimothy McDaniel * fills in the fields that args points to, except the following: 9585433956dSTimothy McDaniel * - max_contiguous_atomic_inflights 9595433956dSTimothy McDaniel * - max_contiguous_hist_list_entries 9605433956dSTimothy McDaniel * - max_contiguous_ldb_credits 9615433956dSTimothy McDaniel * - max_contiguous_dir_credits 9625433956dSTimothy McDaniel * 9635433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 9645433956dSTimothy McDaniel * device. 9655433956dSTimothy McDaniel * 9665433956dSTimothy McDaniel * Return: 9675433956dSTimothy McDaniel * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is 9685433956dSTimothy McDaniel * invalid. 9695433956dSTimothy McDaniel */ 9705433956dSTimothy McDaniel int dlb2_hw_get_num_used_resources(struct dlb2_hw *hw, 9715433956dSTimothy McDaniel struct dlb2_get_num_resources_args *arg, 9725433956dSTimothy McDaniel bool vdev_request, 9735433956dSTimothy McDaniel unsigned int vdev_id); 9745433956dSTimothy McDaniel 9755433956dSTimothy McDaniel /** 9765433956dSTimothy McDaniel * dlb2_send_async_vdev_to_pf_msg() - (vdev only) send a mailbox message to 9775433956dSTimothy McDaniel * the PF 9785433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 9795433956dSTimothy McDaniel * 9805433956dSTimothy McDaniel * This function sends a VF->PF mailbox message. It is asynchronous, so it 9815433956dSTimothy McDaniel * returns once the message is sent but potentially before the PF has processed 9825433956dSTimothy McDaniel * the message. The caller must call dlb2_vdev_to_pf_complete() to determine 9835433956dSTimothy McDaniel * when the PF has finished processing the request. 9845433956dSTimothy McDaniel * 9855433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 9865433956dSTimothy McDaniel * device. 9875433956dSTimothy McDaniel */ 9885433956dSTimothy McDaniel void dlb2_send_async_vdev_to_pf_msg(struct dlb2_hw *hw); 9895433956dSTimothy McDaniel 9905433956dSTimothy McDaniel /** 9915433956dSTimothy McDaniel * dlb2_vdev_to_pf_complete() - check the status of an asynchronous mailbox 9925433956dSTimothy McDaniel * request 9935433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 9945433956dSTimothy McDaniel * 9955433956dSTimothy McDaniel * This function returns a boolean indicating whether the PF has finished 9965433956dSTimothy McDaniel * processing a VF->PF mailbox request. It should only be called after sending 9975433956dSTimothy McDaniel * an asynchronous request with dlb2_send_async_vdev_to_pf_msg(). 9985433956dSTimothy McDaniel * 9995433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 10005433956dSTimothy McDaniel * device. 10015433956dSTimothy McDaniel */ 10025433956dSTimothy McDaniel bool dlb2_vdev_to_pf_complete(struct dlb2_hw *hw); 10035433956dSTimothy McDaniel 10045433956dSTimothy McDaniel /** 10055433956dSTimothy McDaniel * dlb2_vf_flr_complete() - check the status of a VF FLR 10065433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 10075433956dSTimothy McDaniel * 10085433956dSTimothy McDaniel * This function returns a boolean indicating whether the PF has finished 10095433956dSTimothy McDaniel * executing the VF FLR. It should only be called after setting the VF's FLR 10105433956dSTimothy McDaniel * bit. 10115433956dSTimothy McDaniel */ 10125433956dSTimothy McDaniel bool dlb2_vf_flr_complete(struct dlb2_hw *hw); 10135433956dSTimothy McDaniel 10145433956dSTimothy McDaniel /** 10155433956dSTimothy McDaniel * dlb2_send_async_pf_to_vdev_msg() - (PF only) send a mailbox message to a 10165433956dSTimothy McDaniel * vdev 10175433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 10185433956dSTimothy McDaniel * @vdev_id: vdev ID. 10195433956dSTimothy McDaniel * 10205433956dSTimothy McDaniel * This function sends a PF->vdev mailbox message. It is asynchronous, so it 10215433956dSTimothy McDaniel * returns once the message is sent but potentially before the vdev has 10225433956dSTimothy McDaniel * processed the message. The caller must call dlb2_pf_to_vdev_complete() to 10235433956dSTimothy McDaniel * determine when the vdev has finished processing the request. 10245433956dSTimothy McDaniel * 10255433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 10265433956dSTimothy McDaniel * device. 10275433956dSTimothy McDaniel */ 10285433956dSTimothy McDaniel void dlb2_send_async_pf_to_vdev_msg(struct dlb2_hw *hw, unsigned int vdev_id); 10295433956dSTimothy McDaniel 10305433956dSTimothy McDaniel /** 10315433956dSTimothy McDaniel * dlb2_pf_to_vdev_complete() - check the status of an asynchronous mailbox 10325433956dSTimothy McDaniel * request 10335433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 10345433956dSTimothy McDaniel * @vdev_id: vdev ID. 10355433956dSTimothy McDaniel * 10365433956dSTimothy McDaniel * This function returns a boolean indicating whether the vdev has finished 10375433956dSTimothy McDaniel * processing a PF->vdev mailbox request. It should only be called after 10385433956dSTimothy McDaniel * sending an asynchronous request with dlb2_send_async_pf_to_vdev_msg(). 10395433956dSTimothy McDaniel * 10405433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 10415433956dSTimothy McDaniel * device. 10425433956dSTimothy McDaniel */ 10435433956dSTimothy McDaniel bool dlb2_pf_to_vdev_complete(struct dlb2_hw *hw, unsigned int vdev_id); 10445433956dSTimothy McDaniel 10455433956dSTimothy McDaniel /** 10465433956dSTimothy McDaniel * dlb2_pf_read_vf_mbox_req() - (PF only) read a VF->PF mailbox request 10475433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 10485433956dSTimothy McDaniel * @vf_id: VF ID. 10495433956dSTimothy McDaniel * @data: pointer to message data. 10505433956dSTimothy McDaniel * @len: size, in bytes, of the data array. 10515433956dSTimothy McDaniel * 10525433956dSTimothy McDaniel * This function copies one of the PF's VF->PF mailboxes into the array pointed 10535433956dSTimothy McDaniel * to by data. 10545433956dSTimothy McDaniel * 10555433956dSTimothy McDaniel * Return: 10565433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 10575433956dSTimothy McDaniel * 10585433956dSTimothy McDaniel * EINVAL - len >= DLB2_VF2PF_REQ_BYTES. 10595433956dSTimothy McDaniel */ 10605433956dSTimothy McDaniel int dlb2_pf_read_vf_mbox_req(struct dlb2_hw *hw, 10615433956dSTimothy McDaniel unsigned int vf_id, 10625433956dSTimothy McDaniel void *data, 10635433956dSTimothy McDaniel int len); 10645433956dSTimothy McDaniel 10655433956dSTimothy McDaniel /** 10665433956dSTimothy McDaniel * dlb2_pf_read_vf_mbox_resp() - (PF only) read a VF->PF mailbox response 10675433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 10685433956dSTimothy McDaniel * @vf_id: VF ID. 10695433956dSTimothy McDaniel * @data: pointer to message data. 10705433956dSTimothy McDaniel * @len: size, in bytes, of the data array. 10715433956dSTimothy McDaniel * 10725433956dSTimothy McDaniel * This function copies one of the PF's VF->PF mailboxes into the array pointed 10735433956dSTimothy McDaniel * to by data. 10745433956dSTimothy McDaniel * 10755433956dSTimothy McDaniel * Return: 10765433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 10775433956dSTimothy McDaniel * 10785433956dSTimothy McDaniel * EINVAL - len >= DLB2_VF2PF_RESP_BYTES. 10795433956dSTimothy McDaniel */ 10805433956dSTimothy McDaniel int dlb2_pf_read_vf_mbox_resp(struct dlb2_hw *hw, 10815433956dSTimothy McDaniel unsigned int vf_id, 10825433956dSTimothy McDaniel void *data, 10835433956dSTimothy McDaniel int len); 10845433956dSTimothy McDaniel 10855433956dSTimothy McDaniel /** 10865433956dSTimothy McDaniel * dlb2_pf_write_vf_mbox_resp() - (PF only) write a PF->VF mailbox response 10875433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 10885433956dSTimothy McDaniel * @vf_id: VF ID. 10895433956dSTimothy McDaniel * @data: pointer to message data. 10905433956dSTimothy McDaniel * @len: size, in bytes, of the data array. 10915433956dSTimothy McDaniel * 10925433956dSTimothy McDaniel * This function copies the user-provided message data into of the PF's VF->PF 10935433956dSTimothy McDaniel * mailboxes. 10945433956dSTimothy McDaniel * 10955433956dSTimothy McDaniel * Return: 10965433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 10975433956dSTimothy McDaniel * 10985433956dSTimothy McDaniel * EINVAL - len >= DLB2_PF2VF_RESP_BYTES. 10995433956dSTimothy McDaniel */ 11005433956dSTimothy McDaniel int dlb2_pf_write_vf_mbox_resp(struct dlb2_hw *hw, 11015433956dSTimothy McDaniel unsigned int vf_id, 11025433956dSTimothy McDaniel void *data, 11035433956dSTimothy McDaniel int len); 11045433956dSTimothy McDaniel 11055433956dSTimothy McDaniel /** 11065433956dSTimothy McDaniel * dlb2_pf_write_vf_mbox_req() - (PF only) write a PF->VF mailbox request 11075433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 11085433956dSTimothy McDaniel * @vf_id: VF ID. 11095433956dSTimothy McDaniel * @data: pointer to message data. 11105433956dSTimothy McDaniel * @len: size, in bytes, of the data array. 11115433956dSTimothy McDaniel * 11125433956dSTimothy McDaniel * This function copies the user-provided message data into of the PF's VF->PF 11135433956dSTimothy McDaniel * mailboxes. 11145433956dSTimothy McDaniel * 11155433956dSTimothy McDaniel * Return: 11165433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 11175433956dSTimothy McDaniel * 11185433956dSTimothy McDaniel * EINVAL - len >= DLB2_PF2VF_REQ_BYTES. 11195433956dSTimothy McDaniel */ 11205433956dSTimothy McDaniel int dlb2_pf_write_vf_mbox_req(struct dlb2_hw *hw, 11215433956dSTimothy McDaniel unsigned int vf_id, 11225433956dSTimothy McDaniel void *data, 11235433956dSTimothy McDaniel int len); 11245433956dSTimothy McDaniel 11255433956dSTimothy McDaniel /** 11265433956dSTimothy McDaniel * dlb2_vf_read_pf_mbox_resp() - (VF only) read a PF->VF mailbox response 11275433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 11285433956dSTimothy McDaniel * @data: pointer to message data. 11295433956dSTimothy McDaniel * @len: size, in bytes, of the data array. 11305433956dSTimothy McDaniel * 11315433956dSTimothy McDaniel * This function copies the VF's PF->VF mailbox into the array pointed to by 11325433956dSTimothy McDaniel * data. 11335433956dSTimothy McDaniel * 11345433956dSTimothy McDaniel * Return: 11355433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 11365433956dSTimothy McDaniel * 11375433956dSTimothy McDaniel * EINVAL - len >= DLB2_PF2VF_RESP_BYTES. 11385433956dSTimothy McDaniel */ 11395433956dSTimothy McDaniel int dlb2_vf_read_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len); 11405433956dSTimothy McDaniel 11415433956dSTimothy McDaniel /** 11425433956dSTimothy McDaniel * dlb2_vf_read_pf_mbox_req() - (VF only) read a PF->VF mailbox request 11435433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 11445433956dSTimothy McDaniel * @data: pointer to message data. 11455433956dSTimothy McDaniel * @len: size, in bytes, of the data array. 11465433956dSTimothy McDaniel * 11475433956dSTimothy McDaniel * This function copies the VF's PF->VF mailbox into the array pointed to by 11485433956dSTimothy McDaniel * data. 11495433956dSTimothy McDaniel * 11505433956dSTimothy McDaniel * Return: 11515433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 11525433956dSTimothy McDaniel * 11535433956dSTimothy McDaniel * EINVAL - len >= DLB2_PF2VF_REQ_BYTES. 11545433956dSTimothy McDaniel */ 11555433956dSTimothy McDaniel int dlb2_vf_read_pf_mbox_req(struct dlb2_hw *hw, void *data, int len); 11565433956dSTimothy McDaniel 11575433956dSTimothy McDaniel /** 11585433956dSTimothy McDaniel * dlb2_vf_write_pf_mbox_req() - (VF only) write a VF->PF mailbox request 11595433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 11605433956dSTimothy McDaniel * @data: pointer to message data. 11615433956dSTimothy McDaniel * @len: size, in bytes, of the data array. 11625433956dSTimothy McDaniel * 11635433956dSTimothy McDaniel * This function copies the user-provided message data into of the VF's PF->VF 11645433956dSTimothy McDaniel * mailboxes. 11655433956dSTimothy McDaniel * 11665433956dSTimothy McDaniel * Return: 11675433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 11685433956dSTimothy McDaniel * 11695433956dSTimothy McDaniel * EINVAL - len >= DLB2_VF2PF_REQ_BYTES. 11705433956dSTimothy McDaniel */ 11715433956dSTimothy McDaniel int dlb2_vf_write_pf_mbox_req(struct dlb2_hw *hw, void *data, int len); 11725433956dSTimothy McDaniel 11735433956dSTimothy McDaniel /** 11745433956dSTimothy McDaniel * dlb2_vf_write_pf_mbox_resp() - (VF only) write a VF->PF mailbox response 11755433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 11765433956dSTimothy McDaniel * @data: pointer to message data. 11775433956dSTimothy McDaniel * @len: size, in bytes, of the data array. 11785433956dSTimothy McDaniel * 11795433956dSTimothy McDaniel * This function copies the user-provided message data into of the VF's PF->VF 11805433956dSTimothy McDaniel * mailboxes. 11815433956dSTimothy McDaniel * 11825433956dSTimothy McDaniel * Return: 11835433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 11845433956dSTimothy McDaniel * 11855433956dSTimothy McDaniel * EINVAL - len >= DLB2_VF2PF_RESP_BYTES. 11865433956dSTimothy McDaniel */ 11875433956dSTimothy McDaniel int dlb2_vf_write_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len); 11885433956dSTimothy McDaniel 11895433956dSTimothy McDaniel /** 11905433956dSTimothy McDaniel * dlb2_reset_vdev() - reset the hardware owned by a virtual device 11915433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 11925433956dSTimothy McDaniel * @id: virtual device ID 11935433956dSTimothy McDaniel * 11945433956dSTimothy McDaniel * This function resets the hardware owned by a vdev, by resetting the vdev's 11955433956dSTimothy McDaniel * domains one by one. 11965433956dSTimothy McDaniel * 11975433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 11985433956dSTimothy McDaniel * device. 11995433956dSTimothy McDaniel */ 12005433956dSTimothy McDaniel int dlb2_reset_vdev(struct dlb2_hw *hw, unsigned int id); 12015433956dSTimothy McDaniel 12025433956dSTimothy McDaniel /** 12035433956dSTimothy McDaniel * dlb2_vdev_is_locked() - check whether the vdev's resources are locked 12045433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 12055433956dSTimothy McDaniel * @id: virtual device ID 12065433956dSTimothy McDaniel * 12075433956dSTimothy McDaniel * This function returns whether or not the vdev's resource assignments are 12085433956dSTimothy McDaniel * locked. If locked, no resources can be added to or subtracted from the 12095433956dSTimothy McDaniel * group. 12105433956dSTimothy McDaniel * 12115433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 12125433956dSTimothy McDaniel * device. 12135433956dSTimothy McDaniel */ 12145433956dSTimothy McDaniel bool dlb2_vdev_is_locked(struct dlb2_hw *hw, unsigned int id); 12155433956dSTimothy McDaniel 12165433956dSTimothy McDaniel /** 12175433956dSTimothy McDaniel * dlb2_lock_vdev() - lock the vdev's resources 12185433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 12195433956dSTimothy McDaniel * @id: virtual device ID 12205433956dSTimothy McDaniel * 12215433956dSTimothy McDaniel * This function sets a flag indicating that the vdev is using its resources. 12225433956dSTimothy McDaniel * When the vdev is locked, its resource assignment cannot be changed. 12235433956dSTimothy McDaniel * 12245433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 12255433956dSTimothy McDaniel * device. 12265433956dSTimothy McDaniel */ 12275433956dSTimothy McDaniel void dlb2_lock_vdev(struct dlb2_hw *hw, unsigned int id); 12285433956dSTimothy McDaniel 12295433956dSTimothy McDaniel /** 12305433956dSTimothy McDaniel * dlb2_unlock_vdev() - unlock the vdev's resources 12315433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 12325433956dSTimothy McDaniel * @id: virtual device ID 12335433956dSTimothy McDaniel * 12345433956dSTimothy McDaniel * This function unlocks the vdev's resource assignment, allowing it to be 12355433956dSTimothy McDaniel * modified. 12365433956dSTimothy McDaniel * 12375433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 12385433956dSTimothy McDaniel * device. 12395433956dSTimothy McDaniel */ 12405433956dSTimothy McDaniel void dlb2_unlock_vdev(struct dlb2_hw *hw, unsigned int id); 12415433956dSTimothy McDaniel 12425433956dSTimothy McDaniel /** 12435433956dSTimothy McDaniel * dlb2_update_vdev_sched_domains() - update the domains assigned to a vdev 12445433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 12455433956dSTimothy McDaniel * @id: virtual device ID 12465433956dSTimothy McDaniel * @num: number of scheduling domains to assign to this vdev 12475433956dSTimothy McDaniel * 12485433956dSTimothy McDaniel * This function assigns num scheduling domains to the specified vdev. If the 12495433956dSTimothy McDaniel * vdev already has domains assigned, this existing assignment is adjusted 12505433956dSTimothy McDaniel * accordingly. 12515433956dSTimothy McDaniel * 12525433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 12535433956dSTimothy McDaniel * device. 12545433956dSTimothy McDaniel * 12555433956dSTimothy McDaniel * Return: 12565433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 12575433956dSTimothy McDaniel * 12585433956dSTimothy McDaniel * Errors: 12595433956dSTimothy McDaniel * EINVAL - id is invalid, or the requested number of resources are 12605433956dSTimothy McDaniel * unavailable. 12615433956dSTimothy McDaniel * EPERM - The vdev's resource assignment is locked and cannot be changed. 12625433956dSTimothy McDaniel */ 12635433956dSTimothy McDaniel int dlb2_update_vdev_sched_domains(struct dlb2_hw *hw, u32 id, u32 num); 12645433956dSTimothy McDaniel 12655433956dSTimothy McDaniel /** 12665433956dSTimothy McDaniel * dlb2_update_vdev_ldb_queues() - update the LDB queues assigned to a vdev 12675433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 12685433956dSTimothy McDaniel * @id: virtual device ID 12695433956dSTimothy McDaniel * @num: number of LDB queues to assign to this vdev 12705433956dSTimothy McDaniel * 12715433956dSTimothy McDaniel * This function assigns num LDB queues to the specified vdev. If the vdev 12725433956dSTimothy McDaniel * already has LDB queues assigned, this existing assignment is adjusted 12735433956dSTimothy McDaniel * accordingly. 12745433956dSTimothy McDaniel * 12755433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 12765433956dSTimothy McDaniel * device. 12775433956dSTimothy McDaniel * 12785433956dSTimothy McDaniel * Return: 12795433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 12805433956dSTimothy McDaniel * 12815433956dSTimothy McDaniel * Errors: 12825433956dSTimothy McDaniel * EINVAL - id is invalid, or the requested number of resources are 12835433956dSTimothy McDaniel * unavailable. 12845433956dSTimothy McDaniel * EPERM - The vdev's resource assignment is locked and cannot be changed. 12855433956dSTimothy McDaniel */ 12865433956dSTimothy McDaniel int dlb2_update_vdev_ldb_queues(struct dlb2_hw *hw, u32 id, u32 num); 12875433956dSTimothy McDaniel 12885433956dSTimothy McDaniel /** 12895433956dSTimothy McDaniel * dlb2_update_vdev_ldb_ports() - update the LDB ports assigned to a vdev 12905433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 12915433956dSTimothy McDaniel * @id: virtual device ID 12925433956dSTimothy McDaniel * @num: number of LDB ports to assign to this vdev 12935433956dSTimothy McDaniel * 12945433956dSTimothy McDaniel * This function assigns num LDB ports to the specified vdev. If the vdev 12955433956dSTimothy McDaniel * already has LDB ports assigned, this existing assignment is adjusted 12965433956dSTimothy McDaniel * accordingly. 12975433956dSTimothy McDaniel * 12985433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 12995433956dSTimothy McDaniel * device. 13005433956dSTimothy McDaniel * 13015433956dSTimothy McDaniel * Return: 13025433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 13035433956dSTimothy McDaniel * 13045433956dSTimothy McDaniel * Errors: 13055433956dSTimothy McDaniel * EINVAL - id is invalid, or the requested number of resources are 13065433956dSTimothy McDaniel * unavailable. 13075433956dSTimothy McDaniel * EPERM - The vdev's resource assignment is locked and cannot be changed. 13085433956dSTimothy McDaniel */ 13095433956dSTimothy McDaniel int dlb2_update_vdev_ldb_ports(struct dlb2_hw *hw, u32 id, u32 num); 13105433956dSTimothy McDaniel 13115433956dSTimothy McDaniel /** 13125433956dSTimothy McDaniel * dlb2_update_vdev_ldb_cos_ports() - update the LDB ports assigned to a vdev 13135433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 13145433956dSTimothy McDaniel * @id: virtual device ID 13155433956dSTimothy McDaniel * @cos: class-of-service ID 13165433956dSTimothy McDaniel * @num: number of LDB ports to assign to this vdev 13175433956dSTimothy McDaniel * 13185433956dSTimothy McDaniel * This function assigns num LDB ports from class-of-service cos to the 13195433956dSTimothy McDaniel * specified vdev. If the vdev already has LDB ports from this class-of-service 13205433956dSTimothy McDaniel * assigned, this existing assignment is adjusted accordingly. 13215433956dSTimothy McDaniel * 13225433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 13235433956dSTimothy McDaniel * device. 13245433956dSTimothy McDaniel * 13255433956dSTimothy McDaniel * Return: 13265433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 13275433956dSTimothy McDaniel * 13285433956dSTimothy McDaniel * Errors: 13295433956dSTimothy McDaniel * EINVAL - id is invalid, or the requested number of resources are 13305433956dSTimothy McDaniel * unavailable. 13315433956dSTimothy McDaniel * EPERM - The vdev's resource assignment is locked and cannot be changed. 13325433956dSTimothy McDaniel */ 13335433956dSTimothy McDaniel int dlb2_update_vdev_ldb_cos_ports(struct dlb2_hw *hw, 13345433956dSTimothy McDaniel u32 id, 13355433956dSTimothy McDaniel u32 cos, 13365433956dSTimothy McDaniel u32 num); 13375433956dSTimothy McDaniel 13385433956dSTimothy McDaniel /** 13395433956dSTimothy McDaniel * dlb2_update_vdev_dir_ports() - update the DIR ports assigned to a vdev 13405433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 13415433956dSTimothy McDaniel * @id: virtual device ID 13425433956dSTimothy McDaniel * @num: number of DIR ports to assign to this vdev 13435433956dSTimothy McDaniel * 13445433956dSTimothy McDaniel * This function assigns num DIR ports to the specified vdev. If the vdev 13455433956dSTimothy McDaniel * already has DIR ports assigned, this existing assignment is adjusted 13465433956dSTimothy McDaniel * accordingly. 13475433956dSTimothy McDaniel * 13485433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 13495433956dSTimothy McDaniel * device. 13505433956dSTimothy McDaniel * 13515433956dSTimothy McDaniel * Return: 13525433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 13535433956dSTimothy McDaniel * 13545433956dSTimothy McDaniel * Errors: 13555433956dSTimothy McDaniel * EINVAL - id is invalid, or the requested number of resources are 13565433956dSTimothy McDaniel * unavailable. 13575433956dSTimothy McDaniel * EPERM - The vdev's resource assignment is locked and cannot be changed. 13585433956dSTimothy McDaniel */ 13595433956dSTimothy McDaniel int dlb2_update_vdev_dir_ports(struct dlb2_hw *hw, u32 id, u32 num); 13605433956dSTimothy McDaniel 13615433956dSTimothy McDaniel /** 13625433956dSTimothy McDaniel * dlb2_update_vdev_ldb_credits() - update the vdev's assigned LDB credits 13635433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 13645433956dSTimothy McDaniel * @id: virtual device ID 13655433956dSTimothy McDaniel * @num: number of LDB credit credits to assign to this vdev 13665433956dSTimothy McDaniel * 13675433956dSTimothy McDaniel * This function assigns num LDB credit to the specified vdev. If the vdev 13685433956dSTimothy McDaniel * already has LDB credits assigned, this existing assignment is adjusted 13695433956dSTimothy McDaniel * accordingly. vdevs are assigned a contiguous chunk of credits, so this 13705433956dSTimothy McDaniel * function may fail if a sufficiently large contiguous chunk is not available. 13715433956dSTimothy McDaniel * 13725433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 13735433956dSTimothy McDaniel * device. 13745433956dSTimothy McDaniel * 13755433956dSTimothy McDaniel * Return: 13765433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 13775433956dSTimothy McDaniel * 13785433956dSTimothy McDaniel * Errors: 13795433956dSTimothy McDaniel * EINVAL - id is invalid, or the requested number of resources are 13805433956dSTimothy McDaniel * unavailable. 13815433956dSTimothy McDaniel * EPERM - The vdev's resource assignment is locked and cannot be changed. 13825433956dSTimothy McDaniel */ 13835433956dSTimothy McDaniel int dlb2_update_vdev_ldb_credits(struct dlb2_hw *hw, u32 id, u32 num); 13845433956dSTimothy McDaniel 13855433956dSTimothy McDaniel /** 13865433956dSTimothy McDaniel * dlb2_update_vdev_dir_credits() - update the vdev's assigned DIR credits 13875433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 13885433956dSTimothy McDaniel * @id: virtual device ID 13895433956dSTimothy McDaniel * @num: number of DIR credits to assign to this vdev 13905433956dSTimothy McDaniel * 13915433956dSTimothy McDaniel * This function assigns num DIR credit to the specified vdev. If the vdev 13925433956dSTimothy McDaniel * already has DIR credits assigned, this existing assignment is adjusted 13935433956dSTimothy McDaniel * accordingly. vdevs are assigned a contiguous chunk of credits, so this 13945433956dSTimothy McDaniel * function may fail if a sufficiently large contiguous chunk is not available. 13955433956dSTimothy McDaniel * 13965433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 13975433956dSTimothy McDaniel * device. 13985433956dSTimothy McDaniel * 13995433956dSTimothy McDaniel * Return: 14005433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 14015433956dSTimothy McDaniel * 14025433956dSTimothy McDaniel * Errors: 14035433956dSTimothy McDaniel * EINVAL - id is invalid, or the requested number of resources are 14045433956dSTimothy McDaniel * unavailable. 14055433956dSTimothy McDaniel * EPERM - The vdev's resource assignment is locked and cannot be changed. 14065433956dSTimothy McDaniel */ 14075433956dSTimothy McDaniel int dlb2_update_vdev_dir_credits(struct dlb2_hw *hw, u32 id, u32 num); 14085433956dSTimothy McDaniel 14095433956dSTimothy McDaniel /** 14105433956dSTimothy McDaniel * dlb2_update_vdev_hist_list_entries() - update the vdev's assigned HL entries 14115433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 14125433956dSTimothy McDaniel * @id: virtual device ID 14135433956dSTimothy McDaniel * @num: number of history list entries to assign to this vdev 14145433956dSTimothy McDaniel * 14155433956dSTimothy McDaniel * This function assigns num history list entries to the specified vdev. If the 14165433956dSTimothy McDaniel * vdev already has history list entries assigned, this existing assignment is 14175433956dSTimothy McDaniel * adjusted accordingly. vdevs are assigned a contiguous chunk of entries, so 14185433956dSTimothy McDaniel * this function may fail if a sufficiently large contiguous chunk is not 14195433956dSTimothy McDaniel * available. 14205433956dSTimothy McDaniel * 14215433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 14225433956dSTimothy McDaniel * device. 14235433956dSTimothy McDaniel * 14245433956dSTimothy McDaniel * Return: 14255433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 14265433956dSTimothy McDaniel * 14275433956dSTimothy McDaniel * Errors: 14285433956dSTimothy McDaniel * EINVAL - id is invalid, or the requested number of resources are 14295433956dSTimothy McDaniel * unavailable. 14305433956dSTimothy McDaniel * EPERM - The vdev's resource assignment is locked and cannot be changed. 14315433956dSTimothy McDaniel */ 14325433956dSTimothy McDaniel int dlb2_update_vdev_hist_list_entries(struct dlb2_hw *hw, u32 id, u32 num); 14335433956dSTimothy McDaniel 14345433956dSTimothy McDaniel /** 14355433956dSTimothy McDaniel * dlb2_update_vdev_atomic_inflights() - update the vdev's atomic inflights 14365433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 14375433956dSTimothy McDaniel * @id: virtual device ID 14385433956dSTimothy McDaniel * @num: number of atomic inflights to assign to this vdev 14395433956dSTimothy McDaniel * 14405433956dSTimothy McDaniel * This function assigns num atomic inflights to the specified vdev. If the vdev 14415433956dSTimothy McDaniel * already has atomic inflights assigned, this existing assignment is adjusted 14425433956dSTimothy McDaniel * accordingly. vdevs are assigned a contiguous chunk of entries, so this 14435433956dSTimothy McDaniel * function may fail if a sufficiently large contiguous chunk is not available. 14445433956dSTimothy McDaniel * 14455433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 14465433956dSTimothy McDaniel * device. 14475433956dSTimothy McDaniel * 14485433956dSTimothy McDaniel * Return: 14495433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 14505433956dSTimothy McDaniel * 14515433956dSTimothy McDaniel * Errors: 14525433956dSTimothy McDaniel * EINVAL - id is invalid, or the requested number of resources are 14535433956dSTimothy McDaniel * unavailable. 14545433956dSTimothy McDaniel * EPERM - The vdev's resource assignment is locked and cannot be changed. 14555433956dSTimothy McDaniel */ 14565433956dSTimothy McDaniel int dlb2_update_vdev_atomic_inflights(struct dlb2_hw *hw, u32 id, u32 num); 14575433956dSTimothy McDaniel 14585433956dSTimothy McDaniel /** 14595433956dSTimothy McDaniel * dlb2_reset_vdev_resources() - reassign the vdev's resources to the PF 14605433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 14615433956dSTimothy McDaniel * @id: virtual device ID 14625433956dSTimothy McDaniel * 14635433956dSTimothy McDaniel * This function takes any resources currently assigned to the vdev and 14645433956dSTimothy McDaniel * reassigns them to the PF. 14655433956dSTimothy McDaniel * 14665433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 14675433956dSTimothy McDaniel * device. 14685433956dSTimothy McDaniel * 14695433956dSTimothy McDaniel * Return: 14705433956dSTimothy McDaniel * Returns 0 upon success, <0 otherwise. 14715433956dSTimothy McDaniel * 14725433956dSTimothy McDaniel * Errors: 14735433956dSTimothy McDaniel * EINVAL - id is invalid 14745433956dSTimothy McDaniel * EPERM - The vdev's resource assignment is locked and cannot be changed. 14755433956dSTimothy McDaniel */ 14765433956dSTimothy McDaniel int dlb2_reset_vdev_resources(struct dlb2_hw *hw, unsigned int id); 14775433956dSTimothy McDaniel 14785433956dSTimothy McDaniel /** 14795433956dSTimothy McDaniel * dlb2_notify_vf() - send an alarm to a VF 14805433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 14815433956dSTimothy McDaniel * @vf_id: VF ID 14825433956dSTimothy McDaniel * @notification: notification 14835433956dSTimothy McDaniel * 14845433956dSTimothy McDaniel * This function sends a notification (as defined in dlb2_mbox.h) to a VF. 14855433956dSTimothy McDaniel * 14865433956dSTimothy McDaniel * Return: 14875433956dSTimothy McDaniel * Returns 0 upon success, <0 if the VF doesn't ACK the PF->VF interrupt. 14885433956dSTimothy McDaniel */ 14895433956dSTimothy McDaniel int dlb2_notify_vf(struct dlb2_hw *hw, 14905433956dSTimothy McDaniel unsigned int vf_id, 14915433956dSTimothy McDaniel u32 notification); 14925433956dSTimothy McDaniel 14935433956dSTimothy McDaniel /** 14945433956dSTimothy McDaniel * dlb2_vdev_in_use() - query whether a virtual device is in use 14955433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 14965433956dSTimothy McDaniel * @id: virtual device ID 14975433956dSTimothy McDaniel * 14985433956dSTimothy McDaniel * This function sends a mailbox request to the vdev to query whether the vdev 14995433956dSTimothy McDaniel * is in use. 15005433956dSTimothy McDaniel * 15015433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 15025433956dSTimothy McDaniel * device. 15035433956dSTimothy McDaniel * 15045433956dSTimothy McDaniel * Return: 15055433956dSTimothy McDaniel * Returns 0 for false, 1 for true, and <0 if the mailbox request times out or 15065433956dSTimothy McDaniel * an internal error occurs. 15075433956dSTimothy McDaniel */ 15085433956dSTimothy McDaniel int dlb2_vdev_in_use(struct dlb2_hw *hw, unsigned int id); 15095433956dSTimothy McDaniel 15105433956dSTimothy McDaniel /** 15115433956dSTimothy McDaniel * dlb2_hw_get_ldb_queue_depth() - returns the depth of a load-balanced queue 15125433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 15135433956dSTimothy McDaniel * @domain_id: domain ID. 15145433956dSTimothy McDaniel * @args: queue depth args 15155433956dSTimothy McDaniel * @resp: response structure. 15165433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 15175433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 15185433956dSTimothy McDaniel * 15195433956dSTimothy McDaniel * This function returns the depth of a load-balanced queue. 15205433956dSTimothy McDaniel * 15215433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 15225433956dSTimothy McDaniel * device. 15235433956dSTimothy McDaniel * 15245433956dSTimothy McDaniel * Return: 15255433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 15265433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. If successful, resp->id 15275433956dSTimothy McDaniel * contains the depth. 15285433956dSTimothy McDaniel * 15295433956dSTimothy McDaniel * Errors: 15305433956dSTimothy McDaniel * EINVAL - Invalid domain ID or queue ID. 15315433956dSTimothy McDaniel */ 15325433956dSTimothy McDaniel int dlb2_hw_get_ldb_queue_depth(struct dlb2_hw *hw, 15335433956dSTimothy McDaniel u32 domain_id, 15345433956dSTimothy McDaniel struct dlb2_get_ldb_queue_depth_args *args, 15355433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 15365433956dSTimothy McDaniel bool vdev_request, 15375433956dSTimothy McDaniel unsigned int vdev_id); 15385433956dSTimothy McDaniel 15395433956dSTimothy McDaniel /** 15405433956dSTimothy McDaniel * dlb2_hw_get_dir_queue_depth() - returns the depth of a directed queue 15415433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 15425433956dSTimothy McDaniel * @domain_id: domain ID. 15435433956dSTimothy McDaniel * @args: queue depth args 15445433956dSTimothy McDaniel * @resp: response structure. 15455433956dSTimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 15465433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 15475433956dSTimothy McDaniel * 15485433956dSTimothy McDaniel * This function returns the depth of a directed queue. 15495433956dSTimothy McDaniel * 15505433956dSTimothy McDaniel * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 15515433956dSTimothy McDaniel * device. 15525433956dSTimothy McDaniel * 15535433956dSTimothy McDaniel * Return: 15545433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 15555433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. If successful, resp->id 15565433956dSTimothy McDaniel * contains the depth. 15575433956dSTimothy McDaniel * 15585433956dSTimothy McDaniel * Errors: 15595433956dSTimothy McDaniel * EINVAL - Invalid domain ID or queue ID. 15605433956dSTimothy McDaniel */ 15615433956dSTimothy McDaniel int dlb2_hw_get_dir_queue_depth(struct dlb2_hw *hw, 15625433956dSTimothy McDaniel u32 domain_id, 15635433956dSTimothy McDaniel struct dlb2_get_dir_queue_depth_args *args, 15645433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 15655433956dSTimothy McDaniel bool vdev_request, 15665433956dSTimothy McDaniel unsigned int vdev_id); 15675433956dSTimothy McDaniel 15685433956dSTimothy McDaniel enum dlb2_virt_mode { 15695433956dSTimothy McDaniel DLB2_VIRT_NONE, 15705433956dSTimothy McDaniel DLB2_VIRT_SRIOV, 15715433956dSTimothy McDaniel DLB2_VIRT_SIOV, 15725433956dSTimothy McDaniel 15735433956dSTimothy McDaniel /* NUM_DLB2_VIRT_MODES must be last */ 15745433956dSTimothy McDaniel NUM_DLB2_VIRT_MODES, 15755433956dSTimothy McDaniel }; 15765433956dSTimothy McDaniel 15775433956dSTimothy McDaniel /** 15785433956dSTimothy McDaniel * dlb2_hw_set_virt_mode() - set the device's virtualization mode 15795433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 15805433956dSTimothy McDaniel * @mode: either none, SR-IOV, or Scalable IOV. 15815433956dSTimothy McDaniel * 15825433956dSTimothy McDaniel * This function sets the virtualization mode of the device. This controls 15835433956dSTimothy McDaniel * whether the device uses a software or hardware mailbox. 15845433956dSTimothy McDaniel * 15855433956dSTimothy McDaniel * This should be called by the PF driver when either SR-IOV or Scalable IOV is 15865433956dSTimothy McDaniel * selected as the virtualization mechanism, and by the VF/VDEV driver during 15875433956dSTimothy McDaniel * initialization after recognizing itself as an SR-IOV or Scalable IOV device. 15885433956dSTimothy McDaniel * 15895433956dSTimothy McDaniel * Errors: 15905433956dSTimothy McDaniel * EINVAL - Invalid mode. 15915433956dSTimothy McDaniel */ 15925433956dSTimothy McDaniel int dlb2_hw_set_virt_mode(struct dlb2_hw *hw, enum dlb2_virt_mode mode); 15935433956dSTimothy McDaniel 15945433956dSTimothy McDaniel /** 15955433956dSTimothy McDaniel * dlb2_hw_get_virt_mode() - get the device's virtualization mode 15965433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 15975433956dSTimothy McDaniel * 15985433956dSTimothy McDaniel * This function gets the virtualization mode of the device. 15995433956dSTimothy McDaniel */ 16005433956dSTimothy McDaniel enum dlb2_virt_mode dlb2_hw_get_virt_mode(struct dlb2_hw *hw); 16015433956dSTimothy McDaniel 16025433956dSTimothy McDaniel /** 16035433956dSTimothy McDaniel * dlb2_hw_get_ldb_port_phys_id() - get a physical port ID from its virt ID 16045433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 16055433956dSTimothy McDaniel * @id: virtual port ID. 16065433956dSTimothy McDaniel * @vdev_id: vdev ID. 16075433956dSTimothy McDaniel * 16085433956dSTimothy McDaniel * Return: 16095433956dSTimothy McDaniel * Returns >= 0 upon success, -1 otherwise. 16105433956dSTimothy McDaniel */ 16115433956dSTimothy McDaniel s32 dlb2_hw_get_ldb_port_phys_id(struct dlb2_hw *hw, 16125433956dSTimothy McDaniel u32 id, 16135433956dSTimothy McDaniel unsigned int vdev_id); 16145433956dSTimothy McDaniel 16155433956dSTimothy McDaniel /** 16165433956dSTimothy McDaniel * dlb2_hw_get_dir_port_phys_id() - get a physical port ID from its virt ID 16175433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 16185433956dSTimothy McDaniel * @id: virtual port ID. 16195433956dSTimothy McDaniel * @vdev_id: vdev ID. 16205433956dSTimothy McDaniel * 16215433956dSTimothy McDaniel * Return: 16225433956dSTimothy McDaniel * Returns >= 0 upon success, -1 otherwise. 16235433956dSTimothy McDaniel */ 16245433956dSTimothy McDaniel s32 dlb2_hw_get_dir_port_phys_id(struct dlb2_hw *hw, 16255433956dSTimothy McDaniel u32 id, 16265433956dSTimothy McDaniel unsigned int vdev_id); 16275433956dSTimothy McDaniel 16285433956dSTimothy McDaniel /** 16295433956dSTimothy McDaniel * dlb2_hw_register_sw_mbox() - register a software mailbox 16305433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 16315433956dSTimothy McDaniel * @vdev_id: vdev ID. 16325433956dSTimothy McDaniel * @vdev2pf_mbox: pointer to a 4KB memory page used for vdev->PF communication. 16335433956dSTimothy McDaniel * @pf2vdev_mbox: pointer to a 4KB memory page used for PF->vdev communication. 16345433956dSTimothy McDaniel * @pf2vdev_inject: callback function for injecting a PF->vdev interrupt. 16355433956dSTimothy McDaniel * @inject_arg: user argument for pf2vdev_inject callback. 16365433956dSTimothy McDaniel * 16375433956dSTimothy McDaniel * When Scalable IOV is enabled, the VDCM must register a software mailbox for 16385433956dSTimothy McDaniel * every virtual device during vdev creation. 16395433956dSTimothy McDaniel * 16405433956dSTimothy McDaniel * This function notifies the driver to use a software mailbox using the 16415433956dSTimothy McDaniel * provided pointers, instead of the device's hardware mailbox. When the driver 16425433956dSTimothy McDaniel * calls mailbox functions like dlb2_pf_write_vf_mbox_req(), the request will 16435433956dSTimothy McDaniel * go to the software mailbox instead of the hardware one. This is used in 16445433956dSTimothy McDaniel * Scalable IOV virtualization. 16455433956dSTimothy McDaniel */ 16465433956dSTimothy McDaniel void dlb2_hw_register_sw_mbox(struct dlb2_hw *hw, 16475433956dSTimothy McDaniel unsigned int vdev_id, 16485433956dSTimothy McDaniel u32 *vdev2pf_mbox, 16495433956dSTimothy McDaniel u32 *pf2vdev_mbox, 16505433956dSTimothy McDaniel void (*pf2vdev_inject)(void *), 16515433956dSTimothy McDaniel void *inject_arg); 16525433956dSTimothy McDaniel 16535433956dSTimothy McDaniel /** 16545433956dSTimothy McDaniel * dlb2_hw_unregister_sw_mbox() - unregister a software mailbox 16555433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 16565433956dSTimothy McDaniel * @vdev_id: vdev ID. 16575433956dSTimothy McDaniel * 16585433956dSTimothy McDaniel * This function notifies the driver to stop using a previously registered 16595433956dSTimothy McDaniel * software mailbox. 16605433956dSTimothy McDaniel */ 16615433956dSTimothy McDaniel void dlb2_hw_unregister_sw_mbox(struct dlb2_hw *hw, unsigned int vdev_id); 16625433956dSTimothy McDaniel 16635433956dSTimothy McDaniel /** 16645433956dSTimothy McDaniel * dlb2_hw_setup_cq_ims_entry() - setup a CQ's IMS entry 16655433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 16665433956dSTimothy McDaniel * @vdev_id: vdev ID. 16675433956dSTimothy McDaniel * @virt_cq_id: virtual CQ ID. 16685433956dSTimothy McDaniel * @is_ldb: CQ is load-balanced. 16695433956dSTimothy McDaniel * @addr_lo: least-significant 32 bits of address. 16705433956dSTimothy McDaniel * @data: 32 data bits. 16715433956dSTimothy McDaniel * 16725433956dSTimothy McDaniel * This sets up the CQ's IMS entry with the provided address and data values. 16735433956dSTimothy McDaniel * This function should only be called if the device is configured for Scalable 16745433956dSTimothy McDaniel * IOV virtualization. The upper 32 address bits are fixed in hardware and thus 16755433956dSTimothy McDaniel * not needed. 16765433956dSTimothy McDaniel */ 16775433956dSTimothy McDaniel void dlb2_hw_setup_cq_ims_entry(struct dlb2_hw *hw, 16785433956dSTimothy McDaniel unsigned int vdev_id, 16795433956dSTimothy McDaniel u32 virt_cq_id, 16805433956dSTimothy McDaniel bool is_ldb, 16815433956dSTimothy McDaniel u32 addr_lo, 16825433956dSTimothy McDaniel u32 data); 16835433956dSTimothy McDaniel 16845433956dSTimothy McDaniel /** 16855433956dSTimothy McDaniel * dlb2_hw_clear_cq_ims_entry() - clear a CQ's IMS entry 16865433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 16875433956dSTimothy McDaniel * @vdev_id: vdev ID. 16885433956dSTimothy McDaniel * @virt_cq_id: virtual CQ ID. 16895433956dSTimothy McDaniel * @is_ldb: CQ is load-balanced. 16905433956dSTimothy McDaniel * 16915433956dSTimothy McDaniel * This clears the CQ's IMS entry, reverting it to its reset state. 16925433956dSTimothy McDaniel */ 16935433956dSTimothy McDaniel void dlb2_hw_clear_cq_ims_entry(struct dlb2_hw *hw, 16945433956dSTimothy McDaniel unsigned int vdev_id, 16955433956dSTimothy McDaniel u32 virt_cq_id, 16965433956dSTimothy McDaniel bool is_ldb); 16975433956dSTimothy McDaniel 16985433956dSTimothy McDaniel /** 16995433956dSTimothy McDaniel * dlb2_hw_register_pasid() - register a vdev's PASID 17005433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 17015433956dSTimothy McDaniel * @vdev_id: vdev ID. 17025433956dSTimothy McDaniel * @pasid: the vdev's PASID. 17035433956dSTimothy McDaniel * 17045433956dSTimothy McDaniel * This function stores the user-supplied PASID, and uses it when configuring 17055433956dSTimothy McDaniel * the vdev's CQs. 17065433956dSTimothy McDaniel * 17075433956dSTimothy McDaniel * Return: 17085433956dSTimothy McDaniel * Returns >= 0 upon success, -1 otherwise. 17095433956dSTimothy McDaniel */ 17105433956dSTimothy McDaniel int dlb2_hw_register_pasid(struct dlb2_hw *hw, 17115433956dSTimothy McDaniel unsigned int vdev_id, 17125433956dSTimothy McDaniel unsigned int pasid); 17135433956dSTimothy McDaniel 17145433956dSTimothy McDaniel /** 17155433956dSTimothy McDaniel * dlb2_hw_pending_port_unmaps() - returns the number of unmap operations in 17165433956dSTimothy McDaniel * progress. 17175433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 17185433956dSTimothy McDaniel * @domain_id: domain ID. 17195433956dSTimothy McDaniel * @args: number of unmaps in progress args 17205433956dSTimothy McDaniel * @resp: response structure. 17215433956dSTimothy McDaniel * @vf_request: indicates whether this request came from a VF. 17225433956dSTimothy McDaniel * @vf_id: If vf_request is true, this contains the VF's ID. 17235433956dSTimothy McDaniel * 17245433956dSTimothy McDaniel * Return: 17255433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 17265433956dSTimothy McDaniel * assigned a detailed error code from enum dlb2_error. If successful, resp->id 17275433956dSTimothy McDaniel * contains the number of unmaps in progress. 17285433956dSTimothy McDaniel * 17295433956dSTimothy McDaniel * Errors: 17305433956dSTimothy McDaniel * EINVAL - Invalid port ID. 17315433956dSTimothy McDaniel */ 17325433956dSTimothy McDaniel int dlb2_hw_pending_port_unmaps(struct dlb2_hw *hw, 17335433956dSTimothy McDaniel u32 domain_id, 17345433956dSTimothy McDaniel struct dlb2_pending_port_unmaps_args *args, 17355433956dSTimothy McDaniel struct dlb2_cmd_response *resp, 17365433956dSTimothy McDaniel bool vf_request, 17375433956dSTimothy McDaniel unsigned int vf_id); 17385433956dSTimothy McDaniel 17395433956dSTimothy McDaniel /** 17405433956dSTimothy McDaniel * dlb2_hw_get_cos_bandwidth() - returns the percent of bandwidth allocated 17415433956dSTimothy McDaniel * to a port class-of-service. 17425433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 17435433956dSTimothy McDaniel * @cos_id: class-of-service ID. 17445433956dSTimothy McDaniel * 17455433956dSTimothy McDaniel * Return: 17465433956dSTimothy McDaniel * Returns -EINVAL if cos_id is invalid, else the class' bandwidth allocation. 17475433956dSTimothy McDaniel */ 17485433956dSTimothy McDaniel int dlb2_hw_get_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id); 17495433956dSTimothy McDaniel 17505433956dSTimothy McDaniel /** 17515433956dSTimothy McDaniel * dlb2_hw_set_cos_bandwidth() - set a bandwidth allocation percentage for a 17525433956dSTimothy McDaniel * port class-of-service. 17535433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 17545433956dSTimothy McDaniel * @cos_id: class-of-service ID. 17555433956dSTimothy McDaniel * @bandwidth: class-of-service bandwidth. 17565433956dSTimothy McDaniel * 17575433956dSTimothy McDaniel * Return: 17585433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. 17595433956dSTimothy McDaniel * 17605433956dSTimothy McDaniel * Errors: 17615433956dSTimothy McDaniel * EINVAL - Invalid cos ID, bandwidth is greater than 100, or bandwidth would 17625433956dSTimothy McDaniel * cause the total bandwidth across all classes of service to exceed 17635433956dSTimothy McDaniel * 100%. 17645433956dSTimothy McDaniel */ 17655433956dSTimothy McDaniel int dlb2_hw_set_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id, u8 bandwidth); 17665433956dSTimothy McDaniel 17675433956dSTimothy McDaniel enum dlb2_wd_tmo { 17685433956dSTimothy McDaniel /* 40s watchdog timeout */ 17695433956dSTimothy McDaniel DLB2_WD_TMO_40S, 17705433956dSTimothy McDaniel /* 10s watchdog timeout */ 17715433956dSTimothy McDaniel DLB2_WD_TMO_10S, 17725433956dSTimothy McDaniel /* 1s watchdog timeout */ 17735433956dSTimothy McDaniel DLB2_WD_TMO_1S, 17745433956dSTimothy McDaniel 17755433956dSTimothy McDaniel /* Must be last */ 17765433956dSTimothy McDaniel NUM_DLB2_WD_TMOS, 17775433956dSTimothy McDaniel }; 17785433956dSTimothy McDaniel 17795433956dSTimothy McDaniel /** 17805433956dSTimothy McDaniel * dlb2_hw_enable_wd_timer() - enable the CQ watchdog timers with a 17815433956dSTimothy McDaniel * caller-specified timeout. 17825433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 17835433956dSTimothy McDaniel * @tmo: watchdog timeout. 17845433956dSTimothy McDaniel * 17855433956dSTimothy McDaniel * This function should be called during device initialization and after reset. 17865433956dSTimothy McDaniel * The watchdog timer interrupt must also be enabled per-CQ, using either 17875433956dSTimothy McDaniel * dlb2_hw_enable_dir_cq_wd_int() or dlb2_hw_enable_ldb_cq_wd_int(). 17885433956dSTimothy McDaniel * 17895433956dSTimothy McDaniel * Return: 17905433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. 17915433956dSTimothy McDaniel * 17925433956dSTimothy McDaniel * Errors: 17935433956dSTimothy McDaniel * EINVAL - Invalid timeout. 17945433956dSTimothy McDaniel */ 17955433956dSTimothy McDaniel int dlb2_hw_enable_wd_timer(struct dlb2_hw *hw, enum dlb2_wd_tmo tmo); 17965433956dSTimothy McDaniel 17975433956dSTimothy McDaniel /** 17985433956dSTimothy McDaniel * dlb2_hw_enable_dir_cq_wd_int() - enable the CQ watchdog interrupt on an 17995433956dSTimothy McDaniel * individual CQ. 18005433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 18015433956dSTimothy McDaniel * @id: port ID. 18025433956dSTimothy McDaniel * @vdev_req: indicates whether this request came from a vdev. 18035433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 18045433956dSTimothy McDaniel * 18055433956dSTimothy McDaniel * Return: 18065433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. 18075433956dSTimothy McDaniel * 18085433956dSTimothy McDaniel * Errors: 18095433956dSTimothy McDaniel * EINVAL - Invalid directed port ID. 18105433956dSTimothy McDaniel */ 18115433956dSTimothy McDaniel int dlb2_hw_enable_dir_cq_wd_int(struct dlb2_hw *hw, 18125433956dSTimothy McDaniel u32 id, 18135433956dSTimothy McDaniel bool vdev_req, 18145433956dSTimothy McDaniel unsigned int vdev_id); 18155433956dSTimothy McDaniel 18165433956dSTimothy McDaniel /** 18175433956dSTimothy McDaniel * dlb2_hw_enable_ldb_cq_wd_int() - enable the CQ watchdog interrupt on an 18185433956dSTimothy McDaniel * individual CQ. 18195433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 18205433956dSTimothy McDaniel * @id: port ID. 18215433956dSTimothy McDaniel * @vdev_req: indicates whether this request came from a vdev. 18225433956dSTimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 18235433956dSTimothy McDaniel * 18245433956dSTimothy McDaniel * Return: 18255433956dSTimothy McDaniel * Returns 0 upon success, < 0 otherwise. 18265433956dSTimothy McDaniel * 18275433956dSTimothy McDaniel * Errors: 18285433956dSTimothy McDaniel * EINVAL - Invalid load-balanced port ID. 18295433956dSTimothy McDaniel */ 18305433956dSTimothy McDaniel int dlb2_hw_enable_ldb_cq_wd_int(struct dlb2_hw *hw, 18315433956dSTimothy McDaniel u32 id, 18325433956dSTimothy McDaniel bool vdev_req, 18335433956dSTimothy McDaniel unsigned int vdev_id); 18345433956dSTimothy McDaniel 18355433956dSTimothy McDaniel /** 18365433956dSTimothy McDaniel * dlb2_hw_enable_sparse_ldb_cq_mode() - enable sparse mode for load-balanced 18375433956dSTimothy McDaniel * ports. 18385433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 18395433956dSTimothy McDaniel * 18405433956dSTimothy McDaniel * This function must be called prior to configuring scheduling domains. 18415433956dSTimothy McDaniel */ 18425433956dSTimothy McDaniel void dlb2_hw_enable_sparse_ldb_cq_mode(struct dlb2_hw *hw); 18435433956dSTimothy McDaniel 18445433956dSTimothy McDaniel /** 18455433956dSTimothy McDaniel * dlb2_hw_enable_sparse_dir_cq_mode() - enable sparse mode for directed ports. 18465433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 18475433956dSTimothy McDaniel * 18485433956dSTimothy McDaniel * This function must be called prior to configuring scheduling domains. 18495433956dSTimothy McDaniel */ 18505433956dSTimothy McDaniel void dlb2_hw_enable_sparse_dir_cq_mode(struct dlb2_hw *hw); 18515433956dSTimothy McDaniel 18525433956dSTimothy McDaniel /** 18535433956dSTimothy McDaniel * dlb2_hw_set_qe_arbiter_weights() - program QE arbiter weights 18545433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 18555433956dSTimothy McDaniel * @weight: 8-entry array of arbiter weights. 18565433956dSTimothy McDaniel * 18575433956dSTimothy McDaniel * weight[N] programs priority N's weight. In cases where the 8 priorities are 18585433956dSTimothy McDaniel * reduced to 4 bins, the mapping is: 18595433956dSTimothy McDaniel * - weight[1] programs bin 0 18605433956dSTimothy McDaniel * - weight[3] programs bin 1 18615433956dSTimothy McDaniel * - weight[5] programs bin 2 18625433956dSTimothy McDaniel * - weight[7] programs bin 3 18635433956dSTimothy McDaniel */ 18645433956dSTimothy McDaniel void dlb2_hw_set_qe_arbiter_weights(struct dlb2_hw *hw, u8 weight[8]); 18655433956dSTimothy McDaniel 18665433956dSTimothy McDaniel /** 18675433956dSTimothy McDaniel * dlb2_hw_set_qid_arbiter_weights() - program QID arbiter weights 18685433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 18695433956dSTimothy McDaniel * @weight: 8-entry array of arbiter weights. 18705433956dSTimothy McDaniel * 18715433956dSTimothy McDaniel * weight[N] programs priority N's weight. In cases where the 8 priorities are 18725433956dSTimothy McDaniel * reduced to 4 bins, the mapping is: 18735433956dSTimothy McDaniel * - weight[1] programs bin 0 18745433956dSTimothy McDaniel * - weight[3] programs bin 1 18755433956dSTimothy McDaniel * - weight[5] programs bin 2 18765433956dSTimothy McDaniel * - weight[7] programs bin 3 18775433956dSTimothy McDaniel */ 18785433956dSTimothy McDaniel void dlb2_hw_set_qid_arbiter_weights(struct dlb2_hw *hw, u8 weight[8]); 18795433956dSTimothy McDaniel 18805433956dSTimothy McDaniel /** 18815433956dSTimothy McDaniel * dlb2_hw_ldb_cq_interrupt_enabled() - Check if the interrupt is enabled 18825433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 18835433956dSTimothy McDaniel * @port_id: physical load-balanced port ID. 18845433956dSTimothy McDaniel * 18855433956dSTimothy McDaniel * This function returns whether the load-balanced CQ interrupt is enabled. 18865433956dSTimothy McDaniel */ 18875433956dSTimothy McDaniel int dlb2_hw_ldb_cq_interrupt_enabled(struct dlb2_hw *hw, int port_id); 18885433956dSTimothy McDaniel 18895433956dSTimothy McDaniel /** 18905433956dSTimothy McDaniel * dlb2_hw_ldb_cq_interrupt_set_mode() - Program the CQ interrupt mode 18915433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 18925433956dSTimothy McDaniel * @port_id: physical load-balanced port ID. 18935433956dSTimothy McDaniel * @mode: interrupt type (DLB2_CQ_ISR_MODE_{DIS, MSI, MSIX, ADI}) 18945433956dSTimothy McDaniel * 18955433956dSTimothy McDaniel * This function can be used to disable (MODE_DIS) and re-enable the 18965433956dSTimothy McDaniel * load-balanced CQ's interrupt. It should only be called after the interrupt 18975433956dSTimothy McDaniel * has been configured with dlb2_configure_ldb_cq_interrupt(). 18985433956dSTimothy McDaniel */ 18995433956dSTimothy McDaniel void dlb2_hw_ldb_cq_interrupt_set_mode(struct dlb2_hw *hw, 19005433956dSTimothy McDaniel int port_id, 19015433956dSTimothy McDaniel int mode); 19025433956dSTimothy McDaniel 19035433956dSTimothy McDaniel /** 19045433956dSTimothy McDaniel * dlb2_hw_dir_cq_interrupt_enabled() - Check if the interrupt is enabled 19055433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 19065433956dSTimothy McDaniel * @port_id: physical load-balanced port ID. 19075433956dSTimothy McDaniel * 19085433956dSTimothy McDaniel * This function returns whether the load-balanced CQ interrupt is enabled. 19095433956dSTimothy McDaniel */ 19105433956dSTimothy McDaniel int dlb2_hw_dir_cq_interrupt_enabled(struct dlb2_hw *hw, int port_id); 19115433956dSTimothy McDaniel 19125433956dSTimothy McDaniel /** 19135433956dSTimothy McDaniel * dlb2_hw_dir_cq_interrupt_set_mode() - Program the CQ interrupt mode 19145433956dSTimothy McDaniel * @hw: dlb2_hw handle for a particular device. 19155433956dSTimothy McDaniel * @port_id: physical directed port ID. 19165433956dSTimothy McDaniel * @mode: interrupt type (DLB2_CQ_ISR_MODE_{DIS, MSI, MSIX, ADI}) 19175433956dSTimothy McDaniel * 19185433956dSTimothy McDaniel * This function can be used to disable (MODE_DIS) and re-enable the 19195433956dSTimothy McDaniel * directed CQ's interrupt. It should only be called after the interrupt 19205433956dSTimothy McDaniel * has been configured with dlb2_configure_dir_cq_interrupt(). 19215433956dSTimothy McDaniel */ 19225433956dSTimothy McDaniel void dlb2_hw_dir_cq_interrupt_set_mode(struct dlb2_hw *hw, 19235433956dSTimothy McDaniel int port_id, 19245433956dSTimothy McDaniel int mode); 19255433956dSTimothy McDaniel 1926ffa46fc4STimothy McDaniel /** 1927ffa46fc4STimothy McDaniel * dlb2_hw_enable_cq_weight() - Enable QE-weight based scheduling on an LDB port. 1928ffa46fc4STimothy McDaniel * @hw: dlb2_hw handle for a particular device. 1929ffa46fc4STimothy McDaniel * @domain_id: domain ID. 1930ffa46fc4STimothy McDaniel * @args: CQ weight enablement arguments. 1931ffa46fc4STimothy McDaniel * @resp: response structure. 1932ffa46fc4STimothy McDaniel * @vdev_request: indicates whether this request came from a vdev. 1933ffa46fc4STimothy McDaniel * @vdev_id: If vdev_request is true, this contains the vdev's ID. 1934ffa46fc4STimothy McDaniel * 1935ffa46fc4STimothy McDaniel * This function enables QE-weight based scheduling on a load-balanced port's 1936ffa46fc4STimothy McDaniel * CQ and configures the CQ's weight limit. 1937ffa46fc4STimothy McDaniel * 1938ffa46fc4STimothy McDaniel * This must be called after creating the port but before starting the 1939ffa46fc4STimothy McDaniel * domain. 1940ffa46fc4STimothy McDaniel * 1941ffa46fc4STimothy McDaniel * Return: 1942ffa46fc4STimothy McDaniel * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 1943ffa46fc4STimothy McDaniel * assigned a detailed error code from enum dlb2_error. If successful, resp->id 1944ffa46fc4STimothy McDaniel * contains the queue ID. 1945ffa46fc4STimothy McDaniel * 1946ffa46fc4STimothy McDaniel * Errors: 1947ffa46fc4STimothy McDaniel * EINVAL - The domain or port is not configured, the domainhas already been 1948ffa46fc4STimothy McDaniel * started, the requested limit exceeds the port's CQ depth, or this 1949ffa46fc4STimothy McDaniel * feature is unavailable on the device. 1950ffa46fc4STimothy McDaniel * EFAULT - Internal error (resp->status not set). 1951ffa46fc4STimothy McDaniel */ 1952ffa46fc4STimothy McDaniel int dlb2_hw_enable_cq_weight(struct dlb2_hw *hw, 1953ffa46fc4STimothy McDaniel u32 domain_id, 1954ffa46fc4STimothy McDaniel struct dlb2_enable_cq_weight_args *args, 1955ffa46fc4STimothy McDaniel struct dlb2_cmd_response *resp, 1956ffa46fc4STimothy McDaniel bool vdev_request, 1957ffa46fc4STimothy McDaniel unsigned int vdev_id); 1958ffa46fc4STimothy McDaniel 19595433956dSTimothy McDaniel #endif /* __DLB2_RESOURCE_H */ 1960