[dpdk-dev,3/5] net/tap: remove redundant fds array

Message ID 20170202223330.39240-3-keith.wiles@intel.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation success Compilation OK

Commit Message

Wiles, Keith Feb. 2, 2017, 10:33 p.m. UTC
  Signed-off-by: Keith Wiles <keith.wiles@intel.com>
---
 drivers/net/tap/rte_eth_tap.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
  

Comments

Pascal Mazon Feb. 3, 2017, 9:38 a.m. UTC | #1
On Thu,  2 Feb 2017 16:33:28 -0600
Keith Wiles <keith.wiles@intel.com> wrote:

> Signed-off-by: Keith Wiles <keith.wiles@intel.com>
> ---
>  drivers/net/tap/rte_eth_tap.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index 9ed7a87..6673182 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -103,7 +103,6 @@ struct pmd_internals {
>  	struct ether_addr eth_addr;	/* Mac address of the device port
> */ 
>  	int if_index;			/* IF_INDEX for the port */
> -	int fds[RTE_PMD_TAP_MAX_QUEUES]; /* List of all file descriptors */
>  
>  	struct rx_queue rxq[RTE_PMD_TAP_MAX_QUEUES];	/* List of RX
> queues */ struct tx_queue txq[RTE_PMD_TAP_MAX_QUEUES];	/* List of TX
> queues */ @@ -350,8 +349,8 @@ tap_dev_stop(struct rte_eth_dev *dev)
>  	struct pmd_internals *internals = dev->data->dev_private;
>  
>  	for (i = 0; i < internals->nb_queues; i++)
> -		if (internals->fds[i] != -1)
> -			close(internals->fds[i]);
> +		if (internals->rxq[i].fd != -1)
> +			close(internals->rxq[i].fd);
>  	tap_link_set_down(dev);
>  }
>  
> @@ -583,7 +582,6 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
>  	if (fd == -1)
>  		return -1;
>  
> -	internals->fds[rx_queue_id] = fd;
>  	RTE_LOG(INFO, PMD, "RX TAP device name %s, qid %d on fd %d\n",
>  		internals->name, rx_queue_id,
> internals->rxq[rx_queue_id].fd); 
> @@ -720,7 +718,6 @@ eth_dev_tap_create(const char *name, char *tap_name)
>  
>  	/* Presetup the fds to -1 as being not working */
>  	for (i = 1; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
> -		pmd->fds[i] = -1;
>  		pmd->rxq[i].fd = -1;
>  		pmd->txq[i].fd = -1;
>  	}
> @@ -728,7 +725,6 @@ eth_dev_tap_create(const char *name, char *tap_name)
>  	/* Take the TUN/TAP fd and place in the first location */
>  	pmd->rxq[0].fd = fd;
>  	pmd->txq[0].fd = fd;
> -	pmd->fds[0] = fd;
>  
>  	if (pmd_mac_address(fd, dev, &pmd->eth_addr) < 0) {
>  		RTE_LOG(ERR, PMD, "Unable to get MAC address\n");
> @@ -851,8 +847,8 @@ rte_pmd_tap_remove(const char *name)
>  
>  	internals = eth_dev->data->dev_private;
>  	for (i = 0; i < internals->nb_queues; i++)
> -		if (internals->fds[i] != -1)
> -			close(internals->fds[i]);
> +		if (internals->rxq[i].fd != -1)
> +			close(internals->rxq[i].fd);
>  
>  	rte_free(eth_dev->data->dev_private);
>  	rte_free(eth_dev->data);

Acked-by: Pascal Mazon <pascal.mazon@6wind.com>
  

Patch

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 9ed7a87..6673182 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -103,7 +103,6 @@  struct pmd_internals {
 	struct ether_addr eth_addr;	/* Mac address of the device port */
 
 	int if_index;			/* IF_INDEX for the port */
-	int fds[RTE_PMD_TAP_MAX_QUEUES]; /* List of all file descriptors */
 
 	struct rx_queue rxq[RTE_PMD_TAP_MAX_QUEUES];	/* List of RX queues */
 	struct tx_queue txq[RTE_PMD_TAP_MAX_QUEUES];	/* List of TX queues */
@@ -350,8 +349,8 @@  tap_dev_stop(struct rte_eth_dev *dev)
 	struct pmd_internals *internals = dev->data->dev_private;
 
 	for (i = 0; i < internals->nb_queues; i++)
-		if (internals->fds[i] != -1)
-			close(internals->fds[i]);
+		if (internals->rxq[i].fd != -1)
+			close(internals->rxq[i].fd);
 	tap_link_set_down(dev);
 }
 
@@ -583,7 +582,6 @@  tap_rx_queue_setup(struct rte_eth_dev *dev,
 	if (fd == -1)
 		return -1;
 
-	internals->fds[rx_queue_id] = fd;
 	RTE_LOG(INFO, PMD, "RX TAP device name %s, qid %d on fd %d\n",
 		internals->name, rx_queue_id, internals->rxq[rx_queue_id].fd);
 
@@ -720,7 +718,6 @@  eth_dev_tap_create(const char *name, char *tap_name)
 
 	/* Presetup the fds to -1 as being not working */
 	for (i = 1; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
-		pmd->fds[i] = -1;
 		pmd->rxq[i].fd = -1;
 		pmd->txq[i].fd = -1;
 	}
@@ -728,7 +725,6 @@  eth_dev_tap_create(const char *name, char *tap_name)
 	/* Take the TUN/TAP fd and place in the first location */
 	pmd->rxq[0].fd = fd;
 	pmd->txq[0].fd = fd;
-	pmd->fds[0] = fd;
 
 	if (pmd_mac_address(fd, dev, &pmd->eth_addr) < 0) {
 		RTE_LOG(ERR, PMD, "Unable to get MAC address\n");
@@ -851,8 +847,8 @@  rte_pmd_tap_remove(const char *name)
 
 	internals = eth_dev->data->dev_private;
 	for (i = 0; i < internals->nb_queues; i++)
-		if (internals->fds[i] != -1)
-			close(internals->fds[i]);
+		if (internals->rxq[i].fd != -1)
+			close(internals->rxq[i].fd);
 
 	rte_free(eth_dev->data->dev_private);
 	rte_free(eth_dev->data);