diff mbox series

net:hns3:add xps init support

Message ID 1546840985-114205-1-git-send-email-jinyuqi@huawei.com
State Deferred
Delegated to: David Miller
Headers show
Series net:hns3:add xps init support | expand

Commit Message

yuqi jin Jan. 7, 2019, 6:03 a.m. UTC
XPS settings based on CPU(s) map . we can use __netdev_pick_tx
to select the transmit queue,then we can improve performance

Cc: Yisen Zhuang <yisen.zhuang@huawei.com>
Cc: Salil Mehta <salil.mehta@huawei.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: yuqi jin <jinyuqi@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 30 +++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Comments

David Miller Jan. 7, 2019, 1:20 p.m. UTC | #1
From: yuqi jin <jinyuqi@huawei.com>
Date: Mon, 7 Jan 2019 14:03:05 +0800

> XPS settings based on CPU(s) map . we can use __netdev_pick_tx
> to select the transmit queue,then we can improve performance
> 
> Cc: Yisen Zhuang <yisen.zhuang@huawei.com>
> Cc: Salil Mehta <salil.mehta@huawei.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Signed-off-by: yuqi jin <jinyuqi@huawei.com>

Please resubmit this when the net-next tree opens back up.

Also, please fix your Subject lines.  Put spaces after the subsystem
prefixes.  Nobody else does this "x:y:z:" like you do, put proper
spaces there like "x: y: z: ".

Thank you.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index d3b9aaf..29e2225 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -377,6 +377,30 @@  static int hns3_nic_net_up(struct net_device *netdev)
 	return ret;
 }
 
+static int hns3_config_xps(struct hns3_nic_priv *priv)
+{
+	struct hnae3_handle *h = priv->ae_handle;
+	struct hnae3_knic_private_info *kinfo = &h->kinfo;
+	unsigned int queue_size = kinfo->rss_size * kinfo->num_tc;
+	struct hns3_enet_tqp_vector *tqp_vector;
+	struct hns3_nic_ring_data ring_data;
+	int ret = 0, i;
+
+	for (i = 0; i < queue_size; i++) {
+		ring_data = priv->ring_data[i];
+		tqp_vector = ring_data.ring->tqp_vector;
+		ret = netif_set_xps_queue(kinfo->netdev,
+					  &tqp_vector->affinity_mask,
+					  ring_data.queue_index);
+		if (ret) {
+			netdev_err(kinfo->netdev, "ret %d xps %d\n", ret,
+				   tqp_vector->idx);
+			return ret;
+		}
+	}
+	return ret;
+}
+
 static int hns3_nic_net_open(struct net_device *netdev)
 {
 	struct hns3_nic_priv *priv = netdev_priv(netdev);
@@ -409,6 +433,12 @@  static int hns3_nic_net_open(struct net_device *netdev)
 	if (h->ae_algo->ops->set_timer_task)
 		h->ae_algo->ops->set_timer_task(priv->ae_handle, true);
 
+	ret = hns3_config_xps(priv);
+	if (ret) {
+		netdev_err(netdev,
+			   "hns xps init fail, ret=%d!\n", ret);
+		return ret;
+	}
 	return 0;
 }