* The relevant files have been modified in order to compile with McKernel.

Conflicts:
	kernel/Makefile.build.in
This commit is contained in:
Aram Santogidis
2017-08-01 16:17:04 +09:00
committed by Balazs Gerofi
parent 14b360e867
commit 64e2639adc
17 changed files with 637 additions and 55 deletions

View File

@ -48,7 +48,11 @@
#ifndef _COMMON_H
#define _COMMON_H
#ifdef __HFI1_ORIG__
#include "update/hfi1_user.h"
#else
#include <hfi1/hfi1_user.h>
#endif /* __HFI1_ORIG__ */
/*
* This file contains defines, structures, etc. that are used

View File

@ -0,0 +1,9 @@
#ifndef _HFI1_FILE_OPS_H_
#define _HFI1_FILE_OPS_H_
#include <ihk/types.h>
#include <uio.h>
ssize_t hfi1_aio_write(void *private_data, const struct iovec *iovec, unsigned long dim);
#endif

View File

@ -47,6 +47,10 @@
*
*/
#include <hfi1/user_sdma.h>
#ifdef __HFI1_ORIG__
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
@ -92,7 +96,10 @@
#define DROP_PACKET_OFF 0
#define DROP_PACKET_ON 1
#endif /* __HFI1_ORIG__ */
extern unsigned long hfi1_cap_mask;
#define HFI1_CAP_KGET_MASK(mask, cap) ((mask) & HFI1_CAP_##cap)
#define HFI1_CAP_UGET_MASK(mask, cap) \
(((mask) >> HFI1_CAP_USER_SHIFT) & HFI1_CAP_##cap)
@ -125,6 +132,8 @@ extern unsigned long hfi1_cap_mask;
#define NUM_SEND_CTXT_ERR_STATUS_COUNTERS 5
#define NUM_SEND_DMA_ENG_ERR_STATUS_COUNTERS 24
#ifdef __HFI1_ORIG__
/*
* per driver stats, either not device nor port-specific, or
* summed over all of the devices and ports.
@ -194,7 +203,7 @@ struct tid_queue {
u32 enqueue; /* count of tid enqueues */
u32 dequeue; /* count of tid dequeues */
};
struct hfi1_ctxtdata {
/* shadow the ctxt's RcvCtrl register */
u64 rcvctrl;
@ -358,6 +367,15 @@ struct hfi1_ctxtdata {
int (*do_interrupt)(struct hfi1_ctxtdata *rcd, int threaded);
};
#endif /* __HFI1_ORIG__ */
#ifndef __HFI1_ORIG__
struct hfi1_ctxtdata {
unsigned ctxt;
};
#endif /* __HFI1_ORIG__ */
#ifdef __HFI1_ORIG__
/*
* Represents a single packet at a high level. Put commonly computed things in
* here so we do not have to keep doing them over and over. The rule of thumb is
@ -584,6 +602,7 @@ struct vl_arb_cache {
struct ib_vl_weight_elem table[VL_ARB_TABLE_SIZE];
};
/*
* The structure below encapsulates data relevant to a physical IB Port.
* Current chips support only one such port, but the separation
@ -788,7 +807,15 @@ struct hfi1_pportdata {
/* Does this port need to prescan for FECNs */
bool cc_prescan;
};
#endif /* __HFI1_ORIG__ */
#ifndef __HFI1_ORIG__
struct hfi1_pportdata {
};
#endif /* __HFI1_ORIG__ */
#ifdef __HFI1_ORIG__
typedef int (*rhf_rcv_function_ptr)(struct hfi1_packet *packet);
typedef void (*opcode_handler)(struct hfi1_packet *packet);
@ -857,6 +884,7 @@ struct sdma_vl_map;
#define SERIAL_MAX 16 /* length of the serial number */
typedef int (*send_routine)(struct rvt_qp *, struct hfi1_pkt_state *, u64);
struct hfi1_devdata {
struct hfi1_ibdev verbs_dev; /* must be first */
struct list_head list;
@ -1169,7 +1197,7 @@ struct hfi1_devdata {
/* hfi1_pportdata, points to array of (physical) port-specific
* data structs, indexed by pidx (0..n-1)
*/
struct hfi1_pportdata *pport;
struct hfi1_pportdata *pport; //used
/* receive context data */
struct hfi1_ctxtdata **rcd;
u64 __percpu *int_counter;
@ -1221,6 +1249,20 @@ struct hfi1_devdata {
struct kobject kobj;
};
#endif /* __HFI1_ORIG__ */
#ifndef __HFI1_ORIG__
struct hfi1_devdata {
struct list_head list;
/* pointers to related structs for this device */
/* pci access data structure */
struct pci_dev *pcidev;
dma_addr_t sdma_pad_phys;
/* array of engines sized by num_sdma */
struct sdma_engine *per_sdma;
struct hfi1_pportdata *pport;
};
#endif /* __HFI1_ORIG__ */
/* 8051 firmware version helper */
#define dc8051_ver(a, b) ((a) << 8 | (b))
@ -1230,6 +1272,8 @@ struct hfi1_devdata {
#define PT_EAGER 1
#define PT_INVALID 2
#ifdef __HFI1_ORIG__
struct tid_rb_node;
struct mmu_rb_node;
struct mmu_rb_handler;
@ -1254,6 +1298,19 @@ struct hfi1_filedata {
spinlock_t invalid_lock;
struct mm_struct *mm;
};
#endif /* __HFI1_ORIG__ */
#ifndef __HFI1_ORIG__
/* Private data for file operations */
struct hfi1_filedata {
struct hfi1_ctxtdata *uctxt;
unsigned subctxt;
struct hfi1_user_sdma_comp_q *cq;
struct hfi1_user_sdma_pkt_q *pq;
};
#endif /* __HFI1_ORIG__ */
#ifdef __HFI1_ORIG__
extern struct list_head hfi1_dev_list;
extern spinlock_t hfi1_devs_lock;
@ -2039,10 +2096,12 @@ void hfi1_format_hwerrors(u64 hwerrs,
const struct hfi1_hwerror_msgs *hwerrmsgs,
size_t nhwerrmsgs, char *msg, size_t lmsg);
#endif /* __HFI1_ORIG__ */
#define USER_OPCODE_CHECK_VAL 0xC0
#define USER_OPCODE_CHECK_MASK 0xC0
#define OPCODE_CHECK_VAL_DISABLED 0x0
#define OPCODE_CHECK_MASK_DISABLED 0x0
#ifdef __HFI1_ORIG__
static inline void hfi1_reset_cpu_counters(struct hfi1_devdata *dd)
{
@ -2149,4 +2208,6 @@ __print_symbolic(opcode, \
ib_opcode_name(UD_SEND_ONLY), \
ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE), \
ib_opcode_name(CNP))
#endif /* __HFI1_ORIG__ */
#endif /* _HFI1_KERNEL_H */

View File

@ -56,8 +56,12 @@
#ifndef _LINUX__HFI1_USER_H
#define _LINUX__HFI1_USER_H
#ifdef __HFI1_ORIG__
#include <linux/types.h>
#endif /* __HFI1_ORIG__ */
/*
* This version number is given to the driver by the user code during
* initialization in the spu_userversion field of hfi1_user_info, so
@ -211,6 +215,8 @@ struct hfi1_cmd;
#define HFI1_POLL_TYPE_ANYRCV 0x0
#define HFI1_POLL_TYPE_URGENT 0x1
#ifdef __HFI1_ORIG__
/*
* This structure is passed to the driver to tell it where
* user code buffers are, sizes, etc. The offsets and sizes of the
@ -264,6 +270,7 @@ struct hfi1_tid_info {
/* length of transfer buffer programmed by this request */
__u32 length;
};
#endif /* __HFI1_ORIG__ */
enum hfi1_sdma_comp_state {
FREE = 0,
@ -280,6 +287,8 @@ struct hfi1_sdma_comp_entry {
__u32 errcode;
};
#ifdef __HFI1_ORIG__
/*
* Device status and notifications from driver to user-space.
*/
@ -353,6 +362,7 @@ struct hfi1_base_info {
__u64 subctxt_rcvegrbuf;
__u64 subctxt_rcvhdrbuf;
};
#endif /* __HFI1_ORIG__ */
enum sdma_req_opcode {
EXPECTED = 0,
@ -391,7 +401,7 @@ struct sdma_req_info {
* in charge of managing its own ring.
*/
__u16 comp_idx;
} __packed;
} __attribute__((packed));
/*
* SW KDETH header.
@ -402,7 +412,7 @@ struct hfi1_kdeth_header {
__le16 jkey;
__le16 hcrc;
__le32 swdata[7];
} __packed;
} __attribute__((packed));
/*
* Structure describing the headers that User space uses. The
@ -413,8 +423,9 @@ struct hfi1_pkt_header {
__be16 lrh[4];
__be32 bth[3];
struct hfi1_kdeth_header kdeth;
} __packed;
} __attribute__((packed));
#ifdef __HFI1_ORIG__
/*
* The list of usermode accessible registers.
@ -435,5 +446,5 @@ enum hfi1_ureg {
/* (RW) Receive TID flow table */
ur_rcvtidflowtable = 256
};
#endif /* __HFI1_ORIG__ */
#endif /* _LINIUX__HFI1_USER_H */

View File

@ -0,0 +1,218 @@
#ifndef _IHK_HFI1_COMMON_H_
#define _IHK_HFI1_COMMON_H_
#include <ihk/atomic.h>
#include <ihk/types.h>
#include <kmalloc.h>
#include <lwk/compiler.h>
#include <arch-lock.h>
#include <page.h>
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
/* From: mckernel/kernel/include/xpmem_private.h */
#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
#define min(x, y) ({ \
__typeof__(x) _min1 = (x); \
__typeof__(y) _min2 = (y); \
(void) (&_min1 == &_min2); \
_min1 < _min2 ? _min1 : _min2;})
#define BIT_ULL(nr) (1ULL << (nr))
/* Disable debug macros */
#define hfi1_cdbg(...) do {} while(0)
#define SDMA_DBG(...) do {} while(0)
#define WARN_ON(...) do {} while(0)
#define WARN_ON_ONCE WARN_ON // use the local definition
#define trace_hfi1_ahg_allocate(...) do {} while(0)
#define trace_hfi1_ahg_deallocate(...) do {} while(0)
/* Byte swapping */
#define be32_to_cpu(x) __builtin_bswap32(x)
#define be16_to_cpu(x) __builtin_bswap16(x)
#define le32_to_cpu(x) x
#define le16_to_cpu(x) x
#define cpu_to_le16(x) x
#define cpu_to_le32(x) x
#define cpu_to_le64(x) x
#define __cpu_to_le64(x) x
#define __le64_to_cpu(x) x
#define __le32_to_cpu(x) x
#define __le16_to_cpu(x) x
//TODO: double-check
#define cpu_to_be16(x) __builtin_bswap16(x)
#define cpu_to_be32(x) __builtin_bswap32(x)
/* Compiler */
#ifndef likely
# define likely(x) __builtin_expect(!!(x), 1)
#endif
#ifndef unlikely
# define unlikely(x) __builtin_expect(!!(x), 0)
#endif
/* From: kernel-xppsl_1.5.2/include/linux/compiler.h */
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
/* Atomic ops */
#define atomic_inc ihk_atomic_inc
#define atomic_dec ihk_atomic_dec
#define atomic_read ihk_atomic_read
#define atomic_add ihk_atomic_add
#define atomic_t ihk_atomic_t
/* TODO***********************************/
#define spin_lock_irqsave(lock, flags) do {} while(0)
#define spin_unlock_irqsave(lock, flags) do {} while(0)
#define spin_unlock_irqrestore(lock, flags) do {} while(0)
typedef ihk_spinlock_t spinlock_t;
#define ____cacheline_aligned_in_smp
#define __iomem
#define spin_lock(...) do {} while(0)
#define spin_unlock(...) do {} while(0)
#define smp_wmb() barrier()
#define smp_rmb() barrier()
/***********************************************/
/* TODO: Figure the corresponding flag for McKernel-kmalloc()*/
#define __GFP_ZERO 0
#define GFP_KERNEL 0
/* kernel-xppsl_1.5.2/include/linux/seqlock.h */
/***********************************************/
typedef struct seqcount {
unsigned sequence;
} seqcount_t;
typedef struct {
struct seqcount seqcount;
spinlock_t lock;
} seqlock_t;
static inline unsigned raw_seqcount_begin(const seqcount_t *s)
{
unsigned ret = ACCESS_ONCE(s->sequence);
smp_rmb();
return ret & ~1;
}
/***********************************************/
/* Misc */
/* From: kernel-xppsl_1.5.2/include/linux/kernel.h */
#define min_t(type, x, y) ({ \
type __min1 = (x); \
type __min2 = (y); \
__min1 < __min2 ? __min1: __min2; })
#define SIZE_MAX (~(size_t)0)
#define MAX_TID_PAIR_ENTRIES 1024 /* max receive expected pairs */
#define PIO_BLOCK_SIZE 64 /* bytes */
/* From: chip.c/h */
//num_vls = HFI1_MAX_VLS_SUPPORTED;
//num_vls = dd->chip_sdma_engines;
#define HFI1_MAX_VLS_SUPPORTED 8
/* integer typedefs */
typedef __signed__ char __s8;
typedef unsigned char __u8;
typedef __signed__ short __s16;
typedef unsigned short __u16;
typedef __signed__ int __s32;
typedef unsigned int __u32;
typedef __signed__ long __s64;
typedef unsigned long __u64;
typedef __u64 u64;
typedef __s64 s64;
typedef __u32 u32;
typedef __s32 s32;
typedef __u16 u16;
typedef __s16 s16;
typedef __u8 u8;
typedef __s8 s8;
typedef __u16 __le16;
typedef __u16 __be16;
typedef __u32 __le32;
typedef __u32 __be32;
typedef __u64 __le64;
typedef __u64 __be64;
typedef unsigned int uint;
/* TODO: There should be a header file that I can include */
typedef _Bool bool;
#define false 0
#define true !false
/* TODO: double check this typedef */
typedef u64 dma_addr_t;
/* From: kernel-xppsl_1.5.2/include/linux/types.h */
typedef unsigned gfp_t;
/* kernel-xppsl_1.5.2/include/asm-generic/io.h */
#ifndef __raw_writeq
static inline void __raw_writeq(u64 b, volatile void __iomem *addr)
{
*(volatile u64 __force *) addr = b;
}
#endif
#define writeq(b, addr) __raw_writeq(__cpu_to_le64(b), addr)
/* TODO: I'm not sure if this definition is correct */
#define LOCK_PREFIX "lock; "
/* From: kernel-xppsl_1.5.2/arch/x86/include/asm/bitops.h */
#define BITOP_ADDR(x) "+m" (*(volatile long *) (x))
#define LINUX_ADDR BITOP_ADDR(addr)
/* From: kernel-xppsl_1.5.2/arch/x86/include/asm/bitops.h */
static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
{
int oldbit;
asm volatile(LOCK_PREFIX "bts %2,%1\n\t"
"sbb %0,%0" : "=r" (oldbit), LINUX_ADDR : "Ir" (nr) : "memory");
return oldbit;
}
/* From: kernel-xppsl_1.5.2/arch/x86/include/asm/atomic.h */
static inline int atomic_dec_and_test(atomic_t *v)
{
unsigned char c;
asm volatile(LOCK_PREFIX "decl %0; sete %1"
: "+m" (v->counter), "=qm" (c)
: : "memory");
return c != 0;
}
/* From: kernel-xppsl_1.5.2/include/linux/slab.h */
static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
{
if (size != 0 && n > SIZE_MAX / size)
return NULL;
return __kmalloc(n * size, flags);
}
static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
{
return kmalloc(n * size, flags | __GFP_ZERO);
}
#endif

View File

@ -47,6 +47,7 @@
*
*/
#ifdef __HFI1_ORIG__
#include <linux/list.h>
#include <linux/workqueue.h>
#include <linux/sched.h>
@ -58,6 +59,7 @@
* @work: pointer to work structure
*/
typedef void (*restart_t)(struct work_struct *work);
#endif /* __HFI1_ORIG__ */
#define IOWAIT_PENDING_IB 0x0
#define IOWAIT_PENDING_TID 0x1
@ -88,7 +90,11 @@ struct sdma_engine;
*/
struct iowait;
struct iowait_work {
#ifdef __HFI1_ORIG__
struct work_struct iowork;
#else
//TODO:
#endif /* __HFI1_ORIG__ */
struct list_head tx_head;
struct iowait *iow;
};
@ -140,9 +146,13 @@ struct iowait {
unsigned seq);
void (*wakeup)(struct iowait *wait, int reason);
void (*sdma_drained)(struct iowait *wait);
#ifdef __HFI1_ORIG__
seqlock_t *lock;
wait_queue_head_t wait_dma;
wait_queue_head_t wait_pio;
#else
//TODO:
#endif /* __HFI1_ORIG__ */
atomic_t sdma_busy;
atomic_t pio_busy;
u32 count;
@ -154,6 +164,8 @@ struct iowait {
#define SDMA_AVAIL_REASON 0
#ifdef __HFI1_ORIG__
void iowait_set_flag(struct iowait *wait, u32 flag);
bool iowait_flag_set(struct iowait *wait, u32 flag);
void iowait_clear_flag(struct iowait *wait, u32 flag);
@ -182,6 +194,7 @@ static inline bool iowait_schedule(
struct workqueue_struct *wq,
int cpu)
{
hfi1_cdbg(AIOWRITE, ".");
return !!queue_work_on(cpu, wq, &wait->wait[IOWAIT_IB_SE].iowork);
}
@ -196,6 +209,7 @@ static inline bool iowait_tid_schedule(
struct workqueue_struct *wq,
int cpu)
{
hfi1_cdbg(AIOWRITE, ".");
return !!queue_work_on(cpu, wq, &wait->wait[IOWAIT_TID_SE].iowork);
}
@ -208,6 +222,7 @@ static inline bool iowait_tid_schedule(
*/
static inline void iowait_sdma_drain(struct iowait *wait)
{
hfi1_cdbg(AIOWRITE, ".");
wait_event(wait->wait_dma, !atomic_read(&wait->sdma_busy));
}
@ -219,6 +234,7 @@ static inline void iowait_sdma_drain(struct iowait *wait)
*/
static inline int iowait_sdma_pending(struct iowait *wait)
{
hfi1_cdbg(AIOWRITE, ".");
return atomic_read(&wait->sdma_busy);
}
@ -228,17 +244,21 @@ static inline int iowait_sdma_pending(struct iowait *wait)
*/
static inline void iowait_sdma_inc(struct iowait *wait)
{
hfi1_cdbg(AIOWRITE, ".");
atomic_inc(&wait->sdma_busy);
}
#endif
/**
* iowait_sdma_add - add count to pending
* @wait: iowait_work structure
*/
static inline void iowait_sdma_add(struct iowait *wait, int count)
{
hfi1_cdbg(AIOWRITE, ".");
atomic_add(count, &wait->sdma_busy);
}
#ifdef __HFI1_ORIG__
/**
* iowait_pio_drain() - wait for pios to drain
@ -250,6 +270,7 @@ static inline void iowait_sdma_add(struct iowait *wait, int count)
*/
static inline void iowait_pio_drain(struct iowait *wait)
{
hfi1_cdbg(AIOWRITE, ".");
wait_event_timeout(wait->wait_pio,
!atomic_read(&wait->pio_busy),
HZ);
@ -263,6 +284,7 @@ static inline void iowait_pio_drain(struct iowait *wait)
*/
static inline int iowait_pio_pending(struct iowait *w)
{
hfi1_cdbg(AIOWRITE, ".");
return atomic_read(&w->pio_busy);
}
@ -274,6 +296,7 @@ static inline int iowait_pio_pending(struct iowait *w)
*/
static inline void iowait_drain_wakeup(struct iowait *w)
{
hfi1_cdbg(AIOWRITE, ".");
wake_up(&w->wait_dma);
wake_up(&w->wait_pio);
if (w->sdma_drained)
@ -286,6 +309,7 @@ static inline void iowait_drain_wakeup(struct iowait *w)
*/
static inline void iowait_pio_inc(struct iowait *wait)
{
hfi1_cdbg(AIOWRITE, ".");
atomic_inc(&wait->pio_busy);
}
@ -295,6 +319,7 @@ static inline void iowait_pio_inc(struct iowait *wait)
*/
static inline int iowait_pio_dec(struct iowait *wait)
{
hfi1_cdbg(AIOWRITE, ".");
if (!wait)
return 0;
return atomic_dec_and_test(&wait->pio_busy);
@ -306,6 +331,7 @@ static inline int iowait_pio_dec(struct iowait *wait)
*/
static inline int iowait_sdma_dec(struct iowait *wait)
{
hfi1_cdbg(AIOWRITE, ".");
if (!wait)
return 0;
return atomic_dec_and_test(&wait->sdma_busy);
@ -319,6 +345,7 @@ static inline struct sdma_txreq *iowait_get_txhead(struct iowait_work *wait)
{
struct sdma_txreq *tx = NULL;
hfi1_cdbg(AIOWRITE, ".");
if (!list_empty(&wait->tx_head)) {
tx = list_first_entry(
&wait->tx_head,
@ -333,6 +360,7 @@ static inline u16 iowait_get_desc(struct iowait_work *w)
{
u16 num_desc = 0;
struct sdma_txreq *tx = NULL;
hfi1_cdbg(AIOWRITE, ".");
if (!list_empty(&w->tx_head)) {
tx = list_first_entry(
@ -348,6 +376,7 @@ static inline u32 iowait_get_all_desc(struct iowait *w)
{
u32 num_desc = 0;
hfi1_cdbg(AIOWRITE, ".");
num_desc = iowait_get_desc(&w->wait[IOWAIT_IB_SE]);
num_desc += iowait_get_desc(&w->wait[IOWAIT_TID_SE]);
return num_desc;
@ -359,9 +388,11 @@ static inline u32 iowait_get_all_desc(struct iowait *w)
*/
static inline bool iowait_packet_queued(struct iowait_work *w)
{
hfi1_cdbg(AIOWRITE, ".");
return !list_empty(&w->tx_head);
}
#endif /* __HFI1_ORIG__ */
/**
* inc_wait_count - increment wait counts
* @w: the log work struct
@ -369,11 +400,13 @@ static inline bool iowait_packet_queued(struct iowait_work *w)
*/
static inline void iowait_inc_wait_count(struct iowait_work *w, u16 n)
{
hfi1_cdbg(AIOWRITE, ".");
if (!w)
return;
w->iow->tx_count++;
w->iow->count += n;
}
#ifdef __HFI1_ORIG__
/**
* iowait_get_tid_work - return iowait_work for tid SE
@ -381,15 +414,18 @@ static inline void iowait_inc_wait_count(struct iowait_work *w, u16 n)
*/
static inline struct iowait_work *iowait_get_tid_work(struct iowait *w)
{
hfi1_cdbg(AIOWRITE, ".");
return &w->wait[IOWAIT_TID_SE];
}
#endif /* __HFI1_ORIG__ */
/**
* iowait_get_ib_work - return iowait_work for ib SE
* @w: the iowait struct
*/
static inline struct iowait_work *iowait_get_ib_work(struct iowait *w)
{
hfi1_cdbg(AIOWRITE, ".");
return &w->wait[IOWAIT_IB_SE];
}
@ -399,12 +435,15 @@ static inline struct iowait_work *iowait_get_ib_work(struct iowait *w)
*/
static inline struct iowait *iowait_ioww_to_iow(struct iowait_work *w)
{
hfi1_cdbg(AIOWRITE, ".");
if (likely(w))
return w->iow;
return NULL;
}
#ifdef __HFI1_ORIG__
void iowait_cancel_work(struct iowait *w);
int iowait_set_work_flag(struct iowait_work *w);
#endif /* __HFI1_ORIG__ */
#endif

View File

@ -47,6 +47,11 @@
*
*/
#include <hfi1/ihk_hfi1_common.h>
#include <hfi1/sdma_txreq.h>
#ifdef __HFI1_ORIG__
#include <linux/types.h>
#include <linux/list.h>
#include <asm/byteorder.h>
@ -57,6 +62,11 @@
#include "verbs.h"
#include "sdma_txreq.h"
#define hfi1_cdbg(which, fmt, ...) \
__hfi1_trace_##which(__func__, fmt, ##__VA_ARGS__)
extern void __hfi1_trace_AIOWRITE(const char *func, char *fmt, ...);
#endif /* __HFI1_ORIG__ */
/* Hardware limit */
#define MAX_DESC 64
/* Hardware limit for SDMA packet size */
@ -192,6 +202,7 @@ struct sdma_set_state_action {
unsigned go_s99_running_totrue:1;
};
#ifdef __HFI1_ORIG__
struct sdma_state {
struct kref kref;
struct completion comp;
@ -203,6 +214,11 @@ struct sdma_state {
unsigned previous_op;
enum sdma_events last_event;
};
#else
struct sdma_state {
enum sdma_states current_state;
};
#endif /* __HFI1_ORIG__ */
/**
* DOC: sdma exported routines
@ -394,6 +410,7 @@ struct sdma_engine {
/* private: */
struct list_head dmawait;
#ifdef __HFI1_ORIG__
/* CONFIG SDMA for now, just blindly duplicate */
/* private: */
struct tasklet_struct sdma_hw_clean_up_task
@ -409,14 +426,20 @@ struct sdma_engine {
u32 progress_check_head;
/* private: */
struct work_struct flush_worker;
#endif /* __HFI1_ORIG__ */
/* protect flush list */
spinlock_t flushlist_lock;
/* private: */
struct list_head flushlist;
#ifdef __HFI1_ORIG__
struct cpumask cpu_mask;
struct kobject kobj;
#endif /* __HFI1_ORIG__ */
};
#ifdef __HFI1_ORIG__
int sdma_init(struct hfi1_devdata *dd, u8 port);
void sdma_start(struct hfi1_devdata *dd);
void sdma_exit(struct hfi1_devdata *dd);
@ -441,6 +464,7 @@ static inline int sdma_empty(struct sdma_engine *sde)
return sde->descq_tail == sde->descq_head;
}
#endif /* __HFI1_ORIG__ */
static inline u16 sdma_descq_freecnt(struct sdma_engine *sde)
{
return sde->descq_cnt -
@ -478,9 +502,11 @@ static inline int sdma_running(struct sdma_engine *engine)
unsigned long flags;
int ret;
hfi1_cdbg(AIOWRITE, "+");
spin_lock_irqsave(&engine->tail_lock, flags);
ret = __sdma_running(engine);
spin_unlock_irqrestore(&engine->tail_lock, flags);
hfi1_cdbg(AIOWRITE, "-");
return ret;
}
@ -619,6 +645,7 @@ static inline int sdma_txinit(
{
return sdma_txinit_ahg(tx, flags, tlen, 0, 0, NULL, 0, cb);
}
#ifdef __HFI1_ORIG__
/* helpers - don't use */
static inline int sdma_mapping_type(struct sdma_desc *d)
@ -639,6 +666,7 @@ static inline dma_addr_t sdma_mapping_addr(struct sdma_desc *d)
>> SDMA_DESC0_PHY_ADDR_SHIFT;
}
#endif /* __HFI1_ORIG__ */
static inline void make_tx_sdma_desc(
struct sdma_txreq *tx,
int type,
@ -666,7 +694,6 @@ static inline void make_tx_sdma_desc(
int ext_coal_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx,
int type, void *kvaddr, struct page *page,
unsigned long offset, u16 len);
int _pad_sdma_tx_descs(struct hfi1_devdata *, struct sdma_txreq *);
void __sdma_txclean(struct hfi1_devdata *, struct sdma_txreq *);
static inline void sdma_txclean(struct hfi1_devdata *dd, struct sdma_txreq *tx)
@ -674,6 +701,8 @@ static inline void sdma_txclean(struct hfi1_devdata *dd, struct sdma_txreq *tx)
if (tx->num_desc)
__sdma_txclean(dd, tx);
}
#ifdef __HFI1_ORIG__
int _pad_sdma_tx_descs(struct hfi1_devdata *, struct sdma_txreq *);
/* helpers used by public routines */
static inline void _sdma_close_tx(struct hfi1_devdata *dd,
@ -689,6 +718,7 @@ static inline void _sdma_close_tx(struct hfi1_devdata *dd,
SDMA_DESC1_INT_REQ_FLAG);
}
#endif /* __HFI1_ORIG__ */
static inline int _sdma_txadd_daddr(
struct hfi1_devdata *dd,
int type,
@ -707,11 +737,13 @@ static inline int _sdma_txadd_daddr(
/* special cases for last */
if (!tx->tlen) {
if (tx->packet_len & (sizeof(u32) - 1)) {
rval = _pad_sdma_tx_descs(dd, tx);
//TODO: _pad_sdma_tx_descs
//rval = _pad_sdma_tx_descs(dd, tx);
if (rval)
return rval;
} else {
_sdma_close_tx(dd, tx);
//TODO: _sdma_close_tx
//_sdma_close_tx(dd, tx);
}
}
tx->num_desc++;
@ -743,7 +775,7 @@ static inline int sdma_txadd_page(
{
dma_addr_t addr;
int rval;
hfi1_cdbg(AIOWRITE, "+");
if ((unlikely(tx->num_desc == tx->desc_limit))) {
rval = ext_coal_sdma_tx_descs(dd, tx, SDMA_MAP_PAGE,
NULL, page, offset, len);
@ -751,6 +783,7 @@ static inline int sdma_txadd_page(
return rval;
}
#ifdef __HFI1_ORIG__
addr = dma_map_page(
&dd->pcidev->dev,
page,
@ -762,7 +795,11 @@ static inline int sdma_txadd_page(
__sdma_txclean(dd, tx);
return -ENOSPC;
}
#else
//TODO: dma_map_page
#endif /* __HFI1_ORIG__ */
hfi1_cdbg(AIOWRITE, "-");
return _sdma_txadd_daddr(
dd, SDMA_MAP_PAGE, tx, addr, len);
}
@ -833,6 +870,7 @@ static inline int sdma_txadd_kvaddr(
return rval;
}
#ifdef __HFI1_ORIG__
addr = dma_map_single(
&dd->pcidev->dev,
kvaddr,
@ -843,6 +881,9 @@ static inline int sdma_txadd_kvaddr(
__sdma_txclean(dd, tx);
return -ENOSPC;
}
#else
//TODO: dma_map_single
#endif /* __HFI1_ORIG__ */
return _sdma_txadd_daddr(
dd, SDMA_MAP_SINGLE, tx, addr, len);
@ -885,6 +926,7 @@ static inline u32 sdma_build_ahg_descriptor(
((data & SDMA_AHG_VALUE_MASK) <<
SDMA_AHG_VALUE_SHIFT));
}
#ifdef __HFI1_ORIG__
/**
* sdma_progress - use seq number of detect head progress
@ -1061,6 +1103,7 @@ struct sdma_engine *sdma_select_engine_sc(
u32 selector,
u8 sc5);
#endif /* __HFI1_ORIG__ */
struct sdma_engine *sdma_select_engine_vl(
struct hfi1_devdata *dd,
u32 selector,
@ -1068,6 +1111,8 @@ struct sdma_engine *sdma_select_engine_vl(
struct sdma_engine *sdma_select_user_engine(struct hfi1_devdata *dd,
u32 selector, u8 vl);
#ifdef __HFI1_ORIG__
ssize_t sdma_get_cpu_to_sde_map(struct sdma_engine *sde, char *buf);
ssize_t sdma_set_cpu_to_sde_map(struct sdma_engine *sde, const char *buf,
size_t count);
@ -1095,4 +1140,5 @@ extern uint mod_num_sdma;
void sdma_update_lmc(struct hfi1_devdata *dd, u64 mask, u32 lid);
#endif /* __HFI1_ORIG__ */
#endif

View File

@ -48,6 +48,8 @@
#ifndef HFI1_SDMA_TXREQ_H
#define HFI1_SDMA_TXREQ_H
#include <hfi1/iowait.h>
/* increased for AHG */
#define NUM_DESC 6
@ -105,7 +107,7 @@ struct sdma_txreq {
/* private: */
struct iowait *wait;
/* private: */
callback_t complete;
callback_t complete;
#ifdef CONFIG_HFI1_DEBUG_SDMA_ORDER
u64 sn;
#endif

View File

@ -46,8 +46,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifdef __HFI1_ORIG__
#include "hfi.h"
#endif /* __HFI1_ORIG__ */
#define EXP_TID_TIDLEN_MASK 0x7FFULL
#define EXP_TID_TIDLEN_SHIFT 0
@ -70,6 +71,7 @@
(tid) |= EXP_TID_SET(field, (value)); \
} while (0)
#ifdef __HFI1_ORIG__
struct tid_group {
struct list_head list;
unsigned base;
@ -154,4 +156,6 @@ int hfi1_user_exp_rcv_setup(struct file *, struct hfi1_tid_info *);
int hfi1_user_exp_rcv_clear(struct file *, struct hfi1_tid_info *);
int hfi1_user_exp_rcv_invalid(struct file *, struct hfi1_tid_info *);
#endif /* __HFI1_ORIG__ */
#endif /* _HFI1_USER_EXP_RCV_H */

View File

@ -1,3 +1,7 @@
#ifndef _HFI1_USER_SDMA_H
#define _HFI1_USER_SDMA_H
/*
* Copyright(c) 2015, 2016 Intel Corporation.
*
@ -44,6 +48,17 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <hfi1/ihk_hfi1_common.h>
#include <hfi1/iowait.h>
#include <hfi1/sdma.h>
#include <string.h>
#include <hfi1/hfi.h>
#include <hfi1/hfi1_user.h>
#include <uio.h>
#ifdef __HFI1_ORIG__
#include <linux/device.h>
#include <linux/wait.h>
@ -53,6 +68,7 @@
extern uint extended_psn;
#endif /* __HFI1_ORIG__ */
/*
* Define fields in the KDETH header so we can update the header
* template.
@ -105,16 +121,24 @@ struct hfi1_user_sdma_pkt_q {
atomic_t n_reqs;
u16 reqidx;
struct hfi1_devdata *dd;
#ifdef __HFI1_ORIG__
struct kmem_cache *txreq_cache;
#else
void *txreq_cache; //unused
#endif /* __HFI1_ORIG__ */
struct user_sdma_request *reqs;
unsigned long *req_in_use;
struct iowait busy;
unsigned state;
#ifdef __HFI1_ORIG__
wait_queue_head_t wait;
unsigned long unpinned;
struct mmu_rb_handler *handler;
atomic_t n_locked;
struct mm_struct *mm;
#else
//TODO:
#endif /* __HFI1_ORIG__ */
};
struct hfi1_user_sdma_comp_q {
@ -122,7 +146,14 @@ struct hfi1_user_sdma_comp_q {
struct hfi1_sdma_comp_entry *comps;
};
int hfi1_user_sdma_process_request(void *private_data, struct iovec *iovec,
unsigned long dim, unsigned long *count);
#ifdef __HFI1_ORIG__
int hfi1_user_sdma_alloc_queues(struct hfi1_ctxtdata *, struct file *);
int hfi1_user_sdma_free_queues(struct hfi1_filedata *);
int hfi1_user_sdma_process_request(struct file *, struct iovec *, unsigned long,
unsigned long *);
#endif /* __HFI1_ORIG__ */
#endif /* _HFI1_SDMA_H */