libnfb-ext-python 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- libnfb_ext_python-0.1.1/LICENSE +29 -0
- libnfb_ext_python-0.1.1/MANIFEST.in +3 -0
- libnfb_ext_python-0.1.1/PKG-INFO +36 -0
- libnfb_ext_python-0.1.1/libnfb_ext_python.egg-info/PKG-INFO +36 -0
- {libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/libnfb_ext_python.egg-info/SOURCES.txt +8 -1
- {libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/libnfb_ext_python.egg-info/requires.txt +1 -0
- libnfb_ext_python-0.1.1/nfb/ext/python/shim.h +70 -0
- libnfb_ext_python-0.1.1/nfb/ext/python/shim.pxd +121 -0
- libnfb_ext_python-0.1.1/nfb/ext/python/shim.pyx +272 -0
- libnfb_ext_python-0.1.1/nfb/ext/python/shim_api.h +179 -0
- libnfb_ext_python-0.1.1/pyproject.toml +37 -0
- libnfb_ext_python-0.1.1/readme.rst +10 -0
- libnfb_ext_python-0.1.0/PKG-INFO +0 -9
- libnfb_ext_python-0.1.0/libnfb_ext_python.egg-info/PKG-INFO +0 -9
- libnfb_ext_python-0.1.0/pyproject.toml +0 -6
- {libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/libnfb_ext_python.egg-info/dependency_links.txt +0 -0
- {libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/libnfb_ext_python.egg-info/top_level.txt +0 -0
- {libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/nfb/ext/python/__init__.py +0 -0
- {libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/nfb/ext/python/ext_entry.c +0 -0
- {libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/nfb/ext/python/shim.c +0 -0
- {libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/setup.cfg +0 -0
- {libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/setup.py +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2003-2022 CESNET
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: libnfb-ext-python
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Python extension for libnfb — implement NFB device backends in Python
|
|
5
|
+
Author: Martin Spinler
|
|
6
|
+
Author-email: Martin Spinler <spinler@cesnet.cz>
|
|
7
|
+
License-Expression: BSD-3-Clause
|
|
8
|
+
Project-URL: Homepage, https://github.com/CESNET/ndk-sw
|
|
9
|
+
Project-URL: Documentation, https://cesnet.github.io/ndk-sw/
|
|
10
|
+
Project-URL: Repository, https://github.com/CESNET/ndk-sw
|
|
11
|
+
Project-URL: Bug Tracker, https://github.com/CESNET/ndk-sw/issues
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Cython
|
|
17
|
+
Classifier: Topic :: System :: Hardware
|
|
18
|
+
Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/x-rst
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: fdt
|
|
23
|
+
Requires-Dist: nfb
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
Installation
|
|
28
|
+
------------
|
|
29
|
+
|
|
30
|
+
libnfb_ext_python package requires nfb package for build.
|
|
31
|
+
The wanted nfb package is probably not available in ordinary way, so
|
|
32
|
+
local (venv) installation via pip can be done for example like this:
|
|
33
|
+
|
|
34
|
+
# current directory is root of this git repository
|
|
35
|
+
$ pip wheel -w ./localwhldir ./pynfb/
|
|
36
|
+
$ pip install --find-links ./localwhldir ./ext/libnfb_ext_python/
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: libnfb-ext-python
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Python extension for libnfb — implement NFB device backends in Python
|
|
5
|
+
Author: Martin Spinler
|
|
6
|
+
Author-email: Martin Spinler <spinler@cesnet.cz>
|
|
7
|
+
License-Expression: BSD-3-Clause
|
|
8
|
+
Project-URL: Homepage, https://github.com/CESNET/ndk-sw
|
|
9
|
+
Project-URL: Documentation, https://cesnet.github.io/ndk-sw/
|
|
10
|
+
Project-URL: Repository, https://github.com/CESNET/ndk-sw
|
|
11
|
+
Project-URL: Bug Tracker, https://github.com/CESNET/ndk-sw/issues
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Cython
|
|
17
|
+
Classifier: Topic :: System :: Hardware
|
|
18
|
+
Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/x-rst
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: fdt
|
|
23
|
+
Requires-Dist: nfb
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
Installation
|
|
28
|
+
------------
|
|
29
|
+
|
|
30
|
+
libnfb_ext_python package requires nfb package for build.
|
|
31
|
+
The wanted nfb package is probably not available in ordinary way, so
|
|
32
|
+
local (venv) installation via pip can be done for example like this:
|
|
33
|
+
|
|
34
|
+
# current directory is root of this git repository
|
|
35
|
+
$ pip wheel -w ./localwhldir ./pynfb/
|
|
36
|
+
$ pip install --find-links ./localwhldir ./ext/libnfb_ext_python/
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
1
3
|
pyproject.toml
|
|
4
|
+
readme.rst
|
|
2
5
|
setup.py
|
|
3
6
|
libnfb_ext_python.egg-info/PKG-INFO
|
|
4
7
|
libnfb_ext_python.egg-info/SOURCES.txt
|
|
@@ -7,4 +10,8 @@ libnfb_ext_python.egg-info/requires.txt
|
|
|
7
10
|
libnfb_ext_python.egg-info/top_level.txt
|
|
8
11
|
nfb/ext/python/__init__.py
|
|
9
12
|
nfb/ext/python/ext_entry.c
|
|
10
|
-
nfb/ext/python/shim.c
|
|
13
|
+
nfb/ext/python/shim.c
|
|
14
|
+
nfb/ext/python/shim.h
|
|
15
|
+
nfb/ext/python/shim.pxd
|
|
16
|
+
nfb/ext/python/shim.pyx
|
|
17
|
+
nfb/ext/python/shim_api.h
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* Generated by Cython 3.2.5 */
|
|
2
|
+
|
|
3
|
+
#ifndef __PYX_HAVE__shim
|
|
4
|
+
#define __PYX_HAVE__shim
|
|
5
|
+
|
|
6
|
+
#include "Python.h"
|
|
7
|
+
|
|
8
|
+
#ifndef __PYX_HAVE_API__shim
|
|
9
|
+
|
|
10
|
+
#ifdef CYTHON_EXTERN_C
|
|
11
|
+
#undef __PYX_EXTERN_C
|
|
12
|
+
#define __PYX_EXTERN_C CYTHON_EXTERN_C
|
|
13
|
+
#elif defined(__PYX_EXTERN_C)
|
|
14
|
+
#ifdef _MSC_VER
|
|
15
|
+
#pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.")
|
|
16
|
+
#else
|
|
17
|
+
#warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.
|
|
18
|
+
#endif
|
|
19
|
+
#else
|
|
20
|
+
#ifdef __cplusplus
|
|
21
|
+
#define __PYX_EXTERN_C extern "C"
|
|
22
|
+
#else
|
|
23
|
+
#define __PYX_EXTERN_C extern
|
|
24
|
+
#endif
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
#ifndef DL_IMPORT
|
|
28
|
+
#define DL_IMPORT(_T) _T
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
__PYX_EXTERN_C int pynfb_ext_get_ops(char const *, struct libnfb_ext_ops *);
|
|
32
|
+
__PYX_EXTERN_C int nfb_ext_python_open(char const *, int, void **, void **);
|
|
33
|
+
__PYX_EXTERN_C void nfb_ext_python_close(void *);
|
|
34
|
+
__PYX_EXTERN_C int nfb_pynfb_bus_open(void *, int, int, void **, struct libnfb_bus_ext_ops *);
|
|
35
|
+
__PYX_EXTERN_C void nfb_pynfb_bus_close(void *);
|
|
36
|
+
__PYX_EXTERN_C Py_ssize_t nfb_pynfb_bus_read(void *, void *, size_t, off_t);
|
|
37
|
+
__PYX_EXTERN_C Py_ssize_t nfb_pynfb_bus_write(void *, void const *, size_t, off_t);
|
|
38
|
+
__PYX_EXTERN_C int nfb_pyndp_queue_open(struct nfb_device *, void *, unsigned int, int, int, struct ndp_queue **);
|
|
39
|
+
__PYX_EXTERN_C int nfb_pyndp_queue_close(struct ndp_queue *);
|
|
40
|
+
__PYX_EXTERN_C int pyndp_start(void *);
|
|
41
|
+
__PYX_EXTERN_C int pyndp_stop(void *);
|
|
42
|
+
__PYX_EXTERN_C unsigned int pyndp_rx_burst_get(void *, struct ndp_packet *, unsigned int);
|
|
43
|
+
__PYX_EXTERN_C int pyndp_rx_burst_put(void *);
|
|
44
|
+
__PYX_EXTERN_C unsigned int pyndp_tx_burst_get(void *, struct ndp_packet *, unsigned int);
|
|
45
|
+
__PYX_EXTERN_C int pyndp_tx_burst_put(void *);
|
|
46
|
+
__PYX_EXTERN_C int pyndp_tx_burst_flush(void *);
|
|
47
|
+
|
|
48
|
+
#endif /* !__PYX_HAVE_API__shim */
|
|
49
|
+
|
|
50
|
+
/* WARNING: the interface of the module init function changed in CPython 3.5. */
|
|
51
|
+
/* It now returns a PyModuleDef instance instead of a PyModule instance. */
|
|
52
|
+
|
|
53
|
+
/* WARNING: Use PyImport_AppendInittab("shim", PyInit_shim) instead of calling PyInit_shim directly from Python 3.5 */
|
|
54
|
+
PyMODINIT_FUNC PyInit_shim(void);
|
|
55
|
+
|
|
56
|
+
#if PY_VERSION_HEX >= 0x03050000 && (defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) || (defined(__cplusplus) && __cplusplus >= 201402L))
|
|
57
|
+
#if defined(__cplusplus) && __cplusplus >= 201402L
|
|
58
|
+
[[deprecated("Use PyImport_AppendInittab(\"shim\", PyInit_shim) instead of calling PyInit_shim directly.")]] inline
|
|
59
|
+
#elif defined(__GNUC__) || defined(__clang__)
|
|
60
|
+
__attribute__ ((__deprecated__("Use PyImport_AppendInittab(\"shim\", PyInit_shim) instead of calling PyInit_shim directly."), __unused__)) __inline__
|
|
61
|
+
#elif defined(_MSC_VER)
|
|
62
|
+
__declspec(deprecated("Use PyImport_AppendInittab(\"shim\", PyInit_shim) instead of calling PyInit_shim directly.")) __inline
|
|
63
|
+
#endif
|
|
64
|
+
static PyObject* __PYX_WARN_IF_PyInit_shim_INIT_CALLED(PyObject* res) {
|
|
65
|
+
return res;
|
|
66
|
+
}
|
|
67
|
+
#define PyInit_shim() __PYX_WARN_IF_PyInit_shim_INIT_CALLED(PyInit_shim())
|
|
68
|
+
#endif
|
|
69
|
+
|
|
70
|
+
#endif /* !__PYX_HAVE__shim */
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
from posix.types cimport off_t
|
|
2
|
+
|
|
3
|
+
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t
|
|
4
|
+
from libc.stdlib cimport malloc, strtoull, free
|
|
5
|
+
from libc.string cimport strlen, memcpy, strncmp
|
|
6
|
+
|
|
7
|
+
from cpython.ref cimport PyObject, Py_INCREF, Py_DECREF
|
|
8
|
+
|
|
9
|
+
from libc.stdio cimport printf
|
|
10
|
+
cimport libc.errno
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
cdef extern from "<libfdt.h>":
|
|
14
|
+
int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
|
|
15
|
+
|
|
16
|
+
cdef extern from "<nfb/ndp.h>":
|
|
17
|
+
cdef struct nfb_device:
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
cdef struct nfb_comp:
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
cdef struct ndp_packet:
|
|
24
|
+
unsigned char *data
|
|
25
|
+
unsigned char *header
|
|
26
|
+
unsigned data_length
|
|
27
|
+
unsigned header_length
|
|
28
|
+
uint16_t flags
|
|
29
|
+
|
|
30
|
+
cdef struct ndp_queue:
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
cdef extern from "<nfb/ext.h>":
|
|
34
|
+
ctypedef ssize_t nfb_bus_read_func(void *p, void *buf, size_t nbyte, off_t offset)
|
|
35
|
+
ctypedef ssize_t nfb_bus_write_func(void *p, const void *buf, size_t nbyte, off_t offset)
|
|
36
|
+
|
|
37
|
+
ctypedef int libnfb_ext_ops_open(const char *devname, int oflag, void **priv, void **fdt)
|
|
38
|
+
ctypedef void libnfb_ext_ops_close(void *priv)
|
|
39
|
+
ctypedef int libnfb_ext_ops_bus_open_mi(void *dev_priv, int bus_node, int comp_node, void ** bus_priv, libnfb_bus_ext_ops* ops)
|
|
40
|
+
ctypedef void libnfb_ext_ops_bus_close_mi(void *bus_priv)
|
|
41
|
+
ctypedef int libnfb_ext_ops_comp_lock(const nfb_comp *comp, uint32_t features)
|
|
42
|
+
ctypedef void libnfb_ext_ops_comp_unlock(const nfb_comp *comp, uint32_t features)
|
|
43
|
+
|
|
44
|
+
ctypedef int libnfb_ext_ops_ndp_queue_open(nfb_device *dev, void *dev_priv, unsigned index, int dir, int flags, ndp_queue ** pq)
|
|
45
|
+
ctypedef int libnfb_ext_ops_ndp_queue_close(ndp_queue *q)
|
|
46
|
+
|
|
47
|
+
ctypedef unsigned ndp_rx_burst_get_t(void *priv, ndp_packet *packets, unsigned count)
|
|
48
|
+
ctypedef int ndp_rx_burst_put_t(void *priv)
|
|
49
|
+
|
|
50
|
+
ctypedef unsigned ndp_tx_burst_get_t(void *priv, ndp_packet *packets, unsigned count)
|
|
51
|
+
ctypedef int ndp_tx_burst_put_t(void *priv)
|
|
52
|
+
ctypedef int ndp_tx_burst_flush_t(void *priv)
|
|
53
|
+
|
|
54
|
+
struct libnfb_ext_ops:
|
|
55
|
+
libnfb_ext_ops_open open
|
|
56
|
+
libnfb_ext_ops_close close
|
|
57
|
+
libnfb_ext_ops_bus_open_mi bus_open_mi
|
|
58
|
+
libnfb_ext_ops_bus_close_mi bus_close_mi
|
|
59
|
+
libnfb_ext_ops_comp_lock comp_lock
|
|
60
|
+
libnfb_ext_ops_comp_unlock comp_unlock
|
|
61
|
+
|
|
62
|
+
libnfb_ext_ops_ndp_queue_open ndp_queue_open
|
|
63
|
+
libnfb_ext_ops_ndp_queue_close ndp_queue_close
|
|
64
|
+
|
|
65
|
+
cdef struct libnfb_bus_ext_ops:
|
|
66
|
+
nfb_bus_read_func *read
|
|
67
|
+
nfb_bus_write_func *write
|
|
68
|
+
|
|
69
|
+
ctypedef struct ndp_queue_ops_burst_tx:
|
|
70
|
+
ndp_tx_burst_get_t get
|
|
71
|
+
ndp_tx_burst_put_t put
|
|
72
|
+
ndp_tx_burst_flush_t flush
|
|
73
|
+
ctypedef struct ndp_queue_ops_burst_rx:
|
|
74
|
+
ndp_rx_burst_get_t get
|
|
75
|
+
ndp_rx_burst_put_t put
|
|
76
|
+
|
|
77
|
+
ctypedef union ndp_queue_ops_burst:
|
|
78
|
+
ndp_queue_ops_burst_rx rx
|
|
79
|
+
ndp_queue_ops_burst_tx tx
|
|
80
|
+
|
|
81
|
+
ctypedef struct ndp_queue_ops_control:
|
|
82
|
+
int (*start)(void *priv)
|
|
83
|
+
int (*stop)(void *priv)
|
|
84
|
+
|
|
85
|
+
cdef struct ndp_queue_ops:
|
|
86
|
+
ndp_queue_ops_burst burst
|
|
87
|
+
ndp_queue_ops_control control
|
|
88
|
+
|
|
89
|
+
cdef ndp_queue * ndp_queue_create(nfb_device *dev, int numa, int type, int index)
|
|
90
|
+
cdef void ndp_queue_destroy(ndp_queue* q)
|
|
91
|
+
|
|
92
|
+
cdef void* ndp_queue_get_priv(ndp_queue *q)
|
|
93
|
+
cdef void ndp_queue_set_priv(ndp_queue *q, void *priv)
|
|
94
|
+
|
|
95
|
+
cdef ndp_queue_ops* ndp_queue_get_ops(ndp_queue *q)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
cdef public api:
|
|
99
|
+
int pynfb_ext_get_ops(const char *devname, libnfb_ext_ops* ops) noexcept
|
|
100
|
+
|
|
101
|
+
int nfb_ext_python_open(const char *devname, int oflag, void **priv, void **fdt) noexcept with gil
|
|
102
|
+
void nfb_ext_python_close(void *priv) noexcept with gil
|
|
103
|
+
|
|
104
|
+
int nfb_pynfb_bus_open(void *dev_priv, int bus_node, int comp_node, void ** bus_priv, libnfb_bus_ext_ops* ops) noexcept with gil
|
|
105
|
+
void nfb_pynfb_bus_close(void *bus_priv) noexcept with gil
|
|
106
|
+
|
|
107
|
+
ssize_t nfb_pynfb_bus_read(void *bus_priv, void *buf, size_t nbyte, off_t offset) noexcept with gil
|
|
108
|
+
ssize_t nfb_pynfb_bus_write(void *bus_priv, const void *buf, size_t nbyte, off_t offset) noexcept with gil
|
|
109
|
+
|
|
110
|
+
cdef int nfb_pyndp_queue_open(nfb_device *dev, void *dev_priv, unsigned index, int dir, int flags, ndp_queue ** pq) noexcept with gil
|
|
111
|
+
cdef int nfb_pyndp_queue_close(ndp_queue *q) noexcept with gil
|
|
112
|
+
|
|
113
|
+
cdef int pyndp_start(void *priv) with gil
|
|
114
|
+
cdef int pyndp_stop(void *priv) with gil
|
|
115
|
+
|
|
116
|
+
cdef unsigned pyndp_rx_burst_get(void *priv, ndp_packet *packets, unsigned count) with gil
|
|
117
|
+
cdef int pyndp_rx_burst_put(void *priv) with gil
|
|
118
|
+
|
|
119
|
+
cdef unsigned pyndp_tx_burst_get(void *priv, ndp_packet *packets, unsigned count) with gil
|
|
120
|
+
cdef int pyndp_tx_burst_put(void *priv) with gil
|
|
121
|
+
cdef int pyndp_tx_burst_flush(void *priv) with gil
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
cdef api const char *libnfb_ext_compatible_pattern = "libnfb-ext-compat_pattern:"
|
|
2
|
+
|
|
3
|
+
def get_libnfb_ext_path(nfb):
|
|
4
|
+
# early version of libnfb relies on a pattern "libnfb-ext-" somewhere in device string/path
|
|
5
|
+
base = __file__ + ":" + libnfb_ext_compatible_pattern.decode()
|
|
6
|
+
# new extension identification string must have a "libnfb-ext:" prefix (backward incompatible)
|
|
7
|
+
#base = "libnfb-ext:" + __file__ + ":"
|
|
8
|
+
return base + str(id(nfb))
|
|
9
|
+
|
|
10
|
+
cdef class __NfbWrapper:
|
|
11
|
+
cdef char * fdt
|
|
12
|
+
cdef object nfb
|
|
13
|
+
cdef list bus
|
|
14
|
+
|
|
15
|
+
cdef int nfb_ext_python_open(const char *devname, int oflag, void **priv, void **fdt) noexcept with gil:
|
|
16
|
+
cdef int ret
|
|
17
|
+
cdef uint64_t addr
|
|
18
|
+
cdef object nfb
|
|
19
|
+
cdef bytes dtb
|
|
20
|
+
cdef PyObject* _nfb
|
|
21
|
+
cdef __NfbWrapper wrap
|
|
22
|
+
|
|
23
|
+
addr = strtoull(devname + strlen(libnfb_ext_compatible_pattern), NULL, 10)
|
|
24
|
+
_nfb = <PyObject*> <void*> addr
|
|
25
|
+
nfb = <object> _nfb
|
|
26
|
+
|
|
27
|
+
wrap = __NfbWrapper()
|
|
28
|
+
Py_INCREF(wrap)
|
|
29
|
+
wrap.nfb = <object> _nfb
|
|
30
|
+
|
|
31
|
+
dtb = nfb._nfb_ext_python_dtb
|
|
32
|
+
ret = len(dtb)
|
|
33
|
+
|
|
34
|
+
wrap.fdt = <char*> malloc(ret)
|
|
35
|
+
if wrap.fdt == NULL:
|
|
36
|
+
Py_DECREF(wrap)
|
|
37
|
+
return -libc.errno.ENOMEM
|
|
38
|
+
|
|
39
|
+
memcpy(wrap.fdt, <const char*>dtb, ret)
|
|
40
|
+
|
|
41
|
+
fdt[0] = wrap.fdt
|
|
42
|
+
priv[0] = <void*><PyObject*> wrap
|
|
43
|
+
|
|
44
|
+
return 0
|
|
45
|
+
|
|
46
|
+
cdef void nfb_ext_python_close(void *priv) noexcept with gil:
|
|
47
|
+
cdef PyObject* _wrap
|
|
48
|
+
cdef __NfbWrapper wrap
|
|
49
|
+
cdef object nfb
|
|
50
|
+
cdef bytes dtb
|
|
51
|
+
|
|
52
|
+
_wrap = <PyObject*> priv
|
|
53
|
+
wrap = <object> _wrap
|
|
54
|
+
|
|
55
|
+
# The libnfb is responsible for freeing fdt
|
|
56
|
+
#free(wrap.fdt)
|
|
57
|
+
Py_DECREF(wrap)
|
|
58
|
+
|
|
59
|
+
cdef ssize_t nfb_pynfb_bus_read(void *p, void *buf, size_t nbyte, off_t offset) noexcept with gil:
|
|
60
|
+
cdef PyObject* _bus = <PyObject *> p
|
|
61
|
+
cdef object bus = <object> _bus
|
|
62
|
+
cdef bytes data
|
|
63
|
+
cdef ssize_t ret
|
|
64
|
+
|
|
65
|
+
nfb, comp_node, bus_node = bus
|
|
66
|
+
data = nfb.read(bus_node, comp_node, offset, nbyte)
|
|
67
|
+
ret = len(data)
|
|
68
|
+
if ret > int(nbyte):
|
|
69
|
+
ret = -1
|
|
70
|
+
|
|
71
|
+
if ret > 0:
|
|
72
|
+
memcpy(buf, <const char*>data, ret)
|
|
73
|
+
|
|
74
|
+
return ret
|
|
75
|
+
|
|
76
|
+
cdef ssize_t nfb_pynfb_bus_write(void *p, const void *buf, size_t nbyte, off_t offset) noexcept with gil:
|
|
77
|
+
cdef PyObject* _bus = <PyObject *> p
|
|
78
|
+
cdef object bus = <object> _bus
|
|
79
|
+
cdef const char* c_data = <const char*> buf
|
|
80
|
+
cdef bytes data = c_data[:nbyte]
|
|
81
|
+
|
|
82
|
+
nfb, comp_node, bus_node = bus
|
|
83
|
+
nfb.write(bus_node, comp_node, offset, data)
|
|
84
|
+
|
|
85
|
+
return nbyte
|
|
86
|
+
|
|
87
|
+
cdef int nfb_pynfb_bus_open(void *dev_priv, int bus_offset, int comp_offset, void ** bus_priv, libnfb_bus_ext_ops* ops) noexcept with gil:
|
|
88
|
+
cdef PyObject* _wrap = <PyObject*> dev_priv
|
|
89
|
+
cdef __NfbWrapper wrap = <object> _wrap
|
|
90
|
+
|
|
91
|
+
cdef int ret
|
|
92
|
+
cdef char * path
|
|
93
|
+
cdef object bus
|
|
94
|
+
cdef bytes bpath
|
|
95
|
+
|
|
96
|
+
path = <char*> malloc(1024)
|
|
97
|
+
if path == NULL:
|
|
98
|
+
return -libc.errno.ENOMEM
|
|
99
|
+
|
|
100
|
+
fdt = wrap.nfb._nfb_ext_python_fdt
|
|
101
|
+
|
|
102
|
+
ret = fdt_get_path(wrap.fdt, comp_offset, path, 1024)
|
|
103
|
+
comp_node = fdt.get_node((<bytes>path).decode())
|
|
104
|
+
ret = fdt_get_path(wrap.fdt, bus_offset, path, 1024)
|
|
105
|
+
bus_node = fdt.get_node((<bytes>path).decode())
|
|
106
|
+
|
|
107
|
+
free(path)
|
|
108
|
+
|
|
109
|
+
ops.read = <nfb_bus_read_func*> nfb_pynfb_bus_read
|
|
110
|
+
ops.write = <nfb_bus_write_func*> nfb_pynfb_bus_write
|
|
111
|
+
|
|
112
|
+
bus = (wrap.nfb, comp_node, bus_node)
|
|
113
|
+
|
|
114
|
+
Py_INCREF(bus)
|
|
115
|
+
bus_priv[0] = <PyObject*>bus
|
|
116
|
+
|
|
117
|
+
return 0
|
|
118
|
+
|
|
119
|
+
cdef void nfb_pynfb_bus_close(void *priv) noexcept with gil:
|
|
120
|
+
cdef PyObject* _bus = <PyObject *> priv
|
|
121
|
+
cdef object bus = <object> _bus
|
|
122
|
+
|
|
123
|
+
Py_DECREF(bus)
|
|
124
|
+
|
|
125
|
+
# NDP functions
|
|
126
|
+
|
|
127
|
+
cdef int pyndp_start(void *priv) noexcept with gil:
|
|
128
|
+
cdef object t = <object>priv
|
|
129
|
+
|
|
130
|
+
queue, temp = t
|
|
131
|
+
queue.start()
|
|
132
|
+
|
|
133
|
+
return 0
|
|
134
|
+
|
|
135
|
+
cdef int pyndp_stop(void *priv) noexcept with gil:
|
|
136
|
+
cdef object t = <object>priv
|
|
137
|
+
|
|
138
|
+
queue, temp = t
|
|
139
|
+
queue.stop()
|
|
140
|
+
|
|
141
|
+
return 0
|
|
142
|
+
|
|
143
|
+
cdef unsigned pyndp_rx_burst_get(void *priv, ndp_packet *packets, unsigned count) noexcept with gil:
|
|
144
|
+
cdef object t = <object>priv
|
|
145
|
+
|
|
146
|
+
cdef uint8_t* c_data
|
|
147
|
+
cdef uint8_t* c_hdr
|
|
148
|
+
|
|
149
|
+
queue, temp = t
|
|
150
|
+
|
|
151
|
+
pkts = queue.burst_get(count)
|
|
152
|
+
cnt = min(len(pkts), count)
|
|
153
|
+
for i in range(cnt):
|
|
154
|
+
pkt, hdr, flags = pkts[i]
|
|
155
|
+
|
|
156
|
+
c_data = pkt
|
|
157
|
+
c_hdr = hdr
|
|
158
|
+
packets[i].data_length = len(pkt)
|
|
159
|
+
packets[i].header_length = len(hdr)
|
|
160
|
+
packets[i].data = c_data
|
|
161
|
+
packets[i].header = c_hdr
|
|
162
|
+
packets[i].flags = flags
|
|
163
|
+
|
|
164
|
+
return cnt
|
|
165
|
+
|
|
166
|
+
cdef int pyndp_rx_burst_put(void *priv) noexcept with gil:
|
|
167
|
+
cdef object t = <object>priv
|
|
168
|
+
|
|
169
|
+
queue, temp = t
|
|
170
|
+
queue.burst_put()
|
|
171
|
+
|
|
172
|
+
return 0
|
|
173
|
+
|
|
174
|
+
cdef unsigned pyndp_tx_burst_get(void *priv, ndp_packet *packets, unsigned count) noexcept with gil:
|
|
175
|
+
cdef object t = <object>priv
|
|
176
|
+
queue, temp = t
|
|
177
|
+
|
|
178
|
+
pkts = []
|
|
179
|
+
for i in range(count):
|
|
180
|
+
pkts.append((
|
|
181
|
+
int(packets[i].data_length),
|
|
182
|
+
int(packets[i].header_length),
|
|
183
|
+
int(packets[i].flags),
|
|
184
|
+
))
|
|
185
|
+
prep = queue.burst_get(pkts)
|
|
186
|
+
|
|
187
|
+
for i in range(len(prep)):
|
|
188
|
+
packets[i].data = <unsigned char*>prep[i][0]
|
|
189
|
+
packets[i].header = <unsigned char*>prep[i][1]
|
|
190
|
+
|
|
191
|
+
return len(prep)
|
|
192
|
+
|
|
193
|
+
cdef int pyndp_tx_burst_put(void *priv) noexcept with gil:
|
|
194
|
+
cdef object t = <object>priv
|
|
195
|
+
|
|
196
|
+
queue, temp = t
|
|
197
|
+
queue.burst_put()
|
|
198
|
+
|
|
199
|
+
return 0
|
|
200
|
+
|
|
201
|
+
cdef int pyndp_tx_burst_flush(void *priv) noexcept with gil:
|
|
202
|
+
cdef object t = <object>priv
|
|
203
|
+
|
|
204
|
+
queue, temp = t
|
|
205
|
+
queue.burst_flush()
|
|
206
|
+
return 0
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
cdef int nfb_pyndp_queue_open(nfb_device *dev, void *dev_priv, unsigned index, int dir, int flags, ndp_queue ** pq) noexcept with gil:
|
|
210
|
+
cdef PyObject* _wrap = <PyObject*> dev_priv
|
|
211
|
+
cdef __NfbWrapper wrap = <object> _wrap
|
|
212
|
+
|
|
213
|
+
cdef int ret
|
|
214
|
+
cdef ndp_queue *q
|
|
215
|
+
cdef ndp_queue_ops* ops
|
|
216
|
+
|
|
217
|
+
cdef object t
|
|
218
|
+
|
|
219
|
+
try:
|
|
220
|
+
queue = wrap.nfb.queue_open(index, dir, flags)
|
|
221
|
+
assert queue is not None
|
|
222
|
+
except:
|
|
223
|
+
return -libc.errno.ENODEV
|
|
224
|
+
|
|
225
|
+
q = ndp_queue_create(dev, -1, dir, index)
|
|
226
|
+
if q == NULL:
|
|
227
|
+
return -libc.errno.ENOMEM
|
|
228
|
+
|
|
229
|
+
t = (queue, [])
|
|
230
|
+
Py_INCREF(t)
|
|
231
|
+
|
|
232
|
+
ndp_queue_set_priv(q, <PyObject*>t);
|
|
233
|
+
|
|
234
|
+
ops = ndp_queue_get_ops(q)
|
|
235
|
+
ops.control.start = pyndp_start
|
|
236
|
+
ops.control.stop = pyndp_stop
|
|
237
|
+
if dir == 0:
|
|
238
|
+
ops.burst.rx.get = pyndp_rx_burst_get
|
|
239
|
+
ops.burst.rx.put = pyndp_rx_burst_put
|
|
240
|
+
else:
|
|
241
|
+
ops.burst.tx.get = pyndp_tx_burst_get
|
|
242
|
+
ops.burst.tx.put = pyndp_tx_burst_put
|
|
243
|
+
ops.burst.tx.flush = pyndp_tx_burst_flush
|
|
244
|
+
|
|
245
|
+
pq[0] = q
|
|
246
|
+
|
|
247
|
+
return 0
|
|
248
|
+
|
|
249
|
+
cdef int nfb_pyndp_queue_close(ndp_queue *q) noexcept with gil:
|
|
250
|
+
cdef object t = <object>ndp_queue_get_priv(q)
|
|
251
|
+
|
|
252
|
+
queue, temp = t
|
|
253
|
+
Py_DECREF(t)
|
|
254
|
+
return 0
|
|
255
|
+
|
|
256
|
+
cdef int nfb_pynfb_comp_lock(const nfb_comp *comp, uint32_t features) noexcept with gil:
|
|
257
|
+
# TODO
|
|
258
|
+
return 1;
|
|
259
|
+
|
|
260
|
+
cdef void nfb_pynfb_comp_unlock(const nfb_comp *comp, uint32_t features) noexcept with gil:
|
|
261
|
+
pass
|
|
262
|
+
|
|
263
|
+
cdef int pynfb_ext_get_ops(const char *devname, libnfb_ext_ops* ops) noexcept:
|
|
264
|
+
ops.open = nfb_ext_python_open
|
|
265
|
+
ops.close = nfb_ext_python_close
|
|
266
|
+
ops.bus_open_mi = nfb_pynfb_bus_open
|
|
267
|
+
ops.bus_close_mi = nfb_pynfb_bus_close
|
|
268
|
+
ops.comp_lock = nfb_pynfb_comp_lock
|
|
269
|
+
ops.comp_unlock = nfb_pynfb_comp_unlock
|
|
270
|
+
ops.ndp_queue_open = nfb_pyndp_queue_open
|
|
271
|
+
ops.ndp_queue_close = nfb_pyndp_queue_close
|
|
272
|
+
return 1
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/* Generated by Cython 3.2.5 */
|
|
2
|
+
|
|
3
|
+
#ifndef __PYX_HAVE_API__shim
|
|
4
|
+
#define __PYX_HAVE_API__shim
|
|
5
|
+
#ifdef __MINGW64__
|
|
6
|
+
#define MS_WIN64
|
|
7
|
+
#endif
|
|
8
|
+
#include "Python.h"
|
|
9
|
+
#include "shim.h"
|
|
10
|
+
|
|
11
|
+
static int (*__pyx_api_f_4shim_pynfb_ext_get_ops)(char const *, struct libnfb_ext_ops *) = 0;
|
|
12
|
+
#define pynfb_ext_get_ops __pyx_api_f_4shim_pynfb_ext_get_ops
|
|
13
|
+
static int (*__pyx_api_f_4shim_nfb_ext_python_open)(char const *, int, void **, void **) = 0;
|
|
14
|
+
#define nfb_ext_python_open __pyx_api_f_4shim_nfb_ext_python_open
|
|
15
|
+
static void (*__pyx_api_f_4shim_nfb_ext_python_close)(void *) = 0;
|
|
16
|
+
#define nfb_ext_python_close __pyx_api_f_4shim_nfb_ext_python_close
|
|
17
|
+
static int (*__pyx_api_f_4shim_nfb_pynfb_bus_open)(void *, int, int, void **, struct libnfb_bus_ext_ops *) = 0;
|
|
18
|
+
#define nfb_pynfb_bus_open __pyx_api_f_4shim_nfb_pynfb_bus_open
|
|
19
|
+
static void (*__pyx_api_f_4shim_nfb_pynfb_bus_close)(void *) = 0;
|
|
20
|
+
#define nfb_pynfb_bus_close __pyx_api_f_4shim_nfb_pynfb_bus_close
|
|
21
|
+
static Py_ssize_t (*__pyx_api_f_4shim_nfb_pynfb_bus_read)(void *, void *, size_t, off_t) = 0;
|
|
22
|
+
#define nfb_pynfb_bus_read __pyx_api_f_4shim_nfb_pynfb_bus_read
|
|
23
|
+
static Py_ssize_t (*__pyx_api_f_4shim_nfb_pynfb_bus_write)(void *, void const *, size_t, off_t) = 0;
|
|
24
|
+
#define nfb_pynfb_bus_write __pyx_api_f_4shim_nfb_pynfb_bus_write
|
|
25
|
+
static int (*__pyx_api_f_4shim_nfb_pyndp_queue_open)(struct nfb_device *, void *, unsigned int, int, int, struct ndp_queue **) = 0;
|
|
26
|
+
#define nfb_pyndp_queue_open __pyx_api_f_4shim_nfb_pyndp_queue_open
|
|
27
|
+
static int (*__pyx_api_f_4shim_nfb_pyndp_queue_close)(struct ndp_queue *) = 0;
|
|
28
|
+
#define nfb_pyndp_queue_close __pyx_api_f_4shim_nfb_pyndp_queue_close
|
|
29
|
+
static int (*__pyx_api_f_4shim_pyndp_start)(void *) = 0;
|
|
30
|
+
#define pyndp_start __pyx_api_f_4shim_pyndp_start
|
|
31
|
+
static int (*__pyx_api_f_4shim_pyndp_stop)(void *) = 0;
|
|
32
|
+
#define pyndp_stop __pyx_api_f_4shim_pyndp_stop
|
|
33
|
+
static unsigned int (*__pyx_api_f_4shim_pyndp_rx_burst_get)(void *, struct ndp_packet *, unsigned int) = 0;
|
|
34
|
+
#define pyndp_rx_burst_get __pyx_api_f_4shim_pyndp_rx_burst_get
|
|
35
|
+
static int (*__pyx_api_f_4shim_pyndp_rx_burst_put)(void *) = 0;
|
|
36
|
+
#define pyndp_rx_burst_put __pyx_api_f_4shim_pyndp_rx_burst_put
|
|
37
|
+
static unsigned int (*__pyx_api_f_4shim_pyndp_tx_burst_get)(void *, struct ndp_packet *, unsigned int) = 0;
|
|
38
|
+
#define pyndp_tx_burst_get __pyx_api_f_4shim_pyndp_tx_burst_get
|
|
39
|
+
static int (*__pyx_api_f_4shim_pyndp_tx_burst_put)(void *) = 0;
|
|
40
|
+
#define pyndp_tx_burst_put __pyx_api_f_4shim_pyndp_tx_burst_put
|
|
41
|
+
static int (*__pyx_api_f_4shim_pyndp_tx_burst_flush)(void *) = 0;
|
|
42
|
+
#define pyndp_tx_burst_flush __pyx_api_f_4shim_pyndp_tx_burst_flush
|
|
43
|
+
|
|
44
|
+
static char const **__pyx_api_vp_4shim_libnfb_ext_compatible_pattern = 0;
|
|
45
|
+
#define libnfb_ext_compatible_pattern (*__pyx_api_vp_4shim_libnfb_ext_compatible_pattern)
|
|
46
|
+
static int __Pyx_ImportVoidPtr_3_2_5(PyObject *module, const char *name, void **p, const char *sig);
|
|
47
|
+
|
|
48
|
+
#ifndef __PYX_HAVE_RT_ImportFromPxd_3_2_5
|
|
49
|
+
#define __PYX_HAVE_RT_ImportFromPxd_3_2_5
|
|
50
|
+
static int __Pyx_ImportFromPxd_3_2_5(PyObject *module, const char *name, void **p, const char *sig, const char *what) {
|
|
51
|
+
PyObject *d = 0;
|
|
52
|
+
PyObject *cobj = 0;
|
|
53
|
+
d = PyObject_GetAttrString(module, "__pyx_capi__");
|
|
54
|
+
if (!d)
|
|
55
|
+
goto bad;
|
|
56
|
+
#if (defined(Py_LIMITED_API) && Py_LIMITED_API >= 0x030d0000) || (!defined(Py_LIMITED_API) && PY_VERSION_HEX >= 0x030d0000)
|
|
57
|
+
PyDict_GetItemStringRef(d, name, &cobj);
|
|
58
|
+
#else
|
|
59
|
+
cobj = PyDict_GetItemString(d, name);
|
|
60
|
+
Py_XINCREF(cobj);
|
|
61
|
+
#endif
|
|
62
|
+
if (!cobj) {
|
|
63
|
+
PyErr_Format(PyExc_ImportError,
|
|
64
|
+
"%.200s does not export expected C %.8s %.200s",
|
|
65
|
+
PyModule_GetName(module), what, name);
|
|
66
|
+
goto bad;
|
|
67
|
+
}
|
|
68
|
+
if (!PyCapsule_IsValid(cobj, sig)) {
|
|
69
|
+
PyErr_Format(PyExc_TypeError,
|
|
70
|
+
"C %.8s %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
|
71
|
+
what, PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
|
|
72
|
+
goto bad;
|
|
73
|
+
}
|
|
74
|
+
*p = PyCapsule_GetPointer(cobj, sig);
|
|
75
|
+
if (!(*p))
|
|
76
|
+
goto bad;
|
|
77
|
+
Py_DECREF(d);
|
|
78
|
+
Py_DECREF(cobj);
|
|
79
|
+
return 0;
|
|
80
|
+
bad:
|
|
81
|
+
Py_XDECREF(d);
|
|
82
|
+
Py_XDECREF(cobj);
|
|
83
|
+
return -1;
|
|
84
|
+
}
|
|
85
|
+
#endif
|
|
86
|
+
|
|
87
|
+
#ifndef __PYX_HAVE_RT_ImportVoidPtr_3_2_5
|
|
88
|
+
#define __PYX_HAVE_RT_ImportVoidPtr_3_2_5
|
|
89
|
+
static int __Pyx_ImportVoidPtr_3_2_5(PyObject *module, const char *name, void **p, const char *sig) {
|
|
90
|
+
return __Pyx_ImportFromPxd_3_2_5(module, name, p, sig, "variable");
|
|
91
|
+
}
|
|
92
|
+
#endif
|
|
93
|
+
|
|
94
|
+
static int __Pyx_ImportFunction_3_2_5(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
|
|
95
|
+
|
|
96
|
+
#ifndef __PYX_HAVE_RT_ImportFromPxd_3_2_5
|
|
97
|
+
#define __PYX_HAVE_RT_ImportFromPxd_3_2_5
|
|
98
|
+
static int __Pyx_ImportFromPxd_3_2_5(PyObject *module, const char *name, void **p, const char *sig, const char *what) {
|
|
99
|
+
PyObject *d = 0;
|
|
100
|
+
PyObject *cobj = 0;
|
|
101
|
+
d = PyObject_GetAttrString(module, "__pyx_capi__");
|
|
102
|
+
if (!d)
|
|
103
|
+
goto bad;
|
|
104
|
+
#if (defined(Py_LIMITED_API) && Py_LIMITED_API >= 0x030d0000) || (!defined(Py_LIMITED_API) && PY_VERSION_HEX >= 0x030d0000)
|
|
105
|
+
PyDict_GetItemStringRef(d, name, &cobj);
|
|
106
|
+
#else
|
|
107
|
+
cobj = PyDict_GetItemString(d, name);
|
|
108
|
+
Py_XINCREF(cobj);
|
|
109
|
+
#endif
|
|
110
|
+
if (!cobj) {
|
|
111
|
+
PyErr_Format(PyExc_ImportError,
|
|
112
|
+
"%.200s does not export expected C %.8s %.200s",
|
|
113
|
+
PyModule_GetName(module), what, name);
|
|
114
|
+
goto bad;
|
|
115
|
+
}
|
|
116
|
+
if (!PyCapsule_IsValid(cobj, sig)) {
|
|
117
|
+
PyErr_Format(PyExc_TypeError,
|
|
118
|
+
"C %.8s %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
|
119
|
+
what, PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
|
|
120
|
+
goto bad;
|
|
121
|
+
}
|
|
122
|
+
*p = PyCapsule_GetPointer(cobj, sig);
|
|
123
|
+
if (!(*p))
|
|
124
|
+
goto bad;
|
|
125
|
+
Py_DECREF(d);
|
|
126
|
+
Py_DECREF(cobj);
|
|
127
|
+
return 0;
|
|
128
|
+
bad:
|
|
129
|
+
Py_XDECREF(d);
|
|
130
|
+
Py_XDECREF(cobj);
|
|
131
|
+
return -1;
|
|
132
|
+
}
|
|
133
|
+
#endif
|
|
134
|
+
|
|
135
|
+
#ifndef __PYX_HAVE_RT_ImportFunction_3_2_5
|
|
136
|
+
#define __PYX_HAVE_RT_ImportFunction_3_2_5
|
|
137
|
+
static int __Pyx_ImportFunction_3_2_5(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
|
|
138
|
+
union {
|
|
139
|
+
void (*fp)(void);
|
|
140
|
+
void *p;
|
|
141
|
+
} tmp;
|
|
142
|
+
int result = __Pyx_ImportFromPxd_3_2_5(module, funcname, &tmp.p, sig, "function");
|
|
143
|
+
if (result == 0) {
|
|
144
|
+
*f = tmp.fp;
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
#endif
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
static int import_shim(void) {
|
|
152
|
+
PyObject *module = 0;
|
|
153
|
+
module = PyImport_ImportModule("shim");
|
|
154
|
+
if (!module) goto bad;
|
|
155
|
+
if (__Pyx_ImportFunction_3_2_5(module, "pynfb_ext_get_ops", (void (**)(void))&__pyx_api_f_4shim_pynfb_ext_get_ops, "int (char const *, struct libnfb_ext_ops *)") < 0) goto bad;
|
|
156
|
+
if (__Pyx_ImportFunction_3_2_5(module, "nfb_ext_python_open", (void (**)(void))&__pyx_api_f_4shim_nfb_ext_python_open, "int (char const *, int, void **, void **)") < 0) goto bad;
|
|
157
|
+
if (__Pyx_ImportFunction_3_2_5(module, "nfb_ext_python_close", (void (**)(void))&__pyx_api_f_4shim_nfb_ext_python_close, "void (void *)") < 0) goto bad;
|
|
158
|
+
if (__Pyx_ImportFunction_3_2_5(module, "nfb_pynfb_bus_open", (void (**)(void))&__pyx_api_f_4shim_nfb_pynfb_bus_open, "int (void *, int, int, void **, struct libnfb_bus_ext_ops *)") < 0) goto bad;
|
|
159
|
+
if (__Pyx_ImportFunction_3_2_5(module, "nfb_pynfb_bus_close", (void (**)(void))&__pyx_api_f_4shim_nfb_pynfb_bus_close, "void (void *)") < 0) goto bad;
|
|
160
|
+
if (__Pyx_ImportFunction_3_2_5(module, "nfb_pynfb_bus_read", (void (**)(void))&__pyx_api_f_4shim_nfb_pynfb_bus_read, "Py_ssize_t (void *, void *, size_t, off_t)") < 0) goto bad;
|
|
161
|
+
if (__Pyx_ImportFunction_3_2_5(module, "nfb_pynfb_bus_write", (void (**)(void))&__pyx_api_f_4shim_nfb_pynfb_bus_write, "Py_ssize_t (void *, void const *, size_t, off_t)") < 0) goto bad;
|
|
162
|
+
if (__Pyx_ImportFunction_3_2_5(module, "nfb_pyndp_queue_open", (void (**)(void))&__pyx_api_f_4shim_nfb_pyndp_queue_open, "int (struct nfb_device *, void *, unsigned int, int, int, struct ndp_queue **)") < 0) goto bad;
|
|
163
|
+
if (__Pyx_ImportFunction_3_2_5(module, "nfb_pyndp_queue_close", (void (**)(void))&__pyx_api_f_4shim_nfb_pyndp_queue_close, "int (struct ndp_queue *)") < 0) goto bad;
|
|
164
|
+
if (__Pyx_ImportFunction_3_2_5(module, "pyndp_start", (void (**)(void))&__pyx_api_f_4shim_pyndp_start, "int (void *)") < 0) goto bad;
|
|
165
|
+
if (__Pyx_ImportFunction_3_2_5(module, "pyndp_stop", (void (**)(void))&__pyx_api_f_4shim_pyndp_stop, "int (void *)") < 0) goto bad;
|
|
166
|
+
if (__Pyx_ImportFunction_3_2_5(module, "pyndp_rx_burst_get", (void (**)(void))&__pyx_api_f_4shim_pyndp_rx_burst_get, "unsigned int (void *, struct ndp_packet *, unsigned int)") < 0) goto bad;
|
|
167
|
+
if (__Pyx_ImportFunction_3_2_5(module, "pyndp_rx_burst_put", (void (**)(void))&__pyx_api_f_4shim_pyndp_rx_burst_put, "int (void *)") < 0) goto bad;
|
|
168
|
+
if (__Pyx_ImportFunction_3_2_5(module, "pyndp_tx_burst_get", (void (**)(void))&__pyx_api_f_4shim_pyndp_tx_burst_get, "unsigned int (void *, struct ndp_packet *, unsigned int)") < 0) goto bad;
|
|
169
|
+
if (__Pyx_ImportFunction_3_2_5(module, "pyndp_tx_burst_put", (void (**)(void))&__pyx_api_f_4shim_pyndp_tx_burst_put, "int (void *)") < 0) goto bad;
|
|
170
|
+
if (__Pyx_ImportFunction_3_2_5(module, "pyndp_tx_burst_flush", (void (**)(void))&__pyx_api_f_4shim_pyndp_tx_burst_flush, "int (void *)") < 0) goto bad;
|
|
171
|
+
if (__Pyx_ImportVoidPtr_3_2_5(module, "libnfb_ext_compatible_pattern", (void **)&__pyx_api_vp_4shim_libnfb_ext_compatible_pattern, "char const *") < 0) goto bad;
|
|
172
|
+
Py_DECREF(module); module = 0;
|
|
173
|
+
return 0;
|
|
174
|
+
bad:
|
|
175
|
+
Py_XDECREF(module);
|
|
176
|
+
return -1;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
#endif /* !__PYX_HAVE_API__shim */
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"setuptools>=40.1.0",
|
|
4
|
+
"Cython>=0.29.33",
|
|
5
|
+
]
|
|
6
|
+
build-backend = "setuptools.build_meta"
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "libnfb-ext-python"
|
|
10
|
+
version = "0.1.1"
|
|
11
|
+
description = "Python extension for libnfb — implement NFB device backends in Python"
|
|
12
|
+
readme = "readme.rst"
|
|
13
|
+
license = "BSD-3-Clause"
|
|
14
|
+
license-files = ["LICENSE"]
|
|
15
|
+
authors = [
|
|
16
|
+
{ name = "Martin Spinler", email = "spinler@cesnet.cz" },
|
|
17
|
+
]
|
|
18
|
+
requires-python = ">=3.8"
|
|
19
|
+
dependencies = [
|
|
20
|
+
"fdt",
|
|
21
|
+
"nfb",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 3 - Alpha",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Operating System :: POSIX :: Linux",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Cython",
|
|
29
|
+
"Topic :: System :: Hardware",
|
|
30
|
+
"Topic :: System :: Hardware :: Hardware Drivers",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/CESNET/ndk-sw"
|
|
35
|
+
Documentation = "https://cesnet.github.io/ndk-sw/"
|
|
36
|
+
Repository = "https://github.com/CESNET/ndk-sw"
|
|
37
|
+
"Bug Tracker" = "https://github.com/CESNET/ndk-sw/issues"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Installation
|
|
2
|
+
------------
|
|
3
|
+
|
|
4
|
+
libnfb_ext_python package requires nfb package for build.
|
|
5
|
+
The wanted nfb package is probably not available in ordinary way, so
|
|
6
|
+
local (venv) installation via pip can be done for example like this:
|
|
7
|
+
|
|
8
|
+
# current directory is root of this git repository
|
|
9
|
+
$ pip wheel -w ./localwhldir ./pynfb/
|
|
10
|
+
$ pip install --find-links ./localwhldir ./ext/libnfb_ext_python/
|
libnfb_ext_python-0.1.0/PKG-INFO
DELETED
{libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/libnfb_ext_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{libnfb_ext_python-0.1.0 → libnfb_ext_python-0.1.1}/libnfb_ext_python.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|