All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Daniel Santos <daniel.santos@pobox.com>
Cc: linux-can <linux-can@vger.kernel.org>
Subject: Re: Framework for hardware filter support?
Date: Sun, 11 Feb 2018 13:32:28 +0100	[thread overview]
Message-ID: <eabc4877-8f50-7246-32da-1f5bbb2e507e@hartkopp.net> (raw)
In-Reply-To: <98bcd448-4d2a-bf2f-ae5a-4db7f1eac896@pobox.com>

Hello Daniel,

On 02/11/2018 03:38 AM, Daniel Santos wrote:
> Hello.  I'm doing a project where hardware filters will pretty much be
> required unless we change the hardware.  I can just hack up the mcp251x
> driver and add some sysfs nodes to modify the filters, but it would be
> much nicer to implement using some type of standard framework that I
> could submit back upstream.

Definitely a better approach :-)

> My current project uses an MCP2515 (with only two rx buffers) connected
> via an MCP2210 USB-to-SPI bridge and that introduces a lot of latency
> and interrupts may not be serviced for as much as 20-30 ms and w/o
> hardware filters, we'll be missing a lot of messages we want to sniff.
> 
> I've read some of the arguments against it, such is it being a
> multi-user environment.  To me that just means that hardware filters
> should be configured at the interface level and not at the socket level.

Correct for your use-case.

As you already pointed out in the user in a multi-user environment 
expects to be able to access the entire CAN traffic on that bus.

You want to reduce bandwidth and system load on the path from the 
controller into the system to cope with hardware limitations.

IMO this can be a valid requirement BUT we always have to keep in mind 
that the filters on that (CAN controller) level affect all users.

> So is there no such framework already in place?  If not, where would be
> the most logical place to add it? netfilter in the kernel and iproute2
> in userland?

A hardware filter support needs to be placed in hardware ;-)

The netfilter stuff comes into action when the network packets are 
already processed inside the network layer - so it's too late.

I would suggest to create an add-on to the existing netlink 
configuration interface for CAN controllers (the iproute2 stuff).

The question is, how to build a common configuration interface for CAN 
hardware filters that fits the design of the CAN controllers hardware 
filters?!?

Would it make sense to implement a similar interface like CAN_RAW filters

http://elixir.free-electrons.com/linux/v4.15.2/source/Documentation/networking/can.txt#L446

for the configuration of hardware filters?

E.g. the SJA1000 controller only has exactly ONE of these filters

http://elixir.free-electrons.com/linux/v4.15.2/source/drivers/net/can/sja1000/sja1000.c#L190

where the CAN_RAW filter design would easily fit.

E.g. the MCP2515 filters look a bit different on page 33:
http://ww1.microchip.com/downloads/en/DeviceDoc/21801e.pdf

but the CAN_RAW filter set idea seems to be applicable too.

Would this approach match your requirements?

Best regards,
Oliver

  reply	other threads:[~2018-02-11 12:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-11  2:38 Framework for hardware filter support? Daniel Santos
2018-02-11 12:32 ` Oliver Hartkopp [this message]
2018-02-11 22:33   ` Daniel Santos
2018-02-13 19:42     ` Kurt Van Dijck
2018-02-13 20:44       ` Oliver Hartkopp
2018-02-14 22:40       ` Daniel Santos
2018-02-15 23:03         ` Kurt Van Dijck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eabc4877-8f50-7246-32da-1f5bbb2e507e@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=daniel.santos@pobox.com \
    --cc=linux-can@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.