1c0943303SHans Petter Selasky /*- 261d82b07SHans Petter Selasky * Copyright (c) 2015-2020 Mellanox Technologies, Ltd. 3c0943303SHans Petter Selasky * All rights reserved. 4c0943303SHans Petter Selasky * 5c0943303SHans Petter Selasky * Redistribution and use in source and binary forms, with or without 6c0943303SHans Petter Selasky * modification, are permitted provided that the following conditions 7c0943303SHans Petter Selasky * are met: 8c0943303SHans Petter Selasky * 1. Redistributions of source code must retain the above copyright 9c0943303SHans Petter Selasky * notice unmodified, this list of conditions, and the following 10c0943303SHans Petter Selasky * disclaimer. 11c0943303SHans Petter Selasky * 2. Redistributions in binary form must reproduce the above copyright 12c0943303SHans Petter Selasky * notice, this list of conditions and the following disclaimer in the 13c0943303SHans Petter Selasky * documentation and/or other materials provided with the distribution. 14c0943303SHans Petter Selasky * 15c0943303SHans Petter Selasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16c0943303SHans Petter Selasky * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17c0943303SHans Petter Selasky * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18c0943303SHans Petter Selasky * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19c0943303SHans Petter Selasky * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20c0943303SHans Petter Selasky * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21c0943303SHans Petter Selasky * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22c0943303SHans Petter Selasky * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23c0943303SHans Petter Selasky * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24c0943303SHans Petter Selasky * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25c0943303SHans Petter Selasky */ 261a01b4e5SHans Petter Selasky 27*307f78f3SVladimir Kondratyev #ifndef _LINUXKPI_LINUX_SRCU_H_ 28*307f78f3SVladimir Kondratyev #define _LINUXKPI_LINUX_SRCU_H_ 29c0943303SHans Petter Selasky 3061d82b07SHans Petter Selasky #include <linux/compiler.h> 3161d82b07SHans Petter Selasky 32c0943303SHans Petter Selasky struct srcu_struct { 33c0943303SHans Petter Selasky }; 34c0943303SHans Petter Selasky 3561d82b07SHans Petter Selasky #define srcu_dereference(p, srcu) \ 3661d82b07SHans Petter Selasky ((__typeof(*(p)) *)READ_ONCE(p)) 37959d6165SHans Petter Selasky 388b2a8a49SHans Petter Selasky #define DEFINE_STATIC_SRCU(name) \ 3961d82b07SHans Petter Selasky static struct srcu_struct name 408b2a8a49SHans Petter Selasky 411a01b4e5SHans Petter Selasky /* prototypes */ 42c0943303SHans Petter Selasky 431a01b4e5SHans Petter Selasky extern int srcu_read_lock(struct srcu_struct *); 441a01b4e5SHans Petter Selasky extern void srcu_read_unlock(struct srcu_struct *, int index); 451a01b4e5SHans Petter Selasky extern void synchronize_srcu(struct srcu_struct *); 461f827dabSHans Petter Selasky extern void srcu_barrier(struct srcu_struct *); 471a01b4e5SHans Petter Selasky extern int init_srcu_struct(struct srcu_struct *); 481a01b4e5SHans Petter Selasky extern void cleanup_srcu_struct(struct srcu_struct *); 49c0943303SHans Petter Selasky 50cf9f2ca3SHans Petter Selasky #define synchronize_srcu_expedited(srcu) do { \ 51cf9f2ca3SHans Petter Selasky synchronize_srcu(srcu); \ 52cf9f2ca3SHans Petter Selasky } while (0) 53cf9f2ca3SHans Petter Selasky 54*307f78f3SVladimir Kondratyev #endif /* _LINUXKPI_LINUX_SRCU_H_ */ 55