Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d3240fe authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "wil6210: support multiple desc and status rings handling"

parents e70b432e 9f5f05a8
Loading
Loading
Loading
Loading
+40 −12
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ static void wil_print_desc_edma(struct seq_file *s, struct wil6210_priv *wil,
			&ring->va[idx].rx.enhanced;
		u16 buff_id = le16_to_cpu(rx_d->mac.buff_id);

		if (wil->rx_buff_mgmt.buff_arr &&
		    wil_val_in_range(buff_id, 0, wil->rx_buff_mgmt.size))
			has_skb = wil->rx_buff_mgmt.buff_arr[buff_id].skb;
		seq_printf(s, "%c", (has_skb) ? _h : _s);
	} else {
@@ -60,9 +62,9 @@ static void wil_print_desc_edma(struct seq_file *s, struct wil6210_priv *wil,
			&ring->va[idx].tx.enhanced;

		num_of_descs = (u8)d->mac.d[2];
		has_skb = ring->ctx[idx].skb;
		has_skb = ring->ctx && ring->ctx[idx].skb;
		if (num_of_descs >= 1)
			seq_printf(s, "%c", ring->ctx[idx].skb ? _h : _s);
			seq_printf(s, "%c", has_skb ? _h : _s);
		else
			/* num_of_descs == 0, it's a frag in a list of descs */
			seq_printf(s, "%c", has_skb ? 'h' : _s);
@@ -73,7 +75,7 @@ static void wil_print_ring(struct seq_file *s, struct wil6210_priv *wil,
			   const char *name, struct wil_ring *ring,
			   char _s, char _h)
{
	void __iomem *x = wmi_addr(wil, ring->hwtail);
	void __iomem *x;
	u32 v;

	seq_printf(s, "RING %s = {\n", name);
@@ -85,7 +87,21 @@ static void wil_print_ring(struct seq_file *s, struct wil6210_priv *wil,
	else
		seq_printf(s, "  swtail = %d\n", ring->swtail);
	seq_printf(s, "  swhead = %d\n", ring->swhead);
	if (wil->use_enhanced_dma_hw) {
		int ring_id = ring->is_rx ?
			WIL_RX_DESC_RING_ID : ring - wil->ring_tx;
		/* SUBQ_CONS is a table of 32 entries, one for each Q pair.
		 * lower 16bits are for even ring_id and upper 16bits are for
		 * odd ring_id
		 */
		x = wmi_addr(wil, RGF_DMA_SCM_SUBQ_CONS + 4 * (ring_id / 2));
		v = readl_relaxed(x);

		v = (ring_id % 2 ? (v >> 16) : (v & 0xffff));
		seq_printf(s, "  hwhead = %u\n", v);
	}
	seq_printf(s, "  hwtail = [0x%08x] -> ", ring->hwtail);
	x = wmi_addr(wil, ring->hwtail);
	if (x) {
		v = readl(x);
		seq_printf(s, "0x%08x = %d\n", v, v);
@@ -188,7 +204,7 @@ static const struct file_operations fops_ring = {
static void wil_print_sring(struct seq_file *s, struct wil6210_priv *wil,
			    struct wil_status_ring *sring)
{
	void __iomem *x = wmi_addr(wil, sring->hwtail);
	void __iomem *x;
	int sring_idx = sring - wil->srings;
	u32 v;

@@ -199,7 +215,19 @@ static void wil_print_sring(struct seq_file *s, struct wil6210_priv *wil,
	seq_printf(s, "  size   = %d\n", sring->size);
	seq_printf(s, "  elem_size   = %zu\n", sring->elem_size);
	seq_printf(s, "  swhead = %d\n", sring->swhead);
	if (wil->use_enhanced_dma_hw) {
		/* COMPQ_PROD is a table of 32 entries, one for each Q pair.
		 * lower 16bits are for even ring_id and upper 16bits are for
		 * odd ring_id
		 */
		x = wmi_addr(wil, RGF_DMA_SCM_COMPQ_PROD + 4 * (sring_idx / 2));
		v = readl_relaxed(x);

		v = (sring_idx % 2 ? (v >> 16) : (v & 0xffff));
		seq_printf(s, "  hwhead = %u\n", v);
	}
	seq_printf(s, "  hwtail = [0x%08x] -> ", sring->hwtail);
	x = wmi_addr(wil, sring->hwtail);
	if (x) {
		v = readl_relaxed(x);
		seq_printf(s, "0x%08x = %d\n", v, v);
@@ -1124,18 +1152,17 @@ static int wil_txdesc_debugfs_show(struct seq_file *s, void *data)

	if (wil->use_enhanced_dma_hw) {
		if (tx) {
			skb = ring->ctx[txdesc_idx].skb;
		} else {
			skb = ring->ctx ? ring->ctx[txdesc_idx].skb : NULL;
		} else if (wil->rx_buff_mgmt.buff_arr) {
			struct wil_rx_enhanced_desc *rx_d =
				(struct wil_rx_enhanced_desc *)
				&ring->va[txdesc_idx].rx.enhanced;
			u16 buff_id = le16_to_cpu(rx_d->mac.buff_id);

			if (!wil_val_in_range(buff_id, 0,
					      wil->rx_buff_mgmt.size)) {
					      wil->rx_buff_mgmt.size))
				seq_printf(s, "invalid buff_id %d\n", buff_id);
				return 0;
			}
			else
				skb = wil->rx_buff_mgmt.buff_arr[buff_id].skb;
		}
	} else {
@@ -1180,7 +1207,7 @@ static int wil_status_msg_debugfs_show(struct seq_file *s, void *data)
	struct wil6210_priv *wil = s->private;
	int sring_idx = dbg_sring_index;
	struct wil_status_ring *sring;
	bool tx = sring_idx == wil->tx_sring_idx ? 1 : 0;
	bool tx;
	u32 status_msg_idx = dbg_status_msg_index;
	u32 *u;

@@ -1190,6 +1217,7 @@ static int wil_status_msg_debugfs_show(struct seq_file *s, void *data)
	}

	sring = &wil->srings[sring_idx];
	tx = !sring->is_rx;

	if (!sring->va) {
		seq_printf(s, "No %cX status ring\n", tx ? 'T' : 'R');
+4 −3
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
				    (~(BIT_DMA_EP_RX_ICR_RX_HTRSH)))
#define WIL6210_IMC_TX		(BIT_DMA_EP_TX_ICR_TX_DONE | \
				BIT_DMA_EP_TX_ICR_TX_DONE_N(0))
#define WIL6210_IMC_TX_EDMA		BIT_TX_STATUS_IRQ
#define WIL6210_IMC_TX_EDMA		(0xFFFFFFFFUL)
#define WIL6210_IMC_RX_EDMA		BIT_RX_STATUS_IRQ
#define WIL6210_IMC_MISC_NO_HALP	(ISR_MISC_FW_READY | \
					 ISR_MISC_MBOX_EVT | \
@@ -215,6 +215,7 @@ void wil_unmask_irq(struct wil6210_priv *wil)
void wil_configure_interrupt_moderation_edma(struct wil6210_priv *wil)
{
	u32 moderation;
	int i, num_int_lines = 2 /* Rx + Tx status */;

	wil_s(wil, RGF_INT_GEN_IDLE_TIME_LIMIT, WIL_EDMA_IDLE_TIME_LIMIT_USEC);

@@ -223,8 +224,8 @@ void wil_configure_interrupt_moderation_edma(struct wil6210_priv *wil)
	/* Update RX and TX moderation */
	moderation = wil->rx_max_burst_duration |
		(WIL_EDMA_AGG_WATERMARK << WIL_EDMA_AGG_WATERMARK_POS);
	wil_w(wil, RGF_INT_CTRL_INT_GEN_CFG_0, moderation);
	wil_w(wil, RGF_INT_CTRL_INT_GEN_CFG_1, moderation);
	for (i = 0; i < num_int_lines; i++)
		wil_w(wil, i * 4 + RGF_INT_CTRL_INT_GEN_CFG, moderation);

	/* Treat special events as regular
	 * (set bit 0 to 0x1 and clear bits 1-8)
+10 −2
Original line number Diff line number Diff line
@@ -186,10 +186,18 @@ static int wil6210_netdev_poll_tx_edma(struct napi_struct *napi, int budget)
						napi_tx);
	int tx_done;
	/* There is only one status TX ring */
	struct wil_status_ring *sring = &wil->srings[wil->tx_sring_idx];
	struct wil_status_ring *sring;

	if (!sring->va)
	if (wil->tx_sring_idx >= WIL6210_MAX_STATUS_RINGS) {
		napi_complete(napi);
		return 0;
	}

	sring = &wil->srings[wil->tx_sring_idx];
	if (!sring->va) {
		napi_complete(napi);
		return 0;
	}

	tx_done = wil_tx_sring_handler(wil, sring);

+36 −30
Original line number Diff line number Diff line
@@ -743,21 +743,19 @@ static void wil_get_netif_rx_params(struct sk_buff *skb, int *cid,
 * Pass Rx packet to the netif. Update statistics.
 * Called in softirq context (NAPI poll).
 */
void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev)
void wil_netif_rx(struct sk_buff *skb, struct net_device *ndev, int cid,
		  struct wil_net_stats *stats, bool gro)
{
	gro_result_t rc = GRO_NORMAL;
	struct wil6210_vif *vif = ndev_to_vif(ndev);
	struct wil6210_priv *wil = ndev_to_wil(ndev);
	struct wireless_dev *wdev = vif_to_wdev(vif);
	unsigned int len = skb->len;
	int cid;
	int security;
	u8 *sa, *da = wil_skb_get_da(skb);
	/* here looking for DA, not A1, thus Rxdesc's 'mcast' indication
	 * is not suitable, need to look at data
	 */
	int mcast = is_multicast_ether_addr(da);
	struct wil_net_stats *stats;
	struct sk_buff *xmit_skb = NULL;
	static const char * const gro_res_str[] = {
		[GRO_MERGED]		= "GRO_MERGED",
@@ -767,25 +765,6 @@ void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev)
		[GRO_DROP]		= "GRO_DROP",
	};

	wil->txrx_ops.get_netif_rx_params(skb, &cid, &security);

	stats = &wil->sta[cid].stats;

	skb_orphan(skb);

	if (security && (wil->txrx_ops.rx_crypto_check(wil, skb) != 0)) {
		rc = GRO_DROP;
		dev_kfree_skb(skb);
		stats->rx_replay++;
		goto stats;
	}

	/* check errors reported by HW and update statistics */
	if (unlikely(wil->txrx_ops.rx_error_check(wil, skb, stats))) {
		dev_kfree_skb(skb);
		return;
	}

	if (wdev->iftype == NL80211_IFTYPE_STATION) {
		sa = wil_skb_get_sa(skb);
		if (mcast && ether_addr_equal(sa, ndev->dev_addr)) {
@@ -831,7 +810,10 @@ void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev)
	if (skb) { /* deliver to local stack */
		skb->protocol = eth_type_trans(skb, ndev);
		skb->dev = ndev;
		if (gro)
			rc = napi_gro_receive(&wil->napi_rx, skb);
		else
			netif_rx_ni(skb);
		wil_dbg_txrx(wil, "Rx complete %d bytes => %s\n",
			     len, gro_res_str[rc]);
	}
@@ -851,6 +833,36 @@ void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev)
	}
}

void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev)
{
	int cid, security;
	struct wil6210_priv *wil = ndev_to_wil(ndev);
	struct wil_net_stats *stats;

	wil->txrx_ops.get_netif_rx_params(skb, &cid, &security);

	stats = &wil->sta[cid].stats;

	skb_orphan(skb);

	if (security && (wil->txrx_ops.rx_crypto_check(wil, skb) != 0)) {
		dev_kfree_skb(skb);
		ndev->stats.rx_dropped++;
		stats->rx_replay++;
		stats->rx_dropped++;
		wil_dbg_txrx(wil, "Rx drop %d bytes\n", skb->len);
		return;
	}

	/* check errors reported by HW and update statistics */
	if (unlikely(wil->txrx_ops.rx_error_check(wil, skb, stats))) {
		dev_kfree_skb(skb);
		return;
	}

	wil_netif_rx(skb, ndev, cid, stats, true);
}

/**
 * Proceed all completed skb's from Rx VRING
 *
@@ -1440,12 +1452,6 @@ static struct wil_ring *wil_find_tx_bcast_2(struct wil6210_priv *wil,
	return v;
}

static inline
void wil_tx_desc_set_nr_frags(struct vring_tx_desc *d, int nr_frags)
{
	d->mac.d[2] |= (nr_frags << MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_POS);
}

/**
 * Sets the descriptor @d up for csum and/or TSO offloading. The corresponding
 * @skb is used to obtain the protocol and headers length.
+9 −12
Original line number Diff line number Diff line
/* SPDX-License-Identifier: ISC */
/*
 * Copyright (c) 2012-2016 Qualcomm Atheros, Inc.
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef WIL6210_TXRX_H
@@ -645,7 +634,15 @@ static inline void wil_skb_set_cid(struct sk_buff *skb, u8 cid)
	skb_rx_info->rx_info.cid = cid;
}

static inline
void wil_tx_desc_set_nr_frags(struct vring_tx_desc *d, int nr_frags)
{
	d->mac.d[2] |= (nr_frags << MAC_CFG_DESC_TX_2_NUM_OF_DESCRIPTORS_POS);
}

void wil_netif_rx_any(struct sk_buff *skb, struct net_device *ndev);
void wil_netif_rx(struct sk_buff *skb, struct net_device *ndev, int cid,
		  struct wil_net_stats *stats, bool gro);
void wil_rx_reorder(struct wil6210_priv *wil, struct sk_buff *skb);
void wil_rx_bar(struct wil6210_priv *wil, struct wil6210_vif *vif,
		u8 cid, u8 tid, u16 seq);
Loading