Exemplo n.º 1
0
static void
r12au_postattach(struct rtwn_softc *sc)
{
	struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);
	struct r12a_softc *rs = sc->sc_priv;

	if (usbd_get_speed(uc->uc_udev) == USB_SPEED_SUPER) {
		rs->ac_usb_dma_size = 0x07;
		rs->ac_usb_dma_time = 0x1a;
	} else {
		rs->ac_usb_dma_size = 0x01;
		rs->ac_usb_dma_time = 0x10;
	}

	if (rs->chip & R12A_CHIP_C_CUT)
		sc->sc_rf_read = r12a_c_cut_rf_read;
	else
		sc->sc_rf_read = r12a_rf_read;

	if (rs->board_type == R92C_BOARD_TYPE_MINICARD ||
	    rs->board_type == R92C_BOARD_TYPE_SOLO ||
	    rs->board_type == R92C_BOARD_TYPE_COMBO)
		sc->sc_set_led = r88e_set_led;
	else
		sc->sc_set_led = r12a_set_led;

	if (!(rs->ext_pa_2g || rs->ext_lna_2g ||
	    rs->ext_pa_5g || rs->ext_lna_5g))
		sc->mac_prog = &rtl8812au_mac_no_ext_pa_lna[0];

	sc->sc_ic.ic_ioctl = r12a_ioctl_net;
}
Exemplo n.º 2
0
static void
rtwn_usb_start_xfers(struct rtwn_softc *sc)
{
	struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);

	usbd_transfer_start(uc->uc_xfer[RTWN_BULK_RX]);
}
Exemplo n.º 3
0
static int
rtwn_do_request(struct rtwn_softc *sc, struct usb_device_request *req,
    void *data)
{
	struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);
	usb_error_t err;
	int ntries = 10;

	RTWN_ASSERT_LOCKED(sc);

	while (ntries--) {
		err = usbd_do_request_flags(uc->uc_udev, &sc->sc_mtx,
		    req, data, 0, NULL, 250 /* ms */);
		if (err == USB_ERR_NORMAL_COMPLETION)
			return (0);

		RTWN_DPRINTF(sc, RTWN_DEBUG_USB,
		    "%s: control request failed, %s (retries left: %d)\n",
		    __func__, usbd_errstr(err), ntries);
		if (err == USB_ERR_NOT_CONFIGURED)
			return (ENXIO);

		usb_pause_mtx(&sc->sc_mtx, hz / 100);
	}
	return (EIO);
}
Exemplo n.º 4
0
void
r92cu_init_tx_agg(struct rtwn_softc *sc)
{
	struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);

	rtwn_setbits_4(sc, R92C_TDECTRL,
	    R92C_TDECTRL_BLK_DESC_NUM_M, uc->tx_agg_desc_num);
}
Exemplo n.º 5
0
static void
rtwn_usb_free_rx_list(struct rtwn_softc *sc)
{
	struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);

	rtwn_usb_free_list(sc, uc->uc_rx, RTWN_USB_RX_LIST_COUNT);

	STAILQ_INIT(&uc->uc_rx_active);
	STAILQ_INIT(&uc->uc_rx_inactive);
}
Exemplo n.º 6
0
static void
rtwn_usb_reset_lists(struct rtwn_softc *sc, struct ieee80211vap *vap)
{
	struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);

	RTWN_ASSERT_LOCKED(sc);

	rtwn_usb_reset_tx_list(uc, &uc->uc_tx_active, vap);
	rtwn_usb_reset_tx_list(uc, &uc->uc_tx_pending, vap);
	if (vap == NULL)
		sc->qfullmsk = 0;
}
Exemplo n.º 7
0
static void
rtwn_usb_abort_xfers(struct rtwn_softc *sc)
{
	struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);
	int i;

	RTWN_ASSERT_LOCKED(sc);

	/* abort any pending transfers */
	RTWN_UNLOCK(sc);
	for (i = 0; i < RTWN_N_TRANSFER; i++)
		usbd_transfer_drain(uc->uc_xfer[i]);
	RTWN_LOCK(sc);
}
Exemplo n.º 8
0
static int
rtwn_usb_alloc_rx_list(struct rtwn_softc *sc)
{
	struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);
	int error, i;

	error = rtwn_usb_alloc_list(sc, uc->uc_rx, RTWN_USB_RX_LIST_COUNT,
	    uc->uc_rx_buf_size * RTWN_USB_RXBUFSZ_UNIT);
	if (error != 0)
		return (error);

	STAILQ_INIT(&uc->uc_rx_active);
	STAILQ_INIT(&uc->uc_rx_inactive);

	for (i = 0; i < RTWN_USB_RX_LIST_COUNT; i++)
		STAILQ_INSERT_HEAD(&uc->uc_rx_inactive, &uc->uc_rx[i], next);

	return (0);
}
Exemplo n.º 9
0
static struct mbuf *
rtwn_rxeof(struct rtwn_softc *sc, uint8_t *buf, int len)
{
	struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);
	struct r92c_rx_stat *stat;
	struct mbuf *m, *m0 = NULL;
	uint32_t rxdw0;
	int totlen, pktlen, infosz;

	/* Process packets. */
	while (len >= sizeof(*stat)) {
		stat = (struct r92c_rx_stat *)buf;
		rxdw0 = le32toh(stat->rxdw0);

		pktlen = MS(rxdw0, R92C_RXDW0_PKTLEN);
		if (__predict_false(pktlen == 0))
			break;

		infosz = MS(rxdw0, R92C_RXDW0_INFOSZ) * 8;

		/* Make sure everything fits in xfer. */
		totlen = sizeof(*stat) + infosz + pktlen;
		if (totlen > len)
			break;

		if (m0 == NULL)
			m0 = m = rtwn_rx_copy_to_mbuf(sc, stat, totlen);
		else {
			m->m_next = rtwn_rx_copy_to_mbuf(sc, stat, totlen);
			if (m->m_next != NULL)
				m = m->m_next;
		}

		/* Align next frame. */
		totlen = rtwn_usb_align_rx(uc, totlen, len);
		buf += totlen;
		len -= totlen;
	}

	return (m0);
}
Exemplo n.º 10
0
static void
rtwn_usb_sysctlattach(struct rtwn_softc *sc)
{
	struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);
	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
	char str[64];
	int ret;

	ret = snprintf(str, sizeof(str),
	    "Rx buffer size, 512-byte units [%d...%d]",
	    RTWN_USB_RXBUFSZ_MIN, RTWN_USB_RXBUFSZ_MAX);
	KASSERT(ret > 0, ("ret (%d) <= 0!\n", ret));
	(void) ret;

	uc->uc_rx_buf_size = RTWN_USB_RXBUFSZ_DEF;
	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
	    "rx_buf_size", CTLFLAG_RDTUN, &uc->uc_rx_buf_size,
	    uc->uc_rx_buf_size, str);
	if (uc->uc_rx_buf_size < RTWN_USB_RXBUFSZ_MIN)
		uc->uc_rx_buf_size = RTWN_USB_RXBUFSZ_MIN;
	if (uc->uc_rx_buf_size > RTWN_USB_RXBUFSZ_MAX)
		uc->uc_rx_buf_size = RTWN_USB_RXBUFSZ_MAX;
}