net/pcap: use a struct to pass user options
PATCH v3 1/2 net/pcap: use a struct to pass user options
The argument lists on some of the device creation functions are quite large. Using a struct to hold the user options parsed in 'pmd_pcap_probe' will allow for cleaner function calls and definitions. Adding user options will also be easier.
--- drivers/net/pcap/rte_eth_pcap.c | 51 ++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-)
drivers/net/pcap/rte_eth_pcap.c +35 -16
@@ -101,6 +101,14 @@ struct pmd_devargs {int phy_mac; }; +struct pmd_devargs_all { +struct pmd_devargs rx_queues; +struct pmd_devargs tx_queues; +int single_iface; +unsigned int is_tx_pcap; +unsigned int is_tx_iface; +}; +static const char *valid_arguments[] = {ETH_PCAP_RX_PCAP_ARG ,ETH_PCAP_TX_PCAP_ARG ,
@@ -1061,11 +1069,14 @@ eth_pcap_update_mac(const char *if_name, struct rte_eth_dev *eth_dev,static int eth_from_pcaps_common (struct rte_vdev_device *vdev, -struct pmd_devargs *rx_queues,const unsigned int nb_rx_queues, -struct pmd_devargs *tx_queues,const unsigned int nb_tx_queues, +struct pmd_devargs_all *devargs_all,struct pmd_internals **internals,struct rte_eth_dev **eth_dev) {struct pmd_process_private *pp; +struct pmd_devargs *rx_queues = &devargs_all->rx_queues; +struct pmd_devargs *tx_queues = &devargs_all->tx_queues; +const unsigned int nb_rx_queues = rx_queues->num_of_queue; +const unsigned int nb_tx_queues = tx_queues->num_of_queue;unsigned int i;/* do some parameter checking */
@@ -1103,16 +1114,15 @@ eth_from_pcaps_common(struct rte_vdev_device *vdev,static int eth_from_pcaps (struct rte_vdev_device *vdev, -struct pmd_devargs *rx_queues,const unsigned int nb_rx_queues, -struct pmd_devargs *tx_queues,const unsigned int nb_tx_queues, -int single_iface,unsigned int using_dumpers) +struct pmd_devargs_all *devargs_all) {struct pmd_internals *internals =NULL ;struct rte_eth_dev *eth_dev =NULL ; +struct pmd_devargs *rx_queues = &devargs_all->rx_queues; +int single_iface = devargs_all->single_iface;int ret; - ret =eth_from_pcaps_common (vdev, rx_queues, nb_rx_queues, - tx_queues, nb_tx_queues, &internals, ð_dev); + ret =eth_from_pcaps_common (vdev, devargs_all, &internals, ð_dev);if (ret <0 )return ret;
@@ -1134,7 +1144,8 @@ eth_from_pcaps(struct rte_vdev_device *vdev, eth_dev->rx_pkt_burst = eth_pcap_rx; -if (using_dumpers) +/* Assign tx ops. */ +if (devargs_all->is_tx_pcap) eth_dev->tx_pkt_burst = eth_pcap_tx_dumper;else eth_dev->tx_pkt_burst = eth_pcap_tx;
@@ -1147,15 +1158,20 @@ static int pmd_pcap_probe(struct rte_vdev_device *dev) {const char *name; -unsigned int is_rx_pcap =0 , is_tx_pcap =0 ; +unsigned int is_rx_pcap =0 ;struct rte_kvargs *kvlist;struct pmd_devargs pcaps = {0 };struct pmd_devargs dumpers = {0 };struct rte_eth_dev *eth_dev =NULL ;struct pmd_internals *internal; -int single_iface =0 ;int ret; +struct pmd_devargs_all devargs_all = { + .single_iface =0 , + .is_tx_pcap =0 , + .is_tx_iface =0 , + }; + name =rte_vdev_device_name (dev);PMD_LOG (INFO ,"Initializing pmd_pcap for %s" , name);
@@ -1202,7 +1218,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev) dumpers.phy_mac = pcaps.phy_mac; - single_iface =1 ; + devargs_all.single_iface =1 ; pcaps.num_of_queue =1 ; dumpers.num_of_queue =1 ;
@@ -1231,10 +1247,11 @@ pmd_pcap_probe(struct rte_vdev_device *dev)* We check whether we want to open a TX stream to a real NIC or a * pcap file */ - is_tx_pcap =rte_kvargs_count (kvlist,ETH_PCAP_TX_PCAP_ARG ) ?1 :0 ; + devargs_all.is_tx_pcap = +rte_kvargs_count (kvlist,ETH_PCAP_TX_PCAP_ARG ) ?1 :0 ; dumpers.num_of_queue =0 ; -if (is_tx_pcap) +if (devargs_all.is_tx_pcap) ret =rte_kvargs_process (kvlist,ETH_PCAP_TX_PCAP_ARG , &open_tx_pcap, &dumpers);else
@@ -1276,7 +1293,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev) eth_dev->process_private = pp; eth_dev->rx_pkt_burst = eth_pcap_rx; -if (is_tx_pcap) +if (devargs_all.is_tx_pcap) eth_dev->tx_pkt_burst = eth_pcap_tx_dumper;else eth_dev->tx_pkt_burst = eth_pcap_tx;
@@ -1285,8 +1302,10 @@ pmd_pcap_probe(struct rte_vdev_device *dev) goto free_kvlist; } - ret =eth_from_pcaps (dev, &pcaps, pcaps.num_of_queue, &dumpers, - dumpers.num_of_queue, single_iface, is_tx_pcap); + devargs_all.rx_queues = pcaps; + devargs_all.tx_queues = dumpers; + + ret =eth_from_pcaps (dev, &devargs_all); free_kvlist:rte_kvargs_free (kvlist);
Signature · 1 line
2.17.1
PATCH v3 2/2 net/pcap: enable infinitely rxing a pcap file
It can be useful to use pcap files for some rudimental performance
At a high level, this works by creaing a ring of sufficient size to store the packets in the pcap file passed to the application. When the rx function for this mode is called, packets are dequeued from the ring for use by the application and also enqueued back on to the ring to be "received" again.
A tx_drop mode is also added since transmitting to a tx_pcap file isn't desirable at a high traffic rate.
Jumbo frames are not supported in this mode. When filling the ring at rx queue setup time, the presence of multi segment mbufs is checked for. The PMD will exit on detection of these multi segment mbufs.
---
v3 changes:
* Update PCAP docs:
* State that 'infinite_rx' should only be provided once per device.
* Drop use of tx_drop and mention its use through not providing a txq.
* Remove the tx_drop option and related args processing.
* Notify user when tx_drop is being used.
* Change infinite_rx from an 'int' to 'unsigned int' in pmd_internals struct.
* Add pmd_devargs_all struct to pass args from pmd_probe to ethdev creation.
* Improve args parsing of infinite_rx so -1 doesn't enable feature.
* Change order of tx ops assignment so tx_drop is default case.
* Move args parsing of infinite_rx inside 'is_rx_pcap' check.
* Only notify user of 'infinite_rx' state if arg has been passed on cmdline.
* Call eth_dev_close for 'infinite_rx' cleanup rather than duplicating code.
doc/guides/nics/pcap_ring.rst | 20 +++ drivers/net/pcap/rte_eth_pcap.c | 234 ++++++++++++++++++++++++++++++-- 2 files changed, 246 insertions(+), 8 deletions(-)
doc/guides/nics/pcap_ring.rst +20 -0
@@ -106,6 +106,26 @@ Runtime Config Options --vdev 'net_pcap0,iface=eth0,phy_mac=1' +- Use the RX PCAP file to infinitely receive packets + + In case ``rx_pcap=`` configuration is set, user may want to use the selected PCAP file for rudimental + performance testing. This can be done with a ``devarg`` ``infinite_rx``, for example:: + + --vdev 'net_pcap0,rx_pcap=file_rx.pcap,infinite_rx=1,tx_drop=1' + + When this mode is used, it is recommended to drop all packets on transmit by not providing a tx_pcap or tx_iface. + + This option is device wide, so all queues on a device will either have this enabled or disabled. + This option should only be provided once per device. + +- Drop all packets on transmit + + The user may want to drop all packets on tx for a device. This can be done by not providing a tx_pcap or tx_iface, for example:: + + --vdev 'net_pcap0,rx_pcap=file_rx.pcap' + + In this case, one tx drop queue is created for each rxq on that device. + Examples of Usage ^^^^^^^^^^^^^^^^^
drivers/net/pcap/rte_eth_pcap.c +226 -8
357 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH 19.08 v3 2/2] net/pcap: enable infinitely rxing a pcap file
Quoted 16 lines · Cian Ferriter
It can be useful to use pcap files for some rudimental performance
At a high level, this works by creaing a ring of sufficient size to store the packets in the pcap file passed to the application. When the rx function for this mode is called, packets are dequeued from the ring for use by the application and also enqueued back on to the ring to be "received" again.
A
tx_dropmode is also added since transmitting to atx_pcapfile isn't desirable at a high traffic rate.Jumbo frames are not supported in this mode. When filling the ring at rx queue setup time, the presence of multi segment mbufs is checked for. The PMD will exit on detection of these multi segment mbufs.
Signed-off-by Cian Ferriter <[email protected]>
<...>
doc/guides/nics/pcap_ring.rst Runtime Config Options · line 114
Quoted 10 lines
doc/guides/nics/pcap_ring.rst +6
-0@@ -106,6 +106,26 @@ Runtime Config Options --vdev 'net_pcap0,iface=eth0,phy_mac=1' +- Use the RX PCAP file to infinitely receive packets + + In case ``rx_pcap=`` configuration is set, user may want to use the selected PCAP file for rudimental + performance testing. This can be done with a ``devarg`` ``infinite_rx``, for example:: + + --vdev 'net_pcap0,rx_pcap=file_rx.pcap,infinite_rx=1,tx_drop=1'
'tx_drop' seems remaining, it is no more valid.
<...>
drivers/net/pcap/rte_eth_pcap.c pmd_pcap_remove(struct rte_vdev_device *dev) · line 1555
Quoted 6 lines
drivers/net/pcap/rte_eth_pcap.c +2
-0@@ -1337,6 +1551,9 @@ pmd_pcap_remove(struct rte_vdev_device *dev) eth_dev->data->mac_addrs =NULL ; } +if (internals->infinite_rx) +eth_dev_close (eth_dev);
Why 'internals->infinite_rx' check is required to call the 'eth_dev_close()'? Can we remove the check?
Re: [dpdk-dev] [PATCH 19.08 v3 2/2] net/pcap: enable infinitely rxing a pcap file
Hi Ferruh,
I've responded inline but to summarize, I agree with both of your points.
There is one additional piece of rework that I spotted for this version. I have left out a small part of the commit message. Please see my response inline below for more details.
Since the rework is minor here, I'd be happy if you wanted to make the changes and apply the patches to save going through another version + review cycle.
Let me know if there is anything else.
Thanks,
Cian
Quoted 10 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: 27 June 2019 18:56
To: Ferriter, Cian <[email protected]>; Richardson, Bruce <[email protected]>; Mcnamara, John <[email protected]>; Kovacevic, Marko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 19.08 v3 2/2] net/pcap: enable infinitely rxing a pcap file
Quoted 3 lines
Quoted 2 lines · Cian Ferriter
It can be useful to use pcap files for some rudimental performance
Part of the commit message got lost in my splitting of the patch into two patches between v2 and v3. The above line should read:
It can be useful to use pcap files for some rudimental performance
testing. This patch enables this functionality in the pcap driver.
Quoted 26 lines
Quoted 14 lines
At a high level, this works by creaing a ring of sufficient size to store the packets in the pcap file passed to the application. When the rx function for this mode is called, packets are dequeued from the ring for use by the application and also enqueued back on to the ring to be "received" again.
A
tx_dropmode is also added since transmitting to atx_pcapfile isn't desirable at a high traffic rate.Jumbo frames are not supported in this mode. When filling the ring at rx queue setup time, the presence of multi segment mbufs is checked for. The PMD will exit on detection of these multi segment mbufs.
Signed-off-by Cian Ferriter <[email protected]><...>
doc/guides/nics/pcap_ring.rst Runtime Config Options · line 112
Quoted 8 lines
doc/guides/nics/pcap_ring.rst +4
-0@@ -106,6 +106,26 @@ Runtime Config Options --vdev 'net_pcap0,iface=eth0,phy_mac=1' +- Use the RX PCAP file to infinitely receive packets + + In case ``rx_pcap=`` configuration is set, user may want to use the + selected PCAP file for rudimental performance testing. This can be donewith a ``devarg`` ``infinite_rx``, for example::
Quoted 5 lines
Review Runtime Config Options · line 114
Quoted 2 lines
(quoted diff) +2
-0+ + --vdev 'net_pcap0,rx_pcap=file_rx.pcap,infinite_rx=1,tx_drop=1''
tx_drop' seems remaining, it is no more valid.
I missed this, it should be removed.
Quoted 4 lines
<...>
Review pmd_pcap_remove(struct rte_vdev_device
Quoted 1 line
(quoted diff) +0
-0@@ -1337,6 +1551,9 @@ pmd_pcap_remove(struct rte_vdev_device*dev)
Quoted 8 lines
drivers/net/pcap/rte_eth_pcap.c pmd_pcap_remove(struct rte_vdev_device *dev) · line 1555
Quoted 5 lines
drivers/net/pcap/rte_eth_pcap.c +2
-0eth_dev->data->mac_addrs =NULL ; } +if (internals->infinite_rx) +eth_dev_close (eth_dev);Why '
internals->infinite_rx' check is required to call the 'eth_dev_close()'? Can we remove the check?
Good point, we don't need to check whether the device is in infinite_rx mode, since this is done in eth_dev_close anyway.
Re: [dpdk-dev] [PATCH 19.08 v3 2/2] net/pcap: enable infinitely rxing a pcap file
Quoted 7 lines · Cian
Hi Ferruh,
I've responded inline but to summarize, I agree with both of your points.
There is one additional piece of rework that I spotted for this version. I have left out a small part of the commit message. Please see my response inline below for more details.
Since the rework is minor here, I'd be happy if you wanted to make the changes and apply the patches to save going through another version + review cycle.
+1, I will update them while merging.
Quoted 72 lines
Let me know if there is anything else.
Thanks,
CianQuoted 10 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: 27 June 2019 18:56
To: Ferriter, Cian <[email protected]>; Richardson, Bruce <[email protected]>; Mcnamara, John <[email protected]>; Kovacevic, Marko <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 19.08 v3 2/2] net/pcap: enable infinitely rxing a pcap fileQuoted 3 lines
Quoted 2 lines · Cian Ferriter
It can be useful to use pcap files for some rudimental performance
Part of the commit message got lost in my splitting of the patch into two patches between v2 and v3. The above line should read:
It can be useful to use pcap files for some rudimental performance
testing. This patch enables this functionality in the pcap driver.Quoted 26 lines
Quoted 14 lines
At a high level, this works by creaing a ring of sufficient size to store the packets in the pcap file passed to the application. When the rx function for this mode is called, packets are dequeued from the ring for use by the application and also enqueued back on to the ring to be "received" again.
A
tx_dropmode is also added since transmitting to atx_pcapfile isn't desirable at a high traffic rate.Jumbo frames are not supported in this mode. When filling the ring at rx queue setup time, the presence of multi segment mbufs is checked for. The PMD will exit on detection of these multi segment mbufs.
Signed-off-by Cian Ferriter <[email protected]><...>
doc/guides/nics/pcap_ring.rst Runtime Config Options · line 112
Quoted 8 lines
doc/guides/nics/pcap_ring.rst +4
-0@@ -106,6 +106,26 @@ Runtime Config Options --vdev 'net_pcap0,iface=eth0,phy_mac=1' +- Use the RX PCAP file to infinitely receive packets + + In case ``rx_pcap=`` configuration is set, user may want to use the + selected PCAP file for rudimental performance testing. This can be donewith a ``devarg`` ``infinite_rx``, for example::
Quoted 5 lines
Review Runtime Config Options · line 114
Quoted 2 lines
(quoted diff) +2
-0+ + --vdev 'net_pcap0,rx_pcap=file_rx.pcap,infinite_rx=1,tx_drop=1''
tx_drop' seems remaining, it is no more valid.I missed this, it should be removed.
Quoted 4 lines
<...>
Review pmd_pcap_remove(struct rte_vdev_device
Quoted 1 line
(quoted diff) +0
-0@@ -1337,6 +1551,9 @@ pmd_pcap_remove(struct rte_vdev_device*dev)
Quoted 8 lines
drivers/net/pcap/rte_eth_pcap.c pmd_pcap_remove(struct rte_vdev_device *dev) · line 1555
Quoted 5 lines
drivers/net/pcap/rte_eth_pcap.c +2
-0eth_dev->data->mac_addrs =NULL ; } +if (internals->infinite_rx) +eth_dev_close (eth_dev);Why '
internals->infinite_rx' check is required to call the 'eth_dev_close()'? Can we remove the check?Good point, we don't need to check whether the device is in
infinite_rxmode, since this is done ineth_dev_closeanyway.
Quoted 6 lines · Cian Ferriter
The argument lists on some of the device creation functions are quite large. Using a struct to hold the user options parsed in '
pmd_pcap_probe' will allow for cleaner function calls and definitions. Adding user options will also be easier.Signed-off-by Cian Ferriter <[email protected]>
For series,
Series applied to dpdk-next-net/master, thanks.
(Mentioned changes done while merging)