get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1365,
    "url": "https://patches.dpdk.org/api/patches/1365/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1416474399-16851-3-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": "<1416474399-16851-3-git-send-email-mukawa@igel.co.jp>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1416474399-16851-3-git-send-email-mukawa@igel.co.jp",
    "date": "2014-11-20T09:06:16",
    "name": "[dpdk-dev,02/25] ethdev: Remove assumption that port will not be detached",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "17977834159a498f8c2a06dddad3c0b803e4e759",
    "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/1416474399-16851-3-git-send-email-mukawa@igel.co.jp/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/1365/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/1365/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 551D97F7C;\n\tThu, 20 Nov 2014 09:56:54 +0100 (CET)",
            "from mail-pd0-f169.google.com (mail-pd0-f169.google.com\n\t[209.85.192.169]) by dpdk.org (Postfix) with ESMTP id A44417F74\n\tfor <dev@dpdk.org>; Thu, 20 Nov 2014 09:56:50 +0100 (CET)",
            "by mail-pd0-f169.google.com with SMTP id fp1so2675692pdb.14\n\tfor <dev@dpdk.org>; Thu, 20 Nov 2014 01:07:19 -0800 (PST)",
            "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\ta6sm1432407pbu.64.2014.11.20.01.07.16 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tThu, 20 Nov 2014 01:07:18 -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=6/L27SXBoKLpE80/pgJRN5x6ZlBOuCVmah7sIqCSewk=;\n\tb=DpiakTM81zkrPcyzAw2ZJP5C2o1w0O7DRy2c65er35qJh/T0xlu0AIiAvGkdqiMchl\n\t3Alove/NYOe7movxT1/LcM0PnSvsaP1/HylrMDpOsAE/fJ6PuD/nd4bDmapCEQqahdBF\n\tJXBlrQJ9eBjfDHDyweVd1nN8skeHvI3LZ8/mpCLTVZJEeWh7r3v2eMcx5FUm/ZLIGmAt\n\tPXETmwhwdQazi+CsbgqBw9YwGYOjXHSiUTI2S/XEiYNm8OnqNhCx/w6gFyU/yl+Wb8Ld\n\twIDNB3KRPIrtrOEX573ubW77AXR2cKtQrlzgt2aO5Fv2HN24qnOGjyX2BaD2lfGsN6B9\n\tTP2Q==",
        "X-Gm-Message-State": "ALoCoQmpgLM8nloK0tD7FYdGlILKoRKYvqtaV3OgY7x7rGH0RUoJJQXQzK768BhPuq4VM3FfOJD9",
        "X-Received": "by 10.70.118.72 with SMTP id kk8mr28314763pdb.147.1416474439233; \n\tThu, 20 Nov 2014 01:07:19 -0800 (PST)",
        "From": "Tetsuya Mukawa <mukawa@igel.co.jp>",
        "To": "dev@dpdk.org",
        "Date": "Thu, 20 Nov 2014 18:06:16 +0900",
        "Message-Id": "<1416474399-16851-3-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1416474399-16851-1-git-send-email-mukawa@igel.co.jp>",
        "References": "<1414572576-21371-1-git-send-email-mukawa@igel.co.jp>\n\t<1416474399-16851-1-git-send-email-mukawa@igel.co.jp>",
        "Cc": "nakajima.yoshihiro@lab.ntt.co.jp, menrigh@brocade.com,\n\tmasutani.hitoshi@lab.ntt.co.jp",
        "Subject": "[dpdk-dev] [PATCH 02/25] ethdev: Remove assumption that port will\n\tnot 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- Add rte_eth_dev_allocate_new_port().\n  This function is used for allocating new port.\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n lib/librte_ether/rte_ethdev.c | 236 +++++++++++++++++++++++-------------------\n lib/librte_ether/rte_ethdev.h |   5 +\n 2 files changed, 136 insertions(+), 105 deletions(-)",
    "diff": "diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c\nindex 8c65d72..446c53a 100644\n--- a/lib/librte_ether/rte_ethdev.c\n+++ b/lib/librte_ether/rte_ethdev.c\n@@ -201,19 +201,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_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)\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 +240,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 = 1;\n+\tnb_ports++;\n \treturn eth_dev;\n }\n \n@@ -283,6 +299,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 = 0;\n \tnb_ports--;\n \treturn diag;\n }\n@@ -308,10 +325,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@@ -369,7 +395,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 +421,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 +447,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 +473,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 +688,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@@ -847,7 +873,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@@ -882,7 +908,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@@ -910,7 +936,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@@ -929,7 +955,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@@ -948,7 +974,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@@ -976,7 +1002,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@@ -1049,7 +1075,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@@ -1082,7 +1108,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@@ -1098,7 +1124,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@@ -1114,7 +1140,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@@ -1128,7 +1154,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@@ -1144,7 +1170,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@@ -1160,7 +1186,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@@ -1188,7 +1214,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@@ -1208,7 +1234,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@@ -1228,7 +1254,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@@ -1245,7 +1271,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@@ -1266,7 +1292,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@@ -1335,7 +1361,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@@ -1357,7 +1383,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@@ -1392,7 +1418,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@@ -1412,7 +1438,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@@ -1426,7 +1452,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@@ -1442,7 +1468,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@@ -1462,7 +1488,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@@ -1487,7 +1513,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@@ -1509,7 +1535,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@@ -1529,7 +1555,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@@ -1574,7 +1600,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@@ -1598,7 +1624,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@@ -1616,7 +1642,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@@ -1650,7 +1676,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@@ -1684,7 +1710,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@@ -1715,7 +1741,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@@ -1740,7 +1766,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@@ -1780,7 +1806,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@@ -1818,7 +1844,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@@ -1854,7 +1880,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@@ -1874,7 +1900,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@@ -1890,7 +1916,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@@ -1910,7 +1936,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@@ -1934,7 +1960,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@@ -1986,7 +2012,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@@ -2007,7 +2033,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@@ -2029,7 +2055,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@@ -2044,7 +2070,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@@ -2070,7 +2096,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@@ -2095,7 +2121,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@@ -2110,7 +2136,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@@ -2150,7 +2176,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@@ -2201,7 +2227,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@@ -2235,7 +2261,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@@ -2290,7 +2316,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@@ -2343,7 +2369,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@@ -2362,7 +2388,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@@ -2388,7 +2414,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@@ -2413,7 +2439,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@@ -2444,7 +2470,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@@ -2481,7 +2507,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@@ -2515,7 +2541,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@@ -2556,7 +2582,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@@ -2581,7 +2607,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@@ -2601,7 +2627,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@@ -2621,7 +2647,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@@ -2635,7 +2661,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@@ -2656,7 +2682,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@@ -2696,7 +2722,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@@ -2756,7 +2782,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@@ -2776,7 +2802,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@@ -2795,7 +2821,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@@ -2815,7 +2841,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@@ -2835,7 +2861,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@@ -2855,7 +2881,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@@ -2875,7 +2901,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@@ -2895,7 +2921,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@@ -2915,7 +2941,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@@ -2937,7 +2963,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@@ -2952,7 +2978,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@@ -2971,7 +2997,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@@ -2987,7 +3013,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@@ -3008,7 +3034,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@@ -3027,7 +3053,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@@ -3044,7 +3070,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@@ -3066,7 +3092,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@@ -3085,7 +3111,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@@ -3101,7 +3127,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@@ -3124,7 +3150,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@@ -3143,7 +3169,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@@ -3160,7 +3186,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@@ -3175,7 +3201,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@@ -3194,7 +3220,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@@ -3210,7 +3236,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@@ -3227,7 +3253,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 c29525b..2cd1c43 100644\n--- a/lib/librte_ether/rte_ethdev.h\n+++ b/lib/librte_ether/rte_ethdev.h\n@@ -1554,6 +1554,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@@ -1626,6 +1627,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",
        "02/25"
    ]
}