Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Make RT 2860 for the if_ral_pci.c driver compile.
details: https://anonhg.NetBSD.org/src/rev/54b02012f033
branches: trunk
changeset: 344917:54b02012f033
user: christos <christos%NetBSD.org@localhost>
date: Wed Apr 27 19:49:26 2016 +0000
description:
Make RT 2860 for the if_ral_pci.c driver compile.
This work was done by Jeff Rizzo
diffstat:
sys/dev/ic/rt2860.c | 1036 +++++++++++++++++++++++++----------------------
sys/dev/ic/rt2860reg.h | 1 +
sys/dev/ic/rt2860var.h | 22 +-
3 files changed, 564 insertions(+), 495 deletions(-)
diffs (truncated from 2624 to 300 lines):
diff -r 3294f94f654d -r 54b02012f033 sys/dev/ic/rt2860.c
--- a/sys/dev/ic/rt2860.c Wed Apr 27 19:48:11 2016 +0000
+++ b/sys/dev/ic/rt2860.c Wed Apr 27 19:49:26 2016 +0000
@@ -1,3 +1,4 @@
+/* $NetBSD: rt2860.c,v 1.2 2016/04/27 19:49:26 christos Exp $ */
/* $OpenBSD: rt2860.c,v 1.90 2016/04/13 10:49:26 mpi Exp $ */
/*-
@@ -21,43 +22,46 @@
* http://www.ralinktech.com/
*/
-#include "bpfilter.h"
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.2 2016/04/27 19:49:26 christos Exp $");
#include <sys/param.h>
#include <sys/sockio.h>
+#include <sys/sysctl.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/queue.h>
-#include <sys/timeout.h>
+#include <sys/callout.h>
+#include <sys/module.h>
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/endian.h>
-
-#include <machine/bus.h>
-#include <machine/intr.h>
-
-#if NBPFILTER > 0
+#include <sys/cprng.h>
+
+#include <sys/bus.h>
+#include <sys/intr.h>
+
#include <net/bpf.h>
-#endif
#include <net/if.h>
#include <net/if_dl.h>
+#include <net/if_ether.h>
#include <net/if_media.h>
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_amrr.h>
#include <net80211/ieee80211_radiotap.h>
+#include <dev/firmload.h>
+
#include <dev/ic/rt2860var.h>
#include <dev/ic/rt2860reg.h>
#include <dev/pci/pcidevs.h>
+#define RAL_DEBUG
#ifdef RAL_DEBUG
#define DPRINTF(x) do { if (rt2860_debug > 0) printf x; } while (0)
#define DPRINTFN(n, x) do { if (rt2860_debug >= (n)) printf x; } while (0)
@@ -67,94 +71,94 @@
#define DPRINTFN(n, x)
#endif
-void rt2860_attachhook(struct device *);
-int rt2860_alloc_tx_ring(struct rt2860_softc *,
+static void rt2860_attachhook(struct device *);
+static int rt2860_alloc_tx_ring(struct rt2860_softc *,
struct rt2860_tx_ring *);
-void rt2860_reset_tx_ring(struct rt2860_softc *,
+static void rt2860_reset_tx_ring(struct rt2860_softc *,
struct rt2860_tx_ring *);
-void rt2860_free_tx_ring(struct rt2860_softc *,
+static void rt2860_free_tx_ring(struct rt2860_softc *,
struct rt2860_tx_ring *);
-int rt2860_alloc_tx_pool(struct rt2860_softc *);
-void rt2860_free_tx_pool(struct rt2860_softc *);
-int rt2860_alloc_rx_ring(struct rt2860_softc *,
+static int rt2860_alloc_tx_pool(struct rt2860_softc *);
+static void rt2860_free_tx_pool(struct rt2860_softc *);
+static int rt2860_alloc_rx_ring(struct rt2860_softc *,
struct rt2860_rx_ring *);
-void rt2860_reset_rx_ring(struct rt2860_softc *,
+static void rt2860_reset_rx_ring(struct rt2860_softc *,
struct rt2860_rx_ring *);
-void rt2860_free_rx_ring(struct rt2860_softc *,
+static void rt2860_free_rx_ring(struct rt2860_softc *,
struct rt2860_rx_ring *);
-struct ieee80211_node *rt2860_node_alloc(struct ieee80211com *);
-int rt2860_media_change(struct ifnet *);
-void rt2860_iter_func(void *, struct ieee80211_node *);
-void rt2860_updatestats(struct rt2860_softc *);
-void rt2860_newassoc(struct ieee80211com *, struct ieee80211_node *,
+static struct ieee80211_node *rt2860_node_alloc(struct ieee80211_node_table *);
+static int rt2860_media_change(struct ifnet *);
+static void rt2860_iter_func(void *, struct ieee80211_node *);
+static void rt2860_updatestats(struct rt2860_softc *);
+static void rt2860_newassoc(struct ieee80211_node *,
int);
-void rt2860_node_leave(struct ieee80211com *,
- struct ieee80211_node *);
-int rt2860_ampdu_rx_start(struct ieee80211com *,
+#ifdef notyet
+static int rt2860_ampdu_rx_start(struct ieee80211com *,
struct ieee80211_node *, uint8_t);
-void rt2860_ampdu_rx_stop(struct ieee80211com *,
+static void rt2860_ampdu_rx_stop(struct ieee80211com *,
struct ieee80211_node *, uint8_t);
-int rt2860_newstate(struct ieee80211com *, enum ieee80211_state,
+#endif
+static int rt2860_newstate(struct ieee80211com *, enum ieee80211_state,
int);
-uint16_t rt3090_efuse_read_2(struct rt2860_softc *, uint16_t);
-uint16_t rt2860_eeprom_read_2(struct rt2860_softc *, uint16_t);
-void rt2860_intr_coherent(struct rt2860_softc *);
-void rt2860_drain_stats_fifo(struct rt2860_softc *);
-void rt2860_tx_intr(struct rt2860_softc *, int);
-void rt2860_rx_intr(struct rt2860_softc *);
-void rt2860_tbtt_intr(struct rt2860_softc *);
-void rt2860_gp_intr(struct rt2860_softc *);
-int rt2860_tx(struct rt2860_softc *, struct mbuf *,
+static uint16_t rt3090_efuse_read_2(struct rt2860_softc *, uint16_t);
+static uint16_t rt2860_eeprom_read_2(struct rt2860_softc *, uint16_t);
+static void rt2860_intr_coherent(struct rt2860_softc *);
+static void rt2860_drain_stats_fifo(struct rt2860_softc *);
+static void rt2860_tx_intr(struct rt2860_softc *, int);
+static void rt2860_rx_intr(struct rt2860_softc *);
+static void rt2860_tbtt_intr(struct rt2860_softc *);
+static void rt2860_gp_intr(struct rt2860_softc *);
+static int rt2860_tx(struct rt2860_softc *, struct mbuf *,
struct ieee80211_node *);
-void rt2860_start(struct ifnet *);
-void rt2860_watchdog(struct ifnet *);
-int rt2860_ioctl(struct ifnet *, u_long, caddr_t);
-void rt2860_mcu_bbp_write(struct rt2860_softc *, uint8_t, uint8_t);
-uint8_t rt2860_mcu_bbp_read(struct rt2860_softc *, uint8_t);
-void rt2860_rf_write(struct rt2860_softc *, uint8_t, uint32_t);
-uint8_t rt3090_rf_read(struct rt2860_softc *, uint8_t);
-void rt3090_rf_write(struct rt2860_softc *, uint8_t, uint8_t);
-int rt2860_mcu_cmd(struct rt2860_softc *, uint8_t, uint16_t, int);
-void rt2860_enable_mrr(struct rt2860_softc *);
-void rt2860_set_txpreamble(struct rt2860_softc *);
-void rt2860_set_basicrates(struct rt2860_softc *);
-void rt2860_select_chan_group(struct rt2860_softc *, int);
-void rt2860_set_chan(struct rt2860_softc *, u_int);
-void rt3090_set_chan(struct rt2860_softc *, u_int);
-int rt3090_rf_init(struct rt2860_softc *);
-void rt3090_rf_wakeup(struct rt2860_softc *);
-int rt3090_filter_calib(struct rt2860_softc *, uint8_t, uint8_t,
+static void rt2860_start(struct ifnet *);
+static void rt2860_watchdog(struct ifnet *);
+static int rt2860_ioctl(struct ifnet *, u_long, void *);
+static void rt2860_mcu_bbp_write(struct rt2860_softc *, uint8_t, uint8_t);
+static uint8_t rt2860_mcu_bbp_read(struct rt2860_softc *, uint8_t);
+static void rt2860_rf_write(struct rt2860_softc *, uint8_t, uint32_t);
+static uint8_t rt3090_rf_read(struct rt2860_softc *, uint8_t);
+static void rt3090_rf_write(struct rt2860_softc *, uint8_t, uint8_t);
+static int rt2860_mcu_cmd(struct rt2860_softc *, uint8_t, uint16_t, int);
+static void rt2860_enable_mrr(struct rt2860_softc *);
+static void rt2860_set_txpreamble(struct rt2860_softc *);
+static void rt2860_set_basicrates(struct rt2860_softc *);
+static void rt2860_select_chan_group(struct rt2860_softc *, int);
+static void rt2860_set_chan(struct rt2860_softc *, u_int);
+static void rt3090_set_chan(struct rt2860_softc *, u_int);
+static int rt3090_rf_init(struct rt2860_softc *);
+static void rt3090_rf_wakeup(struct rt2860_softc *);
+static int rt3090_filter_calib(struct rt2860_softc *, uint8_t, uint8_t,
uint8_t *);
-void rt3090_rf_setup(struct rt2860_softc *);
-void rt2860_set_leds(struct rt2860_softc *, uint16_t);
-void rt2860_set_gp_timer(struct rt2860_softc *, int);
-void rt2860_set_bssid(struct rt2860_softc *, const uint8_t *);
-void rt2860_set_macaddr(struct rt2860_softc *, const uint8_t *);
-void rt2860_updateslot(struct ieee80211com *);
-void rt2860_updateprot(struct ieee80211com *);
-void rt2860_updateedca(struct ieee80211com *);
-int rt2860_set_key(struct ieee80211com *, struct ieee80211_node *,
- struct ieee80211_key *);
-void rt2860_delete_key(struct ieee80211com *,
- struct ieee80211_node *, struct ieee80211_key *);
-#if NBPFILTER > 0
-int8_t rt2860_rssi2dbm(struct rt2860_softc *, uint8_t, uint8_t);
+static void rt3090_rf_setup(struct rt2860_softc *);
+static void rt2860_set_leds(struct rt2860_softc *, uint16_t);
+static void rt2860_set_gp_timer(struct rt2860_softc *, int);
+static void rt2860_set_bssid(struct rt2860_softc *, const uint8_t *);
+static void rt2860_set_macaddr(struct rt2860_softc *, const uint8_t *);
+static void rt2860_updateslot(struct ifnet *);
+static void rt2860_updateprot(struct ieee80211com *);
+static int rt2860_updateedca(struct ieee80211com *);
+static int rt2860_set_key(struct ieee80211com *,
+ const struct ieee80211_key *, const uint8_t *);
+static int rt2860_delete_key(struct ieee80211com *,
+ const struct ieee80211_key *);
+static int8_t rt2860_rssi2dbm(struct rt2860_softc *, uint8_t, uint8_t);
+static const char * rt2860_get_rf(uint8_t);
+static int rt2860_read_eeprom(struct rt2860_softc *);
+static int rt2860_bbp_init(struct rt2860_softc *);
+static int rt2860_txrx_enable(struct rt2860_softc *);
+static int rt2860_init(struct ifnet *);
+static void rt2860_stop(struct ifnet *, int);
+static int rt2860_load_microcode(struct rt2860_softc *);
+#if 0
+static void rt2860_calib(struct rt2860_softc *);
#endif
-const char * rt2860_get_rf(uint8_t);
-int rt2860_read_eeprom(struct rt2860_softc *);
-int rt2860_bbp_init(struct rt2860_softc *);
-int rt2860_txrx_enable(struct rt2860_softc *);
-int rt2860_init(struct ifnet *);
-void rt2860_stop(struct ifnet *, int);
-int rt2860_load_microcode(struct rt2860_softc *);
-void rt2860_calib(struct rt2860_softc *);
-void rt3090_set_rx_antenna(struct rt2860_softc *, int);
-void rt2860_switch_chan(struct rt2860_softc *,
+static void rt3090_set_rx_antenna(struct rt2860_softc *, int);
+static void rt2860_switch_chan(struct rt2860_softc *,
struct ieee80211_channel *);
#ifndef IEEE80211_STA_ONLY
-int rt2860_setup_beacon(struct rt2860_softc *);
+static int rt2860_setup_beacon(struct rt2860_softc *);
#endif
-void rt2860_enable_tsf_sync(struct rt2860_softc *);
+static void rt2860_enable_tsf_sync(struct rt2860_softc *);
static const struct {
uint32_t reg;
@@ -200,19 +204,21 @@
int qid, ntries, error;
uint32_t tmp;
+ aprint_normal_dev(sc->sc_dev, "in %s\n", __func__);
sc->amrr.amrr_min_success_threshold = 1;
sc->amrr.amrr_max_success_threshold = 15;
/* wait for NIC to initialize */
for (ntries = 0; ntries < 100; ntries++) {
+ aprint_normal_dev(sc->sc_dev, "reading ASIC\n");
tmp = RAL_READ(sc, RT2860_ASIC_VER_ID);
if (tmp != 0 && tmp != 0xffffffff)
break;
DELAY(10);
}
if (ntries == 100) {
- printf("%s: timeout waiting for NIC to initialize\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(sc->sc_dev,
+ "timeout waiting for NIC to initialize\n");
return ETIMEDOUT;
}
sc->mac_ver = tmp >> 16;
@@ -224,39 +230,39 @@
id == PCI_PRODUCT_AWT_RT2890))
sc->sc_flags |= RT2860_ADVANCED_PS;
+ aprint_normal_dev(sc->sc_dev, "reading eeprom\n");
/* retrieve RF rev. no and various other things from EEPROM */
rt2860_read_eeprom(sc);
- printf(", address %s\n", ether_sprintf(ic->ic_myaddr));
- printf("%s: MAC/BBP RT%X (rev 0x%04X), RF %s (MIMO %dT%dR)\n",
- sc->sc_dev.dv_xname, sc->mac_ver, sc->mac_rev,
- rt2860_get_rf(sc->rf_rev), sc->ntxchains, sc->nrxchains);
+ aprint_normal_dev(sc->sc_dev, "802.11 address %s\n",
+ ether_sprintf(ic->ic_myaddr));
+ aprint_normal_dev(sc->sc_dev, "MAC/BBP RT%X (rev 0x%04X), RF %s (MIMO %dT%dR)\n",
+ sc->mac_ver, sc->mac_rev, rt2860_get_rf(sc->rf_rev),
+ sc->ntxchains, sc->nrxchains);
/*
* Allocate Tx (4 EDCAs + HCCA + Mgt) and Rx rings.
*/
for (qid = 0; qid < 6; qid++) {
if ((error = rt2860_alloc_tx_ring(sc, &sc->txq[qid])) != 0) {
- printf("%s: could not allocate Tx ring %d\n",
- sc->sc_dev.dv_xname, qid);
+ aprint_error_dev(sc->sc_dev,
+ "could not allocate Tx ring %d\n", qid);
goto fail1;
}
}
if ((error = rt2860_alloc_rx_ring(sc, &sc->rxq)) != 0) {
- printf("%s: could not allocate Rx ring\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(sc->sc_dev, "could not allocate Rx ring\n");
goto fail1;
}
if ((error = rt2860_alloc_tx_pool(sc)) != 0) {
- printf("%s: could not allocate Tx pool\n",
- sc->sc_dev.dv_xname);
+ aprint_error_dev(sc->sc_dev, "could not allocate Tx pool\n");
goto fail2;
}
Home |
Main Index |
Thread Index |
Old Index