Show a patch.

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

{
    "id": 44603,
    "url": "http://patches.dpdk.org/api/patches/44603/",
    "web_url": "http://patches.dpdk.org/patch/44603/",
    "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": "<20180911232906.18352-2-dg@adax.com>",
    "date": "2018-09-11T23:29:05",
    "name": "[1/2] kni: add API to set link status on kernel interface",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "751977fb3d090094a7f21706e7d5058402fa0795",
    "submitter": {
        "id": 1040,
        "url": "http://patches.dpdk.org/api/people/1040/",
        "name": "Dan Gora",
        "email": "dg@adax.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/patch/44603/mbox/",
    "series": [
        {
            "id": 1288,
            "url": "http://patches.dpdk.org/api/series/1288/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1288",
            "date": "2018-09-11T23:29:04",
            "name": "kni: add API to set link status on kernel interface",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1288/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44603/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44603/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "Date": "Tue, 11 Sep 2018 20:29:05 -0300",
        "In-Reply-To": "<20180911232906.18352-1-dg@adax.com>",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Mailer": "git-send-email 2.19.0",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 82DAD4C95;\n\tWed, 12 Sep 2018 01:29:26 +0200 (CEST)",
            "from mail-qk1-f195.google.com (mail-qk1-f195.google.com\n\t[209.85.222.195]) by dpdk.org (Postfix) with ESMTP id D69CB4C94\n\tfor <dev@dpdk.org>; Wed, 12 Sep 2018 01:29:25 +0200 (CEST)",
            "by mail-qk1-f195.google.com with SMTP id f17-v6so32608qkh.4\n\tfor <dev@dpdk.org>; Tue, 11 Sep 2018 16:29:25 -0700 (PDT)",
            "from snappy.local.lan (189-46-164-241.dsl.telesp.net.br.\n\t[189.46.164.241]) by smtp.gmail.com with ESMTPSA id\n\tp30-v6sm12767814qta.4.2018.09.11.16.29.21\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tTue, 11 Sep 2018 16:29:24 -0700 (PDT)"
        ],
        "References": "<20180911232906.18352-1-dg@adax.com>",
        "X-Google-Smtp-Source": "ANB0VdZSMqU3g7agqrJwRA750traNHslUqwZJ0vL+3BISYnDbqaa82gN1kdCR9W19cjH0EWvK26qSQ==",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=brKgXRmAdYdNeL3uqBo0I3ImwvPWLgFWozo5r8fr8WE=;\n\tb=KJlNr9W+jF7TRpZem/EbIKwgveOlC4PL2Zd13KCpNi7odfYYHKpvtMjVYGm6Y/jfv8\n\tKCbukPkFLJFYqx5kwE4FZRF2cr1/Y3E+lPLVE9mVYjObleJnkWjNADeUcwhJZXRQyfon\n\tIUWWsiogbcQTzSNnOBiQ/PIEP4Ec75OQu4qtW+6LEJ5Yc5nPsDkBR5V07wgt7hjRqG21\n\tGIZC4BmYxvCSvxtCLIxsJYN79O97EEcDC33P7x0fKh1L+xnXmdFiLRF4DMYs3AuDQd3x\n\tek4YfHxw4XdKZkA0m1Kn1B7LnH4zzHP2Ap+RRSjioAIqJE6fYOdXSYRHbjtaOfX/y/EM\n\tHXqA==",
        "MIME-Version": "1.0",
        "X-Received": "by 2002:a37:cc9a:: with SMTP id\n\tn26-v6mr20947097qkl.112.1536708564872; \n\tTue, 11 Sep 2018 16:29:24 -0700 (PDT)",
        "Message-Id": "<20180911232906.18352-2-dg@adax.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:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references:mime-version:content-transfer-encoding;\n\tbh=brKgXRmAdYdNeL3uqBo0I3ImwvPWLgFWozo5r8fr8WE=;\n\tb=LScDXJTP/jGo+IA+xonP8eGpsZPhLZ/beOEbeVH/jtQwGJX+mcEZXnQOErEfMwwJhK\n\t5cKWOmEZOIO2lO7JAiO1Ww2Yjb8XhWHcR8oAp61pWoZutIvZ/A6eAeUlVC3p2z7CcZSL\n\tFtf+QAaxKM4rKj5dMviVJ/YtOmLewbVhwxY9C6RoGOrdA3tmwXMFK88ZVlWRrMdAVq6o\n\trmF19xfdLpjfi46zuV8UEKGF0ATW9DLzDcLtDJ7a+FRM15CyKMcW8xzETVJqRMDQH/XW\n\tJcVlH3s32Mrc6nt3WcmMJzEM6eWdEEBstvKK4aCn/my7r23v8CfExoH/Cam7blvet3az\n\tJ7mw==",
        "Delivered-To": "patchwork@dpdk.org",
        "Content-Transfer-Encoding": "8bit",
        "From": "Dan Gora <dg@adax.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "dev@dpdk.org",
        "Precedence": "list",
        "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>",
        "X-BeenThere": "dev@dpdk.org",
        "X-Gm-Message-State": "APzg51DTsCf3syC/4GrqZSav3svLhuE9nUMxe4IG1yuBTbj2Wcv+jsMf\n\t88eCjMXNJDEBbnY05w/lJGjd22fz",
        "Cc": "Igor Ryzhov <iryzhov@nfware.com>,\n\tStephen Hemminger <stephen@networkplumber.org>,\n\tFerruh Yigit <ferruh.yigit@intel.com>, Dan Gora <dg@adax.com>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH 1/2] kni: add API to set link status on kernel\n\tinterface"
    },
    "content": "Add a new API function to KNI, rte_kni_update_link() to allow DPDK\napplications to update the link status for KNI network interfaces in\nthe linux kernel.\n\nSigned-off-by: Dan Gora <dg@adax.com>\n---\n lib/librte_kni/rte_kni.c | 57 ++++++++++++++++++++++++++++++++++++++++\n lib/librte_kni/rte_kni.h | 18 +++++++++++++\n 2 files changed, 75 insertions(+)",
    "diff": "diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c\nindex 65f6a2b03..afe1d7410 100644\n--- a/lib/librte_kni/rte_kni.c\n+++ b/lib/librte_kni/rte_kni.c\n@@ -790,6 +790,63 @@ rte_kni_unregister_handlers(struct rte_kni *kni)\n \n \treturn 0;\n }\n+\n+int\n+rte_kni_update_link(struct rte_kni *kni, struct rte_eth_link *link)\n+{\n+\tchar path[64];\n+\tchar carrier[2];\n+\tconst char *new_carrier;\n+\tint fd, ret;\n+\n+\tif (kni == NULL || link == NULL)\n+\t\treturn -1;\n+\n+\tsnprintf(path, sizeof(path), \"/sys/devices/virtual/net/%s/carrier\",\n+\t\tkni->name);\n+\n+\tfd = open(path, O_RDWR);\n+\tif (fd == -1) {\n+\t\tRTE_LOG(ERR, KNI, \"Failed to open file: %s.\\n\", path);\n+\t\treturn -1;\n+\t}\n+\n+\tret = read(fd, carrier, 2);\n+\tif (ret < 1) {\n+\t\t/* Cannot read carrier until interface is marked\n+\t\t * 'up', so don't log an error.\n+\t\t */\n+\t\tclose(fd);\n+\t\treturn -1;\n+\t}\n+\n+\tnew_carrier = (link->link_status == ETH_LINK_UP) ? \"1\" : \"0\";\n+\tret = write(fd, new_carrier, 1);\n+\tif (ret < 1) {\n+\t\tRTE_LOG(ERR, KNI, \"Failed to write file: %s.\\n\", path);\n+\t\tclose(fd);\n+\t\treturn -1;\n+\t}\n+\n+\tif (strncmp(carrier, new_carrier, 1)) {\n+\t\tif (link->link_status == ETH_LINK_UP) {\n+\t\t\tRTE_LOG(INFO, KNI, \"%s NIC Link is Up %d Mbps %s %s.\\n\",\n+\t\t\t\tkni->name,\n+\t\t\t\tlink->link_speed,\n+\t\t\t\tlink->link_autoneg ? \"(Fixed)\" : \"(AutoNeg)\",\n+\t\t\t\tlink->link_duplex ?\n+\t\t\t\t\t\"Full Duplex\" : \"Half Duplex\");\n+\t\t} else {\n+\t\t\tRTE_LOG(INFO, KNI, \"%s NIC Link is Down.\\n\",\n+\t\t\t\tkni->name);\n+\t\t}\n+\t}\n+\n+\tclose(fd);\n+\n+\treturn 0;\n+}\n+\n void\n rte_kni_close(void)\n {\ndiff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h\nindex 99055e2c2..4118ae97a 100644\n--- a/lib/librte_kni/rte_kni.h\n+++ b/lib/librte_kni/rte_kni.h\n@@ -21,6 +21,7 @@\n #include <rte_memory.h>\n #include <rte_mempool.h>\n #include <rte_ether.h>\n+#include <rte_ethdev.h>\n \n #include <exec-env/rte_kni_common.h>\n \n@@ -228,6 +229,23 @@ int rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops);\n  */\n int rte_kni_unregister_handlers(struct rte_kni *kni);\n \n+/**\n+ * Update link status info for KNI port.\n+ *\n+ * Update the linkup/linkdown status of a KNI interface in the kernel.\n+ *\n+ * @param kni\n+ *  pointer to struct rte_kni.\n+ * @param link\n+ *  pointer to struct rte_eth_link containing new interface status.\n+ *\n+ * @return\n+ *  On success: 0\n+ *  On failure: -1\n+ */\n+int __rte_experimental\n+rte_kni_update_link(struct rte_kni *kni, struct rte_eth_link *link);\n+\n /**\n  *  Close KNI device.\n  */\n",
    "prefixes": [
        "1/2"
    ]
}