From patchwork Wed Jun 7 21:07:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 103313 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2133994qgd; Wed, 7 Jun 2017 14:08:31 -0700 (PDT) X-Received: by 10.84.130.99 with SMTP id 90mr30125947plc.165.1496869710911; Wed, 07 Jun 2017 14:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496869710; cv=none; d=google.com; s=arc-20160816; b=YN/yJBEJsvh5/wU+8nlPNl10zMWNwGb1Zr1ihm1xR7xpenXaE3/GHaIvoSZ/qeM8lI 6iZY+u3EsNoaXLtB9tC8ZSod2dVe+mKLWCnLi1IuOetxy0+t2s6tWX/ij4RdBOSks9TU 7KUnwxhfqJo/jzSLOodQNrNayw7oomAZ+gKq77KLpd8meU28SBV/i1ULQ9qF53Lng6vs CmUt6UOvvxf6JBL7XNpQlD97Mx9CubMfhvDAijBxB9wyRAP0xY/a0k+mvCW+rF8euyO4 BsrfA1nTVSD3idCgwnEUmyYqfw4Unxo83/tfydGiUDwanDZkYyV6XenY/Rf02YMmGlNf dcbA== 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:arc-authentication-results; bh=ZDli+ju3xukeebpOdUnUQQczHAQ9qeVy1KSorxXQB1Y=; b=polaorKbYLcABtBWBwZNY6GvU8X18b9omAiiBRmRpA/Soefw1XBc1rP7W5yzq3d+8w DWAD+WIYVeW7bBob3eRkWyzxRCts1Jtlzc4be7l76lWPc5fbWdEvfffVIcjUk03jTaI8 0wGvgWW9ZZJcNDDlzD8WZLY03jjzW9BW+Ie28t0lH5U2gV4eInZXGkK7+P4DBkyKL57S ckTsxmNJXBlzK5cwd+RcCmwQb3BHBHRwU9TYKkC2trFMSsYM/K4NMqOfkIqXfnvv74xU W6DfVSAEYzDrvmYHolW0lrG8ZnyqR9wbtpGqbL1w7CJp0iewFOeMoaG7Cd1IRkrp5QWg Jzzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 s82si2622156pgs.324.2017.06.07.14.08.30; Wed, 07 Jun 2017 14:08:30 -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; 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 S1751948AbdFGVHt (ORCPT + 25 others); Wed, 7 Jun 2017 17:07:49 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:33091 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751843AbdFGVHp (ORCPT ); Wed, 7 Jun 2017 17:07:45 -0400 Received: by mail-pf0-f171.google.com with SMTP id 83so9676553pfr.0 for ; Wed, 07 Jun 2017 14:07:45 -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=ZDli+ju3xukeebpOdUnUQQczHAQ9qeVy1KSorxXQB1Y=; b=JYkRMk66P2woW4i7Qq6UThwhTij7lFM77LD6i2dfZT1MwX2jKwDYuPe1kzIgqYKKnF /3g0Lt4KbF9d5CBgHTJftPXKCmaAhTNi6Qv7x7qZJ+0dD3Q9DwGQ8OrgjNSPlHhYEMKR M/8FUcHN04Fk7/KcRTWQhFe+cIRaI1hQ0L908= 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=ZDli+ju3xukeebpOdUnUQQczHAQ9qeVy1KSorxXQB1Y=; b=oXDyFcQMBAkOSCePvkf7nwqAp/ZVZt9xq0b6BqdciqUkGcKFilZHDvSEAE2RMjvImb INBp53m7uPv8BRzVlLXQfASe6J+HpJ3p50MuCpSn6okkplz4Q4N58abq62KMJYF1047q crVkZpel7KYfp6ETYnlO+/yH4aN0xIDK2VqaHoTvp7GaTxhVvTQ0rPc8MDI18Bc08jud DmPiwbFLFYj1qpRgKnnGFWKYpk9NY8abpZuzcePNhyh59y3asg2DHEXvdSK0mYNeDPu2 5Q8Ou+i8Fz0N9VOFFe6ljE1ooWUaz89K+Hx/3jQEbOUWyadAPM9HIfk7+x06zvmoZ1yF l4ew== X-Gm-Message-State: AODbwcDrbR9Xsn+yg8uLdyZzkxy8hVXPqQRr7cKKrbP3j+znf7/sEw8d jR73HmA+EK+2PdWn X-Received: by 10.84.215.216 with SMTP id g24mr30015822plj.201.1496869664519; Wed, 07 Jun 2017 14:07:44 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id s131sm6564392pgs.6.2017.06.07.14.07.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 14:07:43 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: Arun Kumar Neelakantam , netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Courtney Cavin Subject: [RESEND PATCH 1/4] net: qrtr: Refactor packet allocation Date: Wed, 7 Jun 2017 14:07:36 -0700 Message-Id: <20170607210739.27263-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170607210739.27263-1-bjorn.andersson@linaro.org> References: <20170607210739.27263-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extract the allocation and filling in the control message header fields to a separate function in order to reuse this in subsequent patches. Cc: Courtney Cavin Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) -- 2.12.0 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index a9a8c7d5a4a9..86d35ed50da9 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -245,14 +245,11 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) } EXPORT_SYMBOL_GPL(qrtr_endpoint_post); -/* Allocate and construct a resume-tx packet. */ -static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, - u32 dst_node, u32 port) +static struct sk_buff *qrtr_alloc_ctrl_packet(u32 type, size_t pkt_len, + u32 src_node, u32 dst_node) { - const int pkt_len = 20; struct qrtr_hdr *hdr; struct sk_buff *skb; - __le32 *buf; skb = alloc_skb(QRTR_HDR_SIZE + pkt_len, GFP_KERNEL); if (!skb) @@ -261,7 +258,7 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, hdr = (struct qrtr_hdr *)skb_put(skb, QRTR_HDR_SIZE); hdr->version = cpu_to_le32(QRTR_PROTO_VER); - hdr->type = cpu_to_le32(QRTR_TYPE_RESUME_TX); + hdr->type = cpu_to_le32(type); hdr->src_node_id = cpu_to_le32(src_node); hdr->src_port_id = cpu_to_le32(QRTR_PORT_CTRL); hdr->confirm_rx = cpu_to_le32(0); @@ -269,6 +266,22 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, hdr->dst_node_id = cpu_to_le32(dst_node); hdr->dst_port_id = cpu_to_le32(QRTR_PORT_CTRL); + return skb; +} + +/* Allocate and construct a resume-tx packet. */ +static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, + u32 dst_node, u32 port) +{ + const int pkt_len = 20; + struct sk_buff *skb; + __le32 *buf; + + skb = qrtr_alloc_ctrl_packet(QRTR_TYPE_RESUME_TX, pkt_len, + src_node, dst_node); + if (!skb) + return NULL; + buf = (__le32 *)skb_put(skb, pkt_len); memset(buf, 0, pkt_len); buf[0] = cpu_to_le32(QRTR_TYPE_RESUME_TX); From patchwork Wed Jun 7 21:07:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 103315 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2134185qgd; Wed, 7 Jun 2017 14:09:03 -0700 (PDT) X-Received: by 10.99.149.70 with SMTP id t6mr33971216pgn.168.1496869743314; Wed, 07 Jun 2017 14:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496869743; cv=none; d=google.com; s=arc-20160816; b=0qnpjVS30n52bjak8HTUOZuaE6yxeryGFy/+Qj6h8S1oG17f401PpOOjIpcug6emns 7NlChx77A/7YTKKuaY4tqxGHmQ/Dk6JTWb+fmB7nYGHZtNDV9sMCCiC8IKNs1HLP52DL WFObZZ+fR7mKJvjR1TIb+gzQq6RRBhBOmtIwo4gzEtKokeX3B5lIQFoo6Zs9x3fOLqrY O1wu4MihBUZ5+qmIaBeRnCgq8mp/VxrFCajHiKSleTWImqmiptE2QKz6wBMzlu1hffwo 3ZUgyhmjH44fZXA+5i6ZihaTciDpUy1yl/RNvO79zvW7RAbh4SbhMcgFYG4YxeTPTiaQ OjTQ== 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:arc-authentication-results; bh=wsbAtJQRkV+WiCryejZUb4dPHA+7dvCq1BleeeWvY4Q=; b=LJrWLgrR4fq6BI5fRYQYLAd/KyDjgr5lZGheVxY2PuiXUD3YoWXNy1h3/NNeUNucx7 De517sTHxHg7yFTYVCDCSHPUXGPqgdWX3p4ofc8xfjS2jBVsUoAP546ayYvk3kokfjoq SFbtINVC0q+GSklxuv0cdpJHaFNyXoim8An+Jj853B4/HZMoyAkZfiDgdPy3osr68Gng zZyCdSm57K2iMzHkzvx92iIm2nfXD44QTr0JSM1ofCcwn9FZQP83y6wG3R/EuO60yEjk QWgpaF4JqhUi79dCjjPZyfdUFPfwOwsVn0lElvTqAhMvwtNAHBAHrCT2PltNsCWawt93 F1KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 e5si2667824plk.249.2017.06.07.14.09.03; Wed, 07 Jun 2017 14:09:03 -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; 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 S1752038AbdFGVIj (ORCPT + 25 others); Wed, 7 Jun 2017 17:08:39 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:33951 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751893AbdFGVHr (ORCPT ); Wed, 7 Jun 2017 17:07:47 -0400 Received: by mail-pf0-f172.google.com with SMTP id 9so9681653pfj.1 for ; Wed, 07 Jun 2017 14:07:47 -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=wsbAtJQRkV+WiCryejZUb4dPHA+7dvCq1BleeeWvY4Q=; b=CqLcjrZ6GxtVYKfI0zm97qSVimSIP6jLJ5CmqSIvWzOfjiWrigYH9wRnlH5S2SXIPN CKM6iPfzIyNvh9ICB7MfOEfxbWGZkvRw8aBQq5C1B/GI6GgM8l+d2AtyAUiAcR7ktyYm 6wYCikXYmjN2ylWCuA8dTaQIX+mwk97yHmt1I= 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=wsbAtJQRkV+WiCryejZUb4dPHA+7dvCq1BleeeWvY4Q=; b=VuAw/fqHCcFSX4+2nWQU81CF3EIsLg0xaw839XuektrJ9agvEm6kuhfOkn/59ChQ3M MXLbCMpZwMsYu86rM21U7Jzn4prowg6ybbdHEsaeGbE2hj89WdlAvBCB0LirERToV56H JMhdPASxteVdpwECkDP8aVAP+yNAf2YXnjU883YzMKPHUy4Cu7SQ8tAdPxKRVrnaJ5a7 tEk+b/CDAVJntt0XLmxg4s0EWPYsI7g8Tkz2/tDo7N6LdJ9RrZaNhGW6otn7op5B7MEk HPJhBw/423MOSvW+pvzjXo5aGTOQzr3IVcEdztiWMQlT8UQMHb5Q3vB60fWgd5iuqaVF cSHA== X-Gm-Message-State: AODbwcCwDvkCSjTtYnG8Ba+Wnhwd9BQ+3lnj14JZnKBbXfR4nktBCQ5o 6NRwdFgTG/85+rX8 X-Received: by 10.84.217.206 with SMTP id d14mr29932204plj.59.1496869666563; Wed, 07 Jun 2017 14:07:46 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id s131sm6564392pgs.6.2017.06.07.14.07.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 14:07:46 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: Arun Kumar Neelakantam , netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Courtney Cavin Subject: [RESEND PATCH 3/4] net: qrtr: Broadcast DEL_CLIENT message when endpoint is closed Date: Wed, 7 Jun 2017 14:07:38 -0700 Message-Id: <20170607210739.27263-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170607210739.27263-1-bjorn.andersson@linaro.org> References: <20170607210739.27263-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Per the QMUXv2 protocol specificiation a DEL_CLIENT message should be broadcasted when an endpoint is disconnected. The protocol specification does suggest that the router can keep track of which nodes the endpoint has been communicating with to not wake up sleeping remotes unecessarily, but implementation of this suggestion is left for the future. Cc: Courtney Cavin Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) -- 2.12.0 diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index e8cbab23d667..d7516098b5aa 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -112,6 +112,7 @@ struct qrtr_node { }; static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb); +static int qrtr_bcast_enqueue(struct qrtr_node *node, struct sk_buff *skb); /* Release node resources and free the node. * @@ -312,6 +313,26 @@ static struct sk_buff *qrtr_alloc_local_bye(u32 src_node) return skb; } +static struct sk_buff *qrtr_alloc_del_client(struct sockaddr_qrtr *sq) +{ + const int pkt_len = 20; + struct sk_buff *skb; + __le32 *buf; + + skb = qrtr_alloc_ctrl_packet(QRTR_TYPE_DEL_CLIENT, pkt_len, + sq->sq_node, QRTR_NODE_BCAST); + if (!skb) + return NULL; + + buf = (__le32 *)skb_put(skb, pkt_len); + memset(buf, 0, pkt_len); + buf[0] = cpu_to_le32(QRTR_TYPE_DEL_CLIENT); + buf[1] = cpu_to_le32(sq->sq_node); + buf[2] = cpu_to_le32(sq->sq_port); + + return skb; +} + static struct qrtr_sock *qrtr_port_lookup(int port); static void qrtr_port_put(struct qrtr_sock *ipc); @@ -448,8 +469,15 @@ static void qrtr_port_put(struct qrtr_sock *ipc) /* Remove port assignment. */ static void qrtr_port_remove(struct qrtr_sock *ipc) { + struct sk_buff *skb; int port = ipc->us.sq_port; + skb = qrtr_alloc_del_client(&ipc->us); + if (skb) { + skb_set_owner_w(skb, &ipc->sk); + qrtr_bcast_enqueue(NULL, skb); + } + if (port == QRTR_PORT_CTRL) port = 0;