From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id C5D7C5A29 for ; Mon, 19 Jan 2015 15:25:11 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 19 Jan 2015 06:19:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,427,1418112000"; d="scan'208";a="639340527" Received: from pgsmsx108.gar.corp.intel.com ([10.221.44.103]) by orsmga001.jf.intel.com with ESMTP; 19 Jan 2015 06:25:08 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by PGSMSX108.gar.corp.intel.com (10.221.44.103) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 19 Jan 2015 22:25:06 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.64]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.231]) with mapi id 14.03.0195.001; Mon, 19 Jan 2015 22:24:59 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: FW: [dpdk-dev] [PATCH v4 01/11] eal/pci, ethdev: Remove assumption that port will not be detached Thread-Index: AQHQM9Sd8K2laK79b0mhc2MQUvvQiw== Date: Mon, 19 Jan 2015 14:24:58 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CB76AF@SHSMSX101.ccr.corp.intel.com> References: <1418106629-22227-2-git-send-email-mukawa@igel.co.j> <1421664027-17971-1-git-send-email-mukawa@igel.co.jp> <1421664027-17971-2-git-send-email-mukawa@igel.co.jp> <8CEF83825BEC744B83065625E567D7C2049D7C19@IRSMSX108.ger.corp.intel.com> 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="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] FW: [PATCH v4 01/11] eal/pci, 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: Mon, 19 Jan 2015 14:25:13 -0000 Hi, Tetsuya=0A= =0A= You see lots of places have below three lines:=0A= =0A= if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= return -EINVAL;=0A= }=0A= =0A= They are all the same(only few has the print log different), so can we impr= ove it?=0A= =0A= See below:=0A= =0A= +static int=0A= +rte_eth_dev_validate_port(uint8_t port_id, bool trace) {=0A= + if (port_id >=3D RTE_MAX_ETHPORTS ||=0A= + rte_eth_devices[port_id].attached !=3D DEV_CONNECTED) {=0A= + if (trace)=0A= + PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= + return DEV_INVALID;=0A= + }=0A= + else=0A= + return DEV_VALID;=0A= +}=0A= =0A= For normal case we just call this function use=0A= rte_eth_dev_validate_port(port_id, 1)=0A= here 1 could be a enmu value(Thus trace should be defined as int).=0A= After call, we didn't need to add PMD_DEBUG_TRACE() any more.=0A= =0A= For few cases like:=0A= PMD_DEBUG_TRACE("set VF rate limit:invalid port id=3D%d\n",=0A= port_id);=0A= =0A= We can call the function with secondary param set to "0", and add the trace= log after the function called, just as before.=0A= =0A= I think after this enhancement, the code seems more clean and efficiency=1B= $B!#=1B(B=0A= =0A= =0A= Thanks,=0A= Michael=0A= =0A= >> -----Original Message-----=0A= >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tetsuya Mukawa=0A= >> Sent: Monday, January 19, 2015 10:40 AM=0A= >> To: dev@dpdk.org=0A= >> Subject: [dpdk-dev] [PATCH v4 01/11] eal/pci, ethdev: Remove assumption = that port will not be=0A= >> detached=0A= >>=0A= >> To remove assumption, do like followings.=0A= >>=0A= >> This patch adds "RTE_PCI_DRV_DETACHABLE" to drv_flags of rte_pci_driver = structure. The flags=0A= >> indicates the driver can detach devices at runtime.=0A= >> Also remove assumption that port will not be detached.=0A= >>=0A= >> To remove the assumption.=0A= >> - Add 'attached' member to rte_eth_dev structure.=0A= >> This member is used for indicating the port is attached, or not.=0A= >> - Add rte_eth_dev_allocate_new_port().=0A= >> This function is used for allocating new port.=0A= >>=0A= >> v4:=0A= >> - Use braces with 'for' loop.=0A= >> - Fix indent of 'if' statement.=0A= >>=0A= >> Signed-off-by: Tetsuya Mukawa =0A= >> ---=0A= >> lib/librte_eal/common/include/rte_pci.h | 2 +=0A= >> lib/librte_ether/rte_ethdev.c | 248 ++++++++++++++++++-------= -------=0A= >> lib/librte_ether/rte_ethdev.h | 5 +=0A= >> 3 files changed, 151 insertions(+), 104 deletions(-)=0A= >>=0A= >> diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/co= mmon/include/rte_pci.h=0A= >> index 66ed793..dd1da28 100644=0A= >> --- a/lib/librte_eal/common/include/rte_pci.h=0A= >> +++ b/lib/librte_eal/common/include/rte_pci.h=0A= >> @@ -199,6 +199,8 @@ struct rte_pci_driver { #define RTE_PCI_DRV_FORCE_U= NBIND 0x0004=0A= >> /** Device driver supports link state interrupt */=0A= >> #define RTE_PCI_DRV_INTR_LSC 0x0008=0A= >> +/** Device driver supports detaching capability */=0A= >> +#define RTE_PCI_DRV_DETACHABLE 0x0010=0A= >>=0A= >> /**< Internal use only - Macro used by pci addr parsing functions **/= =0A= >> #define GET_PCIADDR_FIELD(in, fd, lim, dlm) \=0A= >> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev= .c index 077d430..46cabaf=0A= >> 100644=0A= >> --- a/lib/librte_ether/rte_ethdev.c=0A= >> +++ b/lib/librte_ether/rte_ethdev.c=0A= >> @@ -175,6 +175,16 @@ enum {=0A= >> STAT_QMAP_RX=0A= >> };=0A= >>=0A= >> +enum {=0A= >> + DEV_INVALID =3D 0,=0A= >> + DEV_VALID,=0A= >> +};=0A= >> +=0A= >> +enum {=0A= >> + DEV_DISCONNECTED =3D 0,=0A= >> + DEV_CONNECTED=0A= >> +};=0A= >> +=0A= >> static inline void=0A= >> rte_eth_dev_data_alloc(void)=0A= >> {=0A= >> @@ -201,19 +211,34 @@ rte_eth_dev_allocated(const char *name) {=0A= >> unsigned i;=0A= >>=0A= >> - for (i =3D 0; i < nb_ports; i++) {=0A= >> - if (strcmp(rte_eth_devices[i].data->name, name) =3D=3D 0)=0A= >> + for (i =3D 0; i < RTE_MAX_ETHPORTS; i++) {=0A= >> + if ((rte_eth_devices[i].attached =3D=3D DEV_CONNECTED) &&=0A= >> + strcmp(rte_eth_devices[i].data->name, name) =3D=3D 0)=0A= >> return &rte_eth_devices[i];=0A= >> }=0A= >> return NULL;=0A= >> }=0A= >>=0A= >> +static uint8_t=0A= >> +rte_eth_dev_allocate_new_port(void)=0A= >> +{=0A= >> + unsigned i;=0A= >> +=0A= >> + for (i =3D 0; i < RTE_MAX_ETHPORTS; i++) {=0A= >> + if (rte_eth_devices[i].attached =3D=3D DEV_DISCONNECTED)=0A= >> + return i;=0A= >> + }=0A= >> + return RTE_MAX_ETHPORTS;=0A= >> +}=0A= >> +=0A= >> struct rte_eth_dev *=0A= >> rte_eth_dev_allocate(const char *name)=0A= >> {=0A= >> + uint8_t port_id;=0A= >> struct rte_eth_dev *eth_dev;=0A= >>=0A= >> - if (nb_ports =3D=3D RTE_MAX_ETHPORTS) {=0A= >> + port_id =3D rte_eth_dev_allocate_new_port();=0A= >> + if (port_id =3D=3D RTE_MAX_ETHPORTS) {=0A= >> PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");=0A= >> return NULL;=0A= >> }=0A= >> @@ -226,10 +251,12 @@ rte_eth_dev_allocate(const char *name)=0A= >> return NULL;=0A= >> }=0A= >>=0A= >> - eth_dev =3D &rte_eth_devices[nb_ports];=0A= >> - eth_dev->data =3D &rte_eth_dev_data[nb_ports];=0A= >> + eth_dev =3D &rte_eth_devices[port_id];=0A= >> + eth_dev->data =3D &rte_eth_dev_data[port_id];=0A= >> snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name)= ;=0A= >> - eth_dev->data->port_id =3D nb_ports++;=0A= >> + eth_dev->data->port_id =3D port_id;=0A= >> + eth_dev->attached =3D DEV_CONNECTED;=0A= >> + nb_ports++;=0A= >> return eth_dev;=0A= >> }=0A= >>=0A= >> @@ -283,6 +310,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,=0A= >> (unsigned) pci_dev->id.device_id);=0A= >> if (rte_eal_process_type() =3D=3D RTE_PROC_PRIMARY)=0A= >> rte_free(eth_dev->data->dev_private);=0A= >> + eth_dev->attached =3D DEV_DISCONNECTED;=0A= >> nb_ports--;=0A= >> return diag;=0A= >> }=0A= >> @@ -308,10 +336,22 @@ rte_eth_driver_register(struct eth_driver *eth_drv= )=0A= >> rte_eal_pci_register(ð_drv->pci_drv);=0A= >> }=0A= >>=0A= >> +static int=0A= >> +rte_eth_dev_validate_port(uint8_t port_id) {=0A= >> + if (port_id >=3D RTE_MAX_ETHPORTS)=0A= >> + return DEV_INVALID;=0A= >> +=0A= >> + if (rte_eth_devices[port_id].attached =3D=3D DEV_CONNECTED)=0A= >> + return DEV_VALID;=0A= >> + else=0A= >> + return DEV_INVALID;=0A= >> +}=0A= >> +=0A= >> int=0A= >> rte_eth_dev_socket_id(uint8_t port_id)=0A= >> {=0A= >> - if (port_id >=3D nb_ports)=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID)=0A= >> return -1;=0A= >> return rte_eth_devices[port_id].pci_dev->numa_node;=0A= >> }=0A= >> @@ -369,7 +409,7 @@ rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t= rx_queue_id)=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -EINVAL;=0A= >> }=0A= >> @@ -395,7 +435,7 @@ rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t = rx_queue_id)=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -EINVAL;=0A= >> }=0A= >> @@ -421,7 +461,7 @@ rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t= tx_queue_id)=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -EINVAL;=0A= >> }=0A= >> @@ -447,7 +487,7 @@ rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t = tx_queue_id)=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -EINVAL;=0A= >> }=0A= >> @@ -703,7 +743,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_r= x_q, uint16_t nb_tx_q,=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);=0A= >>=0A= >> - if (port_id >=3D nb_ports || port_id >=3D RTE_MAX_ETHPORTS) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-EINVAL);=0A= >> }=0A= >> @@ -888,7 +928,7 @@ rte_eth_dev_start(uint8_t port_id)=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%" PRIu8 "\n", port_id);=0A= >> return (-EINVAL);=0A= >> }=0A= >> @@ -923,7 +963,7 @@ rte_eth_dev_stop(uint8_t port_id)=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_RET();=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%" PRIu8 "\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -951,7 +991,7 @@ rte_eth_dev_set_link_up(uint8_t port_id)=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -EINVAL;=0A= >> }=0A= >> @@ -970,7 +1010,7 @@ rte_eth_dev_set_link_down(uint8_t port_id)=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -EINVAL;=0A= >> }=0A= >> @@ -989,7 +1029,7 @@ rte_eth_dev_close(uint8_t port_id)=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_RET();=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1017,7 +1057,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t r= x_queue_id,=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-EINVAL);=0A= >> }=0A= >> @@ -1090,7 +1130,7 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t t= x_queue_id,=0A= >> * in a multi-process setup*/=0A= >> PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);=0A= >>=0A= >> - if (port_id >=3D RTE_MAX_ETHPORTS || port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-EINVAL);=0A= >> }=0A= >> @@ -1123,7 +1163,7 @@ rte_eth_promiscuous_enable(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1139,7 +1179,7 @@ rte_eth_promiscuous_disable(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1155,7 +1195,7 @@ rte_eth_promiscuous_get(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -1;=0A= >> }=0A= >> @@ -1169,7 +1209,7 @@ rte_eth_allmulticast_enable(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1185,7 +1225,7 @@ rte_eth_allmulticast_disable(uint8_t port_id) {= =0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1201,7 +1241,7 @@ rte_eth_allmulticast_get(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -1;=0A= >> }=0A= >> @@ -1229,7 +1269,7 @@ rte_eth_link_get(uint8_t port_id, struct rte_eth_l= ink *eth_link) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1249,7 +1289,7 @@ rte_eth_link_get_nowait(uint8_t port_id, struct rt= e_eth_link *eth_link) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1269,7 +1309,7 @@ rte_eth_stats_get(uint8_t port_id, struct rte_eth_= stats *stats) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1286,7 +1326,7 @@ rte_eth_stats_reset(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1307,7 +1347,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth= _xstats *xstats,=0A= >> uint64_t val;=0A= >> char *stats_ptr;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -1;=0A= >> }=0A= >> @@ -1376,7 +1416,7 @@ rte_eth_xstats_reset(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1398,7 +1438,7 @@ set_queue_stats_mapping(uint8_t port_id, uint16_t = queue_id, uint8_t=0A= >> stat_idx, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -1433,7 +1473,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_e= th_dev_info *dev_info)=0A= >> {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1453,7 +1493,7 @@ rte_eth_macaddr_get(uint8_t port_id, struct ether_= addr *mac_addr) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return;=0A= >> }=0A= >> @@ -1467,7 +1507,7 @@ rte_eth_dev_get_mtu(uint8_t port_id, uint16_t *mtu= ) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1483,7 +1523,7 @@ rte_eth_dev_set_mtu(uint8_t port_id, uint16_t mtu)= =0A= >> int ret;=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1503,7 +1543,7 @@ rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t = vlan_id, int on) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1528,7 +1568,7 @@ rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_i= d, uint16_t=0A= >> rx_queue_id, int o {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1550,7 +1590,7 @@ rte_eth_dev_set_vlan_ether_type(uint8_t port_id, u= int16_t tpid) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1570,7 +1610,7 @@ rte_eth_dev_set_vlan_offload(uint8_t port_id, int = offload_mask)=0A= >> int mask =3D 0;=0A= >> int cur, org =3D 0;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1615,7 +1655,7 @@ rte_eth_dev_get_vlan_offload(uint8_t port_id)=0A= >> struct rte_eth_dev *dev;=0A= >> int ret =3D 0;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1639,7 +1679,7 @@ rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_= t pvid, int on) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1657,7 +1697,7 @@ rte_eth_dev_fdir_add_signature_filter(uint8_t port= _id, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1691,7 +1731,7 @@ rte_eth_dev_fdir_update_signature_filter(uint8_t p= ort_id, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1725,7 +1765,7 @@ rte_eth_dev_fdir_remove_signature_filter(uint8_t p= ort_id, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1756,7 +1796,7 @@ rte_eth_dev_fdir_get_infos(uint8_t port_id, struct= rte_eth_fdir *fdir) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1781,7 +1821,7 @@ rte_eth_dev_fdir_add_perfect_filter(uint8_t port_i= d, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1821,7 +1861,7 @@ rte_eth_dev_fdir_update_perfect_filter(uint8_t por= t_id, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1859,7 +1899,7 @@ rte_eth_dev_fdir_remove_perfect_filter(uint8_t por= t_id, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1895,7 +1935,7 @@ rte_eth_dev_fdir_set_masks(uint8_t port_id, struct= rte_fdir_masks=0A= >> *fdir_mask) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1915,7 +1955,7 @@ rte_eth_dev_flow_ctrl_get(uint8_t port_id, struct = rte_eth_fc_conf=0A= >> *fc_conf) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1931,7 +1971,7 @@ rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct = rte_eth_fc_conf=0A= >> *fc_conf) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -1951,7 +1991,7 @@ rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id= , struct=0A= >> rte_eth_pfc_conf *pfc {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2030,7 +2070,7 @@ rte_eth_dev_rss_reta_update(uint8_t port_id,=0A= >> struct rte_eth_dev *dev;=0A= >> int ret;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -2081,7 +2121,7 @@ rte_eth_dev_rss_hash_update(uint8_t port_id, struc= t rte_eth_rss_conf=0A= >> *rss_conf)=0A= >> struct rte_eth_dev *dev;=0A= >> uint16_t rss_hash_protos;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2103,7 +2143,7 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id, {= =0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2118,7 +2158,7 @@ rte_eth_dev_udp_tunnel_add(uint8_t port_id, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -2144,7 +2184,7 @@ rte_eth_dev_udp_tunnel_delete(uint8_t port_id, {= =0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -2169,7 +2209,7 @@ rte_eth_led_on(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2184,7 +2224,7 @@ rte_eth_led_off(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2224,7 +2264,7 @@ rte_eth_dev_mac_addr_add(uint8_t port_id, struct e= ther_addr *addr,=0A= >> int index;=0A= >> uint64_t pool_mask;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2275,7 +2315,7 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struc= t ether_addr *addr)=0A= >> struct rte_eth_dev *dev;=0A= >> int index;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2309,7 +2349,7 @@ rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16= _t vf,=0A= >> struct rte_eth_dev *dev;=0A= >> struct rte_eth_dev_info dev_info;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("set VF RX mode:Invalid port_id=3D%d\n",=0A= >> port_id);=0A= >> return (-ENODEV);=0A= >> @@ -2364,7 +2404,7 @@ rte_eth_dev_uc_hash_table_set(uint8_t port_id, str= uct ether_addr *addr,=0A= >> int ret;=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=3D%d\n",=0A= >> port_id);=0A= >> return (-ENODEV);=0A= >> @@ -2417,7 +2457,7 @@ rte_eth_dev_uc_all_hash_table_set(uint8_t port_id,= uint8_t on) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=3D%d\n",=0A= >> port_id);=0A= >> return (-ENODEV);=0A= >> @@ -2436,7 +2476,7 @@ rte_eth_dev_set_vf_rx(uint8_t port_id,uint16_t vf,= uint8_t on)=0A= >> struct rte_eth_dev *dev;=0A= >> struct rte_eth_dev_info dev_info;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2462,7 +2502,7 @@ rte_eth_dev_set_vf_tx(uint8_t port_id,uint16_t vf,= uint8_t on)=0A= >> struct rte_eth_dev *dev;=0A= >> struct rte_eth_dev_info dev_info;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("set pool tx:Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2487,7 +2527,7 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, ui= nt16_t vlan_id, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("VF VLAN filter:invalid port id=3D%d\n",=0A= >> port_id);=0A= >> return (-ENODEV);=0A= >> @@ -2518,7 +2558,7 @@ int rte_eth_set_queue_rate_limit(uint8_t port_id, = uint16_t queue_idx,=0A= >> struct rte_eth_dev_info dev_info;=0A= >> struct rte_eth_link link;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("set queue rate limit:invalid port id=3D%d\n",=0A= >> port_id);=0A= >> return -ENODEV;=0A= >> @@ -2555,7 +2595,7 @@ int rte_eth_set_vf_rate_limit(uint8_t port_id, uin= t16_t vf, uint16_t tx_rate,=0A= >> if (q_msk =3D=3D 0)=0A= >> return 0;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("set VF rate limit:invalid port id=3D%d\n",=0A= >> port_id);=0A= >> return -ENODEV;=0A= >> @@ -2589,7 +2629,7 @@ rte_eth_mirror_rule_set(uint8_t port_id, {=0A= >> struct rte_eth_dev *dev =3D &rte_eth_devices[port_id];=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2630,7 +2670,7 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t= rule_id) {=0A= >> struct rte_eth_dev *dev =3D &rte_eth_devices[port_id];=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2655,7 +2695,7 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_i= d, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return 0;=0A= >> }=0A= >> @@ -2675,7 +2715,7 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_i= d, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return 0;=0A= >> }=0A= >> @@ -2695,7 +2735,7 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t q= ueue_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return 0;=0A= >> }=0A= >> @@ -2709,7 +2749,7 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16= _t queue_id, uint16_t=0A= >> offset) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2730,7 +2770,7 @@ rte_eth_dev_callback_register(uint8_t port_id,=0A= >>=0A= >> if (!cb_fn)=0A= >> return (-EINVAL);=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-EINVAL);=0A= >> }=0A= >> @@ -2770,7 +2810,7 @@ rte_eth_dev_callback_unregister(uint8_t port_id,= =0A= >>=0A= >> if (!cb_fn)=0A= >> return (-EINVAL);=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-EINVAL);=0A= >> }=0A= >> @@ -2830,7 +2870,7 @@ int rte_eth_dev_bypass_init(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2850,7 +2890,7 @@ rte_eth_dev_bypass_state_show(uint8_t port_id, uin= t32_t *state) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2869,7 +2909,7 @@ rte_eth_dev_bypass_state_set(uint8_t port_id, uint= 32_t *new_state) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2889,7 +2929,7 @@ rte_eth_dev_bypass_event_show(uint8_t port_id, uin= t32_t event, uint32_t=0A= >> *state) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2909,7 +2949,7 @@ rte_eth_dev_bypass_event_store(uint8_t port_id, ui= nt32_t event, uint32_t=0A= >> state) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2929,7 +2969,7 @@ rte_eth_dev_wd_timeout_store(uint8_t port_id, uint= 32_t timeout) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2949,7 +2989,7 @@ rte_eth_dev_bypass_ver_show(uint8_t port_id, uint3= 2_t *ver) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2969,7 +3009,7 @@ rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id= , uint32_t=0A= >> *wd_timeout) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -2989,7 +3029,7 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return (-ENODEV);=0A= >> }=0A= >> @@ -3011,7 +3051,7 @@ rte_eth_dev_add_syn_filter(uint8_t port_id, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3026,7 +3066,7 @@ rte_eth_dev_remove_syn_filter(uint8_t port_id) {= =0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3045,7 +3085,7 @@ rte_eth_dev_get_syn_filter(uint8_t port_id,=0A= >> if (filter =3D=3D NULL || rx_queue =3D=3D NULL)=0A= >> return -EINVAL;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3061,7 +3101,7 @@ rte_eth_dev_add_ethertype_filter(uint8_t port_id, = uint16_t index, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3082,7 +3122,7 @@ rte_eth_dev_remove_ethertype_filter(uint8_t port_i= d, uint16_t index) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3101,7 +3141,7 @@ rte_eth_dev_get_ethertype_filter(uint8_t port_id, = uint16_t index,=0A= >> if (filter =3D=3D NULL || rx_queue =3D=3D NULL)=0A= >> return -EINVAL;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3118,7 +3158,7 @@ rte_eth_dev_add_2tuple_filter(uint8_t port_id, uin= t16_t index, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3140,7 +3180,7 @@ rte_eth_dev_remove_2tuple_filter(uint8_t port_id, = uint16_t index) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3159,7 +3199,7 @@ rte_eth_dev_get_2tuple_filter(uint8_t port_id, uin= t16_t index,=0A= >> if (filter =3D=3D NULL || rx_queue =3D=3D NULL)=0A= >> return -EINVAL;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3175,7 +3215,7 @@ rte_eth_dev_add_5tuple_filter(uint8_t port_id, uin= t16_t index, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3198,7 +3238,7 @@ rte_eth_dev_remove_5tuple_filter(uint8_t port_id, = uint16_t index) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3217,7 +3257,7 @@ rte_eth_dev_get_5tuple_filter(uint8_t port_id, uin= t16_t index,=0A= >> if (filter =3D=3D NULL || rx_queue =3D=3D NULL)=0A= >> return -EINVAL;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3234,7 +3274,7 @@ rte_eth_dev_add_flex_filter(uint8_t port_id, uint1= 6_t index, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3249,7 +3289,7 @@ rte_eth_dev_remove_flex_filter(uint8_t port_id, ui= nt16_t index) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3268,7 +3308,7 @@ rte_eth_dev_get_flex_filter(uint8_t port_id, uint1= 6_t index,=0A= >> if (filter =3D=3D NULL || rx_queue =3D=3D NULL)=0A= >> return -EINVAL;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3284,7 +3324,7 @@ rte_eth_dev_filter_supported(uint8_t port_id, enum= rte_filter_type=0A= >> filter_type) {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> @@ -3301,7 +3341,7 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_= filter_type filter_type, {=0A= >> struct rte_eth_dev *dev;=0A= >>=0A= >> - if (port_id >=3D nb_ports) {=0A= >> + if (rte_eth_dev_validate_port(port_id) =3D=3D DEV_INVALID) {=0A= >> PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id);=0A= >> return -ENODEV;=0A= >> }=0A= >> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev= .h index ce0528f..616a44a=0A= >> 100644=0A= >> --- a/lib/librte_ether/rte_ethdev.h=0A= >> +++ b/lib/librte_ether/rte_ethdev.h=0A= >> @@ -1565,6 +1565,7 @@ struct rte_eth_dev {=0A= >> struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */=0A= >> struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */= =0A= >> struct rte_eth_dev_cb_list callbacks; /**< User application callbacks = */=0A= >> + uint8_t attached; /**< Flag indicating the port is attached */=0A= >> };=0A= >>=0A= >> struct rte_eth_dev_sriov {=0A= >> @@ -1630,6 +1631,10 @@ extern struct rte_eth_dev rte_eth_devices[];=0A= >> * initialized by the [matching] Ethernet driver during the PCI probing= phase.=0A= >> * All devices whose port identifier is in the range=0A= >> * [0, rte_eth_dev_count() - 1] can be operated on by network applicat= ions.=0A= >> + * immediately after invoking rte_eal_init().=0A= >> + * If the application unplugs a port using hotplug function, The=0A= >> + enabled port=0A= >> + * numbers may be noncontiguous. In the case, the applications need to= =0A= >> + manage=0A= >> + * enabled port by themselves.=0A= >> *=0A= >> * @return=0A= >> * - The total number of usable Ethernet devices.=0A= >> --=0A= >> 1.9.1=0A= >=0A= =0A=