The info_get callback doesn't need to check its args
since already done by ethdev.

The null driver generates fake packets of configured packet_size.
The mbuf pool passed when setting up Rx queue must have space
to hold the requested packet size; otherwise eth_null_copy_rx()
would generate invalid mbufs.

Setting min_rx_bufsize to packet_size enables the existing
validation in rte_eth_rx_queue_setup() to reject undersized pools.

Fixes: c743e50c475f ("null: new poll mode driver")
Cc: [email protected]

Signed-off-by: Stephen Hemminger <[email protected]>
---
 drivers/net/null/rte_eth_null.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 46e7e7bd8c..ba87c82a73 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -298,17 +298,13 @@ static int
 eth_dev_info(struct rte_eth_dev *dev,
                struct rte_eth_dev_info *dev_info)
 {
-       struct pmd_internals *internals;
-
-       if ((dev == NULL) || (dev_info == NULL))
-               return -EINVAL;
+       struct pmd_internals *internals = dev->data->dev_private;
 
-       internals = dev->data->dev_private;
        dev_info->max_mac_addrs = 1;
-       dev_info->max_rx_pktlen = (uint32_t)-1;
+       dev_info->max_rx_pktlen = UINT32_MAX;
        dev_info->max_rx_queues = RTE_DIM(internals->rx_null_queues);
        dev_info->max_tx_queues = RTE_DIM(internals->tx_null_queues);
-       dev_info->min_rx_bufsize = 0;
+       dev_info->min_rx_bufsize = internals->packet_size;
        dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS | 
RTE_ETH_TX_OFFLOAD_MT_LOCKFREE;
 
        dev_info->reta_size = internals->reta_size;
-- 
2.51.0

Reply via email to