All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 1/4] net: support per queue tx_usecs in sysfs
@ 2015-12-01  8:01 ` kan.liang
  0 siblings, 0 replies; 20+ messages in thread
From: kan.liang @ 2015-12-01  8:01 UTC (permalink / raw)
  To: netdev, intel-wired-lan, davem
  Cc: jesse.brandeburg, andi, jeffrey.t.kirsher, shannon.nelson,
	carolyn.wyborny, donald.c.skidmore, matthew.vick, john.ronciak,
	mitch.a.williams, john.r.fastabend, ogerlitz, edumazet, jiri,
	sfeldma, gospo, sasha.levin, f.fainelli, dsahern, tj, cascardo,
	corbet, Kan Liang

From: Kan Liang <kan.liang@intel.com>

Network devices usually have many queues. Each queue has its own
tx_usecs options. Currently, we can only set all the queues with same
value by ethtool. This patch expose the tx_usecs in sysfs. So the user
can set/get per queue coalesce parameter tx_usecs by sysfs.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 Documentation/networking/scaling.txt | 12 ++++++++++++
 include/linux/netdevice.h            |  8 ++++++++
 net/core/net-sysfs.c                 | 38 ++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+)

diff --git a/Documentation/networking/scaling.txt b/Documentation/networking/scaling.txt
index 59f4db2..636192d 100644
--- a/Documentation/networking/scaling.txt
+++ b/Documentation/networking/scaling.txt
@@ -431,6 +431,18 @@ a max-rate attribute is supported, by setting a Mbps value to
 
 A value of zero means disabled, and this is the default.
 
+Per Queue interrupt moderation:
+=============================
+
+The interrupt moderation mechanism, which implemented by HW, employs
+a series of timers to limit the number of interrupts it generates.
+TX queue absolute delay timer can be set to a microseconds value with
+
+/sys/class/net/<dev>/queues/tx-<n>/tx_usecs
+
+For the device which doesn't support per queue interrupt moderation,
+it shows "N/A".
+
 Further Information
 ===================
 RPS and RFS were introduced in kernel 2.6.35. XPS was incorporated into
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7d2d1d7..9db5c57 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1059,6 +1059,10 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
  *	This function is used to get egress tunnel information for given skb.
  *	This is useful for retrieving outer tunnel header parameters while
  *	sampling packet.
+ * void (*ndo_set_per_queue_tx_usecs)(struct net_device *dev,
+ * 				      int index, u32 val);
+ * void (*ndo_get_per_queue_tx_usecs)(struct net_device *dev, int index);
+ * 	This function is used to set/get per queue coalesce parameter tx_usecs.
  *
  */
 struct net_device_ops {
@@ -1236,6 +1240,10 @@ struct net_device_ops {
 							 bool proto_down);
 	int			(*ndo_fill_metadata_dst)(struct net_device *dev,
 						       struct sk_buff *skb);
+	void			(*ndo_set_per_queue_tx_usecs)(struct net_device *dev,
+							      int index, u32 val);
+	u32			(*ndo_get_per_queue_tx_usecs)(struct net_device *dev,
+							      int index);
 };
 
 /**
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index f88a62a..48016b8 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1239,12 +1239,50 @@ static struct netdev_queue_attribute xps_cpus_attribute =
     __ATTR(xps_cpus, S_IRUGO | S_IWUSR, show_xps_map, store_xps_map);
 #endif /* CONFIG_XPS */
 
+static ssize_t tx_usecs_show(struct netdev_queue *queue,
+			     struct netdev_queue_attribute *attr,
+			     char *buf)
+{
+	struct net_device *dev = queue->dev;
+	int index = queue - dev->_tx;
+	u32 val;
+
+	if (dev->netdev_ops->ndo_get_per_queue_tx_usecs) {
+		val = dev->netdev_ops->ndo_get_per_queue_tx_usecs(dev, index);
+		return sprintf(buf, "%u\n", val);
+	}
+
+	return sprintf(buf, "N/A\n");
+}
+
+static ssize_t tx_usecs_store(struct netdev_queue *queue,
+			      struct netdev_queue_attribute *attr,
+			      const char *buf, size_t len)
+{
+	struct net_device *dev = queue->dev;
+	int index = queue - dev->_tx;
+	u32 val, ret;
+
+	ret = kstrtouint(buf, 0, &val);
+	if (ret < 0)
+		return -EINVAL;
+
+	if (dev->netdev_ops->ndo_set_per_queue_tx_usecs)
+		dev->netdev_ops->ndo_set_per_queue_tx_usecs(dev, index, val);
+
+	return len;
+}
+
+static struct netdev_queue_attribute tx_usecs_attribute =
+    __ATTR(tx_usecs, S_IRUGO | S_IWUSR, tx_usecs_show, tx_usecs_store);
+
 static struct attribute *netdev_queue_default_attrs[] = {
 	&queue_trans_timeout.attr,
 #ifdef CONFIG_XPS
 	&xps_cpus_attribute.attr,
 	&queue_tx_maxrate.attr,
 #endif
+	&tx_usecs_attribute.attr,
 	NULL
 };
 
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [RFC 1/4] net: support per queue tx_usecs in sysfs
@ 2015-12-01  8:01 ` kan.liang
  0 siblings, 0 replies; 20+ messages in thread
From: kan.liang @ 2015-12-01  8:01 UTC (permalink / raw)
  To: intel-wired-lan

From: Kan Liang <kan.liang@intel.com>

Network devices usually have many queues. Each queue has its own
tx_usecs options. Currently, we can only set all the queues with same
value by ethtool. This patch expose the tx_usecs in sysfs. So the user
can set/get per queue coalesce parameter tx_usecs by sysfs.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 Documentation/networking/scaling.txt | 12 ++++++++++++
 include/linux/netdevice.h            |  8 ++++++++
 net/core/net-sysfs.c                 | 38 ++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+)

diff --git a/Documentation/networking/scaling.txt b/Documentation/networking/scaling.txt
index 59f4db2..636192d 100644
--- a/Documentation/networking/scaling.txt
+++ b/Documentation/networking/scaling.txt
@@ -431,6 +431,18 @@ a max-rate attribute is supported, by setting a Mbps value to
 
 A value of zero means disabled, and this is the default.
 
+Per Queue interrupt moderation:
+=============================
+
+The interrupt moderation mechanism, which implemented by HW, employs
+a series of timers to limit the number of interrupts it generates.
+TX queue absolute delay timer can be set to a microseconds value with
+
+/sys/class/net/<dev>/queues/tx-<n>/tx_usecs
+
+For the device which doesn't support per queue interrupt moderation,
+it shows "N/A".
+
 Further Information
 ===================
 RPS and RFS were introduced in kernel 2.6.35. XPS was incorporated into
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7d2d1d7..9db5c57 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1059,6 +1059,10 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
  *	This function is used to get egress tunnel information for given skb.
  *	This is useful for retrieving outer tunnel header parameters while
  *	sampling packet.
+ * void (*ndo_set_per_queue_tx_usecs)(struct net_device *dev,
+ * 				      int index, u32 val);
+ * void (*ndo_get_per_queue_tx_usecs)(struct net_device *dev, int index);
+ * 	This function is used to set/get per queue coalesce parameter tx_usecs.
  *
  */
 struct net_device_ops {
@@ -1236,6 +1240,10 @@ struct net_device_ops {
 							 bool proto_down);
 	int			(*ndo_fill_metadata_dst)(struct net_device *dev,
 						       struct sk_buff *skb);
+	void			(*ndo_set_per_queue_tx_usecs)(struct net_device *dev,
+							      int index, u32 val);
+	u32			(*ndo_get_per_queue_tx_usecs)(struct net_device *dev,
+							      int index);
 };
 
 /**
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index f88a62a..48016b8 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1239,12 +1239,50 @@ static struct netdev_queue_attribute xps_cpus_attribute =
     __ATTR(xps_cpus, S_IRUGO | S_IWUSR, show_xps_map, store_xps_map);
 #endif /* CONFIG_XPS */
 
+static ssize_t tx_usecs_show(struct netdev_queue *queue,
+			     struct netdev_queue_attribute *attr,
+			     char *buf)
+{
+	struct net_device *dev = queue->dev;
+	int index = queue - dev->_tx;
+	u32 val;
+
+	if (dev->netdev_ops->ndo_get_per_queue_tx_usecs) {
+		val = dev->netdev_ops->ndo_get_per_queue_tx_usecs(dev, index);
+		return sprintf(buf, "%u\n", val);
+	}
+
+	return sprintf(buf, "N/A\n");
+}
+
+static ssize_t tx_usecs_store(struct netdev_queue *queue,
+			      struct netdev_queue_attribute *attr,
+			      const char *buf, size_t len)
+{
+	struct net_device *dev = queue->dev;
+	int index = queue - dev->_tx;
+	u32 val, ret;
+
+	ret = kstrtouint(buf, 0, &val);
+	if (ret < 0)
+		return -EINVAL;
+
+	if (dev->netdev_ops->ndo_set_per_queue_tx_usecs)
+		dev->netdev_ops->ndo_set_per_queue_tx_usecs(dev, index, val);
+
+	return len;
+}
+
+static struct netdev_queue_attribute tx_usecs_attribute =
+    __ATTR(tx_usecs, S_IRUGO | S_IWUSR, tx_usecs_show, tx_usecs_store);
+
 static struct attribute *netdev_queue_default_attrs[] = {
 	&queue_trans_timeout.attr,
 #ifdef CONFIG_XPS
 	&xps_cpus_attribute.attr,
 	&queue_tx_maxrate.attr,
 #endif
+	&tx_usecs_attribute.attr,
 	NULL
 };
 
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC 2/4] i40e: handle per queue tx_usecs setting
  2015-12-01  8:01 ` [Intel-wired-lan] " kan.liang
@ 2015-12-01  8:01   ` kan.liang
  -1 siblings, 0 replies; 20+ messages in thread
From: kan.liang @ 2015-12-01  8:01 UTC (permalink / raw)
  To: netdev, intel-wired-lan, davem
  Cc: jesse.brandeburg, andi, jeffrey.t.kirsher, shannon.nelson,
	carolyn.wyborny, donald.c.skidmore, matthew.vick, john.ronciak,
	mitch.a.williams, john.r.fastabend, ogerlitz, edumazet, jiri,
	sfeldma, gospo, sasha.levin, f.fainelli, dsahern, tj, cascardo,
	corbet, Kan Liang

From: Kan Liang <kan.liang@intel.com>

Handle ndo_get_per_queue_tx_usecs and ndo_set_per_queue_tx_usecs
options for i40e driver specifically.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 39 +++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 4b7d874..d4310ae 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8673,6 +8673,43 @@ static int i40e_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 				       nlflags, 0, 0, filter_mask, NULL);
 }
 
+/**
+ * i40e_ndo_get_per_queue_tx_usecs - Get per queue coalesce parameter tx_usecs
+ * @dev: the netdev being configured
+ * @index: queue index
+ *
+ * Return tx_usecs for specific channel
+ **/
+u32 i40e_ndo_get_per_queue_tx_usecs(struct net_device *dev, int index)
+{
+	struct i40e_netdev_priv *np = netdev_priv(dev);
+	struct i40e_vsi *vsi = np->vsi;
+	struct i40e_pf *pf = vsi->back;
+	struct i40e_hw *hw = &pf->hw;
+	u32 val;
+
+	val = rd32(hw, I40E_PFINT_ITRN(1, index));
+
+	return (val * 2);
+}
+
+/**
+ * i40e_ndo_set_per_queue_tx_usecs - Set per queue coalesce parameter tx_usecs
+ * @dev: the netdev being configured
+ * @index: queue index
+ * @val: tx_usecs value
+ **/
+void i40e_ndo_set_per_queue_tx_usecs(struct net_device *dev, int index, u32 val)
+{
+	struct i40e_netdev_priv *np = netdev_priv(dev);
+	struct i40e_vsi *vsi = np->vsi;
+	struct i40e_pf *pf = vsi->back;
+	struct i40e_hw *hw = &pf->hw;
+
+	wr32(hw, I40E_PFINT_ITRN(1, index), val / 2);
+	i40e_flush(hw);
+}
+
 #define I40E_MAX_TUNNEL_HDR_LEN 80
 /**
  * i40e_features_check - Validate encapsulated packet conforms to limits
@@ -8729,6 +8766,8 @@ static const struct net_device_ops i40e_netdev_ops = {
 	.ndo_features_check	= i40e_features_check,
 	.ndo_bridge_getlink	= i40e_ndo_bridge_getlink,
 	.ndo_bridge_setlink	= i40e_ndo_bridge_setlink,
+	.ndo_get_per_queue_tx_usecs	= i40e_ndo_get_per_queue_tx_usecs,
+	.ndo_set_per_queue_tx_usecs	= i40e_ndo_set_per_queue_tx_usecs,
 };
 
 /**
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [RFC 2/4] i40e: handle per queue tx_usecs setting
@ 2015-12-01  8:01   ` kan.liang
  0 siblings, 0 replies; 20+ messages in thread
From: kan.liang @ 2015-12-01  8:01 UTC (permalink / raw)
  To: intel-wired-lan

From: Kan Liang <kan.liang@intel.com>

Handle ndo_get_per_queue_tx_usecs and ndo_set_per_queue_tx_usecs
options for i40e driver specifically.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 39 +++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 4b7d874..d4310ae 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8673,6 +8673,43 @@ static int i40e_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 				       nlflags, 0, 0, filter_mask, NULL);
 }
 
+/**
+ * i40e_ndo_get_per_queue_tx_usecs - Get per queue coalesce parameter tx_usecs
+ * @dev: the netdev being configured
+ * @index: queue index
+ *
+ * Return tx_usecs for specific channel
+ **/
+u32 i40e_ndo_get_per_queue_tx_usecs(struct net_device *dev, int index)
+{
+	struct i40e_netdev_priv *np = netdev_priv(dev);
+	struct i40e_vsi *vsi = np->vsi;
+	struct i40e_pf *pf = vsi->back;
+	struct i40e_hw *hw = &pf->hw;
+	u32 val;
+
+	val = rd32(hw, I40E_PFINT_ITRN(1, index));
+
+	return (val * 2);
+}
+
+/**
+ * i40e_ndo_set_per_queue_tx_usecs - Set per queue coalesce parameter tx_usecs
+ * @dev: the netdev being configured
+ * @index: queue index
+ * @val: tx_usecs value
+ **/
+void i40e_ndo_set_per_queue_tx_usecs(struct net_device *dev, int index, u32 val)
+{
+	struct i40e_netdev_priv *np = netdev_priv(dev);
+	struct i40e_vsi *vsi = np->vsi;
+	struct i40e_pf *pf = vsi->back;
+	struct i40e_hw *hw = &pf->hw;
+
+	wr32(hw, I40E_PFINT_ITRN(1, index), val / 2);
+	i40e_flush(hw);
+}
+
 #define I40E_MAX_TUNNEL_HDR_LEN 80
 /**
  * i40e_features_check - Validate encapsulated packet conforms to limits
@@ -8729,6 +8766,8 @@ static const struct net_device_ops i40e_netdev_ops = {
 	.ndo_features_check	= i40e_features_check,
 	.ndo_bridge_getlink	= i40e_ndo_bridge_getlink,
 	.ndo_bridge_setlink	= i40e_ndo_bridge_setlink,
+	.ndo_get_per_queue_tx_usecs	= i40e_ndo_get_per_queue_tx_usecs,
+	.ndo_set_per_queue_tx_usecs	= i40e_ndo_set_per_queue_tx_usecs,
 };
 
 /**
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC 3/4] net: support per queue rx_usecs in sysfs
  2015-12-01  8:01 ` [Intel-wired-lan] " kan.liang
@ 2015-12-01  8:01   ` kan.liang
  -1 siblings, 0 replies; 20+ messages in thread
From: kan.liang @ 2015-12-01  8:01 UTC (permalink / raw)
  To: netdev, intel-wired-lan, davem
  Cc: jesse.brandeburg, andi, jeffrey.t.kirsher, shannon.nelson,
	carolyn.wyborny, donald.c.skidmore, matthew.vick, john.ronciak,
	mitch.a.williams, john.r.fastabend, ogerlitz, edumazet, jiri,
	sfeldma, gospo, sasha.levin, f.fainelli, dsahern, tj, cascardo,
	corbet, Kan Liang

From: Kan Liang <kan.liang@intel.com>

Network devices usually have many queues. Each queue has its own
rx_usecs options. Currently, we can only set all the queues with same
value by ethtool. This patch expose the rx_usecs in sysfs. So the user
can set/get per queue coalesce parameter rx_usecs by sysfs.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 Documentation/networking/scaling.txt |  4 ++++
 include/linux/netdevice.h            |  8 ++++++++
 net/core/net-sysfs.c                 | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/Documentation/networking/scaling.txt b/Documentation/networking/scaling.txt
index 636192d..218429c 100644
--- a/Documentation/networking/scaling.txt
+++ b/Documentation/networking/scaling.txt
@@ -440,6 +440,10 @@ TX queue absolute delay timer can be set to a microseconds value with
 
 /sys/class/net/<dev>/queues/tx-<n>/tx_usecs
 
+RX queue absolute delay timer can be set to a microseconds value with
+
+/sys/class/net/<dev>/queues/rx-<n>/rx_usecs
+
 For the device which doesn't support per queue interrupt moderation,
 it shows "N/A".
 
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9db5c57..45a0054 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1063,6 +1063,10 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
  * 				      int index, u32 val);
  * void (*ndo_get_per_queue_tx_usecs)(struct net_device *dev, int index);
  * 	This function is used to set/get per queue coalesce parameter tx_usecs.
+ * void (*ndo_set_per_queue_rx_usecs)(struct net_device *dev,
+ * 				      int index, u32 val);
+ * void (*ndo_get_per_queue_rx_usecs)(struct net_device *dev, int index);
+ * 	This function is used to set/get per queue coalesce parameter rx_usecs.
  *
  */
 struct net_device_ops {
@@ -1244,6 +1248,10 @@ struct net_device_ops {
 							      int index, u32 val);
 	u32			(*ndo_get_per_queue_tx_usecs)(struct net_device *dev,
 							      int index);
+	void			(*ndo_set_per_queue_rx_usecs)(struct net_device *dev,
+							      int index, u32 val);
+	u32			(*ndo_get_per_queue_rx_usecs)(struct net_device *dev,
+							      int index);
 };
 
 /**
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 48016b8..ab08b2b 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -831,11 +831,47 @@ static struct rx_queue_attribute rps_dev_flow_table_cnt_attribute =
 	    show_rps_dev_flow_table_cnt, store_rps_dev_flow_table_cnt);
 #endif /* CONFIG_RPS */
 
+static ssize_t rx_usecs_show(struct netdev_rx_queue *queue,
+			     struct rx_queue_attribute *attribute, char *buf)
+{
+	struct net_device *dev = queue->dev;
+	int index = queue - dev->_rx;
+	u32 val;
+
+	if (dev->netdev_ops->ndo_get_per_queue_rx_usecs) {
+		val = dev->netdev_ops->ndo_get_per_queue_rx_usecs(dev, index);
+		return sprintf(buf, "%u\n", val);
+	}
+	return sprintf(buf, "N/A\n");
+}
+
+static ssize_t rx_usecs_store(struct netdev_rx_queue *queue,
+			      struct rx_queue_attribute *attribute,
+			      const char *buf, size_t len)
+{
+	struct net_device *dev = queue->dev;
+	int index = queue - dev->_rx;
+	u32 val, ret;
+
+	ret = kstrtouint(buf, 0, &val);
+	if (ret < 0)
+		return -EINVAL;
+
+	if (dev->netdev_ops->ndo_set_per_queue_rx_usecs)
+		dev->netdev_ops->ndo_set_per_queue_rx_usecs(dev, index, val);
+
+	return len;
+}
+
+static struct rx_queue_attribute rx_usecs_attribute =
+	__ATTR(rx_usecs, S_IRUGO | S_IWUSR, rx_usecs_show, rx_usecs_store);
+
 static struct attribute *rx_queue_default_attrs[] = {
 #ifdef CONFIG_RPS
 	&rps_cpus_attribute.attr,
 	&rps_dev_flow_table_cnt_attribute.attr,
 #endif
+	&rx_usecs_attribute.attr,
 	NULL
 };
 
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [RFC 3/4] net: support per queue rx_usecs in sysfs
@ 2015-12-01  8:01   ` kan.liang
  0 siblings, 0 replies; 20+ messages in thread
From: kan.liang @ 2015-12-01  8:01 UTC (permalink / raw)
  To: intel-wired-lan

From: Kan Liang <kan.liang@intel.com>

Network devices usually have many queues. Each queue has its own
rx_usecs options. Currently, we can only set all the queues with same
value by ethtool. This patch expose the rx_usecs in sysfs. So the user
can set/get per queue coalesce parameter rx_usecs by sysfs.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 Documentation/networking/scaling.txt |  4 ++++
 include/linux/netdevice.h            |  8 ++++++++
 net/core/net-sysfs.c                 | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/Documentation/networking/scaling.txt b/Documentation/networking/scaling.txt
index 636192d..218429c 100644
--- a/Documentation/networking/scaling.txt
+++ b/Documentation/networking/scaling.txt
@@ -440,6 +440,10 @@ TX queue absolute delay timer can be set to a microseconds value with
 
 /sys/class/net/<dev>/queues/tx-<n>/tx_usecs
 
+RX queue absolute delay timer can be set to a microseconds value with
+
+/sys/class/net/<dev>/queues/rx-<n>/rx_usecs
+
 For the device which doesn't support per queue interrupt moderation,
 it shows "N/A".
 
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9db5c57..45a0054 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1063,6 +1063,10 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
  * 				      int index, u32 val);
  * void (*ndo_get_per_queue_tx_usecs)(struct net_device *dev, int index);
  * 	This function is used to set/get per queue coalesce parameter tx_usecs.
+ * void (*ndo_set_per_queue_rx_usecs)(struct net_device *dev,
+ * 				      int index, u32 val);
+ * void (*ndo_get_per_queue_rx_usecs)(struct net_device *dev, int index);
+ * 	This function is used to set/get per queue coalesce parameter rx_usecs.
  *
  */
 struct net_device_ops {
@@ -1244,6 +1248,10 @@ struct net_device_ops {
 							      int index, u32 val);
 	u32			(*ndo_get_per_queue_tx_usecs)(struct net_device *dev,
 							      int index);
+	void			(*ndo_set_per_queue_rx_usecs)(struct net_device *dev,
+							      int index, u32 val);
+	u32			(*ndo_get_per_queue_rx_usecs)(struct net_device *dev,
+							      int index);
 };
 
 /**
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 48016b8..ab08b2b 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -831,11 +831,47 @@ static struct rx_queue_attribute rps_dev_flow_table_cnt_attribute =
 	    show_rps_dev_flow_table_cnt, store_rps_dev_flow_table_cnt);
 #endif /* CONFIG_RPS */
 
+static ssize_t rx_usecs_show(struct netdev_rx_queue *queue,
+			     struct rx_queue_attribute *attribute, char *buf)
+{
+	struct net_device *dev = queue->dev;
+	int index = queue - dev->_rx;
+	u32 val;
+
+	if (dev->netdev_ops->ndo_get_per_queue_rx_usecs) {
+		val = dev->netdev_ops->ndo_get_per_queue_rx_usecs(dev, index);
+		return sprintf(buf, "%u\n", val);
+	}
+	return sprintf(buf, "N/A\n");
+}
+
+static ssize_t rx_usecs_store(struct netdev_rx_queue *queue,
+			      struct rx_queue_attribute *attribute,
+			      const char *buf, size_t len)
+{
+	struct net_device *dev = queue->dev;
+	int index = queue - dev->_rx;
+	u32 val, ret;
+
+	ret = kstrtouint(buf, 0, &val);
+	if (ret < 0)
+		return -EINVAL;
+
+	if (dev->netdev_ops->ndo_set_per_queue_rx_usecs)
+		dev->netdev_ops->ndo_set_per_queue_rx_usecs(dev, index, val);
+
+	return len;
+}
+
+static struct rx_queue_attribute rx_usecs_attribute =
+	__ATTR(rx_usecs, S_IRUGO | S_IWUSR, rx_usecs_show, rx_usecs_store);
+
 static struct attribute *rx_queue_default_attrs[] = {
 #ifdef CONFIG_RPS
 	&rps_cpus_attribute.attr,
 	&rps_dev_flow_table_cnt_attribute.attr,
 #endif
+	&rx_usecs_attribute.attr,
 	NULL
 };
 
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC 4/4] i40e: handle per queue rx_usecs setting
  2015-12-01  8:01 ` [Intel-wired-lan] " kan.liang
@ 2015-12-01  8:01   ` kan.liang
  -1 siblings, 0 replies; 20+ messages in thread
From: kan.liang @ 2015-12-01  8:01 UTC (permalink / raw)
  To: netdev, intel-wired-lan, davem
  Cc: jesse.brandeburg, andi, jeffrey.t.kirsher, shannon.nelson,
	carolyn.wyborny, donald.c.skidmore, matthew.vick, john.ronciak,
	mitch.a.williams, john.r.fastabend, ogerlitz, edumazet, jiri,
	sfeldma, gospo, sasha.levin, f.fainelli, dsahern, tj, cascardo,
	corbet, Kan Liang

From: Kan Liang <kan.liang@intel.com>

Handle ndo_get_per_queue_rx_usecs and ndo_set_per_queue_rx_usecs
options for i40e driver specifically.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 39 +++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index d4310ae..c0291bb 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8710,6 +8710,43 @@ void i40e_ndo_set_per_queue_tx_usecs(struct net_device *dev, int index, u32 val)
 	i40e_flush(hw);
 }
 
+/**
+ * i40e_ndo_get_per_queue_rx_usecs - Get per queue coalesce parameter rx_usecs
+ * @dev: the netdev being configured
+ * @index: queue index
+ *
+ * Return rx_usecs for specific queue
+ **/
+u32 i40e_ndo_get_per_queue_rx_usecs(struct net_device *dev, int index)
+{
+	struct i40e_netdev_priv *np = netdev_priv(dev);
+	struct i40e_vsi *vsi = np->vsi;
+	struct i40e_pf *pf = vsi->back;
+	struct i40e_hw *hw = &pf->hw;
+	u32 val;
+
+	val = rd32(hw, I40E_PFINT_ITRN(0, index));
+
+	return (val * 2);
+}
+
+/**
+ * i40e_ndo_set_per_queue_rx_usecs - Set per queue coalesce parameter rx_usecs
+ * @dev: the netdev being configured
+ * @index: queue index
+ * @val: rx_usecs value
+ **/
+void i40e_ndo_set_per_queue_rx_usecs(struct net_device *dev, int index, u32 val)
+{
+	struct i40e_netdev_priv *np = netdev_priv(dev);
+	struct i40e_vsi *vsi = np->vsi;
+	struct i40e_pf *pf = vsi->back;
+	struct i40e_hw *hw = &pf->hw;
+
+	wr32(hw, I40E_PFINT_ITRN(0, index), val / 2);
+	i40e_flush(hw);
+}
+
 #define I40E_MAX_TUNNEL_HDR_LEN 80
 /**
  * i40e_features_check - Validate encapsulated packet conforms to limits
@@ -8768,6 +8805,8 @@ static const struct net_device_ops i40e_netdev_ops = {
 	.ndo_bridge_setlink	= i40e_ndo_bridge_setlink,
 	.ndo_get_per_queue_tx_usecs	= i40e_ndo_get_per_queue_tx_usecs,
 	.ndo_set_per_queue_tx_usecs	= i40e_ndo_set_per_queue_tx_usecs,
+	.ndo_get_per_queue_rx_usecs	= i40e_ndo_get_per_queue_rx_usecs,
+	.ndo_set_per_queue_rx_usecs	= i40e_ndo_set_per_queue_rx_usecs,
 };
 
 /**
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [RFC 4/4] i40e: handle per queue rx_usecs setting
@ 2015-12-01  8:01   ` kan.liang
  0 siblings, 0 replies; 20+ messages in thread
From: kan.liang @ 2015-12-01  8:01 UTC (permalink / raw)
  To: intel-wired-lan

From: Kan Liang <kan.liang@intel.com>

Handle ndo_get_per_queue_rx_usecs and ndo_set_per_queue_rx_usecs
options for i40e driver specifically.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 39 +++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index d4310ae..c0291bb 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -8710,6 +8710,43 @@ void i40e_ndo_set_per_queue_tx_usecs(struct net_device *dev, int index, u32 val)
 	i40e_flush(hw);
 }
 
+/**
+ * i40e_ndo_get_per_queue_rx_usecs - Get per queue coalesce parameter rx_usecs
+ * @dev: the netdev being configured
+ * @index: queue index
+ *
+ * Return rx_usecs for specific queue
+ **/
+u32 i40e_ndo_get_per_queue_rx_usecs(struct net_device *dev, int index)
+{
+	struct i40e_netdev_priv *np = netdev_priv(dev);
+	struct i40e_vsi *vsi = np->vsi;
+	struct i40e_pf *pf = vsi->back;
+	struct i40e_hw *hw = &pf->hw;
+	u32 val;
+
+	val = rd32(hw, I40E_PFINT_ITRN(0, index));
+
+	return (val * 2);
+}
+
+/**
+ * i40e_ndo_set_per_queue_rx_usecs - Set per queue coalesce parameter rx_usecs
+ * @dev: the netdev being configured
+ * @index: queue index
+ * @val: rx_usecs value
+ **/
+void i40e_ndo_set_per_queue_rx_usecs(struct net_device *dev, int index, u32 val)
+{
+	struct i40e_netdev_priv *np = netdev_priv(dev);
+	struct i40e_vsi *vsi = np->vsi;
+	struct i40e_pf *pf = vsi->back;
+	struct i40e_hw *hw = &pf->hw;
+
+	wr32(hw, I40E_PFINT_ITRN(0, index), val / 2);
+	i40e_flush(hw);
+}
+
 #define I40E_MAX_TUNNEL_HDR_LEN 80
 /**
  * i40e_features_check - Validate encapsulated packet conforms to limits
@@ -8768,6 +8805,8 @@ static const struct net_device_ops i40e_netdev_ops = {
 	.ndo_bridge_setlink	= i40e_ndo_bridge_setlink,
 	.ndo_get_per_queue_tx_usecs	= i40e_ndo_get_per_queue_tx_usecs,
 	.ndo_set_per_queue_tx_usecs	= i40e_ndo_set_per_queue_tx_usecs,
+	.ndo_get_per_queue_rx_usecs	= i40e_ndo_get_per_queue_rx_usecs,
+	.ndo_set_per_queue_rx_usecs	= i40e_ndo_set_per_queue_rx_usecs,
 };
 
 /**
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [RFC 4/4] i40e: handle per queue rx_usecs setting
  2015-12-01  8:01   ` [Intel-wired-lan] " kan.liang
@ 2015-12-01 19:47     ` Stephen Hemminger
  -1 siblings, 0 replies; 20+ messages in thread
From: Stephen Hemminger @ 2015-12-01 19:47 UTC (permalink / raw)
  To: kan.liang
  Cc: netdev, intel-wired-lan, davem, jesse.brandeburg, andi,
	jeffrey.t.kirsher, shannon.nelson, carolyn.wyborny,
	donald.c.skidmore, matthew.vick, john.ronciak, mitch.a.williams,
	john.r.fastabend, ogerlitz, edumazet, jiri, sfeldma, gospo,
	sasha.levin, f.fainelli, dsahern, tj, cascardo, corbet

On Tue,  1 Dec 2015 08:01:32 +0000
kan.liang@intel.com wrote:

> +u32 i40e_ndo_get_per_queue_rx_usecs(struct net_device *dev, int index)
> +{
> +	struct i40e_netdev_priv *np = netdev_priv(dev);
> +	struct i40e_vsi *vsi = np->vsi;
> +	struct i40e_pf *pf = vsi->back;
> +	struct i40e_hw *hw = &pf->hw;
> +	u32 val;
> +
> +	val = rd32(hw, I40E_PFINT_ITRN(0, index));
> +
> +	return (val * 2);

Please don't put useless paren's around return value.
That is a BSD style that is not practiced in Linux.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [RFC 4/4] i40e: handle per queue rx_usecs setting
@ 2015-12-01 19:47     ` Stephen Hemminger
  0 siblings, 0 replies; 20+ messages in thread
From: Stephen Hemminger @ 2015-12-01 19:47 UTC (permalink / raw)
  To: intel-wired-lan

On Tue,  1 Dec 2015 08:01:32 +0000
kan.liang at intel.com wrote:

> +u32 i40e_ndo_get_per_queue_rx_usecs(struct net_device *dev, int index)
> +{
> +	struct i40e_netdev_priv *np = netdev_priv(dev);
> +	struct i40e_vsi *vsi = np->vsi;
> +	struct i40e_pf *pf = vsi->back;
> +	struct i40e_hw *hw = &pf->hw;
> +	u32 val;
> +
> +	val = rd32(hw, I40E_PFINT_ITRN(0, index));
> +
> +	return (val * 2);

Please don't put useless paren's around return value.
That is a BSD style that is not practiced in Linux.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC 1/4] net: support per queue tx_usecs in sysfs
  2015-12-01  8:01 ` [Intel-wired-lan] " kan.liang
@ 2015-12-01 22:13   ` Florian Fainelli
  -1 siblings, 0 replies; 20+ messages in thread
From: Florian Fainelli @ 2015-12-01 22:13 UTC (permalink / raw)
  To: kan.liang, netdev, intel-wired-lan, davem
  Cc: jesse.brandeburg, andi, jeffrey.t.kirsher, shannon.nelson,
	carolyn.wyborny, donald.c.skidmore, matthew.vick, john.ronciak,
	mitch.a.williams, john.r.fastabend, ogerlitz, edumazet, jiri,
	sfeldma, gospo, sasha.levin, dsahern, tj, cascardo, corbet

On 01/12/15 00:01, kan.liang@intel.com wrote:
> From: Kan Liang <kan.liang@intel.com>
> 
> Network devices usually have many queues. Each queue has its own
> tx_usecs options. Currently, we can only set all the queues with same
> value by ethtool. This patch expose the tx_usecs in sysfs. So the user
> can set/get per queue coalesce parameter tx_usecs by sysfs.

The new interface you propose makes things inconsistent, since we have
two separate configuration paths (sysfs and ethtool), and it would seem
better to have per-queue awareness in ethtool, since there is a whole
bunch of other parameters that could be configured on a per-queue basis.

Have you tried to extend existing ethtool interfaces to cover the need
for multiple queues?

> 
> Signed-off-by: Kan Liang <kan.liang@intel.com>
> ---
>  Documentation/networking/scaling.txt | 12 ++++++++++++
>  include/linux/netdevice.h            |  8 ++++++++
>  net/core/net-sysfs.c                 | 38 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 58 insertions(+)
> 
> diff --git a/Documentation/networking/scaling.txt b/Documentation/networking/scaling.txt
> index 59f4db2..636192d 100644
> --- a/Documentation/networking/scaling.txt
> +++ b/Documentation/networking/scaling.txt
> @@ -431,6 +431,18 @@ a max-rate attribute is supported, by setting a Mbps value to
>  
>  A value of zero means disabled, and this is the default.
>  
> +Per Queue interrupt moderation:
> +=============================
> +
> +The interrupt moderation mechanism, which implemented by HW, employs
> +a series of timers to limit the number of interrupts it generates.
> +TX queue absolute delay timer can be set to a microseconds value with
> +
> +/sys/class/net/<dev>/queues/tx-<n>/tx_usecs
> +
> +For the device which doesn't support per queue interrupt moderation,
> +it shows "N/A".
> +
>  Further Information
>  ===================
>  RPS and RFS were introduced in kernel 2.6.35. XPS was incorporated into
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 7d2d1d7..9db5c57 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -1059,6 +1059,10 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
>   *	This function is used to get egress tunnel information for given skb.
>   *	This is useful for retrieving outer tunnel header parameters while
>   *	sampling packet.
> + * void (*ndo_set_per_queue_tx_usecs)(struct net_device *dev,
> + * 				      int index, u32 val);
> + * void (*ndo_get_per_queue_tx_usecs)(struct net_device *dev, int index);
> + * 	This function is used to set/get per queue coalesce parameter tx_usecs.
>   *
>   */
>  struct net_device_ops {
> @@ -1236,6 +1240,10 @@ struct net_device_ops {
>  							 bool proto_down);
>  	int			(*ndo_fill_metadata_dst)(struct net_device *dev,
>  						       struct sk_buff *skb);
> +	void			(*ndo_set_per_queue_tx_usecs)(struct net_device *dev,
> +							      int index, u32 val);
> +	u32			(*ndo_get_per_queue_tx_usecs)(struct net_device *dev,
> +							      int index);
>  };
>  
>  /**
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index f88a62a..48016b8 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -1239,12 +1239,50 @@ static struct netdev_queue_attribute xps_cpus_attribute =
>      __ATTR(xps_cpus, S_IRUGO | S_IWUSR, show_xps_map, store_xps_map);
>  #endif /* CONFIG_XPS */
>  
> +static ssize_t tx_usecs_show(struct netdev_queue *queue,
> +			     struct netdev_queue_attribute *attr,
> +			     char *buf)
> +{
> +	struct net_device *dev = queue->dev;
> +	int index = queue - dev->_tx;
> +	u32 val;
> +
> +	if (dev->netdev_ops->ndo_get_per_queue_tx_usecs) {
> +		val = dev->netdev_ops->ndo_get_per_queue_tx_usecs(dev, index);
> +		return sprintf(buf, "%u\n", val);
> +	}
> +
> +	return sprintf(buf, "N/A\n");
> +}
> +
> +static ssize_t tx_usecs_store(struct netdev_queue *queue,
> +			      struct netdev_queue_attribute *attr,
> +			      const char *buf, size_t len)
> +{
> +	struct net_device *dev = queue->dev;
> +	int index = queue - dev->_tx;
> +	u32 val, ret;
> +
> +	ret = kstrtouint(buf, 0, &val);
> +	if (ret < 0)
> +		return -EINVAL;
> +
> +	if (dev->netdev_ops->ndo_set_per_queue_tx_usecs)
> +		dev->netdev_ops->ndo_set_per_queue_tx_usecs(dev, index, val);
> +
> +	return len;
> +}
> +
> +static struct netdev_queue_attribute tx_usecs_attribute =
> +    __ATTR(tx_usecs, S_IRUGO | S_IWUSR, tx_usecs_show, tx_usecs_store);
> +
>  static struct attribute *netdev_queue_default_attrs[] = {
>  	&queue_trans_timeout.attr,
>  #ifdef CONFIG_XPS
>  	&xps_cpus_attribute.attr,
>  	&queue_tx_maxrate.attr,
>  #endif
> +	&tx_usecs_attribute.attr,
>  	NULL
>  };
>  
> 


-- 
Florian

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [RFC 1/4] net: support per queue tx_usecs in sysfs
@ 2015-12-01 22:13   ` Florian Fainelli
  0 siblings, 0 replies; 20+ messages in thread
From: Florian Fainelli @ 2015-12-01 22:13 UTC (permalink / raw)
  To: intel-wired-lan

On 01/12/15 00:01, kan.liang at intel.com wrote:
> From: Kan Liang <kan.liang@intel.com>
> 
> Network devices usually have many queues. Each queue has its own
> tx_usecs options. Currently, we can only set all the queues with same
> value by ethtool. This patch expose the tx_usecs in sysfs. So the user
> can set/get per queue coalesce parameter tx_usecs by sysfs.

The new interface you propose makes things inconsistent, since we have
two separate configuration paths (sysfs and ethtool), and it would seem
better to have per-queue awareness in ethtool, since there is a whole
bunch of other parameters that could be configured on a per-queue basis.

Have you tried to extend existing ethtool interfaces to cover the need
for multiple queues?

> 
> Signed-off-by: Kan Liang <kan.liang@intel.com>
> ---
>  Documentation/networking/scaling.txt | 12 ++++++++++++
>  include/linux/netdevice.h            |  8 ++++++++
>  net/core/net-sysfs.c                 | 38 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 58 insertions(+)
> 
> diff --git a/Documentation/networking/scaling.txt b/Documentation/networking/scaling.txt
> index 59f4db2..636192d 100644
> --- a/Documentation/networking/scaling.txt
> +++ b/Documentation/networking/scaling.txt
> @@ -431,6 +431,18 @@ a max-rate attribute is supported, by setting a Mbps value to
>  
>  A value of zero means disabled, and this is the default.
>  
> +Per Queue interrupt moderation:
> +=============================
> +
> +The interrupt moderation mechanism, which implemented by HW, employs
> +a series of timers to limit the number of interrupts it generates.
> +TX queue absolute delay timer can be set to a microseconds value with
> +
> +/sys/class/net/<dev>/queues/tx-<n>/tx_usecs
> +
> +For the device which doesn't support per queue interrupt moderation,
> +it shows "N/A".
> +
>  Further Information
>  ===================
>  RPS and RFS were introduced in kernel 2.6.35. XPS was incorporated into
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 7d2d1d7..9db5c57 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -1059,6 +1059,10 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
>   *	This function is used to get egress tunnel information for given skb.
>   *	This is useful for retrieving outer tunnel header parameters while
>   *	sampling packet.
> + * void (*ndo_set_per_queue_tx_usecs)(struct net_device *dev,
> + * 				      int index, u32 val);
> + * void (*ndo_get_per_queue_tx_usecs)(struct net_device *dev, int index);
> + * 	This function is used to set/get per queue coalesce parameter tx_usecs.
>   *
>   */
>  struct net_device_ops {
> @@ -1236,6 +1240,10 @@ struct net_device_ops {
>  							 bool proto_down);
>  	int			(*ndo_fill_metadata_dst)(struct net_device *dev,
>  						       struct sk_buff *skb);
> +	void			(*ndo_set_per_queue_tx_usecs)(struct net_device *dev,
> +							      int index, u32 val);
> +	u32			(*ndo_get_per_queue_tx_usecs)(struct net_device *dev,
> +							      int index);
>  };
>  
>  /**
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index f88a62a..48016b8 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -1239,12 +1239,50 @@ static struct netdev_queue_attribute xps_cpus_attribute =
>      __ATTR(xps_cpus, S_IRUGO | S_IWUSR, show_xps_map, store_xps_map);
>  #endif /* CONFIG_XPS */
>  
> +static ssize_t tx_usecs_show(struct netdev_queue *queue,
> +			     struct netdev_queue_attribute *attr,
> +			     char *buf)
> +{
> +	struct net_device *dev = queue->dev;
> +	int index = queue - dev->_tx;
> +	u32 val;
> +
> +	if (dev->netdev_ops->ndo_get_per_queue_tx_usecs) {
> +		val = dev->netdev_ops->ndo_get_per_queue_tx_usecs(dev, index);
> +		return sprintf(buf, "%u\n", val);
> +	}
> +
> +	return sprintf(buf, "N/A\n");
> +}
> +
> +static ssize_t tx_usecs_store(struct netdev_queue *queue,
> +			      struct netdev_queue_attribute *attr,
> +			      const char *buf, size_t len)
> +{
> +	struct net_device *dev = queue->dev;
> +	int index = queue - dev->_tx;
> +	u32 val, ret;
> +
> +	ret = kstrtouint(buf, 0, &val);
> +	if (ret < 0)
> +		return -EINVAL;
> +
> +	if (dev->netdev_ops->ndo_set_per_queue_tx_usecs)
> +		dev->netdev_ops->ndo_set_per_queue_tx_usecs(dev, index, val);
> +
> +	return len;
> +}
> +
> +static struct netdev_queue_attribute tx_usecs_attribute =
> +    __ATTR(tx_usecs, S_IRUGO | S_IWUSR, tx_usecs_show, tx_usecs_store);
> +
>  static struct attribute *netdev_queue_default_attrs[] = {
>  	&queue_trans_timeout.attr,
>  #ifdef CONFIG_XPS
>  	&xps_cpus_attribute.attr,
>  	&queue_tx_maxrate.attr,
>  #endif
> +	&tx_usecs_attribute.attr,
>  	NULL
>  };
>  
> 


-- 
Florian

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC 1/4] net: support per queue tx_usecs in sysfs
  2015-12-01 22:13   ` [Intel-wired-lan] " Florian Fainelli
@ 2015-12-01 23:44     ` Jesse Brandeburg
  -1 siblings, 0 replies; 20+ messages in thread
From: Jesse Brandeburg @ 2015-12-01 23:44 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: kan.liang, netdev, intel-wired-lan, davem, andi,
	jeffrey.t.kirsher, shannon.nelson, carolyn.wyborny,
	donald.c.skidmore, matthew.vick, john.ronciak, mitch.a.williams,
	john.r.fastabend, ogerlitz, edumazet, jiri, sfeldma, gospo,
	sasha.levin, dsahern, tj, cascardo, corbet

On Tue, 1 Dec 2015 14:13:34 -0800
Florian Fainelli <f.fainelli@gmail.com> wrote:

> On 01/12/15 00:01, kan.liang@intel.com wrote:
> > From: Kan Liang <kan.liang@intel.com>
> > 
> > Network devices usually have many queues. Each queue has its own
> > tx_usecs options. Currently, we can only set all the queues with same
> > value by ethtool. This patch expose the tx_usecs in sysfs. So the user
> > can set/get per queue coalesce parameter tx_usecs by sysfs.
> 
> The new interface you propose makes things inconsistent, since we have
> two separate configuration paths (sysfs and ethtool), and it would seem
> better to have per-queue awareness in ethtool, since there is a whole
> bunch of other parameters that could be configured on a per-queue basis.
> 
> Have you tried to extend existing ethtool interfaces to cover the need
> for multiple queues?

While I agree that ethtool provides a similar functionality, ethtool
was designed (particularly the ethtool -C/c commands) around one queue
NICs.  We can't change the output or functionality of the user
interface without breaking a bunch of user's scripts and stuff.

With this effort, Kan is laying groundwork for making further kernel
changes, and having the kernel call back in to drivers via ethtool
mechanisms that were designed before multiple queue adapters.

We can also next migrate the legacy ethtool interfaces to use these
new .ndo_ops should we wish.

These patches were provided with the intent of getting some feedback
about going down this path of making a *consistent* user interface that
is driver agnostic in sysfs, and supports multiple queue adapters.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [RFC 1/4] net: support per queue tx_usecs in sysfs
@ 2015-12-01 23:44     ` Jesse Brandeburg
  0 siblings, 0 replies; 20+ messages in thread
From: Jesse Brandeburg @ 2015-12-01 23:44 UTC (permalink / raw)
  To: intel-wired-lan

On Tue, 1 Dec 2015 14:13:34 -0800
Florian Fainelli <f.fainelli@gmail.com> wrote:

> On 01/12/15 00:01, kan.liang at intel.com wrote:
> > From: Kan Liang <kan.liang@intel.com>
> > 
> > Network devices usually have many queues. Each queue has its own
> > tx_usecs options. Currently, we can only set all the queues with same
> > value by ethtool. This patch expose the tx_usecs in sysfs. So the user
> > can set/get per queue coalesce parameter tx_usecs by sysfs.
> 
> The new interface you propose makes things inconsistent, since we have
> two separate configuration paths (sysfs and ethtool), and it would seem
> better to have per-queue awareness in ethtool, since there is a whole
> bunch of other parameters that could be configured on a per-queue basis.
> 
> Have you tried to extend existing ethtool interfaces to cover the need
> for multiple queues?

While I agree that ethtool provides a similar functionality, ethtool
was designed (particularly the ethtool -C/c commands) around one queue
NICs.  We can't change the output or functionality of the user
interface without breaking a bunch of user's scripts and stuff.

With this effort, Kan is laying groundwork for making further kernel
changes, and having the kernel call back in to drivers via ethtool
mechanisms that were designed before multiple queue adapters.

We can also next migrate the legacy ethtool interfaces to use these
new .ndo_ops should we wish.

These patches were provided with the intent of getting some feedback
about going down this path of making a *consistent* user interface that
is driver agnostic in sysfs, and supports multiple queue adapters.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC 1/4] net: support per queue tx_usecs in sysfs
  2015-12-01 23:44     ` [Intel-wired-lan] " Jesse Brandeburg
@ 2015-12-02  1:57       ` Alexander Duyck
  -1 siblings, 0 replies; 20+ messages in thread
From: Alexander Duyck @ 2015-12-02  1:57 UTC (permalink / raw)
  To: Jesse Brandeburg
  Cc: Florian Fainelli, kan.liang, Netdev, intel-wired-lan,
	David Miller, Andi Kleen, Jeff Kirsher, Nelson, Shannon,
	Carolyn Wyborny, Skidmore, Donald C, Vick, Matthew, Ronciak,
	John, Mitch Williams, John Fastabend, Or Gerlitz, Eric Dumazet,
	Jiri Pirko, Scott Feldman, andy gospodarek, sasha.levin,
	David Ahern, tj, cascardo, corbet

On Tue, Dec 1, 2015 at 3:44 PM, Jesse Brandeburg
<jesse.brandeburg@intel.com> wrote:
> On Tue, 1 Dec 2015 14:13:34 -0800
> Florian Fainelli <f.fainelli@gmail.com> wrote:
>
>> On 01/12/15 00:01, kan.liang@intel.com wrote:
>> > From: Kan Liang <kan.liang@intel.com>
>> >
>> > Network devices usually have many queues. Each queue has its own
>> > tx_usecs options. Currently, we can only set all the queues with same
>> > value by ethtool. This patch expose the tx_usecs in sysfs. So the user
>> > can set/get per queue coalesce parameter tx_usecs by sysfs.
>>
>> The new interface you propose makes things inconsistent, since we have
>> two separate configuration paths (sysfs and ethtool), and it would seem
>> better to have per-queue awareness in ethtool, since there is a whole
>> bunch of other parameters that could be configured on a per-queue basis.
>>
>> Have you tried to extend existing ethtool interfaces to cover the need
>> for multiple queues?
>
> While I agree that ethtool provides a similar functionality, ethtool
> was designed (particularly the ethtool -C/c commands) around one queue
> NICs.  We can't change the output or functionality of the user
> interface without breaking a bunch of user's scripts and stuff.

Actually it seems like it should be fairly easy to extend the existing
interface.  If for example you were to add a couple new keywords such
as rx-queue or tx-queue what you could do is make it so that you would
then specifically overwrite or access the values of a given Tx queue
or Rx queue instead of doing it generically for the entire device.

> With this effort, Kan is laying groundwork for making further kernel
> changes, and having the kernel call back in to drivers via ethtool
> mechanisms that were designed before multiple queue adapters.
>
> We can also next migrate the legacy ethtool interfaces to use these
> new .ndo_ops should we wish.

Maybe that is the path this should start taking now.  Another thing to
keep in mind is that not all drivers make use of the rx-usecs value
the way the Intel drivers do.  As such we need to be able to still
support all the various interrupt moderation types that are supported
by any NICs that might make use of this feature.

> These patches were provided with the intent of getting some feedback
> about going down this path of making a *consistent* user interface that
> is driver agnostic in sysfs, and supports multiple queue adapters.

If you are truly going for something that is driver agnostic you need
to start looking at other drivers.  For example I don't see how this
current implementation deals with the tx/rx_frames values provided in
the mlx4 drivers for their interrupt moderation.  Also it seems like
the assumption here is that you are going to want to run all of the
queues statically without allowing dynamic interrupt moderation.  I
would think that this might be something that could be managed per
queue as well.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [RFC 1/4] net: support per queue tx_usecs in sysfs
@ 2015-12-02  1:57       ` Alexander Duyck
  0 siblings, 0 replies; 20+ messages in thread
From: Alexander Duyck @ 2015-12-02  1:57 UTC (permalink / raw)
  To: intel-wired-lan

On Tue, Dec 1, 2015 at 3:44 PM, Jesse Brandeburg
<jesse.brandeburg@intel.com> wrote:
> On Tue, 1 Dec 2015 14:13:34 -0800
> Florian Fainelli <f.fainelli@gmail.com> wrote:
>
>> On 01/12/15 00:01, kan.liang at intel.com wrote:
>> > From: Kan Liang <kan.liang@intel.com>
>> >
>> > Network devices usually have many queues. Each queue has its own
>> > tx_usecs options. Currently, we can only set all the queues with same
>> > value by ethtool. This patch expose the tx_usecs in sysfs. So the user
>> > can set/get per queue coalesce parameter tx_usecs by sysfs.
>>
>> The new interface you propose makes things inconsistent, since we have
>> two separate configuration paths (sysfs and ethtool), and it would seem
>> better to have per-queue awareness in ethtool, since there is a whole
>> bunch of other parameters that could be configured on a per-queue basis.
>>
>> Have you tried to extend existing ethtool interfaces to cover the need
>> for multiple queues?
>
> While I agree that ethtool provides a similar functionality, ethtool
> was designed (particularly the ethtool -C/c commands) around one queue
> NICs.  We can't change the output or functionality of the user
> interface without breaking a bunch of user's scripts and stuff.

Actually it seems like it should be fairly easy to extend the existing
interface.  If for example you were to add a couple new keywords such
as rx-queue or tx-queue what you could do is make it so that you would
then specifically overwrite or access the values of a given Tx queue
or Rx queue instead of doing it generically for the entire device.

> With this effort, Kan is laying groundwork for making further kernel
> changes, and having the kernel call back in to drivers via ethtool
> mechanisms that were designed before multiple queue adapters.
>
> We can also next migrate the legacy ethtool interfaces to use these
> new .ndo_ops should we wish.

Maybe that is the path this should start taking now.  Another thing to
keep in mind is that not all drivers make use of the rx-usecs value
the way the Intel drivers do.  As such we need to be able to still
support all the various interrupt moderation types that are supported
by any NICs that might make use of this feature.

> These patches were provided with the intent of getting some feedback
> about going down this path of making a *consistent* user interface that
> is driver agnostic in sysfs, and supports multiple queue adapters.

If you are truly going for something that is driver agnostic you need
to start looking at other drivers.  For example I don't see how this
current implementation deals with the tx/rx_frames values provided in
the mlx4 drivers for their interrupt moderation.  Also it seems like
the assumption here is that you are going to want to run all of the
queues statically without allowing dynamic interrupt moderation.  I
would think that this might be something that could be managed per
queue as well.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC 1/4] net: support per queue tx_usecs in sysfs
  2015-12-01 22:13   ` [Intel-wired-lan] " Florian Fainelli
@ 2015-12-02  2:23     ` David Miller
  -1 siblings, 0 replies; 20+ messages in thread
From: David Miller @ 2015-12-02  2:23 UTC (permalink / raw)
  To: f.fainelli
  Cc: kan.liang, netdev, intel-wired-lan, jesse.brandeburg, andi,
	jeffrey.t.kirsher, shannon.nelson, carolyn.wyborny,
	donald.c.skidmore, matthew.vick, john.ronciak, mitch.a.williams,
	john.r.fastabend, ogerlitz, edumazet, jiri, sfeldma, gospo,
	sasha.levin, dsahern, tj, cascardo, corbet

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 01 Dec 2015 14:13:34 -0800

> The new interface you propose makes things inconsistent, since we have
> two separate configuration paths (sysfs and ethtool), and it would seem
> better to have per-queue awareness in ethtool, since there is a whole
> bunch of other parameters that could be configured on a per-queue basis.

Agreed, we have to extend ethtool to support this, in order to provide
a consistent interface.

We could even do this by encapsulating one ethtool command within
another, the outer ethtool command says "apply the inner op to
queue(s) N".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [RFC 1/4] net: support per queue tx_usecs in sysfs
@ 2015-12-02  2:23     ` David Miller
  0 siblings, 0 replies; 20+ messages in thread
From: David Miller @ 2015-12-02  2:23 UTC (permalink / raw)
  To: intel-wired-lan

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 01 Dec 2015 14:13:34 -0800

> The new interface you propose makes things inconsistent, since we have
> two separate configuration paths (sysfs and ethtool), and it would seem
> better to have per-queue awareness in ethtool, since there is a whole
> bunch of other parameters that could be configured on a per-queue basis.

Agreed, we have to extend ethtool to support this, in order to provide
a consistent interface.

We could even do this by encapsulating one ethtool command within
another, the outer ethtool command says "apply the inner op to
queue(s) N".

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC 1/4] net: support per queue tx_usecs in sysfs
  2015-12-01 23:44     ` [Intel-wired-lan] " Jesse Brandeburg
@ 2015-12-02  2:27       ` David Miller
  -1 siblings, 0 replies; 20+ messages in thread
From: David Miller @ 2015-12-02  2:27 UTC (permalink / raw)
  To: jesse.brandeburg
  Cc: f.fainelli, kan.liang, netdev, intel-wired-lan, andi,
	jeffrey.t.kirsher, shannon.nelson, carolyn.wyborny,
	donald.c.skidmore, matthew.vick, john.ronciak, mitch.a.williams,
	john.r.fastabend, ogerlitz, edumazet, jiri, sfeldma, gospo,
	sasha.levin, dsahern, tj, cascardo, corbet

From: Jesse Brandeburg <jesse.brandeburg@intel.com>
Date: Tue, 1 Dec 2015 15:44:54 -0800

> While I agree that ethtool provides a similar functionality, ethtool
> was designed (particularly the ethtool -C/c commands) around one queue
> NICs.  We can't change the output or functionality of the user
> interface without breaking a bunch of user's scripts and stuff.

See my suggestion, we can encapsulate existing ethtool commands inside
of a new command that specifies operations that are to be applied to
specific queues.

Do not use sysfs for this.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Intel-wired-lan] [RFC 1/4] net: support per queue tx_usecs in sysfs
@ 2015-12-02  2:27       ` David Miller
  0 siblings, 0 replies; 20+ messages in thread
From: David Miller @ 2015-12-02  2:27 UTC (permalink / raw)
  To: intel-wired-lan

From: Jesse Brandeburg <jesse.brandeburg@intel.com>
Date: Tue, 1 Dec 2015 15:44:54 -0800

> While I agree that ethtool provides a similar functionality, ethtool
> was designed (particularly the ethtool -C/c commands) around one queue
> NICs.  We can't change the output or functionality of the user
> interface without breaking a bunch of user's scripts and stuff.

See my suggestion, we can encapsulate existing ethtool commands inside
of a new command that specifies operations that are to be applied to
specific queues.

Do not use sysfs for this.

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-12-02  2:27 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01  8:01 [RFC 1/4] net: support per queue tx_usecs in sysfs kan.liang
2015-12-01  8:01 ` [Intel-wired-lan] " kan.liang
2015-12-01  8:01 ` [RFC 2/4] i40e: handle per queue tx_usecs setting kan.liang
2015-12-01  8:01   ` [Intel-wired-lan] " kan.liang
2015-12-01  8:01 ` [RFC 3/4] net: support per queue rx_usecs in sysfs kan.liang
2015-12-01  8:01   ` [Intel-wired-lan] " kan.liang
2015-12-01  8:01 ` [RFC 4/4] i40e: handle per queue rx_usecs setting kan.liang
2015-12-01  8:01   ` [Intel-wired-lan] " kan.liang
2015-12-01 19:47   ` Stephen Hemminger
2015-12-01 19:47     ` [Intel-wired-lan] " Stephen Hemminger
2015-12-01 22:13 ` [RFC 1/4] net: support per queue tx_usecs in sysfs Florian Fainelli
2015-12-01 22:13   ` [Intel-wired-lan] " Florian Fainelli
2015-12-01 23:44   ` Jesse Brandeburg
2015-12-01 23:44     ` [Intel-wired-lan] " Jesse Brandeburg
2015-12-02  1:57     ` Alexander Duyck
2015-12-02  1:57       ` [Intel-wired-lan] " Alexander Duyck
2015-12-02  2:27     ` David Miller
2015-12-02  2:27       ` [Intel-wired-lan] " David Miller
2015-12-02  2:23   ` David Miller
2015-12-02  2:23     ` [Intel-wired-lan] " David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.