summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorAlex Feldman <alex@cvs.openbsd.org>2004-07-16 15:11:46 +0000
committerAlex Feldman <alex@cvs.openbsd.org>2004-07-16 15:11:46 +0000
commit25a92820f089dc87ce3ef9bcb777d7b80c037cc1 (patch)
tree8ba91a25621c09dea6ea67bb7065a2aa00993f6e /sys/dev/pci
parent409820beb8c529b2d4250186df30b67c28d5bbd7 (diff)
Aft source update.
mcbride ok.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/if_san_common.c3
-rw-r--r--sys/dev/pci/if_san_common.h36
-rw-r--r--sys/dev/pci/if_san_obsd.c5
-rw-r--r--sys/dev/pci/if_san_te1.c3
-rw-r--r--sys/dev/pci/if_san_xilinx.c76
-rw-r--r--sys/dev/pci/if_san_xilinx.h4
-rw-r--r--sys/dev/pci/if_sandrv.c35
-rw-r--r--sys/dev/pci/if_sandrv.h28
8 files changed, 138 insertions, 52 deletions
diff --git a/sys/dev/pci/if_san_common.c b/sys/dev/pci/if_san_common.c
index a2fb3330dee..6b953b8d009 100644
--- a/sys/dev/pci/if_san_common.c
+++ b/sys/dev/pci/if_san_common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_san_common.c,v 1.3 2004/06/26 22:19:38 mcbride Exp $ */
+/* $OpenBSD: if_san_common.c,v 1.4 2004/07/16 15:11:45 alex Exp $ */
/*-
* Copyright (c) 2001-2004 Sangoma Technologies (SAN)
@@ -33,7 +33,6 @@
*/
-# include </usr/include/bitstring.h>
# include <sys/types.h>
# include <sys/param.h>
# include <sys/systm.h>
diff --git a/sys/dev/pci/if_san_common.h b/sys/dev/pci/if_san_common.h
index 9bdb7eb318c..26f9606ea37 100644
--- a/sys/dev/pci/if_san_common.h
+++ b/sys/dev/pci/if_san_common.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_san_common.h,v 1.3 2004/06/26 22:19:38 mcbride Exp $ */
+/* $OpenBSD: if_san_common.h,v 1.4 2004/07/16 15:11:45 alex Exp $ */
/*-
* Copyright (c) 2001-2004 Sangoma Technologies (SAN)
@@ -287,6 +287,18 @@ typedef struct wan_udp_hdr{
/* Unsafe sprintf and vsprintf function removed from the kernel */
# define WAN_IRQ_RETVAL(a) return;
+#define _bit_byte(bit) ((bit) >> 3)
+#define _bit_mask(bit) (1 << ((bit)&0x7))
+
+/* is bit N of bitstring name set? */
+#define bit_test(name, bit) ((name)[_bit_byte(bit)] & _bit_mask(bit))
+
+/* set bit N of bitstring name */
+#define bit_set(name, bit) ((name)[_bit_byte(bit)] |= _bit_mask(bit))
+
+/* clear bit N of bitstring name */
+#define bit_clear(name, bit) ((name)[_bit_byte(bit)] &= ~_bit_mask(bit))
+
/****** Data Structures *****************************************************/
typedef struct wan_udp_pkt {
@@ -361,19 +373,19 @@ typedef struct sdla {
char state; /* device state */
unsigned long critical; /* critical section flag */
- int (*iface_up) (struct ifnet*);
- int (*iface_down) (struct ifnet*);
- int (*iface_send) (struct mbuf* skb, struct ifnet*);
- int (*iface_ioctl) (struct ifnet*, int, struct ifreq*);
+ int(*iface_up) (struct ifnet*);
+ int(*iface_down) (struct ifnet*);
+ int(*iface_send) (struct mbuf* skb, struct ifnet*);
+ int(*iface_ioctl) (struct ifnet*, int, struct ifreq*);
unsigned long state_tick; /* link state timestamp */
unsigned long in_isr; /* interrupt-in-service flag */
unsigned long configured; /* configurations status */
- int (*del_if) (struct sdla*, struct ifnet*);
- void (*isr)(struct sdla*); /* interrupt service routine */
- void (*poll)(struct sdla*); /* polling routine */
- int (*exec)(struct sdla*, void*, void*);
- int (*ioctl) (struct ifnet*, int, struct ifreq*);
+ int(*del_if) (struct sdla*, struct ifnet*);
+ void(*isr)(struct sdla*); /* interrupt service routine */
+ void(*poll)(struct sdla*); /* polling routine */
+ int(*exec)(struct sdla*, void*, void*);
+ int(*ioctl) (struct ifnet*, int, struct ifreq*);
union {
sdla_xilinx_t xilinx;
@@ -388,8 +400,8 @@ typedef struct sdla {
unsigned char front_end_status;
WRITE_FRONT_END_REG_T* write_front_end_reg;
READ_FRONT_END_REG_T* read_front_end_reg;
- void (*te_enable_timer) (void*);
- void (*te_link_state) (void*);
+ void(*te_enable_timer) (void*);
+ void(*te_link_state) (void*);
LIST_HEAD(,wanpipe_common) dev_head;
LIST_ENTRY(sdla) next; /* -> next device */
diff --git a/sys/dev/pci/if_san_obsd.c b/sys/dev/pci/if_san_obsd.c
index 99d26d54687..39f5f467ca9 100644
--- a/sys/dev/pci/if_san_obsd.c
+++ b/sys/dev/pci/if_san_obsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_san_obsd.c,v 1.3 2004/06/26 22:48:14 mcbride Exp $ */
+/* $OpenBSD: if_san_obsd.c,v 1.4 2004/07/16 15:11:45 alex Exp $ */
/*-
* Copyright (c) 2001-2004 Sangoma Technologies (SAN)
@@ -32,7 +32,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-# include </usr/include/bitstring.h>
# include <sys/types.h>
# include <sys/param.h>
# include <sys/systm.h>
@@ -115,7 +114,7 @@ wanpipe_generic_name(sdla_t *card, char *ifname)
}
int
-wanpipe_generic_register (sdla_t *card, struct ifnet *ifp, char *ifname)
+wanpipe_generic_register(sdla_t *card, struct ifnet *ifp, char *ifname)
{
if (ifname == NULL || strlen(ifname) > IFNAMSIZ) {
return (-EINVAL);
diff --git a/sys/dev/pci/if_san_te1.c b/sys/dev/pci/if_san_te1.c
index ecb25845f2b..c6b8c82425d 100644
--- a/sys/dev/pci/if_san_te1.c
+++ b/sys/dev/pci/if_san_te1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_san_te1.c,v 1.3 2004/06/27 01:54:20 mcbride Exp $ */
+/* $OpenBSD: if_san_te1.c,v 1.4 2004/07/16 15:11:45 alex Exp $ */
/*-
* Copyright (c) 2001-2004 Sangoma Technologies (SAN)
@@ -32,7 +32,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include </usr/include/bitstring.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
diff --git a/sys/dev/pci/if_san_xilinx.c b/sys/dev/pci/if_san_xilinx.c
index 7483c411282..ab80d1c8622 100644
--- a/sys/dev/pci/if_san_xilinx.c
+++ b/sys/dev/pci/if_san_xilinx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_san_xilinx.c,v 1.3 2004/06/28 01:16:30 mcbride Exp $ */
+/* $OpenBSD: if_san_xilinx.c,v 1.4 2004/07/16 15:11:45 alex Exp $ */
/*-
* Copyright (c) 2001-2004 Sangoma Technologies (SAN)
@@ -33,7 +33,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include </usr/include/bitstring.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
@@ -58,6 +57,8 @@
#include <netinet/udp.h>
#include <netinet/ip.h>
+#include <machine/bus.h>
+
#include <dev/pci/if_san_common.h>
#include <dev/pci/if_san_obsd.h>
#include <dev/pci/if_san_xilinx.h>
@@ -163,6 +164,10 @@ typedef struct {
void *prot_ch;
wan_trace_t trace_info;
+ u_int8_t tx_dma_status;
+ bus_dma_segment_t tx_dma_seg;
+ int tx_dma_rseg;
+ caddr_t tx_dma_vaddr;
}xilinx_softc_t;
#define WAN_IFP_TO_SOFTC(ifp) (xilinx_softc_t *)((ifp)->if_softc)
@@ -556,6 +561,15 @@ wan_xilinx_down(struct ifnet *ifp)
aft_init_requeue_free_m(sc, m);
sc->rx_dma_mbuf = NULL;
}
+ if (bit_test((u_int8_t *)&sc->tx_dma_status, TX_DMA_BUF_INIT)){
+ bus_dma_tag_t dmat;
+
+ sdla_getcfg(card->hw, SDLA_DMATAG, &dmat);
+ bus_dmamem_unmap(dmat, sc->tx_dma_vaddr, sc->dma_mtu);
+ bus_dmamem_free(dmat, &sc->tx_dma_seg, sc->tx_dma_rseg);
+ bit_clear((u_int8_t *)&sc->tx_dma_status, TX_DMA_BUF_INIT);
+ }
+
/* If there is something in rx_complete_list, then
** move evething to rx_free_list. */
for (;;) {
@@ -845,7 +859,8 @@ process_udp_mgmt_pkt(sdla_t* card, struct ifnet* ifp,
* indicate there are more frames
* on board & exit
*/
- wan_udp_pkt->wan_udp_aft_ismoredata = 0x01;
+ wan_udp_pkt->wan_udp_aft_ismoredata
+ = 0x01;
break;
}
@@ -1807,7 +1822,6 @@ xilinx_dma_tx(sdla_t *card, xilinx_softc_t *sc)
bit_clear((u_int8_t *)&sc->dma_status, TX_BUSY);
return (-ENOBUFS);
} else {
-
len = m->m_len;
if (len > MAX_XILINX_TX_DMA_SIZE) {
/* FIXME: We need to split this frame into
@@ -1821,7 +1835,59 @@ xilinx_dma_tx(sdla_t *card, xilinx_softc_t *sc)
return (-EINVAL);
}
- sc->tx_dma_addr = kvtop(mtod(m, caddr_t));
+ if (mtod(m, u_int32_t) & 0x03) {
+ if (!bit_test((u_int8_t *)&sc->tx_dma_status,
+ TX_DMA_BUF_INIT)) {
+ bus_dma_tag_t dmat;
+ int err;
+
+ sdla_getcfg(card->hw, SDLA_DMATAG, &dmat);
+ err = bus_dmamem_alloc(
+ dmat,
+ sc->dma_mtu,
+ PAGE_SIZE,
+ 0,
+ &sc->tx_dma_seg,
+ 1,
+ &sc->tx_dma_rseg,
+ BUS_DMA_NOWAIT);
+ if (err) {
+ log(LOG_INFO,
+ "%s: Failed allocate DMA buffer!\n",
+ sc->if_name);
+ m_freem(m);
+ bit_clear((u_int8_t *)&sc->dma_status,
+ TX_BUSY);
+ return (-EINVAL);
+ }
+ err = bus_dmamem_map(
+ dmat,
+ &sc->tx_dma_seg,
+ sc->tx_dma_rseg,
+ sc->dma_mtu,
+ (caddr_t*)&sc->tx_dma_vaddr,
+ BUS_DMA_NOWAIT);
+ if (err) {
+ log(LOG_INFO,
+ "%s: Failed to map DMA buffer!\n",
+ sc->if_name);
+ bus_dmamem_free(
+ dmat,
+ &sc->tx_dma_seg,
+ sc->tx_dma_rseg);
+ m_freem(m);
+ bit_clear((u_int8_t *)&sc->dma_status,
+ TX_BUSY);
+ return (-EINVAL);
+ }
+ bit_set((u_int8_t *)&sc->tx_dma_status,
+ TX_DMA_BUF_INIT);
+ }
+ memcpy(sc->tx_dma_vaddr, mtod(m, caddr_t), m->m_len);
+ sc->tx_dma_addr = kvtop(sc->tx_dma_vaddr);
+ } else {
+ sc->tx_dma_addr = kvtop(mtod(m, caddr_t));
+ }
sc->tx_dma_len = len;
}
diff --git a/sys/dev/pci/if_san_xilinx.h b/sys/dev/pci/if_san_xilinx.h
index 14e2d0073bb..bc498952774 100644
--- a/sys/dev/pci/if_san_xilinx.h
+++ b/sys/dev/pci/if_san_xilinx.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_san_xilinx.h,v 1.3 2004/06/28 01:16:30 mcbride Exp $ */
+/* $OpenBSD: if_san_xilinx.h,v 1.4 2004/07/16 15:11:45 alex Exp $ */
/*-
* Copyright (c) 2001-2004 Sangoma Technologies (SAN)
@@ -326,6 +326,8 @@ typedef struct {
#define MAX_TRACE_QUEUE 100
+#define TX_DMA_BUF_INIT 0
+
#define MAX_TRACE_BUFFER (MAX_LGTH_UDP_MGNT_PKT - \
sizeof(iphdr_t) - \
sizeof(udphdr_t) - \
diff --git a/sys/dev/pci/if_sandrv.c b/sys/dev/pci/if_sandrv.c
index fda3c4e6e8e..1f55d9a5d81 100644
--- a/sys/dev/pci/if_sandrv.c
+++ b/sys/dev/pci/if_sandrv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sandrv.c,v 1.3 2004/06/26 22:05:25 mcbride Exp $ */
+/* $OpenBSD: if_sandrv.c,v 1.4 2004/07/16 15:11:45 alex Exp $ */
/*-
* Copyright (c) 2001-2004 Sangoma Technologies (SAN)
@@ -171,13 +171,13 @@ static void sdla_poke_by_4(sdlahw_t *, unsigned long, void *, unsigned int);
static sdlahw_card_t* sdla_card_register(u_int16_t, int, int);
#if 0
-static int sdla_card_unregister (unsigned char hw_type, int slot_no, int bus_no, int ioport);
+static int sdla_card_unregister (unsigned char, int, int, int);
#endif
static sdlahw_card_t* sdla_card_search(u_int16_t, int, int);
static sdlahw_t* sdla_hw_register(sdlahw_card_t *, int, int, void *);
#if 0
-static int sdla_hw_unregister(sdlahw_card_t* card, int cpu_no);
+static int sdla_hw_unregister(sdlahw_card_t*, int);
#endif
static sdlahw_t* sdla_hw_search(u_int16_t, int, int, int);
@@ -387,7 +387,7 @@ sdladrv_exit(void)
sdla_hw_probe_t *tmp = elm_hw_probe;
elm_hw_probe = LIST_NEXT(elm_hw_probe, next);
if (tmp->used){
- log(LOG_INFO, "sdladrv: HW probe info is in used (%s)\n",
+ log(LOG_INFO, "HW probe info is in used (%s)\n",
elm_hw_probe->hw_info);
return -EBUSY;
}
@@ -617,7 +617,7 @@ sdla_card_register(u_int16_t atype, int slot_no, int bus_no)
#if 0
static int
-sdla_card_unregister (u_int16_t atype, int slot_no, int bus_no, int ioport)
+sdla_card_unregister(u_int16_t atype, int slot_no, int bus_no, int ioport)
{
sdlahw_card_t* tmp_card;
@@ -631,12 +631,14 @@ sdla_card_unregister (u_int16_t atype, int slot_no, int bus_no, int ioport)
}
}
if (tmp_card == NULL){
- log(LOG_INFO, "Error: Card didn't find %04X card (slot=%d, bus=%d)\n",
+ log(LOG_INFO,
+ "Error: Card didn't find %04X card (slot=%d, bus=%d)\n"
atype, slot_no, bus_no);
return -EFAULT;
}
if (tmp_card->used){
- log(LOG_INFO, "Error: Card is still in used (slot=%d,bus=%d,used=%d)\n",
+ log(LOG_INFO,
+ "Error: Card is still in used (slot=%d,bus=%d,used=%d)\n",
slot_no, bus_no, tmp_card->used);
return -EBUSY;
}
@@ -703,7 +705,7 @@ sdla_hw_register(sdlahw_card_t *card, int cpu_no, int irq, void *dev)
#if 0
static int
-sdla_hw_unregister (sdlahw_card_t* hwcard, int cpu_no)
+sdla_hw_unregister(sdlahw_card_t* hwcard, int cpu_no)
{
sdlahw_t* tmp_hw;
int i;
@@ -717,13 +719,18 @@ sdla_hw_unregister (sdlahw_card_t* hwcard, int cpu_no)
}
}
if (tmp_hw == NULL){
- log(LOG_INFO, "Error: Failed to find device (slot=%d,bus=%d,cpu=%c)\n",
- hwcard->slot_no, hwcard->bus_no, SDLA_GET_CPU(cpu_no));
+ log(LOG_INFO,
+ "Error: Failed to find device (slot=%d,bus=%d,cpu=%c)\n",
+ hwcard->slot_no, hwcard->bus_no, SDLA_GET_CPU(cpu_no));
return -EFAULT;
}
if (tmp_hw->used){
- log(LOG_INFO, "Error: Device is still in used (slot=%d,bus=%d,cpu=%c,used=%d)\n",
- hwcard->slot_no, hwcard->bus_no, SDLA_GET_CPU(cpu_no), hwcard->used);
+ log(LOG_INFO,
+ "Error: Device is still in used (slot=%d,bus=%d,cpu=%c,%d)\n",
+ hwcard->slot_no,
+ hwcard->bus_no,
+ SDLA_GET_CPU(cpu_no),
+ hwcard->used);
return -EBUSY;
}
@@ -743,7 +750,9 @@ sdla_hw_search(u_int16_t atype, int slot_no, int bus_no, int cpu_no)
LIST_FOREACH(tmp_hw, &sdlahw_head, next) {
if (tmp_hw->hwcard == NULL) {
- log(LOG_INFO, "Critical Error: sdla_cpu_search: line %d\n", __LINE__);
+ log(LOG_INFO,
+ "Critical Error: sdla_cpu_search: line %d\n",
+ __LINE__);
LIST_REMOVE(tmp_hw, next);
continue;
}
diff --git a/sys/dev/pci/if_sandrv.h b/sys/dev/pci/if_sandrv.h
index a8579b653c7..789e167b4a6 100644
--- a/sys/dev/pci/if_sandrv.h
+++ b/sys/dev/pci/if_sandrv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sandrv.h,v 1.2 2004/06/26 20:17:23 mcbride Exp $ */
+/* $OpenBSD: if_sandrv.h,v 1.3 2004/07/16 15:11:45 alex Exp $ */
/*-
* Copyright (c) 2001-2004 Sangoma Technologies (SAN)
@@ -36,7 +36,7 @@
# define __IF_SANDRV_H
#ifdef __SDLADRV__
-# define EXTERN
+# define EXTERN
#else
# define EXTERN extern
#endif
@@ -51,7 +51,7 @@ typedef struct {
struct {
unsigned char opp_flag;
unsigned char command;
- unsigned short data_len;
+ unsigned short data_len;
unsigned char return_code;
} wan_p_cmd;
unsigned char mbox[WAN_MAILBOX_SIZE];
@@ -170,8 +170,8 @@ typedef struct {
#define PCI_MEM_BASE0_DWORD 0x14 /* memory base - apperture 0 */
#define PCI_MEM_BASE1_DWORD 0x18 /* memory base - apperture 1 */
#if 0
-#define PCI_SUBSYS_VENDOR_WORD 0x2C /* subsystem vendor ID */
-#define PCI_SUBSYS_ID_WORD 0x2E /* subsystem ID */
+#define PCI_SUBSYS_VENDOR_WORD 0x2C /* subsystem vendor ID */
+#define PCI_SUBSYS_ID_WORD 0x2E /* subsystem ID */
#define PCI_INT_LINE_BYTE 0x3C /* interrupt line */
#define PCI_INT_PIN_BYTE 0x3D /* interrupt pin */
#endif
@@ -179,13 +179,13 @@ typedef struct {
#define PCI_MAP1_DWORD 0x44 /* PCI to local bus address 1 */
#define PCI_INT_STATUS 0x48 /* interrupt status */
#define PCI_INT_CONFIG 0x4C /* interrupt configuration */
-
+
#define PCI_DEV_SLOT_MASK 0x1F /* mask for slot numbering */
#define PCI_IRQ_NOT_ALLOCATED 0xFF /* interrupt line for no IRQ */
/* Local PCI register usage */
#define PCI_MEMORY_ENABLE 0x00000003 /* enable PCI memory */
#define PCI_CPU_A_MEM_DISABLE 0x00000002 /* disable CPU A memory */
-#define PCI_CPU_B_MEM_DISABLE 0x00100002 /* disable CPU B memory */
+#define PCI_CPU_B_MEM_DISABLE 0x00100002 /* disable CPU B memory */
#define PCI_ENABLE_IRQ_CPU_A 0x005A0004 /* enable IRQ for CPU A */
#define PCI_ENABLE_IRQ_CPU_B 0x005A0008 /* enable IRQ for CPU B */
#define PCI_ENABLE_IRQ_DMA0 0x01000000 /* enable IRQ for DMA 0 */
@@ -194,7 +194,7 @@ typedef struct {
#define PCI_DISABLE_IRQ_CPU_B 0x00000008 /* disable IRQ for CPU B */
#define PCI_DISABLE_IRQ_DMA0 0x01000000 /* disable IRQ for DMA 0 */
#define PCI_DISABLE_IRQ_DMA1 0x02000000 /* disable IRQ for DMA 1 */
-
+
/* Setting for the Interrupt Status register */
#define IRQ_DMA0 0x01000000 /* IRQ for DMA0 */
#define IRQ_DMA1 0x02000000 /* IRQ for DMA1 */
@@ -208,13 +208,13 @@ typedef struct {
/* S514 control register offsets within the memory address space */
#define S514_CTRL_REG_BYTE 0x80000
-
+
/* S514 adapter control bytes */
-#define S514_CPU_HALT 0x00
+#define S514_CPU_HALT 0x00
#define S514_CPU_START 0x01
/* The maximum number of S514 adapters supported */
-#define MAX_S514_CARDS 20
+#define MAX_S514_CARDS 20
#define WAN_CMD_OK 0 /* normal firmware return code */
#define WAN_CMD_TIMEOUT 0xFF /* firmware command timed out */
@@ -232,7 +232,7 @@ typedef struct {
(core_id == AFT_ATM_CORE_ID) ? "ATM" : \
(core_id == AFT_SS7_CORE_ID) ? "SS7" : \
"Unknown"
-#define WAN_ASSERT(val) \
+#define WAN_ASSERT(val) \
if (val){ \
log(LOG_INFO, "********** ASSERT FAILED **********\n"); \
log(LOG_INFO, "%s:%d - Critical error\n", \
@@ -240,7 +240,7 @@ typedef struct {
return -EINVAL; \
}
-#define WAN_ASSERT1(val) \
+#define WAN_ASSERT1(val) \
if (val){ \
log(LOG_INFO, "********** ASSERT FAILED **********\n"); \
log(LOG_INFO, "%s:%d - Critical error\n", \
@@ -329,5 +329,5 @@ extern int sdla_is_te1(void*);
#endif
-#undef EXTERN
+#undef EXTERN
#endif /* __IF_SANDRV_H */