[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <07d0f972-ce8b-1938-579f-733b1547e745@codeaurora.org>
Date: Thu, 9 May 2019 15:53:49 +0530
From: Arun Kumar Neelakantam <aneela@...eaurora.org>
To: Bjorn Andersson <bjorn.andersson@...aro.org>,
"David S. Miller" <davem@...emloft.net>,
Chris Lew <clew@...eaurora.org>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-msm@...r.kernel.org
Subject: Re: [PATCH 1/5] net: qrtr: Move resume-tx transmission to recvmsg
On 5/8/2019 11:36 AM, Bjorn Andersson wrote:
> The confirm-rx bit is used to implement a per port flow control, in
> order to make sure that no messages are dropped due to resource
> exhaustion. Move the resume-tx transmission to recvmsg to only confirm
> messages as they are consumed by the application.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@...aro.org>
> ---
> net/qrtr/qrtr.c | 60 +++++++++++++++++++++++++++----------------------
> 1 file changed, 33 insertions(+), 27 deletions(-)
>
> diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
> index dd0e97f4f6c0..07a35362fba2 100644
> --- a/net/qrtr/qrtr.c
> +++ b/net/qrtr/qrtr.c
> @@ -369,22 +369,11 @@ static void qrtr_port_put(struct qrtr_sock *ipc);
> static void qrtr_node_rx_work(struct work_struct *work)
> {
> struct qrtr_node *node = container_of(work, struct qrtr_node, work);
> - struct qrtr_ctrl_pkt *pkt;
> - struct sockaddr_qrtr dst;
> - struct sockaddr_qrtr src;
> struct sk_buff *skb;
>
> while ((skb = skb_dequeue(&node->rx_queue)) != NULL) {
> struct qrtr_sock *ipc;
> - struct qrtr_cb *cb;
> - int confirm;
> -
> - cb = (struct qrtr_cb *)skb->cb;
> - src.sq_node = cb->src_node;
> - src.sq_port = cb->src_port;
> - dst.sq_node = cb->dst_node;
> - dst.sq_port = cb->dst_port;
> - confirm = !!cb->confirm_rx;
> + struct qrtr_cb *cb = (struct qrtr_cb *)skb->cb;
>
> qrtr_node_assign(node, cb->src_node);
>
> @@ -397,20 +386,6 @@ static void qrtr_node_rx_work(struct work_struct *work)
>
> qrtr_port_put(ipc);
> }
> -
> - if (confirm) {
> - skb = qrtr_alloc_ctrl_packet(&pkt);
> - if (!skb)
> - break;
> -
> - pkt->cmd = cpu_to_le32(QRTR_TYPE_RESUME_TX);
> - pkt->client.node = cpu_to_le32(dst.sq_node);
> - pkt->client.port = cpu_to_le32(dst.sq_port);
> -
> - if (qrtr_node_enqueue(node, skb, QRTR_TYPE_RESUME_TX,
> - &dst, &src))
> - break;
> - }
> }
> }
>
> @@ -822,6 +797,34 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
> return rc;
> }
>
> +static int qrtr_resume_tx(struct qrtr_cb *cb)
This function name is adding some confusion with qrtr_tx_resume() in
next patch. can you please rename this function to qrtr_send_resume_tx().
> +{
> + struct sockaddr_qrtr remote = { AF_QIPCRTR, cb->src_node, cb->src_port };
> + struct sockaddr_qrtr local = { AF_QIPCRTR, cb->dst_node, cb->dst_port };
> + struct qrtr_ctrl_pkt *pkt;
> + struct qrtr_node *node;
> + struct sk_buff *skb;
> + int ret;
> +
> + node = qrtr_node_lookup(remote.sq_node);
> + if (!node)
> + return -EINVAL;
> +
> + skb = qrtr_alloc_ctrl_packet(&pkt);
> + if (!skb)
> + return -ENOMEM;
> +
> + pkt->cmd = cpu_to_le32(QRTR_TYPE_RESUME_TX);
> + pkt->client.node = cpu_to_le32(cb->dst_node);
> + pkt->client.port = cpu_to_le32(cb->dst_port);
> +
> + ret = qrtr_node_enqueue(node, skb, QRTR_TYPE_RESUME_TX, &local, &remote);
> +
> + qrtr_node_release(node);
> +
> + return ret;
> +}
> +
> static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg,
> size_t size, int flags)
> {
> @@ -844,6 +847,7 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg,
> release_sock(sk);
> return rc;
> }
> + cb = (struct qrtr_cb *)skb->cb;
>
> copied = skb->len;
> if (copied > size) {
> @@ -857,7 +861,6 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg,
> rc = copied;
>
> if (addr) {
> - cb = (struct qrtr_cb *)skb->cb;
> addr->sq_family = AF_QIPCRTR;
> addr->sq_node = cb->src_node;
> addr->sq_port = cb->src_port;
> @@ -865,6 +868,9 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg,
> }
>
> out:
> + if (cb->confirm_rx)
> + qrtr_resume_tx(cb);
> +
> skb_free_datagram(sk, skb);
> release_sock(sk);
>
Powered by blists - more mailing lists