Show a patch.

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

{
    "id": 44081,
    "url": "http://patches.dpdk.org/api/patches/44081/",
    "web_url": "http://patches.dpdk.org/patch/44081/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<20180831092038.23051-2-adrien.mazarguil@6wind.com>",
    "date": "2018-08-31T09:57:28",
    "name": "[1/8] net/mlx5: speed up interface index retrieval for flow rules",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "18f867983c72ed2963bd23a8cebf30a6f4312c01",
    "submitter": {
        "id": 165,
        "url": "http://patches.dpdk.org/api/people/165/",
        "name": "Adrien Mazarguil",
        "email": "adrien.mazarguil@6wind.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/patch/44081/mbox/",
    "series": [
        {
            "id": 1126,
            "url": "http://patches.dpdk.org/api/series/1126/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1126",
            "date": "2018-08-31T09:57:25",
            "name": "net/mlx5: add switch offload for VXLAN encap/decap",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1126/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44081/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44081/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "In-Reply-To": "<20180831092038.23051-1-adrien.mazarguil@6wind.com>",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Mailer": "git-send-email 2.11.0",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 4212E4C9D;\n\tFri, 31 Aug 2018 11:57:46 +0200 (CEST)",
            "from mail-wm0-f66.google.com (mail-wm0-f66.google.com\n\t[74.125.82.66]) by dpdk.org (Postfix) with ESMTP id D080E4C90\n\tfor <dev@dpdk.org>; Fri, 31 Aug 2018 11:57:44 +0200 (CEST)",
            "by mail-wm0-f66.google.com with SMTP id y2-v6so4651149wma.1\n\tfor <dev@dpdk.org>; Fri, 31 Aug 2018 02:57:44 -0700 (PDT)",
            "from 6wind.com (host.78.145.23.62.rev.coltfrance.com.\n\t[62.23.145.78]) by smtp.gmail.com with ESMTPSA id\n\th73-v6sm11677905wma.11.2018.08.31.02.57.43\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 31 Aug 2018 02:57:43 -0700 (PDT)"
        ],
        "References": "<20180831092038.23051-1-adrien.mazarguil@6wind.com>",
        "X-Google-Smtp-Source": "ANB0VdYUOqgqcGI9k/ByN5C+zzJmrPSS73l6+y6r8BXNCC7GR8uAuFxZoFjwsixOTikawBa3dgj7AA==",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=6wind-com.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:in-reply-to;\n\tbh=qWS7v5uSqkMAKw3w1FV0YuFOdRJ3wxulqB9LQSxnVdA=;\n\tb=gPoj0noHqhlGr7/eM0tluaLaTIQtL8rgOsTf+/G4tHeyePJxrB5Hv6BChrKOG0Hj/x\n\tsZOoC+1RyYPmfZngy/Wz0ISLx99XEPEY8Y02+UhzDjQP7Vpzm6AE7HagrsdDgzLgYKns\n\tdppQQmMeaNtPwemBkOwS6LOeIUB8pvEk6KfHxe2qkM4yV47+F4vMibdm9d2QxfikWjkH\n\tt6CJspCOV7HNkHCeMdNdNzrEcoGdcx++TKm3k63/hS/RhK5Ej1IOc0THOfYgNbtX7eSw\n\t5blkysQOIoeIiCIQ0nsm6/Ir/sV9vQS3at4d3uB5KNsnPLTVtukA+Q3h0Ajp4oLRT7BP\n\t642Q==",
        "MIME-Version": "1.0",
        "X-Received": "by 2002:a1c:2351:: with SMTP id\n\tj78-v6mr4281894wmj.68.1535709464412; \n\tFri, 31 Aug 2018 02:57:44 -0700 (PDT)",
        "Message-ID": "<20180831092038.23051-2-adrien.mazarguil@6wind.com>",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to;\n\tbh=qWS7v5uSqkMAKw3w1FV0YuFOdRJ3wxulqB9LQSxnVdA=;\n\tb=NVsP/S8TvczdzP1PHw26AgPZq4hz4C3b/aNHHhgr2qdX7MCmUqAGpaafndBZjwQRSd\n\tlv9YcACe307DgWtnWCXLu0DFr8unr5WzhXxt5fHePd57GMT2JdJ/fSxeua4DfNRSdrQx\n\tNMortKlJXpjP3TR2XdW2tGpESk4NWzOQlxSzRdcfLrZ6tKsCO7JjpVOhksBT7xBtV200\n\ttO6xvHqjIiJh7s/ktvbakmqkzcJA9URan4H6jyDhggDo3U8XH6Om2lixmrcGHop8EkAP\n\tc/yBj9uJFO1JI7EWGF5IJT7FRK3ONP1V2QsqgXAooM5L+A3mE7M1cH/3wa7Ox/bzvc0J\n\tk7nA==",
        "Delivered-To": "patchwork@dpdk.org",
        "Precedence": "list",
        "From": "Adrien Mazarguil <adrien.mazarguil@6wind.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "Content-Type": "text/plain; charset=us-ascii",
        "Content-Disposition": "inline",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "To": "Shahaf Shuler <shahafs@mellanox.com>, Yongseok Koh <yskoh@mellanox.com>, \n\tSlava Ovsiienko <viacheslavo@mellanox.com>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Fri, 31 Aug 2018 11:57:28 +0200",
        "X-Gm-Message-State": "APzg51DfyxSZM/6rn1onCZpOlEpyDipunv85cD5FxF+tlMSvPiVWGOJD\n\t6ZYcPByJ/R+075xj7Hn+a63E+1e8NH51sA==",
        "Cc": "dev@dpdk.org",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "X-BeenThere": "dev@dpdk.org",
        "Subject": "[dpdk-dev] [PATCH 1/8] net/mlx5: speed up interface index retrieval\n\tfor flow rules"
    },
    "content": "rte_eth_dev_info_get() can be avoided since the underlying device type and\ndata structure are known.\n\nCaching the index before creating any flow rules avoids a number of\nredundant system calls later since users are not expected to destroy the\nassociated network interface while PMD is bound and running.\n\nSigned-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>\n---\n drivers/net/mlx5/mlx5.c        | 48 ++++++++++++++++++-------------------\n drivers/net/mlx5/mlx5.h        |  1 +\n drivers/net/mlx5/mlx5_ethdev.c |  4 +---\n drivers/net/mlx5/mlx5_flow.c   |  6 ++---\n drivers/net/mlx5/mlx5_nl.c     |  9 +++----\n 5 files changed, 32 insertions(+), 36 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex a8ae2b5d3..55b73a03b 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -736,6 +736,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \tstruct ether_addr mac;\n \tchar name[RTE_ETH_NAME_MAX_LEN];\n \tint own_domain_id = 0;\n+\tstruct rte_flow_error flow_error;\n \tunsigned int i;\n \n \t/* Determine if this port representor is supposed to be spawned. */\n@@ -959,6 +960,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \tpriv->domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID;\n \tpriv->representor_id =\n \t\tswitch_info->representor ? switch_info->port_name : -1;\n+\t/* Interface index will be known once eth_dev is allocated. */\n+\tpriv->ifindex = 0;\n \t/*\n \t * Look for sibling devices in order to reuse their switch domain\n \t * if any, otherwise allocate one.\n@@ -1087,6 +1090,16 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \t\terr = rte_errno;\n \t\tgoto error;\n \t}\n+\t/*\n+\t * Cache associated interface index since lookups are expensive.\n+\t * It is not expected to change while a PMD instance is bound and\n+\t * running.\n+\t */\n+\tpriv->ifindex = mlx5_ifindex(eth_dev);\n+\tif (!priv->ifindex)\n+\t\tDRV_LOG(WARNING,\n+\t\t\t\"cannot retrieve network interface index: %s\",\n+\t\t\tstrerror(rte_errno));\n \t/* Configure the first MAC address by default. */\n \tif (mlx5_get_mac(eth_dev, &mac.addr_bytes)) {\n \t\tDRV_LOG(ERR,\n@@ -1131,32 +1144,19 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \tif (vf && config.vf_nl_en)\n \t\tmlx5_nl_mac_addr_sync(eth_dev);\n \tpriv->mnl_socket = mlx5_nl_flow_socket_create();\n-\tif (!priv->mnl_socket) {\n-\t\terr = -rte_errno;\n+\tif (!priv->mnl_socket ||\n+\t    !priv->ifindex ||\n+\t    mlx5_nl_flow_init(priv->mnl_socket, priv->ifindex, &flow_error)) {\n+\t\tif (!priv->mnl_socket) {\n+\t\t\tflow_error.message = \"cannot open libmnl socket\";\n+\t\t} else if (!priv->ifindex) {\n+\t\t\trte_errno = ENXIO;\n+\t\t\tflow_error.message = \"unknown network interface index\";\n+\t\t}\n \t\tDRV_LOG(WARNING,\n \t\t\t\"flow rules relying on switch offloads will not be\"\n-\t\t\t\" supported: cannot open libmnl socket: %s\",\n-\t\t\tstrerror(rte_errno));\n-\t} else {\n-\t\tstruct rte_flow_error error;\n-\t\tunsigned int ifindex = mlx5_ifindex(eth_dev);\n-\n-\t\tif (!ifindex) {\n-\t\t\terr = -rte_errno;\n-\t\t\terror.message =\n-\t\t\t\t\"cannot retrieve network interface index\";\n-\t\t} else {\n-\t\t\terr = mlx5_nl_flow_init(priv->mnl_socket, ifindex,\n-\t\t\t\t\t\t&error);\n-\t\t}\n-\t\tif (err) {\n-\t\t\tDRV_LOG(WARNING,\n-\t\t\t\t\"flow rules relying on switch offloads will\"\n-\t\t\t\t\" not be supported: %s: %s\",\n-\t\t\t\terror.message, strerror(rte_errno));\n-\t\t\tmlx5_nl_flow_socket_destroy(priv->mnl_socket);\n-\t\t\tpriv->mnl_socket = NULL;\n-\t\t}\n+\t\t\t\" supported: %s: %s\",\n+\t\t\tflow_error.message, strerror(rte_errno));\n \t}\n \tTAILQ_INIT(&priv->flows);\n \tTAILQ_INIT(&priv->ctrl_flows);\ndiff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex 35a196e76..4c2dec644 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -183,6 +183,7 @@ struct priv {\n \tunsigned int representor:1; /* Device is a port representor. */\n \tuint16_t domain_id; /* Switch domain identifier. */\n \tint32_t representor_id; /* Port representor identifier. */\n+\tunsigned int ifindex; /* Interface index associated with device. */\n \t/* RX/TX queues. */\n \tunsigned int rxqs_n; /* RX queues array size. */\n \tunsigned int txqs_n; /* TX queues array size. */\ndiff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c\nindex 34c5b95ee..cf0b415b2 100644\n--- a/drivers/net/mlx5/mlx5_ethdev.c\n+++ b/drivers/net/mlx5/mlx5_ethdev.c\n@@ -511,7 +511,6 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)\n \tstruct priv *priv = dev->data->dev_private;\n \tstruct mlx5_dev_config *config = &priv->config;\n \tunsigned int max;\n-\tchar ifname[IF_NAMESIZE];\n \n \t/* FIXME: we should ask the device for these values. */\n \tinfo->min_rx_bufsize = 32;\n@@ -532,8 +531,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)\n \tinfo->rx_offload_capa = (mlx5_get_rx_port_offloads() |\n \t\t\t\t info->rx_queue_offload_capa);\n \tinfo->tx_offload_capa = mlx5_get_tx_port_offloads(dev);\n-\tif (mlx5_get_ifname(dev, &ifname) == 0)\n-\t\tinfo->if_index = if_nametoindex(ifname);\n+\tinfo->if_index = priv->ifindex;\n \tinfo->reta_size = priv->reta_idx_n ?\n \t\tpriv->reta_idx_n : config->ind_table_max_size;\n \tinfo->hash_key_size = MLX5_RSS_HASH_KEY_LEN;\ndiff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c\nindex 3f548a9a4..f093a5ed0 100644\n--- a/drivers/net/mlx5/mlx5_flow.c\n+++ b/drivers/net/mlx5/mlx5_flow.c\n@@ -2466,13 +2466,13 @@ mlx5_flow_merge_switch(struct rte_eth_dev *dev,\n \t\tn = RTE_MIN(mlx5_dev_to_port_id(dev->device, port_id, n), n);\n \t}\n \tfor (i = 0; i != n; ++i) {\n-\t\tstruct rte_eth_dev_info dev_info;\n+\t\tstruct rte_eth_dev *i_dev = &rte_eth_devices[port_id[i]];\n+\t\tstruct priv *i_priv = i_dev->data->dev_private;\n \n-\t\trte_eth_dev_info_get(port_id[i], &dev_info);\n \t\tif (port_id[i] == dev->data->port_id)\n \t\t\town = i;\n \t\tptoi[i].port_id = port_id[i];\n-\t\tptoi[i].ifindex = dev_info.if_index;\n+\t\tptoi[i].ifindex = i_priv->ifindex;\n \t}\n \t/* Ensure first entry of ptoi[] is the current device. */\n \tif (own) {\ndiff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c\nindex d61826aea..a298db68c 100644\n--- a/drivers/net/mlx5/mlx5_nl.c\n+++ b/drivers/net/mlx5/mlx5_nl.c\n@@ -362,7 +362,6 @@ mlx5_nl_mac_addr_list(struct rte_eth_dev *dev, struct ether_addr (*mac)[],\n \t\t      int *mac_n)\n {\n \tstruct priv *priv = dev->data->dev_private;\n-\tunsigned int iface_idx = mlx5_ifindex(dev);\n \tstruct {\n \t\tstruct nlmsghdr\thdr;\n \t\tstruct ifinfomsg ifm;\n@@ -374,7 +373,7 @@ mlx5_nl_mac_addr_list(struct rte_eth_dev *dev, struct ether_addr (*mac)[],\n \t\t},\n \t\t.ifm = {\n \t\t\t.ifi_family = PF_BRIDGE,\n-\t\t\t.ifi_index = iface_idx,\n+\t\t\t.ifi_index = priv->ifindex,\n \t\t},\n \t};\n \tstruct mlx5_nl_mac_addr data = {\n@@ -421,7 +420,6 @@ mlx5_nl_mac_addr_modify(struct rte_eth_dev *dev, struct ether_addr *mac,\n \t\t\tint add)\n {\n \tstruct priv *priv = dev->data->dev_private;\n-\tunsigned int iface_idx = mlx5_ifindex(dev);\n \tstruct {\n \t\tstruct nlmsghdr hdr;\n \t\tstruct ndmsg ndm;\n@@ -437,7 +435,7 @@ mlx5_nl_mac_addr_modify(struct rte_eth_dev *dev, struct ether_addr *mac,\n \t\t.ndm = {\n \t\t\t.ndm_family = PF_BRIDGE,\n \t\t\t.ndm_state = NUD_NOARP | NUD_PERMANENT,\n-\t\t\t.ndm_ifindex = iface_idx,\n+\t\t\t.ndm_ifindex = priv->ifindex,\n \t\t\t.ndm_flags = NTF_SELF,\n \t\t},\n \t\t.rta = {\n@@ -600,7 +598,6 @@ static int\n mlx5_nl_device_flags(struct rte_eth_dev *dev, uint32_t flags, int enable)\n {\n \tstruct priv *priv = dev->data->dev_private;\n-\tunsigned int iface_idx = mlx5_ifindex(dev);\n \tstruct {\n \t\tstruct nlmsghdr hdr;\n \t\tstruct ifinfomsg ifi;\n@@ -613,7 +610,7 @@ mlx5_nl_device_flags(struct rte_eth_dev *dev, uint32_t flags, int enable)\n \t\t.ifi = {\n \t\t\t.ifi_flags = enable ? flags : 0,\n \t\t\t.ifi_change = flags,\n-\t\t\t.ifi_index = iface_idx,\n+\t\t\t.ifi_index = priv->ifindex,\n \t\t},\n \t};\n \tint fd;\n",
    "prefixes": [
        "1/8"
    ]
}