From: Alejandro Lucero <alejandro.lucero@netronome.com>
To: "Burakov, Anatoly" <anatoly.burakov@intel.com>
Cc: dev <dev@dpdk.org>,
stable@dpdk.org, Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: Re: [dpdk-stable] [PATCH 1/6] mem: add function for checking memsegs IOVAs addresses
Date: Tue, 3 Jul 2018 11:01:09 +0100 [thread overview]
Message-ID: <CAD+H992hfhhEzVAxjLENd41ZmdxsvWcAyYG3FLuMQGB8Hghxaw@mail.gmail.com> (raw)
In-Reply-To: <ac14782d-72a8-1d8c-66da-2658297a75c7@intel.com>
On Tue, Jul 3, 2018 at 10:07 AM, Burakov, Anatoly <anatoly.burakov@intel.com
> wrote:
> On 02-Jul-18 6:26 PM, Alejandro Lucero wrote:
>
>> A device can suffer addressing limitations. This functions checks
>> memsegs have iovas within the supported range based on dma mask.
>>
>> PMD should use this during initialization if supported devices
>> suffer addressing limitations, returning an error if this function
>> returns memsegs out of range.
>>
>> Another potential usage is for emulated IOMMU hardware with addressing
>> limitations.
>>
>> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
>> ---
>>
>
> <snip>
>
> + const struct rte_mem_config *mcfg;
>> + uint64_t mask;
>> + int i;
>> + int ret = 0;
>> +
>> + /* create dma mask */
>> + mask = 1ULL << maskbits;
>> + mask -= 1;
>>
>
> mask = ~((1ULL << maskbits) - 1);
>
> ? IMO this makes it much more clear what you're trying to do.
>
>
Sure. I will change it.
> +
>> + /* get pointer to global configuration */
>> + mcfg = rte_eal_get_configuration()->mem_config;
>> +
>> + for (i = 0; i < RTE_MAX_MEMSEG; i++) {
>> + if (mcfg->memseg[i].addr == NULL)
>> + break;
>> +
>> + if (mcfg->memseg[i].iova & ~mask) {
>> + ret = -1;
>> + break;
>> + }
>> + }
>> +
>> + if (!ret)
>> + return ret;
>> +
>> + RTE_LOG(INFO, EAL, "memseg[%d] iova %"PRIx64" out of range:\n",
>> + i, mcfg->memseg[i].iova);
>> + RTE_LOG(INFO, EAL, "\tusing dma mask %"PRIx64"\n", mask);
>> +
>> + return -1;
>>
>
> The control flow looks weird to me. You break if iova has any bits that
> are in the mask, then you display log messages and return -1. How about
> just logging error and returning -1, and simply returning 0 after the loop?
>
>
I agree. The truth is I did that initially, but the log lines were too long
with the indent. I will go back to the original.
Thanks
> --
> Thanks,
> Anatoly
>
next prev parent reply other threads:[~2018-07-03 10:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-02 17:26 [dpdk-stable] [PATH 0/6] Use IOVAs check based on DMA mask Alejandro Lucero
2018-07-02 17:26 ` [dpdk-stable] [PATCH 1/6] mem: add function for checking memsegs IOVAs addresses Alejandro Lucero
2018-07-03 9:07 ` Burakov, Anatoly
2018-07-03 10:01 ` Alejandro Lucero [this message]
2018-07-02 17:26 ` [dpdk-stable] [PATCH 2/6] ethdev: add function for checking IOVAs by a device Alejandro Lucero
2018-07-02 17:27 ` [dpdk-stable] [PATCH 3/6] bus/pci: use IOVAs check when setting IOVA mode Alejandro Lucero
2018-07-03 9:10 ` Burakov, Anatoly
2018-07-03 10:08 ` Alejandro Lucero
2018-07-02 17:27 ` [dpdk-stable] [PATCH 4/6] mem: use address hint for mapping hugepages Alejandro Lucero
2018-07-03 9:17 ` Burakov, Anatoly
2018-07-03 10:44 ` Alejandro Lucero
2018-07-03 10:46 ` Burakov, Anatoly
2018-07-02 17:27 ` [dpdk-stable] [PATCH 5/6] net/nfp: check hugepages IOVAs based on DMA mask Alejandro Lucero
2018-07-02 17:27 ` [dpdk-stable] [PATCH 6/6] net/nfp: support IOVA VA mode Alejandro Lucero
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAD+H992hfhhEzVAxjLENd41ZmdxsvWcAyYG3FLuMQGB8Hghxaw@mail.gmail.com \
--to=alejandro.lucero@netronome.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).