xref: /spdk/lib/ioat/ioat_internal.h (revision a6dbe3721eb3b5990707fc3e378c95e505dd8ab5)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (C) 2015 Intel Corporation.
3  *   All rights reserved.
4  */
5 
6 #ifndef __IOAT_INTERNAL_H__
7 #define __IOAT_INTERNAL_H__
8 
9 #include "spdk/stdinc.h"
10 
11 #include "spdk/ioat.h"
12 #include "spdk/ioat_spec.h"
13 #include "spdk/queue.h"
14 #include "spdk/mmio.h"
15 
16 /* Allocate 1 << 15 (32K) descriptors per channel by default. */
17 #define IOAT_DEFAULT_ORDER			15
18 
19 struct ioat_descriptor {
20 	uint64_t		phys_addr;
21 	spdk_ioat_req_cb	callback_fn;
22 	void			*callback_arg;
23 };
24 
25 /* One of these per allocated PCI device. */
26 struct spdk_ioat_chan {
27 	/* Opaque handle to upper layer */
28 	struct spdk_pci_device		*device;
29 	uint64_t            max_xfer_size;
30 	volatile struct spdk_ioat_registers *regs;
31 
32 	volatile uint64_t   *comp_update;
33 
34 	uint32_t            head;
35 	uint32_t            tail;
36 
37 	uint32_t            ring_size_order;
38 	uint64_t            last_seen;
39 
40 	struct ioat_descriptor		*ring;
41 	union spdk_ioat_hw_desc		*hw_ring;
42 	uint32_t			dma_capabilities;
43 
44 	/* tailq entry for attached_chans */
45 	TAILQ_ENTRY(spdk_ioat_chan)	tailq;
46 };
47 
48 static inline uint32_t
is_ioat_active(uint64_t status)49 is_ioat_active(uint64_t status)
50 {
51 	return (status & SPDK_IOAT_CHANSTS_STATUS) == SPDK_IOAT_CHANSTS_ACTIVE;
52 }
53 
54 static inline uint32_t
is_ioat_idle(uint64_t status)55 is_ioat_idle(uint64_t status)
56 {
57 	return (status & SPDK_IOAT_CHANSTS_STATUS) == SPDK_IOAT_CHANSTS_IDLE;
58 }
59 
60 static inline uint32_t
is_ioat_halted(uint64_t status)61 is_ioat_halted(uint64_t status)
62 {
63 	return (status & SPDK_IOAT_CHANSTS_STATUS) == SPDK_IOAT_CHANSTS_HALTED;
64 }
65 
66 static inline uint32_t
is_ioat_suspended(uint64_t status)67 is_ioat_suspended(uint64_t status)
68 {
69 	return (status & SPDK_IOAT_CHANSTS_STATUS) == SPDK_IOAT_CHANSTS_SUSPENDED;
70 }
71 
72 #endif /* __IOAT_INTERNAL_H__ */
73