ipro1000: Delete the old BeOS driver.
"Where we're going, we don't need BeOS drivers..."
This commit is contained in:
@@ -1,32 +1,3 @@
|
||||
SubDir HAIKU_TOP src add-ons kernel drivers network ipro1000 ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
# For ether_driver.h
|
||||
UsePrivateHeaders net ;
|
||||
|
||||
KernelAddon beos_ipro1000 :
|
||||
driver.c
|
||||
device.c
|
||||
if_compat.c
|
||||
if_em.c
|
||||
if_em_hw.c
|
||||
if_em_osdep.c
|
||||
mempool.c
|
||||
timer.c
|
||||
util.c
|
||||
;
|
||||
|
||||
# Installation
|
||||
|
||||
HaikuInstall install-networking : /boot/home/config/add-ons/kernel/drivers/bin :
|
||||
beos_ipro1000
|
||||
;
|
||||
|
||||
HaikuInstallRelSymLink install-networking : /boot/home/config/add-ons/kernel/drivers/dev/net :
|
||||
<installed>beos_ipro1000 :
|
||||
installed-symlink
|
||||
;
|
||||
|
||||
SubInclude HAIKU_TOP src add-ons kernel drivers network ipro1000 dev ;
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
$FreeBSD: /repoman/r/ncvs/src/sys/dev/em/LICENSE,v 1.1.2.2 2003/04/04 18:39:28 pdeuskar Exp $
|
||||
Copyright (c) 2001-2003, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,351 +0,0 @@
|
||||
$FreeBSD: /repoman/r/ncvs/src/sys/dev/em/README,v 1.1.2.8 2003/09/03 16:36:45 pdeuskar Exp $
|
||||
FreeBSD* Driver for the Intel(R) PRO/1000 Family of Adapters
|
||||
============================================================
|
||||
|
||||
July 24, 2003
|
||||
|
||||
|
||||
Contents
|
||||
========
|
||||
|
||||
- Overview
|
||||
- Supported Adapters
|
||||
- Building and Installation
|
||||
- Speed and Duplex Configuration
|
||||
- Additional Configurations
|
||||
- Known Limitations
|
||||
- Support
|
||||
- License
|
||||
|
||||
|
||||
Overview
|
||||
========
|
||||
|
||||
This file describes the FreeBSD* driver, version 1.7.x, for the Intel(R)
|
||||
PRO/1000 Family of Adapters. This driver has been developed for use with
|
||||
FreeBSD, version 4.7.
|
||||
|
||||
For questions related to hardware requirements, refer to the documentation
|
||||
supplied with your Intel PRO/1000 adapter. All hardware requirements listed
|
||||
apply to use with FreeBSD.
|
||||
|
||||
|
||||
Supported Adapters
|
||||
==================
|
||||
|
||||
The following Intel network adapters are compatible with the drivers in this
|
||||
release:
|
||||
|
||||
Controller Adapter Name Board IDs
|
||||
---------- ------------ ---------
|
||||
|
||||
82542 PRO/1000 Gigabit Server Adapter 700262-xxx, 717037-xxx
|
||||
|
||||
82543 PRO/1000 F Server Adapter 738640-xxx, A38888-xxx,
|
||||
A06512-xxx
|
||||
|
||||
82543 PRO/1000 T Server Adapter A19845-xxx, A33948-xxx
|
||||
|
||||
82544 PRO/1000 XT Server Adapter A51580-xxx
|
||||
|
||||
82544 PRO/1000 XF Server Adapter A50484-xxx
|
||||
|
||||
82544 PRO/1000 T Desktop Adapter A62947-xxx
|
||||
|
||||
82540 PRO/1000 MT Desktop Adapter A78408-xxx
|
||||
|
||||
82541 PRO/1000 MT Desktop Adapter C91016-xxx
|
||||
|
||||
82545 PRO/1000 MT Server Adapter A92165-xxx
|
||||
|
||||
82545 PRO/1000 MF Server Adapter A91622-xxx
|
||||
|
||||
82545 PRO/1000 MF Server Adapter(LX) A91624-xxx
|
||||
|
||||
82546 PRO/1000 MT Dual Port Server Adapter A92111-xxx
|
||||
|
||||
82546 PRO/1000 MF Dual Port Server Adapter A91620-xxx
|
||||
|
||||
82546EB PRO/1000 MT Quad Port Server Adapter C11227-xxx
|
||||
|
||||
82547 PRO/1000 CT Network Connection
|
||||
|
||||
|
||||
To verify your Intel adapter is supported, find the board ID number on the
|
||||
adapter. Look for a label that has a barcode and a number in the format of
|
||||
123456-001 (six digits hyphen three digits). Match this to the list of
|
||||
numbers above.
|
||||
|
||||
For more information on how to identify your adapter, go to the Adapter &
|
||||
Driver ID Guide at:
|
||||
|
||||
http://support.intel.com/support/network/adapter/pro100/21397.htm
|
||||
|
||||
For the latest Intel network drivers for FreeBSD, see:
|
||||
|
||||
http://appsr.intel.com/scripts-df/support_intel.asp
|
||||
|
||||
|
||||
Building and Installation
|
||||
=========================
|
||||
|
||||
NOTE: The driver can be installed as a dynamic loadable kernel module or
|
||||
compiled into the kernel. You must have kernel sources installed in
|
||||
order to compile the driver module.
|
||||
|
||||
In the instructions below, x.x.x is the driver version as indicated in the
|
||||
name of the driver tar file.
|
||||
|
||||
1. Move the base driver tar file to the directory of your choice. For
|
||||
example, use /home/username/em or /usr/local/src/em.
|
||||
|
||||
2. Untar/unzip the archive:
|
||||
|
||||
tar xvfz em-x.x.x.tar.gz
|
||||
|
||||
This will create an em-x.x.x directory.
|
||||
|
||||
3. To create a loadable module, perform the following steps.
|
||||
NOTE: To compile the driver into the kernel, go directly to step 4.
|
||||
|
||||
a. To compile the module
|
||||
|
||||
cd em-x.x.x
|
||||
make
|
||||
|
||||
b. To install the compiled module in system directory:
|
||||
|
||||
make install
|
||||
|
||||
c. If you want the driver to load automatically when the system is booted:
|
||||
|
||||
1. Follow steps a, and b above to compile and install the module
|
||||
2. Edit /boot/loader.conf, and add the following line:
|
||||
|
||||
if_em_load="YES"
|
||||
|
||||
4. To compile the driver into the kernel:
|
||||
|
||||
cd em-x.x.x/src
|
||||
|
||||
cp if_em* /usr/src/sys/dev/em
|
||||
|
||||
cp Makefile.kernel /usr/src/sys/modules/em/Makefile
|
||||
|
||||
Edit the /usr/src/sys/conf/files.i386 file, and add the following lines:
|
||||
|
||||
dev/em/if_em.c optional em
|
||||
|
||||
dev/em/if_em_hw.c optional em
|
||||
|
||||
Remove the following lines from the /usr/src/sys/conf/files.i386 file,
|
||||
if they exist:
|
||||
|
||||
dev/em/if_em_fxhw.c optional em
|
||||
dev/em/if_em_phy.c optional em
|
||||
|
||||
Edit the kernel configuration file (i.e., GENERIC or MYKERNEL) in
|
||||
/usr/src/sys/i386/conf, and ensure the following line is present:
|
||||
|
||||
device em
|
||||
|
||||
Compile and install the kernel. The system must be rebooted for the kernel
|
||||
updates to take effect. For additional information on compiling the
|
||||
kernel, consult the FreeBSD operating system documentation.
|
||||
|
||||
5. To assign an IP address to the interface, enter the following:
|
||||
|
||||
ifconfig em<interface_num> <IP_address>
|
||||
|
||||
6. Verify that the interface works. Enter the following, where <IP_address>
|
||||
is the IP address for another machine on the same subnet as the interface
|
||||
that is being tested:
|
||||
|
||||
ping <IP_address>
|
||||
|
||||
7. To configure the IP address to remain after reboot, edit /etc/rc.conf,
|
||||
and create the appropriate ifconfig_em<interface_num> entry:
|
||||
|
||||
ifconfig_em<interface_num>="<ifconfig_settings>"
|
||||
|
||||
Example usage:
|
||||
|
||||
ifconfig_em0="inet 192.168.10.1 netmask 255.255.255.0"
|
||||
|
||||
NOTE: For assistance, see the ifconfig man page.
|
||||
|
||||
|
||||
Speed and Duplex Configuration
|
||||
==============================
|
||||
|
||||
By default, the adapter auto-negotiates the speed and duplex of the
|
||||
connection. If there is a specific need, the ifconfig utility can be used to
|
||||
configure the speed and duplex settings on the adapter. Example usage:
|
||||
|
||||
ifconfig em<interface_num> <IP_address> media 100baseTX mediaopt
|
||||
full-duplex
|
||||
|
||||
NOTE: Only use mediaopt to set the driver to full-duplex. If mediaopt is
|
||||
not specified and you are not running at gigabit speed, the driver
|
||||
defaults to half-duplex.
|
||||
|
||||
|
||||
This driver supports the following media type options:
|
||||
|
||||
autoselect - Enables auto-negotiation for speed and duplex.
|
||||
|
||||
10baseT/UTP - Sets speed to 10 Mbps. Use the ifconfig mediaopt
|
||||
option to select full-duplex mode.
|
||||
|
||||
100baseTX - Sets speed to 100 Mbps. Use the ifconfig mediaopt
|
||||
option to select full-duplex mode.
|
||||
|
||||
1000baseTX - Sets speed to 1000 Mbps. In this case, the driver
|
||||
supports only full-duplex mode.
|
||||
|
||||
1000baseSX - Sets speed to 1000 Mbps. In this case, the driver
|
||||
supports only full-duplex mode.
|
||||
|
||||
For more information on the ifconfig utility, see the ifconfig man page.
|
||||
|
||||
|
||||
Additional Configurations
|
||||
=========================
|
||||
|
||||
The driver supports Transmit/Receive Checksum Offload and Jumbo Frames on
|
||||
all but the 82542-based adapters. For specific adapters, refer to the
|
||||
Supported Adapters section.
|
||||
|
||||
Jumbo Frames
|
||||
------------
|
||||
To enable Jumbo Frames, use the ifconfig utility to increase the MTU
|
||||
beyond 1500 bytes.
|
||||
|
||||
NOTES: Only enable Jumbo Frames if your network infrastructure supports
|
||||
them.
|
||||
|
||||
The Jumbo Frames setting on the switch must be set to at least
|
||||
22 bytes larger than that of the adapter.
|
||||
|
||||
The Jumbo Frames MTU range for Intel Adapters is 1500 to 16114. The default
|
||||
MTU range is 1500. To modify the setting, enter the following:
|
||||
|
||||
ifconfig em<interface_num> <hostname or IP address> mtu 9000
|
||||
|
||||
To confirm an interface's MTU value, use the ifconfig command. To confirm
|
||||
the MTU used between two specific devices, use:
|
||||
|
||||
route get <destination_IP_address>
|
||||
|
||||
VLANs
|
||||
-----
|
||||
To create a new VLAN pseudo-interface:
|
||||
|
||||
ifconfig <vlan_name> create
|
||||
|
||||
To associate the VLAN pseudo-interface with a physical interface and
|
||||
assign a VLAN ID, IP address, and netmask:
|
||||
|
||||
ifconfig <vlan_name> <ip_address> netmask <subnet_mask> vlan
|
||||
<vlan_id> vlandev <physical_interface>
|
||||
|
||||
Example:
|
||||
|
||||
ifconfig vlan10 10.0.0.1 netmask 255.255.255.0 vlan10 vlandev em0
|
||||
|
||||
In this example, all packets will be marked on egress with 802.1Q VLAN
|
||||
tags, specifying a VLAN ID of 10.
|
||||
|
||||
To remove a VLAN pseudo-interface:
|
||||
|
||||
ifconfig <vlan_name> destroy
|
||||
|
||||
Polling
|
||||
-------
|
||||
To enable polling in the driver, add the following options to the kernel
|
||||
configuration, and then recompile the kernel:
|
||||
|
||||
options DEVICE_POLLING
|
||||
options HZ=1000
|
||||
|
||||
At runtime, use the following command to turn on polling mode. Similarly,
|
||||
turn off polling mode by setting the variable to 0:
|
||||
|
||||
sysctl kern.polling.enable=1
|
||||
|
||||
|
||||
NOTES: DEVICE POLLING is only valid for non-SMP kernels.
|
||||
|
||||
The driver has to be built into the kernel for DEVICE POLLING to be
|
||||
enabled in the driver.
|
||||
|
||||
|
||||
Known Limitations
|
||||
=================
|
||||
|
||||
There are known performance issues with this driver when running UDP traffic
|
||||
with Jumbo Frames. Intel recommends not using Jumbo Frames for UDP traffic.
|
||||
|
||||
|
||||
82541/82547 can't link or is slow to link with some link partners
|
||||
-----------------------------------------------------------------
|
||||
|
||||
There is a known compatibility issue with 82541/82547 and some switches
|
||||
where link will not be established, or will be slow to establish. In
|
||||
particular, these switches are known to be incompatible with 82541/82547:
|
||||
|
||||
Planex FXG-08TE
|
||||
I-O Data ETG-SH8
|
||||
|
||||
To workaround the issue, the driver can be compiled with an override of the
|
||||
PHY's master/slave setting. Forcing master or forcing slave mode will
|
||||
improve time-to-link.
|
||||
|
||||
Edit ./em.x.x.x/src/if_em.h to remove the #define EM_MASTER_SLAVE
|
||||
from within the comments.
|
||||
|
||||
/* #define EM_MASTER_SLAVE 2 */
|
||||
#define EM_MASTER_SLAVE 2
|
||||
|
||||
Use one of the following options.
|
||||
0 = Hardware default
|
||||
1 = Master mode
|
||||
2 = Slave mode
|
||||
3 = Auto master/slave
|
||||
|
||||
Recompile the module (refer to step 3 above)
|
||||
a. To compile the module
|
||||
|
||||
cd em-x.x.x
|
||||
make clean
|
||||
make
|
||||
|
||||
b. To install the compiled module in system directory:
|
||||
|
||||
make install
|
||||
|
||||
|
||||
Support
|
||||
=======
|
||||
|
||||
For general information and support, go to the Intel support website at:
|
||||
|
||||
http://support.intel.com
|
||||
|
||||
If an issue is identified with the released source code on the supported
|
||||
kernel with a supported adapter, email the specific information related to
|
||||
the issue to [email protected].
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This software program is released under the terms of a license agreement
|
||||
between you ('Licensee') and Intel. Do not use or load this software or any
|
||||
associated materials (collectively, the 'Software') until you have carefully
|
||||
read the full terms and conditions of the LICENSE located in this software
|
||||
package. By loading or using the Software, you agree to the terms of this
|
||||
Agreement. If you do not agree with the terms of this Agreement, do not
|
||||
install or use the Software.
|
||||
|
||||
* Other names and brands may be claimed as the property of others.
|
||||
@@ -1,76 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <[email protected]>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef __DEBUG_H
|
||||
#define __DEBUG_H
|
||||
|
||||
#include <KernelExport.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/* Set these to 1 to enable debugging */
|
||||
#define DEBUG_DEVICE 0
|
||||
#define DEBUG_INIT 0
|
||||
#define DEBUG_IOCTL 0
|
||||
#define DEBUG_HW 0
|
||||
#define DEBUG_FUNC_CALLS 0
|
||||
#define DEBUG_DISPLAY_STATS 1
|
||||
|
||||
#define ASSERT(a) if (a) ; else panic("ipro1000: ASSERT failed, " #a)
|
||||
#define DEBUGFUNC(S) if (DEBUG_FUNC_CALLS) dprintf("ipro1000: " S "\n")
|
||||
#define DEVICE_DEBUGOUT(S) if (DEBUG_DEVICE) dprintf("ipro1000: " S "\n")
|
||||
#define DEVICE_DEBUGOUT1(S,A) if (DEBUG_DEVICE) dprintf("ipro1000: " S "\n", A)
|
||||
#define DEVICE_DEBUGOUT2(S,A,B) if (DEBUG_DEVICE) dprintf("ipro1000: " S "\n", A, B)
|
||||
#define INIT_DEBUGOUT(S) if (DEBUG_INIT) dprintf("ipro1000: " S "\n")
|
||||
#define INIT_DEBUGOUT1(S,A) if (DEBUG_INIT) dprintf("ipro1000: " S "\n", A)
|
||||
#define INIT_DEBUGOUT2(S,A,B) if (DEBUG_INIT) dprintf("ipro1000: " S "\n", A, B)
|
||||
#define INIT_DEBUGOUT3(S,A,B,C) if (DEBUG_INIT) dprintf("ipro1000: " S "\n", A, B, C)
|
||||
#define INIT_DEBUGOUT7(S,A,B,C,D,E,F,G) if (DEBUG_INIT) dprintf("ipro1000: " S "\n", A,B,C,D,E,F,G)
|
||||
#define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) dprintf("ipro1000: " S "\n")
|
||||
#define IOCTL_DEBUGOUT1(S,A) if (DEBUG_IOCTL) dprintf("ipro1000: " S "\n", A)
|
||||
#define IOCTL_DEBUGOUT2(S,A,B) if (DEBUG_IOCTL) dprintf("ipro1000: " S "\n", A, B)
|
||||
#define HW_DEBUGOUT(S) if (DEBUG_HW) dprintf("ipro1000: " S "\n")
|
||||
#define HW_DEBUGOUT1(S,A) if (DEBUG_HW) dprintf("ipro1000: " S "\n", A)
|
||||
#define HW_DEBUGOUT2(S,A,B) if (DEBUG_HW) dprintf("ipro1000: " S "\n", A, B)
|
||||
#define HW_DEBUGOUT7(S,A,B,C,D,E,F,G) if (DEBUG_HW) dprintf("ipro1000: " S "\n", A,B,C,D,E,F,G)
|
||||
#else
|
||||
#define DEBUG_DISPLAY_STATS 0
|
||||
#define DEBUGFUNC(S)
|
||||
#define DEVICE_DEBUGOUT(S)
|
||||
#define DEVICE_DEBUGOUT1(S,A)
|
||||
#define DEVICE_DEBUGOUT2(S,A,B)
|
||||
#define INIT_DEBUGOUT(S)
|
||||
#define INIT_DEBUGOUT1(S,A)
|
||||
#define INIT_DEBUGOUT2(S,A,B)
|
||||
#define INIT_DEBUGOUT3(S,A,B,C)
|
||||
#define INIT_DEBUGOUT7(S,A,B,C,D,E,F,G)
|
||||
#define IOCTL_DEBUGOUT(S)
|
||||
#define IOCTL_DEBUGOUT1(S,A)
|
||||
#define IOCTL_DEBUGOUT2(S,A,B)
|
||||
#define HW_DEBUGOUT(S)
|
||||
#define HW_DEBUGOUT1(S,A)
|
||||
#define HW_DEBUGOUT2(S,A,B)
|
||||
#define HW_DEBUGOUT7(S,A,B,C,D,E,F,G)
|
||||
#define ASSERT(a)
|
||||
#endif
|
||||
|
||||
#define ERROROUT(S) dprintf("ipro1000: ERROR " S "\n")
|
||||
#define ERROROUT1(S,A) dprintf("ipro1000: ERROR " S "\n", A)
|
||||
#define ERROROUT3(S,A,B,C) dprintf("ipro1000: ERROR " S "\n", A,B,C)
|
||||
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
$FreeBSD$
|
||||
|
||||
Copyright (c) 2001-2010, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -1,406 +0,0 @@
|
||||
$FreeBSD$
|
||||
FreeBSD* Driver for Intel Network Connection
|
||||
=============================================
|
||||
|
||||
May 30, 2007
|
||||
|
||||
|
||||
Contents
|
||||
========
|
||||
|
||||
- Overview
|
||||
- Identifying Your Adapter
|
||||
- Building and Installation
|
||||
- Speed and Duplex Configuration
|
||||
- Additional Configurations
|
||||
- Known Limitations
|
||||
- Support
|
||||
- License
|
||||
|
||||
|
||||
Overview
|
||||
========
|
||||
|
||||
This file describes the FreeBSD* driver for Intel Network Connection.
|
||||
This driver has been developed for use with FreeBSD, Release 7.x.
|
||||
|
||||
For questions related to hardware requirements, refer to the documentation
|
||||
supplied with your Gigabit adapter. All hardware requirements listed
|
||||
apply to use with FreeBSD.
|
||||
|
||||
|
||||
Identifying Your Adapter
|
||||
========================
|
||||
|
||||
For information on how to identify your adapter, go to the Adapter &
|
||||
Driver ID Guide at:
|
||||
|
||||
http://support.intel.com/support/network/sb/cs-012904.htm
|
||||
|
||||
|
||||
For the latest Intel network drivers for FreeBSD, see:
|
||||
|
||||
http://downloadfinder.intel.com/scripts-df-external/support_intel.aspx
|
||||
|
||||
|
||||
NOTE: Mobile adapters are not fully supported.
|
||||
NOTE: The Intel(R) 82562v 10/100 Network Connection only provides 10/100
|
||||
support.
|
||||
|
||||
Building and Installation
|
||||
=========================
|
||||
|
||||
NOTE: The driver can be installed as a dynamic loadable kernel module or
|
||||
compiled into the kernel. You must have kernel sources installed in
|
||||
order to compile the driver module.
|
||||
|
||||
In the instructions below, x.x.x is the driver version as indicated in the
|
||||
name of the driver tar file.
|
||||
|
||||
1. Move the base driver tar file to the directory of your choice. For
|
||||
example, use /home/username/em or /usr/local/src/em.
|
||||
|
||||
2. Untar/unzip the archive:
|
||||
|
||||
tar xzvf em-x.x.x.tar.gz
|
||||
|
||||
This will create an em-x.x.x directory.
|
||||
|
||||
3. To create a loadable module, perform the following steps.
|
||||
NOTE: To compile the driver into the kernel, go directly to step 4.
|
||||
|
||||
a. To compile the module
|
||||
|
||||
cd em-x.x.x
|
||||
make
|
||||
|
||||
b. To install the compiled module to the system directory:
|
||||
|
||||
make install
|
||||
|
||||
c. If you want the driver to load automatically when the system is booted:
|
||||
|
||||
1. Edit /boot/loader.conf, and add the following line:
|
||||
|
||||
if_em_load="YES"
|
||||
|
||||
4. To compile the driver into the kernel, enter:
|
||||
|
||||
cd em-x.x.x/src
|
||||
cp *.[ch] /usr/src/sys/dev/em
|
||||
|
||||
Edit the kernel configuration file (i.e., GENERIC or MYKERNEL) in
|
||||
/usr/src/sys/i386/conf, and ensure the following line is present:
|
||||
|
||||
device em
|
||||
|
||||
Compile and install the kernel. The system must be rebooted for the
|
||||
kernel updates to take effect. For additional information on compiling
|
||||
the kernel, consult the FreeBSD operating system documentation.
|
||||
|
||||
5. To assign an IP address to the interface, enter the following:
|
||||
|
||||
ifconfig em<interface_num> <IP_address>
|
||||
|
||||
6. Verify that the interface works. Enter the following, where <IP_address>
|
||||
is the IP address for another machine on the same subnet as the interface
|
||||
that is being tested:
|
||||
|
||||
ping <IP_address>
|
||||
|
||||
7. To configure the IP address to remain after reboot, edit /etc/rc.conf,
|
||||
and create the appropriate ifconfig_em<interface_num>entry:
|
||||
|
||||
ifconfig_em<interface_num>="<ifconfig_settings>"
|
||||
|
||||
Example usage:
|
||||
|
||||
ifconfig_em0="inet 192.168.10.1 netmask 255.255.255.0"
|
||||
|
||||
NOTE: For assistance, see the ifconfig man page.
|
||||
|
||||
|
||||
Speed and Duplex Configuration
|
||||
==============================
|
||||
|
||||
By default, the adapter auto-negotiates the speed and duplex of the
|
||||
connection. If there is a specific need, the ifconfig utility can be used to
|
||||
configure the speed and duplex settings on the adapter. Example usage:
|
||||
|
||||
ifconfig em<interface_num> <IP_address> media 100baseTX mediaopt
|
||||
full-duplex
|
||||
|
||||
NOTE: Only use mediaopt to set the driver to full-duplex. If mediaopt is
|
||||
not specified and you are not running at gigabit speed, the driver
|
||||
defaults to half-duplex.
|
||||
|
||||
If the interface is currently forced to 100 full duplex, in order to change
|
||||
to half duplex you must use this command:
|
||||
|
||||
ifconfig em<interface_num> <IP_address> media 100baseTX -mediaopt
|
||||
full-duplex
|
||||
|
||||
|
||||
This driver supports the following media type options:
|
||||
|
||||
autoselect - Enables auto-negotiation for speed and duplex.
|
||||
|
||||
10baseT/UTP - Sets speed to 10 Mbps. Use the ifconfig mediaopt
|
||||
option to select full-duplex mode.
|
||||
|
||||
100baseTX - Sets speed to 100 Mbps. Use the ifconfig mediaopt
|
||||
option to select full-duplex mode.
|
||||
|
||||
1000baseTX - Sets speed to 1000 Mbps. In this case, the driver
|
||||
supports only full-duplex mode.
|
||||
|
||||
1000baseSX - Sets speed to 1000 Mbps. In this case, the driver
|
||||
supports only full-duplex mode.
|
||||
|
||||
For more information on the ifconfig utility, see the ifconfig man page.
|
||||
|
||||
|
||||
Additional Configurations
|
||||
=========================
|
||||
|
||||
The driver supports Transmit/Receive Checksum Offload and Jumbo Frames on
|
||||
all but the 82542-based adapters. For specific adapters, refer to the
|
||||
Identifying Your Adapter section.
|
||||
|
||||
Jumbo Frames
|
||||
------------
|
||||
To enable Jumbo Frames, use the ifconfig utility to set the Maximum
|
||||
Transport Unit (MTU) frame size above its default of 1500 bytes.
|
||||
|
||||
The Jumbo Frames MTU range for Intel Adapters is 1500 to 16110. To modify
|
||||
the setting, enter the following:
|
||||
|
||||
ifconfig em<interface_num> <hostname or IP address> mtu 9000
|
||||
|
||||
To confirm the MTU used between two specific devices, use:
|
||||
|
||||
route get <destination_IP_address>
|
||||
|
||||
Notes:
|
||||
|
||||
- Only enable Jumbo Frames if your network infrastructure supports them.
|
||||
|
||||
- To enable Jumbo Frames, increase the MTU size on the interface beyond
|
||||
1500.
|
||||
|
||||
- The Jumbo Frames setting on the switch must be set to at least 22 bytes
|
||||
larger than that of the MTU.
|
||||
|
||||
- The maximum MTU setting for Jumbo Frames is 16110. This value coincides
|
||||
with the maximum Jumbo Frames size of 16128.
|
||||
|
||||
- Some Intel gigabit adapters that support Jumbo Frames have a frame size
|
||||
limit of 9238 bytes, with a corresponding MTU size limit of 9216 bytes.
|
||||
The adapters with this limitation are based on the Intel(R) 82571EB,
|
||||
82572EI, 82573L, 82566, 82562, and 80003ES2LAN controller. These
|
||||
correspond to the following product names:
|
||||
Intel(R) PRO/1000 PT Server Adapter
|
||||
Intel(R) PRO/1000 PT Desktop Adapter
|
||||
Intel(R) PRO/1000 PT Network Connection
|
||||
Intel(R) PRO/1000 PT Dual Port Server Adapter
|
||||
Intel(R) PRO/1000 PT Dual Port Network Connection
|
||||
Intel(R) PRO/1000 PT Quad Port Server Adapter
|
||||
Intel(R) PRO/1000 PF Quad Port Server Adapter
|
||||
Intel(R) PRO/1000 PF Server Adapter
|
||||
Intel(R) PRO/1000 PF Network Connection
|
||||
Intel(R) PRO/1000 PF Dual Port Server Adapter
|
||||
Intel(R) PRO/1000 PB Server Connection
|
||||
Intel(R) PRO/1000 PL Network Connection
|
||||
Intel(R) PRO/1000 EB Network Connection with I/O Acceleration
|
||||
Intel(R) PRO/1000 EB Backplane Connection with I/O Acceleration
|
||||
Intel(R) 82566DM-2 Gigabit Network Connection
|
||||
|
||||
- Adapters based on the Intel(R) 82542 and 82573V/E controller do not
|
||||
support Jumbo Frames. These correspond to the following product names:
|
||||
Intel(R) PRO/1000 Gigabit Server Adapter
|
||||
Intel(R) PRO/1000 PM Network Connection
|
||||
|
||||
- Using Jumbo Frames at 10 or 100 Mbps may result in poor performance or
|
||||
loss of link.
|
||||
|
||||
- The following adapters do not support Jumbo Frames:
|
||||
Intel(R) 82562V 10/100 Network Connection
|
||||
Intel(R) 82566DM Gigabit Network Connection
|
||||
Intel(R) 82566DC Gigabit Network Connection
|
||||
Intel(R) 82566MM Gigabit Network Connection
|
||||
Intel(R) 82566MC Gigabit Network Connection
|
||||
Intel(R) 82562GT 10/100 Network Connection
|
||||
Intel(R) 82562G 10/100 Network Connection
|
||||
Intel(R) 82566DC-2 Gigabit Network Connection
|
||||
Intel(R) 82562V-2 10/100 Network Connection
|
||||
Intel(R) 82562G-2 10/100 Network Connection
|
||||
Intel(R) 82562GT-2 10/100 Network Connection
|
||||
|
||||
VLANs
|
||||
-----
|
||||
To create a new VLAN interface:
|
||||
|
||||
ifconfig <vlan_name> create
|
||||
|
||||
To associate the VLAN interface with a physical interface and
|
||||
assign a VLAN ID, IP address, and netmask:
|
||||
|
||||
ifconfig <vlan_name> <ip_address> netmask <subnet_mask> vlan
|
||||
<vlan_id> vlandev <physical_interface>
|
||||
|
||||
Example:
|
||||
|
||||
ifconfig vlan10 10.0.0.1 netmask 255.255.255.0 vlan 10 vlandev em0
|
||||
|
||||
In this example, all packets will be marked on egress with 802.1Q VLAN
|
||||
tags, specifying a VLAN ID of 10.
|
||||
|
||||
To remove a VLAN interface:
|
||||
|
||||
Intel Network Connection ifconfig <vlan_name> destroy
|
||||
|
||||
|
||||
Polling
|
||||
-------
|
||||
|
||||
To enable polling in the driver, add the following options to the kernel
|
||||
configuration, and then recompile the kernel:
|
||||
|
||||
options DEVICE_POLLING
|
||||
options HZ=1000
|
||||
|
||||
At runtime use:
|
||||
ifconfig emX polling (to turn polling on)
|
||||
and:
|
||||
ifconfig emX -polling (to turn it off)
|
||||
|
||||
|
||||
Checksum Offload
|
||||
----------------
|
||||
Checksum offloading is not supported on 82542 Gigabit adapters.
|
||||
|
||||
Checksum offloading supports both TCP and UDP packets and is
|
||||
supported for both transmit and receive.
|
||||
|
||||
Checksum offloading can be enabled or disabled using ifconfig.
|
||||
Both transmit and receive offloading will be either enabled or
|
||||
disabled together. You cannot enable/disable one without the other.
|
||||
|
||||
To enable checksum offloading:
|
||||
|
||||
ifconfig <interface_num> rxcsum
|
||||
|
||||
To disable checksum offloading:
|
||||
|
||||
ifconfig <interface_num> -rxcsum
|
||||
|
||||
To confirm the current setting:
|
||||
|
||||
ifconfig <interface_num>
|
||||
|
||||
Look for the presence or absence of the following line:
|
||||
|
||||
options=3 <RXCSUM,TXCSUM>
|
||||
|
||||
See the ifconfig man page for further information.
|
||||
|
||||
|
||||
TSO
|
||||
---
|
||||
The FreeBSD driver offers support for TSO (TCP Segmentation Offload).
|
||||
|
||||
You can enable/disable it in two ways/places:
|
||||
|
||||
- sysctl net.inet.tcp.tso=0 (or 1 to enable it)
|
||||
|
||||
Doing this disables TSO in the stack and will affect all adapters.
|
||||
|
||||
- ifconfig emX -tso
|
||||
|
||||
Doing this will disable TSO only for this adapter.
|
||||
|
||||
To enable:
|
||||
|
||||
- ifconfig emX tso
|
||||
|
||||
NOTES: By default only PCI-Express adapters are ENABLED to do TSO. Others
|
||||
can be enabled by the user at their own risk
|
||||
TSO is not supported on 82547 and 82544-based adapters, as well as older adapters.
|
||||
|
||||
|
||||
Known Limitations
|
||||
=================
|
||||
|
||||
Detected Tx Unit Hang in Quad Port Adapters
|
||||
-------------------------------------------
|
||||
|
||||
In some cases ports 3 and 4 wont pass traffic. Ports 1 and 2 don't show
|
||||
any errors and will pass traffic.
|
||||
|
||||
This issue MAY be resolved by updating to the latest BIOS. You can
|
||||
check your system's BIOS by downloading the Linux Firmware Developer Kit
|
||||
that can be obtained at http://www.linuxfirmwarekit.org/
|
||||
|
||||
|
||||
There are known performance issues with this driver when running UDP traffic
|
||||
with Jumbo Frames.
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
82541/82547 can't link or is slow to link with some link partners
|
||||
-----------------------------------------------------------------
|
||||
|
||||
There is a known compatibility issue where time to link is slow or link is not
|
||||
established between 82541/82547 controllers and some switches. Known switches
|
||||
include:
|
||||
Planex FXG-08TE
|
||||
I-O Data ETG-SH8
|
||||
Netgear GS105v3
|
||||
|
||||
The driver can be compiled with the following changes:
|
||||
|
||||
Edit ./em.x.x.x/src/if_em.h to change the #define EM_MASTER_SLAVE
|
||||
For example, change from:
|
||||
|
||||
#define EM_MASTER_SLAVE e1000_ms_hw_default
|
||||
to:
|
||||
#define EM_MASTER_SLAVE 2
|
||||
|
||||
Use one of the following options:
|
||||
1 = Master mode
|
||||
2 = Slave mode
|
||||
3 = Auto master/slave
|
||||
Setting 2 is recommended.
|
||||
|
||||
Recompile the module:
|
||||
a. To compile the module
|
||||
cd em-x.x.x
|
||||
make clean
|
||||
make
|
||||
|
||||
b. To install the compiled module in system directory:
|
||||
make install
|
||||
|
||||
|
||||
Support
|
||||
=======
|
||||
|
||||
For general information and support, go to the Intel support website at:
|
||||
|
||||
http://support.intel.com
|
||||
|
||||
If an issue is identified, support is through email only at:
|
||||
[email protected]
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This software program is released under the terms of a license agreement
|
||||
between you ('Licensee') and Intel. Do not use or load this software or any
|
||||
associated materials (collectively, the 'Software') until you have carefully
|
||||
read the full terms and conditions of the LICENSE located in this software
|
||||
package. By loading or using the Software, you agree to the terms of this
|
||||
Agreement. If you do not agree with the terms of this Agreement, do not
|
||||
install or use the Software.
|
||||
|
||||
* Other names and brands may be claimed as the property of others.
|
||||
@@ -1,404 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <[email protected]>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include "debug.h"
|
||||
#include "device.h"
|
||||
#include "driver.h"
|
||||
#include "util.h"
|
||||
#include "if_em.h"
|
||||
#include "if_compat.h"
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <driver_settings.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
# include <net/if_media.h>
|
||||
#endif
|
||||
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
static int32 gOpenMask = 0;
|
||||
|
||||
int em_attach(device_t);
|
||||
int em_detach(device_t);
|
||||
void em_media_status(struct ifnet *, struct ifmediareq *);
|
||||
|
||||
|
||||
static void
|
||||
ipro1000_read_settings(ipro1000_device *device)
|
||||
{
|
||||
void *handle;
|
||||
const char *param;
|
||||
int mtu;
|
||||
|
||||
handle = load_driver_settings("ipro1000");
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
param = get_driver_parameter(handle, "mtu", "-1", "-1");
|
||||
mtu = atoi(param);
|
||||
if (mtu >= 50 && mtu <= 1500)
|
||||
device->maxframesize = mtu + ENET_HEADER_SIZE;
|
||||
else if (mtu != -1)
|
||||
dprintf("ipro1000: unsupported mtu setting '%s' ignored\n", param);
|
||||
|
||||
unload_driver_settings(handle);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ipro1000_open(const char *name, uint32 flags, void** cookie)
|
||||
{
|
||||
ipro1000_device *device;
|
||||
char *deviceName;
|
||||
int dev_id;
|
||||
int mask;
|
||||
|
||||
DEVICE_DEBUGOUT("ipro1000_open()");
|
||||
|
||||
for (dev_id = 0; (deviceName = gDevNameList[dev_id]) != NULL; dev_id++) {
|
||||
if (!strcmp(name, deviceName))
|
||||
break;
|
||||
}
|
||||
if (deviceName == NULL) {
|
||||
ERROROUT("invalid device name");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// allow only one concurrent access
|
||||
mask = 1 << dev_id;
|
||||
if (atomic_or(&gOpenMask, mask) & mask)
|
||||
return B_BUSY;
|
||||
|
||||
*cookie = device = (ipro1000_device *)malloc(sizeof(ipro1000_device));
|
||||
if (!device) {
|
||||
atomic_and(&gOpenMask, ~(1 << dev_id));
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
memset(device, 0, sizeof(*device));
|
||||
|
||||
device->devId = dev_id;
|
||||
device->pciInfo = gDevList[dev_id];
|
||||
device->nonblocking = (flags & O_NONBLOCK) ? true : false;
|
||||
device->closed = false;
|
||||
|
||||
device->pciBus = device->pciInfo->bus;
|
||||
device->pciDev = device->pciInfo->device;
|
||||
device->pciFunc = device->pciInfo->function;
|
||||
device->adapter = 0;
|
||||
device->maxframesize = 1514; // XXX is MAXIMUM_ETHERNET_FRAME_SIZE = 1518 too much?
|
||||
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
device->linkChangeSem = -1;
|
||||
#endif
|
||||
|
||||
ipro1000_read_settings(device);
|
||||
|
||||
if (em_attach(device) != 0) {
|
||||
DEVICE_DEBUGOUT("em_attach failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
|
||||
err:
|
||||
free(device);
|
||||
atomic_and(&gOpenMask, ~(1 << dev_id));
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ipro1000_close(void* cookie)
|
||||
{
|
||||
ipro1000_device *device = (ipro1000_device *)cookie;
|
||||
struct ifnet *ifp = &device->adapter->interface_data.ac_if;
|
||||
DEVICE_DEBUGOUT("ipro1000_close()");
|
||||
|
||||
device->closed = true;
|
||||
release_sem(ifp->if_rcv_sem);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ipro1000_free(void* cookie)
|
||||
{
|
||||
ipro1000_device *device = (ipro1000_device *)cookie;
|
||||
DEVICE_DEBUGOUT("ipro1000_free()");
|
||||
|
||||
if (em_detach(device) != 0) {
|
||||
DEVICE_DEBUGOUT("em_detach failed");
|
||||
}
|
||||
|
||||
free(device);
|
||||
atomic_and(&gOpenMask, ~(1 << device->devId));
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ipro1000_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
|
||||
{
|
||||
ipro1000_device *device = (ipro1000_device *)cookie;
|
||||
struct ifnet *ifp = &device->adapter->interface_data.ac_if;
|
||||
struct mbuf *mb;
|
||||
status_t stat;
|
||||
int len;
|
||||
|
||||
// DEVICE_DEBUGOUT("ipro1000_read() enter");
|
||||
|
||||
if (device->closed) {
|
||||
DEVICE_DEBUGOUT("ipro1000_read() interrupted 1");
|
||||
return B_INTERRUPTED;
|
||||
}
|
||||
retry:
|
||||
stat = acquire_sem_etc(ifp->if_rcv_sem, 1, B_CAN_INTERRUPT | (device->nonblocking ? B_TIMEOUT : 0), 0);
|
||||
if (device->closed) {
|
||||
// DEVICE_DEBUGOUT("ipro1000_read() interrupted 2"); // net_server will crash if we print this (race condition in net_server?)
|
||||
return B_INTERRUPTED;
|
||||
}
|
||||
if (stat == B_WOULD_BLOCK) {
|
||||
DEVICE_DEBUGOUT("ipro1000_read() would block (OK 0 bytes)");
|
||||
*num_bytes = 0;
|
||||
return B_OK;
|
||||
}
|
||||
if (stat != B_OK) {
|
||||
DEVICE_DEBUGOUT("ipro1000_read() error");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
IF_DEQUEUE(&ifp->if_rcv, mb);
|
||||
if (!mb) {
|
||||
ERROROUT("ipro1000_read() mbuf not ready");
|
||||
goto retry;
|
||||
}
|
||||
|
||||
len = mb->m_len;
|
||||
if (len < 0)
|
||||
len = 0;
|
||||
if (len > (int)*num_bytes)
|
||||
len = *num_bytes;
|
||||
|
||||
memcpy(buf, mtod(mb, uint8 *), len); // XXX this is broken for jumbo frames
|
||||
*num_bytes = len;
|
||||
|
||||
m_freem(mb);
|
||||
|
||||
// DEVICE_DEBUGOUT1("ipro1000_read() leave, %d bytes", len);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ipro1000_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
||||
{
|
||||
// bigtime_t t = system_time();
|
||||
ipro1000_device *device = (ipro1000_device *)cookie;
|
||||
struct ifnet *ifp = &device->adapter->interface_data.ac_if;
|
||||
struct mbuf *mb;
|
||||
|
||||
// DEVICE_DEBUGOUT("ipro1000_write() enter");
|
||||
|
||||
// allocate mbuf
|
||||
for (;;) {
|
||||
MGETHDR(mb, M_DONTWAIT, MT_DATA);
|
||||
if (mb)
|
||||
break;
|
||||
snooze(700);
|
||||
if (device->closed)
|
||||
return B_INTERRUPTED;
|
||||
}
|
||||
|
||||
// DEVICE_DEBUGOUT("ipro1000_write() 1");
|
||||
|
||||
// allocate memory
|
||||
for (;;) {
|
||||
MCLGET(mb, M_DONTWAIT);
|
||||
if (mb->m_flags & M_EXT)
|
||||
break;
|
||||
snooze(700);
|
||||
if (device->closed) {
|
||||
m_freem(mb);
|
||||
return B_INTERRUPTED;
|
||||
}
|
||||
}
|
||||
|
||||
// DEVICE_DEBUGOUT("ipro1000_write() 2");
|
||||
|
||||
// copy data
|
||||
mb->m_len = *num_bytes;
|
||||
if (mb->m_len > MCLBYTES)
|
||||
mb->m_len = MCLBYTES;
|
||||
memcpy(mtod(mb, uint8 *), buffer, mb->m_len);
|
||||
|
||||
// DEVICE_DEBUGOUT("ipro1000_write() 3");
|
||||
|
||||
// add mbuf to send queue
|
||||
IF_APPEND(&ifp->if_snd, mb);
|
||||
|
||||
// DEVICE_DEBUGOUT("ipro1000_write() 4");
|
||||
|
||||
// wait for output available
|
||||
while (ifp->if_flags & IFF_OACTIVE) {
|
||||
snooze(700);
|
||||
if (device->closed)
|
||||
return B_INTERRUPTED;
|
||||
}
|
||||
|
||||
// DEVICE_DEBUGOUT("ipro1000_write() 5");
|
||||
|
||||
// send everything (if still required)
|
||||
if (ifp->if_snd.ifq_head != NULL)
|
||||
ifp->if_start(ifp);
|
||||
|
||||
// while (ifp->if_snd.ifq_head != NULL) {
|
||||
// ifp->if_start(ifp);
|
||||
// if (ifp->if_snd.ifq_head != NULL) {
|
||||
// snooze(1000);
|
||||
// if (device->closed)
|
||||
// return B_INTERRUPTED;
|
||||
// }
|
||||
// }
|
||||
|
||||
// t = system_time() - t;
|
||||
|
||||
// if (t > 20)
|
||||
// DEVICE_DEBUGOUT("write %Ld", t);
|
||||
|
||||
// DEVICE_DEBUGOUT("ipro1000_write() finished");
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static struct ifnet *
|
||||
device_ifp(ipro1000_device *device)
|
||||
{
|
||||
return &device->adapter->interface_data.ac_if;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ipro1000_control(void *cookie, uint32 op, void *arg, size_t len)
|
||||
{
|
||||
ipro1000_device *device = (ipro1000_device *)cookie;
|
||||
|
||||
switch (op) {
|
||||
case ETHER_INIT:
|
||||
DEVICE_DEBUGOUT("ipro1000_control() ETHER_INIT");
|
||||
return B_OK;
|
||||
|
||||
case ETHER_GETADDR:
|
||||
DEVICE_DEBUGOUT("ipro1000_control() ETHER_GETADDR");
|
||||
memcpy(arg, &device->macaddr, sizeof(device->macaddr));
|
||||
return B_OK;
|
||||
|
||||
case ETHER_NONBLOCK:
|
||||
if (*(int32 *)arg) {
|
||||
DEVICE_DEBUGOUT("non blocking mode on");
|
||||
device->nonblocking = true;
|
||||
} else {
|
||||
DEVICE_DEBUGOUT("non blocking mode off");
|
||||
device->nonblocking = false;
|
||||
}
|
||||
return B_OK;
|
||||
|
||||
case ETHER_ADDMULTI:
|
||||
case ETHER_REMMULTI:
|
||||
{
|
||||
struct ifnet *ifp = device_ifp(device);
|
||||
struct sockaddr_dl address;
|
||||
|
||||
if (len != ETHER_ADDR_LEN)
|
||||
return EINVAL;
|
||||
|
||||
memset(&address, 0, sizeof(address));
|
||||
address.sdl_family = AF_LINK;
|
||||
memcpy(LLADDR(&address), arg, ETHER_ADDR_LEN);
|
||||
|
||||
if (op == ETHER_ADDMULTI)
|
||||
return ether_add_multi(ifp, (struct sockaddr *)&address);
|
||||
else
|
||||
return ether_rem_multi(ifp, (struct sockaddr *)&address);
|
||||
}
|
||||
|
||||
case ETHER_SETPROMISC:
|
||||
if (*(int32 *)arg) {
|
||||
DEVICE_DEBUGOUT("promiscuous mode on not supported");
|
||||
} else {
|
||||
DEVICE_DEBUGOUT("promiscuous mode off");
|
||||
}
|
||||
return B_OK;
|
||||
|
||||
case ETHER_GETFRAMESIZE:
|
||||
DEVICE_DEBUGOUT2("ipro1000_control() ETHER_GETFRAMESIZE, framesize = %d (MTU = %d)", device->maxframesize, device->maxframesize - ENET_HEADER_SIZE);
|
||||
*(uint32*)arg = device->maxframesize;
|
||||
return B_OK;
|
||||
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
case ETHER_GET_LINK_STATE:
|
||||
{
|
||||
struct ifmediareq mediareq;
|
||||
ether_link_state_t state;
|
||||
|
||||
if (len < sizeof(ether_link_state_t))
|
||||
return ENOBUFS;
|
||||
|
||||
em_media_status(device_ifp(device), &mediareq);
|
||||
|
||||
state.media = mediareq.ifm_active;
|
||||
if (mediareq.ifm_status & IFM_ACTIVE)
|
||||
state.media |= IFM_ACTIVE;
|
||||
if (mediareq.ifm_active & IFM_10_T)
|
||||
state.speed = 10000000;
|
||||
else if (mediareq.ifm_active & IFM_100_TX)
|
||||
state.speed = 100000000;
|
||||
else
|
||||
state.speed = 1000000000;
|
||||
state.quality = 1000;
|
||||
|
||||
return user_memcpy(arg, &state, sizeof(ether_link_state_t));
|
||||
}
|
||||
|
||||
case ETHER_SET_LINK_STATE_SEM:
|
||||
{
|
||||
if (user_memcpy(&device->linkChangeSem, arg, sizeof(sem_id)) < B_OK) {
|
||||
device->linkChangeSem = -1;
|
||||
return B_BAD_ADDRESS;
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
DEVICE_DEBUGOUT("ipro1000_control() Invalid command");
|
||||
break;
|
||||
}
|
||||
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef __DEVICE_H
|
||||
#define __DEVICE_H
|
||||
|
||||
#include <PCI.h>
|
||||
#include "setup.h"
|
||||
|
||||
extern pci_module_info *gPci;
|
||||
|
||||
status_t ipro1000_open(const char *name, uint32 flags, void** cookie);
|
||||
status_t ipro1000_read(void* cookie, off_t position, void *buf, size_t* num_bytes);
|
||||
status_t ipro1000_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes);
|
||||
status_t ipro1000_control(void *cookie, uint32 op, void *arg, size_t len);
|
||||
status_t ipro1000_close(void* cookie);
|
||||
status_t ipro1000_free(void* cookie);
|
||||
|
||||
struct adapter;
|
||||
|
||||
typedef struct device {
|
||||
int devId;
|
||||
pci_info * pciInfo;
|
||||
|
||||
struct adapter * adapter;
|
||||
uint8 pciBus;
|
||||
uint8 pciDev;
|
||||
uint8 pciFunc;
|
||||
void * regAddr;
|
||||
|
||||
volatile bool nonblocking;
|
||||
volatile bool closed;
|
||||
|
||||
uint32 maxframesize; // 14 bytes header + MTU
|
||||
uint8 macaddr[6];
|
||||
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
sem_id linkChangeSem;
|
||||
#endif
|
||||
} ipro1000_device;
|
||||
|
||||
#endif
|
||||
@@ -1,219 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include <KernelExport.h>
|
||||
#include <Errors.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "timer.h"
|
||||
#include "device.h"
|
||||
#include "driver.h"
|
||||
#include "mempool.h"
|
||||
|
||||
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
||||
|
||||
pci_module_info *gPci;
|
||||
|
||||
char* gDevNameList[MAX_CARDS + 1];
|
||||
pci_info *gDevList[MAX_CARDS];
|
||||
|
||||
static const char *
|
||||
identify_device(const pci_info *info)
|
||||
{
|
||||
if (info->vendor_id != 0x8086)
|
||||
return 0;
|
||||
switch (info->device_id) {
|
||||
case 0x1000: return "82542";
|
||||
case 0x1001: return "82543GC FIBER";
|
||||
case 0x1004: return "82543GC COPPER";
|
||||
case 0x1008: return "82544EI COPPER";
|
||||
case 0x1009: return "82544EI FIBER";
|
||||
case 0x100C: return "82544GC COPPER";
|
||||
case 0x100D: return "82544GC LOM";
|
||||
case 0x100E: return "82540EM";
|
||||
case 0x100F: return "82545EM COPPER";
|
||||
case 0x1010: return "82546EB COPPER";
|
||||
case 0x1011: return "82545EM FIBER";
|
||||
case 0x1012: return "82546EB FIBER";
|
||||
case 0x1013: return "82541EI";
|
||||
case 0x1014: return "unknown 1014";
|
||||
case 0x1015: return "82540EM LOM";
|
||||
case 0x1016: return "82540EP LOM";
|
||||
case 0x1017: return "82540EP";
|
||||
case 0x1018: return "82541EI MOBILE";
|
||||
case 0x1019: return "82547EI";
|
||||
case 0x101A: return "unknown 101A";
|
||||
case 0x101D: return "82546EB QUAD COPPER";
|
||||
case 0x101E: return "82540EP LP";
|
||||
case 0x1026: return "82545GM COPPER";
|
||||
case 0x1027: return "82545GM FIBER";
|
||||
case 0x1028: return "82545GM SERDES";
|
||||
case 0x1075: return "82547GI";
|
||||
case 0x1076: return "82541GI";
|
||||
case 0x1077: return "82541GI MOBILE";
|
||||
case 0x1078: return "82541ER";
|
||||
case 0x1079: return "82546GB COPPER";
|
||||
case 0x107A: return "82546GB FIBER";
|
||||
case 0x107B: return "82546GB SERDES";
|
||||
case 0x107C: return "82541PI";
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
status_t
|
||||
init_hardware(void)
|
||||
{
|
||||
pci_module_info *pci;
|
||||
pci_info info;
|
||||
status_t res;
|
||||
int i;
|
||||
|
||||
INIT_DEBUGOUT("init_hardware()");
|
||||
|
||||
if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci) < B_OK)
|
||||
return B_ERROR;
|
||||
for (res = B_ERROR, i = 0; pci->get_nth_pci_info(i, &info) == B_OK; i++) {
|
||||
if (identify_device(&info)) {
|
||||
res = B_OK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
init_driver(void)
|
||||
{
|
||||
struct pci_info *item;
|
||||
int index;
|
||||
int cards;
|
||||
|
||||
#ifdef DEBUG
|
||||
set_dprintf_enabled(true);
|
||||
load_driver_symbols("ipro1000");
|
||||
#endif
|
||||
|
||||
dprintf("ipro1000: " INFO "\n");
|
||||
|
||||
item = (pci_info *)malloc(sizeof(pci_info));
|
||||
if (!item)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK) {
|
||||
free(item);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
for (cards = 0, index = 0; gPci->get_nth_pci_info(index++, item) == B_OK; ) {
|
||||
const char *info = identify_device(item);
|
||||
if (info) {
|
||||
char name[64];
|
||||
sprintf(name, "net/ipro1000/%d", cards);
|
||||
dprintf("ipro1000: /dev/%s is a %s\n", name, info);
|
||||
gDevList[cards] = item;
|
||||
gDevNameList[cards] = strdup(name);
|
||||
gDevNameList[cards + 1] = NULL;
|
||||
cards++;
|
||||
item = (pci_info *)malloc(sizeof(pci_info));
|
||||
if (!item)
|
||||
goto err_outofmem;
|
||||
if (cards == MAX_CARDS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(item);
|
||||
|
||||
if (!cards)
|
||||
goto err_cards;
|
||||
|
||||
if (initialize_timer() != B_OK) {
|
||||
ERROROUT("timer init failed");
|
||||
goto err_timer;
|
||||
}
|
||||
|
||||
if (mempool_init(cards * 768) != B_OK) {
|
||||
ERROROUT("mempool init failed");
|
||||
goto err_mempool;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
|
||||
err_mempool:
|
||||
terminate_timer();
|
||||
err_timer:
|
||||
err_cards:
|
||||
err_outofmem:
|
||||
for (index = 0; index < cards; index++) {
|
||||
free(gDevList[index]);
|
||||
free(gDevNameList[index]);
|
||||
}
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
uninit_driver(void)
|
||||
{
|
||||
int32 i;
|
||||
|
||||
INIT_DEBUGOUT("uninit_driver()");
|
||||
|
||||
terminate_timer();
|
||||
|
||||
mempool_exit();
|
||||
|
||||
for (i = 0; gDevNameList[i] != NULL; i++) {
|
||||
free(gDevList[i]);
|
||||
free(gDevNameList[i]);
|
||||
}
|
||||
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
}
|
||||
|
||||
|
||||
device_hooks
|
||||
gDeviceHooks = {
|
||||
ipro1000_open,
|
||||
ipro1000_close,
|
||||
ipro1000_free,
|
||||
ipro1000_control,
|
||||
ipro1000_read,
|
||||
ipro1000_write,
|
||||
};
|
||||
|
||||
|
||||
const char**
|
||||
publish_devices()
|
||||
{
|
||||
return (const char**)gDevNameList;
|
||||
}
|
||||
|
||||
|
||||
device_hooks*
|
||||
find_device(const char* name)
|
||||
{
|
||||
return &gDeviceHooks;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef __DRIVER_H
|
||||
#define __DRIVER_H
|
||||
|
||||
#include <Drivers.h>
|
||||
#include <PCI.h>
|
||||
#include "ether_driver.h"
|
||||
|
||||
#define MAX_CARDS 8
|
||||
|
||||
extern pci_module_info *gPci;
|
||||
|
||||
extern char* gDevNameList[];
|
||||
extern pci_info *gDevList[];
|
||||
|
||||
#endif
|
||||
@@ -1,260 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "if_compat.h"
|
||||
#include "if_em.h"
|
||||
#include "device.h"
|
||||
#include "debug.h"
|
||||
#include "mempool.h"
|
||||
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
spinlock mbuf_lock = 0;
|
||||
|
||||
struct mbuf *
|
||||
m_gethdr(int how, int type)
|
||||
{
|
||||
struct mbuf *m = mbuf_pool_get();
|
||||
if (!m)
|
||||
return m;
|
||||
memset(m, 0, sizeof(m));
|
||||
m->m_flags = M_PKTHDR;
|
||||
return m;
|
||||
}
|
||||
|
||||
void
|
||||
m_clget(struct mbuf * m, int how)
|
||||
{
|
||||
// TRACE("m_clget\n");
|
||||
|
||||
m->m_ext.ext_buf = chunk_pool_get();
|
||||
m->m_data = m->m_ext.ext_buf;
|
||||
if (m->m_ext.ext_buf)
|
||||
m->m_flags |= M_EXT;
|
||||
}
|
||||
|
||||
void
|
||||
m_adj(struct mbuf *mp, int bytes)
|
||||
{
|
||||
mp->m_data = (char *)mp->m_data + bytes;
|
||||
}
|
||||
|
||||
void
|
||||
m_freem(struct mbuf *mp)
|
||||
{
|
||||
struct mbuf *m, *c;
|
||||
// TRACE("m_freem\n");
|
||||
|
||||
for (m = mp; m; ) {
|
||||
if (m->m_flags & M_EXT)
|
||||
chunk_pool_put(m->m_ext.ext_buf);
|
||||
c = m;
|
||||
m = m->m_next;
|
||||
mbuf_pool_put(c);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ether_input(struct ifnet *ifp, struct mbuf *m)
|
||||
{
|
||||
/*
|
||||
uint8 *buf;
|
||||
int len;
|
||||
|
||||
buf = mtod(m, uint8 *);
|
||||
len = m->m_len;
|
||||
TRACE("ether_input: received packet with %d bytes\n", len);
|
||||
TRACE("%02x %02x %02x %02x . %02x %02x %02x %02x . %02x %02x %02x %02x \n",
|
||||
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
|
||||
buf[6], buf[7], buf[8], buf[8], buf[10], buf[11]);
|
||||
|
||||
m_freem(m);
|
||||
return;
|
||||
*/
|
||||
|
||||
IF_APPEND(&ifp->if_rcv, m);
|
||||
release_sem_etc(ifp->if_rcv_sem, 1, B_DO_NOT_RESCHEDULE);
|
||||
}
|
||||
|
||||
void
|
||||
ether_ifattach(struct ifnet *ifp, const uint8 *etheraddr)
|
||||
{
|
||||
ipro1000_device *dev = ifp->if_softc->dev;
|
||||
|
||||
INIT_DEBUGOUT("ether_ifattach");
|
||||
|
||||
TAILQ_INIT(&ifp->if_multiaddrs);
|
||||
|
||||
memcpy(dev->macaddr, etheraddr, 6);
|
||||
|
||||
ifp->if_input = ether_input;
|
||||
|
||||
ifp->if_rcv_sem = create_sem(0, "ifp->if_rcv_sem");
|
||||
set_sem_owner(ifp->if_rcv_sem, B_SYSTEM_TEAM);
|
||||
|
||||
INIT_DEBUGOUT("calling if_init...");
|
||||
ifp->if_init(ifp->if_softc);
|
||||
INIT_DEBUGOUT("done calling if_init!");
|
||||
}
|
||||
|
||||
|
||||
static struct ifmultiaddr *
|
||||
ether_find_multi(struct ifnet *ifp, const struct sockaddr *_address)
|
||||
{
|
||||
const struct sockaddr_dl *address = (const struct sockaddr_dl *)_address;
|
||||
struct ifmultiaddr *ifma;
|
||||
|
||||
TAILQ_FOREACH (ifma, &ifp->if_multiaddrs, ifma_link) {
|
||||
if (memcmp(LLADDR(address),
|
||||
LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
|
||||
ETHER_ADDR_LEN) == 0)
|
||||
return ifma;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ether_add_multi(struct ifnet *ifp, const struct sockaddr *address)
|
||||
{
|
||||
struct ifmultiaddr *addr = ether_find_multi(ifp, address);
|
||||
|
||||
if (addr != NULL) {
|
||||
addr->ifma_refcount++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
addr = (struct ifmultiaddr *)malloc(sizeof(struct ifmultiaddr));
|
||||
if (addr == NULL)
|
||||
return ENOBUFS;
|
||||
|
||||
memcpy(&addr->ifma_addr_storage, address, sizeof(struct sockaddr_dl));
|
||||
addr->ifma_addr = (struct sockaddr *)&addr->ifma_addr_storage;
|
||||
|
||||
addr->ifma_refcount = 1;
|
||||
|
||||
TAILQ_INSERT_HEAD(&ifp->if_multiaddrs, addr, ifma_link);
|
||||
|
||||
return ifp->if_ioctl(ifp, SIOCADDMULTI, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ether_delete_multi(struct ifnet *ifp, struct ifmultiaddr *ifma)
|
||||
{
|
||||
TAILQ_REMOVE(&ifp->if_multiaddrs, ifma, ifma_link);
|
||||
free(ifma);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ether_rem_multi(struct ifnet *ifp, const struct sockaddr *address)
|
||||
{
|
||||
struct ifmultiaddr *addr = ether_find_multi(ifp, address);
|
||||
if (addr == NULL)
|
||||
return EADDRNOTAVAIL;
|
||||
|
||||
addr->ifma_refcount--;
|
||||
if (addr->ifma_refcount == 0) {
|
||||
ether_delete_multi(ifp, addr);
|
||||
return ifp->if_ioctl(ifp, SIOCDELMULTI, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ether_ifdetach(struct ifnet *ifp)
|
||||
{
|
||||
struct ifmultiaddr *ifma, *next;
|
||||
|
||||
INIT_DEBUGOUT("ether_ifdetach");
|
||||
|
||||
delete_sem(ifp->if_rcv_sem);
|
||||
|
||||
TAILQ_FOREACH_SAFE(ifma, &ifp->if_multiaddrs, ifma_link, next)
|
||||
ether_delete_multi(ifp, ifma);
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
if_dequeue(struct if_queue *queue)
|
||||
{
|
||||
cpu_status s;
|
||||
struct mbuf *m;
|
||||
|
||||
// TRACE("IF_DEQUEUE\n");
|
||||
|
||||
s = disable_interrupts();
|
||||
acquire_spinlock(&mbuf_lock);
|
||||
|
||||
m = (struct mbuf *) queue->ifq_head;
|
||||
if (m) {
|
||||
queue->ifq_head = m->m_nextq;
|
||||
if (!queue->ifq_head)
|
||||
queue->ifq_tail = 0;
|
||||
m->m_nextq = 0;
|
||||
}
|
||||
|
||||
release_spinlock(&mbuf_lock);
|
||||
restore_interrupts(s);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
void
|
||||
if_prepend(struct if_queue *queue, struct mbuf *mb)
|
||||
{
|
||||
cpu_status s;
|
||||
// TRACE("IF_PREPEND\n");
|
||||
|
||||
s = disable_interrupts();
|
||||
acquire_spinlock(&mbuf_lock);
|
||||
|
||||
mb->m_nextq = (struct mbuf *) queue->ifq_head;
|
||||
queue->ifq_head = mb;
|
||||
if (!queue->ifq_tail)
|
||||
queue->ifq_tail = mb;
|
||||
|
||||
release_spinlock(&mbuf_lock);
|
||||
restore_interrupts(s);
|
||||
}
|
||||
|
||||
void
|
||||
if_append(struct if_queue *queue, struct mbuf *mb)
|
||||
{
|
||||
cpu_status s;
|
||||
// TRACE("IF_APPEND\n");
|
||||
|
||||
s = disable_interrupts();
|
||||
acquire_spinlock(&mbuf_lock);
|
||||
|
||||
mb->m_nextq = 0;
|
||||
if (!queue->ifq_tail) {
|
||||
queue->ifq_tail = mb;
|
||||
queue->ifq_head = mb;
|
||||
} else {
|
||||
queue->ifq_tail->m_nextq = mb;
|
||||
queue->ifq_tail = mb;
|
||||
}
|
||||
|
||||
release_spinlock(&mbuf_lock);
|
||||
restore_interrupts(s);
|
||||
}
|
||||
@@ -1,303 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef __IF_COMPAT_H
|
||||
#define __IF_COMPAT_H
|
||||
|
||||
#include <OS.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include "if_em_osdep.h" // for TAILQ_...
|
||||
|
||||
#define __FreeBSD_version 500001
|
||||
|
||||
#define IFF_RUNNING 0x10000
|
||||
#define IFF_OACTIVE 0x20000
|
||||
|
||||
#define IFCAP_HWCSUM 0x0001
|
||||
#define IFCAP_VLAN_HWTAGGING 0x0002
|
||||
#define IFCAP_VLAN_MTU 0x0004
|
||||
#define IFCAP_TXCSUM 0x0010
|
||||
#define IFCAP_RXCSUM 0x0020
|
||||
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
# define IFM_AVALID 0
|
||||
# define IFM_FDX IFM_FULL_DUPLEX
|
||||
# define IFM_HDX IFM_HALF_DUPLEX
|
||||
# define IFM_1000_TX IFM_1000_T
|
||||
#else
|
||||
# define IFM_ACTIVE 0x0001
|
||||
# define IFM_FDX 0x0002
|
||||
# define IFM_HDX 0x0004
|
||||
# define IFM_10_T 0x0008
|
||||
# define IFM_100_TX 0x0010
|
||||
# define IFM_1000_T 0x0020
|
||||
# define IFM_1000_TX 0x0040
|
||||
# define IFM_1000_SX 0x0080
|
||||
# define IFM_ETHER 0x0100
|
||||
# define IFM_AUTO 0x0200
|
||||
# define IFM_AVALID 0x0400
|
||||
# define IFM_GMASK (IFM_FDX | IFM_HDX)
|
||||
# define IFM_TYPE_MASK (IFM_ETHER)
|
||||
# define IFM_SUBTYPE_MASK \
|
||||
(IFM_AUTO | IFM_1000_SX | IFM_1000_TX | IFM_1000_T | IFM_100_TX | IFM_10_T)
|
||||
# define IFM_TYPE(media) ((media) & IFM_TYPE_MASK)
|
||||
# define IFM_SUBTYPE(media) ((media) & IFM_SUBTYPE_MASK)
|
||||
#endif
|
||||
|
||||
#define CSUM_TCP 0x0001 // ifnet::if_hwassist
|
||||
#define CSUM_UDP 0x0002 // ifnet::if_hwassist
|
||||
#define CSUM_IP_CHECKED 0x0004
|
||||
#define CSUM_IP_VALID 0x0008
|
||||
#define CSUM_DATA_VALID 0x0010
|
||||
#define CSUM_PSEUDO_HDR 0x0020
|
||||
|
||||
#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
|
||||
#define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */
|
||||
#define ETHER_CRC_LEN 4 /* length of the Ethernet CRC */
|
||||
#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
|
||||
#define ETHER_MIN_LEN 64 /* minimum frame len, including CRC */
|
||||
#define ETHER_MAX_LEN 1518 /* maximum frame len, including CRC */
|
||||
#define ETHER_MAX_LEN_JUMBO 9018 /* max jumbo frame len, including CRC */
|
||||
#define ETHER_VLAN_ENCAP_LEN 4 /* len of 802.1Q VLAN encapsulation */
|
||||
#define ETHERMTU ETHER_MAX_LEN_JUMBO
|
||||
#define IP_HEADER_SIZE 20
|
||||
#define OFFSETOF_IPHDR_SUM 10
|
||||
#define OFFSETOF_TCPHDR_SUM 16
|
||||
#define OFFSETOF_UDPHDR_SUM 6
|
||||
|
||||
|
||||
// vlan stuff is not supported
|
||||
#define ETHERTYPE_VLAN 0x8100
|
||||
#define VLAN_INPUT_TAG(a, b, c, d)
|
||||
#define VLAN_TAG_VALUE(mtag) 0
|
||||
#define VLAN_OUTPUT_TAG(ifp, m_head) 0
|
||||
|
||||
|
||||
// BPF listener not supported
|
||||
#define BPF_MTAP(a, b)
|
||||
|
||||
|
||||
// sysctl stuff is not supported
|
||||
#define sysctl_ctx_init(a)
|
||||
#define sysctl_ctx_free(a)
|
||||
#define SYSCTL_HANDLER_ARGS void
|
||||
#define SYSCTL_ADD_NODE(a, b, c, d, e, f, g) \
|
||||
(struct sysctl_oid *) 1
|
||||
#define SYSCTL_ADD_PROC(a, b, c, d, e, f, g, h, i, j)
|
||||
|
||||
struct sysctl_ctx_list
|
||||
{
|
||||
};
|
||||
|
||||
struct sysctl_oid
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
struct adapter;
|
||||
struct ifnet;
|
||||
struct mbuf;
|
||||
|
||||
|
||||
struct ifmedia
|
||||
{
|
||||
uint32 ifm_media;
|
||||
};
|
||||
|
||||
struct if_queue
|
||||
{
|
||||
volatile struct mbuf * ifq_head;
|
||||
volatile struct mbuf * ifq_tail;
|
||||
int ifq_maxlen; // ignored
|
||||
};
|
||||
|
||||
typedef void (*if_start)(struct ifnet *);
|
||||
typedef int (*if_ioctl)(struct ifnet *, u_long, caddr_t);
|
||||
typedef void (*if_watchdog)(struct ifnet *);
|
||||
typedef void (*if_init)(void *);
|
||||
typedef void (*if_input)(struct ifnet *, struct mbuf *);
|
||||
|
||||
struct m_pkthdr
|
||||
{
|
||||
int len;
|
||||
int csum_flags;
|
||||
uint16 csum_data;
|
||||
struct ifnet * rcvif; // set by receive int
|
||||
};
|
||||
|
||||
struct m_ext
|
||||
{
|
||||
void *ext_buf;
|
||||
};
|
||||
|
||||
struct mbuf
|
||||
{
|
||||
struct mbuf * m_next; // next buffer in chain (e.g. for jumboframes)
|
||||
struct mbuf * m_nextq; // next buffer in queue
|
||||
int m_len;
|
||||
int m_flags;
|
||||
void * m_data;
|
||||
struct m_pkthdr m_pkthdr;
|
||||
struct m_ext m_ext;
|
||||
};
|
||||
|
||||
#define M_DONTWAIT 0x01
|
||||
#define M_EXT 0x02
|
||||
#define M_PKTHDR 0x04
|
||||
#define MT_DATA 1
|
||||
#define MCLBYTES 2048
|
||||
|
||||
struct mbuf *m_gethdr(int how, int type);
|
||||
|
||||
// Allocate and return a single M_PKTHDR mbuf. NULL is returned on failure.
|
||||
#define MGETHDR(mb, how, type) ((mb) = m_gethdr((how), (type)))
|
||||
|
||||
void m_clget(struct mbuf * mb, int how);
|
||||
|
||||
// Fetch a single mbuf cluster and attach it to an existing mbuf. If
|
||||
// successfull, configures the provided mbuf to have mbuf->m_ext.ext_buf
|
||||
// pointing to the cluster, and sets the M_EXT bit in the mbuf's flags.
|
||||
// The M_EXT bit is not set on failure
|
||||
#define MCLGET(mb, how) m_clget((mb), (how))
|
||||
|
||||
struct mbuf *if_dequeue(struct if_queue *queue);
|
||||
|
||||
void if_prepend(struct if_queue *queue, struct mbuf *mb);
|
||||
void if_append(struct if_queue *queue, struct mbuf *mb);
|
||||
|
||||
#define IF_DEQUEUE(queue, mb) ((mb) = if_dequeue((queue)))
|
||||
#define IF_PREPEND(queue, mb) if_prepend((queue), (mb))
|
||||
#define IF_APPEND(queue, mb) if_append((queue), (mb))
|
||||
|
||||
void m_adj(struct mbuf *mp, int bytes);
|
||||
void m_freem(struct mbuf *mp);
|
||||
|
||||
#define mtod(m, t) ((t)((m)->m_data))
|
||||
|
||||
void ether_ifattach(struct ifnet *ifp, const uint8 *etheraddr);
|
||||
void ether_ifdetach(struct ifnet *ifp);
|
||||
|
||||
int ether_add_multi(struct ifnet *ifp, const struct sockaddr *address);
|
||||
int ether_rem_multi(struct ifnet *ifp, const struct sockaddr *address);
|
||||
|
||||
TAILQ_HEAD(ifmultihead, ifmultiaddr);
|
||||
|
||||
struct ifmultiaddr
|
||||
{
|
||||
TAILQ_ENTRY(ifmultiaddr) ifma_link;
|
||||
struct sockaddr *ifma_addr;
|
||||
int ifma_refcount;
|
||||
|
||||
/* private */
|
||||
struct sockaddr_dl ifma_addr_storage;
|
||||
};
|
||||
|
||||
struct if_data
|
||||
{
|
||||
int ifi_hdrlen;
|
||||
};
|
||||
|
||||
struct ether_vlan_header
|
||||
{
|
||||
uint8 evl_dhost[ETHER_ADDR_LEN];
|
||||
uint8 evl_shost[ETHER_ADDR_LEN];
|
||||
uint16 evl_encap_proto;
|
||||
uint16 evl_tag;
|
||||
uint16 evl_proto;
|
||||
};
|
||||
|
||||
struct ifnet
|
||||
{
|
||||
const char *if_name;
|
||||
|
||||
struct adapter *if_softc;
|
||||
|
||||
int if_unit;
|
||||
int if_mtu;
|
||||
volatile uint32 if_flags;
|
||||
uint32 if_capabilities;
|
||||
uint32 if_hwassist;
|
||||
uint32 if_capenable;
|
||||
uint64 if_baudrate;
|
||||
int64 if_timer;
|
||||
|
||||
uint64 if_ibytes;
|
||||
uint64 if_obytes;
|
||||
uint64 if_imcasts;
|
||||
uint64 if_collisions;
|
||||
uint64 if_ierrors;
|
||||
uint64 if_oerrors;
|
||||
uint64 if_ipackets;
|
||||
uint64 if_opackets;
|
||||
|
||||
struct if_queue if_snd; // send queue
|
||||
struct if_queue if_rcv; // recveive queue
|
||||
|
||||
sem_id if_rcv_sem;
|
||||
|
||||
struct if_data if_data;
|
||||
struct ifmultihead if_multiaddrs;
|
||||
|
||||
if_start if_start;
|
||||
if_ioctl if_ioctl;
|
||||
if_watchdog if_watchdog;
|
||||
if_init if_init;
|
||||
if_input if_input;
|
||||
|
||||
|
||||
void *if_output; // unused
|
||||
#define ether_output 0
|
||||
};
|
||||
|
||||
struct arpcom
|
||||
{
|
||||
struct ifnet ac_if;
|
||||
uint8 ac_enaddr[ETHER_ADDR_LEN];
|
||||
};
|
||||
|
||||
#define device_get_softc(dev) \
|
||||
(dev->adapter ? dev->adapter : (dev->adapter = (struct adapter *)malloc(sizeof(struct adapter), 0, 0)))
|
||||
|
||||
#define device_get_unit(dev) \
|
||||
dev->devId
|
||||
|
||||
enum { // ioctl commands
|
||||
SIOCSIFADDR = 0x7000,
|
||||
SIOCGIFADDR,
|
||||
SIOCSIFMTU,
|
||||
SIOCSIFFLAGS,
|
||||
SIOCADDMULTI,
|
||||
SIOCDELMULTI,
|
||||
SIOCSIFMEDIA,
|
||||
SIOCGIFMEDIA,
|
||||
SIOCSIFCAP,
|
||||
};
|
||||
|
||||
// used for media properties
|
||||
#define ifmedia_init(a, b, c, d)
|
||||
#define ifmedia_add(a, b, c, d)
|
||||
#define ifmedia_set(a, b)
|
||||
#define ifmedia_ioctl(ifp, ifr, media, command) 0
|
||||
|
||||
// called for SIOCxIFADDR (Get/Set Interface Addr)
|
||||
#define ether_ioctl(ifp, command, data)
|
||||
|
||||
#endif // __IF_COMPAT_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,340 +0,0 @@
|
||||
/**************************************************************************
|
||||
|
||||
Copyright (c) 2001-2003, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/*$FreeBSD: /repoman/r/ncvs/src/sys/dev/em/if_em.h,v 1.1.2.16 2003/11/18 17:25:52 pdeuskar Exp $*/
|
||||
|
||||
#ifndef _EM_H_DEFINED_
|
||||
#define _EM_H_DEFINED_
|
||||
|
||||
#include "if_em_osdep.h"
|
||||
#include "if_em_hw.h"
|
||||
#include "if_compat.h"
|
||||
|
||||
/* Tunables */
|
||||
|
||||
/*
|
||||
* EM_MAX_TXD: Maximum number of Transmit Descriptors
|
||||
* Valid Range: 80-256 for 82542 and 82543-based adapters
|
||||
* 80-4096 for others
|
||||
* Default Value: 256
|
||||
* This value is the number of transmit descriptors allocated by the driver.
|
||||
* Increasing this value allows the driver to queue more transmits. Each
|
||||
* descriptor is 16 bytes.
|
||||
*/
|
||||
#define EM_MAX_TXD 256
|
||||
|
||||
/*
|
||||
* EM_MAX_RXD - Maximum number of receive Descriptors
|
||||
* Valid Range: 80-256 for 82542 and 82543-based adapters
|
||||
* 80-4096 for others
|
||||
* Default Value: 256
|
||||
* This value is the number of receive descriptors allocated by the driver.
|
||||
* Increasing this value allows the driver to buffer more incoming packets.
|
||||
* Each descriptor is 16 bytes. A receive buffer is also allocated for each
|
||||
* descriptor. The maximum MTU size is 16110.
|
||||
*
|
||||
*/
|
||||
#define EM_MAX_RXD 256
|
||||
|
||||
/*
|
||||
* EM_TIDV - Transmit Interrupt Delay Value
|
||||
* Valid Range: 0-65535 (0=off)
|
||||
* Default Value: 64
|
||||
* This value delays the generation of transmit interrupts in units of
|
||||
* 1.024 microseconds. Transmit interrupt reduction can improve CPU
|
||||
* efficiency if properly tuned for specific network traffic. If the
|
||||
* system is reporting dropped transmits, this value may be set too high
|
||||
* causing the driver to run out of available transmit descriptors.
|
||||
*/
|
||||
#define EM_TIDV 64
|
||||
|
||||
/*
|
||||
* EM_TADV - Transmit Absolute Interrupt Delay Value (Not valid for 82542/82543/82544)
|
||||
* Valid Range: 0-65535 (0=off)
|
||||
* Default Value: 64
|
||||
* This value, in units of 1.024 microseconds, limits the delay in which a
|
||||
* transmit interrupt is generated. Useful only if EM_TIDV is non-zero,
|
||||
* this value ensures that an interrupt is generated after the initial
|
||||
* packet is sent on the wire within the set amount of time. Proper tuning,
|
||||
* along with EM_TIDV, may improve traffic throughput in specific
|
||||
* network conditions.
|
||||
*/
|
||||
#define EM_TADV 64
|
||||
|
||||
/*
|
||||
* EM_RDTR - Receive Interrupt Delay Timer (Packet Timer)
|
||||
* Valid Range: 0-65535 (0=off)
|
||||
* Default Value: 0
|
||||
* This value delays the generation of receive interrupts in units of 1.024
|
||||
* microseconds. Receive interrupt reduction can improve CPU efficiency if
|
||||
* properly tuned for specific network traffic. Increasing this value adds
|
||||
* extra latency to frame reception and can end up decreasing the throughput
|
||||
* of TCP traffic. If the system is reporting dropped receives, this value
|
||||
* may be set too high, causing the driver to run out of available receive
|
||||
* descriptors.
|
||||
*
|
||||
* CAUTION: When setting EM_RDTR to a value other than 0, adapters
|
||||
* may hang (stop transmitting) under certain network conditions.
|
||||
* If this occurs a WATCHDOG message is logged in the system event log.
|
||||
* In addition, the controller is automatically reset, restoring the
|
||||
* network connection. To eliminate the potential for the hang
|
||||
* ensure that EM_RDTR is set to 0.
|
||||
*/
|
||||
#define EM_RDTR 0
|
||||
|
||||
/*
|
||||
* Receive Interrupt Absolute Delay Timer (Not valid for 82542/82543/82544)
|
||||
* Valid Range: 0-65535 (0=off)
|
||||
* Default Value: 64
|
||||
* This value, in units of 1.024 microseconds, limits the delay in which a
|
||||
* receive interrupt is generated. Useful only if EM_RDTR is non-zero,
|
||||
* this value ensures that an interrupt is generated after the initial
|
||||
* packet is received within the set amount of time. Proper tuning,
|
||||
* along with EM_RDTR, may improve traffic throughput in specific network
|
||||
* conditions.
|
||||
*/
|
||||
#define EM_RADV 64
|
||||
|
||||
|
||||
/*
|
||||
* This parameter controls the maximum no of times the driver will loop
|
||||
* in the isr.
|
||||
* Minimum Value = 1
|
||||
*/
|
||||
#define EM_MAX_INTR 3
|
||||
|
||||
/*
|
||||
* Inform the stack about transmit checksum offload capabilities.
|
||||
*/
|
||||
#define EM_CHECKSUM_FEATURES (CSUM_TCP | CSUM_UDP)
|
||||
|
||||
/*
|
||||
* This parameter controls the duration of transmit watchdog timer.
|
||||
*/
|
||||
#define EM_TX_TIMEOUT 5 /* set to 5 seconds */
|
||||
|
||||
/*
|
||||
* This parameter controls when the driver calls the routine to reclaim
|
||||
* transmit descriptors.
|
||||
*/
|
||||
#define EM_TX_CLEANUP_THRESHOLD EM_MAX_TXD / 8
|
||||
|
||||
/*
|
||||
* This parameter controls whether or not autonegotation is enabled.
|
||||
* 0 - Disable autonegotiation
|
||||
* 1 - Enable autonegotiation
|
||||
*/
|
||||
#define DO_AUTO_NEG 1
|
||||
|
||||
/*
|
||||
* This parameter control whether or not the driver will wait for
|
||||
* autonegotiation to complete.
|
||||
* 1 - Wait for autonegotiation to complete
|
||||
* 0 - Don't wait for autonegotiation to complete
|
||||
*/
|
||||
#define WAIT_FOR_AUTO_NEG_DEFAULT 0
|
||||
|
||||
/*
|
||||
* EM_MASTER_SLAVE is only defined to enable a workaround for a known compatibility issue
|
||||
* with 82541/82547 devices and some switches. See the "Known Limitations" section of
|
||||
* the README file for a complete description and a list of affected switches.
|
||||
*
|
||||
* 0 = Hardware default
|
||||
* 1 = Master mode
|
||||
* 2 = Slave mode
|
||||
* 3 = Auto master/slave
|
||||
*/
|
||||
/* #define EM_MASTER_SLAVE 2 */
|
||||
|
||||
/* Tunables -- End */
|
||||
|
||||
#define AUTONEG_ADV_DEFAULT (ADVERTISE_10_HALF | ADVERTISE_10_FULL | \
|
||||
ADVERTISE_100_HALF | ADVERTISE_100_FULL | \
|
||||
ADVERTISE_1000_FULL)
|
||||
|
||||
#define EM_VENDOR_ID 0x8086
|
||||
#define EM_MMBA 0x0010 /* Mem base address */
|
||||
#define EM_ROUNDUP(size, unit) (((size) + (unit) - 1) & ~((unit) - 1))
|
||||
|
||||
#define EM_JUMBO_PBA 0x00000028
|
||||
#define EM_DEFAULT_PBA 0x00000030
|
||||
#define EM_SMARTSPEED_DOWNSHIFT 3
|
||||
#define EM_SMARTSPEED_MAX 15
|
||||
|
||||
|
||||
#define MAX_NUM_MULTICAST_ADDRESSES 128
|
||||
#define PCI_ANY_ID (~0U)
|
||||
#define ETHER_ALIGN 2
|
||||
|
||||
|
||||
/* Supported RX Buffer Sizes */
|
||||
#define EM_RXBUFFER_2048 2048
|
||||
#define EM_RXBUFFER_4096 4096
|
||||
#define EM_RXBUFFER_8192 8192
|
||||
#define EM_RXBUFFER_16384 16384
|
||||
|
||||
|
||||
struct em_buffer {
|
||||
struct mbuf *m_head;
|
||||
};
|
||||
|
||||
|
||||
typedef enum _XSUM_CONTEXT_T {
|
||||
OFFLOAD_NONE,
|
||||
OFFLOAD_TCP_IP,
|
||||
OFFLOAD_UDP_IP
|
||||
} XSUM_CONTEXT_T;
|
||||
|
||||
struct adapter;
|
||||
struct em_int_delay_info {
|
||||
struct adapter *adapter; /* Back-pointer to the adapter struct */
|
||||
int offset; /* Register offset to read/write */
|
||||
int value; /* Current value in usecs */
|
||||
};
|
||||
|
||||
/* For 82544 PCIX Workaround */
|
||||
typedef struct _ADDRESS_LENGTH_PAIR
|
||||
{
|
||||
u_int64_t address;
|
||||
u_int32_t length;
|
||||
} ADDRESS_LENGTH_PAIR, *PADDRESS_LENGTH_PAIR;
|
||||
|
||||
typedef struct _DESCRIPTOR_PAIR
|
||||
{
|
||||
ADDRESS_LENGTH_PAIR descriptor[4];
|
||||
u_int32_t elements;
|
||||
} DESC_ARRAY, *PDESC_ARRAY;
|
||||
|
||||
// used by interrupt and event handling thread
|
||||
enum {
|
||||
EVENT_LINK_CHANGED = 0x01,
|
||||
};
|
||||
|
||||
/* Our adapter structure */
|
||||
struct adapter {
|
||||
struct arpcom interface_data;
|
||||
struct em_hw hw;
|
||||
|
||||
/* FreeBSD operating-system-specific structures */
|
||||
struct em_osdep osdep;
|
||||
struct device *dev;
|
||||
struct resource *res_memory;
|
||||
struct resource *res_ioport;
|
||||
struct resource *res_interrupt;
|
||||
void *int_handler_tag;
|
||||
struct ifmedia media;
|
||||
struct callout_handle timer_handle;
|
||||
struct callout_handle tx_fifo_timer_handle;
|
||||
int io_rid;
|
||||
u_int8_t unit;
|
||||
|
||||
/* Event processing thread, to move link status change out of the interrupt */
|
||||
thread_id event_thread;
|
||||
sem_id event_sem;
|
||||
volatile int32 event_flags;
|
||||
|
||||
/* Info about the board itself */
|
||||
u_int32_t part_num;
|
||||
u_int8_t link_active;
|
||||
u_int16_t link_speed;
|
||||
u_int16_t link_duplex;
|
||||
u_int32_t smartspeed;
|
||||
struct em_int_delay_info tx_int_delay;
|
||||
struct em_int_delay_info tx_abs_int_delay;
|
||||
struct em_int_delay_info rx_int_delay;
|
||||
struct em_int_delay_info rx_abs_int_delay;
|
||||
|
||||
XSUM_CONTEXT_T active_checksum_context;
|
||||
|
||||
/*
|
||||
* Transmit definitions
|
||||
*
|
||||
* We have an array of num_tx_desc descriptors (handled
|
||||
* by the controller) paired with an array of tx_buffers
|
||||
* (at tx_buffer_area).
|
||||
* The index of the next available descriptor is next_avail_tx_desc.
|
||||
* The number of remaining tx_desc is num_tx_desc_avail.
|
||||
*/
|
||||
struct em_tx_desc *tx_desc_base;
|
||||
u_int32_t next_avail_tx_desc;
|
||||
u_int32_t oldest_used_tx_desc;
|
||||
volatile u_int16_t num_tx_desc_avail;
|
||||
u_int16_t num_tx_desc;
|
||||
u_int32_t txd_cmd;
|
||||
struct em_buffer *tx_buffer_area;
|
||||
|
||||
/*
|
||||
* Receive definitions
|
||||
*
|
||||
* we have an array of num_rx_desc rx_desc (handled by the
|
||||
* controller), and paired with an array of rx_buffers
|
||||
* (at rx_buffer_area).
|
||||
* The next pair to check on receive is at offset next_rx_desc_to_check
|
||||
*/
|
||||
struct em_rx_desc *rx_desc_base;
|
||||
u_int32_t next_rx_desc_to_check;
|
||||
u_int16_t num_rx_desc;
|
||||
u_int32_t rx_buffer_len;
|
||||
struct em_buffer *rx_buffer_area;
|
||||
|
||||
/* Jumbo frame */
|
||||
struct mbuf *fmp;
|
||||
struct mbuf *lmp;
|
||||
|
||||
u_int16_t tx_fifo_head;
|
||||
|
||||
struct sysctl_ctx_list sysctl_ctx;
|
||||
struct sysctl_oid *sysctl_tree;
|
||||
|
||||
/* Misc stats maintained by the driver */
|
||||
unsigned long dropped_pkts;
|
||||
unsigned long mbuf_alloc_failed;
|
||||
unsigned long mbuf_cluster_failed;
|
||||
unsigned long no_tx_desc_avail1;
|
||||
unsigned long no_tx_desc_avail2;
|
||||
u_int64_t tx_fifo_reset;
|
||||
u_int64_t tx_fifo_wrk;
|
||||
|
||||
/* For 82544 PCIX Workaround */
|
||||
boolean_t pcix_82544;
|
||||
boolean_t in_detach;
|
||||
|
||||
#if DEBUG_DISPLAY_STATS
|
||||
unsigned long no_pkts_avail;
|
||||
unsigned long clean_tx_interrupts;
|
||||
#endif
|
||||
|
||||
struct em_hw_stats stats;
|
||||
};
|
||||
|
||||
#endif /* _EM_H_DEFINED_ */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,175 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "if_em_osdep.h"
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
|
||||
void *
|
||||
driver_malloc(int size, int p2, int p3)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
driver_free(void *p, int p2)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
contigmalloc(int size, int p1, int p2, int p3, int p4, int p5, int p6)
|
||||
{
|
||||
void *adr;
|
||||
if (create_area("contigmalloc", &adr, B_ANY_KERNEL_ADDRESS, size,
|
||||
B_CONTIGUOUS, 0) < B_OK)
|
||||
return NULL;
|
||||
return adr;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
contigfree(void *p, int p1, int p2)
|
||||
{
|
||||
delete_area(area_for(p));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
callout_handle_init(struct callout_handle *handle)
|
||||
{
|
||||
handle->timer = -1;
|
||||
}
|
||||
|
||||
|
||||
struct callout_handle
|
||||
timeout(timer_function func, void *cookie, bigtime_t timeout)
|
||||
{
|
||||
struct callout_handle handle;
|
||||
handle.timer = create_timer(func, cookie, timeout, B_ONE_SHOT_RELATIVE_TIMER);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
untimeout(timer_function func, void *cookie, struct callout_handle handle)
|
||||
{
|
||||
delete_timer(handle.timer);
|
||||
}
|
||||
|
||||
|
||||
struct resource *
|
||||
bus_alloc_resource(device_t dev, int type, int *rid, int d, int e, int f, int g)
|
||||
{
|
||||
switch (type) {
|
||||
case SYS_RES_IOPORT:
|
||||
{
|
||||
uint32 v = pci_read_config(dev, *rid, 4) & PCI_address_io_mask;
|
||||
INIT_DEBUGOUT2("bus_alloc_resource SYS_RES_IOPORT, reg 0x%x, adr %p\n", *rid, (void *)v);
|
||||
return (struct resource *) v;
|
||||
}
|
||||
|
||||
case SYS_RES_MEMORY:
|
||||
{
|
||||
uint32 v = pci_read_config(dev, *rid, 4) & PCI_address_memory_32_mask;
|
||||
uint32 size = 128 * 1024; // XXX get size from BAR
|
||||
void *virt;
|
||||
INIT_DEBUGOUT2("bus_alloc_resource SYS_RES_MEMORY, reg 0x%x, adr %p\n", *rid, (void *)v);
|
||||
if (map_mem(&virt, (void *)v, size, 0, "SYS_RES_MEMORY") < 0)
|
||||
return 0;
|
||||
return (struct resource *) virt;
|
||||
}
|
||||
|
||||
case SYS_RES_IRQ:
|
||||
{
|
||||
uint8 v = pci_read_config(dev, PCI_interrupt_line, 1);
|
||||
if (v == 0 || v == 0xff) {
|
||||
ERROROUT("bus_alloc_resource SYS_RES_IRQ: no irq");
|
||||
return 0;
|
||||
}
|
||||
return (struct resource *)(int)v;
|
||||
}
|
||||
|
||||
default:
|
||||
INIT_DEBUGOUT("bus_alloc_resource default!\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bus_release_resource(device_t dev, int type, int reg, struct resource *res)
|
||||
{
|
||||
switch (type) {
|
||||
case SYS_RES_IOPORT:
|
||||
case SYS_RES_IRQ:
|
||||
return;
|
||||
|
||||
case SYS_RES_MEMORY:
|
||||
delete_area(area_for(res));
|
||||
return;
|
||||
|
||||
default:
|
||||
INIT_DEBUGOUT("bus_release_resource default!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
rman_get_start(struct resource *res)
|
||||
{
|
||||
return (uint32)res;
|
||||
}
|
||||
|
||||
|
||||
struct int_tag {
|
||||
interrupt_handler int_func;
|
||||
void *cookie;
|
||||
int irq;
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
bus_setup_intr(device_t dev, struct resource *res, int p3, interrupt_handler int_func, void *cookie, void **tag)
|
||||
{
|
||||
int irq = (int)res;
|
||||
|
||||
struct int_tag *int_tag = (struct int_tag *) malloc(sizeof(struct int_tag));
|
||||
int_tag->int_func = int_func;
|
||||
int_tag->cookie = cookie;
|
||||
int_tag->irq = irq;
|
||||
*tag = int_tag;
|
||||
|
||||
return install_io_interrupt_handler(irq, int_func, cookie, 0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bus_teardown_intr(device_t dev, struct resource *res, void *tag)
|
||||
{
|
||||
struct int_tag *int_tag = (struct int_tag *) tag;
|
||||
remove_io_interrupt_handler(int_tag->irq, int_tag->int_func, int_tag->cookie);
|
||||
free(int_tag);
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
/**************************************************************************
|
||||
|
||||
Copyright (c) 2001-2003, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Intel Corporation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _IF_EM_OSDEP_H_
|
||||
#define _IF_EM_OSDEP_H_
|
||||
|
||||
#include "driver.h"
|
||||
#include "device.h"
|
||||
#include "timer.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include <OS.h>
|
||||
#include <KernelExport.h>
|
||||
#include <ByteOrder.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define usec_delay(x) snooze(x)
|
||||
#define msec_delay(x) snooze(1000*(x))
|
||||
|
||||
// no longer used in FreeBSD
|
||||
#define splx(s)
|
||||
#define splimp() 0
|
||||
|
||||
#ifndef bzero
|
||||
#define bzero(d,c) memset((d), (0), (c))
|
||||
#endif
|
||||
#ifndef bcopy
|
||||
#define bcopy(s,d,c) memmove((d), (s), (c))
|
||||
#endif
|
||||
#ifndef bcmp
|
||||
#define bcmp(p1, p2, s) memcmp((p1), (p2), (s)) // XXX correct order?
|
||||
#endif
|
||||
|
||||
#define TUNABLE_INT(a, b) /* ignored */
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#define hz 1000000LL
|
||||
|
||||
typedef bool boolean_t;
|
||||
typedef unsigned long vm_offset_t;
|
||||
|
||||
|
||||
struct em_osdep
|
||||
{
|
||||
ipro1000_device *dev;
|
||||
};
|
||||
|
||||
typedef ipro1000_device * device_t;
|
||||
|
||||
#define PCIR_COMMAND PCI_command
|
||||
#define PCIR_REVID PCI_revision
|
||||
#define PCIR_SUBVEND_0 PCI_subsystem_vendor_id
|
||||
#define PCIR_SUBDEV_0 PCI_subsystem_id
|
||||
#define PCIM_CMD_IOEN 0x0001
|
||||
#define PCIM_CMD_MEMEN 0x0002
|
||||
#define PCIM_CMD_BUSMASTEREN 0x0004
|
||||
#define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */
|
||||
|
||||
#define pci_read_config(dev, offset, size) \
|
||||
gPci->read_pci_config(dev->pciBus, dev->pciDev, dev->pciFunc, offset, size)
|
||||
|
||||
#define pci_write_config(dev, offset, value, size) \
|
||||
gPci->write_pci_config(dev->pciBus, dev->pciDev, dev->pciFunc, offset, size, value)
|
||||
|
||||
#define pci_get_vendor(dev) \
|
||||
gPci->read_pci_config(dev->pciBus, dev->pciDev, dev->pciFunc, PCI_vendor_id, 2)
|
||||
|
||||
#define pci_get_device(dev) \
|
||||
gPci->read_pci_config(dev->pciBus, dev->pciDev, dev->pciFunc, PCI_device_id, 2)
|
||||
|
||||
#define inl(port) \
|
||||
gPci->read_io_32(port)
|
||||
|
||||
#define outl(port, value) \
|
||||
gPci->write_io_32(port, value)
|
||||
|
||||
|
||||
void *contigmalloc(int size, int p1, int p2, int p3, int p4, int p5, int p6);
|
||||
void contigfree(void *p, int p1, int p2);
|
||||
|
||||
static inline u_int64_t vtophys(unsigned long virtual_addr)
|
||||
{
|
||||
physical_entry pe;
|
||||
status_t err;
|
||||
// vtophys is called for the start of any page aligned contiguous large buffer,
|
||||
// and also with offset 2 into 2048 byte aligned (non-contiguous) rx/tx buffer.
|
||||
// Thus we only ask for 2046 bytes to get exactly one physical_entry. If the
|
||||
// next physical page is non-contiguous, using 2048 may return B_BUFFER_OVERFLOW.
|
||||
err = get_memory_map((void *)virtual_addr, 2046, &pe, 1);
|
||||
if (err < 0)
|
||||
panic("ipro1000: get_memory_map failed for %p, error %08lx\n", (void *)virtual_addr, err);
|
||||
return pe.address;
|
||||
}
|
||||
|
||||
#define M_DEVBUF 1
|
||||
#define M_NOWAIT 2
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
|
||||
struct callout_handle
|
||||
{
|
||||
timer_id timer;
|
||||
};
|
||||
|
||||
void callout_handle_init(struct callout_handle *handle);
|
||||
struct callout_handle timeout(timer_function func, void *cookie, bigtime_t timeout);
|
||||
void untimeout(timer_function func, void *cookie, struct callout_handle handle);
|
||||
|
||||
|
||||
// resource management
|
||||
struct resource * bus_alloc_resource(device_t dev, int type, int *rid, int d, int e, int f, int g);
|
||||
void bus_release_resource(device_t dev, int type, int reg, struct resource *res);
|
||||
uint32 rman_get_start(struct resource *res);
|
||||
|
||||
#define bus_generic_detach(dev)
|
||||
|
||||
#define SYS_RES_IOPORT 0x01
|
||||
#define SYS_RES_MEMORY 0x02
|
||||
#define SYS_RES_IRQ 0x04
|
||||
#define RF_SHAREABLE 0
|
||||
#define RF_ACTIVE 0
|
||||
|
||||
|
||||
#define INTR_TYPE_NET 0
|
||||
int bus_setup_intr(device_t dev, struct resource *res, int p3, interrupt_handler int_func, void *cookie, void **tag);
|
||||
void bus_teardown_intr(device_t dev, struct resource *res, void *tag);
|
||||
|
||||
|
||||
#undef malloc
|
||||
#define malloc driver_malloc
|
||||
#undef free
|
||||
#define free driver_free
|
||||
|
||||
void *driver_malloc(int size, int p2, int p3);
|
||||
void driver_free(void *p, int p2);
|
||||
|
||||
/* GCC will always emit a read opcode when reading from */
|
||||
/* a volatile pointer, even if the result is unused */
|
||||
#define E1000_WRITE_FLUSH(a) \
|
||||
E1000_READ_REG(a, STATUS)
|
||||
|
||||
/* Read from an absolute offset in the adapter's memory space */
|
||||
#define E1000_READ_OFFSET(hw, offset) \
|
||||
(*(volatile uint32 *)((char *)(((struct em_osdep *)(hw)->back)->dev->regAddr) + offset))
|
||||
|
||||
/* Write to an absolute offset in the adapter's memory space */
|
||||
#define E1000_WRITE_OFFSET(hw, offset, value) \
|
||||
(*(volatile uint32 *)((char *)(((struct em_osdep *)(hw)->back)->dev->regAddr) + offset) = value)
|
||||
|
||||
/* Convert a register name to its offset in the adapter's memory space */
|
||||
#define E1000_REG_OFFSET(hw, reg) \
|
||||
((hw)->mac_type >= em_82543 ? E1000_##reg : E1000_82542_##reg)
|
||||
|
||||
#define E1000_READ_REG(hw, reg) \
|
||||
E1000_READ_OFFSET(hw, E1000_REG_OFFSET(hw, reg))
|
||||
|
||||
#define E1000_WRITE_REG(hw, reg, value) \
|
||||
E1000_WRITE_OFFSET(hw, E1000_REG_OFFSET(hw, reg), value)
|
||||
|
||||
#define E1000_READ_REG_ARRAY(hw, reg, index) \
|
||||
E1000_READ_OFFSET(hw, E1000_REG_OFFSET(hw, reg) + ((index) << 2))
|
||||
|
||||
#define E1000_WRITE_REG_ARRAY(hw, reg, index, value) \
|
||||
E1000_WRITE_OFFSET(hw, E1000_REG_OFFSET(hw, reg) + ((index) << 2), value)
|
||||
|
||||
#define TAILQ_HEAD(name, type) \
|
||||
struct name { struct type *tqh_first, **tqh_last; }
|
||||
|
||||
#define TAILQ_ENTRY(type) \
|
||||
struct { struct type *tqe_next, **tqe_prev; }
|
||||
|
||||
#define TAILQ_FIRST(head) \
|
||||
((head)->tqh_first)
|
||||
|
||||
#define TAILQ_NEXT(elm, field) \
|
||||
((elm)->field.tqe_next)
|
||||
|
||||
#define TAILQ_FOREACH(var, head, field) \
|
||||
for ((var) = TAILQ_FIRST((head)); (var); (var) = TAILQ_NEXT((var), field))
|
||||
|
||||
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = TAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); (var) = (tvar))
|
||||
|
||||
#define TAILQ_INIT(head) do { \
|
||||
TAILQ_FIRST((head)) = NULL; \
|
||||
(head)->tqh_last = &TAILQ_FIRST((head)); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
|
||||
TAILQ_FIRST((head))->field.tqe_prev = &TAILQ_NEXT((elm), field); \
|
||||
else \
|
||||
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
|
||||
TAILQ_FIRST((head)) = (elm); \
|
||||
(elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
||||
if ((TAILQ_NEXT((elm), field)) != NULL) \
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev = (elm)->field.tqe_prev; \
|
||||
else \
|
||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||
*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
# Sample settings file for the ipro1000 driver
|
||||
#
|
||||
# This file should be moved to the directory ~/config/settings/kernel/drivers/
|
||||
# and must be RENAMED into "ipro1000"
|
||||
|
||||
# Currently supported settings are:
|
||||
#
|
||||
# mtu <value>
|
||||
#
|
||||
# where value can be in the range 50 to 1500
|
||||
#
|
||||
# to fix upload problems with DSL, use
|
||||
#
|
||||
# mtu 1492
|
||||
@@ -1,143 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include <KernelExport.h>
|
||||
#include <malloc.h>
|
||||
#include "mempool.h"
|
||||
#include "if_compat.h"
|
||||
#include "util.h"
|
||||
#include "debug.h"
|
||||
|
||||
spinlock mbuf_pool_lock = 0;
|
||||
spinlock chunk_pool_lock = 0;
|
||||
|
||||
void *mbuf_pool = 0;
|
||||
void *chunk_pool = 0;
|
||||
|
||||
void *mbuf_head = 0;
|
||||
void *chunk_head = 0;
|
||||
|
||||
int
|
||||
mempool_init(int count)
|
||||
{
|
||||
int chunk_size = 2048;
|
||||
int mbuf_size = ROUNDUP(sizeof(struct mbuf), 16);
|
||||
|
||||
int chunk_alloc_size = chunk_size * (count + 1);
|
||||
int mbuf_alloc_size = mbuf_size * (count + 1);
|
||||
|
||||
char *chunk_base;
|
||||
char *mbuf_base;
|
||||
|
||||
int i;
|
||||
|
||||
INIT_DEBUGOUT2("chunk_size %d, mbuf_size %d", chunk_size, mbuf_size);
|
||||
INIT_DEBUGOUT2("chunk_alloc_size %d, mbuf_alloc_size %d", chunk_alloc_size, mbuf_alloc_size);
|
||||
|
||||
chunk_pool = area_malloc(chunk_alloc_size);
|
||||
if (!chunk_pool) {
|
||||
ERROROUT1("failed to allocate chunk storage of %d bytes\n", chunk_alloc_size);
|
||||
return -1;
|
||||
}
|
||||
mbuf_pool = area_malloc(mbuf_alloc_size);
|
||||
if (!mbuf_pool) {
|
||||
ERROROUT1("failed to allocate mbuf storage of %d bytes\n", mbuf_alloc_size);
|
||||
area_free(chunk_pool);
|
||||
return -1;
|
||||
}
|
||||
|
||||
chunk_base = (char *)ROUNDUP((unsigned long)chunk_pool, 2048);
|
||||
mbuf_base = (char *)ROUNDUP((unsigned long)mbuf_pool, 16);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
chunk_pool_put(chunk_base + i * chunk_size);
|
||||
mbuf_pool_put(mbuf_base + i * mbuf_size);
|
||||
}
|
||||
|
||||
INIT_DEBUGOUT("mempool init success");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
mempool_exit(void)
|
||||
{
|
||||
area_free(chunk_pool);
|
||||
area_free(mbuf_pool);
|
||||
}
|
||||
|
||||
void *
|
||||
mbuf_pool_get(void)
|
||||
{
|
||||
void *p;
|
||||
cpu_status s;
|
||||
s = disable_interrupts();
|
||||
acquire_spinlock(&mbuf_pool_lock);
|
||||
|
||||
p = mbuf_head;
|
||||
if (p)
|
||||
mbuf_head = *(void **)p;
|
||||
|
||||
release_spinlock(&mbuf_pool_lock);
|
||||
restore_interrupts(s);
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
mbuf_pool_put(void *p)
|
||||
{
|
||||
cpu_status s;
|
||||
s = disable_interrupts();
|
||||
acquire_spinlock(&mbuf_pool_lock);
|
||||
|
||||
*(void **)p = mbuf_head;
|
||||
mbuf_head = p;
|
||||
|
||||
release_spinlock(&mbuf_pool_lock);
|
||||
restore_interrupts(s);
|
||||
}
|
||||
|
||||
void *
|
||||
chunk_pool_get(void)
|
||||
{
|
||||
void *p;
|
||||
cpu_status s;
|
||||
s = disable_interrupts();
|
||||
acquire_spinlock(&chunk_pool_lock);
|
||||
|
||||
p = chunk_head;
|
||||
if (p)
|
||||
chunk_head = *(void **)p;
|
||||
|
||||
release_spinlock(&chunk_pool_lock);
|
||||
restore_interrupts(s);
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
chunk_pool_put(void *p)
|
||||
{
|
||||
cpu_status s;
|
||||
s = disable_interrupts();
|
||||
acquire_spinlock(&chunk_pool_lock);
|
||||
|
||||
*(void **)p = chunk_head;
|
||||
chunk_head = p;
|
||||
|
||||
release_spinlock(&chunk_pool_lock);
|
||||
restore_interrupts(s);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef __MEMPOOL_H
|
||||
#define __MEMPOOL_H
|
||||
|
||||
int mempool_init(int count);
|
||||
void mempool_exit(void);
|
||||
|
||||
void *mbuf_pool_get(void);
|
||||
void *chunk_pool_get(void);
|
||||
|
||||
void chunk_pool_put(void *p);
|
||||
void mbuf_pool_put(void *p);
|
||||
|
||||
#endif
|
||||
@@ -1,26 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef __SETUP_H
|
||||
#define __SETUP_H
|
||||
|
||||
#define VERSION "0.3"
|
||||
|
||||
#define INFO "Intel PRO/1000 Family Driver. Version " VERSION " Build " __DATE__ " "__TIME__
|
||||
|
||||
#endif
|
||||
@@ -1,215 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include <Errors.h>
|
||||
#include <OS.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "timer.h"
|
||||
|
||||
#define MAX_TIMERS 4
|
||||
|
||||
|
||||
struct timer_info
|
||||
{
|
||||
timer_id id;
|
||||
timer_function func;
|
||||
void * cookie;
|
||||
bigtime_t next_event;
|
||||
bigtime_t interval;
|
||||
bool periodic;
|
||||
};
|
||||
|
||||
|
||||
static struct timer_info sTimerData[MAX_TIMERS];
|
||||
static int sTimerCount;
|
||||
static timer_id sTimerNextId;
|
||||
static thread_id sTimerThread;
|
||||
static sem_id sTimerSem;
|
||||
static spinlock sTimerSpinlock;
|
||||
|
||||
|
||||
static int32
|
||||
timer_thread(void *cookie)
|
||||
{
|
||||
status_t status = 0;
|
||||
|
||||
do {
|
||||
bigtime_t timeout;
|
||||
bigtime_t now;
|
||||
cpu_status cpu;
|
||||
timer_function func;
|
||||
void * cookie;
|
||||
int i;
|
||||
int index;
|
||||
|
||||
cpu = disable_interrupts();
|
||||
acquire_spinlock(&sTimerSpinlock);
|
||||
|
||||
now = system_time();
|
||||
cookie = 0;
|
||||
func = 0;
|
||||
|
||||
// find timer with smallest event time
|
||||
index = -1;
|
||||
timeout = B_INFINITE_TIMEOUT;
|
||||
for (i = 0; i < sTimerCount; i++) {
|
||||
if (sTimerData[i].next_event < timeout) {
|
||||
timeout = sTimerData[i].next_event;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeout < now) {
|
||||
// timer is ready for execution, load func and cookie
|
||||
ASSERT(index >= 0 && index < sTimerCount);
|
||||
func = sTimerData[index].func;
|
||||
cookie = sTimerData[index].cookie;
|
||||
if (sTimerData[index].periodic) {
|
||||
// periodic timer is ready, update the entry
|
||||
sTimerData[index].next_event += sTimerData[index].interval;
|
||||
} else {
|
||||
// single shot timer is ready, delete the entry
|
||||
if (index != (sTimerCount - 1) && sTimerCount != 1) {
|
||||
memcpy(&sTimerData[index], &sTimerData[sTimerCount - 1], sizeof(struct timer_info));
|
||||
}
|
||||
sTimerCount--;
|
||||
}
|
||||
}
|
||||
|
||||
release_spinlock(&sTimerSpinlock);
|
||||
restore_interrupts(cpu);
|
||||
|
||||
// execute timer hook
|
||||
if (timeout < now) {
|
||||
ASSERT(func);
|
||||
func(cookie);
|
||||
continue;
|
||||
}
|
||||
|
||||
status = acquire_sem_etc(sTimerSem, 1, B_ABSOLUTE_TIMEOUT, timeout);
|
||||
} while (status != B_BAD_SEM_ID);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
timer_id
|
||||
create_timer(timer_function func, void *cookie, bigtime_t interval, uint32 flags)
|
||||
{
|
||||
cpu_status cpu;
|
||||
timer_id id;
|
||||
|
||||
if (func == 0)
|
||||
return -1;
|
||||
|
||||
// Attention: flags are not real flags, as B_PERIODIC_TIMER is 3
|
||||
|
||||
cpu = disable_interrupts();
|
||||
acquire_spinlock(&sTimerSpinlock);
|
||||
|
||||
if (sTimerCount < MAX_TIMERS) {
|
||||
id = sTimerNextId;
|
||||
sTimerData[sTimerCount].id = id;
|
||||
sTimerData[sTimerCount].func = func;
|
||||
sTimerData[sTimerCount].cookie = cookie;
|
||||
sTimerData[sTimerCount].next_event = (flags == B_ONE_SHOT_ABSOLUTE_TIMER) ? interval : system_time() + interval;
|
||||
sTimerData[sTimerCount].interval = interval;
|
||||
sTimerData[sTimerCount].periodic = flags == B_PERIODIC_TIMER;
|
||||
sTimerNextId++;
|
||||
sTimerCount++;
|
||||
} else {
|
||||
id = -1;
|
||||
}
|
||||
|
||||
release_spinlock(&sTimerSpinlock);
|
||||
restore_interrupts(cpu);
|
||||
|
||||
if (id != -1)
|
||||
release_sem_etc(sTimerSem, 1, B_DO_NOT_RESCHEDULE);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
delete_timer(timer_id id)
|
||||
{
|
||||
cpu_status cpu;
|
||||
bool deleted;
|
||||
int i;
|
||||
|
||||
deleted = false;
|
||||
|
||||
cpu = disable_interrupts();
|
||||
acquire_spinlock(&sTimerSpinlock);
|
||||
|
||||
for (i = 0; i < sTimerCount; i++) {
|
||||
if (sTimerData[i].id == id) {
|
||||
if (i != (sTimerCount - 1) && sTimerCount != 1) {
|
||||
memcpy(&sTimerData[i], &sTimerData[sTimerCount - 1], sizeof(struct timer_info));
|
||||
}
|
||||
sTimerCount--;
|
||||
deleted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
release_spinlock(&sTimerSpinlock);
|
||||
restore_interrupts(cpu);
|
||||
|
||||
if (!deleted)
|
||||
return B_ERROR;
|
||||
|
||||
release_sem_etc(sTimerSem, 1, B_DO_NOT_RESCHEDULE);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
initialize_timer(void)
|
||||
{
|
||||
sTimerCount = 0;
|
||||
sTimerNextId = 1;
|
||||
sTimerSpinlock = 0;
|
||||
|
||||
sTimerThread = spawn_kernel_thread(timer_thread, "ipro1000 timer", 80, 0);
|
||||
sTimerSem = create_sem(0, "ipro1000 timer");
|
||||
set_sem_owner(sTimerSem, B_SYSTEM_TEAM);
|
||||
|
||||
if (sTimerSem < 0 || sTimerThread < 0) {
|
||||
delete_sem(sTimerSem);
|
||||
kill_thread(sTimerThread);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
resume_thread(sTimerThread);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
terminate_timer(void)
|
||||
{
|
||||
status_t thread_return_value;
|
||||
|
||||
delete_sem(sTimerSem);
|
||||
return wait_for_thread(sTimerThread, &thread_return_value);
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef __TIMER_H
|
||||
#define __TIMER_H
|
||||
|
||||
#include <KernelExport.h>
|
||||
|
||||
// Since the BeOS kernel timers are executed in interrupt context,
|
||||
// a new timer has been created. The timers are executed in thread
|
||||
// context, and are passed a cookie.
|
||||
|
||||
typedef int32 timer_id;
|
||||
|
||||
typedef void (*timer_function)(void *cookie);
|
||||
|
||||
// create_timer() can be called from interrupt context.
|
||||
// Only up to 4 concurrent timers are supported.
|
||||
// Flags can be one of B_ONE_SHOT_ABSOLUTE_TIMER,
|
||||
// B_ONE_SHOT_RELATIVE_TIMER or B_PERIODIC_TIMER.
|
||||
|
||||
timer_id create_timer(timer_function func, void *cookie, bigtime_t interval, uint32 flags);
|
||||
status_t delete_timer(timer_id id);
|
||||
|
||||
|
||||
status_t initialize_timer(void);
|
||||
status_t terminate_timer(void);
|
||||
|
||||
#endif
|
||||
@@ -1,69 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include <Errors.h>
|
||||
#include <OS.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "util.h"
|
||||
|
||||
area_id
|
||||
map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name)
|
||||
{
|
||||
uint32 offset;
|
||||
void *phyadr;
|
||||
void *mapadr;
|
||||
area_id area;
|
||||
|
||||
INIT_DEBUGOUT3("mapping physical address %p with %ld bytes for %s\n", phy, size, name);
|
||||
|
||||
offset = (uint32)phy & (B_PAGE_SIZE - 1);
|
||||
phyadr = (char *)phy - offset;
|
||||
size = ROUNDUP(size + offset, B_PAGE_SIZE);
|
||||
area = map_physical_memory(name, (addr_t)phyadr, size,
|
||||
B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr);
|
||||
if (area < B_OK) {
|
||||
ERROROUT3("mapping '%s' failed, error 0x%lx (%s)\n", name, area, strerror(area));
|
||||
return area;
|
||||
}
|
||||
|
||||
*virt = (char *)mapadr + offset;
|
||||
|
||||
INIT_DEBUGOUT7("physical = %p, virtual = %p, offset = %ld, phyadr = %p, mapadr = %p, size = %ld, area = 0x%08lx\n",
|
||||
phy, *virt, offset, phyadr, mapadr, size, area);
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
void *
|
||||
area_malloc(size_t size)
|
||||
{
|
||||
void *p;
|
||||
size = ROUNDUP(size, B_PAGE_SIZE);
|
||||
|
||||
if (create_area("area_malloc", &p, B_ANY_KERNEL_ADDRESS, size, B_FULL_LOCK, 0) < 0)
|
||||
return 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
area_free(void *p)
|
||||
{
|
||||
delete_area(area_for(p));
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/* Intel PRO/1000 Family Driver
|
||||
* Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies, and that both the
|
||||
* copyright notice and this permission notice appear in supporting documentation.
|
||||
*
|
||||
* Marcus Overhagen makes no representations about the suitability of this software
|
||||
* for any purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
|
||||
* OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef __UTIL_H
|
||||
#define __UTIL_H
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
area_id map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name);
|
||||
|
||||
void * area_malloc(size_t size);
|
||||
void area_free(void *p);
|
||||
|
||||
// generic macro for rounding, can only be used for power of 2 blocksize
|
||||
#define ROUNDUP(size, blocksize) (((size) + (blocksize) - 1) & ~((blocksize) - 1))
|
||||
|
||||
#define atomic_read(a) atomic_or(a, 0)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user