Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6620502ybl; Wed, 15 Jan 2020 07:34:38 -0800 (PST) X-Google-Smtp-Source: APXvYqxqV+dAK99YGIPynYl/SEPdL0tXFfXO72fQ2kSRFqdgGLj5Box0ovxHQoYJhjtiHLZxz4GE X-Received: by 2002:aca:4c07:: with SMTP id z7mr295821oia.74.1579102477901; Wed, 15 Jan 2020 07:34:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579102477; cv=none; d=google.com; s=arc-20160816; b=yJDq8wmIXrQb5I8z7X4HOPCx3PKrCDKDj/sMlNCfmwg218J5wN46V5h2COx9xhnAXZ 0/+RSdmsAhDg6gzmn6Edd/LMdfhNcmhAjRsCu6uWH8Ct5nmKrf/rlANxelcWfTr6V0HN GPIPxL6adnylbUnaywY5gUWW30WwR07p179rDvRRFluCcaiUDbfZ/mdJIP/nep0qe3Ba nGPkcy3FLcf21V+mJvTwRkeVm9R+vNfl+zRRVyXujtcTSPJIVGZurOZQPVfewKWoTeJc 2MspXcpbWIdjL5qxmH2JdGvIwt360hyuvB5hy4ydlF94m21+BpBEKTl1VEI2BHTTveB9 8gvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=CIFk2z09Rgz02itwkwKbH7Ge7nfwZT4HXBXZ1Nbl/zo=; b=qypd3S8huUz/z03UHubTyb3lWtaNTi+MbscI5C5hCbY0Z46u62pd9FAGC+0cH/7jnm aoCNGLMu3m4m39bkHrn0bE6IKx+vnRskQ4L7OG/BLVwGNRW2Ggjc2JV0F4P9iv4kblzx ronfYD5TiuGqh6rOWp4NYz+ppvZnOiwmHavb3rFOTm1dRutF8KfQ4/CakVysHAaNeIr4 nBUAzCmHzmZEXAzVQyrclg7kwhjrV0qbchWwRMerIQ2zgYebQFyY134hKBrxSG1IOTzy /P7MiPVmo/Kt38hPWrFEbRupYVRNjl+1mOz66ju0Kwf2Hc/SxYhcj4olEWz08AJfvTqZ T7Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xFnBcx4+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k23si9107177oiw.238.2020.01.15.07.34.25; Wed, 15 Jan 2020 07:34:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xFnBcx4+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728931AbgAOPc3 (ORCPT + 99 others); Wed, 15 Jan 2020 10:32:29 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:54296 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbgAOPc3 (ORCPT ); Wed, 15 Jan 2020 10:32:29 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 00FFWMfY033992; Wed, 15 Jan 2020 09:32:22 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1579102342; bh=CIFk2z09Rgz02itwkwKbH7Ge7nfwZT4HXBXZ1Nbl/zo=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=xFnBcx4+Uhej6Vz6Bz7EP8VZvHtQwU2E+pxVoHhvZdfjxQe2spY3EpUs6gyx4hlCA CWmmkcAaYTdlaCpJin0HL1FtiTT2Hyi/S+h6o+lgCP5qQyD/pkNNFTuRqJLwvD66AF +6qtkOI6H19tyqWdxkPSWMDADGscjeTztJXK/LjM= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 00FFWM5Q057468 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 15 Jan 2020 09:32:22 -0600 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Wed, 15 Jan 2020 09:32:22 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 15 Jan 2020 09:32:22 -0600 Received: from [128.247.58.153] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 00FFWLRR063623; Wed, 15 Jan 2020 09:32:21 -0600 Subject: Re: [PATCH v3] rpmsg: core: add API to get MTU To: Arnaud Pouliquen , Ohad Ben-Cohen , Bjorn Andersson , , , CC: Fabien DESSENNE , References: <20200115082722.13102-1-arnaud.pouliquen@st.com> From: Suman Anna Message-ID: <744500d3-643e-1446-1606-b4dde313e98f@ti.com> Date: Wed, 15 Jan 2020 09:32:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20200115082722.13102-1-arnaud.pouliquen@st.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/15/20 2:27 AM, Arnaud Pouliquen wrote: > Return the rpmsg buffer MTU for sending message, so rpmsg users > can split a long message in several sub rpmsg buffers. > > Signed-off-by: Arnaud Pouliquen Acked-by: Suman Anna regards Suman > --- > V2[1] to V3 > - fix parameter description in rpmsg_device_ops struct > > [1]: https://lore.kernel.org/patchwork/patch/1124684/ > --- > drivers/rpmsg/rpmsg_core.c | 21 +++++++++++++++++++++ > drivers/rpmsg/rpmsg_internal.h | 2 ++ > drivers/rpmsg/virtio_rpmsg_bus.c | 10 ++++++++++ > include/linux/rpmsg.h | 10 ++++++++++ > 4 files changed, 43 insertions(+) > > diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c > index e330ec4dfc33..a6ef54c4779a 100644 > --- a/drivers/rpmsg/rpmsg_core.c > +++ b/drivers/rpmsg/rpmsg_core.c > @@ -283,6 +283,27 @@ int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, > } > EXPORT_SYMBOL(rpmsg_trysend_offchannel); > > +/** > + * rpmsg_get_mtu() - get maximum transmission buffer size for sending message. > + * @ept: the rpmsg endpoint > + * > + * This function returns maximum buffer size available for a single message. > + * > + * Return: the maximum transmission size on success and an appropriate error > + * value on failure. > + */ > + > +ssize_t rpmsg_get_mtu(struct rpmsg_endpoint *ept) > +{ > + if (WARN_ON(!ept)) > + return -EINVAL; > + if (!ept->ops->get_mtu) > + return -ENOTSUPP; > + > + return ept->ops->get_mtu(ept); > +} > +EXPORT_SYMBOL(rpmsg_get_mtu); > + > /* > * match an rpmsg channel with a channel info struct. > * this is used to make sure we're not creating rpmsg devices for channels > diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h > index 3fc83cd50e98..e6f88ee90ff6 100644 > --- a/drivers/rpmsg/rpmsg_internal.h > +++ b/drivers/rpmsg/rpmsg_internal.h > @@ -47,6 +47,7 @@ struct rpmsg_device_ops { > * @trysendto: see @rpmsg_trysendto(), optional > * @trysend_offchannel: see @rpmsg_trysend_offchannel(), optional > * @poll: see @rpmsg_poll(), optional > + * @get_mtu: see @rpmsg_get_mtu(), optional > * > * Indirection table for the operations that a rpmsg backend should implement. > * In addition to @destroy_ept, the backend must at least implement @send and > @@ -66,6 +67,7 @@ struct rpmsg_endpoint_ops { > void *data, int len); > __poll_t (*poll)(struct rpmsg_endpoint *ept, struct file *filp, > poll_table *wait); > + ssize_t (*get_mtu)(struct rpmsg_endpoint *ept); > }; > > int rpmsg_register_device(struct rpmsg_device *rpdev); > diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c > index 376ebbf880d6..6e48fdf24555 100644 > --- a/drivers/rpmsg/virtio_rpmsg_bus.c > +++ b/drivers/rpmsg/virtio_rpmsg_bus.c > @@ -175,6 +175,7 @@ static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, > int len, u32 dst); > static int virtio_rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, > u32 dst, void *data, int len); > +static ssize_t virtio_rpmsg_get_mtu(struct rpmsg_endpoint *ept); > > static const struct rpmsg_endpoint_ops virtio_endpoint_ops = { > .destroy_ept = virtio_rpmsg_destroy_ept, > @@ -184,6 +185,7 @@ static const struct rpmsg_endpoint_ops virtio_endpoint_ops = { > .trysend = virtio_rpmsg_trysend, > .trysendto = virtio_rpmsg_trysendto, > .trysend_offchannel = virtio_rpmsg_trysend_offchannel, > + .get_mtu = virtio_rpmsg_get_mtu, > }; > > /** > @@ -699,6 +701,14 @@ static int virtio_rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, > return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); > } > > +static ssize_t virtio_rpmsg_get_mtu(struct rpmsg_endpoint *ept) > +{ > + struct rpmsg_device *rpdev = ept->rpdev; > + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); > + > + return vch->vrp->buf_size - sizeof(struct rpmsg_hdr); > +} > + > static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev, > struct rpmsg_hdr *msg, unsigned int len) > { > diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h > index 9fe156d1c018..88d7892ca93d 100644 > --- a/include/linux/rpmsg.h > +++ b/include/linux/rpmsg.h > @@ -135,6 +135,8 @@ int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, > __poll_t rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, > poll_table *wait); > > +ssize_t rpmsg_get_mtu(struct rpmsg_endpoint *ept); > + > #else > > static inline int register_rpmsg_device(struct rpmsg_device *dev) > @@ -242,6 +244,14 @@ static inline __poll_t rpmsg_poll(struct rpmsg_endpoint *ept, > return 0; > } > > +static inline ssize_t rpmsg_get_mtu(struct rpmsg_endpoint *ept) > +{ > + /* This shouldn't be possible */ > + WARN_ON(1); > + > + return -ENXIO; > +} > + > #endif /* IS_ENABLED(CONFIG_RPMSG) */ > > /* use a macro to avoid include chaining to get THIS_MODULE */ >