Skip to content

Commit 27e1833

Browse files
committed
libxscale: Add support for cq related verbs
This patch adds support for the following cq verbs: 1. create_cq 2. poll_cq 3. req_notify_cq 4. cq_event 5. resize_cq 6. destroy_cq Signed-off-by: Tian Xin <tianx@yunsilicon.com> Signed-off-by: Wei Honggang <weihg@yunsilicon.com> Signed-off-by: Zhao Qianwei <zhaoqw@yunsilicon.com> Signed-off-by: Li Qiang <liq@yunsilicon.com> Signed-off-by: Yan Lei <jacky@yunsilicon.com>
1 parent 563b8a9 commit 27e1833

File tree

8 files changed

+1676
-8
lines changed

8 files changed

+1676
-8
lines changed

providers/xscale/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
rdma_provider(xscale
22
xscale.c
33
verbs.c
4+
cq.c
5+
xsc_hsi.c
6+
buf.c
47
)

providers/xscale/bitmap.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (c) 2021 - 2022, Shanghai Yunsilicon Technology Co., Ltd.
4+
* All rights reserved.
5+
*/
6+
7+
#ifndef BITMAP_H
8+
#define BITMAP_H
9+
10+
#include <stdlib.h>
11+
#include <stdio.h>
12+
#include <pthread.h>
13+
#include <string.h>
14+
#include <sys/types.h>
15+
#include <sys/ipc.h>
16+
#include <sys/shm.h>
17+
#include <sys/mman.h>
18+
#include <linux/errno.h>
19+
20+
/* Only ia64 requires this */
21+
#ifdef __ia64__
22+
#define XSC_SHM_ADDR ((void *)0x8000000000000000UL)
23+
#define XSC_SHMAT_FLAGS (SHM_RND)
24+
#else
25+
#define XSC_SHM_ADDR NULL
26+
#define XSC_SHMAT_FLAGS 0
27+
#endif
28+
29+
#define BITS_PER_LONG (8 * sizeof(long))
30+
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG)
31+
32+
#ifndef HPAGE_SIZE
33+
#define HPAGE_SIZE (2UL * 1024 * 1024)
34+
#endif
35+
36+
#define XSC_SHM_LENGTH HPAGE_SIZE
37+
#define XSC_Q_CHUNK_SIZE 32768
38+
#define XSC_SHM_NUM_REGION 64
39+
40+
static inline unsigned long xsc_ffz(u32 word)
41+
{
42+
return __builtin_ffs(~word) - 1;
43+
}
44+
45+
static inline u32 xsc_find_first_zero_bit(const unsigned long *addr,
46+
u32 size)
47+
{
48+
const unsigned long *p = addr;
49+
u32 result = 0;
50+
unsigned long tmp;
51+
52+
while (size & ~(BITS_PER_LONG - 1)) {
53+
tmp = *(p++);
54+
if (~tmp)
55+
goto found;
56+
result += BITS_PER_LONG;
57+
size -= BITS_PER_LONG;
58+
}
59+
if (!size)
60+
return result;
61+
62+
tmp = (*p) | (~0UL << size);
63+
if (tmp == (u32)~0UL) /* Are any bits zero? */
64+
return result + size; /* Nope. */
65+
found:
66+
return result + xsc_ffz(tmp);
67+
}
68+
69+
static inline void xsc_set_bit(unsigned int nr, unsigned long *addr)
70+
{
71+
addr[(nr / BITS_PER_LONG)] |= (1 << (nr % BITS_PER_LONG));
72+
}
73+
74+
static inline void xsc_clear_bit(unsigned int nr, unsigned long *addr)
75+
{
76+
addr[(nr / BITS_PER_LONG)] &= ~(1 << (nr % BITS_PER_LONG));
77+
}
78+
79+
static inline int xsc_test_bit(unsigned int nr, const unsigned long *addr)
80+
{
81+
return !!(addr[(nr / BITS_PER_LONG)] & (1 << (nr % BITS_PER_LONG)));
82+
}
83+
84+
#endif

0 commit comments

Comments
 (0)