Received: by 10.213.65.68 with SMTP id h4csp916583imn; Wed, 14 Mar 2018 04:14:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELth2ItjAyJAqjs/rlhhMxqMxeWSetY2U5k1o5Zr3CU4VxeTPoQ4VgWz8NT9XkbBCVBrBKNL X-Received: by 10.101.75.202 with SMTP id p10mr925268pgr.339.1521026079446; Wed, 14 Mar 2018 04:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521026079; cv=none; d=google.com; s=arc-20160816; b=H98XTOcIP3gFqLrOB6pfhv876Vylg0cvWode1LXvxjnKPb3lq8WEsiukqb8jEGN6/N 1LEU9sAaGmZs+fq5WmK7YNo8f82m1Ns7E8KPQVkWkTn2LFRPdm5Ur/Il7Pn3NSzPnaYx GOamUV8U5HgVLBvatObwUCSFSAJspZI+ORKPkYd3F0nS8Um1bJhJOQhNXkTKascb8n6B oyN3lLANSb8lXunZUHCtSAfQwVYz8DfCKSbS0QYNN/LijEQtHrGGXPN+3Zv9gA4Lpjar CcESdfsdocmARJr2xhQylWxHnqYlSfRqKNBESVKWXHFBD36KZoJ20FHhwS+dCdZlAKew k9XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=grhp/4IXPtjhVcmeq8FmqjZOvVm6moAXIsuw1FopPrM=; b=IqesRjMVrNJRS0/ZsG4ZXAuIHVEucn6DO++obJuhmwOs9gm4Pe+U22Us5pQlH5G0qt CqshxqCBseimGt8Dsbtb6dLCJbpT3CaFe1K3FJGatHaOgh4OEJvRTOn41pE9Js7BVm8l hwfGuz1GqbQFv2kK/t7RYoiOeKMq/O7S913NuFgBfIBx0iHb+LZcd5+EGV9Umo57kcym APdhu+uY3zbutDmdXG/l1hDY2ox/PZRFrRPO3DbRJK1B8B6/9DKK+COsY9PsJ9uEKiHg /OKC46LDX2A0CInA/uwHtLJnTun3Le8/awDSePj/5cA+FJmVJqxF1j2UCy6rh/qpVT2j L90g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@de.bosch.com header.s=2015-01-21 header.b=Gz6MO3gO; 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=fail (p=NONE sp=NONE dis=NONE) header.from=de.bosch.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f29si1872634pff.364.2018.03.14.04.14.24; Wed, 14 Mar 2018 04:14:39 -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=fail header.i=@de.bosch.com header.s=2015-01-21 header.b=Gz6MO3gO; 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=fail (p=NONE sp=NONE dis=NONE) header.from=de.bosch.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752047AbeCNLMG (ORCPT + 99 others); Wed, 14 Mar 2018 07:12:06 -0400 Received: from de-deferred2.bosch-org.com ([139.15.180.217]:44044 "EHLO de-deferred2.bosch-org.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750751AbeCNLMD (ORCPT ); Wed, 14 Mar 2018 07:12:03 -0400 X-Greylist: delayed 512 seconds by postgrey-1.27 at vger.kernel.org; Wed, 14 Mar 2018 07:12:03 EDT Received: from de-out1.bosch-org.com (snat-lb41g3-dmz-psi-sl1-maildeferred.fe.ssn.bosch.com [139.15.180.215]) by fe0vms0193.rbdmz01.com (Postfix) with ESMTPS id 401TNd0Hy9zdRn; Wed, 14 Mar 2018 12:03:29 +0100 (CET) Received: from si0vm1947.rbesz01.com (lb41g3-ha-dmz-psi-sl1-mailout.fe.ssn.bosch.com [139.15.230.188]) by fe0vms0186.rbdmz01.com (Postfix) with ESMTPS id 401TNb3mZqz1XLFV5; Wed, 14 Mar 2018 12:03:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1521025407; bh=xKWvSJAExCFYwQPkF9cpeARYs1KgGM4+MQ0/Lt2hetU=; l=10; h=From:From:Reply-To:Sender; b=Gz6MO3gOPgfSq+hSPF3PV3c4KnNoIfYVXugr5HuiblrYTJQtV3G6qt9obfOTgyN/s YrrbgkbdYai41r4+0zrfS/7nAfONlaX31JP5D2kd1Y9om7xZb4delon1qjEGBosllh Jwc2zy+vcEC5CcErrV68ypEeemzMDdYnmun+Tdzs= Received: from fe0vm1741.rbesz01.com (unknown [10.58.172.176]) by si0vm1947.rbesz01.com (Postfix) with ESMTPS id 401TNb3KsQz6CjQ3D; Wed, 14 Mar 2018 12:03:27 +0100 (CET) X-AuditID: 0a3aad15-083ff700000062e5-7c-5aa901802c9b Received: from si0vm1950.rbesz01.com ( [10.58.173.29]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by fe0vm1741.rbesz01.com (SMG Outbound) with SMTP id 6C.89.25317.08109AA5; Wed, 14 Mar 2018 12:03:28 +0100 (CET) Received: from FE-HUB1000.de.bosch.com (fe-hub1000.de.bosch.com [10.4.103.107]) by si0vm1950.rbesz01.com (Postfix) with ESMTPS id 401TNb1nBVzCpNK; Wed, 14 Mar 2018 12:03:27 +0100 (CET) Received: from luchador.grb-fir.grb.de.bosch.com (10.19.187.97) by FE-HUB1000.de.bosch.com (10.4.103.107) with Microsoft SMTP Server id 14.3.319.2; Wed, 14 Mar 2018 12:03:26 +0100 From: Mark Jonas To: Wolfgang Grandegger , Marc Kleine-Budde CC: , , , , Zhu Yi , Mark Jonas Subject: [PATCH] can: enable multi-queue for SocketCAN devices Date: Wed, 14 Mar 2018 11:33:16 +0100 Message-ID: <1521023596-30108-1-git-send-email-mark.jonas@de.bosch.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Brightmail-Tracker: H4sIAAAAAAAAA22Sa0xTZxzGeXsO5bT0mMMphb+Vgp64KCa6snnp5iUkmtjsixpvsermYT3S Km1JTyGU+aFbBooaFagxdgQLCkGMuOCFWk0amoy0EKeibGNsujBcOsA5RVYULzuHgu0Hv/3z PP/f+7zvk5fA6HMpasJsdXB2K1vESOW4/NOLmsUudN6g7euep/P99hDTtUZPYrp7/jqp7lKj G9d1eTN0TQ+uJ+dL9fWeEK5/2juA9Mdfa/Vj7dkbcYN8lZErMpdy9g/X7JGbWl7fQMXts8u+ 7VzlQkdUh5GMAGopVL+qQ4eRnKCpUxIY66qRigZN3UTw3z/m2NyBoMZrEWcptQj6Qz5MnNOp rfDdo0pchDHqe2Fn8LZENJTUGqi61oyLM059AC09LVM6Sa2H1ju/4rHkbOj/sQqL6WkQPj00 pWMUQGckgp1ApCfB8iRYXiRpRaq9nLbUkrdiad4SewHHl2vzlnxps7SjWG0qH2po2BZEFIEY BVmfdN5AJ7OlvNMSRMsICaMiA+4WAz2rwGZ0mlje9IW9pIjjGTWJkpKSaOU7mS8psJh53myz BhEQGJNOXs0SONLIOss5uy2GBdEcAmcyyaPGAwaaKmQd3H6OK+bsM+5KgmCAvP1WANPsXCFX ttdc5JixGU0sMyPRSYyVELIg+phQCNlR8QiSL2YtvLlwGp8dw+kZNY52o7XEL5GRSozGrTYr p84ktSJPiZumEuu7G6izyN2KZgOtSjDipwyjfiR0qCR5sUOF8Dvj2UD6lHU76LRpMQ591CQw 1EAq1PvGEYR8B3GYcNXi0Bbpw+FF9V84hKIdyfD88WQy9Po9KVA1WimDu4eeyOD5ZCAVxj1v U6H2ZoCEiZN1FNy/+7MSJtpH06H6jisDxir8mTB6wa8Wlrs0cP9WRAM/XenOhqGvXTkwFIjm wPgf43NhqPMbBhpbjy2A8MiDhdD57N+FEP7bmwsR15VcCLtf5g4LxUqEYs3Xpop1sI73FDut xl+ndqFUZ7Q5R4P0HT3uMw99g8ayufv61rYNnygtl88fGVBHt7ibenZWkdGarImXvwf2pdxS bO3NX+3xju7f4CpUWvhTO52RQ7X3Ahcuvwg0HA09erN88597tle417FZbT+cqeDnfNK/+MlZ 52TF4Ff+4U35ssvbtoRXt7FvbjTv+uzzI427GZw3sXmLMDvP/g9Z97mVNwQAAA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhu Yi The existing SocketCAN implementation provides alloc_candev() to allocate a CAN device using a single Tx and Rx queue. This can lead to priority inversion in case the single Tx queue is already full with low priority messages and a high priority message needs to be sent while the bus is fully loaded with medium priority messages. This problem can be solved by using the existing multi-queue support of the network subsystem. The commit makes it possible to use multi-queue in the CAN subsystem in the same way it is used in the Ethernet subsystem by adding an alloc_candev_mqs() call and accompanying macros. With this support a CAN device can use multi-queue qdisc (e.g. mqprio) to avoid the aforementioned priority inversion. The existing functionality of alloc_candev() is the same as before. CAN devices need to have prioritized multiple hardware queues or are able to abort waiting for arbitration to make sensible use of multi-queues. Signed-off-by: Zhu Yi Signed-off-by: Mark Jonas Reviewed-by: Heiko Schocher --- drivers/net/can/dev.c | 8 +++++--- include/linux/can/dev.h | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index b177956..636f853 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c @@ -703,7 +703,8 @@ EXPORT_SYMBOL_GPL(alloc_can_err_skb); /* * Allocate and setup space for the CAN network device */ -struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max) +struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max, + unsigned int txqs, unsigned int rxqs) { struct net_device *dev; struct can_priv *priv; @@ -715,7 +716,8 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max) else size = sizeof_priv; - dev = alloc_netdev(size, "can%d", NET_NAME_UNKNOWN, can_setup); + dev = alloc_netdev_mqs(size, "can%d", NET_NAME_UNKNOWN, can_setup, + txqs, rxqs); if (!dev) return NULL; @@ -734,7 +736,7 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max) return dev; } -EXPORT_SYMBOL_GPL(alloc_candev); +EXPORT_SYMBOL_GPL(alloc_candev_mqs); /* * Free space of the CAN network device diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 055aaf5..a83e1f6 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -143,7 +143,12 @@ u8 can_dlc2len(u8 can_dlc); /* map the sanitized data length to an appropriate data length code */ u8 can_len2dlc(u8 len); -struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); +struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max, + unsigned int txqs, unsigned int rxqs); +#define alloc_candev(sizeof_priv, echo_skb_max) \ + alloc_candev_mqs(sizeof_priv, echo_skb_max, 1, 1) +#define alloc_candev_mq(sizeof_priv, echo_skb_max, count) \ + alloc_candev_mqs(sizeof_priv, echo_skb_max, count, count) void free_candev(struct net_device *dev); /* a candev safe wrapper around netdev_priv */ -- 2.7.4