From e48469e3eef7982c6de6f0042cdeccb6f5466ef5 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 18 Jul 2008 14:45:56 -0300 Subject: ethtool: bindings for binding for ETHTOOL_[GS]RINGPARAM Signed-off-by: Arnaldo Carvalho de Melo --- python-ethtool/ethtool.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'python-ethtool') diff --git a/python-ethtool/ethtool.c b/python-ethtool/ethtool.c index ba8eaa3..cbc083d 100644 --- a/python-ethtool/ethtool.c +++ b/python-ethtool/ethtool.c @@ -667,6 +667,46 @@ static PyObject *set_coalesce(PyObject *self __unused, PyObject *args) return Py_None; } +struct struct_desc ethtool_ringparam_desc[] = { + member_desc(struct ethtool_ringparam, rx_max_pending), + member_desc(struct ethtool_ringparam, rx_mini_max_pending), + member_desc(struct ethtool_ringparam, rx_jumbo_max_pending), + member_desc(struct ethtool_ringparam, tx_max_pending), + member_desc(struct ethtool_ringparam, rx_pending), + member_desc(struct ethtool_ringparam, rx_mini_pending), + member_desc(struct ethtool_ringparam, rx_jumbo_pending), + member_desc(struct ethtool_ringparam, tx_pending), +}; + +static PyObject *get_ringparam(PyObject *self __unused, PyObject *args) +{ + struct ethtool_ringparam ring; + + if (get_dev_value(ETHTOOL_GRINGPARAM, args, &ring) < 0) + return NULL; + + return struct_desc_create_dict(ethtool_ringparam_desc, &ring); +} + +static PyObject *set_ringparam(PyObject *self __unused, PyObject *args) +{ + struct ethtool_ringparam ring; + char *devname; + PyObject *dict; + + if (!PyArg_ParseTuple(args, "sO", &devname, &dict)) + return NULL; + + if (struct_desc_from_dict(ethtool_ringparam_desc, &ring, dict) != 0) + return NULL; + + if (send_command(ETHTOOL_SRINGPARAM, devname, &ring)) + return NULL; + + Py_INCREF(Py_None); + return Py_None; +} + static struct PyMethodDef PyEthModuleMethods[] = { { .ml_name = "get_module", @@ -718,6 +758,16 @@ static struct PyMethodDef PyEthModuleMethods[] = { .ml_meth = (PyCFunction)get_active_devices, .ml_flags = METH_VARARGS, }, + { + .ml_name = "get_ringparam", + .ml_meth = (PyCFunction)get_ringparam, + .ml_flags = METH_VARARGS, + }, + { + .ml_name = "set_ringparam", + .ml_meth = (PyCFunction)set_ringparam, + .ml_flags = METH_VARARGS, + }, { .ml_name = "get_tso", .ml_meth = (PyCFunction)get_tso, -- cgit