[v5] net/tap: fix missing _SC_IOV_MAX

Message ID 20190308192940.6972-1-olegp123@walla.co.il (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series [v5] net/tap: fix missing _SC_IOV_MAX |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

olegpoly123 March 8, 2019, 7:29 p.m. UTC
  From: Oleg Polyakov <olegp123@walla.co.il>

If the value _SC_IOV_MAX is missing, sysconf returns -1.
In this case, iov_max is set to a default value of 1024.

Cc: stable@dpdk.org

Signed-off-by: Oleg Polyakov <olegp123@walla.co.il>
---
 drivers/net/tap/rte_eth_tap.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Thomas Monjalon March 8, 2019, 11:14 p.m. UTC | #1
08/03/2019 20:29, olegpoly123:
> From: Oleg Polyakov <olegp123@walla.co.il>
> 
> If the value _SC_IOV_MAX is missing, sysconf returns -1.
> In this case, iov_max is set to a default value of 1024.
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: Oleg Polyakov <olegp123@walla.co.il>

Please add the "Fixes:" line and the "Acked-by" line from Keith.
Or, at least, please reply and confirm the "Fixes" line I suggested is the right one.
  

Patch

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 6f5109fca..8f7c552b3 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -68,6 +68,8 @@ 
 /* IPC key for queue fds sync */
 #define TAP_MP_KEY "tap_mp_sync_queues"
 
+#define TAP_IOV_DEFAULT_MAX 1024
+
 static int tap_devices_count;
 static struct rte_vdev_driver pmd_tap_drv;
 static struct rte_vdev_driver pmd_tun_drv;
@@ -1326,6 +1328,13 @@  tap_rx_queue_setup(struct rte_eth_dev *dev,
 	struct rx_queue *rxq = &internals->rxq[rx_queue_id];
 	struct rte_mbuf **tmp = &rxq->pool;
 	long iov_max = sysconf(_SC_IOV_MAX);
+
+	if (iov_max <= 0) {
+		TAP_LOG(WARNING,
+			"_SC_IOV_MAX is not defined. Using %d as default\n",
+			TAP_IOV_DEFAULT_MAX);
+		iov_max = TAP_IOV_DEFAULT_MAX;
+	}
 	uint16_t nb_desc = RTE_MIN(nb_rx_desc, iov_max - 1);
 	struct iovec (*iovecs)[nb_desc + 1];
 	int data_off = RTE_PKTMBUF_HEADROOM;