[dpdk-dev] [PATCH 06/12] eal: add channel for primary/secondary communication
Tan, Jianfeng
jianfeng.tan at intel.com
Thu Sep 21 08:11:42 CEST 2017
Hi Jiayu,
On 9/18/2017 9:49 PM, Jiayu Hu wrote:
> Hi Jianfeng,
>
>
> On Fri, Aug 25, 2017 at 09:40:46AM +0000, Jianfeng Tan wrote:
>> Previouly, there is only one way for primary/secondary to exchange
>> messages, that is, primary process writes info into some predefind
>> file, and secondary process reads info out. That cannot address
>> the requirements:
>> a. Secondary wants to send info to primary.
>> b. Sending info at any time, instead of just initialization time.
>> c. Share FD with the other side.
> If you can explain more about why the above three characters are required
> for enabling vdev in the secondary process here, that would be better. For
> example, vdev may hot plugin or remove, so the primary and the secondary
> process need to exchange data bidirectionally and dynamically.
OK, I'll exemplify each item with a case.
>
>> This patch proposes to create a communication channel (as an unix
>> socket connection) for above requirements.
> Can you give more explainations about how the channel works? Like both
> the primary and the secondary register actions for specific messages, and
> another thread is created to listen and react incoming messages.
I suppose for users/developers who want to use it, below description
about how to use related APIs is enough. As for how the channel is
created, i'll try to describe more here.
>
>> Three new APIs are added:
>>
>> 1. rte_eal_primary_secondary_add_action is used to register an action,
>> if the calling component wants to response the messages from the
>> corresponding component in its primary process or secondary processes.
>> 2. rte_eal_primary_secondary_del_action is used to unregister the
>> action if the calling component does not want to response the messages.
>> 3. rte_eal_primary_secondary_sendmsg is used to send a message.
>>
>> Signed-off-by: Jianfeng Tan <jianfeng.tan at intel.com>
>> ---
>> lib/librte_eal/bsdapp/eal/rte_eal_version.map | 8 +
>> lib/librte_eal/common/eal_common_proc.c | 454 ++++++++++++++++++++++++
>> lib/librte_eal/common/eal_filesystem.h | 18 +
>> lib/librte_eal/common/eal_private.h | 10 +
>> lib/librte_eal/common/include/rte_eal.h | 74 ++++
>> lib/librte_eal/linuxapp/eal/eal.c | 6 +
>> lib/librte_eal/linuxapp/eal/rte_eal_version.map | 8 +
>> 7 files changed, 578 insertions(+)
...
>> +
>> +int
>> +rte_eal_primary_secondary_add_action(const char *action_name,
>> + rte_eal_primary_secondary_t action)
>> +{
>> + struct action_entry *entry = malloc(sizeof(struct action_entry));
>> +
>> + if (entry == NULL)
>> + return -ENOMEM;
>> +
>> + strncpy(entry->action_name, action_name, MAX_ACTION_NAME_LEN);
>> + entry->action = action;
> In struct action_entry, the type of action is 'rte_eal_primary_secondary_t *',
> but you assign an object to action here.
Nice catch!
>
>> + TAILQ_INSERT_TAIL(&action_entry_list, entry, next);
> What would happen if register two actions for a same message name?
Hmm, yes, let's return error if there's an existing one for that name.
>
>> + return 0;
>> +}
>> +
>> +void
>> +rte_eal_primary_secondary_del_action(const char *name)
>> +{
>> + struct action_entry *entry = find_action_entry_by_name(name);
>> +
>> + TAILQ_REMOVE(&action_entry_list, entry, next);
>> + free(entry);
>> +}
>> +
>> +#define MAX_SECONDARY_PROCS 8
> A simple question: why the max number is 8?
Just a hard-coded value.
Thanks,
Jianfeng
More information about the dev
mailing list