get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/8522/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 8522,
    "url": "https://patches.dpdk.org/api/patches/8522/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1446459547-1754-9-git-send-email-harry.van.haaren@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1446459547-1754-9-git-send-email-harry.van.haaren@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1446459547-1754-9-git-send-email-harry.van.haaren@intel.com",
    "date": "2015-11-02T10:19:05",
    "name": "[dpdk-dev,v5,08/10] i40e: add xstats() implementation",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "1f2a924e7f3844362367fe60989b6059ff9c18d4",
    "submitter": {
        "id": 317,
        "url": "https://patches.dpdk.org/api/people/317/?format=api",
        "name": "Van Haaren, Harry",
        "email": "harry.van.haaren@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1446459547-1754-9-git-send-email-harry.van.haaren@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/8522/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/8522/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 12BB3919D;\n\tMon,  2 Nov 2015 11:19:30 +0100 (CET)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 910EF8E9D\n\tfor <dev@dpdk.org>; Mon,  2 Nov 2015 11:19:27 +0100 (CET)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby orsmga101.jf.intel.com with ESMTP; 02 Nov 2015 02:19:27 -0800",
            "from sie-lab-212-222.ir.intel.com (HELO\n\tsilpixa00366884.ir.intel.com) ([10.237.212.222])\n\tby orsmga002.jf.intel.com with ESMTP; 02 Nov 2015 02:19:25 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.20,234,1444719600\"; d=\"scan'208\";a=\"840505446\"",
        "From": "Harry van Haaren <harry.van.haaren@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Mon,  2 Nov 2015 10:19:05 +0000",
        "Message-Id": "<1446459547-1754-9-git-send-email-harry.van.haaren@intel.com>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1446459547-1754-1-git-send-email-harry.van.haaren@intel.com>",
        "References": "<1446204998-17151-2-git-send-email-harry.van.haaren@intel.com>\n\t<1446459547-1754-1-git-send-email-harry.van.haaren@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v5 08/10] i40e: add xstats() implementation",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add xstats functions to i40e PMD, allowing extended statistics\nto be retrieved from the NIC and exposed to the DPDK.\n\nSigned-off-by: Harry van Haaren <harry.van.haaren@intel.com>\n---\n drivers/net/i40e/i40e_ethdev.c | 215 +++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 209 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c\nindex 2dd9fdc..089d414 100644\n--- a/drivers/net/i40e/i40e_ethdev.c\n+++ b/drivers/net/i40e/i40e_ethdev.c\n@@ -127,7 +127,10 @@ static int i40e_dev_set_link_up(struct rte_eth_dev *dev);\n static int i40e_dev_set_link_down(struct rte_eth_dev *dev);\n static void i40e_dev_stats_get(struct rte_eth_dev *dev,\n \t\t\t       struct rte_eth_stats *stats);\n+static int i40e_dev_xstats_get(struct rte_eth_dev *dev,\n+\t\t\t       struct rte_eth_xstats *xstats, unsigned n);\n static void i40e_dev_stats_reset(struct rte_eth_dev *dev);\n+static void i40e_dev_xstats_reset(struct rte_eth_dev *dev);\n static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,\n \t\t\t\t\t    uint16_t queue_id,\n \t\t\t\t\t    uint8_t stat_idx,\n@@ -232,6 +235,8 @@ static int i40e_timesync_read_rx_timestamp(struct rte_eth_dev *dev,\n \t\t\t\t\t   uint32_t flags);\n static int i40e_timesync_read_tx_timestamp(struct rte_eth_dev *dev,\n \t\t\t\t\t   struct timespec *timestamp);\n+static void i40e_read_stats_registers(struct i40e_pf *pf, struct i40e_hw *hw);\n+\n \n static const struct rte_pci_id pci_id_i40e_map[] = {\n #define RTE_PCI_DEV_ID_DECL_I40E(vend, dev) {RTE_PCI_DEVICE(vend, dev)},\n@@ -252,7 +257,9 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {\n \t.dev_set_link_down            = i40e_dev_set_link_down,\n \t.link_update                  = i40e_dev_link_update,\n \t.stats_get                    = i40e_dev_stats_get,\n+\t.xstats_get                   = i40e_dev_xstats_get,\n \t.stats_reset                  = i40e_dev_stats_reset,\n+\t.xstats_reset                 = i40e_dev_xstats_reset,\n \t.queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,\n \t.dev_infos_get                = i40e_dev_info_get,\n \t.vlan_filter_set              = i40e_vlan_filter_set,\n@@ -291,6 +298,101 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {\n \t.timesync_read_tx_timestamp   = i40e_timesync_read_tx_timestamp,\n };\n \n+/* store statistics names and its offset in stats structure */\n+struct rte_i40e_xstats_name_off {\n+\tchar name[RTE_ETH_XSTATS_NAME_SIZE];\n+\tunsigned offset;\n+};\n+\n+static const struct rte_i40e_xstats_name_off rte_i40e_stats_strings[] = {\n+\t{\"rx_unicast_packets\", offsetof(struct i40e_eth_stats, rx_unicast)},\n+\t{\"rx_multicast_packets\", offsetof(struct i40e_eth_stats, rx_multicast)},\n+\t{\"rx_broadcast_packets\", offsetof(struct i40e_eth_stats, rx_broadcast)},\n+\t{\"rx_dropped\", offsetof(struct i40e_eth_stats, rx_discards)},\n+\t{\"rx_unknown_protocol_packets\", offsetof(struct i40e_eth_stats,\n+\t\trx_unknown_protocol)},\n+\t{\"tx_unicast_packets\", offsetof(struct i40e_eth_stats, tx_unicast)},\n+\t{\"tx_multicast_packets\", offsetof(struct i40e_eth_stats, tx_multicast)},\n+\t{\"tx_broadcast_packets\", offsetof(struct i40e_eth_stats, tx_broadcast)},\n+\t{\"tx_dropped\", offsetof(struct i40e_eth_stats, tx_discards)},\n+};\n+\n+static const struct rte_i40e_xstats_name_off rte_i40e_hw_port_strings[] = {\n+\t{\"tx_link_down_dropped\", offsetof(struct i40e_hw_port_stats,\n+\t\ttx_dropped_link_down)},\n+\t{\"rx_crc_errors\", offsetof(struct i40e_hw_port_stats, crc_errors)},\n+\t{\"rx_illegal_byte_errors\", offsetof(struct i40e_hw_port_stats,\n+\t\tillegal_bytes)},\n+\t{\"rx_error_bytes\", offsetof(struct i40e_hw_port_stats, error_bytes)},\n+\t{\"mac_local_errors\", offsetof(struct i40e_hw_port_stats,\n+\t\tmac_local_faults)},\n+\t{\"mac_remote_errors\", offsetof(struct i40e_hw_port_stats,\n+\t\tmac_remote_faults)},\n+\t{\"rx_length_errors\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_length_errors)},\n+\t{\"tx_xon_packets\", offsetof(struct i40e_hw_port_stats, link_xon_tx)},\n+\t{\"rx_xon_packets\", offsetof(struct i40e_hw_port_stats, link_xon_rx)},\n+\t{\"tx_xoff_packets\", offsetof(struct i40e_hw_port_stats, link_xoff_tx)},\n+\t{\"rx_xoff_packets\", offsetof(struct i40e_hw_port_stats, link_xoff_rx)},\n+\t{\"rx_size_64_packets\", offsetof(struct i40e_hw_port_stats, rx_size_64)},\n+\t{\"rx_size_65_to_127_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_size_127)},\n+\t{\"rx_size_128_to_255_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_size_255)},\n+\t{\"rx_size_256_to_511_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_size_511)},\n+\t{\"rx_size_512_to_1023_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_size_1023)},\n+\t{\"rx_size_1024_to_1522_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_size_1522)},\n+\t{\"rx_size_1523_to_max_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_size_big)},\n+\t{\"rx_undersized_errors\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_undersize)},\n+\t{\"rx_oversize_errors\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_oversize)},\n+\t{\"rx_mac_short_dropped\", offsetof(struct i40e_hw_port_stats,\n+\t\tmac_short_packet_dropped)},\n+\t{\"rx_fragmented_errors\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_fragments)},\n+\t{\"rx_jabber_errors\", offsetof(struct i40e_hw_port_stats, rx_jabber)},\n+\t{\"tx_size_64_packets\", offsetof(struct i40e_hw_port_stats, tx_size_64)},\n+\t{\"tx_size_65_to_127_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\ttx_size_127)},\n+\t{\"tx_size_128_to_255_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\ttx_size_255)},\n+\t{\"tx_size_256_to_511_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\ttx_size_511)},\n+\t{\"tx_size_512_to_1023_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\ttx_size_1023)},\n+\t{\"tx_size_1024_to_1522_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\ttx_size_1522)},\n+\t{\"tx_size_1523_to_max_packets\", offsetof(struct i40e_hw_port_stats,\n+\t\ttx_size_big)},\n+\t{\"rx_flow_director_atr_match_packets\",\n+\t\toffsetof(struct i40e_hw_port_stats, fd_atr_match)},\n+\t{\"rx_flow_director_sb_match_packets\",\n+\t\toffsetof(struct i40e_hw_port_stats, fd_sb_match)},\n+\t{\"tx_low_power_idle_status\", offsetof(struct i40e_hw_port_stats,\n+\t\ttx_lpi_status)},\n+\t{\"rx_low_power_idle_status\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_lpi_status)},\n+\t{\"tx_low_power_idle_count\", offsetof(struct i40e_hw_port_stats,\n+\t\ttx_lpi_count)},\n+\t{\"rx_low_power_idle_count\", offsetof(struct i40e_hw_port_stats,\n+\t\trx_lpi_count)},\n+};\n+\n+/* Q Stats: 5 stats are exposed for each queue, implemented in xstats_get() */\n+#define I40E_NB_HW_PORT_Q_STATS (8 * 5)\n+\n+#define I40E_NB_ETH_XSTATS (sizeof(rte_i40e_stats_strings) / \\\n+\t\tsizeof(rte_i40e_stats_strings[0]))\n+#define I40E_NB_HW_PORT_XSTATS (sizeof(rte_i40e_hw_port_strings) / \\\n+\t\tsizeof(rte_i40e_hw_port_strings[0]))\n+#define I40E_NB_XSTATS (I40E_NB_ETH_XSTATS + I40E_NB_HW_PORT_XSTATS + \\\n+\t\tI40E_NB_HW_PORT_Q_STATS)\n+\n static struct eth_driver rte_i40e_pmd = {\n \t.pci_drv = {\n \t\t.name = \"rte_i40e_pmd\",\n@@ -1322,16 +1424,12 @@ i40e_update_vsi_stats(struct i40e_vsi *vsi)\n \t\t    vsi->vsi_id);\n }\n \n-/* Get all statistics of a port */\n static void\n-i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)\n+i40e_read_stats_registers(struct i40e_pf *pf, struct i40e_hw *hw)\n {\n-\tuint32_t i;\n-\tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n-\tstruct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tunsigned int i;\n \tstruct i40e_hw_port_stats *ns = &pf->stats; /* new stats */\n \tstruct i40e_hw_port_stats *os = &pf->stats_offset; /* old stats */\n-\n \t/* Get statistics of struct i40e_eth_stats */\n \ti40e_stat_update_48(hw, I40E_GLPRT_GORCH(hw->port),\n \t\t\t    I40E_GLPRT_GORCL(hw->port),\n@@ -1510,6 +1608,19 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)\n \n \tif (pf->main_vsi)\n \t\ti40e_update_vsi_stats(pf->main_vsi);\n+}\n+\n+/* Get all statistics of a port */\n+static void\n+i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)\n+{\n+\tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tstruct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tstruct i40e_hw_port_stats *ns = &pf->stats; /* new stats */\n+\tunsigned i;\n+\n+\t/* call read registers - updates values, now write them to struct */\n+\ti40e_read_stats_registers(pf, hw);\n \n \tstats->ipackets = ns->eth.rx_unicast + ns->eth.rx_multicast +\n \t\t\t\t\t\tns->eth.rx_broadcast;\n@@ -1599,6 +1710,98 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)\n \tPMD_DRV_LOG(DEBUG, \"***************** PF stats end ********************\");\n }\n \n+static void\n+i40e_dev_xstats_reset(struct rte_eth_dev *dev)\n+{\n+\tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tstruct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tstruct i40e_hw_port_stats *hw_stats = &pf->stats;\n+\n+\t/* The hw registers are cleared on read */\n+\tpf->offset_loaded = false;\n+\ti40e_read_stats_registers(pf, hw);\n+\n+\t/* reset software counters */\n+\tmemset(hw_stats, 0, sizeof(*hw_stats));\n+}\n+\n+static int\n+i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,\n+\t\t    unsigned n)\n+{\n+\tstruct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);\n+\tstruct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tunsigned i, count = 0;\n+\tstruct i40e_hw_port_stats *hw_stats = &pf->stats;\n+\n+\tif (n < I40E_NB_XSTATS)\n+\t\treturn I40E_NB_XSTATS;\n+\n+\ti40e_read_stats_registers(pf, hw);\n+\n+\t/* Reset */\n+\tif (xstats == NULL)\n+\t\treturn 0;\n+\n+\t/* Get stats from i40e_eth_stats struct */\n+\tfor (i = 0; i < I40E_NB_ETH_XSTATS; i++) {\n+\t\tsnprintf(xstats[count].name, sizeof(xstats[count].name),\n+\t\t\t \"%s\", rte_i40e_stats_strings[i].name);\n+\t\txstats[count].value = *(uint64_t *)(((char *)&hw_stats->eth) +\n+\t\t\trte_i40e_stats_strings[i].offset);\n+\t\tcount++;\n+\t}\n+\n+\t/* Get individiual stats from i40e_hw_port struct */\n+\tfor (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) {\n+\t\tsnprintf(xstats[count].name, sizeof(xstats[count].name),\n+\t\t\t \"%s\", rte_i40e_hw_port_strings[i].name);\n+\t\txstats[count].value = *(uint64_t *)(((char *)hw_stats) +\n+\t\t\t\trte_i40e_hw_port_strings[i].offset);\n+\t\tcount++;\n+\t}\n+\n+\t/* Get per-queue stats from i40e_hw_port struct */\n+\tfor (i = 0; i < 8; i++) {\n+\t\tsnprintf(xstats[count].name, sizeof(xstats[count].name),\n+\t\t\t \"rx_q%u_xon_priority_packets\", i);\n+\t\txstats[count].value = *(uint64_t *)(((char *)hw_stats) +\n+\t\t\t\toffsetof(struct i40e_hw_port_stats,\n+\t\t\t\t\t priority_xon_rx[i]));\n+\t\tcount++;\n+\n+\t\tsnprintf(xstats[count].name, sizeof(xstats[count].name),\n+\t\t\t \"rx_q%u_xoff_priority_packets\", i);\n+\t\txstats[count].value = *(uint64_t *)(((char *)hw_stats) +\n+\t\t\t\toffsetof(struct i40e_hw_port_stats,\n+\t\t\t\t\t priority_xoff_rx[i]));\n+\t\tcount++;\n+\n+\t\tsnprintf(xstats[count].name, sizeof(xstats[count].name),\n+\t\t\t \"tx_q%u_xon_priority_packets\", i);\n+\t\txstats[count].value = *(uint64_t *)(((char *)hw_stats) +\n+\t\t\t\toffsetof(struct i40e_hw_port_stats,\n+\t\t\t\t\t priority_xon_tx[i]));\n+\t\tcount++;\n+\n+\t\tsnprintf(xstats[count].name, sizeof(xstats[count].name),\n+\t\t\t \"tx_q%u_xoff_priority_packets\", i);\n+\t\txstats[count].value = *(uint64_t *)(((char *)hw_stats) +\n+\t\t\t\toffsetof(struct i40e_hw_port_stats,\n+\t\t\t\t\t priority_xoff_tx[i]));\n+\t\tcount++;\n+\n+\t\tsnprintf(xstats[count].name, sizeof(xstats[count].name),\n+\t\t\t \"xx_q%u_xon_to_xoff_priority_packets\", i);\n+\t\txstats[count].value = *(uint64_t *)(((char *)hw_stats) +\n+\t\t\t\toffsetof(struct i40e_hw_port_stats,\n+\t\t\t\t\t priority_xon_2_xoff[i]));\n+\t\tcount++;\n+\t}\n+\n+\treturn I40E_NB_XSTATS;\n+}\n+\n /* Reset the statistics */\n static void\n i40e_dev_stats_reset(struct rte_eth_dev *dev)\n",
    "prefixes": [
        "dpdk-dev",
        "v5",
        "08/10"
    ]
}