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 37*4490696bSAlexander Motin int ntb_register_device(device_t ntb); 38*4490696bSAlexander Motin int ntb_unregister_device(device_t ntb); 39*4490696bSAlexander Motin 40*4490696bSAlexander Motin /* 41*4490696bSAlexander Motin * ntb_link_event() - notify driver context of a change in link status 42*4490696bSAlexander Motin * @ntb: NTB device context 43*4490696bSAlexander Motin * 44*4490696bSAlexander Motin * Notify the driver context that the link status may have changed. The driver 45*4490696bSAlexander Motin * should call intb_link_is_up() to get the current status. 46*4490696bSAlexander Motin */ 47*4490696bSAlexander Motin void ntb_link_event(device_t ntb); 48*4490696bSAlexander Motin 49*4490696bSAlexander Motin /* 50*4490696bSAlexander Motin * ntb_db_event() - notify driver context of a doorbell event 51*4490696bSAlexander Motin * @ntb: NTB device context 52*4490696bSAlexander Motin * @vector: Interrupt vector number 53*4490696bSAlexander Motin * 54*4490696bSAlexander Motin * Notify the driver context of a doorbell event. If hardware supports 55*4490696bSAlexander Motin * multiple interrupt vectors for doorbells, the vector number indicates which 56*4490696bSAlexander Motin * vector received the interrupt. The vector number is relative to the first 57*4490696bSAlexander Motin * vector used for doorbells, starting at zero, and must be less than 58*4490696bSAlexander Motin * ntb_db_vector_count(). The driver may call ntb_db_read() to check which 59*4490696bSAlexander Motin * doorbell bits need service, and ntb_db_vector_mask() to determine which of 60*4490696bSAlexander Motin * those bits are associated with the vector number. 61*4490696bSAlexander Motin */ 62*4490696bSAlexander Motin void ntb_db_event(device_t ntb, uint32_t vec); 63*4490696bSAlexander Motin 64*4490696bSAlexander Motin /* 65*4490696bSAlexander Motin * ntb_link_is_up() - get the current ntb link state 66*4490696bSAlexander Motin * @ntb: NTB device context 67*4490696bSAlexander Motin * @speed: OUT - The link speed expressed as PCIe generation number 68*4490696bSAlexander Motin * @width: OUT - The link width expressed as the number of PCIe lanes 69*4490696bSAlexander Motin * 70*4490696bSAlexander Motin * RETURNS: true or false based on the hardware link state 71*4490696bSAlexander Motin */ 72*4490696bSAlexander Motin bool ntb_link_is_up(device_t ntb, enum ntb_speed *speed, enum ntb_width *width); 73*4490696bSAlexander Motin 74*4490696bSAlexander Motin /* 75*4490696bSAlexander Motin * ntb_link_enable() - enable the link on the secondary side of the ntb 76*4490696bSAlexander Motin * @ntb: NTB device context 77*4490696bSAlexander Motin * @max_speed: The maximum link speed expressed as PCIe generation number[0] 78*4490696bSAlexander Motin * @max_width: The maximum link width expressed as the number of PCIe lanes[0] 79*4490696bSAlexander Motin * 80*4490696bSAlexander Motin * Enable the link on the secondary side of the ntb. This can only be done 81*4490696bSAlexander Motin * from the primary side of the ntb in primary or b2b topology. The ntb device 82*4490696bSAlexander Motin * should train the link to its maximum speed and width, or the requested speed 83*4490696bSAlexander Motin * and width, whichever is smaller, if supported. 84*4490696bSAlexander Motin * 85*4490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 86*4490696bSAlexander Motin * 87*4490696bSAlexander Motin * [0]: Only NTB_SPEED_AUTO and NTB_WIDTH_AUTO are valid inputs; other speed 88*4490696bSAlexander Motin * and width input will be ignored. 89*4490696bSAlexander Motin */ 90*4490696bSAlexander Motin int ntb_link_enable(device_t ntb, enum ntb_speed speed, enum ntb_width width); 91*4490696bSAlexander Motin 92*4490696bSAlexander Motin /* 93*4490696bSAlexander Motin * ntb_link_disable() - disable the link on the secondary side of the ntb 94*4490696bSAlexander Motin * @ntb: NTB device context 95*4490696bSAlexander Motin * 96*4490696bSAlexander Motin * Disable the link on the secondary side of the ntb. This can only be done 97*4490696bSAlexander Motin * from the primary side of the ntb in primary or b2b topology. The ntb device 98*4490696bSAlexander Motin * should disable the link. Returning from this call must indicate that a 99*4490696bSAlexander Motin * barrier has passed, though with no more writes may pass in either direction 100*4490696bSAlexander Motin * across the link, except if this call returns an error number. 101*4490696bSAlexander Motin * 102*4490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 103*4490696bSAlexander Motin */ 104*4490696bSAlexander Motin int ntb_link_disable(device_t ntb); 105*4490696bSAlexander Motin 106*4490696bSAlexander Motin /* 107*4490696bSAlexander Motin * get enable status of the link on the secondary side of the ntb 108*4490696bSAlexander Motin */ 109*4490696bSAlexander Motin bool ntb_link_enabled(device_t ntb); 110*4490696bSAlexander Motin 111*4490696bSAlexander Motin /* 112*4490696bSAlexander Motin * ntb_set_ctx() - associate a driver context with an ntb device 113*4490696bSAlexander Motin * @ntb: NTB device context 114*4490696bSAlexander Motin * @ctx: Driver context 115*4490696bSAlexander Motin * @ctx_ops: Driver context operations 116*4490696bSAlexander Motin * 117*4490696bSAlexander Motin * Associate a driver context and operations with a ntb device. The context is 118*4490696bSAlexander Motin * provided by the client driver, and the driver may associate a different 119*4490696bSAlexander Motin * context with each ntb device. 120*4490696bSAlexander Motin * 121*4490696bSAlexander Motin * Return: Zero if the context is associated, otherwise an error number. 122*4490696bSAlexander Motin */ 123*4490696bSAlexander Motin int ntb_set_ctx(device_t ntb, void *ctx, const struct ntb_ctx_ops *ctx_ops); 124*4490696bSAlexander Motin 125*4490696bSAlexander Motin /* 126*4490696bSAlexander Motin * ntb_set_ctx() - get a driver context associated with an ntb device 127*4490696bSAlexander Motin * @ntb: NTB device context 128*4490696bSAlexander Motin * @ctx_ops: Driver context operations 129*4490696bSAlexander Motin * 130*4490696bSAlexander Motin * Get a driver context and operations associated with a ntb device. 131*4490696bSAlexander Motin */ 132*4490696bSAlexander Motin void * ntb_get_ctx(device_t ntb, const struct ntb_ctx_ops **ctx_ops); 133*4490696bSAlexander Motin 134*4490696bSAlexander Motin /* 135*4490696bSAlexander Motin * ntb_clear_ctx() - disassociate any driver context from an ntb device 136*4490696bSAlexander Motin * @ntb: NTB device context 137*4490696bSAlexander Motin * 138*4490696bSAlexander Motin * Clear any association that may exist between a driver context and the ntb 139*4490696bSAlexander Motin * device. 140*4490696bSAlexander Motin */ 141*4490696bSAlexander Motin void ntb_clear_ctx(device_t ntb); 142*4490696bSAlexander Motin 143*4490696bSAlexander Motin /* 144*4490696bSAlexander Motin * ntb_mw_count() - Get the number of memory windows available for KPI 145*4490696bSAlexander Motin * consumers. 146*4490696bSAlexander Motin * 147*4490696bSAlexander Motin * (Excludes any MW wholly reserved for register access.) 148*4490696bSAlexander Motin */ 149*4490696bSAlexander Motin uint8_t ntb_mw_count(device_t ntb); 150*4490696bSAlexander Motin 151*4490696bSAlexander Motin /* 152*4490696bSAlexander Motin * ntb_mw_get_range() - get the range of a memory window 153*4490696bSAlexander Motin * @ntb: NTB device context 154*4490696bSAlexander Motin * @idx: Memory window number 155*4490696bSAlexander Motin * @base: OUT - the base address for mapping the memory window 156*4490696bSAlexander Motin * @size: OUT - the size for mapping the memory window 157*4490696bSAlexander Motin * @align: OUT - the base alignment for translating the memory window 158*4490696bSAlexander Motin * @align_size: OUT - the size alignment for translating the memory window 159*4490696bSAlexander Motin * 160*4490696bSAlexander Motin * Get the range of a memory window. NULL may be given for any output 161*4490696bSAlexander Motin * parameter if the value is not needed. The base and size may be used for 162*4490696bSAlexander Motin * mapping the memory window, to access the peer memory. The alignment and 163*4490696bSAlexander Motin * size may be used for translating the memory window, for the peer to access 164*4490696bSAlexander Motin * memory on the local system. 165*4490696bSAlexander Motin * 166*4490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 167*4490696bSAlexander Motin */ 168*4490696bSAlexander Motin int ntb_mw_get_range(device_t ntb, unsigned mw_idx, vm_paddr_t *base, 169*4490696bSAlexander Motin caddr_t *vbase, size_t *size, size_t *align, size_t *align_size, 170*4490696bSAlexander Motin bus_addr_t *plimit); 171*4490696bSAlexander Motin 172*4490696bSAlexander Motin /* 173*4490696bSAlexander Motin * ntb_mw_set_trans() - set the translation of a memory window 174*4490696bSAlexander Motin * @ntb: NTB device context 175*4490696bSAlexander Motin * @idx: Memory window number 176*4490696bSAlexander Motin * @addr: The dma address local memory to expose to the peer 177*4490696bSAlexander Motin * @size: The size of the local memory to expose to the peer 178*4490696bSAlexander Motin * 179*4490696bSAlexander Motin * Set the translation of a memory window. The peer may access local memory 180*4490696bSAlexander Motin * through the window starting at the address, up to the size. The address 181*4490696bSAlexander Motin * must be aligned to the alignment specified by ntb_mw_get_range(). The size 182*4490696bSAlexander Motin * must be aligned to the size alignment specified by ntb_mw_get_range(). The 183*4490696bSAlexander Motin * address must be below the plimit specified by ntb_mw_get_range() (i.e. for 184*4490696bSAlexander Motin * 32-bit BARs). 185*4490696bSAlexander Motin * 186*4490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 187*4490696bSAlexander Motin */ 188*4490696bSAlexander Motin int ntb_mw_set_trans(device_t ntb, unsigned mw_idx, bus_addr_t addr, 189*4490696bSAlexander Motin size_t size); 190*4490696bSAlexander Motin 191*4490696bSAlexander Motin /* 192*4490696bSAlexander Motin * ntb_mw_clear_trans() - clear the translation of a memory window 193*4490696bSAlexander Motin * @ntb: NTB device context 194*4490696bSAlexander Motin * @idx: Memory window number 195*4490696bSAlexander Motin * 196*4490696bSAlexander Motin * Clear the translation of a memory window. The peer may no longer access 197*4490696bSAlexander Motin * local memory through the window. 198*4490696bSAlexander Motin * 199*4490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 200*4490696bSAlexander Motin */ 201*4490696bSAlexander Motin int ntb_mw_clear_trans(device_t ntb, unsigned mw_idx); 202*4490696bSAlexander Motin 203*4490696bSAlexander Motin /* 204*4490696bSAlexander Motin * ntb_mw_get_wc - Get the write-combine status of a memory window 205*4490696bSAlexander Motin * 206*4490696bSAlexander Motin * Returns: Zero on success, setting *wc; otherwise an error number (e.g. if 207*4490696bSAlexander Motin * idx is an invalid memory window). 208*4490696bSAlexander Motin * 209*4490696bSAlexander Motin * Mode is a VM_MEMATTR_* type. 210*4490696bSAlexander Motin */ 211*4490696bSAlexander Motin int ntb_mw_get_wc(device_t ntb, unsigned mw_idx, vm_memattr_t *mode); 212*4490696bSAlexander Motin 213*4490696bSAlexander Motin /* 214*4490696bSAlexander Motin * ntb_mw_set_wc - Set the write-combine status of a memory window 215*4490696bSAlexander Motin * 216*4490696bSAlexander Motin * If 'mode' matches the current status, this does nothing and succeeds. Mode 217*4490696bSAlexander Motin * is a VM_MEMATTR_* type. 218*4490696bSAlexander Motin * 219*4490696bSAlexander Motin * Returns: Zero on success, setting the caching attribute on the virtual 220*4490696bSAlexander Motin * mapping of the BAR; otherwise an error number (e.g. if idx is an invalid 221*4490696bSAlexander Motin * memory window, or if changing the caching attribute fails). 222*4490696bSAlexander Motin */ 223*4490696bSAlexander Motin int ntb_mw_set_wc(device_t ntb, unsigned mw_idx, vm_memattr_t mode); 224*4490696bSAlexander Motin 225*4490696bSAlexander Motin /* 226*4490696bSAlexander Motin * ntb_spad_count() - get the total scratch regs usable 227*4490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 228*4490696bSAlexander Motin * 229*4490696bSAlexander Motin * This function returns the max 32bit scratchpad registers usable by the 230*4490696bSAlexander Motin * upper layer. 231*4490696bSAlexander Motin * 232*4490696bSAlexander Motin * RETURNS: total number of scratch pad registers available 233*4490696bSAlexander Motin */ 234*4490696bSAlexander Motin uint8_t ntb_spad_count(device_t ntb); 235*4490696bSAlexander Motin 236*4490696bSAlexander Motin /* 237*4490696bSAlexander Motin * ntb_get_max_spads() - zero local scratch registers 238*4490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 239*4490696bSAlexander Motin * 240*4490696bSAlexander Motin * This functions overwrites all local scratchpad registers with zeroes. 241*4490696bSAlexander Motin */ 242*4490696bSAlexander Motin void ntb_spad_clear(device_t ntb); 243*4490696bSAlexander Motin 244*4490696bSAlexander Motin /* 245*4490696bSAlexander Motin * ntb_spad_write() - write to the secondary scratchpad register 246*4490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 247*4490696bSAlexander Motin * @idx: index to the scratchpad register, 0 based 248*4490696bSAlexander Motin * @val: the data value to put into the register 249*4490696bSAlexander Motin * 250*4490696bSAlexander Motin * This function allows writing of a 32bit value to the indexed scratchpad 251*4490696bSAlexander Motin * register. The register resides on the secondary (external) side. 252*4490696bSAlexander Motin * 253*4490696bSAlexander Motin * RETURNS: An appropriate ERRNO error value on error, or zero for success. 254*4490696bSAlexander Motin */ 255*4490696bSAlexander Motin int ntb_spad_write(device_t ntb, unsigned int idx, uint32_t val); 256*4490696bSAlexander Motin 257*4490696bSAlexander Motin /* 258*4490696bSAlexander Motin * ntb_spad_read() - read from the primary scratchpad register 259*4490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 260*4490696bSAlexander Motin * @idx: index to scratchpad register, 0 based 261*4490696bSAlexander Motin * @val: pointer to 32bit integer for storing the register value 262*4490696bSAlexander Motin * 263*4490696bSAlexander Motin * This function allows reading of the 32bit scratchpad register on 264*4490696bSAlexander Motin * the primary (internal) side. 265*4490696bSAlexander Motin * 266*4490696bSAlexander Motin * RETURNS: An appropriate ERRNO error value on error, or zero for success. 267*4490696bSAlexander Motin */ 268*4490696bSAlexander Motin int ntb_spad_read(device_t ntb, unsigned int idx, uint32_t *val); 269*4490696bSAlexander Motin 270*4490696bSAlexander Motin /* 271*4490696bSAlexander Motin * ntb_peer_spad_write() - write to the secondary scratchpad register 272*4490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 273*4490696bSAlexander Motin * @idx: index to the scratchpad register, 0 based 274*4490696bSAlexander Motin * @val: the data value to put into the register 275*4490696bSAlexander Motin * 276*4490696bSAlexander Motin * This function allows writing of a 32bit value to the indexed scratchpad 277*4490696bSAlexander Motin * register. The register resides on the secondary (external) side. 278*4490696bSAlexander Motin * 279*4490696bSAlexander Motin * RETURNS: An appropriate ERRNO error value on error, or zero for success. 280*4490696bSAlexander Motin */ 281*4490696bSAlexander Motin int ntb_peer_spad_write(device_t ntb, unsigned int idx, uint32_t val); 282*4490696bSAlexander Motin 283*4490696bSAlexander Motin /* 284*4490696bSAlexander Motin * ntb_peer_spad_read() - read from the primary scratchpad register 285*4490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 286*4490696bSAlexander Motin * @idx: index to scratchpad register, 0 based 287*4490696bSAlexander Motin * @val: pointer to 32bit integer for storing the register value 288*4490696bSAlexander Motin * 289*4490696bSAlexander Motin * This function allows reading of the 32bit scratchpad register on 290*4490696bSAlexander Motin * the primary (internal) side. 291*4490696bSAlexander Motin * 292*4490696bSAlexander Motin * RETURNS: An appropriate ERRNO error value on error, or zero for success. 293*4490696bSAlexander Motin */ 294*4490696bSAlexander Motin int ntb_peer_spad_read(device_t ntb, unsigned int idx, uint32_t *val); 295*4490696bSAlexander Motin 296*4490696bSAlexander Motin /* 297*4490696bSAlexander Motin * ntb_db_valid_mask() - get a mask of doorbell bits supported by the ntb 298*4490696bSAlexander Motin * @ntb: NTB device context 299*4490696bSAlexander Motin * 300*4490696bSAlexander Motin * Hardware may support different number or arrangement of doorbell bits. 301*4490696bSAlexander Motin * 302*4490696bSAlexander Motin * Return: A mask of doorbell bits supported by the ntb. 303*4490696bSAlexander Motin */ 304*4490696bSAlexander Motin uint64_t ntb_db_valid_mask(device_t ntb); 305*4490696bSAlexander Motin 306*4490696bSAlexander Motin /* 307*4490696bSAlexander Motin * ntb_db_vector_count() - get the number of doorbell interrupt vectors 308*4490696bSAlexander Motin * @ntb: NTB device context. 309*4490696bSAlexander Motin * 310*4490696bSAlexander Motin * Hardware may support different number of interrupt vectors. 311*4490696bSAlexander Motin * 312*4490696bSAlexander Motin * Return: The number of doorbell interrupt vectors. 313*4490696bSAlexander Motin */ 314*4490696bSAlexander Motin int ntb_db_vector_count(device_t ntb); 315*4490696bSAlexander Motin 316*4490696bSAlexander Motin /* 317*4490696bSAlexander Motin * ntb_db_vector_mask() - get a mask of doorbell bits serviced by a vector 318*4490696bSAlexander Motin * @ntb: NTB device context 319*4490696bSAlexander Motin * @vector: Doorbell vector number 320*4490696bSAlexander Motin * 321*4490696bSAlexander Motin * Each interrupt vector may have a different number or arrangement of bits. 322*4490696bSAlexander Motin * 323*4490696bSAlexander Motin * Return: A mask of doorbell bits serviced by a vector. 324*4490696bSAlexander Motin */ 325*4490696bSAlexander Motin uint64_t ntb_db_vector_mask(device_t ntb, uint32_t vector); 326*4490696bSAlexander Motin 327*4490696bSAlexander Motin /* 328*4490696bSAlexander Motin * ntb_peer_db_addr() - address and size of the peer doorbell register 329*4490696bSAlexander Motin * @ntb: NTB device context. 330*4490696bSAlexander Motin * @db_addr: OUT - The address of the peer doorbell register. 331*4490696bSAlexander Motin * @db_size: OUT - The number of bytes to write the peer doorbell register. 332*4490696bSAlexander Motin * 333*4490696bSAlexander Motin * Return the address of the peer doorbell register. This may be used, for 334*4490696bSAlexander Motin * example, by drivers that offload memory copy operations to a dma engine. 335*4490696bSAlexander Motin * The drivers may wish to ring the peer doorbell at the completion of memory 336*4490696bSAlexander Motin * copy operations. For efficiency, and to simplify ordering of operations 337*4490696bSAlexander Motin * between the dma memory copies and the ringing doorbell, the driver may 338*4490696bSAlexander Motin * append one additional dma memory copy with the doorbell register as the 339*4490696bSAlexander Motin * destination, after the memory copy operations. 340*4490696bSAlexander Motin * 341*4490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 342*4490696bSAlexander Motin * 343*4490696bSAlexander Motin * Note that writing the peer doorbell via a memory window will *not* generate 344*4490696bSAlexander Motin * an interrupt on the remote host; that must be done separately. 345*4490696bSAlexander Motin */ 346*4490696bSAlexander Motin int ntb_peer_db_addr(device_t ntb, bus_addr_t *db_addr, vm_size_t *db_size); 347*4490696bSAlexander Motin 348*4490696bSAlexander Motin /* 349*4490696bSAlexander Motin * ntb_db_clear() - clear bits in the local doorbell register 350*4490696bSAlexander Motin * @ntb: NTB device context. 351*4490696bSAlexander Motin * @db_bits: Doorbell bits to clear. 352*4490696bSAlexander Motin * 353*4490696bSAlexander Motin * Clear bits in the local doorbell register, arming the bits for the next 354*4490696bSAlexander Motin * doorbell. 355*4490696bSAlexander Motin * 356*4490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 357*4490696bSAlexander Motin */ 358*4490696bSAlexander Motin void ntb_db_clear(device_t ntb, uint64_t bits); 359*4490696bSAlexander Motin 360*4490696bSAlexander Motin /* 361*4490696bSAlexander Motin * ntb_db_clear_mask() - clear bits in the local doorbell mask 362*4490696bSAlexander Motin * @ntb: NTB device context. 363*4490696bSAlexander Motin * @db_bits: Doorbell bits to clear. 364*4490696bSAlexander Motin * 365*4490696bSAlexander Motin * Clear bits in the local doorbell mask register, allowing doorbell interrupts 366*4490696bSAlexander Motin * from being generated for those doorbell bits. If a doorbell bit is already 367*4490696bSAlexander Motin * set at the time the mask is cleared, and the corresponding mask bit is 368*4490696bSAlexander Motin * changed from set to clear, then the ntb driver must ensure that 369*4490696bSAlexander Motin * ntb_db_event() is called. If the hardware does not generate the interrupt 370*4490696bSAlexander Motin * on clearing the mask bit, then the driver must call ntb_db_event() anyway. 371*4490696bSAlexander Motin * 372*4490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 373*4490696bSAlexander Motin */ 374*4490696bSAlexander Motin void ntb_db_clear_mask(device_t ntb, uint64_t bits); 375*4490696bSAlexander Motin 376*4490696bSAlexander Motin /* 377*4490696bSAlexander Motin * ntb_db_read() - read the local doorbell register 378*4490696bSAlexander Motin * @ntb: NTB device context. 379*4490696bSAlexander Motin * 380*4490696bSAlexander Motin * Read the local doorbell register, and return the bits that are set. 381*4490696bSAlexander Motin * 382*4490696bSAlexander Motin * Return: The bits currently set in the local doorbell register. 383*4490696bSAlexander Motin */ 384*4490696bSAlexander Motin uint64_t ntb_db_read(device_t ntb); 385*4490696bSAlexander Motin 386*4490696bSAlexander Motin /* 387*4490696bSAlexander Motin * ntb_db_set_mask() - set bits in the local doorbell mask 388*4490696bSAlexander Motin * @ntb: NTB device context. 389*4490696bSAlexander Motin * @db_bits: Doorbell mask bits to set. 390*4490696bSAlexander Motin * 391*4490696bSAlexander Motin * Set bits in the local doorbell mask register, preventing doorbell interrupts 392*4490696bSAlexander Motin * from being generated for those doorbell bits. Bits that were already set 393*4490696bSAlexander Motin * must remain set. 394*4490696bSAlexander Motin * 395*4490696bSAlexander Motin * Return: Zero on success, otherwise an error number. 396*4490696bSAlexander Motin */ 397*4490696bSAlexander Motin void ntb_db_set_mask(device_t ntb, uint64_t bits); 398*4490696bSAlexander Motin 399*4490696bSAlexander Motin /* 400*4490696bSAlexander Motin * ntb_peer_db_set() - Set the doorbell on the secondary/external side 401*4490696bSAlexander Motin * @ntb: pointer to ntb_softc instance 402*4490696bSAlexander Motin * @bit: doorbell bits to ring 403*4490696bSAlexander Motin * 404*4490696bSAlexander Motin * This function allows triggering of a doorbell on the secondary/external 405*4490696bSAlexander Motin * side that will initiate an interrupt on the remote host 406*4490696bSAlexander Motin */ 407*4490696bSAlexander Motin void ntb_peer_db_set(device_t ntb, uint64_t bits); 408*4490696bSAlexander Motin 4099a5325c2SAlexander Motin #endif /* _NTB_H_ */ 410