get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1002,
    "url": "http://patchwork.dpdk.org/api/patches/1002/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1414572576-21371-3-git-send-email-mukawa@igel.co.jp/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<1414572576-21371-3-git-send-email-mukawa@igel.co.jp>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1414572576-21371-3-git-send-email-mukawa@igel.co.jp",
    "date": "2014-10-29T08:49:13",
    "name": "[dpdk-dev,RFC,02/25] ethdev: Remove assumption that port will not be detached",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "40d2d69ceb8d5f3631241b23b474b026a7b7860d",
    "submitter": {
        "id": 64,
        "url": "http://patchwork.dpdk.org/api/people/64/?format=api",
        "name": "Tetsuya Mukawa",
        "email": "mukawa@igel.co.jp"
    },
    "delegate": null,
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1414572576-21371-3-git-send-email-mukawa@igel.co.jp/mbox/",
    "series": [],
    "comments": "http://patchwork.dpdk.org/api/patches/1002/comments/",
    "check": "pending",
    "checks": "http://patchwork.dpdk.org/api/patches/1002/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 9D3B77FC6;\n\tWed, 29 Oct 2014 09:41:16 +0100 (CET)",
            "from mail-pd0-f181.google.com (mail-pd0-f181.google.com\n\t[209.85.192.181]) by dpdk.org (Postfix) with ESMTP id 4D4E47FC0\n\tfor <dev@dpdk.org>; Wed, 29 Oct 2014 09:41:11 +0100 (CET)",
            "by mail-pd0-f181.google.com with SMTP id y10so2528960pdj.26\n\tfor <dev@dpdk.org>; Wed, 29 Oct 2014 01:50:01 -0700 (PDT)",
            "from eris.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\tky4sm3686872pbc.55.2014.10.29.01.49.59 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tWed, 29 Oct 2014 01:50:00 -0700 (PDT)"
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=g1bc6S/DQ0Kq/h1Y+TyGezJvvoMx2NBmbMPpUusmdnA=;\n\tb=evp4PHeS7kxsbEDuh6syRQIfzfX97GN1DzFQIhfRcJBYg97E0cDaw31NYU+bX8QnKR\n\tKgdGGqs5xk5ksQTXaLFg5/LQ/G3QvQ/cOzGaVDQEu22u+0Z8A8x3ti92koVdd9yZPj0P\n\tqvgtvWdvmKMcpsczfNEqLwPMlLYGoz+OLjBEvXNnWT9qop14/TmqtG+MPFjBbwi+Dl0o\n\t2sVkNcmXhEMqSSgfHyV9VIWXR+26gRLfoJKsGhgOmtdVHQAUYzxXO99ajOYm/TmIZTDs\n\tY6Ia8Rm0KUpd5gYItpAZCvtW3nFb9IZvgv/oY/iSOxUOiIzg9KDB0pE/WJZSN9Ik/Vg1\n\tmEfg==",
        "X-Gm-Message-State": "ALoCoQmuLaybFQoyfWfPS/3e6pEWOm+F0/nF6+V5UCmyDp7xa/9PmVolYo45aoKKR79lIqGDHcuS",
        "X-Received": "by 10.70.88.139 with SMTP id bg11mr9091295pdb.145.1414572601387; \n\tWed, 29 Oct 2014 01:50:01 -0700 (PDT)",
        "From": "Tetsuya Mukawa <mukawa@igel.co.jp>",
        "To": "dev@dpdk.org",
        "Date": "Wed, 29 Oct 2014 17:49:13 +0900",
        "Message-Id": "<1414572576-21371-3-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1414572576-21371-1-git-send-email-mukawa@igel.co.jp>",
        "References": "<1414572576-21371-1-git-send-email-mukawa@igel.co.jp>",
        "Cc": "nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp",
        "Subject": "[dpdk-dev] [RFC PATCH 02/25] ethdev: Remove assumption that port\n\twill not be detached",
        "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": "To remove assumption, do like followings.\n\n- Add 'attached' member to rte_eth_dev structure.\n  This member is used for indicating the port is attached, or not.\n- Delete nb_ports, and fix rte_eth_dev_count().\n  The value was used for counting attached ports and also used for indicating\n  maximum attached port number. But if some ports are detached, these 2 values\n  may not be equal. So delete nb_ports, and fix rte_eth_dev_count() to count\n  how many ports are attached actually.\n- Add rte_eth_dev_allocate_new_port().\n  This function is used for allocating new port.\n- Add rte_eth_dev_validate_port().\n  This function is used for check whether the port number is valid and the\n  port is attached.\n- Replace port validation codes to rte_eth_dev_validate_port().\n  nb_ports is deleted in this patch, so use rte_eth_dev_validate_port() to\n  validate a port.\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n lib/librte_ether/rte_ethdev.c | 247 +++++++++++++++++++++++-------------------\n lib/librte_ether/rte_ethdev.h |   5 +\n 2 files changed, 143 insertions(+), 109 deletions(-)",
    "diff": "diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c\nindex ff1c769..93d5a42 100644\n--- a/lib/librte_ether/rte_ethdev.c\n+++ b/lib/librte_ether/rte_ethdev.c\n@@ -109,7 +109,6 @@\n static const char *MZ_RTE_ETH_DEV_DATA = \"rte_eth_dev_data\";\n struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];\n static struct rte_eth_dev_data *rte_eth_dev_data = NULL;\n-static uint8_t nb_ports = 0;\n \n /* spinlock for eth device callbacks */\n static rte_spinlock_t rte_eth_dev_cb_lock = RTE_SPINLOCK_INITIALIZER;\n@@ -201,19 +200,33 @@ rte_eth_dev_allocated(const char *name)\n {\n \tunsigned i;\n \n-\tfor (i = 0; i < nb_ports; i++) {\n-\t\tif (strcmp(rte_eth_devices[i].data->name, name) == 0)\n+\tfor (i = 0; i < RTE_MAX_ETHPORTS; i++)\n+\t\tif (rte_eth_devices[i].attached && strcmp(\n+\t\t\t\trte_eth_dev_data[i].name, name) == 0)\n \t\t\treturn &rte_eth_devices[i];\n-\t}\n+\n \treturn NULL;\n }\n \n+static uint8_t\n+rte_eth_dev_allocate_new_port(void)\n+{\n+\tunsigned i;\n+\n+\tfor (i = 0; i < RTE_MAX_ETHPORTS; i++)\n+\t\tif (!rte_eth_devices[i].attached)\n+\t\t\treturn i;\n+\treturn RTE_MAX_ETHPORTS;\n+}\n+\n struct rte_eth_dev *\n rte_eth_dev_allocate(const char *name)\n {\n+\tuint8_t port_id;\n \tstruct rte_eth_dev *eth_dev;\n \n-\tif (nb_ports == RTE_MAX_ETHPORTS) {\n+\tport_id = rte_eth_dev_allocate_new_port();\n+\tif (port_id >= RTE_MAX_ETHPORTS) {\n \t\tPMD_DEBUG_TRACE(\"Reached maximum number of Ethernet ports\\n\");\n \t\treturn NULL;\n \t}\n@@ -226,10 +239,11 @@ rte_eth_dev_allocate(const char *name)\n \t\treturn NULL;\n \t}\n \n-\teth_dev = &rte_eth_devices[nb_ports];\n-\teth_dev->data = &rte_eth_dev_data[nb_ports];\n+\teth_dev = &rte_eth_devices[port_id];\n+\teth_dev->data = &rte_eth_dev_data[port_id];\n \tsnprintf(eth_dev->data->name, sizeof(eth_dev->data->name), \"%s\", name);\n-\teth_dev->data->port_id = nb_ports++;\n+\teth_dev->data->port_id = port_id;\n+\teth_dev->attached = 1;\n \treturn eth_dev;\n }\n \n@@ -283,7 +297,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,\n \t\t\t(unsigned) pci_dev->id.device_id);\n \tif (rte_eal_process_type() == RTE_PROC_PRIMARY)\n \t\trte_free(eth_dev->data->dev_private);\n-\tnb_ports--;\n+\teth_dev->attached = 0;\n \treturn diag;\n }\n \n@@ -308,10 +322,19 @@ rte_eth_driver_register(struct eth_driver *eth_drv)\n \trte_eal_pci_register(&eth_drv->pci_drv);\n }\n \n+static int\n+rte_eth_dev_validate_port(uint8_t port_id)\n+{\n+\tif (port_id >= RTE_MAX_ETHPORTS)\n+\t\treturn 1;\n+\n+\treturn !rte_eth_devices[port_id].attached;\n+}\n+\n int\n rte_eth_dev_socket_id(uint8_t port_id)\n {\n-\tif (port_id >= nb_ports)\n+\tif (rte_eth_dev_validate_port(port_id))\n \t\treturn -1;\n \treturn rte_eth_devices[port_id].pci_dev->numa_node;\n }\n@@ -319,7 +342,13 @@ rte_eth_dev_socket_id(uint8_t port_id)\n uint8_t\n rte_eth_dev_count(void)\n {\n-\treturn (nb_ports);\n+\tunsigned i;\n+\tuint8_t nb_ports = 0;\n+\n+\tfor (i = 0; i < RTE_MAX_ETHPORTS; i++)\n+\t\tif (rte_eth_devices[i].attached)\n+\t\t\tnb_ports++;\n+\treturn nb_ports;\n }\n \n static int\n@@ -369,7 +398,7 @@ rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t rx_queue_id)\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -395,7 +424,7 @@ rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t rx_queue_id)\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -421,7 +450,7 @@ rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t tx_queue_id)\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -447,7 +476,7 @@ rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t tx_queue_id)\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -662,7 +691,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);\n \n-\tif (port_id >= nb_ports || port_id >= RTE_MAX_ETHPORTS) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -846,7 +875,7 @@ rte_eth_dev_start(uint8_t port_id)\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%\" PRIu8 \"\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -881,7 +910,7 @@ rte_eth_dev_stop(uint8_t port_id)\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_RET();\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%\" PRIu8 \"\\n\", port_id);\n \t\treturn;\n \t}\n@@ -909,7 +938,7 @@ rte_eth_dev_set_link_up(uint8_t port_id)\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -928,7 +957,7 @@ rte_eth_dev_set_link_down(uint8_t port_id)\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -947,7 +976,7 @@ rte_eth_dev_close(uint8_t port_id)\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_RET();\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -975,7 +1004,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -1048,7 +1077,7 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,\n \t * in a multi-process setup*/\n \tPROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);\n \n-\tif (port_id >= RTE_MAX_ETHPORTS || port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -1081,7 +1110,7 @@ rte_eth_promiscuous_enable(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1097,7 +1126,7 @@ rte_eth_promiscuous_disable(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1113,7 +1142,7 @@ rte_eth_promiscuous_get(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -1;\n \t}\n@@ -1127,7 +1156,7 @@ rte_eth_allmulticast_enable(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1143,7 +1172,7 @@ rte_eth_allmulticast_disable(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1159,7 +1188,7 @@ rte_eth_allmulticast_get(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -1;\n \t}\n@@ -1187,7 +1216,7 @@ rte_eth_link_get(uint8_t port_id, struct rte_eth_link *eth_link)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1207,7 +1236,7 @@ rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1227,7 +1256,7 @@ rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1244,7 +1273,7 @@ rte_eth_stats_reset(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1265,7 +1294,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,\n \tuint64_t val;\n \tchar *stats_ptr;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -1;\n \t}\n@@ -1334,7 +1363,7 @@ rte_eth_xstats_reset(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1356,7 +1385,7 @@ set_queue_stats_mapping(uint8_t port_id, uint16_t queue_id, uint8_t stat_idx,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -1391,7 +1420,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1411,7 +1440,7 @@ rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1425,7 +1454,7 @@ rte_eth_dev_get_mtu(uint8_t port_id, uint16_t *mtu)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1441,7 +1470,7 @@ rte_eth_dev_set_mtu(uint8_t port_id, uint16_t mtu)\n \tint ret;\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1461,7 +1490,7 @@ rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id, int on)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1486,7 +1515,7 @@ rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_id, uint16_t rx_queue_id, int o\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1508,7 +1537,7 @@ rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tpid)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1528,7 +1557,7 @@ rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)\n \tint mask = 0;\n \tint cur, org = 0;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1573,7 +1602,7 @@ rte_eth_dev_get_vlan_offload(uint8_t port_id)\n \tstruct rte_eth_dev *dev;\n \tint ret = 0;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1597,7 +1626,7 @@ rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1615,7 +1644,7 @@ rte_eth_dev_fdir_add_signature_filter(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1649,7 +1678,7 @@ rte_eth_dev_fdir_update_signature_filter(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1683,7 +1712,7 @@ rte_eth_dev_fdir_remove_signature_filter(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1714,7 +1743,7 @@ rte_eth_dev_fdir_get_infos(uint8_t port_id, struct rte_eth_fdir *fdir)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1739,7 +1768,7 @@ rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1779,7 +1808,7 @@ rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1817,7 +1846,7 @@ rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1853,7 +1882,7 @@ rte_eth_dev_fdir_set_masks(uint8_t port_id, struct rte_fdir_masks *fdir_mask)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1873,7 +1902,7 @@ rte_eth_dev_flow_ctrl_get(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1889,7 +1918,7 @@ rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1909,7 +1938,7 @@ rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, struct rte_eth_pfc_conf *pfc\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1933,7 +1962,7 @@ rte_eth_dev_rss_reta_update(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)\n \tuint16_t max_rxq;\n \tuint8_t i,j;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1985,7 +2014,7 @@ rte_eth_dev_rss_reta_query(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2006,7 +2035,7 @@ rte_eth_dev_rss_hash_update(uint8_t port_id, struct rte_eth_rss_conf *rss_conf)\n \tstruct rte_eth_dev *dev;\n \tuint16_t rss_hash_protos;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2028,7 +2057,7 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2043,7 +2072,7 @@ rte_eth_dev_udp_tunnel_add(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -2069,7 +2098,7 @@ rte_eth_dev_udp_tunnel_delete(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -2094,7 +2123,7 @@ rte_eth_led_on(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2109,7 +2138,7 @@ rte_eth_led_off(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2149,7 +2178,7 @@ rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,\n \tint index;\n \tuint64_t pool_mask;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2200,7 +2229,7 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)\n \tstruct rte_eth_dev *dev;\n \tint index;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2231,7 +2260,7 @@ rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,\n \tstruct rte_eth_dev *dev;\n \tstruct rte_eth_dev_info dev_info;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"set VF RX mode:Invalid port_id=%d\\n\",\n \t\t\t\tport_id);\n \t\treturn (-ENODEV);\n@@ -2286,7 +2315,7 @@ rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,\n \tint ret;\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"unicast hash setting:Invalid port_id=%d\\n\",\n \t\t\tport_id);\n \t\treturn (-ENODEV);\n@@ -2339,7 +2368,7 @@ rte_eth_dev_uc_all_hash_table_set(uint8_t port_id, uint8_t on)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"unicast hash setting:Invalid port_id=%d\\n\",\n \t\t\tport_id);\n \t\treturn (-ENODEV);\n@@ -2358,7 +2387,7 @@ rte_eth_dev_set_vf_rx(uint8_t port_id,uint16_t vf, uint8_t on)\n \tstruct rte_eth_dev *dev;\n \tstruct rte_eth_dev_info dev_info;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2384,7 +2413,7 @@ rte_eth_dev_set_vf_tx(uint8_t port_id,uint16_t vf, uint8_t on)\n \tstruct rte_eth_dev *dev;\n \tstruct rte_eth_dev_info dev_info;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"set pool tx:Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2409,7 +2438,7 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"VF VLAN filter:invalid port id=%d\\n\",\n \t\t\t\tport_id);\n \t\treturn (-ENODEV);\n@@ -2440,7 +2469,7 @@ int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,\n \tstruct rte_eth_dev_info dev_info;\n \tstruct rte_eth_link link;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"set queue rate limit:invalid port id=%d\\n\",\n \t\t\t\tport_id);\n \t\treturn -ENODEV;\n@@ -2477,7 +2506,7 @@ int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf, uint16_t tx_rate,\n \tif (q_msk == 0)\n \t\treturn 0;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"set VF rate limit:invalid port id=%d\\n\",\n \t\t\t\tport_id);\n \t\treturn -ENODEV;\n@@ -2511,7 +2540,7 @@ rte_eth_mirror_rule_set(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2552,7 +2581,7 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)\n {\n \tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2577,7 +2606,7 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn 0;\n \t}\n@@ -2597,7 +2626,7 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn 0;\n \t}\n@@ -2617,7 +2646,7 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn 0;\n \t}\n@@ -2631,7 +2660,7 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2652,7 +2681,7 @@ rte_eth_dev_callback_register(uint8_t port_id,\n \n \tif (!cb_fn)\n \t\treturn (-EINVAL);\n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -2692,7 +2721,7 @@ rte_eth_dev_callback_unregister(uint8_t port_id,\n \n \tif (!cb_fn)\n \t\treturn (-EINVAL);\n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -2752,7 +2781,7 @@ int rte_eth_dev_bypass_init(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2772,7 +2801,7 @@ rte_eth_dev_bypass_state_show(uint8_t port_id, uint32_t *state)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2791,7 +2820,7 @@ rte_eth_dev_bypass_state_set(uint8_t port_id, uint32_t *new_state)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2811,7 +2840,7 @@ rte_eth_dev_bypass_event_show(uint8_t port_id, uint32_t event, uint32_t *state)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2831,7 +2860,7 @@ rte_eth_dev_bypass_event_store(uint8_t port_id, uint32_t event, uint32_t state)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2851,7 +2880,7 @@ rte_eth_dev_wd_timeout_store(uint8_t port_id, uint32_t timeout)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2871,7 +2900,7 @@ rte_eth_dev_bypass_ver_show(uint8_t port_id, uint32_t *ver)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2891,7 +2920,7 @@ rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id, uint32_t *wd_timeout)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2911,7 +2940,7 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2933,7 +2962,7 @@ rte_eth_dev_add_syn_filter(uint8_t port_id,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -2948,7 +2977,7 @@ rte_eth_dev_remove_syn_filter(uint8_t port_id)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -2967,7 +2996,7 @@ rte_eth_dev_get_syn_filter(uint8_t port_id,\n \tif (filter == NULL || rx_queue == NULL)\n \t\treturn -EINVAL;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -2983,7 +3012,7 @@ rte_eth_dev_add_ethertype_filter(uint8_t port_id, uint16_t index,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3004,7 +3033,7 @@ rte_eth_dev_remove_ethertype_filter(uint8_t port_id,  uint16_t index)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3023,7 +3052,7 @@ rte_eth_dev_get_ethertype_filter(uint8_t port_id, uint16_t index,\n \tif (filter == NULL || rx_queue == NULL)\n \t\treturn -EINVAL;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3040,7 +3069,7 @@ rte_eth_dev_add_2tuple_filter(uint8_t port_id, uint16_t index,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3062,7 +3091,7 @@ rte_eth_dev_remove_2tuple_filter(uint8_t port_id, uint16_t index)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3081,7 +3110,7 @@ rte_eth_dev_get_2tuple_filter(uint8_t port_id, uint16_t index,\n \tif (filter == NULL || rx_queue == NULL)\n \t\treturn -EINVAL;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3097,7 +3126,7 @@ rte_eth_dev_add_5tuple_filter(uint8_t port_id, uint16_t index,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3120,7 +3149,7 @@ rte_eth_dev_remove_5tuple_filter(uint8_t port_id, uint16_t index)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3139,7 +3168,7 @@ rte_eth_dev_get_5tuple_filter(uint8_t port_id, uint16_t index,\n \tif (filter == NULL || rx_queue == NULL)\n \t\treturn -EINVAL;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3156,7 +3185,7 @@ rte_eth_dev_add_flex_filter(uint8_t port_id, uint16_t index,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3171,7 +3200,7 @@ rte_eth_dev_remove_flex_filter(uint8_t port_id, uint16_t index)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3190,7 +3219,7 @@ rte_eth_dev_get_flex_filter(uint8_t port_id, uint16_t index,\n \tif (filter == NULL || rx_queue == NULL)\n \t\treturn -EINVAL;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3206,7 +3235,7 @@ rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_type)\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3223,7 +3252,7 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,\n {\n \tstruct rte_eth_dev *dev;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id)) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\ndiff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h\nindex 8bf274d..5d3956a 100644\n--- a/lib/librte_ether/rte_ethdev.h\n+++ b/lib/librte_ether/rte_ethdev.h\n@@ -1534,6 +1534,7 @@ struct eth_dev_ops {\n  * process, while the actual configuration data for the device is shared.\n  */\n struct rte_eth_dev {\n+\tuint8_t attached; /**< Flag indicating the port is attached */\n \teth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function. */\n \teth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function. */\n \tstruct rte_eth_dev_data *data;  /**< Pointer to device data */\n@@ -1606,6 +1607,10 @@ extern struct rte_eth_dev rte_eth_devices[];\n  * initialized by the [matching] Ethernet driver during the PCI probing phase.\n  * All devices whose port identifier is in the range\n  * [0,  rte_eth_dev_count() - 1] can be operated on by network applications.\n+ * immediately after invoking rte_eal_init().\n+ * If the application unplugs a port using hotplug function, The enabled port\n+ * numbers may be noncontiguous. In the case, the applications need to manage\n+ * enabled port by themselves.\n  *\n  * @return\n  *   - The total number of usable Ethernet devices.\n",
    "prefixes": [
        "dpdk-dev",
        "RFC",
        "02/25"
    ]
}