Skip to content

Commit

Permalink
pynfb / libnfb_ext_python: move cdefs to ext and remove nfb dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
martinspinler committed Oct 24, 2024
1 parent fe7141a commit cd91cb0
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 68 deletions.
82 changes: 81 additions & 1 deletion ext/libnfb_ext_python/libnfb_ext_python/libnfb_ext_python.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,91 @@ from cpython.ref cimport PyObject, Py_INCREF, Py_DECREF
from libc.stdio cimport printf
cimport libc.errno

from nfb.libnfb cimport *

cdef extern from "<libfdt.h>":
int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)

cdef extern from "<nfb/ndp.h>":
cdef struct nfb_device:
pass

cdef struct nfb_comp:
pass

cdef struct ndp_packet:
unsigned char *data
unsigned char *header
unsigned data_length
unsigned header_length
uint16_t flags

cdef struct ndp_queue:
pass

cdef extern from "<nfb/ext.h>":
ctypedef ssize_t nfb_bus_read_func(void *p, void *buf, size_t nbyte, off_t offset)
ctypedef ssize_t nfb_bus_write_func(void *p, const void *buf, size_t nbyte, off_t offset)

ctypedef int libnfb_ext_ops_open(const char *devname, int oflag, void **priv, void **fdt)
ctypedef void libnfb_ext_ops_close(void *priv)
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)
ctypedef void libnfb_ext_ops_bus_close_mi(void *bus_priv)
ctypedef int libnfb_ext_ops_comp_lock(const nfb_comp *comp, uint32_t features)
ctypedef void libnfb_ext_ops_comp_unlock(const nfb_comp *comp, uint32_t features)

ctypedef int libnfb_ext_ops_ndp_queue_open(nfb_device *dev, void *dev_priv, unsigned index, int dir, int flags, ndp_queue ** pq)
ctypedef int libnfb_ext_ops_ndp_queue_close(ndp_queue *q)

ctypedef unsigned ndp_rx_burst_get_t(void *priv, ndp_packet *packets, unsigned count)
ctypedef int ndp_rx_burst_put_t(void *priv)

ctypedef unsigned ndp_tx_burst_get_t(void *priv, ndp_packet *packets, unsigned count)
ctypedef int ndp_tx_burst_put_t(void *priv)
ctypedef int ndp_tx_burst_flush_t(void *priv)

struct libnfb_ext_ops:
libnfb_ext_ops_open open
libnfb_ext_ops_close close
libnfb_ext_ops_bus_open_mi bus_open_mi
libnfb_ext_ops_bus_close_mi bus_close_mi
libnfb_ext_ops_comp_lock comp_lock
libnfb_ext_ops_comp_unlock comp_unlock

libnfb_ext_ops_ndp_queue_open ndp_queue_open
libnfb_ext_ops_ndp_queue_close ndp_queue_close

cdef struct libnfb_bus_ext_ops:
nfb_bus_read_func *read
nfb_bus_write_func *write

ctypedef struct ndp_queue_ops_burst_tx:
ndp_tx_burst_get_t get
ndp_tx_burst_put_t put
ndp_tx_burst_flush_t flush
ctypedef struct ndp_queue_ops_burst_rx:
ndp_rx_burst_get_t get
ndp_rx_burst_put_t put

ctypedef union ndp_queue_ops_burst:
ndp_queue_ops_burst_rx rx
ndp_queue_ops_burst_tx tx

ctypedef struct ndp_queue_ops_control:
int (*start)(void *priv)
int (*stop)(void *priv)

cdef struct ndp_queue_ops:
ndp_queue_ops_burst burst
ndp_queue_ops_control control

cdef ndp_queue * ndp_queue_create(nfb_device *dev, int numa, int type, int index)
cdef void ndp_queue_destroy(ndp_queue* q)

cdef void* ndp_queue_get_priv(ndp_queue *q)
cdef void ndp_queue_set_priv(ndp_queue *q, void *priv)

cdef ndp_queue_ops* ndp_queue_get_ops(ndp_queue *q)


cdef api const char *nfb_pynfb_prefix

Expand Down
1 change: 0 additions & 1 deletion ext/libnfb_ext_python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
requires = [
"setuptools>=40.1.0",
"Cython>=0.29.33",
"nfb",
]
build-backend = "setuptools.build_meta"
1 change: 0 additions & 1 deletion ext/libnfb_ext_python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
setuptools>=40.1.0
Cython>=0.29.33
nfb
2 changes: 1 addition & 1 deletion ext/libnfb_ext_python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
),
py_modules=["libnfb_ext_python"],
packages=find_namespace_packages(include=["nfb.*"]),
install_requires=['nfb'],
install_requires=['fdt'],
)
64 changes: 0 additions & 64 deletions pynfb/nfb/libnfb.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -68,70 +68,6 @@ cdef extern from "<nfb/ndp.h>":
int ndp_queue_start(ndp_queue *queue)
int ndp_queue_stop(ndp_queue *queue)

cdef extern from "<nfb/ext.h>":
ctypedef ssize_t nfb_bus_read_func(void *p, void *buf, size_t nbyte, off_t offset)
ctypedef ssize_t nfb_bus_write_func(void *p, const void *buf, size_t nbyte, off_t offset)

ctypedef int libnfb_ext_ops_open(const char *devname, int oflag, void **priv, void **fdt)
ctypedef void libnfb_ext_ops_close(void *priv)
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)
ctypedef void libnfb_ext_ops_bus_close_mi(void *bus_priv)
ctypedef int libnfb_ext_ops_comp_lock(const nfb_comp *comp, uint32_t features)
ctypedef void libnfb_ext_ops_comp_unlock(const nfb_comp *comp, uint32_t features)

ctypedef int libnfb_ext_ops_ndp_queue_open(nfb_device *dev, void *dev_priv, unsigned index, int dir, int flags, ndp_queue ** pq)
ctypedef int libnfb_ext_ops_ndp_queue_close(ndp_queue *q)

ctypedef unsigned ndp_rx_burst_get_t(void *priv, ndp_packet *packets, unsigned count)
ctypedef int ndp_rx_burst_put_t(void *priv)

ctypedef unsigned ndp_tx_burst_get_t(void *priv, ndp_packet *packets, unsigned count)
ctypedef int ndp_tx_burst_put_t(void *priv)
ctypedef int ndp_tx_burst_flush_t(void *priv)

struct libnfb_ext_ops:
libnfb_ext_ops_open open
libnfb_ext_ops_close close
libnfb_ext_ops_bus_open_mi bus_open_mi
libnfb_ext_ops_bus_close_mi bus_close_mi
libnfb_ext_ops_comp_lock comp_lock
libnfb_ext_ops_comp_unlock comp_unlock

libnfb_ext_ops_ndp_queue_open ndp_queue_open
libnfb_ext_ops_ndp_queue_close ndp_queue_close

cdef struct libnfb_bus_ext_ops:
nfb_bus_read_func *read
nfb_bus_write_func *write

ctypedef struct ndp_queue_ops_burst_tx:
ndp_tx_burst_get_t get
ndp_tx_burst_put_t put
ndp_tx_burst_flush_t flush
ctypedef struct ndp_queue_ops_burst_rx:
ndp_rx_burst_get_t get
ndp_rx_burst_put_t put

ctypedef union ndp_queue_ops_burst:
ndp_queue_ops_burst_rx rx
ndp_queue_ops_burst_tx tx

ctypedef struct ndp_queue_ops_control:
int (*start)(void *priv)
int (*stop)(void *priv)

cdef struct ndp_queue_ops:
ndp_queue_ops_burst burst
ndp_queue_ops_control control

cdef ndp_queue * ndp_queue_create(nfb_device *dev, int numa, int type, int index)
cdef void ndp_queue_destroy(ndp_queue* q)

cdef void* ndp_queue_get_priv(ndp_queue *q)
cdef void ndp_queue_set_priv(ndp_queue *q, void *priv)

cdef ndp_queue_ops* ndp_queue_get_ops(ndp_queue *q)


cdef class NfbDeviceHandle:
#cdef object __weakref__
Expand Down

0 comments on commit cd91cb0

Please sign in to comment.