Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1456728 > unrolled thread
| Started by | Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> |
|---|---|
| First post | 2016-08-04 23:20 +0200 |
| Last post | 2016-08-04 23:20 +0200 |
| Articles | 3 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 0/2] Add ability to configure ethernet h/w shaper Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> - 2016-08-04 23:20 +0200
[PATCH 2/2] net: core: ethtool: add ringparam perqueue command Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> - 2016-08-04 23:20 +0200
Re: [PATCH 0/2] Add ability to configure ethernet h/w shaper Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> - 2016-08-04 23:20 +0200
| From | Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> |
|---|---|
| Date | 2016-08-04 23:20 +0200 |
| Subject | [PATCH 0/2] Add ability to configure ethernet h/w shaper |
| Message-ID | <s2ydz-6EW-5@gated-at.bofh.it> |
These two patches can be used to set per queue bandwidth with ethtool. I've create them as logical continuation of patchset from intel, that have introduced per-queue setting command month ago for ethtool interface (http://kernel.opensuse.org/cgit/kernel-source/commit/?h=rpm-4.4.9-36& id=feaab26abfffe381fb4c8c10d2762a753d481c6c). Actually I've not tested this interface and planning to send it in parallel with "net: ethernet: ti: cpsw: add multi-queue support" (https://lkml.org/lkml/2016/6/30/603), as it contains only changes to ethtool interface. First patch can be used to set per-channel bandwidth, second to tune number of per-channel descriptors. It can solve issues described by Schuyler. In case if per-channel bandwidth is equal to maximum for every channel, the driver could be switched to priority mode. Ivan Khoronzhuk (2): net: core: ethtool: add per queue bandwidth command net: core: ethtool: add ringparam perqueue command include/linux/ethtool.h | 8 ++ include/uapi/linux/ethtool.h | 2 + net/core/ethtool.c | 206 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 216 insertions(+) -- 1.9.1
[toc] | [next] | [standalone]
| From | Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> |
|---|---|
| Date | 2016-08-04 23:20 +0200 |
| Subject | [PATCH 2/2] net: core: ethtool: add ringparam perqueue command |
| Message-ID | <s2ydA-6EW-37@gated-at.bofh.it> |
| In reply to | #1456728 |
It useful feature to be able to configure number of buffers for
every queue.
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
include/linux/ethtool.h | 4 ++
net/core/ethtool.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 7e64c17..7109736 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -372,6 +372,10 @@ struct ethtool_ops {
struct ethtool_coalesce *);
int (*get_per_queue_bandwidth)(struct net_device *, u32, int *);
int (*set_per_queue_bandwidth)(struct net_device *, u32, int);
+ int (*get_per_queue_ringparam)(struct net_device *, u32,
+ struct ethtool_ringparam *);
+ int (*set_per_queue_ringparam)(struct net_device *, u32,
+ struct ethtool_ringparam *);
int (*get_link_ksettings)(struct net_device *,
struct ethtool_link_ksettings *);
int (*set_link_ksettings)(struct net_device *,
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index f31d539..42a7cb3 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -2347,6 +2347,104 @@ static int ethtool_get_per_queue_coalesce(struct net_device *dev,
}
static int
+ethtool_get_per_queue_ringparam(struct net_device *dev,
+ void __user *useraddr,
+ struct ethtool_per_queue_op *per_queue_opt)
+{
+ u32 bit;
+ int ret;
+ DECLARE_BITMAP(queue_mask, MAX_NUM_QUEUE);
+
+ if (!dev->ethtool_ops->get_per_queue_ringparam)
+ return -EOPNOTSUPP;
+
+ useraddr += sizeof(*per_queue_opt);
+
+ bitmap_from_u32array(queue_mask,
+ MAX_NUM_QUEUE,
+ per_queue_opt->queue_mask,
+ DIV_ROUND_UP(MAX_NUM_QUEUE, 32));
+
+ for_each_set_bit(bit, queue_mask, MAX_NUM_QUEUE) {
+ struct ethtool_ringparam
+ ringparam = { .cmd = ETHTOOL_GRINGPARAM };
+
+ ret = dev->ethtool_ops->get_per_queue_ringparam(dev, bit,
+ &ringparam);
+ if (ret != 0)
+ return ret;
+ if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
+ return -EFAULT;
+ useraddr += sizeof(ringparam);
+ }
+
+ return 0;
+}
+
+static int
+ethtool_set_per_queue_ringparam(struct net_device *dev,
+ void __user *useraddr,
+ struct ethtool_per_queue_op *per_queue_opt)
+{
+ struct ethtool_ringparam *backup = NULL, *tmp = NULL;
+ DECLARE_BITMAP(queue_mask, MAX_NUM_QUEUE);
+ int i, ret = 0;
+ int n_queue;
+ u32 bit;
+
+ if ((!dev->ethtool_ops->set_per_queue_ringparam) ||
+ (!dev->ethtool_ops->get_per_queue_ringparam))
+ return -EOPNOTSUPP;
+
+ useraddr += sizeof(*per_queue_opt);
+
+ bitmap_from_u32array(queue_mask,
+ MAX_NUM_QUEUE,
+ per_queue_opt->queue_mask,
+ DIV_ROUND_UP(MAX_NUM_QUEUE, 32));
+ n_queue = bitmap_weight(queue_mask, MAX_NUM_QUEUE);
+ tmp = kmalloc_array(n_queue, sizeof(*backup), GFP_KERNEL);
+ if (!tmp)
+ return -ENOMEM;
+ backup = tmp;
+
+ for_each_set_bit(bit, queue_mask, MAX_NUM_QUEUE) {
+ struct ethtool_ringparam
+ ringparam = { .cmd = ETHTOOL_SRINGPARAM };
+
+ ret = dev->ethtool_ops->get_per_queue_ringparam(dev, bit, tmp);
+ if (ret != 0)
+ goto roll_back;
+
+ tmp++;
+
+ if (copy_from_user(&ringparam, useraddr, sizeof(ringparam))) {
+ ret = -EFAULT;
+ goto roll_back;
+ }
+
+ ret = dev->ethtool_ops->set_per_queue_ringparam(dev, bit,
+ &ringparam);
+ if (ret != 0)
+ goto roll_back;
+
+ useraddr += sizeof(ringparam);
+ }
+
+roll_back:
+ if (ret != 0) {
+ tmp = backup;
+ for_each_set_bit(i, queue_mask, bit) {
+ dev->ethtool_ops->set_per_queue_ringparam(dev, i, tmp);
+ tmp++;
+ }
+ }
+ kfree(backup);
+
+ return ret;
+}
+
+static int
ethtool_get_per_queue_bandwidth(struct net_device *dev,
void __user *useraddr,
struct ethtool_per_queue_op *per_queue_opt)
@@ -2509,6 +2607,12 @@ static int ethtool_set_per_queue(struct net_device *dev, void __user *useraddr)
return -EFAULT;
switch (per_queue_opt.sub_command) {
+ case ETHTOOL_GRINGPARAM:
+ return ethtool_get_per_queue_ringparam(dev, useraddr,
+ &per_queue_opt);
+ case ETHTOOL_SRINGPARAM:
+ return ethtool_set_per_queue_ringparam(dev, useraddr,
+ &per_queue_opt);
case ETHTOOL_GCOALESCE:
return ethtool_get_per_queue_coalesce(dev, useraddr, &per_queue_opt);
case ETHTOOL_SCOALESCE:
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> |
|---|---|
| Date | 2016-08-04 23:20 +0200 |
| Message-ID | <s2ydA-6EW-43@gated-at.bofh.it> |
| In reply to | #1456728 |
Please, ignore it It was sent by mistake On 05.08.16 00:11, Ivan Khoronzhuk wrote: > These two patches can be used to set per queue bandwidth with ethtool. > I've create them as logical continuation of patchset from intel, > that have introduced per-queue setting command month ago for ethtool > interface > (http://kernel.opensuse.org/cgit/kernel-source/commit/?h=rpm-4.4.9-36& > id=feaab26abfffe381fb4c8c10d2762a753d481c6c). Actually I've not tested this > interface and planning to send it in parallel with > "net: ethernet: ti: cpsw: add multi-queue support" > (https://lkml.org/lkml/2016/6/30/603), as it contains only changes to > ethtool interface. > > First patch can be used to set per-channel bandwidth, second to tune > number of per-channel descriptors. It can solve issues described by > Schuyler. In case if per-channel bandwidth is equal to maximum > for every channel, the driver could be switched to priority mode. > > Ivan Khoronzhuk (2): > net: core: ethtool: add per queue bandwidth command > net: core: ethtool: add ringparam perqueue command > > include/linux/ethtool.h | 8 ++ > include/uapi/linux/ethtool.h | 2 + > net/core/ethtool.c | 206 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 216 insertions(+) > -- Regards, Ivan Khoronzhuk
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web