From patchwork Wed May 8 06:06:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 163620 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp2259756ilm; Tue, 7 May 2019 23:06:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZAIFMZFuRc5l+IUfjGTaVpDr0QWrO2fM1fmDobN5YhkQ/OwL/pjhKY7wvztqXZxMmvmGw X-Received: by 2002:a63:6981:: with SMTP id e123mr44540521pgc.28.1557295611780; Tue, 07 May 2019 23:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557295611; cv=none; d=google.com; s=arc-20160816; b=EyKE0cBwuWE/rZVULK63WzwwTobhG8OceUcD7y6vrr2DVpa8IMCvcjE4Zl2xz7Ri8s NVNBJY8O8xTZ9D1RZDT5ymyWQs07D3+KJ1tHtEmaO6UHc4cPHHNg+k+DpcfqzvWiC/hL WwQHFqGmBDGn6DK5CxdC/JuYeRBZUWCUxU2hTHJ7hBdOK+AoaElnC0iyROGWGBtk5gPJ MIlhy/VZHQ/o+JJAx7ygW3zFcKQ0WYLl79/DN/Z9rTuOJkuCPUyfWGPeFEjIM9ZCAG0u RM8vL06X275qGDm6xEEWcgPeOoou9RCxOIdrw4F10mQtWwZq7QMoWLw3Y7m53kCusyNQ /clw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=e6SrybXQBzQ/pQVF99s2mcphn7kgLGBW4wNCs7GR8pQ=; b=NFtMirvt50xwsuuiIiNaMAq4WYoZtVqKdhz0DSyRH1Va9LddKj4yVCQZmmvv9++k/w jKThr3nSdWIf4FPUFPWZ3JuTJwQFTv3oM2QHqGTDrMUBbZRtpxHL6HyFSbh5yeS+a0TB gdfxWnCmMFBawM4LYromEfhoqvkdQ7Ute3ANX7aKnkDdg6dNWL6KPbZqyW2+VSodm+f7 Enui4IgFhe2McV+qPiByZoiLkH9Qw1no34V6Dqnnkl8p7gSTh80C5W/t/QtTqITlBMtL Gk3GrKce8QtBy2+yUIW3rJPv87GexKW1kH8ypico9G4zIYtrDX7gRyWITm930oq451KO iTPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mnVP4QJs; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13si11535643pgk.500.2019.05.07.23.06.51; Tue, 07 May 2019 23:06:51 -0700 (PDT) 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=@linaro.org header.s=google header.b=mnVP4QJs; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728629AbfEHGGu (ORCPT + 30 others); Wed, 8 May 2019 02:06:50 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33731 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726858AbfEHGGt (ORCPT ); Wed, 8 May 2019 02:06:49 -0400 Received: by mail-pg1-f193.google.com with SMTP id h17so3573094pgv.0 for ; Tue, 07 May 2019 23:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e6SrybXQBzQ/pQVF99s2mcphn7kgLGBW4wNCs7GR8pQ=; b=mnVP4QJsmIS3xsrRwE0Oyy7T8OIVzjRrDafg0KhMdBVUdYpXBLZFy/TupNd2N9NMNz upHa/EiNFZmErX+Yaguhkr2Zsv6wf/vhmy8UdCqaFWsxWwOBYNi8X2+jl73r3epkoSwW NmSV4DMbfMJdcHEQTZ6uY3r1yvbHtke4jQCuIUOPuNbuQ58ER0LvNSrt5V5CCFKD1sFO 4+qa0O10hUQE40dCmaUltBFdNbSY7UFDkQrBBsYKbE79TfMNGG4IHk58ctqN2NlYU7mv DG4XmEY0Phvyr33d1YGONqxxMhYCWhUUyXtK15WMdv5lVujEiVZoiLW/h1oIskrGs+K5 sKxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e6SrybXQBzQ/pQVF99s2mcphn7kgLGBW4wNCs7GR8pQ=; b=k5EdCH7sYXmVFPD0HpsH0g/6E5QbTEfS16M3JsdBAJgh1LWVkGlHV81VvXV37M73M5 Bc+YFGHYyguzRn5wm0vwZNBy8FFXr9ZxYOqbbjK+wz7U6DCETeR7FC628DqS4EbPdi5e +LVzyNA2+QI3lXmR6sGrGIFMKV4MrzWV+InlemMRWNc53khXh71IsWvNcH/QsHWodg74 uG6K6xhVg/eUqLPbissqT5MqZhLCF3FNrWcoGKntQOjrHrCGs4qSnO/CY8dnavjt2alu Q/+Hfb2cU7ie6M0iB+yA6Vu36/C8LyM+FqSq9m2+ooNS8XWhByfXv8OeLF2eETCBzwBC cpNQ== X-Gm-Message-State: APjAAAUj2LmKlIfl1Tu4B3xoavMrdF2DCQQHsXgS3COGUFE3+o+dezXO IDPEbrNjGjlWawFpnoyIcta5Aw== X-Received: by 2002:a62:e101:: with SMTP id q1mr46510709pfh.160.1557295608349; Tue, 07 May 2019 23:06:48 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id t5sm2756130pgn.80.2019.05.07.23.06.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 May 2019 23:06:47 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" , Arun Kumar Neelakantam , Chris Lew Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 1/5] net: qrtr: Move resume-tx transmission to recvmsg Date: Tue, 7 May 2019 23:06:39 -0700 Message-Id: <20190508060643.30936-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190508060643.30936-1-bjorn.andersson@linaro.org> References: <20190508060643.30936-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/qrtr/qrtr.c | 60 +++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 27 deletions(-) -- 2.18.0 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) +{ + 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);