2015-12-03 21:30:38 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
2016-01-26 17:47:22 +00:00
|
|
|
* Copyright (c) Intel Corporation.
|
2015-12-03 21:30:38 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IOAT_INTERNAL_H__
|
|
|
|
#define __IOAT_INTERNAL_H__
|
|
|
|
|
2017-05-02 18:18:25 +00:00
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
|
2015-12-03 21:30:38 +00:00
|
|
|
#include "spdk/ioat.h"
|
|
|
|
#include "spdk/ioat_spec.h"
|
|
|
|
#include "spdk/queue.h"
|
2015-12-10 23:56:12 +00:00
|
|
|
#include "spdk/mmio.h"
|
2015-12-03 21:30:38 +00:00
|
|
|
|
2018-07-04 05:45:37 +00:00
|
|
|
/* Allocate 1 << 15 (32K) descriptors per channel by default. */
|
2015-12-03 21:30:38 +00:00
|
|
|
#define IOAT_DEFAULT_ORDER 15
|
|
|
|
|
|
|
|
struct ioat_descriptor {
|
2018-07-03 17:15:41 +00:00
|
|
|
uint64_t phys_addr;
|
2016-02-11 19:31:35 +00:00
|
|
|
spdk_ioat_req_cb callback_fn;
|
2015-12-03 21:30:38 +00:00
|
|
|
void *callback_arg;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* One of these per allocated PCI device. */
|
2016-02-11 19:31:35 +00:00
|
|
|
struct spdk_ioat_chan {
|
2015-12-03 21:30:38 +00:00
|
|
|
/* Opaque handle to upper layer */
|
2018-06-27 09:06:47 +00:00
|
|
|
struct spdk_pci_device *device;
|
2015-12-03 21:30:38 +00:00
|
|
|
uint64_t max_xfer_size;
|
2016-02-11 17:39:28 +00:00
|
|
|
volatile struct spdk_ioat_registers *regs;
|
2015-12-03 21:30:38 +00:00
|
|
|
|
|
|
|
volatile uint64_t *comp_update;
|
|
|
|
|
|
|
|
uint32_t head;
|
|
|
|
uint32_t tail;
|
|
|
|
|
|
|
|
uint32_t ring_size_order;
|
|
|
|
uint64_t last_seen;
|
|
|
|
|
2015-12-08 17:34:30 +00:00
|
|
|
struct ioat_descriptor *ring;
|
2016-02-11 17:39:28 +00:00
|
|
|
union spdk_ioat_hw_desc *hw_ring;
|
2016-01-29 08:01:43 +00:00
|
|
|
uint32_t dma_capabilities;
|
2016-02-03 19:57:51 +00:00
|
|
|
|
|
|
|
/* tailq entry for attached_chans */
|
2016-02-11 19:31:35 +00:00
|
|
|
TAILQ_ENTRY(spdk_ioat_chan) tailq;
|
2015-12-03 21:30:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
is_ioat_active(uint64_t status)
|
|
|
|
{
|
2016-02-11 17:39:28 +00:00
|
|
|
return (status & SPDK_IOAT_CHANSTS_STATUS) == SPDK_IOAT_CHANSTS_ACTIVE;
|
2015-12-03 21:30:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
is_ioat_idle(uint64_t status)
|
|
|
|
{
|
2016-02-11 17:39:28 +00:00
|
|
|
return (status & SPDK_IOAT_CHANSTS_STATUS) == SPDK_IOAT_CHANSTS_IDLE;
|
2015-12-03 21:30:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
is_ioat_halted(uint64_t status)
|
|
|
|
{
|
2016-02-11 17:39:28 +00:00
|
|
|
return (status & SPDK_IOAT_CHANSTS_STATUS) == SPDK_IOAT_CHANSTS_HALTED;
|
2015-12-03 21:30:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
is_ioat_suspended(uint64_t status)
|
|
|
|
{
|
2016-02-11 17:39:28 +00:00
|
|
|
return (status & SPDK_IOAT_CHANSTS_STATUS) == SPDK_IOAT_CHANSTS_SUSPENDED;
|
2015-12-03 21:30:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __IOAT_INTERNAL_H__ */
|