From patchwork Mon Mar 15 12:09:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 400402 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3356534jai; Mon, 15 Mar 2021 05:09:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmEBTjdi6ehDhKTLKqEB/F5FFazoxEIoNRcayO3glJL36Cm36YrKpnVnC2ZJvhVDvE39wd X-Received: by 2002:a5d:564b:: with SMTP id j11mr27485014wrw.326.1615810149482; Mon, 15 Mar 2021 05:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615810149; cv=none; d=google.com; s=arc-20160816; b=ZtSSr6jsnBAShOxFEGofKpax++OJ3Th+WsYP40+5R61hVf2Pip5J11g0W0puOHTmRG j7D3j1OdTliVQ9QEJGtd3gL3JfC6+hE0vbVTmxxZ+u+H0xYHyXSx694G9rBWGOuyhDau jNLvmcVkfgJh1m878ylrD005VYmcNv/iffoosFnHu4PPkJzK4uB7MxPdQghSMPDMmAC0 EwgEOAYYfbZElf3y4lMY590xkxvPil9CXibkddnkrP1S/XFg1DtAkNQh6lUJ2hSKU93Y P60fFzLJTNaUuKibqd47VTqXIR1IVIGkH8AJaz8Fm3JalU9H8g2pMI3MiCIY2ZHPezQm QCfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GoM6r0aQNFv6P86Jh2bARDY3W042U1bUTvbdF/AjcU4=; b=frnZSOIPLER+Za4IGBD6gwAa4KsbmWnWljdXh9VBy4YFrkO16DuncLW6L2BzVgAukJ XzYZlKKHCxh5W4qzabBgIOx2l0H5smvajE/Rf8g/zgu/Nq43z6LbSdlRxfnHK2vXuZ0I UZLXt1sSGEviNVNHyWlc11QBJ5zhyq8iCdwKbFhCxyu9pMit0GtAjy/IYNmhlOXN7iXl vfy5b//uJB1c4Ss+oSVPPidIUVGdkbiro2/1H9SMTF9L7Ts7ckI9og7PQfsNnFVsGZX7 1gqOwRCgb8faQnzWRwo1M4go7ISV4yfWgb1Kq7HIxA2J8nwuwAHUoUByb591xQoOdhSq DiaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XNVEh20c; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si9901547wmk.85.2021.03.15.05.09.09; Mon, 15 Mar 2021 05:09:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XNVEh20c; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230520AbhCOMIh (ORCPT + 2 others); Mon, 15 Mar 2021 08:08:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230452AbhCOMIN (ORCPT ); Mon, 15 Mar 2021 08:08:13 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D67C7C061574 for ; Mon, 15 Mar 2021 05:08:12 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id a18so8530982wrc.13 for ; Mon, 15 Mar 2021 05:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GoM6r0aQNFv6P86Jh2bARDY3W042U1bUTvbdF/AjcU4=; b=XNVEh20cIrQnryK4qPBNcAkK7p3E9OSmEDiZnM52sZCD6L/1M4fW1dwW/ugYUBXe6R j11OLv1Y4eLxxAbZdAgfPj7Hu4heDs3xP5NIAemRRe2HbetO427BUJ2YTH9SUo4QS+8x CN93zzqkptfkqN/mV36Ezx9VlnURttrQLYRDIuVDPuHRY9LjItNQME8SqYHpBkqbBx6Z vtBVM80aQwQdf43cHNX0+MXHHcVmRrVbmnhNVlRIirCf7KjCA+YK7Fe9XmnzhxeIVe0M LyqWIH+kwd/amvnS+hFXNICUgqPNkg/5f9zZP+/vurwbP5nlMYWdHigIU/alMSKi0IVb 51VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GoM6r0aQNFv6P86Jh2bARDY3W042U1bUTvbdF/AjcU4=; b=WWrPzVOYxeny/48/Vs+JnTmIBlJWNR087ZPIOg/H/R0vHiH29Ns966vGWM0loD4sWM /68wt602AkdXBsQb4vIcgDKeXPnJhCzWBz+cWlPqk/doBQJKCH7h4ea/dMA6mH/RuHrF bUO23H398ZMyYaFPCt6tr00xtZG2Ci6V4Y2FXLVmXgJPkX4GY8R2OjG7k1XywKnB5d6b 59HLfZs8Yq99+n/6RU6SQ8eQOJj4fG5exgfM9Tbfr7mkSJ2bQhEY+vpFwyH5p/73tRYY Lep0r1AitvqBl8/2gTBElNBN+WSvF4DX34J0BsH1tE/JkEfC1i4yAZeKihkdi/6rDqpZ Qj9Q== X-Gm-Message-State: AOAM531n0AeVxGaRChpNGqKCNu8sbM5S/MQRKOsT2c8JPCd2ZH4Mytu3 P5tSTzhIB/MDDlyGmIJZ3vmWpQ== X-Received: by 2002:a05:6000:1ca:: with SMTP id t10mr27272945wrx.45.1615810091428; Mon, 15 Mar 2021 05:08:11 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id c18sm29239891wmk.0.2021.03.15.05.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 05:08:10 -0700 (PDT) From: Bryan O'Donoghue To: kvalo@codeaurora.org, wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org Cc: bryan.odonoghue@linaro.org, shawn.guo@linaro.org, benl@squareup.com, loic.poulain@linaro.org, bjorn.andersson@linaro.org Subject: [PATCH v2 03/12] wcn36xx: Add ipv4 ARP offload support in suspend Date: Mon, 15 Mar 2021 12:09:28 +0000 Message-Id: <20210315120937.2512341-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210315120937.2512341-1-bryan.odonoghue@linaro.org> References: <20210315120937.2512341-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add ARP offload support. Firmware is capable of responding to ARP requests for a single ipv4 address only. Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/hal.h | 10 +++---- drivers/net/wireless/ath/wcn36xx/main.c | 5 +++- drivers/net/wireless/ath/wcn36xx/smd.c | 38 +++++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/smd.h | 4 +++ 4 files changed, 51 insertions(+), 6 deletions(-) -- 2.30.1 diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h index 65ef893f2736..b56c8292fa62 100644 --- a/drivers/net/wireless/ath/wcn36xx/hal.h +++ b/drivers/net/wireless/ath/wcn36xx/hal.h @@ -3465,7 +3465,7 @@ struct wcn36xx_hal_rem_bcn_filter_req { #define WCN36XX_HAL_OFFLOAD_ENABLE 1 #define WCN36XX_HAL_OFFLOAD_BCAST_FILTER_ENABLE 0x2 #define WCN36XX_HAL_OFFLOAD_ARP_AND_BCAST_FILTER_ENABLE \ - (HAL_OFFLOAD_ENABLE|HAL_OFFLOAD_BCAST_FILTER_ENABLE) + (WCN36XX_HAL_OFFLOAD_ENABLE | WCN36XX_HAL_OFFLOAD_BCAST_FILTER_ENABLE) struct wcn36xx_hal_ns_offload_params { u8 src_ipv6_addr[WCN36XX_HAL_IPV6_ADDR_LEN]; @@ -3487,10 +3487,10 @@ struct wcn36xx_hal_ns_offload_params { /* slot index for this offload */ u32 slot_index; u8 bss_index; -}; +} __packed; struct wcn36xx_hal_host_offload_req { - u8 offload_Type; + u8 offload_type; /* enable or disable */ u8 enable; @@ -3499,13 +3499,13 @@ struct wcn36xx_hal_host_offload_req { u8 host_ipv4_addr[4]; u8 host_ipv6_addr[WCN36XX_HAL_IPV6_ADDR_LEN]; } u; -}; +} __packed; struct wcn36xx_hal_host_offload_req_msg { struct wcn36xx_hal_msg_header header; struct wcn36xx_hal_host_offload_req host_offload_params; struct wcn36xx_hal_ns_offload_params ns_offload_params; -}; +} __packed; /* Packet Types. */ #define WCN36XX_HAL_KEEP_ALIVE_NULL_PKT 1 diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index c0c1ea18864f..f95103706100 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -1117,11 +1117,13 @@ static int wcn36xx_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow) vif_priv = wcn36xx_vif_to_priv(vif); if (!vif_priv->sta_assoc) goto out; + ret = wcn36xx_smd_arp_offload(wcn, vif, true); + if (ret) + goto out; ret = wcn36xx_smd_set_power_params(wcn, true); } out: mutex_unlock(&wcn->conf_mutex); - return ret; } @@ -1142,6 +1144,7 @@ static int wcn36xx_resume(struct ieee80211_hw *hw) goto out; wcn36xx_smd_set_power_params(wcn, false); + wcn36xx_smd_arp_offload(wcn, vif, false); } out: mutex_unlock(&wcn->conf_mutex); diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c index d0c3a1557e8d..478e363610e1 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.c +++ b/drivers/net/wireless/ath/wcn36xx/smd.c @@ -2756,6 +2756,43 @@ int wcn36xx_smd_set_mc_list(struct wcn36xx *wcn, return ret; } +int wcn36xx_smd_arp_offload(struct wcn36xx *wcn, struct ieee80211_vif *vif, + bool enable) +{ + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); + struct wcn36xx_hal_host_offload_req_msg msg_body; + int ret; + + mutex_lock(&wcn->hal_mutex); + + INIT_HAL_MSG(msg_body, WCN36XX_HAL_HOST_OFFLOAD_REQ); + msg_body.host_offload_params.offload_type = + WCN36XX_HAL_IPV4_ARP_REPLY_OFFLOAD; + if (enable) { + msg_body.host_offload_params.enable = + WCN36XX_HAL_OFFLOAD_ARP_AND_BCAST_FILTER_ENABLE; + memcpy(&msg_body.host_offload_params.u, + &vif->bss_conf.arp_addr_list[0], sizeof(__be32)); + } + msg_body.ns_offload_params.bss_index = vif_priv->bss_index; + + PREPARE_HAL_BUF(wcn->hal_buf, msg_body); + + ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len); + if (ret) { + wcn36xx_err("Sending host_offload_arp failed\n"); + goto out; + } + ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len); + if (ret) { + wcn36xx_err("host_offload_arp failed err=%d\n", ret); + goto out; + } +out: + mutex_unlock(&wcn->hal_mutex); + return ret; +} + int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev, void *buf, int len, void *priv, u32 addr) { @@ -2804,6 +2841,7 @@ int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev, case WCN36XX_HAL_8023_MULTICAST_LIST_RSP: case WCN36XX_HAL_START_SCAN_OFFLOAD_RSP: case WCN36XX_HAL_STOP_SCAN_OFFLOAD_RSP: + case WCN36XX_HAL_HOST_OFFLOAD_RSP: memcpy(wcn->hal_buf, buf, len); wcn->hal_rsp_len = len; complete(&wcn->hal_rsp_compl); diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h index 462860572e1f..6492a628ea6a 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.h +++ b/drivers/net/wireless/ath/wcn36xx/smd.h @@ -146,4 +146,8 @@ int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev, int wcn36xx_smd_set_mc_list(struct wcn36xx *wcn, struct ieee80211_vif *vif, struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp); + +int wcn36xx_smd_arp_offload(struct wcn36xx *wcn, struct ieee80211_vif *vif, + bool enable); + #endif /* _SMD_H_ */