From patchwork Mon Jan 23 05:31:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13111675 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24429C54EED for ; Mon, 23 Jan 2023 05:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230239AbjAWFb5 (ORCPT ); Mon, 23 Jan 2023 00:31:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230148AbjAWFbz (ORCPT ); Mon, 23 Jan 2023 00:31:55 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DCA5EC7B for ; Sun, 22 Jan 2023 21:31:54 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d9so10333168pll.9 for ; Sun, 22 Jan 2023 21:31:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0lS8RxxZjmGlqZ8cnEymEaNnDbuVt+IfNcHGvu/vuIE=; b=XcZK0qpPVooMp9/r0K+9ME9y5HWbzxEo95R2wiW4GvYj4yH9fVkG0iqF6fzePlOvqA XuKE+V0y8a6e81v1UTo9zZfZj0RZvxoOS5JesxI3FQBSwFWKYQ5JZtgXKkm1V2jE6HpL 8r5O7y6crKh1ArP3+U54Rugxvth+7E0C/xUzo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0lS8RxxZjmGlqZ8cnEymEaNnDbuVt+IfNcHGvu/vuIE=; b=cjXc4pkW3gwg7E5K60kq7Vsfeoe5MFkPONeWsf1JuVqT/W+kD6VyXVSA5BtXGcTy4D 3Pp90uqlWmQFrrXLLYLbXgtL2VzZaNvyk6rZjKXhmXXQj1ccPxQ1yrBldRhilL+JSjdi Zw08vlcnKU5K8pop9uU+U2Kob3U/9CurN8MnX9rmYuC+7i02nxfdhKZKK6F1naTjl7kF UaEt3eS1IEr5OGGeeDTU1Lhm9AiWw6+/XfjyKGH4Zrdm3idxyNlL6RxaWlazskqIgNlB QRgL7Q4WzEDL/KzyfLCEvJVSEYgWn68Y+tdfjwCC2Q+vy3J65iIf0iQe04mkMNwWRnpz xbJg== X-Gm-Message-State: AFqh2kqi8uNAl4wh6WIOs5adiTLC8+ImUzi9jFe7xD0PEghDatZcPxV8 q0OKnsw+E9kqaGeN3RBYbxsLxw== X-Google-Smtp-Source: AMrXdXv4d9WR0BLVLX8gqZyPGFcJu7LLqeAEAcsKCvousE8W1W3sAA7X/k7BITaizhVmlaO3U/LfDA== X-Received: by 2002:a17:903:324e:b0:185:441e:222c with SMTP id ji14-20020a170903324e00b00185441e222cmr24256123plb.39.1674451913779; Sun, 22 Jan 2023 21:31:53 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id m3-20020a170902db0300b0018963b8e131sm9125244plx.290.2023.01.22.21.31.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Jan 2023 21:31:53 -0800 (PST) From: Doug Brown To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dan Williams , Simon Horman , libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v4 1/4] wifi: libertas: fix code style in Marvell structs Date: Sun, 22 Jan 2023 21:31:29 -0800 Message-Id: <20230123053132.30710-2-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123053132.30710-1-doug@schmorgal.com> References: <20230123053132.30710-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Several of the structs are using the deprecated convention of items[1] for a dynamically sized trailing element. Convert these structs to the modern C99 style of items[]. Also fix a couple of camel case struct element names. Signed-off-by: Doug Brown --- drivers/net/wireless/marvell/libertas/types.h | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/marvell/libertas/types.h b/drivers/net/wireless/marvell/libertas/types.h index cd4ceb6f885d..de60becaac12 100644 --- a/drivers/net/wireless/marvell/libertas/types.h +++ b/drivers/net/wireless/marvell/libertas/types.h @@ -105,23 +105,23 @@ struct mrvl_ie_header { struct mrvl_ie_data { struct mrvl_ie_header header; - u8 Data[1]; + u8 data[]; } __packed; struct mrvl_ie_rates_param_set { struct mrvl_ie_header header; - u8 rates[1]; + u8 rates[]; } __packed; struct mrvl_ie_ssid_param_set { struct mrvl_ie_header header; - u8 ssid[1]; + u8 ssid[]; } __packed; struct mrvl_ie_wildcard_ssid_param_set { struct mrvl_ie_header header; - u8 MaxSsidlength; - u8 ssid[1]; + u8 maxssidlength; + u8 ssid[]; } __packed; struct chanscanmode { @@ -146,7 +146,7 @@ struct chanscanparamset { struct mrvl_ie_chanlist_param_set { struct mrvl_ie_header header; - struct chanscanparamset chanscanparam[1]; + struct chanscanparamset chanscanparam[]; } __packed; struct mrvl_ie_cf_param_set { @@ -164,12 +164,12 @@ struct mrvl_ie_ds_param_set { struct mrvl_ie_rsn_param_set { struct mrvl_ie_header header; - u8 rsnie[1]; + u8 rsnie[]; } __packed; struct mrvl_ie_tsf_timestamp { struct mrvl_ie_header header; - __le64 tsftable[1]; + __le64 tsftable[]; } __packed; /* v9 and later firmware only */ @@ -220,7 +220,7 @@ struct led_pin { struct mrvl_ie_ledgpio { struct mrvl_ie_header header; - struct led_pin ledpin[1]; + struct led_pin ledpin[]; } __packed; struct led_bhv { @@ -233,7 +233,7 @@ struct led_bhv { struct mrvl_ie_ledbhv { struct mrvl_ie_header header; - struct led_bhv ledbhv[1]; + struct led_bhv ledbhv[]; } __packed; /* From patchwork Mon Jan 23 05:31:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13111676 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9701C05027 for ; Mon, 23 Jan 2023 05:32:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230369AbjAWFcB (ORCPT ); Mon, 23 Jan 2023 00:32:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbjAWFb5 (ORCPT ); Mon, 23 Jan 2023 00:31:57 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0473EC69 for ; Sun, 22 Jan 2023 21:31:55 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id t12-20020a17090aae0c00b00229f4cff534so5628024pjq.1 for ; Sun, 22 Jan 2023 21:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A0fz9zHVDO2m4yGb0WkSftssKbcC8YshpBpIYHhLj7c=; b=YtpYWKD1RCi3cTP3XrrnB/WHttQVmyq0+fxnE232LMmf6udL+pQAqDDKcRjxAb4wMf 6Hvrj9ybI4YT+EuV5AkugIFht0gh0UOT2mWN8lnqKCqeSZjfQOMuIgDtQ1DHIxlz7uXp sWpuVFXofqwKkV6JrdJotO5kgr6ypRwjcHfPs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A0fz9zHVDO2m4yGb0WkSftssKbcC8YshpBpIYHhLj7c=; b=srAsSIgbEpveaL7OlGWyBiEyaV60OAgDsORJdrp/gul018sqqYWsQm2cv2JVPm5Zno 6SQsDuWTjegLoehIyQkXYRago97vcqVwIpKU8q4QPJvFV02bEzU4HHsx17zY+KSzgRL1 Iq0FzmfRbZpQ3kHUNGkIsvzzpflCRk5UQZ/8B/X+ONzUP90d/p82vqNNfRVImFX1X/Zs vWRUuZx10Hj9I+HA6q8EiaF1ISj/gVVgTXXQXHslA1bGvBUjVoD872yIEIHdJv73D/1i FWKvIawjRXU4R3TpxTb+9zrXBYqzTwWSKjMHwTYulhD9rzOzXFZObTId7hDSZ3wYj6e+ VXrw== X-Gm-Message-State: AFqh2kqbnTLZ1WCQwbMMTECcjJm+4US3KgTqZO3skJrJW0BmdZ7lXnVp 9ixON80xv8KixGjBLxiRcuR3xg== X-Google-Smtp-Source: AMrXdXusvSxSXsCftAbS8TjS01eWzPAOdRLnzG++9siaPiVBq7PGYvPhjJV7xS1Ofhvxus2zcCY59g== X-Received: by 2002:a05:6a20:9f09:b0:b8:c6ec:a269 with SMTP id mk9-20020a056a209f0900b000b8c6eca269mr24710795pzb.16.1674451915198; Sun, 22 Jan 2023 21:31:55 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id m3-20020a170902db0300b0018963b8e131sm9125244plx.290.2023.01.22.21.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Jan 2023 21:31:54 -0800 (PST) From: Doug Brown To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dan Williams , Simon Horman , libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v4 2/4] wifi: libertas: only add RSN/WPA IE in lbs_add_wpa_tlv Date: Sun, 22 Jan 2023 21:31:30 -0800 Message-Id: <20230123053132.30710-3-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123053132.30710-1-doug@schmorgal.com> References: <20230123053132.30710-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The existing code only converts the first IE to a TLV, but it returns a value that takes the length of all IEs into account. When there is more than one IE (which happens with modern wpa_supplicant versions for example), the returned length is too long and extra junk TLVs get sent to the firmware, resulting in an association failure. Fix this by finding the first RSN or WPA IE and only adding that. This has the extra benefit of working properly if the RSN/WPA IE isn't the first one in the IE buffer. While we're at it, clean up the code to use the available structs like the other lbs_add_* functions instead of directly manipulating the TLV buffer. Signed-off-by: Doug Brown --- drivers/net/wireless/marvell/libertas/cfg.c | 28 +++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/marvell/libertas/cfg.c b/drivers/net/wireless/marvell/libertas/cfg.c index 3e065cbb0af9..3f35dc7a1d7d 100644 --- a/drivers/net/wireless/marvell/libertas/cfg.c +++ b/drivers/net/wireless/marvell/libertas/cfg.c @@ -416,10 +416,20 @@ static int lbs_add_cf_param_tlv(u8 *tlv) static int lbs_add_wpa_tlv(u8 *tlv, const u8 *ie, u8 ie_len) { - size_t tlv_len; + struct mrvl_ie_data *wpatlv = (struct mrvl_ie_data *)tlv; + const struct element *wpaie; + + /* Find the first RSN or WPA IE to use */ + wpaie = cfg80211_find_elem(WLAN_EID_RSN, ie, ie_len); + if (!wpaie) + wpaie = cfg80211_find_vendor_elem(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, + ie, ie_len); + if (!wpaie || wpaie->datalen > 128) + return 0; /* - * We need just convert an IE to an TLV. IEs use u8 for the header, + * Convert the found IE to a TLV. IEs use u8 for the header, * u8 type * u8 len * u8[] data @@ -428,14 +438,12 @@ static int lbs_add_wpa_tlv(u8 *tlv, const u8 *ie, u8 ie_len) * __le16 len * u8[] data */ - *tlv++ = *ie++; - *tlv++ = 0; - tlv_len = *tlv++ = *ie++; - *tlv++ = 0; - while (tlv_len--) - *tlv++ = *ie++; - /* the TLV is two bytes larger than the IE */ - return ie_len + 2; + wpatlv->header.type = cpu_to_le16(wpaie->id); + wpatlv->header.len = cpu_to_le16(wpaie->datalen); + memcpy(wpatlv->data, wpaie->data, wpaie->datalen); + + /* Return the total number of bytes added to the TLV buffer */ + return sizeof(struct mrvl_ie_header) + wpaie->datalen; } /* From patchwork Mon Jan 23 05:31:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13111677 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E593C38142 for ; Mon, 23 Jan 2023 05:32:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231130AbjAWFcH (ORCPT ); Mon, 23 Jan 2023 00:32:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbjAWFb5 (ORCPT ); Mon, 23 Jan 2023 00:31:57 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23698EC7B for ; Sun, 22 Jan 2023 21:31:57 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d3so10333515plr.10 for ; Sun, 22 Jan 2023 21:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GWC1KMyV1A6Rl/COql8OC8fu95Avmd8JBknQzjt01sI=; b=Zf/NDMEwvDxlPca3OM3Bm9bWcAeHNm9tS4PI2VKNDzm/pxcYYTLfLQM8A3HFvzwvM5 gkBMQkSHGAwcIsVvaQPaJvEpSS0hok9QhRgy/gGOywslUMfjbTfP7kPNiZNwmHrFPIuk NxZDOEx7ySl0Ed1NqnAVdO+07VrDoZqPMKApA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GWC1KMyV1A6Rl/COql8OC8fu95Avmd8JBknQzjt01sI=; b=Ptx8QxNJ7xDR9H0xeE0pVOwESYOnh5/nvwwAUq1QdbJ96T1G1UXLlK5A0FEOp9Si4P RBDUP/FfebVDds979OIP+4ksNXljevSiNzWTzHRNuBiVzvK3ljFkwuIEtoPbX2dzdDGu AX8fI8ZVphbVDEGCZ6rGdIoKTdVhCNdCk/zCksM4pt0FBWNiHQo2EgjaeD3jUbcbAR0y H+tbgx21PMn6lsvV90RqKSx1fD9ZkoXiGsZREM24BYTb8Li94DA5zlQYZvbW7/Vk/NcW T+0GaHdmt1T79+sOCWEvUsTLYN5Qp7cj3/5qf+Bq9E8rd3oXOUaAplh/buNI0wZHzwWp qq0A== X-Gm-Message-State: AFqh2koumzcraw3pZNFmqi9woZmcv+VZ7IteVpex6zYqHnw/i3JSqL8E U3TSVIPsMMwmUoZ4AFOLaiBmbg== X-Google-Smtp-Source: AMrXdXuSnQEOljzY6lLfs+YGvp3fwfttCOozHsP9CcvWI1/0DsVhUuMOFjvhBsEacS82f57FARAOSA== X-Received: by 2002:a17:902:7fc2:b0:194:7ae9:c704 with SMTP id t2-20020a1709027fc200b001947ae9c704mr20251416plb.36.1674451916492; Sun, 22 Jan 2023 21:31:56 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id m3-20020a170902db0300b0018963b8e131sm9125244plx.290.2023.01.22.21.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Jan 2023 21:31:56 -0800 (PST) From: Doug Brown To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dan Williams , Simon Horman , libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v4 3/4] wifi: libertas: add new TLV type for WPS enrollee IE Date: Sun, 22 Jan 2023 21:31:31 -0800 Message-Id: <20230123053132.30710-4-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123053132.30710-1-doug@schmorgal.com> References: <20230123053132.30710-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add a define for the TLV type that will be used to add WPS enrollee information to probe requests. Suggested-by: Dan Williams Signed-off-by: Doug Brown --- drivers/net/wireless/marvell/libertas/types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/marvell/libertas/types.h b/drivers/net/wireless/marvell/libertas/types.h index de60becaac12..bad38d312d0d 100644 --- a/drivers/net/wireless/marvell/libertas/types.h +++ b/drivers/net/wireless/marvell/libertas/types.h @@ -93,6 +93,7 @@ union ieee_phy_param_set { #define TLV_TYPE_TSFTIMESTAMP (PROPRIETARY_TLV_BASE_ID + 19) #define TLV_TYPE_RSSI_HIGH (PROPRIETARY_TLV_BASE_ID + 22) #define TLV_TYPE_SNR_HIGH (PROPRIETARY_TLV_BASE_ID + 23) +#define TLV_TYPE_WPS_ENROLLEE (PROPRIETARY_TLV_BASE_ID + 27) #define TLV_TYPE_AUTH_TYPE (PROPRIETARY_TLV_BASE_ID + 31) #define TLV_TYPE_MESH_ID (PROPRIETARY_TLV_BASE_ID + 37) #define TLV_TYPE_OLD_MESH_ID (PROPRIETARY_TLV_BASE_ID + 291) From patchwork Mon Jan 23 05:31:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Brown X-Patchwork-Id: 13111678 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FA8BC54EAA for ; Mon, 23 Jan 2023 05:32:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231274AbjAWFcI (ORCPT ); Mon, 23 Jan 2023 00:32:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbjAWFb7 (ORCPT ); Mon, 23 Jan 2023 00:31:59 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51F7A193F0 for ; Sun, 22 Jan 2023 21:31:58 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id x24-20020a17090ab01800b00229f43b506fso9253955pjq.5 for ; Sun, 22 Jan 2023 21:31:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schmorgal.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K8+DZHs7W1LerSJJiFLS+9N/xwxbQMvpL/BRfvv3cOc=; b=P/l7eWG3BmqnQO4wqUvbJtHpHjt/A8z6m/zZ+3DWEF2oldbRXyY/fN8bll+3Y2Md3G 2xypAVdGzbhDgS1LvLFDv6rPdRMPTVznctC39cBKHZfBi6FOzt9iw0EeRKneCVVizPRd QRL+kI5Yc0Vv66O2EcAhHkPztNE5Quw0Nhu4k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K8+DZHs7W1LerSJJiFLS+9N/xwxbQMvpL/BRfvv3cOc=; b=kFt0HRiTfKED44YEvfeQBUBC7wdDZH4TIKfcpYBZwailjxwoIK9KE4FZSLYNamz+D7 hDXm75/dRD6Q6/Ta5zgn5cUy0LvRp70BllfvTDG20IqfrIm8xQBpTSalh5RNuAZvUKqd qqvOy0qA2Aqklbww2lidiwSq8EO2LztRX6h6dbSu9nQV+/0u/Ze5r96L43lMymJenXso 58hAWNqXAsNDO7ctmnQvKDrsL5ZaK+ykXqeB/fM0D8tHsER61rZrui80cHD2XpbgUbuN 037LoAgl/JCIcUC6CmqkPCOEzvPFaYrfgK3bMaXeooE5OGpcepTatydKbUIstgtjK+cu wWWg== X-Gm-Message-State: AFqh2kpj6J6qhSHoGVTEaRaST6jnJUiJbDrBhcjyP+F3nxLmKgiIAQBx mWqRmkvrUnqM0TB7WF4Nb2zZ8g== X-Google-Smtp-Source: AMrXdXvXg/t7MBwXdFbXlfQPyMVlnSAe6u2W38kuh1OetTjVTzqJUwCLvhTi5g5T7ot4DWW8VzbYSg== X-Received: by 2002:a17:902:6bc6:b0:194:9c69:290c with SMTP id m6-20020a1709026bc600b001949c69290cmr21761765plt.67.1674451917791; Sun, 22 Jan 2023 21:31:57 -0800 (PST) Received: from doug-ryzen-5700G.. ([192.183.212.197]) by smtp.gmail.com with ESMTPSA id m3-20020a170902db0300b0018963b8e131sm9125244plx.290.2023.01.22.21.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Jan 2023 21:31:57 -0800 (PST) From: Doug Brown To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dan Williams , Simon Horman , libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Doug Brown Subject: [PATCH v4 4/4] wifi: libertas: add support for WPS enrollee IE in probe requests Date: Sun, 22 Jan 2023 21:31:32 -0800 Message-Id: <20230123053132.30710-5-doug@schmorgal.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123053132.30710-1-doug@schmorgal.com> References: <20230123053132.30710-1-doug@schmorgal.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add compatibility with WPS by passing on WPS enrollee information in probe requests. Ignore other IEs supplied in the scan request. This also has the added benefit of restoring compatibility with newer wpa_supplicant versions that always add scan IEs. Previously, with max_scan_ie_len set to 0, scans would always fail. Suggested-by: Dan Williams Signed-off-by: Doug Brown Reviewed-by: Dan Williams --- drivers/net/wireless/marvell/libertas/cfg.c | 48 +++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/marvell/libertas/cfg.c b/drivers/net/wireless/marvell/libertas/cfg.c index 3f35dc7a1d7d..b700c213d10c 100644 --- a/drivers/net/wireless/marvell/libertas/cfg.c +++ b/drivers/net/wireless/marvell/libertas/cfg.c @@ -446,6 +446,41 @@ static int lbs_add_wpa_tlv(u8 *tlv, const u8 *ie, u8 ie_len) return sizeof(struct mrvl_ie_header) + wpaie->datalen; } +/* Add WPS enrollee TLV + */ +#define LBS_MAX_WPS_ENROLLEE_TLV_SIZE \ + (sizeof(struct mrvl_ie_header) \ + + 256) + +static int lbs_add_wps_enrollee_tlv(u8 *tlv, const u8 *ie, size_t ie_len) +{ + struct mrvl_ie_data *wpstlv = (struct mrvl_ie_data *)tlv; + const struct element *wpsie; + + /* Look for a WPS IE and add it to the probe request */ + wpsie = cfg80211_find_vendor_elem(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPS, + ie, ie_len); + if (!wpsie) + return 0; + + /* Convert the WPS IE to a TLV. The IE looks like this: + * u8 type (WLAN_EID_VENDOR_SPECIFIC) + * u8 len + * u8[] data + * but the TLV will look like this instead: + * __le16 type (TLV_TYPE_WPS_ENROLLEE) + * __le16 len + * u8[] data + */ + wpstlv->header.type = cpu_to_le16(TLV_TYPE_WPS_ENROLLEE); + wpstlv->header.len = cpu_to_le16(wpsie->datalen); + memcpy(wpstlv->data, wpsie->data, wpsie->datalen); + + /* Return the total number of bytes added to the TLV buffer */ + return sizeof(struct mrvl_ie_header) + wpsie->datalen; +} + /* * Set Channel */ @@ -672,14 +707,15 @@ static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy, /* - * Our scan command contains a TLV, consting of a SSID TLV, a channel list - * TLV and a rates TLV. Determine the maximum size of them: + * Our scan command contains a TLV, consisting of a SSID TLV, a channel list + * TLV, a rates TLV, and an optional WPS IE. Determine the maximum size of them: */ #define LBS_SCAN_MAX_CMD_SIZE \ (sizeof(struct cmd_ds_802_11_scan) \ + LBS_MAX_SSID_TLV_SIZE \ + LBS_MAX_CHANNEL_LIST_TLV_SIZE \ - + LBS_MAX_RATES_TLV_SIZE) + + LBS_MAX_RATES_TLV_SIZE \ + + LBS_MAX_WPS_ENROLLEE_TLV_SIZE) /* * Assumes priv->scan_req is initialized and valid @@ -728,6 +764,11 @@ static void lbs_scan_worker(struct work_struct *work) /* add rates TLV */ tlv += lbs_add_supported_rates_tlv(tlv); + /* add optional WPS enrollee TLV */ + if (priv->scan_req->ie && priv->scan_req->ie_len) + tlv += lbs_add_wps_enrollee_tlv(tlv, priv->scan_req->ie, + priv->scan_req->ie_len); + if (priv->scan_channel < priv->scan_req->n_channels) { cancel_delayed_work(&priv->scan_work); if (netif_running(priv->dev)) @@ -2114,6 +2155,7 @@ int lbs_cfg_register(struct lbs_private *priv) int ret; wdev->wiphy->max_scan_ssids = 1; + wdev->wiphy->max_scan_ie_len = 256; wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; wdev->wiphy->interface_modes =