linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Kurt Van Dijck <kurt.van.dijck@eia.be>
Cc: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: j1939 - mainline problems
Date: Mon, 18 Mar 2013 22:31:25 +0100	[thread overview]
Message-ID: <514787AD.50303@hartkopp.net> (raw)

Hi Kurt,

i still try to get behind the implementation.

Simplicity is something else ...

Some things that definitely will not go into mainline:

  7 can-j1939 SYSCTL
    7.1 /proc/sys/net/can-j1939/transport_max_payload_in_bytes
    7.2 /proc/sys/net/can-j1939/transport_cts_nr_of_frames
    7.3 /proc/sys/net/can-j1939/transport_tx_retry_ms

sysfs for this kind of configuration is not getting into mainline.

Provide proper defaults and a sockopt interface, if people really want to
change their private defaults.

  6 can-j1939 procfs interface
    6.1 /proc/net/can-j1939/ecu
    6.2 /proc/net/can-j1939/filter
    6.3 /proc/net/can-j1939/sock
    6.4 /proc/net/can-j1939/transport

What does transport mean?
Does this entry appear when a PDU is sent and disappear afterwards?

-> seq_printf(sqf, "iface\tsrc\tdst\tpgn\tdone/total\n");

Supposed debugging output has to be removed anyway.

Things that look fishy:

#1 (Documentation)

  Per default j1939 is not active. Specifying can_ifindex != 0 in bind(2)
  or connect(2) needs an active j1939 on that interface. You must have done
  $ ip link set canX j1939 on
  on that interface.

Eh?

Never seen something like "ip link set eth0 tcp on" before setting the ip
address ??

Why doesn't it 'just work' ?

#2 (Documentation)

  Add the address to the system:
  $ ip addr add j1939 0x20 dev can0

  Bind:
    struct sockaddr_can addr;

    memset(&addr, 0, sizeof(addr));
    addr.can_ifindex = ifindex("can0"); // ifindex is a substitute.
    addr.can_addr.j1939.name = J1939_NO_NAME;
    addr.can_addr.j1939.addr = 0x20;
    addr.can_addr.j1939.pgn = J1939_NO_PGN;

    bind(sk, (void *)&addr, sizeof(addr));

Why does bind() not make the "ip addr add j1939 0x20 dev can0" automatically?

#3 (j1939/main.c)

in static void j1939_can_recv(struct sk_buff *skb, void *data)

        msg = (void *)skb->data;
        orig_len = skb->len;
        skb_pull(skb, CAN_HDR);
        /* fix length, set to dlc, with 8 maximum */
        skb_trim(skb, min_t(uint8_t, msg->can_dlc, 8));

You can not fiddle with skb offsets unless you've cloned it.

#4 (segments / ecus / bus / sk / ...)

Even when trying to follow any concepts in the source code, it's hard to
follow any idea when these structures and definitions are not described.

E.g. why don't you add a j1939_priv pointer to struct dev_rcv_lists when
CONFIG_CAN_J1939 is enabled?

Looks like j1939_segment_find() is a frequently used walkthrough function ...

#5 (j1939/main.c) filters

#define J1939_CAN_ID    CAN_EFF_FLAG
#define J1939_CAN_MASK  (CAN_EFF_FLAG | CAN_RTR_FLAG)

        ret = can_rx_register(netdev, J1939_CAN_ID, J1939_CAN_MASK,
                        j1939_can_recv, jseg, "j1939");

You read EVERY EFF frame. Filters should be created based on the concrete
requirement of the userspace (socket).

#6 (amount of code)

ls *.c | grep -v mod | xargs wc -l
   227 address-claim.c
   523 bus.c
    76 filter.c
   458 main.c
   104 proc.c
    43 promisc.c
   306 rtnl.c
   984 socket.c
  1449 transport.c
  4170 total

Sometimes i feel a much more simple approach is needed.

You provide a full featured 4 tons SUV IMO no one understands.
- thousands of knobs to configure
- and when looking under the hood you get lost from all the cables

I would like to have a bicycle and probably a quad with AC some days later.

E.g. with a struct j1939 message having an address field (similar to the
CAN-ID) with some data behind it.

That's simple and similar to other implementations.

I might be wrong with this requirement of simplicity.
But i might be right too.

Let's wait for beta-testers feedback if your concept is easy to use and adopt
for j1939 application programmers ...

Best regards,
Oliver

             reply	other threads:[~2013-03-18 21:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-18 21:31 Oliver Hartkopp [this message]
2013-03-20 10:18 ` j1939 - mainline problems Kurt Van Dijck
2013-03-21  6:05 ` Kurt Van Dijck
2013-03-21  6:47   ` Oliver Hartkopp

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=514787AD.50303@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=kurt.van.dijck@eia.be \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).