lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211223011358.4031459-44-davidm@egauge.net>
Date:   Thu, 23 Dec 2021 01:14:07 +0000 (UTC)
From:   David Mosberger-Tang <davidm@...uge.net>
To:     Ajay Singh <ajay.kathat@...rochip.com>
Cc:     Claudiu Beznea <claudiu.beznea@...rochip.com>,
        Kalle Valo <kvalo@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        David Mosberger-Tang <davidm@...uge.net>
Subject: [PATCH v2 43/50] wilc1000: add support for zero-copy transmit of tx
 packets

Add the infrastructure to enable zero-copy transmits.  This is
currently a no-op as the SPI or SDIO drivers will need to implement
hif_sk_buffs_tx to take advantage of this.

Signed-off-by: David Mosberger-Tang <davidm@...uge.net>
---
 .../net/wireless/microchip/wilc1000/wlan.c    | 43 ++++++++++++++++++-
 .../net/wireless/microchip/wilc1000/wlan.h    |  2 +
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 08f3e96bf72cf..d96a7e2a0bd59 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -935,6 +935,44 @@ static int copy_and_send_packets(struct wilc *wilc, int entries)
 	return ret;
 }
 
+/**
+ * zero_copy_send_packets() - send packets to the chip (copy-free).
+ * @wilc: Pointer to the wilc structure.
+ * @entries: The number of packets to send from the VMM table.
+ *
+ * Zero-copy version of sending the packets in the VMM table to the
+ * chip.
+ *
+ * Context: The wilc1000 bus must have been released but the chip
+ *	must be awake.
+ *
+ * Return: Negative number on error, 0 on success.
+ */
+static int zero_copy_send_packets(struct wilc *wilc, int entries)
+{
+	const struct wilc_hif_func *func = wilc->hif_func;
+	struct wilc_skb_tx_cb *tx_cb;
+	struct sk_buff *tqe;
+	int ret, i = 0;
+
+	acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
+
+	ret = func->hif_clear_int_ext(wilc, ENABLE_TX_VMM);
+	if (ret == 0)
+		ret = func->hif_sk_buffs_tx(wilc, 0, entries, &wilc->chipq);
+
+	release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
+
+	for (i = 0; i < entries; ++i) {
+		tqe = __skb_dequeue(&wilc->chipq);
+		tx_cb = WILC_SKB_TX_CB(tqe);
+		wilc->fw[tx_cb->q_num].count++;
+		wilc->chipq_bytes -= tqe->len;
+		wilc_wlan_tx_packet_done(tqe, ret == 0);
+	}
+	return ret;
+}
+
 int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
 {
 	int vmm_table_len, entries;
@@ -966,7 +1004,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
 	if (entries <= 0) {
 		ret = entries;
 	} else {
-		ret = copy_and_send_packets(wilc, entries);
+		if (wilc->hif_func->hif_sk_buffs_tx)
+			ret = zero_copy_send_packets(wilc, entries);
+		else
+			ret = copy_and_send_packets(wilc, entries);
 	}
 	if (ret >= 0 && entries < vmm_table_len)
 		ret = WILC_VMM_ENTRY_FULL_RETRY;
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h
index 11a54320ffd05..bda31f0970bda 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.h
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.h
@@ -367,6 +367,8 @@ struct wilc_hif_func {
 	int (*hif_read_size)(struct wilc *wilc, u32 *size);
 	int (*hif_block_tx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
 	int (*hif_block_rx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size);
+	int (*hif_sk_buffs_tx)(struct wilc *wilc, u32 addr,
+			       size_t num_skbs, struct sk_buff_head *skbs);
 	int (*hif_sync_ext)(struct wilc *wilc, int nint);
 	int (*enable_interrupt)(struct wilc *nic);
 	void (*disable_interrupt)(struct wilc *nic);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ