From patchwork Tue Jul 26 21:02:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2257 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 9E3703F081 for ; Tue, 26 Jul 2022 23:03:33 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id dz20-20020a0564021d5400b0043be2c5cd32sf5349862edb.2 for ; Tue, 26 Jul 2022 14:03:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658869413; cv=pass; d=google.com; s=arc-20160816; b=To0rp46GPry7AOotnS2NAGY9R/X/1/ntMOMcbeuXpC/uHyZX8we16OP1jw7Y6uQgRV qKNrXxHVSIljkUnnGzSgsPcqlNnTmSosXdMVoMHDH7NibRwhXOuGL98VBBBigWzu0/iJ pTw8ROO/x+4fqv4wFR66g/YNsDbGM9pB4x0qAB55Dzxs40JWflKh5sPZmCXqJ5g20653 FHseugoxZ5bCW9gMizgdY4eD78Ya4aypVS8DdDXS6iGfLWHi/EMmav61YntvDRAabHyg Bn8fgklpQUzbiZJZTbpQb9FHS5Wz3EYPmcLOdvSN6h6y4sKlyayzTBSZtkpHUbv1ntZk F0yQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ld54SDtYXLxUGopup6ScpeTylocEzEsXm7cbEHLuHgE=; b=q3pRWfaP0/KubnAnulazSI1/hNGY5fON8Xdndy/vziNdx03306DoHLV0qACLR+Dou3 pzRm2bveA+i3QsQY4X+lVVMQ7Yaf54j+4I304YhGfcM2xayVD/Yc0ypRsSTvqsEcFUB7 DpmZ9mqePkoXAWoqwahqM8O1/yyISf8uAqLSSL5WLZ8JUrPgnh5xk/F34Ib9uR3ns/HG u0z4Nxq3vrZh7SFUnKrCCDDSR4Nw7HMM87rvjFETd756vBaID88buP3gLtf51uHl7hl4 VnTxtpwIibZxCGSntetRHGUjesTdEK3U/eTrSQrspuMQtz8nJ/TJxNioxoRbTA2JJ/Zg yXTw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="GloOwx/m"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=ld54SDtYXLxUGopup6ScpeTylocEzEsXm7cbEHLuHgE=; b=o+IgdSlM6GRrusBpsAc0V8JVSYnbrZ5sm65Qq4DNzq2oJTyvbhP14P7lYOtJc4PhU3 p9g31pZy/nS+G0AdGDhl+fAH22Lb/ngUMoqW4uQ/s78WZepGmKHlDMLAbo2ktkzRUyGx nLKVqqEGS3NdtTWETyzM1Yl0Zk4gu6JMZlXoI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=ld54SDtYXLxUGopup6ScpeTylocEzEsXm7cbEHLuHgE=; b=xzjrr4agMIv7dZ3UKm+lO2iCxftgnIR9lXTju4fmUCEhxCvvNnl4NsWPf1tyUqVlFz SaSB9KVrI0aslXPdLyOBKUtJ6cIXH109MSf3JY1EnrfS9ZA7Cc/RvTgkByL8UatBsAjM hJfRwTsMig5Msaez8R2h+iYgChH2h+B58BNdUAE0Wb6H+D8vzUtmPVSnwfIRTISGRglj oJIR7OKeqcSUqOJMHUCV3oIXKwJyl14rRLDYi/GqdWtc+OOeB2h0eKfNYW4jcrqoyb9m z2AMsiVt/WS35sMuoQ5u/YDJJoAdB7XIwuuiD60U3AJp63tiDk5DV/dsYcY09Kru4ghY pg0Q== X-Gm-Message-State: AJIora9lXO7mSamOIiH9CJ/q9/CvVLd1vG/MNlo6rqWRvfcbeECXm+7l kwues0fVUimZStAZoRlVaHg1FDJV X-Google-Smtp-Source: AGRyM1vjJ3IqqInLz4zvL877fxaV2ncKmHsfvebD6U8vs6E7nE9vn5KU2JTUWko9AZCzzUvJF4ZpTg== X-Received: by 2002:a17:906:98c8:b0:72b:3a31:6cc3 with SMTP id zd8-20020a17090698c800b0072b3a316cc3mr15449182ejb.597.1658869413474; Tue, 26 Jul 2022 14:03:33 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:af86:b0:72b:41fa:b554 with SMTP id mj6-20020a170906af8600b0072b41fab554ls1355497ejb.10.-pod-prod-gmail; Tue, 26 Jul 2022 14:03:32 -0700 (PDT) X-Received: by 2002:a17:907:a218:b0:72b:8aae:3f84 with SMTP id qp24-20020a170907a21800b0072b8aae3f84mr15200441ejc.367.1658869412509; Tue, 26 Jul 2022 14:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658869412; cv=none; d=google.com; s=arc-20160816; b=freYmc6xCUfIpHsKPCnQekBAEje1B55YbqwTmOuykZd6LDSXCE/y2bexlw2W7/SCYq F7Nvj08u/wmif6R1kpde6Zzp4RQRLBX9W4oO0U2FE4SqJyD1azPODgglovzmE9AI4Uf8 ZqnnC71rlOLQIRgkVQh93ztkcDopqVJmAwumqLAILDRCa719xwoPcWtWCu2zPKgH5eQO KCy2vHF4noHWNqlmlVEveh7bSWQ5ofnTq3HxgF6dZ+qAqC3lttBlnTCkkFoUbdWUjOBj OGI9mMuEOoAwj4ZbZ7PtPet4yEVeYrqZcTmqWHAGhJb1iZE1qsD+tSta0qJm+oZVpIvu WpUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=rbjoK64u0Nv21CxxlQFKwTPmVGnv7nDMih2pZ9805sY=; b=zf7EnrCHSfrbjeG6ug0gyWn7gq+NlDpUZoJAnxR9rDrfXx+M4e3u7pC4dT6RsmbI3E Jo5ih0h2TR8K7QJYZ7Ws7j4UuVe7vHHuozRXHuTuJtgoC8zvcEJt7hg0lP3tMmYBfGye SD11gYzQYTmT6WR90TXVX8XiH5mCCjs6ptaMlIDIPCkq2bb52APLZwi0dlay6yzvVZ+5 T7A3Pen/rJyPdNXjnF4lQSdlueNf8JeIS2rVA6QMz4h+/dT4CuejqLjBcSxJjNRzxWkl JYLx/LcHHQ2xLOQ/yElTpwSsZa7UUJc+Mq/86nTGizojQ+v3GV9LGlBV9vzR0BLYgDb0 fz2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="GloOwx/m"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id s1-20020a170906bc4100b007262f75c699sor6191628ejv.116.2022.07.26.14.03.32 for (Google Transport Security); Tue, 26 Jul 2022 14:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:3f1a:b0:72b:394b:ad32 with SMTP id hq26-20020a1709073f1a00b0072b394bad32mr15286276ejc.445.1658869412188; Tue, 26 Jul 2022 14:03:32 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-14-98-67.retail.telecomitalia.it. [87.14.98.67]) by smtp.gmail.com with ESMTPSA id y19-20020aa7d513000000b0043a7293a03dsm9092849edq.7.2022.07.26.14.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 14:03:31 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-can@vger.kernel.org, Marc Kleine-Budde , Oliver Hartkopp , michael@amarulasolutions.com, Amarula patchwork , Jeroen Hofstee , Dario Binacchi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wolfgang Grandegger , netdev@vger.kernel.org Subject: [RFC PATCH v3 6/9] can: slcan: add support for listen-only mode Date: Tue, 26 Jul 2022 23:02:14 +0200 Message-Id: <20220726210217.3368497-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220726210217.3368497-1-dario.binacchi@amarulasolutions.com> References: <20220726210217.3368497-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="GloOwx/m"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , For non-legacy, i.e. ip based configuration, add support for listen-only mode. If listen-only is requested send a listen-only ("L\r") command instead of an open ("O\r") command to the adapter. Signed-off-by: Dario Binacchi --- (no changes since v2) Changes in v2: - Remove comment on listen-only command. - Update the commit subject and description. drivers/net/can/slcan/slcan-core.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c index d12d98426f37..45e521910236 100644 --- a/drivers/net/can/slcan/slcan-core.c +++ b/drivers/net/can/slcan/slcan-core.c @@ -726,10 +726,20 @@ static int slcan_netdev_open(struct net_device *dev) } } - err = slcan_transmit_cmd(sl, "O\r"); - if (err) { - netdev_err(dev, "failed to send open command 'O\\r'\n"); - goto cmd_transmit_failed; + if (sl->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) { + err = slcan_transmit_cmd(sl, "L\r"); + if (err) { + netdev_err(dev, + "failed to send listen-only command 'L\\r'\n"); + goto cmd_transmit_failed; + } + } else { + err = slcan_transmit_cmd(sl, "O\r"); + if (err) { + netdev_err(dev, + "failed to send open command 'O\\r'\n"); + goto cmd_transmit_failed; + } } } @@ -816,6 +826,7 @@ static int slcan_open(struct tty_struct *tty) /* Configure CAN metadata */ sl->can.bitrate_const = slcan_bitrate_const; sl->can.bitrate_const_cnt = ARRAY_SIZE(slcan_bitrate_const); + sl->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY; /* Configure netdev interface */ sl->dev = dev;