Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/714694/?format=api
{ "id": 714694, "url": "http://patchwork.ozlabs.org/api/patches/714694/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1484260510-9162-7-git-send-email-sridhar.samudrala@intel.com/", "project": { "id": 46, "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api", "name": "Intel Wired Ethernet development", "link_name": "intel-wired-lan", "list_id": "intel-wired-lan.osuosl.org", "list_email": "intel-wired-lan@osuosl.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1484260510-9162-7-git-send-email-sridhar.samudrala@intel.com>", "list_archive_url": null, "date": "2017-01-12T22:35:09", "name": "[next-queue,v4,6/7] i40e: Add support for exposing VF port statistics via VFPR netdev on the host.", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "7e730cd3f1fcdf958f21ba9d6b1e8f0b58b53271", "submitter": { "id": 65219, "url": "http://patchwork.ozlabs.org/api/people/65219/?format=api", "name": "Samudrala, Sridhar", "email": "sridhar.samudrala@intel.com" }, "delegate": { "id": 68, "url": "http://patchwork.ozlabs.org/api/users/68/?format=api", "username": "jtkirshe", "first_name": "Jeff", "last_name": "Kirsher", "email": "jeffrey.t.kirsher@intel.com" }, "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1484260510-9162-7-git-send-email-sridhar.samudrala@intel.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/714694/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/714694/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@lists.osuosl.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Received": [ "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3v00vw6YXzz9t15\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 13 Jan 2017 09:35:40 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 20D9B2DC8B;\n\tThu, 12 Jan 2017 22:35:39 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id jQY-IMk4l8-a; Thu, 12 Jan 2017 22:35:33 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 92EC9308D7;\n\tThu, 12 Jan 2017 22:35:28 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 4BE501C001E\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Jan 2017 22:35:21 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 44E7C2DC8B\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Jan 2017 22:35:21 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id Qb1DPe7KJbrE for <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Jan 2017 22:35:17 +0000 (UTC)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby silver.osuosl.org (Postfix) with ESMTPS id F19BD2DEF9\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Jan 2017 22:35:16 +0000 (UTC)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga101.fm.intel.com with ESMTP; 12 Jan 2017 14:35:16 -0800", "from sri-mi-02.jf.intel.com ([10.166.188.51])\n\tby FMSMGA003.fm.intel.com with ESMTP; 12 Jan 2017 14:35:16 -0800" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.33,220,1477983600\"; d=\"scan'208\";a=\"808217583\"", "From": "Sridhar Samudrala <sridhar.samudrala@intel.com>", "To": "alexander.h.duyck@intel.com, john.r.fastabend@intel.com,\n\tanjali.singhai@intel.com, jakub.kicinski@netronome.com,\n\tdavem@davemloft.net, scott.d.peterson@intel.com, gerlitz.or@gmail.com,\n\tjiri@resnulli.us, intel-wired-lan@lists.osuosl.org,\n\tnetdev@vger.kernel.org", "Date": "Thu, 12 Jan 2017 14:35:09 -0800", "Message-Id": "<1484260510-9162-7-git-send-email-sridhar.samudrala@intel.com>", "X-Mailer": "git-send-email 2.5.5", "In-Reply-To": "<1484260510-9162-1-git-send-email-sridhar.samudrala@intel.com>", "References": "<1484260510-9162-1-git-send-email-sridhar.samudrala@intel.com>", "Subject": "[Intel-wired-lan] [next-queue v4 PATCH 6/7] i40e: Add support for\n\texposing VF port statistics via VFPR netdev on the host.", "X-BeenThere": "intel-wired-lan@lists.osuosl.org", "X-Mailman-Version": "2.1.18-1", "Precedence": "list", "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.lists.osuosl.org>", "List-Unsubscribe": "<http://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@lists.osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@lists.osuosl.org?subject=help>", "List-Subscribe": "<http://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "intel-wired-lan-bounces@lists.osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@lists.osuosl.org>" }, "content": "From: Sridhar Samudrala <sridhar.samudrala@intel.com>\n\nBy default stats counted by HW are returned via the original ndo_get_stats64()\napi. Stats counted in SW are returned via ndo_get_offload_stats() api.\n\nSmall script to demonstrate vfpr stats in switchdev mode.\nPF: enp5s0f0, VFs: enp5s2,enp5s2f1 VFPRs:enp5s0f0-vf0, enp5s0f0-vf1\n\n# rmmod i40e; modprobe i40e\n# devlink dev eswitch set pci/0000:05:00.0 mode switchdev\n# echo 2 > /sys/class/net/enp5s0f0/device/sriov_numvfs\n# ip link set enp5s0f0 vf 0 mac 00:11:22:33:44:55\n# ip link set enp5s0f0 vf 1 mac 00:11:22:33:44:56\n# rmmod i40evf; modprobe i40evf\n\n/* Create 2 namespaces and move the VFs to the corresponding ns */\n# ip netns add ns0\n# ip link set enp5s2 netns ns0\n# ip netns exec ns0 ip addr add 192.168.1.10/24 dev enp5s2\n# ip netns exec ns0 ip link set enp5s2 up\n# ip netns add ns1\n# ip link set enp5s2f1 netns ns1\n# ip netns exec ns1 ip addr add 192.168.1.11/24 dev enp5s2f1\n# ip netns exec ns1 ip link set enp5s2f1 up\n\n/* bring up pf and vfpr netdevs */\n# ip link set enp5s0f0 up\n# ip link set enp5s0f0-vf0 up\n# ip link set enp5s0f0-vf1 up\n\n/* Create a linux bridge and add vfpr netdevs to it. */\n# ip link add vfpr-br type bridge\n# ip link set enp5s0f0-vf0 master vfpr-br\n# ip link set enp5s0f0-vf1 master vfpr-br\n# ip addr add 192.168.1.1/24 dev vfpr-br\n# ip link set vfpr-br up\n\n# ip netns exec ns0 ping -c3 192.168.1.11\n# ip netns exec ns1 ping -c3 192.168.1.10\n\n# ip netns exec ns0 ip -s l show enp5s2\n56: enp5s2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\n link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff\n RX: bytes packets errors dropped overrun mcast\n 1468 18 0 0 0 0\n TX: bytes packets errors dropped carrier collsns\n 1398 17 0 0 0 0\n# ip -s l show enp5s0f0-vf0\n52: enp5s0f0-vf0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master vfpr-br state UP mode DEFAULT group default qlen 1000\n link/ether 68:05:ca:2e:72:68 brd ff:ff:ff:ff:ff:ff\n RX: bytes packets errors dropped overrun mcast\n 1398 17 0 0 0 0\n TX: bytes packets errors dropped carrier collsns\n 1468 18 0 0 0 0\n# ip netns exec ns1 ip -s l show enp5s2f1\n57: enp5s2f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000\n link/ether 00:11:22:33:44:56 brd ff:ff:ff:ff:ff:ff\n RX: bytes packets errors dropped overrun mcast\n 1486 18 0 0 0 0\n TX: bytes packets errors dropped carrier collsns\n 1538 19 0 0 0 0\n# ip -s l show enp5s0f0-vf1\n53: enp5s0f0-vf1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master vfpr-br state UP mode DEFAULT group default qlen 1000\n link/ether 68:05:ca:2e:72:68 brd ff:ff:ff:ff:ff:ff\n RX: bytes packets errors dropped overrun mcast\n 1538 19 0 0 0 0\n TX: bytes packets errors dropped carrier collsns\n 1486 18 0 0 0 0\n\nSigned-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>\n---\n drivers/net/ethernet/intel/i40e/i40e_txrx.c | 44 ++++++++-\n drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 108 +++++++++++++++++++++\n drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h | 10 ++\n 3 files changed, 160 insertions(+), 2 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c\nindex f43d1df..d1583ee 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c\n@@ -1279,6 +1279,32 @@ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring,\n }\n \n /**\n+ * i40e_vfpr_receive_skb\n+ * @vf: pointer to VF\n+ * @skb: packet to send up\n+ *\n+ * Update skb dev to vfpr netdev and rx stats.\n+ **/\n+static void i40e_vfpr_receive_skb(struct i40e_vf *vf, struct sk_buff *skb)\n+{\n+\tstruct i40e_vfpr_netdev_priv *priv;\n+\tstruct vfpr_pcpu_stats *vfpr_stats;\n+\n+\tif (!vf->vfpr_netdev)\n+\t\treturn;\n+\n+\tskb->dev = vf->vfpr_netdev;\n+\n+\tpriv = netdev_priv(vf->vfpr_netdev);\n+\tvfpr_stats = this_cpu_ptr(priv->vfpr_stats);\n+\n+\tu64_stats_update_begin(&vfpr_stats->syncp);\n+\tvfpr_stats->rx_packets++;\n+\tvfpr_stats->rx_bytes += skb->len;\n+\tu64_stats_update_end(&vfpr_stats->syncp);\n+}\n+\n+/**\n * i40e_receive_skb - Send a completed packet up the stack\n * @rx_ring: rx ring in play\n * @skb: packet to send up\n@@ -1310,7 +1336,7 @@ static void i40e_receive_skb(struct i40e_ring *rx_ring,\n \t\tvf = &pf->vf[vf_id];\n \t\tif (ether_addr_equal(eth->h_source,\n \t\t\t\t vf->default_lan_addr.addr)) {\n-\t\t\tskb->dev = vf->vfpr_netdev;\n+\t\t\ti40e_vfpr_receive_skb(vf, skb);\n \t\t\tbreak;\n \t\t}\n \t}\n@@ -3428,11 +3454,25 @@ netdev_tx_t i40e_vfpr_netdev_start_xmit(struct sk_buff *skb,\n \tstruct i40e_vf *vf = priv->vf;\n \tstruct i40e_pf *pf = vf->pf;\n \tstruct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];\n+\tint ret;\n \n \tskb_dst_drop(skb);\n \tdst_hold(&priv->vfpr_dst->dst);\n \tskb_dst_set(skb, &priv->vfpr_dst->dst);\n \tskb->dev = vsi->netdev;\n \n-\treturn dev_queue_xmit(skb);\n+\tret = dev_queue_xmit(skb);\n+\tif (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {\n+\t\tstruct vfpr_pcpu_stats *vfpr_stats;\n+\n+\t\tvfpr_stats = this_cpu_ptr(priv->vfpr_stats);\n+\t\tu64_stats_update_begin(&vfpr_stats->syncp);\n+\t\tvfpr_stats->tx_packets++;\n+\t\tvfpr_stats->tx_bytes += skb->len;\n+\t\tu64_stats_update_end(&vfpr_stats->syncp);\n+\t} else {\n+\t\tthis_cpu_inc(priv->vfpr_stats->tx_drops);\n+\t}\n+\n+\treturn ret;\n }\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\nindex 7211fba..1af8472 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n@@ -1057,10 +1057,110 @@ static int i40e_vfpr_netdev_stop(struct net_device *dev)\n \treturn 0;\n }\n \n+/**\n+ * i40e_vfpr_netdev_get_stats64\n+ * @dev: network interface device structure\n+ * @stats: netlink stats structure\n+ *\n+ * Fills the hw statistics from the VSI corresponding to the associated VFPR\n+ **/\n+void\n+i40e_vfpr_netdev_get_stats64(struct net_device *netdev,\n+\t\t\t struct rtnl_link_stats64 *stats)\n+{\n+\tstruct i40e_vfpr_netdev_priv *priv = netdev_priv(netdev);\n+\tstruct i40e_vf *vf = priv->vf;\n+\tstruct i40e_pf *pf = vf->pf;\n+\tstruct i40e_vsi *vsi;\n+\tstruct i40e_eth_stats *estats;\n+\n+\tvsi = pf->vsi[vf->lan_vsi_idx];\n+\ti40e_update_stats(vsi);\n+\n+\testats = &vsi->eth_stats;\n+\n+\t/* TX and RX stats are flipped as we are returning the stats as seen\n+\t * at the switch port corresponding to the VF.\n+\t */\n+\tstats->rx_packets = estats->tx_unicast + estats->tx_multicast +\n+\t\t\t estats->tx_broadcast;\n+\tstats->tx_packets = estats->rx_unicast + estats->rx_multicast +\n+\t\t\t estats->rx_broadcast;\n+\tstats->rx_bytes = estats->tx_bytes;\n+\tstats->tx_bytes = estats->rx_bytes;\n+\tstats->rx_dropped = estats->tx_discards;\n+\tstats->tx_dropped = estats->rx_discards;\n+}\n+\n+/**\n+ * i40e_vfpr_get_cpu_hit_stats64\n+ * @dev: network interface device structure\n+ * @stats: netlink stats structure\n+ *\n+ * stats are filled from the priv structure. correspond to the packets\n+ * that are seen by the cpu and sent/received via vfpr netdev.\n+ **/\n+static int\n+i40e_vfpr_get_cpu_hit_stats64(const struct net_device *dev,\n+\t\t\t struct rtnl_link_stats64 *stats)\n+{\n+\tstruct i40e_vfpr_netdev_priv *priv = netdev_priv(dev);\n+\tint i;\n+\n+\tfor_each_possible_cpu(i) {\n+\t\tstruct vfpr_pcpu_stats *vfpr_stats;\n+\t\tu64 tbytes, tpkts, tdrops, rbytes, rpkts;\n+\t\tunsigned int start;\n+\n+\t\tvfpr_stats = per_cpu_ptr(priv->vfpr_stats, i);\n+\t\tdo {\n+\t\t\tstart = u64_stats_fetch_begin_irq(&vfpr_stats->syncp);\n+\t\t\ttbytes = vfpr_stats->tx_bytes;\n+\t\t\ttpkts = vfpr_stats->tx_packets;\n+\t\t\ttdrops = vfpr_stats->tx_drops;\n+\t\t\trbytes = vfpr_stats->rx_bytes;\n+\t\t\trpkts = vfpr_stats->rx_packets;\n+\t\t} while (u64_stats_fetch_retry_irq(&vfpr_stats->syncp, start));\n+\t\tstats->tx_bytes += tbytes;\n+\t\tstats->tx_packets += tpkts;\n+\t\tstats->tx_dropped += tdrops;\n+\t\tstats->rx_bytes += rbytes;\n+\t\tstats->rx_packets += rpkts;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static bool\n+i40e_vfpr_netdev_has_offload_stats(const struct net_device *dev, int attr_id)\n+{\n+\tswitch (attr_id) {\n+\tcase IFLA_OFFLOAD_XSTATS_CPU_HIT:\n+\t\treturn true;\n+\t}\n+\n+\treturn false;\n+}\n+\n+static int\n+i40e_vfpr_netdev_get_offload_stats(int attr_id, const struct net_device *dev,\n+\t\t\t\t void *sp)\n+{\n+\tswitch (attr_id) {\n+\tcase IFLA_OFFLOAD_XSTATS_CPU_HIT:\n+\t\treturn i40e_vfpr_get_cpu_hit_stats64(dev, sp);\n+\t}\n+\n+\treturn -EINVAL;\n+}\n+\n static const struct net_device_ops i40e_vfpr_netdev_ops = {\n \t.ndo_open\t\t= i40e_vfpr_netdev_open,\n \t.ndo_stop\t\t= i40e_vfpr_netdev_stop,\n \t.ndo_start_xmit = i40e_vfpr_netdev_start_xmit,\n+\t.ndo_get_stats64 = i40e_vfpr_netdev_get_stats64,\n+\t.ndo_has_offload_stats = i40e_vfpr_netdev_has_offload_stats,\n+\t.ndo_get_offload_stats = i40e_vfpr_netdev_get_offload_stats,\n };\n \n /**\n@@ -1119,6 +1219,13 @@ int i40e_alloc_vfpr_netdev(struct i40e_vf *vf, u16 vf_num)\n \tpf->vf[vf_num].vfpr_netdev = vfpr_netdev;\n \n \tpriv = netdev_priv(vfpr_netdev);\n+\tpriv->vfpr_stats = netdev_alloc_pcpu_stats(struct vfpr_pcpu_stats);\n+\tif (!priv->vfpr_stats) {\n+\t\tdev_err(&pf->pdev->dev, \"alloc_pcpu_stats failed for vf:%d\\n\",\n+\t\t\tvf_num);\n+\t\tfree_netdev(vfpr_netdev);\n+\t\treturn -ENOMEM;\n+\t}\n \tpriv->vf = &pf->vf[vf_num];\n \tpriv->vfpr_dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX,\n \t\t\t\t\t GFP_KERNEL);\n@@ -1175,6 +1282,7 @@ void i40e_free_vfpr_netdev(struct i40e_vf *vf)\n \n \tpriv = netdev_priv(vf->vfpr_netdev);\n \tdst_release((struct dst_entry *)priv->vfpr_dst);\n+\tfree_percpu(priv->vfpr_stats);\n \tunregister_netdev(vf->vfpr_netdev);\n \tfree_netdev(vf->vfpr_netdev);\n \ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h\nindex 3dea207..52ba9d5 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h\n@@ -72,10 +72,20 @@ enum i40e_vf_capabilities {\n \tI40E_VIRTCHNL_VF_CAP_IWARP,\n };\n \n+struct vfpr_pcpu_stats {\n+\tu64 tx_packets;\n+\tu64 tx_bytes;\n+\tu64 tx_drops;\n+\tu64 rx_packets;\n+\tu64 rx_bytes;\n+\tstruct u64_stats_sync syncp;\n+};\n+\n /* VF Port representator netdev private structure */\n struct i40e_vfpr_netdev_priv {\n \tstruct metadata_dst *vfpr_dst;\n \tstruct i40e_vf *vf;\n+\tstruct vfpr_pcpu_stats *vfpr_stats;\n };\n \n /* VF information structure */\n", "prefixes": [ "next-queue", "v4", "6/7" ] }