/*
* udmfE_usbgem.c : Davicom DM9601E USB to Fast Ethernet Driver for Solaris
*
* Copyright (c) 2009-2012 Masayuki Murayama. 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
*
* 3. Neither the name of the author 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.
*/
/*
* Changelog:
*/
/*
* TODO
*/
/* ======================================================= */
/*
* Solaris system header files and macros
*/
/* minimum kernel headers for drivers */
#include <sys/byteorder.h>
/* ethernet stuff */
#include <sys/ethernet.h>
/* interface card depend stuff */
#include "usbgem.h"
/* hardware stuff */
#include "usbgem_mii.h"
#include "dm9601reg.h"
char ident[] = "dm9601 usbnic driver v" VERSION;
/*
* Useful macros
*/
/*
* Debugging
*/
#ifdef DEBUG_LEVEL
#else
#endif
/*
* Our configration for dm9601
*/
/* timeouts */
/*
* Local device definitions
*/
struct udmf_dev {
/*
* Misc HW information
*/
};
/*
* private functions
*/
/* mii operations */
/* nic operations */
static int udmf_reset_chip(struct usbgem_dev *);
static int udmf_init_chip(struct usbgem_dev *);
static int udmf_start_chip(struct usbgem_dev *);
static int udmf_stop_chip(struct usbgem_dev *);
static int udmf_set_media(struct usbgem_dev *);
static int udmf_set_rx_filter(struct usbgem_dev *);
static int udmf_get_stats(struct usbgem_dev *);
/* packet operations */
/* =============================================================== */
/*
* I/O functions
*/
/* =============================================================== */
/* bmRequestType */ USB_DEV_REQ_HOST_TO_DEV \
/* bRequest */ 1, \
/* wValue */ 0, \
/* wIndex */ (ix), \
/* wLength */ (len), \
/* value */ (buf), \
/* bmRequestType */ USB_DEV_REQ_HOST_TO_DEV \
/* bRequest */ 3, \
/* wValue */ (val), \
/* wIndex */ (ix), \
/* wLength */ 0, \
/* value */ NULL, \
/* bmRequestType */ USB_DEV_REQ_DEV_TO_HOST \
/* bRequest */ 0, \
/* wValue */ 0, \
/* wIndex */ (ix), \
/* wLength */ (len), \
/* valuep */ (buf), \
/* =============================================================== */
/*
* Hardware manupilation
*/
/* =============================================================== */
static void
{
/* de-assert reset signal to phy */
;
}
static int
{
drv_usecwait(100);
return (err);
}
/*
* Setup dm9601
*/
static int
{
int i;
/* tx control regiser: enable padding and crc generation */
/* rx control register: will be set later by udmf_set_rx_filer() */
/* back pressure threshold: */
/* flow control threshold: same as default */
/* usb control register */
/* flow control: will be set later by udmf_set_media() */
/* wake up control register: */
return (err);
}
static int
{
/* enable Rx */
return (err);
}
static int
{
/* disable rx */
return (err);
}
static int
{
/* empty */
return (USB_SUCCESS);
}
static uint_t
{
}
static int
{
int i;
uint_t h;
/* set promiscuous mode before changing rx filter mode */
}
mode = 0;
mac = invalid_mac;
/* promiscious mode implies all multicast and all physical */
/* accept all multicast packets */
/*
* make hash table to select interresting
* multicast address only.
*/
/* hash table is 64 = 2^6 bit width */
}
}
/* set node address */
}
/* set multicast hash table */
/* update rcr */
#if DEBUG_LEVEL > 1
/* verify rcr */
#endif
return (err);
}
static int
{
/* setup flow control */
fcr = 0;
if (dp->full_duplex) {
/* select flow control */
switch (dp->flow_control) {
case FLOW_CONTROL_RX_PAUSE:
break;
case FLOW_CONTROL_TX_PAUSE:
break;
case FLOW_CONTROL_SYMMETRIC:
break;
}
}
/* update flow control register */
return (err);
}
/*
*/
static mblk_t *
{
int n;
align_mask = 63;
/*
* re-allocate the mp
*/
/* minimum ethernet packet size of ETHERMIN */
#if 0 /* CONFIG_ADD_TX_DELIMITOR_ALWAYS */
#endif
/* padding is required in usb communication */
}
return (NULL);
}
/* add a header */
bp += TX_HEADER_SIZE;
/* copy contents of the buffer */
bp += n;
}
/* clear the rest including the next zero length header */
*bp++ = 0;
}
return (new);
}
static void
{
int i;
}
}
static mblk_t *
{
if (len <= RX_HEADER_SIZE) {
/*
* the usb bulk-in frame doesn't include a valid
* ethernet packet.
*/
return (NULL);
}
/* remove rx header */
}
/* late collision */
}
/* rx timeout */
}
/* physical layer error */
}
/* alignment error */
}
/* crc error */
}
/* fifo overflow error */
}
}
}
return (mp);
}
/*
* MII Interfaces
*/
static uint16_t
{
int i;
for (i = 0; i < 100; i++) {
/* done */
goto done;
}
drv_usecwait(10);
}
/* timeout */
val = 0;
done:
return (val);
return (0);
}
static void
{
int i;
for (i = 0; i < 100; i++) {
/* done */
goto done;
}
drv_usecwait(10);
}
/* timeout */
done:
return;
}
static uint16_t
{
return (val);
}
static void
{
}
static void
{
"!%s: %s: size:%d, nsr:%b tsr1:%b tsr2:%b"
" rsr:%b rocr:%b rxc:%02x txc:%b gpr:%b",
}
}
/* ======================================================== */
/*
* OS depend (device driver DKI) routine
*/
/* ======================================================== */
static uint16_t
{
return (val);
}
#ifdef DEBUG_LEVEL
static void
{
int i;
int err;
err = USB_SUCCESS;
for (i = 0; i < size; i += 4) {
}
;
}
#endif
static int
{
int i;
uint8_t *m;
int err;
/*
* get mac address from EEPROM
*/
for (i = 0; i < ETHERADDRL; i += 2) {
}
/* invalidate a private cache for mac addr */
#ifdef CONFIG_VLAN
#endif
#if DEBUG_LEVEL > 0
#endif
{
}
return (USB_SUCCESS);
return (USB_FAILURE);
}
static int
{
return (usbgem_mii_probe_default(dp));
}
static int
{
return (USB_SUCCESS);
}
static int
{
int i;
int ret;
int revid;
int unit;
int len;
const char *drv_name;
void *base;
if (cmd == DDI_ATTACH) {
/*
* construct usbgem configration
*/
/* name */
/*
* softmac requires that ppa is the instance number
* of the device, otherwise it hangs in seaching the device.
*/
ugcp->usbgc_ifnum = 0;
/* time out parameters */
#if 1
/* flow control */
#else
/*
* XXX - flow control caused link down frequently under
* heavy traffic
*/
#endif
/* MII timeout parameters */
/* I/O methods */
/* mac operation */
/* packet operation */
/* mii operations */
/* mtu */
return (DDI_SUCCESS);
}
err:
return (DDI_FAILURE);
}
if (cmd == DDI_RESUME) {
return (usbgem_resume(dip));
}
return (DDI_FAILURE);
}
static int
{
int ret;
if (cmd == DDI_DETACH) {
if (ret != DDI_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
if (cmd == DDI_SUSPEND) {
return (usbgem_suspend(dip));
}
return (DDI_FAILURE);
}
/* ======================================================== */
/*
* OS depend (loadable streams driver) routine
*/
/* ======================================================== */
#ifdef USBGEM_CONFIG_GLDv3
#else
0, /* mi_idnum */
"udmf", /* mi_idname */
0, /* mi_minpsz */
ETHERMTU, /* mi_maxpsz */
1, /* mi_lowat */
};
(int (*)()) NULL, /* qi_putp */
usbgem_rsrv, /* qi_srvp */
usbgem_open, /* qi_qopen */
usbgem_close, /* qi_qclose */
(int (*)()) NULL, /* qi_qadmin */
&udmfminfo, /* qi_minfo */
NULL /* qi_mstat */
};
usbgem_wput, /* qi_putp */
usbgem_wsrv, /* qi_srvp */
(int (*)()) NULL, /* qi_qopen */
(int (*)()) NULL, /* qi_qclose */
(int (*)()) NULL, /* qi_qadmin */
&udmfminfo, /* qi_minfo */
NULL /* qi_mstat */
};
&udmfrinit, /* st_rdinit */
&udmfwinit, /* st_wrinit */
NULL, /* st_muxrinit */
NULL /* st_muxwrinit */
};
nulldev, /* cb_open */
nulldev, /* cb_close */
nodev, /* cb_strategy */
nodev, /* cb_print */
nodev, /* cb_dump */
nodev, /* cb_read */
nodev, /* cb_write */
nodev, /* cb_ioctl */
nodev, /* cb_devmap */
nodev, /* cb_mmap */
nodev, /* cb_segmap */
nochpoll, /* cb_chpoll */
ddi_prop_op, /* cb_prop_op */
&udmf_info, /* cb_stream */
};
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
usbgem_getinfo, /* devo_getinfo */
nulldev, /* devo_identify */
nulldev, /* devo_probe */
udmfattach, /* devo_attach */
udmfdetach, /* devo_detach */
nodev, /* devo_reset */
&cb_udmf_ops, /* devo_cb_ops */
NULL, /* devo_bus_ops */
usbgem_power, /* devo_power */
#if DEVO_REV >= 4
usbgem_quiesce, /* devo_quiesce */
#endif
};
#endif
&mod_driverops, /* Type of module. This one is a driver */
ident,
&udmf_ops, /* driver ops */
};
};
/* ======================================================== */
/*
* _init : done
*/
/* ======================================================== */
int
_init(void)
{
int status;
if (status != DDI_SUCCESS) {
return (status);
}
if (status != DDI_SUCCESS) {
}
return (status);
}
/*
* _fini : done
*/
int
_fini(void)
{
int status;
if (status == DDI_SUCCESS) {
}
return (status);
}
int
{
}