Debian Codegraph @

prov/usnic/src/usnic_direct/kcompat_priv.h

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 /*
2 * Copyright (c) 2014, Cisco Systems, Inc. All rights reserved.
3 *
4 * LICENSE_BEGIN
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 *
38 * LICENSE_END
39 *
40 *
41 */
42
43 #ifndef _KCOMPAT_PRIV_H_
44 #define _KCOMPAT_PRIV_H_
45
46 #include <stdint.h>
47 #include <stdio.h>
48
49 struct pci_dev;
50 typedef uint64_t dma_addr_t;
51 struct usd_device;
52
53 int usd_alloc_mr(struct usd_device *dev, size_t size, void **vaddr_o);
54 int usd_free_mr(void *);
55 char *pci_name(struct pci_dev *pdev);
56
57 static inline void *pci_alloc_consistent(struct pci_dev *hwdev,
58 size_t size,
59 dma_addr_t * dma_handle)
60 {
61 int ret;
62 void *va;
63
64 ret = usd_alloc_mr((struct usd_device *) hwdev, size, &va);
65 if (ret == 0) {
66 *dma_handle = (dma_addr_t) va;
67 return va;
68 } else {
69 return NULL;
70 }
71 }
72
73 static inline void pci_free_consistent( __attribute__ ((unused))
74 struct pci_dev *pdev,
75 __attribute__ ((unused)) size_t
76 size, void *vaddr,
77 __attribute__ ((unused)) dma_addr_t
78 dma)
79 {
80 (void) usd_free_mr(vaddr);
81 }
82
83 #define usd_err(args...) fprintf(stderr, args)
84 #define pr_err usd_err
85 #define pr_warning(args...)
86
87 #ifndef wmb
88 #define wmb() asm volatile("" ::: "memory")
89 #endif
90
91 #ifndef rmb
92 #define rmb() asm volatile("" ::: "memory")
93 #endif
94
95 #endif /* _KCOMPAT_PRIV_H_ */