Support non-PCI devices
Re: [PATCH v3 06/15] eal/soc: implement probing of drivers
In reply to Jan ViktorinHi Jan,
Quoted 58 lines
-----Original Message-----
From: Jan Viktorin [mailto:[email protected]]
Sent: Monday, September 19, 2016 5:04 PM
To: Shreyansh Jain <[email protected]>
Cc: [email protected]; Hemant Agrawal <[email protected]>
Subject: Re: [PATCH v3 06/15] eal/soc: implement probing of driversQuoted 7 lines · On Mon, 19 Sep 2016 12:17:53 +0530 Shreyansh Jain <[email protected]>…
Hi Jan,
Quoted 4 lines · Jan Viktorin
Quoted 1 line · On Fri, 9 Sep 2016 14:13:50 +0530 Shreyansh Jain <[email protected]> wrote:
Each SoC PMD registers a set of callback for scanning its own bus/infra
and
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
matching devices to drivers when probe is called. This patch introduces the infra for calls to SoC scan on
rte_eal_soc_init()Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
and match on
rte_eal_soc_probe().Patch also adds test case for scan and probe.
Signed-off-by Jan Viktorin <[email protected]>Signed-off-by Shreyansh Jain <[email protected]>Signed-off-by Hemant Agrawal <[email protected]>--- app/test/test_soc.c | 138 ++++++++++++++- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 4 + lib/librte_eal/common/eal_common_soc.c | 215++++++++++++++++++++++++
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/common/include/rte_soc.h | 51 ++++++ lib/librte_eal/linuxapp/eal/eal.c | 5 + lib/librte_eal/linuxapp/eal/eal_soc.c | 16 ++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 4 + 7 files changed, 432 insertions(+), 1 deletion(-)[...]
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
+static void
test_soc_scan_dev0_cb(void);Similar here, something like "
match_by_name".Review
Quoted 2 lines
(quoted diff) +2
-0+static int test_soc_match_dev0_cb(struct rte_soc_driver *drv, + struct rte_soc_device *dev);I prefer an empty line here.
Quoted 4 lines
Do we really place newlines in function declarations? That doesn't really help anything, until and unless some comments are added to those. Anyways, rather than added blank lines, I will add some comments - those are indeed misssing.
Quoted 4 lines
It took me a while to parse those lines... If they are logically grouped, it'd be ok. Comments might be helpful. However, here these are forward declarations so it's a question whether to put comments here or to the implementations below.
Ok. I will keep this mind in v4.
Quoted 36 lines
Quoted 16 lines
Quoted 5 lines
ditto...
Will add comments.
Quoted 4 lines
Quoted 2 lines
+static void
test_soc_scan_dev1_cb(void);ditto...
Same here, I prefer comment rather than blank line.
Quoted 1 line
[...]
Quoted 9 lines
Quoted 8 lines
app/test/test_soc.c test_register_unregister(void) · line 229
Quoted 4 lines
app/test/test_soc.c +3
-0+/* Test Probe (scan and match) functionality */ +static int +test_soc_init_and_probe (void )You say to test scan and match. I'd prefer to reflect this in the name of the test. Otherwise, it seems you are testing init and probe which is not true, I think.
Quoted 7 lines
I agree. I will update the name of the function.
Quoted 3 lines
Do you test that "match principle works" or that "match functions are OK" or "match functions are called as expected", ...?
"match functions are called as expected"
Quoted 8 lines
OK, but there is no assert that says "yes, the match function has been called".
In other words, it is not an automatic test and it does not help to verify that the code is working.I think that you should test that a particular match function succeeds or not.
So again, I don't consider this to be a test. It does not verify anything.
Agree with you. This is not a 'test' in real sense. I will revisit and see what can be done about this. Probably your method of 'match' succeeds with 'always_find_device0' style function.
Quoted 9 lines
Quoted 3 lines
The model for the patchset was to allow PMDs to write their own match and hence, verifying a particular match is not definitive. Rather, the
If you want to verify a particular match implementation then there should be a particular test verifying that implementation, e.g.
test_match_compatible(),test_match_proprietary,test_match_by_name.
Quoted 9 lines
However, this is testing the
rte_eal_soc_probe(at least, I understand it that way).
The probe iterates over devices and drivers and matches them. Thus, the argument
"a particular match is not definitive" seems to be irrelevant here. You should build
a testing match function like "match_always" that verifies the probe is working. Not
that the "match" is working.
Ok. 'match_always' called after 'always_find_device0' like scan function. So, essentially rather than a functional match, the testcase only checks if these handlers can be called or not. The naming of such handlers in test case would explain the user what the intention of the test is, rather than its outcome. Is this what you are suggesting?
Quoted 24 lines
Quoted 2 lines
test case simply confirms that a SoC based PMD would be able to
It does not confirm anything from my point of view. You *always* print "successful"
at the end of this test (see below).Quoted 1 line
implement its own match/scan and these would be called from EAL as
expected.
Quoted 9 lines
Quoted 9 lines
app/test/test_soc.c test_register_unregister(void)
Quoted 9 lines
app/test/test_soc.c +7
-0+{ +struct rte_soc_driver *drv; + +/* Registering dummy drivers */ +rte_eal_soc_register (&empty_pmd0.soc_drv); +rte_eal_soc_register (&empty_pmd1.soc_drv); +/* Assuming that test_register_unregister is working, not verifying
Quoted 4 lines
Quoted 4 lines
app/test/test_soc.c test_register_unregister(void)
Quoted 4 lines
app/test/test_soc.c +4
-0+* that drivers are indeed registered +*/ + +/* rte_eal_soc_init is called by rte_eal_init, which in turn calls the
Quoted 5 lines
Quoted 1 line
Quoted 1 line
app/test/test_soc.c test_register_unregister(void) · line 241
Quoted 1 line
app/test/test_soc.c +1
-0+* scan_fn of each driver. So, I'd comment this as something like:
"mimic
rte_eal_soc_initto prepare for therte_eal_soc_probe"
Agree.
Quoted 37 lines
Quoted 29 lines
Quoted 8 lines
app/test/test_soc.c test_register_unregister(void) · line 246
Quoted 6 lines
app/test/test_soc.c +5
-0+*/ + TAILQ_FOREACH(drv, &soc_driver_list, next) { +if (drv && drv->scan_fn) + drv->scan_fn (); + }Here, I suppose you mimic the
rte_eal_soc_init?Yes.
Quoted 17 lines
Quoted 4 lines
app/test/test_soc.c +3
-0+ +/* rte_eal_init() would perform other inits here */ +app/test/test_soc.c test_register_unregister(void) · line 259
Quoted 10 lines
app/test/test_soc.c +10
-0+/* Probe would link the SoC devices<=>drivers */ +rte_eal_soc_probe (); + +/* Unregistering dummy drivers */ +rte_eal_soc_unregister (&empty_pmd0.soc_drv); +rte_eal_soc_unregister (&empty_pmd1.soc_drv); + +free (empty_pmd0.soc_dev.addr.name); + +printf ("%s has been successful\n" , __func__);How you detect it is unsuccessful? Is it possible to fail in this test? A test that can never fail is in fact not a test :).
Quoted 7 lines
The design assumption for SoC patcheset was: A PMDs scan is called to find devices on its bus (PMD ~ bus). Whether devices are found or not, is irrelevant to EAL - whether that is because of error or actually no devices were available.
With the above logic, no 'success/failure' is checked in the test. It is simply a verification of EAL's ability to link the PMD with it (scan/match function pointers).
Quoted 4 lines
I am sorry, I disagree. You always print "successful". The only way to fail here is a SIGSEGV or other very serious system failure. But we test
rte_eal_soc_probe
and not system failures.
Ok. I am not yet clear how the test case would be created, except what I have mentioned above that rather than being functional, testcase only explains the case through function naming. The premise on which match/scan are based is that they would be implemented by the respective PMD. Which makes testing of such function either irrelevant or simply a help to user to understand how SoC PMD should be created. If this persists, probably I would rather remove this test case all together. It doesn't serve any purpose, which you have rightly pointed out.
Quoted 54 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
app/test/test_soc.c +3
-0+return 0 ; +} +/* save real devices and drivers until the tests finishes */ [...]
Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/lib/librte_eal/common/eal_common_soc.cQuoted 12 lines
Quoted 12 lines
Quoted 12 lines
index 5dcddc5..bb87a67 100644
lib/librte_eal/common/eal_common_soc.c +2
-0@@ -36,6 +36,8 @@#include <sys/queue.h> #include <rte_log.h> +#include <rte_common.h> +#include <rte_soc.h> #include "eal_private.h" Quoted 7 lines
Quoted 7 lines
lib/librte_eal/common/eal_common_soc.c struct soc_driver_list soc_driver_list = · line 50
Quoted 5 lines
lib/librte_eal/common/eal_common_soc.c +1
-0@@ -45,6 +47,213 @@ struct soc_driver_list soc_driver_list =struct soc_device_list soc_device_list =TAILQ_HEAD_INITIALIZER (soc_device_list); +/* Default SoC device<->Driver match handler function */ I think this comment is redundant. All this is already said in the
rte_soc.h.Quoted 7 lines
Ok. I will remove it from here and if need be, update the
rte_soc.hto have elaborate comments.Quoted 3 lines
lib/librte_eal/common/eal_common_soc.c struct soc_driver_list soc_driver_list = · line 52
Quoted 3 lines
lib/librte_eal/common/eal_common_soc.c +2
-0+int +rte_eal_soc_match(struct rte_soc_driver *drv, struct rte_soc_device*dev)
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_eal/common/eal_common_soc.c +14
-0+{ +int i, j; + +RTE_VERIFY (drv !=NULL && drv->id_table !=NULL ); +RTE_VERIFY (dev !=NULL && dev->id !=NULL ); + +for (i =0 ; drv->id_table[i].compatible; ++i) { +const char *drv_compat = drv->id_table[i].compatible; + +for (j =0 ; dev->id[j].compatible; ++j) { +const char *dev_compat = dev->id[j].compatible; + +if (!strcmp (drv_compat, dev_compat)) +return 0 ;
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/common/eal_common_soc.c struct soc_driver_list soc_driver_list = · line 72
Quoted 6 lines
lib/librte_eal/common/eal_common_soc.c +6
-0+ } + } + +return 1 ; +} +A redundant empty line here...
Yes, I will remove this.
Quoted 17 lines
Quoted 12 lines
Quoted 11 lines
lib/librte_eal/common/eal_common_soc.c struct soc_driver_list soc_driver_list = · line 79
Quoted 8 lines
lib/librte_eal/common/eal_common_soc.c +7
-0+ +static int +rte_eal_soc_probe_one_driver (struct rte_soc_driver *drv, +struct rte_soc_device *dev) +{ +int ret =1 ; +I think, the
RTE_VERIFY(dev->match_fn)might be good here. It avoids any doubts about the validity of the pointer.Quoted 4 lines
That has already been done in
rte_eal_soc_registerwhich is called when PMDs are registering themselves throughDRIVER_REGISTER_SOC. That would prevent any PMD leaking through to this stage without a proper match_fn/scan_fn.
Quoted 9 lines
Well, yes. It seems to be redundant. However, it would emphesize the fact that this function expects that
match_fnis set.In the
rte_eal_soc_register, theRTE_VERIFYsays "The API requires those".But when I review I do not always see all the context. It is not safe for me to assume that there was probably some
RTE_VERIFYin the path... It is not a fast path so it does not hurt the performance in anyway.
You mean RTE_VERIFY should be duplicated so that code readability increases?
I am not really convinced on that.
My opinion: rte_eal_soc_*probe* series shouldn't actually worry about whether a valid PMD has been plugged in or. It should simply assume that having reached here, all is well on the PMDs definition side.
On the contrary, placing a RTE_VERIFY here would only state the reader that it is possible to reach this code path without a valid match function.
Quoted 26 lines
Quoted 10 lines
Quoted 9 lines
lib/librte_eal/common/eal_common_soc.c struct soc_driver_list soc_driver_list = · line 83
Quoted 6 lines
lib/librte_eal/common/eal_common_soc.c +4
-0+ ret = drv->match_fn (drv, dev); +if (ret) { +RTE_LOG (DEBUG ,EAL , +" match function failed, skipping\n" );Is this a failure? I think it is not. Failure would be if the match function cannot execute correctly. This is more like "no-match".
Quoted 5 lines
The log message is misleading. This is _not_ a failure but simply a 'no-match'. I will update this.
Quoted 2 lines
When debugging, I'd like to see more a message like "driver <name> does
not match".
Quoted 9 lines
Problem would be about '<name>' of a driver. There is already another discussion about SoC capability/platform bus definitions - probably I will wait for that so as to define what a '<name>' for a driver and device is.
In this case, the key reason for not adding such a message was because it was assumed PMDs are black boxes with EAL not even assuming what '<name>' means. Anyways, it is better to discuss these things in that other email.
Quoted 1 line
I am not sure which thread do you mean... Can you point me there, please?
Sorry, somehow I forgot to add that:
http://dpdk.org/ml/archives/dev/2016-September/046933.html
One of the discussion point in above thread is whether platform bus is a good assumption for a SoC driver or not. Based on that '<name>' (or any other identifier, like 'compatible'), the log can be printed as you suggested above.
Quoted 31 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_eal/common/eal_common_soc.c +1
-0+return ret;[...]
Quoted 11 lines
Quoted 11 lines
lib/librte_eal/common/eal_common_soc.c struct soc_driver_list soc_driver_list =
Quoted 11 lines
lib/librte_eal/common/eal_common_soc.c +11
-0+ +int +rte_eal_soc_probe_one (const struct rte_soc_addr *addr) +{ +struct rte_soc_device *dev =NULL ; +int ret =0 ; + +if (addr ==NULL ) +return -1 ; + +/* unlike pci, in case of soc, it the responsibility of the soc driver
Quoted 1 line
Quoted 1 line
lib/librte_eal/common/eal_common_soc.c
Quoted 1 line
lib/librte_eal/common/eal_common_soc.c +1
-0+* to check during init whether device has been updated since last add.
Quoted 10 lines
Quoted 2 lines
Why? Can you give a more detailed explanation?
For this patch, I have _not_ assumed anything for a SoC's bus/driver/device model. In absence of a proper standard, each SoC is unique - categorizing all SoC under a platform bus, for example, would only mean assuming platform bus is a standard.
Best judge for the layout of SoC devices is the SoC PMD (which is also like a bus driver, other than being a device driver).
Quoted 4 lines
Quoted 2 lines
Once again, if the discussion in other thread comes to a logical conclusion, this would get updated.
Again, I am not sure which thread discusses this topic.
Copying the link again: http://dpdk.org/ml/archives/dev/2016-September/046933.html
Quoted 4 lines
I just don't like the idea to leave update responsibility on PMDs. Maybe, there can be a callback update in
rte_soc_device(set or not-set by the custom scan function) that is to be called here.
And for me, the very idea of 'leave update responsibility to PMD' is appealing in case of SoC.
Though, I think your suggestion of 'callback' is pretty good. Just to clarify, is my understanding correct: PMD registers a callback for 'update' and EAL would call that when it reaches this code path (of update device information during probe). The callback can be passed the device found so that PMD can update that. Is that what you too had in mind?
Quoted 63 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
lib/librte_eal/common/eal_common_soc.c +13
-0+*/ + + TAILQ_FOREACH(dev, &soc_device_list, next) { +if (rte_eal_compare_soc_addr (&dev->addr, addr)) +continue ; + + ret =soc_probe_all_drivers (dev); +if (ret <0 ) + goto err_return; +return 0 ; + } +return -1 ; +Quoted 8 lines
Quoted 8 lines
lib/librte_eal/common/eal_common_soc.c struct soc_driver_list soc_driver_list =
Quoted 8 lines
lib/librte_eal/common/eal_common_soc.c +8
-0+err_return: +RTE_LOG (WARNING ,EAL , +"Requested device %s cannot be used\n" , addr->name); +return -1 ; +} + +/* +* Scan the SoC devices and call the devinit() function for all registered
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ * drivers that have a matching entry in its
id_tablefor discovereddevices.
Quoted 36 lines
Quoted 3 lines
Quoted 1 line
+ */
Should be in header. Here it is redundant.
Ok. I will move to
rte_soc.h.Quoted 29 lines
Quoted 21 lines
lib/librte_eal/common/eal_common_soc.c +16
-0+int +rte_eal_soc_probe (void ) +{ +struct rte_soc_device *dev =NULL ; +int ret =0 ; + + TAILQ_FOREACH(dev, &soc_device_list, next) { + ret =soc_probe_all_drivers (dev); +if (ret <0 ) +rte_exit (EXIT_FAILURE ,"Requested device %s" +" cannot be used\n" , dev->addr.name); + } + +return 0 ; +} +/* dump one device */ static int soc_dump_one_device (FILE *f,struct rte_soc_device *dev)lib/librte_eal/common/eal_common_soc.c rte_eal_soc_dump(FILE *f) · line 293
Quoted 6 lines
lib/librte_eal/common/eal_common_soc.c +3
-0@@ -79,6 +288,12 @@ rte_eal_soc_dump(FILE *f)void rte_eal_soc_register (struct rte_soc_driver *driver) { +/* For a valid soc driver, match and scan function +* should be provided. +*/ This comment should be in the header file.
Quoted 7 lines
Quoted 2 lines
Actually there is no valueable addition made by this comment.
RTE_VERIFYis self explanatory. I will remove the comment all together.No, the comment must be present for the
rte_eal_soc_registerfunction as its documentation. TheRTE_VERIFYis not an excuse, it just verifies the fact that the caller understands the documentation and that she didn't make a mistake.
Ok. It doesn't hurt to have a comment. I will add that.
Quoted 82 lines
Quoted 10 lines
Quoted 10 lines
Review
Quoted 10 lines
lib/librte_eal/common/eal_common_soc.c +3
-0+RTE_VERIFY (driver !=NULL ); +RTE_VERIFY (driver->match_fn !=NULL ); +RTE_VERIFY (driver->scan_fn !=NULL );TAILQ_INSERT_TAIL (&soc_driver_list, driver, next); }(quoted diff) +0
-0
b/lib/librte_eal/common/include/rte_soc.hQuoted 4 lines
Quoted 4 lines
lib/librte_eal/common/include/rte_soc.h typedef int (soc_devinit_t)(struct rte_soc_driver *,
Quoted 4 lines
index c6f98eb..bfb49a2 100644
lib/librte_eal/common/include/rte_soc.h +0
-0@@ -97,6 +97,16 @@ typedef int (soc_devinit_t)(struct rte_soc_driver *,struct
rte_soc_device*);Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
lib/librte_eal/common/include/rte_soc.h +1
-0typedef int (soc_devuninit_t )(struct rte_soc_device *);/** +* SoC device scan callback, called from rte_eal_soc_init. Quoted 8 lines
Quoted 2 lines
Can you explain what is the goal of the callback?
What is the expected behaviour.EAL would call the scan of each registered SoC PMD (
DRIVER_REGISTER_SOC). This scan is responsible for finding devices on SoC's specific bus and add them to SoCdevice_list. This is a callback because SoC don't have a generalization like PCI. A SoC is not necessarily a platform bus either (what original patch series assumed).In doc comment...
Quoted 6 lines
Quoted 5 lines
It returns void so it seems it can never fail. Is this correct? I can image that to scan for devices, I need to check some file-system structure which can be unavailable...
Quoted 6 lines
This is what I had in mind:
That is true, it never fails. It is expected that scan function simply ignores (logs error) and moves ahead. A local error for a particular SoC (I agree, there might not be more than one SoC) doesn't necessarily mean that complete DPDK Application should quit. It only means that application user should get some error/warning/message about failure.I understand, this is OK then.
Quoted 9 lines
Quoted 6 lines
lib/librte_eal/common/include/rte_soc.h typedef int (soc_devinit_t)(struct rte_soc_driver *, struct rte_soc_device *); · line 102
Quoted 4 lines
lib/librte_eal/common/include/rte_soc.h +2
-0+*/ +typedef void (soc_scan_t )(void );You are missing the '*' in (
*soc_scan_t).That was put in the definition in the
rte_soc_driver- but, I see you have already commented there. I will add the '*' here and remove fromthere.
Quoted 11 lines
Quoted 7 lines
lib/librte_eal/common/include/rte_soc.h typedef int (soc_devinit_t)(struct rte_soc_driver *, struct rte_soc_device *); · line 105
Quoted 5 lines
lib/librte_eal/common/include/rte_soc.h +3
-0+ +/** +* Custom device<=>driver match callback for SoC Can you explain the semantics (return values), please?
rte_soc.halready has explanation on the expected semantics overrte_eal_soc_match- the default implementation. But, I agree, it should be above this declaration.True ;).
Quoted 4 lines
Quoted 4 lines
lib/librte_eal/common/include/rte_soc.h typedef int (soc_devinit_t)(struct rte_soc_driver *, · line 107
Quoted 4 lines
lib/librte_eal/common/include/rte_soc.h +2
-0+*/ +typedef int (soc_match_t)(struct rte_soc_driver *, struct
rte_soc_device*);Quoted 1 line
Quoted 1 line
[...]
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
I think, we should tell the users that
scan_fnandmatch_fnmust bealways set
Quoted 3 lines
Quoted 1 line
to something.
How? I think it would be part of documentation, isn't it?
Yes. It should be documented in the comment for
rte_eal_soc_init. My comment was misplaced a bit...
Ok.
Quoted 71 lines
Quoted 5 lines
Also,
rte_eal_soc_init()already enforces this check withRTE_VERIFY.Quoted 2 lines
Quoted 2 lines
const struct
rte_soc_id*id_table; /**< ID table, NULL terminated*/
Quoted 3 lines
Quoted 3 lines
lib/librte_eal/common/include/rte_soc.h rte_eal_compare_soc_addr(const struct rte_soc_addr
Quoted 3 lines
};
lib/librte_eal/common/include/rte_soc.h +0
-0@@ -146,6 +158,45 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr*a0,
Quoted 4 lines
Quoted 4 lines
lib/librte_eal/common/include/rte_soc.h rte_eal_compare_soc_addr(const struct rte_soc_addr · line 161
Quoted 4 lines
lib/librte_eal/common/include/rte_soc.h +1
-0}/** +* Default function for matching the Soc driver with device. Each driver can
Quoted 2 lines
Quoted 2 lines
lib/librte_eal/common/include/rte_soc.h rte_eal_compare_soc_addr(const struct rte_soc_addr · line 163
Quoted 2 lines
lib/librte_eal/common/include/rte_soc.h +2
-0+* either use this function or define their own soc matching function. +* This function relies on the compatible string extracted from sysfs. But,
Quoted 1 line
Quoted 1 line
lib/librte_eal/common/include/rte_soc.h rte_eal_compare_soc_addr(const struct rte_soc_addr · line 164
Quoted 1 line
lib/librte_eal/common/include/rte_soc.h +1
-0+* a SoC might have different way of identifying its devices. Such SoC can
Quoted 8 lines
Quoted 8 lines
lib/librte_eal/common/include/rte_soc.h rte_eal_compare_soc_addr(const struct rte_soc_addr *a0,
Quoted 8 lines
lib/librte_eal/common/include/rte_soc.h +8
-0+* override match_fn. +* +* @return +* 0 on success +* -1 when no match found +*/ +int +rte_eal_soc_match(struct rte_soc_driver *drv, struct rte_soc_device*dev);
Quoted 10 lines
Quoted 4 lines
What about naming it
rte_eal_soc_match_defaultOk.
Quoted 3 lines
or maybe better
Quoted 7 lines
Quoted 3 lines
rte_eal_soc_match_compatiblewhat do you think?
From what I had in mind - the discussion about SoC not necessarily
being a Platform bus - 'compatible' doesn't look fine to me. But again, it is still open debate so - I will wait until that is conlcuded.Why? The current implementation works this way:
int
rte_eal_soc_match(struct rte_soc_driver *drv, struct rte_soc_device *dev){ int i, j; RTE_VERIFY(drv != NULL && drv->id_table != NULL); RTE_VERIFY(dev != NULL && dev->id != NULL); for (i = 0; drv->id_table[i].compatible; ++i) { const char *drv_compat = drv->id_table[i].compatible; for (j = 0; dev->id[j].compatible; ++j) { const char *dev_compat = dev->id[j].compatible; if (!strcmp(drv_compat, dev_compat)) return 0; } } return 1; }
Quoted 2 lines
It checks for compatible. So why not to name it that way? If you provide a match testing the name of devices then it can be named
*_match_name.
I think all the confusion is about whether match on compatible string should be kept as default or not.
My opinion: No.
Because I have a usecase where the SoC PMD is not a platform bus. [1]
By keeping a 'compatible' string based match, it would be obvious to have a scan for /sys/bus/platform. That in itself is based on assumption that a SoC is platform bus and would adhere to generally known semantics of a platform bus.
Other the other hand, as Hemant has suggested in [1], plan is to have a skeletal code for SoC framework - one which allows any SoC PMD to be plugged in irrespective of the bus/device design. Thereafter, when more PMDs become part of the DPDK framework, generalize functions (which is where your implementations of scan/match over /sys/bus/platform fit pretty well).
[1] http://dpdk.org/ml/archives/dev/2016-September/046967.html
Quoted 81 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
lib/librte_eal/common/include/rte_soc.h +23
-0+ +/** +* Probe SoC devices for registered drivers. +*/ +int rte_eal_soc_probe (void ); + +/** +* Probe the single SoC device. +*/ +int rte_eal_soc_probe_one (const struct rte_soc_addr *addr); + +/** +* Close the single SoC device. +* +* Scan the SoC devices and find the SoC device specified by the SoC +* address, then call the devuninit() function for registered driver +* that has a matching entry in its id_table for discovered device. +* +* @param addr +* The SoC address to close. +* @return +* - 0 on success. +* - Negative on error. Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
lib/librte_eal/common/include/rte_soc.h +4
-0+*/ +int rte_eal_soc_detach (const struct rte_soc_addr *addr); + +/** * Dump discovered SoC devices. */ void rte_eal_soc_dump (FILE *f);(quoted diff) +0
-0
b/lib/librte_eal/linuxapp/eal/eal.cQuoted 15 lines
Quoted 15 lines
Quoted 15 lines
index 15c8c3d..147b601 100644
lib/librte_eal/linuxapp/eal/eal.c +1
-0@@ -70,6 +70,7 @@#include <rte_cpuflags.h> #include <rte_interrupts.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_dev.h> #include <rte_devargs.h> #include <rte_common.h> @@ -881,6 +882,10 @@ rte_eal_init(int argc, char **argv)if (rte_eal_pci_probe ())rte_panic ("Cannot probe PCI\n" );Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal.c +4
-0+/* Probe & Initialize SoC devices */ +if (rte_eal_soc_probe ()) +rte_panic ("Cannot probe SoC\n" ); +rte_eal_mcfg_complete ();return fctret;(quoted diff) +0
-0
b/lib/librte_eal/linuxapp/eal/eal_soc.cQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
index 04848b9..5f961c4 100644
lib/librte_eal/linuxapp/eal/eal_soc.c +0
-0@@ -52,5 +52,21 @@int rte_eal_soc_init (void )Quoted 8 lines
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal_soc.c
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +7
-0{ +struct rte_soc_driver *drv; + +/* for debug purposes, SoC can be disabled */ +if (internal_config.no_soc) +return 0 ; + +/* For each registered driver, call their scan routine to perform any
Quoted 7 lines
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_soc.c line 64
Quoted 3 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +3
-0+* custom scan for devices (for example, custom buses) +*/ + TAILQ_FOREACH(drv, &soc_driver_list, next) {Is it possible to have
drv->scan_fn== NULL? I suppose, this is invalid. I'd prefer to haveRTE_VERIFYfor this check.
Quoted 7 lines
Quoted 2 lines
rte_eal_soc_init()has this check already. Driver wouldn't even be registered in case scan/match are not implemented.True, but when reviewing or refactoring, you cannot see always all this context.
It is more defensive to explain here "don't worry, thescan_fnis always set here".
Ok. I will add this.
Quoted 32 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +4
-0+if (drv && drv->scan_fn) { + drv->scan_fn (); +/* Ignore all errors from this */ + }Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +2
-0+ } +return 0 ; }(quoted diff) +0
-0b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
Quoted 18 lines
Quoted 17 lines
lib/librte_eal/linuxapp/eal/rte_eal_version.map DPDK_16.11 { · line 187
Quoted 13 lines
index b9d1932..adcfe7d 100644
lib/librte_eal/linuxapp/eal/rte_eal_version.map +4
-0@@ -179,5 +179,9 @@ DPDK_16.11 { rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_soc_dump; + rte_eal_soc_match; + rte_eal_soc_detach; + rte_eal_soc_probe; + rte_eal_soc_probe_one; } DPDK_16.07;Regards
Jan
Quoted 7 lines
Quoted 5 lines
I hope I have covered all your comments. That was an exhaustive review. Thanks a lot for your time.
Lets work to resolve the architectural issues revolving around SoC scan/match.
;)
Phew!
I am already loosing track of things you have suggested.
What if we can chat on IRC and resolve the issue surrounding the 'default match/scan', 'platform or not platform dependent SoC' etc? I think it would save a lot of ping-pong effort. (For today (20/Sep), I might not be available, but I am OK any other time).
Quoted 7 lines
Quoted 4 lines
-
Shreyansh
Quoted 5 lines
--
Jan Viktorin E-mail: [email protected]
System Architect Web: www.RehiveTech.com
RehiveTech
Brno, Czech Republic
Thanks a lot.
-
Shreyansh
Re: [PATCH v3 06/15] eal/soc: implement probing of drivers
Quoted 13 lines · On Tue, 20 Sep 2016 06:46:31 +0000 Shreyansh Jain <[email protected]>…
Hi Jan,
Quoted 11 lines
-----Original Message-----
From: Jan Viktorin [mailto:[email protected]]
Sent: Monday, September 19, 2016 5:04 PM
To: Shreyansh Jain <[email protected]>
Cc: [email protected]; Hemant Agrawal <[email protected]>
Subject: Re: [PATCH v3 06/15] eal/soc: implement probing of driversQuoted 1 line · On Mon, 19 Sep 2016 12:17:53 +0530 Shreyansh Jain <[email protected]>…
Hi Jan,
[...]
Quoted 20 lines
Quoted 10 lines
Quoted 4 lines
The model for the patchset was to allow PMDs to write their own match and hence, verifying a particular match is not definitive. Rather, the
If you want to verify a particular match implementation then there should be a particular test verifying that implementation, e.g.
test_match_compatible(),test_match_proprietary,test_match_by_name.Quoted 9 lines
However, this is testing the
rte_eal_soc_probe(at least, I understand it that way).
The probe iterates over devices and drivers and matches them. Thus, the argument
"a particular match is not definitive" seems to be irrelevant here. You should build
a testing match function like "match_always" that verifies the probe is working. Not
that the "match" is working.
Quoted 1 line
Ok. '
match_always' called after 'always_find_device0' like scan function. So, essentially rather than a functional match, the testcase only checks if these handlers can be called or not. The naming of such handlers in test case would explain the user what the intention of the test is, rather than its outcome. Is this what you are suggesting?
Yes, it seems to be ;).
Quoted 70 lines
Quoted 25 lines
Quoted 3 lines
test case simply confirms that a SoC based PMD would be able to
It does not confirm anything from my point of view. You *always* print "successful"
at the end of this test (see below).Quoted 1 line
implement its own match/scan and these would be called from EAL as
expected.
Quoted 9 lines
Quoted 9 lines
app/test/test_soc.c test_register_unregister(void)
Quoted 9 lines
app/test/test_soc.c +7
-0+{ +struct rte_soc_driver *drv; + +/* Registering dummy drivers */ +rte_eal_soc_register (&empty_pmd0.soc_drv); +rte_eal_soc_register (&empty_pmd1.soc_drv); +/* Assuming that test_register_unregister is working, not verifying
Quoted 4 lines
Quoted 4 lines
app/test/test_soc.c test_register_unregister(void)
Quoted 4 lines
app/test/test_soc.c +4
-0+* that drivers are indeed registered +*/ + +/* rte_eal_soc_init is called by rte_eal_init, which in turn calls the
Quoted 5 lines
Quoted 1 line
Quoted 1 line
app/test/test_soc.c test_register_unregister(void) · line 241
Quoted 1 line
app/test/test_soc.c +1
-0+* scan_fn of each driver. So, I'd comment this as something like:
"mimic
rte_eal_soc_initto prepare for therte_eal_soc_probe"Agree.
Quoted 37 lines
Quoted 36 lines
Quoted 8 lines
app/test/test_soc.c test_register_unregister(void) · line 246
Quoted 6 lines
app/test/test_soc.c +5
-0+*/ + TAILQ_FOREACH(drv, &soc_driver_list, next) { +if (drv && drv->scan_fn) + drv->scan_fn (); + }Here, I suppose you mimic the
rte_eal_soc_init?Yes.
Quoted 17 lines
Quoted 4 lines
app/test/test_soc.c +3
-0+ +/* rte_eal_init() would perform other inits here */ +app/test/test_soc.c test_register_unregister(void) · line 259
Quoted 10 lines
app/test/test_soc.c +10
-0+/* Probe would link the SoC devices<=>drivers */ +rte_eal_soc_probe (); + +/* Unregistering dummy drivers */ +rte_eal_soc_unregister (&empty_pmd0.soc_drv); +rte_eal_soc_unregister (&empty_pmd1.soc_drv); + +free (empty_pmd0.soc_dev.addr.name); + +printf ("%s has been successful\n" , __func__);How you detect it is unsuccessful? Is it possible to fail in this test? A test that can never fail is in fact not a test :).
The design assumption for SoC patcheset was: A PMDs scan is called to find devices on its bus (PMD ~ bus). Whether devices are found or not, is irrelevant to EAL - whether that is because of error or actually no devices were available.
With the above logic, no 'success/failure' is checked in the test. It is simply a verification of EAL's ability to link the PMD with it (scan/match function pointers).
Quoted 8 lines
Quoted 4 lines
I am sorry, I disagree. You always print "successful". The only way to fail here is a SIGSEGV or other very serious system failure. But we test
rte_eal_soc_probe
and not system failures.Ok. I am not yet clear how the test case would be created, except what I have mentioned above that rather than being functional, testcase only explains the case through function naming. The premise on which match/scan are based is that they would be implemented by the respective PMD. Which makes testing of such function either irrelevant or simply a help to user to understand how SoC PMD should be created. If this persists, probably I would rather remove this test case all together. It doesn't serve any purpose, which you have rightly pointed out.
I'd vote to have this test to check for regressions. See the test_pci.c, e.g. test_pci_blacklist(). It is not ideal but it works. You can check how many devices have been matched or seen.
Unfortunately, I am not familiar with DPAA2 API. I assume that it works via /sys as well as platform_device but with different properties. You can create a fake /sys sub-tree (see app/test/test_pci_sysfs/) and test whether your scan function reads data successfully and fills all the structures as expected. I think, there is a lot of space in this area.
Next, is it possible to write a generic DPAA2 backend for the SoC Framework? I mean to not introduce the DPAA2 into PMDs (this looks like mixing of responsibilities) but have it in EAL as an alternative to UIO, VFIO, etc. I suppose that as DPAA2 is a kind of API, it should be possible to go this way.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
app/test/test_soc.c +3
-0+return 0 ; +} +/* save real devices and drivers until the tests finishes */
[...]
Quoted 57 lines
Quoted 19 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +2
-0+int +rte_eal_soc_match(struct rte_soc_driver *drv, struct rte_soc_device*dev)
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_eal/common/eal_common_soc.c +14
-0+{ +int i, j; + +RTE_VERIFY (drv !=NULL && drv->id_table !=NULL ); +RTE_VERIFY (dev !=NULL && dev->id !=NULL ); + +for (i =0 ; drv->id_table[i].compatible; ++i) { +const char *drv_compat = drv->id_table[i].compatible; + +for (j =0 ; dev->id[j].compatible; ++j) { +const char *dev_compat = dev->id[j].compatible; + +if (!strcmp (drv_compat, dev_compat)) +return 0 ;Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
app/test/test_soc.c struct test_wrapper empty_pmd1 = { · line 183
Quoted 6 lines
app/test/test_soc.c +6
-0+ } + } + +return 1 ; +} +A redundant empty line here...
Yes, I will remove this.
Quoted 17 lines
Quoted 12 lines
Quoted 11 lines
lib/librte_eal/common/eal_common_soc.c struct soc_driver_list soc_driver_list = · line 79
Quoted 8 lines
lib/librte_eal/common/eal_common_soc.c +7
-0+ +static int +rte_eal_soc_probe_one_driver (struct rte_soc_driver *drv, +struct rte_soc_device *dev) +{ +int ret =1 ; +I think, the
RTE_VERIFY(dev->match_fn)might be good here. It avoids any doubts about the validity of the pointer.Quoted 4 lines
That has already been done in
rte_eal_soc_registerwhich is called when PMDs are registering themselves throughDRIVER_REGISTER_SOC. That would prevent any PMD leaking through to this stage without a proper match_fn/scan_fn.Quoted 9 lines
Well, yes. It seems to be redundant. However, it would emphesize the fact that this function expects that
match_fnis set.In the
rte_eal_soc_register, theRTE_VERIFYsays "The API requires those".But when I review I do not always see all the context. It is not safe for me to assume that there was probably some
RTE_VERIFYin the path... It is not a fast path so it does not hurt the performance in anyway.
Quoted 5 lines
You mean
RTE_VERIFYshould be duplicated so that code readability increases?
I am not really convinced on that.
My opinion: rte_eal_soc_*probe* series shouldn't actually worry about whether a valid PMD has been plugged in or. It should simply assume that having reached here, all is well on the PMDs definition side.On the contrary, placing a
RTE_VERIFYhere would only state the reader that it is possible to reach this code path without a valid match function.
Yes, it would state that the match function must always be valid here. That's the point.
Quoted 27 lines
Quoted 27 lines
Quoted 11 lines
Quoted 10 lines
lib/librte_eal/common/eal_common_soc.c struct soc_driver_list soc_driver_list = · line 83
Quoted 7 lines
lib/librte_eal/common/eal_common_soc.c +4
-0+ ret = drv->match_fn (drv, dev); +if (ret) { +RTE_LOG (DEBUG ,EAL , +" match function failed, skipping\n" );Is this a failure? I think it is not. Failure would be if the match function cannot execute correctly. This is more like "no-match".
Quoted 5 lines
The log message is misleading. This is _not_ a failure but simply a 'no-match'. I will update this.
Quoted 2 lines
When debugging, I'd like to see more a message like "driver <name> does
not match".
Quoted 9 lines
Problem would be about '<name>' of a driver. There is already another discussion about SoC capability/platform bus definitions - probably I will wait for that so as to define what a '<name>' for a driver and device is.
In this case, the key reason for not adding such a message was because it was assumed PMDs are black boxes with EAL not even assuming what '<name>' means. Anyways, it is better to discuss these things in that other email.
Quoted 6 lines
Quoted 1 line
I am not sure which thread do you mean... Can you point me there, please?
Sorry, somehow I forgot to add that:
http://dpdk.org/ml/archives/dev/2016-September/046933.htmlOne of the discussion point in above thread is whether platform bus is a good assumption for a SoC driver or not. Based on that '<name>' (or any other identifier, like 'compatible'), the log can be printed as you suggested above.
Quite frankly, I don't know. The platform bus seemed the obvious starting point to me when I started working on this topic. There was no DPAA2 (as far as I know), nothing more suitable. I write custom kernel drivers as platform devices.
However, if you look into PCI infrastructure you can see that the UIO, VFIO and custom approaches are available. And there is no PMD-specific scan function. I'd rather go the way it is already done to not diverge a lot from the base code. Otherwise, we can easily come to a point like "drop DPDK and write again" :).
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
[...]
Quoted 39 lines
Quoted 39 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +4
-0+if (drv && drv->scan_fn) { + drv->scan_fn (); +/* Ignore all errors from this */ + }Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
app/test/test_soc.c +2
-0+ } +return 0 ; }(quoted diff) +0
-0b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
index b9d1932..adcfe7d 100644
lib/librte_eal/linuxapp/eal/rte_eal_version.map +4
-0@@ -179,5 +179,9 @@ DPDK_16.11 { rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_soc_dump; + rte_eal_soc_match; + rte_eal_soc_detach; + rte_eal_soc_probe; + rte_eal_soc_probe_one;Quoted 5 lines
lib/librte_eal/linuxapp/eal/rte_eal_version.map DPDK_16.11 { · line 187
Quoted 1 line
lib/librte_eal/linuxapp/eal/rte_eal_version.map +0
-0} DPDK_16.07;Regards
JanI hope I have covered all your comments. That was an exhaustive review. Thanks a lot for your time.
Lets work to resolve the architectural issues revolving around SoC scan/match.
Quoted 6 lines
Quoted 1 line
;)
Phew!
I am already loosing track of things you have suggested.
What if we can chat on IRC and resolve the issue surrounding the 'default match/scan', 'platform or not platform dependent SoC' etc? I think it would save a lot of ping-pong effort. (For today (20/Sep), I might not be available, but I am OK any other time).
Sure... write me when you are available. I maybe temporarily away.
Quoted 18 lines
Quoted 8 lines
Quoted 5 lines
-
ShreyanshQuoted 5 lines
--
Jan Viktorin E-mail: [email protected]
System Architect Web: www.RehiveTech.com
RehiveTech
Brno, Czech RepublicThanks a lot.
-
Shreyansh
Signature · 4 lines
Jan Viktorin E-mail: [email protected] System Architect Web: www.RehiveTech.com RehiveTech Brno, Czech Republic
PATCH v3 7/15 eal/soc: extend and utilize devargs
In reply to Shreyansh JainIt is assumed that SoC Devices provided on command line are prefixed with "soc:". This patch adds parse and attach support for such devices.
--- lib/librte_eal/common/eal_common_dev.c | 27 ++++++++++---- lib/librte_eal/common/eal_common_devargs.c | 17 +++++++++ lib/librte_eal/common/eal_common_soc.c | 55 ++++++++++++++++++++++++++--- lib/librte_eal/common/include/rte_devargs.h | 8 +++++ lib/librte_eal/common/include/rte_soc.h | 24 +++++++++++++ 5 files changed, 119 insertions(+), 12 deletions(-)
lib/librte_eal/common/eal_common_dev.c +20 -7
@@ -106,17 +106,23 @@ rte_eal_dev_init(void)int rte_eal_dev_attach (const char *name,const char *devargs) { -struct rte_pci_addr addr; +struct rte_soc_addr soc_addr; +struct rte_pci_addr pci_addr;if (name ==NULL || devargs ==NULL ) {RTE_LOG (ERR ,EAL ,"Invalid device or arguments provided\n" );return -EINVAL ; } -if (eal_parse_pci_DomBDF (name, &addr) ==0 ) { -if (rte_eal_pci_probe_one (&addr) <0 ) +memset (&soc_addr,0 ,sizeof (soc_addr)); +if (rte_eal_parse_soc_spec (name, &soc_addr) ==0 ) { +if (rte_eal_soc_probe_one (&soc_addr) <0 ) { +free (soc_addr.name); + goto err; + } + }else if (eal_parse_pci_DomBDF (name, &pci_addr) ==0 ) { +if (rte_eal_pci_probe_one (&pci_addr) <0 ) goto err; - }else {if (rte_eal_vdev_init (name, devargs)) goto err;
@@ -131,15 +137,22 @@ err:int rte_eal_dev_detach (const char *name) { -struct rte_pci_addr addr; +struct rte_soc_addr soc_addr; +struct rte_pci_addr pci_addr;if (name ==NULL ) {RTE_LOG (ERR ,EAL ,"Invalid device provided.\n" );return -EINVAL ; } -if (eal_parse_pci_DomBDF (name, &addr) ==0 ) { -if (rte_eal_pci_detach (&addr) <0 ) +memset (&soc_addr,0 ,sizeof (soc_addr)); +if (rte_eal_parse_soc_spec (name, &soc_addr) ==0 ) { +if (rte_eal_soc_detach (&soc_addr) <0 ) { +free (soc_addr.name); + goto err; + } + }else if (eal_parse_pci_DomBDF (name, &pci_addr) ==0 ) { +if (rte_eal_pci_detach (&pci_addr) <0 ) goto err; }else {if (rte_eal_vdev_uninit (name))
lib/librte_eal/common/eal_common_devargs.c +17 -0
@@ -41,6 +41,7 @@#include <string.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_devargs.h> #include "eal_private.h"
@@ -105,6 +106,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) goto fail;break ; + +case RTE_DEVTYPE_WHITELISTED_SOC : +case RTE_DEVTYPE_BLACKLISTED_SOC : +/* try to parse soc device with prefix "soc:" */ +if (rte_eal_parse_soc_spec (buf, &devargs->soc.addr) !=0 ) + goto fail; +break ; +case RTE_DEVTYPE_VIRTUAL :/* save driver name */ ret = snprintf(devargs->virt.drv_name,
@@ -166,6 +175,14 @@ rte_eal_devargs_dump(FILE *f) devargs->pci.addr.devid, devargs->pci.addr.function, devargs->args); + else if (devargs->type == RTE_DEVTYPE_WHITELISTED_SOC) + fprintf(f, " SoC whitelist %s %s\n", + devargs->soc.addr.name, + devargs->soc.addr.fdt_path); + else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_SOC) + fprintf(f, " SoC blacklist %s %s\n", + devargs->soc.addr.name, + devargs->soc.addr.fdt_path); else if (devargs->type == RTE_DEVTYPE_VIRTUAL) fprintf(f, " VIRTUAL %s %s\n", devargs->virt.drv_name,
lib/librte_eal/common/eal_common_soc.c +50 -5
89 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +8 -0
@@ -51,6 +51,7 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> #include <rte_pci.h> +#include <rte_soc.h> /** * Type of generic device
@@ -58,6 +59,8 @@ extern "C" {enum rte_devtype {RTE_DEVTYPE_WHITELISTED_PCI ,RTE_DEVTYPE_BLACKLISTED_PCI , +RTE_DEVTYPE_WHITELISTED_SOC , +RTE_DEVTYPE_BLACKLISTED_SOC ,RTE_DEVTYPE_VIRTUAL , };
@@ -82,6 +85,11 @@ struct rte_devargs {/** PCI location. */ struct rte_pci_addr addr; } pci; +/** Used if type is RTE_DEVTYPE_*_SOC. */ +struct { +/** SoC location. */ +struct rte_soc_addr addr; + } soc;/** Used if type is RTE_DEVTYPE_VIRTUAL. */ struct {/** Driver name. */
lib/librte_eal/common/include/rte_soc.h +24 -0
@@ -158,6 +158,30 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, }/** +* Parse a specification of a soc device. The specification must differentiate +* a SoC device specification from the PCI bus and virtual devices. We assume +* a SoC specification starts with "soc:". The function allocates the name +* entry of the given addr. +* +* @return +* - 0 on success +* - 1 when not a SoC spec +* - -1 on failure +*/ +static inline int +rte_eal_parse_soc_spec (const char *spec,struct rte_soc_addr *addr) +{ +if (strstr (spec,"soc:" ) == spec) { + addr->name =strdup (spec +4 ); +if (addr->name ==NULL ) +return -1 ; +return 0 ; + } + +return 1 ; +} + +/** * Default function for matching the Soc driver with device. Each driver can * either use this function or define their own soc matching function. * This function relies on the compatible string extracted from sysfs. But,
Signature · 1 line
2.7.4
PATCH v3 8/15 eal/soc: add drv_flags
In reply to Shreyansh JainThe flags are copied from the PCI ones. They should be refactorized into a general set of flags in the future.
--- lib/librte_eal/common/include/rte_soc.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/librte_eal/common/include/rte_soc.h +10 -0
@@ -117,8 +117,18 @@ struct rte_soc_driver {soc_scan_t *scan_fn;/**< Callback for scanning SoC bus*/ soc_match_t *match_fn;/**< Callback to match dev<->drv */ const struct rte_soc_id *id_table;/**< ID table, NULL terminated */ +uint32_t drv_flags;/**< Control handling of device */ }; +/** Device needs to map its resources by EAL */ +#define RTE_SOC_DRV_NEED_MAPPING 0x0001 +/** Device needs to be unbound even if no module is provieded */ +#define RTE_SOC_DRV_FORCE_UNBIND 0x0004 +/** Device driver supports link state interrupt */ +#define RTE_SOC_DRV_INTR_LSC 0x0008 +/** Device driver supports detaching capability */ +#define RTE_SOC_DRV_DETACHABLE 0x0010 +/** * Utility function to write a SoC device name, this device name can later be * used to retrieve the corresponding rte_soc_addr using above functions.
Signature · 1 line
2.7.4
PATCH v3 9/15 eal/soc: add intr_handle
In reply to Shreyansh Jain--- lib/librte_eal/common/include/rte_soc.h | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_eal/common/include/rte_soc.h +2 -0
@@ -53,6 +53,7 @@ extern "C" {#include <rte_dev.h> #include <rte_eal.h> #include <rte_debug.h> +#include <rte_interrupts.h> extern struct soc_driver_list soc_driver_list;/**< Global list of SoC Drivers */
@@ -81,6 +82,7 @@ struct rte_soc_device {struct rte_device device;/**< Inherit code device */ struct rte_soc_addr addr;/**< SoC device Location */ struct rte_soc_id *id;/**< SoC device ID list */ +struct rte_intr_handle intr_handle;/**< Interrupt handle */ struct rte_soc_driver *driver;/**< Associated driver */ };
Signature · 1 line
2.7.4
PATCH v3 10/15 ether: utilize container_of for pci_drv
In reply to Shreyansh JainIt is not necessary to place the rte_pci_driver at the beginning of the rte_eth_dev struct anymore as we use the container_of macro to get the parent pointer.
--- lib/librte_ether/rte_ethdev.c | 4 ++-- lib/librte_ether/rte_ethdev.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/librte_ether/rte_ethdev.c +2 -2
@@ -242,7 +242,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,int diag; - eth_drv = (struct eth_driver *)pci_drv; + eth_drv = container_of(pci_drv, struct eth_driver, pci_drv);rte_eal_pci_device_name (&pci_dev->addr, ethdev_name,sizeof (ethdev_name));
@@ -303,7 +303,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)if (eth_dev ==NULL )return -ENODEV ; - eth_drv = (const struct eth_driver *)pci_dev->driver; + eth_drv = container_of(pci_dev->driver, struct eth_driver, pci_drv);/* Invoke PMD device uninit function */ if (*eth_drv->eth_dev_uninit) {
lib/librte_ether/rte_ethdev.h +1 -1
@@ -1842,7 +1842,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev);* Each Ethernet driver acts as a PCI driver and is represented by a generic * *eth_driver* structure that holds: * -* - An *rte_pci_driver* structure (which must be the first field). +* - An *rte_pci_driver* structure. * * - The *eth_dev_init* function invoked for each matching PCI device. *
Signature · 1 line
2.7.4
PATCH v3 11/15 ether: verify we copy info from a PCI device
In reply to Shreyansh JainNow that different types of ethdev exist, check for presence of PCI dev while copying out the info.
Similar would be done for SoC.
--- lib/librte_ether/rte_ethdev.c | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_ether/rte_ethdev.c +2 -0
@@ -3200,6 +3200,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dereturn ; } +RTE_VERIFY (eth_dev->pci_dev !=NULL ); + eth_dev->data->dev_flags =0 ;if (pci_dev->driver->drv_flags &RTE_PCI_DRV_INTR_LSC ) eth_dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC ;
Signature · 1 line
2.7.4
PATCH v3 12/15 ether: extract function eth_dev_get_intr_handle
In reply to Shreyansh JainWe abstract access to the intr_handle here as we want to get it either from the pci_dev or soc_dev.
--- lib/librte_ether/rte_ethdev.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +13 -2
@@ -2526,6 +2526,17 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,rte_spinlock_unlock (&rte_eth_dev_cb_lock); } +static inline +struct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) +{ +if (dev->pci_dev) { +return &dev->pci_dev->intr_handle; + } + +RTE_VERIFY (0 ); +return NULL ; +} +int rte_eth_dev_rx_intr_ctl (uint8_t port_id,int epfd,int op,void *data) {
@@ -2538,7 +2549,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - intr_handle = &dev->pci_dev->intr_handle; + intr_handle =eth_dev_get_intr_handle (dev);if (!intr_handle->intr_vec) {RTE_PMD_DEBUG_TRACE ("RX Intr vector unset\n" );return -EPERM ;
@@ -2598,7 +2609,7 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,return -EINVAL ; } - intr_handle = &dev->pci_dev->intr_handle; + intr_handle =eth_dev_get_intr_handle (dev);if (!intr_handle->intr_vec) {RTE_PMD_DEBUG_TRACE ("RX Intr vector unset\n" );return -EPERM ;
Signature · 1 line
2.7.4
Re: [PATCH v3 12/15] ether: extract function eth_dev_get_intr_handle
Quoted 16 lines · Shreyansh Jain
We abstract access to the
intr_handlehere as we want to get it either from thepci_devorsoc_dev.Signed-off-by Jan Viktorin <[email protected]>Signed-off-by Shreyansh Jain <[email protected]>Signed-off-by Hemant Agrawal <[email protected]>--- lib/librte_ether/rte_ethdev.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)lib/librte_ether/rte_ethdev.c +0
-0@@ -2526,6 +2526,17 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,rte_spinlock_unlock (&rte_eth_dev_cb_lock);
lib/librte_ether/rte_ethdev.c _rte_eth_dev_callback_process(struct rte_eth_dev *dev, · line 2536
Quoted 10 lines
lib/librte_ether/rte_ethdev.c +8
-0} +static inline +struct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) +{ +if (dev->pci_dev) { +return &dev->pci_dev->intr_handle; + } + +RTE_VERIFY (0 );
Rather than RTE_VERIFY(0), might I suggest using rte_panic with a more relevant error message?
Quoted 24 lines
lib/librte_ether/rte_ethdev.c +5
-2+return NULL ; +} +int rte_eth_dev_rx_intr_ctl (uint8_t port_id,int epfd,int op,void *data) {@@ -2538,7 +2549,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - intr_handle = &dev->pci_dev->intr_handle; + intr_handle =eth_dev_get_intr_handle (dev);if (!intr_handle->intr_vec) {RTE_PMD_DEBUG_TRACE ("RX Intr vector unset\n" );return -EPERM ;@@ -2598,7 +2609,7 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,return -EINVAL ; } - intr_handle = &dev->pci_dev->intr_handle; + intr_handle =eth_dev_get_intr_handle (dev);if (!intr_handle->intr_vec) {RTE_PMD_DEBUG_TRACE ("RX Intr vector unset\n" );return -EPERM ;
Re: [PATCH v3 12/15] ether: extract function eth_dev_get_intr_handle
2016-09-15 14:02, Hunt, David:
Quoted 12 lines · Shreyansh Jain
lib/librte_ether/rte_ethdev.c _rte_eth_dev_callback_process(struct rte_eth_dev *dev, · line 2536
Quoted 8 lines
lib/librte_ether/rte_ethdev.c +8
-0+static inline +struct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) +{ +if (dev->pci_dev) { +return &dev->pci_dev->intr_handle; + } + +RTE_VERIFY (0 );Rather than
RTE_VERIFY(0), might I suggest usingrte_panicwith a more relevant error message?
RTE_ASSERT is preferred.
We must stop adding some rte_panic calls except for debug.
Re: [PATCH v3 12/15] ether: extract function eth_dev_get_intr_handle
Quoted 14 lines · Thomas Monjalon
2016-09-15 14:02, Hunt, David:
Quoted 12 lines · Shreyansh Jain
lib/librte_ether/rte_ethdev.c _rte_eth_dev_callback_process(struct rte_eth_dev *dev, · line 2536
Quoted 8 lines
lib/librte_ether/rte_ethdev.c +8
-0+static inline +struct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) +{ +if (dev->pci_dev) { +return &dev->pci_dev->intr_handle; + } + +RTE_VERIFY (0 );Rather than
RTE_VERIFY(0), might I suggest usingrte_panicwith a more relevant error message?
Quoted 2 lines
RTE_ASSERTis preferred.
We must stop adding somerte_paniccalls except for debug.
+1
It wouldn't hurt to make that a hard rule.
- Panu -
PATCH v3 13/15 ether: extract function eth_dev_get_driver_name
In reply to Shreyansh Jain--- lib/librte_ether/rte_ethdev.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +14 -1
@@ -2568,6 +2568,17 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)return 0 ; } +static inline +const char *eth_dev_get_driver_name (const struct rte_eth_dev *dev) +{ +if (dev->pci_dev) { +return dev->driver->pci_drv.driver.name; + } + +RTE_VERIFY (0 ); +return NULL ; +} +const struct rte_memzone * rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, size_t size, unsigned align,
@@ -2575,9 +2586,11 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, {char z_name[RTE_MEMZONE_NAMESIZE ];const struct rte_memzone *mz; +const char *drv_name; + drv_name =eth_dev_get_driver_name (dev);snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->driver->pci_drv.driver.name, ring_name, + drv_name, ring_name, dev->data->port_id, queue_id); mz =rte_memzone_lookup (z_name);
Signature · 1 line
2.7.4
Re: [PATCH v3 13/15] ether: extract function eth_dev_get_driver_name
Quoted 13 lines · Shreyansh Jain
Signed-off-by Jan Viktorin <[email protected]>Signed-off-by Shreyansh Jain <[email protected]>Signed-off-by Hemant Agrawal <[email protected]>--- lib/librte_ether/rte_ethdev.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)lib/librte_ether/rte_ethdev.c +0
-0@@ -2568,6 +2568,17 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)return 0 ;
lib/librte_ether/rte_ethdev.c rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data) · line 2578
Quoted 10 lines
lib/librte_ether/rte_ethdev.c +8
-0} +static inline +const char *eth_dev_get_driver_name (const struct rte_eth_dev *dev) +{ +if (dev->pci_dev) { +return dev->driver->pci_drv.driver.name; + } + +RTE_VERIFY (0 );
Same comment as last patch, maybe add an rte_panic with more descriptive error message.
Quoted 19 lines
lib/librte_ether/rte_ethdev.c +6
-1+return NULL ; +} +const struct rte_memzone * rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, size_t size, unsigned align,@@ -2575,9 +2586,11 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, {char z_name[RTE_MEMZONE_NAMESIZE ];const struct rte_memzone *mz; +const char *drv_name; + drv_name =eth_dev_get_driver_name (dev);snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->driver->pci_drv.driver.name, ring_name, + drv_name, ring_name, dev->data->port_id, queue_id); mz =rte_memzone_lookup (z_name);
PATCH v3 14/15 ether: Support rte_soc_driver/device for etherdev
In reply to Shreyansh Jain- eth_driver/rte_eth_dev embeds rte_soc_driver/device for relating SoC PMDs to ethernet devices.
- Add probe and remove functions linked to eth_dev_init/uninit
--- lib/librte_ether/rte_ethdev.c | 129 ++++++++++++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 31 ++++++++++ 2 files changed, 160 insertions(+)
lib/librte_ether/rte_ethdev.c +129 -0
@@ -326,6 +326,101 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev) }int +rte_eth_dev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev) +{ +struct eth_driver *eth_drv; +struct rte_eth_dev *eth_dev; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; + +int diag; + + eth_drv = container_of(soc_drv, struct eth_driver, soc_drv); + +rte_eal_soc_device_name (&soc_dev->addr, ethdev_name, +sizeof (ethdev_name)); + + eth_dev =rte_eth_dev_allocate (ethdev_name); +if (eth_dev ==NULL ) +return -ENOMEM ; + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { + eth_dev->data->dev_private =rte_zmalloc ( +"ethdev private structure" , + eth_drv->dev_private_size, +RTE_CACHE_LINE_SIZE ); +if (eth_dev->data->dev_private ==NULL ) +rte_panic ("Cannot allocate memzone for private port " +"data\n" ); + } + eth_dev->soc_dev = soc_dev; + eth_dev->driver = eth_drv; + eth_dev->data->rx_mbuf_alloc_failed =0 ; + +/* init user callbacks */ +TAILQ_INIT (&(eth_dev->link_intr_cbs)); + +/* +* Set the default MTU. +*/ + eth_dev->data->mtu =ETHER_MTU ; + +/* Invoke PMD device initialization function */ + diag = (*eth_drv->eth_dev_init)(eth_dev); +if (diag ==0 ) +return 0 ; + +RTE_PMD_DEBUG_TRACE ("driver %s: eth_dev_init(%s) failed\n" , + soc_drv->driver.name, + soc_dev->addr.name); +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (eth_dev->data->dev_private); +rte_eth_dev_release_port (eth_dev); +return diag; +} + +int +rte_eth_dev_soc_remove (struct rte_soc_device *soc_dev) +{ +const struct eth_driver *eth_drv; +struct rte_eth_dev *eth_dev; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +int ret; + +if (soc_dev ==NULL ) +return -EINVAL ; + +rte_eal_soc_device_name (&soc_dev->addr, ethdev_name, +sizeof (ethdev_name)); + + eth_dev =rte_eth_dev_allocated (ethdev_name); +if (eth_dev ==NULL ) +return -ENODEV ; + + eth_drv = container_of(soc_dev->driver, struct eth_driver, soc_drv); + +/* Invoke PMD device uninit function */ +if (*eth_drv->eth_dev_uninit) { + ret = (*eth_drv->eth_dev_uninit)(eth_dev); +if (ret) +return ret; + } + +/* free ether device */ +rte_eth_dev_release_port (eth_dev); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (eth_dev->data->dev_private); + + eth_dev->soc_dev =NULL ; + eth_dev->driver =NULL ; + eth_dev->data =NULL ; + +return 0 ; +} + + +int rte_eth_dev_is_valid_port (uint8_t port_id) { if (port_id >= RTE_MAX_ETHPORTS ||
@@ -1555,6 +1650,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)RTE_FUNC_PTR_OR_RET (*dev->dev_ops->dev_infos_get); (*dev->dev_ops->dev_infos_get)(dev, dev_info); dev_info->pci_dev = dev->pci_dev; + dev_info->soc_dev = dev->soc_dev; dev_info->driver_name = dev->data->drv_name; dev_info->nb_rx_queues = dev->data->nb_rx_queues; dev_info->nb_tx_queues = dev->data->nb_tx_queues;
@@ -2530,8 +2626,13 @@ static inlinestruct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) {if (dev->pci_dev) { +RTE_VERIFY (dev->soc_dev ==NULL );return &dev->pci_dev->intr_handle; } +if (dev->soc_dev) { +RTE_VERIFY (dev->pci_dev ==NULL ); +return &dev->soc_dev->intr_handle; + }RTE_VERIFY (0 );return NULL ;
@@ -2572,9 +2673,15 @@ static inlineconst char *eth_dev_get_driver_name (const struct rte_eth_dev *dev) {if (dev->pci_dev) { +RTE_VERIFY (dev->soc_dev ==NULL );return dev->driver->pci_drv.driver.name; } +if (dev->soc_dev) { +RTE_VERIFY (dev->pci_dev ==NULL ); +return dev->driver->soc_drv.driver.name; + } +RTE_VERIFY (0 );return NULL ; }
@@ -3237,6 +3344,28 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de eth_dev->data->drv_name = pci_dev->driver->driver.name; } +void +rte_eth_copy_soc_info (struct rte_eth_dev *eth_dev, +struct rte_soc_device *soc_dev) +{ +if ((eth_dev ==NULL ) || (soc_dev ==NULL )) { +RTE_PMD_DEBUG_TRACE ("NULL pointer eth_dev=%p soc_dev=%p\n" , + eth_dev, soc_dev); +return ; + } + +RTE_VERIFY (eth_dev->soc_dev !=NULL ); + + eth_dev->data->dev_flags =0 ; +if (soc_dev->driver->drv_flags &RTE_SOC_DRV_INTR_LSC ) + eth_dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC ; +if (soc_dev->driver->drv_flags &RTE_SOC_DRV_DETACHABLE ) + eth_dev->data->dev_flags |=RTE_ETH_DEV_DETACHABLE ; + + eth_dev->data->numa_node = soc_dev->device.numa_node; + eth_dev->data->drv_name = soc_dev->driver->driver.name; +} +int rte_eth_dev_l2_tunnel_eth_type_conf (uint8_t port_id,struct rte_eth_l2_tunnel_conf *l2_tunnel)
lib/librte_ether/rte_ethdev.h +31 -0
@@ -180,6 +180,7 @@ extern "C" {#include <rte_log.h> #include <rte_interrupts.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_dev.h> #include <rte_devargs.h> #include "rte_ether.h"
@@ -870,6 +871,7 @@ struct rte_eth_conf {*/ struct rte_eth_dev_info {struct rte_pci_device *pci_dev;/**< Device PCI information. */ +struct rte_soc_device *soc_dev;/**< Device SoC information. */ const char *driver_name;/**< Device Driver name. */ unsigned int if_index;/**< Index to bound host interface, or 0 if none. Use if_indextoname() to translate into an interface name. */
@@ -1619,6 +1621,7 @@ struct rte_eth_dev {const struct eth_driver *driver;/**< Driver for this device */ const struct eth_dev_ops *dev_ops;/**< Functions exported by PMD */ struct rte_pci_device *pci_dev;/**< PCI info. supplied by probing */ +struct rte_soc_device *soc_dev;/**< SoC info. supplied by probing */ /** User application callbacks for NIC interrupts */ struct rte_eth_dev_cb_list link_intr_cbs;/**
@@ -1852,6 +1855,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev);*/ struct eth_driver {struct rte_pci_driver pci_drv;/**< The PMD is also a PCI driver. */ +struct rte_soc_driver soc_drv;/**< The PMD is also a SoC driver. */ eth_dev_init_t eth_dev_init;/**< Device init function. */ eth_dev_uninit_t eth_dev_uninit;/**< Device uninit function. */ unsigned int dev_private_size;/**< Size of device private data. */
@@ -4244,6 +4248,20 @@ void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev);/** +* Copy SoC device info to the Ethernet device data. +* +* @param eth_dev +* The *eth_dev* pointer is the address of the *rte_eth_dev* structure. +* @param soc_dev +* The *soc_dev* pointer is the address of the *rte_soc_device* structure. +* +* @return +* - 0 on success, negative on error +*/ +void rte_eth_copy_soc_info (struct rte_eth_dev *eth_dev, +struct rte_soc_device *soc_dev); + +/** * Create memzone for HW rings. * malloc can't be used as the physical address is needed. * If the memzone is already created, then this function returns a ptr
@@ -4356,6 +4374,19 @@ int rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,*/ int rte_eth_dev_pci_remove (struct rte_pci_device *pci_dev); +/** +* Wrapper for use by SoC drivers as a .devinit function to attach to a ethdev +* interface. +*/ +int rte_eth_dev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev); + +/** +* Wrapper for use by SoC drivers as a .devuninit function to detach a ethdev +* interface. +*/ +int rte_eth_dev_soc_remove (struct rte_soc_device *soc_dev); + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH v3 15/15 eal/crypto: Support rte_soc_driver/device for cryptodev
In reply to Shreyansh Jain- rte_cryptodev_driver/rte_cryptodev_dev embeds rte_soc_driver/device for linking SoC PMDs to crypto devices.
- Add probe and remove functions linked
--- lib/librte_cryptodev/rte_cryptodev.c | 122 ++++++++++++++++++++++++- lib/librte_cryptodev/rte_cryptodev.h | 3 + lib/librte_cryptodev/rte_cryptodev_pmd.h | 18 +++- lib/librte_cryptodev/rte_cryptodev_version.map | 3 + 4 files changed, 141 insertions(+), 5 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +118 -4
@@ -423,7 +423,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,int retval; - cryptodrv = (struct rte_cryptodev_driver *)pci_drv; + cryptodrv = container_of(pci_drv, struct rte_cryptodev_driver, + pci_drv);if (cryptodrv ==NULL )return -ENODEV ;
@@ -490,7 +491,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)if (cryptodev ==NULL )return -ENODEV ; - cryptodrv = (const struct rte_cryptodev_driver *)pci_dev->driver; + cryptodrv = container_of(pci_dev->driver, struct rte_cryptodev_driver, + pci_drv);if (cryptodrv ==NULL )return -ENODEV ;
@@ -514,6 +516,111 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)return 0 ; } + +int +rte_cryptodev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev) +{ +struct rte_cryptodev_driver *cryptodrv; +struct rte_cryptodev *cryptodev; + +char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN ]; + +int retval; + + cryptodrv = container_of(soc_drv, struct rte_cryptodev_driver, + soc_drv); + +rte_eal_soc_device_name (&soc_dev->addr, cryptodev_name, +sizeof (cryptodev_name)); + + cryptodev =rte_cryptodev_pmd_allocate (cryptodev_name, +rte_socket_id ()); +if (cryptodev ==NULL ) +return -ENOMEM ; + + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { + cryptodev->data->dev_private = +rte_zmalloc_socket ( +"cryptodev private structure" , + cryptodrv->dev_private_size, +RTE_CACHE_LINE_SIZE , +rte_socket_id ()); + +if (cryptodev->data->dev_private ==NULL ) +rte_panic ("Cannot allocate memzone for private " +"device data" ); + } + + cryptodev->soc_dev = soc_dev; + cryptodev->driver = cryptodrv; + +/* init user callbacks */ +TAILQ_INIT (&(cryptodev->link_intr_cbs)); + +/* Invoke PMD device initialization function */ + retval = (*cryptodrv->cryptodev_init)(cryptodrv, cryptodev); +if (retval ==0 ) +return 0 ; + +CDEV_LOG_ERR ("driver %s: cryptodev_init(%s) failed\n" , + soc_drv->driver.name, + soc_dev->addr.name); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (cryptodev->data->dev_private); + + cryptodev->attached =RTE_CRYPTODEV_DETACHED ; + cryptodev_globals.nb_devs--; + +return -ENXIO ; +} + +int +rte_cryptodev_soc_remove (struct rte_soc_device *soc_dev) +{ +const struct rte_cryptodev_driver *cryptodrv; +struct rte_cryptodev *cryptodev; +char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN ]; +int ret; + +if (soc_dev ==NULL ) +return -EINVAL ; + +rte_eal_soc_device_name (&soc_dev->addr, cryptodev_name, +sizeof (cryptodev_name)); + + cryptodev =rte_cryptodev_pmd_get_named_dev (cryptodev_name); +if (cryptodev ==NULL ) +return -ENODEV ; + + cryptodrv =container_of (soc_dev->driver, + struct rte_cryptodev_driver, soc_drv); +if (cryptodrv ==NULL ) +return -ENODEV ; + +/* Invoke PMD device uninit function */ +if (*cryptodrv->cryptodev_uninit) { + ret = (*cryptodrv->cryptodev_uninit)(cryptodrv, cryptodev); +if (ret) +return ret; + } + +/* free crypto device */ +rte_cryptodev_pmd_release_device (cryptodev); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (cryptodev->data->dev_private); + + cryptodev->pci_dev =NULL ; + cryptodev->soc_dev =NULL ; + cryptodev->driver =NULL ; + cryptodev->data =NULL ; + +return 0 ; +} +uint16_t rte_cryptodev_queue_pair_count (uint8_t dev_id) {
@@ -869,8 +976,15 @@ rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info) (*dev->dev_ops->dev_infos_get)(dev, dev_info); dev_info->pci_dev = dev->pci_dev; -if (dev->driver) - dev_info->driver_name = dev->driver->pci_drv.driver.name; + dev_info->soc_dev = dev->soc_dev; +if (dev->driver) { +if (dev->soc_dev) + dev_info->driver_name + = dev->driver->soc_drv.driver.name; +else + dev_info->driver_name + = dev->driver->pci_drv.driver.name; + } }
lib/librte_cryptodev/rte_cryptodev.h +3 -0
@@ -231,6 +231,7 @@ struct rte_cryptodev_info {const char *driver_name;/**< Driver name. */ enum rte_cryptodev_type dev_type;/**< Device type */ struct rte_pci_device *pci_dev;/**< PCI information. */ +struct rte_soc_device *soc_dev;/**< SoC information. */ uint64_t feature_flags;/**< Feature flags */
@@ -610,6 +611,8 @@ struct rte_cryptodev {/**< Supported features */ struct rte_pci_device *pci_dev;/**< PCI info. supplied by probing */ +struct rte_soc_device *soc_dev; +/**< SoC info. supplied by probing/Scanning */ enum rte_cryptodev_type dev_type;/**< Crypto device type */
lib/librte_cryptodev/rte_cryptodev_pmd.h +17 -1
@@ -48,6 +48,7 @@ extern "C" {#include <rte_dev.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_malloc.h> #include <rte_mbuf.h> #include <rte_mempool.h>
@@ -129,7 +130,8 @@ typedef int (*cryptodev_uninit_t)(const struct rte_cryptodev_driver *drv,* - The size of the private data to allocate for each matching device. */ struct rte_cryptodev_driver { -struct rte_pci_driver pci_drv;/**< The PMD is also a PCI driver. */ +struct rte_pci_driver pci_drv;/**< The PMD is PCI type driver. */ +struct rte_soc_driver soc_drv;/**< The PMD is SoC type driver. */ unsigned dev_private_size;/**< Size of device private data. */ cryptodev_init_t cryptodev_init;/**< Device init function. */
@@ -517,6 +519,20 @@ int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,*/ int rte_cryptodev_pci_remove (struct rte_pci_device *pci_dev); +/** +* Wrapper for use by SoC drivers as a .devinit function to attach to a +* cryptodev interface. +*/ +int rte_cryptodev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev); + +/** +* Wrapper for use by SoC drivers as a .devuninit function to detach a +* cryptodev interface. +*/ +int rte_cryptodev_soc_remove (struct rte_soc_device *soc_dev); + + #ifdef __cplusplus }#endif
lib/librte_cryptodev/rte_cryptodev_version.map +3 -0
@@ -44,4 +44,7 @@ DPDK_16.11 { rte_cryptodev_pci_probe; rte_cryptodev_pci_remove; + rte_cryptodev_soc_probe; + rte_cryptodev_soc_remove; + } DPDK_16.07;
Signature · 1 line
2.7.4
Re: [PATCH v3 00/15] Introduce SoC device/driver framework for EAL
In reply to Shreyansh JainShreyansh, Jan, Hemant,
Quoted 5 lines · Shreyansh Jain
Introduction:
=============This patch set is direct derivative of Jan's original series [1],[2].
Quoted 11 lines
- As this deviates substantially from original series, if need be I can post it as a separate patch rather than v2. Please suggest.
- Also, there are comments on original v1 ([4]) which are _not_ incorporated in this series as they refer to section no more in new version.
- This v3 version is based on the rte_driver/device patchset v9 [10]. That series introduced device structures (rte_driver/rte_device) generalizing devices into PCI, VDEV, XXX. For the purpose of this patchset, XXX=>SOC.
---snip---
FYI, I've reviewed this patch set, and it looks to me like there's
some very good work here. Each patch in the set builds nicely on the one before, and logically introduces the changes one by one.
I've no functional suggestions as the implementation looks clean,
but I've one or two tiny suggestions on headers and error messages. I'll add a reply to the relevant patches in the set.
Also, there's one or two issues thrown up by checkpatch, but I suspect they're false positives, as I'm using the 4.6 kernel version.
Regards,
Dave
Re: [PATCH v3 00/15] Introduce SoC device/driver framework for EAL
Hi David,
Quoted 27 lines
-----Original Message-----
From: Hunt, David [mailto:[email protected]]
Sent: Thursday, September 15, 2016 6:26 PM
To: Shreyansh Jain <[email protected]>; [email protected]
Cc: [email protected]; Hemant Agrawal <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 00/15] Introduce SoC device/driver framework for EALShreyansh, Jan, Hemant,
Quoted 5 lines · Shreyansh Jain
Introduction:
=============This patch set is direct derivative of Jan's original series [1],[2].
Quoted 11 lines
- As this deviates substantially from original series, if need be I can post it as a separate patch rather than v2. Please suggest.
- Also, there are comments on original v1 ([4]) which are _not_ incorporated in this series as they refer to section no more in new version.
- This v3 version is based on the rte_driver/device patchset v9 [10]. That series introduced device structures (rte_driver/rte_device) generalizing devices into PCI, VDEV, XXX. For the purpose of this patchset, XXX=>SOC.
Quoted 5 lines
---snip---
FYI, I've reviewed this patch set, and it looks to me like there's
some very good work here. Each patch in the set builds nicely on the one before, and logically introduces the changes one by one.
Great. Thank you so much for reviewing this series. It would really help us move it ahead and introduce other series which are based on it.
Quoted 4 lines
I've no functional suggestions as the implementation looks clean,
but I've one or two tiny suggestions on headers and error messages. I'll add a reply to the relevant patches in the set.
I will have a look at those and fix them soon (v4).
Quoted 3 lines
Also, there's one or two issues thrown up by checkpatch, but I suspect they're false positives, as I'm using the 4.6 kernel version.
Thanks for headup - I will see/fix those in v4, if any.
Quoted 4 lines
Regards,
Dave
-
Shreyansh
Re: [PATCH v3 00/15] Introduce SoC device/driver framework for EAL
In reply to Shreyansh JainQuoted 71 lines · Shreyansh Jain
Introduction:
=============This patch set is direct derivative of Jan's original series [1],[2].
- As this deviates substantially from original series, if need be I can post it as a separate patch rather than v2. Please suggest.
- Also, there are comments on original v1 ([4]) which are _not_ incorporated in this series as they refer to section no more in new version.
- This v3 version is based on the rte_driver/device patchset v9 [10]. That series introduced device structures (rte_driver/rte_device) generalizing devices into PCI, VDEV, XXX. For the purpose of this patchset, XXX=>SOC.Aim:
====As of now EAL is primarly focused on PCI initialization/probing.
rte_eal_init()|- rte_eal_pci_init(): Find PCI devices from sysfs |- ... |- rte_eal_memzone_init() |- ...`-
rte_eal_pci_probe(): Driver<=>Device initializationThis patchset introduces SoC framework which would enable SoC drivers and drivers to be plugged into EAL, very similar to how PCI
drivers/devicesare done today.This is a stripped down version of PCI framework which allows the SoC PMDs to implement their own routines for detecting devices and linking devices to drivers.
1) Changes to EAL
rte_eal_init()|- rte_eal_pci_init(): Find PCI devices from sysfs |- rte_eal_soc_init(): Calls PMDs->scan_fn |- ... |- rte_eal_memzone_init() |- ... |- rte_eal_pci_probe(): Driver<=>Device initialization, PMD->devinit()`-
rte_eal_soc_probe(): CallsPMDs->match_fnandPMDs->devinit();2) New device/driver structures:
-rte_soc_driver(inheritingrte_driver)
-rte_soc_device(inheritingrte_device)
-rte_eth_devandeth_driverembeddedrte_soc_deviceandrte_soc_driver, respectively.3) The SoC PMDs need to:
- definerte_soc_driverwith necessary scan and match callbacks
- Register themselves usingDRIVER_REGISTER_SOC()
- Implement respective bus scanning in the scan callbacks to add necessary devices to SoC device list
- Implement necessary eth_dev_init/uninint for ethernet instances4) Design considerations that are same as PCI:
- SoC initialization is being done throughrte_eal_init(), just after PCI initialization is done.
- As in case of PCI, probe is done afterrte_eal_pci_probe()to link the devices detected with the drivers registered.
- Device attach/detach functions are available and have been designed on the lines of PCI framework.
- PMDs register usingDRIVER_REGISTER_SOC, very similar toDRIVER_REGISTER_PCIfor PCI devices.
- Linked list of SoC driver and devices exists independent of the other driver/device list, but inheriting rte_driver/rte_driver, these are also part of a global list.
Quoted 6 lines
5) Design considerations that are different from PCI:
- Each driver implements its own scan and match function. PCI uses the BDF format to read the device from sysfs, but this _may_not_ be a case for a SoC ethernet device.
= This is an important change from initial proposal by Jan in [2]. Unlike his attempt to use/sys/bus/platform, this patch relies on the PMD to
It could be many redundant code if Each PMD driver has the scan function if its own.
I think Jan's implementation is common to many platform drivers.
Quoted 2 lines
detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have embedded
Can you give us more precise definition about SoC driver? Does it include the driver in ARM server?
Quoted 2 lines
devices/MACs which require initialization which cannot be covered through sysfs parsing.
I think it can be done in devinit, not in scan function. devinit can be different for each driver.
Quoted 4 lines
= PCI based PMDs rely on EAL's capability to detect devices. This proposal puts the onus on PMD to detect devices, add to
soc_device_listand wait for Probe. Matching, of device<=>driver is again PMD's callback.
Re: [PATCH v3 00/15] Introduce SoC device/driver framework for EAL
Quoted 15 lines · On Sun, 18 Sep 2016 13:58:50 +0800 Jianbo Liu <[email protected]> wrote:
Quoted 14 lines · Shreyansh Jain
Introduction:
=============This patch set is direct derivative of Jan's original series [1],[2].
- As this deviates substantially from original series, if need be I can post it as a separate patch rather than v2. Please suggest.
- Also, there are comments on original v1 ([4]) which are _not_ incorporated in this series as they refer to section no more in new version.
- This v3 version is based on the rte_driver/device patchset v9 [10]. That series introduced device structures (rte_driver/rte_device) generalizing devices into PCI, VDEV, XXX. For the purpose of this patchset, XXX=>SOC.
[...]
Quoted 11 lines
Quoted 7 lines
5) Design considerations that are different from PCI:
- Each driver implements its own scan and match function. PCI uses the BDF format to read the device from sysfs, but this _may_not_ be a case for a SoC ethernet device.
= This is an important change from initial proposal by Jan in [2]. Unlike his attempt to use/sys/bus/platform, this patch relies on the PMD toIt could be many redundant code if Each PMD driver has the scan function if its own.
I think Jan's implementation is common to many platform drivers.
I personally can find a use case for having a custom scan function. However, we should at least provide a default implementation. Probably, both the scan and match functions should be used to _override_ a default behaviour. So, only drivers that require to scan devices in a specific way would provide a custom function for this.
I agree, that this can sometimes lead to code duplication. Moreover, it opens door for a very non-standard, unsecure and wrong-by-design approaches. I'd like more to provide one or more scan implementations in EAL and do not put this responsibility on PMDs.
Quoted 3 lines
Quoted 3 lines
detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have embedded
Can you provide an example for "additional info for device detection"?
Quoted 3 lines
Can you give us more precise definition about SoC driver? Does it include the driver in ARM server?
I am sorry but I don't understand this question.
What you mean by a "driver in ARM server"? Do you mean a kernel driver?
There is no "SoC driver" in the text so what definition are asking for?
Quoted 3 lines
Quoted 3 lines
devices/MACs which require initialization which cannot be covered through sysfs parsing.
I think, the description itself is incorrect.
If a device's initialization cannot be satisfied vie sysfs, it means that you have to write a specific probe function. This is not related to scan in any way.
However, there may be a group of devices which are not managed by the standard platform_driver of the Linux Kernel (or other OS). In that case, the custom scan function would be helpful. I can imagine a device in a fully I/O coherent platform that only requires to access the /dev/mem only (for the register space). It is unsecure but it would work without any OS-driver. However, I consider it a corner case. It can be useful for testing sometimes but not very helpful for production.
We should however support mainly the standard devices which are always represented by the OS. Otherwise, such system would introduce security issues.
Quoted 3 lines
I think it can be done in devinit, not in scan function. devinit can be different for each driver.
+1
Quoted 5 lines
Quoted 5 lines
= PCI based PMDs rely on EAL's capability to detect devices. This proposal puts the onus on PMD to detect devices, add to
soc_device_listand wait for Probe. Matching, of device<=>driver is again PMD's callback.
Regards
Jan
Signature · 4 lines
Jan Viktorin E-mail: [email protected] System Architect Web: www.RehiveTech.com RehiveTech Brno, Czech Republic
Re: [PATCH v3 00/15] Introduce SoC device/driver framework for EAL
Quoted 33 lines · Jan Viktorin
Quoted 15 lines · On Sun, 18 Sep 2016 13:58:50 +0800 Jianbo Liu <[email protected]> wrote:
Quoted 14 lines · Shreyansh Jain
Introduction:
=============This patch set is direct derivative of Jan's original series [1],[2].
- As this deviates substantially from original series, if need be I can post it as a separate patch rather than v2. Please suggest.
- Also, there are comments on original v1 ([4]) which are _not_ incorporated in this series as they refer to section no more in new version.
- This v3 version is based on the rte_driver/device patchset v9 [10]. That series introduced device structures (rte_driver/rte_device) generalizing devices into PCI, VDEV, XXX. For the purpose of this patchset, XXX=>SOC.[...]
Quoted 11 lines
Quoted 7 lines
5) Design considerations that are different from PCI:
- Each driver implements its own scan and match function. PCI uses the BDF format to read the device from sysfs, but this _may_not_ be a case for a SoC ethernet device.
= This is an important change from initial proposal by Jan in [2]. Unlike his attempt to use/sys/bus/platform, this patch relies on the PMD toIt could be many redundant code if Each PMD driver has the scan function if its own.
I think Jan's implementation is common to many platform drivers.
Quoted 6 lines
I personally can find a use case for having a custom scan function. However, we should at least provide a default implementation. Probably, both the scan and match functions should be used to _override_ a default behaviour. So, only drivers that require to scan devices in a specific way would provide a custom function for this.
And for each platform/product....
Quoted 12 lines
I agree, that this can sometimes lead to code duplication. Moreover, it opens door for a very non-standard, unsecure and wrong-by-design approaches. I'd like more to provide one or more scan implementations in EAL and do not put this responsibility on PMDs.
Quoted 3 lines
Quoted 3 lines
detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have embedded
Can you provide an example for "additional info for device detection"?
Quoted 1 line
Quoted 9 lines
Quoted 2 lines
Can you give us more precise definition about SoC driver? Does it include the driver in ARM server?
I am sorry but I don't understand this question.
What you mean by a "driver in ARM server"? Do you mean a kernel driver?
There is no "SoC driver" in the text so what definition are asking for?
This patchset introduces rte_soc_driver, which is inheriting from rte_driver. I want to know what devices can use this SoC driver/device framework. Is it for the devices from ARM servers, or embedded systems of different vendors?
And this framework is too generalized, if we don't try to understand "soc" in rte_soc_driver, we can use it for PCI devices. :)
Thanks!
Jianbo
Re: [PATCH v3 00/15] Introduce SoC device/driver framework for EAL
Quoted 59 lines · On Sun, 18 Sep 2016 16:56:54 +0800 Jianbo Liu <[email protected]> wrote:
Quoted 33 lines · Jan Viktorin
Quoted 15 lines · On Sun, 18 Sep 2016 13:58:50 +0800 Jianbo Liu <[email protected]> wrote:
Quoted 14 lines · Shreyansh Jain
Introduction:
=============This patch set is direct derivative of Jan's original series [1],[2].
- As this deviates substantially from original series, if need be I can post it as a separate patch rather than v2. Please suggest.
- Also, there are comments on original v1 ([4]) which are _not_ incorporated in this series as they refer to section no more in new version.
- This v3 version is based on the rte_driver/device patchset v9 [10]. That series introduced device structures (rte_driver/rte_device) generalizing devices into PCI, VDEV, XXX. For the purpose of this patchset, XXX=>SOC.[...]
Quoted 11 lines
Quoted 7 lines
5) Design considerations that are different from PCI:
- Each driver implements its own scan and match function. PCI uses the BDF format to read the device from sysfs, but this _may_not_ be a case for a SoC ethernet device.
= This is an important change from initial proposal by Jan in [2]. Unlike his attempt to use/sys/bus/platform, this patch relies on the PMD toIt could be many redundant code if Each PMD driver has the scan function if its own.
I think Jan's implementation is common to many platform drivers.Quoted 6 lines
I personally can find a use case for having a custom scan function. However, we should at least provide a default implementation. Probably, both the scan and match functions should be used to _override_ a default behaviour. So, only drivers that require to scan devices in a specific way would provide a custom function for this.
And for each platform/product....
Quoted 17 lines
I agree, that this can sometimes lead to code duplication. Moreover, it opens door for a very non-standard, unsecure and wrong-by-design approaches. I'd like more to provide one or more scan implementations in EAL and do not put this responsibility on PMDs.
Quoted 3 lines
Quoted 3 lines
detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have embedded
Can you provide an example for "additional info for device detection"?
Quoted 3 lines
Can you give us more precise definition about SoC driver? Does it include the driver in ARM server?
I am sorry but I don't understand this question.
Quoted 8 lines
Quoted 4 lines
What you mean by a "driver in ARM server"? Do you mean a kernel driver?
There is no "SoC driver" in the text so what definition are asking for?
This patchset introduces
rte_soc_driver, which is inheriting fromrte_driver. I want to know what devices can use this SoC driver/device framework. Is it for the devices from ARM servers, or embedded systems of different vendors?
First, this is not an ARM-specific feature. Consider any MAC connected to the processor via some on-chip bus. In the world of ARM, it is usually a kind of AMBA bus. I think, the Intel Xeon with FPGA would be a good non-ARM example. Here they provide the Quick Path bus (but I don't know the details). So, you cannot access such device as PCI. It is usually not possible to distinguish the bus type easily (Linux calls this a platform device).
So, an rte_soc_device denotes a device integrated on the chip (SoC, System-on-Chip). Such devices can have a lower access latency because they are closer to the processor.
So, if you have a server system driver by a SoC with integrated MACs (no PCI-E involved), there is no way how to access them from DPDK. An rte_soc_device represents such devices and provides a way how to access them from DPDK. That is the goal...
You can have an embedded device (router, switch, monitoring device, NAT, firewall, anything in a "small box" with high throughput demands) that perfectly fits into this SoC framework because it would be usually based on some SoC (ARM, ARM64, ...).
Quoted 2 lines
And this framework is too generalized, if we don't try to understand "soc" in
rte_soc_driver, we can use it for PCI devices. :)
No, you cannot use it for PCI devices, don't worry. There should be no PCI facilities like access to BARs :). But, I think I got your point.
It seems to be generalized because there is no real standard in this area. Any vendor of SoC can provide her custom on-chip bus. The original idea was to build on top of the platform_device from Linux which hides this information from you (unless there is some bus-specific DMA which we must handle in the DPDK PMD).
We could provide an rte_amba_device instead but there is no advantage in this. The amba bus is defined on the RTL level and not on the software level (no BARs, no device discovery). And there are other buses working in a similar way.
Quoted 3 lines
Thanks!
Jianbo
Signature · 4 lines
Jan Viktorin E-mail: [email protected] System Architect Web: www.RehiveTech.com RehiveTech Brno, Czech Republic
Re: [PATCH v3 00/15] Introduce SoC device/driver framework for EAL
Quoted 30 lines
-----Original Message-----
From: Jan Viktorin [mailto:[email protected]]Quoted 1 line · On Sun, 18 Sep 2016 16:56:54 +0800 Jianbo Liu <[email protected]> wrote:
On 18 September 2016 at 15:22, Jan Viktorin <[email protected]>
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 1 line · On Sun, 18 Sep 2016 13:58:50 +0800 Jianbo Liu <[email protected]> wrote:
On 9 September 2016 at 16:43, Shreyansh Jain <[email protected]>
Quoted 15 lines · wrote:
Quoted 15 lines
Quoted 14 lines
Quoted 14 lines
Introduction:
=============This patch set is direct derivative of Jan's original series [1],[2].
- As this deviates substantially from original series, if need be I can post it as a separate patch rather than v2. Please suggest.
- Also, there are comments on original v1 ([4]) which are _not_ incorporated in this series as they refer to section no more in new version.
- This v3 version is based on the rte_driver/device patchset v9 [10]. That series introduced device structures (rte_driver/rte_device) generalizing devices into PCI, VDEV, XXX. For the purpose of this patchset, XXX=>SOC.
Quoted 28 lines
Quoted 5 lines
Quoted 5 lines
[...]
Quoted 3 lines
Quoted 3 lines
5) Design considerations that are different from PCI:
- Each driver implements its own scan and match function. PCI uses theBDF
Quoted 22 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
format to read the device from sysfs, but this _may_not_ be a case for a SoC ethernet device.
= This is an important change from initial proposal by Jan in [2]. Unlike his attempt to use/sys/bus/platform, this patch relies on the
PMD toIt could be many redundant code if Each PMD driver has the scan function if its own.
I think Jan's implementation is common to many platform drivers.Quoted 6 lines
I personally can find a use case for having a custom scan function. However, we should at least provide a default implementation. Probably, both the scan and match functions should be used to _override_ a default behaviour. So, only drivers that require to scan devices in a specific way would provide a custom function for this.
And for each platform/product....
Quoted 4 lines
I agree, that this can sometimes lead to code duplication. Moreover, it opens door for a very non-standard, unsecure and wrong-by-design approaches. I'd like more to provide one or more scan implementations in EAL and do not put this responsibility on PMDs.
[Hemant] A common/default scan function can be added, provided at least one or more PMD driver support it.
w.r.t Jan's original scan function, it was not suitable for any of the NXP SoC's whether ARM or PowerPC.
Unable to validate the Jan's scan function on a real platform, we have skipped it for next phase. Addition of a default scan function can only be done in next phase, when we find a suitable SoC PMD driver supporting it.
Quoted 47 lines
Quoted 14 lines
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have
embeddedCan you provide an example for "additional info for device detection"?
Quoted 3 lines
Can you give us more precise definition about SoC driver? Does it include the driver in ARM server?
I am sorry but I don't understand this question.
Quoted 8 lines
Quoted 4 lines
What you mean by a "driver in ARM server"? Do you mean a kernel driver?
There is no "SoC driver" in the text so what definition are asking for?
This patchset introduces
rte_soc_driver, which is inheriting fromrte_driver. I want to know what devices can use this SoC driver/device framework. Is it for the devices from ARM servers, or embedded systems of different vendors?First, this is not an ARM-specific feature. Consider any MAC connected to the processor via some on-chip bus. In the world of ARM, it is usually a kind of AMBA bus. I think, the Intel Xeon with FPGA would be a good non-ARM example. Here they provide the Quick Path bus (but I don't know the details). So, you cannot access such device as PCI. It is usually not possible to distinguish the bus type easily (Linux calls this a platform device).
So, an
rte_soc_devicedenotes a device integrated on the chip (SoC, System-on- Chip). Such devices can have a lower access latency because they are closer to the processor.So, if you have a server system driver by a SoC with integrated MACs (no PCI-E involved), there is no way how to access them from DPDK. An
rte_soc_devicerepresents such devices and provides a way how to access them from DPDK. That is the goal...You can have an embedded device (router, switch, monitoring device, NAT, firewall, anything in a "small box" with high throughput demands) that perfectly fits into this SoC framework because it would be usually based on some SoC (ARM, ARM64, ...).
Quoted 2 lines
And this framework is too generalized, if we don't try to understand "soc" in
rte_soc_driver, we can use it for PCI devices. :)
Quoted 8 lines
No, you cannot use it for PCI devices, don't worry. There should be no PCI facilities like access to BARs :). But, I think I got your point.
It seems to be generalized because there is no real standard in this area. Any vendor of SoC can provide her custom on-chip bus. The original idea was to build on top of the
platform_devicefrom Linux which hides this information from you (unless there is some bus-specific DMA which we must handle in the DPDK PMD).
[Hemant] Agree with Jan's comments.
This "SoC" term is coined to differentiate the non-PCI based devices. It is not specific to ARM or embedded systems. So, now we have two categories of device drivers,
- one which can be represented by standard PCI device framework;
- others, which does not fit into PCI devices model.
The framework has to be generic to accommodate different types of drivers, as there is no "standard" driver model for SoCs.
Quoted 8 lines
We could provide an
rte_amba_deviceinstead but there is no advantage in this. The amba bus is defined on the RTL level and not on the software level (no BARs, no device discovery). And there are other buses working in a similar way.Quoted 3 lines
Thanks!
Jianbo
Thanks
[Hemant]
Quoted 7 lines
--
Jan Viktorin E-mail: [email protected]
System Architect Web: www.RehiveTech.com
RehiveTech
Brno, Czech Republic
Re: [PATCH v3 00/15] Introduce SoC device/driver framework for EAL
Quoted 3 lines · On Sun, 18 Sep 2016 09:41:55 +0000 Hemant Agrawal <[email protected]>…
Quoted 2 lines
-----Original Message-----
From: Jan Viktorin [mailto:[email protected]]
[...]
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
And for each platform/product....
Quoted 4 lines
I agree, that this can sometimes lead to code duplication. Moreover, it opens door for a very non-standard, unsecure and wrong-by-design approaches. I'd like more to provide one or more scan implementations in EAL and do not put this responsibility on PMDs.
Hi Hemant.
Quoted 5 lines
[Hemant] A common/default scan function can be added, provided at least one or more PMD driver support it.
w.r.t Jan's original scan function, it was not suitable for any of the NXP SoC's whether ARM or PowerPC.Unable to validate the Jan's scan function on a real platform, we have skipped it for next phase. Addition of a default scan function can only be done in next phase, when we find a suitable SoC PMD driver supporting it.
Quite frankly, the situation is same for me. I still have no clue about your approach which seems to be pretty non-standard. I have no way how to test it.
My approach can be tested on any Linux machine with platform devices and device-tree enabled. You would see that I detect those devices (I don't mean any certain network device, I mean all platform devices) and if you provide a driver with a proper compatible string it will be set for you.
I presume that I don't have any upstreamable PMD for this at the moment.
From the very generic scan approach, I cannot see, what kernel infrastructure are you going to use. We should support at least the VFIO-platform which is standard and with IOMMU, it is considered secure. Any other approach would require an out-of-tree kernel driver or some non-secure access to devices. I don't say it is very wrong, but we should be careful about this.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have
embeddedCan you provide an example for "additional info for device detection"?
Can you?
Regards
Jan
[...]
Signature · 4 lines
Jan Viktorin E-mail: [email protected] System Architect Web: www.RehiveTech.com RehiveTech Brno, Czech Republic
Re: [PATCH v3 00/15] Introduce SoC device/driver framework for EAL
Quoted 22 lines · Jan Viktorin
Quoted 3 lines · On Sun, 18 Sep 2016 09:41:55 +0000 Hemant Agrawal <[email protected]>…
Quoted 2 lines
-----Original Message-----
From: Jan Viktorin [mailto:[email protected]][...]
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
And for each platform/product....
Quoted 4 lines
I agree, that this can sometimes lead to code duplication. Moreover, it opens door for a very non-standard, unsecure and wrong-by-design approaches. I'd like more to provide one or more scan implementations in EAL and do not put this responsibility on PMDs.
Hi Hemant.
Quoted 3 lines
[Hemant] A common/default scan function can be added, provided at least one or more PMD driver support it.
w.r.t Jan's original scan function, it was not suitable for any of the NXP SoC's whether ARM or PowerPC.
Quoted 7 lines
Quoted 2 lines
Unable to validate the Jan's scan function on a real platform, we have skipped it for next phase. Addition of a default scan function can only be done in next phase, when we find a suitable SoC PMD driver supporting it.
Quite frankly, the situation is same for me. I still have no clue about your approach which seems to be pretty non-standard. I have no way how to test it.
Yes! Our first sample to test the above proposal is with a specific bus; NXP's new generation Layerscape devices use fsl-mc bus.
https://www.kernel.org/doc/readme/drivers-staging-fsl-mc-README.txt
This is neither a platform bus nor a PCI bus. It does not fit the default implementation for platform bus.
Our objective is to make the first design of SoC patchset very simple and extendable for future. This will improve, when we have more SoC vendor participation and sharing their requirements.
Also, we definitely have a plan to provide default implementation for buses which are generic or have more than one PMD implementation depending on them e.g. use your Platform Bus scan function
Quoted 6 lines
My approach can be tested on any Linux machine with platform devices and device-tree enabled. You would see that I detect those devices (I don't mean any certain network device, I mean all platform devices) and if you provide a driver with a proper compatible string it will be set for you.
Quoted 9 lines
I presume that I don't have any upstreamable PMD for this at the moment.
From the very generic scan approach, I cannot see, what kernel infrastructure are you going to use. We should support at least the VFIO-platform which is standard and with IOMMU, it is considered secure. Any other approach would require an out-of-tree kernel driver or some non-secure access to devices. I don't say it is very wrong, but we should be careful about this.
I agree with your description and approach when the devices are on platform-bus.
We plan to address it in next phase. We have identified another NXP device, which uses platform-bus for device detection. We will use that for our testing.
Quoted 10 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have
embeddedCan you provide an example for "additional info for device detection"?
Can you?
e.g. our fsl-mc bus is more close to PCI bus, where we get object identifiers instead of compatible string.
Quoted 5 lines
Regards
Jan[...]
v4 cover Introduce SoC device/driver framework for EAL
In reply to Shreyansh JainIntroduction:
=============
This patch set is direct derivative of Jan's original series [1],[2].
- This version is based on HEAD (tag: v16.11-rc1) + patch series [11]
Aim:
====
As of now EAL is primarly focused on PCI initialization/probing.
rte_eal_init()
|- rte_eal_pci_init(): Find PCI devices from sysfs |- ... |- rte_eal_memzone_init() |- ...
`- rte_eal_pci_probe(): Driver<=>Device initialization
This patchset introduces SoC framework which would enable SoC drivers and drivers to be plugged into EAL, very similar to how PCI drivers/devices are done today.
This is a stripped down version of PCI framework which allows the SoC PMDs to implement their own routines for detecting devices and linking devices to drivers.
1) Changes to EAL
rte_eal_init()
|- rte_eal_pci_init(): Find PCI devices from sysfs |- rte_eal_soc_init(): Calls PMDs->scan_fn |- ... |- rte_eal_memzone_init() |- ... |- rte_eal_pci_probe(): Driver<=>Device initialization, PMD->devinit()
`- rte_eal_soc_probe(): Calls PMDs->match_fn and PMDs->devinit();
2) New device/driver structures:
- rte_soc_driver (inheriting rte_driver)
- rte_soc_device (inheriting rte_device)
- rte_eth_dev and eth_driver embedded rte_soc_device and rte_soc_driver, respectively.
3) The SoC PMDs need to:
- define rte_soc_driver with necessary scan and match callbacks
- Register themselves using DRIVER_REGISTER_SOC()
- Implement respective bus scanning in the scan callbacks to add necessary devices to SoC device list
- Implement necessary eth_dev_init/uninint for ethernet instances
4) Design considerations that are same as PCI:
- SoC initialization is being done through rte_eal_init(), just after PCI initialization is done.
- As in case of PCI, probe is done after rte_eal_pci_probe() to link the devices detected with the drivers registered.
- Device attach/detach functions are available and have been designed on the lines of PCI framework.
- PMDs register using DRIVER_REGISTER_SOC, very similar to DRIVER_REGISTER_PCI for PCI devices.
- Linked list of SoC driver and devices exists independent of the other driver/device list, but inheriting rte_driver/rte_driver, these are also part of a global list.
5) Design considerations that are different from PCI:
- Each driver implements its own scan and match function. PCI uses the BDF format to read the device from sysfs, but this _may_not_ be a case for a SoC ethernet device.
= This is an important change from initial proposal by Jan in [2]. Unlike his attempt to use /sys/bus/platform, this patch relies on the PMD to detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have embedded devices/MACs which require initialization which cannot be covered through sysfs parsing.
`-> Point (6) below is a side note to above.
= PCI based PMDs rely on EAL's capability to detect devices. This proposal puts the onus on PMD to detect devices, add to soc_device_list and wait for Probe. Matching, of device<=>driver is again PMD's callback.
6) Adding default scan and match helpers for PMDs
- The design warrrants the PMDs implement their own scan of devices on bus, and match routines for probe implementation.
This patch introduces helpers which can be used by PMDs for scan of the platform bus and matching devices against the compatible string extracted from the scan.
- Intention is to make it easier to integrate known SoC which expose platform bus compliant information (compat, sys/bus/platform...).
- PMDs which have deviations from this standard model can implement and hook their bus scanning and probe match callbacks while registering driver.
Patchset Overview:
==================
- Patches 0001~0004 introduce the base infrastructure and test case
- Patch 0005 is for command line support for no-soc, on lines of no-pci
- Patch 0006 enables EAL to handle SoC type devices
- Patch 0007 adds support for scan and probe callbacks and updates the test framework with relevant test case.
- Patch 0008~0010 enable device argument, driver specific flags and interrupt handling related basic infra. Subsequent patches build up on them.
- Patch 0011~0012 add support for default function which PMDs can use for scanning platform bus. These functions are optional and need to be hooked to by PMDs.
- Patch 0013~0014 makes changes to PCI as well as ethdev code to remove assumption that eth_driver is a PCI driver.
- Patch 0016 adds necessary ethdev probe/remove functions for PMDs to use
- Patch 0017 adds support for SoC driver/devices, along with probe/remove functions for Cryptodev devices.
Future/Pending Changes:
=======================
- Device whitelisting/blacklist still relies on command line '-b' and '-c' which are internally implemented using OPT_PCI_BLACKLIST/OPT_PCI_WHITELIST. This needs to be changed to a generic form - OPT_DEV_*LIST - probably.
- No cryptodriver currently uses SoC framework - probably a example driver can be created to demonstrate usage.
- test case for enable-soc command line parameter
[1] http://dpdk.org/ml/archives/dev/2016-January/030915.html
[2] http://www.dpdk.org/ml/archives/dev/2016-May/038486.html
[3] http://dpdk.org/ml/archives/dev/2016-August/045707.html
[4] http://dpdk.org/ml/archives/dev/2016-May/038948.html
[5] http://dpdk.org/ml/archives/dev/2016-May/038953.html
[6] http://dpdk.org/ml/archives/dev/2016-May/038487.html
[7] http://dpdk.org/ml/archives/dev/2016-May/038488.html
[8] http://dpdk.org/ml/archives/dev/2016-May/038489.html
[9] http://dpdk.org/ml/archives/dev/2016-May/038491.html
[10] http://dpdk.org/ml/archives/dev/2016-September/046256.html
[11] http://dpdk.org/ml/archives/dev/2016-October/048915.html
Changes since v3:
- rebasing over HEAD (fed622df tag: v16.11-rc1)
- Add support for default scan function; PMD can use this for scanning on platform bus.
- Support for kernel driver bind/unbind, numa and DMA from Jan's original patches.
- SoC is disabled by default. '--enable-soc' command line parameter enables it. doc updated.
- Updated testcase function names and comments
- Map file addition alphabetically ordered
- Patch author corrected
Changes since v2:
- Rebasing over rte_driver/device patchset v9 [10]
- Added cryptodev support for SoC
- Default match function for SoC device<=>Driver
- Some variables renamed to reflect 'drv' rather than 'dr'
Change since v1 [2]:
- Removed patch 1-5 which were for generalizing some PCI specific routines into EAL. These patches are good-to-have but not directly linked to SoC and hence would be proposed separately.
- Removed support for sysfs parsing (patches 6~9)
- Rebasing over the recent (v8) version of rte_driver/device patchset
- Rebasing over master (16.07)
- Changes to various map file to change API intro to 16.11 from 16.07
Jan Viktorin (15):
eal: define container macro
eal/soc: introduce very essential SoC infra definitions eal/soc: add SoC PMD register/unregister logic eal/soc: implement SoC device list and dump
eal: introduce command line enable SoC option eal/soc: init SoC infra from EAL
eal/soc: extend and utilize devargs
eal/soc: add drv_flags
eal/soc: add intr_handle
eal/soc: add default scan for Soc devices eal/soc: additional features for SoC
ether: utilize container_of for pci_drv
ether: verify we copy info from a PCI device
ether: extract function eth_dev_get_intr_handle
ether: introduce ethernet dev probe remove
Shreyansh Jain (2):
eal/soc: implement probing of drivers eal/crypto: Support rte_soc_driver/device for cryptodev
app/test/Makefile | 1 + app/test/test_soc.c | 404 +++++++++++++++++++ doc/guides/testpmd_app_ug/run_app.rst | 4 + lib/librte_cryptodev/rte_cryptodev.c | 122 +++++- lib/librte_cryptodev/rte_cryptodev.h | 3 + lib/librte_cryptodev/rte_cryptodev_pmd.h | 18 +- lib/librte_cryptodev/rte_cryptodev_version.map | 2 + lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/eal.c | 4 + lib/librte_eal/bsdapp/eal/eal_soc.c | 46 +++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 9 + lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_dev.c | 27 +- lib/librte_eal/common/eal_common_devargs.c | 17 + lib/librte_eal/common/eal_common_options.c | 5 + lib/librte_eal/common/eal_common_soc.c | 368 +++++++++++++++++ lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/common/eal_options.h | 2 + lib/librte_eal/common/eal_private.h | 37 ++ lib/librte_eal/common/include/rte_common.h | 18 + lib/librte_eal/common/include/rte_devargs.h | 8 + lib/librte_eal/common/include/rte_soc.h | 318 +++++++++++++++ lib/librte_eal/linuxapp/eal/Makefile | 2 + lib/librte_eal/linuxapp/eal/eal.c | 8 + lib/librte_eal/linuxapp/eal/eal_soc.c | 515 ++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 9 + lib/librte_ether/rte_ethdev.c | 166 +++++++- lib/librte_ether/rte_ethdev.h | 33 +- 28 files changed, 2131 insertions(+), 19 deletions(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/bsdapp/eal/eal_soc.c create mode 100644 lib/librte_eal/common/eal_common_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.h create mode 100644 lib/librte_eal/linuxapp/eal/eal_soc.c
Signature · 1 line
2.7.4
PATCH v4 1/17 eal: define container macro
From: Jan Viktorin <[email protected]>
--- lib/librte_eal/common/include/rte_common.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
lib/librte_eal/common/include/rte_common.h +18 -0
@@ -331,6 +331,24 @@ rte_bsf32(uint32_t v)#define offsetof (TYPE ,MEMBER ) __builtin_offsetof (TYPE, MEMBER)#endif +/** +* Return pointer to the wrapping struct instance. +* Example: +* +* struct wrapper { +* ... +* struct child c; +* ... +* }; +* +* struct child *x = obtain(...); +* struct wrapper *w = container_of(x, struct wrapper, c); +*/ +#ifndef container_of +#define container_of (p, type, member) \ + ((type *) (((char *) (p)) - offsetof(type, member))) +#endif +#define _RTE_STR (x) #x/** Take a macro value and get a string version of it */ #define RTE_STR (x) _RTE_STR(x)
Signature · 1 line
2.7.4
PATCH v4 2/17 eal/soc: introduce very essential SoC infra definitions
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Define initial structures and functions for the SoC infrastructure. This patch supports only a very minimal functions for now. More features will be added in the following commits.
Includes rte_device/rte_driver inheritance of
rte_soc_device/rte_soc_driver.
--- app/test/Makefile | 1 + app/test/test_soc.c | 90 +++++++++++++++++++++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_private.h | 4 + lib/librte_eal/common/include/rte_soc.h | 138 ++++++++++++++++++++++++++++++++ 5 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.h
app/test/Makefile +1 -0
@@ -77,6 +77,7 @@ APP = test # SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := commands.c SRCS-y += test.c +SRCS-y += test_soc.c SRCS-y += resource.c SRCS-y += test_resource.c test_resource.res: test_resource.c
app/test/test_soc.c new file +90 -0
90 lines not on this page · raw message
lib/librte_eal/common/Makefile +1 -1
@@ -33,7 +33,7 @@ include $(RTE_SDK)/mk/rte.vars.mk INC := rte_branch_prediction.h rte_common.h INC += rte_debug.h rte_eal.h rte_errno.h rte_launch.h rte_lcore.h -INC += rte_log.h rte_memory.h rte_memzone.h rte_pci.h +INC += rte_log.h rte_memory.h rte_memzone.h rte_soc.h rte_pci.h INC += rte_per_lcore.h rte_random.h INC += rte_tailq.h rte_interrupts.h rte_alarm.h INC += rte_string_fns.h rte_version.h
lib/librte_eal/common/eal_private.h +4 -0
@@ -36,6 +36,7 @@#include <stdio.h> #include <rte_pci.h> +#include <rte_soc.h> /** * Initialize the memzone subsystem (private to eal).
@@ -118,6 +119,9 @@ int rte_eal_log_init(const char *id, int facility);*/ int rte_eal_pci_init (void ); +struct rte_soc_driver ; +struct rte_soc_device ; +struct rte_pci_driver ;struct rte_pci_device ;
lib/librte_eal/common/include/rte_soc.h new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 3/17 eal/soc: add SoC PMD register/unregister logic
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Registeration of a SoC driver through a helper RTE_PMD_REGISTER_SOC (on the lines of RTE_PMD_REGISTER_PCI). soc_driver_list stores all the registered drivers.
Test case has been introduced to verify the registration and deregistration.
--- app/test/test_soc.c | 111 ++++++++++++++++++++++++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 3 + lib/librte_eal/common/eal_common_soc.c | 56 ++++++++++++ lib/librte_eal/common/include/rte_soc.h | 26 ++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 3 + 6 files changed, 200 insertions(+) create mode 100644 lib/librte_eal/common/eal_common_soc.c
app/test/test_soc.c +111 -0
@@ -75,6 +75,108 @@ static int test_compare_addr(void)free (a2.name);free (a1.name);free (a0.name); + +return 0 ; +} + +/** +* Empty PMD driver based on the SoC infra. +* +* The rte_soc_device is usually wrapped in some higher-level struct +* (eth_driver). We simulate such a wrapper with an anonymous struct here. +*/ +struct test_wrapper { +struct rte_soc_driver soc_drv; +}; + +struct test_wrapper empty_pmd0 = { + .soc_drv = { + .driver = { + .name ="empty_pmd0" + }, + }, +}; + +struct test_wrapper empty_pmd1 = { + .soc_drv = { + .driver = { + .name ="empty_pmd1" + }, + }, +}; + +static int +count_registered_socdrvs (void ) +{ +int i; +struct rte_soc_driver *drv; + + i =0 ; +TAILQ_FOREACH (drv, &soc_driver_list, next) + i += 1; + +return i; +} + +static int +test_register_unregister (void ) +{ +struct rte_soc_driver *drv; +int count; + +rte_eal_soc_register (&empty_pmd0.soc_drv); + +TEST_ASSERT (!TAILQ_EMPTY (&soc_driver_list), +"No PMD is present but the empty_pmd0 should be there" ); + drv =TAILQ_FIRST (&soc_driver_list); +TEST_ASSERT (!strcmp (drv->driver.name,"empty_pmd0" ), +"The registered PMD is not empty_pmd0 but '%s'" , + drv->driver.name); + +rte_eal_soc_register (&empty_pmd1.soc_drv); + + count =count_registered_socdrvs (); +TEST_ASSERT_EQUAL (count,2 ,"Expected 2 PMDs but detected %d" , count); + +rte_eal_soc_unregister (&empty_pmd0.soc_drv); + count =count_registered_socdrvs (); +TEST_ASSERT_EQUAL (count,1 ,"Expected 1 PMDs but detected %d" , count); + +rte_eal_soc_unregister (&empty_pmd1.soc_drv); + +printf ("%s has been successful\n" , __func__); +return 0 ; +} + +/* save real devices and drivers until the tests finishes */ +struct soc_driver_list real_soc_driver_list = +TAILQ_HEAD_INITIALIZER (real_soc_driver_list); + +static int test_soc_setup (void ) +{ +struct rte_soc_driver *drv; + +/* no real drivers for the test */ +while (!TAILQ_EMPTY (&soc_driver_list)) { + drv =TAILQ_FIRST (&soc_driver_list); +rte_eal_soc_unregister (drv); +TAILQ_INSERT_TAIL (&real_soc_driver_list, drv, next); + } + +return 0 ; +} + +static int test_soc_cleanup (void ) +{ +struct rte_soc_driver *drv; + +/* bring back real drivers after the test */ +while (!TAILQ_EMPTY (&real_soc_driver_list)) { + drv =TAILQ_FIRST (&real_soc_driver_list); +TAILQ_REMOVE (&real_soc_driver_list, drv, next); +rte_eal_soc_register (drv); + } +return 0 ; }
@@ -84,6 +186,15 @@ test_soc(void)if (test_compare_addr ())return -1 ; +if (test_soc_setup ()) +return -1 ; + +if (test_register_unregister ()) +return -1 ; + +if (test_soc_cleanup ()) +return -1 ; +return 0 ; }
lib/librte_eal/bsdapp/eal/rte_eal_version.map +3 -0
@@ -171,8 +171,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_register; + rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; } DPDK_16.07;
lib/librte_eal/common/eal_common_soc.c new file +56 -0
56 lines not on this page · raw message
lib/librte_eal/common/include/rte_soc.h +26 -0
@@ -51,8 +51,14 @@ extern "C" {#include <string.h> #include <rte_dev.h> +#include <rte_eal.h> #include <rte_debug.h> +extern struct soc_driver_list soc_driver_list; +/**< Global list of SoC Drivers */ + +TAILQ_HEAD (soc_driver_list, rte_soc_driver);/**< SoC drivers in D-linked Q. */ +struct rte_soc_id {const char *compatible;/**< OF compatible specification */ uint64_t priv_data;/**< SoC Driver specific data */
@@ -135,4 +141,24 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, return strcmp(a0->name, a1->name); } +/** +* Register a SoC driver. +*/ +void rte_eal_soc_register (struct rte_soc_driver *driver); + +/** Helper for SoC device registeration from PMD Drivers */ +#define RTE_PMD_REGISTER_SOC (nm, soc_drv) \ +RTE_INIT(socinitfn_ ##name); \ +static void socinitfn_ ##name(void) \ +{\ + (soc_drv).driver.name = RTE_STR(nm);\ + rte_eal_soc_register(&soc_drv); \ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +/** +* Unregister a SoC driver. +*/ +void rte_eal_soc_unregister (struct rte_soc_driver *driver); +#endif
lib/librte_eal/linuxapp/eal/Makefile +1 -0
@@ -77,6 +77,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_soc.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c
lib/librte_eal/linuxapp/eal/rte_eal_version.map +3 -0
@@ -175,8 +175,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_register; + rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; } DPDK_16.07;
Signature · 1 line
2.7.4
PATCH v4 4/17 eal/soc: implement SoC device list and dump
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
SoC devices would be linked in a separate list (from PCI). This is used for probe function.
A helper for dumping the device list is added.
--- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++ lib/librte_eal/common/eal_common_soc.c | 34 +++++++++++++++++++++++++ lib/librte_eal/common/include/rte_soc.h | 9 +++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++ 4 files changed, 47 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +2 -0
@@ -171,11 +171,13 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_dump; rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_device_list; soc_driver_list; } DPDK_16.07;
lib/librte_eal/common/eal_common_soc.c +34 -0
@@ -31,6 +31,8 @@* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <stddef.h> +#include <stdio.h> #include <sys/queue.h> #include <rte_log.h>
@@ -40,6 +42,38 @@/* Global SoC driver list */ struct soc_driver_list soc_driver_list =TAILQ_HEAD_INITIALIZER (soc_driver_list); +struct soc_device_list soc_device_list = +TAILQ_HEAD_INITIALIZER (soc_device_list); + +/* dump one device */ +static int +soc_dump_one_device (FILE *f,struct rte_soc_device *dev) +{ +int i; + +fprintf (f,"%s" , dev->addr.name); +fprintf (f," - fdt_path: %s\n" , + dev->addr.fdt_path ? dev->addr.fdt_path :"(none)" ); + +for (i =0 ; dev->id && dev->id[i].compatible; ++i) +fprintf (f," %s\n" , dev->id[i].compatible); + +return 0 ; +} + +/* dump devices on the bus to an output stream */ +void +rte_eal_soc_dump (FILE *f) +{ +struct rte_soc_device *dev =NULL ; + +if (!f) +return ; + + TAILQ_FOREACH(dev, &soc_device_list, next) { +soc_dump_one_device (f, dev); + } +}/* register a driver */ void
lib/librte_eal/common/include/rte_soc.h +9 -0
@@ -56,8 +56,12 @@ extern "C" {extern struct soc_driver_list soc_driver_list;/**< Global list of SoC Drivers */ +extern struct soc_device_list soc_device_list; +/**< Global list of SoC Devices */ TAILQ_HEAD (soc_driver_list, rte_soc_driver);/**< SoC drivers in D-linked Q. */ +TAILQ_HEAD (soc_device_list, rte_soc_device);/**< SoC devices in D-linked Q. */ +struct rte_soc_id {const char *compatible;/**< OF compatible specification */
@@ -142,6 +146,11 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, }/** +* Dump discovered SoC devices. +*/ +void rte_eal_soc_dump (FILE *f); + +/** * Register a SoC driver. */ void rte_eal_soc_register (struct rte_soc_driver *driver);
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
@@ -175,11 +175,13 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_dump; rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_device_list; soc_driver_list; } DPDK_16.07;
Signature · 1 line
2.7.4
PATCH v4 5/17 eal: introduce command line enable SoC option
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Support --enable-soc. SoC support is disabled by default.
--- doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ lib/librte_eal/common/eal_common_options.c | 5 +++++ lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/common/eal_options.h | 2 ++ 4 files changed, 12 insertions(+)
doc/guides/testpmd_app_ug/run_app.rst +4 -0
@@ -156,6 +156,10 @@ See the DPDK Getting Started Guides for more information on these options. Use malloc instead of hugetlbfs. +* ``--enable-soc`` + + Enable SoC framework support + Testpmd Command-line Options ----------------------------
lib/librte_eal/common/eal_common_options.c +5 -0
@@ -75,6 +75,7 @@ const struct option eal_long_options[] = { {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM }, {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM }, + {OPT_ENABLE_SOC, 0, NULL, OPT_ENABLE_SOC_NUM }, {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM }, {OPT_HELP, 0, NULL, OPT_HELP_NUM }, {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM },
@@ -843,6 +844,10 @@ eal_parse_common_option(int opt, const char *optarg,break ;/* long options */ +case OPT_ENABLE_SOC_NUM : + conf->enable_soc =1 ; +break ; +case OPT_HUGE_UNLINK_NUM : conf->hugepage_unlink =1 ;break ;
lib/librte_eal/common/eal_internal_cfg.h +1 -0
@@ -67,6 +67,7 @@ struct internal_config {unsigned hugepage_unlink;/**< true to unlink backing files */ volatile unsigned xen_dom0_support;/**< support app running on Xen Dom0*/ volatile unsigned no_pci;/**< true to disable PCI */ +volatile unsigned enable_soc;/**< true to enable SoC */ volatile unsigned no_hpet;/**< true to disable HPET */ volatile unsigned vmware_tsc_map;/**< true to use VMware TSC mapping * instead of native TSC */
lib/librte_eal/common/eal_options.h +2 -0
@@ -49,6 +49,8 @@ enum {OPT_BASE_VIRTADDR_NUM , #define OPT_CREATE_UIO_DEV "create-uio-dev"OPT_CREATE_UIO_DEV_NUM , +#define OPT_ENABLE_SOC "enable-soc" +OPT_ENABLE_SOC_NUM , #define OPT_FILE_PREFIX "file-prefix"OPT_FILE_PREFIX_NUM , #define OPT_HUGE_DIR "huge-dir"
Signature · 1 line
2.7.4
PATCH v4 6/17 eal/soc: init SoC infra from EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/eal.c | 4 +++ lib/librte_eal/bsdapp/eal/eal_soc.c | 46 ++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 10 +++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/eal.c | 3 ++ lib/librte_eal/linuxapp/eal/eal_soc.c | 56 +++++++++++++++++++++++++++++++++++ 7 files changed, 121 insertions(+) create mode 100644 lib/librte_eal/bsdapp/eal/eal_soc.c create mode 100644 lib/librte_eal/linuxapp/eal/eal_soc.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -56,6 +56,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_hugepage_info.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_thread.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_pci.c +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_soc.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_debug.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_lcore.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_timer.c
lib/librte_eal/bsdapp/eal/eal.c +4 -0
@@ -64,6 +64,7 @@#include <rte_string_fns.h> #include <rte_cpuflags.h> #include <rte_interrupts.h> +#include <rte_soc.h> #include <rte_pci.h> #include <rte_dev.h> #include <rte_devargs.h>
@@ -564,6 +565,9 @@ rte_eal_init(int argc, char **argv)if (rte_eal_pci_init () <0 )rte_panic ("Cannot init PCI\n" ); +if (rte_eal_soc_init () <0 ) +rte_panic ("Cannot init SoC\n" ); +eal_check_mem_on_local_socket ();if (eal_plugins_init () <0 )
lib/librte_eal/bsdapp/eal/eal_soc.c new file +46 -0
46 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +10 -0
@@ -122,6 +122,16 @@ int rte_eal_pci_init(void);struct rte_soc_driver ;struct rte_soc_device ; +/** +* Init the SoC infra. +* +* This function is private to EAL. +* +* @return +* 0 on success, negative on error +*/ +int rte_eal_soc_init (void ); +struct rte_pci_driver ;struct rte_pci_device ;
lib/librte_eal/linuxapp/eal/Makefile +1 -0
@@ -65,6 +65,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio_mp_sync.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_uio.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_vfio.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_soc.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_debug.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_lcore.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_timer.c
lib/librte_eal/linuxapp/eal/eal.c +3 -0
@@ -810,6 +810,9 @@ rte_eal_init(int argc, char **argv)rte_panic ("Cannot init VFIO\n" );#endif +if (rte_eal_soc_init () <0 ) +rte_panic ("Cannot init SoC\n" ); +if (rte_eal_memory_init () <0 )rte_panic ("Cannot init memory\n" );
lib/librte_eal/linuxapp/eal/eal_soc.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 7/17 eal/soc: implement probing of drivers
In reply to Shreyansh JainEach SoC PMD registers a set of callback for scanning its own bus/infra and matching devices to drivers when probe is called.
This patch introduces the infra for calls to SoC scan on rte_eal_soc_init() and match on rte_eal_soc_probe().
Patch also adds test case for scan and probe.
--
v4:
- Update test_soc for descriptive test function names
- Comments over test functions
- devinit and devuninint --> probe/remove
- RTE_VERIFY at some places
--- app/test/test_soc.c | 205 ++++++++++++++++++++++- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 4 + lib/librte_eal/common/eal_common_soc.c | 213 +++++++++++++++++++++++- lib/librte_eal/common/include/rte_soc.h | 83 ++++++++- lib/librte_eal/linuxapp/eal/eal.c | 5 + lib/librte_eal/linuxapp/eal/eal_soc.c | 21 ++- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 4 + 7 files changed, 523 insertions(+), 12 deletions(-)
app/test/test_soc.c +204 -1
@@ -87,14 +87,65 @@ static int test_compare_addr(void)*/ struct test_wrapper {struct rte_soc_driver soc_drv; +struct rte_soc_device soc_dev; }; +static int empty_pmd0_probe (struct rte_soc_driver *drv, +struct rte_soc_device *dev); +static int empty_pmd0_remove (struct rte_soc_device *dev); + +static void always_find_dev0_cb (void ); +static int match_dev0_by_name (struct rte_soc_driver *drv, +struct rte_soc_device *dev); + +static void always_find_dev1_cb (void ); +static int match_dev1_by_name (struct rte_soc_driver *drv, +struct rte_soc_device *dev); + +/** +* Dummy probe handler for PMD driver 'pmd0'. +* +* @param drv +* driver object +* @param dev +* device object +* @return +* 0 on success +*/ +static int +empty_pmd0_probe(struct rte_soc_driver *drv __rte_unused, + struct rte_soc_device *dev __rte_unused) +{ +return 0 ; +} + +/** +* Remove handler for PMD driver 'pmd0'. +* +* @param dev +* device to remove +* @return +* 0 on success +*/ +static int +empty_pmd0_remove (struct rte_soc_device *dev) +{ +/* Release the memory associated with dev->addr.name */ +free (dev->addr.name); + +return 0 ; +} +struct test_wrapper empty_pmd0 = { .soc_drv = { .driver = { .name ="empty_pmd0" }, - }, + .probe = empty_pmd0_probe, + .remove = empty_pmd0_remove, + .scan_fn = always_find_dev0_cb, + .match_fn = match_dev0_by_name, + } };struct test_wrapper empty_pmd1 = {
@@ -102,9 +153,87 @@ struct test_wrapper empty_pmd1 = { .driver = { .name = "empty_pmd1" }, + .scan_fn = always_find_dev1_cb, + .match_fn = match_dev1_by_name, }, }; +/** +* Bus scan by PMD 'pmd0' for adding device 'dev0' +* +* @param void +* @return void +*/ +static void +always_find_dev0_cb (void ) +{ +/* SoC's scan would scan devices on its bus and add to +* soc_device_list +*/ + empty_pmd0.soc_dev.addr.name =strdup ("empty_pmd0_dev" ); + +TAILQ_INSERT_TAIL (&soc_device_list, &empty_pmd0.soc_dev, next); +} + +/** +* Match device 'dev0' with driver PMD pmd0 +* +* @param drv +* Driver with this matching needs to be done; unused here +* @param dev +* device to be matched against driver +* @return +* 0 on successful matched +* 1 if driver<=>device don't match +*/ +static int +match_dev0_by_name(struct rte_soc_driver *drv __rte_unused, +struct rte_soc_device *dev) +{ +if (!dev->addr.name ||strcmp (dev->addr.name,"empty_pmd0_dev" )) +return 0 ; + +return 1 ; +} + +/** +* Bus scan by PMD 'pmd0' for adding device 'dev1' +* +* @param void +* @return void +*/ +static void +always_find_dev1_cb (void ) +{ +/* SoC's scan would scan devices on its bus and add to +* soc_device_list +*/ + empty_pmd0.soc_dev.addr.name =strdup ("empty_pmd1_dev" ); + +TAILQ_INSERT_TAIL (&soc_device_list, &empty_pmd1.soc_dev, next); +} + +/** +* Match device 'dev1' with driver PMD pmd0 +* +* @param drv +* Driver with this matching needs to be done; unused here +* @param dev +* device to be matched against driver +* @return +* 0 on successful matched +* 1 if driver<=>device don't match +*/ +static int +match_dev1_by_name(struct rte_soc_driver *drv __rte_unused, +struct rte_soc_device *dev) +{ +if (!dev->addr.name ||strcmp (dev->addr.name,"empty_pmd1_dev" )) +return 0 ; + +return 1 ; +} +static int count_registered_socdrvs (void ) {
@@ -148,13 +277,68 @@ test_register_unregister(void)return 0 ; } +/* Test Probe (scan and match) functionality */ +static int +test_soc_scan_and_match (void ) +{ +int drv_count =0 ; +struct rte_soc_driver *drv; + +/* Registering dummy drivers */ +rte_eal_soc_register (&empty_pmd0.soc_drv); +rte_eal_soc_register (&empty_pmd1.soc_drv); +/* Assuming that test_register_unregister is working, not verifying +* that drivers are indeed registered +*/ + +/* rte_eal_soc_init is called by rte_eal_init, which in turn calls the +* scan_fn of each driver. +*/ + TAILQ_FOREACH(drv, &soc_driver_list, next) { +if (drv && drv->scan_fn) + drv->scan_fn (); + drv_count++; + } + +/* rte_eal_init() would perform other inits here */ + +/* Probe would link the SoC devices<=>drivers */ +rte_eal_soc_probe (); + +/* Unregistering dummy drivers */ +rte_eal_soc_unregister (&empty_pmd0.soc_drv); +rte_eal_soc_unregister (&empty_pmd1.soc_drv); + +/* Verify the Unregistering has removed the driver from list */ + TAILQ_FOREACH(drv, &soc_driver_list, next) { +if (drv) + drv_count--; + } + +free (empty_pmd0.soc_dev.addr.name); + +/* If drv_count is anything other than 0, Unregistering failed */ +if (drv_count) { +printf ("%s has failed\n" , __func__); +return 1 ; + } + +printf ("%s has been successful\n" , __func__); +return 0 ; +} +/* save real devices and drivers until the tests finishes */ struct soc_driver_list real_soc_driver_list =TAILQ_HEAD_INITIALIZER (real_soc_driver_list); +/* save real devices and drivers until the tests finishes */ +struct soc_device_list real_soc_device_list = +TAILQ_HEAD_INITIALIZER (real_soc_device_list); +static int test_soc_setup (void ) {struct rte_soc_driver *drv; +struct rte_soc_device *dev;/* no real drivers for the test */ while (!TAILQ_EMPTY (&soc_driver_list)) {
@@ -163,12 +347,20 @@ static int test_soc_setup(void)TAILQ_INSERT_TAIL (&real_soc_driver_list, drv, next); } +/* And, no real devices for the test */ +while (!TAILQ_EMPTY (&soc_device_list)) { + dev =TAILQ_FIRST (&soc_device_list); +TAILQ_REMOVE (&soc_device_list, dev, next); +TAILQ_INSERT_TAIL (&real_soc_device_list, dev, next); + } +return 0 ; }static int test_soc_cleanup (void ) {struct rte_soc_driver *drv; +struct rte_soc_device *dev;/* bring back real drivers after the test */ while (!TAILQ_EMPTY (&real_soc_driver_list)) {
@@ -177,6 +369,13 @@ static int test_soc_cleanup(void)rte_eal_soc_register (drv); } +/* And, bring back real devices after the test */ +while (!TAILQ_EMPTY (&real_soc_device_list)) { + dev =TAILQ_FIRST (&real_soc_device_list); +TAILQ_REMOVE (&real_soc_device_list, dev, next); +TAILQ_INSERT_TAIL (&soc_device_list, dev, next); + } +return 0 ; }
@@ -192,6 +391,10 @@ test_soc(void)if (test_register_unregister ())return -1 ; +/* Assuming test_register_unregister has succeeded */ +if (test_soc_scan_and_match ()) +return -1 ; +if (test_soc_cleanup ())return -1 ;
lib/librte_eal/bsdapp/eal/rte_eal_version.map +4 -0
@@ -171,7 +171,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_detach; rte_eal_soc_dump; + rte_eal_soc_match; + rte_eal_soc_probe; + rte_eal_soc_probe_one; rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_unmap_resource;
lib/librte_eal/common/eal_common_soc.c +210 -3
243 lines not on this page · raw message
lib/librte_eal/common/include/rte_soc.h +78 -5
123 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal.c +5 -0
@@ -70,6 +70,7 @@#include <rte_cpuflags.h> #include <rte_interrupts.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_dev.h> #include <rte_devargs.h> #include <rte_common.h>
@@ -890,6 +891,10 @@ rte_eal_init(int argc, char **argv)if (rte_eal_pci_probe ())rte_panic ("Cannot probe PCI\n" ); +/* Probe & Initialize SoC devices */ +if (rte_eal_soc_probe ()) +rte_panic ("Cannot probe SoC\n" ); +rte_eal_mcfg_complete ();return fctret;
lib/librte_eal/linuxapp/eal/eal_soc.c +18 -3
@@ -44,13 +44,28 @@#include <rte_log.h> #include <rte_soc.h> -#include "eal_internal_cfg.h" -#include "eal_filesystem.h" -#include "eal_private.h" +#include <eal_internal_cfg.h> +#include <eal_filesystem.h> +#include <eal_private.h> /* Init the SoC EAL subsystem */ int rte_eal_soc_init (void ) { +struct rte_soc_driver *drv; + +/* SoC is disabled by default */ +if (!internal_config.enable_soc) +return 0 ; + +/* For each registered driver, call their scan routine to perform any +* custom scan for devices (for example, custom buses) +*/ + TAILQ_FOREACH(drv, &soc_driver_list, next) { +RTE_VERIFY (drv->scan_fn); + drv->scan_fn (); +/* Ignore all errors from this */ + } +return 0 ; }
lib/librte_eal/linuxapp/eal/rte_eal_version.map +4 -0
@@ -175,7 +175,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_detach; rte_eal_soc_dump; + rte_eal_soc_match; + rte_eal_soc_probe; + rte_eal_soc_probe_one; rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_unmap_resource;
Signature · 1 line
2.7.4
PATCH v4 8/17 eal/soc: extend and utilize devargs
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
It is assumed that SoC Devices provided on command line are prefixed with "soc:". This patch adds parse and attach support for such devices.
--- lib/librte_eal/common/eal_common_dev.c | 27 +++++++++---- lib/librte_eal/common/eal_common_devargs.c | 17 ++++++++ lib/librte_eal/common/eal_common_soc.c | 61 ++++++++++++++++++++++++----- lib/librte_eal/common/include/rte_devargs.h | 8 ++++ lib/librte_eal/common/include/rte_soc.h | 24 ++++++++++++ 5 files changed, 120 insertions(+), 17 deletions(-)
lib/librte_eal/common/eal_common_dev.c +20 -7
@@ -107,17 +107,23 @@ rte_eal_dev_init(void)int rte_eal_dev_attach (const char *name,const char *devargs) { -struct rte_pci_addr addr; +struct rte_soc_addr soc_addr; +struct rte_pci_addr pci_addr;if (name ==NULL || devargs ==NULL ) {RTE_LOG (ERR ,EAL ,"Invalid device or arguments provided\n" );return -EINVAL ; } -if (eal_parse_pci_DomBDF (name, &addr) ==0 ) { -if (rte_eal_pci_probe_one (&addr) <0 ) +memset (&soc_addr,0 ,sizeof (soc_addr)); +if (rte_eal_parse_soc_spec (name, &soc_addr) ==0 ) { +if (rte_eal_soc_probe_one (&soc_addr) <0 ) { +free (soc_addr.name); + goto err; + } + }else if (eal_parse_pci_DomBDF (name, &pci_addr) ==0 ) { +if (rte_eal_pci_probe_one (&pci_addr) <0 ) goto err; - }else {if (rte_eal_vdev_init (name, devargs)) goto err;
@@ -132,15 +138,22 @@ err:int rte_eal_dev_detach (const char *name) { -struct rte_pci_addr addr; +struct rte_soc_addr soc_addr; +struct rte_pci_addr pci_addr;if (name ==NULL ) {RTE_LOG (ERR ,EAL ,"Invalid device provided.\n" );return -EINVAL ; } -if (eal_parse_pci_DomBDF (name, &addr) ==0 ) { -if (rte_eal_pci_detach (&addr) <0 ) +memset (&soc_addr,0 ,sizeof (soc_addr)); +if (rte_eal_parse_soc_spec (name, &soc_addr) ==0 ) { +if (rte_eal_soc_detach (&soc_addr) <0 ) { +free (soc_addr.name); + goto err; + } + }else if (eal_parse_pci_DomBDF (name, &pci_addr) ==0 ) { +if (rte_eal_pci_detach (&pci_addr) <0 ) goto err; }else {if (rte_eal_vdev_uninit (name))
lib/librte_eal/common/eal_common_devargs.c +17 -0
@@ -41,6 +41,7 @@#include <string.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_devargs.h> #include "eal_private.h"
@@ -105,6 +106,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) goto fail;break ; + +case RTE_DEVTYPE_WHITELISTED_SOC : +case RTE_DEVTYPE_BLACKLISTED_SOC : +/* try to parse soc device with prefix "soc:" */ +if (rte_eal_parse_soc_spec (buf, &devargs->soc.addr) !=0 ) + goto fail; +break ; +case RTE_DEVTYPE_VIRTUAL :/* save driver name */ ret = snprintf(devargs->virt.drv_name,
@@ -166,6 +175,14 @@ rte_eal_devargs_dump(FILE *f) devargs->pci.addr.devid, devargs->pci.addr.function, devargs->args); + else if (devargs->type == RTE_DEVTYPE_WHITELISTED_SOC) + fprintf(f, " SoC whitelist %s %s\n", + devargs->soc.addr.name, + devargs->soc.addr.fdt_path); + else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_SOC) + fprintf(f, " SoC blacklist %s %s\n", + devargs->soc.addr.name, + devargs->soc.addr.fdt_path); else if (devargs->type == RTE_DEVTYPE_VIRTUAL) fprintf(f, " VIRTUAL %s %s\n", devargs->virt.drv_name,
lib/librte_eal/common/eal_common_soc.c +51 -10
94 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +8 -0
@@ -51,6 +51,7 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> #include <rte_pci.h> +#include <rte_soc.h> /** * Type of generic device
@@ -58,6 +59,8 @@ extern "C" {enum rte_devtype {RTE_DEVTYPE_WHITELISTED_PCI ,RTE_DEVTYPE_BLACKLISTED_PCI , +RTE_DEVTYPE_WHITELISTED_SOC , +RTE_DEVTYPE_BLACKLISTED_SOC ,RTE_DEVTYPE_VIRTUAL , };
@@ -83,6 +86,11 @@ struct rte_devargs {/** PCI location. */ struct rte_pci_addr addr; } pci; +/** Used if type is RTE_DEVTYPE_*_SOC. */ +struct { +/** SoC location. */ +struct rte_soc_addr addr; + } soc;/** Used if type is RTE_DEVTYPE_VIRTUAL. */ struct {/** Driver name. */
lib/librte_eal/common/include/rte_soc.h +24 -0
@@ -164,6 +164,30 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, }/** +* Parse a specification of a soc device. The specification must differentiate +* a SoC device specification from the PCI bus and virtual devices. We assume +* a SoC specification starts with "soc:". The function allocates the name +* entry of the given addr. +* +* @return +* - 0 on success +* - 1 when not a SoC spec +* - -1 on failure +*/ +static inline int +rte_eal_parse_soc_spec (const char *spec,struct rte_soc_addr *addr) +{ +if (strstr (spec,"soc:" ) == spec) { + addr->name =strdup (spec +4 ); +if (addr->name ==NULL ) +return -1 ; +return 0 ; + } + +return 1 ; +} + +/** * Default function for matching the Soc driver with device. Each driver can * either use this function or define their own soc matching function. * This function relies on the compatible string extracted from sysfs. But,
Signature · 1 line
2.7.4
PATCH v4 9/17 eal/soc: add drv_flags
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
The flags are copied from the PCI ones. They should be refactorized into a general set of flags in the future.
--- lib/librte_eal/common/include/rte_soc.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/librte_eal/common/include/rte_soc.h +10 -0
@@ -123,8 +123,18 @@ struct rte_soc_driver {soc_scan_t *scan_fn;/**< Callback for scanning SoC bus*/ soc_match_t *match_fn;/**< Callback to match dev<->drv */ const struct rte_soc_id *id_table;/**< ID table, NULL terminated */ +uint32_t drv_flags;/**< Control handling of device */ }; +/** Device needs to map its resources by EAL */ +#define RTE_SOC_DRV_NEED_MAPPING 0x0001 +/** Device needs to be unbound even if no module is provieded */ +#define RTE_SOC_DRV_FORCE_UNBIND 0x0004 +/** Device driver supports link state interrupt */ +#define RTE_SOC_DRV_INTR_LSC 0x0008 +/** Device driver supports detaching capability */ +#define RTE_SOC_DRV_DETACHABLE 0x0010 +/** * Utility function to write a SoC device name, this device name can later be * used to retrieve the corresponding rte_soc_addr using above functions.
Signature · 1 line
2.7.4
PATCH v4 10/17 eal/soc: add intr_handle
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_eal/common/include/rte_soc.h | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_eal/common/include/rte_soc.h +2 -0
@@ -53,6 +53,7 @@ extern "C" {#include <rte_dev.h> #include <rte_eal.h> #include <rte_debug.h> +#include <rte_interrupts.h> extern struct soc_driver_list soc_driver_list;/**< Global list of SoC Drivers */
@@ -80,6 +81,7 @@ struct rte_soc_device {struct rte_device device;/**< Inherit code device */ struct rte_soc_addr addr;/**< SoC device Location */ struct rte_soc_id *id;/**< SoC device ID list */ +struct rte_intr_handle intr_handle;/**< Interrupt handle */ struct rte_soc_driver *driver;/**< Associated driver */ };
Signature · 1 line
2.7.4
PATCH v4 11/17 eal/soc: add default scan for Soc devices
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Default implementation which scans the sysfs platform devices hierarchy. For each device, extract the ueven and convert into rte_soc_device.
The information populated can then be used in probe to match against the drivers registered.
--- lib/librte_eal/common/include/rte_soc.h | 10 +- lib/librte_eal/linuxapp/eal/eal_soc.c | 315 ++++++++++++++++++++++++++++++++ 2 files changed, 324 insertions(+), 1 deletion(-)
lib/librte_eal/common/include/rte_soc.h +9 -1
@@ -64,7 +64,10 @@ TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked Q. */TAILQ_HEAD (soc_device_list, rte_soc_device);/**< SoC devices in D-linked Q. */ struct rte_soc_id { -const char *compatible;/**< OF compatible specification */ +union { +const char *compatible;/**< OF compatible specification */ +char *_compatible; + };uint64_t priv_data;/**< SoC Driver specific data */ };
@@ -200,6 +203,11 @@ rte_eal_parse_soc_spec(const char *spec, struct rte_soc_addr *addr) }/** +* Scan for new SoC devices. +*/ +int rte_eal_soc_scan (void ); + +/** * Default function for matching the Soc driver with device. Each driver can * either use this function or define their own soc matching function. * This function relies on the compatible string extracted from sysfs. But,
lib/librte_eal/linuxapp/eal/eal_soc.c +315 -0
321 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v4 11/17] eal/soc: add default scan for Soc devices
Quoted 11 lines · On Sat, 15 Oct 2016 19:15:02 +0530 Shreyansh Jain <[email protected]>…
From: Jan Viktorin <[email protected]>
Default implementation which scans the sysfs platform devices hierarchy. For each device, extract the ueven and convert into
rte_soc_device.The information populated can then be used in probe to match against the drivers registered.
Signed-off-by Jan Viktorin <[email protected]>[Shreyansh: restructure commit to be an optional implementation]Signed-off-by Shreyansh Jain <[email protected]>
[...]
lib/librte_eal/linuxapp/eal/eal_soc.c line 336
Quoted 3 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +3
-0+ +int +rte_eal_soc_scan (void )
What about naming it rte_eal_soc_scan_default? This would underline the fact that this function can be replaced.
Second, this is for the 7/17 patch:
-/* register a driver */
void
rte_eal_soc_register(struct rte_soc_driver *driver) {
+ /* For a valid soc driver, match and scan function
+ * should be provided.
+ */
+ RTE_VERIFY(driver != NULL);
+ RTE_VERIFY(driver->match_fn != NULL);
+ RTE_VERIFY(driver->scan_fn != NULL);
What about setting the match_fn and scan_fn to default implementations if they are NULL? This would make the standard/default approach easier to use.
TAILQ_INSERT_TAIL(&soc_driver_list, driver, next);
}
Quoted 32 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +29
-0+{ +struct dirent *e; +DIR *dir; +char dirname[PATH_MAX ]; + + dir =opendir (soc_get_sysfs_path ()); +if (dir ==NULL ) { +RTE_LOG (ERR ,EAL ,"%s(): opendir failed: %s\n" , + __func__,strerror (errno)); +return -1 ; + } + +while ((e =readdir (dir)) !=NULL ) { +if (e->d_name[0 ] =='.' ) +continue ; + +snprintf (dirname,sizeof (dirname),"%s/%s" , +soc_get_sysfs_path (), e->d_name); +if (soc_scan_one (dirname, e->d_name) <0 ) + goto error; + } +closedir (dir); +return 0 ; + +error: +closedir (dir); +return -1 ; +} +/* Init the SoC EAL subsystem */ int rte_eal_soc_init (void )
Signature · 4 lines
Jan Viktorin E-mail: [email protected] System Architect Web: www.RehiveTech.com RehiveTech Brno, Czech Republic
Re: [PATCH v4 11/17] eal/soc: add default scan for Soc devices
Hi Jan,
Quoted 22 lines
-----Original Message-----
From: Jan Viktorin [mailto:[email protected]]
Sent: Sunday, October 16, 2016 6:27 AM
To: Shreyansh Jain <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v4 11/17] eal/soc: add default scan for Soc devicesQuoted 11 lines · On Sat, 15 Oct 2016 19:15:02 +0530 Shreyansh Jain <[email protected]>…
From: Jan Viktorin <[email protected]>
Default implementation which scans the sysfs platform devices hierarchy. For each device, extract the ueven and convert into
rte_soc_device.The information populated can then be used in probe to match against the drivers registered.
Signed-off-by Jan Viktorin <[email protected]>[Shreyansh: restructure commit to be an optional implementation]Signed-off-by Shreyansh Jain <[email protected]>
Quoted 8 lines
[...]
lib/librte_eal/linuxapp/eal/eal_soc.c line 336
Quoted 3 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +3
-0+ +int +rte_eal_soc_scan (void )What about naming it
rte_eal_soc_scan_default? This would underline the fact that this function can be replaced.
Yes, that would be in sync with match default. I will do it.
Quoted 14 lines
Second, this is for the 7/17 patch:
(quoted diff) +6
-1-/* register a driver */ void rte_eal_soc_register(struct rte_soc_driver *driver) { + /* For a valid soc driver, match and scan function + * should be provided. + */ + RTE_VERIFY(driver != NULL); + RTE_VERIFY(driver->match_fn != NULL); + RTE_VERIFY(driver->scan_fn != NULL);
Quoted 6 lines
What about setting the
match_fnandscan_fnto default implementations if they
are NULL? This would make the standard/default approach easier to use.
TAILQ_INSERT_TAIL(&soc_driver_list, driver, next);
}
I am not in favor of a forced default. What if user never intended it - it would lead to wrong scan being used and only intimation which can provided to user is a log. Selecting such functions should be a model of PMD - one which is enforced.
Quoted 36 lines
Quoted 23 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +22
-0+{ +struct dirent *e; +DIR *dir; +char dirname[PATH_MAX ]; + + dir =opendir (soc_get_sysfs_path ()); +if (dir ==NULL ) { +RTE_LOG (ERR ,EAL ,"%s(): opendir failed: %s\n" , + __func__,strerror (errno)); +return -1 ; + } + +while ((e =readdir (dir)) !=NULL ) { +if (e->d_name[0 ] =='.' ) +continue ; + +snprintf (dirname,sizeof (dirname),"%s/%s" , +soc_get_sysfs_path (), e->d_name); +if (soc_scan_one (dirname, e->d_name) <0 ) + goto error; + } +closedir (dir);lib/librte_eal/linuxapp/eal/eal_soc.c line 368
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +7
-0+return 0 ; + +error: +closedir (dir); +return -1 ; +} +/* Init the SoC EAL subsystem */ int rte_eal_soc_init (void )
Quoted 5 lines
--
Jan Viktorin E-mail: [email protected]
System Architect Web: www.RehiveTech.com
RehiveTech
Brno, Czech Republic
Thanks for your quick comments.
I have not yet taken all the inputs you had provided in review of v3 - I will be replying to those soon marking out what I have taken and what I have not.
-
Shreyansh
Re: [PATCH v4 11/17] eal/soc: add default scan for Soc devices
Hi Jan,
Quoted 26 lines · Shreyansh Jain
Hi Jan,
Quoted 24 lines
-----Original Message-----
From: Jan Viktorin [mailto:[email protected]]
Sent: Sunday, October 16, 2016 6:27 AM
To: Shreyansh Jain <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v4 11/17] eal/soc: add default scan for Soc devicesQuoted 11 lines · On Sat, 15 Oct 2016 19:15:02 +0530 Shreyansh Jain <[email protected]>…
From: Jan Viktorin <[email protected]>
Default implementation which scans the sysfs platform devices hierarchy.. For each device, extract the ueven and convert into
rte_soc_device.The information populated can then be used in probe to match against the drivers registered.
Signed-off-by Jan Viktorin <[email protected]>[Shreyansh: restructure commit to be an optional implementation]Signed-off-by Shreyansh Jain <[email protected]>[...]
Quoted 8 lines
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_soc.c line 336
Quoted 3 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +3
-0+ +int +rte_eal_soc_scan (void )What about naming it
rte_eal_soc_scan_default? This would underline the fact that this function can be replaced.Yes, that would be in sync with match default. I will do it.
In v5 I have replaced the name with rte_eal_soc_platform_bus(). This is long but it does exactly what the name states - scan for platform bus. This is still a helper.
Quoted 19 lines
Quoted 19 lines
Second, this is for the 7/17 patch:
(quoted diff) +6
-1-/* register a driver */ void rte_eal_soc_register(struct rte_soc_driver *driver) { + /* For a valid soc driver, match and scan function + * should be provided. + */ + RTE_VERIFY(driver != NULL); + RTE_VERIFY(driver->match_fn != NULL); + RTE_VERIFY(driver->scan_fn != NULL);What about setting the
match_fnandscan_fnto default implementations if they
are NULL? This would make the standard/default approach easier to use.
Quoted 5 lines
Quoted 2 lines
TAILQ_INSERT_TAIL(&soc_driver_list, driver, next);
}I am not in favor of a forced default. What if user never intended it - it would lead to wrong scan being used and only intimation which can provided to user is a log. Selecting such functions should be a model of PMD - one which is enforced.
As mentioned before, I am not in favor of a 'default' implementation. Thus, I would rather call these functions as 'helpers' rather than defaults.
[...]
-
Shreyansh
Re: [PATCH v4 11/17] eal/soc: add default scan for Soc devices
Quoted 5 lines · On Mon, 24 Oct 2016 17:38:29 +0530 Shreyansh Jain <[email protected]>…
Hi Jan,
Quoted 2 lines · Shreyansh Jain
Hi Jan,
[...]
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_soc.c line 336
Quoted 4 lines
lib/librte_eal/linuxapp/eal/eal_soc.c +3
-0+ +int +rte_eal_soc_scan (void )What about naming it
rte_eal_soc_scan_default? This would underline the fact that this function can be replaced.
Quoted 5 lines
Quoted 1 line
Yes, that would be in sync with match default. I will do it.
In v5 I have replaced the name with
rte_eal_soc_platform_bus(). This is long but it does exactly what the name states - scan for platform bus. This is still a helper.
OK.
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Second, this is for the 7/17 patch:
(quoted diff) +6
-1-/* register a driver */ void rte_eal_soc_register(struct rte_soc_driver *driver) { + /* For a valid soc driver, match and scan function + * should be provided. + */ + RTE_VERIFY(driver != NULL); + RTE_VERIFY(driver->match_fn != NULL); + RTE_VERIFY(driver->scan_fn != NULL);What about setting the
match_fnandscan_fnto default implementations if they
are NULL? This would make the standard/default approach easier to use.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
TAILQ_INSERT_TAIL(&soc_driver_list, driver, next);
}I am not in favor of a forced default. What if user never intended it - it would lead to wrong scan being used and only intimation which can provided to user is a log. Selecting such functions should be a model of PMD - one which is enforced.
As mentioned before, I am not in favor of a 'default' implementation. Thus, I would rather call these functions as 'helpers' rather than defaults.
Hmm, OK.
Jan
Quoted 5 lines
[...]
-
Shreyansh
Signature · 4 lines
Jan Viktorin E-mail: [email protected] System Architect Web: www.RehiveTech.com RehiveTech Brno, Czech Republic
PATCH v4 12/17 eal/soc: additional features for SoC
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Additional features introduced:
- Find kernel driver through sysfs bindings
- Dummy implementation for mapping to kernel driver
- DMA coherency value from sysfs
- Numa node number from sysfs
- Support for updating device during probe if already registered
--- lib/librte_eal/common/eal_common_soc.c | 30 ++++++++ lib/librte_eal/common/eal_private.h | 23 ++++++ lib/librte_eal/common/include/rte_soc.h | 28 +++++++ lib/librte_eal/linuxapp/eal/eal_soc.c | 129 ++++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+)
lib/librte_eal/common/eal_common_soc.c +30 -0
@@ -114,6 +114,26 @@ rte_eal_soc_probe_one_driver(struct rte_soc_driver *drv,return ret; } +if (!dev->is_dma_coherent) { +if (!(drv->drv_flags &RTE_SOC_DRV_ACCEPT_NONCC )) { +RTE_LOG (DEBUG ,EAL , +" device is not DMA coherent, skipping\n" ); +return 1 ; + } + } + +if (drv->drv_flags &RTE_SOC_DRV_NEED_MAPPING ) { +/* map resources */ + ret =rte_eal_soc_map_device (dev); +if (ret) +return ret; + }else if (drv->drv_flags &RTE_SOC_DRV_FORCE_UNBIND + &&rte_eal_process_type () ==RTE_PROC_PRIMARY ) { +/* unbind */ +if (soc_unbind_kernel_driver (dev) <0 ) +return -1 ; + } + dev->driver = drv;RTE_VERIFY (drv->probe !=NULL );return drv->probe (drv, dev);
@@ -166,6 +186,10 @@ rte_eal_soc_detach_dev(struct rte_soc_driver *drv,if (drv->remove && (drv->remove (dev) <0 ))return -1 ;/* negative value is an error */ +if (drv->drv_flags &RTE_SOC_DRV_NEED_MAPPING ) +/* unmap resources for devices */ +rte_eal_soc_unmap_device (dev); +/* clear driver structure */ dev->driver =NULL ;
@@ -241,6 +265,12 @@ rte_eal_soc_probe_one(const struct rte_soc_addr *addr)if (addr ==NULL )return -1 ; +/* update current SoC device in global list, kernel bindings might have +* changed since last time we looked at it. +*/ +if (soc_update_device (addr) <0 ) + goto err_return; + TAILQ_FOREACH(dev, &soc_device_list, next) {if (rte_eal_compare_soc_addr (&dev->addr, addr))continue ;
lib/librte_eal/common/eal_private.h +23 -0
@@ -159,6 +159,29 @@ int pci_update_device(const struct rte_pci_addr *addr);int pci_unbind_kernel_driver (struct rte_pci_device *dev);/** +* Update a soc device object by asking the kernel for the latest information. +* +* This function is private to EAL. +* +* @param addr +* The SoC address to look for +* @return +* - 0 on success. +* - negative on error. +*/ +int soc_update_device (const struct rte_soc_addr *addr); + +/** +* Unbind kernel driver for this device +* +* This function is private to EAL. +* +* @return +* 0 on success, negative on error +*/ +int soc_unbind_kernel_driver (struct rte_soc_device *dev); + +/** * Map the PCI resource of a PCI device in virtual memory * * This function is private to EAL.
lib/librte_eal/common/include/rte_soc.h +28 -0
@@ -46,9 +46,11 @@ extern "C" {#include <stdio.h> #include <stdlib.h> +#include <sys/queue.h> #include <stdint.h> #include <inttypes.h> #include <string.h> +#include <limits.h> #include <rte_dev.h> #include <rte_eal.h>
@@ -63,6 +65,14 @@ extern struct soc_device_list soc_device_list;TAILQ_HEAD (soc_driver_list, rte_soc_driver);/**< SoC drivers in D-linked Q. */ TAILQ_HEAD (soc_device_list, rte_soc_device);/**< SoC devices in D-linked Q. */ +#define SOC_MAX_RESOURCE 6 + +struct rte_soc_resource { +uint64_t phys_addr; +uint64_t len; +void *addr; +}; +struct rte_soc_id {union {const char *compatible;/**< OF compatible specification */
@@ -84,8 +94,12 @@ struct rte_soc_device {struct rte_device device;/**< Inherit code device */ struct rte_soc_addr addr;/**< SoC device Location */ struct rte_soc_id *id;/**< SoC device ID list */ +struct rte_soc_resource mem_resource[SOC_MAX_RESOURCE ];struct rte_intr_handle intr_handle;/**< Interrupt handle */ struct rte_soc_driver *driver;/**< Associated driver */ +int numa_node;/**< NUMA node connection */ +int is_dma_coherent;/**< DMA coherent device */ +enum rte_kernel_driver kdrv;/**< Kernel driver */ };struct rte_soc_driver ;
@@ -139,6 +153,8 @@ struct rte_soc_driver {#define RTE_SOC_DRV_INTR_LSC 0x0008/** Device driver supports detaching capability */ #define RTE_SOC_DRV_DETACHABLE 0x0010 +/** Device driver accepts DMA non-coherent devices */ +#define RTE_SOC_DRV_ACCEPT_NONCC 0x0020/** * Utility function to write a SoC device name, this device name can later be
@@ -252,6 +268,18 @@ int rte_eal_soc_probe_one(const struct rte_soc_addr *addr);int rte_eal_soc_detach (const struct rte_soc_addr *addr);/** +* Map SoC device resources into userspace. +* +* This is called by the EAL if (drv_flags & RTE_SOC_DRV_NEED_MAPPING). +*/ +int rte_eal_soc_map_device (struct rte_soc_device *dev); + +/** +* Unmap the device resources. +*/ +void rte_eal_soc_unmap_device (struct rte_soc_device *dev); + +/** * Dump discovered SoC devices. * * @param f
lib/librte_eal/linuxapp/eal/eal_soc.c +129 -0
159 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 13/17 ether: utilize container_of for pci_drv
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
It is not necessary to place the rte_pci_driver at the beginning of the rte_eth_dev struct anymore as we use the container_of macro to get the parent pointer.
--- lib/librte_ether/rte_ethdev.c | 4 ++-- lib/librte_ether/rte_ethdev.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/librte_ether/rte_ethdev.c +2 -2
@@ -241,7 +241,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,int diag; - eth_drv = (struct eth_driver *)pci_drv; + eth_drv = container_of(pci_drv, struct eth_driver, pci_drv);rte_eal_pci_device_name (&pci_dev->addr, ethdev_name,sizeof (ethdev_name));
@@ -302,7 +302,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)if (eth_dev ==NULL )return -ENODEV ; - eth_drv = (const struct eth_driver *)pci_dev->driver; + eth_drv = container_of(pci_dev->driver, struct eth_driver, pci_drv);/* Invoke PMD device uninit function */ if (*eth_drv->eth_dev_uninit) {
lib/librte_ether/rte_ethdev.h +1 -1
@@ -1850,7 +1850,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev);* Each Ethernet driver acts as a PCI driver and is represented by a generic * *eth_driver* structure that holds: * -* - An *rte_pci_driver* structure (which must be the first field). +* - An *rte_pci_driver* structure. * * - The *eth_dev_init* function invoked for each matching PCI device. *
Signature · 1 line
2.7.4
PATCH v4 14/17 ether: verify we copy info from a PCI device
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Now that different types of ethdev exist, check for presence of PCI dev while copying out the info.
Similar would be done for SoC.
--- lib/librte_ether/rte_ethdev.c | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_ether/rte_ethdev.c +2 -0
@@ -3205,6 +3205,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dereturn ; } +RTE_VERIFY (eth_dev->pci_dev !=NULL ); + eth_dev->data->dev_flags =0 ;if (pci_dev->driver->drv_flags &RTE_PCI_DRV_INTR_LSC ) eth_dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC ;
Signature · 1 line
2.7.4
PATCH v4 15/17 ether: extract function eth_dev_get_intr_handle
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
We abstract access to the intr_handle here as we want to get it either from the pci_dev or soc_dev.
--- lib/librte_ether/rte_ethdev.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +12 -2
@@ -2531,6 +2531,16 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,rte_spinlock_unlock (&rte_eth_dev_cb_lock); } +static inline +struct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) +{ +if (dev->pci_dev) +return &dev->pci_dev->intr_handle; + +RTE_ASSERT (0 ); +return NULL ; +} +int rte_eth_dev_rx_intr_ctl (uint8_t port_id,int epfd,int op,void *data) {
@@ -2543,7 +2553,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - intr_handle = &dev->pci_dev->intr_handle; + intr_handle =eth_dev_get_intr_handle (dev);if (!intr_handle->intr_vec) {RTE_PMD_DEBUG_TRACE ("RX Intr vector unset\n" );return -EPERM ;
@@ -2603,7 +2613,7 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,return -EINVAL ; } - intr_handle = &dev->pci_dev->intr_handle; + intr_handle =eth_dev_get_intr_handle (dev);if (!intr_handle->intr_vec) {RTE_PMD_DEBUG_TRACE ("RX Intr vector unset\n" );return -EPERM ;
Signature · 1 line
2.7.4
PATCH v4 16/17 ether: introduce ethernet dev probe remove
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_ether/rte_ethdev.c | 148 +++++++++++++++++++++++++++++++++++++++++- lib/librte_ether/rte_ethdev.h | 31 +++++++++ 2 files changed, 177 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +146 -2
@@ -325,6 +325,101 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev) }int +rte_eth_dev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev) +{ +struct eth_driver *eth_drv; +struct rte_eth_dev *eth_dev; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; + +int diag; + + eth_drv = container_of(soc_drv, struct eth_driver, soc_drv); + +rte_eal_soc_device_name (&soc_dev->addr, ethdev_name, +sizeof (ethdev_name)); + + eth_dev =rte_eth_dev_allocate (ethdev_name); +if (eth_dev ==NULL ) +return -ENOMEM ; + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { + eth_dev->data->dev_private =rte_zmalloc ( +"ethdev private structure" , + eth_drv->dev_private_size, +RTE_CACHE_LINE_SIZE ); +if (eth_dev->data->dev_private ==NULL ) +rte_panic ("Cannot allocate memzone for private port " +"data\n" ); + } + eth_dev->soc_dev = soc_dev; + eth_dev->driver = eth_drv; + eth_dev->data->rx_mbuf_alloc_failed =0 ; + +/* init user callbacks */ +TAILQ_INIT (&(eth_dev->link_intr_cbs)); + +/* +* Set the default MTU. +*/ + eth_dev->data->mtu =ETHER_MTU ; + +/* Invoke PMD device initialization function */ + diag = (*eth_drv->eth_dev_init)(eth_dev); +if (diag ==0 ) +return 0 ; + +RTE_PMD_DEBUG_TRACE ("driver %s: eth_dev_init(%s) failed\n" , + soc_drv->driver.name, + soc_dev->addr.name); +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (eth_dev->data->dev_private); +rte_eth_dev_release_port (eth_dev); +return diag; +} + +int +rte_eth_dev_soc_remove (struct rte_soc_device *soc_dev) +{ +const struct eth_driver *eth_drv; +struct rte_eth_dev *eth_dev; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +int ret; + +if (soc_dev ==NULL ) +return -EINVAL ; + +rte_eal_soc_device_name (&soc_dev->addr, ethdev_name, +sizeof (ethdev_name)); + + eth_dev =rte_eth_dev_allocated (ethdev_name); +if (eth_dev ==NULL ) +return -ENODEV ; + + eth_drv = container_of(soc_dev->driver, struct eth_driver, soc_drv); + +/* Invoke PMD device uninit function */ +if (*eth_drv->eth_dev_uninit) { + ret = (*eth_drv->eth_dev_uninit)(eth_dev); +if (ret) +return ret; + } + +/* free ether device */ +rte_eth_dev_release_port (eth_dev); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (eth_dev->data->dev_private); + + eth_dev->soc_dev =NULL ; + eth_dev->driver =NULL ; + eth_dev->data =NULL ; + +return 0 ; +} + + +int rte_eth_dev_is_valid_port (uint8_t port_id) { if (port_id >= RTE_MAX_ETHPORTS ||
@@ -1557,6 +1652,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)RTE_FUNC_PTR_OR_RET (*dev->dev_ops->dev_infos_get); (*dev->dev_ops->dev_infos_get)(dev, dev_info); dev_info->pci_dev = dev->pci_dev; + dev_info->soc_dev = dev->soc_dev; dev_info->driver_name = dev->data->drv_name; dev_info->nb_rx_queues = dev->data->nb_rx_queues; dev_info->nb_tx_queues = dev->data->nb_tx_queues;
@@ -2534,8 +2630,15 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,static inline struct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) { -if (dev->pci_dev) +if (dev->pci_dev) { +RTE_ASSERT (dev->soc_dev ==NULL );return &dev->pci_dev->intr_handle; + } + +if (dev->soc_dev) { +RTE_ASSERT (dev->pci_dev ==NULL ); +return &dev->soc_dev->intr_handle; + }RTE_ASSERT (0 );return NULL ;
@@ -2572,6 +2675,23 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)return 0 ; } +static inline +const char *eth_dev_get_driver_name (const struct rte_eth_dev *dev) +{ +if (dev->pci_dev) { +RTE_ASSERT (dev->soc_dev ==NULL ); +return dev->driver->pci_drv.driver.name; + } + +if (dev->soc_dev) { +RTE_ASSERT (dev->pci_dev ==NULL ); +return dev->driver->soc_drv.driver.name; + } + +RTE_ASSERT (0 ); +return NULL ; +} +const struct rte_memzone * rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, size_t size, unsigned align,
@@ -2579,9 +2699,11 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, {char z_name[RTE_MEMZONE_NAMESIZE ];const struct rte_memzone *mz; +const char *drv_name; + drv_name =eth_dev_get_driver_name (dev);snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->driver->pci_drv.driver.name, ring_name, + drv_name, ring_name, dev->data->port_id, queue_id); mz =rte_memzone_lookup (z_name);
@@ -3228,6 +3350,28 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de eth_dev->data->drv_name = pci_dev->driver->driver.name; } +void +rte_eth_copy_soc_info (struct rte_eth_dev *eth_dev, +struct rte_soc_device *soc_dev) +{ +if ((eth_dev ==NULL ) || (soc_dev ==NULL )) { +RTE_PMD_DEBUG_TRACE ("NULL pointer eth_dev=%p soc_dev=%p\n" , + eth_dev, soc_dev); +return ; + } + +RTE_ASSERT (eth_dev->soc_dev !=NULL ); + + eth_dev->data->dev_flags =0 ; +if (soc_dev->driver->drv_flags &RTE_SOC_DRV_INTR_LSC ) + eth_dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC ; +if (soc_dev->driver->drv_flags &RTE_SOC_DRV_DETACHABLE ) + eth_dev->data->dev_flags |=RTE_ETH_DEV_DETACHABLE ; + + eth_dev->data->numa_node = soc_dev->device.numa_node; + eth_dev->data->drv_name = soc_dev->driver->driver.name; +} +int rte_eth_dev_l2_tunnel_eth_type_conf (uint8_t port_id,struct rte_eth_l2_tunnel_conf *l2_tunnel)
lib/librte_ether/rte_ethdev.h +31 -0
@@ -180,6 +180,7 @@ extern "C" {#include <rte_log.h> #include <rte_interrupts.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_dev.h> #include <rte_devargs.h> #include "rte_ether.h"
@@ -877,6 +878,7 @@ struct rte_eth_conf {*/ struct rte_eth_dev_info {struct rte_pci_device *pci_dev;/**< Device PCI information. */ +struct rte_soc_device *soc_dev;/**< Device SoC information. */ const char *driver_name;/**< Device Driver name. */ unsigned int if_index;/**< Index to bound host interface, or 0 if none. Use if_indextoname() to translate into an interface name. */
@@ -1626,6 +1628,7 @@ struct rte_eth_dev {const struct eth_driver *driver;/**< Driver for this device */ const struct eth_dev_ops *dev_ops;/**< Functions exported by PMD */ struct rte_pci_device *pci_dev;/**< PCI info. supplied by probing */ +struct rte_soc_device *soc_dev;/**< SoC info. supplied by probing */ /** User application callbacks for NIC interrupts */ struct rte_eth_dev_cb_list link_intr_cbs;/**
@@ -1860,6 +1863,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev);*/ struct eth_driver {struct rte_pci_driver pci_drv;/**< The PMD is also a PCI driver. */ +struct rte_soc_driver soc_drv;/**< The PMD is also a SoC driver. */ eth_dev_init_t eth_dev_init;/**< Device init function. */ eth_dev_uninit_t eth_dev_uninit;/**< Device uninit function. */ unsigned int dev_private_size;/**< Size of device private data. */
@@ -4262,6 +4266,20 @@ void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev);/** +* Copy SoC device info to the Ethernet device data. +* +* @param eth_dev +* The *eth_dev* pointer is the address of the *rte_eth_dev* structure. +* @param soc_dev +* The *soc_dev* pointer is the address of the *rte_soc_device* structure. +* +* @return +* - 0 on success, negative on error +*/ +void rte_eth_copy_soc_info (struct rte_eth_dev *eth_dev, +struct rte_soc_device *soc_dev); + +/** * Create memzone for HW rings. * malloc can't be used as the physical address is needed. * If the memzone is already created, then this function returns a ptr
@@ -4376,6 +4394,19 @@ int rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,*/ int rte_eth_dev_pci_remove (struct rte_pci_device *pci_dev); +/** +* Wrapper for use by SoC drivers as a .devinit function to attach to a ethdev +* interface. +*/ +int rte_eth_dev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev); + +/** +* Wrapper for use by SoC drivers as a .devuninit function to detach a ethdev +* interface. +*/ +int rte_eth_dev_soc_remove (struct rte_soc_device *soc_dev); + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH v4 17/17 eal/crypto: Support rte_soc_driver/device for cryptodev
In reply to Shreyansh Jain- rte_cryptodev_driver/rte_cryptodev_dev embeds rte_soc_driver/device for linking SoC PMDs to crypto devices.
- Add probe and remove functions linked
--- lib/librte_cryptodev/rte_cryptodev.c | 122 ++++++++++++++++++++++++- lib/librte_cryptodev/rte_cryptodev.h | 3 + lib/librte_cryptodev/rte_cryptodev_pmd.h | 18 +++- lib/librte_cryptodev/rte_cryptodev_version.map | 2 + 4 files changed, 140 insertions(+), 5 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +118 -4
@@ -422,7 +422,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,int retval; - cryptodrv = (struct rte_cryptodev_driver *)pci_drv; + cryptodrv = container_of(pci_drv, struct rte_cryptodev_driver, + pci_drv);if (cryptodrv ==NULL )return -ENODEV ;
@@ -489,7 +490,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)if (cryptodev ==NULL )return -ENODEV ; - cryptodrv = (const struct rte_cryptodev_driver *)pci_dev->driver; + cryptodrv = container_of(pci_dev->driver, struct rte_cryptodev_driver, + pci_drv);if (cryptodrv ==NULL )return -ENODEV ;
@@ -513,6 +515,111 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)return 0 ; } + +int +rte_cryptodev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev) +{ +struct rte_cryptodev_driver *cryptodrv; +struct rte_cryptodev *cryptodev; + +char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN ]; + +int retval; + + cryptodrv = container_of(soc_drv, struct rte_cryptodev_driver, + soc_drv); + +rte_eal_soc_device_name (&soc_dev->addr, cryptodev_name, +sizeof (cryptodev_name)); + + cryptodev =rte_cryptodev_pmd_allocate (cryptodev_name, +rte_socket_id ()); +if (cryptodev ==NULL ) +return -ENOMEM ; + + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { + cryptodev->data->dev_private = +rte_zmalloc_socket ( +"cryptodev private structure" , + cryptodrv->dev_private_size, +RTE_CACHE_LINE_SIZE , +rte_socket_id ()); + +if (cryptodev->data->dev_private ==NULL ) +rte_panic ("Cannot allocate memzone for private " +"device data" ); + } + + cryptodev->soc_dev = soc_dev; + cryptodev->driver = cryptodrv; + +/* init user callbacks */ +TAILQ_INIT (&(cryptodev->link_intr_cbs)); + +/* Invoke PMD device initialization function */ + retval = (*cryptodrv->cryptodev_init)(cryptodrv, cryptodev); +if (retval ==0 ) +return 0 ; + +CDEV_LOG_ERR ("driver %s: cryptodev_init(%s) failed\n" , + soc_drv->driver.name, + soc_dev->addr.name); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (cryptodev->data->dev_private); + + cryptodev->attached =RTE_CRYPTODEV_DETACHED ; + cryptodev_globals.nb_devs--; + +return -ENXIO ; +} + +int +rte_cryptodev_soc_remove (struct rte_soc_device *soc_dev) +{ +const struct rte_cryptodev_driver *cryptodrv; +struct rte_cryptodev *cryptodev; +char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN ]; +int ret; + +if (soc_dev ==NULL ) +return -EINVAL ; + +rte_eal_soc_device_name (&soc_dev->addr, cryptodev_name, +sizeof (cryptodev_name)); + + cryptodev =rte_cryptodev_pmd_get_named_dev (cryptodev_name); +if (cryptodev ==NULL ) +return -ENODEV ; + + cryptodrv =container_of (soc_dev->driver, + struct rte_cryptodev_driver, soc_drv); +if (cryptodrv ==NULL ) +return -ENODEV ; + +/* Invoke PMD device uninit function */ +if (*cryptodrv->cryptodev_uninit) { + ret = (*cryptodrv->cryptodev_uninit)(cryptodrv, cryptodev); +if (ret) +return ret; + } + +/* free crypto device */ +rte_cryptodev_pmd_release_device (cryptodev); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (cryptodev->data->dev_private); + + cryptodev->pci_dev =NULL ; + cryptodev->soc_dev =NULL ; + cryptodev->driver =NULL ; + cryptodev->data =NULL ; + +return 0 ; +} +uint16_t rte_cryptodev_queue_pair_count (uint8_t dev_id) {
@@ -868,8 +975,15 @@ rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info) (*dev->dev_ops->dev_infos_get)(dev, dev_info); dev_info->pci_dev = dev->pci_dev; -if (dev->driver) - dev_info->driver_name = dev->driver->pci_drv.driver.name; + dev_info->soc_dev = dev->soc_dev; +if (dev->driver) { +if (dev->soc_dev) + dev_info->driver_name + = dev->driver->soc_drv.driver.name; +else + dev_info->driver_name + = dev->driver->pci_drv.driver.name; + } }
lib/librte_cryptodev/rte_cryptodev.h +3 -0
@@ -244,6 +244,7 @@ struct rte_cryptodev_info {const char *driver_name;/**< Driver name. */ enum rte_cryptodev_type dev_type;/**< Device type */ struct rte_pci_device *pci_dev;/**< PCI information. */ +struct rte_soc_device *soc_dev;/**< SoC information. */ uint64_t feature_flags;/**< Feature flags */
@@ -623,6 +624,8 @@ struct rte_cryptodev {/**< Supported features */ struct rte_pci_device *pci_dev;/**< PCI info. supplied by probing */ +struct rte_soc_device *soc_dev; +/**< SoC info. supplied by probing/Scanning */ enum rte_cryptodev_type dev_type;/**< Crypto device type */
lib/librte_cryptodev/rte_cryptodev_pmd.h +17 -1
@@ -48,6 +48,7 @@ extern "C" {#include <rte_dev.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_malloc.h> #include <rte_mbuf.h> #include <rte_mempool.h>
@@ -131,7 +132,8 @@ typedef int (*cryptodev_uninit_t)(const struct rte_cryptodev_driver *drv,* - The size of the private data to allocate for each matching device. */ struct rte_cryptodev_driver { -struct rte_pci_driver pci_drv;/**< The PMD is also a PCI driver. */ +struct rte_pci_driver pci_drv;/**< The PMD is PCI type driver. */ +struct rte_soc_driver soc_drv;/**< The PMD is SoC type driver. */ unsigned dev_private_size;/**< Size of device private data. */ cryptodev_init_t cryptodev_init;/**< Device init function. */
@@ -519,6 +521,20 @@ int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,*/ int rte_cryptodev_pci_remove (struct rte_pci_device *pci_dev); +/** +* Wrapper for use by SoC drivers as a .devinit function to attach to a +* cryptodev interface. +*/ +int rte_cryptodev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev); + +/** +* Wrapper for use by SoC drivers as a .devuninit function to detach a +* cryptodev interface. +*/ +int rte_cryptodev_soc_remove (struct rte_soc_device *soc_dev); + + #ifdef __cplusplus }#endif
lib/librte_cryptodev/rte_cryptodev_version.map +2 -0
@@ -44,5 +44,7 @@ DPDK_16.11 { rte_cryptodev_pci_probe; rte_cryptodev_pci_remove; + rte_cryptodev_soc_probe; + rte_cryptodev_soc_remove; } DPDK_16.07;
Signature · 1 line
2.7.4
Re: [PATCH v4 00/17] Introduce SoC device/driver framework for EAL
In reply to Shreyansh JainOn Saturday 15 October 2016 07:14 PM, Shreyansh Jain wrote:
[...]
Quoted 14 lines
4) Design considerations that are same as PCI:
- SoC initialization is being done throughrte_eal_init(), just after PCI initialization is done.
- As in case of PCI, probe is done afterrte_eal_pci_probe()to link the devices detected with the drivers registered.
- Device attach/detach functions are available and have been designed on the lines of PCI framework.
- PMDs register usingDRIVER_REGISTER_SOC, very similar toDRIVER_REGISTER_PCIfor PCI devices.
- Linked list of SoC driver and devices exists independent of the other driver/device list, but inheriting rte_driver/rte_driver, these are also part of a global list.
[...]
Two points which I missed in the Cover letter:
1. DRIVER_REGISTER_* has been replaced with RTE_PMD_REGISTER_*.
2. This is an experimental series. Verification of this has been done using NXP's PMD (to be published on ML soon) without using default scan/match helpers.
-
Shreyansh
v5 cover Introduce SoC device/driver framework for EAL
In reply to Shreyansh JainIntroduction:
=============
This patch set is direct derivative of Jan's original series [1],[2].
- This version is based on master HEAD (173511).
- In this, I am merging the series [11] back. It was initially part of this set but I had split considering that those changes in PCI were good standalone as well. But, 1) not much feedback was avail- able and 2) this patchset is a use-case for those patches making it easier to review. Just like what Jan had intended in original series.
- Hereafter, this series is not dependent on any other external patch series.
Aim:
====
As of now EAL is primarly focused on PCI initialization/probing.
rte_eal_init()
|- rte_eal_pci_init(): Find PCI devices from sysfs |- ... |- rte_eal_memzone_init() |- ...
`- rte_eal_pci_probe(): Driver<=>Device initialization
This patchset introduces SoC framework which would enable SoC drivers and drivers to be plugged into EAL, very similar to how PCI drivers/devices are done today.
This is a stripped down version of PCI framework which allows the SoC PMDs to implement their own routines for detecting devices and linking devices to drivers.
1) Changes to EAL
rte_eal_init()
|- rte_eal_pci_init(): Find PCI devices from sysfs |- rte_eal_soc_init(): Calls PMDs->scan_fn |- ... |- rte_eal_memzone_init() |- ... |- rte_eal_pci_probe(): Driver<=>Device initialization, PMD->devinit()
`- rte_eal_soc_probe(): Calls PMDs->match_fn and PMDs->devinit();
2) New device/driver structures:
- rte_soc_driver (inheriting rte_driver)
- rte_soc_device (inheriting rte_device)
- rte_eth_dev and eth_driver embedded rte_soc_device and rte_soc_driver, respectively.
3) The SoC PMDs need to:
- define rte_soc_driver with necessary scan and match callbacks
- Register themselves using DRIVER_REGISTER_SOC()
- Implement respective bus scanning in the scan callbacks to add necessary devices to SoC device list
- Implement necessary eth_dev_init/uninint for ethernet instances
4) Design considerations that are same as PCI:
- SoC initialization is being done through rte_eal_init(), just after PCI initialization is done.
- As in case of PCI, probe is done after rte_eal_pci_probe() to link the devices detected with the drivers registered.
- Device attach/detach functions are available and have been designed on the lines of PCI framework.
- PMDs register using DRIVER_REGISTER_SOC, very similar to DRIVER_REGISTER_PCI for PCI devices.
- Linked list of SoC driver and devices exists independent of the other driver/device list, but inheriting rte_driver/rte_driver, these are also part of a global list.
5) Design considerations that are different from PCI:
- Each driver implements its own scan and match function. PCI uses the BDF format to read the device from sysfs, but this _may_not_ be a case for a SoC ethernet device.
= This is an important change from initial proposal by Jan in [2]. Unlike his attempt to use /sys/bus/platform, this patch relies on the PMD to detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have embedded devices/MACs which require initialization which cannot be covered through sysfs parsing.
`-> Point (6) below is a side note to above.
= PCI based PMDs rely on EAL's capability to detect devices. This proposal puts the onus on PMD to detect devices, add to soc_device_list and wait for Probe. Matching, of device<=>driver is again PMD's callback.
6) Adding default scan and match helpers for PMDs
- The design warrrants the PMDs implement their own scan of devices on bus, and match routines for probe implementation.
This patch introduces helpers which can be used by PMDs for scan of the platform bus and matching devices against the compatible string extracted from the scan.
- Intention is to make it easier to integrate known SoC which expose platform bus compliant information (compat, sys/bus/platform...).
- PMDs which have deviations from this standard model can implement and hook their bus scanning and probe match callbacks while registering driver.
Patchset Overview:
==================
- Patches 0001~0004 are from [11] - moving some PCI specific functions and definitions to non-PCI area.
- Patches 0005~0008 introduce the base infrastructure and test case
- Patch 0009 is for command line support for no-soc, on lines of no-pci
- Patch 0010 enables EAL to handle SoC type devices
- Patch 0011 adds support for scan and probe callbacks and updates the test framework with relevant test case.
- Patch 0012~0014 enable device argument, driver specific flags and interrupt handling related basic infra. Subsequent patches build up on them.
- Patch 0015~0016 add support for default function which PMDs can use for scanning platform bus. These functions are optional and need to be hooked to by PMDs.
- Patch 0017~0019 makes changes to PCI as well as ethdev code to remove assumption that eth_driver is a PCI driver.
- Patch 0020 adds necessary ethdev probe/remove functions for PMDs to use
- Patch 0021 adds support for SoC driver/devices, along with probe/remove functions for Cryptodev devices.
Future/Pending Changes:
=======================
- Device whitelisting/blacklist still relies on command line '-b' and '-c' which are internally implemented using OPT_PCI_BLACKLIST/OPT_PCI_WHITELIST. This needs to be changed to a generic form - OPT_DEV_*LIST - probably.
- No cryptodriver currently uses SoC framework - probably a example driver can be created to demonstrate usage.
- test case for enable-soc command line parameter
[1] http://dpdk.org/ml/archives/dev/2016-January/030915.html
[2] http://www.dpdk.org/ml/archives/dev/2016-May/038486.html
[3] http://dpdk.org/ml/archives/dev/2016-August/045707.html
[4] http://dpdk.org/ml/archives/dev/2016-May/038948.html
[5] http://dpdk.org/ml/archives/dev/2016-May/038953.html
[6] http://dpdk.org/ml/archives/dev/2016-May/038487.html
[7] http://dpdk.org/ml/archives/dev/2016-May/038488.html
[8] http://dpdk.org/ml/archives/dev/2016-May/038489.html
[9] http://dpdk.org/ml/archives/dev/2016-May/038491.html
[10] http://dpdk.org/ml/archives/dev/2016-September/046256.html
[11] http://dpdk.org/ml/archives/dev/2016-October/048915.html
Changes since v4:
- change name of rte_eal_soc_scan function name to rte_eal_soc_scan_platform_bus. This still remains a helper function.
- Fix comments over scan and match functions
Changes since v3:
- rebasing over HEAD (fed622df tag: v16.11-rc1)
- Add support for default scan function; PMD can use this for scanning on platform bus.
- Support for kernel driver bind/unbind, numa and DMA from Jan's original patches.
- SoC is disabled by default. '--enable-soc' command line parameter enables it. doc updated.
- Updated testcase function names and comments
- Map file addition alphabetically ordered
- Patch author corrected
Changes since v2:
- Rebasing over rte_driver/device patchset v9 [10]
- Added cryptodev support for SoC
- Default match function for SoC device<=>Driver
- Some variables renamed to reflect 'drv' rather than 'dr'
Change since v1 [2]:
- Removed patch 1-5 which were for generalizing some PCI specific routines into EAL. These patches are good-to-have but not directly linked to SoC and hence would be proposed separately.
- Removed support for sysfs parsing (patches 6~9)
- Rebasing over the recent (v8) version of rte_driver/device patchset
- Rebasing over master (16.07)
- Changes to various map file to change API intro to 16.11 from 16.07
Jan Viktorin (19):
eal: generalize PCI kernel driver enum to EAL
eal: generalize PCI map/unmap resource to EAL eal/linux: generalize PCI kernel unbinding driver to EAL eal/linux: generalize PCI kernel driver extraction to EAL
eal: define container macro
eal/soc: introduce very essential SoC infra definitions eal/soc: add SoC PMD register/unregister logic eal/soc: implement SoC device list and dump
eal: introduce command line enable SoC option eal/soc: init SoC infra from EAL
eal/soc: extend and utilize devargs
eal/soc: add drv_flags
eal/soc: add intr_handle
eal/soc: add default scan for Soc devices eal/soc: additional features for SoC
ether: utilize container_of for pci_drv
ether: verify we copy info from a PCI device
ether: extract function eth_dev_get_intr_handle
ether: introduce ethernet dev probe remove
Shreyansh Jain (2):
eal/soc: implement probing of drivers eal/crypto: Support rte_soc_driver/device for cryptodev
app/test/Makefile | 1 + app/test/test_soc.c | 404 +++++++++++++++++++ doc/guides/testpmd_app_ug/run_app.rst | 4 + lib/librte_cryptodev/rte_cryptodev.c | 122 +++++- lib/librte_cryptodev/rte_cryptodev.h | 3 + lib/librte_cryptodev/rte_cryptodev_pmd.h | 18 +- lib/librte_cryptodev/rte_cryptodev_version.map | 2 + lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/eal.c | 18 + lib/librte_eal/bsdapp/eal/eal_pci.c | 6 +- lib/librte_eal/bsdapp/eal/eal_soc.c | 46 +++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 11 + lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_dev.c | 66 ++- lib/librte_eal/common/eal_common_devargs.c | 17 + lib/librte_eal/common/eal_common_options.c | 5 + lib/librte_eal/common/eal_common_pci.c | 39 -- lib/librte_eal/common/eal_common_pci_uio.c | 16 +- lib/librte_eal/common/eal_common_soc.c | 368 +++++++++++++++++ lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/common/eal_options.h | 2 + lib/librte_eal/common/eal_private.h | 64 +++ lib/librte_eal/common/include/rte_common.h | 18 + lib/librte_eal/common/include/rte_dev.h | 44 ++ lib/librte_eal/common/include/rte_devargs.h | 8 + lib/librte_eal/common/include/rte_pci.h | 41 -- lib/librte_eal/common/include/rte_soc.h | 322 +++++++++++++++ lib/librte_eal/linuxapp/eal/Makefile | 2 + lib/librte_eal/linuxapp/eal/eal.c | 63 +++ lib/librte_eal/linuxapp/eal/eal_pci.c | 62 +-- lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 5 +- lib/librte_eal/linuxapp/eal/eal_soc.c | 515 ++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 11 + lib/librte_ether/rte_ethdev.c | 166 +++++++- lib/librte_ether/rte_ethdev.h | 33 +- 36 files changed, 2343 insertions(+), 165 deletions(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/bsdapp/eal/eal_soc.c create mode 100644 lib/librte_eal/common/eal_common_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.h create mode 100644 lib/librte_eal/linuxapp/eal/eal_soc.c
Signature · 1 line
2.7.4
PATCH v5 1/21 eal: generalize PCI kernel driver enum to EAL
From: Jan Viktorin <[email protected]>
--
Changes since v0:
- fix compilation error due to missing include
--- lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++ lib/librte_eal/common/include/rte_pci.h | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
@@ -109,6 +109,18 @@ struct rte_mem_resource {void *addr;/**< Virtual address, NULL when not mapped. */ }; +/** +* Kernel driver passthrough type +*/ +enum rte_kernel_driver { +RTE_KDRV_UNKNOWN =0 , +RTE_KDRV_IGB_UIO , +RTE_KDRV_VFIO , +RTE_KDRV_UIO_GENERIC , +RTE_KDRV_NIC_UIO , +RTE_KDRV_NONE , +}; +/** Double linked list of device drivers. */ TAILQ_HEAD (rte_driver_list, rte_driver);/** Double linked list of devices. */
lib/librte_eal/common/include/rte_pci.h +0 -9
@@ -135,15 +135,6 @@ struct rte_pci_addr {struct rte_devargs ; -enum rte_kernel_driver { -RTE_KDRV_UNKNOWN =0 , -RTE_KDRV_IGB_UIO , -RTE_KDRV_VFIO , -RTE_KDRV_UIO_GENERIC , -RTE_KDRV_NIC_UIO , -RTE_KDRV_NONE , -}; -/** * A structure describing a PCI device. */
Signature · 1 line
2.7.4
Re: [PATCH v5 01/21] eal: generalize PCI kernel driver enum to EAL
Quoted 4 lines · On Mon, 24 Oct 2016 17:29:20 +0530 Shreyansh Jain <[email protected]>…
From: Jan Viktorin <[email protected]>
Signed-off-by Jan Viktorin <[email protected]>Signed-off-by Shreyansh Jain <[email protected]>
I think, there is no reason to prevent merging this. Feel free to add:
PATCH v5 2/21 eal: generalize PCI map/unmap resource to EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
The functions pci_map_resource, pci_unmap_resource are generic so the pci_* prefix can be omitted. The functions are moved to the eal_common_dev.c so they can be reused by other infrastructure.
--- lib/librte_eal/bsdapp/eal/eal_pci.c | 2 +- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++ lib/librte_eal/common/eal_common_dev.c | 39 +++++++++++++++++++++++++ lib/librte_eal/common/eal_common_pci.c | 39 ------------------------- lib/librte_eal/common/eal_common_pci_uio.c | 16 +++++----- lib/librte_eal/common/include/rte_dev.h | 32 ++++++++++++++++++++ lib/librte_eal/common/include/rte_pci.h | 32 -------------------- lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 5 ++-- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++ 10 files changed, 89 insertions(+), 82 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +1 -1
@@ -228,7 +228,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,/* if matching map is found, then use it */ offset = res_idx * pagesz; - mapaddr =pci_map_resource (NULL , fd, (off_t )offset, + mapaddr =rte_eal_map_resource (NULL , fd, (off_t )offset, (size_t )dev->mem_resource[res_idx].len,0 );close (fd);if (mapaddr ==MAP_FAILED )
lib/librte_eal/bsdapp/eal/rte_eal_version.map +2 -0
@@ -170,6 +170,8 @@ DPDK_16.11 { rte_delay_us_callback_register; rte_eal_dev_attach; rte_eal_dev_detach; + rte_eal_map_resource; + rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister;
lib/librte_eal/common/eal_common_dev.c +39 -0
@@ -36,6 +36,7 @@#include <string.h> #include <inttypes.h> #include <sys/queue.h> +#include <sys/mman.h> #include <rte_dev.h> #include <rte_devargs.h>
@@ -151,3 +152,41 @@ err:RTE_LOG (ERR ,EAL ,"Driver cannot detach the device (%s)\n" , name);return -EINVAL ; } + +/* map a particular resource from a file */ +void * +rte_eal_map_resource (void *requested_addr,int fd,off_t offset,size_t size, +int additional_flags) +{ +void *mapaddr; + +/* Map the Memory resource of device */ + mapaddr =mmap (requested_addr, size,PROT_READ |PROT_WRITE , +MAP_SHARED | additional_flags, fd, offset); +if (mapaddr ==MAP_FAILED ) { +RTE_LOG (ERR ,EAL ,"%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s" +" (%p)\n" , __func__, fd, requested_addr, + (unsigned long )size, (unsigned long )offset, +strerror (errno), mapaddr); + }else +RTE_LOG (DEBUG ,EAL ," Device memory mapped at %p\n" , mapaddr); + +return mapaddr; +} + +/* unmap a particular resource */ +void +rte_eal_unmap_resource (void *requested_addr,size_t size) +{ +if (requested_addr ==NULL ) +return ; + +/* Unmap the Memory resource of device */ +if (munmap (requested_addr, size)) { +RTE_LOG (ERR ,EAL ,"%s(): cannot munmap(%p, 0x%lx): %s\n" , + __func__, requested_addr, (unsigned long )size, +strerror (errno)); + }else +RTE_LOG (DEBUG ,EAL ," Device memory unmapped at %p\n" , + requested_addr); +}
lib/librte_eal/common/eal_common_pci.c +0 -39
@@ -67,7 +67,6 @@#include <stdlib.h> #include <stdio.h> #include <sys/queue.h> -#include <sys/mman.h> #include <rte_interrupts.h> #include <rte_log.h>
@@ -114,44 +113,6 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)return NULL ; } -/* map a particular resource from a file */ -void * -pci_map_resource (void *requested_addr,int fd,off_t offset,size_t size, -int additional_flags) -{ -void *mapaddr; - -/* Map the PCI memory resource of device */ - mapaddr =mmap (requested_addr, size,PROT_READ |PROT_WRITE , -MAP_SHARED | additional_flags, fd, offset); -if (mapaddr ==MAP_FAILED ) { -RTE_LOG (ERR ,EAL ,"%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\n" , - __func__, fd, requested_addr, - (unsigned long )size, (unsigned long )offset, -strerror (errno), mapaddr); - }else -RTE_LOG (DEBUG ,EAL ," PCI memory mapped at %p\n" , mapaddr); - -return mapaddr; -} - -/* unmap a particular resource */ -void -pci_unmap_resource (void *requested_addr,size_t size) -{ -if (requested_addr ==NULL ) -return ; - -/* Unmap the PCI memory resource of device */ -if (munmap (requested_addr, size)) { -RTE_LOG (ERR ,EAL ,"%s(): cannot munmap(%p, 0x%lx): %s\n" , - __func__, requested_addr, (unsigned long )size, -strerror (errno)); - }else -RTE_LOG (DEBUG ,EAL ," PCI memory unmapped at %p\n" , - requested_addr); -} -/* * If vendor/device ID match, call the probe() function of the * driver.
lib/librte_eal/common/eal_common_pci_uio.c +9 -7
@@ -75,9 +75,11 @@ pci_uio_map_secondary(struct rte_pci_device *dev)return -1 ; } -void *mapaddr =pci_map_resource (uio_res->maps[i].addr, - fd, (off_t )uio_res->maps[i].offset, - (size_t )uio_res->maps[i].size,0 ); +void *mapaddr =rte_eal_map_resource ( + uio_res->maps[i].addr, fd, + (off_t )uio_res->maps[i].offset, + (size_t )uio_res->maps[i].size, +0 );/* fd is not needed in slave process, close it */ close (fd);if (mapaddr != uio_res->maps[i].addr) {
@@ -88,11 +90,11 @@ pci_uio_map_secondary(struct rte_pci_device *dev)if (mapaddr !=MAP_FAILED ) {/* unmap addrs correctly mapped */ for (j =0 ; j < i; j++) -pci_unmap_resource ( +rte_eal_unmap_resource ( uio_res->maps[j].addr, (size_t )uio_res->maps[j].size);/* unmap addr wrongly mapped */ -pci_unmap_resource (mapaddr, +rte_eal_unmap_resource (mapaddr, (size_t )uio_res->maps[i].size); }return -1 ;
@@ -150,7 +152,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)return 0 ; error:for (i =0 ; i < map_idx; i++) { -pci_unmap_resource (uio_res->maps[i].addr, +rte_eal_unmap_resource (uio_res->maps[i].addr, (size_t )uio_res->maps[i].size);rte_free (uio_res->maps[i].path); }
@@ -167,7 +169,7 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res)return ;for (i =0 ; i != uio_res->nb_maps; i++) { -pci_unmap_resource (uio_res->maps[i].addr, +rte_eal_unmap_resource (uio_res->maps[i].addr, (size_t )uio_res->maps[i].size);if (rte_eal_process_type () ==RTE_PROC_PRIMARY )rte_free (uio_res->maps[i].path);
lib/librte_eal/common/include/rte_dev.h +32 -0
@@ -234,6 +234,38 @@ int rte_eal_dev_attach(const char *name, const char *devargs);*/ int rte_eal_dev_detach (const char *name); +/* +* @internal +* Map a particular resource from a file. +* +* @param requested_addr +* The starting address for the new mapping range. +* @param fd +* The file descriptor. +* @param offset +* The offset for the mapping range. +* @param size +* The size for the mapping range. +* @param additional_flags +* The additional flags for the mapping range. +* @return +* - On success, the function returns a pointer to the mapped area. +* - On error, the value MAP_FAILED is returned. +*/ +void *rte_eal_map_resource (void *requested_addr,int fd,off_t offset, +size_t size,int additional_flags); + +/** +* @internal +* Unmap a particular resource. +* +* @param requested_addr +* The address for the unmapping range. +* @param size +* The size for the unmapping range. +*/ +void rte_eal_unmap_resource (void *requested_addr,size_t size); +#define RTE_PMD_EXPORT_NAME_ARRAY (n, idx) n##idx[]#define RTE_PMD_EXPORT_NAME (name, idx) \
lib/librte_eal/common/include/rte_pci.h +0 -32
@@ -399,38 +399,6 @@ int rte_eal_pci_map_device(struct rte_pci_device *dev);void rte_eal_pci_unmap_device (struct rte_pci_device *dev);/** -* @internal -* Map a particular resource from a file. -* -* @param requested_addr -* The starting address for the new mapping range. -* @param fd -* The file descriptor. -* @param offset -* The offset for the mapping range. -* @param size -* The size for the mapping range. -* @param additional_flags -* The additional flags for the mapping range. -* @return -* - On success, the function returns a pointer to the mapped area. -* - On error, the value MAP_FAILED is returned. -*/ -void *pci_map_resource (void *requested_addr,int fd,off_t offset, -size_t size,int additional_flags); - -/** -* @internal -* Unmap a particular resource. -* -* @param requested_addr -* The address for the unmapping range. -* @param size -* The size for the unmapping range. -*/ -void pci_unmap_resource (void *requested_addr,size_t size); - -/** * Probe the single PCI device. * * Scan the content of the PCI bus, and find the pci device specified by pci
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +1 -1
@@ -347,7 +347,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,if (pci_map_addr ==NULL ) pci_map_addr =pci_find_max_end_va (); - mapaddr =pci_map_resource (pci_map_addr, fd,0 , + mapaddr =rte_eal_map_resource (pci_map_addr, fd,0 , (size_t )dev->mem_resource[res_idx].len,0 );close (fd);if (mapaddr ==MAP_FAILED )
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +3 -2
@@ -465,7 +465,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev)void *map_addr =NULL ;if (memreg[0 ].size) {/* actual map of first part */ - map_addr =pci_map_resource (bar_addr, vfio_dev_fd, + map_addr =rte_eal_map_resource (bar_addr, + vfio_dev_fd, memreg[0 ].offset, memreg[0 ].size,MAP_FIXED );
@@ -477,7 +478,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)void *second_addr =RTE_PTR_ADD (bar_addr, memreg[1 ].offset - (uintptr_t )reg.offset); - map_addr =pci_map_resource (second_addr, + map_addr =rte_eal_map_resource (second_addr, vfio_dev_fd, memreg[1 ].offset, memreg[1 ].size,MAP_FIXED );
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
@@ -174,6 +174,8 @@ DPDK_16.11 { rte_delay_us_callback_register; rte_eal_dev_attach; rte_eal_dev_detach; + rte_eal_map_resource; + rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister;
Signature · 1 line
2.7.4
PATCH v5 3/21 eal/linux: generalize PCI kernel unbinding driver to EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Generalize the PCI-specific pci_unbind_kernel_driver. It is now divided into two parts. First, determination of the path and string identification of the device to be unbound. Second, the actual unbind operation which is generic.
BSD implementation updated as ENOTSUP
--
Changes since v2:
- update BSD support for unbind kernel driver
--- lib/librte_eal/bsdapp/eal/eal.c | 7 +++++++ lib/librte_eal/bsdapp/eal/eal_pci.c | 4 ++-- lib/librte_eal/common/eal_private.h | 13 +++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 26 ++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 33 +++++++++------------------------ 5 files changed, 57 insertions(+), 26 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +7 -0
@@ -633,3 +633,10 @@ rte_eal_process_type(void) {return rte_config.process_type; } + +int +rte_eal_unbind_kernel_driver(const char *devpath __rte_unused, + const char *devid __rte_unused) +{ +return -ENOTSUP ; +}
lib/librte_eal/bsdapp/eal/eal_pci.c +2 -2
@@ -89,11 +89,11 @@/* unbind kernel driver for this device */ int -pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused) +pci_unbind_kernel_driver (struct rte_pci_device *dev) {RTE_LOG (ERR ,EAL ,"RTE_PCI_DRV_FORCE_UNBIND flag is not implemented " "for BSD\n" ); -return -ENOTSUP ; +return rte_eal_unbind_kernel_driver (dev); }/* Map pci device */
lib/librte_eal/common/eal_private.h +13 -0
@@ -256,6 +256,19 @@ int rte_eal_alarm_init(void);int rte_eal_check_module (const char *module_name);/** +* Unbind kernel driver bound to the device specified by the given devpath, +* and its string identification. +* +* @param devpath path to the device directory ("/sys/.../devices/<name>") +* @param devid identification of the device (<name>) +* +* @return +* -1 unbind has failed +* 0 module has been unbound +*/ +int rte_eal_unbind_kernel_driver (const char *devpath,const char *devid); + +/** * Get cpu core_id. * * This function is private to the EAL.
lib/librte_eal/linuxapp/eal/eal.c +26 -0
@@ -943,3 +943,29 @@ rte_eal_check_module(const char *module_name)/* Module has been found */ return 1 ; } + +int +rte_eal_unbind_kernel_driver (const char *devpath,const char *devid) +{ +char filename[PATH_MAX ]; +FILE *f; + +snprintf (filename,sizeof (filename), +"%s/driver/unbind" , devpath); + + f =fopen (filename,"w" ); +if (f ==NULL )/* device was not bound */ +return 0 ; + +if (fwrite (devid,strlen (devid),1 , f) ==0 ) { +RTE_LOG (ERR ,EAL ,"%s(): could not write to %s\n" , __func__, + filename); + goto error; + } + +fclose (f); +return 0 ; +error: +fclose (f); +return -1 ; +}
lib/librte_eal/linuxapp/eal/eal_pci.c +9 -24
@@ -59,38 +59,23 @@ int pci_unbind_kernel_driver(struct rte_pci_device *dev) {int n; -FILE *f; -char filename[PATH_MAX ]; -char buf[BUFSIZ ]; +char devpath[PATH_MAX ]; +char devid[BUFSIZ ];struct rte_pci_addr *loc = &dev->addr; -/* open /sys/bus/pci/devices/AAAA:BB:CC.D/driver */ -snprintf (filename,sizeof (filename), -"%s/" PCI_PRI_FMT "/driver/unbind" ,pci_get_sysfs_path (), +/* devpath /sys/bus/pci/devices/AAAA:BB:CC.D */ +snprintf (devpath,sizeof (devpath), +"%s/" PCI_PRI_FMT ,pci_get_sysfs_path (), loc->domain, loc->bus, loc->devid, loc->function); - f =fopen (filename,"w" ); -if (f ==NULL )/* device was not bound */ -return 0 ; - - n =snprintf (buf,sizeof (buf),PCI_PRI_FMT "\n" , + n =snprintf (devid,sizeof (devid),PCI_PRI_FMT "\n" , loc->domain, loc->bus, loc->devid, loc->function); -if ((n <0 ) || (n >= (int )sizeof (buf))) { +if ((n <0 ) || (n >= (int )sizeof (devid))) {RTE_LOG (ERR ,EAL ,"%s(): snprintf failed\n" , __func__); - goto error; - } -if (fwrite (buf, n,1 , f) ==0 ) { -RTE_LOG (ERR ,EAL ,"%s(): could not write to %s\n" , __func__, - filename); - goto error; +return -1 ; } -fclose (f); -return 0 ; - -error: -fclose (f); -return -1 ; +return rte_eal_unbind_kernel_driver (devpath, devid); } static int
Signature · 1 line
2.7.4
PATCH v5 4/21 eal/linux: generalize PCI kernel driver extraction to EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Generalize the PCI-specific pci_get_kernel_driver_by_path. The function is general enough, we have just moved it to eal.c, changed the prefix to rte_eal and provided it privately to other parts of EAL.
--- lib/librte_eal/bsdapp/eal/eal.c | 7 +++++++ lib/librte_eal/common/eal_private.h | 14 ++++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 29 +++++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 31 +------------------------------ 4 files changed, 51 insertions(+), 30 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +7 -0
@@ -640,3 +640,10 @@ rte_eal_unbind_kernel_driver(const char *devpath __rte_unused, {return -ENOTSUP ; } + +int +rte_eal_get_kernel_driver_by_path(const char *filename __rte_unused, + char *dri_name __rte_unused) +{ +return -ENOTSUP ; +}
lib/librte_eal/common/eal_private.h +14 -0
@@ -269,6 +269,20 @@ int rte_eal_check_module(const char *module_name);int rte_eal_unbind_kernel_driver (const char *devpath,const char *devid);/** +* Extract the kernel driver name from the absolute path to the driver. +* +* @param filename path to the driver ("<path-to-device>/driver") +* @path dri_name target buffer where to place the driver name +* (should be at least PATH_MAX long) +* +* @return +* -1 on failure +* 0 when successful +* 1 when there is no such driver +*/ +int rte_eal_get_kernel_driver_by_path (const char *filename,char *dri_name); + +/** * Get cpu core_id. * * This function is private to the EAL.
lib/librte_eal/linuxapp/eal/eal.c +29 -0
@@ -969,3 +969,32 @@ error:fclose (f);return -1 ; } + +int +rte_eal_get_kernel_driver_by_path (const char *filename,char *dri_name) +{ +int count; +char path[PATH_MAX ]; +char *name; + +if (!filename || !dri_name) +return -1 ; + + count =readlink (filename, path,PATH_MAX ); +if (count >=PATH_MAX ) +return -1 ; + +/* For device does not have a driver */ +if (count <0 ) +return 1 ; + + path[count] ='\0' ; + + name =strrchr (path,'/' ); +if (name) { +strncpy (dri_name, name +1 ,strlen (name +1 ) +1 ); +return 0 ; + } + +return -1 ; +}
lib/librte_eal/linuxapp/eal/eal_pci.c +1 -30
@@ -78,35 +78,6 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev)return rte_eal_unbind_kernel_driver (devpath, devid); } -static int -pci_get_kernel_driver_by_path (const char *filename,char *dri_name) -{ -int count; -char path[PATH_MAX ]; -char *name; - -if (!filename || !dri_name) -return -1 ; - - count =readlink (filename, path,PATH_MAX ); -if (count >=PATH_MAX ) -return -1 ; - -/* For device does not have a driver */ -if (count <0 ) -return 1 ; - - path[count] ='\0' ; - - name =strrchr (path,'/' ); -if (name) { -strncpy (dri_name, name +1 ,strlen (name +1 ) +1 ); -return 0 ; - } - -return -1 ; -} -/* Map pci device */ int rte_eal_pci_map_device (struct rte_pci_device *dev)
@@ -354,7 +325,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,/* parse driver */ snprintf (filename,sizeof (filename),"%s/driver" , dirname); - ret =pci_get_kernel_driver_by_path (filename, driver); + ret =rte_eal_get_kernel_driver_by_path (filename, driver);if (ret <0 ) {RTE_LOG (ERR ,EAL ,"Fail to get kernel driver\n" );free (dev);
Signature · 1 line
2.7.4
PATCH v5 5/21 eal: define container macro
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_eal/common/include/rte_common.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
lib/librte_eal/common/include/rte_common.h +18 -0
@@ -331,6 +331,24 @@ rte_bsf32(uint32_t v)#define offsetof (TYPE ,MEMBER ) __builtin_offsetof (TYPE, MEMBER)#endif +/** +* Return pointer to the wrapping struct instance. +* Example: +* +* struct wrapper { +* ... +* struct child c; +* ... +* }; +* +* struct child *x = obtain(...); +* struct wrapper *w = container_of(x, struct wrapper, c); +*/ +#ifndef container_of +#define container_of (p, type, member) \ + ((type *) (((char *) (p)) - offsetof(type, member))) +#endif +#define _RTE_STR (x) #x/** Take a macro value and get a string version of it */ #define RTE_STR (x) _RTE_STR(x)
Signature · 1 line
2.7.4
PATCH v5 6/21 eal/soc: introduce very essential SoC infra definitions
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Define initial structures and functions for the SoC infrastructure. This patch supports only a very minimal functions for now. More features will be added in the following commits.
Includes rte_device/rte_driver inheritance of
rte_soc_device/rte_soc_driver.
--- app/test/Makefile | 1 + app/test/test_soc.c | 90 +++++++++++++++++++++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_private.h | 4 + lib/librte_eal/common/include/rte_soc.h | 138 ++++++++++++++++++++++++++++++++ 5 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.h
app/test/Makefile +1 -0
@@ -77,6 +77,7 @@ APP = test # SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := commands.c SRCS-y += test.c +SRCS-y += test_soc.c SRCS-y += resource.c SRCS-y += test_resource.c test_resource.res: test_resource.c
app/test/test_soc.c new file +90 -0
90 lines not on this page · raw message
lib/librte_eal/common/Makefile +1 -1
@@ -33,7 +33,7 @@ include $(RTE_SDK)/mk/rte.vars.mk INC := rte_branch_prediction.h rte_common.h INC += rte_debug.h rte_eal.h rte_errno.h rte_launch.h rte_lcore.h -INC += rte_log.h rte_memory.h rte_memzone.h rte_pci.h +INC += rte_log.h rte_memory.h rte_memzone.h rte_soc.h rte_pci.h INC += rte_per_lcore.h rte_random.h INC += rte_tailq.h rte_interrupts.h rte_alarm.h INC += rte_string_fns.h rte_version.h
lib/librte_eal/common/eal_private.h +4 -0
@@ -36,6 +36,7 @@#include <stdio.h> #include <rte_pci.h> +#include <rte_soc.h> /** * Initialize the memzone subsystem (private to eal).
@@ -118,6 +119,9 @@ int rte_eal_log_init(const char *id, int facility);*/ int rte_eal_pci_init (void ); +struct rte_soc_driver ; +struct rte_soc_device ; +struct rte_pci_driver ;struct rte_pci_device ;
lib/librte_eal/common/include/rte_soc.h new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v5 06/21] eal/soc: introduce very essential SoC infra definitions
Quoted 23 lines · On Mon, 24 Oct 2016 17:29:25 +0530 Shreyansh Jain <[email protected]>…
From: Jan Viktorin <[email protected]>
Define initial structures and functions for the SoC infrastructure. This patch supports only a very minimal functions for now. More features will be added in the following commits.
Includes rte_device/rte_driver inheritance of
rte_soc_device/rte_soc_driver.Signed-off-by Jan Viktorin <[email protected]>Signed-off-by Shreyansh Jain <[email protected]>Signed-off-by Hemant Agrawal <[email protected]>--- app/test/Makefile | 1 + app/test/test_soc.c | 90 +++++++++++++++++++++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_private.h | 4 + lib/librte_eal/common/include/rte_soc.h | 138 ++++++++++++++++++++++++++++++++ 5 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.happ/test/Makefile +0
-0
[...]
Quoted 2 lines
+++
b/lib/librte_eal/common/include/rte_soc.happ/test/Makefile +0
-0@@ -0,0 +1,138 @@
[...]
app/test/Makefile
Quoted 13 lines
app/test/Makefile +13
-0+ +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <inttypes.h> +#include <string.h> + +#include <rte_dev.h> +#include <rte_debug.h> + +struct rte_soc_id { + const char *compatible; /**< OF compatible specification */ + uint64_t priv_data; /**< SoC Driver specific data */
Do you expect this to be a pointer?
Quoted 2 lines
app/test/Makefile +2
-0+}; +
[...]
Quoted 9 lines
app/test/Makefile +9
-0+ +/** + * Initialization function for the driver called during SoC probing. + */ +typedef int (soc_devinit_t)(struct rte_soc_driver *, struct rte_soc_device *); + +/** + * Uninitialization function for the driver called during hotplugging. + */
app/test/Makefile
Quoted 10 lines
app/test/Makefile +10
-0+typedef int (soc_devuninit_t)(struct rte_soc_device *); + +/** + * A structure describing a SoC driver. + */ +struct rte_soc_driver { + TAILQ_ENTRY(rte_soc_driver) next; /**< Next in list */ + struct rte_driver driver; /**< Inherit core driver. */ + soc_devinit_t *devinit; /**< Device initialization */ + soc_devuninit_t *devuninit; /**< Device uninitialization */
Shouldn't those functions be named probe/remove?
Quoted 3 lines
app/test/Makefile +3
-0+ const struct rte_soc_id *id_table; /**< ID table, NULL terminated */ +}; +
[...]
Quoted 1 line
+#endif
Signature · 4 lines
Jan Viktorin E-mail: [email protected] System Architect Web: www.RehiveTech.com RehiveTech Brno, Czech Republic
Re: [PATCH v5 06/21] eal/soc: introduce very essential SoC infra definitions
Hello Jan,
Quoted 34 lines · Jan Viktorin
Quoted 23 lines · On Mon, 24 Oct 2016 17:29:25 +0530 Shreyansh Jain <[email protected]>…
From: Jan Viktorin <[email protected]>
Define initial structures and functions for the SoC infrastructure. This patch supports only a very minimal functions for now. More features will be added in the following commits.
Includes rte_device/rte_driver inheritance of
rte_soc_device/rte_soc_driver.Signed-off-by Jan Viktorin <[email protected]>Signed-off-by Shreyansh Jain <[email protected]>Signed-off-by Hemant Agrawal <[email protected]>--- app/test/Makefile | 1 + app/test/test_soc.c | 90 +++++++++++++++++++++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_private.h | 4 + lib/librte_eal/common/include/rte_soc.h | 138 ++++++++++++++++++++++++++++++++ 5 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.happ/test/Makefile +0
-0[...]
Quoted 2 lines
+++
b/lib/librte_eal/common/include/rte_soc.happ/test/Makefile +0
-0@@ -0,0 +1,138 @@[...]
Quoted 15 lines
app/test/Makefile
Quoted 13 lines
app/test/Makefile +13
-0+ +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <inttypes.h> +#include <string.h> + +#include <rte_dev.h> +#include <rte_debug.h> + +struct rte_soc_id { + const char *compatible; /**< OF compatible specification */ + uint64_t priv_data; /**< SoC Driver specific data */Do you expect this to be a pointer?
A 64 bit entry, which can be typecasted to pointer by implementations, if required. Or, it might as well remain as a 64bit entry as ID.
Quoted 19 lines
Quoted 3 lines
app/test/Makefile +2
-0+}; +[...]
Quoted 13 lines
app/test/Makefile +13
-0+ +/** + * Initialization function for the driver called during SoC probing. + */ +typedef int (soc_devinit_t)(struct rte_soc_driver *, struct rte_soc_device *); + +/** + * Uninitialization function for the driver called during hotplugging. + */ +typedef int (soc_devuninit_t)(struct rte_soc_device *); + +/** + * A structure describing a SoC driver.
Quoted 8 lines
app/test/Makefile
Quoted 6 lines
+ */
app/test/Makefile +5
-0+struct rte_soc_driver { + TAILQ_ENTRY(rte_soc_driver) next; /**< Next in list */ + struct rte_driver driver; /**< Inherit core driver. */ + soc_devinit_t *devinit; /**< Device initialization */ + soc_devuninit_t *devuninit; /**< Device uninitialization */Shouldn't those functions be named probe/remove?
Indeed. I think there was a comment on v4 as well - I thought I had fixed it but it seems I have mixed up my patches. I will send v6 immediately with this fixed. Thanks for pointing out.
Quoted 11 lines
Quoted 4 lines
app/test/Makefile +3
-0+ const struct rte_soc_id *id_table; /**< ID table, NULL terminated */ +}; +[...]
Quoted 1 line
+#endif
-
Shreyansh
Re: [PATCH v5 06/21] eal/soc: introduce very essential SoC infra definitions
Quoted 86 lines · Shreyansh Jain
Hello Jan,
Quoted 35 lines · Jan Viktorin
Quoted 24 lines · On Mon, 24 Oct 2016 17:29:25 +0530 Shreyansh Jain <[email protected]>…
From: Jan Viktorin <[email protected]>
Define initial structures and functions for the SoC infrastructure. This patch supports only a very minimal functions for now. More features will be added in the following commits.
Includes rte_device/rte_driver inheritance of
rte_soc_device/rte_soc_driver.Signed-off-by Jan Viktorin <[email protected]>Signed-off-by Shreyansh Jain <[email protected]>Signed-off-by Hemant Agrawal <[email protected]>--- app/test/Makefile | 1 + app/test/test_soc.c | 90 +++++++++++++++++++++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_private.h | 4 + lib/librte_eal/common/include/rte_soc.h | 138 ++++++++++++++++++++++++++++++++ 5 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.happ/test/Makefile +0
-0[...]
Quoted 2 lines
+++
b/lib/librte_eal/common/include/rte_soc.happ/test/Makefile +0
-0@@ -0,0 +1,138 @@[...]
Quoted 15 lines
app/test/Makefile
Quoted 13 lines
app/test/Makefile +13
-0+ +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <inttypes.h> +#include <string.h> + +#include <rte_dev.h> +#include <rte_debug.h> + +struct rte_soc_id { + const char *compatible; /**< OF compatible specification */ + uint64_t priv_data; /**< SoC Driver specific data */Do you expect this to be a pointer?
A 64 bit entry, which can be typecasted to pointer by implementations, if required. Or, it might as well remain as a 64bit entry as ID.
Quoted 20 lines
Quoted 3 lines
app/test/Makefile +2
-0+}; +[...]
Quoted 14 lines
app/test/Makefile +5
-0+ +/** + * Initialization function for the driver called during SoC probing. + */ +typedef int (soc_devinit_t)(struct rte_soc_driver *, struct
rte_soc_device*);app/test/Makefile +8
-0+ +/** + * Uninitialization function for the driver called during hotplugging. + */ +typedef int (soc_devuninit_t)(struct rte_soc_device *); + +/** + * A structure describing a SoC driver.Quoted 8 lines
app/test/Makefile
Quoted 6 lines
+ */
app/test/Makefile +5
-0+struct rte_soc_driver { + TAILQ_ENTRY(rte_soc_driver) next; /**< Next in list */ + struct rte_driver driver; /**< Inherit core driver. */ + soc_devinit_t *devinit; /**< Device initialization */ + soc_devuninit_t *devuninit; /**< Device uninitialization */Shouldn't those functions be named probe/remove?
Quoted 3 lines
Indeed. I think there was a comment on v4 as well - I thought I had fixed it but it seems I have mixed up my patches. I will send v6 immediately with this fixed. Thanks for pointing out.
Ah, I just noticed that I did change it - but in Patch 11. Ideally, it should have been done here itself. My bad.
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
+ const struct
rte_soc_id*id_table; /**< ID table, NULL
terminated */app/test/Makefile +2
-0+}; +[...]
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
+#endif
-
Shreyansh
-
Shreyansh
PATCH v5 7/21 eal/soc: add SoC PMD register/unregister logic
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Registeration of a SoC driver through a helper RTE_PMD_REGISTER_SOC (on the lines of RTE_PMD_REGISTER_PCI). soc_driver_list stores all the registered drivers.
Test case has been introduced to verify the registration and deregistration.
--- app/test/test_soc.c | 111 ++++++++++++++++++++++++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 3 + lib/librte_eal/common/eal_common_soc.c | 56 ++++++++++++ lib/librte_eal/common/include/rte_soc.h | 26 ++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 3 + 6 files changed, 200 insertions(+) create mode 100644 lib/librte_eal/common/eal_common_soc.c
app/test/test_soc.c +111 -0
@@ -75,6 +75,108 @@ static int test_compare_addr(void)free (a2.name);free (a1.name);free (a0.name); + +return 0 ; +} + +/** +* Empty PMD driver based on the SoC infra. +* +* The rte_soc_device is usually wrapped in some higher-level struct +* (eth_driver). We simulate such a wrapper with an anonymous struct here. +*/ +struct test_wrapper { +struct rte_soc_driver soc_drv; +}; + +struct test_wrapper empty_pmd0 = { + .soc_drv = { + .driver = { + .name ="empty_pmd0" + }, + }, +}; + +struct test_wrapper empty_pmd1 = { + .soc_drv = { + .driver = { + .name ="empty_pmd1" + }, + }, +}; + +static int +count_registered_socdrvs (void ) +{ +int i; +struct rte_soc_driver *drv; + + i =0 ; +TAILQ_FOREACH (drv, &soc_driver_list, next) + i += 1; + +return i; +} + +static int +test_register_unregister (void ) +{ +struct rte_soc_driver *drv; +int count; + +rte_eal_soc_register (&empty_pmd0.soc_drv); + +TEST_ASSERT (!TAILQ_EMPTY (&soc_driver_list), +"No PMD is present but the empty_pmd0 should be there" ); + drv =TAILQ_FIRST (&soc_driver_list); +TEST_ASSERT (!strcmp (drv->driver.name,"empty_pmd0" ), +"The registered PMD is not empty_pmd0 but '%s'" , + drv->driver.name); + +rte_eal_soc_register (&empty_pmd1.soc_drv); + + count =count_registered_socdrvs (); +TEST_ASSERT_EQUAL (count,2 ,"Expected 2 PMDs but detected %d" , count); + +rte_eal_soc_unregister (&empty_pmd0.soc_drv); + count =count_registered_socdrvs (); +TEST_ASSERT_EQUAL (count,1 ,"Expected 1 PMDs but detected %d" , count); + +rte_eal_soc_unregister (&empty_pmd1.soc_drv); + +printf ("%s has been successful\n" , __func__); +return 0 ; +} + +/* save real devices and drivers until the tests finishes */ +struct soc_driver_list real_soc_driver_list = +TAILQ_HEAD_INITIALIZER (real_soc_driver_list); + +static int test_soc_setup (void ) +{ +struct rte_soc_driver *drv; + +/* no real drivers for the test */ +while (!TAILQ_EMPTY (&soc_driver_list)) { + drv =TAILQ_FIRST (&soc_driver_list); +rte_eal_soc_unregister (drv); +TAILQ_INSERT_TAIL (&real_soc_driver_list, drv, next); + } + +return 0 ; +} + +static int test_soc_cleanup (void ) +{ +struct rte_soc_driver *drv; + +/* bring back real drivers after the test */ +while (!TAILQ_EMPTY (&real_soc_driver_list)) { + drv =TAILQ_FIRST (&real_soc_driver_list); +TAILQ_REMOVE (&real_soc_driver_list, drv, next); +rte_eal_soc_register (drv); + } +return 0 ; }
@@ -84,6 +186,15 @@ test_soc(void)if (test_compare_addr ())return -1 ; +if (test_soc_setup ()) +return -1 ; + +if (test_register_unregister ()) +return -1 ; + +if (test_soc_cleanup ()) +return -1 ; +return 0 ; }
lib/librte_eal/bsdapp/eal/rte_eal_version.map +3 -0
@@ -171,8 +171,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_register; + rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; } DPDK_16.07;
lib/librte_eal/common/eal_common_soc.c new file +56 -0
56 lines not on this page · raw message
lib/librte_eal/common/include/rte_soc.h +26 -0
@@ -51,8 +51,14 @@ extern "C" {#include <string.h> #include <rte_dev.h> +#include <rte_eal.h> #include <rte_debug.h> +extern struct soc_driver_list soc_driver_list; +/**< Global list of SoC Drivers */ + +TAILQ_HEAD (soc_driver_list, rte_soc_driver);/**< SoC drivers in D-linked Q. */ +struct rte_soc_id {const char *compatible;/**< OF compatible specification */ uint64_t priv_data;/**< SoC Driver specific data */
@@ -135,4 +141,24 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, return strcmp(a0->name, a1->name); } +/** +* Register a SoC driver. +*/ +void rte_eal_soc_register (struct rte_soc_driver *driver); + +/** Helper for SoC device registeration from PMD Drivers */ +#define RTE_PMD_REGISTER_SOC (nm, soc_drv) \ +RTE_INIT(socinitfn_ ##name); \ +static void socinitfn_ ##name(void) \ +{\ + (soc_drv).driver.name = RTE_STR(nm);\ + rte_eal_soc_register(&soc_drv); \ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +/** +* Unregister a SoC driver. +*/ +void rte_eal_soc_unregister (struct rte_soc_driver *driver); +#endif
lib/librte_eal/linuxapp/eal/Makefile +1 -0
@@ -77,6 +77,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_soc.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c
lib/librte_eal/linuxapp/eal/rte_eal_version.map +3 -0
@@ -175,8 +175,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_register; + rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; } DPDK_16.07;
Signature · 1 line
2.7.4
PATCH v5 8/21 eal/soc: implement SoC device list and dump
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
SoC devices would be linked in a separate list (from PCI). This is used for probe function.
A helper for dumping the device list is added.
--- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++ lib/librte_eal/common/eal_common_soc.c | 34 +++++++++++++++++++++++++ lib/librte_eal/common/include/rte_soc.h | 9 +++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++ 4 files changed, 47 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +2 -0
@@ -171,11 +171,13 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_dump; rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_device_list; soc_driver_list; } DPDK_16.07;
lib/librte_eal/common/eal_common_soc.c +34 -0
@@ -31,6 +31,8 @@* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <stddef.h> +#include <stdio.h> #include <sys/queue.h> #include <rte_log.h>
@@ -40,6 +42,38 @@/* Global SoC driver list */ struct soc_driver_list soc_driver_list =TAILQ_HEAD_INITIALIZER (soc_driver_list); +struct soc_device_list soc_device_list = +TAILQ_HEAD_INITIALIZER (soc_device_list); + +/* dump one device */ +static int +soc_dump_one_device (FILE *f,struct rte_soc_device *dev) +{ +int i; + +fprintf (f,"%s" , dev->addr.name); +fprintf (f," - fdt_path: %s\n" , + dev->addr.fdt_path ? dev->addr.fdt_path :"(none)" ); + +for (i =0 ; dev->id && dev->id[i].compatible; ++i) +fprintf (f," %s\n" , dev->id[i].compatible); + +return 0 ; +} + +/* dump devices on the bus to an output stream */ +void +rte_eal_soc_dump (FILE *f) +{ +struct rte_soc_device *dev =NULL ; + +if (!f) +return ; + + TAILQ_FOREACH(dev, &soc_device_list, next) { +soc_dump_one_device (f, dev); + } +}/* register a driver */ void
lib/librte_eal/common/include/rte_soc.h +9 -0
@@ -56,8 +56,12 @@ extern "C" {extern struct soc_driver_list soc_driver_list;/**< Global list of SoC Drivers */ +extern struct soc_device_list soc_device_list; +/**< Global list of SoC Devices */ TAILQ_HEAD (soc_driver_list, rte_soc_driver);/**< SoC drivers in D-linked Q. */ +TAILQ_HEAD (soc_device_list, rte_soc_device);/**< SoC devices in D-linked Q. */ +struct rte_soc_id {const char *compatible;/**< OF compatible specification */
@@ -142,6 +146,11 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, }/** +* Dump discovered SoC devices. +*/ +void rte_eal_soc_dump (FILE *f); + +/** * Register a SoC driver. */ void rte_eal_soc_register (struct rte_soc_driver *driver);
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
@@ -175,11 +175,13 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_dump; rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_device_list; soc_driver_list; } DPDK_16.07;
Signature · 1 line
2.7.4
PATCH v5 9/21 eal: introduce command line enable SoC option
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Support --enable-soc. SoC support is disabled by default.
--- doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ lib/librte_eal/common/eal_common_options.c | 5 +++++ lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/common/eal_options.h | 2 ++ 4 files changed, 12 insertions(+)
doc/guides/testpmd_app_ug/run_app.rst +4 -0
@@ -156,6 +156,10 @@ See the DPDK Getting Started Guides for more information on these options. Use malloc instead of hugetlbfs. +* ``--enable-soc`` + + Enable SoC framework support + Testpmd Command-line Options ----------------------------
lib/librte_eal/common/eal_common_options.c +5 -0
@@ -75,6 +75,7 @@ const struct option eal_long_options[] = { {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM }, {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM }, + {OPT_ENABLE_SOC, 0, NULL, OPT_ENABLE_SOC_NUM }, {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM }, {OPT_HELP, 0, NULL, OPT_HELP_NUM }, {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM },
@@ -843,6 +844,10 @@ eal_parse_common_option(int opt, const char *optarg,break ;/* long options */ +case OPT_ENABLE_SOC_NUM : + conf->enable_soc =1 ; +break ; +case OPT_HUGE_UNLINK_NUM : conf->hugepage_unlink =1 ;break ;
lib/librte_eal/common/eal_internal_cfg.h +1 -0
@@ -67,6 +67,7 @@ struct internal_config {unsigned hugepage_unlink;/**< true to unlink backing files */ volatile unsigned xen_dom0_support;/**< support app running on Xen Dom0*/ volatile unsigned no_pci;/**< true to disable PCI */ +volatile unsigned enable_soc;/**< true to enable SoC */ volatile unsigned no_hpet;/**< true to disable HPET */ volatile unsigned vmware_tsc_map;/**< true to use VMware TSC mapping * instead of native TSC */
lib/librte_eal/common/eal_options.h +2 -0
@@ -49,6 +49,8 @@ enum {OPT_BASE_VIRTADDR_NUM , #define OPT_CREATE_UIO_DEV "create-uio-dev"OPT_CREATE_UIO_DEV_NUM , +#define OPT_ENABLE_SOC "enable-soc" +OPT_ENABLE_SOC_NUM , #define OPT_FILE_PREFIX "file-prefix"OPT_FILE_PREFIX_NUM , #define OPT_HUGE_DIR "huge-dir"
Signature · 1 line
2.7.4
PATCH v5 10/21 eal/soc: init SoC infra from EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/eal.c | 4 +++ lib/librte_eal/bsdapp/eal/eal_soc.c | 46 ++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 10 +++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/eal.c | 3 ++ lib/librte_eal/linuxapp/eal/eal_soc.c | 56 +++++++++++++++++++++++++++++++++++ 7 files changed, 121 insertions(+) create mode 100644 lib/librte_eal/bsdapp/eal/eal_soc.c create mode 100644 lib/librte_eal/linuxapp/eal/eal_soc.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -56,6 +56,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_hugepage_info.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_thread.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_pci.c +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_soc.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_debug.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_lcore.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_timer.c
lib/librte_eal/bsdapp/eal/eal.c +4 -0
@@ -64,6 +64,7 @@#include <rte_string_fns.h> #include <rte_cpuflags.h> #include <rte_interrupts.h> +#include <rte_soc.h> #include <rte_pci.h> #include <rte_dev.h> #include <rte_devargs.h>
@@ -564,6 +565,9 @@ rte_eal_init(int argc, char **argv)if (rte_eal_pci_init () <0 )rte_panic ("Cannot init PCI\n" ); +if (rte_eal_soc_init () <0 ) +rte_panic ("Cannot init SoC\n" ); +eal_check_mem_on_local_socket ();if (eal_plugins_init () <0 )
lib/librte_eal/bsdapp/eal/eal_soc.c new file +46 -0
46 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +10 -0
@@ -122,6 +122,16 @@ int rte_eal_pci_init(void);struct rte_soc_driver ;struct rte_soc_device ; +/** +* Init the SoC infra. +* +* This function is private to EAL. +* +* @return +* 0 on success, negative on error +*/ +int rte_eal_soc_init (void ); +struct rte_pci_driver ;struct rte_pci_device ;
lib/librte_eal/linuxapp/eal/Makefile +1 -0
@@ -65,6 +65,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio_mp_sync.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_uio.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_vfio.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_soc.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_debug.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_lcore.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_timer.c
lib/librte_eal/linuxapp/eal/eal.c +3 -0
@@ -810,6 +810,9 @@ rte_eal_init(int argc, char **argv)rte_panic ("Cannot init VFIO\n" );#endif +if (rte_eal_soc_init () <0 ) +rte_panic ("Cannot init SoC\n" ); +if (rte_eal_memory_init () <0 )rte_panic ("Cannot init memory\n" );
lib/librte_eal/linuxapp/eal/eal_soc.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v5 11/21 eal/soc: implement probing of drivers
In reply to Shreyansh JainEach SoC PMD registers a set of callback for scanning its own bus/infra and matching devices to drivers when probe is called.
This patch introduces the infra for calls to SoC scan on rte_eal_soc_init() and match on rte_eal_soc_probe().
Patch also adds test case for scan and probe.
--
v4:
- Update test_soc for descriptive test function names
- Comments over test functions
- devinit and devuninint --> probe/remove
- RTE_VERIFY at some places
--- app/test/test_soc.c | 205 ++++++++++++++++++++++- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 4 + lib/librte_eal/common/eal_common_soc.c | 213 +++++++++++++++++++++++- lib/librte_eal/common/include/rte_soc.h | 83 ++++++++- lib/librte_eal/linuxapp/eal/eal.c | 5 + lib/librte_eal/linuxapp/eal/eal_soc.c | 21 ++- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 4 + 7 files changed, 523 insertions(+), 12 deletions(-)
app/test/test_soc.c +204 -1
@@ -87,14 +87,65 @@ static int test_compare_addr(void)*/ struct test_wrapper {struct rte_soc_driver soc_drv; +struct rte_soc_device soc_dev; }; +static int empty_pmd0_probe (struct rte_soc_driver *drv, +struct rte_soc_device *dev); +static int empty_pmd0_remove (struct rte_soc_device *dev); + +static void always_find_dev0_cb (void ); +static int match_dev0_by_name (struct rte_soc_driver *drv, +struct rte_soc_device *dev); + +static void always_find_dev1_cb (void ); +static int match_dev1_by_name (struct rte_soc_driver *drv, +struct rte_soc_device *dev); + +/** +* Dummy probe handler for PMD driver 'pmd0'. +* +* @param drv +* driver object +* @param dev +* device object +* @return +* 0 on success +*/ +static int +empty_pmd0_probe(struct rte_soc_driver *drv __rte_unused, + struct rte_soc_device *dev __rte_unused) +{ +return 0 ; +} + +/** +* Remove handler for PMD driver 'pmd0'. +* +* @param dev +* device to remove +* @return +* 0 on success +*/ +static int +empty_pmd0_remove (struct rte_soc_device *dev) +{ +/* Release the memory associated with dev->addr.name */ +free (dev->addr.name); + +return 0 ; +} +struct test_wrapper empty_pmd0 = { .soc_drv = { .driver = { .name ="empty_pmd0" }, - }, + .probe = empty_pmd0_probe, + .remove = empty_pmd0_remove, + .scan_fn = always_find_dev0_cb, + .match_fn = match_dev0_by_name, + } };struct test_wrapper empty_pmd1 = {
@@ -102,9 +153,87 @@ struct test_wrapper empty_pmd1 = { .driver = { .name = "empty_pmd1" }, + .scan_fn = always_find_dev1_cb, + .match_fn = match_dev1_by_name, }, }; +/** +* Bus scan by PMD 'pmd0' for adding device 'dev0' +* +* @param void +* @return void +*/ +static void +always_find_dev0_cb (void ) +{ +/* SoC's scan would scan devices on its bus and add to +* soc_device_list +*/ + empty_pmd0.soc_dev.addr.name =strdup ("empty_pmd0_dev" ); + +TAILQ_INSERT_TAIL (&soc_device_list, &empty_pmd0.soc_dev, next); +} + +/** +* Match device 'dev0' with driver PMD pmd0 +* +* @param drv +* Driver with this matching needs to be done; unused here +* @param dev +* device to be matched against driver +* @return +* 0 on successful matched +* 1 if driver<=>device don't match +*/ +static int +match_dev0_by_name(struct rte_soc_driver *drv __rte_unused, +struct rte_soc_device *dev) +{ +if (!dev->addr.name ||strcmp (dev->addr.name,"empty_pmd0_dev" )) +return 0 ; + +return 1 ; +} + +/** +* Bus scan by PMD 'pmd0' for adding device 'dev1' +* +* @param void +* @return void +*/ +static void +always_find_dev1_cb (void ) +{ +/* SoC's scan would scan devices on its bus and add to +* soc_device_list +*/ + empty_pmd0.soc_dev.addr.name =strdup ("empty_pmd1_dev" ); + +TAILQ_INSERT_TAIL (&soc_device_list, &empty_pmd1.soc_dev, next); +} + +/** +* Match device 'dev1' with driver PMD pmd0 +* +* @param drv +* Driver with this matching needs to be done; unused here +* @param dev +* device to be matched against driver +* @return +* 0 on successful matched +* 1 if driver<=>device don't match +*/ +static int +match_dev1_by_name(struct rte_soc_driver *drv __rte_unused, +struct rte_soc_device *dev) +{ +if (!dev->addr.name ||strcmp (dev->addr.name,"empty_pmd1_dev" )) +return 0 ; + +return 1 ; +} +static int count_registered_socdrvs (void ) {
@@ -148,13 +277,68 @@ test_register_unregister(void)return 0 ; } +/* Test Probe (scan and match) functionality */ +static int +test_soc_scan_and_match (void ) +{ +int drv_count =0 ; +struct rte_soc_driver *drv; + +/* Registering dummy drivers */ +rte_eal_soc_register (&empty_pmd0.soc_drv); +rte_eal_soc_register (&empty_pmd1.soc_drv); +/* Assuming that test_register_unregister is working, not verifying +* that drivers are indeed registered +*/ + +/* rte_eal_soc_init is called by rte_eal_init, which in turn calls the +* scan_fn of each driver. +*/ + TAILQ_FOREACH(drv, &soc_driver_list, next) { +if (drv && drv->scan_fn) + drv->scan_fn (); + drv_count++; + } + +/* rte_eal_init() would perform other inits here */ + +/* Probe would link the SoC devices<=>drivers */ +rte_eal_soc_probe (); + +/* Unregistering dummy drivers */ +rte_eal_soc_unregister (&empty_pmd0.soc_drv); +rte_eal_soc_unregister (&empty_pmd1.soc_drv); + +/* Verify the Unregistering has removed the driver from list */ + TAILQ_FOREACH(drv, &soc_driver_list, next) { +if (drv) + drv_count--; + } + +free (empty_pmd0.soc_dev.addr.name); + +/* If drv_count is anything other than 0, Unregistering failed */ +if (drv_count) { +printf ("%s has failed\n" , __func__); +return 1 ; + } + +printf ("%s has been successful\n" , __func__); +return 0 ; +} +/* save real devices and drivers until the tests finishes */ struct soc_driver_list real_soc_driver_list =TAILQ_HEAD_INITIALIZER (real_soc_driver_list); +/* save real devices and drivers until the tests finishes */ +struct soc_device_list real_soc_device_list = +TAILQ_HEAD_INITIALIZER (real_soc_device_list); +static int test_soc_setup (void ) {struct rte_soc_driver *drv; +struct rte_soc_device *dev;/* no real drivers for the test */ while (!TAILQ_EMPTY (&soc_driver_list)) {
@@ -163,12 +347,20 @@ static int test_soc_setup(void)TAILQ_INSERT_TAIL (&real_soc_driver_list, drv, next); } +/* And, no real devices for the test */ +while (!TAILQ_EMPTY (&soc_device_list)) { + dev =TAILQ_FIRST (&soc_device_list); +TAILQ_REMOVE (&soc_device_list, dev, next); +TAILQ_INSERT_TAIL (&real_soc_device_list, dev, next); + } +return 0 ; }static int test_soc_cleanup (void ) {struct rte_soc_driver *drv; +struct rte_soc_device *dev;/* bring back real drivers after the test */ while (!TAILQ_EMPTY (&real_soc_driver_list)) {
@@ -177,6 +369,13 @@ static int test_soc_cleanup(void)rte_eal_soc_register (drv); } +/* And, bring back real devices after the test */ +while (!TAILQ_EMPTY (&real_soc_device_list)) { + dev =TAILQ_FIRST (&real_soc_device_list); +TAILQ_REMOVE (&real_soc_device_list, dev, next); +TAILQ_INSERT_TAIL (&soc_device_list, dev, next); + } +return 0 ; }
@@ -192,6 +391,10 @@ test_soc(void)if (test_register_unregister ())return -1 ; +/* Assuming test_register_unregister has succeeded */ +if (test_soc_scan_and_match ()) +return -1 ; +if (test_soc_cleanup ())return -1 ;
lib/librte_eal/bsdapp/eal/rte_eal_version.map +4 -0
@@ -171,7 +171,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_detach; rte_eal_soc_dump; + rte_eal_soc_match; + rte_eal_soc_probe; + rte_eal_soc_probe_one; rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_unmap_resource;
lib/librte_eal/common/eal_common_soc.c +210 -3
243 lines not on this page · raw message
lib/librte_eal/common/include/rte_soc.h +78 -5
123 lines not on this page · raw message
lib/librte_eal/linuxapp/eal/eal.c +5 -0
@@ -70,6 +70,7 @@#include <rte_cpuflags.h> #include <rte_interrupts.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_dev.h> #include <rte_devargs.h> #include <rte_common.h>
@@ -890,6 +891,10 @@ rte_eal_init(int argc, char **argv)if (rte_eal_pci_probe ())rte_panic ("Cannot probe PCI\n" ); +/* Probe & Initialize SoC devices */ +if (rte_eal_soc_probe ()) +rte_panic ("Cannot probe SoC\n" ); +rte_eal_mcfg_complete ();return fctret;
lib/librte_eal/linuxapp/eal/eal_soc.c +18 -3
@@ -44,13 +44,28 @@#include <rte_log.h> #include <rte_soc.h> -#include "eal_internal_cfg.h" -#include "eal_filesystem.h" -#include "eal_private.h" +#include <eal_internal_cfg.h> +#include <eal_filesystem.h> +#include <eal_private.h> /* Init the SoC EAL subsystem */ int rte_eal_soc_init (void ) { +struct rte_soc_driver *drv; + +/* SoC is disabled by default */ +if (!internal_config.enable_soc) +return 0 ; + +/* For each registered driver, call their scan routine to perform any +* custom scan for devices (for example, custom buses) +*/ + TAILQ_FOREACH(drv, &soc_driver_list, next) { +RTE_VERIFY (drv->scan_fn); + drv->scan_fn (); +/* Ignore all errors from this */ + } +return 0 ; }
lib/librte_eal/linuxapp/eal/rte_eal_version.map +4 -0
@@ -175,7 +175,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_detach; rte_eal_soc_dump; + rte_eal_soc_match; + rte_eal_soc_probe; + rte_eal_soc_probe_one; rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_unmap_resource;
Signature · 1 line
2.7.4
PATCH v5 12/21 eal/soc: extend and utilize devargs
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
It is assumed that SoC Devices provided on command line are prefixed with "soc:". This patch adds parse and attach support for such devices.
--- lib/librte_eal/common/eal_common_dev.c | 27 +++++++++---- lib/librte_eal/common/eal_common_devargs.c | 17 ++++++++ lib/librte_eal/common/eal_common_soc.c | 61 ++++++++++++++++++++++++----- lib/librte_eal/common/include/rte_devargs.h | 8 ++++ lib/librte_eal/common/include/rte_soc.h | 24 ++++++++++++ 5 files changed, 120 insertions(+), 17 deletions(-)
lib/librte_eal/common/eal_common_dev.c +20 -7
@@ -107,17 +107,23 @@ rte_eal_dev_init(void)int rte_eal_dev_attach (const char *name,const char *devargs) { -struct rte_pci_addr addr; +struct rte_soc_addr soc_addr; +struct rte_pci_addr pci_addr;if (name ==NULL || devargs ==NULL ) {RTE_LOG (ERR ,EAL ,"Invalid device or arguments provided\n" );return -EINVAL ; } -if (eal_parse_pci_DomBDF (name, &addr) ==0 ) { -if (rte_eal_pci_probe_one (&addr) <0 ) +memset (&soc_addr,0 ,sizeof (soc_addr)); +if (rte_eal_parse_soc_spec (name, &soc_addr) ==0 ) { +if (rte_eal_soc_probe_one (&soc_addr) <0 ) { +free (soc_addr.name); + goto err; + } + }else if (eal_parse_pci_DomBDF (name, &pci_addr) ==0 ) { +if (rte_eal_pci_probe_one (&pci_addr) <0 ) goto err; - }else {if (rte_eal_vdev_init (name, devargs)) goto err;
@@ -132,15 +138,22 @@ err:int rte_eal_dev_detach (const char *name) { -struct rte_pci_addr addr; +struct rte_soc_addr soc_addr; +struct rte_pci_addr pci_addr;if (name ==NULL ) {RTE_LOG (ERR ,EAL ,"Invalid device provided.\n" );return -EINVAL ; } -if (eal_parse_pci_DomBDF (name, &addr) ==0 ) { -if (rte_eal_pci_detach (&addr) <0 ) +memset (&soc_addr,0 ,sizeof (soc_addr)); +if (rte_eal_parse_soc_spec (name, &soc_addr) ==0 ) { +if (rte_eal_soc_detach (&soc_addr) <0 ) { +free (soc_addr.name); + goto err; + } + }else if (eal_parse_pci_DomBDF (name, &pci_addr) ==0 ) { +if (rte_eal_pci_detach (&pci_addr) <0 ) goto err; }else {if (rte_eal_vdev_uninit (name))
lib/librte_eal/common/eal_common_devargs.c +17 -0
@@ -41,6 +41,7 @@#include <string.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_devargs.h> #include "eal_private.h"
@@ -105,6 +106,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) goto fail;break ; + +case RTE_DEVTYPE_WHITELISTED_SOC : +case RTE_DEVTYPE_BLACKLISTED_SOC : +/* try to parse soc device with prefix "soc:" */ +if (rte_eal_parse_soc_spec (buf, &devargs->soc.addr) !=0 ) + goto fail; +break ; +case RTE_DEVTYPE_VIRTUAL :/* save driver name */ ret = snprintf(devargs->virt.drv_name,
@@ -166,6 +175,14 @@ rte_eal_devargs_dump(FILE *f) devargs->pci.addr.devid, devargs->pci.addr.function, devargs->args); + else if (devargs->type == RTE_DEVTYPE_WHITELISTED_SOC) + fprintf(f, " SoC whitelist %s %s\n", + devargs->soc.addr.name, + devargs->soc.addr.fdt_path); + else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_SOC) + fprintf(f, " SoC blacklist %s %s\n", + devargs->soc.addr.name, + devargs->soc.addr.fdt_path); else if (devargs->type == RTE_DEVTYPE_VIRTUAL) fprintf(f, " VIRTUAL %s %s\n", devargs->virt.drv_name,
lib/librte_eal/common/eal_common_soc.c +51 -10
94 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +8 -0
@@ -51,6 +51,7 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> #include <rte_pci.h> +#include <rte_soc.h> /** * Type of generic device
@@ -58,6 +59,8 @@ extern "C" {enum rte_devtype {RTE_DEVTYPE_WHITELISTED_PCI ,RTE_DEVTYPE_BLACKLISTED_PCI , +RTE_DEVTYPE_WHITELISTED_SOC , +RTE_DEVTYPE_BLACKLISTED_SOC ,RTE_DEVTYPE_VIRTUAL , };
@@ -83,6 +86,11 @@ struct rte_devargs {/** PCI location. */ struct rte_pci_addr addr; } pci; +/** Used if type is RTE_DEVTYPE_*_SOC. */ +struct { +/** SoC location. */ +struct rte_soc_addr addr; + } soc;/** Used if type is RTE_DEVTYPE_VIRTUAL. */ struct {/** Driver name. */
lib/librte_eal/common/include/rte_soc.h +24 -0
@@ -164,6 +164,30 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, }/** +* Parse a specification of a soc device. The specification must differentiate +* a SoC device specification from the PCI bus and virtual devices. We assume +* a SoC specification starts with "soc:". The function allocates the name +* entry of the given addr. +* +* @return +* - 0 on success +* - 1 when not a SoC spec +* - -1 on failure +*/ +static inline int +rte_eal_parse_soc_spec (const char *spec,struct rte_soc_addr *addr) +{ +if (strstr (spec,"soc:" ) == spec) { + addr->name =strdup (spec +4 ); +if (addr->name ==NULL ) +return -1 ; +return 0 ; + } + +return 1 ; +} + +/** * Default function for matching the Soc driver with device. Each driver can * either use this function or define their own soc matching function. * This function relies on the compatible string extracted from sysfs. But,
Signature · 1 line
2.7.4
PATCH v5 13/21 eal/soc: add drv_flags
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
The flags are copied from the PCI ones. They should be refactorized into a general set of flags in the future.
--- lib/librte_eal/common/include/rte_soc.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/librte_eal/common/include/rte_soc.h +10 -0
@@ -123,8 +123,18 @@ struct rte_soc_driver {soc_scan_t *scan_fn;/**< Callback for scanning SoC bus*/ soc_match_t *match_fn;/**< Callback to match dev<->drv */ const struct rte_soc_id *id_table;/**< ID table, NULL terminated */ +uint32_t drv_flags;/**< Control handling of device */ }; +/** Device needs to map its resources by EAL */ +#define RTE_SOC_DRV_NEED_MAPPING 0x0001 +/** Device needs to be unbound even if no module is provieded */ +#define RTE_SOC_DRV_FORCE_UNBIND 0x0004 +/** Device driver supports link state interrupt */ +#define RTE_SOC_DRV_INTR_LSC 0x0008 +/** Device driver supports detaching capability */ +#define RTE_SOC_DRV_DETACHABLE 0x0010 +/** * Utility function to write a SoC device name, this device name can later be * used to retrieve the corresponding rte_soc_addr using above functions.
Signature · 1 line
2.7.4
PATCH v5 14/21 eal/soc: add intr_handle
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_eal/common/include/rte_soc.h | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_eal/common/include/rte_soc.h +2 -0
@@ -53,6 +53,7 @@ extern "C" {#include <rte_dev.h> #include <rte_eal.h> #include <rte_debug.h> +#include <rte_interrupts.h> extern struct soc_driver_list soc_driver_list;/**< Global list of SoC Drivers */
@@ -80,6 +81,7 @@ struct rte_soc_device {struct rte_device device;/**< Inherit code device */ struct rte_soc_addr addr;/**< SoC device Location */ struct rte_soc_id *id;/**< SoC device ID list */ +struct rte_intr_handle intr_handle;/**< Interrupt handle */ struct rte_soc_driver *driver;/**< Associated driver */ };
Signature · 1 line
2.7.4
PATCH v5 15/21 eal/soc: add default scan for Soc devices
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Default implementation which scans the sysfs platform devices hierarchy. For each device, extract the ueven and convert into rte_soc_device.
The information populated can then be used in probe to match against the drivers registered.
--
v5:
- Update rte_eal_soc_scan to rte_eal_soc_scan_platform_bus
- Fix comments over scan and match functions
--- lib/librte_eal/common/include/rte_soc.h | 16 +- lib/librte_eal/linuxapp/eal/eal_soc.c | 315 ++++++++++++++++++++++++++++++++ 2 files changed, 329 insertions(+), 2 deletions(-)
lib/librte_eal/common/include/rte_soc.h +14 -2
@@ -64,7 +64,10 @@ TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked Q. */TAILQ_HEAD (soc_device_list, rte_soc_device);/**< SoC devices in D-linked Q. */ struct rte_soc_id { -const char *compatible;/**< OF compatible specification */ +union { +const char *compatible;/**< OF compatible specification */ +char *_compatible; + };uint64_t priv_data;/**< SoC Driver specific data */ };
@@ -200,7 +203,16 @@ rte_eal_parse_soc_spec(const char *spec, struct rte_soc_addr *addr) }/** -* Default function for matching the Soc driver with device. Each driver can +* Helper function for scanning for new SoC devices on platform bus. +* +* @return +* 0 on success +* !0 on failure to scan +*/ +int rte_eal_soc_scan_platform_bus (void ); + +/** +* Helper function for matching the Soc driver with device. Each driver can * either use this function or define their own soc matching function. * This function relies on the compatible string extracted from sysfs. But, * a SoC might have different way of identifying its devices. Such SoC can
lib/librte_eal/linuxapp/eal/eal_soc.c +315 -0
321 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v5 16/21 eal/soc: additional features for SoC
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Additional features introduced:
- Find kernel driver through sysfs bindings
- Dummy implementation for mapping to kernel driver
- DMA coherency value from sysfs
- Numa node number from sysfs
- Support for updating device during probe if already registered
--- lib/librte_eal/common/eal_common_soc.c | 30 ++++++++ lib/librte_eal/common/eal_private.h | 23 ++++++ lib/librte_eal/common/include/rte_soc.h | 28 +++++++ lib/librte_eal/linuxapp/eal/eal_soc.c | 129 ++++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+)
lib/librte_eal/common/eal_common_soc.c +30 -0
@@ -114,6 +114,26 @@ rte_eal_soc_probe_one_driver(struct rte_soc_driver *drv,return ret; } +if (!dev->is_dma_coherent) { +if (!(drv->drv_flags &RTE_SOC_DRV_ACCEPT_NONCC )) { +RTE_LOG (DEBUG ,EAL , +" device is not DMA coherent, skipping\n" ); +return 1 ; + } + } + +if (drv->drv_flags &RTE_SOC_DRV_NEED_MAPPING ) { +/* map resources */ + ret =rte_eal_soc_map_device (dev); +if (ret) +return ret; + }else if (drv->drv_flags &RTE_SOC_DRV_FORCE_UNBIND + &&rte_eal_process_type () ==RTE_PROC_PRIMARY ) { +/* unbind */ +if (soc_unbind_kernel_driver (dev) <0 ) +return -1 ; + } + dev->driver = drv;RTE_VERIFY (drv->probe !=NULL );return drv->probe (drv, dev);
@@ -166,6 +186,10 @@ rte_eal_soc_detach_dev(struct rte_soc_driver *drv,if (drv->remove && (drv->remove (dev) <0 ))return -1 ;/* negative value is an error */ +if (drv->drv_flags &RTE_SOC_DRV_NEED_MAPPING ) +/* unmap resources for devices */ +rte_eal_soc_unmap_device (dev); +/* clear driver structure */ dev->driver =NULL ;
@@ -241,6 +265,12 @@ rte_eal_soc_probe_one(const struct rte_soc_addr *addr)if (addr ==NULL )return -1 ; +/* update current SoC device in global list, kernel bindings might have +* changed since last time we looked at it. +*/ +if (soc_update_device (addr) <0 ) + goto err_return; + TAILQ_FOREACH(dev, &soc_device_list, next) {if (rte_eal_compare_soc_addr (&dev->addr, addr))continue ;
lib/librte_eal/common/eal_private.h +23 -0
@@ -159,6 +159,29 @@ int pci_update_device(const struct rte_pci_addr *addr);int pci_unbind_kernel_driver (struct rte_pci_device *dev);/** +* Update a soc device object by asking the kernel for the latest information. +* +* This function is private to EAL. +* +* @param addr +* The SoC address to look for +* @return +* - 0 on success. +* - negative on error. +*/ +int soc_update_device (const struct rte_soc_addr *addr); + +/** +* Unbind kernel driver for this device +* +* This function is private to EAL. +* +* @return +* 0 on success, negative on error +*/ +int soc_unbind_kernel_driver (struct rte_soc_device *dev); + +/** * Map the PCI resource of a PCI device in virtual memory * * This function is private to EAL.
lib/librte_eal/common/include/rte_soc.h +28 -0
@@ -46,9 +46,11 @@ extern "C" {#include <stdio.h> #include <stdlib.h> +#include <sys/queue.h> #include <stdint.h> #include <inttypes.h> #include <string.h> +#include <limits.h> #include <rte_dev.h> #include <rte_eal.h>
@@ -63,6 +65,14 @@ extern struct soc_device_list soc_device_list;TAILQ_HEAD (soc_driver_list, rte_soc_driver);/**< SoC drivers in D-linked Q. */ TAILQ_HEAD (soc_device_list, rte_soc_device);/**< SoC devices in D-linked Q. */ +#define SOC_MAX_RESOURCE 6 + +struct rte_soc_resource { +uint64_t phys_addr; +uint64_t len; +void *addr; +}; +struct rte_soc_id {union {const char *compatible;/**< OF compatible specification */
@@ -84,8 +94,12 @@ struct rte_soc_device {struct rte_device device;/**< Inherit code device */ struct rte_soc_addr addr;/**< SoC device Location */ struct rte_soc_id *id;/**< SoC device ID list */ +struct rte_soc_resource mem_resource[SOC_MAX_RESOURCE ];struct rte_intr_handle intr_handle;/**< Interrupt handle */ struct rte_soc_driver *driver;/**< Associated driver */ +int numa_node;/**< NUMA node connection */ +int is_dma_coherent;/**< DMA coherent device */ +enum rte_kernel_driver kdrv;/**< Kernel driver */ };struct rte_soc_driver ;
@@ -139,6 +153,8 @@ struct rte_soc_driver {#define RTE_SOC_DRV_INTR_LSC 0x0008/** Device driver supports detaching capability */ #define RTE_SOC_DRV_DETACHABLE 0x0010 +/** Device driver accepts DMA non-coherent devices */ +#define RTE_SOC_DRV_ACCEPT_NONCC 0x0020/** * Utility function to write a SoC device name, this device name can later be
@@ -256,6 +272,18 @@ int rte_eal_soc_probe_one(const struct rte_soc_addr *addr);int rte_eal_soc_detach (const struct rte_soc_addr *addr);/** +* Map SoC device resources into userspace. +* +* This is called by the EAL if (drv_flags & RTE_SOC_DRV_NEED_MAPPING). +*/ +int rte_eal_soc_map_device (struct rte_soc_device *dev); + +/** +* Unmap the device resources. +*/ +void rte_eal_soc_unmap_device (struct rte_soc_device *dev); + +/** * Dump discovered SoC devices. * * @param f
lib/librte_eal/linuxapp/eal/eal_soc.c +129 -0
159 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v5 17/21 ether: utilize container_of for pci_drv
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
It is not necessary to place the rte_pci_driver at the beginning of the rte_eth_dev struct anymore as we use the container_of macro to get the parent pointer.
--- lib/librte_ether/rte_ethdev.c | 4 ++-- lib/librte_ether/rte_ethdev.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/librte_ether/rte_ethdev.c +2 -2
@@ -241,7 +241,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,int diag; - eth_drv = (struct eth_driver *)pci_drv; + eth_drv = container_of(pci_drv, struct eth_driver, pci_drv);rte_eal_pci_device_name (&pci_dev->addr, ethdev_name,sizeof (ethdev_name));
@@ -302,7 +302,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)if (eth_dev ==NULL )return -ENODEV ; - eth_drv = (const struct eth_driver *)pci_dev->driver; + eth_drv = container_of(pci_dev->driver, struct eth_driver, pci_drv);/* Invoke PMD device uninit function */ if (*eth_drv->eth_dev_uninit) {
lib/librte_ether/rte_ethdev.h +1 -1
@@ -1850,7 +1850,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev);* Each Ethernet driver acts as a PCI driver and is represented by a generic * *eth_driver* structure that holds: * -* - An *rte_pci_driver* structure (which must be the first field). +* - An *rte_pci_driver* structure. * * - The *eth_dev_init* function invoked for each matching PCI device. *
Signature · 1 line
2.7.4
PATCH v5 18/21 ether: verify we copy info from a PCI device
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Now that different types of ethdev exist, check for presence of PCI dev while copying out the info.
Similar would be done for SoC.
--- lib/librte_ether/rte_ethdev.c | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_ether/rte_ethdev.c +2 -0
@@ -3205,6 +3205,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dereturn ; } +RTE_VERIFY (eth_dev->pci_dev !=NULL ); + eth_dev->data->dev_flags =0 ;if (pci_dev->driver->drv_flags &RTE_PCI_DRV_INTR_LSC ) eth_dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC ;
Signature · 1 line
2.7.4
PATCH v5 19/21 ether: extract function eth_dev_get_intr_handle
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
We abstract access to the intr_handle here as we want to get it either from the pci_dev or soc_dev.
--- lib/librte_ether/rte_ethdev.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +12 -2
@@ -2531,6 +2531,16 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,rte_spinlock_unlock (&rte_eth_dev_cb_lock); } +static inline +struct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) +{ +if (dev->pci_dev) +return &dev->pci_dev->intr_handle; + +RTE_ASSERT (0 ); +return NULL ; +} +int rte_eth_dev_rx_intr_ctl (uint8_t port_id,int epfd,int op,void *data) {
@@ -2543,7 +2553,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - intr_handle = &dev->pci_dev->intr_handle; + intr_handle =eth_dev_get_intr_handle (dev);if (!intr_handle->intr_vec) {RTE_PMD_DEBUG_TRACE ("RX Intr vector unset\n" );return -EPERM ;
@@ -2603,7 +2613,7 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,return -EINVAL ; } - intr_handle = &dev->pci_dev->intr_handle; + intr_handle =eth_dev_get_intr_handle (dev);if (!intr_handle->intr_vec) {RTE_PMD_DEBUG_TRACE ("RX Intr vector unset\n" );return -EPERM ;
Signature · 1 line
2.7.4
PATCH v5 20/21 ether: introduce ethernet dev probe remove
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_ether/rte_ethdev.c | 148 +++++++++++++++++++++++++++++++++++++++++- lib/librte_ether/rte_ethdev.h | 31 +++++++++ 2 files changed, 177 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +146 -2
@@ -325,6 +325,101 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev) }int +rte_eth_dev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev) +{ +struct eth_driver *eth_drv; +struct rte_eth_dev *eth_dev; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; + +int diag; + + eth_drv = container_of(soc_drv, struct eth_driver, soc_drv); + +rte_eal_soc_device_name (&soc_dev->addr, ethdev_name, +sizeof (ethdev_name)); + + eth_dev =rte_eth_dev_allocate (ethdev_name); +if (eth_dev ==NULL ) +return -ENOMEM ; + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { + eth_dev->data->dev_private =rte_zmalloc ( +"ethdev private structure" , + eth_drv->dev_private_size, +RTE_CACHE_LINE_SIZE ); +if (eth_dev->data->dev_private ==NULL ) +rte_panic ("Cannot allocate memzone for private port " +"data\n" ); + } + eth_dev->soc_dev = soc_dev; + eth_dev->driver = eth_drv; + eth_dev->data->rx_mbuf_alloc_failed =0 ; + +/* init user callbacks */ +TAILQ_INIT (&(eth_dev->link_intr_cbs)); + +/* +* Set the default MTU. +*/ + eth_dev->data->mtu =ETHER_MTU ; + +/* Invoke PMD device initialization function */ + diag = (*eth_drv->eth_dev_init)(eth_dev); +if (diag ==0 ) +return 0 ; + +RTE_PMD_DEBUG_TRACE ("driver %s: eth_dev_init(%s) failed\n" , + soc_drv->driver.name, + soc_dev->addr.name); +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (eth_dev->data->dev_private); +rte_eth_dev_release_port (eth_dev); +return diag; +} + +int +rte_eth_dev_soc_remove (struct rte_soc_device *soc_dev) +{ +const struct eth_driver *eth_drv; +struct rte_eth_dev *eth_dev; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +int ret; + +if (soc_dev ==NULL ) +return -EINVAL ; + +rte_eal_soc_device_name (&soc_dev->addr, ethdev_name, +sizeof (ethdev_name)); + + eth_dev =rte_eth_dev_allocated (ethdev_name); +if (eth_dev ==NULL ) +return -ENODEV ; + + eth_drv = container_of(soc_dev->driver, struct eth_driver, soc_drv); + +/* Invoke PMD device uninit function */ +if (*eth_drv->eth_dev_uninit) { + ret = (*eth_drv->eth_dev_uninit)(eth_dev); +if (ret) +return ret; + } + +/* free ether device */ +rte_eth_dev_release_port (eth_dev); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (eth_dev->data->dev_private); + + eth_dev->soc_dev =NULL ; + eth_dev->driver =NULL ; + eth_dev->data =NULL ; + +return 0 ; +} + + +int rte_eth_dev_is_valid_port (uint8_t port_id) { if (port_id >= RTE_MAX_ETHPORTS ||
@@ -1557,6 +1652,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)RTE_FUNC_PTR_OR_RET (*dev->dev_ops->dev_infos_get); (*dev->dev_ops->dev_infos_get)(dev, dev_info); dev_info->pci_dev = dev->pci_dev; + dev_info->soc_dev = dev->soc_dev; dev_info->driver_name = dev->data->drv_name; dev_info->nb_rx_queues = dev->data->nb_rx_queues; dev_info->nb_tx_queues = dev->data->nb_tx_queues;
@@ -2534,8 +2630,15 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,static inline struct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) { -if (dev->pci_dev) +if (dev->pci_dev) { +RTE_ASSERT (dev->soc_dev ==NULL );return &dev->pci_dev->intr_handle; + } + +if (dev->soc_dev) { +RTE_ASSERT (dev->pci_dev ==NULL ); +return &dev->soc_dev->intr_handle; + }RTE_ASSERT (0 );return NULL ;
@@ -2572,6 +2675,23 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)return 0 ; } +static inline +const char *eth_dev_get_driver_name (const struct rte_eth_dev *dev) +{ +if (dev->pci_dev) { +RTE_ASSERT (dev->soc_dev ==NULL ); +return dev->driver->pci_drv.driver.name; + } + +if (dev->soc_dev) { +RTE_ASSERT (dev->pci_dev ==NULL ); +return dev->driver->soc_drv.driver.name; + } + +RTE_ASSERT (0 ); +return NULL ; +} +const struct rte_memzone * rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, size_t size, unsigned align,
@@ -2579,9 +2699,11 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, {char z_name[RTE_MEMZONE_NAMESIZE ];const struct rte_memzone *mz; +const char *drv_name; + drv_name =eth_dev_get_driver_name (dev);snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->driver->pci_drv.driver.name, ring_name, + drv_name, ring_name, dev->data->port_id, queue_id); mz =rte_memzone_lookup (z_name);
@@ -3228,6 +3350,28 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de eth_dev->data->drv_name = pci_dev->driver->driver.name; } +void +rte_eth_copy_soc_info (struct rte_eth_dev *eth_dev, +struct rte_soc_device *soc_dev) +{ +if ((eth_dev ==NULL ) || (soc_dev ==NULL )) { +RTE_PMD_DEBUG_TRACE ("NULL pointer eth_dev=%p soc_dev=%p\n" , + eth_dev, soc_dev); +return ; + } + +RTE_ASSERT (eth_dev->soc_dev !=NULL ); + + eth_dev->data->dev_flags =0 ; +if (soc_dev->driver->drv_flags &RTE_SOC_DRV_INTR_LSC ) + eth_dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC ; +if (soc_dev->driver->drv_flags &RTE_SOC_DRV_DETACHABLE ) + eth_dev->data->dev_flags |=RTE_ETH_DEV_DETACHABLE ; + + eth_dev->data->numa_node = soc_dev->device.numa_node; + eth_dev->data->drv_name = soc_dev->driver->driver.name; +} +int rte_eth_dev_l2_tunnel_eth_type_conf (uint8_t port_id,struct rte_eth_l2_tunnel_conf *l2_tunnel)
lib/librte_ether/rte_ethdev.h +31 -0
@@ -180,6 +180,7 @@ extern "C" {#include <rte_log.h> #include <rte_interrupts.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_dev.h> #include <rte_devargs.h> #include "rte_ether.h"
@@ -877,6 +878,7 @@ struct rte_eth_conf {*/ struct rte_eth_dev_info {struct rte_pci_device *pci_dev;/**< Device PCI information. */ +struct rte_soc_device *soc_dev;/**< Device SoC information. */ const char *driver_name;/**< Device Driver name. */ unsigned int if_index;/**< Index to bound host interface, or 0 if none. Use if_indextoname() to translate into an interface name. */
@@ -1626,6 +1628,7 @@ struct rte_eth_dev {const struct eth_driver *driver;/**< Driver for this device */ const struct eth_dev_ops *dev_ops;/**< Functions exported by PMD */ struct rte_pci_device *pci_dev;/**< PCI info. supplied by probing */ +struct rte_soc_device *soc_dev;/**< SoC info. supplied by probing */ /** User application callbacks for NIC interrupts */ struct rte_eth_dev_cb_list link_intr_cbs;/**
@@ -1860,6 +1863,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev);*/ struct eth_driver {struct rte_pci_driver pci_drv;/**< The PMD is also a PCI driver. */ +struct rte_soc_driver soc_drv;/**< The PMD is also a SoC driver. */ eth_dev_init_t eth_dev_init;/**< Device init function. */ eth_dev_uninit_t eth_dev_uninit;/**< Device uninit function. */ unsigned int dev_private_size;/**< Size of device private data. */
@@ -4262,6 +4266,20 @@ void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev);/** +* Copy SoC device info to the Ethernet device data. +* +* @param eth_dev +* The *eth_dev* pointer is the address of the *rte_eth_dev* structure. +* @param soc_dev +* The *soc_dev* pointer is the address of the *rte_soc_device* structure. +* +* @return +* - 0 on success, negative on error +*/ +void rte_eth_copy_soc_info (struct rte_eth_dev *eth_dev, +struct rte_soc_device *soc_dev); + +/** * Create memzone for HW rings. * malloc can't be used as the physical address is needed. * If the memzone is already created, then this function returns a ptr
@@ -4376,6 +4394,19 @@ int rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,*/ int rte_eth_dev_pci_remove (struct rte_pci_device *pci_dev); +/** +* Wrapper for use by SoC drivers as a .devinit function to attach to a ethdev +* interface. +*/ +int rte_eth_dev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev); + +/** +* Wrapper for use by SoC drivers as a .devuninit function to detach a ethdev +* interface. +*/ +int rte_eth_dev_soc_remove (struct rte_soc_device *soc_dev); + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH v5 21/21 eal/crypto: Support rte_soc_driver/device for cryptodev
In reply to Shreyansh Jain- rte_cryptodev_driver/rte_cryptodev_dev embeds rte_soc_driver/device for linking SoC PMDs to crypto devices.
- Add probe and remove functions linked
--- lib/librte_cryptodev/rte_cryptodev.c | 122 ++++++++++++++++++++++++- lib/librte_cryptodev/rte_cryptodev.h | 3 + lib/librte_cryptodev/rte_cryptodev_pmd.h | 18 +++- lib/librte_cryptodev/rte_cryptodev_version.map | 2 + 4 files changed, 140 insertions(+), 5 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +118 -4
@@ -422,7 +422,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,int retval; - cryptodrv = (struct rte_cryptodev_driver *)pci_drv; + cryptodrv = container_of(pci_drv, struct rte_cryptodev_driver, + pci_drv);if (cryptodrv ==NULL )return -ENODEV ;
@@ -489,7 +490,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)if (cryptodev ==NULL )return -ENODEV ; - cryptodrv = (const struct rte_cryptodev_driver *)pci_dev->driver; + cryptodrv = container_of(pci_dev->driver, struct rte_cryptodev_driver, + pci_drv);if (cryptodrv ==NULL )return -ENODEV ;
@@ -513,6 +515,111 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)return 0 ; } + +int +rte_cryptodev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev) +{ +struct rte_cryptodev_driver *cryptodrv; +struct rte_cryptodev *cryptodev; + +char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN ]; + +int retval; + + cryptodrv = container_of(soc_drv, struct rte_cryptodev_driver, + soc_drv); + +rte_eal_soc_device_name (&soc_dev->addr, cryptodev_name, +sizeof (cryptodev_name)); + + cryptodev =rte_cryptodev_pmd_allocate (cryptodev_name, +rte_socket_id ()); +if (cryptodev ==NULL ) +return -ENOMEM ; + + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { + cryptodev->data->dev_private = +rte_zmalloc_socket ( +"cryptodev private structure" , + cryptodrv->dev_private_size, +RTE_CACHE_LINE_SIZE , +rte_socket_id ()); + +if (cryptodev->data->dev_private ==NULL ) +rte_panic ("Cannot allocate memzone for private " +"device data" ); + } + + cryptodev->soc_dev = soc_dev; + cryptodev->driver = cryptodrv; + +/* init user callbacks */ +TAILQ_INIT (&(cryptodev->link_intr_cbs)); + +/* Invoke PMD device initialization function */ + retval = (*cryptodrv->cryptodev_init)(cryptodrv, cryptodev); +if (retval ==0 ) +return 0 ; + +CDEV_LOG_ERR ("driver %s: cryptodev_init(%s) failed\n" , + soc_drv->driver.name, + soc_dev->addr.name); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (cryptodev->data->dev_private); + + cryptodev->attached =RTE_CRYPTODEV_DETACHED ; + cryptodev_globals.nb_devs--; + +return -ENXIO ; +} + +int +rte_cryptodev_soc_remove (struct rte_soc_device *soc_dev) +{ +const struct rte_cryptodev_driver *cryptodrv; +struct rte_cryptodev *cryptodev; +char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN ]; +int ret; + +if (soc_dev ==NULL ) +return -EINVAL ; + +rte_eal_soc_device_name (&soc_dev->addr, cryptodev_name, +sizeof (cryptodev_name)); + + cryptodev =rte_cryptodev_pmd_get_named_dev (cryptodev_name); +if (cryptodev ==NULL ) +return -ENODEV ; + + cryptodrv =container_of (soc_dev->driver, + struct rte_cryptodev_driver, soc_drv); +if (cryptodrv ==NULL ) +return -ENODEV ; + +/* Invoke PMD device uninit function */ +if (*cryptodrv->cryptodev_uninit) { + ret = (*cryptodrv->cryptodev_uninit)(cryptodrv, cryptodev); +if (ret) +return ret; + } + +/* free crypto device */ +rte_cryptodev_pmd_release_device (cryptodev); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (cryptodev->data->dev_private); + + cryptodev->pci_dev =NULL ; + cryptodev->soc_dev =NULL ; + cryptodev->driver =NULL ; + cryptodev->data =NULL ; + +return 0 ; +} +uint16_t rte_cryptodev_queue_pair_count (uint8_t dev_id) {
@@ -868,8 +975,15 @@ rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info) (*dev->dev_ops->dev_infos_get)(dev, dev_info); dev_info->pci_dev = dev->pci_dev; -if (dev->driver) - dev_info->driver_name = dev->driver->pci_drv.driver.name; + dev_info->soc_dev = dev->soc_dev; +if (dev->driver) { +if (dev->soc_dev) + dev_info->driver_name + = dev->driver->soc_drv.driver.name; +else + dev_info->driver_name + = dev->driver->pci_drv.driver.name; + } }
lib/librte_cryptodev/rte_cryptodev.h +3 -0
@@ -244,6 +244,7 @@ struct rte_cryptodev_info {const char *driver_name;/**< Driver name. */ enum rte_cryptodev_type dev_type;/**< Device type */ struct rte_pci_device *pci_dev;/**< PCI information. */ +struct rte_soc_device *soc_dev;/**< SoC information. */ uint64_t feature_flags;/**< Feature flags */
@@ -623,6 +624,8 @@ struct rte_cryptodev {/**< Supported features */ struct rte_pci_device *pci_dev;/**< PCI info. supplied by probing */ +struct rte_soc_device *soc_dev; +/**< SoC info. supplied by probing/Scanning */ enum rte_cryptodev_type dev_type;/**< Crypto device type */
lib/librte_cryptodev/rte_cryptodev_pmd.h +17 -1
@@ -48,6 +48,7 @@ extern "C" {#include <rte_dev.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_malloc.h> #include <rte_mbuf.h> #include <rte_mempool.h>
@@ -131,7 +132,8 @@ typedef int (*cryptodev_uninit_t)(const struct rte_cryptodev_driver *drv,* - The size of the private data to allocate for each matching device. */ struct rte_cryptodev_driver { -struct rte_pci_driver pci_drv;/**< The PMD is also a PCI driver. */ +struct rte_pci_driver pci_drv;/**< The PMD is PCI type driver. */ +struct rte_soc_driver soc_drv;/**< The PMD is SoC type driver. */ unsigned dev_private_size;/**< Size of device private data. */ cryptodev_init_t cryptodev_init;/**< Device init function. */
@@ -519,6 +521,20 @@ int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,*/ int rte_cryptodev_pci_remove (struct rte_pci_device *pci_dev); +/** +* Wrapper for use by SoC drivers as a .devinit function to attach to a +* cryptodev interface. +*/ +int rte_cryptodev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev); + +/** +* Wrapper for use by SoC drivers as a .devuninit function to detach a +* cryptodev interface. +*/ +int rte_cryptodev_soc_remove (struct rte_soc_device *soc_dev); + + #ifdef __cplusplus }#endif
lib/librte_cryptodev/rte_cryptodev_version.map +2 -0
@@ -44,5 +44,7 @@ DPDK_16.11 { rte_cryptodev_pci_probe; rte_cryptodev_pci_remove; + rte_cryptodev_soc_probe; + rte_cryptodev_soc_remove; } DPDK_16.07;
Signature · 1 line
2.7.4
v6 cover Introduce SoC device/driver framework for EAL
In reply to Shreyansh JainIntroduction:
=============
This patch set is direct derivative of Jan's original series [1],[2].
- This version is based on master HEAD (ca41215)
- In this, I am merging the series [11] back. It was initially part of this set but I had split considering that those changes in PCI were good standalone as well. But, 1) not much feedback was avail- able and 2) this patchset is a use-case for those patches making it easier to review. Just like what Jan had intended in original series.
- SoC support is not enabled by default. It needs the 'enable-soc' toggle on command line. This is primarily because this patchset is still experimental and we would like to keep it isolated from non-SoC ops. Though, it does impact the ABI.
Aim:
====
As of now EAL is primarly focused on PCI initialization/probing.
rte_eal_init()
|- rte_eal_pci_init(): Find PCI devices from sysfs |- ... |- rte_eal_memzone_init() |- ...
`- rte_eal_pci_probe(): Driver<=>Device initialization
This patchset introduces SoC framework which would enable SoC drivers and drivers to be plugged into EAL, very similar to how PCI drivers/devices are done today.
This is a stripped down version of PCI framework which allows the SoC PMDs to implement their own routines for detecting devices and linking devices to drivers.
1) Changes to EAL
rte_eal_init()
|- rte_eal_pci_init(): Find PCI devices from sysfs |- rte_eal_soc_init(): Calls PMDs->scan_fn |- ... |- rte_eal_memzone_init() |- ... |- rte_eal_pci_probe(): Driver<=>Device initialization, PMD->devinit()
`- rte_eal_soc_probe(): Calls PMDs->match_fn and PMDs->devinit();
2) New device/driver structures:
- rte_soc_driver (inheriting rte_driver)
- rte_soc_device (inheriting rte_device)
- rte_eth_dev and eth_driver embedded rte_soc_device and rte_soc_driver, respectively.
3) The SoC PMDs need to:
- define rte_soc_driver with necessary scan and match callbacks
- Register themselves using DRIVER_REGISTER_SOC()
- Implement respective bus scanning in the scan callbacks to add necessary devices to SoC device list
- Implement necessary eth_dev_init/uninint for ethernet instances
4) Design considerations that are same as PCI:
- SoC initialization is being done through rte_eal_init(), just after PCI initialization is done.
- As in case of PCI, probe is done after rte_eal_pci_probe() to link the devices detected with the drivers registered.
- Device attach/detach functions are available and have been designed on the lines of PCI framework.
- PMDs register using DRIVER_REGISTER_SOC, very similar to DRIVER_REGISTER_PCI for PCI devices.
- Linked list of SoC driver and devices exists independent of the other driver/device list, but inheriting rte_driver/rte_driver, these are also part of a global list.
5) Design considerations that are different from PCI:
- Each driver implements its own scan and match function. PCI uses the BDF format to read the device from sysfs, but this _may_not_ be a case for a SoC ethernet device.
= This is an important change from initial proposal by Jan in [2]. Unlike his attempt to use /sys/bus/platform, this patch relies on the PMD to detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have embedded devices/MACs which require initialization which cannot be covered through sysfs parsing.
`-> Point (6) below is a side note to above.
= PCI based PMDs rely on EAL's capability to detect devices. This proposal puts the onus on PMD to detect devices, add to soc_device_list and wait for Probe. Matching, of device<=>driver is again PMD's callback.
6) Adding default scan and match helpers for PMDs
- The design warrrants the PMDs implement their own scan of devices on bus, and match routines for probe implementation.
This patch introduces helpers which can be used by PMDs for scan of the platform bus and matching devices against the compatible string extracted from the scan.
- Intention is to make it easier to integrate known SoC which expose platform bus compliant information (compat, sys/bus/platform...).
- PMDs which have deviations from this standard model can implement and hook their bus scanning and probe match callbacks while registering driver.
Patchset Overview:
==================
- Patches 0001~0004 are from [11] - moving some PCI specific functions and definitions to non-PCI area.
- Patches 0005~0008 introduce the base infrastructure and test case
- Patch 0009 is for command line support for no-soc, on lines of no-pci
- Patch 0010 enables EAL to handle SoC type devices
- Patch 0011 adds support for scan and probe callbacks and updates the test framework with relevant test case.
- Patch 0012~0014 enable device argument, driver specific flags and interrupt handling related basic infra. Subsequent patches build up on them.
- Patch 0015~0016 add support for default function which PMDs can use for scanning platform bus. These functions are optional and need to be hooked to by PMDs.
- Patch 0017~0019 makes changes to PCI as well as ethdev code to remove assumption that eth_driver is a PCI driver.
- Patch 0020 adds necessary ethdev probe/remove functions for PMDs to use
- Patch 0021 adds support for SoC driver/devices, along with probe/remove functions for Cryptodev devices.
Future/Pending Changes:
=======================
- Device whitelisting/blacklist still relies on command line '-b' and '-c' which are internally implemented using OPT_PCI_BLACKLIST/OPT_PCI_WHITELIST. This needs to be changed to a generic form - OPT_DEV_*LIST - probably.
- No cryptodriver currently uses SoC framework - probably a example driver can be created to demonstrate usage.
- test case for enable-soc command line parameter
- This patch impacts a couple of ABIs (rte_device/driver) and thus require a patch for bump of libraries (if need be) and documentation.
[1] http://dpdk.org/ml/archives/dev/2016-January/030915.html
[2] http://www.dpdk.org/ml/archives/dev/2016-May/038486.html
[3] http://dpdk.org/ml/archives/dev/2016-August/045707.html
[4] http://dpdk.org/ml/archives/dev/2016-May/038948.html
[5] http://dpdk.org/ml/archives/dev/2016-May/038953.html
[6] http://dpdk.org/ml/archives/dev/2016-May/038487.html
[7] http://dpdk.org/ml/archives/dev/2016-May/038488.html
[8] http://dpdk.org/ml/archives/dev/2016-May/038489.html
[9] http://dpdk.org/ml/archives/dev/2016-May/038491.html
[10] http://dpdk.org/ml/archives/dev/2016-September/046256.html
[11] http://dpdk.org/ml/archives/dev/2016-October/048915.html
Changes since v5:
- fix devinit/devuninit name change; it was in wrong patch
- rebased over HEAD (ca41215)
- Update to pending section of coverletter
Changes since v4:
- change name of rte_eal_soc_scan function name to rte_eal_soc_scan_platform_bus. This still remains a helper function.
- Fix comments over scan and match functions
Changes since v3:
- rebasing over HEAD (fed622df tag: v16.11-rc1)
- Add support for default scan function; PMD can use this for scanning on platform bus.
- Support for kernel driver bind/unbind, numa and DMA from Jan's original patches.
- SoC is disabled by default. '--enable-soc' command line parameter enables it. doc updated.
- Updated testcase function names and comments
- Map file addition alphabetically ordered
- Patch author corrected
Changes since v2:
- Rebasing over rte_driver/device patchset v9 [10]
- Added cryptodev support for SoC
- Default match function for SoC device<=>Driver
- Some variables renamed to reflect 'drv' rather than 'dr'
Change since v1 [2]:
- Removed patch 1-5 which were for generalizing some PCI specific routines into EAL. These patches are good-to-have but not directly linked to SoC and hence would be proposed separately.
- Removed support for sysfs parsing (patches 6~9)
- Rebasing over the recent (v8) version of rte_driver/device patchset
- Rebasing over master (16.07)
- Changes to various map file to change API intro to 16.11 from 16.07
Jan Viktorin (19):
eal: generalize PCI kernel driver enum to EAL
eal: generalize PCI map/unmap resource to EAL eal/linux: generalize PCI kernel unbinding driver to EAL eal/linux: generalize PCI kernel driver extraction to EAL
eal: define container macro
eal/soc: introduce very essential SoC infra definitions eal/soc: add SoC PMD register/unregister logic eal/soc: implement SoC device list and dump
eal: introduce command line enable SoC option eal/soc: init SoC infra from EAL
eal/soc: extend and utilize devargs
eal/soc: add drv_flags
eal/soc: add intr_handle
eal/soc: add default scan for Soc devices eal/soc: additional features for SoC
ether: utilize container_of for pci_drv
ether: verify we copy info from a PCI device
ether: extract function eth_dev_get_intr_handle
ether: introduce ethernet dev probe remove
Shreyansh Jain (2):
eal/soc: implement probing of drivers eal/crypto: Support rte_soc_driver/device for cryptodev
app/test/Makefile | 1 + app/test/test_soc.c | 404 +++++++++++++++++++ doc/guides/testpmd_app_ug/run_app.rst | 4 + lib/librte_cryptodev/rte_cryptodev.c | 122 +++++- lib/librte_cryptodev/rte_cryptodev.h | 3 + lib/librte_cryptodev/rte_cryptodev_pmd.h | 18 +- lib/librte_cryptodev/rte_cryptodev_version.map | 2 + lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/eal.c | 18 + lib/librte_eal/bsdapp/eal/eal_pci.c | 6 +- lib/librte_eal/bsdapp/eal/eal_soc.c | 46 +++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 11 + lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_dev.c | 66 ++- lib/librte_eal/common/eal_common_devargs.c | 17 + lib/librte_eal/common/eal_common_options.c | 5 + lib/librte_eal/common/eal_common_pci.c | 39 -- lib/librte_eal/common/eal_common_pci_uio.c | 16 +- lib/librte_eal/common/eal_common_soc.c | 368 +++++++++++++++++ lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/common/eal_options.h | 2 + lib/librte_eal/common/eal_private.h | 64 +++ lib/librte_eal/common/include/rte_common.h | 18 + lib/librte_eal/common/include/rte_dev.h | 44 ++ lib/librte_eal/common/include/rte_devargs.h | 8 + lib/librte_eal/common/include/rte_pci.h | 41 -- lib/librte_eal/common/include/rte_soc.h | 322 +++++++++++++++ lib/librte_eal/linuxapp/eal/Makefile | 2 + lib/librte_eal/linuxapp/eal/eal.c | 63 +++ lib/librte_eal/linuxapp/eal/eal_pci.c | 62 +-- lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 5 +- lib/librte_eal/linuxapp/eal/eal_soc.c | 515 ++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 11 + lib/librte_ether/rte_ethdev.c | 166 +++++++- lib/librte_ether/rte_ethdev.h | 33 +- 36 files changed, 2343 insertions(+), 165 deletions(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/bsdapp/eal/eal_soc.c create mode 100644 lib/librte_eal/common/eal_common_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.h create mode 100644 lib/librte_eal/linuxapp/eal/eal_soc.c
Signature · 1 line
2.7.4
PATCH v6 1/21 eal: generalize PCI kernel driver enum to EAL
From: Jan Viktorin <[email protected]>
--
Changes since v0:
- fix compilation error due to missing include
--- lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++ lib/librte_eal/common/include/rte_pci.h | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
@@ -109,6 +109,18 @@ struct rte_mem_resource {void *addr;/**< Virtual address, NULL when not mapped. */ }; +/** +* Kernel driver passthrough type +*/ +enum rte_kernel_driver { +RTE_KDRV_UNKNOWN =0 , +RTE_KDRV_IGB_UIO , +RTE_KDRV_VFIO , +RTE_KDRV_UIO_GENERIC , +RTE_KDRV_NIC_UIO , +RTE_KDRV_NONE , +}; +/** Double linked list of device drivers. */ TAILQ_HEAD (rte_driver_list, rte_driver);/** Double linked list of devices. */
lib/librte_eal/common/include/rte_pci.h +0 -9
@@ -135,15 +135,6 @@ struct rte_pci_addr {struct rte_devargs ; -enum rte_kernel_driver { -RTE_KDRV_UNKNOWN =0 , -RTE_KDRV_IGB_UIO , -RTE_KDRV_VFIO , -RTE_KDRV_UIO_GENERIC , -RTE_KDRV_NIC_UIO , -RTE_KDRV_NONE , -}; -/** * A structure describing a PCI device. */
Signature · 1 line
2.7.4
PATCH v6 2/21 eal: generalize PCI map/unmap resource to EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
The functions pci_map_resource, pci_unmap_resource are generic so the pci_* prefix can be omitted. The functions are moved to the eal_common_dev.c so they can be reused by other infrastructure.
--- lib/librte_eal/bsdapp/eal/eal_pci.c | 2 +- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++ lib/librte_eal/common/eal_common_dev.c | 39 +++++++++++++++++++++++++ lib/librte_eal/common/eal_common_pci.c | 39 ------------------------- lib/librte_eal/common/eal_common_pci_uio.c | 16 +++++----- lib/librte_eal/common/include/rte_dev.h | 32 ++++++++++++++++++++ lib/librte_eal/common/include/rte_pci.h | 32 -------------------- lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 5 ++-- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++ 10 files changed, 89 insertions(+), 82 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +1 -1
@@ -228,7 +228,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,/* if matching map is found, then use it */ offset = res_idx * pagesz; - mapaddr =pci_map_resource (NULL , fd, (off_t )offset, + mapaddr =rte_eal_map_resource (NULL , fd, (off_t )offset, (size_t )dev->mem_resource[res_idx].len,0 );close (fd);if (mapaddr ==MAP_FAILED )
lib/librte_eal/bsdapp/eal/rte_eal_version.map +2 -0
@@ -170,6 +170,8 @@ DPDK_16.11 { rte_delay_us_callback_register; rte_eal_dev_attach; rte_eal_dev_detach; + rte_eal_map_resource; + rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister;
lib/librte_eal/common/eal_common_dev.c +39 -0
@@ -36,6 +36,7 @@#include <string.h> #include <inttypes.h> #include <sys/queue.h> +#include <sys/mman.h> #include <rte_dev.h> #include <rte_devargs.h>
@@ -151,3 +152,41 @@ err:RTE_LOG (ERR ,EAL ,"Driver cannot detach the device (%s)\n" , name);return -EINVAL ; } + +/* map a particular resource from a file */ +void * +rte_eal_map_resource (void *requested_addr,int fd,off_t offset,size_t size, +int additional_flags) +{ +void *mapaddr; + +/* Map the Memory resource of device */ + mapaddr =mmap (requested_addr, size,PROT_READ |PROT_WRITE , +MAP_SHARED | additional_flags, fd, offset); +if (mapaddr ==MAP_FAILED ) { +RTE_LOG (ERR ,EAL ,"%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s" +" (%p)\n" , __func__, fd, requested_addr, + (unsigned long )size, (unsigned long )offset, +strerror (errno), mapaddr); + }else +RTE_LOG (DEBUG ,EAL ," Device memory mapped at %p\n" , mapaddr); + +return mapaddr; +} + +/* unmap a particular resource */ +void +rte_eal_unmap_resource (void *requested_addr,size_t size) +{ +if (requested_addr ==NULL ) +return ; + +/* Unmap the Memory resource of device */ +if (munmap (requested_addr, size)) { +RTE_LOG (ERR ,EAL ,"%s(): cannot munmap(%p, 0x%lx): %s\n" , + __func__, requested_addr, (unsigned long )size, +strerror (errno)); + }else +RTE_LOG (DEBUG ,EAL ," Device memory unmapped at %p\n" , + requested_addr); +}
lib/librte_eal/common/eal_common_pci.c +0 -39
@@ -67,7 +67,6 @@#include <stdlib.h> #include <stdio.h> #include <sys/queue.h> -#include <sys/mman.h> #include <rte_interrupts.h> #include <rte_log.h>
@@ -114,44 +113,6 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)return NULL ; } -/* map a particular resource from a file */ -void * -pci_map_resource (void *requested_addr,int fd,off_t offset,size_t size, -int additional_flags) -{ -void *mapaddr; - -/* Map the PCI memory resource of device */ - mapaddr =mmap (requested_addr, size,PROT_READ |PROT_WRITE , -MAP_SHARED | additional_flags, fd, offset); -if (mapaddr ==MAP_FAILED ) { -RTE_LOG (ERR ,EAL ,"%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\n" , - __func__, fd, requested_addr, - (unsigned long )size, (unsigned long )offset, -strerror (errno), mapaddr); - }else -RTE_LOG (DEBUG ,EAL ," PCI memory mapped at %p\n" , mapaddr); - -return mapaddr; -} - -/* unmap a particular resource */ -void -pci_unmap_resource (void *requested_addr,size_t size) -{ -if (requested_addr ==NULL ) -return ; - -/* Unmap the PCI memory resource of device */ -if (munmap (requested_addr, size)) { -RTE_LOG (ERR ,EAL ,"%s(): cannot munmap(%p, 0x%lx): %s\n" , - __func__, requested_addr, (unsigned long )size, -strerror (errno)); - }else -RTE_LOG (DEBUG ,EAL ," PCI memory unmapped at %p\n" , - requested_addr); -} -/* * If vendor/device ID match, call the probe() function of the * driver.
lib/librte_eal/common/eal_common_pci_uio.c +9 -7
@@ -75,9 +75,11 @@ pci_uio_map_secondary(struct rte_pci_device *dev)return -1 ; } -void *mapaddr =pci_map_resource (uio_res->maps[i].addr, - fd, (off_t )uio_res->maps[i].offset, - (size_t )uio_res->maps[i].size,0 ); +void *mapaddr =rte_eal_map_resource ( + uio_res->maps[i].addr, fd, + (off_t )uio_res->maps[i].offset, + (size_t )uio_res->maps[i].size, +0 );/* fd is not needed in slave process, close it */ close (fd);if (mapaddr != uio_res->maps[i].addr) {
@@ -88,11 +90,11 @@ pci_uio_map_secondary(struct rte_pci_device *dev)if (mapaddr !=MAP_FAILED ) {/* unmap addrs correctly mapped */ for (j =0 ; j < i; j++) -pci_unmap_resource ( +rte_eal_unmap_resource ( uio_res->maps[j].addr, (size_t )uio_res->maps[j].size);/* unmap addr wrongly mapped */ -pci_unmap_resource (mapaddr, +rte_eal_unmap_resource (mapaddr, (size_t )uio_res->maps[i].size); }return -1 ;
@@ -150,7 +152,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)return 0 ; error:for (i =0 ; i < map_idx; i++) { -pci_unmap_resource (uio_res->maps[i].addr, +rte_eal_unmap_resource (uio_res->maps[i].addr, (size_t )uio_res->maps[i].size);rte_free (uio_res->maps[i].path); }
@@ -167,7 +169,7 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res)return ;for (i =0 ; i != uio_res->nb_maps; i++) { -pci_unmap_resource (uio_res->maps[i].addr, +rte_eal_unmap_resource (uio_res->maps[i].addr, (size_t )uio_res->maps[i].size);if (rte_eal_process_type () ==RTE_PROC_PRIMARY )rte_free (uio_res->maps[i].path);
lib/librte_eal/common/include/rte_dev.h +32 -0
@@ -235,6 +235,38 @@ int rte_eal_dev_attach(const char *name, const char *devargs);*/ int rte_eal_dev_detach (const char *name); +/* +* @internal +* Map a particular resource from a file. +* +* @param requested_addr +* The starting address for the new mapping range. +* @param fd +* The file descriptor. +* @param offset +* The offset for the mapping range. +* @param size +* The size for the mapping range. +* @param additional_flags +* The additional flags for the mapping range. +* @return +* - On success, the function returns a pointer to the mapped area. +* - On error, the value MAP_FAILED is returned. +*/ +void *rte_eal_map_resource (void *requested_addr,int fd,off_t offset, +size_t size,int additional_flags); + +/** +* @internal +* Unmap a particular resource. +* +* @param requested_addr +* The address for the unmapping range. +* @param size +* The size for the unmapping range. +*/ +void rte_eal_unmap_resource (void *requested_addr,size_t size); +#define RTE_PMD_EXPORT_NAME_ARRAY (n, idx) n##idx[]#define RTE_PMD_EXPORT_NAME (name, idx) \
lib/librte_eal/common/include/rte_pci.h +0 -32
@@ -399,38 +399,6 @@ int rte_eal_pci_map_device(struct rte_pci_device *dev);void rte_eal_pci_unmap_device (struct rte_pci_device *dev);/** -* @internal -* Map a particular resource from a file. -* -* @param requested_addr -* The starting address for the new mapping range. -* @param fd -* The file descriptor. -* @param offset -* The offset for the mapping range. -* @param size -* The size for the mapping range. -* @param additional_flags -* The additional flags for the mapping range. -* @return -* - On success, the function returns a pointer to the mapped area. -* - On error, the value MAP_FAILED is returned. -*/ -void *pci_map_resource (void *requested_addr,int fd,off_t offset, -size_t size,int additional_flags); - -/** -* @internal -* Unmap a particular resource. -* -* @param requested_addr -* The address for the unmapping range. -* @param size -* The size for the unmapping range. -*/ -void pci_unmap_resource (void *requested_addr,size_t size); - -/** * Probe the single PCI device. * * Scan the content of the PCI bus, and find the pci device specified by pci
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +1 -1
@@ -347,7 +347,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,if (pci_map_addr ==NULL ) pci_map_addr =pci_find_max_end_va (); - mapaddr =pci_map_resource (pci_map_addr, fd,0 , + mapaddr =rte_eal_map_resource (pci_map_addr, fd,0 , (size_t )dev->mem_resource[res_idx].len,0 );close (fd);if (mapaddr ==MAP_FAILED )
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +3 -2
@@ -465,7 +465,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev)void *map_addr =NULL ;if (memreg[0 ].size) {/* actual map of first part */ - map_addr =pci_map_resource (bar_addr, vfio_dev_fd, + map_addr =rte_eal_map_resource (bar_addr, + vfio_dev_fd, memreg[0 ].offset, memreg[0 ].size,MAP_FIXED );
@@ -477,7 +478,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)void *second_addr =RTE_PTR_ADD (bar_addr, memreg[1 ].offset - (uintptr_t )reg.offset); - map_addr =pci_map_resource (second_addr, + map_addr =rte_eal_map_resource (second_addr, vfio_dev_fd, memreg[1 ].offset, memreg[1 ].size,MAP_FIXED );
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
@@ -174,6 +174,8 @@ DPDK_16.11 { rte_delay_us_callback_register; rte_eal_dev_attach; rte_eal_dev_detach; + rte_eal_map_resource; + rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister;
Signature · 1 line
2.7.4
PATCH v6 3/21 eal/linux: generalize PCI kernel unbinding driver to EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Generalize the PCI-specific pci_unbind_kernel_driver. It is now divided into two parts. First, determination of the path and string identification of the device to be unbound. Second, the actual unbind operation which is generic.
BSD implementation updated as ENOTSUP
--
Changes since v2:
- update BSD support for unbind kernel driver
--- lib/librte_eal/bsdapp/eal/eal.c | 7 +++++++ lib/librte_eal/bsdapp/eal/eal_pci.c | 4 ++-- lib/librte_eal/common/eal_private.h | 13 +++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 26 ++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 33 +++++++++------------------------ 5 files changed, 57 insertions(+), 26 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +7 -0
@@ -633,3 +633,10 @@ rte_eal_process_type(void) {return rte_config.process_type; } + +int +rte_eal_unbind_kernel_driver(const char *devpath __rte_unused, + const char *devid __rte_unused) +{ +return -ENOTSUP ; +}
lib/librte_eal/bsdapp/eal/eal_pci.c +2 -2
@@ -89,11 +89,11 @@/* unbind kernel driver for this device */ int -pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused) +pci_unbind_kernel_driver (struct rte_pci_device *dev) {RTE_LOG (ERR ,EAL ,"RTE_PCI_DRV_FORCE_UNBIND flag is not implemented " "for BSD\n" ); -return -ENOTSUP ; +return rte_eal_unbind_kernel_driver (dev); }/* Map pci device */
lib/librte_eal/common/eal_private.h +13 -0
@@ -256,6 +256,19 @@ int rte_eal_alarm_init(void);int rte_eal_check_module (const char *module_name);/** +* Unbind kernel driver bound to the device specified by the given devpath, +* and its string identification. +* +* @param devpath path to the device directory ("/sys/.../devices/<name>") +* @param devid identification of the device (<name>) +* +* @return +* -1 unbind has failed +* 0 module has been unbound +*/ +int rte_eal_unbind_kernel_driver (const char *devpath,const char *devid); + +/** * Get cpu core_id. * * This function is private to the EAL.
lib/librte_eal/linuxapp/eal/eal.c +26 -0
@@ -943,3 +943,29 @@ rte_eal_check_module(const char *module_name)/* Module has been found */ return 1 ; } + +int +rte_eal_unbind_kernel_driver (const char *devpath,const char *devid) +{ +char filename[PATH_MAX ]; +FILE *f; + +snprintf (filename,sizeof (filename), +"%s/driver/unbind" , devpath); + + f =fopen (filename,"w" ); +if (f ==NULL )/* device was not bound */ +return 0 ; + +if (fwrite (devid,strlen (devid),1 , f) ==0 ) { +RTE_LOG (ERR ,EAL ,"%s(): could not write to %s\n" , __func__, + filename); + goto error; + } + +fclose (f); +return 0 ; +error: +fclose (f); +return -1 ; +}
lib/librte_eal/linuxapp/eal/eal_pci.c +9 -24
@@ -59,38 +59,23 @@ int pci_unbind_kernel_driver(struct rte_pci_device *dev) {int n; -FILE *f; -char filename[PATH_MAX ]; -char buf[BUFSIZ ]; +char devpath[PATH_MAX ]; +char devid[BUFSIZ ];struct rte_pci_addr *loc = &dev->addr; -/* open /sys/bus/pci/devices/AAAA:BB:CC.D/driver */ -snprintf (filename,sizeof (filename), -"%s/" PCI_PRI_FMT "/driver/unbind" ,pci_get_sysfs_path (), +/* devpath /sys/bus/pci/devices/AAAA:BB:CC.D */ +snprintf (devpath,sizeof (devpath), +"%s/" PCI_PRI_FMT ,pci_get_sysfs_path (), loc->domain, loc->bus, loc->devid, loc->function); - f =fopen (filename,"w" ); -if (f ==NULL )/* device was not bound */ -return 0 ; - - n =snprintf (buf,sizeof (buf),PCI_PRI_FMT "\n" , + n =snprintf (devid,sizeof (devid),PCI_PRI_FMT "\n" , loc->domain, loc->bus, loc->devid, loc->function); -if ((n <0 ) || (n >= (int )sizeof (buf))) { +if ((n <0 ) || (n >= (int )sizeof (devid))) {RTE_LOG (ERR ,EAL ,"%s(): snprintf failed\n" , __func__); - goto error; - } -if (fwrite (buf, n,1 , f) ==0 ) { -RTE_LOG (ERR ,EAL ,"%s(): could not write to %s\n" , __func__, - filename); - goto error; +return -1 ; } -fclose (f); -return 0 ; - -error: -fclose (f); -return -1 ; +return rte_eal_unbind_kernel_driver (devpath, devid); } static int
Signature · 1 line
2.7.4
PATCH v6 4/21 eal/linux: generalize PCI kernel driver extraction to EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Generalize the PCI-specific pci_get_kernel_driver_by_path. The function is general enough, we have just moved it to eal.c, changed the prefix to rte_eal and provided it privately to other parts of EAL.
--- lib/librte_eal/bsdapp/eal/eal.c | 7 +++++++ lib/librte_eal/common/eal_private.h | 14 ++++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 29 +++++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 31 +------------------------------ 4 files changed, 51 insertions(+), 30 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +7 -0
@@ -640,3 +640,10 @@ rte_eal_unbind_kernel_driver(const char *devpath __rte_unused, {return -ENOTSUP ; } + +int +rte_eal_get_kernel_driver_by_path(const char *filename __rte_unused, + char *dri_name __rte_unused) +{ +return -ENOTSUP ; +}
lib/librte_eal/common/eal_private.h +14 -0
@@ -269,6 +269,20 @@ int rte_eal_check_module(const char *module_name);int rte_eal_unbind_kernel_driver (const char *devpath,const char *devid);/** +* Extract the kernel driver name from the absolute path to the driver. +* +* @param filename path to the driver ("<path-to-device>/driver") +* @path dri_name target buffer where to place the driver name +* (should be at least PATH_MAX long) +* +* @return +* -1 on failure +* 0 when successful +* 1 when there is no such driver +*/ +int rte_eal_get_kernel_driver_by_path (const char *filename,char *dri_name); + +/** * Get cpu core_id. * * This function is private to the EAL.
lib/librte_eal/linuxapp/eal/eal.c +29 -0
@@ -969,3 +969,32 @@ error:fclose (f);return -1 ; } + +int +rte_eal_get_kernel_driver_by_path (const char *filename,char *dri_name) +{ +int count; +char path[PATH_MAX ]; +char *name; + +if (!filename || !dri_name) +return -1 ; + + count =readlink (filename, path,PATH_MAX ); +if (count >=PATH_MAX ) +return -1 ; + +/* For device does not have a driver */ +if (count <0 ) +return 1 ; + + path[count] ='\0' ; + + name =strrchr (path,'/' ); +if (name) { +strncpy (dri_name, name +1 ,strlen (name +1 ) +1 ); +return 0 ; + } + +return -1 ; +}
lib/librte_eal/linuxapp/eal/eal_pci.c +1 -30
@@ -78,35 +78,6 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev)return rte_eal_unbind_kernel_driver (devpath, devid); } -static int -pci_get_kernel_driver_by_path (const char *filename,char *dri_name) -{ -int count; -char path[PATH_MAX ]; -char *name; - -if (!filename || !dri_name) -return -1 ; - - count =readlink (filename, path,PATH_MAX ); -if (count >=PATH_MAX ) -return -1 ; - -/* For device does not have a driver */ -if (count <0 ) -return 1 ; - - path[count] ='\0' ; - - name =strrchr (path,'/' ); -if (name) { -strncpy (dri_name, name +1 ,strlen (name +1 ) +1 ); -return 0 ; - } - -return -1 ; -} -/* Map pci device */ int rte_eal_pci_map_device (struct rte_pci_device *dev)
@@ -354,7 +325,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,/* parse driver */ snprintf (filename,sizeof (filename),"%s/driver" , dirname); - ret =pci_get_kernel_driver_by_path (filename, driver); + ret =rte_eal_get_kernel_driver_by_path (filename, driver);if (ret <0 ) {RTE_LOG (ERR ,EAL ,"Fail to get kernel driver\n" );free (dev);
Signature · 1 line
2.7.4
PATCH v6 5/21 eal: define container macro
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_eal/common/include/rte_common.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
lib/librte_eal/common/include/rte_common.h +18 -0
@@ -331,6 +331,24 @@ rte_bsf32(uint32_t v)#define offsetof (TYPE ,MEMBER ) __builtin_offsetof (TYPE, MEMBER)#endif +/** +* Return pointer to the wrapping struct instance. +* Example: +* +* struct wrapper { +* ... +* struct child c; +* ... +* }; +* +* struct child *x = obtain(...); +* struct wrapper *w = container_of(x, struct wrapper, c); +*/ +#ifndef container_of +#define container_of (p, type, member) \ + ((type *) (((char *) (p)) - offsetof(type, member))) +#endif +#define _RTE_STR (x) #x/** Take a macro value and get a string version of it */ #define RTE_STR (x) _RTE_STR(x)
Signature · 1 line
2.7.4
PATCH v6 6/21 eal/soc: introduce very essential SoC infra definitions
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Define initial structures and functions for the SoC infrastructure. This patch supports only a very minimal functions for now. More features will be added in the following commits.
Includes rte_device/rte_driver inheritance of
rte_soc_device/rte_soc_driver.
--- app/test/Makefile | 1 + app/test/test_soc.c | 90 +++++++++++++++++++++ lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_private.h | 4 + lib/librte_eal/common/include/rte_soc.h | 138 ++++++++++++++++++++++++++++++++ 5 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.h
app/test/Makefile +1 -0
@@ -77,6 +77,7 @@ APP = test # SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) := commands.c SRCS-y += test.c +SRCS-y += test_soc.c SRCS-y += resource.c SRCS-y += test_resource.c test_resource.res: test_resource.c
app/test/test_soc.c new file +90 -0
90 lines not on this page · raw message
lib/librte_eal/common/Makefile +1 -1
@@ -33,7 +33,7 @@ include $(RTE_SDK)/mk/rte.vars.mk INC := rte_branch_prediction.h rte_common.h INC += rte_debug.h rte_eal.h rte_errno.h rte_launch.h rte_lcore.h -INC += rte_log.h rte_memory.h rte_memzone.h rte_pci.h +INC += rte_log.h rte_memory.h rte_memzone.h rte_soc.h rte_pci.h INC += rte_per_lcore.h rte_random.h INC += rte_tailq.h rte_interrupts.h rte_alarm.h INC += rte_string_fns.h rte_version.h
lib/librte_eal/common/eal_private.h +4 -0
@@ -36,6 +36,7 @@#include <stdio.h> #include <rte_pci.h> +#include <rte_soc.h> /** * Initialize the memzone subsystem (private to eal).
@@ -118,6 +119,9 @@ int rte_eal_log_init(const char *id, int facility);*/ int rte_eal_pci_init (void ); +struct rte_soc_driver ; +struct rte_soc_device ; +struct rte_pci_driver ;struct rte_pci_device ;
lib/librte_eal/common/include/rte_soc.h new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 7/21 eal/soc: add SoC PMD register/unregister logic
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Registeration of a SoC driver through a helper RTE_PMD_REGISTER_SOC (on the lines of RTE_PMD_REGISTER_PCI). soc_driver_list stores all the registered drivers.
Test case has been introduced to verify the registration and deregistration.
--- app/test/test_soc.c | 111 ++++++++++++++++++++++++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 3 + lib/librte_eal/common/eal_common_soc.c | 56 ++++++++++++ lib/librte_eal/common/include/rte_soc.h | 26 ++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/rte_eal_version.map | 3 + 6 files changed, 200 insertions(+) create mode 100644 lib/librte_eal/common/eal_common_soc.c
app/test/test_soc.c +111 -0
@@ -75,6 +75,108 @@ static int test_compare_addr(void)free (a2.name);free (a1.name);free (a0.name); + +return 0 ; +} + +/** +* Empty PMD driver based on the SoC infra. +* +* The rte_soc_device is usually wrapped in some higher-level struct +* (eth_driver). We simulate such a wrapper with an anonymous struct here. +*/ +struct test_wrapper { +struct rte_soc_driver soc_drv; +}; + +struct test_wrapper empty_pmd0 = { + .soc_drv = { + .driver = { + .name ="empty_pmd0" + }, + }, +}; + +struct test_wrapper empty_pmd1 = { + .soc_drv = { + .driver = { + .name ="empty_pmd1" + }, + }, +}; + +static int +count_registered_socdrvs (void ) +{ +int i; +struct rte_soc_driver *drv; + + i =0 ; +TAILQ_FOREACH (drv, &soc_driver_list, next) + i += 1; + +return i; +} + +static int +test_register_unregister (void ) +{ +struct rte_soc_driver *drv; +int count; + +rte_eal_soc_register (&empty_pmd0.soc_drv); + +TEST_ASSERT (!TAILQ_EMPTY (&soc_driver_list), +"No PMD is present but the empty_pmd0 should be there" ); + drv =TAILQ_FIRST (&soc_driver_list); +TEST_ASSERT (!strcmp (drv->driver.name,"empty_pmd0" ), +"The registered PMD is not empty_pmd0 but '%s'" , + drv->driver.name); + +rte_eal_soc_register (&empty_pmd1.soc_drv); + + count =count_registered_socdrvs (); +TEST_ASSERT_EQUAL (count,2 ,"Expected 2 PMDs but detected %d" , count); + +rte_eal_soc_unregister (&empty_pmd0.soc_drv); + count =count_registered_socdrvs (); +TEST_ASSERT_EQUAL (count,1 ,"Expected 1 PMDs but detected %d" , count); + +rte_eal_soc_unregister (&empty_pmd1.soc_drv); + +printf ("%s has been successful\n" , __func__); +return 0 ; +} + +/* save real devices and drivers until the tests finishes */ +struct soc_driver_list real_soc_driver_list = +TAILQ_HEAD_INITIALIZER (real_soc_driver_list); + +static int test_soc_setup (void ) +{ +struct rte_soc_driver *drv; + +/* no real drivers for the test */ +while (!TAILQ_EMPTY (&soc_driver_list)) { + drv =TAILQ_FIRST (&soc_driver_list); +rte_eal_soc_unregister (drv); +TAILQ_INSERT_TAIL (&real_soc_driver_list, drv, next); + } + +return 0 ; +} + +static int test_soc_cleanup (void ) +{ +struct rte_soc_driver *drv; + +/* bring back real drivers after the test */ +while (!TAILQ_EMPTY (&real_soc_driver_list)) { + drv =TAILQ_FIRST (&real_soc_driver_list); +TAILQ_REMOVE (&real_soc_driver_list, drv, next); +rte_eal_soc_register (drv); + } +return 0 ; }
@@ -84,6 +186,15 @@ test_soc(void)if (test_compare_addr ())return -1 ; +if (test_soc_setup ()) +return -1 ; + +if (test_register_unregister ()) +return -1 ; + +if (test_soc_cleanup ()) +return -1 ; +return 0 ; }
lib/librte_eal/bsdapp/eal/rte_eal_version.map +3 -0
@@ -171,8 +171,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_register; + rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; } DPDK_16.07;
lib/librte_eal/common/eal_common_soc.c new file +56 -0
56 lines not on this page · raw message
lib/librte_eal/common/include/rte_soc.h +26 -0
@@ -51,8 +51,14 @@ extern "C" {#include <string.h> #include <rte_dev.h> +#include <rte_eal.h> #include <rte_debug.h> +extern struct soc_driver_list soc_driver_list; +/**< Global list of SoC Drivers */ + +TAILQ_HEAD (soc_driver_list, rte_soc_driver);/**< SoC drivers in D-linked Q. */ +struct rte_soc_id {const char *compatible;/**< OF compatible specification */ uint64_t priv_data;/**< SoC Driver specific data */
@@ -135,4 +141,24 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, return strcmp(a0->name, a1->name); } +/** +* Register a SoC driver. +*/ +void rte_eal_soc_register (struct rte_soc_driver *driver); + +/** Helper for SoC device registeration from PMD Drivers */ +#define RTE_PMD_REGISTER_SOC (nm, soc_drv) \ +RTE_INIT(socinitfn_ ##name); \ +static void socinitfn_ ##name(void) \ +{\ + (soc_drv).driver.name = RTE_STR(nm);\ + rte_eal_soc_register(&soc_drv); \ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +/** +* Unregister a SoC driver. +*/ +void rte_eal_soc_unregister (struct rte_soc_driver *driver); +#endif
lib/librte_eal/linuxapp/eal/Makefile +1 -0
@@ -77,6 +77,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_launch.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_soc.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_vdev.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_common_pci_uio.c
lib/librte_eal/linuxapp/eal/rte_eal_version.map +3 -0
@@ -175,8 +175,11 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_register; + rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_driver_list; } DPDK_16.07;
Signature · 1 line
2.7.4
PATCH v6 8/21 eal/soc: implement SoC device list and dump
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
SoC devices would be linked in a separate list (from PCI). This is used for probe function.
A helper for dumping the device list is added.
--- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++ lib/librte_eal/common/eal_common_soc.c | 34 +++++++++++++++++++++++++ lib/librte_eal/common/include/rte_soc.h | 9 +++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++ 4 files changed, 47 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +2 -0
@@ -171,11 +171,13 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_dump; rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_device_list; soc_driver_list; } DPDK_16.07;
lib/librte_eal/common/eal_common_soc.c +34 -0
@@ -31,6 +31,8 @@* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <stddef.h> +#include <stdio.h> #include <sys/queue.h> #include <rte_log.h>
@@ -40,6 +42,38 @@/* Global SoC driver list */ struct soc_driver_list soc_driver_list =TAILQ_HEAD_INITIALIZER (soc_driver_list); +struct soc_device_list soc_device_list = +TAILQ_HEAD_INITIALIZER (soc_device_list); + +/* dump one device */ +static int +soc_dump_one_device (FILE *f,struct rte_soc_device *dev) +{ +int i; + +fprintf (f,"%s" , dev->addr.name); +fprintf (f," - fdt_path: %s\n" , + dev->addr.fdt_path ? dev->addr.fdt_path :"(none)" ); + +for (i =0 ; dev->id && dev->id[i].compatible; ++i) +fprintf (f," %s\n" , dev->id[i].compatible); + +return 0 ; +} + +/* dump devices on the bus to an output stream */ +void +rte_eal_soc_dump (FILE *f) +{ +struct rte_soc_device *dev =NULL ; + +if (!f) +return ; + + TAILQ_FOREACH(dev, &soc_device_list, next) { +soc_dump_one_device (f, dev); + } +}/* register a driver */ void
lib/librte_eal/common/include/rte_soc.h +9 -0
@@ -56,8 +56,12 @@ extern "C" {extern struct soc_driver_list soc_driver_list;/**< Global list of SoC Drivers */ +extern struct soc_device_list soc_device_list; +/**< Global list of SoC Devices */ TAILQ_HEAD (soc_driver_list, rte_soc_driver);/**< SoC drivers in D-linked Q. */ +TAILQ_HEAD (soc_device_list, rte_soc_device);/**< SoC devices in D-linked Q. */ +struct rte_soc_id {const char *compatible;/**< OF compatible specification */
@@ -142,6 +146,11 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, }/** +* Dump discovered SoC devices. +*/ +void rte_eal_soc_dump (FILE *f); + +/** * Register a SoC driver. */ void rte_eal_soc_register (struct rte_soc_driver *driver);
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
@@ -175,11 +175,13 @@ DPDK_16.11 { rte_eal_dev_attach; rte_eal_dev_detach; rte_eal_map_resource; + rte_eal_soc_dump; rte_eal_soc_register; rte_eal_soc_unregister; rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; + soc_device_list; soc_driver_list; } DPDK_16.07;
Signature · 1 line
2.7.4
PATCH v6 9/21 eal: introduce command line enable SoC option
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Support --enable-soc. SoC support is disabled by default.
--- doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ lib/librte_eal/common/eal_common_options.c | 5 +++++ lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/common/eal_options.h | 2 ++ 4 files changed, 12 insertions(+)
doc/guides/testpmd_app_ug/run_app.rst +4 -0
@@ -156,6 +156,10 @@ See the DPDK Getting Started Guides for more information on these options. Use malloc instead of hugetlbfs. +* ``--enable-soc`` + + Enable SoC framework support + Testpmd Command-line Options ----------------------------
lib/librte_eal/common/eal_common_options.c +5 -0
@@ -75,6 +75,7 @@ const struct option eal_long_options[] = { {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM }, {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM }, + {OPT_ENABLE_SOC, 0, NULL, OPT_ENABLE_SOC_NUM }, {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM }, {OPT_HELP, 0, NULL, OPT_HELP_NUM }, {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM },
@@ -843,6 +844,10 @@ eal_parse_common_option(int opt, const char *optarg,break ;/* long options */ +case OPT_ENABLE_SOC_NUM : + conf->enable_soc =1 ; +break ; +case OPT_HUGE_UNLINK_NUM : conf->hugepage_unlink =1 ;break ;
lib/librte_eal/common/eal_internal_cfg.h +1 -0
@@ -67,6 +67,7 @@ struct internal_config {unsigned hugepage_unlink;/**< true to unlink backing files */ volatile unsigned xen_dom0_support;/**< support app running on Xen Dom0*/ volatile unsigned no_pci;/**< true to disable PCI */ +volatile unsigned enable_soc;/**< true to enable SoC */ volatile unsigned no_hpet;/**< true to disable HPET */ volatile unsigned vmware_tsc_map;/**< true to use VMware TSC mapping * instead of native TSC */
lib/librte_eal/common/eal_options.h +2 -0
@@ -49,6 +49,8 @@ enum {OPT_BASE_VIRTADDR_NUM , #define OPT_CREATE_UIO_DEV "create-uio-dev"OPT_CREATE_UIO_DEV_NUM , +#define OPT_ENABLE_SOC "enable-soc" +OPT_ENABLE_SOC_NUM , #define OPT_FILE_PREFIX "file-prefix"OPT_FILE_PREFIX_NUM , #define OPT_HUGE_DIR "huge-dir"
Signature · 1 line
2.7.4
PATCH v6 10/21 eal/soc: init SoC infra from EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/eal.c | 4 +++ lib/librte_eal/bsdapp/eal/eal_soc.c | 46 ++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 10 +++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/eal.c | 3 ++ lib/librte_eal/linuxapp/eal/eal_soc.c | 56 +++++++++++++++++++++++++++++++++++ 7 files changed, 121 insertions(+) create mode 100644 lib/librte_eal/bsdapp/eal/eal_soc.c create mode 100644 lib/librte_eal/linuxapp/eal/eal_soc.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -56,6 +56,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_hugepage_info.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_thread.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_pci.c +SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_soc.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_debug.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_lcore.c SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_timer.c
lib/librte_eal/bsdapp/eal/eal.c +4 -0
@@ -64,6 +64,7 @@#include <rte_string_fns.h> #include <rte_cpuflags.h> #include <rte_interrupts.h> +#include <rte_soc.h> #include <rte_pci.h> #include <rte_dev.h> #include <rte_devargs.h>
@@ -564,6 +565,9 @@ rte_eal_init(int argc, char **argv)if (rte_eal_pci_init () <0 )rte_panic ("Cannot init PCI\n" ); +if (rte_eal_soc_init () <0 ) +rte_panic ("Cannot init SoC\n" ); +eal_check_mem_on_local_socket ();if (eal_plugins_init () <0 )
lib/librte_eal/bsdapp/eal/eal_soc.c new file +46 -0
46 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +10 -0
@@ -122,6 +122,16 @@ int rte_eal_pci_init(void);struct rte_soc_driver ;struct rte_soc_device ; +/** +* Init the SoC infra. +* +* This function is private to EAL. +* +* @return +* 0 on success, negative on error +*/ +int rte_eal_soc_init (void ); +struct rte_pci_driver ;struct rte_pci_device ;
lib/librte_eal/linuxapp/eal/Makefile +1 -0
@@ -65,6 +65,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio_mp_sync.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_uio.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_pci_vfio.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_soc.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_debug.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_lcore.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_timer.c
lib/librte_eal/linuxapp/eal/eal.c +3 -0
@@ -810,6 +810,9 @@ rte_eal_init(int argc, char **argv)rte_panic ("Cannot init VFIO\n" );#endif +if (rte_eal_soc_init () <0 ) +rte_panic ("Cannot init SoC\n" ); +if (rte_eal_memory_init () <0 )rte_panic ("Cannot init memory\n" );
lib/librte_eal/linuxapp/eal/eal_soc.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 12/21 eal/soc: extend and utilize devargs
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
It is assumed that SoC Devices provided on command line are prefixed with "soc:". This patch adds parse and attach support for such devices.
--- lib/librte_eal/common/eal_common_dev.c | 27 +++++++++---- lib/librte_eal/common/eal_common_devargs.c | 17 ++++++++ lib/librte_eal/common/eal_common_soc.c | 61 ++++++++++++++++++++++++----- lib/librte_eal/common/include/rte_devargs.h | 8 ++++ lib/librte_eal/common/include/rte_soc.h | 24 ++++++++++++ 5 files changed, 120 insertions(+), 17 deletions(-)
lib/librte_eal/common/eal_common_dev.c +20 -7
@@ -107,17 +107,23 @@ rte_eal_dev_init(void)int rte_eal_dev_attach (const char *name,const char *devargs) { -struct rte_pci_addr addr; +struct rte_soc_addr soc_addr; +struct rte_pci_addr pci_addr;if (name ==NULL || devargs ==NULL ) {RTE_LOG (ERR ,EAL ,"Invalid device or arguments provided\n" );return -EINVAL ; } -if (eal_parse_pci_DomBDF (name, &addr) ==0 ) { -if (rte_eal_pci_probe_one (&addr) <0 ) +memset (&soc_addr,0 ,sizeof (soc_addr)); +if (rte_eal_parse_soc_spec (name, &soc_addr) ==0 ) { +if (rte_eal_soc_probe_one (&soc_addr) <0 ) { +free (soc_addr.name); + goto err; + } + }else if (eal_parse_pci_DomBDF (name, &pci_addr) ==0 ) { +if (rte_eal_pci_probe_one (&pci_addr) <0 ) goto err; - }else {if (rte_eal_vdev_init (name, devargs)) goto err;
@@ -132,15 +138,22 @@ err:int rte_eal_dev_detach (const char *name) { -struct rte_pci_addr addr; +struct rte_soc_addr soc_addr; +struct rte_pci_addr pci_addr;if (name ==NULL ) {RTE_LOG (ERR ,EAL ,"Invalid device provided.\n" );return -EINVAL ; } -if (eal_parse_pci_DomBDF (name, &addr) ==0 ) { -if (rte_eal_pci_detach (&addr) <0 ) +memset (&soc_addr,0 ,sizeof (soc_addr)); +if (rte_eal_parse_soc_spec (name, &soc_addr) ==0 ) { +if (rte_eal_soc_detach (&soc_addr) <0 ) { +free (soc_addr.name); + goto err; + } + }else if (eal_parse_pci_DomBDF (name, &pci_addr) ==0 ) { +if (rte_eal_pci_detach (&pci_addr) <0 ) goto err; }else {if (rte_eal_vdev_uninit (name))
lib/librte_eal/common/eal_common_devargs.c +17 -0
@@ -41,6 +41,7 @@#include <string.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_devargs.h> #include "eal_private.h"
@@ -105,6 +106,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) goto fail;break ; + +case RTE_DEVTYPE_WHITELISTED_SOC : +case RTE_DEVTYPE_BLACKLISTED_SOC : +/* try to parse soc device with prefix "soc:" */ +if (rte_eal_parse_soc_spec (buf, &devargs->soc.addr) !=0 ) + goto fail; +break ; +case RTE_DEVTYPE_VIRTUAL :/* save driver name */ ret = snprintf(devargs->virt.drv_name,
@@ -166,6 +175,14 @@ rte_eal_devargs_dump(FILE *f) devargs->pci.addr.devid, devargs->pci.addr.function, devargs->args); + else if (devargs->type == RTE_DEVTYPE_WHITELISTED_SOC) + fprintf(f, " SoC whitelist %s %s\n", + devargs->soc.addr.name, + devargs->soc.addr.fdt_path); + else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_SOC) + fprintf(f, " SoC blacklist %s %s\n", + devargs->soc.addr.name, + devargs->soc.addr.fdt_path); else if (devargs->type == RTE_DEVTYPE_VIRTUAL) fprintf(f, " VIRTUAL %s %s\n", devargs->virt.drv_name,
lib/librte_eal/common/eal_common_soc.c +51 -10
94 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +8 -0
@@ -51,6 +51,7 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> #include <rte_pci.h> +#include <rte_soc.h> /** * Type of generic device
@@ -58,6 +59,8 @@ extern "C" {enum rte_devtype {RTE_DEVTYPE_WHITELISTED_PCI ,RTE_DEVTYPE_BLACKLISTED_PCI , +RTE_DEVTYPE_WHITELISTED_SOC , +RTE_DEVTYPE_BLACKLISTED_SOC ,RTE_DEVTYPE_VIRTUAL , };
@@ -83,6 +86,11 @@ struct rte_devargs {/** PCI location. */ struct rte_pci_addr addr; } pci; +/** Used if type is RTE_DEVTYPE_*_SOC. */ +struct { +/** SoC location. */ +struct rte_soc_addr addr; + } soc;/** Used if type is RTE_DEVTYPE_VIRTUAL. */ struct {/** Driver name. */
lib/librte_eal/common/include/rte_soc.h +24 -0
@@ -164,6 +164,30 @@ rte_eal_compare_soc_addr(const struct rte_soc_addr *a0, }/** +* Parse a specification of a soc device. The specification must differentiate +* a SoC device specification from the PCI bus and virtual devices. We assume +* a SoC specification starts with "soc:". The function allocates the name +* entry of the given addr. +* +* @return +* - 0 on success +* - 1 when not a SoC spec +* - -1 on failure +*/ +static inline int +rte_eal_parse_soc_spec (const char *spec,struct rte_soc_addr *addr) +{ +if (strstr (spec,"soc:" ) == spec) { + addr->name =strdup (spec +4 ); +if (addr->name ==NULL ) +return -1 ; +return 0 ; + } + +return 1 ; +} + +/** * Default function for matching the Soc driver with device. Each driver can * either use this function or define their own soc matching function. * This function relies on the compatible string extracted from sysfs. But,
Signature · 1 line
2.7.4
PATCH v6 13/21 eal/soc: add drv_flags
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
The flags are copied from the PCI ones. They should be refactorized into a general set of flags in the future.
--- lib/librte_eal/common/include/rte_soc.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/librte_eal/common/include/rte_soc.h +10 -0
@@ -123,8 +123,18 @@ struct rte_soc_driver {soc_scan_t *scan_fn;/**< Callback for scanning SoC bus*/ soc_match_t *match_fn;/**< Callback to match dev<->drv */ const struct rte_soc_id *id_table;/**< ID table, NULL terminated */ +uint32_t drv_flags;/**< Control handling of device */ }; +/** Device needs to map its resources by EAL */ +#define RTE_SOC_DRV_NEED_MAPPING 0x0001 +/** Device needs to be unbound even if no module is provieded */ +#define RTE_SOC_DRV_FORCE_UNBIND 0x0004 +/** Device driver supports link state interrupt */ +#define RTE_SOC_DRV_INTR_LSC 0x0008 +/** Device driver supports detaching capability */ +#define RTE_SOC_DRV_DETACHABLE 0x0010 +/** * Utility function to write a SoC device name, this device name can later be * used to retrieve the corresponding rte_soc_addr using above functions.
Signature · 1 line
2.7.4
PATCH v6 14/21 eal/soc: add intr_handle
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_eal/common/include/rte_soc.h | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_eal/common/include/rte_soc.h +2 -0
@@ -53,6 +53,7 @@ extern "C" {#include <rte_dev.h> #include <rte_eal.h> #include <rte_debug.h> +#include <rte_interrupts.h> extern struct soc_driver_list soc_driver_list;/**< Global list of SoC Drivers */
@@ -80,6 +81,7 @@ struct rte_soc_device {struct rte_device device;/**< Inherit code device */ struct rte_soc_addr addr;/**< SoC device Location */ struct rte_soc_id *id;/**< SoC device ID list */ +struct rte_intr_handle intr_handle;/**< Interrupt handle */ struct rte_soc_driver *driver;/**< Associated driver */ };
Signature · 1 line
2.7.4
PATCH v6 15/21 eal/soc: add default scan for Soc devices
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Default implementation which scans the sysfs platform devices hierarchy. For each device, extract the ueven and convert into rte_soc_device.
The information populated can then be used in probe to match against the drivers registered.
--
v5:
- Update rte_eal_soc_scan to rte_eal_soc_scan_platform_bus
- Fix comments over scan and match functions
--- lib/librte_eal/common/include/rte_soc.h | 16 +- lib/librte_eal/linuxapp/eal/eal_soc.c | 315 ++++++++++++++++++++++++++++++++ 2 files changed, 329 insertions(+), 2 deletions(-)
lib/librte_eal/common/include/rte_soc.h +14 -2
@@ -64,7 +64,10 @@ TAILQ_HEAD(soc_driver_list, rte_soc_driver); /**< SoC drivers in D-linked Q. */TAILQ_HEAD (soc_device_list, rte_soc_device);/**< SoC devices in D-linked Q. */ struct rte_soc_id { -const char *compatible;/**< OF compatible specification */ +union { +const char *compatible;/**< OF compatible specification */ +char *_compatible; + };uint64_t priv_data;/**< SoC Driver specific data */ };
@@ -200,7 +203,16 @@ rte_eal_parse_soc_spec(const char *spec, struct rte_soc_addr *addr) }/** -* Default function for matching the Soc driver with device. Each driver can +* Helper function for scanning for new SoC devices on platform bus. +* +* @return +* 0 on success +* !0 on failure to scan +*/ +int rte_eal_soc_scan_platform_bus (void ); + +/** +* Helper function for matching the Soc driver with device. Each driver can * either use this function or define their own soc matching function. * This function relies on the compatible string extracted from sysfs. But, * a SoC might have different way of identifying its devices. Such SoC can
lib/librte_eal/linuxapp/eal/eal_soc.c +315 -0
321 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 16/21 eal/soc: additional features for SoC
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Additional features introduced:
- Find kernel driver through sysfs bindings
- Dummy implementation for mapping to kernel driver
- DMA coherency value from sysfs
- Numa node number from sysfs
- Support for updating device during probe if already registered
--- lib/librte_eal/common/eal_common_soc.c | 30 ++++++++ lib/librte_eal/common/eal_private.h | 23 ++++++ lib/librte_eal/common/include/rte_soc.h | 28 +++++++ lib/librte_eal/linuxapp/eal/eal_soc.c | 129 ++++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+)
lib/librte_eal/common/eal_common_soc.c +30 -0
@@ -114,6 +114,26 @@ rte_eal_soc_probe_one_driver(struct rte_soc_driver *drv,return ret; } +if (!dev->is_dma_coherent) { +if (!(drv->drv_flags &RTE_SOC_DRV_ACCEPT_NONCC )) { +RTE_LOG (DEBUG ,EAL , +" device is not DMA coherent, skipping\n" ); +return 1 ; + } + } + +if (drv->drv_flags &RTE_SOC_DRV_NEED_MAPPING ) { +/* map resources */ + ret =rte_eal_soc_map_device (dev); +if (ret) +return ret; + }else if (drv->drv_flags &RTE_SOC_DRV_FORCE_UNBIND + &&rte_eal_process_type () ==RTE_PROC_PRIMARY ) { +/* unbind */ +if (soc_unbind_kernel_driver (dev) <0 ) +return -1 ; + } + dev->driver = drv;RTE_VERIFY (drv->probe !=NULL );return drv->probe (drv, dev);
@@ -166,6 +186,10 @@ rte_eal_soc_detach_dev(struct rte_soc_driver *drv,if (drv->remove && (drv->remove (dev) <0 ))return -1 ;/* negative value is an error */ +if (drv->drv_flags &RTE_SOC_DRV_NEED_MAPPING ) +/* unmap resources for devices */ +rte_eal_soc_unmap_device (dev); +/* clear driver structure */ dev->driver =NULL ;
@@ -241,6 +265,12 @@ rte_eal_soc_probe_one(const struct rte_soc_addr *addr)if (addr ==NULL )return -1 ; +/* update current SoC device in global list, kernel bindings might have +* changed since last time we looked at it. +*/ +if (soc_update_device (addr) <0 ) + goto err_return; + TAILQ_FOREACH(dev, &soc_device_list, next) {if (rte_eal_compare_soc_addr (&dev->addr, addr))continue ;
lib/librte_eal/common/eal_private.h +23 -0
@@ -159,6 +159,29 @@ int pci_update_device(const struct rte_pci_addr *addr);int pci_unbind_kernel_driver (struct rte_pci_device *dev);/** +* Update a soc device object by asking the kernel for the latest information. +* +* This function is private to EAL. +* +* @param addr +* The SoC address to look for +* @return +* - 0 on success. +* - negative on error. +*/ +int soc_update_device (const struct rte_soc_addr *addr); + +/** +* Unbind kernel driver for this device +* +* This function is private to EAL. +* +* @return +* 0 on success, negative on error +*/ +int soc_unbind_kernel_driver (struct rte_soc_device *dev); + +/** * Map the PCI resource of a PCI device in virtual memory * * This function is private to EAL.
lib/librte_eal/common/include/rte_soc.h +28 -0
@@ -46,9 +46,11 @@ extern "C" {#include <stdio.h> #include <stdlib.h> +#include <sys/queue.h> #include <stdint.h> #include <inttypes.h> #include <string.h> +#include <limits.h> #include <rte_dev.h> #include <rte_eal.h>
@@ -63,6 +65,14 @@ extern struct soc_device_list soc_device_list;TAILQ_HEAD (soc_driver_list, rte_soc_driver);/**< SoC drivers in D-linked Q. */ TAILQ_HEAD (soc_device_list, rte_soc_device);/**< SoC devices in D-linked Q. */ +#define SOC_MAX_RESOURCE 6 + +struct rte_soc_resource { +uint64_t phys_addr; +uint64_t len; +void *addr; +}; +struct rte_soc_id {union {const char *compatible;/**< OF compatible specification */
@@ -84,8 +94,12 @@ struct rte_soc_device {struct rte_device device;/**< Inherit code device */ struct rte_soc_addr addr;/**< SoC device Location */ struct rte_soc_id *id;/**< SoC device ID list */ +struct rte_soc_resource mem_resource[SOC_MAX_RESOURCE ];struct rte_intr_handle intr_handle;/**< Interrupt handle */ struct rte_soc_driver *driver;/**< Associated driver */ +int numa_node;/**< NUMA node connection */ +int is_dma_coherent;/**< DMA coherent device */ +enum rte_kernel_driver kdrv;/**< Kernel driver */ };struct rte_soc_driver ;
@@ -139,6 +153,8 @@ struct rte_soc_driver {#define RTE_SOC_DRV_INTR_LSC 0x0008/** Device driver supports detaching capability */ #define RTE_SOC_DRV_DETACHABLE 0x0010 +/** Device driver accepts DMA non-coherent devices */ +#define RTE_SOC_DRV_ACCEPT_NONCC 0x0020/** * Utility function to write a SoC device name, this device name can later be
@@ -256,6 +272,18 @@ int rte_eal_soc_probe_one(const struct rte_soc_addr *addr);int rte_eal_soc_detach (const struct rte_soc_addr *addr);/** +* Map SoC device resources into userspace. +* +* This is called by the EAL if (drv_flags & RTE_SOC_DRV_NEED_MAPPING). +*/ +int rte_eal_soc_map_device (struct rte_soc_device *dev); + +/** +* Unmap the device resources. +*/ +void rte_eal_soc_unmap_device (struct rte_soc_device *dev); + +/** * Dump discovered SoC devices. * * @param f
lib/librte_eal/linuxapp/eal/eal_soc.c +129 -0
159 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 17/21 ether: utilize container_of for pci_drv
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
It is not necessary to place the rte_pci_driver at the beginning of the rte_eth_dev struct anymore as we use the container_of macro to get the parent pointer.
--- lib/librte_ether/rte_ethdev.c | 4 ++-- lib/librte_ether/rte_ethdev.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/librte_ether/rte_ethdev.c +2 -2
@@ -241,7 +241,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,int diag; - eth_drv = (struct eth_driver *)pci_drv; + eth_drv = container_of(pci_drv, struct eth_driver, pci_drv);rte_eal_pci_device_name (&pci_dev->addr, ethdev_name,sizeof (ethdev_name));
@@ -302,7 +302,7 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)if (eth_dev ==NULL )return -ENODEV ; - eth_drv = (const struct eth_driver *)pci_dev->driver; + eth_drv = container_of(pci_dev->driver, struct eth_driver, pci_drv);/* Invoke PMD device uninit function */ if (*eth_drv->eth_dev_uninit) {
lib/librte_ether/rte_ethdev.h +1 -1
@@ -1850,7 +1850,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev);* Each Ethernet driver acts as a PCI driver and is represented by a generic * *eth_driver* structure that holds: * -* - An *rte_pci_driver* structure (which must be the first field). +* - An *rte_pci_driver* structure. * * - The *eth_dev_init* function invoked for each matching PCI device. *
Signature · 1 line
2.7.4
PATCH v6 18/21 ether: verify we copy info from a PCI device
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Now that different types of ethdev exist, check for presence of PCI dev while copying out the info.
Similar would be done for SoC.
--- lib/librte_ether/rte_ethdev.c | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_ether/rte_ethdev.c +2 -0
@@ -3206,6 +3206,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dereturn ; } +RTE_VERIFY (eth_dev->pci_dev !=NULL ); + eth_dev->data->dev_flags =0 ;if (pci_dev->driver->drv_flags &RTE_PCI_DRV_INTR_LSC ) eth_dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC ;
Signature · 1 line
2.7.4
PATCH v6 19/21 ether: extract function eth_dev_get_intr_handle
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
We abstract access to the intr_handle here as we want to get it either from the pci_dev or soc_dev.
--- lib/librte_ether/rte_ethdev.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +12 -2
@@ -2532,6 +2532,16 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,rte_spinlock_unlock (&rte_eth_dev_cb_lock); } +static inline +struct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) +{ +if (dev->pci_dev) +return &dev->pci_dev->intr_handle; + +RTE_ASSERT (0 ); +return NULL ; +} +int rte_eth_dev_rx_intr_ctl (uint8_t port_id,int epfd,int op,void *data) {
@@ -2544,7 +2554,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); dev = &rte_eth_devices[port_id]; - intr_handle = &dev->pci_dev->intr_handle; + intr_handle =eth_dev_get_intr_handle (dev);if (!intr_handle->intr_vec) {RTE_PMD_DEBUG_TRACE ("RX Intr vector unset\n" );return -EPERM ;
@@ -2604,7 +2614,7 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,return -EINVAL ; } - intr_handle = &dev->pci_dev->intr_handle; + intr_handle =eth_dev_get_intr_handle (dev);if (!intr_handle->intr_vec) {RTE_PMD_DEBUG_TRACE ("RX Intr vector unset\n" );return -EPERM ;
Signature · 1 line
2.7.4
PATCH v6 20/21 ether: introduce ethernet dev probe remove
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
--- lib/librte_ether/rte_ethdev.c | 148 +++++++++++++++++++++++++++++++++++++++++- lib/librte_ether/rte_ethdev.h | 31 +++++++++ 2 files changed, 177 insertions(+), 2 deletions(-)
lib/librte_ether/rte_ethdev.c +146 -2
@@ -325,6 +325,101 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev) }int +rte_eth_dev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev) +{ +struct eth_driver *eth_drv; +struct rte_eth_dev *eth_dev; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; + +int diag; + + eth_drv = container_of(soc_drv, struct eth_driver, soc_drv); + +rte_eal_soc_device_name (&soc_dev->addr, ethdev_name, +sizeof (ethdev_name)); + + eth_dev =rte_eth_dev_allocate (ethdev_name); +if (eth_dev ==NULL ) +return -ENOMEM ; + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { + eth_dev->data->dev_private =rte_zmalloc ( +"ethdev private structure" , + eth_drv->dev_private_size, +RTE_CACHE_LINE_SIZE ); +if (eth_dev->data->dev_private ==NULL ) +rte_panic ("Cannot allocate memzone for private port " +"data\n" ); + } + eth_dev->soc_dev = soc_dev; + eth_dev->driver = eth_drv; + eth_dev->data->rx_mbuf_alloc_failed =0 ; + +/* init user callbacks */ +TAILQ_INIT (&(eth_dev->link_intr_cbs)); + +/* +* Set the default MTU. +*/ + eth_dev->data->mtu =ETHER_MTU ; + +/* Invoke PMD device initialization function */ + diag = (*eth_drv->eth_dev_init)(eth_dev); +if (diag ==0 ) +return 0 ; + +RTE_PMD_DEBUG_TRACE ("driver %s: eth_dev_init(%s) failed\n" , + soc_drv->driver.name, + soc_dev->addr.name); +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (eth_dev->data->dev_private); +rte_eth_dev_release_port (eth_dev); +return diag; +} + +int +rte_eth_dev_soc_remove (struct rte_soc_device *soc_dev) +{ +const struct eth_driver *eth_drv; +struct rte_eth_dev *eth_dev; +char ethdev_name[RTE_ETH_NAME_MAX_LEN ]; +int ret; + +if (soc_dev ==NULL ) +return -EINVAL ; + +rte_eal_soc_device_name (&soc_dev->addr, ethdev_name, +sizeof (ethdev_name)); + + eth_dev =rte_eth_dev_allocated (ethdev_name); +if (eth_dev ==NULL ) +return -ENODEV ; + + eth_drv = container_of(soc_dev->driver, struct eth_driver, soc_drv); + +/* Invoke PMD device uninit function */ +if (*eth_drv->eth_dev_uninit) { + ret = (*eth_drv->eth_dev_uninit)(eth_dev); +if (ret) +return ret; + } + +/* free ether device */ +rte_eth_dev_release_port (eth_dev); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (eth_dev->data->dev_private); + + eth_dev->soc_dev =NULL ; + eth_dev->driver =NULL ; + eth_dev->data =NULL ; + +return 0 ; +} + + +int rte_eth_dev_is_valid_port (uint8_t port_id) { if (port_id >= RTE_MAX_ETHPORTS ||
@@ -1557,6 +1652,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)RTE_FUNC_PTR_OR_RET (*dev->dev_ops->dev_infos_get); (*dev->dev_ops->dev_infos_get)(dev, dev_info); dev_info->pci_dev = dev->pci_dev; + dev_info->soc_dev = dev->soc_dev; dev_info->driver_name = dev->data->drv_name; dev_info->nb_rx_queues = dev->data->nb_rx_queues; dev_info->nb_tx_queues = dev->data->nb_tx_queues;
@@ -2535,8 +2631,15 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,static inline struct rte_intr_handle *eth_dev_get_intr_handle (struct rte_eth_dev *dev) { -if (dev->pci_dev) +if (dev->pci_dev) { +RTE_ASSERT (dev->soc_dev ==NULL );return &dev->pci_dev->intr_handle; + } + +if (dev->soc_dev) { +RTE_ASSERT (dev->pci_dev ==NULL ); +return &dev->soc_dev->intr_handle; + }RTE_ASSERT (0 );return NULL ;
@@ -2573,6 +2676,23 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)return 0 ; } +static inline +const char *eth_dev_get_driver_name (const struct rte_eth_dev *dev) +{ +if (dev->pci_dev) { +RTE_ASSERT (dev->soc_dev ==NULL ); +return dev->driver->pci_drv.driver.name; + } + +if (dev->soc_dev) { +RTE_ASSERT (dev->pci_dev ==NULL ); +return dev->driver->soc_drv.driver.name; + } + +RTE_ASSERT (0 ); +return NULL ; +} +const struct rte_memzone * rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, size_t size, unsigned align,
@@ -2580,9 +2700,11 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, {char z_name[RTE_MEMZONE_NAMESIZE ];const struct rte_memzone *mz; +const char *drv_name; + drv_name =eth_dev_get_driver_name (dev);snprintf (z_name,sizeof (z_name),"%s_%s_%d_%d" , - dev->driver->pci_drv.driver.name, ring_name, + drv_name, ring_name, dev->data->port_id, queue_id); mz =rte_memzone_lookup (z_name);
@@ -3229,6 +3351,28 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de eth_dev->data->drv_name = pci_dev->driver->driver.name; } +void +rte_eth_copy_soc_info (struct rte_eth_dev *eth_dev, +struct rte_soc_device *soc_dev) +{ +if ((eth_dev ==NULL ) || (soc_dev ==NULL )) { +RTE_PMD_DEBUG_TRACE ("NULL pointer eth_dev=%p soc_dev=%p\n" , + eth_dev, soc_dev); +return ; + } + +RTE_ASSERT (eth_dev->soc_dev !=NULL ); + + eth_dev->data->dev_flags =0 ; +if (soc_dev->driver->drv_flags &RTE_SOC_DRV_INTR_LSC ) + eth_dev->data->dev_flags |=RTE_ETH_DEV_INTR_LSC ; +if (soc_dev->driver->drv_flags &RTE_SOC_DRV_DETACHABLE ) + eth_dev->data->dev_flags |=RTE_ETH_DEV_DETACHABLE ; + + eth_dev->data->numa_node = soc_dev->device.numa_node; + eth_dev->data->drv_name = soc_dev->driver->driver.name; +} +int rte_eth_dev_l2_tunnel_eth_type_conf (uint8_t port_id,struct rte_eth_l2_tunnel_conf *l2_tunnel)
lib/librte_ether/rte_ethdev.h +31 -0
@@ -180,6 +180,7 @@ extern "C" {#include <rte_log.h> #include <rte_interrupts.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_dev.h> #include <rte_devargs.h> #include "rte_ether.h"
@@ -877,6 +878,7 @@ struct rte_eth_conf {*/ struct rte_eth_dev_info {struct rte_pci_device *pci_dev;/**< Device PCI information. */ +struct rte_soc_device *soc_dev;/**< Device SoC information. */ const char *driver_name;/**< Device Driver name. */ unsigned int if_index;/**< Index to bound host interface, or 0 if none. Use if_indextoname() to translate into an interface name. */
@@ -1626,6 +1628,7 @@ struct rte_eth_dev {const struct eth_driver *driver;/**< Driver for this device */ const struct eth_dev_ops *dev_ops;/**< Functions exported by PMD */ struct rte_pci_device *pci_dev;/**< PCI info. supplied by probing */ +struct rte_soc_device *soc_dev;/**< SoC info. supplied by probing */ /** User application callbacks for NIC interrupts */ struct rte_eth_dev_cb_list link_intr_cbs;/**
@@ -1860,6 +1863,7 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev);*/ struct eth_driver {struct rte_pci_driver pci_drv;/**< The PMD is also a PCI driver. */ +struct rte_soc_driver soc_drv;/**< The PMD is also a SoC driver. */ eth_dev_init_t eth_dev_init;/**< Device init function. */ eth_dev_uninit_t eth_dev_uninit;/**< Device uninit function. */ unsigned int dev_private_size;/**< Size of device private data. */
@@ -4262,6 +4266,20 @@ void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev);/** +* Copy SoC device info to the Ethernet device data. +* +* @param eth_dev +* The *eth_dev* pointer is the address of the *rte_eth_dev* structure. +* @param soc_dev +* The *soc_dev* pointer is the address of the *rte_soc_device* structure. +* +* @return +* - 0 on success, negative on error +*/ +void rte_eth_copy_soc_info (struct rte_eth_dev *eth_dev, +struct rte_soc_device *soc_dev); + +/** * Create memzone for HW rings. * malloc can't be used as the physical address is needed. * If the memzone is already created, then this function returns a ptr
@@ -4376,6 +4394,19 @@ int rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,*/ int rte_eth_dev_pci_remove (struct rte_pci_device *pci_dev); +/** +* Wrapper for use by SoC drivers as a .devinit function to attach to a ethdev +* interface. +*/ +int rte_eth_dev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev); + +/** +* Wrapper for use by SoC drivers as a .devuninit function to detach a ethdev +* interface. +*/ +int rte_eth_dev_soc_remove (struct rte_soc_device *soc_dev); + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH v6 21/21 eal/crypto: Support rte_soc_driver/device for cryptodev
In reply to Shreyansh Jain- rte_cryptodev_driver/rte_cryptodev_dev embeds rte_soc_driver/device for linking SoC PMDs to crypto devices.
- Add probe and remove functions linked
--- lib/librte_cryptodev/rte_cryptodev.c | 122 ++++++++++++++++++++++++- lib/librte_cryptodev/rte_cryptodev.h | 3 + lib/librte_cryptodev/rte_cryptodev_pmd.h | 18 +++- lib/librte_cryptodev/rte_cryptodev_version.map | 2 + 4 files changed, 140 insertions(+), 5 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +118 -4
@@ -422,7 +422,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,int retval; - cryptodrv = (struct rte_cryptodev_driver *)pci_drv; + cryptodrv = container_of(pci_drv, struct rte_cryptodev_driver, + pci_drv);if (cryptodrv ==NULL )return -ENODEV ;
@@ -489,7 +490,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)if (cryptodev ==NULL )return -ENODEV ; - cryptodrv = (const struct rte_cryptodev_driver *)pci_dev->driver; + cryptodrv = container_of(pci_dev->driver, struct rte_cryptodev_driver, + pci_drv);if (cryptodrv ==NULL )return -ENODEV ;
@@ -513,6 +515,111 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)return 0 ; } + +int +rte_cryptodev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev) +{ +struct rte_cryptodev_driver *cryptodrv; +struct rte_cryptodev *cryptodev; + +char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN ]; + +int retval; + + cryptodrv = container_of(soc_drv, struct rte_cryptodev_driver, + soc_drv); + +rte_eal_soc_device_name (&soc_dev->addr, cryptodev_name, +sizeof (cryptodev_name)); + + cryptodev =rte_cryptodev_pmd_allocate (cryptodev_name, +rte_socket_id ()); +if (cryptodev ==NULL ) +return -ENOMEM ; + + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) { + cryptodev->data->dev_private = +rte_zmalloc_socket ( +"cryptodev private structure" , + cryptodrv->dev_private_size, +RTE_CACHE_LINE_SIZE , +rte_socket_id ()); + +if (cryptodev->data->dev_private ==NULL ) +rte_panic ("Cannot allocate memzone for private " +"device data" ); + } + + cryptodev->soc_dev = soc_dev; + cryptodev->driver = cryptodrv; + +/* init user callbacks */ +TAILQ_INIT (&(cryptodev->link_intr_cbs)); + +/* Invoke PMD device initialization function */ + retval = (*cryptodrv->cryptodev_init)(cryptodrv, cryptodev); +if (retval ==0 ) +return 0 ; + +CDEV_LOG_ERR ("driver %s: cryptodev_init(%s) failed\n" , + soc_drv->driver.name, + soc_dev->addr.name); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (cryptodev->data->dev_private); + + cryptodev->attached =RTE_CRYPTODEV_DETACHED ; + cryptodev_globals.nb_devs--; + +return -ENXIO ; +} + +int +rte_cryptodev_soc_remove (struct rte_soc_device *soc_dev) +{ +const struct rte_cryptodev_driver *cryptodrv; +struct rte_cryptodev *cryptodev; +char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN ]; +int ret; + +if (soc_dev ==NULL ) +return -EINVAL ; + +rte_eal_soc_device_name (&soc_dev->addr, cryptodev_name, +sizeof (cryptodev_name)); + + cryptodev =rte_cryptodev_pmd_get_named_dev (cryptodev_name); +if (cryptodev ==NULL ) +return -ENODEV ; + + cryptodrv =container_of (soc_dev->driver, + struct rte_cryptodev_driver, soc_drv); +if (cryptodrv ==NULL ) +return -ENODEV ; + +/* Invoke PMD device uninit function */ +if (*cryptodrv->cryptodev_uninit) { + ret = (*cryptodrv->cryptodev_uninit)(cryptodrv, cryptodev); +if (ret) +return ret; + } + +/* free crypto device */ +rte_cryptodev_pmd_release_device (cryptodev); + +if (rte_eal_process_type () ==RTE_PROC_PRIMARY ) +rte_free (cryptodev->data->dev_private); + + cryptodev->pci_dev =NULL ; + cryptodev->soc_dev =NULL ; + cryptodev->driver =NULL ; + cryptodev->data =NULL ; + +return 0 ; +} +uint16_t rte_cryptodev_queue_pair_count (uint8_t dev_id) {
@@ -868,8 +975,15 @@ rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info) (*dev->dev_ops->dev_infos_get)(dev, dev_info); dev_info->pci_dev = dev->pci_dev; -if (dev->driver) - dev_info->driver_name = dev->driver->pci_drv.driver.name; + dev_info->soc_dev = dev->soc_dev; +if (dev->driver) { +if (dev->soc_dev) + dev_info->driver_name + = dev->driver->soc_drv.driver.name; +else + dev_info->driver_name + = dev->driver->pci_drv.driver.name; + } }
lib/librte_cryptodev/rte_cryptodev.h +3 -0
@@ -244,6 +244,7 @@ struct rte_cryptodev_info {const char *driver_name;/**< Driver name. */ enum rte_cryptodev_type dev_type;/**< Device type */ struct rte_pci_device *pci_dev;/**< PCI information. */ +struct rte_soc_device *soc_dev;/**< SoC information. */ uint64_t feature_flags;/**< Feature flags */
@@ -623,6 +624,8 @@ struct rte_cryptodev {/**< Supported features */ struct rte_pci_device *pci_dev;/**< PCI info. supplied by probing */ +struct rte_soc_device *soc_dev; +/**< SoC info. supplied by probing/Scanning */ enum rte_cryptodev_type dev_type;/**< Crypto device type */
lib/librte_cryptodev/rte_cryptodev_pmd.h +17 -1
@@ -48,6 +48,7 @@ extern "C" {#include <rte_dev.h> #include <rte_pci.h> +#include <rte_soc.h> #include <rte_malloc.h> #include <rte_mbuf.h> #include <rte_mempool.h>
@@ -131,7 +132,8 @@ typedef int (*cryptodev_uninit_t)(const struct rte_cryptodev_driver *drv,* - The size of the private data to allocate for each matching device. */ struct rte_cryptodev_driver { -struct rte_pci_driver pci_drv;/**< The PMD is also a PCI driver. */ +struct rte_pci_driver pci_drv;/**< The PMD is PCI type driver. */ +struct rte_soc_driver soc_drv;/**< The PMD is SoC type driver. */ unsigned dev_private_size;/**< Size of device private data. */ cryptodev_init_t cryptodev_init;/**< Device init function. */
@@ -519,6 +521,20 @@ int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,*/ int rte_cryptodev_pci_remove (struct rte_pci_device *pci_dev); +/** +* Wrapper for use by SoC drivers as a .devinit function to attach to a +* cryptodev interface. +*/ +int rte_cryptodev_soc_probe (struct rte_soc_driver *soc_drv, +struct rte_soc_device *soc_dev); + +/** +* Wrapper for use by SoC drivers as a .devuninit function to detach a +* cryptodev interface. +*/ +int rte_cryptodev_soc_remove (struct rte_soc_device *soc_dev); + + #ifdef __cplusplus }#endif
lib/librte_cryptodev/rte_cryptodev_version.map +2 -0
@@ -44,5 +44,7 @@ DPDK_16.11 { rte_cryptodev_pci_probe; rte_cryptodev_pci_remove; + rte_cryptodev_soc_probe; + rte_cryptodev_soc_remove; } DPDK_16.07;
Signature · 1 line
2.7.4
v7 cover Introduce SoC device/driver framework for EAL
In reply to Shreyansh JainIntroduction:
=============
This patch set is direct derivative of Jan's original series [1],[2].
- This version is based on master HEAD (ca41215)
- In this, I am merging the series [11] back. It was initially part of this set but I had split considering that those changes in PCI were good standalone as well. But, 1) not much feedback was avail- able and 2) this patchset is a use-case for those patches making it easier to review. Just like what Jan had intended in original series.
- SoC support is not enabled by default. It needs the 'enable-soc' toggle on command line. This is primarily because this patchset is still experimental and we would like to keep it isolated from non-SoC ops. Though, it does impact the ABI.
Aim:
====
As of now EAL is primarly focused on PCI initialization/probing.
rte_eal_init()
|- rte_eal_pci_init(): Find PCI devices from sysfs |- ... |- rte_eal_memzone_init() |- ...
`- rte_eal_pci_probe(): Driver<=>Device initialization
This patchset introduces SoC framework which would enable SoC drivers and drivers to be plugged into EAL, very similar to how PCI drivers/devices are done today.
This is a stripped down version of PCI framework which allows the SoC PMDs to implement their own routines for detecting devices and linking devices to drivers.
1) Changes to EAL
rte_eal_init()
|- rte_eal_pci_init(): Find PCI devices from sysfs |- rte_eal_soc_init(): Calls PMDs->scan_fn |- ... |- rte_eal_memzone_init() |- ... |- rte_eal_pci_probe(): Driver<=>Device initialization, PMD->devinit()
`- rte_eal_soc_probe(): Calls PMDs->match_fn and PMDs->devinit();
2) New device/driver structures:
- rte_soc_driver (inheriting rte_driver)
- rte_soc_device (inheriting rte_device)
- rte_eth_dev and eth_driver embedded rte_soc_device and rte_soc_driver, respectively.
3) The SoC PMDs need to:
- define rte_soc_driver with necessary scan and match callbacks
- Register themselves using DRIVER_REGISTER_SOC()
- Implement respective bus scanning in the scan callbacks to add necessary devices to SoC device list
- Implement necessary eth_dev_init/uninint for ethernet instances
4) Design considerations that are same as PCI:
- SoC initialization is being done through rte_eal_init(), just after PCI initialization is done.
- As in case of PCI, probe is done after rte_eal_pci_probe() to link the devices detected with the drivers registered.
- Device attach/detach functions are available and have been designed on the lines of PCI framework.
- PMDs register using DRIVER_REGISTER_SOC, very similar to DRIVER_REGISTER_PCI for PCI devices.
- Linked list of SoC driver and devices exists independent of the other driver/device list, but inheriting rte_driver/rte_driver, these are also part of a global list.
5) Design considerations that are different from PCI:
- Each driver implements its own scan and match function. PCI uses the BDF format to read the device from sysfs, but this _may_not_ be a case for a SoC ethernet device.
= This is an important change from initial proposal by Jan in [2]. Unlike his attempt to use /sys/bus/platform, this patch relies on the PMD to detect the devices. This is because SoC may require specific or additional info for device detection. Further, SoC may have embedded devices/MACs which require initialization which cannot be covered through sysfs parsing.
`-> Point (6) below is a side note to above.
= PCI based PMDs rely on EAL's capability to detect devices. This proposal puts the onus on PMD to detect devices, add to soc_device_list and wait for Probe. Matching, of device<=>driver is again PMD's callback.
6) Adding default scan and match helpers for PMDs
- The design warrrants the PMDs implement their own scan of devices on bus, and match routines for probe implementation.
This patch introduces helpers which can be used by PMDs for scan of the platform bus and matching devices against the compatible string extracted from the scan.
- Intention is to make it easier to integrate known SoC which expose platform bus compliant information (compat, sys/bus/platform...).
- PMDs which have deviations from this standard model can implement and hook their bus scanning and probe match callbacks while registering driver.
Patchset Overview:
==================
- Patches 0001~0004 are from [11] - moving some PCI specific functions and definitions to non-PCI area.
- Patches 0005~0008 introduce the base infrastructure and test case
- Patch 0009 is for command line support for no-soc, on lines of no-pci
- Patch 0010 enables EAL to handle SoC type devices
- Patch 0011 adds support for scan and probe callbacks and updates the test framework with relevant test case.
- Patch 0012~0014 enable device argument, driver specific flags and interrupt handling related basic infra. Subsequent patches build up on them.
- Patch 0015~0016 add support for default function which PMDs can use for scanning platform bus. These functions are optional and need to be hooked to by PMDs.
- Patch 0017~0019 makes changes to PCI as well as ethdev code to remove assumption that eth_driver is a PCI driver.
- Patch 0020 adds necessary ethdev probe/remove functions for PMDs to use
- Patch 0021 adds support for SoC driver/devices, along with probe/remove functions for Cryptodev devices.
Future/Pending Changes:
=======================
- Device whitelisting/blacklist still relies on command line '-b' and '-c' which are internally implemented using OPT_PCI_BLACKLIST/OPT_PCI_WHITELIST. This needs to be changed to a generic form - OPT_DEV_*LIST - probably.
- No cryptodriver currently uses SoC framework - probably a example driver can be created to demonstrate usage.
- test case for enable-soc command line parameter
- This patch impacts a couple of ABIs (rte_device/driver) and thus require a patch for bump of libraries (if need be) and documentation.
[1] http://dpdk.org/ml/archives/dev/2016-January/030915.html
[2] http://www.dpdk.org/ml/archives/dev/2016-May/038486.html
[3] http://dpdk.org/ml/archives/dev/2016-August/045707.html
[4] http://dpdk.org/ml/archives/dev/2016-May/038948.html
[5] http://dpdk.org/ml/archives/dev/2016-May/038953.html
[6] http://dpdk.org/ml/archives/dev/2016-May/038487.html
[7] http://dpdk.org/ml/archives/dev/2016-May/038488.html
[8] http://dpdk.org/ml/archives/dev/2016-May/038489.html
[9] http://dpdk.org/ml/archives/dev/2016-May/038491.html
[10] http://dpdk.org/ml/archives/dev/2016-September/046256.html
[11] http://dpdk.org/ml/archives/dev/2016-October/048915.html
Changes since v6;
- Fix patch rebase over HEAD (ca41215)
Changes since v5:
- fix devinit/devuninit name change; it was in wrong patch
- rebased over HEAD (ca41215)
- Update to pending section of coverletter
Changes since v4:
- change name of rte_eal_soc_scan function name to rte_eal_soc_scan_platform_bus. This still remains a helper function.
- Fix comments over scan and match functions
Changes since v3:
- rebasing over HEAD (fed622df tag: v16.11-rc1)
- Add support for default scan function; PMD can use this for scanning on platform bus.
- Support for kernel driver bind/unbind, numa and DMA from Jan's original patches.
- SoC is disabled by default. '--enable-soc' command line parameter enables it. doc updated.
- Updated testcase function names and comments
- Map file addition alphabetically ordered
- Patch author corrected
Changes since v2:
- Rebasing over rte_driver/device patchset v9 [10]
- Added cryptodev support for SoC
- Default match function for SoC device<=>Driver
- Some variables renamed to reflect 'drv' rather than 'dr'
Change since v1 [2]:
- Removed patch 1-5 which were for generalizing some PCI specific routines into EAL. These patches are good-to-have but not directly linked to SoC and hence would be proposed separately.
- Removed support for sysfs parsing (patches 6~9)
- Rebasing over the recent (v8) version of rte_driver/device patchset
- Rebasing over master (16.07)
- Changes to various map file to change API intro to 16.11 from 16.07
Jan Viktorin (19):
eal: generalize PCI kernel driver enum to EAL
eal: generalize PCI map/unmap resource to EAL eal/linux: generalize PCI kernel unbinding driver to EAL eal/linux: generalize PCI kernel driver extraction to EAL
eal: define container macro
eal/soc: introduce very essential SoC infra definitions eal/soc: add SoC PMD register/unregister logic eal/soc: implement SoC device list and dump
eal: introduce command line enable SoC option eal/soc: init SoC infra from EAL
eal/soc: extend and utilize devargs
eal/soc: add drv_flags
eal/soc: add intr_handle
eal/soc: add default scan for Soc devices eal/soc: additional features for SoC
ether: utilize container_of for pci_drv
ether: verify we copy info from a PCI device
ether: extract function eth_dev_get_intr_handle
ether: introduce ethernet dev probe remove
Shreyansh Jain (2):
eal/soc: implement probing of drivers eal/crypto: Support rte_soc_driver/device for cryptodev
app/test/Makefile | 1 + app/test/test_soc.c | 404 +++++++++++++++++++ doc/guides/testpmd_app_ug/run_app.rst | 4 + lib/librte_cryptodev/rte_cryptodev.c | 122 +++++- lib/librte_cryptodev/rte_cryptodev.h | 3 + lib/librte_cryptodev/rte_cryptodev_pmd.h | 18 +- lib/librte_cryptodev/rte_cryptodev_version.map | 2 + lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/eal.c | 18 + lib/librte_eal/bsdapp/eal/eal_pci.c | 6 +- lib/librte_eal/bsdapp/eal/eal_soc.c | 46 +++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 11 + lib/librte_eal/common/Makefile | 2 +- lib/librte_eal/common/eal_common_dev.c | 66 ++- lib/librte_eal/common/eal_common_devargs.c | 17 + lib/librte_eal/common/eal_common_options.c | 5 + lib/librte_eal/common/eal_common_pci.c | 39 -- lib/librte_eal/common/eal_common_pci_uio.c | 16 +- lib/librte_eal/common/eal_common_soc.c | 368 +++++++++++++++++ lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/common/eal_options.h | 2 + lib/librte_eal/common/eal_private.h | 64 +++ lib/librte_eal/common/include/rte_common.h | 18 + lib/librte_eal/common/include/rte_dev.h | 44 ++ lib/librte_eal/common/include/rte_devargs.h | 8 + lib/librte_eal/common/include/rte_pci.h | 41 -- lib/librte_eal/common/include/rte_soc.h | 322 +++++++++++++++ lib/librte_eal/linuxapp/eal/Makefile | 2 + lib/librte_eal/linuxapp/eal/eal.c | 63 +++ lib/librte_eal/linuxapp/eal/eal_pci.c | 62 +-- lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 5 +- lib/librte_eal/linuxapp/eal/eal_soc.c | 515 ++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 11 + lib/librte_ether/rte_ethdev.c | 166 +++++++- lib/librte_ether/rte_ethdev.h | 33 +- 36 files changed, 2343 insertions(+), 165 deletions(-) create mode 100644 app/test/test_soc.c create mode 100644 lib/librte_eal/bsdapp/eal/eal_soc.c create mode 100644 lib/librte_eal/common/eal_common_soc.c create mode 100644 lib/librte_eal/common/include/rte_soc.h create mode 100644 lib/librte_eal/linuxapp/eal/eal_soc.c
Signature · 1 line
2.7.4
PATCH v7 1/21 eal: generalize PCI kernel driver enum to EAL
From: Jan Viktorin <[email protected]>
--
Changes since v0:
- fix compilation error due to missing include
--- lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++ lib/librte_eal/common/include/rte_pci.h | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
@@ -109,6 +109,18 @@ struct rte_mem_resource {void *addr;/**< Virtual address, NULL when not mapped. */ }; +/** +* Kernel driver passthrough type +*/ +enum rte_kernel_driver { +RTE_KDRV_UNKNOWN =0 , +RTE_KDRV_IGB_UIO , +RTE_KDRV_VFIO , +RTE_KDRV_UIO_GENERIC , +RTE_KDRV_NIC_UIO , +RTE_KDRV_NONE , +}; +/** Double linked list of device drivers. */ TAILQ_HEAD (rte_driver_list, rte_driver);/** Double linked list of devices. */
lib/librte_eal/common/include/rte_pci.h +0 -9
@@ -135,15 +135,6 @@ struct rte_pci_addr {struct rte_devargs ; -enum rte_kernel_driver { -RTE_KDRV_UNKNOWN =0 , -RTE_KDRV_IGB_UIO , -RTE_KDRV_VFIO , -RTE_KDRV_UIO_GENERIC , -RTE_KDRV_NIC_UIO , -RTE_KDRV_NONE , -}; -/** * A structure describing a PCI device. */
Signature · 1 line
2.7.4
PATCH v7 2/21 eal: generalize PCI map/unmap resource to EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
The functions pci_map_resource, pci_unmap_resource are generic so the pci_* prefix can be omitted. The functions are moved to the eal_common_dev.c so they can be reused by other infrastructure.
--- lib/librte_eal/bsdapp/eal/eal_pci.c | 2 +- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++ lib/librte_eal/common/eal_common_dev.c | 39 +++++++++++++++++++++++++ lib/librte_eal/common/eal_common_pci.c | 39 ------------------------- lib/librte_eal/common/eal_common_pci_uio.c | 16 +++++----- lib/librte_eal/common/include/rte_dev.h | 32 ++++++++++++++++++++ lib/librte_eal/common/include/rte_pci.h | 32 -------------------- lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 5 ++-- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++ 10 files changed, 89 insertions(+), 82 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +1 -1
@@ -228,7 +228,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,/* if matching map is found, then use it */ offset = res_idx * pagesz; - mapaddr =pci_map_resource (NULL , fd, (off_t )offset, + mapaddr =rte_eal_map_resource (NULL , fd, (off_t )offset, (size_t )dev->mem_resource[res_idx].len,0 );close (fd);if (mapaddr ==MAP_FAILED )
lib/librte_eal/bsdapp/eal/rte_eal_version.map +2 -0
@@ -170,6 +170,8 @@ DPDK_16.11 { rte_delay_us_callback_register; rte_eal_dev_attach; rte_eal_dev_detach; + rte_eal_map_resource; + rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister;
lib/librte_eal/common/eal_common_dev.c +39 -0
@@ -36,6 +36,7 @@#include <string.h> #include <inttypes.h> #include <sys/queue.h> +#include <sys/mman.h> #include <rte_dev.h> #include <rte_devargs.h>
@@ -151,3 +152,41 @@ err:RTE_LOG (ERR ,EAL ,"Driver cannot detach the device (%s)\n" , name);return -EINVAL ; } + +/* map a particular resource from a file */ +void * +rte_eal_map_resource (void *requested_addr,int fd,off_t offset,size_t size, +int additional_flags) +{ +void *mapaddr; + +/* Map the Memory resource of device */ + mapaddr =mmap (requested_addr, size,PROT_READ |PROT_WRITE , +MAP_SHARED | additional_flags, fd, offset); +if (mapaddr ==MAP_FAILED ) { +RTE_LOG (ERR ,EAL ,"%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s" +" (%p)\n" , __func__, fd, requested_addr, + (unsigned long )size, (unsigned long )offset, +strerror (errno), mapaddr); + }else +RTE_LOG (DEBUG ,EAL ," Device memory mapped at %p\n" , mapaddr); + +return mapaddr; +} + +/* unmap a particular resource */ +void +rte_eal_unmap_resource (void *requested_addr,size_t size) +{ +if (requested_addr ==NULL ) +return ; + +/* Unmap the Memory resource of device */ +if (munmap (requested_addr, size)) { +RTE_LOG (ERR ,EAL ,"%s(): cannot munmap(%p, 0x%lx): %s\n" , + __func__, requested_addr, (unsigned long )size, +strerror (errno)); + }else +RTE_LOG (DEBUG ,EAL ," Device memory unmapped at %p\n" , + requested_addr); +}
lib/librte_eal/common/eal_common_pci.c +0 -39
@@ -67,7 +67,6 @@#include <stdlib.h> #include <stdio.h> #include <sys/queue.h> -#include <sys/mman.h> #include <rte_interrupts.h> #include <rte_log.h>
@@ -114,44 +113,6 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)return NULL ; } -/* map a particular resource from a file */ -void * -pci_map_resource (void *requested_addr,int fd,off_t offset,size_t size, -int additional_flags) -{ -void *mapaddr; - -/* Map the PCI memory resource of device */ - mapaddr =mmap (requested_addr, size,PROT_READ |PROT_WRITE , -MAP_SHARED | additional_flags, fd, offset); -if (mapaddr ==MAP_FAILED ) { -RTE_LOG (ERR ,EAL ,"%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\n" , - __func__, fd, requested_addr, - (unsigned long )size, (unsigned long )offset, -strerror (errno), mapaddr); - }else -RTE_LOG (DEBUG ,EAL ," PCI memory mapped at %p\n" , mapaddr); - -return mapaddr; -} - -/* unmap a particular resource */ -void -pci_unmap_resource (void *requested_addr,size_t size) -{ -if (requested_addr ==NULL ) -return ; - -/* Unmap the PCI memory resource of device */ -if (munmap (requested_addr, size)) { -RTE_LOG (ERR ,EAL ,"%s(): cannot munmap(%p, 0x%lx): %s\n" , - __func__, requested_addr, (unsigned long )size, -strerror (errno)); - }else -RTE_LOG (DEBUG ,EAL ," PCI memory unmapped at %p\n" , - requested_addr); -} -/* * If vendor/device ID match, call the probe() function of the * driver.
lib/librte_eal/common/eal_common_pci_uio.c +9 -7
@@ -75,9 +75,11 @@ pci_uio_map_secondary(struct rte_pci_device *dev)return -1 ; } -void *mapaddr =pci_map_resource (uio_res->maps[i].addr, - fd, (off_t )uio_res->maps[i].offset, - (size_t )uio_res->maps[i].size,0 ); +void *mapaddr =rte_eal_map_resource ( + uio_res->maps[i].addr, fd, + (off_t )uio_res->maps[i].offset, + (size_t )uio_res->maps[i].size, +0 );/* fd is not needed in slave process, close it */ close (fd);if (mapaddr != uio_res->maps[i].addr) {
@@ -88,11 +90,11 @@ pci_uio_map_secondary(struct rte_pci_device *dev)if (mapaddr !=MAP_FAILED ) {/* unmap addrs correctly mapped */ for (j =0 ; j < i; j++) -pci_unmap_resource ( +rte_eal_unmap_resource ( uio_res->maps[j].addr, (size_t )uio_res->maps[j].size);/* unmap addr wrongly mapped */ -pci_unmap_resource (mapaddr, +rte_eal_unmap_resource (mapaddr, (size_t )uio_res->maps[i].size); }return -1 ;
@@ -150,7 +152,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)return 0 ; error:for (i =0 ; i < map_idx; i++) { -pci_unmap_resource (uio_res->maps[i].addr, +rte_eal_unmap_resource (uio_res->maps[i].addr, (size_t )uio_res->maps[i].size);rte_free (uio_res->maps[i].path); }
@@ -167,7 +169,7 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res)return ;for (i =0 ; i != uio_res->nb_maps; i++) { -pci_unmap_resource (uio_res->maps[i].addr, +rte_eal_unmap_resource (uio_res->maps[i].addr, (size_t )uio_res->maps[i].size);if (rte_eal_process_type () ==RTE_PROC_PRIMARY )rte_free (uio_res->maps[i].path);
lib/librte_eal/common/include/rte_dev.h +32 -0
@@ -235,6 +235,38 @@ int rte_eal_dev_attach(const char *name, const char *devargs);*/ int rte_eal_dev_detach (const char *name); +/* +* @internal +* Map a particular resource from a file. +* +* @param requested_addr +* The starting address for the new mapping range. +* @param fd +* The file descriptor. +* @param offset +* The offset for the mapping range. +* @param size +* The size for the mapping range. +* @param additional_flags +* The additional flags for the mapping range. +* @return +* - On success, the function returns a pointer to the mapped area. +* - On error, the value MAP_FAILED is returned. +*/ +void *rte_eal_map_resource (void *requested_addr,int fd,off_t offset, +size_t size,int additional_flags); + +/** +* @internal +* Unmap a particular resource. +* +* @param requested_addr +* The address for the unmapping range. +* @param size +* The size for the unmapping range. +*/ +void rte_eal_unmap_resource (void *requested_addr,size_t size); +#define RTE_PMD_EXPORT_NAME_ARRAY (n, idx) n##idx[]#define RTE_PMD_EXPORT_NAME (name, idx) \
lib/librte_eal/common/include/rte_pci.h +0 -32
@@ -399,38 +399,6 @@ int rte_eal_pci_map_device(struct rte_pci_device *dev);void rte_eal_pci_unmap_device (struct rte_pci_device *dev);/** -* @internal -* Map a particular resource from a file. -* -* @param requested_addr -* The starting address for the new mapping range. -* @param fd -* The file descriptor. -* @param offset -* The offset for the mapping range. -* @param size -* The size for the mapping range. -* @param additional_flags -* The additional flags for the mapping range. -* @return -* - On success, the function returns a pointer to the mapped area. -* - On error, the value MAP_FAILED is returned. -*/ -void *pci_map_resource (void *requested_addr,int fd,off_t offset, -size_t size,int additional_flags); - -/** -* @internal -* Unmap a particular resource. -* -* @param requested_addr -* The address for the unmapping range. -* @param size -* The size for the unmapping range. -*/ -void pci_unmap_resource (void *requested_addr,size_t size); - -/** * Probe the single PCI device. * * Scan the content of the PCI bus, and find the pci device specified by pci
lib/librte_eal/linuxapp/eal/eal_pci_uio.c +1 -1
@@ -347,7 +347,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,if (pci_map_addr ==NULL ) pci_map_addr =pci_find_max_end_va (); - mapaddr =pci_map_resource (pci_map_addr, fd,0 , + mapaddr =rte_eal_map_resource (pci_map_addr, fd,0 , (size_t )dev->mem_resource[res_idx].len,0 );close (fd);if (mapaddr ==MAP_FAILED )
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +3 -2
@@ -465,7 +465,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev)void *map_addr =NULL ;if (memreg[0 ].size) {/* actual map of first part */ - map_addr =pci_map_resource (bar_addr, vfio_dev_fd, + map_addr =rte_eal_map_resource (bar_addr, + vfio_dev_fd, memreg[0 ].offset, memreg[0 ].size,MAP_FIXED );
@@ -477,7 +478,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)void *second_addr =RTE_PTR_ADD (bar_addr, memreg[1 ].offset - (uintptr_t )reg.offset); - map_addr =pci_map_resource (second_addr, + map_addr =rte_eal_map_resource (second_addr, vfio_dev_fd, memreg[1 ].offset, memreg[1 ].size,MAP_FIXED );
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
@@ -174,6 +174,8 @@ DPDK_16.11 { rte_delay_us_callback_register; rte_eal_dev_attach; rte_eal_dev_detach; + rte_eal_map_resource; + rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister;
Signature · 1 line
2.7.4
PATCH v7 3/21 eal/linux: generalize PCI kernel unbinding driver to EAL
In reply to Shreyansh JainFrom: Jan Viktorin <[email protected]>
Generalize the PCI-specific pci_unbind_kernel_driver. It is now divided into two parts. First, determination of the path and string identification of the device to be unbound. Second, the actual unbind operation which is generic.
BSD implementation updated as ENOTSUP
--
Changes since v2:
- update BSD support for unbind kernel driver
--- lib/librte_eal/bsdapp/eal/eal.c | 7 +++++++ lib/librte_eal/bsdapp/eal/eal_pci.c | 4 ++-- lib/librte_eal/common/eal_private.h | 13 +++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 26 ++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 33 +++++++++------------------------ 5 files changed, 57 insertions(+), 26 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +7 -0
@@ -633,3 +633,10 @@ rte_eal_process_type(void) {return rte_config.process_type; } + +int +rte_eal_unbind_kernel_driver(const char *devpath __rte_unused, + const char *devid __rte_unused) +{ +return -ENOTSUP ; +}
lib/librte_eal/bsdapp/eal/eal_pci.c +2 -2
@@ -89,11 +89,11 @@/* unbind kernel driver for this device */ int -pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused) +pci_unbind_kernel_driver (struct rte_pci_device *dev) {RTE_LOG (ERR ,EAL ,"RTE_PCI_DRV_FORCE_UNBIND flag is not implemented " "for BSD\n" ); -return -ENOTSUP ; +return rte_eal_unbind_kernel_driver (dev); }/* Map pci device */
lib/librte_eal/common/eal_private.h +13 -0
@@ -256,6 +256,19 @@ int rte_eal_alarm_init(void);int rte_eal_check_module (const char *module_name);/** +* Unbind kernel driver bound to the device specified by the given devpath, +* and its string identification. +* +* @param devpath path to the device directory ("/sys/.../devices/<name>") +* @param devid identification of the device (<name>) +* +* @return +* -1 unbind has failed +* 0 module has been unbound +*/ +int rte_eal_unbind_kernel_driver (const char *devpath,const char *devid); + +/** * Get cpu core_id. * * This function is private to the EAL.
lib/librte_eal/linuxapp/eal/eal.c +26 -0
@@ -943,3 +943,29 @@ rte_eal_check_module(const char *module_name)/* Module has been found */ return 1 ; } + +int +rte_eal_unbind_kernel_driver (const char *devpath,const char *devid) +{ +char filename[PATH_MAX ]; +FILE *f; + +snprintf (filename,sizeof (filename), +"%s/driver/unbind" , devpath); + + f =fopen (filename,"w" ); +if (f ==NULL )/* device was not bound */ +return 0 ; + +if (fwrite (devid,strlen (devid),1 , f) ==0 ) { +RTE_LOG (ERR ,EAL ,"%s(): could not write to %s\n" , __func__, + filename); + goto error; + } + +fclose (f); +return 0 ; +error: +fclose (f); +return -1 ; +}
lib/librte_eal/linuxapp/eal/eal_pci.c +9 -24
@@ -59,38 +59,23 @@ int pci_unbind_kernel_driver(struct rte_pci_device *dev) {int n; -FILE *f; -char filename[PATH_MAX ]; -char buf[BUFSIZ ]; +char devpath[PATH_MAX ]; +char devid[BUFSIZ ];struct rte_pci_addr *loc = &dev->addr; -/* open /sys/bus/pci/devices/AAAA:BB:CC.D/driver */ -snprintf (filename,sizeof (filename), -"%s/" PCI_PRI_FMT "/driver/unbind" ,pci_get_sysfs_path (), +/* devpath /sys/bus/pci/devices/AAAA:BB:CC.D */ +snprintf (devpath,sizeof (devpath), +"%s/" PCI_PRI_FMT ,pci_get_sysfs_path (), loc->domain, loc->bus, loc->devid, loc->function); - f =fopen (filename,"w" ); -if (f ==NULL )/* device was not bound */ -return 0 ; - - n =snprintf (buf,sizeof (buf),PCI_PRI_FMT "\n" , + n =snprintf (devid,sizeof (devid),PCI_PRI_FMT "\n" , loc->domain, loc->bus, loc->devid, loc->function); -if ((n <0 ) || (n >= (int )sizeof (buf))) { +if ((n <0 ) || (n >= (int )sizeof (devid))) {RTE_LOG (ERR ,EAL ,"%s(): snprintf failed\n" , __func__); - goto error; - } -if (fwrite (buf, n,1 , f) ==0 ) { -RTE_LOG (ERR ,EAL ,"%s(): could not write to %s\n" , __func__, - filename); - goto error; +return -1 ; } -fclose (f); -return 0 ; - -error: -fclose (f); -return -1 ; +return rte_eal_unbind_kernel_driver (devpath, devid); } static int
Signature · 1 line
2.7.4