hartkopp [Mon, 15 Nov 2010 15:08:36 +0000 (15:08 +0000)]
isotp: the timestamp for rx stmin enforcement was reset in the function that
receives the flow control. Of course it has to be in the funtion that sends
the FC to the sender of the data. :-(
This patch fixes the rx/tx issue.
hartkopp [Sun, 14 Nov 2010 08:55:06 +0000 (08:55 +0000)]
Added new socketoptions to force the isotp protocol to intentionally
misbehave for regression tests.
CAN_ISOTP_TX_STMIN:
Set a value in nano secs that's used as minimum CF gap by the sender.
This value is used instead of the value provided by the receiver inside the FC.
CAN_ISOTP_RX_STMIN:
Ignores received CF frames which timestamps differ less than this value in nano
secs. This is used to test the receivers misbehaviour when the receiver
provides a lower stmin value that he's able to cope with. Received CF frames
are silently dropped when they come faster than specified by this value.
Reported-by: Dan Rosenberg <drosenberg@vsecurity.com> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> CC: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream Commit:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=0597d1b99fcfc2c0eada09a698f85ed413d4ba84
hartkopp [Fri, 22 Oct 2010 05:24:03 +0000 (05:24 +0000)]
can-raw: add msg_flags to distinguish local traffic
CAN has no addressing scheme. It is currently impossible for userspace
to tell is a received CAN frame comes from another process on the local
host, or from a remote CAN device.
This patch add support for userspace applications to distinguish between
'own', 'local' and 'remote' CAN traffic. The distinction is made by returning
flags in msg->msg_flags in the call to recvmsg().
The added documentation explains the introduced flags.
Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit:
http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=1e55659ce6ddb5247cee0b1f720d77a799902b85
Added information how to obtain timestamps as suggested by
Daniele Venzano <venza@brownhat.org>. Extended the possibility
to get timestamps via recvmsg().
On 64bit systems a 'long' is a 64bit value but the target values of scanf()
are always 32bit in the affected code - which means just an 'unsigned int'.
Unsigned int is fine on 32 and 64 bit systems.
Fixed calculation of needed bits on the physical wire according Ken Tindells
*worst* case calculation for stuff-bits.
(see "Guaranteeing Message Latencies on Controller Area Network" 1st ICC'94)
Due to the bitstuffing estimation the calculated busload may exceed 100%.
hartkopp [Fri, 13 Aug 2010 16:15:16 +0000 (16:15 +0000)]
can: add limit for nframes and clean up signed/unsigned variables
This patch adds a limit for nframes as the number of frames in TX_SETUP and
RX_SETUP are derived from a single byte multiplex value by default.
Use-cases that would require to send/filter more than 256 CAN frames should
be implemented in userspace for complexity reasons anyway.
Additionally the assignments of unsigned values from userspace to signed
values in kernelspace and vice versa are fixed by using unsigned values in
kernelspace consistently.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Reported-by: Ben Hawkes <hawkes@google.com> Acked-by: Urs Thuermann <urs.thuermann@volkswagen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit:
http://git.kernel.org/?p=linux/kernel/git/davem/net-2.6.git;a=commitdiff;h=5b75c4973ce779520b9d1e392483207d6f842cde
can-calc-bit-timing: calculate bit timings for all known controllers by default
When testing or improving the bit timing algorithm, you're probably
interested in the values of all can controllers. Further you might not
know the all reference clocks of the controllers.
This patch add a "ref_clock" member to the "struct can_bittiming_const"
that holds the reference clock of the controller in Hz.
By default now the bit timing is calculated for all known can
controllers with the default ref_clock defined in "can_bittiming_const".
It's still possible to overwrite the ref clock with the command line
option "-c".
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1188 030b6a49-0b11-0410-94ab-b0dab22257f2
can-calc-bit-timing: improve printing of bit timing parameters
This patch adds additional fields when printing the bit timing
parameters. Now the real bitrate the nominal and the real sample point
as well as the error of the sample point is displayed.
can-calc-bit-timing: use algorithm from the kernel
This patch copies the algorithm functions (can_update_spt and
can_calc_bittiming) from the kernel. Then some glue code is added that
these functions compile in userspace.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1186 030b6a49-0b11-0410-94ab-b0dab22257f2
The cleanup of slc_alloc() integrated in SVN Rev1095 based on upstream commit
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=5342b77c4123ba39f911d92a813295fb3bb21f69
was not really Kernel-version depended ...
So far this code section is needed for the changes added in SVN Rev1170 so we
would need to revisit this code when mainlining the driver.
Added possibility to force the slcan driver to use a specific device number
when set via SWTC char (e.g. with stty). See thread
https://lists.berlios.de/pipermail/socketcan-users/2010-April/001378.html
Provided by Stephen Hellriegel <Stephen.Hellriegel@verari.com>
So far this change only applies for Kernels < 2.6.32 ...
There is no reason why the 'real' SLCAN interfaces should have a different
naming scheme than other 'real' CAN interfaces.
So create canX instead of slcX network device names with the slcan driver.
As Stephen Hellriegel pointed out in
https://lists.berlios.de/pipermail/socketcan-users/2010-April/001378.html
it does not make sense to monitor the tx data flow in the slcan driver as
we do not know anything about the CAN specific problems that may occur in the
slcan device.
Therefore we just wait until the ASCII data is sent on the serial line without
having a separate timeout handler in the slcan driver.
- rework internal structures to prepare routings and modifications of CAN traffic also to non-CAN interfaces
- fix reading of netlink messages in cangw.c (added RTCAN_RTA / RTCAN_PAYLOAD macros)
- rework reading of gw-job lists in cgw_dump_jobs()
- rename of functions and API definitions to have a common namespace cgw_
- added infrastructure to perform crc8 and xor checksums in CAN frame data[]
TODO:
- add and test functionality for crc8 and xor checksums in CAN frame data[]
- add help text for crc8 and xor checksums in CAN frame data[]
hartkopp [Wed, 17 Mar 2010 19:21:38 +0000 (19:21 +0000)]
Some binaries in can-utils depend on features in the socket-can svn
repository. Building with exported headers from an unpatched kernel will
fail due to missing symbols or headers.
This patch adds two make variables to optionally disable building such
binaries, like this:
make PROGRAMS_ISOTP= PROGRAMS_CANGW= PROGRAMS_SLCAN= all
Signed-off-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1163 030b6a49-0b11-0410-94ab-b0dab22257f2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1156 030b6a49-0b11-0410-94ab-b0dab22257f2
wolf [Fri, 5 Mar 2010 09:11:52 +0000 (09:11 +0000)]
can: netlink support for bus-error reporting and counters
This patch makes the bus-error reporting configurable and allows to
retrieve the CAN TX and RX bus error counters via netlink interface.
I have added support for the SJA1000. The TX and RX bus error counters
are also copied to the data fields 6..7 of error messages when state
changes are reported.
hartkopp [Thu, 25 Feb 2010 17:10:40 +0000 (17:10 +0000)]
softing_cs: fix for net-next-2.6 (2.6.33+)
The pcmcia_request_window() is postponed a little, as some flags must be
set before this call (I believe). It is a small change, but with some
noise in the patch. Same with softing_card_irq().
The netif_start_queue() is omitted, as softing_cycle() does a
netif_wake_queue().
Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be> Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1146 030b6a49-0b11-0410-94ab-b0dab22257f2
hartkopp [Thu, 25 Feb 2010 08:04:22 +0000 (08:04 +0000)]
can: mscan-mpc5xxx: fix broken support for the MPC5200
Due to an invalid "#ifdef CONFIG_PPC_MPC5200", the real clock setup
function was not called for the MPC5200.
Signed-off-by: Wolfgang Grandegger <wg@denx.de> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit
http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=c5bab5e94d148aee2c852450374143c89aa56511
hartkopp [Sat, 20 Feb 2010 18:04:56 +0000 (18:04 +0000)]
Copy the struct members separately to ensure that no uninitialized
data are copied in the 3 bytes hole of the struct. This is needed
to make easy compares of the data in the struct can_can_gw.
hartkopp [Fri, 19 Feb 2010 13:33:59 +0000 (13:33 +0000)]
Added cangw netlink gateway configuration tool.
TODO (in both cangw and can-gw.ko) : Support removal and listing of rules.
So far the gateway jobs are only removed on can-gw.ko module unload or when
the used CAN netdevices disappear.
wolf [Fri, 19 Feb 2010 09:02:36 +0000 (09:02 +0000)]
ems_pcmcia: Fix compiler errors with recent net-next-2.6
Fix compiler errors with recent net-next-2.6 for 2.6.33
- Removed IRQInfo1 (as for irq_req_t)
- window_handle_t is now unsigned long instead of window_t*
- pcmcia_request_window needs now only a pointer, not pointer to pointer
- pass struct pcmcia_device pointer to pcmcia_map_mem_page
- Replaced cs_error function with dbg_err
Signed-off-by: Markus Plessing <plessing@ems-wuensche.com>
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1135 030b6a49-0b11-0410-94ab-b0dab22257f2
hartkopp [Fri, 19 Feb 2010 07:06:17 +0000 (07:06 +0000)]
Added flag to preserve the timestamp from the source device when routing
the CAN frame (which saves some time, if the timestamp is not needed).
Usually the skb->tstamp is cleared which makes the destination interface
create a new timestamp (e.g. when the frame hit's the bus) on loopback.
hartkopp [Fri, 19 Feb 2010 05:12:49 +0000 (05:12 +0000)]
Swapped the parameters inside the modifier attribute to have the aligned
struct can_frame the first parameter. This allows the usage of 'packed'
structs in userspace with an aligned access to the CAN frame structures.
hartkopp [Thu, 18 Feb 2010 18:37:20 +0000 (18:37 +0000)]
Added netlink powered CAN gateway functionality with CAN frame modification features.
TODO: Implement removal of single routing entries / Dump complete entries with packet counters.
wolf [Thu, 11 Feb 2010 12:33:56 +0000 (12:33 +0000)]
plx_pci: sync with net-next-2.6
This patch makes the plx_pci driver in the BerliOS repo same as in
net-next-2.6
Changes since previous revision (1120):
- Added some defines for static inline int plx_pci_check_sja1000(...)
- static struct pci_device_id plx_pci_tbl[] replaced by
static DEFINE_PCI_DEVICE_TABLE(plx_pci_tbl)
- Typo fixed
- Changed order of device info to have the PCI devices in alphabetical
order
hartkopp [Wed, 3 Feb 2010 17:55:16 +0000 (17:55 +0000)]
The hlist content ensured only CAN netdevices to be accessed by the
can_rx_(un)register() functions which accidently dropped away together with
the receive list access speedup in rev 1118 and rev 1119.
This patch re-introduces the check for CAN netdevices in can_rx_(un)register()
(not in the hot path!) for Kernels >= 2.6.26.
wolf [Sat, 30 Jan 2010 19:07:06 +0000 (19:07 +0000)]
mcp251x: misc bugfixes
Several bugs are fixed: utilization of just half of the RX buffers,
useless wait for interrupt on open, more reliable reset sequence.
The MERR interrupt is not used anymore: it overloads the CPU in
bus-off state without any additional information. One shot mode for
the MCP2515 is added.
Signed-off-by: Christian Pellegrin <chripell@fsfe.org>
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1121 030b6a49-0b11-0410-94ab-b0dab22257f2
wolf [Mon, 25 Jan 2010 10:35:12 +0000 (10:35 +0000)]
sja1000: Driver for some PLX PCI bridge + sja1000 CAN controllers
It's a next version of sja1000_plx_pci driver.
In struct plx_pci_card_info pointer to device-dependent reset function was
added. It's necessary for special reset operations which take place in
some cards (like Marathon CAN-bus-PCI).
Also, I've introduced a special reset function for Marathon card. This
function incapsulates ability to reset the SJA1000 on such cards.
plx_pci_check_sja1000 was slightly modified for a purpose of exhaustive
checking.
Signed-off-by: Pavel Cheblakov <P.B.Cheblakov@inp.nsk.su>
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1120 030b6a49-0b11-0410-94ab-b0dab22257f2
hartkopp [Sun, 24 Jan 2010 21:35:06 +0000 (21:35 +0000)]
Consistently clean up the reference dev->ml_priv when the device receiver list is (to be) removed.
Cleanly separate find_dev_rcv_lists() function for 2.6.26+ as we do not need the fallback.
hartkopp [Sat, 23 Jan 2010 21:25:23 +0000 (21:25 +0000)]
Since 2.6.26 a new "midlevel private" ml_priv pointer has been
introduced in struct net_device. We use this pointer to omit the
linear walk through the can_rx_dev_list. A similar speedup has been
queued for 2.6.34 mainline but using the new netdev_rcu lists.
hartkopp [Sat, 23 Jan 2010 11:20:23 +0000 (11:20 +0000)]
Fix rcu handling by removing nested rcu locks.
This problem was also solved in upstream commit
http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=20dd3850bcf860561496827b711fa10fecf6e787
hartkopp [Fri, 15 Jan 2010 18:35:37 +0000 (18:35 +0000)]
Added '-d' option to support the receive packet drop counting introduced in
http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=3b885787ea4112eaa80945999ea0901bf742707f
This is done by using recvmsg() instead of recvfrom() to allow the timestamp
and the dropcounter to be received within one syscall.
When the application (here 'candump') ist not fast enough to process the
incomming CAN frames the frames are dropped in the socket receive queue.
When this happens and '-d' is set, we get this info now:
DROPCOUNT: dropped 1 CAN frame on 'xxx' socket (total drops 1)
wolf [Thu, 14 Jan 2010 19:40:31 +0000 (19:40 +0000)]
Support for the esd USB2 CAN interface
This patch adds support for the esd USB2 CAN interface.
Changelog
V4:
- remove unnecessary 'else' path after goto statement
in esd_usb2_start_xmit()
- remove driver startup message
- move module_init/module_exit macros
- increase MAX_TX_URBS to next power of two value (16)
- remove done_index variable in esd_usb2_tx_done_msg()
- mask tx_contexts[] index in esd_usb2_tx_done_msg()
for robustness
- esd_usb2_start/close(): 1+1=2
- use u8/u16/u32/__le32 types
- remove unused device message structs
- use kfree_skb() instead of dev_kfree_skb()
- fix cleanup path in esd_usb2_start_xmit()
- explain IDADD filter message more detailed
V3:
- handle msg->msg.txdone.status != 0 in esd_usb2_tx_done_msg()
- move active_tx_urbs-- to esd_usb2_tx_done_msg() from
...write_bulk_callback
- move netif_wake_queue(netdev) to esd_usb2_tx_done_msg()
- add BTR macros
V2:
- remove duplicate line "netdev->flags |= IFF_ECHO; ..."
in esd_usb2_probe_one_net()
- set can.state back to CAN_STATE_STOPPED in esd_usb2_close()
Without this setting the bitrate via sysfs after an interface
up/down cycle does not work.
- remove "#undef DEBUG" line
- codingstyle clean (tabs, empty lines, ...)
- don't check against 0, but use !()
- remove netif_queue_stopped() check before calling netif_wake_queue()
- remove double netif_device_detach() from esd_usb2_open()
- print canbtr in esd_usb2_set_bittiming()
- use __types in structures that a exchanged with the device
- add ESD_MAX_ID_SEGMENT macro to get rid of the magic hardcoded "64"
when setting up the device's ID filter.
- Add some comments about the IDADD message.
- move esd_usb2_bittiming_const close to esd_usb2_set_bittiming()
- move macro definitions to top of file
- use if() for single case switch statements
- add macros for esd bus state event codes
- order declarations somehow: move structs to top
- get rid of ibuf variable in esd_usb2_read_bulk_callback()
- rename no_nets to net_count :-)
- consequently do not use unlikely()
- call can_get_echo_skb() from esd_usb2_tx_done_msg() to loopback
only when message has been sent successfully
- increase MAX_TX_URBS because releasing tx_contexts is now done
much later and we easily run out of free tx_contexts
- check dev->nets[i] before netif_device_detach() in ...read_bulk_callback()
- make esd_usb2_setup_rx_urbs() succeed when we got at least one urb
setup correctly
- implement common error handling in esd_usb2_start_xmit()
- handle failure of alloc_can_(err_)sbk: stats->rx_dropped++
- rename netdev's private data pointer from "net" to "priv"
- add "device %s registered" message on successful net creation