19a5325c2SAlexander Motin /*- 29a5325c2SAlexander Motin * Copyright (c) 2016 Alexander Motin <mav@FreeBSD.org> 39a5325c2SAlexander Motin * All rights reserved. 49a5325c2SAlexander Motin * 59a5325c2SAlexander Motin * Redistribution and use in source and binary forms, with or without 69a5325c2SAlexander Motin * modification, are permitted provided that the following conditions 79a5325c2SAlexander Motin * are met: 89a5325c2SAlexander Motin * 1. Redistributions of source code must retain the above copyright 99a5325c2SAlexander Motin * notice, this list of conditions and the following disclaimer. 109a5325c2SAlexander Motin * 2. Redistributions in binary form must reproduce the above copyright 119a5325c2SAlexander Motin * notice, this list of conditions and the following disclaimer in the 129a5325c2SAlexander Motin * documentation and/or other materials provided with the distribution. 139a5325c2SAlexander Motin * 149a5325c2SAlexander Motin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 159a5325c2SAlexander Motin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 169a5325c2SAlexander Motin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 179a5325c2SAlexander Motin * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 189a5325c2SAlexander Motin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 199a5325c2SAlexander Motin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 209a5325c2SAlexander Motin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 219a5325c2SAlexander Motin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 229a5325c2SAlexander Motin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 239a5325c2SAlexander Motin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 249a5325c2SAlexander Motin * SUCH DAMAGE. 259a5325c2SAlexander Motin * 269a5325c2SAlexander Motin * $FreeBSD$ 279a5325c2SAlexander Motin */ 289a5325c2SAlexander Motin 299a5325c2SAlexander Motin #ifndef _NTB_H_ 309a5325c2SAlexander Motin #define _NTB_H_ 319a5325c2SAlexander Motin 329a5325c2SAlexander Motin #include "ntb_if.h" 339a5325c2SAlexander Motin 349a5325c2SAlexander Motin extern devclass_t ntb_hw_devclass; 359a5325c2SAlexander Motin SYSCTL_DECL(_hw_ntb); 369a5325c2SAlexander Motin 374490696bSAlexander Motin int ntb_register_device(device_t ntb); 384490696bSAlexander Motin int ntb_unregister_device(device_t ntb); 39b7dd3fbeSAlexander Motin int ntb_child_location_str(device_t dev, device_t child, char *buf, 40b7dd3fbeSAlexander Motin size_t buflen); 41b7dd3fbeSAlexander Motin int ntb_print_child(device_t dev, device_t child); 424490696bSAlexander Motin 434490696bSAlexander Motin /* 444490696bSAlexander Motin * ntb_link_event() - notify driver context of a change in link status 454490696bSAlexander Motin * @ntb: NTB device context 464490696bSAlexander Motin * 474490696bSAlexander Motin * Notify the driver context that the link status may have changed. The driver 484490696bSAlexander Motin * should call intb_link_is_up() to get the current status. 494490696bSAlexander Motin */ 504490696bSAlexander Motin void ntb_link_event(device_t ntb); 514490696bSAlexander Motin 524490696bSAlexander Motin /* 534490696bSAlexander Motin * ntb_db_event() - notify driver context of a doorbell event 544490696bSAlexander Motin * @ntb: NTB device context 554490696bSAlexander Motin * @vector: Interrupt vector number 564490696bSAlexander Motin * 574490696bSAlexander Motin * Notify the driver context of a doorbell event. If hardware supports 584490696bSAlexander Motin * multiple interrupt vectors for doorbells, the vector number indicates which 594490696bSAlexander Motin * vector received the interrupt. The vector number is relative to the first 604490696bSAlexander Motin * vector used for doorbells, starting at zero, and must be less than 614490696bSAlexander Motin * ntb_db_vector_count(). The driver may call ntb_db_read() to check which 624490696bSAlexander Motin * doorbell bits need service, and ntb_db_vector_mask() to determine which of 634490696bSAlexander Motin * those bits are associated with the vector number. 644490696bSAlexander Motin */ 654490696bSAlexander Motin void ntb_db_event(device_t ntb, uint32_t vec); 664490696bSAlexander Motin 674490696bSAlexander Motin /* 684490696bSAlexander Motin * ntb_link_is_up() - get the current ntb link state 694490696bSAlexander Motin * @ntb: NTB device context 704490696bSAlexander Motin * @speed: OUT - The link speed expressed as PCIe generation number 714490696bSAlexander Motin * @width: OUT - The link width expressed as the number of PCIe lanes 724490696bSAlexander Motin * 734490696bSAlexander Motin * RETURNS: true or false based on the hardware link state 744490696bSAlexander Motin */ 754490696bSAlexander Motin bool ntb_link_is_up(device_t ntb, enum ntb_speed *speed, enum ntb_width *width); 764490696bSAlexander Motin 774490696bSAlexander Motin /* 784490696bSAlexander Motin * ntb_link_enable() - enable the link on the secondary side of the ntb 794490696bSAlexander Motin * @ntb: NTB device context 804490696bSAlexander Motin * @max_speed: The maximum link speed expressed as PCIe generation number[0] 814490696bSAlexander Motin * @max_width: The maximum link width expressed as the number of PCIe lanes[0] 824490696bSAlexander Motin * 834490696bSAlexander Motin * Enable the link on the secondary side of the ntb. This can only be done 844490696bSAlexander Motin * from the primary side of the ntb in primary or b2b topology. The ntb device 854490696bSAlexander Motin * should train the link to its maximum speed and width, or the requested speed 864490696bSAlexander Motin * and width, whichever is smaller, if supported. 874490696bSAlexander Motin * 884490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 894490696bSAlexander Motin * 904490696bSAlexander Motin * [0]: Only NTB_SPEED_AUTO and NTB_WIDTH_AUTO are valid inputs; other speed 914490696bSAlexander Motin * and width input will be ignored. 924490696bSAlexander Motin */ 934490696bSAlexander Motin int ntb_link_enable(device_t ntb, enum ntb_speed speed, enum ntb_width width); 944490696bSAlexander Motin 954490696bSAlexander Motin /* 964490696bSAlexander Motin * ntb_link_disable() - disable the link on the secondary side of the ntb 974490696bSAlexander Motin * @ntb: NTB device context 984490696bSAlexander Motin * 994490696bSAlexander Motin * Disable the link on the secondary side of the ntb. This can only be done 1004490696bSAlexander Motin * from the primary side of the ntb in primary or b2b topology. The ntb device 1014490696bSAlexander Motin * should disable the link. Returning from this call must indicate that a 1024490696bSAlexander Motin * barrier has passed, though with no more writes may pass in either direction 1034490696bSAlexander Motin * across the link, except if this call returns an error number. 1044490696bSAlexander Motin * 1054490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 1064490696bSAlexander Motin */ 1074490696bSAlexander Motin int ntb_link_disable(device_t ntb); 1084490696bSAlexander Motin 1094490696bSAlexander Motin /* 1104490696bSAlexander Motin * get enable status of the link on the secondary side of the ntb 1114490696bSAlexander Motin */ 1124490696bSAlexander Motin bool ntb_link_enabled(device_t ntb); 1134490696bSAlexander Motin 1144490696bSAlexander Motin /* 1154490696bSAlexander Motin * ntb_set_ctx() - associate a driver context with an ntb device 1164490696bSAlexander Motin * @ntb: NTB device context 1174490696bSAlexander Motin * @ctx: Driver context 1184490696bSAlexander Motin * @ctx_ops: Driver context operations 1194490696bSAlexander Motin * 1204490696bSAlexander Motin * Associate a driver context and operations with a ntb device. The context is 1214490696bSAlexander Motin * provided by the client driver, and the driver may associate a different 1224490696bSAlexander Motin * context with each ntb device. 1234490696bSAlexander Motin * 1244490696bSAlexander Motin * Return: Zero if the context is associated, otherwise an error number. 1254490696bSAlexander Motin */ 1264490696bSAlexander Motin int ntb_set_ctx(device_t ntb, void *ctx, const struct ntb_ctx_ops *ctx_ops); 1274490696bSAlexander Motin 1284490696bSAlexander Motin /* 1294490696bSAlexander Motin * ntb_set_ctx() - get a driver context associated with an ntb device 1304490696bSAlexander Motin * @ntb: NTB device context 1314490696bSAlexander Motin * @ctx_ops: Driver context operations 1324490696bSAlexander Motin * 1334490696bSAlexander Motin * Get a driver context and operations associated with a ntb device. 1344490696bSAlexander Motin */ 1354490696bSAlexander Motin void * ntb_get_ctx(device_t ntb, const struct ntb_ctx_ops **ctx_ops); 1364490696bSAlexander Motin 1374490696bSAlexander Motin /* 1384490696bSAlexander Motin * ntb_clear_ctx() - disassociate any driver context from an ntb device 1394490696bSAlexander Motin * @ntb: NTB device context 1404490696bSAlexander Motin * 1414490696bSAlexander Motin * Clear any association that may exist between a driver context and the ntb 1424490696bSAlexander Motin * device. 1434490696bSAlexander Motin */ 1444490696bSAlexander Motin void ntb_clear_ctx(device_t ntb); 1454490696bSAlexander Motin 1464490696bSAlexander Motin /* 1474490696bSAlexander Motin * ntb_mw_count() - Get the number of memory windows available for KPI 1484490696bSAlexander Motin * consumers. 1494490696bSAlexander Motin * 1504490696bSAlexander Motin * (Excludes any MW wholly reserved for register access.) 1514490696bSAlexander Motin */ 1524490696bSAlexander Motin uint8_t ntb_mw_count(device_t ntb); 1534490696bSAlexander Motin 1544490696bSAlexander Motin /* 1554490696bSAlexander Motin * ntb_mw_get_range() - get the range of a memory window 1564490696bSAlexander Motin * @ntb: NTB device context 1574490696bSAlexander Motin * @idx: Memory window number 1584490696bSAlexander Motin * @base: OUT - the base address for mapping the memory window 1594490696bSAlexander Motin * @size: OUT - the size for mapping the memory window 1604490696bSAlexander Motin * @align: OUT - the base alignment for translating the memory window 1614490696bSAlexander Motin * @align_size: OUT - the size alignment for translating the memory window 1624490696bSAlexander Motin * 1634490696bSAlexander Motin * Get the range of a memory window. NULL may be given for any output 1644490696bSAlexander Motin * parameter if the value is not needed. The base and size may be used for 1654490696bSAlexander Motin * mapping the memory window, to access the peer memory. The alignment and 1664490696bSAlexander Motin * size may be used for translating the memory window, for the peer to access 1674490696bSAlexander Motin * memory on the local system. 1684490696bSAlexander Motin * 1694490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 1704490696bSAlexander Motin */ 1714490696bSAlexander Motin int ntb_mw_get_range(device_t ntb, unsigned mw_idx, vm_paddr_t *base, 1724490696bSAlexander Motin caddr_t *vbase, size_t *size, size_t *align, size_t *align_size, 1734490696bSAlexander Motin bus_addr_t *plimit); 1744490696bSAlexander Motin 1754490696bSAlexander Motin /* 1764490696bSAlexander Motin * ntb_mw_set_trans() - set the translation of a memory window 1774490696bSAlexander Motin * @ntb: NTB device context 1784490696bSAlexander Motin * @idx: Memory window number 1794490696bSAlexander Motin * @addr: The dma address local memory to expose to the peer 1804490696bSAlexander Motin * @size: The size of the local memory to expose to the peer 1814490696bSAlexander Motin * 1824490696bSAlexander Motin * Set the translation of a memory window. The peer may access local memory 1834490696bSAlexander Motin * through the window starting at the address, up to the size. The address 1844490696bSAlexander Motin * must be aligned to the alignment specified by ntb_mw_get_range(). The size 1854490696bSAlexander Motin * must be aligned to the size alignment specified by ntb_mw_get_range(). The 1864490696bSAlexander Motin * address must be below the plimit specified by ntb_mw_get_range() (i.e. for 1874490696bSAlexander Motin * 32-bit BARs). 1884490696bSAlexander Motin * 1894490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 1904490696bSAlexander Motin */ 1914490696bSAlexander Motin int ntb_mw_set_trans(device_t ntb, unsigned mw_idx, bus_addr_t addr, 1924490696bSAlexander Motin size_t size); 1934490696bSAlexander Motin 1944490696bSAlexander Motin /* 1954490696bSAlexander Motin * ntb_mw_clear_trans() - clear the translation of a memory window 1964490696bSAlexander Motin * @ntb: NTB device context 1974490696bSAlexander Motin * @idx: Memory window number 1984490696bSAlexander Motin * 1994490696bSAlexander Motin * Clear the translation of a memory window. The peer may no longer access 2004490696bSAlexander Motin * local memory through the window. 2014490696bSAlexander Motin * 2024490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 2034490696bSAlexander Motin */ 2044490696bSAlexander Motin int ntb_mw_clear_trans(device_t ntb, unsigned mw_idx); 2054490696bSAlexander Motin 2064490696bSAlexander Motin /* 2074490696bSAlexander Motin * ntb_mw_get_wc - Get the write-combine status of a memory window 2084490696bSAlexander Motin * 2094490696bSAlexander Motin * Returns: Zero on success, setting *wc; otherwise an error number (e.g. if 2104490696bSAlexander Motin * idx is an invalid memory window). 2114490696bSAlexander Motin * 2124490696bSAlexander Motin * Mode is a VM_MEMATTR_* type. 2134490696bSAlexander Motin */ 2144490696bSAlexander Motin int ntb_mw_get_wc(device_t ntb, unsigned mw_idx, vm_memattr_t *mode); 2154490696bSAlexander Motin 2164490696bSAlexander Motin /* 2174490696bSAlexander Motin * ntb_mw_set_wc - Set the write-combine status of a memory window 2184490696bSAlexander Motin * 2194490696bSAlexander Motin * If 'mode' matches the current status, this does nothing and succeeds. Mode 2204490696bSAlexander Motin * is a VM_MEMATTR_* type. 2214490696bSAlexander Motin * 2224490696bSAlexander Motin * Returns: Zero on success, setting the caching attribute on the virtual 2234490696bSAlexander Motin * mapping of the BAR; otherwise an error number (e.g. if idx is an invalid 2244490696bSAlexander Motin * memory window, or if changing the caching attribute fails). 2254490696bSAlexander Motin */ 2264490696bSAlexander Motin int ntb_mw_set_wc(device_t ntb, unsigned mw_idx, vm_memattr_t mode); 2274490696bSAlexander Motin 2284490696bSAlexander Motin /* 2294490696bSAlexander Motin * ntb_spad_count() - get the total scratch regs usable 2304490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 2314490696bSAlexander Motin * 2324490696bSAlexander Motin * This function returns the max 32bit scratchpad registers usable by the 2334490696bSAlexander Motin * upper layer. 2344490696bSAlexander Motin * 2354490696bSAlexander Motin * RETURNS: total number of scratch pad registers available 2364490696bSAlexander Motin */ 2374490696bSAlexander Motin uint8_t ntb_spad_count(device_t ntb); 2384490696bSAlexander Motin 2394490696bSAlexander Motin /* 2404490696bSAlexander Motin * ntb_get_max_spads() - zero local scratch registers 2414490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 2424490696bSAlexander Motin * 2434490696bSAlexander Motin * This functions overwrites all local scratchpad registers with zeroes. 2444490696bSAlexander Motin */ 2454490696bSAlexander Motin void ntb_spad_clear(device_t ntb); 2464490696bSAlexander Motin 2474490696bSAlexander Motin /* 2484490696bSAlexander Motin * ntb_spad_write() - write to the secondary scratchpad register 2494490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 2504490696bSAlexander Motin * @idx: index to the scratchpad register, 0 based 2514490696bSAlexander Motin * @val: the data value to put into the register 2524490696bSAlexander Motin * 2534490696bSAlexander Motin * This function allows writing of a 32bit value to the indexed scratchpad 2544490696bSAlexander Motin * register. The register resides on the secondary (external) side. 2554490696bSAlexander Motin * 2564490696bSAlexander Motin * RETURNS: An appropriate ERRNO error value on error, or zero for success. 2574490696bSAlexander Motin */ 2584490696bSAlexander Motin int ntb_spad_write(device_t ntb, unsigned int idx, uint32_t val); 2594490696bSAlexander Motin 2604490696bSAlexander Motin /* 2614490696bSAlexander Motin * ntb_spad_read() - read from the primary scratchpad register 2624490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 2634490696bSAlexander Motin * @idx: index to scratchpad register, 0 based 2644490696bSAlexander Motin * @val: pointer to 32bit integer for storing the register value 2654490696bSAlexander Motin * 2664490696bSAlexander Motin * This function allows reading of the 32bit scratchpad register on 2674490696bSAlexander Motin * the primary (internal) side. 2684490696bSAlexander Motin * 2694490696bSAlexander Motin * RETURNS: An appropriate ERRNO error value on error, or zero for success. 2704490696bSAlexander Motin */ 2714490696bSAlexander Motin int ntb_spad_read(device_t ntb, unsigned int idx, uint32_t *val); 2724490696bSAlexander Motin 2734490696bSAlexander Motin /* 2744490696bSAlexander Motin * ntb_peer_spad_write() - write to the secondary scratchpad register 2754490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 2764490696bSAlexander Motin * @idx: index to the scratchpad register, 0 based 2774490696bSAlexander Motin * @val: the data value to put into the register 2784490696bSAlexander Motin * 2794490696bSAlexander Motin * This function allows writing of a 32bit value to the indexed scratchpad 2804490696bSAlexander Motin * register. The register resides on the secondary (external) side. 2814490696bSAlexander Motin * 2824490696bSAlexander Motin * RETURNS: An appropriate ERRNO error value on error, or zero for success. 2834490696bSAlexander Motin */ 2844490696bSAlexander Motin int ntb_peer_spad_write(device_t ntb, unsigned int idx, uint32_t val); 2854490696bSAlexander Motin 2864490696bSAlexander Motin /* 2874490696bSAlexander Motin * ntb_peer_spad_read() - read from the primary scratchpad register 2884490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 2894490696bSAlexander Motin * @idx: index to scratchpad register, 0 based 2904490696bSAlexander Motin * @val: pointer to 32bit integer for storing the register value 2914490696bSAlexander Motin * 2924490696bSAlexander Motin * This function allows reading of the 32bit scratchpad register on 2934490696bSAlexander Motin * the primary (internal) side. 2944490696bSAlexander Motin * 2954490696bSAlexander Motin * RETURNS: An appropriate ERRNO error value on error, or zero for success. 2964490696bSAlexander Motin */ 2974490696bSAlexander Motin int ntb_peer_spad_read(device_t ntb, unsigned int idx, uint32_t *val); 2984490696bSAlexander Motin 2994490696bSAlexander Motin /* 3004490696bSAlexander Motin * ntb_db_valid_mask() - get a mask of doorbell bits supported by the ntb 3014490696bSAlexander Motin * @ntb: NTB device context 3024490696bSAlexander Motin * 3034490696bSAlexander Motin * Hardware may support different number or arrangement of doorbell bits. 3044490696bSAlexander Motin * 3054490696bSAlexander Motin * Return: A mask of doorbell bits supported by the ntb. 3064490696bSAlexander Motin */ 3074490696bSAlexander Motin uint64_t ntb_db_valid_mask(device_t ntb); 3084490696bSAlexander Motin 3094490696bSAlexander Motin /* 3104490696bSAlexander Motin * ntb_db_vector_count() - get the number of doorbell interrupt vectors 3114490696bSAlexander Motin * @ntb: NTB device context. 3124490696bSAlexander Motin * 3134490696bSAlexander Motin * Hardware may support different number of interrupt vectors. 3144490696bSAlexander Motin * 3154490696bSAlexander Motin * Return: The number of doorbell interrupt vectors. 3164490696bSAlexander Motin */ 3174490696bSAlexander Motin int ntb_db_vector_count(device_t ntb); 3184490696bSAlexander Motin 3194490696bSAlexander Motin /* 3204490696bSAlexander Motin * ntb_db_vector_mask() - get a mask of doorbell bits serviced by a vector 3214490696bSAlexander Motin * @ntb: NTB device context 3224490696bSAlexander Motin * @vector: Doorbell vector number 3234490696bSAlexander Motin * 3244490696bSAlexander Motin * Each interrupt vector may have a different number or arrangement of bits. 3254490696bSAlexander Motin * 3264490696bSAlexander Motin * Return: A mask of doorbell bits serviced by a vector. 3274490696bSAlexander Motin */ 3284490696bSAlexander Motin uint64_t ntb_db_vector_mask(device_t ntb, uint32_t vector); 3294490696bSAlexander Motin 3304490696bSAlexander Motin /* 3314490696bSAlexander Motin * ntb_peer_db_addr() - address and size of the peer doorbell register 3324490696bSAlexander Motin * @ntb: NTB device context. 3334490696bSAlexander Motin * @db_addr: OUT - The address of the peer doorbell register. 3344490696bSAlexander Motin * @db_size: OUT - The number of bytes to write the peer doorbell register. 3354490696bSAlexander Motin * 3364490696bSAlexander Motin * Return the address of the peer doorbell register. This may be used, for 3374490696bSAlexander Motin * example, by drivers that offload memory copy operations to a dma engine. 3384490696bSAlexander Motin * The drivers may wish to ring the peer doorbell at the completion of memory 3394490696bSAlexander Motin * copy operations. For efficiency, and to simplify ordering of operations 3404490696bSAlexander Motin * between the dma memory copies and the ringing doorbell, the driver may 3414490696bSAlexander Motin * append one additional dma memory copy with the doorbell register as the 3424490696bSAlexander Motin * destination, after the memory copy operations. 3434490696bSAlexander Motin * 3444490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 3454490696bSAlexander Motin * 3464490696bSAlexander Motin * Note that writing the peer doorbell via a memory window will *not* generate 3474490696bSAlexander Motin * an interrupt on the remote host; that must be done separately. 3484490696bSAlexander Motin */ 3494490696bSAlexander Motin int ntb_peer_db_addr(device_t ntb, bus_addr_t *db_addr, vm_size_t *db_size); 3504490696bSAlexander Motin 3514490696bSAlexander Motin /* 3524490696bSAlexander Motin * ntb_db_clear() - clear bits in the local doorbell register 3534490696bSAlexander Motin * @ntb: NTB device context. 3544490696bSAlexander Motin * @db_bits: Doorbell bits to clear. 3554490696bSAlexander Motin * 3564490696bSAlexander Motin * Clear bits in the local doorbell register, arming the bits for the next 3574490696bSAlexander Motin * doorbell. 3584490696bSAlexander Motin * 3594490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 3604490696bSAlexander Motin */ 3614490696bSAlexander Motin void ntb_db_clear(device_t ntb, uint64_t bits); 3624490696bSAlexander Motin 3634490696bSAlexander Motin /* 3644490696bSAlexander Motin * ntb_db_clear_mask() - clear bits in the local doorbell mask 3654490696bSAlexander Motin * @ntb: NTB device context. 3664490696bSAlexander Motin * @db_bits: Doorbell bits to clear. 3674490696bSAlexander Motin * 3684490696bSAlexander Motin * Clear bits in the local doorbell mask register, allowing doorbell interrupts 3694490696bSAlexander Motin * from being generated for those doorbell bits. If a doorbell bit is already 3704490696bSAlexander Motin * set at the time the mask is cleared, and the corresponding mask bit is 3714490696bSAlexander Motin * changed from set to clear, then the ntb driver must ensure that 3724490696bSAlexander Motin * ntb_db_event() is called. If the hardware does not generate the interrupt 3734490696bSAlexander Motin * on clearing the mask bit, then the driver must call ntb_db_event() anyway. 3744490696bSAlexander Motin * 3754490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 3764490696bSAlexander Motin */ 3774490696bSAlexander Motin void ntb_db_clear_mask(device_t ntb, uint64_t bits); 3784490696bSAlexander Motin 3794490696bSAlexander Motin /* 3804490696bSAlexander Motin * ntb_db_read() - read the local doorbell register 3814490696bSAlexander Motin * @ntb: NTB device context. 3824490696bSAlexander Motin * 3834490696bSAlexander Motin * Read the local doorbell register, and return the bits that are set. 3844490696bSAlexander Motin * 3854490696bSAlexander Motin * Return: The bits currently set in the local doorbell register. 3864490696bSAlexander Motin */ 3874490696bSAlexander Motin uint64_t ntb_db_read(device_t ntb); 3884490696bSAlexander Motin 3894490696bSAlexander Motin /* 3904490696bSAlexander Motin * ntb_db_set_mask() - set bits in the local doorbell mask 3914490696bSAlexander Motin * @ntb: NTB device context. 3924490696bSAlexander Motin * @db_bits: Doorbell mask bits to set. 3934490696bSAlexander Motin * 3944490696bSAlexander Motin * Set bits in the local doorbell mask register, preventing doorbell interrupts 3954490696bSAlexander Motin * from being generated for those doorbell bits. Bits that were already set 3964490696bSAlexander Motin * must remain set. 3974490696bSAlexander Motin * 3984490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 3994490696bSAlexander Motin */ 4004490696bSAlexander Motin void ntb_db_set_mask(device_t ntb, uint64_t bits); 4014490696bSAlexander Motin 4024490696bSAlexander Motin /* 4034490696bSAlexander Motin * ntb_peer_db_set() - Set the doorbell on the secondary/external side 4044490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 4054490696bSAlexander Motin * @bit: doorbell bits to ring 4064490696bSAlexander Motin * 4074490696bSAlexander Motin * This function allows triggering of a doorbell on the secondary/external 4084490696bSAlexander Motin * side that will initiate an interrupt on the remote host 4094490696bSAlexander Motin */ 4104490696bSAlexander Motin void ntb_peer_db_set(device_t ntb, uint64_t bits); 4114490696bSAlexander Motin 4129a5325c2SAlexander Motin #endif /* _NTB_H_ */ 413