get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2366,
    "url": "https://patches.dpdk.org/api/patches/2366/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1421664027-17971-2-git-send-email-mukawa@igel.co.jp/",
    "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": "<1421664027-17971-2-git-send-email-mukawa@igel.co.jp>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1421664027-17971-2-git-send-email-mukawa@igel.co.jp",
    "date": "2015-01-19T10:40:17",
    "name": "[dpdk-dev,v4,01/11] eal/pci, ethdev: Remove assumption that port will not be detached",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "e527c717207c0be9e2f029c1bdb59eeb25c85b7e",
    "submitter": {
        "id": 64,
        "url": "https://patches.dpdk.org/api/people/64/?format=api",
        "name": "Tetsuya Mukawa",
        "email": "mukawa@igel.co.jp"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1421664027-17971-2-git-send-email-mukawa@igel.co.jp/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/2366/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/2366/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 AE1815AA9;\n\tMon, 19 Jan 2015 11:41:19 +0100 (CET)",
            "from mail-pd0-f176.google.com (mail-pd0-f176.google.com\n\t[209.85.192.176]) by dpdk.org (Postfix) with ESMTP id 920DA5A9B\n\tfor <dev@dpdk.org>; Mon, 19 Jan 2015 11:41:10 +0100 (CET)",
            "by mail-pd0-f176.google.com with SMTP id r10so35921728pdi.7\n\tfor <dev@dpdk.org>; Mon, 19 Jan 2015 02:41:09 -0800 (PST)",
            "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\ta13sm11337588pdm.44.2015.01.19.02.41.07\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tMon, 19 Jan 2015 02:41:08 -0800 (PST)"
        ],
        "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=2tJnxluzWFBhUP/vL1gd3LBx/7HnImoOW/EJTETENlQ=;\n\tb=aRhKAV6cPqrSFrkZDAM+3nmtFTdq1dkaaaHEtT7d8cZohnp90+5eCjxGrEowdsrosh\n\tGoJ0fK32JrDLtv/A6bdZ/JTBhn9LoVRM2eQXWE0joJGDM2a/VBKwAZg3uWsJnp+k1mx+\n\tc3/79CGIJqmolCwx8Qp/lnxU0KTf4PS+QEKS4c/yKfJGPXgsju79Lk8drrk9hj5038/w\n\tHZP7ogRJ7uPGj0ldfOSEIwYp0/yw9Kam+TC/ybUJkHAo2nFlwhWj5U0ETod3EJb+VQqR\n\tbpvaPmsQ0cwEiCrkHeAT0kiP6xeuIpDVioXkIq6287LK3o0XkZOJvH9EFZd2DMOcqVq3\n\tBstQ==",
        "X-Gm-Message-State": "ALoCoQngHSr1ba725J3IC5uXbgAh7b2tTJxWy1CZRNWWfdy3VQjgIdAiY2T7jQJNPTxgRP6oedxX",
        "X-Received": "by 10.66.97.97 with SMTP id dz1mr16257148pab.90.1421664069875;\n\tMon, 19 Jan 2015 02:41:09 -0800 (PST)",
        "From": "Tetsuya Mukawa <mukawa@igel.co.jp>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 19 Jan 2015 19:40:17 +0900",
        "Message-Id": "<1421664027-17971-2-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1421664027-17971-1-git-send-email-mukawa@igel.co.jp>",
        "References": "<1418106629-22227-2-git-send-email-mukawa@igel.co.j>\n\t<1421664027-17971-1-git-send-email-mukawa@igel.co.jp>",
        "Subject": "[dpdk-dev] [PATCH v4 01/11] eal/pci,\n\tethdev: Remove assumption that port will 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\nThis patch adds \"RTE_PCI_DRV_DETACHABLE\" to drv_flags of rte_pci_driver\nstructure. The flags indicates the driver can detach devices at runtime.\nAlso remove assumption that port will not be detached.\n\nTo remove the assumption.\n- Add 'attached' member to rte_eth_dev structure.\n  This member is used for indicating the port is attached, or not.\n- Add rte_eth_dev_allocate_new_port().\n  This function is used for allocating new port.\n\nv4:\n- Use braces with 'for' loop.\n- Fix indent of 'if' statement.\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n lib/librte_eal/common/include/rte_pci.h |   2 +\n lib/librte_ether/rte_ethdev.c           | 248 ++++++++++++++++++--------------\n lib/librte_ether/rte_ethdev.h           |   5 +\n 3 files changed, 151 insertions(+), 104 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h\nindex 66ed793..dd1da28 100644\n--- a/lib/librte_eal/common/include/rte_pci.h\n+++ b/lib/librte_eal/common/include/rte_pci.h\n@@ -199,6 +199,8 @@ struct rte_pci_driver {\n #define RTE_PCI_DRV_FORCE_UNBIND 0x0004\n /** Device driver supports link state interrupt */\n #define RTE_PCI_DRV_INTR_LSC\t0x0008\n+/** Device driver supports detaching capability */\n+#define RTE_PCI_DRV_DETACHABLE\t0x0010\n \n /**< Internal use only - Macro used by pci addr parsing functions **/\n #define GET_PCIADDR_FIELD(in, fd, lim, dlm)                   \\\ndiff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c\nindex 077d430..46cabaf 100644\n--- a/lib/librte_ether/rte_ethdev.c\n+++ b/lib/librte_ether/rte_ethdev.c\n@@ -175,6 +175,16 @@ enum {\n \tSTAT_QMAP_RX\n };\n \n+enum {\n+\tDEV_INVALID = 0,\n+\tDEV_VALID,\n+};\n+\n+enum {\n+\tDEV_DISCONNECTED = 0,\n+\tDEV_CONNECTED\n+};\n+\n static inline void\n rte_eth_dev_data_alloc(void)\n {\n@@ -201,19 +211,34 @@ 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 == DEV_CONNECTED) &&\n+\t\t    strcmp(rte_eth_devices[i].data->name, name) == 0)\n \t\t\treturn &rte_eth_devices[i];\n \t}\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 == DEV_DISCONNECTED)\n+\t\t\treturn i;\n+\t}\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 +251,12 @@ 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 = DEV_CONNECTED;\n+\tnb_ports++;\n \treturn eth_dev;\n }\n \n@@ -283,6 +310,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+\teth_dev->attached = DEV_DISCONNECTED;\n \tnb_ports--;\n \treturn diag;\n }\n@@ -308,10 +336,22 @@ 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 DEV_INVALID;\n+\n+\tif (rte_eth_devices[port_id].attached == DEV_CONNECTED)\n+\t\treturn DEV_VALID;\n+\telse\n+\t\treturn DEV_INVALID;\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) == DEV_INVALID)\n \t\treturn -1;\n \treturn rte_eth_devices[port_id].pci_dev->numa_node;\n }\n@@ -369,7 +409,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -395,7 +435,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -421,7 +461,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -447,7 +487,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -703,7 +743,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -888,7 +928,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%\" PRIu8 \"\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -923,7 +963,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%\" PRIu8 \"\\n\", port_id);\n \t\treturn;\n \t}\n@@ -951,7 +991,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -970,7 +1010,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -EINVAL;\n \t}\n@@ -989,7 +1029,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1017,7 +1057,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -1090,7 +1130,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -1123,7 +1163,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1139,7 +1179,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1155,7 +1195,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -1;\n \t}\n@@ -1169,7 +1209,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1185,7 +1225,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1201,7 +1241,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -1;\n \t}\n@@ -1229,7 +1269,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1249,7 +1289,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1269,7 +1309,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1286,7 +1326,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1307,7 +1347,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -1;\n \t}\n@@ -1376,7 +1416,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1398,7 +1438,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -1433,7 +1473,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1453,7 +1493,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn;\n \t}\n@@ -1467,7 +1507,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1483,7 +1523,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1503,7 +1543,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1528,7 +1568,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1550,7 +1590,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1570,7 +1610,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1615,7 +1655,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1639,7 +1679,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1657,7 +1697,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1691,7 +1731,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1725,7 +1765,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1756,7 +1796,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1781,7 +1821,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1821,7 +1861,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1859,7 +1899,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1895,7 +1935,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1915,7 +1955,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1931,7 +1971,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -1951,7 +1991,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2030,7 +2070,7 @@ rte_eth_dev_rss_reta_update(uint8_t port_id,\n \tstruct rte_eth_dev *dev;\n \tint ret;\n \n-\tif (port_id >= nb_ports) {\n+\tif (rte_eth_dev_validate_port(port_id) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -2081,7 +2121,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2103,7 +2143,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2118,7 +2158,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -2144,7 +2184,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -2169,7 +2209,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2184,7 +2224,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2224,7 +2264,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2275,7 +2315,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2309,7 +2349,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) == DEV_INVALID) {\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@@ -2364,7 +2404,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"unicast hash setting:Invalid port_id=%d\\n\",\n \t\t\tport_id);\n \t\treturn (-ENODEV);\n@@ -2417,7 +2457,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"unicast hash setting:Invalid port_id=%d\\n\",\n \t\t\tport_id);\n \t\treturn (-ENODEV);\n@@ -2436,7 +2476,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2462,7 +2502,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"set pool tx:Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2487,7 +2527,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"VF VLAN filter:invalid port id=%d\\n\",\n \t\t\t\tport_id);\n \t\treturn (-ENODEV);\n@@ -2518,7 +2558,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) == DEV_INVALID) {\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@@ -2555,7 +2595,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) == DEV_INVALID) {\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@@ -2589,7 +2629,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2630,7 +2670,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2655,7 +2695,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn 0;\n \t}\n@@ -2675,7 +2715,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn 0;\n \t}\n@@ -2695,7 +2735,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn 0;\n \t}\n@@ -2709,7 +2749,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2730,7 +2770,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -2770,7 +2810,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-EINVAL);\n \t}\n@@ -2830,7 +2870,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2850,7 +2890,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2869,7 +2909,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2889,7 +2929,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2909,7 +2949,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2929,7 +2969,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2949,7 +2989,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2969,7 +3009,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -2989,7 +3029,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn (-ENODEV);\n \t}\n@@ -3011,7 +3051,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3026,7 +3066,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3045,7 +3085,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3061,7 +3101,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3082,7 +3122,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3101,7 +3141,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3118,7 +3158,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3140,7 +3180,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3159,7 +3199,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3175,7 +3215,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3198,7 +3238,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3217,7 +3257,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3234,7 +3274,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3249,7 +3289,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3268,7 +3308,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3284,7 +3324,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) == DEV_INVALID) {\n \t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n \t\treturn -ENODEV;\n \t}\n@@ -3301,7 +3341,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) == DEV_INVALID) {\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 ce0528f..616a44a 100644\n--- a/lib/librte_ether/rte_ethdev.h\n+++ b/lib/librte_ether/rte_ethdev.h\n@@ -1565,6 +1565,7 @@ struct rte_eth_dev {\n \tstruct eth_dev_ops *dev_ops;    /**< Functions exported by PMD */\n \tstruct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */\n \tstruct rte_eth_dev_cb_list callbacks; /**< User application callbacks */\n+\tuint8_t attached; /**< Flag indicating the port is attached */\n };\n \n struct rte_eth_dev_sriov {\n@@ -1630,6 +1631,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",
        "v4",
        "01/11"
    ]
}