> On Oct 2, 2018, at 10:22 PM, Dekel Peled <dek...@mellanox.com> wrote:
> 
>>> @@ -137,8 +152,10 @@
>>>             n = RTE_MIN((uint16_t)(pkts_n - nb_tx),
>> MLX5_VPMD_TX_MAX_BURST);
>>>             if (txq->offloads & DEV_TX_OFFLOAD_MULTI_SEGS)
>>>                     n = txq_count_contig_single_seg(&pkts[nb_tx], n);
>>> -           if (txq->offloads & MLX5_VEC_TX_CKSUM_OFFLOAD_CAP)
>>> -                   n = txq_calc_offload(&pkts[nb_tx], n, &cs_flags);
>>> +           if (txq->offloads & (MLX5_VEC_TX_CKSUM_OFFLOAD_CAP |
>>> +                           DEV_TX_OFFLOAD_MATCH_METADATA))
>> 
>> How about writing a separate func - txq_count_contig_same_metadata()?
>> And it would be better to rename txq_calc_offload() to
>> txq_count_contig_same_csflag().
>> Then, there could be less redundant if-clause in the funcs.
> 
> It was considered during implementation but decided to handle all related 
> logic
> In same function.

But it doesn't look efficient. Note that it is performance critical datapath.

        if (A) {
                for (n)
                        do_a();
        }
        if (B) {
                for (n)
                        do_b();
        }

vs.

        if (A or B) {
                for (n) {
                        if (A)
                                do_a();
                        if (B)
                                do_b();
                }
        }

In the worst case, condition A and B will be checked n times each while it can 
be
only once in the first case.

Thanks,
Yongseok

Reply via email to