aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/an/if_an.c
Commit message (Collapse)AuthorAgeFilesLines
* sys/dev: Replace zero with NULL for pointers.Pedro F. Giffuni2017-02-201-1/+1
| | | | | | | | | | | Makes things easier to read, plus architectures may set NULL to something different than zero. Found with: devel/coccinelle MFC after: 3 weeks Notes: svn path=/head/; revision=313982
* Reject ioctl commands for FLSHGCHR and FLSHPCHR if the size is greaterSean Bruno2016-05-241-0/+6
| | | | | | | | | | | | than sc->areq. This is a bounds check to ensure we're not just cramming arbitrarily sized nonsense into the driver and overflowing the heap. PR: 209545 Submitted by: cturt@hardenedbsd.org MFC after: 2 weeks Notes: svn path=/head/; revision=300612
* Move mutex initialization from PCI probe to PCI attach. Drivers are notScott Long2016-05-121-17/+0
| | | | | | | | | | | allowed to create any persistent state in their probe routine because it's not guaranteed that they'll win the election and be allowed to attach. Submitted by: Matthew Macy MFC after: 3 days Notes: svn path=/head/; revision=299544
* sys/dev: minor spelling fixes.Pedro F. Giffuni2016-05-031-1/+1
| | | | | | | Most affect comments, very few have user-visible effects. Notes: svn path=/head/; revision=298955
* Migrate many bus_alloc_resource() calls to bus_alloc_resource_anywhere().Justin Hibbits2016-02-271-6/+6
| | | | | | | | | | | Most calls to bus_alloc_resource() use "anywhere" as the range, with a given count. Migrate these to use the new bus_alloc_resource_anywhere() API. Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D5370 Notes: svn path=/head/; revision=296137
* In order to reduce use of M_EXT outside of the mbuf allocator andRobert Watson2015-01-061-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=276750
* Mechanically convert to if_inc_counter().Gleb Smirnoff2014-09-191-20/+20
| | | | Notes: svn path=/head/; revision=271849
* last is set and not used, most likely a cut and paste error from otherWarner Losh2014-08-081-3/+1
| | | | | | | sysctl setting functions in this module. Notes: svn path=/head/; revision=269712
* Don't destroy bus_dma maps created by bus_dmamem_alloc(). In some cases,John Baldwin2014-06-101-8/+0
| | | | | | | | | | | | don't create a map before calling bus_dmamem_alloc() (such maps were leaked). It is believed that the extra destroy of the map was generally harmless since bus_dmamem_alloc() often uses special maps for which bus_dmamap_destroy() is a no-op (e.g. on x86). Reviewed by: scottl Notes: svn path=/head/; revision=267340
* Fix several panics when initialization of an ISA or PC-CARD device fails:Gavin Atkinson2013-12-141-4/+5
| | | | | | | | | | | | | | | o Assign sc->an_dev in an_probe() (which isn't really a probe function in the standard newbus sense) as we may need it for printing errors. o Use device_printf() rather than if_printf() in an_reset() - this is called from an_probe() long before the ifp structure is initialised in an_attach(). o Initialize the ifp structure early in an_attach() as we use if_printf() in cases where allocation of descriptors etc fails. MFC after: 3 days Notes: svn path=/head/; revision=259393
* The r48589 promised to remove implicit inclusion of if_var.h soon. PrepareGleb Smirnoff2013-10-261-0/+1
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=257176
* Mechanically substitute flags from historic mbuf allocator withGleb Smirnoff2012-12-041-4/+4
| | | | | | | malloc(9) flags in sys/dev. Notes: svn path=/head/; revision=243857
* ether_ifattach() sets if_mtu to ETHERMTU, don't bother set it againKevin Lo2012-01-071-1/+0
| | | | | | | Reviewed by: yongari Notes: svn path=/head/; revision=229767
* Fix some net80211 enum nits:Bernhard Schmidt2011-12-171-2/+2
| | | | | | | | | | | | | - ic_vap_create() uses an ieee80211_opmode argument - ieee80211_rate2media() takes an ieee80211_phymode argument - ieee80211_plcp2rate() takes an ieee80211_phytype argument - cast to enum ieee80211_protmode and ieee80211_roamingmode to silence compiler warnings Submitted by: arundel@ Notes: svn path=/head/; revision=228621
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten2011-11-071-1/+2
| | | | | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static. Notes: svn path=/head/; revision=227309
* Remove duplicate header includesKevin Lo2011-06-281-1/+0
| | | | Notes: svn path=/head/; revision=223624
* Add new tunable 'net.link.ifqmaxlen' to set default send interfaceMaxim Sobolev2010-05-031-2/+2
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=207554
* - For 350 chips, don't set various INTR bits in TX control word; turning INTRJohn Baldwin2009-11-241-3/+3
| | | | | | | | | | | | bits on seems to confuse hardware TX engine. - For 350 chips, set TX desc's buffer physical address before turning on the TX desc valid bit. Submitted by: Jeremy O'Brien obrien654j | gmail, sephe Obtained from: DragonFly BSD Notes: svn path=/head/; revision=199757
* Use bus_*() rather than bus_space_*().John Baldwin2009-11-241-3/+0
| | | | Notes: svn path=/head/; revision=199756
* - Locking fixes to not do silly things like drop the lock only to call aJohn Baldwin2009-11-101-76/+66
| | | | | | | | | | | | function that immediately reacquires the lock. Also removes recursive locking. - Use the statistics timer to drive the transmit watchdog instead of using if_watchdog and if_timer. Tested by: gavin Notes: svn path=/head/; revision=199154
* - Use device_printf() instead of printf() with an explicit unit numberJohn Baldwin2009-11-061-1/+1
| | | | | | | | | | | | in the PCI attach routine. - Simplify PCI probe. - Remove no-longer-used 'unit' from an_attach() parameters. PR: kern/126924 Submitted by: gavin Notes: svn path=/head/; revision=198995
* Use device_printf() and if_printf() instead of printf() with an explicitJohn Baldwin2009-11-061-68/+61
| | | | | | | unit number and remove 'unit' members from softc. Notes: svn path=/head/; revision=198987
* Shutdown routine returns int.Warner Losh2009-02-041-2/+2
| | | | Notes: svn path=/head/; revision=188128
* In case INET is not defined, then ANCACHE is not defined andBjoern A. Zeeb2008-11-061-0/+2
| | | | | | | | | | | the sc does not have 'an_have_rssimap' variable. Add an ANCACHE check to poperly hide the case and make an(4) compile without INET. MFC after: 2 months Notes: svn path=/head/; revision=184708
* Style changes from avatar.Doug Ambrisko2008-01-181-39/+39
| | | | | | | Submitted by: avatar Notes: svn path=/head/; revision=175446
* First real attempt at proper locking. The locking is a little complicatedDoug Ambrisko2008-01-181-121/+248
| | | | | | | | | | | | | | | | | | | | | | | since the the command and data that is being built to be sent to or read from the HW lives in the softc. Commands are later run via an_setdef etc. In the ioctl path various references are kept to the data stored in the softc so it needs to be protected. Almost think of the command in the softc a global variable since it essentially is. Since locking wasn't done in this type of context the commands would get corrupted. Thanks to avatar@ for catching some lock issues and dhw@ for testing. Things are a lot more stable except for the MPI-350 cards. My an(4) remote laptop stays on the network now. The driver should be changed so that it uses private memory that is passed to the functions that talk to the card. Then only those functions would really need to grab locks. Reviewed by: avatar@ Notes: svn path=/head/; revision=175445
* MFP4(129048): Eliminating an unnecessary check on an_gone insideTai-hwa Liang2007-11-271-4/+0
| | | | | | | | | | | an_stats_update() since a properly locked callout_stop(9) does do the right thing. Reviewed by: ambrisko, jhb MFC after: 3 days Notes: svn path=/head/; revision=173975
* MFP4(128855, 129015):Tai-hwa Liang2007-11-161-10/+17
| | | | | | | | | | | | | | | | | | | | - Trying to eliminate another racing by replacing the timeout(9) with callout APIs. In addition to that, the callout_drain() in an_detach() help us to avoid a possible panic-on-free due to the callout API tries to lock a destroyed mutex. - In an_stats_update(), check the return value of an_read_record(). This should reduce the chance of device removal(PCCARD) panic [2]. - Adding a comment to state the fact that an_stats_update() is now called via callout(9) with a lock held [2]. Submitted by: jhb [1], ambrisko [2] Reviewed by: jhb, ambrisko Reported by: dhw Tested by: dhw MFC after: 3 days Notes: svn path=/head/; revision=173668
* Fixing invalid channel display in ifconfig(8) by implementing requiredTai-hwa Liang2007-09-101-0/+17
| | | | | | | | | | | | | | | | | | ioctl(). Note that other information provided by ifconfig(8) such like "list chan" or "list ap" are still not available at this moment. Before an(4) is connected to wlan(4), users are encouraged to use ancontrol(8) to retrieve aforementioned information. Reported by: dhw (http://lists.freebsd.org/pipermail/freebsd-current/2007-July/074848.html) Reviewed by: ambrisko Tested by: dhw Approved by: re (bmah) Notes: svn path=/head/; revision=172112
* MFP4(123687): Closing another LOR by dropping the driver lock around callsTai-hwa Liang2007-08-071-1/+3
| | | | | | | | | | | to if_input(). Reviewed by: ambrisko Tested by: dhw Approved by: re (kensmith) Notes: svn path=/head/; revision=171775
* MFP4(123686): Fixing various ancontrol(8) related panics by dropping locksTai-hwa Liang2007-08-021-12/+60
| | | | | | | | | | | around copyin()/copyout(). Reviewed by: sam, thompsa Tested by: dhw Approved by: re (kensmith) Notes: svn path=/head/; revision=171692
* Remove assignment to uninitialized variable that wasn't then used anyway.Matt Jacob2007-06-081-2/+0
| | | | Notes: svn path=/head/; revision=170409
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningRobert Watson2006-11-061-5/+6
| | | | | | | | | | | | | | | | 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> Notes: svn path=/head/; revision=164033
* Since DELAY() was moved, most <machine/clock.h> #includes have beenPoul-Henning Kamp2006-05-161-1/+0
| | | | | | | unnecessary. Notes: svn path=/head/; revision=158651
* Silence the strict-alias warnings. Make a trip through (void *) whenWarner Losh2006-02-041-16/+16
| | | | | | | | | casting a structure to a uint32_t *. Many drivers in the tree do this, but I'll not update them until these changes can be reviewed by the pedantic standards folks. Notes: svn path=/head/; revision=155321
* Since the A-Z range is contained in the previous check, the else-if isNate Lawson2006-01-261-3/+2
| | | | | | | | | | | dead code. Clean up both by using isprint() instead, since that's what it really wants. Coverity ID: 100 Found by: Coverity Prevent Notes: svn path=/head/; revision=154866
* Don't leak mbufs and mbuf clusters in several error-handling situationsRobert Watson2006-01-151-0/+4
| | | | | | | | | | in the if_an receive routine. Found with: Coverity Prevent (tm) MFC after: 1 week Notes: svn path=/head/; revision=154394
* If frame length is excessive, don't leak an mbuf and cluster whenRobert Watson2006-01-151-0/+1
| | | | | | | | | | abandoning processing. Found with: Coverity Prevent (tm) MFC after: 1 week Notes: svn path=/head/; revision=154393
* - Store pointer to the link-level address right in "struct ifnet"Ruslan Ermilov2005-11-111-2/+3
| | | | | | | | | | | | | rather than in ifindex_table[]; all (except one) accesses are through ifp anyway. IF_LLADDR() works faster, and all (except one) ifaddr_byindex() users were converted to use ifp->if_addr. - Stop storing a (pointer to) Ethernet address in "struct arpcom", and drop the IFP2ENADDR() macro; all users have been converted to use IF_LLADDR() instead. Notes: svn path=/head/; revision=152315
* - Make IFP2ENADDR() a pointer to IF_LLADDR() rather than anotherRuslan Ermilov2005-11-111-6/+0
| | | | | | | | | | | copy of Ethernet address. - Change iso88025_ifattach() and fddi_ifattach() to accept MAC address as an argument, similar to ether_ifattach(), to make this work. Notes: svn path=/head/; revision=152296
* MFp4: KNF (mostly remove K&R function definitions). Fix some spaces leftWarner Losh2005-09-221-176/+82
| | | | | | | | | | over from de__Ping. # Didn't fix the -Exxxx return statements that appaer to be linuxisms # (and wrong) since I don't have hardware to test with. Notes: svn path=/head/; revision=150446
* Make sure that we call if_free(ifp) after bus_teardown_intr. Since weWarner Losh2005-09-191-1/+1
| | | | | | | | | | 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. Notes: svn path=/head/; revision=150306
* Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE andRobert Watson2005-08-091-12/+12
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=148887
* Do not lock an to check gone flag. Only need to hold the lock to setMaksim Yevmenkin2005-08-021-2/+1
| | | | | | | | | | the gone flag. Reviewed by: imp MFC after: 1 day Notes: svn path=/head/; revision=148639
* Reorganize an_detach() a bit. Make sure ether_ifdetach() and if_free()Maksim Yevmenkin2005-07-271-3/+4
| | | | | | | | | | | | | | are called outside of AN_LOCK()/AN_UNLOCK. This fixes the following WITNESS warning (produced when an(4) PCMCIA card is detached). taskqueue_drain with the following non-sleepable locks held: exclusive sleep mutex an0 (network driver) r = 0 (0xc59af168) locked @ /usr/src/sys/dev/an/if_an.c:2836 MFC after: 3 days Silence from: current@ Notes: svn path=/head/; revision=148454
* Initialize sc->an_ifp when doing if_alloc(). This prevents an(4)Xin LI2005-06-141-1/+1
| | | | | | | | | from being panic when attaching. Approved by: re (scottl) Notes: svn path=/head/; revision=147380
* Stop embedding struct ifnet at the top of driver softcs. Instead theBrooks Davis2005-06-101-17/+23
| | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=147256
* check copyin/copyout return valuesSam Leffler2005-03-281-14/+24
| | | | | | | Noticed by: Coverity Prevent analysis tool Notes: svn path=/head/; revision=144242
* Start each of the license/copyright comments with /*-, minor shuffle of linesWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139749
* Second part of ALTQ driver modifications, covering:Max Laier2004-08-011-5/+7
| | | | | | | | | | | | | an(4), ath(4), hme(4), ndis(4), vr(4) and wi(4) Please help testing: http://people.freebsd.org/~mlaier/ALTQ_driver/ Tested by: Vaidas Damosevicius (an, ath, wi) Roman Divacky (vr) Submitted by: yongari (hme) Notes: svn path=/head/; revision=132986