DPDK patches and discussions
 help / color / mirror / Atom feed
From: Narcisa Ana Maria Vasile <Narcisa.Vasile@microsoft.com>
To: "dev@dpdk.org" <dev@dpdk.org>, thomas <thomas@monjalon.net>,
	Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
	"Kadam, Pallavi" <pallavi.kadam@intel.com>
Cc: "Dmitry Malloy (MESHCHANINOV)" <dmitrym@microsoft.com>,
	Omar Cardona <ocardona@microsoft.com>,
	Harini Ramakrishnan <Harini.Ramakrishnan@microsoft.com>,
	Khoa To <khot@microsoft.com>, Jie Zhou <jizh@microsoft.com>,
	Tal Shnaiderman <talshn@nvidia.com>,
	ranjit.menon <ranjit.menon@intel.com>,
	Tyler Retzlaff <roretzla@microsoft.com>
Subject: [dpdk-dev] Importing DATA into the application
Date: Tue, 8 Dec 2020 07:03:05 +0000	[thread overview]
Message-ID: <MWHPR21MB0765D111A0B8ADD90358677D8ECD1@MWHPR21MB0765.namprd21.prod.outlook.com> (raw)

Hi,

While using the DPDK libs as DLLs, I've ran into some access violation errors. I believe they are caused by some incorrect imports.
In Windows, accessing an imported variable is done either by using __declspec(dllimport), or by using an extra level of indirection[1].

Some examples of variables in DPDK that are not declared correctly:
rte_cycles.h: extern void (*rte_delay_us)(unsigned int us);
rte_mempool.h: extern struct rte_mempool_ops_table rte_mempool_ops_table;
rte_lcore.h: RTE_DECLARE_PER_LCORE(unsigned, _lcore_id); (Which expands to extern __thread unsigned per_lcore__lcore_id)

To fix this, we need to add the __declspec(dllimport) keyword to the declarations of these symbols. Also, we need to consider that the symbols can be used both internally(in the same module) and externally (imported by other modules).
We can define a macro that will tell if the symbol is used internally or is imported by a different DLL. Example:

#ifdef RTE_INTERNAL
extern void (*rte_delay_us)(unsigned int us);
#else
__declspec(dllimport) void (*rte_delay_us)(unsigned int us);
#endif

We can then hide the Windows-specific keywords under a new macro, such as:
#define RTE_IMPORT __declspec(dllimport)

However, there are a few issues to consider:
* We cannot add __declspec(dllimport)  when declaring per_lcore__lcore_id for example. We cannot have both __thread and __declspec(dllimport)  (can't import thread local variables).

Have you discussed/run into these issues before? Let me know what you think.

Thanks,
Naty

[1] https://docs.microsoft.com/en-us/cpp/build/importing-using-def-files?view=msvc-160

             reply	other threads:[~2020-12-08  7:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08  7:03 Narcisa Ana Maria Vasile [this message]
2020-12-08  7:47 ` Thomas Monjalon
2020-12-08 10:06   ` Dmitry Kozlyuk

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=MWHPR21MB0765D111A0B8ADD90358677D8ECD1@MWHPR21MB0765.namprd21.prod.outlook.com \
    --to=narcisa.vasile@microsoft.com \
    --cc=Harini.Ramakrishnan@microsoft.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=dmitrym@microsoft.com \
    --cc=jizh@microsoft.com \
    --cc=khot@microsoft.com \
    --cc=ocardona@microsoft.com \
    --cc=pallavi.kadam@intel.com \
    --cc=ranjit.menon@intel.com \
    --cc=roretzla@microsoft.com \
    --cc=talshn@nvidia.com \
    --cc=thomas@monjalon.net \
    /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).