From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 671D07D4E for ; Thu, 21 Sep 2017 08:11:47 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2017 23:11:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,423,1500966000"; d="scan'208";a="314529499" Received: from tanjianf-mobl.ccr.corp.intel.com (HELO [10.67.64.94]) ([10.67.64.94]) by fmsmga004.fm.intel.com with ESMTP; 20 Sep 2017 23:11:42 -0700 To: Jiayu Hu References: <1503654052-84730-1-git-send-email-jianfeng.tan@intel.com> <1503654052-84730-7-git-send-email-jianfeng.tan@intel.com> <20170918134934.GA93504@dpdk15.sh.intel.com> Cc: dev@dpdk.org, bruce.richardson@intel.com, konstantin.ananyev@intel.com, pablo.de.lara.guarch@intel.com, thomas@monjalon.net, yliu@fridaylinux.org, maxime.coquelin@redhat.com, mtetsuyah@gmail.com, ferruh.yigit@intel.com From: "Tan, Jianfeng" Message-ID: Date: Thu, 21 Sep 2017 14:11:42 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170918134934.GA93504@dpdk15.sh.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 06/12] eal: add channel for primary/secondary communication X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Sep 2017 06:11:48 -0000 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 >> --- >> 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