From owner-svn-src-head@FreeBSD.ORG Sun Mar 15 20:29:23 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A631D2D1; Sun, 15 Mar 2015 20:29:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 91A59F22; Sun, 15 Mar 2015 20:29:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2FKTNjm059479; Sun, 15 Mar 2015 20:29:23 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2FKTNBm059477; Sun, 15 Mar 2015 20:29:23 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201503152029.t2FKTNBm059477@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sun, 15 Mar 2015 20:29:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280064 - head/sys/dev/wpi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2015 20:29:23 -0000 Author: adrian Date: Sun Mar 15 20:29:22 2015 New Revision: 280064 URL: https://svnweb.freebsd.org/changeset/base/280064 Log: Replace few numbers with named constants. PR: kern/197143 Submitted by: Andriy Voskoboinyk Modified: head/sys/dev/wpi/if_wpi.c head/sys/dev/wpi/if_wpireg.h Modified: head/sys/dev/wpi/if_wpi.c ============================================================================== --- head/sys/dev/wpi/if_wpi.c Sun Mar 15 20:23:58 2015 (r280063) +++ head/sys/dev/wpi/if_wpi.c Sun Mar 15 20:29:22 2015 (r280064) @@ -1138,7 +1138,7 @@ wpi_alloc_tx_ring(struct wpi_softc *sc, * to allocate commands space for other rings. * XXX Do we really need to allocate descriptors for other rings? */ - if (qid > 4) + if (qid > WPI_CMD_QUEUE_NUM) return 0; size = WPI_TX_RING_COUNT * sizeof (struct wpi_tx_cmd); @@ -1806,7 +1806,7 @@ wpi_rx_done(struct wpi_softc *sc, struct tap->wr_flags = 0; if (head->flags & htole16(WPI_STAT_FLAG_SHPREAMBLE)) tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; - tap->wr_dbm_antsignal = (int8_t)(stat->rssi - WPI_RSSI_OFFSET); + tap->wr_dbm_antsignal = (int8_t)(stat->rssi + WPI_RSSI_OFFSET); tap->wr_dbm_antnoise = (int8_t)le16toh(stat->noise); tap->wr_tsft = tail->tstamp; tap->wr_antenna = (le16toh(head->flags) >> 4) & 0xf; @@ -1817,11 +1817,11 @@ wpi_rx_done(struct wpi_softc *sc, struct /* Send the frame to the 802.11 layer. */ if (ni != NULL) { - (void)ieee80211_input(ni, m, stat->rssi, -WPI_RSSI_OFFSET); + (void)ieee80211_input(ni, m, stat->rssi, WPI_RSSI_OFFSET); /* Node is no longer needed. */ ieee80211_free_node(ni); } else - (void)ieee80211_input_all(ic, m, stat->rssi, -WPI_RSSI_OFFSET); + (void)ieee80211_input_all(ic, m, stat->rssi, WPI_RSSI_OFFSET); WPI_LOCK(sc); @@ -1906,7 +1906,7 @@ wpi_tx_done(struct wpi_softc *sc, struct static void wpi_cmd_done(struct wpi_softc *sc, struct wpi_rx_desc *desc) { - struct wpi_tx_ring *ring = &sc->txq[4]; + struct wpi_tx_ring *ring = &sc->txq[WPI_CMD_QUEUE_NUM]; struct wpi_tx_data *data; DPRINTF(sc, WPI_DEBUG_CMD, "cmd notification qid=%x idx=%d flags=%x " @@ -1914,7 +1914,7 @@ wpi_cmd_done(struct wpi_softc *sc, struc desc->flags, wpi_cmd_str(desc->type), le32toh(desc->len)); - if ((desc->qid & 7) != 4) + if ((desc->qid & WPI_RX_DESC_QID_MSK) != WPI_CMD_QUEUE_NUM) return; /* Not a command ack. */ data = &ring->data[desc->idx]; @@ -1961,8 +1961,10 @@ wpi_notif_intr(struct wpi_softc *sc) __func__, sc->rxq.cur, desc->qid, desc->idx, desc->flags, desc->type, wpi_cmd_str(desc->type), le32toh(desc->len)); - if (!(desc->qid & 0x80)) /* Reply to a command. */ + if (!(desc->qid & WPI_UNSOLICITED_RX_NOTIF)) { + /* Reply to a command. */ wpi_cmd_done(sc, desc); + } switch (desc->type) { case WPI_RX_DONE: @@ -2804,7 +2806,7 @@ static int wpi_cmd(struct wpi_softc *sc, int code, const void *buf, size_t size, int async) { - struct wpi_tx_ring *ring = &sc->txq[4]; + struct wpi_tx_ring *ring = &sc->txq[WPI_CMD_QUEUE_NUM]; struct wpi_tx_desc *desc; struct wpi_tx_data *data; struct wpi_tx_cmd *cmd; Modified: head/sys/dev/wpi/if_wpireg.h ============================================================================== --- head/sys/dev/wpi/if_wpireg.h Sun Mar 15 20:23:58 2015 (r280063) +++ head/sys/dev/wpi/if_wpireg.h Sun Mar 15 20:29:22 2015 (r280064) @@ -25,6 +25,8 @@ #define WPI_NTXQUEUES 8 #define WPI_DRV_NTXQUEUES 5 +#define WPI_CMD_QUEUE_NUM 4 + #define WPI_NDMACHNLS 6 /* Maximum scatter/gather. */ @@ -222,7 +224,7 @@ #define WPI_APMG_PCI_STT_L1A_DIS (1 << 11) struct wpi_shared { - uint32_t txbase[8]; + uint32_t txbase[WPI_NTXQUEUES]; uint32_t next; uint32_t reserved[2]; } __packed; @@ -269,13 +271,16 @@ struct wpi_rx_desc { uint8_t qid; } __packed; +#define WPI_RX_DESC_QID_MSK 0x07 +#define WPI_UNSOLICITED_RX_NOTIF 0x80 + struct wpi_rx_stat { uint8_t len; #define WPI_STAT_MAXLEN 20 uint8_t id; uint8_t rssi; /* received signal strength */ -#define WPI_RSSI_OFFSET 95 +#define WPI_RSSI_OFFSET -95 uint8_t agc; /* access gain control */ uint16_t signal;