xref: /freebsd/sys/dev/liquidio/base/lio_mem_ops.h (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Cavium, Inc.. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Cavium, Inc. nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  *   \file lio_mem_ops.h
36  *   \brief Host Driver: Routines used to read/write Octeon memory.
37  */
38 
39 #ifndef __LIO_MEM_OPS_H__
40 #define __LIO_MEM_OPS_H__
41 
42 /*
43  *   Read a 64-bit value from a BAR1 mapped core memory address.
44  *   @param  oct        -  pointer to the octeon device.
45  *   @param  core_addr  -  the address to read from.
46  *
47  *   The range_idx gives the BAR1 index register for the range of address
48  *   in which core_addr is mapped.
49  *
50  *   @return  64-bit value read from Core memory
51  */
52 uint64_t	lio_read_device_mem64(struct octeon_device *oct,
53 				      uint64_t core_addr);
54 
55 /*
56  *   Read a 32-bit value from a BAR1 mapped core memory address.
57  *   @param  oct        -  pointer to the octeon device.
58  *   @param  core_addr  -  the address to read from.
59  *
60  *   @return  32-bit value read from Core memory
61  */
62 uint32_t	lio_read_device_mem32(struct octeon_device *oct,
63 				      uint64_t core_addr);
64 
65 /*
66  *   Write a 32-bit value to a BAR1 mapped core memory address.
67  *   @param  oct        -  pointer to the octeon device.
68  *   @param  core_addr  -  the address to write to.
69  *   @param  val        -  32-bit value to write.
70  */
71 void		lio_write_device_mem32(struct octeon_device *oct,
72 				       uint64_t core_addr, uint32_t val);
73 
74 /* Read multiple bytes from Octeon memory. */
75 void		lio_pci_read_core_mem(struct octeon_device *oct,
76 				      uint64_t coreaddr, uint8_t *buf,
77 				      uint32_t len);
78 
79 /* Write multiple bytes into Octeon memory. */
80 void		lio_pci_write_core_mem(struct octeon_device *oct,
81 				       uint64_t coreaddr, uint8_t *buf,
82 				       uint32_t len);
83 
84 #endif	/* __LIO_MEM_OPS_H__ */
85