Add netdev_txq_flush(), that flush packets on a queue. This is needed to transmit packets on the intermediate queue.
Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodire...@intel.com> Signed-off-by: Antonio Fischetti <antonio.fische...@intel.com> Co-authored-by: Antonio Fischetti <antonio.fische...@intel.com> Signed-off-by: Markus Magnusson <markus.magnus...@ericsson.com> Co-authored-by: Markus Magnusson <markus.magnus...@ericsson.com> Acked-by: Eelco Chaudron <echau...@redhat.com> --- lib/netdev-bsd.c | 1 + lib/netdev-dpdk.c | 26 +++++++++++++++++++++----- lib/netdev-dummy.c | 1 + lib/netdev-linux.c | 1 + lib/netdev-provider.h | 8 ++++++++ lib/netdev-vport.c | 2 +- lib/netdev.c | 9 +++++++++ lib/netdev.h | 1 + 8 files changed, 43 insertions(+), 6 deletions(-) diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c index f863a18..cb0edd6 100644 --- a/lib/netdev-bsd.c +++ b/lib/netdev-bsd.c @@ -1548,6 +1548,7 @@ netdev_bsd_update_flags(struct netdev *netdev_, enum netdev_flags off, netdev_bsd_rxq_recv, \ netdev_bsd_rxq_wait, \ netdev_bsd_rxq_drain, \ + NULL, \ \ NO_OFFLOAD_API \ } diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index bba4de3..cc84539 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1892,6 +1892,17 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int qid, } } +/* Flush tx queues + * This is done periodically to empty the intermediate queue in case of + * few packets (< INTERIM_QUEUE_BURST_THRESHOLD) buffered in the queue. + */ +static int +netdev_dpdk_txq_flush(struct netdev *netdev OVS_UNUSED, + int qid OVS_UNUSED, bool concurrent_txq OVS_UNUSED) +{ + return 0; +} + static int netdev_dpdk_eth_send(struct netdev *netdev, int qid, struct dp_packet_batch *batch, bool may_steal, @@ -3241,7 +3252,7 @@ unlock: SET_CONFIG, SET_TX_MULTIQ, SEND, \ GET_CARRIER, GET_STATS, \ GET_FEATURES, GET_STATUS, \ - RECONFIGURE, RXQ_RECV) \ + RECONFIGURE, RXQ_RECV, TXQ_FLUSH) \ { \ NAME, \ true, /* is_pmd */ \ @@ -3308,6 +3319,7 @@ unlock: RXQ_RECV, \ NULL, /* rx_wait */ \ NULL, /* rxq_drain */ \ + TXQ_FLUSH, /* txq_flush */ \ NO_OFFLOAD_API \ } @@ -3325,7 +3337,8 @@ static const struct netdev_class dpdk_class = netdev_dpdk_get_features, netdev_dpdk_get_status, netdev_dpdk_reconfigure, - netdev_dpdk_rxq_recv); + netdev_dpdk_rxq_recv, + netdev_dpdk_txq_flush); static const struct netdev_class dpdk_ring_class = NETDEV_DPDK_CLASS( @@ -3341,7 +3354,8 @@ static const struct netdev_class dpdk_ring_class = netdev_dpdk_get_features, netdev_dpdk_get_status, netdev_dpdk_reconfigure, - netdev_dpdk_rxq_recv); + netdev_dpdk_rxq_recv, + NULL); static const struct netdev_class dpdk_vhost_class = NETDEV_DPDK_CLASS( @@ -3357,7 +3371,8 @@ static const struct netdev_class dpdk_vhost_class = NULL, NULL, netdev_dpdk_vhost_reconfigure, - netdev_dpdk_vhost_rxq_recv); + netdev_dpdk_vhost_rxq_recv, + NULL); static const struct netdev_class dpdk_vhost_client_class = NETDEV_DPDK_CLASS( "dpdkvhostuserclient", @@ -3372,7 +3387,8 @@ static const struct netdev_class dpdk_vhost_client_class = NULL, NULL, netdev_dpdk_vhost_client_reconfigure, - netdev_dpdk_vhost_rxq_recv); + netdev_dpdk_vhost_rxq_recv, + NULL); void netdev_dpdk_register(void) diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c index d189a86..216c98e 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -1414,6 +1414,7 @@ netdev_dummy_update_flags(struct netdev *netdev_, netdev_dummy_rxq_recv, \ netdev_dummy_rxq_wait, \ netdev_dummy_rxq_drain, \ + NULL, \ \ NO_OFFLOAD_API \ } diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index f5dc30f..a2775da 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2874,6 +2874,7 @@ netdev_linux_update_flags(struct netdev *netdev_, enum netdev_flags off, netdev_linux_rxq_recv, \ netdev_linux_rxq_wait, \ netdev_linux_rxq_drain, \ + NULL, \ \ FLOW_OFFLOAD_API \ } diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index 79143d2..b25c82e 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -343,6 +343,11 @@ struct netdev_class { * If the function returns a non-zero value, some of the packets might have * been sent anyway. * + * Some netdev provider - like in case of 'dpdk' - may buffer the batch + * of packets into an intermediate queue. Buffered packets shall be + * transmitted when the packet count exceeds a threshold (or) by the + * periodic call to the flush function. + * * If 'may_steal' is false, the caller retains ownership of all the * packets. If 'may_steal' is true, the caller transfers ownership of all * the packets to the network device, regardless of success. @@ -778,6 +783,9 @@ struct netdev_class { /* Discards all packets waiting to be received from 'rx'. */ int (*rxq_drain)(struct netdev_rxq *rx); + /* Flush all packets waiting to be sent on 'qid' queue. */ + int (*txq_flush)(struct netdev *netdev, int qid, bool concurrent_txq); + /* ## -------------------------------- ## */ /* ## netdev flow offloading functions ## */ /* ## -------------------------------- ## */ diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index 640cdbe..36f62b7 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -905,10 +905,10 @@ netdev_vport_get_ifindex(const struct netdev *netdev_) NULL, /* rx_recv */ \ NULL, /* rx_wait */ \ NULL, /* rx_drain */ \ + NULL, /* tx_flush */ \ \ NETDEV_FLOW_OFFLOAD_API - #define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER, \ GET_IFINDEX) \ { DPIF_PORT, \ diff --git a/lib/netdev.c b/lib/netdev.c index 001b7b3..6111d19 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -700,6 +700,15 @@ netdev_rxq_drain(struct netdev_rxq *rx) : 0); } +/* Flush packets on the 'qid' queue. */ +int +netdev_txq_flush(struct netdev *netdev, int qid, bool netdev_txq_flush) +{ + return (netdev->netdev_class->txq_flush + ? netdev->netdev_class->txq_flush(netdev, qid, netdev_txq_flush) + : EOPNOTSUPP); +} + /* Configures the number of tx queues of 'netdev'. Returns 0 if successful, * otherwise a positive errno value. * diff --git a/lib/netdev.h b/lib/netdev.h index 31846fa..cd8f7c9 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -156,6 +156,7 @@ int netdev_rxq_drain(struct netdev_rxq *); int netdev_send(struct netdev *, int qid, struct dp_packet_batch *, bool may_steal, bool concurrent_txq); void netdev_send_wait(struct netdev *, int qid); +int netdev_txq_flush(struct netdev *, int qid, bool concurrent_txq); /* Flow offloading. */ struct offload_info { -- 2.4.11 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev