[ovs-dev] [PATCH v2 1/5] netdev-dpdk: Refactor dpdk_queue_flush().

Pravin Shelar pshelar at nicira.com
Mon Jun 30 18:10:20 UTC 2014


On Mon, Jun 30, 2014 at 10:53 AM, Ryan Wilson 76511 <wryan at vmware.com> wrote:
> I'll add the inline to both dpdk_queue_flush() and dpdk_queue_flush__()
> and repost this patch.
>
Actually I did it and pushed the patch. I also added unlikely in flush function.

Thanks,
Pravin.

> Cheers,
>
> Ryan
>
> On 6/30/14 9:52 AM, "Daniele Di Proietto" <ddiproietto at vmware.com> wrote:
>
>>I don¹t know if we want to keep the inline attribute here (like Pravin
>>said for commit 4/5).
>>
>>Otherwise LGTM
>>
>>Daniele
>>
>>On Jun 26, 2014, at 6:16 PM, Ryan Wilson <wryan at nicira.com> wrote:
>>
>>> This patch refactors dpdk_queue_flush() to reuse code in
>>> dpdk_queue_pkts().
>>>
>>> Signed-off-by: Ryan Wilson <wryan at nicira.com>
>>> ---
>>> lib/netdev-dpdk.c |   37 ++++++++++++++++---------------------
>>> 1 file changed, 16 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>>> index 72add87..084e8cd 100644
>>> --- a/lib/netdev-dpdk.c
>>> +++ b/lib/netdev-dpdk.c
>>> @@ -567,16 +567,12 @@ netdev_dpdk_rxq_dealloc(struct netdev_rxq *rxq_)
>>>     rte_free(rx);
>>> }
>>>
>>> -inline static void
>>> -dpdk_queue_flush(struct netdev_dpdk *dev, int qid)
>>> +static void
>>> +dpdk_queue_flush__(struct netdev_dpdk *dev, int qid)
>>> {
>>>     struct dpdk_tx_queue *txq = &dev->tx_q[qid];
>>>     uint32_t nb_tx;
>>>
>>> -    if (txq->count == 0) {
>>> -        return;
>>> -    }
>>> -    rte_spinlock_lock(&txq->tx_lock);
>>>     nb_tx = rte_eth_tx_burst(dev->port_id, qid, txq->burst_pkts,
>>>txq->count);
>>>     if (nb_tx != txq->count) {
>>>         /* free buffers if we couldn't transmit packets */
>>> @@ -585,6 +581,18 @@ dpdk_queue_flush(struct netdev_dpdk *dev, int qid)
>>>                              (txq->count - nb_tx));
>>>     }
>>>     txq->count = 0;
>>> +}
>>> +
>>> +static void
>>> +dpdk_queue_flush(struct netdev_dpdk *dev, int qid)
>>> +{
>>> +    struct dpdk_tx_queue *txq = &dev->tx_q[qid];
>>> +
>>> +    if (txq->count == 0) {
>>> +        return;
>>> +    }
>>> +    rte_spinlock_lock(&txq->tx_lock);
>>> +    dpdk_queue_flush__(dev, qid);
>>>     rte_spinlock_unlock(&txq->tx_lock);
>>> }
>>>
>>> @@ -619,7 +627,6 @@ dpdk_queue_pkts(struct netdev_dpdk *dev, int qid,
>>>     struct dpdk_tx_queue *txq = &dev->tx_q[qid];
>>>     uint64_t diff_tsc;
>>>     uint64_t cur_tsc;
>>> -    uint32_t nb_tx;
>>>
>>>     int i = 0;
>>>
>>> @@ -635,7 +642,7 @@ dpdk_queue_pkts(struct netdev_dpdk *dev, int qid,
>>>         i += tocopy;
>>>
>>>         if (txq->count == MAX_TX_QUEUE_LEN) {
>>> -            goto flush;
>>> +            dpdk_queue_flush__(dev, qid);
>>>         }
>>>         cur_tsc = rte_get_timer_cycles();
>>>         if (txq->count == 1) {
>>> @@ -643,20 +650,8 @@ dpdk_queue_pkts(struct netdev_dpdk *dev, int qid,
>>>         }
>>>         diff_tsc = cur_tsc - txq->tsc;
>>>         if (diff_tsc >= DRAIN_TSC) {
>>> -            goto flush;
>>> -        }
>>> -        continue;
>>> -
>>> -    flush:
>>> -        nb_tx = rte_eth_tx_burst(dev->port_id, qid, txq->burst_pkts,
>>> -                                 txq->count);
>>> -        if (nb_tx != txq->count) {
>>> -            /* free buffers if we couldn't transmit packets */
>>> -            rte_mempool_put_bulk(dev->dpdk_mp->mp,
>>> -                                 (void **) &txq->burst_pkts[nb_tx],
>>> -                                 (txq->count - nb_tx));
>>> +            dpdk_queue_flush__(dev, qid);
>>>         }
>>> -        txq->count = 0;
>>>     }
>>>     rte_spinlock_unlock(&txq->tx_lock);
>>> }
>>> --
>>> 1.7.9.5
>>>
>>> _______________________________________________
>>> dev mailing list
>>> dev at openvswitch.org
>>>
>>>https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman
>>>/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=MV9BdLjtFIdhBDBaw5z%2
>>>BU6SSA2gAfY4L%2F1HCy3VjlKU%3D%0A&m=k8OMewN%2BlH4t1D8dKSpSTmTA9pWqQAFUXVuh
>>>QL%2F1MZE%3D%0A&s=700107a65eb0df45bd5ddb456ab1a44352086fd48b96a6ef302a457
>>>fcab16e82
>>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list