1999-03-07 16:08:20 +00:00
|
|
|
/*
|
2000-10-09 13:29:00 +00:00
|
|
|
* Copyright (c) 1999, 2000 Gary Jennejohn. All rights reserved.
|
1999-03-07 16:08:20 +00:00
|
|
|
*
|
|
|
|
* 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 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.
|
|
|
|
* 4. Altered versions must be plainly marked as such, and must not be
|
|
|
|
* misrepresented as being the original software and/or documentation.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------
|
|
|
|
*
|
2000-10-09 13:29:00 +00:00
|
|
|
* i4b_ifpi_pci.c: AVM Fritz!Card PCI hardware driver
|
|
|
|
* --------------------------------------------------
|
1999-12-14 20:48:35 +00:00
|
|
|
*
|
2000-10-09 13:29:00 +00:00
|
|
|
* $Id: i4b_ifpi_pci.c,v 1.4 2000/06/02 11:58:56 hm Exp $
|
1999-12-14 20:48:35 +00:00
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1999-03-07 16:08:20 +00:00
|
|
|
*
|
2001-01-15 14:54:43 +00:00
|
|
|
* last edit-date: [Fri Jan 12 17:01:26 2001]
|
1999-03-07 16:08:20 +00:00
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
#include "ifpi.h"
|
1999-03-07 16:08:20 +00:00
|
|
|
#include "opt_i4b.h"
|
|
|
|
|
2002-06-13 06:04:28 +00:00
|
|
|
#if (NIFPI > 0)
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
#include <machine/bus.h>
|
1999-12-14 20:48:35 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
|
|
|
|
#include <pci/pcireg.h>
|
|
|
|
#include <pci/pcivar.h>
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
|
|
|
|
#include <machine/i4b_debug.h>
|
|
|
|
#include <machine/i4b_ioctl.h>
|
2000-10-09 13:29:00 +00:00
|
|
|
#include <machine/i4b_trace.h>
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
#include <i4b/include/i4b_global.h>
|
|
|
|
#include <i4b/include/i4b_mbuf.h>
|
|
|
|
|
|
|
|
#include <i4b/layer1/i4b_l1.h>
|
2000-10-09 13:29:00 +00:00
|
|
|
#include <i4b/layer1/isic/i4b_isic.h>
|
|
|
|
#include <i4b/layer1/isic/i4b_isac.h>
|
|
|
|
#include <i4b/layer1/isic/i4b_hscx.h>
|
|
|
|
|
|
|
|
#include <i4b/layer1/ifpi/i4b_ifpi_ext.h>
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
#define PCI_AVMA1_VID 0x1244
|
|
|
|
#define PCI_AVMA1_DID 0x0a00
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/* prototypes */
|
1999-12-14 20:48:35 +00:00
|
|
|
static void avma1pp_disable(device_t);
|
|
|
|
|
|
|
|
static void avma1pp_intr(void *);
|
|
|
|
static void hscx_write_reg(int, u_int, u_int, struct l1_softc *);
|
|
|
|
static u_char hscx_read_reg(int, u_int, struct l1_softc *);
|
|
|
|
static u_int hscx_read_reg_int(int, u_int, struct l1_softc *);
|
|
|
|
static void hscx_read_fifo(int, void *, size_t, struct l1_softc *);
|
|
|
|
static void hscx_write_fifo(int, void *, size_t, struct l1_softc *);
|
|
|
|
static void avma1pp_hscx_int_handler(struct l1_softc *);
|
|
|
|
static void avma1pp_hscx_intr(int, u_int, struct l1_softc *);
|
|
|
|
static void avma1pp_init_linktab(struct l1_softc *);
|
1999-03-07 16:08:20 +00:00
|
|
|
static void avma1pp_bchannel_setup(int, int, int, int);
|
|
|
|
static void avma1pp_bchannel_start(int, int);
|
1999-12-14 20:48:35 +00:00
|
|
|
static void avma1pp_hscx_init(struct l1_softc *, int, int);
|
1999-03-07 16:08:20 +00:00
|
|
|
static void avma1pp_bchannel_stat(int, int, bchan_statistics_t *);
|
|
|
|
static void avma1pp_set_linktab(int, int, drvr_link_t *);
|
|
|
|
static isdn_link_t * avma1pp_ret_linktab(int, int);
|
1999-12-14 20:48:35 +00:00
|
|
|
static int avma1pp_pci_probe(device_t);
|
2000-10-09 13:29:00 +00:00
|
|
|
static int avma1pp_hscx_fifo(l1_bchan_state_t *, struct l1_softc *);
|
|
|
|
int avma1pp_attach_avma1pp(device_t);
|
|
|
|
static void ifpi_isac_intr(struct l1_softc *sc);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
static device_method_t avma1pp_pci_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, avma1pp_pci_probe),
|
2000-10-09 13:29:00 +00:00
|
|
|
DEVMETHOD(device_attach, avma1pp_attach_avma1pp),
|
1999-12-14 20:48:35 +00:00
|
|
|
DEVMETHOD(device_shutdown, avma1pp_disable),
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
/* bus interface */
|
|
|
|
DEVMETHOD(bus_print_child, bus_generic_print_child),
|
|
|
|
DEVMETHOD(bus_driver_added, bus_generic_driver_added),
|
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
#if 0 /* use what's in l1_softc */
|
1999-12-14 20:48:35 +00:00
|
|
|
/* a minimal softc for the Fritz!Card PCI */
|
|
|
|
struct avma1pp_softc
|
|
|
|
{
|
|
|
|
bus_space_handle_t avma1pp_bhandle;
|
|
|
|
bus_space_tag_t avma1pp_btag;
|
|
|
|
void *avma1pp_intrhand;
|
|
|
|
struct resource *avma1pp_irq;
|
|
|
|
struct resource *avma1pp_res;
|
2000-10-09 13:29:00 +00:00
|
|
|
/* pointer to ifpi_sc */
|
1999-12-14 20:48:35 +00:00
|
|
|
struct l1_softc *avma1pp_isc;
|
|
|
|
};
|
2000-10-09 13:29:00 +00:00
|
|
|
#endif
|
1999-12-14 20:48:35 +00:00
|
|
|
|
|
|
|
static driver_t avma1pp_pci_driver = {
|
2000-10-09 13:29:00 +00:00
|
|
|
"ifpi",
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_pci_methods,
|
2000-10-09 13:29:00 +00:00
|
|
|
sizeof(struct l1_softc)
|
1999-12-14 20:48:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t avma1pp_pci_devclass;
|
|
|
|
|
|
|
|
DRIVER_MODULE(avma1pp, pci, avma1pp_pci_driver, avma1pp_pci_devclass, 0, 0);
|
1999-05-20 10:14:57 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
/* jump table for multiplex routines */
|
|
|
|
|
|
|
|
struct i4b_l1mux_func avma1pp_l1mux_func = {
|
|
|
|
avma1pp_ret_linktab,
|
|
|
|
avma1pp_set_linktab,
|
|
|
|
ifpi_mph_command_req,
|
|
|
|
ifpi_ph_data_req,
|
|
|
|
ifpi_ph_activate_req,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct l1_softc *ifpi_scp[IFPI_MAXUNIT];
|
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* AVM PCI Fritz!Card special registers
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* register offsets from i/o base
|
|
|
|
*/
|
|
|
|
#define STAT0_OFFSET 0x02
|
|
|
|
#define STAT1_OFFSET 0x03
|
|
|
|
#define ADDR_REG_OFFSET 0x04
|
|
|
|
/*#define MODREG_OFFSET 0x06
|
|
|
|
#define VERREG_OFFSET 0x07*/
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/* these 2 are used to select an ISAC register set */
|
|
|
|
#define ISAC_LO_REG_OFFSET 0x04
|
|
|
|
#define ISAC_HI_REG_OFFSET 0x06
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/* offset higher than this goes to the HI register set */
|
|
|
|
#define MAX_LO_REG_OFFSET 0x2f
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/* mask for the offset */
|
|
|
|
#define ISAC_REGSET_MASK 0x0f
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/* the offset from the base to the ISAC registers */
|
|
|
|
#define ISAC_REG_OFFSET 0x10
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/* the offset from the base to the ISAC FIFO */
|
|
|
|
#define ISAC_FIFO 0x02
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/* not really the HSCX, but sort of */
|
|
|
|
#define HSCX_FIFO 0x00
|
|
|
|
#define HSCX_STAT 0x04
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/*
|
|
|
|
* AVM PCI Status Latch 0 read only bits
|
|
|
|
*/
|
|
|
|
#define ASL_IRQ_ISAC 0x01 /* ISAC interrupt, active low */
|
|
|
|
#define ASL_IRQ_HSCX 0x02 /* HSX interrupt, active low */
|
|
|
|
#define ASL_IRQ_TIMER 0x04 /* Timer interrupt, active low */
|
|
|
|
#define ASL_IRQ_BCHAN ASL_IRQ_HSCX
|
|
|
|
/* actually active LOW */
|
|
|
|
#define ASL_IRQ_Pending (ASL_IRQ_ISAC | ASL_IRQ_HSCX | ASL_IRQ_TIMER)
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/*
|
|
|
|
* AVM Status Latch 0 write only bits
|
|
|
|
*/
|
|
|
|
#define ASL_RESET_ALL 0x01 /* reset siemens IC's, active 1 */
|
|
|
|
#define ASL_TIMERDISABLE 0x02 /* active high */
|
|
|
|
#define ASL_TIMERRESET 0x04 /* active high */
|
|
|
|
#define ASL_ENABLE_INT 0x08 /* active high */
|
|
|
|
#define ASL_TESTBIT 0x10 /* active high */
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/*
|
|
|
|
* AVM Status Latch 1 write only bits
|
|
|
|
*/
|
|
|
|
#define ASL1_INTSEL 0x0f /* active high */
|
|
|
|
#define ASL1_ENABLE_IOM 0x80 /* active high */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "HSCX" mode bits
|
|
|
|
*/
|
|
|
|
#define HSCX_MODE_ITF_FLG 0x01
|
|
|
|
#define HSCX_MODE_TRANS 0x02
|
|
|
|
#define HSCX_MODE_CCR_7 0x04
|
|
|
|
#define HSCX_MODE_CCR_16 0x08
|
|
|
|
#define HSCX_MODE_TESTLOOP 0x80
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "HSCX" status bits
|
|
|
|
*/
|
|
|
|
#define HSCX_STAT_RME 0x01
|
|
|
|
#define HSCX_STAT_RDO 0x10
|
|
|
|
#define HSCX_STAT_CRCVFRRAB 0x0E
|
|
|
|
#define HSCX_STAT_CRCVFR 0x06
|
|
|
|
#define HSCX_STAT_RML_MASK 0x3f00
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "HSCX" interrupt bits
|
|
|
|
*/
|
|
|
|
#define HSCX_INT_XPR 0x80
|
|
|
|
#define HSCX_INT_XDU 0x40
|
|
|
|
#define HSCX_INT_RPR 0x20
|
|
|
|
#define HSCX_INT_MASK 0xE0
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "HSCX" command bits
|
|
|
|
*/
|
|
|
|
#define HSCX_CMD_XRS 0x80
|
|
|
|
#define HSCX_CMD_XME 0x01
|
|
|
|
#define HSCX_CMD_RRS 0x20
|
|
|
|
#define HSCX_CMD_XML_MASK 0x3f00
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Commands and parameters are sent to the "HSCX" as a long, but the
|
|
|
|
* fields are handled as bytes.
|
|
|
|
*
|
|
|
|
* The long contains:
|
|
|
|
* (prot << 16)|(txl << 8)|cmd
|
|
|
|
*
|
|
|
|
* where:
|
|
|
|
* prot = protocol to use
|
|
|
|
* txl = transmit length
|
|
|
|
* cmd = the command to be executed
|
|
|
|
*
|
1999-12-14 20:48:35 +00:00
|
|
|
* The fields are defined as u_char in struct l1_softc.
|
1999-03-07 16:08:20 +00:00
|
|
|
*
|
|
|
|
* Macro to coalesce the byte fields into a u_int
|
|
|
|
*/
|
|
|
|
#define AVMA1PPSETCMDLONG(f) (f) = ((sc->avma1pp_cmd) | (sc->avma1pp_txl << 8) \
|
|
|
|
| (sc->avma1pp_prot << 16))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* to prevent deactivating the "HSCX" when both channels are active we
|
|
|
|
* define an HSCX_ACTIVE flag which is or'd into the channel's state
|
|
|
|
* flag in avma1pp_bchannel_setup upon active and cleared upon deactivation.
|
|
|
|
* It is set high to allow room for new flags.
|
|
|
|
*/
|
|
|
|
#define HSCX_AVMA1PP_ACTIVE 0x1000
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* AVM read fifo routines
|
|
|
|
*---------------------------------------------------------------------------*/
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-05-20 10:14:57 +00:00
|
|
|
|
|
|
|
switch (what) {
|
|
|
|
case ISIC_WHAT_ISAC:
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, ISAC_FIFO);
|
|
|
|
bus_space_read_multi_1(btag, bhandle, ISAC_REG_OFFSET, buf, size);
|
1999-05-20 10:14:57 +00:00
|
|
|
break;
|
|
|
|
case ISIC_WHAT_HSCXA:
|
|
|
|
hscx_read_fifo(0, buf, size, sc);
|
|
|
|
break;
|
|
|
|
case ISIC_WHAT_HSCXB:
|
|
|
|
hscx_read_fifo(1, buf, size, sc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
hscx_read_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
|
1999-05-20 10:14:57 +00:00
|
|
|
{
|
|
|
|
u_int32_t *ip;
|
|
|
|
size_t cnt;
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-12-14 20:48:35 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_4(btag, bhandle, ADDR_REG_OFFSET, chan);
|
1999-05-20 10:14:57 +00:00
|
|
|
ip = (u_int32_t *)buf;
|
|
|
|
cnt = 0;
|
|
|
|
/* what if len isn't a multiple of sizeof(int) and buf is */
|
|
|
|
/* too small ???? */
|
|
|
|
while (cnt < len)
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
*ip++ = bus_space_read_4(btag, bhandle, ISAC_REG_OFFSET);
|
1999-05-20 10:14:57 +00:00
|
|
|
cnt += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* AVM write fifo routines
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
switch (what) {
|
|
|
|
case ISIC_WHAT_ISAC:
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, ISAC_FIFO);
|
|
|
|
bus_space_write_multi_1(btag, bhandle, ISAC_REG_OFFSET, (u_int8_t*)buf, size);
|
1999-05-20 10:14:57 +00:00
|
|
|
break;
|
|
|
|
case ISIC_WHAT_HSCXA:
|
|
|
|
hscx_write_fifo(0, buf, size, sc);
|
|
|
|
break;
|
|
|
|
case ISIC_WHAT_HSCXB:
|
|
|
|
hscx_write_fifo(1, buf, size, sc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
hscx_write_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
|
1999-05-20 10:14:57 +00:00
|
|
|
{
|
|
|
|
u_int32_t *ip;
|
|
|
|
size_t cnt;
|
1999-12-14 20:48:35 +00:00
|
|
|
l1_bchan_state_t *Bchan = &sc->sc_chan[chan];
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-12-14 20:48:35 +00:00
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
|
|
|
|
sc->avma1pp_cmd &= ~HSCX_CMD_XME;
|
|
|
|
sc->avma1pp_txl = 0;
|
1999-08-06 14:05:10 +00:00
|
|
|
if (Bchan->out_mbuf_cur == NULL)
|
1999-05-20 10:14:57 +00:00
|
|
|
{
|
|
|
|
if (Bchan->bprot != BPROT_NONE)
|
|
|
|
sc->avma1pp_cmd |= HSCX_CMD_XME;
|
|
|
|
}
|
1999-08-06 14:05:10 +00:00
|
|
|
if (len != sc->sc_bfifolen)
|
|
|
|
sc->avma1pp_txl = len;
|
1999-05-20 10:14:57 +00:00
|
|
|
|
|
|
|
cnt = 0; /* borrow cnt */
|
|
|
|
AVMA1PPSETCMDLONG(cnt);
|
|
|
|
hscx_write_reg(chan, HSCX_STAT, cnt, sc);
|
|
|
|
|
|
|
|
ip = (u_int32_t *)buf;
|
|
|
|
cnt = 0;
|
|
|
|
while (cnt < len)
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_4(btag, bhandle, ISAC_REG_OFFSET, *ip);
|
1999-05-20 10:14:57 +00:00
|
|
|
ip++;
|
|
|
|
cnt += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* AVM write register routines
|
|
|
|
*---------------------------------------------------------------------------*/
|
1999-05-20 10:14:57 +00:00
|
|
|
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
|
1999-05-20 10:14:57 +00:00
|
|
|
{
|
|
|
|
u_char reg_bank;
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-12-14 20:48:35 +00:00
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
switch (what) {
|
|
|
|
case ISIC_WHAT_ISAC:
|
|
|
|
reg_bank = (offs > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET;
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
|
|
|
printf("write_reg bank %d off %ld.. ", (int)reg_bank, (long)offs);
|
|
|
|
#endif
|
|
|
|
/* set the register bank */
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, reg_bank);
|
|
|
|
bus_space_write_1(btag, bhandle, ISAC_REG_OFFSET + (offs & ISAC_REGSET_MASK), data);
|
1999-05-20 10:14:57 +00:00
|
|
|
break;
|
|
|
|
case ISIC_WHAT_HSCXA:
|
|
|
|
hscx_write_reg(0, offs, data, sc);
|
|
|
|
break;
|
|
|
|
case ISIC_WHAT_HSCXB:
|
|
|
|
hscx_write_reg(1, offs, data, sc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
hscx_write_reg(int chan, u_int off, u_int val, struct l1_softc *sc)
|
1999-05-20 10:14:57 +00:00
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-12-14 20:48:35 +00:00
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
/* point at the correct channel */
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_4(btag, bhandle, ADDR_REG_OFFSET, chan);
|
|
|
|
bus_space_write_4(btag, bhandle, ISAC_REG_OFFSET + off, val);
|
1999-05-20 10:14:57 +00:00
|
|
|
}
|
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* AVM read register routines
|
|
|
|
*---------------------------------------------------------------------------*/
|
1999-05-20 10:14:57 +00:00
|
|
|
static u_int8_t
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
|
1999-05-20 10:14:57 +00:00
|
|
|
{
|
|
|
|
u_char reg_bank;
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-12-14 20:48:35 +00:00
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
switch (what) {
|
|
|
|
case ISIC_WHAT_ISAC:
|
|
|
|
reg_bank = (offs > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET;
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
|
|
|
printf("read_reg bank %d off %ld.. ", (int)reg_bank, (long)offs);
|
|
|
|
#endif
|
|
|
|
/* set the register bank */
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, reg_bank);
|
|
|
|
return(bus_space_read_1(btag, bhandle, ISAC_REG_OFFSET +
|
1999-05-20 10:14:57 +00:00
|
|
|
(offs & ISAC_REGSET_MASK)));
|
|
|
|
case ISIC_WHAT_HSCXA:
|
|
|
|
return hscx_read_reg(0, offs, sc);
|
|
|
|
case ISIC_WHAT_HSCXB:
|
|
|
|
return hscx_read_reg(1, offs, sc);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
static u_char
|
1999-12-14 20:48:35 +00:00
|
|
|
hscx_read_reg(int chan, u_int off, struct l1_softc *sc)
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
|
|
|
return(hscx_read_reg_int(chan, off, sc) & 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-05-20 10:14:57 +00:00
|
|
|
* need to be able to return an int because the RBCH is in the 2nd
|
1999-03-07 16:08:20 +00:00
|
|
|
* byte.
|
|
|
|
*/
|
|
|
|
static u_int
|
1999-12-14 20:48:35 +00:00
|
|
|
hscx_read_reg_int(int chan, u_int off, struct l1_softc *sc)
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-12-14 20:48:35 +00:00
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/* point at the correct channel */
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_4(btag, bhandle, ADDR_REG_OFFSET, chan);
|
|
|
|
return(bus_space_read_4(btag, bhandle, ISAC_REG_OFFSET + off));
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
1999-12-14 20:48:35 +00:00
|
|
|
* avma1pp_probe - probe for a card
|
1999-03-07 16:08:20 +00:00
|
|
|
*---------------------------------------------------------------------------*/
|
1999-12-14 20:48:35 +00:00
|
|
|
static int
|
|
|
|
avma1pp_pci_probe(dev)
|
|
|
|
device_t dev;
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
1999-12-14 20:48:35 +00:00
|
|
|
u_int16_t did, vid;
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
vid = pci_get_vendor(dev);
|
|
|
|
did = pci_get_device(dev);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
if ((vid == PCI_AVMA1_VID) && (did == PCI_AVMA1_DID)) {
|
|
|
|
device_set_desc(dev, "AVM Fritz!Card PCI");
|
1999-03-07 16:08:20 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
return(ENXIO);
|
|
|
|
}
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
/*---------------------------------------------------------------------------*
|
2000-10-09 13:29:00 +00:00
|
|
|
* avma1pp_attach_avma1pp - attach Fritz!Card PCI
|
1999-12-14 20:48:35 +00:00
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
int
|
2000-10-09 13:29:00 +00:00
|
|
|
avma1pp_attach_avma1pp(device_t dev)
|
1999-12-14 20:48:35 +00:00
|
|
|
{
|
|
|
|
struct l1_softc *sc;
|
|
|
|
u_int v;
|
2000-10-09 13:29:00 +00:00
|
|
|
int unit, error = 0;
|
1999-12-14 20:48:35 +00:00
|
|
|
int s;
|
|
|
|
u_int16_t did, vid;
|
2000-10-09 13:29:00 +00:00
|
|
|
void *ih = 0;
|
|
|
|
bus_space_handle_t bhandle;
|
|
|
|
bus_space_tag_t btag;
|
2001-01-09 15:01:42 +00:00
|
|
|
l1_bchan_state_t *chan;
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
s = splimp();
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
vid = pci_get_vendor(dev);
|
|
|
|
did = pci_get_device(dev);
|
2000-10-09 13:29:00 +00:00
|
|
|
sc = device_get_softc(dev);
|
1999-12-14 20:48:35 +00:00
|
|
|
unit = device_get_unit(dev);
|
2000-10-09 13:29:00 +00:00
|
|
|
bzero(sc, sizeof(struct l1_softc));
|
1999-03-07 16:08:20 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
/* probably not really required */
|
|
|
|
if(unit > IFPI_MAXUNIT) {
|
|
|
|
printf("avma1pp%d: Error, unit > IFPI_MAXUNIT!\n", unit);
|
1999-12-14 20:48:35 +00:00
|
|
|
splx(s);
|
|
|
|
return(ENXIO);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
if ((vid != PCI_AVMA1_VID) && (did != PCI_AVMA1_DID)) {
|
|
|
|
printf("avma1pp%d: unknown device!?\n", unit);
|
|
|
|
goto fail;
|
|
|
|
}
|
1999-03-07 16:08:20 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
ifpi_scp[unit] = sc;
|
1999-03-07 16:08:20 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
sc->sc_resources.io_rid[0] = PCIR_MAPS+4;
|
|
|
|
sc->sc_resources.io_base[0] = bus_alloc_resource(dev, SYS_RES_IOPORT,
|
|
|
|
&sc->sc_resources.io_rid[0],
|
1999-12-14 20:48:35 +00:00
|
|
|
0, ~0, 1, RF_ACTIVE);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
if (sc->sc_resources.io_base[0] == NULL) {
|
1999-12-14 20:48:35 +00:00
|
|
|
printf("avma1pp%d: couldn't map IO port\n", unit);
|
|
|
|
error = ENXIO;
|
|
|
|
goto fail;
|
|
|
|
}
|
1999-03-07 16:08:20 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
/* Allocate interrupt */
|
2000-10-09 13:29:00 +00:00
|
|
|
sc->sc_resources.irq_rid = 0;
|
|
|
|
sc->sc_resources.irq = bus_alloc_resource(dev, SYS_RES_IRQ,
|
|
|
|
&sc->sc_resources.irq_rid, 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
if (sc->sc_resources.irq == NULL) {
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, PCIR_MAPS+4, sc->sc_resources.io_base[0]);
|
1999-12-14 20:48:35 +00:00
|
|
|
printf("avma1pp%d: couldn't map interrupt\n", unit);
|
|
|
|
error = ENXIO;
|
|
|
|
goto fail;
|
|
|
|
}
|
1999-03-07 16:08:20 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
error = bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET, avma1pp_intr, sc, &ih);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
if (error) {
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_resources.irq);
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, PCIR_MAPS+4, sc->sc_resources.io_base[0]);
|
1999-12-14 20:48:35 +00:00
|
|
|
printf("avma1pp%d: couldn't set up irq\n", unit);
|
|
|
|
goto fail;
|
|
|
|
}
|
1999-03-07 16:08:20 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
sc->sc_unit = unit;
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
/* end of new-bus stuff */
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
ISAC_BASE = (caddr_t)ISIC_WHAT_ISAC;
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
HSCX_A_BASE = (caddr_t)ISIC_WHAT_HSCXA;
|
|
|
|
HSCX_B_BASE = (caddr_t)ISIC_WHAT_HSCXB;
|
1999-05-20 10:14:57 +00:00
|
|
|
|
|
|
|
/* setup access routines */
|
|
|
|
|
|
|
|
sc->clearirq = NULL;
|
|
|
|
sc->readreg = avma1pp_read_reg;
|
|
|
|
sc->writereg = avma1pp_write_reg;
|
|
|
|
|
|
|
|
sc->readfifo = avma1pp_read_fifo;
|
|
|
|
sc->writefifo = avma1pp_write_fifo;
|
|
|
|
|
|
|
|
/* setup card type */
|
|
|
|
|
|
|
|
sc->sc_cardtyp = CARD_TYPEP_AVMA1PCI;
|
|
|
|
|
|
|
|
/* setup IOM bus type */
|
|
|
|
|
|
|
|
sc->sc_bustyp = BUS_TYPE_IOM2;
|
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
/* set up some other miscellaneous things */
|
1999-05-20 10:14:57 +00:00
|
|
|
sc->sc_ipac = 0;
|
|
|
|
sc->sc_bfifolen = HSCX_FIFO_LEN;
|
1999-12-14 20:48:35 +00:00
|
|
|
|
|
|
|
/* reset the card */
|
1999-05-20 10:14:57 +00:00
|
|
|
/* the Linux driver does this to clear any pending ISAC interrupts */
|
|
|
|
v = 0;
|
|
|
|
v = ISAC_READ(I_STAR);
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
|
|
|
printf("avma1pp_attach: I_STAR %x...", v);
|
|
|
|
#endif
|
|
|
|
v = ISAC_READ(I_MODE);
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
|
|
|
printf("avma1pp_attach: I_MODE %x...", v);
|
|
|
|
#endif
|
|
|
|
v = ISAC_READ(I_ADF2);
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
|
|
|
printf("avma1pp_attach: I_ADF2 %x...", v);
|
|
|
|
#endif
|
|
|
|
v = ISAC_READ(I_ISTA);
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
|
|
|
printf("avma1pp_attach: I_ISTA %x...", v);
|
|
|
|
#endif
|
|
|
|
if (v & ISAC_ISTA_EXI)
|
|
|
|
{
|
|
|
|
v = ISAC_READ(I_EXIR);
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
|
|
|
printf("avma1pp_attach: I_EXIR %x...", v);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
v = ISAC_READ(I_CIRR);
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
|
|
|
printf("avma1pp_attach: I_CIRR %x...", v);
|
|
|
|
#endif
|
|
|
|
ISAC_WRITE(I_MASK, 0xff);
|
|
|
|
/* the Linux driver does this to clear any pending HSCX interrupts */
|
|
|
|
v = hscx_read_reg_int(0, HSCX_STAT, sc);
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
|
|
|
printf("avma1pp_attach: 0 HSCX_STAT %x...", v);
|
|
|
|
#endif
|
|
|
|
v = hscx_read_reg_int(1, HSCX_STAT, sc);
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
|
|
|
printf("avma1pp_attach: 1 HSCX_STAT %x\n", v);
|
|
|
|
#endif
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE);
|
1999-05-20 10:14:57 +00:00
|
|
|
DELAY(SEC_DELAY/100); /* 10 ms */
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_TIMERRESET|ASL_ENABLE_INT|ASL_TIMERDISABLE);
|
1999-05-20 10:14:57 +00:00
|
|
|
DELAY(SEC_DELAY/100); /* 10 ms */
|
|
|
|
#ifdef AVMA1PCI_DEBUG
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_1(btag, bhandle, STAT1_OFFSET, ASL1_ENABLE_IOM|sc->sc_irq);
|
1999-05-20 10:14:57 +00:00
|
|
|
DELAY(SEC_DELAY/100); /* 10 ms */
|
2000-10-09 13:29:00 +00:00
|
|
|
v = bus_space_read_1(btag, bhandle, STAT1_OFFSET);
|
1999-05-20 10:14:57 +00:00
|
|
|
printf("after reset: S1 %#x\n", v);
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
v = bus_space_read_4(btag, bhandle, 0);
|
|
|
|
printf("avma1pp_attach_avma1pp: v %#x\n", v);
|
1999-05-20 10:14:57 +00:00
|
|
|
#endif
|
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
/* from here to the end would normally be done in isic_pciattach */
|
1999-05-20 10:14:57 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
printf("ifpi%d: ISAC %s (IOM-%c)\n", unit,
|
1999-05-20 10:14:57 +00:00
|
|
|
"2085 Version A1/A2 or 2086/2186 Version 1.1",
|
|
|
|
sc->sc_bustyp == BUS_TYPE_IOM1 ? '1' : '2');
|
|
|
|
|
|
|
|
/* init the ISAC */
|
2000-10-09 13:29:00 +00:00
|
|
|
ifpi_isac_init(sc);
|
1999-05-20 10:14:57 +00:00
|
|
|
|
2001-01-15 14:54:43 +00:00
|
|
|
#if defined (__FreeBSD__) && __FreeBSD__ > 4
|
2001-01-09 15:01:42 +00:00
|
|
|
/* Init the channel mutexes */
|
|
|
|
chan = &sc->sc_chan[HSCX_CH_A];
|
2001-12-30 09:27:28 +00:00
|
|
|
if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
|
2002-04-04 21:03:38 +00:00
|
|
|
mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp_rx", NULL, MTX_DEF);
|
2001-12-30 09:27:28 +00:00
|
|
|
if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
|
2002-04-04 21:03:38 +00:00
|
|
|
mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp_tx", NULL, MTX_DEF);
|
2001-01-09 15:01:42 +00:00
|
|
|
chan = &sc->sc_chan[HSCX_CH_B];
|
2001-12-30 09:27:28 +00:00
|
|
|
if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
|
2002-04-04 21:03:38 +00:00
|
|
|
mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp_rx", NULL, MTX_DEF);
|
2001-12-30 09:27:28 +00:00
|
|
|
if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
|
2002-04-04 21:03:38 +00:00
|
|
|
mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp_tx", NULL, MTX_DEF);
|
2001-01-15 14:54:43 +00:00
|
|
|
#endif
|
2001-01-09 15:01:42 +00:00
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
/* init the "HSCX" */
|
|
|
|
avma1pp_bchannel_setup(sc->sc_unit, HSCX_CH_A, BPROT_NONE, 0);
|
|
|
|
|
|
|
|
avma1pp_bchannel_setup(sc->sc_unit, HSCX_CH_B, BPROT_NONE, 0);
|
|
|
|
|
|
|
|
/* can't use the normal B-Channel stuff */
|
|
|
|
avma1pp_init_linktab(sc);
|
|
|
|
|
|
|
|
/* set trace level */
|
|
|
|
|
|
|
|
sc->sc_trace = TRACE_OFF;
|
|
|
|
|
|
|
|
sc->sc_state = ISAC_IDLE;
|
|
|
|
|
|
|
|
sc->sc_ibuf = NULL;
|
|
|
|
sc->sc_ib = NULL;
|
|
|
|
sc->sc_ilen = 0;
|
|
|
|
|
|
|
|
sc->sc_obuf = NULL;
|
|
|
|
sc->sc_op = NULL;
|
|
|
|
sc->sc_ol = 0;
|
|
|
|
sc->sc_freeflag = 0;
|
|
|
|
|
|
|
|
sc->sc_obuf2 = NULL;
|
|
|
|
sc->sc_freeflag2 = 0;
|
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
#if defined(__FreeBSD__) && __FreeBSD__ >=3
|
|
|
|
callout_handle_init(&sc->sc_T3_callout);
|
|
|
|
callout_handle_init(&sc->sc_T4_callout);
|
|
|
|
#endif
|
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
/* init higher protocol layers */
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
i4b_l1_mph_status_ind(L0IFPIUNIT(sc->sc_unit), STI_ATTACH, sc->sc_cardtyp, &avma1pp_l1mux_func);
|
1999-05-20 10:14:57 +00:00
|
|
|
|
1999-12-14 20:48:35 +00:00
|
|
|
fail:
|
|
|
|
splx(s);
|
|
|
|
return(error);
|
1999-05-20 10:14:57 +00:00
|
|
|
}
|
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/*
|
|
|
|
* this is the real interrupt routine
|
|
|
|
*/
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_hscx_intr(int h_chan, u_int stat, struct l1_softc *sc)
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
1999-12-14 20:48:35 +00:00
|
|
|
register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
|
1999-03-07 16:08:20 +00:00
|
|
|
int activity = -1;
|
|
|
|
u_int param = 0;
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_H_IRQ, "%#x", stat);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
if((stat & HSCX_INT_XDU) && (chan->bprot != BPROT_NONE))/* xmit data underrun */
|
|
|
|
{
|
|
|
|
chan->stat_XDU++;
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_H_XFRERR, "xmit data underrun");
|
1999-03-07 16:08:20 +00:00
|
|
|
/* abort the transmission */
|
|
|
|
sc->avma1pp_txl = 0;
|
|
|
|
sc->avma1pp_cmd |= HSCX_CMD_XRS;
|
|
|
|
AVMA1PPSETCMDLONG(param);
|
|
|
|
hscx_write_reg(h_chan, HSCX_STAT, param, sc);
|
|
|
|
sc->avma1pp_cmd &= ~HSCX_CMD_XRS;
|
|
|
|
AVMA1PPSETCMDLONG(param);
|
|
|
|
hscx_write_reg(h_chan, HSCX_STAT, param, sc);
|
|
|
|
|
|
|
|
if (chan->out_mbuf_head != NULL) /* don't continue to transmit this buffer */
|
|
|
|
{
|
|
|
|
i4b_Bfreembuf(chan->out_mbuf_head);
|
|
|
|
chan->out_mbuf_cur = chan->out_mbuf_head = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-05-20 10:14:57 +00:00
|
|
|
* The following is based on examination of the Linux driver.
|
1999-03-07 16:08:20 +00:00
|
|
|
*
|
|
|
|
* The logic here is different than with a "real" HSCX; all kinds
|
|
|
|
* of information (interrupt/status bits) are in stat.
|
|
|
|
* HSCX_INT_RPR indicates a receive interrupt
|
|
|
|
* HSCX_STAT_RDO indicates an overrun condition, abort -
|
|
|
|
* otherwise read the bytes ((stat & HSCX_STZT_RML_MASK) >> 8)
|
|
|
|
* HSCX_STAT_RME indicates end-of-frame and apparently any
|
|
|
|
* CRC/framing errors are only reported in this state.
|
|
|
|
* if ((stat & HSCX_STAT_CRCVFRRAB) != HSCX_STAT_CRCVFR)
|
|
|
|
* CRC/framing error
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(stat & HSCX_INT_RPR)
|
|
|
|
{
|
|
|
|
register int fifo_data_len;
|
|
|
|
int error = 0;
|
|
|
|
/* always have to read the FIFO, so use a scratch buffer */
|
|
|
|
u_char scrbuf[HSCX_FIFO_LEN];
|
|
|
|
|
|
|
|
if(stat & HSCX_STAT_RDO)
|
|
|
|
{
|
|
|
|
chan->stat_RDO++;
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_H_XFRERR, "receive data overflow");
|
1999-03-07 16:08:20 +00:00
|
|
|
error++;
|
|
|
|
}
|
1999-12-14 20:48:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* check whether we're receiving data for an inactive B-channel
|
|
|
|
* and discard it. This appears to happen for telephony when
|
|
|
|
* both B-channels are active and one is deactivated. Since
|
|
|
|
* it is not really possible to deactivate the channel in that
|
|
|
|
* case (the ASIC seems to deactivate _both_ channels), the
|
|
|
|
* "deactivated" channel keeps receiving data which can lead
|
|
|
|
* to exhaustion of mbufs and a kernel panic.
|
|
|
|
*
|
|
|
|
* This is a hack, but it's the only solution I can think of
|
|
|
|
* without having the documentation for the ASIC.
|
|
|
|
* GJ - 28 Nov 1999
|
|
|
|
*/
|
|
|
|
if (chan->state == HSCX_IDLE)
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_H_XFRERR, "toss data from %d", h_chan);
|
1999-12-14 20:48:35 +00:00
|
|
|
error++;
|
|
|
|
}
|
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
fifo_data_len = ((stat & HSCX_STAT_RML_MASK) >> 8);
|
|
|
|
|
|
|
|
if(fifo_data_len == 0)
|
|
|
|
fifo_data_len = sc->sc_bfifolen;
|
|
|
|
|
|
|
|
/* ALWAYS read data from HSCX fifo */
|
|
|
|
|
|
|
|
HSCX_RDFIFO(h_chan, scrbuf, fifo_data_len);
|
|
|
|
chan->rxcount += fifo_data_len;
|
|
|
|
|
|
|
|
/* all error conditions checked, now decide and take action */
|
|
|
|
|
|
|
|
if(error == 0)
|
|
|
|
{
|
|
|
|
if(chan->in_mbuf == NULL)
|
|
|
|
{
|
|
|
|
if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
|
|
|
|
panic("L1 avma1pp_hscx_intr: RME, cannot allocate mbuf!\n");
|
|
|
|
chan->in_cbptr = chan->in_mbuf->m_data;
|
|
|
|
chan->in_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((chan->in_len + fifo_data_len) <= BCH_MAX_DATALEN)
|
|
|
|
{
|
1999-05-20 10:14:57 +00:00
|
|
|
/* OK to copy the data */
|
1999-03-07 16:08:20 +00:00
|
|
|
bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
|
|
|
|
chan->in_cbptr += fifo_data_len;
|
1999-05-20 10:14:57 +00:00
|
|
|
chan->in_len += fifo_data_len;
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
/* setup mbuf data length */
|
|
|
|
|
|
|
|
chan->in_mbuf->m_len = chan->in_len;
|
|
|
|
chan->in_mbuf->m_pkthdr.len = chan->in_len;
|
|
|
|
|
|
|
|
if(sc->sc_trace & TRACE_B_RX)
|
|
|
|
{
|
|
|
|
i4b_trace_hdr_t hdr;
|
2000-10-09 13:29:00 +00:00
|
|
|
hdr.unit = L0IFPIUNIT(sc->sc_unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
|
|
|
|
hdr.dir = FROM_NT;
|
|
|
|
hdr.count = ++sc->sc_trace_bcount;
|
|
|
|
MICROTIME(hdr.time);
|
2000-10-09 13:29:00 +00:00
|
|
|
i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (stat & HSCX_STAT_RME)
|
|
|
|
{
|
|
|
|
if((stat & HSCX_STAT_CRCVFRRAB) == HSCX_STAT_CRCVFR)
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
(*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
activity = ACT_RX;
|
|
|
|
|
|
|
|
/* mark buffer ptr as unused */
|
|
|
|
|
|
|
|
chan->in_mbuf = NULL;
|
|
|
|
chan->in_cbptr = NULL;
|
|
|
|
chan->in_len = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chan->stat_CRC++;
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_H_XFRERR, "CRC/RAB");
|
1999-03-07 16:08:20 +00:00
|
|
|
if (chan->in_mbuf != NULL)
|
|
|
|
{
|
|
|
|
i4b_Bfreembuf(chan->in_mbuf);
|
|
|
|
chan->in_mbuf = NULL;
|
|
|
|
chan->in_cbptr = NULL;
|
|
|
|
chan->in_len = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* END enough space in mbuf */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(chan->bprot == BPROT_NONE)
|
|
|
|
{
|
|
|
|
/* setup mbuf data length */
|
|
|
|
|
|
|
|
chan->in_mbuf->m_len = chan->in_len;
|
|
|
|
chan->in_mbuf->m_pkthdr.len = chan->in_len;
|
|
|
|
|
|
|
|
if(sc->sc_trace & TRACE_B_RX)
|
|
|
|
{
|
|
|
|
i4b_trace_hdr_t hdr;
|
2000-10-09 13:29:00 +00:00
|
|
|
hdr.unit = L0IFPIUNIT(sc->sc_unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
|
|
|
|
hdr.dir = FROM_NT;
|
|
|
|
hdr.count = ++sc->sc_trace_bcount;
|
|
|
|
MICROTIME(hdr.time);
|
2000-10-09 13:29:00 +00:00
|
|
|
i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
if(!(i4b_l1_bchan_tel_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len)))
|
1999-12-14 20:48:35 +00:00
|
|
|
activity = ACT_RX;
|
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
/* move rx'd data to rx queue */
|
|
|
|
|
2001-01-15 14:54:43 +00:00
|
|
|
#if defined (__FreeBSD__) && __FreeBSD__ > 4
|
Lock down the network interface queues. The queue mutex must be obtained
before adding/removing packets from the queue. Also, the if_obytes and
if_omcasts fields should only be manipulated under protection of the mutex.
IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on
the queue. An IF_LOCK macro is provided, as well as the old (mutex-less)
versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which
needs them, but their use is discouraged.
Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF,
which takes care of locking/enqueue, and also statistics updating/start
if necessary.
2000-11-25 07:35:38 +00:00
|
|
|
(void) IF_HANDOFF(&chan->rx_queue, chan->in_mbuf, NULL);
|
2001-01-15 14:54:43 +00:00
|
|
|
#else
|
|
|
|
if(!(IF_QFULL(&chan->rx_queue)))
|
|
|
|
{
|
|
|
|
IF_ENQUEUE(&chan->rx_queue, chan->in_mbuf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i4b_Bfreembuf(chan->in_mbuf);
|
|
|
|
}
|
|
|
|
#endif
|
1999-12-14 20:48:35 +00:00
|
|
|
/* signal upper layer that data are available */
|
2000-10-09 13:29:00 +00:00
|
|
|
(*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
/* alloc new buffer */
|
|
|
|
|
|
|
|
if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
|
|
|
|
panic("L1 avma1pp_hscx_intr: RPF, cannot allocate new mbuf!\n");
|
|
|
|
|
|
|
|
/* setup new data ptr */
|
|
|
|
|
|
|
|
chan->in_cbptr = chan->in_mbuf->m_data;
|
|
|
|
|
|
|
|
/* OK to copy the data */
|
|
|
|
bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
|
|
|
|
|
|
|
|
chan->in_cbptr += fifo_data_len;
|
|
|
|
chan->in_len = fifo_data_len;
|
|
|
|
|
|
|
|
chan->rxcount += fifo_data_len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_H_XFRERR, "RAWHDLC rx buffer overflow in RPF, in_len=%d", chan->in_len);
|
1999-03-07 16:08:20 +00:00
|
|
|
chan->in_cbptr = chan->in_mbuf->m_data;
|
|
|
|
chan->in_len = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* if(error == 0) */
|
|
|
|
else
|
|
|
|
{
|
1999-05-20 10:14:57 +00:00
|
|
|
/* land here for RDO */
|
1999-03-07 16:08:20 +00:00
|
|
|
if (chan->in_mbuf != NULL)
|
|
|
|
{
|
|
|
|
i4b_Bfreembuf(chan->in_mbuf);
|
|
|
|
chan->in_mbuf = NULL;
|
|
|
|
chan->in_cbptr = NULL;
|
|
|
|
chan->in_len = 0;
|
|
|
|
}
|
|
|
|
sc->avma1pp_txl = 0;
|
|
|
|
sc->avma1pp_cmd |= HSCX_CMD_RRS;
|
|
|
|
AVMA1PPSETCMDLONG(param);
|
|
|
|
hscx_write_reg(h_chan, HSCX_STAT, param, sc);
|
|
|
|
sc->avma1pp_cmd &= ~HSCX_CMD_RRS;
|
|
|
|
AVMA1PPSETCMDLONG(param);
|
|
|
|
hscx_write_reg(h_chan, HSCX_STAT, param, sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* transmit fifo empty, new data can be written to fifo */
|
|
|
|
|
|
|
|
if(stat & HSCX_INT_XPR)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* for a description what is going on here, please have
|
|
|
|
* a look at isic_bchannel_start() in i4b_bchan.c !
|
|
|
|
*/
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_H_IRQ, "unit %d, chan %d - XPR, Tx Fifo Empty!", sc->sc_unit, h_chan);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
if(chan->out_mbuf_cur == NULL) /* last frame is transmitted */
|
|
|
|
{
|
|
|
|
IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
|
|
|
|
|
|
|
|
if(chan->out_mbuf_head == NULL)
|
|
|
|
{
|
|
|
|
chan->state &= ~HSCX_TX_ACTIVE;
|
2000-10-09 13:29:00 +00:00
|
|
|
(*chan->isic_drvr_linktab->bch_tx_queue_empty)(chan->isic_drvr_linktab->unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chan->state |= HSCX_TX_ACTIVE;
|
|
|
|
chan->out_mbuf_cur = chan->out_mbuf_head;
|
|
|
|
chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
|
|
|
|
chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
|
|
|
|
|
|
|
|
if(sc->sc_trace & TRACE_B_TX)
|
|
|
|
{
|
|
|
|
i4b_trace_hdr_t hdr;
|
2000-10-09 13:29:00 +00:00
|
|
|
hdr.unit = L0IFPIUNIT(sc->sc_unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
|
|
|
|
hdr.dir = FROM_TE;
|
|
|
|
hdr.count = ++sc->sc_trace_bcount;
|
|
|
|
MICROTIME(hdr.time);
|
2000-10-09 13:29:00 +00:00
|
|
|
i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(chan->bprot == BPROT_NONE)
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
|
1999-03-07 16:08:20 +00:00
|
|
|
activity = ACT_TX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
activity = ACT_TX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
avma1pp_hscx_fifo(chan, sc);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* call timeout handling routine */
|
|
|
|
|
|
|
|
if(activity == ACT_RX || activity == ACT_TX)
|
2000-10-09 13:29:00 +00:00
|
|
|
(*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this is the main routine which checks each channel and then calls
|
|
|
|
* the real interrupt routine as appropriate
|
|
|
|
*/
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_hscx_int_handler(struct l1_softc *sc)
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
|
|
|
u_int stat;
|
|
|
|
|
|
|
|
/* has to be a u_int because the byte count is in the 2nd byte */
|
|
|
|
stat = hscx_read_reg_int(0, HSCX_STAT, sc);
|
|
|
|
if (stat & HSCX_INT_MASK)
|
|
|
|
avma1pp_hscx_intr(0, stat, sc);
|
|
|
|
stat = hscx_read_reg_int(1, HSCX_STAT, sc);
|
|
|
|
if (stat & HSCX_INT_MASK)
|
|
|
|
avma1pp_hscx_intr(1, stat, sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_disable(device_t dev)
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
struct l1_softc *sc = device_get_softc(dev);
|
|
|
|
bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-12-14 20:48:35 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_intr(void *xsc)
|
1999-05-20 10:14:57 +00:00
|
|
|
{
|
1999-03-07 16:08:20 +00:00
|
|
|
u_char stat;
|
1999-12-14 20:48:35 +00:00
|
|
|
struct l1_softc *sc;
|
2000-10-09 13:29:00 +00:00
|
|
|
bus_space_handle_t bhandle;
|
|
|
|
bus_space_tag_t btag;
|
1999-03-07 16:08:20 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
sc = xsc;
|
|
|
|
bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
|
|
|
|
btag = rman_get_bustag(sc->sc_resources.io_base[0]);
|
1999-12-14 20:48:35 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
stat = bus_space_read_1(btag, bhandle, STAT0_OFFSET);
|
|
|
|
NDBGL1(L1_H_IRQ, "stat %x", stat);
|
1999-03-07 16:08:20 +00:00
|
|
|
/* was there an interrupt from this card ? */
|
|
|
|
if ((stat & ASL_IRQ_Pending) == ASL_IRQ_Pending)
|
|
|
|
return; /* no */
|
|
|
|
/* interrupts are low active */
|
|
|
|
if (!(stat & ASL_IRQ_TIMER))
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_H_IRQ, "timer interrupt ???");
|
1999-03-07 16:08:20 +00:00
|
|
|
if (!(stat & ASL_IRQ_HSCX))
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_H_IRQ, "HSCX");
|
1999-03-07 16:08:20 +00:00
|
|
|
avma1pp_hscx_int_handler(sc);
|
|
|
|
}
|
|
|
|
if (!(stat & ASL_IRQ_ISAC))
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_H_IRQ, "ISAC");
|
|
|
|
ifpi_isac_intr(sc);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_hscx_init(struct l1_softc *sc, int h_chan, int activate)
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
1999-12-14 20:48:35 +00:00
|
|
|
l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
|
1999-03-07 16:08:20 +00:00
|
|
|
u_int param = 0;
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
|
|
|
|
sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
if (activate == 0)
|
|
|
|
{
|
|
|
|
/* only deactivate if both channels are idle */
|
|
|
|
if (sc->sc_chan[HSCX_CH_A].state != HSCX_IDLE ||
|
|
|
|
sc->sc_chan[HSCX_CH_B].state != HSCX_IDLE)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
|
|
|
|
sc->avma1pp_prot = HSCX_MODE_TRANS;
|
|
|
|
AVMA1PPSETCMDLONG(param);
|
|
|
|
hscx_write_reg(h_chan, HSCX_STAT, param, sc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(chan->bprot == BPROT_RHDLC)
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_BCHAN, "BPROT_RHDLC");
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
/* HDLC Frames, transparent mode 0 */
|
|
|
|
sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
|
|
|
|
sc->avma1pp_prot = HSCX_MODE_ITF_FLG;
|
|
|
|
AVMA1PPSETCMDLONG(param);
|
|
|
|
hscx_write_reg(h_chan, HSCX_STAT, param, sc);
|
|
|
|
sc->avma1pp_cmd = HSCX_CMD_XRS;
|
|
|
|
AVMA1PPSETCMDLONG(param);
|
|
|
|
hscx_write_reg(h_chan, HSCX_STAT, param, sc);
|
|
|
|
sc->avma1pp_cmd = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_BCHAN, "BPROT_NONE??");
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
/* Raw Telephony, extended transparent mode 1 */
|
|
|
|
sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
|
|
|
|
sc->avma1pp_prot = HSCX_MODE_TRANS;
|
|
|
|
AVMA1PPSETCMDLONG(param);
|
|
|
|
hscx_write_reg(h_chan, HSCX_STAT, param, sc);
|
|
|
|
sc->avma1pp_cmd = HSCX_CMD_XRS;
|
|
|
|
AVMA1PPSETCMDLONG(param);
|
|
|
|
hscx_write_reg(h_chan, HSCX_STAT, param, sc);
|
|
|
|
sc->avma1pp_cmd = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
avma1pp_bchannel_setup(int unit, int h_chan, int bprot, int activate)
|
|
|
|
{
|
|
|
|
#ifdef __FreeBSD__
|
2000-10-09 13:29:00 +00:00
|
|
|
struct l1_softc *sc = ifpi_scp[unit];
|
1999-03-07 16:08:20 +00:00
|
|
|
#else
|
1999-12-14 20:48:35 +00:00
|
|
|
struct l1_softc *sc = isic_find_sc(unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
#endif
|
1999-12-14 20:48:35 +00:00
|
|
|
l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
int s = SPLI4B();
|
|
|
|
|
|
|
|
if(activate == 0)
|
|
|
|
{
|
|
|
|
/* deactivation */
|
1999-12-14 20:48:35 +00:00
|
|
|
chan->state = HSCX_IDLE;
|
1999-03-07 16:08:20 +00:00
|
|
|
avma1pp_hscx_init(sc, h_chan, activate);
|
|
|
|
}
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
|
|
|
|
sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
/* general part */
|
|
|
|
|
|
|
|
chan->unit = sc->sc_unit; /* unit number */
|
1999-05-20 10:14:57 +00:00
|
|
|
chan->channel = h_chan; /* B channel */
|
1999-03-07 16:08:20 +00:00
|
|
|
chan->bprot = bprot; /* B channel protocol */
|
|
|
|
chan->state = HSCX_IDLE; /* B channel state */
|
|
|
|
|
|
|
|
/* receiver part */
|
|
|
|
|
|
|
|
chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
|
Lock down the network interface queues. The queue mutex must be obtained
before adding/removing packets from the queue. Also, the if_obytes and
if_omcasts fields should only be manipulated under protection of the mutex.
IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on
the queue. An IF_LOCK macro is provided, as well as the old (mutex-less)
versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which
needs them, but their use is discouraged.
Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF,
which takes care of locking/enqueue, and also statistics updating/start
if necessary.
2000-11-25 07:35:38 +00:00
|
|
|
|
|
|
|
i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
chan->rxcount = 0; /* reset rx counter */
|
|
|
|
|
|
|
|
i4b_Bfreembuf(chan->in_mbuf); /* clean rx mbuf */
|
|
|
|
|
|
|
|
chan->in_mbuf = NULL; /* reset mbuf ptr */
|
|
|
|
chan->in_cbptr = NULL; /* reset mbuf curr ptr */
|
|
|
|
chan->in_len = 0; /* reset mbuf data len */
|
|
|
|
|
|
|
|
/* transmitter part */
|
|
|
|
|
|
|
|
chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
|
|
|
|
|
Lock down the network interface queues. The queue mutex must be obtained
before adding/removing packets from the queue. Also, the if_obytes and
if_omcasts fields should only be manipulated under protection of the mutex.
IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on
the queue. An IF_LOCK macro is provided, as well as the old (mutex-less)
versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which
needs them, but their use is discouraged.
Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF,
which takes care of locking/enqueue, and also statistics updating/start
if necessary.
2000-11-25 07:35:38 +00:00
|
|
|
i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */
|
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
chan->txcount = 0; /* reset tx counter */
|
|
|
|
|
|
|
|
i4b_Bfreembuf(chan->out_mbuf_head); /* clean tx mbuf */
|
|
|
|
|
|
|
|
chan->out_mbuf_head = NULL; /* reset head mbuf ptr */
|
|
|
|
chan->out_mbuf_cur = NULL; /* reset current mbuf ptr */
|
|
|
|
chan->out_mbuf_cur_ptr = NULL; /* reset current mbuf data ptr */
|
|
|
|
chan->out_mbuf_cur_len = 0; /* reset current mbuf data cnt */
|
|
|
|
|
|
|
|
if(activate != 0)
|
|
|
|
{
|
|
|
|
/* activation */
|
|
|
|
avma1pp_hscx_init(sc, h_chan, activate);
|
|
|
|
chan->state |= HSCX_AVMA1PP_ACTIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
avma1pp_bchannel_start(int unit, int h_chan)
|
|
|
|
{
|
|
|
|
#ifdef __FreeBSD__
|
2000-10-09 13:29:00 +00:00
|
|
|
struct l1_softc *sc = ifpi_scp[unit];
|
1999-03-07 16:08:20 +00:00
|
|
|
#else
|
1999-12-14 20:48:35 +00:00
|
|
|
struct l1_softc *sc = isic_find_sc(unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
#endif
|
1999-12-14 20:48:35 +00:00
|
|
|
register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
|
1999-03-07 16:08:20 +00:00
|
|
|
int s;
|
|
|
|
int activity = -1;
|
|
|
|
|
|
|
|
s = SPLI4B(); /* enter critical section */
|
|
|
|
if(chan->state & HSCX_TX_ACTIVE) /* already running ? */
|
|
|
|
{
|
|
|
|
splx(s);
|
|
|
|
return; /* yes, leave */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get next mbuf from queue */
|
|
|
|
|
|
|
|
IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
|
|
|
|
|
|
|
|
if(chan->out_mbuf_head == NULL) /* queue empty ? */
|
|
|
|
{
|
|
|
|
splx(s); /* leave critical section */
|
|
|
|
return; /* yes, exit */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* init current mbuf values */
|
|
|
|
|
|
|
|
chan->out_mbuf_cur = chan->out_mbuf_head;
|
|
|
|
chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
|
|
|
|
chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
|
|
|
|
|
|
|
|
/* activity indicator for timeout handling */
|
|
|
|
|
|
|
|
if(chan->bprot == BPROT_NONE)
|
|
|
|
{
|
2000-10-09 13:29:00 +00:00
|
|
|
if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
|
1999-03-07 16:08:20 +00:00
|
|
|
activity = ACT_TX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
activity = ACT_TX;
|
|
|
|
}
|
|
|
|
|
|
|
|
chan->state |= HSCX_TX_ACTIVE; /* we start transmitting */
|
|
|
|
|
|
|
|
if(sc->sc_trace & TRACE_B_TX) /* if trace, send mbuf to trace dev */
|
|
|
|
{
|
|
|
|
i4b_trace_hdr_t hdr;
|
2000-10-09 13:29:00 +00:00
|
|
|
hdr.unit = L0IFPIUNIT(sc->sc_unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
|
|
|
|
hdr.dir = FROM_TE;
|
|
|
|
hdr.count = ++sc->sc_trace_bcount;
|
|
|
|
MICROTIME(hdr.time);
|
2000-10-09 13:29:00 +00:00
|
|
|
i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
avma1pp_hscx_fifo(chan, sc);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
/* call timeout handling routine */
|
|
|
|
|
|
|
|
if(activity == ACT_RX || activity == ACT_TX)
|
2000-10-09 13:29:00 +00:00
|
|
|
(*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* return the address of isic drivers linktab
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
static isdn_link_t *
|
|
|
|
avma1pp_ret_linktab(int unit, int channel)
|
|
|
|
{
|
|
|
|
#ifdef __FreeBSD__
|
2000-10-09 13:29:00 +00:00
|
|
|
struct l1_softc *sc = ifpi_scp[unit];
|
1999-03-07 16:08:20 +00:00
|
|
|
#else
|
1999-12-14 20:48:35 +00:00
|
|
|
struct l1_softc *sc = isic_find_sc(unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
#endif
|
1999-12-14 20:48:35 +00:00
|
|
|
l1_bchan_state_t *chan = &sc->sc_chan[channel];
|
1999-03-07 16:08:20 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
return(&chan->isic_isdn_linktab);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* set the driver linktab in the b channel softc
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
avma1pp_set_linktab(int unit, int channel, drvr_link_t *dlt)
|
|
|
|
{
|
|
|
|
#ifdef __FreeBSD__
|
2000-10-09 13:29:00 +00:00
|
|
|
struct l1_softc *sc = ifpi_scp[unit];
|
1999-03-07 16:08:20 +00:00
|
|
|
#else
|
1999-12-14 20:48:35 +00:00
|
|
|
struct l1_softc *sc = isic_find_sc(unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
#endif
|
1999-12-14 20:48:35 +00:00
|
|
|
l1_bchan_state_t *chan = &sc->sc_chan[channel];
|
1999-03-07 16:08:20 +00:00
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
chan->isic_drvr_linktab = dlt;
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* initialize our local linktab
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
1999-12-14 20:48:35 +00:00
|
|
|
avma1pp_init_linktab(struct l1_softc *sc)
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
1999-12-14 20:48:35 +00:00
|
|
|
l1_bchan_state_t *chan = &sc->sc_chan[HSCX_CH_A];
|
2000-10-09 13:29:00 +00:00
|
|
|
isdn_link_t *lt = &chan->isic_isdn_linktab;
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
/* make sure the hardware driver is known to layer 4 */
|
|
|
|
/* avoid overwriting if already set */
|
|
|
|
if (ctrl_types[CTRL_PASSIVE].set_linktab == NULL)
|
|
|
|
{
|
2001-12-29 17:19:25 +00:00
|
|
|
ctrl_types[CTRL_PASSIVE].set_linktab = i4b_l1_set_linktab;
|
|
|
|
ctrl_types[CTRL_PASSIVE].get_linktab = i4b_l1_ret_linktab;
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* local setup */
|
|
|
|
lt->unit = sc->sc_unit;
|
|
|
|
lt->channel = HSCX_CH_A;
|
|
|
|
lt->bch_config = avma1pp_bchannel_setup;
|
|
|
|
lt->bch_tx_start = avma1pp_bchannel_start;
|
|
|
|
lt->bch_stat = avma1pp_bchannel_stat;
|
|
|
|
lt->tx_queue = &chan->tx_queue;
|
|
|
|
|
|
|
|
/* used by non-HDLC data transfers, i.e. telephony drivers */
|
|
|
|
lt->rx_queue = &chan->rx_queue;
|
|
|
|
|
|
|
|
/* used by HDLC data transfers, i.e. ipr and isp drivers */
|
|
|
|
lt->rx_mbuf = &chan->in_mbuf;
|
|
|
|
|
|
|
|
chan = &sc->sc_chan[HSCX_CH_B];
|
2000-10-09 13:29:00 +00:00
|
|
|
lt = &chan->isic_isdn_linktab;
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
lt->unit = sc->sc_unit;
|
|
|
|
lt->channel = HSCX_CH_B;
|
|
|
|
lt->bch_config = avma1pp_bchannel_setup;
|
|
|
|
lt->bch_tx_start = avma1pp_bchannel_start;
|
|
|
|
lt->bch_stat = avma1pp_bchannel_stat;
|
|
|
|
lt->tx_queue = &chan->tx_queue;
|
|
|
|
|
|
|
|
/* used by non-HDLC data transfers, i.e. telephony drivers */
|
|
|
|
lt->rx_queue = &chan->rx_queue;
|
|
|
|
|
|
|
|
/* used by HDLC data transfers, i.e. ipr and isp drivers */
|
|
|
|
lt->rx_mbuf = &chan->in_mbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* use this instead of isic_bchannel_stat in i4b_bchan.c because it's static
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
avma1pp_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp)
|
|
|
|
{
|
|
|
|
#ifdef __FreeBSD__
|
2000-10-09 13:29:00 +00:00
|
|
|
struct l1_softc *sc = ifpi_scp[unit];
|
1999-03-07 16:08:20 +00:00
|
|
|
#else
|
1999-12-14 20:48:35 +00:00
|
|
|
struct l1_softc *sc = isic_find_sc(unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
#endif
|
1999-12-14 20:48:35 +00:00
|
|
|
l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
|
1999-03-07 16:08:20 +00:00
|
|
|
int s;
|
|
|
|
|
|
|
|
s = SPLI4B();
|
|
|
|
|
|
|
|
bsp->outbytes = chan->txcount;
|
|
|
|
bsp->inbytes = chan->rxcount;
|
|
|
|
|
|
|
|
chan->txcount = 0;
|
|
|
|
chan->rxcount = 0;
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* fill HSCX fifo with data from the current mbuf
|
|
|
|
* Put this here until it can go into i4b_hscx.c
|
|
|
|
*---------------------------------------------------------------------------*/
|
2000-10-09 13:29:00 +00:00
|
|
|
static int
|
|
|
|
avma1pp_hscx_fifo(l1_bchan_state_t *chan, struct l1_softc *sc)
|
1999-03-07 16:08:20 +00:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
int nextlen;
|
|
|
|
int i;
|
1999-12-14 20:48:35 +00:00
|
|
|
int cmd = 0;
|
1999-05-20 10:14:57 +00:00
|
|
|
/* using a scratch buffer simplifies writing to the FIFO */
|
1999-03-07 16:08:20 +00:00
|
|
|
u_char scrbuf[HSCX_FIFO_LEN];
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
/*
|
|
|
|
* fill the HSCX tx fifo with data from the current mbuf. if
|
|
|
|
* current mbuf holds less data than HSCX fifo length, try to
|
|
|
|
* get the next mbuf from (a possible) mbuf chain. if there is
|
|
|
|
* not enough data in a single mbuf or in a chain, then this
|
|
|
|
* is the last mbuf and we tell the HSCX that it has to send
|
|
|
|
* CRC and closing flag
|
|
|
|
*/
|
|
|
|
|
1999-03-07 16:08:20 +00:00
|
|
|
while(chan->out_mbuf_cur && len != sc->sc_bfifolen)
|
|
|
|
{
|
|
|
|
nextlen = min(chan->out_mbuf_cur_len, sc->sc_bfifolen - len);
|
|
|
|
|
|
|
|
#ifdef NOTDEF
|
|
|
|
printf("i:mh=%p, mc=%p, mcp=%p, mcl=%d l=%d nl=%d # ",
|
|
|
|
chan->out_mbuf_head,
|
|
|
|
chan->out_mbuf_cur,
|
|
|
|
chan->out_mbuf_cur_ptr,
|
|
|
|
chan->out_mbuf_cur_len,
|
|
|
|
len,
|
|
|
|
nextlen);
|
|
|
|
#endif
|
|
|
|
|
1999-05-20 10:14:57 +00:00
|
|
|
cmd |= HSCX_CMDR_XTF;
|
1999-03-07 16:08:20 +00:00
|
|
|
/* collect the data in the scratch buffer */
|
|
|
|
for (i = 0; i < nextlen; i++)
|
1999-05-20 10:14:57 +00:00
|
|
|
scrbuf[i + len] = chan->out_mbuf_cur_ptr[i];
|
1999-03-07 16:08:20 +00:00
|
|
|
|
|
|
|
len += nextlen;
|
|
|
|
chan->txcount += nextlen;
|
|
|
|
|
|
|
|
chan->out_mbuf_cur_ptr += nextlen;
|
|
|
|
chan->out_mbuf_cur_len -= nextlen;
|
|
|
|
|
|
|
|
if(chan->out_mbuf_cur_len == 0)
|
|
|
|
{
|
|
|
|
if((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL)
|
|
|
|
{
|
|
|
|
chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
|
|
|
|
chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
|
|
|
|
|
|
|
|
if(sc->sc_trace & TRACE_B_TX)
|
|
|
|
{
|
|
|
|
i4b_trace_hdr_t hdr;
|
2000-10-09 13:29:00 +00:00
|
|
|
hdr.unit = L0IFPIUNIT(sc->sc_unit);
|
1999-03-07 16:08:20 +00:00
|
|
|
hdr.type = (chan->channel == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
|
|
|
|
hdr.dir = FROM_TE;
|
|
|
|
hdr.count = ++sc->sc_trace_bcount;
|
|
|
|
MICROTIME(hdr.time);
|
2000-10-09 13:29:00 +00:00
|
|
|
i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-05-20 10:14:57 +00:00
|
|
|
if (chan->bprot != BPROT_NONE)
|
|
|
|
cmd |= HSCX_CMDR_XME;
|
1999-03-07 16:08:20 +00:00
|
|
|
i4b_Bfreembuf(chan->out_mbuf_head);
|
|
|
|
chan->out_mbuf_head = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-05-20 10:14:57 +00:00
|
|
|
/* write what we have from the scratch buf to the HSCX fifo */
|
|
|
|
if (len != 0)
|
|
|
|
HSCX_WRFIFO(chan->channel, scrbuf, len);
|
|
|
|
return(cmd);
|
1999-03-07 16:08:20 +00:00
|
|
|
}
|
|
|
|
|
2000-10-09 13:29:00 +00:00
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* ifpi - ISAC interrupt routine
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
ifpi_isac_intr(struct l1_softc *sc)
|
|
|
|
{
|
|
|
|
register u_char isac_irq_stat;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
/* get isac irq status */
|
|
|
|
isac_irq_stat = ISAC_READ(I_ISTA);
|
|
|
|
|
|
|
|
if(isac_irq_stat)
|
|
|
|
ifpi_isac_irq(sc, isac_irq_stat); /* isac handler */
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ISAC_WRITE(I_MASK, 0xff);
|
|
|
|
|
|
|
|
DELAY(100);
|
|
|
|
|
|
|
|
ISAC_WRITE(I_MASK, ISAC_IMASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* ifpi_recover - try to recover from irq lockup
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
ifpi_recover(struct l1_softc *sc)
|
|
|
|
{
|
|
|
|
u_char byte;
|
|
|
|
|
|
|
|
/* get isac irq status */
|
|
|
|
|
|
|
|
byte = ISAC_READ(I_ISTA);
|
|
|
|
|
|
|
|
NDBGL1(L1_ERROR, " ISAC: ISTA = 0x%x", byte);
|
|
|
|
|
|
|
|
if(byte & ISAC_ISTA_EXI)
|
|
|
|
NDBGL1(L1_ERROR, " ISAC: EXIR = 0x%x", (u_char)ISAC_READ(I_EXIR));
|
|
|
|
|
|
|
|
if(byte & ISAC_ISTA_CISQ)
|
|
|
|
{
|
|
|
|
byte = ISAC_READ(I_CIRR);
|
|
|
|
|
|
|
|
NDBGL1(L1_ERROR, " ISAC: CISQ = 0x%x", byte);
|
|
|
|
|
|
|
|
if(byte & ISAC_CIRR_SQC)
|
|
|
|
NDBGL1(L1_ERROR, " ISAC: SQRR = 0x%x", (u_char)ISAC_READ(I_SQRR));
|
|
|
|
}
|
|
|
|
|
|
|
|
NDBGL1(L1_ERROR, " ISAC: IMASK = 0x%x", ISAC_IMASK);
|
|
|
|
|
|
|
|
ISAC_WRITE(I_MASK, 0xff);
|
|
|
|
DELAY(100);
|
|
|
|
ISAC_WRITE(I_MASK, ISAC_IMASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* NIFPI > 0 */
|