From patchwork Fri Jul 31 11:47:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11694671 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 716481392 for ; Fri, 31 Jul 2020 11:47:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59CD72245C for ; Fri, 31 Jul 2020 11:47:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="HkU9S/+l" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732829AbgGaLry (ORCPT ); Fri, 31 Jul 2020 07:47:54 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:7998 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732801AbgGaLrx (ORCPT ); Fri, 31 Jul 2020 07:47:53 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VBcegX030181; Fri, 31 Jul 2020 13:47:49 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=Al7/FWHuiKIExSa/T5bbmCEZ2bGtSZGlFAqWKG8rmMA=; b=HkU9S/+lcHz2FLd0drohPVM+U+RBzT3b7ggjqmjvfqFeFOglU0OXbysVBIq2YQSVwjg4 okcYNwpREz+9Oq9vMPDoqN8OBG4gvGQuyMtidTQycxRJld+XCS5bXFY2IekQ3Rg/eieY Yeo/B9j80tHNppPunUZxD0MIee5PFq2Zjuy2y8niAMD5d33xt1KGulTEaxuoA6Qfdc2c +5G3JPIuJb3l3O4sMBkV0GabaenRgTI41ULQq+nh+/bVE8fXQRu5Fw/U23Ne5J9hiYlK DB927EcSsbOPvcJikONeG4TyAGgeKclyTmv2C04MBHWUNrehVSSraThpmv+XF7Faa89b pQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32ga72d9jr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 13:47:48 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 88B39100038; Fri, 31 Jul 2020 13:47:48 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7D8DD2A7A83; Fri, 31 Jul 2020 13:47:48 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 13:47:47 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 7/9] rpmsg: ns: add name service announcement service Date: Fri, 31 Jul 2020 13:47:30 +0200 Message-ID: <20200731114732.12815-8-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731114732.12815-1-arnaud.pouliquen@st.com> References: <20200731114732.12815-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org As the RPMsg driver is in charge of the name service announcement, create an API to send channel creation and destruction to the remote processor. Notice that the source address of the message sent is now RPMSG_NS_ADDR. Legacy implementation was to send the message with source address corresponding to the ept created. RPMSG_NS_ADDR as source address make sense as we want to send a message belonging to the NS announcement service and the created ept address is already in the message payload. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_internal.h | 3 +++ drivers/rpmsg/rpmsg_ns.c | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 641b48f6bf2a..d1549e5cb607 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -119,4 +119,7 @@ static inline int rpmsg_ns_register_device(struct rpmsg_device *rpdev) return rpmsg_register_device(rpdev); } +int rpmsg_ns_announce_create(struct rpmsg_device *rpdev); +int rpmsg_ns_announce_destroy(struct rpmsg_device *rpdev); + #endif diff --git a/drivers/rpmsg/rpmsg_ns.c b/drivers/rpmsg/rpmsg_ns.c index fe7713e737c2..cc2bd47c415a 100644 --- a/drivers/rpmsg/rpmsg_ns.c +++ b/drivers/rpmsg/rpmsg_ns.c @@ -37,6 +37,45 @@ struct rpmsg_ns_msg { u32 flags; } __packed; +/** + * rpmsg_ns_announce_create() -announce to the remote processor + * the service creation or destruction + * @rpdev: the rpmsg channel + * @ns_flag: related to the @rpmsg_ns_flags enum + * + * This function can be called on a channel creation or destruction to inform + * the remote processor, using the reserved name service anouncement channel. + */ +static int rpmsg_ns_channel_announce(struct rpmsg_device *rpdev, int ns_flag) +{ + struct rpmsg_ns_msg nsm; + + if (!rpdev->announce || !rpdev->ept) + return 0; + + if (ns_flag != RPMSG_NS_CREATE && ns_flag != RPMSG_NS_DESTROY) + return -EINVAL; + + strncpy(nsm.name, rpdev->id.name, RPMSG_NAME_SIZE); + nsm.addr = rpdev->ept->addr; + nsm.flags = ns_flag; + + return rpmsg_send_offchannel(rpdev->ept, RPMSG_NS_ADDR, RPMSG_NS_ADDR, + &nsm, sizeof(nsm)); +} + +int rpmsg_ns_announce_create(struct rpmsg_device *rpdev) +{ + return rpmsg_ns_channel_announce(rpdev, RPMSG_NS_CREATE); +} +EXPORT_SYMBOL(rpmsg_ns_announce_create); + +int rpmsg_ns_announce_destroy(struct rpmsg_device *rpdev) +{ + return rpmsg_ns_channel_announce(rpdev, RPMSG_NS_DESTROY); +} +EXPORT_SYMBOL(rpmsg_ns_announce_destroy); + /* invoked when a name service announcement arrives */ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, void *priv, u32 src)