<commit_before>/*
 * Copyright (c) 1997, 1998, 1999, 2000
 *	<NAME> <<EMAIL>>.  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. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by <NAME>.
 * 4. Neither the name of the author nor the names of any co-contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY <NAME> 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 <NAME> OR THE VOICES IN HIS HEAD
 * 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$
 */

/*
 * ADMtek AN986 Pegasus USB to ethernet driver. Datasheet is available
 * from http://www.admtek.com.tw.
 *
 * Written by <NAME> <<EMAIL>>
 * Electrical Engineering Department
 * Columbia University, New York City
 */

/*
 * The Pegasus chip uses four USB "endpoints" to provide 10/100 ethernet
 * support: the control endpoint for reading/writing registers, burst
 * read endpoint for packet reception, burst write for packet transmission
 * and one for "interrupts." The chip uses the same RX filter scheme
 * as the other ADMtek ethernet parts: one perfect filter entry for the
 * the station address and a 64-bit multicast hash table. The chip supports
 * both MII and HomePNA attachments.
 *
 * Since the maximum data transfer speed of USB is supposed to be 12Mbps,
 * you're never really going to get 100Mbps speeds from this device. I
 * think the idea is to allow the device to connect to 10 or 100Mbps
 * networks, not necessarily to provide 100Mbps performance. Also, since
 * the controller uses an external PHY chip, it's possible that board
 * designers might simply choose a 10Mbps PHY.
 *
 * Registers are accessed using usbd_do_request(). Packet transfers are
 * done using usbd_transfer() and friends.
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/socket.h>

#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>

#include <net/bpf.h>

#include <sys/bus.h>

#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdivar.h>
#include <dev/usb/usbdevs.h>
#include <dev/usb/usb_ethersubr.h>

#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>

#include <dev/usb/if_auereg.h>

MODULE_DEPEND(aue, miibus, 1, 1, 1);

/* "controller miibus0" required.  See GENERIC if you get errors here. */
#include "miibus_if.h"

#ifndef lint
static const char rcsid[] =
  "$FreeBSD$";
#endif

/*
 * Various supported device vendors/products.
 */
Static struct aue_type aue_devs[] = {
	{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUS },
	{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100 },
	{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX1 },
	{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX5 },
	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650 },
	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX },
	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX_PNA },
	{ USB_VENDOR_SMC, USB_PRODUCT_SMC_2202USB },
	{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX },
	{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TA },
	{ USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TX },
	{ USB_VENDOR_KINGSTON, USB_PRODUCT_KINGSTON_KNU101TX, },
	{ USB_VENDOR_ABOCOM, USB_PRODUCT_DLINK_DSB650TX_PNA },
	{ 0, 0 }
};

Static struct usb_qdat aue_qdat;

Static int aue_match		__P((device_t));
Static int aue_attach		__P((device_t));
Static int aue_detach		__P((device_t));

Static int aue_tx_list_init	__P((struct aue_softc *));
Static int aue_rx_list_init	__P((struct aue_softc *));
Static int aue_newbuf		__P((struct aue_softc *, struct aue_chain *,
				    struct mbuf *));
Static int aue_encap		__P((struct aue_softc *, struct mbuf *, int));
#ifdef AUE_INTR_PIPE<commit_msg>Add support for the I-O DATA USB-ET/TX(USB Ethernet adapter)<commit_after>/*
 * Copyright (c) 1997, 1998, 1999, 2000
 *	<NAME> <<EMAIL>>.  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. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by <NAME>.
 * 4. Neither the name of the author nor the names of any co-contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY <NAME> 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 <NAME> OR THE VOICES IN HIS HEAD
 * 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$
 */

/*
 * ADMtek AN986 Pegasus USB to ethernet driver. Datasheet is available
 * from http://www.admtek.com.tw.
 *
 * Written by <NAME> <<EMAIL>>
 * Electrical Engineering Department
 * Columbia University, New York City
 */

/*
 * The Pegasus chip uses four USB "endpoints" to provide 10/100 ethernet
 * support: the control endpoint for reading/writing registers, burst
 * read endpoint for packet reception, burst write for packet transmission
 * and one for "interrupts." The chip uses the same RX filter scheme
 * as the other ADMtek ethernet parts: one perfect filter entry for the
 * the station address and a 64-bit multicast hash table. The chip supports
 * both MII and HomePNA attachments.
 *
 * Since the maximum data transfer speed of USB is supposed to be 12Mbps,
 * you're never really going to get 100Mbps speeds from this device. I
 * think the idea is to allow the device to connect to 10 or 100Mbps
 * networks, not necessarily to provide 100Mbps performance. Also, since
 * the controller uses an external PHY chip, it's possible that board
 * designers might simply choose a 10Mbps PHY.
 *
 * Registers are accessed using usbd_do_request(). Packet transfers are
 * done using usbd_transfer() and friends.
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/socket.h>

#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>

#include <net/bpf.h>

#include <sys/bus.h>

#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdivar.h>
#include <dev/usb/usbdevs.h>
#include <dev/usb/usb_ethersubr.h>

#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>

#include <dev/usb/if_auereg.h>

MODULE_DEPEND(aue, miibus, 1, 1, 1);

/* "controller miibus0" required.  See GENERIC if you get errors here. */
#include "miibus_if.h"

#ifndef lint
static const char rcsid[] =
  "$FreeBSD$";
#endif

/*
 * Various supported device vendors/products.
 */
Static struct aue_type aue_devs[] = {
	{ USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUS },
	{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100 },
	{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX1 },
	{ USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX5 },
	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650 },
	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX },
	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX_PNA },
	{ USB_VENDOR_SMC, USB_PRODUCT_SMC_2202USB },
	{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX },
	{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TA },
	{ USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TX },
	{ USB_VENDOR_KINGSTON, USB_PRODUCT_KINGSTON_KNU101TX },
	{ USB_VENDOR_ABOCOM, USB_PRODUCT_DLINK_DSB650TX_PNA },
	{ USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTX },
	{ 0, 0 }
};

Static struct usb_qdat aue_qdat;

Static int aue_match		__P((device_t));
Static int aue_attach		__P((device_t));
Static int aue_detach		__P((device_t));

Static int aue_tx_list_init	__P((struct aue_softc *));
Static int aue_rx_list_init	__P((struct aue_softc *));
Static int aue_newbuf		__P((struct aue_softc *, struct aue_chain *,
				    struct mbuf *));
Static int aue_encap		__P((struct aue_softc *, struct mbuf *, int));
#ifdef AUE_INTR_PIPE
{'fraction_non_alphanumeric': 0.08836754643206256, 'fraction_numerical': 0.015640273704789834, 'mean_word_length': 4.5998905309250135, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3266252', 'n_tokens_mistral': 3601, 'n_tokens_neox': 3349, 'n_words': 1161}