The NetBSD Project

CVS log for src/sys/netcan/if_canloop.c

[BACK] Up to [cvs.NetBSD.org] / src / sys / netcan

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.10: download - view: text, markup, annotated - select for diffs
Sat Sep 3 02:48:00 2022 UTC (2 years, 3 months ago) by thorpej
Branches: MAIN
CVS tags: thorpej-ifq-base, thorpej-ifq, thorpej-altq-separation-base, thorpej-altq-separation, perseant-exfatfs-base-20240630, perseant-exfatfs-base, perseant-exfatfs, netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, bouyer-sunxi-drm-base, bouyer-sunxi-drm, HEAD
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +3 -3 lines
Garbage-collect the remaining vestiges of netisr.

Revision 1.5.4.2: download - view: text, markup, annotated - select for diffs
Wed Apr 8 14:08:58 2020 UTC (4 years, 7 months ago) by martin
Branches: phil-wifi
Diff to: previous 1.5.4.1: preferred, colored; branchpoint 1.5: preferred, colored; next MAIN 1.6: preferred, colored
Changes since revision 1.5.4.1: +3 -4 lines
Merge changes from current as of 20200406

Revision 1.8.4.1: download - view: text, markup, annotated - select for diffs
Sat Feb 29 20:21:07 2020 UTC (4 years, 9 months ago) by ad
Branches: ad-namecache
Diff to: previous 1.8: preferred, colored; next MAIN 1.9: preferred, colored
Changes since revision 1.8: +3 -4 lines
Sync with head.

Revision 1.9: download - view: text, markup, annotated - select for diffs
Wed Jan 29 05:20:26 2020 UTC (4 years, 10 months ago) by thorpej
Branches: MAIN
CVS tags: thorpej-i2c-spi-conf2-base, thorpej-i2c-spi-conf2, thorpej-i2c-spi-conf-base, thorpej-i2c-spi-conf, thorpej-futex2-base, thorpej-futex2, thorpej-futex-base, thorpej-futex, thorpej-cfargs2-base, thorpej-cfargs2, thorpej-cfargs-base, thorpej-cfargs, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh, ad-namecache-base3
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +3 -4 lines
Adopt <net/if_stats.h>.

Revision 1.5.4.1: download - view: text, markup, annotated - select for diffs
Mon Jun 10 22:09:47 2019 UTC (5 years, 5 months ago) by christos
Branches: phil-wifi
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +3 -3 lines
Sync with HEAD

Revision 1.8: download - view: text, markup, annotated - select for diffs
Sat Apr 27 08:49:19 2019 UTC (5 years, 7 months ago) by pgoyette
Branches: MAIN
CVS tags: phil-wifi-20191119, phil-wifi-20190609, netbsd-9-base, netbsd-9-4-RELEASE, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, ad-namecache-base2, ad-namecache-base1, ad-namecache-base
Branch point for: ad-namecache
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +3 -3 lines
Semicolon not needed

Revision 1.7: download - view: text, markup, annotated - select for diffs
Sat Apr 27 08:48:31 2019 UTC (5 years, 7 months ago) by pgoyette
Branches: MAIN
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +3 -3 lines
Oooppss - deleted too many chars.  Put them back.

Should fix the build break.

Revision 1.6: download - view: text, markup, annotated - select for diffs
Sat Apr 27 06:18:15 2019 UTC (5 years, 7 months ago) by pgoyette
Branches: MAIN
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +3 -3 lines
A few more empty-string --> NULL in required-modules lists

Revision 1.2.2.1: download - view: text, markup, annotated - select for diffs
Tue Jan 2 10:20:34 2018 UTC (6 years, 11 months ago) by snj
Branches: netbsd-8
CVS tags: netbsd-8-3-RELEASE, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1
Diff to: previous 1.2: preferred, colored; next MAIN 1.3: preferred, colored
Changes since revision 1.2: +9 -4 lines
Pull up following revision(s) (requested by ozaki-r in ticket #456):
	sys/arch/arm/sunxi/sunxi_emac.c: 1.9
	sys/dev/ic/dwc_gmac.c: 1.43-1.44
	sys/dev/pci/if_iwm.c: 1.75
	sys/dev/pci/if_wm.c: 1.543
	sys/dev/pci/ixgbe/ixgbe.c: 1.112
	sys/dev/pci/ixgbe/ixv.c: 1.74
	sys/kern/sys_socket.c: 1.75
	sys/net/agr/if_agr.c: 1.43
	sys/net/bpf.c: 1.219
	sys/net/if.c: 1.397, 1.399, 1.401-1.403, 1.406-1.410, 1.412-1.416
	sys/net/if.h: 1.242-1.247, 1.250, 1.252-1.257
	sys/net/if_bridge.c: 1.140 via patch, 1.142-1.146
	sys/net/if_etherip.c: 1.40
	sys/net/if_ethersubr.c: 1.243, 1.246
	sys/net/if_faith.c: 1.57
	sys/net/if_gif.c: 1.132
	sys/net/if_l2tp.c: 1.15, 1.17
	sys/net/if_loop.c: 1.98-1.101
	sys/net/if_media.c: 1.35
	sys/net/if_pppoe.c: 1.131-1.132
	sys/net/if_spppsubr.c: 1.176-1.177
	sys/net/if_tun.c: 1.142
	sys/net/if_vlan.c: 1.107, 1.109, 1.114-1.121
	sys/net/npf/npf_ifaddr.c: 1.3
	sys/net/npf/npf_os.c: 1.8-1.9
	sys/net/rtsock.c: 1.230
	sys/netcan/if_canloop.c: 1.3-1.5
	sys/netinet/if_arp.c: 1.255
	sys/netinet/igmp.c: 1.65
	sys/netinet/in.c: 1.210-1.211
	sys/netinet/in_pcb.c: 1.180
	sys/netinet/ip_carp.c: 1.92, 1.94
	sys/netinet/ip_flow.c: 1.81
	sys/netinet/ip_input.c: 1.362
	sys/netinet/ip_mroute.c: 1.147
	sys/netinet/ip_output.c: 1.283, 1.285, 1.287
	sys/netinet6/frag6.c: 1.61
	sys/netinet6/in6.c: 1.251, 1.255
	sys/netinet6/in6_pcb.c: 1.162
	sys/netinet6/ip6_flow.c: 1.35
	sys/netinet6/ip6_input.c: 1.183
	sys/netinet6/ip6_output.c: 1.196
	sys/netinet6/mld6.c: 1.90
	sys/netinet6/nd6.c: 1.239-1.240
	sys/netinet6/nd6_nbr.c: 1.139
	sys/netinet6/nd6_rtr.c: 1.136
	sys/netipsec/ipsec_output.c: 1.65
	sys/rump/net/lib/libnetinet/netinet_component.c: 1.9-1.10
kmem_intr_free kmem_intr_[z]alloced memory
the underlying pools are the same but api-wise those should match
Unify IFEF_*_MPSAFE into IFEF_MPSAFE
There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.
Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).
Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.
Proposed on tech-kern@ and tech-net@
Provide macros for softnet_lock and KERNEL_LOCK hiding NET_MPSAFE switch
It reduces C&P codes such as "#ifndef NET_MPSAFE KERNEL_LOCK(1, NULL); ..."
scattered all over the source code and makes it easy to identify remaining
KERNEL_LOCK and/or softnet_lock that are held even if NET_MPSAFE.
No functional change
Hold KERNEL_LOCK on if_ioctl selectively based on IFEF_MPSAFE
If IFEF_MPSAFE is set, hold the lock and otherwise don't hold.
This change requires additions of KERNEL_LOCK to subsequence functions from
if_ioctl such as ifmedia_ioctl and ifioctl_common to protect non-MP-safe
components.
Proposed on tech-kern@ and tech-net@
Ensure to hold if_ioctl_lock when calling if_flags_set
Fix locking against myself on ifpromisc
vlan_unconfig_locked could be called with holding if_ioctl_lock.
Ensure to not turn on IFF_RUNNING of an interface until its initialization completes
And ensure to turn off it before destruction as per IFF_RUNNING's description
"resource allocated". (The description is a bit doubtful though, I believe the
change is still proper.)
Ensure to hold if_ioctl_lock on if_up and if_down
One exception for if_down is if_detach; in the case the lock isn't needed
because it's guaranteed that no other one can access ifp at that point.
Make if_link_queue MP-safe if IFEF_MPSAFE
if_link_queue is a queue to store events of link state changes, which is
used to pass events from (typically) an interrupt handler to
if_link_state_change softint. The queue was protected by KERNEL_LOCK so far,
but if IFEF_MPSAFE is enabled, it becomes unsafe because (perhaps) an interrupt
handler of an interface with IFEF_MPSAFE doesn't take KERNEL_LOCK. Protect it
by a spin mutex.
Additionally with this change KERNEL_LOCK of if_link_state_change softint is
omitted if NET_MPSAFE is enabled.
Note that the spin mutex is now ifp->if_snd.ifq_lock as well as the case of
if_timer (see the comment).
Use IFADDR_WRITER_FOREACH instead of IFADDR_READER_FOREACH
At that point no other one modifies the list so IFADDR_READER_FOREACH
is unnecessary. Use of IFADDR_READER_FOREACH is harmless in general though,
if we try to detect contract violations of pserialize, using it violates
the contract. So avoid using it makes life easy.
Ensure to call if_addr_init with holding if_ioctl_lock
Get rid of outdated comments
Fix build of kernels without ether
By throwing out if_enable_vlan_mtu and if_disable_vlan_mtu that
created a unnecessary dependency from if.c to if_ethersubr.c.
PR kern/52790
Rename IFNET_LOCK to IFNET_GLOBAL_LOCK
IFNET_LOCK will be used in another lock, if_ioctl_lock (might be renamed then).
Wrap if_ioctl_lock with IFNET_* macros (NFC)
Also if_ioctl_lock perhaps needs to be renamed to something because it's now
not just for ioctl...
Reorder some destruction routines in if_detach
- Destroy if_ioctl_lock at the end of the if_detach because it's used in various
  destruction routines
- Move psref_target_destroy after pr_purgeif because we want to use psref in
  pr_purgeif (otherwise destruction procedures can be tricky)
Ensure to call if_mcast_op with holding IFNET_LOCK
Note that CARP doesn't deal with IFNET_LOCK yet.
Remove IFNET_GLOBAL_LOCK where it's unnecessary because IFNET_LOCK is held
Describe which lock is used to protect each member variable of struct ifnet
Requested by skrll@
Write a guideline for converting an interface to IFEF_MPSAFE
Requested by skrll@
Note that IFNET_LOCK must not be held in softint
Don't set IFEF_MPSAFE unless NET_MPSAFE at this point
Because recent investigations show that interfaces with IFEF_MPSAFE need to
follow additional restrictions to work with the flag safely. We should enable it
on an interface by default only if the interface surely satisfies the
restrictions, which are described in if.h.
Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because
the network stack is still serialized by the big kernel locks by default.

Revision 1.5: download - view: text, markup, annotated - select for diffs
Tue Dec 19 03:32:35 2017 UTC (6 years, 11 months ago) by ozaki-r
Branches: MAIN
CVS tags: phil-wifi-base, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, isaki-audio2-base, isaki-audio2
Branch point for: phil-wifi
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +4 -2 lines
Don't set IFEF_MPSAFE unless NET_MPSAFE at this point

Because recent investigations show that interfaces with IFEF_MPSAFE need to
follow additional restrictions to work with the flag safely. We should enable it
on an interface by default only if the interface surely satisfies the
restrictions, which are described in if.h.

Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because
the network stack is still serialized by the big kernel locks by default.

Revision 1.4: download - view: text, markup, annotated - select for diffs
Wed Dec 6 07:40:16 2017 UTC (7 years ago) by ozaki-r
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +6 -3 lines
Ensure to not turn on IFF_RUNNING of an interface until its initialization completes

And ensure to turn off it before destruction as per IFF_RUNNING's description
"resource allocated". (The description is a bit doubtful though, I believe the
change is still proper.)

Revision 1.3.2.2: download - view: text, markup, annotated - select for diffs
Sun Dec 3 11:39:03 2017 UTC (7 years ago) by jdolecek
Branches: tls-maxphys
Diff to: previous 1.3.2.1: preferred, colored; branchpoint 1.3: preferred, colored; next MAIN 1.4: preferred, colored
Changes since revision 1.3.2.1: +220 -0 lines
update from HEAD

Revision 1.3.2.1
Thu Nov 16 03:07:18 2017 UTC (7 years ago) by jdolecek
Branches: tls-maxphys
FILE REMOVED
Changes since revision 1.3: +0 -220 lines
file if_canloop.c was added on branch tls-maxphys on 2017-12-03 11:39:03 +0000

Revision 1.3: download - view: text, markup, annotated - select for diffs
Thu Nov 16 03:07:18 2017 UTC (7 years ago) by ozaki-r
Branches: MAIN
CVS tags: tls-maxphys-base-20171202
Branch point for: tls-maxphys
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +3 -3 lines
Unify IFEF_*_MPSAFE into IFEF_MPSAFE

There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.

Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).

Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.

Proposed on tech-kern@ and tech-net@

Revision 1.2.6.2: download - view: text, markup, annotated - select for diffs
Mon Aug 28 17:53:12 2017 UTC (7 years, 3 months ago) by skrll
Branches: nick-nhusb
Diff to: previous 1.2.6.1: preferred, colored; branchpoint 1.2: preferred, colored; next MAIN 1.3: preferred, colored
Changes since revision 1.2.6.1: +220 -0 lines
Sync with HEAD

Revision 1.2.6.1
Sat May 27 21:02:56 2017 UTC (7 years, 6 months ago) by skrll
Branches: nick-nhusb
FILE REMOVED
Changes since revision 1.2: +0 -220 lines
file if_canloop.c was added on branch nick-nhusb on 2017-08-28 17:53:12 +0000

Revision 1.2: download - view: text, markup, annotated - select for diffs
Sat May 27 21:02:56 2017 UTC (7 years, 6 months ago) by bouyer
Branches: MAIN
CVS tags: perseant-stdc-iso10646-base, perseant-stdc-iso10646, nick-nhusb-base-20170825, netbsd-8-base, matt-nb8-mediatek-base, matt-nb8-mediatek
Branch point for: nick-nhusb, netbsd-8
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +220 -0 lines
merge the bouyer-socketcan branch to HEAD.

CAN stands for Controller Area Network, a broadcast network used
in automation and automotive fields. For example, the NMEA2000 standard
developped for marine devices uses a CAN network as the link layer.

This is an implementation of the linux socketcan API:
https://www.kernel.org/doc/Documentation/networking/can.txt
you can also see can(4).

This adds a new socket family (AF_CAN) and protocol (PF_CAN),
as well as the canconfig(8) utility, used to set timing parameter of
CAN hardware. Also inclued is a driver for the CAN controller
found in the allwinner A20 SoC (I tested it with an Olimex lime2 board,
connected with PIC18-based CAN devices).

There is also the canloop(4) pseudo-device, which allows to use
the socketcan API without CAN hardware.

At this time the CANFD part of the linux socketcan API is not implemented.
Error frames are not implemented either. But I could get the cansend and
canreceive utilities from the canutils package to build and run with minimal
changes. tcpudmp(8) can also be used to record frames, which can be
decoded with etherreal.

Revision 1.1.2.8: download - view: text, markup, annotated - select for diffs
Thu May 25 18:21:00 2017 UTC (7 years, 6 months ago) by bouyer
Branches: bouyer-socketcan
Diff to: previous 1.1.2.7: preferred, colored; branchpoint 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1.2.7: +3 -3 lines
Allow can_bpf_mtap() to call bpf_mtap_softint() when needed.

Revision 1.1.2.7: download - view: text, markup, annotated - select for diffs
Mon May 22 16:11:23 2017 UTC (7 years, 6 months ago) by bouyer
Branches: bouyer-socketcan
Diff to: previous 1.1.2.6: preferred, colored; branchpoint 1.1: preferred, colored
Changes since revision 1.1.2.6: +4 -8 lines
factor out if_attach() and bpf_attach() calls in can_ifattach().
Introduce can_ifdetach().
Introduce can_bpf_mtap(), which converts the can_id to network byte
order (as required by tcpdump/wireshark). Thanks to Guy Harris for
poiting this requirement.

Revision 1.1.2.6: download - view: text, markup, annotated - select for diffs
Mon Apr 24 13:38:33 2017 UTC (7 years, 7 months ago) by bouyer
Branches: bouyer-socketcan
Diff to: previous 1.1.2.5: preferred, colored; branchpoint 1.1: preferred, colored
Changes since revision 1.1.2.5: +3 -3 lines
Use bpf_mtap() not bpf_mtap_af(). Now files produced by tcpdump can be
decoded by wireshark.

Revision 1.1.2.5: download - view: text, markup, annotated - select for diffs
Wed Apr 19 22:17:56 2017 UTC (7 years, 7 months ago) by bouyer
Branches: bouyer-socketcan
Diff to: previous 1.1.2.4: preferred, colored; branchpoint 1.1: preferred, colored
Changes since revision 1.1.2.4: +3 -4 lines
Set rcvif before bpf_mtap

Revision 1.1.2.4: download - view: text, markup, annotated - select for diffs
Sun Feb 5 17:37:10 2017 UTC (7 years, 9 months ago) by bouyer
Branches: bouyer-socketcan
Diff to: previous 1.1.2.3: preferred, colored; branchpoint 1.1: preferred, colored
Changes since revision 1.1.2.3: +30 -36 lines
Introduce can_ifattach(), for common setups of can interfaces.
Convert output to a ifq and change canloop_output to canloop_ifstart

Revision 1.1.2.3: download - view: text, markup, annotated - select for diffs
Sun Feb 5 11:45:11 2017 UTC (7 years, 9 months ago) by bouyer
Branches: bouyer-socketcan
Diff to: previous 1.1.2.2: preferred, colored; branchpoint 1.1: preferred, colored
Changes since revision 1.1.2.2: +4 -9 lines
Centralize mbuf tag cleanup, it will be used by real interface drivers too.

Revision 1.1.2.2: download - view: text, markup, annotated - select for diffs
Mon Jan 16 18:03:38 2017 UTC (7 years, 10 months ago) by bouyer
Branches: bouyer-socketcan
Diff to: previous 1.1.2.1: preferred, colored; branchpoint 1.1: preferred, colored
Changes since revision 1.1.2.1: +7 -3 lines
Use PACKET_TAG_SO to store the sender's struct socket pointer, and use
it to implement socket options CAN_RAW_LOOPBACK and CAN_RAW_RECV_OWN_MSGS.

Revision 1.1.2.1: download - view: text, markup, annotated - select for diffs
Sun Jan 15 20:27:33 2017 UTC (7 years, 10 months ago) by bouyer
Branches: bouyer-socketcan
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +232 -0 lines
Initial commit of a CAN socket layer, compatible with linux SoccketCAN
(but incomplete). Based on work from Robert Swindells.

Revision 1.1
Sun Jan 15 20:27:33 2017 UTC (7 years, 10 months ago) by bouyer
Branches: MAIN
CVS tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, pgoyette-localcount-20170426, pgoyette-localcount-20170320, bouyer-socketcan-base1
Branch point for: bouyer-socketcan
FILE REMOVED
file if_canloop.c was initially added on branch bouyer-socketcan.

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>