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

Commit 2fc28de5 authored by Arik Nemtsov's avatar Arik Nemtsov Committed by Luciano Coelho
Browse files

wlcore/wl18xx: add hw op for setting Tx HW checksum



Some chip families are capable of checksumming certain classes of Tx
packets in HW. Indicate this fact in the netdev features and perform the
HW checksum by protocol type for the 18xx family.

Fix the location of the skb network header when we move it so we can
rely on it when setting the checksum.

Signed-off-by: default avatarArik Nemtsov <arik@wizery.com>
Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent b8422dcb
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1288,6 +1288,13 @@ static void wl12xx_get_mac(struct wl1271 *wl)
		wl12xx_get_fuse_mac(wl);
}

static void wl12xx_set_tx_desc_csum(struct wl1271 *wl,
				    struct wl1271_tx_hw_descr *desc,
				    struct sk_buff *skb)
{
	desc->wl12xx_reserved = 0;
}

static struct wlcore_ops wl12xx_ops = {
	.identify_chip		= wl12xx_identify_chip,
	.identify_fw		= wl12xx_identify_fw,
@@ -1306,6 +1313,7 @@ static struct wlcore_ops wl12xx_ops = {
	.sta_get_ap_rate_mask	= wl12xx_sta_get_ap_rate_mask,
	.get_pg_ver		= wl12xx_get_pg_ver,
	.get_mac		= wl12xx_get_mac,
	.set_tx_desc_csum	= wl12xx_set_tx_desc_csum,
};

static struct ieee80211_sta_ht_cap wl12xx_ht_cap = {
+26 −0
Original line number Diff line number Diff line
@@ -55,3 +55,29 @@ int wl18xx_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap,

	return ret;
}

int wl18xx_acx_set_checksum_state(struct wl1271 *wl)
{
	struct wl18xx_acx_checksum_state *acx;
	int ret;

	wl1271_debug(DEBUG_ACX, "acx checksum state");

	acx = kzalloc(sizeof(*acx), GFP_KERNEL);
	if (!acx) {
		ret = -ENOMEM;
		goto out;
	}

	acx->checksum_state = CHECKSUM_OFFLOAD_ENABLED;

	ret = wl1271_cmd_configure(wl, ACX_CHECKSUM_CONFIG, acx, sizeof(*acx));
	if (ret < 0) {
		wl1271_warning("failed to set Tx checksum state: %d", ret);
		goto out;
	}

out:
	kfree(acx);
	return ret;
}
+16 −0
Original line number Diff line number Diff line
@@ -45,8 +45,24 @@ struct wl18xx_acx_host_config_bitmap {

} __packed;

enum {
	CHECKSUM_OFFLOAD_DISABLED = 0,
	CHECKSUM_OFFLOAD_ENABLED  = 1,
	CHECKSUM_OFFLOAD_FAKE_RX  = 2,
	CHECKSUM_OFFLOAD_INVALID  = 0xFF
};

struct wl18xx_acx_checksum_state {
	struct acx_header header;

	 /* enum acx_checksum_state */
	u8 checksum_state;
	u8 pad[3];
} __packed;

int wl18xx_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap,
				  u32 sdio_blk_size, u32 extra_mem_blks,
				  u32 len_field_size);
int wl18xx_acx_set_checksum_state(struct wl1271 *wl);

#endif /* __WL12XX_ACX_H__ */
+31 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@

#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/ip.h>

#include "../wlcore/wlcore.h"
#include "../wlcore/debug.h"
@@ -501,7 +502,36 @@ static int wl18xx_hw_init(struct wl1271 *wl)
	if (ret < 0)
		return ret;

	ret = wl18xx_acx_set_checksum_state(wl);
	if (ret != 0)
		return ret;

	return ret;
}

static void wl18xx_set_tx_desc_csum(struct wl1271 *wl,
				    struct wl1271_tx_hw_descr *desc,
				    struct sk_buff *skb)
{
	u32 ip_hdr_offset;
	struct iphdr *ip_hdr;

	if (skb->ip_summed != CHECKSUM_PARTIAL) {
		desc->wl18xx_checksum_data = 0;
		return;
	}

	ip_hdr_offset = skb_network_header(skb) - skb_mac_header(skb);
	if (WARN_ON(ip_hdr_offset >= (1<<7))) {
		desc->wl18xx_checksum_data = 0;
		return;
	}

	desc->wl18xx_checksum_data = ip_hdr_offset << 1;

	/* FW is interested only in the LSB of the protocol  TCP=0 UDP=1 */
	ip_hdr = (void *)skb_network_header(skb);
	desc->wl18xx_checksum_data |= (ip_hdr->protocol & 0x01);
}

static struct wlcore_ops wl18xx_ops = {
@@ -517,6 +547,7 @@ static struct wlcore_ops wl18xx_ops = {
	.tx_immediate_compl = wl18xx_tx_immediate_completion,
	.tx_delayed_compl = NULL,
	.hw_init	= wl18xx_hw_init,
	.set_tx_desc_csum = wl18xx_set_tx_desc_csum,
};

int __devinit wl18xx_probe(struct platform_device *pdev)
+1 −0
Original line number Diff line number Diff line
@@ -1245,6 +1245,7 @@ enum {
	ACX_CONFIG_HANGOVER              = 0x0042,
	ACX_FEATURE_CFG                  = 0x0043,
	ACX_PROTECTION_CFG               = 0x0044,
	ACX_CHECKSUM_CONFIG              = 0x0045,
};


Loading