From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id E29C52A9 for ; Tue, 9 Dec 2014 06:08:01 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 08 Dec 2014 21:08:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,542,1413270000"; d="scan'208";a="634796696" Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98]) by fmsmga001.fm.intel.com with ESMTP; 08 Dec 2014 21:07:58 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.110.14) by pgsmsx106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 9 Dec 2014 13:07:54 +0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.182]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.240]) with mapi id 14.03.0195.001; Tue, 9 Dec 2014 13:07:53 +0800 From: "Zhang, Helin" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2 02/28] ethdev: Remove assumption that port will not be detached Thread-Index: AQHQE2JaFWudc3hqSUa5rp3FhhEdLpyGs2FQ Date: Tue, 9 Dec 2014 05:07:52 +0000 Message-ID: References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418096571-27531-1-git-send-email-mukawa@igel.co.jp> <1418096571-27531-3-git-send-email-mukawa@igel.co.jp> In-Reply-To: <1418096571-27531-3-git-send-email-mukawa@igel.co.jp> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "nakajima.yoshihiro@lab.ntt.co.jp" , "masutani.hitoshi@lab.ntt.co.jp" , "menrigh@brocade.com" Subject: Re: [dpdk-dev] [PATCH v2 02/28] ethdev: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Dec 2014 05:08:06 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tetsuya Mukawa > Sent: Tuesday, December 9, 2014 11:42 AM > To: dev@dpdk.org > Cc: nakajima.yoshihiro@lab.ntt.co.jp; menrigh@brocade.com; > masutani.hitoshi@lab.ntt.co.jp > Subject: [dpdk-dev] [PATCH v2 02/28] ethdev: Remove assumption that port = will > not be detached >=20 > To remove assumption, do like followings. >=20 > - Add 'attached' member to rte_eth_dev structure. > This member is used for indicating the port is attached, or not. > - Add rte_eth_dev_allocate_new_port(). > This function is used for allocating new port. >=20 > Signed-off-by: Tetsuya Mukawa > --- > lib/librte_ether/rte_ethdev.c | 248 ++++++++++++++++++++++++------------= ------ > lib/librte_ether/rte_ethdev.h | 5 + > 2 files changed, 149 insertions(+), 104 deletions(-) >=20 > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= c index > 95f2ceb..9f713ae 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -175,6 +175,16 @@ enum { > STAT_QMAP_RX > }; >=20 > +enum { > + DEV_VALID =3D 0, > + DEV_INVALID > +}; Would it be safer to define DEV_INVALID =3D 0, then DEV_VALID after it? Or even as below? Enum { DEV_UNKNOWN =3D 0, DEV_VALID, DEV_INVALID }; Regards, Helin > + > +enum { > + DEV_DISCONNECTED =3D 0, > + DEV_CONNECTED > +}; > + > static inline void > rte_eth_dev_data_alloc(void) > { > @@ -201,19 +211,34 @@ rte_eth_dev_allocated(const char *name) { > unsigned i; >=20 > - for (i =3D 0; i < nb_ports; i++) { > - if (strcmp(rte_eth_devices[i].data->name, name) =3D=3D 0) > + for (i =3D 0; i < RTE_MAX_ETHPORTS; i++) { > + if ((rte_eth_devices[i].attached =3D=3D DEV_CONNECTED) > + && strcmp(rte_eth_devices[i].data->name, > + name) =3D=3D 0) > return &rte_eth_devices[i]; > } > return NULL; > } >=20 > +static uint8_t > +rte_eth_dev_allocate_new_port(void) > +{ > + unsigned i; > + > + for (i =3D 0; i < RTE_MAX_ETHPORTS; i++) > + if (rte_eth_devices[i].attached =3D=3D DEV_DISCONNECTED) > + return i; > + return RTE_MAX_ETHPORTS; > +} > + > struct rte_eth_dev * > rte_eth_dev_allocate(const char *name) > { > + uint8_t port_id; > struct rte_eth_dev *eth_dev; >=20 > - if (nb_ports =3D=3D RTE_MAX_ETHPORTS) { > + port_id =3D rte_eth_dev_allocate_new_port(); > + if (port_id =3D=3D RTE_MAX_ETHPORTS) { > PMD_DEBUG_TRACE("Reached maximum number of Ethernet > ports\n"); > return NULL; > } > @@ -226,10 +251,12 @@ rte_eth_dev_allocate(const char *name) > return NULL; > } >=20 > - eth_dev =3D &rte_eth_devices[nb_ports]; > - eth_dev->data =3D &rte_eth_dev_data[nb_ports]; > + eth_dev =3D &rte_eth_devices[port_id]; > + eth_dev->data =3D &rte_eth_dev_data[port_id]; > snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", > name); > - eth_dev->data->port_id =3D nb_ports++; > + eth_dev->data->port_id =3D port_id; > + eth_dev->attached =3D DEV_CONNECTED; > + nb_ports++; > return eth_dev; > } >=20 > @@ -283,6 +310,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv, > (unsigned) pci_dev->id.device_id); > if (rte_eal_process_type() =3D=3D RTE_PROC_PRIMARY) > rte_free(eth_dev->data->dev_private); > + eth_dev->attached =3D DEV_DISCONNECTED; > nb_ports--; > return diag; > } > @@ -308,10 +336,22 @@ rte_eth_driver_register(struct eth_driver *eth_drv) > rte_eal_pci_register(ð_drv->pci_drv); > } >=20 > +static int > +rte_eth_dev_validate_port(uint8_t port_id) { > + if (port_id >=3D RTE_MAX_ETHPORTS) > + return DEV_INVALID; > + > + if (rte_eth_devices[port_id].attached =3D=3D DEV_CONNECTED) > + return DEV_VALID; > + else > + return DEV_INVALID; > +} > + > int > rte_eth_dev_socket_id(uint8_t port_id) > { > - if (port_id >=3D nb_ports) > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) > return -1; > return rte_eth_devices[port_id].pci_dev->numa_node; > } > @@ -369,7 +409,7 @@ rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t > rx_queue_id) > * in a multi-process setup*/ > PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY); >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -EINVAL; > } > @@ -395,7 +435,7 @@ rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t > rx_queue_id) > * in a multi-process setup*/ > PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY); >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -EINVAL; > } > @@ -421,7 +461,7 @@ rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t > tx_queue_id) > * in a multi-process setup*/ > PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY); >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -EINVAL; > } > @@ -447,7 +487,7 @@ rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t > tx_queue_id) > * in a multi-process setup*/ > PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY); >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -EINVAL; > } > @@ -662,7 +702,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t > nb_rx_q, uint16_t nb_tx_q, > * in a multi-process setup*/ > PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY); >=20 > - if (port_id >=3D nb_ports || port_id >=3D RTE_MAX_ETHPORTS) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-EINVAL); > } > @@ -847,7 +887,7 @@ rte_eth_dev_start(uint8_t port_id) > * in a multi-process setup*/ > PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY); >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%" PRIu8 "\n", port_id); > return (-EINVAL); > } > @@ -882,7 +922,7 @@ rte_eth_dev_stop(uint8_t port_id) > * in a multi-process setup*/ > PROC_PRIMARY_OR_RET(); >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%" PRIu8 "\n", port_id); > return; > } > @@ -910,7 +950,7 @@ rte_eth_dev_set_link_up(uint8_t port_id) > * in a multi-process setup*/ > PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY); >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -EINVAL; > } > @@ -929,7 +969,7 @@ rte_eth_dev_set_link_down(uint8_t port_id) > * in a multi-process setup*/ > PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY); >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -EINVAL; > } > @@ -948,7 +988,7 @@ rte_eth_dev_close(uint8_t port_id) > * in a multi-process setup*/ > PROC_PRIMARY_OR_RET(); >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -976,7 +1016,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t > rx_queue_id, > * in a multi-process setup*/ > PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY); >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-EINVAL); > } > @@ -1049,7 +1089,7 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t > tx_queue_id, > * in a multi-process setup*/ > PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY); >=20 > - if (port_id >=3D RTE_MAX_ETHPORTS || port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-EINVAL); > } > @@ -1082,7 +1122,7 @@ rte_eth_promiscuous_enable(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1098,7 +1138,7 @@ rte_eth_promiscuous_disable(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1114,7 +1154,7 @@ rte_eth_promiscuous_get(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -1; > } > @@ -1128,7 +1168,7 @@ rte_eth_allmulticast_enable(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1144,7 +1184,7 @@ rte_eth_allmulticast_disable(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1160,7 +1200,7 @@ rte_eth_allmulticast_get(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -1; > } > @@ -1188,7 +1228,7 @@ rte_eth_link_get(uint8_t port_id, struct > rte_eth_link *eth_link) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1208,7 +1248,7 @@ rte_eth_link_get_nowait(uint8_t port_id, struct > rte_eth_link *eth_link) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1228,7 +1268,7 @@ rte_eth_stats_get(uint8_t port_id, struct > rte_eth_stats *stats) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1245,7 +1285,7 @@ rte_eth_stats_reset(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1266,7 +1306,7 @@ rte_eth_xstats_get(uint8_t port_id, struct > rte_eth_xstats *xstats, > uint64_t val; > char *stats_ptr; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -1; > } > @@ -1335,7 +1375,7 @@ rte_eth_xstats_reset(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1357,7 +1397,7 @@ set_queue_stats_mapping(uint8_t port_id, uint16_t > queue_id, uint8_t stat_idx, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -1392,7 +1432,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct > rte_eth_dev_info *dev_info) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1412,7 +1452,7 @@ rte_eth_macaddr_get(uint8_t port_id, struct > ether_addr *mac_addr) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return; > } > @@ -1426,7 +1466,7 @@ rte_eth_dev_get_mtu(uint8_t port_id, uint16_t > *mtu) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1442,7 +1482,7 @@ rte_eth_dev_set_mtu(uint8_t port_id, uint16_t > mtu) > int ret; > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1462,7 +1502,7 @@ rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t > vlan_id, int on) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1487,7 +1527,7 @@ rte_eth_dev_set_vlan_strip_on_queue(uint8_t > port_id, uint16_t rx_queue_id, int o { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1509,7 +1549,7 @@ rte_eth_dev_set_vlan_ether_type(uint8_t port_id, > uint16_t tpid) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1529,7 +1569,7 @@ rte_eth_dev_set_vlan_offload(uint8_t port_id, int > offload_mask) > int mask =3D 0; > int cur, org =3D 0; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1574,7 +1614,7 @@ rte_eth_dev_get_vlan_offload(uint8_t port_id) > struct rte_eth_dev *dev; > int ret =3D 0; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1598,7 +1638,7 @@ rte_eth_dev_set_vlan_pvid(uint8_t port_id, > uint16_t pvid, int on) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1616,7 +1656,7 @@ rte_eth_dev_fdir_add_signature_filter(uint8_t > port_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1650,7 +1690,7 @@ rte_eth_dev_fdir_update_signature_filter(uint8_t > port_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1684,7 +1724,7 @@ rte_eth_dev_fdir_remove_signature_filter(uint8_t > port_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1715,7 +1755,7 @@ rte_eth_dev_fdir_get_infos(uint8_t port_id, struct > rte_eth_fdir *fdir) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1740,7 +1780,7 @@ rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id= , > { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1780,7 +1820,7 @@ rte_eth_dev_fdir_update_perfect_filter(uint8_t > port_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1818,7 +1858,7 @@ rte_eth_dev_fdir_remove_perfect_filter(uint8_t > port_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1854,7 +1894,7 @@ rte_eth_dev_fdir_set_masks(uint8_t port_id, struct > rte_fdir_masks *fdir_mask) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1874,7 +1914,7 @@ rte_eth_dev_flow_ctrl_get(uint8_t port_id, struct > rte_eth_fc_conf *fc_conf) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1890,7 +1930,7 @@ rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct > rte_eth_fc_conf *fc_conf) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -1910,7 +1950,7 @@ rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, > struct rte_eth_pfc_conf *pfc { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2019,7 +2059,7 @@ rte_eth_dev_rss_reta_query(uint8_t port_id, > struct rte_eth_dev *dev; > int ret; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -2040,7 +2080,7 @@ rte_eth_dev_rss_hash_update(uint8_t port_id, > struct rte_eth_rss_conf *rss_conf) > struct rte_eth_dev *dev; > uint16_t rss_hash_protos; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2062,7 +2102,7 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2077,7 +2117,7 @@ rte_eth_dev_udp_tunnel_add(uint8_t port_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -2103,7 +2143,7 @@ rte_eth_dev_udp_tunnel_delete(uint8_t port_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -2128,7 +2168,7 @@ rte_eth_led_on(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2143,7 +2183,7 @@ rte_eth_led_off(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2183,7 +2223,7 @@ rte_eth_dev_mac_addr_add(uint8_t port_id, struct > ether_addr *addr, > int index; > uint64_t pool_mask; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2234,7 +2274,7 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, > struct ether_addr *addr) > struct rte_eth_dev *dev; > int index; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2268,7 +2308,7 @@ rte_eth_dev_set_vf_rxmode(uint8_t port_id, > uint16_t vf, > struct rte_eth_dev *dev; > struct rte_eth_dev_info dev_info; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("set VF RX mode:Invalid port_id=3D%d\n", > port_id); > return (-ENODEV); > @@ -2323,7 +2363,7 @@ rte_eth_dev_uc_hash_table_set(uint8_t port_id, > struct ether_addr *addr, > int ret; > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=3D%d\n", > port_id); > return (-ENODEV); > @@ -2376,7 +2416,7 @@ rte_eth_dev_uc_all_hash_table_set(uint8_t port_id, > uint8_t on) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=3D%d\n", > port_id); > return (-ENODEV); > @@ -2395,7 +2435,7 @@ rte_eth_dev_set_vf_rx(uint8_t port_id,uint16_t vf, > uint8_t on) > struct rte_eth_dev *dev; > struct rte_eth_dev_info dev_info; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2421,7 +2461,7 @@ rte_eth_dev_set_vf_tx(uint8_t port_id,uint16_t vf, > uint8_t on) > struct rte_eth_dev *dev; > struct rte_eth_dev_info dev_info; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("set pool tx:Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2446,7 +2486,7 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, > uint16_t vlan_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("VF VLAN filter:invalid port id=3D%d\n", > port_id); > return (-ENODEV); > @@ -2477,7 +2517,7 @@ int rte_eth_set_queue_rate_limit(uint8_t port_id, > uint16_t queue_idx, > struct rte_eth_dev_info dev_info; > struct rte_eth_link link; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("set queue rate limit:invalid port id=3D%d\n", > port_id); > return -ENODEV; > @@ -2514,7 +2554,7 @@ int rte_eth_set_vf_rate_limit(uint8_t port_id, > uint16_t vf, uint16_t tx_rate, > if (q_msk =3D=3D 0) > return 0; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("set VF rate limit:invalid port id=3D%d\n", > port_id); > return -ENODEV; > @@ -2548,7 +2588,7 @@ rte_eth_mirror_rule_set(uint8_t port_id, { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2589,7 +2629,7 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t > rule_id) { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2614,7 +2654,7 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t > queue_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return 0; > } > @@ -2634,7 +2674,7 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t > queue_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return 0; > } > @@ -2654,7 +2694,7 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t > queue_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return 0; > } > @@ -2668,7 +2708,7 @@ rte_eth_rx_descriptor_done(uint8_t port_id, > uint16_t queue_id, uint16_t offset) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2689,7 +2729,7 @@ rte_eth_dev_callback_register(uint8_t port_id, >=20 > if (!cb_fn) > return (-EINVAL); > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-EINVAL); > } > @@ -2729,7 +2769,7 @@ rte_eth_dev_callback_unregister(uint8_t port_id, >=20 > if (!cb_fn) > return (-EINVAL); > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-EINVAL); > } > @@ -2789,7 +2829,7 @@ int rte_eth_dev_bypass_init(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2809,7 +2849,7 @@ rte_eth_dev_bypass_state_show(uint8_t port_id, > uint32_t *state) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2828,7 +2868,7 @@ rte_eth_dev_bypass_state_set(uint8_t port_id, > uint32_t *new_state) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2848,7 +2888,7 @@ rte_eth_dev_bypass_event_show(uint8_t port_id, > uint32_t event, uint32_t *state) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2868,7 +2908,7 @@ rte_eth_dev_bypass_event_store(uint8_t port_id, > uint32_t event, uint32_t state) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2888,7 +2928,7 @@ rte_eth_dev_wd_timeout_store(uint8_t port_id, > uint32_t timeout) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2908,7 +2948,7 @@ rte_eth_dev_bypass_ver_show(uint8_t port_id, > uint32_t *ver) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2928,7 +2968,7 @@ rte_eth_dev_bypass_wd_timeout_show(uint8_t > port_id, uint32_t *wd_timeout) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2948,7 +2988,7 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return (-ENODEV); > } > @@ -2970,7 +3010,7 @@ rte_eth_dev_add_syn_filter(uint8_t port_id, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -2985,7 +3025,7 @@ rte_eth_dev_remove_syn_filter(uint8_t port_id) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3004,7 +3044,7 @@ rte_eth_dev_get_syn_filter(uint8_t port_id, > if (filter =3D=3D NULL || rx_queue =3D=3D NULL) > return -EINVAL; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3020,7 +3060,7 @@ rte_eth_dev_add_ethertype_filter(uint8_t port_id, > uint16_t index, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3041,7 +3081,7 @@ rte_eth_dev_remove_ethertype_filter(uint8_t > port_id, uint16_t index) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3060,7 +3100,7 @@ rte_eth_dev_get_ethertype_filter(uint8_t port_id, > uint16_t index, > if (filter =3D=3D NULL || rx_queue =3D=3D NULL) > return -EINVAL; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3077,7 +3117,7 @@ rte_eth_dev_add_2tuple_filter(uint8_t port_id, > uint16_t index, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3099,7 +3139,7 @@ rte_eth_dev_remove_2tuple_filter(uint8_t port_id, > uint16_t index) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3118,7 +3158,7 @@ rte_eth_dev_get_2tuple_filter(uint8_t port_id, > uint16_t index, > if (filter =3D=3D NULL || rx_queue =3D=3D NULL) > return -EINVAL; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3134,7 +3174,7 @@ rte_eth_dev_add_5tuple_filter(uint8_t port_id, > uint16_t index, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3157,7 +3197,7 @@ rte_eth_dev_remove_5tuple_filter(uint8_t port_id, > uint16_t index) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3176,7 +3216,7 @@ rte_eth_dev_get_5tuple_filter(uint8_t port_id, > uint16_t index, > if (filter =3D=3D NULL || rx_queue =3D=3D NULL) > return -EINVAL; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3193,7 +3233,7 @@ rte_eth_dev_add_flex_filter(uint8_t port_id, > uint16_t index, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3208,7 +3248,7 @@ rte_eth_dev_remove_flex_filter(uint8_t port_id, > uint16_t index) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3227,7 +3267,7 @@ rte_eth_dev_get_flex_filter(uint8_t port_id, > uint16_t index, > if (filter =3D=3D NULL || rx_queue =3D=3D NULL) > return -EINVAL; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3243,7 +3283,7 @@ rte_eth_dev_filter_supported(uint8_t port_id, > enum rte_filter_type filter_type) { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > @@ -3260,7 +3300,7 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum > rte_filter_type filter_type, { > struct rte_eth_dev *dev; >=20 > - if (port_id >=3D nb_ports) { > + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.= h index > f66805d..257de86 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -1565,6 +1565,7 @@ struct rte_eth_dev { > struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */ > struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */ > struct rte_eth_dev_cb_list callbacks; /**< User application callbacks *= / > + uint8_t attached; /**< Flag indicating the port is attached */ > }; >=20 > struct rte_eth_dev_sriov { > @@ -1630,6 +1631,10 @@ extern struct rte_eth_dev rte_eth_devices[]; > * initialized by the [matching] Ethernet driver during the PCI probing = phase. > * All devices whose port identifier is in the range > * [0, rte_eth_dev_count() - 1] can be operated on by network applicati= ons. > + * immediately after invoking rte_eal_init(). > + * If the application unplugs a port using hotplug function, The > + enabled port > + * numbers may be noncontiguous. In the case, the applications need to > + manage > + * enabled port by themselves. > * > * @return > * - The total number of usable Ethernet devices. > -- > 1.9.1