Commit Graph

61 Commits

Author SHA1 Message Date
Ed Maste
e3e6a34984 Use a separate copy of machdep.h in cp and ce drivers
Previously they included sys/dev/cx/machdep.h, but the cx driver was
retired in r359178.  These drivers haven't had real development for
a decade or more so there's no real benefit in sharing this file; just
copy it to the ce and cp subdirs.
2020-03-20 19:28:55 +00:00
Pedro F. Giffuni
4d24901ac9 sys/dev: Replace zero with NULL for pointers.
Makes things easier to read, plus architectures may set NULL to something
different than zero.

Found with:	devel/coccinelle
MFC after:	3 weeks
2017-02-20 03:43:12 +00:00
Pedro F. Giffuni
453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Svatopluk Kraus
a1e1814d76 As <machine/pmap.h> is included from <vm/pmap.h>, there is no need to
include it explicitly when <vm/pmap.h> is already included.

Reviewed by:	alc, kib
Differential Revision:	https://reviews.freebsd.org/D5373
2016-02-22 09:02:20 +00:00
Jung-uk Kim
fd90e2ed54 CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten
years for head.  However, it is continuously misused as the mpsafe argument
for callout_init(9).  Deprecate the flag and clean up callout_init() calls
to make them more consistent.

Differential Revision:	https://reviews.freebsd.org/D2613
Reviewed by:	jhb
MFC after:	2 weeks
2015-05-22 17:05:21 +00:00
Robert Watson
2a8c860fe3 In order to reduce use of M_EXT outside of the mbuf allocator and
socket-buffer implementations, introduce a return value for MCLGET()
(and m_cljget() that underlies it) to allow the caller to avoid testing
M_EXT itself.  Update all callers to use the return value.

With this change, very few network device drivers remain aware of
M_EXT; the primary exceptions lie in mbuf-chain pretty printers for
debugging, and in a few cases, custom mbuf and cluster allocation
implementations.

NB: This is a difficult-to-test change as it touches many drivers for
which I don't have physical devices.  Instead we've gone for intensive
review, but further post-commit review would definitely be appreciated
to spot errors where changes could not easily be made mechanically,
but were largely mechanical in nature.

Differential Revision:	https://reviews.freebsd.org/D1440
Reviewed by:	adrian, bz, gnn
Sponsored by:	EMC / Isilon Storage Division
2015-01-06 12:59:37 +00:00
Alexander V. Chernikov
c6682d5906 Convert most BPF_TAP users to BPF_MTAP.
MFC after:	2 weeks
2014-09-28 19:05:22 +00:00
Gleb Smirnoff
56b61ca27a Remove ifq_drops from struct ifqueue. Now queue drops are accounted in
struct ifnet if_oqdrops.

Some netgraph modules used ifqueue w/o ifnet. Accounting of queue drops
is simply removed from them. There were no API to read this statistic.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2014-09-19 09:01:19 +00:00
Gleb Smirnoff
c8dfaf382f Mechanically convert to if_inc_counter(). 2014-09-19 03:51:26 +00:00
Robert Watson
620dbb4ed1 Replace local copy-and-paste implementations of printmbuf() in several
device drivers with calls to the centralised m_print() implementation.
While the formatting and output details differ a little, the content
is essentially the same, and it is unlikely anyone has used this
debugging output in some time.

This change reduces awareness of mbuf cluster allocation (and,
especially, the M_EXT flag) outside of the mbuf allocator, which will
make it easier to refine the external storage mechanism without
disrupting drivers in the future.

Style bugs are preserved.

Reviewed by:	bz, glebius
MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2014-09-10 09:57:32 +00:00
Gleb Smirnoff
76039bc84f The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare
to this event, adding if_var.h to files that do need it. Also, include
all includes that now are included due to implicit pollution via if_var.h

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2013-10-26 17:58:36 +00:00
Eitan Adler
7a2b450ff8 Fxi a bunch of typos.
PR:	misc/174625
Submitted by:	Jeremy Chadwick <jdc@koitsu.org>
2013-05-10 16:41:26 +00:00
Sofian Brabez
61bfd86762 Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on device_method_t arrays
Reviewed by:	cognet
Approved by:	cognet
2013-01-30 18:01:20 +00:00
Gleb Smirnoff
c6499eccad Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags in sys/dev.
2012-12-04 09:32:43 +00:00
Dimitry Andric
8520ce6001 Fix clang warnings in sys/dev/ce/if_ce.c and sys/dev/cp/if_cp.c,
using jkim's last patch (reviewed by bde) from here:

http://docs.freebsd.org/cgi/mid.cgi?201010141558.03154.jkim

MFC after:	1 week
2011-12-29 17:46:24 +00:00
Rui Paulo
3065282fdb Revert r213793. 2010-10-13 17:38:23 +00:00
Rui Paulo
eab0cdc504 Don't do a logical AND of the result of strcmp() with a constant.
Found with:	clang
2010-10-13 17:17:50 +00:00
Maxim Sobolev
e50d35e6c6 Add new tunable 'net.link.ifqmaxlen' to set default send interface
queue length. The default value for this parameter is 50, which is
quite low for many of today's uses and the only way to modify this
parameter right now is to edit if_var.h file. Also add read-only
sysctl with the same name, so that it's possible to retrieve the
current value.

MFC after:	1 month
2010-05-03 07:32:50 +00:00
John Baldwin
3d32c12abf Always use a private timer instead of if_watchdog and if_timer to drive
the transmit watchdog.  These drivers already used a private timer when
compiled to use Netgraph.  This change just makes them always use the
private timer.  Note that these drivers do not compile and are disconnected
from the build due to TTY changes.
2009-11-17 16:43:02 +00:00
Warner Losh
2b9a8a330f Use new spelling of the NG_*LEN constants. 2009-06-09 07:14:32 +00:00
Robert Watson
c197427cee Remove debug.cp.mpsafenet: we no longer support running the network
stack with conditional Giant acquisition, and IFF_NEEDSGIANT will
be removed in the near future.
2009-02-15 23:18:29 +00:00
Ed Schouten
6bfa9a2d66 Replace all calls to minor() with dev2unit().
After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by:	kib
2008-09-27 08:51:18 +00:00
Roman Kurakin
259edd2800 Do not set IFF_DEBUG directly from the driver.
MFC after:	1 month.
2008-06-30 21:18:27 +00:00
Robert Watson
33d2bb9ca3 First in a series of changes to remove the now-unused Giant compatibility
framework for non-MPSAFE network protocols:

- Remove debug_mpsafenet variable, sysctl, and tunable.
- Remove NET_NEEDS_GIANT() and associate SYSINITSs used by it to force
  debug.mpsafenet=0 if non-MPSAFE protocols are compiled into the kernel.
- Remove logic to automatically flag interrupt handlers as non-MPSAFE if
  debug.mpsafenet is set for an INTR_TYPE_NET handler.
- Remove logic to automatically flag netisr handlers as non-MPSAFE if
  debug.mpsafenet is set.
- Remove references in a few subsystems, including NFS and Cronyx drivers,
  which keyed off debug_mpsafenet to determine various aspects of their own
  locking behavior.
- Convert NET_LOCK_GIANT(), NET_UNLOCK_GIANT(), and NET_ASSERT_GIANT into
  no-op's, as their entire behavior was determined by the value in
  debug_mpsafenet.
- Alias NET_CALLOUT_MPSAFE to CALLOUT_MPSAFE.

Many remaining references to NET_.*_GIANT() and NET_CALLOUT_MPSAFE are still
present in subsystems, and will be removed in followup commits.

Reviewed by:	bz, jhb
Approved by:	re (kensmith)
2007-07-27 11:59:57 +00:00
Yoshihiro Takahashi
41f5bd0f6d Don't call bus_deactivate_resource() explicitly before calling
bus_release_resource().  This is needed for pc98 by upcoming nexus related
change.
2007-03-21 03:38:37 +00:00
Paolo Pisati
ef544f6312 o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@
2007-02-23 12:19:07 +00:00
John Baldwin
0dea849ae9 Various bpf(4) related fixes to catch places up to the new bpf(4)
semantics.
- Stop testing bpf pointers for NULL.  In some cases use
  bpf_peers_present() and then call the function directly inside the
  conditional block instead of the macro.
- For places where the entire conditional block is the macro, remove the
  test and make the macro unconditional.
- Use BPF_MTAP() in if_pfsync on FreeBSD instead of an expanded version of
  the old semantics.

Reviewed by:	csjp (older version)
2006-12-29 13:59:50 +00:00
Robert Watson
acd3428b7d Sweep kernel replacing suser(9) calls with priv(9) calls, assigning
specific privilege names to a broad range of privileges.  These may
require some future tweaking.

Sponsored by:           nCircle Network Security, Inc.
Obtained from:          TrustedBSD Project
Discussed on:           arch@
Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri,
                        Alex Lyashkov <umka at sevcity dot net>,
                        Skip Ford <skip dot ford at verizon dot net>,
                        Antoine Brodin <antoine dot brodin at laposte dot net>
2006-11-06 13:42:10 +00:00
David E. O'Brien
6acb2659e2 trim trailing ^I 2005-12-17 07:09:17 +00:00
Roman Kurakin
732c9a1701 Restore if_cp.c 1.27
----------------------------
	revision 1.27
	date: 2005/09/19 03:10:16;  author: imp;  state: Exp;  lines: +3 -2
	Make sure that we call if_free(ifp) after bus_teardown_intr.  Since we
	could get an interrupt after we free the ifp, and the interrupt
	handler depended on the ifp being still alive, this could, in theory,
	cause a crash.  Eliminate this possibility by moving the if_free to
	after the bus_teardown_intr() call.

In fact, this change do nothing for this driver. It is protected from
this by cp_destroy variable. This variable also protects driver from initiation
of any activity from network stack with disabled intr handler with this change
applied.
2005-09-27 16:57:44 +00:00
Roman Kurakin
3dde86fe4c Backout if_cp 1.26, if_ct 1.27, if_cx 1.47 by obrien:
----------------------------
	revision 1.26
	date: 2005/09/07 09:53:35;  author: obrien;  state: Exp;  lines: +1452 -1453
	Reorder code to not depend on an ISO-C illegal forward extern declaration.
	----------------------------

Reason: do not move large functions location without serious reason. The same
could be done by forward function declaration. Please do not enlarge diff
without a reason any more.

Backout if_cp 1.27
----------------------------
	revision 1.27
	date: 2005/09/19 03:10:16;  author: imp;  state: Exp;  lines: +3 -2
	Make sure that we call if_free(ifp) after bus_teardown_intr.  Since we
	could get an interrupt after we free the ifp, and the interrupt
	handler depended on the ifp being still alive, this could, in theory,
	cause a crash.  Eliminate this possibility by moving the if_free to
	after the bus_teardown_intr() call.

Reason: bad previous commit. Would be restored by next commit.
2005-09-27 16:12:49 +00:00
Warner Losh
ad4f426ef6 Make sure that we call if_free(ifp) after bus_teardown_intr. Since we
could get an interrupt after we free the ifp, and the interrupt
handler depended on the ifp being still alive, this could, in theory,
cause a crash.  Eliminate this possibility by moving the if_free to
after the bus_teardown_intr() call.
2005-09-19 03:10:21 +00:00
David E. O'Brien
8070a603b2 Reorder code to not depend on an ISO-C illegal forward extern declaration. 2005-09-07 09:53:35 +00:00
Robert Watson
13f4c340ae Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags.  Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags.  This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by:	pjd, bz
MFC after:	7 days
2005-08-09 10:20:02 +00:00
Roman Kurakin
0541e456c9 Use m_length (m, NULL) instead of m->m_pkthdr.len.
Problems reported by: strijar at urai dot ru
Approved by:	re (scottl)
2005-07-09 16:14:05 +00:00
Roman Kurakin
de66928b86 Protect from partially initialized channels.
Approved by:	re (scottl)
2005-07-09 14:03:02 +00:00
Roman Kurakin
23f924934d Space & alignment nits.
Approved by:	re (scottl)
2005-07-09 13:44:36 +00:00
Brooks Davis
fc74a9f93a Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have
been replaced with a struct ifnet pointer to be filled by a call to the
new function, if_alloc(). The layer 2 common structure is also allocated
via if_alloc() based on the interface type. It is hung off the new
struct ifnet member, if_l2com.

This change removes the size of these structures from the kernel ABI and
will allow us to better manage them as interfaces come and go.

Other changes of note:
 - Struct arpcom is no longer referenced in normal interface code.
   Instead the Ethernet address is accessed via the IFP2ENADDR() macro.
   To enforce this ac_enaddr has been renamed to _ac_enaddr.
 - The second argument to ether_ifattach is now always the mac address
   from driver private storage rather than sometimes being ac_enaddr.

Reviewed by:	sobomax, sam
2005-06-10 16:49:24 +00:00
Warner Losh
538565c4a5 Use BUS_PROBE_DEFAULT for pci probe return value 2005-03-05 18:30:12 +00:00
Poul-Henning Kamp
80602ed932 Use dynamic major number allocation. 2005-02-27 22:17:51 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Roman Kurakin
64715608d7 Bring back ability to use FR support with sppp from Cronyx. 2004-12-14 23:13:08 +00:00
Roman Kurakin
f41d84e53a Make code MPSAFE.
You could turn this off by debug.mpsafenet=0 for full network
stack or via debug.{cp|cx|ctau}.mpsafenet for cp(4), cx(4) and
ctau(4) accordingly.

MFC after:	10 days
2004-12-13 22:07:23 +00:00
Roman Kurakin
b32a140140 Add support for Tau-PCI-L model - one V.35/RS-232 or
RS-530(449)/X.21 interface.
2004-12-11 22:44:12 +00:00
Roman Kurakin
f7f4970012 Clean up from '#if __FreeBSD_version'. 2004-12-11 05:38:16 +00:00
Roman Kurakin
052bf4427f Don not call pp_down()/pp_up() form XX_tlf()/XX_tls() in non PPP mode
to privent running of PPP's state machine in non PPP mode.

MFC: after 3 days.
2004-12-03 16:57:15 +00:00
Poul-Henning Kamp
3ad06fbb46 Remove bogus cdevsw frobbing code which tries to prevent double
loading of modules.

MODULE_VERSION() should be used for this I belive.
2004-09-23 12:21:11 +00:00
Roman Kurakin
23ee8af5f5 Fix low level code for Tau-PCI/2E1 and Tau-PCI/4E1 that was broken by previous
commit.
Pointy hat: rik
2004-08-16 17:28:04 +00:00
Roman Kurakin
c8a7b935f6 Update low level code for Cronyx Tau-PCI:
1. Add support for Cronyx Tau-PCI/E3 rev.B.
2. Improve model identification and firmware load procedure.
2004-08-16 12:00:07 +00:00
Robert Watson
c84843f1e5 Since if_cp doesn't contain locking or run with INTR_MPSAFE, mark
the interface as IFF_NEEDSGIANT so if_start is run holding Giant.
2004-08-13 23:02:17 +00:00